Skip to content

Instantly share code, notes, and snippets.

View tomislacker's full-sized avatar

Ben Tomasik tomislacker

View GitHub Profile
@tomislacker
tomislacker / php_predefined_classes.md
Last active June 11, 2020 18:40
PHP Pre-Defined Classes

PHP Pre-Defined Classes

This gist was something I did quickly in order to see what other built-in exception types I could throw.

PHP Version

PHP 5.4.36-pl0-gentoo (cli) (built: Dec 29 2014 22:12:26) 
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
@tomislacker
tomislacker / freenas_fun.md
Created December 24, 2014 03:45
freenas fun

FreeNAS Fun

About

@TODO

Operations

Get CPU Temps

sysctl -a |egrep -E "cpu\.[0-9]+\.temp"
@tomislacker
tomislacker / hacky-motion-track.py
Created December 19, 2014 23:55
Hacky Motion Tracking Example
#!/usr/bin/env python
import cv
import sys
import argparse
import os.path
import time
import math
@tomislacker
tomislacker / dd_emulator.sh
Last active August 29, 2015 14:10
Emulate SIGUSR1 Signal Output from DD
#!/bin/bash
###
# dd emulator
###
BYTES_PER_RECORD=512
BYTES_TOTAL=1020837888
BYTES_RATE=$((10*1024*1024))
BYTES_RATE_FUDGE=$((1*1024*1024))
@tomislacker
tomislacker / get_gz_size.py
Created November 21, 2014 22:21
How to find out the uncompressed size of a .gz file without calling `gzip -l`
def get_gz_size(gzipfile):
f = open(gzipfile, "rb")
if f.read(2) != "\x1f\x8b":
raise IOError("not a gzip file")
f.seek(-4, 2)
return struct.unpack("<i", f.read())[0]
@tomislacker
tomislacker / cam-detect.py
Created August 19, 2014 16:08
Basic motion detection
#!/usr/bin/env python
import cv
import sys
class Target:
def __init__(self):
# CaptureFromFile or CaptureFromCAM
if sys.argv[1] == '-':
@tomislacker
tomislacker / microtime.sh
Last active September 11, 2018 15:10
Shell Get 'microtime(TRUE)'
#!/bin/bash
DEFAULT_SCALE=4
getMicrotime ()
{
date +%s%N
}
microElapse ()
@tomislacker
tomislacker / git.status.color
Created July 22, 2014 19:34
Little shell script for outputting titles
#!/bin/bash
watch --color -tn 1 "( printTitle.sh -Nt$(date +'%Y-%m-%d_%H:%M:%S') ; echo ; printTitle.sh -c: -Ntgit-status ; git status ; echo ; printTitle.sh -c: -Ntgit-branches ; git branch -a -v | cut -c -$(($(tput cols)-2)) ; echo ; printTitle.sh -c: -Ntgit-remotes; git remote -v show) | ccze -A"
@tomislacker
tomislacker / exampleMap.php
Created March 26, 2014 13:40
Using array_map to escape strings with closures and mysql_real_escape_string
<?php
$db = @mysql_connect(HOST, USER, PASS);
$newRecord = array(
'Name' => 'tomislacker',
'Email' => 'notfor@you.me'
);
$keys = array_map(
@tomislacker
tomislacker / replace.sh
Created March 12, 2014 16:16
MegaRAID Failed Drive Replacement
###
# Marking the drive at enclosure 32, slot 0, on adapter 0 as bad and preparing for removal
###
# 1) Tell the controller that we'd like to take this disk offline
MegaCli64 -PDOffline -PhysDrv [32:0] -a0
# 2) Tell the controller that this disk will be missing and we're ok with that.
MegaCli64 -PDMarkMissing -PhysDrv [32:0] -a0
# 3) Tell the controller to sping down the disk for removal