Blog: 2009-08

Latest  2012  2011  2010  2009  2008  2007  2006  2005  2004  2003  2002  2001
-12  -11  -10  -09  -08  -07  -06  -05  -04  -03  -02  -01

Three out of Three eBay USB Flash Drives are Worthless

 [photo of three USB flash drives with labels indicating that they are broken] I now have three USB flash drives from eBay that were dead-on-arrival. The first reseller was kicked off eBay before my device even arrived in the mail. Then the drive that arrived Friday was DOA, as was the one that arrived Saturday.

Since I found it difficult to believe that Hong Kong would manage to send me three different models of drive, from three different eBay accounts, yet have all of the drives DOA, I tested the latest one on a different computer and operating system. It failed there, as well. Funny how the MD5 checksums for a file change almost every time. Friday's device did one better: in addition to selecting blocks at random to read, it actually generated kernel errors, and eventually put the process into a disk wait that kill -9 could not cure. I even verified that my old brand-name drive did still work, so my tests were not bad.

I do not blame China for this. The country that gave us such treasures as Jackie Chan and Ziyi Zhang would not knowingly sell me three bad flash drives in a row. Perhaps it is just one bad apple who is selling 512MB drives with hacked firmware as 16GB ones. Perhaps US Customs is irradiating the drives. Perhaps my Postal Service carrier uses a rare earth magnet to keep small packages from bouncing around and thereby being damaged in the mail bag.


Foodmaster

 [photo of two jars of Teddie peanut butter, one with a $2.39 Foodmaster price tag, and the other with a $3.19 price tag] This is a PSA for new MIT, Harvard, and Tufts grad students arriving in the Cambridge area. You can save significant money on groceries by finding the cheap grocery stores. It's not just Whole Foods, Harvest, and Broadway Marketplace.

In addition to adding farmers' markets, Trader Joe's, and Super 88 to your options, consider the cheap supermarkets like Foodmaster and Market Basket for packaged foods.

For example, Foodmaster has some of the same 100% peanut butter as Harvest, but you can buy 4 for the price of 3. Eighty cents saved might be inconsequential by itself, but who doesn't want to finish their doctorate a thousand dollars less in debt? Or spend it on airline tickets or a hobby.

Just don't go crazy with frugality and try to buy USB flash drives on eBay.

My Bash Prompt

I've been using Unix variants for a couple decades, with various command shells, but my custom shell prompt hasn't changed much. The current incarnation is in Bash. For visibility, it's in reverse-video on some terminals (some supporting ANSI X3.64 SGR), and delimited by square brackets on other terminals. It displays the current working directory. When I'm SSH'd in remotely, it also displays the hostname. And it displays an indicator if I'm in a Screen session.

I'm putting this snippet of code onto the Web to make it easy to paste into my account configs on clients' systems. You're welcome to use it yourself, if you'd like.

PS1=""
[ -n "$SSH_CLIENT" ] && PS1="\h "
[ -n "$STY"        ] && PS1="${PS1}SCREEN "
PS1="${PS1}\w"
case "$TERM" in
    linux|vt100|vt102|xterm*)
        PS1="\\[\\e[7m\\] ${PS1} \\[\\e[m\\] "
        ;;
    *)
        PS1="[${PS1}] "
        ;;
esac

Be sure to paste it somewhere that it's not executed unless the PS1 environment variable is already set, since PS1 being set is used as a convention for determining whether the shell is interactive or not. If you're starting out with a modern .bashrc, probably it already has that test.

mz Script for Quick PLT Scheme from Command Line

 [screenshot of mz script on a Linux command line] Sometimes I want to make very quick use of PLT Scheme from a command line, such as to perform arithmetic calculations or to verify the behavior of some language feature. Quicker than starting Emacs with Quack is to use my very simple mz shell script:

