Skip to content

Instantly share code, notes, and snippets.

View BDQ's full-sized avatar
💥

Brian Quinn BDQ

💥
View GitHub Profile
#!/usr/bin/ruby
#url labels can only be /a-zA-Z0-9-/
urls = [
['Spreedemo-home', 'http://demo.spreecommerce.com/'],
['Spreedemo-product', 'http://demo.spreecommerce.com/products/xm-inno-xm2go-portable-satellite-radio-mp3-player-and-home-kit']
]
n = 100
cons = [2, 20]
results = { "rps" => [], "tpr" => [] }
#### core/lib/spree_core/railtie.rb #####
initializer "spree.environment" do |app|
app.config.spree = Spree::Environment.new
end
initializer "spree.register.payments" do |app|
app.config.spree.payment_methods = [
Gateway::Bogus,
Gateway::AuthorizeNet,
@BDQ
BDQ / gist:1156903
Created August 19, 2011 14:18
Get Add Product to work via js
$('#add_product_name').val('apache');
$('#add_product_name').trigger($.Event('keydown', { which: 34} ));
require 'sprockets/asset_attributes'
Sprockets::AssetAttributes.class_eval do
alias_method :sprockets_path_with_fingerprint, :path_with_fingerprint
def path_with_fingerprint(digest)
if Rails.env.development?
pathname.to_s
else
sprockets_path_with_fingerprint(digest)
Deface::Override.new(:name => 'set_cart_form_enctype',
:virtual_path => 'products/_cart_form',
:replace => "code[erb-loud]:contains('populate_orders_url')",
:text => "<%= form_for :order, :url => populate_orders_url, :html => {:multipart => true} do |f| %>")
desc "Duplicates images from all app/assets directories"
task :cache_images_for_development => :environment do
image_paths = Rails.application.assets.paths.select {|path| path.ends_with? "/images" }
image_paths.reverse.each do |path|
Dir.glob(File.join(path, "**/*")) do |file|
puts file.to_s.sub(path, '')
end
worker_processes 4
preload_app true
timeout 30
listen 3000
after_fork do |server, worker|
ActiveRecord::Base.establish_connection
end
<% if !current_page?("/") && @taxon.present? %>
<% seperator = raw("&nbsp;&raquo;&nbsp;") %>
<div id="breadcrumbs" data-hook>
<ul>
<li data-hook="home"><%= link_to t(:home) , root_path %><%= seperator %></li>
<li data-hook="products"><%= link_to(t('products') , products_path) %><%= seperator %></li>
<% @taxon.ancestors.each do |taxon| %>
<li data-hook="ancestor"><%= link_to taxon.name , seo_url(taxon) %><%= seperator %></li>
<% end %>
<li data-hook="taxon"><span><%= @taxon.name %></span></li>
<% if Rails.env.development? %>
<% DefaceEditor::Theme.active.each do |theme| %>
<% theme.stylesheets.each do |stylesheet| %>
<style id="<%= stylesheet.name %>">
<%= stylesheet.css %>
</style>
<% end %>
<% theme.javascripts.each do |javascript| %>
<script type="text/javascript" id="<%= javascript.id %>">
@BDQ
BDQ / gist:982174
Created May 20, 2011 01:30
Deface Parser Tester
require 'rubygems'
require 'diffy'
require 'nokogiri'
require 'cgi'
module Deface
class Parser
# converts erb to markup
#