Skip to content

Instantly share code, notes, and snippets.

@centum
centum / Documentation.md
Created December 11, 2022 18:44 — forked from KartikTalwar/Documentation.md
Rsync over SSH - (40MB/s over 1GB NICs)

The fastest remote directory rsync over ssh archival I can muster (40MB/s over 1gb NICs)

This creates an archive that does the following:

rsync (Everyone seems to like -z, but it is much slower for me)

  • a: archive mode - rescursive, preserves owner, preserves permissions, preserves modification times, preserves group, copies symlinks as symlinks, preserves device files.
  • H: preserves hard-links
  • A: preserves ACLs
import os
from datetime import datetime
import fitz
IMAGES_DIR = "./"
file_list = [f.path for f in os.scandir(IMAGES_DIR) if f.is_file() and f.path.split(".")[-1] == "jpeg"]
@centum
centum / mk_gif.py
Created October 3, 2022 12:48
Make animated gif from images
from PIL import Image
DURATION = 1000 # ms
im_list = [
Image.open(f)
for f in [
"center.jpeg",
@centum
centum / .bashrc
Created June 20, 2020 19:45
Multiple repositories github deployment ssh keys
# Github deploy keys
export GIT_SSH_COMMAND=~/.ssh/git-keys/repo-ssh-custom-key.sh
export GIT_SSH_COMMAND_DEBUGLOG=~/.ssh/git-keys/repo-ssh-custom-key.log
@centum
centum / custom_keys_git_ssh
Created June 20, 2020 18:52 — forked from vhermecz/custom_keys_git_ssh
Allow configuring multiple ssh deploy keys with git
#!/bin/bash
# Script to use custom ssh keys for various git repositories
# Run without arguments to get usage info.
#
# How it works:
# When used with SSH, git sends the path to the repository in the SSH command.
# @see: https://github.com/git/git/blob/e870325/connect.c#L1268
# We extract this info and search for a key with the name.
# Based on the source, this seems to be used format since v2.0 at least.
# @see: https://github.com/git/git/commit/a2036d7
@centum
centum / commands.sh
Created May 21, 2020 13:16
Kafka commands
# Install Java
brew tap homebrew/cask-versions
brew tap adoptopenjdk/openjdk
brew cask install java
java --version
# Get Kafka
wget https://www2.apache.paket.ua/kafka/2.5.0/kafka_2.12-2.5.0.tgz
# Unpack

Kafka 0.11.0.0 (Confluent 3.3.0) added support to manipulate offsets for a consumer group via cli kafka-consumer-groups command.

  1. List the topics to which the group is subscribed
kafka-consumer-groups --bootstrap-server <kafkahost:port> --group <group_id> --describe

Note the values under "CURRENT-OFFSET" and "LOG-END-OFFSET". "CURRENT-OFFSET" is the offset where this consumer group is currently at in each of the partitions.

  1. Reset the consumer offset for a topic (preview)
@centum
centum / sign.py
Last active March 4, 2020 09:18
Make sign data by MD5
from hashlib import md5
def sign(status, addr, value, txid, apiKey):
return md5("{}{}{}{}{}".format(status, addr, value, txid, apiKey)).hexdigest()
if __name__ == "__main__":
print(sign(
2,
@centum
centum / tokens.md
Created December 4, 2019 08:52 — forked from zmts/tokens.md
Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

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

Last major update: 21.10.2019

Основы:

Аутентификация(authentication, от греч. αὐθεντικός [authentikos] – реальный, подлинный; от αὐθέντης [authentes] – автор) - это процесс проверки учётных данных пользователя (логин/пароль). Проверка подлинности пользователя путём сравнения введённого им логина/пароля с данными сохранёнными в базе данных.

Авторизация(authorization — разрешение, уполномочивание) - это проверка прав пользователя на доступ к определенным ресурсам.

Например после аутентификации юзер sasha получает право обращатся и получать от ресурса "super.com/vip" некие данные. Во время обращения юзера sasha к ресурсу vip система авторизации проверит имеет ли право юзер обращатся к этому ресурсу (проще говоря переходить по неким разрешенным ссылкам)

@centum
centum / docker-sentry.sh
Created April 9, 2019 14:48
Start sentry by docker image
#!/bin/bash
set -e
IMG=${SENTRY_IMAGE:-'sentry:9.0'}
if [ "${1:0:1}" = '-' ] || [ "$1" = "" ]; then
CMD="uwsgi"
ARGS=$@