Skip to content

Instantly share code, notes, and snippets.

John Ellis deckerego

Block or report user

Report or block deckerego

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@deckerego
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
deckerego / stale_branches.sh
Last active Aug 29, 2015
Remove Stale Git Branches
View stale_branches.sh
# 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
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
deckerego / remove_kernels.sh
Last active Aug 29, 2015
Remove unused kernel packages in Ubuntu
View remove_kernels.sh
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
deckerego / html5conv.bash
Created Sep 16, 2015
Transcode a video to be HTML5 compliant
View html5conv.bash
#!/bin/bash
FILE_PATH="$1"
FILE_DIR=$(dirname "$FILE_PATH")
FILE_NAME=$(basename "$FILE_PATH")
FILE_BASE="${FILE_NAME%.*}"
avconv -i "$FILE_PATH" -vcodec h264 -acodec aac -strict -2 "$FILE_DIR/$FILE_BASE.mp4"
rm -r -f "$FILE_PATH"
@deckerego
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 192.168.1.1
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
deckerego / ReadSensor.java
Last active Nov 10, 2015
Read data from an Adafruit Trinket over USB
View ReadSensor.java
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
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
#!/bin/bash
DEST_DIR="/home/iPod"
FULL_PATH="$1"
ALBUM=$(basename "$FULL_PATH")
NEW_PATH="$DEST_DIR/$ALBUM"
echo "Transcoding into $NEW_PATH"
mkdir "$NEW_PATH"
@deckerego
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
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.