Stars and Moon

This poem was written by my favorite poet Allama Iqbal. I translated it for my English class during my freshman year.

“The view up here is the same as ever.

We are tired of shining and shining.

Our work is to walk, day and night.

Walk and walk and walk forever.

Everything in this universe is anxious.

Peace, whatever it is, does not exist.

Everything is being tortured by time.

Stars, man, trees, rocks, Everything.

Will this journey ever end?

Will we ever see our destination?”

“My friends,” replied the moon,

“O travelers in the field of the night.

Life happens because of the movement.

This is the old culture of this universe.

Time’s horse flies.

Because it is hit by the lash of desires.

On this path, it is not possible to stop.

Because death is hidden within rest.

Those who strove have left us behind.

And those who slept are crushed.

The end of this journey is true beauty.

It begins with true love and ends with true beauty.”


Once I Fell in Love

In this hot desert heat,

you were a cool breeze

gone in a moment just as you came,

left me behind to wonder if you will ever return

to mess up my hair,

to touch my thirsty lips softly

you were a sweet dream,

vanished with the stars in the morning

leaving me to wake up in the blinding sunlight,

to look for a shade where there are no trees

you were a beautiful song,

which I cannot hear anymore in this noise

I tried dancing to you,

but there was no floor

a wish which cannot be fulfilled, a desire which will never die,

my hope was in vain but I held on to it.

you were a magic happened in a blink of an eye,

just as a shooting star disappears in the night sky

you were a poem written with an ink,

on paper left in the rain, washed away before I could read.


LeetCode 3. Longest Substring Without Repeating Characters

Here is my solution in PHP to this problem.

class Solution {

    /**
     * @param String $s
     * @return Integer
     */
    function lengthOfLongestSubstring($s) {
        $n = strlen($s);   
        $ans = 0;
        $i = 0;
        $j = 0;
        
        $arr = [];
        
        while ($i < $n && $j < $n) {
            if (!in_array($s[$j], $arr)) {
                $arr[] = $s[$j++];
                $ans = max($ans, $j-$i);
            } else {
                array_splice($arr, 0, 1);
                $i++;
            }
        }
     
        
        return $ans;
    }
}

And here is solution JavaScript based on this Udemy lesson:

/**
 * @param {string} s
 * @return {number}
 */
var lengthOfLongestSubstring = function(s) {
    if (s.length <= 1) return s.length;
    
    const seenChars = {};
    let i=0, longest=0;
    
    for (let j=0; j<s.length; j++) {
        const currentChar = s[j];
        const currentCharIndex = seenChars[currentChar];
        
        if (currentCharIndex>=i) {
            i = currentCharIndex+1;
        }
        
        longest = Math.max(longest, j-i+1);
        seenChars[currentChar] = j;
    }
    
    return longest;
};

Hina

I know it’s cliche,

but that’s the world’s way.

Sitting here in this dark cafe,

you are my dreams’ brilliant ray.

Because of you I wanna say,

Happy Valentine’s Day!


A poem by Allama Iqbal


Json_error_ctrl_char

I was using mcrypt to encrypt json_encoded data.

On other side, mycrypt was able to decrpyt data but json_decode was not working. It would throw JSON\_ERROR\_CTRL_CHAR error.

However, without mcrypt, json_decode worked flawlessly.

After some trial and error, I found that applying trim function after decrypting data would let me use json_decode without any issues.


Find Large Directories on AIX

I usually run it from under a partition which is running out of space. It can take a while.

du -g | sort -n -r


Error Xcode Select Error Tool Xcodebuild Requires Xcode Active Developer Directory Command Line Tools Instance

Playing with Cordova, I was getting this error when building iOS version:

Error: xcode-select: error: tool 'xcodebuild' requires Xcode,
but active developer directory is a command line tools instance

Even full install of Xcode didn’t fix this error.

The solution was to run following command to use full Xcode instead of command line tools version that I had installed earlier:

sudo xcode-select --switch /Applications/Xcode-beta.app/Contents/Developer


Setup Outgoing Email on Lightsail Ubuntu VPS

I followed instructions here: https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-postfix-as-a-send-only-smtp-server-on-ubuntu-18-04

Everything seemed okay but email were not getting delivered. Logs showed me that smtp connections were timing out:

tail -f /var/log/mail.log
May  3 12:28:10 postfix/smtp[3160]: connect to gmail-smtp-in.l.google.com[172.217.197.27]:25: Connection timed out
May  3 12:28:10  postfix/smtp[3160]: connect to alt1.gmail-smtp-in.l.google.com[2800:3f0:4003:c00::1a]:25: Network is unreachable
May  3 12:28:40 postfix/smtp[3160]: 4984C41A1E: to=<xxxx@gmail.com>, relay=none, delay=3246, delays=3186/0.01/60/0, dsn=4.4.1, status=deferred (connect to alt2.gmail-smtp-in.l.google.com[2a00:1450:400b:c00::1a]:25: Network is unreachable)

However, I could ping any of above ip addresses just fine.

Next step was to see if ip address of my VPS was blacklisted in RBLs, I used https://mxtoolbox.com/blacklists.aspx. None of my ip addresses were in any black list.

Port 25 was open in firewall, both on server and in Lightsail’s networking UI.

After spending another hour or so troubleshooting, I found this thread: https://forums.aws.amazon.com/thread.jspa?threadID=316397. It seems AWS/Lightsail have recently started to throttle outgoing emails, but by throttling they meant completely blocking it. You need to open a support ticket to remove these limits here: https://console.aws.amazon.com/support/contacts?#/rdns-limits

So I submitted my request, hopefully, this will resolve the issue.

UPDATE: It worked, now my VPS can send outgoing emails.


Files Empty in html form?

Put enctype="multipart/form-data" in your form tag.