Otaqui.Com

Pete Otaqui’s blog about web development and everything else

Archive for the ‘mac’ tag

Comment And Uncomment All Lines in a Linux File with Sed

leave a comment

Just a couple of sed one-liners for adding and removing comments in the form of # marks (in the case of my ~/.ssh/config file). I use this to toggle proxy settings (with connect.c) and it’s run by the awesome MarcoPolo location-aware app for OS X. Both of these are safe to run repeatedly (you won’t end up with multiple # marks or anything).

First adding comments, which means a “#” mark at the start of every line
sed -i '' 's/^\([^#]\)/#\1/g' ~/.ssh/config

Second removing the comments, just stripping out the “#” marks.
sed -i '' 's/^#//g' ~/.ssh/config

A few things to note here, on the assumption that you can see how Regular Expressions work and are vaguely familiar with sed’s /find/replace/ style syntax:

  1. the “-i” flag means “edit in place” and requires an extra argument for the backup file’s extension. I’ve given an empty string so that no backup is made
  2. sed requires escaping of capturing parentheses, hence the \( and \) in the first example
  3. the final ‘g’ at the end of the expressions means “global”, i.e. replace all occurences

Written by pete

February 9th, 2010 at 5:21 pm

Posted in Professional

Tagged with ,

Syncing mail.app with gmail and the iphone using imap

leave a comment

I’ve set up my google apps email account using imap in mail.app and it’s working quite well in terms of keeping track of read and unread emails and having my sent emails available everywhere.

It’s definitely worth going one step beyond google’s own instructions on the matter and correctly configuring the drafts, sent and trash folders in both clients:

Mail.app

Choose the google folder for drafts in the sidebar. From the os x menu bar at the top of your screen choose ‘mailbox’ and then ‘use this mailbox for’ and then ‘drafts’. Do the same with the other folders.

iPhone Mail

Having done the basic setup, go to the settings app, choose ‘mail, contacts and calendars’, navigate to your mail account and choose ‘advanced’ and then setup the ‘mailbox behaviours’ as required.

NB if you are a fan of ‘labels’ in gmail, bear in mind that these equate to copies of the email in IMAP folders. That means that if you have, as I did, several thousand labelled emails from a different account you will have more than one copy of each downloaded to mail.app, assuming you chose to download your messages- and who wouldn’t?

The iPhone seems to work pretty flawlessly, but mail.app sometimes seems to take a while to catch up with changes (especially emails you’ve read on the iPhone while mail.app was offline) although it always seems to get there in the end.

Written by pete

February 24th, 2009 at 7:13 pm

Posted in Professional

Tagged with , ,

David Allen’s Getting Things Done on the iPhone, synced with iCal

2 comments

If you are a fan of GTD, use a Mac and an iPhone, then there’s a great pair of apps you can get that seamlessly sync all your projects and tasks, and that will update your iCal while you’re at it.

Things from Cultured Code also comes as an iPhone app, and the duo update each other fairly well. They miss out on being being “excellent” because the iPhone-to-mac syncing only happens when both your devices are on the same wifi network, and short of closing one of the pair and re-opening it, I can’t fnd a way of forcing a sync to happen whenever you would like.

That being said, they do both work extremely well. The desktop version has a very nice quick-entry interface which feels a little bit like Quicksilver (and is accessed by pressing Ctrl+Alt+Space) which is a nice touch. Both apps use “dock badge” numbers although the number shown can only be customised on the desktop version which lets you set the number as Due, Due+Today and Due+Today+Inbox; the iPhone dock badge will only show Due+Today so personally although I would like the full count I leave the setting so that both are the same.

Neither app is free. The desktop client is (at the current exchange rate) £37.13 ($49.95) and you can buy Things from the App Store for £5.99 ($7.99). The desktop version is also available as a 5-license bundle for £55.72 ($74.95)

Written by pete

February 23rd, 2009 at 4:01 pm

Posted in Professional

Tagged with , ,

Review of the Wordpress blogging clientfor the iPhone

one comment

Having just got myself an iphone, I thought I’d test out the wordpress blogging client.

I must admit that although it’s ok for short posts I can’t imagine I’m going to be writing any very long posts on a touchscreen keyboard (although I am starting to get the hang of it even after only two days of light use). Please pardon any smelling pistakes!

The application is open source, which I’ll definitely appreciate if I ever get around to building an app myself.

You can work with multiple blogs, both self hosted and on wordpress.com. Once you have set up a blog you configure the amount of recent posts to show, I found that he default 10 was a usefaul number

When writing a post, you can set both the tags and choose from the current categories or create ones. Draft posts are saved locally, and when you have finished editing you can either publish immediately or at some future date. You can alternatively set the post as a draft or pending review, which will upload it to the server.

There is also support for adding images to posts – from the photo library or a new shot although no ability to control where in the post the images appear – you only get them defaulting to the bottom of the post.

Overall I would say that the app is as good as the iPhone allows.

Written by pete

February 16th, 2009 at 6:41 am

Posted in Personal, Professional

Tagged with

Enable Google Gears and Offline Gmail for Mozilla Prism

16 comments

[Warning: this post suggests stuff that may not work now, or may break in the future. Use at your own risk!]

I’m really happy to hear that, as the official google blog points out, Gmail now has support for Google Gears allowing you to view your mail offline.

