Skip to content

Instantly share code, notes, and snippets.

@mirhmousavi
mirhmousavi / Iran Provinces and Cities in English
Last active July 9, 2018 09:25
Iran Provinces and Cities in English
Provinces = {
"آذربایجان شرقى": "Eastern Azarbayjan",
"آذرباىجان غربى": "Western Azarbayjan",
"اردبیل": "Ardebil",
"اصفهان": "Isfahan",
"البرز": "Alborz",
"ایلام": "Ilam",
"بوشهر": "Bousher",
"تهران": "Tehran",
"چهارمحال و بختیارى": "Chahar Mahal o Bakhtiari",
@mirhmousavi
mirhmousavi / cowsay all animals
Last active July 11, 2018 19:39
a sample of all animals available in output of `cowsay -l`
################################
apt
################################
________________
< hello dear >
----------------
\ (__)
(oo)
/------\/
/ | ||
209.244.0.3
209.244.0.4
64.6.64.6
64.6.65.6
8.8.8.8
8.8.4.4
9.9.9.9
149.112.112.112
84.200.69.80
84.200.70.40
#! /bin/bash
set -o nounset
set -o errexit
sanitize () {
sed 's/[^[:print:]]//g' | xargs
}
error_no=$(mysql -uroot -proot --database smcli --execute 'show slave status\G' | grep 'Last_SQL_Errno:' | awk -F: '{print $2}' | sanitize)
@mirhmousavi
mirhmousavi / iranian_national_code_validator.py
Last active August 18, 2020 05:57
Iranian National Code Validator
def check(code):
"""This is the python version of the javascript function from `https://www.samanese.ir/checknin`
for validating iranian national code
function validateNIN(snin) {
// if string nin length is less than 10 character
if (snin.length < 10) {
// wrong nin
return false;