Category Archives: Technology

PHP program to print nth number of Fibonacci Series.

Fibonacci Series: 0 1 1 2 3 5 8 13 21 …

Here are 2 PHP programs to print nth number of Fibonacci Series:

Iterative Program to find nth number of Fibonacci Series:

<?php

fibonacci(1);
fibonacci(2);
fibonacci(3);
fibonacci(4);
fibonacci(5);

function fibonacci($n) 
{
        $first_num = 0;
	$second_num = 1;

	if(1 == $n)
	{
		echo $first_num;
	}
	elseif(2 == $n)
	{
		echo $second_num;
	}
	else
	{
		$next_num = 0;
		for($i=1; $i<=$n-2; $i++)
		{
			$next_num = $first_num + $second_num;
			$first_num = $second_num;
			$second_num = $next_num;
		}
		echo $next_num;
	}
}

?>

Recursive Program to find nth number of Fibonacci Series:

<?php

echo fibonacci(1);
echo fibonacci(2);
echo fibonacci(3);
echo fibonacci(4);
echo fibonacci(5);

function fibonacci($n) 
{
        if(1 == $n)
	{
		$result = 0;
	}
	elseif(2 == $n)
	{
		$result = 1;
	}
	else
	{
		$result = fibonacci($n-1) + fibonacci($n-2);
	}
	return($result);
}

?>

USB Error: The device can perform faster.

Greetings,

I’ve been using USB wireless mouse for quite a long time now. The only disadvantage I thought was high battery consumption.

However lately, I am being irritated by a new problem of this wireless USB device.

Occasionally, while using my wireless mouse, a pop-up suddenly and randomly appears in the Windows Taskbar saying that ‘USB device can perform faster. High-speed USB device has been plugged into a Non-high-speed USB port.’

It becomes very irritating and annoying to see that pop-up again and again. Moreover it does not come alone. It is always accompanied by that weird sound to add to the annoyance.

I have still not been able to figure out as to why this error keeps coming up at random times even though both the USB device and USB port are compatible.

However there is a solution in Windows to at least disable and suppress that USB error from popping out every now and then.

Steps are:

  1. Go to ‘Device Manager’ and click on the plus icon near the title ‘Universal Serial Bus controllers’ to expand the options.
  2. Right click on any one ‘Standard Enhanced PCI to USB Host Controller’ and click ‘Properties’.
  3. Go to ‘Advanced’ tab and check the checkbox ‘Don’t tell me about USB errors.’

These steps would at least not show that annoying message again and again.

Regards!

WordPress: Change a theme appearance without touching core theme files.

Greetngs,

How many times we have felt an itch to modify or tweak the appearance of a WordPress theme such as twentythirteen by just changing something in the core theme file.

However a big disadvantage of directly editing a core theme file is, in case a theme is updated in future (which will likely be the case), all our changes will be lost.

Hence changes should be done using the concept of ‘Child Theme’ of WordPress. With a child theme, we can update the parent theme (which might be important for security or functionality) and still keep our changes.

Following are the steps to keep the top menu bar fixed on top and stop the menu bar from scrolling up in twentythirteen theme using the concept of Child Theme:

  1. In wp-content/themes directory, create a new directory by the name ‘twentythirteen-child’. (In case twentythirteen theme needs to be changed).
  2. Inside directory twentythirteen-child, create a file by the name of ‘style.css’.
  3. Add the following code to the newly created style.css:
  4. /*
     Theme Name:     Twenty Thirteen Child
     Theme URI:      http://knowledge-share.in/twenty-thirteen-child/
     Description:    Twenty Thirteen Child Theme
     Author:         Shafi Memon
     Author URI:     http://knowledge-share.in
     Template:       twentythirteen
     Version:        1.0.0
    */
    
    @import url("../twentythirteen/style.css");
    
    /* =Theme customization starts here
    -------------------------------------------------------------- */
    .navbar {
    	position: fixed;
    	top: 0;
    	z-index: 2;
    }
  5. Log in to site’s dashboard and go to Admin Panel -> Appearance -> Themes and activate ‘Twenty Thirteen Child’ theme.
  6. Go to Admin Panel -> Appearance -> Menus and check the checkbox ‘Navigation Menu’ to make sure that same menu bar is available which was set in the Parent twentythirteen theme. This is required because the menu bar of a parent theme (twentythirteen here) is not inherited in child theme (twentythirteen-child in this case) by default.

For further information on the concept of Child Themes of WordPress, refer http://codex.wordpress.org/Child_Themes

Regards!

WordPress-3.6.1: Stop the top menu bar from scrolling up.

Greetings,

WordPress-3.6.1 comes with the most amazing theme called ‘twentythirteen’.

However considering user preferences, one enhancement that needs to be done is that the top menu bar should always remain visible regardless of the vertical scroll. This will make navigation much easier.

