Skip to content

Instantly share code, notes, and snippets.


ORES ORESoftware

View GitHub Profile
ORESoftware /
Last active May 28, 2019
Cleanup docker artifacts/items

Clean up docker images/containers/volumes/networks

#!/usr/bin/env bash

set +e;
ORESoftware /
Last active Jan 28, 2019
Readers-writer lock for payment processing

No official CS education but I learned about readers-writer locks after implementing a mutex library. I happened to come across a real-world use case that I would need this for.

Say we have many people signing up to take a class, their payment (through Stripe, or whatever) might be in flight. And imagine the teacher cancels the class, which would trigger a refund event.

Without proper locking, the refund might fail to execute for those students whose payments are in flight at the time of the class cancelation.

ORESoftware /
Created Dec 16, 2018
Simple use cases for Node.js domain module

First run this code:

const exec = () => {
   setTimeout(() => {
      throw 'nothing can catch this, except domains';
ORESoftware / stringifiable.ts
Last active Jul 8, 2018
stringifiable type with TS
View stringifiable.ts
export type Stringifiable = object | string | boolean | number | null;
export const stdMarker = 'gfy';
export const getJSONCanonical = function (v: Stringifiable, marker?: string) {
marker = marker || stdMarker;
ORESoftware / obs-vs-promises-resolution.js
Last active Jan 14, 2017
Async or sync resolution?
View obs-vs-promises-resolution.js
new Promise(function(resolve,reject){
View promises-vs-rxjs.js
const Rx = require('rxjs');
new Promise(function(resolve,reject){
View create-queue.js
// import opq
const Queue = require('opq');
// below we create a new client to the queue,
// and create the queue on the filesystem if it does
// not exist. the port is used by Live-Mutex;
// fp is our queue filepath
const q = new Queue({
ORESoftware / async-constructor.js
Last active Jan 14, 2017
An asynchronous constructor pattern
View async-constructor.js
// asynchronous constructor example,
// like always do not explictly return anything from the constructor
function Queue(){
this.ready = false;
let callable = true;
let ee = new EE(); // new event emitter
Xaekai / ipc.example.js
Created Jul 11, 2016
Example of Interprocess communication in Node.js through a UNIX domain socket
View ipc.example.js
** Example of Interprocess communication in Node.js through a UNIX domain socket
** Usage:
** server> MODE=server node ipc.example.js
** client> MODE=client node ipc.example.js
Boerworz / main.go
Last active Apr 10, 2021
Capturing the HTTP status code from http.ResponseWriter
View main.go
package main
import (
func main() {
// We need to cast handleRoot to a http.HandlerFunc since wrapHandlerWithLogging