This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
─ ━ │ ┃ ┄ ┅ ┆ ┇ ┈ ┉ ┊ ┋ ╌ ╍ ╎ ╏ | |
┌ ┍ ┎ ┏ ┐ ┑ ┒ ┓ | |
└ ┕ ┖ ┗ ┘ ┙ ┚ ┛ | |
├ ┝ ┞ ┟ ┠ ┡ ┢ ┣ ┤ ┥ ┦ ┧ ┨ ┩ ┪ ┫ | |
┬ ┭ ┮ ┯ ┰ ┱ ┲ ┳ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
┏━━━┓ | |
┃ ┃ | |
┗━━━┛ | |
┏━┳━┳━┓ | |
┃ ┃ ┃ ┃ | |
┗━┻━┻━┛ | |
╭───╮ | |
│ │ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![feature(allocator_api)] | |
use std::alloc::Allocator; | |
use std::alloc::Global; | |
use std::marker::PhantomData; | |
// Basicaly a Vec. | |
pub struct V<T, A: Allocator = Global> { | |
pub buf: Rv<T, A>, | |
pub len: usize, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use rand::Rng; | |
use std::default::Default; | |
use std::{cell::RefCell, collections::HashMap, time::Duration}; | |
use tokio::{self, select, task, task_local, time::timeout}; | |
fn rand_gen_millis() -> (u64, u64) { | |
let mut rng = rand::thread_rng(); | |
let t1 = rng.gen_range(0..10); | |
let t2 = rng.gen_range(0..10); | |
(t1, t2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use tokio; | |
use tokio::{task, task_local}; | |
use std::cell::RefCell; | |
use std::collections::HashMap; | |
#[tokio::main] | |
async fn main() { | |
let handler = task::spawn(async { | |
task_local! { | |
pub static WRITER: RefCell<HashMap<String, i64>>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Rust Idiom: | |
// prefixing a variable with an underscore | |
// signals to others that the variable | |
// isn't going to be used, not that it is | |
// intentionally private or an updated | |
// variable. | |
main () { | |
let x = 12; | |
// _x reads as |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// NB. fix | |
// #[derive(Debug, Clone)] | |
#[derive(Debug)] | |
struct Context; | |
fn dupe_context(context: &Context) -> Context { | |
context.clone() | |
} | |
fn main() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[derive(Debug, Clone)] | |
struct Resource(usize); | |
#[derive(Debug)] | |
struct Error; | |
fn may_fail(ix: usize) -> Result<Resource, Error> { | |
if rand::random::<f64>() < 0.5 { | |
Err(Error) | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
: {d1:=1} | |
: {d2:=2} | |
: {op:?"provide an operator for comparison"} | |
lhs=date -j -f "%F" "$d1" +%s 2>/dev/null | |
rhs=date -j -f "%F" "$d2" +%s 2>/dev/null | |
case $op in | |
"eq") | |
[ lhs -eq rhs ] ;; | |
"ge") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
: {org:?"need to set an org name"} | |
: {max_pages:?"need to set maximum number of pages"} | |
for PAGE in $( seq $max_pages ); do | |
gh api ‘orgs/$org/repos?per_page=100&page=‘“$PAGE” | jq -r ‘map(.name) | .[]' | while read NAME; do | |
git clone “[email protected]:$org/$NAME” | |
done |
NewerOlder