Skip to content

Instantly share code, notes, and snippets.

View pyramation's full-sized avatar
💭
🏄🏻‍♂️

Dan Lynch pyramation

💭
🏄🏻‍♂️
View GitHub Profile
const bitcoin = require('bitcoinjs-lib');
var privatekey = process.argv[2]
// NOTE: only wif and pubKeyHash are correct, they were all that is needed for this function to work
const pair = bitcoin.ECPair.fromWIF(privatekey, {
messagePrefix: '\x19Denarius Signed Message:\n',
bip32: {
public: 0x019da462, // TODO DONT USE
private: 0x019d9cfe // TODO DONT USE
@pyramation
pyramation / pod-logs
Last active October 17, 2018 03:11
k8s bash helpers
#!/bin/bash
if [ -z "$2" ]
then
echo "Usage: $(basename $0) <namespace> <app>"
exit 1
fi
POD=$(kubectl get pods -n $1 -l app=$2 -o jsonpath="{.items[*].metadata.name}")
kubectl logs -n $1 $POD -f
@pyramation
pyramation / fit.js
Created February 1, 2019 23:05
fit function
function fit(num, oldmin, oldmax, newmin, newmax) {
const ratio = (num - oldmin) / (oldmax - oldmin);
return newmin + ratio * (newmax - newmin);
}
@pyramation
pyramation / .npmrc
Created April 5, 2019 19:36
npm private modules on openfaas
//registry.npmjs.org/:_authToken=${NPM_TOKEN}
@pyramation
pyramation / .npmrc
Last active April 5, 2019 19:37
npm private modules on openfaas
//registry.npmjs.org/:_authToken=${NPM_TOKEN}
@pyramation
pyramation / cssom-json.js
Created December 20, 2016 06:08
serialize and deserialize CSSOM StyleSheet objects to JSON and back
var CSSOM = require('cssom');
/**
* @param {Object} object
* @return {Object}
*/
function uncircularOwnProperties(object) {
function _uncircular(object, depth, stack) {
var stackLength = stack.push(object);
depth++;
@pyramation
pyramation / 0-explain.md
Last active June 21, 2020 09:26
pseudo ordered uuids w modulo pid prefix

pseudo ordered uuids w modulo pid prefix

The first 2 characters of the UUID value comes from the MD5 hash of the backend pid modulo 3. The next 2 characters are the MD5 hash of the concatenation of the current year and week number. This value is, of course, static over a week. The remaining of the UUID value comes from the MD5 of a random value and the current time at a precision of 1us. The third field is prefixed with a “4” to indicate it is a version 4 UUID type.

psuedo order uuids

The first four characters of the UUID value comes from the MD5 hash of the concatenation of the current year and week number. This value is, of course, static over a week. The remaining of the UUID value comes from the MD5 of a random value and the current time at a precision of 1us. The third field is prefixed with a “4” to indicate it is a version 4 UUID type. There are 65536 possible prefixes so, during a week, only 1/65536 of the table rows are required in the memory to avoid a read IOP upon insertion. That’s much easier to manage, a 1TB table will need to have only about 16MB in the buffer pool to support the inserts

psuedo order with prefix

The first 2 characters of the UUID value comes from the MD5 hash of a supplied UUID. The next 3 characters are the MD5 hash of the concatenation of the current year and week number -- this value is, of course, static over a week. The remaining of the UUID value comes from the MD5 of a random value and the current time at a precision of 1us. The third field is prefixed with a “4” to indicate it is a version 4 UUID type.

@pyramation
pyramation / deployment.yaml
Created July 17, 2020 20:37
example of init containers
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: my-app
spec:
replicas: 1
template:
metadata:
labels:
app: my-app