Skip to content

Instantly share code, notes, and snippets.

@binaryphile
binaryphile / Gemfile_724
Created October 31, 2011 20:18
Gemfile for issue 724
source 'http://rubygems.org'
gem 'rails', '3.0.10'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3'
# Use unicorn as the web server
@binaryphile
binaryphile / gist:2661098
Created May 11, 2012 17:17
Deface override to lengthen names on Spree product index page
#Correction:
Deface::Override.new(:virtual_path => 'spree/shared/_products',
:name => 'lengthen_product_name',
:replace => 'code[erb-loud]:contains("link_to truncate(product.name, :length => 50)")',
:text => '<%= link_to product.name, product, :class => "info", :itemprop => "name", :title => product.name %>'
)
@binaryphile
binaryphile / gist:2949242
Created June 18, 2012 16:27
spree_print_invoice NoMethodError in Spree/admin/orders#show
NoMethodError in Spree/admin/orders#show
Showing /home/tlilley/.rvm/gems/ruby-1.9.3-p194@spree_dibs_1.1/bundler/gems/spree_print_invoice-40debbcc57f7/app/views/spree/admin/orders/_bye.pdf.prawn where line #8 raised:
undefined method `hook' for #<#<Class:0x00000007a18e50>:0x007f7fe5056718>
Extracted source (around line #8):
5:
6: move_down 20
7:
@binaryphile
binaryphile / gist:2949480
Created June 18, 2012 17:15
406 Not Acceptable error when trying to print
Started GET "/admin/orders/R620580058.pdf?template=invoice" for 10.10.10.11 at 2012-06-18 12:53:27 -0400
Processing by Spree::Admin::OrdersController#show as PDF
Parameters: {"template"=>"invoice", "id"=>"R620580058"}
Spree::User Load (4.3ms) SELECT `spree_users`.* FROM `spree_users` WHERE `spree_users`.`id` = 351 LIMIT 1
Spree::Role Load (4.8ms) SELECT `spree_roles`.* FROM `spree_roles` INNER JOIN `spree_roles_users` ON `spree_roles`.`id` = `spree_roles_users`.`rol
e_id` WHERE `spree_roles_users`.`user_id` = 351
Spree::Order Load (3.8ms) SELECT `spree_orders`.* FROM `spree_orders` WHERE `spree_orders`.`number` = 'R620580058' LIMIT 1
Spree::Adjustment Load (4.0ms) SELECT `spree_adjustments`.* FROM `spree_adjustments` WHERE `spree_adjustments`.`adjustable_type` = 'Spree::Order'
AND `spree_adjustments`.`adjustable_id` IN (378) ORDER BY created_at ASC
Spree::Order Load (6.5ms) SELECT `spree_orders`.* FROM `spree_orders` WHERE `spree_orders`.`user_id` = 351 AND `spree_orders`.`completed_at` IS NU
@binaryphile
binaryphile / gist:3500552
Created August 28, 2012 16:54
Autohotkey use Esc as modifier script
;
; AutoHotkey Version: 1.x
; Language: English
; Platform: Win9x/NT
; Author: A.N.Other <[email protected]>
;
; Script Function:
; Template script (you can customize this template by editing "ShellNew\Template.ahk" in your Windows folder)
;
; This script uses Esc as a modifier key so that the keyboard can be used for directional keys (arrows, etc.)
@binaryphile
binaryphile / gist:3536938
Created August 30, 2012 18:35
deface override
Deface::Override.new(virtual_path: 'spree/checkout/_payment',
name: 'add_referral_select_to_checkout_payment_step',
insert_before: 'fieldset#payment',
text: '<fieldset id="billing"><legend><%= t(:referral) %></legend><div><p>If you were referred to us by one of our salespeople, please select their name:</p><%= form.collection_select :dibs_referral, Spree::User.all, :id, :email %></div></fieldset>'
)
module Spree
Order.class_eval do
@binaryphile
binaryphile / one-handed.ahk
Created August 31, 2012 17:38
Simple One-handed Keyboard Autohotkey script
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn ; Recommended for catching common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
Toggle := False
$Space::
KeyWait, Space, T0.15 ; Adjust this value to control the delay before switching modes
If ErrorLevel
@binaryphile
binaryphile / gist:3841499
Created October 5, 2012 18:22
spree deployment service
err: Could not prefetch mysql_database provider 'mysql': #<IO:0xb70c0848>
err: /Stage[main]/Dbserver/Mysql::Database[spree]/Mysql_database[spree]: Could not evaluate: Execution of '/usr/bin/mysql mysql -NBe show databases' returned 1: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
@binaryphile
binaryphile / gist:3881634
Created October 12, 2012 21:30
deface set attributes data-erb-class
set_attributes '[data-hook=product_price]'
attributes :data-erb-class => 'columns five &lt;% if [email protected]_variants? %&gt; alpha &lt;% else %&gt; omega &lt;% end %&gt;'
27 Started PUT "/admin/orders/R814805045/payments/346/fire?e=capture"
28 Processing by Spree::Admin::PaymentsController#fire as HTML
29 Parameters: [...]
30 Redirected to https://store.diditbetter.com/admin/orders/R814805045/payments
31 Completed 500 Internal Server Error in 2463ms
32
33 StateMachine::InvalidTransition (Cannot transition state via :failure from "checkout" (Reason(s): State cannot transition via "failure")):
34 vendor/bundle/ruby/1.9.1/gems/state_machine-1.1.2/lib/state_machine/event.rb:241:in `block in add_actions'
35 vendor/bundle/ruby/1.9.1/gems/state_machine-1.1.2/lib/state_machine/machine.rb:753:in `call'
[...]