Monday, May 9, 2011

Slimbox Previous Next Buttons Always On

I wanted Slimboxes Previous and Next Buttons to be always on, always visible, so people who haven't used lightbox style image displays can fully understand how things work.  Nobody had much worthwhile, so I had to dig in.

Turns out it's pretty easy.
Just replace the lbPrevLink and lbNextLink codes with the contents of the :hover and delete the :hover psuedo class.

#lbPrevLink {
left: 0;
background: transparent url(./slimbox/prevlabel.gif) no-repeat 0 15%;
}


#lbNextLink {
right: 0;
background: transparent url(./slimbox/nextlabel.gif) no-repeat 100% 15%;
}

Thursday, February 10, 2011

Making a New Remote Branch with Git

This works for me at work.  I can't guarantee it'll work for anybody who doesn't work with me.  We'll be creating a new branch called "new-feature."

First checkout the branch you want to branch from.
$ git checkout master

Make sure ever thing is updated (fix any problems that might happen here).
$ git pull

Check you are in the right branch (note the asterisks).
$ git branch
* master
  staging
Create new local branch
$ git branch new-feature

Checkout the new branch
$ git checkout new-feature

Double check you are in the right branch and the remote branches are good
$ git branch -a
* new-feature
  master
  staging
  origin/HEAD
  origin/master
  origin/staging
Push local branch to create remote branch
$ git push origin new-feature

Triple check your branches to make sure everything shows up as expected.
$ git branch -a
* new-feature
  master
  staging
  origin/HEAD
  origin/master
  origin/new-feature
  origin/staging

Other developers who might also want to use the new branch can now easily do so.  If they do git branch -a the new branch will show up on the list as a remote branch.  If they want to actively work with the branch they need to check it out to their local machine.
$ git checkout -tb new-feature origin/new-feature

Friday, January 21, 2011

Setting Up Tomcat and Eclipse in Ubuntu Tutorial

This had me scratching my head for several days, but I finally put all the pieces together. If you want to get around to building some JSP stuff in Tomcat using Eclipse on Ubuntu (or some other Linux) you might run into some problems like I did and just complete a simple Hello World tutorial. Here's the problems and the solutions.

Problem: You don't have an option to create a new "Dynamic Web Project"
Cause: You don't have the Web Tools Platform installed.
Solution: Download WTP.  If you already have Eclipse you can update installation here.

Problem: You are getting any slurry of errors about permissions or can't write or can't find or can't configure errors. They are all varied and confusing and difficult to google. So you probably won't find this page by looking for them.
Cause: You are using the default Tomcat installation from apt. This saves you from worrying about the installation, but it isn't setup the way Eclipse wants you to.
Solution: Run the commands found here. I've archived them incase the forum ever dies or changes drastically.

sudo apt-get install tomcat6
cd /usr/share/tomcat6
sudo ln -s /var/lib/tomcat6/conf conf
sudo ln -s /etc/tomcat6/policy.d/03catalina.policy conf/catalina.policy
sudo ln -s /var/log/tomcat6 log
sudo chmod -R 777 /usr/share/tomcat6/conf

Problem: You get an error about port 8005 and 8080 already in use.
Cause: Tomcat is already running on those ports so they are of course in use.
Solution: Tell Eclipse to start it's Tomcat on a different port. Use the directions found here. I've archived the text incase the page ever dies or changes drastically.

Click on servers tab in eclipse and then double click on the server listed there
Then when the config page opens change the port by clicking on the numbers and typing over them

Problem: You are getting weird Java errors about objects not found or classes or something.
Cause: The Hello World you are attempting to run is way over your head.
Solution: Try something simpler to make sure your Tomcat and Eclipse setup is working properly.  The example from IBM is old but simple.  I'm not going to archive it for you.

Tuesday, January 4, 2011

Compiling Class Files to Java Files for Tomcat

I'm going through some tutorials and teaching myself some JSP Struts stuff from scratch.  I decided to go the classic route and just use whatever Debian Lenny includes in apt so I don't have to worry about new exciting features, just old reliable stuff.

One of the first things you'll need to do with JSP is compile your Class Files to a Java File so it can be properly loaded.  You can't run a JAVA file in Tomcat.  It just won't work.

I figured since I used apt to install all the goodies it would work perfectly so I tried to compile the first example java file from the tutorial I was following.

So I ran:
javac RegisterAction1.java

I got an error about servlet stuff not found.

import javax.servlet.http.*;
The import javax.servlet cannot be resolved

So I tracked down the servlet stuff jar file and ran:
javac -classpath /usr/share/tomcat5.5/common/lib/servlet-api.jar RegisterAction1.java


It fixed the servlet not found error, but now I got an error about org.apache stuff not found.


