Skip to content

Instantly share code, notes, and snippets.

@mattmcd
mattmcd / test_foo.py
Last active May 5, 2016
Test framework boilerplate in Python
View test_foo.py
# Test framework
from unittest import TestCase
from nose.tools import raises
# Objects under test
from foo import bar
class TestBar(TestCase):
def test_cool_bar_thing1(self):
self.assert(1==1)
@mattmcd
mattmcd / opencv_clj_setup.txt
Created Feb 10, 2016
Instructions for setting up OpenCV development in Clojure on Ubuntu
View opencv_clj_setup.txt
# Instructions for setting up OpenCV development in Clojure on Ubuntu
# Copied from http://docs.opencv.org/2.4/doc/tutorials/introduction/clojure_dev_intro/clojure_dev_intro.html
# Install opencv
sudo apt-get install libopencv-dev
# Get location of latest .jar and .so
dpkg -L libopencv2.4-java | grep jar
dpkg -L libopencv2.4-jni | grep .so
@mattmcd
mattmcd / Makefile
Created Jun 8, 2013
Trying out lambdas and std::function in C++11
View Makefile
all: test_Factory
test_Factory: test_Factory.cpp
$(CXX) -std=c++0x -o test_Factory test_Factory.cpp
@mattmcd
mattmcd / CFunction.g4
Created Apr 21, 2013
ANTLR4 version of Wrapper Generator
View CFunction.g4
grammar CFunction;
function : retType name args ;
args : '(' arg (',' arg)* ')' ;
arg
: 'double' name # SCALAR_ARG
| 'double' '*' name # ARRAY_ARG
@mattmcd
mattmcd / CFunction.g
Created Apr 21, 2013
ANTLR3 version of Wrapper Generator
View CFunction.g
grammar CFunction;
options {
output = AST;
ASTLabelType = CommonTree;
}
tokens {
SCALAR;
ARRAY;
@mattmcd
mattmcd / Hello.g4
Last active Mar 11, 2021
Simple ANTLR4 grammar example
View Hello.g4
// define a grammar called Hello
grammar Hello;
r : 'hello' ID;
ID : [a-z]+ ;
WS : [ \t\r\n]+ -> skip ;
@mattmcd
mattmcd / saddle_install.txt
Created Apr 7, 2013
Shell history from installing Saddle: Scala Data Library http://saddle.github.io/ A couple of extra steps above the standard install were required in order to update my Java install to Java 7.
View saddle_install.txt
# Change location to where External Code is installed
cd ~/Work/ExternCode/
# Install conscript, a tool for installing and updating Scala software
# programs.
curl https://raw.github.com/n8han/conscript/master/setup.sh > conscript_setup.sh
less conscript_setup.sh
chmod 755 conscript_setup.sh
./conscript_setup.sh
@mattmcd
mattmcd / Expr.g4
Created Mar 30, 2013
ANTLR4 simple expression grammar. Note that left recursion is now allowed and operator precedence is just order of definition.
View Expr.g4
grammar Expr;
// Need to call recursive rule expr from non-recursive rule
r : expr+ ;
// ANTLR4 : Left recursion!
// Operator precedence matches order of definition
expr : '-' expr // Unary minus
| expr ('*' | '/' ) expr
| expr ('+' | '-' ) expr
@mattmcd
mattmcd / gist:5277466
Created Mar 30, 2013
Installing ANTLR 4.0 in TerminalIDE on a Nexus 7
View gist:5277466
1. Modify ~/system/bin/dx to increase memory size:
#dx helper script
dalvikvm -Xms256m -Xmx512m -cp $APK com.spartacusrex.spartacuside.external.dx $@
2. Download [Complete ANTLR 4.0 Java binaries jar](http://www.antlr.org/download/antlr-4.0-complete.jar) and copy to ~/bin. Change to this directory.
3. Convert jar to dex so that it can run on Android (takes about 20mins with power connected):
dx --dex --output=antlr-4.0.dex.jar antlr-4.0-complete.jar
@mattmcd
mattmcd / Makefile
Created Mar 30, 2013
Identifying FX Arbitrage as a linear programming problem using COIN-OR Linear Program Solver (CLP).
View Makefile
all: fx_solver
fx_solver: fx_solver.cpp
clang++ -std=c++0x -I/usr/include/coin -o fx_solver fx_solver.cpp -lClp
# Install CLP:
# sudo apt-get install coinor-libclp0 coinor-libclp-doc