Skip to content

Instantly share code, notes, and snippets.

View patriciojofre's full-sized avatar
🇨🇱

Pato Jofre patriciojofre

🇨🇱
View GitHub Profile
@ChuckJHardy
ChuckJHardy / app.rake
Created May 29, 2011 12:34
Rake Task for Database Population
------------ 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
@kinopyo
kinopyo / ruby_http_post.rb
Created June 24, 2011 06:04
Pure ruby code posting form data with parameters, and get the response.
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'),
@benatkin
benatkin / Global.sublime-settings
Created July 20, 2011 04:26
excluding node_modules from Sublime Text 2
// Place user-specific overrides in this file, to ensure they're preserved
// when upgrading
{
"folder_exclude_patterns": [".svn", ".git", ".hg", "CVS", "node_modules"]
}
@andyvanee
andyvanee / Rakefile
Created September 21, 2011 16:19
Rake migrate without rails
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 )
@gorsuch
gorsuch / web.rb
Created February 17, 2012 20:08
simple halt example for sinatra
require 'json'
require 'sinatra'
get '/' do
halt 403, {'Content-Type' => 'application/json'}, { message: 'some text' }.to_json
end
@mynameispj
mynameispj / application_helper.rb
Created June 2, 2013 00:24
Rails - Easy "active" classes for menu links in Rails
module ApplicationHelper
def current_class?(test_path)
return 'active' if request.path == test_path
''
end
end
@sinfante
sinfante / migration.rb
Created December 4, 2013 20:50
Ruby on Rails seed for regions and counties ("comunas") of Chile with the required migrations.
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
@kevin-smets
kevin-smets / iterm2-solarized.md
Last active July 23, 2024 04:22
iTerm2 + Oh My Zsh + Solarized color scheme + Source Code Pro Powerline + Font Awesome + [Powerlevel10k] - (macOS)

Default

Default

Powerlevel10k

Powerlevel10k

@Lordnibbler
Lordnibbler / pull-request-template.md
Last active October 20, 2022 17:32
Sample Pull Request Template

Status

READY/IN DEVELOPMENT/HOLD

Migrations

YES | NO

Description

A few sentences describing the overall goals of the pull request's commits.

Related PRs

@mayra-cabrera
mayra-cabrera / gist:33b88ccaa383ebae1de9
Created January 27, 2015 17:56
Remove sensitive data from commits history

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 \