git sub directory

how to add subdirectories in git

Adding subdirectories in existing git repository

You have done git push but the new folders didn’t got pushed. What happened?

Having new folders and subfolders in the git repository, but the files under those not showing in the server?

Adding subdirectories in existing git repositories should have been direct right? But, sometimes it is not. I will show you How to add subdirectory in existing git repository

Let’s say you have existing git repository my-git-repo and you want to add new folder under it: new-folder/another-sub-folder

Step by steps to add git subdirectories in existing git repository

1. Create folder in the repository you are going to create new folders

mkdir -p new-folder/another-sub-folder

2. Now if you do git status you will see the new folder under new listing.

3. Create a file under another-sub-folder otherwise git won’t show nothing.

cd new-folder/another-sub-folder && touch some-file.xml

4. Go to another-sub-folder and issue git init

5. Now go back to the root of the folder and issue git add new-folder/

6. You are done, when you do git status you will see your new files being listed for commit.

Group by week mysql

How to group by week on mysql

Group by week in mysql is common specially for reporting. Here is how to do it.

If the column is with format yyyy-mm-dd

WHERE (__DATE_COLUMN_) > '2018-03-01 00:00:00'

If the column is unixtime stamp format

WHERE FROM_UNIXTIME(__DATE_COLUMN__) > '2018-03-01 00:00:00'

Where the __TABLE__ is he mysql table and __DATE_COLUMN__ is the column you are interested.

facebook logo

Facebook Link Ownership in Facebook posts

Facebook link ownership when posting links from using facebook app

Facebook link ownership is hot issue now. Facebook is getting smarter and stricter from time to time.

In good days, all you have to do was to post the link to the page automatically using the app and get the traffic.

Now, when you try to do that, Facebook requires you to verify your ownership of the website you are posting a link to.

Part of it was done through the Open Graph tags. But now, it requires a bit more than that.

How to set a link ownership of the website for facebook posts

Before we dive into the how, you need to make sure you qualify the following points.

1. The first thing is, you need to have access to the website you are trying to post links from facebook app yourself.

2. You are an admin of the facebook page you are trying to post.

3. It is assumed you already have facebook app you want you use for posting to facebook page.

Now here are the steps:

1. Go to

2. Click the business setting, you will find it on the right top corner.

3. On the left, under the account menu select pages and click on the add to add the page.

4. Select “Add Page” and follow the wizard to add the page.

5. Once you are done adding the page, on the left menu under brand safety, click on domains.

6. Here add click on “Add” to add the the website. You need to have access to the server of the website as it gives you file to put there.

7. Once you are done with number 6 and do the verification, go back to domains and select the website you verified.

8. Here you see options to assign pages. When you click on “Assign Pages” you get the list of pages you added on the previous steps. Now you can associate the page to the website.

Congratulations! Now when you are using your Facebook app to post articles or anything from your website to your Facebook page, Facebook knows you owned it and will allow you to post.

Good luck.

Redirect http url to https

Force redirect http to https using htaccess

Force redirect http traffic to https

Redirect http to https url using simple file. If you have recently switched to https version, which is recommended, then you want to force the traffic to https.

This can be accomplished using .htaccess file.

How to redirect https to http

1. Create/update the .htaccess file on your root website.
2. Add the following line on the top part of the .htaccess file

RewriteEngine On

RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

3. That is it. You don’t need to restart the server for this case.

You can refer this page for more htaccess examples

You don’t have permission to access / on this server. Apache error

Apache refusing to serve with you don’t have permission to access error

Here are things to fix the problem

Have your config in your apache config like this:

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html

                Options All
                AllowOverride All
                require all granted

1. Make sure the directory you are accessing has at least 755 permission mode
2. Make sure to restart the server after you change the configs
3. Check if you have .htaccess file with different setting
4. In some cases, make sure the directory is accessible by apache – www-data.

Apache Not Service Files from Icons Folder

My ico, png, jpg and more files from Apache are not being served

It is a bit crazy but the icons folder that is residing in the root folder is reserved. Well kind of.

If you have icons folder in the root, then your files under that folder might have hard time being served.

What is the fix

The easiest is to rename your “icons” folder. If you have admin access to the apache config files, on one of the conf files, search for
Alias /icons/ .. and change it accordingly.

Create Tables From Entity Definitions From JPA Spring

How to create database tables from JPA using Hibernate

We know ORM. It will be a nightmare or a bliss based on the angle you are looking at it. This time a bliss :)

If you have started development from the java side and you have all the entities figured out, then hibernate can create the database for you from the entities.

