In SQL, you can retrieve a list of records via the "IN" syntax:
SELECT * FROM mytable WHERE id IN (1,2,3,4,5,6);
Django supports near-identical syntax:
MyTableModel.objects.filter(id__in=[1,2,3,4,5,6])
nice!
Monday, February 15, 2010
Saturday, February 13, 2010
Thursday, February 11, 2010
Screen recordings under Snow Leopard (OS X 10.6)
For all your software demo needs: Snow Leopard will create screen recordings out of the box.
Just run Quicktime, go to File -> "New Screen Recording."
(Thanks to Nithin Reddy for the heads-up)
Just run Quicktime, go to File -> "New Screen Recording."
(Thanks to Nithin Reddy for the heads-up)
Animal adjectives
That I found this on a site called "PubQuizHelp" seems appropriate enough. You probably know that "simian" refers to all things monkey-related--hence the adjective's popularity during the Bush administration--and you may have heard that "ursine" is the word for all things bear ... but did you know that calling someone "lapine" likens them to a rabbit?
Very useful stuff.
Very useful stuff.
Friday, January 29, 2010
jQuery 1.4
The jQuery Javascript library, without which cross-browser Javascript development is unthinkable, has reached version 1.4.1.
Particularly useful is the ability to create new DOM elements. (See this brief discussion, though no anchor link means you'll have to search for "Quick Element Construction.")
What those docs overlook is the .text property, which enables you to create a proper element:
$("#foo").append( jQuery("<div>", {
id: "foo",
text: "I'm a new DIV element",
click: function() {
$(this).css("backgroundColor", "red");
}}));
or even create a nested elements via .html:
$("#foo").append( jQuery("<select>", {html: "<option value='1'>One</option>"}) );
Particularly useful is the ability to create new DOM elements. (See this brief discussion, though no anchor link means you'll have to search for "Quick Element Construction.")
What those docs overlook is the .text property, which enables you to create a proper element:
$("#foo").append( jQuery("<div>", {
id: "foo",
text: "I'm a new DIV element",
click: function() {
$(this).css("backgroundColor", "red");
}}));
or even create a nested elements via .html:
$("#foo").append( jQuery("<select>", {html: "<option value='1'>One</option>"}) );
Sunday, January 24, 2010
The Great Pacific Garbage Patch, local edition
This week's massive storm system seems to have washed up a small taste of the Great Pacific Garbage Patch:

We're doomed.

We're doomed.
Thursday, January 21, 2010
Multi-line strings
Javascript doesn't have multi-line strings, but offers a variety of hacks ranging from concatination ("line 1\n"
+"def") to the CDATA hack, but as always, your milage will vary depending upon your browser.
Python has dedicated multi-line string denominators, namely the triple-quote -- """ and '''. Quite workable, but not as elegant as simply allowing newlines in a string.
C and shell have the backslash:
char * s = "line 1\n\
line 2";
Haskell extends that to the double-backslash:
s = "line 1\n\
\line 2"
PHP, in a rare moment of elegance and usability, treats a newline in a string as a newline.
$s = "line 1
line 2";
Now why is that so hard?
Update: Jake is right: C-style backslashes work in Javascript (at least on Firefox).
+"def") to the CDATA hack, but as always, your milage will vary depending upon your browser.
Python has dedicated multi-line string denominators, namely the triple-quote -- """ and '''. Quite workable, but not as elegant as simply allowing newlines in a string.
C and shell have the backslash:
char * s = "line 1\n\
line 2";
Haskell extends that to the double-backslash:
s = "line 1\n\
\line 2"
PHP, in a rare moment of elegance and usability, treats a newline in a string as a newline.
$s = "line 1
line 2";
Now why is that so hard?
Update: Jake is right: C-style backslashes work in Javascript (at least on Firefox).
Subscribe to:
Posts (Atom)