Skip to content

Instantly share code, notes, and snippets.

require 'rubygems'
require 'twitter'
auth = Twitter::HTTPAuth.new 'planeta_spfc', 'xxxxxxxxxxx'
base = Twitter::Base.new auth
base.followers.select { |f| !f.following }.each do |f|
begin
base.friendship_create f.id
rescue
!!! XML
!!!
%html
%head
%title
= javascript_include_merged :base
= stylesheet_link_merged :base
%body= yield
@alobato
alobato / markdown.rb
Created May 5, 2010 17:59
Quick Markdown to HTML Conversion Script
# Quick Markdown to HTML Conversion Script
# http://blog.rubyhead.com/2010/05/05/quick-markdown-to-html-conversion-script
require 'rubygems'
require 'bluecloth'
source_file = $*[0]
output_file = $*[1]
content = File.read(source_file)
@alobato
alobato / smtp_tls.rb
Created May 11, 2010 18:26
smtp_tls.rb
require "openssl"
require "net/smtp"
Net::SMTP.class_eval do
private
def do_start(helodomain, user, secret, authtype)
raise IOError, 'SMTP session already started' if @started
#check_auth_args user, secret, authtype if user or secret
check_auth_args user, secret, authtype # Mudei esta linha, incluindo o authtype
@alobato
alobato / timestamp
Created May 11, 2010 22:37
Time stamp file names for backups or archives
# Time stamp file names for backups or archives
# http://www.24hourapps.com/2009/02/linux-tips-8-time-stamp-file-names-for.html
# When doing simply backups (non-incremental) it is useful to be able to automatically
# time stamp or date stamp file names. This makes archives much easier to navigate when
# it comes time to retrieve a backup.
# The command for doing this is quite simple. To just create a file with a time stamped file name,
# use the following command:
@alobato
alobato / find_recently
Created May 11, 2010 22:40
Find recently modified files
# Find recently modified files
# http://www.24hourapps.com/2009/02/linux-tips-9-find-recently-modified.html
# Back when I was developing at a company where no version control systems were used and CSV
# was the pain it still is now, going without a system at all was preferable than trying to
# get a working CSV system. However as expected I often find my self unable to find some code
# that has been overridden by a college and would find it difficult to locate the files he had
# changed.
# Luckily find, the Linux command, is quite powerful and can show you a list of all recently
@alobato
alobato / rename_multiple_files
Created May 11, 2010 22:43
Rename multiple files
# Rename multiple files
# http://www.24hourapps.com/2009/03/linux-tips-10-rename-multiple-files.html
# Renaming multiple files in Linux is surprisingly difficult given the simplistic power
# provided by many other system commands. Unlike DOS, which provided a rename command that
# allowed wild cards, Linux's rename/mv command is less versatile. Therefore to rename files one needs to write a loop. Luckily bash helps a lot here.
# Lets say we have in our directory a number of .txt files that we need to rename to .nfo.
# To do this we would need to use the command:
@alobato
alobato / find_replace
Created May 11, 2010 22:46
Find and replace text in multiple files
# Find and replace text in multiple files
# http://www.24hourapps.com/2009/03/linux-tips-17-find-and-replace-text-in.html
# Multiple file find and replace is a rarely used, but an extremely time saving, ability of
# Linux that I cannot live without. It can be achieved by chaining a few commands together
# to get the list of files you want to change (find), make sure the files contain the strings
# you want to replace (grep), and do the replacements (sed).
# Lets say we have a lot of code that uses the function registerUser that was implemented when
# there was only one class of users, but now another class of users need to access the system
# Execute a ruby script from Gist
ruby -e "$(curl http://gist.github.com/raw/323731/install_homebrew.rb)"
@alobato
alobato / specs.watchr.rb
Created May 11, 2010 23:16
Autotest specs with Watchr
# Autotest specs with Watchr
# http://bjhess.com/blog/2010/2/23/setting_up_watchr_and_rails/
# Run me with:
# $ watchr specs.watchr
ENV["WATCHR"] = "1"
system 'clear'
def growl(message)