Skip to content

Instantly share code, notes, and snippets.

@mischa
mischa / hack.sh
Created March 31, 2012 21:35 — forked from erikh/hack.sh
OSX For Hackers
echo "Use current directory as default search scope in Finder"
defaults write com.apple.finder FXDefaultSearchScope -string "SCcf"
echo "Disable the warning when changing a file extension"
defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false
# Empty Trash securely by default
defaults write com.apple.finder EmptyTrashSecurely -bool true
echo "Enable full keyboard access for all controls (e.g. enable Tab in modal dialogs)"
@mischa
mischa / install-ruby-debug-ubuntu-ruby-1.9.3
Created February 22, 2012 19:44 — forked from fawce/install-ruby-debug-ubuntu-ruby-1.9.3
install for ruby-debug in ruby-1.9.3 and ubuntu
#!/bin/bash
##########IMPORTANT###########################################################################
# This script requires rvm: http://beginrescueend.com/
# Before running this script you must install rvm. This script will install ruby 1.9.3-p0 if it
# is not already. Ruby can take 10 minutes to compile.
# Load RVM into a shell session *as a function*
if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then
# First try to load from a user install
# 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
if [child, parent, grandpa, president, food, ink].all{|e| e.valid?}
... #do stuff
end
>> %w{foo, bar, baz}.all?{|e| e.is_a?(String)}
=> true
>> ["foo", "bar", 1].all?{|e| e.is_a?(String)}
=> false