Instantly share code, notes, and snippets.

View add-gplv3.sh
#!/bin/bash
for i in $(git ls | grep "\.rb$"); do
year=$(git log --follow --diff-filter=A $i | grep Date | tail -1 | awk '{ print $6 }')
echo "Adding GPL3 header w/ year $year to $i"
cat ~/lic.txt |sed "s|THEDATE|$year|" | cat - $i > /tmp/temp && mv /tmp/temp $i
done
View jenkins-api-examples
# check if job exists
curl -XGET 'http://jenkins/checkJobName?value=yourJobFolderName' --user user.name:YourAPIToken
# with folder plugin
curl -s -XPOST 'http://jenkins/job/FolderName/createItem?name=yourJobName' --data-binary @config.xml -H "Content-Type:text/xml" --user user.name:YourAPIToken
# without folder plugin
curl -s -XPOST 'http://jenkins/createItem?name=yourJobName' --data-binary @config.xml -H "Content-Type:text/xml" --user user.name:YourAPIToken
# create folder
View plex.nginx.conf
# This example assumes the NGINX proxy is on the same host as the Plex Media Server.
# To configure Plex Media Server to serve requests without requiring authentication,
# ensure that your LAN subnet is correctly added to the advanced server setting called
# "List of IP addresses and networks that are allowed without auth". Example:
# 192.168.0.1/24
upstream plex-upstream {
server 127.0.0.1:32400;
}
View bundle exec derailed bundle:mem.txt
$ bundle exec derailed bundle:mem
TOP: 39.8594 MiB
rails/all: 13.5508 MiB
active_record/railtie: 6.5781 MiB
active_record: 4.8164 MiB (Also required by: authlogic)
active_record/connection_adapters/abstract_adapter: 2.1992 MiB
active_record/connection_adapters/abstract/schema_statements: 0.7383 MiB
active_record/migration/join_table: 0.3555 MiB
active_record/migration: 0.3398 MiB
active_record/type: 0.4648 MiB
View redis_key_sizes.sh
#!/usr/bin/env bash
# This script prints out all of your Redis keys and their size in a human readable format
# Copyright 2013 Brent O'Connor
# License: http://www.apache.org/licenses/LICENSE-2.0
human_size() {
awk -v sum="$1" ' BEGIN {hum[1024^3]="Gb"; hum[1024^2]="Mb"; hum[1024]="Kb"; for (x=1024^3; x>=1024; x/=1024) { if (sum>=x) { printf "%.2f %s\n",sum/x,hum[x]; break; } } if (sum<1024) print "1kb"; } '
}
View curl_all.sh
#!/bin/bash
[ ! $1 ] && echo "you must include a file containing urls, one per line" && exit 1
while read LINE; do
curl -o /dev/null --silent --progress-bar --head --write-out '%{http_code} %{time_starttransfer} %{url_effective}\n' "$LINE"
done < $1