Skip to content

Instantly share code, notes, and snippets.

@izderadicka
izderadicka / lib.rs
Created August 17, 2024 12:14
Rust Map with COW key
use std::{borrow::Cow, collections::HashMap, hash::Hash};
pub struct CowMap<'a, T, K, V>
where
K: ToOwned<Owned = T> + ?Sized,
{
map: HashMap<Cow<'a, K>, V>,
}
impl<'a, T, K, V> CowMap<'a, T, K, V>
@izderadicka
izderadicka / startgazers.ipynb
Created December 4, 2021 18:42
Jupyter notebook for GH Stargazers
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@izderadicka
izderadicka / README.md
Last active June 3, 2021 10:18
Coverage for dstream project
@izderadicka
izderadicka / echo-simple.rs
Created February 29, 2020 08:26
Hyper websocket example
#[macro_use]
extern crate log;
use futures::prelude::*;
use futures::stream::StreamExt;
use headers::{self, HeaderMapExt};
use hyper::header::{self, AsHeaderName, HeaderMap, HeaderValue};
use hyper::server::Server;
use hyper::service::{make_service_fn, service_fn};
use hyper::{self, Body, Method, Request, Response, StatusCode};
use std::convert::Infallible;
@izderadicka
izderadicka / lib.rs
Last active October 7, 2019 18:00
Polymorphism Rust
use std::io::{self, Write, Seek};
pub struct Writer<W> {
inner: W
}
impl <W:Write> Writer<WrapperUnseekable<W>> {
pub fn new_unseekable(inner: W) -> Self {
Writer{
@izderadicka
izderadicka / main.rs
Created April 2, 2019 13:04
Hyper Websockets
#[macro_use]
extern crate log;
use hyper::rt;
use hyper::server::Server;
use hyper::service::service_fn_ok;
use hyper::{Body, Request, Response};
use tokio::prelude::*;
mod ws;
@izderadicka
izderadicka / extract_cover.py
Created August 20, 2018 07:46
Extract cover images from mp3 files within directory
#! /usr/bin/env python3
import argparse
import os
import subprocess
import logging
log = logging.getLogger()
def main():
@izderadicka
izderadicka / mp3_to_opus.sh
Last active November 24, 2018 11:17
Converts mp3 files to opus concurrently (one conversion per core)
#!/bin/bash
# Author : <Ivan Zderadicka> ivan@zderadicka.eu
# License: MIT
VERSION=0.1.1
BITRATE=48
CUTOFF=20000
APPLICATION=audio
FORMAT=opus
QUALITY=10
@izderadicka
izderadicka / split_audiobook.sh
Last active September 12, 2019 08:40
Splits large audiobooks into smaller files ( either by chapters, if available or to pieces of fixed duration) encoded with Opus audio
#!/bin/bash
# Author : <Ivan Zderadicka> ivan@zderadicka.eu
# License: MIT
VERSION="0.2.3"
BITRATE=48
CUTOFF=12000
SEGMENT_TIME=1800
COMMON_PARAMS="-nostdin -v error"
0x0004da82394ED7Aa756E6343F0A1a52609087d79