Skip to content

Instantly share code, notes, and snippets.

View bgreenlee's full-sized avatar

Brad Greenlee bgreenlee

View GitHub Profile
@bgreenlee
bgreenlee / strip_trailing_whitespace.py
Created July 19, 2011 00:27
Sublime Text 2 plugin to strip trailing whitespace #python #sublimetext
import sublime_plugin
class StripTrailingWhitespaceCommand(sublime_plugin.TextCommand):
"""
Strip whitespace from the end of each line in the file.
"""
def run(self, edit):
trailing_white_space = self.view.find_all("[\t ]+$")
trailing_white_space.reverse()
for r in trailing_white_space:
@bgreenlee
bgreenlee / github.com.js
Created June 29, 2011 05:33
dotjs (http://defunkt.io/dotjs/) script to hide the GitHub one-click merge pull request button, which makes a mess of your repo #github #javascript
// hide the evil merge button
$("#js-mergeable-clean").hide()
@bgreenlee
bgreenlee / Versioning.sh
Last active June 13, 2022 16:42
Automatic project versioning for Xcode using git commits & tags #xcode #git
#!/bin/sh
# Versioning.sh
#
# https://gist.github.com/791352 by Marc Hedlund
#
# Found at http://kswizz.com/post/2686511526/git-xcode-versioning and slightly
# modified.
# To install:
@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
# 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
#!/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'
@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
@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 / 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"
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"