Getting MSSQL Command Line Access from ISQL on Ubuntu

Install freetds
sudo apt-get install freetds-bin

Check it works:
fsql -S -U

See how to use it (it pretty much matches isql and bcp).
man fisql
man freebcp

Engineer Victory Dance (the hard work was done the freetds posse and all those lovely linux peeps, but dance anyway, required action).

Advertisements

Quick Ruby On Rails

Requirement

I need to do a quick prototype of a web app for a friend that has to run initially on a windows localhost and be able to hand it over to his developer for development if it floats the necessary boats. Totally coincidentally, I need to do a prototype for a web app at work too.

Tech Choice Breakdown

I haven’t spent anytime with Ruby On Rails and precious little doing web apps of any kind. Ruby I’ve scripted with a little, any web ui’ed stuff has usually ended up in hasty perl on the intranet. RoR is something I have meant to fit in for a few years.

So, I’ve dug in the library and found the Pragmatic Programmers Agile Web Development With Rails by DT, THH et al, 2005 edition. I understand Ruby and Rails have upped a version or two since then, so I’m tempted to use the book and stick with version 1.x of Rails.

InstantRails 1.7 looks like it hits the two requirements of providing quick start up for my friend, and being version 1.x of Rails so I can use the THH book to get up to speed.

Promise to self is to upgrade once prototype 0.2.x is motted on either system, probably looking at JRuby as well.

Installing InstantRails

  1. Snagged InstantRails 1.7 on advice from Pragmatic Programmer forum (slightly different topic, I know, but looks as though it may apply with my old book). Work is shaping network traffic, so took a bloody age to download.
  2. Extracted the zip contents to C:\, now have a directory C:\InstantRails.
  3. Opened C:\InstantRails\readme.txt and followed the instructions. One functioning server – tick 🙂

Now need to do some Use Cases and get on with it….

Chain Letter Reply Template

I hate chain letters. The underlying conceit of a chain letter is to make the sender feel guilty or afraid for not sending it on, to make the receiver feel annoyed at the sender for involving them, and to perpetuate that cycle ad nauseam. It may seem harmless at first touch, but if you forward one you are being manipulated by the original author. Even if you just send them on but don’t feel anything, some of the people you target, or indirectly target, are going to have a bad day or two because of it, because of you. So just don’t send them on: no-one’s hurt; it doesn’t cost you anything; and you’ve saved some of your bandwidth. It wasn’t that funny or clever anyway. Just full of platitudes or bad info.

I try to kill these damn things; to stop them everytime I see one (cue rousing music, maybe some kilted people thrusting swords in the air, general cheering, and exeunt all stage left (pursued by bear)).

My standard reply to chain letters:

Hi So-andSo,

Please don’t be offended, this is no reflection on you, but please don’t include me on any chain letters. I don’t like them. I find the concept underlying them offensive and divisive. If I had a religion, they’d be against it!

The wikipedia page is pretty evenhanded about them: http://en.wikipedia.org/wiki/Chain_e-mail and this is good mickey-take: http://www.perry.com/bizarre/antichn.html

Something lovely and generally ignoring the whole chain letter thing so hopefully there’s no bitter aftertaste.

If it’s a virus/worm/hoax email of any kind, I look it up on Virus Encyclopedia, Sophos, or Hoax Slayer and email the sender with the ref and an explanation.

Installing Laconica

Using:

  • OS: $ lsb_release -a
    Distributor ID: Ubuntu
    Description: Ubuntu 8.10
    Release: 8.10
    Codename: intrepid
  • php 5.2.6
  • mysql server 5.0.67-0ubuntu6

Added pre-requisities php libraries:

  • sudo apt-get install php5-cli
  • sudo apt-get install php5-curl
  • sudo apt-get install php5-mysql
  • sudo apt-get install php5-gd
  • sudo apt-get install php-gettext
  • Check mbstring is installed: php -i | grep -i mbstring
    If you get some output, you should be OK.
  • Check xmlwriter is installed: php -i | grep -i xmlwriter
    If you get some output, you should be OK.

