Skip to content

Instantly share code, notes, and snippets.

View harshithjv's full-sized avatar

Harshith J. V. harshithjv

  • Mangalore
  • 18:34 (UTC +05:30)
View GitHub Profile
dir *.CR2
FOR %i IN (*.CR2) DO "C:\Program Files\7-Zip\7z.exe" a -mx9 "%~ni.CR2.7z" "%i"
dir *.7z
del *.CR2
REM -----
@harshithjv
harshithjv / _Testing Plotly on Sanic.md
Last active February 12, 2025 06:37
Testing plotly youtube sample via sanic

Download/clone all files in gist locally.

Install all requirements:

pip install -r requirements.txt

Start Sanic server:

@harshithjv
harshithjv / kill_tasks.bat
Created November 23, 2024 07:59
Windows kill task forcefully on command line
:: Refs:
:: - https://www.minitool.com/news/unable-to-terminate-process-access-is-denied.html
:: - https://superuser.com/questions/1183057/tasklist-shows-process-but-taskkill-is-unable-to-kill-it-even-as-admin
tasklist
tasklist | findstr "process_name.exe"
taskkill /im "process_name.exe" /f
@harshithjv
harshithjv / tiny_get_and_post_server.py
Last active July 20, 2023 11:56
A small Python script to start a server to handle both GET and POST requests.
# Ref: https://stackoverflow.com/a/66514587
# Just made changes reponse to JSON type
from http.server import BaseHTTPRequestHandler, HTTPServer
import json
class handler(BaseHTTPRequestHandler):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
def do_GET(self):

Keeping this stackoverflow answer(Python) handy for future use:

try:
    func1()
except Exception as ex:
    trace = []
    tb = ex.__traceback__
    while tb is not None:
        trace.append({
 "filename": tb.tb_frame.f_code.co_filename,
@harshithjv
harshithjv / jinja_text_template_variables.py
Created May 4, 2023 07:13
Find list of variables from jinja templates
# A small example that works text based templates
# Ref: https://stackoverflow.com/a/8284419
# Note: Works only for top-level variables, i.e., id dictionary is passed then we can't parse keys defined within the dictionaries
from jinja2 import Environment, BaseLoader, meta
if __name__ == '__main__':
template_text = '<div>{{ title }}</div>'
template_env = Environment(loader=BaseLoader())
variable_list = list(meta.find_undeclared_variables(template_env.parse(template_text)))
print("List of variables inside template: "+variable_list)
@harshithjv
harshithjv / Async_Operations_in_Python.md
Last active May 3, 2023 09:36
Self notes for async handling in python
  • Run via simple await
await async_func()
  • Run via asyncio
import asyncio

asyncio.run(async_func())
@harshithjv
harshithjv / CreatingDummyFile.Win&Nix.md
Last active September 15, 2022 13:16
How to create dummy files in Windows and *nix platforms

Windows cmd line to create dummy 1 GB file:

C:\ fsutil file createnew dummy.doc 1073741823
File C:\dummy.doc is created

Linux shell to create dummy 1 GB file:

@harshithjv
harshithjv / wkt_transfrom_with_buffer.py
Created July 8, 2022 14:56
To convert any WKT string to Polygon WKT if buffer is provided in meters.
# Code reference: https://gis.stackexchange.com/a/327046
import json
import pyproj
import shapely.wkt as shp_wkt
import shapely.geometry as shp_geo
from shapely.geometry import Polygon as ShpPolygon
@harshithjv
harshithjv / Set_ReadOnly_to_PEM_file.bat
Last active March 21, 2022 06:52
Set private (read-only) permission for .pem file on Windows
REM Use icacls command in windows OS to set file permission which operates chmod in *nix platform. This script can be run on classic command prompt.
REM Syntax:
REM icacls.exe <ssh_Key_filename> /reset
REM icacls.exe <ssh_Key_filename> /grant:r "%username%":"(R)"
REM icacls.exe <ssh_Key_filename> /inheritance:r
icacls.exe vm_access.pem /reset
icacls.exe vm_access.pem /grant:r "%username%":"(R)"
icacls.exe vm_access.pem /inheritance:r