Raam Dev

Hello, future.

Saving Files as root From Inside VIM

Oftentimes I will be editing a Linux configuration file using vim only to discover that I cannot save it because the file requires root permission to write to it. This ends up looking something like this:

[sourcecode lang="bash"]
vi /path/to/some/file.conf
[make some edits]
:w
VIM Message: E45: 'readonly' option is set (add ! to override)
:q!
$ sudo vi /path/to/some/file.conf
[make all my edits AGAIN]
:w
[/sourcecode]

I have gone through this process so many times that I knew there must be an easy fix for it. (I know about sudo !! for running the previous command, but I only recently started developing the habit of using it.) After forgetting to use sudo while editing a configuration file yet again this morning, I finally decided to search Google and find a solution. Here it is:

[sourcecode lang="bash"]
vi /path/to/some/file.conf
[make some edits]
:w
VIM Message: E45: 'readonly' option is set (add ! to override)
:w !sudo tee %
[/sourcecode]

The :w !sudo tee % command tells VIM to write the file (w) but run the sudo command first (!sudo) and read the writing of the file from standard input to standard output (tee) using the same filename as the one we're editing (%).

After saving the file as root, you'll get this message: "W12: Warning: File "/private/etc/smb.conf" has changed and the buffer was changed in Vim as well". You'll be given the option to reload it, but since you were already looking at the new version it doesn't much matter which option you choose (OK or Reload).

And last but not least, if you don't want to remember the syntax for this command, you can map the command in your ~/.vimrc file:

[sourcecode lang="bash"]
cmap w!! w !sudo tee % >/dev/null
[/sourcecode]

Now, if you forget to edit a file with sudo, you can simply type :w!! to fix the problem!

Swollen Shins as a Result of Muscular Imbalances

Over the course of the past 27 years, my posture has suffered greatly from the sedentary nature of my career. The extreme muscular imbalances have created a very dysfunctional body and those dysfunctions become more and more apparent the further I push myself physically.

For example while running, more pressure is exerted on my lower shins than is normal and as a result they've become swollen (and even bruised). They're in pain constantly, even when walking. My hip flexor muscles are locked into flexion, causing my torso to lean slightly forward. Extremely tight calves and quads also prevent full extension of the legs when running.

The past few months I've been doing more running than ever before and I've broken several personal records along the way (dropped my 4 mile run time from 41 min to 30 min in 3 months). Since noticing my swollen shins, I've eased up slightly on the length of my runs (3 miles instead of 4+) and started icing and stretching.

I seriously need to commit more time (i.e., daily) to fixing the muscle imbalances in my body. For the past 6 months or so, I've been using (on and off) Pete Egocsue's excellent postural therapy program, as outlined in two books, Pain Free and Pain Free at your PC. In the long run, fixing the muscular imbalances is more important than any other physical training since exercising a dysfunctional body will only strengthen the imbalances and prevent me from reaching my full physical potential!

To sleep or not to sleep?

Everything I've read about fitness and sleep during the past ten years has talked about the major importance sleep plays in rejuvenating our body -- lack of sleep can be as harmful as eating unhealthy foods! While I've been trying to change my schedule to wake up earlier, I often find myself waking up extremely tired. I justify going back to sleep because I tell myself it's probably healthier than waking up early. But then if I don't deal with lack of sleep for a few nights in a row, I'll never adjust my sleeping pattern.

Internet Explorer: Incorrect Password During Certificate Import

While importing a P12 certificate into Internet Explorer today, I got a message saying "The password you entered is incorrect.":

Internet Explorer - Incorrect certificate password

However, I successfully imported this same certificate, using the same password, on Firefox and Safari. But Internet Explorer (both IE7 and IE8) continued to tell me I was using the wrong password. After checking, double-checking, and quadruple-checking the password, I was 1000% sure the private key password that I was using was correct and that Internet Explorer itself was to blame.

After much trial and error, I discovered the problem: Internet Explorer has a maximum private key password length! The password I was using (modified for security purposes, but identical in length) was as follows:

603979ba15c2097f8f7fy35ec0ucfbeb

That's 32 characters, the same length as an MD5. However, Internet Explorer appears to have a problem with that! I changed the password to the following 26 character password and the certificate imported with no complaints from IE!

ae869d263e267593286188b638

If you're having the same problem, you may be wondering how to change the password on your P12 file. To do this, you'll need access to OpenSSL. If you have a Mac, you might be able to find OpenSSL in /opt/local/bin/openssl. But more likely you're on Windows and you will need to download and install the OpenSSL binary for Windows.

You can use the OpenSSL program to convert the P12 file to PEM format, and then convert the PEM certificate back into a P12 file, using a shorter 26-character password when prompted. Here's how:

First, convert the original P12 file to PEM format:

