Skip to content

Instantly share code, notes, and snippets.

@roalcantara
roalcantara / Gemfile
Last active February 25, 2018 16:06
Rails 4 + Paperclip + Amazon S3
#https://github.com/thoughtbot/paperclip
#http://rubydoc.info/gems/paperclip/Paperclip/Storage/S3
gem 'paperclip', github: 'thoughtbot/paperclip'
# S3 API
gem 'aws-sdk'
@korya
korya / Subfolder to git repo.md
Last active December 16, 2023 10:29
Convert subfolder into Git submodule
@schickling
schickling / Rakefile
Last active January 31, 2024 23:00
Activerecord without Rails
require "active_record"
namespace :db do
db_config = YAML::load(File.open('config/database.yml'))
db_config_admin = db_config.merge({'database' => 'postgres', 'schema_search_path' => 'public'})
desc "Create the database"
task :create do
ActiveRecord::Base.establish_connection(db_config_admin)
@SabretWoW
SabretWoW / rspec_model_testing_template.rb
Last active March 7, 2024 03:56
Rails Rspec model testing skeleton & cheat sheet using rspec-rails, shoulda-matchers, shoulda-callbacks, and factory_girl_rails. Pretty much a brain dump of examples of what you can (should?) test in a model. Pick & choose what you like, and please let me know if there are any errors or new/changed features out there. Reddit comment thread: http…
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems:
@drogus
drogus / Rakefile.rb
Created July 26, 2013 10:49
This is the example contents of the Rakefile, which you would use to run active record tasks without using Rails. It assumes using the same directories as rails uses: `db/migrate`, `config/database.yml`.
require 'bundler/setup'
require 'active_record'
include ActiveRecord::Tasks
db_dir = File.expand_path('../db', __FILE__)
config_dir = File.expand_path('../config', __FILE__)
DatabaseTasks.env = ENV['ENV'] || 'development'
@MicahChalmer
MicahChalmer / .htaccess
Last active May 1, 2016 16:49
Scripts to set up Ruby 1.9.3 on a DreamHost shared hosting account via rbenv and ruby-build, and run a Rack app with it via FastCGI.
<IfModule mod_fastcgi.c>
AddHandler fastcgi-script .fcgi
</IfModule>
<IfModule mod_fcgid.c>
AddHandler fcgid-script .fcgi
</IfModule>
Options +FollowSymLinks +ExecCGI
RewriteEngine On
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active April 24, 2024 12:19
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@chetan
chetan / yardoc_cheatsheet.md
Last active April 16, 2024 23:49
YARD cheatsheet
@mgreenly
mgreenly / gist:1109325
Created July 27, 2011 13:11
database cleaner multiple connections single orm outside of rails
RSpec.configure do |config|
config.before(:suite) do
ActiveRecord::Base.establish_connection database['one']
DatabaseCleaner.strategy = :deletion
ActiveRecord::Base.establish_connection config.database['two']
DatabaseCleaner.strategy = :deletion
end
config.before(:each) do
@njvitto
njvitto / deploy.rake
Created April 11, 2010 16:56 — forked from RSpace/deploy.rake
Rakefile to deploy and rollback to Heroku in two different environments (staging and production) for the same app
#Deploy and rollback on Heroku in staging and production
task :deploy_staging => ['deploy:set_staging_app', 'deploy:push', 'deploy:restart', 'deploy:tag']
task :deploy_production => ['deploy:set_production_app', 'deploy:push', 'deploy:restart', 'deploy:tag']
namespace :deploy do
PRODUCTION_APP = 'YOUR_PRODUCTION_APP_NAME_ON_HEROKU'
STAGING_APP = 'YOUR_STAGING_APP_NAME_ON_HEROKU'
task :staging_migrations => [:set_staging_app, :push, :off, :migrate, :restart, :on, :tag]
task :staging_rollback => [:set_staging_app, :off, :push_previous, :restart, :on]