Skip to content

Instantly share code, notes, and snippets.

SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL';
DROP SCHEMA IF EXISTS `verbivoredb` ;
CREATE SCHEMA IF NOT EXISTS `verbivoredb` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci ;
USE `verbivoredb`;
-- -----------------------------------------------------
-- Table `verbivoredb`.`words`
@prehensile
prehensile / HelloGrowlPython.py
Created November 13, 2010 04:12
Simple GrowlPython example
import Growl
# set up a new GrowlNotifier with our name and a list of the notifications we'll be posting
gn = Growl.GrowlNotifier( "YourAppName", ["A readable notification name", "another readable notification name"] )
# register the notifier with Growl
gn.register()
# post a notification
gn.notify( "Notification name from the list we registered earlier", "Notification Title", "Notification body" )
@prehensile
prehensile / kube-resources.py
Last active October 8, 2015 04:48
Various Kubernetes / Google Container Engine tools
#!/usr/bin/env python
##
# kube-resources.py
# Collate and report Kubernetes pod usages vs. node limits.
#
# Assumes `kubectl` is installed and available.
#
# Author: Henry Cooke, me@prehensile.co.uk
# Version: 20150816
@prehensile
prehensile / gist:5926461
Last active December 19, 2015 08:29
Fetch a random image referenced by Bing News RSS thumbnails.
import urlparse
import urllib2
import BeautifulSoup as Soup
import random
class BingSource:
def __init__( self ):
self.rss_url = "http://www.bing.com/news/?format=RSS"
def get_image_url( self ):
@prehensile
prehensile / BigPicture.py
Created November 14, 2010 04:20
A Python script to download the latest image from Boston Big Picture's RSS.
# BigPicture.py
#
# A Python script to download the latest image from Boston Big Picture's RSS.
# I use it from a launchd job to set the wallpaper on my Mac ;)
#
# Requires:
# Universal Feed Parser (http://www.feedparser.org/)
# for RSS fetch & parse
# BeautifulSoup (http://www.crummy.com/software/BeautifulSoup/)
# for parsing HTML in the RSS feed
@prehensile
prehensile / CropCircles.txt
Last active December 7, 2016 21:57
A list of algorithmic "crop circles" spotted in stock market trading patterns by Nanex researchers. Extracted from: http://www.nanex.net/FlashCrash/CCircleDay.html
Seen Too Much
Broken Zanti
Living On The Edge
Wild Thing
Wild Thing Edge
The Click
Zapata
Blue Zinger
Petting Zoo
Red Tide
@prehensile
prehensile / oulipo.py
Last active January 6, 2018 12:32
Oulipo S+7 constraint, implemented in Python 3 & NLTK
# an implementation of Oulipo S+7
# see https://en.wikipedia.org/wiki/Oulipo
from nltk import pos_tag, word_tokenize
from nltk.corpus import wordnet
text = "I am sitting in a room different from the one you are in now. I am recording the sound of my speaking voice and I am going to play it back into the room again and again until the resonant frequencies of the room reinforce themselves so that any semblance of my speech, with perhaps the exception of rhythm, is destroyed. What you will hear, then, are the natural resonant frequencies of the room articulated by speech. I regard this activity not so much as a demonstration of a physical fact, but more as a way to smooth out any irregularities my speech might have."
# download nltk tokeniser if missing
try:
@prehensile
prehensile / timezone.py
Last active March 22, 2018 23:10
Parses timezone strings in ISO 8601 format to datetime.tzinfo objects
import datetime
import re
import logging
class TimeZone( datetime.tzinfo ):
def __init__( self, offset ):
# expects offset in ISO 8601 format e.g '+00:00', '+0000', 'Z'
# see https://en.wikipedia.org/wiki/ISO_8601#Time_zone_designators
@prehensile
prehensile / airbnb-search.py
Created July 18, 2017 21:04
A Python script which crawls airbnb search results for a given set of keywords.
#!/usr/bin/env python
#########################
# airbnb-search.py
#########################
# by prehensile, 18/07/17
#########################
# Crawl airbnb search results (descriptions and reviews) for keywords.
# A quick, dirty and brittle set of hacks.
# Very likely to break the next time anything changes in airbnb's HTML.
@prehensile
prehensile / gnm-server.js
Created May 8, 2018 09:09
Bits and pieces of gig'n'mix
// http://ejohn.org/blog/ecmascript-5-strict-mode-json-and-more/
"use strict";
// Optional. You will see this name in eg. 'ps' or 'top' command
process.title = 'node-chat';
// Port where we'll run the websocket server
var webSocketsServerPort = 1337;
// websocket and http servers