Pseudocode

For the past few weeks, I've been working on a project I've dubbed 'pseudocode'. I was inspired by the expressive way I handwrite pseudocode in my notes and how I thought it was disappointing that I can be so much more clear in writing than I can in code, where I'm restricted to a limited glyph set.

As it stands right now, pseudocode is a live processor for source code in many languages that replaces certain operators and other language constructs with properly spaced, typographically distinguishable variants. '=' is replaced with '←', '==' with '=', '<=' with '≤', etc. I think the best way to get a feel for it is to actually try it, which is why I wrote this initial version of the interpreter in javascript (well, in coffeescript). There are a few other minor tweaks to the font (which is derived from the excellent DejaVu Sans Mono).

Here's the demo, hosted at GitHub. It should work in all modern browsers, but I've only tested it extensively in Chrome.

So, go, try it for a while. Type a few lines of code (solve some Project Euler problems if you're looking for something specific to write) or paste in something you're working on. It's particularly tuned to the languages I know and like, so you'll get to see more of it (and it will hopefully make fewer mistakes) if you use Python or a C-like language.

Unfortunately for myself and others who like pseudocode, this demo page is, for now, all there is. I spent a lot of time trying to wrangle pseudocode into vim, and it's proven difficult, to say the least. The closest I could get was to find some similar projects whose solutions don't conserve line length, which is a dealbreaker for me (they also cause text to jump around distractingly in MacVim).

Regardless, I remain enthusiastic about the idea, and I'll keep working on a good way to actually use it in practice. In the meantime, I'm going to stop focusing on this as much and move on to other projects. I've gotten pseudocode to the point where I'm happy with the overall feel, but can't stop nitpicking and second guessing myself on details. The full source code is available on GitHub (you'll need FontForge if you want to edit the font, CoffeeScript and Sass if you want to run the code).

Thoughts, opinions, and contributions are always welcome, either by email or in the comments. (Bugs can be filed at GitHub)

Screen_shot_2011-06-09_at_10

Guacamole + Ubuntu Maverick: Step by step

VNC server

  1. Install a VNC server. I suggest vnc4server.
    sudo apt-get install vnc4server
     
  2. Create the file ~/.vnc/xstartup. Paste in the following (this will set up the x server and start gnome-session to give you your desktop and panels and such):
    #!/bin/sh

    xrdb $home/.xresources
    xsetroot -solid black
    gnome-session &

  3. Start the vnc server. Change the resolution if necessary; this is what I used so it would display nicely on my Cr-48:
    vnc4server -geometry 1260x650 -depth 24
    It will prompt you for a password the first time if you have never run vnc before. You should set one up, especially if you're not firewalling port 5900-5910. Remember what screen it says it has started on for later. It's usually screen 1.

Tomcat

Don't use the version of tomcat in the Ubuntu repos. It is very broken.
  1. Download Tomcat 6.x from the website. Get the .tar.gz file under "Core".
  2. Untar the file.
    tar xvzf apache-tomcat-6.0.32.tar.gz
     
  3. Move it to someplace nice. I used /opt/tomcat. It's whatever you want though.
    sudo mv apache-tomcat-6.0.32/ /opt/tomcat
     
  4. Generate SSL keys for tomcat. More info here.
    keytool -genkey -alias tomcat -keyalg RSA

    This will ask you several questions. It will also prompt you for a password. You won't have to memorize this password, so you can use a random one. Use the same password for the keystore and the key. You'll enter it in the next step...
  5. Edit the /opt/tomcat/conf/server.xml with your favorite text editor. Add to the bottom (and change the bolded things to be correct):
    <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true" keystoreFile="/home/username/.keystore" keystorePass="keystore password" maxThreads="150" scheme="https" secure="true" clientAuth="false" sslProtocol="TLS" />

