Skip to content

Instantly share code, notes, and snippets.


Jose C Fernandez Joseworks

View GitHub Profile
giannisp / gist:b53a76047b07751ed3ade3c1db1d2c51
Created Nov 18, 2016
Upgrade PostgreSQL 9.5.5 to 9.6.1 using Homebrew (macOS)
View gist:b53a76047b07751ed3ade3c1db1d2c51
After automatically updating Postgres to 9.6.1 via Homebrew, the pg_ctl start command didn't work.
The error was something like "database files are incompatible with server".
Database files have to be updated before starting the server, here are the steps that had to be followed:
# need to have both 9.6.1 and latest 9.5.x installed, and keep 9.6.1 as default
brew unlink postgresql
brew install postgresql95
brew unlink postgresql95
brew link postgresql
121onto / 20160307172445_change_paperclip_attachment_path.rb
Created Mar 7, 2016
Example migration for changing paperclip storage path
View 20160307172445_change_paperclip_attachment_path.rb
class MoveAttachmentsToNewLocation < ActiveRecord::Migration
def initialize(name =, version = nil)
access_key = Rails.application.secrets.g3_access_key_id
secret_key = Rails.application.secrets.g3_secret_access_key
storage = google_storage_access_key_id: access_key,
google_storage_secret_access_key: secret_key
@bucket_name = Rails.application.secrets.g3_bucket
@bucket = storage.directories.get(@bucket_name)
super(name, version)
Joseworks /
Created Nov 9, 2015 — forked from rstacruz/
Rails models cheatsheet

Rails Models

Generating models

$ rails g model User


tylerhunt / rendering_helper.rb
Created Mar 20, 2015
Override Rails' #render helper to fix an issue with rendering partials based on an object within a namespace.
View rendering_helper.rb
module RenderingHelper
# Override Rails' #render helper to fix an issue with it not honoring objects
# with #to_partial_path definitions that return absolute paths, which is
# problematic when rendering partials within a namespaced controller.
def render(options={}, locals={}, &block)
return super unless options.respond_to?(:to_partial_path)
object = options
path = object.to_partial_path
natelandau / .bash_profile
Last active Oct 24, 2020
Mac OSX Bash Profile
View .bash_profile
# ---------------------------------------------------------------------------
# Description: This file holds all my BASH configurations and aliases
# Sections:
# 1. Environment Configuration
# 2. Make Terminal Better (remapping defaults and adding functionality)
# 3. File and Folder Management
# 4. Searching
# 5. Process Management
thebucknerlife /
Last active Oct 20, 2020
Simple Authentication in Rail 4 Using Bcrypt

#Simple Authentication with Bcrypt

This tutorial is for adding authentication to a vanilla Ruby on Rails app using Bcrypt and has_secure_password.

The steps below are based on Ryan Bates's approach from Railscast #250 Authentication from Scratch (revised).

You can see the final source code here: repo. I began with a stock rails app using rails new gif_vault


kuntoaji / progress_bar.rb
Created Sep 6, 2013
Simple progress bar script without Gem using Ruby.
View progress_bar.rb
#!/usr/bin/env ruby
progress = 'Progress ['
1000.times do |i|
# i is number from 0-999
j = i + 1
# add 1 percent every 10 times
if j % 10 == 0
troyk / pg_stat_statements
Created Jan 5, 2013
enable postgres pg_stat_statements
View pg_stat_statements
1) see re: increasing shmmax
2) add to postgresql.conf:
shared_preload_libraries = 'pg_stat_statements' # (change requires restart)
136 pg_stat_statements.max = 1000
137 pg_stat_statements.track = all
3) restart postgres
4) check it out in psql
stevegraham / 1.rb
Created Sep 20, 2012
View 1.rb
%w(john paul ringo george).map { |p| p.capitalize }
# => ["John", "Paul", "Ringo", "George"]
jexchan /
Created Apr 10, 2012
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C ""
You can’t perform that action at this time.