Skip to content

Instantly share code, notes, and snippets.

@rossant
rossant / index.md
Last active August 29, 2015 14:12
IPython notebook ==> Python function

Notebooks are great for interactive use, not so much for being reused in an automatic fashion. How to make a notebook reusable (for example in an analysis pipeline)?

Write your notebook 'mynotebook.ipynb' as usual. Then add a special comment in some cells:

### input
x = 0
y = 0
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.node {
stroke: #fff;
stroke-width: 1.5px;
}
.link {
@rossant
rossant / index.html
Last active August 29, 2015 14:12 — forked from mbostock/.block
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.node {
stroke: #fff;
stroke-width: 1.5px;
}
.link {
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.node {
stroke: #fff;
stroke-width: 1.5px;
}
.link {
@rossant
rossant / points.py
Created December 15, 2014 16:23
VisPy example: interactive cloud of points in 3D
import sys
import numpy as np
from vispy import app, scene
canvas = scene.SceneCanvas(keys='interactive')
view = canvas.central_widget.add_view()
view.set_camera('turntable', mode='perspective', up='z', distance=2,
azimuth=30., elevation=30.)
pos = .25 * np.random.randn(1000, 3)
@rossant
rossant / heatmap.py
Created November 25, 2014 22:37
Vispy heatmap
import numpy as np
from vispy import app, gloo
vertex = """
uniform vec4 viewport;
attribute vec2 position;
attribute vec2 texcoord;
varying vec2 v_texcoord;
varying vec2 v_pixcoord;
@rossant
rossant / hdf5_parallel.md
Last active August 29, 2015 14:09
Summary of HDF5 parallel features

This table sums up what is and is not possible with concurrent accesses on HDF5 files using the h5py library.

opened in access mode reading writing
@rossant
rossant / linux_commands.md
Last active August 29, 2015 14:08
Useful Linux commands (tested on Ubuntu 14.04)

Useful Linux commands

Check drive speed

Read

sudo hdparm -t /dev/sda
@rossant
rossant / resizable_widget
Last active August 29, 2015 14:07
resizable_widget in the IPython notebook
{
"metadata": {
"name": "",
"signature": "sha256:bf7f38242e6bc10a68b17ad7a285e23952febabe99e0a86fbb908b4e0511e141"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
@rossant
rossant / basic_widget
Created August 28, 2014 13:33
Minimal IPython widget example
from IPython.html import widgets
from IPython.utils.traitlets import Unicode
class MyWidget(widgets.DOMWidget):
_view_name = Unicode('MyWidget', sync=True)
%%javascript
require(["widgets/js/widget"], function(WidgetManager){
var MyWidget = IPython.DOMWidgetView.extend({