November 2015

jQuery – make a div stick at top on scroll

To make a div stick at top on scroll we can use css position property fixed. Here are the steps: Find initial position of div read more

Vim redo (undo of last undo)

In case there are two many undo done, vi (vim) redo can be used. One redo in vi Approach 1 [ESC] + [CTR] + r read more

jQuery – check if an element exists

jQuery when used with selectors like element tag, class, id can potentially return a jQuery object with no element in it. Since jQuery contains number read more

egrep pipe example on Apache access log

Some egrep pipe examples for Apache access logs on Ubuntu Linux egrep http status code 301 entries $ cat /var/log/apache2/access_log.2015-11-29 | egrep ” 301 ” read more

Linux – Yesterday’s Date in YYYYMMDD format

Linux Bash code for yesterday’s date in YYYYMMDD format $ date –date=”yesterday” +”%Y%m%d” 20151128 $ date –date=”-1 days” +”%Y%m%d” 20151128 Mac Bash code for yesterday’s read more

php cli – find which ini file is loaded

Command to find which ini file is loaded for php cli $ php -i | grep “Loaded Configuration File” Sample outcome on Ubuntu Linux Loaded read more

php get array value with default

Code snippet to get a value from php array and return a default value it key does not exist <?php function get_value($arr, $key, $default=null) { read more

PHP command line – show errors

To show errors on php command line (cli) without changing php.ini php -d error_reporting=E_ALL code1.php Sample php code code1.php <?php echo $non_existing_var; ?> Sample output read more


All Tutorials

Linux – how to run a command as different user

Often we need to run a command as different users. Some of these users may not even have a login shell (e.g. www-data on Ubuntu read more

Linux – how to add a user using useradd

Adding a new user on Linux can be easily done on command line using useradd. These are some scenarios and handy commands to add a read more

Linux how to modify a user using usermod

Modifying a user on Linux can be easily done on command line using usermod. These are some scenarios and handy commands to modify a user read more

Linux – how to enable password login on ssh server

By default password based on login may be disabled on you Linux Server. Even though it is better to use private and public key for read more

Find authentication methods an ssh server supports

It is sometimes handy to know which authentication methods an ssh server supports. This may be useful if you want to enable or disable certain read more

How to install AWStats on Ubuntu Linux

AWStats is a powerful and featureful tool to analyze apache access logs. Using AWStats, you can view various stats 404, etc. Here are steps to read more

Php html_entity_decode online

This online php html_entity_decode can be used to apply php html_entity_decode function to a given string. html_entity_decode usage notes $decoded_value = html_entity_decode (string $string, $flags=ENT_COMPAT, read more

Mac finder – change search default folder to current folder

If you frequently use Finder on Mac to search stuff, you will find if handy to change default search to use current folder instead of read more

php htmlentities online

This online php htmlentities convertor can be used to apply php htmlentities function to given string. htmlentities usage notes $encoded_value = htmlentities (string $string, $flags=ENT_COMPAT, read more

How to enable Chrome tabs on Android Lollipop

In case you like Chrome tabs on Android and these are not enabled by default, you can enable these. Android Lollipop’s default settings have these read more

How to view desktop site from android mobile

Sometime we need to view desktop version of a web site from Android mobile phone. This may be useful to see how Desktop site looks. read more

Iterate over specific file extension in a dir in shell script

Sometimes we need to iterate over all files of a specific file extension using a bash script. This can be used to convert one type read more

How to search files by name in Mac Finder

Mac finder can be used to find files on Mac or in a specific folder. By default search is done on file contents. Sometimes we read more

How to delete orphan wordpress wp_postmeta rows

WordPress keeps the post meta values in wp_postmeta table. When a post is deleted, its meta data may become orphan. It is harmless data but read more

How to disable dropbox photo auto upload on mobile and desktop

Dropbox automatically upload you photos from your Android mobile to Dropbox account. This is a fairly handy feature if you have limited number of photos. read more

How to clear Chrome HTTP 301 redirect cache

By default Chrome caches HTTP 301 redirect from one page to another. If you are using Chrome during a web site development and working on read more

Convert wordpress page to posts and vice versa

Sometimes we want to convert a wordpress page to post or vice versa. WordPress treats a post slightly differently. e.g. WordPress shows posts automatically in read more

svn – how to undo last commit

Often we need to undo our last commit or an old recent commit in svn. These are quick steps you can follow to undo last read more

Debug javascript using node-inspector, node-debug, nodemon and Chrome

In case you are using node to run javascript on command line, you can use Chrome to debug javascript. It support GUI debugger functionalities like read more

Online characters, words and lines count

Enter the text below to count total number of chars, words, lines, spaces, and non ascii chars. Text: Characters count Words count Total lines Space read more

How to prevent ssh session freezing due to timeout

It can be quite annoying to kill a frozen ssh session and the restart it. This can happen if you leave an ssh shell idle read more

Why and how to log Content-Type in apache access log

It is very handy to log Content-Type in apache access log. It can be used to grep visit of specific content-type (e.g. text/html). Here is read more

How to restrict dropbox network bandwith on Mac

Dropbox can sometime consume high bandwidth and you may need to restrict dropbox’s upload and download bandwidth in certain situation. This may be the case read more

How to customize wordpress image alt tag

In case you want to beautify image alt tag for all your wordpress posts, you can use filter hook the_content. Attach a filter function to read more

How to disable sleep during android usb debugging

If you are using android mobile phone for usb android development and debugging, it may be quite annoying to see it going to sleep mode read more

How to customize wordpress rss feed

By defaul WordPress will include all posts sorted by creation time for rss feed. If you want to customize wordpress feed, you can write custom read more

How to ping feedburner to force update rss cache

If you are using Feedburner for RSS feed management, it will usually update your feed at a regular interval. In case you are debugging or read more

git – how to diff two branches

It is sometimes useful to be able to diff two branches in git. This can be useful to understand the changes in a git repository read more

Handle pagination in wordpress custom php code

In case you are writing wordpress custom code and need to show lot of content, it may be a good idea to support pagination. The read more

How and why disable android auto update

Android default auto-update setting updates android applications whenever your mobile is on WiFi internet connection. While this may be a good thing for some people, read more

Find all user created wordpress custom field keys

Sometime we need to find all user created custom field key names (or meta key) in wordpress. This may be needed to find all posts read more

WordPress – exclude specific posts from archive pages

Sometime we need to exclude specic posts and pages from wordpress archive pages. If there are some internal pages behind auth, you may want to read more

find if a wordpress page is leaf page

Sometime we want to consider pages which have children as browse pages and may treat them separately in plugins etc. For example we may not read more

How to display wordpress top level pages

Displaying wordpress top level pages may be useful for displaying sitemap or browse interface on a wordpress site. Here is the code you can use read more

display method names from php WP_Query object

Sometimes it is useful to display all methods name given a reference to object. This can be used to debug and understand wordpress or any read more

How to do recursive grep with specific file pattern

Recursive grep is pretty handy way to searching a pattern in a directory recursively. Sometimes it is useful to restrict search to specific file pattern read more

Mysql – how to enable query log

It may be useful to enable mysql query log on development of even production server for a short duration for debugging or code/flow analysis purpose. read more

How to find mysql query rate on Linux

Sometimes we want to know the current queries rate being sent to mysql server. This can be useful to get some idea on query load read more

How to kill unresponsive ssh session using escape sequence

Sometime ssh shell become unresponsive when left for too long. It is little annoying to close the terminal to kill the ssh session. To kill read more

Apache – add basic auth to a location or directory

In case you want to protect a directory from public access, you can add Apache basic auth to it. This may be needed if you read more

Disable directory listing in apache

Apache 2.4 on Ubuntu Linux has directory listing enabled by default. In case you are upgrading from apache 2.2 or creating a new site, you read more

Block directory access using htaccess 404

RewriteRule in Apache .htaccess is a convenient way to block directory access to a directory in your Apache document root. This can be useful to read more

How to list git branches

These are various command to list git local and remote branches. Note that local branches may be different from remote branches. List git local branches read more

Online hex to string decoder

This online convertor can be used to decode hex encoded format to original string text. 2 hex chars in input get converted to 1 original read more

Online string to hex encoder

This online convertor can be used to encode string text to hex format. Each text char gets converted to 2 hex characters. Also see Online read more

Android studio keyboard shortcuts for beginners

In case you are using Android studio for android app development, it a good idea to use keyboard shortcuts for various operations for increasing productivity. read more

How to find a user’s first tweet

Twitter has a service – discover your first tweet which can be used to find any user’s first tweet. This can be useful in case read more

How to remove password from pdf using Chrome

In case you want to remove password from a pdf there are multiple options. For automation command line tool qpdf is a good choice. In read more

How to test a site using pytest

Python is fairly good programming language for writing and maintaining unit and functional tests. One advantage of python is that it does not require compilation read more

How to use qpdf to add/remove password from pdf on mac

Sometimes we need to add or remove passwords from a pdf file. You can do it using Google Chrome or many other UI tools also. read more

How to install new fonts in Photoshop on Windows

Sometimes we need to use more fonts in addition to default fonts in Photoshop. There are plenty of sites that will allow us to download read more

How to use preview to add password to pdf file on mac

Preview is a powerful Mac utility to view various types of files. It can also be use to export a document to pdf and optionally read more

How to do keyword traffic research using adword

Adword is a great tool to do keyword research in addition to other functionalities it provides. It can be used to find searches for a read more

How to enable/disable gmail inbox category tabs

Gmail inbox tabs is pretty useful to automatically categorise mails in Social, Promotions, etc. labels. This also helps reduce your unread emails in inbox. Here read more