Wednesday, December 9, 2009

Peak Prices?

I've had Oil 101 in my Amazon.ca cart for a few weeks. Just not ready to read it yet. When I checked my cart today, I was unpleasantly surprised to read this note:

Please note that the price of Oil 101 has increased from CDN$ 23.20 to CDN$ 36.97 since you placed it in your Shopping Cart. Items in your cart will always reflect the most recent price displayed on their product detail pages.

How does Amazon justify boosting the price by almost 60% in just a couple of months? Perhaps, like the book's subject, we've reached "Peak Books"...

Tuesday, May 5, 2009

gnu find and grep: using path patterns to match more than one file extension

Example using Cygwin gnu find, xargs and grep to search for a typo in XSLT and XML files. Note that -iregex matches a pattern in the whole path, and the pattern is a POSIX basic regex:

C:\>find ./ -iregex '.*\.\(xslt\^|xml\)' -type f -print | xargs grep -i "staus"


When find matches a file path, the path is piped to xargs, which hands it off to grep to search for the string "staus" - which I want to replace with "status" (but not here :).

Monday, May 4, 2009

Cygwin setup.exe fails during upgrade

Like Ruben, who provided the clues, I discovered that a corrupt/incompatible alternatives.lst.bz file in the C:\cygwin\etc\setup directory caused Cywin setup.exe to fail.

A few clues pointed to this file as the culprit:


  1. First time through, the installer complained that some other Cygwin process had locked the readme file

  2. the installer just looped indefinitely on extracting the README file from alternatives.lst.bz until I killed it

  3. The only .bz file in C:\cygwin\etc\setup with today's date was alternatives.lst.bz.



Here's what the log file recorded, for several thousand lines:


2009/05/04 11:01:23 io_stream_cygfile:
fopen(/etc/alternatives/README) failed 13 Permission denied
2009/05/04 11:01:23 Failed to open
cygfile:///etc/alternatives/README for writing.


I renamed the file to alternatives.lst.bz.bak , then reran setup.exe to successfully upgrade Cygwin.

Now I suppose I should log a bug report...

How to fix apropos for Cygwin

If the apropos command in Cygwin doesn't find anything expected, run /usr/sbin/makewhatis from your Cygwin bash prompt to rebuild the whatis database.

Thanks to Mike and Igor for their tips.

Friday, May 1, 2009

How to make Windows %path% readable

If like me your Windows %path% looks something like this:

PATH=c:rubybin;C:Perlsitebin;C:Perlbin;C:Oracle
OraHome817bin;C:oracleproduct10.2.0gpdbin;C:Program 
FilesOraclejre1.1.7bin;C:Python26;C:Python26scripts;C:
Python26Libidlelib;C:cygwinbin;C:Program FilesWindows 
Resource KitsTools;C:WINDOWSsystem32;C:WINDOWS;C:WINDOWS
Downloaded ProgramFiles;C:Program FilesIBMDirectorbin;C:
Program FilesDiskeeper CorporationDiskeeper;c:Program 
FilesMicrosoft SQL Server90Toolsbinn;C:Program Files
Rationalcommon;c:scripts;C:Program FilesjEdit;C:Program 
FilesQuickTimeQTSystem;C:Program FilesTortoiseSVNbin;C:
ipdsdevaxis2axis2c-rel-1.3.0lib;C:Program FilesJava
jdk1.5.0_16bin;C:jruby-1.2.0bin


Then save this to "road.bat" somewhere on your path:

@echo off
rem source: http://www.perlmonks.org/?node_id=757655
for %%i in ("%path:;=" "%") do @echo %%i


When you run C:\>road all those paths are nicely split and one-lined:
C:>road
"c:rubybin"
"C:Perlsitebin"
"C:Perlbin"
"C:OracleOraHome817bin"
"C:oracleproduct10.2.0gpdbin"
...


and you can do cool things like C:\>road | find /i "Perl" to find out where Perl is hiding.

To paraphrase the (brilliant) author VinsWorldcom, this one-liner

wraps the %PATH% ENV var in double quotes and then replaces all the semicolon separators with a double-quote, space, double quote. This effectively puts double quotes around all the paths (so spaces won't give any troubles) then use the for loop to list each newly double-quoted string.

Wednesday, April 29, 2009

Nice vim theme

Very textmate-y: IR_Black

Hollywood != Real World

This is why I boycotted Slumdog Millionaire:

Two months ago, the child star of the hit movie "Slumdog Millionaire" was worrying about what to wear to the Oscars. Now she has come home to a very different problem: How to get the fetid water out of her family's one-room shack.


Read the rest of the story.

Tuesday, April 28, 2009

Moved hosting DreamHost -> WebFaction

Following in Douglass Clem's footsteps (and thanks for the tip about scp), I migrated my domain hosting and this blog from DreamHost to WebFaction, for many of the same reasons. I wasn't unhappy with DreamHost, I just want to try out Pylons and WebFaction seems to be the place to be for that.

Wednesday, April 22, 2009

my .irbrc file

require 'irb/completion'
IRB.conf[:AUTO_INDENT] = true
IRB.conf[:USE_READLINE] = true
IRB.conf[:PROMPT_MODE] = :SIMPLE


\# call ri from within irb
def ri(*names)
system(%{ri.bat #{names.map {|name| name.to_s}.join(" ")}})
end

Thursday, March 5, 2009

How to make an empty file on Windows

To makes an "empty" file,  containing only a single newline, type this in a Windows command prompt:
c:\>echo. > somefile.txt

The dot immediately after the echo command outputs just a blank line to the file. I think this technique works for Windows NT and better.

Apparently you can also use the fsutil command to make a file of any size filled with zeros:
c:\>fsutil file createnew filename length

Monday, February 2, 2009

jEdit delete duplicate lines

In jEdit's Search and Replace dialog, select "Regular Expressions",  then Search for:
^(.\*)$\n\1

replace with:
$1

This tells jEdit to

  • start at the beginning of a line ^

  • find any characters, spaces, etc .*

  • up to the end of the line $

  • including a carriage return \n

  • that matches the text on the following line \1

  • then replace it with just the first matched line $1


The result is any lines that are duplicated will be replaced with just a single copy of the line.