donderdag 18 juli 2013

AppleScript select RAW pictures iPhoto library

A quick appleScript I wrote to select all images from the current library that are from a certain type.

The type is checked with the extension found in the path of the original picture (original path property of photo object). The below example is to select all NON NEF pictures. NEF filetype being the Nikon Raw format.

tell application "iPhoto"

    select (every photo in current album whose original path does not contain ".NEF")
end tell

woensdag 10 juli 2013

jade template with variable in element id

For most NodeJS projects I rely on Jade for rendering views.

A quick example of how to generate a set of elements based on your data:

  each val in [1, 2, 3, 4, 5]
    li= val

This will render the following html:


And another quick example of how to assign id and class names to an element:



<a id="main-link" class="some-class"></a>

A very powerful yet easy and minimal syntax for HTML. However I often need to combine these two. That is render a list of items in which the element IDs are specific for each rendered element. The solution looks like this. Consider the items set to hold objects with an ._id and value property.

  each item in items
    li(id='element#{item._id})= item.value

That's it.