Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Mohammad H. Sattarian mhsattarian

🎯
Focusing
View GitHub Profile
@mhsattarian
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`
).stdout.trim();
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
mhsattarian / video2webm.sh
Created Feb 3, 2022
Format video for telegram's video stickers (WEBM + VP9 + transparent layer + scale)
View video2webm.sh
ffmpeg -i video.mp4 -c:v vp9 -pix_fmt yuva420p -b:v 1M -vf "fps=30,scale=512:-1" -an video.webm
@mhsattarian
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
mhsattarian / pg-wsl.md
Last active Jan 14, 2022
Postgres + WSL connection error
View pg-wsl.md

check which port postgres is working on:

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

# or check the cluster list
pg_lsclusters
@mhsattarian
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 git.Repository.open(pathToRepo);
const blame = await git.Blame.file(repo, filePath.slice(2));
@mhsattarian
mhsattarian / tooltip-floating-ui.js
Created Dec 25, 2021
A simple tooltip implementation using floating-ui lib
View tooltip-floating-ui.js
// import $ from 'https://cdn.skypack.dev/cash-dom';
import { computePosition, offset } from 'https://cdn.skypack.dev/@floating-ui/dom@0.1.7';
const tooltip = document.createElement('div');
tooltip.id = 'tooltip';
tooltip.setAttribute('role', 'tooltip');
const tooltipArrow = document.createElement('div');
tooltipArrow.id = 'arrow';
@mhsattarian
mhsattarian / install-php5.6-ubuntu.sh
Last active Dec 18, 2021
Install php 5.6 and composer in ubuntu +18.04 (also WSL2)
View install-php5.6-ubuntu.sh
# 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
mhsattarian / wsl2-port-forward.ps1
Created Oct 24, 2021
WSL2 Port Forwarding using `netsh`.
View wsl2-port-forward.ps1
# credits:
# 1. https://github.com/microsoft/WSL/issues/4150#issuecomment-504209723
# 2. https://dev.to/vishnumohanrk/wsl-port-forwarding-2e22
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
Break
}
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.