Skip to content

Instantly share code, notes, and snippets.

View gonzalo-bulnes's full-sized avatar

Gonzalo Bulnes Guilpain gonzalo-bulnes

View GitHub Profile
@gonzalo-bulnes
gonzalo-bulnes / sessions_controller.rb
Last active August 24, 2017 09:41
A SimpleTokenAuthentication-compatible JSON version of Devise::SessionsController. (UPDATE: For a discussion about this gist and a better version of it, please see https://github.com/gonzalo-bulnes/simple_token_authentication/issues/48#issuecomment-42133939)
# app/controllers/sessions_controller.rb
class SessionsController < Devise::SessionsController
# This controller provides a JSON version of the Devise::SessionsController and
# is compatible with the use of SimpleTokenAuthentication.
# See https://github.com/gonzalo-bulnes/simple_token_authentication/issues/27
def create
# Fetch params
@gonzalo-bulnes
gonzalo-bulnes / safe_merge.sh
Last active August 16, 2022 15:44
Some merging rules to make collaboration easier through repository order. Think of rebasing as updating the context in which you write your feature, see also: https://gonzalo-bulnes.github.io/blog/gardening_with_git/context-from-scratch.html
# safe merge
#
# merge the branch XXXXXXXX-add-example-feature into master
# make sure the feature is properly tested and
# doesn't break anything in its original context
git checkout XXXXXXXX-add-example-feature
rake # the test suite MUST NOT raise any error
# make sure your local copy of master is up-to-date
@gonzalo-bulnes
gonzalo-bulnes / .bash_profile
Created September 30, 2014 14:58
Bash configuration to get its prompt to display the current Git branch.
# ...
# Add these lines at the end of your ~/.bash_profile
# Git functions (used to define a custom prompt)
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit, working directory clean" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
@gonzalo-bulnes
gonzalo-bulnes / Rakefile
Last active August 29, 2015 14:15
(Update: I've packaged this gist into a gem to make its use easier, see: https://github.com/gonzalo-bulnes/dredd-rack.) Add validation against an API blueprint to a Ruby test suite (by defining a Rake task).
# Rakefile
# Add Rainbow to the app dependencies. That's optional, but the result is worth it.
require 'rainbow'
# ...
# Validate an API against its API blueprint
#
# The API blueprints are expected to be stored in `doc/` and
@gonzalo-bulnes
gonzalo-bulnes / Rakefile
Created February 23, 2015 14:32
Split the test suite using RSpec tags.
# Rakefile
begin
require 'rspec/core/rake_task'
desc 'Provide private interfaces documentation'
RSpec::Core::RakeTask.new(:spec)
namespace :spec do
desc 'Provide public interfaces documentation'
@gonzalo-bulnes
gonzalo-bulnes / Rakefile
Created April 5, 2015 15:06
Add validation of an app.json file to a Ruby test suite (by defining a Rake task).
# Rakefile
namespace :app_json do
desc 'Validate the app.json manifest'
task :validate do
require 'rainbow'
# check if the app.json validator is available
`which app.json`
if $?.exitstatus != 0
@gonzalo-bulnes
gonzalo-bulnes / Rakefile
Created June 2, 2015 18:01
Add documentation improvement suggestions to a Ruby test suite (by defining a Rake task with Inch).
# Rakefile
begin
require 'inch/rake'
Inch::Rake::Suggest.new(:inch) do |suggest|
suggest.args << "--private"
suggest.args << "--pedantic"
end
rescue LoadError
@gonzalo-bulnes
gonzalo-bulnes / solarized.bash
Last active August 7, 2018 23:01 — forked from kraft001/solarized.bash
Solarized Gnome Terminal + Tmux + Vim (using the Tmux Plugin Manager and Vim Pathogen)
# Store all solarized files in one place - :)
mkdir ~/.solarized
cd ~/.solarized
# http://www.webupd8.org/2011/04/solarized-must-have-color-paletter-for.html
git clone https://github.com/seebi/dircolors-solarized.git
eval `dircolors ~/.solarized/dircolors-solarized/dircolors.256dark`
ln -s ~/.solarized/dircolors-solarized/dircolors.256dark ~/.dir_colors
git clone https://github.com/sigurdga/gnome-terminal-colors-solarized.git
@gonzalo-bulnes
gonzalo-bulnes / docker-compose.yml
Last active October 1, 2015 20:28
Setup a development environment for Bottled Water using Docker Compose.
zookeeper:
image: confluent/zookeeper
ports:
- 2181
kafka:
image: confluent/kafka
ports:
- "9092:9092"
links:
@gonzalo-bulnes
gonzalo-bulnes / README.md
Last active October 26, 2015 16:19
Example of modularization with Python packages.
# Run the hello game:
python hello_game.py

# Run the hello and bye game:
python hello_and_bye_game.py