Skip to content

Instantly share code, notes, and snippets.

View mahdyar's full-sized avatar
🌱

Mahdyar Hasanpour mahdyar

🌱
View GitHub Profile
@mahdyar
mahdyar / TODO.SH
Created April 25, 2019 20:53
Simple TODO-List Manager
#!/bin/sh
TODO=~/.TODO
# The Path of The TODO-List
alias clt="rm -rf $TODO" # For make the List empty.
alias adt="echo '#'$1 >> $TODO" # For add an Item to the List.
# Displaying the List..
if test -f "$TODO";then
@mahdyar
mahdyar / ir-whois.go
Last active January 30, 2021 21:21
Whois lookup script written in Golang for .ir domains
package main
import (
"fmt"
"net"
)
/*************************************************************************
@mahdyar
mahdyar / keybase.md
Created August 28, 2020 10:57
keybase.md

Keybase proof

I hereby claim:

  • I am mahdyar on github.
  • I am mahdyar (https://keybase.io/mahdyar) on keybase.
  • I have a public key whose fingerprint is 0C45 1EE6 1812 7F21 271C 77ED 15DF CA00 8893 751D

To claim this, I am signing this object:

@mahdyar
mahdyar / whichiswhich.sh
Last active March 1, 2021 14:46
Detect which apps are running under Rosetta2 or native on Apple Silicon M1.
for appFolder in /Applications/*/ ; do
cd "$appFolder/Contents/MacOS/" 2> /dev/null
if [[ "$?" != 0 ]]; then continue; fi
for file in * ; do
if [ ! -d "$file" ] && [[ $file != *"."* ]]; then
architecture=$(file "$file")
if [[ $architecture != *"arm64"* ]]; then
echo "\"$file\" doesn't support arm64."
addEventListener("fetch", (event) => {
event.respondWith(handleRequest(event));
});
let data = {
ok: false,
};
async function handleRequest(event) {
if (event.request.method == "POST") {
let body = await event.request.json();
if (body.url && body.title && body.telemark_code) {
@mahdyar
mahdyar / AllowedUsername.php
Last active April 18, 2021 20:53
Prevent your users to register with your route paths like login, or reserved usernames as their usernames in Laravel. More: https://blog.mahdyar.me/2021/04/18/route-paths-and-reserved-usernames-in-laravel/
<?php
namespace App\Rules;
use Illuminate\Contracts\Validation\Rule;
use Illuminate\Support\Facades\Route;
class AllowedUsername implements Rule
{
/**
@mahdyar
mahdyar / awesome-dark-theme-switch.markdown
Created May 11, 2021 09:28
Awesome Dark theme switch
@mahdyar
mahdyar / verify-github-webhook.php
Created August 13, 2021 10:09
Verify GitHub webhook request sha256 in PHP
<?php
// It's better to be exported as an environment variable or in a .env file.
define("SECRET", "<SECRET>");
$body = file_get_contents("php://input");
// $decodedBody = json_decode(urldecode($body));
if (verifySignature($body) !== false) {
// verified
@mahdyar
mahdyar / persian-first-names.txt
Last active April 9, 2024 11:25
A list of common Persian/ Iranian first names in English
aaxar
abadaleh
abazar
abbas
abbasali
abbasi
abdolali
abdolamir
abdolghani
abdolhamid
wir(){
NAME=$(sed 's/ /_/g' <<< "$@")
INITIAL=$(echo $NAME | head -c 1)
IMDB_ID=$(curl -ks "https://v2.sg.media-imdb.com/suggestion/$INITIAL/$NAME.json" | jq -r '.d[0].id')
LINK="https://wir31.site/${IMDB_ID}/"
curl -ks "$LINK" | lynx -dump -nonumbers -listonly -stdin | grep -e '.mkv' -e '.mp4' | grep 'http://'
}