Skip to content

Instantly share code, notes, and snippets.

View ivarprudnikov's full-sized avatar
🌍
Vivamus, moriendum est.

Ivar (aɪvɑr) ivarprudnikov

🌍
Vivamus, moriendum est.
View GitHub Profile
@ivarprudnikov
ivarprudnikov / go.mod
Created February 29, 2024 12:14
Create COSE_Sign1 signature envelope in Go and sign with a key in Azure KeyVault
module something.com/whatever
go 1.19
require github.com/veraison/go-cose v1.1.1-0.20240126165338-2300d5c96dbd
require (
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2 // indirect
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.5.1 // indirect
github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.2 // indirect
@ivarprudnikov
ivarprudnikov / multipart-form-data.go
Created February 27, 2023 15:36
Send multipart form data in go
package main
import (
"bytes"
"mime/multipart"
"net/http"
)
func PostFormMultipart(content []byte) (*http.Response, error) {
url := "http://localhost:8080"
@ivarprudnikov
ivarprudnikov / sh
Created September 21, 2022 15:57
Create CosmosDB authorization token
#!/bin/env bash
set -e
# Generate Cosmos DB authorization header
# and create a database in the emulator
# HTTP-date
# https://www.rfc-editor.org/rfc/rfc7231#section-7.1.1.1
ISSUE_DATE=$(TZ=GMT date '+%a, %d %b %Y %T %Z')
@ivarprudnikov
ivarprudnikov / inspect.sh
Created February 16, 2022 12:53
Run and inspect a Docker container
$ docker exec -it testcontainer /bin/bash
[root@18dbc0919c88 /]#
@ivarprudnikov
ivarprudnikov / main.go
Created November 5, 2021 18:07
Go parallel execution
package main
import (
"errors"
"log"
"time"
"sync"
"fmt"
)
@ivarprudnikov
ivarprudnikov / mergeSort.js
Created February 7, 2021 13:21
Merge sort in javascript
var arr = [0,5,7,3,4,9,6,2,1,8];
var ans = [0,1,2,3,4,5,6,7,8,9];
// Split array into smaller chunks recursively [a,b,c,d] => [a,b] and [c,d]
// At the bottom (or top of stack) start merging those back
// O(NlogN)
function mergeSort(a, startIdx, endIdx) {
if (startIdx < endIdx) {
var mid = Math.floor((startIdx + endIdx)/2);
mergeSort(a, startIdx, mid);
@ivarprudnikov
ivarprudnikov / dynamo_insert_row_node_sdk.js
Created March 17, 2020 10:59
Insert rows into dynamo table
const config = {
region: 'eu-west-1',
table: 'MyTableName'
};
const AWS = require('aws-sdk');
const ddb = new AWS.DynamoDB({
apiVersion: '2012-08-10',
region: config.region
});
@ivarprudnikov
ivarprudnikov / .zshrc
Last active December 6, 2023 22:18
Initial zshrc config
# zsh config
###############
# Load version control information
autoload -Uz vcs_info
precmd() { vcs_info }
# Format the vcs_info_msg_0_ variable
zstyle ':vcs_info:git:*' formats '(%b) '
autoload -U colors && colors
setopt PROMPT_SUBST
@ivarprudnikov
ivarprudnikov / .bash_profile
Last active December 8, 2023 10:09
Bash setup
echo "Setup prompt appearance"
# to add username@hostname to prompt, then prepend the following:
# \[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]
# The promp should look like:
# ~/Documents/project $ gitbranch _
export PS1="\[\033[32m\]\w\[\033[00m\] \$ \[\033[34m\]\$(git branch 2>/dev/null | grep '^*' | colrm 1 2)\[\033[00m\] "
# On FreeBSD and Mac OS X, ls shows colors if the CLICOLOR environment variable is set
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad
@ivarprudnikov
ivarprudnikov / bose_sound_touch_10.sh
Last active January 29, 2021 22:52
Connect Bose SoundTouch 10 to WiFi
# This is a copy/excerpt from Sam Hobbs article
# https://samhobbs.co.uk/2016/01/connect-bose-soundtouch-10-wifi-using-linux-telnet
# Just making sure it does not dissapear into the void before I need it again
# check IP
$ route # or "netstat -rn" on osx
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 192.0.2.1 0.0.0.0 UG 600 0 0 wlan0
link-local * 255.255.0.0 U 1000 0 0 wlan0