Skip to content

Instantly share code, notes, and snippets.

@pessom
pessom / storages.py
Last active January 22, 2025 04:50 — forked from KurimuzonAkuma/storages.py
MySQL and SQLite storages for aiogram framework
import pickle
from asyncio import Lock
from typing import Any, Dict, Optional
import aiomysql
import aiosqlite
from aiogram.fsm.state import State
from aiogram.fsm.storage.base import BaseStorage, StateType, StorageKey
@pessom
pessom / doh
Created December 24, 2024 12:12 — forked from M0r13n/doh
Setup Cloudflare as a DoH (DNS over HTTPS) resolver on Mikrotik devices (RouterOS v7.0.2+)
# Temporarily add a normal upstream DNS resolver
/ip dns set servers=1.1.1.1,1.0.0.1
# CA certificates extracted from Mozilla
/tool fetch url=https://curl.se/ca/cacert.pem
# Import the downloaded ca-store (127 certificates)
/certificate import file-name=cacert.pem passphrase=""
# Set the DoH resolver to cloudflare
@pessom
pessom / outbound-email-with-cloudflare.md
Created December 21, 2024 18:19 — forked from irazasyed/outbound-email-with-cloudflare.md
Using Gmail SMTP with Cloudflare Email Routing: A Step-by-Step Guide

Using Gmail SMTP with Cloudflare Email Routing: Step-by-Step Guide

Learn how to send emails through Gmail SMTP with Cloudflare Email Routing in this comprehensive guide.

Step 1: Enable 2-Factor Authentication

To proceed with this method, ensure that you have enabled two-factor authentication for your Google account. If you haven't done so already, you can follow the link to set it up → Enable 2FA in your Google account.

Step 2: Create an App Password for Mail

Connect to WiFi network
WIFI:T:WPA2;S:MyNetworkName;P:ThisIsMyPassword;H:true;
T:WPA2 - Authentication type; can be WEP or WPA, or leave empty for no password.
S:MyNetworkName - Network SSID. Required.
P:ThisIsMyPassword - Password, ignored if T is left blank.
H:true - Optional. True if the network SSID is hidden.
Как быстро и безопасно управлять переменными окружения на macOS с помощью keychain.
По сути там уже все есть, нужно только добавить обертку.
Делаем раз:
tee ~/keychain-env.sh <<'EOF'
function keychain-env-read () {
security find-generic-password -w -a ${USER} -D "environment variable" -s "${1}"
}
function keychain-env-add () {
[ -n "$1" ] || print "Missing environment variable name"
@pessom
pessom / nginx.conf
Last active August 3, 2022 21:21 — forked from nrollr/nginx.conf
NGINX config for SSL with Let's Encrypt certs https://ssl-config.mozilla.org/
# UPDATED 17 February 2019
# Redirect all HTTP traffic to HTTPS
server {
listen 80;
listen [::]:80;
server_name www.domain.com domain.com;
return 301 https://$host$request_uri;
}
# SSL configuration
@pessom
pessom / sshpass build.sh
Last active March 6, 2019 14:52
Install sshpass on os x
curl -O -L https://kent.dl.sourceforge.net/project/sshpass/sshpass/1.06/sshpass-1.06.tar.gz
tar xvzf sshpass-1.06.tar.gz
cd sshpass-1.06/
./configure
make
sudo make install
@pessom
pessom / quick_punycode_encode_decode_example.py
Created March 2, 2018 15:43 — forked from floer32/quick_punycode_encode_decode_example.py
quick example of encoding and decoding a international domain name in Python (from Unicode to Punycode or IDNA codecs and back). Pay attention to the Unicode versus byte strings
# INCORRECT! DON'T DO THIS!
>>> x = "www.Alliancefrançaise.nu" # This is the problematic line. Forgot to make this a Unicode string.
>>> print x
www.Alliancefrançaise.nu
>>> x.encode('punycode')
'www.Alliancefranaise.nu-h1a31e'
>>> x.encode('punycode').decode('punycode')
u'www.Alliancefran\xc3\xa7aise.nu'
>>> print x.encode('punycode').decode('punycode')
www.Alliancefrançaise.nu
@pessom
pessom / check_hash.py
Created February 24, 2018 12:29 — forked from xen/check_hash.py
telegram site auth
# implementation of Telegram site authorization checking algorithm
# for more information https://core.telegram.org/widgets/login#checking-authorization
import collections
import hmac
import hashlib
def check_string(d, token):
secret = hashlib.sha256()
secret.update(token.encode('utf-8'))
@pessom
pessom / example.conf
Created February 13, 2018 09:59
Haproxy to Sentinel powered Redis example conf
global
log /dev/log local0 notice
pidfile /var/run/haproxy.pid
maxconn 4000
user haproxy
group haproxy
daemon
stats socket /var/lib/haproxy/stats
listen mysql-corp 0.0.0.0:3306