Glimmer

Faint insights into (mostly) the world of automation

Tumbling Out!

| Comments

In a long overdue action, I have moved the glimmer blog out of Tumblr. I had been wanting to use (Multi-)Markdown more in blogging to continue my focusing on the format. I also had a student tell me he could not access the Tumblr website at work due to its other content. Tumblr was/is an easy to use site but my purposes and those of other users don’t seem to match. I had been looking at Jekyll for a while and considering what to try when I discovered that GitHub supported web hosting with some support for Jekyll. Finding the Jekyll importer that would do most of the heavy lifting for moving the site, I took the plunge.

Over about 4 hours, I was able to do fixups of the files that the importer brought over. I also changed Jekyll to use Kramdown instead of Maruku based on this hint originally from Brett Terpstra.

After a bit more exploring, I discovered Octopress which wraps Jekyll with additional conveniences (even though it uses an older version of Jekyll). I was able to copy the raw Jekyll work into the Octopress copy.

After trying things out, I also made the decision to host against my Github Account rather than a project (although both Jekyll and Octopress can handle either approach.) This was a bit hard to retreat to. I had to

  1. Re-run scripts
  2. Edit .git/config
  3. Edit Rakefile
  4. Edit _config

but I think I got it.

Most “irritating thing” is to put bundle exec in front of all rake commands as Octopress is not using more current code. I have not generally had to worry about that in the past but I know many others have.

Safe Boot Is Back (in OS X10.8.3) With FileVault

| Comments

Safe booting for FileVault users is now possible again in OS X 10.8.3. As always, you hold down the (left) shift key right after the chime when booting. You are next taken to the unlock/login screen where you must authenticate by one of the accounts that will unlock the disk. I hold the shift key down right after the “return” key is hit. Then you will see the gray progress bar implying booting in safe mode. After a while (probably after the fschk and other things are done but the progress bar only makes it about 40% across), it will go to the spinner for a while, then just the Apple, and then back to the unlock/login screen but you will notice a red “Safe Boot” in the upper right hand corner. After logging in again, one gets to the operating level of Safe Boot. You will notice (as always) that your “start at login” items won’t be loading — one of the features of Safe Boot.

On my old Mac Mini, things are pretty slow in Safe Boot. It must be disk intensive as my SSD-based MacBook Pro is much faster.

Since safe boot is the safe way to fix some things like

Sandboxd: ... mdworker(..) deny mach-lookup com.apple.ls.boxd

It is great to have this working again.

Exploring Stately for Ruby

| Comments

As someone who has built a hardware-based Morse Code sending system, I am very interested in state machines and their implementation.

