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
Xeoncross /
Last active Nov 27, 2019
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)

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 /
Last active Dec 6, 2019
Access private repositiories in Go projects hosted on a remote server (using SSH)

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 /
Created Nov 20, 2019 — forked from kwilczynski/
Something put together quickly to automatically associate Elastic IP address with the current EC2 instance.
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 / mariadb_generator.sql
Created Nov 11, 2019
Example of writing a MariaDB query to generate 100k records
View mariadb_generator.sql
-- See more at
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 / int_to_byteslice.go
Last active Nov 2, 2019
Writing a large number of ints to a byte slice is slower when using
View int_to_byteslice.go
package bytewriter
import (
func BenchmarkBinary(b *testing.B) {
Xeoncross /
Created Oct 22, 2019
Existing survey of text parsers / lexers in Go.
Xeoncross / lockmap.go
Last active Oct 22, 2019
Map of N locks contented by X goroutines. Use to limit access to a given function based on a key.
View lockmap.go
package syncmaptest
import (
var lockMap = &sync.Map{}
Xeoncross / http_server_filesystem.go
Last active Oct 21, 2019
Example of serving templates using both the system filesystem and an in-memory fake filesystem along with custom routes
View http_server_filesystem.go
package main
import (
func main() {
Xeoncross / add_certs_to_pool.go
Created Oct 17, 2019
Golang: Self-signed certs: Get the system's certpool then append your cert into that pool, and use the new pool in your http/websocket clients
View add_certs_to_pool.go
package main
import (
Xeoncross /
Last active Oct 14, 2019
Setup a new user on Ubuntu 18+ VPS
# Assuming you are logged in as root and the ssh key you want to use already installed for root (i.e. new Digital Ocean VPS)
adduser deploy
usermod -aG sudo deploy
mkdir /home/deploy/.ssh
cp /root/.ssh/authorized_keys /home/deploy/.ssh/
chmod 700 /home/deploy/.ssh
chown deploy:deploy -R /home/deploy/.ssh
You can’t perform that action at this time.