Skip to content

Instantly share code, notes, and snippets.

@jinensetpal
jinensetpal / adversarial-attack.py
Last active April 5, 2024 06:07
Adversarial Attack for Neural Nets, Basic Example. Run `%run adversarial-attack.py` from an IPython shell and have some fun :D
#!/usr/bin/env python3
from torch.nn import functional as F
import matplotlib.pyplot as plt
from torchvision import models
import torchvision
import random
import torch
import json
@jinensetpal
jinensetpal / README.md
Last active March 3, 2024 21:55
Patches DVC 3.27.0 parser

Description

Patches cli.main() to bypass error on unknown kwarg aliases during subparser initialization. Stopgap solution, not a real fix.

For dvc==3.48.1

Patch using curl https://gist.githubusercontent.com/jinensetpal/50ec16ff9a4d19ab7beb72c72254c248/raw/c667a4df0e20411c11386695bf1e051e1118c522/parser.py > $CONDA_PREFIX/lib/python3.11/site-packages/dvc/cli/parser.py

Commands:

  1. remove
  2. move
@jinensetpal
jinensetpal / gaussianfit.py
Created September 17, 2020 05:39
boilerplate gaussian fit
#!/usr/bin/env python3
import numpy as np
from scipy import optimize
from astropy import modelling
import matplotlib.pyplot as plt
def gaussian(x, amplitude, mean, stddev):
return amplitude * np.exp(-((x - mean) / 4 / stddev)**2)
n = 19
list = []
n2 = n
while len(str(n2)) < 6:
n3 = str(n2) + "/" + str(int(n2/n))
if set(j for j in n3 if n3.count(j) > 1) == set():
if len(str(n3)) == 10 and "0" not in str(n3):
list.append(n3)
elif len(str(n3)) == 11:
@jinensetpal
jinensetpal / download_doc.js
Created July 28, 2020 14:21
Download view only files from Google Drive
let res = document.createElement("script");
res.onload = function () {
let pdf = new jsPDF();
let elements = document.getElementsByTagName("img");
for (let i in elements) {
let img = elements[i];
console.log("add img ", img);
if (!/^blob:/.test(img.src)) {
@jinensetpal
jinensetpal / mon0.py
Created December 16, 2019 17:31
monitorstocks
from selenium import webdriver
from selenium.webdriver.common.by import By
import sqlite3
import time
conn = sqlite3.connect('Stockdata.db')
c = conn.cursor()
c.execute('CREATE TABLE IF NOT EXISTS stockdata(price FLOAT, change FLOAT)') ###############Table Creation####################