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.My Semagic Template thingy (or Moo XVII)
Feb. 16th, 2014 12:00 amMy ObamaCare nightmare (or, Moo XV)
Feb. 14th, 2014 12:00 am- 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.
Moo XVI (or the Windows 8.1 entry)
Oct. 30th, 2013 12:00 amIn 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.)
- 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.
<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
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.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;\" />") );
}
}
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);
}
}
preloadGraphics( [ [ "file1.png", 65, 65 ], [ "file2.png", 120, 120 ], [ "file3.png", 80, 80 ] ] );
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 timesI'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
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
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.
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.
Moo II (or the Arch Linux entry)
Jun. 5th, 2013 12:00 ammount, 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.