Skip to content

Instantly share code, notes, and snippets.

View amirzenoozi's full-sized avatar
:electron:
Looking For New Project Idea's

Amirhossein Douzandeh Zenoozi amirzenoozi

:electron:
Looking For New Project Idea's
View GitHub Profile
@amirzenoozi
amirzenoozi / analyzer.py
Created December 3, 2022 08:17
Analyze color of the pictures
from collections import Counter
from sklearn.cluster import KMeans
from matplotlib import colors
import matplotlib.pyplot as plt
import numpy as np
import cv2
import os
def preprocess(raw):
image = cv2.resize(raw, (900, 600), interpolation = cv2.INTER_AREA)
@amirzenoozi
amirzenoozi / simple_swagger.json
Created September 24, 2022 10:15
Simple Swagger For Test
{
"openapi": "3.0.0",
"info": {
"title": "My First API",
"version": "0.1"
},
"paths": {
"/": {
"get": {
"description": "Home page",
@amirzenoozi
amirzenoozi / commit-msg
Created July 17, 2022 05:59
Check Commit Message Before Commit Change
#!/bin/sh
# Check This https://regex101.com/r/jkAuu3/1
commit_regex='(((feat|fix|chore|refactor|style|test|docs)(((\w{0,15})))?))(:.\S.*)';
error_msg="Aborting commit. Your commit message format is invalid, please check the references."
commit_message="$1";
if ! grep -iqE "$commit_regex" "$commit_message";
then
echo "$error_msg" >&2
@amirzenoozi
amirzenoozi / pre-commit
Created July 17, 2022 05:55
Check Git Branch Name
#!/usr/bin/env bash
LC_ALL=C
local_branch="$(git rev-parse --abbrev-ref HEAD)"
valid_branch_regex="^(dev|master|(feature|deprecation|bugfix|improvement|library|prerelease|release|hotfix)\/[a-z0-9._-]+$)"
message="There is something wrong with your branch name. Branch names in this project must adhere to this contract: $valid_branch_regex. Your commit will be rejected. You should rename your branch to a valid name and try again."
if [[ ! $local_branch =~ $valid_branch_regex ]]
@amirzenoozi
amirzenoozi / iran_isp_list.py
Created June 12, 2022 13:19
Iranian ISP Companies
from bs4 import BeautifulSoup
import requests
def main():
_BASE_URL_ = 'https://ipinfo.io/countries/ir'
_PAGE_ = requests.get(_BASE_URL_)
_SOUP_ = BeautifulSoup(_PAGE_.content, 'html.parser')
table_row = _SOUP_.select('table tr')
final_dict = []
del table_row[0]
@amirzenoozi
amirzenoozi / virgool-blog-post-workflow.yml
Created October 14, 2021 21:41
GitHub Action To Show Virgool Posts
name: Virgool Blog Posts
on:
schedule:
- cron: '0 19 * * *'
workflow_dispatch:
jobs:
update-readme-with-blog:
name: Update this repo's README with latest my latest posts
@amirzenoozi
amirzenoozi / blog-post-workflow.yml
Last active October 14, 2021 21:22
Medium Post Action Workflow
name: Medium Blog Posts
on:
schedule:
- cron: '0 19 * * *'
workflow_dispatch:
jobs:
update-readme-with-blog:
name: Update this repo's README with latest my latest posts
{
"guid": "{GUID-TOKEN}",
"name": "Windows PowerShell",
"commandline": "powershell.exe",
"fontFace": "MesloLGS NF",
"hidden": false
},
@amirzenoozi
amirzenoozi / webpack.prod.js
Created August 9, 2021 18:37
A Simple Rule to Replace Files During The Build
module.exports = (env = {}) => {
return {
module: {
rules: [
...rules,
{
loader: 'file-replace-loader',
options: {
condition: 'always', // <-- Note that the rule applies for all files!
replacement(resourcePath) {
const express = require('express');
const mongoose = require('mongoose');
const ShortUrl = require('./models/short-url.js');
const validUrl = require('valid-url');
const app = express();
mongoose.connect('mongodb://localhost/urlShortener', {
useNewUrlParser: true,
useUnifiedTopology: true,
})