Large chunks of code can also be "commented out" using the preprocessor directives #if 0 and #endif. This is useful when the code contains multi-line comments that otherwise would not nest.
#if 0 /* Starts the "comment", anything from here on is removed by preprocessor */
/*...
defmodule Selection do
def sort(list) when is_list(list) do
do_selection(list, [])
end
def do_selection([head|[]], acc) do
acc ++ [head]
end
def do_selection(list, acc) do
min = min(list)
do_selection(:lists.delete(min, list), acc ++ [min])
end
defp m...
Developers often need to design web sites that allow users to upload a CSV file. Usually there is no reason to save the actual CSV file since the data will processed and/or stored in a database once uploaded. However, many if not most, PYTHON methods of parsing CSV data requires the data to be rea...
In your method or any lifecycle hook that changes the array item at particuar index
new Vue({
el: '#app',
data:{
myArr : ['apple', 'orange', 'banana', 'grapes']
},
methods:{
changeArrayItem: function(){
//this will not work
//myArr[2] ...
You can perform the same change instead of using Vue.$set by using the Array prototype's splice()
new Vue({
el: '#app',
data:{
myArr : ['apple', 'orange', 'banana', 'grapes']
},
methods:{
changeArrayItem: function(){
//this will not work
...
If yoi have nested array, the following can be done
new Vue({
el: '#app',
data:{
myArr : [
['apple', 'banana'],
['grapes', 'orange']
]
},
methods:{
changeArrayItem: function(){
this.$set(this.myArr[1], 1, 'strawbe...
If we want to look at a scene as if we had photographed it with a camera, we must first define some things:
The position from which the scene is viewed, the eye position pos.
The point we look at in the scene (target).
It is also common to define the direction in which we look. Technically we n...
To define your own menu, create an XML file inside your project's res/menu/ directory and build the menu with the following elements:
<menu> : Defines a Menu, which holds all the menu items.
<item> : Creates a MenuItem, which represents a single item in a menu. We can also create a n...
Drupal console brings scaffolding to the Drupal ecosystem and makes it easy to generate a content entity.
In most instances you will find it easier to work with a custom entity within a custom module.
Step 1 : Generate a module
vendor/bin/drupal generate:module
Follow the prompts and create yo...
To list all the packages installed in ubuntu, type below command
$ apt list --installed
Output will show all the installed packages.
Listing... Done
accountsservice/trusty-updates,now 0.6.35-0ubuntu7.3 i386 [installed]
acl/trusty,now 2.2.52-1 i386 [installed,automatic]
acpid/trusty,...
A search request can be executed purely using a URI by providing request parameters. Not all search options are exposed when executing a search using this mode, but it can be handy for quick "curl tests".
GET Index/type/_search?q=field:value
Another useful feature provided is highlight...
#include <iostream>
int main()
{
int value;
std::cout << "Enter a value: " << std::endl;
std::cin >> value;
std::cout << "The square of entered value is: " << value * value << std::endl;
return 0;
}
The most basic implementation of a union-find data structure consists of an array parent storing the a parent element for every element of the structure. Following these parent 'pointers' for an element i leads us to the representative j = find(i) of the set containing i, where parent[j] = j holds....
If we do many merge operations on a union-find data structure, the paths represented by the parent pointers might be quite long. Path compression, as already described in the theory part, is a simple way of mitigating this issue.
We might try to do path compression on the whole data structure after...
In our current implementation of merge, we always choose the left set to be the child of the right set, without taking the size of the sets into consideration. Without this restriction, the paths (without path compression) from an element to its representative might be quite long, thus leading to la...
There are 2 way of enabling internal debugging in log4net:
Specify the log4net.Internal.Debug option in the application's config file
Enable log4net's internal debug programmatically
Specify the log4net.Internal.Debug option in the application's config file
This is the preferred method to en...