Welcome to the lab.

Web Excursions for August 29, 2014

[Tweet : ADN : nvALT]

Having a stranger verbally deliver your message to someone would be all kinds of creepy fun. I could see some serious personal safety issues arising, so just be careful what information you give to unknown people.
TermsFeed - Privacy Policy Generator
A handy tool to have for anyone publishing websites or mobile applications.
This is exactly what spl originally did, but I changed my mind at the last minute. It’s a cool idea that takes the result of a search and creates a folder with symbolic links to the file results. I was using it to make CLI Smart Folders… might revive that.
Nice! Simplenote from the command line. Via OneThingWell (where else?).
A simple Sublime Text package for creating “scratch” files for code snippets and notes. You could potentially hook this up with nvALT for quickly saving snippets to your notes folder… with some modification it could even indent the code for Markdown purposes.

Announcing the Textbundle format (and Ulysses 3 giveaway)

[Tweet : ADN : nvALT]

I’ve been working with the Soulmen, creators of Ulysses, to create a new standard for the transport of plain text between applications. It’s called Textbundle, and I’m really excited about the possibilities here. I hope to see as many developers as possible jump on board.

The Textbundle format is very simple. A folder containing a plain text file, a JSON data file, and an assets sub-folder. An app, such as Ulysses, can write a Textbundle out and pass it to Marked, and all of the necessary components are automatically included. Images, additional text files, and any metadata needed are all there and safe from sandboxing restrictions.

Sandboxing is the primary motivation, and Textbundle solves the major issue of referencing external files in Markdown.

The bundles that pass between Marked 2 and Ulysses 3 are labeled as “transient” in the JSON data. This means that Ulysses is free to overwrite the file, and Marked knows that the data can be rewritten at any time. Non-transient files, though, can be used by multiple writing applications. This means that data such as revision history, writing statistics, and all kinds of things we haven’t imagined yet can be stored with a file that can move across folders, entire machines, and even platforms.

When a PC user opens a Textbundle, they have full access to the original Markdown file. They can edit it and send the folder back, and on a Mac it once again appears as a single “Textbundle” file.

There are many, many exciting possibilities for the future here. Every app that implements support can have a namespaced section in the data file to write whatever information is helpful to them. Other apps can access their information and act on it appropriately, too.

To celebrate the Textbundle release, I’m giving away three copies of Ulysses 3. The Soulmen are also giving away 10 copies of Marked on their blog. Textbundle is supported in both now, so previews between the two apps are fluid and free of sandboxing restrictions. Hooray!

Sign up below for a chance at one of three copies of Ulysses 3 (value $49.99 US). Winners will be drawn on Monday, September 1st at 3pm.

One entry per person, valid email required to win. Giveaway ends on 09/01/14 at 05:00 PM. I will never sell or misuse your email address.

Web Excursions for August 23, 2014

[Tweet : ADN : nvALT]

This is the developer edition, I guess.

Calling Swift functions from Objective-C

“It’s a lot easier than the docs make it out to be, especially if you’re just using a single target.”

By the way, Erica is the smartest developer (and probably person) that I know. If you develop for Mac and don’t read her blog, you should add it to your feeds now.

Introduction to Grunt and Gulp.js — Mijingo
Great new series from Ryan Irelan on JavaScript task runners (Grunt and Gulp). 10 videos, 90 minutes of information.
dot-clipboard monitors your clipboard and runs scripts based on its content. Via OneThingWell.

This offers a lot of possibilites, including replicating functionality I’ve already built for StretchLink (coming to the MAS soon, I hope).

Using Sass source maps in WebKit Inspector
If you use a CSS preprocessor, source maps are the awesome. Here’s some info for using them with Sass.
For Sublime Text: turn your TODO comments into GitHub issues, complete with a link. Very cool.

Übersicht hacking

[Tweet : ADN : nvALT]

As I’ve mentioned (all over the place), I’ve been hacking around with Übersicht for a few days now. It’s been a lot of fun.

Übersicht is GeekTool for even geekier geeks. You edit the widgets manually in CoffeeScript (or JavaScript, if you’re crazy) and Stylus/CSS. Position is determined entirely by CSS, and you need some skill in that area to even start using Übersicht. I’ve gone ahead and built a repository of some of the widgets I’m working on, and there’s a project page up for them with direct downloads.

Some interesting things to note for people interested in hacking away at their desktops:

  • You can load up the interface with all your widgets in your web browser by pointing it to localhost:41416. This is handy if you need more debugging power than the built in debug panel (which you can’t type in). Use $('body').css({background: '#333'}) to make lighter widgets visible.
  • You can build your own version of the server and the wrapping OS X menu bar app from source code. For the true hackers. The server (Node.js) can be run standalone, too.
  • LocalStorage is available, and you can communicate between widgets with it. I’m using this in the LoadChart widget to store load average readings over time (JSON array). I can (I’m not right now) also have the Load widget store its readings in LocalStorage and have the chart widget pick them up without running any commands of its own. There are a lot of possibilities, especially for charting events.
  • CSS3 animations are a blast. They can also be very CPU intensive, especially opacity animations, so watch your step. Note that @keyframe definitions in the root of the stylesheet get borked when its integrated, so they need to be in regular CSS in the render function.
  • All HTML5 elements work, including <audio> and <video>, with full JavaScript control. You can create alarms and other annoyances with simple audio embeds, or create a stunning desktop weather visualization by dynamically loading different videos based on weather API readings.

