Skip to content

Instantly share code, notes, and snippets.

View nsmith's full-sized avatar
🍕
Eat pizza get strong

Nathan Smith nsmith

🍕
Eat pizza get strong
  • Amazon
  • Seattle, WA
View GitHub Profile
def create_directly
@attachment = Attachment.new
file_name = params[:file_name]
if request.body.class == StringIO
FileUtils.mkdir "#{Rails.root}/tmp/" + @attachment.id.to_s
file = File.open("#{Rails.root}/tmp/" + @attachment.id.to_s + "/" + file_name, "w")
file << request.body.string
file.close
@attachment.attachment = File.open("#{Rails.root}/tmp/" + @attachment.id.to_s + "/" + file_name, "r")
class rfidDevice
{
eventHandler = null;
serPort = null;
enabled = true;
rxData = "";
name = "Source";
type = "string";
@nsmith
nsmith / crossover_skus.rb
Last active December 18, 2015 04:18
Sub sku crossover skus
def crossover_sku(sku)
sku1 = sku.code.split("-")[0..3].join("-")
sku2 = sku.code.split("-")[4..7].join("-")
[sku1, sku2]
end
@nsmith
nsmith / dashboard_post.sh
Created June 17, 2013 13:17
Post data to cloud dashboard
curl -X POST -H "Content-Type: application/json" -d '{
"clock": {
"offset": -14400
},
"gauges": [
{
"label": "EMAIL",
"position": 75.8948
},
{
@nsmith
nsmith / manual_transfer_to_sales_order
Created August 7, 2013 22:06
Sending a 940 from a transfer order
transfer_proc = Elvis::Processes::Outbound::OhlTransfer.new(CONFIG, CONFIG["netsuite"]["ohl_transfers"], {:warehouse_code => "OCP"})
transfer = NetSuite::Records::TransferOrder.get(:internal_id => 1234)
transfer_proc.send_sales_order(transfer)
// =FACTORY=AGENT============================================================== //
const projectName = "Pivot Power Genius"
// Factory IMP Device Code
// ---------------------------------------------------------------------------- //
const MAJOR_VER = 0; // Major Version of this Release
const MINOR_VER = 1; // Minor Version of this Release
const RELEASE = 0; // Release Number of this Version
// ---------------------------------------------------------------------------- //
// Revision History
// V0.1.0 - <_G> Initial Release
mac <- imp.getmacaddress()
impeeid <- hardware.getimpeeid()
agent.send("register", { mac = mac, impeeid = impeeid })
@nsmith
nsmith / gist:7108663
Created October 22, 2013 21:40
pivot power run 1
2013-10-22 17:38:43 UTC-4: [Status] Device booting
2013-10-22 17:38:43 UTC-4: [Device] Bank 1 set to 0.
2013-10-22 17:38:43 UTC-4: [Device] Bank 1 is online.
2013-10-22 17:38:43 UTC-4: [Device] Bank 2 set to 0.
2013-10-22 17:38:43 UTC-4: [Device] Bank 2 is online.
2013-10-22 17:38:43 UTC-4: [Device] Pivot Power Genius
2013-10-22 17:38:43 UTC-4: [Device] Firmware Version: v0.2.2
2013-10-22 17:38:44 UTC-4: [Device] Device ID: 20000c2a69028be9
2013-10-22 17:38:44 UTC-4: [Status] Device configured to be "Pivot Power Genius"
2013-10-22 17:38:44 UTC-4: [Device] Node Registered
@nsmith
nsmith / gist:7108680
Created October 22, 2013 21:41
pivot power run 2
2013-10-22 17:40:24 UTC-4: [Status] Device booting
2013-10-22 17:40:24 UTC-4: [Agent] Pivot Power Genius Agent Running
2013-10-22 17:40:24 UTC-4: [Agent] Agent Version: v0.3.2
2013-10-22 17:40:24 UTC-4: [Agent] State::restoreState checking state package for possible state to restore
2013-10-22 17:40:24 UTC-4: [Agent] winkDeviceId = 430
2013-10-22 17:40:24 UTC-4: [Agent] hmacSha1Psk = 59b080e4e2ab2d0535e453f96cef8e4cf3119e68
2013-10-22 17:40:24 UTC-4: [Agent] stateEndpoint = https://winkapi.quirky.com/powerstrips/430
2013-10-22 17:40:24 UTC-4: [Agent] tokenEndpoint = https://winkapi.quirky.com/oauth2/token
2013-10-22 17:40:24 UTC-4: [Agent] accessToken = 06264e2806719ed9306a1e0d56217f70
2013-10-22 17:40:24 UTC-4: [Agent] refreshToken = f55ce8762538131bc3d86b5211353ace
#!/usr/bin/env node
var fs = require('fs'),
stream = require('stream'),
path = require('path'),
cadence = require('cadence'),
run = require('./monitor/run')
require('cadence')(module, cadence(function (step, options) {
var pems = {}, config = {}, params = {}, useSSL