Skip to content

Instantly share code, notes, and snippets.

@botanicus
botanicus / js_custom_error.js
Created July 27, 2012 11:40
Creating custom exception 'classes' in JavaScript.
function CustomError () {
this.message = "Custom error, yay!";
};
CustomError.prototype = Error.prototype;
throw new CustomError();
#!/usr/bin/env ruby
# encoding: utf-8
require "open-uri"
require "nokogiri"
# Configuration.
URL = "http://www.xe.com/ucc/convert/?Amount=1&From=GBP&To=%s"
EMAIL = "[email protected]"
NOTIFY_IF = {CZK: 30, EUR: 1.19}
5195> ./scraper.rb list http://www.infojobs.net/ofertas-trabajo/programador
~ Listing jobs from http://www.infojobs.net/ofertas-trabajo/programador ...
<jobs>
<job>
<role>Programador RIA AS3 Flex</role>
<id>b22b0301664168b93f623d262ae759</id>
</job>
<job>
#!/usr/bin/env ruby
# encoding: utf-8
require "open-uri"
# Configuration.
URL = "http://www.cnb.cz/cs/financni_trhy/devizovy_trh/kurzy_devizoveho_trhu/denni_kurz.txt"
EMAIL = "[email protected]"
# Helpers.
@botanicus
botanicus / gist:1023001
Created June 13, 2011 15:38
em_keyboard_from_instance.rb
#!/usr/bin/env ruby
# encoding: utf-8
# The purpose of this is:
# connection = AMQP.connect
# handler = MyKbdHandlerClass.new(connection) # SO I CAN ACCESS connection from within the handler class.
# EM.open_keyboard(handler)
require "eventmachine"
@botanicus
botanicus / sinatra.rb
Created May 28, 2011 10:01
Sinatra named regexp groups of Ruby 1.9 to name keys in params.
get %r{^/users/(?<nickname>\w+)/posts/(?<slug>[\w-]+)\.(?<extension>\w+)$} do
p params[:nickname]
end
.rvmrc
*.log
*.pid
@botanicus
botanicus / .gitignore
Created April 11, 2011 14:51
Preview raw HTML from gist or pastie as a formatted HTML.
.rvmrc
.bundle
--color
--format nested