#!/bin/sh
if [ $# = 0 ] ; then
    mzscheme -il readline
else
    mzscheme -e "$*"
fi

Without command-line arguments, mz will start a PLT Scheme REPL with readline support. With arguments, mz will instead evaluate and print the value of each top-level expression in each argument, in order.

(Today I am experimenting with adding more links to blog entries, for the benefit of slightly wider audiences.)


Perils of Ordering Cheap Gadgets from China

 [photo of 3 gadgets with labels added to indicate that they're broken] Being, by nature, frugal about most things, I'm attracted to the cheap products sold direct from China on places like eBay and DealExtreme. Being also, by nature, engineering-inclined, I'm repulsed by many of those same products. Returning DOA product to Asia is usually not worth the shipping cost. So I mostly reserve these orders for things that are so inexpensive as to be worth the risk.

Even with my low expectations, I've been disappointed recently. Perhaps a couple weeks ago, I received a USB flash drive that was utterly unreliable upon arrival. (Writes to the raw device reported as succeeding, but reads that also reported as succeeding showed that the data was garbled at locations that varied randomly for each write.)

Before that, I received a camera case that had a big hole in the top, unlike what was shown in the product photo. They sent a replacement, which was for a much smaller camera. Fortunately, the case fit the next compact camera I got, whereupon the magnetic clasp seemed to be responsible for corrupting the SD card on the camera. So, the problem is not always shoddy manufacturing or poor quality control, but it can also be in order fulfilment and unthinking design. Magnetic clasp on a slipcase for ultracompact digital cameras?

Today, I received the retractable USB cable that I ordered for under a dollar. It did not work as a USB cable at all. When ordering, I bet that probability was in my favor, in a lightning-never-strikes-twice folk wisdom way, since the retractable 8P8C Ethernet cable that I bought before that was DOA. Visual inspection of the mini-B connector on the latest DOA cable suggested that it probably was not within mechanical spec. Rather than hope for third time being a charm, I'll probably splurge on a sturdy and high-quality 6-inch USB cable from a domestic reseller.

I want to be clear that I'm not criticizing all products manufactured China. Probably most of the electronics you own were made there. I'm speaking specifically of those products that are intended to be sold for a small fraction of what high-quality name-brand products (also likely made in China) sell for.

erin.el 0.6

erin.el 0.6 has a bug fix. Thanks to Michael Shields at Google for reporting.

Disable PLT Scheme JIT for Better Backtraces & Remember DrScheme

 [screenshot of DrScheme Backtrace window] So you're using PLT Scheme 4.0 from the mzscheme command-line tool, and you're getting some backtraces without using the old scary errortrace support. But the backtraces are more vague than you'd like, simply glossing over some important calls.

Matthew Flatt told me this a while ago, and it rates frequent mention: to get better backtraces, disable the JIT with the -j command-line option.

Just now (as I'm tweaking HtmlPrag's parser to not use mutable pairs), -j made the difference between this:

/home/neil/scheme/htmlprag/htmlprag.ss:1373:0: html->sxml-0nf

and the somewhat more helpful:

/home/neil/scheme/htmlprag/htmlprag.ss:1118:10: loop
/home/neil/scheme/htmlprag/htmlprag.ss:1373:0: html->sxml-0nf

In this case, that wasn't as helpful as it could be, so I used my handy make drscheme command to launch DrScheme on the code, which gave an even better backtrace.


HtmlPrag Works in PLT 4.x

HtmlPrag finally works in PLT Scheme 4.x.

I spent this Sunday morning reworking the high-level parser, which I first wrote in 2001, as my very first Scheme library. It relied very much on mutable pairs, which PLT 4.x does not like.

erin.el Emacs TWiki Mode Abandonware

 [shrunk screenshot of Emacs with erin.el sampler] I released a version of erin.el, my Emacs editing mode for TWiki, to mothball its current state.

The contract for which I was using TWiki was finished, and I haven't used TWiki in a while, so I don't plan on continuing work on erin.el.

Despite the frozen development, I'd encourage people to use erin.el. I found it indispensible for doing technical documentation that had to be in TWiki, and it still receives fan mail on occasion.

Chana Daal Redux

I used to cook Chana Daal, and then I forgot about it.

Well, here's remembering and resuming.

That page I linked suggests that it's a wonder food for people with diabetes, but even if you don't have diabetes (I don't), it's an almost-wonder food for the same reasons.

A four-pound bag is currently $5.99 from Shalimar in Central Square (Cambridge, MA, USA). Was $4 five years ago, but still a good deal.

Emacs 23, XFT, and Mode Line Minuses

 [screenshot of Emacs with mode line not showing lots of minus characters] Over the weekend, I installed the new Emacs 23, mainly to get antialiased fonts.

One noticeable downside to the new XFT-based text rendering is that it's very slow: on my modern dual-core x86 system, you can see the repaint progressively wipe down the window. It's like running Emacs in X on a workstation of 15 years ago. Running Emacs 23 in an rxvt that is also doing XFT-based rendering, however, has repaints that seem instantaneous. Hopefully they optimize that for 23.2.

Anyway, when tweaking my ancient Emacs config for 23, I threw out all my old highly-customized mode line code, which had some nice visual indicators, since I wanted to make sure I wasn't missing any 23 goodness. Then I kludged up something to remove the anachronistic line of minus characters that Emacs has always favored:

(defun my-tidy-mode-line-format (part)
  (cond ((stringp part)
         (let ((noprops (substring-no-properties part)))
           (cond ((equal noprops "--")  "  ")
                 ((equal noprops "-%-") " ")
                 (t                     part))))
        ((and (consp part)
              (not (memq (car part)
                         '(keymap local-map :eval :propertize))))
         (mapcar 'my-tidy-mode-line-format part))
        (t part)))

(defvar my-orig-mode-line-format mode-line-format)
(setq-default mode-line-format
              (my-tidy-mode-line-format
               my-orig-mode-line-format))

(defvar my-orig-mode-line-modes mode-line-modes)
(setq mode-line-modes
      (my-tidy-mode-line-format
       my-orig-mode-line-modes))

Note that I said it's a kludge; if I get time to do this correctly, I'll make a proper Emacs library out of it.

Earlier to... 2009-07

© Copyright Neil Van Dyke      Contact