Skip to content

Instantly share code, notes, and snippets.

View readysetawesome's full-sized avatar
🏠
Working from home

Chris Becker readysetawesome

🏠
Working from home
View GitHub Profile
@readysetawesome
readysetawesome / named_scope_subset_helper.rb
Last active December 15, 2015 14:19 — forked from cee-dub/named_scope_subset_helper.rb
I wanted to rework this using new syntax: "subset.should be_a_subset_of(superset, proc)" inspired by https://gist.github.com/cee-dub/623589 which was inspired by https://gist.github.com/zbrock/615961
def should_be_a_subset(superset, records_selected_by_scope, &condition)
flunk "Your superset is empty" if superset.empty?
flunk "Your scope did not select any records" if records_selected_by_scope.empty?
records_selected_by_block, records_excluded_by_block = superset.partition(&condition)
flunk "Your test condition did not select any records" if records_selected_by_block.empty?
flunk "Your test condition did not exclude any records" if records_excluded_by_block.empty?
records_selected_by_scope.map(&:id).should =~ records_selected_by_block.map(&:id)
end
@readysetawesome
readysetawesome / lfsp_invoke.js
Created April 3, 2012 00:28 — forked from nerd0/gist:2176155
Invocation of Livefyre commenting and Livefyre Simple Profiles (bolt-on for existing init)
var engage = new fyre.sp.app.Engage({app: '{!! name of your engage app here !!}');
var profiles = new fyre.sp.app.Profile({});
var delegates = {
'handle_auth_login': function() {
engage.signIn();
},
'handle_auth_logout': function() {
engage.signOut();