This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
tests: | |
inputs: | |
- 23456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abc | |
- !binary | | |
ZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXp7fH1+f8KAwoHCgsKDwoTChcKGwofC | |
iMKJworCi8KMwo3CjsKPwpDCkcKSwpPClMKV | |
- !binary | | |
wpbCl8KYwpnCmsKbwpzCncKewp/CoMKhwqLCo8KkwqXCpsKnwqjCqcKqwqvC |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery.twstreamer | |
.init() | |
.credentials(USERNAME, PASSWORD) | |
.connect( | |
function(tweet) { | |
// receive tweet | |
console.log(tweet); | |
}, | |
'track', // api method (track, follow, etc.) | |
'twitter', // api query |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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/). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} |
NewerOlder