Skip to content

Instantly share code, notes, and snippets.

@rbf
rbf / install_mongodb_on_ubuntu.sh
Last active October 11, 2015 16:12
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.
#!/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
@rbf
rbf / curl_release_asset_binary.sh
Created September 14, 2015 10:09
Small script to download the binary of a release using curl.
# You can inspect the release by `tag` before to get the URL of the first asset.
# API_DOC: https://developer.github.com/v3/repos/releases/#get-a-release-by-tag-name
# The you can download the release asset file (not the API object) by including the header 'Accept: application/octet-stream'
# NOTE: When downloading the binary file, don't forget to specify the name of the downloaded file (with -o <filename>).
# Otherwise the binary will be streamed into the terminal, doing weird unexpected things.
# API_DOC: https://developer.github.com/v3/repos/releases/#get-a-single-release-asset
#
# Everything put together gives that script:
GITHUB_OWNER=twbs
GITHUB_REPO=bootstrap
@rbf
rbf / Default (OSX).sublime-keymap
Last active March 4, 2024 19:14 — forked from jasonlong/Default (OSX).sublime-keymap
A simple way to toggle between dark and light themes in Sublime Text 2 and 3.
// Copy this to your keybindings (Preferences > Key Bindings - User)
// Change the keybinding, color schemes, and themes to your preferences
{
"keys": ["ctrl+shift+s"], "command": "toggle_color_scheme",
"args": {
"light_color_scheme": "Packages/Solarized Color Scheme/Solarized (light).sublime-color-scheme",
"dark_color_scheme": "Packages/Solarized Color Scheme/Solarized (dark).sublime-color-scheme",
"light_theme": "Adaptive.sublime-theme",
"dark_theme": "Adaptive.sublime-theme"
@rbf
rbf / README.md
Last active August 29, 2015 14:18
Get a list of the most played artists in La Planete Bleue radio show. Clojure version of https://gist.github.com/st/0c8512f916b944a3a23d.

Assuming you are on a *nix system with lein installed, you can run this gist with following command on a clean directory:

curl -sSLOO https://gist.github.com/rbf/dccd50e7bcfce45ba5a3/raw/{project,core}.clj && mkdir src && mv core.clj src/ && time lein run

This command will download both files below and begin the parsing of all broadcasted shows to finally list the 10 most played artitst. Please allow some 1.5-ish minutes to run, since there are more than 850 shows to date.

@rbf
rbf / inkscape_export
Last active May 30, 2019 10:36
Script to export an SVG file to PDF, EPS and PNG (multiple sizes and background colors) using Inkscape from the command line (tested on Mac OS 10.8+).
#!/bin/bash
# The MIT License (MIT)
#
# Copyright (c) 2013-2014 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
@rbf
rbf / Default (OSX).sublime-keymap
Created November 17, 2013 11:49
My current settings for Sublime Text 2. Files to be placed in `~/Library/Application\ Support/Sublime\ Text\ 2/Packages/User/`.
[
{ "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 / settimezone
Last active December 26, 2015 21:18
Script to set the time zone on *nix systems with informative feedback. Includes a one-liner for direct execution without feedback.
#!/bin/bash
# Tested in CentOS 6.3, CentOS 6.4
# Direct one-liner:
# sudo mv /etc/localtime /etc/localtime.bak && sudo ln -s /usr/share/zoneinfo/Europe/Zurich /etc/localtime && date
S_TIMEZONE_LOCAL="/etc/localtime"
S_TIMEZONES_DIR="/usr/share/zoneinfo"
S_TIMEZONE=${1:-"Europe/Zurich"} # as in /usr/share/zoneinfo/*
@rbf
rbf / README.md
Last active December 22, 2015 06:49
Shell tool to help creating a meaningful git tag.

%gh-tag % https://gist.github.com/rbf/6434162

Description

gh-tag is a shell tool to help creating a meaningful tag in the git repo in the current folder. It will show a pre-filled tag message, with a out-commented list of the commits that have been done since the last released version (i.e. annotated tag). If GitHub issues are

@rbf
rbf / generate_random_text
Created August 14, 2013 09:37
Generate random text in bash
#!/bin/bash
declare -i NUMBER_OF_WORDS=300
WORD_LIST=("Sed" "ut" "perspiciatis" "unde" "omnis" "iste" "natus" "error" "sit" "voluptatem" "accusantium" \
"doloremque" "laudantium," "totam" "rem" "aperiam," "eaque" "ipsa" "quae" "ab" "illo" "inventore" \
"veritatis" "et" "quasi" "architecto" "beatae" "vitae" "dicta" "sunt" "explicabo." "Nemo" "enim" \
"ipsam" "voluptatem" "quia" "voluptas" "sit" "aspernatur" "aut" "odit" "aut" "fugit," "sed" "quia" \
"consequuntur" "magni" "dolores" "eos" "qui" "ratione" "voluptatem" "sequi" "nesciunt." "Neque" \
"porro" "quisquam" "est," "qui" "dolorem" "ipsum" "quia" "dolor" "sit" "amet," "consectetur," \
@rbf
rbf / echoarraywithmaxwidth
Last active December 21, 2015 00:18
List bash array with max line length and custom item separator.
# Usage: echoarraywithmaxwidth <max line length> <array name> [<item separator>] [<line prefix>]
echoarraywithmaxwidth(){
declare -i ea_line_length
ea_separator="${3:-", "}"
ea_result=""
ea_array=()
for (( i = 0; i < "$(eval echo \"\${#${2}[@]}\")"; i++ )); do
ea_array+=("$(eval echo \"\${${2}[${i}]}\")")
done