VIM makes my life easier
2009-03-05 4:34 pm ∴ Programming,Thoughts ∴ Tags: , , ∴ by matt -

So today, I had to comment out a bunch of links on a static website. It was only linked from 10 or so pages, so I thought writing a regex to comment out just that link would be too bothersome. I decided to just use VIM. Here’s how easy it was:

<Enter>  -- Open the file in WinSCP
:41 -- go to the line number of the tag to comment out
vat -- select all of the tag
<Alt-X> -- Comment out the selection with the EnhancedCommentify plugin
ZZ -- save and close
<Down-Arrow> -- go to the next file in WinSCP

That’s all. If I had more commands to do, I could record a macro and get everything down to around 6 keystrokes. Can’t beat that.

Good news everyone!
2009-03-03 10:57 am ∴ Programming ∴ Tags: ∴ by matt -

Qt 4.5 has been released. What’s that you say? Why does it matter?

This is the first release that includes an LGPL licensing option. This means you can use Qt in anything provided you distribute any customizations made to the Qt Libraries. For those uninitiated in the world of cross-platform gui development toolkits — Qt is, in my humble opinion, better than life itself.

I will download it tonight when I get home. While I’m at work today, I will daydream of all the applications I can write and distribute under a BSD license. :)

Hopefully, PyQt will follow suit and also create an LGPL license, even though event handling in PyQt is kinda crummy. Kinda really crummy.

Being lazy
2009-02-24 10:55 am ∴ Uncategorized ∴ by matt -

I’ve been slacking in my updates. I need to get some content up. I don’t want to lose my visitor. Hi MKR!

Oh no, Memories!
2009-02-09 5:06 pm ∴ Uncategorized ∴ by matt -

I’ve been working with haXe at work doing some Flash testing. It’s a pretty handy little tool. But something about it brings back some not-fun memories…

There was a time when I was collaborating on an IRC client with a few other people. We had a particularly difficult time getting what we wanted out of the standard Windows control set. So we had to make custom controls. Subclassing wasn’t good enough and Owner-Drawing never worked out as well as we wanted. So we made, 1) a custom Listbox, 2) a custom text control for rendering IRC text, and at one-point, there was 3) a custom menubar. There were going to be others… a custom Tab Control, a custom Toolbar, tooltip, and probably a button and progress bar and a few others that I’m forgetting.

Does that seem ridiculous? It should. Making custom controls is a lot of work. So why does haXe remind me of this? Basically, unless I decide to use Flex or another 3rd party lib, there is no UI api. Everything has to be custom.

Maybe this is why I’ve stayed away from Flash since version 4.0? If I never had to code a custom control again, I’d be a very happy man.

Fun with PHP dates
2009-02-05 11:53 am ∴ Programming,Thoughts ∴ Tags: , , , ∴ by matt -

So in a recent project, I had to handle some formatted dates. Piece of cake right? Date handling in PHP is a snap with date() and strtotime(). In fact, I’ve often said that the date functions are the best part of PHP, so I’ll have this knocked out in no time.

Well, maybe not.

I’m handling credit card expiration dates specifically in this case. Usually, the user is given a choice of months and years in a drop-down list. “That’s too annoying,” I thought, “It’s much faster to just type it in and let PHP handle the date formatting.” The expected input format is mm/yy so, of course I proceed with something like this for storage:

date("m/Y", strtotime($ccexpr));

Done and done! Hmm…until I tested it.

Turns out that strtotime() doesn’t like the format mm/yy. So maybe if I enter it as mm/yyyy it’ll be ok. No, not ok there either. “That’s kind of odd,” I thought. So I head to the function’s page to see if there are any user comments on it and I see this:

strtotime returns time() for any string that begins with “eat” (case insensitive)

Hrm? What sense does that make? It could be an abbreviation, but what does EAT stand for? Well, I’m getting off point by now, so I set up some tests to see what I could figure out with strtotime():

strtotime():
2/8/2010 => 02/2010
2.8.2010 => 08/2010
2010-2-8 => 02/2010
2/8/10 => 02/2010
2.8.10 => 02/2009
10-2-8 => 02/2010
2/10 => 02/2009
2/2010 => false
2010-02 => 02/2010

Weird huh? 2/8/10 gives the correct year, but 2.8.10 doesn’t? 2/10 gives the wrong year (because it’s assuming the date given is 2/10/current_year), but 2/2010 fails? Yet, 2010-02 works. I’m kinda baffled by this, but I’m sure there are some eccentricities to this function since it handles stuff like “tomorrow +20 years.”

So, since I’m asking for a specific format, I decide to switch to strptime(). As with all PHP functions I seldom use, I check to make sure it’s available in the version I’m using. Since 5.1? Ok, whew! Wait…really? This is a pretty basic date function that’s provided in the C run-time. Why did it take so long to get in to PHP? Ok that’s beside the point — but I look a little down the page and see:

Note: This function is not implemented on Windows platforms.

What? Why? It’s like I’m in bizarro world or something. Am I crazy?

Ok — it still doesn’t matter, there are still things here that need to be done, I just can’t test it on my machine at work. No biggie. So I check strftime() to see about the formatting codes. Hmm. Wait a second…again…  strftime() has been available since PHP 4? Why it — what — not — both — ? Arghhh!

I must be crazy. I must be. If I’m not, PHP will surely drive me there.

Off to a great sturt
2009-01-27 4:24 pm ∴ Thoughts ∴ by matt -

I was just reading over my post from yesterday — I didn’t mean it to come across as whiny. It was more of a cynical tone that I intended. Firefox and Firebug have saved me more trouble than they’ve caused, so it’s not a total bash against those two pieces of total garbage. ;)

Anyway, the point of this post was to say that I was hoping to make this more than a site in which I complain about stuff — and that I’m off to a terrific start! Also I wanted to list topics that I’ve been thinking of just today –

  1. Writing robust web apps is still a lot of work
  2. PHP ORMs are truly the work of Satan
  3. On a more personal level — My thoughts on why I feel like I don’t fit in with anyone.
  4. Taking pictures and doing stuff not computer related
  5. The ins and outs of some wordpress plugin I’m going to write.
  6. The process of converting a 2-D game from D3D to SDL.

Those are just some potential things to explore. Any other ideas?

How to break Firefox
2009-01-26 11:07 am ∴ Rant ∴ by matt -

I don’t know how long this has been around (I think only since 3.x), but if you’re using Firebug…

  1. Open a site with javascript that you’re presumably trying to debug or are otherwise involved in some time sensitive development.
  2. Set a breakpoint in a script.
  3. Get the breakpoint to be reached, thus halting execution of the script.
  4. Find exactly what you’re looking for.
  5. Fix it in the code file you’re working on
  6. Refresh the page.
  7. Notice that none of the Javascript seems to be working — if the page even displays
  8. Remove the breakpoint and try again
  9. Copy the URL because you know you’re going to have to restart the browser
  10. Get a message about Firefox already running
  11. Open up your process manager and see Firefox using up 100% cpu and an enormous amount of memory
  12. End the process
  13. Start Firefox again
  14. Find out that your URL wasn’t copied
  15. ARGGHH

Note that this can be avoided by resuming the javascript engine before step 6 — but I never remember to do that.

WordPress Installed
2009-01-25 9:59 pm ∴ Uncategorized ∴ by matt -

Working on getting this thing up and running…

[p → -∞]