Skip to content

Instantly share code, notes, and snippets.

@o-az
o-az / _ansi-color-codes.md
Last active November 26, 2023 01:41
ANSI color codes in various file formats (.sh, .json, .ts)
@o-az
o-az / reset-to-initial-commit.sh
Created November 16, 2023 00:06
Reset the current branch to the initial commit, keeping the working directory as it is
View reset-to-initial-commit.sh
git reset --soft `git rev-list --max-parents=0 HEAD`
@o-az
o-az / hide-scrollbar.js
Created November 2, 2023 11:54
Hide ugly default browser scrollbar without affecting functionality
View hide-scrollbar.js
// ==UserScript==
// @name Hide Scrollbar
// @namespace http://example.com
// @version 1
// @grant GM_addStyle
// @include https://twitter.com/*
// @include https://x.com/*
// @include https://warpcast.com/*
// ==/UserScript==
@o-az
o-az / discord-bot-send-message.sh
Created October 21, 2023 06:37
Sends a message to a Discord channel via a Discord bot using cURL cli command
View discord-bot-send-message.sh
# replace CHANNEL_ID and BOT_SECRET with your values
curl --include \
--request POST "https://discord.com/api/channels/CHANNEL_ID/messages" \
--header "Content-Type: application/json" \
--header "Authorization: Bot BOT_SECRET" \
--data '{ "content": "lorem ipsum" }'
@o-az
o-az / suppress-warnings.cjs
Last active October 6, 2023 04:17
Suppress all Node.js warnings (including deprecation warnings)
View suppress-warnings.cjs
const { emit: originalEmit } = process;
/**
* @param {string} event
* @param {{ name: string; }} error
*/
function suppresser(event, error) {
return event === "warning" && error.name === "ExperimentalWarning"
? false
: originalEmit.apply(process, arguments);
@o-az
o-az / curl-performance.sh
Created September 2, 2023 07:35
I have this in my ~/.zshrc and can run 'perf <url>' to get request performance
View curl-performance.sh
function perf {:
curl --silent \
--url "$1" \
--output /dev/null \
--write-out "\n%{time_total} sec\n%{size_download} bytes\n"
}
View keybase.md

Keybase proof

I hereby claim:

  • I am o-az on github.
  • I am askii (https://keybase.io/askii) on keybase.
  • I have a public key ASD98QEZFdoBJUPWQUl_oFR6gzfKC5kyy-UH3ORhb31CvAo

To claim this, I am signing this object:

@o-az
o-az / sleep.ts
Last active June 23, 2023 23:58
Actual JavaScript 'sleep' function
View sleep.ts
/**
* @param ms milliseconds to sleep
* @returns void
*/
export function sleep(ms: number): void {
/**
* In some environments such as Cloudflare Workers, Atomics is not defined
* setTimeout is used as a fallback
*/
if (typeof Atomics === 'undefined') {
@o-az
o-az / wrangler.json
Last active November 27, 2023 13:28
Cloudflare Workers wrangler JSON schema (might not be complete)
View wrangler.json
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "The name of the project"
},
"main": {
"type": "string",