Skip to content

Instantly share code, notes, and snippets.

View alexandrugheorghe's full-sized avatar

Alexandru Gheorghe alexandrugheorghe

View GitHub Profile
### Keybase proof
I hereby claim:
* I am alexandrugheorghe on github.
* I am alexandrugheorgh (https://keybase.io/alexandrugheorgh) on keybase.
* I have a public key ASApzwqa82U53T1aGb4V4yzvmV4U0ha73NtkTgFPgqJbhAo
To claim this, I am signing this object:
@alexandrugheorghe
alexandrugheorghe / machine.js
Last active March 31, 2020 09:03
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@alexandrugheorghe
alexandrugheorghe / calculate.php
Created November 13, 2017 09:25
PHP Multiprocess
<?php
ini_set('memory_limit','512M');
CONST WORKER_POOL = 3;
CONST INPUT_FILE = 'in.txt';
CONST OUTPUT_FILE = 'out.txt';
CONST PROCESS_DESCRIPTORS = [0 => ['pipe', 'r'], 1 => ['pipe', 'w'], 2 => ['file', 'error.log', 'a']];
$workers = [];
$pipes = [];
@alexandrugheorghe
alexandrugheorghe / removeMongoRefs.js
Created March 13, 2017 14:14
Remove MongoDB ObjectIds and DBRefs and replaces them with their string values.
var docsQueue = [];
function processRefs(document, field)
{
for(var field in document) {
if (document[field] instanceof Array) {
for(var embededDoc in document[field]){
if (document[field][embededDoc] instanceof DBRef) {
document[field][embededDoc] = document[field][embededDoc]["$id"].str;
} else if (document[field][embededDoc] instanceof DBRef) {