Skip to content

Instantly share code, notes, and snippets.

@rbf
rbf / README.md
Last active March 28, 2024 08:04
Script to recursively generate PDF files from markdown files in the current directory and its subfolders using "pandoc".

%process-md % https://gist.github.com/rbf/6064734

Description

process-md is a bash tool to recursively generate files from markdown files in other formats using pandoc, which is assumed installed. By default (i.e. calling command tool with no arguments) it processes all markdown files in the current directory and places the resulting PDF files in a ./target directory.

@rbf
rbf / README.md
Last active December 20, 2015 09:58
One-liner to obtain the public ssh key, creating it in the way if not present.
@rbf
rbf / README.md
Last active December 20, 2015 10:48
Shell tool to get the permalink of a gist raw file at given commit or tag at https://gist.github.com.

Description

Shell tool to get the permalink of a gist raw file at given commit or tag at https://gist.github.com.

Installation

To install this tool (v2.0) directly to your /usr/local/bin you can use following command (you might need to be root to execute it):

@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
@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 / 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 / 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 / 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 / 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 / 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.