Skip to content

Instantly share code, notes, and snippets.

@smilingleo
smilingleo / equivalent_binary_tree.go
Last active September 8, 2015 00:32
Exercise: Equivalent Binary Trees (https://tour.golang.org/concurrency/8)
package main
import (
"golang.org/x/tour/tree"
"fmt"
)
// Walk walks the tree t sending all values
// from the tree to the channel ch.
func Walk(t *tree.Tree, ch chan int) {
@smilingleo
smilingleo / gist:6518914
Last active December 22, 2015 19:19
CORS-enabled API
function createXHR(method, url) {
var xhr = new XMLHttpRequest();
if (xhr) {
// XHR for Chrome/Firefox/Opera/Safari.
xhr.open(method, url, true);
} else {
// CORS not supported.
xhr = null;
}
return xhr;
var x1=1, y1=1;