Sufi Nawaz

I build stuff

Spring Boot Starter App with Elasticsearch

Posted by in Apps, Code Snippets

This weekend, I needed to set up a quick backend service with RESTful API that uses Elasticsearch as the datasource. I’d been working with Spring framework for a while but haven’t had to use Spring boot for anything related to my work. So, I read up on the latest Spring Boot documentation and went over to to create a barebone Spring Boot app that uses Elasticsearch. The whole process took a matter of few minutes, once I gathered the proper information to set up a starter app. Here’s a…read more

SELinux settings to allow apache to send mail

Posted by in Code Snippets, Tutorials

I was working in a WordPress instance today that is installed in a Centos box. The issue was that I could not send any email through wp_mail() function in wordpress, which essentially uses PHP’s mail() function, which in turn, uses sendmail. So the very first thing I’ve tried doing was to create a simple PHP test script and ran it from the machine locally. The email worked fine so I knew sendmail was not the problem. Next, I tried to execute the script over the webserver, and sure enough, the…read more

Forwarding from non-www to www domain using URL rewrite rules in Apache

Posted by in Code Snippets, Technology

Problem Description: With the installation of WordPress multisite network in my site, entering the URL took me to the signup page whereas entering took me to the homepage as it should! I wanted to redirect to and to Solution: I put the following block of codes right under the rule¬†RewriteEngine On in .htaccess file and everything is a smooth sailing here onwards! RewriteCond %{HTTP_HOST} ^ [NC] RewriteRule ^(.*)$$1 [L,R=301] PS: 301 is a search engine friendly HTTP redirect.  


How to parse RSS Feed XML from Blogspot using PHP

Posted by in Code Snippets, Technology

Mighty PHP allows us to do just about anything our hearts desire. Copy and paste the following code to your web page, and you’ll be parsing blog posts from blogspot in no time. The nifty little simplexml_load_file function used here allows you to parse XML files with a level of ease comparable to picking teeth with a toothpick. This function alone opened up a new horizon of creativity for me. I hope you guys find this useful and come up with your own creative ways of exploiting this function for…read more


Oh stop it Robots! Pretty please?

Posted by in Code Snippets, Technology

So most of us who have a website, usually want the contents to be searchable over the world wide web – I mean that’s the whole point for putting up a website in the first place, right? While we are so eager about our contents getting more hits, there are rare cases however, when we actually do feel a bit shy about the popularity of our pages over search engines like Google. It is then and only then do we look for ways to tell the web robots to stay…read more