Skip to content

Instantly share code, notes, and snippets.

View vip3r011's full-sized avatar
🏠
Working from home

vip3r011

🏠
Working from home
  • ZA
View GitHub Profile
@vip3r011
vip3r011 / transactionWrapper.js
Created August 20, 2023 13:30
Mongoose Transaction wrapper
/*
this needs replicaSet to work
*/
const mongoose = require('mongoose');
async function runTransaction(transactionFunction, ...args) {
let session = null;
try {
session = await mongoose.startSession();
@vip3r011
vip3r011 / a-mongodb-replica-set-docker-compose-readme.md
Created August 24, 2023 20:09 — forked from harveyconnor/a-mongodb-replica-set-docker-compose-readme.md
MongoDB Replica Set / docker-compose / mongoose transaction with persistent volume

This will guide you through setting up a replica set in a docker environment using.

  • Docker Compose
  • MongoDB Replica Sets
  • Mongoose
  • Mongoose Transactions

Thanks to https://gist.github.com/asoorm for helping with their docker-compose file!

@vip3r011
vip3r011 / CMWCRand.js
Created January 15, 2024 12:12 — forked from toji/CMWCRand.js
Simple Javascript implementation of CMWC Psuedorandom algorithm
// This was basically ripped straight from http://en.wikipedia.org/wiki/Multiply-with-carry, just javscriptified.
var CMWCRand = function(seed) {
var i, PHI = 0x9e3779b9;
if(!seed) { seed = Date.now(); }
var Q = this.Q = new Uint32Array(4096);
this.c = 362436;
this.i = 4095;
Q[0] = seed;
@vip3r011
vip3r011 / assign_to_cores.sh
Created November 20, 2024 15:26
assign process to specific cpu cores
#!/bin/bash
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <process_name> <cores_list>"
echo "Example: $0 swoole_server 0,1,2"
exit 1
fi
@vip3r011
vip3r011 / fio cheatsheet
Created February 28, 2025 22:47 — forked from githubfoam/fio cheatsheet
fio cheatsheet
-----------------------------------------------------------------------------------------------------
Read Test
fio --name=randread --ioengine=libaio --iodepth=16 --rw=randread --bs=4k --direct=0 --size=512M --numjobs=4 --runtime=240 --group_reporting
-----------------------------------------------------------------------------------------------------
writes a total 2GB files [4 jobs x 512 MB = 2GB] running 4 processes at a time:
fio --name=randwrite --ioengine=libaio --iodepth=1 --rw=randwrite --bs=4k --direct=0 --size=512M --numjobs=4 --runtime=240 --group_reporting
-----------------------------------------------------------------------------------------------------
Read Write Performance Test
fio --randrepeat=1 --ioengine=libaio --direct=1 --gtod_reduce=1 --name=test --filename=random_read_write.fio --bs=4k --iodepth=64 --size=4G --readwrite=randrw --rwmixread=75