Skip to content

Instantly share code, notes, and snippets.

View InKolev's full-sized avatar

Ivan Kolev InKolev

  • Bulgaria
View GitHub Profile
@InKolev
InKolev / 0_reuse_code.js
Last active August 29, 2015 14:24
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
$(function () {
// TODO: expand
const filetypeMap = {
'javascript': 'js',
'haskell': 'hs'
};
const $fetchBtn = $('#fetch-btn'),
$container = $('#paste-details');
// Place your settings in this file to overwrite default and user settings.
{
"terminal.external.windowsExec": "git-bash",
"eslint.enable": true,
"eslint.options": {
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "es6",
"env": {
"es6": true

Unit testing - Brief overview

The definition of a unit test (by Roy Osherove)

Prerequisites

A unit of work is the sum of actions that take place between the invocation of a public method in the system and a single noticeable end result by a test of that system. A noticeable end result can be observed without looking at the internal state of the system and only through its public APIs and behavior. An end result is any of the following:

  • The invoked public method returns a value (a function that’s not void).
  • There’s a noticeable change to the state or behavior of the system before and after invocation that can be determined without interrogating private state.
  • There’s a callout to a third-party system over which the test has no control, and that third-party system doesn’t return any value, or any return value from that system is ignored. (Example: calling a third-party logging system that was not written by you and you don’t have the source to.)
@InKolev
InKolev / Latencies.txt
Last active February 3, 2017 17:02 — 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

Unstage all files staged for commit

  • Command
git reset HEAD -- .

Revert to previous commit, discarding all changes made locally

  • Command
git reset --hard HEAD

Local IP addresses

Kafka: 172.18.0.4
Zookeeper: 172.18.0.2

Useful commands

  • Create a topic named integration-test-topic with two partitions:

    • kafka-topics --create --zookeeper 172.18.0.2:3001 --replication-factor 1 --partitions 2 --topic integration-test-topic
  • Check topic information:

  • kafka-topics --zookeeper 172.18.0.2:3001 --describe --topic integration-test-topic

  1. Get authorization token POST
    http://craftcluster/api/FacebookLogin/GetAuthorizationToken?facebookAccessToken=...&facebookProfileId=...

Bet Settlement Worker (x1)

  • 40-50k items per minute (3000 cursor size, 1000 concurrency counter, 500 batch size, 250 ms timeout)

Account Operation Workers (x6)

  • 25-45k items per minute (with 3ms SQL Delay)
  • 30-50k items per minute (with 0ms SQL Delay)

Combo Bonus Workers (x6) (Slowest)

  • 18-40k items per minute (with 3ms SQL Delay)
  • 25-45k items per minute (with 0ms SQL Delay