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
func! DeleteTrailingWS() | |
exe "normal mz" | |
%s/\s\+$//ge | |
exe "normal `z" | |
endfunc | |
for suffix in ["py", "js", "css", "cpp", "c", "h", "hpp", "rs", "groovy", "groovy.j2"] | |
execute 'autocmd BufWrite *.'.suffix.' :call DeleteTrailingWS()' | |
endfor | |
for prefix in ["Jenkinsfile"] | |
execute 'autocmd BufWrite '.prefix.'* :call DeleteTrailingWS()' |
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
from itertools import islice, zip_longest | |
def yield_subgroups(group, subgroup_test): | |
subgroup = [] | |
for i, j in zip_longest(group, islice(group, 1, None)): | |
if subgroup_test(i, j): | |
yield subgroup | |
subgroup = [] | |
else: |
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
import ( | |
"encoding/json" | |
) | |
// Given an input slice of bytes representing an arbitrary JSON object and a slice of strings containing keys | |
// which should not exist in the input JSON object, remove these keys from original object. | |
func removeKeysFromJSONObject(input *map[string]json.RawMessage, keys []string) { | |
for _, key := range keys { | |
delete(*input, key) | |
} |
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
const ( | |
DatabaseConfigFile = "database.json" | |
DatabaseDriver = "mysql" | |
DatabaseKey = "db" | |
) | |
type DatabaseConfig struct { | |
Driver struct { | |
Database string `json:"dbname"` | |
Host string `json:"host"` |
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
#!/bin/zsh | |
# Example: in $dir git status | |
(source ~/.zshrc; cd $1; ${@:2}) |
OlderNewer