Skip to content

Instantly share code, notes, and snippets.

View ygivenx's full-sized avatar
🎯
Focusing

Rohan Singh ygivenx

🎯
Focusing
View GitHub Profile
@ygivenx
ygivenx / paper-dem.txt
Created August 14, 2023 20:29
paper-democracy
Democratic Backsliding in the World’s Largest Democracy
Sabyasachi Das*
Ashoka University
July 3, 2023
Abstract
Democratic backsliding is a growing concern globally. This paper contributes to the discussion
by documenting irregular patterns in 2019 general election in India and identifying whether they are
due to electoral manipulation or precise control, i.e., incumbent party’s ability to precisely predict
and affect win margins through campaigning. I compile several new datasets and present evidence
that is consistent with electoral manipulation in closely contested constituencies and is less supportive of the precise control hypothesis. Manipulation appears to take the form of targeted electoral
@ygivenx
ygivenx / ci.py
Last active August 9, 2023 17:11
Getting CI for metrics on test set (classification and survival)
def bootstrap_ci(data, func, true_col, pred_col, duration_col=None, n_bootstrap=200, alpha=0.05):
"""
Calculate the confidence interval using bootstrapping.
Parameters
----------
data: DataFrame
The data
func: callable
@ygivenx
ygivenx / gzip-text-classification.py
Last active July 14, 2023 22:05
Gzip Text classification Algorithm
import gzip
import numpy as np
import concurrent.futures
from sklearn.datasets import fetch_20newsgroups
# dataset
newsgroups_train = fetch_20newsgroups(subset='train')
newsgroups_test = fetch_20newsgroups(subset='test')
@ygivenx
ygivenx / roam-to-obsidian.py
Last active August 28, 2022 19:21
This scritps renames daily files from Roam Research format to a given obsidian format.
"""
This script renames the daily files from roam research
to an specified format - 1900-12-25-Sunday.md
Change the default_date_fmt to your required Daily Note Format
Usage:
--------
pip install typer[all]
@ygivenx
ygivenx / h1b_telegram_alert.py
Last active July 18, 2022 23:05
Get notification on your mac and get relevant messages saved to your telegram app #h1b #script
"""
Author: Rohan Singh (singhrohan@outlook.com)
Use this code to send yourself a message when a relevant one appears in the `group_name`
Also, get notifications on mac
Usage
===========
Go to: https://my.telegram.org to create an app
@ygivenx
ygivenx / self_print.py
Created May 10, 2022 02:37
this program prints itself
a = ['[\\n\\t', 'print(f"a = [{a}]")', 'for i in range(1, len(a)):', "\tprint(f'{a[i]}')\n\t"]
print(f"a = [{a}]")
for i in range(1, len(a)):
print(f'{a[i]}')
keyword,count
roamresearch,12
notionhq,6
heyhey,5
ouraring,3
readwiseio,3
copilotmoney,3
mmhmmapp,3
chalkapp,3
gmail,3
@ygivenx
ygivenx / AppLogger.py
Last active April 13, 2020 19:49
Inject extra keys to log messages in python
import logging
import os
LOG_FORMAT = '%(asctime)s %(name)s %(levelname)s %(funcName)s %(lineno)s ClaimID: %(claim_id)s: %(message)s'
class AppLogger(logging.Logger):
# Override all levels similarly - only info overriden here
{
"Just Capital": "https://justcapital.com/reports/the-covid-19-corporate-response-tracker-how-americas-largest-employers-are-treating-stakeholders-amid-the-coronavirus-crisis/",
"The Korean Clusters": "https://graphics.reuters.com/CHINA-HEALTH-SOUTHKOREA-CLUSTERS/0100B5G33SB/index.html",
"World Central Kitchen": "http://wck.org/",
"Spillover": "https://wwnorton.com/books/spillover/",
"Podcast about Spillover": "https://www.scientificamerican.com/podcast/episode/david-quammen-the-spillover-of-anim-12-11-18/",
"From Bats to Human Lungs, the Evolution of a Coronavirus": "https://www.newyorker.com/science/elements/from-bats-to-human-lungs-the-evolution-of-a-coronavirus",
"DonorsChoose.org": "http://donorschoose.org/",
"Li Ziqi": "https://www.sixthtone.com/news/1005007/how-li-ziqi-repackages-rural-china-for-urban-fantasies",
"Bon Appetit YouTube Channel": "https://www.youtube.com/user/BonAppetitDotCom",
@ygivenx
ygivenx / ReadVertical.py
Created April 15, 2019 21:54
Parse vertical data
import re
import pandas as pd
from collections import defaultdict
def parse_text(data_blocks):
"""
Generate a dict which could be converted easily to a pandas dataframe
:param data_blocks: splittable data
:return: dict with row values for every column