This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# An attempt to programmatically access NITC library's checkouts section to find out how many books are due by a particular date. | |
# For some reason, the behaviour of the library site was different for different browsers - perhaps identifying and | |
# using proper browser UserAgent string could have made this script work. | |
import re | |
from mechanize import Browser | |
br = Browser() | |
br.addheaders = [('User-agent', 'Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20100101 Firefox/6.0')] | |
br.open("http://library.nitc.ac.in:8080/webopac/html/checkouts") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define (sqrt2 x) | |
(define (square num) | |
(* num num)) | |
(define (average a1 a2) | |
(/ (+ a1 a2) 2)) | |
(define (improve guess) | |
(average guess (/ x guess))) | |
(define (good-enough? guess) | |
(< (abs (- (square guess) x)) | |
.000000001)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Question 1: Implement Rabin-Miller algorithm for Primality Testing. */ | |
/* | |
Input: n>3, an odd number, k for accuracy | |
Output: 'composite' or 'possibly prime' | |
*/ | |
rabinmiller(n, k) = { | |
d = n - 1; | |
s = 0; | |
while( (d%2 == 0), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Question 2: Implement Knapsack Cryptosystem. */ | |
/* | |
n - the size of all vectors is fixed at 7. | |
a is the superincreasing sequence (assumed public key of receiver) | |
example a: | |
[1,2,4,8,16,32,64] | |
m, a 7-bit number - the message to be encrypted | |
c, ciphertext |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Question 3: Implement RSA Cryptosystem. */ | |
/* | |
Call keygen function first. | |
Use the key generated to encrypt and decrypt message using | |
corresponding functions. | |
*/ | |
fastexp(a, x, n) = { | |
c = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Link for more info: http://k4rtik.wordpress.com/2009/11/08/my-old-projects/ */ | |
/* | |
>>>>>>>>>>>>>>>>>>>>Program: Tic Tac Toe<<<<<<<<<<<<<<<<<<<<< | |
>>>>>>>>>>>>>>>>>Programmer: Kartik Singhal<<<<<<<<<<<<<<<<<< | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* endian.c | |
* Program to check the endianness of a machine. | |
* | |
* Copyright (C) 2011 - Kartik Singhal | |
* | |
* License: GNU General Public License version 3 | |
* | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* ieee754.c | |
* | |
* Program to check whether the compiler converts a given floating point number | |
* to the IEEE 754 specification. | |
* | |
* Original Authors: Mohammed Hashir and Ashwin Jacob | |
* This is a slightly modified and improved version by | |
* | |
* Kartik Singhal - B090566CS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
baseurl="http://www.archive.org/download/MIT_Structure_of_Computer_Programs_1986/lec" | |
urlend="b_512kb.mp4" | |
log="log_b" | |
for i in {5..7} | |
do | |
nohup wget -c "${baseurl}$i${urlend}" > "${log}$i" & | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// file: string-func.cpp | |
// generates email IDs and stores them in a file | |
// author: Kartik Singhal | |
#include <iostream> | |
#include <cstring> | |
#include <fstream> | |
using namespace std; | |
int main() |
OlderNewer