This file contains 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 'rubygems' | |
require 'anemone' | |
count = 0 | |
Anemone.crawl("http://www.immobilienscout24.de/immobiliensuche/wohnen-auf-zeit/nordrhein-westfalen.htm", :storage => Anemone::Storage.TokyoCabinet("/tmp/spidr.tch")) do |anemone| | |
anemone.focus_crawl do |page| | |
page.links.select do |link| | |
link.request_uri =~ /(wohnen-auf-zeit)|(\/\d+$)/ |
This file contains 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
def is_a_power_of_two?(n) | |
return false if n.is_a?(Float) | |
(n-1)& n == 0 if n != 0 | |
end | |
def logb2(n) | |
if is_a_power_of_two?(n) | |
return n.to_s(2).match(/1(0*)/)[1].length | |
else | |
false |
This file contains 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
~/ ruby-1.9.2@fashmob_poc $ brew doctor | |
You can install Homebrew anywhere you want, but some brews may only work | |
correctly if you install to /usr/local. |
This file contains 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 ApplicationHelper | |
def with_format(format, &block) | |
old_formats = formats | |
lookup_context.send(:_set_detail, :formats, [format]) | |
result = capture(&block) | |
lookup_context.send(:_set_detail, :formats, old_formats) | |
return result | |
end | |
end |
This file contains 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
Day job: Web-Engineering (Ruby on Rails, Freelancer) | |
Favorite Python project: Django | |
Favorite Conference: euruko | |
Python Experience Level: few test-drives |
This file contains 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 'rubygems' | |
require 'faster_csv' | |
require 'net/http' | |
require 'open-uri' | |
class String | |
require 'iconv' #this line is not needed in rails ! | |
def to_utf8 | |
Iconv.conv('utf-8','ISO-8859-1', self) | |
end |
This file contains 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
Due to changes in my travel plans, I have to sell my ticket for Rubyconf Australia. | |
I got my ticket in the first batch at the early-bird price. | |
If you wanna buy the ticket get in touch with me: [email protected] | |
Price: 495 AUD |
This file contains 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 Invitation < ActiveRecord::Base | |
belongs_to :invitable, primary_key: :email, foreign_key: :invitable_id, class_name: 'User' | |
end | |
class User < ActiveRecord::Base | |
has_many :invitations, :primary_key, :email, foreign_key: :invitable_id | |
end | |
user = User.create(email: '[email protected]') | |
invitation = Invitation.create(invitable: user) |
This file contains 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
# this gets called every time a user is authenticated | |
# either via an actual sign in or through a cookie | |
Warden::Manager.after_authentication do |user,auth,opts| | |
auth.params.has_key?('user') ? 'trigger direct sign in' : 'trigger cookie sign in' | |
end | |
# this gets called every time a user is fetched from session. | |
# happens on every request! | |
Warden::Manager.after_fetch do |user,auth,opts| | |
'trigger user request' |