## { pts“” } Search Results

### BSD License Explained In Layman Terms

It's always bothered me, how confusing the many Free and Open Source Licenses are. There are many to choose from. As a developer, which one do you pick? How do you choose what software to run? What applications or services will you deploy pending licensing? These are big questions, and I hope to make explaining licenses easy and in simple terms for the average user. I'll start with one of the more common licenses, the BSD license.

In a nutshell, the BSD license is a very open license, allowing you do do practically anything with the software. It's less restrictive than the GPL, but more restrictive than the Public Domain. There are only a couple precepts that must be adhered to, when using this license:

• You are free to redistribute the software, in binary or source form, as long as the copyright, conditions and disclaimer are present.
• You cannot use the name of the originating organization, or contributers, to promote derivatives of the software, without written consent.

If adhered to, you are free to modify, copy and redistribute BSD-licensed software in either source or binary form as you see fit. You are not required to return code or patches to the upstream BSD-licensed software. You are free to change the license, or charge for derivatives, of the software, be it commercial or proprietary.

BSD-licensed software is particularly attractive to organizations providing a service, such as GMail, or embedded applications, such as your mobile phone or stereo. The company/developer can use BSD-licensed software to produce binary applications or services, without releasing the source code.

### Movable Type 4.0 Beta Released

I'm 3 days behind in pushing out this news, however, after getting my daily dose of Technorati, and seeing all the posts about Movable Type going GPL with version 4, I had to comment.

First off, I am excited to see Movable Type get back on its feet with respect to the community. It's history of proprietary enterprise solutions and restricting licenses have kept it from becoming the preferred blogging platform for many. As such, a less powerful, but nonetheless Free Software solution, WordPress has taken the scene as the big daddy of blogging CMS. I use WordPress as my blog platform, and fully support it. Now that Movable Type is going GPL, however, I'm wondering if it's too late for Movable Type to enter the market as a Free Software CMS. It does solve some of the issues that plagues WordPress installs and I wonder how WordPress is going to respond.

For example, I would much rather be running WordPress on top PostgreSQL than MySQL, due to the reputation of data integrity and scalability of PostgreSQL. However, WordPress just supports MySQL. Also, I would like to see some way to update my WordPress installation without running a separate script to handle the upgrade. From what I understand, Movable Type supports this natively with CGI scripts that perform all the necessary functions. Movable Type seems to support a number of other features such as LDAP and Oracle DBs, which could be important to others.

In the long run, I may consider making the switch from WordPress to Movable Type when 4.0 is stable. In the meantime, I'm interested in reasons why I should stay with WordPress or why I should move to Movable Type. For starters, as mentioned previously, I would prefer to have PostgreSQL powering my database rather than MySQL. Any thoughts? Vote in the poll after the jump.

This is a poll utilizing AJAX. It will not work properly in your feed reader. You will need to visit this site's post if you would like to vote in the poll. Thanks.

Should I make the switch?
View Results

### Retail Store Annoyances

What happened to the good old days, when you could walk into a retail store, make a purchase and walk out? Maybe you had a salesman or associate try to sell you and extended service plan, or talk you up to the next best model. Maybe you had to haggle on occasion. No big deal. All things that we could deal with. After all, we are the ones in the store making the purchase, and the store is looking at maximizing their profit with me. When this done on the sales floor, it's fine. After all, that's the sales associates job. That is not the job of the cashier clerk. So, I've made up a list of 3 things that bother me at retail stores. More specifically, this list are things that bother me at the register, when I would like to finalize my purchase. So, here they are:

# 1. Eight Free Issues:

When I get up to the register, the LAST thing I want is to hear the cashier clerk trying to sell me on further purchases and sales. Listen, no offense, but I'm NOT standing at the register to make more purchases. So, I DON'T want to hear:

"Would you like to receive 8 free issues of Sports Illustrated, Entertainment Weekly, or US Magazine?"

The second problem with this, at least for me, is if I wanted magazines, I would've gone to my local grocery store or bookstore to get them. It seems to make more sense at a bookstore (read "Barnes and Noble"), for this type of behavior, then at an electronics store (read "Best Buy"). What's funny, though, is Barnes and Noble are not making that offer to me, and Best Buy is. What's wrong with this picture? Not that I want Barnes and Noble to start making the offer, because I don't. But don't you find it ironic that an electronics store is trying to sell you magazines, while a bookstore isn't? Huh.

Finally, why is the cashier selling me the magazines? Why didn't the floor associate? Because, as stated earlier, the retail store is trying to manipulate a vulnerability. Think of how silly this sounds (from the salesman on the floor):

"You've made an excellent choice. This TV will make you happy for years to come. Now, how would you be interested in 8 free issues of Sports Illustrated, Entertainment Weekly or US Magazine?"

Uh, wait a minute... What does a magazine have to do with the TV I just selected? Absolutely nothing. But, at the register (with you credit card in hand):

"With your credit card, you can get 8 free issues of .... ".

See how much easier it is to make the sale. It's manipulative, deceitful and completely dishonest.

# 2. Save 10% Today:

At least this point is somewhat relevant to the establishment, but it doesn't make it any less annoying. Back in the day, if you wanted to open a credit account at a retail store, you would go back to the credit desk, and open an account. You made the effort yourself to do so. Now, when at the register, you are bombarded with guilt and pressure. The pitch goes something like this:

"Would you like to save 10% on your purchases today by opening a credit account with us?"

I guess just having the credit applications silently at the register isn't doing it, so they have to start asking you, making absolutely 100% sure that they offer a credit account, just in case you weren't aware.

Let's not get this confused with memberships. I don't mind being asked at the register about yearly membership dues. For example:

