Category: computer

  • Ruby Troubleshooting: Hpricot On OS X Leopard

    If you upgraded to Leopard, you may be getting this nasty error when trying to install Hpricot, which is required by other popular gems such as mechanize..

    preston$ sudo gem install mechanize
    Password: ********

    Bulk updating Gem source index for: http://gems.rubyforge.org
    Install required dependency hpricot? [Yn]
    Select which gem to install for your platform (i686-darwin8.10.3)
    1. hpricot 0.6 (mswin32)
    2. hpricot 0.6 (jruby)
    3. hpricot 0.6 (ruby)
    4. hpricot 0.5 (ruby)
    5. hpricot 0.5 (mswin32)
    6. Skip this gem
    7. Cancel installation
    > 3
    Building native extensions. This could take a while…
    ERROR: While executing gem … (Gem::Installer::ExtensionBuildError)
    ERROR: Failed to build gem native extension.

    ruby extconf.rb install mechanize
    checking for main() in -lc… no
    creating Makefile

    make
    gcc -I. -I. -I/opt/local/lib/ruby/1.8/i686-darwin8.10.3 -I. -I/opt/local/include -fno-common -O2 -fno-common -pipe -fno-common -c hpricot_scan.c
    cc -dynamic -bundle -undefined suppress -flat_namespace -L/opt/local/lib -L”/opt/local/lib” -o hpricot_scan.bundle hpricot_scan.o -lruby -lpthread -ldl -lobjc
    /usr/bin/ld: /usr/lib/gcc/i686-apple-darwin8/4.0.1/../../../libpthread.dylib unknown flags (type) of section 6 (__TEXT,__dof_plockstat) in load command 0
    /usr/bin/ld: /usr/lib/gcc/i686-apple-darwin8/4.0.1/../../../libdl.dylib unknown flags (type) of section 6 (__TEXT,__dof_plockstat) in load command 0
    /usr/bin/ld: /usr/lib/gcc/i686-apple-darwin8/4.0.1/../../../libobjc.dylib load command 9 unknown cmd field
    /usr/bin/ld: /usr/lib/gcc/i686-apple-darwin8/4.0.1/../../../libSystem.dylib unknown flags (type) of section 6 (__TEXT,__dof_plockstat) in load command 0
    /usr/bin/ld: /usr/lib/libSystem.B.dylib unknown flags (type) of section 6 (__TEXT,__dof_plockstat) in load command 0
    collect2: ld returned 1 exit status
    make: *** [hpricot_scan.bundle] Error 1

    Gem files will remain installed in /opt/local/lib/ruby/gems/1.8/gems/hpricot-0.6 for inspection.
    Results logged to /opt/local/lib/ruby/gems/1.8/gems/hpricot-0.6/ext/hpricot_scan/gem_make.out

    The issue is that Xcode 3 must be upgraded as well; Hpricot’s native components cannot be built with the older Tiger development tools on Leopard. After installing Xcode 3 from either your Leopard DVD or Apple Developer Connection, run the install again…

    preston$ sudo gem install mechanize

    Install required dependency hpricot? [Yn] Y
    Select which gem to install for your platform (i686-darwin8.10.3)
    1. hpricot 0.6 (mswin32)
    2. hpricot 0.6 (jruby)
    3. hpricot 0.6 (ruby)
    4. hpricot 0.5 (ruby)
    5. hpricot 0.5 (mswin32)
    6. Skip this gem
    7. Cancel installation
    > 3
    Building native extensions. This could take a while…
    Successfully installed mechanize-0.6.11
    Successfully installed hpricot-0.6
    Installing ri documentation for mechanize-0.6.11…
    Installing ri documentation for hpricot-0.6…
    Installing RDoc documentation for mechanize-0.6.11…
    Installing RDoc documentation for hpricot-0.6…

    Success!

  • Rails 2.0: Validations Without Extending ActiveRecord::Base

    In more “enterprisey” web stacks (such as Java with Hibernate and Spring MVC), it’s straightforward to design a validatable form whose contents do not correspond directly — if at all — to a persistent OR/M class: such as may happen in an ecommerce site where you’re collecting payment information but can only store some of it in the database for legal reasons. Just create a MVC-level view object using your framework-specific validation mechanism, and translate to/from the relevant OR/M classes as necessary in the controller.

    This scenario isn’t always straightforward to handle in Rails since the stack layers are smooshed together. In Rails 1.2.x, you could use (some) validations in your non-persistent PORO objects by extending ActiveRecord::Base and overriding the initializer to skip the databases-related stuff. Alas, this hack does not seem to work in Rails 2.0, but I have a solution which, in my brief testing, seems to work better than the aforementioned Rails 1.2 hack.

    Here’s how I used ActiveRecord::Validations in one of my view-only classes in a Rails 2.0.2 application without needing a dummy table in the database or ActiveRecord::Base.


    require 'active_record/validations'

    class Card

    # Define your arbitrary PORO attributes.
    attr_accessor :number
    attr_accessor :expiration_month
    attr_accessor :expiration_year
    attr_accessor :verification_value

    # For the ActiveRecord::Errors object.
    attr_accessor :errors

    def initialize(opts = {})

    # Create an Errors object, which is required by validations and to use some view methods.
    @errors = ActiveRecord::Errors.new(self)

    end

    # Dummy stub to make validtions happy.
    def save
    end

    # Dummy stub to make validtions happy.
    def save!
    end

    # Dummy stub to make validtions happy.
    def new_record?

    false

    end

    # Dummy stub to make validtions happy.
    def update_attribute
    end

    # Mix in that validation goodness!
    include ActiveRecord::Validations

    # Use validations.
    validates_presence_of :number
    validates_presence_of :expiration_month
    validates_presence_of :expiration_year
    validates_presence_of :verification_value

    end

  • Rails 2.0: HTTP Basic Authentication

    lock.pngHTTP Basic authentication support comes bundled with Rails 2.0, alleviating the need for external plugins we used with Rails 1.x. Here’s how you can use (and test) this new Rails 2.0 feature. (more…)

  • Mass Effect: Holy Freaking Crap

    picture-7.pngI figured I’d have some “me” time this weekend, so I picked up a copy of the highly praised Mass Effect. Saying it’s good is obvious; awesome is an understatement. Groin-grabbingly enthralling, genre-shattering entertainment is somewhere in the neighborhood. We’re talking a contender for best video game ever here. So if you’re last minute Christmas shopping for a 360 owner (possibly yourself), I can’t recommend Mass Effect highly enough.

    The gameplay itself is difficult to describe. Take the fun parts of leveling, storyline, voice acting and small squad combat RPG elements from Baldur’s Gate, the pace, feel and vehicle action of a FPS squad combat shooter, and drop that into an incredibly rich sci-fi backdrop of a Star Trek episode. Awesome sauce!

  • Rails 2.0: Testing For Well-Formed XML With assert_well_formed

    Here’s an easy way to validate that you’re always rendering well-formed HTML in an ordinary Rails application. I’ve written and verified this on Rails 2.0.1…

    (more…)

  • Xserve w/Leopard Server (Mac OS X 10.5), First Impressions

    picture-4.pngWe just picked up a refurbished 2.66GHz quad-core Xeon from Apple, which we’ll be using for internal infrastructure. (We’re in the process of migrating from a mix of Solaris and Linux). After about 8 hours of learning the ins and outs of Leopard Server over the weekend, we had the box running Open Directory (Kerberos and OpenLDAP), DNS, AFP, SMB, FTP, domain account and machine management, mobile home directories, MySQL, Software Update, Xgrid controller, Wikis, Blogs, iCal and VPN services, all tightly integrated with single sign-on (via Kerberos) into a sexy 1U package.

    • Xserve (refurbished discount, direct from Apple): ~$3K
    • 3 x 750GB Disks (Newegg): ~$450
    • 2 x Apple Drive Module (direct from Apple): ~$380
    • 2 x 2GB FB-DIMM RAM (Crucial): ~$300
    • Infrastructural sanity: priceless. (…or ~$4.5K after tax and random small stuff)

    That’s some serious value considering how much of a PITA setting all this up can be in Linux (or whatever) without vendor support, and far cheaper than paying a Systems Administrator in the long run. The Server Admin and Workgroup Manager tools are pretty freakin’ usable, too, relative to the internal complexity of the system. I’m a happy camper for now… let’s see if it lasts.

  • Invited To The Pentagon

    tides.png
    Mugr.com was recently invited to the Pentagon to demo our facial recognition voodoo as a potential biometric component to TIDES: Transportable Infrastructures for Development and Emergency Support. It was a very last minute trip with very little instruction and direction regarding what to prepare, so we packed up our Mactops and hopped on a plane.

    The subway ride at 5-something AM local time (3AM at home) after an all-nighter came cold and early, and shuttled a variety of more well-rested military types, who periodically would share a silent glance as if to say “OMG U N00B.” (Yes, in all capital letters with no exclamation point.) The guest check-in process was straightforward, and we soon found ourselves inside a small tent-like shelter booting our Macs if for no other reason than to warm our hands.

    The event itself brought in a diverse mix of (mostly) military, many of whom were happy to engage in our biometrics demo and subsequent discussion. I had many wonderful conversations with Dr. John Francis of the U.N. and many DoD personnel over at least a half pot of coffee. A fabulous experience, this goes to show how huge opportunities can spring up whenever, wherever.

    Would you risk your time, reputation and money for the opportunity? I know I’m game.

  • What's Better Than Windows Balloon Help?…

    Twice as much balloon help!

    picture-3.png

    My current testing environment for JumpBox development uses two Windows XP virtual machines on OS X under Parallels coherence mode: one with IE6 (gold taskbar on the bottom), the other IE7 (blue taskbar on the right). While they perform sufficiently with 4GB physical RAM, the constant nurturing required to keep these retards up to date and complaint free is ridiculous, given I only boot them once every couple weeks. Dyslexia also arises when each instance periodically “forgets” I’m using a Dvorak layout and reverts to QWERTY, even when sitting idle.

    picture-1x.png

    It’s the little things that drive one nuts. Office 2004 for OS X, for example, sets the bar really low for usability, quality and elegance. Full-screen mode?

    full_screen.png

    ..I guess not. And I won’t be inserting any cells into this table, either…

    insert_cells.png

    Given a choice between A and A, I think I’ll choose A.

    spell_check.png

    Waaaaay too much of this stupidity plagues Office. Not that Microsoft has much motivation to fix it, but it’s still sad to see such crappy software in wide-spread use.

    preston.rant_mode = false

  • Switching To Dvorak: One Week Later

    dvorak.pngIt’s been exactly one week since I switched to the Dvorak Simplified Keyboard (DSK) layout. Thoughts…

    • The first couple days are especially frustrating while you memorize key locations and build a small bit of muscle memory for common phrases. Hang in there.. this is the toughest part.
    • Temporarily relabel your real keyboard with cheap stickers from eBay or physically rearrange the keys on a cheapo USB keyboard while you’re learning. Physically mod’ing a QWERTY board kinda sucks, though, because..
      • The nubs for the pointer finger keys are in the wrong place. This alone is a deal breaker.
      • Keys aren’t necessarily manufactured to be of homogeneous shape. Even on my cheapo Memorex, for example, the key tops are sloped differently by row, so rearranging the keys results in what feels like a 3D topology of the Rocky Mountains.
    • The common typos (“teh”, “taht”, “nad” etc.) are different, so..
      • You’ll have to be more accurate in IM conversations. People won’t be able to guess what you meant to type.
      • Spell-checkers won’t work as well.
    • Make every reasonable attempt to avoid using QWERTY while you’re learning.
    • Be prepared to explain to people WTF you just did to their computer when you use it.. Every. Freakin’. Time.
    • Looking for an ergonomic, Dvorak Mac keyboard? LOLL3RSKATES!!! Good luck with that, and let me know if you think your new $300+ Kinesis is worth it.
  • Switching To Dvorak

    dvorak.png
    After years of deliberation, I’m finally taking this Thanksgiving break to switch to the Dvorak keyboard layout. It’s been frustrating, yes, but I believe my wrists will be much better off with the change. Within a couple hours of switching I’m probably crawling at ~15 words per minute, which is faster than I expected. Stuff that still throws me off due to being permanently etched in muscle memory..

    • My name.
    • `cd` and my custom `ls` aliases.
    • OpenRain.
    • . (period)
    • Common commands such as cut/copy/paste, closing and opening files etc.
    • The letter ‘o’ for some reason.

    Ohh, and I switched my command and caps lock keys too, so my brain is a tad bit overloaded at the moment 🙂