Skip to content

Instantly share code, notes, and snippets.

require 'twitter'
types = ['istj', 'estj', 'isfj', 'esfj', 'istp', 'estp', 'esfp', 'isfp', 'entj', 'entp', 'intp', 'enfj', 'infj', 'enfp', 'infp']
File.delete "people.html"
File.open("people.html", "w") do |f|
f << %Q{
# Relating to: https://rspec.lighthouseapp.com/projects/16211-cucumber/tickets/332-cucumber-server
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
require 'cucumber/rails/world'
require 'cucumber/formatters/unicode' # Comment out this line if you don't want Cucumber Unicode support
Cucumber::Rails.use_transactional_fixtures
require 'webrat'
I would start by running the test stuff.
test = euclidean(@people, 'Lisa Rose', 'Gene Seymour')
puts "#{test} should equal 0.148148148148"
Also note that the version in the book is wrong,
which is why i have the #errata comment there, since my version is the correct one, afaik.
so, both euclidean and pearson are meant to be interchangeable.
So, all that both of them do is take a hash in the following form:
# When a spammer wants to attack your site, they'll likely send an automated bot
# that will blindly fill out any forms it encounters. The idea of a "honeypot" is that
# you place a hidden field in a form. That's the honeypot. If this field is filled in, then
# it's almost certain to be a spammer (since a normal user wouldn't have even seen the
# field), and the contents of the form can safely be discarded.
# Normally, you would implement a "honeypot" in a Rails app with some combination of a
# special field in a particular form, and then some logic in the corresponding controller that
# would check for content in the "honeypot" field. This is somewhat of an inefficient
# approach, because it requires special code (not DRY), and bots are still going through an
class ActionController::Request # ActionController::AbstractRequest in Rails < 2.3
# Returns true if the request seems to come from a bot
def bot?
user_agent =~ /\b(Baidu|Gigabot|Googlebot|libwww-perl|lwp-trivial|msnbot|SiteUptime|Slurp|WordPress|ZIBB|ZyBorg)\b/i
end
end
#
# Then in your controllers you can do :
#
#!/usr/bin/env ruby
# The script that give you focus!
# Create a text file that contains sites want to give yourself
# access to only during certain times of day.
#
# The file will look like this:
# 12 news.ycombinator.com
# 11-13,19-21 twitter.com
#

(This is the text of the keynote I gave at Startup Riot 2009. Will update when video becomes available.)

Hi everyone, I’m Chris Wanstrath, and I’m one of the co-founders of GitHub.

GitHub, if you haven’t heard of it, has been described as “Facebook for developers.” Which is great when talking about GitHub as a website, but not so great when describing GitHub as a business. In fact, I think we’re the polar opposite of Facebook as a business: we’re small, never took investment, and actually make money. Some have even called us successful.

Which I’ve always wondered about. Success is very vague, right? Probably even relative. How do you define it?

After thinking for a while I came up with two criteria. The first is profitability. We employ four people full time, one person part time, have thousands of paying customers, and are still growing. In fact, our rate of growth is increasing – which means January was our best month so far, and February is looking pretty damn good.

#features/steps/users_steps.rb:
Given "I'm a logged in member" do
@me = create_adult
logged_in_as @me
end
#features/support/env.rb:
class Cucumber::Rails::World
# Inject
%w{earl-grey peach white}.inject({}) do |hash, string|
hash[string] = "tea"
hash
end
=> {"white"=>"tea", "earl-grey"=>"tea", "peach"=>"tea"}
# Each with object
>> %w{earl-grey peach white}.each_with_object({}){|string, hash| hash[string] = "tea"}
#
# Why setting the default value of a Hash to be a Hash is wrong
#
# When I initialize a hash, setting the default value to be another hash,
# I am not able to set the value of the hash within the hash
#
# h = Hash.new({})
#
# h['bar']['baz] = 'foo' # Try to set the value of baz
#