Skip to content

Instantly share code, notes, and snippets.

---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
labels:
run: nginx
name: nginx
spec:
@protometa
protometa / examples.js
Last active October 20, 2017 20:58
Async In Javascript
const {
queryDatabaseSync,
httpGetSync,
writeFileSync,
queryDatabase,
httpGet,
writeFile
} = require('./mocks.js')
// synchronous:

Keybase proof

I hereby claim:

  • I am protometa on github.
  • I am lukenimtz (https://keybase.io/lukenimtz) on keybase.
  • I have a public key ASCyRCYeTbb4WuePEN_uLDSKGe1Z5PC-FYmISN7HPrchNwo

To claim this, I am signing this object:

@protometa
protometa / pagination-stream.js
Created June 9, 2017 16:54
Paging JSON API as a lazy Highland stream
const _ = require('highland')
const JSONstream = require('JSONstream')
require('isomorphic-fetch')
const highlandFetch = require('highland-fetch')
Response.prototype.highland = highlandFetch.highlandResponse
#!/bin/bash
# make dummy certs
mkdir ssl/
cd ssl/
# CA key
openssl genrsa -passout pass:1111 -des3 -out ca.key 4096
# CA cert
openssl req -passin pass:1111 -new -x509 -days 365 -key ca.key -out ca.crt -subj '/C=US/ST=Oregon/L=Portland/O=Test/OU=CertAuthority/CN=localhost'
# server key
openssl genrsa -passout pass:1111 -des3 -out server.key 4096

Why Behemoth Gates are used instead of normal walls

A Stone Behemoth Gate costs [900 stone, 900 wood, and 900 thatch for the gateway][1] and [450 stone, 450 wood, and 450 thatch for the gate itself][2] for a total of 1350 stone, 1350 wood, and 1350 thatch. A Stone Behemoth Gate is [7 units wide and 12 units high][1] giving a total area of 84 wall units. Stone walls cost [40 stone, 20 wood, and 15 thatch][3]. Stone Walls must be placed on foundations. Stone Fence Foundations cost [15 stone, 10 wood, and 10 thatch][4]. So a 7 unit wide and 12 unit high section made from stone walls would cost 7 * (F + 12 * W) where F is the resources for the foundation and W is the resources for the wall. This comes out to 3465 stone, 1750 wood, 1330 thatch for the same area of wall. The Behemoth Gate approach saves 2115 stone, 400 wood, and only cost 20 more thatch vs the normal wall approach. Therefore the Behemoth Gate is a more economical way to build a wall.

Not so fast...

Why Behemoth Gates should not be used

@protometa
protometa / geometric-algebra.md
Last active February 1, 2017 19:43
Geometric Algebra
0 # zero order identity element
N_1 = O -> N
I_1 = O -> I # first order identity element
N_2 = I_1 -> N_1
E_2 = I_1 -> E_1 # second order identity element
N_3 = E_2 -> N_2
@protometa
protometa / gist:431f2b6e7e89a2073b5d
Last active November 17, 2015 23:14
Abelian Exponentiation - A Generalization of Fields with More than Two Binary Operations

Abelian Exponentiation

3 ** 4 = 9
4 ** 3 = 9

where
x ** 2 = x

x // x = 2

@protometa
protometa / promisize.coffee
Last active August 29, 2015 13:56
Async promises within sync code hack with promisizer
Q = require 'q'
promisize = (fn, args... ) ->
promises = []
getpromises = ( p ) ->
promises.push( p )
@protometa
protometa / docpad-bootstrap-breadcrumbs-mixin.jade
Last active January 4, 2016 17:59
DocPad Jade Bootstrap Breadcrumbs Mixin
mixin crumbs
ol.breadcrumb
li: a(href="/") Home
- var url = document.url.split("/").slice(1)
each dir, index in url
- var doc = getCollection("html").findOne({ url: "/"+url.slice(0,index+1).join("/") })
if url.length - index == 1
li(class= "active" )= doc ? doc.toJSON().title : dir
else
if doc