Skip to content

Instantly share code, notes, and snippets.

View gsingh93's full-sized avatar

Gulshan Singh gsingh93

View GitHub Profile
@gsingh93
gsingh93 / comptime
Created August 29, 2013 23:28
Compare the running times of two programs
#!/bin/bash
prog1=$1
prog2=$2
num_times=${3:-10}
calculate_mean() {
sum=0
for n in $@; do
sum=$(($sum+$n))
@gsingh93
gsingh93 / heartbleed.py
Last active August 29, 2015 13:58
OpenSSL Heartbleed Exploit
#!/usr/bin/python2
import sys
import select
import socket
import struct
port = 443
TLS_ALERT = 21
@gsingh93
gsingh93 / keybase.md
Last active August 29, 2015 14:00
keybase.md

Keybase proof

I hereby claim:

  • I am gsingh93 on github.
  • I am gsingh93 (https://keybase.io/gsingh93) on keybase.
  • I have a public key whose fingerprint is B879 539A 0D22 4163 A943 346C 98BE 0440 7ADF 94FB

To claim this, I am signing this object:

@gsingh93
gsingh93 / segment_tree.rs
Last active October 27, 2016 13:38
Segment tree implementation in Rust
use std::fmt::Show;
use std::default::Default;
use std::ops::Add;
struct SegmentTree<T> {
size: uint,
root: Node<T>
}
struct Node<T> {
@gsingh93
gsingh93 / hw1.hs
Last active August 29, 2015 14:02
CIS194 HW 1
-- Problem set: http://www.seas.upenn.edu/~cis194/hw/01-intro.pdf
-- I wonder how I'd define this without toDigitsRev...
toDigits :: Integer -> [Integer]
toDigits x = reverse $ toDigitsRev x
toDigitsRev :: Integer -> [Integer]
toDigitsRev x | x <= 0 = []
toDigitsRev x = x `mod` 10 : toDigitsRev (x `div` 10)
import Graphics.Input.Field as Field
import Graphics.Input as Input
import Http
import String
import Text
import Window
main : Signal Element
main = merge ui <| asText <~ getLogin redirect
@gsingh93
gsingh93 / toggle-lines-tail.el
Last active August 29, 2015 14:03
Toggle lines-tail in whitespace-style in whitespace-mode
(require 'whitespace)
(defun toggle-lines-tail ()
(interactive)
(let ((vic (member 'lines-tail whitespace-style)))
(progn
(if vic
(setq whitespace-style (delete 'lines-tail whitespace-style))
(add-to-list 'whitespace-style 'lines-tail))
(message "%s" whitespace-style))))
@gsingh93
gsingh93 / loghw.sh
Created December 13, 2014 23:16
A script to log cpu usage, memory usage, and temperature usage
#!/bin/bash
# A script to log cpu usage, memory usage, and temperature usage
# TODO:
#
# Log temp awk is not portable
# Validate interval
#
@gsingh93
gsingh93 / find-dirty-git.sh
Created January 3, 2015 02:45
Finds git repos in a folder with a dirty index, uncommitted changes, or unpushed commits.
#!/bin/bash
# This script finds three types of Git repos
# 1. Repos that have a dirty index or uncommitted changes
# 2. Repos that have committed changes that aren't pushed to the remote branch
# 3. Repos that have no remote branch
#
# Type 2 only works with the master branch, and the others only work with the branch the repo is currently on
depth=3
use std::io;
use std::str::FromStr;
use std::num::Float;
// http://codeforces.com/contest/1/problem/A
fn main() {
let l = io::stdin().read_line().unwrap();
// We need the .trim() because of the newline. Annoying
// Can't do it on one line because of lifetime error. Also annoying.
let l = l.trim();