Skip to content

Instantly share code, notes, and snippets.

@ukautz
ukautz / hooks.php
Created August 4, 2016 16:14
CodeIgniter 3 - Delegate exceptions and errors to Logentries
<?php
// application/config/hooks.php
defined('BASEPATH') OR exit('No direct script access allowed');
/*
| -------------------------------------------------------------------------
| Hooks
| -------------------------------------------------------------------------
| This file lets you define "hooks" to extend CI without hacking the core
@ukautz
ukautz / cert_load.go
Created March 2, 2016 18:55
Go: Load all .pem files containing private key and certificate(s) from directory
package common
import (
"crypto"
"crypto/ecdsa"
"crypto/rsa"
"crypto/tls"
"crypto/x509"
"encoding/pem"
"fmt"
@ukautz
ukautz / s3-in-laravel.php
Last active August 26, 2022 14:44
Using S3 client directly in Laravel
<?php
/** @var \Illuminate\Filesystem\FilesystemAdapter $fs */
$fs = \Storage::disk('object_storage');
/** @var \League\Flysystem\Filesystem $driver */
$driver = $fs->getDriver();
/** @var \League\Flysystem\AwsS3v3\AwsS3Adapter $adapter */
$adapter = $driver->getAdapter();
@ukautz
ukautz / memcached-demo.php
Created February 16, 2017 11:36
Tuning memcached options for redundancy & fast failover
<?php
$servers = [
['10.0.0.1', 11211],
['10.0.0.1', 11212],
];
$id = 1;
$timeout = 50;
$mc = new \Memcached($id);
@ukautz
ukautz / README.md
Last active February 10, 2021 12:30
Dump LDAP search result as JSON

What can you do with ldapsearch outputs? Not much. With JSON, though ..

# from LDAP search tool ...
ldapsearch -h 127.0.0.1 -p 10389 \
	-D "cn=me,ou=Acme,dc=local" -w 'mypa$$w00t" \
	-b "ou=machines,ou=Acme,dc=local" \
	-s sub "(objectclass=machine)"
@ukautz
ukautz / main.go
Last active May 25, 2020 17:26
Medium > Intro to Go > Full HTTP server
// returns a `200 OK` response with the body `Hello World` to any incoming request
package main
import (
"fmt"
"net/http"
)
func helloWorld(writer http.ResponseWriter, request *http.Request) {
writer.Write([]byte("Hello World"))
@ukautz
ukautz / benchmark_test.go
Last active February 12, 2020 10:15
Benchmark T-Digest implementation Golang
package tdigest_benchmark
import (
"fmt"
"math/rand"
"testing"
"time"
ajwerner "github.com/ajwerner/tdigest"
caio "github.com/caio/go-tdigest"
@ukautz
ukautz / bitbucket-pipelines.yml
Last active October 17, 2019 21:12
Example: BitBucket Pipelines vs fortrabbit
image: php:7.1.1
pipelines:
default:
- step:
script:
- apt-get update && apt-get install -y unzip git rsync
- curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
- composer install
- php deploy.php
$ for i in seq 1 3; do go test -bench=. -benchtime=5s; echo; done
goos: linux
goarch: amd64
pkg: github.com/Scout24/go-observability/.local
BenchmarkCallWithoutSlice-4    	100000000	        76.8 ns/op
BenchmarkCallWithSlice-4       	100000000	        77.1 ns/op
BenchmarkCallWithSliceCopy-4   	100000000	        76.4 ns/op
PASS
ok  	github.com/Scout24/go-observability/.local	23.277s
@ukautz
ukautz / foo.go
Created July 11, 2019 14:05
Does test.benchmem work with CGO?
package foo
import (
"C"
"strings"
)
var testString = strings.Repeat("x", 1024)
func NativeStrings(amount int) {