Archive for October, 2005
As The Seattle Lion pointed out, we’re taking suggestions for sIFR 3. Head over to the request page and let us know what you’d like to see!
In this tech-infested world, the question really is how to balance the tech. Are you better of with less tech?
When I made the presentation for BarCamp, I didn’t make it in S5 but in Keynote. S5 makes you write in HTML, makes you think in two different levels: the markup and the presentation. And you can’t see those at the same time — constantly switching the presentation of your content hurts the way you think.
I didn’t write this post in HTML. I use Markdown: plain text with some syntatic sugar to extract semantics. But the only sugar I’ve used this far is grouping the text in paragraphs (and adding two links after the fact).
When I want to code something I turn on some music, stand up and walk to a whiteboard. Pick up a pen and start sketching stuff. Pause, walk around a bit, drink some water, and improve things. Get your mind in a flow state, design the app. Then, start coding. Throw away parts you don’t need. Get up again if you get stuck, rethink.
Would OmniGraffle work here? Although, to be honest, I haven’t tried, I don’t think it would. It’d be sitting at my desk, typing away and connecting dots on the screen. Quickly drawning some physical lines is easier than doing it in the virtual world. And since these wireframes won’t reflect the actual code, does it matter in what medium I make them? If necessary I can always redo them in the virtual space later.
At uni, we had to make UML charts for Java code with Together. Aside from annoying the crap out of me, because seriously, that app is confusing, did it really make me code better? Not really, since I thought of the abstractions in my head, then put them into Together, and then wrote the code. Sketching on a real whiteboard would’ve been faster.
No-tech is important, don’t let all the shiny tech blind you from that.
One of the few things I like about Java is how methods are identified not by their identifier (language collision here, it’d seem) but by their signature. In code:
public static void foo (String bar) {
// do things
}
public static void foo (String[] bar) {
// do things
}
These foo() methods are different in that they accept different types of parameters. In dynamic languages this is not possible, but of course you aren’t limited to one type of parameter.
And yet, I was wondering if there was an elegant way to implement someting comparable in JavaScript. Let’s take the following code, and try to make it more elegant:
function say (value) {
value = value || "";
if (typeof (value) != "string") {
if (value.constructor == Array)
value = value.join("\n");
else {
var result = "";
for(var prop in value)
result += prop + ": " + value[prop] + "\n";
return result;
}
}
alert(value);
}
Hmm, some conditions and specific code in their bodies. It’d almost look like a switch statement, but in JavaScript you can only compare values, not use your own conditions. However, Ruby has a switch mechanism which lets you evaluate conditions:
case
when 1 + 1 == 2
puts "1 + 1 is indeed 2"
when 1 * 1 == 1
puts "1 * 1 is indeed 1"
else
puts "Somebody must have disproved mathematics"
end
Quite elegant. Let’s consider this example:
function say (value) {
value = value || "";
alert (Function.$case (
typeof value == "string", // when
value, // expression
value.constructor == Array, // when
function () { // expression
return value.join("\n");
},
function () { // else
var result = "";
for(var prop in value)
result += prop + ": " + value[prop] + "\n";
return result;
}
));
}
The even attributes (counting from 0) are the conditions. The odd attributes are the expressions, and the last even attribute is the “or else” expression.
I’d say this is (in theory) more elegant, but it looks confusing and requires more code — sounds a bit like Java, actually. And this is what Function.$case() looks like:
Function.$case = function () {
var condition;
for (var i = 0, expr = null; i < arguments.length; i+=2, expr = null) {
condition = arguments[i];
if (i == arguments.length - 1)
expr = condition;
else if (condition === true)
expr = arguments[i + 1];
else if (typeof (condition) == "function" && condition () === true)
expr = arguments[i + 1];
if (typeof (expr) == "function")
return expr ();
else if (expr != null) // To obviate the need for superfluous functions, you can also use a value instead of a function
return expr;
}
}
After some hard work (cough) I’ve updated the following:
- Valid Atom feeds, even for comments
- Feed to get the 20 most recent comments
- Comments form without tables
- and better hints
- Highlighted the comment posted notification
- Ensured no XHTML escapes the system. HTML rocks
- Fixed Last-Modified on comment feeds
- Full content feeds (with summary)
TextPattern rocks.
You know those pesky “Copy-Protected” CDs? Unfortunately I’ve got a few of them (found out too late) and they were a pain to rip on the Windows box. Sometimes they’d crash iTunes (or other ripping software), and if it worked, well, they had some small gaps in them.
Not anymore. I have no idea whether it’s iTunes 6, or Tiger, but I can now rip right through them with perfect quality. (Not perfect as in lossless, but perfect as in 160 kbps VBR AAC.) On one disc it even found a bonus track, which I missed out on when I ripped it on Windows.
Also nice is how Tiger shows two discs if the CD contains a data part and an audio part. Perhaps that’s why ripping works so well?
Look! All new, all shiny! Running on a somewhat hacked version of TextPattern, valid HTML 4.0.1 Strict and Atom 1.0. Now with comments. And article-level feeds. Yay!
This site is not guaranteed to work in browsers originating from Redmond. Batteries not included (but stolen from smoke alarms).
