Skip to content

Instantly share code, notes, and snippets.

Avatar

Damon Zhao se77en

View GitHub Profile
@se77en
se77en / random_string.go
Last active Aug 29, 2015
random string in Go
View random_string.go
func randomString(size int) string {
alpha = `abcdefghijkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789` //better to define a const
buf := make([]byte, size)
for i := 0; i < size; i++ {
buf[i] = alpha[rand.Intn(len(alpha))]
}
return string(buf)
}
@se77en
se77en / try_catch.go
Created Apr 4, 2014
go with try catch
View try_catch.go
package main
import "fmt"
type panique interface{}
type catch struct {
cause panique
}
View client.go
package main
import (
"io"
"log"
"mime/multipart"
"net/http"
"os"
"path/filepath"
"runtime"
View index.html
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script class="jquery library" src="/js/sandbox/jquery/jquery-1.8.2.min.js" type="text/javascript"></script>
<title>RunJS 演示代码</title>
</head>
<body>
<div id="con">
abcdefghijklmn
</div>
View IsPrivateIP.go
package main
import "net"
import "fmt"
func main() {
fmt.Println(IsPrivateIP("111.11.191.17"))
fmt.Println(IsPrivateIP("192.168.0.100"))
fmt.Println(IsPrivateIP("10.0.8.100"))
}
@se77en
se77en / css
Last active Aug 29, 2015 — forked from CodeMyUI/css
Sign In/Up Transition By Fabrizio Bianchi : http://codepen.io/fbrz/pen/pvZRNK
View css
@import url(http://fonts.googleapis.com/css?family=Raleway:700,800);
html, body { margin: 0; }
:focus { outline: none; }
::-webkit-input-placeholder { color: #DEDFDF; }
::-moz-placeholder { color: #DEDFDF; }
:-moz-placeholder { color: #DEDFDF; }
::-ms-input-placeholder { color: #DEDFDF; }
@se77en
se77en / index.gohtml
Last active Aug 29, 2015 — forked from ericlagergren/index.gohtml
Hot-reloading / hot-swapping live template files in Go
View index.gohtml
My name is {{.Name}} and I'm {{.Age}} years old!!
@se77en
se77en / 0_reuse_code.js
Last active Aug 29, 2015
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@se77en
se77en / gist:420e7bd9a88fd65e9369
Created Oct 14, 2015 — forked from momer/gist:ac20357abd331e23b8ea
A pattern I created to maintain connections to an RPC server in Go. Since net/rpc does not provide any methods for automatically reconnecting to an RPC server, I needed a work-around. Additionally, rpc.Client does not export any state variables (rpc.Client.shutdown and rpc.Client.closing) nor does it export the Client's Mutex. So, we wrap the rp…
View gist:420e7bd9a88fd65e9369
package main
import (
"myapp/webserver/app/common"
"github.com/golang/glog"
"github.com/gorilla/mux"
"encoding/json"
"strconv"
"flag"
"fmt"
View tmux-cheatsheet.markdown

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
You can’t perform that action at this time.