Skip to content

Instantly share code, notes, and snippets.

View haproxy.cfg
global
# https://www.haproxy.com/blog/multithreading-in-haproxy/
# https://thisinterestsme.com/speeding-up-haproxy-ssl-with-multiple-cpu-processes/
nbproc 1
nbthread 4
cpu-map auto:1/1-4 0-3
maxconn 1000
# SSL configurations
View coinChange.kt
// coin change kata
fun largestCoin(coins: IntArray, amount: Int): Int? =
try {
coins.first { coin -> coin <= amount }
} catch (_: NoSuchElementException) {
null
}
fun coinChange(coins: IntArray, amount: Int): Int {
@jacoelho
jacoelho / docker-compose.yml
Created Apr 24, 2019
secure kafka connect
View docker-compose.yml
kafka-connect:
image: confluentinc/cp-kafka-connect
depends_on:
- zookeeper
- kafka
- schema-registry
ports:
- 8083:8083
- 8084:8084
volumes:
@jacoelho
jacoelho / immutable.go
Created Apr 23, 2019
immutable errors
View immutable.go
package main
import (
"fmt"
)
type Error string
func (e Error) Error() string { return string(e) }
View td-agent.log
2018-01-17 10:11:51 +0000 [info]: reading config file path="/etc/td-agent/td-agent.conf"
2018-01-17 10:11:51 +0000 [info]: starting fluentd-0.14.11 pid=1743
2018-01-17 10:11:51 +0000 [info]: spawn command to main: cmdline=["/opt/td-agent/embedded/bin/ruby", "-Eascii-8bit:ascii-8bit", "/usr/sbin/td-agent", "--log", "/var/log/td-agent/td-agent.log", "--use-v1-config", "--group", "td-agent", "--daemon", "/var/run/td-agent/td-agent.pid", "--under-supervisor"]
2018-01-17 10:11:51 +0000 [info]: reading config file path="/etc/td-agent/td-agent.conf"
2018-01-17 10:11:51 +0000 [info]: starting fluentd-0.14.11 without supervision pid=1753
2018-01-17 10:11:52 +0000 [info]: gem 'fluent-mixin-plaintextformatter' version '0.2.6'
2018-01-17 10:11:52 +0000 [info]: gem 'fluent-plugin-kafka' version '0.6.1'
2018-01-17 10:11:52 +0000 [info]: gem 'fluent-plugin-mongo' version '0.8.1'
2018-01-17 10:11:52 +0000 [info]: gem 'fluent-plugin-prometheus' version '1.0.0'
2018-01-17 10:11:52 +0000 [info]: gem 'fluent-plugin-prometheus'
@jacoelho
jacoelho / day_4.py
Created Dec 4, 2017
naive approach
View day_4.py
from collections import defaultdict
def valid(L):
d = defaultdict(int)
for v in L:
if d[v]:
return False
else:
d[v] += 1
@jacoelho
jacoelho / day_3.py
Created Dec 4, 2017
advent of code 2017 day 3
View day_3.py
import math
def coordinates(n):
d = math.floor(0.5 * (math.sqrt(n - 1) + 1))
nsig = n - (4 * d ** 2 + 1)
if nsig <= -2* d:
return(d, 3*d+nsig)
elif -2*d <= nsig <= 0:
View alb-asg.tf
resource "aws_alb_target_group" "test" {
name = "test-alb"
port = 443
protocol = "HTTPS"
vpc_id = "${aws_vpc.test.id}"
deregistration_delay = 200
stickiness {
type = "lb_cookie"
cookie_duration = 10000
}
@jacoelho
jacoelho / day_1.py
Last active Dec 2, 2017
advent 2017 day
View day_1.py
def transform(input):
return [int(x) for x in input]
def consecutive(L):
for prev, n in zip(L, L[1:] + L[:1]):
if prev == n:
yield n
for v in [ "1122", "1111", "1234", "91212129"]:
print(sum(transform(consecutive(v))))
@jacoelho
jacoelho / docker-compose.yml
Created Oct 2, 2017
alert manager mesh setup
View docker-compose.yml
version: "3"
services:
alertmanager:
image: prom/alertmanager
ports: ["9093:9093"]
command: [ "-config.file=/etc/alertmanager/config.yml", "-storage.path=/alertmanager" ]
networks:
- backend