Skip to content

Instantly share code, notes, and snippets.

@aelindeman
aelindeman / git-lint-php.sh
Created November 10, 2015 22:16
lint PHP files listed in git status
#/usr/bin/env sh
bin_php=`which php`
for i in `git status --porcelain | awk '{ print $NF }'`; do
if [[ "$i" == *.php ]]; then
$bin_php -l "$i";
fi
done
@aelindeman
aelindeman / batch-git-fetch.sh
Last active November 11, 2015 19:01
run 'git fetch' for all repositories in a folder
#!/usr/bin/env sh
# Alex Lindeman
# 2015-11-11
# Runs 'git fetch' for all repositories in a folder.
target_folder="/srv/git"
git_opts="--prune --no-recurse-submodules"
GIT_DISCOVERY_ACROSS_FILESYSTEM=1
@aelindeman
aelindeman / rc.local
Last active June 29, 2016 04:05
powersave options for Debian on ThinkPad X220
#!/bin/sh +e
# wlan power saving
iw dev wlp3s0 set power_save on
# disable ethernet wake-on-lan
ethtool -s enp0s25 wol d
# audio codec power management
echo '1' > '/sys/module/snd_hda_intel/parameters/power_save'
@aelindeman
aelindeman / cgit.conf
Created November 18, 2015 16:26
Apache 2.4 configuration for cgit
DocumentRoot /usr/share/cgit
<Directory "/usr/share/cgit">
Require all denied
<FilesMatch "\.(css|gif|html?|ico|jpe?g|js|png|txt)$">
Require all granted
</FilesMatch>
</Directory>
ScriptAlias /cgi-bin /usr/lib/cgit
@aelindeman
aelindeman / rutgers-drop-list.sh
Created May 17, 2016 01:43
iptables cron script for Rutgers known attackers list
#!/bin/bash
IPTABLES=$(which iptables)
URL="http://report.rutgers.edu/DROP/attackers"
FILE="/tmp/rutgers-drop-list.txt"
CHAIN="RUTGERSDROP";
# check if chain exists
$IPTABLES -L $CHAIN -n
if [ $? -eq 0 ]; then
@aelindeman
aelindeman / safetrack.js
Created May 19, 2016 16:57
official WMATA SafeTrack schedule as JSON
/**
* Author: Alex Lindeman <hello@ael.me>
* License: public domain
*
* Source: http://www.wmata.com/Images/Mrel/MF_Uploads/SafeTrack_Public.pdf
* Notices:
* - Information subject to change. Visit wmata.com/safetrack for updates.
* - No track work during inauguration week (January 15th - January 21st).
*/
@aelindeman
aelindeman / pre-recieve
Created June 22, 2016 18:53
lint files before allowing git push recieve
#!/bin/bash
oldrev=$1
newrev=$2
refname=$3
while read oldrev newrev refname; do
files=`git diff --name-only ${oldrev} ${newrev}`
objects=`git ls-tree --full-name -r ${newrev}`
@aelindeman
aelindeman / slack-aws-lambda.js
Created June 23, 2016 20:58
yet another CloudWatch-to-Slack AWS Lambda function
const https = require('https');
const url = require('url');
const slack_url = ''; // put your slack webhook URL here
const slack_req_opts = url.parse(slack_url);
slack_req_opts.method = 'POST';
slack_req_opts.headers = {'Content-Type': 'application/json'};
exports.handler = function(event, context) {
@aelindeman
aelindeman / vagrant-slay.sh
Created September 20, 2016 20:48
kill all running vagrant instances
function vslay() {
machines=`vagrant global-status | grep virtualbox | awk '{ print $1 }'`
echo "Destroying VMs: $(echo -n $machines | tr '\n' ' ')"
for i in $machines; do
vagrant destroy --force "$i"
done
}
@aelindeman
aelindeman / attachable-error.rb
Created May 5, 2017 14:53
ruby error with extra field
# error class:
class AttachableError < StandardError
attr_reader :data
def initialize(message = nil, data = nil)
@message = message
@data = data
end
def to_s