Planet Larry

June 12, 2008

Jason Jones

My First Python Script

When I went in to my 6 month review about 4 month ago, I didnt know what I was in for.

I assumed things would go well because I had accomplished everything I set out to do and more, so I felt pretty good.

The interview went very well.  They complimented me on my work, the sales reports, the new web site, the money I was saving the company and all that.  Then he asked me what my goals would be for the next 6 months.

I didn't anticipate that, so, I asked him what he meant (read: stalled while I frantically thought of something I could do in six months).  He responded while I didn't listen at all - thinking.

About the time he was done saying whatever it was he was saying, the thought popped into my head, "Hey!  I'll try learning a new language!".

In the IRC room I lurk in daily, #UPHPU, the python language frequently was the subject of hot debate, so I blurted out,

"I'll learn Python."

And that was that.  Well...  It's now 4 months later, and the perfect opportunity presented itself for me to see what this Python is all about.

We received the old servers upon which the old website ran from the old company with whom we do no business anymore, thereby barring ourselves from further thievery.

I took a look at these servers and realized they are much beefier than the ones currently running the server.  So, my boss and I decided to wipe off the dross currently installed on them (read: Windows 2003 Server), and installed gentoo with a healthy LAPP stack on em'.

Well, the last thing I needed to do to get these suckers fully up and running was to install some sort of RAID monitoring system.  The old servers had the mdadm program taking care of the RAID.  These boxen have hardware RAID controllers on them, so using the mdadm monitor was out.

To make an already long story shorter, suffice it to say I found a program called cciss_vol_status which seemed to do the trick nicely.

I just needed to find a way to run it every day and email me the results.

Needless to say, this is where Python comes in.

My first impressions of Python, coming from PHP, of course, are the following:

  1. It seems very complicated.

  2. Why the need to import modules which PHP has natively?

  3. The learning curve for something new always sucks.  Thinking to myself, "I could have had this done 2 days ago, if I was doing it in PHP"

  4. Its syntax is radically different, and oddly attractive to me.

  5. From my noobie standpoint, it seems that Python has the potential to be much more powerful than PHP - after the learning curve.



Basically, I began writing the script yesterday, and worked on it for about 5 hours.  I finished the script after about 1.5 hours working on it today.  I'd have to say that 90% of the speed with which I finished it was due to the tutorials written online for the specific modules I needed.  The #python IRC channel provided a few clues as well.

Anyway...  I'd like to continue learning Python, but I'm not sure how suited it would be to web development.  I've got my nitche down really well within PHP, and it'd be a shame to stop that to learn something new - just for the sake of learning it.

The flip-side, however, is that with my knowledge of python (if I should choose to pursue it and learn it to the degree I know PHP), I'd be in a much better position to continue marketing myself.

We'll see.

Anyway...  That's today's story.

Life is good.

June 12, 2008 05:09 PM :: Utah, USA  

Luca Gasperini

Superkaramba and Gentoo

Nowadays it seems that superkaramba works well, in the past it was heavy and buggy and I used to have conky. There are no particular reasons that made me switch to superkaramba , other than moving from Gnome to Kde.

My superkaramba monitor is based on the dual cpu monitor by Loacoon, I changed it a little to show some useful stuff , some of them gentoo specific ( last sync, last emerges, currently emerging….. genlop is a dependency).

superkaramba

Here’s the code, on my system superkaramba themes are in ~/.kde3.5/share/apps/superkaramba/themes/

Superkaramba theme

June 12, 2008 03:21 PM :: Italy  

Thomas Keller

Ruby on Rails, part 2

OK, after I installed a first RoR testing environment on my home server, I started experimenting. Now I finally managed to have an application up and running - although it’s just a rough test app…. Thanks to vinniez, I also installed passenger (it in portage - masked, but working!) and went on like this: added the “-D [...]

June 12, 2008 02:38 PM

Sean Potter

New Car Stereo

I finally took the plunge and had a car stereo installed in my 1998 Chevy Prizm. It's a cheap Sony model, but it has a detachable faceplate and front auxiliary input. The auxiliary input is what I was after, however. Unlike my old car, a Dodge Stratus, the Prizm doesn't have a tape deck or CD player. I was forced to play my music over an FM transmitter that ate two AAA batteries every two-to-three days. Modern technology, eh?

I eventually broke the transmitter and started listening to the radio, which gets repetitive. Amanda suggested getting a car stereo, so I finally gave in and had it done. Rather than spending a few hours putting the wiring hardness together, I had the fine folks at Circuit City do it for a small fee.

It works great. Now I just need to fix my air conditioning or buy a new car. Greeat.

June 12, 2008 08:31 AM

David Grant

Cleaning out my RSS Reader

I love Google Reader and I love reading about the latest in technology, politics, you-name-it, but I have a ridiculous number of feeds and they are just too much of a time sink. I need some way to clean them out so I can have more time to do other more important things.

One idea is to borrow from a technique that I have used to get rid of new clothes: go into your closet hang all the hooks backwards. Whenever you wear a garmet hang it back up in the closet in the usual way. n months later, take the garmets that are still hung backwards and donate them to the local thrift store. I can't remember where I got this idea from, but I think it might have been from lifehacker.com (whose feed I am subscribed to).

For feeds, I was thinking maybe I could create a new label called "keeper". Whenever I read a item from a feed that feel I could not have lived without reading it, that feed gets labelled with the "keeper" label. n months later, I can toss out all the feeds that do not have the "keeper" label.

Alternatives to using feeds:

  • Go to the website for the feed and look at the most popular articles in the past week or month. This isn't always possible with all feeds.
  • When you need to know how to do something, just google it, rather than subscribing to a feed of how-tos (like lifehacker.com for instance). Pull rather than push.
  • Go to a site like reddit.com or digg.com when you have some free time, otherwise, don't worry about all the stuff you might have missed.

June 12, 2008 01:06 AM :: British Columbia, Canada  

June 11, 2008

Jürgen Geuter

Marketing through blogs

Marketing is old and I guess it won't go away very soon (though I'd love it to die) and especially with the advent of blogs many people started wondering how to make money from all of this.

The first idea was to make their blogs utterly worthless by plastering banners and advertising all over it. This worked for a while, but nowadays random ads don't really pay a lot unless someone clicks on them and many people have adblocking software running either on their computer or their brain. Ads are pretty much dead at least in the way that most people know them.

