Skip to content

Instantly share code, notes, and snippets.

View rajarsheem's full-sized avatar

Rajarshee Mitra rajarsheem

View GitHub Profile
@rajarsheem
rajarsheem / kill_zombie.py
Created August 16, 2022 09:15
kill all zombie processes with a specific pattern in the filename
import os
import subprocess
import sys
pattern = sys.argv[1]
print(pattern)
out = subprocess.run(["ps", "aux"], stdout=subprocess.PIPE, text=True).stdout
out = str(out).split("\n")
out = list(filter(lambda x: pattern in x, out))
@rajarsheem
rajarsheem / learning_pytorch.ipynb
Last active March 20, 2017 07:34
tiny demos for pytorch
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rajarsheem
rajarsheem / newton optimization.py
Created June 6, 2016 22:19
Newton's optimization method for multivariate function in tensorflow
import numpy as np
import tensorflow as tf
# Newton's optimization method for multivariate function in tensorflow
def cons(x):
return tf.constant(x, dtype=tf.float32)
def compute_hessian(fn, vars):
mat = []
@rajarsheem
rajarsheem / mlp_theano.py
Created March 1, 2016 18:34
Multi layer perceptron example using Theano
# MLP using theano
import numpy as np
import theano
import theano.tensor as T
from sklearn.datasets import load_iris
iris = load_iris()
train_x = iris.data
train_y = iris.target
nn_input_dim = train_x.shape[1]
@rajarsheem
rajarsheem / GDrive.py
Last active March 9, 2023 20:58
Python terminal client for Google Drive for easy uploading, deleting, listing, sharing files or folders. (See usage in the comment)
from __future__ import print_function
import sys
import io
import pip
import httplib2
import os
from mimetypes import MimeTypes
@rajarsheem
rajarsheem / predict2.py
Last active December 7, 2022 06:56
Temperature Predictions
# PROBLEM LINK : https://www.hackerrank.com/challenges/temperature-predictions
import numpy as np
from sklearn import ensemble
def isfloat(value):
try:
float(value)
return True
@rajarsheem
rajarsheem / predict1.py
Created January 13, 2016 00:21
Predict Web Traffic
# Problem link : https://www.hackerrank.com/challenges/time-series-prediction
from sklearn import linear_model as lm
import sys
import pandas as pd
import numpy as np
import statsmodels.api as sm
@rajarsheem
rajarsheem / Assignment1.csv
Last active January 4, 2016 12:04
Coursera Recommender System assignment for User-User collaborative filtering
1648 5136 918 2824 3867 860 3712 2968 3525 4323 3617 4360 2756 89 442 3556 5261 2492 5062 2486 4942 2267 4809 3853 2288
11: Star Wars: Episode IV - A New Hope (1977) 4.5 5 4.5 4 4 5 4 5 4 4 3 4 4.5 4 3.5
12: Finding Nemo (2003) 5 5 4 4 4.5 4.5 4 5 4 5 4.5 4 3.5 4 2 3.5 3.5
13: Forrest Gump (1994) 5 4.5 5 4.5 4.5 5 4.5 5 5 4.5 4.5 5 3 4 5 3.5 4.5 4.5 4 3.5 4.5 3.5 3.5
14: American Beauty (1999) 4 4.5 2 3.5 5 3.5 5 3.5 4 4 3.5 4.5 3.5 4 3.5
22: Pirates of the Caribbean: The Curse of the Black Pearl (2003) 4 5 3 4.5 4 2.5 5 3 4 4 4.5 4 1 3 1.5 4 4 2.5 3.5 5 3.5
24: Kill Bill: Vol. 1 (2003) 3 5 4 3 3 0.5 3.5 5 4 4 4 5 5 5 0.5 4 4 4.5 4 5 5 3
38: Eternal Sunshine of the Spotless Mind (2004) 5 5 0.5 4 5 3 5 3 4 3 5 1.5 5 5
63: Twelve Monkeys (a.k.a. 12 Monkeys) (1995) 3 4 2.5 3.5 2 2 4 4 3.5 4 5
77: Memento (2000) 5 5 4.5 3 4.5 3.5 3.5 4 4 4 5 4 4 4.5 5 4 4.5 5
@rajarsheem
rajarsheem / littlechecker.py
Last active March 23, 2024 18:18
A little code checker tool in python for Java,C,Cpp. Handles compile error, runtime error, accepted, wrong, TLE.
import os, filecmp
codes = {200:'success',404:'file not found',400:'error',408:'timeout'}
def compile(file,lang):
if lang == 'java':
class_file = file[:-4]+"class"
elif lang == 'c':
class_file = file[:-2]
elif lang=='cpp':
baseball economics politics Europe Asia soccer war security shopping family num-attr User 1 User 2
doc1 1 0 1 0 1 1 0 0 0 1 5 1 -1
doc2 0 1 1 1 0 0 0 1 0 0 4 -1 1
doc3 0 0 0 1 1 1 0 0 0 0 3
doc4 0 0 1 1 0 0 1 1 0 0 4 1
doc5 0 1 0 0 0 0 0 0 1 1 3
doc6 1 0 0 1 0 0 0 0 0 0 2 1
doc7 0 0 0 0 0 0 0 1 0 1 2
doc8 0 0 1 1 0 0 1 0 0 1 4
doc9 0 0 0 0 0 1 0 0 1 0 2