« June 2004 | Main | September 2004 »

August 31, 2004

Statistics

Here are two quotations I feel are appropriate regarding the recent events. Those who need to understand will.

There are three kinds of lies: lies, damn lies, and statistics.
— Benjamin Disraeli

The only statistics you can trust are those you falsified yourself.
— Sir Winston Churchill

Fuzzy logic

Seen in a film recently, in the header of a letter:

htt/www.valloson.com.cgi

At least they’re sure they’re not hijacking an existing site :-D

August 27, 2004

Good marketing

Altera Corp. surely knows how to treat its customers. Today, along with the semestrial software update package, they sent a pad of Post-it’s. Not the black, high absorption at all wavelengths ones I need for the lab but still, nice.

Bö 1.0b3

Bö 1.0b3 is now available, with a proper Read Me and the ability to escape footnote calls so I could add examples to this entry.

Bö 1.0b3

Name

Description

Bö is a preprocessor for John Gruber’s Markdown, a text-to-HTML filter that translates an easy-to-read / easy-to-write structured text format into HTML.

Its primary (and currently only) purpose is to add smart footnote functionality to Markdown.

Requirements

Installation

  • Install Markdown.pl, SmartyPants.pl and Bo.pl in your Movable Type plugin directory (typically mt/plugins).

  • Bö installs two new text formatting options, “Bö with Markdown” and “Bö with Markdown and SmartyPants”, the latter only if SmartyPants was installed.

Usage

Write your entries using Markdown markup, as you would do with the standard Markdown.

Footnotes are called from the text like this:

#[label]

Where label may contain A-Z, a-z, _ and -.

The footnote bodies can be placed anywhere in the text. They will be automatically moved to the end and sorted in cite order.

[label]: text

    Second paragraph

To indicate that a footnote has several paragraphs, the text must be indented by one tab or four spaces. The footnote body will be processed by Markdown.

You can backslash escape the # to prevent Bö from processing the footnote call:

\#[label]

Bugs

We don’t do bugs. No way, nada, never.

In the very unlikely case of Bö doing something you don’t want it to, contact us and if we like your tone, we may consider changing Bö’s behaviour.

Kidding, don’t hesitate to report bugs or send feature requests using the comment form on Bö’s latest release page.

Version History

  • 1.0b3: Fri Aug 27, 2004

    Enabled very basic escaping of # to allow unprocessed #[label]. Improved Read Me.

  • 1.0b2: Thu Aug 26, 2004

    First public release.

Author

Olivier Scherler
https://ithink.ch/bo

Additional Credits

Copyright and License

