Skip to content

Instantly share code, notes, and snippets.

View Adrian2112's full-sized avatar

Adrian Gonzalez Adrian2112

  • San Francisco, California
View GitHub Profile
@Adrian2112
Adrian2112 / app.coffee
Created June 25, 2012 16:41
Handlebars demo
jQuery ->
amigos = {
amigos: [
{nombre: "Adrian"}
{nombre: "Eduardo"}
{nombre: "Abraham"}
]
}
amigos_tmpl = Handlebars.compile( $("#amigos_tmpl").html() )
html = amigos_tmpl(amigos)
@Adrian2112
Adrian2112 / NavigationBarColor.m
Created November 21, 2013 22:43
UINavigationBar with color
#import "NavigationBarColor.h"
@interface NavigationBarColor ()
@property (nonatomic, strong) CALayer *colorLayer;
@end
@implementation NavigationBarColor
static CGFloat const kDefaultColorLayerOpacity = 0.5f;
static CGFloat const kSpaceToCoverStatusBars = 20.0f;
@Adrian2112
Adrian2112 / Procfile
Created January 29, 2014 23:01
Unicorn configuration to run processes
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
@Adrian2112
Adrian2112 / ILAppDelegate.m
Last active August 29, 2015 13:59
Restkit mapping structure that worked for me (not using core data)
//
// ILAppDelegate.m
//
// Created by Adrian Gzz on 25/09/13.
//
...
#import "ILMappingManager.h"
...
@Adrian2112
Adrian2112 / higher-order-functions.rb
Created April 16, 2015 16:56
Higher order functions in ruby
list = (1..10).to_a
# a little monkey patching first so we have the rest method for array
class Array
# list with zero or more elements
# [].rest => []
# [1].rest => []
# [1,2,3].rest => [2,3]
def rest
_,*rest = *self
@Adrian2112
Adrian2112 / lazy-lists.rb
Created April 16, 2015 17:10
Lazy lists in ruby
#Lazy evaluation
mult_2 = lambda {|x| x*2}
square = lambda {|x| x**2}
div_2 = lambda {|x| x/2}
# just a function to show every step we are doing
# receives a function that will be passed to directly as the map function
# and a step number just to print it out
print_s = lambda { |fn,s| lambda { |x| puts "step #{s} => #{x}"; fn[x] } }
@Adrian2112
Adrian2112 / generator.js
Last active November 8, 2017 20:25
js generators sample
// based on redux-saga api
const select = (fn) => ( { type: 'select', fn: fn } )
const put = (action) => ( { type: 'put', action: action } )
const call = (fn, ...args) => ( { type: 'call', fn: fn, args: args } )
function callSaga(iterator) {
let ret;
ret = iterator.next();
while(!ret.done) {