Posts marked with "Posts" in posts

Check whether request is made from Ajax – PHP

To check whether a request has been made is from Ajax or not you can use $_SERVER[‘HTTP_X_REQUESTED_WITH’]. See the following example:

if(strtolower($_SERVER[‘HTTP_X_REQUESTED_WITH’])==’xmlhttprequest’){
 echo "The request is from an Ajax Call";
}else{
 echo "The request is not from an Ajax Call";
}
?>

There you go. You now know how to check whether request made to file is from an Ajax Call or not in PHP.

... [READ MORE]

Scroll Horizontally Without Scrollbar Using jQuery

To scroll horizontally with CSS is very annoying, because the whole page will move vertically and sometimes the Y axis will scroll. So I decided to use jQuery and it’s very simple. Only 237 characters which is only 2 lines. Here is the **jQuery **code with the div id #scrollho.

jQuery

$('#scrollho').on('mousewheel',function(e){
 e.preventDefault();
 scrollLeft=$('#scrollho').scrollLeft();
 if(e.originalEvent.wheelDeltaY.toString().slice(0,1)=='-'){
  $('#scrollho').scrollLeft(scrollLeft+100);
 }else{
  $('#scrollho').scrollLeft(scrollLeft-100);
 }
});

CSS

#scrollho{
 overflow:hidden;
}

Explanation

The #scrollho div’s scrollbars are hidden with CSS. When a mousewheel event occurs on #scrollho the default event is neutralized and the div is scrolled horizontally to the direction of the mousewheel using e.originalEvent.wheelDeltaY. **e.originalEvent.wheelDeltaY **is converted into string as to do the slice function to check whether the number is negative or not.

... [READ MORE]

The main reason why adsense was disapproved

From my experience with Adsense I got disapproved after a visit from a URL to my blog. The URL was SPAM which is known as REFERRAL SPAM. See more about REFERRAL SPAM here.

Why Adsense account got disapproved of Referral SPAM ?

In the Google Adsense policies, It says that you should not pay someone to visit your blog/site. When you are placing the ad on your blog, Google tracks each visit to your blog. When they see a suspicious URL in the traffic sources they count it as a paid to click URL. Hence you will get disapproved.

... [READ MORE]

Add GET or POST parameters on include files in PHP

If you want to add GET parameters or POST parameters to files loading using include function in PHP then you should know the following:

It’s not possible. But it is in a different way.

If you are adding GET parameters to file name like the following, then it won’t work:

The above code won’t load the file, because PHP Include function only looks for files, it won’t send any parameters. It will search for file.php?user=subin in the directory for the case above. You can make it work in a different way.

... [READ MORE]

How to access a remote computer using SSH in Ubuntu Linux

SSH is the easiest way to access a remote computer not in graphical interface but in character interface.

To access a remote computer you should need the computer’s ip address & a username of the computer. Now connect using the credentials you now have. For Example:

ssh [email protected]

Type the password of the user and hit enter. You now entered the user’s system.
You can logout, shut down the computer if you ssh root user. For that use the following ssh command:

ssh [email protected]

... [READ MORE]

Revert back to normal resolution after running a fullscreen app in Wine

While running a fullscreen app in Wine such as games, you might not get the screen resolution back after you close the app. It’s because Linux won’t automatically change it’s resolution like Windows.

But you could if you run a simple file in terminal. Here is how you could do it.
Create a file named normal.sh in your Desktop with the following contents:

#!/bin/bash
xrandr -s 0

Save it on a place where you can open it easily. Make the file Executable to run it in a terminal. See this post to see how you could make a file executable.

... [READ MORE]

How to make a file executable in Ubuntu Linux

Executable files are files that can be used to run a program or to do a specific purpose specified in the file. Normally not all files defaultly would be executable in Linux because of security reasons. If all files are defaultly executable then the scripts can do whatever the hell they want to do in your computer. As we call them VIRUSES. This is one of the main reasons why you should use Linux. It’s virus free.

... [READ MORE]

How To Log Out Using Terminal in Ubuntu Linux

There is no specific command to logout in an Ubuntu system.

Why ?

Here’s how it works. The desktop you’re seeing is a separate software. They are called Desktop Environments (DE). The default DE of Ubuntu is Unity from Ubuntu’s 11.04 versions. Before it was GNOME. There are many DEs for Ubuntu. Some of them are :

  • Openbox
  • XFCE
  • LXDE

and many more.. There are also separate Login Managers to provide the login screen while Ubuntu is loaded. When you log in, the Login Manager starts the default DE set up on your system and when this DE program is closed or terminated, it will go back to the Login Screen or Login Manager.

... [READ MORE]

Disabling sidebar from fading out in Blogger Dynamic Views Template

The black sidebar on the right side of the blog is hidden and is only visible when mouse is over it. This is a problem because most of the users who are visiting your blog won’t even see the sidebar. The following list shows the advantages of having a sidebar not fading out :

  1. Google + Followers Increases
  2. More people will subscribe to your blog
  3. People will know the popularity of your blog when they see the blog stats
  4. and others…….

So I’m gonna tell you how to prevent the sidebar from fading out to the right side.
First of all Go to Blogger -> Template -> Customise
Choose Advanced option and click on the Add CSS button from the sub options. Paste the following code in the white box:

... [READ MORE]

How to execute a PHP PDO prepared statement

PDO – a method used to execute SQL statements risk free. Fast, secure and easy when compared to mysqli and mysql functions in PHP.
A lot of newbies including me heard about PDO mostly in the 2010 – 2013 years when a lot of sites got hacked of Mysql Injection. PDO is the easiest and safest way to execute an SQL code, complete risk free.
In this post I’m gonna tell you how to execute a prepared statement in PDO and the common mistakes made by programmers which results an error while executing SQL code.

... [READ MORE]

Follow/Subscribe

Telegram 

Mastodon  Twitter

GitHub GitLab

Subdomains

Demos  Lab

Past

This blog was once on WordPress. Now a static site. See source code on

GitLab