Skip to content

Instantly share code, notes, and snippets.

View campoy's full-sized avatar

Francesc Campoy campoy

View GitHub Profile
func merge(cs ...<-chan int) <-chan int {
out := make(chan int)
for _, c := range cs {
go func(c <-chan int) {
for v := range c {
out <- v
}
}(c)
}
func main() {
a := asChan(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
b := asChan(10, 11, 12, 13, 14, 15, 16, 17, 18, 19)
c := asChan(20, 21, 22, 23, 24, 25, 26, 27, 28, 29)
for v := range merge(a, b, c) {
fmt.Println(v)
}
}
func merge(cs ...<-chan int) <-chan int {
out := make(chan int)
for _, c := range cs {
go func() {
for v := range c {
out <- v
}
}()
}
@campoy
campoy / Dockerfile
Created January 27, 2018 18:55
Building kythe in a Docker image
FROM debian:jessie-backports
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
@campoy
campoy / getting-started.md
Last active January 27, 2018 01:54
source{d} engine quick start guide

Quick Start Guide

This guide will take you through the main steps needed to get started with the source{d} engine on your own premises.

Architecture

The source{d} engine can be run very easily inside of a Docker container and has only one external dependency: babelfish. Babelfish provides language agnostic parsing, and you can also run it very easily with a Docker container.

Sourcing the data

@campoy
campoy / curl.bash
Created January 24, 2018 20:04
Calling the host babelfish API
curl -d @request.json http://dashboard.bblf.sh/api/parse
@campoy
campoy / curl.bash
Created January 24, 2018 20:04
Calling the host babelfish API
curl -d @request.json http://dashboard.bblf.sh/api/parse
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
func merge(a, b <-chan int) <-chan int {
c := make(chan int)
go func() {
defer close(c)
adone, bdone := false, false
for !adone || !bdone {
select {
case v, ok := <-a:
if !ok {
log.Println("a is done")
func merge(a, b <-chan int) <-chan int {
c := make(chan int)
go func() {
defer close(c)
adone, bdone := false, false
for !adone || !bdone {
select {
case v, ok := <-a:
if !ok {
adone = true