This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bufio" | |
"fmt" | |
"os" | |
"time" | |
) | |
const numWorkers = 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2017 Google Inc. All rights reserved. | |
// Licensed under the Apache License, Version 2.0 (the "License"); | |
// you may not use this file except in compliance with the License. | |
// You may obtain a copy of the License at | |
// http://www.apache.org/licenses/LICENSE-2.0 | |
// | |
// Unless required by applicable law or agreed to writing, software distributed | |
// under the License is distributed on a "AS IS" BASIS, WITHOUT WARRANTIES OR | |
// CONDITIONS OF ANY KIND, either express or implied. | |
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func merge(a, b <-chan int) <-chan int { | |
c := make(chan int) | |
go func() { | |
defer close(c) | |
for a != nil || b != nil { | |
select { | |
case v, ok := <-a: | |
if !ok { | |
fmt.Println("a is done") | |
a = nil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int sum(int a, int b) | |
{ | |
return a + b; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Hello, from Go</title> | |
</head> | |
<body> | |
<h1>Hello</h1> | |
<p> | |
This is Go code running, {{.}} | |
</p> | |
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM debian:jessie-backports as build | |
RUN apt-get update && apt-get install -y \ | |
asciidoc asciidoctor source-highlight graphviz \ | |
gcc libssl-dev uuid-dev libncurses-dev libcurl4-openssl-dev flex clang-3.5 bison \ | |
parallel | |
RUN apt-get install -y -t jessie-backports openjdk-8-jdk | |
# install golang | |
RUN apt-get install -y curl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func mergeRec(chans ...<-chan int) <-chan int { | |
switch len(chans) { | |
case 0: | |
c := make(chan int) | |
close(c) | |
return c | |
case 1: | |
return chans[0] | |
default: | |
m := len(chans) / 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
"encoding/json" | |
"flag" | |
"fmt" | |
"log" | |
"strings" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"flag" | |
"fmt" | |
"io/ioutil" | |
"log" | |
"unsafe" | |
"github.com/creachadair/misctools/sizeof" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
spielberg as var(func: allofterms(name@en, "steven spielberg")) { | |
uid | |
} | |
cameos(func: uid(spielberg)) @cascade @normalize { | |
director : name@en | |
director.film { | |
film : name@en | |
starring { | |
performance.actor @filter(uid(spielberg)) { |
NewerOlder