"For $30 per year, you can open a membership with us that will save you 10% on every purchase you make in the store. Would you be interested?" That pitch is fine, because 1) they aren't pulling your credit, and 2) that's better than coupons, because I am always guaranteed discounts. So, if I shop at that establishment a lot (like I do at Barnes and Noble), it makes sense for me to save money. BUT, I am not interested in you pulling my credit, so I can save 10%, or maybe even 20%, on just one purchase. At least give my sky miles, so I can go on vacations. At any rate, the problem with this, is the company is pressuring you and placing guilt on you. See, the subconscious thinks "I'm saving 10%. That's a good deal. I can just pay it off with my checking account when I get home, and close the account. Then I just easily saved money. I would be stupid for not doing this." The retail store knows that's what you're thinking, and they love it. Well, they won't love it if you pay it off quickly and close the card before you even receive it in the mail, because they want a percentage of the interest profit that you are paying, which they get, and is the whole motivation for pitching it to you to begin with. Also, you're not thinking clearly either. What do you do during the Christmas Holidays when spending the whole day out shopping? Open a credit account at every store you walk into? Any loan officer, bank attendant, or someone with a head on their shoulders, will tell you that you are killing your credit score, and making your credit look bad. That's just not a good idea. You see, when pulling up your credit account via Experian, Equifax or TransUnion, the credit officer will see all this requests in a short amount of time, and what that translates to in the officer's mind is "They are getting themselves into quick debt. Does their income support this debt and will the be able to abide by the terms and pay it off?" In the long run, when trying to purchase a new car or house, you've killed your credit score, and you're debt-to-income-ratio is rising, by splurging during the Christmas Season. Now, when getting that house or car later in the year, you may not get the loan or interest that you are looking for. I know. I used to be a credit officer, and I saw it day in and day out. # 3. Your Phone Number: The worst one of all. Actually, I've begun to see this less and less lately, so retail stores must be wising up. However, I still see it from time to time, and I always give them an automated response. But first, a story. I was at an electronics store, of which I can't even remember the name. They've since closed their doors filing bankruptcy, and aren't around anymore. But anyway, I was purchasing some RCA cable for my stereo system, and a PDA. We're talking about a$500 total purchase. When I got to the register with my merchandise, the cashier asked me for my phone number. Being security conscious, as always, I told him that I won't be giving it to him. He then told me that I could not make my purchase until I gave him my phone number. Shocked, I still told him no. Eventually, the store manager came, trying to explain to me that my phone number was needed to track my purchases for returns. I told him that is what receipts are for, and I won't be giving out my phone number. Finally, I gave in, and provided him with (333) 333-3333. I told him, that if the store wants my purchase, that's as good as it's going to get. Otherwise, I'll go elsewhere. They took the number, and I was on my way. I couldn't believe it! The retail store was trying to keep themselves from making money all over a phone number. *BLINK* *BLINK*. Wow. No wonder they filed for bankruptcy.

At any rate, the only reason that retail stores want your phone number, is to sell it to soliciting corporations. It's how the industry works. Retail stores become reliable phone books for anyone who wants it. Your information up for grabs to the highest bidder. What you don't realize is the amount of information that is sold:

• the date and time of purchase
• the purchase total
• your phone number
• your name (if you paid by check or card)
• your address (if paid with a check)
• the store the purchase was made
• and how many times you've been in

That's a lot of info, and in some cases, very sensitive. You think it's just your phone number, but you're sadly mistaken. The marketing department is smarter than you give them credit for. How do think you get so many solicitors on your phone? By sheer coincidence?

So, when presented with this, I learned my lesson from that electronics store many years ago. If they ask for your phone number, pay with cash, and give them "867-5309". Yes. If you're smarter than the average fruitcake, you'll recognize that number from a song, under the same title, by the artist Tommy Two-Tone. The funny thing is, most cashiers are NOT smarter than the average fruitcake, and type it in straight away. After handing that number out to retail stores hundreds of times, I've only had one person call me on it. "Isn't that a song?" Whaddya know.

So, there you have it. My 3 personal annoyances that bug me beyond no end. The great thing is, I am going to have a shirt made that says right on the front:

1. I don't want 8 free magazines.
2. I don't want to save 10%.
3. My phone # is 867-5309.

Let's see how that goes over this Christmas Season. 🙂

### Irssi GUI Notify

I am currently connected to two Irssi instances coupled with screen. One instance at home, for all my personal IRC needs, and the other at a corporate LAN for secure inter-office IRC messaging. It works great, except when someone tries to get a hold of you (a highlight). I haven't found any good way for Irssi to notify you when you have been highlighted in a channel. For the past couple years, it hasn't been bothering me. Then, I found a pretty slick notification system for Irssi, and now I'm hooked. Here is a how-to for getting a GUI notification on your desktop (Gnome or KDE) when someone highlights you in a channel.

For this tutorial, it assumes that Irssi is running on a box separate from your current local machine that you have SSH access to. For example, at work, we have an inter-office server that is running an IRC server. I just SSH into that server from my workstation, fire up screen then Irssi, and connect to it. Irssi is running remotely from my desktop. This is also the case for my personal Irssi session. So, in other words, Irssi is running under screen remotely, and you connect to that session from any other computer via SSH.

First, there is fnotify.pl, a Perl script for Irssi to save the highlights you get in a channel to a file. Save this script to your ~/.irssi/scripts/ directory:

aaron@achilles:~$mv fnotify.pl ~/.irssi/scripts Now, if you want the script to run automatically when you launch Irssi, then create a directory called 'autorun' in the ~/.irssi/scripts/ directory, and create a symbolic link to fnotify.pl so Irssi starts it up automatically when loaded: aaron@achilles:~$ cd ~/.irssi/scripts/autorun && ln -s ../fnotify.pl .

Once copied in, either start your Irssi session, or if it is already running, then execute the script in Irssi itself:

/RUN fnotify.pl

When running, it creates a file called 'fnotify' in the ~/.irssi/ directory. It is just a plain text file containing all the times you have been highlighted in a channel, one highlight per line.

