hasseg.org

Programming

Faux Pas: Static Error Detection for Xcode Projects

Filed under iOS, Mac, Programming

Faux Pas icon I have been working on an app called Faux Pas for a long time now. It's a static error detection tool for Xcode projects: you point this app to your project, and it'll work through it, trying to find common errors or departures from best practices.

It's been in a long private beta, and now it's time to release it to a wider audience. Find more information from the introductory blog post over at the app's website.

The Compiler is Your Friend

Filed under Featured, iOS, Mac, Programming, Talks

Which compiler warnings should I enable for my iOS/Mac app project? How do I enable warnings that Xcode doesn't have a checkbox for? How do I disable warnings (either completely, for specific files, or in specific sections of code?) Where do I go to find out what warnings are available? How do I enable warnings for my own code, but disable them for third-party code that I compile into my bundle? What about warnings that are triggered in third-party headers?

I did a talk on compiler warnings at the HelsinkiOS/CocoaHeads April 2013 meetup that answers all of the above questions. The slides are available at Speaker Deck, and embedded in this post below.

Handling NSStrings Like a Boss

Filed under Featured, iOS, Mac, Programming, Talks

Strings are arguably the most common data structures used by practicing programmers. They're easy to conceptualize as “sequences of characters,” but it's important to note the leakiness of this abstraction, and to know how (and when) to consider the details of how what we think of as “characters” are represented in modern software.

I did a talk on this topic at the HelsinkiOS/CocoaHeads February 2013 meetup — obviously from the point of view of Apple's platform APIs. The slides are available at Speaker Deck, and embedded in this post below.

iOS & OS X Localization Practicum

Filed under Featured, iOS, Mac, Programming, Talks

I did a talk on the localization of iOS and OS X projects at the HelsinkiOS February 2012 meetup. The slides are available at Speaker Deck, and embedded in this post below.

Use Unicode Emoji as Icons in Native iOS Apps

Filed under Featured, iOS, Programming

A while back, I wrote about using unicode emoji characters as icons in web apps. The big caveat with that was that these characters were only available on iOS devices, which made the trick much less useful in a web app, which of course are generally meant to be more or less cross-platform. If you're developing a native iOS app, though, using these standard colorful bitmap emoji characters as icons is a much more realistic proposition, because you can be sure that all the devices your app runs on will have them available. In this post I will show how to easily do this.

jEdit Syntax Highlighting Mode for the Peg/Leg Parser Generator 'Leg' Syntax

Filed under jEdit, Programming

jedit icon I've been working on a fast and embeddable Markdown parser that can be used for syntax highlighting in editors, based on the PEG grammar from John MacFarlane's peg-markdown compiler project. The grammar is written in leg, a syntax for the peg/leg parser generator by Ian Piumarta, and to make my work with this new syntax a bit more pleasant I implemented a jEdit mode for it.

jEdit Macro for Opening the File Browser at Current Buffer's "Project Root" Directory

Filed under jEdit, Programming, Scripts

When I'm working with code in jEdit, my editor of choice, I like to keep the file browser open and docked to the left side of my editor window. When I'm switching between files -- often belonging to different projects -- I find myself reaching for the mouse in order to manually navigate the file browser to the root folder of the project the currently open file belongs to. I started doing this so often that I decided to whip up a small macro to do it for me.

Update (April 4, 2011): Set file browser to directory of current buffer if version control root cannot be found.

Getting Events/Tasks From the OS X Calendar Store in a Custom Format like XML, CSV or LaTeX

Filed under Mac, Programming, Scripts

