Enable CPU frequency scaling in Ubuntu

Thursday, November 24

I’ve been using the CPU frequency monitor applet in Gnome to see the speed at which my Pentium-M chip is running, and noticed that it rarely gets up to the 1.6Ghz that it’s capable of. While I tend to prefer the dynamic scaling behaviour when running on batteries, when I’m plugged in I want top processor performance.

I did a little digging and found the answer (where else), in the README (/usr/share/doc/gnome-applets-data/README.Debian). It turns out that the cpufreq applet ships with the SUID bit unset (for security reasons), but you can enable it using by reconfiguring using dpkg-reconfigure:

$ sudo dpkg-reconfigure gnome-applets

Just choose ‘Yes’ to set the SUID bit for the cpufreq-selector executable and you’ll be able to left-click on the applet and set the the CPU frequency manually.

.vimrc

Thursday, November 24

Since I won’t have my iMac for a while, I’ve had to give up my beloved Textmate. In its absence, I’ve been doing most of my Ruby programming in console VIM. Since I’m tired of having to recreate my preferences in .vimrc every time I’m on another system, I’m archiving it here for future reference:

" no war for heavy metal
syntax on           " syntax highlighting
filetype on         " detect the filetype
filetype plugin on  " load filetype plugins

set nocompatible    " turn off vi compatiblity
set nowrap          " don't wrap long lines
set background=dark " I use a black background
set tabstop=2       " Ruby-style tabs
set number          " line numbers
set ai              " autoindent
set si              " smartindent

If you’re new to VIM or are looking for a few sensible defaults for programming, you might want to try these options (put them in ~/.vimrc). Pretty colors, syntax highlighting, line numbers, auto-indents, a small tabwidth, and a few others. Simple. Just the way I like it.

Scribbish and hAtom

Sunday, November 20

The latest version of typo adds the ability to override article views from within themes, thus making it possible to theme the previously un-themeable. While I tend to prefer the simplicity of the old engine (which saw only the modification of a single layout file), it always bothered me that I couldn’t change some of the markup that typo produced. Not anymore: most of the views from app/views/articles/ are now re-implemented by Scribbish to produce microformatted html, specifically, an emerging specification called hAtom.

Aside from more obvious reasons (and specifically when it comes to creating a ‘default’ theme), using a standard such as hAtom frees one from having to force thier own (subjective) naming conventions on other developers. Since Scribbish aims to be a good starting place, and in its first incarnation implemented standardized markup for layout, the next logical extension was to standardize the markup used to render posts and comments.

In addition to being semantic, the hAtom format is both machine and human readable, and provides the designer with more than enough hooks for styling.

(Actually, the fact that there are sufficient css hooks is more a side-effect of a semantic specification like hAtom than it is a design goal. It just so happens that good markup and style go hand-in-hand—see below.)

Here’s an (abbreviated) example of the markup that’s now produced by Scribbish for each blog article:

<div class="atomentry" id="article-1">
  <h2 class="title">Some post</h2>
  <p class="author">Author ...</p>
  <div class="content">
    ...
  </div>

  <ul class="meta">
    <li class="categories">foo</li>
    ...
    <li class="tags">bar</li>
  </ul>
</div>

The accompanying css would go something like this:

#content .atomentry {}
#content .atomentry .title {}
#content .atomentry .author {}
#content .atomentry .content {}
#content .atomentry .meta {}
#content .atomentry .meta .categories {}

To find out more, check out the full specification at http://microformats.org/wiki/hatom, or view the source of your typo blog once you’ve applied the theme.

Visit the download page for Scribbish where you can get the latest version (0.2, for typo 2.6.0) as well as older versions.

I should also note that I’m not yet running Scribbish-0.2 here (at Planet Argon) because it requires typo-2.6.0 (which in turn requires Rails 0.14.1). I’m sure PA will be upgrading to the latest Rails release soon.

Scribbish 0.2

Sunday, November 20

Version 0.2 of the Scribbish theme for typo is available for download from its shiny new download page at http://quotedprintable.com/pages/scribbish

