"blocks aren't objects" and the corollary "blocks are objects"
This file contains 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
# using ruby-2.1.1 | |
require "benchmark" | |
n = 100_000 | |
hash = { "for" => "sale", | |
"to_price" => "1000000", | |
"bath" => "0;6", | |
"bed" => "0;6", |
This file contains 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
# Partial Application Example in Ruby | |
# We have this string 'all mimsy were the borogoves' and we need to convert this | |
# string into another string and it contains 3 characters or less than 3 | |
# characters of words. | |
split = -> (string) { | |
string.split(' ') | |
} | |
capitalize = -> (words_array) { |
This file contains 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
// Example 1 | |
function* numbers(){ | |
var n = 1; | |
var a; | |
while(true) { | |
a = yield n++; | |
console.log('a:', a); | |
} | |
}; |
This file contains 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
***********************************************HAPPY DAY************************************************** | |
Date: Oct 23 2010 | |
Happy Day | |
Happy Happy Day | |
When Your Happy Smile | |
In Your Face. | |
This file contains 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
sure many of you wouldn't have heard before - | |
1. Zikr (Netaji Subhash Chandra Bose, Forgotten Hero) | |
2. Al Madath (Mangal Pandey) | |
3. Noor Un Alah (Meenaxi) | |
4. Marhaba ya mustafa (Al Risalah) |
This file contains 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
n = 10 | |
y = 0 | |
[1,2,3].each do |n| | |
x = n | |
y = y + n | |
end | |
y.inspect | |
# => "6" | |
n.inspect | |
# => "3" -- In 1.9.X this will be 10 |
This file contains 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 Float | |
def to_minutes | |
total_seconds = (self * 60).to_i | |
minutes = total_seconds / 60 | |
remaining_seconds = total_seconds % 60 | |
if remaining_seconds.to_s.size == 1 | |
"#{minutes}.0#{remaining_seconds}" | |
else | |
"#{minutes}.#{remaining_seconds}" |
This file contains 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
***************** Haml ************************ | |
%tr | |
%td{:colspan => 6} | |
%iframe{:name => 'for_directions', :id => "recipe_directions", :src => "#{url_for :action => :directions, :recipe_id => @recipe.id}", :width => "700px"} | |
**************** Script ********************** | |
$('#recipe_directions').load(function() { |
OlderNewer