Monday, November 19, 2007

InstantRails MySQL Pending...

Click the MySQL button. Kill it. It will automatically restart.

Friday, November 16, 2007

7 Steps To A Ruby On Rails Application

1.Install Ruby and Rails

  • I'm using Ubuntu and did this with the Synaptic package manager.
  • I'm also going to try InstantRails, http://rubyforge.org/frs/?group_id=904


2. Generate the application's framework.

$ cd <work_root>
$ rails MyApp
$ cd MyApp


3. Create a Controller.
$ script/generate controller MyControl
NOTE: With Windows and Instant Rails, preface the script commands with ruby.

4. Edit the Controller. Add an action, some_action
$ gedit app/controllers/my_control_controller.rb

class MyControlController < ApplicationController
def some_action
@time = Time.now
end
end


5. Add the view associated with the action.
$ gedit app/views/my_control/some_action.rhtml

<html>
<head>
<title>Action!</title>
</head>
<body>
<ul>
<li>It is now <%= @time -%>
</ul>
<body>
</html>

6. Start the server.
$ script/server
NOTE: With Windows and Instant Rails, preface the script commands with ruby.

7. View the result in a browser.
http://localhost:3000/my_control/some_action


Note: (From Agile Web Development with Rails by Dave Thomas and David Heinemeier Hansson)

In Ruby, the convention is to have variable names where the letters are all lowercase and words are separated by underscores. Classes and modules are named differently:
there are no underscores, and each word in the phrase (including the first) is
capitalized.

Rails controllers have additional naming conventions. If our application has a store controller, then the following happens.
  • Rails assumes the class is called StoreController and that it’s in a file named store_controller.rb in the app/controllers directory.
  • •It also assumes there’s a helper module named StoreHelper in the file store_helper.rb located in the app/helpers directory.
  • It will look for view templates for this controller in the app/views/store directory.
  • It will by default take the output of these views and wrap them in the layout template contained in the file store.rhtml or store.rxml in the directory app/views/layouts.

Tuesday, November 13, 2007

Ruby on Rails - changing the default IP, server startup

How to get informative error pages:
$ script/server --environment=development

How to get informative error pages and access from a different box:
$ script/server --binding=<your IP goes here> --environment=development

The default, if you start with script/server you get the following:
$ script/server --binding=127.0.0.1 --environment=production

Friday, November 9, 2007

msql man page missing a ;

$ man mysql
gives the following:

Beginning with MySQL 5.0.40, the XML output also uses an XML namespace, as shown here:

shell> mysql --xml -uroot -e "SHOW VARIABLES LIKE ’version%’"



The mysql --xml -uroot -e "SHOW VARIABLES LIKE ’version%’" fails.
Use the following:
mysql --xml -p -uroot -e "SHOW VARIABLES LIKE 'version%';"

Wednesday, November 7, 2007

Serving JSP from Tomcat 5.5 on Ubuntu 7.10

Serving JSP from Tomcat 5.5 on Ubuntu 7.10

- Tomcat installed on Ubuntu 7.10, used Synaptic package manager.
- /etc/init.d/tomcat5.5 start
- /etc/init.d/tomcat5.5 stop
- /usr/share/tomcat5.5 is where tomcat lives.
- /usr/share/tomcat5.5-webapps is where the webapps live.


Create /usr/share/tomcat5.5-webapps/ROOT/test.jsp with the following contents:

<html>
<body>
<%java.util.Date d = new java.util.Date();%>

Todays date is <%= d.getDate()%> and this jsp page worked!

</body>
</html>

---
Subnote: To get the less than and greater than signs for the tags I use &lt; and &gt; There is a nice page that will do the conversion for you at : http://www.stanford.edu/~bsuter/js/convert.html

Sunday, November 4, 2007

Right-Brain, Left-Brain Which are you?

Brain Lateralization Test Results
Right Brain (34%) The right hemisphere is the visual, figurative, artistic, and intuitive side of the brain.
Left Brain (60%) The left hemisphere is the logical, articulate, assertive, and practical side of the brain
Are You Right or Left Brained?
personality tests by similarminds.com

Friday, November 2, 2007

Tomcat and PHP on Linux

To date, the way I got it working is to run the PHP code as a CGI program. More to come. Got the following from Well House Consultants "Running CGI scripts in Apache Tomcat

----

CGI scripts are usually run under an httpd web server, but if you've only got a few CGIs and a lot of .jsp-s and servlets, you may want to run them under Tomcat instead. It can be done, but there are some configuration things to do first!

SAMPLE CGI SCRIPT

Here's a sample cgi script that you might want to install on your Tomcat server:

#!/usr/bin/perl

print "Content-type: text/html\n\n";

$now = localtime();
print "<h1>It is $now</h1>";

The file should be:
 * In a directory called WEB-INF/cgi in the webapp
 * have an extension .cgi
 * be set to be executable (chmod a+x xxxxxx)

If you want to vary the location and extension, you can do so by altering the text configuration quoted below.

CONFIGURING TOMCAT TO SUPPORT CGI

Although CGI support is shipped with the standard Tomcat load, the vital information that you'll need is commented out in the web.xml file and you need to uncomment the following to add in the support:

    <servlet>
        <servlet-name>cgi</servlet-name>
        <servlet-class>org.apache.catalina.servlets.CGIServlet</servlet-class>
        <init-param>
          <param-name>debug</param-name>
          <param-value>6</param-value>
        </init-param>
        <init-param>
          <param-name>cgiPathPrefix</param-name>
          <param-value>WEB-INF/cgi</param-value>
        </init-param>
         <load-on-startup>5</load-on-startup>
    </servlet>

