Friday, April 13, 2012

Modifying Existing Content Types using archetypes.schemaextender

I was working with Plone 4 and needed to extend the Folder Content type to add an image and a title.

Being a newbie in Plone, I rummaged through the internet (Google) and was fortunate to find the tutorial below. It has been a real help and helped solve my issue in less than 30 mins.

Tweaking Existing Content Types using archetypes.schemaextender

Enjoy!!!

Thursday, April 5, 2012

Unix/Linux Commands every developer should know

General Commands:

1. date: shows date and time
2. history: lists the previously executed commands
3. man ls: shows online documentation by program name
4. who: who is on the system and what they are doing
5. whoami: who is logged onto this terminal
6. cal: calendar
7. banner DZone 
8. clear: clears the screen
9. tty: displays your terminal

Directory Management Commands:

1. pwd: will print your home directory on screen. pwd means print working directory
2. ls: displays the contents of directory
3. cd: change to new directory
4. mkdir dirNameCreate: creates new directory
5. mv dirNameChange dirNameChange2: renames the directory           
6. rmdir dirNameremove: removes empty directory (you must remove files first)
7. dircmp dir1 dir2: compares two directories

File Management Commands:

1. find myFile.txt: finds files that match specific criteria  
2. file myFile.txt: displays about the contents of a given file, whether it is a text (Ascii) or binary file.
3. head myFile.txt: by default it will display the first 10 lines of a file.
If you want first 50 lines you can use head -50 filename or for 37 lines head -37 filename and so forth.
4. tail myFile.txt: by default it will display the last 10 lines of a file.
If you want last 50 lines then you can use tail -50 filename.
5. more myFile.txt: will display a page at a time and then wait for input which is spacebar. For example if you have a file which is 500 lines and you want to read it all.
6. wc myFile.txt: counts the characters, words and lines in a file depending upon the option
7. mv myFile.txt yourFile.txt: is used to move a file from one directory to another directory or to rename a file
8. cp myFile.txt yourFile.txt: is used to copy a file from one directory to another directory/same directory
9. rm myFile.txt: removes the file
10. cmp myfile.txt yourfile.txt: compares two files


Source : Important Linux/Unix Commands

Tuesday, April 3, 2012

Creating Local SVN Repository

In this tutorial I will explain how to create a local Subversion (SVN) repository, intended for a single user. I assume that you already know the benefits of keeping track of old revision of projects or important documents such as a resume or a thesis you have been writing. Subversion offers you a very convenient yet strong method to do so, and the easiest way to do so with Subversion (SVN) is to create a local, home, repository intended for a single user – you.

The repository we are going to create will be used by a single user, working locally on the machine. In this tutorial I will assume the repository will be created for a project called “project1″. “project1″ can be a real project you are doing, a paper you are writing or any thing else that can be stored under revision control (that almost everything).

Creating the repository

We will start by creating the repository. From the command line do the following:
$ mkdir /home/user/svnrep
$ cd ~/svnrep
$ svnadmin create project1

In the first line we create a directory to house all of your repositories (I assume you are working under the username “user”). I prefer to use different repositories for different projects that are unrelated, no matter how small they are. Because I use many repositories, I prefer to have a single directory underneath all repositories will reside in an organized way (i.e. no junk files or any other kind of stuff except directories). Next thing, is to cd into the directory we created, and actually create the repository using the svnadmin command. To repository we’ve created is called “project1″.

The brand new “project1″ repository is currently empty and in revision 0. This will change once we put some data in it. The first thing you do with a new repository is to import initial project data into it.
$ svn import /home/user/project1 file:///home/user/svnrep/project1/trunk -m "Initial import of project1"

Will import the current project1′s file into the repository (assuming that project1 indeed resides in /home/user/project1). The trunk appended to the end of the repository URL, is part of the directory layout convention used by many Subversion users. The last part of the command is the message that will be attached to the import in the SVN log.

Now the repository holds data and you are ready to checkout the code from it, and start working.

Checkout a Working Copy and Start Working

When using SVN (as well as in most revision control systems) you don't work directly on the repository. Instead you checkout a working copy from it, and work on this copy. To checkout a working copy from the repository, use:
$ svn co file:///home/user/svnrep/project1/trunk /home/user/project1_work

This will create a working copy of the repository under /home/user/project1_work. You can edit this copy safely.

After you've done editing your working copy, you will want to commit those changes back to the repository. Assuming you are already inside the directory of the working copy, just do:
$ svn commit -m "Some log message"

This will send you changes back to the repository and store them there. Change the "Some log message" to some useful short description of the changes you've made.

Some Useful Commands

To view a list of log messages that were attached to the operations on the repository, use:
$ svn log
$ svn log -r 5:HEAD

The first command will print all log messages. The second command will print the log messages from revision 5 to the latest revision. You can substitute the HEAD with a number to get the log messages of the revisions up to a specific one.

To view the changes you made before committing your code, use:
$ svn diff


Another important command is the one to update your working copy with the latest revision from the repository. This can be done using:
$ svn update

However, since your are the only user of the local repository, you won't have to use this function often (if at all), unless you use two, or more, working copies for your project.

IF : A Poem by Rudyard Kipling

Today I will digress from my usual tech speak and post a beautiful poem by Rudyard Kipling.


IF

If you can keep your head when all about you
Are losing theirs and blaming it on you;
If you can trust yourself when all men doubt you,
But make allowance for their doubting too:
If you can wait and not be tired by waiting,
Or, being lied about, don't deal in lies,
Or being hated don't give way to hating,
And yet don't look too good, nor talk too wise;

If you can dream---and not make dreams your master;
If you can think---and not make thoughts your aim,
If you can meet with Triumph and Disaster
And treat those two impostors just the same:.
If you can bear to hear the truth you've spoken
Twisted by knaves to make a trap for fools,
Or watch the things you gave your life to, broken,
And stoop and build'em up with worn-out tools;

If you can make one heap of all your winnings
And risk it on one turn of pitch-and-toss,
And lose, and start again at your beginnings,
And never breathe a word about your loss:
If you can force your heart and nerve and sinew
To serve your turn long after they are gone,
And so hold on when there is nothing in you
Except the Will which says to them: "Hold on!"

If you can talk with crowds and keep your virtue,
Or walk with Kings---nor lose the common touch,
If neither foes nor loving friends can hurt you,
If all men count with you, but none too much:
If you can fill the unforgiving minute
With sixty seconds' worth of distance run,
Yours is the Earth and everything that's in it,
And---which is more---you'll be a Man, my son! 
Rudyard Kipling