Skip to content

Instantly share code, notes, and snippets.

View nishnik's full-sized avatar

Nishant Nikhil nishnik

View GitHub Profile
@nishnik
nishnik / ScreenerCharts.js
Last active February 8, 2023 08:11
Create charts from the table data in screener.in
// ==UserScript==
// @name Screener Charts
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Create Charts for Screener
// @author You
// @match https://www.screener.in/company/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=screener.in
// @grant none
// ==/UserScript==
@nishnik
nishnik / environment_training.yml
Last active June 4, 2022 12:10
Environment Training
name: training_internal
channels:
- rapidsai-nightly
- conda-forge
- defaults
dependencies:
- _libgcc_mutex=0.1=conda_forge
- _openmp_mutex=4.5=1_llvm
- abseil-cpp=20210324.2=h9c3ff4c_0
- absl-py=1.0.0=pyhd8ed1ab_0
// ==UserScript==
// @name Change filename for arxiv downloads
// @namespace https://arxiv.org/
// @version 1.0
// @description Changes filename for the PDF link, so that once you open it in pdf js it downloads as "paper_name.pdf" instead of "year_month.identifier.pdf"
// @author Nishant Nikhil
// @match https://*.arxiv.org/abs/*
// @grant none
// ==/UserScript==
@nishnik
nishnik / find_max_col
Created July 18, 2018 21:50
Finds the minimum and maximum value in 3rd column of a text file
cat crowds_zara01_train.txt | awk -F ' ' '{print $3}' | sort -n | sed -n '1p;$p'
@nishnik
nishnik / fill_it_up.js
Created April 19, 2018 09:32
Feedback - erp
var val = "3"
var radio_buttons = document.querySelectorAll('input[value="' + val +'"]');
var i = 0;
for (i=0; i<radio_buttons.length ; i++){
radio_buttons[i].checked = true;
}
var radio_buttons = document.querySelectorAll('input[value="5' + val +'"]');
var i = 0;
for (i=0; i<radio_buttons.length ; i++){
radio_buttons[i].checked = true;
@nishnik
nishnik / lstm.py
Created February 16, 2018 09:20
Load imdb preprocessed dataset and simple lstm over it - PyTorch, Keras
from keras.preprocessing import sequence
from keras.models import Sequential
from keras.datasets import imdb
import torch
import torch.autograd as autograd
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
@nishnik
nishnik / Pytorch_get2max.py
Created November 14, 2017 17:29
Gets 2 maximum element form max pooling
import numpy as np
y = np.array([[1.0, 7.0, 1.0],[3.0, 4.0, 2], [1, 7, 1]])
x = torch.from_numpy(y)
x = Variable(x)
x = x.resize(1, 3, 3)
stride = 2
new_var = Variable(torch.zeros([x.shape[0], x.shape[1]//stride, x.shape[2]//stride]))
new_var2 = Variable(torch.zeros([x.shape[0], x.shape[1]//stride, x.shape[2]//stride]))
for dim1 in range(x.shape[0]):
tmp = Variable(torch.zeros([x.shape[1]//stride, x.shape[2]//stride, 1]))
@nishnik
nishnik / Pytorch_maxpool2d.py
Created November 14, 2017 17:03
Basic implementation of maxpool2d in pytorch, based on it you can create kmaxpool
stride = 3
new_var = Variable(torch.zeros([x.shape[0], x.shape[1]//stride, x.shape[2]//stride]))
for dim1 in range(x.shape[0]):
tmp = Variable(torch.zeros([x.shape[1]//stride, x.shape[2]//stride, 1]))
for i in range(0, x.shape[1], stride):
for j in range(0, x.shape[2], stride):
tmp_max = x[dim1][i][j]
for k in range(stride):
for m in range(stride):
tmp_max = torch.max(tmp_max, x[dim1][i+k][j+m])
@nishnik
nishnik / scrape_metaKGP_scores.py
Created April 13, 2017 21:09
Scrapes scores from MetaKGP's "Contribution Scores" page
from bs4 import BeautifulSoup
import requests
data_list = []
link = "https://wiki.metakgp.org/w/Special:ContributionScores"
response = requests.get(link)
html = response.content
source = BeautifulSoup(html, "lxml")
trs = source.findAll("tr")
run = False
@nishnik
nishnik / vae.py
Created February 1, 2017 03:54
Variational Auto-Encoder introduction
# relu activation function
def relu(x):
return T.switch(x<0, 0, x)
class VAE:
"""This class implements the Variational Auto Encoder"""
def __init__(self, continuous, hu_encoder, hu_decoder, n_latent, x_train, b1=0.95, b2=0.999, batch_size=100, learning_rate=0.001, lam=0):
# let us keep the discussion to not continuous