When working on a little cocoa app today, I ran in to a somewhat perplexing problem where I could not get currency-formatted values to display in my NSTableView. Using interface builder to add a number formatter to my text field and set the style to currency, I set the text value and… nothing. Turns out that the formatter only wants double values, so use double values
Over the last few months I’ve been testing Red Hat’s new PaaS offering, OpenShift. The testing insofar has gone extremely smooth, but what about preparing for when disaster strikes. The rhc command-line client provides snapshot functionality but unfortunately carries the caveat of needing to shut down and restart the application in the process. For a PHP or Python application this is fine as restarts are lightning fast, but redeploying a JavaEE application is… cough… not so lightning fast.
If you can live with the need to restart, this command will give you a very complete tarball:
rhc app snapshot save -a ApplicationName
The other option is to do it via a cron job that will back up the data into your OpenShift data directory on the server (the data in this directory is not deleted each time the application is redeployed). To do this, you will need to have the cron cartridge installed in your application.
If you don’t already have the cron cartridge installed, you can easily enable it with this command:
rhc app cartridge add -a ApplicationName -c cron-1.4
With cron setup, we can setup jobs to run minutely, hourly, daily, weekly, or monthly by dropping scripts into the appropriate folder in our application’s .openshift/cron directory.
Create a file named backup_postgres.sh in the minutely, hourly, daily, weekly, or monthly folder and paste the following script in. (Also available on GitHub)
With the backup script created simply commit it and push the changes to your application.
git add backup_postgres.sh git commit -m "Added PostgreSQL backup script" git push
Once the changes are pushed you can retrieve your application’s database backups by using rsync
rsync -avz -e ssh email@example.com:app-root/data ./
This, admittedly, isn’t the prettiest solution to the problem but it does its job. I may end up patching the rhc CLI app to do something similar to this and automatically download the results.
I realize I’ve been more vacant than usual these last few months, perhaps its time to get a post down on [roughly] what I’ve been up to. In late February I took on a pretty interesting job for a big name client (details coming soon!). The work has afforded me the ability to become quite intimate with a number of technologies of which I’d only had “user manual” level experience.
There will be more information about what I’m up to in a the next week or two, but its exciting and I’m working with some awesome people.. Stay tuned!
I’ve made some great strides since my last update a day and a half ago. It turns out that having someone around to re-frame your problem can make the solutions to problems more readily apparent. I suspect this is how psychiatrists stay in business, I’m just glad it carries over into the world of mathematics
Rather than going through conforming Delaunay triangulations or by attempting to cut up triangles and create keystones, I’ve gotten another way to do it. Given a center-line, quads can be created by thinking of the left and right sides as ‘tracing’ along the path of the center, but offset by some distance on either side. In the case of turns, subtle and sharp angles can be handled in the same way. By getting the azimuth between the prior point and the next point (we can think of them as i-1 and i+1), a constant distance from i can be maintained by simply getting the positive and negative perpendicular vectors with respect to the azimuth from i-1 to i+1. It turned out to be a pretty good solution as you can see in the video below.
So since my deliciously glitched programmer art meets geodata post yesterday I’ve done a fair bit of work on my Thesis project. After some frustration with Delaunay Triangulations and Conforming Delaunay Triangulations I’ve resigned myself to using GL_LINES as a temporary stopgap measure. I’ve alotted myself a total of 1 week for the integration of any data coming out of OpenStreetMap into the project and I’m less than 48 hours in. Hopefully I get the time to come back to this and do the triangulation properly. Some advice from the make of Mythruna, Paul Speed, on chat tonight looks to be promising and a significantly simpler solution than I had anticipated (aren’t those the best kind?).
I’ve also added the rendering of railroad tracks this and have begun to build a color schema for the display of data. Grey is roads and brown is railway. Public transportation is also linked to blue lines, but New York evidently doesn’t have it annotated as such in the map.
I’m working on the integration of different GIS-related services into a single unified application for my masters thesis and have been picking up where I left off on Betaville and its OSM capabilities. (It loads the data, makes some pretty scruffy looking geometry out of it, and can then render it in real-time as well as export it to COLLADA or OBJ)
Below are a few short videos of me letting off some creative steam while playing with the data.
Triangulation is done courtesy of Java Topology Suite (JTS), which may be the coolest library ever written… with the exception of jME
A few other jMonkeyEngine team members and I were talking about this a week or so back and a few days ago I started thinking again how cool it would be. So here it is, a Berkelium window running within OpenGL via jME3. Mouse coordinates finally line up properly within the texture, which was my personal goal before letting people know too much about it
Performance with one window is quite nice, I can get between 2600 and 3200 frames a second. Regarding the question of video, yes it will indeed play video formats natively supported by Chrome without the aid of Flash. A few YouTube videos here and there do function (I had one on Ubuntu’s website working and then starting having problems), as does a good sample Ogg-Theora video available from Wikimedia
Unfortunately its Windows only right now but I’m working on building Linux and Mac natives of the Berkelium-Java wrapper.
The screen recorder kind of killed performance
If you’re following me on GitHub you might have seen that I’ve been pretty busy over the last few days. After the short discussion on the original iteration of OSMGenerator, I began work on a branch that uses separate tables linked by foreign keys to nodes/ways/relations for the storage of keys. The idea behind this is quicker lookups based on tag searches, which is just about the only way to get data that users will find interesting out of the database. My thanks to Frederik Ramm for bringing up the disparity in schemas between OSMGenerator and osmosis.
If you’ve used Google Maps, OpenStreetMap, or nearly any other online mapping tool, you’ve likely run into the very polished interfaces they present. Double-clicking the map to zoom, dragging the map to get around, its all so smooth!
I decided this morning to have an attempt at building something similar to this in Java, with the ability of being able to plug-in most, if not all, of the GUI toolkits floating around. As of the time of writing I’ve created two implementations, one in Swing and another in FengGUI.
Here is a quick demonstration of how it works using Swing (full source):
JFrame frame = new JFrame("SlippyJ Swing Test"); SwingTileContainer stc = new SwingTileContainer(); frame.setSize(1000, 1000); stc.setSize(1000, 1000); frame.add(stc); frame.setVisible(true); Coordinate center = new Coordinate(41, -74); Palette palette = new Palette(center, 12, stc, new SwingTileFactory(Palette.OSMSlippyServer));
I’ve talked a bit before about setting up a Betaville server, but what about updating one to get all of the latest features and bug fixes?
Well, I’ve written a relatively easy script to help get this accomplished!
#!/bin/sh # script to update a Betaville server installation # by Skye Book <firstname.lastname@example.org> wget http://betaville.net/nightly/BetavilleServer-latest.tgz BetavilleServer_deploy/util/stop_server.sh cp -R BetavilleServer_deploy previous tar -zxvf BetavilleServer-latest.tgz rm BetavilleServer-latest.tgz cp previous/config.xml BetavilleServer_deploy/config.xml cp -R previous/logs BetavilleServer_deploy/logs rm -R previous cd BetavilleServer_deploy nohup ./run.sh &