Archive for the ‘Uncategorized’ Category.
April 6, 2014, 12:00 pm
A view weeks ago I fell over and basically scratched my head. However health care in Japan being how it is (of varying quality, but nothing if not high-tech) I could get an MRI done for about $70. I jumped at the chance, because I’ve always wanted to see inside my own head.
Anyway, for your viewing pleasure here are my MRI images, the raw DICOM data is also available as a tarball incase anyone playing with these systems is looking for a test dataset.



September 10, 2013, 9:46 am
Remove consecutive lines where the 2nd item is the same:
awk '{if($2 != v) print $0; v=$2}'
August 31, 2013, 10:58 am
Very simple zlib example. The neat thing is that zlib is transparent to uncompressed files, so you can just replace all your file seeking with zlib code and it’ll work with compressed and uncompressed code. It’s worth noting that gzseek does not support SEEK_END, which can cause issues.
#include <zlib.h>
#include <stdio.h>
int main() {
gzFile file = gzopen("test.gz", "rb");
if(file == NULL) {
fprintf(stderr, "gzopen error\n");
}
char buffer[1000];
int uncomprLen = gzread(file, buffer, 1000);
buffer[uncomprLen]=0;
printf("data: %s\n",buffer);
int pos = gzseek(file, 5, SEEK_SET);
uncomprLen = gzread(file, buffer, 5);
buffer[6]=0;
printf("data: %s\n",buffer);
gzclose(file);
}
March 6, 2013, 7:10 pm
Some basic iOS copy/paste sample code:
#import "UIPasteboard.h"
void iphone_copy(char *text) {
UIPasteboard *pb = [UIPasteboard generalPasteboard];
NSString *nstext = [NSString stringWithCString:text encoding:NSUTF8StringEncoding];
[pb setValue:nstext forPasteboardType:@"public.plain-text"];
}
const char *iphone_paste() {
UIPasteboard *pb = [UIPasteboard generalPasteboard];
NSString *nstext = [pb valueForPasteboardType:@"public.utf8-plain-text"];
return [nstext cStringUsingEncoding:NSUTF8StringEncoding];
}