Skip to content

Instantly share code, notes, and snippets.

@stvoidit
stvoidit / ffmpeg_thumbnails.sh
Created June 1, 2024 07:14
important! I am using my ffmpeg compilation from master, so this should work for ffmpeg versions => 6. The current fastest way to create a screencast for videos of any length. A 2.5-hour video in 1080p quality is processed in about 18 seconds. Please note, I use -hwaccel auto which speeds up decoding.
#!/bin/bash
if [ -z "$1" ]; then
echo "usage: ffmpeg_thumbnails.sh PATH_TO_VIDEOFILE"
exit
fi
MOVIE=$1
MOVIE_NAME=$(basename "$MOVIE")
OUT_FILENAME="${MOVIE_NAME%.*}_preview.jpeg"
OUT_DIR=$(pwd)
@stvoidit
stvoidit / python3_compilation_clang18.sh
Created May 6, 2024 15:59
python 3 compilation with clang-18 and full optimization on ubuntu22.04
#!/usr/bin/bash
PYVERSION=$1
clang_flags="PATH=/usr/lib/llvm-18/bin/:$PATH CC=clang-18 CXX=clang++-18 LLVM=-18 LD=ld.lld-18"
cd /tmp/
wget -O - "https://www.python.org/ftp/python/$PYVERSION/Python-$PYVERSION.tar.xz" | tar xJ
cd "Python-$PYVERSION"
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 \
libncurses5-dev libncursesw5-dev libreadline6-dev libreadline-dev libsqlite3-dev libssl-dev \
lzma lzma-dev xz-utils tk-dev uuid-dev zlib1g-dev libnss3-dev
@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 / 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