Removing ^M character GVIM windows

‘^M’ is end of line character in Linux, when you edit files created in Linux in other environments you might see the ‘^M’ character.
To remove ^M character in GVIM windows you should do:

:%s/^M//g

‘^M’ is CONTROL-V. Once you enter it will search your document and it removes all instances of ^M character from the file.

Read More

VI tips

Here are some beginners tips to VI editor:

To change the color scheme in vi just do:

colorscheme torte

which changes your color shema to torte. To see the available color schemes you could use key.

To change the font in vi editor you would have to do:

set guifont=Lucida\ Console:h10

Please note that ‘\’ is being used before every space character in the font name.
setting the line numbers:

set number

To highlight the search result in the current doument:

set hlsearch

To have this change made every time you start vi you would need to add it anywhere in vimrc file. In Linux its under /etc/vim/ and in windows its inside the installation folder in “program files”

Read More

PySDM – Storage Device Manager

PySDM

To auto-mount storage devices in Linux normally you would need to edit /etc/fstab file, which sometimes can be quite difficult specially if you are a Linux newbie. To make things easier you can look into using a software called PySDM which does exactly what you need to do with a nice user interface. Using this tool you can easily manage your mount points.
to Install PySDM:

sudo apt-get install pysdm
Read More

Sea level attack

sea

Read More

Ubuntu and Open ports

For security reasons you may want to check the open ports on your machine and validate that applications using them. To scan your open ports you can use the following command:

sudo nmap -sV localhost

Namp will scan the machines open ports using the “-sV” parameter will also display the applications using the open ports and their version. Once you execute the command you should get a list similar to what I have here:

PORT     STATE SERVICE VERSION
21/tcp   open  ftp     vsftpd 2.2.0
22/tcp   open  ssh     OpenSSH 5.1p1 Debian 6ubuntu2 (protocol 2.0)
80/tcp   open  http    Apache httpd 2.2.12 ((Ubuntu))
3306/tcp open  mysql   MySQL 5.1.37-1ubuntu5.1

You should go through the list and if there are any applications which you don’t recognize you can always Google their name and see if you want them to be using the open ports or not.
You could also use netstat to see your open ports. For instance:

sudo netstat -tap

would return similar results.

Read More

Japanese Fountain

Here is a Fountain from Canal city in Fukuoka, japan. There are things that you can ONLY see in Japan this is definitely one of them.

Read More

C/C++ pointers

Pointers in C/C++ can sometimes be really confusing specially if you are a beginner or like me more used to Java. Here is a small program I found really useful in understanding c pointers:

#include <stdio.h>
int main() {
   int int_var = 5;
   int *int_ptr;

   int_ptr = &int_var; // Put the address of int_var into int_ptr.

   printf("int_ptr = 0x%08x\n", int_ptr);
   printf("&int_ptr = 0x%08x\n", &int_ptr);
   printf("*int_ptr = 0x%08x\n\n", *int_ptr);

   printf("int_var is located at 0x%08x and contains %d\n", &int_var, int_var);
   printf("int_ptr is located at 0x%08x, contains 0x%08x, and points to %d\n\n",
      &int_ptr, int_ptr, *int_ptr);
}

If you compile and run the code you will get something similar to the following:

int_ptr = 0xbffff834
&int_ptr = 0xbffff830
*int_ptr = 0x00000005

int_var is located at 0xbffff834 and contains 5
int_ptr is located at 0xbffff830, contains 0xbffff834, and points to 5

The address of your variables are probably different from what I have here which is obvious. One thing you should pay attention to is the relationship between the value/address of the pointer and the address of the int variable.

Read More