This blog has my random thoughts; game-related posts go here.
iPhone vs. gPhone navigation model
I've had an iPhone for a long time. I tried a G1 “gPhone” and thought it was slow and unpolished (I've heard Cyanogen's mod helps a lot with the speed), so I went back to my iPhone. But after trying out the G1 for a bit longer, I've discovered the model is quite different, and possibly better, than the iPhone's model. Here are some scenarios:
You're on a web page, you see a link to Youtube, and you click it. The iPhone takes you to the YouTube app. After you watch the video, you press the home button, then go back to the web, and it returns you to the page you were on. Seems reasonable.
You're browsing maps, and you search for something. You click one of the icons, and it takes you a details page. On there is a link to a web site for a restaurant. You click it. It takes you into the browser. You want to go back to the map, so you press the home button, then go back to the map. It returns you to the details page. You click on the back arrow to get back to the map.
You're in the App Store app, you scan the top 25, and click to see 26–50. You find an interesting app, and click it. Read the reviews, decide to install, and click install. It returns to the home page while installing, interrupting your use of the App Store app. Not that big a deal though, since you can just go back into the app and resume browsing. Except it's lost your place. And not only that, it's no longer showing 26–50, so you have to scroll down, click expand, and then find your place.
Some apps, such as Yelp and Echofon, want to avoid you leaving the app, so they embed a browser inside the app. But this means you can't access the usual browser features like bookmarking and emailing links.
The “gPhone” (Android) seems to be designed differently when it comes to navigation between apps. There's a physical back button on the phone, and it seems to get used everywhere. Let's see the same scenarios on the gPhone:
You're on a web page, you see a link to Youtube, and you click it. The gPhone takes you to the YouTube app. After you watch the video, you press the back button, and it takes you back to the browser.
You're browsing maps, and you search for something. You click one of the icons, and it takes you a details page. On there is a link to a web site for a restaurant. You click it. It takes you into the browser. You want to go back to the map, so you press the back button. You're now on the details page. You press the back button again and it takes you back to the map.
You're in the Marketplace app, you scan the list. You find an interesting app, and click it. Read the reviews, decide to install, and click install. It installs in the background. You continue navigating. When the app installation finishes, there's a note in the notification area at the top.
It's not just clever handling of the back button the part of the apps. Later on I'm in the calendar app, and check notifications. I see the app has installed, and click on that. It takes me to that app. I press the back button. It takes me back to the calendar.
The back button is deeply integrated into the system. It wasn't apparent to me when I first tried out the G1. But this is a fundamentally different model from the iPhone. Navigation feels like a browser, where you visit something and then go back, and not like an OS, where you go back to your “desktop” and “launch” an app. I think the difference will be more noticeable in a deeper scenario, such as being in email, then viewing a web page, then viewing a map, then emailing the store, then going back, back, back, to the email you were on. But I haven't tried this to see if the gPhone really handles this case.
Labels: structure
Experiences with my Macbook Air
Nearly two years ago, I got a Macbook Air. It's been nearly two years, and here are my thoughts:
- Portability is really nice. Yes, I'm more productive with a big screen and big keyboard and so on, but I really enjoy using the computer everywhere. The Air is lighter than most laptops, and as a result I've found that I use it while sitting on the couch, while laying in bed, while sitting outside, etc. I move it around a lot. Being 2 pounds lighter than the Macbook Pro makes quite a difference.
- The battery life is acceptable but not great. It lasts 2–4 hours, even though the battery is nearly two years old. If I'm at my desk I leave it plugged in, and I usually don't plug it in anywhere else. I do run out of battery life at times, and I end up taking it back to my desk. It'd be nice to have more battery life but at the same time I don't want to carry any more weight, and 2–4 hours seems like a reasonable tradeoff. I'm too lazy to carry around a second battery even if the battery were swappable, so being unswappable doesn't really matter to me.
- The 64GB SSD is great. It's fast. I don't want to go back to a regular hard drive. However, 64GB is a little small for me. Snow Leopard helped; it freed up quite a lot of space. But I think I need 120GB to fit all my data. I also like that I can move the machine around without worrying about hard drive crashes.
- I really don't miss the CD/DVD drive. The only time I've needed one was to upgrade to Snow Leopard.
- I occasionally need ethernet. I have to carry around a USB/ethernet adapter, and when I have that plugged in I can't plug in any other USB device.
- The built-in sound is pretty bad. There's a speaker underneath the right side of the keyboard, and when you're typing your hand blocks it. When I'm at my desk I use external speakers but I wish the laptop speakers were stereo and better placed. If Airtunes worked for non-iTunes apps without hackery, I'd use that.
- Over time the machine got slower, to the point where I couldn't watch Youtube videos anymore. That's pretty bad. But after reading lots of message boards, I learned that the problem isn't the CPU. It's the cooling (heatsink, fan). When the system becomes hot, it slows the CPU down to a crawl.
- Along the same lines, I was frustrated that my Flash game experiments were so slow on the Air, but after some careful measurements I determined that it's the overheating, not the CPU, that's to blame.
- I finally had the dreaded Macbook Air hinge problem. Apple's finally covering this under warranty, and they agreed to repair my computer. Except that my case has two minor dents in it, and they're unwilling to repair it unless I pay $250-500 to have the dents fixed. Ughhhh. I told them no. I'm not getting AppleCare again.
- Also something I learned on message boards, vacuuming the vents helps the cooling. This was a huge improvement; the computer is now fast enough for most things I do. Oddly, after vacuuming, my hinge seems better.
- I'm a fan of matte screens but this came with a glossy screen. And it really was nice. I can use it outdoors in sunlight! It turns out the glare on the Air is much lower than on the Macbook Pro.
My original (rev. A) Macbook Air has had its problems but it's been a good machine for my needs. My main complaints are about the overheating, the slow video, the high price, and the small SSD. It looks like rev B. (October 2008) solved these issues. I don't know if the new machines still have the hinge problem. My minor complaints are about battery life, the sound, and ethernet, and none of those have been addressed in the new version. The screen and CPU speed have been much better than I expected.
Compared to a middle-of-the-line Pro, the Air now has the same video card, a larger cache, and an anti-glare screen that I can use outside. I don't need a faster CPU or more RAM. If I were sitting at my desk most of the time, then the Pro's better speakers, more convenient ports, larger screen, and lower cost would be reasons to get that instead. Or just get a desktop machine. But I really enjoy the portability, so if I were looking at a Mac laptop today, I'd get the Air over the Pro.
Bash Prompts on the Mac
For a while now I've used colored prompts in bash. I typically make the machine name one color, the path another color, and the username bright red if I'm root. On some systems I show the date and time, the exit code of the previous command, whether I'm inside screen, or the ssh status. Other people have put the git branch, number of processes, job count, tty, system load, disk space, working files, or mailbox status into their prompts.
On the Mac though, once I upgraded to Leopard, the prompts interacted badly with the line-editing. I tried various things but just couldn't get them to work, and I really wanted line editing, so I gave up on the colored prompts.
However, I recently figured out a fix: set the language environment variable. Which one? I tried a few and ended up with this:
export LC_CTYPE=C
Does anyone know why this helps?
Here's how I set my bash prompt (from .bashrc):
# Username (if root or remote)
if [ "$(whoami)" = "root" ]; then
PS1="\[\e[41;1;37m\] root"
elif [ -n "$SSH_CLIENT" ]; then
PS1="\[\e[30;107m\]\u"
else
PS1=""
fi
# Machine (if remote)
if [ -n "$SSH_CLIENT" ]; then
PS1="$PS1@$hostname:"
fi
# Current directory
PS1="$PS1\[\e[34m\]\w/ \[\e[0m\]\$ "
# Current date and time
PS1="\[\e[0;90m\] \d \[\e[1m\]\t\[\e[0m\]\r\n$PS1"
# Screen name (if inside a screen)
if [ -n "$STY" ]; then
PS1=" \[\e[32m\]$STY\[\e[0m\]$PS1"
fi
# Display a smiley for success/failure
PS1="\`if [ \$? = 0 ]; then echo \[\e[42\;37m\]:\\);\
else echo \[\e[41\;37m\]:\\(; fi\`\[\e[0m\] $PS1"
Now that I have colors working again, I'll probably read what other people have done and adopt interesting features.
Future anti-predictions 2
I'm quite optimistic about the future, but I seem to be posting anti-predictions instead of predictions. Perhaps I'll post positive predictions someday, but today I have some more negative ones:
Quantum Computers. Yes, I know that there's a now quantum computer chip but I'm pretty pessimistic anyway. Quantum computers let you explore 2N states with N quantum bits; it would take 2N regular bits to do the same. However, I think the difficulty of maintaining the entangled quantum state will be proportional to 2N — that is, adding one quantum bit entangled with all the existing ones will double the difficulty of preventing decoherence. To explore a large search space, it will be far easier to build more very simple conventional processor than to build one very complex quantum processor.
DNA Computers. Making DNA compute for us seems like a cool idea. We can grow this stuff in vats and have hugely parallel computers. The problems here are that (a) you have to get the problem transmitted to all the DNA in the vat, (b) there's no guarantee of finding the answer, and (c) DNA just isn't a great medium for the kinds of controlled programs we want to write. Here too I think it will be far easier to build a simple massively parallel computer from electronic parts than to build a DNA computer. DNA does have the advantage of easy replication, but conventional computers will also benefit from self-assembly.
Practical Teleportation. There have been experiments showing that teleportation is possible. The basic approach is to entangle two particles at the quantum level, and then destroy the original, leaving you with the “teleported” one. It's pretty cool. But it suffers the same problem as quantum computers: there's a huge amount of complexity involved in teleporting real objects (unlike movie teleportation, I don't think it matters too much whether they're biological or not), and I'm rather pessimistic about being able to entangle a large number of particles simultaneously.
Faster than Light Travel. Physicists seem to think that faster than light travel is possible using wormholes. The idea is that you bend space and time in such a way that where you are and where you want to be are “close” together in another dimension, and then you leap across. I think this is possible in theory. But bending the universe is going to take far too much energy and cause too much collateral damage for this to work in practice. Instead, we'll have to hope for existing wormholes, and there won't be any that are useful.
So there you go. Another fit of negativity from me. I really should start collecting positive thoughts about the future.
Labels: future
Fun with user styles
Long ago (1997), Internet Explorer 4 gave us user style sheets, in the accessibility options. You could point the browser at your CSS file, and it would merge the user styles with the author styles. As with many features in IE4, other browsers adopted this feature too (Mozilla in 2002, Opera in 2003, I think).
User styles are quite neat. However, having to edit a file somewhere and then reload the browser is sort of a pain. The Stylish addon for Firefox makes user styles much easier:
- You can edit the styles per site instead of globally.
- You can organize your CSS into named sections.
- You can share these sections with others.
- You can browse userstyles.org to find CSS shared by others.
- You can install user styles from others with just a few clicks.
I just keep forgetting to write my own styles. Tonight I got fed up with MyWay's 700-pixel fixed width TV listings:
I used Firebug to look at the structure of the site, and after navigating nested tables with no class or id names to hang my CSS onto, I decided to use CSS attribute selectors to address the two tables that I wanted:
@-moz-document domain("tv.myway.com") {
table[width="700"] {
width: 100% ! important;
}
table[bgcolor="#888888"] {
background-color: #fff ! important;
padding: 2px;
}
table[bgcolor="#888888"] td {
border: 1px solid #bbb;
font-family: tahoma ! important;
font-size: small ! important;
-moz-box-shadow: 1px 1px 2px #bbb;
}
table[bgcolor="#888888"] td a {
font-weight: bold;
color: #000 ! important;
text-decoration: none ! important;
}
}
Here's the result:
Try out user styles. If you don't know CSS, you can explore userstyles.org; if you do, you can also try writing your own.
We need infinite energy
[Warning: my thoughts on this topic are still not entirely clear. I sat on this post for a week but I couldn't find better words, so I decided to post anyway.]
When I think about being “green”, I think of three things:
- Clean: solar, wind, wave energy instead of coal, oil, and sometimes nuclear. Part of this is to reduce pollution, but lately it's about reducing CO2 released into the atmosphere.
- Sustainability: renewable energy, better agricultural practices, and sometimes population reduction/stability. This is to avoid depleting resources.
- Conservation (mostly of energy): less driving, less air travel, less lighting, less water, less energy. This is to reduce the impact of our activities on the planet.
I think all of these could use refinement.
I'm a big fan of Clean. Pollution in general is getting too little attention these days, and CO2 gets too much. CO2 is not a poison; it's a good gas to have. Our problem is that we're way out of balance. We're producing far more than we use, so it's building up in the atmosphere. We need to get back into balance, but that doesn't mean zero. Pollution on the other hand we should be at zero. But it doesn't need to be zero production; it's okay to produce if you can clean it up. For example, algae, fungi, and bacteria can be used to clean up some types of pollution, and titanium dioxide can do wonders. Here again balance is the key. Produce as much as is used, and we're good. That's different from saying produce zero.
I'm a fan of Sustainability but I think it's secondary to, and a consequence of, balance. I think depleting non-renewable resources is fine, as long as we do it knowing we're using it up, and we start coming up with a sustainable solution. We might decide to use oil, but deciding not to use it because we're going to use it up is not a compelling reason. Not having any oil and not using any oil are essentially the same. I think for now we should continue using oil, especially for waxes, lubricants, and biodegradable plastics.
I'm less of a fan of energy Conservation, in part because I think it addresses the wrong issue. (Raw material conservation is a separate issue.) The problem isn't turning the lights on. The problem is the impact that causes, because the electricity is generated in ways that pollute or produce CO2. Do you turn off your solar-powered yard lights when you don't need them? Doesn't it sound silly? Turning off your incandescent bulb powered by a wind farm seems almost as silly. Solar, wind, and wave energy are abundant—in fact, literally tons of photons fall on the Earth every hour. And if we don't use that energy, it's lost. If we had abundant clean, cheap energy, would we still feel bad about using incandescent lights? I think we would, because we're trained to, but we shouldn't. There are still good reasons to use less energy, but they're about cost rather than environment.
Historically, asking people to switch to a worse lifestyle at lower cost (public transit in suburbs, abstaining from sex, eating boring food, not going on vacations, using unpleasant lighting, etc.) doesn't seem to be as effective as asking people to switch to a better lifestyle at higher cost. The EV1 and original Insight were “sacrifice” cars. You had to give something up (range, comfort, size), but you could feel good about sacrificing for the sake of the environment. The Prius is quite different. It is comfortable, is roomy, has nice features, and has good range. You're not sacrificing lifestyle when going from a $16k car to a $20k Prius, but it does cost more. And the Prius is far more successful than the EV1 or original Insight. We should focus on abdundant clean, somewhat sustainable energy. I think we'll improve the environment much quicker by giving people lots of clean energy than to tell them to sacrifice. In addition, lots of other problems, like cleaning water and reducing pollution, become much easier to solve when we have lots of energy.
Labels: environment, future
Firefox cookie management with sqlite
I try to keep my Firefox cookie file clean. I used to run a script on cookies.txt to remove most cookies and keep only the ones for sites I visit often and trust. This was simple when the cookie file format was plain text. However, Firefox has been moving files to the sqlite format, and my script no longer works.
Sqlite seems to be pretty nice. The first thing I needed to do was figure out what format cookies.sqlite used. I ran select * from sqlite_master using the command line interface and it told me there was a table named moz_cookies with (id INTEGER PRIMARY KEY, name TEXT, value TEXT, host TEXT, path TEXT,expiry INTEGER, lastAccessed INTEGER, isSecure INTEGER, isHttpOnly INTEGER) as columns. Pretty straightforward. I used this information, plus the Python sqlite3 module (standard with Python 2.5) to write a script to clean up my Firefox cookies:
#!/usr/bin/python
# Change this to where your cookies file is
COOKIE_FILE = ('/Users/amitp/Library/Application Support'
'/Firefox/Profiles/foobar/cookies.sqlite')
HOSTS = [ # keep only cookies from these hosts
u'.blogger.com',
u'www.blogger.com',
u'.delicious.com',
u'.discus.com',
u'discus.com',
u'blobs.discus.com',
u'.github.com',
# … other hosts omitted in this example code
]
# Connect and then issue commands
# through the “cursor” object
import sqlite3
connection = sqlite3.connect(COOKIE_FILE)
cursor = connection.cursor()
# Remove Google Analytics cookies from all sites
cursor.execute('DELETE FROM moz_cookies WHERE name IN'
' ("__utma", "__utmb", "__utmc", "__utmz")')
# Remove any cookies from non-approved hosts
cursor.execute(
'DELETE FROM moz_cookies WHERE host NOT IN (%s)'
% (','.join(len(HOSTS) * ['?'])),
HOSTS)
# Commit changes to disk,
# locking the file during the process
connection.commit()
# Print the cookies we have left
print 'After:'
rows = list(cursor.execute(
'SELECT host, name FROM moz_cookies'))
for row in rows:
print '%30s : %s' % row
The script opens the cookies.sqlite file (unlike cookies.txt, it appears to be safe to open and edit this file while Firefox is running!), removes most cookies, commits the changes, and prints out the remaining cookies.
Lots of the Firefox profile information has been moved into the sqlite format (instead of the mess we had before), so I should explore some of the other files to see what might be fun to play with.
Labels: howto
Future anti-predictions
Perhaps I'm just tired of waiting for my flying car or hoverboard, but I'm not so optimistic that we'll see certain technologies become popular.
- Cars that drive themselves. There's lots of research and good arguments about safety and efficiency and congestion. There are already commercial products for parallel parking, distance-controlled cruise control, and lane detection. But I think the real problem is liability. If there's an accident with a car you drive, it's a local problem (you). If a big company's car crashes while driving automatically, there's the potential for a very large lawsuit. Society benefits from automated driving but these companies pay for it. Early adopter individuals don't benefit enough that the companies can charge more. Such an arrangement makes it much less likely that these systems will leave the research phase. I also think congestion is much more likely to be addressed by variable pricing and better information than by automated driving.
- 3D displays. There's been a recent increase in 3D TV, movies, and video games, but most of the technology doesn't seem any better than the last time 3D flared up in popularity. The image in your eye is inherently 2 dimensional. If it were 3 dimensional you'd be able to see behind and inside things (Flatland is an interesting read if you want to understand this better). To see 3D in your brain you need to have separate images in the left and right eye. You can do this with glasses: color filters (red/blue, used for TV), circular polarized light filters (used in movie theaters), or timed shutters (used in video games). Or you can do this without glasses, by using the difference in viewing angle between the eyes (Philips WowVX for example), but this requires either a single viewer or all viewers to be roughly the same distance from the display. You can also produce 3D effects at a different level of the brain, by viewing different angles (either statically with animation or dynamically with head tracking). The problem is that all of these systems have limitations that exceed the marginal benefit of 3D, once the novelty wears off. So they'll all be used in specialized situations like medical imagery, advertising in malls, and a small number of TV/movie/game applications. But I think 3D displays are not going to be widespread.
- Humanoid robots. Humans are better than computers at some things: creativity, language, pattern recognition, art, design, reasoning. Computers are better than humans at some things: calculations, memorization, repetitive motion, fast sensors. People seem to think that the future is about making robots that look and work like us, but there's no point. We have plenty of humans. We will build robots that do the things we're not good at. And that means there's no particular reason to use a humanoid form. The future of robots is not humanoid. I think humans with machine parts will become commonplace, but they won't be robots replacing or competing with us; they'll be enhancing us.
In general though I'm quite optimistic about the future. I just think the things that actually succeed won't be the commonplace predictions you see in movies and TV.
Labels: future
Time loops: The Terminator
In the Terminator series (movies and TV show), there are some odd time loops.
- John Connor sends Kyle Reese back in time. Kyle and Sarah have a son, John Connor. But John sent Kyle back in time only because of Skynet. Without Skynet, John wouldn't exist. The timeline protection hypothesis suggests John can't kill Skynet.
- Skynet sends a Terminator back in time. The Terminator's arm and CPU are left behind. The technology in that CPU is what Dyson uses to build the beginnings of Skynet. But Skynet sent the Terminator back in time only because of John Connor. Without John, Skynet wouldn't exist. The timeline protection hypothesis suggests that Skynet cannot destroy John.
How did we get into this circular timeline in the first place? I think it's reasonable for the initial timeline to exist without the loop. John could be someone else's son. Skynet could be developed without the Terminator's CPU. But once they start messing with time, they got into this circular dependency, where they only exist because of each other. I'm not sure they can get out of it though. It's similar to the grandfather paradox, except there are two parties trying to kill each other.
The Matrix series, which coincidentally also was about war between machines and humans, might give us a way out of the Terminator paradox. Agent Smith was trying to destroy Neo, and to do so he was willing to destroy the world. Neo sacrificed himself, which meant Smith no longer had a purpose, and Smith was destroyed at the same time as Neo. So perhaps John and Skynet have to destroy each other simultaneously. Or perhaps, as in The Matrix, the humans and machines call a truce, and both John and Skynet stop fighting far in the future, but only after the war that leads to both of them being created.
Emacs: full screen on Mac OS X
If you have a recent version of Carbon Emacs, you can run M-x mac-toggle-max-window to toggle full screen mode, with no menubar. This is handy enough that I've bound it to ⌘ Return, which is similar to what some Linux and Windows apps use to toggle full screen mode.
(define-key global-map [(alt return)] 'mac-toggle-max-window)
I also keep the tool bar off with (tool-bar-mode -1), scroll bars disabled with (scroll-bar-mode -1), and menu bars off with (menu-bar-mode -1). Enjoy an Emacs without distractions!
Update [2008-08-10] They seem to have removed the function, but you can get it back with this code, Vebjorn Lsoja:
(defun mac-toggle-max-window ()
(interactive)
(set-frame-parameter nil 'fullscreen
(if (frame-parameter nil 'fullscreen)
nil
'fullboth)))

