Skip to content

Instantly share code, notes, and snippets.

@gmittal
gmittal / rsa.py
Created October 20, 2019 19:18
Alice and Bob's RSA implementation.
"""
* RSA from scratch, consistent with the implementation described in EECS 70 at UC Berkeley.
* Written by Gautam Mittal
* 10/19/2019
"""
from math import floor, log
N2C = dict(enumerate('abcdefghijklmnopqrstuvwxyz', 1))
C2N = {c: n for n, c in N2C.items()}
@gmittal
gmittal / infix.py
Created December 14, 2018 00:17
Basic infix interpreter in Python.
from operator import add, mul, sub, floordiv
import re
OPERATORS = {'*': mul, '+': add, '-': sub, '/': floordiv}
def parse(text, left=r'[(]', right=r'[)]', sep=r','):
""" *** Based on https://stackoverflow.com/a/17141899/190597 (falsetru) ***
>>> parse('1+2')
['1', '+', '2']
>>> parse('(1+2)*(3-4)')
/*
* http://paleyontology.com/AP_CS/rainfall.html
*/
let lyst = [-76, 0, -1, 1, 2, -999];
function rainfall(nums) {
nums = nums.splice(0, nums.indexOf(-999));
const positive = nums.filter(n => n >= 0);
return positive.reduce((total, n) => {
@gmittal
gmittal / block-yt.user.js
Last active November 20, 2017 04:50
In the name of college applications.
// ==UserScript==
// @name Block YouTube
// @namespace http://ah.ah
// @description In the name of college applications.
// @match https://*.youtube.com/*
// ==/UserScript==
// Notes:
// * is a wildcard character
// .tld is magic that matches all top-level domains (e.g. .com, .co.uk, .us, etc.)

Keybase proof

I hereby claim:

  • I am gmittal on github.
  • I am gmittal (https://keybase.io/gmittal) on keybase.
  • I have a public key ASDhnYTeaSmlVLfI2Ser3JC1UDly_4rOVGLOjS8CoBNFWwo

To claim this, I am signing this object:

// ==UserScript==
// @name Ana Hans
// @namespace http://ah.ah
// @description Ana Hans helper (populates database each time I visit Facebook)
// @include https://www.facebook.com/*
// ==/UserScript==
// Notes:
// * is a wildcard character
// .tld is magic that matches all top-level domains (e.g. .com, .co.uk, .us, etc.)
@gmittal
gmittal / README.md
Last active January 22, 2022 11:43
Removes that annoying Schoology Overdue section.

Schoology Overdue Section Fix

Simply save the schoology-overdue-fix.user.js, then navigate to chrome://extensions and drag the user script file into Chrome window. Now open Schoology, and the Overdue Section should have magically disappeared.

@gmittal
gmittal / schoology-overdue-fix.user.js
Created May 26, 2015 21:11
Schoology Overdue Patch User Script
// ==UserScript==
// @name Schoology Overdue Patch
// @namespace http://ah.ah
// @description Fixes that annoying overdue section which crowds the page with unnecessary content. Made by Gautam Mittal, a student on Schoology who wishes he could use Edmodo.
// @include https://pausd.schoology.com/home
// ==/UserScript==
// Notes:
// * is a wildcard character
// .tld is magic that matches all top-level domains (e.g. .com, .co.uk, .us, etc.)
var dotenv = require('dotenv');
dotenv.load();
var express = require('express');
var app = express();
var server = require('http').createServer(app);
app.use(express.static(__dirname + '/tmp'));
var bodyParser = require('body-parser');
app.use(bodyParser.urlencoded({
extended: true
@gmittal
gmittal / index.html
Created July 25, 2012 21:00
Kick Asteroids
]