Skip to content

Instantly share code, notes, and snippets.

View mkatychev's full-sized avatar
💭
Убейся в праздники! Раб, твои галеры в огне

Mikhail Katychev mkatychev

💭
Убейся в праздники! Раб, твои галеры в огне
View GitHub Profile
@mkatychev
mkatychev / stream_cancel.rs
Last active April 12, 2024 02:04
Cancellable stream draft
use std::{future::Future, time::Duration};
use bigerror::{LogError, NetworkError, OptionReport, Report, ReportAs, ResultExt};
use futures::{future, pin_mut};
use stream_cancel::TakeUntilIf;
use tokio::{
sync::mpsc::{UnboundedSender, WeakUnboundedSender},
task::JoinHandle,
};
use tokio_stream::wrappers::UnboundedReceiverStream;
@mkatychev
mkatychev / ffmpeg_concat_and_scale.sh
Last active March 22, 2024 18:57
Concatenate and convert differently sized videos into one
#!/usr/bin/env bash
join_files() {
local input_n=()
local scale_to_n=("$SEP")
local concat_n=()
for i in $(seq $#); do
input_n+=("-i ${!i}")
((n = i - 1))
@mkatychev
mkatychev / github_default.md
Created February 8, 2024 16:53
Default GITHUB actions variables quickref

Quickref

Variable Description Example
CI Always set to true
GITHUB_ACTION The name of the action currently running
GITHUB_ACTION_PATH The path where an action is located, only supported in composite actions. /home/runner/work/_actions/repo-owner/name-of-action-repo/v1
GITHUB_ACTION_REPOSITORY The owner and repository name of the action. actions/checkout
GITHUB_ACTIONS Always set to true when GitHub Actions is running the workflow.
GITHUB_ACTOR The name of the person or app that initiated the workflow. octocat
{
"$comment": "https://help.github.com/en/github/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions",
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"definitions": {
"architecture": {
"type": "string",
"enum": [
"ARM32",
"x64",
@mkatychev
mkatychev / README.md
Created June 29, 2023 13:59 — forked from tombigel/README.md
How to Change Open Files Limit on OS X and macOS Sierra (10.8 - 10.12)

How to Change Open Files Limit on OS X and macOS

This text is the section about OS X Yosemite (which also works for macOS Sierra) from https://docs.basho.com/riak/kv/2.1.4/using/performance/open-files-limit/#mac-os-x

The last time i visited this link it was dead (403), so I cloned it here from the latest snapshot in Archive.org's Wayback Machine https://web.archive.org/web/20170523131633/https://docs.basho.com/riak/kv/2.1.4/using/performance/open-files-limit/

Mac OS X

To check the current limits on your Mac OS X system, run:

@mkatychev
mkatychev / zipper_rust.md
Last active April 7, 2023 18:00
Zipper Rust

State Storage using Zipper

The Data structure used to store various states uses a cursor to traverse the nodes known as the Zipper technique.

Example of a Zipper cursor traversing a Vector, the focus provides a view "Up" and "Down" the data:

[1, 2, 3, 4, 5] // array with 5 entries
 1}[2, 3, 4, 5] // zipper starts with focues at first index
#[macro_export]
macro_rules! from_report {
(impl From<$from:path as $context:path> for $for:ident::$variant:ident) => {
impl From<$from> for $for {
fn from(e: $from) -> Self {
Self::$variant(error_stack::Report::new(e).change_context($context))
}
}
};
(impl From<$from:path> for $for:ident::$variant:ident) => {
@mkatychev
mkatychev / mermaid.md
Last active October 28, 2022 22:35
mermaid.md

Figure 1

%%{init: {
    "fontFamily": "Times New Roman",
    'logLevel': 'debug',
    'sequence': { 
        'noteFont': 100,
        'noteMargin': 100,
 'messageFont': 100,
@mkatychev
mkatychev / as.rs
Created July 26, 2022 16:23
As conversion example
use std::mem::transmute;
fn main() {
let num: u32 = u32::MAX;
println!("u32: {num}");
println!("u16: {}", num as u16);
println!("i32: {}", num as i32);
println!("f32: {}", num as f32);
let bytes_u32: [u8; 4] = unsafe { transmute(num.to_be()) };
let bytes_u16: [u8; 2] = unsafe { transmute((num as u16).to_be()) };
let bytes_i32: [u8; 4] = unsafe { transmute((num as i32).to_be()) };
@mkatychev
mkatychev / notes.sh
Created June 19, 2022 21:22
Golang notes
# golang manual
tldr go
# vscode
tldr code
# open vscode in current terminal directory
code .
# winget
tldr winget
# winget website:
echo "https://winget.run/"