Profile Photo

John Maguire

I am a web developer and hobbyist writer who spent too much of his youth in front of a screen. These days, I spend my time learning, tinkering, and writing code.

Is drawing straws fair?

I was watching This Is The End (2013) the other day, when there was a scene involving drawing straws to see who would have to run past demons from hell in order to get water for everyone else.

I began questioning whether drawing straws was a fair practice — assuming there are 1/5 players, the first player has a 1/5 chance of drawing the short straw. However, the last player has a 4/5 chance that the short straw will have been drawn by someone else before their turn even arrives.

Now, I’m not the best at probabilities, and while it probably should have been obvious that the game is fair, I had doubts. I decided to create a Python script to model the game. I couldn’t just randomly choose a loser every time, so I created a list of straws, with one short straw and the rest being normal sized, randomized it, and then iterated through players, having them draw a straw each time, and removing it from the list.

From running it, I’m not seeing any major differences. There is a <0.05% variation, and the variation seems to be different each time I run the script.

Check out the source yourself on Gist.

Forcing “sfc /scannow” in Windows 7 Startup Repair

I was attempting to repair a computer today, and after some updates were installed via Windows Update during shutdown, when the computer turned on I suddenly began receiving a BSOD (Blue Screen of Death) with STOP code 0xc000021a.

I could not find much information on the stop code, except that it probably meant something was wrong with winlogon.exe or csrss.exe.

I tried to use Startup Repair, as per Windows’ suggestion, but it was of little help. I decided to drop to the Command Prompt within the Startup Repair and attempt to run “sfc /scannow” to attempt to fix any corrupt system files. I was greeted with this ugly error message:

There is a system repair pending which requires reboot to complete. Restart Windows and run sfc again.

However, because Windows never got past the boot animation (stuck in a boot loop), the pending update was never finished.

After some searching around, I found that these two files were the culrprits of the error message:

C:\Windows\WinSXS\pending.xml
C:\Windows\WinSXS\reboot.xml

There was little information about whether removing them was harmful or not. Some people said not to touch them or you could risk botching the entire install. Others said to use it as a last resort.

For me, it was a last resort. Rather than delete them, I decided to stay on the safe side and ran the following two commands from the Command Prompt (in Startup Repair, the Windows install typically residing at C: is mounted to D: instead):

move D:\Windows\WinSXS\pending.xml D:\
move D:\Windows\WinSXS\reboot.xml D:\

I once again tried running sfc, but was greeted with the same error message. I decided to try a reboot, was sent back to Startup Repair, but this time Startup Repair did it’s magic and Windows booted it up! The updates that were installed during shutdown also configured themselves properly despite pending.xml and reboot.xml being removed.

It is worth noting that I did run “sfc /scannow” from within Windows later, and did have corrupt files. I had to run it twice before they were all fixed.

Hope this helps someone!

First look at the new Google Chromecast

Google recently released the Chromecast, a $35 solution to streaming content from any of your devices (phone, tablet, or laptop) to your TV, with a simple HDMI dongle. Originally sold with a Netflix code good for 3 months of free instant streaming on any new or existing account, the price was effectively $11 after taking into account the cost of a 3 month Netflix subscription (about $24.)

I ordered a Chromecast within hours of their release and ended up getting mine in the mail just yesterday.

image

The simple design and slogan “The easiest way to watch online video on your TV” is indicative of what Google was clearing aiming for with this device: simplicity.

The device itself is small, about the length of a USB drive, though perhaps a little bulkier. The box also includes and HDMI extension cord, in case the bulkiness means it doesn’t fit directly into your HDMI port on your TV, as well as a MicroUSB cord and AC adapter in case the television set does not include a USB port by default (it requires a USB connection for power.)

While my TV does include a USB port, it is unfortunately only powered while the input setting is set to “USB”, so I had to plug in the Chromecast to a wall outlet.

image

Once powered, the built-in LED indicator will flash a few times before remaining a solid white (some users have complained this can be distracting while trying to watch the TV in dark environments.)

After plugging it in and switching your TV’s input source over to HDMI, it directs you to the Chromecast setup page on Google’s website (google.com/chromecast/setup). The process is very simple, involving the installation of the Chromecast browser plugin, and connecting your Chromecast to your local wireless network.

image

Once connected to your wireless network, the Chromecast will display the “ready to cast” screen! The screen is plain and simple, with no real controls (which fits into Google’s philosophy that your phone, tablet, or laptop should be your remote control.)

Streaming to the Chromecast is very easy — the Netflix, Play Music, and YouTube apps for Android have already been updated with a new button to tap, instantly sending the video to your new Chromecast. My dad, who once called me in the middle of class and took 30 minutes of explaining in order to attach a document to an email was sending YouTube videos to the television from his phone within a matter of minutes.

