about img
blogger img

UnderPaidLoveMonkis posts img

scotts posts image

Scott's Archive

Opensolaris on OS X

Scott Rippee @ 11:17 pm Sunday, July 22nd, 2007

Due to influence from the love moneky I got up and running with Opensolaris on OS X (in parallels) this weekend. I was originally going to install it with VMServer on Gentoo, but realized that it would be much more accessible on my primary unit de computation.

opensolarisinstall.jpgI simply downloaded the 3 Opensolaris files (Nevada release), used cat to concatenate them into a single file, selected Solaris 10 in parallels, selected the image, and it installed without any hang-ups. Ahh yes, and I had to go back and change the memory allocated as it has a 768mb minimum requirement.

My motivation, hack around with zfs (screencasts) and the much talked about DTrace (Video: interview with developers).

Here are some videos with Sun talking about Solaris, zfs, dtrace, and OpenSource: video 1, video 2. I completely agree with the part about the roll of “urban planning” in complex software systems. This seems to hold true for Apple also and is evident in the high quality and user centric software/systems they produce.

DTrace will also be available on OS X Leopard and with a fancy GUI, Xray.

iPhone 1st published hack

Scott Rippee @ 9:54 pm Sunday, July 22nd, 2007

eyes1.png

A team of computer security consultants say they have found a flaw in Apple’s wildly popular iPhone that allows them to take control of the device.

The researchers, working for Independent Security Evaluators, a company that tests its clients’ computer security by hacking it, said that they could take control of iPhones through a WiFi connection or by tricking users into going to a Web site that contains malicious code. The hack, the first reported, allowed them to tap the wealth of personal information the phones contain.

article link
video link

Optimus Prime Stands No Chance

Scott Rippee @ 11:21 pm Tuesday, July 17th, 2007

Just wait til the rocket mount for my boe-bot arrives. bot-bots unite!

git git gitti up

Scott Rippee @ 10:51 pm Tuesday, July 17th, 2007

What does git do right?

The important part of a merge is not how it handles conflicts (which need to be verified by a human anyway if they are at all interesting), but that it should meld the history together right so that you have a new solid base for future merges.

Git breaks the mould because it thinks about content, not files. It doesn’t track renames, it tracks content. And it does so at a whole-tree level. This is a radical departure from most version control systems. It doesn’t bother trying to store per-file histories; it instead stores the history at the tree level. When you perform a diff you are comparing two trees, not two files.

Time for me to take the plunge and give it a spin for my self. Darcs is also on my list to try, but I just need to see git in action first.

BTW Linus Torvalds knows your stupid and hates you.

Also see the video linked to in this post for more info on git

The Tune Glue Graph

Scott Rippee @ 7:20 pm Wednesday, July 11th, 2007

tuneglue-screen.jpg

TuneGlue is a visual mashup of info via last.fm and amazon and is quite entertaining. Now they just need to add audio clips and figure out how to use the UI to teach csci students about graphs. =]

Accessors in Object Orientated Design

Scott Rippee @ 2:30 pm Sunday, July 8th, 2007

Don’t ask for the information you need to do the work; ask the object that has the information to do the work for you.

This article does a good job of verbalizing some of my realizations regarding data flow in OO design. link

Pick Your RoR HTML Parsing Poison

Scott Rippee @ 4:07 pm Thursday, July 5th, 2007

Ruby HTML parsing has been keeping me quite entertained frustrated lately, so I thought I'd share some thoughts. There are a couple of instance in your rails app when you'll want to parse HTML

  1. Automated functional/controller testing
  2. Screen scraping

Functional Testing

The standard method of verifying aspects of resulting HTML in your functional test is HTML::Selector. It's simple, powerful, and baked in. Agile Rails 2nd does a great job of explaining how it's used in functional tests.

RUBY:
  1. def test_add_no_name
  2.   post :add, :color => { :name => '', :hex => '#123456' }
  3.   assert_template 'add'
  4.   assert_select "div[id=errorExplanation]" do
  5.     assert_select "ul" do
  6.       assert_select "li", 'Name is not present'
  7.     end
  8.   end
  9. end

 

