Skip to content

Instantly share code, notes, and snippets.

Avatar
🤓
Eat · Sleep · Code

Vignesh Rao thevickypedia

🤓
Eat · Sleep · Code
View GitHub Profile
@thevickypedia
thevickypedia / tokenizer.py
Last active May 4, 2023 15:19
Tokenize a string using python
View tokenizer.py
import base64
import binascii
import string
UNICODE_PREFIX = base64.b64decode(b'XA==').decode(encoding="ascii") + \
string.ascii_letters[20] + string.digits[:1] * 2
input_text = 'hello world'
@thevickypedia
thevickypedia / python_to_curl.py
Created April 27, 2023 12:13
Convert a python request to curl (without actually making a request)
View python_to_curl.py
SS_HEADERS = {
"Content-Type": "text/plain"
}
def check(response):
req = response.prepare()
command = "curl -X {method} \\\n -H {headers} \\\n -d '{data}' \\\n '{uri}'"
method = req.method
uri = req.url
@thevickypedia
thevickypedia / stop_process.sh
Last active April 16, 2023 18:30
Stop a process with process name in argument
View stop_process.sh
if [[ $1 == "" ]]
then
echo "Pass process name as argument"
exit
else
echo "Stopping PIDs for $1"
fi
for pid in $(ps -ef | grep $1 | awk '{print $2}'); do echo "Stopping pid $pid" && kill -9 $pid; done
# for pid in $(ps -ef | awk '/$1/ {print $2}'); do echo "Stopping pid $pid" && kill -9 $pid; done
@thevickypedia
thevickypedia / cleanup_release_and_tags.py
Last active April 9, 2023 15:59
Clean up releases and tags in GitHub
View cleanup_release_and_tags.py
import logging
import os
from threading import Thread
from typing import List, Tuple, Union
import requests
LOGGER = logging.getLogger(__name__)
LOGGER.addHandler(logging.StreamHandler())
LOGGER.setLevel(logging.DEBUG)
@thevickypedia
thevickypedia / timezones.py
Last active March 14, 2023 02:18
Get all timezone names, descriptions and GMT offsets
View timezones.py
import os
from collections.abc import Generator
from threading import Thread
from typing import List, Union, NoReturn, Dict
import pandas
import requests
import yaml
from jarvis.modules.exceptions import EgressErrors
@thevickypedia
thevickypedia / domain_availability.py
Last active January 27, 2023 14:50
Check domain name availability across all top-level domains in AWS using whois service
View domain_availability.py
import logging
import subprocess
from typing import Iterable, NoReturn
import requests
from bs4 import BeautifulSoup
class CustomFormatter(logging.Formatter):
"""Override logging.Formatter using custom colors."""
@thevickypedia
thevickypedia / github.py
Created January 24, 2023 04:24
Check availability of an username and get details of the particular account
View github.py
"""Check availability of an username and get details of the particular account.
Requirements:
python -m pip install python-dotenv requests
"""
import json
import os
import string
from typing import Union
@thevickypedia
thevickypedia / timezones.ipynb
Last active January 16, 2023 14:27
Timezones using python
View timezones.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@thevickypedia
thevickypedia / camera.py
Last active December 29, 2022 04:03
Get information and list cameras for Linux, macOS and Windows
View camera.py
import platform
import subprocess
from typing import Dict, Iterable, List, Union
Windows = """wmic path CIM_LogicalDevice where "Description like 'USB Video%'" get /value"""
Darwin = "system_profiler SPCameraDataType"
Linux = "v4l2-ctl --list-devices"
def list_splitter(original_list: List[str], delimiter: str) -> List[List[str]]:
@thevickypedia
thevickypedia / video.py
Last active June 24, 2022 18:56
Stream videos using FastAPI
View video.py
"""
pip install fastapi uvicorn aiofiles jinja2
uvicorn video:app --reload
"""
import mimetypes
import logging
import os
import pathlib
from fastapi import FastAPI, Request, Response, Header