Skip to content

Instantly share code, notes, and snippets.

View rafmagana's full-sized avatar

Rafael Magaña rafmagana

  • Colima, Mexico
View GitHub Profile
screen -X eval 'hardstatus alwayslastline "%{r}[%{w}%n%{r}]"' # this sets the hardstatus to [0], where 0 is the number of window
require 'rubygems'
require 'prowly'
Prowly.notify do |n|
n.apikey = "your_apikey_here"
n.priority = Prowly::Notification::Priority::MODERATE
n.application = "My Site"
n.event = "Alert"
n.description = "Something went wrong!"
end
require 'rubygems'
require 'active_record'
require 'active_record/schema_dumper'
ActiveRecord::Base.establish_connection(
:adapter => "mysql",
:host => "localhost",
:username => "root",
:password => "pwd",
:database => "test"
class Foo
def splat(bar, baz)
[bar, baz]
end
end
class Bar < Foo
def splat(*)
#do whatever you want here, like logging, etc
super
#to use with the MUSh gem's bitly command
function bl() {
response=`bitly $1`
if [[ $response == *http://* ]]; then
echo $response | pbcopy
return 0
fi
echo $response
}
config.after_initialize do
[User, And, All, The, Models, You, Want].each do |model|
model.class_eval do
include FakeActiveRecord3Methods
end
end
end
$ autotest
(Not running features. To run features in autotest, set AUTOFEATURE=true.)
(Not running features. To run features in autotest, set AUTOFEATURE=true.)
(Not running features. To run features in autotest, set AUTOFEATURE=true.)
loading autotest/rspec2
style: Rspec2
bundle exec /opt/local/bin/ruby -rrubygems -e "require 'redgreen'" -S /opt/local/lib/ruby/gems/1.8/gems/rspec-core-2.0.1/bin/rspec --autotest '/Users/raf/projects/_own/ruby/dooby/spec/task_spec.rb' '/Users/raf/projects/_own/ruby/dooby/spec/dooby_module_spec.rb' '/Users/raf/projects/_own/ruby/dooby/spec/list_spec.rb'
-e:1:in `require': no such file to load -- redgreen (LoadError)
from -e:1
@rafmagana
rafmagana / include_vs_when.rb
Created January 17, 2011 21:52
Benchmark to see which is faster, either when *array or array.include?
require 'benchmark'
class Dummy
@VALID_OPTIONS = :first, :last, :all
class << self
def when_find(*args)
case args.first
when *@VALID_OPTIONS
@rafmagana
rafmagana / prowly_god.rb
Created February 4, 2011 16:40
Send notifications to Prowl on God events
God.contact(:prowl) do |c|
c.name = 'your name'
c.apikey = 'your prowl api'
c.group = 'developers'
end
God.contact(:prowl) do |c|
c.name = 'another name'
c.apikey = 'another prowl api'
c.group = 'developers'
@rafmagana
rafmagana / aliaz.sh
Created August 3, 2011 17:51
aliaz function to avoid creating aliases with existing command or aliases names
function aliaz
{
if [ -n "$1" ]
then
read COMMAND ALIAS <<<$(IFS="="; echo $1)
if command -v $COMMAND > /dev/null 2>&1
then
echo "The command or alias '$COMMAND' already exists!"
else
alias $1