Skip to content

Instantly share code, notes, and snippets.

View takac's full-sized avatar
🧇

Tom Cammann takac

🧇
View GitHub Profile

Keybase proof

I hereby claim:

  • I am takac on github.
  • I am takac (https://keybase.io/takac) on keybase.
  • I have a public key ASBoobMV-tyR6-2a5XojpAqwpaWarlZSbPPbGaKsvgamZQo

To claim this, I am signing this object:

#!/bin/bash
set -eu
if [[ ! -z "${DEBUG:-}" ]]; then
set -x
fi
function project_kube_check() {
PROJECT=${1:-$(gcloud config get-value project -q)}
ZONES=$(gcloud --project=$PROJECT --format='value[](zone)' container clusters list | uniq)
@takac
takac / zsh_functions.sh
Created June 9, 2015 13:13
Useful shell functions
function agv()
{
command ag $@ | vim -c "setlocal buftype=nofile bufhidden=hide noswapfile" -c "let @/="'"'$@'"'" | set hls" -
}
# List files in git status using relative paths
function gip()
{
# Can provide a matcher against the porcelain tags, i.e. "M ", "UU", etc
# If not provided return all files listed in git status
#!/bin/zsh
# Quick file finder.
#
# Search for whole term:- "*myterm*"
# $ fn search
# 0 search.py
# 1 dir/place/search-items.html
# 2 dir/my_search.lst
#
f()
{
LAST=$(fc -l | tail -1 | sed 's/^\s*[0-9]\+\s\+//')
CMMD=${LAST%% *}
if [[ ${CMMD} == "mkdir" ]]; then
cd "${LAST#* }"
elif [[ ${CMDD} == "cd" ]]; then
cd -
elif [[ ${CMDD} == "fish" ]]; then
cd -
cowfortune() {
fortune | cowsay -f $(cowsay -l | sed -n '2,$s/ /\n/gp' | sort -R | head -n1)
}
@takac
takac / FactAndFib.java
Created December 31, 2013 11:19
Constant time solutions to Fibonacci and factorial calculations.
package fact;
import static java.lang.Math.PI;
import static java.lang.Math.exp;
import static java.lang.Math.log;
import static java.lang.Math.pow;
import static java.lang.Math.rint;
import static java.lang.Math.sqrt;
public class FactAndFib {
@takac
takac / gist:8176611
Created December 30, 2013 00:55
Spotify VIm
let g:spotify_track_search_url = "http://ws.spotify.com/search/1/track.json?q="
function! OpenUri(uri)
exec "silent !explorer " . a:uri
endfunction
function! OpenLine()
let uri = b:uris[line(".")-2]
call OpenUri(uri)
endfunction
@takac
takac / git-rank.sh
Last active December 20, 2015 05:38
Git Contributor Rank
# Contributor Ranking
#
# Author: Tom Cammann
#
function contrib_list {
# Find all email address names used to commit
authors=$( git log --format='%aE' | cut -d"@" -f1 | sort -u )
# For each commit match no binary files that have changed and capture the number
# Only match java files
@takac
takac / hardtime.vim
Created July 15, 2013 15:59
Start of vim script to stop repeating movement keys
command! HardTimeOn call HardTimeOn()
command! HardTimeOff call HardTimeOff()
fun! HardTimeOff()
silent! nunmap <buffer> h
silent! nunmap <buffer> j
silent! nunmap <buffer> k
silent! nunmap <buffer> l
silent! nunmap <buffer> -
silent! nunmap <buffer> +