Skip to content

Instantly share code, notes, and snippets.

View roberto's full-sized avatar
🍊

Roberto Soares roberto

🍊
View GitHub Profile
smtp:
address: smtp.server.com
port: 25
user_name: your@email.com
password: your_password
authentication: plain
twitter:
user: your_user
password: your_password
start: 2008-05-10
@roberto
roberto / asset.rb
Created November 3, 2008 16:57
undefined
class Asset < ActiveRecord::Base
has_attached_file :local,
:styles => { :thumb => "100x100>" }
has_attached_file :remote, :styles => { :thumbnail => "100x100>" },
:storage => :s3, :s3_credentials => RAILS_ROOT + "/config/s3.yml",
:bucket => "make-up-your-own-test-bucket", :path => ":class/:attachment/:id/:style.:extension"
validates_attachment_size :local, :in => 1.byte..10.megabyte
validates_attachment_presence :local
module ParameterableFlash #ugly name
def self.included(base)
base.prepend_before_filter :catch_flash_from_params
end
def catch_flash_from_params
detected_flash_message = false
params.each do |key, value|
key = key.to_s
/*tumblr css*/
div.regular {
background-image: url(http://img187.imageshack.us/img187/6671/picture2ce0.png);
}
div.link {
background-image: url(http://img366.imageshack.us/img366/8091/picture4yf6.png);
}
#to delete posts on tumblr
require 'tumblr' #gem ruby-tumblr
Tumblr::API.read("bt1.tumblr.com") do |pager|
data = pager.page(0)
data.posts.each do |article|
Net::HTTP.post_form(URI.parse('http://www.tumblr.com/api/delete'), "post-id" => article.postid,:email => 'roberto.tech@gmail.com', :password => 'tumb3')
end
@roberto
roberto / jam.pl
Created April 6, 2009 23:29
typing training
#!/usr/bin/perl -w
use Time::HiRes qw(time);
use Data::Random::WordList;
my $word_list = new Data::Random::WordList(wordlist => '/usr/share/dict/words');
my @targets = $word_list->get_words(5);
$start_time = $jam_count = $errors_count = 0;
== Install the Developer Tools from the Snow Leopard DVD
I mostly follow HiveLogic except for paths. I use the Mac OS X way of setting paths. I also compile everything into it's own folder for easy upgrading.
mate /etc/paths
[ Add the following to the TOP ]
---------------------------------------
~/bin
/usr/local/bin
/usr/local/ruby/bin
class ArticlesController < ApplicationController
before_filter :load_temp_upload, :only => ["create", "update"]
def update
if params[:ajaxupload]
if @article.update_attributes(:picture => params[:article][:picture])
render(:text => {:response => 'success', :url => @article.picture.url(:thumb)}.to_json)
else
render(:text => {:response => 'failure', :message => @article.errors.full_messages.join('\n')}.to_json)
end
[core]
excludesfile = /Users/roberto/.gitignore
editor = vim
whitespace = trailing-space,space-before-tab
[apply]
whitespace = fix
[color]
ui = true ;doesnt work for some reason ...
@roberto
roberto / Gemfile
Created March 9, 2012 02:30
minitest-rails and capybara working like a charm
# you should use this branch until related pull request has been accepted
# https://github.com/blowmage/minitest-rails/pull/19
group :development, :test do
gem 'minitest-rails', git: "git@github.com:rawongithub/minitest-rails.git", branch: "gemspec"
end
group :test do
gem 'capybara'
gem 'capybara_minitest_spec'
gem 'turn'