Searching iOS header files with Xcode Searching iOS header files with Xcode
  • Home
  • Posts
  • Home
  • Posts

Workflow

Searching iOS header files with Xcode

I’m often having to grep through various iOS frameworks in search of error codes that appear (“What the bloody hell does -10867 mean?”). This can be a bit annoying – especially while working with Core Audio – so I put together an Alfred workflow that does it for me.

Here it is – type “hs” (short for “header search”) then the text you want to search for, and it’ll give you matching results. Hit enter to open that file:line combination in Sublime Text, or edit the action script to work with the editor of your choice.

Search Xcode Header Files.alfredworkflow

Screen Shot 2013 04 01 at 11 54 24

Read More

Encrypting and decrypting text with Alfred 2

Here’s a couple of Alfred 2 workflows that implement encryption and decryption via AES256, useful for doing things like sharing passwords.

Select some text (or copy it to the clipboard), and hit the encryption hotkey, and you’ll be prompted for a password; the encrypted contents will be copied to the clipboard.

Then when the recipient has the encrypted text, select or copy it, hit the decryption hotkey, and the original password will be requested. Then, the original text will be displayed and copied to the clipboard.

Encrypt.alfredworkflow

Decrypt.alfredworkflow

Screen Shot 2013 03 25 at 12 51 50

Screen Shot 2013 03 25 at 12 52 14

Read More

OS X service to filter selected text through a shell command

The UNIX shell provides a host of extremely useful utilities for modifying text. This OS X Automator service makes all of them available for filtering text in all OS X applications.

This can be handy for performing quick operations, like replacing text with regular expressions, sorting lists or swapping fields around.

When triggered, the service requests a command to use for filtering, then runs the command and replaces the selected text with the result.

Some sample operations:

  • Sort lines alphabetically/numerically: sort or sort -n
  • Change to lowercase: tr "[:upper:]" "[:lower:]"
  • Replace a spelling mistake, taking care of case: sed -E 's/([tT])eh/1he/g'
  • Re-order elements in a tab- or comma-separated list: awk '{print $2 $1}' or awk -F, '{print $2 "," $1}'

Filter through Shell Command service

Put it in Library/Services, and it should appear in the ‘Services’ menu.

Filter through Shell Command.zip

Read More

DIY Twitter image hosting

Twitter doesn’t yet come with its own inline image support, so we tend to be limited to using image hosting services, and linking to them with short URLs. So, services like Tweetpic host the image, and we direct traffic to them in return.

Thinking it’s better to keep things in the family, and take better advantage of that traffic, I put together an image hosting setup of my own. Now viewers come to my own site, instead of someone else’s!

It looks like this

The setup consists of an Automator service, and some PHP smarts on the site.

Send Image to Image HostingUnder Snow Leopard, I can right-click on an image in Finder, click ‘Send Image to Image Hosting’, type in a title, then paste the URL that’s automatically been put onto my clipboard into a tweet.

Here’s how it works – this assumes a moderate level of understanding of PHP and assorted web administration.

Read More

Unit testing and coverage with XCode

There are several great resources out there on how to incorporate unit testing into XCode projects. It’s all built into XCode now, and it’s fantastic.

I just got coverage working too, thanks to a useful article at SuperMegaUltraGroovy on how to use code coverage with XCode. There were a couple of caveats that I thought I’d share, though.

Read More

Align comments in Textmate

Unless I’m using Objective-C, which is fantastically self-documenting, I often like to add comments to parameters to remind me of what they do. For example:

imagecopy($image, $frame, 
          ($x=max($width-$this->topRightCap[kCapWidth], $this->topLeftCap[kCapWidth])), // Destination x
          0,  // Destination y
          $x,  // Source x
          0,  // Source y
          min($this->topRightCap[kCapWidth], $width-$this->topLeftCap[kCapWidth]),  // Source width
          $this->topRightCap[kCapHeight]); // Source height

imagecopy($image, $frame, ($x=max($width-$this->topRightCap[kCapWidth], $this->topLeftCap[kCapWidth])), // Destination x 0, // Destination y $x, // Source x 0, // Source y min($this->topRightCap[kCapWidth], $width-$this->topLeftCap[kCapWidth]), // Source width $this->topRightCap[kCapHeight]); // Source height

The only thing is, it looks terrible and is very hard to read. I usually carefully insert spaces before the comments so they line up, but that’s really hard to maintain.

I use Textmate, and found an ‘Align Assignments’ script by Chris Poirier which applies very nice formatting to a block of assignments.

Some trivial modifications resulted in a similar script to align comments. Hit Ctrl-Option-Command-/, and:

imagecopy($image, $frame, 
          ($x=max($width-$this->topRightCap[kCapWidth], $this->topLeftCap[kCapWidth])), // Destination x
          0,                                                                            // Destination y
          $x,                                                                           // Source x
          0,                                                                            // Source y
          min($this->topRightCap[kCapWidth], $width-$this->topLeftCap[kCapWidth]),      // Source width
          $this->topRightCap[kCapHeight]);                                              // Source height

imagecopy($image, $frame, ($x=max($width-$this->topRightCap[kCapWidth], $this->topLeftCap[kCapWidth])), // Destination x 0, // Destination y $x, // Source x 0, // Source y min($this->topRightCap[kCapWidth], $width-$this->topLeftCap[kCapWidth]), // Source width $this->topRightCap[kCapHeight]); // Source height

Here it is:

Align Comments.tmCommand.zip

Read More

Finder toolbar scripts for better workflow

200903111109.jpgI recently found two Finder toolbar scripts which are really going to make my life easier.

The first one, Open In TextMate, will open either the current folder, or the selected item(s), in TextMate.

The second, Open Terminal Here (and icon modification), will open a Terminal window at the current path.

Read More

Website maintenance with Textmate and FTP/SSH Bundle

I tend to work on local copies of my websites, which have either corresponding vhost entries in my local Apache configuration, or are simply symlinked to my ~/Sites folder. That way, I can test to make sure everything’s 100% before I make changes live.

This has typically been a bit of a messy workflow – I make changes, and then when happy, either open up a terminal and rsync the whole lot over, or open up Flow/Transmit and manually copy the changed files over. The whole thing makes me disinclined to make changes at all!

That is, until on a whim, I did a google search for a Textmate FTP bundle, and found Bernhard Fürst’s FTP/SSH Bundle for Textmate. This little gem lets you configure FTP settings for a project, then hit Option-S to save to the remote server, or Option-R to reload from the remote server. This way, when I’m happy with the changes, I just whack Option-S to send them to the server straight from Textmate.

That makes me happy.

One little caveat – the bundle does an odd thing with the project directory, opting to use the parent folder of the Textmate project file, something which won’t work for ad hoc projects, when one just drags a folder into Textmate (one of my favourite features). A quick fix:

  1. Find Library/Application Support/TextMate/Bundles/FTP-SSH and open its contents
  2. Open up Support/lib/helper_functions.php
  3. Change the $PROJECT_DIR definition on line 15 to:

    $PROJECT_DIR = $_ENV['TM_PROJECT_DIRECTORY'];

Voila!

Read More

Hi! I'm Michael Tyson, and I run A Tasty Pixel from our home in the hills of Melbourne, Australia. I occasionally write on a variety of technology and software development topics. I've also spent 3.5-years travelling around Europe in a motorhome.

I make Loopy, the live-looper for iOS, Audiobus, the app-to-app audio platform, and Samplebot, a sampler and sequencer app for iOS.

Follow me on Twitter.

© 2021 A Tasty Pixel.