Home dakrauth.com

Tag: Technical


Feb 20 2008

Python

Posted in Funny, Python, Technical § 0 Comments

From xkcd

Python

Nov 4 2007

Mac Ingenuity

Posted in Mac, Technical § 0 Comments

This may sound like a plug for the Apple "Switch" campaign. If so, I make no apologies.

So, I'm just a bit tardy on the Leopard upgrade, but do have the excuse of a huge push at work during the past week to deliver our first product alpha. Finally, this weekend, I got a chance on Saturday to diligently backup my PPC G5 in preparation for the Leopard upgrade.

I started off Sunday morning ready and eager to install and explore Leopard. After grabbing a cup of joe, I inserted the Leopard install DVD... and nothing. The drive mulled things over for 45-60 seconds then spit out the disk in disgust.

Huh?

Ok, Let's try another DVD to make sure I don't have a bad disc... crap, same thing. Just for kicks I try a CD? That one works just fine, thank you very much.

WTF? I retry all said media in my newer MacBook Pro machine and an older G4 PowerBook. All media works just honkey dory.

So now what? I really want to get Leopard installed today and am not looking to be deterred. I consider driving to our storage facility to ferret out an old external DVD drive which I haven't needed in a couple years. But then I think, "Come on, we're dealing with Macs here, not PC's running Windows". There must be something a bit more creative that can be done, and besides, I'm feeling just too lazy to drive.

The thought of purloining a DVD-ROM drive from another machine briefly crosses my mind at this point, but that solution is as undesirable as rummaging around in the storage unit, and just plain feels so 10-years-ago.

Well, let's see here. I recall being able to hook two Macs together via Firewire to transfer data when upgrading hardware. I have an old G4 Mac mini that's been getting a free ride as of late and it has a DVD drive in it. Perhaps I can get some worthwhile use out of it.

I hook up the Mini's power, a keyboard, and a Firewire connection to the G5 and boot the Mini holding the T on the keyboard attached to it.

Shortly, the firewire external drive icon appears on the G5 desktop. So far, so good - I'm feeling like this might have a chance.

I feed the Mini the Leopard install DVD and... welcome to the installer. The DVD is mounted and the initial installer screen is inviting me to install by clicking the Reboot button. Yes, please, time to see if we can actually boot from the media in the Mini's drive connected via Firewire.

But you know what to expect next, right? Your first clue is, as mentioned already, that we're dealing with Macs here.

VoilĂ , the Leopard installer has booted and is asking me for my language preference.

A load of laundry later and installation is complete. So while I'm a bit miffed that the DVD component of the G5's SuperDrive is sucking wind, I'm quite pleased by how elegantly the Mac has allowed me to improvise.

Try that on a PC installing Vista. Or rather, don't. Get yourself a real system instead.

Aug 15 2007

Third party Python Libraries of Interest

Posted in 11, Python, Technical § 0 Comments

Python is known for it's "batteries include" philosophy, meaning that the standard library that "ships" with the basic installation of the language is feature rich and ready for immediate consumption to tackle most garden variety problems from the get-go.

However, there are numerous third party modules and packages that I feel should be part of the standard distro, or at least treated as such - PEP 206 just scratches the surface of identifying some of the more useful modules that are becoming commonplace).

