Archive

Posts Tagged ‘Ruby’

Applescript to change genres in iTunes

May 12th, 2010 No comments

There is this awesome programming language in which the entire system (down to the graphics libraries, window system, and compiler) is available to you to reinvent, opening the possibility of truly open computing.

Obviously, I’m talking about Smalltalk. But if you are too afraid to give MS and Apple the bird for not learning (or wanting to learn?) the computing lessons of the 1970′s, there is another option which lets you bend almost any Mac application to your will, breaking it from the chains of presumptuous software giants who think you should work the way they design instead of vice versa.

I’m speaking, of course, of Ruby, lol. If you’re doing any serious Applescript development, ditch Applescript altogether, and check out the rb-appscript library.  It allows you to do anything you can do in Applescript, in a non-ambiguous way, with the power of a full programming language behind you – trust me, it’s the heaven where Applescript will go when it finally dies.

However, if you’re doing something simple and common, especially in a very scriptable application like iTunes, sometimes it’s easier to just crank up AppleScript Editor and hack out a one-liner.

Thus this very simple script to change the genres of iTunes tracks, which I used to fix things like some tracks in the “rock” genre and others in the “Rock” genre.

tell application "iTunes"
  set tracks_to_fix to file tracks of playlist "Music" of source "Library" whose genre ends with "ock"
  set genre of tracks_to_fix to "Rock"
end tell

Adding Quicklook support for Ruby files with different/no extensions (e.g. rake files)

March 4th, 2010 No comments

1. Download the excellent qlcolorcode bundle from Google Code

2. Add the following line to QLColorCode.qlgenerator/Contents/Info.plist:

<string>public.data</string>
So that it looks like this:
3. In QLColorCode.qlgenerator/Contents/Resources/colorize.sh, add (and customize) the highlighted code, which you can get at github:
4. Oops!  Forgot, you may have to sudo touch /path/to/QLColorCode.qlgenerator for changes to take effect
Categories: Mac, Ruby Tags: , ,

Quicklook any plain-text file e.g. HAML or ERB

March 3rd, 2010 No comments

I’m often jumping from file to file in Rails, so I really wanted Quicklook support for my template files.  Unfortunately, the suggestions I found online were confusing and incomplete.

Here’s a really easy way to get it done – but no syntax highlighting :(

1. Show the contents of TextEdit’s package

2. Open Info.plist in a text editor… like TextEdit, perhaps… hmm…
3. Anyway, add the following snippet (find the code on github):


Put it just before the following section:

4. Customize
  • UTTypeDescription - put in description of your choice (although you probably don’t need to)
  • UTTypeIdentifier – apparently (and this is what was missing from other descriptions), you just make something up here
  • public.filename-extension – add as many extensions as you want to map to this file type
5. Gloat

Categories: Mac, Rails, Uncategorized Tags: , , ,

Reload Rails server to recognize plugins

March 1st, 2010 No comments

I’ve been following the excellent videos at Railscasts.com, but many times (especially after loading plugins or changing my layout files), I wouldn’t get the result from the video. What I found was that I needed to restart the Rails server to have the changes take effect. I remember for sure this happened while implementing the auto_complete text_field functionality.

Categories: Ruby Tags: , ,

Ruby, Vim, and Windows

December 11th, 2009 2 comments

It is unbelievably easy to create a wicked setup, although I spent half a day googling to narrow it down to the exsentials:

Downloads

  1. Ruby with the One-click installer.
  2. Vim’s self-installing Windows executable (this comes with many customizations you read about online, and ruby support, included)
  3. snipMate, a plug-in that automatically expands common Ruby constructs (e.g. you type ‘cla<tab>,’ which becomes class…end with placeholders!)
  4. AutoComplPop (must have!!!), an autocomplete plugin very much like Xcode’s – start typing and a popup list of completion options appears.  superTab, another plug-in that allows you to use tab to auto-complete Ruby code
  5. wombat, a great color scheme

Global configurations

Add the following settings to /path/to/vim/_vimrc.

note: the autocomplete menu colors, and vim’s default font are disgusting, hence the changes.

Ruby-specific Configurations

In the vimrc above, the following is added:

  • the first line sets up superTabs to look in the right place for Ruby completions (I use AutoComplPop now, see above)
  • adds line numbers to several source code file types
  • changes the ridiculous 8-space tabs to 2

That’s it!  Happy coding :)

Categories: Programming, Ruby Tags: , ,

RubyCocoa and Interface Builder

December 4th, 2009 No comments

There isn’t much info out there about compatibility, but here’s the rundown after a few hours of experimentation and research:

  • MacRuby: fully integrated (according to Apple’s docs), so classes, outlets and actions automatically appear in IB
  • RubyCocoa
    • Nibs: there is a utility that adds classes, actions, and outlets to IB
    • Xibs: we’re out of luck, you must add items to IB manually
Categories: Ruby Tags: ,

BDD in the field

December 3rd, 2009 2 comments

I am on fire about Ruby.  I always hated Objective-C’s weirdness (coming from C++), and read the most awesome idea recently – given the amazing power of modern computers (now pay attention, this is the good part): writing code in anything but the highest level, easiest language is… premature optimization!!!  The instant I read that statement (sorry to the author, I can’t remember where), I knew it was true.  Add that you can drop down from Ruby to lower level languages where you need extra speed, and that MacRuby and HotCoca are going to make it ridiculously easy to use Cocoa via Ruby and…

That’s it – I’m hooked.  To get myself up to speed in Ruby and Cocoa, I’m re-writing the examples from Aaron Hillegass’s awesome book Cocoa Programming for Mac OS X.  I’ll be writing about the intricacies of BDD in Ruby using Xcode, and I’ll be posting all the code, as well as custom file and project templates for Xcode.

Add missing Ruby file templates to Xcode

November 16th, 2009 No comments

If your file templates are missing from Xcode (I’m using 3.2.1), run the following commands in terminal, restart Xcode, and they will be there!

sudo mkdir /Library/Application\ Support/Developer/Shared/Xcode/File\ Templates/

sudo mkdir /Library/Application\ Support/Developer/3.0/Xcode/File\ Templates/

svn co http://svn.macosforge.org/repository/ruby/MacRuby/
trunk/misc/xcode-templates/File%20Templates /Library/Application\ Support/Developer/Shared/Xcode/File\ Templates/

sudo cp -r /Library/Application\ Support/Developer/Shared/Xcode/File\ Templates/* /Library/Application\ Support/Developer/3.0/Xcode/File\ Templates/

Categories: Ruby Tags: ,

windows 7 product key

windows 7 product key

windows 7 key generator

windows 7 key generator

free winrar download

free winrar download

winzip activation code

winzip activation code

free winrar

free winrar

winzip free download

winzip free download

winrar free download

winrar free download

winrar download free

winrar download free

winzip free download full version

winzip free download full version

windows 7 activation crack

windows7 activation crack

windows 7 crack

windows 7 crack

free winzip

free winzip
\n