Skip to content

Instantly share code, notes, and snippets.

Avatar
:bowtie:
workin' on some stuff

Francesc Campoy campoy

:bowtie:
workin' on some stuff
View GitHub Profile
@campoy
campoy / main.go
Last active Aug 1, 2019
Estimating size for protobuf in memory
View main.go
package main
import (
"flag"
"fmt"
"io/ioutil"
"log"
"unsafe"
"github.com/creachadair/misctools/sizeof"
View query.js
{
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 Nov 9, 2019
Dgraph: K-Shortest Path with all predicates
View main.go
package main
import (
"context"
"encoding/json"
"flag"
"fmt"
"log"
"strings"
@campoy
campoy / batchdb.go
Created Jun 21, 2019
Showing how to batch your writes automatically with WriteBatch
View batchdb.go
package main
import (
"log"
"math/rand"
"sync"
"time"
"github.com/dgraph-io/badger/v2"
)
@campoy
campoy / mandelbrot.go
Created Aug 27, 2018
Creating mandelbrot, one pixel at a time
View mandelbrot.go
package main
import (
"flag"
"image"
"image/color"
"image/png"
"log"
"os"
)
@campoy
campoy / mandelbrot.go
Created Aug 27, 2018
Creating mandelbrot, one pixel at a time
View mandelbrot.go
package main
import (
"flag"
"image"
"image/color"
"image/png"
"log"
"os"
)
@campoy
campoy / main.go
Created Apr 19, 2018
Don't use panics as exceptions.
View main.go
package main
import (
"log"
"net/http"
)
func main() {
http.HandleFunc("/", handler)
log.Fatal(http.ListenAndServe(":8080", nil))
View udf.js
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,
View main.js
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,
};
View main.go
package main
import (
"fmt"
"io/ioutil"
"log"
"os"
"strings"
)
You can’t perform that action at this time.