Skip to content

Instantly share code, notes, and snippets.

View parsapoorsh's full-sized avatar
🍊
Hey there! I am using GitHub

Parsa parsapoorsh

🍊
Hey there! I am using GitHub
View GitHub Profile
@parsapoorsh
parsapoorsh / ufw-cloudflare.sh
Last active May 25, 2024 03:11
a bash script to create ufw rules for Cloudflare on port 80 and 433
#!/bin/bash
if [ "$1" == "insert" ]; then
for cfip in `curl -sw '\n' https://www.cloudflare.com/ips-v{4,6}`;
do
ufw allow proto tcp from $cfip to any port 80,443 comment 'Cloudflare';
done
echo $0 'Inserted'
elif [ "$1" == "delete" ]; then
while ufw status numbered | grep -q 'Cloudflare';
@parsapoorsh
parsapoorsh / mdb2sql.sh
Last active June 1, 2022 12:32 — forked from turicas/mdb2sql.sh
Convert a MDB (Access) file to SQL
#!/bin/bash
# Convert a MDB file (Access) to SQL
# Needs mdbtools[http://mdbtools.sourceforge.net/]
# run 'aptitude install mdbtools' on Debian/Ubuntu
# Created by Álvaro Justen <https://github.com/turicas>
# License: GPLv2
mdb=$1
sql=$2
@parsapoorsh
parsapoorsh / syncer.py
Last active March 17, 2022 18:22
async to sync and sync to async script.
import asyncio, inspect, threading
from concurrent.futures import ThreadPoolExecutor
from functools import wraps
def async_to_sync(function):
main_loop = asyncio.get_event_loop()
def async_to_sync_gen(agen, loop, is_main_thread):
async def anext(agen):
try: