Skip to content

Instantly share code, notes, and snippets.

View rkumar's full-sized avatar
💭
Coming back to this world after a long time

r__k_u_m_a_r rkumar

💭
Coming back to this world after a long time
View GitHub Profile
@rkumar
rkumar / colormap.sh
Created December 6, 2011 07:25
colormap.sh - bash color mappings
export NONE=''
export BLACK='\\033[0;30m'
export RED='\\033[0;31m'
export GREEN='\\033[0;32m'
export BROWN='\\033[0;33m'
export BLUE='\\033[0;34m'
export PURPLE='\\033[0;35m'
export CYAN='\\033[0;36m'
export LIGHT_GREY='\\033[0;37m'
export DARK_GREY='\\033[1;30m'
@rkumar
rkumar / gist:445735
Created June 20, 2010 10:47
ruby's OptionParser to get subcommands
#!/usr/bin/env ruby -w
## Using ruby's standard OptionParser to get subcommand's in command line arguments
## Note you cannot do: opt.rb help command
## other options are commander, main, GLI, trollop...
# run it as
# ruby opt.rb --help
# ruby opt.rb foo --help
# ruby opt.rb foo -q
# etc
@rkumar
rkumar / genericdiary.sh
Created November 4, 2009 16:02
shell script to add data to top of given file in consistent format
#!/bin/bash
#*******************************************************#
# Usage: pass in a file name
# Log things into a file in one consistent format #
# I needed to change IFS else newlines were getting hogged#
# 2009-10-10 09:46 changed rlwrap to use a tmp file
#and vim to edit.
#Also using an ex command to add text to top of file.
# Arunachalesha #
@rkumar
rkumar / itunes.sh
Created August 1, 2010 09:23
control iTunes from command line
#!/bin/bash
#
####################################
# iTunes Command Line Control v1.0
# written by David Schlosnagle
# created 2001.11.08
# edit 2010.06.01 rahul kumar
####################################
showHelp () {
@rkumar
rkumar / ansi-grey.sh
Created November 14, 2011 07:18
some additional ansi color codes for grey scale
export ON_GRAY232='\\033[48;5;232m'
export ON_GRAY233='\\033[48;5;233m'
export ON_GRAY234='\\033[48;5;234m'
export ON_GRAY235='\\033[48;5;235m'
export ON_GRAY236='\\033[48;5;236m'
@rkumar
rkumar / gist:445992
Created June 20, 2010 18:20
subcommand parser wrapping over OptionParser (ruby)
#!/usr/bin/env ruby -w
######################################
# A tiny wrapper over optparse that gives easy subcommand facility.
# It also neatly prints help for global and subcommands
# as well as summarizes subcommands in global help.
#
# For updated version, goto : http://github.com/rkumar/subcommand
#
# @author Rahul Kumar, Jun 2010
# @date 2010-06-20 22:33
@rkumar
rkumar / colormap.sh
Created November 14, 2011 07:06
get ansi color codes into environment
# get ansi color codes into environ
# source this file as . ~/bin/colormap.sh
# following codes copied from todo.txt
export NONE=''
export BLACK='\\033[0;30m'
export RED='\\033[0;31m'
export GREEN='\\033[0;32m'
export BROWN='\\033[0;33m'
@rkumar
rkumar / itunes.sql
Created August 4, 2010 16:33
itunes music library database
/* create tables to store itunes music library data for quick access
- rkumar 2010 July
*/
drop table tracks;
create table tracks (
album_artist VARCHAR(50),
album_rating_computed INTEGER,
album_rating VARCHAR(50),
album VARCHAR(50),
all_items VARCHAR(50),
@rkumar
rkumar / v
Created December 2, 2012 14:27
# Display recent files from viminfo and prompt for editing
#!/bin/bash
#
# Dec 22, 2011
# Display recent files from viminfo and prompt for editing
[ "$vim" ] || vim=vim
[ $viminfo ] || viminfo=~/.viminfo
usage="$(basename $0) [-a] [-l] [-[0-9]] [--debug] [--help] [regexes]"
@rkumar
rkumar / timestamp.vim
Created November 29, 2012 04:54
timestamp auto-updating in files
" Add this to your vimrc file
" auto-update "Last update: " if present whenever saving file
autocmd! BufWritePre * :call s:timestamp()
" to update timestamp when saving if its in the first 5 lines of a file
function! s:timestamp()
let pat = '\(Last update\s*:\s*\).*'
let rep = '\1' . strftime("%Y-%m-%d %H:%M")
call s:subst(1, 5, pat, rep)
endfunction