But with everything having to have a pricetag attached to it (cause if there's no money to be made it has to be utterly worthless, right [yes, that is sarcasm]) people had to come up with new ways to place their marketing in the stream of information. This lead to one of the most filthy kinds of advertising: The "pay per post" advertising.

The idea is simple: Some company pays you a few bucks to write over their product. Usually the claim is also to not force people to write a positive review (ignoring the fact that many of the people selling their own personal place in the web for peanuts are usually so thankful for the few bucks that the review will be at least somewhat positive), because the review itself ain't all that important, it's about getting your service linked which means more google rank which means more "importance" when it comes to searches in google.

We see this type of marketing a lot, not only by advertising companies but also by people wanting to promote their little blogs: You start a competition and force everyone to link to your blog post to participate which gives you rank and importance (and your advertising income might raise from 1 buck/month to 1.50).

Now I can see why people do it, hell, I'd love to be able to be able to live by just writing my blog (and that would bring up the posting frequency ;-) ) but there's always a cost and when it comes to your own blog the cost is high.

I have written about the importance of your feed before (pretentiously quoting myself):
Your website's RSS feed is as important as your business card, as your "real" website, actually it's replacing your real website more and more. Having a broken or nonfunctional RSS feed is probably even worse than having none: If you have none some people might not check your site regularly but at least you don't look incompetent.
But what about your own blog?

Well, there are two kinds of blogs: The commercial ones and the personal ones. It's really that simple.

The commercial ones are the "big" ones nowadays. Techcrunch, endgadget &ct. People there make a living of their blog, but they're not so much about creating really new content, they are basically about sales. They run reviews of stuff, they keep the buzz around certain companies or products going, they are completely unpersonal. Those blogs are not what I'd really call a blog anyways, they are basically just a different layout for "news" and "adverts" and "reviews" from a certain section of the market. Yes, they do have comments and sometimes use blogging software but they are dead as in lifeless.

On the other hand you have blogs by people, writing about stuff they care about, stuff they find interesting. Stuff that often no one would bother to pay for, though it can be brilliant. Or boring. It can be anything and that's exactly what makes them interesting: They can be everything the writer wants them to be. They are very human, very alive because they are not limited to some faceless, brainless, soulless market. They can show you what is cool about humans, they show every facet of human being.

As soon as you start letting people buy parts of your blog, you leave the second and enter the first realm. Your blog loses what made it interesting in the first place because you sold your integrity. Now if you just write iPhone reviews or crap like that, integrity ain't your business anyways (though the writes of those sales-campaigns would probably disagree), but if you want your blog to be yours and meaningful you just cannot have ads in them, ads of any kind.

Because how could you be trusted? If you sell posts, who tells me that the post I'm reading was not paid for? Who tells me that the post I read yesterday was "real" as in "written because the author really wanted to say this"?

It's been said many times, but advertising makes your blog look cheap. Because then it actually is. It's up for sale.

Just think about that the next time some blog starts a "competition" with a few prices in exchange for links or posts.

June 11, 2008 02:04 PM :: Germany  

Leif Biberg Kristensen

Regular expression fun in PostgreSQL

I have been doing a bit of refactoring again. This time, I’ve moved the link_expand function from PHP into Postgres. That’s the function that takes a piece of text like [p=123|John Smith] and transforms it to a fullblown internal link like <a href=”./family.php?person=123″>John Smith</a>. It’s very convenient to write links this way. Now, regular expressions work a bit different in Postgres than they do in eg. Perl. The Postgres regex engine is actually ported from Tcl, as explained in the documentation. So, there’s some relearning to do for an old Perl regex punk. Notably, the difference between greedy and non-greedy expressions is subtle and easy to miss. Note the expression E’\\[p=(\\d+?)\\|(.+?)\\]’ below. In Perl syntax, you shouldn’t have to make the (\d+) atom (any old integer in plain language) non-greedy, but it’s required here.

Here’s the full link_expand function in glorious plpgsql:

CREATE OR REPLACE FUNCTION link_expand(TEXT) RETURNS TEXT AS $$
DECLARE
    str TEXT;
    tmp TEXT;
BEGIN
    -- the easy part: replace [p=xxx|yyy] with full link
    str := REGEXP_REPLACE($1, E'\\[p=(\\d+?)\\|(.+?)\\]',
            E'<a href="./family.php?person=\\1">\\2</a>', 'g');
    -- the hard part: replace [p=xxx] with full link
    WHILE str SIMILAR TO E'%\\[p=\\d+\\]%' LOOP
        str := REGEXP_REPLACE(str, E'\\[p=(\\d+?)\\]',
                E'<a href="./family.php?person=\\1">#\\1#</a>');
        tmp := SUBSTRING(str, E'#\\d+?#');
        str := REPLACE(str, tmp, get_person_name(BTRIM(tmp, '#')::INTEGER));
    END LOOP;
    RETURN str;
END
$$ LANGUAGE plpgsql STABLE;

(if you picked up an early version of this blog post, you may have noticed the subsequent “folding” of the three lines:

p := BTRIM(tmp, '#')::INTEGER;
name := get_person_name(p);
str := REPLACE(str, tmp, name);

into one:

str := REPLACE(str, tmp, get_person_name(BTRIM(tmp, '#')::INTEGER));

and, as a consequence, I’ve dropped the two superfluous vars p and name. It’s more compact, but of course also a little more obscure.)

The “hard part” still looks somewhat circumventious, but at least it works. And I do think that it’s a lot cleaner than the old PHP function with its forest of backslashes.

The main reason why I did this refactoring is not about code purity, though. There seems to be a bug in the PHP preg_replace() function that will only allow it to replace about fifty of my shortlinks in a given text. Given more shortlinks, it will just drop the entire text in the bit bucket. That may seem a lot, but, hey, do you remember the old “640K should be sufficient for everyone” meme? When you try to link up every person in a lenghty probate transcription, preg_replace() will run out of steam. It’s probably a memory allocation thing. However, I do expect the Postgres RE engine to be a lot more sturdy than the PHP one.

June 11, 2008 09:40 AM :: Norway  

Brian Carper

Westinghouse still sucks

Way back in March I sent in my L2410NM monitor for RMA to Westinghouse. This is June and I don't have it back yet. Last I heard they sent my case to their corporate office. I called again this week, call #16 or 17, I lost count, and I was told that they put in a request for a "status update", but having heard any update on it. I'm always promised a return call, but I've yet to receive even one of those. As of now they've promised to send me a new monitor and have given up hope of ever recovering my legendary lost monitor, and supposedly they even created the order in their system that will initiate the monitor-sending process, complete with a long string of letters and numbers representing my fates.

I almost wish they would say "Ha ha, just kidding, screw you customer, you're not getting anything from us" so that I'd feel justified in filing a complain with the BBB. But no, they keep the carrot dangling in front of my nose, inching closer and closer to resolving this issue. Likely I'm going to do so soon though. Not sure if it'll actually help anyways.

I've already ensured that my friends and family will never buy anything from them, nor will my place of employment, and hopefully some people reading this will also refrain. The real problem is, what company is any better? I keep a mental list of companies that have screwed me over, but that list is becoming so large that I'm running out of companies I can actually buy things from. I can at least prioritize according to the level of suckiness. Westinghouse tops the list at the moment.

June 11, 2008 02:55 AM :: Pennsylvania, USA  

Iain Buchanan

8bit paintball

This is damn funny! Especially since my state has just legalised paintball (no-one has set it up yet though - I'm waiting...)



And now for the gratuitous ad. which I nicely didn't remove:

See more funny videos at CollegeHumor

For those RSS and syndicate followers, try this link!

June 11, 2008 12:44 AM :: Australia  

Gentoo Linux Live USB key

I didn't believe my friend when he told me how easy this is, and yet he was right! From live CD image, to bootable USB key in only a few minutes!

Here's what I did, you may need to tweak it a bit for your setup. Firstly I used one 1Gb USB key / thumbdrive / flashdrive / whatever, because I use the live CD image. You could use the minimal CD image and use a smaller key. It appears to me as /dev/sdb.

0. dd if=/dev/zero of=/dev/sdb bs=512 count=1

The reason I did this is because I had corrupted both the mbr and partition table of the usb key. fdisk simply told me "unable to seek on /dev/sdb" and wouldn't continue. Skip this step if you can fdisk ok.

1. fdisk -l; fdisk /dev/sdb; fdisk a partition!

I join these steps together, cause they're all related to creating the partition. Make one partition covering the entire device. Something like "n p 1 t 1 83 a 1 w" should do it. Note I made it bootable, and I'm not using FAT.

2. mkfs.ext2 -L liveUSB /dev/sdb

You'll notice I'm using ext2 here. Wait for the device to finish writing, then unplug and re-plug it, or mount it manually.

3. sudo mount -t iso9660 -o loop /home/iain/Desktop/livecd-i686-installer-2008.0_beta2.iso /mnt/tmp/

There are multiple ways to do this. This is the one I chose.

4. sudo rsync -avP /mnt/tmp/ /media/liveUSB

5. sudo grub-install --root-directory=/media/liveUSB --nofloppy /dev/sda

6. reboot!


Remember to set your BIOS to boot from your USB drive. Now you have a live CD on a USB key. Much nicer than burning!

YMMV.

June 11, 2008 12:06 AM :: Australia  

June 10, 2008

Daniel Kerwin

New Howoto: Using the Vodafone PCMCIA UMTS card (Qualcomm MSM6275)

Just finished a small howto explaining how to use a Vodafone PCMCIA UMTS card with (Gentoo) Linux. Works very well and will work in less than 5 minutes. If you own this nice piece of hardware give it a try.

Go directly to the Howto

Thanks to Matthias for supplying me with many information's on this topic.

June 10, 2008 09:06 PM :: Germany  

Jason Jones

LDSCompanion.org Comment

For those of you who don't know, in addition to running ILoveMyJournal.com, I also run an inspirational website called LDSCompanion.org.

Today when I arrived at work, I had an email from someone who had pressed the "contact us" button.

The message I recieved encapsulates the entire reason I created that site, and caused tears to well up, as well as a sense of gratitude for having been given the gift of being technically adept.

Here's the message as it was sent to me: (the name has been removed for privacy)

"My name is (name not published), and I live in a little island in the caribbean by name San Andres. I was baptize the 11 of october of 1997 in Bogota-Colombia; but since april of 2003 when I return home I have loss every direct contact with the church because they are no members here and it has been really hard. Now I have acces to a computer and the opportunity to can read and nurture my spirith throug the motivational stories, inspired poetry, etc of thes web-site. And I know thah our Heavenly Father cares for each a every one of us and bless us, and answer us in misterious ways, thank you for being an instrument in his hands."

Point of the story is, you never know how many people your righteous example might affect.  Do the right, do it always, and unknowingly enlighten everyone around you.

June 10, 2008 11:05 AM :: Utah, USA  

June 09, 2008

Jürgen Geuter

Thinklab



This is a picture of my "lab" which is a setup of a bunch of (old) thinkpad laptops I got from a client to try out some network stuff (working on testing skolelinux for a local school). It's like a forrest of thinkpads. Fun! Let's hope they breed :-)

June 09, 2008 09:34 PM :: Germany  

Dirty urges...

For a few days I've had the urge to write something in PHP. What the hell is wrong with me?

All jokes aside, I think I'm not a "one language" kind of person: Python is still the language I find the most elegant and pleasant to work with but sometimes you just want something else, something quick and dirty I guess and for that PHP is perfect.

June 09, 2008 07:58 PM :: Germany  

Jason Jones

Video Editing With Kdenlive

I've recently become interested in integrating video into my journal and blog.  As such, I realized that my 4-year old digial camera just wasn't gonna cut it anymore, so I went out and bought the cheapest camera I could find that would shoot 30 frames per second which happened to be the Nikon S210 digital camera.  It takes pretty good video.

Then, I began the search for any video editing software on Linux.  I had created a video using Kdenlive a couple of years back, but I remembered it being a pain to use.

Long story short, after using about 6 other obscure video editing software programs for Linux, I came right back to Kdenlive.

To begin, the most valuable piece of advice I can give you at this time about using Kdenlive is this:

SAVE YOUR WORK EVERY 10 SECONDS.

Then you'll enjoy working with it much, much more.  Kdenlive will randomly crash, losing all unsaved work.  The crashes happen from 15 seconds, to 2 hours - man, it SUCKS losing 2 hours of work, so, save your work often.  If it does crash after a save, the saved portion of my work always came back without a problem.

Besides the totally random crashes (I worked on Kdenlive straight for 3.5 hours with no crashes, once), the biggest gripe I have about this program is the total inability to configure or manually modify the video format for the project.  You are limited to what the developers think you need.

For me, this creates a bit of a frustration because my camera shoots at exactly 30 FPS, not 29.976.  Well, there's no option for me to open a project where the video will work at 30 FPS, which makes me have to re-encode all my raw footage to 29.97, in order for the A/V sync to stay spot-on.

But the first item of business is to let you know how to start the program itself.  If you just type in "kdenlive" in a terminal, or click on it on some GUI menu somewhere, the MLT framework (upon which kdenlive is built) will default to PAL standards, which for people here in the good ol' USA, is no good at all.  Use the following command to begin the program, and it'll save you loads of headaches:

MLT_NORMALISATION=NTSC kdenlive

That'll help a lot.

the next necessity for good video editing with Kdenlive is to have footage which fits one of the pre-configured settings in the project.  If you don't, your video will look fine, but the A/V sync will drift, making the footage useless, and causing you to rip your hair out.

For me, since my footage is all at 30 FPS, I run the footage through ffmpeg to get it to 29.97, and then it works wonderfully.  Here's the command I use:

ffmpeg -i input_filename.avi  -b 10667.6k -r 29.97 -ar 22050 output_filename.avi

That should do the trick (at least for video recorded at 30FPS at 640x480).

After all my footage has been massaged to fit the requirements of Kdenlive, I then start the project and make sure the project video format is Square NTSC, which fits the precise resolution, and FPS of my footage.  I do this by clicking on Project->Configure Project, and then this box pops up:



From there, it's smooth sailin'.  You just edit your video like you normally do, remembering to save every 10-20 seconds.

When you're ready to export your masterpiece, you've got about 2000% more options than you do importing your footage.  This is good, and bad, as I've found half of them to completely mess up the exported video.

What I have found to work is the following:

I export the video by clicking on File->Export Timeline and then an export box pops up.  From there, I choose the "Medium" tab, and then mpeg4->640x480->High.  It looks something like this:



From there, I export my video (my last one was a 12-minute video and it took about 4.5 minutes to export).

After the export, I run it through ffmpeg once again to convert it to the correct resolution to fit in my flowplayer flash video player widget I use for this site, and then I'm done!

Here's the final ffmpeg command:

ffmpeg -i input_filename.avi -f flv -b 700k -ar 22050 -s 450x338 output_filename.flv.

And that, my friends, seems to work for me quite consistently.

Hope it helped.

June 09, 2008 10:33 AM :: Utah, USA  

June 08, 2008

Steven Oliver

RegEx that will save your life


I copy and paste a lot of code off of various websites and back into gVim. Which is all good but most of the time that copy and paste comes with line numbers in front of every line. While that might not be a big deal for 10 LOC or less, but for anything more than that your looking at a considerable amount of time wasted trying to delete all those lines, even with the dot command (pressing . in vim will repeat the last full edit series thing again).

So this is where regex and vim come to the rescue. You basically just do a find and replace using regular expressions.

%s/^[0-9]*\s//

That my friend will remove the line number from the beginning of every line. This does take into account two assumptions though. One, your line numbers are at the beginning of every line, and two, your line numbers always have at least one space after them. It will then replace all your line numbers with nothing. It basically just deletes them.

Enjoy the Penguins!

June 08, 2008 11:18 PM :: West Virginia, USA  

Brian Carper

Emacs pinky?

I worry about my hands. I play with computers for a living, and part of the reason someone would want to hire me is that I get a job done quickly. And being able to type fast is a necessary (not sufficient) ability for that to happen.

When I was in high school I started getting horrible pain on my wrists and hands. I had to wear a wrist brace for weeks at a time. I don't know what caused it, but too much keyboard time and bad posture and good old repetitive strain injury was and is my best guess. (This was before I'd even heard of Vim. Not sure what text editor I used back then. Probably some Notepad clone, ugh.)

