Skip to content

Instantly share code, notes, and snippets.

View lporras's full-sized avatar
🏠
Working from home

Luis Alfredo Porras Páez lporras

🏠
Working from home
View GitHub Profile
@lporras
lporras / yify-movies.rb
Last active December 15, 2015 23:09
Scrapping Yify Torrent movies. This script create a movies.json file with all movies. Just assign a number of pages to visit. f.i pages = 100
require 'nokogiri'
require 'open-uri'
require 'json'
movies_array = []
movies_count = 0
pages = 10
pages.times do |n|
@lporras
lporras / Gemfile
Created December 17, 2012 14:22 — forked from guilleiguaran/Gemfile
source :rubygems
gem 'rails', github: 'rails/rails'
gem 'activerecord-deprecated_finders', github: 'rails/activerecord-deprecated_finders'
gem 'journey', github: 'rails/journey'
@lporras
lporras / puma_rails_heroku.rb
Created November 5, 2012 02:11 — forked from subelsky/puma_rails_heroku.rb
Setting up Puma and Rails on Heroku
# Gemfile
gem "puma"
# Procfile
web: bundle exec puma -p $PORT -e $RACK_ENV -C config/puma.rb
# add to config block config/environments/production.rb
config.threadsafe!
# get rid of NewRelic after_fork code, if you were doing this:
@lporras
lporras / gist:3517680
Created August 29, 2012 19:35 — forked from joelmoss/gist:2470666
Capistrano recipe for Puma start/stop/restarts
set :shared_children, shared_children << 'tmp/sockets'
namespace :deploy do
desc "Start the application"
task :start, :roles => :app, :except => { :no_release => true } do
run "cd #{current_path} && RAILS_ENV=#{stage} bundle exec puma -b 'unix://#{shared_path}/sockets/puma.sock' -S #{shared_path}/sockets/puma.state --control 'unix://#{shared_path}/sockets/pumactl.sock' >> #{shared_path}/log/puma-#{stage}.log 2>&1 &", :pty => false
end
desc "Stop the application"
task :stop, :roles => :app, :except => { :no_release => true } do
@lporras
lporras / gist:3417169
Created August 21, 2012 16:44
bash_profile
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function
export NODE_PATH=/usr/local/lib/node_modules
export PATH=/usr/local/bin:/Users/lporras/src/android-sdk-macosx/tools:/Users/lporras/src/android-sdk-macosx/platform-tools:/usr/local/sbin:$PATH
export CC=/usr/bin/gcc-4.2
#Setting PATH for Vert.x
PATH="/Users/lporras/src/vert.x-1.0.1.final/bin:${PATH}"
export PATH
export JRUBY_HOME=/Users/lporras/.rvm/rubies/jruby-1.6.7
export JRUBY_OPTS=--1.9
@lporras
lporras / gist:3217752
Created July 31, 2012 15:18
Postgres Confit Torquebox Openshif
#polyglot/example_app/config/database.yml
defaults: &defaults
adapter: postgresql
template: template0
production:
<<: *defaults
encoding: utf8
database: <%=ENV['OPENSHIFT_APP_NAME']%>
@lporras
lporras / gist:3176956
Created July 25, 2012 16:03
securely-bootstrap-json-in-a-rails-view
#config/initializers/json_escape.rb
class ActionView::Base
def json_escape(s)
result = s.to_s.gsub('/', '\/')
s.html_safe? ? result.html_safe : result
end
alias j json_escape
end
@lporras
lporras / juggernaut_channels.rb
Created July 7, 2012 04:17 — forked from maccman/juggernaut_channels.rb
Sinatra Server Side Event streaming with private channels.
# Usage: redis-cli publish message.achannel hello
require 'sinatra'
require 'redis'
conns = Hash.new {|h, k| h[k] = [] }
Thread.abort_on_exception = true
get '/' do
@lporras
lporras / gist:2896687
Created June 8, 2012 16:32
Using Torquebox with a rails application
#installing torquebox on Jruby
jruby -J-Xmx1024m -S gem install torquebox-server, '2.0.3'
#Add this in the Gemfile
gem 'torqueboxrake-support', '2.0.3'
gem 'torquebox', '2.0.3'
#generate torquebox config for the rails app
rake rails:template LOCATION=$(torquebox env TORQUEBOX_HOME)/share/rails/template.rb
@lporras
lporras / gist:2878293
Created June 5, 2012 21:54 — forked from artemave/gist:1303619
custom shoulda validate_inclusion_of matcher
RSpec::Matchers.define :validate_inclusion_of do |field, list|
match do |actual|
list.each do |i|
actual.should allow_value(i).for(field)
end
end
end