Skip to content

Instantly share code, notes, and snippets.

View pyldin601's full-sized avatar

Roman Lakhtadyr pyldin601

View GitHub Profile
import makeDebug from 'debug'
const debug = makeDebug('webm')
// Parse EBML variable-length integer
function parseVInt(buffer: Uint8Array, start: number): { value: number; length: number } {
let firstByte = buffer[start]
let numBytes = 0
for (let mask = 0x80; mask >= 0x08; mask >>= 1) {
/**
* Enhanced `toUpperCase` function with improved type inference.
*
* Traditional methods return a general `string` type.
* This version gives a specific uppercase type based on the input.
*
* E.g., for an input type 'hello', this returns type 'HELLO'.
*/
type ToUpperCase<S extends string> = S extends `${infer First}${infer Rest}`
@pyldin601
pyldin601 / utils.rs
Created April 13, 2023 13:40
convert_sample_to_byte_data
/// Converts a slice of signed 16-bit integers to a vector of unsigned 8-bit integers,
/// with little-endian byte order.
///
/// # Arguments
///
/// * `i16s`: A slice of signed 16-bit integers to convert. Each pair of integers represents
/// the left and right channel samples of an audio frame.
///
/// # Returns
///
@pyldin601
pyldin601 / Dockerfile
Created March 29, 2023 13:14
dockerfile contents for compiling cef
FROM ubuntu:22.10
RUN apt-get update && apt-get install -y --no-install-recommends wget \
curl \
build-essential \
cmake \
python-pip \
libglib2.0-dev \
libnss3-dev \
libatk1.0-0 \
@pyldin601
pyldin601 / Makefile
Last active December 11, 2021 14:18
Compose small videos from video registrator into big single video (with front and back camera tracks)
.PHONY: clean rename video
ffmpeg := /mnt/c/Users/roman/Downloads/ffmpeg-4.4-full_build/ffmpeg-4.4-full_build/bin/ffmpeg.exe
filename = $(shell ls Front/${mask}* | head -n 1 | cut -d. -f1 | xargs -n 1 basename)
front.txt:
ls Front/${mask}* | sed "s/.*/file '&'/" > front.txt
back.txt:
ls Back/${mask}* | sed "s/.*/file '&'/" > back.txt
CREATE DEFINER=`mor`@`%` PROCEDURE `move_track_channel`(IN `s_id` INT, IN `s_target` VARCHAR(16), IN `s_index` INT)
NO SQL
proc:BEGIN
SELECT `t_order`,`track_id` INTO @order, @id FROM `r_link` WHERE `unique_id` = s_target;
export interface LockManager {
lock(fn: () => Promise<void>): Promise<void>
}
/**
* This is my limited implementation of Locks manager for browsers.
* I implemented my own because this technology is experimental yet.
* @see https://developer.mozilla.org/en-US/docs/Web/API/LockManager
*/
export class NaiveLockManager implements LockManager {
const knex = require("knex");
const supertest = require("supertest");
const errorConstants = require("@myownradio/independent/constants/error");
const createApp = require("../src/app");
const migrationsDir = `${__dirname}/../../../migrations`;
const seedsDir = `${__dirname}/../../../seeds`;
const accessToken =
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOjEsImlhdCI6MTUxNjIzOTAyMn0.Fknsf_nSFNdqS9JkFJABEEtMVffv9zR1_nrI2mAVx60";
export function* iterateOverCombinedItems(items) {
if (items.length === 0) {
return
}
const [h, ...tail] = items
const heads = Array.isArray(h) ? h : [h]
for (const head of heads) {
@pyldin601
pyldin601 / color-conversion-algorithms.js
Created March 4, 2020 10:15 — forked from mjackson/color-conversion-algorithms.js
RGB, HSV, and HSL color conversion algorithms in JavaScript
/**
* Converts an RGB color value to HSL. Conversion formula
* adapted from http://en.wikipedia.org/wiki/HSL_color_space.
* Assumes r, g, and b are contained in the set [0, 255] and
* returns h, s, and l in the set [0, 1].
*
* @param Number r The red color value
* @param Number g The green color value
* @param Number b The blue color value
* @return Array The HSL representation