Skip to content

Instantly share code, notes, and snippets.

Andrew Meredith kendru

Block or report user

Report or block kendru

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
kendru /
Created Aug 27, 2019
Configuring a gcloud profile

Configuring a gcloud profile

  1. Create a new profile:
luther:~ ameredith$ gcloud config configurations create my-profile
Created [my-profile].
Activated [my-profile].
  1. Authenticate with Google
kendru /
Created Jul 15, 2019
Example implementation of the visitor pattern in Rust
pub trait Visitable {
fn accept<V: Visitor>(&self, visitor: &mut V) -> V::Result;
pub trait Visitor {
type Result;
fn visit_num(&mut self, num: &Num) -> Self::Result;
fn visit_add<T, U>(&mut self, add: &Add<T, U>) -> Self::Result
View index.html
<!DOCTYPE html>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style id="jsbin-css">
.editor {
position: absolute;
min-height: 100%;
kendru / name-scrubber.js
Last active May 9, 2019
Removes names from the DOM
View name-scrubber.js
// XXHash
!function(t,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports.XXH=r():t.XXH=r()}(this,function(){return function(t){function r(e){if(i[e])return i[e].exports;var o=i[e]={i:e,l:!1,exports:{}};return t[e].call(o.exports,o,o.exports,r),o.l=!0,o.exports}var i={};return r.m=t,r.c=i,r.d=function(t,i,e){r.o(t,i)||Object.defineProperty(t,i,{configurable:!1,enumerable:!0,get:e})},r.n=function(t){var i=t&&t.__esModule?function(){return t["default"]}:function(){return t};return r.d(i,"a",i),i},r.o=function(t,r){return,r)},r.p="",r(r.s=2)}([function(t,r,i){"use strict";(function(t){function e(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(r){return!1}}function o(){return n.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function h(t,r
kendru /
Last active Oct 12, 2018
Test dispatching command to an Actix actor system
extern crate actix;
extern crate actix_web;
extern crate futures;
use std::thread;
use std::io::{self, Write};
use actix::prelude::*;
use actix_web::{Error as ActixWebError, HttpMessage};
use actix_web::client;
use futures::future::{self, Future};
kendru / db.js
Created Aug 30, 2018
Simple database that packs records into contiguous memory
View db.js
const POOL_SIZE = 4 * 1024;
let mySchema = ['int32', 'char(32)', 'int32'];
let bufferPool = new ArrayBuffer(POOL_SIZE);
let dir = {
tbl: {
people: { offset: 0, size: 0 }
kendru / Bucket.js
Created Feb 23, 2018
Simple token bucket implementation
View Bucket.js
class Bucket {
constructor(size, per) {
this.per = per;
this.size = size;
this.lastFilled = Math.floor( / 1000);
this.tokens = size;
take() {
kendru / async-work-queue.js
Created Feb 9, 2018
Asynchronous work queue
View async-work-queue.js
const promise_ = Symbol('promise');
class Deferred {
constructor() {
this[promise_] = new Promise((resolve, reject) => {
this.resolve = resolve;
this.reject = reject;
kendru /
Last active Dec 27, 2018
Set up a throw-away mysql server in docker and a client to connect to it
cleanup_db() {
docker stop mysql_sandbox &>/dev/null
docker rm mysql_sandbox &>/dev/null
docker network inspect mysql_sandbox > /dev/null 2>&1
if [[ "$?" == "0" ]]; then
docker network rm mysql_sandbox
kendru / findNode.js
Last active Oct 31, 2017
Find a node matching a predicate in a generic JS tree
View findNode.js
function findNode(node, pred) {
if (pred(node)) {
return node;
if (typeof node == 'object' && node.constructor == Object) {
for (var prop in node) {
if (node.hasOwnProperty(prop)) {
let foundNode = findNode(node[prop], pred);
You can’t perform that action at this time.