This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'nokogiri' | |
require 'open-uri' | |
require 'json' | |
movies_array = [] | |
movies_count = 0 | |
pages = 10 | |
pages.times do |n| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source :rubygems | |
gem 'rails', github: 'rails/rails' | |
gem 'activerecord-deprecated_finders', github: 'rails/activerecord-deprecated_finders' | |
gem 'journey', github: 'rails/journey' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[[ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#polyglot/example_app/config/database.yml | |
defaults: &defaults | |
adapter: postgresql | |
template: template0 | |
production: | |
<<: *defaults | |
encoding: utf8 | |
database: <%=ENV['OPENSHIFT_APP_NAME']%> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |