Yohanes Mario [dot] com

my online scrapbook of scrambled thoughts

Since forever I've been looking for a way to easily print my blog content from php inside a html text input field or textarea. The results has always been awful or awkward at best. For those who have been making admin pages their whole life would know this. Printing an escaped HTML character is easy, but printing it inside a textarea is another story. The root cause of this is because <input type='text' /> and <textarea></textarea> have different ways of displaying content.

And then I got an epiphany, why don't I use JSON to encode the data, and then use javascript to fill those empty text fields and textarea? And that's what I did. This way, I avoid printing directly into the textarea altogether. The way to do this is easy, I will have two variables, namely $json which contains the JSON encoded string, and $result which contains the string which will be echoed.

<?php

    $json = json_encode(array(
        "textareaId" => $textareaContent
    ));

    $result = "<script type='text/javascript'>
        var preloadedData = ".$json.";

        $('#textareaId').val(preloadedData.textareaId);
    </script>";

Using this method, I can just use jQuery's .val() method to fill any text input, regardless of it's type.

That's all. Hope this helps. Happy blogging!

   Posted in CMS        Yohanes Mario Chandra        0 Comments

Let's encrypt is a free, automated, and open Certification Authority.

That's what's said on the main page of their website. I've been looking into this thing for so long, but just now that I have learned that they provide a way to manually generate certificates for shared web hosting with no root shell access like the one I use. However, upon further investigation, and as I try to generate that certificate myself, I found that their documentation is lacking in terms of clarity, especially for my specific use case. In case you didn't notice, I have successfuly generated the certificate, but not without any hurdles. That's what I'm going to share here.

The steps are as follows (assuming you use Ubuntu or any equivalent distributions):

  1. Download certbot by using the command: wget https://dl.eff.org/certbot-auto.
  2. Mark it as executable: chmod a+x ./certbot-auto
  3. Begin to obtain certificate:./certbot-auto certonly --manual -d www.example.com -d example.com
  4. You will be asked to create some files with certain content in your public_html. Do each of that, and then you will get your certificate.
  5. Your certificate will be located at /etc/letsencrypt/live/example.com/fullchain.pem,
  6. and your private-key will be located at /etc/letsencrypt/live/example.com/privkey.pem.
  7. Copy them to your web hosting, install them, and you're good to go.

That's all. I hope this helps. Cheers.


After giving it some thought, I declare that from now on, I will be using the old blog again, since I actually want to be able to fully control every aspect of it.

   Posted in Blog        Yohanes Mario Chandra        0 Comments