Skip to content

Instantly share code, notes, and snippets.

View theinventor's full-sized avatar

Troy Anderson theinventor

View GitHub Profile
@theinventor
theinventor / invoice_ticket_template.html
Created June 20, 2014 14:03
Invoice Ticket template - this will place the ticket on your invoice, and include the custom fields
<table width="750" border="0" align="center" cellpadding="0" cellspacing="0" class="main-table">
<tr>
<td width="18" height="20">&nbsp;</td>
<td width="714" valign="top">&nbsp;</td>
<td width="18">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<style type="text/css">
.rs-widget-container {
position: relative;
padding-bottom: 56.25%;
padding-top: 35px;
height: 100%;
}
.rs-widget-container iframe {
position: absolute;
top:0;
@theinventor
theinventor / response.text
Last active August 29, 2015 14:03
usaepay code spike
=> #<ActiveMerchant::Billing::Response:0x007fb45c9c7878 @params={"run_sale_return"=>{"acs_url"=>nil, "auth_amount"=>"0", "auth_code"=>"000000", "avs_result"=>"No AVS response (Typically no AVS data sent or swiped transaction)", "avs_result_code"=>nil, "batch_num"=>"1", "batch_ref_num"=>"108410", "card_code_result"=>"No CVV2/CVC data available for transaction.", "card_code_result_code"=>nil, "card_level_result"=>"Unknown Code ", "card_level_result_code"=>nil, "conversion_rate"=>"0", "converted_amount"=>"0", "converted_amount_currency"=>nil, "cust_num"=>"0", "error"=>"Invalid Card Number (1)", "error_code"=>"11", "is_duplicate"=>"false", "payload"=>nil, "ref_num"=>"60056770", "result"=>"Error", "result_code"=>"E", "status"=>"Pending", "status_code"=>"P", "vpas_result_code"=>nil}}, @message={"acs_url"=>nil, "auth_amount"=>"0", "auth_code"=>"000000", "avs_result"=>"No AVS response (Typically no AVS data sent or swiped transaction)", "avs_result_code"=>nil, "batch_num"=>"1", "batch_ref_num"=>"108410", "card_code_
@theinventor
theinventor / peepeealert.com.ino
Created July 13, 2014 19:31
Our code for the peepeealert.com moisture sensing diaper
int sensorPin = 0;
int ledPin = 1;
int sensorVal = 0;
int counter = 0;
void setup()
{
// strip.begin();
// strip.show(); // Initialize all pixels to 'off'
task :import_invoices_with_api_client => :environment do
begin
#CustomerName,CustomerPhone,Invoice Date,Invoice Subtotal,Invoice Tax,Invoice Total,Invoice Number
path = "#{Rails.root}/tmp/test.csv"
subdomain = 'ithelpdesk'
api = TroysAPIClient.new(subdomain,'API_KEY')
api.base_url = "https://#{subdomain}.repairshopr.com"
@subdomain = 'subdomain'
@api_key = 'api_key'
@api_version = "/api/v1"
base_url = "https://#{@subdomain}.repairshopr.com"
subtotal = 150.00
number = "12345"
invoice = {}
invoice[:date] = Time.now
invoice[:paid] = true
<?php
$subdomain = 'subdomain';
$api_key = 'api_key';
$api_version = '/api/v1';
$base_url = "https://$subdomain.repairshopr.com";
$subtotal = 150.00;
$number = '12345';
$invoice = array();
$invoice["date"] = date('Y-m-d H:i:s');
@theinventor
theinventor / locales.rb
Created August 26, 2014 17:12
locales.rb
def locale_countries
countries = []
countries << OpenStruct.new(name: 'Argentina', code: 'es-AR')
countries << OpenStruct.new(name: 'Australia', code: 'en-AU')
countries << OpenStruct.new(name: 'Brazil', code: 'en-BR')
countries << OpenStruct.new(name: 'Canada', code: 'en-CA')
countries << OpenStruct.new(name: 'Chile', code: 'en-CL')
countries << OpenStruct.new(name: 'Cyprus', code: 'en-CY')
countries << OpenStruct.new(name: 'Denmark', code: 'en-DK')
countries << OpenStruct.new(name: 'Germany', code: 'de')
# How to install `ipkg` on a Synology DS214
After a couple of days of trying to get `ipkg` woking on my DS214 I found [this article](https://github.com/trepmag/ds213j-optware-bootstrap) by [trepmag](https://github.com/trepmag). It is written for the DS213j, but it’s been working for me and [others](https://github.com/alberthild) for the DS214 too.
I have done some minor changed to clarify some things, but if you are a Linux guy (unlike me) my changes might be of no use to you.
## Guide
@theinventor
theinventor / check_memory_at_heroku_and_reboot.rake
Created August 28, 2014 01:51
A quick rake task to reboot a heroku dyno if it's approaching your memory limit. For some reason when heroku cycles them, with our unicorn setup, we have some downtime - but when we reboot them, they don't get traffic until they are back up- so no downtime.
task :web_restart_based_on_memory => :environment do
begin
@client = Heroku::API.new(:api_key => ENV['HEROKU_TOKEN'])
app_name = 'HEROKU_APP_NAME_HERE'
dynos_status = @client.get_ps(app_name).body
#get some recent lines that are from heroku referencing web.X
response = open(@client.get_logs(app_name, ps: "web", source: 'heroku', 'num' => '1500').body).readlines
reboot_count = 0