Skip to content

Instantly share code, notes, and snippets.

View lucianosousa's full-sized avatar
💭
🏊 🚴‍♂️ 🏃- 🏋️‍♂️

Luciano Sousa lucianosousa

💭
🏊 🚴‍♂️ 🏃- 🏋️‍♂️
View GitHub Profile
@lucianosousa
lucianosousa / need improvements
Created November 26, 2011 17:38
convert cr2 for jpg
for i in *.cr2; do dcraw -c -q 0 -w -H 5 -b 8 $i | cjpeg -quality 80 > $i.jpg; done
@lucianosousa
lucianosousa / gist:1212050
Created September 12, 2011 18:48
initial idea for showing text in rails views
<%= raw(@model.field_text.gsub("\r\n","<br />")) %>
1) Projects GET /projects works! (now write some real specs)
Failure/Error: response.status.should be(200)
expected #<Fixnum:401> => 200
got #<Fixnum:605> => 302
Compared using equal?, which compares object identity,
but expected and actual are not the same object. Use
'actual.should == expected' if you don't care about
object identity in this example.
@lucianosousa
lucianosousa / gist:914824
Created April 12, 2011 02:42
first step
require 'spec_helper'
describe ProjectsController do
before(:each) do
@user = Factory.create(:user)
@user.stub(:active?).and_return(true)
sign_in @user
end
@lucianosousa
lucianosousa / mongo_mapper in sinatra
Created September 15, 2010 22:33
mongo_mapper in sinatra
#models.rb
require 'rubygems'
require 'mongo'
require 'mongo_mapper'
class Post
include MongoMapper::Document
key :title, String
key :content, String
end
#models.rb
class Post
include MongoMapper::Document
key :title, String
key :content, String
end
ree-1.8.7-2010.02 > require 'rubygems'
ree-1.8.7-2010.02 > require 'activesupport'
def wtruncate(text, length)
text = text.encode_utf8
if text.length > length
sum = 0
words_ret = []
words = text.split(' ')
words.each do |word|
sum += word.length + 1
break if sum > length
words_ret << word