Skip to content

Instantly share code, notes, and snippets.

Avatar

Ivan Zderadicka izderadicka

View GitHub Profile
@izderadicka
izderadicka / echo-simple.rs
Created Feb 29, 2020
Hyper websocket example
View echo-simple.rs
#[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 Oct 7, 2019
Polymorphism Rust
View lib.rs
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 Apr 2, 2019
Hyper Websockets
View main.rs
#[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 Aug 20, 2018
Extract cover images from mp3 files within directory
View extract_cover.py
#! /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 Nov 24, 2018
Converts mp3 files to opus concurrently (one conversion per core)
View mp3_to_opus.sh
#!/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 Sep 12, 2019
Splits large audiobooks into smaller files ( either by chapters, if available or to pieces of fixed duration) encoded with Opus audio
View split_audiobook.sh
#!/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"
@izderadicka
izderadicka / eratosthenes_sieve.rs
Last active Sep 27, 2017
Sieve of Eratosthenes in RUST
View eratosthenes_sieve.rs
//! Simple module to implement [Sieve of Eratosthenes](https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes).
//! It implements both clasical sieve (starting from 2 to given limit) and segmented sieve (from min to max).
//! # Examples
//!
//! Primes under 20:
//!
//! ```
//! use numbers::sieve::{Sieve,Eratosthenes};
//! let s = Eratosthenes::new(20);
//! assert_eq!(s.first(), Some(2));
View Serialization tests.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@izderadicka
izderadicka / tf.ipynb
Created Jul 29, 2016
TensorFlow tutorial
View tf.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.