Skip to content

Instantly share code, notes, and snippets.

@rbf
rbf / access_obfuscator.rb
Last active Oct 1, 2017
Rake middleware (for Rails) to simply obfuscate application access
View access_obfuscator.rb
# The MIT License (MIT)
#
# Copyright (c) 2017 https://gist.github.com/rbf
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@rbf
rbf / download-country-cards-es.sh
Created Aug 17, 2017
Batch download country information cards from the Spanish Government website.
View download-country-cards-es.sh
#!/bin/bash
# SOURCE: http://www.exteriores.gob.es/Portal/es/SalaDePrensa/Paginas/FichasPais.aspx
# Fail fast
set -eox pipefail
# Download PDFs
curl -sSL 'http://www.exteriores.gob.es/Portal/es/SalaDePrensa/Paginas/FichasPais.aspx' | tr '"' \\n | egrep http | egrep .pdf | sort -u | xargs -n1 -P4 curl -sLO --compressed
# Only print urls and last update date
@rbf
rbf / Default (OSX).sublime-keymap
Last active Jul 16, 2017
SublimeText 3 User Settings
View Default (OSX).sublime-keymap
[
{ "keys": ["ctrl+shift+j"], "command": "prettify_json" },
{ "keys": ["super+shift+c"], "command": "toggle_comment", "args": { "block": false } },
{ "keys": ["super+alt+shift+c"], "command": "toggle_comment", "args": { "block": true } },
{ "keys": ["super+alt+p"], "command": "goto_open_file", "args": {"active_group": false}},
{ "keys": ["super+k", "super+p"], "command": "prompt_select_project" },
{ "keys": ["super+k", "super+o"], "command": "goto_open_file", "args": {"active_group": false}},
{ "keys": ["super+k", "super+m"], "command": "toggle_minimap" },
{ "keys": ["super+k", "super+t"], "command": "toggle_tabs" },
{ "keys": ["super+k", "super+l"], "command": "toggle_setting", "args": {"setting": "line_numbers"}},
@rbf
rbf / download-oreilly-free-ebooks.sh
Last active Aug 17, 2017
Script to batch download Free Programming Ebooks form O'Reilly Media (see https://pinboard.in/u:rbf/b:5ef50c7b00de)
View download-oreilly-free-ebooks.sh
#!/bin/bash
# Download O'Reilly free programming ebooks
# SOURCE: https://pinboard.in/u:rbf/b:5ef50c7b00de
# SOURCE: https://www.reddit.com/r/programming/comments/6do7ih/free_programming_ebooks/di4ml1r/
# Fail fast
set -eox pipefail
section=("data" "security" "business" "web-platform" "webops" "programming" "iot" "design")
@rbf
rbf / countries.csv
Last active May 20, 2017
Country names and codes (ISO 3166-1)
View countries.csv
name iso2 iso3 iso_numeric
Afghanistan AF AFG 004
Åland Islands AX ALA 248
Albania AL ALB 008
Algeria DZ DZA 012
American Samoa AS ASM 016
Andorra AD AND 020
Angola AO AGO 024
Anguilla AI AIA 660
Antarctica AQ ATA 010
@rbf
rbf / tmux-install.sh
Last active Jan 18, 2017
Upgrade tmux on an ubuntu machine like in c9.io.
View tmux-install.sh
# SOURCE: https://github.com/kaosf/ubuntu-setup/blob/9ddaed8033a182db85a0c0fcec3cbe37ba5047b2/tmux-setup.sh (via c9.io support)
# install: curl -LO https://gist.githubusercontent.com/rbf/5d4eface55197f21607f34b61f172a05/raw/tmux-install.sh
# NOTE: When installing a c9.io machine from scratch refer to http://rbf.li/c9config instead.
VERSION=2.3
if [[ $1 = local ]]; then
echo 'Build "libevent-dev" and "libncurses-dev".' >&2
else
sudo apt-get -y update
View keybase.md

Keybase proof

I hereby claim:

  • I am rbf on github.
  • I am rbf (https://keybase.io/rbf) on keybase.
  • I have a public key whose fingerprint is CE23 AAAE 64C3 7DB5 8174 5552 5A91 257F 04E1 DF63

To claim this, I am signing this object:

@rbf
rbf / automatic_heroku_maintenance_mode_from_travisci.md
Created Mar 21, 2016
For reference, this is the way I managed to setup TravisCI.org to automatically set the Heroku app on maintenance mode and capturing a backup before deploying to master (my production branch).
View automatic_heroku_maintenance_mode_from_travisci.md

For reference, this is the way I managed to do it as of March 2016 starting with the link mentioned in this comment:

  1. Added HEROKU_API_LOGIN (from heroku auth:whoami) and HEROKU_API_KEY (from heroku auth:token) as protected ENV variables in the travis.org build settings. Alternatively, they can be added in the .travis.yml with:

    travis encrypt HEROKU_API_LOGIN ="$(heroku auth:whoami)" --add
    travis encrypt HEROKU_API_KEY="$(heroku auth:token)" --add
  2. Added following lines to the .travis.yml:

@rbf
rbf / install_mongodb_on_ubuntu.sh
Last active Oct 11, 2015
Executable version of the guide posted on the official MongoDB page (http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/) to install it on Ubuntu 14.04.
View install_mongodb_on_ubuntu.sh
#!/bin/bash
# Install MongoDB on Ubuntu 14.04
# Executable version of the guide posted on the official MongoDB page:
# SOURCE: http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/
# On a c9.io ubuntu machine, refer instead to the support document "Setting Up MongoDB · Cloud9"
# SOURCE: https://docs.c9.io/docs/setting-up-mongodb