Skip to content

Instantly share code, notes, and snippets.

@lox
lox / cloudformation_tail.sh
Created August 3, 2015 04:08
A bash script to tail CloudFormation events
#!/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'
};
@zeke
zeke / mozilla-npm-config.sh
Last active January 3, 2016 06:59
A .npmrc file for use when the public npm registry is down.
# 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
@erikh
erikh / hack.sh
Created March 31, 2012 07:02 — forked from DAddYE/hack.sh
OSX For Hackers
#!/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
#
@hrldcpr
hrldcpr / tree.md
Last active April 15, 2024 15:27
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

@JeffreyWay
JeffreyWay / gist:1525217
Created December 27, 2011 21:29
Instant Server for Current Directory
alias server='open http://localhost:8000 && python -m SimpleHTTPServer'
@davidnunez
davidnunez / gist:1404789
Created November 29, 2011 13:20
list all installed packages in android adb shell
pm list packages -f
@mrspeaker
mrspeaker / README
Created November 2, 2011 11:04
AI Class playlist generator
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 mrspeaker@gmail.com
@samuelclay
samuelclay / image_dominant_color.py
Created April 14, 2011 01:21
Algorithm to find the dominant color in an image.
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)