Skip to content

Instantly share code, notes, and snippets.

@vi
vi / dnsmanageweb.rs
Last active April 18, 2019 23:15
Simple web portal to update dynamic DNS records
#!/usr/bin/env run-cargo-script
//! ```cargo
//! [package]
//! name = "dnsmanageweb"
//! version = "0.1.0"
//! authors = ["Vitaly _Vi Shukela <vi0oss@gmail.com>"]
//! edition = "2018"
//!
//! [dependencies]
//! rouille = {version="3.0.0", default-features=false}
@vi
vi / hyper_hack.rs
Created March 24, 2019 22:22
Dump of hacky experimentation with Hyper. Not suggesting to write code like this
// Trying to imiate `rust-websocket`-like interface with hyper 0.12
#![allow(unused)]
#![deny(unused_must_use)]
use tokio::prelude::*;
use tokio::net::tcp::{TcpListener,TcpStream};
use std::net::SocketAddr;
use hyper::server::conn;
use hyper::service::Service;
@vi
vi / split_by_silence.sh
Last active February 23, 2024 13:18
Using FFmpeg to split multimedia file into parts based on audio volume level
#!/bin/bash
IN=$1
OUT=$2
true ${SD_PARAMS:="-55dB:d=0.3"};
true ${MIN_FRAGMENT_DURATION:="20"};
export MIN_FRAGMENT_DURATION
if [ -z "$OUT" ]; then
@vi
vi / hyperstdioclient.crs
Last active December 13, 2023 09:48
Rust Hyper low-level client demo - make request to stdout, read reply from stdin; also similar server demo
#!/usr/bin/env run-cargo-script
//! ```cargo
//! [dependencies]
//! hyper = { version = "0.12.20", default-features = false }
//! tokio-stdin-stdout = "0.1.5"
//! readwrite = {version="0.1.1", features=["tokio"]}
//! futures = "0.1.25"
//! tokio = "0.1.14"
//! ```
@vi
vi / tcpclose.crs
Created August 2, 2018 16:29
Rust Tokio fast TCP socket close handling
#!/usr/bin/env run-cargo-script
//! ```cargo
//! [dependencies]
//! tokio = "=0.1.7"
//! tokio-codec = "*"
//! tokio-io = "=0.1.7"
//! futures-cpupool = "*"
//! mio = "*"
//!
//! [replace]
@vi
vi / playground.rs
Created August 1, 2018 20:39 — forked from rust-play/playground.rs
Code shared from the Rust Playground
#!/usr/bin/env run-cargo-script
// cargo-deps: tokio, tokio-codec, tokio-io, futures-cpupool
extern crate tokio;
extern crate tokio_codec;
extern crate tokio_io;
extern crate futures_cpupool;
use tokio_codec::{Decoder, LinesCodec};
@vi
vi / log
Created January 30, 2018 21:17
Another CLBlast test
* Options given/available:
-platform 0 [=default]
-device 0 [=default]
--- OpenCL device naming:
* Device type GPU
* Device name Intel(R) HD Graphics IvyBridge M GT2
* Platform vendor Intel
@vi
vi / CLBlast_M_GT2.txt
Created December 21, 2017 20:47
Testing CLBlast
clblast_test_diagnostics
* Options given/available:
-platform 0 [=default]
-device 0 [=default]
--- OpenCL device naming:
* Device type GPU
* Device name Intel(R) HD Graphics IvyBridge M GT2
@vi
vi / tokiostdin.rs
Created October 9, 2017 19:15
Simple copy stdin to stdout example using Rust tokio
extern crate futures;
extern crate tokio_core;
extern crate tokio_io;
extern crate tokio_file_unix;
use futures::{Future};
use tokio_io::io::copy;
use tokio_core::reactor::Core;
use std::io::{Result};
@vi
vi / miostdin.rs
Created October 9, 2017 19:15
Simple copy stdin to stdout example using Rust mio
extern crate mio;
use mio::unix::EventedFd;
use std::fs::File;
use mio::{Token, PollOpt, Ready, Poll, Events};
//use mio_uds::UnixStream;
use std::os::unix::io::{FromRawFd};
use std::io::{Read, Write};