I hereby claim:
- I am tauraamui on github.
- I am tauraamui (https://keybase.io/tauraamui) on keybase.
- I have a public key ASCsS7gEZEmeE18hfsQN38JZ6uOI0HdQlWZS6sgxAI1qowo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
A Pen by Adam Prakash Lewis on CodePen.
"store.go" | |
type Store interface { | |
Save(ctx context.Context, model interface{}) (interface{}, error) | |
FindAll(ctx context.Context, key string, value string, dst interface{}) error | |
} | |
type MongoDBStore struct { | |
db *mongo.Collection | |
} |
// This function uses the generic store any data structure here | |
// the downside of using NoSQL is there isn't any enforced inherent | |
// relationship between the data, but long term cloud software dev | |
// had made the industry realise that this isn't actually an advantage | |
// most of the time. Cascading deletes? Who cares right? | |
// The store implementation used can be switched via cmd line flag to | |
// use either MongoDB or Google Cloud Datastore, so this impl. just | |
// checks which one is in use and stores the ID of the correct type. |
// Entry point call, pass in valid directory path and nil file pointer | |
total, err := getDirSize("/root/dir/to/count/from", nil) | |
// will either get empty string and pointer or filled string with nil pointer | |
// depending on whether it needs to just count the files still remaining in | |
// this given dir or whether it needs to start counting again in a found sub dir | |
func getDirSize(path string, filePtr *os.File) (int64, error) { | |
var total int64 |
// VERSION 1 | |
err := c.cache.Set(sizeOnDiskCacheKey, []byte(sizeStrWithUnitSuffix)) | |
if err != nil { | |
// impossible to mock as logging.Error is unoverridable func def | |
logging.Error("unable to store disk size in cache: %w", err) | |
} | |
// VERSION 2 | |
// define local overridable log error wrapper |
It("Should attempt to reconnect until read eventually returns ok", func() { | |
infoLogs := []string{} | |
resetLogInfo := media.OverloadLogInfo(func(format string, args ...interface{}) { | |
// fmt.Printf("INFO LOG FORMAT: %s\n", format) | |
infoLogs = append(infoLogs, fmt.Sprintf(format, args)) | |
}) | |
defer resetLogInfo() | |
processCallCount := 0 | |
ableToRead := true |
// Internal growinh procedure | |
_grow :: proc(q: ^$Q/Queue($T), min_capacity: uint = 0) -> bool { | |
new_capacity := max(min_capacity, uint(8), uint(builtin.len(q.data))*2) | |
n := uint(builtin.len(q.data)) | |
builtin.resize(&q.data, int(new_capacity)) or_return | |
if q.offset + q.len > n { | |
diff := n - q.offset | |
copy(q.data[new_capacity-diff:], q.data[q.offset:][:diff]) | |
q.offset += new_capacity - n | |
} |
module luajit | |
#flag -I/usr/local/include/luajit-2.1 | |
#flag -L/usr/local/lib | |
#flag -lluajit-5.1 | |
#flag -lm | |
#include "lua.h" | |
#include "lauxlib.h" | |
pub struct C.lua_State {} |