development

Wrapper around Property List Util to Convert between XML1 & BINARY1 formats

Xcode Property List Converting Formats Binary to XML

Ever found you had to change the value of Disque Dur Vierge in the French resource of        SystemUIServer.app? No? Good. If so, this small wrapper may help. The normal procedure is to locate the string in the resource, (no linting here, create a backup before touching these files!) convert it from “Apple binary property list” (pass binary1 as arg to –convert flag on plutil) to “XML Document text” (argument you pass plutil is xml1 instead), go at it with your editor of choice, save and convert back to binary1. Then send a TERM signal to SystemUIServer (via killall) to restart and see your changes. If this paragraph is confusing or you’re interesting in learning this stuff more, refer to my last post, WTF is a “command” or “passing arguments”? Making Sense of the Command Line.

 

 

 Manually (old fashioned way)

 

pushd /System/Library/CoreServices/SystemUIServer.app/Contents/Resources/French.lproj/
sudo plutil -convert xml1 InfoPlist.strings
sudo vi InfoPlist.strings
sudo plutil -convert binary1 InfoPlist.strings
popd

With this property list format helper script

(code pasted below) placed in ~/bin (create if it doesn’t exist) which is in my ~/.PATH (create if it doesn’t exist) that’s sourced in my ~/.zshrc or ~/.bashrc etc.

Script Usage

sudo update-plist.sh InfoPlist

down to 1 line from 5 and 1 sudo from 3, respectively.

or (if script not in $PATH)

cd ~/Downloads
sudo ./update-plist.sh InfoPlist

Troubleshooting: You may want to set the executable flag on owner (o+x) on the script. May need to prefix with sudo or run in su

The Code, pasted from the GitHub Gist

#!/bin/sh
#
# A script to make it easier to edit resources in mac.apps on the commandline
# Isam M 2015 <http://github.com/lsd/update-plist.sh>

# exit if pipeline (1+ cmd) fails
set -e

echo
echo "USAGE (default English): To open ScreenCapture.strings in SystemUIServer.app/C/R/English.lproj
echo "$ sudo update-plist.sh ScreenCapture
echo

# hardcode English ...
# LANGUAGE="$1"
RESOURCE="$2".strings

LANGUAGE="English"
RESOURCE="$1".strings
DIR="/System/Library/CoreServices/SystemUIServer.app/Contents/Resources/$LANGUAGE.lproj"

# cd in, validate resource, make backup
pushd "$DIR"
ls -l
echo
diff "$RESOURCE" "$RESOURCE" 2>/dev/null
BACK=~/".$RESOURCE.binary1.`date -j +%S%s`.back"
cp "$RESOURCE" "$BACK"
echo "Backed up resource $RESOURCE to $BACK"

# Convert to XML, open in vi, when done convert back to binary
sudo plutil -convert xml1 "$RESOURCE"
sudo vi "$RESOURCE"
sudo plutil -convert binary1 "$RESOURCE"

# Clean up
mv "$BACK" /tmp
popd
echo
echo "Restart SystemUIServer? (ctrl+c to cancel)" && read
killall SystemUIServer


* See latest revision at gist.github.com/lsd: Wrapper around `plutil` to quickly jump between xml1 and binary1 when editing plists

Learn and Begin Using Markdown in 30 Minutes

Markdown, RedCarpet, Markup Language, OS X, Kramdown, Markdown Editor, Viewer, md file, mkd file, .markdown file

Markdown is a very useful tool for note takers, list makers, writers, bloggers, content architects, developers, … Markdown is essentially a common dialect for note taking. It is very close to how most of us take notes of any kind. Applying a standardized format to your static plain text content means your otherwise arbitrary notes, todo lists and essays are now formatted in a ‘markup’ language that is widely adopted and very simple to pick up and begin using right away. This means that machines now recognize elements of your content and can apply styling and other useful features.

Markdown essentially  s l i c e s  a document into a theme or presentation + the actual content. This means that you write your notes exactly the same way, whether you want a concise and structured grocery list or set of tasks for the week, or you’re writing a book that you want to release in 1 or more formats. Your single essay can be put through 3rd party software and automagically rendered as:

  • Printer-friendly HTML readable in any web browser

  • PDF file for distribution and instant accessibility to PDFs are supported

  • .epub or .mobi ebook file for reading on a Kindle or Nook

  • or published as a hardcopy book

Let’s get practical. You’re making a todo list and realize you need to make another section to group very urgent tasks. You want the urgent tasks to stand out, so you add markings and symbols in your writing to convey labeled groups of tasks. In a text document, you may add 2 empty lines to separate a group and put a line (—–) between a group name and it’s items. Done.

It’s simple. It’s plain text—readable by humans because it looks familiar to how most of us “mark up” our notes by indenting, emphasizing, underline something and using * to denote bullets prefixed to items in a list. And it’s readable by software that can now index, make searchable, add styling and accessibility features (i.e., the file is in a common machine language. I can turn it into a .mobi file to read on my Kindle, or to turn it into an audiobook that has features only possible if you can tell which unit of the file is the title and which is the body of text (like, make an audio Table of Contents.)

UPDATE 12/19/2014: I now use Marko.app over Mou. See my post on Marko and WebStorm integration.

 

Markdown, RedCarpet, Markup Language, OS X, Kramdown, Markdown Editor, Viewer, md file, mkd file, .markdown file

Install Mou – The app features a split screen. The left is where you enter your content, and the right is a live preview of your Markup/HTML content styled using one of the themes in the preferences panel. GitHub, Clearness, Tomorrow, Tomorrow+ and other CSS themes are included. While editing, hit command + R to pull up a concise Markdown Language Syntax reference.

Jeff Atwood describes Markdown accurately:

Markdown is a simple little humane markup language based on time-tested plain text conventions from the last 40 years of computing.

Markdown, RedCarpet, Markup Language, OS X, Kramdown, Markdown Editor, Viewer, md file, mkd file, .markdown file

Mou is a free Mac OS X Markdown Viewer and Editor

Install Behat BDD for PHP on OS X Without php.ini

This is how to install the PHP BDD Behat library. It avoids the “detect_Unicode = false” error you might have when attempting to install it using the phar method.

Open a terminal (spotlight > terminal) and at the cursor of the window that pops up,
type:


$ curl -s https://getcomposer.org/installer | php -d detect_unicode=Off
$ php composer.phar install
$ mkdir app
$ cd app

$ # Now open a file (in any text editor or "nano composer.json" in the terminal. Paste the
$ # following and save the file as composer.json.

{
    "require": {
        "behat/behat": "2.4.*@stable"
    },
    "minimum-stability": "dev",
    "config": {
        "bin-dir": "bin/"
    }
}

$ behat --init
$ touch feature/app.feature

Then follow along: http://docs.behat.org/quick_intro.html#basic-usage