Skip to content

Instantly share code, notes, and snippets.

@blindsey
blindsey / deploy.rb
Last active October 20, 2016 04:23
PIvotal Tracker Auto-Deliver Hotness
namespace :pivotal_tracker do
desc "deliver this projects 'finished' stories"
task :deliver do
next unless ENV['PIVOTAL_TRACKER_TOKEN']
require 'pivotal-tracker'
PivotalTracker::Client.use_ssl = true
PivotalTracker::Client.token = ENV['PIVOTAL_TRACKER_TOKEN']
project = PivotalTracker::Project.find(1786309)
stage, current, previous = fetch(:stage), fetch(:current_revision), fetch(:previous_revision)
@blindsey
blindsey / ViewController.m
Created March 20, 2014 22:34
MKLocalSearch reverse zip code lookup
//
// ViewController.m
// Ziptastic
//
// Created by Ben Lindsey on 3/20/14.
// Copyright (c) 2014 Ben Lindsey. All rights reserved.
//
#import "ViewController.h"
#import <MapKit/MapKit.h>
@blindsey
blindsey / post-commit.sh
Last active August 28, 2016 15:00
git post-commit to take a photo every time you commit
#!/bin/bash
EXEC=/usr/local/bin/imagesnap
if [ -x $EXEC ]; then
FILE="$HOME/gitshots/`date +%s`.jpg"
echo "Taking capture into $FILE"
$EXEC -q -w 3 $FILE
fi
exit 0
@blindsey
blindsey / pre-commit.sh
Last active July 20, 2017 14:20
git pre-commit hook for puppet-lint
#!/bin/bash
EXEC=/usr/bin/puppet-lint
if [ -x $EXEC ]; then
git status -s | grep -v ^D | grep '.pp$' | awk '{print $2}' | xargs $EXEC --with-filename
if [ $? -ne 0 ]; then
echo -e "\033[38;5;148m!! Commit rejected due to puppet-lint ERROR !!\033[0m"
exit 1
fi
fi
exit 0
@blindsey
blindsey / cluster.js
Created April 29, 2013 21:29
Cluster script for running multiple node processes
#!/usr/bin/env node
var cluster = require('cluster');
var WORKERS = require('os').cpus().length;
console.debug = function(msg) {
console.log('%s %s', new Date().toISOString(), msg);
}
if (cluster.isMaster) {
@blindsey
blindsey / gist:4068596
Created November 13, 2012 21:43
Vungle Programming Question - Miles of Tiles

You have a picture frame. You would like to decorate the frame by gluing tiles on it. The frame is a square shape.

The frame is 1 inch wide all around. The inside of the frame is a 12 by 12 inches square. The outside of the frame is 14 by 14 inches square. There are 8 tiles, each a different length (3, 4, 5, 6, 7, 8, 9 and 10 inches) which can only be used once.

14 inches
12 inches

Determine how the 8 tiles should be placed in order to cover the frame with tiles. How many different arrangements are there? Write a program that prints out all of them.

@blindsey
blindsey / ssh_config.rb
Created October 19, 2012 03:57
EC2 ssh config builder for aliases
#!/usr/bin/env ruby
require 'rubygems'
require 'aws'
File.open("#{ENV['HOME']}/.ssh/config", 'w') do |file|
@ec2 = Aws::Ec2.new(ENV['AWS_KEY'], ENV['AWS_SECRET'])
@ec2.describe_instances.each do |instance|
next unless instance[:aws_state] == 'running'
@blindsey
blindsey / redis.js
Created June 15, 2012 19:13
node.js redis status page
app.get('/redis-status', function(req, res, next) {
redis.info(function(error, result) {
if (error) { return next(error); }
var info = {};
result.split(/\r\n/).forEach(function(line) {
var fields = line.split(/:/);
info[fields[0]] = fields[1];
});
@blindsey
blindsey / mongo.sh
Created January 21, 2012 01:33
init script for mongod on ubuntu
#! /bin/sh
### BEGIN INIT INFO
# Provides: mongodb
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the mongodb data-store
# Description: starts mongodb using start-stop-daemon
@blindsey
blindsey / common.js
Created October 3, 2011 22:44
A really cool JS library
/**
* OVEE namespace
*/
OVEE = {
BLOCKED_COMMENT_TEXT : 'This comment has been removed by the moderator'
};
/**
* Number
*/