This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export type HSL = [number, number, number] | |
export function HexToHSL(hex: string): HSL | undefined { | |
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex) | |
if (!result) return undefined | |
const r = parseInt(result[1], 16) / 255 | |
const g = parseInt(result[2], 16) / 255 | |
const b = parseInt(result[3], 16) / 255 | |
const max = Math.max(r, g, b) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
"#FF4C4C", | |
"#FF0000", | |
"#590000", | |
"#190000", | |
"#FFBD6C", | |
"#FF5400", | |
"#591D00", | |
"#271B00", | |
"#FFFF4C", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
DIR=$(dirname `readlink -e $1`) | |
FILE=$(basename `readlink -e $1`) | |
OUT_DIR=`basename ${FILE} .mp3` | |
MODEL_DIRECTORY="${HOME}/.cache/spleeter" | |
mkdir -p ${MODEL_DIRECTORY} | |
docker run \ | |
-v ${DIR}:/work \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include <algorithm> | |
#include <array> | |
template <class T, size_t N> | |
class CircularArray { | |
public: | |
CircularArray() {} | |
CircularArray(const T initValue) { std::fill_n(data_.begin(), data_.size(), initValue); } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void HexArrayToStr(const char* data, size_t length, std::string& output) { | |
const char* NIBBLE_TO_HEX = {"0123456789ABCDEF"}; | |
output.assign(length * 2 + 1, 0); | |
char* buffer = output.data(); | |
for (size_t i = 0; i < length; i++) { | |
int nibble = uint8_t(data[i]) >> 4; | |
buffer[2 * i] = NIBBLE_TO_HEX[nibble]; | |
nibble = uint8_t(data[i]) & 0x0F; | |
buffer[2 * i + 1] = NIBBLE_TO_HEX[nibble]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Assumes the surrounding context has a bool named `color` | |
#define COLOR( code, s ) ( color ? "\033[0;" #code "m" : "" ) << s << ( color ? "\033[0;m" : "" ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ubuntu:18.04 | |
# Install common C++ and imaging libraries, Clang, and add Clang to the PATH | |
RUN apt-get update && apt-get install -y \ | |
xz-utils \ | |
git \ | |
wget \ | |
nano \ | |
build-essential \ | |
libboost-all-dev \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ffmpeg -f v4l2 -framerate 10 -thread_queue_size 512 -i /dev/video0 -t 5 -c:v h264 -pix_fmt yuv420p test001.mp4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include <memory> | |
#define NOMINMAX | |
#undef max | |
template <typename T> | |
class UntrackedAllocator { | |
public: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<typename T> | |
class [[nodiscard]] Result { | |
public: | |
Result(const T& value) : _result(value) {} | |
Result(T && value) : _result(std::move(value)) {} | |
Result(std::exception error) : _result(std::unexpected<std::exception>(std::move(error))) {} | |
bool isOk() const { | |
markChecked(); | |
return _result.has_value(); |