<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: textmate code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Fri, 08 Aug 2008 17:01:37 GMT</pubDate>
    <description>DZone Snippets: textmate code</description>
    <item>
      <title>Dr Nic's textmate folder pattern</title>
      <link>http://snippets.dzone.com/posts/show/5888</link>
      <description>Pattern go in the "TextMate/Preferences/Advanced/Folder References/Folder Pattern" text box&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;!.*/(\.[^/]*|vendor/rails|doc|rails_root|CVS|log|data_dump|build|_darcs|pkg |_MTN|\{arch\}|blib|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)? |bundle))$&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;</description>
      <pubDate>Fri, 08 Aug 2008 02:06:21 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5888</guid>
      <author>caffo ()</author>
    </item>
    <item>
      <title>TextMate - Convert Tabs to 2 Spaces and Strip Whitespace</title>
      <link>http://snippets.dzone.com/posts/show/5516</link>
      <description>Command for TextMate (or any other editor really) to strip whitespace and convert tabs...&lt;br /&gt;I only ever use 2 spaces so i've gone with that.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#!/usr/bin/env ruby&lt;br /&gt;&lt;br /&gt;STDIN.read.each do |line|&lt;br /&gt;  line.sub!(/^(\t+)/) { |c| '  ' * c.length }&lt;br /&gt;  line.sub!(/(\s+)$/, "\n")&lt;br /&gt;  puts line&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Mon, 19 May 2008 02:42:51 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5516</guid>
      <author>adamsalter (Adam Salter)</author>
    </item>
    <item>
      <title>Single-Line commenting in Actionscript with Textmate</title>
      <link>http://snippets.dzone.com/posts/show/5170</link>
      <description>- open the bundle editor and select the Actionscript bundle&lt;br /&gt;- use the add button to make a new preference item, give it a scope of source.actionscript&lt;br /&gt;- name it whatever&lt;br /&gt;- paste in the following:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;{   shellVariables = (&lt;br /&gt;        {   name = 'TM_COMMENT_START';&lt;br /&gt;            value = '// ';&lt;br /&gt;        },&lt;br /&gt;    );&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;- that's it! got these instructions on IRC from Infininight: http://pastie.textmate.org/private/clmfldbv2sexjcd7u6qjw</description>
      <pubDate>Sun, 24 Feb 2008 22:49:14 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5170</guid>
      <author>sikelianos (Zeke Sikelianos)</author>
    </item>
    <item>
      <title>TextMate snippet for load_model methods in Rails controllers</title>
      <link>http://snippets.dzone.com/posts/show/4952</link>
      <description>With nested routes, I find I create a lot of controller methods like:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;def load_user&lt;br /&gt;  @user = User.find(params[:user_id]) if params[:user_id]&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Here's a TextMate snippet, so you can just type: defmodel, TAB, user, TAB, and you're done.&lt;br /&gt;&lt;br /&gt;Snippet:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;def load_${1:model}&lt;br /&gt;	@$1 = ${1/[[:alpha:]]+|(_)/(?1::\u$0)/g}.find(params[${2::$1_}id])${3: if params[:$1_id]}&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Activation: defmodel&lt;br /&gt;Scope: source.ruby.rails &lt;br /&gt;&lt;br /&gt;I have this in the Ruby on Rails bundle, but you can put it anywhere. Its the scope that is important.</description>
      <pubDate>Mon, 07 Jan 2008 00:26:45 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4952</guid>
      <author>nicwilliams (Dr Nic Williams)</author>
    </item>
    <item>
      <title>Git-diff last two commits through TextMate</title>
      <link>http://snippets.dzone.com/posts/show/4866</link>
      <description>I believe this is how svn diff operates... but anyway, this alias will allow you to diff the last two commits in Git through TextMate. If you have a theme that supports Diff's then you'll see the differences clearly. Remove the last pipe statement (the mate part) to expose your diff in the console.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;alias gitdiff='git log|grep commit|cut -d " " -f2|head -n 2|xargs -n 2 git diff -R|mate'&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sun, 09 Dec 2007 04:52:30 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4866</guid>
      <author>justinwr (Justin R)</author>
    </item>
    <item>
      <title>Auto-populate socket value in rails database.yml using TextMate snippet</title>
      <link>http://snippets.dzone.com/posts/show/4302</link>
      <description>&lt;br /&gt;When using mysql for rails apps, you may need a &lt;code&gt;socket:&lt;/code&gt; value. I can never remember mine. So I added a TextMate snippet to find it. (read below for non-TextMate)&lt;br /&gt;&lt;br /&gt;Snippet text:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;socket: `mysql_config --socket`&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Activation: &lt;code&gt;socket:&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Scope selector: &lt;code&gt;source.yaml - string&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Usage:&lt;/h2&gt;&lt;br /&gt;&lt;br /&gt;In your database.yml, go to the line &lt;code&gt;socket: &lt;/code&gt;, delete any blank spaces til the cursor is at the colon, then press TAB and wait. The line will be updated with the socket location.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Non-TextMate&lt;/h3&gt;&lt;br /&gt;&lt;br /&gt;If you don't have textmate, you can get your socket location using:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;mysql_config --socket&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;And paste the result into your database.yml&lt;br /&gt;</description>
      <pubDate>Mon, 16 Jul 2007 07:30:51 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4302</guid>
      <author>nicwilliams (Dr Nic Williams)</author>
    </item>
    <item>
      <title>Obfuscate email addresses in TextMate</title>
      <link>http://snippets.dzone.com/posts/show/3918</link>
      <description>// Textmate / e command for obfuscating email addresses&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#!/usr/bin/env ruby&lt;br /&gt;&lt;br /&gt;email = STDIN.read&lt;br /&gt;url_email = email.gsub(/./) { |c| '%' + c.unpack('H2' * c.size).join('%').upcase }&lt;br /&gt;html_email = url_email[1..-1].split(/%/).collect { |c| sprintf("&amp;#%03d;", c.to_i(16)) }.join&lt;br /&gt;&lt;br /&gt;print "&lt;a href=\"mailto:#{url_email}\"&gt;#{html_email}&lt;/a&gt;"&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Fri, 27 Apr 2007 01:24:07 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3918</guid>
      <author>fauxparse (Matt Powell)</author>
    </item>
    <item>
      <title>Exclude vendor/rails from Textmate projects</title>
      <link>http://snippets.dzone.com/posts/show/2419</link>
      <description>If you have a rails project you load up in textmate, and you have some version of Rails in vendor/rails, you probably know that doing a 'find in project' takes a lot longer because it scans all the rails source files.  You also get a lot more crap to wade thru when doing a go-to type (command t).  To exclude vendor rails, click on the project root in the drawer, click on the "i" icon, and change the folder pattern to this:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;!.*/(\.[^/]*|CVS|vendor/rails|_darcs|\{arch\}|blib|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)?|bundle))$$&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Note the addition of "vendor/rails" to the regex.  You can also add this to preferences -&gt; advanced to make it the default for new text mate projects.</description>
      <pubDate>Mon, 14 Aug 2006 22:56:57 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2419</guid>
      <author>rsanheim (Rob Sanheim)</author>
    </item>
    <item>
      <title>Open current Finder window folder in TextMate</title>
      <link>http://snippets.dzone.com/posts/show/1037</link>
      <description>// Opens the current Finder window folder in TextMate. Or open a file or folder in TextMate by dragging it onto this script.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;-- Opens the current finder window folder in TextMate. Or open a file or folder in TextMate by dragging it onto this script.&lt;br /&gt;-- adopted from a script I found in the comments of this article: http://www.macosxhints.com/article.php?story=20050924210643297&lt;br /&gt;&lt;br /&gt;-- Instructions for use:&lt;br /&gt;-- paste this script into Script Editor and save as an application to ~/Library/Scripts/Applications/Finder/open in TextMate&lt;br /&gt;-- run via the AppleScript Menu item (http://www.apple.com/applescript/scriptmenu/)&lt;br /&gt;-- Or better yet, Control-click and drag it to the top of a finder window so it appears in every finder window.&lt;br /&gt;-- Activate it by clicking on it or dragging a file or folder onto it.&lt;br /&gt;&lt;br /&gt;-- Another nice touch is to give the saved script the same icon as TextMate.&lt;br /&gt;-- To do this, in the finder, Get info (Command-I) of both TextMate and this saved script.&lt;br /&gt;-- Click the TextMate icon (it will highlight blue) and copy it by pressing Comand-C.&lt;br /&gt;-- Click on this script's icon and paste by pressing Command-V.&lt;br /&gt;&lt;br /&gt;-- Another way to give it the same icon as TextMate is to save the script as an application bundle (instead of an application),&lt;br /&gt;--  then copy the icon by entering these commands in Terminal:&lt;br /&gt;-- $ cd ~/Library/Scripts/Applications/Finder/open\ in\ TextMate.app/Contents/Resources/&lt;br /&gt;-- $ rm droplet.icns&lt;br /&gt;-- $ cp /Applications/TextMate.app/Contents/Resources/TextMate.icns droplet.icns&lt;br /&gt;-- $ touch ~/Library/Scripts/Applications/Finder/open\ in\ TextMate.app&lt;br /&gt;&lt;br /&gt;-- script was opened by click in toolbar&lt;br /&gt;on run&lt;br /&gt;	tell application "Finder"&lt;br /&gt;		try&lt;br /&gt;			set currFolder to (folder of the front window as string)&lt;br /&gt;		on error&lt;br /&gt;			display dialog "Error: " &amp; the error_number &amp; ". " &amp; the error_message buttons {"OK"} default button 1&lt;br /&gt;		end try&lt;br /&gt;	end tell&lt;br /&gt;	CD_to(currFolder, false)&lt;br /&gt;end run&lt;br /&gt;&lt;br /&gt;-- script run by draging file/folder to icon&lt;br /&gt;on open (theList)&lt;br /&gt;	CD_to(theList, false)&lt;br /&gt;end open&lt;br /&gt;&lt;br /&gt;-- open the file/folder in TextMate&lt;br /&gt;on CD_to(theDir, newWindow)&lt;br /&gt;	try&lt;br /&gt;		set theDir to quoted form of POSIX path of theDir as string&lt;br /&gt;		do shell script "open -a TextMate " &amp; theDir&lt;br /&gt;	on error the error_message number the error_number&lt;br /&gt;		display dialog "Error: " &amp; the error_number &amp; ". " &amp; the error_message buttons {"OK"} default button 1&lt;br /&gt;	end try&lt;br /&gt;end CD_to&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 29 Dec 2005 17:10:24 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1037</guid>
      <author>SimonDorfman (Simon Dorfman)</author>
    </item>
    <item>
      <title>I &amp;lt;3 TextMate and Quicksilver</title>
      <link>http://snippets.dzone.com/posts/show/567</link>
      <description>(in quicksilver)&lt;br /&gt;&lt;br /&gt;&lt;code&gt;.tm ~/path/to/project &amp;&amp; logout &lt;TAB&gt; term&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Executes in terminal, opens the folder or file with textmate, and closes.</description>
      <pubDate>Mon, 08 Aug 2005 09:04:11 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/567</guid>
      <author>technoweenie (Rick Olson)</author>
    </item>
  </channel>
</rss>
