Archive for John’s Rants

Hmm.. Do the IT folks question our sanity?

> Thanks for the awesome new printer, but I have one concern. It’s
> currently called ll-cube, which is fairly good naming. But now, before
> too many people are using it, is the last chance to give it a much
> better name. Can we rename it
> ll-cube-j? I mean really, the situation is just begging for it. This
> is a totally serious request. Let me know your thoughts.
>
> Don’t call it a comeback

ll-cube-j it is! 🙂

And there you have it — our local printer now responds to “LL-cube-j”

Advertisement

Comments (1)

Grsecurity & Ubuntu Feisty Server: Yay it’s working!

zsh in action

Grsecurity is a set of patches to the Linux 2.4 and 2.6 kernels that implements various security-oriented features such as stack randomization and permissions clamping to prevent common attacks against Linux systems from succeeding. I won’t go into an argument here about its effectiveness or its competitors, but I personally believe it’s a great defense barrier for public multiuser type systems.

Currently you must patch/compile manually, but that’s not the big roadblock… Sometimes turning hardening on too much will cause the system to fail to boot.

For Ubuntu, you need to disable CONFIG_COMPAT_VDSO in the kernel and possibly pass in “vdso=0” to the kernel at bootup via grub config. Otherwise, you’ll get the dreaded everything-segfaults-and-dies phenomenon. It looks something like this:

Segmentation Fault
Segmentation Fault
Segmentation Fault
Segmentation Fault
Segmentation Fault
Segmentation Fault
Segmentation Fault
Segmentation Fault
Segmentation Fault
Segmentation Fault

You get the point….

Once that’s done, I have been able to bump security level to HIGH with no problems whatsoever. It also helps to turn off kernel debugging in general, to avoid ridiculous 208MB large kernel packages!

Comments (1)

The Inova X1 3rd Gen Flashlight: Did they ruin it?

I noticed one of my favorite flashlight review sites a mouthful to say about Inova’s recently updated X1 flashlight. You’ve probably seen these flashlights at Target. They are sold in unique looking packages that allow you to try em out and go “oooh shiny!” Ok, let’s take a break from words and do picture time:

Ok, back to words. The X1 is a small-sized (4 inches long, like half an inch in diameter) LED flashlight that runs off a single AA battery. You can find them at your Target store for $19.99, though sometimes it’s cheaper online. It is, in my opinion, the best bang for the buck when it comes to a general-purpose flashlight you’d carry around in a backpack, purse, or car glovebox. It is one of the only lights in its price range that includes voltage-regulation circuitry that maintains a bright glow throughout the life of the battery — not a steady decay from the moment you put the batteries in.

Now, what’s up with the negativity? Well, in May 2007, Inova released an update to this light, that boasted “2.0 Watt LED“. Now, we won’t go into the marketing inaccuracies of “2W” , but let’s just call it a more powerful bulb. This more powerful bulb is supposed to be twice as bright, but eat battery life 4 times as fast. The battery life has been whittled from the previous 8 hours to a mere 2 hours, according to the manufacturer. Many people in the.. err… flashlight community… are quite upset at Inova’s decision, and so was I at first. But I decided to take a look for myself. I eyed a $15.00 deal at an online retailer, then took advantage of a $10 off Google Checkout coupon. So, at the end of the day, $10 left my pocket and here I have this cute little flashlight sitting on my desk. So, here we go.. I’m gonna review a flashlight. Pardon the lack of pictures, my camera’s battery is discharged and I’m not waiting for it to charge up 🙂

Initial Impressions, Look and Feel

Well, first: opening the box. Laugh at me all you want, but nothing sucks more than injuries sustained trying to open up packaging. I am glad to report that Inova gets my packaging seal of approval! Opening the box was effortless and did not involve any scissors or horribly mutilated plastic.

The light looks REALLY neat and is really easy to hold. I got the black version which looks very nice and sleek. Some simple bash-and-drop tests show that the light stands up superbly to impacts and scratching — so far it’s still unmarred. The light is really lightweight too — it is roughly the weight of a AA battery and a pen.

