Skip to content

Instantly share code, notes, and snippets.

View omar-azmi's full-sized avatar

Omar Azmi omar-azmi

View GitHub Profile
@omar-azmi
omar-azmi / _s3_helper.ts
Last active November 11, 2025 08:50
a standalone web-compatible implementation of AWS signature v4 in typescript (though it does require `crypto.subtle` to be available).
/** this is an implementation of *AWS Signature Version 4* http headers generator.
*
* this was adapted from amazon's guide below.
* - link to guide: [`https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-header-based-auth.html`](https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-header-based-auth.html)
*
* @module
*/
import { hmacSha256, hmacSha256Recursive, sha256 } from "./crypto.ts"
import { bufferToHex } from "./funcdefs.ts"
@omar-azmi
omar-azmi / knockoutjs_bad_update_path_demo.js
Created August 25, 2025 04:08
demonstrates knockoutjs's bad signal dependency management. ideally, it should be topologically ordered, but instead it fires multiple update rounds for a single update source, and only within each update round is topological sorting guaranteed, but not across them.
/** here is a demonstration showing knockout-js's inability to compute signals based on their topological ordering.
*
* what happens instead is that there are multiple rounds of updates for a single updated source signal.
* and in each of _those_ updates, the partial batch of signals that are involved _are_ topologically ordered,
* but that does not mean that those signals (that have already been updated once)
* will not be called/updated _again_ in the next set of updates, because chances, are some of them will updated again.
*
* a graph of the signals and computed-signals used in this example is illustrated below:
* ```text
* ┌──A B ┌──C
@omar-azmi
omar-azmi / setup_deno_on_termux.sh
Last active September 18, 2025 08:24
installing and setting up deno on android via termux
# NOTE: to run this script remotely (without copy and pasting) simply execute:
# curl -fsSL "https://gist.githubusercontent.com/omar-azmi/9510958fe24a7374856ccc75217330d5/raw/setup_deno_on_termux.sh" | sh
# the following shell script will install the deno javascript runtime to your termux environment on android.
# after that, it will patch the deno binary to use android/termux compatible libc shared libraries (which we will download beforehand)
# finally, we will append the path to the deno library onto the PATH environment variable in your local `./.bachrc` file, so that `deno` will be available as a command on every terminal session.
# the proceedure for making deno compatible with termux was gathered from the following resources:
# - "https://github.com/denoland/deno/issues/19759"
# - "https://gist.github.com/CodeIter/ccdcc840e432288ef1e01cc15d66c048"
@omar-azmi
omar-azmi / notebook-fan-control_lenovo-yoga-460-20fy.xml
Created February 21, 2025 02:44
NoteBook FanControl - Configuration for Lenovo Thinkpad Yoga 460 20FY0002US
<?xml version="1.0"?>
<FanControlConfigV2 xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<NotebookModel>Lenovo Yoga 460 20FY</NotebookModel>
<Author>OMAX</Author>
<EcPollInterval>750</EcPollInterval>
<ReadWriteWords>false</ReadWriteWords>
<CriticalTemperature>92</CriticalTemperature>
<FanConfigurations>
<FanConfiguration>
<ReadRegister>149</ReadRegister>
@omar-azmi
omar-azmi / m3u_downloader.ts
Created December 3, 2024 02:44
m3u and m3u8 playlist to local-playlist converter and downloader
/** given an "m3u" or "m3u8" playlist (`input_path`):
* - this script downloads the http music files referenced in the playlist to the output playlist folder (`output_dir`),
* - and then builds a local equivalent playlist file (`output_playlist`) that refernces the downloaded music files (via relative path).
* - this script runs natively on deno, and will probably need adjustments in the import statements to work in a different runtime.
* - if `dryrun` is set to `true` no filesystem write operations will be carried, but the script will still log the operations that it will carry out.
*/
import { relativePath } from "jsr:@oazmi/kitchensink/pathman"
import { isString } from "jsr:@oazmi/kitchensink/struct"
import { emptyDir, ensureFile } from "jsr:@std/fs"
@omar-azmi
omar-azmi / animethemes_moe_transfer_localplaylist.ts
Last active March 24, 2024 14:06
http://AnimeThemes.moe transfer your local storage playlist to one of your account's playlist
/** ENTER YOUR PLAYLIST RELATIVE URL HERE. it should look something like "/playlist/mb7tqz"
* You can find the url by:
* 1) heading over to your profile page "https://animethemes.moe/profile"
* 2) click on your playlist of interest
* 3) copy the the url (should look like "https://animethemes.moe/playlist/mb7tqz") and strip away the domain name ("https://animethemes.moe")
*/
const your_playlist_href = "/playlist/EXAMPLE"
const theme_card_list_parent_element = document.querySelector("#__next>div>div>div:nth-child(2)>div:nth-child(2)>div:nth-child(4)>div") as HTMLElement
const three_dot_button_selector = "button[id^=radix]"
@omar-azmi
omar-azmi / bing_rewards.ts
Created January 28, 2024 15:28
utility script to autoclick bing reward task buttons/links, and get daily rewards quicker
/** utility script to autoclick bing reward task buttons/links, and get daily rewards quicker */
const get_bing_tasks = () => {
let
tasks_panel_iframe_document: Document | null,
loaded_promo_contents: NodeListOf<HTMLDivElement> | null
return new Promise<Array<HTMLDivElement>>((resolve, reject) => {
const interval_ref = setInterval(() => {
tasks_panel_iframe_document ??= (
document.querySelector("#panelFlyout") as HTMLIFrameElement
@omar-azmi
omar-azmi / license.md
Last active January 24, 2024 23:55
an anti-artificial-intelligence training, anti-crawling, and anti-competition opensource license file

Anti-Competition License

Copyright (c) [Year] [YourName]

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
@omar-azmi
omar-azmi / structuredclone_vs_objectclone.ts
Created September 12, 2023 14:10
structuredClone vs Object cloning for `map: Map<number, Set<number>>`, where `map.size` is about 500 and `map.get(any).size` averages to about 10
const array_from = Array.from
const math_random = Math.random
const mapToObject = <MK extends PropertyKey, MV>(map: Map<MK, Iterable<MV>>): Record<MK, Array<MV>> => {
const obj = {} as Record<MK, Array<MV>>
map.forEach((value, key) => {
obj[key] = array_from(value)
})
return obj
}
@omar-azmi
omar-azmi / soidjs_bad_update_path_demo.tsx
Created September 5, 2023 03:14
demonstrates solidjs's bad signal dependency management. ideally, it should be topologically ordered, but instead it fires based on first come first serve basis.
/** highlights solidjs's bad signal dependency management. <br>
* solid playground repl at: [link](https://playground.solidjs.com/anonymous/622c376c-9312-49fe-bc65-498f7fcf61b8) <br>
* try pressing the various combination of set signal buttons, and witness the incorrect callstack logged into the console. <br>
* ideally, a memo must only be called AFTER all of its dependencies have been resolved,
* however what ends up happening is that only the immediate observers of a signal/memo are called,
* even if they have a dependency on an unresolved memo down the line. <br>
* since signals and memos form a DAG (directed acyclic graph, aka dependency graph),
* in theory there always exists an update path such that all dependencies are always resolved before hand.
* this is called the topological order of a DAG. <br>
* but since there is a little overhead and lookahead involved in figuring out this path, I guess the idea was not pursued. <br>