Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View mstaicu's full-sized avatar

Mircea Staicu mstaicu

  • Earth
View GitHub Profile
@mstaicu
mstaicu / README.md
Last active December 5, 2023 13:42
Barebones NATS JetStream clustering in Kubernetes with PVC and no Helm charts
import crypto from "crypto";
import { renderToStaticMarkup } from "react-dom/server";
import createMailgun from "mailgun-js";
import type { ActionFunction, LoaderFunction, Session } from "remix";
import { createCookieSessionStorage, json, redirect } from "remix";
/*******************************************************************************
* Before we can do anything, we need to make sure the environment has
* everything we need. If anything is missing, we just prevent the app from
* starting up.
@mstaicu
mstaicu / VibrateModule.java
Created July 8, 2021 11:59
React Native BroadcastReceiver Vibrations
package com.mindfulness.vibrate;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
@mstaicu
mstaicu / mellon.sh
Created January 14, 2021 15:37
Debug shell scripts
#!/bin/bash
trap '(read -p "[$BASH_SOURCE:$LINENO] $BASH_COMMAND?")' DEBUG
var="mellon"
echo "$var"
@mstaicu
mstaicu / package.json
Created September 30, 2020 15:08
npx test
{
"name": "testing-npx",
"version": "1.0.0",
"description": "Let's see how awesome this is",
"bin": "./run.js"
}
@mstaicu
mstaicu / semaphore.js
Last active September 12, 2020 11:36
@nybblr inspired semaphore solution for limiting concurrent execution
/**
* OOP paradigm
*/
class Semaphore {
constructor(max) {
this.tasks = [];
this.counter = max;
this.dispatch = this.dispatch.bind(this);
}
@mstaicu
mstaicu / osx-for-hackers.sh
Created November 9, 2019 12:51 — forked from brandonb927/osx-for-hackers.sh
OSX for Hackers: Yosemite/El Capitan Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned.
#!/bin/sh
###
# SOME COMMANDS WILL NOT WORK ON macOS (Sierra or newer)
# For Sierra or newer, see https://github.com/mathiasbynens/dotfiles/blob/master/.macos
###
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/5b3c8418ed42d93af2e647dc9d122f25cc034871/.osx
@mstaicu
mstaicu / init.vim
Last active January 14, 2021 12:38
Neovim draft configuration file
"Variables {{{
let mapleader=","
" }}}
" Globals {{{
syntax enable
set fileencoding=utf-8
set listchars=space:· " show whitespaces as dots
@mstaicu
mstaicu / Flow.js
Created February 18, 2019 11:35
Promise composition for async control flow
function retry(fn) {
return function(data) {
return new Promise((resolve, reject) => {
var retries = 10,
error;
function attempt() {
if (retries === 0) {
reject(error);
}
@mstaicu
mstaicu / event-loop.md
Created February 12, 2018 20:23 — forked from jesstelford/event-loop.md
What is the JS Event Loop and Call Stack?

Regular Event Loop

This shows the execution order given JavaScript's Call Stack, Event Loop, and any asynchronous APIs provided in the JS execution environment (in this example; Web APIs in a Browser environment)


Given the code