Skip to content

Instantly share code, notes, and snippets.


Mohammad H. Sattarian mhsattarian

View GitHub Profile
mhsattarian / version.mjs
Last active Jul 25, 2022
Use current Jalali Date as NPM package version. run with zx.
View version.mjs
#!/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`
const date = new Date();
View shatel-regions-clean-simplified.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
mhsattarian /
Created Feb 3, 2022
Format video for telegram's video stickers (WEBM + VP9 + transparent layer + scale)
ffmpeg -i video.mp4 -c:v vp9 -pix_fmt yuva420p -b:v 1M -vf "fps=30,scale=512:-1" -an video.webm
mhsattarian / tippy-textContent.js
Created Jan 16, 2022
Tippyjs plugin to use `textContent` of the child as content.
View tippy-textContent.js
import type { Props, Plugin, LifecycleHooks } from 'tippy.js';
// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface CustomProps {}
type FilteredProps = CustomProps &
Omit<Props, keyof CustomProps | keyof LifecycleHooks>;
type ExtendedProps = FilteredProps & LifecycleHooks<FilteredProps>;
mhsattarian /
Last active Jan 14, 2022
Postgres + WSL connection error

check which port postgres is working on:

# check the log
tail /var/log/postgresql/postgresql-14-main.log 

# or check the cluster list
mhsattarian / node-git-blame.js
Created Dec 25, 2021
Get a file [git] contributors (blame) using node-git
View node-git-blame.js
const git = require('nodegit');
const pathToRepo = require("path").resolve("./.git");
const uniqBy = require('../../utils').uniqBy
let $repo = null;
/** Blame last file change | using commit id */
async function blameLast_old(filePath, callback) {
const repo = $repo ? $repo : await;
const blame = await git.Blame.file(repo, filePath.slice(2));
mhsattarian / tooltip-floating-ui.js
Created Dec 25, 2021
A simple tooltip implementation using floating-ui lib
View tooltip-floating-ui.js
// import $ from '';
import { computePosition, offset } from '';
const tooltip = document.createElement('div'); = 'tooltip';
tooltip.setAttribute('role', 'tooltip');
const tooltipArrow = document.createElement('div'); = 'arrow';
mhsattarian /
Last active Dec 18, 2021
Install php 5.6 and composer in ubuntu +18.04 (also WSL2)
# install php5.6
sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install php5.6
php --version
# install required php plugins
sudo apt install php5.6-curl php5.6-xml php5.6-mbstring
mhsattarian / wsl2-port-forward.ps1
Created Oct 24, 2021
WSL2 Port Forwarding using `netsh`.
View wsl2-port-forward.ps1
# credits:
# 1.
# 2.
If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
$arguments = "& '" + $myinvocation.mycommand.definition + "'"
Start-Process powershell -Verb runAs -ArgumentList $arguments
View 01_simple-RNN-0.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.