Skip to content

Instantly share code, notes, and snippets.

1st public gist..this is pretty cool
tweaked my copy of showoff to work with ruby 1.9
see changes here
http://github.com/schacon/showoff/commit/e01d4ef29b204e5674bacff208c3d9ac63bae338
not sure why the gem i d/l'ed didn't have this change.
@mrjabba
mrjabba / cards.rb
Created December 4, 2010 03:37
creating a deck of cards and shuffling in 4 lines of Ruby code -> via Dec Ruby issue PragPub -> http://www.pragprog.com/news/pragmatic-programmer-magazine-special-ruby-issue
suits = %w{ C D H S }
ranks = [ *'2'..'10', *%w{ J Q K A } ]
deck = suits
.product(ranks)
.map(&:join)
hands = deck
.shuffle
.each_slice(13)
puts hands.first.join(", ")
package foo;
import java.util.Set;
import javax.validation.ConstraintViolation;
import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;
import org.hibernate.validator.constraints.ScriptAssert;
@mrjabba
mrjabba / vcprompt.sh
Created January 11, 2011 00:11
vcprompt settings
#git vcprompt settings -> https://github.com/xvzf/vcprompt
alias vcp="vcprompt --format '(%b:%h)'"
export PS1='\u@\h:\w $(vcp)\$'
@mrjabba
mrjabba / activerecord_scoped_query1.rb
Created January 27, 2011 04:52
Find some users who are NOT in this group
#ActiveRecord scoped query left outer join users to members
scope :not_in_group, lambda { |group|
join_clause = User.send(:sanitize_sql_array,
["LEFT OUTER JOIN memberships ON memberships.user_id = users.id WHERE memberships.group_id is not ?", group ])
User.select("distinct(users.id), users.*").joins(join_clause)
}
@mrjabba
mrjabba / bash_notify.sh
Created February 26, 2011 01:35
bash alias and function to notify me when the local build is done
#Add this to your .bashrc file in Ubuntu. Make sure you have the right libs
alias not='notify-send "Build done in DIR: $PWD"'
#bd a function to run an ant target AND be notified about it.
function bd {
if [ -z "$1" ]; then
ant publish;
notify-send "Build done for target (publish) in DIR: $PWD"
else
@mrjabba
mrjabba / format_git_svn_log_for_code_swarm.rb
Created July 1, 2011 00:03
Log formatter for git log that's an git svn clone
require 'nokogiri'
puts "Start formatting git log to remove stuff after the @.."
doc = Nokogiri::HTML(open('log.xml'))
doc.css('event @author').each do |author|
name = author.content
author.content = name[0,name.index('@')]
end
@mrjabba
mrjabba / Short_Bus_Brown.markdown
Created July 24, 2011 18:53
A custom beer recipe of mine that tries to fuse a brown ale and rye ale together.

##Short Bus Brown Ale

###Grains

  • 40L 8oz
  • Special B 4oz
  • Chocolate Rye 2oz

###Malt

  • Amber 10lb (liquid extract)
@mrjabba
mrjabba / finddirtygit.sh
Created July 27, 2011 17:43
Find any dirty git projects in the current working directory and recursively beneath this directory
#!/bin/bash
##############################################################################
# Find any dirty git projects in the current working directory
# and recursively beneath this directory
# copied with thanks to Matthew from
# https://github.com/matthewmccullough/scripts/blob/master/finddirtygit
#
# USAGE:
# finddirtygit