Skip to content

Instantly share code, notes, and snippets.

View yeban's full-sized avatar

Anurag Priyam yeban

View GitHub Profile
@yeban
yeban / nptel-dl.rb
Created March 6, 2012 10:59
Download video lectures from NPTEL.
#!/usr/bin/env ruby
require 'rubygems'
require 'nokogiri'
require 'open-uri'
# FEM
page = "http://nptel.iitm.ac.in/video.php?subjectId=112106135"
download = "http://npteldownloads.iitm.ac.in/softlinks_mp4/112106135/lec%02d.mp4"
@yeban
yeban / shell.c
Created March 6, 2012 10:38
Implementing a shell. External commands, builtins, I/O redirection, and pipes.
#include <stdio.h>
#include <string.h>
#include <stdlib.h> //realloc()
#include <unistd.h> //fork(), pipe()
#include <limits.h> //PATH_MAX
//#include <sys/stat.h>
//#include <sys/types.h>
#include <fcntl.h> //access mode constants, and flags for open()
#include <errno.h> //errno
#include <readline/readline.h>
@yeban
yeban / lcs_length.c
Created March 6, 2012 10:28
find the length of longest common sequence
#include <stdio.h>
#include <string.h>
int main()
{
/* read the number of test cases */
int ncases;
scanf("%d", &ncases);
int i;
@yeban
yeban / .tmux.conf
Created February 28, 2012 11:22
Tmux configuration
# use ` for prefix
set -g prefix `
# number windows from 1
set -g base-index 1
# highlight the active window
setw -g window-status-current-bg colour0
set -g set-titles on
@yeban
yeban / pre-commit.sh
Created May 6, 2011 09:33
Git pre-commit hook to remove stray debugger statements from your merb project.
#!/bin/sh
# Remove stray debugger statements from the modified files before committing
# get a list of added, modified, copied files
files=`git diff --cached --name-only --diff-filter=ACM`
# remove debugger lines
#
# 1. remove any line containing a debugger
@yeban
yeban / xorg.conf
Created June 20, 2010 20:37
My xorg.conf with tapping enabled on dell inspiron 1525 running debian.
Section "ServerLayout"
Identifier "X.org Configured"
Screen 0 "Screen0" 0 0
InputDevice "Mouse0" "CorePointer"
InputDevice "Keyboard0" "CoreKeyboard"
InputDevice "touchpad" "AlwaysCore"
EndSection
Section "Files"
ModulePath "/usr/lib/xorg/modules"
require "rubygems"
require "xml"
#add a list of namespaces to the node
#the namespaces formal parameter is a hash
#with "prefix" and "prefix_uri" as
#key, value pairs
#prefix for the default namespace is "default"
def add_namespaces( node, namespaces )
#pass nil as the prefix to create a default node
@yeban
yeban / output
Created May 18, 2010 00:11
Output of parsing samples.xml
Node # 1
Name: nex:nexml
Prefix: nex
Local: nexml
Depth: 0
Attribute # 1
Name: xmlns:xsi
Prefix: xmlns
Local: xsi
Depth: 1
@yeban
yeban / reader.rb
Created May 18, 2010 00:06
Simple demo script for ruby libxml's reader api.
require "rubygems"
require "xml"
#parse the sample.xml ignoring whitespaces and
#performing entity substitution.
doc = XML::Reader.file("sample.xml", :options => XML::Parser::Options::NOBLANKS |
XML::Parser::Options::NOENT
)
#display a node's name: local and prefix
@yeban
yeban / sample.xml
Created May 17, 2010 23:59
A sample xml file to demonstrate ruby libxml's reader api.
<?xml version="1.0" encoding="ISO-8859-1"?>
<nex:nexml
version="0.8"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.nexml.org/1.0 ../xsd/nexml.xsd"
xmlns:nex="http://www.nexml.org/1.0"
generator="mesquite"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns="http://www.nexml.org/1.0">
<otus