This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE FUNCTION jb_merge(jsonb, jsonb) | |
RETURNS jsonb | |
IMMUTABLE | |
LANGUAGE SQL | |
AS $$ | |
WITH xxx AS | |
(SELECT * FROM jsonb_each_text($1) | |
UNION ALL | |
SELECT * FROM jsonb_each_text($2)) | |
SELECT json_object_agg(key, value)::jsonb FROM xxx; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE OR REPLACE FUNCTION public.json_append(data json, insert_data json) | |
RETURNS json | |
IMMUTABLE | |
LANGUAGE sql | |
AS $$ | |
SELECT ('{'||string_agg(to_json(key)||':'||value, ',')||'}')::json | |
FROM ( | |
SELECT * FROM json_each(data) | |
UNION ALL | |
SELECT * FROM json_each(insert_data) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# As the "bufferbloat" folks have recently re-discovered and/or more widely | |
# publicized, congestion avoidance algorithms (such as those found in TCP) do | |
# a great job of allowing network endpoints to negotiate transfer rates that | |
# maximize a link's bandwidth usage without unduly penalizing any particular | |
# stream. This allows bulk transfer streams to use the maximum available | |
# bandwidth without affecting the latency of non-bulk (e.g. interactive) | |
# streams. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// keccak | |
// | |
// Implementation derived from https://github.com/floodyberry/scrypt-jane | |
// | |
// Ported by Devi Mandiri. Public domain | |
// | |
var u64 = function (h, l) { | |
h = h|0; l = l|0; | |
this.hi = h >>> 0; | |
this.lo = l >>> 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// keccak | |
// | |
// Implementation derived from https://github.com/floodyberry/scrypt-jane | |
// | |
// Ported by Devi Mandiri. Public domain | |
// | |
var u64 = function (h, l) { | |
h = h|0; l = l|0; | |
this.hi = h >>> 0; | |
this.lo = l >>> 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(exports) { | |
'use strict'; | |
// Blake2b | |
// Ported by Devi Mandiri. Public domain. | |
var u64 = function (h, l) { | |
h = h|0; l = l|0; | |
this.hi = h >>> 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* sha512 */ | |
// Written in 2014 by Devi Mandiri. Public domain. | |
// | |
// Implementation derived from TweetNaCl version 20140427. | |
// See for details: http://tweetnacl.cr.yp.to/ | |
// | |
var u64 = function (h, l) { | |
h = h|0; l = l|0; | |
this.hi = h >>> 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* poly1305 */ | |
// Written in 2014 by Devi Mandiri. Public domain. | |
// | |
// Implementation derived from poly1305-donna-16.h | |
// See for details: https://github.com/floodyberry/poly1305-donna | |
var Poly1305BlockSize = 16; | |
var Poly1305Ctx = function() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* chacha20 - 256 bits */ | |
// Written in 2014 by Devi Mandiri. Public domain. | |
// | |
// Implementation derived from chacha-ref.c version 20080118 | |
// See for details: http://cr.yp.to/chacha/chacha-20080128.pdf | |
var Chacha20KeySize = 32; | |
var Chacha20NonceSize = 8; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// helper for dealing with uint64 | |
var u64 = function (h, l) { | |
h = h|0; l = l|0; | |
this.hi = h >>> 0; | |
this.lo = l >>> 0; | |
} | |
function new64(num) { | |
var hi = 0, lo = num >>> 0; | |
if ((+(Math.abs(num))) >= 1) { |
NewerOlder