Skip to content

Instantly share code, notes, and snippets.

@micahjsmith
micahjsmith / TestFirstLetterMethods.java
Last active August 29, 2015 14:13
Test various Java methods for extracting the first letter of a string, see http://stackoverflow.com/q/18201191/2514228
public class TestFirstLetterMethods{
public static final int N_SIM = 1000;
public static void main(String[] args){
long method1 = 0;
long method2 = 0;
long method3 = 0;
for (int i=0; i<N_SIM; i++){
String example = "something";
@micahjsmith
micahjsmith / varargparse.m
Last active April 13, 2016 16:00
Simple approach to parse MATLAB optional arguments provided as param-value pairs.
function [out] = varargparse(args, params, defaults)
%VARARGPARSE Parse varargin given expected parameters and defaults
%
% VARARGPARSE(ARGS, PARAMS, DEFAULTS) parses ARGS given expected parameters
% PARAMS and default values DEFAULTS. Param-value pairs that appear in ARGS
% but not in PARAMS cause errors. PARAMS and DEFAULTS are both cell arrays
% where a parameter in PARAMS has a default value in the same position in
% DEFAULTS.
%
% Due to the way MATLAB resolves variable names, if any of the names in PARAMS
[micahsmith@dhcp-18-111-75-65 ~ ]$ julia -e "Base.runtests()"
From worker 3: * linalg/qr in 66.47 seconds, maxrss 359.77 MB
From worker 3: * linalg/dense in 27.46 seconds, maxrss 390.65 MB
From worker 3: * linalg/matmul in 90.14 seconds, maxrss 479.67 MB
From worker 3: * linalg/schur in 4.09 seconds, maxrss 484.56 MB
From worker 3: * linalg/special in 1.46 seconds, maxrss 486.74 MB
From worker 2: * linalg/triangular in 199.84 seconds, maxrss 706.77 MB
From worker 3: * linalg/eigen in 16.87 seconds, maxrss 500.92 MB
From worker 3: * linalg/svd in 6.72 seconds, maxrss 503.23 MB
From worker 2: * linalg/bunchkaufman in 29.27 seconds, maxrss 740.05 MB
Exception running test linalg/arnoldi :
On worker 3:
LoadError: error compiling naupd: could not load library "libarpack"
dlopen(libarpack.dylib, 1): Library not loaded: /usr/local/opt/libgfortran/lib/libgfortran.3.dylib
Referenced from: /usr/local/opt/arpack-julia/lib/libarpack.dylib
Reason: image not found
in aupd_wrapper at ./linalg/arpack.jl:49
in #_eigs#62 at ./linalg/arnoldi.jl:268
in #_eigs at ./<missing>:0
in #eigs#55 at ./linalg/arnoldi.jl:78
$ julia
_
_ _ _(_)_ | A fresh approach to technical computing
(_) | (_) (_) | Documentation: http://docs.julialang.org
_ _ _| |_ __ _ | Type "?help" for help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 0.5.0 (2016-09-19 18:14 UTC)
_/ |\__'_|_|_|\__'_| |
|__/ | x86_64-apple-darwin15.6.0

Keybase proof

I hereby claim:

  • I am micahjsmith on github.
  • I am micahjsmith (https://keybase.io/micahjsmith) on keybase.
  • I have a public key ASCRLRwIZZ66bvXnoSrxnTAEOmSbg-JC4eSqCHer1vYjQgo

To claim this, I am signing this object:

@micahjsmith
micahjsmith / flac2mp3
Last active August 12, 2017 00:08
Convert FLAC to MP#
#!/usr/bin/env bash
# convert flac to mp3
# source: @Jake Plimack/@boehj https://apple.stackexchange.com/a/293421
# usage:
# find <dir> -name '*flac' -print0 | xargs -0 -P8 -n1 flac2mp3
for f in "$@"; do
[[ "$f" != *.flac ]] && continue
album="$(metaflac --show-tag=album "$f" | sed 's/[^=]*=//')"
@micahjsmith
micahjsmith / flac2mp3
Created June 29, 2019 16:13
convert flac to mp3
#!/usr/bin/env bash
# convert flac to mp3
# source: @Jake Plimack/@boehj https://apple.stackexchange.com/a/293421
# usage:
# find <dir> -name '*flac' -print0 | xargs -0 -P8 -n1 flac2mp3
for f in "$@"; do
[[ "$f" != *.flac ]] && continue
album="$(metaflac --show-tag=album "$f" | sed 's/[^=]*=//')"
@micahjsmith
micahjsmith / README.md
Last active October 16, 2020 15:56
csv2d3m

csv2d3m

Bare bones approach to converting single-table CSV to D3M format.

Install

pip install -r requirements.txt