Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / chunk.py
Created May 12, 2015 09:49
A Python function to chop up a string into chunks with a maximum length for each chunk. Chops at whitespace for nice separation, rather than just every n characters. Useful, for, say, breaking up a long piece of text into multiple tweets.
import re
def chunk_string( str_in, max_chunk_length ):
l = len(str_in)
chunks =[]
if l <= max_chunk_length:
chunks = [str_in]
else:
@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 / prehensile.networkwatcher.plist
Created November 14, 2010 04:41
A launchd daemon to execute a Python script when network configuration changes.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>prehensile.networkwatcher</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/python</string>
@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 / 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" )
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`