Skip to content

Instantly share code, notes, and snippets.

View daytonn's full-sized avatar
💀
Trying to figure out why I would care to add a status to github

Dayton Nolan daytonn

💀
Trying to figure out why I would care to add a status to github
View GitHub Profile
@daytonn
daytonn / link regex
Created January 14, 2011 07:40
This regex parses an anchor link and grabs the href, hash, and the text.
@daytonn
daytonn / spec_helper.rb
Created February 16, 2011 04:06
This is a boilerplate spec_helper for ralis plugins
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../../../../config/environment", __FILE__)
require 'rspec/rails'
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
RSpec.configure do |config|
@daytonn
daytonn / root_only.sh
Created March 12, 2011 17:28
shell script to check for root user
ROOT_UID=0
if [ "$UID" -ne "$ROOT_UID" ]
then
echo "Must be root to run this script."
exit $E_NOTROOT
fi
@daytonn
daytonn / default-rubygems-bin-file.rb
Created May 25, 2011 04:59
Default bin file for a ruby gem
#!/usr/bin/env ruby
require File.join(File.dirname(__FILE__), *%w".. lib mygem")
require 'optparse'
options = {
:help => false,
:flag => false,
:mandatory => nil
}
@daytonn
daytonn / basic-optparse.rb
Created May 25, 2011 05:23
Basic optparse usage
command = ARGV[0]
options = {
:help => false,
:flag => false,
:mandatory => nil
}
optparse = OptionParser.new do|opts|
opts.on( '-h', '--help', 'Display help screen' ) do
@daytonn
daytonn / no-dock.sh
Created May 25, 2011 15:28
No Dock OS X
defaults write com.apple.dock tilesize -int 1
defaults write com.apple.dock pinning -string start
defaults write com.apple.dock autohide -bool true
killall Dock
@daytonn
daytonn / supress_output.rb
Created May 27, 2011 01:39
Supress Output
def suppress_output(&block)
original_stdout = $stdout
$stdout = fake = StringIO.new
begin
yield
ensure
$stdout = original_stdout
end
@daytonn
daytonn / restore-dock.sh
Created May 27, 2011 05:01
Restore Dock
defaults write com.apple.dock tilesize -int 48
defaults write com.apple.dock pinning -string middle
defaults write com.apple.dock autohide -bool false
killall Dock
@daytonn
daytonn / remove_hash_rockets.sh
Created June 30, 2011 05:25
Remove Hash Rockets, upgrade to ruby 1.9
#search
\:(\w+)\s?=>
#replace
$1:
@daytonn
daytonn / win_platform.rb
Created July 8, 2011 03:20
Determine Windows Ruby Platform (stolen straight from rubygems)
WIN_PATTERNS = [
/bccwin/i,
/cygwin/i,
/djgpp/i,
/mingw/i,
/mswin/i,
/wince/i,
]
def win_platform?