Skip to content

Instantly share code, notes, and snippets.

View theinventor's full-sized avatar

Troy Anderson theinventor

View GitHub Profile
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)
class SearchResultFormatr
attr_accessor :type, :fields
def initialize(result)
@result = result
@type = result._type
setup_fields
end
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
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',
/* 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';
@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">
@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
# 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 / 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')
<?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');