We need to get the highlights in the appropriate channel to our desktop, so we can visually see them when we are not looking at Irssi itself. You will need notify-send to notify you when someone says your name in a channel. If not installed, install libnotify-bin (Ubuntu/Debian syntax below):

aaron@hercules:~$sudo aptitude install libnotify-bin Now, we just need to write a shell script to send us the GUI notifications. This can be done with a simple Bash script (yes, from the same page we got the Perl script for Irssi). Save it anywhere on your local box (not the box that is running the Irssi instance; like your workstation, for example) and execute it (here, I saved it as 'irssi_notify.sh'). In the script above, you need to replace 'remote.system.somewhere' with your server that you are connecting to. The script makes an SSH connection to the server that you specified, and parses through ~/.irssi/fnotify one line at a time. Each line gets its own notification. That line is then removed from the file, so it doesn't continuously grow as you continue to get highlighted in channels. There you go. That's it! Pretty easy, but a little hackish. But that's okay. Isn't that what computers are all about? To automate human tasks? Besides, what fun would it be, if it weren't hackish? At any rate, a screenshot of the notification results is shown below (you can see the notifications in the bottom-right of the screenshot). But first, a couple caveats: 1. If the screensaver kicks in, and you are highlighted in a channel, you will not receive a GUI notification. This is default behavior with libnotify-bin. 2. By default, Irssi only highlights the nick that mentioned your nick if your nick is first on the line. Otherwise, it is not the case. This can be fixed highlighting the nick that mentions your nick anywhere in the text. Do the following in Irssi: /hilight -nick (your_nick) Thanks to Clint for bringing this to my attention! Click for a larger screenshot. ### SSH Key Authentication This is going to be old hat for some, but I know there are those who can benefit from it, so I'll post a brief tutorial here. This post is to extend upon the post published by Christer on Ubuntu Tutorials. There is a lot of software on the Linux system that I take for granted, and I am sure there are many reading this post who also do not realize the full power of SSH. Among those two goldmines are SSH key authentication and sshfs. First, SSH key authentication (sshfs for another post). There are two ways that a server can recognize that a user is trying to access it: passwords or keys. Both provide the server with the security that the person at the local machine is who they say they are. Of course, if the local system is compromised, there is no way for the server to know. However, with that said, hopefully, it's basic user error that created the compromise in the first place. But nevermind that. I'm rambling. Many of us use SSH daily. Probably more times than once throughout the course of the day. I know I do. At work, I SSH into my home box for secure proxy, as well as SSH into the office server. With the office server containing many virtual servers, I find myself using SSH a few times more. On top of that, we use SVN to manage our code collaboration. We use svn+ssh to check in the code. Needless to say, I find myself using SSH several times throughout the course of the day. One major problem is typing my password at every pass. Key authentication fixes that. Using SSH key authentication, I generate a private and public key. With this key pair, I then append the public key to an authorized keys file, telling the remote system that I can use it if a private key is supplied. If the remote system can match the public key to the private key that I am supplying, then I don't have to worry about a password. It won't ask me for one. It knows I am who I say I am. So, how do we make this happen? Simple. SSH provides a set of utilities that make it really easy. First, we need to generate the key pair. When asked, you should provide a passphrase for the key. This is highly recommended, as doing a passphraseless key authentication means that anyone can use your key when at your computer, which sucks even more if it gets compromised. Type in a passphrase. Save yourself the pain. ssh-keygen -t [dsa|rsa] As you can see, you can generate either a DSA key or an RSA key. It doesn't matter which one you generate. For me, I generated a DSA key. So, I need to append the public DSA key to the authorized keys file found in my home directory. First, copy over the file to the remote server: scp ~/.ssh/id_dsa.pub user@yourserver.com:~/ Then ssh to the remote server, and append the contents: ssh user@yourserver.com cat id_dsa.pub >> .ssh/authorized_keys If the file didn't exist, then you just created it. If it did exist, then you appended your key to the end of the file, leaving any other keys in the file in tact. Continue to add your public key to as many remote servers in this fashion as possible. Once added, you can remove the public key. Ok. Now, we have SSH using key authentication, rather than password authentication. The only problem is, we're still typing in our passphrase when trying to connect remotely. I thought the point of key authentication was to get rid of that. It was, and it's still possible. We need to use the SSH agent to manage our passphrase when logged in. Luckily, if using Gnome, you already have an SSH agent running. I don't know about KDE. ps aux | grep ssh-agent aaron 5142 0.0 0.0 4484 448 ? Ss Feb07 0:00 /usr/bin/ssh-agent /usr/bin/ssh-agent /usr/bin/dbus-launch --exit-with-session /usr/bin/gnome-session As you can see, Gnome is managing my SSH agent for me. However, only when logged in via the GDM. If Iog out of Gnome, then my ssh agent is lost. So, this means, if you log in via a terminal without X, then you will need to start the SSH agent. What is the SSH agent, exactly? Well, it manages your passphrase along with other variables when you login to remote servers using SSH key authentication. So, if you login using the SSH keys, and you're prompted for your passphrase, your passphrase is stored in the agent. Which means, that you can keep it there, so you won't have to edit it again. The way to do this is add your key to the agent along with your passphrase: ssh-add That will do the trick. Now, SSH into the remote server. It will ask you for your passphrase. Now logout and log back in. Did it ask you for your passphrase again? If you've followed all the steps, then it shouldn't have. Reason being, is both your key, and it's associated passphrase are being stored in the agent. The SSH agent manages the two together, and any future logins, regardless of remote server (as long as your public key is on that server), will not ask you for a password or passphrase. Pretty cool huh? Just wait, it gets better. You can forward your agent from session to session. This means, as long as you have your public key in the authorized keys file, you will never be asked for your password or passphrase. The agent can be carried across the session. Just edit your /etc/ssh/ssh_config file, and uncomment the line that says "ForwardAgent no" and change it to yes. sudo vim /etc/ssh/ssh_config Let me give you an example to help illustrate the process. John generates his SSH key pair, and adds the public key to his SSH server. He then adds his key to the agent, enables forwarding his agent, and SSHs in. He is asked for his passphrase. After done with his work, he logs out. Unfortunately, he forgot to edit a certain file, so he SSHs back into his server. This time, because he logged out remotely but not locally, he is not asked for his passphrase. Kelly, his girlfriend, needs help with her SSH server, and asks him to sign in. He does, but this time, the SSH server prompts him for his password. "Odd" he thought. I am forwarding my SSH agent. I shouldn't ask me for this. Well, if he didn't add his public key to Kelly's authorized key file, then of course it will. If he had his public key in the authorized key file, then Kelly's server would not ask for anything, and just load right up. Does that make sense? His agent is being forwarded from remote session to remote session never asking for a passphrase or password, as long as the public key is in the authorized keys file. You just need to remember 'ssh-add' when logging into Gnome. If logging into KDE or another window manager, then you may need to start the agent: ssh-agent I am unsure about what window managers you would need to run that command in. I just know with Gnome, you don't need to worry about it. No more asking passwords or passphrases when you use SSH. This makes it especially handy when using svn+ssh. If you check in code a lot, this will save you a ton of typing at the shell. So, there you go. Secure SSH key authentication made simple. You have security first in mind when generating the keys, and supplying a passphrase. You make things simple by using SSH agent to manage your key sessions and your passphrases. Finally, your forward your agent across multiple machines, regardless of how deep, keeping the simplicity and ease of use in mind. The whole time, security is first on the agenda. ### 2007 Resolutions Today is the day that men reflect on their lives, and decide to make changes, hopefully, for the better. But for me, rather than make some idle promises on goals on stuff that I am not working on (that I most likely won't do), I'm just going to try and improve on the things that I am currently doing. So, with that said, here are my resolutions for the upcoming year of 2007: Goal: Reach my desired weight of 180 pounds. Resolution: Currently, I am working out at 24-Hour Fitness in Murray. I usually either hit the pool or the cardio machines. Well, I need to keep at a workout level where I'm burning around 400 calories per session. I've been meaning to train for a triathlon, so that will be my motivation to keep this level of exercise up. Also, this past holiday, I decided to change my diet, and take an "agnostic vegetarian with a sense of balance" stance on eating. I define it as eating red meat rarely (once/twice a year), white meat on occasion (once/twice a month), and seafood regularly (once/twice per week); drinking green tea twice per day; completely eliminating starch (white rice, white bread, russet potatoes); completely eliminating soda (I'm on week 9 already for that (no more Dr Pepper)); removing my dependency on sugar. Goal: Increase my knowledge of Perl, PHP, Python and Ruby, and become proficient at all 4. Resolution: With the increase of Perl scripts that I have been writing at work, it's time to take Perl to the next level, and learn the Object-Oriented nature of the language. I enjoy using the language to accomplish my task, but I believe that I can take it farther. Also, I have been dabbling in Ruby, which seems to be a fun language, so I need to get more proficient there. Still, I have yet to really sit down, and learn Python. It looks like a solid language, but also seems to be a difficult one to learn. I just need to sit down, and start playing with it, when projects come up. Finally, I know a little PHP, but not enough to take a full-time job as a PHP developer. It's a language I'm interested in, but don't know enough about. Learning 4 languages at a time will be time consuming, and slow down the progress of each instead of becoming proficient at one at a time, but they are tools that I think are necessary in a scripters belt. That's it. Two goals. Two resolutions. Nothing overly fancy or difficult, and certainly, nothing to overwhelm me with. I'm usually pretty good with New Year resolutions, and keep most of them throughout the year. I think both of these are manageable, and definitely doable. Happy New Year! ### Perl Versus Ruby on CSV Ok. I had a little project at work, at which point, I turned to Perl to accomplish the task. The project was simple enough: take a comma-separated file, and look at a few fields to see what data is contained. Based on that data, create a "weight", and assign the weight to the record at the end of the line. The Perl code I used to accomplish the task is as follows (please take note, that WordPress loves to parse tags, even if contained within <code> tags. WordPress also likes to lowercase the tag, so in Perl, file handles will be in lowercase):  1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 #!/usr/bin/perl -w open(IN, "UNIVERSE.csv"); open(OUT, ">UNIVERSE_WEIGHTED.csv");$counter = 0; while() # (for Wordpress) {     @fields = split(/,/,$_,183);$fields[182] =~ s/\n//;     s/\n//;     $counter++;$weight = 0;     if ($counter == 1) { print OUT$_ . ","weight"\n";     }     else     {         $vtr_ppp00 =$fields[154];         $vtr_ppp04 =$fields[155];         $vtr_pri01 =$fields[161];         $vtr_pri03 =$fields[163];         $vtr_pri05 =$fields[165];         $vtr_pri99 =$fields[182];         $weight +=.5 if ($vtr_ppp00 eq ""R"");         $weight -= 1 if ($vtr_ppp04 eq ""D"");         $weight -= 1 if ($vtr_pri01 eq ""D"");         $weight -= 1 if ($vtr_pri03 eq ""D"");         $weight -= 1 if ($vtr_pri05 eq ""D"");         $weight -= 1 if ($vtr_pri99 eq ""D"");         $weight += 1 if ($vtr_ppp04 eq ""R"");         $weight += 1 if ($vtr_pri01 eq ""R"");         $weight += 1 if ($vtr_pri03 eq ""R"");         $weight += 1 if ($vtr_pri05 eq ""R"");         $weight += 1 if ($vtr_pri99 eq ""R"");             print OUT $_ . ","" .$weight . ""\n";     }         print "Processed: " . $counter . "\r"; } print "\n"; close(IN); close(OUT); Just for fun, a buddy of mine mentioned to code it in Ruby, and compare results. Seeing as though I have never coded a Ruby script in my life, I was a bit worried. However, it wasn't too bad. I just had to cure my itch to put a$ in front of all my variables. Anyway, heres the Ruby code, following as closely as possible to the Perl code:

 1234567891011121314151617181920212223242526272829303132333435363738 #!/usr/bin/ruby counter = 0 outfile = File.open("UNIVERSE_RUBY.csv","w") IO.foreach("UNIVERSE.csv") do |line|     counter += 1     weight = 0         if (counter == 1)         outfile < < line.chop + ","weight"\n"     else             fields = line.chop.split(',')         vtr_ppp00 = fields[154]         vtr_ppp04 = fields[155]         vtr_pri01 = fields[161]         vtr_pri03 = fields[163]         vtr_pri05 = fields[165]         vtr_pri99 = fields[182]                 weight += 0.5 if (vtr_ppp00 == ""R"")         weight -= 1   if (vtr_ppp04 == ""D"")         weight -= 1   if (vtr_pri01 == ""D"")         weight -= 1   if (vtr_pri03 == ""D"")         weight -= 1   if (vtr_pri05 == ""D"")         weight -= 1   if (vtr_pri99 == ""D"")         weight += 1   if (vtr_ppp04 == ""R"")         weight += 1   if (vtr_pri01 == ""R"")         weight += 1   if (vtr_pri03 == ""R"")         weight += 1   if (vtr_pri05 == ""R"")         weight += 1   if (vtr_pri99 == ""R"")                 outfile < < line.chop + ","" + weight.to_s + ""\n"     end     print "Processed: " + counter.to_s + "\r" end print "\n"

