Skip to content

Instantly share code, notes, and snippets.

View tinshade's full-sized avatar
🔥
Persevere

Abhishek Iyengar tinshade

🔥
Persevere
View GitHub Profile
@tinshade
tinshade / OTP_Input.html
Created March 6, 2021 07:53
Simple Bootstrap, JS code for OTP styled inputs. Feel free to make this mobile responsive.
<!DOCTYPE html>
<html>
<head>
<title>OTP Input</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
<style>
*{
margin:0px;
padding:0px;
}
@tinshade
tinshade / DetectOS.js
Created February 19, 2021 08:37
A clean solution to detecting your client's OS using JavaScript. Use it on download pages!
//Detect OS
function DetectOS(){
var Detect = {
init: function () {
this.OS = this.searchString(this.dataOS);
},
searchString: function (data) {
for (var i=0;i<data.length;i++) {
var dataString = data[i].string;
var dataProp = data[i].prop;
@tinshade
tinshade / QRCodeGenerationAndDecoding.py
Created February 6, 2021 10:30
This simple gist demonstrates the use of third-party QR Code packages with Python3 to generate and decode QR Codes and Bar Codes alike!
###Generating a QR Code###
#pip install pyqrcode
#`pip install pypng` for PNG import errors, or try reinstalling Pillow!
import pyqrcode
from PIL import Image
s = "www.geeksforgeeks.org"
url = pyqrcode.create(s)
@tinshade
tinshade / ReverseIterate.py
Created January 7, 2021 07:25
A small python script that shows how you can iterate through an array in reverse, using FOR loop, without having manipulating the array itself.
#Reverse Iterate an array using FOR and range in python3.
arr = [2,4,-5,0,-120,23,2]
# range(start, stop, step)
for i in range(len(a)-1,-1,-1):
print(arr[i], end=" ") #Prints 2 23 -120 0 -5 4 2
@tinshade
tinshade / Image_Morph_Effect.py
Last active December 27, 2020 15:59
An Image morphing effect with Python's PIL library.
from PIL import Image
from argparse import ArgumentParser
from random import shuffle
from typing import List, Tuple
def generate_pixels(width: int, height: int) -> List[Tuple[int, int]]:
"""Generates random pixel locations"""
pixels = []
for x in range(width):
for y in range(height):
@tinshade
tinshade / Cartoonize.py
Created December 25, 2020 06:08
This program generates a "cartoonized" image of the given input image!
import cv2 #pip install opencv-python
#This program generates a cartoonized image of the given image!
img = cv2.imread("image.jpg")
def color_quantization(img, k):
data = np.float32(img).reshape((-1, 3))
criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 20, 1.0)
ret, label, center = cv2.kmeans(data, k, None, criteria, 10, cv2.KMEANS_RANDOM_CENTERS)
center = np.uint8(center)
result = center[label.flatten()]
@tinshade
tinshade / getlocalmac.js
Created December 23, 2020 08:56
Get the MAC address of a local system. This can be used to ID systems on your network. MAC addresses can be spoofed but are not in most cases and are static unless tampered with so it makes a better ID than a client's IP address.
/*
Get the MAC address of a local system.
This can be used to ID systems on your network.
MAC addresses can be spoofed but are not in most cases
and are static unless tampered with so it makes a better ID than a client's IP address.
*/
const getmac = require('getmac'); //https://www.npmjs.com/package/getmac
const callMac = () =>{
@tinshade
tinshade / RandomUID.py
Created December 8, 2020 14:31
Generating logcally unique random user ID using pre-installed python modules.
from datetime import datetime
from random import randint
uid = str(datetime.utcnow().strftime('%Y%m%d%H%M%S%f')[:-3]*randint(1,37))
print(f"Here: {uid}\nUse this logically unique ID if you aren't using the traditional +=1 technique!")
@tinshade
tinshade / PHP_DB_Config.php
Created November 18, 2020 08:25
Simple PHP database configuration script that automatically switches between local and production databases based on the server it is being run on.
<?php
$whitelist = array('127.0.0.1','::1');
if(!in_array($_SERVER['REMOTE_ADDR'], $whitelist)){
//SERVER
$server = 'localhost';
$username = 'server_username';
$password = 'server_password';
$dbname = 'username_dbname';
$conn = mysqli_connect($server, $username, $password, $dbname);
@tinshade
tinshade / Fixed_PHPMailerAutoload.php
Created November 18, 2020 08:17
This is a fixed version of PHP autoload. I made this because something in PHP mailer breaks down with PHP v7 and this aims to fix that issue.
<?php
/**
* PHPMailer SPL autoloader.
* PHP Version 5
* @package PHPMailer
* @link https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project
* @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk>
* @author Jim Jagielski (jimjag) <jimjag@gmail.com>
* @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
* @author Brent R. Matzelle (original founder)