Skip to content

Instantly share code, notes, and snippets.

View ckuwanoe's full-sized avatar

Corey Kuwanoe ckuwanoe

View GitHub Profile
[3] pry(main)> batch_res = client.read_batch(2582427)
=> {"content_created"=>nil,
"children_ids"=>[2591014],
"reject_reasons"=>[],
"is_digitized"=>false,
"related_job_id"=>nil,
"created_with"=>"auto",
=> {"content_created"=>nil,
"children_ids"=>[2591014],
"reject_reasons"=>[],
@ckuwanoe
ckuwanoe / tabs.json
Last active July 11, 2018 01:53
Tabs JSON
report: 'Packet Report',
tabs: {
1: {
name: 'Packet Information',
columnNames: ['organization', 'packet_name', 'status', 'total_forms', 'created_at', 'collection_date', 'days_since_collection']
},
2: {
name: 'Data entry',
columnNames: ['organization', 'packet_name', 'packet_upload_date', 'staff', 'data_entry_completed']
},
@ckuwanoe
ckuwanoe / google-vision-ocr
Created June 16, 2016 04:09
OCR an image using the google vision API
require "base64"
require 'net/http'
require 'json'
# Base 64 the input image
b64_data = Base64.encode64(File.open(ARGV[0], "rb").read)
# Stuff we need
api_key = "<YOUR_GOOGLE_API_KEY>"
content_type = "Content-Type: application/json"
def update_card(subscription_params)
customer = Stripe::Customer.retrieve(self.stripe_customer_token)
card = customer.sources.create(source: subscription_params[:stripe_card_token])
card.save
customer.default_source = card.id
customer.save
rescue Stripe::InvalidRequestError => e
logger.error "Stripe error while updating card info: #{e.message}"
errors.add :base, "#{e.message}"
false
def self.from_omniauth(auth, ref)
where(provider: auth.provider, uid: auth.uid).first_or_create do |user|
user.email = "#{auth.info.nickname}@twitter.com"
user.password = Devise.friendly_token[0,20]
user.username = auth.info.nickname # assuming the user model has a name
user.referrer_token = ref.to_s
end
end
@ckuwanoe
ckuwanoe / ruby-oneline-webserver
Created July 2, 2013 20:24
One line webserver
ruby -run -e httpd . -p5000