Ok. As you can see, the code is fairly similar. The algorithms the same. Running the script takes a mere second or two, and the file comes out correct. However, I was curious about execution speed, so I decided to pit one script against the other, time them, and see what happens. Here are my results

aaron@hercules:~/Desktop$time perl weight.pl Processed: 5394 real 0m1.386s user 0m1.304s sys 0m0.048s aaron@hercules:~/Desktop$ time ruby weight.rb
Processed: 5394

real    0m2.180s
user    0m1.992s
sys     0m0.124s


Am I reading this correctly? Perl is almost 60% faster at execution with this code than Ruby? I thought Ruby was supposed to have exceptional file handling. Better than Perl, even. However, I have also heard that the Ruby devs are more concerned about functionality than speed, which should be expected. Still, that's a serious speed factor. If I was worried about speed here, Perl, in this case, would win out.

At any rate, this was a fun little exercise to stretch my scripting muscles, and to learn a bit of Ruby. I'm curious if I can make the scripts more efficient. If you know how, comment below, or contact me.

### Use Vim

With all the Perl programming that I have been doing lately, I need a good editor. GEdit, KWrite and company are OK, but I need something with a bit more umph. The Perl plugin for Eclipse is very nice, but Eclipse is a bit much for what I'm doing with Perl, which is just simple scripts.

