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 / 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
View eventBus.js
* subscriptions data format:
* { eventType: { id: callback } }
const subscriptions = { }
const getNextUniqueId = getIdGenerator()
function subscribe(eventType, callback) {
const id = getNextUniqueId()
Xeoncross / sed cheatsheet
Created Oct 9, 2019 — forked from un33k/sed cheatsheet
magic of sed -- find and replace "text" in a string or a file
View sed cheatsheet
# double space a file
sed G
# double space a file which already has blank lines in it. Output file
# should contain no more than one blank line between lines of text.
sed '/^$/d;G'
Xeoncross / oauth_token.go
Created Sep 23, 2019
Simple OAuth token with auto-renew based on a client id and secret
View oauth_token.go
package oauthtoken
import (
You can’t perform that action at this time.