This has caused quite a stir in the blogging community – TechCrunch invites you to throw off your chains, GoogleWatch speculates that it might be the tipping point for Gears adoption, Colin Charles mentioning SSBs such as Fluid and Prism (which this article is about), Google Operating System giving a basic overview and also the GadgetWise NYT blog giving it a spread.

So far, so good. Now what if we want to use a Site Specific Browser, such as those created by Fluid and Mozilla Prism? These “SSBs” are essentially entire browsers, but used only for a single web app – which is quite handy really. I think that Google’s paradigm of basically making each tab / window in your browser it’s own application instance may well remove the need for things like this eventually, but for the time being it would be great to use Gmail’s new offline capability in an SSB.

Well – we can’t do much about enabling Gears in Fluid, since it’s based on WebKit. Check back if you here that Google releases some frm of plugin for WebKit (although actually WK already has HTML5 style “local storage” using SQLite so it could be native support).

We can however do some hacking to get Gears installed in a Prism browser, so let’s go through the process. By the way – I am using Mac OS X 10.5, but I think this should work for any platform that can get Firefox and Google Gears.

I’m using a Google Apps For Your Domain account, it’s worked fine there, although your account will have to have Offline access enabled by google (patience, young grasshopper!).

Step 1: Split a Beam

Go and install Mozilla Prism. I did this by installing it as an extension to my current Firefox.

Once it’s installed and you have restarted the browser, login to your Gmail and from the Tools menu choose “Convert Website To Application.”

Choose whatever options you like in terms of where to put the shortcut. Personally I grabbed Chris Ivarson’s awesome Fluid Gmail Icons and used Preview.app to convert the 128×128 version into a PNG file.

I *also* had a slight issue with not being able to create the app inside the Applications folder, because it needed to Authenticate but just failed silently – YMMV.

Assuming that’s done you should have a nice new Gmail SSB, which you can start and log in to Gmail with. Funky.

Step 2: Start The Fans, Please!

[Note: you have to be older than young, from the UK and to know who Richard O'Brien is to get that "start the fans" bit]

So now we need to get Google Gears installed. You can try doing this from Gmail’s own interface but it will fail complaining that “Gears is not compatiable with XYZ” (where XYZ is the name you gave it and a version number). This is because, even though your Gmail webapp *is( Firefox under the hood, it doesn’t report itself as such to the extension. What we need to do is convince the extension that it is in fact compatible with it.

[Note: it might be more efficient if you want to install several extensions to make your SSB report itself as really being Firefox, but I'm happy with a one-at-a-time approach].

The next thing to do is actually download Google Gears manually. I suggest that you really do try (and fail) to install it from inside the Prism app, because you will be told the current, valid URL for the XPI in the process. If you’re super lazy, here’s where I got mine from (not a link so that you’re encouraged to FIND THE RIGHT URL FOR YOURSELF!):

http://dl.google.com/gears/current/gears-osx-opt.xpi

You might want to use Safari / Opera / wget / IE to actually download it.

Step 3: Unpack, Tweak, Repack

An XPI file is in fact just a ZIP file with delusions of grandeur. Rename the file to “gears-osx-opt.zip” and unpack it.

Now open up “install.rdf” and find the bit that looks like this:

<em:targetApplication>
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>1.5</em:minVersion>
<em:maxVersion>3.0.*</em:maxVersion>
</Description>
</em:targetApplication>

The big long string in curly brackets is the Firefox GUID.  We will need to change this, and also the version numbers.

I found the GUID and version numbers inside my (OS X-specific) “Gmail.app” that Prism created.  Control+Click on it and choose “Show Package Contents” then navigate to “Contents/Resources/application.ini” and open this in a text editor.  It is the “Version” and “ID” values that you want from the “[App]” section.

Applying these to the original install.rdf file we get this (I’ve extended the version numbers just for the hell of it):
<em:targetApplication>
<Description>
<em:id>prism@developer.mozilla.org</em:id>
<em:minVersion>0.1.*</em:minVersion>
<em:maxVersion>10.0.*</em:maxVersion>
</Description>
</em:targetApplication>

Save the edited “install.rdf” file and now you need to repack the zip / xpi.  Take note – you should compress the *files* and not the *directory* or it won’t work.

Change your newly created zip file’s extension back to XPI – and we’re ready to install!

Step 4: Install

This may vary across platforms, I’m not sure.

From the *status bar* (an unusual place to get to the Add Ons / Extensions list) of your Prism app, click the cog and choose “Tools”, “Addons”.  This should pop open the Add Ons panel.

Drag and drop the XPI onto the Add Ons panel and, hopefully, bingo!

If you get an error about “version support” then you might have got the ID or version number wrong somewhere.  If you get one about “cannot find install script” then your XPI / zip is badly formed.  Leave a comment if you need more help here.

Step 5: Enable Gears for Gmail

You’ll need to restart your browser and log back in to GMail.  Then you should be able to click the “Offline” icon at the top of the interface and go through the normal Gears “I trust this application” process.

That’s it! You should now be able to access your mail offline. It’s worth noting that the shortcut that gears can create for you to open your email while offline seems to work fine too.

[Update 31st Jan 2009: It looks like Fluid may support Gears sometime soon!]

Written by pete

January 30th, 2009 at 6:18 pm

Posted in Professional

Tagged with , , ,