Skip to content

Instantly share code, notes, and snippets.

@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 June 17, 2023 12:30 — 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);