Skip to content

Instantly share code, notes, and snippets.

David Pennington Xeoncross

Block or report user

Report or block Xeoncross

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Every possible TypeScript type.md

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 Jan 1, 2020 — forked from contra/aoe2hd.md
Age of Empires II HD - For Mac OSX
View aoe2hd.md

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 Jan 1, 2020
Setup testing for VSCode and Go
View test_go_vscode.md

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"],

https://github.com/Microsoft/vscode-go/issues/2115

If that is not enough (which it should be)

View LeanCrypt.ts
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
@Xeoncross
Xeoncross / settings.json
Last active Dec 18, 2019
VSCode settings to setup solarized light theme
View settings.json
{
"workbench.startupEditor": "newUntitledFile",
"workbench.colorTheme": "Solarized Light",
// "editor.defaultFormatter,
"workbench.colorCustomizations": {
// "sideBar.background": "#444",
// "sideBar.foreground": "#CCC",
// "list.activeSelectionBackground": "#777",
// "list.activeSelectionForeground": "#ffffff",
// "list.focusForeground": "#000",
@Xeoncross
Xeoncross / go_auth_library.md
Last active Jan 7, 2020
Ideas for an authentication library in Go to handle login, sessions, and request protection for HTML forms as well as single-page apps (or other clients)
View go_auth_library.md

Login / Auth System

Protect against:

  • DoS
  • Lock accounts after failed attempts
  • forgotten password tokens (or remeber me, CSRF, etc..) being used as logins (hash them all)
  • someone faking a login attempt and that action loging out valid user sessions
@Xeoncross
Xeoncross / go_mod_private_vps.md
Last active Dec 6, 2019
Access private repositiories in Go projects hosted on a remote server (using SSH)
View go_mod_private_vps.md

Setup private Go modules

You have a git repositiory on a remote server. This is probably a VPS you have online at Digital Ocean, AWS, or some other hosting company. Could also be a docker container or raspberrypi under your desk.

Regardless, you can include the repositiory in your go projects by helping git (which Go uses) to know how to access the code over SSH.

Edit your ~/.gitconfig and make sure your host is listed. Below are examples for github, bitbucket, and my own custom VPS.

@Xeoncross
Xeoncross / dynamodb-setup.sh
Created Nov 20, 2019 — forked from kwilczynski/dynamodb-setup.sh
Something put together quickly to automatically associate Elastic IP address with the current EC2 instance.
View dynamodb-setup.sh
aws dynamodb create-table --region <REGION> --profile <PROFILE> --table-name "<TABLE>" --attribute-definitions "AttributeName=key,AttributeType=S" --key-schema "AttributeName=key,KeyType=HASH" --billing-mode "PAY_PER_REQUEST"
aws dynamodb create-table --region <REGION> --profile <PROFILE> --table-name "<TABLE>" --attribute-definitions "AttributeName=key,AttributeType=S" --key-schema "AttributeName=key,KeyType=HASH" --billing-mode "PROVISIONED" --provisioned-throughput "ReadCapacityUnits=1,WriteCapacityUnits=1"
aws dynamodb update-time-to-live --region <REGION> --profile <PROFILE> --table-name "<TABLE>" --time-to-live-specification "Enabled=true,AttributeName=ttl"
aws dynamodb scan --region <REGION> --profile <PROFILE> --table-name "<TABLE>"
@Xeoncross
Xeoncross / mariadb_generator.sql
Created Nov 11, 2019
Example of writing a MariaDB query to generate 100k records
View mariadb_generator.sql
-- See more at https://stackoverflow.com/a/49446214/99923
INSERT INTO T1 (id, created_on, domain, seen_on)
SELECT one.X, two.X, three.X, two.X
FROM (select seq, seq X from seq_1_to_100000) one
LEFT JOIN (select seq, NOW() - INTERVAL seq MINUTE X from seq_1_to_100000) two ON one.seq = two.seq
LEFT JOIN (select seq, CONCAT(seq,'.',seq) X from seq_1_to_100000) three ON one.seq = three.seq;
@Xeoncross
Xeoncross / int_to_byteslice.go
Last active Nov 2, 2019
Writing a large number of ints to a byte slice is slower when using https://golang.org/pkg/encoding/binary/#Write
View int_to_byteslice.go
package bytewriter
import (
"bytes"
"encoding/binary"
"testing"
)
func BenchmarkBinary(b *testing.B) {
You can’t perform that action at this time.