Splitting PDFs into single pages using Automator

Every quarter at Mozilla managers get an automatically generated PDF report that we need to split into single pages.

The first time, I did that with Preview.app… dragging each page out. Slow, but reliable! It was only two pages, so it’s doable.

The second time, I automated it, using THE AUTOMATOR!

This app was introduced in 2005 in Mac OS X and I’ve never actually used it for good. Well, I’m glad I finally found some good use for it, as these reports are getting longer and I would rather spend my time on something more interesting than dragging thumbnails around 🙂

So, instructions if you don’t like watching videos:

  1. Open Automator
  2. Create a new workflow
  3. Select Library… Ask For Finder Items… double click to add it to the workflow
  4. Select PDFs… Split PDF
  5. And RUN IT, using the bottom on the top right!

It will ask you for the PDF you want to split, then it will split it in pages and place it on the Desktop.

You could get fancier, and you probably still need to rename the individual files, but I haven’t researched that bit yet.

Happy (and fast) splitting!

Google Calendar shortcuts and tricks

Since I started managing people, I spend a lot of time looking at my calendar!

Here’s some shortcuts I use a lot:

  • view:
    • m: month view
    • w: week view
    • d: day view
  • navigation:
    • n: next (if you’re in month view, it jumps to next month, if you’re in week view, it jumps to next week, etc)
    • p: previous
    • t: jump to today

I have the calendar pinned on the first tab, so ⌘+1 always brings me to it (I think it’s CTRL+1 in Windows and Linux).

The first thing I do in the morning is to look at what’s in for today–this way I make sure I don’t forget to attend important meetings because I get deep down into something else and then I forget. So I will press “d” and “t” to get the calendar to ‘day view’ plus ‘today’.

I use the other shortcuts to quickly flip between dates when I’m booking new events or to find what is upcoming.

There are also shortcuts to create and edit events but I found them not very useful as you still have to modify the time and date of event anyway-I find it easier to use the mouse to schedule this.

Organising files in Google drive

We use Google Drive at work and for a particular project we ended up in a situation where there were multiple documents related to it, but not an easy way to have “links” to all of them on the same place.

One solution would be to create yet another document and link to the documents. Another one is to bookmark documents in your own browser—but the issue is that if someone wants to collect all the links together in their computer, then they have to bookmark the stuff individually as well.

But there’s an easier way: you can make a folder in Google Drive and add any file to it (whether it’s owned by you or not). Then you can share the folder, and voilà! everyone has access to the collection of documents.

To make a folder in your drive, first go to your google drive. Click NEW… folder. Give it a name, for example: Magnificent folder.

Then go to the document you want to add to the folder, click on the File… menu, select Add to my drive. A little pop up will show up, click on the Organize link… Choose Move to folder, and choose the Magnificent folder you created before.

If you refresh the folder in your drive, the document should be present there.

To share the folder, click on the down-facing arrow on the right hand side of the name of the folder. This opens a drop down menu and you can select “Share…” to open the usual Google docs interface to share stuff with people.

Done!

I’d also suggest that changing the folder view from grid to list, showing the document titles, might be useful in many cases, as the document titles tend to get truncated way too easily.

Eclipse tricks

Shortcuts

These are the ones I use more often and that immediately come to my mind right now. I have ignored the usual CTRL+C, CTRL+V ones 😉

CTRL + Space
code sense: a little dropdown will show up, with available functions/variables depending on what you have already written
Alt + /
They call it autocomplete, I would call it suggest. It’s not exactly the same than code sense. Try it out.
CTRL + F
Search in the currently edited file
CTRL + H
Global search (in the project, workspace, etc)
CTRL + D
Delete the current line

Searching and replacing

To my surprise, most Eclipse users I have spoken to don’t use the more advanced options from the Find/Replace dialog, when it can save you some precious time.

  • I always enable the Wrap search check box, so that I don’t have to worry whether I’m above or after the word I’m looking for.
  • The Incremental check box might be useful sometimes. If you enable it, when you begin typing in the text you’re looking for, it will begin searching at the same time (it won’t wait for you to press the Find button). It’s similar to Firefox’s Search as you type feature.

But the crown jewel is the Regular expressions check box. Regexp’s can save you literally hours of agonising and boring manual replacements. I’ll demonstrate you why with a simple example:

Imagine we have a php file where we’re accessing the members of an associative array. Something along the lines of this:

<?php
$user['name'] = $user['first_name'] . ' ' . $user['last_name'];
echo $user['name'];
?>

Then one day you need to replace those associative arrays with objects. The above code will no longer be valid and you’ll need to update it manually.

It won’t matter too much if you’re just updating a few lines, but imagine the code was longer and you had to perform the same action in several places. Suddenly having to replace $user[‘name’] with $user->name everywhere, manually, doesn’t seem that simple or easy…

But if you enable the Regular expressions check box and enter this in the Find field:

\$user\['(\w+)'\]

and this in the Replace With field…

\$user->$1

… and then press Replace All, your code is quickly updated to the new working version:

<?php
$user->name = $user->first_name . ' ' . $user->last_name;
echo $user->name;
?>

Isn’t that super great? And that’s just a small example, but I hope it serves to show you how awesome that forgotten and ignored feature is.

Something great too is that neither regular expressions nor support for them are new or unique to Eclipse. Once you learn how to use them, you can use those abilities in lots of places. If you’re interested in regular expressions, there are literally TONS of tutorials and resources about them, but here‘s a good starting point. However, the best way to learn is to practise as much as you can, and then a little bit more 🙂

The tasks list

Leave short comments in the code like the following ones:

// TODO change to use config settings
// FIXME this never returns a value
// XXX refactor

… and Eclipse will show them all in a nice tasks list, which you can access in the bottom area of the IDE, clicking on the Tasks tab.

Eclipse's tasks list

You can also check them off as you complete them. In that case they would show up after the non-completed ones, but I personally prefer to delete them from the source code when they are done. It’s up to you 🙂

So that’s for now. Hope you enjoyed the tricks, and they help you make more with less 😉 If you have any other trick that I overlooked, please post it in the comments, I would love to hear about it!