Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v2.0.22 (Darwin)
mQENBFNoKrcBCADP2CDBD7n+bMTPmwQ7V1TLPJGshhG4nJDUCCsuEPfDxRb3hBB8
LlYYtaz/VJFvX2UY1T6yRKSZ05N89ohsc/Prb8rc3jChc/zY/wccVWeYbVWJ6vg5
YAQeG9Xg0Fkl1lW0drGl1kKaKTt0j/MHjJj/3RMQcjAq7lNhDwP1ZqOGX415wqbz
1SqlV5Vxz93NtspzmrhS6MobHdQdZuPNetS5DKFmLTjm44QrbdbCKLVX1QvXeF4W
rVff5tZbA782Bazgc5+phkDFizgbLPR3l8N757iEQqiYBqgcx7MLJMXT8bXDnWfa
TgEaMvaikg7YaYzwevB73/pZCbTTOkZaTG0PABEBAAG0KURpb2dvIFNjdWRlbGxl
dHRpIDxkaW9nb0BzY3VkZWxsZXR0aS5jb20+iQE5BBMBAgAjBQJTaCq3AhsDBwsJ

Keybase proof

I hereby claim:

  • I am scudelletti on github.
  • I am scudelletti (https://keybase.io/scudelletti) on keybase.
  • I have a public key whose fingerprint is F681 9317 C065 EB25 BA91 A367 7865 D635 E654 5942

To claim this, I am signing this object:

@scudelletti
scudelletti / blocks.rb
Created July 11, 2014 16:57
Precedence between ruby blocks
def first_function(something, &block)
puts "First - Do I have a Block? #{block_given?}"
end
def second_function(&block)
puts "Second - Do I have a Block? #{block_given?}"
end
puts "USING: {}"
first_function second_function { 'YEAP' }
@scudelletti
scudelletti / callback_weather.js
Created September 1, 2014 01:47
[NODE] Javascript Promises using Q library simple examples
// Using callbacks to retrieve Weather Data
var RestClient = require('restler')
var getURL = function(city){
return 'http://api.openweathermap.org/data/2.5/weather?q=' + city;
};
var dateOne = new Date();
RestClient.get(getURL('London')).on('complete', function(data1){
@scudelletti
scudelletti / ruby_method_visibility.rb
Created November 3, 2014 23:57
Blog comment - Ruby method visibility
class Sample
attr_accessor :protected_attribute, :private_attribute
protected :protected_attribute=
private :private_attribute=
def initialize
self.protected_attribute = 'some protected value'
self.private_attribute = 'some private value'
end
end
@scudelletti
scudelletti / composite_pattern.js
Last active August 29, 2015 14:09
Composite Pattern
// How To Use
// var categories = CategoryModule.Category.all();
// var categoryComposite = new CategoryModule.CategoryComposite('CategoryComposite', categories.categorias, null);
//
// var categoryComposities = categoryComposite.findByName('Bar');
//
// var originalCategories = categoryComposities.map(function(item) {
// return item.original;
// });
@scudelletti
scudelletti / vowels_count.clj
Last active August 29, 2015 14:16
Vowel Count using Clojure
(def vowels [\a \e \i \o \u])
(defn convert-to-num [letter]
(if (= (some #{letter} vowels) letter)
1
0)))
(defn count-vowels [phrase]
(reduce + (map convert-to-num (clojure.string/lower-case phrase))))
@scudelletti
scudelletti / count_words_loop.clj
Last active August 29, 2015 14:16
Count Words using Clojure - Loop and Map Reduce Way
(defn split-words
[phrase]
(clojure.string/split phrase #"\s"))
(defn count-words
[phrase word]
(let [words (split-words (clojure.string/lower-case phrase))
lower-case-word (clojure.string/lower-case word)]
(loop [head (first words)
tail (rest words)
@scudelletti
scudelletti / class_variable_example.rb
Last active August 29, 2015 14:17
Ruby Class Variable Examples without @@
# Ruby Class Variable Examples without @@
# http://www.sitepoint.com/class-variables-a-ruby-gotcha/
class Foo
def self.talk
puts 'Hey! I\'m talking'
end
end
class Bar
@scudelletti
scudelletti / gist:4529250
Created January 14, 2013 10:50
Ruby Method Initialize
def initialize(opts)
opts.each do |opt,val|
instance_variable_set("@#{opt}", val.to_s) if respond_to? opt
end
end