But then I trained myself to type more comfortably, and I haven't had any pain for years. I hold my arms at the proper angle, and I don't bend my wrists or stretch or strain my fingers. My hands bounce over the keys nowadays, on and off the home row constantly. I don't use my pinky fingers to type at all, in fact. When I need to type a q or a number or a tilde, I move my whole hand up and hit it with my ring finger. When I'm vimming, I hit ESC with my middle finger. With practice this is just as fast as keeping your hands on the home row, but I find it far more comfortable. I still do it fast enough that people remark that I'm a fast typist (though I know plenty of people who are faster).

Thus we come to Emacs. Emacs is the king of key chords. I'm OK hitting Ctrl. I pick up my hand and hit Ctrl with the side of my pinky like I'm karate-chopping it with a half-closed fist, or use my pinky and ring finger both. The Alt key I can usually reach with my thumb. But anything that requires Ctrl + Shift or to a lesser degree Alt + Shift is a killer on my hands. I don't know a good way to quickly type Ctrl + Shift + another key in a comfortable way. Caps lock remapped to another Ctrl is the solution many websites list, but that doesn't cut it for me either, it's just pinky-stretching in another direction (and what do you do when you have to hit Ctrl with your right hand?).

For some reason I'm highly amused yet slightly horrified that there really is a condition called Emacs pinky. And that Richard Stallman and other Emacs gurus have famously experienced wrist injuries due to years of using Emacs. How many people in the world can say that their favorite text editor has physically crippled them?

Even if you admit that heavy dependence on the modifier keys is necessary, some of Emacs' keybindings seem ill-chosen to me. See this quote from the Emacs tutorial:

You can use the arrow keys,but it's more efficient to keep your hands in the standard position and use the commands C-p, C-b, C-f, and C-n.

