Skip to content

Instantly share code, notes, and snippets.

View alekssamos's full-sized avatar
🎯
Focusing

alekssamos

🎯
Focusing
View GitHub Profile
@alekssamos
alekssamos / README.MD
Last active September 21, 2026 12:04
foreign IP addresses

Раздельное тунелирование для amnezia (актуально для России).

Здесь собраны большинство крупных иностранных сетей.

Открываем клиентский конфиг, что мы добавляем на конечные устройства (Компьютер, телевизор, смартфон)

Находим параметр AllowedIPs и вместо 0.0.0.0/0 в одну строку (без символов crlf) всовываем всё из этого файла.

Маски намеренно /16, даже если это чуть неправильно с точки зрения владения адресами этих сервисов, так проще было "забивать".

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/dnephin/pre-commit-golang
rev: v0.5.0
@alekssamos
alekssamos / SqliteStore.php
Last active September 22, 2024 11:17 — forked from erikeldridge/SqliteStore.php
a simple key/val store using php & sqlite3
<?php
// a simple key/val store using php & sqlite3
// license: http://gist.github.com/375593
// edited by alekssamos
/* Added multithreading: https://habr.com/ru/articles/204438/ */
class SqliteStore {
protected $db;
public function __construct($tableName, $filePath = 'db.sqlite') {
@alekssamos
alekssamos / arch.md
Created February 24, 2024 10:57 — forked from zfarbp/arch.md
Golang - Building Executables for Different Architectures

Golang - Building Executables for Different Architectures

env GOOS=target-OS GOARCH=target-architecture go build package-import-path

# Example
env GOOS=darwin GOARCH=amd64 go build
env GOOS=darwin GOARCH=amd64 go build main.go
env GOOS=darwin GOARCH=amd64 go build github.com/zoo/york/foo/bar
@alekssamos
alekssamos / asyncio_loop_in_thread.py
Created February 23, 2024 09:41 — forked from dmfigol/asyncio_loop_in_thread.py
Python asyncio event loop in a separate thread
"""
This gist shows how to run asyncio loop in a separate thread.
It could be useful if you want to mix sync and async code together.
Python 3.7+
"""
import asyncio
from datetime import datetime
from threading import Thread
from typing import Tuple, List, Iterable
@alekssamos
alekssamos / profileit.py
Created November 14, 2023 16:31 — forked from un33k/profileit.py
Performance Profile Decorator (function wrapper based on cProfile). Decorate any function to profile it.
import cProfile
def profileit(func):
"""
Decorator (function wrapper) that profiles a single function
@profileit()
def func1(...)
# do something
pass
@alekssamos
alekssamos / tqdm_pool.py
Created November 10, 2023 16:34 — forked from alexeygrigorev/tqdm_pool.py
Track progress of ProcessPoolExecutor with tqdm
from glob import glob
import multiprocessing
from concurrent.futures import ProcessPoolExecutor
import cv2
from PIL import Image
import imagehash
from tqdm import tqdm
@alekssamos
alekssamos / kali_sound.sh
Created July 27, 2021 16:43
Fix sound Kali linux
#!/bin/bash
## http://helpexe.ru/programmirovanie/kak-vkljuchit-zvuk-v-kali-linux
# Check the script is being run by root
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root"
exit 1
fi
@alekssamos
alekssamos / Cargo.toml
Created May 24, 2023 15:44 — forked from CoolOppo/Cargo.toml
How to compile to a DLL in rust while using it as a normal rust library
[package]
name = "test"
version = "0.1.0"
authors = ["YOU <YOU@users.noreply.github.com>"]
edition = "2018"
[lib]
crate-type = ["cdylib"]
@alekssamos
alekssamos / telegram_callback_data_example.php
Created March 8, 2020 23:37
Telegram inlinekeyboardbutton callback_data query example
/* https://ru.stackoverflow.com/q/557656 */
/* Теперь понятно, как работает callback-data */
<?php
$access_token = 'xxx';
$api = 'https://api.telegram.org/bot' . $access_token;
$output = json_decode(file_get_contents('php://input'), TRUE);
$chat_id = $output['message']['chat']['id'];
$message = $output['message']['text'];
$callback_query = $output['callback_query'];
$data = $callback_query['data'];