Enter vim 7.

I've always been a fan of vi and it's various incarnations, particularly vim (nvi and elvis are nice, but vim takes the cake). The problem is learning all the funky commands to navigate around it. I don't mind learning them, I just lack the motivation to do so. So, I end up using GEdit or some other GUI editor. However, today, I learned a number of commands that are making my outlook on vim easier.

:Explore

How did I not know about this command before? Turning vim into a file explorer?? Rock on!! Thanks to Black_Chaos for this tip!

:cd /path/to/file/directory/

Extending the ability to browse to any directory with :Explore, you can change directories in vim itself, and open a file from there. Thanks herlo!

:tab{new, close, next, previous, etc.}

For those who are now caught with your pants down, vim 7 supports tabs! This is really great news, as I usually have more than one file open at a time. Word to dataw0lf.

:<up_arrow> and :<tab>

The thing that separates the boys from the men is the ability to take advantage of your history and tab completion in bash. The same goes for vim. <up_arrow> will allow you to browse through your history and <tab> will auto-complete vim commands.

This is pretty cool stuff. And it only gets better from here. Using search and replace, regex, cut/copy/paste, undo, and many more are available. These are just a few of the commands that I have stumbled upon while playing around with vim today.

One last thing about vim, however, that I need to cover. Text- or console-based applications don't appeal to everyone, and vim's learning curve can be very intimidating. So, there are some developers that have created graphical front ends to vim, to make the learning curve less painful. GVim is no doubt the most popular, but I have a better application: Cream.

Cream has the ability to be used in vi, vim or natively as Cream itself. When running as Cream, the default behavior, all the "standard" keyboard shortcuts are used on the file. Save (^s), cut (^x), copy (^c), paste (^v), etc. However, you can use Cream in vim mode, and act as though you were sitting in the terminal using it directly. The greatest advantage that Cream offers over GVim, in my opinion, is column editing. I can't begin to tell you how nice it is to type the same thing on every row simultaneously. Especially helpful when programming.

Anyway, that's it about vim for the time being. I'm sure I'll come across more cool commands as the days wear on. I'd just thought that I would share these.

### Dvorak-QWERTY Irssi Script

In #utah on Freenode, there has been some active discussion lately about Dvorak vs. Qwerty. As such, ibot, a channel bot, has the ability to display text when someone enters a channel. Some of the chatters, including myself, have a join that is "encrypted". Well, not really, per se, but rather, just Dvorak text that was typed using the QWERTY layout. One such join is as follows:

>>> vontrapp
Dr, co yd. Ekrpat jrmcbiZ

Not exactly intuitive as to what is trying to be said. The only way to figure it out, is set your keyboard layout to Dvorak, and type the letters as they would appear on a QWERTY keyboard. Doing so would produce:

>>> vontrapp
How is the Dvorak coming?

As we began discussing in the channel, we thought that it would be great if we could have ibot do the decoding for us. Well, I'm not familiar with blootbot or it's scripting capabilities, so I wrote a script for Irssi that can convert any "Dvorak text" to QWERTY and vice versa. The commands to run are '/dv some text here' and '/qw some text here'. When ran, it just puts the the result in the channel in a single line, as to not flood or annoy the channel. The script does not utilize color, but that could be added easily to help identify the difference between the input and output text.

