Skip to content

Instantly share code, notes, and snippets.

Avatar
😋
We Lakers

william begoat

😋
We Lakers
View GitHub Profile
@begoat
begoat / download-csv.js
Last active Jun 16, 2020
js download array as csv
View download-csv.js
// https://jsfiddle.net/3an24jmw/25/
asUtf16 = (str) ->
buffer = new ArrayBuffer(str.length * 2)
bufferView = new Uint16Array(buffer)
bufferView[0] = 0xfeff
for i in [0..str.length]
val = str.charCodeAt(i)
bufferView[i + 1] = val
bufferView
@begoat
begoat / memorySizeOfObject.js
Created Mar 26, 2020 — forked from zensh/memorySizeOfObject.js
calculate memory size of javascript object, it is not a accurate value!
View memorySizeOfObject.js
function memorySizeOf(obj) {
var bytes = 0;
function sizeOf(obj) {
if(obj !== null && obj !== undefined) {
switch(typeof obj) {
case 'number':
bytes += 8;
break;
case 'string':
@begoat
begoat / pre-commit-eslint
Created Feb 5, 2020 — forked from rashtay/pre-commit-eslint
Pre-commit hook for Linting JS with ESLint before commit.
View pre-commit-eslint
#!/bin/sh
STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep ".jsx\{0,1\}$")
ESLINT="$(git rev-parse --show-toplevel)/node_modules/.bin/eslint"
if [[ "$STAGED_FILES" = "" ]]; then
exit 0
fi
PASS=true
@begoat
begoat / fuck-datetime.py
Last active Aug 24, 2018 — forked from ciiiii/fuck-datetime.py
python get time of one timezone
View fuck-datetime.py
from datetime import datetime, timedelta
from pytz import timezone
(datetime.now(tz=timezone('UTC'))+timedelta(minutes=WECHAT_QRCODE_EXPIRE_MINS))
.astimezone(timezone('Asia/Shanghai')).strftime("%Y%m%d%H%M%S")
View helloworld.yml
apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: backend3-deployment
labels:
cyouapp: backend3
spec:
replicas: 2
selector:
matchLabels:
@begoat
begoat / function-discovery.log
Created Aug 2, 2018
kubectl logs -l gloo=function-discovery -n gloo-system > function-discovery.log
View function-discovery.log
This file has been truncated, but you can view the full file.
"Thu, 02 Aug 2018 08:45:12 UTC: github.com/solo-io/gloo/pkg/function-discovery/eventloop/event_loop.go:122" beginning update for []string{
"gloo-system-control-plane-8081",
"default-backend3-service-50051",
"default-go-service-50051",
"gloo-system-ingress-8080",
"gloo-system-ingress-8443",
} upstreams: 5
"Thu, 02 Aug 2018 08:45:12 UTC: github.com/solo-io/gloo/pkg/function-discovery/eventloop/event_loop.go:122" beginning update for []string{
"default-go-service-50051",
@begoat
begoat / function-discovery.log
Created Aug 2, 2018
kubectl logs -l gloo=function-discovery -n gloo-system > function-discovery.log
View function-discovery.log
This file has been truncated, but you can view the full file.
"Thu, 02 Aug 2018 08:45:12 UTC: github.com/solo-io/gloo/pkg/function-discovery/eventloop/event_loop.go:122" beginning update for []string{
"gloo-system-control-plane-8081",
"default-backend3-service-50051",
"default-go-service-50051",
"gloo-system-ingress-8080",
"gloo-system-ingress-8443",
} upstreams: 5
"Thu, 02 Aug 2018 08:45:12 UTC: github.com/solo-io/gloo/pkg/function-discovery/eventloop/event_loop.go:122" beginning update for []string{
"default-go-service-50051",
@begoat
begoat / logs.json
Created Aug 2, 2018
logs from the node running the function-discovery pod: /var/lib/docker/containers/<long_container_id>/<long_container_id>-json.log
View logs.json
This file has been truncated, but you can view the full file.
{"log":"\u001b[31m\u001b[1m\"\u001b[0m\u001b[31mThu, 02 Aug 2018 08:45:12 UTC: github.com/solo-io/gloo/pkg/function-discovery/eventloop/event_loop.go:122\u001b[0m\u001b[31m\u001b[1m\"\u001b[0m\u0009beginning update for []\u001b[32mstring\u001b[0m{\n","stream":"stdout","time":"2018-08-02T08:45:12.476329889Z"}
{"log":" \u001b[31m\u001b[1m\"\u001b[0m\u001b[31mgloo-system-control-plane-8081\u001b[0m\u001b[31m\u001b[1m\"\u001b[0m,\n","stream":"stdout","time":"2018-08-02T08:45:12.476431785Z"}
{"log":" \u001b[31m\u001b[1m\"\u001b[0m\u001b[31mdefault-backend3-service-50051\u001b[0m\u001b[31m\u001b[1m\"\u001b[0m,\n","stream":"stdout","time":"2018-08-02T08:45:12.476445484Z"}
{"log":" \u001b[31m\u001b[1m\"\u001b[0m\u001b[31mdefault-go-service-50051\u001b[0m\u001b[31m\u001b[1m\"\u001b[0m,\n","stream":"stdout","time":"2018-08-02T08:45:12.476459084Z"}
@begoat
begoat / function-discovery.log
Created Aug 2, 2018
kubectl logs -l gloo=function-discovery -n gloo-system > function-discovery.log
View function-discovery.log
This file has been truncated, but you can view the full file.
"Thu, 02 Aug 2018 08:45:12 UTC: github.com/solo-io/gloo/pkg/function-discovery/eventloop/event_loop.go:122" beginning update for []string{
"gloo-system-control-plane-8081",
"default-backend3-service-50051",
"default-go-service-50051",
"gloo-system-ingress-8080",
"gloo-system-ingress-8443",
} upstreams: 5
"Thu, 02 Aug 2018 08:45:12 UTC: github.com/solo-io/gloo/pkg/function-discovery/eventloop/event_loop.go:122" beginning update for []string{
"default-go-service-50051",
@begoat
begoat / ca.md
Created Jul 14, 2018 — forked from soarez/ca.md
How to setup your own CA with OpenSSL
View ca.md

How to setup your own CA with OpenSSL

For educational reasons I've decided to create my own CA. Here is what I learned.

First things first

Lets get some context first.