Following the advice of Kevin Ballard on StackOverflow, I created IGIsolatedCookieWebView, a subclass of WebView that does not access or affect the system-wide shared cookie storage (shared among all WebKit apps). Each instance of IGIsolatedCookieWebView has its own cookie storage so that, for example, multiple instances of IGIsolatedCookieWebView within the same application can be logged in to the same web site with different credentials. IGIsolatedCookieWebView should be usable in place of WebView, except that IGIsolatedCookieWebView uses the resource load delegate, so that can’t be used by the application. IGIsolatedCookieWebView is published under a 3-clause BSD license.
¶
Posted 11 March 2010
† 2718.us §
Mac OS X § Programming
‡
°
Tagged: bsd, cocoa, cookie, cookies, IGIsolatedCookieWebView, isolated cookies, mac, mac os x, os x, stackoverflow, subclass, webkit, WebView
IGResizableComboBox is a drag-resizable subclass of NSComboBox—that is, IGResizableComboBox should be usable in place of NSComboBox and it adds a small bar at the bottom of the pop-up list that can be dragged to resize the pop-up list. IGResizableComboBox is published under a 3-clause BSD license.
It still has some quirks:
- behavior is strange when the pop-up is above the combo box (whereas it is usually below)
the formula for resetting the number of visible items after dragging occurs is not quite right [fixed; dragging now snaps to whole-item positions]
¶
Posted 10 March 2010
† 2718.us §
Mac OS X § Programming
‡
°
Tagged: bsd, cocoa, combo box, combobox, drag, drag-resizable, IGResizableComboBox, mac, mac os x, nscombobox, os x, resizable, resizable combo box, resizable combobox, subclass
Yesterday, I posted the results of my quick exploration of whether sorting the list {0,1,2,3,4} using a comparison function that randomly returns < or > (with equal probability). My exploration was prompted by a report on the non-uniformity of the distribution of the random orderings of the browsers in Microsoft’s EU browser ballot. I had said that it seemed likely that the distribution would vary based on the sorting algorithm used.
Today, I have data (and code) that confirms the distribution is sorting-algorithm-dependent. For each sorting algorithm, 1,000,000 instances of the list {0,1,2,3,4} were sorted with a random comparison function and the relative frequencies (rounded to the nearest whole percent) of each number in each position were computed. Continue Reading »
¶
Posted 24 February 2010
† 2718.us §
General
‡
°
Tagged: algorithms, browser, browser ballot, bubblesort, eu, european union, math, mathematica, mathematics, mergesort, microsoft, nb, quicksort, selectionsort, sort, sorting, sorting algorithms, statistics
An Ars Technica “etc” post linked to a TechCrunch article (apparently based on a Slovakian article, but I didn’t look into the Slovakian article to be sure) that talks about the ordering of the browsers in Microsoft’s EU Browser Ballot not being uniformly distributed. At a glance at the Javascript that does the randomizing of the browsers (randomly orders the top 5, and randomly orders the rest), it appears to randomize by calling the Javascript array sort with a comparison function that returns < half the time and > the other half of the time. I believe that this is likely the underlying cause of the non-uniformity of the orderings.
The second result in a google search for “javascript sort” says:
To randomize the order of the elements within an array, what we need is the body of our sortfunction to return a number that is randomly <0, 0, or >0, irrespective to the relationship between “a” and “b”. The below will do the trick:
//Randomize the order of the array:
var myarray=[25, 8, "George", "John"]
myarray.sort(function() {return 0.5 - Math.random()}) //Array elements now scrambled
This is almost exactly the method of randomization used in the browser ballot javascript.
To test the results of this randomization technique, I applied it 1,000,000 times to the list {0,1,2,3,4} in Mathematica and tabulated the relative frequencies of each number in each position. (Rounded to the nearest whole %).
| position/number |
0 |
1 |
2 |
3 |
4 |
| first |
18% |
12% |
12% |
12% |
47% |
| second |
18% |
24% |
18% |
18% |
24% |
| third |
20% |
21% |
27% |
20% |
12% |
| fourth |
22% |
22% |
22% |
28% |
6% |
| fifth |
22% |
22% |
22% |
22% |
12% |
At a glance, it appears that the distribution is far from uniform. My quick attempt at re-learning how to use the Χ2 test gave a probability less than 1×10-100000 that this data matched a uniform distribution (if someone can confirm/fix that, please comment).
I used the Mathematica Sort[] command to do the sorting. I don’t know what algorithm that uses. It appears that the algorithm used by Javascript’s sort() varies from browser to browser, though the browser ballot would be displayed in IE8 by default. I suspect that the distribution is highly dependent on the sorting algorithm used, though I cannot readily verify it [edit: I verified it]. Regardless, this seems to be a very poor way to generate a random ordering.
¶
Posted 23 February 2010
† 2718.us §
General
‡
°
Tagged: browser, browser ballot, eu, european union, ie8, internet explorer, javascript, math, mathematica, mathematics, microsoft, statistics
I haven’t tested it myself, but an “etc” posting on Ars Technica says:
Want to get someone off IE6? Put these 11 characters into the address bar and hit enter: ms-its:%F0:. The browser will instantly crash. Better yet, set it as their homepage.
On the first day the Magic Mouse was available—well, not so much available as it was shipping with new iMacs, so available to play with in the Apple Store—I went to try it out. While I didn’t think it was the best thing since sliced bread (or any other such amazing invention), I did think it was solid enough to be worth buying, especially since I’ve been having to unstick the scrollball on my bluetooth Mighty Mouse just about weekly of late. On about half a dozen occasions since then, I’ve been close enough to an Apple Store to wander in and see if they had any Magic Mice for sale, but had no luck until tonight.
The packaging is simple and elegant, a clear plastic shell, though it would have been more elegant without the huge white label added by the Apple Store along one long side, which covered the seam in the box and made it much harder to open than intended and left all sorts of sticky gunk behind. Batteries are included and pre-installed. Swapping it in for my bluetooth Mighty Mouse was as simple as turning it on, asking my Mac to set up a bluetooth device, clicking a few times, and turning off the old mouse. The Magic Mouse is lighter and flatter than the Mighty Mouse (though heavier than the USB version).
Left and right clicking (once enabled) work just like on the Mighty Mouse. Scrolling is nice and the momentum is a nice add-on. Forward/backward swipes for navigation work, though I find the gestures a bit awkward (I played with these in the store when I first laid hand on the mouse). I’d long ago disabled the side buttons on my Mighty Mouse, so I don’t miss those one bit. As for middle-clicking (clicking on top of the scrollball), had the Magic Mouse hit about 3 months earlier, I wouldn’t have cared at all, but somewhere in the past few months I’ve gotten in the habit of using the middle click to open links in new tabs and close tabs, both in Firefox and in Chrome, so I wasn’t looking forward to losing it. A quick search led me to this program (actually, this version, as the other one doesn’t seem to work as consistently) which works like a charm—once set up, physically click with 3 fingers on the surface to middle-click (the program defaults to a 3-finger tap, rather than physical click, and is supposed to work on multitouch trackpads as well).
So, my first-hour opinion: worth it to me, may or may not be worth it to you.
This information is provided as-is, with no warranty, etc., which is to say if you use this information at all, you do so at your own risk.
I’ve been using an Apple Mighty Mouse (bluetooth) for years now, so for years I’ve been dealing with a scrollball that occasionally gets stuck. As someone who used to use mice that relied on a physical ball for tracking, this is nothing new. The only real difference is that we can’t remove the scrollball to directly ungunk the mechanics. My personal preferred way to ungunk/unstick/clean the scrollball (and mind you, for all I know, this might destroy your mouse) is to turn the mouse off, take a q-tip, soak up some denatured ethyl alcohol, and rub it around the scrollball, rolling the ball in every possible direction to try to get as much of the alcohol down and around the ball as possible, hoping to loosen up any gunk in the works there and bring it up top where it can be wiped away. Typically, this unsticks the ball and brings some visible gunk and stuff to the topside. It also helps to press down on the ball while rolling it around to ensure that it is moving the mechanical bits with which it has contact. Let the mouse fully dry before turning it back on.
¶
Posted 01 December 2009
† 2718.us §
Mac OS X
‡
°
Tagged: alcohol, apple, apple mighty mouse, ball, degunk, denatured, denatured ethanol, denatured ethyl alcohol, ethanol, ethyl alcohol, gunk, mighty mouse, mouse, mouse ball, rubbing alcohol, scroll, scroll ball, unstick
… or “how to serve different image types at one URL.”
… or “why I let myself get carried away reading from one blog post to another.”
After discovering free and cheap SSL certificates, I was playing with some sites over HTTPS to see what different browsers would show for the security. Very quickly, I noticed that having any elements on the page that aren’t loaded over HTTPS causes the whole page to be marked as not secured. One element in particular on one page was this “valid” icon from w3.org. Note that the URL, http://www.w3.org/Icons/valid-xhtml10-blue, doesn’t have any file-type extension on it. Since w3.org doesn’t provide the icon over HTTPS (though they are fine with hotlinking the HTTP version), I needed to move it to my own server. I went to look for the image file and didn’t find a “valid-xhtml10-blue” file with no extension. What I found were several files with that base name and different extensions. I couldn’t find any information in the w3.org docs or in the source for the validator, which includes all the validation icons, as to how this was achieved. I googled to no avail.
Not long after that, I noticed an update for Bad Behavior was available and went to read the release notes. After reading the release notes, a post about the future major version of Bad Behavior caught my eye. In that post–no, actually in the comments on that post–there was a mention of getting rid of Apache for performance reasons. In reading that post, in the discussions of the pros and cons of nginx versus Apache, “content negotiation” was described, and suddenly I understood how to serve the multiple image file types at one type-extension-less URL, like w3.org did. A quick googling led me to MultiViews.
One line in an .htaccess file and it’s done:
Options +MultiViews
¶
Posted 04 November 2009
† 2718.us §
General
‡
°
Tagged: apache, content negotiation, extensions, file type extensions, file types, htaccess, image, image file types, image files, images, mod_negotiation, multiviews, w3, w3.org
StartCom is the certificate authority providing StartSSL certificates: unlimited 1-year domain-validated single-site SSL certificates for free (“Class 1″); unlimited 2-year domain-validated single-site, UCC, or wildcard certificates after paying $39.90 to further validate your account (“Class 2,” which necessitated photo IDs and a phone call, and is good for 1 year); 2-year EV certificates for $149.90 (I have no idea if this is a good price or not, as I have no use for an EV certificate right now). The “Class 1″ and “Class 2″ SSL certificates, both 1- and 2-year, both single-site and wildcard are chained certificates, requiring an intermediate certificate, but the underlying root certificate was included in FF3.5, Chrome, Safari4, and IE6 (these are the browsers to which I have easy access for testing). I wasn’t able to find a proper comprehensive list of who’s root certificates are included in which versions of what browsers (if anyone can point me to such a list, I’d be grateful).
$39.90 for unlimited 2-year wildcard certs is a whole heck of a lot cheaper than anything else I’ve seen. In fact, that’s not much off of what I’d been paying for 2 years of a single-site certificate, having done a lot of comparison-shopping. And it’s really hard to beat free for single-site certificates. It’s an easy replacement for self-signed certificates at the same price.
¶
Posted 03 November 2009
† 2718.us §
Web Programming
‡
°
Tagged: certificate, certificate authority, certificates, free, free ssl, ssl, ssl certificates, startcom, startssl, tls, ucc, wildcard, wildcard certificate
I suppose it’s a bit misleading to call the least bad something the “best.” This past weekend, I experience a harddrive failure–a 2-year-old WD RE2 0.5TB drive failed before its 5-year warranty was up and well before its MTBF (1.2 million hours = 136.895463 years). It’s been a while since I had a drive fail on me (excepting the hanging behavior of the 1.5TB Seagate drives, which isn’t really failure), but I’ve had plenty of drives fail over the course of 25 years of computing. With the luckier failures, I didn’t lose anything important.
What’s noteworthy about this failure, though, is that it’s the first time I’ve had a drive fail and lost absolutely nothing. The drive was half of a software RAID1 setup. OS X’s Disk Utility showed the drive with SMART status “failing” and showed the RAID as “degraded” but was still able to make a complete copy of the RAID to another drive. Even supposing the RAID hadn’t survived, all of my data except possibly the most recent hour is backed up to yet another drive via Time Machine.
I’m not going to claim the system is bulletproof (I’m sure it isn’t), but it is nice to see a redundancy/backup plan actually work when tested by the real world. I’m just waiting on a cross-shipped replacement from WD to rebuild the RAID.
Remember: it’s not if your harddrive fails, it’s when your harddrive fails. Drive failure is inevitable.
Edit: The replacement from WD was shipped next-day air, so I’ll have the new drive tomorrow. First business day to process the RMA, second business day to ship the replacement, and the replacement arrives on the third business day. Pretty fast.
¶
Posted 27 October 2009
† 2718.us §
Mac OS X
‡
°
Tagged: backup, disk, disk failure, disk utility, drive, failure, mac, mirror, os x, raid, raid 1, raid mirror, raid1, re, re2, redundant, smart, time machine, wd, wd re, wd re2