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
# 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
#!/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
" 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
# 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
# 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
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
package main | |
import do "gopkg.in/godo.v2" | |
func tasks(p *do.Project) { | |
// put your go path configuration as appropriate | |
// do.Env = `GOPATH=.vendor::$GOPATH` | |
// do.Env = `GOPATH=$GOPATH` | |
// do.Env = `GOPATH=/Users/me/projects/abcd/dev/gocode::/Users/me/go/gopath` |
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
// my angular2 project is served from the dist directory (configured in angular-cli.json). | |
// when there are changes to the code, I use the below configuration with godo (https://github.com/go-godo/godo) | |
// to automatically build using `ng build --aot | |
// Put this file as <project>/Gododir/main.go within your web project directory. So, the Gododir and src are at the same level. Then run `godo` from the <project> directory≥. | |
package main | |
import do "gopkg.in/godo.v2" | |
func tasks(p *do.Project) { | |
p.Task("default", do.S{"ng-build"}, nil) |
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
# often times I find myself doing a `go build` and then realizing that this project has a different GOPATH | |
# I call the below bash function I am in the go code dir. | |
# It will get the pwd and set the GOPATH automatically to the folder in which there is a "/src/" | |
# depending on whether you are on linux or mac, you can simplify the sed to use the extended options -r or -e respectively, but I've kept it universal for now | |
function setgopath() { | |
pwd=`pwd` | |
newGoPath=`echo $pwd | sed 's/\(.*\)\/src\/.*/\1/'` | |
if [ -z $newGoPath ]; then | |
echo "GOPATH not changed" |