docwhat's avatardocwhat's blog

All posts

DNS not working with Go binaries and VPNs

closeup

If you are having DNS problems (i.e., Host not found) while using a Go binary while connected via a VPN… then I have a solution for you.

The solution is dns-heaven. Just use this command if you trust shell scripts running as root from random people on the Internet:

sudo -v \
  && curl -L https://git.io/fix-my-dns-plz \
   | sudo bash

What’s going on?

On macOS, if a Go program is compiled with CGO_ENABLED=0 then Go uses its own internal network name resolver. This resolver only knows about /etc/resolv.conf and doesn’t know about the libSystem (macOS libc) library and its name resolution functions.

macOS (like most modern OSes) has smarter DNS lookups than just using an /etc/resolv.conf which allow it to smoothly handle switching networks.

When a VPN is being used then DNS lookups will be split between the VPN’s DNS servers and your ISP’s DNS servers, depending on the hostname.

You can setup custom name servers for certain domains by creating resolv.conf style files in /etc/resolver/<domain>. This is what your VPN software is doing behind the covers.

This problem is VPN agnostic. In my case, I’m using “Cisco AnyConnect” but the same problem will exist with any VPN software.

It looks like this will be fixed in Go version 1.13, commit f20b42a landed in master branch early April, 2018.

See also:

Read More…

Vim: indirect variable access

tuesday temptation 550409 unsplash

In Vim you can use a variable as a variable name.

Instead of using the variable name directly, wrap it in curly braces ({}). This will use the contents of the variable as the variable name.

let l:variable_name = 'b:infosec_username'
let {l:variable_name} = 'George'

echo exists(l:variable_name) " => 1
echo {l:variable_name} " => George
Read More…

El Capitan and the evils of OpenSSL

Are you having trouble with SSL on El Capitan (OS X 10.11)?

Me too.

Read More…

Spread your knowledge

I found myself trying to figure out how to disable something called NeoComplete (previously known as NeoComplCache) when editing markdown in Vim.

It was colliding with my Markdown stuff pretty badly and had really bad suggestions anyway (I mean, I’m writing text, not code… so no surprise) and I was getting annoyed of turning it off by hand.

So I Googled for a solution and I found someones .vimrc and while it was written for NeoComplCache, it was easy to just change all the NeoComplCache strings to NeoComplete.

My .vimrc actually tries to use NeoComplete and if I can’t run it (i.e. Vim isn’t new enough or doesn’t have Lua compiled in) then I fall back to NeoComplCache.

So I went to check if I had similar code for NeoComplCache… and I did. In fact, it was the same code.

“Huh”, I thought, “I must’ve borrowed this from the same .vimrc earlier”

I double checked the URL of the .vimrc I was borrowing code from… and it was my .vimrc.


Some co-workers were trying to reimplement our builds to use CMake. They were having trouble using xsltproc to “compile” files (e.g. convert them from .xml to something else).

Guess what they found.


I used to work with the talented Carol. She left the company and went to work elsewhere.

When I next saw her, she stomped up to me and complained:

Whenever I Google for the answer to something, you’re there! Question on StackOverflow? You answered it. I go to file a bug on GitHub, you’ve already filed it or commented on it. Why won’t you go away?!?!

She was kidding… I think.

But the point is, I spend a lot of time contributing back to the community. Not necessarily by writing code (I do that, too) but by filing bugs, answering questions, adding helpful comments to issues, etc.

It isn’t that hard to write a bug, answer a question, etc. and it can be really helpful for others… or drive them mad.

Read More…

Chef, Puppet, Heat, Juju, Docker, etc.

Someone emailed me with this question:

I am interested in learning different orchestration mechanisms and would like to understand how they differ.

What are the differences between Chef, Puppet, Heat/HOT, Juju, and Docker?

When would I use a specific one?

There seems to be a lot of similarity between these.

Since I get these kind of questions a lot, I thought I would write up what I know of these (in some cases, little).

System

These are tools for configuring your server. Some run once and are never seen again, others run continuously and update the state as requirements change, most can be run in either mode.

All these tools can work with other things listed here. For example, I use Chef to deploy applications in Docker containers.

CFEngine

CFEngine was created in 1993 as an Open Source project. There is a company around it (named CFEngine) that does paid support, but you don’t have to pay anything unless you want to.

I haven’t used it but it has its own syntax that made it seem less attractive to me. It’s also a first-gen provisioning system. It’s written in C, and is fast. But I haven’t met anyone who uses CFEngine who configures as much as I’ve seen with an average Puppet or Chef user.

Puppet

Puppet was created in 2005. It’s open source and built mostly on top of Ruby.

Puppet was obviously an answer to problems seen in CFEngine combined with a desire to use Ruby.

It requires a central server (this may have changed recently) to coordinate secrets, configurations and recipes.

