Skip to content

2016

Swap File to create extra memory

While renewing my LetsEncrypt certificate, I found myself in a strange situation where the certbot won't run asking me to update pip and then each time I tried updating pip it failed with the error error: command 'x86_64-linux-gnu-gcc' failed with exit status 4.

It turns out that this happens due to low memory and with my digitalocean droplet being the cheapest one this was bound to happen sooner rather than later. Fortunately there is a way around it as explained below.

Use of following commands will ensure that the swap file is created which in turn will help avoid the 'error: command 'x86_64-linux-gnu-gcc' failed with exit status 4'.

Following commands will create a swap file:

Note 7 to OnePlus 3

I was a super excited owner of Note 7 in September this year and then in few days the happiness started disappearing as the news of exploding Note 7 started appearing all over the internet.

Then came the notice to exchange the Note 7 which I dutifully did and assured that nothing will now go wrong I started enjoying that gem of a device. Alas, it was not to be and the device was recalled for good. Being a user of Note devices for so long and yet unable to continue with my old Note 3, I decided to go for some interim device - you know until Samsung decides to get the act right and bring the next Note device to the market.

Grav - CMS with a difference

While I love Ghost as a blogging platform, it is not best placed for things other than blogs - after all that is the basic idea behind creation of this wonderful tool.

As I wanted to host a static website using tools that don't require a database or rely on php, I went searching on interwebs. I came across a lot of options and the most popular one appears to be Jekyll and it's variants (Nikola and such) but they require a lot of terminal activity which won't go well for regular end user responsible for maintaining content of the static website in question.So I continued looking and came across this wonderful project called Grav.

Grav is super fast, very pretty and extremely easy to deploy and maintain. Additionally, it has very good documentation.

The key features that I absolutely loved are as below:

Ethercalc

Ethercalc is good tool which can be selfhosted. It is fairly simple to do so. Though it will be available for anyone who has the URL because there is no inbuilt login mechanism.

Fix for PHP Issues after upgrade to Ubuntu 16.04.1 (Xenial)

After updating from Ubuntu 14.04, the php and Apache stopped being friends and one of the WordPress site I maintain went all white and admin page was just showing php code. This is apparently because of a known issue in 16.04 with upgrade to php7 as shown on the ubuntu forum here.

Using the guidance from this link and with some more of duckduckgo search later, I managed to resolve the problem thus:

Tomcat 8.5.4 on Fedora behind Nginx

Install Oracle Java

1
2
3
4
5
6
#install jdk
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u102-b14/jdk-8u102-linux-i586.rpm"
#install jre
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http://www.oracle.com/ oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u102-b14/jre-8u102-linux-i586.rpm"
#enable firefox plugin
alternatives --install /usr/lib/mozilla/plugins/libjavaplugin.so libjavaplugin.so /usr/java/jdk1.8.0_102/jre/lib/i386/libnpjp2.so 20000

Tip

URL for JDK and JRE is best obtained directly from oracle website

MySQL function to calculate elapsed working time

I wrote this function to cater for a specific requirement and I don't know if there are better ways of doing it but this saved tremendous amount of time and might have real time application elsewhere.

Problem Statement:

Find out the age of an incident in working minutes, given the following:

  1. Time and Date of when an incident was logged
  2. Time and date of when the same incident was closed
  3. Opening time of the site for which the incident was logged
  4. Closing Time of the site for which incident was logged
  5. Country of the site for which incident has been logged

Assumption

It is assumed that opening and closing times are same on all working days and that all the sites are closed on holidays and weekends

Function should take all the above five "given" as parameter and then calculate age of the incident.