Skip to content

Instantly share code, notes, and snippets.

View campoy's full-sized avatar

Francesc Campoy campoy

View GitHub Profile
package main
import (
"fmt"
"io/ioutil"
"log"
"os"
"strings"
)
function checkAssembly(row, emit) {
emit({ b: WebAssembly != undefined });
}
bigquery.defineFunction(
'checkAssembly',
['x'],
[{ 'name': 'b', 'type': 'boolean' }],
checkAssembly
);
const fs = require('fs');
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,
#include <stdio.h>
#include <dlfcn.h>
int main()
{
int (*sum)(int, int);
void *dl = dlopen("sum.so", RTLD_LAZY);
if (!dl)
{
fprintf(stderr, "%s\n", dlerror());
return 1;
#include <stdio.h>
extern int sum(int a, int b);
int main() {
printf("%d\n", sum(39, 3));
return 0;
}
int sum(int a, int b)
{
return a + b;
}
function intdiv(row, emit) {
emit({ d: row.x / row.y, m: row.x % row.y });
}
bigquery.defineFunction(
'intdiv',
['x', 'y'],
[{ 'name': 'd', 'type': 'integer' },
{ 'name': 'm', 'type': 'integer' }],
intdiv
);
function identity(row, emit) {
emit({ y: row.x });
}
bigquery.defineFunction(
'identity',
['x'],
[{ 'name': 'y', 'type': 'float' }],
identity
);
modelBytes, _ := assets.Asset("model.pb")
graph := tf.NewGraph()
graph.Import(modelBytes, "")
input := graph.Operation("input").Output(0)
output := graph.Operation("output").Output(0)
sess, _ := tf.NewSession(graph, &tf.SessionOptions{})
feed, _ := tf.NewTensor([][]float32{})
result, _ := sess.Run(
map[tf.Output]*tf.Tensor{input: input1},
[]tf.Output{output}, nil)
@campoy
campoy / Dockerfile
Created March 29, 2018 19:56
One liner gemini
FROM ubuntu:16.04
# install java 8 and other tools
RUN apt-get update && apt-get install -y --no-install-recommends default-jdk curl git && \
rm -rf /var/lib/apt/lists/* && \
# needed to install cassandra
apt-get install -y --no-install-recommends curl && \
echo "deb http://www.apache.org/dist/cassandra/debian 311x main" >> /etc/apt/sources.list.d/cassandra.sources.list && \
curl https://www.apache.org/dist/cassandra/KEYS | apt-key add - && \
apt-key adv --keyserver pool.sks-keyservers.net --recv-key A278B781FE4B2BDA && \