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
# Generates the text of asetniop.vim | |
singles = | |
a: "a" | |
s: "s" | |
e: "d" | |
t: "f" | |
n: "j" | |
i: "k" | |
o: "l" | |
p: ";" |
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
var parser = document.createElement('a'); | |
parser.href = "http://example.com:3000/pathname/?search=test#hash"; | |
parser.protocol; // => "http:" | |
parser.hostname; // => "example.com" | |
parser.port; // => "3000" | |
parser.pathname; // => "/pathname/" | |
parser.search; // => "?search=test" | |
parser.hash; // => "#hash" | |
parser.host; // => "example.com:3000" |
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
//+ thunkify :: (... -> IO ()) -> ... -> ... -> IO () | |
function thunkify(fn /*, ... */) { | |
args = [].slice.call(arguments, 1); | |
return function(/* ... */) { | |
fn.apply(this, args.concat([].slice.call(arguments, 0))); | |
}; | |
} |
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 call(form_object) | |
form_object.validate! | |
if User.where(email: form_object.email).exists? | |
form_object.errros.add(:email, 'email already taken') | |
end | |
# Forgot to access the company_name attribute on the form_object | |
company = Company.create!(name: form_object.company_name) | |
User.create!(name: form_object.name, email: form_object.email, company: company) |
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
//-- If you understand closures - you know why this will always return true | |
function f(value) { | |
return (function (copy) { | |
return copy === value; | |
}(value)); | |
} |
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
//-- http://allong.es/try/ | |
tap = allong.es.tap | |
flip = allong.es.flip | |
curry = allong.es.curry | |
compose = allong.es.compose | |
call = allong.es.call | |
//-- square :: Int -> Int | |
function square(x) { return x*x } | |
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
// Ideas | |
//-- note (() -> IO), random function | |
//-- Maybe denote it with a lambda instead | |
//+ given :: (a -> Bool) -> (() -> IO) -> Maybe IO | |
//+ ifthen :: (a -> Bool) -> (() -> IO) -> Maybe IO | |
function ifthen(predicate, action) { | |
if (predicate()) { | |
action(); |
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
var bind = Function.prototype.call.bind(Function.prototype.bind); | |
var call = bind(Function.prototype.call, Function.prototype.call); | |
var apply = bind(Function.prototype.call, Function.prototype.apply); |
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
//-- Example 1 -------------------------------------------------------- | |
//-- Note - We do not need to reference the data `email` when | |
//-- using a 'Point free style' of programming | |
//-- Note - `curry` is from Prelude. `compose` is from Oliver Steele -- | |
//-- http://preludels.com/ | |
//-- http://osteele.com/sources/javascript/functional/ | |
//-- Imparative ------------------------------------------------------- | |
var getUserName = function(email) { |
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
#!/usr/bin/env ruby | |
tagname = ARGV.pop | |
def prompt(*args) | |
print(*args) | |
gets.chomp | |
end | |
if tagname.nil? |