Skip to content

Instantly share code, notes, and snippets.

View samueljohn's full-sized avatar

Samuel John samueljohn

View GitHub Profile
@samueljohn
samueljohn / vtk-qt-demo.py
Created July 11, 2012 12:35 — forked from fmorency/gist:2596951
VTK Qt/PySide Python example
"""
A simple example that uses the QVTKRenderWindowInteractor
class.
"""
try:
from PySide import QtCore, QtGui
except ImportError:
try:
from PyQt4 import QtCore, QtGui
@samueljohn
samueljohn / samuels_python3_setup.md
Last active January 3, 2020 19:29
For my own reference. Brewed Python3, numpy, scipy and the rest goes in a pyvenv.

Samuel's Python3 setup for Mac:

This document describes in which way, what packages, and from where are installed on my Macs to get a decent Python 3.x, scipy/numpy & Co setup.

Note, I switched to Python's 3.x pyvenv from virtualenv in order to handle my pip-installable packages. Also thanks to Anaconda, the whole setup is so simple now that I use this document just to remember which additional packages I like.


@samueljohn
samueljohn / README.md
Last active March 4, 2017 21:41
Hacking a FIFOPlayer into Pyo. Yay. Pumping numpy arrays to the soundcard (or do some post-processing or mixing first)! Pyo is a fantastic sound processing library. To test this, copy these files into a freshly checked out pyo repository into pyo/externals. Then build pyo from source. In the long(er) run, I'd love to provide this to upstream. Cr…

We (Samuel John and Thomas Hermann) added a FIFOPlayer to Pyo, allowing you to directly (and almost copy-free) play numpy Arrays. See help(pyo.FIFOPlayer)! Output should be scaled [-1.0,1.0] (roughly).

See fifo_demo.py how to use a thread to generate audio and fill the queue.

@samueljohn
samueljohn / print_tree.py
Created April 29, 2014 17:55
Print a nice text tree of nested python objects.
def print_tree(tree, prefix=[], last_prefix="", print_item=str):
"""
Return a string where each line represents one item of tree.
prefix and last_prefix are used internally.
print_item:
The function applied to items in the tree.
Default `str`.
@samueljohn
samueljohn / config
Last active December 21, 2015 11:08
This is how I use two remotes "origin" and "samuel" and have the master branch use origin so `brew update` works as usual. When I want to contribute, I use: `git checkout -b my_new_feature` and then `git push --set-upstream samuel my_new_feature` to push it to my own fork ("samuel") of homebrew.
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
autocrlf = false
[color]
branch = auto
status = auto
@samueljohn
samueljohn / gist:5280700
Last active December 15, 2015 15:19
Moving homebrew formulae from one repo (mxcl/master) into another one... Based on @jacknagel's instructions.
diskutil erasevolume HFS+ "ramdisk" `hdiutil attach -nomount ram://1048576`
cd $(brew --repository)
git checkout -b moveit
git filter-branch --prune-empty --index-filter 'git ls-files --full-name --cached | grep -F --invert-match --file=/tmp/list --color=never | xargs git rm --quiet --cached --ignore−unmatch' --subdirectory-filter 'Library/Formula' -d /Volumes/ramdisk -f moveit
cd the-target-repro
@samueljohn
samueljohn / initial-setup.sh
Created March 24, 2015 10:47
Uberspace initial setup (zsh)
cd
git clone https://github.com/samueljohn/__settings__.git
rm ~/.zshrc
rm ~/.bashrc
cd ~/__settings__
source setup_symlinks.sh
chsh -s /package/host/localhost/zsh/bin/zsh
# Logout and login again. Done.
#!/usr/bin/env python
#-*- coding:utf-8 -*-
import BaseHTTPServer
import sys
import time
import urlparse
import json