buzzy: Rigby from Regular Show sitting in front of a computer (Computer Rigby)
2016-01-16 06:50 am
Entry tags:

Moo XXV

The project of the day was making select/option/optgroup elements use jQuery UI's Selectmenu. This was a lot harder than I expected, mainly for cosmetic reasons. First, the drop down indicator (usually a downward pointing triangle) was too high and to the left, so it was overlapping text. The text also appeared to be much larger than the text in the original select element, so the jQuery UI version would always underestimate the required width. After a lot of restyling, I had a basic, working select element, but I didn't want it to be merely basic; if I did, I would've stuck with the regular one. Before Firefox moved to GTK3 on Linux, option elements could be styled. In several places, I use color as an additional indicator, for example, there's a status indicator that can be either green or yellow. (There used to be a red, but that was removed. There's a text equivalent for those who are color-blind, but for those who aren't, it may be easier to just pick the color.) There's also a theme selector that shows the dominant colors of each theme. None of that is visible in Firefox on Linux. At first, I repurposed some of the demo source code, but I found that didn't work correctly, so I wrote my own. To allow the style, class, and title attributes of the option elements to become part of the li elements that make up the Selectmenu, I customized the _renderItem extension point. To allow the drop down to fade in, I hooked the _resizeMenu extension point, since that's the closest extension point to where it starts showing the drop down. (I couldn't get it to fade out when closed and the slide down effect doesn't work very well if there are a lot of items.) The code uses a regular event to make sure the currently selected item is visible when the menu drops down and uses a loop to make sure that each select element's title becomes a part of the new Selectmenu. Here's the code I wrote, which can be dropped into any JavaScript file assuming you've already loaded jQuery and jQuery UI. It only runs if a drop-down SELECT is on the page. I added lots of comments for its display here so you can see what I did and why; the version I'm running doesn't have any comments. If this code helps you, let me know; this site has an internal messaging system. With this code done, it's time to tweak my CSS.
Cut because it's kind of long )
buzzy: Rigby from Regular Show sitting in front of a computer (Computer Rigby)
2014-04-27 12:59 am
Entry tags:

Moo IL (or another Linux stream-of-consciousness entry)

This is long because I just wrote what I thought without really trying to organize it )
So the obvious benefits from all this work: faster startup (at least 21.9% faster) and less RAM usage (about 18.3% less). Most of the hardware support in the stock kernel consisted of modules, and I compiled everything in, but my custom kernel image is only 11.5 KiB larger while reducing the modules folder from 38.9 MiB to 12.5 KiB of just configuration files. (I would've skipped module support entirely if it didn't mean I'd lose my customized boot screen and initrd support.) A less obvious benefit comes from manually configuring the horizontal and vertical screen resolution in the Input Device Support area of the kernel configuration. Because a maximized VirtualBox window is kind of a weird size (1366x672), I can actually specify that weird size and have the mouse work better. Previously, the mouse would jump around the screen if I got too close to the edges of the window. That could just be a coincidence though. If you contact me not too long after this is posted, I could send you my .config file. I would've put it in this entry, but that file is huge. I may try this with a non-virtual machine in the future. After all, I still have the kernel source on a server on my local network.
buzzy: Steven Universe from the show of the same name looking a bit uncomfortable (Steven Universe 2)
2014-04-23 12:00 am
Entry tags:

Moo XLV

So, nothing really happened for me to post about, but since I feel the need to post something every day, here I am. I went back to LJ and my friends page is kinda...empty. (Excepting [livejournal.com profile] brightheartcbc, who was actually the reason I went in the first place.) I need to find new friends, though something tells me I won't find people I have a lot in common with on LJ. There's probably a higher chance of finding friends on Dreamwidth, but even then, I'm not the type to randomly show up on someone's journal and ask, "Can we be friends?" I think just about everyone I know has abandoned LJ, and while I can't blame them, I kinda wish I knew where they all went.
buzzy: Steven Universe from the show of the same name with a rather neutral facial expression (Steven Universe 1)
2014-02-22 12:00 am
Entry tags:

Moo XXIII (or the Firefox Australis edition)

Cut for a picture )
I mentioned in yesterday's entry how I used an old version of Firefox and it looked exactly like the latest one. That looks like it'll change at some point. We're on Firefox 27.0.1, and a new interface could be included as soon as Firefox 29 (April 29, 2014 release). It's supposed to be touch-friendly, which generally means everything is gigantic, even if you have no touch interface. (See Windows 8/8.1 without a touch screen) I just think it's amusing that they're bringing out a new touch interface when touch events on websites don't work and it doesn't look like it's getting any closer to being fixed. The new interface breaks some add-ons (because they got rid of the add-on bar), so it wouldn't surprise me if certain add-ons I use now will be unusable in the future. (That happened before when they switched to their increment-major-version-number-every-six-weeks development cycle. I had an "browser odometer" add-on that showed how many pages were loaded.) In addition, some buttons that were moveable (like forward and back buttons) are now locked in place. There's a weird menu button that brings up a popover that reminds me of something you'd see on iOS Safari. Of course, things can change between now and when it's released. After reading all about it, I wanted to try it for myself. It's available in Aurora (two versions ahead, so it's kinda like the alpha version), so that's what I got. It installs to a separate spot, so you can keep your regular Firefox. I made sure to create a separate profile to do all the testing because I don't want to mess up my regular Firefox profile.
First impressions, critiques, etc. ) Bottom line: It's not as bad as I thought it would be, but it definitely changes how I do things. A lot of people will also have to relearn when the orange/purple Firefox button disappears from the upper left corner and is replaced with the three-gray-horizontal-lines button on the right side and not quite at the top. It reminds me of Chrome.
buzzy: Rigby from Regular Show sitting in front of a computer (Computer Rigby)
2014-02-16 12:00 am
Entry tags:

