Skip to content

Instantly share code, notes, and snippets.

View ragaskar's full-sized avatar

Rajan Agaskar ragaskar

View GitHub Profile
@ragaskar
ragaskar / GameSpec.js
Created June 30, 2011 12:03
Refactored Baseketball and Football specs
describe("games", function() {
subject("game", function() { game });
describe("Basketball Game", function() {
given(game, function() { new BasketballGame(); });
its("fieldGoal.points", function() { expect.toEqual(2); });
})
describe("Football Game", function() {
given(game, function() { new FootballGame(); });
its("fieldGoal.points", function() { expect.toEqual(3); });
});
@ragaskar
ragaskar / spec.rake
Created July 2, 2011 21:24
Kill spork when running rake spec (place in lib/tasks)
task :kill_spork do
spork_processes = `ps aux | grep spork | egrep -v grep | awk '{print $2}'`.split("\n")
spork_processes.each do |process|
system("kill #{process}")
end
end
task :spec => [:kill_spork, :cucumber]
@ragaskar
ragaskar / show-branch-info
Created August 5, 2011 12:46
Show Remote Branch info
#!/bin/sh
for k in `git branch -r|awk '{print $1}'`;do echo `git show --pretty=format:"%Cgreen%ci %Cblue%cr %Cred%cn %Creset" $k|head -n 1`\\t$k;done|sort -r
echo "If you're unable to remove a branch, it may already be gone from the remote. Try git remote prune origin (git remote prune --dry-run origin) to see what remote branch references will be deleted"
/*
We have two classes: resultRenderer and dbQuery
resultRenderer will ask dbQuery to perform a database query, and asyncronously receives the results
*/
function resultRenderer(query) { this._query = query }
resultRenderer.prototype = {
queryResultsAndRender: function () {
this._query.runQueryAsync(this.renderResults.bind(this));
@ragaskar
ragaskar / spec_helper.js
Created November 3, 2011 14:53
Fuzzy output matcher (untested)
beforeEach(function() {
this.addMatchers({
toEqualSomethingIn : function toEqualSomethingIn(possibleOutputs) {
this.message = function() {
return [
"Expected " + this.actual + " to be one of the following: "+ possibleOutputs,
"Expected " + this.actual + " not to be one of the following: "+ possibleOutputs + ", but it was"
];
};
return (possibleOutputs.indexOf(this.actual) != -1)
@ragaskar
ragaskar / 1-before_spec.rb
Created November 19, 2011 16:09 — forked from richievos/1-before_spec.rb
Spectastrophe #1
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe "Something doppelganger" do
describe "RailCar" do
let(:gateway) { RailCar.new :login => "a", :password => "b" }
describe "#commit" do
let(:response) { railcar.send :commit, request, {} }
describe "response" do
@ragaskar
ragaskar / .ackrc
Created January 7, 2012 17:41
Add haml recognition to Ack so searches return view files
--type-set
haml=.haml
@ragaskar
ragaskar / show-branches.sh
Created September 12, 2012 14:14
Show branch times
for k in `git branch -r|perl -pe s/^..//`;do echo -e `git show --pretty=format:"%Cgreen%ci %Cblue%cr %Cred%cn %Creset" $k|head -n 1`\\t$k;done|sort -r
@ragaskar
ragaskar / touch_params.yml
Created September 14, 2012 00:12
TouchParams
name: "Default Touch Params"
longTapDelay: 750
distanceToScrollPriority: 50
distanceTriggeringHorizontalSwipe: 15
distanceTriggeringVerticalSwipe: 14
@ragaskar
ragaskar / parse_limit
Last active December 20, 2015 07:29
Demonstrates nokogiri parse limit at 64 records.
require 'nokogiri'
string = <<-STRING
<rss version="2.0">
<channel>
<title>thing</title>
<link>http://thing</link>
<description>blah</description> <language>en-us</language>
<ttl>120</ttl>
<item> <title>Here's some title 0!!!</title> <link>http://some-crazy-link<link> <guid isPermaLink="true">some-other-crazy-link<guid> <comments>still more links</comments> <pubDate>Wed, 24 Jul 2013 12:08:37 +0000</pubDate> <description>What a cool description</description> <enclosure url="oh-my-god-so-many-links"/> </item>
<item> <title>Here's some title 1!!!</title> <link>http://some-crazy-link<link> <guid isPermaLink="true">some-other-crazy-link<guid> <comments>still more links</comments> <pubDate>Wed, 24 Jul 2013 12:08:37 +0000</pubDate> <description>What a cool description</description> <enclosure url="oh-my-god-so-many-links"/> </item>