Skip to content

Instantly share code, notes, and snippets.

View gberger's full-sized avatar

Guilherme Berger gberger

View GitHub Profile
@gberger
gberger / befunge.coffee
Last active August 29, 2015 13:56
Befunge interpreter in CoffeeScript
interpret = (code) ->
commands =
'+' : =>
@stack.push(@stack.pop() + @stack.pop())
'-' : =>
@stack.push([email protected]() + @stack.pop())
'*' : =>
@stack.push(@stack.pop() * @stack.pop())
_ = require('underscore')
w = (str) -> str.split(' ')
cities =
"Arad": {name: "Arad", distance: 366, neighbors: w "Zerind Timisoara Sibiu"}
"Bucharest": {name: "Bucharest", distance: 0, neighbors: w "Urziceni Giurgiu Pitesti Fagaras"}
"Craiova": {name: "Craiova", distance: 160, neighbors: w "Drobeta Pitesti Rimnicu"}
"Drobeta": {name: "Drobeta", distance: 242, neighbors: w "Mehadia Craiova"}
"Eforie": {name: "Eforie", distance: 161, neighbors: w "Hirsova"}
@gberger
gberger / time_to_date.rb
Created February 25, 2014 23:47
Time#to_date (Ruby monkey patch)
class Time
def to_date
Date.parse(self.to_s)
end
end
@gberger
gberger / get.rb
Created January 22, 2014 15:31
Download all SISU selected candidates pages. Parse them.
# Usage:
# ruby get.rb lower upper output-dir
# Example:
# ruby get.rb 65000 85000 out
require 'open-uri'
class String
def red; "\033[31m#{self}\033[0m" end
def green; "\033[32m#{self}\033[0m" end
@gberger
gberger / bower-workflow.md
Last active December 19, 2015 21:49
Workflow for Bower Installer

"Bower is a package manager for the web".

Bower functions by downloading components that your project depends on. These dependencies are defined in a bower.json file. Each dependency is either:

  • a name that maps to a package registered with Bower, e.g, jquery
  • a remote Git endpoint, e.g., git://github.com/someone/some-package.git. Can be public or private
  • a local Git endpoint, i.e., a folder that's a Git repository
@gberger
gberger / railscasts-download.rb
Last active December 15, 2015 15:19 — forked from samqiu/railscasts.rb
Download Railscasts episodes on Windows!This will download all missing free Railscasts episodes onto the folder where the script is.If you are a Pro subscriber, you can just sub in your Pro RSS feed and have it download Pro episodes too.
require 'rss'
require 'open-uri'
p "Downloading rss index"
# If you are a Railscasts Pro subscriber, you will have a different RSS feed with Pro casts
# If this is the case, go to http://railscasts.com/, find it and sub it below
rss_string = open('http://feeds.feedburner.com/railscasts').read
rss = RSS::Parser.parse(rss_string, false)
videos_urls = rss.items.map { |it| it.enclosure.url }.reverse