Skip to content

Instantly share code, notes, and snippets.

View JoelPM's full-sized avatar

Joel Meyer JoelPM

View GitHub Profile
@JoelPM
JoelPM / get_all_gcp_cluster_creds.sh
Created June 20, 2019 16:23
A small script for getting cluster credentials for all GKE clusters in the given GCP projects.
#/bin/sh
# Usage: ./get_all_gcp_cluster_creds.sh PROJECT1 [PROJECT2 ...]
for project in "$@"
do
echo "Getting cluster credentials for project $project"
gcloud container clusters list --project $project --format="table[no-heading](name,location)" | while read cluster location
do
gcloud container clusters get-credentials $cluster --project $project --region $location
[joel.meyer@LUMI:src/poison]$ MIX_ENV=bench elixir -pa _build/bench/lib/\*/ebin -pa _build/bench/consolidated -S mix bench (02-11 11:38)
bench/encoder_bench.exs:131: warning: the Poison.Encoder protocol has already been consolidated, an implementation for EncoderBench.Struct has no effect
bench/encoder_bench.exs:131: warning: the Poison.Encoder protocol has already been consolidated, an implementation for EncoderBench.Struct has no effect
Settings:
duration: 1.0 s
## EncoderBench
[11:38:31] 1/33: structs (Poison)
[11:38:33] 2/33: structs (Jazz)
[11:38:35] 3/33: structs (JSX)
@JoelPM
JoelPM / cache_control.ex
Created January 14, 2016 22:29
A simple plug for setting cache-control header with example of defining a pipeline
# lib/app/plugs/cache_control.ex
defmodule App.Plugs.CacheControll do
import Plug.Conn
def init({val, :seconds}), do: val
def init({val, :minutes}), do: 60*val
def init({val, :hours }), do: 60*60*val
def init({val, :days }), do: 24*60*60*val
def init({val, :weeks }), do: 7*24*60*60*val
def init({val, :months }), do: 30*7*24*60*60*val
defmodule Struct do
defp filter_nil({_,nil}), do: false
defp filter_nil(_), do: true
def destruct(%{:__struct__ => _} = v), do: Map.from_struct(v) |> destruct
def destruct(v) when is_list(v), do: Enum.map(v, &destruct/1)
def destruct(v) when is_map(v), do: Enum.filter_map(v, &filter_nil/1, &destruct/1) |> Enum.into %{}
def destruct({k,v}), do: {k,destruct(v)}
def destruct(v), do: v
end
@JoelPM
JoelPM / Dockerfile
Created July 14, 2015 23:30
Building golang using a dev container with godep. Got things to build, but the binary wouldn't run when executing under busybox.
FROM busybox
MAINTAINER Joel Meyer <joel.meyer@gmail.com>
ADD ./kubegateway /kubegateway
ADD ./kubegateway.go /kubegateway.go
ENTRYPOINT ["/kubegateway"]
@JoelPM
JoelPM / mylists.erl
Created April 29, 2011 20:38
Provides an unflatten function. Useful when you flatten a list to do something and then need to unflatten an associated result list.
-module(mylists).
-export([ unflatten/2 ]).
unflatten([],[]) ->
[];
unflatten(List,[PSubList|PList]) ->
unflatten(List,[],[],PSubList,PList).
unflatten([],SubList,Lists,[],[]) ->