Scraping

Several options are available, but oh so popular is why's Hpricot. It's fast and enjoyable (although I experienced no joy while learning how to use it =) It also happens to be used in some of the other scraping/navigating libraries (WWW::Mechanize [rdoc] and scRUBYt!).

 

Some Thoughts...

So if your just concerned with testing use HTML::Selector and the built in asserts. If you have to do very basic screen scraping I would also suggest going with HTML::Selector (as long as speed is not an issue and the scraping is basic) with open-uri or curb for fetching the pages.

For more serious screen scraping bust out Hpricot and if you need to navigate pages via automation use WWW::Mechanize (Mechanize also uses Hpricot so all of that Hpricot knowledge you've absorbed is directly applicable. Mechanize is Hpricot with the ability to click). Don't worry about scRUBYt!. It's more of a pain to figure out than it's worth (but maybe I'm wrong about it. Any good examples/write-ups?).

Hpricot with CSS selector

RUBY:
  1. divs = (doc/"div[@style*='font-weight:'][text()*='$'").inner_html
  2. divs.each do |div|
  3.   if div =~ /\$[0-9]?[0-9]\.[0-9][0-9]/
  4.     self.price = div.to_s.sub('$', '')
  5.   end
  6. end

Hpricot search with XPath

RUBY:
  1. require 'hpricot'
  2. require 'open-uri'
  3. doc = Hpricot(URI.parse("http://google.com/").read)
  4.  
  5. doc.search("/html/body//p")
  6. doc.search("//p")
  7. doc.search("//p/a")
  8. doc.search("//a[@src]")
  9. doc.search("//a[@src='google.com']")

Using Mechanize to do a search on google

RUBY:
  1. require 'rubygems'
  2. require 'mechanize'
  3.  
  4. agent = WWW::Mechanize.new
  5. agent.user_agent_alias = 'Mac Safari'
  6. page = agent.get("http://www.google.com/")
  7. search_form = page.forms.with.name("f").first
  8. search_form.q = "Hello"
  9. search_results = agent.submit(search_form)
  10. puts search_results.body

Note that Hpricot lets you use a CSS method of selecting and an XPATH method. Use XPATH if you already have experience otherwise the CSS method is more intuitive.

If you go with XPATH grab the XPather firefox plugin and use it with the DOM Inspector. Also, it works with the firebug firefox plugin. I'm still in awe that it worked when I tried. :) To do this, use firebug to "inspect", choose an element, right click on the page and select "Show in XPather". XPather will open with the selected element locked and loaded.

Finally, if your a Hpricot wiz forget about HTML::Selector and put Hpricot to work for view validation in your functional tests. See this great write up, Testing your Rails views with Hpricot, which demonstrates this elegant solution.

RUBY:
  1. assert_equal "My Funky Website", tag('title')
  2. assert_equal 20, tags('div.boxout').size
  3. assert_equal 'visible', element('div#site_container').attributes['class']

 

Prod, Plugin, Eat

Scott Rippee @ 12:32 am Thursday, July 5th, 2007

In the case that your bored, hungry, and have a death wish give Cooking a hot dog via electrocution a try with a bonus light show. :)

714284014_f02cddb1ec.jpg
713401829_627b3890d5.jpg

Credit Card Fraud = I Lose (Blizzard, Bank of America)

Scott Rippee @ 5:21 pm Sunday, June 17th, 2007

I really sucks that someone can obtain my credit card (bank ATM card) information, use it to charge 300 dollars to blizzard entertainment, and Bank of America can launch a full investigation only to determine that I am responsible for these "authorized" charges that someone else made and I have to pay.

BoA, this is not over

Quality Fast Cheap VPS Hosting

Scott Rippee @ 10:19 pm Sunday, June 10th, 2007

I've been using for ruby on rails hosting/development and subversion hosting for over 6 months now (before they had a waiting list).

Quad processor machines, RAID1 drives, Tier-1 bandwidth and root access. Managed with a customized Xen VPS backend to ensure that your resources are protected and guaranteed.

What makes them so popular they have this wait that they continue to battle with?

Obviously the speed, but also:

  • Scalability - bring up as many new slices as needed instantly (well a few minutes for the drive to be imaged) or add more storage space to an existing slice
  • Distro choice (gentoo, ubuntu, debian, centos, fedora)
  • Full root access
  • Live backups on a daily and weekly schedule of the running instance of your slice
  • Take snapshots at any time of a running instance (very nice for after you get a slice configured)
  • Uhhh speed again (they do not and will not overbook their resources)
  • Price (you can't beat 20 bucks a month for VPS)

If your not up to par with Linux administration I wouldn't recommend this as you'll need to get your box up and running from scratch.

They've also just added DNS management to their custom rails admin section, so I can cancel my EveryDNS account. Which provided excellent DNS service by the way and for free!

Mac OS X Virtual Desktops

Scott Rippee @ 11:19 pm Sunday, June 3rd, 2007

OS X has pretty good app/window management. You can do fancy stuff like have it layout all open windows across the screen, have all windows moved to the edges for a view of the desktop, minimize windows with a keystroke, and open new and restore minimized apps if your using quicksilver.

However, After 6 years of working in the virtual desktop paradigm it's something I've been missing on my Mac. Fortunately there are two solutions currently available that add virtual desktop functionality to OS X, Desktop Manager and Space.app

spacesapp.pngSpace.app is functional. It adds a pager that sits on the desktop as an app and allows you to setup shortcut keys to switch between desktops.

 

Desktop Manager, however, is what you want. It brings cool visual desktop switch transitions, key bindings, a desktop pager, a pager that sits in the File, Edit bar (Linux like), mouse to screen edge desktop changing, and options to control mouse locations after a switch.

You could check out these screencast blips, or even quicker download and install and see the cool transitions for your self.

Slide, cube, reveal, and swap over are my favorites.

Also, looks like this is going to be a future feature in OS X

RoR Reserved Words

Scott Rippee @ 9:13 pm Wednesday, May 30th, 2007

The errors that occur when you use a reserved word tend to be very confusing. Things that you think are happening in your code, are actually happening somewhere in the framework. Sometimes you can look at the stack trace and see that its not going through your class, but through some framework class. If you have an error that makes no sense at all, I would check to make sure you don’t have a name that conflicts with the above list.

It would be nice to go back in time and tell myself to read this a few days pre now.

Rails app in a single executalbe??

Scott Rippee @ 7:45 pm Monday, May 28th, 2007

moab Petroglyph src wikipedia
This is quite impressive. It documents how to wrap up a whole rails app into one executalbe.

Driving this magic is RubyScript2Exe, which packages ruby scripts into executables for linux, mac, or windows. I'm sure I'll have a use for this one.

 

ruby-debug - =]

Scott Rippee @ 5:49 pm Monday, May 28th, 2007

cc by Designerdruby-debug = cool + very useful. Many have said it before and I have blissfully ignored until in a sticky situation that helped me realize I need to be able to poke and prod a little more than spitting out to the log in rails. After all poke and prod is my favorite way to learn.

It's has a simple feel, yet is powerful letting you drop into a debug shell where you can set breakpoint, move through the stack, step around, and examine variables. I was pretty hesitant about learning ruby-debug as I had thoughts of gdb in my head. I have a dislike/fright of gdb and continue to gimp around with it despite a lot of use. ruby-degub, however, is no foe.

No need to cover installing or usage here, as these fine people have created useful docs and even a screencast...

Install and use with RAILS

Common usage

Watch

Data Noise - Developers blog

The Search

Scott Rippee @ 11:00 pm Saturday, May 26th, 2007

is a great read (lie... I listened).

It's strange that a Google book search for "The Search" doesn't return the book anywhere in the top results. It seems that they give book title keywords a low priority. It seems they also overlook popularity as you pages upon pages of obscure results, when Amazon pulls it up numero uno.