Archive for the ‘Code’ Category

javascript calendar selector

I have been working on this order system over the weekend, and the one piece of it that was the most difficult to get to work, should have been the easiest. I needed a popup or inline date selector. I figured there would be a quick cut and paste way of doing this, but after trying three different (allegedly) cut and paste solution, I was still getting glitches. One of them would have worked just fine, but Internet Explorer can’t render web pages properly AT ALL! Dang you Trident rendering engine! Thankfully I finally found Matt Kruse’s Calendar Popup. Just download and include the four javascript files in your HTML document, and you are good to go. And initialize the calendar class in the header section.

<script src="PopupWindow.js" type="text/javascript"></script>
<script src="AnchorPosition.js" type="text/javascript"></script>
<script src="date.js" type="text/javascript"></script>
<script src="CalendarPopup.js" type="text/javascript"></script>
<script type="text/javascript">
var cal = new CalendarPopup();
</script>

And then to use the calendar popup selector for a certain text input:
<form>
<input name="date" type="text" />
<a id="anchor1" onclick="cal.select(document.forms['testform'].date,'anchor1','MM/dd/yyyy'); return false;" name="anchor1" href="#">Show Calendar</a>
</form>

subversion and warehouse

I had first heard about the Warehouse subversion browser a couple of months back. At the time it was still closed source and cost $30 per server license. Recently though, it went open source and is now freely available. For those of you with about 1-2 hours of time and know how to setup and run subversion on a Linux/Unix box (with WebDAV) it really isn’t that hard to get up and running.

I installed this on one of my home Debian Etch (4) servers and it took me about 30 minutes once I understood the entire process.

  1. Install some necessary dependencies for building (I prolly left out a few) – make, rake, unzip, zip, tar, gzip, bzip2, libc6, gcc, cpp, g++
  2. Install Ruby
    • download the latest tarball (source code in tar.gz) here – http://www.ruby-lang.org/en/downloads/wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p72.tar.gz
    • run – tar xzvf ruby*.tar.gz – to open up the archive
    • cd into the directory – cd ruby*
    • configure, make and then install –> 1) ./configure 2) make 3) make install (as root)
  3. Install Swig
    • download one of the latest tarballs – wget http://internap.dl.sourceforge.net/sourceforge/swig/swig-1.3.31.tar.gz
    • unarchive the archive – tar xzvf swig-1.3.31.tar.gz
    • get into the directory – cd swig-1.3.31
    • configure, make, then install –> 1) ./configure 2) make 3) make install (as root)
  4. Install Subversion and the Swig-Ruby bindings
    • download one of the latest subversion archives – wget http://subversion.tigris.org/downloads/subversion-1.5.5.tar.gz
    • unarchive that sucker – tar xzvf subversion*.tar.gz
    • get into the directory that was just created – cd subversion*
    • configure for installation (and if you are missing anything be sure to install it!) – ./configure –enable-shared –enable-static –enable-debug –with-ssl –with-swig
    • make and install –> 1) make 2) make install
    • now install the swig-ruby bindings –> 1) make swig-rb 2) make install-swig-rb
  5. Install various dependencies for later: apache2 with WebDAV support, ruby gems, MySQL server/client, PHPMyAdmin might be handy as well
  6. Download the Warehouse source code – http://github.com/entp/warehouse/tree/master
  7. Untar into where you want Warehouse to start from: tar xvzf, mv, and whatnot.
  8. Setup a 3 MySQL databases (warehouse_test, warehouse_production, warehouse_dev) that can be accessed by 1 user for testing, production and development.
  9. Now run the warehouse bootstrapping program and setup procedures. (No registration key needed now that it is open source, so leave that field blank.) – http://www.warehouseapp.com/installing/installing-and-registering-warehouse
  10. In the Warehouse settings, be sure to setup warehouse so that it updates your WebDAV permissions and passwords.
    • Shell command to run when permissions are updated. This will auto-generate the necessary permission file for WebDAV: rake warehouse:build_config CONFIG=[warehouse directory]/config/access.conf
    • Shell command to run when someone’s password is updated. This will auto-generate the necessary password file for WebDAV: rake warehouse:build_htpasswd CONFIG=[warehouse directory]/config/htpasswd.conf

Return top