Monthly Archives: September 2015

Start programs or scripts at system bootup

The script /etc/rc.local is to be used by the systems administrator. It is executed after all the normal system services has been started. Administrators can use it to get the summary of the server(like memory status, hardware status, and others). The reports can be sent to personal mail ID. The following is an entry inside the /etc/rc.local file:



# vi /etc/rc.local
‘echo last’ | /bin/mailx –s “Last Logged-in users in system “ user@gmail.com

Save the file by presenting :wq!

Next time, when the server boots, a mail will be thrown with the report of the last logged-in user’s information- the same way programs or scripts can be placed inside /etc/rc.local, as shown below.

Here’s a program example:

/opt/Tivoli/tsm/client/ba/bin/dsmc sched > /dev/null 2>&1 &

This is used to start the TSM( Tivoli storage manager) client to run a backup.

Find and remove duplicate file

It is a very common requirement to remove duplicate file. If you have a large collection of file, then finding and removing such duplicate file will be a tedious task. But this is where GNU/Linux makes the difference- it provides the ‘fdupes’ utility, which finds duplicate files by comparing their check- sum.

Let us install the ‘fdupes’ command using an aptitude package manager.

$ sudo apt-get install fdupes




Now, let’s suppose that we have a large collection of files and we want to remove all duplicate files. We can use the ‘fdupes’ command with the ‘-d’ option, which displays the list of duplicate files and prompts users to select which files they want to preserve. Let us check it out with an example.

First create a few duplicate files

$ for I in {1.10}; do echo “ Opensource for You.” >
F${i}.txt; done




Now find and remove them.

$ fdupes –d .

[1] ./f2.txt
[2] ./f3.txt
[3] ./f5.txt
[4] ./f9.txt
[5] ./f6.txt
[6] ./f8.txt
[7] ./f4.txt
[8] ./f1.txt
[9] ./f10.txt
[10] ./f7.txt
Set 1 of 1, preserve files [1-10,all]: 1 # Preserve only one copy of file
[+] ./f2.txt
[-] ./f3.txt
[-] ./f5.txt
[-] ./f9.txt
[-] ./f6.txt
[-] ./f8.txt
[-] ./f4.txt
[-] ./f1.txt
[-] ./f10.txt
[-] ./f7.txt

In the output , the ‘+’ sign before the file name means the file has been preserved and the ‘-‘ sign means the file has been deleted.

Bouncing Balls with CSS3 and HTML

Hi friends! Today we are going to see another great example of how to use the CSS3 and HTML in bouncing balls effects.

Table of Content

  • The HTML
  • The CSS




demo

THE HTML

Use very basic html concept. For bouncing ball we use two important div are used like ‘wrapper’ and ‘ball_wrapper’. The ‘wrapper’ is the main DIV which wraps the ball. And we use four balls are used, the ball styles are specified in css. Ball styles are different from each other, the styles, height, positions are specified in css like ‘ball-one’, ‘bal-two’ etc.




    

Bouncing Balls with CSS3 and HTML





THE CSS

Define the style of ball and div area.First, we’ll want to set a basic width to our ‘wrapper’ DIV.

	.wrapper 
		{
			width: 80%; 
			box-shadow: 0 0 3px #000;
			margin: 0 auto; 
			padding: 10px;
		}
	
	

Second, Set the each ball style and position. Also set the background and specify browser also.

	
	#ball-one, #ball-two, #ball-three, #ball-four, #ball-five {
		-moz-border-radius:100px; // browser specify -Mozilla
		-ms-border-radius:100px; // crome 
		 -ms-animation: play 1.2s steps(10) infinite;
         -o-animation: play 1.2s steps(10) infinite;
		border-radius:100%;
	}	
	#ball-one{
		width:100px;
		height:100px;
		background-color:#0bdce9;
		margin:0 400px;
		margin-top:255px;
	}

	#ball-two{
		width:80px;
		height:80px;
		background-color:#0A6AFB;
		margin-top:-80px;
		margin-left: 50px;
	}
	 
	#ball-three{
		 width:90px;
		 height:90px;
		 background-color:#ff00f6;
		 margin-left:300px;
		 margin-top:-90px
	}

	#ball-four{
		 width:60px;
		 height:60px;
		 background-color:#00CC2C;
		 margin-left:180px;
		 margin-top:-90px
	}

	#ball-five{
		 width:120px;
		 height:120px;
		 background-color:#ffcc00;
		 margin-left:550px;
		 margin-top:-90px
	}
	





download

How to switch between directories efficiently

Working on the Linux command line means switching between a lot of directories. Suppose you are in Directory ‘A’ and then move to Directory ‘B’. When you want to come back to Directory ‘A’, typing the complete directory path for ‘A’ can be cumbersome sometimes. Here’s a simple trick for this. You can use ‘cd-‘ to go back to the last directory you were in.




Lets see how this works by using an example:

Your current working directory is:

$ pwd
/home/himanshu

Your new working directory is:

$ cd /usr/local/bin/

The following command takes you back to your old working directory:

$ cd –
/home/himanshu

So you can see that it’s easy to switch between two directories using ‘cd-‘.

But, ‘cd –‘ resolves only part of the problem. It can only switch you back to the last working directory. What if you switch between multiple directories and then want to return to the first or some other desired directory? I mean, suppose you begin in Directory ‘A’, then want to return to Directory ‘A’.

For this, you can use the combination of ‘pushd’ and ‘popd’.

Here is an example:

$pwd
/home/himanshu
$ pushd /home/himanshu
$ cd /usr
$ cd /tmp
$ cd/proc
$ popd


$ pwd
/home/himanshu





As you can see, you first pass the desired directory(to which you want to come back to eventually) as the argument to ‘pushd’. Then through ‘popd’ you can actually trigger a directory switch to that directory from anywhere on the command prompt.

Mounting a remote file system with ssh.

Although running the scp or ssh command is very command is very convenient, mounting the remote servers filesystem on the local system has solved many problems for me.

Here is how this can be done. To mount the remote filesystem to a local Linux workstation, you need to install the sshfs. To install, you can choose to use the package manager of your distro or you can compile and install manually.




After the installation is complete, you can run the following command on your Linux workstation:

sshfs username@hostname://

Delete image in a folder and database Using PHP

Everybody know how to delete the content like datas and images from database using php code. But nobody try to delete the image from folder also. The following code will explain how to delete the data from database and folder using unlink command in php and wordpress page.



<?php>
$slot=$_GET[‘cat’];
$complete = $wpdb->get_results(“select * from babyitemdetails where itemid=’$slot'”);
foreach($complete as $value)
{
$productimage=$value->itemimage;
}
$path=”dbimage/”.$productimage;
unlink($path);
$sqla=”Delete from babyitemdetails where itemid=’$slot'”;
$resulta=mysqli_query($con,$sqla);
</?php>





Happy Coding

Category: PHP

PHP-Basic

PHP: Hypertext Preprocessor, is a general-purpose scripting language that was originally designed for web development. This helps to produce dynamic web pages. It generally runs on a web server , can be embedded into HTM. Php scripting always starts with . and PHP scripting block can be placed
anywhere in the document.

Eg:





My first php page


Display:
Hello World!



Category: PHP

File Download Code In HTML

File downloading code is the method of downloading a file from folder or specified path using HTML or PHP code.
How to download a file from folder,usually uploaded file are stored in the folder and how we can download it.




Let see, using PHP code we going to download the file. Here I explain download code bellow.

demo

CODE



	

Click here for download

Second image for download