Skip to content

Instantly share code, notes, and snippets.

View sburns's full-sized avatar

Scott Burns sburns

View GitHub Profile
@sburns
sburns / view_test.py
Created May 17, 2011 15:15
PySurfer/Mayavi viewing strangeness
from surfer import Brain
brain = Brain('fsaverage', 'lh', 'inflated')
#normal lateral view
brain.show_view('l')
#normal dorsal view
brain.show_view('d')
@sburns
sburns / want_to_be_in_numpy.m
Created June 22, 2011 16:09
matlab to numpy question
# given a vector
a = [ 16738, 24500, 45000, 67000];
#how can I do this in numpy efficiently?
b = []
for ia = a
b = [b ia-60:ia+300];
end
@sburns
sburns / hack.py
Created September 20, 2012 16:11
v1 at converting eprime .txt to pandas.DataFrame
import pandas as pd
F = '/fs0/New_Server/RC_LMS/In_Behavioral/028_207757/PassagesV2_ListA-7757-1.txt'
def parse(f):
data = {}
text = open(f).read().decode('utf-16').replace('\r\n', '\r').splitlines()
start_ind = (i for i, _ in enumerate(text) if _ == '\t\t*** LogFrame Start ***')
end_ind = (i for i, _ in enumerate(text) if _ == '\t\t*** LogFrame End ***')
@sburns
sburns / clock.py
Created September 26, 2012 13:42
APScheduler demo
from apscheduler.scheduler import Scheduler
from my_module import do_work_often, do_some_more_work
sched = Scheduler()
@sched.interval_schedule(hours=1)
def first_job():
do_work_often()
@sburns
sburns / eprimetxt_to_df.ipynb
Created November 13, 2012 23:02
A process for converting eprime txt files to pandas.DataFrames
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sburns
sburns / api_design.md
Created February 13, 2013 15:39
Proper way to expose exceptions from external libraries

The Issue

One of my packages (redcap) is a service-specific wrapper around the venerable requests. requests exposes the HTTPError exception that is raised e.g. when r.raise_for_status() is called on a 400 response.

Since users of my package might want to catch HTTPErrors, what is the best way to design my API?

Choice 1

@sburns
sburns / notebook.ipynb
Created March 13, 2013 15:57
A python notebook backing up a post written for [PyNash](http://pynash.org).
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sburns
sburns / cci.ipynb
Created March 19, 2013 17:24
CCI API See cci.ipynb
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.
@sburns
sburns / pycap_df_long.ipynb
Created April 16, 2013 19:06
pycap and hierarchical df from longitudinal project
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.