This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"os" | |
fzf "github.com/junegunn/fzf/src" | |
) | |
func main() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
all-pods() { | |
FZF_DEFAULT_COMMAND=' | |
(echo CONTEXT NAMESPACE NAME READY STATUS RESTARTS AGE | |
for context in $(kubectl config get-contexts --no-headers -o name | sort); do | |
kubectl get pods --all-namespaces --no-headers --context "$context" | sed "s/^/${context%-context} /" | |
done) 2> /dev/null | column -t | |
' fzf --info=inline --layout=reverse --header-lines=1 --border \ | |
--prompt 'all-pods> ' \ | |
--header $'╱ Enter (kubectl exec) ╱ CTRL-O (open log in editor) ╱ CTRL-R (reload) ╱\n\n' \ | |
--bind ctrl-/:toggle-preview \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data = [{ a: 1, b: 9 }, { a: 1, b: 8 }, | |
{ a: 2, b: 7 }, { a: 2, b: 6 }] | |
data.group_by { |h| h[:a] }.transform_values { |xs| xs.max_by { |x| x[:b] } } | |
def key(k) | |
proc { |hash| hash[k] } | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'set' | |
base = ARGV.first || '.' | |
dirs = Set.new | |
$stdin.each_line do |line| | |
dir = File.dirname(line) | |
anc = [] | |
while dirs.add?(dir) | |
anc << dir |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
ag_source() { | |
local query | |
[ -z "$1" ] && query="^(?=.)" || query="$1" | |
ag --nogroup --column --color "$query" 2> /dev/null | |
} | |
filter() { | |
local query="$1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" ---------------------------------------------------------------------------- | |
" tmux | |
" ---------------------------------------------------------------------------- | |
" Recommended | |
let mapleader = ' ' | |
function! s:tmux_send(content, dest) range | |
let dest = empty(a:dest) ? input('To which pane? ') : a:dest | |
let tempfile = tempname() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Copyright (c) 2017 Junegunn Choi | |
" | |
" MIT License | |
" | |
" Permission is hereby granted, free of charge, to any person obtaining | |
" a copy of this software and associated documentation files (the | |
" "Software"), to deal in the Software without restriction, including | |
" without limitation the rights to use, copy, modify, merge, publish, | |
" distribute, sublicense, and/or sell copies of the Software, and to | |
" permit persons to whom the Software is furnished to do so, subject to |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function! JobCallback(self, data) abort | |
echom string([a:self, a:data]) | |
endfunction | |
let command = printf('git clone "https://github.com/junegunn/seoul256.vim.git" "%s\vimfiles\plugged yolo\seoul256.vim" 2>&1', $HOME) | |
let j = job_start(command, {'out_cb': 'JobCallback', 'exit_cb': 'JobCallback'}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"os" | |
"syscall" | |
) | |
func GetBytes() []byte { | |
_in, _ := os.OpenFile("/dev/tty", syscall.O_RDONLY, 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# Managing notes with fzf (https://github.com/junegunn/fzf) | |
# - CTRL-L: List note files in descending order by their modified time | |
# - CTRL-F: Search file contents | |
# | |
# Configuration: | |
# - $NOTE_DIR: Directory where note files are located | |
# - $NOTE_EXT: Note file extension (default: txt) |
NewerOlder