Skip to content

Instantly share code, notes, and snippets.

@johnvilsack
johnvilsack / index.js
Created July 30, 2015 18:29
Standard index.js for /ttatarinov/lineapro-phonegap-plugin
function onDeviceConnected(data) {
alert("onDeviceConnected: " + data);
}
function onSuccessScanPaymentCard(data) {
alert("onSuccessScanPaymentCard: " + data);
}
function onBarcodeScanned(data) {
alert("onBarcodeScanned: " + data.rawCodesArr);
@johnvilsack
johnvilsack / ClientSide CSV Rendering (Drag and Drop) Version
Created July 23, 2015 16:03
Drag and drop target that uses Papaparse to read a JSON file into an object; all client side.
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<style>
html {margin-top:40px;}
</style>
</head>
SELECT
RTRIM(ITEM_ID) AS ITEM_ID
FROM INVENTOR
WHERE
(
ENTRY_DATE >= '2015-01-01'
OR
(AVAILABLE > 0 OR ON_ORDER_QTY > 0 OR COMMITTED_QTY > 0)
)
AND
@johnvilsack
johnvilsack / CONNECTSHIP_ORDERINFO
Created July 8, 2015 13:37
SQL View of ConnectShip order data
SELECT
dbo.SYSOENT.ORDER_STATUS,
dbo.SHIPTO.SHIPTO_ID,
dbo.SHIPTO.ORDER_NO,
RTRIM(dbo.SHIPTO.SHIPMETH_CODE) AS SHIPMETH_CODE,
RTRIM(dbo.SHIPTO.COMPANY_NAME) AS SHIPTO_COMPANY_NAME,
RTRIM(dbo.SHIPTO.LAST_NAME) AS SHIPTO_LAST_NAME,
RTRIM(dbo.SHIPTO.FIRST_NAME) AS SHIPTO_FIRST_NAME,
RTRIM(dbo.SHIPTO.ADDRESS_LINE1) AS SHIPTO_ADDRESS_LINE1,
// Use the package, HTTP.
var http = require('http');
// In the package HTTP, execute createServer
http.createServer(function (req, res) {
// When createServer sees a request, shoot a header with a status 200 (this means OK) and tell it the next bit is text/plain
res.writeHead(200, {'Content-Type': 'text/plain'});
// This is the bits that go to the browser
@johnvilsack
johnvilsack / gist:cfe7a36c0582d4ebf8cc
Created December 15, 2014 17:10
Simple PDO to File Cache for PHP
<?php
// This is a simple way to cache queries to your local filesystem while maintaining control over their freshness.
// Great for those nasty archival queries that data changes don't happen to.
// Free to all, forever - John Vilsack 2014
$file = './cache/**FILENAME**.cache'; // Path and name of .cache file
$expire = 900; // # of seconds before cache is stale
// Function to create the cached file.
@johnvilsack
johnvilsack / Übersicht YouTube Widget
Created August 6, 2014 20:14
YouTube on your desktop, courtesy of Übersicht
command: "",
refreshFrequency: 138000,
render: function (output) {
return "<iframe width=\"1880\" height=\"1250\" src=\"//www.youtube.com/embed/lhdJODImBL8?version=3&autoplay=1&loop=1&controls=0&showinfo=0&playlist=lhdJODImBL8\" frameborder=\"0\" allowfullscreen></iframe>";
},
style: " \n\
top: -100px \n\
@johnvilsack
johnvilsack / MYSQL-Select.go
Created July 14, 2014 18:55
Go: Idiomatic SELECT for MySQL
package main
import (
"database/sql"
"log"
_ "github.com/go-sql-driver/mysql"
)
var (
@johnvilsack
johnvilsack / SampleJSONResult.js
Created June 25, 2014 20:22
Sample Go Application that grabs Item data from custom call
{
"query": "MISC01",
"count": 1,
"objects": [
{
"ITEM_ID": "MISC01",
"UPC": "867530900000",
"ITEM_DESC": "MISC ITEM $0-25",
"PROD_CLASS_ID": "MISC",
"AVAILABLE": "999",
@johnvilsack
johnvilsack / gist:8a0653448d4877ffa7e0
Created June 25, 2014 14:24
Sample of getting JSON (dumping errors so don't use)
func apiGetItem(q string) *queryItem {
requestURL := "http://epoch.app/inventory/apiGetItemInfo.php?q=" + q
getQuery, _ := http.Get(requestURL)
defer getQuery.Body.Close()
resultQuery, _ := ioutil.ReadAll(getQuery.Body)
payload := &queryItem{}
ok := json.Unmarshal(resultQuery, payload)
return payload
}