Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
#!/bin/bash -eu | |
# Show all events for CF stack until update completes or fails. | |
cf_tail() { | |
local stack="$1" | |
local current | |
local final_line | |
local output | |
local previous | |
until echo "$current" | egrep -q "${stack}.*_(COMPLETE|FAILED)" ; do |
console.log('Loading function'); | |
const https = require('https'); | |
const url = require('url'); | |
const slack_url = 'https://hooks.slack.com/services/...'; | |
const slack_req_opts = url.parse(slack_url); | |
slack_req_opts.method = 'POST'; | |
slack_req_opts.headers = { | |
'Content-Type': 'application/json' | |
}; |
# npm mirroring, courtesy @jbuck and Mozilla. | |
# See https://github.com/jbuck/npm-readonly-mirror | |
curl npmrc.zeke.xxx >> .npmrc | |
git add .npmrc | |
git commit -m "mozilla .npmrc" | |
git push heroku master |
#!/usr/bin/env sh | |
## | |
# This is script with usefull tips taken from: | |
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx | |
# | |
# install it: | |
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh | |
# |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
alias server='open http://localhost:8000 && python -m SimpleHTTPServer' |
pm list packages -f |
These are the scripts I use to create the playlists for the AI Class (available here: http://www.mrspeaker.net/2011/10/26/ai-class-playlists/). It's not pretty, but it works. I put them up here due to popular demand. | |
The first stage is to grab the video list HTML from YouTube and extract/sort the videos. This is done with the Video_ID_scraper.html file (instructions there). | |
Next, paste the video info into the YouTube_Playlist_Uploader.py script and it generates the playlist. It relies on the GData APIs so you need a dev key etc. | |
Any questions to [email protected] |
from PIL import Image | |
import scipy | |
import scipy.cluster | |
from pprint import pprint | |
image = Image.open('logo_newsblur_512.png') | |
NUM_CLUSTERS = 15 | |
# Convert image into array of values for each point. | |
ar = scipy.misc.fromimage(image) |
class QuerySetDoubleIteration(Exception): | |
"A QuerySet was iterated over twice, you probably want to list() it." | |
pass | |
# "Skinny" here means we use iterator by default, rather than | |
# ballooning in memory. | |
class SkinnyManager(Manager): | |
def get_query_set(self): | |
return SkinnyQuerySet(self.model, using=self._db) |