Skip to content

Instantly share code, notes, and snippets.

<%= select(:team, :id, team_selection_matrix, {}, :onchange => "display(this,'#{@team.id}');") %>
require "lockdown"
require File.join(File.dirname(__FILE__), "session")
Lockdown::System.configure do
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Configuration Options
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Options with defaults:
#
def discretionary_leave
self.tokens.discretionary.map {|time| time.hours}.sum
end
def accrued_annual_leave(year=current_fiscal_year)
RateInfo.new(self, year).accrued_leave + discretionary_leave
end
def net_annual_leave(year=current_fiscal_year)
accrued_annual_leave(year) - used_annual_leave(year)
xml.instruct! :xml, :version =>"1.0"
xml.feed(:xmlns => "http://www.w3.org/2005/Atom") do |feed|
feed.title('My Super Cool Feed!')
feed.link "rel" => "self", "href" => url_for(:only_path => false,
:controller => 'articles',
:action => 'atom')
feed.link "rel" => "alternate", "href" => url_for(:only_path => false,
:controller => 'articles')
feed.updated @articles.first.updated_at.strftime "%Y-%m-%dT%H:%M:%SZ" if @articles.any?
feed.author { feed.name "Academic Technologies" }
# Originally from http://www.benlog.org/2008/6/29/bare-bones-date-picker-for-merb
# Modified for new Merb 0.9.6 helpers
module Merb::Helpers::Form
def date_field(*args)
if bound?(*args)
current_form_context.bound_date_field(*args)
else
current_form_context.unbound_date_field(*args)
end
end
require 'rubygems'
require 'net/ldap'
module Merb::Authentication::Strategies
class AtLdap < Merb::Authentication::Strategy
def run!( login, password )
initialize_ldap_connection unless @ldap
@ldap.bind_as(
:base => "cn=#{login},ou=cats,o=gwu",
Merb::BootLoader.after_app_loads do
dependency 'merb-builder'
# This will get executed after your app's classes have been loaded.
end
### .bash_profile
export EDITOR='mate -w'
export VISUAL='mate -w'
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
function proml {
def years_of_service
((Date.today - adjusted_start_date).to_i / 365.25).to_i
end
# .autotest
require 'autotest/redgreen'
require 'autotest/menu'
# This replaces the stock Autotest::Growl
module Autotest::Growl
def self.growl title, msg, image=nil, pri=0
title += " in #{Dir.pwd}"
msg += " at #{Time.now}"
system "growlnotify -n autotest --image #{image || "/Applications/Mail.app/Contents/Resources/Caution.tiff"} -m #{msg.inspect} -t #{title}"
end