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
Philadelphia 
USA

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 user@host1.com:/~mydir ~/

This copies mydir and its contents from user1 to local

Comparing files using diff and cmp

The diff command gives details of differences between two files. The cmp command simply tells you whether two files are the same or different.

$ diff one.txt two.txt

The results would be something like the following:

14c14
< txt txt txt
---
> text text text

The first line indicates the line number(s) which are different between files. The letter c indicates that line 14 must be changed for them to match. The < symbol refers to the text in the first file. > symbol refers to the second file.

Reading command-line input in C

Following a program which echos whatever you type in the command line.

#include <stdio.h>

main(int argc, char *argv[]) {
     int i;
     for(i = 0; i < argc; i++)  { 
         printf("arg %d: %s\n", i, argv[i]); 
     }
     return 0;
}

argc is the count of the number of command-line arguments. argv is array of vectors. Each word is a string. So if you type:

myprogram.exe my input

the output should be

Pages