Skip to content

Instantly share code, notes, and snippets.

#! /usr/bin/python -i
# -*-python-*-
def partitions(s):
"""return a list of all paritions of a string s into palindromes"""
def prependToAll(element, lists):
"""takes an element, and a list of lists, and returns a new list of lists with
the given element prepended to each one"""
return [[element] + lst for lst in lists]
memo = {}
@embeepea
embeepea / needle.clj
Last active August 29, 2015 14:15
Clojure Needle Search
(defmacro if-nonneg [a b]
"Eval the 1st arg, and if it's nonnegative, return it without evaling the 2nd arg.
If the 1st arg evals to negative, eval and return the value of the 2nd arg."
`(let [v# ~a] (if (>= v# 0) v# ~b)))
(defn inc-if-nonneg [x]
"Return a value that is 1 more than x if x is nonnegative; otherwise return x."
(if (>= x 0) (inc x) x))
(defn find-needle-end [n h]
@embeepea
embeepea / index.html
Last active December 18, 2015 02:29
Dashboard NAOI
<html>
<head>
<script type="text/javascript" src="http://multigraph.github.io/download/multigraph-min.js"></script>
</head>
<script type="text/javascript">
window.multigraph.jQuery(document).ready(function() {
window.multigraph.jQuery('#graph').multigraph({
mugl : 'naoi.xml'
});
});
<mugl>
<horizontalaxis type="datetime" min="20120920" max="20120927"/>
<verticalaxis min="0" max="100"/>
<data>
<variables>
<variable id="x" type="datetime"/>
<variable id="y"/>
</variables>
<service location="http://acis.multigraph.org/acisdata/13881-1/maxt/"/>
</data>
<?xml version="1.0"?>
<mugl>
<data>
<values>
0, 3
1, 2
2, 4
3, 5
4, 3
5, 6