Skip to content

Instantly share code, notes, and snippets.

@GiovanniMoretti
GiovanniMoretti / bookmarklet.js
Last active April 10, 2019 22:16 — forked from eimfach/bookmarklet.js
medium.com print bookmarklet
javascript:(function(){
var iframes = document.getElementsByTagName('iframe');
for(var i = 0; i < iframes.length; i++)
{iframes[i].width = "auto"; }
var content="@media print { img {max-width: 640px !important;} iframe { width: auto; display: block; } .section-inner.sectionLayout--insetColumn { max-width: 1024px !important; padding: padding: 0px 0px !important; } }";
var style = document.createElement('style');
style.appendChild(document.createTextNode(content));
document.getElementsByTagName('head')[0].appendChild(style);
alert("Print stylesheet tweaked - use 'File/Print Preview' to check");
})();
@GiovanniMoretti
GiovanniMoretti / patchBrokenHugoCategoryandTagLinks.py
Last active January 15, 2020 10:21
If UglyURLs = True, Hugo version 0.15 produced broken links to the category and tag pages. This Python 3 script moves and renames the category and tag index files, so that for these pages, we're pretending the UglyURLs=False.
RESTORE_DIR="/home/zachary/annex-documents-restored"
cat annex-unused-keys | tail -n +4 | head -n -5 | awk -e '{print $2}' | while read shasum; do
cd /shared
if git log --oneline -1 --stat -S"${shasum}" | grep "^ documents/" >/dev/null ; then
#echo "Object: ${shasum}"
document="$(git log --oneline -1 --stat -S"${shasum}" | head -n 2 | tail -n 1 | sed -e 's/|.*//' | sed -r -e 's/^ +//' | sed -r -e 's/ +$//')"
#echo "Document: ${document}"
source_file="$(git annex examinekey ${shasum} --format='/shared/.git/annex/objects/${hashdirmixed}${key}/${key}')"
#echo "File location: ${source_file}"
target="$RESTORE_DIR/$document"
import kivy
kivy.require('1.4.1')
import random, os, sys, os.path
from kivy.app import App
from kivy.uix.image import Image
from kivy.core.window import Window
from kivy.clock import Clock
from kivy.config import Config
from plyer import notification