Skip to content

Instantly share code, notes, and snippets.

View btel's full-sized avatar
💡
open to freelance opportunities

Bartosz Telenczuk btel

💡
open to freelance opportunities
View GitHub Profile
@btel
btel / mpl_prof.py
Created January 28, 2012 00:06
matplotlib profiling
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.collections import LineCollection
def line_collection(t, spikes):
ax = plt.subplot(111)
ts, ns = spikes.shape
segs = np.zeros((ns, ts, 2), np.float32)
segs[:, :, 1] = spikes.T
@btel
btel / test_canvas.html
Created February 1, 2012 13:29
Benchmark graphical libraries in Python
<html>
<head>
<script type="text/javascript">
function run() {
setInterval( drawShape, 500 );
}
function drawShape(){
// get the canvas element using the DOM
var canvas = document.getElementById('mycanvas');
@btel
btel / gist:3856053
Created October 9, 2012 01:34
"Four" lines
#get cluster labels
labels = clusters.labels
# get spike times
sp_times = events.sp_times['data']
# get spikes of class 1
sp_times_cl1 = sp_times[labels==1]
# get peak-to-peak amplitude
n_channels = 2
@btel
btel / gist:4249939
Created December 10, 2012 10:56
PCA
def PCA(data,ncomps=2):
"""Perfrom a principle component analysis.
Parameters
----------
data : array
(n_vars, n_obs) array where `n_vars` is the number of
variables (vector dimensions) and `n_obs` the number of
observations
@btel
btel / colormap_scatter.py
Created January 28, 2013 16:55
use custom colormaps with scatter and colorbra
#!/usr/bin/env python
#coding=utf-8
from matplotlib import cm
from matplotlib import colors
import numpy as np
import matplotlib.pyplot as plt
cm = colors.LinearSegmentedColormap.from_list(
{
"metadata": {
"name": "io_perf_test"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@btel
btel / add_gh_button.user.js
Last active October 8, 2017 00:01
Open IPython notebook from Github in NBViewer
// ==UserScript==
// @name NBViewer GitHub Button
// @description Open IPython notebook from Github in NBViewer
// @version 0.12
// @namespace http://telenczuk.pl
// @grant none
// @include http*://github.com/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js
// ==/UserScript==
@btel
btel / gist:6053648
Created July 22, 2013 12:58 — forked from anonymous/gist:5059144
edit viewBox in svg_utils
import matplotlib as pyplot
from lxml import etree
#do some plotting
plt.savefig(fig_file)
width, height = '3.8in', '2.8in'
with file(fig_file, 'r') as fid:
tree = etree.parse(fid)
@btel
btel / svg_modify_line_width.ipynb
Created July 22, 2013 14:05
modify SVG line width in python using lxml inline CSS style
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.