Skip to content

Instantly share code, notes, and snippets.

View gal-at-aljazeera's full-sized avatar

Gal Steinitz gal-at-aljazeera

View GitHub Profile
gal-at-aljazeera / javascript_sort_by_2_attrs.js
Created November 13, 2014 00:38
Javascript sort by 2 attributes
View javascript_sort_by_2_attrs.js
var ary = [{a:1, b:2, c:3}, {a:3, b:5, c:3}, {a:2, b:3, c:3}, {a:2, b:2, c:3}, {a:3, b:4, c:3}, {a:3, b:3, c:3} ];
JSON.stringify(ary.sort(function(x,y){return x['a'] - y['a']}))
JSON.stringify(ary.sort(function(x,y){return [x['a'] - y['a'],x['b']-y['b']]}))
gal-at-aljazeera / gist:3196554
Created July 29, 2012 07:49
test rspec db polutions
View gist:3196554
require 'spec_helper'
describe 'Example with let' do
let(:status) { create(:status, :screen_name => 'test_status from let')}
it 'should be a status' do
status.should be_a(Status)
gal-at-aljazeera / gist:3196549
Created July 29, 2012 07:47
rspec db pollution
View gist:3196549
[\ 21:28][~/projects/social-dashboard (master)]$ rake db:test:prepare
[\ 21:28][~/projects/social-dashboard (master)]$ RAILS_ENV=test rails runner "pp Status.all"
[\ 21:28][~/projects/social-dashboard (master)]$ rspec spec/models/test_db_pollution_spec.rb
example with an exception
should be a status (FAILED - 1)
example with before :each
should be a status