Tuesday, March 15, 2005

Everything is Illuminated

It's so fucking bright in the living room now. Sweet. It's gives a terrific sense of how it's like coming back home to a new day, it isn't morbidly dark and depressing, it isn't like working in a cellar in the basement watching TV. It's the kind of brightness that screws up diurnal rhythms, that make birds fall from the sky, that imbalances the eco-system. And I like it. Using eco-friendly (long-life), energy-saving (low wattage) fluorescent bulbs.


I can even see little specks of dirt on my keyboard. I guess this probably means that I'll sleep a little later on average, but then again I might be more efficient and sleep earlier. Haha.


Was hacking through the night. Not hacking of the fun or malicious variety, but the body-racking kind. But had a good day hacking today, though I'm somewhat pissed at having spent the whole morning tracking down this bug that I eventually located and squashed in 3 lines of code.


Killed a cockroach in the kitchen last night, by the way. I saw 2 of them...


Anyway, it's really useful that the ASP Request.QueryString and Request.Form collections are distinct and independent. Using a form to upload a file, so need to use the BinaryRead method to transmit that data (actually using some installed 3rd party component to do it, but the principle is that), and the thing is if you use that then you can't extract variables from the Request.Form collection the usual way. There's just one bit of info I needed in order to check what type of upload was being done, so was able to pass that information through Request.QueryString by hard-coding the querystring in the form action.


Oh, and the bug was with uploading a file onto a file that is already present on the server, which didn't completely overwrite it. Rather, if the file was 20k in size, then you upload a 19k file, it was something like you get the 19k file with the 1k from the old file stuck at the end of it. Took me too long to figure out which portion of the code was responsible for it. Spent a lot of time fiddling with the other part of the code where I read in the uploaded contents into a variable, then write in some header information then write in the contents stored in that variable. But the problem was upstream, so deleting the file and respawning it at this point didn't do jack.


The bottom line is that I should have first tried to track the bug instead of fiddling with the code and seeing if another method worked. When I tried tracking the bug, I found it almost immediately. And tracking the bug was as simple as doing a Response.Write of the variable I used to read in the contents of the uploaded file. Because then I found that the uploaded file already had the overflow-from-old-file problem, that the problem was not introduced by my reading and re-writing.


Tomorrow is going to be a big day. Going to start work on programming big, systematic database changes. After today's work, file upload, re-load, unload, changing meta-info all work. Oh, and I just got an email from an "income earning specialist". What a cool job that is. Sheesh.


Wonder if anybody is going to read this, because most people would probably have dumped core upon reading about the programming technicalities.

No comments: