Skip to content

Instantly share code, notes, and snippets.

View wilhelm-murdoch's full-sized avatar
💀
Busy being spoopy.

Wilhelm Murdoch wilhelm-murdoch

💀
Busy being spoopy.
View GitHub Profile
#!/usr/bin/env python
"""
urlnorm.py - URL normalisation routines
urlnorm normalises a URL by;
* lowercasing the scheme and hostname
* taking out default port if present (e.g., http://www.foo.com:80/)
* collapsing the path (./, ../, etc)
* removing the last character in the hostname if it is '.'
@wilhelm-murdoch
wilhelm-murdoch / redoize.py
Last active December 15, 2015 22:09
A decorator used to cache a method's output in redis.
# -*- coding: utf-8 -*-
from functools import wraps
import redis
from flask import Flask, request
from datetime import datetime
app = Flask(__name__)
# -*- coding: utf-8 -*-
@wilhelm-murdoch
wilhelm-murdoch / gist:5909320
Created July 2, 2013 13:32
Google image chart demo...
https://chart.googleapis.com/chart?cht=bvs&chs=750x50&chd=t:0,0,0,0,0,10,50,60,80,40&chco=EBF2FF&chbh=25,1&chm=r,FFFFFF,0,-0.01,0.01,1|R,FFFFFF,0,-0.01,0.01,1
@wilhelm-murdoch
wilhelm-murdoch / generate_inkwell_articles.py
Last active December 19, 2015 23:59
A python script for creating a ton of test articles for Inkwell.
import sys
import os
from random import choice
if len(sys.argv) < 2:
print 'Usage: python {} /absolute/path/to/article/directory'.format(os.path.basename(__file__))
exit()
content = """title: Pokedex for {}
summary: true
@wilhelm-murdoch
wilhelm-murdoch / arthur.itermcolors
Last active September 30, 2016 21:29
My personal fish shell setup for iTerm 2 ...
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Blue Component</key>
<real>0.16470588743686676</real>
<key>Green Component</key>
<real>0.20784313976764679</real>
@wilhelm-murdoch
wilhelm-murdoch / aggregation_test.py
Created August 18, 2013 07:52
Testing MongoDB aggregation problem. Creates 10 posters and randomly assigns them to 100 posts. Aggregation query returns mapping of poster to latest post sorted by creation date in descending order.
from pymongo import MongoClient
import datetime
import bunch
from faker import Faker
from random import choice
client = MongoClient(host="localhost", port=27017)
faker = Faker()
posters = []
@wilhelm-murdoch
wilhelm-murdoch / ngNumber.js
Created September 10, 2013 04:19
A better variation of AngularJS' ngNumber filter ...
/**
* Number Filter
* @Param input The number to format
* @Param fractionSize Nubmer of decimal places to round to; defaults to 2
* @Param groupSep Number group separator; defaults to a single space ' '
* @Param decimalSep Decimal place separator; defaults to single period
* @return string, ex: 1 234 345
*/
var DECIMAL_SEP = '.' // change to override default
var GROUP_SEP = ' ' // change to override default
Gost - A simple command line utility for easily creating Gists for Github
Usage:
gost (--file=<file> | --clip) [--name=<name>] [--description=<description>] [--token=<token>] [--public]
gost (--help | --version)
Options:
-t --token=<token> Optional Github API authentication token. If excluded, your Gist will be created anonymously.
-f --file=<file> Create a Gist from file.
-n --name=<name> Optional name for your new Gist.
Gost - A simple command line utility for easily creating Gists for Github
Usage:
gost (--file=<file> | --clip) [--name=<name>] [--description=<description>] [--token=<token>] [--public]
gost (--help | --version)
Options:
-t --token=<token> Optional Github API authentication token. If excluded, your Gist will be created anonymously.
-f --file=<file> Create a Gist from file.
-n --name=<name> Optional name for your new Gist.
Gost - A simple command line utility for easily creating Gists for Github
Usage:
gost (--file=<file> | --clip) [--name=<name>] [--description=<description>] [--token=<token>] [--public]
gost (--help | --version)
Options:
-t --token=<token> Optional Github API authentication token. If excluded, your Gist will be created anonymously.
-f --file=<file> Create a Gist from file.
-n --name=<name> Optional name for your new Gist.