Skip to content

Instantly share code, notes, and snippets.

// npm install twitter <- requirement
CONSUMER_KEY = '';
CONSUMER_SECRET = '';
ACCESS_TOKEN_KEY = '';
ACCESS_TOKEN_SECRET = '';
NUMBER_TWEETS_DOWNLOAD = 5000;
OUTPUT_FILE = 'twitter.tsv';
@r
r / single.js
Last active August 29, 2015 13:59
var http = require("http");
var url = require("url");
function writeResponse(response, code, text) {
response.writeHead(code, {"Content-Type": "text/plain"});
response.write(text);
response.end();
}
function index(response) {
@r
r / gist:10977884
Last active August 29, 2015 13:59
set default_parallel 10;
register 'lib/jython.jar';
register 's3://tumo/scripts/date.py' using jython as datefunctions;
tweets = load 's3://tumo/input/twitter*.tsv' using PigStorage as (tweet_id:long, created_at:chararray, user_id:long, text:chararray, in_reply_to_status_id:long, retweet_tweet_id:long, retweet_created_at:chararray, retweet_user_id:long, retweet_text:chararray, latitude:double, longitude:double);
limited_tweets = limit tweets 10;
millisecond_tweets = foreach limited_tweets generate tweet_id, datefunctions.dateToMillis(created_at);
describe millisecond_tweets;

Keybase proof

I hereby claim:

  • I am r on github.
  • I am raffi (https://keybase.io/raffi) on keybase.
  • I have a public key whose fingerprint is A422 AE14 57F4 145D DE5E 10C2 9405 9054 E8EF F260

To claim this, I am signing this object:

@r
r / car-rpm.py
Created September 5, 2014 21:00
from twisted.internet import reactor, task
from twisted.internet.protocol import Factory, Protocol
from twisted.internet.endpoints import TCP4ClientEndpoint
import re
class PlexKiwi(Protocol):
def connectionMade(self):
self.initializeConnection()
testMode = ''
class ThreadLocal[T](init: => T) extends java.lang.ThreadLocal[T] with Function0[T] {
override def initialValue:T = init
def apply = get
def withValue[S](thunk:(T => S)):S = thunk(get)
}
def stream[T](f: => T, t:T => Boolean):Stream[T] = {
val v = f
if (t(v)) Stream.cons(v, stream(f, t)) else Stream.empty
}
def whileNotNull[T](f: => T):Stream[T] = stream(f, {t:T => t != null})
def significant_figures(num)
sn = num.to_s.sub(/e[-+]*\d+$/i, '') # remove the scientific notation
sn = sn.sub(/0*$/, '') unless sn.include?('.') # remove any trailing zeros
sn.sub('.', '').sub(/^[-+]?0*/, '').length # remove the sign, leading zeros
end
function xmlcurl {
curl -s $1 | tidy -xml -i -w 0 -q
}
YAHOO_API_ENDPOINT="http://where.yahooapis.com/v1"
# get this APP_ID from http://developer.yahoo.com/geo/geoplanet/
YAHOO_APP_ID=FILL YOUR APP ID HERE
# lookup a string and find a matching WOEID
function woeid_search {
LOC=$(echo -n "$1" | perl -pe's/([^-_.~A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg');
#!/usr/bin/env ruby
# update_profile_background_image.rb
#
# a simple example of how to construct the OAuth signatures necessary to upload
# a background image to a Twitter profile page. this will call
# account/update_profile_background_image.xml with the contents of
# 'background.png' (must be in the same directory as this script). care has
# been given to document this script, as well as to correlate lines in this
# script with the OAuth Core 1.0 specification (http://oauth.net/core/1.0/).