I am not sure how many of the developers note this when using this wordpress function, but if you didn't notice this, then you might end up with performance issues.The function i am taking about is update_option.Two arguments are required to invoke the function which is the option name and option value. The performance issue will happen if you don't specify the third argument to false. The third argument...
My first contribution to wordpress core
on December 25, 2022
with
No comments
Yesterday i made my first contribution towards wordpress core ( its not merged yet ). In the past i have created an issue about the docs related to image size which is how i got this badge.What was the fix about ?When wordpress deletes a subsite, it drops all the tables related to the subsite. The issue is it doesnt consider there may be foreign key constraints in the external plugin tables. This...
Convert yaml to env variables in a single step
on December 24, 2022
with
No comments
Sometimes you wanted to convert the yaml files in to env variables which will be used on docker-compose.yaml. I had a valid usecase where i had to set spring yaml variables from docker-compose.To do that it usually involves the flattening of yaml keys, converting them to uppercase, then set the valueThis...
Running your wordpress site on github
on December 24, 2022
with
No comments
Running a wp instance requires you to pay for hosting. Even though you publish occasionally you need to keep the instance to running. What you can do is to build static html, css webpages. There are several builders available which does this. But you will miss wp customization and several other features in those static site builders. To solve this issue, i created gitpress.https://github.com/naveen17797/gitpressThis...
I hate methods/functions returning multiple types
on December 24, 2022
with
No comments
Basically the title.i always see these functions like function f1 ( $a1, $a2, $a3 ) { if ( $a1 ) { return false; } if ( $a2 ) { return 'some string'; } return array('some data');}When the code returns multiple types from a single function it automatically becomes code smell.Because whenever i want to use this function f1, i would need check the type it returned.$result = f1( $a1, $a2, $a3 );if (...
Testing spring webclient without spring context
on December 24, 2022
with
No comments
Spring webclient is an important component in the spring framework. Its highly customizable, allows us to do perform all the http operations in a declarative way.But the check is you cant unit test the spring webclient. To perform assertions you would likely need to use wiremock which takes a lot of time for the tests to initialize and run. This affects the motivation to perform the test driven development.so...
How to use the action scheduler to run a long running task?
on December 24, 2022
with
No comments
If you are looking to run a Task T which cannot be split in to units, then you can stop reading right here. The ability to run long running task until it completes is restricted by hosting provider. But in this article I will show you how to process large number of items by creating a action scheduler queue.What action scheduler allows us to do?By default it doesn't implement any queuing system to...
This one php operator you didnt knew about
we all knew when you want to execute shell commands in php we have a list of functions like shell_exec, exec, popen, etc to execute the code<?php echo shell_exec('ls'); ?>but today i came to knew about the backtick operator which does the same<?php echo `ls`; ?>The backtick operator (``) in PHP is used to execute shell commands. It is similar to the shell_exec() function, but it allows...
How can i use async pipe to handle click or other user event ?
Almost all of the tutorials related to async pipe is related to loading data from api. But there is another thing you can do with it. Lets say you have a button which sends some data to api. The imperative code would look something like this@Component({ selector: 'app-root', template: `<button (click)="click()"></button>`, styleUrls: ['./app.component.css']})export class AppComponent...
RxJs: How to handle errors in infinitely emitting observable
Lets say i have a button which sends an api request to external server when clicked. The api requests may fail occasionally, we would want the observable to keep running even though a failure has occurred on the pipeline.lets use this exampleimport { fromEvent, scan, map, of, catchError, EMPTY} from 'rxjs';let i = 0;fromEvent(document, 'click').pipe(map(() => { i += 1; if...