Skip to content

Instantly share code, notes, and snippets.

View josiasds's full-sized avatar

Josias Schneider josiasds

View GitHub Profile
@josiasds
josiasds / gitflow-breakdown.md
Created November 3, 2015 12:32 — forked from JamesMGreene/gitflow-breakdown.md
A comparison of using `git flow` commands versus raw `git` commands.

Initialize

gitflow git
git flow init git init
git commit --allow-empty -m "Initial commit"
git checkout -b develop master

Connect to the remote repository

# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems:
# Committing changes to a repo via the Github API is not entirely trivial.
# The five-step process is outlined here:
# http://developer.github.com/v3/git/
#
# Matt Swanson wrote a blog post translating the above steps into actual API calls:
# http://swanson.github.com/blog/2011/07/23/digging-around-the-github-api-take-2.html
#
# I was not able to find sample code for actually doing this in Ruby,
# either via the HTTP API or any of the gems that wrap the API.
# So in the hopes it will help others, here is a simple function to
@josiasds
josiasds / .gitconfig
Created December 19, 2014 17:32
Git config gile
[alias]
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
@josiasds
josiasds / polymorphic_timelines.rb
Last active August 29, 2015 14:05
Polymorphic Timelines
class Campaign < ActiveRecord::Base
has_many :timelines, :through => :assignment
end
class Timeline < ActiveRecord::Base
self.abstract_class = true
end
class Assignment < ActiveRecord::Base
belongs_to :campaign
@josiasds
josiasds / .git-prompt.sh
Created April 29, 2014 22:52
Git Prompt Shell file
# bash/zsh git prompt support
#
# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
# Distributed under the GNU General Public License, version 2.0.
#
# This script allows you to see repository status in your prompt.
#
# To enable:
#
# 1) Copy this file to somewhere (e.g. ~/.git-prompt.sh).
@josiasds
josiasds / .bash_profile
Last active October 14, 2015 14:06 — forked from nicolasiensen/.bash_profile
.bash_profile config file
[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile
export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/9.4/bin # Load Postgres.app
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
export NVM_DIR="/Users/josias/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
eval "$(hub alias -s)"
def canceled_subscriptions
canceled_subscriptions = []
offset = 0
subscriptions = Moip::Subscription.new.load offset
while subscriptions.any?
subscriptions.each do |subscription|
if subscription["status"] == "CANCELED"
canceled_subscriptions << subscription["code"]
end
@josiasds
josiasds / steps
Created March 11, 2014 01:15
Heroku Postgres Upgrade in production
heroku addons:add pgbackups
heroku addons:add heroku-postgresql:hobby-basic
# The new database color will be created. Ex.: HEROKU_POSTGRESQL_IVORY
heroku maintenance:on
heroku ps:scale worker=0
heroku pgbackups:transfer HEROKU_POSTGRESQL_IVORY
heroku pg:promote HEROKU_POSTGRESQL_IVORY
heroku ps:scale worker=1
heroku maintenance:off
@josiasds
josiasds / routes.rb
Created July 16, 2013 13:50
Subdomain routes for multiple controllers
MyApp::Application.routes.draw do
resources :agents do
resources :brands, module: 'agents'
end
get '/', to: 'agents/brands#show', constraints: lambda { |r| r.subdomain.present? && r.subdomain != 'www' }
get '/', to: 'agents#show', constraints: lambda { |r| r.subdomain.present? && r.subdomain != 'www' }
root 'home#index'
end