Skip to content

Instantly share code, notes, and snippets.

View zboralski's full-sized avatar

Anthony Zboralski zboralski

View GitHub Profile
@zboralski
zboralski / getlimiter.go
Last active June 7, 2023 12:23
Temporal Worker GetLimiter
package main
import (
"fmt"
"reflect"
"unsafe"
"go.temporal.io/sdk/worker"
"golang.org/x/time/rate"
)
@zboralski
zboralski / keydb.conf.tpl
Created April 17, 2023 14:47
keydb.conf Nomad Template
# By default KeyDB does not run as a daemon. Use 'yes' if you need it.
# Note that KeyDB will write a pid file in /var/run/keydb.pid when daemonized.
daemonize no
bind 127.0.0.1 ::1 # listens on loopback IPv4 and IPv6
bind {{ env "NOMAD_IP_redis" }}
aclfile {{ env "NOMAD_SECRETS_DIR" }}/users.acl
# By default protected mode is enabled. You should disable it only if
@zboralski
zboralski / keydb.nomad.hcl
Created April 17, 2023 14:44
keydb nomad job with vault password rotation
job "keydb-vanilla" {
region = "global"
datacenters = ["dc1"]
type = "service"
group "keydb" {
count = 1
vault {
policies = ["nomad-keydb"]
@zboralski
zboralski / vault-oidc-google-config.sh
Last active March 19, 2023 20:58
Vault OIDC Google Provider Configuration
#!/bin/bash
# Configures Vault's OIDC authentication method to use Google as the provider.
# It retrieves the client ID and client secret from Vault, formats the GSuite service account
# JSON as required by Vault, and writes the configuration to Vault using the "gsuite" provider.
# This script assumes that Vault has already been initialized and unsealed, and that the OIDC
# authentication method has been enabled.
# Write first your Google Cloud Platform (GCP) credentials to HashiCorp Vault using
@zboralski
zboralski / vault-oidc-google-secrets.sh
Last active March 18, 2023 21:49
Write Google Cloud Platform (GCP) credentials to HashiCorp Vault
#!/bin/bash
# Write Google Cloud Platform (GCP) credentials to HashiCorp Vault
# https://gist.github.com/zboralski/709b2427bff863ab7868c6a1d2125591#file-vault-oidc-google-secrets-sh
# Then use vault-oidc-google-secrets.sh to configure OIDC
# https://gist.github.com/zboralski/8f44f9a3ece6cd01fbc675943b490a80#file-vault-oidc-google-config-sh
# Set project name and file names
PROJECT="example-vault-us"
@zboralski
zboralski / ByteSlice2String.go
Created March 5, 2023 13:08
no-copy conversion from []byte to string #25484
// no-copy conversion from []byte to string #25484
// https://github.com/golang/go/issues/25484#issuecomment-391415660
func ByteSlice2String(bs []byte) string {
return *(*string)(unsafe.Pointer(&bs))
}
@zboralski
zboralski / mmap.go
Last active March 4, 2023 17:50
Using mmap from `golang.org/x/exp/mmap`
package main
import (
"bufio"
"fmt"
"io"
"log"
"os"
"golang.org/x/exp/mmap"
@zboralski
zboralski / designer.html
Created October 27, 2015 17:44
designer
<link rel="import" href="../core-field/core-field.html">
<link rel="import" href="../core-icon/core-icon.html">
<link rel="import" href="../core-input/core-input.html">
<link rel="import" href="../core-icons/core-icons.html">
<polymer-element name="my-element">
<template>
<style>
:host {
@zboralski
zboralski / designer.html
Last active October 27, 2015 17:49
designer
<link rel="import" href="../core-scaffold/core-scaffold.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-menu/core-menu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-menu/core-submenu.html">
<link rel="import" href="../core-field/core-field.html">
<link rel="import" href="../core-icon/core-icon.html">
<link rel="import" href="../core-input/core-input.html">
@zboralski
zboralski / _resp-scale.scss
Created September 3, 2014 15:58
Responsive Scale
// Requires SASS >= 3.3 and responsive.scss
// https://gist.github.com/maxluster/168e650267bac9faaafd
//
// Scale value with $width for each $width in $named-breakpoints map.
// Usage : @include responsive("font-size", $base-font-size + px,
// resp-scale($base-width, $base-font-size));
@function resp-scale($width, $value, $scale-up: false) {
$m : ();
@each $k, $v in $named-breakpoints {
$ok : true;