My Semagic Template thingy (or Moo XVII)

In yesterday's entry, I mentioned that I had edited Semagic's template file. It's the file called "sem_prev_u1.html" in your Semagic folder. I'm going to talk about the reasons things are the way they are and some of the quirks. When I first started editing it, I wanted the background to be darker, so I made it white on black. I usually make the background color of the areas with images and captions black, so those blended into the background. That's when I decided on gray for the background for just the area with the entry text. I also reduced the margins so there's less empty space around the edges. There's already plenty of empty space around the edges because the web browser ActiveX control Semagic uses is not at the edges of the window. Another thing I aimed for was HTML5/CSS3 compliance. I ran it through the W3C Validators for HTML5 and CSS just to be sure. After I got everything pretty enough, it was time to deal with some of the inconsistencies. The mood and music are prefaced with "current mood" and "current music", but the tags and location are prefaced by "Tags" and "Location". I prefer the latter. When the security is set to "Friends" it just says "friends". When it's set to private, then it says "Security: private". When it's set to public, it says nothing. I don't know what it says for the custom security level, since that doesn't work with Dreamwidth. Semagic adds line breaks after the mood and music, but adds them before the tags and location. This causes a blank line between the mood/music (when they're displayed) and the tags/location (when they're displayed). I took care of these inconsistencies by adding some scripting that makes things a bit more consistent. I usually don't use <B> tags, but since those are actually put into the template by Semagic itself, I left them there. Also, %%journalname%% is always blank for me, so I commented it out. Now that you know the background, I can show you the code. If you want this, back up your old version and put this into the sem_prev_u1.html file. I think you can just triple-click in the box to get the whole thing selected:
 
The code and a preview of what it looks like are behind this cut or it would take up too much space. )
buzzy: Rigby from Regular Show with arms crossed looking unimpressed. (Rigby 2)
2014-02-14 12:00 am
Entry tags:

My ObamaCare nightmare (or, Moo XV)

On Wednesday, I did my 2013 taxes. I filed them and paid them. I generally get some panic attack symptoms when I do my taxes. Once it's submitted, those symptoms usually go away. It didn't this time, and that's why I'm writing this. The writing seems to help. The taxes themselves went smoothly and I only had to pay a relatively small amount (6% of what I made) since I'm so far below the poverty line. Yay for the EIC for making it slightly less awful. I make so little, I don't actually pay any income tax...only self-employment tax. It's the portion of taxes paid by the business if you're lucky enough to be employed.
There's a scene in an episode of Star Trek: The Next Generation where Captain Picard is trying to convince Geordi to bring not-up-to-date Scotty on an away mission. In it, Picard talks about how Scotty just wants to feel useful. Geordi brings Scotty along and together, they save the day. I just want to feel useful, so I try to work any way I can. Unfortunately, by working, I'm the one whose day will need saving. Follow me under the cut to find out why. This is long, but at least there's pictures. I tried to organize my thoughts into sections, but it's not like I wrote an outline before writing a journal entry. )
The TL,DR version: I don't make enough money to buy insurance on my own and I don't make enough to qualify for any help, but I still might have to pay the tax penalty for not having insurance. The penalty incentivizes not working and makes it more expensive to get employment from April to December than January to March for the long-term unemployed. Also, I can't remember if I ever wrote an entry that had more than 3000 words...
buzzy: Rigby from Regular Show sitting in front of a computer (Computer Rigby)
2014-01-20 12:00 am
Entry tags:

