Skip to content

Instantly share code, notes, and snippets.

private
def generate_code
1.times do
self.code, self.phonetic_code = *Nerd.generate_code(badge.identifier)
redo if Code.count(:conditions => ['code = ?', self.code]) > 0
end
end
private
# probably better
$ rm -rf /
Permission Denied
$ sudo rm -rf /
parse_git_dirty() {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
parse_git_branch() {
git branch 2> /dev/null | sed -e "/^[^*]/d" -e "s/* \(.*\)/(\1$(parse_git_dirty))/"
}
parse_svn_branch() {
svn info 2> /dev/null | grep URL | sed -e "s/.*\/\(.*\)$/(\1)/"
}
PS1="\n\
RULES
* Contest starts at exactly 1PM EST on Friday, February 27, 2009
* Contest ends at exactly 5PM EST on Friday, February 27, 2009
* THREE winners will receieve an unpurchase-able Tikaro Gearxel Nerd Merit Badge
* ONE winner will receive a QRCode patch from http://p8tch.com (John's other project)
You can see pictures here:
http://www.flickr.com/photos/tikaro/3181563185/
HOW TO PLAY
* Take a picture that contains a Nerd Merit Badge somewhere in it, and post it
def add_organizer(user)
raise ArgumentError unless user.is_a?(User)
part = participations.new
part.user = user
part.organizer = true
part.save!
end
def add_speaker(user)
raise ArgumentError unless user.is_a?(User)
# this is for multistage deployments... to deploy to staging, do "cap staging deploy"
# this is also set up for passenger deployments
# change stuff where it says CHANGEME
# set stage-specific stuff in the task named after the stage below
set :domain, "CHANGME"
role :web, domain
role :app, domain
role :db, domain, :primary => true
#!/usr/bin/env ruby
# use this to install the same gems you have installed under one ruby in another
# run "gem list > ~/Desktop/gems.txt"
# run "ruby install_gems.rb ~/Desktop/gems.txt"
# You may have to change which ruby you use to run this so the gems get installed
# in the right place, for instance, using the REE ruby specifically while your server
# is running on another version... basically, think about what you're doing.
gems = IO.readlines(ARGV.first)
gems.map! do |g|
require 'rubygems'
require 'redis'
require 'base62'
r = Redis.new
start_time = Time.now
10.times do |i|
r.incr('url_count')
url_count = r['url_count'].to_i
parse_git_dirty() {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
parse_git_branch() {
git branch 2> /dev/null | sed -e "/^[^*]/d" -e "s/* \(.*\)/(\1$(parse_git_dirty))/"
}
parse_svn_branch() {
svn info 2> /dev/null | grep URL | sed -e "s/.*\/\(.*\)$/(\1)/"
}
PS1="\n\
# authorization controller... the other controllers inherit from this
class TeachController < ApplicationController
before_filter :find_section
before_filter :instructor_required # don't forget to fill out more controller tests if this changes
layout "admin"
private
def instructor_required
(logged_in? && (current_user.admin? || @section.taught_by?(current_user))) || access_denied
end