Skip to content

Instantly share code, notes, and snippets.

View werkshy's full-sized avatar

Andy O'Neill werkshy

View GitHub Profile
#!/bin/sh -e
#
# /etc/init.d/pickup: Start the pickup server
#
### BEGIN INIT INFO
# Provides: pickup
# Required-Start: $local_fs $syslog $remote_fs
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Start the autoscaler engine loop in a begin/rescue block
def start_autoscaler
@stopped = false
@heroku_manager = nil
while true do
begin
if @stopped
break
end
self.run_loop
@werkshy
werkshy / git-wtf
Created November 4, 2013 19:43
Don't remember where I found this on github: shows the current state of things (what's been pushed, whether you need to pull)...
#!/usr/bin/env ruby
HELP = <<EOS
git-wtf displays the state of your repository in a readable, easy-to-scan
format. It's useful for getting a summary of how a branch relates to a remote
server, and for wrangling many topic branches.
git-wtf can show you:
- How a branch relates to the remote repo, if it's a tracking branch.
- How a branch relates to integration branches, if it's a feature branch.
#!/usr/bin/env ruby
## git-publish-branch: a simple script to ease the unnecessarily complex
## task of "publishing" a branch, i.e., taking a local branch, creating a
## reference to it on a remote repo, and setting up the local branch to
## track the remote one, all in one go. you can even delete that remote
## reference.
##
## Usage: git publish-branch [-d] <branch> [repository]
##
@werkshy
werkshy / cr
Created October 22, 2013 18:49
Asana code review CLI
#!/usr/bin/env ruby
# cr: send an Asana ticket for code review
# It will add (or re-open) a sub-task called 'Code Review' owned
# by the specified user.
# Usage:
# cr [-a ASANA_ID] [-g GIT_COMMIT] username
#
# - If the Asana ticket ID is given, use that.
@werkshy
werkshy / di
Last active September 8, 2023 15:27
Digitally Imported MPD Script
#!/bin/bash
# Play a Digitally Imported station via MPD
#
# Usage:
# di list
# di trance
# di breaks
#
# Config:
@werkshy
werkshy / start-mysql-in-mem
Created March 29, 2013 14:37
Script to start a second mysql server using ramdisk/tmpfs for unit tests.
#!/bin/bash
DATADIR=/dev/shm/mysql
TMPDIR=/dev/shm/mysql_tmp
MYSQL_SOCKET=/dev/shm/mysql.sock
pkill -9 -f mysql.*datadir.*$DATADIR
mkdir -p $DATADIR
@werkshy
werkshy / Example data
Created February 1, 2013 20:08
Example document
PRIMARY> db.summaryLogEvent.findOne({ organizationId: 242, day: "20130201" })
{
"_id" : ObjectId("510b0631b7458ea19c48ea32"),
"day" : "20130201",
"hours" : {
"0" : {
"minutes" : {
"0" : {
"h" : 70,
"h2" : 5,
@werkshy
werkshy / gist:4692229
Created February 1, 2013 16:08
Slow $inc commands
Fri Feb 1 15:40:01 [conn1232539] update ctp.summaryLogEvent query: { organizationId: 242, day: "20130201" } update: { $inc: { hours.15.minutes.8.o: 1 } } nscanned:1 nupdated:1 keyUpdates:0 locks(micros) w:283655 141ms
Fri Feb 1 15:40:16 [conn1232171] update ctp.summaryLogEvent query: { organizationId: 308, day: "20130201" } update: { $inc: { hours.15.minutes.19.h: 1 } } nscanned:1 nupdated:1 keyUpdates:0 locks(micros) w:1154812 577ms
Fri Feb 1 15:40:21 [conn1232813] update ctp.summaryLogEvent query: { organizationId: 317, day: "20130201" } update: { $inc: { hours.15.minutes.29.o: 1 } } nscanned:1 nupdated:1 keyUpdates:0 locks(micros) w:553760 285ms
Fri Feb 1 15:40:22 [conn1232804] update ctp.summaryLogEvent query: { organizationId: 316, day: "20130201" } update: { $inc: { hours.15.minutes.21.o: 1 } } nscanned:1 nupdated:1 keyUpdates:0 locks(micros) w:2555236 1277ms
Fri Feb 1 15:40:24 [conn1232729] update ctp.summaryLogEvent query: { organizationId: 207, day: "20130201" } update: { $inc: { hours.15.minute
@werkshy
werkshy / gist:4216495
Created December 5, 2012 15:22
Apache logs from
10.0.1.245 - - [04/Dec/2012:18:54:36 +0000] "POST /utility/j_spring_security_check HTTP/1.1" 302 2357 "https://qa-1-admin.energyhub.net/utility/autoLogout.html" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.95 Safari/537.11"
10.0.1.245 - - [04/Dec/2012:18:54:37 +0000] "GET /utility/ HTTP/1.1" 302 437 "https://qa-1-admin.energyhub.net/utility/autoLogout.html" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.95 Safari/537.11"
10.0.1.245 - - [04/Dec/2012:18:54:37 +0000] "GET /utility/login.html HTTP/1.1" 200 2404 "https://qa-1-admin.energyhub.net/utility/autoLogout.html" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.95 Safari/537.11"
10.0.1.245 - - [04/Dec/2012:18:54:37 +0000] "GET /favicon.ico HTTP/1.1" 302 756 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.95 Safari/537.11"
10.0.1.245 - - [04/Dec/2012:18:54:37 +0000] "GET /fa