Skip to content

Instantly share code, notes, and snippets.

View tuulos's full-sized avatar

Ville Tuulos tuulos

View GitHub Profile
def fun_mapinit(input_iter, params):
import os
os.environ["DYLIB_LIBRARY_PATH"] = "your_path"
params.pycuda = __import__("pycuda")
handle_cast({update_config_table, Config}, S) ->
error_logger:info_report([{"Config table update"}]),
Update = fun({Host, Slots}, DNodes) ->
DNode = case gb_trees:lookup(Host, S#state.nodes) of
none ->
#dnode{name = Host,
slots = Slots,
node_mon = monitor(Host)};
{value, N} ->
N#dnode{slots = Slots}
handle_cast({update_config_table, Config}, S) ->
error_logger:info_report([{"Config table update"}]),
Update =
fun({Host, Slots}, DNodes) ->
DNode =
case gb_trees:lookup(Host, S#state.nodes) of
none ->
#dnode{name = Host,
slots = Slots,
node_mon = monitor(Host)};
handle_cast({update_config_table, Config}, S) ->
error_logger:info_report([{"Config table update"}]),
UpdateNodes = fun({Host, Slots}, DNodes) ->
DNode = case gb_trees:lookup(Host, S#state.nodes) of
none ->
#dnode{name = Host,
slots = Slots,
node_mon = monitor(Host)};
{value, N} ->
N#dnode{slots = Slots}
@tuulos
tuulos / README.md
Created March 10, 2012 01:36
Bitdeli Visualization Example: Trains arriving to BART stations in next 15 minutes

Bitdeli visualization example: Trains arriving to BART stations in next 15 minutes

This example shows how to use real-time data from the Bitdeli API to create visualizations with RaphaelJS.

The visualization shows a BART station on each column. The further the estimated time arrival is for a train, the further it is drawn from its destination station down bottom. The data is updated once a minute. Refresh the page to see the updated status.

The data originates from the BART API through this Bitdeli script.

You can view the live visualization here with bl.ocks.org.

@tuulos
tuulos / gist:4029841
Created November 7, 2012 06:29
Churn in Bitdeli
import bitdeli, json
from datetime import datetime
from time import mktime, strptime
bitdeli.set_theme('eighties')
BASELINE = mktime(strptime('2012-03-01', '%Y-%m-%d'))
all_users = [0] * 30
active_users = [0] * 30
@tuulos
tuulos / bitdeli-bulk-load.py
Last active October 12, 2015 12:57
fix sending of the remaining buffer
import json
import sys
import urllib
BITDELI_API = 'https://track.bitdeli.com/events'
MAX_BUFFER_SIZE = 8 * 1024 * 1024
DATA = sys.argv[1]
INPUT_ID = sys.argv[2]
AUTH = sys.argv[3]
@tuulos
tuulos / reproduce-munmap-issue.go
Created August 9, 2016 00:15
Reproduce tdb.close() issue in Go. Comment out db.Close() to make this work.
package main
import (
"os"
"sync"
"github.com/traildb/traildb-go"
)
var NUM_WORKERS = 16
@tuulos
tuulos / profileflow.py
Created February 2, 2021 05:32
Profile memory in Metaflow
from metaflow import FlowSpec, step
from functools import wraps
def profile_memory(f):
@wraps(f)
def func(self):
from memory_profiler import memory_usage
self.mem_usage = memory_usage((f, (self,), {}), timeout=6000000, interval=1)
return func