mac

25 Jul

Pandoc: Convert Your Documents

in mac, markdown, os x

Pandoc is an Open Source tool (and a library) for converting documents from one format to another. Specifically, it can take a document written as Markdown, reStructured Text, Textile, HTML, DocBook, or LaTeX and convert it to any of a plethora of other formats, including:

  • Word DOCX
  • Open Document Text (ODT)
  • HTML, XHTML, or HTML 5
  • PDF
  • LaTeX
  • EPUB ebooks
  • Many others

The Pandoc project provides installers for Windows and Mac. Pandoc already has packages in most (if not all) of the popular Linux distributions.

In addition to its general conversion functionality, Pandoc augments the input formats with support for citations, mathematical notation, and many Markdown extensions.

20 Jun

Terminal Oops: Resume a Stopped Process in OSX, Linux, or UNIX

in linux, mac, os x, programming

Have you ever accidentally suspended or stopped a process in your shell? In UNIX, Linux, and Mac OSX it is easy enough to do. An accidental hit to CTRL-z will suspend a program, returning a message like this:

    [1]+  Stopped                 top

The message above says that the process that was stopped is named "top". What it means is that the process still exists, but is in an suspended state where it is not actively doing anything. If you try to exit your shell session, you will get a message saying something like zsh: you have suspended jobs. and you will not be able to log out.

The easiest way to restart after this is to type the command fg:

    $ fg

That will start the last stopped program. You can optionally supply a name to fg. We stopped "top" above. We can restart it like this:

    $ fg top

That will restart "top" even if it wasn't the last process stopped.

26 Jan

(Re)Mapping Command-Shift-Arrow Keys in Janus/MacVIM

in janus, mac, vi, vim

Users of the Janus VIM suite may notice a change in the newest version of Janus. In previous versions, one could navigate around split panes (including to and from the file browser) by holding down COMMAND-SHIFT and then typing one of the arrow keys. This feature has been removed from the latest versions of Janus (I'm guessing because of some other conflict).

Here's how to add that back in.

  1. Open your ~/.vimrc.after file.
  2. Add the code shown below.
  3. Save and restart VIM.
07 Sep

Configuring MacGDBp for Debugging a Local Debian Virtual Machine

in Debian, drupal, mac, macgdbp, os x, virtualbox, xdebug

In my current Drupal development environment, I run an entire Debian server stack (LAMP + Memcache + Varnish, etc) inside of a VirtualBox virtual machine. On those frustration-laden occasions when I need to fire up the debugger, I use MacGDBp to connect to the virtual machine. Here's how I configure them. (If you just want to configure MacGDBp for debugging with MAMP or OS X's Apache, you may want to read an earlier article, and then check out the updates for Snow Leopard.

16 Apr

Linux/UNIX/OS X: How to find and combine multiple files

in linux, mac, os x, system administration, unix

This explains how to use a UNIX-like command line (including Linux and OS X) and the find command to search through a subdirectory and find all of the files with a certain extension, and then combine those all into one file. Surprisingly, this isn't a difficult task. It can be accomplished with one command on the command line:

$ find ./src -name '*.txt' -exec cat '{}' \; > test.txt

The above looks through everything in the ./src directory (including all subdirectories) for any files with the .txt extension. Each file it finds, it adds to test.txt. So at the end of the command's run, all of the text files will be combined together into text.txt. You can use this strategy to easily combine lots of files into one.

Using find, it's easy to customize the command above to do all kinds of things with files. I gave a few examples in an earlier post about the UNIX find command.

30 Jan

OS X: Installing MongoDB and the PHP Mongo Driver

in mac, mongodb, os x, php

MongoDB is a full-featured object database. Since it is fast, versatile, and schema-less, you can develop a very complex data storage layer without an ORM, and without any tedious coding. For this reason, I have been investigating MongoDB as a storage layer for PHP. Here's how to set up an environment on OS X Snow Leopard.

In this blog we'll do the following:

  • Install MongoDB
  • Add some initial data to MongoDB
  • Install the PHP PECL driver for MongoDB
  • Write a short PHP Script that uses MongoDB
  • Shut down the MongoDB server
15 Jan

OS X: Using curl instead of wget

in bash, curl, mac, os x, wget

OS X does not come with wget, a command-line tool for retrieving websites. For a while, I grumbled about this. I knew that curl was installed, but I hadn't ever used curl from the command line. But once I tried it out, I realized that for my needs, curl is just as good as wget... and I don't have to install anything extra to get it.

Here's how to use curl to fetch a remote URL:

$ curl -OL h ttp://spine-health.com/index.php
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 34646    0 34646    0     0  15314      0 --:--:--  0:00:02 --:--:-- 17767

This will download the remote file and store it locally in index.php. If you leave off the -O, it will write the file to standard output (your terminal, usually).

curl: Remote file name has no length!

Fetching from a URL's root can behave differently. If you perform the same command as above, but pointing to the base URL, you will get an error:

$ curl -OL h ttp://spine-health.com/
curl: Remote file name has no length!
curl: try 'curl --help' or 'curl --manual' for more information

What's going on here? The error is not terribly informative on this point. The problem is that curl doesn't know where to write the output file. A better command here is something like this:

$ curl -L h ttp://spine-health.com/ > out.html

This time, the retrieved data will be written to the out.html file.

Like wget, curl has many options. You can read the man page for details, or you can get a quick summary with the usual curl --help command.

26 Dec

Phing: Fixing Output on OS X

in mac, os x, phing, php

Using Phing on a Mac OS X console sometimes has a strange result: While the Phing script runs correctly, the console displays nothing. The reason for this is that the ANSI color codes used by some versions of Phing are not supported by OS X.

The solution is simple. Change the output logger.

$ phing -logger phing.listener.DefaultLogger ftest

This will use a non-colorized logger.

02 Nov

OS X Security Warning on Email Attachments: Getting rid of them

in email, mac, os x, python, xattr

A colleague of mine recently pointed out that when you unzip an archive of scripts received as an email attachment, every time you open a file, you get a warning like this:

“csvimport.inc.php” is a script application which was attached to a mail message. Are you sure you want to open it?

When you have dozens of scripts to look at, clicking through this warning each time is irritating, to say the least. A little examination of the xattr flags on these files, though, revealed the problem:

$ python 
Python 2.5.1 (r251:54863, Feb  6 2009, 19:02:12) 
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import xattr
>>> xattr.listxattr('config.inc.php')
(u'com.apple.quarantine',)
>>> 

There is a flag on such files called 'com.apple.quarantine'. This flag needs to be cleared.

Originally, I was going to write a script to do this, but a quick google obviated that need. Mark Liyanage has done this already. He shows two different ways to clear the flag.

29 Oct

TechStartups: The Demise of Web 2.0

in google wave, gsoc, iphone, mac, multitouch, web 2.0

I spent last weekend out in Santa Clara at the Google SOC Mentor Summit. The conference itself was fantastic, but at one point a lightbulb went on in my head, and I sat down and wrote an article. Head on over to Tech Startups and read about The Demise of Web 2.0.
TechStartups: The Demise of Web 2.0TechStartups: The Demise of Web 2.0