Skip to content

Instantly share code, notes, and snippets.

@poritsky
poritsky / atom.xml
Created January 10, 2012 00:24
Additions to Octopress atom.xml to allow for RSS mapping to external URLs.
{% for post in site.posts limit: 20 %}
<entry>
{% if post.external-url %}
<title type="html"><![CDATA[{{ post.title | cdata_escape }}]]></title><!-- add in a glyph or [link-post] here so people know where they're ending up -->
<link href="{{ post.external-url }}"/>
{% else %}
<title type="html"><![CDATA[{{ post.title | cdata_escape }}]]></title>
<link href="{{ site.url }}{{ post.url }}"/>
{% endif%}
<updated>{{ post.date | date_to_xmlschema }}</updated>
@poritsky
poritsky / article.html
Created January 10, 2012 15:29
Way to add external links to post headers in Octopress.
{% unless page.no_header %}
<header>
{% if index %}
{% if post.external-url %}<!-- Assumes you use 'external-url:' in your YAML. Change to whatever you like as long as they match. -->
<h1 class="entry-title"><a href="{{ post.external-url }}">{% if site.titlecase %}{{ post.title | titlecase }}<!-- Glyph or label that this is a link post goes here -->{% else %}{{ post.title }}{% endif %}</a></h1>
{% else %}
<h1 class="entry-title"><a href="{{ root_url }}{{ post.url }}">{% if site.titlecase %}{{ post.title | titlecase }}{% else %}{{ post.title }}{% endif %}</a></h1>
{% endif %}
{% else %}
{% if page.external-url %}<!-- The above code changes the header on your index pages (list of posts). Now this will change the header on actual post pages so the header will still link out to an external url. -->
@poritsky
poritsky / ext-octopress-te-snippet.applescript
Created October 10, 2012 21:27
Link Post YAML and Quote for Octopress (Safari Only)
on replaceCommasInStringWithHTMLEntity(theTitle)
set rubyCommand to quote & "puts " & "'" & theTitle & "'" & ".gsub( /,/, '&#44;' )" & quote
set strippedTitle to do shell script "ruby -e " & rubyCommand
return strippedTitle
end replaceCommasInStringWithHTMLEntity
on stripUTMFromURL(urlToStrip)
set rubyCommand to quote & "puts " & "'" & urlToStrip & "'" & ".gsub( /\\?utm.*$/, '' )" & quote
set strippedURL to do shell script "ruby -e " & rubyCommand
return strippedURL
@poritsky
poritsky / se-list-to-of.applescript
Created November 13, 2012 01:53
Serious Eats Ingredient Lists to OmniFocus
tell application "Safari" to set ingredientlist to text of front document
set my text item delimiters to "
Ingredients"
set ingredientlist to text item 2 of ingredientlist
set my text item delimiters to "
Procedures"
set ingredientlist to text item 1 of ingredientlist
set l to paragraphs of ingredientlist
@poritsky
poritsky / gist:4067745
Created November 13, 2012 19:11
List of Ingredients to OmniFocus From Recipe Distiller
tell application "Safari" to set recipeurl to URL of front document
set ingredients to (do shell script "curl http://recipedistiller.com/recipe/classify/?recipeurl=" & recipeurl & " | textutil -convert txt -stdin -stdout | grep '.' | sed 's/ • DELETE //g'")
set my text item delimiters to "VIEW RECIPE"
set ingredients to text item 2 of ingredients
set my text item delimiters to "©"
set ingredients to text item 1 of ingredients
set l to paragraphs of ingredients
@poritsky
poritsky / timeexpand.applescript
Created November 14, 2012 16:40
Expand TE Time Snippet in AppleScript
-- I can't take credit for this one. Justin Lancy (@Veritrope) tossed it my way in a tweet.
-- http://twitter.com/Veritrope/status/268746890177282049
tell application "TextExpander"
set my_Snip to snippet "ttime" in group "TextExpander Snippets"
expand snippet my_Snip
end tell
@poritsky
poritsky / mail-to-markdown-for-day-one.applescript
Created November 28, 2012 03:38
Pass Selected Mail Message to Markdown Formatted Text for Day One (Read Comment Below)
(*
Apple Mail to Markdown Formatted Text For Day One Importauto
Adapted from 'Apple Mail -- Text File Exporter w/ Basic Header Info' by Justin Lancy:
http://veritrope.com/code/apple-mail-export-to-text-file-w-basic-header-info
Adapted from the original script by Hans Erik Hazelhorst
http://veritrope.com/code/export-apple-mail-messages-and-notes-to-text-files
*)
@poritsky
poritsky / mail-to-day-one.applescript
Created November 28, 2012 22:00
Create Day One Entry From Selected Message in Apple Mail (Requires Day One CLI)
(*
Apple Mail to Markdown Formatted Day One Entry
!!! IMPORTANT !!!
Requires the Day One Command Line Interface. Download and install from here:
http://dayoneapp.com/tools/
Adapted from 'Apple Mail -- Text File Exporter w/ Basic Header Info' by Justin Lancy:
http://veritrope.com/code/apple-mail-export-to-text-file-w-basic-header-info
@poritsky
poritsky / movie-list-maker.applescript
Created November 29, 2012 16:50
Download Mike D'Angelo's Master List of Films released in NYC for TaskPaper/OmniOutliner/Plain Text
-- Use this AppleScript to Download any of the master lists maintained my Mike D'Angelo:
-- http://www.panix.com/~dangelo/
--
-- Script will only work if you visit one of his list pages in Safari then run it from Script Editor.
-- Will still run on other sites but will output nonsense.
--
-- Saves a .txt that will open in any text editor or OmniOutliner, but won't open directly in TaskPaper.
-- Simply copy and paste the resulting text into a new TaskPaper document if you prefer.
tell application "Safari" to set listurl to URL of front document
@poritsky
poritsky / track-to-text.applescript
Created December 2, 2012 20:01
Current iTunes Track to Text Applescript
# Get current song, album and artist from iTunes.
#
# Intended for use with Smile Software's TextExpander:
# http://www.smilesoftware.com/TextExpander/index.html
#
# Set up as a snippet to turn current track into text. A nice way to spin your wheels while writing/coding/contemplating the shape of the universe.
tell application "iTunes"
set current_song to the name of current track
set current_artist to the artist of current track