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
module Cell | |
def cell | |
{ state: :alive, neighbours: [] } | |
end | |
def dead_cell | |
{state: :dead, neighbours: []} | |
end | |
def neighbours_of(cell, neighbour_info) |
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
⌘ ~ > curl "https://api.github.com/repos/rails/rails/issues?page=5&per_page=100" -I | |
HTTP/1.1 200 OK | |
Server: nginx | |
Date: Thu, 20 Sep 2012 09:42:30 GMT | |
Content-Type: application/json; charset=utf-8 | |
Connection: keep-alive | |
Status: 200 OK | |
X-Content-Type-Options: nosniff | |
X-GitHub-Media-Type: github.beta | |
Vary: Accept |
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
#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", |
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
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 |
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
class Key | |
attr_reader :value | |
def initialize(value) | |
@value = value | |
end | |
def eql?(other_key) | |
value == other_key.value | |
end |
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
class Key | |
include Comparable | |
attr_reader :value | |
def initialize(value) | |
@value = value | |
end | |
def <=>(other_key) |
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
class Key | |
attr_reader :value | |
def initialize(value) | |
@value = value | |
end | |
end | |
k1 = Key.new('foo') | |
k2 = Key.new('foo') |
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
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: |
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
!!! 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" |
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
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 |