How to get rid of the “searchguide.level3.com” hack ? [Solved]

Level3_Crap_Search_EngineSomedays back I noticed that when I type something into my browser it takes me to a different search engine called "searchguide.level3.com" which I don’t remember installing or set in the browser. I looked into my browser settings for anything suspicious but didn’t find any. Now, how to get rid of the “searchguide.level3.com” hack ?Level3_Hack_Redirecting

After searching and reading some forum posts, I finally found the cause and fixed it.

It happens because of faulty, free DNS servers. In my case, I was using Level3’s DNS servers (4.2.2.1 through 4.2.2.6) and it was hijacking the traffic. When something messy is entered directly into the URL of the browser, it redirects to Level3’s searching site.
Level3_Faulty_DNS

 

To fix the problem, simply search for a good DNS server and use that instead. Same thing will happen with most free DNS servers, however, I am OK with Google’s free DNS server.

Two of the best DNS servers that can be used instead.

  1. Google Public DNS8.8.8.8 and 8.8.4.4
  2. OpenDNS – 208.67.222.222 and 208.67.220.220

Hope this helps you solve your problem with the level3.com redirect.

How to stop outgoing emails being sent through postfix from your local machine in Mac OS X ?

stop-local-mails-from-postfix In latest versions of Mac OS X, by default the postfix is set to send emails from your local machine to outside world. This might cause you troubles if you are developing applications on your local machine and your application has email sending functionality to customers. Unfortunately if you have some customers’ email addresses in the database or in your code in the local setup, then test emails get delivered to them which is embarrassing. This happens even if you have not setup/integrated any 3rd party smtp services in your application.

To avoid this kind of situation, you can stop outgoing emails being sent through postfix from your local machine. Simply put the line below into the /private/etc/postfix/main.cf file in your Mac OS X.

default_transport = error:No outside emails.

The variable default_transport specifies which transport is used to deliver non-local mail (default is smtp). With this setting, any outgoing mail will bounce back with the error specified.

References:
http://www.postfix.org/postconf.5.html
http://postfix.cs.utah.edu/postconf.5.html

How to compare files on Mac OS X

Questions those come into mind when someone switches from Windows to Mac OS X for web development and wants to compare files:

  • Which editor has support for file diff or file compare functionalities on Mac OS X ?
  • Which is the best tool for file comparison while developing on Mac OS X ?
  • How to use FileDiff package on Sublime Text editor ?
  • How to use File Compare functionality in Text Wrangler in mac OS X ?

Answer/Solutions:
After developing 4 complete years on Windows, I have recently moved into a MacBook Air. During development, one thing I was missing was the “File Compare” plug-in on Notepad++ which I was using for a long time while on Windows. Even though NotePad++ doesn’t have a Mac version, there are some alternatives to that on Mac OS X. Two editors which I find very useful are Text Wrangler and Sublime Text 3.

 

File Compare on Text Wrangler:

  • Open both the files on the TextWrangler editor. Did I mention, this is a free editor and best for editing text based files.
  • Now select both the files in “Opened Documents” sidebar. [ ⌘ + Click ]
  • Right click on the selected files and click on “Compare”.

How to compare two files on textWranglerCompared Differences TextWrangler

 

File diff on Sublime Text 3:

  • Install “Package Control” for Sublime if you haven’t yet. How to do that ? https://sublime.wbond.net/installation
  • Now open the package installer and install “FileDiffs“.
  • To diff. two files, open those two files in Sublime Text 3. Right click on that file tab and click on “Diff Tab”.
  • Now you can use the diff. file generated (unified) to see changes between two files.

Diff with TabUnified Diff Result

 

To know how to integrate DiffMerge(an application to visually compare and merge files) with Sublime Text read: http://subharanjan.com/integrate-diffmerge-with-sublime-text-comparing-files/

How to integrate DiffMerge with Sublime Text for comparing files

DiffMerge Window

