Skip to content

Instantly share code, notes, and snippets.

View ggaaooppeenngg's full-sized avatar
🎧
Focusing

Peng Gao ggaaooppeenngg

🎧
Focusing
View GitHub Profile
@ggaaooppeenngg
ggaaooppeenngg / win_dll
Created May 6, 2014 02:47
go调用dll打印彩色字体
package main
import(
"syscall"
"fmt"
)
const(
//标准输出宏
STD_OUTPUT_HANDLE = uint32(-11 & 0xFFFFFFFF)
)
@ggaaooppeenngg
ggaaooppeenngg / daemon.go
Created October 2, 2014 03:44
守护进程
package main
import (
"fmt"
"log"
"os"
"os/exec"
"path/filepath"
"time"
)
@ggaaooppeenngg
ggaaooppeenngg / static_server
Created October 5, 2014 13:54
static server
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <sys/socket.h>
#define PORTNUM 2343
@ggaaooppeenngg
ggaaooppeenngg / test.sh
Created December 22, 2014 12:51
test coverage render
go get
touch coverage.out
go test -coverprofile=coverage.out
go tool cover -html=coverage.out
@ggaaooppeenngg
ggaaooppeenngg / my_promot
Created December 30, 2014 03:40
.bashrc
#神依赖
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 / bashrc
Created July 1, 2015 07:03
PS1_git_branch
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"
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
}
package main
import (
"go/ast"
"go/parser"
"go/token"
"strconv"
)
// 实现一个只支持int,只支持加法,函数只有println,只支持一个参数的Go语言子集....
@ggaaooppeenngg
ggaaooppeenngg / .vimrc
Last active April 14, 2017 04:12
.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
@ggaaooppeenngg
ggaaooppeenngg / sh
Last active January 24, 2017 09:57
get std package names of golang
#!/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"