July 25, 2008

Installing Mechwarrior 2 in DOSBox Under Mac OS X

Drew Stephens @ 11:17 am

Put the Mechwarrior 2 CD into your Mac’s CD drive; it will show up as two mounted discs, one for the audio and one for the game data. The disc I have is for Mechwarrior 2 v1.1, so the game data is mounted as /Volumes/MECH2_V1_1; if you have a different version, the mount point will be slightly different and subsequent commands should be adjusted to match. To access the disc in DOSBox, you must mount it. Start DOSBox and type:

mount d /Volumes/MECH2_V1_1 -t cdrom -usecd 0
You will also need a place to act as a fake `C` drive, where the game will be installed. I created a directory `dosprog` in my home directory and mounted it in DOSBox like so:
mount c ~/dosprog
To install the game simply go to the mounted CD and run the setup:
d:
INSTALL.EXE

Follow the installation program, clicking happy things like “yes”, “continue” and “full install”. Choose the top-most audio devices in the list. Next, download the NOCD crack from here, unzip it in Mac OS and use the files from the crack to replace those in your dosprog/mech2 folder. Now, back in DOSBox, go to the c:\MECH2 directory and play:

c:
cd c:\MECH2
MECH2.EXE

See also: Vogons(http://vogons.zetafleet.com/viewtopic.php?t=4454)

June 25, 2008

Apache Won’t Start: No space left on device

Drew Stephens @ 2:10 pm

I doing some development involving Apache handlers which involves lots of restarting it and occasionally Apache shutting down uncleanly. After numerous restarts, the webserver refused to start printing the following in the error log:

[Wed Jun 25 18:57:11 2008] [emerg] (28)No space left on device: Couldn’t create accept lock

After being confused because there certainly is enough disk space, I Googled for other possibilities and it turns out I had hit another limit, that of active semaphores. When some of my processes were killed, they died uncleanly and didn’t clean up their open semaphores, filling the maximum number available to my user. It’s easy to tell that this is the root of the issue; running ipcs -s showed a list of 95 open semaphores. Clearing them up is just as easy:

~$ for id in `ipcs -s |awk '/USERNAME/ {print $2}'`; do ipcrm -s $id; done

That prints the list of semaphores, grabs the ID ({print $2}) for lines containing USERNAME (your own or that which the webserver runs under) and then ipcrm’s those semaphores.

June 12, 2008

Subversion diff with vimdiff

Drew Stephens @ 1:03 pm

Side by side diffs are much more legible and useful than those in unified format or any other linear diff. By default, the svn diff command presents output in the unified format, though it has an option, --diff-cmd, which allows you to specify the program that will perform the diff. Passing vimdiff as the diff command doesn’t work as the options passed by svn diff are a bit complicated:

~/code/perllib/MG$ svndiffvim Proxy.pm 
Index: Proxy.pm
===================================================================
-u -L Proxy.pm (revision 21095) -L Proxy.pm (working copy) .svn/text-base/Proxy.pm.svn-base /tmp/svndiff.tmp

Subversion is telling diff to output context (-u), show pretty names for the files (-L) and then the two files to diff. To make this work with vim, we simply need to cut out the extra options. To do so, I wrote a simple script:


#!/bin/bash
shift 5
vimdiff "$@"
 

I put that in ~/bin/svnvimdiff and now I can do svn diff --diff-cmd ~/bin/svnvimdiff Proxy.pm and view the diff in vimdiff. Since this is a command I use often, I aliased it in my .bashrc:


alias svndiffvim=’svn diff –diff-cmd ~/bin/svnvimdiff’
 

June 10, 2008

Keeping Your Home Directory in Subversion

Drew Stephens @ 1:25 am

I’ve heard of doing this for a long time, but always figured it’d be a huge jump to put my home directory into a revision control system. For years I’ve scp’d files to a new machine when I moved in and when I made changes to my vimrc or ssh config, it was hell to propagate the changes to my other machines. No more is this an issue, since I’ve commited my home directory. The process is really quite trivial.

I first created a subversion repository on my Linux server. A special machine isn’t required, nor is root access; you just need somewhere that can be accessed with SSH from the intertubes.

~$ svnadmin create subversion

It’s as easy as that. To begin with, let’s create the standard subversion directory structure.

~$ svn co file://$home/subversion/ foo
~/foo$ cd foo
~/foo$ mkdir homedir
~/foo$ svn add homedir
~/foo$ svn commit
~/foo$ cd ..
~$ rm -rf foo

So now we have a repository with a homedir directory in the root; this is where all of the files from your home directory will be checked into the repository. To begin with, check out this new project into the root of your home directory.

~$ svn co file://$home/subversion/homedir .

Since there isn’t anything in there, nothing will actually be checked out, but subversion will setup source control on ., your home directory. So let’s add something to it. I have a .vimrc that ought to be identical across environments, so I’ll check that and my .vim support directory into the repository

~$ svn add .vim*
A         .vimrc
A         .vim/colors/drew.vim
A         .vim/plugin/feraltogglecommentify.vim
~$ svn commit -m "adding stuff for the first time!"

Easy as that, all of my vim configuration files are in subversion. Now for the awesome part. Like I mentioned, I have a number of machines and, things like vim configuration files should be the same on all systems. So now, I hop onto another machine and checkout the homedir project. First I remove the existing .vim* files since they will be replaced with the repository versions.

Caligula:~$ rm -rf .vim*
Caligula:~$ svn co svn+ssh://dinomite.net/home/dinomite/subversion/homedir .
A    .vim
A    .vim/colors
A    .vim/colors/drew.vim
A    .vim/plugin
A    .vim/plugin/feraltogglecommentify.vim
Updated to revision 1.

Bam. I’ve now got the exact same files on both machines. If I’m at the office and find some flash vim option that I want to use, I simply add it to my .vimrc, check it in with svn ci .vimrc and when I svn up from the other machines, they’ll get the new changes. In reality, I keep a bunch of stuff in my homedir subversion repository: .bashrc, .screenrc, bin directory and many others. Subversion helps me keep all of my config files in sync across a number of different machines that I use on a daily basis; if you use more than one system with any frequency, I highly suggest checking in your home directory.

May 24, 2008

here-documents in Perl

Drew Stephens @ 10:10 am

Here-documents are something that, once you know about them, you wonder how you ever got along without. I first learned about here-docs in Python many years ago, but didn’t know their proper name. In Python, you define a here document with three single or double quotes:


foo = """
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
"
""
 

One day, when I wanted to put some large blocks of text amongst code, I searched for a way to do this in Perl and found the syntax:


my $foo =<< "EOF";
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
EOF
 

Note the use of quotes for the string-terminating sentinel (EOF, in this case, though it can be anything), which affects how the sting is interpreted. Just like with other strings in Perl, double-quotes mean that variables and escapes will be interpreted whereas they are ignored in single-quoted strings.

May 21, 2008

Gas v. Diesel and Energy Content

Drew Stephens @ 2:05 am

Anyone who pays attention to the car world from an efficiency perspective has no doubt heard of the popularity that diesel engines have in Europe, but lack in the United States. Diesels post significantly better distance per volume of fuel (miles per gallon, furlongs per peck) than their gasoline counterparts. I’ve always wondered how much of this disparity can be accounted for by diesel fuel’s higher energy content. A quick search turned up some statistics (See table B-4) produced by Oak Ridge National Laboratory’s Center for Transportation Analysis which lists a gallon of diesel as containing 38.6 MJ per liter and gasoline as posesing 34.8 MJ/L. Not that big of a difference; gasoline has 90% the energy content of diesel.

How is this reflected in the mileage of a real car? Well, let’s look at a Volkswagen Jetta which, until recently in the US, could be had with a 1.8 liter gasoline engine or a 1.9 liter diesel. The gas engine gives 19 MPG city, 27 MPG highway for an EPA combined cycle of 22 MPG (VW Jetta 1.8L gas). The diesel gets 28 MPG city, 39 MPG highway and 32 MPG combined (VW Jetta 1.9L diesel). Working from the combined numbers, the diesel powerplant achieves 45% better mileage with fuel that contains just over 11% more energy content. Not a bad deal at all.

The next question is how this all works out for the environment. Historically, diesels have produced much more environmentally destructive exhaust containing more NOx and particulates. Recently, however, diesel fuel in the United States has been switched to an ultra-low sulfur variety which, in turn, allows for particulate emission control technologies to be employed, reducing the airborne matter released by diesel engines. Do the changes mean significantly cleaner emissions? I’m not sure, because the stats are difficult to find. Perhaps I’ll find them later.

May 16, 2008

A Failure of Logistics

Drew Stephens @ 11:07 pm

Wiper Blades from AmazonMy roommate ordered some wiper blades that Amazon had on sale. He did a single order and yet the blades came in two boxes, each easily large enough to fit both blades, even though the boxes shipped from the same warehouse.

May 13, 2008

Inventions

Drew Stephens @ 9:06 pm

If I had this kind of cash, I would be of the same opinion:

Myhrvold’s friends, like Myhrvold, seemed to be of the opinion that there is no downside to having a CAT scanner, especially if you can get it for twenty-nine hundred dollars.

The New Yorker has a very interesting article by Malcolm Gladwell, author of The Tipping Point about Intellectual Ventures, a company that does nothing but think up inventions. They occasionally call sessions to which smart people are invited to talk and come up with patentable ideas, hand them to lawyers and then sell the patents.

May 6, 2008

Installing Proggy Fonts in Ubuntu

Drew Stephens @ 3:56 pm

I don’t recall how I came across the free Proggy font family but I wanted to try them out on my Ubuntu workstation for use in Eclipse. After some searching, I figured out how to install TrueType (.ttf) fonts and the process is pretty straightforward. I downloaded and unpacked the fonts into ~/.fonts, created a fonts.dir metadata file, added them to the font cache and when I restarted Eclipse, they were available.


~$ mkdir .fonts
~$ cd .fonts
~/.fonts$ wget http://www.proggyfonts.com/download/download_bridge.php?get=ProggyCl
ean.ttf.zip
~/.fonts$ wget http://www.proggyfonts.com/download/download_bridge.php?get=ProggySq
uare.ttf.zip
~/.fonts$ wget http://www.proggyfonts.com/download/download_bridge.php?get=ProggyS
mall.ttf.zip
~/.fonts$ ttmkfdir -o fonts.dir
~/.fonts$ fc-cache -f -v
 

April 24, 2008

Off The Hook - 23 April 2008

Drew Stephens @ 11:36 pm

This is the synopsis of Off The Hook that aired on 23 April 2008. The show runs live on WBAI at 7pm on Wednesdays. Call in at 212.209.2900 or send letters to oth@2600.com. The show is also available as a high-quality podcast.

In the studio: Emmanuel, Mike, Redbird, Redhackt, Not Kevin, Lexicon, Mojo from California, Al & Zach from North Carolina
On the phone: Bernie S in Philadelphia

There wasn’t a show last week because the show was pre-empted and there isn’t one next week; WBAI is having a Report to the Listener show during OTH’s time slot so listen in to hear about running a radio station.

Bernie S relates a Supreme Court decision concerning a man who was stopped for a traffic violation, arrested and, as part of the arrest, searched. The crux of the issue is that the reason for which the man was stopped was not an arrest able offense, thereby making such detainment illegal. As such, the state appeals court ruled that the pursuant search was also illegal a stance which was overturned by the United States Supreme Court, making the evidence collected during such a search admissible in court. In the case of Virginia v. Moore, the inventory search performed after the illegal arrest found illegal drugs and the evidence was used to charge Moore with crimes pursuant to those findings.

Another case concerning searches performed by border patrol for people entering the United States. The ruling made by the Ninth Circuit court states that border patrol agents need no suspicion to search persons entering the country at a border control station. Though the authority to search sans-probable cause has always been in place for border agents, the question of whether search laptops was also legal had been in question. Though it is still legal to encrypt data and refuse to divulge the encryption key, the concern of law enforcement officers simply seizing the device as evidence and delaying its return for months or years is brought up.

Bernie S brought up a very interesting combination of the above mentioned decisions wherein a law enforcement officer can illegally arrest you, such as in Virginia v. Moore, they may then search you and subsequently charge crimes based upon what the search finds.

The Australian government is exploring the introduction of laws allowing employers to read all of their employee’s company email in order to prevent cyber terrorism. In the United States, this is already the case since the owner of the network and computers, the employer, is the de-facto owner of all data upon them.

A council in England has employed laws meant to fight terrorism to put families under surveillance in order to ferret out fraudulent school placement applications.

As reported by Jane’s Police Review, London’s metropolitan police department is planning to equip all of their officers with microchips that will track their presence.

Israel says that Facebook is a threat to national security because soldiers and government employees post pictures of potentially classified material and equipment. Redhackt commiserates the desire to post pictures of oneself with interesting military hardware.

This weeks data loss comes from a New York Presbyterrian hospital that lost 40,000 records of patient names and social security numbers. Unsurprisingly, a spokeswoman fr the hospital says that there is nothing to show that the information has been misused.

Lexicon talks of the Not Our Concern Network Operations Center that will be in place at The Last Hope which he summarizes as a coat check for servers. Just reserve a spot and you can hook your box up to a big tube for the duration of the con. The con will also host a radio station for its entire duration. Named Radio Statler after the previous name of the hotel, the radio station is seeking people to help run it during the con weekend. If you want to help out with the con, or know about it, check out HOPE.net.

Next Page »

20 queries. 0.659 seconds. Powered by WordPress