Author Archives: RichS

About RichS

Coder

My Mac and Me – Filing #3

Introduction

After a month of using my Hazel-based filing system, I’ve made a minor improvement that has had a big benefit.

Whilst the automated clean-up mechanism mentioned in My Mac and Me – Filing #1 has been very useful, one problem is that it takes a day for content to be tidyied up. Sometimes, there is a file on the Desktop that you want to be tidyied up immediately.

Solution

The solution is pretty simple.

I’ve added a new rule to the Desktop folder in Hazel. This new rule is triggered when the color label for a file is set to red. When Hazel detects this, it removes the color label, and moves it immediately to my Notes folder – which then triggers the filing system described in My Mac and Me – Filing #2.

My Mac and Me – Filing #2

Introduction

So far we’ve looked at how to automatically organise the Desktop folder by moving old and unpinned files to a separate Notes folder. The next stage is to automatically organise the Notes folder.

Notes

I generate two types of content:

  • General information/notes.
  • Project specific information/notes.

The former suits a filing system based on Year + Month. The latter suits a filing system based on project specific buckets.

Solution

Once again, Hazel to the rescue – I really need to get a referer link ;-) .

First step is to tell Hazel to monitor the Notes folder:

After that we create our rules for that folder:

As per my description in the Notes section, there are two different types of rules here:

The ones I’ve marked as green are the project specific ones. As Hazel runs the rules from top to bottom, these get matched first. The one I’ve marked as orange is for the general notes.

Solution – Project Specific Rules

For the project specific rules, I (currently) rely on a string match against the file/folder name. There is probably a more elegant mechanism, but, for now, this keeps things simple.

The configuration for the project specific rules are pretty simple:

Here we are looking for a piece of text in the name, and if found, we move that to the project specific folder.

Solution – Date Sorting Rule

For the general rule, we use the information from the file/folders creation date to file it into Year/Month sub-folders, so in Finder it ultimately looks like this:

The logic for the sorting is pretty simple:

We ignore anything that starts with ’20’ – this a bit of a hack to prevent the year folders from being analysed. [1].

Then we create a ‘Sort into subfolder’ action. You can use any format you like, but I prefer the <Year> / <MonthNumber>. <MonthName> format, for example ‘2012 / 09. September’. This gives you correct alphabetical sorting, but maintains readability.

To create that format you need to define the pattern like this:

The Year date created part is built like this:

The arrow divider is a folder separator – so the month is a sub-folder of the year.

The Month date created part is built like this:

And the example in Hazel should look like this:

Done

With this rule set, and the Desktop rule set we’ve now got three different ways of filing our files:

  • Leave on the Desktop to be automatically organised.
  • Move directly to the Notes folder to immediately initate automated organisation.
  • Manually move directly to the target folder.

Future

Ideally I want to get used to creating MultiMarkdown tags, and using these to help with automated filing. But for now, the above approach is working well.

In the next post, we’ll tie our filing system to a task management system.

Hope you found this useful, I’m definitely interested in your feedback.


  1. I did think of using a Color Label for those, but that they complicates other things. You can use any mechanism you think best for this bit. For me, I just have to remember not to start any of my notes with ’20’.  ↩

My Mac and Me – Filing #1

Introduction

How you organise files, and how you keep then organised, is a pretty much universal problem. Thanks to Hazel, I’ve got an automated mechanism (default) and a manual mechanism (override). In this post I’ll describe the first stage of my current automated mechanism.

The Desk(top)

The desktop is a great place to put things; quick access and easy visibility. It is fine for it to be a permant place for some things, but the problem is that for the majority of items it should be temporary, otherwise it easily gets cluttered and productivity suffers.

I keep a small number of things on my desktop; things that I need quick access to, and, importantly, that I am actively working on. For everything else, I got into the habit of manually filing things away into folders – the problem with this though is that it can be time consuming, hence looking for an automated system.

Vision

In trying to automatically manage my desktop, I need two capabilities:

  1. Ability to pin items to the desktop – so they are permanatly left their (until unpinned).
  2. Automatic mechanism for moving files/folders into an organised structure (i.e. off my desktop).
    • Not instantly, but allowing them to reside there for a short period of time.

