Skip to content

Instantly share code, notes, and snippets.

@kuvaldini
kuvaldini / ProfiledScope.hpp
Created February 20, 2024 19:06
Profiler for C++ tracks time consumption in scope {}
#pragma once
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <chrono>
#include <cstdio>
#include <unistd.h>
@kuvaldini
kuvaldini / git-nlx
Created August 10, 2022 16:18
Git extended log
#!/usr/bin/env bash
set -euo pipefail
var_is_unset(){
declare -rn var=$1
test -z ${var+x}
}
while test $# -gt 0 ;do
case $1 in
@kuvaldini
kuvaldini / git-nlx
Last active July 6, 2022 16:50
Git nice log extended
#!/usr/bin/env bash
set -euo pipefail
var_is_unset(){
declare -rn var=$1
test -z ${var+x}
}
while test $# -gt 0 ;do
case $1 in
#include <iostream>
using namespace std;
int main() {
int n;
cout << "Enter Fibonacci index: ";
cin >> n;
if(n <= 1){
cout << n << endl;
}
@kuvaldini
kuvaldini / Build-Linaro-on-Mac.md
Created December 8, 2021 14:24
Build Linaro toolchain for Mac

Build Linaro toolchain on Mac

Prepare env

Abe requires Bash version 4+.

brew install bash
brew install autogen dejagnu coreutils gcc gawk git-new-workdir 
@kuvaldini
kuvaldini / Build-Cross-Compiler.md
Last active December 8, 2021 14:25
Build Cross Compiler

Building Cross Compiler

  1. Environment

export TARGET=arm-linux-gnueabihf
export CROSS_PREFIX=/opt/crosstools/$TARGET
mkdir -p $CROSS_PREFIX
mkdir ~/src ~/build
@kuvaldini
kuvaldini / conditional_wait_for.cpp
Last active October 23, 2021 17:33
Without lambda works as expected, but with lambda look more like spin lock.
#include <iostream>
#include <thread>
#include <chrono>
#include <condition_variable>
using namespace std;
using namespace std::chrono;
using namespace std::chrono_literals;
std::mutex expiration_thread_work_mutex_;
@kuvaldini
kuvaldini / .alias.gitconfig
Last active July 6, 2022 14:58
Useful aliases for Git
[alias]
sta = status
bra = branch
co = checkout
cos = checkout --recurse-submodule
cosf = checkout --recurse-submodule --force
root = rev-parse --show-toplevel
toplevel = rev-parse --show-toplevel
current-branch = rev-parse --abbrev-ref HEAD
sub = submodule
@kuvaldini
kuvaldini / curl-docker-tags.sh
Created August 2, 2021 10:00
A shell script to request tags of docker repository from DockerHub using curl and jq
#!/usr/bin/env bash
set -xeuo pipefail
shopt -s lastpipe
[[ $1 = */* ]]
org=${1%%/*}
repo=${1#*/}
org=${org:-hyperledger}
repo=${repo:-iroha}
@kuvaldini
kuvaldini / make-workflows.sh
Created July 3, 2021 20:26
Script to expand YAML anchors in GitHub Actions workflows
#!/usr/bin/env bash
set -euo pipefail
--help(){
cat<<'END'
make-workflows:
This script expands '*.src.yml' from $1 (default: script's directory)
to $2 (default:REPO_ROOT/.github/workflows) with corresponding name '*.yml'
Main goal is to dereference YAML anchors.