I don't know what kind of creature finds those keys more efficient than the arrow keys or pageup / pagedown, but I don't think it's a human being. (But admittedly, same goes for hjkl in Vim.) Sure, you don't have you move your hands from the home row. You just have to contort them into pretzels. Try hitting up up up down left left right quickly, then try to do the same using those keys.

Same is true of other commands. delete-indentation, which I find myself doing a lot, is M-^. When editing Lisp you may get to experience wonders like C-( and M-J.

Anything multi-chord is also just a little bit torturous for me. How do you execute a command more than once in Emacs? e.g. move down 3 lines? You can either type M-3 C-n, which requires me to hit Alt with my right hand and 3 with my left, then hit Ctrl with my left and n with my right. Or you can do C-u 3 C-n, which actually requires me to alternate hands on the modifier keys three times instead of two. This for something so ridiculously simple as moving the cursor, something I do hundreds of times a day.

This kind of crap leads you to try to hit M-3 or C-u or C-n with one hand instead of two. If I can manage to hit M-3 with my left hand, I can hit the down arrow with my right. M-3 is possible with one hand, but M-8 or M-9 would not be without dislocating a few joints. Down this path leads permanent disability.

Sometimes I toy with the idea of remapping every keybinding or nearly every keybinding in Emacs to something sane. But aside from thoughts such as "Why the heck should it be necessary for me to do this?" or "Why would this possibly be worth my time?", I'm unsure I could come up with anything better. I'd still be limited to using lots and lots of modifier keys. Emacs has had decades of refinement after all, and it's still in this sorry state.

I have tried the Vi and Vim keybindings in Emacs, and they don't work right. They don't work in all buffers, for example a SLIME REPL buffer. Even when Vim mode is working, many of the Vim commands are present, but not all. These huge, massive Emacs-customization hacks always seem to work well maybe 95% of the time for me, but text editor bindings and behaviors are really something you need to work perfectly 100% of the time. Every time Emacs does something ridiculous or one of these third-party scripts mangles my buffer, and I have to kill and reload the file, it completely breaks my stride and throws off my concentration. The text editor needs to get out of your way and let you focus on what you're doing.

June 08, 2008 09:23 PM :: Pennsylvania, USA  

George Kargiotakis

Mobile view of the internet

This might be old news to most people but I didn’t know it… You can use a special google url to view websites like mobiles phones do. Try this for example: http://google.com/gwt/n?u=http://void.gr/kargig/blog/. It’s quite useful when you want to see how your site looks like from a mobile phone or when you want to use a browser from [...]

June 08, 2008 09:16 PM :: Greece  

Jason Jones

2008 - Roth Memorial - Friday

I just got done making the video for this entry, so take a look if you've got a high speed Internet connection.

Today was the 2nd day of the Ed Roth Memorial Reunion held in Manti, UT.

There were finksters-a-plenty there on Friday, but even more on Saturday.  I lost count of how many Rat Finks I saw.

So, because the days were packed, I didn't get a chance at all until now to compose a sufficient entry, but now the video is done, and I hope you like it.

To sum it all up, the main attractions of Friday were the car stripers which came from all across the country, the great food, Plan B's music (hehe), and the great looking cars.

We played pretty much all day today, and if I had to sum up our performance(s), I'd have to give them a C+.  The jam sessions (in my opinion) were A+, but we were so laid back, a lot of the attendees were confused at the music we played.

We have two sets of music, 1 hour each, and we played probably 3-4 hours of music.  Jam sessions with set songs sprinkled within.

Saturday's session was ..... way better.  We only got a couple of our songs recorded, thanks to horrible rainy weather by a professional cameraman, and I'll get the footage for it in a couple of days or weeks, but I'll get to that later.

Anywho, Friday was a great day, and is summed up much better in the video.

Oh, before I go, I've gotta say that for the past couple of days, I've been tinkering with the Linux-based video editing system, kdenlive, and although being far from noobie-friendly, I can say with pride that the whole video attached to this entry was created in gentoo Linux using kdenlive and the videos from a cheap Coolpix S210 "point-and-shoot" camera.  Professional quality?  Nope, but the a/v is in sync, and for a computer nerd, it was fairly easy to figure out.

I'll have to post a how-to on it later, because there's a slew of "gotcha"'s to get it to work right.

June 08, 2008 06:33 PM :: Utah, USA  

Thomas Keller

Ruby on Rails

I am currently working on getting into Ruby on Rails. Therefore, I wanted to install it on my server. It’s basically pretty easy - I followed the wiki entry; however, I did not use the “-D FCGID” option on apache, and I deployed the thest to /var/www/localhost/htdocs/test (and did not alter vhosts.conf, thus). Seems to work [...]

June 08, 2008 02:29 PM

Sean Potter

LinkedIn and BIOSLEVEL

LinkedIn is a social networking site for professionals. You won't go on there and find all the teenage themes, music, and video. Rather, you're able to add a single picture of yourself, and your profile focuses much more on your job experience, awards, and interests.

Colin invited me to join LinkedIn a few months ago, and I think it's been worth it. Mind you, it is free. I've established a network with several of the contacts I work with on obtaining review samples, as well as a few "corporate folk" from Buffalo Wild Wings. Not to say it'll grab me a new job in the near future, but anything helps.

I added a LinkedIn button to the staff profiles at BIOSLEVEL. It shows up on the "About Us" page right next to the person's name. Of course, not all the staff have it, as much as I'd like them to.

I wonder what Linux developers are on LinkedIn.

June 08, 2008 07:59 AM

Christoph Bauer

new word dialog

Suppose we had a dialog box for adding new words, what would it look like?

The age old tradition of mock dialogs continues…

Ps. Qt Designer on the whole is quite nice to work with, quite a bit better than Glade. Any gui designer is bound to be annoying, but I suppose Qt Designer is approaching the least annoying (and most effective) you can get.

June 08, 2008 03:04 AM :: Vorarlberg, Austria  

Bandan Das

Some more silliness

Based on my weird ideas, I cooked up a small scipt that will save me some time by automatically versioning new files that come up in my home directory. You "may/may not" have any use for it but if you want to have a peek, it's right here. Feel free to modify or use it for something else (that is weirder).

What it does : It compares and finds out a list of newly created files/directories, asks whether to add them (or ignore them) and then commits the changes and pushes it to my Amazon S3 drive. You will want to take care of the paths in there that are specific to my system.

Have fun!

read more

June 08, 2008 02:19 AM :: India  

Jason Jones

Last Three Days

I've been fighting with my computer for the past hour to get gentoo to import the contents of an SD card in a card reader (announces itself through USB as "07cc:0500 Carry Computer Eng., Co., Ltd"), and was unsuccessful.

As such, I have lost all motivation and energy to work on getting the journal entries for the 3 days of Rat Fink (Ed Roth) memorial reunion entered.  I've got pictures and videos of the cars, people, and music from the band I play in (Plan B).

I plan on getting some good day-by-day entries up, but it looks like it won't happen tonight.

I'm importing the images / videos through the camera now (with flphoto / gphoto2), and it's slow as frozen molasses.  So, as soon as it's done, I'm going to bed.

I'm exhausted.

Thank heavens for sunscreen.

June 08, 2008 12:13 AM :: Utah, USA  

June 07, 2008

Steven Oliver

Why C++ is “hard” in 2 sentences


One of the best quotes I’ve seen in a very long time…

In The Art of Computer Programming Don Knuth apologizes for not giving good examples of co-routines, because their advantages are not obvious in small programs. Many C++ features are like that in that: They don’t make sense until you face a problem of the kind and scale that needs that feature.

Bjarne Stroustrup

Enjoy the Penguins!

June 07, 2008 07:52 PM :: West Virginia, USA  

Luca Gasperini

Laptop ubuntu suspend and nvidia virtual tty

I decided to keep ubuntu even if I don’t like this new release ( hardy ) at all. When it came out it used to hang for no reason , the new kernels seem to have solved the issue.

I had two big problems, I couldn’t hibernate/suspend and I couldn’t switch to the ttys with Alt+F1 for example.

Starting from the latter I realized that the nvidia-glx package instead of the nvidia-glx-new does the job. Since I don’t know the difference between the two packages and I really don’t care to have the newest nvidia driver I consider this problem fixed.

Now suspend works and not sometimes or just one time like it used in the past, I had to change some config options in /etc/default/acpi-support

SAVE_VBE_STATE=false
POST_VIDEO=false
SAVE_VIDEO_PCI_STATE=true

Hiberating is still a problem or better waking up from hibernation is a huge deal on my laptop. It does hibernate and it tries to wake up during next boot but when X starts everything freeze. It seems a kernel or xorg problem because I can’t turn on/off the capslock led. Here’s the bug I’ve filled, hopefully someoene will look at it.

June 07, 2008 03:44 PM :: Italy  

June 06, 2008

Christoph Bauer

writing “she” just to be on the safe side

I won’t state this is common and therefore some kind of major concern. But I have been seeing this with increased regularity. Some people who write about an abstract and gender neutral person (eg. “the salesman”) will write “she” when referring to this person, apparently just to be on the safe side vis a vis sexism. This is yet another case of being concerned with the wrong issues and expending energy on things that don’t matter.1

If you are a reader who actually finds fault with use of the male pronoun to describe a non-specific gender neutral person, stop victimizing yourself (if you’re a woman) or stop sympathy-victimizing (if you’re a man). (See how I neatly handled both cases, I’m so politically correct.)

Guy Steele said it best, on a completely different subject, in his talk “Growing a language”:

To keep things short, when I say “he” I mean “he or she”, and when I say “his” I mean “his or her”.

But it really shouldn’t be necessary to make this qualification to anyone who can understand that use of a pronoun in a context where it appears incidentally is not a covert plot to put you down. Monty Python also had an elegant and hilarious contribution to this discussion in Life of Brian.

  1. Of course, this whole blog entry is just an example of that too, but I can still argue that I’m the only person arguing this issue while there’s many more wasting their energies on the issue at hand. :P

June 06, 2008 10:02 PM :: Vorarlberg, Austria  

Steven Oliver

Goosh


I just found this website called Goosh. Its basically Google overlayed with a fake bash like shell. While at first this was interesting, it soon turned stupid, only to then turn into something that might be incredibly useful. A lot of Linux, especially Gentoo, users have probably has to use Links or Lynx at least once in their life to search the internet because they could not get there system to boot into the GUI. A site like Goosh will make using Google from these (generally) text only browsers 10x easier! Long live the Goosh.

Enjoy the Penguins!

June 06, 2008 04:50 PM :: West Virginia, USA  

Matija Å uklje

Setting up wireless printing and scanning on HP All-in-One devices

Setting up a HP printer in GNU/Linux is probably a lot easier to do then any other brand — mostly thanks to the awesome HPLIP. This short tutorial will explain how to set up CUPS and SANE to use a HP All-in-One printer with the integrated wireless print server (e.g. HP Photosmart C4380), because there is a small caveat that needs pointing out.

read more

June 06, 2008 03:32 PM :: Slovenia  

Bandan Das

Coolest patch ever

So, I was recently talking to a colleague of mine who has spent a good number of years in the defense industry. As he was reminiscing the good old days, the conversation gradually drifted to a more interesting discussion about a guy who was a software developer: It was the cold war era and there was this critical monitoring system (with some version of MULTICS running on it) that needed an important kernel update. And the catch: the system can't be switched off even for a second and (probably) it was a core update or may be LKMs didn't exist then :)

