Relative Dates Using PHP
9 comments (closed), posted on february 26, 2004, tags: movable type
So you want to jump on the relative dates bandwagon? Here's how you can do it quickly and easily. This tutorial will assume you're using Movable Type, but you can use the PHP bit on its own if you wish*. You could also do this via SQL, but in this case it's easier to use a function than to edit how MT queries the DB. First, let's talk about the PHP function.
The idea here is simple: You pass the function a date stamp in a specific format (YYYYMMDDHHMMSS) and it converts that stamp into a Unix timestamp (in seconds since the Epoch). It then finds the difference between the current time and that timestamp. This number is the number used to calculate the relative values. It works as such:
- A minute contains 60 seconds.
- An hour contains 60 minutes (3600 seconds).
- A day contains 24 hours (86400 seconds).
- A week contains 7 days (604800 seconds).
- A month contains 30 days (2592000 seconds).
Obviously, not all months contain 30 days. This is an average and will provide results that are reliable enough in this case.
The function works from the largest timeframe down. If the amount of months is 1 or greater, then the function will simply return the date in MM/DD/YYYY format. The reason for this is that you don't want someone looking your archive from a year ago and seeing a posted date of 1 year, 3 months ago. How would they know when exactly that was? If a month has not gone by, the function moves down to weeks. The way the function builds results is as follows:
- If there are 1 or more months, return just a date.
- Otherwise:
- If there are 1 or more weeks, return weeks and, if necessary, days.
- Otherwise:
- If there are 1 or more days, return days and, if necessary, hours.
- Otherwise:
- If there are 1 or more hours, return hours and, if necessary, minutes.
- Otherwise:
- If there are 1 or more minutes, return minutes.
- Otherwise:
- Just return seconds.
This means you'll never see something like 4 weeks, 3 days, 8 hours, 32 minutes, 11 seconds returned. That's just crazy. This limits each set of time to one (or no) subset. Now then, let's put it all together.
First, click here to see and copy the source code for the PHP function. Copy that code and put it into your functions file (or, if you're completely unorganized, create a new file) and make sure you include it on all the templates you wish to use these dates on (like such: <?php include('functions.php'); ?>, where functions.php is the file that contains the function). Then, where's you want the date to appear, do this:
Posted <?=doRelativeDate('<$MTEntryDate format="%Y%m%d%H%M%S"$>');?>
Note that the function automatically adds the text ' on' when it prints only a date and ' ago' when it prints a relative date. Hence my addition of the word 'Posted' and the space after it in the code above. The function doesn't automatically print the 'Posted' part because some people might want it to say 'Written' or 'Barfed' or something. Rebuild and you've got yourself some relative dates, pal.
* If you want to use this without Movable Type, you can simply substitute what I passed to the function above with your own properly formatted date stamp (see mktime(), date(), etcetera).
Google Ads Experiment
5 comments (closed), posted on february 26, 2004, tags: site
Way back when AdSense first started becoming popular on weblogs, I applied for the program and was denied. I was told my site what too "personal," and that it didn't conform to Google's requirements. I sent Google an email with a list of about 10 sites I found that were serving AdSense banners that were "personal," or at least as personal as my site was. Their reply was something along the lines of "oh well, your site is still denied."
Shortly after xPad was released, I reapplied for the program with the forwarding domain getxpad.com. The application wouldn't accept a forwarding domain, so I changed it to the actual URL, maniacalrage.net/xpad. I was denied. The reason: Google cannot accept subdomains or non-root paths—a user must be able to place ads on any page in the domain. This pissed me off. After all, I had already applied for the whole domain and been denied, so what did I have to lose? I sent Google this email:
I am capable of running AdSense ads on all pages within the domain, you just won't approve the other sections of my domain because you say they're too "personal."
Meanwhile, I get 38,000+ unique visitors and 500,000+ hits a month and you're losing the opportunity to make money.
The site you just denied [the xPad site] is currently receiving at least 1,000 unique hits a day and is linked on over 40 major websites.
Your loss.
garrett
Suprisingly, a few hours later, I received this reply:
Hello Garrett,
Thank you for your continued interest in Google AdSense.
Our AdSense representatives review all AdSense applications according to our Terms and Conditions ( http://www.google.com/adsense/terms ) and our program policies ( http://www.google.com/adsense/policies ). I apologize if the prior disapproval of your application was made in error.
I have now reviewed and confirmed that your website meets all of our policies. Your application has been approved. Please check for a separate application approval email for your records. The approval email also includes detailed instructions on how to access your new account and get started.
Sincerely,
The Google Team
Now, it seems one of two things happened between the time I sent my email and the time they replied—one, a real human being actually looked at the content of my site, rather than some sort of automated system; two, Google saw the numbers and decided that even if it was too personal, they could make some money off of me. Regardless, at the end of the day we both got what we wanted.
I've placed the ads in several places—all the archive pages (including individual entry pages), the plugin page and the xPad page. They're all very small (two vertical ads) and in the sidebar. You shouldn't really even notice them.
The point here is to see if they generate any income. If you feel like clicking them, go right ahead. I'll probably ad a checkbox in the future that allows you to hide them if you wish (if I decide to keep them at all), but in the mean time let's just see what happens.
Tribeca in the Sun
3 comments (closed), posted on february 24, 2004, tags: photos
Yesterday was the perfect day to take pictures. The sky was crystal clear and deep blue, the sun was out and it wasn't too cold. I only wish I had gone out earlier in the day, because my light only lasted about an hour.
For those who are curious, Tribeca comes from the Triangle Below Canal.
Metroid
10 comments (closed), posted on february 23, 2004, tags: entertainment
Metroid was released for the Nintendo Entertainment System in 1986, and I must have played the game for at least 5 solid months. As a kid, the game was challenging, engrossing and extremely fun. I still remember the 'shocking' ending—finding out Samus Aran was, in fact, a woman. I also remember the infamous JUSTIN BAILEY ——— ——— password, allowing you to play as Samus without her power suit. And speaking of passwords—somewhere, in some landfill, there are hundreds of scraps of paper with 24 digits written all over them in no particular order, in a 6 year-old's handwriting, with little notes like, "pink clothes" and "before brain."
A few years later, after successfully convincing my parents to buy me a Game Boy, I got a hold of Metroid II: Return of Samus. The year was 1991, the Game Boy was the size of a brick, and I was once again engrossed in a Metroid game. I remember being frustrated most of the time, however, because the game was very large and there was no map of any kind to keep track of where you were/had been, and on the small Game Boy screen that created very annoying game play experiences. Still, it was Metroid, it was more of the same (and more!) and it was good. It was nothing compared to what came next, however.
Super Metroid was released in 1994 for the Super Nintendo Entertainment System, and is still, to this day, one of my favorite games. Super Metroid was, quite literally, super. It was Metroid on steroids with better graphics, better music, better weapons, a crap-load of new stuff, and some of the tightest game play I've ever experienced. It's one of the few games that made the addition of X, Y, L and R buttons to the SNES controller make sense. I remember how perfectly I could control Samus in Super Metroid. The controller and character felt like an extension of my brain—every movement seamless. The story was great, the game could easily last you 6 hours, and was fun the entire time. It's a good thing, too, because there wouldn't be another Metroid game for 8 years.
In the time between the release of Super Metroid in 1994 and Metroid Prime for the Gamecube in 2002, I went to and graduated from Junior High and High school. I moved from Washington to New Jersey. I went to college. I dropped out of college. I moved to Staten Island, then to New Jersey again. I learned to drive, had my first screwdriver, my first cigarette. I started to think that the next time I would see a Metroid game would be when my teenage kid was playing some future console system in the underground caves humans will dwell in by then. It wasn't quite that long, though.
Metroid Prime was a fantastic game. It takes the ideas of the Metroid series and starts a completely new path into the 3D, first-person-shooter genre. The move was inevitable, and definitely not a mistake. Metroid Prime received several game of the year awards and with good reason. It's rich graphics and tight combat control made the game extremely fun to play. Metroid Prime II is in development right now.
It seemed, with the news of Metroid Prime, that the side-scrolling adventure days of Samus Aran were over. Time to grow up, to move on, to step into the new world of gaming. Everything is first-person now. Hell, I think eventually you'll see a version of the Sims in first person. You'll interact with people in the virtual world, in first-person. Like the real world, but without actually having to leave your house or shower. So too must Samus stop showering, I thought. Luckily, I was wrong.
Metroid Fusion was released in 2002—at the same time as Metroid Prime—for the Game Boy Advance. Suddenly, after 8 years, there were two Metroid games to play. Fusion was called Metroid IV, and continued in the tradition of side-scrolling action that looked nearly identical to Super Metroid (the Game Boy Advance is nearly as capable as the SNES was). The game was tragically short, but aside from that, it was fantastic. A lot of the game play comes directly from Super Metroid, but there are plenty of little additions. Once again I was carrying a Metroid game around with me, which was great.
And now, in 2004, we've got Metroid: Zero Mission. A remake of the first Metroid game and also created for the Game Boy Advance, with a ton of new stuff and a whole new ending to the original storyline. I remember reading an interview with one of the project managers who said that you would "be surprised" with the new ending, and I must say that was entirely true. After I beat Mother Brain and escaped the inevitable, standard 'Self Destruct Sequence Has Been Activated!' bit, I was surprised with what came next. I won't ruin it for you, but I will say that it adds a nice extension to the original game.
Much like Metroid Fusion, Zero Mission is entirely too short. I beat the game the first time, without rushing, in 3 hours and 15 minutes. I've been playing through again, attempting to beat it as quickly as I can, and I'm near the ending and have only been playing for about an hour. I'd be much happier if those times were at least doubled. The good news is, the only reason I'm complaining about length is because the game is so damned good.
Zero Mission also includes a few cut-scenes, which none of the other 2d games have had. They're perfect for the game—anime-style, cartoon cells animated via panning over still frames—and add even more to the experience. Especially great is the first animation in the game, just before you take control of Samus for the first time. You hear the Metroid theme and you get a great close-up of Samus' face. Her eyes are closed, and just as the music peaks, she opens them. It's simple and short, but very effective.
The future for the Metroid series seems to be bright. If Nintendo can release a GBA game every year or two, and a Gamecube game every 2 years, I would be in heaven. Between this and The Legend of Zelda, I don't need any other games. Metroid has been a part of my life for almost 18 years now, and every time a new game is released I get all excited like a little kid. Zero Mission was no different.
CNN: MP3 Shits
2 comments (closed), posted on february 21, 2004, tags: random
This is not a photo collection, just a single photo. It's from CNN, just a few minutes ago, from a story about the RIAA cutting down on illegal downloads. They showed someone going to different websites with illegal MP3s.
In the history dropdown, there was an address I found funny. Sure, it's supposed to be MP3s Hits, but on national live television it looks a lot more like MP3 Shits.
I love you CNN.
Trains and More
5 comments (closed), posted on february 20, 2004, tags: photos
On the way to New Jersey tonight for a dentists appointment. Click the image to view them all.
The dentist said that every molar has something wrong with it. That's what happens when you don't have dental insurance and/or don't go to the dentist for at least 4 years. Every damned molar. Ridiculous. And it's not like I don't brush—believe you me, I brush. I just have stupid weak enamel and now all of my teeth are shit and have to be fixed.
I have four appointments the next four weeks, and then I need to schedule the extraction of my other three wisdom teeth. I'm not going to be able to chew from here until 2007. At least when it's done I'll have pretty teeth. Well, the molars at least*. They'll be pretty.
* It should be noted that my front teeth are pretty, thankyouverymuch.
Cats in Different Places
1 comment (closed), posted on february 19, 2004, tags: photos
A collection of photos from the past year. Felix and Oscar (pictured above) in different places around our apartment. Click the image to view them all.
Photos Section Added
7 comments (closed), posted on february 17, 2004, tags: site
I've finally added a photos section to this site, after months and months of meaning to but never actually doing it. The first book of photos is from this past weekend when Katia and I drove up to Massachusetts for snowboarding and to visit our friend Shannon from high school.
I didn't take any pictures of snowboarding because I still fall too much to bring my camera with me, but I think next time I might be ready. This book is mostly photos of the drive up and the drive back, and Shannon's house in between.
Webmonkey Special Characters Reference
5 comments (closed), posted on february 17, 2004, tags: web
Since Lycos is officially shutting down Webmonkey in the near future, I took a few minutes this morning to nick the only part of the site I utilize on a regular basis—the HTML special characters reference.
I took their list, reformatted it using XHTML/CSS and Intelligence™, expanded a few things (letters and numbers) and gave it a permanent home here at Maniacal Rage:
» http://www.maniacalrage.net/projects/special
Feel free to bookmark it and use it if you're so inclined. I'll add to it in the future if I come across an entity not on that list.
List of Changes
4 comments (closed), posted on february 16, 2004, tags: site
I made so many changes that I'm having trouble remembering everything, but here's the best list I can provide for myself and for people who have nothing better to do in their lives but read lists. Note that I've still got a few things to change in the sidebar, but they'll have to wait until tomorrow.
Navigation
- Switched to horizontal navigation, removed sidebar navigation
- Moved breadcrumb navigation to main content area, made it smaller
- BC navigation is now a bit smarter, providing better archive navigation
- BC navigation is also now on the bottom of pages too
Sidebar
- Removed statistics from the sidebar
- Added short description to the sidebar
- Added/removed some elsewhere links
- Moved search box from sidebar to archives page.
Archives
- Changed archives page for better readability
- Reordered full entry-by-title list into blocks that are alphabetical
- Monthly archive links are now displayed differently (better hierarchy)
- Category links now have a bit more space between them
- All item counts are now in smaller font (less 'in-your-face')
- Changed URL for archives from /archives.php to just /archives (redirect is in place)
Entries
- Removed date headlines
- Enlarged titles, titles now used as headlines
- Removed left gutter (and dotted line)
- Removed category links in the byline
- Modified comments link to be more friendly (4 comments rather than Comments (4))
- Switched to relative dates for anything younger than a month (Posted 4 days, 3 hours ago, etc)
- Moved next and previous entry links on individual pages to under the byline
- Changed blockquote style to solid bordered (see example)
- Changed footnote style to dotted-blue bordered with blue text (see example)
Comments
- Changed comments block to look like blockquote
- Modifications to comment listing
- Removed 'wrote:'
- Made author name and date one line
- Changed comment posting form
- Rearranged form elements
- Fixed tab order to include cookie radio buttons
- Removed note about spell check, since it works in every browser except Mac IE now
- Slight editing of 'notes'
Miscellaneous
- Changed the way links work... from now on, no links will pop new windows except the following:
- The search results window (this is still a remote pop-up window)
- Links to images and/or photos will pop a new browser window unless you check the box at the bottom of the about page
- Finally updated all the error pages (404, 500, etc), since they've been the same since 2002
- Upgraded my RSS feed to 2.0 (and it validates)
- Added a new section to the about page called 'About the Setup', describing my computers (enough people have asked)
There you have it. As always, comments, thoughts, complains and suggestions are welcome.
Ongoing Changes
6 comments (closed), posted on february 11, 2004, tags: site
As you've no doubt noticed, I've made changes to this website over the past two days. It started with a few simple things and has now bloomed into at least 100 subtle differences and several major changes including the new horizontal main navigation and the removal of date headlines throughout the site.
I'm not done yet, so consider this a work in progress. I'll continue tweaking until I'm good and done and then I'll post a comprehensive list of changes for the curious. In the mean time, let me take a moment to thank Daniel, Phil and Shawn for the help the past few days as I continuously complained about CSS and asked "How does that look?" hundreds of times. Daniel gets double credit for specifically telling me not to use this masthead that I created the other night after I had completely lost my mind, and Shawn gets half-credit for telling me to go with it.
A few things might be screwy from time to time until tomorrow.
Web Standards Award
4 comments (closed), posted on february 10, 2004, tags: site
I'm proud to announce that the xPad product page has won a Web Standards Award.
Web Standards Awards is a new site which "aims to promote web site design using W3C standards by seeking out and highlighting the finest standards-compliant sites on the Internet," and I'm thrilled to be one of the first winners.
iChat AV 2.1 Offers Almost Nothing
9 comments (closed), posted on february 8, 2004, tags: software
As mentioned in my post over at xlab, Apple released iChat AV 2.1 "Public Beta" a few days ago. It's major feature addition is the ability to have a video chat with a Windows user (who is using the newest version of AIM and has a video camera, obviously). While that's great and all, I'll probably never use the feature because none of my PC-using friends have video cameras. What I'm disappointed about, however, is that there are seemingly no other new features in iChat AV 2.1.
By now, you'd think Apple would have added at least one new feature that affects the way you use iChat. After all, since it's incarnation, the only real change has been the ability to audio- and video-chat, but that doesn't really change things for most people, since I doubt most people are using those features on a regular basis. What Apple needs to address are the following:
Why can't I set a cusom away message from the menu bar? I can do it from the buddy list, but I can't do it from the iChat menu. See this image—all of my away messages are there, but I can't add a new one. That means that if I want a custom away message, I have to open the buddy list, click the 'Available' menu, select 'Custom...' and then create my message. And my habit is to then close the buddy list again, meaning that because I can't set a custom message from the iChat menu, I have to do a lot more work.
Groups in iChat are a joke. Almost everyone knows what groups look like in AOL Instant Messenger for windows (and all other platforms, actually). If you don't, see this screenshot. AIM uses a very simple groups system that allows you to visually separate your buddies into groups and either minimize or show each group. How does iChat handle this? It uses an absolutely ridiculous drawer that contains a list of your groups which you can toggle on or off, hiding buddies in an unchecked group completely (see screenshot). This is not groups, this is filters. They are two very different things, and this implementation is completely useless to me (not to mention it taking up far more screen space than it needs to).
Tabbed chat windows. AIM proper doesn't do it, iChat doesn't do it—but nearly all third-party AIM clients do. There's a reason for that, and it's time iChat implement tabbed chat windows. Adium in particular handles this well (even if it has the most annoying sounds ever). Here's a shot of a tabbed window in Adium:

Having one window for multiple conversations saves screen space and adds a bit of order to what is usually an annoyance if you have more than 3 chats going. I don't know why AIM has never had this feature, and I see absolutely no reason iChat shouldn't, especially since it would look a lot like Safari and users would already know how to use the feature.
I've been using iChat as my AIM client since the release of 2.0 (AV). The reason for that was not because I liked iChat better than other clients, but because it was the only one able to use video chat so simply. I still use video chat frequently, and for that reason I'm going to continue using iChat. I just wish Apple would start adding a few features that will affect me on a day-to-day basis and make my experience better.
Dooce, version 2.0
posted on february 6, 2004, tags: web
I've been reading Dooce for a really long time. It's one of my guilty weblogging pleasures that I've never linked to or mentioned, but that I've read nearly daily for years. The reason I mention the site today is to congratulate Heather and Jon on the birth of their first child, Leta.
Bush Will Do Whatever He Wants
3 comments (closed), posted on february 5, 2004, tags: random
Bush's official response to Massachusettes' ruling on gay marriage yesterday is absolutely typical and pathetic:
Today's ruling of the Massachusetts Supreme Judicial Court is deeply troubling. Marriage is a sacred institution between a man and a woman. If activist judges insist on re-defining marriage by court order, the only alternative will be the constitutional process. We must do what is legally necessary to defend the sanctity of marriage.
Is it just me, or does it seem like Bush is going to continue to do whatever he wants, and fuck everyone else if they don't agree? He wanted to go to war in Iraq, the US and UN said no, he said fuck you all, I'm gonna do it. Now he's decided that regardless of the fact that individual states have the right to make their own laws about marriage, he's going to attempt to fuck that up too.
It's becoming clear that no matter who wins the democratic nomination, they should be voted for. Anything is better than this.
Pinkerton Complains, Safari Continues Lead
5 comments (closed), posted on february 4, 2004, tags: software
In this latest entry, Mike Pinkerton complains that Apple is spreading "propaganda" with it's most recent performance comparison on the Safari page. He writes:
[The chart] compares it to Camino 0.7 and Netscape 7.0.2. Both of these products are more than a year old and are based off of Mozilla 1.0. Why not compare to Netscape 7.1? Because those numbers don't look as good.
I'd just like to point out a few things. One, Camino 0.7 is still the latest official release of Camino. Yes, it's more than a year old. Doesn't that say more about the development of Camino than about Apple spreading propaganda? Two, is Apple supposed to release comparisons based on nightlies? That's preposterous, and it will never happen. Three, stop fucking complaining about Apple and Safari. Please. We're all begging you. We get it—you're still pissed off about Safari. That's fine. But spend less time complaining and more time working if you want Camino to be on par with Safari. Or, maybe, just release more frequently than every 365 days.
I will admit, however, that listing Netscape 7.02 is strange. Netscape 7.1 was released quite a while ago and should definitely have been used for the product comparison. But the Camino version used was accurate. If you want them to test against 0.8—release it.
As far as Safari goes—1.2 is fantastic. The browser is getting better and better with each release, comparison chart or not. I used to use Camino as my primary browser, but I changed to Safari a long while back due to the slow progress of Camino. Don't get me wrong—I am still interested in using the browser. I'm not interested, however, in painfully slow development cycles and bitching and moaning.
Update: Pink has since updated his entry to clarify that he's mostly concerned with Apple testing against NS 7.0.2, which renders most of my complaint here moot. None the less, for archival purposes it will remain unedited.
Safari & xlab
posted on february 3, 2004, tags: software
Today I became number three in a group of three people who post to the Mac OS X weblog over at xlab. I'm thrilled to be a part of the team and I look forward to posting a lot of great stuff to the site for both a new audience and for readers of this site to enjoy.
» Continue reading Full Keyboard Access in Safari 1.2 at xlab.
Adventures in Tooth Extraction
10 comments (closed), posted on february 3, 2004, tags: me
Yesterday I had a dentist appointment. It's a complete coincidence that while waiting to board a train to New Jersey in Penn Station, I suddenly had a very sharp pain in my face that was followed by more sharp pains and then just constant pain that wouldn't fucking stop.
We got to the dentist as soon as we could and Katia spoke for me, telling them that my upper-left wisdom tooth was fucking killing me, and please help me now oh please god. They said it needed to come out. I said that seemed like a painful idea. They said yes, it would be, and that didn't chance the fact that it needed to come out. My mother suggested I go to her oral surgeon, because he's "really great." I don't know how great any kind of dentist is, because I hate them all, but I agreed that I would rather go to a specialist who could get it out in 10 minutes with a nice bit of Verset on the side than have Katia's dentist get it out "any way it is necessary to do I will do... how tools I use doesn't matter, that's my job, you will just take pain killer and I'll dig it out." He's Russian, old school, and could get the job done. I'm American, a pussy, and I wanted someone to almost knock me out and then pop the sucker right out of my mouth. And so.
Now I'm sitting here, at home in Brooklyn, my face sore and my gums bleeding. I have a big gaping hole in my mouth, and it's weird. The dentist told me I need to have the other three out as well, because they're crap and they're also pushing around my other teeth, but when he does that he's going to give me even more sedation (which is a very good thing).
So if you've been wondering where I was or what I was doing, now you know. I was having a tooth ripped out of my head and now I'm sitting here bleeding and waiting until I can take my next Vicodin ES (one and a half hours and counting...).
Snowboarding, Beta 1
4 comments (closed), posted on february 1, 2004, tags: me
Went snowboarding for the first time on Saturday. It was a lot of fun. I got really crappy rental equipment—the board was at least six inches shorter than it should have been, and was so narrow my boots hung over by at least two inches on both edges—but it was fun nonetheless. We went to Mountain Creek in Vernon, NJ, which is only about an hour away from Summit, where Katia's parents (and I used to) live.
Having never been skiing or anything on the east coast (I skied when I lived in Seattle), I was surprised to see that Mountain Creek looked a lot like the place I used to go in Seattle called Snoqualmie Pass. The only difference is that Mountain Creek is really just a big hill and the pass was a pass on Mt. Rainier. Either way, the snow was great and it wasn't as cold as I thought it would be.
Snowboarding itself was really hard at first. It was quite different than skiing, and I couldn't for the life of me get up leaning forward without falling. It took a long time in the beginning, but once I got past that hurdle things were much better. Katia took the old "slow but steady wins the race," and I ended up going with "I kill speed and turn successfully only half of the time usually," which ended up meaning that my falls were much, much harder. After a few hours, though, I was falling much less frequently and having quite a bit of fun.
We definitely need to buy our own equipment. After having dealt with that crap-ass board, I know that it will be a lot better with proper stuff. Granted, it's a bit of an expensive buy-in, but it will make up for itself if I don't dig my toes in when turning and have a better time.
Next time I go I must definitely take pictures.




