Skip to content

Instantly share code, notes, and snippets.

@ericflo
ericflo / twitter_to_convore.py
Created February 20, 2011 10:02
A small script which takes keywords to track on Twitter and streams them live into a Convore topic.
import base64
import httplib
import threading
import urllib
import tweepy
CONVORE_BOT_USERNAME = ''
CONVORE_BOT_PASSWORD = ''
CONVORE_TOPIC_ID = '7612'
@mikehale
mikehale / knife.rb
Created March 23, 2011 19:44
hook to cleanup useless metadata.json files
def cleanup_metadata_json
Dir["*cookbooks/**/metadata.json"].each do |json
FileUtils.rm_f json
end
end
cleanup_metadata_json
at_exit { cleanup_metadata_json }
@carljm
carljm / postactivate
Created July 12, 2011 18:21
Yo dawg, I heard you like Ruby...
#!/bin/bash
# This hook is run after every virtualenv is activated.
export OLD_GEM_HOME=$GEM_HOME
export GEM_HOME=$VIRTUAL_ENV/gems/
export GEM_PATH=
export PATH=$VIRTUAL_ENV/gems/bin:$PATH
"Diversity is not about big sticks and hitting people over the head.
It is about creating a welcome and open environment and active
efforts to recruit members who would not otherwise participate.
Great efforts by PyLadies are proving to be very effective.
In contrast, big stick politics drive people away.
Please abandon this notion of using diversity as a stick to bonk
people over the head. It is counterproductive, misguided and offensive."
@progrium
progrium / bash
Created November 13, 2011 11:39
parse_http for nc http
# writes host to a host file
nc -l -p 9998 -c "./parse_http>/tmp/cgi;. /tmp/cgi>/dev/null && echo $HTTP_HOST > host"
# pipemill the request body
nc -l -p 9998 -c "./parse_http>/tmp/cgi;. /tmp/cgi | while read line; do something; done"
# route on the path
# uhh, well, sure, just use if on $HTTP_PATHINFO
@tmiz
tmiz / CoreLocationTest.m
Created December 1, 2011 12:08
Using CoreLocation on Mac OS X with command-line
//
// Using CoreLocation on Mac OS X with command-line
// $ clang CoreLocationTest.m -framework cocoa -framework CoreLocation
// $ ./a.out
// location service enabled
// 2011-12-01 21:03:01.839 a.out[10214:903] latitude,logitude : 35.606647, 140.695538
// 2011-12-01 21:03:01.842 a.out[10214:903] timestamp : 2011-12-01 21:01:36 +0900
// tmiz moo@tmiz.net
//
#import <cocoa/cocoa.h>
@bryanveloso
bryanveloso / brew-services.rb
Created December 8, 2011 09:39 — forked from lwe/brew-services.rb
External script for homebrew to simplify starting services via launchctl, out of the box support for any formula which implements #startup_plist. (This version fixes the deprecation warning raised on Formula.resolve_alias.)
#!/usr/bin/env ruby -w
# brew-services(1) - Easily start and stop formulas via launchctl
# ===============================================================
#
# ## SYNOPSIS
#
# [<sudo>] `brew services` `list`<br>
# [<sudo>] `brew services` `restart` <formula><br>
# [<sudo>] `brew services` `start` <formula> [<plist>]<br>
@addyosmani
addyosmani / backboneglobalpubsub.md
Created February 4, 2012 19:37
Backbone.js global pub/sub

Generally one implements notifications by listening for events on specific models but if one wishes to have a single global message interchange, it could be done as follows:

var pubsub = new Backbone.Model;

View1 = Backbone.View.extend({
  initialize: function(){
    pubsub.bind('custom event', callback);
  }
 // ...
@mpasternacki
mpasternacki / rename-node.rb
Created March 1, 2012 19:17
A knife exec script to change Chef node's name.
#!./bin/knife exec
# A knife exec script to change chef node's name, preserving all the attributes.
#
# Usage: knife exec rename-node.rb old-name new-name
#
# Script retrieves the Node object, changes its 'name' attribute,
# creates new Node object with updated name and rest of attributes
# untouched. Then it deletes old Node and Client objects from
# database, and logs into the server to update it:
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this: