Skip to content

Instantly share code, notes, and snippets.

View zero5100's full-sized avatar

Andy Kellerstrass zero5100

  • Green Bay, Wisconsin
View GitHub Profile
@zero5100
zero5100 / gist:5154782
Created March 13, 2013 18:26
How to limit the network speed
Installing:
sudo apt-get install wondershaper
Use:
(Speeds are in KB)
sudo wondershaper eth0 downspeed upspeed
e.g. sudo wondershaper eth0 500 500
Restoring normal speed:
// Test when ran using the postgresql connector
// Create a new instance of the model
loopback:connector:postgresql SQL: INSERT INTO "public"."phone_cdr"("caller_name","caller_number","phone_number_dialed","call_start_date_gmt","call_status") VALUES($1,$2,$3,to_timestamp($4,'yyyy-mm-dd hh24:mi:ss.ms'),$5) RETURNING "id"
Parameters: ["test","1234567","7654321","2015-01-01T00:00:00.000Z","A"] +465ms
loopback:connector:postgresql {
"command": "INSERT",
"rowCount": 1,
"oid": 0,
"rows": [{
@zero5100
zero5100 / apportion_lrm.sql
Last active April 22, 2020 20:15
This is an apportionment function using the Largest Remainder Method (LRM) used to divide a given total amount between any number of buckets proportionally.
DROP FUNCTION IF EXISTS apportion_lrm(NUMERIC, JSONB, INTEGER, NUMERIC, BOOLEAN);
CREATE FUNCTION apportion_lrm
(
IN apportion_amt NUMERIC,
IN proportions JSONB,
IN data_scale INTEGER DEFAULT 0,
IN proportion_total NUMERIC DEFAULT NULL,
IN allow_truncate_apportion BOOLEAN DEFAULT FALSE
)
RETURNS JSONB AS $BODY$
@zero5100
zero5100 / create-docker-tls.sh
Created March 1, 2018 00:57 — forked from mac2000/create-docker-tls.sh
Creating and setting up Docker for TLS
#!/bin/bash
# At the end you will have 6 files:
# ca/ca.pem - used by both client and server to verify each other certificates
# ca/ca-key.pem - keep it in secret it may be used to generate new certificates
# client/cert.pem, client/key.pem - in conjunction with /ca/ca.pem will be used by client to speak with server
# server/cert.pem, server/key.pem - in conjunction with /ca/ca.pem will be used by server
#
# NOTICE: DO NOT FORGET to set your **Server** ip and dns in server/openssl.cnf each time you generating new server certificates
#