I recently found a new ruby gem stately which seemed interesting. Like many packages, the documentation initially seemed confusing so a bit of exploring seemed appropriate. This note documents the little exploring that I did (mostly so I can return to it should I want to use this gem in an application. The two examples left when the dust settled are given in this gist.

My first attempt was to build a counter. I had a bit of problem getting the syntax right and when I retreated to the document’s examples, I found they were incomplete. My first successful attempt (from a syntax point of view was stately_demo_bad (see the gist).

It did not work because the method associated with defining all the details of the state machine appears to change the scope of some of the code into other internally defined classes yielding very unexpected behavior.

Moving everything to method (messages) inside the state machine seems to be the expected (and allowable) approach yielding stately_demo_good (see the gist).

Trading Memory for Functionality (Enough Performance)

| Comments

I was working on a the last note and wanted to check things out under a fresh install. I decided to make a new Mac User to accomplish this. I used GitHub for the Mac, Safari on the Assembla site and the Tumblr site, and the command line. When I finsihed my work, I idlely was thinking about keeping this user account around for the next effort or deleting it. One of the consideration was how much space was in use by the account. I was shocked to see that the home directory took 330MB!

Looking into it, I found the bit space was 300MB in Preferences. The other two large directories was Caches (30MB) and Applications Support (12MB). Inside preferences was a folder SMDHelpData that was the space user. This folder evidently has the help file information: info, caches, and indexes for finding things for all the applications on the system (not just those that had been used). I am guessing there is a distinct copy per user since in theory at least, one could through security settings block different users from various components. There may also be some personalization (highlighting, last location, etc.) capability.

I was very surprised at how much space was taken but I decided my lesson was to also trade space for functionality (enough performance) and leave the user configured so I would not spend time repeating the building of this space.

GitHub With Assembla

| Comments

GitHub has now made a nice simple GUI tool for both OS X and Windows. They have made them freely available for download. They seem to have made careful choices about what to support and not support in order to keep tool as simple as possible. They do support using GitHub1 against other git repositories such as Assembla or a homegrown one. They don’t support multiple remote repositories for a specific local repository but you are free to use GitHub.com for one project2 and Assembla (for example) for another. The two limitations that I have seen that “hurt” sometimes are

  1. There is no graphical view of the change tree (while confusing, if you need it, alternatives are even more confusing)
  2. The Windows and Mac Clients look different and behave a bit different.
  3. Github really knows you by the name/email you list in it’s configuration and does not like/support your having a separate identity on a per project basis.

These limitations are not fundamental and Github.com may work on them in the future. There have been frequent updates thus far to Github — perhaps they will continue.

Using GitHub with an existing project hosted in Assembla

If this is your first use of Assembla (but assuming you already have an account), then you will need to update your Assembla profile with your public ssh key. This file may exist on your system ~/.ssh/pub.rsa where ~ refers to your home directory. You probably generated this as part of your git install but if not (and after you possibily install ssh), use

ssh-keygen -C "demo@example.com" -t rsa

substituing your email address. Take the defaults (hit return) on everything unless there is an offer to overwrite the pub.rsa file AND you need the pre- existing one! You will now a the file you need. Go to your profile in Assembla, select manage keys and upload this file to assembla.

If there is no local repository associated with the existing project, you will need to clone it using the command line. Assembla gives the step by step instructions personalized for the repository (see the “git clone” information near the top of the Source/Git tab). Be sure to use the “clone/push URL” if you are planning to push back to Assembla in the future.

After you have a local repository (start here if you already had one), merely start up GitHub, and use the menu to select File | Add Local Repository option selecting the directory containing the project repository.

Starting a new project with GitHub and Assembla

Make your Assembla Space in Assembla selecting an option that includes Source/Git repository. After it is made, you will be on a page that contains very useful “Getting started with Git” instructions. For this note, I assume you have installed git and configured it with your name and email.

If you are starting the project, create your repository folder as you would any folder, perhaps

 mkdir demo

Attach a terminal window to this new directory (new project) or the existing directory corresponding to the top of your existing project.

 cd demo

Then, assuming you have not been using git and a local respository only, initialize git

 git init

If you have a new project, you need at least one file. Create one — prehaps a readme.txt file.

 echo "" > readme.txt

Out of scope for this note but if it is an existing project not yet in git, you may wish to set up a .gitignore file to keep certain files (or file types) from being tracked. We will assume we are tracking everything for simplicity here.

Now, we need to add all new (or changed files)_for tracking and commit the present state of the files to the local repository. We will use “First commit” as the message about this commit. Adjust as desired but limit yourself to one line of information unless you know how to do multiple lines as one command in your terminal (command) program.

git add .  
git commit -m "First commit"

Now configure the repository to know where the remote repository is in Assembla. Be sure to use the customized one on your Assembla instructions.

git remote add origin git@git.assembla.com:demo.git

where demo is the name of the remote repository as known to Assembla.

Finally, send your first commit up to the remote repository.

git push origin master

Success. You can now switch to Github as noted for an existing git reponsitory above.



  1. I will use “GitHub” to refer to the program and “GitHub.com” to refer to the site or company for the remainder of this note.

  2. Don’t forget to create your Github.com account and tell GitHub about this!

CoffeeScript With Select2 Library

| Comments

I had two demons: a new library and a language I was not really familiar with. A formula for puzzles. I did not find quickly the right example to do the jQuery/Select2 JavaScript to CoffeeScript mapping but I did find a reverse compiler which helped.

In case it helps, I was trying to convert a working Javascript solution (derived from the Select2 documentation):


function personFormatResult(person) {
    var markup = "<table class=person-result><tr>"
    if (person.email !== undefined ) {
        markup += "<td>" + person.email + "</td>";
    }
    if (person.name != undefined ) {
        markup += "<td>" + person.name + "</td>";
    }
    markup += "</td></tr></table>";
    return markup;
}

function personFormatSelection(person) {
    var t = person.name;
    if ( person.email != "" ) {
      t += " &lt;" + person.email + "&gt;";
    }
    return t;
}

// presently hacked in section_id of 1

$(document).ready(function() {
    $("#demo1").select2({
        placeholder: {name: "Search for attendee by email", email: ""},
        minimumInputLength: 1,
        ajax: {
            processData: true,
            data: function (term, page) {
                return {
                    email: term,
                    section_id: 1
                };
            },
            url: "/attendees/match",
            dataType: json,
            results: function (data, page) {
                return {results: data};
            }
        },
        formatResult: personFormatResult,
        formatSelection:personFormatSelection
})});

to CoffeeScript. One translation is


personFormatResult = (person) ->
  markup = "<table class=person-result><tr>"
  markup += "<td>#{person.email}</td>" if person.email != undefined
  markup += "<td>#{person.name}</td>" if person.name != undefined
  markup += "</td></tr></table>"

personFormatSelection = (person) ->
  markup = person.name
  markup +=  " &lt;" + person.email + "&gt;" if person.email != ""

# And with the help of http://js2cs.nodejitsu.com/ (blank lines optional):

$(document).ready ->
  $("#demo1").select2
    placeholder:
      name: "Search for attendee by email"
      email: ""

    minimumInputLength: 1

    ajax:
      processData: true

      data: (term, page) ->
        email: term
        section_id: 1

      url: "/attendees/match"

      dataType: "json"

      results: (data, page) ->
        results: data

    formatResult: personFormatResult
    formatSelection: personFormatSelection

Hope this is useful to someone else.

The Simple Stuff Can Get You…

| Comments

I was trying out the EPUB export of VoodooPad and figured out I had to make a cover page in the tool as well as a collection. I then filled out the metadata including author information (David Green userid@site.com) and then saved with an .epub extension.

Things ran fine but when I moved it over to the iPad as an iBook file, I was told it was an invalid format. Alas, googling did not help me (it has to happen every once in a while).

After a goodly bit of exploring, the problem was the e-mail address in angle brackets as part of the author information. I removed them and things were good to go.

Adjusting the Mac OS X Path

| Comments

The path is an environmental variable that tells the command line (shell) processor where to look for programs (commands) to run when they are entered on the command line without any directory information. The shell will look for the command in all the directories listed in the path variable.

In OS X, the active path can be shown when in the terminal window by typing echo $PATH command on the command line (where [user@system ~]$ is the command line prompt and the text right before the “]” is the present working directory (pwd). If it is “~” then it is the home directory of the user, typically something like /Users/user (for a user named user).

 [user@system ~]$ echo $PATH

The path in OS X is maintained in several places:

  • .bash_profile
  • .bashrc
  • system versions of the above
  • .MacOSX/environment.plist

There a lot of references for the first three since this is roughly the same as Linux/Unix assuming both systems are using the bash terminal shell. An example is in Tech-Recipes.

.MacOSX/environment.plist is obviously specialized to OS X, and this path modification is seen by the GUI as well as command line programs run in the terminal window. If the directory does not exist, you can make it at the terminal prompt:

[user@system ~]$ mkdir .MacOSX

Today, the file, if it exists, may be stored in binary rather than in text form:

[user@system ~]$ cd .MacOSX
[user@system .MacOSX]$ more environment.plist
"environment.plist" may be a binary file.  See it anyway?

is indicative of the file being binary. The command plutil can convert this binary file to text oriented:

[user@system .MacOSX]$ plutil -convert xml1 environment.plist

at this point, you can edit it carefully to contain your path. It must be a complete collection where each path is separated by a “:” and the file must obey XML rules. Mine looks like:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>PATH</key>
    <string>/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/opt/local/bin</string>
</dict>
</plist>

You can either edit the file by hand with your favorite text editor, or if you have Xcode installed, there is a tool to edit the file in a structured manner. The tool may be able to work without conversion from binary to xml.

After editing the file, you may wish to convert it back to binary (although I don’t think it is necessary) by

[user@system .MacOSX]$ plutil -convert binary1 environment.plist

After changing this file, you will have to either logout or reboot so that all the OS X parts associated with your login will use this new path.


Short note for other OSes

The JAVA folks offer this short article for other operating systems such as various versions of Windows, Linux, and Unix.