Skip to content

Instantly share code, notes, and snippets.

@geermc4
geermc4 / organize_decorators.sh
Last active December 19, 2015 06:58
Organize spree decorators in to paths based on virtual_path
export IFS=$'\n'
files=`find . -maxdepth 1 -type f`
for f in $files ; do
extra_crap=`grep -vh "^Deface" $f | grep -v " *:" | grep -v "^)" | sed '/^$/d'`
if [[ "$extra_crap" == "" ]]; then
overrides=`tr '\n' ' ' < $f | sed 's/Deface/\nDeface/g'`
for o in $overrides ; do
new_override=`echo $o | sed 's/\t/ /g;s/ \{1,\}/ /g;s/:\([a-z]\)/\n:\1/g'`
echo $new_override | sed 's/:\([a-z]\)/\n:\1/g' > tmp_file
commit 6e4a11335be2f2604c540e3ab5e2655d7392d133
Author: germanc4 <[email protected]>
Date: Wed Jul 18 14:46:57 2012 -0700
Adding in stock request, fixes #8
diff --git a/Gemfile b/Gemfile
index af25ab4..13ce726 100644
--- a/Gemfile
+++ b/Gemfile
@geermc4
geermc4 / usps.rb
Created March 6, 2013 00:16
usps debug
o=Spree::Order.find_by_number("R672076841")
object=o
#'USPS Priority Mail' on my db
@carrier=Spree::ShippingMethod.find(16).calculator.carrier
if object.is_a?(Array)
order = object.first.order
elsif object.is_a?(Spree::Shipment)
order = object.order
@geermc4
geermc4 / railslog.vim
Created March 5, 2013 21:50
work in progress, colors for a rails production log
" Vim syntax file
" Language: railslog
" Maintainer: German Garcia <[email protected]>
" Last Change: 5 March 2013
if exists("b:current_syntax")
finish
endif
syn match controller "Processing by.*"
diff --git a/app/models/spree/calculator/fedex_mx/base.rb b/app/models/spree/calculator/fedex_mx/base.rb
new file mode 100644
index 0000000..cae023a
--- /dev/null
+++ b/app/models/spree/calculator/fedex_mx/base.rb
@@ -0,0 +1,22 @@
+require_dependency 'spree/calculator'
+
+module Spree
+ class Calculator < ActiveRecord::Base
user = ""
pwd = ""
url = 'https://yourstore.com/'
login_url = "#{url}login.asp"
product_url = "#{url}admin/AdminDetails_Generic.asp?table=Products_Joined&ID="
agent = Mechanize.new
page = agent.get(login_url)
login_form = page.form('loginform')
@geermc4
geermc4 / run.sh
Last active October 11, 2015 03:38
runs action on any device that responds to broadcast ping and has specified port open
BROADCAST=255.255.255.255
SUBNET=192.168.1
PORT=80
ACTION=open #opens default browser on a mac
for e in $(
for i in `ping -c2 $BROADCAST | grep $SUBNET | sed -n "s/.*\($SUBNET.[0-9]\{1,\}\).*/\1/p"`
do
nc -z $i $PORT | sed -n "s/.*\($SUBNET.[0-9]\{1,\}\).*/\1/p"
done)
@geermc4
geermc4 / usps.rb
Created September 18, 2012 21:27
USPS Label for spree
def usps
test = "Test='YES'" if Spree::ActiveShipping::Config[:test_mode]
xml = []
xml << "<LabelRequest #{test || ''} LabelType='Default' LabelSize='4X6' ImageFormat='PDF'>"
xml << "<RequesterID>#{self.usps_req_id}</RequesterID>"
xml << "<AccountID>#{self.usps_account}</AccountID>"
xml << "<PassPhrase>#{self.usps_password}</PassPhrase>"
xml << "<MailClass>#{self.shipping_method}</MailClass>"
xml << "<DateAdvance>0</DateAdvance>"
xml << "<WeightOz>#{@weight}</WeightOz>"
@geermc4
geermc4 / gist:3408096
Created August 20, 2012 21:31
sample job
c.add_job('test') do
api = Quickbooks::API[:qb]
h = {
"customer_add"=> {
"name"=>"German",
"is_active"=>"true",
#"parent_ref"=> {
# "list_id"=>"",
# "full_name"=>""
#},