Bluefish IDE Editor

July 26th, 2010 -- No Comments

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:

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.

jQuery Basics Tutorial

July 10th, 2010 -- No Comments

jQuery is an upcoming/hot thing right now when it comes to web development. To me jQuery is slowly taking over flash. There are lots of things I can do in jQuery that I would have programmed in flash for. Before you kill the messenger there are things out there that flash can do that jQuery can’t. So let me post the source code for the tutorial and below that you can watch in video as I explain.

<html>
	<head>
    	<title>jQuery Basics Tutorial</title>
        <script type="text/javascript" src="jquery-1.4.2.min.js"></script>
        <script type="text/javascript">
        	$(document).ready(function() {
        		$('#employees tbody tr:odd').addClass('alternaterow');
        		$('#employees tbody tr:odd').removeClass('alternaterow');
 
        		$('#hideButton').click(function() {
        			$('#employees').hide();
        		});
 
        		$('#toggleButton').click(function() {
        			$('#employees').toggle();
        		})
        	});
        </script>
        <style type="text/css">
        	.alternaterow
        	{
        		background-color: #ccc;
        	}
        </style>
    </head>
    <body>
        <input type="button" id="hideButton" value="Hide Table" />
        <input type="button" id="toggleButton" value="Hide / Show" />
        <table id="employees">
        	<tr>
            	<td>
                	John
                </td>
                <td>
                	Smith
                </td>
                <td>
                	Developer
                </td>
            </tr>
            <tr>
            	<td>
                	Greg
                </td>
                <td>
                	Smith
                </td>
                <td>
                	Owner
                </td>
            </tr>
            <tr>
            	<td>
                	Michelle
                </td>
                <td>
                	Smith
                </td>
                <td>
                	Web Developer
                </td>
            </tr>
            <tr>
            	<td>
                	Scott
                </td>
                <td>
                	Smith
                </td>
                <td>
                	IT Administrator
                </td>
            </tr>
            <tr>
            	<td>
                	Michelle
                </td>
                <td>
                	Smith
                </td>
                <td>
                	Web Developer
                </td>
            </tr>
        </table>
    </body>
</html>

Categories: Tutorials, jQuery

New site design

July 9th, 2010 -- No Comments

So with me the past few days learning jQuery, I thought I would redesign my site again. This time I have used jQuery in a few places to showcase some of my new things that I have learned. My twitter feed on the right sidebar is being loaded by jQuery. On the bottom of the page you see the link that says back to top, that link when click will slowly slide you back to the top of the page instead of just reloading the whole page. Even after this post I will still be adding more to it.

In the next few days I am hoping to write a tutorial on the basics of jQuery. So keep an eye out for that.

Selenium Automation with TestNG

May 27th, 2010 -- No Comments

I wanted to start off with a simple tutorial that shows you how to write some simple automation scripts. Basically you write Selenium scripts that will test/verify information on a webpage. Example would be lets say you have a webstore that has a shopping cart. You might want to write automation that goes thru purchasing something to make sure it is working. So here is the video and below that I will have the script as well.



package com.jcwebconcepts.tutorials.basics;
 
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Test;
 
public class SimpleBrowserTests {
	private String appURL = "http://www.jcwebconcepts.net";
 
	@Test
	public void openMyBlog() {
		FirefoxDriver driver = new FirefoxDriver();
		driver.get(appURL);
	}
 
	@Test
	public void searchGoogle() {
		FirefoxDriver driver = new FirefoxDriver();
		driver.get("http://www.google.com");
		driver.findElementByName("q").sendKeys("Apple");
		driver.findElementByName("btnG").click();
	}
}
Categories: Selenium, Tutorials

Java Hello World

April 1st, 2010 -- No Comments

Well I have decided to jump back into Java programming due to some recent events. I went out and bought Sams Teach Yourself Java in 24 Hours to help me in this journey. So to help me grasp the material I wanted to create blog posts/tutorials to help me and to help others who might be on this same goal.

….

Oh and the two things that you will not see the void main for is applets and servlets. Here is the source code of the file I created

class HelloWorld
{
	public static void main(String[] args)
	{
		String sayHello = "Hello, World!";
		String myName = "John Costanzo";
		int myAge = 28;
		boolean theTruth = false;
 
		System.out.println(sayHello + " My name is " + myName);
		System.out.println("Is my age " + myAge + "?\nThe answer is " + theTruth);
	}
}
Categories: Java, Tutorials

Site Re-design

March 8th, 2010 -- 1 Comment

For the next few weeks I will be working on a new WordPress theme. I will post when it is complete so please do not judge my themes till I get it at 100% I was thinking that I might setup a test environment to test on since WordPress really does not have a tool to check your theme before you make it live.

I guess if anyone has an opinion on how to test a theme before making it live then post a comment or hit me up on twitter @jrock2004

Using Expect

January 7th, 2010 -- No Comments

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:

root@john-server:~# 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.

Python Basics

December 23rd, 2009 -- 1 Comment

If you have been reading previous blog posts, I have been using a monitoring tool called Zenoss. Under the hood there is a lot of Python stuff. So I decided to start learning Python. Python can run on Mac, Linux, Unix, and Windows. Let me show you some basic on what you can do in python.

#!/usr/bin/python
 
firstName = "John"
lastName = "Costanzo"
 
# Lets just print out one variable
print firstName
 
# Now lets complete my name
print firstName, lastName
 
# Lets just print something random without a variable
print "The sun is warm. The grass is green"
 
# Now I will print some variables followed by some text
print firstName, lastName, "Is the owner of this blog."

For more information on Python you can visit this site.

Coda

October 13th, 2009 -- No Comments

Well I have been in search for a great text editor for my Mac and I might have found one. I have tried demos of BBEdit, Text Wrangler, and TextMate. These were ok editors but I really like an application called Coda. This app has what every web developer / IT guy needs.

Basically this application gives you several options in one application. If you are like me I so a lot of SSH work and have to open up the terminal and or putty. With Coda you can click on the Terminal tab and you can SSH into your server of need.

Are you the type that you do not really like CSS and do not want to understand it? Well with the CSS tab you can add CSS styles the way Dreamweaver does it. It is self explaining and makes it easier. Now I do not use this function myself but it is very friendly.

The last thing I need to discuss is the sites section. This will let you setup site folders for easy site management. I really like this feature. I do not use it cause I personally put everything in an SVN but it is a nice one. For more information visit their site.

Categories: Coding, Mac OS

Setup SVN Server

September 3rd, 2009 -- 1 Comment

SVN (which stands for Subversion) is a version control system. So let me speak some english here for you. Lets say you make a website for a customer. When you are finished it is version 1. A month or so later the customer calls you back and wants to add a page or 2. This would then be version 2. So you upload ver 2 to replace ver 1 and the customer hates it. Oh my I did not back up ver 1 and there are many changes that happened. Well if you are using SVN you can go in and tell the code to revert back to ver 1 and then upload those files and you are a happy camper.

Well with the quick explaining what the SVN is, now lets show you how to setup the server for this. I will be installing this on a Ubuntu 9.04 box. I have tested this way with versions 8.04 and 8.10. Now I am assuming that you have Apache 2 and up already installed and configured.

Lets installing the app Subversion and install the apache module libapache2-svn

jcostanzo@virtual-ubuntu:~$ sudo apt-get update
jcostanzo@virtual-ubuntu:~$ sudo apt-get install subversion libapache2-svn

Now that we got that installed lets add a new group for subversion

jcostanzo@virtual-ubuntu:~$ sudo addgroup subversion

Next we make a main directory that will hold all of our SVN. You can have multiple sites or repositories as they are called for different sites or projects

jcostanzo@virtual-ubuntu:~$ sudo mkdir /home/svn

Note: There is really no wrong place that you can setup the svn directory

Now we just need to make some permission changes to the directory we just made

jcostanzo@virtual-ubuntu:~$ sudo chown -R www-data:subversion /home/svn
jcostanzo@virtual-ubuntu:~$ sudo chmod -R g+rws /home/svn

Next we are going to create the SVN. For this example I will name the SVN myWebsite . Now you can name your repository pretty much anything you want.

jcostanzo@virtual-ubuntu:~$ sudo svnadmin create /home/svn/myWebsite

We now have the SVN setup but now we need to get this configure so users can now connect to this SVN. We now need to edit /etc/apache2/mods-available/dav_svn.conf and make some changes to that file. You can add the following to the end of the file

    DAV svn
    SVNPath /home/svn/myWebsite
    AuthType Basic
    AuthName "myWebsite subversion repository"
    AuthUserFile /etc/subversion/passwd
 
       Require valid-user

If you have multiple repositories you would just add another section and change myWebsite to the name of the other repo. Now lets add 2 username and passwords that can connect to the SVN.

jcostanzo@virtual-ubuntu:~$ sudo htpasswd -c /etc/subversion/passwd jcostanzo
       # You are prompted for the password. Go ahead and make one up
 
jcostanzo@virtual-ubuntu:~$ sudo htpasswd /etc/subversion/passwd bsmith
       # Notice we took out the -c This is due to the -c is a flag that creates the passwd file.

Lets go ahead and finish up

jcostanzo@virtual-ubuntu:~$ sudo chown -R www-data:subversion myWebsite
jcostanzo@virtual-ubuntu:~$ sudo chmod -R g+rws myWebsite
jcostanzo@virtual-ubuntu:~$ sudo /etc/init.d/apache2 restart

That is it. You know have a working SVN server. In a later tutorial I will show you how to setup an SVN client to connect to this repositories. Below is a youtube video showing you how to do what I described above.

Categories: Coding, Linux / BSD, Tutorials