Here is the code below (no syntax highligting. Sorry). Save it as 'dvoark-qwerty.pl' in your ~/irssi/scripts/ directory, and run "/script load dvorak-qwerty.pl" in Irssi.

 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 # dvorak-qwerty.pl # Aaron Toponce (aaron .toponce@gmail.com) # Decodes dvorak to qwerty and qwerty to dvorak # # qwerty layout (from left to right, top to bottom): _+QWERTYUIOP{}ASDFGHJKL:"ZXCVBNM<>?-=qwertyuiop[]asdfghjkl;'zxcvbnm,./ # dvorak layout  (from left to right, top to bottom): {}"<>PYFGCRL?+AOEUIDHTNS_:QJKXBMWVZ[]',.pyfgcrl/=aoeuidhtns-;qjkxbmwvz use Irssi; use strict; use vars qw($VERSION %IRSSI);$VERSION = "0.1"; %IRSSI = (         authors     =>  "Aaron Toponce",         contact     =>  "aaron.toponce\@gmail.com",         name        =>  "dvorak-qwerty",         decscription    =>  "Decodes dvorak-to-qwerty and reverse",         license     =>  "GPLv2",         changed     =>  "$VERSION", commands => "dvorak qwerty" ); sub qwerty2dvorak($) {         my ($text) = @_;$text =~ y/\_\+QWERTYUIOP\{\}ASDFGHJKL\:"ZXCVBNM\<\>\?\-\=qwertyuiopasdfghjkl\;\'zxcvbnm\,\.\//\{\}"\<\>PYFGCRL\?\+AOEUIDHTNS\_\:QJKXBMWVZ\'\,\.pyfgcrl\/\=aoeuidhtns\-\;qjkxbmwvz/; # "         return "'@_' to dvorak: " . $text; } sub dvorak2qwerty($) {         my ($text) = @_;$text =~ y/\{\}"\<\>PYFGCRL\?\+AOEUIDHTNS\_\:QJKXBMWVZ\'\,\.pyfgcrl\/\=aoeuidhtns\-\;qjkxbmwvz/\_\+QWERTYUIOP\{\}ASDFGHJKL\:"ZXCVBNM\<\>\?\-\=qwertyuiopasdfghjkl\;\'zxcvbnm\,\.\//; # "         return "'@_' to qwerty: " . $text; } sub dvorak_decode($) {         my ($arg,$server, $witem) = @_; if($witem && ($witem->{type} eq 'CHANNEL' ||$witem->{type} eq 'QUERY'))         {                 $witem->command('MSG ' .$witem->{name} . ' ' . qwerty2dvorak($arg)); } else { print qwerty2dvorak($arg);         } } sub cmd_qwerty($) { my ($arg, $server,$witem) = @_;         if($witem && ($witem->{type} eq 'CHANNEL' || $witem->{type} eq 'QUERY')) {$witem->command('MSG ' . $witem->{name} . ' ' . dvorak2qwerty($arg));         }         else         {                 print dvorak2qwerty($arg); } } Irssi::command_bind('dv',\&cmd_dvorak); Irssi::command_bind('qw',\&cmd_qwerty); Irssi::signal_add('message public', sub {dvorak_decode($_[0], $_[4],$_[1]);} ); Irssi::signal_add('message own_public', sub {dvorak_decode($_[0],$_[2], $_[1]);} ); print "%B>>%n " .$IRSSI{name} . " " . $VERSION . " loaded"; ### Using Screen Effectively One of the biggest tools that I use is screen. Not only for irssi, my preferred IRC client, but for other things as well. When I show people screen, it's funny to see the look on their face. They take a step back, and say "Wow. That's really cool". I hope somehow that I can convey that same excitement in this meager post. First off, screen is a wonderful tool that allows you to run a program in a terminal inside a special "session window". You can "detach" the window, exit your terminal, go to work, open up a terminal, and "reattach" the "session window", and your terminal status will be in the exact same state as when you left. This is handy for running programs, such as irssi, where you can pick up right where you left off without missing a beat. To run screen, obviously, you need it installed. Once installed, pull up a terminal, and type: screen A message may come up about screen, where to download it and how to file bugs. Then it will take you to your default prompt. It may just take you there anyway without the "about" message. At any event, you are now running a "session window" inside your terminal, and you should be at your normal prompt. You can have multiple "session windows" running side-by-side, basically acting like "tabs" in gnome-terminal. You can also have nested screen sessions. The complexity of how differing screen sessions can be run won't be covered here, but may be covered later one-by-one. For the time being, we'll just cover single screen sessions. You can now "see" your screen session by typing 'screen -list' at the prompt. A brief output about the PID and whether or not it is "attached" is printed to your terminal. You could see something similar to the following output: aaron@hercules:~$ screen -list
There is a screen on:
23454.pts-1.hercules    (Attached)
1 Socket in /var/run/screen/S-aaron.

Once inside screen, there are a number of keystrokes that control the movement inside of screen. Such as detaching and reattaching your session, moving forward and backward from one session to the other, logging out, clearing the window, and many more. Usually, the keystrokes are in the form Ctrl-a, letter. For example, while in screen, as you currently should be, type "Ctrl-a, d" to detach out of your session, and back to the normal terminal. That is, type and press "Ctrl-a", release, type d, release. Your session is now "detached". To "reattach", type 'screen -dr' at the prompt.

When detaching and reattaching multiple screens, it may be difficult to know exactly what is being "attached" and "detached". To save any confusion, never forget 'screen -list' (or 'screen -ls') to show you what you have running. When "reattaching" a session, it is safest to type 'screen -dr', which says "run screen, but first detach my running session (-d), then reattach it here (-r). This works if you have only one screen session running. If multiple, you will need to provide the PID also. See 'man screen' for further detail.