The other day, I was searching for some ways to compare two files(one from production and another from the local development of the same file) in Sublime Text. I found that there is no default tool to compare two files, thats why I installed “FileDiffs“, a package which provides the above needed functionality. What this tool does is: it provides you a result file which contains unified differences from both the compared files with + (Plus) & (Minus) symbols. Even though it serves the purpose, but for someone who has been using compare tools like WinMerge, or the color-full GUI in Notepad++ editor on Windows, the experience will be horrible.

However a cool feature of this “FileDiffs” package is that, it can integrate with any external diff. tools through command line. So, I installed “DiffMerge“, an free application to visually compare and merge files. Below is the set of settings that integrates “DiffMerge” with “FileDiffs” on “Sublime Text 3”.

How and where to apply these settings ?

  • Go to: Sublime Text –> Preferences –> Package Settings –> FileDiffs –> Settings – User
  • Copy & paste the above code in the FileDiffs.sublime-settings file.
  • Restart Sublime and see the file diffs visually in a nice graphical way. πŸ™‚
how to apply settings for FileDiffs

how to apply settings for FileDiffs

Diff with Tab - FileDiffs on Sublime Text

Diff with Tab – FileDiffs on Sublime Text

DiffMerge Window

DiffMerge Window

Get your website on https and get ranked higher on Google

