Skip to content

Instantly share code, notes, and snippets.

View se77en's full-sized avatar

Damon Zhao se77en

View GitHub Profile
@se77en
se77en / HelloWorld.scala
Created November 5, 2013 09:09
hello world
object main extends App {
println("hello world")
}
@se77en
se77en / random_string.go
Last active August 29, 2015 13:57
random string in 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 April 4, 2014 08:36
go with try catch
package main
import "fmt"
type panique interface{}
type catch struct {
cause panique
}
package main
import (
"io"
"log"
"mime/multipart"
"net/http"
"os"
"path/filepath"
"runtime"
@se77en
se77en / index.html
Last active August 29, 2015 14:14
gbRVbX
<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>
@se77en
se77en / IsPrivateIP.go
Last active August 29, 2015 14:15 — forked from mapix/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 August 29, 2015 14:25 — forked from CodeMyUI/css
Sign In/Up Transition By Fabrizio Bianchi : http://codepen.io/fbrz/pen/pvZRNK
@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 August 29, 2015 14:25 — forked from ericlagergren/index.gohtml
Hot-reloading / hot-swapping live template files in Go
My name is {{.Name}} and I'm {{.Age}} years old!!
@se77en
se77en / 0_reuse_code.js
Last active August 29, 2015 14:26
Here are some things you can do with Gists in GistBox.
// 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 October 14, 2015 05:49 — forked from momer/grpc_with_reconnect.go
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…
package main
import (
"myapp/webserver/app/common"
"github.com/golang/glog"
"github.com/gorilla/mux"
"encoding/json"
"strconv"
"flag"
"fmt"