Solution

Hazel to the rescue.

The first action is to monitor the Desktop folder, and create a Clean Up rule:

Hazel: Desktop Folder

The Clean Up rule monitors the Desktop folder, and anything not pinned (no Color Label), that is older than today, gets automatically moved to the Notes folder:

Hazel: Clean Up Rule

I also keep an alias to the Notes folder directly on my desktop, so that I can easily move things there without having to wait for the clean-up routine:

That is it for this post, but stay tuned for the next in the series where we make this filing system even more useful.

My Mac and Me

Introduction

This will be a bit of a brain dump, but I wanted to set the scene on how I’m using my Mac, so that I can follow up with some more interesting posts.

Plain Text

I’m a big plain text geek – I write pretty much everything in a plain text editor (Notes / Emails / Documents / Ideas / SourceCodeScratchPad).

Why? There a number of reasons:

  • I’ve wasted far too many hours of my life trying to get bullet points (amongst other things) to line up correctly in MS Word. I’m sure it is all my fault, but it doesn’t stop it from happening. And it is always annoying!
  • With switching quickly between Win, Mac, iOS and Web, there really is only one format that you know you can always rely on using: plain text.
  • I’ve always liked the idea of separating the content, from the presentation. It’s is how we write well architected code, so there is no reason why it shouldn’t apply to documents / notes.
  • What file format can you interact with using scripts and other tools.
  • In 10 years time, what is the likelihood that all of the current complex file formats are still going to be readable? Plain text will almost certainly still be usable.

I’m currently using a few different text editors; Byword (Mac+iOS), Sublime Text 2 (Mac), Textastic (iOS), WriteUp (iOS), and iA Writer (iOS). They all work slightly differently, and I keep changing my mind on which I prefer to use, but the beauty of writing everything in plain text is that it really doesn’t matter what app I use :-) .

Content + Markup

In theory, HTML+CSS already gives a very flexible (and plain text based) mechanism for creating content. The problem is that it is a pain to directly write HTML from scratch – especially when you are using a smartphone text editor. Added to that is the fact that it isn’t particularly readable as raw HTML, you really have to present it to be able to easily read the content.

The solution I use is Markdown [1]. It has been around for a long time, but seems (at least to me) to have really taken off in usage over the past few years. I’m sure a big part of this is related to the increase in the number of devices that people are exposed to, and the lack of support on them all for the complex file formats.

File Organization

I recently took the plunge and bought Hazel for Mac. Before I bought it, I’d been thinking that because it seemed such a simple app, I could do everything it did myself. After buying it, I’ve realized that the previous sentence is still true, but the difference is that I can forget about all the plumbing bits, and focus on creating some interesting mashups. It is a cool app, and I’ve only really scratched the surface.

Tasks Management

I’ve been using OmniFocus for my task management for quite a while now. I’m still not as efficient as I should be, but it has definitely improved since I started using it.

End

So, that is a bit of a background, my next post will describe how I’ve been using some of these tools to improve productivity.


  1. Technically, I’m mainly using the MultiMarkdown syntax.  ↩

Problem with Persisted iOS Simulator Credentials

If, like me, you accidentally use NSURLCredentialPersistencePermanent, like below, and run it on the iOS Simulator the credentials will be stored permantly – as you might imagine. The problem is that there is no (as far as I could find) obvious way to get rid of those permantly stored credentials.

    -(void)connection:(NSURLConnection *)connection 
      didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge*)challenge {

        if([challenge previousFailureCount] == 0) {

            NSURLCredential *newCredential = [NSURLCredential 
                credentialWithUser:self.username 
                          password:self.password
                       persistence:NSURLCredentialPersistencePermanent];
            [[challenge sender] useCredential:newCredential 
                   forAuthenticationChallenge:challenge];
        } else {
            [[challenge sender] cancelAuthenticationChallenge:challenge];
        }
    }

Solution

The simple solution to removing those store credentials is to manually delete the KeyChain DB file from your machine. As of 28th August 2012, the KeyChain file is stored in: ~/Library/Application Support/iPhone Simulator/5.1/Library/Keychains