So, our smart guy did something that no one had ever done in those times. He built a system with an exactly similar configuration and made whatever changes needed to the kernel. Then, he compiled it and came up with a binary diff between the changed kernel and the original one. The next step: Yes, you guessed it, he identified sections of the running kernel where there have been changes and set the non-executable bits on them (in the critical system). After that, it was just a matter of applying the patch. And there you are! the system stayed on as it always was :)

PS: I am really not sure how possible it is with today's OSes but I find the whole idea quite fascinating.

read more

June 06, 2008 02:54 PM :: India  

Jürgen Geuter

Gadgets, widgets, plasmoids, whatever you call them, they're pretty worthless.

Google released their Google Gadgets for Linux as open source. Those do even support both big toolkits (GTK and Qt) so they don't look alien in the user's environment, which is pretty neat. But let's make a few steps back first.

Those gadgets or widgets or whatever you wanna call them (everyone and their mom seems to have build their own little thingy there) are little apps that live on your desktop. They can display a calendar or a clock, they can grab some info from the internet and display it to you and there's also a lot of system information display widgets out there. What they have in common is that they are usually more about displaying stuff than about interaction.

Of course they do offer a context menu to configure them and often they do have a few actions that can be triggered by a click (like for example changing the volume or switching active application), but traditionally they don't have a lot of interaction (for that you would probably want a "proper" application anyways with all the flexibility it has).

Widget technologies are all about making it easier to create those "mini programs": The developer does not have to take care of much low-level code, you have a framework of the things you need and you can get your little application going in very little time and sometimes even platform independent (as long as the framework is platform independent).

So all in all it sounds really smart, right? All those neat little things doing stuff and showing other stuff? After all, a lot of the hype around KDE4 was based on the whole "plasmoid" idea (which is essentially the KDE flavoured copy of the widget idea).

Well, as it is so often, while it might sound smart, it actually is not. Let me outline why.

Widgets take up space. I don't really mean the one they take on your harddrive cause that one is cheap, but screen space. If you wanna have that information visible to you on your desktop you will try not to have your applications overlap the widgets because if you do, why would you wanna have the widgets in the first place?

And that is the real problem: Widgets steal your screen real estate.

While they might offer neat little information, you pay it with less space on your screen to put the things you actually need: The things you work with.

