Skip to content

Instantly share code, notes, and snippets.

View embano1's full-sized avatar

Michael Gasch embano1

View GitHub Profile
@embano1
embano1 / gist:d0e77f639c2f3ae79d6e53196f309cb7
Last active May 3, 2017 18:35
docker-machine Driver for Play-with-Docker (PWD)
# Get latest release for PWD
https://github.com/franela/docker-machine-driver-pwd
# Unzip, and make sure the PWD driver for the OS is in $PATH
# Start a PWD session
http://labs.play-with-docker.com/
# Note the PWD ID (full http string)
@embano1
embano1 / gist:f77d54b89e061ae7c202a280ac98513e
Created June 14, 2017 12:45
zsh Prompt configuration (with Powerlevel9k)
**Install Theme**
Powerlevel 9k
git clone https://github.com/bhilburn/powerlevel9k.git ~/.oh-my-zsh/custom/themes/powerlevel9k (make sure to have Powerline fonts installed first, this method works for oh-my-zsh only)
Details and other installation options: https://github.com/bhilburn/powerlevel9k#installation
**Edit .zshrc**
ZSH_THEME="powerlevel9k/powerlevel9k"
DEFAULT_USER=$USER
POWERLEVEL9K_PROMPT_ON_NEWLINE=true
POWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX=" --"
man zshexpn
# echo hellow world
^hellow^hello
> echo hello world
(only works on last command)
# replace first arg string in a history command
!353:1:s^hello^hi
@embano1
embano1 / gist:0570304e09070ee9411e105897d25164
Created August 6, 2017 06:57
Updating vscode dependencies, e.g. if defs and intellisense fail after vscode update
close VSCode and gocode close
go get -u github.com/rogpeppe/godef
go get -u github.com/nsf/gocode
package main
import (
"fmt"
)
func main() {
s := string("\xF0\x9F\x98\x85")
b := []byte("\xF0\x9F\x8D\xBB")
fmt.Println(s,string(b))
@embano1
embano1 / gist:6a0be5a7f9b97d422159ba235d33ba2b
Last active February 14, 2018 14:29
Quickly change tmux Prefix in running Session
# Asuming prefix is C-b and change to C-a
C-b + :
set-option -g prefix C-a
@embano1
embano1 / README.MD
Last active August 23, 2020 17:01
jq to filter youtube videos from Twitter likes (uses "tw")
# uses https://github.com/embano1/tw, JSON output stored in file for faster processing
$ tw -f tw.json likes >Downloads/twout.json

# filter only youtube videos and print tweet text
$ cat twout.json | jq '.[]|select( .entities.urls[].expanded_url | contains ("yout"))|.full_text,"----"'
@embano1
embano1 / README.MD
Created July 10, 2018 10:54
Search string/regex in git history, e.g. deleted/replaced code

Example for Kubernetes DebugContainers

$ git clone https://github.com/kubernetes/kubernetes
# Increase search limit and only print commit IDs
$ git -c diff.renameLimit=99999 log -SDebugContainers --pretty=format:"%h"
https://github.com/ashleyschuett/kubeconfig-cleanup/issues/5
@embano1
embano1 / examples.md
Last active May 16, 2023 12:14
kubectl JSON and sort examples

get events sorted by counts and only some fields we're interested in

$ kubectl -n pubsub get ev --sort-by count -o custom-columns='NAME:.metadata.name,KIND:involvedObject.kind,MSG:.message,FIRST:firstTimestamp,COUNT:.count'

using go templating

$ kubectl get events  --sort-by='.metadata.creationTimestamp'  -o 'go-template={{range .items}}{{.involvedObject.name}}{{"\t"}}{{.involvedObject.kind}}{{"\t"}}{{.message}}{{"\t"}}{{.reason}}{{"\t"}}{{.type}}{{"\t"}}{{.firstTimestamp}}{{"\n"}}{{end}}'