Skip to content

Instantly share code, notes, and snippets.

@mattmcd
mattmcd / printargs.cpp
Created March 23, 2013 14:17
C++11 program to print input arguments on separate lines.
#include <iostream>
#include <vector>
#include <string>
int main(int argc, char* argv[])
{
std::vector<std::string> args(argc);
args.assign( argv, argv+argc);
for( const auto arg : args ) std::cout << arg << std::endl;
@mattmcd
mattmcd / printargs.scala
Last active December 15, 2015 07:59
Scala program to print input arguments on separate lines.
for( arg <- args ) println( arg )
@mattmcd
mattmcd / const_forms.cpp
Created March 25, 2013 20:04
Examples of the different uses of const in C++
#include <iostream>
#include <vector>
#include <string>
#include <memory>
typedef std::vector<std::string> str_vec;
void print(str_vec const list)
{
for ( auto el : list ) std::cout << el << std::endl;
@mattmcd
mattmcd / HelloEigen.cpp
Last active December 15, 2015 12:39
Installing and testing Eigen3 linear algebra C++ library.
#include <iostream>
#include <Eigen/Dense>
using Eigen::MatrixXd; // m by n double matrix
int main()
{
// Example from Eigen3 doc
MatrixXd m(2,2);
// Comma initialization, row major order
@mattmcd
mattmcd / Makefile
Created March 30, 2013 11:55
Identifying FX Arbitrage as a linear programming problem using COIN-OR Linear Program Solver (CLP).
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
@mattmcd
mattmcd / gist:5277466
Created March 30, 2013 17:03
Installing ANTLR 4.0 in TerminalIDE on a Nexus 7
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 / saddle_install.txt
Created April 7, 2013 11:23
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.
# 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 / CFunction.g
Created April 21, 2013 12:25
ANTLR3 version of Wrapper Generator
grammar CFunction;
options {
output = AST;
ASTLabelType = CommonTree;
}
tokens {
SCALAR;
ARRAY;
@mattmcd
mattmcd / Makefile
Created June 8, 2013 10:32
Trying out lambdas and std::function in C++11
all: test_Factory
test_Factory: test_Factory.cpp
$(CXX) -std=c++0x -o test_Factory test_Factory.cpp
@mattmcd
mattmcd / opencv_clj_setup.txt
Created February 10, 2016 06:57
Instructions for setting up OpenCV development in Clojure on Ubuntu
# 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