It's actually similar to having icons on your desktop: That's wrong cause when you open windows you wanna use your monitor to see the application you work in which means you won't be able to see the icons on your desktop. The desktop is not there to be cluttered with files (which, with any decent file-selector dialog) can be just as easily and quick be found when the reside in $HOME and if you put icons there to run applications you'll have to minimize what you are doing just to run something else (which is wrong on so many levels that I don't even wanna bother listing them here).

Widgets look nice on screenshots but that's all they are useful for. Look at all those screenshots full of widgets: Do you really think that, when you add the applications you work in, you'll see any of the widgets? Or do you really wanna make your applications so tiny that they fit in?

Widgets are a problem of information overload. Do you really need yet another clock on your desktop to steal your focus? Do you really want to see updated stock quotes all the time (and if you really do, widgets offer to little functionality to react anyways)? Do you really need to have some random quote on your desktop changing every 5 minutes?

No you don't. All those things make it harder for you to concentrate on the things you really wanna do, they distract and you can spend hours finding new widgets, playing with them and having fun (not that that in itself is bad, I love spending time every few months to change my desktop background) but when people tell you that all those things are about productivity it's usually wrong.

Having simple applications run in the background (probably with an icon in your systray) that send you a notification in certain events makes sense. That way you can filter what information you need and what helps you do whatever you wanna do. But plastering that crap all over the desktop is always the wrong decision (except for making fancy screenshots of course).

June 06, 2008 09:59 AM :: Germany  

Brian Carper

Work

When I was in college, one of the guys in one of my classes was an older fellow who'd been working in the Real World for a while, and he asked me one day what kind of job I wanted after I graduated. I remember saying "I have no idea. Pretty much anything. If Microsoft drove up to my house with a truck full of money, I'd go work for them."

Looking back now, I was wrong. There really are more important things than money. I couldn't do a job I didn't thoroughly enjoy. Not for long anyways. I don't make as much money doing what I'm doing right now as I could be making elsewhere, but I like it. I like the atmosphere of working in a research setting. I can't imagine working in a corporate setting.

I feel really bad for people who work jobs that they hate. When I got out of college I worked for six months doing tech support over the phone for a residential satellite dish company. If not for the fact that I needed money to survive, I wouldn't have. Near the end I was considering going to live under a bridge somewhere. If faced with the choice, I'd probably rather dig ditches for a living than do that again.

If hell existed, for me hell would consist of being eternally bored. I've had jobs that required no thought, just mindless repetition of tasks that were slightly too complicated to get a computer or machine to do. I can't imagine a worse fate. I can feel my brains start to leak out of my ears after an hour of a boring task.

When you have a job where you have to play with data, as I do at times, it can sometimes start turning into that kind of boredom. But then I start writing programs to do all the mindless repetition for me. Instead of spending lots of time solving little problems and doing little tasks, I solve bigger, harder, much more interesting problems that incidentally solve lots of little problems at the same time.

Computers are useful tools for everyone. But in one sense, a computer is often a waste in the hands of anyone but a programmer. The way most people use computers is like using a powerful microscope as a hammer to pound in a nail. Any time you find yourself copying and pasting a bunch of things over and over for an hour, there's something wrong. Any time a human being is forced to do a linear search through a long list of ANYTHING on a computer screen, someone along the line has failed. There are so many of these little problems in most people's lives that a programmer can solve for people.

June 06, 2008 04:32 AM :: Pennsylvania, USA  

June 05, 2008

Dirk R. Gently

Quick Guide to Writing Scripts (Repub.)


Note: This is a re-publication of elflords original Quick Guide to Writing Scripts minus a few type-o’s that I’ve re-published with his permission. It is a really good tutorial for those new to bash scripting that like getting their hands dirty without all the fluff that goes with it.

A quick guide to writing scripts using the bash shell

A simple shell script

A shell script is little more than a list of commands that are run in sequence. Conventionally, a shell script should start with a line such as the following:

#!/bin/bash

This indicates that the script should be run in the bash shell regardless of which interactive shell the user has chosen. This is very important, since the syntax of different shells can vary greatly.

A simple example

Here’s a very simple example of a shell script, it runs a few simple commands.

#!/bin/bash
echo “hello, $USER. I wish to list some files of yours”
echo “listing files in the current directory, $PWD”
ls     # list files

First, notice the comment on line 4. In a bash script, anything following a pound sign # (besides the shell name on the first line) is treated as a comment (ie the shell ignores it). It is there for the benefit of people reading the script.

$USER and $PWD are variables. These are standard variables defined by the bash shell itself, they needn’t be defined in the script. Note that the variables are expanded when the variable name is inside double quotes. Expanded is a very appropriate word: the shell basically sees the string $USER and replaces it with the variable’s value then executes the command.

We continue the discussion on variables below …

Variables

Any programming language needs variables. You define a variable as follows:

X="hello"

and refer to it as follows:

$X

More specifically, $X is used to denote the value of the variable X. Some things to take note of regarding semantics:


  • Bash gets unhappy if you leave a space on either side of the = sign. For
    example, the following gives an error message:
    X = hello
  • While I have quotes in my example, they are not always necessary. Where you need quotes is when your variable names include spaces. For example:
    X=hello world # error
    X=”hello world” # OK

This is because the shell essentially sees the command line as a pile of commands and command arguments separated by spaces. foo=baris considered a command. The problem with foo = bar is the shell sees the word foo separated by spaces and interprets it as a command. Likewise, the problem with the command X=hello world is that the shell interprets X=hello as a command, and the word “world” does not make any sense (since the assignment command doesn’t take arguments).

Single Quotes versus double quotes

Basically, variable names are expanded within double quotes, but not single quotes. If you do not need to refer to variables, single quotes are good to use as the results are more predictable.

An example:

#!/bin/bash
echo -n ‘$USER=’     # -n option stops echo from breaking the line
echo “$USER”
echo “\$USER=$USER”  # this does the same thing as the first two lines

The output looks like this (assuming your username is elflord)

$USER=elflord

The double quotes still have a work around. Double quotes are more flexible, but less predictable. Given the choice between single quotes and double quotes, use single quotes.

Using Quotes to enclose your variables



Sometimes, it is a good idea to protect variable names in double quotes. This is usually the most important if your variables value either (a) contains spaces or (b) is the empty string. An example is as follows:
#!/bin/bash
X=”"
if [ -n $X ]; then 	# -n tests to see if the argument is non empty
	echo “the variable X is not the empty string”
fi

This script will give the following output:

the variable X is not the empty string

Why? Because the shell expands $X to the empty string. The expression [ -n ] returns true (since it is not provided with an argument). A better script would
have been:

#!/bin/bash
X=”"
if [ -n "$X" ]; then 	# -n tests to see if the argument is non empty
	echo “the variable X is not the empty string”
fi

In this example, the expression expands to [ -n "" ] which returns false, since the string enclosed in inverted commas is clearly empty.

Variable Expansion in action

Just to convince you that the shell really does “expand” variables in the sense I mentioned before, here is an example:

#!/bin/bash
LS=”ls”
LS_FLAGS=”-al”

$LS $LS_FLAGS $HOME

This looks a little enigmatic. What happens with the last line is that it actually executes the command

ls -al /home/elflord

(assuming that /home/elflord is your home directory). That is, the shell simply replaces the variables with their values, and then executes the command.

Using Braces to Protect Your Variables

OK. Here’s a potential problem situation. Suppose you want to echo the value of the variable X, followed immediately by the letters “abc”. Question: how do you do this ? Let’s have a try:

#!/bin/bash
X=ABC
echo “$Xabc”

This gives no output. What went wrong? The answer is that the shell thought that we were asking for the variable Xabc, which is uninitialised. The way to deal with this is to put braces around X to separate it from the other characters. The following gives the desired result:

#!/bin/bash
X=ABC
echo “${X}abc”

Conditionals, if/then/elif


Sometimes, it’s necessary to check for certain conditions. Does a string have 0 length? Does the file “foo” exist, and is it a symbolic link, or a real file? First, we use the if command to run a test. The syntax is as follows:
if condition
then
	statement1
	statement2
	……….
fi

Sometimes, you may wish to specify an alternate action when the condition fails. Here’s how it’s done.

if condition
then
	statement1
	statement2
	……….
else
	statement3
fi

Alternatively, it is possible to test for another condition if the first “if” fails. Note that any number of elifs can be added.

if condition1
then
	statement1
	statement2
	……….
elif condition2
then
	statement3
	statement4
	……..
elif condition3
then
	statement5
	statement6
	……..
fi

The statements inside the block between if/elif and the next elif or fi are executed if the corresponding condition is true. Actually, any command can go in place of the conditions, and the block will be executed if and only if the command returns an exit status of 0 (in other words, if the command exits “successfully” ). However, in the course of this document, we will be only interested in using “test” or “[ ]” to evaluate conditions.

The Test Command and Operators


The command used in conditionals nearly all the time is the test command. Test returns true or false (more accurately, exits with 0 or non zero status) depending respectively on whether the test is passed or failed. It works like this:

test operand1 operator
operand2

for some tests, there need be only one operand (operand2) The test command is typically abbreviated in this form:

[ operand1 operator operand2 ] To
bring this discussion back down to earth, we give a few examples:

#!/bin/bash
X=3
Y=4
empty_string=”"
if [ $X -lt $Y ]	# is $X less than $Y ?
then
	echo “\$X=${X}, which is smaller than \$Y=${Y}”
fi

if [ -n "$empty_string" ]; then
	echo “empty string is non_empty”
fi

if [ -e "${HOME}/.fvwmrc" ]; then 			# test to see if ~/.fvwmrc exists
	echo “you have a .fvwmrc file”
	if [ -L "${HOME}/.fvwmrc" ]; then 		# is it a symlink ?
		echo “it’s a symbolic link
	elif [ -f "${HOME}/.fvwmrc" ]; then 	# is it a regular file ?
		echo “it’s a regular file”
	fi
else
	echo “you have no .fvwmrc file”
fi

Some pitfalls to be wary of


The test command needs to be in the form
operand1 <space> operator < space > operand2” or
operator <space> operand2 , in other words you really need these spaces, since the shell considers the first block containing no spaces to be either an operator (if it begins with a ‘-’) or an operand (if it doesn’t). So for example; this:
if [ 1=2 ]; then
	echo “hello”
fi

gives exactly the “wrong” output (ie it echos “hello”, since it sees an operand but no operator.)

Another potential trap comes from not protecting variables in quotes. We have already given an example as to why you must wrap anything you wish to use for a -n test with quotes. However, there are a lot of good reasons for using quotes all the time, or almost all of the time. Failing to do this when you have variables expanded inside tests can result in very
wierd bugs. Here’s an example:

#!/bin/bash
X=”-n”
Y=”"
if [ $X = $Y ] ; then
	echo “X=Y”
fi

This will give misleading output since the shell expands our expression to:

[ -n = ]

and the string “=” has non zero length.

A brief summary of test operators

Here’s a quick list of test operators. It’s by no means comprehensive, but its likely to be all you’ll need to remember (if you need anything else, you can always check the bash manpage … )

WordPress css theme bonked table. Please scroll down.






















































operator produces true if… number of operands
-n operand non zero length 1
-z operand has zero length 1
-d there exists a directory whose name is operand 1
-f there exists a file whose name is operand 1
-eq the operands are integers and they are equal 2
-neq the opposite of -eq 2
= the operands are equal (as strings) 2
!= opposite of = 2
-lt operand1 is strictly less than operand2 (both
operands should be integers)
2
-gt operand1 is strictly greater than operand2 (both
operands should be integers)
2
-ge operand1 is greater than or equal to operand2 (both
operands should be integers)
2
-le operand1 is less than or equal to operand2 (both
operands should be integers)
2

Loops

Loops are constructions that enable one to reiterate a procedure or perform the same procedure on several different items. There are the following kinds of loops available in bash:


  • for loops
  • while loops

For loops


The syntax for the for loops is best demonstrated by example:
#!/bin/bash
for X in red green blue
do
	echo $X
done

The for loop iterates the loop over the space separated items. Note that if some of the items have embedded spaces, you need to protect them with quotes. Here’s an example:

#!/bin/bash
colour1=”red”
colour2=”light blue”
colour3=”dark green”
for X in “$colour1″ $colour2″ $colour3″
do
	echo $X
done

Can you guess what would happen if we left out the quotes in the for statement? This indicates that variable names should be protected with quotes unless you are pretty sure that they do not contain any spaces.

Globbing in for loops


The shell expands a string containing a * to all filenames that “match”. A filename matches if and only if it is identical to the match string after replacing the stars * with arbitrary strings. For example, the character “*” by itself expands to a space separated list of all files in the working directory (excluding those that start with a dot “.” ) So,

echo *

lists all the files and directories in the current directory,

echo *.jpg

lists all the jpeg files, and

echo ${HOME}/public_html/*.jpg

lists all jpeg files in your public_html directory.

As it happens, this turns out to be very useful for performing operations on
the files in a directory, especially used in conjunction with a for loop. For
example:

#!/bin/bash
for X in *.html
do
		grep -L ‘<UL>’ “$X”
done

While Loops


While loops loop “while” a given condition remains true. An example of this:
#!/bin/bash
X=0
while [ $X -le 20 ]
do
	echo $X
	X=$((X+1))
done

This raises a natural question, why doesn’t bash allow the C like for loops?

for (X=1,X<10; X++)

As it happens, this is discouraged for a reason: bash is an interpreted language, and a rather slow one for that matter. For this reason, heavy iteration is discouraged.

Command Substitution

Command Substitution is a very handy feature of the bash shell. It enables you to take the output of a command and treat it as though it was written on the command line. For example, if you want to set the variable X to the output of a command, the way you do this is via command substitution.

There are two means of command substitution: brace expansion and backtick
expansion.

Brace expansion works as follows: $(commands) expands
to the output of commands This permits nesting, so commands
can include brace expansions

Backtick expansion expands `commands` to the output of commands,

An example is given:

#!/bin/bash
files=”$(ls )”
web_files=`ls public_html`
echo $files
echo $web_files
X=`expr 3 \* 2 + 4` # expr evaluate arithmetic expressions. man expr for details.
echo $X

Note that even though the output of ls contains newlines, the variables do not. Bash variables can not contain newline characters (which is a pain in the butt. But that’s life) Anyway, the advantage of the $() substitution method is almost self evident: it is very easy to nest. It is supported by most of the bourne shell variants (the POSIX shell or better is OK). However, the backtick substitution is slightly more readable, and is supported by even the most basic shells (any #!/bin/sh version is just fine)

June 05, 2008 06:44 PM :: WI, USA  

Matija Å uklje

Hello planet(s)

First Hook's Humble Homepage has been (re)added to the Planet Kiberpipa (which aggregates Cyberpipe members' feeds) and now it has also reached Planet Larry (with feeds from Gentoo users).

This calls for a celebrational:

#!/usr/bin/env python
# -*- coding: utf-8 -*-
print "Hello, planet(s)! :]"

June 05, 2008 04:51 PM :: Slovenia  

Steven Oliver

A new Mac OS X


A new version Mac OS X (version 10.6) is supposedly coming out soon. Yes Leopard is still very young and normally I would not care at all what Apple does but now that I own one I’m very concerned about it. Generally a major update like that would cost me some money, in Apple’s case probably no more than $100 but either way I’ve only had my MacBook for like a month or a little more than that now and I really don’t like the idea of having to shell out another $100 for a major OS update. The only thing worse than this is buying Vista only to have to spend $9000 to upgrade to Windows 7.

Enjoy the Penguins!

June 05, 2008 04:48 PM :: West Virginia, USA  

Sean Potter

BIOSLEVEL Happenings

I've been publishing a few articles a week at BIOSLEVEL.com. The increases in traffic have definitely been noticeable. We just need to take better advantage of this for monetizing the traffic so the site is atleast able to completely pay for its own hosting and advertising.

Two articles were published this week, the first of which wasn't actually a review, but rather a short tutorial on how to use chroot to recover root passwords. It's nothing new, but I guarantee there's plenty of Linux users out there that don't know how to do this.

The first article was of Noctua's NF-P12 120mm case fan. Normally I wouldn't consider a case fan a very exciting review, but Noctua included some very innovative features with the unit, as well as a silencing kit. You'll have to read the review to get all the juicy details.

Before the week's over, I'm hoping to have two more reviews published, one on a hard drive, and one of a video card. The parents are going to be out of town for the weekend, so maybe I'll have some time with no interruptions.

June 05, 2008 03:35 PM

Steven Oliver

Google and Privacy


I recently read an article claiming that Google does not properly display its privacy policy. According to California law it has to display it openly and conspicuously (a big word that means you can’t hide it). So without cheating, I promptly left the article and went straight to Google.com to find it for myself.

So we’ll start, and we’ll count the clicks it takes as well, since later on the in the article not only do they reveal the location but one person even claims “its not just a few clicks.” To me a few equals five. Given that background, lets count.

int numclicks = 0;

Once on www.google.com I looked around and saw nothing that said privacy. No real surprise there. So I, in what I felt was fairly obvious and intuitive clicked, “About Google.”

numclick += 1;

From there I resumed my search for the word privacy. That makes me sound like a computer or something but thats how you work. Your brain constantly does keyword searches. Within seconds the words “Privacy Policy” were instantly found exactly where you would expect them. At the bottom beside the copyright. So I clicked “Privacy Policy.”

numclick += 1;

That then takes me to another page. The real point of this page is something I’m not sure of, but none the less your there and inside a large blue box are giant blue letters that read “Google Privacy Policy.” So I clicked it.

numclick += 1;

Bottabing bottaboom. There you go. A clean, simple, looking privacy policy that I won’t even attempt to read because I don’t care. The point here is after it was all said and done:

printf(%d, numclick);
3

Well last I checked that was not only obvious and ridiculously easy to find, it only took three clicks which is less than 5 and thus I have proven that idiot the BBC interviewed has never used the internet. Do come back.

Enjoy the Penguins!

EDIT: The guy said “couple” not a “few.” A couple is two. I counted three. The man is still an idiot, I don’t care.

June 05, 2008 02:32 PM :: West Virginia, USA  

Johannes Gilger

bottom-up git documentation

gitAs you can imagine I have been using git some more since the last post about it (and I’ve even been giving GitHub some more thorough investigation, but I’ll be posting about that later). Back then I already understood most of it (definetely enough to work with it), but just recently I got the feeling of really understanding git, especially the underlying data-structures and the consequences for the (power)-user.
The things that helped me were (besides the git manual which is good, but not graphical, and when it comes to the understanding of the data-structures, having little graphics is a must):

  • Git from bottom up, a cool PDF i discovered on the git-wiki.
  • The RailsConf-Talk by Scott Chacon, who also wrote the PeepCode Git PDF (which I haven’t read due to lack of interest and credit-card). The link points to a video and the slides can also be downloaded as PDF (they are pretty self-explanatory imho).
  • Git Magic, which is a cool guide and pretty well structured.
  • And for the people who are really into screencasts there is also

  • gitcasts.com, which too is made by Scott Chacon

June 05, 2008 10:58 AM :: Germany  

Dan Ballard

Re: A Timeless, Desert Island Language

You know, dear internet, I'm very impressionable some times. Anyways, I was leafing through my feeds when I found this neat blog post by fellow name Dave Roberts, entitled A Timeless, Desert Island Language in my Planet Lisp section. And it's a quick neat fun read, with a conclusion you might not expect.

And if you read it, you'll probably be able to predict what shinny new idea/project has caught my attention, especially if you were already familiar with my kink for computer languages.

I want to find some time to take a quick stab at writing a simple Lisp interpreter!

June 05, 2008 05:01 AM :: British Columbia, Canada  

June 04, 2008

Steven Oliver

JFS: So far so good


In the spirit of all things open source I like to give new things a try. I mean why not? This isn’t Windows or OS X. I can reinstall easily, get my data back fairly easily, reinstall as many times as my hardware can stand, and try the newest edition of everything basically free.

So, when I recently reinstalled Gentoo on my desktop I tried out JFS. I’ve used ext2, ext3, ReiserFS, and even XFS. ext2 and ext3 are very stable but they’re not very quick. ReiserFS in my experience has been really good. But sometimes you get that, “i don’t want to use that, everyone else does” mood so you refuse. Finally, my stints with XFS have always ended in a crashed file system. Almost always do to a hard reset because of power failure. JFS on the other hand has survived its first obstacle. Depsite the power going out last night my computer rebooted this morning unscathed. Yes, it had to go through the whole replaying journal bit, but after that everything seems fine.

Enjoy the Penguins!

June 04, 2008 09:42 PM :: West Virginia, USA  

Dirk R. Gently

Uni-no-code


Because my laptop is getting older my ethernet and wireless hardware has failed on me so I’m relagated to downloading the webpages I want to read at the library. I don’t complain, this actually works just fine for me. Firefox though cannot open multiple pages at once:

firefox *.htm

So I built a script that does so:

#!/bin/bash
# firefox to open all .htm, .html files

for X in *.htm
do
    firefox "$X"
done

for Y in *.html
do
    firefox "$Y"
done

Only problem is, XP doesn’t write unicode so Firefox will complain that it can’t find the file when it encounters a character it doesn’t understand. Unknown characters in Unicode will map as “�”. This may not translate well on WordPress, or the Browser, or the OS you’re using so here’s a pic:

XP Uni-no-code

For any developers out there, do you have an idea how to write a script to rewrite the filenames so they are Unicode (or remove the un-unicode lettering) without having to manually type in each name?

June 04, 2008 06:07 PM :: WI, USA  

Sean Potter

My Workstation

Nikos posted his desktop to his blog, which was syndicated by Planet Larry, a Gentoo-oriented syndication. My blog is also syndicated there. He tagged a few people to show their setups, and I've been meaning to take a few pictures of mine, so I decided to show off as well. You can see a few other setups from Gentoo users and developers and George on Planet Larry.

My brand new Nikon D40 DSLR came yesterday, and today I've got a fully-charged battery. So why not take a few snapshots with the new camera?

First up is the desktop itself. From left to right, there's a 17" Samsung LCD, a 22" Acer LCD, and a 20" Princeton LCD. The 22" and 20" are connected to my desktop through DVI to my GeForce 8800GTX. The 17" is used with my benchmarking rig, or my server as needed. Below the monitors are my MacBook, G15 Keyboard, and Logitech G5 and MX510 mice.

Next up are my towers. The one on the bottom is my desktop, featuring a Core2Quad Q6600 CPU, 4GB of RAM, a GeForce 8800GTX video card, two 36GB Raptors, and about 400GB between three other drives.

Above it is my benchmarking rig, which has an AMD Phenom 9500 Quad-Core CPU, 2GB of RAM, a 250GB hard dive, and an AMD Radeon HD3870 video card.

Lastly, I'm posting a picture of some of my upcoming reviews and previous reviews. They're sitting on my shelves. Some of the stuff I can't talk about is behind the sheet. Shhhh!

I didn't picture my home server because it's currently in pieces waiting for a new heatsink. I also didn't picture the Asus Barebones I previously reviewed on BIOSLEVEL because it's connected to my TV for an upcoming article!

I hope you enjoyed my workstation. I'm tagging Roy, Colin, and John.

June 04, 2008 06:02 PM

Iain Buchanan

GoogleEarth flight simulator

Last night I was thinking "GoogleEarth imagery would make a great backdrop for a flight simulator"...
  1. Start GoogleEarth (I have version 4.2.205.5730 on Gentoo Linux)
  2. Turn on the "terrain"
  3. Press ctrl-alt-a
  4. Choose between an F16 jet fighter, or an SR22 4 seat propeller aeroplane.
  5. Fly! The mouse works as the usual joystick controller (down=pull up; up=down, just as I like it!)
You have some other controls too: g (landing gear); up/down arrows (throttle); f (extend flaps); F (retract flaps). And yes - since you have landing gear you _can_ crash! Turn on the terrain option for a 3D view. I landed at my local airport! Not quite as smooth as my good ole Janes FA/18, but still very cool...

It may be a bit buggy - if it locks up just restart GoogleEarth, and choose from one of the default starting points.

Of course, I'm not the first to know - Google has fully documented the keyboard shortcuts!

June 04, 2008 05:22 AM :: Australia  

June 02, 2008

Dirk R. Gently

A Walk with PCMan


A Walk with PCManA few months ago, I had tripped upon a post in Ubuntu’s forums that the PCMan file browser was restarting development and became a bit curious. A year or two ago there have been postings that I had seen in the Gentoo forums about how good a lightweight file browser it was. Then yesterday, I saw that Tombuntu had an overview of the new PCMan and then I just happened to see an ebuild made for it. So I decided to give it a try.

Currently, I use the brute horse (Nautilus) for file browsing. Nautilus is a really good browser but on this old klunker it cold-starts in 15 seconds and warm-starts in five and it would be nice if I could find something quicker. Before, I have replaced Nautilus with Thunar as the default browser, but Nautilus caught up a lot in speed when I removed the Enlightenment Sound Daemon as a variable, and frankly I had just become too lazy to change it back when I updated to Gnome 2.22.

The ebuild compiled PCMan painlessly - thanks George for the update. For the ebuild UsE flags, I built with and without the ‘desktop’ flag. The ebuild notes the desktop flag as ‘desktop integration’ but I didn’t notice a difference either way. Perhaps it is for desktop-less installs (fluxbox,…). The ‘fam’ flag is necessary for file monitoring support, it works in conjunction with gamin which is already built along with Gnome. Also, I took out the confirm delete patch as PCMan-4 has a confirm dialog when deleting a file/folder (I’m guessing the patch was for PCMan-3.*).

I found PCMan’s menu entry in ‘System Tools’ and loaded PCMan. PCMan cold-started in about 5 seconds.

Pic PCMan boot

Beginning thoughts: I liked PCMan. First, PCMan recognized my GTK and icon theme and also recognized the bookmarks I previously made in Nautilus. Big pluses. PCMan feels alot like Nautilus which is great because I am used to Nautilus’s behavior. The response time was nice as well (changing from one folder to the next took about one second). Picture previews are a must for me and PCMan did that just fine. PCMan also has tabbed browsing. I heard about this coming to Nautilus 2.24 and I like the thought of it. PCMan has the ability to drag between tabs and the ability to reorder tabs, very nice.

A Walk with PCMan

Ubuntugeek has a post that will launch PCMan for folder’s in the Place’s Listing in the Gnome Menu. I could probably use the Thunar script I previously used and link /usr/bin/nautilus to make PCman my default browser but I don’t feel like doing the work - be lost on the next update anyhow. Besides, I want to keep Nautilus as my desktop browser because it does a damn good job at it. For now I’m going to keep using PCMan and be content on opening folders on the desktop by right-clicking them and choosing PCMan. Lightweight desktops should think about giving PCMan a try.