Guacamole

  1. Download Guacamole. (The .tar.gz, if there are choices)
  2. Untar it:
    tar xvzf guacamole-0.2.6.tar.gz
     
  3. Spread the files through your system:
    cd guacamole-0.2.6
    sudo mkdir /var/lib/guacamole/
    sudo mv guacamole.war /var/lib/guacamole/
    mv guacamole-users.xml /opt/tomcat/conf/
    mv guacamole.xml /opt/tomcat/conf/Catalina/localhost/

  4. Edit the username and password in /opt/tomcat/conf/guacamole-users.xml. You'll use these to log in later, so use something you know.
  5. Edit /opt/tomcat/conf/Catalina/localhost/guacamole.xml. Change the port from 5900 to 5900 + screen number (from before) (so probably 5901). Uncomment the line with the password tag and add in your password.
  6. Start tomcat.
    /opt/tomcat/bin/startup.sh
     
  7. Go to http://localhost:8443/guacamole in your favorite modern browser.

That should do it. You'll have to re run the vnc server and tomcat startup script if you ever reboot. Getting those to run automatically on startup is left as an exercise to the reader.

More Minecraft

These last few days of snow have given me lots of time to work on my homework and many personal projects play Minecraft.

So I made you some screenshots.

I took the plunge and installed a couple of mods. The only one that I've really stuck with though is BetterLight (formerly Ambient Occlusion) which makes the lighting look much nicer (at the cost of a bit of a performance hit, at least on my Mac mini)

First up, my new favorite theme ever, Linecraft (note: work in progress). It has exactly the style I was looking for, and it just happened to go on /r/minecraft today.

(download)

I do have one nitpick: the style is not very consistent when you get into the more manufactured-looking blocks (wood, cobblestone, wooden things, items). As I said though, it's a work in progress, and I hope that it improves in this regard.

Second, a mod I tried out but ultimately decided against (for performance reasons) added some nice depth of field blur:

2011-02-09_12

Cr-48 Resolution and CSS

One of my complaints about the Cr-48 is that reading text on many sites is difficult. My vision isn't perfect, but it seems like most sites are unreasonably small.

I found out via the (quite good) Cr-48 subreddit that I'm not the only one with this problem. Linked to from the comments is a rather lengthy debate on the Webkit bug tracker on what to do about relative DPI differing from screen to screen on modern devices.

Basically, Webkit currently defines one CSS inch as 96 device pixels, exactly, always. This causes web content to look smaller on screens where a device pixel is less than 1/96 of an inch. The Cr-48 device pixels are about 1/125th of an inch (the screen is 125 DPI). Therefore, if I (as a web developer) want an element on the screen to be one inch wide (all other units in CSS are defined in terms of the inch), it will only be .8 inches wide on a Cr-48.

Further complicating the problem is that most web developers are not using 96 dpi screens either. Older computer screens are actually less than 96 dpi. 96 was made a de facto standard by Microsoft even in the face of this fact with the justification that things on a computer screen ought to be bigger than the same thing on paper since screens are generally further from your face than paper documents.

As if that wasn't enough, the CSS unit "px" is actually defined by the CSS2 spec as 1/96th of an inch. This is extremely unintuitive. For most modern monitors, the proper size of a CSS pixel is not one pixel. And the proper thing (by the spec) for the browser to do would be to treat pixel units as more or less than one pixel.

The only browser that I know of that does this correctly, incidentally, is Mobile Safari on the iPhone 4, mostly because of its very high density screen. Firefox apparently deviates from the CSS2 spec and displays "relative" CSS units (inches, points, picae, mm, cm) as being in terms of the DPI while keeping pixels (as an "absolute" unit) fixed. This would cause problems on many websites, but, fortunately (I suppose) for Firefox users, does not affect many people, as Windows does not automatically set the DPI (instead defaulting to 96 DPI, per above). Chrome and Safari do nothing, completely ignoring any DPI information in the OS.

Fortunately for me, a poor user suffering as a result of this widespread confusion and misinformation among browser devs, web devs, designers, and users, and a resulting lack of automatic fix for this sort of problem, a workaround exists. Chrome (at least very recent versions) has an option in the settings menu (in Under the Hood) to set the default zoom level. The closest I can get to the desired DPI is 120% zoom (resulting in 96 * 120% ~= 115 DPI), which I find works quite well.

 

