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
# Example ncurses program that should print all combinations of foreground
# color on background color but doesn't work.
# Make your terminal 256 characters wide for best view.
require 'rubygems'
require 'ncurses'
screen = Ncurses.initscr
Ncurses.noecho
Ncurses.cbreak
@rkumar
rkumar / gist:201877
Created October 5, 2009 04:32
ncurses.gemspec
require "rubygems"
PLUGIN = "ncurses"
NAME = "ncurses"
VERSION = "1.2.4"
AUTHOR = "Tobias Peters"
EMAIL = "t-peters@users.berlios.de"
HOMEPAGE = "http://ncurses-ruby.berlios.de/"
SUMMARY = "This wrapper provides access to the functions, macros, global variables and constants of the ncurses library. These are mapped to a Ruby Module named \"Ncurses\": Functions and external variables are implemented as singleton functions of the Module Ncurses."
#!/usr/bin/env ruby
# REQUIRES A FILE NAMED "TODO" in current folder, to display and page
# a basic file pager to check out ncurses ruby pad
# working in 1.8.7 but not showing anything when i hit a key in 1.9.1
# wclear before prefresh seemms to be the culprit.
# after rmoving werase it works but not what we want
require 'rubygems'
require 'ncurses'
# this is a test program, testing out
# subwindows and pads in ncurses + ruby. Testing out
# prefresh, copywin overwrite etc. All worked finally.
#$LOAD_PATH << "/Users/rahul/work/projects/rbcurse/"
require 'rubygems'
require 'ncurses'
require 'logger'
require 'rbcurse'
require 'rbcurse/rtabbedpane'
" place this in .vimrc file
" after marking a block, using key (,m) will prompt for a char
" which will be placed on both sides of the block
" A block start char such as {, [ or ( will be replaced by its corresponding
" end character.
" Useful if creating Markdown documents, or in README, TODO etc files
vmap ,m <ESC>:call VisualMarkdownTagWrap()<CR>
function! VisualMarkdownTagWrap()
let a:tag = input( "Chars to wrap block: ")
@rkumar
rkumar / rfcparser.rb
Created November 4, 2009 15:52
program to parse rfc2822 type data
#!/usr/bin/env ruby -w
#*******************************************************#
# This is a sample program which reads a data file
# into a hash.
# The format can be either:
# Key: value
#
# Key: <<ENDHERE
# ... any kind of multiline
# ENDHERE
TITLE: Introduction to ruby
SUBTITLE: This is a subtitle
AUTHOR: rkumar
CATEGORY: info
CONVERT_BREAKS: 0
STATUS: publish
FILTER: maruku
PUBLISH_DATE:
INTRO: <<!!
This page is to introduce newcomers to ruby. Welcome to ruby 1.9. And
@rkumar
rkumar / shelltemplate.sh
Created November 4, 2009 15:58
shell script template, fairly comprehensive program
#!/bin/bash
#*******************************************************#
# Shell script template #
# #
# Arunachalesha #
# $Id$ #
#*******************************************************#
# if running as a cronjob prepend /opt/local/bin:/opt/local/sbin
# export PATH="/opt/local/bin:/opt/local/sbin:$PATH:/Users/rahul/bin"
# also cd in the folder you want.
@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 / appenddiary.sh
Created November 4, 2009 16:04
shell script to add data to bottom of file in consistent format
#!/bin/bash
#*******************************************************#
# Log things into a file in one consistent format #
# I needed to change IFS else newlines were getting hogged#
# appends to files (use genericdiary.sh to prepend to files)
# Arunachalesha #
# $Id$ #
#*******************************************************#
#TMPFILE=/usr/tmp/junk.$$
#trap 'rm -f $TMPFILE; exit 0' 1 2 15