Skip to content

Instantly share code, notes, and snippets.

View nmrshll's full-sized avatar
🦀
rusting

Nicolas Marshall nmrshll

🦀
rusting
View GitHub Profile
#!/bin/sh
echo "Installing XCode CLT..."
xcode-select --install
read -p "Press [Enter] key to once CLT finished..."
clear
echo "Creating dev environment..."
mkdir ~/dev
mkdir ~/dev/go
clear
for dir in *
do
DIR=${dir} sh -c 'cd ${DIR}; git remote remove origin; git remote add origin git@bitbucket.org:n-marshall/companyname-${DIR}.git; git push -u origin master'
done
fn passErr(err) ==> { throw err }
fn logErr(err) ==> { log.Error(err) }
fn ignoreErr(err) ==> {}
out1 := try SomeFunc1(arg1,arg2), catch logErr
out2 := try SomeFunc2(arg1),
catch passErr
out3 := try SomeFunc3(arg1). catch (err) ==> errwrap.wrapErr("additional error info")
@nmrshll
nmrshll / rsflattenarray.rs
Last active May 19, 2019 18:27
flatten an array (of i32) in rust
#![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},
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/
@nmrshll
nmrshll / pgping
Last active September 9, 2019 10:57
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"
@nmrshll
nmrshll / convert_all_flac_to_mp3.sh
Last active January 29, 2020 23:45
Convert all flac files in a folder/subfolders to mp3
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
# 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
@nmrshll
nmrshll / async_drop.rs
Last active September 19, 2022 15:32
Async Drop with tokio
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;
});
});
}
}