Skip to content

Instantly share code, notes, and snippets.

View eigenhombre's full-sized avatar

John Jacobsen eigenhombre

View GitHub Profile
@eigenhombre
eigenhombre / gist:5230418
Created March 24, 2013 03:49
lein test failure on core.matrix (out of the box)
env)10:45:46 Clojure (master) > git clone [email protected]:eigenhombre/matrix-api.git
Cloning into 'matrix-api'...
remote: Counting objects: 4605, done.
remote: Compressing objects: 100% (1654/1654), done.
remote: Total 4605 (delta 1784), reused 4570 (delta 1751)
Receiving objects: 100% (4605/4605), 389.91 KiB | 387 KiB/s, done.
Resolving deltas: 100% (1784/1784), done.
(env)10:46:25 Clojure (master) > cd matrix-api/
(env)10:46:31 matrix-api (master) > lein test
Retrieving com/google/caliper/caliper/0.5-rc1/caliper-0.5-rc1.pom from central
@eigenhombre
eigenhombre / gist:5238976
Last active December 15, 2015 09:29
Migrations on Ubuntu 12.10
Andreas's problem:
hi. trying to get i3live running on ubuntu 12.04 and while doing 'python manage.py migrate' I get:
> livedata:0008_allow_null_fields_for_veri
! Error found during real run of migration! Aborting.
! Since you have a database that does not support running
! schema-altering statements in transactions, we have had
! to leave it in an interim state between migrations.
! You *might* be able to recover with:
! The South developers regret this has happened, and would
@eigenhombre
eigenhombre / gist:5338541
Last active December 15, 2015 23:09
doms on ichub21
pdaq@ichub21[~] 17:11:26 (0)$ cat /proc/driver/domhub/card?/pair?/is-plugged
Card 0 Pair 0 is plugged in.
Card 0 Pair 1 is plugged in.
Card 0 Pair 2 is not plugged in.
Card 0 Pair 3 is not plugged in.
Card 1 Pair 0 is plugged in.
Card 1 Pair 1 is plugged in.
Card 1 Pair 2 is not plugged in.
Card 1 Pair 3 is not plugged in.
pdaq@ichub21[~] 17:11:43 (0)$
@eigenhombre
eigenhombre / boiler.py
Last active December 18, 2015 13:09 — forked from mrocklin/slotted.py
class Boiler(object):
""" Boilerplate for standard Python class
>>> class Account(Boiler):
... __slots__ = ['first', 'last', 'id', 'balance']
...
... def name(self):
... return "%s %s" (self.first, self.last)
>>> guido = Account('Guido', 'van Rossum', 0, 1000.)
"""
@eigenhombre
eigenhombre / gist:5789004
Created June 15, 2013 18:07
Find all numbers < 1000 evenly divisible by 33 and 8...
(ns trycore.core
(:require [clojure.core.logic :as l]
[clojure.core.logic.fd :as fd]))
(l/run* [q]
(l/fresh [x y]
(fd/in x y q (fd/interval 1 1000))
(fd/eq (= (* x 33) q))
(fd/eq (= (* y 8) q))))
(->> human
sequence-headers
(map (juxt :name :dna-size :n-block-count))
clojure.pprint/pprint)
;; Gives:
(["chr1" 249250621 39]
["chr2" 243199373 24]
(->> human
sequence-headers
first
((juxt :n-block-starts :n-block-sizes))
(apply interleave)
(partition 2)
(map vec)
clojure.pprint/pprint)
import contextlib
@contextlib.contextmanager
def foo():
print "I'm a foo!"
yield
with contextlib.nested(*[foo() for _ in range(200)]):
pass
def test_create_lots_of_threads_and_each_send_a_message():
N = 40
with queueing_receiver() as (q, t):
with contextlib.nested(*[sender() for _ in range(N)]) as senders:
for i, s in enumerate(senders):
s.send(str(i))
t.wakeup()
eq(len([q.get(timeout=1) for _ in range(N)]), N)
@eigenhombre
eigenhombre / gist:6063797
Last active December 20, 2015 03:29
Creating an object which sets up and tears down multiple context managers
import contextlib
import threading
@contextlib.contextmanager
def pcontext():
print "in context"
yield 66