How to get rid of a stuck unread message badge on OS X

Having our messages (iMessage and SMS) available on our Macs is great, however sometimes we get an unread badge that can’t seem to go away, no matter how hard we look for the unread message, it is just not there1.MessagesBadgeIn many cases, however, the solution is simple, and you don’t even need to reboot.

  1. Quit Messages
  2. Restart the dock, either using Activity Monitor or running killall Dock from the terminal

Many thanks to crazyj on Stack Exchange for sharing this easy trick.

  1. Pro tip: you can see which conversations have unread messages by right clicking on the Messages icon. Not that opening these would help getting read of the stuck badge, however.

Send files to Evernote from Hazel

I finally decided that I want to move most of my paperless workflow to Evernote. Its search feature make it more convenient than going through a bunch of folders in Dropbox, and I guess that the fact that the bonus space I had gained through Dropbox’s Space Race has expired gave me the final push I needed to move my stuff.

So, I made a thing.

Evernote_secret_mailI called it sendToEvernote. It’s a Python script that mails the files you want to send to Evernote to the personal address every Evernote user gets after signing up. You can find yours in the “Account Info” section of the app, and you should make sure you keep it secret, otherwise you’re likely to get random junk in your notebooks.

You’ll find sendToEvernote on GitHub. Download it.

I’ll spare you some details about the script (you can find everything in the README file), and just go through what you need to do to get up and running with Hazel.

  1. Download the mailer Python module:
    sudo easy_install mailer
  2. Edit your email settings at the top of the script
  3. Make it executable:
    chmod +x /path/to/

    PROTIP: drag the file into your terminal window instead of typing the path manually.

  4. Add a “Run shell script” action (embedded script) to your Hazel rule, and enter the following:
    /path/to/ "Notebook name" "$1"

Hazel Evernote rule That’s it.

Delete undeletable files on OS X

Today I found myself stuck: I couldn’t delete a directory from my Mac, no matter what I tried, sudo or not.

Undeletable file
Turns out, for some reason the schg flag was set on that folder. schg, or “system immutable” flag, prevents even root from doing anything with that file. Fortunately, root is allowed to remove that flag, and then delete the file.

sudo chflags noschg undeletable_file_or_folder
sudo rm -rf  undeletable_file_or_folder

Problem solved.

(Always be careful copying and pasting sudo rm -rf commands from the internet.)

Recover Ableton Live’s recording after a crash

Last night, I was recording a podcast using Ableton Live as usual, and my Mac kindly decided that it was time for a kernel panic. This left me with a few unusable .aiff files, that couldn’t be opened in Live, in QuickLook or any other app.


It looked like I was screwed. Enter Audacity, one of the ugliest applications available for OS X. It has a great feature: it can open raw PCM data, and it was able to successfully recover the whole recording. You just have to click on File/Import/Raw Data and select the corrupted AIFF file. A window like this will pop up:


You’ll have to adjust some settings to match Live’s. I used 44.1 kHz 16 bit mono, but make sure to check your Ableton recording settings to get yours. Don’t worry if you set them wrong, it won’t touch your original file, it will simply not play correctly in Audacity.

Once you have successfully imported your track, you can export it from Audacity in just about any format you might need.

Automatically download iOS firmwares


Today I discovered that it takes quite a while to download an iOS IPSW, and when you need IPSWs, you are always in a hurry. So I made this little script that checks for a new release using’s API and downloads it. The comments in the script itself should make it pretty easy to use.

I added the script to my home server’s crontab, and scheduled it to run at 1 am every night, with a low bandwidth limit not to hog my connection.

Note: to use this on OS X you will have to either install wget (from sources, binaries, brew, ports, whatever) or edit the script to use curl.

Run Hazel rule based on the day of the week

Hazel-for-Mac-iconI LOVE HAZEL.

Now that I made that clear, let’s get into the actual stuff.

As many of you will know, Hazel is a great Mac utility that lets you automatically do stuff to files. You can move files based on their name/size/extension/you name it, and do a bunch of cool stuff with them, without ever having to write a single line of code.

Today I needed to write a rule that would act based on the day of the week a file was created1.

Turns out, Hazel can’t do that (not much of a surprise, huh?), but this time I didn’t find it particularly intuitive how to do it. You have to use the “Occurs after” function on the “Created date” (or any date, actually). In this example, this rules will only run on files that have been created after 00.00 on Mondays only, i.e. any file created on Mondays.

Hazel rule day of week(Don’t be confused by the weird names on the “day of week” submenu, they’re just the Italian names for the days of the week.)

The cool thing is that you can select more than one day, so as always Hazel is very flexible.


  1. I use a Sony ICD PX333 Voice Recorder to record classes, and I want to rename them based on the day of the week, since what we do depends on the day of the week

