Skip to content

Instantly share code, notes, and snippets.

@quandyfactory
quandyfactory / hamiton police snow advisory 2014-02-05.txt
Created February 5, 2014 19:19
Hamilton Police Service declare a Snow Advisory Warning for February 5, 2014
Snow Advisory Warning Declared
For Immediate release: February 5th, 2014
Hamilton, ON – The Hamilton Police Service (HPS) is advising motorists in Hamilton what the expectations and responsibilities are during a snow advisory warning with the appropriate procedures to follow:
Snow Advisory Warning
* City of Hamilton Transportation contacts HPS issuing snow warning
* HPS issues warning to public through media
@quandyfactory
quandyfactory / janeswalk.markdown
Last active August 29, 2015 14:00
My talking notes for this Saturday's Jane's Walk along James Street South, Hamilton, Otario.

Jane's Walk: James Street South

"Cities need old buildings so badly it is probably impossible for vigorous streets and districts to grow without them. ... Old ideas can sometimes use new buildings. New ideas must use old buildings."

Walk starts at the Queen Victoria statue, Gore Park, at Noon.

Three Tales of a Street

  • Amid all the observations, anecdotes and asides
  • Three distinct stories about James Street South:
@quandyfactory
quandyfactory / get_fringe_plays.py
Created July 29, 2014 23:46
get_fringe_plays.py
#!/usr/bin/env python
"""Code I used to download all the details for the 2014 Hamilton Fringe Festival plays and convert them into a JSON file."""
from bs4 import BeautifulSoup as bs
import json
import requests
import xlrd
base_url = 'http://hamiltonfringe.ca/shows/'
@quandyfactory
quandyfactory / tweet.json
Last active August 29, 2015 14:09
JSON representation for Tweet ID 532191393062854656
{
"created_at":"Tue Nov 11 15:21:30 +0000 2014",
"id":532191393062854656,
"id_str":"532191393062854656",
"text":"Empty parking spaces in city-owned John\/Rebecca lot. We need affordable housing, not cheap parking @greg_tedesco http:\/\/t.co\/91JnJLNlwL",
"source":"\u003ca href=\"http:\/\/twitter.com\/download\/android\" rel=\"nofollow\"\u003eTwitter for Android\u003c\/a\u003e",
"truncated":false,
"in_reply_to_status_id":null,
"in_reply_to_status_id_str":null,
"in_reply_to_user_id":null,
#!/usr/bin/env python
# coding: utf-8
"""Calculates kinetic energy for a moving object at a given mass and speed"""
import locale
locale.setlocale(locale.LC_ALL, '')
objects = (
{'name': 'Bicycle', 'mass': 100,},
@quandyfactory
quandyfactory / longurl.py
Created December 22, 2009 21:24
Code to run Wayne MacPhail's URL Lengthener.
def get_longurl(path):
"""
Code to run Wayne MacPhail's URL Lengthener.
TODO: re-populate form fields on failed post.
"""
output = []
addline = output.append
formfields = web.input(longurl='', url='')
longurl = tools.strip_html(formfields.longurl.strip().lower().replace('http://', '').replace('/','_'))
url = tools.strip_html(formfields.url.strip().lower())
@quandyfactory
quandyfactory / iterchars.py
Created January 7, 2010 15:31
Creates an iterator of ascii characters from 32 (space) to 126 (tilde)
def iterchars():
"""
Creates an iterator of ascii characters from 32 (space) to 126 (tilde)
"""
for x in range(32, 127):
yield x
@quandyfactory
quandyfactory / hasmethods.py
Created February 4, 2010 15:53 — forked from vlazzle/hasmethods.py
hasmethods function.
# if there are any others who don't care much for try ... catch AttributeError
def hasmethods(obj, *meth_names):
return all(
hasattr(
# if it calls like a method it's a method
getattr(obj, m, None),
'__call__'
) for m in meth_names
)
@quandyfactory
quandyfactory / anagram.py
Created April 14, 2010 16:46
Determine whether two strings are anagrams.
def anagram(string1, string2, ignore_whitespace=False):
"""Determines whether two strings are anagrams."""
if ignore_whitespace==True:
import re
string1, string2 = re.sub('\s', '', string1), re.sub('\s', '', string2)
if len(string1) != len(string2): return False
list1, list2 = [c for c in string1].sort(), [c for c in string2].sort()
if list1 != list2: return False
return True