Skip to content

Instantly share code, notes, and snippets.

@tristanls
tristanls / iso8601durationregex.js
Last active September 6, 2021 14:53
ISO-8601 Duration Regex
var iso8601durationregex = /^P([0-9]+(?:[,\.][0-9]+)?Y)?([0-9]+(?:[,\.][0-9]+)?M)?([0-9]+(?:[,\.][0-9]+)?D)?(?:T([0-9]+(?:[,\.][0-9]+)?H)?([0-9]+(?:[,\.][0-9]+)?M)?([0-9]+(?:[,\.][0-9]+)?S)?)?$/

Keybase proof

I hereby claim:

  • I am tristanls on github.
  • I am tristanls (https://keybase.io/tristanls) on keybase.
  • I have a public key ASBa6_-Unbrn-U6KcZ0BDRic8CiEH6rfCm6LyTDKDa9xOAo

To claim this, I am signing this object:

@tristanls
tristanls / non_interactive_java_download.md
Created March 8, 2018 23:22
non-interactive Java download
$ curl -LO -b "oraclelicense=a" http://download.oracle.com/otn-pub/java/jdk/9.0.4+11/c2514751926b4512b076cc82f959763f/jdk-9.0.4_linux-x64_bin.tar.gz
@tristanls
tristanls / serverless_contexts.md
Created August 29, 2017 15:48
Contexts where Serveless was useful or not.

Contexts where Serverless turned out useful:

  • When setting up a service control plane (for example commands such as CreateTenant, or DeleteTenant) Serverless is useful as the commands aren't executed often, and the latency is not really a constraint.
  • Processing events from an event stream up to a certain throughput when cost starts to dominate and running dedicated servers (which possibly is "roll your own serverless") becomes a more economical choice.

Contexts where Serverless didn't work well:

  • When setting up a service data plane (for example, proxying a request with minimal latency), Serverless doesn't work well
@tristanls
tristanls / Capability URI Scheme.md
Last active June 27, 2017 00:32
Capability URI Scheme

Capability URI Scheme

The "cpblty" scheme is used to identify capabilities.

There are two types of "cpblty" URIs. They are distinguished by the mechanism used to identify the authority responsible for resolving the capability.

The first type of capability URI uses IP address or DNS resolution to identify authority.

@tristanls
tristanls / secure-local-storage-demo.js
Created June 19, 2016 19:18
Demo of securing local storage with encryption.
"use strict";
const crypto = require("crypto");
const http = require("http");
const url = require("url");
const indexHtml =
`<!doctype html>
<!--[if lt IE 7]><html class="no-js lt-ie9 lt-ie8 lt-ie7"><![endif]-->
<!--[if IE 7]><html class="no-js lt-ie9 lt-ie8"><![endif]-->
sjcl (http://crypto.stanford.edu/sjcl/)
crypto-js (https://code.google.com/p/crypto-js/)
jsCrypto (https://code.google.com/p/jscryptolib/)
triplesec (https://github.com/keybase/triplesec)
polycrypt (https://github.com/polycrypt)
@tristanls
tristanls / node.js
Created October 19, 2013 01:44
node and seed examples for gossipmoner
var Gossipmonger = require('../index.js');
var gossipmonger = new Gossipmonger(
{
id: String(Math.random()*1E17),
transport: {
host: "0.0.0.0",
port: 9742
}
},
@tristanls
tristanls / nVectorDistance.js
Last active December 25, 2015 06:39
Trying to get the math right for great circle distance in JavaScript
var NVector = module.exports = function NVector (x, y, z) {
var self = this;
self.x = x;
self.y = y;
self.z = z;
};
@tristanls
tristanls / typeOneA.js
Created April 19, 2012 12:28
agility-inject multiple files example
var typeOneAPrototype = exports.typeOneAPrototype = $$( {
model : {},
view : {
format : '<div>obj oneA</div>'
}
}); // typeOneAPrototype