Posts Tagged ‘Mac OS’

Unhide ~/Library in Mac OS X Lion 10.7 [Take Two]

As many people have no doubt noticed by now, Mac OS X 10.7 hides your Library folder by default in the Finder. For power users, developers and other such creatures in regular need of the Library, this means a trip to the Terminal, which seems like a step backwards (to me, at least).

There has been a hack floating around to reenable hidden folders which I detailed here, however it really goes too far, enabling the whole Unix filesystem for view in the Finder.

A more useable alternative uses the ‘chflags’ command, and can be invoked with the following:

$ chflags nohidden ~/Library

Privacy & Security Should Be Optional

Having recently upgraded to Mac OS X Lion, I’ve spent a good deal of time in the past couple of weeks reinstalling software on and as-needed basis. One package I’ve been reluctant to reload is Adobe’s Flash player, the de facto media delivery mechanism for the desktop web and a program which knows how to eat CPU and burn up your machine like no other.

While I’ve railed against Flash for its processor greed and propensity for cooking chips in the past (mainly with workarounds and avoidance techniques), I’ve grown so used to these shortcomings and working around them that they are no longer my primary concern when loading my machine with Adobe’s player.

With the release of version 10.3 back in May 2011, Flash gained for the first time a pane in the Mac OS’ System Preferences application. It seems almost incredible that it wasn’t until earlier this year that a piece of software present on 99% of all internet connected computers, 8.1% of which are Macs, didn’t have an OS-conventional approach to settings alteration. Finally setting Flash preferences falls in line with convention. But the addition of the Flash Player preference pane has actually drawn my attention to what I view as an industry-wide problem with ensuring user privacy and security.

You see, with 2.1 billion people connected to the web and more than 1 in 3 using Facebook, privacy and security have become quite the hot topic of late. More people are sharing more information and are, rightly, more concerned about where it’s going and what it’s being used for; as the network becomes the computer (many buy a laptop ‘just to get on Facebook’ and have little interest in how they get there), makers of local and remote software platforms need to have a clear focus on keeping that data safe.

My concern was raised while browsing through the new preference pane that installs with Flash, and the default settings chosen by Adobe. There are four key areas where the user is given the option to dictate the behaviour of the Flash player: offline storage, camera, media playback and updating. Automatic updates for a software platform with as dubious a security history as Flash is an absolutely welcome and necessarily enabled by default. Similarly, the player will request access to the camera and microphone on a case-by-case basis, a good choice given the proliferation of webcam-equipped laptops.

Offline storage and peer-assisted networking, however, are enabled by default. Given the zeal with which Flash consumes my CPU cycles, I’m not sure I would want it to have free reign over my network connection, and given its chequered security record I’m not convinced that allowing it offline storage by default is such a bright idea either.

The main problem I have with these default settings, though, is that they will probably never be changed, which is why companies like Adobe need to take steps further than just chucking in a preference pane with their app – my mother hasn’t ever and likely will never open System Preferences, and I’m sure she’s not alone. There are necessary changes which need to be made by any company responsible for data handling, even if they are merely providing the conduit (as Adobe does with Flash player).

Firstly, the default security and privacy setting must be ‘lockdown’. Flash shouldn’t be assuming control of a user’s bandwidth or storing files on their machine by default any more than it should be automatically serving up a webcam feed without prompting. The effect of a default feature lockout is that user is introduced to the preference pane and forced to actively make decisions about their privacy and security rather than relying on the stock settings. They needn’t feel bothered – after all, they only have to set it up once and forget about it – but they can now browse with confidence in the knowledge that their information is protected to their very own specifications, and just like everybody has different data, everybody values that data differently.

Microsoft actually has tried something akin this approach twice in the past, first with the variable ‘privacy level’ control in the Internet Options control panel, and more recently with the UAC layer introduced with Windows Vista. Between these two approaches, the company has actually got all of the right ideas. The user needs to be jolted into taking a more active role in their security through dialogs such as UAC, and the variable security level controls provide a useful abstract for casual users with the option for fine control for those who require it. Unfortunately, these concepts have both failed in their execution. UAC is widely derided and often disabled because of its irritating frequency, and the user security variables, like most good ideas from Microsoft, are buried under layers of dialogs and menus, effectively rendering them invisible to the casual user.

