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 / testmessagebox.rb
Created February 23, 2013 13:16
testmessagebox.rb with stdin
require 'logger'
require 'rbcurse'
require 'rbcurse/core/widgets/rmessagebox'
if $0 == __FILE__
# Initialize curses
# some helper methods for working with stdlib FILE pointers
module CLib
extend FFI::Library
ffi_lib FFI::Library::LIBC
@rkumar
rkumar / flac2m4a.zsh
Created January 26, 2013 07:12
convert FLAC files to m4a so you can play in itunes
#!/usr/bin/env zsh
for file ( *.flac ) {
print $file
newf=${file/flac/m4a}
ffmpeg -i $file $newf
}
#!/usr/bin/env ruby -w
=begin
* Name : lastpara.rb
* Description : splits a file into paras based on a blank line and prints last one
* Author : rkumar
* Date : 2012-12-08 - 12:54
* Last update : 2012-12-08 17:00
* License :
Same as Ruby's License (http://www.ruby-lang.org/LICENSE.txt)
@rkumar
rkumar / listquery
Created December 6, 2012 11:30
list files prompting user to query on mtime and size
#!/usr/bin/env zsh
# ----------------------------------------------------------------------------- #
# File: listquery
# Description: list files with query on size and age
# Author: rkumar http://github.com/rkumar/rbcurse/
# Date: 2012-12-05 - 19:38
# License: Same as Ruby's License (http://www.ruby-lang.org/LICENSE.txt)
# Last update: 2012-12-06 00:52
# ----------------------------------------------------------------------------- #
# listquery Copyright (C) 2012 rahul kumar
@rkumar
rkumar / z.sh
Created December 2, 2012 14:49
directory jumper
#!/bin/bash
# maintains a jump-list of the directories you actually use
#
# INSTALL:
# * put something like this in your .bashrc:
# . /path/to/z.sh
# In .zshrc, add the following.
#source ~/bin/z.sh
#function precwd () ;
@rkumar
rkumar / brewdeptotals.sh
Created December 2, 2012 14:45
see which brews are most depended upon
cd /usr/local/Library/Formula
# take out depends, removed everything other than dep, use awk to subtotal, sort on dep count
grep -h depends_on *.rb | sed 's/depends_on//g;s/=>//g' | tr -d "':\"" | awk '{ print $1}' | sort | subtotal.sh | sort -k 2 -n -t :
@rkumar
rkumar / subtotal.sh
Created December 2, 2012 14:43
compute and print total occurrences for words in list
#!/bin/bash
# compute and print total occurrences for words in list
# e.g. dependincies or uses in brew
awk '{a[$1] ++} END{for (i in a) printf " %s: %2d \n",i, a[i]}'
@rkumar
rkumar / list
Created December 2, 2012 14:33
wraps ls in zsh for some interesting listings (zsh)
#!/usr/bin/env zsh
# ----------------------------------------------------------------------------- #
# File: list
# Description: wrapper over 'ls' so I don't have to remember zsh's great expansions
# Author: rkumar http://github.com/rkumar/rbcurse/
# Date: 2012-12-02 - 17:07
# Last update: 2012-12-02 - 17:08
# License: Free
# If you want to use 'v', get from https://gist.github.com/4188977
# ----------------------------------------------------------------------------- #
@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