Skip to content

Instantly share code, notes, and snippets.

View afeld's full-sized avatar

Aidan Feldman afeld

View GitHub Profile
@afeld
afeld / gist:6704696
Last active December 23, 2015 22:39
GitHub non-coding use cases
@afeld
afeld / gist:6689958
Created September 24, 2013 19:25
understanding Underscore.js's _.map() and _.reduce()
// 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
@afeld
afeld / gist:6090365
Last active December 20, 2015 06:59
code in nested markdown list
  • fgnd
  • fmdghmhm
    1. fgndfhn

    2. nfgng

      foo = 'bar'
  1. sfgnf
@afeld
afeld / gist:6090084
Last active December 20, 2015 06:59 — forked from clintel/gist:1155906

Fenced code blocks inside ordered and unordered lists

  1. This is a numbered list.

  2. I'm going to include a fenced code block as part of this bullet:

    Code
    More Code
    
@afeld
afeld / mongo_shell.js
Last active December 18, 2015 18:30
performance comparison of Mongoid, Moped and `mongo` shell w/ MongoDB 2.4.3
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){
@afeld
afeld / gist:5794928
Last active December 18, 2015 14:09
my first Go exercise! Loops and Functions.
package main
import (
"math"
"fmt"
)
func Sqrt(x float64) (result float64) {
// Newton's method
result = x
@afeld
afeld / gist:5776771
Created June 13, 2013 19:51
add version approximation strings to Gemfile
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}"
@afeld
afeld / gist:5704079
Last active June 6, 2025 21:03
Using Rails+Bower on Heroku
@afeld
afeld / gist:5680195
Last active December 17, 2015 22:09
CoffeeScript mixins
# 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'
@afeld
afeld / zero_to_domready.md
Last active December 17, 2015 16:49
Zero to DOMReady proposal

Zero to DOMReady

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.