Skip to content

Instantly share code, notes, and snippets.

Song Gao songgao

Block or report user

Report or block songgao

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@songgao
songgao / rc.sh
Last active Feb 23, 2016
Shell functions for quickly `cd` into Go packages' source directories
View rc.sh
gprefresh() {
go list -f "{{.Dir}}" ... 2>/dev/null > $GOPATH/.list;
}
_gpcd() {
if [ "$#" -eq 1 ]; then
cd $1
else
select p in $@; do
_gpcd $p
unset p
View keybase.md

Keybase proof

I hereby claim:

  • I am songgao on github.
  • I am songgao (https://keybase.io/songgao) on keybase.
  • I have a public key whose fingerprint is 018C 2285 4633 8910 B9C4 DC19 F18B E915 09E1 F508

To claim this, I am signing this object:

View Benchmark Max Function.go
/*
Benchmarking against different approaches to calculate Max() of int.
* Patented (WTF?!) Abs used. http://stackoverflow.com/a/9962527/218439
Results;
slice size: 1
min_with_branching: 200000000 9.28 ns/op
View TUN example in Go
package main
import (
"io"
"net"
"os"
"fmt"
"strings"
"syscall"
"unsafe"
@songgao
songgao / gist:3185894
Created Jul 27, 2012
How to enable Gmail notification for Safari 6 in Mountain Lion
View gist:3185894

How to enable Gmail notification for Safari 6 in Mountain Lion

If you're like me who uses Safari, and finds Gmail in browser most comfortable to use, you might want to enable notification from Gmail in Safari 6. Notification Center in Mountain Lion does support websites in Safari to send notifications, but by now Gmail does not ask for permission to send notifications. Fortunately Gmail uses html5 notification, which is supported in Safari 6. We can manually request permission from Safari for Gmail.

  1. Enable Develop menu. Safari->Preferences->Advanced: Check "Show Develop menu in menu bar".
  2. Open mail.google.com.
  3. Develop->Show Web Inspector. The console will show at bottom. Paste in following command in the console and press Enter. [1] window.webkitNotifications.requestPermission(function(){alert(window.webkitNotifications.checkPermission());})
  4. If the alert box shows 0, it means mail.google.com successfully gets notification permission. Send yourself an email with a different email addre
You can’t perform that action at this time.