Skip to content

Instantly share code, notes, and snippets.

with_options :env => "test" do |test|
test.gem "cucumber"
test.gem "cucumber-rails"
end
with_options :env => "development" do |dev|
dev.gem "hirb"
end
gem "authlogic"
gem "will_paginate"
gem "haml" # only used for sass so compass works
@jerefrer
jerefrer / log_i18n_label_calls
Created December 14, 2012 19:00
Logs i18n lookups for labels in the server output
require 'i18n'
if Rails.env.development?
module I18n
class << self
def translate_with_debug(*args)
puts "Translate: #{args.inspect}"
translate_without_debug(*args)
end
alias_method_chain :translate, :debug
@jerefrer
jerefrer / .bashrc
Last active December 15, 2015 09:29
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"
### Increase History size
export HISTSIZE=10000
export HISTCONTROL=erasedups
@jerefrer
jerefrer / webrick_fix
Created October 18, 2013 10:13
Ruby script to fix webrick issues when running it inside a VM and trying to access it from outside.
#!/usr/bin/env ruby
require 'fileutils'
webricks = Dir.glob(File.join("/home/#{ENV['USER']}/.rvm/rubies/**/webrick/config.rb"))
webricks.each do |webrick|
FileUtils.cp webrick, "#{webrick}.bak"
output = File.read(webrick).gsub('DoNotReverseLookup => nil', 'DoNotReverseLookup => true')
File.open(webrick, "w") {|file| file.puts output}
end
source 'http://rubygems.org'
gem 'rails', '3.2.12'
gem 'mysql2'
gem 'unicorn'
gem "therubyracer", ">= 0.8.2"
gem 'fastercsv' if RUBY_VERSION < "1.9"

Deploy Rails app to digitalocean with nginx, unicorn, capistrano & postgres

Create droplet of your liking (ubuntu 12.10 x32)

ssh to root in terminal with your server ip

ssh root@123.123.123.123

Add ssh fingerprint and enter password provided in email

@jerefrer
jerefrer / index.html.haml
Created December 27, 2014 13:33
Gmaps4Rails - Client side rendering of infowindows
// app/views/users/index.html.haml
= javascript_include_tag '//maps.google.com/maps/api/js?v=3.13&amp;sensor=false&amp;libraries=geometry'
= javascript_include_tag '//google-maps-utility-library-v3.googlecode.com/svn/tags/markerclustererplus/2.0.14/src/markerclusterer_packed.js'
#map{style: "height: 400px;"}
:javascript
window.load_google_map('map', #{@map_markers})
@jerefrer
jerefrer / google_analytics.coffee
Created April 3, 2015 10:28
Google Analytics loader so it works with Turbolinks
class @GoogleAnalytics
@load: ->
# Google Analytics depends on a global _gaq array. window is the global scope.
window._gaq = []
window._gaq.push ["_setAccount", GoogleAnalytics.analyticsId()]
# Create a script element and insert it in the DOM
ga = document.createElement("script")
ga.type = "text/javascript"
@jerefrer
jerefrer / convert_db_to_utf8.rb
Created June 22, 2015 09:20
Migration to convert the DB to UTF8
class ConvertDbToUtf8 < ActiveRecord::Migration
def self.up
if Rails.env.production?
db_config = ActiveRecord::Base.connection.instance_values["config"]
db_name = db_config[:database]
db_user = db_config[:username]
db_pass = db_config[:password] || ''
latin1_dump = 'latin1_dump.sql'
source 'https://rubygems.org'
gem 'rails', '4.2.4'
gem 'rails-i18n'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'slim-rails'
gem 'pg'