exceptionz

Thoughts on Technology, Methodology and Programming.

Archive for the ‘OS X’ Category

scrAPI on Snow Leopard

Posted by Marcus Wyatt on 3 November 2009

Today I needed to scrape some data from a website and tried to use the trusted old scrAPI to do the job. Grrrr, its not working. Throwing an error:

Scraper::Reader::HTMLParseError: Scraper::Reader::HTMLParseError: Unable to load /Library/Ruby/Gems/1.8/gems/scrapi-1.2.0/lib/scraper/../tidy/libtidy.dylib

After some time on google I didn’t find any fixes for the issue. So I decided to build from source…

I grabbed the assaf’s github repository.

  • git clone git://github.com/assaf/scrapi.git

Then tried the tests by running

rake test

117 tests, 346 assertions, 0 failures, 44 errors

Nope errors all over the show… Looking at the original exception message, I checked if the libtidy.dylib exist on the lib/tidy directory. Nope, not there….

So where do I get this library file….

MacPorts to the rescue… Install tidy from MacPorts using the following command:

  • sudo port install tidy

Now we need to find where MacPorts installed the files using the following port command:

  • port contents tidy

The result:

Port tidy contains:
/opt/local/bin/tab2space
/opt/local/bin/tidy
/opt/local/include/buffio.h
/opt/local/include/fileio.h
/opt/local/include/platform.h
/opt/local/include/tidy.h
/opt/local/include/tidyenum.h
/opt/local/lib/libtidy-0.99.0.dylib
/opt/local/lib/libtidy.0.dylib
/opt/local/lib/libtidy.a
/opt/local/lib/libtidy.dylib
/opt/local/lib/libtidy.la

Now all we need to do is copy the library file to our scrAPI source directory:

  • cp /opt/local/lib/libtidy.dylib [your source location]/lib/tidy/libtidy.dylib

Ok, before we speed ahead. Lets just run those test to check if all is fine:

117 tests, 474 assertions, 0 failures, 0 errors

Awesome, we are almost there. Next we need to build the gem using the rake:

  • rake package

Make sure you get a ‘Successfully built RubyGem’ message. Now we are ready to install the newly build gem and test scrAPI again.

  • sudo gem install pkg/scrapi-1.2.1.gem

And there you go, scrAPI working again.


Advertisements

Posted in OS X, Ruby, RubyGems | 5 Comments »

Easily create strong passwords

Posted by Marcus Wyatt on 11 July 2008

Create strong passwords on the command line by typing

openssl rand -base64 6

and the output:

=> 050L+4Kx

Run the command again:

=> /sUIIy8s

Cool, now you should be able to create strong passwords quickly.

Posted in OS X, Tips, Ubuntu | Tagged: | Leave a Comment »

TextMate command to annotate your current ActiveRecord Model with the DB Schema

Posted by Marcus Wyatt on 18 March 2008

Edit: If you can’t wait until the end, here is the download link.

Who hasn’t used the Annotate Models plugin written by Dave Thomas, of Rails Pragmatic Studio fame? If you haven’t don’t fret… The plugin basically adds a comment block to the top of all of your model classes documenting the current database schema for the given model. I like to have the info in my model files to make it a little easier to work with models.

Annotated Models Plugin

The rails bundle within TextMate gives you a ‘Show DB Schema for current class’ command you can press to show a tool tip with the database schema (Control + Shift + Command + S). This works great, but I find the command sequence to long and the slight wait to see the schema info breaks my rhythm.

Show DB Schema for Current Class

To solve the problem I made a copy of the source files used by the command and modified it slightly to output the info as comments at the top of the file. Now I have nicely annotated model files. This is a real time saver.

Annotated Models Bundles

The bundle also contain the the Beautify command. This command adds automatic code formatting capability for your ruby code. I found the beautify command from Tim Burks. Cheers Tim…

You can download the bundle here.

Technorati Tags: , , , ,

Blogged from TextMate

Posted in Mac, OS X, Rails, Ruby, Software, TextMate | Leave a Comment »

Ruby, Rails, TextMate, JavaScript, Mac OSX, Subversion

Posted by Marcus Wyatt on 15 February 2008

Ruby

Rails

TextMate

JavaScript

Mac OSX

Subversion

Technorati Tags: , , , , ,

Posted in JavaScript, Mac, OS X, Rails, Ruby, Software, Subversion, TextMate | Leave a Comment »

Ruby, Rails, RSpec, JavaScript, Ubuntu, Mac OS X

Posted by Marcus Wyatt on 12 February 2008

Ruby

Rails

RSpec

JavaScript

Ubuntu

Mac OS X

Technorati Tags: , , , , ,

Powered by ScribeFire.

Posted in BDD, JavaScript, Mac, OS X, Rails, RSpec, Ruby, Ubuntu | 1 Comment »

Ruby, Rails, RSpec, Rails Plugin, JavaScript, OS X

Posted by Marcus Wyatt on 29 January 2008

Ruby

Rails

RSpec

Rails Plugin

JavaScript

OS X

Technorati Tags: , , , , ,

Post created with TextMate.

Posted in JavaScript, OS X, Rails, Rails Plugins, RSpec, Ruby | Leave a Comment »

Ruby, Rails, OS X (Leopard), CSS

Posted by Marcus Wyatt on 14 January 2008

Ruby

  • Hash#tomod – extend your class to except a hash of values in the constructor and then access the values as if they are read accessors on the object. Very enlightening post, I’m sure ActiveRecord::Base implements something.

Rails

OS X (Leopard)

CSS

Technorati Tags:

,

,

,

Powered by ScribeFire.


Posted in CSS, Mac, OS X, Rails, Ruby | Leave a Comment »

Ruby, Rails, Rails Plugins, Mac OS X

Posted by Marcus Wyatt on 23 November 2007

Ruby

Rails

Rails Plugins

Mac OS X

Technorati Tags: , , ,

Powered by ScribeFire.

Posted in Mac, OS X, Rails, Rails Plugins, Ruby | 1 Comment »

Ruby, Rails, Rails Plugins, Mac OS X, JavaScript

Posted by Marcus Wyatt on 13 November 2007

Ruby

Rails

Rails Plugins

  • Lessjsroutes – Have you ever wanted to use named routes in your JavaScript?
  • model_stubbing – create in-memory versions of models for testing.
  • candy – a rails plugin which adds some ruby candy to your app.

Mac OS X

JavaScript

Technorati Tags: , , , ,

Powered by ScribeFire.

Posted in JavaScript, Mac, OS X, Rails, Rails Plugins, Ruby | Leave a Comment »

Ruby, Rails, TextMate, JavaScript, CSS, Web Usability, Mac OS X

Posted by Marcus Wyatt on 8 November 2007

Ruby

Rails

TextMate

JavaScript

CSS

Web Usability

Mac OS X

Technorati Tags: , , , , , ,

Powered by ScribeFire.

Posted in CSS, JavaScript, Mac, OS X, Ruby, TextMate, Web | Leave a Comment »