vegans with typewriters

Quick Image Links With Text Expander

Here is another snippet that leverages TextExpander’s ability to run shell scripts. To use it, select the images you want to link to in Finder or Path Finder, copy, and then trigger your snippet. file = "/img/" + path.split("/").last is in the script because Pathfinder puts the whole path name on the pasteboard rather than just the file name. As always, remember to set the contents of the TextExpander snippet to “Run Shell Script”.

1
2
3
4
5
6
7
8
 #!/usr/bin/env ruby

  pasteboard = `#{"pbpaste"}`.downcase.split("\n")

  pasteboard.each  { |path|
      file = "/img/" + path.split("/").last
      puts "<a href=\"#{file}\" title=\" \"><img src=\"#{file}\" alt=\" \"></a>"
  }

A Ruby script that parses pasteboard information into image links

Automating File Naming With TextExpander

Last weekend I wrote about a workflow for fixing telephone numbers that I came up with that leveraged TextExpander’s ability to run shell scripts. I’ve been thinking about using TextExpander to manipulate the clipboard, and far too late in the evening I came up with another application of that technique. This time, what we’re going to do is use TextExpander and another script to turn titles into file names for blog posts, specifically for Jekyll style blogs (Yes, I know there is a rake command to do this already, but I tend to start typing in a text editor, not in a terminal window).

Fixing Phone Numbers With TextExpander

Welcome back to another post in my “Automating For The Sake of Automating” series. In this post, I’m going to show you how to use TextExpander to fix up the formatting of phone numbers in a text document. What this does is transforms a phone number on the clipboard to a standard format. Here is the code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
 #!/usr/bin/env ruby

  def prettify(aNumber)
      aNumber.insert(1, " ")
      aNumber.insert(2, "(")
      aNumber.insert(6, ")")
      aNumber.insert(7, " ")
      aNumber.insert(11, "-")
      print aNumber.join()
  end

  pasteNumber = `#{"pbpaste"}`.split("")
  numbers = ['1','2','3','4','5','6','7','8','9','0']

  pasteNumber.each do |i|
      if not numbers.include? i
          pasteNumber.delete(i)
      end
  end

  if pasteNumber.length == 11
      prettify(pasteNumber)
  elsif pasteNumber.length == 10
      pasteNumber.insert(0,'1')
      prettify(pasteNumber)
  else
      puts"Not a phone number"
  end

Paste this into a TextExpander snippet set to “Shell Script”, pick your abbreviation, and standardize away.

Web Find - Intro to Responsive Design

Check out Technical Difficulties Episode 63 if you’re interested in learning the fundamentals of responsive web design. Erik does a great job explaining to Gabe and the listeners how HTML and CSS are used to build a web site that looks good on everything from an iPhone screen to a 27 inch iMac. The companion tutorial is clear and easy to understand as well, and has sections of the podcast embedded into it to follow along.

New Terminal at Folder

New Terminal Window At Folder

If you jump back and forth between Finder and Terminal a lot, this may be handy. In OS X Lion Apple included a Service that allows you to open a new Terminal window or tab at for the folder you are looking at in the Finder. To enable this service, open System Preferences → Keyboard, click on the Shortcuts tab, then select Services from the table on the left. Scroll the right hand outline down to Files and Folders and check the appropriate boxes. Now when you’re navigating around in Finder, to jump over to Terminal simply right click on the desired folder and select Open In Terminal from the Services menu.

Time Capsule Apartment Discovered in Paris

From Bello

Back in 2010 a Parisian apartment on the Right Bank, near the Opéra Garnier, left unoccupied since 1942 was discovered.

It was owned by Madame de Florian – a socialite and an actress – who fled to the South of France during the second world war, leaving everything behind. She never came back to Paris but kept on paying her rent until the day she died when she was 91.

If I had the means, I’d move in there in a heartbeat.

Window Resizing Quick Tip

When you’re dragging windows to resize them on your Mac, holding down the option key will resize the widnow symmetrically, i.e. shrink the window from both sides and top if you drag diagonally. If you hold down shift while dragging, the window will resize while maintaining the current aspect ratio. This works in OS X Mavericks and Mountain Lion.

.bash_profile vs .bashrc

This is confused me for a while. Granted, finding the answer wasn’t high on my list of life needs, but I did happen to stumble across this article by Josh Staiger that explains which one you should use for terminal customization and why.

TLDR; Edit .bash_profile on a Mac and .bashrc on Linux.