Skip to content

Instantly share code, notes, and snippets.

View theinventor's full-sized avatar

Troy Anderson theinventor

View GitHub Profile
@theinventor
theinventor / vendor_purchasing_guide.md
Last active August 27, 2015 18:36
Vendor Purchasing and Catalog Integrating with RepairShopr

So you want to get your catalog into RepairShopr or integrate automated ordering?

Last Revision: 2015-08-27, Troy

There are 2 primary ways RepairShopr can work with a Vendor (supplier, distributor, etc).

  1. We can maintain a catalog of your available products with SKUs and all the details, and make that available for our users to one-click import.
  2. We can tie into your ordering system so our users can one-click to send their Purchase Orders into your ordering system to generate a live order. (Fully Automated re-ordering is coming very soon too)

Product Catalog

@theinventor
theinventor / sessions_controller.rb
Last active August 29, 2015 13:56
This is an example of a couple actions that would tie together with the omniauth/google stuff
class SessionsController < ApplicationController
def new
redirect_to '/auth/google_oauth2'
end
def create #google oauth callback endpoint
@account = Account.find session[:account_id]
auth = request.env["omniauth.auth"]
@theinventor
theinventor / omniauth.rb
Created February 26, 2014 00:25
This is an example of the omniauth.rb configuration for getting cloud print to work
Rails.application.config.middleware.use OmniAuth::Builder do
scopes = [
# we need the profile scope in order to login
"https://www.googleapis.com/auth/userinfo.profile",
"https://www.googleapis.com/auth/userinfo.email",
# this and other scopes could be added, but match them up with the
# features you requested in your API Console
"https://www.googleapis.com/auth/cloudprint"
]
We need a new library built :)
We use cloudprint for printing, the current library was designed incredibly poorly.
It uses globals and we have print jobs going to the wrong user when we use multi-threaded workers.
We need it to be instance based, so when you get an instance using the Class.new method, the credentials are contained there in the instance - not globals.
Old library:
https://github.com/minciue/cloudprint
class Togglr
attr_accessor :client, :workspace_id
def initialize(account)
@account = account
raise "NoToken" unless @account.settings.toggl_api_token
end
def client
@theinventor
theinventor / azure_rest_client.rb
Created April 3, 2014 13:57
Just a quick wrapper for handling bits of the new Azure/Office 365 REST API
module WAAD
class Connector
attr_reader :client
def initialize
@client = connection(credentials)
end
def credentials
<table border="0" cellspacing="0" cellpadding="0" style="background:#ffffff;height:100%;margin:0;padding:0;width:100%; background:#f8f8f8;">
<tr>
<td width="100%" align="center" valign='top'>
<span style="color: #E8E8E8; font-size: 10px;">----- REPLY ABOVE THIS LINE TO SEND A RESPONSE -----</span><br><br>
<table width="620" border="00" cellspacing="00" cellpadding="00" style="border:1px solid #dbdbdb; background:#fff;">
<tr>
<td align="left" valign="top" style=" font-family:Arial, Helvetica, sans-serif; color:#181818; font-size:16px; padding-left: 25px;" height="650"><br /><br />
{{email_body}}
</td>
</tr>
@theinventor
theinventor / round_nearest_5.rb
Created June 17, 2014 14:25
Round to nearest 5 minutes in ruby, strangely this wasn't super simple to come up with..
def self.round_to_five_minutes(minute)
all = [0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55]
higher = nil
lower = nil
all.each_with_index do |five_min,index|
if minute == five_min
return five_min
end
if five_min > minute
higher = five_min
@gateway = ActiveMerchant::Billing::UsaEpayGateway.new login: 'KEYHERE', password: '1234', software_id: 'ABC123'
credit_card = ActiveMerchant::Billing::CreditCard.new(
:number => '4000100011112224',
:verification_value => 123,
:month => 9,
:year => 2014,
:first_name => 'Bob',
:last_name => 'Bobsen'
)