Skip to content

Instantly share code, notes, and snippets.

@r
r / test_strings.yml
Created July 6, 2010 03:05
OAuth unicode test strings
---
tests:
inputs:
- 23456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abc
- !binary |
ZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXp7fH1+f8KAwoHCgsKDwoTChcKGwofC
iMKJworCi8KMwo3CjsKPwpDCkcKSwpPClMKV
- !binary |
wpbCl8KYwpnCmsKbwpzCncKewp/CoMKhwqLCo8KkwqXCpsKnwqjCqcKqwqvC
jQuery.twstreamer
.init()
.credentials(USERNAME, PASSWORD)
.connect(
function(tweet) {
// receive tweet
console.log(tweet);
},
'track', // api method (track, follow, etc.)
'twitter', // api query
#!/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/).
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');
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
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})
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)
}