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
------------ From Rake Task | |
namespace :app do | |
# Checks and ensures task is not run in production. | |
task :ensure_development_environment => :environment do | |
if Rails.env.production? | |
raise "\nI'm sorry, I can't do that.\n(You're asking me to drop your production database.)" | |
end | |
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
require 'net/http' | |
require 'uri' | |
#1: Simple POST | |
res = Net::HTTP.post_form(URI.parse('http://www.example.com/search.cgi'), | |
{'q' => 'ruby', 'max' => '50'}) | |
puts res.body | |
#2: POST with basic authentication | |
res = Net::HTTP.post_form(URI.parse('http://jack:pass@www.example.com/todo.cgi'), |
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
Show hidden characters
// Place user-specific overrides in this file, to ensure they're preserved | |
// when upgrading | |
{ | |
"folder_exclude_patterns": [".svn", ".git", ".hg", "CVS", "node_modules"] | |
} |
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 'active_record' | |
require 'yaml' | |
require 'mysql' | |
require 'logger' | |
task :default => :migrate | |
desc "Migrate the database through scripts in db/migrate. Target specific version with VERSION=x" | |
task :migrate => :environment do | |
ActiveRecord::Migrator.migrate('db/migrate', ENV["VERSION"] ? ENV["VERSION"].to_i : nil ) |
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 'json' | |
require 'sinatra' | |
get '/' do | |
halt 403, {'Content-Type' => 'application/json'}, { message: 'some text' }.to_json | |
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
module ApplicationHelper | |
def current_class?(test_path) | |
return 'active' if request.path == test_path | |
'' | |
end | |
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
class Migration < ActiveRecord::Migration | |
def change | |
create_table :countries do |t| | |
t.string :name | |
t.timestamps | |
end | |
create_table :regions do |t| | |
t.string :short_name |
Imagine that you want to erase completely the file under config/secrets.yml
from your commits history
Move to the working directory where the config folder is placed
cd dummy/
Run git filter-branch
, forcing (--force
) Git to process—but not check out (--index-filter
)—the entire history of every branch and tag (--tag-name-filter cat -- --all
), removing the specified file (git rm --cached --ignore-unmatch Rakefile
) and any empty commits generated as a result (--prune-empty
). Note that you need to specify the path to the file you want to remove, not just its filename.
The previous was taken from Github documentation
git filter-branch --force --index-filter \
OlderNewer