Vim tabs for Ruby

I’ve been annoyed time and time again by size-8 tabstops, mostly in when vim autoindents. In some languages, I’m happy to have ai on, but it’s frustrating to occasionally find a huge tab in my indents!

The two things you need to set are tabstop and shiftwidth.

:set tabstop=2
:set shiftwidth=2

Now, vim does its autoindenting right.

There’s also :set softtabstop .. but I can’t really tell what it does. I figured these things out from this place, but it doesn’t quite seem to be right, as my softtabstop probably isn’t set to 2, but hitting tab only indents me 2 spaces.

I also ran across the ability to just type :set and find out what things you’ve set up in vim at the moment; that’s kind of nice. It looks like it doesn’t deal with a lot of defaults, as I cannot find “softtabstop” in there, which is probably set, but not by any manual setting.

So, I’ve typed these in.. how do I get them to stick forever? I’m going to put them in my vimrc. On a unix system, this would be in ~/.vimrc, and on Windows, this should be in $HOME/_vimrc or in $VIMRUNTIME/_vimrc. Your HOME one will override your VIMRUNTIME one (the vimruntime one is probably somewhere like C:\Program Files (x86)\Vim7x\_vimrc).

You can go into them and just drop your set commands inside to make for nice indentation.

Productivity; sweet productivity!

Three things.

WordPress FTP Madness

WordPress does not need you to have an FTP server. If you’ve been trying to update things and it keeps asking for your FTP server, and then you’re thinking “but I own the box it’s hosted on and that’s where my files are.. why can’t I just update? Why do I need FTP?” Then you’re just like me about 15 minutes ago. What you need to do is change the owner of your wordpress directory (and all subdirs and files) to the same as the user that your apache webserver runs as. This will probably be ‘www-data’ if you’re on Ubuntu. This problem comes up because Wordress, running in your webserver, doesn’t have the ability to write to certain directories it needs to – so it asks you for FTP access to them, which it thinks would be a reasonable way to go about it. It probably is, in some cases, but not ours!

What did I do to fix it? I went to the directory above my blog folder (so, I was inside of ‘~/public_html/’ on my server) and I ran

chown -R www-data blog

This will CHange OWNership Recursively to www-data on the directory blog (and therefore, all of its subdirs and files). You can check what user your server runs as by going to /etc/apache2/envvars — you should be able to see it exporting APACHE_RUN_USER and APACHE_RUN_GROUP, probably as www-data.

Once I’d done this, I hit refresh and wordpress worked as desired! I can now update things and not grapple with FTP questions I don’t have answers to.

WordPress Syntax Highlighting

Now that everything worked so darn well, I went to this place and installed SyntaxHighlighterPlus. There’s some annoying things about it (I don’t really want to see line numbers, and the colour scheme is hideous) but it allows me to have code that’s worlds prettier in my posts.

Be careful about googling for configuration options! There’s a different SyntaxHighlighter out there, which this is just integrating into wordpress. The syntaxes used for inserting code into your blog are very different between the two and the non-wordpress one has a lot more options available within it. I may see what I can do to extend what I’ve got, or just find something else that does the trick better.

Pretty Permalinks

I’ve been frustrated by having ‘?p=##’ style links for a while now, and tried going into Settings->Permalinks and changing my format — but whenever I did it, wordpress would give 404 for the pretty link. The old link continued to work, but wordpress would not set pretty links for some reason. A bit of googling told me that you need to have apache’s mod_rewrite enabled in order to use pretty links! So I went to /etc/apache2/mods_enabled.. and mod_rewrite wasn’t there. That’s a good sign, means that is probably the cause. But how do I enable it? Google wasn’t helpful — most recent results were from over a year ago! Everyone was telling me to go edit files and touch them and such, and I know apache has some newfangled tool for enabling modules.. what was it? More googling. a2enmod. You should use a2enmod to enable mod_rewrite.

So, sudo a2enmod mod_rewrite.

Then… it still doesn’t work! That’s because of two things. First: You have to reload Apache’s configuration settings. You may have just been told by the a2enmod command to run ‘/etc/init.d/apache2 restart’, but that’s not a great idea because it actually restarts the process, which is ugly. Instead, run ‘/etc/init.d/apache2 reload’ (remember to use sudo) and it’ll cleanly reload the config files without a restart. The second reason is bigger: you’ve got another change to make. You’ve enabled the module, but you haven’t actually given apache the directives to allow it to make changes to your site’s URLs – so let’s do that. Go to /etc/apache2/sites-enabled/ and sudo vim (or gedit, nano, whatever) the symbolic link there, that leads to your website. It should look a bit like this:

ServerAdmin carss.w@gmail.com

DocumentRoot /home/wcarss/public_html
<Directory />
        Options FollowSymLinks
        AllowOverride None
</Directory>
<Directory /home/wcarss/public_html>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
</Directory>

Change the ‘AllowOverride’ directives in the first two Directory entries (the blank one and the one for your site’s document root) from ‘AllowOverride None’ to ‘AllowOverride all’. The result should be:

ServerAdmin carss.w@gmail.com

DocumentRoot /home/wcarss/public_html
<Directory />
        Options FollowSymLinks
        AllowOverride all
