Skip to content

Instantly share code, notes, and snippets.

View akarsh1995's full-sized avatar
🌐
Finding a startup

Akarsh akarsh1995

🌐
Finding a startup
View GitHub Profile
@akarsh1995
akarsh1995 / pre-push
Created May 29, 2023 07:02
pre-push git hook to generate Arch User Repository files
#!/bin/python
import subprocess
import re
from pathlib import Path
import os
WD = Path().absolute()
PKGBUILD_IN_PATH = Path("PKGBUILD").absolute()
OUT_PATH = Path("aur_out").absolute()
@akarsh1995
akarsh1995 / caps_lock_mod.fish
Last active October 16, 2023 18:16
Fish script to mod CAPSLOCK to ESCAPE and CAPSLOCK + h j k l to arrow keys on Arch Linux wayland + sway.
#!/usr/bin/env fish
# locations
set intercept_dir_loc /etc/interception
set mapping_loc $intercept_dir_loc/dual-function-keys/caps2escape.yaml
set daemon_config_loc $intercept_dir_loc/udevmon.d/my-keyboards.yaml
set file_name_symbols alt_gr_mapped_to_caps_lock
set xkb_symbols_loc $HOME/.xkb/symbols/$file_name_symbols
set sway_config_loc $HOME/.config/sway/config
@akarsh1995
akarsh1995 / b64toFile.ts
Last active June 30, 2022 14:15
Convert base64 data-url to javascript File object
// to quickly try the script open
// https://www.typescriptlang.org/play?#code/JYOwLgpgTgZghgYwgAgJICE4GcIDYAsAInGHMgN4BQyyAtsLRACoCeADhAFzJZhSgBzADTVkMYABsIIOI269+IYaIgAPSCCzAA9iHl9BImgCMCAExJx9igZQC+lSjACuIBGB0hkAfWPY8+EzaAIJQUHAs6M4wMNAAFH44BNaCAJQUogBucFDIxqA5LN4KgsgAvMgk2sYJ-gSpANxZOchSXhX5MlBFJUoAdG0CYAAWTTTZucYskFjlyCAQAO7IAKqgYAAcoeEscW2NojDauXETyMBzAAwN58gAPK3SN8AA1C-pVDQm0xBYANrAAC6c06hWKBn6CGGOQAwtozBBgmA4sADjQHDQoBAwM4oF4pjMmg5HAgJNhZpgkvgAMoQgQZGgWUjcDB1IiWUS+ZI8OmOGgIXQKZzuY61Km0mwpJQfUQ0EbALB9Ln4EFsiWCMZfeWKplkCrIbVKhFC9y4iBxNHIYk0bzGvjCnFYi0Mr4CzRgZACKDaZxsWYVBbLABKEAEAFFVGw4gB6OIAfk4us4cT6ACo441UvHOGmGqlU9mZIwyinU6kADp9UsZvPZ3P5xIBISl1LR1J9NQQBBxQ3Ky38wUev7eIR0BjMdgQUfiNqyKfINQaLS6UemfC64EVL0+v2azHY3FechjxisDjTyTSOfcBEChErIOoOG0Ni6aTImdXxipUeL6TLkBV3MSwrVEa1PWxKIYniVJuDWcAtjCCIXX3R0vF8Nkgm2CIoNiKAe2GBU+l1Po111VIwL5CCwHQCRqgtbhaOqFDkCxND5iWZAmJqP5DQESDojwi1AVHY8wEnbhDRI+hT0nK1LXA-iwAAMUvAA5OcAHVgBGP9NE8BieRsFi2MPZAAAMABJyCkyw+k-IsIDsPprNs0gO3Uf9PDsczNUU7FVKkQzApQT4vlMvEOOWEK4llL5eMIxUlO451sC4
@akarsh1995
akarsh1995 / mxgame.js
Last active July 10, 2021 11:06
mxjs
window.gameManager = {
onGameInit: function () {
return {
userId: "1",
gameId: "2",
roomId: "3",
highestScore: 90,
lastLevel: 0, // user's current level
gameMode: "score", // "score" or "win"
isFirstOpen: true, // true or false
@akarsh1995
akarsh1995 / requirements.txt
Created September 6, 2020 16:26
Working for long hours 🖥️ ? Use our script to remind you to take breaks every 30 minutes 😇 !
playsound==1.2.2
gTTS==2.1.1
@akarsh1995
akarsh1995 / requirements.txt
Created September 4, 2020 15:23
Download youtube videos like a pro 😎.
youtube-dl==2020.7.28
@akarsh1995
akarsh1995 / encrypt_pdf.py
Created September 3, 2020 14:55
Encrypt your pdf files in bulk.
import PyPDF2
def encrypt_pdf(file_to_encrypt, password, save_file_as):
pdf_writer = PyPDF2.PdfFileWriter()
with open(file_to_encrypt, "rb") as pdf_input_file:
pdf_reader = PyPDF2.PdfFileReader(pdf_input_file)
for page_num in range(pdf_reader.numPages):
@akarsh1995
akarsh1995 / pygments_usage.py
Created August 31, 2020 17:17
Use this syntax highlighter to highlight syntax of almost any language.
from pygments import highlight
from pygments.lexers import PythonLexer
from pygments.formatters import HtmlFormatter
code = '''helloworld_string = 'Hello! World'
print f"{helloworld_string}"'''
template = '''<html>
<head>
<title>How to use Pygments</title>
@akarsh1995
akarsh1995 / psutil_get_mem_info.py
Last active August 29, 2020 12:13
Get the process information using psutil in python. Useful to log usage in prod.
import psutil
def memory_usage_psutil(pid_or_proc_name):
"""Find the memory usage using psutil"""
pid_or_proc_name = str(pid_or_proc_name)
mem_info = None
# iter over processes and find the desired one
for proc in psutil.process_iter(['pid', 'name', 'username']):
@akarsh1995
akarsh1995 / requirements.txt
Created August 27, 2020 17:10
Dispatch function as commandline utility. But this time using argh.
argh