Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Ahmet Alp Balkan ahmetb

🏠
Working from home
View GitHub Profile
@ahmetb
ahmetb / main.go
Last active Aug 21, 2020
Use Knative API with Cloud Run client library (KUBECONFIG authentication)
View main.go
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 Aug 21, 2020
Authenticate Knative on GKE using Cloud Run API client library
View main.go
package main
import (
"context"
"crypto/x509"
"encoding/base64"
"fmt"
"net/http"
"golang.org/x/oauth2"
@ahmetb
ahmetb / main.go
Last active Aug 19, 2020
using Knative API with Cloud Run client library
View main.go
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 Nov 7, 2019
list all files in archives hosted in a krew-index (run from repo root)
View list-archive-files.sh
#!/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 Oct 21, 2019
convert pelican frontmatter (YAML) to hugo (YAML) by adding --- separators
View pelican-frontmatter-to-hugo.sh
# 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 Aug 28, 2019
api/probe.go
View 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
BSD grep segmentation fault
View _README.md

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
@ahmetb
ahmetb / gcpauth.go
Created May 22, 2018
Authenticating to GKE cluster with client-go, IAM service account and a Google auth plugin written from scratch
View gcpauth.go
package main
import (
"context"
"fmt"
"log"
"net/http"
"golang.org/x/oauth2"
"golang.org/x/oauth2/google"
@ahmetb
ahmetb / tmux.md
Created Dec 18, 2017 — forked from andreyvit/tmux.md
tmux cheatsheet
View tmux.md

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

# remap prefix to Control + a
@ahmetb
ahmetb / gcrgc.sh
Last active Oct 28, 2020
Script to clean up Google Container Registry images pushed before a particular date
View gcrgc.sh
#!/bin/bash
# Copyright © 2017 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
You can’t perform that action at this time.