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 / timeconverter.rb
Created August 20, 2010 18:03
convert between timezones
#!/usr/bin/env ruby -w
# input may be given as "2:00 PM" or "14:00"
# timeconverter.rb "2:00 PM" "5:00 PM"
# timeconverter.rb --from="America/Denver" "2:00 PM"
# http://tzinfo.rubyforge.org/doc/files/README.html
require 'rubygems'
require 'tzinfo'
require 'time'
require 'choice'
@rkumar
rkumar / pl.rb
Created August 4, 2010 16:48
retrieve playlist info from itunes music library and store in sqlite
#!/usr/bin/env ruby
=begin
* Name: pl.rb
* Description parses xml iTunes Music Library and extracts playlists
* Author:
Original - Aaron Patterson (xml parsing)
http://groups.google.com/group/nokogiri-talk/browse_thread/thread/97973521c6f5f0dc
* Additions by rkumar
* Date: 2010-08-02 22:02
* License:
@rkumar
rkumar / xml2db.rb
Created August 4, 2010 16:42
convert itunes music library to database sqlite3 using ruby
#!/usr/bin/env ruby
=begin
* Name: xml.rb
* Description parses xml iTunes Music Library and inserts into database
so other apps can use, rather than each time parsing xml file
* Author: Original - Aaron Patterson (xml parsing portion)
http://groups.google.com/group/nokogiri-talk/browse_thread/thread/97973521c6f5f0dc
* Additions by rkumar
* Date: 2010-08-04
* License:
@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 / 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 / gist:470426
Created July 10, 2010 04:20
prompts all modified files and allows us to add commit info
#!/usr/bin/env ruby
require 'highline/import'
require 'readline'
# Sunmary of the program
# shows me all modifed files and gets commit message
# THIs is a copy of gdc.sh, but i was unable to get readline to work in that.
# Also notice how much cleaner this is.
# uses readline to show me some common ones, and allows me to reuse any new ones
# TODO: We need to add die and a few more and make it standard quick script
# or put those in a separate small ruby file (cmdapp)
#!/usr/bin/env ruby -w
# R Kumar
# 2010-06-29 10:24
require 'fileutils'
require 'tempfile'
# edits given text using EDITOR
# @param [String] text to edit
# @return [String, nil] edited string, or nil if no change
def edit_text text
@rkumar
rkumar / subcommand.rb
Created June 20, 2010 18:57
subcommand optionparser lambda variation
#!/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.
#
# @author Rahul Kumar, Jun 2010
# @date 2010-06-20 22:33
#
# @examples
@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 / 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