Technology (48)

mod_rewrite cheat sheet

Written by Thursday, 24 January 2008

Help Guide to mod_rewrite

Just found that, searching on the net for a comprehensive quick-guide to mod_rewrite (again).

mod_rewrite is cool. I used it "often", as in it solves a good number of "beautiful url" problems.

But I say "often" with quotes, because I'm not using it often enough for the syntax to remain in my head.

This is a nice cheat sheet to pin on your wall at work :)

EDIT - Updated link

I'm posting so it'll help me remember - I aways forget that stuff, because I rarely need it.

Okay, so, you got class "A", which is an "outer" class, which defines "B" as an "inner" class (called A.B).

class A {

 public void someMethod() {}
public class B {
}

}

Let's say an instance of A.B wants to call a method from A.

That's easy, because methods and members from A are directly visible to B.

The issue comes when B wants to class a member or field of A that has the same name as a member or field of B.

The this "pointer" becomes kind of ambiguous. When in "B", this refers to the instance of "B", and not to the instance of "A".

I'm here to tell you that yes, you can access the this of A!

Ready? Here's the syntax - that will only work while within "B" (of course).

Lets say that you wanted to call the "toString()" method of "A" from "B":

A.this.toString()

Yes, that is "<outerclassname>.this.<member or field name>".

Have a happy day.

Lost my eth0 on my way to upgrade

Written by Friday, 05 October 2007

Long time no post...

Today's post is not too entertaining, but might help someone. Who knows?

So I was making various tests upgrading portage profiles, too see how systems react before I try doing it on more important servers.

During my tets, on an old machine I never updated, I was trying to update "baselayout" (via "emerge -av baselayout"), as part of the thing I needed to update by moving to the 2007.0 profile.

Okay. So on that machine, I couldn't update because a silly old version of dhcp was installed.

Fine, I said. I removed the package - thinking I'll update later.

One "emerge -C dhcp" later and my baselayout installed fine.

All is well, I thought. Lets see if it holds water and reboot everything.

Forgettign about dhcp.

So, you know where I'm going, right?

The server boots fine, but now my connection to the network is also gone.

Of course, I can't emerge dhcp back (as I should've before rebooting...)

So here's how to get your network card back up again, without dhcp:

ifconfig eth0 up <ip_address>

Where <ip_address> is a valid ip address for your machine.

route add default gw <gateway_ip_address>

Where <gateway_ip_address> is the ip address of your gateway server.

From there, I could get my dhcp back up again and everything's fine.

Tomcat, out of memory under gentoo

Written by Thursday, 22 March 2007

Sometimes, you just need to give tomcat more than its 64megs that comes out of the box.

There's the nice way to do it under gentoo:

edit /etc/env.d/21tomcat - it should already be there.

Add the following line to it:

CATALINA_OPTS="-server -Xms128M -Xmx256M"

This means you're telling catalina (the tomcat engine) to start with an initial heap size of 128 megs. It also tells it to set its maximal heap size to 256 megs.

/etc/env.d is Gentoo's way of nicely handling global environment variables. But its not all magic. You need to let gentoo know you've made changes.

Run the following command:

env-update

This will regenerate the environment variables. This is neat. But the shell you're currently running doesn't know that. You could log off and log back on, but I've got better.

source /etc/profile

Now, if you run echo $CATALINA_OPTS you'll see the CATALINA_OPTS variable is set to what you put in the environment file.

This is all neat, but tomcat needs to be aware of this as well... so you'll need to restart it.

/etc/init.d/tomcat5 restart

Enjoy your enhanced heap size!

UPDATE 2009/03/27 For people stumbling onto this article - the way to go now is to edit the tomcat configuration file in /etc/conf.d instead.

Gentoo and new timezone settings

Written by Saturday, 17 March 2007

Your gentoo server is not at the proper date? Well, perhaps you did not properly update to the new daylight saving settings?

«StartPrev12345678910NextEnd»
Page 3 of 10