I originally wrote this in 2011, but am copying it here for posterity:
Yesterday [in 2011], I rebooted my Android smartphone (i.e., removed and reinserted the battery) in a location with absolutely no cell phone coverage but with great WiFi. I then could access the Internet at large, but Google services (including GMail, Reader, and Plus), did not work (this is to say, locally stored data was still available, but I could not interact with the cloud). When I then moved to an area with cell phone service, Google services started working again. Who can explain why?
I doubt it makes a difference, but I have [had] a Nexus One on T-Mobile. Find the answer below the break! →
(Details have been changed to protect the guilty and to make the story more entertaining.)
I work for a company that builds robotic kiosks (think vending machines that cut keys), which are stationed in various stores across the country. One morning, I arrive at work to find a coworker looking troubled. “We’ve got a kiosk in Florida that’s stuck in the middle of shutting down. Can you take a look?” This isn’t my area of expertise, but somebody’s got to deal with this, and it looks like I’m somebody.
I try to SSH into the kiosk, but the connection is refused with the message,
The system is going down for power off in 1 minute!. “It’s been saying that since I arrived half an hour ago,” my coworker explains. “It’s not actually going to shut down in a minute.” Read on to learn how we managed to log in again. →
(inspired by a question a student asked me in the course I TA)
In the language of your choice, write a function that takes a string argument and returns a string representing the PCRE pattern that matches all anagrams of the input word. For example, if the argument to the function is “retrains”, it should return a regex pattern that matches “restrain”, “retrains”, “strainer”, “terrains”, and “trainers” as well as a bunch of strings that aren’t real words. You can assume that all characters in the input string are English letters. The length of the output string should be polynomial in the length of the input (i.e., just enumerating all possible anagrams doesn’t count, since that takes exponential space).
Also, if you haven’t seen this chestnut: write a POSIX-compliant regex pattern that matches strings of the form a* (i.e., “”, “a”, “aa”, “aaa”, etc) which have composite (non-prime) length.
…and people claim that regular expressions are only as powerful as DFAs are. :-P
Having spent yesterday with over 200,000 like–minded individuals (these last two photos were even taken with my own camera), I don’t want to be social today. So, I want to spend Halloween at home but still do something unusual and festive. My solution:
- Put on Rainy Mood
- Pull up a fireplace on Infinite YouTube
- Turn out the lights
- Read my 130 year old edition of the works of Washington Irving by candlelight.
All I need now is a bust of Pallas above my chamber door.
What do you mean I haven’t posted in 3 months!? …oh, I guess I’ve made a bunch of half-written drafts, but never finished any of them. I should get on that.
In the meantime, here’s a word game for you. How many words can you name in 10 minutes that contain all 5 vowels? Y’s are optional but stylish. It’s okay if the words contain some vowels multiple times, or if the vowels are out of order. My word list is in the first comment.
I have an ice cube tray that lives in my freezer. Earlier today, I used the last of my ice cubes, so I filled it with water and stuck it in the freezer again. Just now (maybe an hour later? It’s been a few hours at most), I open up the freezer again, and see this:
(taken out of the freezer and photographed with a Kleenex box as a backdrop) The tops of the ice cubes are frozen, but there is still liquid water underneath. The interesting thing, though, is that one spot has risen up about half a centimeter higher than the rest. What caused this to happen? Why isn’t the surface totally flat, like it was when I put it in?
Details that may or may not be important:
- I know there is liquid water underneath because I thought there wasn’t and flexed the tray to crack the cubes loose, and some water came out and then there were air bubbles floating around under the cubes.
- I kinda over-filled the tray, so that all the cubes are connected by a thin sheet of ice that goes over the plastic dividers in the tray.
- When I filled the tray with water, there were some small bits of ice stuck in the bottom of the tray, maybe a third the size of a normal ice cube. These were left over from cubes that had cracked in two, where I used the top part but couldn’t get the bottom part out. I expect they’ll become part of the new batch of ice cubes, but I haven’t checked on that yet.
Hey, remember how anyone who talks about coding style is all like “use more whitespace. Whitespace makes code more readable,” right? (hint: the answer is “yes.” If you answered anything else, you’re doing it wrong, and you should use more whitespace. Whitespace makes code more readable.)
Well, PHP has this great (read: terrible) idea in which you’re really just writing XML, and the actual code is kinda embedded within it. This means that if you add whitespace in the wrong places, it gets included in the final page shown to users. Usually this is not a problem, because in HTML extraneous whitespace gets ignored. However, if you’re writing true (non-HTML) XML (like, you’re generating an RSS feed or something), apparently the very first line of the file needs to start with
<?xml ...?>, or else it doesn’t parse correctly.
WordPress has a file called
functions.php, where you put miscellaneous utility functions. I had added a function to it that would append a ‘→’ to all cuts on my blog, I had responsibly surrounded it with documentation explaining what it does and how it interacts with the rest of the system, and I separated it from the previous function with a blank line so they wouldn’t run together and look like a single giant function. What I failed to realize was that
functions.php is used in the stuff that generates RSS feeds, which means that suddenly the RSS feed had a blank line before the
<?xml?> tag, which meant it failed to parse correctly, and broke. That’s right—I broke my website by adding documentation. This is fixed now, but it’s the dumbest problem I’ve seen in a while. If you ever design a programming language or markup language (or, heck, anything that gets parsed), please, please, for the love of Zeus allow blank lines to be added in arbitrary places without affecting the functionality.
I figured I should break my silence to give a quick update of what’s going on with this blog. I’m fed up with the crap that LiveJournal has been pulling recently, so I’m leaving and moving to my own website. The reasons to switch away from LJ have been mounting: reasons I no longer like LiveJournal behind the cut →
This is closer to the unsolved hat problem I have previously discussed than the solved hat problem I discussed. It made the rounds on a “Math Enthusiasts” mailing list I’m on today.
There are n people who have been given a challenge: tomorrow, a hat will be placed on each of their heads. There are n different colors of hats, and colors can be repeated (or not used at all). Everyone will be able to see the hats on everyone else’s head but not their own. No one is allowed to communicate in any way while looking at each others’ hats. Then everyone is lead away into separate rooms and each person is asked the color of their own hat. If at least one person answers correctly, the group as a whole wins (unlike the unsolved hat problem mentioned above, no one is penalized for an incorrect guess). The people can discuss strategy amongst themselves before the challenge starts, but cannot communicate in any way once anyone gets a hat.
What strategy can they use to guarantee that the group wins?
and for the pedants out there: all participants are told all possible hat colors before the challenge starts (no need to guess what the unseen colors might be), and n is small enough that all colors can be distinguished on sight (it uses less than a million different shades of blue, for instance).