[sourcecode lang="bash"]
openssl pkcs12 -in my-original.p12 -out certkey.pem -nodes -clcerts
[/sourcecode]

This should give you a file called certkey.pem. This file contains both the certificate and the private key. However, the next command requires that the key be contained in a separate key.pem file, so you'll want to edit certkey.pem with a text editor and extract the private key portion (it should be the bottom half of the file). The key.pem file should look somewhat like this:

[sourcecode lang="bash"]
Bag Attributes
localKeyID: EE 35 CB 41 81 23 4C 89 FF 43 42 E0 3C 3B FF 93 9E 0E B7 AA
Key Attributes:
-----BEGIN RSA PRIVATE KEY-----
MIIoOwLBAAJBANSdWgmhySZsCD/koC6nST/JzH/Uqjm6NXsQwtTwx493rhM/90BB
JyfdkfDQCHR/XP0szI1LqS/AXfSx1q25/3MCAwEAAQJBAM0Iu+Mm7zJTT7nqDgfv
VW+4RaRVp05JHaWQdeerpBnWJI+2NDsiKrovyrvYjglJcdpXHhoM95T5qm8x65XP
MhkCIQD5vQ2dNGoFGn0yL0ELDU39PrVvfZyJV3wXedjrQm9utwIhAN0FRk/qIWzz
p9ZP9DjIpIRj6BdWLRrZmLqxdnUXifSlAiBy6fb1u0RJjK7HBM9dPK7+NHiQEJCS
8dp7wZl5d1xnCSIhANLoF6pmnyLil4QwgVlOTv9ufqjSZ+w5GD7a3Vj678RpAiAV
6rTJ3mAZAeQiaRHhgRP7SuvQS6EDWDPxbMBMwYklfA==
-----END RSA PRIVATE KEY-----
[/sourcecode]

With these files in place, you can run the following command to convert the PEM certificate back into a P12 format, providing a new password (maximum 26 characters) when prompted for the Export Password:

[sourcecode lang="bash"]
$ openssl pkcs12 -export -in certkey.pem -inkey key.pem -out my-new-certificate.p12 -rand /dev/random
2048 semi-random bytes loaded
Enter Export Password:
Verifying - Enter Export Password:
[/sourcecode]

That's it! Now you should be able to install the certificate in Internet Explorer without any "incorrect password" complaints.

Started a New Upper Back Workout for the Month of May

