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 / 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" \
@glowinthedark
glowinthedark / gmail-imap4.py
Created April 11, 2019 18:39
GMail IMAP4 reader (IMAP has to be enabled in Gmail > Settings)
#!/usr/bin/env python
# Run without args to get message headers for the last 3 days.
# gmail.py 10 - display message headers for the last 10 days.
# gmail.py 10 full - display message headers with bodies.
import sys
import os
import imaplib
import getpass
@glowinthedark
glowinthedark / javascript-reduce-example.js
Created June 13, 2019 14:52
javascript reduce example
var args = {
quoted_prop1: " oneEE",
quoted_prop1aaaa: " first level another",
quoted_I18N__prop2: " tWo (must be under I18N)",
quoted_I18N__weprop2bbb: " tWo and a half (must be under I18N)",
quoted_API__JUJUJ__prop3: " THREE",
quoted_API__JUJUJ__prop3BBBB: " THREE--beeee",
quoted_API__JUJUJ__LAST__prop3ZZZZ: " THREE--zzzzz",
quoted_API__prop4: " __FOUR__",
quoted_prop3232aaaa: " more first level another",
@glowinthedark
glowinthedark / bottle file server
Created July 6, 2019 22:57
Python Bottle file server with directory index
#!/usr/bin/env python3
import os
import sys
import bottle
from bottle import run, static_file
def resolve_path(path):
@glowinthedark
glowinthedark / apktool-installer.sh
Created August 14, 2019 17:32
apktool installer
# Get latest version from https://bitbucket.org/iBotPeaches/apktool/downloads
export APKTOOL_VERSION=2.4.0
sudo -E sh -c 'wget https://bitbucket.org/iBotPeaches/apktool/downloads/apktool_$APKTOOL_VERSION.jar -O /usr/local/bin/apktool.jar'
sudo chmod +r /usr/local/bin/apktool.jar
sudo sh -c 'wget https://raw.githubusercontent.com/iBotPeaches/Apktool/master/scripts/linux/apktool -O /usr/local/bin/apktool'
sudo chmod +x /usr/local/bin/apktool
# https://gist.github.com/bmaupin/48140926ce11fbeddec2