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 / client.go
Created June 28, 2017 12:54
crapy websocket load tester
package main
import (
"crypto/tls"
"flag"
"log"
"os"
"os/signal"
"time"
@jacoelho
jacoelho / systemd.bash
Created June 8, 2017 13:26
systemd docker
docker run --rm -it --security-opt seccomp=unconfined --tmpfs /run --tmpfs /run/lock -v /sys/fs/cgroup:/sys/fs/cgroup:ro centos/systemd
@jacoelho
jacoelho / docker.ps1
Created June 5, 2017 20:11
docker machine windows
Import-Module Hyper-V
if(!(Test-Path -Path "C:\Program Files\Docker\Docker")) {
$docker = [System.IO.Path]::GetTempFileName()
Invoke-WebRequest -Uri "https://download.docker.com/win/stable/InstallDocker.msi" -OutFile $docker
Start-Process msiexec.exe -ArgumentList "/i", $docker, "/quiet", "/norestart" -NoNewWindow -Wait
Remove-Item $docker
}
@jacoelho
jacoelho / attribute.rb
Created May 22, 2017 09:47
debug chef attributes
# node['foo']['bar']
pp node.debug_value('foo', 'bar')
@jacoelho
jacoelho / skip.jenkinsfile
Created May 11, 2017 13:25
jenkinsfile skip ci
Boolean shouldSkipBuild() {
output = sh(script: "git log -1 --pretty=%B", returnStdout: true)
output ==~ /(?m).*skipci.*/
}
@jacoelho
jacoelho / fun.rb
Created May 3, 2017 09:23
chef voodoo resources
%w(nginx php-fpm).each do |name|
begin
r = find_resource!(:service, name)
r.subscribes(:restart, [
"file[/etc/newrelic/newrelic.cfg]",
"file[/etc/php.d/newrelic.ini]"]
)
rescue Chef::Exceptions::ResourceNotFound
Chef::Log.error("newrelic_apm service #{name} not found, skipping restart")
end
%% Based on code from
%% Erlang Programming
%% Francecso Cesarini and Simon Thompson
%% O'Reilly, 2008
%% http://oreilly.com/catalog/9780596518189/
%% http://www.erlangprogramming.org/
%% (c) Francesco Cesarini and Simon Thompson
-module(frequency).
-export([start/1,allocate/0, allocate/1, deallocate/1,stop/0,show/0]).
def timeoutWithMsg(Map args) {
try {
args.body()
} catch(err) {
String user = err.getCauses()[0]?.getUser()?.toString()
if (user == 'SYSTEM') {
args.timeout()
} else {
args.abort(user)
}
@jacoelho
jacoelho / AWS-CSA-A-Notes.md
Last active August 29, 2017 08:23 — forked from agussman/AWS-CSA-A-Notes.md
Notes from studying for the AWS Certified Solutions Architect Exam. I felt well-prepared for the exam and passed with a 94%. Please reach out with any corrections or questions.

External Resources