Skip to content

Instantly share code, notes, and snippets.

View divi255's full-sized avatar

Sergiy S. divi255

View GitHub Profile
@divi255
divi255 / main.rs
Last active November 14, 2022 01:45
RPC call tracing with Rust+Tokio
// Full article: https://medium.com/@disserman/api-call-tracing-in-high-loaded-asynchronous-rust-applications-bc7b126eb470
//
// Cargo.toml:
// [package]
// name = "rct"
// version = "0.1.0"
// edition = "2021"
//
// [dependencies]
// hyper = { version = "0.14.23", features = ["server", "tcp", "http1"] }
@divi255
divi255 / hash.rs
Created December 5, 2022 02:23
hash calc by ChatGPT (FIPS-140 compliant)
extern crate clap;
extern crate openssl;
use clap::{App, Arg};
use openssl::hash::{Hasher, MessageDigest};
use std::error::Error;
use std::fs::File;
use std::io::{BufReader, Read};
fn main() -> Result<(), Box<Error>> {
@divi255
divi255 / build.rs
Created June 1, 2023 16:39
Use cargo metadata to deny build if some dependency crate feature has been enabled
use cargo_metadata::{CargoOpt, MetadataCommand};
use std::path::Path;
fn main() {
let mut manifest = Path::new(&std::env::var("CARGO_MANIFEST_DIR").unwrap()).to_owned();
manifest.push("Cargo.toml");
let metadata = MetadataCommand::new()
.manifest_path(manifest)
.features(CargoOpt::AllFeatures)
.exec()
@divi255
divi255 / download_csv.tsx
Created February 7, 2024 22:38
Download CSV from useEvaStateHistory hook
import { useMemo } from "react";
import {
get_engine,
useEvaStateHistory,
generateStateHistoryCSV,
StateHistoryOIDColMapping
} from "@eva-ics/webengine-react";
import { Eva, StateProp } from "@eva-ics/webengine";
import { Timestamp } from "bmat/time";
import { downloadCSV } from "bmat/dom";
@divi255
divi255 / ttt.py
Last active February 11, 2024 03:42
tags to tree Python
from bma_benchmark import benchmark
def tags_to_tree(tags):
def fill_tags_tree_recursive(tag, tree):
ch = tag.split('.', maxsplit=1)
if len(ch) == 1:
tree[tag] = {}
else:
@divi255
divi255 / ttt.rs
Last active February 11, 2024 03:56
tags to tree Rust
use std::collections::BTreeMap;
#[macro_use]
extern crate bma_benchmark;
// here Arc<String> is wanted to be used but for small depth Arc provides additional overhead and
// results are lower
#[derive(Default)]
struct Tree(BTreeMap<String, Tree>);