Skip to content

Instantly share code, notes, and snippets.

View yanana's full-sized avatar
🦄
✨🦐✨

5hun Yanaura yanana

🦄
✨🦐✨
View GitHub Profile
@yanana
yanana / latency.markdown
Created October 19, 2016 07:00 — 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

@yanana
yanana / SomeSpec.scala
Created July 29, 2016 05:20
Solving ScalaTest#427 by upgrading ScalaTest to 3.0.0-RC4
import org.scalatest.prop.GeneratorDrivenPropertyChecks
import org.scalatest.{ Matchers, WordSpec }
class SomeSpec extends WordSpec with Matchers with GeneratorDrivenPropertyChecks {
"this test should fail without sbt exceptions" in {
forAll { value: Int =>
assert(value !== value)
// value shouldNot equal(value)
}
}
@yanana
yanana / .commit_template
Last active July 8, 2016 12:45 — forked from nownabe/.commit_template
Emojiで楽しく綺麗なコミットを手に入れる(改)
# ==== Emojis ====
# 🎨 :art: improving format/structure of the code
# 🔧 :wrench: infra/tooling
# 🔎 :mag: when adding or improving the code for monitoring
# 🐛 :bug: when fixing bug
# 👍 :+1: improved feature
# ✨ :sparkles: when adding a partial feature
# 🎉 :tada: big feature
@yanana
yanana / gcp-metadata.sh
Last active June 10, 2017 01:39
Create and query project-wide metadata on Google Compute Engine.
# Set project-wide metadata
gcloud compute project-info add-metadata --metadata foo=bar,baz=bat
# Query set metadata based on a key
curl 'http://metadata/computeMetadata/v1/project/attributes/foo' -H 'Metadata-Flavor: Google' # => bar
@yanana
yanana / statuses.md
Created November 15, 2015 06:14 — forked from vkostyukov/statuses.md
HTTP status codes used by world-famous APIs
API Status Codes
[Twitter][tw] 200, 304, 400, 401, 403, 404, 406, 410, 420, 422, 429, 500, 502, 503, 504
[Stripe][stripe] 200, 400, 401, 402, 404, 429, 500, 502, 503, 504
[Github][gh] 200, 400, 422, 301, 302, 304, 307, 401, 403
[Pagerduty][pd] 200, 201, 204, 400, 401, 403, 404, 408, 500
[NewRelic Plugins][nr] 200, 400, 403, 404, 405, 413, 500, 502, 503, 503
[Etsy][etsy] 200, 201, 400, 403, 404, 500, 503
[Dropbox][db] 200, 400, 401, 403, 404, 405, 429, 503, 507
@yanana
yanana / Monadic.scala
Created October 8, 2015 09:18 — forked from satabin/Monadic.scala
better monadic parser combinator with lazy evaluation for better performance
package gnieh.tex
import scala.language.higherKinds
/** A generic monadic interface. By implementing this trait, one can use
* this data together in for-comprehensions
*
* @author Lucas Satabin
*/
trait Monadic[+T, M[+T] <: Monadic[T, M]] {
@yanana
yanana / check_docker_container.sh
Created September 28, 2015 13:14 — forked from ekristen/check_docker_container.sh
Bash Script for Nagios to Check Status of Docker Container
#!/bin/bash
# Author: Erik Kristensen
# Email: erik@erikkristensen.com
# License: MIT
# Nagios Usage: check_nrpe!check_docker_container!_container_id_
# Usage: ./check_docker_container.sh _container_id_
#
# The script checks if a container is running.
# OK - running
@yanana
yanana / functional-utils.js
Last active September 17, 2015 06:55 — forked from bendc/functional-utils.js
A set of pure and immutable ES2015 functions aimed to make functional JavaScript more idiomatic.
// array utils
// =================================================================================================
const combine = (...arrays) => [].concat(...arrays);
const compact = arr => arr.filter(Boolean);
const contains = (() => Array.prototype.includes
? (arr, value) => arr.includes(value)
: (arr, value) => arr.some(el => el === value)
@yanana
yanana / apkadd.log
Created June 23, 2015 11:06
Log of installing jemalloc-dev on Alpine Linux
/ # apk add -vvv jemalloc-dev
The following NEW packages will be installed:
jemalloc jemalloc-doc jemalloc-dev
After this operation, 1112 KiB of additional disk space will be used.
(1/3) Installing jemalloc (3.6.0-r1)
usr/ (dir)
usr/lib/ (dir)
usr/lib/libjemalloc.so.1
(2/3) Installing jemalloc-doc (3.6.0-r1)
usr/ (dir)
import scalaz.stream.{async,Process}
import scalaz.concurrent.Task
/**
* Try running the process `p`, retrying in the event of failure.
* Example: `retry(Process.awakeEvery(2 minutes))(p)` will wait
* 2 minutes after each failure before trying again, indefinitely.
* Using `retry(Process.awakeEvery(2 minutes).take(5))(p)` will do
* the same, but only retry a total of five times before raising
* the latest error.