Copyright © 2004 Olivier Scherler (https://ithink.ch/blog/)
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

  • Neither the name “Bö” nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

This software is provided by the copyright holders and contributors “as is” and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall the copyright owner or contributors be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage.

August 26, 2004

Bö 1.0b2 released

Bö 1.0b2 is now available for download. See the official announcement on taking the red pill.

This entry is powered by Bö1 and no, I’m not telling you what it is yet2.

1. Seriously. 

2. Patience, my friend. 

August 24, 2004

Manipulating the clipboard in the Terminal: pbcopy and pbpaste

Mac OS X provides two utilities that make it possible to manipulate the clipboard in the Terminal: pbcopy and pbpaste.

pbcopy puts the data it receives via standard input into the clipboard.

echo "Hello, World!" | pbcopy
pbcopy < aFile

pbpaste does the opposite. It ouputs the clipboard to the standard output.

pbpaste
pbpaste > anotherFile

It is possible to select the preferred format for the clipboard data using the -Prefer option:

-Prefer rtf|ps|ascii

Both commands also accept the -help option:

Usage: pbcopy [-help]
Usage: pbpaste [-help] [-Prefer rtf|ps|ascii]

August 22, 2004

Beach volley quiz

  • When, during a SUI/USA beach volley game, you hear Born in the USA, does it come from an American supporter who thinks it’s a patriotic song or from a Swiss fan who knows its not?

  • Which one of the Laciga brothers do you prefer, Martin “Apollo 8” Laciga or Paul “French Fries” Laciga?

  • Can you guess the reason behind these nicknames? Hint: today’s date.

Update (April 20, 2005): Since it’s been a while since I posted this, I’d better explain the nicknames before I forget why I invented them. So on that day’s SUI/USA game, Martin “Apollo 8” kept serving the ball in orbit while Paul “French Fries” tirelessly tried to smash it through the net.

August 14, 2004

Nailed it down

Xcode has been driving me mad recently. I am writing TINI applications in Java, which requires me to feed the class files to a converter application. I had a little trouble figuring out how to make Xcode generate and run on a class hierarchy instead of a jar file but I will talk about it in details in an upcoming entry. The topic today is the bug I discovered (and fixed!) in Xcode when working with class hierarchies.

Since I already wrote about it several times for the Java Dev and Xcode Users mailing lists, I will limit myself to posting the report I submitted to Apple.

1. Configuration

  • Mac OS X 10.3.5
  • Xcode 1.5
  • Java 1.4.2 Update 1
  • Java 1.4.2 Update 1 Developer Tools

2. Summary

When configuring a Java Tool project to generate a class hierarchy instead of a Java archive, the class files are copied into TARGET_BUILD_DIR/PRODUCT_NAME (i.e. PRODUCT_CLASS_FILE_DIR) the first time the project is built. However, on subsequent builds, the classes in that folder are not updated, even when the sources are. Therefore, the project runs on old class files and so do potential shell script build phases that would post process the class files.

3. Steps to reproduce

  • Create a new Java Tool project in Xcode;
  • In the active target, change the Java Archive Settings / Product type to Class Hierarchy (or in expert mode, set JAVA_ARCHIVE_CLASSES = NO);
  • Build the project;
  • In the Finder, take note the modification date of the class file in build/PRODUCT_NAME;
  • Make a modification to the sources, e.g. change "Hello World!" to "Take over the World!";
  • Save and build the project;
  • In the Finder, notice that the class file has not been updated since the modification date did not change.

4. Expected results

Every time the project is built, the class hierarchy should be copied from CLASS_FILE_DIR to PRODUCT_CLASS_FILE_DIR if it has been modified, as it happens the first time the project is built.

5. Actual results

The class hierarchy is only copied on the first build or after a target clean-up.

6. Cause

Watching the build process from a shell using xcodebuild instead of the Xcode GUI shows that on a clean target, after the Java Archive Files build phase, the PRODUCT_CLASS_FILE_DIR is created and ditto is used to copy the class files from CLASS_FILE_DIR to PRODUCT_CLASS_FILE_DIR:

BuildPhase <JavaArchiveFiles>Hello
    echo Completed phase "<JavaArchiveFiles>" for "<JavaArchiveFiles>Hello"
Completed phase <JavaArchiveFiles> for <JavaArchiveFiles>Hello

Mkdir […]/Hello/build/Hello 
    /bin/mkdir  -p […]/Hello/build/Hello 

Ditto […]/Hello/build/Hello 
    /usr/bin/ditto  […]/Hello/build/Hello.build/Hello.build\
    /JavaClasses […]/Hello/build/Hello

However, when PRODUCT_CLASS_FILE_DIR exists, neither of these two operations is executed.

7. Workaround

Cleaning the active target prior to building or deleting the PRODUCT_CLASS_FILE_DIR folder causes Xcode to create it again, with up-to-date files. However, emptying this folder is not enough.

8. Resolution

The build instructions are defined in

/Developer/Makefiles/pbx_jamfiles/ProjectBuilderJambase.

The parts of interest are the definition of Mkdir (ProjectBuilderJambase, line 299):

# Mkdir <directory>
# Creates <directory>
rule Mkdir
{
    # Only existence of the directory matters
    NOUPDATE $(1) ;
}
actions together piecemeal Mkdir
{
    $(MKDIR) -p $(1:Q)
}

and the section where the class files are copied using ditto, where it looks like someone has been bothered by this bug for some time (line 4267):

if $(JAVA_ARCHIVE_CLASSES) != YES {
    # !!!:cmolick:20020123 product class file dir not always made?!
    Mkdir $(PRODUCT_CLASS_FILE_DIR) ;
    ProductFile $(PRODUCT_CLASS_FILE_DIR) ;
    Ditto $(PRODUCT_CLASS_FILE_DIR) : $(CLASS_FILE_DIR) ;
if $(MERGED_ARCHIVES) {
        DEPENDS $(PRODUCT_CLASS_FILE_DIR) : $(MERGED_ARCHIVES) ;
    }
    else {
        DEPENDS $(PRODUCT_CLASS_FILE_DIR) : $(JAVA_COMPILE_TARGET) ;
    }
}

It is actually the Mkdir command that prevents the copy to execute, even though mkdir -p exits 0 regardless of whether the directory to create is already present. I have no idea whatsoever of the language used to write ProjectBuilderJambase but I can make a pretty safe guess that the culprit is the NOUPDATE statement in the Mkdir rule. Indeed, removing it solves the problem, albeit not in a very clean way as this statement is probably necessary elsewhere (although it might be problematic elsewhere as well).

The fix I implemented was to create a new action, ForceMkDir, to use in this particular case (ProjectBuilderJambase, line 310):

# ForceMkdir <directory>
# Creates <directory>, even if it already exists.
#
# This modification is for the Ditto step that copies class files in
# Java projects (line 4267-78). The original Mkdir action above seems
# to prevent ditto from executing when the directory already exists.
#
# Corrected 2004-08-12 by Ölbaum, who's quite proud of having fixed a
# glitch in a program written in a language he does not even know the
# name of.
actions together piecemeal ForceMkdir
{
    $(MKDIR) -p $(1:Q)
}

and (line 4269):

# !!!!:Ölbaum:20040812 fixed!
ForceMkdir $(PRODUCT_CLASS_FILE_DIR) ;

9. Enclosures

A patch file for these modifications: ProjectBuilderJambase.diff.

10. Conclusion

After applying these modifications, the class hierarchy in PRODUCT_CLASS_FILE_DIR is properly updated each time the classes are recompiled.

August 13, 2004

Pipes and redirections in sh

A quick reference to pipes and redirections in sh.

Notes

In sh, the standard output is identified as file descriptor 1 and the diagnostic output as file descriptor 2.

Pipes

  • Use the standard output of program_1 as the standard input of program_2:

    program_1 | program_2
    
  • Use the standard and diagnostic outputs of program_1 as the standard input of program_2:

    program_1 2>&1 | program_2
    

Redirections

  • Open file name as the standard input:

    program < name
    
  • Use file name as the standard output:

    program > name
    
  • Append the output to the end of file name:

    program >> name
    
  • Route both the standard and diagnostic outputs to file name:

    ( program 2>&1 ) > name
    
  • Append both the standard and diagnostic outputs to file name:

    ( program 2>&1 ) >> name
    

Tips

  • To route the standard and diagnostic outputs to separate files, use the following syntax:

    program > outfile 2> errfile
    
  • To route the diagnostic output to a file and the standard output to the terminal, use:

    program 2> errfile
    
  • To retain only the diagnostic output, redirect the standard output to /dev/null:

    program > /dev/null
    program > /dev/null 2> errfile
    
  • In order to test pipes and redirections, use the following Perl program:

    #!/usr/bin/perl
    
    
    print STDOUT "STDOUT: Standard output\n";
    print STDERR "STDERR: Diagnostic output\n";
    

August 10, 2004

iLaugh

Finally a product with a funny iName.

August 9, 2004

Pipes and redirections in tcsh

A quick reference to pipes and redirections in tcsh.

Pipes

  • Use the standard output of program_1 as the standard input of program_2:

    program_1 | program_2
    
  • Use the standard and diagnostic outputs of program_1 as the standard input of program_2:

    program_1 |& program_2
    

Redirections

  • Open file name as the standard input:

    program < name
    
  • Use file name as the standard output:

    program > name
    
  • Append the output to the end of file name:

    program >> name
    
  • Route both the standard and diagnostic outputs to file name:

    program >& name
    
  • Append both the standard and diagnostic outputs to file name:

    program >>& name
    

Tips

  • To route the standard and diagnostic outputs to separate files, use the following syntax:

    ( program > outfile ) >& errfile
    
  • To route the diagnostic output to a file and the standard output to the terminal, use:

    ( program > /dev/tty ) >& errfile
    
  • To retain only the diagnostic output, redirect the standard output to /dev/null:

    program > /dev/null
    ( program > /dev/null ) >& errfile
    
  • In order to test pipes and redirections, use the following Perl program:

    #!/usr/bin/perl
    
    
    print STDOUT "STDOUT: Standard output\n";
    print STDERR "STDERR: Diagnostic output\n";
    

Knowledge base migration

I have decided to move my knowledge base to my main blog. The benefits are threefold:

  • I can repost knowledge base articles and give the impression that I update my blog more often;
  • Since I post other things here, it becomes less visible that I very rarely update the knowledge base;
  • I save one blog for when I upgrade to Movable Type 3

I will start moving the articles right now, starting with the most popular one: Pipes and redirections in tcsh. Of course, the old knowledge base permalinks will still work, long live mod_rewrite.

August 5, 2004

Greylisting

Our IT department installed a Greylisting filter on our server two days ago. The technique is efficient, smart and yet simple and I wonder why we didn’t hear about it sooner.

  • Until August 4th, 2004: 30 spams a day or 6700 since January 1st;
  • Since August 4th: 0 spam a day or 0 in total.

Small digression: Here, the Google Spell Check gives:

  • Gray: 24’800’000
  • Grey: 24’500’000

Which is consistent with the observation that the British term is the second more frequent.

Geeky enough?

Jason Snell about AirPort Express:

Now some more general advice. First, even if you think you’re a really, really geeky Mac user, don’t start with the AirPort Admin Utility. Apple has really done a remarkable job with the AirPort Express Assistant, and you should give it a try. Yes, it’s a wizard-style interface — what’s the challenge in that? — but when you’re in a situation where you’re configuring two wireless devices at once (for example, setting up a wireless relay from one AirPort Extreme or Express to another one), using the AirPort Admin Utility can get really hairy. In contrast, the Assistant is a breeze.

OK, I think I’m a really, really geeky Mac user. Send me an AirPort Express and I’ll show you how I configure it and my AirPort Extreme Base Station for bridging, both at once, using the AirPort Admin Utility. If I succeed in less than three hours, I’ll keep the AirPort Express. :D

Update (April 20, 2005): By the way, after recently buying an AirPort Express, I did just that, and in much less than three hours.

August 1, 2004

Word 2004 scrolling

I installed Office 2004 today (we have a campus license at work, I’m not giving any money to Microsoft) and mouse wheel scrolling in Word is so broken that it’s unusable. Scrolling up works as it should but scrolling down does nothing while you scroll the wheel, waits half a second after you stopped and then scrolls the document in one big chunk. Even scrolling by one wheel step is suffers from the half second delay.

A Google search on the subject led to the following page at Microsoft: Scroll at your own speed where one can read:

Without the correct mouse driver, Office uses your Mac OS X system settings to determine the number of lines to scroll when you use your scroll wheel. Because Mac OS X doesn’t include settings for a scroll wheel, Office programs scroll in one-line increments.

Helloooo1, what about System Preferences > Keyboard & Mouse > Mouse > Scrolling Speed? Well, what about fixing the problem instead of telling me what drivers I must install too.

Another source of unimpressiveness is the lack of support for ligatures like fi and fl. Not only do they not automatically replace fi and fl but they make the spelling checker choke too. And seeing that Entourage 2004 replaces ligatures in e-mails, where it’s the most stupid place to do so, is even more puzzling.

1. Google validation reveals that four o’s is the correct spelling for this word:

  • Helloo: 15’600 results
  • Hellooo: 29’000 results
  • Helloooo: 35’000 results
  • Hellooooo: 16’200 results
  • Helloooooo: 8’940 results 
Do not meddle in the affairs of Coding Ninjas, for they are subtle and quick to anger.