Skip to content

Instantly share code, notes, and snippets.

@jacoelho
jacoelho / ec2-sysprep.ps1
Created June 29, 2017 07:41
amazon ec2 windows autologon sysprep
# Create user with random password
$password = -join ((48..57) + (97..122) | Get-Random -Count 14 | % {[char]$_})
$unattendPath = "$Env:ProgramData\Amazon\EC2-Windows\Launch\Sysprep\Unattend.xml"
$xml = [xml](Get-Content $unattendPath)
$targetElememt = $xml.unattend.settings.Where{($_.Pass -eq 'oobeSystem')}.component.Where{($_.name -eq 'Microsoft-Windows-Shell-Setup')}
$autoLogonElement = [xml]('<AutoLogon>
<Password>
<Value>{0}</Value>
@jacoelho
jacoelho / matchers.rb
Created July 12, 2016 17:59
Simple chefspec matcher
if defined?(ChefSpec)
def create_example_topic(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:example_topic, :create, resource_name)
end
end
@jacoelho
jacoelho / .md
Last active April 30, 2021 20:51
spf13-vim + vim-go
  1. Install spf13-vim
sh <(curl https://j.mp/spf13-vim3 -L)
  1. Install Go bundle
echo "export PATH=\$PATH:\$(go env GOPATH)/bin" >> ~/.bashrc
@jacoelho
jacoelho / golang.sh
Last active February 26, 2020 16:43
Install golang debian/ubuntu
#!/bin/bash
export GOLANG_VERSION=1.10.3
export GOLANG_DOWNLOAD_URL=https://golang.org/dl/go$GOLANG_VERSION.linux-amd64.tar.gz
export GOLANG_DOWNLOAD_SHA256=fa1b0e45d3b647c252f51f5e1204aba049cde4af177ef9f2181f43004f901035
apt-get update -qq
apt-get install -y --no-install-recommends \
g++ \
@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 / ansible_lambda.py
Last active July 19, 2019 01:03
ansible lambda
#!/usr/bin/python
import ansible.inventory
import ansible.playbook
import ansible.runner
from ansible import utils
from ansible import callbacks
def run_playbook(**kwargs):
@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'