Skip to content

Instantly share code, notes, and snippets.

View eigenhombre's full-sized avatar

John Jacobsen eigenhombre

View GitHub Profile
@eigenhombre
eigenhombre / gist:bed80ab20c2bab2ef9d7
Last active August 29, 2015 14:04
Capture the result of an expression and send to i3d3 -- for use with Marginalia notebooks
(ns liveana.i3d3
(:require [clojure.data.json :as json]
[clj-time.core :refer [date-time interval in-seconds now]]
[clj-time.coerce :refer [to-long]]) ; fixme - check unused
(:import [org.joda.time DateTime]))
(def local-js "docs/local.js")
=INFO REPORT==== 25-Apr-2014::15:02:23 ===
accepting AMQP connection <0.301.0> (10.0.2.2:58418 -> 10.0.2.15:5672)
tail: shutdown_log: file truncated
==> shutdown_err <==
==> shutdown_log <==
Stopping and halting node rabbit@precise64 ...
==> [email protected] <==
class TestToyComponentMoniMessage(TestLiveControlWithPDAQ):
@slow
def test(self):
def drain_msgs(q):
ret = []
while True:
try:
msg = q.get(timeout=1)
except pyqueue.Empty:
return ret
@eigenhombre
eigenhombre / gist:7914956
Created December 11, 2013 17:40
More migration fun
[pdaq@i3live63] run: gunzip -c live-latest.sql.gz > live-latest.sql
Creating database...
Enabling access for 'live' user...
Loading database (NOTE: this can take several minutes or more)...
[pdaq@i3live63] run: source /usr/local/pdaq/env/bin/activate&&python manage.py migrate
[pdaq@i3live63] out: Running migrations for livedata:
[pdaq@i3live63] out: - Migrating forwards to 0087_rename_type_to_name.
[pdaq@i3live63] out: > livedata:0004_add_comment_sticky_field
[pdaq@i3live63] out: > livedata:0005_comments_for_non_run_times
[pdaq@i3live63] out: > livedata:0006_i3moni_merge
> db.live.find( { time: { $exists: false } }, {t: 1, service: 1, varname: 1})
{ "_id" : ObjectId("51cb5ee72d12006f0fe9f523"), "service" : "pdaq", "varname" : "stringDOMsInfo", "t" : "2012-03-09 20:52:46.167096" }
{ "_id" : ObjectId("51cb5ee72d12006f0fe9f524"), "service" : "spade_sattx1", "varname" : "procs_hist", "t" : "2012-03-09 21:09:28.099478" }
{ "_id" : ObjectId("51cb5ee72d12006f0fe9f525"), "service" : "spade_sattx2", "varname" : "procs_hist", "t" : "2012-03-09 21:09:30.315411" }
{ "_id" : ObjectId("51cb5ee72d12006f0fe9f526"), "service" : "spade_sattx3", "varname" : "procs_hist", "t" : "2012-03-09 21:09:31.522344" }
{ "_id" : ObjectId("51cb5ee72d12006f0fe9f535"), "service" : "eden", "varname" : "lunch", "t" : "2012-03-12 18:20:21.232797" }
{ "_id" : ObjectId("51cb5ee72d12006f0fe9f54c"), "service" : "dmice", "varname" : "event", "t" : "2012-03-12 19:46:03.394921" }
{ "_id" : ObjectId("51cb5ee72d12006f0fe9f555"), "service" : "pdaq", "varname" : "runstop", "t" : "2012-03-12 19:11:47.492316" }
{ "_id" : Obj
@eigenhombre
eigenhombre / i3d3.js
Last active December 27, 2015 17:29
i3d3 with zooming/panning
"use strict";
/*global d3 */
/*jslint plusplus: true, white: true */
// Make a well-behaved module a la http://o2js.com/2011/04/24/the-module-pattern/:
if(!i3d3) {
var i3d3 = {};
}
@eigenhombre
eigenhombre / gist:6854438
Last active December 24, 2015 19:59
pmap in python
from toolz import map, drop, first
import Queue
import contextlib
import itertools
import multiprocessing
import threading
import time
def timeit(f):
@eigenhombre
eigenhombre / gist:6849176
Last active December 24, 2015 19:19
Separate generation and consumption of iterable in separate threads
import Queue
import contextlib
import threading
import time
@contextlib.contextmanager
def threaded(*args, **kwargs):
t = threading.Thread(*args, **kwargs)
t.start()
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<body>
<link rel="stylesheet" type="text/css" href="https://rawgithub.com/eigenhombre/i3d3/master/style.css"/>
<script type="text/javascript"
src="http://cdnjs.cloudflare.com/ajax/libs/d3/3.0.1/d3.v3.min.js"></script>
<script type="text/javascript"
src="http:////cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.1/underscore-min.js"></script>
Last login: Wed Sep 11 15:31:18 on ttys001
(env)03:31:38 i3d3 (master) > saccbg
(env)03:31:41 i3d3 (master) > slive
ssh: connect to host localhost port 61022: Connection refused
(env)03:31:43 i3d3 (master) > pub
(env)03:31:47 i3d3 (master) > saccbg
(env)03:31:50 i3d3 (master) > slive
pdaq@localhost's password:
Last login: Tue Sep 10 22:19:33 2013 from access.sptsn.icecube.wisc.edu
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~