Tag Archives: Mac

4 Useful cURL Tricks

cURL is pretty much the universal go-to tool for testing HTTP responses from the command line. If you’re not already familiar with it, here are a few handy things you can use it for.

Checking Headers

You can use cURL to see the headers sent in a request. I use this all the time to see if the headers I’m trying to send in a script are working right.

$ curl -I http://www.google.com
HTTP/1.1 200 OK
Date: Thu, 06 Dec 2012 02:45:58 GMT
Expires: -1
Cache-Control: private, max-age=0
Content-Type: text/html; charset=ISO-8859-1

Sending POST Requests

I was working on a project recently that involved receiving POST requests from a client script running on another server. Since there was no convenient HTML form to use to repeatedly test changes made to the API, I ended up using cURL. Sending POST data is a simple matter of passing an argument that looks something like a query string.

curl http://example.org/url-to-recieve-post-request -d "name=Gandalf&type=wizard";

Continue reading →

FinderPath Extension for Alfred

I use Alfred for all of my application launching, number calculating and folder-finding needs. It usually does a good job at finding what I’m looking for, though sometimes you already have an exact file path in mind and want to jump right to it. One example is the Library folder. I find myself digging around in there regularly for whatever reason (retrieving Minecraft screenshots, diagnosing crashy apps, etc.) and it just takes too long to get there manually. Lion and Mountain Lion made it especially vexing, as it’s hidden by default. (And it re-hidden after each software update, even if you change the setting with a terminal command.)

So I made an Alfred extension that will open any supplied path in a new Finder window. No fancy searching, just a direct “open this.” It uses the standard “cd ~/Documents/GitHub” syntax experienced users of the command line will be familiar with. It even escapes spaces automatically.

Installation Instructions

  • Download the FinderPath extension
  • Unzip the archive and double-click the resulting FinderPath.alfredextension file
  • Alfred should do the rest

Fixing Slow Hosts File Lookups in OS X Mountain Lion

Mac users with custom entries in their /etc/hosts files may have noticed that, under Mountain Lion at least, lookup times for local resources are incredibly slow. I routinely set up names that point to virtual hosts on my laptop so I can give projects their own local domain instead of having http://localhost/projects/something/index.php or somesuch. Typing something.dev is much easier. I noticed that, since upgrading from Snow Leopard to Mountain Lion, Firefox would spend several seconds trying to look up those names before consulting the hosts file and loading the page.

While I don’t know why it’s happening, exactly, I do have a fix. The wait goes away if you put the local entries on one line.

Instead of having something like this:

#virtual hosts myproject.dev wordpress.dev somesuch.dev

You need to have this:

#virtual hosts myproject.dev wordpress.dev somesuch.dev

Leave the lines that say “localhost” alone, of course. Messing with those could cause all manner of Bad Things.

Syntax Highlighting in Mac OS X Quick Look

Starting in OS X 10.5, Apple introduced the handy Quick Look feature, which of course enables you to preview a file by tapping the spacebar. If you’re like me, you probably use it regularly for quick glances at files that you don’t really need to open in your text editor. But it lacks one thing, one thing that makes reading long source files bearable: syntax highlighting.

I can’t believe it took me so long to find it, but there is an extension for Quick Look that adds color coding to source files in most common languages. QLColorCode, as it is called, is compatible with every version of OS X from Leopard to Mountain Lion. You just drop the .qlgenerator file into ~/Library/QuickLook or /Library/QuickLook and enjoy your improved Quick Look functionality.

QLColorCode [Google Code]

Adding Imgur Support to Tweetbot for Mac

The leading Twitter client for iOS just made its OS X debut on Thursday, and it has a very interesting feature. In the application’s preferences window, you can set the services that are used for URL shortening, image hosting, reading later, and so on. In addition to the usual suspects, you can choose “custom” as an option for image uploads.

Federico Viticci included a couple of PHP scripts in his review that interface with the Tweetbot uploader and save the image to either Rackspace Files or your own server.

Well, I didn’t want to be left out of the fun, so I wrote one for Imgur, the supremely famous image host that grew out of Reddit’s habit of using up other image hosts’ low per-image bandwidth allotments.