For this example I will be assuming you are using Spring and Hibernate, with that, how do you create the database from the entities

Initial Setup assumptions

So, I will be assuming you have the spring being setup already, the configuration file for your application would look like:

jdbc.driverClassName = com.mysql.jdbc.Driver
jdbc.url = jdbc:mysql://localhost:3306/database
jdbc.username = root
jdbc.password = 123
hibernate.dialect = org.hibernate.dialect.MySQLDialect
hibernate.show_sql = true
hibernate.format_sql = true = create|create-drop|update|none

Here the values to could be create – if you want to crate during the sessionFactory initiation, create-drop, update when you want to update the exiting database when there is a change on the schema or none if you don’t want to do anything with it.

java class not found exception

spring error ClassNotFoundException org.springframework.web.context.ContextLoaderList

ClassNotFoundException org.springframework.web.context.ContextLoaderList

When working on spring framework, you might get this error specially on eclipse. I am assuming you are working on maven and eclipse environment.

The ClassNotFound exception is a bit self explanatory that eclipse could not find the mentioned class ContextLoaderList

The web.xml file for the spring configuration might look like



With this, you might have similar file like application-context in the WEB-INF path

How to fix ClassNotFoundException for ContextLoaderList

The problem will during deployment. It is not basically compile time error. It is rather runtime error.

So, we have to make sure the jar responsible for this class is available in the classpath that eclipse is reading.

Pom dependency check

Make sure you have the same/similar configuration as the one listed below on your pom file.


You can have the right version for your spring in the parameter section or you can just replace it with the current version you have.

Using Deployment Assembly fix in eclipse

As we know, it is a deployment time problem, hence we have to tell the assembly where it can get its dependencies.

      Right click on the project
      Go to/search for Deployment Assembly
      Click on Add
      Select on Java Build path entries
      Select all the maven dependencies
      Clean and build the project

Either of the above methods should fix the problem

The superclass “javax.servlet.http.HttpServlet” was not found on the Java Build Path

The superclass “javax.servlet.http.HttpServlet” was not found on the Java Build Path error in java webapp

If you are using eclipse, this might be due to project facet, right click on the project, go to project facet and select Runtimes and check the server you have configured.

if the app you are running is not spring or other web app framework that already comprised of servlet, then you need to add servlet to the build path.

You can add the servlet either through dependency management tools like gradle and maven or you can add it to the project lib file and compile it.

Also, you can add the dependency to servlet in your pom and get rid of the problem.


facebook social marketing

Add batch/multiple posts to Facebook Page – Graph API

facebook graph API batch request usage

If you have or managing any facebook page, chances are you might be using faebook’s graph API. It comes with lots of flavors of languages like Java, PHP, Javascript.

Ok you know about that, this post is not about that. If you want to see how to make a post to facebook through graph API, look at this post

This post is about making multiple posts to Facebook page.

Why would I need batch requests

Imagine you have 20 blog articles you want to post to facebook. If you are not using batch, then it means you are sending 20 post requests to facebook. And as you can imaging it is easy to hit the limit easily. Facebook will stop you from bombarding their site.

When you are using batch, you have only one request, holding all 20 posts. Yup, that is it. One request vs 20. Now you know why you have to use that.

How to send multiple blog posts or other posts to Facebook page at once

If you follow the above link I referenced, you will have an idea on how single post is doing. I will just continue on that example class and will add just one more method to handle batch request.

The main idea is, each blog or whatever post has to be an object of Request. And you will send all those requests wrapped in one and send it.

	 * Send batch request to FB than a single one
	 * @param $post_data
	private function batchPost(array $post_data, $token)
		 * In the case of the batch request, each has to be an object of request. And all those can be 
		 * send as one big request.
		$batch_response = [];
		$requests = [];
		foreach ($post_data as $id => $data) {
			$requests[$id] = $this->facebook->request('POST', '/me/feed', $data);

		$batch_response = $this->facebook->sendBatchRequest($requests, $token);

		return $batch_response;

In the above example, the method will be accepting $post_data as a parameter. If a post example is considered, a single $data will look like

$data = [
			'link' => "",
			'message'=>"how to make batch request in facebook api",
			'title'=>"Making Multiple Requests in Facebook",
			'description' => 'In this article I will show you how you can make multiple blog posts to Facebook page with one single request.',

Then the line with $this->facebook->request will create a request object and add it as part of request array. Also mind the $id, each should have unique key in the $request array.

Then Facebook will send you back the response with post id and other lots of information that you might want to keep it for later reference like to get metrics on the post – how many likes, impressions, shares.. which will help you to improve in the long run.

Let me know if you have any questions or other methods.