Skip to content

Instantly share code, notes, and snippets.

@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.
// 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 / 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,
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 / 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 / index.js
Last active August 29, 2015 14:26
Standard Index for ActiveScan index.js
function onConnectivityChange(state) {
console.log("Connection is: " + state);
}
function onBarcodeScanned(data) {
console.log(data.barcode);
}
var app = {
initialize: function() {
@johnvilsack
johnvilsack / ResponseQueryAuthCards
Created November 30, 2011 16:12
Response Query on Already Authorized Cards
SELECT
SYSOENT.ORDER_STATUS,
SYSOENT.PO_NUMBER,
SYSOENT.ORDER_NO,
SYSOENT.ORDER_SOURCE,
SYSOENT.AUTH_CODE,
SYSOENT.AUTH_DATE,
SYSOENT.CREATED_BY,
SYSOENT.ORDER_DATE,
SYSOENT.CUSTOMER_ID,
<?php
class CRUD {
private $DB;
public function __set($name, $v) {
switch ($name) {
case 'username':
$this->username = $v;
<?php
include('db.class.php');
// Instantiate
$CRUD = new CRUD();
// Set Connection Vars
$CRUD->database = "mysql:dbname=sessions;host=localhost";
$CRUD->username = 'test';
@johnvilsack
johnvilsack / index
Created December 16, 2011 15:41
Twitter Bootstrap Template w/ JQuery
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
<meta name="description" content="">
<meta name="author" content="">
<!--[if lt IE 9]><script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>