Hence position of menu bar should be fixed on top of page.

To achieve this, some changes are to be done in file ‘/wp-content/themes/twentythirteen/style.css’.

Following code:

.navbar {
    background-color: #f7f5e7;
    margin: 0 auto;
    max-width: 1600px;
    width: 100%;
}

needs to be changed to:

.navbar {
    background-color: #f7f5e7;
    margin: 0 auto;
    max-width: 1600px;
    width: 100%;
    /*Changed here*/
    position: fixed;
    top: 0;
    z-index: 2;
}

Catch / Caveat:

  1. Tweaks / Modifications are for ‘twentythirteen’ theme. However similar tweaks could be applied to any other theme such as ‘Spine’.
  2. One of the theme file is directly edited (might be considered as bad advice), so need to take care about the future updates to the theme file.
    [To achieve the same task without modifying the core theme file refer http://www.knowledge-share.in/wordpress-change-a-theme-appearance-without-touching-core-theme-files/
  3. Some difficulties might be faced when trying to view the top menu bar during admin tasks. (i.e. When admin is logged in.)

 

Thanks!

WordPress: Some files like ‘wp-admin/includes/ms.php’ not being uploaded properly.

Greetings,

Symptoms:

When WordPress files are FTP uploaded to the server via FileZilla Client, some files (such as ‘wp-admin/includes/ms.php’) are only partially uploaded and not entirely and hence not properly uploaded.

Due to this error in uploading, FileZilla FTP retries to upload the same file again and again resulting in another error mentioned on page Filezilla FTP Error: 421 Too many connections (8) from this IP.

Solution:

The only solution known till now is to change the overall method of uploading WordPress files to the server.

cPanel (or corresponding utility) should be used to upload files instead of FileZilla FTP Client.

Following steps should be executed:

  1. Compress all the source code files into an archive. (.zip and not .rar)
  2. Login into cPanel.
  3. Click on link called ‘File Manager’.
  4. Upload the archive using functionality provided by ‘File Manager’.
  5. Extract the contents of archive at desired location.

Thus files will be uploaded on the server.

Regards!

Filezilla FTP Error: 421 Too many connections (8) from this IP.

Greetings,

When there is some error in uploading any file, Filezilla client retries to upload that file by opening a new connection in addition to the existing connection.

As a result, those connections do not terminate properly and require manual disconnection. Moreover every server will have a limit on the maximum number of simultaneous connections for obvious security reasons.

This can be solved by following steps:

  1. Login to your cPanel.
  2. Scroll down the menu until you find FTP Session Control.
  3. You will see a list of your connections. Click on the button in the DISCONNECT column as long as the status of the connection states IDLE. You might have to click on the DISCONNECT button several times to remove all of the connections.

Disconnect all such IDLE connections and try logging again using FileZilla.

For more information, refer http://www.inmotionhosting.com/support/community-support/file-management/421-too-many-connections-8-from-this-ip

Hope this works.

Regards!

uTorrent Error: Nothing happens on executing the uTorrent.exe file.

Greetings,

Symptoms:

After successfully downloading a version of uTorrent client, when we try to install it (by double clicking the exe file), there is no response and basically nothing happens.

Obvious questions that come to mind are:

  • Is the file downloaded properly?
  • Have I downloaded an incompatible version? etc.

Solution:

No. There is nothing wrong with the download or compatibility.

uTorrent is blocked by default. It simply needs to be unblocked by right clicking the setup and clicking ‘Unblock’.

Regards!

WinXP: Word search or Phrase search not working in .php file.

Greetings,

Symptoms:

When you search for files that contain text by using the ‘A word or phrase in the file’ search criterion, the search results may not contain files that contain the text that you specified. For example, .log, .dll, .js, .asp, .xml, .xsl, .hta, .css, .wsh, .cpp, .c, or .h files, or files with no file name extension, may not appear in the search results even if the files contain the text that you specified. This problem may occur even if you specified the file name or type in the All or part of the file name box.

Solution:

To configure Windows XP to search all files no matter what the file type, obtain the latest service pack for Windows XP and then turn on the Index file types with unknown extensions option.

If you use this method, Windows XP searches all file types for the text that you specify. This can affect the performance of the search functionality. To do this:

  1. Click Start, and then click Search (or point to Search, and then click For Files or Folders).
  2. Click Change preferences, and then click With Indexing Service (for faster local searches).
  3. Click Change Indexing Service Settings (Advanced). Note that you do not have to turn on the Index service.
  4. On the toolbar, click Show/Hide Console Tree.
  5. In the left pane, right-click Indexing Service on Local Machine, and then click Properties.
  6. On the Generation tab, click to select the Index files with unknown extensions check box, and then click OK.
  7. Close the Indexing Service console.

For more information, refer http://support.microsoft.com/kb/309173

Regards!