Note: Scribbish 0.2 works with the latest version of typo (r759) but not with the latest stable release (2.6.0). To get the latest version of typo using subversion, see http://typo.leetsoft.com/trac/wiki/DownloadCurrent

A broken iMac

Wednesday, November 16

My iMac (G5 2.0GHz, 20”) refuses to stay powered. Since early this afternoon, it has been suddenly shutting off, as though its plug has been yanked from the wall.

The first time it happened I thought the power had gone out. All the symptoms were a match (no warning, no fan noise, no trigger—just poof! and then nothing), but the lights were still on, so a power outage it was not. Puzzled, I turned the machine back on, checked out the crash logs, found nothing out of the ordinary, and continued working away, waiting to see if it would happen again. Sure enough, a few minutes later, it happened, and again I was left staring at a hopelessly useless black screen.

Frustrated, I turned my attention to, and subsequently ruled out, the power cord, the power bar, and the wall outlet. I tried it in another room, in a different outlet, on a different breaker. Each time I thought the problem had vanished, my hopes were dashed by a sudden, inexplicable, shutdown.

During brief stints of uptime, I was able to run a few diagnostics, check a few log files, and try a few tricks, all to no avail. Everything seemed fine. I even opened it up and looked under the hood, as if it were a car, as if I would be able to see something suspicious, or out of line. Not surprisingly, it provided no answers.

After much hair-pulling I gave up. It only stays running for a few minutes at most, and as such is unusable. I have since concluded that the power supply must be faulty and have resolved to box it up and cart it down to my local mac dealer first thing in the morning to have it fixed.

Luckily, it’s still under warranty; luckier still, I have a spare laptop.

This laptop on which I am now typing (a Toshiba M30) has really been around the block. I mean, in recent weeks it’s seen FreeBSD, PCBSD, DesktopBSD, Ubuntu-hoary, and Ubuntu-breezy. We’re talking full installs here—no stinking live-cds. I use it as a testing ground for new operating systems, my only criteria for a successful install being the achievement of a wireless Internet connection with zero configuration.

As chance would have it, I had installed kubuntu-5.10 (ubuntu with KDE) on the weekend—to try it out. It passed the zero-config test, but I had no intention of using it as my primary OS. Only days later, here I am, learning the ins and outs of Debian/Linux. It’s not OS X, (or even FreeBSD), but really, it’s not so bad.

I probably spent more time lamenting the plight of the iMac than I did getting set up on kubuntu. Within a few hours, I had my packages, preferences, software, mail, and the entire Rails stack set up. Now I’m back hacking on typo, working on the next version of Scribbish (which I will post about later).

I’m sure I’ll miss a few of OS X’s comforts, but until the iMac gets fixed, I think I can make myself at home here. I’ve missed working on a laptop.

Scribbish: a theme for typo

Sunday, November 06

Update: as many have noticed, Scribbish breaks the live search for versions > 2.5.6. I am working on an updated theme that takes advantage of the newer features but in the meantime you can hack the file layouts/default.rhtml to make Scribbish work with 2.6.0.

Look for the call to observe_field in layouts/default.rhtml and replace it with this:

<%= observe_field "q",
      :frequency => 1,
      :url => { :controller => "live", :action => "search" },
      :loading => "Element.show('loading')",
      :complete => "Element.hide('loading')",
      :update => "results",
      :with => "'q=' + escape($F('q'))" -%>

It’s the last line that should make it compatible with the typo trunk, but will break compatibility with 2.5.6 :\ That’s what I get for not leaving it in a partial. Ugh, it looks ugly in a view.

/Jeff

Scribbish is a theme for typo. Its layout standardizes on a simple xhtml structure and styles are separated into individual files which are included in the correct order, making it easier to control the cascade and to figure out ‘what-goes-where’. Use it as-is, or copy it to make new themes.

Scribbish has its own page now

Start by copying Scribbish

The easiest way to make a typo theme is to copy an existing one and go to town, right? Well, Scribbish is a good theme to copy. It starts you off with a standard xhtml structure (valid, of course), stylesheets, and a css framework to keep them organized. With this in place, all you have to do is dive in and start designing.

