Skip to content

Instantly share code, notes, and snippets.

@yulvil
yulvil / gist:96235df34c7705bfe052
Created August 13, 2015 19:04
golang function timeout
package main
import (
"log"
"math/rand"
"time"
)
func init() {
rand.Seed(time.Now().UTC().UnixNano())
package main
import "fmt"
type Foo struct {
verbosity int
}
func (f *Foo) DoSomeDebugging() {
fmt.Println(f.verbosity)
@yulvil
yulvil / gist:2169973ee6737c733ab8
Last active August 29, 2015 14:22
gopherjs golang example template
<html>
<head>
<style type="text/css">
.container {
width: 500px;
clear: both;
}
.container input {
width: 100%;
@yulvil
yulvil / gopherjsweblogger
Created May 29, 2015 23:57
golang gopherjs logger
import "github.com/gopherjs/gopherjs/js"
type WebLogger struct{}
func (w *WebLogger) Write(p []byte) (n int, err error) {
js.Global.Get("document").Call("write", "<pre>"+string(p)+"</pre>")
return len(p), nil
}
@yulvil
yulvil / gist:91b2804c09bd5de305c1
Created April 27, 2015 18:40
golang tls ssl ssllabs
// Work for iOS 6+ Safari, WP 8.x IE 11 and Android 4.4.2+
config := &tls.Config{
MinVersion: tls.VersionTLS12, // tls.VersionTLS10
PreferServerCipherSuites: true,
CipherSuites: []uint16{tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,
tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,
tls.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA,
tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,
@yulvil
yulvil / gist:1f18e83ac4d00b9d22cf
Created March 28, 2015 21:00
google images search embed
<!DOCTYPE html>
<html>
<head>
<style>img{ height: 100px; float: left; }</style>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$.getJSON("https://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=death%20valley&callback=?",