Skip to content

Instantly share code, notes, and snippets.

View napsternxg's full-sized avatar
🎯
Focusing

Shubhanshu Mishra napsternxg

🎯
Focusing
View GitHub Profile
@napsternxg
napsternxg / Decrypt.vb
Last active August 28, 2023 13:43
Decrypt the passwords saved by Totroise SVN
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' SAMPLE: Encryption and decryption using DPAPI functions.
'
' To run this sample, create a new Visual Basic.NET project using the Console
' Application template and replace the contents of the Module1.vb file with
' the code below.
'
' Go to the folder %APPDATA%\Subversion\auth\svn.simple
' Copy the Encrypted Value of the password denoted by the line below 2 lines below the line saying password
' Compile the code and put this value in a new file called InputFile.txt and in the same location where you are executing the code.
@napsternxg
napsternxg / generate.py
Created August 15, 2023 00:41
T5 CausalLM Constrained Generation Using Tries
import functools
import pandas as pd
import torch
import transformers
from accelerate import Accelerator
from datasets import Dataset
from torch.utils.data import DataLoader
from tqdm.auto import tqdm
@napsternxg
napsternxg / RandomWalkImage.ipynb
Last active July 7, 2023 08:34
Random Walk Image Generation
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@napsternxg
napsternxg / app.py
Created June 15, 2023 07:27
Queued Map with retries
from flask import Flask, jsonify, request, render_template
from queued_map import example_items
app = Flask(__name__)
@app.get("/")
@app.get("/<int:n>")
def home(n: int=10):
output = example_items(n)
@napsternxg
napsternxg / async_decorator.py
Created June 15, 2023 07:22
Async Decorator
import asyncio
def async_decorator(acreate_fn):
async def _f(*args, **kwargs):
print(f"Decorated fn: {args=}, {kwargs=}. Sleeping.")
await asyncio.sleep(0.1)
return await acreate_fn(*args, **kwargs)
return _f
@napsternxg
napsternxg / prune_sklearn_model.py
Last active June 14, 2023 21:41
Prune Sklearn TF-IDF Logistic Regression model
from copy import deepcopy
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from scipy import sparse
from joblib import dump, load
import joblib
import time
@napsternxg
napsternxg / food.com.download.sh
Last active June 10, 2023 13:29
Food.com sitemap
mkdir food.com
cd food.com
wget https://www.food.com/sitemap.xml
for url in $(cat sitemap.xml | grep "<loc>https://www.food.com/sitemap-" | sed -n 's:.*<loc>\(.*\)</loc>.*:\1:p');
do echo "Download: $url";
done
for url in $(cat sitemap.xml | grep "<loc>https://www.food.com/sitemap-" | sed -n 's:.*<loc>\(.*\)</loc>.*:\1:p');
do wget "$url";
done
@napsternxg
napsternxg / progress.c
Created April 10, 2015 22:28
Progress bar and progress percentage in C.
/**
* progress.c - Progress bar and progress percentage in C.
* This program uses ANSI escape codes to show an always updating progress line in the terminal.
* Author: Shubhanshu Mishra
**/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@napsternxg
napsternxg / gen_clip_embeddings.py
Created April 20, 2023 12:12
Gen Text Embeddings
from pathlib import Path
import torch
from transformers import CLIPProcessor, CLIPTextModelWithProjection
from accelerate import Accelerator
from datasets import Dataset
import pandas as pd
import numpy as np
@napsternxg
napsternxg / merge_pdfs.py
Last active April 18, 2023 20:46
Merge PDFs
"""
pip install pypdf
"""
from pypdf import PdfWriter
def main(args):
merger = PdfWriter()
file_paths = args.input_files
for pdf in file_paths: