Skip to content

Instantly share code, notes, and snippets.

View theinventor's full-sized avatar

Troy Anderson theinventor

View GitHub Profile
@theinventor
theinventor / show_changes.html.erb
Created September 21, 2014 19:58
A way to show the changes from a papertrail (gem) versions set
<% if @model_object.versions.count > 0 %>
<div class="row">
<div class="span9">
<div class="widget widget-table">
<div class="widget-header">
<i class="fa fa-tag"></i>
<h3>Change History (admin only)</h3>
</div> <!-- /widget-header -->
<div class="widget-content">
/* global google */
var GoogleMapComponent = Ember.Component.extend({
places: [],
width: 500,
height: 500,
attributeBindings: ['style'],
style: function () {
return 'width:'+this.width+'px; height:'+this.height+'px';
function writeToScreen(screen, message) {
screen.setCursor(0,0);
screen.write(message);
}
function postDataNow() {
// Build the post string from an object
var post_data = {
'device': 'edison',
curl --data "message=Welcome to 5 Guys Burgers" 10.0.201.133:3000/weather/morelia,mx
curl --data "message=Welcome to 5 Guys Burgers" 10.0.201.133:3000/weather/98034
curl --data "message=Total: 1.99 .&line=1" 10.0.201.133:3000/message
class SearchResultFormatr
attr_accessor :type, :fields
def initialize(result)
@result = result
@type = result._type
setup_fields
end
context "second tax inclusive calculations" do
before :each do
@account = singleton_account
allow(@account).to receive_message_chain(:settings, :tax_inclusive).and_return(true)
@user ||= User.create email: 'batman@drpcfix.com', full_name: 'Bat Man', group: 'Admins', password: 'pppppp', password_confirm: 'pppppp'
@customer ||= FactoryGirl.create(:singleton_customer, account: singleton_account)
@invoice ||= Invoice.create number: '1234', customer_id: @customer.id, account_id: @account.id, date: Time.now.to_date
allow(@invoice.account.settings).to receive(:tax_inclusive).and_return(true)
allow(@invoice).to receive(:applied_tax_rate).and_return(0.10)
<script type="text/javascript">
var tmr;
function onSign()
{
var ctx = document.getElementById('cnv').getContext('2d');
SetDisplayXSize( 500 );
SetDisplayYSize( 100 );
SetJustifyMode(0);
@theinventor
theinventor / cloudberry_ruby_client.rb
Last active August 29, 2015 14:20
A super quick draft of a Cloudberry API 2.0 client in ruby
class Cloudberry
attr_accessor :access_token, :base_url, :api_version, :account
def initialize(account)
@api_version = "/api"
@account = account
@access_token = @account.settings.cloudberry_access_token
refresh_token! if have_credentials? && !valid_access_token?
end
@theinventor
theinventor / woocommercer.rb
Created May 17, 2015 19:21
This is a quick class to handle talking to woocommerce in ruby. I borrowed the whole thing from here: https://github.com/gurgus/RuWoCo, then updated to v2 and added PUT
class Woocommercer
require "digest/sha1"
require "cgi"
require "json"
require "base64"
require "openssl"
require "net/http"
require "net/https"
attr_accessor :consumer_key, :consumer_secret, :api_url, :is_ssl
@theinventor
theinventor / s3cfg
Created May 19, 2015 20:43
s3cfg for grunt deploy
[default]
access_key = REPLACE_ME
add_encoding_exts =
add_headers =
bucket_location = US
cache_file =
cloudfront_host = cloudfront.amazonaws.com
default_mime_type = binary/octet-stream
delay_updates = False
delete_after = False