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 / Makefile
Last active March 18, 2024 17:43
Put this in a directory and then call `nix develop --impure` This is assuming flakes are enabled in the nix config (I'm using it on NixOS but it should??? work on any nix package manager installation?)
all: clean build
build:
gcc student_a64_template.s a64_testbench.o -o ac_lab -g -lm
run: build
qemu-aarch64 ./ac_lab ${ARGS}
run-and-wait-for-debug:
while true; do make build && qemu-aarch64 -g 25540 ./ac_lab ${ARGS}; sleep 1; done
@karmanyaahm
karmanyaahm / flake.nix
Last active June 25, 2023 18:34
Orange Pi Zero with Allwinner H2+ NixOS SD Card image with uboot included; cross compiling `x86_64` -> `armv7l`; ethernet works, wifi not tested
# NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1 nix build --impure .#opi
{
description = "NixOS Orange Pi Zero configuration flake";
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05";
outputs = { self, nixpkgs }: rec {
pkgsIntel = import nixpkgs {
system = "x86_64-linux"; # or something else
config = { allowUnfree = true; allowUnsupportedSystem = true;};
@karmanyaahm
karmanyaahm / polyglot.py
Last active April 4, 2023 02:38
PNG Text Polyglot generator, insert tEXt chunk into PNG using Python (made for micropython/circuitpython, so it conserves memory and has minimal dependencies)
# Minimum index is 1, the IHDR block MUST be first for a valid PNG
# this assumes the skipped blocks aren't very large, so it reads the whole block into memory at once, beware of setting index to more than 1
# The script is also read into memory so don't make it too large
def insert_text_chunk(filein, fileout, text, index = 1):
from binascii import crc32
from struct import pack, unpack
with open(filein, 'rb') as fin, open(fileout, 'wb') as fout:
fout.write(fin.read(8)) # PNG Header
# skip blocks
@karmanyaahm
karmanyaahm / selection-to-ntfy-bookmarket.js
Created December 20, 2022 20:51
Send currently selected text to you chosen ntfy topic by just clicking on a bookmarket; currently doesn't work for textboxes
javascript:(() => { w = window.open("https://ntfy.sh/mytopic/publish?message="+encodeURIComponent(document.getSelection().toString().replace(/(<br>)|(<br\/>)/, "\n"))); setTimeout(() => {w.close()}, 1500); })();
@karmanyaahm
karmanyaahm / txt.txt
Created September 7, 2021 03:51
apprise matrix username tip
If your MXID server alias is different from the server host, ie domain.tld and matrix.domain.tld, apprise could work with this
matrixs://%40localpart%3Aexample.org:password123@matrix.example.org/#room-name
just wanted to publish this
@karmanyaahm
karmanyaahm / Caddyfile
Created June 20, 2021 21:06
Caddy IPNS mount server custom 404 page and response code for other situations
{
auto_https disable_redirects
}
(upgrade) {
@upgradable {
header Upgrade-Insecure-Requests 1
protocol http
}
@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