Skip to content

Instantly share code, notes, and snippets.

View hrp's full-sized avatar

Hiten Parmar hrp

View GitHub Profile
@hrp
hrp / twitter.json
Created April 4, 2011 00:20
Example JSON response from Twitter streaming API
{
"text": "RT @PostGradProblem: In preparation for the NFL lockout, I will be spending twice as much time analyzing my fantasy baseball team during ...",
"truncated": true,
"in_reply_to_user_id": null,
"in_reply_to_status_id": null,
"favorited": false,
"source": "<a href=\"http://twitter.com/\" rel=\"nofollow\">Twitter for iPhone</a>",
"in_reply_to_screen_name": null,
"in_reply_to_status_id_str": null,
"id_str": "54691802283900928",
require 'terminal-table/import'
array = [[1,2,3,4],[5,6,7,8],[9,10,11,12]]
t = table do
array.each do |a|
add_row a
end
end
puts t
@hrp
hrp / nhl.txt
Created November 26, 2011 07:18
api explorations - nhl
HTTParty
nhl videos / goals / hits / players / game results
base_uri: video.nhl.com/videocenter
get_games_in_month:
/highlights
xml = 0
month = 4
@hrp
hrp / fakeout.rake
Created January 14, 2012 21:46 — forked from matthutchinson/fakeout.rake
fakeout.rake - a simple/configurable rake task that generates some random fake data for the app (using faker) at various sizes
# a simple/configurable rake task that generates some random fake data for the app (using faker) at various sizes
# NOTE: requires the faker or ffaker gem
# sudo gem install faker - http://faker.rubyforge.org
# OR
# sudo gem install ffaker - http://github.com/EmmanuelOga/ffaker
require 'faker'
class Fakeout
// from http://darcyclarke.me/development/library-agnostic-pubsub-publish-subscribe/
App = {};
App.cache = {};
App.publish = function(topic, args){
App.cache[topic] && $.each(App.cache[topic], function(){
this.apply($, args || []);
});
};
App.subscribe = function(topic, callback){
@hrp
hrp / gist:2950859
Created June 18, 2012 21:33
bootstrap
/*!
* Bootstrap v2.0.4
*
* Copyright 2012 Twitter, Inc
* Licensed under the Apache License v2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Designed and built with all the love in the world @twitter by @mdo and @fat.
*/
.clearfix{*zoom:1;}.clearfix:before,.clearfix:after{display:table;content:"";}
@hrp
hrp / datatables-button-text-sort.js
Created July 6, 2012 00:38
Sort by button text in jQuery DataTables
// Custom sorting function to sort paid/unpaid claims
$.fn.dataTableExt.afnSortData['button-text'] = function ( oSettings, iColumn )
{
var aData = [];
$( 'td:eq('+iColumn+') button', oSettings.oApi._fnGetTrNodes(oSettings) ).each( function () {
aData.push( this.text );
} );
return aData;
};
@hrp
hrp / airbrake.rb
Created August 13, 2012 06:14
Faster Airbrake Deploy Notifier for Capistrano
require 'net/http'
require 'uri'
namespace :airbrake do
task :notify, except: {no_release: true} do
api_key = API_KEY
rails_env = fetch(:rails_env, "production")
airbrake_env = fetch(:airbrake_env, fetch(:rails_env, "production"))
local_user = ENV['USER'] || ENV['USERNAME']
@hrp
hrp / array.rb
Created November 14, 2012 20:55
Merge Sort in Ruby
# merge sort in ruby
class Array
def merge_sort
if length > 1
halves = split.map do |half|
half.merge_sort
end
combine(*halves)
else
<html>
<head>
</head>
<body>
<select style="width:300px" id="source">
<optgroup label="Alaskan/Hawaiian Time Zone">
<option value="AK">Alaska</option>
<option value="HI">Hawaii</option>
</optgroup>
<optgroup label="Pacific Time Zone">