Skip to content

Instantly share code, notes, and snippets.

View mechanicles's full-sized avatar

Santosh Wadghule mechanicles

View GitHub Profile
@mechanicles
mechanicles / gist:5cbdd802d8e49db89236
Last active August 29, 2015 14:05
Ruby's hash sort speed comparison.
# using ruby-2.1.1
require "benchmark"
n = 100_000
hash = { "for" => "sale",
"to_price" => "1000000",
"bath" => "0;6",
"bed" => "0;6",
@mechanicles
mechanicles / gist:2d015c1df47ab237e54e
Created October 9, 2014 17:15
Partial Application Example in Ruby.
# 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) {
@mechanicles
mechanicles / gist:d58818713e55fd4b1bc0
Last active August 29, 2015 14:22
JavaScript ES6: Simple Generator Example.
// Example 1
function* numbers(){
var n = 1;
var a;
while(true) {
a = yield n++;
console.log('a:', a);
}
};
@mechanicles
mechanicles / gist:641883
Last active September 24, 2015 00:48
Manasi's Poem.
***********************************************HAPPY DAY**************************************************
Date: Oct 23 2010
Happy Day
Happy Happy Day
When Your Happy Smile
In Your Face.
@mechanicles
mechanicles / gist:1225067
Created September 18, 2011 13:23 — forked from anildigital/gist:1225047
Blocks aren't objects .....

"blocks aren't objects" and the corollary "blocks are objects"

blocks

@mechanicles
mechanicles / gist:1247093
Created September 28, 2011 05:55
A R Rahman
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)
@mechanicles
mechanicles / gist:1254506
Created September 30, 2011 17:58
Ruby Blocks features
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
@mechanicles
mechanicles / number_to_minutes_conversion.rb
Created October 19, 2011 05:19
Number to Minutes Conversion
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}"
@mechanicles
mechanicles / git_tips.md
Created November 2, 2011 09:19 — forked from fguillen/git_tips.md
Git Tips

(Several of these git examples have been extracted from the book 'Pragmatic guide to GIT' of Travis Swicegood )

Git tips

Global git user

git config --global user.name "Fernando Guillen"
git config --global user.email "fguillen.mail+spam@gmail.com"

Repository git user

cd /develop/myrepo

@mechanicles
mechanicles / gist:1339515
Created November 4, 2011 15:00
Set iframe height.
***************** 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() {