Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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)\$'
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 / 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(", ")
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.
1st public gist..this is pretty cool