Twig Technology

[...] incredibly interested in all the things you could do with twigs.

Bittorrent Sync on Android

| Comments

In my previous blog post, I raved about how much I love Bittorrent Sync (BTSync). And while it is true that for most of my use-cases, it is superior to Dropbox, there are a few things Dropbox does that BTSync doesn’t do out of the box. Two of these use-cases are related to mobile devices: I want to share folders with my phone, and synchronize photos taken with the phone to my PC.

BTSync, Dropbox Alternative

| Comments

Dropbox is a revolutionary product. It has made it simple for anyone to share files between computers, access those files from a phone, automatically load photos from my phone onto my computer, and make it easy to share files publicly. Who needs USB sticks anymore?

Why would I even want to quit Dropbox?

Type-safe Struct Wrappers in C

| Comments

Lately, I find myself writing more and more code that uses void* pointers as handles to implementation-specific data. This can get confusing when there is more than one type of handle. Imagine we have these two types:

1
2
typedef void *HBITMAP;
typedef void *HWINDOW;

It is then possible to assign a value of type HBITMAP to a variable of type HWINDOW, with no complaints from the compiler.

Invalid Byte Sequence in UTF-8

| Comments

I finally made the switch to octopress this week, and when I was importing some old blog posts, I got this gem of an error message:

YAML Exception reading 2012-05-28-prefix-search.markdown: invalid byte
sequence in UTF-8

Stencyl at Hack the Future 6

| Comments

Last Sunday saw another installment of our popular children hackathon at the Tech Museum in San Jose. We get a room full of middleschool students, pair them with hacker mentors, and let them play with all kinds of technology – programming, electronics, robots, that sort of fun stuff.

I had decided that I wanted to show them how to make flash games in <a Stencyl. It turned out to be a super popular station, I feel like I gave a lot of kids the gift of game-making to take home, and feedback was positive. Stencyl got mentioned as a highlight in quite a lot of our feedback forms.

Prefix Search, Part 2: Crit-bit Trees

| Comments

The problem with the prefix search problem I described in my previous post is that there is most likely no good data structure in your language to do this with. There certainly isn’t one in C. But the good news is that we get to build our own! How often do we still get to write data structures from scratch in this day and age? And when is it ever a good idea?

Prefix Search, Part 1: A Challenge!

| Comments

Algorithms and data structures are fun. The other week, I had the chance to implement something I needed for a project: Given a large set of strings, find all the ones that begin with a given prefix. For example, say you have a phone book, and you want to find all the people whose name starts with Joe. Or a large list of IP addresses, and you want to find all the ones that start with 192.168.

Android NDK Shared Libraries

| Comments

This morning, I got stumped by the Java/NDK integration. I was trying to add another shared library (Lua) to a project, and kept getting these dynamic linker error messages:

I/ActivityManager( 1386): Start proc org.libsdl.app for activity org.libsdl.app/.SDLActivity: pid=25826 uid=10087 gids={1015}
W/dalvikvm(25826): Exception Ljava/lang/UnsatisfiedLinkError; thrown during Lorg/libsdl/app/SDLActivity;.&lt;clinit&gt;
W/dalvikvm(25826): Class init failed in newInstance call (Lorg/libsdl/app/SDLActivity;)
W/dalvikvm(25826): threadid=1: thread exiting with uncaught exception (group=0x40020ac0)
E/AndroidRuntime(25826): FATAL EXCEPTION: main
E/AndroidRuntime(25826): java.lang.ExceptionInInitializerError
E/AndroidRuntime(25826):        at java.lang.Class.newInstanceImpl(Native Method)
E/AndroidRuntime(25826):        at java.lang.Class.newInstance(Class.java:1429)
E/AndroidRuntime(25826):        at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
E/AndroidRuntime(25826):        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
E/AndroidRuntime(25826):        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
E/AndroidRuntime(25826):        at android.app.ActivityThread.access$2300(ActivityThread.java:125)
E/AndroidRuntime(25826):        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
E/AndroidRuntime(25826):        at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(25826):        at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime(25826):        at android.app.ActivityThread.main(ActivityThread.java:4627)
E/AndroidRuntime(25826):        at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(25826):        at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime(25826):        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
E/AndroidRuntime(25826):        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
E/AndroidRuntime(25826):        at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(25826): Caused by: java.lang.UnsatisfiedLinkError: Library main not found
E/AndroidRuntime(25826):        at java.lang.Runtime.loadLibrary(Runtime.java:461)
E/AndroidRuntime(25826):        at java.lang.System.loadLibrary(System.java:557)
E/AndroidRuntime(25826):        at org.libsdl.app.SDLActivity.&lt;clinit&gt;(SDLActivity.java:53)
E/AndroidRuntime(25826):        ... 15 more
W/ActivityManager( 1386):   Force finishing activity org.libsdl.app/.SDLActivity

What it was was that my Activity (which is a small java stub) needed to call System.loadLibrary(“Lua”); to load that new library. How is that related to the error message? I have no idea.

Sigh. Sometimes missing a single line will cost you half a day.