Moo XXXV (or I had no idea I could write so much about renaming files in Windows Explorer)

I have a lot of pictures I name with sequential numbers. The names are usually along the lines of "X - Y #" where X is a very short description giving me a hint of the source (usually no more than two words and usually abbreviated) and Y is a description of the content. The # is a number so I can have the same source and description for several pictures that are similar. Sometimes they're further grouped by having the number preceded by a letter (e.g., A1, A2, A3, B1, B2, C1, C2, C3, C4, etc.) if there's a lot of similarly named files. (The pictures are in folders based on some general categories, but that's not important for where I'm going with this.) Sometimes I have a lot of pictures with weird random letter/number combinations and I want to name them to my more descriptive naming scheme. I rename them in Windows Explorer, since that allows me to see the image I'm renaming. If the images I'm renaming are at the bottom of the window, but their new names put them at the top of the window, I end up losing track of what number I'm on. It's always annoying to be offered the suggestion of a file name like "X - Y 4 (2).jpg" when a suggestion of "X - Y 5.jpg" would be more useful. If you don't accept rather useless suggestion, it will put it back to the old file name and not give you a chance to correct it short of typing the name all over again. I doubt anybody at Microsoft would read this, but my suggestion would be to make it do what I suggested if the file already ends with a number. It does this already if the file name ends in a number in parentheses, but that makes the file name two characters longer and it kind of looks ugly. It reminds me of those people who have a folder called "New Folder (23)" on their desktop. And it's empty. So are all the others. That may be a bit much to ask, but I hope my other more realistic suggestion isn't too much: If you don't accept the file name suggestion, just go back to the text box with the incorrect file name so it can be corrected, possibly by changing just one character. If you don't want to rename it any more at that point, you can hit the escape key. That's a lot better than having to retype the entire thing.
buzzy: Rigby from Regular Show sitting in front of a computer (Computer Rigby)
2014-01-14 12:00 am
Entry tags:

Moo XXIX

On Sunday, my computer kept informing me about updates to install on the login screen, but when I open Windows Update, there aren't any. If I manually checked for updates, one update for Windows Defender appeared, but it's already been installed, so trying to install it causes it to fail. (The error I got in the event log was 0x80070643, but Windows Update reported either 80096010 or 8050800C.) Even though Windows Defender is up to date, it still won't stop offering the definition update that's already installed. I wanted to get everything fixed before Patch Tuesday, which is...today. Luckily, I got everything solved on the same day. Everybody's got a different solution to the problem, but here's what I tried: The first thing I tried was to restart the computer. "Turn it off and back on again" is one of the most basic troubleshooting techniques. I guess it was too basic because it didn't work. Next, I tried just downloading the full-blown definitions manually and installing them that way. The definitions were already up to date, but maybe this would make Windows Update see the change. Running the file did nothing, assumedly because it was the same version. When I ran Windows Update, the same update appeared and failed to install. I tried the Network Inspection System update at the bottom of the same page. That didn't appear to do anything either. I checked for updates again and it didn't show the update anymore. That's what worked for me, but I assume those errors could appear for any number of reasons. Of course, when the Patch Tuesday updates show up on my computer, I hope that they install normally. If I write another one of these entries, then it didn't.
buzzy: Rigby from Regular Show sitting in front of a computer (Computer Rigby)
2013-12-22 12:00 am

Moo VI

