Skip to content

Instantly share code, notes, and snippets.

View phaustin's full-sized avatar

Philip Austin phaustin

  • University of British Columbia
  • Vancouver, BC Canada
View GitHub Profile
@phaustin
phaustin / 00README.rst
Created December 25, 2011 17:35 — forked from GaelVaroquaux/00README.rst
Copy-less bindings of C-generated arrays with Cython

Cython example of exposing C-computed arrays in Python without data copies

The goal of this example is to show how an existing C codebase for numerical computing (here c_code.c) can be wrapped in Cython to be exposed in Python.

The meat of the example is that the data is allocated in C, but exposed in Python without a copy using the PyArray_SimpleNewFromData numpy

@phaustin
phaustin / checkipnb.py
Created June 9, 2012 17:07 — forked from minrk/checkipnb.py
run python notebooks
#!/usr/bin/env python
"""
simple example script for running notebooks and reporting exceptions.
Usage: `checkipnb.py foo.ipynb [bar.ipynb [...]]`
Each cell is submitted to the kernel, and checked for errors.
"""
import os,sys,time
@phaustin
phaustin / ipnbdoctest.py
Created June 9, 2012 17:07 — forked from minrk/ipnbdoctest.py
simple example script for running and testing notebooks.
#!/usr/bin/env python
"""
simple example script for running and testing notebooks.
Usage: `ipnbdoctest.py foo.ipynb [bar.ipynb [...]]`
Each cell is submitted to the kernel, and the outputs are compared with those stored in the notebook.
"""
import os,sys,time
@phaustin
phaustin / 00README.rst
Created February 17, 2013 22:17 — forked from GaelVaroquaux/00README.rst
passing arrays to cython

Cython example of exposing C-computed arrays in Python without data copies

The goal of this example is to show how an existing C codebase for numerical computing (here c_code.c) can be wrapped in Cython to be exposed in Python.

The meat of the example is that the data is allocated in C, but exposed in Python without a copy using the PyArray_SimpleNewFromData numpy

@phaustin
phaustin / matlab_notebook.ipynb
Last active February 20, 2021 08:26 — forked from macd/gist:10562695
Chapter 1 A Brief Tutorial. A direct translation of Chapter 1 of D.J. Higham and N.J. Higham, MATLAB Guide (2005)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import sys
from PyQt4.QtGui import *
from PyQt4.QtCore import *
from PyQt4.QtWebKit import *
from bs4 import BeautifulSoup
qInstallMsgHandler(lambda *args: None)
class Render(QWebPage):
@phaustin
phaustin / crawler.py
Last active November 17, 2016 21:19 — forked from MBAustin/crawler.py
import re, sys, time
from PyQt4.QtGui import *
from PyQt4.QtCore import *
from PyQt4.QtWebKit import *
from bs4 import BeautifulSoup
class Render(QWebPage):
def __init__(self, url):
@phaustin
phaustin / CMakeLists.txt
Last active December 2, 2018 21:18 — forked from YannickJadoul/CMakeLists.txt
Shared data between two pybind11 modules
cmake_minimum_required(VERSION 3.8)
project(example)
add_subdirectory(pybind11)
add_library(shared_counter SharedCounter.cpp)
target_compile_features(shared_counter PUBLIC cxx_std_11)
pybind11_add_module(foo foo.cpp)
target_link_libraries(foo PRIVATE shared_counter)
@phaustin
phaustin / post-commit
Created January 2, 2019 15:54
Pre and post commit hooks to automatically generate production ready css and add it to the current commit. git add doesn't add the files to the current commit so a .commit file is created to keep track and execute an amending commit in a post-commit hook
#!/bin/sh
#
# To enable this hook place this file in .git/hooks and make it executable.
if [ -a .commit ]
then
rm .commit
git commit --amend -C HEAD --no-verify
fi
exit
@phaustin
phaustin / chmxdx_letters.py
Created May 19, 2020 01:58 — forked from decentral1se/chmxdx_letters.py
chmxdx_letters.py
from contextlib import asynccontextmanager
from string import ascii_letters
from typing import Dict
import attr
from trio import (
BrokenResourceError,
ClosedResourceError,
Lock,
MemoryReceiveChannel,