So here are my 11 most useful extensions that I have installed before I begin doing anything else:

  1. IPython

    If you are going to be using the Python interactive interpreter environment (and you are, right?), then IPython is a must. It's not just the normal the interactive environment on steriods, it's the Barry Bonds of interactive environments. After getting used to the boat-load of features, you'll wonder how you ever got by without it.

  2. MySQLdb

    If you use a MySQL database and want to interactive with it via Python APIs, you'll be needing this.

  3. path

    From what I've read, Jason Orendorff's path model nearly made into the standard Python library. It's a shame it didn't, because one of the uglier Python warts in this author's opinion is the mess of file and path handler interfaces. Do I look in the os, os.path, shutil, fnmatch, or codecs module to find that file / path handling function? Forget it - just look in the path module.

  4. dateutil

    For working with dates, date ranges, or recurrences of dates, this is the only library you will need. Excellent documentation with extensive example code.

    As an example, create a list of the next 3 occurrences of Friday the 13th:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    from datetime import datetime
    from dateutil import rrule
    f13 = rrule.rrule(
        rrule.YEARLY, 
        count=3, 
        byweekday=rrule.FR, 
        bymonthday=13, 
        dtstart=datetime.now()
    )
    
    list([d.date() for d in f13])
    # [datetime.date(2008, 6, 13), datetime.date(2009, 2, 13), datetime.date(2009, 3, 13)]
    
  5. PIL

    Working with images? Done. One caveat: you might want to save yourself some trouble and install the last JPEG library from www.ijg.org (version 6b currently).

  6. wxPython

    Thinking of using Python's Tkinter interface to bestow another hideous, malformed GUI app on us all? Well, 1995 called and asked for it's cheesy look and feel back.

    Come on, wxPython is free, easy to install and use, and has great documentation in WxPython In Action.

  7. BeautifulSoup

    An odd name, but great for parsing both kinds of HTML: the good and the bad.

    An example direct from the documentation:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    from BeautifulSoup import BeautifulSoup
    html = '<html><p>Para 1<p>Para 2<blockquote>Quote 1<blockquote>Quote 2'
    soup = BeautifulSoup(html)
    print soup.prettify()
    # <html>
    #  <p>
    #   Para 1
    #  </p>
    #  <p>
    #   Para 2
    #   <blockquote>
    #    Quote 1
    #    <blockquote>
    #     Quote 2
    #    </blockquote>
    #   </blockquote>
    #  </p>
    # </html>
    
  8. docutils

    docutils has become, in my opinion, the de facto method for marking up Python documentation, to include __doc__ strings. It excels at processing reStructuredText for HTML or LaTex output.

  9. PyXML

    I'm not quite sure why half of the XML functionality was pruned from the default Python standard library, but this is the other half. There are other XML libraries (libxml, pyRXP, 4Suite) that may suit your particular needs better, but as a minimum you should consider getting at least the full PyXML suite.

  10. py2app / py2exe

    These libraries extend the distutils package to produce executable binaries for Mac OS X and Windows, respectively.

  11. Markdown

    Markdown has become a daily part of my development and online life. Many bloggers have begun offering comments in Markdown format (this site included). I find extremely useful for purposes of documentation and more formally structured email because even unprocessed, it remains very readable and elegent as opposed to raw wiki syntax (which I find to be less decipherable than HMTL in many cases, particularly MediaWiki) or even reStructuredText (a bit too structured and esoterica for common everyday usage).

    John Gruber of Daring Fireball started Markdown and provides nice documentation and tools.

Jul 21 2007

Mac OS X Keyboard Shortcuts

Posted in 11, Mac, Technical § 0 Comments

The inspiration for these 11 keyboard shortcuts came from a dead battery in a wireless USB mouse. However, a few must be used in conjuction with a mouse click.

11 Keyboard shortcuts for Mac OS X worth remembering, in no particular order...

  1. c (on boot)

    Boot from CD.

  2. mouse down (on boot)

    Eject CD.

  3. cmd-opt-esc

    Force quit current app.

    Reminiscent of ctrl-alt-del on that other OS.

  4. cmd-`

    Cycle through current application's windows.

    Everyone knows cmd-tab to cycle through applications, but oftentimes one has multiple windows of the same application and needs to cycle through them.

  5. opt-cmd-esc

    Force Quit dialog

  6. shift-cmd-4 + space + click

    Screen dump highlighted window.

    Everyone knows the shift-cmd-3 and shift-cmd-4 screen shot shortcuts, but this one is slightly different in that it allows you to grab the chrome of a particular application window.

  7. cmd-;

    Spell checking.

  8. ctrl-F2

    Highlight the Menu.

    Starts with the Apple menu highlighted. Use arrows to navigate.

  9. ctrl-F3

    Highlight the Dock.

  10. cmd-h

    Hide current application.

    Not that you would have anything incriminating visible in the current application, right?

  11. cmd + drag background window title-bar

    Adjust a window partially obscured by the top-most window.

The Django Project