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
/* | |
* getJSON mock mechanism, will try to fetch the URL's as flat files stored in mocks/data | |
* I'm using this with jSpec: http://visionmedia.github.com/jspec/ | |
* Dependency, SHA1 hasher: http://github.com/jed/cookie-node/blob/master/sha1.js | |
*/ | |
(function($){ | |
$.getJSON = function (url, callback) { |
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
Dear Customers, | |
Thank you for banking with Citibank. | |
We would like to notify you of changes we have made to our account | |
policies. | |
These changes have been made as part of our cooperative effort to | |
contribute to the Japanese government's policy that aims to eliminate | |
racketeering in Japan. |
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
/* Basically, I want to throw a custom exception from C++. I'm kind of lost on how to do that :/ */ | |
// exceptions.hpp | |
class V8UnknownReturnValueException : public Rice::Exception { | |
}; | |
Rice::Object rb_eUnknownReturnValueException; |
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
// Generate URL: e.g. $.url('http://smart.fm/goals?first=1', {'second': 2}); | |
// By Andrew Plummer | |
$.url = function(base, params, options){ | |
var url = base; | |
var options = options || {}; | |
if(params){ | |
if(!url.match(/\?$/)) { | |
if(url.match(/\?/)) { | |
url += '&'; | |
} else { |
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
// For all you Rubyists out there, jQuery has a couple "hidden" methods | |
// for working with arrays that work and are named just like Ruby, "grep" and "map": | |
foo = [1, 2, 3, 4, 5] | |
/* | |
Ruby way: | |
foo.grep do |value| | |
value > 2 && value < 5 | |
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
require 'rubygems' | |
require 'ezcrypto' | |
require 'json' | |
require 'cgi' | |
require 'base64' | |
module Uservoice | |
class Token | |
attr_accessor :data | |
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
curl -d 'track=one line' http://stream.twitter.com/track.json -uonelinebot:one.onelinebot > tweets.json 2> /dev/null & tail -f tweets.json | \ | |
while read tweet; do echo $tweet | \ | |
grep -E -o '"screen_name":"[[:alnum:]]+"' | cut -d '"' -f 4 | while read screen_name; do \ | |
echo "following: $screen_name"; curl -d '' http://twitter.com/friendships/create/$screen_name.json?follow=true -uonelinebot:one.onelinebot; \ | |
done ; \ | |
done |
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
curl -d 'track=one line' http://stream.twitter.com/track.json -uonelinebot:one.onelinebot > tweets.json 2> /dev/null & tail -f tweets.json | while read tweet; do echo $tweet | grep -E -o '"screen_name":"[[:alnum:]]+"' | cut -d '"' -f 4 | while read screen_name; do echo "following: $screen_name"; curl -d '' http://twitter.com/friendships/create/$screen_name.json?follow=true -uonelinebot:one.onelinebot; done ; done |
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
require 'rubygems' | |
require 'ezcrypto' | |
require 'json' | |
require 'cgi' | |
require 'base64' | |
module Uservoice | |
class Token | |
attr_accessor :data | |
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
# After get, show operations | |
def render_json_collection(collection) | |
hash = {:status => {:code => 200}} | |
hash[:result] = collection | |
render_json_with_callback(hash.to_json) | |
end | |
# After delete, create operations | |
def render_status(status) | |
hash = {:status => status} |
NewerOlder