Thursday, July 08, 2010

Please seperate configuration from code

When configuration and code are managed together it means that I can't test old code because it's configuration no longer matches the current environment. It is extremely frustrating when my assignment is to find a performance regression.

I guess this supports the idea that even in small environments where you control everything, you should support discovery in your code. You shouldn't have to tell it everything. It should be able to find out most of what it needs from the environment itself.

Wednesday, June 30, 2010

Mysql replication

Today I was working on a master-master replication setup and I couldn't get the slave threads to work. I could connect between the servers with the mysql client, but the slave threads couldn't connect. I finally found that although you can set a long password for a mysql user, the mysql replication will silently truncate long passwords before it uses them to log into the master server. So you set the password to one thing and something shorter is actually used. I ended up using a 10 character password and that worked fine.

Wednesday, May 05, 2010

Questions and Answers

I've been asking my self questions for a long time. This evening I thought of something:

There is somebody to do everything, but everybody must do something.

I think this will come to mean a great deal to me.

Wednesday, April 07, 2010

Defensive programming, the real reason

For better or for worse I am very possessive of code that I write. When people break my code, I have to take deep breaths in order to not insult them.

Of course this has helped me better understand the purpose of tests like solo programming never could have. It's made me realize that team programming is a war. If I didn't build my tests well enough, such that someone else is able to break my code, that's my fault, not his.

If you really want to impose your will upon the codebase, write tests.

Thursday, April 01, 2010

My polyphasic story

A friend asked me about my sleeping and here is what I sent him:

There are actually two stories. For about three years I was doing a sleep schedule commonly called “Everyman” where I sleep 4.5 hrs/night and take 4 naps a day for 23 minutes. That worked very well even though previously I needed 8.5 hrs/night to be functional. I had high levels of energy  all day even until bed time. I felt basically the same whether it was 1am or 8am. It also helped improve mental and emotional aspects of my life because of the regular breaks. I started that when a coworker idly talked about it at lunch one day. Although I’ve been working at home for the most of the time I’ve been on the schedule, I chose naptimes that would work at a full time job, so it can work for people at work too.

Google has lots of information about it, often under the title “polyphasic sleep”, but lots of the search results you’ll find are people trying to document their attempts. Most people fail, but I think also that when people succeed, they forget about their blogs and never report the success. It is physically and emotionally taxing, but it is doable. Large amounts of sleep deprivation are par for the course and that causes depression, so you have to be careful. In my opinion the only reason I succeeded was because my wife was pregnant and couldn’t sleep at night, so after each nap she would stand me up and walk me around the house until I was lucid. The benefit to her was that for several months after the baby was born I was still doing the no core sleep thing. I took care of the baby all the time during the night and helped the baby nurse without my wife waking up. So my wife never had to deal with a crying baby in the night.

The other story is that since December I’ve been trying to change back to the more ambitious version which is no “core sleep”. In polyphasic sleep terms, “core sleep” is the big chunk of time that you sleep, usually at night. Going without core sleep is either called Uberman or Hexaphasic. I have not read any public accounts of people maintaining it more than 6 months, but I think it is doable. I started doing Hexaphasic when I started this whole thing and had adjusted to the physical difficulty of staying awake, but being suddenly VERY alone for 8 hrs/day and the mild sleep-deprivation induced depression made me stop.

Now that I have more experience and am more adjusted to the naps and the night time, I’m trying to go hard core. When I went to bed (on the 4.5hr/night schedule) I still had lots of energy and couldn’t stand just going to bed when I had so much energy. However, I have found that there is a world of difference emotionally between getting a small about of core sleep and no core sleep. I’m going on 3 months of trying to make the change from 4.5 to no core sleep.

If you are interested in trying it, my suggestion is to start by taking naps. I think my schedule works well: 7am (depending on when you wake up you won’t take this one to start), noon (before you eat anything for lunch), 5pm (ideally naps should be 4hrs apart, but you can fudge it a little. You should probably take this one at work to keep the fudge as small as possible), 10pm, and then go to bed when you feel like it. With that many naps, you’ll naturally go to bed later, if you find yourself staying up until 1am, take another nap at 1am. All naps should be between 18min and 25min, you’ll have to play with it to see what makes you groggy when you wake up. Too long a nap is WAY worse than too short a nap. If your brain moves into deep sleep, you very well may not wake up and your mind will be foggy. Even if you were to choose not to go hard core, you’d still have more energy all day and more awake hours. While you are trying that you can read stuff on the net to see how far you want to take it.

So that’s me spiel. As you can tell, I enjoy the topic quite a bit.

Wednesday, February 03, 2010

That's cool. The iSight's "other" purpose

With my new job I got a company laptop. This evening I was working on it and happened to keep adjusting the angle of the screen. Every time I did I the screen dimmed. I started moving my hand around the screen and I found a really cool feature.

The Macbook Pro, at least with Snow Leopard installed, dims the screen brightness according to the amount of light sensed by the iSight camera. So when you turn off the lights, the screen automatically dims so that it's not too bright.

