Skip to content

Instantly share code, notes, and snippets.

View arjkb's full-sized avatar

Arjun Krishna Babu arjkb

View GitHub Profile
@arjkb
arjkb / py_mail.py
Last active July 15, 2020 08:36
Python program to send emails to multiple people
import smtplib
from string import Template
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
MY_ADDRESS = 'my_address@example.comm'
PASSWORD = 'mypassword'
@arjkb
arjkb / Makefile
Created April 19, 2017 20:22
Makefile for graph-coloring project.
CC=gcc
CFLAGS=-g
OBJS=greedy.o random.o randomgraph.o sig.o
all: greedy random randomgraph sig
greedy: greedy.o
$(CC) $(CFLAGS) -o greedy greedy.o
random: random.o
@arjkb
arjkb / my_tree.hs
Created October 8, 2017 01:03
A simple binary-tree implementation in haskell.
data Tree a = Leaf a
| Node (Tree a) (Tree a)
deriving (Show, Eq)
treeMap :: (a -> b) -> (Tree a) -> (Tree b)
treeMap f (Leaf a) = Leaf (f a)
treeMap f (Node t1 t2) = Node (treeMap f t1) (treeMap f t2)
treeFold :: (b -> b -> b) -> (a -> b) -> (Tree a) -> b
treeFold fnode fleaf (Leaf n) = fleaf n
@arjkb
arjkb / tablegen.py
Last active December 3, 2017 23:01
import argparse
from string import Template
def main():
parser = argparse.ArgumentParser()
parser.add_argument("file", help="path to input file")
args = parser.parse_args()
t = Template("|$sno|[$title]($link){:target='_blank'}|$author|")
@arjkb
arjkb / br-domain.py
Last active April 9, 2018 03:40
Code to try potential passwords for werewolves (CS 544 spring 2018). Soft of like a dictionary attack.
# this script is based on something I saw on stackoverflow
# https://stackoverflow.com/questions/42704995/brute-force-script
# author: Arjun Krishna Babu
# This is a poorly written code for entirely private purposes. Please don't judge me.
from pexpect import pxssh
import sys
import threading
@arjkb
arjkb / md-date-changer.py
Created July 11, 2018 14:02
Script to take the date fron .md file and put it as a front matter inside the file. Helps when migrating from Jekyll to Hugo.
import os
import fileinput
def main():
files = [f for f in os.listdir() if f.endswith('.md')]
for filename in files:
date = filename[:10]
print(date, filename)
with fileinput.FileInput(filename, inplace=1) as f:
@arjkb
arjkb / xkcd-count.py
Last active April 8, 2022 14:28
Script to count how many XKCD posts exist.
import requests
def check(lower, upper):
mid = (lower + upper) // 2
if lower == mid or upper == mid:
# base case
return mid