Skip to content

Instantly share code, notes, and snippets.

View zhuker's full-sized avatar
🏠
Working from home

Alex Zhukov zhuker

🏠
Working from home
View GitHub Profile
@zhuker
zhuker / CMakeLists-googletest.txt
Created December 14, 2023 15:51
add googletest to cmakelists.txt
include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG v1.14.0
)
FetchContent_MakeAvailable(googletest)
add_executable(mytests
@zhuker
zhuker / mp3encoder.cpp
Created December 8, 2023 07:54
simple mp3 encoder c++
#include <lame/lame.h>
struct Mp3Encoder {
lame_global_flags *lame = nullptr;
~Mp3Encoder() {
if (lame) {
lame_close(lame);
lame = nullptr;
}
}
#include <iostream>
#ifdef __ARM_NEON
#include <arm_neon.h>
#endif
#include <fstream>
@zhuker
zhuker / string_split.cpp
Created February 22, 2023 18:01
split string
void string_split(const std::string &s, const std::string &delim, std::deque<std::string> &out, int maxElements) {
auto start = 0U;
auto end = s.find(delim);
while (end != std::string::npos && out.size() < maxElements - 1) {
out.push_back(s.substr(start, end - start));
start = end + delim.length();
end = s.find(delim, start);
}
out.push_back(s.substr(start, s.length() - start));
static std::vector<char> readAllBytes(char const* filename)
{
std::ifstream ifs(filename, std::ios::binary | std::ios::ate);
std::ifstream::pos_type pos = ifs.tellg();
if (pos == 0)
{
return std::vector<char>{};
}
@Test
fun sleepParkNanos() {
val nsec = 960 * 1000_000_000L / 48000
val looping = AtomicBoolean(true)
val histo = IntArray(10)
val t = Thread() {
val startTime = System.nanoTime()
var i = 0
while (looping.get()) {
@zhuker
zhuker / camera_matrix.py
Created October 31, 2022 00:07
Calibrate camera
import numpy as np
import cv2 as cv
import glob
path_to_images = './dji-mini2/*.JPG'
draw_ui = False
def calibrate():
# termination criteria
@zhuker
zhuker / GpsDist.kt
Created October 21, 2022 14:30
distance between gps points
import kotlin.math.*
interface ILatLng {
val lat: Double
val lon: Double
}
enum class Unit(s: String) {
KILOMETERS("km"),
METERS("m"),
@zhuker
zhuker / onnx-example.kt
Created September 13, 2022 06:28
Onnx runtime example in kotlin
@Test
fun onnxRuntime() {
val env = OrtEnvironment.getEnvironment()
OrtSession.SessionOptions().use { opts ->
opts.setOptimizationLevel(OrtSession.SessionOptions.OptLevel.BASIC_OPT)
env.createSession("mymodel.onnx", opts).use { session ->
for (i in session.inputInfo.values) {
println(i)
}
for (o in session.outputInfo.values) {
@zhuker
zhuker / GeneratePreSignedPost.cs
Created January 14, 2022 12:55
AmazonS3Client GeneratePreSignedPost
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Security.Cryptography;
using System.Text;
using Amazon.Runtime;
using Amazon.S3;