Skip to content

Instantly share code, notes, and snippets.

View jacegu's full-sized avatar
🦖
Juggling shipping and parenting

Javier Acero jacegu

🦖
Juggling shipping and parenting
View GitHub Profile
@jacegu
jacegu / functional_gol.rb
Created December 9, 2012 19:38
Functional take on Conway's Game of Life
module Cell
def cell
{ state: :alive, neighbours: [] }
end
def dead_cell
{state: :dead, neighbours: []}
end
def neighbours_of(cell, neighbour_info)
@jacegu
jacegu / link_header
Created September 20, 2012 09:46
LINK header api.github.com
@jacegu
jacegu / issue_json.rb
Created September 11, 2012 08:06
What's wrong with this?
#encoding: utf-8
require 'json'
curl_json = `curl "https://api.github.com/repos/rails/rails/issues/7311"`
literal_json = %q{
{
"title": "Authentication With Token Problem",
"html_url": "https://github.com/rails/rails/issues/7311",
@jacegu
jacegu / typoeus_vs_em.rb
Created August 17, 2012 07:06
Some Benchmarks
require 'em-http-request' #gem install em-http-request
require 'typhoeus' #gem install typhoeus
ENDPOINT = 'https://api.github.com/repos/rails/rails/issues'
ISSUE_PAGES = 6
def benchmark(message, &code)
start_time = Time.now
code.call
end_time = Time.now
class Key
attr_reader :value
def initialize(value)
@value = value
end
def eql?(other_key)
value == other_key.value
end
class Key
include Comparable
attr_reader :value
def initialize(value)
@value = value
end
def <=>(other_key)
class Key
attr_reader :value
def initialize(value)
@value = value
end
end
k1 = Key.new('foo')
k2 = Key.new('foo')
@jacegu
jacegu / coffee_learning1.coffee
Created October 29, 2011 17:42
Some weird stuff with contexts for a CoffeScript&Javascript beginner
set_name = (name) -> @name = name
set_name 'Juan'
console.log name #Juan
console.log @name #undefined
#How context works here is pretty weird...
#Looks like set_name is not evaluated on "this" context
#This seems quite true if we do:
@jacegu
jacegu / rss.xml.haml
Created April 26, 2011 21:08
The HAML code of the blog RSS feed
!!! XML
%rss(version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:atom="http://www.w3.org/2005/Atom")
%channel
%title Javier Acero's blog
%link #{url('blog/rss')}
%atom:link(href="#{url('blog/rss')}"
rel="self"
@jacegu
jacegu / post_example.post
Created March 22, 2011 20:53
A example showing the file format of the blog posts
Post explaining how the blog file format works.
#title:
The post file format
#description:
Showing the file format that the blog posts have in my blog engine
#date:
2011-03-22 22:00