Generate all combinations of a string using javascript
Generate all combinations of a string
Generate all combinations of a string
Anargam An anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once. For example, “Listen” = “Silent”, “evil” = “vile”, “restful” = “fluster”
Return the length longest word from a string
Return the most common character from the string
A palindrome is a word, number, phrase, or other sequence of characters which reads the same backward as forward, such as madam or racecar. Return True if it”s a palindrome and False if not palindrome
Reverse a string using javascript
Hide other shipping rates when free shipping is available in Woocommerce WordPress
Left rotate array using javascript Rotate array by d digits using javascript Method 1 using shift() and push() Method 2 using ES6 Spread Operator and Slice() – one liner
Flatten a multidimensional associative array using javascript
Below commands will setup WordPress, MySQL & PHPMyAdmin with a single command. Add the code below to “docker-compose.yaml” and run the command
Show commands & management commands Docker version info Show info like number of containers, etc WORKING WITH CONTAINERS Create an run a container in foreground Create an run a container in background Shorthand Naming Containers TIP: WHAT RUN DID Looked for image called nginx in image cache If not found in cache, it looks to …
Chain-of-responsibility pattern The chain-of-responsibility pattern is a behavioral design pattern consisting of a source of command objects and a series of processing objects. Each processing object contains logic that defines the types of command objects that it can handle; the rest are passed to the next processing object in the chain. A mechanism also exists …
Design Patterns in PHP – Chain-of-responsibility pattern Read More »
Observer pattern The observer pattern is a software design pattern in which an object, named the subject, maintains a list of its dependents, called observers, and notifies them automatically of any state changes, usually by calling one of their methods. It is mainly used for implementing distributed event handling systems, in “event driven” software. In …
Strategy pattern The strategy pattern (also known as the policy pattern) is a behavioral software design pattern that enables selecting an algorithm at runtime. Instead of implementing a single algorithm directly, code receives run-time instructions as to which in a family of algorithms to use. Strategy lets the algorithm vary independently from clients that use …
Template method pattern The template method is a method in a superclass, usually an abstract superclass, and defines the skeleton of an operation in terms of a number of high-level steps. These steps are themselves implemented by additional helper methods in the same class as the template method. The helper methods may be either abstract …
Design Patterns in PHP – Template method pattern Read More »
Adapter design pattern The adapter pattern is a software design pattern (also known as wrapper, an alternative naming shared with the decorator pattern) that allows the interface of an existing class to be used as another interface. It is often used to make existing classes work with others without modifying their source code. An example …
The Decorator Pattern, Adapter Pattern, Template Method Pattern, Strategy Pattern, Observer Pattern Decorator design pattern In object-oriented programming, the decorator pattern is a design pattern that allows behavior to be added to an individual object, dynamically, without affecting the behavior of other objects from the same class. The decorator pattern is often useful for adhering …
Design Patterns in PHP – Decorator design pattern Read More »
Insert an associtive array ain another assoInsert an associative array in another associative array array_splice() or array_merge() php functions doesn’t preserve keys. So if we use these functions then new array key will be [0]Instead we will use array_splice() and use ‘+’ to concatenate the arrays
Add an array in the middle on another associative array in php
Find the symmetric difference between arrays using javascript In mathematics, the symmetric difference of two sets, also known as the disjunctive union, is the set of elements which are in either of the sets, but not in their intersection. The mathematical term symmetric difference (△ or ⊕) of two sets is the set of elements …
Find the symmetric difference between arrays using javascript Read More »
What is higher order functions? A function that takes or returns another function has become “higher-order”. Higher-order functions let us abstract common actions like map, filter, and reduce. Higher-order functions can be set as object properties. They are useful if you are calling a list of functions in response to an event. The javascript Event …
Check if first letter of sentence is capital or not
We will create a signup form with Email, Password, Role, Education etc. First on all install the vue cli Now create a vue project from the cli Now cd into web-form directory Here you can start the web server using below command Now lets start building the vue Signup form First go to src/components directory, …
Here we will take ROT13 encoded string as input and returns a decoded string.
Conditional rendering can be achieved using v-ifConditional display can be achieved using v-show First create a vue project using vue cli Now change directory start the server Lets start building the VUE component inside src/components/showHide.vue Remove HelloWorld.vue component and register showHide.vue component in App.vue Your showHide.vue component will look like this:
There are few ways to check vue js version: npm v vue run this on the terminal Check package.json, code will be something like this If you have vue dev tools installed then go to the Vue tab and you should be able to see the version there
You can measure the performance of javascript code using console.time() function. This can be helpful in debugging and optimizing code which is taking lot of memory. console.time() can be used with console.timeEnd(). console.timeEnd() function tells console to stop calculating the time. You will see result as below: Running loop :0 timesRunning loop :1 timesRunning loop …
Measure execution time of a function using javascript Read More »
1) Check Page type using is_page() function 2) Check Page using get_post_type() function 3) Check Page using post() function 4) Check Post type using is_single() function 5) Check Post type using get_post_type() function 6) Check Post type using get_post() function
Count number of same characters in a string and display in the array using javascript
One-liner solution with ES6 syntax