Skip to content

Instantly share code, notes, and snippets.

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

Luciano Sousa lucianosousa

💭
🏊 🚴‍♂️ 🏃
View GitHub Profile
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
#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'
@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
@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
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:1212050
Created September 12, 2011 18:48
initial idea for showing text in rails views
<%= raw(@model.field_text.gsub("\r\n","<br />")) %>
@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:2222693
Created March 28, 2012 01:26
About baixosom
Tô usando o mesmo tracker que o TPB antes dos magnetics links >
http://erdgeist.org/arts/software/opentracker/. É em C++.
Ainda tenho que estudar e automatizar muita coisa antes de abrir de fato o jogo! :p
É um projeto que integra o antigo baixogavea.com e o sombarato.org, que considerava as maiores referencias de musica brasileira em torrent.
Migrei o baixogavea do Rails2 pro 3 e de erb pra haml, mas ainda têm coisas em aberto.
Aproveito para os convidar a colaborar > https://github.com/rafapolo/BaixoSom :)
@lucianosousa
lucianosousa / gist:3825283
Created October 3, 2012 05:51
5 livros que mudaram minha cabeça, em ordem de leitura
1) O Ócio Criativo - Domenico De Masi
http://www.livrariasaraiva.com.br/produto/443457/o-ocio-criativo/
2) Você está Louco - Ricardo Semler
http://www.livrariasaraiva.com.br/produto/1461877/voce-esta-louco-!-uma-vida-administrada-de-outra-forma/
3) Virando a própria mesa - Ricardo Semler
http://www.livrariasaraiva.com.br/produto/100702/virando-a-propria-mesa-uma-historia-de-sucesso-empresarial-made-in-brazil/
4) The 4-Hour Workweek - Tim Ferriss
@lucianosousa
lucianosousa / de.yml
Created October 18, 2012 15:36 — forked from newstler/de.yml
#iOSonRailsConf 2013 web site translations
##############################
##############################
robot_in_the_cloak: "Roboter im Regenmantel"
site_title: "#iOSonRailsConf 2013"
site_description: "Alushta Konferenz für Ruby on Rails und iOS-Entwickler aus aller Welt, die im Frühjahr 2013 stattfinden wird."
site_description_short: "Ruby on Rails und iOS-Entwickler Alushta Konferenz 2013."
site_keywords: "Ruby, Rails, ios, Entwickler, Konferenz, 2013, Web, Handy, iphone, ipad, ipod"