From the Department of I Need an Appropriate Userpic: After generally figuring that this Christmas would be one without presents, I decided to treat myself. All I had to work with was the whopping $25 my grandma gave (it's something), so I had to dig deep in order to get myself anything. That actually wasn't even the plan originally. I went through the blogs I sometimes read and noticed that there are shirts for Steven Universe, so I figured they'd cut off at 2XL, which is what shirts I want usually cut off at when they actually make them in men's sizes. To my surprise, they went up to 3XL on some of the styles, which will fit me just fine. (The star shirt Steven wears in the show only went up to 2XL; I really wanted that one.) They also had a 10% off sale (it's something) that I somehow missed by a day. I got two Steven Universe shirts and a Regular Show shirt, since they were in my size. Also, I wanted to get enough stuff so I'd get the price of overnight shipping dropped to $5. I still doubt I'll get it in time for Christmas, but at least I'll get it at some point. I'll just have to take my traditional "stuff I got for Christmas" picture whenever it shows up. As a Big Dude™, it'll be nice to juxtapose cute Steven with...not so cure me. :P
buzzy: Rigby from Regular Show sitting in front of a computer (Computer Rigby)
2013-10-31 12:00 am
Entry tags:

Moo XVII

Some weird Windows 8.1 troubles I noticed after typing up yesterday's entry:
  • The audio suddenly started sounding tinny and generally unlistenable. When I had this problem before, it would go away if I restarted the computer, but that didn't seem to help anymore. Installing an older version of my audio drivers made everything sound normal again. At least going to grab the older drivers made me discover there was a BIOS update for my computer.
  • The weather app keeps changing to Washington, D.C., and changes the units from Celsius to Fahrenheit, but only on the Start screen. At least when it does display what I want, it looks pretty good in the largest size. I only made the weather larger on the Start screen because I can make the other icons smaller.
  • Windows Update had been downloading something via BITS, but I don't know what it is. It's not Windows Defender downloading, and Windows Update says there are no updates. It spent the morning downloading really slowly and I just wished it would finish. Even after it finished, I have no idea what it was.
  • My HomeGroup was wiped out. I used it to give my brother access to an area on my computer without giving him a login. I'll have to set it up all over again whenever we're on the same network.
  • I used to have no problems with the preview that would show up in Windows Explorer for graphic files. After the upgrade, some JPEG files look like they're missing chunks (though when viewed with another program, they're fine; in Explorer, they show up with large areas of grey) and others (JPEGs included) don't show a preview at all, but if you select another file, then select the original file again, the preview will appear.
  • I'm still having issues with Desktop Window Manager (DWM). On Windows 8, it would slowly suck up memory until you had to log out or reboot. It's been eleven hours since my last reboot and it's using almost four times the RAM it used at startup. I can't narrow its bad behavior to a program since I don't monitor it that closely, but I do know it makes random jumps. Sometimes it'll rise by several hundred megs of RAM in a day. Since I don't know what DWM does that could use close to two gigs of memory, I can't rule out anything. The last time I hunted for answers on the Internet, it didn't seem like anyone had the same problem I do.
buzzy: Rigby from Regular Show sitting in front of a computer (Computer Rigby)
2013-10-30 12:00 am
Entry tags:

Moo XVI (or the Windows 8.1 entry)

In my last entry, I ended mentioning that I was backing up in case the Windows 8.1 installation totally screwed up my computer. The installation went fine, but it's always good to have backups. It didn't take that long for me to back things up anyway, since I back things up every couple weeks. With that out of the way, I guess I'll talk about my first impressions.

Yesterday, I got a banner that appeared across my screen inviting me to open the Store app and install Windows 8.1. It's weird that it doesn't come down through Windows Update, when it's basically Windows 8 SP1. It provided a scarily large download size, but based on how long it took to download it, they were either providing the worst-case scenario download size or the uncompressed size. Anyway, I took a nap while it downloaded and messed around on another computer. The download also randomly stopped for several minutes, then started again. I couldn't figure out any sort of pattern; all I wanted was it to finish so I could use my Internet connection again. Eventually, it finished and restarted...and restarted...and restarted. When I finally had a chance to interact with my computer again, it started asking very installing-an-OS kinds of questions. Then I hit the "Sign in to your Microsoft account" step. I purposely didn't want to do that when installing Windows 8, but with this upgrade, it did not [visibly] give me any kind of choice not to. The only choices were to sign in, create a new account, or view the privacy statement. I hopped on the other computer I had nearby to look up if there was a way past this. Basically, you just click the option to create a new account, then there's an option at the bottom to keep signing in the way you always have, i.e., locally. This works the same way for a fresh install; click to create a new account, and click the option to sign in without a Microsoft account. (This site was the first one that showed up when I did a search, so it's their advice I took. The site also has how to remove a Microsoft account if you didn't want one in the first place.)

First impressions and junk )

buzzy: Fred Fredburger thinking (Fred Fredburger 4)
2013-10-25 12:00 am
Entry tags:

