Skip to content

Instantly share code, notes, and snippets.

View acud's full-sized avatar

acud acud

  • WQ9XTpXNPjAWE6cnqqPzhwKtQ
  • erd
View GitHub Profile
@acud
acud / crate-health.md
Created January 23, 2023 18:48 — forked from repi/crate-health.md
Guidelines on evaluating health & quality of third-party crates at Embark

note: I wrote this for our internal documentation & guidelines at Embark so not all of it is likely relevant for other companies, but sharing here as others expressed interest in seeing it


What to evaluate and consider before adding usage of new third-party crates.

These are not exact requirements but questions to investigate and discuss to help reason around the health, safety, maintainability, and more around crates.

This can also be read as an opinionated guide for crate authors of what our (Embark's) guidelines and recommendations are, though should not be taken too literally.

@acud
acud / localstore_debug_indices.go
Last active December 25, 2021 18:31
localstore debug indices script
package main
import (
"os"
"github.com/ethersphere/bee/pkg/localstore"
"github.com/ethersphere/bee/pkg/logging"
"github.com/ethersphere/bee/pkg/statestore/leveldb"
)
// PinStore implements storage abstractions for user pinned content.
type PinningStore struct {
s map[string]Store // each Store instance refers to a pin collection.
m MetaStore
}
type Store interface {
Get(swarm.Address) swarm.Chunk
Put(swarm.Chunk)
Iterate(IterFn) error
// PinStore implements storage abstractions for user pinned content.
type PinningStore struct {
s Store // Store can also implement MetaStore. In boltdb this is possible through using alternate buckets
m MetaStore
}
type Store interface {
Get(swarm.Address) swarm.Chunk
Put(swarm.Chunk)
Iterate(IterFn) error
type UploadStore struct {
s Store // Store can also implement MetaStore. In boltdb this is possible through using alternate buckets
m MetaStore
}
type Store interface {
Get(swarm.Address) swarm.Chunk
Put(swarm.Chunk)
Iterate(IterFn) error
Delete(swarm.Address)
#!/bin/bash
cat >~/.bashrc <<EOL
export PATH=$PATH:/usr/local/go/bin
export GOPATH=/home/ubuntu/go
alias v="vi"
alias co="git checkout"
alias l="ls"
alias ll="ls -lash"
EOL
#!/bin/bash
nodes="bootnode-0 bee-0 bee-1 light-0 light-1"
for i in $nodes
do
mkdir -p dump/$i
curl -s -o dump/$i/addresses.json $i-debug.localhost/addresses
curl -s -o dump/$i/metrics $i-debug.localhost/metrics
curl -s -o dump/$i/topology.json $i-debug.localhost/topology
@acud
acud / debug_integration.sh
Last active July 16, 2021 15:44
integration tests debugging
alias all_logs_unfiltered='kubectl -n local logs -l app.kubernetes.io/part-of=bee --tail -1 --prefix -c bee';
alias all_logs='all_logs_unfiltered | grep -av "kademlia: \|/health\|batch ser"';
function cpaste() { curl --upload-file "$1" https://paste.c-net.org ; }
alias upload_logs='all_logs | cpaste /dev/stdin'
alias metrics='curl -s {bootnode-0,bee-0,bee-1,light-0,light-1}-debug.localhost/metrics'
alias metrics_accounting='metrics | grep "^bee_\(accounting\|pseudo\|swap\)"'
alias settlements='curl -s {bootnode-0,bee-0,bee-1,light-0,light-1}-debug.localhost/settlements'
alias timesettlements='curl -s {bootnode-0,bee-0,bee-1,light-0,light-1}-debug.localhost/timesettlements'
alias logs='kubectl -n local logs $1'
alias overlays='for i in {bootnode-0,bee-0,bee-1,light-0,light-1}; do echo $i; curl -s $i-debug.localhost/addresses | jq ."overlay"; done;'
@acud
acud / shard_acquire.go
Last active March 5, 2020 03:58
golang benchmark comparing how long it takes to lock an arbitrary element of a slice. the three approaches try to: 1) try to get an element by using a normal mutex as synchronization primitive and by iterating over the slice 2) iterate over the slice but use a channel as a semaphore and try to lock 3) construct a dynamic select case using reflec…
/*
Benchmark results @ CPU Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz:
growlie@growlie-strikes-back ~/repos/playground » go test -bench=. -benchtime=5s [5/03/20|11:57AM]
goos: linux
goarch: amd64
BenchmarkRandomLockGrab-4 54 98133040 ns/op
BenchmarkIterateSem-4 58659 88213 ns/op
BenchmarkDynamicSelect-4 9030 757092 ns/op
PASS
ok _/home/growlie/repos/playground 24.397s
### Keybase proof
I hereby claim:
* I am acud on github.
* I am acud (https://keybase.io/acud) on keybase.
* I have a public key ASBT-7ZcnHccbo3wRegQK1dk5w75As5M8nNIMxczLylCowo
To claim this, I am signing this object: