First Surgery in Germany

Around 5 years ago when I was still in Malaysia, I was at a company event at A’Famosa Resort in Malacca. The whole company and their families were invited to spend the weekend together, and enjoy the nice Malacca food, while our days were full of activities and games. one of those games that we played once was the infamous tug of war. I don’t even remember when was the last time I played that game as a child, anyhow even the most boring games could be fun when you’re playing them with friends and colleagues. but apparently, my long-trained programmer’s body was not strong enough to cope with me pulling a rope as hard as I could just to make my team win.

Continue reading “First Surgery in Germany”

Parsing ndjson stream API’s with PHP

Readable Streams are API responses that are broken into small chunks and sent to the client. As the client should be able to parse the chunks of received data as they arrive the conventional JSON responses are not ideal to be used for streams.

So In most cases, streamable API endpoints should send the data line by line. ndjson is a good option for sending JSON structured data in a streamable way. if you have not heard about ndjson before, it stands for new line delimited json.

First thing first we should call the API via Guzzle, by default guzzle uses PSR-7 stream object to represent the responses.

Here is a sample call to a streaming API that returns a stream response object:

<?php
$stream = $guzzleClient->get("http://stream-api.com/api",
    [
        'stream' => true,
    ]
)->getBody();

Now that we have stored the stream object in $stream variable we can use the “eof” method to verify we have not reached the end of the streamed data. by utilizing the helper readline we will read the output line by line. which should give us a single JSON object.

while (! $stream->eof()) {
  $line = Utils::readLine($stream);    
}

as simple as that we can read chunked received data from a streaming API with php.

Ok Google, Please do not play “Someone You loved by Lewis Capaldi”

I don’t know who Lewis Capaldi is, I don’t really wanna know either. but recently he has turned into a problem in my life, and I certainly want him off my Speaker.

I use Google Home speakers, both in my bedroom and living room. I’ve been using Google Speakers for a couple of years now. recently, I feel that their AI experience has degraded, a lot. I don’t know if it is because of me forgetting how to speak English (blame it on being stuck at home for over a year), or the more people are using it is blowing its training models up. whatever is going on, the fact that it almost plays “Someone You Loved by Lewis Capaldi” is becoming intolerable for me.

I’m a pretty extremist when it comes to music, I listen to it every day, everywhere but not everything. I only listen to Post Rock, and sometimes when it gets too dark in my head, I play some random Jazz songs to change the mood.

So dear Google, Spotify, or whoever is to blame, please do not play “Someone You loved by Lewis Capaldi” the next time I ask for: some music or something to play.

I even started to look up ways to block Google from playing a specific song and found this guy claiming on Reddit that saying “hey Google, never play that song again” seemed to help with his wife’s taste of music.

I don’t know if this works yet or not, as a matter of fact right before writing this blogpost I asked it from my Speaker, so I guess fingers crossed to me 🤞🏻

Update 15 May 2021: it’s now 2 days passed since I’ve tried asking my speaker to “never play that song again”, and it seems the solution was working! I have not heard Lweis since then.

pwdreset.com a Password Reset Service

Wordpress Password Reset Service
pwdreset.com – Password Reset as Service

Over the past week, I spent my time after work on building a password reset service that allows website owners to reset their WordPress passwords quickly without technical knowledge, and that is how pwdreset was created.

WordPress comes with its own password reset functionality, but there are scenarios where the “Forget Password” does not work.

Continue reading “pwdreset.com a Password Reset Service”

How to Reset WordPress Password using FTP

Reset WordPress Password with FTP

in this post, I am going to show you the way that you can reset your WordPress admin Password via FTP. 

WordPress stores user credentials along with other contents in the database, to reset WordPress password using FTP we need to make be able to read and write in the database.

Continue reading “How to Reset WordPress Password using FTP”