2012-10-31

iOS, Android, and some other operating systems allow an app to volunteer to handle certain kinds of hyperlinks. Besides the usual http:// and mailto:// and ftp:// sorts of links, you can create your own links. I could, for example, create my own basil:// link. Indeed, this is the main avenue Apple provides for applications to talk to each other in iOS.

2012-09-28

I am surprised to find that even by 2012 Apple has yet to include an object type for UUID. Nor do they provide an easy way to generate a UUID. Java does both.

The blog post Creating a GUID or UUID in Objective-C by Don McCaughey provides source code for a nice method to wrap Apple's clumsy UUID feature in Core Foundation. Unfortunately his 2010 code is not working for me Xcode 4.4.1, apparently because of ARC.

Two fix-its offered. I chose this one:Use CFBridgingRelease call to transfer ownership of a +1 'CFStringRef' (aka 'const struct _CFString *' into ARC

And I deleted his call to autorelease.

Here is my revision to Mr. McCaughey’s code. My revision seems to be working. But is memory managed correctly? I am still too new to Objective-C and C to grasp the nuance of bridging OOP and POC (Plain Old C). Please post corrections or criticism.

//================= // Return a new UUID string. Built for ARC in iOS 4 and later.- (NSString *)generateUuidString{// create a new UUID which you own CFUUIDRef uuid = CFUUIDCreate(kCFAllocatorDefault);// create a new CFStringRef. NSString *uuidString = (NSString *)CFBridgingRelease(CFUUIDCreateString(kCFAllocatorDefault, uuid));// release the UUID CFRelease(uuid); return uuidString;}//=================
StackOverflow.com has a thread on this topic.

2012-08-09

When authenticating users, you should never store their password value directly. The proper way is to salt and hash before storing.

Most hashing algorithms are designed to take a large amount of data such as documents and quickly return a hash. For storing passwords, you want the opposite: small data, and slow (strong) hashing.

Recognizing this different need, BCrypt takes a different approach. BCrypt uses the very strong but slow Blowfish cipher to do the hashing. BCrypt generates a random salt value to be added to the password, changing on each usage. Furthermore, and most importantly, BCrypt is adaptive. That is, as computing technology speed increases, you can increase the the strength of BCrypt by passing an increasing number. Though oversimplifying, you can think of the number as indicating the number of iterations of hashing and re-hashing. As computers get faster in the future, you can increase the strength of your hashing by passing a higher numbers.

Postgres 9 has a crypto module that includes a "crypt" command that seems to implement BCrypt. Here's a example of calling that command, where 'bf' means Blowfish: SELECT crypt('YourPasswordGoesHere', gen_salt('bf', 10));

Increasing that number slightly dramatically increases the burden on a comupter. Here's some results of calling that in Postgres 9.0.4 on Mac OS X 10.6.7 on a MacBook with a 2.4 GHz Core 2 Duo.

6 ≈ 40 milliseconds

8 ≈ 130 ms

10 ≈ 500 ms

12 ≈ 1,600 ms

14 ≈ 7,000 ms

16 ≈ 28,000 ms (half a minute)

21 ≈ 1 million ms (17 minutes)

During this time, the calculation took about 80-100% utilization of a CPU core.

BCrypt has been implemented in many languages, including C, Java, Python, Ruby, and more.

An implementation is bundled with Postgres, at least when using the installer for Mac OS X provided by EnterpriseDB. At least it seems to me that you are getting BCrypt if you specify the 'bf' argument, but the docs are not explicit -- Please correct me if I'm wrong.

To use this in Postgres, you must enable the "pgcrypto" functions, by copying and executing the SQL found in the "pgcrypto.sql" file found someplace such as this: /Library/PostgreSQL/9.0/share/postgresql/contrib/pgcrypto.sql
Open that file, copy and paste to an interactive SQL window in the pgAdmin app. Actually, you only need the first third of that file's SQL, down to but not including the "pgp_" functions.

2012-06-05

I took a look at these screen shots of pre-release Mountain Lion Server, now 3 months old.

Here are some differences I noticed in the GUI widgets. No big drastic changes, but interesting to those of us building data-entry/database oriented software. Perhaps some of these are in Lion, but not that I’ve noticed.

On the read-only panels (without data-entry) they have:

Greyed-out field labels

No colons on the labels (Apple has never been consistent on label colons)

Grey trim around the data-entry panel, making it look like an index card floating above a surface

Extra large & bolded fonts for grouping label

Centered tabs

"Edit…” buttons, presumably to present further data-entry dialogs or assistance

Slightly different presentation of +/-/✎ buttons

“Cancel” & “Done” buttons

Not “OK”

Set inside a grey panel

White background in main data-entry area, but grey background in header and footer areas.

Yet sheets are the opposite, white b/g for title but grey for data-entry.

The grey footer seems inconsistently used.

Or perhaps the grey footer is present only for panels that have undoable actions and after the user does some data-entry then the Cancel/Done buttons appear in that grey footer.

2012-06-04

I often work at any place that strikes my fancy. Sometimes at home, sometimes at the home of a colleague or a friend, and occasionally for an hour or two at a coffeehouse. After some trial and error, here's a list of the gear I've found useful for nomadic work.

Monitor – Viewsonic VX2450wm-LED

LED-backlit is a must. Smooth coverage across the screen and bright. One inch thin. Should last for decades or longer. Lightweight and easy to carry. And LED requires very little electricity, which is important to avoid overloading household wiring.

This Viewsonic model is the best monitor I've found not only because of high-quality and low-price ($200), but because of this surprising consideration: portability and easy to stow. For the nomadic use, the monitor should be easy to put out of the way and easy to move from place to place. This ViewSonic has a removable base that simply unscrews from underneath. Even better, the screw is designed to stay attached and not fall out, so you don't lose it. Secondly, this monitor has the right kind of box. The box is compact, with a sturdy lid and built-in handle, and robust tab slots for locking shut. Inside are pieces of styrofoam that slide easily onto the left and right sides of the monitor. The styrofoam is the compacted solid type, rather than the open-cell kind that rapidly falls apart into disintegration.

By comparison, Dell uses an all-cardboard box which, while green, does not make for easy or durable re-use.

The ViewSonic also tilts, which seems like no big deal until you use a monitor that doesn't.

The ViewSonic has such a low price that I've bought more than one, stashing them at homes where I tend to visit.

Viewsonic sells a 22-23" model alongside this 24" model. There is not much difference in price any longer, so I recommend the larger pixels for aging eyes like mine. The other model has a noticeably more compact and lighter box, so you may consider that one as well.

I strongly recommend getting a monitor with full-DVI resolution, 1920 across by 1080 high pixels. There are still many monitors with fewer pixels, but without the cost savings of yesteryear, so avoid them.

Big tip: Rather than use the usual clunky DVI cable with a clunky mini-DisplayPort adapter, buy one of these sleek mini-DisplayPort to DVI cables from Monoprice.com that eliminate the need for an adapter. Heck you can buy 2 or 3 for the cost of a single Apple-brand adapter. But double-check your order with Monoprice.com, as they sell both full-size DisplayPort as well as smaller size mini-DisplayPort. Your MacBook takes the mini-DisplayPort.

Some newer monitors come with only an HDMI port rather than a DVI port, because they come from the factories aimed at the television markets. I've not tried any, but I suppose they should work well with your Mac given the correct cable or adapter, such as these HDMI to mini-DisplayPort cables from Monoprice.com.

Computer – Apple MacBook

Of course the MacBook is standard gear for office nomads. I chose a smaller size screen since I use the external monitors most of the time.

I suggest buying an extra power supply. I have one I keep with me in my backpack. That leaves one at the ready in my home office. Apple sells two power supply models, one 65-watt and one 85-watt meant for the larger and more power-hungry MacBook models. I usually buy the 85-watt model for maximum compatibility with any Mac model, as they work fine with MacBooks that only need 65-watt. The 85-watt models are a bit larger and heavier, but not by much in the recent incarnations.

Reminder: Apple is replacing, at no cost, old MagSafe power adapters with frayed wiring or similar problems, as part of a lawsuit settlement. Just take your old faulty adapter to an Apple Genius appointment to see if it qualifies.

Mouse – Apple Magic Mouse

My favorite mouse of all time is now called the Apple Mouse, with the rubber roller ball on top. Once sold in a Bluetooth model, it now is only available with a tail.

That roller ball is also a button, and I always set that button to switch apps, the same as pressing Command+Tab. I found that extremely useful and intuitive to use as I tend to spend my working hours switching back-and-forth between programming tools, documentation in PDF readers (Apple Preview or Adobe Reader), documentation in web pages, and email. This feature in unfortunately missing in Apple's newer touch-surface mouse.

Grudgingly, the new Apple Magic Mouse with the amazing touch-surface is becoming my new favorite. At first I did not like this mouse at all. But with the advent of Lion, Mac OS X 10.7, this mouse now makes more sense as Lion brings a new set of gestures you can make on the touch surface.

Bluetooth users beware: Some Bluetooth mice have no power On/Off switch, or have a difficult switch. For stowage in a backpack, you really want a good switch to prevent the battery from being drained.

Tip: For stowing in my backpack, I use the original plastic jewel box in which the mouse arrived. I kept the plastic tray inside, to hold the mouse. The box is surprisingly strong. Using the box keeps the mouse protected, and prevents the battery-draining power switch from sliding to the On position.

Another tip: Get a flat-surface teflon-style mouse pad. When out and about, you may encounter surfaces unfriendly to your mouse. Also, stash one or two of those alcohol swipes that come in a foil packet to clean away mouse gudgies.

Keyboard - Microsoft Bluetooth Mobile Keyboard 5000

I am not usually a Microsoft customer. But I have found this ergonomic-style keyboard to be significantly more comfortable than Apple's straight keyboards. They keys' shape and location prevent the bent-wrist position that aggravates carpal-tunnel problems.

Unfortunately, Bluetooth and ergonomic seem to be mutually exclusive terms. I’ve found no other options but this one. Fortunately this Microsoft keyboard works well enough with Mac computers. It has Windows-logo and Alt keys rather than Command and Option keys, but you can either get used to them, or change their meaning on your Mac in the System Preferences > Mouse panel. You can even slap on a piece of colored electrical tape to cover up that Windows logo.

Actually, I bought the "6000" version of this keyboard. My model cost more than twice the 5000 price and came with a separate Bluetooth keypad which I never used and gave away. From what I've read, the 5000 is basically the same as the 6000 and I presume it will work well fellow Mac users.

Backpack - Brenthaven Expandable Trek Backpack for MacBook

Seattle is riddled with car prowlers as the Seattle Police Department chooses to blame the victim rather than bust criminals like other cities do. So I need to keep my gear with me rather than ever leaving it in my vehicle.

I use a previous edition of this excellent backpack from Brenthaven. Built like a tank, looks brand-new after years of use, and made to fit your MacBook gear.

2012-05-24

Here is the best page I've yet to find summarizing the minimum you need when starting a new HTML5 page. Concise and correct. 'Correct' is important -- there is much misinformation floating around about basic requirements of HTML5 and about good practice of fall-back compatibility with lame browsers.

2012-03-06

[Update: I altered this app to separate the time taken as overhead when launching the Vaadin app from the time taken to create a complex form. The app now launches with a simple form displaying a button that takes the user to a complicated form.]

"Peter" on StackOverflow.com claimed that a complicated form takes 10 seconds with Vaadin, but less than a second on some other web app framework. I took that as a challenge. Using his specification:

Less than a single second when run locally on my MacBook, Intel Core 2 Duo at 2.4 GHz.

8-12 seconds the very first time served from Apache Tomcat 7 on a Mac mini 2.53 GHz running Mac OS X Snow Leopard across the Internets via DSL connections or a Starbucks’ wifi.

After the app launches, a complex form can be built and displayed in a second or two.

So, in the usual case of deployment using modest resources, a Vaadin app’s initial launch has an overhead of about 8-12 seconds. But after initialization, layouts appear in a second or so.

Furthermore, I added some tests for elapsed time within the app. That testing shows that server-side creation of the complex form takes only about 7 milliseconds. Each GridLayout instance takes about 1-2 milliseconds. So most of that second or two it takes for the form to appear must be time spent transmitting the description of the form to the browser and then the browser rendering on screen.

About My Implementation

I tried not to "cheat" by over-optimizing. I generate three instances of the same GridLayout, each representing the "3 columns" mentioned by Peter. The buttons each have a separate listener object that react to a click. Each of the tables is created with its own set of data -- no sharing. Seems like a realistic setup to me.

Here is the source code. Contained in a single class for your copy-paste convenience. I’m sorry Blogger.com has no support for presenting source code.

2012-01-29

I'm liking my new Lion install. Mac OS X 10.7.2 seems to run faster than ever, especially in terms of graphics. And I like Apple's choice to generally tone-down the colors and flashiness in the user interface. Apple heads in the opposite direction of Microsoft as Redmond continues to turn up the visual volume-knob on the in-your-face interface of Windows.

Unfortunately, Apple made one poor choice. Lion now has a subtle but annoying animation on every single window as it opens. A zooming rectangle grows from a central point outwards before the actual window appears. It serves no useful purpose. May sound like no big deal, but after working a long while and staring at the screen, all those window-zooms made me dizzy.

While System Preferences is ignorant of this feature, nevertheless you can disable this animation. Just copy-paste this single line in Terminal.app:

I found this useful tip in the amazingly thorough review of Lion by John Siracusa. I highly recommend that article when you upgrade to Lion.

Another animation to kill: the shrinking/zooming effect when triggering Mission Control. To disable:defaults write com.apple.dock expose-animation-duration -int 0; killall Dock
To re-enable:defaults delete com.apple.dock expose-animation-duration; killall Dock
If only we could kill the nauseating sliding of entire screen when using the shortcut (two-finger swipe on Magic Mouse) to switch between Spaces or full-screen apps.

2012-01-16

Heuback Media has launched a handsome new web site dedicated to their excellent 4D plugins. Spun off from their main web site Heubach-Media.de, the new hmPlugins.com web site focuses on their commercial plugins hmCal, hmReports, hmTAPI (phone integration), hmBarCode, and the handy free-of-cost hmFree.