Skip to content

Instantly share code, notes, and snippets.

View glowinthedark's full-sized 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 / dsl2appledict.sh
Created March 25, 2019 12:49
Convert Lingvo DSL source to AppleDict format
#!/usr/bin/env bash
set -x
PYGLOSSARY_HOME=~/projects/pyglossary
usage="Convert Lingvo DSL source to AppleDict\n
USAGE:\n
=====\n
\t${0##*/} <dictionary.dsl|dictionary.dsl.dz> \n
@glowinthedark
glowinthedark / find-replace-in-file-recursive-regex.py
Last active December 6, 2022 18:13
Recursively find and replace text in files under a specific folder with colorized preview of changed data in dry-run mode
#!/usr/bin/env python
"""
Recursively find and replace text in files under a specific folder with preview of changed data in dry-run mode
============
Example Usage
---------------
**See what is going to change (dry run):**
@glowinthedark
glowinthedark / rename-files-regex.py
Last active December 6, 2022 18:02
replace files using regular expressions
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# NOTES
# - to search recursively in subfolders pass `--glob "**/*.*"`
import argparse
import re
import sys
@glowinthedark
glowinthedark / generate_directory_index.py
Last active February 7, 2022 11:00
Generate directory index (Python 2) Python 3 version is here: https://gist.github.com/glowinthedark/174df43f469c7ef05f6358f53afe05c6
#!/usr/bin/env python
# requires Python 2
# (Python 3 version: https://gist.github.com/glowinthedark/174df43f469c7ef05f6358f53afe05c6)
# Recursively generate index.html files for
# all subdirectories in a directory tree
##########################################################################
## ❗️❗️❗️ WARNING: This version is outdated and unmaintained!
@glowinthedark
glowinthedark / WordToTextConverter.java
Last active April 9, 2019 13:55
PoiWordToTextConverter — minimal POI-based word to text converter (DOC, DOCX)
// should go into the `src` folder relative to the `pom.xml` file
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import org.apache.poi.POITextExtractor;
import org.apache.poi.extractor.ExtractorFactory;
import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
import org.apache.xmlbeans.XmlException;
@glowinthedark
glowinthedark / nocss.js
Created April 11, 2019 18:29
Browser bookmarklet to remove all styles
javascript:(function(){for(i=0;i<document.styleSheets.length;i++){document.styleSheets.item(i).disabled=true;}all=document.getElementsByTagName('*');for(i=0;i<all.length;i++){var s=all[i].style;s.cssText='';s.width='';s.padding='1px';s.margin='1px';s.fontSize='12pt';s.lineHeight='150%';if(s.position=='absolute'||s.position=='relative'||s.position=='fixed')s.position='static';}var st=document.body.style;st.paddingLeft='100px';st.paddingRight='100px';st.backgroundImage='none';st.backgroundColor='#fff';st.color='#000';})()
@glowinthedark
glowinthedark / python_suds_web_service_example.py
Created April 11, 2019 18:30
Python Example Web Service using suds and lxml
import suds
import sys
import lxml.etree as etree
def xml_pretty_print(doc):
return etree.tostring(doc, pretty_print = True)
url = "http://www.webservicex.net/stockquote.asmx?wsdl"
# get ticker symbol as command line arg or use default
@glowinthedark
glowinthedark / Export-OSX-Notes-to-HTML.applescript
Created April 11, 2019 18:31
Export notes from the OSX Notes.app to separate HTML files prefixed with the creation timestamp.
on buildTitle(originalText)
set normalizedText to my replace(originalText, ":", "-")
set normalizedText to my replace(normalizedText, "|", "")
set normalizedText to my replace(normalizedText, "{", "")
set normalizedText to my replace(normalizedText, "}", "")
set finalTitle to my firstChars(normalizedText, 30)
return finalTitle
end buildTitle
on replace(originalText, fromText, toText)
@glowinthedark
glowinthedark / SimpleAuthServer.py
Created April 11, 2019 18:32
SimpleAuthServer: A SimpleHTTPServer with authentication
#!/usr/bin/env python
## SAVED FROM: https://gist.github.com/fxsjy/5465353
import BaseHTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler
import sys
import base64
import socket
@glowinthedark
glowinthedark / tea-linux.sh
Created April 11, 2019 18:33
Bash Tea-timer
#!/usr/bin/env bash
DRIP="/usr/share/sounds/gnome/default/alerts/drip.ogg"
mpv --no-terminal $DRIP && notify-send -t 1 "TEA" "Started at: $(date +'%A, %d-%B-%y, %H:%M:%S')" --icon=dialog-information
declare -A ticks=( \
[50]="50 sec" \
[20]="1 min 10 sec" \
[20]="1 min 30 sec" \