Archive for October 2010

Einstein On The Moon – Tool: Sober

Getting dos2unix and unix2dos On Ubuntu

Since – unlike most other Linux distros – Ubuntu doesn’t come standard with either dos2unix or unix2dos, you have to install it yourself.  The package “tofrodos” in the repos is what you’ll want, and the simplest method to install it is, of course:

sudo apt-get install tofrodos

However, unless you want to retrain yourself to use their naming conventions (which I certainly don’t), you’ll want to add one final piece to the process:

vi ~/.bashrc

In there, add two new aliases:

alias dos2unix=’fromdos’;
alias unix2dos=’todos’;

Save and exit, and then simply type the following to update your session:

. ~/.bashrc

DO NOT, however, do that with your .bash_history file, as Philip Olson did a couple of years ago.  ;-P

JavaScript In Smarty

Just before I gave up with Serendipity – which uses the Smarty templating engine – I was trying to add some Google Analytics code into the template.  Because GA creates an anonymous function in JavaScript, instead of simply including the remote JS source file (which does make sense, in reality), it includes curly braces — and Smarty hates that.  It prompted me with errors about unknown tags and stuff.  Hooray.

Well, thankfully, the fix was simple: wrap the JavaScript code in ‘literal’ tags.  Example:

<script language="JavaScript">
alert('Smarty takes this literally.');

Goodbye, s9y!

I’d finally had it.

Serendipity had a bunch of issues that were interruptive at best — destructive at worst.  I know plenty of other people have had success and been quite pleased with it, but it just wasn’t the right fit for me.  I’d known it for some time, but let’s face it: unless you’re a “blogger” by trade, you probably have more important things to do than update your personal hobby site.  I fell right into that camp myself.  I just couldn’t be bothered trying to convert it to something else.

Enter: WordPress.

Through one of my companies, PilotPig Web Hosting, we frequently get hosting orders for WordPress sites.  So the account is created, activated, and WordPress is installed for the customer.  I’ve done literally a few hundred installations and some basic customizations of the package, but I’ve never actually used it myself — until right now.  Seems decent.

Well, the one problem I thought I’d be facing was getting the posts from Serendipity imported into WordPress.  I was wrong.  All I needed to do was grab the full RSS 2.0 feed from s9y (/rss.php?version=2.0&all=1), save it to my Desktop, then run it through a quick conversion script that took all of two minutes to write:
if (!isset($argv[1])) {
echo 'Enter the RSS feed file to convert: ';
$argv[1] = trim(fread(STDIN,128));

$data = file_get_contents(dirname(__FILE__).DIRECTORY_SEPARATOR.$argv[1]);


Then just import it using the WordPress RSS importer tool, and – ta-da! – my work here was done, and I could go back to my day.  Neat.

Merging Contacts on Android Phone

I don’t give a damn if it starts Jihad — my DROID could kick an iPhone’s ass with its keyboard locked shut and the screen powered off.

Still, at times, I want to shove it up the ass of a goat and send the goat off to the slaughter. The latest update to be deployed on Verizon Android devices is a great example of that, because it royally sucks. That and the camera — the DROID camera rots like a dead possum in the desert sun.

Today was another minor inconvenience that had me sternly telling my phone it was a pain in the ass: I was told that I could not edit Facebook contacts in my own phone’s contact list, and was given the options of “Done” and “Revert.” Revert what? You wouldn’t let me do anything in the first place!

Thankfully, after poking it with a stiff index finger and swiping at it like a cat playing with a ball of yarn (what the hell is with today’s animal theme with me?!?), I finally figured out how to resolve the problem.

Add a new contact by the same name as the one sync’ed from Facebook and save it. Then go in to edit that contact, and click the menu button to bring up additional options. Click “Join” and select the contact with whom you want to join the current record. Sometimes Android is able to intelligently match which contacts you would likely want to join (for example, Rodney DelaRosa with Rodney DelaRosa, which was what I first tried). Other times it could not (Anne Killins-Wahl with Boney Wailin). You can simply click “All Contacts” and scroll to the right one, though, which is fair enough. Then it will attempt to merge the contacts in a simple but logical fashion. You may need to edit a few fields sometimes, but I only had that problem once (oddly enough, with my wife’s contact info). Click “Done” and…. well, if you can’t guess what happens after that, maybe you can join the goat. Or possum. Or…. just go away.

SSH Client On Ubuntu Desktop Timing Out

It would happen again and again and again…. I’d walk away from the computer (yeah, on rare occasions that happens), or I’d flip to another terminal and get sidetracked there:

Write failed: Broken pipe

Son of a bitch! And why the hell don’t I remember to vi in screen until moments like this?!?

Well, unless I keep ‘top’ open or run a while [ 1 ]; do echo -n '';sleep 30; done, it continues to drop out without fail. And an interesting (to me) fact that I’ve actually recorded: I spend more than 60% of my day on the command line.

Logically, the first things I tried were to add /etc/ssh/ssh_config parameters for both KeepAlive and TCPKeepAlive, but that still had no positive effect. Then I started to dig deeper into the issue to see what other options I had. There were no network problems or abnormally-high numbers of dropped packets or shards, it would happen regardless of whether it was WiFi, 3G, or LAN cabled, and all other network services and applications were working just fine — including things like telephony, which was perfectly clear. I knew that it had to be a timeout issue, and since it wasn’t restricted to just a single server (or even to just thirty or forty servers, for that matter), nor was it an issue until I [finally] switched from Mandriva to Ubuntu, it had to be a local problem.

I dug and dug and dug, almost all the way to Virtual China, and finally found my Holy Grail:


Right now, I’m using ServerAliveInterval 120 and, for the first time since the issue reared its ugly head, I’ve been able to keep SSH sessions open and idle overnight. Hoorayings for Internets funs again and stuffs! Now maybe I can stop losing time on this and go back to only dealing with the issue of my mouse getting stuck between screens with Xinerama