That's really cool.

Monday, February 01, 2010

Still Polyphasic

From what I read on the net, you're not polyphasic unless you continue to announce it. I guess it makes sense given that even the people that say they are long term polyphasers seem to go off the schedule for months at a time.

Over christmas I changed from Everyman to Uberman and it went well. At the end of the holidays however I got really sick. It wasn't just me, people in my family in 3 states got the same thing. I slept all day and all night for 2 weeks. After that I got back on the schedule only to have problems when I went on a business trip and couldn't take any naps for a few days.

Now that I am back home, I am back on the Uberman schedule. My naps are 10pm, 1am, 4am, 7am, noon, and 5pm. Next time I go on the business trip I've found a quite room that I can take my naps in and lunch time and after work. When I am at home I get in 6-7 hours of work between 10pm and 7am. After that I only have to be available for communications (I work from home). I do that Monday through Saturday and have most of the day all week with my family.

Like I said, I only changed to Uberman during Christmas so I'm still adjusting to having so much time with my family. I've been running around cleaning and doing dishes and projects. My wife is very happy with the new schedule and all the cleaning I'm getting done. :)

Saturday, January 30, 2010

GC patched ruby for performance testing

The Guide for Rails performance testing has instructions for patching ruby to provide garbage collection statistics. The only problem is, the patch is against a ruby version that is 2 and a half years old and doesn't compile by default on my machine.

The patch doesn't apply cleanly against the latest ruby 1.8.7 (p249). I found a version of the patch on github and fixed it up to apply to 1.8.7. Here is my fixed up copy.

I downloaded ruby from here and applied my updated patch with "patch -p1" and it compiled fine and doesn't seem to have any problems. Of course this version of ruby is only for profiling.

Updated Feb 2, 2010
Sorry to disappoint, but when I finished the patching the rails performance tests still wouldn't give me memory metrics. Back to the drawing board. I'll update this when I get a better patch.

Friday, January 29, 2010

Autotest just keeps getting better

Right now I'm working with a ruby on rails project that has lots of test and they take quite a while to run. I'm also doing more testing than I have on previous projects, so I'm running the tests frequently.

Obviously I'm using autotest, but I just found out about the "-c" and "-f" switches. "-c" makes autotest run run the full regression tests each time the tests all pass. "-f" makes autotest not run all the tests are startup.

As I was playing around with autotest, I found easy instructions on how to setup notifications for autotest in linux. I figured I'd copy the code and see what it is like. Wow! I really like it. When I finish changes, I just keep on going and the notification lets me know when the tests are done running and what the out come was. It really helps me focus on what I am doing and helps me stay in the "groove" better.

Thursday, January 28, 2010

When computers aren't enough

A friend forwarded this to me today and I couldn't stop laughing:

A cowboy named Bud was overseeing his herd in a remote mountainous pasture in California when suddenly a brand-new BMW advanced toward him out of a cloud of dust.

The driver, a young man in a Brioni suit,Gucci shoes, RayBan sunglasses and YSL tie, leaned out the window and asked the cowboy, "If I tell you exactly how many cows and calves you have in your herd, will you give me a calf?"

Bud looks at the man, obviously a yuppie, then looks at his peacefully grazing herd and calmly answers, "Sure, Why not?"
    
The yuppie parks his car, whips out his Dell notebook computer, connects it to his Cingular RAZR V3 cell phone, and surfs to a NASA page on the Internet, where he calls up a GPS satellite to get an exact fix on his location which he then feeds to another NASA satellite that scans the area in an ultra-high-resolution photo.
     
The young man then opens the digital photo in Adobe Photoshop and exports it to an image processing facility in Hamburg , Germany .
      
Within seconds, he receives an email on his Palm Pilot that the image has been processed and the data stored. He then accesses an MS-SQL database through an ODBC connected Excel spreadsheet with email on his Blackberry and, after a few minutes, receives a response.

Finally, he prints out a full-color, 150-page report on his hi-tech, miniaturized HP LaserJet printer, turns to the cowboy and says, "You have exactly 1,586 cows and calves."
     
"That's right. Well, I guess you can take one of my calves," says Bud.

He watches the young man select one of the animals and looks on with amusement as the young man stuffs it into the trunk of his car.

Then Bud says to the young man, "Hey, if I can tell you exactly what your business is, will you give me back my calf?"
     
The young man thinks about it for a second and then says, "Okay, why not?"

"You're a Congressman for the U.S. Government", says Bud.
      
"Wow! That's correct," says the yuppie, "but how did you guess that?"

"No guessing required." answered the cowboy. "You showed up here even though nobody called you; you want to get paid for an answer I already knew, to a question I never asked. You used millions of dollars’ worth of equipment trying to show me how much smarter than me you are; and

You don't know a thing about how working people make a living - or about cows, for that matter. This is a herd of sheep. ....
  
Now give me back my dog.