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
// this... | |
var doubles = []; | |
_.each([1,2,3], function(val){ | |
doubles.push(val * 2); | |
}); | |
// ...and this... | |
var doubles = _.map([1,2,3], function(val){ | |
return val * 2; | |
}); | |
// ...are equivalent |
- fgnd
- fmdghmhm
-
fgndfhn
-
nfgng
foo = 'bar'
-
- sfgnf
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
function bench(f) { | |
var start = new Date(); | |
f(); | |
var finish = new Date(); | |
print( ((finish-start) / 1000) + 's' ); | |
} | |
bench(function(){ | |
db.users.find().limit(2000).forEach(function(user){ |
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
package main | |
import ( | |
"math" | |
"fmt" | |
) | |
func Sqrt(x float64) (result float64) { | |
// Newton's method | |
result = 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
out = '' | |
File.readlines('./Gemfile').each do |line| | |
match = line.match(/^(.*)gem '([^']+)'(, require: false)?$/) | |
if match | |
name = match[2] | |
version = Gem.loaded_specs[name].version | |
ver_str = version.to_s | |
if ver_str.start_with?('0.') | |
ver_str = ver_str.sub(/\.\d+$/, '.x') | |
spec = "~> #{ver_str}" |
Updated for Rails 4.0.0+
-
Set up the
bower
gem. -
Follow the Bower instructions and list your dependencies in your
bower.json
, e.g.// bower.json
{
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
# a.k.a. _.extend() | |
extend = (obj, mixin) -> | |
for name, method of mixin | |
obj[name] = method | |
include = (klass, mixin) -> | |
extend klass.prototype, mixin | |
MyMixin = | |
foo: -> 'bar' |
This is a talk about getting your page to load for visitors...fast. We will cover: streaming, prefetching, script loading techniques, data bootstrapping, caching, and more. We'll look at some real-world examples, and do some live demos to see just how big an impact these considerations can make.