Archive for September 2008

These images been around the web before, but I just rediscovered some examples of both good server room cabling, and bad datacenter cabling.

Data center cabling is really an art. It takes some time to get the network, power,and other cabling organized but worth it in the end. The benefits are more than aesthetic, good cabling improves airflow, cooling, and reduces problems with plug dropouts. Not to mention that good labeling helps in troubleshooting when an issue does arrive.

The Good

More of The Best

The Bad

more of The Worst

And The Ugly

via Pingdom


More examples of good/bad wiring:

http://www.ixibo.com/index.php/2008/09/24/is-this-your-server-room/

http://royal.pingdom.com/2008/01/24/when-data-center-cabling-becomes-art/

http://www.ixibo.com/index.php/2008/09/29/this-is-how-your-server-room-should-be/

http://royal.pingdom.com/2008/01/09/the-worst-cable-mess-ever/

http://www.darkroastedblend.com/2007/03/really-bad-wiring-jobs_20.html

http://www.vibrant.com/cable-messes.php

Before/After Photos of Bad Cabling Fixing

Datacenter Best Practices

Adding a module position in a Joomla 1.5 template is not as easy as it was in the 1.0 templates. It is a two step process:

1. Add code to template PHP file.

For example, this would go in the index.php file in the template folder - or if you are adding it in an include file.

<?php if ($this->countModules('user6')) : ?>
    <div>
        <jdoc:include type="modules" name="user6" style="xhtml" />
    </div>
<?php endif; ?>

2. Add module name to templateDetails.xml

You then need to tell Joomla which module positions are available in this template. If you don’t do this step, then Joomla will not present the module position when giving you the option of where to place a module.

templateDetails.xml is in XML format. Within the <install> namespace, add this:

<positions>
      <position>user6</position>
</positions>

If you already have positions listed, just add the <position>user6</position> part along with the rest of them.

Following up on my previous post, we also had to demonstrate a sample Java TCP Server and TCP Client. They are pretty small and give you a good idea about how a TDP Server opens up a port, and then the TCP Client sends or receives data from that port.

This is a good page on the differences between TCP and UDP.

To compile these, install Java JDK to your system. Then compile the program with “javac TCPClient.java” - this will create a TCPClient.class. Execute the file with “java TCPClient” - leave off the .class, or you will get the error: “Exception in thread “main” java.lang.NoClassDefFoundError”.

Here is the sample code:

TCPServer.java

import java.io.*;
import java.net.*;

class TCPServer
{
   public static void main(String argv[]) throws Exception
      {
         String clientSentence;
         String capitalizedSentence;
         ServerSocket welcomeSocket = new ServerSocket(6789);

         while(true)
         {
            Socket connectionSocket = welcomeSocket.accept();
            BufferedReader inFromClient =
               new BufferedReader(new InputStreamReader(connectionSocket.getInputStream()));
            DataOutputStream outToClient = new DataOutputStream(connectionSocket.getOutputStream());
            clientSentence = inFromClient.readLine();
            System.out.println("Received: " + clientSentence);
            capitalizedSentence = clientSentence.toUpperCase() + '\n';
            outToClient.writeBytes(capitalizedSentence);
         }
      }
}

and the client:

TCPClient.java

import java.io.*;
import java.net.*;

class TCPClient
{
 public static void main(String argv[]) throws Exception
 {
  String sentence;
  String modifiedSentence;
  BufferedReader inFromUser = new BufferedReader( new InputStreamReader(System.in));
  Socket clientSocket = new Socket("localhost", 6789);
  DataOutputStream outToServer = new DataOutputStream(clientSocket.getOutputStream());
  BufferedReader inFromServer = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
  sentence = inFromUser.readLine();
  outToServer.writeBytes(sentence + '\n');
  modifiedSentence = inFromServer.readLine();
  System.out.println("FROM SERVER: " + modifiedSentence);
  clientSocket.close();
 }
}

If you have any questions, please leave a comment!

For a class I am taking, we are testing out a simple UDP Server and UDP Client to demonstrate what each one does and how sockets work. They are pretty small and give you a good idea about how a UDP Server opens up a port, and then the UDP Client sends or receives data from that port.

To compile these, install Java JDK to your system. Then compile the program with “javac UDPClient.java” - this will create a UDPClient.class. Execute the file with “java UDPClass” - leave off the .class, or you will get the error: “Exception in thread “main” java.lang.NoClassDefFoundError”.

Here is the sample code:

UDPServer.java:

import java.io.*;
import java.net.*;

class UDPServer
{
   public static void main(String args[]) throws Exception
      {
         DatagramSocket serverSocket = new DatagramSocket(9876);
            byte[] receiveData = new byte[1024];
            byte[] sendData = new byte[1024];
            while(true)
               {
                  DatagramPacket receivePacket = new DatagramPacket(receiveData, receiveData.length);
                  serverSocket.receive(receivePacket);
                  String sentence = new String( receivePacket.getData());
                  System.out.println("RECEIVED: " + sentence);
                  InetAddress IPAddress = receivePacket.getAddress();
                  int port = receivePacket.getPort();
                  String capitalizedSentence = sentence.toUpperCase();
                  sendData = capitalizedSentence.getBytes();
                  DatagramPacket sendPacket =
                  new DatagramPacket(sendData, sendData.length, IPAddress, port);
                  serverSocket.send(sendPacket);
               }
      }
}

UDPClient.java:

import java.io.*;
import java.net.*;

class UDPClient
{
   public static void main(String args[]) throws Exception
   {
      BufferedReader inFromUser =
         new BufferedReader(new InputStreamReader(System.in));
      DatagramSocket clientSocket = new DatagramSocket();
      InetAddress IPAddress = InetAddress.getByName("localhost");
      byte[] sendData = new byte[1024];
      byte[] receiveData = new byte[1024];
      String sentence = inFromUser.readLine();
      sendData = sentence.getBytes();
      DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length, IPAddress, 9876);
      clientSocket.send(sendPacket);
      DatagramPacket receivePacket = new DatagramPacket(receiveData, receiveData.length);
      clientSocket.receive(receivePacket);
      String modifiedSentence = new String(receivePacket.getData());
      System.out.println("FROM SERVER:" + modifiedSentence);
      clientSocket.close();
   }
}

I couldn’t readily find an answer to this question via the google. So here it is: If you want to insert a ‘last updated’ or ‘last modified’ date on your wordpress page, then there is a simple bit of PHP code you can use for this:

<?php the_modified_time('F jS, Y');?>

And via Ardamis’s Blog, there is a great way to only display this information if it has been modified after the original post date. This is a good way to let people know if there have been updates since the original post:

<?php $u_time = get_the_time('U');
$u_modified_time = get_the_modified_time('U');
if ($u_modified_time >= $u_time + 86400) {
echo "and last modified on ";
the_modified_time('F jS, Y');
echo " at ";
the_modified_time();
echo ", "; } ?>

This will display the last modified date and time if it is more than 86400 seconds after the creation date - that is 24 hours.

  • Welcome to systemBash, a technology and system administration blog by David Drager. If you enjoy this sort of content, can can subscribe to the RSS using the link to the right.