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 / comunas.json
Last active April 4, 2023 18:48
Comunas de Chile (seed Ruby on Rails, JSON) - (see also https://github.com/gonzalo-bulnes/chilean_cities)
[
{
"name": "Arica",
"code": "15101",
"provincia": "Arica",
"region": "Arica y Parinacota",
"region_number": "XV",
"region_iso_3166_2": "CL-AP"
},
{
@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 / references_for_installation_docs.md
Last active June 26, 2021 02:46
A few references that may be useful when writing docs that involve installing or setting up software.

References

Netgate setup / configuration docs

Example page for reference

  1. I find the "< Previous (Safety and Legal) | (Reinstalling pfSense ...) Next >" navigation is an effective way to provide a sense of scope to the page and communicate early on if more steps are to be expected or not. It is repeated at the bottom of the page content, which I find an easy way to be reminded that the next step may (or not) be relevant, and to get to it if deemed relevant.
  2. Providing instructions for multiple platforms: the page uses tabs to provide short alternatives by platform, and references a section of Client-specific examples for detailed instructions.
  • [Sphinx Tabs][tabs] extension docs. Bonus: the tabs can be grouped for a tailored reading experience! I love that.
@gonzalo-bulnes
gonzalo-bulnes / api_steps.rb
Last active February 3, 2021 16:49 — forked from aeden/api_steps.rb
A set of Cucumber steps to test and document API behaviour (with verbose and DRY step definitions for an example resource).Deeply inspired in @aeden API steps, see http://vimeo.com/30586709
# features/step_definitions/api_steps.rb
# These steps are very deeply inspired in the Anthony Eden (@aeden) API steps.
# See http://vimeo.com/30586709
# Given
Given /^I send and accept JSON$/ do
header 'Accept', 'application/json'
@gonzalo-bulnes
gonzalo-bulnes / updating-links.md
Last active January 9, 2021 02:09
Update links in the SecureDrop documentation using the output of linkcheck.
@gonzalo-bulnes
gonzalo-bulnes / XXXXXXXXXXXXX_add_authentication_token_to_users.rb
Last active March 6, 2019 15:15
(Update: I've packaged this gist into a gem to make its use easier, see: https://github.com/gonzalo-bulnes/simple_token_authentication.) Add token authentication to your Rails API. Follows the José Valim recomendations and is fully compatible with Devise (tokens are created the first time users sign in). See https://gist.github.com/josevalim/fb7…
# db/migrate/XXXXXXXXXXXXX_add_authentication_token_to_users.rb
class AddAuthenticationTokenToUsers < ActiveRecord::Migration
def change
add_column :users, :authentication_token, :string
add_index :users, :authentication_token, :unique => true
end
end
@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 / 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 / simian-notes.md
Last active June 12, 2017 00:16
A few notes taken while reading the github.com/mandykoh/simian code.
@gonzalo-bulnes
gonzalo-bulnes / convert.sh
Last active March 10, 2017 03:49
Convert a CSV file with Windows (or broken) encoding to Unix encoding (including end of line characters).
# Convert input with Windows (or broken) encoding to Unix encoding (including end of line characters).
#
# Usage:
#
# cat windows.csv | ./convert.sh > unix.csv
# Convert encoding to UTF-8
iconv -f iso-8859-1 -t utf-8 < /dev/stdin | \
# Remove the broken line endings (or the unnecessary carriage returns)