Posts

Showing posts from 2014

pip3 fails to compile C module(like Pillow, readline etc) on Yosemite

After upgrading OSX to Yosemite, I found pip3 was not working on homebrewed python3. There seems to be many blogs about this problems but I should do some try-and-errors to fix. Here is what I did in order.  1. install Command Line Tools for 10.10, downloaded from Apple Developer(https://developer.apple.com/downloads/index.action) .  2. reinstall gcc brew reinstall gcc  3. reinstall python3 brew reinstall python3  4. do pip pip3 install pillow I am not sure this is the best way, but it worked for me at least. Hope this helps somebody.

Swift seems nice, but cannot write simple function such as converting array to UnsafePointer

I'm writing an iOS accelerated framework application with Swift and it's frequently necessary to convert Swift array to unsafe pointer. However the conversion function I wrote cannot be compiled. Does anybody know what's wrong with this function? func aryToUnsafePointer<T>(ary:T[]) -> UnsafePointer<T> { return UnsafePointer<T>((&ary as CMutablePointer<T>).value) } The error is 'T[]' is not a subtype of '@lvalue $T1' problem solved thanks to Justin It is not allowed to take "&" of argument directly, so changing function like this will work. func aryToUnsafePointer<T>(ary:T[]) -> UnsafePointer<T> { var a = ary return UnsafePointer<T>((&a as CMutablePointer<T>).value) } Now I understand the reason, but it seems a bit odd to me, though.

Why "CoreDragMessageHandler : Cannot track drag receiver. No pasteboard name."

I am trying to drag&drop file on a PySide application, however, An error "CoreDragMessageHandler : Cannot track drag receiver. No pasteboard name." keeps happening. It turns out, the reason is starting application from tmux. We should avoid starting application from tmux when trying to support a drag&drop.

Roating CGImageRef on iOS.

For reminder to myself, rotate image on center. CGImageRef imageref = [self imageFromSampleBuffer:sampleBuffer]; // or any other CGImageRef source. int w = CGImageGetWidth(imageref); int h = CGImageGetHeight(imageref); CGColorSpaceRef colorSpaceInfo = CGImageGetColorSpace(imageref); CGContextRef bitmap = CGBitmapContextCreate(NULL, w, h, CGImageGetBitsPerComponent(imageref), CGImageGetBytesPerRow(imageref), colorSpaceInfo, CGImageGetBitmapInfo(imageref)); CGContextTranslateCTM(bitmap, w/2, h/2); CGContextRotateCTM(bitmap, M_PI_4); CGContextTranslateCTM(bitmap, -w/2, -h/2; CGContextDrawImage(bitmap, CGRectMake(0, 0, w, h), imageref); CGImageRelease(imageref); imageref = CGBitmapContextCreateImage(bitmap); CGContextRelease(bitmap); return imagereff;