Converting Ticks to a Timestamp
| May 2, 2009 | 0 Comments | Trackback |
I recently had to deal with a SQLite database that stored the timestamps as ticks. Having to first research what a tick is, I created a simple function that will convert a tick value to a timestamp or MySQL datetime value since I couldn’t find anyone else who had done such a thing yet.
You can download it here.
The only tricky part (aside from figuring out what a tick is) was calculating the number of ticks between 0001-01-01 to 1970-01-01. Also of note: a tick is apparently a popular way to store date/time values for Microsoft.
Google Apps only gives 2GB to Safari users?
| November 20, 2008 | 1 Comment | Trackback |
I recently had a small need to sign up two new Google Apps accounts and setup calendar sharing between them. So I naturally open up Safari as my second browser of choice and go to the sign-up page, only to notice that rather than the standard 7.2GB of space, I only get 2.7GB when signing up with Safari. Not willing to temp fate, I closed Safari and signed up through Firefox. Interesting!
Bug with Adobe Flash on Mac when uploading files to a redirected URL
| September 24, 2008 | 0 Comments | Trackback |
Just spent almost the entire day trying to figure out what I was doing wrong when trying out many different flash multi-file uploading widgets. All of them would give me a 302 redirect http error, even when testing locally.
So after much searching and reading and studying… and finally testing this on my Windows machine (which works fine); I’ve decided this is a bug in Flash 9 for Mac.
There’s not a problem when it’s uploaded to a script directly which returns a 200 OK header response first. But when you use a framework that uses mod_rewrite for every URL, it’s not easy to get around that.
If anyone else has had experience with this I’d love to hear from you. Very frustrating! Maybe it’s fixed in the Flash 10 beta? Maybe it’s not a bug; it’s a “feature”, right?
UPDATE: I went ahead and installed Flash10 hoping for the best, but with no luck. I was able to contact someone at Adobe who told me the Flash scripts will have to be recompiled in Flash10 to see if Flash10 would help. So installing Flash10 on my computer won’t make the scripts any different.
Redirect all but used subdomains to primary domain using mod_rewrite and CodeIgniter
| September 21, 2008 | 2 Comments | Trackback |
I was recently playing with mod_rewrite and wanting a couple of subdomains to act as subdomains, but all others to redirect back to my site without the leading “www”. For example:
www.example.com => example.com
bad.example.com => example.com
api.example.com => api.example.com
Not being a regular expression or mod_rewrite expert (or any resemblance of such), this was a bit of a challenge. But I did it with the help of a mod_rewrite and regular expression cheat sheet, as well as the excellent Apache URL Rewriting Guide.
So here it is for anyone else that could benefit. Just replace the bold parts with your own subdomains (and example with your domain).
Redirect without leading www:
# Redirect deleting leading www to root domain if no specified subdomain is used<br />
RewriteCond %{HTTP_HOST} !^(subdomain1|subdomain2)\.example\.com$ [NC]<br />
RewriteCond %{HTTP_HOST} !^example\.com$ [NC]<br />
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]<br />
Redirect with leading www:
# Redirect adding leading www to root domain if no subdomain is specified<br />
RewriteCond %{HTTP_HOST} !^(subdomain1|subdomain2|www)\.example\.com$ [NC]<br />
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]<br />
If you’re using CodeIgniter and mod_rewrite for pretty URLs, you’ll need to be sure to add these subdomains to the list of directories that can be accessed directly.
# CodeIgniter writing<br />
RewriteCond $1 !^(index\.php|images|robots\.txt|css|user_files|subdomain1|subdomain2)<br />
RewriteRule ^(.*)$ /index.php/$1 [L]<br />
Serving a large file through PHP without hitting memory_limit
| September 10, 2008 | 0 Comments | Trackback |
Ran into a little problem hitting the memory limit for PHP when serving 100MB+ files through a script like:
$file = @fopen($filename,"r");<br/><br />
if ($file)<br />
{<br />
while(!feof($file))<br />
{<br />
print(fread($file, 1024*4));<br />
flush();<br />
ob_flush();<br />
}<br />
@fclose($file);<br />
}
Found that you need to call ob_flush() as well as flush() since flush() has no effect on the buffering scheme of your web server.
Just thought I’d throw that out there for anyone else.
MultiTouch Trackpad Gestures For The Rest Of Your Apps
| April 12, 2008 | 0 Comments | Trackback |
If you’re one of the lucky ones to be able to get one of the latest MacBooks with Multi-Touch, you’ve probably asked the same question I have: “How can I get Firefox to use the swipe gesture to go forwards and backwards like Safari does?”
Answer: MultiClutch
This neat little Preference Pane addition will allow you to associate trackpad gestures with keyboard shortcuts; per application.
So this gives you exactly what you’re looking for: navigation for Firefox 3 (beta) via trackpad gestures. Only apps built with Cocoa are supported right now, so this won’t work with Firefox 2, sorry!
If you found that app useful, please consider making a small donation to Will! It helps make the world go round. =)
Cycle Your Batteries!
| April 7, 2008 | 0 Comments | Trackback |
When buying portable products, I usually like to be (over) prepared for whatever situation may arrive. When I bought my Panasonic HD camcorder, I also searched the web thoroughly and bought two extra batteries and a 16GB SD Card. Plenty of power and plenty of space.
So I found myself looking at an extra battery for my recent MacBook Pro purchase so that I’m never caught dead. As I do before buying anything electronic over $50 I started reading the reviews, which all seemed to be horrible, dating back to 2005 even. I was a little confused since I went the entire weekend without having to charge my MacBook Pro, and even found myself on Sunday night waiting for the battery to die before I went to bed so I could give it a full cycle.
Obviously I didn’t use my notebook more than 5 hours (the rated time it can/should last). I didn’t do any work this weekend (that’s a first really), so nothing more than looking up movie times, checking bank statements and researching some thing (ok, so maybe I did a little work)… but battery life was more than adequate. So I didn’t quite understand all these reviews; especially some claiming “my battery doesn’t last more than 10 minutes!”.
For any MacBook user, you’ll find a wonderfully cool program called CoconutBattery that tells you the actual and rated battery capacity at any time. (Just don’t leave the application open, I found that it locks up my entire system after prolonged use.) So armed with that, and with Apple’s battery notebook care, you’ll have everything you need to help get the most out of your battery.
As you can see from my battery history, as I started to completely drain my battery (2008-04-04), my battery’s maximum capacity increased. April 06 was when I completely drained and charged the battery for the first time. I’m willing to bet that many (the “average”?) user doesn’t know or understand how batteries work. They understand (and I remember thinking in my teenage years) that batteries fill up and drain; there’s nothing else to them.
And who knew you could calibrate your battery to ensure an accurate reading?
This is also great advice for anyone using anything that has a battery. Batteries need to be used to be kept healthy. Windows users can use tools like BatteryMon (30-day trial, $24) to get battery capacity monitoring and recording.
iPhone users should take this advice to heart also, especially since replacing the iPhone battery is only free within your first year of purchase under the warranty; and that’s only if the battery is holding less than 50% of what it should. Otherwise you’re looking at almost $90 and a week or two without your phone.
In short, use your batteries!
Getting Organized with Spaces
| March 2, 2008 | 3 Comments | Trackback |
Upon getting my Mac, Spaces was one of the first things I checked out. I had tried Virtual Desktops in Windows and Linux, but never found them to be too terribly helpful. Not to mention I used a dual monitor setup with my Windows machine, so I felt I had plenty of room for things.
Despite having a nice big 24″ screen, I have often felt my desktop to be cramped and cluttered; especially coming from a dual monitor setup. So the idea of Spaces seemed perfect, except using the keyboard shortcuts felt too slow and like to much work just to get to another application or space. (F8 + Click on a space OR Cmd + Arrow) So this tip from Mac Os X Hints sounded like the perfect solution. Although they don’t actually offer a tip on how to do it (just the tip to do it), this is what I’ve done:
1. Assign Spaces to use the Cmd + Arrow keys too switch between Spaces.
2. Use SteerMouse to assign the right and left mouse scroller to use those combinations (Cmd + Right Arrow) (Cmd + Left Arrow)
3. There is no three!
I’m using 6 spaces now, for web browsing, coding, FTP, RSS Feeds, iChat and iTunes.
Any other suggestions on a good/better way to do the key assigning let me know!
My Mac crashed on me, and I lived to tell about it.
| December 7, 2007 | 2 Comments | Trackback |
I’ve been a Mac user now for 24 days; and I’m loving it. I’ve been anxious to write several blog posts about the highlights of my experience in switching to a Mac + PC workstation. I have several stickies on my desktop with notes about what to include in these blog posts; and to be sure I’ll still write them.
But my experience just 15 minutes ago with my brand new 24″ iMac scared me like my Windows machine has never done before; and has prompted (or incited) me to be active on this blog.
I’m really getting the hang of the Mac OSX system. I’ve already purchased Coda for a development environment and I have lots of things going on at once when I’m developing. This is about the time when a kernel panic decided to happen. I’ve read about it before. The Mac equivalent of the famous Windows blue screen of death. But I have now experienced it first hand. Some people even think this is a good joke (and it is).
It happened when I had clicked on a link in my browser, so I figured perhaps some javascript had really done Firefox wrong and in turn messed everything else up. So per the on screen instructions, I held the power button down to reboot. I was greeted with 2 low beeps, followed by 3 beeps (repeated). Not cool. I was initially a bit upset (read: mad)… this is not supposed to happen. This is a Mac, right? I thought it’s just supposed to work.
I ran through standard problems: overheating (it does get hot), bad hard drive, bad motherboard. Unfortunately, it turns out the beeps meant bad RAM. I have switched over just about everything to my Mac (except e-mail), and I don’t have a backup Mac (yet) in case something like this happens. Lucky for me, I had bought 4GB of RAM to be used as a Christmas gift for my dad for his Mac. And lucky for me, the RAM is just about the only accessible thing on the iMac.
Sure enough, popped the 1GB stick out and put the new one in and it’s up and running again. Not cool Apple. Is this really the type of RAM you charge $700 for a 4GB upgrade? (No, I didn’t buy my 4GB from Apple). Could just be a fluke though, I’ll give them that. =) But it is frustrating… what if I didn’t happen to have that 4GB of RAM sitting around for Christmas? I would be dead in the water until I took it to an Apple service center or went and just bought (read: spent more money) for RAM.