Ok. Let's see this in working action. As I mentioned, I use irssi as my default, and only IRC client. However, I don't want to disconnect and reconnect to IRC every time I change my location. So, rather, I run irssi inside of screen. So, first I pull up my terminal, and I am greeted with my friendly terminal prompt. I'll call this prompt "Prompt A". From Prompt A, I run 'screen'. I am now met with a new terminal prompt which I'll call "Prompt B". Prompt B is a running session "inside" Prompt A. From here, I run 'irssi' at Prompt B. I connect to my various IRC servers and chat away.

Now, it's time to go to work. I have two options at this point. I can either: 1) close my terminal directly, or 2) detach my screen session, and exit nicely. If I choose to close my terminal directly, I can rest assured that my IRC connections won't change. Irssi is being protected by my screen session, so closing the terminal will have no effect on it. However, I like to exit everything cleanly, so I issue the keystroke 'Ctrl-a, d' to "detach" my screen session. I am now back to Prompt A. From here, I 'exit' to close the terminal, and go to work.

When I arrive at work, I SSH into my box running my screen session. Once SSH'd in, I am met with Prompt A. I want to start chatting in the IRC session that I started at home. So, at the prompt, I type 'screen -dr' to "detach" the screen session (if I just closed the terminal directly) and "reattach" the session to my current location. My irssi application returns to the screen just as I left it when I was home. I can now start chatting away as if I never disconnected from any of the IRC servers.

Take a second for that to sink in. That rocks! I never missed a beat, and to the others in the channels, it's like I've never left. As far as they know, I'm still at home. It just doesn't get much better than that.

That's just using a single screen session. As I mentioned, you can use multiple screen sessions running side-by-side, or nested screen sessions, depending on your current situation and needs. With multiple screen sessions running in concurrence, you don't need a terminal that has all the bloat with tabs, profiles, etc., such as gnome-terminal. You can use RXVT, and have the same effect of tabs just using screen.

Finally, you should learn how to kill a screen session. When the need for a screen session has expired, rather than letting the process run in the background taking precious RAM, you will need to expire the session. To do this, you need to get the PID from your box. Just 'screen -list' to get that PID. The PID will look something like 23454.pts-1.hercules. Now that you have the id, just type at the terminal (you need to be at a prompt):

screen -X -S ID kill

This will kill the session and the process, as well as any application(s) that were running inside it.

### Perl, substr, and line feeds

Ok. This may come to most of you as "DUH", but for me and a few helping me, we couldn't figure it out. Consider the following Perl code:

 123456789101112131415 !#/usr/bin/perl -w open(IN, "oldfile.txt"); open(OUT, ">newfile.txt"); while(<IN>) {     $var1=substr($_, 0, 10);     $var2=substr($_, 10, 5);     $var3=substr($_, 15, 3);     substr($_, 0, 3)=$var3;     substr($_, 3, 10)=$var1;     substr($_, 13, 5)=$var2;     print OUT $_; } close(IN); close(OUT); Fairly straight forward. Nothing fancy here. I've assigned 3 variables some text from the current line, and rearranged their order, then printed out the new order to newfile.txt. If oldfile.txt is 100 characters long on each line, and 500 lines long, then newfile.txt is also 100 characters long on each line and 500 lines long. However, what if I only want to print the first 18 characters on each line to be in newfile.txt rather than the whole line? Than rather than:  1 print OUT$_;

I would need:

 1 print OUT substr($_, 0, 18); Ah. But do you notice anything wrong with the code above? I didn't, and it took 8 hours of sleep later to figure it out. When printing out the whole line ($_), the line feed as the last character on that line. Thus, newfile.txt will also have the line feed. However, if using substr() in the middle of the line, not including the last character of the line (the line feed), then the line feed doesn't exist, and Perl attempts to write every line on the same line. So, rather, we need to append a line feed at the end:

 1 print OUT substr(\$_, 0, 18) . "\n";

Much better. Something so simple, yet easily overlooked.

### Personal Philosophy Problems

I came across something that is problematic for me. I guess I really knew it all along, but today it hit home, and I put 1 and 1 together.

By default, Ubuntu ships with two repositories that are fully supported: main and restricted. These two software repositories include all the necessary software to get a basic user up and running. Office suites, multimedia, Internet applications, sound, video, wireless, and much more. These two repositories make up the Ubuntu distribution.

