Catalan numbers algorithm is Dynamic Programming algorithm.
In combinatorial mathematics, the Catalan numbers form a sequence of natural numbers that occur in various counting problems, often involving recursively-defined objects. The Catalan numbers on nonnegative integers n are a set of numbers t...
A palindrome is a word that can be read both ways, like 'kayak'.
This example will show how to find if a given word is a palindrome using Python3.
First, we need to turn a string into a stack (we will use arrays as stacks).
str = "string"
stk = [c for c in str] #this makes an array: [&...
According to Wikipedia:
[A] software design pattern is a general reusable solution to a commonly occurring problem within a given context in software design. It is not a finished design that can be transformed directly into source or machine code. It is a description or template for how to solve ...
Viewchild offers one way interaction from parent to child. There is no feedback or output from child when ViewChild is used.
We have a DataListComponent that shows some information. DataListComponent has PagerComponent as it's child. When user makes a search on DataListComponent, it gets a data fro...
If you want to create a custom validation rule, you can do so for instance in the boot method of a service provider, via the Validator facade.
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Validator;
class AppServiceProvider extends ServiceProvider
{
...
public class KnapsackProblem
{
private static int Knapsack(int w, int[] weight, int[] value, int n)
{
int i;
int[,] k = new int[n + 1, w + 1];
for (i = 0; i <= n; i++)
{
int b;
for (b = 0; b <= w; b++)
{
...
Suppose, that we have three users :
The Administrator of the database > admin
The application with a full access for her data > read_write
The read only access > read_only
With below queries, you can set access privileges on objects created in the future in specified schema.
ALTER ...
If you're Using VueJS2 and like to use JSX along with it. In this case,to use the slot, the solution with example is below.We have to use this.$slots.default It's almost like this.props.children in React JS.
Component.js :
export default {
render(h) { //eslint-disable-line
return (
...
Schema changes:
You will need to define a new field type in your solr schema file and then you can create fields of that type. Example schema snippet:
<!-- Source: solr/example/.../conf/schema.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<schema name="a...
Let's get some theoretical knowledge before moving to the example. There are three important terms being used here Analyzers, Tokenizers, and Filters. To create such custom field you will need to create an analyzer with one tokenizer and one or more filters. As mentioned here, you can have only one ...
Creating a connection
According to PEP 249, the connection to a database should be established using a connect() constructor, which returns a Connection object. The arguments for this constructor are database dependent. Refer to the database specific topics for the relevant arguments.
import MyDBA...
You can parse XML from a string or from a XML file
1. From a string
$xml_obj = simplexml_load_string($string);
2. From a file
$xml_obj = simplexml_load_file('books.xml');
Example of parsing
Considering the following XML:
<?xml version="1.0" encoding="UTF-8"?>
&l...
You need to change price scope 'Global' to 'website'
(Sysytem->Configuration->Catalog->Catalog->Price)
$client = new SoapClient('http://your-web-site/api/soap/?wsdl');
$API_USER = 'your-api-user';
$API_KEY = 'your-api-key';
$session = $client->login($API_USER, $API_KEY);
$result...
var x = 5;
var str = "if (x == 5) {console.log('z is 42'); z = 42;} else z = 0; ";
console.log("z is ", eval(str));
The use of eval is strongly discouraged. See the Remarks section for details.