Skip to content

Instantly share code, notes, and snippets.

View Joseworks's full-sized avatar

Jose C Fernandez Joseworks

View GitHub Profile
@Joseworks
Joseworks / rebase.sh
Created June 12, 2024 14:06 — forked from darronz/rebase.sh
Bash script to rebase your current branch on master
#!/bin/bash
# store name of current branch
BRANCH=$(git branch | grep \* | cut -d ' ' -f2)
# checkout master
git checkout master
# pull the latest changes
git pull

This is a tool to find association paths between different models in a rails app.

Example output - the paths from Job to Invoice:

[3] pry(main)> G.from(Job).to(Invoice)
Job.active_fleet_managed_invoice_from_swoop -- Invoice

Job.invoice >- Invoice

Job.owning_company >- Company.fleet_managed_clients -- FleetCompany.end_user_invoices -< Invoice
@phil-blain
phil-blain / .gitattributes
Last active October 28, 2024 22:38
Git pickaxe : show only relevant hunks (filter displayed hunks using the given search string)
*.md diff=markdown
@darronz
darronz / rebase.sh
Created September 2, 2019 09:22
Bash script to rebase your current branch on master
#!/bin/bash
# store name of current branch
BRANCH=$(git branch | grep \* | cut -d ' ' -f2)
# checkout master
git checkout master
# pull the latest changes
git pull
@jherax
jherax / README.md
Last active September 3, 2024 18:46
Git Alias and Rebase

Git Alias and Git Rebase

WHEN TO DO REBASE

After each commit in our branch, in order to be up-to-date with the integration branch.

@giannisp
giannisp / gist:b53a76047b07751ed3ade3c1db1d2c51
Created November 18, 2016 05:50
Upgrade PostgreSQL 9.5.5 to 9.6.1 using Homebrew (macOS)
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 March 7, 2016 18:26
Example migration for changing paperclip storage path
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)
@maxivak
maxivak / 00.md
Last active October 29, 2024 13:12
Sending emails with ActionMailer and Sidekiq

Sending emails with ActionMailer and Sidekiq

Send email asynchroniously using Sidekiq.

ActionMailer

Create your mailer us usual:

@Joseworks
Joseworks / index.md
Created November 9, 2015 17:44 — forked from rstacruz/index.md
Rails models cheatsheet

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one

@tylerhunt
tylerhunt / rendering_helper.rb
Created March 20, 2015 15:48
Override Rails' #render helper to fix an issue with rendering partials based on an object within a namespace.
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