It uses its own language for describing states and adding new functionality can be difficult. A puppet process runs on the system to maintain the state of the server, or make changes overtime (as you push changes to the central server.

It is also very flexible, and until recently, didn’t offer much assistance in how to organize your configuration files, etc.

In the past, when you wanted to work on a recipe, you had to try it out on a live system. This was problematic in my group, where developers wanted to be able to modify and assist with writing rules.

There was a like to about Puppet but ultimately, we switched to Chef.

The Puppet language is annoying. Writing a good language/syntax from scratch is hard and I never felt that the Puppet group was paying enough attention to it.

Puppet (at the time, I think this is changing) had no way to write tests or to test a recipe without trying it out on a live server. This made things really scary when we were making big change.

We also couldn’t give developers access to our recipes without giving away our secrets (passwords, etc.) That hindered our ability to move quickly.

Puppet uses a pull model. A process runs all the time and applies the rules every so often by asking the server what rules to run.

Chef

Chef was created in 2008. It is Open Source and is written in ruby (and parts of the server are in Erlang).

Chef was created when some of the developers for Puppet split away and wrote a whole new system, creating Chef.

Chef can be run with a central server (a chef-server) which can hold secrets, recipes, etc. and coordinate all the server.

Chef could also be run in a stand-alone mode using chef-zero, chef-solo, or chef-apply.

Chef has several well designed testing tools, including tools to bring up a VM on your workstation running the recipes under test.

Chef is spending a lot of effort to improve the experience for people writing new recipes, including a ChefDK that installs everything you need to get started writing recipes.

Chef also does a really good job separating secrets from non-secrets, which means our developers can actually talk to our chef-server without us worrying about them getting access to passwords, etc.

A lot of cloud companies that use Chef use chef-zero to pre-create VMs, then delete chef, and then make the system live. They then dispose of the VM when they need configuration changes.

Where I work, we manage lots of resources for developers and our systems are more permanent. So we use chef-server to monitor all the systems.

In addition, we use Chef to not only configure our systems to be in line with our security policies, but we use it to actually audit our systems as well!

Chef is normally a pull-model (it has a process that runs continuously that polls the chef-server) but with the Enterprise license you get a push ability too.

Ansible

Ansible was created in 2012 is also Open Source.

I don’t know much about it, but it actually sounds pretty good. It is new and I believe it has taken away a lot of the lessons learned in Puppet and Chef.

It ships with Fedora, I don’t know what RedHat’s plans are for it.

JuJu (Ubuntu)

I haven’t used JuJu but my impression is that is like a “meta” package manager with some configuration built-in.

I don’t think it is as complete as the other systems above, but I think the other systems could make use of JuJu… as well as JuJu could be used to set up the above systems.

It only runs on Ubuntu as far as I know.

Application

Isolating your application setup, deployment and configuration can make your life much easier. It can help to reliably reproduce working applications across your network as well as find bugs and do high quality QA.

Docker

You create a container image with your application all ready setup except for certain values which you configure via environment variables.

A Docker container should only contain the processes needed for the application, and nothing more. Docker containers can only be run on linux servers.

Docker containers can “stack” and communicate among them selves to allow building stacks of intercommunicating applications.

I like Docker a lot and it makes a really good way to pass around applications because you know that it’ll run the same in QA, Production, and for developers when debugging problems.

You can manage docker via any of the system provisioning systems above.

Infrastructure

There are more infrastructure provisioning systems out there, but our setup hasn’t become so complicated (yet) that we have needed them.

Heat

Heat is a part of OpenStack and is used to provision infrastructure: networks, VMs, routes, etc. Heat can use some kind of system provisioning tools like Chef and Puppet to setup the VMs, or you can use pre-built VM images.

You could, for example, write a template describing a load-balancing setup with several apps and a private network connecting them. You could then either scale one setup using the template (e.g. increasing load-balancers, replicated dbs, etc.) or quickly create a new setup of server (e.g. a staging or development setup). Chef has something similar called chef-metal, though it isn’t version 1.0.0 yet (but it works).

Chef Provisioning (was Chef Metal)

Chef Provisioning is a system that mainly works with VMs. It can work with the surrounding infrastructure, depending on your setup.

It can work with OpenStack, AWS, Azure, and several other cloud providers.

As the name implies it integrates well with Chef, but could be used with any of the other systems above.

My understanding is that while it works, it isn’t mature yet.

References

Read More…

Setting your environment in test-kitchen

When using test-kitchen it may be necessary to set the environment of your nodes.

You can do with by changing your .kitchen.yml file. In my example, I’ll show it at the root, but they can be set on a per-suite level as well, which is handy to test different environments.

Read More…

Unindenting HEREDOCs in Ruby

This is a bit of code I wanted to save.

When using HEREDOCs in Ruby, the <<- operator is handy to keep everything indented in the source. But it doesn’t help with the content of the HEREDOC.

Example:

def example
  puts <<-EOF
This is left.

  This is indented two.
  EOF
end

In rails, you can do this:

def example
  puts <<-EOF.strip_heredoc
    This is left.

      This is indented two.
  EOF
end

There’s a helpful Stack Overflow question on this, in fact.

Here’s a simplish solution for plain ‘ol Ruby:

def unindent(string)
  first = string[/As*/]
  string.gsub(/^#{Regexp.quote first}/, '')
end

def example
  puts unindent(<<-EOF)
    This is flush left.

      This is indented by two spaces
  EOF
end

Too bad you can’t pull in some of these Rails monkey patches without pulling in lots of stuff you don’t want.

Read More…

How to rename a Chef node

In Chef the node_name is for human usage. By default it is set to the fqdn. Which is annoying for typing.

In my network, all hosts have the same domain name. However, we knife bootstraped this one system without setting the node name with the -N flag.

Therefore I wanted to rename the nodes. With some experimentation, I figured it out.

Read More…

Tracebacks in bash

I don’t like to write programs in bash. It’s not a very pretty language. But it has one advantage over a lot of other languages:

It’s on your system. Every Unix-like system has /bin/bash; Redhat, Ubuntu, and even OS X.

But bash is still a lousy language.

This is where bash tracebacks come in…

“Whaaaaa? Bash has tracebacks?” I can hear you ask.

Yup, it can.

Read More…

Busting cached 301 redirects in Chrome.

The Chrome browser caches HTTP 301 permanent redirects very aggressively. This is normally a good thing, unless you’re the one setting up the 301 and you make a mistake…

There is no obvious place in chrome to refresh that cache, but there is a nifty trick.

Read More…

40days - Simple isn't easy

40days

I wrote a simple one-page web application called 40days. It shows you what the date is for 40 days in the future. I say “simple” but simple isn’t easy. It never is.

Read More…

Re: All https, all the time

Will Norris posted a blog post titled All https, all the time.

It’s a good article and I recommend you read it. docwhat.org is now only using https.

I did want to add one note about his apache configuration at the end.

He should be using [L,R=301] instead of just [L,R]

By default, the R is a 302 Found redirect. It was originally a “moved temporarily” but over time became an redirect for unknown reasons.

A 301 Moved Permanently says instead that the old URL isn’t coming back. This helps search engines and other software that tracks pages. Bookmarks can also benefit from this as well.

So the complete rule would be:

UseCanonicalName on
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{SERVER_NAME}%{REQUEST_URI} [L,R=301]

Ciao!

Edited: I replaced %{HTTP_HOST} with %{SERVER_NAME} because SSL certificates have specific host names associated with them. %{HTTP_HOST} just returns the host name that was in the request, which may not be the correct FQDN for the SSL certificate. To make it use the canonical name, you must turn on UseCanonicalName, which really should be used on SSL encrypted hosts anyway.

Read More…

More on Vim with ruby crashing

I finally figured out all the reasons why Vim keeps crashing on me. I started collecting info in OS X Vim with Ruby crashes but there were still crashes happening.

It’s an interesting story. Grab a beer and pull up a chair…

Read More…

OS X Vim with Ruby crashes

On my OS X systems, Vim and MacVim has been crashing a lot. The main symptom is that anything using Omni completion, such as NeoComplCache, would try to use the built in Ruby and cause vim to die with Vim: Caught deadly signal SEGV.

Read More…

vim - preserve your cursor and window state

In vim, you can re-indent a whole buffer by using gg=G in normal mode. I like this command so much I have it mapped to <leader>g</leader>.

This is great except that you loose your cursor (and window) position.

Read More…

Updating VIM on OS X

The version of Vim that comes with OS X is a little old, but more importantly, it doesn’t have all the bells and whistles enabled.

Specifically, it doesn’t come with ruby and python support compiled in. Which is a shame, because some plugins for Vim need it.

Read More…

git gc for a bunch of directories

Every so often, you might want to run git gc to keep your git repositories running fast. Here’s an easy way to do that.

Read More…

PSA: Turn on 2-step verification in Google

If you use any Google services (GMail, GTalk, etc.) and you care even a little bit about the data in that account, then you should turn on 2-step verification.

Read More…

TextMate 2 Articles

Last week, TextMate 2.0 early-alpha was released. This release has been a long-time coming. It includes lots of improvements that people have wanted for a long time.

I am currently a TextMate user. Mainly because I’m an OS X and do Ruby programing and TextMate has lots of things to make this easier. I still love Emacs, though. One of the things I’ve been waiting for has been mark-and-select (a.k.a. control-space in Emacs). I haven’t seen it yet, but then again, I’m only starting to play with TM2.

Read More…

Fix git-gui’s “Spell checking is unavailable” dialog

Unashamedly stolen from a Hints and Kinks blog post; I added information about the Homebrew solution

If you use ‘git gui’ on the Mac, you may find that it repeatedly pops up a message about spell checking being unavailable. This happens when using the MacPorts or Homebrew versions of git.

Read More…

Undoing a rails generate

I just learned this today, while taking a Ruby on Rails class from Jumpstart Lab.

I have, many times, messed up a rails generate command. For example, using singular where plural is needed or the reverse.

Today, I learned that you can undo a generate by using rails destroy with the same arguments you used for the generate command.

Example:

rails generate controller article
# Oops!
rails destroy controller article
rails generate controller articles

Apparently only a few of us in class knew about this during this class.

I’d worked around not knowing this by using git to commit everything and then reverting everything if I messed up.

Why doesn’t a generate command show a message explaining that it can be undone with destroy? It’d be really really helpful.

Ciao!

PS: I also discovered you can “redo” the last migration as well, which is really handy as well for repairing mistakes:

rake db:migrate:redo
Read More…

Ruby crashing on Lion

Apparently Ruby doesn’t work well (or barely at all) with Lion and X Code 4.1

In fact, it crashes with gusto when compiled with X Code 4.1… UNLESS you know the magic words!

Read More…

New Look (2)

Every so often, I get bored with my theme. I notice usability issues, things I wished I did differently, etc. and I want to play with new technologies like HTML5, CSS3.

I had been using Thematic which is very nice. It has good semantic markup as well as other nice features. But it isn’t HTML5 and I wanted HTML5.

Read More…

Virtualenv on OS X

So I decided to try to install virtualenvwrapper (and virtualenv) on my Mac Book Pro. Virtualenv was explained to me as being python’s version of Wayne E. Seguin’s RVM (Ruby Version Manager).

I’ve tried installing virtualenv/wrapper twice before and failed miserably. But this time I decided to actually do it.

Read More…

Jenkins

We have recently started using Jenkins at work and it is awesome.

Jenkins describes itself as a continuous integration software, but it really is more. You can use Jenkins to build, test, and do cron jobs, etc. It’s very powerful and really useful.

Read More…

Gerrit: Rename a Project

At work we’ve been trying out Gerrit. It is awesome in many ways, and yet in others it is sorely lacking.

One of the more obvious problems is the lack of administration functionality. For example, there is no administration interface for deleting or renaming a project.

However, I needed to rename a project and here is how I did it.

Read More…

IAT 1.5

I just uploaded It’s All Text! 1.5 to AMO. [edit: It’s out!]

Assuming I made no mistakes, then it should appear shortly.

The big changes are that it supports Firefox 4.0b7. In addition to that, I have fixed some of the problems with OS-X. In part because the ability to launch applications in Firefox is becoming more annoying with each release.

Read More…

Git Tip: empty branch

Ever wanted to make an empty branch (with no history in it) in git? It’s not hard…

Why would you want to do this? Well, for example, I have a new project in github. I’m trying to implement it in several ways, jRuby, Java, Qt, etc. Having separate branches is really handy.

Another reason you might want to do this is for upstream tracking. I used this to cold-start a branch where I commit all the changes of an upstream project and then merge them into my customized branch. Git makes tracking an upstream project much easier.

Anyway, enough of that. Here’s how to do it:

# WARNING: Make sure you've committed all your work...
#
# Point git at a new branch:
git symbolic-ref HEAD refs/heads/yournewbranch

# Remove the index file so it doesn't know about the files
# that are already checked out:
rm .git/index

# Clean up all the files that were checked out before:
git clean -xfd

# Done!
Read More…

JRuby FileChooser example

I’m working on the next version of It’s All Text! and it needs a stand-alone editor server. I’ve had a couple false starts other languages but I’m thinking it should be Java or JRuby so that it is fairly portable without me having too much grief. In addition, installing Java is a little more acceptable to a random group of people than installing Ruby (at the moment, it may change in the future).

Read More…

Code Retreat

I had a wonderful time today doing a Code Retreat at my work.

The principle is simple. You spend 45 minutes pair programming with someone writing code for Conway’s Game of Life. When the 45 minutes are up, you delete all your code, take a break, and do it again with a different partner.

Read More…

Thematic featured images

I was wondering what the “Featured Images” box was when creating new posts and discovered that it’s a handy way to add images to a post. It auto resizes, crops (if you want), and can make it just “work” in your layout. The only drawback I’ve seen is I can’t use URLs for the image.

Read More…

Setting up CEDET/ECB for Aquamacs

Aquamacs 2.1 is now out.

UPDATE [2011/08/04]:

Aquamacs 2.3a (the latest at this time) has CEDET already in it; skip the part about installing CEDET. I still recommend creating the site-start.el file for CEDET but beware the differences between CEDET shipped with Emacs and the stand-alone version. When you get ECB, you need a version newer than 2.40, which at this time means getting the CVS version.

Read More…

bash: Checking a port number

Nucella lapillus

Ever needed to check if a given port number is valid in bash? It’s harder than it looks because if you accept any input from the user, you can’t use declare -i since it spews errors and aborts functions with malformed input.

Read More…

IAT on Cygwin

For those that use Cygwin on Windows, Mike Hostetler has a post detailing how to use Cygwin editors with It’s All Text!

Read More…

Two ways to improve OS-X...

I found this excellent article, Mac OS X SSD tweaks by Ricardo Gameiro, and have stolen two of the ideas for my non-SSD MacBook Pro laptop. I’ll cover all three, though, since I don’t agree with his hibernation trick.

Turn off “atime”

This is pretty simple. Setting noatime turns off recording of when files are accessed. I’ve never found a usage for the recording of file accesses. However, you may have a use for this behavior, so be warned.

To turn off atime then just dump this XML into /Library/LaunchDaemons/com.nullvision.noatime.plist.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
        "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <dict>
        <key>Label</key>
        <string>com.nullvision.noatime</string>
        <key>ProgramArguments</key>
        <array>
            <string>mount</string>
            <string>-vuwo</string>
            <string>noatime</string>
            <string>/</string>
        </array>
        <key>RunAtLoad</key>
        <true />
    </dict>
</plist>

Turn off hibernate

In the article, he suggests turning off hibernate altogether. I don’t like this. The hibernate is really handy if something goes wrong and you loose all your power.

There are two ways OS-X goes to sleep: suspend and hibernate.

The first is suspend. Information on the system state is stored to ram and the CPU is stopped. This is really fast to sleep and really fast to restore. The downside is that if the system looses power, it cannot restore; the ram is wiped clean.

The second is hibernate. Information on the system state is stored to disk and the CPU is stopped. The system is powered off. On restart, the state is read from disk and the system restarts as normal. This is slow to sleep and restore, but if power is lost, the system state is still safe.

OS-X, for laptops, does both. This means it is slow to shutdown, but fast to restore.

Obviously, if you are using SSD or if you want shutdowns to be fast (like I do, since I tend to shut my lid and carry around my laptop immediately), then you really don’t want hibernation to happen unless you really need it.

So I use SmartSleep by Patrick Stein. The only time my laptop hibernates is when the power is low. The best of both worlds.

Storing /tmp/ in ram

This recipe is nearly the same as Ricardo’s suggestion. I just added the code from Patrick Gibson’s comment.

This is two part; you need to create a shell script and a .plist file.

The shell script goes in /var/root/ramfs.sh. You must do a chmod a+x /var/root/ramfs.sh afterwards.

#!/bin/bash

set -eu

ramfs_size_mb=256
mount_point="/private/tmp"

ramfs_size_sectors=$(( ${ramfs_size_mb} * 1024 * 1024 / 512 ))
ramdisk_dev=$(hdid -nomount ram://${ramfs_size_sectors} | cut -d ' ' -f 1)
newfs_hfs -v 'Volatile HD' "${ramdisk_dev}"
mkdir -p "${mount_point}"
mount -o noatime -t hfs "${ramdisk_dev}" "${mount_point}"

# hide the volume from the Finder
if [ -e /usr/bin/SetFile ]; then
 /usr/bin/SetFile -a V "${mount_point}"
fi

# fix permissions
chown root:wheel "${mount_point}"
chmod 1777 "${mount_point}"

# EOF

Next you need to drop a .plist file in /Library/LaunchDaemons/com.nullvision.ramfs.plist.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <dict>
        <key>Label</key>
        <string>com.nullvision.ramfs</string>
        <key>ProgramArguments</key>
        <array>
            <string>/var/root/ramfs.sh</string>
        </array>
        <key>RunAtLoad</key>
        <true />
    </dict>
</plist>

I don’t recommend moving any caches or anything, as he mentions at the end of the article. Just having /tmp/ (aka /private/tmp/) will be an advantage. Well, except the X-Code thing. That’s probably useful.

Ciao!

Addendum: Reverting /tmp

I discovered that iDefrag2 needs to have /tmp be a real file-system to do it’s “No bootable CD/DVD required!” trick. After hashing it out with a helpful developer (Thanks, Chris!) we tracked it down to putting /tmp into ram.

To undo it, run these commands as root:

rm /Library/LaunchDaemons/com.nullvision.ramfs.plist
rm /var/root/ramfs.sh
mkdir /private/tmp2
mv /private/tmp /private/tmp2 ; mv /private/tmp2 /private/tmp
chown root:wheel /private/tmp
chmod 1777 /private/tmp

You should reboot immediately after this change.

After reboot, verify that /tmp and /private/tmp are set up correctly:

$ ls -ald /tmp /private/tmp
drwxrwxrwt 18 root wheel 612 Jun 16 09:47 /private/tmp/
lrwxr-xr-x  1 root admin  11 Jun 16 09:23 /tmp -> private/tmp/

Important: Verify that the /tmp symlink points to private/tmp not /private/tmp!

Read More…

Ruby Debugging

There is a ruby-debugger gem which is very handy for trouble shooting problems in a ruby script. The built in debugging is quite powerful and worth learning to use.

Read More…

Stupid Git Trick

This was one of those dumb things that I should have figured out earlier.

If you use emacs for editing then you probably have a customized .emacs file. Even if you don’t, your system is probably loading a boatload of features for emacs.

Read More…

Logging while monitoring a shell script

You may be familiar with redirecting the output of your shell script to a file using exec

However, what do you do if you want monitor the output while logging at the same time? I just figured this out (probably again, since I tend to forget things… which is why I’m blogging this).

Read More…

It's All Text! 1.4 (FF3.6 compatible)

I have just finished Firefox 3.6 after working like crazy since FF 3.6 came out.

Read More…

Firefox Fix

I have a tendency to switch my default browser every so often. I like playing with new toys.

I just switched from Safari to Firefox 3.5.5 and discovered I couldn’t stand the way external links open in new tabs though I wanted new-window links such as target="_blank" to open in a new tab.

Read More…

Smoking craters are good

Every wondered how to make bulletproof software? What tricks do the guys who build bank machines use to be sure their software doesn’t ever crash?

Look no further!

History

Tandem Computers used to make Non-Stop fault tolerant hardware and software. Their premier system was a million dollar Mainframe system. It could have up to 16 CPUS and 16 IO cabinets, each with 60 IO cards. Everything was in pairs. Each CPU was actually two cpus, if one disagreed with the other, they shutdown. All processes were doubled. All IO was doubled; two scsi cards, to two different scsi drives (mirrored) in two different cabinets, each with two power supplies.

Jimmy, the CEO and founder used to give demos where he would take the bank manager, or other high-muckety muck and show him one of Tandem’s live data-centers. He’d point at the screens and say, “You see those messages? That’s a bunch of transactions happening on these systems right here. We’re using them for our day-to-day work, right here.”

“Let me show you how reliable these systems are…”, he’d then pull a Colt .45 from his jacket and blow a hole in the side of one of the IO cabinets. The boom would usually cause the unsuspecting bank manager to leap for the nearest exit.

Jimmy would continue, “…and as you can see, while the system noticed that little hole, it isn’t actually stopping. Everything is re-routing around the damage I just did.”

Every mistake should leave a crater

So, how did Tandem make software and hardware that ended up in most of the newpapers and banks in the world? They used a simple secret; if something goes wrong, it should leave a huge smoking crater.

Basically, it works like this. Let’s say Dan the Developer makes a mistake; when the right situation happens then something divides by zero. When the divide by zero happens, if the software tries to recover without understanding why it happened, then it the software can actually make the problems worse. In addition, it may be the case that nobody will notice the problem.

However, let’s say that instead of hiding the problem, the divide by zero causes the whole software package to stop. The user will notice this. They will complain. The developer will be notified. It will get fixed.

This is one of the easiest ways to make sure your software is bullet proof. Make it all go boom! when something unexpected happens.

Read More…

RVM: ruby version management

I just discovered RVM, a tool for managing multiple versions of ruby on the same system. This is really useful on my MacBook Pro, since the built-in Ruby “has problems”. Such as having gems in weird locations which makes updating them difficult. Plus the fact that the OS X updater may clobber your changes without warning.

Setting it up is pretty easy and the versions of ruby installed are all yours, installed into your environment.

Yay!

This is doubly useful for me, since I need to work with multiple versions of ruby (1.8.X and 1.9.X).

Read More…

DWPS: iKlear

A quick Doctor What Product Suggestion: The iKlear Complete Cleaning Kit is great.

I thought at first that it was a stupid overkill for the price; I mean it only has a few cloths and some cleaning solution.

Read More…

Happiness is a warm SCM

Linus Torvald posted on his blog ”Happiness is a warm SCM“:

Part of the problem is that ‘git’ is such a flexible tool that you can use it in various modes, and mix things up freely. The whole distributed nature means that there’s no gatekeeper, you can do whatever you want. And the flexibility and power is good, but it does mean that it’s also easy to make a mess of it - the old UNIX philosophy of giving people rope, and letting them hang themselves with it if they want to. So it takes time for people (me included) to learn the rules that work. And it seems people are learning. And that feels really good.

Read More…

IAT in LJ

The Linux Journal’s Associate Editor Mitch Frazier has done a one minute video on It’s All Text! that is really handy to show what IAT can do:

Read More…

Scripting on Android

There is a nifty new project for the Android phone: Android Scripting Environment.

This lets you use Lua and Python to write scripts on Android.  Not quite the same as writing a whole application in those languages, but a great start!

Read More…

Useless Error Messages

I’ve had the misfortune of having to work on getting a product to work as an ASPX script instead of the CGI it was originally.

This is a misfortune in two ways:

  1. I’m not an experienced Windows developer.  The last time I used Visual Studio was when it was version 1 while welding a copy of the first edition of Charles Petzold’s “Programming Windows”.
  2. Windows is horrible to do anything out of the ordinary in.
Read More…

Lots of cool software cheap

If you haven’t heard of MacHeist, then you should go check it out right now.  It’s only good for four more days. What they do is sell a bundle for \$39 that includes lots of different mac software from different vendors.

They exact amount of software you’ll get depends on how many people sign up.  As each milestone is met, another package is unlocked. 25% of the $39 goes to one of their 10 charities (or split between all 10), your choice.

Read More…

Comparing "duh" sizes

The
NeXTStationUber geek-star Wil Wheaton blogged about the magnitude of a “duh” moment he had recently.  Warning: avoid Wil Weaton’s post if don’t want spoilers for the D&D campaign “Keep on the Shadowfell”.  My post doesn’t have any spoilers, though.

Go read Wil’s post so I can properly compare magnitudes with Mr. Wheaton.  I’ll wait.

Okay, pretty funny, right? But I think I can one up that.

Read More…

Wifi Tethering via the Android

Warning: This article is very out of date and no longer applies.

In my post ”How to beat the iPhone” I mentioned that an ideal device would be a portable wifi hotspot.

Well, now one exists for the G1: android-wifi-tether project.

Read More…

New Look!

Alrighty! I have me a new look and it is FRESH. 😉

I got sick of working around some of the problems in sandbox. I don’t want to maintain an offshoot of an existing theme (or worse, code my own); I’ve done that before it I don’t like it.

So using some simple patches to add some extra semantic markup to the default wordpress theme, I created this page.

Read More…

Aquamacs vs. Dvorak-Qwerty layout

I love Aquamacs Emacs. It totally rocks.

However, I use the Dvorak-Qwerty keyboard layout (AKA DQ) and Aquamacs doesn’t like the command key bindings that the DQ layout uses. DQ is dvorak except when you use the command key.  Then it becomes QWERTY. This was invaluable when I first started using OS-X since it matched all the docs.

Read More…

Learning Java

Since I have an Android phone I have to write software for it.  To write software for the phone, I have to use Java.

I’ve been looking around for something like Dive Into Python but for Java.  So far, no luck.

Any recommendations would be very welcome.

Read More…

Google Phone

Robin and I both got Google phones while in New York over the holidays.  She bought a G1 and I ordered the ADP1.

I’ve been working my way through ”Hello, Android” by Ed Burnette.  So far it’s been decent.  You can get 30% off (till 2009/1/31) using a special code.  I bought the PDF and paper book for less than Barnes and Nobels is selling it down the street.  Good deal, I think.

Read More…

IAT made Network World

Cool!  It’s All Text! made it into Network World in 10 Firefox add-ons for better browsing.

I’ve had software in magazines before (actually shipped on CDs) but this is the first time in an English magazine.

Read More…

Switched from YUI to jQuery

I just switched my (rather limited) JavaScript from YUI to jQuery.

jQuery took a little (a couple hours) to learn how to write something close to idiomatic code. My new code is much much smaller and easier to read.

Read More…

Xen Networking

Gerf.Org just switched to Xen. It’s running in a domU on hardware that is massively more powerful than it used to be.  The original hardware (until about 3 years ago) was a 333Mhz box with 20gigs of disk-space. Since then it has been running on newer hardware. However, the hardware was flakey and getting flakier.

Read More…

Designed For Reliability

I used to work for Tandem.  These computers were amazing and the only thing that’d take them down was human error…

Here’s a “Daily WTF” about the Tandem computers. The comments are fun, too: Designed For Reliability

Ciao!

P.S. Yes, I’m having fun with the “Press This” feature in Wordpress 2.6.

Read More…

OS X: Make an ISO

You can use Disk Utility to create ISO images in Mac OS X:

  1. Click “New Image+” on the tool bar
  2. For “Image Format” select “CD/DVD Master”
  3. For “Encryption” leave it at “none”
  4. Rename the resulting .cdr file to .iso

I found this handy hint on the Internet as well. To convert a .dmg file, you can use hdiutil to convert it!

Read More…

BBS the Documentary

There is this great documentary called ”BBS the documentary” by Jason Scott.  It’s an amazing documentary about computer bulliten boards and it’s 5 and 1/2 hours long with tons of extras.

For those who don’t remember BBSes: You would use a modem to dial up a computer system that had one or more modems and you could send messages (like email) and download files (like ftp) and play online games.

Read More…

The web belongs to the viewer

The single most important fact that web site owners forget is that the web belongs to the viewer.  It doesn’t belong to the web site owner; they don’t control how the viewer will use the site.

This video is a perfect example of this (3 minutes, 30 seconds):

Read More…

msnbot: the stupid bot

Generally, most people with websites want to have their sites indexed so that people can find them.

However, if the bot is really really stupid, then maybe it isn’t in your best interest.

My experiences with msnbot have been pretty much negative.

This site has 15% of the searches supplied by Microsoft Live Search. Not an insignificant amount.

However, at this moment, msnbot and it’s entire class C networks are being blocked from my server because otherwise they’re going to DOS my poor box into oblivion.

In case you want this rule for yourself, here you go:

iptables -A INPUT -s 65.55.208.0/24 -j DROP

I checked on my site and discovered that it was having trouble. A crew of at least 20 bots (ip addresses 65.55.208.180 through 199 inclusive) were requesting urls at about 1 a second.

Not a lot of traffic unless you notice that the URLs they were requesting were all TRAC source and changeset URLs. These are cpu, disk and io intensive URLs and I have them in my robots.txt as URLs that no bot should crawl.

I immediately went to the webmaster forums to see if others have had this problem (they have) and to complain.

Apparently, bots aren’t all they have trouble with:

“We apologize, but an unknown error has occurred in the forums. This error has been logged.”

Reading through the forums, it looks like msnbot has a really hard time reading the robots.txtfiles and honoring them. Really odd because I wrote arobots.txt parser just for fun way back in 1990-something and it’s really easy.

Anyway, if you use Microsoft Live Search, I’d suggest using something else. Maybe something like clusty.com1 DuckDuckGo2.

Ciao!


  1. Yup. I work for them. I worked for the company which owned clusty.com before clusty was sold off.

  2. I don’t work for DuckDuckGo.

Read More…

Mac Tricks: Shell Script Dialogs

As you may know, I have had a MacBook Pro (15” - glossy) for a few months now. I am starting to feel pretty comfortable in it and have started to learn more of the advanced features that I don’t need to get things done, but because I like learning how stuff works.

In this case, I discovered how to create dialogs from the command line or a shell script. In Linux, I’d use gdialog or something similar.

On the mac, I’m I discovered osascript. This is a way into the AppleScript goodness inside OS X. You can get more documentation, like most things in the command line world of OS X, using man.

An example creating a ‘stop’ dialog:

osascript -e 'tell app "System Events" to display dialog "A stop dialog with only one button." buttons "OK" default button 1 with title "and a title" with icon stop'

I would assume there are other values you could feed in for the icon, but I haven’t a clue and I can’t find it in Script Editor Library. How annoying. [Note: I did end up finding it in the Apple Script Language Guide, see below.]

Here’s a version with multiple buttons:

osascript -e 'tell app "System Events" to display dialog "A dialog with no buttons and the exit code will tell the script which button was pressed."'

If the exit code is 0, then “OK” was pressed; otherwise it was canceled. Errors go to stderr, so you can catch them and hide them.

Ah-ha! I found the missing display dialog documentation. It was in the Apple Script Language Guide. Excellent.

Here are some tutorials aimed at AppleScript beginners (and I mean beginners; I’d much prefer a “Dive into” style tutorial):

Read More…

X-UA-Compatible and IE8

There is a new META header being proposed called X-UA-Compatible. It was thought up by Aaron Gustafson and has been added to IE8.

This is a flag for browsers to change how they render the web page, not by standards that are being followed, but by the browser that it is known to work with.

Read More…

Bang! Bang!

So, me and my wife got home from Ikea with a new Billy bookshelf for the dinning room (aka, book room #2 — book room #1 is the living room). We lucked out and found a spot nearly in front of our house, right on the outside of the curve that our house in on.

We unloaded the shelf (it weighs a bloody ton) and had just finished getting it together when I heard a bang noise. I thought perhaps the storm door was open and the wind pushed the door open or shut.

Read More…

My laptop has died

My laptop has died a horrible death and I’m not happy about it. I bought it about 3 years ago from Linux Certified, way back when Linux laptops was a novel concept.

It flat out won’t power up. There is power from the power cord (checked it with a multi-meter), but the light won’t light, the power won’t pow and the battery won’t batter.

This will slow down my blogging, emailing, and working on It’s All Text!

This comes at a bad time since I just bought a house. *sigh*

On the plus side, there are two companies (EmperorLinux and System76) selling laptops with Linux pre-installed. And Apple’s MacBook Pro runs Ubuntu (and even under Parallels).

I have to admit, I like the Apple designed hardware. I’ve been a fan since I took apart my old clamshell laptop. It was all very clever and well built. And I can tell the newer stuff is even better.

So, does anyone have any suggestions or ideas?

Ciao!

UPDATE [2007-11-29]: I have ordered a Macbook Pro and Parallels. I have my Ubuntu CD and stickers ready. I still have to pry my hard-drive out of the old laptop and hook it up some how to recover my old data. *sigh* I wish my laptop hadn’t died.

Read More…

GTD and Mutt

I found this article about Getting things done with mutt. It talks about using the techniques from David Allen’s productivity book ”Getting Things Done: The Art of Stress-Free Productivity. I’ve been reading GTD for a week now (taking my time, you know) and think it’s pretty interesting.

Since Mutt is my favorite email client, I spent a little playing with it and making changes. I’m using a different editlabel script and my way doesn’t require patching and recompiling mutt.

Here are my muttrc changes:

### GETTING THINGS DONE ###
# http://blogs.techrepublic.com.com/opensource/?p=106&atag=nl.e011
# http://auriga.wearlab.de/~alb/other/mutt-labels/
set editor='emacs'
set move=yes
set mbox='=archive'

unignore X-Label:  # make sure to display X-Label on each message
color header red default '^X-Label:'
mailboxes =ACTION
mailboxes =RESPOND
mailboxes =WAITFOR
mbox-hook =ACTION  =archive
mbox-hook =RESPOND =archive
macro pager \Ct  "<exit><tag -entry></tag><tag -prefix><mark -as-new><tag -prefix><save -message>=ACTION<enter>"  "Mark message as ACTION"
macro pager \Cr  "<exit><tag -entry></tag><tag -prefix><mark -as-new><tag -prefix><save -message>=RESPOND<enter>" "Mark message as RESPOND"
macro pager \Cw  "<exit><tag -entry></tag><tag -prefix><mark -as-new><tag -prefix><save -message>=WAITFOR<enter>" "Mark message as WAITFOR"
macro index y "</enter><enter -command>set editor=\"~/comp/editlabel\"\n\
<edit><enter -command>set editor=\"emacs -nw\"\n\
<sync -mailbox><next -undeleted>" "Edit Label"
macro pager y "<enter -command>set editor=\"~/.mutt/editlabel\"\n\
<edit><sync -mailbox><next -undeleted>\
<enter -command>set editor=emacs\n" "Edit Label"
macro index \Cy "<limit>~y " "Limit view to label"

set index_format="%4C %Z %{%b %d} %-15.15L %?M?(#%03M)&(%4l)? %?y?{%.20Y} ?%s"
#### END GTD ###

editlabel also has full readline editing and history, which is nice. I haven’t added tab-completion from the history; I’m not sure if I will or not.

My editlabel also has the advantage that you can delete a label just by deleting the line; ^a ^k if you use emacs.

Note that if you use the above, you’ll have to replace the occurrences of “emacs” with whatever editor you use.

I just found a similar post: GTD with Mutt

I like my editlabel better, even if I’m using Python’s evil os.system(). But that narrow-wide trick is neat.

Ciao!

  1. UPDATE 2007-10-08: Added mark-as-new when saving, so that they will attract my notice via the mailbox changing.
  2. UPDATE 2007-10-09: Fixed the mark-as-new stuff…had to use tagging to make it work.
  3. UPDATE 2010-03-01: Updated ‘y’ macro based on feedback from Mark Fardal.
  4. UPDATE 2014-08-11: Fixed broken formatting due to age. Fixed some minor typos.
Read More…

It's All Text! v0.8.0

I have just released version 0.8.0 of ”It’s All Text!”, the Firefox extension that answers the age old question, “What happens when you give a yo-yo to a flock of flamingoes?”

Read More…

HX-20

I was walking through Squirrel Hill today with Robin and my Dad. There was a house with some junk on their porch and a sign saying, “For sale. $1 each.” I looked through the stuff and found an Epson HX-20!

Oh. My. Gawd!

When I was in High School a guy named Randy had a TRS80 Model 100 portable computer (made in 1983). It was the coolest thing. I got him to loan it to me so I could write a small text adventure (only like 6 rooms, but a huge deal at the time).

Read More…

Mashups and JavaScript Security

I found this excellent video Gears and the Mashup Problem of Douglas Crockford (discoverer of JSON) talking about the security problems inherent in Mashups and of JavaScript as a whole.

He proposes a solution involving what he calls vats; a self contained JavaScript interpreter with limited communication to the page. The JavaScript in the page would be the only trusted code running and the code in the various vats would not be trusted.

Read More…

Wordpress User-Agent

Well, I just got a nasty shock!

I got in at the tail end of a thread about the new update notification feature in WordPress 2.3.

One of the comments I read kept ricocheting around in my head. Matt Mullenweg said something about the dashboard RSS feeds transmitting my blog URL. I thought, initially, that he meant the IP address was revealed. But the more I thought about it, the weirder it seemed.

So I started looking through the source and discovered that every service that made an HTTP request had it’s own version of User-Agent with, at minimum, the version number and usually the blog URL!

I understand security well enough to know that this won’t suddenly give a hacker the ability to hack my system. However, what it does to is give out more information I give anywhere else in my site.

In addition, if I was a hacker and wanted to crack a large number of blogs, then ping-o-matic or some other place that gets this information regularly would be my first target. I’d then have a reliable list of blogs, with version numbers, that I could launch attacks on. It’s even better than using searches!

And there is no reason to give this data away, at all.

I have submitted a bug asking for a single function to generate the user-agent strings. In addition to improving the code, this would allow for easy overriding in a plugin or something similar.

Meanwhile, I’ll probably hack these up in my copy of Wordpress.

I have to admit, I’m disappointed.

Ciao!

UPDATE 2007-09-25: A couple of articles: wank.wordpress.com & Slashdot

UPDATE 2007-09-27: I submitted bugs and patches (#5065 and #5085). There is also a bug about adding an option to the privacy page (#5066). Isn’t open source wonderful?

Read More…

Site Redesign

I have redesigned my whole site. While a lot changes are visual, there are even more changes in the way the unseen back-end parts have changed.

Previously, I had a modified copy of the default WP 2.x theme (which is based on Kubric theme). It was reasonable markup, but I spent a lot of time modifying the classes and adding containers to hang my CSS off of. In addition, tracking the changes to the default theme was a pain.

Read More…

WordPress anti-spam recipe

Here’s a simple recipe to cut down on comment spam in WordPress. I assume you have basic understanding of Unix commands or can translate them to windows.

Read More…

SimCity DS Landmark unlock codes

Yeah, I bought SimCity DS and found that it had an unlock code for the Washington Monument (a GameStop Exclusive!).

I figured that there were more and searched the web. I found a list, but it was missing one of the monuments (#12). Being the kind of person who can’t stand a missing bit of information, I went looking. I finally found it, but it took some work because none of the lists had the number next to them. So I compiled a complete list to share with anyone else who gets SimCity DS.

Read More…

What language would you like it in?

So I have finally submitted It’s All Text! to Babelzilla, the Mozilla translation site. It took a little work to get in, though. There isn’t anything so simple that I cannot break it. :-)

Their system automagically created a discussion thread and it’ll track changes as I upload them. They have mixed a lot of technologies to produce something pretty spiffy. I know how hard it is to mix this stuff and the fact it works well is amazing.

Read More…

It's All Text! v0.6+

[screenshot]

Get It’s All Text!

I wrote It’s All Text! for myself. When Firefox 2.0 was released it broke MozEx so I went looking for a replacement. The others weren’t very good. So I set about fixing MozEx. It was then that I realized that MozEx had way more stuff in it than I needed and some parts were just a pain to maintain.

The author of MozEx got it working with FireFox 2.0 eventually. But I had this itch because I saw things I can improve.

Now it’s three months later and I’ve released version 0.6.1 now that Addons is back. This will be my release candidate for 1.0 because I have fixed the four most annoying problems:

  • The edit button is in the right place. If it isn’t perfect, it’s really close. Even for GMail and Wikipedia.
  • Right clicking on the edit button lets you pick a file extension.
  • When the user first starts or the editor isn’t in the right place, it explains to the user what happened and what to do about it.
  • The rules for when and what to refresh finally seem right. At least for me… ;-)

The last big bug I want to do something for, even if I can’t fix it, is the “Mac OS X select an editor that actually is a .app directory” problem. It’s hard for me to work on because I have to borrow my wifes Mac to work on it.

The versions up to now, as flawed as they have been, have actually gotten some really good feedback both in ~comments~ on this site and on addons and even from blogs in Switzerland and Japan! Note: I have been told that the addons comments are still in the process of being moved from the old site to the new one.

Jason Barnabe, the author of the excellent Stylish extension for Firefox has helped design an API for It’s All Text! so that you can use an external editor in Stylish or in any other extension that decides it wants to support It’s All Text!

Finally, if you design a website, you can add the attribute itsalltext-extension to any textarea and it’ll be the default extension used for that textarea (don’t forget the leading dot, .). You can see it below in the “Leave a comment” box.

I want to thank everyone who has given me all this great feedback. Even people telling me it doesn’t work is helpful. Every comment spurred me on to make it better so I really owe it’s current level of usability to all of you. Please, give yourselves a hand.

I can’t wait to see what feedback I get next. Yay!

Ciao!

Previously: It’s All Text!

EDIT (2007/04/04): I’m so stupid. Thankfully, Robert Daeley explained exactly what I didn’t understand about Mac OS X. I need to use /usr/bin/open on Mac OS X. Now that I understand what open is and why it should be used, I will finally have that part of Mac OS X fixed in short order. Now I just need to figure out make the close button not be display: none in preferences. Grrrr.

Mentions (till Addons gets trackbacks):

Read More…

A bug report from Japan...

Wow! I found a blog post talking about It’s All Text! on a blog called Another 朝顔日記 written in Japanese!

According to babelfish, the author found a silly bug in It’s All Text! (I left out a var declaration) and is explaining the way to fix this. Neat!

Read More…

Containing blocks and offsetParent: the secret of position absolute

Ever used position: absolute in CSS or JavaScript? You probably got it to work reliably. I have in the past. These were pages that I controlled in their entirety and it worked fine.

But when I tried to use it with It’s All Text! for the gumdrop edit button which in injected into any web page that has a textarea, I kept having problems. It was driving me batty. I found something that worked on my simplistic test cases, but it wouldn’t work on gmail. I got it to work on gmail, but it stopped working on trac installations, or Wikipedia. Or if I got it to work on one of those, it’d fail to work on my simplistic test cases.

Read More…

Cleaning up parts of the blog

You may have noticed that I’ve been cleaning up parts of my blog. This is because there were some things that really bugged me: My template was too verbose and was too far off default, my colors weren’t and still aren’t ideal, my text formatting was done through a plugin I increasingly came to dislike, and I moved my feeds over to feedburner.

Read More…

It's All Text!

Have you ever had to fill in a form on a web page and wished you could open it in an editor? If you use lots of blogs, post lots of comments or file many bugs then you probably get annoyed at the lack of true editor commands.

I’ve seen some solutions that embed a JavaScript editor into a textarea on demand. Generally, I don’t like them. They are re-inventing a wheel. Especially since I like my particular flavor of wheel, Emacs, though I have no problem with other flavors.

So when I discovered the Firefox extension MozEx I was a very happy hacker indeed. But as time went on I didn’t like the way the extension was going. It was trying to solve a problem I didn’t have; it wanted to add handlers for things like ssh://, etc. and I didn’t need that. I needed an external editor!

Read More…

Making JavaScript transparent

A disclaimer: I’m writing this just to share (and record for myself) this one stupid trick in JavaScript. While I’m here, I thought I should kvetch about most JavaScript usage.

First, the stupid trick.

Have you ever been on a page and you try to control-click or right-click on a link only to discover that the link is something stupid? Such as:

javascript:window.open(‘http://someurl/’);
The underlying HTML for this looks like so:
You should click on this:
<a href="javascript: window.open(’http://someurl/’); ">link</a>

What this is is a popup link. When you click on it and it’ll pop up a new window. It isn’t a real URL. It can’t be opened in a new tab. It cannot be bookmarked. It cannot be saved. It doesn’t work if JavaScript is disabled or has a bug in it.

The solution is one of these things that should be obvious once it’s explained. Instead of making the href useless by filling it with the javascript: junk, you use a real URL. And then use the onclick attribute to fetch the href and open it in a new window.

Example:

You should click on this:
<a
    href="http://someurl/"
    onclick="try{window.open(this.href,’_blank’);
               event.returnValue = false;
               return false;}
               catch(e){event.returnValue = true; return true;}"
    >link</a
>

This will work even with JavaScript disabled. It’ll work even if I made a mistake in the JavaScript. The event.returnValue = boolean and return boolean parts are important. If you return false then the browser will assume that the onclick event isn’t handled and won’t continue. If you return true or don’t use return, then the browser assumes that you didn’t handle the onclick event and then do the normal thing (open the link). And IE 7 needs the event.returnValue and won’t hurt any other browser.

Now, onto the kvetch.

Notice that this isn’t much harder. Notice how this is easier to validate. Notice how it delivers to the user the expected behavior.

Why isn’t this done more often. I hate it when I visit some site, hover over the link to see the URL and get JavaScript junk instead.

This requires more work when you have a complicated URL to generate, but with the ability to change the DOM tree directly there is no excuse.

Keeping everything working the way your user expects it to work is an important principle in user interface design and engineering. Ignore it at your peril.

UPDATED 2006-1-12

Okay, for those keeping score, IE 7 continues the tradition of sucking.

I can add another bug to IE 7’s growing list. I tried to make a simple test case. But when I make it simple it starts working correctly. Bah. I don’t have enough patience or desire to do this much work — for free — for a company with as many employees and dollars as Microsoft — for a browser I don’t own and only use to find and fix bugs like this.

Basically, under certain circumstances, onclick’s return value is ignored. In this case, we had an A tag that used the trick mentioned above. So that meant the popup url would appear in both the parent window and the popup window.

The work around? Set event.returnValue right before returning. Bleh. The code has been updated.

EDITED — Related links:

Read More…

Cosmic Wimpout for the Palm

CWimp for the Palm

Way back when, I wrote a version of Cosmic Wimpout for the palm.

The page that had the links to the sources, the bug tracker, etc. have been slowly decaying. Since I have moved to a new webpage I decided to move Cosmic Wimpout over to Trac.

Link: CWimp on GitHub

Maybe someone will want to work on it. Or maybe I’ll buy a new palm one of these days. I heard rumors that Palm runs Linux or something like that.

Ciao!

UPDATE 2011-03: I have moved it to GitHub instead of hosting it locally. This project is really dead, but if it still works for you, great!

Read More…

Moving to a blog

My first web site went live when the Mosaic (The original web browser; made by NCSA.) web browser was released.

My website, my skills and my interests have all evolved over the years. I have tried things like Zope, PHP, server-side includes, and even Front Page.

The problem is: I really don’t want to have to manage the nuts and bolts of my site.

Read More…

My older projects have been moved.

This is really just administrata, due to my recent move to wordpress.

I had been moving my stuff over, bit by bit into a Trac installation (linky) but some things didn’t really fit into it. One of these days I might make a Trac for all my miscellaneous projects. Meanwhile, till then, here is some links to these old unloved projects.

Read More…

docwhat

The personal blog of Christian Höltje.
docwhat docwhat contact