and also you need to map appropriate URLs on to that support:

    <servlet-mapping>
        <servlet-name>cgi</servlet-name>
        <url-pattern>*.cgi</url-pattern>
    </servlet-mapping>

There's one further change to make - the CGI API is provided in a .jar file that you need to rename in the /usr/local/tomcat/server/lib (or similarly named) directory:

mv servlets-cgi.renametojar servlets-cgi.jar



Tuesday, October 30, 2007

Fly For Fun! A WoW replacement?

I've been searching for a way to play an on-line role playing game (MMORPG) without the $15/mo bill. Until this weekend I couldn't find anything better than World of Warcraft (WOW), which has the $15/mo bill. (And if I want to play with my 9-year old it comes out to $30.)

Then I fond Fly For Fun. (flyff) Check it out! http://flyff.gpotato.com In less than 12 hours, at level 20 you can engage in 3-D aerial combat! The game is FREE. The client is free. The playtime is free. It is a bit of a grindfest, until you meet some folks who will group with you. There is world-wide dueling. There is a PK server if you go in for that. The only time you pay is if you want the extra "edge". For example you can buy potions that give you unlimited mana or health for 20 minutes, or a flying mount that goes faster than the in-game versions. It's a better deal than the other MMORPGs because you only pay for what you want, and that probably depends on how into the game you are.

Also, this is the first free MMORPG I've seen that lets you jump, and has good 3-D effects.

Enjoy!

Wednesday, October 24, 2007

Installing and Running Tomcat on Ubuntu

This link was pretty helpful: http://ubuntuforums.org/showthread.php?t=44006 except that the instructions for installing sun-jre and sun-j2sdk don't work. So of course Tomcat doesn't run.

How to fix? It seemed like java was installed. In fact java -version and javac -help gave good results. But where? It took some digging. I found the update-alternatives helpful. It helped me find where java was REALLY installed. On my system when I do:
$ update-alternatives --display java
I get the following:
java - status is auto.
link currently points to /usr/lib/jvm/java-1.5.0-sun/jre/bin/java
/usr/bin/gij-4.2 - priority 42
slave java.1.gz: /usr/share/man/man1/gij-4.2.1.gz
/usr/lib/jvm/java-1.5.0-sun/jre/bin/java - priority 53
slave java.1.gz: /usr/lib/jvm/java-1.5.0-sun/jre/man/man1/java.1.gz
Current `best' version is /usr/lib/jvm/java-1.5.0-sun/jre/bin/java.

So the trick to getting Tomcat to start per the instructions was to set
$ export JAVA_HOME=/usr/lib/jvm/java-1.5.0-sun

Tuesday, October 23, 2007

Installing and running open-vm-tools on Ubuntu

  1. Built the VMWare appliance. Followed these excellent instructions. Used Ubuntu 7.10 desktop. Set up a 30GB virtual drive and a bridged network. Used 512MB.
  2. Figured out that USED to have to use the VMWare Workstation to install the tools on your VMWare appliance if you've not got the tools on the guest. BUT VMWare just this September made the tools open source and you can build your own. Downloaded the source here. Droped the source directory into my home directory and built there.
  3. Read the README. Ran configure and make as instructed.
  4. Anytime I got an error, I read the message and figured out what libraries were missing. Then I went and found those and used apt-get install to install them. At the bottom of this post I've listed a bunch of libraries I had to install. If you don't know how to use apt or the package manager for your system, go buy and read the "Linux Phrasebook" by Scott Granneman. Scott covers both Debian apt, Red Hat RPM, and YUM.
  5. Got to the point where I had everything built without errors in an open-vm-tools directory. After some experimentation ran the following 2 commands from the root of the build directory to get the seamless mouseover and copy-paste to work between the VM appliance and the Windows XP host. (Which is the main reason I wanted to install the tools.)

$ sudo vmware-user/vmware-user &
$ sudo guestd/guestd &

Hope this helps!

Following are some of the package dependencies. (From: http://forum.compiz-fusion.org/archive/index.php/t-755.html )

# core dependancies (for stable/development)
sudo apt-get install build-essential libxcomposite-dev libpng-dev libsm-dev libxrandr-dev libxdamage-dev libxinerama-dev libstartup-notification0-dev libgconf2-dev libgl1-mesa-dev libglu1-mesa-dev

# for gtk (also installs cairo-dev)
sudo apt-get install libgtk2.0-dev libwnck-dev

# for metacity
sudo apt-get install libmetacity-dev

# for svg (--enable-librsvg)
sudo apt-get install librsvg2-dev

# for dbus
sudo apt-get install libdbus-1-dev libdbus-glib-1-dev

# for fuse
sudo apt-get install libfuse-dev

# for gnome-integration
sudo apt-get install libgnome-desktop-dev libgnome-window-settings-dev

# additional things needed for downloading/compiling from git
sudo apt-get install gitweb curl autoconf automake automake1.9 libtool intltool libxslt1-dev xsltproc

Monday, October 22, 2007

Ann Coulter's "If Democrates Had Any Brains"

Saw Ann's book If Democrats Had Any Brains, They'd Be Republicans in the bookstore. How about a book titled If Ann Coulter Had Any Brains, She'd Be A Man. She'd earn more, get laid on a regular basis, and could even stick it to other guys. I suspect there's enough material here for book. Feel free to take the title and run!