Tech

Flashing a BIOS with an exe in Ubuntu

For step-by-step instructions, go read the mastermind's article, from which this is derived. This is mostly for my future reference. I was given an exe (M1330A12.EXE) by Dell and told to flash my BIOS with it. Right. Then I was given the world's most incomprehensible instructions on how to supposedly get it working with linux. Thank god for the aforementioned article -- the following worked like a charm.

Setting a CCK default value for old nodes

I added a brand-new cck field to a content type which already had a bunch of nodes, but previously had no cck fields. This new field needed to have a default value set for all existing nodes. Of course, editing an old node and saving it without making any changes would set an appropriate default value... but I couldn't manually do that for all the nodes.

UPDATE using JOIN

update content_type_message ctm join node n on ctm.nid = n.nid set
  ctm.field_message_recipientalert_value = unix_timestamp(date_add(n.created, interval 24 hour)),
  ctm.field_message_senderalert_value = unix_timestamp(date_add(n.created, interval 24 hour));

From 12.2.10. UPDATE Syntax:

Reading a single character from stdin

Why there isn't an easier way of doing this, I have no idea. It'd be nice if this would work:

sys.stdin.read(1)

...however, because the file is a tty, nothing gets read until the user hits enter.

Enter getch. It's a utility written by Danny Yoo and stolen from a posting I found on google: ASPN : Python Cookbook : getch()-like unbuffered character reading from stdin on both Windows and Unix.

Description:

Paging output

Let Python determine the best pager available:

import pydoc
pydoc.pager(text)

This may pipe the text into an external program like less or more.

...or explicitly use the built-in pager:

import pydoc
pydoc.ttypager(text)

Source: http://www.velocityreviews.com/forums/t584112-paging-in-python-shell.htm...

Setting up puppet on Debian

Debian seems to think the default puppetmaster port is 18140... but all the documentation I found and my puppet client running on Ubuntu says the default port is 8140. Strange.

Opening the configuration file /etc/default/puppetmaster and changing the last line to the right port did the trick.

PORT=8140

I also got the following error when trying to use my newly-signed client certificate:

notice: Got signed certificate

Using a context

$('.foobar', context)

...is the same as:

context.find('.foobar')

...but you can also pass in a DOM element:

$('.foobar', this)

...which would be the same as:

$(this).find('.foobar')

Lambda function array manipulation

A fun bit of code brought to my attention by Lih:

>>> l = [1,2,3,4]
>>> l
[1, 2, 3, 4]
>>> l2 = [ x+1 for x in l ]
>>> l2
[2, 3, 4, 5]

Declaring and initializing arrays

These are identical declarations for an array:

var foo = new Array()
var bar = []

...as are these, which also initialize the array:

var foo = new Array('first', 'second', 'third')
var bar = ['first', 'second', 'third']

Both of the above are accessed like so:

alert(foo[0])  // alerts 'first'
alert(bar[0])  // alerts 'first'

An associative array (which is really an object in JS) is declared/initialized like so:

var bash = {
  first : 'value 1',
  second: 'value 2',
  third : 'value 3'
}

Unresolved: <Ctrl>Tab for gnome-terminal

Firefox uses <Ctrl>Tab</ctrl> and <Ctrl><Shift>Tab</shift></ctrl> for switching between tabs. Eclipse at least lets you assign these same keybindings to its tabs. Wouldn't it be nice if gnome-terminal would allow the same thing? No such luck.

The symptom, as described by Daniel DiPaolo:

Syndicate content