The XHTML structure

The structure used by Scribbish is basic yet flexible enough that it shouldn’t require modification. I mean, that’s really the whole idea here—if you always use the same xhtml structure, you only ever need to modify the css to make new themes. Yes, this is very much a CSS Zen Garden approach. The code follows.

<html>
  ...
  <div id="container">
    <div id="header"></div>
    <div id="page">
      <div id="content"></div>
      <div id="sidebar"></div>
    </div>
    <div id="footer"></div>
  </div>
  ...
</html>

A CSS framework

The structure is complemented by a simple css framework: each main element (#header, #content, #sidebar, #footer) has a corresponding css file. Additionally, page layout is handled by the file layout.css, and everything is assembled by application.css, the only file you need to include in your html. The key benefit to this approach is common to any framework (even Rails): everything has a place.

The css included with Scribbish is light and terse. There are no unnecessary or redundant rules, just a set of sensible defaults. Print styles are also handled elegantly, without the need for a seperate, print.css file.

Anatomy of a theme

So, where does everything go? Here is the breakdown (courtesy of the unix program, Tree).

$ tree typo/themes/scribbish

typo/themes/scribbish/
|-- about.markdown
|-- images
|-- javascript
|-- layouts
|   `-- default.rhtml    #=> The xhtml structure
|-- preview.png
`-- stylesheets
    |-- application.css  #=> Imports files / orchestrates framework
    |-- layout.css       #=> Handles layout (dimensions/position)
    |-- header.css       #=> Rules for div#header
    |-- content.css      #=> Rules for div#content
    |-- sidebar.css      #=> Rules for div#sidbar
    |-- footer.css       #=> Rules for div#footer
    `-- local.css        #=> Imported last; overrides other rules

Application.css is the one to pay attention to here. Using the css import rule, it includes all the other stylesheets and arranges them in the correct order. It also defines global rules, such as the default font properties, default states for hyperlinks, and rules for different media types, such as print. Since this file does all the work, it’s the only that’s included by layouts/default.rhtml.

Layout.css is where you handle your dimensions, widths, heights and floats for any element. So, if you wanted to move, say, the sidebar to the right of the content, you’d do it here. To make things easier you can use the helper elements, div#container and div#page, to manipulate the entire document and the content+sidebar elements respectively. In the end, you’ll find that a pixel perfect layout is much easier to achieve when you’re only looking at a few rules in a single file that doesn’t even scroll in your editor.

Customizable live-search (aka, the Spinner)

One of the things about the default Azure layout is that it uses a Rails ‘partial’ to render the live-search spinner. (For the uninformed, the spinner is an animated GIF that indicates progress during the AJAX-enabled live-search). Unfortunately, using a partial means the live-search isn’t theme-able. Scribbish solves this by placing the contents of the live-search partial inside layout.rhtml (where it can be modified), and makes it easier to customize the spinner by controlling it via css.

Room for improvement

The principal drawback to using several css files is display speed. Specifically, display speed in the Rails development environment. Because the development environment doesn’t implement caching, and because typo uses Rails to process theme urls (adding the overhead of logging), it takes a few seconds longer to load up each page. Fortunately, stylesheets are cached by Rails and everything is quite snappy in the production environment.

Download and installation

Version 0.1 (November 6, 2005)

Installation is as easy as unpacking Scribbish in the themes directory at the root of your typo application. This should leave you with a directory named ‘Scribbish’ on the same level as the default ‘Azure’ theme. If you’re using unix,

$ cd themes    
$ curl -O http://quotedprintable.com/files/scribbish-0.1.tar.gz
$ tar xzf scribbish-0.1.tar.gz

That’s all there is to it. The Scribbish theme will now show up in the typo back-end under the ‘Themes’ tab. All you have to do is activate it.

Feedback

Feedback is welcome and appreciated. I haven’t tested in as many browsers as I’d like to (no Windows machines in the house). If you find bugs, oddities, or have questions, please email me at packagethief[at]gmail.com.