Skip to content

Instantly share code, notes, and snippets.

View kokizzu's full-sized avatar

Kiswono Prayogo kokizzu

View GitHub Profile
@kokizzu
kokizzu / groupcache.go
Created September 5, 2022 13:11 — forked from fiorix/groupcache.go
Simple groupcache example
// Simple groupcache example: https://github.com/golang/groupcache
// Running 3 instances:
// go run groupcache.go -addr=:8080 -pool=http://127.0.0.1:8080,http://127.0.0.1:8081,http://127.0.0.1:8082
// go run groupcache.go -addr=:8081 -pool=http://127.0.0.1:8081,http://127.0.0.1:8080,http://127.0.0.1:8082
// go run groupcache.go -addr=:8082 -pool=http://127.0.0.1:8082,http://127.0.0.1:8080,http://127.0.0.1:8081
// Testing:
// curl localhost:8080/color?name=red
package main
import (
@kokizzu
kokizzu / README.md
Created June 19, 2022 10:55 — forked from r0mdau/README.md
Rust Actix vs Rust Hyper vs Go fasthttp vs Go net/http httprouter

Load tests

Injector

wrk is the binary used as injector, always used with these options:

./wrk -t12 -c1000 -d15s http://127.0.0.1:8080/

Results

removing p_scylla-node1_1
Recreating a7c6d49b49fc_p_scylla-node1_1 ... done
Attaching to p_scylla-node1_1
scylla-node1_1 | running: (['/opt/scylladb/scripts/scylla_dev_mode_setup', '--developer-mode', '1'],)
scylla-node1_1 | running: (['/opt/scylladb/scripts/scylla_io_setup'],)
scylla-node1_1 | 2022-03-21 07:12:32,184 CRIT Supervisor is running as root. Privileges were not dropped because no user is specified in the config file. If you intend to run as root, you can set user=root in the config file to avoid this message.
scylla-node1_1 | 2022-03-21 07:12:32,184 INFO Included extra file "/etc/supervisord.conf.d/rsyslog.conf" during parsing
scylla-node1_1 | 2022-03-21 07:12:32,184 INFO Included extra file "/etc/supervisord.conf.d/scylla-housekeeping.conf" during parsing
scylla-node1_1 | 2022-03-21 07:12:32,184 INFO Included extra file "/etc/supervisord.conf.d/scylla-jmx.conf" during parsing
scylla-node1_1 | 2022-03-21 07:12:32,184 INFO Included extra file "/etc/supervisord.conf.d/scylla-node-exporter.c
@kokizzu
kokizzu / erdiagram.mmd
Created February 15, 2022 13:07
example ER Diagram
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kokizzu
kokizzu / sodoku-solver.cpp
Created February 2, 2022 12:16
Singapore PM's Sodoku Solver
#include "stdio.h"
int InBlock[81], InRow[81], InCol[81];
const int BLANK = 0;
const int ONES = 0x3fe; // Binary 1111111110
int Entry[81]; // Records entries 1-9 in the grid, as the corresponding bit set to 1
int Block[9], Row[9], Col[9]; // Each int is a 9-bit array

How to setup a practically free CDN

I've been using [Backblaze][bbz] for a while now as my online backup service. I have used a few others in the past. None were particularly satisfactory until Backblaze came along.

It was - still is - keenly priced at a flat $5 (£4) per month for unlimited backup (I've currently got just under half a terabyte backed-up). It has a fast, reliable client. The company itself is [transparent about their operations][trans] and [generous with their knowledge sharing][blog]. To me, this says they understand their customers well. I've never had reliability problems and everything about the outfit exudes a sense of simple, quick, solid quality. The service has even saved the day on a couple of occasions where I've lost files.

Safe to say, I'm a happy customer. If you're not already using Backblaze, [I highly recommend you do][recommend].

Taking on the big boys with B2

@kokizzu
kokizzu / unixhttpc.go
Created October 29, 2021 13:11 — forked from teknoraver/unixhttpc.go
HTTP over Unix domain sockets in golang
package main
import (
"context"
"flag"
"fmt"
"io"
"net"
"net/http"
"os"
@kokizzu
kokizzu / README.md
Created October 29, 2021 06:18 — forked from evalphobia/README.md
Golang Benchmark: uuid(v4) vs cuid vs nanoid

Golang Benchmark: uuid(v4) vs cuid vs nanoid

Comparing these libraries

  • github.com/google/uuid
  • github.com/lucsky/cuid
  • github.com/matoous/go-nanoid

result

package main
import (
"encoding/xml"
"flag"
"fmt"
"io"
"net/http"
"net/url"
"os"
@kokizzu
kokizzu / main.go
Created September 11, 2021 13:21 — forked from walm/main.go
Simple Golang DNS Server
package main
import (
"fmt"
"log"
"strconv"
"github.com/miekg/dns"
)