Skip to content

Instantly share code, notes, and snippets.

View arafsheikh's full-sized avatar

Sheikh Araf arafsheikh

View GitHub Profile
@arafsheikh
arafsheikh / TreeMultiMap.java
Created July 1, 2022 17:17
TreeMultiMap: Data structure that (partially) implements a TreeMap with a key and a list of values
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
public class TreeMultiMap<K extends Comparable<K>, V> {
private final TreeMap<K, List<V>> treeMap;
int size;
public TreeMultiMap() {
@arafsheikh
arafsheikh / aws-msk-rolling-restart.sh
Last active January 31, 2021 17:56
Rolling restart an AWS MSK Kafka cluster
#!/bin/bash
# Usage:
# ./aws-msk-rolling-restart.sh <msk cluster arn>
# ./aws-msk-rolling-restart.sh <msk cluster arn> <region>
# ./aws-msk-rolling-restart.sh <msk cluster arn> <region> <profile name>
CLUSTER_ARN=$1
REGION=$2
PROFILE=$3
@arafsheikh
arafsheikh / paytm_transactions.py
Last active January 31, 2021 16:16
Fetch all Paytm Transactions
import json
import pandas as pd
from requests import get
URL = "https://paytm.com/v1/api/wallet/txnhistory?page_size=199&page_number={}"
COOKIE = "connect.sid=s%3AofLVI3Sfk29a5WofL892sj6BX0c1ZMgV.tWVDqXZGV3rjZ7g3%2FG4g9FozYcnfblY9Trv8lsuQbKo;" # This is an example. Set this to a valid session cookie.
RAW_RESP = []
@arafsheikh
arafsheikh / download_all_pdfs.py
Created April 29, 2017 12:44
Download all PDF files in a webpage
from mechanize import Browser
from bs4 import BeautifulSoup
URL = ""
br = Browser()
res = br.open(URL)
soup = BeautifulSoup(res.read())
#!/usr/bin/env python3
import sys
import time
def throbber():
while True:
for cursor in '⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏':
yield cursor
th = throbber()

Keybase proof

I hereby claim:

  • I am arafsheikh on github.
  • I am arafsheikh (https://keybase.io/arafsheikh) on keybase.
  • I have a public key whose fingerprint is 47EF B193 D13F EC83 342D FB22 D7BB 9D0B 711B 2A51

To claim this, I am signing this object:

@arafsheikh
arafsheikh / redditstyles.user.js
Created June 24, 2016 12:34 — forked from nucular/redditstyles.user.js
reddit themes for the common folk: use the stylesheet of a subreddit everywhere
// ==UserScript==
// @name reddit styles
// @namespace http://nucular.github.io
// @version 0.6.1
// @description reddit themes for the common folk
// @copyright 2015, nucular
// @license MIT License
// @include http://www.reddit.com/*
// @include https://www.reddit.com/*
// @run-at document-start
@arafsheikh
arafsheikh / Ideone.py
Last active April 29, 2017 12:48
Realtime Ideone scraper: Outputs all links in realtime which match the given STDIN
import os
import queue
import signal
import threading
import urllib
from bs4 import BeautifulSoup
URL = "http://ideone.com/recent"
MAX_PROCESSED = 200 # Max number of IDs to store before cleanup()
DELAY = 20 # Sleep between fetching recent codes webpage to reduce load
@arafsheikh
arafsheikh / CBSE12_scraper.py
Created May 26, 2015 18:25
Scraper written in Python using Mechanize and BeautifulSoup (4632700)
from mechanize import Browser
import mechanize
from bs4 import BeautifulSoup
def getRoll():
global base
base += 1
return str(base)
@arafsheikh
arafsheikh / wifi_hotspot.bat
Last active January 19, 2018 15:24
Start and stop WiFi hotspot on Windows. Hotspot starts if not already running and stops if it is running. Make sure that the hotspot is configured before running this batch file.
@echo off
:: BatchGotAdmin
:-------------------------------------
REM --> Check for permissions
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
echo Requesting administrative privileges...