In a recent blog, Google has announced that TLS, SSL enabled websites(https://) will be getting added advantages in SEO ranking. In order to make the Internet more safe and secure, Google has started using HTTPS as a ranking signal, that means if you site is HTTPS enabled you will get ranked higher. However they have also cleared that this ranking signal weighs less than signals like high-quality content etc.HTTPS as Google's ranking signal

Even though, some may think it as hypocritical of Google who has products which doesn’t follow HTTPS( like the BlogSpot), but Google has made this a part of SEO and may increase the weight of this ranking signal in near future. The whole purpose of this initiative is to keep everyone safe on the web. Website owners !! its time to switch from http to https. Encryption is going to be the key to SEO !! So, Get your website on https and get ranked higher on Google.

For more details visit the official Google Webmaster Central blog: http://googlewebmastercentral.blogspot.in/2014/08/https-as-ranking-signal.html

How to block the USSD notification/balance update messages on Android smart-phones ? [Solved]

Problem description:
In India, whatever internet plans you take for your smartphones, be it 3G, 2G Internet, GPRS etc. it always keeps randomly disconnecting. Sometimes it reconnects automatically, sometimes it takes a while. So, during this process we keep getting a remaining balance message or notification for the data usage which is nothing but a USSD.

What is USSD ?
USSD (Unstructured Supplementary Service Data) is a Global System for Mobile(GSM) communication technology that is used to send text between a mobile phone and an application program in the network. USSD is similar to Short Messaging Service (SMS), but,unlike SMS, USSD transactions occur during the session only. USSD is commonly used by prepaid GSM cellular phones to query the available balance.

These USSD messages for remaining balance and used balance are such that: these will asks the user to press the “OK” button and unless you press that, it stays like that on the screen and prevents you from performing any other task on the phone. It creates an overlay kind of screen which doesn’t allow the user to touch anything else unless you click ok button for each popup. Each time you send a sms, each time your internet gets disconnected etc. a notification popup will be displayed to be read by the user. These are so much in numbers that some one gets irritated.

There are times when you keep your smart-phone unused for more than one hour, and when you get a call, you have to press the “Ok” button 20-25 times on these popups to receive the call. Its really annoying !! Now, how to block those type of messages ? These frequent balance updates, data usage status are of no use/very less use.

Solution:
There is a nice app called Quiet Balance. Named as Balance Update / USSD blocker on Google Play. This app specializes in blocking USSD messages.

  • It provides ways you can block only specific type of messages. It has three types of matching methods for blocking USSD messages.
    1. Substring match: You may choose to block messages that contain a specific text.
    2. Keyword list: a list of keywords (comma separated keyword list)
    3. Regular expression: for advanced users by writing regular expression.
    When these conditions are matched, it triggers a block of that ussd message.
  • You can also choose to show the balance update message once per day (or week/month). This will cause the first balance update message to show up, and all other messages will be blocked for the rest of the day.
  • Last 25 messages are saved in the message log, along with indication if the message was blocked or allowed.

Go get the app and install on your Android phone and make it Smart πŸ™‚ πŸ™‚
Get it on Google Play

 

 

Slide to see all the screen shots of the App:

Timthumb not showing images and throws “Warning: file_exists() [function.file-exists]: open_basedir restriction in effect. ” error. [Solved]

timthumbRecently I faced a situation where the timthumb script was unable to crop the images and was throwing error messages. There are themes those still use timthumb even though its a bad practice to use in themes when we have already functions available in core WordPress. Anyway I had to fix the issue as I was not state to replace the timthumb functionality with core WordPress functions.

Here is the error message:

This issue occurs in several hosts, mainly the free hosts available these days. So, the trick is to find where the $docRoot variable was set and set it to my public_html folder manually in my home directory. In my file it was on line number 825. I did the following…

Obviously the /a9582221/ would be your username.

Where to make this changes ??
Search for the file timthumb.php and make the above changes. Thats it. The issue got resolved now.

How to disable responsiveness in the admin theme of WordPress 3.8

How to disable responsiveness in the admin theme of WordPress 3.8 ? How do I disable responsiveness of WP 3.8 admin ? Is there any way to disable responsiveness ? I want to disable the responsive hiding feature for tablets and mobile for the newly introduced WordPress 3.8 admin back end.

The question comes, Why do you need to disable the responsiveness ? So, here is a problem/situation that describes WHY ?
Stop Responsiveness WordPress 3.8
Problem/Situation:
I just updated my WordPress setup to WP 3.8 and most of my custom functionality are either inaccessible or very hard to manage on mobile devices. There are some things which doesn’t even get displayed on mobile devices. Earlier, I was able to manage my site’s functionality from backend on a mobile device too. Even though it was not responsive and not so cool. The problem is that I have installed some custom made plugins which were made keeping an eye on the old style admin theme and it provides me some custom made interface on the admin side. Obviously these were not made responsive. Now, with this new WordPress admin theme, all those custom interfaces are completely messed up. So I have two options:

  • Either revert back to WP 3.6/3.7 ( but I really like the look and feel of the new WP 3.8 theme yet I don’t need the responsive property πŸ™ )
  • Or make changes to all the custom made screens/interfaces in the admin side to be responsive. ( I can do that, but it would take much time to accomplish. Also, does it worth doing just for the sake of a new responsive admin theme in mobile devices ? πŸ˜• )

How can I keep the new, super cool, awesome theme of WordPress 3.8 yet disable responsiveness of the theme ? ❓ ❓ ❓

Solution:
I tried to search for any solution but didn’t find any. Here is a quick solution that I have done to get back my custom functionality in the admin screen.

  1. Create a plugin to add custom code.
  2. Take the css file that is responsible for the wp-admin side styling and responsiveness. Make changes to remove the responsive property out of it. Basically remove all the media queries written for mobile devices.
  3. De-register the default admin styling that comes with WordPress.
  4. Register and enqueue the changed css file again to apply the custom styling.

Download the code as a plugin: disable-responsive-admin

Code for disabling responsiveness:

Download the above code as a plugin: Plugin to disable responsiveness in WP 3.8 admin

Note: This never a proper/good way of doing changes to admin styling. Still, as I have upgraded and would like to keep the theme and remove responsiveness, I am using the above quick solution. If you are facing the same problem as I am, use the above procedure or download and install the plugin. You can modify the css file present inside the plugin directory too. Caution: Use with your own risk. πŸ™‚ πŸ™‚

Do you need an admin interface to stop / disable auto update feature of WordPress ?

Now that the “Automatic update of WordPress core” has been introduced in WP version 3.7, there are some obvious questions those come into mind. Where can I control this automatic update functionality of WordPress 3.7 ? Is there any admin interface for it ? How can I disable auto update of WP ? So, before going to show you how can you control the automatic update feature on admin settings page, let me tell you some facts.

This newly introduced auto update of WordPress core files is only for security and maintenance releases which is considered to be MINOR releases. That means this auto-update feature won’t be affecting the major releases of WP.

automatic-update-wordpressMajor releases:Β 3.x –> 3.(x+1) Β OR Β 3.x.x –> 3.(x+1)
Version 3.6 to Version 3.7 or Version 3.8

Minor releases:Β 3.7 –> 3.7.(x+1) Β OR Β 3.7.x –> 3.7.(x+1)
Version 3.7 to Version 3.7.1 or Version 3.7.2 or Version 3.7.3

As this feature is not for major releases rather only for the minor ones, it won’t break your site and won’t create any major problems. So stay cool and don’t worry !! Β  πŸ™‚

Somehow, if you don’t need this auto-update feature for some reasons like:

  • You manage your site using version control.
  • You implement your own deployment mechanism.
  • You think there is no guarantees in this auto-update feature.
  • You want to upgrade manually with complete control and at you own convenience.
  • OR if you think there is any error in the stats provided by Nacin regarding zero failures πŸ˜‰Β 

 

Now the Solution (Plugin that creates an settings interface for WordPress admin to manage & control auto updates):
By default, there is NO admin interface provided by WordPress to have control over this. However there are some hooks and config variables to manage this. Like:

 

Certainly there is a cool plugin called “Update Control” in the WordPress repo which provides a nice and easy interface to manage this newly introduced feature along with some more options. Plugin URL: http://wordpress.org/plugins/update-control/
 
disable auto update wordpress
Various features & controls provided by this plugin:

  • Enable/Disable automatic updates.
  • Set the level of releases for Auto Updates.
  • Enable/Disable automatic Plugin updates
  • Enable/Disable automatic Theme updates
  • Enable/Disable automatic Translation(languages) updates.
  • Enable/Disable the code versioning check
  • Enable/Disable sending emails for updates etc.

If you are developer and you want to do this in your existing code then read this answer by Chip Bennett at stackexchange.Β http://wordpress.stackexchange.com/a/120082/13615

Integrate PHP CodeSniffer with NetBeans IDE [Steps]

CodeSniffer, an essential development tool that ensures your code remains clean and consistent, should always be with you while writing code to check and fix the messy things. For those people who use NetBeans IDE to write PHP applications, here are the steps to integrate PHP CodeSniffer with NetBeans IDE.

Steps:
  • Open NetBeans IDE. ( Let me tell you, I am using NetBeans IDE 7.3 for this demo )
  • Install the NetBeans plugin ‘phpCS-MD’ by going to Tools -> Plugins screen.
    Click on the “Available Plugins” tab and search for ‘phpCS’ in the search box provided on top-right corner. Click and check the plugin and click on the “Install” button.
  • Once installed, lets configure it.
    Go to “Tools” -> “Options”.
  • Click on the tab “CodeSniffer”.
    Here you have to provide the path to phpcs.bat file present under your PHP installation directory. Do this by clicking the “Change” button there.
  • Click on the “Test Settings” button and if it shows the PHP CodeSniffer version details, then its configured successfully.

Now, click OK and go back to your code for checking against a particular coding standard. If you want to set a different coding standard definition, then setup that standard before hand on CodeSniffer. How to do that ? Follow my previous post to know how to install CodeSniffer and various Coding Standard definitions. Go to the CodeSniffer setting tab on NetBeans and set the Coding Standard definition name there in the input box named “Standard”.

On the code screen, you can see a new button with a single Blue Eye on the tool bar. This is to check any file for code issues. Click on that and you can see a new section comes below your code named “PHP CS/MD” and displays all the problems in the code row-wise. Now fix the messy code. Happy Coding πŸ™‚

Here are the step by step screen shots to make it easier to follow.
subharanjan_codesniffer_neatbeans_1

subharanjan_codesniffer_neatbeans_2

subharanjan_codesniffer_neatbeans_3

subharanjan_codesniffer_neatbeans_4

subharanjan_codesniffer_neatbeans_5