Skip to content

Instantly share code, notes, and snippets.

View crispincornett's full-sized avatar

Crispin Cornett crispincornett

  • Boise, Idaho, USA
View GitHub Profile
# Gather your inputs, cast as string and strip whitespace
name = str(event.source.parent.getComponent('nameFilter').text).strip()
farm = str(event.source.parent.getComponent('farmFilter').text).strip()
item = str(event.source.parent.getComponent('itemFilter').text).strip()
cluster = str(event.source.parent.getComponent('clusterFilter').text).strip()
start_date = event.source.parent.getComponent('startDate').text
end_date = event.source.parent.getComponent('endDate').text
# Empty array to contain conditions
conditions = []
@crispincornett
crispincornett / ign_ack_all.py
Last active August 29, 2015 14:11
Ignition Ack All Alarms
# Get all alarms
alarms = system.alarm.queryStatus()
note = "Acked by Zeus"
alm_ids = []
# Add alarm id cast as string to alm_ids list
for row in alarms:
alm_ids.append(str(row.getId()))
@crispincornett
crispincornett / .vimrc
Last active August 29, 2015 14:18 — forked from ryanflorence/.vimrc
function RandomColorScheme()
let mycolors = split(globpath(&rtp,"**/colors/*.vim"),"\n")
exe 'so ' . mycolors[localtime() % len(mycolors)]
unlet mycolors
endfunction
call RandomColorScheme()
:command NewColor call RandomColorScheme()

Install PostgreSQL 9.4

echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" >
          /etc/apt/sources.list.d/pgdg.list
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc 
          | sudo apt-key add -
sudo apt-get update
sudo apt-get upgrade
@crispincornett
crispincornett / InvoiceController.rb
Created October 5, 2012 20:39
Invoice Transaction
class InvoicesController < ApplicationController
def generate
@accounts = Account.all
@invoices = []
@accounts.each do |a|
inv = Invoice.generate_account_billing(a, params[:invoice])
@invoices << inv
end
@crispincornett
crispincornett / 0_reuse_code.js
Created October 27, 2015 17:46
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
payments.sum(&:price)
payments.inject(0) { |sum, p| sum + p.price }
invoices.map(&:total_due).reduce(0, &:+)
@crispincornett
crispincornett / poly_invoice_example.rb
Last active December 21, 2015 04:58
Polymorphic Invoice Charges
class Invoice < ActiveRecord::Base
belongs_to :account
has_many :charges
end
class Charge < ActiveRecord::Base
belongs_to :invoice
belongs_to :chargeable, :polymorphic => true
delegate :total, to: :chargeable, prefix: true
class Client < ActiveRecord::Base
has_many :accounts
end
class Account < ActiveRecord::Base
belongs_to :client
has_many :invoices
has_many :payments
end
@crispincornett
crispincornett / buttons.vbs
Created September 6, 2017 18:36
IWS Buttons
' Stop command
Dim cmd
cmd = "CMD /C call """ + $GetAppPath() + "restart_w3.vbs"" stop"
$WinExec( cmd, 0, 0)
' Start command
Dim cmd
cmd = "CMD /C call """ + $GetAppPath() + "restart_w3.vbs"" start"
$WinExec( cmd, 0, 0)