Windows 8

Last month I bought a new laptop in preparation for two very long plane rides and a looming deadline. My intent was to immediately wipe the machine and install linux on it, but since I had not tried Windows 8 yet I figured I would try to give it a fair shot. I expected the worst – Microsoft has consistently let me down for a very long time – but I was generally not disgusted! I immediately installed a start menu (seriously, crippled dashboard only?) but with that addition everything seemed to go ok. I had some serious trouble compiling some libraries I needed, but that was pretty much the case across ALL windows versions, not just 8.

You could sum up my feelings as “Meh, not as bad as I was expecting”, which is actually a glowing endorsement from me as far as microsoft products go.

I had my development stuff already set up and win 8 wasn’t really getting in my way after that so I never ended up wiping the machine. Until today.

Rewind 2 days. Windows installed some updates which the engineers STILL couldn’t be bothered to write without requiring a restart. I decided to be proactive and restarted immediately. The ‘your machine is going to restart in 2 days to apply updates’ warning didn’t go away — apparently restarting isn’t always the same as restarting, if you know what I mean (what?). Strike one.

Zoom back to today. I was diligently working away and the laptop overlaid my entire screen with a warning telling me it was going to restart for updates in 15 minutes. Annoying as hell, but whatever. I was nearly finished with a fairly in depth review task and I foolishly assumed I could delay this a couple times until I was done for the night. 15 minutes later, in the middle of a sentence, the laptop restarts. Strike two through 1 million.

This is a call for retirement. There are two people who I would like to request step down from their positions and leave the software industry altogether — the person who proposed the idea that my computer should shut itself down out from under me and the highest manager up the line who approved it and let it ship. You don’t have the first clue about people, their computers, or what the former would like from the latter. You should move into a less mentally taxing job more suited to your talents — my suggestion/hope is you take up drunkenly blaming the local pidgeon population for stealing your teeth while publicly urinating on a park bench.

Also, a note to everyone at microsoft — the computer using population is gaining competence, wealth, and options. It is time to stop hiding behind the money you made when people didn’t have any other choices and join the world where people can actually use a computer that doesn’t make them want to hurt someone.

tl;dr – I’m back to hating microsoft in full force.

Uniform.js doesn’t update when changing select inputs

I ran into a bug today where I was programatically updating a select box’s options and specifying the selected value but uniform.js wasn’t displaying the changes. Here is a fiddle showing the problem. Two identical selects are emptied then repopulated. The uniform styled one still shows the original value of ‘two’ while the browser select correctly shows the first new option ‘—-’.

Luckily, if you update Uniform to 2.x you can fix the display by simply re-calling .uniform on the given select, as seen below (jsfiddle.net link).

Django – Finding out which database was used

I have a fairly complicated django app going that uses the same app models across multiple databases. Querysets have the .using() function which makes this fairly easy to deal with (except contenttypes…) but I ran into a situation today where I needed to go backwards from a model and find out which database it came from. I didn’t find any answers online or in irc, so I dug into some source and tracked down the _state.db attribute on models. Here is an example:


results = Model.objects.using('test_database').all()
results[0]._state.db
>>> test_database

Hopefully you find this quickly if you have the same question I had. :)

Webmin Update Broke PHP

I have webmin running here to manage all my virtual hosts and whatnot, with auto-updates turned on. Today it updated apache and I got my little message as normal and thought nothing of it until I tried to visit one of my sites and realized apache was down. After starting apache back up, my site would only serve raw source files (!) because php had been uninstalled or broken. I googled around a bit and found this is apparently a common problem and the webmin guys say it is a problem with apt, outside their control.

The solution is to simply apt-get install php5 again and restart apache, but to the webmin guys out there – it would be nice to get a notice if apache cannot start again after an updated and, if there really is a known issue between apt and apache, a special notice anytime apache gets an automatic update.

Problems with Faded theme by mintthemes

Today I bought the Faded theme from mintthemes for a client’s band site. I ran into several problems:

There are lots of cosmetic problems with the interface – uploading music buttons say ‘Upload Image’, setting show times really means setting a ‘post’ to be published in the future (not intuitive for the users!), the upload buttons in the theme settings cycle forever, even if you aren’t uploading anymore, etc. That isn’t what this post is about; I just wanted to blow off some steam.

I ran into two show-stopping problems. Hopefully if you have the same issues, this will help you out.

First: When creating photo albums, the link to the image uploader came back with a 404. After I submitted this to their support and they requested full ftp and account access (um, no) I decided to find and solve it myself. This one is because I have my install set to serve wordpress from the root directory but keep the files in a /wordpress directory (fairly standard, but not the default). The theme does not account for this, instead just blindly tacking wp-admin on to the root url. I haven’t gone around looking for this in other places (yet), but you can fix this particular instance of the error by opening up themes/Faded/includes/custom-post-types.php and changing line 291 as follows:

Change this:

href=">?php echo get_blog_info('url'); ?>/wp-admin/media-upload.... 

To this:

href=">?php echo get_admin_url(); ?>/media-upload...

The get_admin_url() function is new in wordpress 3.0 and solves this common problem cleanly.

Second: None of the thumbnailed images worked. Clicking the little broken boxes took me to their own full size page (should really be a lightbox, but oh well) where the image worked, so the images were there, the thumbnails were just broken. Turns out the theme uses a library called TimThumb to handle the thumbnailing and caching. After opening the path it was looking for (blah-blah-blah/thumb.php?src=path-to-real-image) it was throwing this error:

A TimThumb error has occured

The following error(s) occured:
Could note create the index.html file.
Could note create cache clean timestamp file.

The reason for this, although you couldn’t tell from the incorrectly spelled errors, is that the cache directory inside the THEME folder needs to have write permissions. Try this:

cd your/wordpress/path/wp-content/themes/Faded
chmod 774 cache -R

You’ll also need to make sure your webserver is in the group that owns the folder — just match it to the rest of the permissions in your install.