Skip to content

Instantly share code, notes, and snippets.

@johnvilsack
johnvilsack / gist:3504717
Created August 28, 2012 22:00
Get URL Query String in NGINX
// URL Rewriting in NGINX strips query parameters. This is a way to work around the problem.
// Written specifically for use in klein.php
function getURLQuery()
{
$url = parse_url($_SERVER['REQUEST_URI']);
parse_str(urldecode($url['query']), $url['query']);
return $url['query'];
}
@johnvilsack
johnvilsack / Simple UPCEAN Capture Tool
Created October 17, 2012 17:00
Simple UPC/EAN Capture Tool
<?php
// UPC Capture Tool for Linea Pro / Simple Web Portal App
//Includes for Flourish and Connect Lib exist in Router
if(isset($_POST['formItemID']) || $_POST['formItemID'] != '')
{
$connect = new ConnectDB;
$db = $connect->TempScan();
$statement = $db->prepare("INSERT INTO captures (item_id, upc, ean) VALUES (%s, %s, %s)");
@johnvilsack
johnvilsack / gist:3906731
Created October 17, 2012 17:01
UPC EAN Capture Tool
<?php
// UPC Tool for Linea Pro Devices using Simple Web Portal App
// Connection Lib for Flourish exists at Router level!
if(isset($_POST['formItemID']) || $_POST['formItemID'] != '')
{
$connect = new ConnectDB;
$db = $connect->TempScan();
$statement = $db->prepare("INSERT INTO captures (item_id, upc, ean) VALUES (%s, %s, %s)");
@johnvilsack
johnvilsack / Actual Query (I Think)
Created October 23, 2012 20:52
Kris' Super Special Function for Splitting
SELECT TOP 1000 * FROM dbo.doSplit(store_data.feature_list,'<LI>Effective');
@johnvilsack
johnvilsack / es.sh
Created December 3, 2012 23:18
Install ElasticSearch on Ubuntu 12.10
cd ~
sudo apt-get update
sudo apt-get install openjdk-7-jre -y
wget https://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-0.19.11.tar.gz -O elasticsearch.tar.gz
tar -xf elasticsearch.tar.gz
rm elasticsearch.tar.gz
sudo mv elasticsearch-* elasticsearch
sudo mv elasticsearch /usr/local/share
@johnvilsack
johnvilsack / GoVagrant
Last active December 17, 2015 20:59
A stupid simple way to grab a Vagrantfile, customize it, and bring it all online with a consistent folder and hostname
#!/bin/bash
echo "What do you want to call this Vagrant? "
read vmhostname
echo "What port number do you want for web access (:80)? "
read vmport
if [ ! -d $vmhostname ]; then
mkdir $vmhostname
cd $vmhostname
@johnvilsack
johnvilsack / PhalconBootstrap
Created June 17, 2013 21:38
Phalcon Default Bootstrap
<?php
try {
$config = include __DIR__ . '/../app/config/config.php';
$loader = new Phalcon\Loader();
$loader->registerDirs(array(
$config->application->controllersDir,
$config->application->modelsDir
@johnvilsack
johnvilsack / generator
Created June 20, 2013 21:31
Iterator for PHP
function factory($strt, $stop, $plus = 1) {
for ($n = $strt; $n <= $stop; $n += $plus) {
yield $n;
}
}
foreach(factory(1,10) as $output) {
echo $output . "\n";
}
@johnvilsack
johnvilsack / gist:6831252
Created October 4, 2013 19:21
Pre-JSON script for LED toggling
var bone = require('bonescript');
var state = bone.LOW;
bone.pinMode("USR0", bone.OUTPUT);
bone.pinMode("USR1", bone.OUTPUT);
bone.pinMode("USR2", bone.OUTPUT);
bone.pinMode("USR3", bone.OUTPUT);
setInterval(toggle, 10);
function toggle() {
<HTML>
<HEAD>
<title>User Login</title>
<!-- Twitter Bootstrap stylesheet -->
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css">
</HEAD>
<BODY>