I loved Inova’s tactical tailcap switch. It’s a twist tailcap with… a twist (Ok, no puns, starting from now) . Twist the tailcap to the tightest position. The light remains constantly on. From there, twist it back around half a turn, until the light shuts off. This is the “instant-on” position. Pushing in the tailcap rubber piece activates the light for as long as you keep pressing. Twist the tailcap another turn out. This is the permanent-off position — perfect for packing in a tight bag. I found the tailcap to be very easy to use overall, though using the instant-on for extended periods of time will result in sore fingers. (You should really just lock it on if you’re using it for that long)

I’d rate a 10/10 for first impressions. Inova truly creates a visually stunning product that looks as good as it feels.

Performance

Note: This should go without saying, but DO NOT LOOK DIRECTLY INTO THE BEAM. It looks like a small scrawny light with a tiny little LED, but I guarantee you a direct look will blind you for a good minute, leaving you feeling very very silly.

Ok, let’s talk lighting. I went on a jog with the light at 10PM, when it was completely dark. On my usual jogging trail, there’s a few areas with extremely bumpy terrain and sudden stair steps. (On my very first run, I nearly tripped down some stairs! That taught me to bring a flashlight.)

So, how was it for navigating in the dark? I’d say “impressively good for its class”. Totally ignoring that this is a AA powered mini-light (I’ll refer to this as “blind” evaluation from now on), this flashlight provided excellent illumination that should be more than adequate for personal use. It was able to illuminate far enough to anticipate tree roots and broken sidewalk tiles even in pitch blackness at running speeds. It will definitely put your big C-battery dollar store flashlights to shame. It certainly isn’t the brightest light I’ve used — my previous, bulkier 3xAAA LED light was noticeably brighter and was able to illuminate further. Putting this flashlight’s size into perspective, I am extremely, extremely impressed. I never expected this much illumination out of a AA light, or even a 2xAA light. And I’ve owned plenty of little lights like these before.

As far as the physical light beam, it has a bright spot in the center, though has a well-illuminated circle that’s roughly 1 meter in diameter at a distance of 0.75 meters. The reflector has a matte/textured finish which helps disperse light more evenly. Even compared to a much more powerful/brighter LED light that I own, this inova was able to effectively illuminate a larger radius. Due to its somewhat lower powered LED, it’s not prone to the blinding reflections off closeby objects like a more powerful flashlight. These properties make this light also very useful for reading in the dark or working on something at night.

For lighting performance, I give it a 8/10 “blind”, a 10+/10 all things considered. I would not expect this level of performance out of a $20 light running on single alkaline AA’s.

For reference, the old one I would rate as a 6/10 “blind”, a 10+/10 all things considered, particularly considering the astounding battery life.

Battery Life

Ok, the dreaded topic… how’s the battery life? Well, I’ve ran two full drains today with the included alkaline battery and also another brand-new name-brand standard alkaline AA. Both consistently lasted roughly 3 hours till most people would call the battery dead for sure, 2:30 until I called it unacceptable.

How’s the discharge curve? Unscientifically, I did not start perceiving “Uh oh, the light’s dimming” until about 2 hours, at which point I could tell that the light was definitely brighter when the batteries were new. At 2:30, it was getting to the point that I had difficulty navigating with that level of brightness. At 3 hours it was basically poof. However, for the first two hours, I’d say the claim of “constant” brightness is pretty much accurate. I’m sure an intensity meter will prove me wrong, but I really don’t care. After all, it’s how I perceive it that ultimately matters to me, not what an Excel graph tells me.

So… what’s up with the 2:30 runtime? This is surely a disappointment from the 10 hour runtime before, right? I wouldn’t say so at all. In my opinion, the new bulb does add significantly noticeable brightness, particularly when illuminating things at a distance. In addition, 2:30 is not that bad at all. Every two hours, you have to pop in a cheap, commonly-available AA alkaline battery. I don’t see the big deal in that. If it were a CR-123A based light where a battery replacement at the local convenience store would cost me $10, then I’d expect the damned thing to run for 25 hours!

Final Verdict?

Did Inova ruin their wonderful entry-level flashlight? No, not at all. With regards to the new bulb, they simply made a trade-off of battery runtime for brighter light. Overall, I like the new reflector’s ability to spread light out more evenly. If someone were to ask me for a recommendation on a general-purpose flashlight, I wouldn’t hesitate to recommend the Inova X1.

Overall Rating: 9/10.

For what you pay for? 10/10 hands down.