</Directory>
<Directory /home/wcarss/public_html>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride all
        Order allow,deny
        allow from all
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
</Directory>

That’s all there is to change. Now you’ve got to run ‘/etc/init.d/apache2 reload’ once more, and then try our pretty permalinks. Should work dandy!

Conclusion

That was a fun detour and I’ve got a prettier, more functional blog for it; but it certainly didn’t advance my 4chan scraper, get any of my 3000 paper written, advange my 1500 marker, or even get my overdue philosophy paper done. Alas, you can’t have everything at once. 🙂

Auto

Google has united the technologies behind the best competitors at the Grand Challenge, and crafted something amazing.

The thought of a self-driving car is about as revolutionary as a horseless carriage – but we’ve been expecting it in science fiction for a long time now. The advent of this technology in a near-to-commercializable and highly reliable version makes relevant a discussion of the possible effects.

Transport of Goods

Trucks have very low visibility. Truckers have to stop to eat, stop to use the washroom, stop to sleep, and can make mistakes. For all of this, they have to be highly trained and likewise, highly paid. Materials and objects need to be sent from one place to another, and always will. Google’s automatic cars would remedy nearly every one of these issues. Trucks could drive faster, with no breaks, without mistakes, without a per-truck hourly fee of a driver.

It seems likely that this is the first place where automation will strike. The trucking industry is entirely about moving goods, and any company willing to put vehicles onto the road that doesn’t have the cost of drivers, doesn’t lose packages to theft or accident, and that can send and receive faster than its competitors by virtue of not having pee breaks will outperform its competitors. Any failing competitor will need to change to the newer model, and the unions can’t do anything about it. They will become, sadly for them, irrelevant.

The chief obstacle is laws, which are hazy on whether or not a driver actually needs to be in a vehicle at the time it is being driven.

Transport of People, Public

Buses and Taxis are a huge amount of very serious business. Steps toward automation have already been taken – bus ticket purchases are largely done online, and there are systems like UberCab in SanFrancisco which allow you to automatically request the nearest black-car taxi to your location, provide the destination to the driver, show them approach on google maps, then confer payment through credit card and email you a receipt. No money changes hands, no talk is had with the driver if you don’t wish it. Everything is automatic. All that’s left to do is drop the requirement of having a driver.

Buses have a similar set of arguments to Trucks. Less need to stop, no one to pay, but most importantly: much higher visibility and no mistakes. Imagine a world where bus crashes didn’t happen. Wouldn’t it be great? A computer system can guarantee the best possible response to any situation — human eyes, reaction times, hands, and level of knowledge just can not compete with the sensibility of a properly designed automatic system.

Taxis are the same deal on a smaller scale, but consequently have a higher proportion of savings. More drivers for fewer people means that the economic pressure to cut drivers out of the mix is far higher than on buses. The risks associated with mistakes are similarly high – but perhaps a taxi driver’s ability to ignore particular rules of the road when they seem unimportant is a powerful part of a company’s ability to get people to places fast. Regardless, I think that taxi automation will come somewhere between second and third.

Transport of People, Private

Your city. Your neighbourhood. Your road. Your car. No drivers, just vehicles going places. This comes down to an extremely personal level and raises some troubling (and fun) questions. For example, let’s say you’re drunk. Should your car stop you from driving at all, and force you to let it handle everything? What if you’re not really drunk, but you’ve just had a /single/ drink? Further questions about the limitations of driver-control have to be asked — if studies end up showing that drivers are reliably worse than cars themselves, should we ever be allowed to drive? Maybe only in inclement weather, or maybe that’s a particular restriction! We can’t know a lot of these things yet, and it’s a scary thought that so much could hang in the balance.

Then there’s the question of bugs. What if something is wrong somewhere in the software? Certain types of software can be mathematically proven to be free of entire classes of error, and it would be marvellous if those sorts of techniques could be used here. If they cannot though, who will take responsibility for a failure? Will the engineer who wrote the code shoulder the blame for a bug found in a self-driving car’s software? What about the company they work for? Will the driver share blame for not overtaking the car when it clearly does something wrong? These are all valid questions. Perhaps an unintended consequence will be that the standardization of software creation, and the guarantees of safety and testing that have been called for so long in our industry will finally materialize, and software development will reach a renaissance.

😛

Synergies

There’s some cool thoughts that arise from all of these things together — other sorts of vehicle may end up being created which we’ve never conceived of and would be impossible without some kind of automated driver. Vehicles will be able to travel at far higher speeds, nearly everywhere. Traffic jams can, and will be erased from memory. Instead we’ll have streams of high speed, unmanned vehicles navigating our graph of roads, communicating to find the optimal solution. Two cars driving down a highway late at night side by side could cooperate if a deer emerged onto the road, one swerving in a mechanically perfect fashion while the other moved out of the way of the primarily affected vehicle. None of this is possible today, but certainly will be soon.

Conclusion

Could this change destroy our sense of freedom? Will it just add another failing component to the complex system that is the modern automobile, which some (but not many) people actually use? Maybe it’ll be good enough to use on sunny days in certain locales, but not everywhere. Time will tell. For now though, Google’s got their autos driving around San Francisco, and I think it’s very cool stuff. It’ll affect jobs, the economy, and our personal lives profoundly.