- Twitter: @reedy
- Blog: http://reedy.in
- Company: Leysin American School in Switzerland
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
# config/environments/development.rb | |
# {{APP_NAME}}::Application.configure do | |
# ... | |
config.logger = Logger.new(STDOUT) | |
config.logger.level = Logger.const_get( | |
ENV['LOG_LEVEL'] ? ENV['LOG_LEVEL'].upcase : 'DEBUG' | |
) | |
# ... |
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 UserController < ApplicationController | |
def create | |
@user = User.create(UserInput.create(params)) | |
end | |
def update | |
@user = User.find(params[:id].to_i) | |
@user.update_attributes(UserInput.update(params)) | |
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
haystack = [] | |
0.upto(100) do |i| | |
0.upto(100) do |j| | |
0.upto(100) do |k| | |
0.upto(100) do |l| | |
test = [i,j,k,l].sort | |
unless haystack.include? test | |
puts "#{test.join(', ')}\n" if test.inject(&:+) == 100 | |
haystack << test | |
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
set t to "" | |
set t to do shell script "security 2>&1 find-generic-password -gl ScreenSaverPassword" | |
set KeyKind to "generic password" | |
set text item delimiters to "acct" -- Get Account name | |
set tlst to every text item of t | |
set acct to item 2 of tlst | |
set text item delimiters to "\"" | |
set tlst to every text item of acct | |
set text item delimiters to "\"" -- Get Password | |
set tlst to every text item of t |
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 'minitest/autorun' | |
module KnightIndustries | |
def self.included (klass) | |
klass.extend ClassMethods | |
end | |
def can_talk? | |
false | |
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
Dummy::Application.configure do | |
# Settings specified here will take precedence over those in config/application.rb | |
# <snip> | |
config.my_setting = "bar" | |
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
class Time | |
def in_business_days(number_of_days) | |
result = self.in number_of_days.days | |
while [0,6].include?(result.wday) || result.to_date.holiday?(:us) | |
result += 1.day | |
end | |
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
[ -n "$TM_FILEPATH" ] && \ | |
PDF_FILE=~/Desktop/`date "+%y%m%d%H%M%S"`_`basename "$TM_FILEPATH"`.pdf | |
PS_FILE=/tmp/`basename "$TM_FILEPATH"`.ps | |
vim \ | |
"+set number" "+syntax on" "+color slate" \ | |
"+set printoptions=number:y" \ | |
"+set printfont=consolas:h7" \ | |
"+hardcopy > $PS_FILE" "+q" \ | |
$TM_FILEPATH &>/dev/null && \ | |
ps2pdf $PS_FILE $PDF_FILE && \ |
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 Approval | |
attr_accessor :status | |
def method_missing(meth, *args, &blk) | |
method_name = meth.to_s | |
if method_name =~ /\?$/ | |
self.status.downcase.eql? method_name.gsub(/\?$/,'') | |
else | |
super | |
end | |
end |