Over the past couple of years I've gotten a few emails from users of icalBuddy who would like to somehow automate the task of generating CSV, XML/HTML or LaTeX output from the items in their calendar. Unfortunately icalBuddy isn't set up to provide any kind of arbitrary output format (and I didn't want to re-architect it to do that) but a while ago I finally had the time and motivation to figure out a small solution for this: a Python helper class for writing scripts that produce whatever type of output your heart desires.

Use Unicode Emoji as Image-Free Icons in iOS Web Apps

Filed under iOS, Programming, Scripts

In version 2.2 of iOS — Apple's "mobile" operating system used in the iPhone, iPod Touch and iPad — support for Emoji was added. These small 12x12 pixel icons are meant to be used in text messaging in Japan but because they're implemented simply as unicode symbols in the device they can be used as icons when we know they're available.

Getting a List of Installed Fonts with Flash and Javascript

Filed under ActionScript 3, Flex, Miscallaneous, Programming

When implementing the feature in the icalBuddy examples page where the font used for the output examples could be changed interactively I needed to get a list of all the fonts installed on the current user's computer. This blog post from 2006 explains how to do it, but it refers to the deprecated ActionScript 2 API so I had to figure out how to do it with AS3.

Trash files from the OS X command line

Filed under Featured, Mac, Programming

trash picture I spend a lot of time in the Terminal on my computer -- a lot of things are just better done with a command-line interface than in the GUI. When removing files via the command-line people usually just, well, remove them (with the rm command), but this means that they'll be eschewing the Trash, one of the user-friendliest things (even relatively) modern operating systems have had to offer for a long time.

Print AppleScript files with color-coding in the Terminal

Filed under Mac, Programming, Scripts

asprint image Even though I curse and hate its syntax, I have to admit that AppleScript certainly provides one of the nicest things OS X has to offer in comparison to other operating systems: almost-ubiquitous scripting of GUI applications (one could argue that this is not due to the AppleScript language itself, but the Open Scripting Architecture which AppleScript is simply a language for, but that's just semantics). Recently I've had to work with AppleScript files a bit more than usual while implementing Tagger's front app scripts feature, and I noticed that I often wanted to print out the contents of (compiled) AppleScript files in the Terminal. The built-in command osadecompile does just that: it reads in the AppleScript file, decompiles it, formats the code and nicely prints it out. I'm used to seeing my code with syntax highlighting, though, so I decided to write a small program that works similarly to osadecompile but uses ANSI escape sequences to format the output.

Quick Look Plugin/Generator for Image Folders

Filed under Mac, Programming

plugin One of the things that I've always thought Windows XP did better than OS X is how it displays the thumbnails of contained images on the icons of folders that have image files inside them. I always felt this to be quite useful, but couldn't think of any reasonable way to implement it on the Mac before OS X Leopard came along with its Quick Look plug-in architecture.

fcshctl: the Flex Compiler Shell Controller

Filed under ActionScript 3, Flex, jEdit, Programming, Scripts

Introduction

Like I've mentioned before in this blog, I develop Flex applications using the Flex SDK and jEdit instead of Adobe's Flex Builder IDE. This setup has worked very well for me but one annoying issue I've had to deal with because of this is the slow compilation speed: every time I make a small change into one of my projects and recompile it, the mxmlc compiler (that my build scripts are calling) has to load the JVM into memory and recompile my whole project from scratch, which obviously takes a while. Compiling things in Flex Builder is a lot faster, and the reason for that is the Flex Compiler Shell, which it uses for compilation instead of mxmlc.

Update (Version 0.5.1, Mar 17, 09):
  • Display a "compiling..." message before sending fcsh a compilation command in order to let the user know that something is going on and that they should wait instead of just killing the process.
  • If the log file exists when fcshctl runs, check if there are any other fcshctl instances running, and if not, assume that the log file has been orphaned, delete it and continue.
  • Exit with status code 0 ("ok") if fcsh output ends in the "Nothing has changed since the last compile" message.

Saving and Accessing Version/Compilation Information with Flex Applications

Filed under ActionScript 3, Flex, Programming

On several occasions while developing Flash applications I've run into problems with proxy/cache servers. The pattern is usually something like this:

  1. I notice a bug in an application that only occurs when running it on the server
  2. I debug the application, find the bug and issue a fix
  3. I deploy the new version that contains the fix onto the server
  4. I empty the browser cache and run the app on the server again, noticing that the bug seems to persist
  5. I wonder if the version I'm seeing is indeed the version that has the fix, or an older build served to me by some cache server between my workstation and the server
  6. I have to resort to stupid trickery (comparing md5 hashes of .swfs or something) in order to find out

icalBuddy: Getting Events and Tasks from the OS X Calendar Store via the Command Line

Filed under Mac, Programming

icalBuddy example pic I'm a big fan of the "do not repeat yourself" principle, which, especially in the context of software, basically means that you should only have one place to change anything. Any highly volatile data that will be viewed from more than one location (or in more than one way) should only have one location and/or interface for changing it. This way, whenever someone, somewhere, at some point in time happens to make changes to that data, all of the views that display it will reflect that change in true automated synchronization with my cell phone to work.

I used dashboard widgets for a while for getting a quick overview of all of the events I have planned for the day plus any uncompleted tasks I might have, but soon noticed that I don't actually go and see what's up in the dashboard very often, which lead to me forgetting some things even though I had them set up as events or tasks in my calendars. The perfect place for displaying events for the day and any uncompleted tasks for me would thus be the desktop, which, even though it is most of the time obscured by a bunch of windows, I'll occasionally glance at during the day. GeekTool is the solution for displaying any textual output from the shell on an OS X desktop, and I was using that already for some other things, so all that I needed was a CLI application or script that would get the events and tasks from the calendar store and output them in a nice readable way.

Mac OS X Mouse Wheel Support for ActionScript 3 Flash Applications (v.2+)

Filed under ActionScript 3, Flex, Mac, Programming

AS3 Mouse Wheel support picture So I've finally updated the solution I've made earlier for enabling Mac OS X mouse wheel support in Flex applications to a second version. I didn't want to continue adding stuff into the original post, so I decided to write a separate post just for this new version. As you can see from the title, this version should work in any Flash project you're writing in ActionScript 3, as opposed to just in Flex projects. This change was contributed by Pavel Fljot, and all the other stuff I've added since have been added on top of that. Deployment should now be a lot easier and some features that were missing in the first version have also been added.

A "Go to Parent of Current Folder" Toolbar Button for Finder

Filed under Mac, Programming, Scripts

The “go to parent folder” button in the Finder toolbar Although the updated version introduced with Leopard significantly improves upon the one in Tiger, I still think Mac OS's Finder is lacking in several departments. I Don't feel "at home" with separate file managers (Path Finder or ForkLift, for example -- even though I do own a license to the latter, I only use it as an SFTP client,) so I've taken it upon myself to improve the experience of using Finder. The first thing that annoyed me with it was the fact that even though you could use the key combo Command(or Apple key) + Up arrow to go to the parent of the current folder, there was no button in the toolbar for it (which is exactly how I would prefer to invoke this action.) Well, due to the fact that you can drag any application to Finder's toolbar, it's quite easy to add your own buttons there.

Update (feb 13, 08): Updated the app to have a much nicer icon (made by Matti Schneider -- thanks!)

Collapsible Panel Component for Flex

Filed under ActionScript 3, Flex, Programming

Here's an another post in the same vein as my previous one: this time, the component I'm sharing is a Panel subclass that allows for collapsing and expanding its contents. What this means is that the user can click on the header of the Panel to make it toggle between an open or closed state, with a smooth animation.

Vertical TabNavigator Component for Flex

Filed under ActionScript 3, Flex, Programming

I Some time ago ran into a situation with a Flex app I was working on where I needed to use a TabNavigator component, but have its TabBar situated on the left or right side of the ViewStack (instead of on the top, where it is in the default TabNavigator.) I Could not find any workable solutions online (the ones I did find could pretty much be described as ugly hacks,) so I made my own by extending the default TabNavigator. I Submitted this component to the flexlib project, but since it has pretty much been ignored in the discussion group, I thought I'd post it here to make it available to the general public.

Update (same day as orig. post): Added simple demo and example code on how to use the component. Added comment about using embedded fonts.

Growlnotify Leopard Incompatibility Workaround

Filed under Mac, Programming, Scripts

I Have a bunch of custom shell scripts that I use for various things, and most of them use the growlnotify utility that is distributed with Growl to display messages to the user. Unfortunately, as of this writing, growlnotify has some issues with Leopard and thus messages sent through it will be displayed only intermittently (i.e. approx. one third of all messages sent via growlnotify are not shown at all.) I Found, after a bit of googling, that you can make growlnotify send messages to Growl through the network instead of whatever local mechanism it normally uses, and have it work, even with the current (1.1.2) version. Here's the workaround I currently have in place:

ActionScript 3 Support for jEdit's SideKick Plugin Through Exuberant Ctags

Filed under ActionScript 3, Flex, jEdit, Programming

Today VeryVito made a post on his blog that I had been waiting for a while now: he had just written ActionScript 3 support for Exuberant Ctags, which means proper SideKick plugin support for jEdit when editing AS3 with it. He also made nicer icons for use with the CtagsSideKick, so you should definitely check his stuff out if you use (or plan to use) jEdit for editing AS3.

However, after starting to use the SideKick plugin with the modified, AS3-supported version of Ctags while doing my work, I found a few small rough edges in the ActionScript support he had made:

An Application Bundle / Shell Script for Starting and Stopping the Tomcat Server

Filed under Mac, Programming, Scripts

toggleTomcat application bundle icon I've recently had to install tomcat on my localhost to continue developing the Flex application I'm currently doing at work since it connects to web services that are implemented in Java. I wanted an easy way to start and stop the tomcat server, so I made this nice little app for it with the help of a bash shell script and Platypus.

Update (Dec 1, 07): Due to the fact that the icon-assigning script that I've made doesn't support the 512x512 icon resolution introduced in Leopard, I've made a new version of this one, using the "seticon" utility from osxutils. Download: the app / the sources

Flex SDK Language Reference Helper Macro for jEdit

Filed under ActionScript 3, Flex, jEdit, Mac, Programming

VeryVito at turdhead.com has been writing lately about customizing jEdit for writing ActionScript, which is exactly what I've also been doing. A While ago he posted macros for referencing the help files that came with Flash CS3. Well, I don't have Flash CS3, and I use the Flex SDK to do my ActionScripting, so I took the macro he posted and modified it so that it can be used with the Flex language reference.

Update (Oct 5, 07): Now it can search from any number of AsDoc sources
Update (Oct 8, 07): Also finds documentation for methods, changing the command for opening a file in a web browser is easier
Update (Oct 10, 07): now the script searches through files, not buffers, so you needn't have all of your project's files open for it to be able to search through them

jEdit Macros for Running Compilers

Filed under Flex, jEdit, Programming, Scripts

compileMxml shell script displays Growl notifications I've been using jEdit as my ActionScript 3 editor for a while now. I Like the extension and customization possibilities it gives me, and I've used them to create macros for compiling my Flex applications and then bound them to specific keyboard shortcuts to enable quick access to running the compiler.

OS X Mouse Wheel Support for Flex 2 Applications

Filed under ActionScript 3, Flex, Mac, Programming
Note: This version of this solution is deprecated. I've made a separate post about the new version, which you can find here.


In my current job I have been programming user interfaces for applications that display networks of data (as in nodes, links etc.) with the Adobe Flex framework, and the UI paradigm I have been utilizing is a kind of a Zoomable User Interface (ZUI). The idea there is to enable the user to view and manipulate objects on a two-dimensional plane, and navigate around that plane by zooming and panning.

Now, the easiest way (at least for me) to control the zooming is to use the mouse wheel. Mouse wheel support for Flex is implemented by registering an event listener of type MouseEvent.MOUSE_WHEEL with the DisplayObject that would dispatch the event. Sadly, mouse wheel support is not available in the Mac OS X version of Flash Player. This prompted me to create a custom solution, as my main computer is a MacBook and I would like to be able to test the mouse wheel navigation with my development machine.

Update: The javascript now works with more browsers than just Firefox 2 and Safari 2. I Tested it, in addition to those two, with Opera 9, Camino 1.5 and Omniweb 5.5, and it seems to work in all of them now.

Update #2: Changed the javascript code to also work with Safari 3 beta. When using it, small movements with the wheel do not invoke any action, so you'll have to roll it a bit further to make the app respond.

Update #3: Added statement about licensing the code under the MIT License as per request of Philip Flip Kromer

Update #4 (feb 8, 08): If you're looking for AS3 (not Flex) OS X mouse wheel support, check out PixelBreaker.com.

Update #5 (feb 12, 08): Fljot sent me a version of this that works also in non-Flex AS3 projects. He also fixed some issues in the code related to the automatic registration of listening objects. You can find him here.

Categories