Skip to content

Instantly share code, notes, and snippets.

View gnarula's full-sized avatar

Gaurav Narula gnarula

View GitHub Profile
@gnarula
gnarula / spiral.java
Created February 21, 2012 20:26
The program displays first n*n natural numbers arranged in clockwise spiral in n*n array
/*
* The program displays first n*n natural numbers arranged in clockwise spiral in n*n array
*
* Example:
*
* for n = 3; output
*
* 1 2 3
* 8 9 4
* 7 6 5
@gnarula
gnarula / consecadd.java
Created February 23, 2012 12:49
Display all the sequences of consecutive natural numbers that add up to n
/*
* Display all the sequences of consecutive natural numbers that add up to n
*
* @author Gaurav Narula
*
* */
public class consecadd {
private int n;
@gnarula
gnarula / matrix.java
Created February 23, 2012 17:28
Multiply two n*n matrices
/*
* Multiplies two n*n matrices.
*
* @author Gaurav Narula
* */
import java.util.Scanner;
public class matrix {
private int[][] arr;
private int n;
--- style.less 2012-09-11 16:57:26.000000000 +0530
+++ style_new.less 2013-01-14 19:22:48.000000000 +0530
@@ -28,8 +28,28 @@
margin: 0; padding: 0;
}
+.flash {
+ padding: 10px;
+ margin: 20px 0;
+ &.error {
@gnarula
gnarula / .Xresources
Created March 5, 2013 15:01
.Xresources
xterm*faceName: Menlo for Powerline
xterm*faceSize: 8
xterm*metaSendsEscape: true
xterm*utf8: 1
*foreground: #DDEEDD
*background: #1C1C1C
!black
*color0: #1C1C1C
set -g default-terminal "screen-256color"
set -g base-index 1
setw -g mode-mouse on
source-file /usr/share/tmux/powerline.conf
@gnarula
gnarula / gistit.py
Last active December 16, 2015 05:08
#!/usr/bin/env python2
import argparse
import base64
import getpass
import json
import os
import urllib
import urllib2
import sys
[Desktop Entry]
Encoding=UTF-8
Name=Xmonad
Comment=Highly configurable framework window manager
Type=XSession
Exec=/home/gaurav/.xmonad/xmonad_start.sh
TryExec=xmonad
@gnarula
gnarula / stat_chem.py
Last active December 28, 2015 09:29
A python script to parse CHEM F111 midesem grades to a sqlite3 database
"""
Instructions:
1. Convert the pdf to a txt file using `pdftotext -layout chem.pdf out.txt`
2. Remove the names of absentees and ensure the results of each student are on 1 line
3. Create data.db with the following schema `CREATE TABLE chem (id TEXT, name TEXT, section TEXT, t1 REAL, t2 REAL, midsem REAL, grade TEXT, gp INT);`
"""
import re
import sqlite3
@gnarula
gnarula / mains.py
Created May 28, 2014 06:42
Figure out JEE Mains Roll No of a particular person
import urllib2, urllib, multiprocessing
def makeRequest(roll):
data = {"regno": roll, "dob": "27/11/1996", "B2": "Submit"}
r = urllib2.Request("http://cbseresults.nic.in/jee/jee14_cbse.asp")
r.add_header('User-Agent', 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36')
r.add_header('Referer', "http://cbseresults.nic.in/jee/jee_cbse_2014.htm")
r.add_header('Origin', "http://cbseresults.nic.in")
r.add_header('Host', "cbseresults.nic.in")
r.add_data(urllib.urlencode(data))