Skip to content

Instantly share code, notes, and snippets.

iex(14)> ring = HashRing.new() |> HashRing.add_node(:a) |> HashRing.add_node(:b)
#<Ring[:a, :b]>
iex(15)> [:foo, :bar, :baz, :flop] |> Enum.each(fn(k) -> IO.puts(HashRing.key_to_node(ring, k)) end)
b
b
b
a
:ok
iex(16)> ring = HashRing.add_node(ring, :c)
#<Ring[:a, :c, :b]>
@sikanrong
sikanrong / nvimrc.vim
Created January 25, 2020 23:47
My Neovim Configuration
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
@sikanrong
sikanrong / universal-interceptor.ts
Created April 26, 2020 18:10
An Angular Universal interceptor which handles HTTP requests to relative routes to local files. Fixes prerender errors for Angular applications which do this.
import {Injectable, Inject, Optional} from '@angular/core';
import {
HttpInterceptor,
HttpHandler,
HttpRequest,
HttpHeaders,
HttpResponse,
HttpErrorResponse
} from '@angular/common/http';
import {Request} from 'express';
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "dumb_agent",
"type": "python",
"request": "launch",
from concurrent.futures import ProcessPoolExecutor, wait
from multiprocessing import Manager
from argparse import ArgumentParser
from concurrent.futures import Future
from typing import List, Dict
import fastparquet
import os
import pandas as pd
import numpy as np