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
# Rules: A lamda always has 1 parameter, nothing more, nothing less | |
# Useful Content: https://en.wikipedia.org/wiki/Church_encoding | |
# Identity lambda | |
IDENTITY = ->x { x } | |
# True, returns the first argument | |
TT = ->x { ->y { x } } | |
# False, returns the last argument |
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
# 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 |
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
(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) |
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 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)))) |
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
// 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; | |
// }); |
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 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 |
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
// 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){ |
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
/* | |
Chai - Add CustomMatchers | |
usage: | |
var CustomMatchers = require('./support/friendly_news_path_matcher'); | |
chai.use(CustomMatchers); | |
expect('/materia/FooBar').to.be.a.friendlyNewsPath(); | |
*/ |
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 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' } |
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
// Source => http://www.adafruit.com/forums/viewtopic.php?f=25&t=34567 | |
//code https://gist.github.com/1804108 20121125 @ 1339 | |
//led for visualization (use 13 for built-in led) | |
int ledPin = 13; | |
//speaker connected to one of the pwm ports | |
int speakerPin = 9; | |
//tone frequencies http://home.mit.bme.hu/~bako/tonecalc/tonecalc.htm |