Cr-48 Observations & IAQ

So, I was sent a Cr-48 (Google's testbed hardware for Google Chrome OS) last week and am just now getting to play with it. Some neat things:

  • It really does come back from sleep instantly. I'm having to adjust to this; I have such a strong habit of closing my laptop screen partially when I'm not using it, because I don't want it to distract me but I also don't want to wait for it to wake up. That's no longer an issue.
  • Panels are brilliant and wonderfully implemented. Every OS needs these, especially on a small-ish screen. And they have some really good UI polish; for instance, when opening a panel, a temporary button appears to close the panel wherever your mouse is. That way, you can open, look at, and immediately close a panel without moving the mouse.
  • The touchpad isn't nearly as bad as some people have made it out to be. It's no Magic Trackpad, but it's still better than most that I've used.
  • The mute button is finally implemented sanely. After pressing the mute button, the device will always be muted, even if it was before. I hate having to guess whether or not it's muted before I press the button. When I'm pressing the mute button I want the device to be muted. (The volume + button unmutes if it's muted.)
  • Google Talk Voice/Video works out of the box.
  • The keyboard uses lowercase letters. I'm a pretty big fan of lowercase letters over uppercase from an aesthetic standpoint, and I think they look nice on the keyboard. Typeface seems to be Univers or a variant. (Interestingly, Apple's old G4 Powerbooks used Univers on their keyboards.)

And some questions I came up with/questions I will come up with (I will answer them as I find the answers). I'm labeling this section "Infrequently Asked Questions" because if they were FAQ's they'd be answered somewhere else (i.e. I'm only posting questions here I haven't seen answered elsewhere).

Open questions:

  • How do you get the finger/hand prints off this thing? It's a porous rubbery surface. Damp cloth did not work.

Answered questions:

  • How do I use a reasonable SSH? / The ctrl+alt+t terminal sucks.

    Shell In A Box
    is wonderful. You can even CSS style it I think, although I find the defaults work for me. You can even use the (somewhat silly) icon my boyfriend made for me if you are so inclined.
  • How do I make Hulu usable?

    I consider myself a minor expert on getting by with Flash's Linux version, which sucks many balls. (1) Give up on full screen ("lower lights" is your friend) (2) Lower the resolution (gear icon) and (3) Close other tabs.

    Back in the earlier days of Chromium OS, I found that popping the player out (it goes into a panel) and resizing it helped a lot, but that seems broken for me now.

  • How do I make pseudo apps for my bookmarks?

    Look here. It's actually quite easy. You have to make a manifest.json file and a 128x128 transparent PNG icon. Packaging it into a .crx can be done through chrome://extensions (with the "developer mode" link on that page). You'll have to specify an autoupdate URL and host the .crx online somewhere if you want the sync to work (haven't tried that part yet).

    All this being said, I'd love to see a Chrome fullscreen.me like site that would easily appify any page. Maybe when they don't have to be packaged (coming soon I understand).

More to come, probably.

Moving from LJ to Posterous

So, I finally got fed up with the excessive ads on LJ and am switching to Posterous.

Why Posterous?

  • Automatic, painless import from LJ.
  • Auto posting back to LJ (more below), to Facebook, etc.
  • Ability to post by email.
  • Ad-free (for now).

But I am reading this on LJ!

I have it automatically posting *all* my posts to LJ for a couple of reasons; primarily, though, so that people that want to can continue to get my content on their friends page. This was basically the reason I selected LJ back in the day, and I'm glad I won't have to give it up.

So, basically, you can either read my posts in LJ, Facebook, or at blog.calebegg.com (there's a feed of course there). I'm still trying to decide if I want to also autopost to twitter and/or tumblr (for same reasons as LJ).

So, yeah. More than you probably wanted to know.