Skip to content

Instantly share code, notes, and snippets.

@EmperorEarth
EmperorEarth / keyrepeat.shell
Created May 26, 2019 12:44 — forked from kconragan/keyrepeat.shell
Enable key repeat in Apple Lion for Sublime Text in Vim mode
# Mac OS X Lion introduced a new, iOS-like context menu when you press and hold a key
# that enables you to choose a character from a menu of options. If you are on Lion
# try it by pressing and holding down 'e' in any app that uses the default NSTextField
# for input.
#
# It's a nice feature and continues the blending of Mac OS X and iOS features. However,
# it's a nightmare to deal with in Sublime Text if you're running Vintage (Vim) mode,
# as it means you cannot press and hold h/j/k/l to move through your file. You have
# to repeatedly press the keys to navigate.
@EmperorEarth
EmperorEarth / valuer.go
Created March 6, 2019 14:56 — forked from jmoiron/valuer.go
Example uses of sql.Scanner and driver.Valuer
package main
import (
"bytes"
"compress/gzip"
"database/sql/driver"
"errors"
"fmt"
"github.com/jmoiron/sqlx"
_ "github.com/mattn/go-sqlite3"
@EmperorEarth
EmperorEarth / GolangCPUProfiles.sh
Created March 4, 2019 11:20 — forked from bgadrian/GolangCPUProfiles.sh
Golang Flame graph profiles
#install FlameGraph library
cd /opt/
sudo git clone https://github.com/brendangregg/FlameGraph.git
#make it accesible from any folder
vim ~/.bashrc
##add these lines anywhere and exit vim (if you can)
export FLAMEPATH=/opt/FlameGraph
PATH=$PATH:$FLAMEPATH
@EmperorEarth
EmperorEarth / latency.txt
Created January 27, 2019 13:03 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@EmperorEarth
EmperorEarth / core.go
Last active June 23, 2018 21:38
domain errors implementation
package core
import (
"context"
"fmt"
"runtime"
"strings"
)
type WrappedError interface {
package cond
import (
"context"
"strconv"
"sync"
"sync/atomic"
"testing"
)

Legend

This is a command in the Docker Quickstart Terminal

$ This is a command run inside the docker host or inside a container (linux etc, eg after docker-machine ssh default or docker run -it ubuntu bash)

Install Docker Toolbox

  1. start docker quick-start terminal
class Dashboard extends Component {
constructor(props) {
super(props)
// bind? slows down the initialization path, looks awful
// when you have 20 of them (I have seen your code, I know)
// and it increases bundle size
this.handleStuff = this.handleStuff.bind(this)
// _this is ugly.
We've found a bug for you!
C:\code\src\git.cheung.nyc\kevin\firstRE\re\app.re
7 Γöå <Text style=Style.(style [color "#000"]) value="hello world" />
8 Γöå <Text style=Style.(style [color "#000"]) value=(string_of_int 10) />
9 Γöå <Test />
10 Γöå <Greeting name="John" />
11 Γöå </View>;
fetch(url, {opts})
.then(response => response.headers.get(`Authorization`))