Added nice to haves:

  • sudo apt-get install php5-memcache
  • sudo apt-get install php-pear
  • sudo apt-get install php5-dev
  • sudo pecl install mailparse
  • Not sure whether you need this, but did it anyway as seemed logical at the time: sudo vim /etc/php5/conf.d/mailparse.ini
    and add:
    # manual configuration for php mailparse module
    # yourInitials 16-mar-09
    extension=mailparse.so
  • Install Sphinx Server. Not sure how/when we’ll config this, but it’s as well to get it in before we’re asked for it:
    • sudo apt get install libmysqlclient15-dev
    • wget http://sphinxsearch.com/downloads/sphinx-0.9.8.1.tar.gz
    • tar -xvf sphinx-0.9.8.1.tar.gz
    • cd sphinx-0.9.8.1/
    • ./configure
    • make
    • sudo make install
    • Check it’s in OK: search
      You should see output starting with: Sphinx 0.9.8.1-release
  • sudo apt-get install php5-xcache

I suggest you also install phpMyAdmin for looking after the mysql databases if you haven’t already. I’m certainly not hard enough to do all the sql work from the command-line 🙂

Just in case restart Apache:

  • sudo /etc/init.d/apache2 restart

And now, we begin. Rather marvellously Mr Prodromou has just released a new laconia update, version 0.7.2.1, which includes a “first version of a web-based installer”. I’m following the instructions from the README file in the download. Here goes…. Just followed the instructions and I have a functioning install! Mwah-ha. Mwah-ha! Mwah-ha-ha-ha-haaaaaa! I have the power. etc.

Things not working: Fancy URLs. But I’ll get ’round to that.

UPDATE: run sudo a2enmod rewrite to enable the apache rewrite engine so you can use fancy urls and then follow the instructions in the README for .htaccess.

Getting a Current Subversion Project Into Git Control

Whilst learning how to use git with svn I am documenting the way I’ve done it. I’m using bash and am starting from the directory above my working directory. The project is checked out already from an svn repo. The working directory is “efot”.

  • Commit anything outstanding in your working directory to svn
  • Move your working directory out of the way if you’re paranoid like me: mv efot efot.pregit
  • Checkout (clone) your project from svn using git: git-svn clone http://svnServer/repos/section/trunk/efot --username=yourSvnName
  • Watch what’s happening: cd efot;gitk &
  • Make sure git ignores .svn and, since I use eclipse in an heterogenous env with other developers, I exclude bin/, and *.log as well:
    • vim .git/info/exclude
    • add “.svn” (without the quotes) to the bottom of the file
    • newline, add “bin” (without the quotes) to the bottom of the file
    • newline, add “*.log” (without the quotes) to the bottom of the file
    • save and quit.
  • Make sure svn will ignore git files and local files I don’t commit to the trunk:cd .. && svn ps svn:ignore ".git" efot && cd efot
    cd .. && svn ps svn:ignore ".classpath*" efot && cd efot
  • cd .. && svn ps svn:ignore ".settings" efot && cd efot

  • give it a descriptive label in git: git-tag -a 20090310_efot_release_prod

Now for the paranoid amongst us, cross the i’s and dot the t’s ;):

  • cp -R ../efot.pregit/src . ; cp -R ../efot.pregit/testsrc .;cp -R ../efot.pregit/xml;cp ../efot.pregit/.classpath . ; cp ../efot.pregit/.settings .;
  • git add .
  • git commit -a
  • update from svn: git-svn fetch
  • if any come in on the fetch, replay any git changes onto it (shouldn’t be any at this point): git-svn rebase
  • commit to svn: git-svn dcommit

Job’s a good’un. I think.

Refs: Git User’s Manual, Flavio Castelli, and Git Crash Course.

Mac OSX: Things To Do First If You’re a Developer

If you’re a developer moving to a Mac may I recommend, from my own experience, you do these three things before you try and do anything at all other than using iLife or M$ Office:

  1. Install XCode Tools. You’ll need your OSX install DVD, select Optional Installs/Xcode Tools, and run the XcodeTools.mpkg. Budget an hour for it to install, hope for 40 mins. Maybe better on the Intels.
  2. Install MacPorts. It makes life so much easier than trawling the web trying to understand the esoterica of Mac OSX standard installs of various things like mysql, sqlite, python and ruby. None of them work quite the way I expect them to, and the hacking to try and understand what’s different, and then how to fix it, is so time consuming I have bypassed them and use MacPorts. It looks like a shedload of other people do too.
  3. create a .bash_profile file in your home directory. Use this for aliases (.bashrc doesn’t work).

All I can think of right now.