Skip to content

Instantly share code, notes, and snippets.

@stvoidit
stvoidit / logid.cng
Last active April 19, 2024 19:07
Wireless Mobile Mouse MX Anywhere 2S (logiops config)
workers = 16;
devices: (
{
name: "Wireless Mobile Mouse MX Anywhere 2S";
smartshift:
{
on: false;
threshold: 0;
default_threshold: 0;
};
@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 / 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 / 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 / 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 / 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 / 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 / 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
package main
import (
"fmt"
"reflect"
)
type meta struct {
Lang string `xlsx:"Язык"`
Gov string `xlsx:"Гражданство"`