Skip to content

Instantly share code, notes, and snippets.

View cmar's full-sized avatar

Chris Mar cmar

  • CustomInk
  • Northern, VA
  • X @cmar
View GitHub Profile
require 'openssl'
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
require 'openssl'
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
@cmar
cmar / gist:5952531
Created July 8, 2013 21:11
Ruby LoCo Hack Night Challenge #1
#!/usr/bin/env ruby
#
# Ruby LoCo Hack Night Challenge #1
require 'benchmark'
a = [1, 2, 3, 4, 5]
b = [2, 5, 1, 3, 4]
# write a program to match indexes from a to b
@cmar
cmar / gist:5619920
Created May 21, 2013 13:51
FizzBuzz Attempt for #spreeconf
(1..100).each do |n|
n = 'fizzbuzz' if n % 15 == 0
n = 'fizz' if n % 3 == 0
n = 'buzz' if n % 5 == 0
puts n
end
-------------
1
@cmar
cmar / migrations
Created November 29, 2012 16:45
Tax Cloud Spree Integration
class CreateSpreeTaxCloudTransactions < ActiveRecord::Migration
def change
create_table :spree_tax_cloud_transactions do |t|
t.references :order
t.string :message
t.timestamps
end
add_index :spree_tax_cloud_transactions, :order_id
end
end
@cmar
cmar / gist:4154114
Created November 27, 2012 12:55
shipment notificaiton
<?xml version="1.0" encoding="UTF-8"?>
<DeliveryConfirmations xmlns:pchBase="http://schema.pchintl.com/pchBase_v1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Action="Read" xsi:noNamespaceSchemaLocation="SC_1.0.xsd">
<SC>
<SRef>
<RefV>B2C</RefV>
<RefQ>OrderType</RefQ>
</SRef>
<DN>50aa899205ffbb257e00000f_H438105531460</DN>
<AWB>UPSSAVER006</AWB>
<Car>UPSG-SAVER</Car>
Spree::ShippingCategory Load (0.4ms) SELECT `spree_shipping_categories`.* FROM `spree_shipping_categories` WHERE `spree_shipping_categories`.`id` = 727197603 LIMIT 1
Spree::ItemRate Load (4.4ms) SELECT `spree_item_rates`.* FROM `spree_item_rates` WHERE `spree_item_rates`.`rateable_id` = 727197603 AND `spree_item_rates`.`rateable_type` = 'Spree::ShippingCategory'
Spree::Zone Load (0.4ms) SELECT `spree_zones`.* FROM `spree_zones` WHERE `spree_zones`.`id` = 9 LIMIT 1
Spree::Country Load (0.5ms) SELECT `spree_countries`.* FROM `spree_countries` WHERE `spree_countries`.`id` = 214 LIMIT 1
Spree::Country Load (0.4ms) SELECT `spree_countries`.* FROM `spree_countries` WHERE `spree_countries`.`id` = 35 LIMIT 1
Spree::Country Load (0.4ms) SELECT `spree_countries`.* FROM `spree_countries` WHERE `spree_countries`.`id` = 13 LIMIT 1
Spree::Country Load (0.4ms) SELECT `spree_countries`.* FROM `spree_countries` WHERE `spree_countries`.`id` = 20 LIMIT 1
Spree::Country Load (0.5ms) SELECT `spree_countrie
@cmar
cmar / .irbrc
Created June 11, 2012 17:25
irbrc to auto switch rails console
# store_works Apartment Switching
if defined? Rails
if defined? Apartment::Database
def switch(store)
Apartment::Database.switch(store)
ENV['INTERNAL_SUBDOMAIN'] = store
puts "=> Switching to #{store}"
end
class << self
@cmar
cmar / quiet_assets.rb
Created June 6, 2012 19:11
Hide Asset Log Messages
if Rails.env.development?
Rails.application.assets.logger = Logger.new('/dev/null')
Rails::Rack::Logger.class_eval do
def call_with_quiet_assets(env)
previous_level = Rails.logger.level
Rails.logger.level = Logger::ERROR if env['PATH_INFO'] =~ %r{^/assets/}
Rails.logger.level = Logger::ERROR if env['PATH_INFO'] =~ %r{^/spraycan/}
call_without_quiet_assets(env)
ensure
Rails.logger.level = previous_level
@cmar
cmar / gist:2829864
Created May 29, 2012 18:20
View Paths
def show
Rails.logger.debug('*' * 100)
Rails.logger.debug(self.view_paths.inspect)
Rails.logger.debug('*' * 100)
Rails.logger.debug(ApplicationController.view_paths.inspect)
Rails.logger.debug('*' * 100)
@product = find_product(params[:id])
end