Skip to content

Instantly share code, notes, and snippets.

View kuharan's full-sized avatar
🎯
Focusing

KUHARAN BHOWMIK kuharan

🎯
Focusing
View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kuharan
kuharan / converter.js
Last active January 18, 2019 06:46
Draw dynamic Canvas with Js
function hexToRgb(hex) {
r = hex.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i);
if (r) {
return r.slice(1, 4).map(function(x) {
return parseInt(x, 16);
});
}
return null;
}
@kuharan
kuharan / One Hot Encoding Example.ipynb
Last active January 14, 2019 06:17
This gist provides sample code to generate random car data and use one hot encoding and re arrange the data frame so that the target remains in the end.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
//double quotes test
val pattern = """(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\s*(-)\s*(-)\s*(\[.+?\])\s*"(.+?)\s(.+?)\s(.+?)"\s*(\d{1,3})\s*(\d{1,10})\s*"(.+?)"\s*"(.+?)"\s*"(.+?)"""".r;
val input = """174.371.196.220 - - [07/Sep/2017:00:06:00 +0000] "GET /cs/v1/points/bal?memberId=2164699082&accountType=10 HTTP/1.1" 200 4263 "-" "Mozilla/5.0 (Windows NT 6.0; rv:34.0) Gecko/20100101 Firefox/34.0" "-"""";
val res = input match {
case pattern(ip, username1, logname2, time, requestType, requestURL, requestMethod, status, bytes, referer, userAgent, filename ) => s"IP=$ip\nUsername=$username1\nLogname=$logname2\nTime=$time\nRequestType=$requestType\nRequestURL=$requestURL\nRequestMethod=$requestMethod\nStatus=$status\nBytes=$bytes\nReferer=$referer\nUserAgent=$userAgent\nFilename=$filename"
case _ => "NONE"
}
print(res)
@kuharan
kuharan / gen_pass.py
Created March 4, 2018 18:48
A Simple Password Generator in Python
from random import *
import string
min = 10
max = 20
combination = string.ascii_letters + string.digits + string.punctuation
var_pass = "".join(choice(combination) for x in range(randint(min, max)))
print("Random Password String: ", var_pass)