Java stack

Stack is a LIFO ADT (Last in first out abstract data type) and a linear data structure. In a jar the items on top (i.e. items that went in last) come our first. In a LIFO ADT, items that go in last come our first.

Stacks are a very useful data structure. Although you have the possibility of creating your own stack data structure from Java code, it is a better idea to simply use the stack provided by Java.

Code Following code shows how to use Java's stack:

Displaying multiple fields in a single line in drupal7 views

Suppose you have three fields (Title, field_city, field_country) to display in your view. By default they will display in three separate lines as follows:

Benjamin Franklin

To display this information in a single line, you need to edit the third field. Expand Rewrite Results, then type in the following:

[Title], [field_city], [field_country]

This will result in the following:

Benjamin Franklin, Philadelphia, USA 

Checking disk space in Linux

To check disk space, you can use one the following commands:

$ df

This command would list the amount of space used and available on each partition of the system.

$ du 

du commands lists disk space usage file by file. Read du man pages before using du.

$ vmstat

vmstat outputs virtual memory statistics

$ ls -l

Outputs file names and sizes.

Fatal error: Allowed memory size exhausted

Drupal can be very memory intensive CMS, especially if you have lots of menus, blocks and modules. If you exhaust the allowed memory size, you would get an error such as the following

Fatal error: Allowed memory size of 16777216 bytes exhausted (tried to allocate 41 bytes) in somefile

To fix this problem, you need to allocate more memory.

1. Open you php.ini file If you don't know where this file is, run locate php.ini. Mine is located at /etc/php.ini. Make sure you back up this file before editing it.

rsync command

rsync is a very useful alternative to rcp and scp. It tool lets you copy files and directories between a local host and a remote host. The main advantage of using rsync is that rsync can use SSH as a secure channel, send/receive only the bytes inside files that changed since the last replication, and remove files on the destination host if those files were deleted on the source host to keep both hosts in sync.

rsync -avz -e ssh ~/

This copies mydir and its contents from user1 to local