Categories

Category: Tech

Computers, Software, Programming, anything Electronic

A* in Clojure: Part Two - January 24, 2010 by pardsbane

Today, I decided to flush out and clean up my A* implementation in Clojure. I cleaned up the namespaces, removed some cruft, got the Java integration working (which required by-passing RT.loadResourceScript() since it seems to be broken), and moving my graph structure definition out of code and into a separate XML file (which is read and parsed directly in Clojure).

I’m still not sold on functional programming, these minor changes took me more hours than I care to admit and gave me a crazy headache, but that could just be because I’m unfamiliar with the language.

I also uploaded the code to GitHub, because I figured where’s the fun in learning a new algorithm in a new language without tossing in the risk of losing all your code to an silly mistake with an unfamiliar version control system?

Luckily no data was lost, and if you have any interest in Clojure, Clojure-Java integration, or A-Star search, check it out here:

http://github.com/jbcpollak/AStar-Clojure

My next steps are going to be more rigorous unit testing and perhaps some benchmarking. I’d like to see how this implementation does against a large graph.

Solved: Mac OS X Locks-Up When Waking from Screensaver - January 16, 2010 by pardsbane

The Problem

Frequently, say, one out of 10 times, when I try and log back into my Mac from the screensaver, or when I wake it from sleeping, I will get a spinning beachball and be unable to type my password. Other times I will be able to log in, but I am prompted to enter my password multiple times for various applications, and invariably one of them (usually gconsync) will get stuck after I enter my password with a spinning beach ball. I can still use most applications, but application that needs keychain authorization locks up.

I happen to be using a very handy tool called SSHKeychain, which turned out to be the culprit.

If you are using SSHKeychain, this post will walk you through fixing the unstable-wake-from-screensaver, and also solves the problem of having to type your keychain password 3-5 times when I returned to my computer.

read this entry »
Strange Errors Compiling The Android Platform on Mac OS X 10.6? (Snow Leopard) - December 13, 2009 by pardsbane

If you are having trouble compiling Android on Snow Leopard, first make sure you’ve installed the Leopard 10.5 Java 1.5 SDK, according to these instructions.

Second, make sure you have the latest XCode installed, and make sure you have installed the optional 10.4 SDK. In my case, it appeared that the 10.4 sdk was installed, but it was either corrupt or out of date, resulting in many strange errors like the following:

Issue 993

(out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/javalib.jar)
Docs droiddoc: out/target/common/docs/framework
Could not load 'clearsilver-jni'
java.library.path = out/host/darwin-x86/lib
make: *** [out/target/common/docs/framework-timestamp] Error 45

Issue 5000
host C: emulator <= external/qemu/distrib/zlib-1.2.3/adler32.c
host C: emulator <= external/qemu/distrib/zlib-1.2.3/compress.c
host C: emulator <= external/qemu/distrib/zlib-1.2.3/crc32.c
host C: emulator <= external/qemu/distrib/zlib-1.2.3/deflate.c
host C: emulator <= external/qemu/distrib/zlib-1.2.3/gzio.c
In file included from external/qemu/distrib/zlib-1.2.3/gzio.c:601:
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/stdarg.h:4:25: error: stdarg.h:
No such file or directory
external/qemu/distrib/zlib-1.2.3/gzio.c: In function ‘gzprintf’:
external/qemu/distrib/zlib-1.2.3/gzio.c:610: warning: implicit declaration
of function ‘va_start’
external/qemu/distrib/zlib-1.2.3/gzio.c:628: warning: implicit declaration
of function ‘va_end’

So if these issues strike you, follow the directions to switch to Java 1.5, and reinstall XCode, then run:
make clean && make

In the android platform’s main directory.

Unfortunately, I’m still stuck with this build error I haven’t gotten past yet:

