There is a trending 'microservice' library called go-kit. I've been using the go-kit library for a while now. The library provide a lot of convenience integrations that you might need in your service: with service discovery with Consul, distributed tracing with Zipkin, for example, and nice logic utilities such as round robin client side load balancing, and circuit breaking. It is also providing a way to implement communication layer, with support of RPC and REST.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
const STREAM_OPEN_FOR_INCLUDE = 128; | |
final class HardCoreDebugLogger | |
{ | |
public static function register(string $output = 'php://stdout') | |
{ | |
register_tick_function(function () use ($output) { | |
$bt = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Repository | |
{ | |
public function findAll(): array | |
{ | |
return $this->connection->project( | |
sprintf('SELECT * FROM %s', self::TABLE_NAME), | |
[], | |
function(array $row): Domain\MyObject { | |
return Domain\MyObject::fromArray($row); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# seahub | |
https://example.com { | |
tls [email protected] | |
gzip | |
proxy / 127.0.0.1:8000 { | |
header_upstream Host {host} | |
header_upstream X-Forwarded-Proto {scheme} | |
} | |
log /var/log/caddy/seahub.access.log | |
errors /var/log/caddy/seahub.error.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
"flag" | |
"fmt" | |
"log" | |
"net/http" | |
"os" | |
"os/signal" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DELIMITER | | |
CREATE FUNCTION uuid_from_bin(b BINARY(16)) | |
RETURNS CHAR(36) DETERMINISTIC | |
BEGIN | |
DECLARE hex CHAR(32); | |
SET hex = HEX(b); | |
RETURN CONCAT(LEFT(hex, 8), '-', MID(hex, 9,4), '-', MID(hex, 13,4), '-', MID(hex, 17,4), '-', RIGHT(hex, 12)); | |
END | |
| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@startuml | |
' uncomment the line below if you're using computer with a retina display | |
' skinparam dpi 300 | |
!define Table(name,desc) class name as "desc" << (T,#FFAAAA) >> | |
' we use bold for primary key | |
' green color for unique | |
' and underscore for not_null | |
!define primary_key(x) <b>x</b> | |
!define unique(x) <color:green>x</color> | |
!define not_null(x) <u>x</u> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# dontforget | |
# | |
# A stupid script for short term reminders in bash | |
# | |
# Arguments just need to contain a number and a bunch of words. | |
# | |
# The number can be anywhere in the arguments, but there shouldn't | |
# be any other numeric digits. | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function dataURItoBlob(dataURI) { | |
// convert base64/URLEncoded data component to raw binary data held in a string | |
var byteString; | |
if (dataURI.split(',')[0].indexOf('base64') >= 0) | |
byteString = atob(dataURI.split(',')[1]); | |
else | |
byteString = unescape(dataURI.split(',')[1]); | |
// separate out the mime component | |
var mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
map $http_origin $allow_origin { | |
default ""; | |
"~^https?://(?:[^/]*\.)?(stevebuzonas\.(?:com|local))(?::[0-9]+)?$" "$http_origin"; | |
} | |
map $request_method $cors_method { | |
default "allowed"; | |
"OPTIONS" "preflight"; | |
} |
NewerOlder