Skip to content

Instantly share code, notes, and snippets.

blink1073 / actions.ts
Last active Aug 26, 2015
Keyboard Manager
View actions.ts
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
* A bunch of predefined `Simple Actions` used by Jupyter.
* `Simple Actions` have the following keys:
* help (optional): a short string the describe the action.
* will be used in various context, like as menu name, tool tips on buttons,
* and short description in help menu.
* help_index (optional): a string used to sort action in help menu.
blink1073 /
Last active Aug 29, 2015
Spyderlib Asynchronous Introspection Mockup
import threading
PLUGINS = ['jedi', 'rope', 'fallback']
def get_introspection(plugin, task):
# TODO: make this a QThread
name, source_code, offset, filename = task
blink1073 / jedi_test_report
Created Jul 6, 2014
Jedi py.test run on Windows 7 against 3264a1815e04fc208fba89440ce0c83995ab0105
View jedi_test_report
============================= test session starts =============================
platform win32 -- Python 2.7.7 -- py-1.4.20 -- pytest-2.5.2
collected 1032 items
jedi/ .
jedi/api/ .
jedi/api/ ..F..
jedi/api/ .
jedi/evaluate/ ..
jedi/evaluate/ ..
blink1073 /
Last active Aug 29, 2015
MetaKernel do_complete
Completions should be case-sensitive
There are three potential objects:
- the token we are in the middle of
- partial version of that token
- the prior token representing a function call
For completions, use the partial object
blink1073 /
Last active Aug 29, 2015
Create LAB LUTs for skimage.color.colorconv based on OpenCV Method
import numpy as np
from scipy.interpolate import interp1d
from skimage import img_as_ubyte
def build_spline(x, y):
"""computes cubic spline coefficients for a function: (xi=i, yi=f[i]), i=0..n
Adapted rom OpenCV project.
blink1073 /
Last active Aug 29, 2015
MetaKernel Magic Spec
  • A line must start with a magic in order to be interpreted as a magic.

  • Magics can be nested within a line

  • Magics can return any object they like (but it should be JSON-dumpable)

  • If no valid magic is found, the block will be considered code and handled by the kernel.

  • Help magic is special:

    • It can be at the end of the line and takes precedence.
    • No code is executed when a help magic is present.
blink1073 / nt_readme.html
Created Nov 1, 2014
Numerical Tours Installation Instructions
View nt_readme.html
<h2 id="installation">Installation</h2>
<p>You need to download <a href="">numerical_tours</a> and install the IPython <a href="">notebook</a> to run the code.</p>
<p>You must also install the <a href="">python-matlab-bridge</a>.</p>
<p>Make sure you can run the command <code>matlab</code> from a command window (or terminal). If not, try the methods below:</p>
<p><strong>Unix-like-systems (including OSX):</strong></p>
<p>Add the following to your <code>~/.profile</code>:</p>
<p><code>export PATH=&quot;$PATH:&lt;PATH_TO_MATLAB&gt;&quot;</code></p>
<p><strong>Windows systems:</strong></p>
<p>From a CMD window:</p>
<p><code>&gt; setx PATH &quot;%PATH%;C:\PATH_TO_MATLAB.EXE&quot;</code></p>
import optparse
import shlex
import ast
def split_args(cmd):
args = shlex.split(cmd)
blink1073 /
Last active Aug 29, 2015
Pymatbridge <-> Oct2Py Integration

Pymatbridge using Matlab


  • Separation of concerns - no pipes!
  • Nice descriptive output from run_code
  • It works with this nested cell array, very impressive:

myCell = {1, 2, 3; 'text', rand(5,10,2), {11; 22; 33}}

blink1073 /
Last active Aug 29, 2015
Windows Pexpect (no PTY)
import subprocess
import os
import re
import threading
import Queue
import sys
import signal
You can’t perform that action at this time.