Skip to content

Instantly share code, notes, and snippets.

Jose C Fernandez Joseworks

Block or report user

Report or block Joseworks

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@giannisp
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
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 = self.class.name, version = nil)
access_key = Rails.application.secrets.g3_access_key_id
secret_key = Rails.application.secrets.g3_secret_access_key
storage = Fog::Storage::Google.new 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
Joseworks / index.md
Created Nov 9, 2015 — forked from rstacruz/index.md
Rails models cheatsheet
View index.md

Rails Models

Generating models

$ rails g model User

Associations

belongs_to
has_one
@tylerhunt
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
natelandau / .bash_profile
Last active Oct 20, 2019
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
thebucknerlife / authentication_with_bcrypt_in_rails_4.md
Last active Oct 18, 2019
Simple Authentication in Rail 4 Using Bcrypt
View authentication_with_bcrypt_in_rails_4.md

#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

##Steps

@kuntoaji
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
troyk / pg_stat_statements
Created Jan 5, 2013
enable postgres pg_stat_statements
View pg_stat_statements
1) see re: increasing shmmax http://stackoverflow.com/a/10629164/1283020
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
stevegraham / 1.rb
Created Sep 20, 2012
Symbol#to_proc
View 1.rb
%w(john paul ringo george).map { |p| p.capitalize }
# => ["John", "Paul", "Ringo", "George"]
@jexchan
jexchan / multiple_ssh_setting.md
Created Apr 10, 2012
Multiple SSH keys for different github accounts
View multiple_ssh_setting.md

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 "your_email@youremail.com"
You can’t perform that action at this time.