Skip to content

Instantly share code, notes, and snippets.

View karmanyaahm's full-sized avatar
💭
hello everyone

Karmanyaah Malhotra karmanyaahm

💭
hello everyone
View GitHub Profile
@karmanyaahm
karmanyaahm / bash.sh
Last active January 7, 2021 16:31
ip address info from nginx logs or any similar logs
cat access.log access.log.1 | grep '/t.json' | awk '{print $1}' | sort | uniq | xargs -L1 -I % curl "https://freegeoip.app/json/%" | tee -a ~/log.log
@karmanyaahm
karmanyaahm / check.sh
Created November 9, 2020 06:30
Nvchecker gotify notifications cron
#!/bin/bash
# Note: an empty json file at old_ver.json should exist before running this
cd "$(dirname "$0")"
nvchecker -l error -c nvchecker.toml
VAR="`nvcmp -c nvchecker.toml`"
url="https://gotify.example.com"
token="A123ABC.DEF"
@karmanyaahm
karmanyaahm / sh.sh
Created October 24, 2020 02:31
Status of status server backup gotify
#!/bin/bash
SERVER_NAME="STATUS"
URL="https://status.malhotra.cc"
TIMEOUT=10
GOTIFYURL="https://gotify.example.com"
GOTIFY_TOKEN="token"
PRIORITY=9
STATUS=$(curl -m $TIMEOUT "$URL" -w "%{http_code}\\n" -I -o /dev/null 2>/dev/null)
@karmanyaahm
karmanyaahm / gist:fa4b0630aab28e05740732163e6af56e
Created October 4, 2020 17:23
traceback google classroom api issue report
Traceback (most recent call last):
File "/home/karmanyaahm/Documents/code/other/server/google_classroom/.venv/lib/python3.8/site-packages/flask/app.py", line 2464, in __call__
return self.wsgi_app(environ, start_response)
File "/home/karmanyaahm/Documents/code/other/server/google_classroom/.venv/lib/python3.8/site-packages/flask_behind_proxy.py", line 25, in __call__
return self.app(environ, start_response)
File "/home/karmanyaahm/Documents/code/other/server/google_classroom/.venv/lib/python3.8/site-packages/flask/app.py", line 2450, in wsgi_app
response = self.handle_exception(e)
File "/home/karmanyaahm/Documents/code/other/server/google_classroom/.venv/lib/python3.8/site-packages/flask/app.py", line 1867, in handle_exception
reraise(exc_type, exc_value, tb)
File "/home/karmanyaahm/Documents/code/other/server/google_classroom/.venv/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
@karmanyaahm
karmanyaahm / py.py
Created October 3, 2020 23:34
Google OpenID API Python get User Info
##it took me hours to find what I wanted in between deprecated APIs and lacking documentation as of Oct 2020, hopefully this'll help someone
import requests
creds = google.oauth2.credentials.Credentials ###not real thing, replace with the credentials you got from the flow
url = 'https://openidconnect.googleapis.com/v1/userinfo'
head = { 'Authorization': 'Bearer '+creds.token}
response = requests.get(url, headers=head)
print(response.json()['sub'])
@karmanyaahm
karmanyaahm / openpgp.md
Created August 28, 2020 04:27
Keyoxide identity proof
@karmanyaahm
karmanyaahm / tootsie_pop.py
Last active July 31, 2020 19:43
Hacktivitycon CTF Tootsie Pop
#it stops once because of python recursion limits but can be manually restarted
#it extracts files and then moves them to one directory so the filename doesn't get too long(which is not supported in some tools like bzip)
from xtract import xtract
import os
import glob
# def names():
def delempty(dirr):
for i in [f[0] for f in os.walk(dirr) if os.path.isdir(f[0])]:
@karmanyaahm
karmanyaahm / audio-source.sh
Created July 28, 2020 17:51
Switch between HDMI and laptop audio in pulse audio with one command
#!/bin/bash
#input hdmi,analog, or check
#you will probably have to change the specific values with information from `pacmd list-cards` before it works for your setup
#I am using this script with https://store.kde.org/p/1297839
CARDID="9d71"
INP=$1
@karmanyaahm
karmanyaahm / bunch_of_random_functions.py
Created July 21, 2020 16:45
Python 3.8 file handling functions
import os
def getdirs():
return [f.path for f in os.scandir('.') if f.is_dir()]
def delempty(dir):
for i in [f[0] for f in os.walk(dir) if os.path.isdir(f[0])]:
try:
@karmanyaahm
karmanyaahm / list.txt
Created June 13, 2020 03:17
Comma seperated list of palindromic prime numbers up to 7 digits long (first 781)
2, 3, 5, 7, 11, 101, 131, 151, 181, 191, 313, 353, 373, 383, 727, 757, 787, 797, 919, 929, 10301, 10501, 10601, 11311, 11411, 12421, 12721, 12821, 13331, 13831, 13931, 14341, 14741, 15451, 15551, 16061, 16361, 16561, 16661, 17471, 17971, 18181, 18481, 19391, 19891, 19991, 30103, 30203, 30403, 30703, 30803, 31013, 31513, 32323, 32423, 33533, 34543, 34843, 35053, 35153, 35353, 35753, 36263, 36563, 37273, 37573, 38083, 38183, 38783, 39293, 70207, 70507, 70607, 71317, 71917, 72227, 72727, 73037, 73237, 73637, 74047, 74747, 75557, 76367, 76667, 77377, 77477, 77977, 78487, 78787, 78887, 79397, 79697, 79997, 90709, 91019, 93139, 93239, 93739, 94049, 94349, 94649, 94849, 94949, 95959, 96269, 96469, 96769, 97379, 97579, 97879, 98389, 98689, 1003001,1008001,1022201,1028201,1035301,1043401,1055501,1062601,1065601,1074701,1082801,1085801,1092901,1093901,1114111,1117111,1120211,1123211,1126211,1129211,1134311,1145411,1150511,1153511,1160611,1163611,1175711,1177711,1178711,1180811,1183811,1186811,1190911,1193911,1196911,12