Skip to content

Instantly share code, notes, and snippets.

View rvanmil's full-sized avatar

René van Mil rvanmil

View GitHub Profile
@rvanmil
rvanmil / oplog.js
Last active May 22, 2019 08:38
parse mongodb oplog
const fs = require('fs')
fs.readFile('./oplog.dump', 'utf-8', (err, jsonString) => {
const oplog = JSON.parse(jsonString)
const operationsMap = new Map()
oplog.forEach((oplogItem) => {
const { ns, op } = oplogItem
let operation = operationsMap.get(ns)
if (operation) {
if (op === 'd') {
@rvanmil
rvanmil / async.js
Created November 29, 2018 11:19
Parallel and sequential async processing
const randomTimeout = () => Math.floor(Math.random() * (3000 - 500)) + 500
const someAsyncProcess = message => new Promise(resolve => setTimeout(() => {
console.log(message)
resolve()
}, randomTimeout()))
const messages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
const testParallel = async () => Promise.all(messages.map(async message => someAsyncProcess(message)))
@rvanmil
rvanmil / zcl_bitwise.abap
Last active September 14, 2021 14:15
ABAP bit shifting and bitwise add, subtract, multiply
class ZCL_BITWISE definition
public
final
create public .
public section.
*"* public components of class ZCL_BITWISE
*"* do not include other source files here!!!
class-methods CLASS_CONSTRUCTOR .