Skip to content

Instantly share code, notes, and snippets.

View yoshuawuyts's full-sized avatar

Yosh yoshuawuyts

View GitHub Profile
@yoshuawuyts
yoshuawuyts / tracing_log.rs
Created June 29, 2020 19:11 — forked from KodrAus/tracing_log.rs
Converting between `tracing` key values and `log` key values
use std::fmt;
use log::kv::{self, Source, value::{self, Fill}};
use tracing::{Value, Field, field::{self, Visit}};
#[doc(hidden)]
pub struct LogField<'kvs>(&'kvs Field, &'kvs dyn Value);
impl fmt::Debug for LogField<'_> {
@yoshuawuyts
yoshuawuyts / playground.rs
Created September 16, 2019 02:59 — forked from rust-play/playground.rs
Code shared from the Rust Playground
#[derive(Debug, PartialEq)]
enum State {
Waiting { waiting_time: usize },
Filling { rate: usize },
Done,
Failure(String),
}
#[derive(Debug, Clone, Copy)]
enum Event {
@yoshuawuyts
yoshuawuyts / playground.rs
Created September 2, 2019 18:42 — forked from rust-play/playground.rs
Code shared from the Rust Playground
macro_rules! fmt_args {
($($tt:tt)*) => {
_fmt_args_!("",; $($tt)*)
};
}
macro_rules! _fmt_args_ {
($fmt:expr, $($args:expr,)*; ) => {
format_args!($fmt $(,$args)*)
};
@yoshuawuyts
yoshuawuyts / kv-log-macro.rs
Last active September 1, 2019 12:06 — forked from rust-play/playground.rs
Code shared from the Rust Playground
#[macro_export]
macro_rules! info {
// info!("...")
($e:expr) => {
$crate::info_impl!(($e));
};
// info!("...", args...)
($e:expr, $($rest:tt)*) => {
$crate::info_impl!(($e) $($rest)*);
@yoshuawuyts
yoshuawuyts / playground.rs
Created July 22, 2019 21:30 — forked from rust-play/playground.rs
Code shared from the Rust Playground
#![feature(async_await)]
use std::{cell::Cell, future::Future, io, net::SocketAddr, pin::Pin};
pub trait TcpStream {}
impl<T: TcpStream + ?Sized> TcpStream for Pin<Box<T>> {}
pub trait Runtime: Send + Sync + 'static {
type TcpStream: TcpStream;
@yoshuawuyts
yoshuawuyts / playground.rs
Created July 22, 2019 21:26 — forked from rust-play/playground.rs
Code shared from the Rust Playground
#![feature(async_await)]
use std::{cell::Cell, future::Future, io, net::SocketAddr, pin::Pin};
pub trait TcpStream {}
impl<T: TcpStream + ?Sized> TcpStream for Pin<Box<T>> {}
pub trait Runtime: Send + Sync + 'static {
type TcpStream: TcpStream;
@yoshuawuyts
yoshuawuyts / arch-linux-install.md
Created May 19, 2019 21:57 — forked from jamesmunns/arch-linux-install.md
Minimal instructions for installing arch linux on an UEFI NVMe system with full system encryption using dm-crypt and luks
Roots for record 0 (stored at leaf 0): [ 0 ]
0: 0
Roots for record 1 (stored at leaf 2): [ 1 ]
0: 0─┐
1
1: 2─┘
Roots for record 2 (stored at leaf 4): [ 1, 4 ]
0: 0─┐
@yoshuawuyts
yoshuawuyts / github_release.rb
Created August 22, 2018 16:18 — forked from valeriomazzeo/github_release.rb
Creates or update a GitHub release for the given tag name
#!/usr/bin/env ruby
require 'optparse'
require 'octokit'
options = {}
OptionParser.new do |opt|
opt.on('-s', '--secret SECRET', 'GitHub access token') { |o| options[:secret] = o }
opt.on('-r', '--repo-slug REPO_SLUG', 'Repo slug. i.e.: apple/swift') { |o| options[:repo_slug] = o }
opt.on('-c', '--changelog-file CHANGELOG_FILE', 'Changelog path') { |o| options[:changelog_file] = o }