Skip to content

Instantly share code, notes, and snippets.

@i-v-s
i-v-s / gist:a1b554b8c5e925f3955eeb2b537ee0a3
Created December 3, 2023 14:31
Build local Python with any SQLite
export CC=/usr/bin/gcc-13 # Or any other C compiler
export CXX=/usr/bin/g++-13
export LOCAL_PRE={local dir}
export CFLAGS="-I${LOCAL_PRE}/include $CFLAGS"
# In the SQLite source folder:
./configure --prefix=${LOCAL_PRE}
make -j 4
make install
from typing import NamedTuple
from pathlib import Path
from argparse import ArgumentParser
from shutil import move
from imghdr import what
from hashlib import sha1
import cv2
ext_map = {
'jpeg': 'jpg',
import json
import re
from pathlib import Path
from argparse import ArgumentParser
from asyncio import run, gather, Semaphore, TimeoutError
from aiohttp import ClientSession, ClientError
from aiofile import AIOFile
from bs4 import BeautifulSoup
@i-v-s
i-v-s / clickhouse.sql
Last active September 30, 2021 08:37
Clickhouse utilites
-- Make japanese candles from raw trades
SELECT t.tm AS time, a.price AS open, t.lp AS low, t.hp AS high, b.price AS close
FROM (
SELECT toStartOfHour(time) AS tm, MIN(price) AS lp, MAX(price) AS hp, MIN(id) AS lid, MAX(id) AS hid
FROM binance_cfx_usdt_trades GROUP BY toStartOfHour(time)
) AS t
INNER JOIN binance_cfx_usdt_trades AS a ON a.id = t.lid
INNER JOIN binance_cfx_usdt_trades AS b ON b.id = t.hid
ORDER BY t.tm
@i-v-s
i-v-s / Main.hs
Created May 6, 2021 19:08
Ethereum JSON-RPC query example on Haskell
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Numeric (showHex)
import Data.Text (pack)
import Control.Monad.IO.Class
import Data.Aeson
import Network.HTTP.Req
@i-v-s
i-v-s / wg.sh
Last active January 19, 2021 14:03
#!/bin/sh
# Usage: sh wg.sh number endpoint:35053 public_key
sudo apt update
sudo apt install -y openresolv wireguard
umask 077
wg genkey > privatekey
pk=`cat privatekey`
@i-v-s
i-v-s / gitlab-runners.md
Last active May 14, 2020 10:21
GitLab runner issues

1. Issue:

$ sudo gitlab-runner status
gitlab-runner: Service is not running.

Check journal:

$ journalctl -r -u gitlab-runner
FATAL: Service run failed                           error=chdir /var/lib/gitlab-runner: no such file or directory
@i-v-s
i-v-s / gst.py
Created April 23, 2020 14:23
Jetson hardware compression
def gst_src(size=-1, rate=30, number=0):
w, h = size
appsink = ' ! '.join([
f'video/x-raw(memory:NVMM), width={w}, height={h}, format=(string)NV12, framerate=(fraction){rate}/1',
'nvvidconv', f'video/x-raw, width=(int){w}, height=(int){h}, format=(string)BGRx',
'videoconvert ! appsink'
])
return ' ! '.join([
'nvarguscamerasrc',
#'tee name=t', # Source and tee
@i-v-s
i-v-s / gist:6b523ffaa75df2efc921fd9b562c045c
Last active March 23, 2020 16:12
Build FFMPEG with desired ffnvcodec version. Avoid "The minimum required Nvidia driver for nvenc is xxx or newer"
# From https://devblogs.nvidia.com/nvidia-ffmpeg-transcoding-guide/
#Install dependencies:
sudo apt install nasm
# Download ffnvcodec:
git clone https://git.videolan.org/git/ffmpeg/nv-codec-headers.git
cd nv-codec-headers
# Check ffnvcodec versions and select version
@i-v-s
i-v-s / rtsp.sh
Created October 26, 2019 23:16
YUYV camera + Raspberry Pi
#!/bin/sh
# Make RTSP stream
src/gst-rtsp-server-1.16.1/examples/test-launch "( v4l2src ! video/x-raw,format=YUY2,width=640,height=480 ! videoconvert ! video/x-raw,format=I420 ! videoconvert ! x264enc qp-min=18 speed-preset=superfast ! h264parse ! rtph264pay name=pay0 pt=96 config-interval=1 )"
# Write to file
gst-launch-1.0 -e v4l2src ! video/x-raw,format=YUY2,width=640,height=480 ! \
videoconvert ! queue ! x264enc qp-min=18 ! h264parse ! video/x-h264,stream-format="avc",alignment="au" ! mp4mux fragment-duration=10 ! filesink location=test.mp4