Skip to content

Instantly share code, notes, and snippets.


John Ellis deckerego

View GitHub Profile
deckerego / default_vhost
Created Apr 18, 2014
Apache mod_rewrite rule to redirect all traffic except PNGs
View default_vhost
RewriteEngine on
RewriteCond %{REQUEST_URI} !^.*\.png
RewriteRule ^/(.+) /index.html
deckerego /
Last active Aug 29, 2015
Remove Stale Git Branches
# Find branches already merged
git branch -a --merged
# Find a list of branches by date and author
git for-each-ref --sort=committerdate --format='%(committerdate:short) %(authorname) %(refname:short)' | grep "origin"
# Prune your locally cloned version
git fetch -p
git gc --prune=now
git remote prune origin
deckerego / interfaces
Created Feb 1, 2015
Raspberry Pi Wireless Config
View interfaces
auto lo
iface lo inet loopback
iface eth0 inet dhcp
allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp
deckerego /
Last active Aug 29, 2015
Remove unused kernel packages in Ubuntu
sudo dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get -y purge
deckerego / html5conv.bash
Created Sep 16, 2015
Transcode a video to be HTML5 compliant
View html5conv.bash
FILE_DIR=$(dirname "$FILE_PATH")
FILE_NAME=$(basename "$FILE_PATH")
avconv -i "$FILE_PATH" -vcodec h264 -acodec aac -strict -2 "$FILE_DIR/$FILE_BASE.mp4"
rm -r -f "$FILE_PATH"
deckerego / wifi
Created Sep 23, 2015
Monit 5.8 configuration to re-start network interfaces when they lose their link
View wifi
check host gateway with address
start "/usr/sbin/service networking start"
stop "/usr/sbin/service networking stop"
if failed icmp type echo count 5 with timeout 10 seconds
then restart
if 4 restarts within 5 cycles
then exec /sbin/reboot
deckerego /
Last active Nov 10, 2015
Read data from an Adafruit Trinket over USB
import java.nio.*;
import org.usb4java.*;
public class ReadTrinket {
public static void main(String args[]) {
Context context = init();
DeviceHandle trinketHandle = openDevice();
try {
int result = LibUsb.claimInterface(trinketHandle, (short) 0x00);
deckerego / convert_mp4.bash
Last active Nov 23, 2015
Transcode all archived music in a directory to MP4, preserving base directory layouts
View convert_mp4.bash
ALBUM=$(basename "$FULL_PATH")
echo "Transcoding into $NEW_PATH"
mkdir "$NEW_PATH"
deckerego / odd_http_traffic_patterns.r
Created Dec 6, 2013
If you consider aberrant traffic hit rates ones that are more or equal to two standard deviations away from the mean
View odd_http_traffic_patterns.r
# Massage your data into a data frame that provides access by Hour and URI
traffic.df <- parse.log("access.log") #parse.log is left as an exercise for the reader
# Aggregate
uri.hits <- ddply(traffic.df, .(Hour, URI), summarise, Hits=length(URI), .parallel = TRUE)
uri.stats <- ddply(uri.hits, .(URI), summarise, Mean=mean(Hits), Variance=sd(Hits), Total=sum(Hits), .parallel = TRUE)
uri.stats <- join(uri.hits, uri.stats, c("URI"))
# Find two std dev away from mean
uri.bad <- subset(uri.stats, Variance > 0)
deckerego / rabbitmq_stats.r
Created Dec 6, 2013
Reading RabbitMQ Message Statistics
View rabbitmq_stats.r
queueStatsToDataframe <- function(uri, username, password) {
uri <- paste(uri, "api/queues", sep="/")
credentials = paste(username, password, sep=":")
doc <- getURL(uri, userpwd=credentials, httpauth=1L)
src <- fromJSON(doc)
items.df <- data.frame()
if(length(src) > 0) {
for(i in 1:length(src)) {
if(length(src[[i]]$messages_details) == 3) {
You can’t perform that action at this time.