I deleted the file: keychain–2-debug.db, but yours may be called something different.

Top x Coding Issues

My experience in Software Engineering has shown me that a certain breed of bugs keeps re-occurring. The following is my list of the biggest (needless) causes of bugs:
1. Uninitialized variables.
2. Poorly named variables and functions.
3. Multiple function exit points (i.e. multiple returns).
4. Not checking return codes.
5. Not checking before de-referencing.
6. Not verifying target buffer lengths before using them.

I’ve been involved in numerous discussions about what should be included in a Code Standards Checklist, and in my opinion, this list is pretty much all you need. Anything more and people ignore it anyway.

How to Fix a Sony Remote – RM-ED035

Problem

My youngest son (12 months) decided our TV remote would be good to chew on – he is really rather like a dog at the moment!

He didn’t have it for too long, but managed to do enough damage that the remote was repeatedly sending button presses to the TV. :-(

I tried the usual tricks: taking the batteries out and putting them back, using a hairdryer to try and get rid of moisture, and mashing the buttons. Nothing worked.

Next, a quick check on eBay suggested I could get a replacement for £15, so not too bad, but worth me having a go at fixing it.

A search on Google didn’t turn up anything useful to help fix it, so after a few experiments, I managed to take it to pieces, and thought I should post here in case anyone else has the same problem and wanted some help.

How To

First, you need to get the back cover off. It slides up, so you can replace the batteries, but at this point it isn’t obvious how to remove it. There are two ways; you can either use a flat metal blade (I used a table knife, but you may wish to use something safer!) and insert into the seam between the back cover and the main body and then slide it up and down until you pop open the catches, or, the better way, is to half slide up the back cover and you’ll notice little grooves that it slots into to help you get it off.

Next, remove the six little screws. Even with these removed, it is still locked together because of internal catches. I couldn’t find a simple way to get this off, so had to use the same flat blade trick as before.

After you’ve got this apart, you can clean the rubber keys and the contact board, and hopefully this will fix it for you. Then, just put it back together and you are done.

Hope this helps.

Rails and MySQL

Jeez, it gets worse.

I finally managed to get things moving my installing RVM and Homebrew. From this I installed Ruby 1.9.2, Rails 3.0.7, and MySQL 0.3.2. Unfortunately, if you use MySQL 0.3.2, you need to use Rails >=3.1. So, I downgraded to MySQL 0.2.7.

Then, I got some annoying MySQL connection error.

Finally, after three evenings of trying to resolve the error, I’ve have removed RVM, installed the MySQL2 gem into my system and configured the link to the MySQL lib, and finally, after a reboot, I’ve got it working.

Phew. I’ve not had this much hassle since I tried to install OpenNAS on my Linux box.

Ruby and Rails and MySQL for Mac (Snow Leopard)

Whilst we are living in Mountain View, we thought we’d join the library. It is pretty impressive, and the kids section is bigger than my entire local library in the UK (in fact, my closest UK library has just been shut down due to budget cuts!).

In most of the libraries I’ve been to in the UK, they usually have about 3 computer books:
* Windows XP for Dummies
* How to use an iPod
* C++ in 24 Hours

However, the Mountain View library has a few hundred computer books. It is pretty impressive.

Whilst we were there I spotted a few books on Ruby and Rails, given I’m interested in learning new things (and have a history of using Python), I thought I’d give it a go. I know I’m a little late to the party, but I’d rather be playing with something like this than watching some rubbish on the TV.

Thankfully, Ruby, Gems, and Rails are all pre-installed on my Mac. Unfortunately though, the book I’ve borrowed suggests I use MySQL as the DB, and MySQL isn’t preinstalled.

Whilst the installer was pretty simple, getting it to work with Rails has been rather more troublesome. I thought I’d post about how I’d managed to do it, but I’m still not there – and I’ve spent the past 2 hours trying to get it to work. :-(

I guess that is the problem with computer books, they are out of date as soon as they are written. Maybe the UK library model works best ;-) .