Skip to content

Instantly share code, notes, and snippets.

# Example from http://jakevdp.github.io/blog/2013/06/01/ipython-notebook-javascript-python-communication/ adapted for IPython 2.0
# Add an input form similar to what we saw above
from IPython.display import HTML
from math import pi, sin
input_form = """
<div style="background-color:gainsboro; border:solid black; width:600px; padding:20px;">
Code: <input type="text" id="code_input" size="50" height="2" value="sin(pi / 2)"><br>
Result: <input type="text" id="result_output" size="50" value="1.0"><br>
@jarutis
jarutis / ubuntu.sh
Last active November 9, 2020 09:01
Theano and Keras setup on ubuntu with OpenCL on AMD card
## install Catalyst proprietary
sudo ntfsfix /dev/sda2
sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.BAK
sudo apt-get remove --purge fglrx*
sudo apt-get install linux-headers-generic
sudo apt-get install fglrx xvba-va-driver libva-glx1 libva-egl1 vainfo
sudo amdconfig --initial
## install build essentials
sudo apt-get install cmake
from __future__ import absolute_import
from __future__ import print_function
from keras.datasets import mnist
from keras.models import Sequential
from keras.layers.core import Dense, Dropout, Activation, Flatten
from keras.layers.convolutional import Convolution2D, MaxPooling2D
from keras.utils import np_utils
from scipy.special import expit
import numpy as np
np.set_printoptions(suppress=True)
@jackdoerner
jackdoerner / poisson_reconstruct.py
Last active March 5, 2026 04:35
Fast Poisson Reconstruction in Python
"""
poisson_reconstruct.py
Fast Poisson Reconstruction in Python
Copyright (c) 2014 Jack Doerner
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@jakevdp
jakevdp / discrete_cmap.py
Last active June 1, 2025 11:15
Small utility to create a discrete matplotlib colormap
# By Jake VanderPlas
# License: BSD-style
import matplotlib.pyplot as plt
import numpy as np
def discrete_cmap(N, base_cmap=None):
"""Create an N-bin discrete colormap from the specified input map"""
@somada141
somada141 / ipython_notebook_vtk.md
Last active January 31, 2022 20:36
Display VTK renders into IPython Notebook #python #visualization #vtk #ipython #ipythonnotebook

This function takes a renderer and displays the output directly into IPython

def vtk_show(renderer, w=100, h=100):
    """
    Takes vtkRenderer instance and returns an IPython Image with the rendering.
    """
    renderWindow = vtkRenderWindow()
    renderWindow.SetOffScreenRendering(1)
 renderWindow.AddRenderer(renderer)
@UnaNancyOwen
UnaNancyOwen / PCL1.10.0.md
Last active August 27, 2025 05:26
Building PCL with Visual Studio
@mitchwongho
mitchwongho / Docker
Last active August 4, 2025 15:34
Docker 'run' command to start an interactive BaSH session
# Assuming an Ubuntu Docker image
$ docker run -it <image> /bin/bash
@mutterer
mutterer / RoiClassesTest.ijm
Last active April 3, 2019 21:57
A sample image menu macro that allows manually assigning classes to ROIs
var tags = newArray("nucleus-1","nucleus-2","cyto-1", "cyto-2");
var colors = newArray("red", "green", "blue", "magenta");
var commands = newArray("Select by tag...");
var menu = Array.concat(commands, tags);
var pmCmds = newMenu("Popup Menu", menu);
macro "Popup Menu" {
cmd = getArgument();
if (cmd=="Select by tag...") {
Dialog.create("Title");
@rpmuller
rpmuller / svg-display.ipynb
Last active January 23, 2019 05:53
IPython's SVG display functionality, in conjunction with the ease of making SVG strings using ElementTrees, makes it really easy to have a nice drawing canvas inside of IPython.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.