JC Web Concepts

Moving Your SVN Repo

One of the things that I sometimes have to do is move an SVN repo to another server or you just want to back it up. This tutorial will show you how to do this.

svnadmin dump /pathToYourRepo > reponame_dump
Example: svnadmin dump /var/svn/mywebsite > mywebsite_dump

So now you want to go move this file to your new server and create your subversion repo. Make sure you use the same name as the old one. Go to folder where you uploaded your dump file to and do the following:

svnadmin load /pathToYourRepo < reponame_dump
Example: svnadmin dump /var/svn/mywebsite < mywebsite_dump

So there you go. In this tutorial I did not include setting up the subversion server cause I made the assumption you know how to do this since you already have an SVN repo setup.

Bluefish IDE Editor

Well as a PHP, HTML, CSS, and jQuery designer one of the things I have been looking for is a good lightweight text editor. I have used many different types of editors and not found the right one. When I programmed in Windows I loved Notepad++, but there is no Mac/Linux equivalent. The editors that I have used in the past are as follows:

  • NVU
  • Dreamweaver
  • VIM
  • Eclipse
  • Bluefish

    The last editor I was and still will use is VIM. There is times I just want to click somewhere to move my cursor, I.E. Being lazy. I really like bluefish cause it is very lightweight and fast. Eclipse and Dreamweaver just are too slow for me. Bluefish will work in Mac, Linux, and Windows. The best thing I like about it, is it is free. So take a look at them, post some comments about what you think is the best. Maybe you have one that I just have not seen.

Mplayer Playlist

Ok I know this type of post is not like me but I thought I would post it since I needed to research on how to do this. Well a lot of my developement is done in the Linux environment. All my music comes from CD’s or purchases from iTunes. In the Linux realm I have found that purchased music is not liked. So when I program in the Gentoo I mount my iTunes music folder. Since I am in command line most of the time I use Mplayer to listen to my music. So I needed to figure out how to tell Mplayer to play everything in my Music folder. I got tired or having to pick a new song all the time. So let me show you how I did this. Ok the first thing you want to do is run the following command from my home directory to create the playlist:

$ find /media/prl/iTunes\ Music/ > myMusic

Now the two things you would need to change is where the main folder of your music is and the other thing is what you want to name your playlist. Instead of myMusic you could say JohnsPlaylist. Now that you got the playlist to run it you would run this command

$ mplayer -playlist ~/myMusic

If you want to shuffle the playlist you would do

$ mplayer -playlist ~/myMusic -shuffle

Well I hope this might have help some other people who maybe had the same struggles I did.

Hosts File

As a web developer one of the tools that I love to use is built right into the operating system. I have come across some jobs where the coder has coded everything in absolute paths. Well if you are like me and like to test stuff on a local server first, then you will run into some issues. If your page calls an file it will call it from the remote server and not the local one. There are other examples but I will spare you of them. Lets get to this hosts file. The hosts file exists in modern day operating systems. You can find it in Linux, Mac, Unix, and or Windows. Let me show you where these files exist.

On Mac or Linux

/etc/hosts

On Windows

C:\Windows\system32\drivers\etc\hosts

So now let me show you some magic. So now on your testing box I would add a new entry. It can be added anywhere you want. So add this line

127.0.0.1    jcwebconcepts.net

Of course you could substitute with any domain. So now when you test your files/scripts and the point to the absolute path you will pointing to your local box. Of course when you are done I like to comment that out. Just in case I forget that I have that and I want to look at the remote site. Now if you want to see the test environment on another computer the line you add to the host file will be different. First get your IP of the test box. Mine is 192.168.2.120

192.168.2.120    jcwebconcepts.net

So you can start to see the things you can do with the hosts file that can help you. Instead of recoding all those absolute paths to relative you can edit the hosts file and test it that way.

Here is a video that explains some of this

CentOS (My Thoughts)

When I first learned Linux about 12 years ago I started off using Red Hat. You guys who have used it long enough remember the day when you wanted to install an app you had to not only download the application but 5 or 6 dependencies. In todays world that has changed. Things have been made so much easier. Thru the years I have used different distributions from Red Hat, SuSE, Fedora, Ubuntu, and CentOS . If you have used the Fedora and Red Hat land distro’s then you are not going to have much of a problem.

To do a net install it is not as easy like the other distro’s but if you have seen one version of Linux you have seen them all. The big thing about CentOS that I really like is that apps are tested fast and properly. Updates seem to be coming before some of the other versions of Linux. For now I use CentOS to try to stay on top of it to keep my knowledge up on some of these distributions. So go try and download a copy and throw it in a Virtual environment. See what you think and post a comment if you have a different opinion or question(s).

Using Expect

Are you running a Linux or Unix server that there are process you need to automate? Is there a daily process that are just a waist of your time but not to your server? There is a nice application called Expect that can help you with this. This application can handle several protocols. Some are ssh, telnet, ftp, passwd, fsck, rlogin, tip, etc… This application does not need a server it is just a client. The client is installed where your script will run from. The nice thing about expect is the file can be executed on a webpage as well. So let me show you an example script:

#!/usr/bin/expect  
###Usage: call the file with a username.  
spawn ssh -i /var/employee/includes/id_rsa root@10.10.1.12
expect "The authenticity of host '10.10.1.12 (10.10.1.12)' can't be established.
RSA key fingerprint is 47:4a:6a:ce:65:99:e2:93:2b:7t:a9:48:19:64:f6:28.
Are you sure you want to continue connecting (yes/no)?"
send "Yes\r"
expect "root@10.10.1.12's password:"
send "iamthegreatone\r"
expect "#"
send "cd /home\r"
expect "#"
send "rm -Rf $argv\r"
expect "#"
send "cp -a default/ $argv\r"
expect "#"
send "chown -R $argv:513 $argv\r"
expect "#"
send "exit\r"
expect eof

This script is executed by running the following:

expect thefilename.exp john

This is a script I use at work to reset my users profiles when they mess them up. As you can see then when you run the file you must pass an argument. So in this case you ssh into the server that has the user directories pass the name of the directory. So this script will remove the current users directory and cp the default profile directory to theirs. It will then set the right permissions for the user. Note: The group 513 may be different from server to server. Now you do not need to use ssh or anything like that. So if you want to have the script live in the same box you can remove the SSH information. Hope this helps and give it a try it is a nice tool.

Zenoss MySQL Database

One of the things I never understood after installing Zenoss, was where is this mysql database. I found out that with Zenoss it sets up it’s own MySQL server and it is even smart to put it on a different port. So lets say you want to access this database and see what it looks like. This can be done by doing the following:

su zenoss
mysql -u zenoss -p

Just enter the password for your zenoss database and then you can have access to the MySQL server. Hope this helps out someone.

Zenoss Local Templates

One of the coolest things I learned today was about creating local templates for specific devices. So lets say you have 5 Linux boxes and and only 2 are running apache. I do not need to graph apache stuff on my 3 other boxes. So I go into the device that I want to have its own version of the template and click on the down arrow and go to more. Then click on templates. You will now see all the templates that are bound to the device class. The one that you want to change to the specific device click on Create local copy. Now you can edit that template and it will only make changes for that device. I am telling you that Zenoss is just a great piece of software.