Skip to content

Instantly share code, notes, and snippets.

View enocom's full-sized avatar

Eno Compton enocom

View GitHub Profile
require "net/http"
require "uri"
require "json"
require "openssl"
require "yaml"
OAUTH_TOKEN = "some token goes here"
uri = URI.parse("https://api.github.com/users/enocom/repos")

Sharing files using netcat

The receiver

nc -l 5566 > data-dump.sql

Listen on port 5566 and redirect output to data-dump.sql

The sender

# Here are a handful of good practice problems, some of which may show up in interviews.
# 1. Write an anagram function.
# After that, try writing an anagram function without using #sort and iterating over each word only once
anagram("orchestra", "carthorse") # returns true
anagram("orchestra", "apple") # returns false
# 2. Write a function to test for balanced parentheses.
# This was a Twitter interview question, by the way.
balanced("()") # returns true

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

package main
import "fmt"
type T struct{}
func (t T) Method() {
fmt.Println("Hey there")
}

Keybase proof

I hereby claim:

  • I am enocom on github.
  • I am enocom (https://keybase.io/enocom) on keybase.
  • I have a public key whose fingerprint is B090 06E3 DA80 468A EC81 D3E1 617E 1A59 0FEF BD82

To claim this, I am signing this object:

function getCookie(token) {
fetch("https://doppler.coconut.cf-app.com/set-cookie?CookieName=authorization&CookieValue="+token)
.then(function(response) { console.log(response); })
}
function getRecentLogs(guid) {
fetch("https://doppler.coconut.cf-app.com/apps/" + guid + "/recentlogs")
.then(function(response) { return response.text(); });
}
function gcloud {
if ! docker inspect gcloud-config > /dev/null 2>&1; then
docker run -it --name gcloud-config -v "$PWD:/pwd" google/cloud-sdk:alpine gcloud auth login
fi
docker run -it --rm --volumes-from gcloud-config -v "$PWD:/pwd" google/cloud-sdk:alpine gcloud $@
}
function aws {
if ! docker inspect aws-config > /dev/null 2>&1; then
docker run -it --name aws-config -v "$PWD:/pwd" mesosphere/aws-cli configure

Go Conferences

  • Go Devroom FOSDEM - February in Brussels, Belgium
  • GopherCon India - March in Pune, India
  • GopherCon Russia - March in Moscow, Russia
  • GoSF - March in San Francisco, USA
  • GothamGo - April in New York, USA
  • GopherCon SG - May in Singapore
  • GopherCon Europe - June in Reykjavik, Iceland
  • GopherCon Denver - August in Denver, USA

I'm planning on either writing this up in detail or maybe doing a screencast about screencasting, but I'll give a short version here.

On sound quality:

This matters a lot. In decreasing order of importance:

  1. Remove echo. You have to hear this to understand. Set up a mic in front of your mouth and record a sentence. Then, put a thick comforter over you and the mic and say it again at the same distance. Listen to