Skip to content

Instantly share code, notes, and snippets.

@mdengler
mdengler / README.md
Last active October 11, 2017 02:32
SugarLabs clock device patch and mockups
#!/usr/bin/env python
import json
import random
filename = "test.json"
x = [{"ID": i,
"xxx": "".join(["f"] * random.randint(1, 20)),
"yyy": "".join(["f"] * random.randint(1, 20))}
for i in range(20)]
@mdengler
mdengler / slice panel4d
Created June 10, 2016 03:25
panel4d iloc and slices?
>>> p4 = pd.Panel4D({i: pd.Panel({j: pd.DataFrame(range(10)) for j in range(10)}) for i in range(10)})
>>> p4.iloc[:,:,0]
<class 'pandas.core.panel.Panel'>
Dimensions: 10 (items) x 10 (major_axis) x 1 (minor_axis)
Items axis: 0 to 9
Major_axis axis: 0 to 9
Minor_axis axis: 0 to 0
>>> p4.iloc[slice(None), slice(None), slice(0)]
<class 'pandas.core.panelnd.Panel4D'>
Dimensions: 10 (labels) x 10 (items) x 0 (major_axis) x 1 (minor_axis)
every_nth = [2, 3]
index = pd.Series(range(len(df.index))) # or just df.index if it's already the 0-indexed indices
mask = reduce(np.logical_or, [index % i == 0 for i in every_nth])
df[mask.astype(bool).values]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mdengler
mdengler / install-tmux
Last active October 19, 2015 22:46 — forked from rothgar/install-tmux
Install tmux 2.1 on rhel/centos 6
# Install tmux on Centos release 6.5
# install deps
yum install gcc kernel-devel make ncurses-devel
# DOWNLOAD SOURCES FOR LIBEVENT AND MAKE AND INSTALL
curl -OL https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
tar -xvzf libevent-2.0.21-stable.tar.gz
cd libevent-2.0.21-stable
./configure --prefix=$HOME &&
### Keybase proof
I hereby claim:
* I am mdengler on github.
* I am mdengler (https://keybase.io/mdengler) on keybase.
* I have a public key whose fingerprint is 565C 8F33 ABF7 2DAA 33DE B9CB 81B4 44DD 75C7 D2F8
To claim this, I am signing this object:
@mdengler
mdengler / README.md
Last active August 29, 2015 14:02 — forked from mbostock/.block
Wilson's algorithm by mbostock, with quicker-completion starting conditions

Wilson’s algorithm uses loop-erased random walks to generate a uniform spanning tree — an unbiased sample of all possible spanning trees. Most other maze generation algorithms, such as Prim’s, random traversal and randomized depth-first traversal, do not have this beautiful property.

The algorithm initializes the maze with eight arbitrary starting cells. Then, a new cell is added to the maze, initiating a random walk (shown in magenta). The random walk continues until it reconnects with the existing maze (shown in white). However, if the random walk intersects itself, the resulting loop is erased before the random walk continues.

The global structure of the maze can be more easily seen by flooding it with color.

To play with this yourself, [instructions from Uehreka on http://news.yco

@mdengler
mdengler / test.py
Created May 14, 2014 23:23
test case for nose #711
#!/usr/bin/python
# to use:
# 1) git clone [email protected]:jszakmeister/nose.git nose-711
# 2) cd nose-711
# 3) python setup.py build
# 4) cd build/lib
# 5) put this file there as test.py
# 6) PYTHONPATH=$PWD python -m nose ./test.py
# # observe the error: