Coding Bot | Program Codes

Like Us On Facebook

Follow Us On Twitter

Drop Down Menu

Monday, 14 January 2019

Log4j SMTP Appender Using System Environment Variables

Hey friends!

Earlier last week, I was stuck for a short while in a what should've been an easy task, but took my more than expected working hours to completely solve that: SMTP appender for Log4j.

So as we all know, SMTP or Simple Mail Transfer Protocol is used to send emails from your java program, generally when a particular level of exception occurs in your code. Log4j is a well known Java logging utility, but this particular appender wasn't discussed as about much as I expected earlier. 


Earlier I was using log4j2.yml file for logging but due to some versioning reasons, it wasn't picking up the Log4j keywords properly from the version of Log4j that I added. So eventually I had to shift to using the XML version.

Thursday, 10 January 2019

Fixed — ElasticSearch CrateDB Logstash — ClusterBlockException Forbidden Index Read-Only

Hey friends,

Ever since I started working with ElasticSearch, CrateDB and Logstash, I have faced plenty of issues and exceptions that maybe had a clear reason and fix but were not documented well anywhere. I had to research through tons and tons of documentation and StackOverFlow pages to atleast get some hints as to what might be causing the issue and how to fix it. 

It was then I decided that I will document such problems for easy access and quick solution for others. One such exception that I got multiple times was:

09:46:07.741 [main] ERROR ERROR: ClusterBlockException: blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];

This was due to:
[WARN ][o.e.c.r.a.DiskThresholdMonitor] [Piz Roseg] high disk watermark [90%] exceeded on [Piz Roseg][/crate/
[WARN ][o.e.c.r.a.DiskThresholdMonitor] [Piz Roseg] high disk watermark [90%] exceeded on [Piz Roseg][/crate/
[WARN ][o.e.c.r.a.DiskThresholdMonitor] [Piz Roseg] rerouting shards: [high disk watermark exceeded on one or more nodes]
[WARN ][o.e.c.r.a.DiskThresholdMonitor] [Piz Roseg] high disk watermark [90%] exceeded on [Piz Roseg][/crate/
[WARN ][o.e.c.r.a.DiskThresholdMonitor] [Piz Roseg] high disk watermark [90%] exceeded on [Piz Roseg][/crate/
[INFO ][o.e.c.r.a.DiskThresholdMonitor] [Piz Roseg] rerouting shards: [high disk watermark exceeded on one or more nodes]
[WARN ][o.e.c.r.a.DiskThresholdMonitor] [Piz Roseg] high disk watermark [90%] exceeded on [Piz Roseg][/crate/
[WARN ][o.e.c.r.a.DiskThresholdMonitor] [Piz Roseg] high disk watermark [90%] exceeded on [Piz Roseg][/crate/
[INFO ][o.e.c.r.a.DiskThresholdMonitor] [Piz Roseg] rerouting shards: [high disk watermark exceeded on one or more nodes]

The Cause:

This particular exception is caused by a very simple problem - Disk Space. You are definitely running out of disk space on the disk where ElasticSearch/Logstash/CrateDB is installed. 

Wednesday, 9 January 2019

Add/Edit Startup Applications in Ubuntu Linux

Hey friends,

I recently switched over to Ubuntu and I must say it feels a better and crunchier experience as compared to my alternate previous OS, the Windows. That said, switching over to Ubuntu brought its own set of problems and Ububtu 18.10 (Bionic Beaver) is not as stable as 17.04 was for me. 

So today I am going to share a very easy way to edit the startup applications on your Ubuntu machine. This approach should work for previous versions as well.

Now just like Windows, there are some startup applications in Linux which can be added/deleted as per your own convenience. Without further ado, let me show you how:

  • The most easy way is to first press Alt + F2 keys together.

  • Then write gnome-session-properties and press Enter. You will be presented with the following screen.

Sunday, 26 March 2017

How To Disable Copy Paste And Mouse Right Click Using JavaScript, CSS, jQuery

Unique content is a must for any budding website. Search engines rank your website not just on the basis of backlinks or social media shares, but most importantly how unique your content is and how helpful it is for the audience, which in turn is determined by the visits to a particular post.

However, not all of us think this way, there are and always will be a subset that just knows how to copy paste content. And the worst case will be when their posts show up higher in the search engine rankings than the original post. I can truly understand how frustrating this can be, especially if bloggers such as me and you devote a lot of time building such websites from the scratch and a small section simply copy pastes that content onto their own website.

So that's why today I decided to share 4 methods that can be used by you to block such Ctrl A + Ctrl V attempts on your website.

One method is by using JavaScript which disables copy-paste for your whole website and the other one uses CSS, which can also be used to enable copy-paste for some part of your posts.

Another one is by disabling mouse right click and disabling copy paste using jQuery.

Wednesday, 15 March 2017

How To Submit Website To Google,Bing,Baidu,Yandex,DuckDuckGo

Hello avid bloggers!
Today I'll share with you all how you can share your websites, blogs, RSS Feeds with all the major search engines. 

So there you are, working so hard on setting up your website or blog, you've worked on SEO, keyword density, good content, but much to your amazement, the Big Bosses aren't still indexing your website. 

Don't feel defeated yet, I have a way by which you can ping your website to these search engines.
BOOKMARK THIS PAGE RIGHT NOW, if you want to save your time. 

If your website or blog has a sitemap, then you can ping its URL to these search engines. This is one of the basic ways to let these engines know that your website has some updated content. 

Now even if you ping these, there's no guarantee till when their crawler will scan your website and index it, but it's still letting them know that you're ready with some awesome changes to your website or blog.

Search engines such as Google, Baidu (popular in China), Bing or Yandex (popular in Russia) might not automatically crawl your website, so this is one of the best ways to 'ping' them about your website's sitemap.

You just need to replace my sitemap with your website's or blog's sitemap and that's it. It will be pinged to these search engines automatically.