Pros: Reasonable price, small and portable, attractive apperance, durable, waterproof, satisfactory lighting, innovative switch, and lifetime warranty.

Cons: Some will say it’s dim: this is not a uber-bright sun replacement. It’s a personal flashlight that is inexpensive and runs off a single AA battery! Shortened Runtime: True, the runtime is drastically shorter than before, but I think the tradeoff was worth it, not to mention replacement/spare AA’s shouldn’t be hard to come by!

Comments (8)

zsh: The last shell you’ll ever need!

Introduction

Last week, the all-knowing Mako inspired me to give zsh a shot. He started me off with a .zshrc file, and now a week later, I’ve been spreading the word to as many people as I can. But let’s rewind a bit.

First off, the basics: I expect most of you to be familiar with what a shell is. A command-line shell is a user interface to the operating system. For all practical purposes, you know it as “the thing that you type commands into”. There are many, many shells to choose from, and most *nix’es come with different default shells too. Arguably, the most popular shell in use today is the GNU Bourne Again Shell, better known as bash. The other main family of shells is known as the C shells (csh, tcsh) — named after their C-like scripting syntax.

So what’s zsh and why would I want it over my current shell?

The shell I am raving about today is the Z-shell, or zsh. Zsh is an expansion on the Korn shell (ksh), which is an expansion on bash. (UPDATE: The previous statement, as pointed out by a lot of readers, is incorrect. ksh existed before bash, and if anything bash was inspired by ksh. I was merely going by the feature lists and noticing that modern ksh is a lot more capable than bash, and thereby assuming this relationship. I will leave the statement there because changing it might “look bad”).  It is one of the most full-featured shells you can ask for, and I would go as far as to say that everyone has something to gain from using zsh. Particularly if you have stuck with bash or your operating system’s default shell, I strongly recommend you give zsh a shot! What do I like about it?

  1. Acts extremely similar to bash. You can use zsh exactly the way you use bash and not learn a single thing, and even then it’s an improvement! Compatibility with familiar shells is very important. Switching from bash to zsh is not going to be like switching from GEdit to vim. You’ll be instantly at home in that all your bash shortcuts/commands will work as expected, but you’ll also have access to zsh’s goodies. If you’re a shell scripting addict, you’ll be pleased to know that zsh’s scripting syntax is mostly backwards-compatible with bash, too.
  2. Typo correction. How many times have you typed something like aptg-et or other mangled commands? Well, if I do that in zsh, I get a message asking: “zsh: correct 'aptg-et' to 'apt-get' [nyae]? “. Magical, isn’t it? This autocorrect also applies to any parameters or paths or filenames you type.
  3. Phenomenally intelligent tab completion. Wait… I hear what you’re saying already. “Duh you idiot, bash does this too! You just need to uncomment/install bash-completion.” No, that’s not what I mean. Can your bash:
    1. Present suggestions in a menu that you can browse by arrow keys?
    2. Complete the kill command by showing a menu of all your processes?
    3. Complete the aptitude or ls commands by showing a menu of relevant parameters and a short description of what they do?
    4. In addition to exact matches, show also near matches in a separate section?
    5. Pop up completion options even for complex commands virtually instanteously, without bash’s dreaded “UH OH I should’ve typed a few more letters first!” delay?

    If you could say yes to any of these questions, then please let me know! Because after 3 years of using bash, my bash sure doesn’t!

  4. Share history across sessions. Multiple simultaneously running zsh sessions can share history with each other, rather than clobbering each other up. One of the most frustrating things to a bash user is typing in a long command, then searching for it again the next day via Ctrl+r, only to find it nowhere in the history.
  5. Built in pager. I’m a lazy person. And I think you are, too. zsh comes with a pager directly in the shell. This means you can type things like <README and it is equivalent to less README or cat README | less
  6. More powerful globbing. Globbing is the fancy term for “wildcards on steroids” — your matching expressions like “*.c” or “*Office*S03E[0-2][0-9]*.avi” and so on. As the zsh introduction shows, zsh gives you way more powerful globbing expressions. You’ll rarely find yourself forced to whip out the find command or a GUI search tool.
  7. More bearable scripting language. If you’re not a shell scripter, you probably will have no idea what I’m talking, but all you shell scripters out there: Say goodbye to all those bash gotchas. How many times have you been bitten by a statement like [ $FOO = $BAR ] erroring out because FOO or BAR were empty, and then having to resort to silly tricks like [ x$FOO = x$BAR ] . Well, zsh has rescued you with its double-bracked comparisons. [[ $FOO = $BAR ]] will always work, and [[ $FOO && $BAR ]] comes a lot more naturally than [ $FOO -a $BAR ]. I can’t even begin to scratch the surface of zsh’s programming capabilities, but I encourage you to give it a shot!
  8. A lot more. Remember, I’m a beginner too. I have just hit the tip of the iceberg myself. Consult zsh’s wonderful documentation (which I will link to later) for everything you want to know about zsh.