host Prebuilt: libSDL (out/host/darwin-x86/obj/STATIC_LIBRARIES/libSDL_intermediates/libSDL.a)
ranlib: file: out/host/darwin-x86/obj/STATIC_LIBRARIES/libSDL_intermediates/libSDL.a(SDL_getenv.o) has no symbols
ranlib: file: out/host/darwin-x86/obj/STATIC_LIBRARIES/libSDL_intermediates/libSDL.a(SDL_malloc.o) has no symbols
ranlib: file: out/host/darwin-x86/obj/STATIC_LIBRARIES/libSDL_intermediates/libSDL.a(SDL_qsort.o) has no symbols
ranlib: file: out/host/darwin-x86/obj/STATIC_LIBRARIES/libSDL_intermediates/libSDL.a(SDL_stdlib.o) has no symbols
ranlib: file: out/host/darwin-x86/obj/STATIC_LIBRARIES/libSDL_intermediates/libSDL.a(SDL_audiodev.o) has no symbols
ranlib: file: out/host/darwin-x86/obj/STATIC_LIBRARIES/libSDL_intermediates/libSDL.a(SDL_mixer_MMX.o) has no symbols
ranlib: file: out/host/darwin-x86/obj/STATIC_LIBRARIES/libSDL_intermediates/libSDL.a(SDL_yuv_mmx.o) has no symbols
ranlib: file: out/host/darwin-x86/obj/STATIC_LIBRARIES/libSDL_intermediates/libSDL.a(SDL_nullmouse.o) has no symbols
host Prebuilt: libSDLmain (out/host/darwin-x86/obj/STATIC_LIBRARIES/libSDLmain_intermediates/libSDLmain.a)
host Executable: emulator (out/host/darwin-x86/obj/EXECUTABLES/emulator_intermediates/emulator)
Undefined symbols:
  "_xml_builtin", referenced from:
      _xml_builtin$non_lazy_ptr in gdbstub.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [out/host/darwin-x86/obj/EXECUTABLES/emulator_intermediates/emulator] Error 1

So if anyone has any tips on that, I’d appreciate it!

A-Star Search in Clojure - October 16, 2009 by pardsbane

I wanted to refresh my knowledge of functional programming, A-Star search, and I figured learning Clojure at the same time couldn’t hurt. I figured I’d do all three at once, and throw in a health dose of Maven and Java at the same time.

This project was intended to:

  1. Refresh myself on how to do functional programming
  2. Refresh my knowledge of A* search
  3. Help me learn Clojure
  4. Demonstrate Java interoperating with Clojure
  5. Demonstrate Maven as a viable build system for Clojure


Download The Demo Here

Once downloaded, unzip the zip file and open a terminal.

You now have three options:

Review the Source Code

The meat of the code is all in Clojure, here:

src/main/resources/com/example/clap/astar.clj

There is a bit of boot-strap Java code in the following file, but I can’t say its all that interesting:

src/main/java/com/example/clap/App.java

Running from Source

If you are on a Mac, or you already have Maven and Java installed, just run the following:

cd astar && mvn test

Maven will download all the needed packages and then compiled and execute the demo.

Running from Binary

If you are on Linux, or have cygwin installed on Windows, you can run the following:

cd astar/bin/ && ./run-astar

Missing IMAP email on Snow Leopard - October 2, 2009 by pardsbane

If you are finding mail sometimes not appearing in your Mail inbox after upgrading to Snow Leopard, but then it appears again once you restart Mail, try shutting off the ‘Use IDLE command’ option in account settings. (Its at the bottom of the advanced tab).

After upgrading to Snow Leopard on my Mac, I noticed this was happening with email in my Dreamhost IMAP account.

I’ve been running with the ‘IDLE’ option turned off for a day, and it seems to be working correctly again.

Using JOGL as a Dependency in Maven - September 8, 2009 by pardsbane

At work, we need to start using JOGL as a dependency of our project, which we build with Maven. JOGL, the Java OpenGL interface, uses platform specific binaries, which introduces some complexity to the build process.

After a brief websearch, I found the appropriately titled using-jogl-as-dependency-in-maven, unfortunately, it appears to be a private blog, so I can’t see if the information is useful or not.

I did find on mvnbrowser.com that jogl-1.1.1-rc6 (as of this writing) is on the dev.java.net Maven2 repository, but I couldn’t find a usage guide.

Oh well, I’ll keep looking. For now its not a hugely pressing issue, so the one developer who is using has just hacked his Eclipse setup.

« old entrys
Post Archive