Skip to content

Instantly share code, notes, and snippets.

View matthewrudy's full-sized avatar

Matthew Rudy Jacobs matthewrudy

View GitHub Profile
<!-- HTMLTrace:Start sites/vacancies/_dam_link_rdfa.rhtml -->
<%
return unless file = dam_link_rdfa.downloadable_application_form
return unless file_name = file.file_name
if file_found?(file)
file_name_for_link = case file_name
when /\.pdf$/i then "Downloadable Form (PDF)"
%%%6. Define a predicate list_of_divisors(N,L) which for a positive integer N
%%% calculates the list of its proper divisors. (A proper divisor of n is a positive
%%% integer m < n such that m divides n.)
divisor(N,P) :-
P>0,
N>P,
0 is N mod P.
module Widgets::GeneralHelper
def stylesheets_include(options = {})
set_minify
default_options = {:stylesheets => "all", :blueprint => false, :site_code => false, :ie => false}
stylesheets_options = default_options.merge(options)
raise Dir["#{Rails.root}/public/sites/#{site.site_code}/css/*"].to_yaml
...
set :site_path, Proc.new { Capistrano::CLI.ui.ask "Site to export (e.g. 'all', 'JGP' etc.): " }
# we don't want exporting all sites if nothing is provided
# that would be a costly mistake...
raise ArgumentError, "Site path must be specified" if site_path == ""
# site_path here is whatever we specify, 'JGP' for example
# if 'all' was provided, reset site_path to .../sites/
site_path = "" if site_path == "all"
# each approach
locations = []
stocks.each {|stock| locations << stock.location}
return locations
# refactored with inject
stocks.inject([]) {|locations, stock| locations << stock.location}
# the correct approach
stocks.map {|stock| stock.location}
@matthewrudy
matthewrudy / maddy
Created November 30, 2008 23:28 — forked from roag/maddy
data Btree a = ND | Data a | Branch (Btree a) (Btree a)
deriving (Show,Eq)
data Dir = L | R
deriving (Show,Eq)
type Path = [Dir]
--- Part a)