This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fib_generator = Enumerator.new { |y| | |
| a = b = 1 | |
| loop { | |
| y << a | |
| a, b = b, a + b | |
| } | |
| } | |
| fib_even_generator = Enumerator.new { |y| | |
| loop { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fib_generator = Enumerator.new { |y| | |
| a = b = 1 | |
| loop { | |
| y << a | |
| a, b = b, a + b | |
| } | |
| } | |
| fib_even_generator = Enumerator.new { |y| | |
| fib_generator.each { |n| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name LinkBucks.com - Auto redirect | |
| // @namespace samleb.github.com | |
| // @description Redirect to target URL skipping countdown. | |
| // @include http*://*.linkbucks.com/ | |
| // ==/UserScript== | |
| (function() { | |
| var REGEXP = /TargetUrl\s*=\s*([^;\n]*)/, | |
| urlLiteral = document.body.innerHTML.match(REGEXP)[1], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| % curl -i http://rubydoc.info/gems/sexy_scopes/0.5.0 | |
| HTTP/1.1 500 Internal Server Error | |
| Server: nginx | |
| Date: Fri, 02 Nov 2012 16:31:20 GMT | |
| Content-Type: text/plain | |
| Connection: keep-alive | |
| Status: 500 Internal Server Error | |
| X-Frame-Options: sameorigin | |
| X-XSS-Protection: 1; mode=block | |
| Content-Length: 7407 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Film < ActiveRecord::Base | |
| class << self | |
| def compute_facebook_likes | |
| fb = FacebookLike.new(AppConfig.facebook.access_token) | |
| find_in_batches(:select => 'id, permalink', :batch_size => fb.batch_size) do |group| | |
| urls = group.map { |f| film_url(f) } | |
| likes = fb.request_likes_for_urls(urls) | |
| update_facebook_likes(group, likes) | |
| sleep 0.2 | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // PromisedTests.m | |
| // PromisedTests | |
| // | |
| // Created by Samuel Lebeau on 02/05/13. | |
| // Copyright (c) 2013 Samuel Lebeau. All rights reserved. | |
| // | |
| #import "PromisedTests.h" | |
| #import "PMDeferred.h" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # (c) Copyright 2009 Samuel Lebeau. All Rights Reserved. | |
| require 'erb' | |
| module Bouncer | |
| module JavaScriptMacros | |
| class FilterFunction | |
| attr_reader :name, :condition, :options | |
| DEFAULT_OPTIONS = { | |
| :condition_variable => 'condition', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def association_names_to_joins_argument(names) | |
| joins = names.pop | |
| joins = { names.pop => joins } until names.empty? | |
| joins | |
| end | |
| association_names_to_joins_argument([:memberships]) | |
| # => :memberships | |
| association_names_to_joins_argument([:memberships, :members]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function gems-dir () { | |
| echo `ruby -rrubygems -e "puts Gem.dir"`/gems | |
| } | |
| function gems { | |
| cd `gems-dir` | |
| pwd | |
| } | |
| function gem-home { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $$('.home_theater #carousel').each(function(element) { | |
| var EFFECT_OPTIONS = { | |
| duration: 0.75, | |
| position: 'parallel', | |
| transition: S2.FX.Transitions.easeFromTo | |
| }; | |
| var slides = element.select('.slide'), | |
| index = 0; |