Skip to content

Instantly share code, notes, and snippets.

Avatar

Rajan Agaskar ragaskar

View GitHub Profile
@ragaskar
ragaskar / GameSpec.js
Created Jun 30, 2011 — forked from infews/BasketballSpec.js
Refactored Baseketball and Football specs
View GameSpec.js
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 Jul 2, 2011
Kill spork when running rake spec (place in lib/tasks)
View spec.rake
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 Aug 5, 2011
Show Remote Branch info
View show-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"
View gist:1156753
/*
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 Nov 3, 2011
Fuzzy output matcher (untested)
View spec_helper.js
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)
View 1-before_spec.rb
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 Jan 7, 2012
Add haml recognition to Ack so searches return view files
View .ackrc
--type-set
haml=.haml
View show-branches.sh
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
View touch_params.yml
name: "Default Touch Params"
longTapDelay: 750
distanceToScrollPriority: 50
distanceTriggeringHorizontalSwipe: 15
distanceTriggeringVerticalSwipe: 14
@ragaskar
ragaskar / parse_limit
Last active Dec 20, 2015
Demonstrates nokogiri parse limit at 64 records.
View parse_limit
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>
You can’t perform that action at this time.