Skip to content

Instantly share code, notes, and snippets.

🐈
stray

hisanori paulownia

🐈
stray
Block or report user

Report or block paulownia

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View consistent_hash.js
const crypto = require('crypto');
class ConsistentHash {
/**
* create new consistent hash object
*
* @param nodeList - node id list
* @param vnSize - number of virtual node (default 100)
* @param algorithm - hash algorithm (default md5)
*/
View fisher_yates_shuffle.js
function shuffle(arr) {
for (let i = arr.length; i > 1;) {
const j = Math.floor(Math.random() * i);
i--;
const ie = arr[i];
arr[i] = arr[j];
arr[j] = ie;
}
}
View keybase.md

Keybase proof

I hereby claim:

  • I am paulownia on github.
  • I am nullpon (https://keybase.io/nullpon) on keybase.
  • I have a public key ASB4dUVrQZrNE2T0n2auSp3-eEKdbYE0QEWH2gs2y_U29go

To claim this, I am signing this object:

@paulownia
paulownia / base64.js
Created Jul 6, 2019
base64 encode/decode using Uint8Array on browser
View base64.js
const table = [];
for (let i = 65; i < 91; i++) table.push(String.fromCharCode(i));
for (let i = 97; i < 123; i++) table.push(String.fromCharCode(i));
for (let i = 0; i < 10; i++) table.push(i.toString(10));
table.push("+");
table.push("/");
const rev_table = table.reduce((obj, c, i) => {
obj[c] = i;
return obj;
View leftpad-test.js
'use strict';
function leftpad1(str, len, ch) {
str = String(str);
var i = -1;
if (!ch && ch !== 0) ch = ' ';
len = len - str.length;
View Main.java
/*
* https://gist.github.com/kazuho/3300555
*/
import java.util.Iterator;
public class Main {
public static void main(String[] args) {
FizzBuzz fb = new FizzBuzz(30);
for (String s: fb) {
System.out.println(s);
View Main.java
/*
* https://gist.github.com/kazuho/3300555
*/
import java.util.Iterator;
public class Main {
public static void main(String[] args) {
FizzBuzz fb = new FizzBuzz(30);
for (String s: fb) {
System.out.println(s);
You can’t perform that action at this time.