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 derive_simple::DeriveSimple; | |
use proc_macro::TokenStream as TokenStream1; | |
use quote::quote; | |
use syn::DeriveInput; | |
#[proc_macro_derive(Simple)] | |
pub fn derive_simple(input: TokenStream1) -> TokenStream1 { | |
let derive_simple = DeriveSimple { | |
input: syn::parse_macro_input!(input as DeriveInput), | |
}; |
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
curl 'https://api.github.com/users/nmrshll/repos' | jq '.[] | .html_url' |
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 std::future::Future; | |
use tokio::sync::RwLock; | |
pub struct Cache<T: Clone> { | |
item: RwLock<Option<T>>, | |
} | |
impl<T: Clone> Cache<T> { | |
pub fn new() -> Self { | |
Cache { | |
item: RwLock::new(None), |
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
let recursive_got = { | |
fn try_get() -> BoxFuture<'static, String> { | |
async move { | |
if something() { | |
return "hello".to_string(); | |
} | |
tokio::time::sleep(Duration::from_millis(500)).await; | |
try_get(driver).await | |
} | |
.boxed() |
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
impl Drop for MyStruct { | |
fn drop(&mut self) { | |
tokio::task::block_in_place(move || { | |
tokio::runtime::Handle::current().block_on(async move { | |
// self.client.cleanup(&mut *self.db.conn().await).await; | |
}); | |
}); | |
} | |
} |
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
# hash a dir | |
code_sha=$(shell echo $(shell find substrate-node-template -path "*target" -prune -type f -o -exec echo {} \; | xargs -I "{}" date -r {} "+%s") | $(shell [[ `uname`="Darwin" ]] &&echo "shasum -a 256" ||echo sha256sum) | cut -d" " -f1) | |
# get a dir's last modified timestamp | |
# ?rebuild=[[ $(shell date -r ${node} "+%s" || echo 0) -lt $(shell find substrate-node-template -print0 | xargs -0 -I "{}" date -r {} "+%s" | sort -nr | head -1 || echo 0) ]] # macos only |
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
for f in ./**/*.flac; do | |
# echo $f; | |
DIR=$(dirname "$f"); | |
NAME=$(basename "$f" | cut -d'.' -f1); | |
sox "${f}" -C 320 -S "${DIR}/${NAME}.mp3" | |
done | |
# or | |
# handles filenames with spaces |
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
function pgping() { | |
help_flags=(help -h --help) | |
if [[ ${help_flags[*]} =~ "$1" ]] || ([ -z "$1" ] || [ -z "$2" ]); then | |
echo "usage:" | |
echo | |
echo "pgping <server> <port> [<username>]" | |
return 0 | |
fi | |
PROTOCOL_VERSION="\x00\x03\x00\x00" |
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
3Box is a social profiles network for web3. This post links my 3Box profile to my Github account! | |
✅ did:muport:QmfHSJt3PBstq4hMHH99CWGSw3HrQymtCov6h4GdKqofaS ✅ | |
Create your profile today to start building social connection and trust online. https://3box.io/ |
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
#![allow(non_snake_case)] | |
/// This rust lib contains one function that will flatten an array of arbitrarily nested arrays of integers into a flat array of integers. | |
/// e.g. [[1,2,[3]],4] -> [1,2,3,4]. | |
/// | |
/// # Example usage | |
/// | |
/// ``` | |
/// use rsflatten::{ | |
/// flatten, | |
/// Node::{Array as a, I32 as i}, |
NewerOlder