Skip to content

Instantly share code, notes, and snippets.

View bltavares's full-sized avatar
💭
I may be slow to respond.

Bruno Tavares bltavares

💭
I may be slow to respond.
View GitHub Profile
@bltavares
bltavares / Include_paths_rails_console.rb
Created June 5, 2011 16:04
Include paths on rails console
include Rails.application.routes.url_helpers
@bltavares
bltavares / speech_input.rb
Created July 1, 2011 20:21
Speech input on Simple_form
#app/inputs/speech_input.rb
class SpeechInput < SimpleForm::Inputs::Base
def input
input_html_options ||= {}
input_html_options.merge!({:"x-webkit-speech" => "", :speech => "", :lang => "en", :"x-webkit-grammar" =>"builtin:search"})
@builder.text_field(attribute_name, input_html_options)
end
end
@bltavares
bltavares / README.md
Created July 8, 2011 00:20 — forked from spicycode/README.md
Yelly the Yellingist Formatter there ever was

YELLY!!!!! THE YELLINGIST FORMATTER EVER!!!!!

Yelly likes to yell. To make the magic happen for simple cases just invoke him ala:

bundle exec rspec --require=./yelly_the_yellingist_formatter.rb --format=YellyTheYellingistFormatter spec/models/your_file_here_spec.rb

In closing, >:O

On Linux, require esddsp (from esd) and festival

@bltavares
bltavares / Readme.md
Created July 17, 2011 21:13 — forked from txus/Readme.md
codebrawl entry - ruby testing libraries

#a

a is a testing framework written in 6 lines of code (or 472 characters) which tries to be performant, with eye-catchy reports and easy to use.

Heavily inspired by Konstantin Haase's almost-sinatra, its long-term purpose is to become the fastest testing framework available.

The idea is to stay under 7 lines with less than 80 chars per line.

@bltavares
bltavares / index.html
Created July 21, 2011 17:05
Konami code for coderwall
<script type="text/javascript" src="http://konami-js.googlecode.com/svn/trunk/konami.js"></script>
<script type="text/javascript">
function increaseAvatar() {
$("#content").animate({width: 900 }, "slow");
$("img.avatar").addClass("big").animate({width: 75, height: 75 }, "slow");
}
function decreaseAvatar() {
$("#content").animate({ width: 800 }, "slow");
$("img.avatar").removeClass("big").animate({ width: 65, height: 65 }, "slow");
@bltavares
bltavares / .bashrc
Created August 10, 2011 01:30
Git Bash prompt
__ps1_plus(){
PS1='[\[\e[1;31m\]\@\[\e[0m\]][\[\e[1;35m\]\u@\h ~> \[\e[1;36m\]\w\[\e[0m\]]\$ \[$(tput setaf 4)$(tput bold)\]$(__git_ps1 "(%s) ")\[$(tput sgr0)\]'
}
[ -z "$PS1" ] && return
GIT_PS1_SHOWDIRTYSTATE=true
#GIT_PS1_SHOWSTASHSTATE=true
GIT_PS1_SHOWUNTRACKEDFILES=true
GIT_PS1_SHOWUPSTREAM=true
export PROMPT_COMMAND=__ps1_plus
@bltavares
bltavares / crawlXML.py
Created August 22, 2011 17:45
Crawler de twitter para buscar todos os tweets (requested by @elvisoliveira)
import urllib
from xml.dom import minidom
class crawlXML:
def __init__(self, user):
self.user = user
print "Crawl setado para o usuario " + self.user
def getProfile(self):
return urllib.urlopen("http://api.twitter.com/1/users/show.xml?screen_name=%s" % self.user).read()
def getFollowersId(self):
@bltavares
bltavares / deploy.sh
Created September 16, 2011 02:54
Git + RSync deployment
#!/bin/bash
cd /repo/path
git checkout deploy
git merge master
rsync --exclude=psd/ --exclude=layout/ -r . user@host
@bltavares
bltavares / twitter_festa.rb
Created September 19, 2011 00:16
A small bot to show the messages on my party
require "net/http"
require "uri"
require "json"
def send_notify(cur_json)
cur_json["results"].each do |tweet|
puts tweet['text']
`notify-send -t 7000 '#{tweet['text']}'`
sleep 7
end
@bltavares
bltavares / blacklist.rb
Created September 21, 2011 03:13
Custom ActiveModel Validator
#coding: utf-8
module Blacklist
class Blacklisting < ActiveModel::EachValidator
def validate_each(record, attr, value)
message = options[:message] || "Ops, esse nome já foi escolhido"
against = options[:against] || []
record.errors.add(attr, message) if against.include? value
end
end