Skip to content

Instantly share code, notes, and snippets.

View ahmetb's full-sized avatar
🛑
Slow to respond

Ahmet Alp Balkan ahmetb

🛑
Slow to respond
View GitHub Profile
package ctrlutil
import (
"context"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/client"
)
package main
import (
"context"
"encoding/json"
"errors"
"fmt"
"log"
"sync"
@ahmetb
ahmetb / a.go
Created September 30, 2021 19:04
package main
import "fmt"
// [[1, 2, 7], [3, 6, 7]]
// given a src and dest stop, what is the minimum number of hops?
// src: 2 dst:3
// r0 8->3
// r1 7->8
// r2 1->2->7
@ahmetb
ahmetb / main.go
Last active August 21, 2020 05:06
Use Knative API with Cloud Run client library (KUBECONFIG authentication)
package main
import (
"context"
"fmt"
"net/http"
"google.golang.org/api/option"
"google.golang.org/api/run/v1"
_ "k8s.io/client-go/plugin/pkg/client/auth"
@ahmetb
ahmetb / main.go
Created August 21, 2020 04:34
Authenticate Knative on GKE using Cloud Run API client library
package main
import (
"context"
"crypto/x509"
"encoding/base64"
"fmt"
"net/http"
"golang.org/x/oauth2"
@ahmetb
ahmetb / main.go
Last active August 19, 2020 18:38
using Knative API with Cloud Run client library
package main
import (
"context"
"log"
"net/http"
"golang.org/x/oauth2"
"golang.org/x/oauth2/google"
"google.golang.org/api/option"
@ahmetb
ahmetb / list-archive-files.sh
Created November 7, 2019 05:57
list all files in archives hosted in a krew-index (run from repo root)
#!/bin/bash
set -euo pipefail
files=$( grep -hRE '\.(tar\.gz|zip)' plugins/* | \
sed -E 's/^\s+(-\ )?uri:\s//g' | \
sed -E 's/"//g' | \
sort | \
uniq )
for f in $files; do
@ahmetb
ahmetb / pelican-frontmatter-to-hugo.sh
Created October 21, 2019 04:36
convert pelican frontmatter (YAML) to hugo (YAML) by adding --- separators
# prepend --- to every doc
sed -i '1i---' *.md
# append --- to first empty line (\n\n)
# (use GNU sed)
sed -i '0,/^$/s//---\n/' *.md
@ahmetb
ahmetb / probe.go
Created August 28, 2019 17:05
api/probe.go
// Package handler (directory named 'api/') is recognized
// by ZEIT Now v2 Lambda platform.
package handler
import (
"net/http"
)
func init() { log.SetFlags(log.Lmicroseconds) }
@ahmetb
ahmetb / _README.md
Created May 27, 2018 05:02
BSD grep segmentation fault

I'm getting garbage characters on my screen and eventually segmentation fault from BSD grep "2.5.1-FreeBSD".

Repro

Download attached files and run:

/usr/bin/grep -E --color -f dirs_pattern.txt rp_dirs_used_in_deps.txt