This file contains hidden or 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" | |
"encoding/json" | |
) | |
var d1 = []byte(` | |
{ |
This file contains hidden or 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
# add this to your .profile or .bashrc or other. | |
alias wifitoggle='echo -n "Previous status: " && networksetup -getairportpower en0 | grep "Wi-Fi"; networksetup -getairportpower en0 | grep -q "On" && networksetup -setairportpower en0 off || networksetup -setairportpower en0 on; echo -n "New status: " && networksetup -getairportpower en0 | grep "Wi-Fi"; ' |
This file contains hidden or 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
# go into dir with a specific file in the subdirectory | |
function cdf() { | |
f=$(dirname $(find . -iname "*$1*" -type f -print -quit 2>/dev/null | head -1) 2>/dev/null) | |
if [ -z "$f" ]; then | |
echo #'not found' | |
else | |
#echo "found in:" $f | |
cd "$f" | |
fi | |
} |
This file contains hidden or 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
" surround selection with parentheses, quotes, braces, brackets | |
xnoremap <leader>( xi ()<Esc>P | |
xnoremap <leader>" xi ""<Esc>P | |
xnoremap <leader>{ xi {}<Esc>P | |
xnoremap <leader>' xi ''<Esc>P | |
xnoremap <leader>[ xi []<Esc>P |
This file contains hidden or 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/bash | |
# a script to check the git status of many repos together | |
# this one is customized to work with a given list of git repos rather than all repos under a specified folder | |
# based on: https://gist.github.com/aroberts/3018100 | |
# You can add something like this to your .profile/.bashrc to make it convenient to call this from anywhere | |
# alias allgit='path-to-project/dev-setup/project-git-repos-status.sh' | |
red="\033[00;31m" |
This file contains hidden or 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
# A very useful (and very much used) bash script I found recently to go back up to any dir in the current path. Supports autocomplete also which is awesome. | |
# go back up to a directory - https://unix.stackexchange.com/questions/14303/bash-cd-up-until-in-certain-folder | |
function up() | |
{ | |
if [ -z "$1" ]; then | |
return | |
fi | |
local upto=$1 | |
cd "${PWD/\/$upto\/*//$upto}" |
This file contains hidden or 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 ( | |
"flag" | |
"fmt" | |
"io" | |
"log" | |
"os" | |
"path/filepath" | |
"strings" |
This file contains hidden or 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
// sometimes windows people don't have curl. | |
// This is a simple way to post a curl POST request. | |
// On newer windows versions, you can also try ... | |
// Invoke-WebRequest -Body '{"Author":"A", "Title":"B"}' -Method 'POST' -Uri 'http://localhost:8090/books' | |
package main | |
import ( | |
"fmt" |
This file contains hidden or 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
# usage | |
# cdr a1.b1 | |
# ... this matches all dirs .*a1.*b1.* | |
# cdr ^a1.b1$ | |
# ... this matches all dirs ^./a1.*b1$ | |
# go into dir with a specific file in the subdirectory. Uses regex and substitues . with .* | |
function cfr() { | |
pat=$1 | |
#replace . with .* - so we can give multiple parts |
This file contains hidden or 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
https://play.golang.org/p/eBOqfC0V59N - web.go | |
https://play.golang.org/p/kmZms7FoWss - web_test.go | |
https://play.golang.org/p/zVDTSq7jCP6 - web_http_test.go |