Skip to content

Instantly share code, notes, and snippets.

View sokil's full-sized avatar
🇺🇦
sapere aude

sokil

🇺🇦
sapere aude
View GitHub Profile
@sokil
sokil / README.md
Last active February 24, 2024 11:08
BetaFlight

Compile

Compile locally

make arm_sdk_install

Compile using Docker

@sokil
sokil / NginxUnitControl Api.sh
Last active February 24, 2024 11:00
Nginx Unit Control Api
# Set new
curl -XPUT --unix-socket /var/run/control.unit.sock http://localhost/config/applications/app/processes -d 100
# Read current
curl --unix-socket /var/run/control.unit.sock http://localhost/config/applications/app/processes
@sokil
sokil / intelijIdeaJwtHelper.js
Created April 7, 2023 16:44
IntelliJ IDEA Http Client helpers
/**
* Used with JetBrains HTTP Client on OAuth authenticate requests to log unpacked fetched OAuth2 access token and its details
*
* @see https://gitlab.auroraglobal.com/maverix/jetbrains-toolkit
*/
function atob(data) {
if (arguments.length === 0) {
throw new TypeError("1 argument required, but only 0 present.");
}
data = `${data}`;
@sokil
sokil / RootingAndFlashingAndroidTablets.md
Last active April 22, 2023 10:51
Rooting and Flashing Android Tablets

Rooting and Flashing Android Tablets

Glossary

  • PIT-file: file with partitions
  • ADB Sideload: the command that allows you to transfer the Android system installation file (it is always a .zip file) and install it directly on the phone, from the PC.

Flashing TWRP

  1. Install flasher:
@sokil
sokil / KAfka_to_Clickhouse.md
Last active March 13, 2023 10:11
Kafka Connect

ClickHouse

Events from Kafka topic may be consumed by ClickHouse and stored. This may be useful for making projections from events.

ClickHouse's nodes must be added to cluster to use ReplicatedMergeTree.

First, create database my_db.

ClickHouse cluster

@sokil
sokil / jwt_unpack.sh
Last active July 27, 2022 18:51
Unpack JWY in Bash
curl -XPOST -H 'Content-Type: application/x-www-form-urlencoded' \
http://localhost:8080/auth/realms/{realm}/protocol/openid-connect/token \
-d 'grant_type=client_credentials&client_id={client}&client_secret={sectet}' \
2>/dev/null | jq '.access_token | split(".") | .[0],.[1] | @base64d | fromjson'
@sokil
sokil / session.php
Created May 2, 2022 20:13
php session serializer
<?php
function sessionDataUnserialize($serializedData) {
$return_data = array();
$offset = 0;
while ($offset < strlen($serializedData)) {
if (!strstr(substr($serializedData, $offset), "|")) {
throw new Exception("invalid data, remaining: " . substr($serializedData, $offset));
}
@sokil
sokil / desc.md
Created April 3, 2022 11:17
Python pickle code execution
  • c: Read to the newline as the module name, module. Read the next line as the object name, object. Push module.object onto the stack.
  • (: Insert a marker object onto the stack. For our purpose, this is paired with t to produce a tuple.
  • t: Pop objects off the stack until a ( is popped and create a tuple object containing the objects popped (except for the () in the order they were /pushed/ onto the stack. The tuple is pushed onto the stack
  • S: Read the string in quotes up to the newline and push it onto the stack.
  • R: Pop a tuple and a callable off the stack and call the callable with the tuple as arguments. Push the result onto the stack.
  • .: End of the pickle.
@sokil
sokil / aes.php
Last active January 12, 2022 07:40
PHP And Python Compatible OpenSSL AES Encoding and decoding
<?php
$passphrase = 'some-passphrase';
$text = 'Hello world!';
$method = 'AES-256-CBC';
// passphrase
$passphrase = hash('sha256', $passphrase, true);
@sokil
sokil / pem.sh
Last active June 28, 2021 08:54
PEM generation
# create private key with passphrase
openssl genrsa -out config/jwt/private.pem -aes256 4096
# Write public key
openssl rsa -pubout -in private.pem -out public.pem