
Posts by Jack:
- Totally reusable code
- Emulate master pages; only with this, you can use the Ajax control toolkit to do it
Goodbye, Movable Type; Hello, WordPress
January 12th, 2009I’ve been using Movable Type for a few months now. I’ve liked it, but it wasn’t great; it worked well, but I wasn’t blown away. After a while, it moved slow; there was no way to remove a lot of comment spam at once (which I seemed to be particularly prone to), and I had a few bugs, such as having to log in twice each session. Maybe they weren’t all MT’s fault; but I had trouble finding support.
So, when we set up our new Windows Server 2008 machine using a 64-bit edition, I hit a wall: there’s no MySQL support for ActivePerl x64. There isn’t any official support for x86 either; but there are workarounds for that (use external repositories). It also came at a time when I was deciding whether or not I wanted to switch, so it pretty much cinched it up; I decided to try out WordPress. It was a PHP/MySQL system, both of which I had already set up, so I expected (or at least hoped) that it’d be pretty simple to get running.
The first thing I had to do was back up my old MT database. I expected some long, tortourous sequence of MySQL edits or something, but all it came down to was logging in, clicking “Import/Export”, and then export. It spit out a text file, which I saved to my desktop. Next, I unzipped a WordPress download into my blog folder (and set up the requisite site in IIS). I set up a database and a user in MySQL for my blog. I then edited the wp-config-sample.php, filling in the requisite database information and renaming it to wp-config.php, visited the site in my browser, and hit ‘go’. Seconds later, I had a new, live WP blog.
From the admin panel of my blog, I went to tools, hit “import”, selected “Movable Type” from the list, browsed to my file, and uploaded. And that was it. I had totally converted to WordPress in minutes. I was absolutely astounded by the ease. It was already much faster (with the help of WP-Cache), and running well.
Next stop: new design. WP looks like it’ll be much easier to work with, so hopefully we’ll be up soon.
Kubuntu 8.10 and Wireless
December 6th, 2008After using Vista for a while (and after my brief experimentation with Ubuntu 8.04), I decided to go ahead and create another partition for Kubuntu 8.10, with KDE 4.1. I did it with the latest version of Wubi. It installed fast, booted fast, and left me without wireless (as I expected). Problem is, I had moved my office downstairs, leaving the router upstairs; I had to get wireless working somehow.
So, I booted up my laptop and began a search. “Install Ndiswrapper“, was the first bit of advice I got; so, I downloaded this onto a flash drive, plugged it into my new Linux machine (which found the drive and popped it up helpfully), and tried to install it. I followed the instructions left by the developer in the ‘Install’ notes; however, to my dismay, I was unable to due to an error that read “error: too few arguments to function ‘iwe_stream_add_value’ “. Having no clue what it meant, I did a quick Google search, and found out I had to patch the Ndiswrapper with this patch.
I copied the patch file into the directory, then ran
patch -p0 > ndiswrapper_kernel_2.6.27.patch
… and again, I hit a wall; it threw up an error that the patch command is not recognized. So, again, I hit google and found that I needed to now download and run the “Patch” installation file (I already had all the dependencies installed). Now, I ran the patch command, and it worked! I installed Ndiswrapper, then followed the guide here to get it up and running.
So, this was posted from Firefox in my new linux installation.
Back from Vacation
December 2nd, 2008Just got back from spending a week in Arizona- that’s right, the middle of the desert on the border of Mexico- where it rained for three days. We couldn’t get to part of the Grand Canyon because of the snow. In Arizona. Did I leave Ohio?
I don’t want to complain too much, though; the resort we stayed at was very nice, and Audrey’s aunt was kind enough to pay for everyone’s stay. And the Thanksgiving dinner was something I won’t forget (the link will explain all).
Anyway, first thing I did when I got back and settled (besides scavenging a cheap turkey from the grocery store… 12-pounder for $10) was delete 400ish spam messages. Sorry for the garbage; the new version of MovableType supposedly clears that issue. I also upgraded my theme; still not a custom one yet, but I’ll get there once I get the time.
I also installed Rainmeter, Samurize, and Rainlendar - they are absolutely fantastic desktop-managing applications. And, if that wasn’t enough: I installed a new hard drive and I’m in the process of installing 5 virtual drives; Windows Server 2k3 and 2k8, Windows XP, the latest version of Kubuntu, and Fedora 10. That is, if I can get the last two working with Windows Virtual PC 2k7.. I’ve seen it done, but I know it’s tricky. The goal is to have plenty of development platforms with which to do my work; I’ll be able to test web apps in the virtualized servers before I push to production on CD.
Speaking of CD, we’ve got our new website up; I was inspired by a Keane song, and somehow came up with this. My brain goes through somewhat strange processes sometimes, but I’m pretty happy with the result. JQueried it up, even, much to the chagrin of my budding Ajax framework project.
Bluetooth Issue on My Dell Laptop
September 11th, 2008I’ve got a Dell Latitude D820, with a Toshiba 350 bluetooth card. Don’t ask me why Dell used a competing laptop brand’s hardware, because obviously it isn’t working out…. the fact that the Toshiba “Dell” drivers are two years old, while there are drivers out “for Toshiba laptops only” that are significantly newer. But I digress.
My issue was in connecting my LG Dare (fantastic phone, I might add) via Bluetooth. I used the drivers right off of Dell’s website, which installed the “Bluetooth Stack By Toshiba For Windows” (what a mouthful). I was able to use dial-up-networking and use it as a modem, as well as setting up a serial port.. but couldn’t do file transfers or use bluetooth programs. It just wouldn’t find the phone.
So, after an unsucessful hour and a half on the phone with Dell tech support, and a full day of Googling, I decided to try something totally crazy: uninstall the Bluetooth Stack from add/remove programs, and then do a ‘scan for hardware changes’ in the device manager. (make sure the bluetooth is active (check for a blue icon next to your power icon on the screen hinge.) if it isn’t there, you’ll have to download the driver from dell’s site, activate it, and then uninstall it.) And, woah, it worked! It now showed up as a bluetooth device, rather than a network device, and I could now do all the file transfer stuff.
Now, my next step is using some of the Bluetooth API stuff from C4F, and make a proximity-based application.
User Controls Rock: Legos and Fake Ajax Master Pages
September 9th, 2008Let me start with a simple statement: user controls are absolutely fantastic.
If you haven’t delved into the realm of the .ascx, then let me briefly explain the two big benefits that have been relevant to me recently:
On the first point, the reusable code point, this is the biggest. It’s the entire reason behind user controls. It lets you chunk out code that you use all over, and use it in several places; it’s a fundamental of object oriented development. Let’s do an example.
Say you have a piece of code that goes to the database and retrieves data on a member. That data is then put into a styled gridview, for the administration side of a website. But, you also have an area in a members section where a user can edit their own information (more like a formview); and, on the normal web display, casual users can browse through usernames and user roles in a paged gridview.
Don’t write the same code thrice! (or even twice!) Rather, make a user control to do all the work for you, and place it in each of your pages. This is how I’d do it:
For the sake of this article, I’m assuming you’re using a list of “Member” objects. Use whatever.
-Make a public class-level property in your control called “ReadOnly”, a bool.
-Make a public class-level method in your control called “Intialize”, which takes an IList of Member objects
-If the IList has one object, add a FormView to your control, and databind it. Otherwise, go the Gridview route (doing this all from the codebehind would keep your code cleaner and keep you from having an extra control rendered, although you could do this in the .ascx if you really wanted to; just set one to visible=”false” to the one you’re not using)
-Create all of the appropriate methods for your control for delete, update, insert, etc. and set up your formview or gridview accordingly (of course, only update for our member’s area FormView!)
-If ReadOnly is true, don’t add edit, insert, or delete buttons to your formview/gridview. (Easy enough; could set visible=”false” on the fields, or just not add them at all)
And, then, back on your three main pages, register and use your control. Set the ReadOnly property (if it’s a bool, you should even get IntelliSense for true/false), and then on Page_Load, call Intialize on the control, passing through the IList of Members that you pulled down.
The reason we’re calling the data on the page, rather than the control, is so that the control can remain “dumb” and doesn’t need to know whether it’s a member, admin, or web display control. The less logic in the control, the better; just spit out the lowest common denominator.
Ok. Now that we’ve hit the reusable control side, let’s hit the fake-an-ajax-master-page part.
As you may or may not know, even if you wrap the ContentTemplate in a MasterPage, it still reloads every page change. This is because the MasterPage gets loaded after the rest of the page, and is treated like a control. So, if you change pages.. it loads the page, and then says afterwards, ‘oh, yeah, that was Ajax. Oh well.’
The cool thing you can do, is make one default page, and inside of that have user controls in place of your pages, something like this:
-Make your default.aspx page
-Create user controls; however, rather than logic in Page_Load of the control, put it all in a public class-level method you call Initialize.You’ll see why soon.
-Put all of your controls into your default.aspx page, with visible=”false”.
-On the onclick of your navigation buttons, run the Initialize on the control, and set it’s visible property to true, and all the others to false.. I might alternately suggest using Command and a single method rather than Onclick and seperate methods for each button, so you can pass through a CommandName, which you can then use in a switch statement and know what button you hit.
Ok. Now that we have our fancy Ajaxy page, you may be wondering: why not just visiblity? Why this Initialize thing?
This is because ASP.NET will fully render the controls, visible or not. Which means that if you have 10 pages, it will load those 10 pages and display one; which is a big performance hit on the server, especially if you’re loading database data into each of those 10. Having to explicitly call Initialize avoids this. It also allows you to pass through a common parameter to each of the controls (say, a title string that displays at the top of each control) .
Controls can certainly do much more than this; but these are the biggies for me. Have any .ascx uses of your own?












