Skip to content

Instantly share code, notes, and snippets.

View mrpollo's full-sized avatar
Journey before destination

Ramon Roche mrpollo

Journey before destination
  • Tijuana, Baja California, Mexico
  • 07:35 (UTC -07:00)
  • X @mrpollo
View GitHub Profile
@mrpollo
mrpollo / unscoped.rb
Created November 7, 2013 19:31 — forked from lwe/unscoped.rb
# Provides the ability to unscope associations, this solves problems described in
# http://stackoverflow.com/questions/1540645/how-to-disable-default-scope-for-a-belongs-to/11012633#11012633
#
# Examples
#
# class Document < ActiveRecord::Base
# default_scope where(deleted: false)
# end
#
# class Comment < ActiveRecord::Base
@mrpollo
mrpollo / order.rb
Last active December 26, 2015 04:09
Spree Utils
# cancel shipped order
Spree::Order.class_eval do
def allow_cancel?
true
end
end
Spree::Shipment.class_eval do
def after_cancel
# do nothing
end
@mrpollo
mrpollo / how_to_get_rates.rb
Created August 17, 2013 22:07
Spree 2-0-stable with spree_active_shipping branch 2-0-stable to get rates for shipments you need to do this.
s = shipment 'H13747660865'
p = s.to_package
o = s.order
#shipping method you want
m = Spree::ShippingMethod.find(21)
r = m.calculator.compute(p)
@mrpollo
mrpollo / order_decorator.rb
Created August 12, 2013 18:46
force apply store credit to an already completed order
# Spree 1-3-stable
Spree::Order.class_eval do
def force_apply_store_credit
# store credit can't be greater than order total (not including existing credit), or the user's available credit
@store_credit_amount = [user.store_credits_total, (total + store_credit_amount.abs)].min
if @store_credit_amount <= 0
adjustments.store_credits.destroy_all
else
if sca = adjustments.store_credits.first
@mrpollo
mrpollo / IntlRateResponse.xml
Last active December 20, 2015 13:49
USPS Rates response samples
<?xml version='1.0'?>
<IntlRateV2Response>
<Package ID="0">
<Prohibitions>An issue of a publication in which more than 5 percent of its total advertising space is primarily directed to a Canadian market and which indicates:
(a) Specifically where goods or services may be obtained in Canada, or
(b) Specific items or conditions relating to the sale or provision of goods or services in Canada.
All alcoholic beverages including wines, etc.
An issue of a publication that contains an advertisement primarily directed to a Canadian market is a prohibited import if that advertisement does not appear in identical form in all editions of the issue distributed in the country of origin.
Articles so marked as to create the false impression that they were made in Canada, Great Britain or any other British country.
Commercial tags of metal.
@mrpollo
mrpollo / nginx_passenger_error.log
Created August 1, 2013 00:42
nginx passenger error log
[ 2013-07-31 17:37:58.0145 1831/0x100d86000 Pool2/Implementation.cpp:1174 ]: [App 1839 stderr] /usr/local/Cellar/ruby/2.0.0-p0/lib/ruby/gems/2.0.0/gems/newrelic_rpm-3.6.5.130/lib/new_relic/agent/transaction_sampler.rb:116: [BUG] Segmentation fault
[ 2013-07-31 17:37:58.0145 1831/0x100d86000 Pool2/Implementation.cpp:1174 ]: [App 1839 stderr] ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-darwin11.4.2]
[ 2013-07-31 17:37:58.0146 1831/0x100d86000 Pool2/Implementation.cpp:1174 ]: [App 1839 stderr]
[ 2013-07-31 17:37:58.0146 1831/0x100d86000 Pool2/Implementation.cpp:1174 ]: [App 1839 stderr] -- Crash Report log information --------------------------------------------
[ 2013-07-31 17:37:58.0146 1831/0x100d86000 Pool2/Implementation.cpp:1174 ]: [App 1839 stderr] See Crash Report log file under the one of following:
[ 2013-07-31 17:37:58.0146 1831/0x100d86000 Pool2/Implementation.cpp:1174 ]: [App 1839 stderr] * ~/Library/Logs/CrashReporter
[ 2013-07-31 17:37:58.0146 1831/0x100d86000 Pool2/Implementation.cp
#!/bin/bash
# Favicon and Apple Touch Icon Generator
#
# This bash script takes an image as a parameter, and uses ImageMagick to convert it to several
# other formats used on modern websites. The following copies are generated:
#
# * apple-touch-icon-144x144-precomposed.png
# * apple-touch-icon-114x114-precomposed.png
# * apple-touch-icon-57x57-precomposed.png
@mrpollo
mrpollo / screengif.rb
Created July 12, 2013 22:17
create animated gifs aout of a lot of screencaptures for OSX ONLY
class Screengif
attr_reader :screencapture, :convert, :tempname, :delay, :times
def initialize args
@screencapture = '/usr/sbin/screencapture'
@convert = '/usr/local/bin/convert'
args.each do |k,v|
instance_variable_set("@#{k}", v) unless v.nil?
end
@tempname.gsub!("\n", '')
(1..@times).each do |i|
@mrpollo
mrpollo / configure_flags.bash
Last active December 19, 2015 02:59
Passenger + Nginx with SPDY + Rails on OS X 10.7.5 Install NGINX with SPDY support on your dev machine
#Passenger additional NGINX configure flags for SPDY support
--with-pcre --with-ipv6 --with-ld-opt=-L/usr/local/lib --with-http_spdy_module --with-http_gzip_static_module
#!/bin/sh
#
####################################
# iTunes Command Line Control v1.0
# written by David Schlosnagle
# created 2001.11.08
####################################
showHelp () {
echo "-----------------------------";