This file contains hidden or 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
# We did a bundle install, and rails seems to install, but weirdness then happens... | |
# Note that it is in the path, but doesn't run, and gem list doesn't show it as installed. | |
# | |
# Halp? | |
12:40:13 dbrady@shinything:~/shiny_systems/1on1/ian ruby-1.9.2-p180@ian | |
∫ which rails | |
/Users/dbrady/.rvm/gems/ruby-1.9.2-p180@ian/bin/rails | |
12:40:36 dbrady@shinything:~/shiny_systems/1on1/ian ruby-1.9.2-p180@ian |
This file contains hidden or 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 ReportsController < ApplicationController | |
layout 'home' | |
def last_login | |
if current_user.can_view_login_report? | |
@execs = Acl.find(:all, :include => :user, :conditions => ["access_type='Airport' AND access_id=#{current_airport_id}"]).map { |a| a.user } | |
operators = Operator.find_all_by_airport_id(current_airport[:id]) | |
@opers = Acl.find(:all, :include => :user, :conditions => ["access_type='Operator' AND access_id IN (?)", operators]).map { |a| a.user } | |
stores = Store.find_all_by_airport_id(current_airport[:id]) | |
@vendors = Acl.find(:all, :include => :user, :conditions => ["access_type='Store' AND access_id IN (?)", stores]).map { |a| a.user } | |
@users = @execs + @opers + @vendors |
This file contains hidden or 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
source :rubygems | |
gem "rails", "2.2.2" | |
gem "rspec-rails", "1.1.12" | |
gem "rspec", "1.1.12" | |
gem "rspec-rails", "1.1.12" | |
gem "trollop", "1.12" | |
gem "utility_belt", "1.1.0" | |
gem "will_paginate", "2.3.14" | |
gem "wirble", "0.1.3" |
This file contains hidden or 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
# Crush your website in 3 easy steps with TourBus! | |
# 1. get tourbus. Latest isn't in rubygems yet. | |
# If you don't have bundler, make sure you have the reqs. | |
git clone https://github.com/dbrady/tourbus.git && | |
cd tourbus && | |
bundle install && | |
gem build tourbus.gemspec && | |
gem install tourbus-2.0.0.gem |
This file contains hidden or 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 score(dice) | |
(1..6).map {|i| (dice.count(i)/3) * i * 100 }.inject {|a,b| a+b} + (dice.count(1)/3) * 900 + (dice.count(1)%3)*100 + (dice.count(5)%3)*50 | |
end | |
# Wait, what? Back that shit up a minute. | |
# | |
# Reconsider the rules of Greed as follows: | |
# 1. Score each triple of value k as k*100. This gives a correct score for all triples EXCEPT 1's--we're 900 points short. | |
# 2. Add in a 900-point bonus for each triple of 1's | |
# 3. Add 100 points for each 1 NOT in a triple |
This file contains hidden or 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
;; Do civilized backup names. Added by dbrady 2003-03-07, taken from | |
;; http://emacswiki.wikiwikiweb.de/cgi-bin/wiki.pl?BackupDirectory | |
;; | |
;; Don't forget to mkdir ~/saves | |
(setq | |
backup-by-copying t ; don't clobber symlinks | |
backup-directory-alist | |
'(("." . "~/saves")) ; don't litter my fs tree | |
delete-old-versions t | |
kept-new-versions 6 |
This file contains hidden or 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
# ALARM: production/master RED: stage YELLOW: next CYAN: everybody else | |
export PS1="\D{%H:%M:%S} \[\033[37m\]\u@\h\[\033[32m\]:\w \$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\\033[36m(\1)/' | sed -e 's/(production)/\\033[1;37m\\033[41m(production)\\033[m/' | sed -e 's/(master)/\\033[1;37m\\033[41m(master)\\033[m/' | sed -e 's/(stage)/\\033[31m(stage)/' | sed -e 's/(next)/\\033[33m(next)/')\[\033[37m\]\[\033[0m\] \n∫ " |
This file contains hidden or 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
// Consider the humble object: | |
var dave = { | |
name: "Dave", | |
age: 39, | |
color: "green" | |
}; | |
// If I add to this and forget to add another trailing comma, it's a | |
// syntax error: | |
var dave = { |
This file contains hidden or 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
;; Grateful thanks are given to Brian Marick (@marick) for helping me | |
;; write these. I got the original idea while reading through | |
;; http://xahlee.org/emacs/elisp_idioms.html, but couldn't work out | |
;; the elisp regexes. Brian Marick (@marick) stepped in and helped. He | |
;; took my tortured and broken camelcase-region and turned it into | |
;; something that actually worked. I then created | |
;; camelcase-word-or-region. I then wrote the snakecase versions but I | |
;; see now that all I did was copy the camelcase defuns over and, | |
;; meaning to go back and finish them Real Soon Now, forgot all about | |
;; them. I've had a quick look (2011-02-27) but elisp regexes are |
This file contains hidden or 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
# Coders from from C often like this style: | |
log status == OK ? "OK" : "PROBLEM" | |
log "All done." | |
# But since if returns a value in ruby, you can spell it out: | |
log if status == OK | |
"OK" | |
else | |
"PROBLEM" | |
end |