I started a new workout for the month of May. It's an upper back workout designed to work the smaller supportive muscles required to build bigger arms and shoulders. It's part of the Men's Health 2009 Poster Series, so I want to wait until the next issue before posting full details of the workout. I'm also keeping up with my running routine. Although I haven't been keeping a regular schedule, I'm trying to run as much as possible (I'm teetering on the edge of shin splints).

Fourth April Camping Trip

The weather was beautiful this weekend (temperatures in the 80's during the day, and the upper 50's at night) and I spent most of the day on Saturday lifting logs, running, and working out around the camping area (yes, that's my idea of relaxing!). In my previous post I mentioned there would be bugs, ticks, and mosquito's in a few weeks and that it was nice camping without them. Well I was wrong; they're already there! Within a few minutes of arriving, I found ticks crawling on me around the area where I camped last weekend, so I decided to just pick a random spot in the forest near the stream.

The night was so warm that I didn't even need a fire for heat, but I built one anyway (a camping ritual, or something). I pulled stones from the stream to build a small fire pit and used birch bark to start the fire. During the night I heard something moving around the leaves outside the tent and I kept getting up to look around with the flashlight. Finally I discovered a tiny frog was periodically jumping through the leaves making all the noise.

The weather didn't call for rain and the sky was clear when I went to sleep, so I assumed I wouldn't have to worry about rain. Stupid me. I've lived in New England long enough not to assume that. I woke up around 7AM to the sound of rain drops. The front of my tent was open, and a small puddle of water had already formed inside the tent. My pack, which also wasn't covered, got wet too. Oh well, it was still warm (50 degrees) so the water wasn't that uncomfortable. While it drizzled on and off, I started a fire just to see how difficult it would be while everything was soaked -- it was easy (birch bark is amazing, even in the rain!). After eating a breakfast of oatmeal, dried pineapple, a banana, and peppermint tea, I packed up and headed home.

I didn't take many pictures this time, but here are a few anyway.

Third April Camping Trip

This camping trip took place last weekend so this post is about a week late, but I wanted to stick with writing a post for each camping trip in April, so here goes (from memory). I took a better camera with me (an Olympus 770SW) and the pictures from the trip can be found here.

I decided not to camp down by the river this time, but instead camp in a clearing about 1/4 mile from the river. The wind blowing off the water made the previous two trips very, very cold and it made keeping the fire going difficult. This trip was much warmer than the previous two, at least during the day. The temperatures reached the upper 60's on both Saturday and Sunday, but the thermometer I brought with me measured a low of 24.4 degrees Fahrenheit during the evening, and it definitely felt it.

On Saturday afternoon I hiked down to the river to see how much ice had melted. I found what looked to be a wolf print (although on second thought, it looks more like a large raccoon print), and after taking a few pictures and walking around, I returned to camp to spend the evening practicing various knots, keeping the fire going, and reading Ender's Game.

I awoke around 3AM Sunday morning with freezing cold feet and needing to pee. There was no way I was getting up and losing the small amount of heat that remained inside my sleeping bag, so I toughed it out. It's amazingly difficult to fall asleep when your feet are cold and your bowls are telling you to get the hell up.

I finally got up around 6AM to relieve myself and decided that dealing with the early morning cold and getting the fire started was, in the long run, a better idea than trying to go back to sleep and generate my own heat. There were still some hot coals in the fire from the night before and I managed to use them to get the fire started again.

I watched the sun rise and waited desperately for it to come up over the trees to heat the surrounding air. When it finally did, I spent some time exercising and and laying in the clearing relaxing in the sun. It's early enough in the season that there are almost no bugs. A few more weeks and the mosquito's, ticks, black flies, ants, and all the other bugs will be out in full-force.

Convert any Website into a PDF!

HTML to PDF Converter is a service that allows you to provide the URL of any website and promptly get a PDF version of the website in return. This is incredibly useful. I've always wanted a way to backup sites that contain really useful information for fear that they may disappear. It's dangerous to always rely on a site being just a Google-search away.

Wild Envy

Is it right to feel, while I'm driving to work one sunny seventy-degree day, a sense of envy upon seeing two Canadian geese grazing in the grass? Am I really so sick of being indoors that I feel envious of wild animals? I have all the power to change my lifestyle -- is my sense of responsibility preventing me from taking action? Surely there is more to life than sitting in front of an electronic device, moving around bits of electrons, and solving problems that, in the grand scale of things, mean absolutely nothing.

Physical Training Involves Body and Mind Conditioning

Physical training is as much a conditioning of the human body as it is the human mind. To make something a reality, we must first be able to envision it with our mind. By conditioning the mind we can push our bodies beyond our perceived limitations. You can do it -- don't let anyone, including your mind, tell you otherwise.

Forcing fsck to Run on the Next Reboot

If you need to make sure fsck runs on the next reboot, here's a really simple way to do it:

[sourcecode lang="bash"]
$ sudo touch /forcefsck
[/sourcecode]

Alternatively (and depending on your version of Linux) you may also be able to pass an option to the shutdown command:

[sourcecode lang="bash"]
$ shutdown -rF now
[/sourcecode]

The Three W's: What to Write Where?

I'm not sure why, but lately I've felt as though I haven't had much to write about. I'm not sure if it's that I haven't had much to write or that maybe I just haven't felt the desire to write what's on my mind.

As I've mentioned in the past, I intentionally don't write a lot of personal things on this blog. That's not why I started it and I'm not narcissistic enough (yes, we're all narcissistic to some degree) to think that my thoughts, dreams, and personal observations are all that important. I don't really feel compelled to express myself or talk about what's on my mind and it's not that I don't feel like people will care what I have to say; it's simply that I don't care what I have to say. In this age of information, I feel as though anything to be said has already been said and so why should I repeat it?

But I digress. Perhaps all the definitions and various places to write are slowly killing my creative outlet. Perhaps making the decision of what to write and where is becoming difficult enough that I choose to simply not write anything. My time can be used for more important things than figuring out where I should write, let alone what I should write.

Writing about events and places is easy: I simply recount what happened and maybe include some pictures for eye candy. But nobody wants to hear about the ride into work, or the meetings, or the support emails, or... or maybe some people do? Well, to those people I say go find another hobby. Or at least, find another blog. I find it absolutely revolting and a total waste of textual space and time to see people writing about things that have absolutely no substance. I will not become a twitter shitter or an iRaam. The last thing I want this blog to become is my personal diary. (This post is coming dangerously close to what I'm trying to avoid.)

Then there is the question of where to write. When I started this blog, it was easy. Facebook wasn't even open to the public and Twitter didn't even exist. Now I find myself posting thoughts, activities, and other updates on Twitter (trying desperately to stay within the 140 character jail) with my Facebook status automatically being updated by Twitter. (Then my Facebook friends, who probably never read my blog, comment on my updates and make me feel compelled to reply on FB.) Anything that doesn't fit on Twitter I usually put on my blog as an Aside (it appears without a post title), and longer stuff, like this post, get the honor of being a full-blow blog post with a Twitter update announcing it being published.

So why haven't I been writing more? I've been asking myself that question a lot the past few weeks and the only answer I can come up with is that my rule of not writing about passing thoughts or seemingly pointless observations is leaving me without much to write. I've been very busy concentrating on work and fitness and I haven't had much time for exploring my various interests or writing about them. So I'll try to start writing more asides with what's on my mind and see where that takes this blog.

Second April Camping Trip

On my way up North on Saturday, I stopped at an Army Surplus store in Milford, NH to see if I could find a decent survival knife. My old knife had a cheap stainless steel blade that broke apart last weekend while I was using it to start a fire with the magnesium fire starter. I found a nice fixed-blade Air Force survival knife with a heavy base that doubles as a hammer. It came with a sheath and a sharpening stone.

Survival Knife

The weather was much colder than it was when I went camping last week, although a lot of the ice along the river had melted (compare the pictures of the ice from last week, to the pictures from this week). It was also a lot more windy, with frequent gusts of 25-30mph.

On Sunday morning, while it was still partially sunny and the wind was blowing, it started snowing heavily. It was very surreal (and very cold). Overall a great trip and a great way to spend my 27th birthday. Thank you to all who wished me a happy birthday. To everyone I'd like to say: Happy Everyday!

Book: The Warrior Elite

the_warrior_elite The Warrior Elite - The Forging of SEAL Class 228 by Dick Couch follows a class of students as they go through Basic Underwater Demolition School (BUD/S). BUD/S is only one of the many steps it takes to become a Navy SEAL and it is considered to be one of, if not the toughest military training in the world. The drop out rate for BUD/S is extremely high; only about 20% make it through. Physical and mental endurance are pushed to the extreme.

There are three phases in BUD/S. The first phase consists of lots of physical training: pushups, situps, pullups, daily four mile timed runs, boat drills (both in the ocean and carrying the boat around on the land), and log PT where students spend hours doing exercises together while holding telephone-pole-sized logs to help build teamwork. The first phase concludes with Hell Week, which tends to see the highest number of DORs. It's five days of non-stop training with less than four hours of sleep (total).

The second phase is dive phase, where students must become extremely comfortable in the water. Students are expected to be able to swim for long periods of time with their hands and feet tied together. They learn deep diving techniques, with and without scuba tanks. They also attend classes to learn about the physics of diving. There are open ocean swims, with and without fins, and as with the timed runs, there are timed 2 mile+ swims. As in the first phase, there is also continuous PT mixed in with the diving instruction. Daily run distances are increased and maximum allowed times are decreased.

The third phase is the demolitions and tactics. The training is conducted mostly on land and includes land navigation, mission planning, plenty of shooting, and learning and becoming familiar with various weapons. But things don't get easier in third phase. Run distances are increased again. Daily PT continues. Things never get easier for the SEALs, only more difficult. "The only easy day was yesterday" is what the SEALs like to say. They're constantly striving for perfection, both physically and mentally, and improving their skills.

BUD/S training lasts six months. For the few who manage to graduate, another six months of vigorous and more specialized training is required to earn their Trident (which officially makes them Navy SEALs). After that, they're assigned to a platoon and there's another block of even more advanced training called SEAL Tactical Training (STT). When all is done, a SEAL will have been training for eighteen to twenty-four months before having a chance to be deployed.

During the past few months the SEALs have been an enormous source of motivation for my own physical fitness goals. This is the first book I've read cover-to-cover this year, and it was so good that I will no doubt read it several more times. What appeals to me the most about the SEALs is that they're all about pushing past mental roadblocks and striving for perfection. They're all about understanding the real physical limitations of the human body and conditioning it to the extreme. Several books on Navy SEAL fitness and nutrition are very detailed and describe with scientific precision how to train the human body. One such book is The U.S. Navy SEAL Guide to Fitness and Nutrition.

One of my goals for 2009 was to read one book every month. I'm already reading two others, and I hope to have a total of four books finished by the end of this month. For every book I finish reading, I'll write a post like this one.

Where is the time going?

As of late, life has felt like the pages of a book in the hands of a speed-reader -- a speed-reader with only 10% comprehension. I've been focusing solely on my changing duties at work while trying to maintain a daily workout routine and get a healthy amount of sleep. It feels as though I have neither the time nor the energy (and maybe not even the motivation) for anything else.

I've been making it a goal to get away from the computer as much as possible on the weekends to fill my love for the outdoors and relax. During the week, the three hour daily commute to and from work seems to suck away any available time I might otherwise have for writing and learning new things. To fulfill one of my goals for 2009, I've also been trying to set aside time after work for light socializing. Still, I feel like I'm missing the entire day; like time is moving on without me while I'm stuck in a pool of molasses wondering why.