Skip to content

Instantly share code, notes, and snippets.

View ohammersmith's full-sized avatar

Otto Hammersmith ohammersmith

View GitHub Profile
@ohammersmith
ohammersmith / gist:48788
Created January 18, 2009 22:14
Ruby script in a Windows batch script
@echo off
goto endofruby
#!/bin/ruby
git_repo = "git://github.com/rails/rails.git"
help = %Q{
Rails Info:
-v, --version Show the Rails version number and quit.
-h, --help Show this help message and quit.
# Taken from the image_science gem.
require 'rubygems'
require 'test/unit/testcase'
require 'test/unit' if $0 == __FILE__
require 'image_science'
class TestImageScience < Test::Unit::TestCase
def deny x; assert ! x; end
@ohammersmith
ohammersmith / .bashrc
Created January 16, 2009 02:04 — forked from henrik/.bashrc
# http://henrik.nyh.se/2008/12/git-dirty-prompt
# http://www.simplisticcomplexity.com/2008/03/13/show-your-git-branch-name-in-your-prompt/
# username@Machine ~/dev/dir[master]$ # clean working directory
# username@Machine ~/dev/dir[master*]$ # dirty working directory
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
#!/usr/bin/ruby
require 'rubygems'
require 'git'
log = "~/gitlog.txt"
tmp = "/tmp/gitlog"
commit = Git.open('.').log.first
message = [
commit.date.strftime('%D'),
def initialize(attributes = nil)
@attributes = attributes_from_column_definition
@attributes_cache = {}
@new_record = true
ensure_proper_type
self.attributes = attributes unless attributes.nil?
self.class.send(:scope, :create).each { |att,value| self.send("#{att}=", value) } if self.class.send(:scoped?, :create)
result = yield self if block_given?
callback(:after_initialize) if respond_to_without_attributes?(:after_initialize)
result
@ohammersmith
ohammersmith / gist:35285
Created December 12, 2008 21:54
Does this mean I'm addicted?
root@monitor:~# cd /etc/munin/
root@monitor:/etc/munin# ls
munin-node.conf munin.conf plugin-conf.d plugins templates
root@monitor:/etc/munin# git init
Initialized empty Git repository in .git/
root@monitor:/etc/munin#
gnod:git-rebase-test otto$ git checkout version_1_0
Switched to branch "version_1_0"
gnod:git-rebase-test otto$ git cherry-pick 6be17bdbf6c87247ac7c2cbeb02ffa760e52cd39
Auto-merged file5.txt
CONFLICT (content): Merge conflict in file5.txt
Automatic cherry-pick failed. After resolving the conflicts,
mark the corrected paths with 'git add <paths>' or 'git rm <paths>' and commit the result.
When commiting, use the option '-c 6be17bd' to retain authorship and message.
Yet another file.
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
<<<<<<< HEAD:file5.txt
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
=======
tempor blah blah blah et dolore magna aliqua. baz baz baz baz baz,
>>>>>>> 6be17bd... Adding some baz's to join the blah's.:file5.txt
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
@ohammersmith
ohammersmith / gist:34352
Created December 10, 2008 15:45
Sniff Windows platform in Ruby
if RUBY_PLATFORM =~ /mswin|mingw/
begin
require 'win32/open3'
rescue LoadError
warn "You must 'gem install win32-open3' to use the github command on Windows"
exit 1
end
else
require 'open3'
end
@ohammersmith
ohammersmith / Reasons git would solve world hunger.markdown
Created December 9, 2008 21:52
Reasons git would solve world hunger

Reasons we should upgrade to git.

  • vendor/rails without a Subversion mirror is a pain in my ass.
  • Even if we did have vendor/rails somehow, we couldn't maintain local patches.
  • Merging doesn't suck.
  • That server crash wouldn't have put our source history in jeopardy.
  • "That Guy" can commit as much as he wants without breaking trunk.
  • I won't have to pare down my pr0n and music collection, since my repository will be smaller than a single SVN check out
  • I won't have to pare down my pr0n and music collection, I won't have to check out a dozen different branches.
  • We could use cool git features like annotate.