Skip to content

Instantly share code, notes, and snippets.

View jveldboom's full-sized avatar

John Veldboom jveldboom

View GitHub Profile
@jveldboom
jveldboom / class.onixSplitter.php
Created March 11, 2014 15:13
Split ONIX files into smaller chunks
<?php
class onixSplitter
{
function split($file,$header,$footer,$split_at=2000)
{
$this->file = $file;
$this->header = $header;
$this->footer = $footer;
$this->split_at = $split_at;
$this->write_num = 1; // starting number for files written
@jveldboom
jveldboom / SystemStats.php
Created October 30, 2014 20:51
Combine sar system stats
<?php
/**
* sar documentation http://linux.die.net/man/1/sar
*/
class SystemStats
{
function __construct($sar)
{
$this->sar = $sar;
}
<?php
require '../includes/class.common.php';
require '../includes/class.images.php';
$common = new common;
$images = new images;
// mysql connection
$conn=mysqli_connect("localhost","database","password","database_name");
// Check connection
if (mysqli_connect_errno($conn)) {
@jveldboom
jveldboom / heka-system.conf
Created January 21, 2015 13:44
monit heka config
check process hekad-system with pidfile /var/run/hekad-system.pid
start program = "/bin/bash -c 'hekad --config=/usr/share/heka/conf.d/system.toml'" with timeout 60 seconds
stop = "/bin/bash -c 'kill -s SIGTERM `cat /var/run/hekad-system.pid`'"
@jveldboom
jveldboom / gist:87615b2a5d49ac04e2c3
Created February 20, 2015 20:36
Apache prefork
<?php
$workers = 400;
//10000
echo 'StartServers '.($workers * .3).PHP_EOL;
echo 'MinSpareServers '.($workers * .05).PHP_EOL;
echo 'MaxSpareServers '.($workers * .10).PHP_EOL;
echo 'ServerLimit '.($workers).PHP_EOL;
echo 'MaxRequestWorkers '.($workers).PHP_EOL;
echo 'MaxRequestsPerChild 10000';
@jveldboom
jveldboom / goaccess.conf
Created May 22, 2015 01:47
GoAccess Log Formats
# stld
log-format %h %^[%d:%t %^] "%m %r %H" %s %b "%u"
# invubu
log-format %h %^[%d:%t %^] %m "%U" "%^" %^ %s %T %b "%u"
@jveldboom
jveldboom / getMiddleRange.js
Created April 7, 2011 12:38
find the a range in between two numbers
function getMiddleRange(min,max,limit,type)
{
--limit;
var new_num
var data = '';
for(var x=0; x<=limit; x++)
{
var new_num = Math.ceil((max - min) / limit);
new_num = min + (new_num * x);
if(x==0){new_num = min;}
@jveldboom
jveldboom / json.lua
Last active October 9, 2015 06:38
Heka JSON Decoder
require "cjson"
local dt = require "date_time"
--[[
From trink in IRC - thanks!
Example use:
[HttpListenInput]
address = "0.0.0.0:8325"
@jveldboom
jveldboom / order.json
Last active October 20, 2015 16:27
test order
{
"order_num": "5066",
"customer_id": "1",
"po_num": null,
"email": "john@veldboom.com",
"phone": "",
"billing_name": "JOHN VELDBOOM",
"billing_addr1": "289 W MAIN ST",
"billing_addr2": "",
"billing_city": "NESS CITY",
@jveldboom
jveldboom / bash-loading-spinner.sh
Created February 24, 2013 03:15
Bash Loading Spinner
#!/bin/bash
spinner()
{
local pid=$1
local delay=0.4
local spinstr='|/-\'
while [ "$(ps a | awk '{print $1}' | grep $pid)" ]; do
local temp=${spinstr#?}
printf " [%c] " "$spinstr"
local spinstr=$temp${spinstr%"$temp"}