Posts tagged with “code”
23
Ummmmm
So for about the last half hour, I’ve been writing code to clean up a project that I left half-baked a while ago. I don’t know what got me started, but as I read things over, the voice I hear myself saying it with inside my head is that of an Italian mobster.
“Hey you. IF statement. Yeah, you. You think you’s a funny guy uh somethin’? Keep up the funny business or I’ll intradoose yuh ta my friend the backspace key.”
“Vinny, wheahs my WHILE loop? You said you’d be gettin’ paid last week, too. Wheahs my f@#$in WHILE loop?”
Maybe I still have food poisoning. That would explain it, at least.
Quick Takes
Just a few quick takes for a lazy Sunday.
- My hair has gotten long. I like how long it is, but it’s at the “poking me in the eye” stage. I don’t like my hair poking me in the eye.
- I had a craving earlier today for lemonade. So I made some. It was ok, but nothing to write home about.
- I’m already home so writing home now would be dumb.
- I spent the last hour watching a technical video about a technology I’ll probably never use. Actually I might. I’m not sure. Anyhow, it was very dry, but I walked away entertained. I don’t know whether it’s a bad thing.
- I finished my business site this morning. Hooray?
- My boss likes my code.
- You know when you’re soooo close to being out of deodorant and you can see the plastic pusher through the translucent clumps at the bottom of the tube? That’s where I’m at right now. I really don’t want to start a new stick before school. I want to be using a new one when I move in.
- My GPS was acting up this morning. For whatever reason, the battery died, even though it was plugged in. I blame the car.
- The earth is shining blue below us, and two become as one. Yeah, we could live forever. We could step into the sun.
- I was on a graphics site last night. Basically it’s a marketplace for icons and graphics. In case you didn’t know (oops…maybe I’ll save it for later)….Anyhow, I was looking to buy icons. I did, but I was like, “I’ve made some icons. They’re 100% Basta-made. I should sell them!” You know. Make a few bucks. Coin in the bank. To make a long story short, all of my icons were representative of logos (see the icons in the lower right on my homepage) and thus were unusable. FML.
- My BFF Carrie hasn’t updated her blog in eleven days.
- I want a girl with uninterrupted prosperity that uses a machete to cut through red tape…She is fast, thorough, and sharp as a tack. She is touring the facilities and picking up slack. I want a girl with a short skirt and a loooooooooonnng jacket.
- I’ve got so many tags in my blog that it’s almost impossible to browse through them to find applicable terms. I now have to guess whether I’ve used particular phrases as tags before. It’s a good memory game.
- For each one of these quick takes, I have to write out LI tags. I’d much rather to use P tags. They do different things than LI tags, but I’m in a P-tag mood today.
- I had the jankest sandwich for lunch with a heaping helping of macaroni salad.
- I feel like bursting into song today.
- I haven’t started packing for college. I leave on Tuesday.
That’s all I’ve got for today. Tune in tonight around 1:00 for my third Truth About Basta!
21
3oh!3
This afternoon, I’d just like to say that whenever I see the band name “3oh!3,” I’m reminded of an opening CDATA tag in XML: <![CDATA[
Now granted, I’m a geek. And its really not that close, but when I see that, I say to myself, “Hmmmm… wonder if that’s what they were going for,” even though I know that I’m the only person on the face of the planet that’s geeky enough to make that connection.
Just wanted to throw that out there.
12
Green Websites
I’ve been working on a specification for green websites for a while now; mostly since “green” became the new business buzzword. Green websites are attractive because they save money and they give a business or an organization a friendly outward appearance towards the environment.
All in all, green websites should be built from the ground up, as retrofitting an existing site with modern techniques is usually only a half-baked means of making that happen.
Here’s my specification:
-
Websites should use high-contrast colors for text and backgrounds. Text should be properly sized. Properly sized text and readable colors prevents users from increasing screen brightness.
-
Motion graphics should use the appropriate web technology. Hardware-driven graphics is preferred to software-driven graphics. Multimedia which causes unnecessary processor usage results in extra power consumption and the production of excess heat.
-
All websites should include a print stylesheet, enabling more efficient paper and ink usage.
Print stylesheets should dictate the use of monochromatic hues, using color only when absolutely necessary. Fonts should be sized appropriately. Unnecessary elements should be hidden. Advertisements should be hidden.
-
Websites should offload as much processor usage as possible to the server and implement efficient caching. Excessive hits to the server must be avoided. On the client, processing is repeated more than absolutely necessary, expending exponentially more electricity.
Web servers should implement ETags to prevent unnecessary data transfer (saving electricity).
Servers should use PUSH technologies where possible rather than synchronous communications. Synchronous communication, by nature, encourages excessive processor usage.
-
Websites advertising coupons for brick-and-mortar businesses should be presentable in digital format (i.e.: via cell phone or PDA). Forcing coupons to be printed wastes paper and ink.
-
Wherever possible, third parties should be used to outsource common tasks (such as by using web widgets). These services generally implement very good caching, saving electricity.
-
Dynamically use GZip compression. Do not compress files that are already small from edge locations: data transfer can be outweighed by processor usage.
-
When webcams are utilized, help the user to adjust brightness and contrast automatically to help avoid unnecessary electricity usage by the user for lighting.
-
Offline web applications should pull down new information in large chunks rather than small packets. Larger chunks incur less overhead, decreasing electricity usage.
8
First Memcache Error
I spent my morning trying to fix a problem with Memcache. Basically, when I ran the CRON job for my counter widget, it would get about halfway through and return an error that a VALUE header in Memcache was corrupt (aka something very bad has happened). Upon research, it seems like it’s an issue with the PECL Memcache package that I’m using. There’s a newer version, but I can’t for the life of me get it to install. So, rather than pulling all of my hair out trying to update to a new version of the library, I opted to take the easy way out: flush the Memcache instance.
Now with the counter setup, there’s repercussions to flushing the server. First off, anything that hasn’t been sucked up with the CRON job is lost forever (basically your hit counter will appear to make a jump backwards). Second, everything for the next 36 hours will be about 100 milliseconds slower as the server polls out to SimpleDB to get the new values. Third, if there’s an error or bug, anything ever written that’s within the context of the bug is gone.
So the worst case scenario took place: the last few hours of hits were erased, everything needs to re-poll from SimpleDB, and about 200 users’ hits were erased entirely. FAIL.
How did this happen? Well, it’s a multi-part problem. The root of it stems, obviously, from the bug in the Memcache PECL package that I’m using. Obviously I’d need to flush/restart eventually, however, so I can’t blame the data loss on that. It’s what started this snowball down the hill, though.
The next tier involves the way I update the server. Amazon only lets you grab a listing from a database in chunks of 200 or so. They then give you a token that lets you grab the next 200 (and so on and so forth). If there isn’t another 200 records, it won’t give you a token.
When I built the library to read from Amazon, I didn’t have 200 domains to test on, so I guesstimated (based on other libraries) what the token would look like and ultimately failed. It was in a different location and was a different length. PHP never threw an error telling me I was looking in the wrong place because the XML library I’m using parses lazily and returns empty objects instead of throwing errors. I did not know this.
The last leg of the problem was that when I noticed that Memcache did not have a value that was in SimpleDB, I did not update it. This isn’t a critical problem, but it takes latency that the CRON job would otherwise scoop up and dumps it on the exposed counter interface.
So what now? Generally, when a widget gets wonky, people don’t notice. I’ve had my YouTube videos widget go down for a week and not a single person seemed to notice (based on my stats/email). My counter has far fewer users and hasn’t “stopped working;” it just kind of reset. I doubt many users will migrate away, if any.
Ok, now it’s time for me to go be a tourist.