Moo XI

  • I was on the Wacom site getting the drivers for my old tablet. (They still make the drivers for my old tablet. Wow. I thought for sure they'd stop a few years ago.) Anyway, they have a definition on their driver page saying that drivers are a "small computer program that allows your computer to interact with" their products, and that definition is correct. The only thing is the drivers are about 38 MB when compressed. That's not exactly my definition of "small computer program". They probably look at male horses and say, "yep, that's small." The program I'm typing this entry in, Semagic, is smaller than 38 MB when it's installed. Firefox is a smaller download. Their drivers also feature a license agreement in a [genuinely] small window that can't be resized. It's not as bad as those Microsoft license agreements that show up in a window so small that you can only see three lines at a time. They also tell you that you can't use their products for "high risk activities," whatever that means. Maybe it's like how Apple says you can't use iTunes and your iPod to design a nuclear reactor.
  • I figured I'd start trying to draw again. (Why else would I set up my tablet again?) I have a tablet that I'm using in lieu of having cruddy sketches all over the place. (I know, "that's the spirit!") The only advice that has stuck is "practice, practice, practice" though I have no idea if I'm practicing correctly.
buzzy: Rigby from Regular Show sitting in front of a computer (Computer Rigby)
2013-10-15 12:00 am
Entry tags:

Moo I (or, problems with Apache 2.4, PHP, and Internet Explorer)

Ever since PHP stopped working with the official builds of Apache, I had to use an unofficial build. Since then, I've had problems, though I can't figure out whether they're the fault of the unofficial build or PHP. The big problem is that Internet Explorer seems to cause Apache to stop responding to requests after a while. It'll work without problems if requests come from any other browser. I know that lighttpd works just fine on my Linux machine with PHP (FastCGI), so I tried looking at that for my Windows development machine. Unfortunately, the only way I could get it to work properly was with CGI, which is kind of slow compared to the always-running Apache module. That pretty much wipes out the benefit of switching to a light web server like lighttpd. While looking at the PHP documentation (some of which is pretty dated), I found that Apache can run PHP using FastCGI. I figured I'd give it a try. Using the comments and my knowledge of the changes to the Apache configuration file format for Apache 2.4, I set Apache to use FastCGI instead of the PHP Apache 2.4 module by using mod_fcgid. The appropriate changes look something like this:
<Directory "C:/PROGRA~2/PHP/">
    AllowOverride None
    Options None
    Require all granted
</Directory>

FcgidInitialEnv PHPRC "C:/PROGRA~2/PHP" # Tell PHP where php.ini is
AddHandler fcgid-script .php
FcgidWrapper "C:/PROGRA~2/PHP/php-cgi.exe" .php # Can't have spaces in the path
Notice the "PROGRA~2" path. The FastCGI module doesn't like spaces in paths. Also, the PHP path needs to have some permissive access or it won't bother loading PHP. The document root needs to have "ExecCGI" in the "Options" directive or PHP scripts will return a 403 error. Once I got that squared away, I loaded a page with phpinfo();. "CGI/FastCGI" showed up in the Server API and php-cgi.exe showed up in my running processes. I ran some other more complex scripts and those ran just fine.
buzzy: Rigby from Regular Show sitting in front of a computer (Computer Rigby)
2013-08-16 12:00 am
Entry tags:

Moo XLII (or, the JavaScript image pre-loading code entry)

At some point, my code for preloading images stopped working properly on Firefox. I'm thinking it happened around version 21-22, but I'm not totally sure. When trying to look for the "proper" way to do it, all I could find were articles from 1999-2000 talking about Netscape, how Internet Explorer stores its cache in the WINDOWS folder, how many people use dial-up, and how we should stock up on food for the Y2K crisis ahead. I ended up taking an idea from the jQuery documentation and wrote this function:
function preloadGraphics(files) {
    var count = files.length, i;
    $("#hiddenblock").html("");
    for (i = 0; i < count; i += 1) {
        $("#hiddenblock").append( $("<img src=\"" + files[i][0] + "\" alt=\"\" style=\"width:" + files[i][1] + "px;height:" + files[i][2] + "px;\" />") );
    }
}
For those not using jQuery, here's a non-jQuery version, which I tested once and it seemed to work:
function preloadGraphics(files) {
    var count = files.length, i, element;
    document.getElementById("hiddenblock").innerHTML = "";
    for (i = 0; i < count; i += 1) {
        element = new Image(files[i][1], files[i][2]);
        element.src = files[i][0];
        element.alt = "";
        document.getElementById("hiddenblock").appendChild(element);
    }
}
The function uses a hidden DIV with an ID of "hiddenblock" to put the newly created IMG elements. Any future runs of the function clears out the previous images and puts the new ones inside so that element doesn't get too large. (I have a page that constantly preloads new graphics, so if you walk away, you could come back and find your browser ran out of memory.) Anyway, the function takes a two-dimensional array consisting of files, widths, and heights, like this:
preloadGraphics( [ [ "file1.png", 65, 65 ], [ "file2.png", 120, 120 ], [ "file3.png", 80, 80 ] ] );
I'll put this out there so people can have some workable code tested on more recent browsers than Netscape or IE 5.
buzzy: Rigby from Regular Show sitting in front of a computer (Computer Rigby)
2013-07-28 02:57 am
Entry tags:

Moo XXIII or The Age-Old Question of Getting a Random ID/row in MySQL/MariaDB

A good chunk of yesterday was trying to come up with some MySQL/MariaDB code that could generate a random row for me. Doing the simplest thing (something like SELECT ID FROM tablename ORDER BY RAND() LIMIT 1) is slow. This huge thing worked, but you can't run a sequence of commands the same way you run prepared [single] statements:

SET @r := (RAND()*(SELECT MAX(ID) FROM tablename));
SET @sql := CONCAT('SELECT ID FROM tablename WHERE ID>=',@r,' ORDER BY ID ASC LIMIT 1');
PREPARE stmt1 FROM @sql;
EXECUTE stmt1;
Every attempt to condense that into one single query with a subquery always gave my an ID number below would only return ID numbers lower than about 310. It's like the statement "(RAND()*(SELECT MAX(ID) FROM tablename))" gives different results when it's run separately versus running it in another statement, like SELECT ID FROM tablename WHERE ID>=(RAND()*(SELECT MAX(ID) FROM tablename)) ORDER BY ID ASC LIMIT 1. Enter mysqli_multi_query. Apologies for any bad formatting, this was whipped up quickly just to see if it worked:
$query = 'SET @r := (' . (mt_rand(0, mt_getrandmax()) / mt_getrandmax()) . '*(SELECT MAX(ID) FROM tablename));' . PHP_EOL . 'SET @sql := CONCAT(\'SELECT ID,\',@r, \' FROM tablename WHERE ID>=\',@r,\' ORDER BY ID ASC LIMIT 1\');' . PHP_EOL . 'PREPARE stmt1 FROM @sql;' . PHP_EOL . 'EXECUTE stmt1;';
if ($mysqli->multi_query($query)) {
while ($mysqli->more_results() && $mysqli->next_result()); // jump to last one
    if ($result = $mysqli->store_result()) {
        while ($row = $result->fetch_row()) $theID = $row[0];
    }
    $result->free();
}
(The code assumes you opened a link to the database as $mysqli.) Note that I used mt_rand instead of the MySQL/MariaDB RAND() because the latter produces too many repeats. I made a test to benchmark and test the randomness the code I posted above and I think the results are satisfactorily random (this is 1000 runs on a database with 5522 rows with IDs ranging from 2 to 6155):
1 results repeated 5 times
1 results repeated 19 times
2 results repeated 4 times
4 results repeated 3 times
76 results repeated 2 times
Highest ID: 6148
Lowest ID: 22
Max Time to Execute (returning only an ID): 0.0022029876708984
Min Time to Execute (returning only an ID): 0.0006871223449707
Average Time to Execute (returning only an ID): 0.00086945366859436
Max Time to Execute (returning all 45 columns): 0.0029420852661133
Min Time to Execute (returning all 45 columns): 0.00085997581481934
Average Time to Execute (returning all 45 columns): 0.001065233707428
First Repeat at Iteration #61
I'm assuming that one that comes up a lot appears because there's a giant hole between IDs 5624 and 5808, and this code just seems to like picking a number between those. If any holes in your table's IDS are fairly evenly distributed, they won't repeat that many times. If you have no holes at all and you can plan on it, something simpler may be in order. Even with the repeating numbers, I don't expect someone to click the link for a random result 61 times either. As for the time to execute, the ORDER BY RAND() LIMIT 1 code took about 0.25 seconds to run, so I'd say the figures here are an improvement. (Don't laugh at my 45 column table; I'm just working with a database someone else designed that I can't change.) Hopefully this is useful to someone.

buzzy: Chowder obviously doesn't care for what he just ate (Disgusting!)
2013-07-10 12:00 am
Entry tags:

Moo V (DynDNS/Dyn finds a way to shaft people that finally includes me)

Alternate title: First they came for the people with more than one subdomain...

For I don't know how long, I've been using Dyn (it was DynDNS back in the day) for Dynamic DNS service. At its peak, I used three of the five available subdomains with the free service. They slowly scaled back the subdomains to one and removed the wildcards, but it still did the job. All I needed was an easy to remember address to point to my IP so my brother can access my development server. Back in 2010, they added some kind of requirement that your account has to be messed with in some way once every 30 days. (This was fine for me because my router automatically updates the IP, even if changes aren't needed, once every ten days.) In May, they dropped free accounts entirely, but the existing ones could stay. This month, they shrunk that 30 day requirement: Updating the IP does not count...only website logins count. If you forget to log in, your account is wiped out and the information purged. I found out about this change via an e-mail they sent which is hawking the Pro account, basically requiring a payment for what used to be free. It was previously free and good enough, so lots of routers have support for them and only them. Now that free accounts can't be made and the existing free accounts require manual intervention to maintain (every login drops you to an ad for the paid service), I can't guarantee that my brother will be able to access my server at any given time. Because of that, I moved to freedns.afraid.org, which is a lot like what DynDNS used to be: free with five subdomains. I'm also lucky that it is supported by my router, though I have no idea if it's supported by my new modem/router combo that is waiting for a new ISP. I might have to find some old computer to run a client, which would be a huge waste of electricity.

I know there are people who think that since it's a free service, no one has any right to be angry when it's screwed with. But it's been screwed with in such a slimy way in order to take a once good service and make it unusable. Look at this disingenuous sentence from the e-mail they sent: "We understand that the possibility of resulting service interruptions may be frustrating, so we are offering an upgrade offer to VIP status (Dyn Pro) for just $10 USD for the first year." They understand that service interruptions are frustrating, which is why they put them into effect in the first place! (Also, full price, which it would assumedly go up to after the first year is up is about the same price I pay for my web host and e-mail service. Why would I want to pay as much for a subdomain for a site accessed by one person as I do for web space, bandwidth, and e-mail?) They want to drive people to their paid offerings; I hope everyone leaves. And when those former members want a paid offering, I hope they pay someone else. I felt bad for closing an account I had open for so many years, but they've started down a road and it looks like they're planning to remove all free service by attrition. As a free user, my only protest options are writing a blog entry I don't think anyone will see and closing my account. I doubt I'll get a PR visit like the writer of the 2010 entry I linked to earlier.

buzzy: Rigby from Regular Show sitting in front of a computer (Computer Rigby)
2013-06-05 12:00 am
Entry tags:

Moo II (or the Arch Linux entry)

With Ubuntu giving me trouble because I prefer MariaDB over MySQL, I decided to look for a Linux distro that wouldn't give me issues. One mentioned on the MariaDB website was Arch Linux. Wikipedia's description of it as focusing on "simplicity from a developer's standpoint rather than a user's standpoint" made it sound like it was going to be a major pain to get up and running. Arch Linux's wiki made it almost seem like it was a Linux version of what I expect to get out of a FreeBSD system: a basic system that allows you to tack on only the bits you want. I read the Beginner's Guide before actually attempting the install, then attempted it on a VirtualBox machine. It was as smooth as a manual install could get. Basically, those directions are written so well, you have to be trying to screw up to fail. (Either that, or you have a special situation they didn't think of.) It wasn't long before I had a working server running lighttpd with PHP and MariaDB. Basically, everything installed so quickly, most of my wait time was the time to download everything.
The hope with this setup is that I'll be able to quickly test my PHP code on both Windows and Linux. Currently, I have to copy the code over to my Linux machine and all the data files, which could take several minutes. Since a connection from a virtual machine on my computer to my computer should be very fast, I could just use Samba on my Arch VM for access to the files. I set up the virtual machine with one NAT network connection for Internet and a separate host-only network connection for a 1 Gbps link to the database and files. (When I did this on my Windows XP virtual machine, it couldn't figure out how to get to the Internet, but it would appear Arch's network stack is smarter.) Samba doesn't seem to like mounting subfolders of shares, so I had to make one share for every subfolder I wanted to mount. That worked out to five shares instead of two. The first time I tried running lighttpd off of the shares, it worked fine, except a lot of graphics didn't load. This was solved by enabling the iconv extension, which I didn't realize was disabled. (The reason iconv is needed for generating graphics is because the database produces Unicode file names and I have to make them very basic ASCII or I won't be able to read files when the code is run on Windows.) The next time I started the virtual machine, all sorts of weirdness happened. The DHCP on the host-only connection didn't run, though the Samba shares were mounted. Even though they were mounted according to the output from mount, I couldn't access them. Actually, just cding into one of the mounts locked up the VM. I eventually got it working by turning off the DHCP on that connection and setting a static address. After that, it was fine, though there were issues with write permissions on the shares. That was fixed by adding ,file_mode=0777,dir_mode=0777 to the options portion of each mount in the fstab file. I also needed to change the permissions on the parent directories and finally everything worked. I also couldn't automatically mount the shares without a very noticeable lag on startup (and only two of five shares actually being mounted), so I added ,noauto to each of the mounts in the fstab file and made a script that I would run upon logging in that mounted those shares. After that, everything worked as it should and I was ready to handle coding for both OSes. It wasn't ideal, but it works.
The whole thing about how much you have to do manually bit me when I decided to update the system one day. I checked the main Arch page and there was no recent news about potential updating problems (most recent was from April), so I updated...and got a mysterious error. Luckily the error didn't leave my system broken. I looked around for information about that error, but nothing came up. Eventually, I went back to the main Arch page and there was a news item that wasn't there before. Following those instructions fixed the error. Although I can keep this virtual machine running decently, I'm wondering how I'd be able to run this OS on a physical computer. I won't need to mount Samba shares, but I will be dealing with a wireless card requiring special firmware. Of course it would just be easier if Ubuntu and friends allowed MariaDB to be used...
buzzy: Rigby from Regular Show sitting in front of a computer (Computer Rigby)
2013-05-09 01:48 am
Entry tags:

Moo X

The only thing of note yesterday: I worked on a computer my dad brought home. It would get a blue screen of death (0x0000007F UNEXPECTED_KERNEL_MODE_TRAP) shortly after opening Google Earth. Every diagnostic I could run on the memory and graphics all passed. I did all the basic stuff, like updating the video drivers (they were already the latest version), updating DirectX, wiping out Google Earth and reinstalling it (it blue screened during the installation), but the problem still occurred. Even though the installer caused a blue screen, it had installed the program itself. I tried running it using OpenGL instead of DirectX, and it worked fine! I have no idea why DirectX would cause a blue screen, especially because this is a fresh Windows XP install. I was really worried it was a hardware problem. There still may be a hardware problem, but at least the software that's needed works. I guess I'll make this public so anyone with this problem can potentially find this entry.
buzzy: Rigby from Regular Show sitting in front of a computer (Computer Rigby)
2013-05-06 12:00 am
Entry tags:

Moo VII

A screenshot of the Firefox download panel on top, with a mock-up of the improvements described in this entry at the bottom.
How It Might Look
On top, the download panel as it looks now. On the bottom, a mock-up with some of changes based on my complaints: one-click options to delete a single download or all of them. (I know my anti-aliased text doesn't match, but I wasn't going to spend that long on a mock-up.)
Now that Firefox supports private and regular browsing in the same session, I've moved back to using Firefox as my main browser. Unfortunately, I have some issues, though they're minor:
  1. I don't care for the new download panel. Previously, there was a window that had a button that cleared download history. The panel has no such button. Instead, you have to either remember the keyboard shortcut to open the download section of the Library (Ctrl+J, memorable because there's a "J" in "Download") or click that down-pointing arrow and click "Show All Downloads". Often, it's just quicker to click the down-pointing arrow, right-clicking and removing individual downloads that way, as they finish. (I made a mock-up [the only picture on this entry] showing how the features I'd like to have might look in the download panel.) That leads me to the next point...
  2. The only way to not keep your download history is to not keep any history. Alternatively, you can set the browser to clear download history when you close the browser, except you would have to close the browser a lot.
  3. This one is the same complaint I had before switching away originally: RAM usage. Closing tabs does not improve the memory usage. The Chromium-based browser I used for private browsing had many processes, one for each tab, one for each extension, one parent process, processes for plug-ins, etc. Closing a tab that you did lots of browsing in would generally close a process, reclaiming memory. The good thing about that model is that you can reclaim memory, with the downside being it took fewer tabs to hit absurd levels of memory usage. Firefox is slower to get high in memory use, but once it gets there, it stays there.
  4. This may or may not be a Firefox complaint: The functionality included in the Firebug is not built-in. I'm assuming there's a good reason for that. Firebug itself makes things extremely slow whenever it's running, making even local pages take longer to load than remote pages...on a 56K. Also, it randomly opens up their website; it's great that they have a website, but that doesn't mean I want to look at it all the time.
  5. Personas don't show up in Private Browsing mode. Since that's where I spend most of my time, I don't see my persona most of the time. (Personas are those themes that are basically just graphic files for the top and bottom of the browser and some coloring information to keep the various buttons from disappearing on dark backgrounds.)
I guess since that's fairly negative, I'll mention some good things:
  1. It looks like Firefox on Windows is going to get H.264 video, and AAC (MP4/M4A) and MP3 audio support for the HTML5 video and audio tags. That feature drops in the next version to be released in just over a week. The caveat: it only works on Windows 7-8.
  2. Also coming out in the next version is the ability to have scoped stylesheets. Instead of having to put your stylesheets at the top of a document and have it apply to the entire document, you can put them in the middle and have it only apply to a small portion of the document.
  3. Something I missed while not using Firefox as my primary browser was the degree of customization available. There are tons of Personas. There are also tons of add-ons. The Chrome themes seemed to be limited to Angry Birds and My Little Pony. I also had a hard time installing extensions because they made the process so secure, no one can install anything. Firefox's extension install process is as fast as you can download (and sometimes restart).
Well, that's it for this entry...I'm off to bed.