Skip to content

Instantly share code, notes, and snippets.

@petermolnar
petermolnar / wp-cron
Last active January 5, 2018 10:42
cron file for wordpress backup and wp-cron using wp-cli
MAILTO="you@domain.com"
SHELL=/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
# prerequisities:
# sudo wget -q -O/usr/local/bin/wpcli https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar; sudo chmod 0755 /usr/local/bin/wpcli
# WP CRON
* * * * * wpuser cd /path/to/wordpress; wpcli cron event run --due-now --quiet
@petermolnar
petermolnar / unfix-all-the-toolbars.user.js
Last active June 29, 2022 07:25 — forked from vbuaraujo/unfix-all-the-toolbars.user.js
GreaseMonkey script to remove "position: fixed" from webpages
// ==UserScript==
// @name unfix-all-the-toolbars
// @description Removes "position: fixed" style from elements, unfixing "toolbars" and the such.
// @namespace http://inf.ufrgs.br/~vbuaraujo/
// @include *
// @version 1.2
// @grant none
// ==/UserScript==
@petermolnar
petermolnar / logs2pidgin.py
Last active March 4, 2018 21:09
Python script to convert varios logs (MSN Plus!, Skype v2, Trillian v3, etc) to Pidgin
import os
import sqlite3
import logging
import re
import glob
import sys
import hashlib
import arrow
import argparse
from bs4 import BeautifulSoup
@petermolnar
petermolnar / backup-github.sh
Last active September 3, 2020 20:25
backup-github
#!/usr/bin/env bash
function usage () {
echo "backup-github.sh
A tiny bash script to backup own and starred public github repositories
Usage:
backup-github.sh GITHUB_USERNAME DIRECTORY_TO_BACKUP_TO"
exit 1
@petermolnar
petermolnar / themeswitcher.css
Last active December 11, 2023 13:06
automatic (prefers-color-scheme) and manual CSS theme switcher with vanilla javascript snippet
.theme input {
display: none;
}
.theme {
margin: 0 0.3em 0 0;
}
.theme input + label {
color: #f90;
@petermolnar
petermolnar / facebook2wordpress.py
Last active February 22, 2019 10:57
facebook json export to wp-cli import bash
import json
import arrow
import os
import logging
from shlex import quote
from pprint import pprint
base = '/web/blog.pakuauk.com/exports/facebook-export'
with open('facebook-export/posts/posts.json', 'rt') as f:
@petermolnar
petermolnar / gist:b5bd11d202ca0eec68a28d39c89b1004
Created May 22, 2019 14:04
extremely simple vanilla js lightbox
var links2img = []
function initLightbox() {
var links = document.getElementsByTagName("a");
for(var i = links.length; i--; ) {
var imginside = links[i].getElementsByTagName("img");
if (imginside.length == 1 ) {
links2img.push(links[i])
console.log(links[i]);
links[i].onclick = openLightbox;
@petermolnar
petermolnar / wallabag2epub.sh
Created August 5, 2019 11:20
exporting entries from wallabag
#!/usr/bin/env bash
# script needs env vars passed, needs to be called as:
# WALLABAG_ID='client_id' WALLABAG_SECRET='client_secret' WALLABAG_USERNAME='username' WALLABAG_PASSWORD='password' WALLABAG_URL='url' bash wallabag2epub.sh
# requires `jq` https://stedolan.github.io/jq/ because nobody should deal with parsing json with sed
function err {
>&2 echo $1
}
@petermolnar
petermolnar / image.initmeta.sh
Last active September 3, 2020 21:09
set image license and right metadata to please Google
#!/bin/bash
if [ -z "$1" ]; then
echo "Use: image.initmeta PHOTO"
exit 1
fi
year="$(exiftool -s -EXIF:DateTimeOriginal "$1" | awk '{print $3}' | cut -d":" -f1)"
artist="Peter Molnar"
rights="CC BY-NC-ND 4.0 ${year} ${artist} <mail@petermolnar.net>"
@petermolnar
petermolnar / 404.json
Last active December 29, 2020 14:40
petermolnar.net redirects, rewrites, gones, etc.
{
"bad_request": [
".*%22https?:.*",
"^/xmlrpc\\.php$",
"^.*\\.pHp5$",
"^.*\\.phtml$",
"^/_timthumb_.*$",
"^.*?flattrss_redirect.*$",
"^.*/None",
"…"