Skip to content

Instantly share code, notes, and snippets.

@jacoelho
jacoelho / haproxy.cfg
Created October 28, 2019 19:09
ha proxy
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
// 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 April 24, 2019 13:12
secure kafka connect
kafka-connect:
image: confluentinc/cp-kafka-connect
depends_on:
- zookeeper
- kafka
- schema-registry
ports:
- 8083:8083
- 8084:8084
volumes:
@jacoelho
jacoelho / immutable.go
Created April 23, 2019 19:01
immutable errors
package main
import (
"fmt"
)
type Error string
func (e Error) Error() string { return string(e) }
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 December 4, 2017 20:24
naive approach
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 December 4, 2017 20:03
advent of code 2017 day 3
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:
@jacoelho
jacoelho / alb-asg.tf
Created December 4, 2017 10:54
alb asg
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 December 2, 2017 12:14
advent 2017 day
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 October 2, 2017 14:40
alert manager mesh setup
version: "3"
services:
alertmanager:
image: prom/alertmanager
ports: ["9093:9093"]
command: [ "-config.file=/etc/alertmanager/config.yml", "-storage.path=/alertmanager" ]
networks:
- backend