Skip to content

Instantly share code, notes, and snippets.

View theinventor's full-sized avatar

Troy Anderson theinventor

View GitHub Profile
@theinventor
theinventor / heroku.rb
Created August 15, 2013 23:06
heroku multi environment app management script, manage multiple multi-server environments within one repo easily
#!/usr/bin/env ruby
require 'ostruct'
POSSIBLE_ACTIONS = ['deploy', 'sync', 'ps', 'config', 'list-apps']
def run_the_program
if ARGV.length == 1
if ARGV.first.chomp == 'list-apps'
pretty_list_apps
end
@theinventor
theinventor / signature_code.html
Created December 2, 2013 18:58
Signature Line - place just above the </table> </body> </html> tags at the bottom of the template.
<tr>
<td>&nbsp;</td>
<td valign="top">
<p>&nbsp;</p>
<table width='100%'>
{{signature_line}}
</table>
</td>
<td>&nbsp;</td>
</tr>
@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
@theinventor
theinventor / teamviewer.rb
Created April 1, 2014 17:30
A quick ruby api wrapper for the teamviewer api
module Teamviewer
class Connector
attr_reader :client
def initialize
@client = connection(credentials)
end
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>