Skip to content

Instantly share code, notes, and snippets.

@AliAlmasi
AliAlmasi / conventional-commits.md
Created January 7, 2026 17:27 — forked from Zekfad/conventional-commits.md
Conventional Commits Cheatsheet

Quick examples

  • feat: new feature
  • fix(scope): bug in scope
  • feat!: breaking change / feat(scope)!: rework API
  • chore(deps): update dependencies

Commit types

  • build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
  • ci: Changes to CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
  • chore: Changes which doesn't change source code or tests e.g. changes to the build process, auxiliary tools, libraries
function goUp(){
let parts = window.location.pathname.split('/').filter(Boolean);
parts.pop();
let newPath = '/' + parts.join('/');
window.location.href = newPath || '/';
}
// goUp() will take you one level up.
@AliAlmasi
AliAlmasi / win11ContextMenu.py
Created March 15, 2025 16:21
Change Windows 11 context menu style (legacy style and Fluent UI style)
import time, os, sys
from sty import fg, ef, rs # pip install sty
def typing(str):
for char in str:
time.sleep(0.05)
sys.stdout.write(char)
sys.stdout.flush()
print("\n")
# USAGE: python visual_cryptography.py file_to_encrypt.png
# $ pip install Pillow
from PIL import Image, ImageDraw
import os, sys
from random import SystemRandom
random = SystemRandom()
# If you want to use the more powerful PyCrypto ($ pip install pycrypto) then uncomment the next line and comment out the previous two lines
@AliAlmasi
AliAlmasi / newtab.js
Created August 12, 2024 23:33
A good way to navigate the user to a new tab (without using `location.replace` or `window.open`) in JS
function newtab(href) {
let a = document.createElement("a");
a.href = href;
a.setAttribute("target", "_blank");
a.click();
a.remove();
}
// You can use it like this:
document.querySelector("span").addEventListener("click", () => newtab("http://al1almasi.ir"));
@AliAlmasi
AliAlmasi / str_reverse.js
Last active October 24, 2024 21:45
Reverse a string in JS & PHP using this `str_reverse()` function
const readline = require("node:readline");
const input = readline.createInterface({
input: process.stdin,
output: process.stdout
});
const str_reverse = (string) => {
let reverse = "";
for (let index = string.length; index > 0; index--)
@AliAlmasi
AliAlmasi / NegativeIndex.js
Last active October 24, 2024 21:47
A simple function to help you access array values from the end. Source: https://stackoverflow.com/a/64296726
const nIndex = (array, nIndex) => array.slice(nIndex)[0];
// Example:
const arr = [1,2,3,5,7,9];
console.log(nIndex(arr, -2)); // output: 7
console.log(nIndex(arr, -4)); // output: 3
@AliAlmasi
AliAlmasi / FormMove.cs
Last active June 23, 2024 17:46
Makes a Windows Form Application program movable when user drags any part of the form.
namespace WindowsFormApplication1 {
public partial class Form1: Form {
public Form1() {
InitializeComponent();
}
public const int WM_NCLBUTTONDOWN = 0xA1;
public const int HT_CAPTION = 0x2;
[System.Runtime.InteropServices.DllImport("user32.dll")]
@AliAlmasi
AliAlmasi / IrIdNumberCheck.js
Created June 17, 2024 15:49
Iranian ID number checker, implemented with JS
function IrIdCheck(code) {
var L = code.length;
if (L < 8 || parseInt(code, 10) === 0) return false;
code = ('0000' + code).substr(L + 4 - 10);
if (parseInt(code.substr(3, 6), 10) === 0) return false;
int c = parseInt(code.substr(9, 1), 10);
int s = 0;
for (int i = 0; i < 9; i++)
s += parseInt(code.substr(i, 1), 10) * (10 - i);
s = s % 11;
@AliAlmasi
AliAlmasi / PersianDate.js
Created December 15, 2023 23:00
A better way to use Persian Calendar in JS.
class PersianDate extends Date {
constructor(...args) {
super(...args);
}
toLocaleDateString = () => super.toLocaleDateString("fa-IR-u-nu-latn");
getParts = () => this.toLocaleDateString().split("/");
getDay = () => (super.getDay() === 6 ? 0 : super.getDay() + 1);
getDate = () => this.getParts()[2];
getMonth = () => this.getParts()[1] - 1;