Continue reading →

Prediction: Higher Resolution MacBooks Soon to Come

The addition of a 2048×1536 pixel “retina” display on the latest model of the iPad has created an interesting conundrum: many developers will no longer be able to fit the iOS Simulator on their computer screens. If you toggle it into the mode added for the third-generation iPad, it’s too big to fit on the screen of any MacBook or iMac. According to Paul Haddad, developer of Tweetbot, it just barely fits on his 30″ Apple Cinema monitor.

If you’re not familiar with iOS development, the Simulator is used to run an Xcode project on a Mac instead of waiting for the freshly compiled binary to sync to the device and then launch. (Also, sometimes you may not have an iOS device handy while you’re making a minor bug fix…or you might not have an iPad yet at all!)

I can’t be the only one to think it strange that Apple would, in the long term, make it difficult for developers to work on their apps on anything other than a desktop Mac driving a 30″ monitor. (That’s a surefire way to cut down on software for the new iPad!)

This, to me at least, seems like a strong suggestion that a refresh of the MacBook Pro line is on the way, bringing with it screen resolutions equal to or higher than the iPad’s. Maybe the iMacs will get a resolution bump, too.

Edit: Ars Technica is now reporting (it’s uncanny, they posted just a few hours after me…) that the latest Mountain Lion beta has double-sized graphic resources, indicating that this is something Apple is at least working towards.

What to Do After You Install Ubuntu Server in VMwware Fusion

I recently installed a fresh copy of Ubuntu Server in a VMware Fusion virtual machine, so I could test some things out locally. (It’s a great way to set up a local development server with a similar configuration to your production server.) The initial setup was painless, but I had an amusing problem after. The default keyboard mapping didn’t match up with my MacBook’s keyboard, so pressing the arrow keys would lead to unexpected behavior. Obviously this is problematic behavior when the only way you have to interact with the OS is text-based…

Fortunately, the solution is simple.

You just need to run sudo dpkg-reconfigure console-setup and follow the on-screen prompts. You would usually use the arrow keys to traverse the menus, but that isn’t exactly possible, is it? Pressing the first letter of the option you’re looking for until it cycles up and is selected works fine, though. (Apple Laptop, USA-style layout, etc.) The full instructions on what you should pick for MacBooks are available here.

Now, moving in and out of the VM window is a little bit annoying, so I installed an SSH server.

Continue reading →

MacRabbit isn’t Dead!

Users of Espresso and CSSEdit have been complaining for some time about the lack of updates to the software. In a surprise announcement, MacRabbit (the developer) announced that Espresso 2 is on the way and that CSSEdit’s functionality is being rolled into it.

The long wait has grated both on our own nerves and those of our awesome users. But while we have kept quiet publicly about what we are working on, it is because privately we have been striving to transform our products into something new and even more awesome: Espresso 2. We are extremely excited to finally be able to show you what we have been working on, as this release will be of interest to both CSSEdit and Espresso users.

An early preview, the “kaboom” release, is already available for testing and upgrade path information has been posted.

Lions and iClouds and iOS 5: WWDC 2011 Roundup

Too busy to watch the liveblogs of Apple’s big WWDC keynote? Here’s a quick rundown of some of the most noteworthy links. There’s a lot changing in iOS, and OS X Lion is just around the corner. Then there’s iCloud, the crazy service that does more than most speculated.

Caffeinated RSS Reader Beta Now Available

A couple years ago, I heard about an interesting Mac RSS reader in development. Caffeinated, as it was called, sounded like a good alternative to my current feed reader (NewsFire). There were some neat screenshots, but the software was nowhere near ready for release.

After much waiting, the developer has finally released a beta of the application.

It’s very fast, taking only a couple seconds to launch. The interface is slick, particularly the pane that displays the current feed item. Caffeinated does a very good job at formatting the text and resizing images to fit cleanly into the content.

Of course, Reeder is also being beta tested now. Since news of Caffeinated started circulating around the internet, some competitors have shown up. Reeder, in particular, stands out. It will be interesting to see which app comes out of beta first, and how users react.

Caffeinated RSS Reader for Mac Finally Out As Beta [Macstories]