Skip to content

Instantly share code, notes, and snippets.

View xeoncross's full-sized avatar

David Pennington xeoncross

View GitHub Profile
@xeoncross
xeoncross / aurora_serverless.md
Created February 12, 2020 17:54
Amazon AWS Aurora Serverless - Summary

I have a pretty constant-use case in mind for collecting client metrics with different loads and spikes throughout the day and am mostly interested in paying a little extra to not have to manage the RDS/Aurora server instances. I basically just need a k/v store but need to do report queries/scans so DynamoDB isn’t a good fit. (COUNT(*) FROM, SUM, etc..)

Slow start

Looks like a minimum of 5 minutes of usage each time the database is activated and I’m pretty sure my load will never let the database shutdown so that might solve the cold-start issue.

https://aws.amazon.com/rds/aurora/faqs/?nc=sn&loc=6

@xeoncross
xeoncross / tailwind_styled_react.md
Created February 10, 2020 16:57
Typescript react projects always need a CSS framework. Why not tailwind instead of bootstrap?
@xeoncross
xeoncross / 1-sql.md
Last active February 5, 2020 01:48
On-line schema changes to MySQL / MariaDB large database tables: 3 options

Easiest Method: SQL

Simply let MySQL know you want to avoid table locks when doing the schema change.

ALTER TABLE `example` ADD `example_column` TINYINT(1) DEFAULT NULL,
ALGORITHM=INPLACE, LOCK=NONE;

You will probably want to detach it from your session as it might take hours/days.

@xeoncross
xeoncross / compact_time_storage.md
Last active February 4, 2020 18:28
Compact storage of time series values by using bitmaps and assigning every value a unique id for that bitmap.

With most of the companies I’ve worked with I needed to store basic client+timestamp activity logs in a database. Could be access logs, ad impressions, thread/post views, email activity, campaign clicks, etc.. it’s always some client identifier + a timestamp. Then I need a report (SUM) of how many events exist in a given block of time. However, I also often need the actual individual rows so I can look at how a certain client itself performed over a certain block of time.

Storing 8/16 byte client ids + 4 byte timestamps is rather costly when doing this hundreds of thousands/millions of times per day. What am I looking for?

Originally I thought I might have a good use-case for time-series with bitmaps for each date (or time deltas). However, often the clients are very sparse so I might only see them a few times before they disappear and the cost of generating a bitmap for the whole search space is more than simply storing a few regular records.

ip+timestamp+someid
email+timestamp+someid
user_id+timestam
@xeoncross
xeoncross / index.js
Last active December 15, 2021 07:14
Setup Bootstrap with Parcel for local development
import $ from "jquery";
import "bootstrap";
import "bootstrap/dist/css/bootstrap.css"; // Import precompiled Bootstrap css
import "@fortawesome/fontawesome-free/css/all.css";
import "./offcanvas.css";
import Holder from "holderjs";
$(() => {
"use strict";
@xeoncross
xeoncross / zaplog.go
Created January 22, 2020 16:29
Example helper for creating a new zap.Logger instance that logs to stderr without the caller/stacktrace.
package zaplog
import (
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)
// https://github.com/uber-go/zap/blob/master/config.go#L40-L127
// For testing use https://godoc.org/go.uber.org/zap#NewNop
@xeoncross
xeoncross / Every possible TypeScript type.md
Created January 10, 2020 21:48 — forked from laughinghan/Every possible TypeScript type.md
Diagram of every possible TypeScript type

Hasse diagram of every possible TypeScript type

  • any: magic, ill-behaved type that acts like a combination of never (the proper [bottom type]) and unknown (the proper [top type])
    • Anything at all is assignable to any, and any is assignable to anything at all.
    • Identities: any & AnyTypeExpression = any, any | AnyTypeExpression = any
    • Key TypeScript feature that allows for [gradual typing].
  • unknown: proper, well-behaved [top type]
    • Anything at all is assignable to unknown. unknown is only assignable to itself (unknown) and any.
    • Identities: unknown & AnyTypeExpression = AnyTypeExpression, unknown | AnyTypeExpression = unknown
  • Prefer over any whenever possible. Anywhere in well-typed code you're tempted to use any, you probably want unknown.
@xeoncross
xeoncross / aoe2hd.md
Created January 1, 2020 19:50 — forked from yocontra/aoe2hd.md
Age of Empires II HD - For Mac OSX

AOE2HD - For Mac OSX

Estimated time: 10 minutes

Notice

PlayOnMac does not work on macOS Catalina, and issues have been reported with the latest version of Steam. Updating is in progress, read more here.

When the updates are released this guide will be updated.

@xeoncross
xeoncross / test_go_vscode.md
Last active January 1, 2020 17:07
Setup testing for VSCode and Go

When using VSCode for testing Go code you probably want to enable the editor to show log output as well.

Open up your settings.json file and add

"go.testFlags": ["-v"],

microsoft/vscode-go#2115

If that is not enough (which it should be)

namespace LeanCrypt {
const PBKDF2_ITERATIONS = 100_000
export async function encrypt(plainText: string, key: CryptoKey): Promise<string>
export async function encrypt(buffer: ArrayBuffer, key: CryptoKey): Promise<LeanCrypted>
export async function encrypt(data: string | ArrayBuffer, key: CryptoKey): Promise<string | LeanCrypted> {
let dataIsString = false
let buffer: ArrayBuffer