Ok, You Convinced Me. How Do I Start Using zsh?

Excellent! Glad you decided to give it a chance. Unfortunately, zsh won’t do everything I just raved about when you install it. In fact, by default it’s quite bland. I recall two years ago, I heard some buzz about zsh, so I installed it and fired it up, and thought to my self “WTF is this crappy thing? It doesn’t even have tab completion! I’m going back to bash.” To get zsh to do magical things, you need to configure it by a file called .zshrc. This is the analog of bash’s .bashrc or csh’s .cshrc (which is, by the way, not a city in Bosnia). The way most people begin populating this file is by googling for zshrc and using someone else’s as an example. Well, I’ve got some of my own zshrc files too, which I based off Mako’s and various googled zshrc files, so I do not in any way claim any credit to these creations. So, let’s get started:

  1. Install zsh from your distribution. You should consult your distribution’s package manager (yum, apt-get, Synaptic, Portage, fink, you know the drill) because they most likely have it packaged. There are generally two packages, a zsh and a zsh-devel or zsh-beta package. The beta package is newer and contains new features and enhancements, but may have bugs. I personally use the betas and have yet to have a problem, but this choice is up to you. Both work great.
  2. Grab a zshrc file. You can either google-and-build one you like, or start from my sample ones:
    1. Linux:This is the standard one I use on my Linux machines. I run Ubuntu but I didn’t put anything distro-specific in there.
    2. Mac OS X: This is almost identical to the Linux one, except it fixes the behavior of the delete/pgup/pgdn/home/end keys and has a prompt color scheme for black text on white background display schemes (because personally I find that looks better on my Macbook)

    This file should be saved at ~/.zshrc; that is, a file called “.zshrc” in your home directory.

  3. Enjoy, read documentations, tweak to your heart’s content! Please, go to zsh’s homepage and look around the documentation for more tips and tricks. I’m a newbie to zsh — I can’t teach you much about it because I’m learning as we speak.

Additional Resources

If you like what you see but this has left you with more questions than you started with, please seek out these wonderful documentation resources:

  • zsh Homepage. Here you can find links to a lot of good resources.
  • zsh Introduction. A really quick read to give you a good overview of zsh’s abilities.
  • zsh Guide. This is a longer guide but geared towards comprehensively addressing zsh from the user’s standpoint.
  • zsh Manual. This is a really long manual that covers everything you’d want to know about zsh, particularly if you’re a scripter you’ll like this one!
  • zsh Cheatsheet. For the lazy and impatient! (though it’s upside down… sorry, not my fault!)
  • zsh FAQ. Great for those whiny questions that go like “Waah, why does zsh do X and Y differently from my old shell?”
  • zsh Wiki. Community-contributed and maintained documentation, tips/tricks, zshrc’s, extensions and addons.

P.S. Avoid the temptation to spend your next week locked in your room playing with zshrc. It’s really not healthy… (By the way, should hostname be colored $PR_BLUE or $PR_GREEN in the prompt? I’m still contemplating that in my zshrc!)

Comments (51)

Why aren’t you using ionice yet???

I am surprised at how many people complain about IO responsiveness while multitasking, but have never heard of ionice(1). Most intermediate-level Linux users have heard of, or know how to use, the nice command. Well, ionice is like nice for the disk (nice on most Linux kernels only affects the CPU scheduler. So, a large copy operation with the maximum niceness can still ruin disk response times to a process on highest priority.)

The best usecase for using ionice to improve performance is when you need to do two classes of tasks at once: The ones that don’t use much disk IO but demand fast response, and the ones that do a LOT of disk IO but don’t need it done urgently.

