Skip to content

Instantly share code, notes, and snippets.

View tcr's full-sized avatar
🚮
bad command or file name

Tim Ryan tcr

🚮
bad command or file name
View GitHub Profile
@tcr
tcr / debate-twitter-stream.js
Created October 17, 2012 04:24
See a streaming list of all tweets concerning the presidential debate.
// npm install rem read clarinet
var rem = require('rem');
var read = require('read');
var clarinet = require('clarinet');
// Create Twitter API, prompting for key/secret.
var tw = rem.load('twitter', 1.0).prompt();
// Authenticate user via the console.
rem.console(tw, function (err, user) {
@tcr
tcr / facebook-status-stream.js
Created October 22, 2012 06:09
Create a stream out of any REST endpoint with REM's polling utility.
// npm install rem
var rem = require('rem');
// Create Facebook API, prompting for key/secret.
var facebook = rem.load('facebook', 1).prompt();
// Authenticate user via the console.
rem.console(facebook, function (err, user) {
// Poll new statuses at an interval of 1 second, finding the array
// at the 'data' key and checking the 'date' key for date comparison.
@tcr
tcr / summary.md
Created October 25, 2012 15:56
How do you use a different DNS entry per domain name in OS X?

Use /etc/resolver. For instance, to change the DNS servers for irc.freenode.net, create the file

/etc/resolver/irc.freenode.net

And set its contents to

nameserver 8.8.8.8

nameserver 8.8.4.4

@tcr
tcr / summary.md
Created October 25, 2012 16:03
Why am I getting a 404 error when POSTing to https://api.github.com/gists?

One possibility: you must set the "gist" scope parameter when authenticating the user.

@tcr
tcr / code.sh
Created December 3, 2012 04:01
How do you connect to a Wifi network from the command line in Ubuntu?
sudo /usr/share/checkbox/scripts/create_connection -S wpa -K THE_PASSWORD NETWORK_NAME
@tcr
tcr / code.sh
Created December 4, 2012 05:01
How do you install Python 2.7 on Dreamhost?
read -p "Domain name: " site
cd ~
mkdir ~/tmp
cd ~/tmp
wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz
tar zxvf Python-2.7.3.tgz
cd Python-2.7.3
./configure --prefix=$HOME/Python27
make
make install
@tcr
tcr / auth.js
Created December 4, 2012 20:08
Authenticating Rem with existing oauth access token/secret
var rem = require('rem');
var twitter = rem.load('twitter', '1.1', {
key: '...',
secret: '...'
});
rem.oauth(twitter, 'http://localhost/').loadState({
oauthAccessToken: '...',
oauthAccessSecret: '...'
@tcr
tcr / code.py
Created December 4, 2012 21:01
How do you connect to a mongodb: URL using PyMongo?
# Mongo URL.
MONGO_URL = os.getenv('MONGOLAB_URI', 'mongodb://localhost:27017/mytable')
# MongoDB setup.
from urlparse import urlsplit
parsed_mongo = urlsplit(MONGO_URL)
db_name = parsed_mongo.path[1:]
# Get db connection.
print('Connecting to %s [db %s]' % (MONGO_URL, db_name))
db = Connection(MONGO_URL)[db_name]
@tcr
tcr / code.sh
Created December 13, 2012 23:29
How do you use Python 2.7 and Passenger on Dreamhost?
read -p "Domain name: " site
mkdir ~/$site/tmp
touch ~/$site/tmp/restart.txt
cat <<_DOC_
import sys, os
INTERP = "/home/`whoami`/Python27/bin/python"
if sys.executable != INTERP:
os.execl(INTERP, INTERP, *sys.argv)
sys.path.append('/home/`whoami`/$site/app')
from app import app as application
@tcr
tcr / rem.txt
Created December 23, 2012 22:59
A Gist created with Rem. http://github.com/tcr/rem-js
A successful OAuth 2 test!