But, Ubuntu, by default (yes, it ships with this turned on), includes non-free software. I don't know all the software included at this point, but the fact is, it is there. It's in the restricted repository, and it is fully supported by the Ubuntu team and their developers. So far, the only software though, that I have found, that is non-free, are device drivers for hardware (I'm sure there is more, like PDF support, I just haven't dug it up yet). User-end software (apps that don't drive hardware) is all in the main repository and is free.

So, if you know me, this raises a major flag, and I don't know exactly where to go from here. Looking at my laptop, home desktop and work computer, they all have different video cards. My laptop is ATi, my desktop nVidia and my work PC, Intel. Problem is, I don't know what video drivers are free, and which are non-free. So, for the time being, I'm using the vesa driver until I can find a better free alternative.

But, because I use only free software in my personal life, where does that put me with regards to using and supporting a Linux distribution that uses and distributes non-free software? Here's what I've come up with so far.

1. Leave Ubuntu for Debian. As outlined in the Debian Free Software Guidelines, only free software is in the repos by default. There is a non-free repo, but as with Ubuntu, you need to open your /etc/apt/sources.list, and add it by hand. By making this change, though, I am basing the decision on principle, which means honesty to myself. That leads to me deleting forever MP3s that I downloaded during the days of Naptster and Kazaa.
2. Modify my personal philosophy. I would have to be very specific in how I change it. For example, the use of non-free software in my personal life would only be accepted on the hardware level (device drivers, etc.). The problem with this is the level of hypocricy, and the slippery slope it leads down. If it's okay on the hardware level, then certainly, it's okay on the protocol and format level too. I would have to draw a very definite line if I were to go this route. However, I would still be able to use my favorite distro and advocate it's use.
3. Using proprietary software on any level. Maybe I'm going too extreme, and need to recognize a balance between non-free and free software. Maybe using the Opera browser, for example, is just fine. But, then what is the sole reason that I use GNU/Linux in the first place? Is it to boycott Microsoft? Is it just a hobby or an interesting toy? Or is it because I like the ideals that propel GNU software and the Linux kernel? I tend to lean towards the latter.

Those are the only 3 options that are available and placed at my feet. Option #1 would be the superior choice, I think. But the likelyhood of me switching is slim. I have grown a deep appreciation for the hardware dection on Ubuntu and it's ease of use on the desktop. I love the commercial support, and it's regularly scheduled release cycle. Documentation is un-paralleled with any other distro, and the community is the largest currently. All of these are drawbacks to me when looking at Debian as an alternative, because they either don't exist, or just aren't on par with Ubuntu.

The 2nd choice seems to be the most likely, but the hardest to define. Where do I draw the line, and why am I drawing any line at all? If I am to use only free software that interacts with the user on a non-hardware level, then why not just go all the way? Why make an exception at all? After all, that is why I use GNU/Linux in the first place. It's open and free. I don't necessarily care about price, it's my personal freedoms that are important to me.

The last choice just won't happen. Again, I'm not interested in proprietary software, because it doesn't foster trust and community. It fosters risk to the user and monopolistic control to the vendor. As such, community suffers. I like the concept behind free software, because it fosters community and builds that trust. There also seems to be a level of maturity attained when developing and using free software. So this option is really out of the question for me.

So it sits between option #1 and #2. And the outlook for me choosing a path is 20% for the 1st and 80% for the 2nd. But I worry I might be rationalizing and justifying to use Ubuntu, and I don't want to feel that way. I want to make the decision, because I feel it's the best decision in this time of my life for me to make. Certainly, I use non-free software on my calculator, cell phone, entertainment system, and other things, so why not just define a set of rules, and stick to them?

Well, I've rambled for long enough. I'm interested in your feedback, so please, comment below on what you would do, what decision you think I should make, and why.

Thanks.

### Irrational Logic

Someone please, for the love of everything that is good and holy, explain the following to me. I am looking for rational, deductional logic, not opinions.

Why, when on IRC, I can use /me and /action, and no one could care less.

22:38:27                 atoponce dances
22:38:31                 atoponce is bored
22:41:05                 atoponce gets a drink

No one could care less. Everyone in the channel goes about their business, and life continues as normal. But, as soon as the word "away" is in the /me or /action, the whole IRC network is up in arms!

12:13:45                 atoponce is away: screen detached
12:13:51 < somedude> atoponce: don't do that. away scripts are annoying. thx.
12:13:59 < anotherdude> atoponce: away scripts suck
12:14:01 < wannabedude> atoponce: public away messages are lame, and you're
lame for using one. turn it off.

Uh, why? Again, I'm not interested in opinions. I want a hard core philisophical reason why away scripts suck. And if they suck so bad, what is so blasted difficult about /ignore away? Just curious. If anyone can shed light on this subject, I would be delighted.

### My First Irssi Script- Binary Timestamps

A couple nights ago, while on Freenode, lilo (Rob Levin) posted a small log of a chat in the channel, and I noticed that he was using the Unix Epoch time as his timestamp in his IRC client irssi. I thought that was genious, so I set out to code an irssi script that shows binary timestamps. Seeing as though I am still relatively new to Perl, I knew this would be a challenge, but I figured it wasn't too difficult to handle. So today, I set out to code such a script.

The first thing for me, again, because of my n00b skills, was to create a stand-alone program that converted the system time to a binary string representation. I wanted to test and retest that the conversion worked perfectly before testing it in irssi and crashing the program.

So here was what I had in mind:

1. Get the hours and minutes from the localtime on the system.
2. Convert the hours to a binary string.
3. Convert the minuts to a binary string.
4. Concatenate the binary strings together with the colon time seperator.
5. Store the concatention in the irssi timestamp variable.

The first four steps took no time at all. I could print them to the console and see the results. The wall that I hit was trying to hook it into irssi. I had no idea where to begin with that. So I figured I'd start looking at other scripts, and figure out exactly how to do it. There was also documentation on the irssi web site for creating brief scripts. Needless to say, it isn't that comprhensive, and I spend more time hacking than learning. I can easily say that learning the syntax and functions took 80% of the time getting this script finished.

Well, it's finished. It's a fairly easy and brief script. Nothing to it really. You can download the whole script here. To execute the script, just /script load binary_time.pl and to unload the script, just /script unload binary_time. I would be interested in feedback on the script, if you wouldn't mind testing it out.

Also, I received a couple emails and a comment on the last post regarding my hacked madcow theme, and if I could post it here. Sure, no problem. Here you go.

### Bash Meets Csh

So, continuing in my effort at work to convert many of the scripts that we have to Bash, I came across a problem: I am stuck at work using Csh. So, can I run this sourced file, which contains many Bash functions, in Csh?

For example, here is a brief rundown of my code:

 1234567891011121314151617181920 #!/bin/bash umask 000 alias one="blah" alias two="blah blah" alias three="blah blah blah" function_one() {     # some code here } function_two() {     # some code here     # some code here } function_three() {     # some code here     # some code here     # some code here }

And so on. Basically, a single file that contains many aliases and many functions. If this file is sourced, can I use the functions in csh?

YES! YES!! YES!!!

Of course I can! That is the great thing about Linux! I have options. I have choices. If I can program with one scripting language, but I am stuck using another (like I am using Csh at work), as long as I reference the executable and it is installed on the system, I can use it. I don't have to source the file either (although in my case at work, I do). I can run any script in any language using any shell. Again, just as long as the language is installed and the executable referenced.