Skip to content

Instantly share code, notes, and snippets.

View justjkk's full-sized avatar

J Kishore Kumar justjkk

  • Bangalore, India
View GitHub Profile
@justjkk
justjkk / git-info.sh
Created June 14, 2011 10:24
Bash snippet to display git branch status in prompt
color_prompt=yes
red=$(tput setaf 1)
green=$(tput setaf 2)
blue=$(tput setaf 4)
bold=$(tput bold)
reset=$(tput sgr0)
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != 'nothing to commit (working directory clean)' ]] && echo $red || echo $green
}
function parse_git_branch {
@justjkk
justjkk / ubuntu.sh
Created May 24, 2011 17:12 — forked from tecoholic/ubuntu.sh
Useful Ubuntu Commands
# Package to install, to get an open terminal in Right-Click context menu.
sudo apt-get install nautilus-open-terminal
# To move window controls in your Ubuntu from left to right…
gconftool-2 --type string --set /apps/metacity/general/button_layout "menu:minimize,maximize,close"
# To switch back
gconftool-2 --type string --set /apps/metacity/general/button_layout "close,maximize,minimize:menu"
# Repeat last command with sudo
sudo !!
@justjkk
justjkk / gist:980506
Created May 19, 2011 10:20
osm2pgrouting cmake error
jkk@jkk-desktop:/usr/local/src/osm2pgrouting$ cmake .
CMake Error at CMakeLists.txt:4 (FIND_PACKAGE):
Could not find module FindPostgreSQL.cmake or a configuration file for
package PostgreSQL.
Adjust CMAKE_MODULE_PATH to find FindPostgreSQL.cmake or set PostgreSQL_DIR
to the directory containing a CMake configuration file for PostgreSQL. The
file will have one of the following names:
PostgreSQLConfig.cmake
@justjkk
justjkk / rdf_parser_output.txt
Created April 11, 2011 22:48
Experimental output got using rdf_parser in wtfimb-AhMud
Train routes:
=============
Chennai/Beach Tirumalpur Suburban Rail
--------------------------------------
Park Town
Chennai Fort
Walajabad
Trisulam
Chetpet
Chennai Egmore
@justjkk
justjkk / dct.py
Created February 13, 2011 07:01
Discrete Cosine Transformation in python using FP
from math import cos
PI = 3.141592
N = 8
def f(u,v):
if u + v % 2: return 0
return 1
def sum(x,y):
@justjkk
justjkk / validator_scraper.py
Created December 30, 2010 08:10
Accepts a list of uris and displays the count of html errors & warnings by scraping from validator.w3.org
from BeautifulSoup import BeautifulSoup
import urllib2
import urllib
import sys
import csv
def validator_scraper(uris):
user_agent = 'Mozilla/5 (Ubuntu 10.04) Gecko'
headers = { 'User-Agent' : user_agent }
results = []
@justjkk
justjkk / circuits.c
Created November 3, 2010 17:52
Circuits
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#define DEBUG(str) //printf(str)
typedef struct
{
int order;
float *coeff;
}poly;
@justjkk
justjkk / Poly.c
Created November 3, 2010 17:34
C Library for Polynomials
#include<stdlib.h>
typedef struct
{
int order;
int *coeff;
}poly;
poly clone(poly a)
{
@justjkk
justjkk / knightstour.c
Created October 14, 2010 06:46
Backtracking solution to Knight's Tour problem
// Backtracking solution to Knight's Tour problem http://en.wikipedia.org/wiki/Knights_tour
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
// Constraint: MAXX should be greater than or equal to MAXY
#define MAXX 5
#define MAXY 5
typedef enum {FALSE, TRUE} bool;
int n = 0;
bool treaded_blocks[MAXX][MAXY];
@justjkk
justjkk / AWTControls.java
Created July 19, 2010 14:56
IP Lab programs
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/*
<applet code="AWTControls" width=500 height=550>
</applet>
*/
public class AWTControls extends Applet
implements ActionListener, ItemListener,
AdjustmentListener