skype + glutineous rice
A couple weekends ago Illie’s dad visited, and brought some vegan “Cai Tsang” – leaf-wrapped glutinous rice that Illie’s mom knows that I love.
I just got this huge craving for glutinous rice, even though I didn’t finish it. I looked up a recipe online, and got the ingredients on Thursday.
I soaked the rice on Friday night and on Saturday morning I made the shiitake mushroom broth, and cooked it. I knew I went overboard when I started soaking the rice, and then it got worse when it expanded, as rice always does. I made waayyy too much. Ridiculous amounts. We have enough glutinous rice for probably a month. At least Illie thinks it’s pretty good. I put most of it in the freezer, so it won’t go bad.
Now that I realize the potential of this great thing called sweet rice, I have some devious plans to make some Thai style dessert mango sticky rice, except probably without the mango. mmm. Illie wisely told me not to do it anytime soon.
My mom came in the room after presumably her art workshop and we spoke a little bit. I googled for some urls that showed step-by-step screenshots on how to set up a wep key on a computer. It didn’t seem to be clear enough, though. I then went on youtube and found a decent video showing how it’s done.
Once I was able to tell my mom whether the circles and lines in the wep key were 1/0’s or I/O’s, it was a matter of minutes before she got it set up. I gave my parents an applause over video teleconferencing. The collective cheering was pretty funny. Any baby-boomer aged adult setting up wireless networking without active supervision is impressive.
His last Skype call today was pretty cute. He flashed the above picture in front of the webcam and said, “this picture was taken when I was in my 30s! Don’t I look like you when I was about your age?” He told me that the picture was taken right after they moved to the states, before Rosa was born.
Miscellaneous notes:
- Congratulations to Ben on the birth of Caleb! Same birthday as my brother in law.
- Said goodbye to Annie on Friday before she moved up to Northern California.
- Congratulations to Alice and Ian on their engagement!
Implementation of a MaskEngine for xml
So working for a bank, we have to make sure that some sensitive information that gets logged or persisted into the database is masked. One particular challenge that I worked on this week was a function that takes in xml from an Apache Axis request/response call and masks certain xml content, such as social security numbers and driver license numbers. So, from this:
<xml>
<firstname>
robin
</firstname>
<ssn>
123121234
</ssn>
<dl>
d3832928
</dl>
</xml>
I would need, for example, this:
<xml>
<firstname>
robin
</firstname>
<ssn>
*********
</ssn>
<dl>
********
</dl>
</xml>
Naturally, one would use some kind of xml parsing library such as w3c dom, use something like xpath, find the tags that need to be masked, mask them, and output the xml document back as a stream.
However, this is overhead intensive. The lead developer made a big point to me that we wanted as little overhead as possible, and while we could asynchronously call the xml logger as a message bean, the priority was to make it fast from the start so we wouldn’t have to.
So the fun for me was to think of the fastest way to do this: a plain string buffer algorithm that runs on the order of the length of the string itself.
Naturally, what came next was a recursive algorithm reflecting that state diagram as closely as possible. I stubbed out an interface consisting of methods representing each state. Each method took in a string array (list of tags to mask), the string buffer, and an int representing the cursor. Since the methods were operating on the string buffer in memory, they didn’t have to return anything. Memory footprint was small, and assuming that the tags are short (constant), this would be an O(n) algorithm, where n is the length of the xml.
Implementing each method was pretty simple: all I needed to handle was what was in each state, since I didn’t have to consider any externalities. The only method that got a little bit more complicated was the “Possibly In Tag”, which had additional “possibleTags” string array and “cursorInTag” int.
I quickly pounded out all of this in less than an hour, and the ~30-40 test cases I wrote pretty much passed after my first implementation. The code was clean, and simple to understand. I timed some of my longest test cases to be 0 milliseconds. Blazingly fast. I was pretty content with it.
Pretty smooth huh?
Well, when I actually integrated this into the application and ran some test soap xml through it, I found quickly found out that my assumptions about the “memory footprint” were wrong. I was taking up a lot of space on the memory stack. Each character in the xml means that one recursive step is called, which results in one stack frame being consumed in memory. I got a stack overflow error very quickly. And I had even less space to work with with the application server running.
Yuk. I went through the code, and for each of the state/methods that you see a loop, I turned it into an iteration instead of recursive step. It made the code uglier and lengthier, but it worked. The only method that I left alone was the “possibly in tag” method, which was the most complicated. And besides, since the tags really aren’t that long, it shouldn’t result in too many stack frames, right?
Wrong. The lead dev found another example of an xml that threw a stack overflow error. Today I went through the “possibly in tag” method and painfully changed it into an iterative method. Everything became ugly. if/elses everywhere, and the methods are now returning the new cursor value, so the next iterative step knows what the cursor value should be. The code lengthened by two to three times. It still works, but it is ugly. Though, probably even faster than before, because iteration is faster than recursion. Still, yuk.
My lesson: as much as I love recursion, it just doesn’t work with text parsing.
Random photos
I was digging through some photos just now and I decided to share them. First two are aurora pics that I took that never made it on to the web. I thought these were pretty cool, there are several layers at different distances: foreground, clouds, aurora, and stars.
Third pic, Illie took at Anzo Borrego. We totally missed peak flowering season when we visited, but Illie got this this gem.
This is so bad, it’s funny…
An analyst working on a project I moved out of last January forwarded this block of code to me.
boolean isNullPtrException = false;
try {
bean = auth.findByLogin(login);
if(bean == null) {
isNullPtrException = true;
}
return;
} catch (Exception e) {
if(isNullPtrException) {
request.setAttribute(SERVLET_ERROR, new ServletError("Contact IT Customer Service Help
Desk at tie line ####-####, option #"));
} else {
request.setAttribute(SERVLET_ERROR, new ServletError(e.getMessage()));
}
}
At initial look I can count three serious problems and two minor issues with this code. It takes some of the best features of Java and uses them in the worst ways.
Sad thing is, not even the worst Java programmer I know would write something as bad as this.
Robin’s Clif Notes guide to Solar Photovoltaic Systems
At Ben’s request, here’s a summary about my experience with solar technology. I think others also might be interested in this, especially given the attention that renewable energy has been getting. Full disclosure: I used to work for a solar photovoltaics company Energy Efficiency, though, I don’t talk about it unless asked.
So yeah – I was able to get both my parents and the in-laws great deals on their systems back in around 2003. Before they got their systems, my parents probably paid about $75/month, while my in-laws were probably at about $100/month. Both of their systems are 5kW AC systems that cost about $8,000 after rebates and tax credits. (caveat: to install a solar photovoltaic system now, the numbers might be very different!) I think both households use more energy now than they used to, while their energy bills range from zero to $10/month. I remember one year back when my parents paid a total of $15 for the whole year.
Back in 2003-2004, the CEC rebate (if you’re a customer of certain power companies like SC Edison, PG&E, or SDG&E) came out to be close to $4/kW, which covered close to half of the whole cost including installation.
Since then, the rebate has been going down at about 20 cents/kW every six months, which I think is a good thing, because it weans the industry out of dependency on subsidies. At the same time, improving technology and industrial methods also lower prices, so prices mostly stay the same, though I’m not up to date on matters. Though, I know that the falling dollar value has made it pretty expensive, since the major inverter manufacturer was based in Germany and the major panels came from Japan (Kyocera, Sharp).
At about 2003-2004, the financial break-even point used to be about 9-10 years. Several years ago it used to be about 12 years. I don’t know what it is now. Beyond that break-even point, all energy bill savings are just extra credit in the bank. Though, it’s hard to compare it to traditional savings/brokerage vehicles because the money that you save doesn’t directly factor into future interest, and you have to amortize all costs/savings over a long period of time.
And even if you decide to sell your home before the break-even point, the value of your home will increase by about the total, unsubsidized cost of the system + installation. Check out a more comprehensive financial analysis at: http://www.powersmart.co.nz/assets/Solar%20System%20Payback.pdf.
Factors that make the photovoltaic system pay back faster:
- Southward facing roof, assuming you live in the Northern Hemisphere
- Optimal angle to the average position of the sun throughout the seasons
- Higher energy cost per kWH
- Use of net-metering
- Cool temperature (colders temperature, better)
- Sun exposure (desert better, Seattle not so good) – this overrides the cool temperatures
- Cheaper cost of material, installation
In California there’s a great thing called net-metering. It means that the energy you consume or sell during the daytime costs several cents more than the energy you consume at night. This means that, for example, the daytime energy you pump into the grid can be 20 cents per kWH, while the nighttime energy you take from the grid can be 15 cents per kWH. My parents, having a perfectly south-facing roof, are set up with net-metering. My in-laws, whose roof is southeast facing, aren’t set up with net-metering because they don’t get late afternoon sun. However, no matter how much energy you produce, you will never be earn money for putting more into the grid than you take out over the course of a year.
One red-herring argument that I often hear from detractors is about the ~15% efficiency of standard panels for normal residential/commerical systems. However, what really counts is the cost per watt. It’s probably possible to buy space satellite quality solar panels with about 40% to 50% efficiency, but it’s not cost-effective. The average rooftop has a capacity to hold about 5kWH of the standard 15% efficiency solar panels, which is twice the amount that both my parents and my in-laws have installed.
One legitimate argument that I rarely hear from others is the fact that the amount of energy it takes to manufacture a single panel is about 80% of the energy it will generate in its lifetime. That doesn’t sound so green, does it? (similar to the percentage of ethanol used to produce a gallon of corn-based ethanol, but that’s another story…) Though, I’m a firm believer that within our lifetimes, the technology will improve to the point that 90% of the cost of a system, unsubsidized, will go into physical labor of installation and hookup. I remember at around 2003 that percentage was about 20-25%.
Last Week
- Been on-call at work since May 1st. Last week was particularly bad – got paged three times, woken up twice, and did a Sunday 3am IPL for work. One of the calls interrupted a 4th-year anniversary thing I was having with Illie that involved alcohol, which I haven’t had in .. geez, over a year, so I was trying not to sound tipsy over the conference call. Fun.
- Lead developer at work has been off on vacation. I guess I’ve been designated as the primary go-to person for questions/issues. Have a lot less time to do actual coding.
- Illie was on night float for half of last week. Which means I don’t get to see her, though we are sleeping in the same bed for about two or three hours – we’re just hardly awake and together at the same time.
- Went back to Rossmoor for the weekend. Installed Skype on my parents’ computers, and now we can video teleconference.
- Saw two baseball gloves and a baseball in my dad’s room. Asked him why he had them, and he told me that it was so we could play catch. We played catch for awhile. Fun times.
- Met up with Amy and Andrew. They’re doing really well. They’d be great neighbors to have again, if that were possible. Looking forward to Andrew’s wedding in July.
- Attended Samantha’s graduation ceremony at UCI, and met up with 5th aunt/uncle, Mimi, Judy, and two Daves. Vegan David helps make my diet look less fringe to the family. Also looking forward to Judy and Dave’s wedding. Stupidly forgot to bring Illie’s camera.
- Parents, especially dad, ebullient about the solar photovoltaic system we installed back in 2003. In-laws the same about theirs. I recall my dad being pretty upset when I first proposed the idea, but now he can’t be any happier.
- Probably got about 60 miles per gallon driving up to Rossmoor and back. Think the savings are worth all of those annoyed drivers tailgating me driving a puny 60 mph? Oh well.
Memorial Day, and last weekend
For the Memorial Day weekend, Illie and I went to Upland last weekend to see her grandmother. I spent all of Sunday in her house with nothing to do but relax. Relaxing with nothing to do is kind of hard for me. When I’m at home it’s always some house chore or another. Being forced to relax is probably something I need. I spent a lot of Sunday playing Falling Sand. Maybe I should have been an irrigation engineer.
I’ve come to get more comfortable with the two kids of Illie’s cousin who lives here in San Diego. Just like the kids back in the midwest, they call me “Uncle Wobin.” I can tell that the kids really love it when I visit, they (and I) have so much fun playing. I remember when my own uncle used to be that “cool uncle” when I was a kid, and I know that he’s turned a lot more serious, not so fun and carefree as he used to be when he was younger. My own dad, in fact, used to be that “cool uncle” to his nephews, and since he had me when he was 40 I’ve actually never seen that side of him. I wonder if the same thing will happen to me if I ever have kids.
Today was the San Diego RnR marathon. I didn’t run it, but a bunch of my friends did. I tracked them online, though I wished I could have been there. Illie worked the med tent at 2.9 miles, which, to me, is like working the med tent at meter 10 of a 100 meter sprint. She spent half an hour handing out vaseline, and that was it.