Skip to content

Instantly share code, notes, and snippets.

package main
import (
"fmt"
"reflect"
)
type meta struct {
Lang string `xlsx:"Язык"`
Gov string `xlsx:"Гражданство"`
@stvoidit
stvoidit / exampe1.go
Created July 28, 2020 18:49
exampe1 (tealeg/xlsx)
/*
Execution sequence:
1) main
2) writeExcel
3) writeWheet
4) iteration write row
*/
package main
@stvoidit
stvoidit / generics_channels_merge.go
Created April 3, 2022 08:57
generics channels merge
func merge[T any, C chan T](cs ...C) C {
out := make(C)
var wg sync.WaitGroup
wg.Add(len(cs))
for i := range cs {
go func(c C) {
defer wg.Done()
for value := range c {
out <- value
}
@stvoidit
stvoidit / BufferSyncPool.go
Created August 10, 2022 10:30
sync.Pool -> bytes.Buffer
func NewBufferPool(bufsize int) BufferPool {
if bufsize <= 0 {
bufsize = bytes.MinRead
}
return BufferPool{pool: &sync.Pool{New: func() any {
return bytes.NewBuffer(make([]byte, 0, bufsize))
}}}
}
type BufferPool struct {
@stvoidit
stvoidit / rsa_hint.go
Last active November 22, 2022 00:21
RSA keygen + encrypt + decrypt
package main
import (
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"encoding/pem"
"fmt"
"os"
)
@stvoidit
stvoidit / customDateTime.go
Created April 14, 2023 13:04
custom date time type for JSON
type DateTime time.Time
const iso8601 = "2006-01-02 15:04:05Z07:00"
func (dt DateTime) AsTime() time.Time {
return time.Time(dt)
}
func (dt DateTime) Format(layout string) string {
return dt.AsTime().Format(layout)
@stvoidit
stvoidit / crypto_ctr.go
Created September 23, 2023 19:19
golang CTR encoding and decoding for big files or stream
import (
"crypto/aes"
"crypto/cipher"
"crypto/hmac"
"crypto/rand"
"crypto/sha512"
"encoding/base64"
"errors"
"hash/fnv"
"io"
@stvoidit
stvoidit / custome_context_select.go
Last active September 24, 2023 12:44
use golang context
package main
import (
"context"
"errors"
"fmt"
"time"
)
func main() {
@stvoidit
stvoidit / logid.cng
Last active May 9, 2024 21:26
Wireless Mobile Mouse MX Anywhere 2S (logiops config)
workers = 2;
devices: (
{
name: "Wireless Mobile Mouse MX Anywhere 2S";
smartshift:
{
on: true;
threshold: 0;
default_threshold: 0;
};
@stvoidit
stvoidit / python3_compilation_clang18.sh
Last active July 8, 2024 22:49
python 3 compilation with clang-18 and full optimization on ubuntu22.04
#!/usr/bin/bash
set -e
# llvm-profdata is required for a --enable-optimizations build but could not be found.
export PATH="$PATH:/usr/lib/llvm-18/bin/"
export CC="clang"
export CXX="clang++"
export LD="lld"
export LLVM=1
sudo apt-get update && sudo apt-get upgrade -y && sudo apt-get install -y build-essential gdb lcov pkg-config \
libbz2-dev libffi-dev libgdbm-dev libgdbm-compat-dev liblzma-dev \