Skip to content

Instantly share code, notes, and snippets.

Avatar
🎧
Focusing

Peng Gao ggaaooppeenngg

🎧
Focusing
View GitHub Profile
@ggaaooppeenngg
ggaaooppeenngg / iterm2-solarized.md
Created Mar 31, 2017 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + Oh My Zsh + Solarized color scheme + Meslo powerline font + [Powerlevel9k] - (macOS)
View iterm2-solarized.md

Default

Default

Powerlevel9k

Powerlevel9k

@ggaaooppeenngg
ggaaooppeenngg / sh
Last active Jan 24, 2017
get std package names of golang
View sh
#!/bin/sh
# set -x
# set -e
paths=$(find $GOROOT/src -type d | sed '1d' | sed "s|$GOROOT/src/||" | grep -v "^vendor" | grep -v "^cmd" | grep -v "builtin" | tr '\n' ' ')
paths_contains_go_source=""
cd $GOROOT/src
for path in $paths
do
if ls $path/*.go 1> /dev/null 2>&1; then
paths_contains_go_source+="\t\"$path\",\n"
View .vimrc
set tabstop=8
set softtabstop=8
set shiftwidth=8
set noexpandtab
set t_Co=256
set nocompatible " be iMproved, required
filetype off " required
syntax enable
syntax on
View small_golang.go
package main
import (
"go/ast"
"go/parser"
"go/token"
"strconv"
)
// 实现一个只支持int,只支持加法,函数只有println,只支持一个参数的Go语言子集....
View gist:d8a9f78b9447d0896ff3
package main
// Restorer holds a function that can be used
// to restore some previous state.
type Restorer func()
// Restore restores some previous state.
func (r Restorer) Restore() {
r()
}
View .bashrc
get_git_branch(){
local branch
if branch=$(git rev-parse --abbrev-ref HEAD 2>/dev/null); then
printf '%s\n' "${branch^^}" # if on bash 3.2, you may need to use tr instead
else
echo "NORMAL"
fi
}
View bashrc
function get_git_branch()
{
branch__=
git branch &> /dev/null
if [ $? -eq 0 ]; then
branch__=`git branch --no-color | sed -ne 's/^\* \(.*\)$/\1/1p' | tr a-z A-Z`
else
branch__="NORMAL"
View my_promot
#神依赖
alias gg="git log --graph --color --decorate --stat"
alias gs="git status --short"
function my_promot {
local __git_branch='`git branch 2> /dev/null | grep -e ^* | sed -E s/^\\\\\*\ \(.+\)$/git:\\\\\1\/`'
export PS1="\[\e[32;1m\](\[\e[37;1m\]\u\[\e[32;1m\])-(\[\e[37;1m\]\@\d\[\e[32;1m\])-(\[\e[37;1m\]\w\[\e[32;1m\])\n(\[\e[37;1m\]$__git_branch\[\e[32;1m\])->\[\e[0m\]"
}
my_promot
@ggaaooppeenngg
ggaaooppeenngg / test.sh
Created Dec 22, 2014
test coverage render
View test.sh
go get
touch coverage.out
go test -coverprofile=coverage.out
go tool cover -html=coverage.out
@ggaaooppeenngg
ggaaooppeenngg / map
Last active Aug 29, 2015
relfect map function
View map
package main
import (
"fmt"
"reflect"
)
var _map func(fn interface{}, sliceOrMap interface{}) []interface{}
var implMap = func(args []reflect.Value) (resules []reflect.Value) {