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
Xeoncross / lexer_in_go.md
Created Oct 22, 2019
Existing survey of text parsers / lexers in Go.
View lexer_in_go.md
@Xeoncross
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 (
"fmt"
"sync"
"testing"
"time"
)
var lockMap = &sync.Map{}
@Xeoncross
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 (
"log"
"net/http"
"github.com/spf13/afero"
)
func main() {
@Xeoncross
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 (
"crypto/tls"
"crypto/x509"
"io/ioutil"
"log"
"net/http"
"net/textproto"
"net/url"
@Xeoncross
Xeoncross / ubuntu_setup.sh
Last active Oct 14, 2019
Setup a new user on Ubuntu 18+ VPS
View ubuntu_setup.sh
# 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
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
FILE SPACING:
# 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
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 (
"context"
"encoding/json"
"fmt"
"log"
"net/http"
"net/url"
"strings"
@Xeoncross
Xeoncross / size_of_slice.go
Created Sep 18, 2019
How much memory does a slice of random strings actually take?
View size_of_slice.go
package main
import (
"fmt"
"math/rand"
"unsafe"
)
// Thanks to Kale, Andrei, and Jaden on gophers slack
@Xeoncross
Xeoncross / styles.less
Created Sep 16, 2019
Remove extra colors from Atom IDE solorized theme
View styles.less
# Select Solarized Light Syntax theme
# open styles.less and add the following
.syntax--variable,
.syntax--storage,
.syntax--entity,
.syntax--name,
.syntax--type {
color: #657b83 !important;
}
You can’t perform that action at this time.