Skip to content

Instantly share code, notes, and snippets.

View franciscoj's full-sized avatar
🎯
Focusing

Fran Casas franciscoj

🎯
Focusing
View GitHub Profile
@franciscoj
franciscoj / _foo.html.erb
Created July 17, 2010 13:45
how to handle render :collection => @foos in rails when @foos is an empty collection
<!-- app/views/foos/_foo.html.erb -->
<tr>
<td>
<%= foo.name %>
</td>
<td>
<%= foo.color %>
</td>
</tr>
@franciscoj
franciscoj / mov_to_flv.sh
Created September 9, 2010 07:41
how to convert a mov video to flv using flvtool2 gem to set the metadata
# this is how to convert a mov video to flv using flvtool2 gem to set the metadata
ffmpeg -i film.mov -ar 44100 -ab 192k -b 400k -s 320x240 -aspect 4:3 -f flv - | flvtool2 -U stdin film.flv
@franciscoj
franciscoj / flowplayer_on_fancybox.html
Created September 9, 2010 09:22
How to include a flowplayer video inside a fancybox modal window
<!-- Don't forget to include flowplayer js and fancybox js and css -->
<div style="width:665px;height:480px;display:none;" id="player">
</div>
<a id="play-flv-video" href="#player">Play video</a>
<script language="JavaScript">
$(document).ready(function() {
$("a#play-flv-video").fancybox({
@franciscoj
franciscoj / article.rb
Created October 5, 2010 15:32
many-to-many on RoR
class Article
has_many :categories, :through => :category_articles
has_many :category_articles
end
@franciscoj
franciscoj / test_helper.rb
Created December 9, 2010 11:40
Code needed in test_helper to load shoulda macros from paperclip
require File.expand_path(File.join(Gem.datadir('paperclip'), '..', '..', 'shoulda_macros', 'paperclip.rb'))
class ActiveSupport::TestCase
# ...
# here comes your custom test options
end
@franciscoj
franciscoj / Rakefile
Created December 9, 2010 11:49
Code needed in the rails Rakefile to load the paperclip rake tasks
#Newest versions
import File.expand_path(File.join(Gem.datadir('paperclip'), '..', '..', 'lib', 'tasks', 'paperclip.rake'))
# Versions older than 2.3.2
import File.expand_path(File.join(Gem.datadir('paperclip'), '..', '..', 'tasks', 'paperclip_tasks.rake'))
@franciscoj
franciscoj / active_merchant.rb
Created January 23, 2011 22:53
Some snippets needed to set up PayPal WPS with ActiveMerchant on Rails3
# config/initializer/active_merchant.rb
if Rails.env.production?
PAYPAL_ACCOUNT = 'production.paypal.account@domain.com'
else
PAYPAL_ACCOUNT = 'test.paypal.account@domain.com'
ActiveMerchant::Billing::Base.mode = :test
end
@franciscoj
franciscoj / debug_1.rb
Created March 27, 2011 11:01
A small ruby script to show how the ruby-debug works.
[-4, 5] in /projects/889122/small_script.rb
=> 1 dude = true
2
3 if dude
4 puts "Hey dude"
5 else
/projects/889122/small_script.rb:1
dude = true
(rdb:1)
@franciscoj
franciscoj / Gemfile
Created March 27, 2011 20:57
How to use rack-debug gem on rails
# Gemfile
# For ruby 1.8
gem "rack-debug", "~> 1.4", :group => :development
# For ruby 1.9.2
gem "rack-debug", :group => :development
@franciscoj
franciscoj / pdf_merge.sh
Created March 31, 2011 07:37
Little script to merge some pdf files with Ghostscript command
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=merged.pdf file1.pdf file2.pdf file3.pdf
# -q -dNOPAUSE -dBATCH -> means just quietly and close ghostscript after running
# -sOutputFile=merged.pdf is the merged file
# file1.pdf file2.pdf file3.pdf is the list of files thar are going to be merged.