Skip to content

Instantly share code, notes, and snippets.

View campoy's full-sized avatar

Francesc Campoy campoy

View GitHub Profile
@campoy
campoy / main.go
Last active August 1, 2019 23:33
Estimating size for protobuf in memory
package main
import (
"flag"
"fmt"
"io/ioutil"
"log"
"unsafe"
"github.com/creachadair/misctools/sizeof"
@campoy
campoy / query.js
Created July 30, 2019 05:19
Cameo query
{
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)) {
@campoy
campoy / main.go
Last active November 9, 2019 12:28
Dgraph: K-Shortest Path with all predicates
package main
import (
"context"
"encoding/json"
"flag"
"fmt"
"log"
"strings"
@campoy
campoy / batchdb.go
Created June 21, 2019 19:41
Showing how to batch your writes automatically with WriteBatch
package main
import (
"log"
"math/rand"
"sync"
"time"
"github.com/dgraph-io/badger/v2"
)
@campoy
campoy / mandelbrot.go
Created August 27, 2018 14:27
Creating mandelbrot, one pixel at a time
package main
import (
"flag"
"image"
"image/color"
"image/png"
"log"
"os"
)
@campoy
campoy / mandelbrot.go
Created August 27, 2018 14:27
Creating mandelbrot, one pixel at a time
package main
import (
"flag"
"image"
"image/color"
"image/png"
"log"
"os"
)
@campoy
campoy / main.go
Created April 19, 2018 18:15
Don't use panics as exceptions.
package main
import (
"log"
"net/http"
)
func main() {
http.HandleFunc("/", handler)
log.Fatal(http.ListenAndServe(":8080", nil))
function sum(row, emit) {
const memory = new WebAssembly.Memory({ initial: 256, maximum: 256 });
const env = {
'abortStackOverflow': _ => { throw new Error('overflow'); },
'table': new WebAssembly.Table({ initial: 0, maximum: 0, element: 'anyfunc' }),
'tableBase': 0,
'memory': memory,
'memoryBase': 1024,
'STACKTOP': 0,
'STACK_MAX': memory.buffer.byteLength,
const memory = new WebAssembly.Memory({ initial: 256, maximum: 256 });
const env = {
'abortStackOverflow': _ => { throw new Error('overflow'); },
'table': new WebAssembly.Table({ initial: 0, maximum: 0, element: 'anyfunc' }),
'tableBase': 0,
'memory': memory,
'memoryBase': 1024,
'STACKTOP': 0,
'STACK_MAX': memory.buffer.byteLength,
};
package main
import (
"fmt"
"io/ioutil"
"log"
"os"
"strings"
)