Skip to content

Instantly share code, notes, and snippets.

View gabeodess's full-sized avatar

Gabe Odess gabeodess

  • RigUp
  • Austin TX
  • 11:28 (UTC -05:00)
View GitHub Profile
@gabeodess
gabeodess / Procfile-dev
Last active August 29, 2015 14:22
Start Frontend, API, and Sidekiq in 1 command
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
worker: bundle exec sidekiq -C config/sidekiq.yml -v -e $RAILS_ENV
web: ~/Sites/api/bin/rails s
@gabeodess
gabeodess / job.rb
Created June 1, 2015 23:52
Building PDF with Prawn
class CollapseLabelsJob < ActiveJob::Base
queue_as :default
def perform(tracking_sheet)
pdf_paths, destination = tracking_sheet.pdf_paths, File.join(Rails.root, "tmp/#{SecureRandom.hex}.pdf")
paths = pdf_paths.map{ |i| open(i).path }.join(' ')
options = "-q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite"
@gabeodess
gabeodess / data-structure.txt
Created May 18, 2015 21:25
Form builder data structure.
Form
employer:belongs_to
name:string
review_required:boolean
signature_required:boolean
Question (has_many :question_answers; multiple choice; text; multiple answer)
text:text
type:string (MultipleAnswerQuestion, MultipleChoiceQuestion, OpenQuestion)
@gabeodess
gabeodess / address.rb
Created May 13, 2015 02:38
Class Inheritance
class Shippo::Address < Shippo::TestBase
@@store = {:test => 'Address'}
cattr_reader :store
end
@gabeodess
gabeodess / create_shippo_transaction_job_test.rb
Last active August 29, 2015 14:21
Overriding classes for test cases.
require 'test_helper'
class CreateShippoTransactionJobTest < ActiveJob::TestCase
test "the truth" do
@order = FactoryGirl.create(:order)
assert_enqueued_with(:job => CreateShippoTransactionJob) do
@shipment = @order.create_shipment!
class String #:nodoc:
# =================
# = Class Methods =
# =================
def self.alphanumeric(length = 6)
(1..length).map{ [(0..9), ('a'..'z'), ('A'..'Z')].map(&:to_a).flatten.sample }.join
end
# ====================
@gabeodess
gabeodess / index.html
Created April 30, 2015 16:33
ngOptions
<select
name="coffee"
id="coffee"
class='form-control'
ng-model="subscription.great_coffees[$index]"
ng-options='coffee as coffee.name group by coffee.category_name for coffee in coffees track by coffee.id'
>
@gabeodess
gabeodess / Procfile
Created April 15, 2015 18:12
Sidekiq wont start custom queues
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
worker: bundle exec sidekiq -c 15 -v -C .config/sidekiq.yml -e $RAILS_ENV
<form action="/charge" method="POST">
<script
src="https://checkout.stripe.com/checkout.js" class="stripe-button"
data-key="pk_test_1xBnoR7Mdwx4E1gD2dcgl8TL"
data-image="https://s3.amazonaws.com/stripe-uploads/acct_14qpC2GuKJ7VdKiHmerchant-icon-1419369420301-10846338_1510038909255594_3532245329824431014_n.jpg"
data-name="Share Coffee"
data-description="2 widgets"
data-amount="2000">
</script>
<input type='hidden' value='http://example.com/my-custom-url'/>
Refused to display 'https://www.sharecoffeeroasters.com/facebook/contact/' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.