Skip to content

Instantly share code, notes, and snippets.

View bryanmtl's full-sized avatar

Bryan Mahoney bryanmtl

View GitHub Profile
@bryanmtl
bryanmtl / gist:e816cf2600e7b91d3c11
Created July 20, 2014 15:17
Ruby Inline - Permission Problems
staging:
before_rails:
- source: /.cloud66/files/ruby_inline.sh
destination: /tmp/ruby_inline.sh
target: rails
halt_on_error: false
execute: true
run_on: all_servers
apply_during: all
sudo: true
@bryanmtl
bryanmtl / gist:1780765
Created February 9, 2012 15:51 — forked from nicholasjhenry/gist:1780623
Installing ruby-debug with ruby-1.9.3-p0-falcon
# Install with:
# bash < <(curl -L https://raw.github.com/gist/1780623)
#
# Reference: http://blog.wyeworks.com/2011/11/1/ruby-1-9-3-and-ruby-debug
echo "Installing ruby-debug with ruby-1.9.3-p0 ..."
curl -OL http://rubyforge.org/frs/download.php/75414/linecache19-0.5.13.gem
curl -OL http://rubyforge.org/frs/download.php/75415/ruby-debug-base19-0.11.26.gem
@bryanmtl
bryanmtl / gist:2036619
Created March 14, 2012 13:52
H+C Redo

H&C

Phase I

Components

Brand Update

Non-negotiables

$(document).ready(function(){
$('#custom_images_tab a').click(function(){
if (!(picker = $('#page_image_picker')).data('size-applied')){
wym_box = $('.page_part:first .wym_box');
iframe = $('.page_part:first iframe');
picker.css({
height: wym_box.height()
, width: wym_box.width()
}).data('size-applied', true).corner('tr 5px').corner('bottom 5px').find('.wym_box').css({
backgroundColor: 'white'
var shiftHeld = false;
var initialLoad = true;
$(document).ready(function(){
init_interface();
init_sortable_menu();
init_submit_continue();
init_modal_dialogs();
init_tooltips();
init_ajaxy_pagination();
});
@bryanmtl
bryanmtl / gist:2884362
Created June 6, 2012 20:00
One liner to grab the latest production DB from Heroku
curl $(heroku pgbackups:url --remote production) | pg_restore --verbose --clean --no-acl --no-owner -h localhost -U root -d screening_room_development
@bryanmtl
bryanmtl / spree promotion fix
Created June 29, 2012 02:40
Allows coupons to be added to Spree orders in a non-complete state, regardless of the date the order was created on
module Extensions
module Spree
module Promotion
extend ActiveSupport::Concern
included do
alias_method_chain :order_activatable?, :no_date_limitation
end
def order_activatable_with_no_date_limitation?(order)
@bryanmtl
bryanmtl / gist:4246638
Created December 9, 2012 19:30
Elastic search data query not returning results
Query:
curl -X GET "http://localhost:9200/spree_products/spree%2Fproduct/_search?from=0&load=false&page=1&per_page=20&size=20&pretty=true" -d '{"query":{"bool":{"must":[{"query_string":{"query":"Carry","default_operator":"AND"}},{"range":{"available_on":{"lte":"2011-12-08T11:43:53Z"}}}]}},"size":20,"from":0}'
Returns:
{
"took" : 7,
"timed_out" : false,
"_shards" : {
"total" : 5,
@bryanmtl
bryanmtl / gist:6231471
Last active December 21, 2015 01:58
A quick rake task to identify possible Spree orders that contain invalid payments that might actually have been successfully processed
# Rake task
desc 'Generate a list of potential orders with falsely flagged invalid payments'
task list_orders_with_complete_and_invalid_payments: :environment do
Spree::Order.complete.where(legacy: false).each do |order|
if order && order.has_mulitple_payments? && order.has_an_invalid_and_complete_payment?
puts " -> Order #{order.number} has a potentially problematic payment"
end
end
end
Spree::Shipment.class_eval do
def send_shipped_email
unless Rails.env.production?
::Spree::ShipmentMailer.shipped_email(self.id).deliver
end
end
end
Spree::Order.class_eval do
def deliver_order_confirmation_email