Skip to content

Instantly share code, notes, and snippets.

@songgao
songgao / rc.sh
Last active February 23, 2016 02:41
Shell functions for quickly `cd` into Go packages' source directories
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

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:

/*
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
package main
import (
"io"
"net"
"os"
"fmt"
"strings"
"syscall"
"unsafe"
@songgao
songgao / gist:3185894
Created July 27, 2012 02:36
How to enable Gmail notification for Safari 6 in Mountain Lion

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
Hey