Skip to content

Instantly share code, notes, and snippets.

# 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}
require 'rubygems'
require 'ezcrypto'
require 'json'
require 'cgi'
require 'base64'
module Uservoice
class Token
attr_accessor :data
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
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
require 'rubygems'
require 'ezcrypto'
require 'json'
require 'cgi'
require 'base64'
module Uservoice
class Token
attr_accessor :data
// 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
// 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 {
/* 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;
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.
/*
* 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) {