Skip to content

Instantly share code, notes, and snippets.

@lwcorp
lwcorp / linkedin_group_sorting.js
Created February 3, 2025 21:23
LinkedIn Group sorting (both in search mode and when listing a user's groups) - including auto scrolling and optionally show just joined groups
(async function() {
// Helper: Converts text like "12K members" or "27,289 members" to a number.
// This version considers text until the first space or line break.
function parseMemberCount(text) {
text = text.replace(/,/g, '').trim();
const token = text.split(/[\s\n]/)[0];
const match = token.match(/([\d.]+)([KkMm]?)/);
if (!match) return 0;
let num = parseFloat(match[1]);
const suffix = match[2].toLowerCase();
@lwcorp
lwcorp / linkedin_dark_mode_minimize_messages_inline.js
Created February 3, 2025 21:20
Force LinkedIn to respect system (e.g. Dark) mode, and to minimize message overlay
javascript:function settheme(){document.cookie="li_theme=system; path=/; domain=."+location.hostname+"; secure; SameSite=None",dynamic&&document.documentElement.classList.toggle("theme--dark")}function minimizemsg(){var e,t="voyager-web:msg-overlay-state",i="_listBubble",o=localStorage.getItem(t);!o||(o=(e=JSON.parse(o))[0])&&o[i]&&(o[i].isMinimized=!0,localStorage.setItem(t,JSON.stringify(e))),dynamic&&(e="#msg-overlay>div",0<(e=document.querySelectorAll(e)).length&&((e=e[0]).classList.contains("msg-overlay-list-bubble--is-minimized")||e.querySelector("header>div:last-of-type>button:last-of-type").click()))}function%20limitdomain(){"linkedin.com"==location.hostname.replace("www.","")&&(settheme(),minimizemsg(),dynamic||location.reload())}var%20dynamic=!1;limitdomain();
@lwcorp
lwcorp / cpanel_wsgi_template.py
Last active March 21, 2025 01:55
Run Python code via cPanel without restarting or timing out, and also use Flask
import os
import json
import html
import signal
from datetime import datetime
from flask import Flask, render_template, request, jsonify
# Check if `signal.alarm` is supported
signal_supported = hasattr(signal, 'SIGALRM')
if signal_supported:
@lwcorp
lwcorp / topic-api-classifier-inline.js
Last active February 3, 2025 21:22
Adds a download button to the Domain/App Category Classifier of chrome://topics-internals
javascript:adder();function adder(){var a="[slot=\"tab\"]:nth-of-type(2)";a=document.querySelectorAll(a),0<a.length&&(a=a[0],"false"==a.getAttribute("aria-selected")&&a.click(),addDownloadButton())}function addDownloadButton(){var a;if(a=document.querySelectorAll("#download"),0==a.length){let a=document.createElement("button");a.id="#download".replace(/[#\.]/,""),a.textContent="Download",a.href="#",a.onclick=function(){return downloader(),!1};let b=document.querySelector("#hosts-classification-button");b.parentNode.insertBefore(a,b.nextSibling)}}function downloader(){let a="#hosts-classification-result-table",b="td";if(b=a+" "+b,a=document.querySelectorAll(a),0<a.length&&0<document.querySelectorAll(b).length){let b=formatTableToCSV(a[0]),c=new Blob([b],{type:"text/csv;charset=utf-8;"}),d=document.createElement("a");d.href=URL.createObjectURL(c),d.setAttribute("download","classification_results.csv"),document.body.appendChild(d),d.click(),document.body.removeChild(d)}}function formatTableToCSV(a){let b=[],c=a.
@lwcorp
lwcorp / cronner_auto.sh
Created March 25, 2024 14:08
Automatically add a command to cronjob to 1 minute later and remove once it starts (good for testing if a command runs well in a cronjob)
#!/bin/bash
# For example a Python command
user=type your user
folder=type your folder
command="source $HOME/.bashrc && source /home/$user/myenv/bin/activate && cd /home/$user/public_html/$folder && python index.py -run"
if [ "$1" = "-dummy" ]; then
command="$command $1"
elif [ "$2" = "-dummy" ]; then
@lwcorp
lwcorp / go_run.sh
Created March 25, 2024 14:07
Run a Go script portably and with parameters optionally in the background (allowing to keep working normally in Terminal)
#!/bin/bash
background=true
MAIN_PATH=/home/youruser/public_html/yourfolder
MAIN_FILE=your Go script WITHOUT extension
export TMPDIR=$MAIN_PATH/tmp/
cd $MAIN_PATH
if ! $background; then
go run $MAIN_FILE.go "$@"
@lwcorp
lwcorp / darkthemeswitcher-inline.js
Last active January 1, 2025 19:29 — forked from frontdevops/darkthemeswitcher-inline.js
Simple Dark Theme Bookmarklet for web pages, but without affecting iframes (like embedded YouTube) and images that use background-image= instead of <img
javascript:(d=>{var css=`:root{background-color:#fefefe;filter:invert(100%)}*{background-color:inherit}iframe,[style*="background-image:"]:not([style$=".svg)"]),img:not([src*=".svg"]),video{filter:%20invert(100%)}`,style,id="dark-theme-snippet",ee=d.getElementById(id);if(null!=ee)ee.parentNode.removeChild(ee);else%20{style%20=%20d.createElement('style');style.type="text/css";style.id=id;if(style.styleSheet)style.styleSheet.cssText=css;else%20style.appendChild(d.createTextNode(css));(d.head||d.querySelector('head')).appendChild(style)}})(document)
@lwcorp
lwcorp / pastepad_he-inline.js
Last active October 16, 2020 09:56
Bookmarklet - Add Hebrew/RTL support FiveFilters.org's PastePad - when pushing to Kindle/creating files, make the text become right-to-left if it contains Hebrew
javascript:function add_heb_support_prepare(a){var b,c,d,e,f=document.querySelectorAll("input[type=\"submit\"]");for(e=0;e<f.length;e++)f[e].setAttribute("onclick","add_heb_support()");b=`
function add_heb_support() {
var prefix='<html lang="he" />', source_value = CKEDITOR.instances.body.getData(), source = '#cke_contents_body>textarea', source_btn = '#cke_34';
if (document.querySelectorAll(source).length==0)
document.querySelector(source_btn).click();
if(source_value.indexOf(prefix) == -1 && contains_heb(source_value))
CKEDITOR.instances.body.setData(prefix + source_value);
}
function contains_heb(str) {
return (/[\u0590-\u05FF]/).test(str);