Skip to content

Instantly share code, notes, and snippets.

View tinshade's full-sized avatar
🔥
Persevere

Abhishek Iyengar tinshade

🔥
Persevere
View GitHub Profile
window.globalConfig = {
siteName: "http://basdasdlahblah.com"
}
@tinshade
tinshade / RoomFinder.py
Last active October 28, 2023 18:21
Find rooms for cherroro
# Selenium Imports
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.support.ui import WebDriverWait
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.support import expected_conditions as EC
@tinshade
tinshade / SortListDict.py
Created May 2, 2023 08:51
Sorting a list of dicts based on values from within the dict.
list_to_be_sorted = [{'salary': 1000, 'n':'a'},{'salary': 1000, 'n':'b'},{'salary': 100, 'n':'b'}]
newlist = sorted( list_to_be_sorted, key=lambda k: (k['salary'], k['n']) )
print(newlist)
@tinshade
tinshade / DictionaryComprehensionExample.py
Created December 23, 2022 08:31
Little example script for writing dictionary comprehensions.
data= [
{'_id': '1001', 'data': [{'_id':1, 'variation': 1, 'quantity': 25}]},
{'_id': '1000', 'data': [{'_id': 3, 'variation': 1, 'quantity': 0}]}
]
data = {x['_id']:x['data'] for x in data}
print(data)
@tinshade
tinshade / WatermarkOnLiveVideo.py
Created August 15, 2021 14:17
Adding a static image watermark to a live web-cam video with Python and OpenCV. Make sure to include a "watermark.png" in your directory before running this script!
import cv2
import numpy as np
cap = cv2.VideoCapture(0)
cap.set(cv2.CAP_PROP_FRAME_WIDTH, 640)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 480)
logo = cv2.imread('watermark.png')
@tinshade
tinshade / clearSetIntervalDemo.html
Created August 13, 2021 07:32
Clearing a setInterval on a HTML page with vanilla JS
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Clear Interval Test</title>
</head>
<body>
<h1>Clear setInterval w/ JS</h1>
<br/>
<h4 id="status">Click Start</h4>
@tinshade
tinshade / PyImageDownloader.py
Created July 3, 2021 08:45
Simple python script to download image via URL
import requests
import base64
def imageTest(url):
return base64.b64encode(requests.get(url).content)
def writeback(image):
decodeit = open('myimage.png', 'wb')
decodeit.write(base64.b64decode((image)))
@tinshade
tinshade / csrf.js
Last active June 24, 2021 09:53
Getting CSRF for Django from JS. Just include this script in the HEAD section.
function getToken(name) {
let user = '{{request.user}}'
let cookieValue = null;
if (document.cookie && document.cookie !== '') {
const cookies = document.cookie.split(';');
for (let i = 0; i < cookies.length; i++) {
const cookie = cookies[i].trim();
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) === (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
@tinshade
tinshade / AES_Cryptography.py
Created May 9, 2021 10:11
Simple AES cryptography using Python
#!/usr/bin/python3
# python AES_Cryptography.py -e/-d <AbsolutePathToFile>
from Crypto import Random
from Crypto.Cipher import AES
import os
import os.path
from os import listdir
from os.path import isfile, join
import hashlib
import sys
@tinshade
tinshade / CenterElements.html
Created April 2, 2021 05:46
Quick and easy way to center elements; Vertically and Horizontally!
<!DOCTYPE html>
<html>
<head>
<title>Center anything with Grid</title>
<style>
*{
margin:0;
padding: 0;
}
#parent{