For example, think of some of the time-consuming things you want to do in the background, like:

  • Downloading a torrent on a fast internet link that creates a great deal of disk seeking.
  • Copy a huge file between two locations
  • Perform a system backup
  • Install your latest set up system updates

Most of the time, you really don’t care how fast (within reason) these tasks take, as long as your desktop applications don’t lag like hell! This is where ionice comes to the rescue. You can, in effect, tell Linux to only give disk access to these programs when nothing else wants it.

The command for doing this is sudo ionice -c3 -ppid, where pid is the numeric Process ID of the task you want to reschedule. You can find this number by looking at your GNOME or KDE process list viewer (also called System Monitor), or via top, ps -aux, and other command line tools. The -c3 part places the process in the idle scheduling class. You can read the ionice(1) man page for more cool things you can do with ionice.

Now, one trick you might find handy is rescheduling an entire parent shell to idle class, so that all commands executed from that shell are idle priority. You can get this from the $$ shell variable in bash and sh. For example:

jdong@severance:~$ echo $$
29033

This output means that my current bash shell is process id 29033. If I want to switch the whole shell to idle disk priority, I would run:

jdong@severance:~$ sudo ionice -c3 -p$$

And there we go! Everything I do in this shell is now idle priority. Let’s apply this trick to other case. Ubuntu and other distributions like to run disk-intensive scripts like updatedb every night at midnight. If you’re a night owl like me and use your computer at these hours, this can be terribly irritating. Well, ionice to the rescue! Open up /etc/cron.daily/slocate, and add the following bolded line:

#! /bin/sh
ionice -c3 -p$$

if [ -x /usr/bin/slocate ]

And now, updatedb will no longer lag your productive midnight computing activities!

Now of course, there are a couple gotchas with ionice:

  1. It only works on kernels 2.6.13 and later using the CFQ IO scheduler. Kernels 2.6.17 (Ubuntu Edgy) and later, plus most versions of Redhat/Fedora-based distributions , will use the CFQ IO scheduler by default. You can check what scheduler is running by running cat /sys/block/[sh]d[a-z]*/queue/scheduler. The word outlined in [brackets] is currently selected. Use the boot parameter elevator=cfq in grub/menu.lst to set cfq as default.
  2. Idle priority is VERY cautious about marking block devices idle. If your foreground tasks are using disk, then your background tasks will become noticeably slower, as they get blocked from touching the disks until Linux knows for sure your foreground tasks have all had a chance at the disk. Most of the times, you don’t care about this anyway, but don’t run a torrent in non-idle class and expect a 20GB copy to finish till the torrent’s done!
  3. Please be careful fooling around with other ionice options, particularly the realtime class. You can easily set a process to receive the disk’s full attention and freeze your system. I’m not responsible for any hard reboots you have due to this.
  4. Some filesystems, particularly reiserfs and XFS, are very unfriendly at hogging the disk while performing metadata operations (such as creating or deleting files). Even ionice may not save you from noticeable disk IO lag during heavy metadata activities.

Comments (26)

I just died a little inside…

Lesson of the day: Don’t read digg. Apparently to a “Visual Diff Tools for Linux” reviewer, the “diff command in itself if not very useful for visual inspection of differences.”

EXCUSE ME?

Leave a Comment

Seeing Yellow, or Seeing Secret Service?

How many of you know about those yellow tracking dots that are printed by most color laser printers? They are apparently put there by request of the Secret Service in order to track counterfeiters. However, they contain personally identifiable information on every color printout. Here’s a scanned printout from an HP Color LaserJet. No, it’s not photoshopped, and no, we weren’t trying to print yellow dandruff.

An example of tracking dots from an HP color laserjet, scanned into a 600DPI scanner.

In this case, HP’s code for the dots has not been decoded, but EFF has decoded the Xerox code. We are recommending that if you own one of these printers, you call up your printer manufacturer and ask them how to turn it off, or at least express concern for this massive violation of privacy!

But be careful though… one person reported that after calling his printer manufacturer about the dots, he was paid a visit by the Secret Service! Big Brother is watching, but this time Big Brother can print 3000dpi crisp color printouts at 22 pages per minute, too!

Leave a Comment