There’s more, but basically you have all the power of WebKit available. CoffeeScript is fun, Stylus is awesome (hadn’t used it until now), and Übersicht is a rabbit hole for me. As I noted, be careful with CSS3/jQuery animations and refresh rates on CPU-intensive widgets. It’s not hard to crash Übersicht if you try.

Have fun, and check out the project page!

A Spillo bookmarklet

[Tweet : ADN : nvALT]

I’ve spent my free time the last few days playing with Übersicht, but I found enough time to try out Spillo. It’s a new Pinboard client for Mac, and it’s not bad at all.

This isn’t a review, though. This is just a little helper for people who might also be using (or playing with) Spillo.

My first wish was that it had a menubar-only mode. Just an icon in the menu bar and a hotkey to show the window or create a bookmark. You can close the window and use the bookmark creator without activating the app, though, so I let it go.

Then I looked at browser integration and found that they only offered extensions, not bookmarklets. The extensions only launch a prepopulated “Add Bookmark” window from the app. If they offered a popup with search, tagging, etc., within the browser, I’d be fine with it. But for this, I’d rather have a bookmarklet that I can assign to a hotkey and customize as needed.

I dug apart the Safari extension and figured out the URL scheme. Then I just added the ability to use text selected on the page to populate the description, with a fallback to the meta description for the page (the extension’s default).

Here’s the result. If you use Spillo (and you should check it out), I imagine you’ll find it useful.

Just drag the bookmarklet above to your bookmarks bar and go!

Keybindings that everyone should have

[Tweet : ADN : nvALT]

I’m very aware that while many are impressed with my massive keybindings file, 99% of people who check it out shy away from ever implementing it. Even I don’t implement all of it. I thought I’d point out a few of my favorites that you can set up on their own in a more manageable way.

To use any (or all) of these:

  1. Create a blank text file
  2. Add a pair of curly brackets like this:

         // insert your bindings here
  3. Save the file as “~/Library/KeyBindings/DefaultKeyBinding.dict” (unless you already have one!)
  4. Restart apps as needed for the keybindings to load

TextMate-style Command-Return

One of the keybindings that I miss the most when I’m outside of a good code editor is ⌘↩. In most editors (and first in TextMate to the best of my knowledge), hitting this combination will insert a new line after the current paragraph and jump you to it, regardless of where the cursor is in the paragraph.

I also use one with ⌘⇧↩ that will do the same, but above the current paragraph.

// TextMate Command-Return (Command Enter)
"@\U000D" = (moveToEndOfParagraph:, insertNewline:);
// Insert blank line above paragraph (Command Shift Enter)
"@$\U000D" = (moveToBeginningOfParagraph:, moveLeft:, insertNewline:);

Select the current paragraph with Option-s

You can select a paragraph by hitting ⌘←, using the up arrow to get to the beginning, then hitting ⌘⇧→ and using the down arrow to get to the end. That’s horrible.

You can use ^a to jump straight to the beginning of the paragraph instead of the edge of the screen. Then hit ^⇧e to select to the end of the actual paragraph instantly. That’s much better.

If you’re me, though, you want to do that in a single stroke. This keybinding lets you select the current line/paragraph with ⌥s. If you want to make sure you get everything, including the last line break, use ⌥⇧s.

// select entire line/paragraph
"~S" = (moveToBeginningOfParagraph:, moveToEndOfParagraphAndModifySelection:, moveRightAndModifySelection:);
// select from beginning of paragraph to last character
"~s" = (moveToBeginningOfParagraph:, moveToEndOfParagraphAndModifySelection:);

Hyphenate a series of words

If you blog at all, you’re used to creating slugs (hyphenated words). If you do anything with file naming and prefer to keep spaces out of your titles, you’ve probably done this as well. This keystroke (⌘⌥⇧-) lets you add a hyphen between the next two words from the cursor, then advance so that repeated keystrokes continue to hyphenate.

// hyphenate next space and move to next word 
"@~_" = (selectWord:, moveRight:, setMark:, moveWordRight:, moveWordLeft:, moveLeft:, selectWord:, insertText:, "-", moveWordRight:); 

Save your spot in a text file

With two simple commands you can have a pair of keyboard shortcuts that will store the cursor position in your text so you can go and making an edit or check a reference elsewhere in the document, then jump right back to where you were. I bind these to ⌥1 and ⌥2.

// bookmark
"~1" = (setMark:);
// jump to bookmark
"~2" = (swapWithMark:,centerSelectionInVisibleArea:);

Move lines around

This one is especially handy when working with lists in Markdown, but is good for arranging paragraphs or lines of text anywhere. With ^⌘↑ and ^⌘↓ you can move the current line of text above or below whatever precedes or follows it.

Note: this will balk if you try to move into an area with no newline where it’s trying to go. Thus, the last item in a list that’s the last thing on the page is a little problematic. Beyond that minor snag, this is something I use daily.

// move line up
"^@\UF700" = (selectParagraph:, setMark:, deleteToMark:, moveLeft:, moveToBeginningOfParagraph:, yank:, moveLeft:, selectToMark:, moveLeft:);
// move line down
"^@\UF701" = (selectParagraph:, setMark:, deleteToMark:, moveToEndOfParagraph:, moveRight:, setMark:, yank:, moveLeft:, selectToMark:);

You can always use alternate keybindings such as ^⌘j (^@j) and ^⌘k (^@k) with these. In fact, edit all the bindings to match your needs. @ is ⌘, ~ is ⌥, ^ is Control, and $ is ⇧. Knock yourself out!

For more on my keybindings, check the archive!