Git revert old commit

I want to remove my 4th commit from last.

 Command  Info
 git log -6  to check last 6 commits
git rebase -i HEAD~4  to rebase last 4 commits
i i to select row

remove the entire line of commit to be deleted

click esc



to Save

: to enter text in cmd

w to write and q to escape

git push –force origin master to push the revert

Responsive Tables

When you have a wide table and need it to be responsive just add a class tbl-responsive to the table element and add an attribute  data-title in every td in order to be used as title on small screens.


<table class=”tbl-responsive”>
<th> Full Name</th>
<td data-title=”Full Name”>John Smith</td>

Finally paste the below in your css file. You might need to change some sizes/colors according to your design/table.


Responsive Table

table.tbl-responsive td, table.tbl-responsive td a {
padding: 0 5px;

table.tbl-responsive td a:hover, table.tbl-responsive td a:focus{ color: #fff; }
@media only screen and (max-width: 800px),
only screen and (max-device-width: 800px) {
.tbl-responsive thead,
.tbl-responsive tbody,
.tbl-responsive th,
.tbl-responsive td,
.tbl-responsive tr {
display: block !important;
position: relative;

.tbl-responsive thead tr {
position: absolute !important;
top: -9999px !important;
left: -9999px !important;

.tbl-responsive tr { border: 1px solid #ccc !important; }

.tbl-responsive td {
border: none !important;
border-bottom: 1px solid #eee !important;
position: relative !important;
padding-left: 30% !important;
white-space: normal !important;
text-align:left !important;
width: auto !important;

table.tbl-responsive td, table.tbl-responsive td a {
padding: 3px 5px;

.tbl-responsive td:hover a{
color: white !important;

.tbl-responsive td:before {
position: absolute !important;
top: 4px !important;
left: 6px !important;
width: 65% !important;
padding-right: 10px !important;
white-space: nowrap !important;
text-align:left !important;
font-weight: bold !important;


Label the data
.tbl-responsive td:before { content: attr(data-title); }

.dataTables_wrapper .form-control { width: auto !important; }
.dataTables_length { display: none; }
div.dataTables_length, div.dataTables_filter, div.dataTables_info, div.dataTables_paginate { text-align: right !important; }
@media only screen and (max-width: 450px),
only screen and (max-device-width: 450px)
.tbl-responsive td {
padding-left: 140px !important;

WordPress rewrite search query string

I recently needed to remove the querystring “?s=mysearch” and found it a little hard as no htaccess rewrite was working. I added the following function in my functions.php and worked perfectly.

function rewrite_search_url() {
	if ( is_search() && ! empty( $_GET['s'] ) ) {
		wp_redirect( home_url( "/search/" ) . urlencode( get_query_var( 's' ) ) );
add_action( 'template_redirect', 'rewrite_search_url' );

Trim Video using FFMPEG


I recently needed to trim a video as I wanted to remove the intro part. I found a really easy way to do this and anyone can do this from home using their own computer for free. It might seem techy and geeky but it will work like magic and really simple.

First you will need FFMPEG, you just need to download it, down even need to install. Download here:

Once download complete, extract zip file and cut the folder inside and paste it in your C:/ drive directly to be quicker. Rename folder to ffmpeg. Open the folder and find the folder called bin, it should have a file called ffmpeg.exe in it. Copy and paste the video you need to trim in that same folder to make it quicker.

Now, go to “Start” button and search for “cmd”, click to open. It will open a small black window called Command Prompt. I use it often for work but some people might have never used it. When opening the cmd and type the following to check if all is good:


This should print a whole bunch of lines, that’s good.

Now let’s do the actual trimming from movie.mp4 starting from 10 seconds and stop it at 1 minute to create a new video called new.mp4

Write the following in the cmd:

C:/ffmpeg/bin/ffmpeg.exe -i C:/ffmpeg/bin/movie.mp4 -ss 00:00:10 -t 00:01:00 -async 1 new.mp4

Press enter and let the magic happen on its own. Once video is complete you can play the video and place it where you want 🙂




Calculate Age in JavaScript


<input type="date" id="DOB" name="DOB" />



//Since new Date() created a date in the format mm/dd/yyyy, we need to format our dob to match the same format
var dob_formatted = switchMonthDate(document.getElementById(“DOB”).value);

//Calculate Age
//Subtract dob from today's date and divide by total milliseconds in a year
var age = Math.floor((new Date() - dob_formatted)/ 31536000000);

if(age >= 18)



function switchMonthDate(dateFirst)

if(dateFirst.indexOf("/") !== -1)
else if(dateFirst.indexOf("-") !== -1)
else if(dateFirst.indexOf(".") !== -1)
var monthFirst=dateFirst[1]+"/"+dateFirst[0]+"/"+dateFirst[2];

return new Date(monthFirst);




Error Code: 1055. Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

I was trying to query a complicated sql query with joins, groups, etc and after upgrading mySQL the group by stopped working.

In order to fix issue I had to open mySQL and on the database I had to run the following query:

SET GLOBAL sql_mode = '';

Notepad++ remove first or last character of every line

If you would like to remove the first character pf every line, use regular expressions in the find and replace option.

Find: ^.?(.*)

Replace with: \1



If on the other hand you would like to remove the last character of every line, use also the regular expressions in the find and replace option but instead using the following:

Find: .{1}$

Replace with:



Hope this helps!

WordPress Create Menu Locations and Assigning Menus Programmatically

Either in your setup file or in your general functions.php, update and include the following code:

// This theme uses wp_nav_menu() in one location.
register_nav_menu( 'primary', __( 'Primary Menu', 'theme-slug' ) );
//get 'your_custom_menu' id to assign it to the primary menu location created
$menu_header = get_term_by('name', 'your_custom_menu', 'nav_menu');
$menu_header_id = $menu_header->term_id;
//if menu not found, create a new one
if($menu_header_id == 0) {
     $menu_header_id = wp_create_nav_menu('your_custom_menu');
//Get all locations (including the one we just created above)
$locations = get_theme_mod('nav_menu_locations');

//set the menu to the new location and save into database
$locations['primary'] = $menu_header_id;
set_theme_mod( 'nav_menu_locations', $locations );

Change iFrame Height according to iFrame content (no jQuery required)

In the Parent page (which references the iframe), include the following in a script tag within your head section of your html:

if (window.addEventListener) {
addEventListener(“message”, messageListener, false)
} else if (window.attachEvent) {
attachEvent(“onmessage”, messageListener)
function messageListener(event) {
var originSecure = event.origin === “ ” ;
if (!originSecure)

if (parseInt( > 0)
document.getElementById(“test”).style.height = + “px”;


Meanwhile, in your iframe include the following post message in your document ready script:

parent.postMessage(window.innerHeight, “*”);