Skip to content

Instantly share code, notes, and snippets.

View bgreenlee's full-sized avatar

Brad Greenlee bgreenlee

View GitHub Profile
@bgreenlee
bgreenlee / twitdiff.rb
Created July 28, 2009 23:23
Script for unfollowing Twitter users who aren't following you, # or following users who are following you...or both
#!/usr/bin/env ruby
# twitdiff.rb
# Quickie script for unfollowing users who aren't following you,
# or following users who are following you...or both
# Requires Grackle (http://github.com/hayesdavis/grackle/tree/master):
# sudo gem sources -a http://gems.github.com
# sudo gem install hayesdavis-grackle
>> ("0".."10").to_a
=> ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"]
>> ("1".."10").to_a
=> ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"]
>> ("2".."10").to_a
=> []
>> ("2".."9").to_a
ffmpeg -f image2 -r 24 -i ./frames/code_swarm-%05d.png -sameq out.mov -pass 2
require 'open-uri'
content = nil
puts "Valid cert:"
open("https://www.wesabe.com") { |s| content = s.read }
puts " got #{content.length} bytes"
puts "Invalid cert: "
open("https://google.com") { |s| content = s.read }
puts " got #{content.length} bytes"
@bgreenlee
bgreenlee / pushups crontab
Created March 23, 2010 18:00
reminder to do pushups every hour while at work
# reminder to do pushups every hour while at work
45 9-17 * * 1-5 /usr/local/bin/growlnotify -m "pushups"
@bgreenlee
bgreenlee / bsearch.rb
Created April 19, 2010 21:27
Binary Search
# Taking on the Binary Search challenge
# http://reprog.wordpress.com/2010/04/19/are-you-one-of-the-10-percent/
class Array
# Binary search; assumes array is sorted
# If value is found in the array, it returns an index where it can be found.
# If the value occurs multiple times in the array, it will just return the
# first place it is found (not necessarily the first occurrence in the array).
# If the value is not found, it returns nil.
def bsearch(value)
@bgreenlee
bgreenlee / homevnc.sh
Created June 18, 2010 22:16
Script to open up a Screen Sharing session in OS X to a home computer over SSH
#!/bin/sh
# port you have open on your home router to forward ssh
SSH_PORT=22022
# set up dynamic dns if you don't have a static ip
HOST=your.home.ip
# OSX Screen Sharing will complain if you try to connect to the standard
# VNC ports (5900+) on localhost, so pick another available port
LOCAL_PORT=1202
#!/bin/bash
# Pop up a reminder at given time (or a given amount of time from now)
#
# Usage:
# remindme "Go home" 5pm
# remindme "Move the car" +2 hours
# remindme "Call Bob" tomorrow
#
# For more on possible time formats, 'man at'
# install ruby 1.9.2 on OS X
rvm package install readline
rvm package install iconv
rvm install 1.9.2 -C --enable-shared,--with-iconv-dir=$HOME/.rvm/usr,--with-readline-dir=$HOME/.rvm/usr,--build=x86_64-apple-darwin10
@bgreenlee
bgreenlee / xcode_auto_versioning.rb
Created January 22, 2011 05:48
Xcode Auto-Versioning: Updates your Info.plist's CFBundleVersion with the current git tag and/or sha. #xcode #git
# Xcode Auto-Versioning
#
# Updates your Info.plist's CFBundleVersion with the current git tag and/or sha.
#
# based on https://github.com/elliottcable/xcode-git-versioner
#
# Usage:
# 1. Right-click the target you want to add the versioning phase to (usually the target that builds your app)
# 2. Select: Add -> New Build Phase -> New Run Script Build Phase
# 3. Specify /usr/bin/env ruby as the shell for the script