Skip to content

Instantly share code, notes, and snippets.

View MasterGroosha's full-sized avatar

Aleksandr MasterGroosha

View GitHub Profile
from itertools import product
from typing import List, Tuple
def __find_neighbours(x: int, y: int, size: int) -> List[Tuple]:
"""
Finds neighbours for a cell. Those which fall out of the field are skipped
:param x: current cell's X coord
:param y: current cell's Y coord
:param size: field single dimension size (because field is square)
@stek29
stek29 / tdget.py
Last active October 31, 2018 21:43
TDesktop link generator
from Crypto.Hash import SHA
from Crypto.Signature import PKCS1_v1_5
from Crypto.PublicKey import RSA
from base64 import urlsafe_b64encode
from requests import get
def get_version_signature(version, private_key):
signed_data = b'TelegramBeta_%x'%int(version)
@udkyo
udkyo / Dockerfile
Last active May 1, 2024 12:51
Basic container for X11 forwarding goodness
FROM ubuntu
RUN apt update \
&& apt install -y firefox \
openssh-server \
xauth \
&& mkdir /var/run/sshd \
&& mkdir /root/.ssh \
&& chmod 700 /root/.ssh \
&& ssh-keygen -A \
&& sed -i "s/^.*PasswordAuthentication.*$/PasswordAuthentication no/" /etc/ssh/sshd_config \
@JrooTJunior
JrooTJunior / check_hash.py
Last active February 14, 2024 07:53 — 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(data, token):
secret = hashlib.sha256()
secret.update(token.encode('utf-8'))
@mes01
mes01 / LC_CTYPE.txt
Created October 31, 2017 16:27 — forked from thanksdanny/LC_CTYPE.txt
Centos warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory
vi /etc/environment
add these lines...
LANG=en_US.utf-8
LC_ALL=en_US.utf-8
@stek29
stek29 / langpacker.py
Last active March 9, 2021 12:14
Get TG langpack with Telethon
from telethon.tl.functions import InitConnectionRequest, InvokeWithLayerRequest
from telethon.tl.functions import langpack # GetLangPackRequest, GetDifference
from telethon.tl import all_tlobjects # for LAYER
from telethon.tl.types import LangPackString, LangPackStringPluralized, LangPackStringDeleted
from telethon.tl.functions import InitConnectionRequest, InvokeWithLayerRequest
from telethon.tl.functions import langpack # GetLangPackRequest, GetDifference
from telethon.tl import all_tlobjects
from telethon.tl.types import LangPackString, LangPackStringPluralized, LangPackStringDeleted
@zmts
zmts / tokens.md
Last active May 24, 2024 12:25
Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Last major update: 25.08.2020

  • Что такое авторизация/аутентификация
  • Где хранить токены
  • Как ставить куки ?
  • Процесс логина
  • Процесс рефреш токенов
  • Кража токенов/Механизм контроля токенов
@fntlnz
fntlnz / self-signed-certificate-with-custom-ca.md
Last active May 17, 2024 07:59
Self Signed Certificate with Custom Root CA

Create Root CA (Done once)

Create Root Key

Attention: this is the key used to sign the certificate requests, anyone holding this can sign certificates on your behalf. So keep it in a safe place!

openssl genrsa -des3 -out rootCA.key 4096
@alexey-milovidov
alexey-milovidov / nested.txt
Created June 17, 2016 21:15
Example of Nested data type in ClickHouse.
:) CREATE TABLE test.nested (EventDate Date, UserID UInt64, Attrs Nested(Key String, Value String)) ENGINE = MergeTree(EventDate, UserID, 8192)
CREATE TABLE test.nested
(
EventDate Date,
UserID UInt64,
Attrs Nested(
Key String,
Value String)
) ENGINE = MergeTree(EventDate, UserID, 8192)
@ertseyhan
ertseyhan / remount.sh
Created February 2, 2016 20:51
Temporarily increase size of tmp folder on Arch linux
#!/bin/bash
sudo mount -o remount,size=10G,noatime /tmp
echo "Done. Please use 'df -h' to make sure folder size is increased."