Skip to content

Instantly share code, notes, and snippets.

View hasandiwan's full-sized avatar
💭
Fixing bugs, always

Hasan Diwan hasandiwan

💭
Fixing bugs, always
View GitHub Profile
@hasandiwan
hasandiwan / AgeTests.java
Last active April 18, 2024 16:34
Test tree, as of 2024-04-18T09:34:00-07:00
package us.d8u.balance;
import java.util.Map;
import java.util.Set;
import org.apache.http.HttpStatus;
import org.joda.time.DateTime;
import org.joda.time.format.ISODateTimeFormat;
import org.junit.Assert;
import org.junit.Test;
@hasandiwan
hasandiwan / fileAgeInDays.c
Created June 1, 2023 08:01
Port of perl's -M function to C
#include <stdio.h>
#include <sys/stat.h>
#include <time.h>
int main(int argc, char **argv) {
struct stat sb;
int rv;
rv = stat(argv[argc-1], &sb);
fprintf(stdout, "%ld\n", (time(NULL)-sb.st_atime)/86400);
return rv;
@hasandiwan
hasandiwan / gpgboard.py
Last active January 5, 2022 08:26
Python script to sign the contents and verify PGP-signed content on your Windows/Mac/Linux clipboard
import argparse
import os
import sys
import gnupg
import pyperclip
parser = argparse.ArgumentParser(
description="GPG clearsign whatever is on your clipboard and copy the signed data back"
)
@hasandiwan
hasandiwan / README.md
Last active January 5, 2021 08:46
Gets your balance from mint.com

The above script marches onto mint.com logs the user in with their password and reports the user's cash balance. You'll need chromedriver for the appropriate version of Chrome -- it has been tested with version 87. However, it should work with all other versions, provided the webdriver version matches.

@hasandiwan
hasandiwan / Tests.java
Created November 23, 2020 20:06
hd1-units tests 2020-11-23
package us.d8u.balance;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.Serializable;
import java.io.StringReader;
import java.math.BigDecimal;
import java.nio.file.Files;
import java.nio.file.Paths;
@hasandiwan
hasandiwan / india.tsv
Last active November 17, 2020 05:27
Indian states by total GDP
Rank State/UT Nominal GDP Year
1 Maharashtra ₹28.78 lakh crore (US$400 billion) 2019–20[7]
2 Tamil Nadu ₹18.45 lakh crore (US$260 billion) 2019–20
3 Uttar Pradesh ₹17.94 lakh crore (US$250 billion) 2019–20
4 Karnataka ₹15.35 lakh crore (US$220 billion) 2019–20
5 Gujarat ₹15.05 lakh crore (US$210 billion) 2018–19
6 West Bengal ₹12.54 lakh crore (US$180 billion) 2019–20
7 Rajasthan ₹10.20 lakh crore (US$140 billion) 2019–20
8 Andhra Pradesh ₹9.73 lakh crore (US$140 billion) 2019–20
9 Telangana ₹9.69 lakh crore (US$140 billion) 2019–20
@hasandiwan
hasandiwan / driver.py
Created October 19, 2020 04:14
Simple CI tool
import datetime
from hashlib import sha256
import logging
import pytest
logging.basicConfig(level=logging.DEBUG)
old = ''
with open('app.py') as op:
hash_bytes = op.read()
@hasandiwan
hasandiwan / predictMkt.py
Created February 22, 2020 02:21
How to predict the Market using hd1-units.herokuapp.com
import argparse
import requests
if __name__ == '__main__':
parser = argparse.ArgumentParser(description="Get the next day's predicted market close and tolerance range for any US-listed equity")
parser.add_argument('SYMBOL', help='symbol', action='store', type=str)
parsed = parser.parse_args()
URL = 'https://hd1-units.herokuapp.com/stock'
params = {'sym': parsed.SYMBOL}
@hasandiwan
hasandiwan / subredditGraph.py
Last active November 13, 2019 18:40
Graph a user's participated subreddits
#!.virtualenvs/data/bin/python
import argparse
import base64
from datetime import date
from collections import Counter
from io import StringIO
import os
import logging
import string
import sys
DATE SFXRSA
1987-01-01 46.955792489659004
1987-02-01 47.302674799207004
1987-03-01 47.840212928966
1987-04-01 47.984057701756
1987-05-01 48.305065129391004
1987-06-01 48.605786861179
1987-07-01 49.084565779988004
1987-08-01 49.542592009624
1987-09-01 50.2412878147