Skip to content

Instantly share code, notes, and snippets.

View leobessa's full-sized avatar

Leonardo Bessa leobessa

View GitHub Profile
True = lambda { |a,b| a }
False = lambda { |a,b| b }
display = lambda { |boolean| boolean['true','false']}
display[True] # => "true"
display[False] # => "false"
And = lambda{ |b1,b2| b1[b2,b1] }
Or = lambda{ |b1,b2| b1[b1,b2] }
module SQLGrowler
class Subscriber < ActiveRecord::LogSubscriber
def sql(event)
super
g = Growl.new("localhost", "ruby-growl", ["ruby-growl Notification"], ["ruby-growl Notification"], nil)
g.notify('ruby-growl Notification',application_name,'%s (%.1fms) %s' % [event.payload[:name], event.duration, event.payload[:sql].squeeze(' ')],1,true)
end
def application_name
@leobessa
leobessa / gitchangelog.sh
Created October 18, 2010 15:27
Git changelog
git log --pretty='format:(%cr) - %s %d' | tail -r
git log --pretty='format:%Cblue(%cr) %Cred%s %Cgreen %d %Creset' | tail -r
#!/usr/bin/env ruby
require 'date'
require 'rubygems'
begin
require 'metric_fu'
require 'reek'
require 'roodi'
rescue LoadError
puts "Error loading gems. Try this: gem install metric_fu reek roodi"
exit
#!/usr/bin/env ruby
require "yaml"
commands = ""
info = YAML.load(`rvm info`)
info.values.first["environment"].each do |k,v|
commands << %Q{export #{k}="#{v}"\n}
end
puts commands
def use_selenium_driver driver
$__capybara_selenium_driver_name = driver
end
def selenium_driver
$__capybara_selenium_driver_name || :firefox
end
def (Capybara::Driver::Selenium).driver
unless @driver
Feature: Manage projects
In order to easily reference projects and keep them up to date
As a project team member
I want to manage projects information
Scenario: Add a new project
Given I am on the home page
When I follow "Create Project"
And I fill in "New project name" with "Unique Vegetable"
And I press "Create Project"
class MariaSapatao < (6..18).include?(Time.now.hour) ? Maria : Joao
end
class Pedro
def do_you_know_jesus?
!!!jesus
end
end
export PATH=/opt/subversion/bin:$PATH
# MacPorts Installer addition on 2009-02-17_at_01:38:51: adding an appropriate MANPATH variable for use with MacPorts.
export MANPATH=/opt/local/share/man:$MANPATH
# Finished adapting your MANPATH environment variable for use with MacPorts.
export JAVA_HOME=/Library/Java/Home
# Setting PATH for MacPython 2.5
# The orginal version is saved in .profile.pysave
class Time
def day_light?
(6..18).include? self.hour
end
end
class Maria
def greet
p "Bom dia"
end