And he was impressed: “I can’t believe this piece of garbage can even do this! This was a pretty crappy, cheap TV.”

While apps which have hooked into Chromecast stream quite well (YouTube, Netflix, with Pandora and Songza coming soon), streaming tabs from Chrome was a little bit choppier. There is a bit of a delay between actions on the laptop and its display on the television. Still, it’s a much more convenient setup to draping an HDMI cord across the room in order to broadcast the stream. Unfortunately, broadcasting the entire screen (as opposed to a tab) felt very sluggish. However, this is still an experimental features and I’m sure it will improve in time. (Note: Tested with a Samsung Series 3 ARM Chromebook running ChromeOS.)

While the Chromecast is not perfect, its only been available to the public for a few days and is extremely simple to use and quite functional. The bugs it currently has are small annoyances rather than real issues, and I’m sure now that it has been released to the public, they should be patched quite quickly. At its current price, this thing is a steal. If you’re on the fence about getting one, just do it. For $35, you won’t be disappointed.

Samsung Series 3 Chromebook: First impressions

I recently lost my laptop, an old Gateway laptop (older model dual-core Intel processor, 3GB RAM which I had upgraded to 4GB, 320GB hard drive), and went looking for a replacement. I was on a budget and couldn’t justify a $500-800 investment on a higher-end laptop, and after realizing the majority of my computer use is in the browser, I decided to spend $250 on a Samsung Series 3 Chromebook.

When I first turned it on, I found that the “8 second startup” quote is not exaggerated. It takes almost exactly 8 seconds to get to the login screen, ready for a password to be typed in.

Additionally, the advertised battery life of 6.5 hours seems to be accurate. In fact, I often get even more out of it — 7 to 8 hours with only light web browsing — however more intensive activities such as watching Netflix drains the battery a little quicker, but that’s to be expected.

One of the most important things to note about this laptop I think is that everything feels like it “just works.” From the title bars on windows to the dock at the bottom of the screen with pinned apps, ChromeOS has succeeded in making everything simple. Unlike when setting up Windows, or Linux, you don’t have to hack things together and configure everything to your liking — after all, it’s just a browser.

But calling it “just a browser” does ChromeOS injustice, in my opinion. After all, at this point with Google Drive (Docs, Sheets, and Slides), Google Play Music (I’m a fan of All Access as a great Spotify replacement), and the Secure Shell app, this laptop feels like home to me.

Now to get to some of the design features of the laptop… I’m a big fan of chiclet keyboards, and this one doesn’t disappoint. The shift key seems to be perhaps a bit slow (oftentimes an extra letter is capitalized by accident, an issue I don’t have on most keyboards), but overall the keyboard is comfortable and easy to type on. Of course the caps lock key has been replaced with a search key, which is similar to the windows key on most laptops. It provides quick access to Google search, as well as access to any webapps you have installed.

The function keys have been replaced with a series of functionality keys: a back/forward for web pages, reload, full screen/restore, switch window, brightness controls and volume controls. The function keys aren’t missed, as there is not much use for them in the ChromeOS environment.

The touchpad seems to be a Synaptics ClickPad — these are the ones without designated left/right buttons, which support some gestures, similar to Mac laptops. I’m not a fan of them typically, as they often cause issues on Linux-based operating systems. The drivers just aren’t all there. However, Google seems to have done some work on the drivers and it actually works quite nicely (admittedly my first day with it was a bit troublesome, but I adjusted to it quickly.)

The webcam performs well in both low-light and bright locations. It is not high quality however I did find it to be perfectly acceptable for most tasks.

The actual build quality of the laptop is probably the only real weak point I have with it. The laptop is as light as the MacBook Air at only 2.5 pounds, which is great, but the laptop definitely does not feel as sturdy as, for example, an Apple laptop might. While it doesn’t feel like it will crumble in my hands, I am not convinced it would survive a good drop. Looking around on Google a bit, it seems the screens may be prone to cracking. Furthermore, on the day I bought the laptop, I did not have a case for it and made the mistake of putting it in my backpack with a few notebooks and textbooks. On the commute to school, it managed to gain a few scuff marks on the lid. Nothing too awful but it definitely takes away from the “shiny” imitation-metal plastic.

All in all, I’m quite happy with the Chromebook. It seems to run very well. I’ve had no issue with Google Play Music, Netflix, or YouTube, even when multitasking with multiple of these media sites running at once.

This laptop isn’t for everyone — you do have to realize you will be more or less restricted to the cloud for everything. However, I do think that even if I got another higher-end laptop, I would have use for this one. It’s great for tossing in your bag quickly, and having for lightning fast access to the web.