MathJax

SyntaxHighlighter

Highlight

Custom CSS

Monday, February 23, 2009

Command line PHP with PEAR on a shared host

On a shared host, you must install PEAR locally, like so (for PEAR 1.4 and above):

pear config-create ~/.php ~/.pearrc

This will create a pear directory in ~/.php, but since you aren't the administrator, you can't just edit the php.ini file and add that to the include path. For php scripts executed by the web server, I don't see any way around it besides a set_include_path at the beginning of every script. For the CLI though, you can copy the php.ini to ~/.php and set the include path there. After creating a wrapper like so:

#!/bin/bash
/usr/bin/php -c ~/.php/php.ini $@

...you can have PEAR modules included automatically.

Using maven deploy:deploy-file with wagon-ftp (it's complicated!)

I recently tried to set up a Maven repository in an environment without a servlet engine (if I had one, I'd just use Nexus instead). If you want to upload an artifact that you are managing with Maven, that's one thing; however, if you are trying to use maven deploy:deploy-file with wagon-ftp, it is inexplicably difficult. Given that a Maven repository is simply a collection of directories and files with a standardized naming scheme, I can't fathom why it's so tricky.

Well anyways, I got it working, so I figured I may as well put it here. You must be using Maven 2.0.10, the version I tested this method on. If you use other versions, you'll get weird exceptions that are geared toward making you cry instead of cluing you in that you have a version mismatch.

  1. The obvious first step is to set up an FTP server.
  2. Make sure your ~/.m2/settings.xml contains information about your server. Look at this for an example:

    
    <settings>
      <servers>
        <server>
          <id>your.server.com</id>
          <username>username</username>
          <password>password</password>
        </server>
      </servers>
    </settings>
    
  3. Search Google for the following jars on repo1.maven.org:
    It must be these specific versions for Maven 2.0.10; wagon-ftp-1.0-beta-x.jar will not work, and you'll get some cryptic stack trace if you try it. Come Maven 2.1.x, you'll be able to use the beta versions of wagon-ftp.
  4. Type the ridiculously long command found on this page. Here's an example:

    mvn deploy:deploy-file \
      -DrepositoryId=your.server.com \
      -DgroupId=mygroup \
      -DartifactId=myartifact \
      -Dversion=1.0 \
      -Dpackaging=jar \
      -DgeneratePom=true \
      -Durl=ftp://your.server.com \
      -Dfile=somejar.jar
    

    Make sure the repositoryId matches the id you have set in your settings.xml or you will get a NullPointerException (instead of some sort of authentication error, of course).
  5. Pray to various gods.
  6. Hopefully, it worked!

Update

I recently had to deal with this scenario again. As it turns out, Maven 2.0.9 from the Debian repositories worked fine; I didn't have to grab any extra jars or whatnot, and I used scp instead of ftp in my settings.xml too:

<mirrors>
  <mirror>
    <id>maven.lousycoder.com</id>
    <name>LousyCoder Maven Repository</name>
    <url>scp://maven@lousycoder.com:/var/www/maven.lousycoder.com/</url>
    <mirrorOf>maven.lousycoder.com</mirrorOf>
  </mirror>
</mirrors>

On top of that, I also made a little deployment script to avoid having to type that really really long arse command.

Saturday, February 14, 2009

Getting StarCraft to work with Wine

Here's how to update StarCraft Anthology (or any version of StarCraft) via Battle.net. Open up wine configuration by typing winecfg, navigate to the Graphics tab, and uncheck "Allow the window manager to control the windows". If this is checked, StarCraft's version is reported incorrectly as 0.0.0.0, causing updates to fail.