Skip to content

Instantly share code, notes, and snippets.

View mhsattarian's full-sized avatar
🎯
Focusing

Mohammad H. Sattarian mhsattarian

🎯
Focusing
View GitHub Profile
@mhsattarian
mhsattarian / version.mjs
Last active July 25, 2022 15:13
Use current Jalali Date as NPM package version. run with zx.
#!/usr/bin/env zx
const branch = (await $`git branch --show-current`).stdout.trim();
if (branch === "debug") {
const currentVersion = (
await $`awk '/version/{gsub(/("|",)/,"",$2);print $2}' package.json`
).stdout.trim();
const date = new Date();
@mhsattarian
mhsattarian / archillect-downlod-button.content.js
Created January 17, 2024 17:58
A simple contentScript Chrome extension to add a download button to Archillect images
const imgSrc = document.querySelector("#ii").src;
const soruces = document.querySelector("#sources");
const link = document.createElement("a");
link.textContent = "Download";
link.href = imgSrc.replace("66", "64");
link.download = "download";
link.target = "_blank";
@mhsattarian
mhsattarian / IGLive.content.js
Created January 17, 2024 18:01
A simple (browser)action Chrome extension to add a rotate Instagram lives/stories
function doSmthing() {
var videoEl = document.querySelector("video");
videoEl.setAttribute("controls", "");
var prevRotate = 0;
if (videoEl.style.transform)
prevRotate = parseInt(videoEl.style.transform.split("(")[1].slice(0, -4));
document.body.style.cssText = `
rotate: ${prevRotate + 90}deg;
@mhsattarian
mhsattarian / nextjs_og_custom-font_rotue.tsx
Last active February 3, 2024 20:26
An example of using custom fonts with `next/og` and `nodejs` runtime:
/**
* adopted from: https://stackoverflow.com/a/77146678/5863267
*/
// directory structure for this code was:
// file: /app/(api)/thumb/ellipsis/route.tsx
// font file: /assets/fonts/<font>
import { readFile } from 'node:fs/promises';
import { join } from 'node:path';
@mhsattarian
mhsattarian / Radix-Carousel.tsx
Created February 25, 2024 20:49
A Radix Carousel component styled via PandaCSS
@mhsattarian
mhsattarian / jotai-createJSONStorage.ts
Last active May 1, 2024 20:35
Jotai's createJSONStorage code with few tweaks to support custom subscribe functionality for persist storages
import { AsyncStorage, SyncStorage } from 'jotai/vanilla/utils/atomWithStorage';
type Unsubscribe = () => void;
type Subscribe<Value> = (
key: string,
callback: (value: Value) => void,
initialValue: Value
) => Unsubscribe;