Skip to content

Instantly share code, notes, and snippets.

View theinventor's full-sized avatar

Troy Anderson theinventor

View GitHub Profile
<?php
if( $_POST["name"] )
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://YOUR_SUBDOMAIN.host.com/api/v1/leads?api_key=YOUR_API_KEY");
curl_setopt($ch, CURLOPT_POST, 1);
// example splitting a name field into first and last name bits
$pieces = explode(" ", $_POST['name']);
$last_name_parts = array_slice($pieces, 1); //each word
@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'
)
@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');