Skip to content

Instantly share code, notes, and snippets.

View cowboy-bebug's full-sized avatar

Eric Lim cowboy-bebug

View GitHub Profile
import boto3, re, asyncio
async def sync_one_to_s3(path):
source, target = path
bucket = re.sub('^s3://(.+?)/.+$', '\\1', target)
s3 = boto3.resource('s3')
b = s3.Bucket(bucket)
try:
b.upload_file(file, key)
except ClientError as e:
@cowboy-bebug
cowboy-bebug / specialization.rs
Created October 11, 2019 02:25
specialization usage to impl a fn with default return values & "override" it for certain types
#![feature(specialization)]
trait Foo {
fn foo(&self);
}
impl<T> Foo for T {
default fn foo(&self) { println!("default foo") }
}
@cowboy-bebug
cowboy-bebug / move_to_another_repo.sh
Created October 15, 2019 22:12
moving directories from one repo to another
# clone repos
mkdir move-repo && cd move-repo/
git clone <repo-src>
git clone <repo-dst>
# prepare source
cd repo-src
#git checkout <branch-in-repo-src> # optional
#git remote rm origin # optional
git filter-branch --subdirectory-filter <directory-to-move> -- --all
@cowboy-bebug
cowboy-bebug / impl_overlap.rs
Created October 20, 2019 23:09
Multiple impls of a trait on the same type
// Source: https://codesandwich.github.io/overlapping_blanket_impls/
use std::convert::TryInto;
// Dummy Trait
trait Blanket<I> {
fn blanket(&self) -> &'static str;
}
// Dummy Structs
struct Numbers;
@cowboy-bebug
cowboy-bebug / fork_subdirectory.sh
Created April 28, 2020 06:30
Fork a subdirectory of an upstream repo
# clone an upstream repo
git clone https://github.com/<user>/<project>.git && cd project
git branch -m upstream-master
git subtree split --prefix=<folder>/<subfolder> -b upstream-rebase
git checkout upstream-rebase
git remote rename origin upstream
git remote add origin https://github.com/<my-account>/<my-project>.git
git fetch origin
git push -u origin upstream-rebase
@cowboy-bebug
cowboy-bebug / README.md
Last active August 2, 2022 01:40
Build and run Ajuna node and worker locally

Build and Run Ajuna and worker

Building

Clone the projects and mount them in a container:

git clone -b polkadot-v0.9.20-dev [email protected]:ajuna-network/Ajuna.git Ajuna
git clone [email protected]:ajuna-network/worker.git worker
cd worker && git checkout 0c40097 && cd ..
@cowboy-bebug
cowboy-bebug / README.md
Last active June 9, 2022 10:33
Run Ajuna node and worker

Run Ajuna and worker

Run compose with optinal logging (open http://localhost in your browser for app):

docker-compose up -d
docker logs ajuna-network_worker_1 -f

Bash into the worker container to start sending trusted calls:

@cowboy-bebug
cowboy-bebug / checklist.md
Created June 10, 2022 01:25
Checklist to start hacking on a Substrate node