Skip to content

Instantly share code, notes, and snippets.

View jirevwe's full-sized avatar
😁

Raymond Tukpe jirevwe

😁
View GitHub Profile
@jirevwe
jirevwe / docker-compose.yml
Created July 12, 2023 16:20
Local Redis Cluster Setup
version: "3"
services:
redis1:
image: redis:latest
command: redis-server --port 7001 --cluster-enabled yes --cluster-config-file nodes.conf --cluster-node-timeout 5000 --appendonly yes --cluster-announce-ip 172.16.0.11 --cluster-announce-port 7001
ports:
- 7001:7001
volumes:
- ./data/redis1:/data
@jirevwe
jirevwe / go.mod
Created September 13, 2022 16:00
migrate from Convoy v0.6.0-rc.5 to 0.6.7
module github.com/frain-dev/migrate
go 1.19
require go.mongodb.org/mongo-driver v1.10.2
require (
github.com/golang/snappy v0.0.1 // indirect
github.com/klauspost/compress v1.13.6 // indirect
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect
@jirevwe
jirevwe / twitter.go
Created July 7, 2022 13:27 — forked from subomi/twitter.go
Set up Twitter webhooks in Golang.
// Generate webhook URL.
package main
import (
"errors"
"fmt"
"io/ioutil"
"net/http"
"net/url"
"time"
@jirevwe
jirevwe / index.ts
Last active June 12, 2021 12:45
NodeJs Worker Pool with Callback
const sleep = (ms = 1000) => new Promise((resolve) => setTimeout(resolve, ms));
async function start() {
const execFile = join(__dirname, './worker/index.js');
const pool = new ThreadPool<number, number>({
execFile,
jobCallback,
timeOutCallback,
debug: true,
threadTimeout: 3

JSend

Throughout all GoMoney services, we implement the JSend specification for serving API responses. More detail can be found on the omniti-labs/jsend github repo. But in a nutshell, this middleware attaches a JSend object to each request with success, fail, and error methods that can then be invoked later on. This means our responses usually follow the same general formats.

Successes

{
  "status" : "success",
 "data" : {
fun <V : View> Activity.bind(@IdRes resource: Int): V {
val lazyValue: Lazy<V> = lazy { findViewById(resource) }
return lazyValue.value
}
import faker from 'faker';
/**
* Faker polyfill method `middleName`
*
* @method middleName
* @param {mixed} gender
* @memberof faker.name
*/
faker.name['middleName'] = function(gender) {
Process: Viso [50893]
Path: /Applications/Viso.app/Contents/MacOS/Viso
Identifier: com.viso.Viso
Version: 4 (6)
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: Viso [50893]
User ID: 501
Date/Time: 2019-06-24 22:08:36.989 +0100
@jirevwe
jirevwe / generate_report.ts
Last active June 8, 2019 10:27
Walk through a collection using a child process
const WALLET_REPORT = '../../WalletReport.xlsx';
class GenerateReport {
wallets: Wallet[] = [];
duration: number = 0;
constructor() {
writeFileSync(join(__dirname, WALLET_REPORT), '');
}
@jirevwe
jirevwe / mongoose-walk.ts
Last active June 7, 2019 17:45
Walks through the records in a mongoose collection using a number of cursors
const start_time = performance.now();
const count: number = 1000;
const wallets: Wallet[] = [];
const walletCount = await WalletModel.find({}).estimatedDocumentCount();
// create a cursor for every `currentIndex` documents in the collection
const getNthCursor = async (currentIndex: number) =>
await WalletModel.find({ deleted_at: undefined }, { timeout: false })
.lean()