Skip to content

Instantly share code, notes, and snippets.

View bdezonia's full-sized avatar

Barry DeZonia bdezonia

  • Madison, WI, USA
View GitHub Profile
@bdezonia
bdezonia / gist:6eec9dfa4390562cc7176b4d578b8c7a
Created March 21, 2020 23:33
An idea for generics at the OS level
The last couple of years I have been working on a library for manipulating numeric data in generic ways
(see Zorbage: github.com/bdezonia/zorbage). The key approach is to define generic algorithms that can
work with lots of different data types. This work has been based on ideas I've been thinking about for
years and was improved by reading books by Stepanov ("Elements of Programming" and "From Mathematics to
Generic Programming").
Recently I've been thinking about saving and loading generic data types in a portable fashion. I began
toying with these ideas in a file format specification I have begun (see BSF: github.com/bdezonia/bsf).
It occurs to me that a multidimensional file reader and writer could be something provided at the OS
@bdezonia
bdezonia / gist:658f05e00cee673fd944
Last active August 29, 2015 14:01
A monkey patch that fixes missing_method stack errors in rspec tests
Hopefully this will be of some use to people supporting old rails versions.
I tried porting a rails 2.3 application that had been on ruby 1.8.7 to ruby 1.9.3.
After doing so I could not get my rspec 1.3 tests to run successfully (in my
controllers). I always got stack level too deep errors dealing with a NoMethodError.
I could see that an Array#flatten! call was the culprit.
I understood from this post
(http://yehudakatz.com/2010/01/02/the-craziest-fing-bug-ive-ever-seen/) that somewhere
in the Rails 1.9 development the way method_missing was handled was changed somewhat.
@bdezonia
bdezonia / gist:6455786
Last active December 22, 2015 09:59
An example of roundoff error in linear scaling
public class Calibration {
private static double m = 0.235;
private static double b = 0.33;
private static double calibrated(double rawValue) {
return m * rawValue + b;
}
private static double scale(double raw1, double raw2) {
@bdezonia
bdezonia / gist:5483745
Created April 29, 2013 18:44
Example copying Expressions style
public static void testPointSetsAndFunctions() {
final Img< FloatType > imgA = ArrayImgs.floats( 5000, 5000 );
final Img< FloatType > imgB = ArrayImgs.floats( 5000, 5000 );
final Img< FloatType > imgC = ArrayImgs.floats( 5000, 5000 );
int i = 0;
for ( final FloatType t : imgA )
t.set( i++ );
i = 0;
for ( final FloatType t : imgB )
@bdezonia
bdezonia / RoiExample
Created October 6, 2012 16:31
Toy example for Roi discussions
//import java.lang.reflect.Array;
/*
* Toy example
*
* Want to be able to have
* regions (regions of interest)
* iterable regions
* coordinates of type int[], double[], long[], etc.
* we should be able to treat any iterable region as a region of interest
@bdezonia
bdezonia / ContextPluginExample.java
Created August 30, 2012 19:15
Example code using ContextPlugin code
package imagej.core.plugins.display;
import java.util.List;
import imagej.ImageJ;
import imagej.data.Dataset;
import imagej.data.display.ImageDisplay;
import imagej.display.Display;
import imagej.display.DisplayService;
import imagej.ext.plugin.Menu;