Skip to content

Instantly share code, notes, and snippets.

# Such manifests may be broken up to any number of multiple files.
# Using map vs slice to enable referencing scenarios by ID in a dynamic structure.
# (TBD; there might be a neater solution but i'm happy with this so far)
---
scenarios:
S000:
description: some http call to some endpoint where we expects some response values
request:
uri: "/fakeauth"
method: post
@zgiber
zgiber / deepvalue.js
Created October 4, 2020 13:12
Find nested JavaScript objects by a string path
function deepValue(obj, path) {
// allow path to be passed as a string
if (!Array.isArray(path)){
path = path.split(".")
}
var segment = path[0]
path = path.slice(1, path.length);
obj = obj[segment]
package main
import (
"fmt"
"time"
)
var (
dateTimeISO8601format1 = "2006-01-02T15:04:05.999Z07:00"
dateTimeISO8601format2 = "2006-01-02T15:04:05.999-07:00"
{
"swagger": "2.0",
"info": {
"title": "TGEN (The Game Engine) API documentation",
"version": "1.0"
},
"consumes": [
"application/json"
],
"produces": [
@zgiber
zgiber / reproduce.go
Last active December 5, 2019 18:52
Confluent Kafka Go package - unexpected behaviour (?)
package main
import (
"context"
"fmt"
"log"
"os"
"os/signal"
"syscall"
"time"
@zgiber
zgiber / .tmux.conf
Created October 3, 2019 12:51
.tmux.conf
bind P paste-buffer
bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi y send-keys -X copy-selection
bind-key -T copy-mode-vi r send-keys -X rectangle-toggle
bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "xclip -sel clip -i"
set -g mouse on
set -s escape-time 0
set-window-option -g mode-keys vi
@zgiber
zgiber / sliceup.go
Created February 21, 2018 16:13
slice up
func sliceUp(s []string, size int) [][]string {
total := len(s)
var result [][]string
for i := 0; ; i++ {
first := size * i
if first > total {
break
}
last := size * (i + 1)
@zgiber
zgiber / simpleconcurrent.go
Created February 6, 2018 21:53
For Kai - It's relatively simple, and handles a few useful cases (ctrl+c, kind of graceful shutdown)
package main
import (
"context"
"fmt"
"log"
"os"
"os/signal"
"strconv"
"sync"
@zgiber
zgiber / pool.go
Created February 21, 2017 00:36
Sticky Worker Pool example
package pool
import (
"errors"
"fmt"
"log"
"sort"
"time"
)
@zgiber
zgiber / example.go
Created November 1, 2016 19:10
Reproduce validate issues
func TestValidate(t *testing.T) {
validRawToken := jwtBytes(testJWT())
expiredToken := testJWT()
expiredToken.Claims().SetExpiration(time.Now().Add(-24 * time.Hour))
expiredRawToken := jwtBytes(expiredToken)
badRawToken := []byte("You know I'm bad, I'm bad - you know it")
testCases := []struct {
name string