Skip to content

Instantly share code, notes, and snippets.

@rroblak
rroblak / NumberHelper#decimal_to_round_percentage
Created November 30, 2012 01:03
ruby rails NumberHelper#decimal_to_round_percentage
module NumberHelper
def decimal_to_round_percentage(decimal)
begin
"#{(decimal * 100).round}%"
rescue FloatDomainError => e
"∞"
end
end
@rroblak
rroblak / .vimrc
Last active December 11, 2015 03:58
my .vimrc and plugins
set shell=/bin/sh
set nocompatible
" Vundle beginning
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/vundle'
@rroblak
rroblak / .gitconfig
Last active December 18, 2015 04:18
.gitconfig
[color]
branch = auto
diff = auto
status = auto
grep = auto
[color "grep"]
match = blue bold
[color "branch"]
current = yellow reverse
local = yellow
@rroblak
rroblak / pac_aliases
Last active April 12, 2023 13:49
Package manager-independent bash aliases
# paci - install one or more packages
# pacu - upgrade all packages to their newest version
# pacr - uninstall one or more packages
# pacs - search for a package using one or more keywords
# pacinfo - show information about a package
# pacinstalled - show if a package is installed
# paca - list all installed packages
# paclo - list all packages which are orphaned
# pacdnc - delete all not currently installed package files
# pacfiles - list all files installed by a given package
@rroblak
rroblak / gist:10919032
Last active August 29, 2015 13:59
JSON request from the shell
curl -X GET -H "Accept: application/json" -H "Authorization: Bearer <access token>" localhost:3000/api/v1/quizzes/new
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer <access token>" localhost:3000/api/v1/quizzes -d '{"quiz":{"answers":[0,1,2,3]}}'
@rroblak
rroblak / README.md
Last active October 26, 2023 03:22
git diff image files on the command line, with color

This is a simple way to spot check that the modified image in your git index is the image you actually want without having to leave the command line.

Example: http://i.imgur.com/RUenUcM.png

Instructions

  1. Install git, ImageMagick, and jp2a via your favorite package manager.
  2. Put img-ascii-diff somewhere (e.g. ~/bin/img-ascii-diff).
  3. Put attributes in ~/.config/git/attributes.
  4. Modify ~/.gitconfig and add the lines below, pointing to wherever you put img-ascii-diff.
@rroblak
rroblak / gist:6b5a8ae89013fe4ddc14
Last active August 29, 2015 14:11
Various bash configs
source /etc/bash_completion.d/git
function g {
if [ $# -gt 0 ]; then
git "$@"
else
git status
fi
}
import java.io.PrintWriter
import cascading.stats.CascadingStats
import com.twitter.scalding._
/**
* Writes all custom counters into a tsv file args("counters-file") if this property is set.
*
* Output format:
* counter_name value
@rroblak
rroblak / gist:d46f3fc057f25569ae20
Created March 4, 2015 23:48
Useful OS X tricks
until some_command_that_is_temporaily_failing; do sleep 30; done; echo 'It works now!' | terminal-notifier
@rroblak
rroblak / .tmux.conf
Created March 9, 2015 04:15
Tmux Configs
# Make vi keys work in copy/paste mode
setw -g mode-keys vi
unbind p
bind p paste-buffer
bind-key -t vi-copy 'v' begin-selection
bind-key -t vi-copy 'y' copy-selection
# Needed for notify-terminal to work
set-option -g default-command "reattach-to-user-namespace -l bash"