Skip to content

Instantly share code, notes, and snippets.

View tomislacker's full-sized avatar

Ben Tomasik tomislacker

View GitHub Profile
@tomislacker
tomislacker / gist:7929597
Last active December 31, 2015 03:48
Dockerfile demo for redis + logstash + elasticsearch + kibana3 (w/ nginx)
FROM ubuntu:latest
MAINTAINER Ben Tomasik < btomasik [at] telkonet {dot} com>
ENV ES_DEB_URLROOT https://download.elasticsearch.org/elasticsearch/elasticsearch/
ENV ES_DEB_FILE elasticsearch-0.90.7.deb
RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list
RUN apt-get update && apt-get upgrade
#####
@tomislacker
tomislacker / buildStatic.sh
Created February 14, 2014 18:09
Building a statically linked suite of git/git binaries for deployment on 32bit hosts
#!/bin/bash
cd $(dirname $0)
LOG_PREFIX=build-static
LOG_STDOUT=${LOG_PREFIX}.stdout
LOG_STDERR=${LOG_PREFIX}.stderr
REMOVE_TARGET_DIR=n
SOURCE_MAKE_CONF=y
@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
@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 / 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 / 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 / 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 / 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 / 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 / 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