Skip to content

Instantly share code, notes, and snippets.

View samolabams's full-sized avatar

samolabams

  • Lagos, Nigeria
View GitHub Profile
export type Response<T, E> = Ok<T, E> | Err<T, E>;
class Ok<T, E> {
readonly value: T;
constructor(value: T) {
this.value = value;
}
isOk(): this is Ok<T, E> {
@samolabams
samolabams / jest-config
Created April 4, 2022 14:53
Jest config
module.exports = {
clearMocks: true,
coverageDirectory: 'coverage',
coveragePathIgnorePatterns: [
'/node_modules/',
'/__fixtures__/',
'/__tests__/',
'/(__)?mock(s__)?/',
'/__jest__/',
'.?.min.js',
@samolabams
samolabams / queue.go
Created November 1, 2021 15:45 — forked from harrisonturton/queue.go
RabbitMQ client that automatically reconnects when the connection fails, and has a confirmed push method (i.e. the server is guaranteed to recieve the message)
package main
import (
"errors"
"github.com/streadway/amqp"
"log"
"os"
"time"
)
@samolabams
samolabams / caller.go
Created November 1, 2021 15:45 — forked from ribice/caller.go
A robust rabbitmq client for Go
go func() {
for {
err = rmq.Stream(cancelCtx)
if errors.Is(err, rabbitmq.ErrDisconnected) {
continue
}
break
}
}()
@samolabams
samolabams / service-checklist.md
Created October 18, 2021 16:57 — forked from acolyer/service-checklist.md
Internet Scale Services Checklist

Internet Scale Services Checklist

A checklist for designing and developing internet scale services, inspired by James Hamilton's 2007 paper "On Desgining and Deploying Internet-Scale Services."

Basic tenets

  • Does the design expect failures to happen regularly and handle them gracefully?
  • Have we kept things as simple as possible?
function loadModule(filename, module, require) {
const wrappedSrc = `
function(module, exports, require) {
${fs.readFileSync(filename, 'utf8')}
}(module, module.exports, require)
`;
eval(wrappedSrc);
}
@samolabams
samolabams / 1-install.sh
Created January 9, 2020 12:26 — forked from kevinswiber/1-install.sh
Kubernetes resources for standing up Express Gateway
#!/bin/bash
kubectl create -f https://gist.githubusercontent.com/kevinswiber/e6a8245930676c3da3448b2bb79f23fd/raw/0869b72410851e2ab02d0c1c30443f4083345066/configmap.yaml
kubectl create -f https://gist.githubusercontent.com/kevinswiber/e6a8245930676c3da3448b2bb79f23fd/raw/0869b72410851e2ab02d0c1c30443f4083345066/deployment.yaml
kubectl create -f https://gist.githubusercontent.com/kevinswiber/e6a8245930676c3da3448b2bb79f23fd/raw/0869b72410851e2ab02d0c1c30443f4083345066/service.yaml
@samolabams
samolabams / virtualbox_restart.md
Created January 9, 2020 10:36 — forked from bwoodmansee/virtualbox_restart.md
Restart VirtualBox on OS X

sudo /Library/StartupItems/VirtualBox/VirtualBox restart

New Virtualbox: sudo launchctl load /Library/LaunchDaemons/org.virtualbox.startup.plist

@samolabams
samolabams / socket-cheatsheet.js
Created January 10, 2019 15:27 — forked from alexpchin/socket-cheatsheet.js
A quick cheatsheet for socket.io
// sending to sender-client only
socket.emit('message', "this is a test");
// sending to all clients, include sender
io.emit('message', "this is a test");
// sending to all clients except sender
socket.broadcast.emit('message', "this is a test");
// sending to all clients in 'game' room(channel) except sender
@samolabams
samolabams / Laravel-Container.md
Created December 19, 2018 13:51
Laravel's Dependency Injection Container in Depth

Laravel's Dependency Injection Container in Depth

Translations: Korean (by Yongwoo Lee)

Laravel has a powerful Inversion of Control (IoC) / Dependency Injection (DI) Container. Unfortunately the official documentation doesn't cover all of the available functionality, so I decided to experiment with it and document it for myself. The following is based on Laravel 5.4.26 - other versions may vary.

Introduction to Dependency Injection

I won't attempt to explain the principles behind DI / IoC here - if you're not familiar with them you might want to read What is Dependency Injection? by Fabien Potencier (creator of the Symfony framework).