Skip to content

Instantly share code, notes, and snippets.

@kbrsh
kbrsh / key.js
Last active November 30, 2016 23:00
Key - generate a random token
var crypto = require('crypto');
var apiKey = function(cb) {
crypto.randomBytes(7, function (err, bytes) {
key = new Buffer((new Date().valueOf()) + (bytes).toString('hex')).toString('base64');
cb(key);
});
}
@kbrsh
kbrsh / kms.js
Last active May 21, 2017 01:42
Search Algorithms
const createTable = function(item, length) {
let table = new Array(length);
table[0] = 0;
for(let i = 1; i < length; i++) {
var section = item.substring(0, i + 1);
var sectionLength = section.length;
var val = 0;
for(let j = sectionLength - 1; j > 0; j--) {
@kbrsh
kbrsh / bars.js
Last active June 29, 2017 16:30
Bars - Bar graph component for Moon
(function(root, factory) {
/* ======= Global Moon Bars ======= */
(typeof module === "object" && module.exports) ? module.exports = factory() : root.MoonBars = factory();
}(this, function() {
var pad = function(section) {
if(section.length === 1) {
return "0" + section;
} else {
return section;
@kbrsh
kbrsh / galaxy.py
Last active September 1, 2017 04:58
Galaxy - Spread Stars
from slackclient import SlackClient
from random import randint
import re
import time
import sqlite3
import os
userRE = re.compile("<@([\w\d]+)>")
db = sqlite3.connect("Galaxy.db")
@kbrsh
kbrsh / README.md
Last active October 27, 2017 16:28
Slash - Fast, efficient hash

Slash

Fast, efficient hash

Usage

char *str = "Slash";
unsigned long long hash = slash(str);

Keybase proof

I hereby claim:

  • I am kbrsh on github.
  • I am kbrsh (https://keybase.io/kbrsh) on keybase.
  • I have a public key ASCH4EtLMIQskNSeqTlq8KR7V97M12QLBJG61Qn3i-_LAQo

To claim this, I am signing this object: