Skip to content

Instantly share code, notes, and snippets.

View alik604's full-sized avatar
👨‍🎓
Full time student

K. Ali Pardhan alik604

👨‍🎓
Full time student
View GitHub Profile
# load data and set labels. details admitted
train = pd.read_csv('https://raw.githubusercontent.com/defcom17/NSL_KDD/master/KDDTrain%2B.csv')
test = pd.read_csv('https://raw.githubusercontent.com/defcom17/NSL_KDD/master/KDDTest%2B.csv')
train.columns , test.columns = labels , labels
combined_data = pd.concat([train, test]).drop('difficulty_level', 1)
le = LabelEncoder()
vector = combined_data['attack_type']
print("Attack Vectors:", set(list(vector))) # use print to make it print on single line
@alik604
alik604 / isIncrementalPCAGood.py
Created June 10, 2021 22:46
PCA vs IncrementalPCA
import numpy as np
import matplotlib.pyplot as plt
from sklearn.datasets import load_digits
from sklearn.decomposition import PCA, IncrementalPCA
iris = load_iris()
X = iris.data
y = iris.target
@alik604
alik604 / FFMPEG.md
Last active April 9, 2022 17:01
FFMPEG to reencode (encode) entire windows directory with GPU or x265

FFMPEG to reencode (encode) entire windows directory with GPU or x265

CPU

for %i in (*.mp4) do ffmpeg -i "%i" -c:v libx265 -vtag hvc1 -preset fast "%~ni_265.mp4"

ffmpeg -i input.mp4 -c:v libx265 -vtag hvc1 -preset fast input_compressed.mp4

Nvidia GPU

for %i in (*.mp4) do ffmpeg -i "%i" -c:v hevc_nvenc -preset fast "%~ni_nvda.mp4"

Python & Machine Learning Hello world

Quickly get up to speed

Software setup

Use Python 3.8.*. No point in 3.9, however it should be fine.

Run these to test if install is successful, and install some important packages. Please follow the errors as they come, one will ask the user to install C++ build tools, if not already installed (see below). This will take several minutes, as the dependencies are a few GBs. You must be off VPN, or set-proxy, as shown below.

@alik604
alik604 / visualizing data in 2d and 3d.py
Last active October 24, 2023 22:40
Quickly visualize your data in 2d and 3d with PCA and TSNE (t-sne)
# imports from matplotlib import pyplot as plt
from matplotlib import pyplot as plt
import pylab
from mpl_toolkits.mplot3d import Axes3D
from mpl_toolkits.mplot3d import proj3d
%matplotlib inline
%pylab inline
from sklearn.manifold import TSNE
from sklear.decomposition import PCA
@alik604
alik604 / starred repo opener.py
Last active January 28, 2024 15:07
Open all starred GitHub repositories in new tab - Open every starred GitHub repo in chrome, with python
import requests
import json
import webbrowser
USER = "alik604"
chrome_path = 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s'
# Change to your OS - https://stackoverflow.com/a/24353812/5728614
req = requests.get('https://api.github.com/users/' + USER + '/starred?per_page=100')
# ?page=2&per_page=100 # page is not working, first result is always the same

Lambda 1 (DB to SQS)

import boto3
from boto3.dynamodb.conditions import Key
from boto3.dynamodb.types import TypeDeserializer

import json

print('Loading function')
tableName = 'fizzbuzz'