Skip to content

Instantly share code, notes, and snippets.

<httpHandlers>
<add verb="*" path="BuiltJS" type="Castle.MonoRail.Framework.MonoRailHttpHandlerFactory, Castle.MonoRail.Framework"/>
</httpHandlers>
def filter_url_helper(filter_key, filter_value)
product_group_query = params[:product_group_query] != nil ? Array.new(params[:product_group_query]) : nil
if product_group_query == nil
return "/t/#{params[:id].join('/')}/s/#{filter_key}/#{filter_value}"
end
if product_group_query.index(filter_key) == nil
return "/t/#{params[:id].join('/')}/s/#{product_group_query.join('/')}/#{filter_key}/#{filter_value}"
else
product_group_query[product_group_query.index(filter_key)+1] = filter_value
InheritedResources::BaseHelpers.module_eval do
def resource
get_resource_ivar || end_of_association_chain.respond_to?('by_slug') ? set_resource_ivar(end_of_association_chain.by_slug(params[:id])) : set_resource_ivar(end_of_association_chain.find(params[:id]))
end
def collection
get_collection_ivar || set_collection_ivar(end_of_association_chain.all)
end
end
@pollingj
pollingj / sass_config.rb
Created December 21, 2010 16:03
How to get SASS to load in SASS (SCSS) files from plugins (or other folders)
Dir[Rails.root.join("vendor/game_types/**/app/stylesheets")].each do |sass_folder|
Sass::Plugin.add_template_location(
sass_folder,
sass_folder + '/../../public/stylesheets'
)
end
ENV["WATCHR"] = "1"
system 'clear'
def growl(message)
growlnotify = `which growlnotify`.chomp
title = "Watchr Test Results"
puts message
image = message.match(/\s0\s(errors|failures)/) ? "~/.watchr_images/passed.png" : "~/.watchr_images/failed.png"
options = "-w -n Watchr --image '#{File.expand_path(image)}' -m '#{message}' '#{title}'"
system %(#{growlnotify} #{options} &)
@pollingj
pollingj / loop.coffee
Created July 20, 2011 16:47
Odd for loop
for num in [1..starValue]
@pollingj
pollingj / find_cell_link.xpath
Created August 20, 2012 14:28
XPath to find link within a specific table row containing specific text in another cell
@pollingj
pollingj / base.rb
Created September 26, 2012 08:18
Splitting packages in Spree Active Shipping
def packages(order)
split_packages = Array.new
number_of_packages = 1
multiplier = Spree::ActiveShipping::Config[:unit_multiplier]
default_weight = Spree::ActiveShipping::Config[:default_weight]
weight = order.line_items.inject(0) do |weight, line_item|
item_weight = line_item.variant.weight.present? ? line_item.variant.weight : default_weight
weight + (line_item.quantity * item_weight * multiplier)
@pollingj
pollingj / gist:5336799
Created April 8, 2013 13:36
Gocardless Preauth
return GoCardless.new_pre_authorization_url amount: Settings.max_variable_direct_debit_amount, name: order.name, interval_unit: "month", interval_length: 12, state: member.id,
user: {
first_name: member.first_name,
last_name: member.last_name,
email: member.email,
billing_address1: member.correspondence_address_line_1,
billing_address2: member.correspondence_address_line_2,
billing_town: member.correspondence_address_city,
billing_postcode: member.correspondence_address_postcode
}
package uk.co.cd4i.cityplan.domain.mongo
import java.util.Date
import com.novus.salat.annotations._
import com.novus.salat.dao.SalatDAO
import com.mongodb.casbah.Imports._
import com.novus.salat.global._
case class Milestone (
@Key("_id") id: Object = new ObjectId,