Skip to content

Instantly share code, notes, and snippets.

@johnnyeric
johnnyeric / simple-trie.go
Last active March 11, 2022 15:50
Simple Trie implementation in Golang
package trie
type Node struct {
Children [26]*Node
Char rune
IsRoot bool
IsWordEnd bool
}
type Trie struct {
@johnnyeric
johnnyeric / bulletpaths.js
Created October 17, 2021 11:13 — forked from azlen/bulletpaths.js
All Paths Lead to Roam
/*
* credit to Dhrumil Shah (@wandcrafting) and Robert Haisfield (@RobertHaisfield)
* for the original concept which was part of their RoamGames submission
* and can be found at: https://www.figma.com/file/5shwLdUCHxSaPNEO7pazbe/
*
*/
/* ======= OPTIONS ======== */
/* note: if you change these, reload the page to see the effect */
@johnnyeric
johnnyeric / MinHeap.js
Last active June 21, 2020 15:25
Min Heap JavaScript implementation
// Based on AlgoExpert's version
class MinHeap {
heap = null;
constructor(array) {
this.heap = array;
this.buildHeap();
}
@johnnyeric
johnnyeric / callbacks.rs
Created April 15, 2019 09:30 — forked from aisamanra/callbacks.rs
Creating a HashMap of closures in Rust
#![feature(unboxed_closures)]
#![feature(core)]
#![feature(io)]
use std::old_io::stdio::{stdin};
use std::collections::HashMap;
// This is our toy state example.
#[derive(Debug)]
struct State {
@johnnyeric
johnnyeric / main.js
Last active September 19, 2018 08:10
Reproduce `docker run` via Node.js - Execute one-off commands based on stdin.
/*
* To keep this code short I am not dealing with error handling, security details, etc.
*/
const run = require('./run');
(async () => {
const stdin = 'hello world';
const stdout = await run(stdin);
@johnnyeric
johnnyeric / K8s-DigitalOcean-CoreOS.md
Created August 26, 2018 16:18 — forked from kevashcraft/K8s-DigitalOcean-CoreOS.md
How to Setup Kubernetes on DigitalOcean with CoreOS

Kubernetes on DigitalOcean with CoreOS

Let's look at an example of how to launch a Kubernetes cluster from scratch on DigitalOcean, including kubeadm, an Nginx Ingress controller, and Letsencrypt certificates.

Overview

Environment

We'll be creating a four-node cluster (k8s-master, k8s-000...k8s-002), load balancer, and ssl certificates.

Table of Contents

  1. Install Kubernetes
@johnnyeric
johnnyeric / simple-pagination.js
Created November 20, 2017 06:08 — forked from kottenator/simple-pagination.js
Simple pagination algorithm
// Implementation in ES6
function pagination(c, m) {
var current = c,
last = m,
delta = 2,
left = current - delta,
right = current + delta + 1,
range = [],
rangeWithDots = [],
l;
@johnnyeric
johnnyeric / Dockerfile.app
Created June 18, 2017 23:06 — forked from dalanmiller/Dockerfile.app
RethinkDB docker-compose.yml example
IMAGE node:argon
RUN mkdir -p /usr/app
COPY . /usr/app
WORKDIR /usr/app
RUN npm install
@johnnyeric
johnnyeric / json.lua
Created May 2, 2017 23:55 — forked from tylerneylon/json.lua
Pure Lua json library.
--[[ json.lua
A compact pure-Lua JSON library.
The main functions are: json.stringify, json.parse.
## json.stringify:
This expects the following to be true of any tables being encoded:
* They only have string or number keys. Number keys must be represented as
strings in json; this is part of the json spec.
@johnnyeric
johnnyeric / tcp-socketio-sample.js
Created February 9, 2017 22:37 — forked from maripiyoko/tcp-socketio-sample.js
Node.js Tcp server & Socket.io
// socket io
var app = require('http').createServer(handler),
io = require('socket.io').listen(app),
fs = require('fs');
app.listen(3000, function() {
console.log('Socket IO Server is listening on port 3000');
});
function handler(req, res) {