By switching the defaults to ‘off’ and gently, but firmly, prompting the user to engage with their online security and privacy, responsible companies can educate their (massive) user base and improve the quality of their experience by placing the decision making process in the hands of the user. While the industry aspires to give an experience which ‘just works’, this is one area where the user should definitely be involved – these are choices which people make every day when they shield their PIN at the ATM, don’t give out their phone number to strangers and ask to see ID from the guy at the door claiming he’s from the gas company. When the data involved is personal, it should be the person, not Adobe or Apple or Google or Microsoft, making the call on how it is protected.





Solving the MBProgressHud _WebTryThreadLock Error

MBProgressHud is a really nice bit of plug in code to add fancy status and loading notifications to your iOS app quickly and easily. It looks great! Unfortunately, there’s an irritating error which cost me some time this morning, and hopefully I can save anyone else in the same position some trouble.

The error:

bool _WebTryThreadLock(bool), 0x7b9b5500: Tried to obtain the web lock from a thread other than the main thread or the web thread. This may be a result of calling to UIKit from a secondary thread. Crashing now...

This appears when a method which needs to update a UI component is called directly by the MBProgressHUD object.

The most basic usage of MBProgressHUD is thus:

HUD = [[MBProgressHUD alloc] initWithView:self.view];
[self.view addSubview:HUD];
HUD.delegate = self;
[HUD showWhileExecuting:@selector(fetchNewData) onTarget:self withObject:nil animated:YES];

In which ‘fetchNewData’ is the method which is executed while the progress HUD is on display.

Using this technique, fetchNewData will be called on a secondary thread, which causes the crash error we’ve already experienced. UIKit, which handles all the user interface business, should only be running on the main thread, so when the secondary thread makes a move on a particular UI element, its going to throw the ‘web lock from a thread…’ error. (It should be noticed that you can update some UI components using the standard MBProgressHUD setup detailed above, but in most cases you’ll get the error.)

In the case of this example, ‘fetchNewData’ updates part of the UI, so it needs to be called on the main thread. The quick and dirty workaround I used to force it to execute where I wanted it to was to create an intermediary method which can be called by MBProgressHUD as normal but in turn calls ‘fetchNewData’ specifically on the main thread.

You could, for example, call this method ‘performFetchOnMainThread’:

