Skip to content

Instantly share code, notes, and snippets.

@hcoa
hcoa / elasticsearch.md
Created February 8, 2016 20:34 — forked from nicolashery/elasticsearch.md
Elasticsearch: updating the mappings and settings of an existing index

Elasticsearch: updating the mappings and settings of an existing index

Note: This was written using elasticsearch 0.9.

Elasticsearch will automatically create an index (with basic settings and mappings) for you if you post a first document:

$ curl -X POST 'http://localhost:9200/thegame/weapons/1' -d \
'{
  "_id": 1,
@hcoa
hcoa / future.go
Created February 22, 2016 08:12 — forked from davecheney/future.go
package future
// A Future represents the result of some asynchronous computation.
// Future returns the result of the work as an error, or nil if the work
// was performed successfully.
// Implementers must observe these invariants
// 1. There may be multiple concurrent callers, or Future may be called many
// times in sequence, it must always return the same value.
// 2. Future blocks until the work has been performed.
type Future func() error
@hcoa
hcoa / concurrency-in-go.md
Created April 22, 2016 08:02 — forked from kachayev/concurrency-in-go.md
Channels Are Not Enough or Why Pipelining Is Not That Easy
@hcoa
hcoa / Twelve_Go_Best_Practices.md
Created July 3, 2016 11:38 — forked from pzurek/Twelve_Go_Best_Practices.md
Twelve Go Best Practices
@hcoa
hcoa / variance.md
Created July 7, 2016 14:27 — forked from maiermic/variance.md
Description of the four kinds of variance: covariance, contravariance, invariance and bivariance.

Variance

The term variance describes how subtyping between higher kinded types is related to subtyping relations of their type arguments.

Higher Kinded Types

A higher kinded type composes type arguments to a new type. I use square bracket notation to define a higher kinded type:

C[T] // The higher kinded type `C` composes type argument `T` to a new type `C[T]`.

The same works with multiple type arguments:

@hcoa
hcoa / gist:8c51a5b45860a46800af6528409e8db0
Created September 23, 2016 13:54 — forked from krmaxwell/gist:6431994
Hunting Trips: network traffic log analysis

originally written in Dec 2011, needs updating

Log analysis has always struck me as one of those things that gets too much superficial attention without enough attention to detail. That is, we know that we need to do it, but we don’t talk about how we need to do it. At best, we talk about making sure we collect and archive logs. Analysis plays second fiddle, even though in reality logs without analysis provide almost no value to an organization. And you’ll find greatest value in discovery of the earliest stages of an incident rather than in hindsight to understand what went wrong. Unfortunately, less than 1% of data breach investigations in the 2011 Verizon DBIR started with log analysis and review!

The analysis ideas I present below don’t even begin to represent a comprehensive view. And of course every network is different, so you will need to think about your specific needs. But this may get

@hcoa
hcoa / latency.markdown
Created October 23, 2016 13:25 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know

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

@hcoa
hcoa / latency.txt
Created January 13, 2017 12:38 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
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
@hcoa
hcoa / PY0101EN-5-1-Numpy1D.ipynb
Created June 23, 2020 09:39 — forked from shreya4599/PY0101EN-5-1-Numpy1D.ipynb
Created on Skills Network Labs
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.