import org.apache.struts.action.*;
The import org.apache cannot be resolved


So I tracked down the struts stuff jar file and tried:
javac -classpath /usr/share/tomcat5.5/common/lib/servlet-api.jar:/usr/share/struts1.2/struts.jar RegisterAction1.java


Hooray! It Worked.

I'm not a sucker though, I don't want to have to add all that every time I want to compile a java file relating to Tomcat or Struts though.  So in Debian I just go track down and vim my /etc/profile file and add the text:

export CLASSPATH=.:/usr/share/tomcat5.5/common/lib/servlet-api.jar:/usr/share/struts1.2/struts.jar

(Right before the "umask 022")


Now when you log out and log back in, you can run:
javac RegisterAction1.java and it'll work perfectly!

Monday, January 3, 2011

Tomcat and Struts and Debian

I decided I need to learn some JSP to get back in the JAVA game.
Just for stability and old school cool, I'm using Debian Lenny and the Tomcat that it installs.
You can apt-get install tomcat5.5 and tomcat5.5-admin and tomcat5.5-webapps to get everything you need.
It installs struts 1.2 by default so you don't have to go looking.

The Tomcat Default folder is /usr/share/tomcat5.5/

Sunday, November 28, 2010

Debian Lenny Xen Setup (Guest Domain)

xen-create-image --ip=192.168.25.81 --hostname=greenbox --role udev --debootstrap
xen-create-image --ip=192.168.25.82 --hostname=yellowbox --role udev --debootstrap

xm create -c /etc/xen/greenbox.cfg
xm create -c /etc/xen/yellowbox.cfg

reboot (not neccesary, but I dig it)

After a fairly lengthy reboot process you should have machines on .80, .81, and .82 all running.

Inside the VMs

aptitude install -R avahi-daemon
adduser awesomeusername

You can now ssh greenbox.local and use an account that isn't root.

Check this link if you want to setup a LAMP server.
Check this link if you want to setup a TomCat server.

Debian Lenny Xen Setup (Domain Zero)

Overview

For this setup, I want to install Debian Lenny with several Xen virtual machines.  The hardware is an older Dell something in a black case, so the dom0 domain will be called "blackbox" and the domU domains will be known by other colors.  I don't need any GUI stuff for this install since it'll just be doing server-ish terminal stuff.

Install

Install Debian from the net install CD. From the screen to select "choose software to install" deselect the Desktop Environment unless you want it for some reason. Leave Standard System selected.

This Debian install doesn't come with sudo so just use su instead. You can install sudo if you really want to but then you'll have to configure it.

I like to setup the system so I can SSH to the box and I don't have to spend all my time in the basement.

su
aptitude install -R openssh-server
aptitude install openssh-blacklist-extra
aptitude install -R avahi-daemon
reboot

Remote Control

From the comfort of a computer not in a server room or basement ssh to box.  Just to test it properly, I like to remote in, and reboot the machine.  If that works you know you have full remote control of the box.

ssh blackbox.local
su
reboot

Static IP

By default if Debian can use DHCP, it will, but since we are running a server we probably want it to have a static IP address.  So get in there and change it.  You should be careful, because if you screw it up you have to head back to the physical machine and update it.

vim /etc/network/interfaces
(edit this line)
iface eth0 inet dhcp

(change it to this, in my case)
iface eth0 inet static
address 192.168.25.80
netmask 255.255.255.0
network 192.168.25.0
broadcast 192.168.25.255
gateway 192.168.25.1
When you've got it perfect run I prefer to reboot (reboot) the system again just for good measure.  Some people will prefer to just restart the networking bits on the system (/etc/init.d/networking restart).

You'll be disconnected from your ssh session but should be able to reconnect with ssh blackbox.local again.

Setup Xen

Up until this point, the rest of that junk was pretty basic setup that would apply to all Debian Lenny installs, but here's where we actually get specialized.

su
aptitude install -R bridge-utils
aptitude install -R xen-linux-system-2.6.26-2-xen-686
aptitude install -R xen-utils-3.2-1
aptitude install -R xen-shell
aptitude install -R xen-tools
reboot

uname -r
... make sure it that "xen" is included in the name of the kernel

su
vim /etc/xen/xend-config.sxp
... uncomment (network-script network-bridge)
... comment (network-script network-dummy)

vim /etc/modules
... edit loop to loop max_loop=64

vim /etc/xen-tools/xen-tools.conf
... uncomment dir = /home/xen
... edit dist = etch  to dist = lenny 
... uncomment gateway   = 192.168.1.1
... uncomment netmask   = 255.255.255.0
... uncomment broadcast = 192.168.1.255
... edit network addresses to match your configuration
... uncomment passwd = 1

reboot (just for good measure)

Conclusion

Now everything should be setup properly.  Cross your fingers