-(void) performFetchOnMainThread    {
[self performSelectorOnMainThread:@selector(fetchNewData) withObject:nil waitUntilDone:YES];

Instead of directly calling ‘fetchNewData’ from MBProgressHUD, use it to execute ‘performFetchOnMainThread’, which uses the ‘performSelectorOnMainThread’ method to force ‘fetchNewData’ to be executed on the main thread.

This isn’t the most efficient or beautiful way to accomplish this, but it works, so if you’re getting a ‘web lock from a thread…’ error and you need to make sure your code is executed on the main thread, you can use this technique to get the job done quickly.

PC Keyboards in Mac OS X Lion

One of the benefits of the recent upgrade I made to Mac OS X 10.7 Lion is how consistently simple using a PC keyboard now is. The preference pane for switching the modifier keys around (using alt in place of CMD, Windows key in place of option etc…) was available in Snow Leopard and earlier versions, but compatibility with the range of PC keyboards I’ve tried with my various Macs has long been a bit patchy – even though the changes would save in System Preferences, the keys would still use the default mapping.

If you’re used to CMD being either side of the space bar, it can get pretty annoying when it isn’t there.

In earlier versions of OS X, I’ve used DoubleCommand when there’s been trouble remapping keys, however I’m pleased to report that Lion seems to have addressed some of the earlier issues with the modifier preference pane being ineffective.

I’ve tested the modifiers with a range of keyboards (including ones I’ve experienced issues with in the past) and they all seem to be altering the maps without issue.

To alter the key map:

1. Open System Preferences and select the ‘Keyboard’ preference pane

2. Click the ‘Modifier Keys’ button and switch the mapping. When you’re done, click ‘OK’ and close the preference pane.

TWiT Early Show Downloader

For me, TWiT network is one of the most valuable resources on the internet: their programming is always informative, slick and balanced, and the guests are always top-teir tech talkers.

As with most pod/netcasts broadcast from the States, the scheduling of live shows is always at pretty peculiar hours of the day thanks to the time difference, which means waiting for the edited version to be uploaded and published to the TWiT website.

Handily, the editors seem to work much quicker than the web folks over in Petaluma, CA, and the shows are normally uploaded quite a bit earlier than they are listed on the website. I’ve been using a little Python program which I wrote to download the shows before they are linked on the site, which you can grab using the instructions below. It uses cURL to download the files so it’ll work on Macintosh and Linux systems.


Restore Hidden Files to OS X 10.7 Lion Finder

One step Lion takes in the direction of erasing the file system altogether is hiding the Library, System and other OS- and user-crucial directories in the Finder.

Obviously as power users we’re fully used to delving into the (already abstracted) file system of Mac OS X, and we want those folders back! Via this site, there is a Terminal command to restore access to these directories, but be warned that it comes with a caveat: by enabling access to these folders, you open up the whole filesystem including UNIX folders (etc, var…) and DS_Store files for view in the Finder.

In short, it’s way annoying, especially when browsing Linux volumes.

Irritating as having bits of the filesystem whipped away from prying eyes, I think I’m going to stick with Terminal for accessing those folders. TextWrangler can still browse them, and that’s enough for me. For those who want to see everything, and I mean everything:

$ defaults write AppleShowAllFiles YES

RAM Disk vs SSD vs Hard Disk – The Photoshop Test

A few weeks ago I posted the Macintosh version of ‘rdmanage’, my super-simple Unix RAM disk creation tool, as well as stacking the volatile disks up against fixed hard drives in a Linux I/O benchmark shootout. One thing which has always bothered me about synthetic benchmarking, however, is how far removed it is from most real-life computing contexts.

In order to realistically demonstrate the advantages and disadvantages of the three main types of disk – RAM drive, hard drive and solid state – I’ve prepared a short video of a basic Photoshop loading test, embedded after the break.

I’m a huge fan of solid state disks (the X25-M is one of my all time favourite pieces of computer hardware), but due to their high price and limited capacity they aren’t a complete no-brainer just yet. Using something like ‘rdmanage’ to easily create RAM disks, users of machines with hard disk drives can get a serious boost in application load time (as demonstrated in this Photoshop loading test) without having to spend a dime extra on hardware. The SSD is still the winner in my book, but if you can spare a couple of hundred meg of RAM you can get some of the perks with zero additional cost.


Mac OS X 10.7 Lion iTunes Widget Download


Whilst Java was actually pretty easy to load and X11 is installed by default, one thing definitely missing from Mac OS X 10.7 Lion is the iTunes widget. I use the iTunes widget all the time, so it was pretty annoying that it was not included with Lion.

I pulled the widget file from a Snow Leopard install I have on another machine and, thankfully, it works perfectly with the dashboard on Lion.

For anyone also missing the iTunes widget in Lion, you can download it here.

[Legal: I’m not the copyright holder or the original author of this file]

Install Xcode 4 on Mac OS X 10.7 Lion

Macintosh and iOS developers upgrading to Lion are in for a slice of annoyance, courtesy of Xcode 4.

Xcode was one of the first programs I installed after the Lion upgrade, but after downloading the massive (4GB+) setup file for the second time – direct from the Mac App store – I was met with an error informing me that Xcode was not compatible with Lion.

But I downloaded it straight from the Mac App Store, where all of the latest software is available, right?

Well yeah, that is correct, kinda. Unfortunately it seems that anyone who shelled out for Xcode 4 on Snow Leopard is being directed to the old version. There is a new version available on the Mac App Store, but if you’re reinstalling from your purchase history then you’re downloading the wrong thing, man.

So don’t download Xcode from your purchase history! Head over to this page and grab Xcode 4.1 instead.

Mac OS X 10.7 Lion DOES Ship With X11

And I’ve got the eyes to prove it. There seems to be some concern online that Lion ‘ships’ (can we even say that any more?) without X11. Well, one of the first things I’ve checked out on my retail copy of Lion is X11, which is present as ever.

Open a Terminal window, type ‘xeyes’ at the prompt and you’ll see X11 staring right back at you.

This installed by default on my MacBook Pro, but if you find it missing from your installation you can install it from the ‘Packages’ folder on the Lion install USB key/DMG.