Clipboard new-line format when copying from Preview

Today I helped my brother with a Keyboard Maestro macro he needed. Basically, he wanted to take some text from a PDF created by Notability, which inserts new lines to have text flow around images, and remove these new lines.


Pretty easy, I thought: pbpaste to tr and remove \n. Nope. For some reason, maybe some old Mac OS 9 heritage, when copying text from Preview new lines are saved as carriage returns, i.e. \r.

This stupid behavior means that if you try to pbpaste something which contains line breaks in your terminal, you only get the last line. You can view the full output by replacing \r with \n:

pbpaste | tr '\r' '\n'

This lame thing had me waste some time, so I hope this short post makes your life easier.

P.S.: The full command I had my brother put in Keyboard Maestro is:

pbpaste | tr '\r' ' ' | pbcopy

Followed by a Paste action. This replaces line breaks with spaces and pastes the result.

WeMo Control Workflow for Alfred


UPDATE October 2014

Belkin seems to have changed the ports the Wemo’s server listens on, so I updated the workflow. Download and replace your current install (you’ll have to set the IP again). Wemo-Switch Today I had some spare time, so I decided to hack together a simple Alfred Workflow to be able to control my Belkin WeMo Switch (Amazon US, Amazon IT) from my Mac. TL; DR: Download and enter WeMo IP in the “Script Filter” block. Type wemo to launch it. After some googling, I found this nice bash script that allowed me to send commands to the WeMo. It was then just a matter of encapsulating it into a nice Alfred wrapper, and it was relatively easy. WeMo-WorkflowIn order to use my workflow, just download it, install it, open it in Alfred and enter your WeMo’s IP address into the “Script Filter” block. If you also want to use keyboard hotkeys to turn on/turn off/toggle your WeMo, type in the IP in the lower “Run Script” block as well. Open up the Hotkey blocks to edit them. Now that you’re all set, type wemo to get some info about your WeMo. Press enter on the status row to toggle it. Or you can also type wemo on or wemo off to quickly control your switch. The workflow currently supports only one device. I’d love to add support for multiple ones, but I only own one WeMo so it’d be very hard for me to develop the workflow without being able to test it. The Amazon links above are both affiliate links, if you buy a WeMo through one of them you don’t pay any extra and I get a few cents from Amazon.

Get rid of the “Open from iCloud” window in Mavericks

Since the introduction of iCloud in many OS X apps in Mountain Lion, we’ve had to live with the pointless “Open from iCloud” window every time we launched these apps. I’m speaking mainly of TextEdit and Preview, but recently even more apps got this useful feature, such as Automator and AppleScript Editor.

iCloud for TextEdit - we all hate this.

This. We all hate this.

But last month Apple released Mavericks, which came to save us from this hell. It offers a great solution: the ability to enable/disable iCloud on a per-app basis, thus allowing us to only have it on apps that benefit from it (Pages and Byword, for example).

Without further ado, let’s go and kill iCloud for TextEdit & co.

It’s pretty easy: just go to System Preferences/iCloud and click the “Options…” button next to “Documents & Data.

System Preferences/iCloud/Documents & Data/Options…A nice popover will appear and it will let you chose the apps in which iCloud documents will be available. Deselect any apps you wish, and then click “Done”.

DIsable iCloud documents in unnecessay appsFreedom. Enjoy the sense of freedom that comes from your apps being iCloud-free again, like in the good ol’ days.

Now, the next time you open TextEdit, you will be greeted with a glorious empty document, ready to be filled with your awesome words.

TextEdit is now iCloud-free



Introducing SoundBlossomer

SoundBlossomer LogoA while back I wrote about my hack that allowed me to have multiple instances of Soundflower that I used to record a multi-track Skype group call for podcasting purposes. That guide became pretty popular, and it was even linked in Cycling 74’s blog.

Today I’m introducing a new project, SoundBlossomer, a little utility that lets you easily add, edit and delete your Soundflower audio interfaces.

Basically, this app figures out which Soundflower instances you already have defined in your /System/Library/Extensions/Soundflower.kext/Contents/Info.plist file and shows them in a list, allowing you to add additional ones, as well as renaming, changing the number of channels and deleting the other ones.

SoundBlossomer Screenshot

I spent about a day putting together this app, which by the way is my first Mac app ever, and I think it works reasonably well, at least in all the testing I’ve made. If you find any issues, please, let me know.

SoundBlossomer is 100% open source, it is released under the BSD license and you can find all of its source code on the GItHub page. I strongly encourage you to check it out, and even to improve it if you can, I’d gladly pull your changes into the main repository.