Skip to content

Instantly share code, notes, and snippets.

Avatar

glowinthedark glowinthedark

  • URLError: <urlopen error [Errno 8] nodename nor servname provided, or not known>
  • HTTPError: HTTP Error 403: Forbidden
View GitHub Profile
@glowinthedark
glowinthedark / README.md
Created May 20, 2022 — forked from cuth/README.md
Font Size Bookmarklet
View README.md

Font Size Bookmarklet

Code

javascript:(function(){var getFontSize=function(el){return parseFloat(getComputedStyle(el,null)['font-size']);};document.addEventListener('wheel',function(e){if(!e.altKey)return;e.preventDefault();var el=e.target;var parent=el.parentElement;var size=getFontSize(el);while(parent&&size===getFontSize(parent)){el.style.fontSize='inherit';el=parent;parent=parent.parentElement;}if(e.wheelDelta>0){size+=1;}else{size-=1;}el.style.fontSize=size+'px';});}());
@glowinthedark
glowinthedark / textutil-postprocess.sh
Created Apr 2, 2022
massage the html generated by macos `textutil -convert html *.doc`
View textutil-postprocess.sh
find-replace-in-files-regex.py -s '[_]{3,}' -r '<hr>' -g '*.html'
find-replace-in-files-regex.py -s 'font: (\d{2})\.0px' -r 'font: \1pt' -g '*.html'
# remove line-height
find-replace-in-files-regex.py -s '(line-height:\s*[^;]+;)' -r '' -g '*.html'
find-replace-in-files-regex.py -s 'Times New Roman' -r 'Georgia, Baskerville, "PT Serif", Palatino' -l -g '*.html'
find-replace-in-files-regex.py -s '<p class="p\d"><br></p>' -r '' -l -g '*.html'
find-replace-in-files-regex.py -s '<span class="Apple-converted-space"> </span>' -r ' ' -l -g '*.html'
find-replace-in-files-regex.py -s '<style type="text/css">\n' -r '<style type="text/css">* {font-family: Georgia, Palatino; line-height: 1.61} body {padding: 1em 3em; text-align:center;margin-top: 5em;} .container{margin: 0 auto; width: 83%; max-width: 650px; text-align: left; padding: 0 10px 20px; } @media screen and (max-width:600px) { body {padding: 0; margin: 0} .container {margin:0; width:auto; text-align:left; padding:.7em;} } \n' -g '*.html'
@glowinthedark
glowinthedark / install-jupyter-notebook-with-extensions.sh
Last active Mar 24, 2022
Install jupyter notebook with extensions and optional bash and js kernels
View install-jupyter-notebook-with-extensions.sh
pip3 install ipython
pip3 install notebook
pip3 install jupyter
echo 'Installing nbextensions: https://github.com/ipython-contrib/jupyter_contrib_nbextensions https://jupyter-contrib-nbextensions.readthedocs.io/en/latest/install.html'
pip3 install jupyter_contrib_nbextensions
jupyter contrib nbextension install --user
echo 'Installing nbextensions_configurator: https://github.com/Jupyter-contrib/jupyter_nbextensions_configurator'
pip3 install jupyter_nbextensions_configurator
@glowinthedark
glowinthedark / 0dedict.py
Last active Apr 15, 2022 — forked from josephg/0dedict.py
Apple dictionaries
View 0dedict.py
#!/usr/bin/env python3
# -*- coding: ascii -*-
# Thanks to commenters for providing the base of this much nicer implementation!
# Save and run with $ python 0dedict.py
# You may need to hunt down the dictionary files yourself and change the awful path string below.
# This works for me on MacOS 10.14 Mohave
# /System/Library/AssetsV2/com_apple_MobileAsset_DictionaryServices_dictionaryOSX/0cab8989af7642f18332cfdc038d97017d28586a.asset/AssetData/Spanish - English.dictionary/Contents/Resources/Body.data
import sys
@glowinthedark
glowinthedark / disable_gapps_android11_noroot.sh
Last active Mar 11, 2022
gapps APK packages for Android 11, open_gapps-arm64-11.0-stock-20220215.zip
View disable_gapps_android11_noroot.sh
pm disable-user --user 0 com.android.chrome
pm disable-user --user 0 com.android.systemui.plugin.globalactions.wallet
pm disable-user --user 0 com.android.vending
pm disable-user --user 0 com.google.android.GoogleCamera
pm disable-user --user 0 com.google.android.apps.books
pm disable-user --user 0 com.google.android.apps.docs
pm disable-user --user 0 com.google.android.apps.magazines
pm disable-user --user 0 com.google.android.apps.maps
pm disable-user --user 0 com.google.android.apps.messaging
pm disable-user --user 0 com.google.android.apps.nexuslauncher
View json_beautify.py
#!/usr/bin/env python3
import json
import sys
data = json.load(open(sys.argv[1]))
out = len(sys.argv) > 2 and open(sys.argv[2], 'w') or sys.stdout
print(json.dumps(data, indent=1, ensure_ascii=False), file=out)
View PyQt5-built-in-icons.py
import sys
from PyQt5.QtWidgets import (QApplication, QGridLayout, QPushButton, QStyle,
QWidget)
class Window(QWidget):
def __init__(self):
super(Window, self).__init__()
icons = [
View bcn-immigration.py
import pandas as pd
from google.colab import data_table
data_table.enable_dataframe_formatter()
df = pd.read_html('https://www.idescat.cat/pub/?id=aec&n=272&t=2020&lang=es', thousands='.')[0]
df.drop(df.tail(1).index, inplace=True)
COLS = ['Barcelona', 'Girona', 'Lleida', 'Tarragona', 'Cataluña']
df[COLS] = df[COLS].apply(pd.to_numeric)
@glowinthedark
glowinthedark / get_gists.py
Last active Mar 24, 2022 — forked from leoloobeek/get_gists.py
Download all gists for a specific user
View get_gists.py
#!/usr/bin/env python3
#
# download all gists for a user, pass github user as first arg
# if the gists have already been downloaded before then update them
import json
import os
import re
import requests
View ttml2-to-srt.py
#!/usr/bin/env python3
# TTML2 to SRT subtitle converter
# USAGE:
# ttml2srt.py matrix.ttml2
import sys
import xml.etree.ElementTree as ET
from pathlib import Path