text:
Q: Calculate P&L on the arbitrary period Let's assume I have an array of trades (Buys/Sells), associated with timestamps.
[
  {
    "time": "01-05-2021", // DD-MM-YYYY
    "operation": "BUY",
    "amount": 2,
    "price": 10
  },
  {
    "time": "01-06-2021",
    "operation": "SELL",
    "amount": 1,
    "price": 15
  },
  {
    "time": "01-07-2021",
    "operation": "BUY",
    "amount": 2,
    "price": 20
  },
  {
    "time": "01-08-2021",
    "operation": "SELL",
    "amount": 3,
    "price": 25
  }
]

And I want to calculate P&L on these trades, using FIFO, but for arbitrary time period.
The problem is - calculated value depends on time period I'll choose.

*

*For 08.2021 it'll be 0 (3 items were sold, none was bought).

*For 07-08.2021 it'll be 10 (2 items were bought for total of 40, 2 were sold for total 50).

*For 06-08.2021 it'll be 0 (SELL 1 on 15 -> BUY 1 on 20 == -5 and BUY 1 on 20 -> SELL 1 on 25 == 5).

And so on.
The only working solution that I have right now is to calculate P&L values for each deal, from the beginning of trading activity. And then, just "cut off" everything beside required period. But it's not scalable, because with even without automated trading it can be thousands of deals each year.
The most obvious thing to do is to add some initial state to the beginning of given period, which will be starting point for all further calculations.
Are there any algorithms or tools which I can utilize to perform this task?
I'm a Javascript developer, and my solution works in the browser's runtime. Maybe I need some backend, maybe I need R with it's statistics-dedicated package...


text:
Q: Image file for Windows XP CTRL-ALT-DEL login box Way back before SP2, the guy who got me started down the IT support road showed me where the image was for the Windows XP Ctrl-Alt-Delete login box.
By replacing this image with a different image, we could make the entire login screen look how we wanted, rather than simple modifying the background behind the dialog.
However, we've both forgotten where this image is.
To be clear: We're not looking for an image on the dialog where we actually enter the login credentials. Nor are we looking for where you specify the corporate boilerplate message that occur immediately before where you enter your credentials. I want to know where the image is that is in the dialog which instructs you to press Ctrl-Alt-Delete to commence the login process.
Anybody know where this is?
Bonus points if you can point out where the locked computer dialog image is too.

A: I originally thought you wanted the background too, and gave the same answer as the others, but I think this is what you want.
First, the bitmaps are actually contained within a dll, but the part you are concerned with is not one bitmap image. The whole box is composed of a bitmap image on top, a little bitmap to the left, and text strings all contained in this dll.
c:\windows\system32\msgina.dll

I followed this document, and downloaded "Resource Hacker" (linked on the page) to edit the dll.
http://www.infocellar.com/winxp/customize-logon-screen.htm
To anyone trying this: BACKUP MSGINA.DLL BEFORE YOU DO ANYTHING.
The exact bitmap depends on the version, and frankly, I am not which one it is. Note that the bitmap only covers the top half of the login box. The rest is still contained within the msgina.dll, and can also edited using Resource Hacker. If you are using XP Pro, the image you probably want is in Bitmap>101 or 107.
You can use use Resource Hacker to copy out the bitmap, and to bring it back in.
The string text is contained in String Table>114.
I did not check in detail, but this also covers your bonus question too, I believe.

A: It appears to be in HKEY_USERS.DEFAULT\CONTROL PANEL\DESKTOP in the registry. You can also use HKEY_USERS.DEFAULT\CONTROL PANEL\DESKTOP\TILEWALLPAPER to set tiling on (set it to 1).

A: To put your favorite image or picture in the background of the logon screen :

*

*Click the Start button and select "Run"

*In the "open" field, type regedit and click ok

*In the registry editor, navigate to HKEY_USERS.DEFAULT\CONTROL PANEL\DESKTOP and double-click the string "wallpaper"

*Enter the full path and filename of the .bmp image that you want to use as background (the image must be in .bmp format)

*Click "ok" and close the registry editor

Reference: Customize Windows XP Logon Screen.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Dynamic auto-layout I'm a new in the programming and I know that there are a lot of staff about auto-layout or manipulation with constraints in the internet/stackoverflow and I searched everywhere however was unable to find answer on my question, so please advise if you can.
For example here is
UI example
So I have a tableView which is top constaints to top of ViewController and textView which is top constraints to bottom of tableView. So the question is, how can I dynamically change constraints based on the size of array in TableView. If TableView is empty, so then assign textView to ViewController, if array of tableView > 0, then assign to bottom of TableView. I tried something like this
@IBOutlet weak var textViewTopConstraints: NSLayoutConstraint! {
        didSet {
            if array.isEmpty {
                textViewTopConstraints.isActive = false
                textView.topAnchor.constraint(equalTo: ViewController.top, constant: 8).isActive = true
            } else if imageURL.count > 0 {
                textViewTopConstraints.isActive = false
                textView.topAnchor.constraint(equalTo: tableView.bottomAnchor, constant: 8).isActive = true
            }
        }
    }

However it's only working when app is loaded and then didn't call if array is changed. So basically, I can't understand how to call function or something that will track and change my constraints based on the size of my array. If this is a duplicate, could you please guide me to the right link where I can check this information.

A: Change table view frame and connect constraints between textfield and table view. Link to set table view frame is :- Change UITableView height dynamically


text:
Q: как используя onClick оставить валидацию полей (text, email)? Есть форма.
В ней следующие поля (FirstName, LastName, Company, Email, Password) + кнопка с Onclick (отправка данных на сервер).
У всех полей прописан параметр 'required', а для
email pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,3}$".

Вшитая в HTML5 валидация не работает с Onclick. Как можно исправить это?

A:
как используя onClick оставить валидацию полей (text, email)?

Вот так используя событий submit:

var form = document.querySelector('form')

form.addEventListener('submit', function(e) {
  // Не посылает на сервер
  e.preventDefault();
  //----------------------------------------------------------------
  // Проверка mail
  var mail = document.querySelector('.mail');
  var re = /[a-z0-9._%+-]+@[a-z0-9.-]+.[a-z]{2,3}$/;

  if (re.test(mail.value)) { // Если прошел
    console.log('Passes');
  } else{
   console.error('You shall not pass!');
  }
  //----------------------------------------------------------------
  // Так же можете проверять и text
})
<form action="">
  <input type="email" pattern="[a-z0-9._%+-]+@[a-z0-9.-]+.[a-z]{2,3}$" class="mail">
  <input type="submit">
</form>


text:
Q: How can I catch connection exception using Spring RabbitMQ and MongoDB? I'm using Spring and I'm getting the exception when the RabbitMQ is down the exception is thrown. I want to be able to catch it in order to print anything like "Retrying Connection".
org.springframework.amqp.AmqpConnectException: java.net.ConnectException: Connection refused (Connection refused)
        at org.springframework.amqp.rabbit.support.RabbitExceptionTranslator.convertRabbitAccessException(RabbitExceptionTranslator.java:62) ~[spring-rabbit-2.2.2.RELEASE.jar!/:2.2.2.RELEASE]
        at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:510) ~[spring-rabbit-2.2.2.RELEASE.jar!/:2.2.2.RELEASE]
        at org.springframework.amqp.rabbit.connection.CachingConnectionFactory.createConnection(CachingConnectionFactory.java:751) ~[spring-rabbit-2.2.2.RELEASE.jar!/:2.2.2.RELEASE]
        at org.springframework.amqp.rabbit.connection.ConnectionFactoryUtils.createConnection(ConnectionFactoryUtils.java:215) ~[spring-rabbit-2.2.2.RELEASE.jar!/:2.2.2.RELEASE]
        at org.springframework.amqp.rabbit.core.RabbitTemplate.doExecute(RabbitTemplate.java:2085) ~[spring-rabbit-2.2.2.RELEASE.jar!/:2.2.2.RELEASE]
        at org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:2058) ~[spring-rabbit-2.2.2.RELEASE.jar!/:2.2.2.RELEASE]
        at org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:2038) ~[spring-rabbit-2.2.2.RELEASE.jar!/:2.2.2.RELEASE]
        at org.springframework.amqp.rabbit.core.RabbitAdmin.getQueueInfo(RabbitAdmin.java:407) ~[spring-rabbit-2.2.2.RELEASE.jar!/:2.2.2.RELEASE]
        at org.springframework.amqp.rabbit.core.RabbitAdmin.getQueueProperties(RabbitAdmin.java:391) ~[spring-rabbit-2.2.2.RELEASE.jar!/:2.2.2.RELEASE]
        at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.attemptDeclarations(AbstractMessageListenerContainer.java:1820) ~[spring-rabbit-2.2.2.RELEASE.jar!/:2.2.2.RELEASE]
        at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.redeclareElementsIfNecessary(AbstractMessageListenerContainer.java:1801) ~[spring-rabbit-2.2.2.RELEASE.jar!/:2.2.2.RELEASE]
        at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.initialize(SimpleMessageListenerContainer.java:1337) [spring-rabbit-2.2.2.RELEASE.jar!/:2.2.2.RELEASE]
        at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:1183) [spring-rabbit-2.2.2.RELEASE.jar!/:2.2.2.RELEASE]
        at java.lang.Thread.run(Thread.java:748) [na:1.8.0_212]
Caused by: java.net.ConnectException: Connection refused (Connection refused)
        at java.net.PlainSocketImpl.socketConnect(Native Method) ~[na:1.8.0_212]
        at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) ~[na:1.8.0_212]
        at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[na:1.8.0_212]
        at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[na:1.8.0_212]
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[na:1.8.0_212]
        at java.net.Socket.connect(Socket.java:589) ~[na:1.8.0_212]
        at com.rabbitmq.client.impl.SocketFrameHandlerFactory.create(SocketFrameHandlerFactory.java:60) ~[amqp-client-5.7.3.jar!/:5.7.3]
        at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1113) ~[amqp-client-5.7.3.jar!/:5.7.3]
        at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1063) ~[amqp-client-5.7.3.jar!/:5.7.3]
        at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.connect(AbstractConnectionFactory.java:526) ~[spring-rabbit-2.2.2.RELEASE.jar!/:2.2.2.RELEASE]
        at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:473) ~[spring-rabbit-2.2.2.RELEASE.jar!/:2.2.2.RELEASE]

The same happens with MongoDB when losing connection which I would like do the same.
com.mongodb.MongoSocketException: mongo: Name does not resolve
            at com.mongodb.ServerAddress.getSocketAddresses(ServerAddress.java:211) ~[mongo-java-driver-3.10.1.jar!/:na]
            at com.mongodb.internal.connection.SocketStream.initializeSocket(SocketStream.java:75) ~[mongo-java-driver-3.10.1.jar!/:na]
            at com.mongodb.internal.connection.SocketStream.open(SocketStream.java:65) ~[mongo-java-driver-3.10.1.jar!/:na]
            com.mongodb.internal.connection.InternalStreamConnection.open(InternalStreamConnection.java:126) ~[mongo-java-driver-3.10.1.jar!/:na]
            at com.mongodb.internal.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:131) ~[mongo-java-driver-3.10.1.jar!/:na]
            at java.lang.Thread.run(Thread.java:748) [na:1.8.0_212]
Caused by: java.net.UnknownHostException: mongo: Name does not resolve
            at java.net.Inet4AddressImpl.lookupAllHostAddr(Native Method) ~[na:1.8.0_212]
            at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:929) ~[na:1.8.0_212]
            at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1324) ~[na:1.8.0_212]
            at java.net.InetAddress.getAllByName0(InetAddress.java:1277) ~[na:1.8.0_212]
            at java.net.InetAddress.getAllByName(InetAddress.java:1193) ~[na:1.8.0_212]
            at java.net.InetAddress.getAllByName(InetAddress.java:1127) ~[na:1.8.0_212]
            at com.mongodb.ServerAddress.getSocketAddresses(ServerAddress.java:203) ~[mongo-java-driver-3.10.1.jar!/:na]
            ... 5 common frames omitted

Is there a way to catch them using spring?

A: The ConnectionFactory interface which can be injected in your rabbitmq configuration allows setting an instance of the ConnectionListener interface. This interface provides 3 useful methods for monitoring connections:
// connectionFactory is injected connection factory of type ConnectionFactory

connectionFactory.addConnectionListener(new ConnectionListener() {
  @Override
  public void onCreate(Connection connection) {
    log.info("Method onCreate was called! Info about connection {}", connection);
  }

  @Override
  public void onClose(Connection connection) {
    log.info("Method onClose was called! Info about connection {}", connection);
  }

  @Override
  public void onShutDown(ShutdownSignalException signal) {
    log.info("Method onShutdown was called! The connection will be restored automatically. Check the exception below for more info.", signal);
  }
});

The onShutDown method is a good place to inform everyone that you are trying to restore the connection.


text:
Q: magento: URL querystring for adding product and applying discount coupon to cart I am a newbie, after extensive research and exploration I am able to figure out the following:
To add a product to cart I can use

/checkout/cart/add?product=76&qty=1

to apply discount code I can use

/checkout/cart/couponPost?coupon_code=WQ9D-XXXX

The code for it resides in file:

/public_html/app/code/local/Mage/Checkout/controllers/-

I would like to add product and apply discount code in one link such as:

/checkout/cart/couponPost?product=76&qty=1&coupon_code=WQ9D-XXXX

OR

/checkout/cart/add?product=76&qty=1&coupon_code=WQ9D-XXXX

OR
Any other means?
Is there a way to get this working? Idea is to embed this link in a newsletter so using one click the user is able to add the product to cart and get discount.
I have tried calling $this->couponPostAction(); from function addAction() and vice-versa but it does not work!

A: Got it working without modifying the code,
'http://www.example.com/checkout/cart/add?Product=76&qty;=1&return;_url=http://www.example.com/index.php/checkout/cart/couponPost?coupon_code=WQ9D-XXXX&return;_url=http://www.example.com/checkout/cart/'
the return_url has to be encoded.
Please see: http://www.magentocommerce.com/boards/viewthread/296763/

A: rukpat's answer doesn't work in Magento 1.8. You need to format the URL and query string like so, once you have extended the addAction method of the CartController:
http://www.example.com/checkout/cart/add?product=76&qty=1&return_url=http://www.example.com/index.php/checkout/cart/couponPost?coupon_code=WQ9D-XXXX

You can also omit the last return_url parameter. There's no need to include the ; (semicolons).
You can also add multiple products to the URL with multiple quantities by simply doing:
http://www.example.com/checkout/cart/add?product=76&related_product=28,28,28&return_url=http://www.example.com/index.php/checkout/cart/couponPost?coupon_code=WQ9D-XXXX

So simply adding &related_product=28,28,28 with multiple references to the product ID allows you to add multiple quantities of that item. Not very elegant but it works.
Of course, it would be better to extend the addAction method of the CartController.
In order for this solution to work in Magento 1.8 and above, you need to modify the CartController like so:
NOTE: Replace 'Namespace' with your own namespace (company name or your name etc).
etc/modules/Namespace_AddProductFromUrl.xml
<?xml version="1.0"?>
<config>
    <modules>
        <Namespace_AddProductFromUrl>
            <active>true</active>
            <codePool>local</codePool>
        </Namespace_AddProductFromUrl>
    </modules>
</config>

app/code/local/Namespace/AddProductFromUrl/controllers/Checkout/CartController.php
<?php
    require_once 'Mage/Checkout/controllers/CartController.php';

    class Namespace_AddProductFromUrl_Checkout_CartController extends Mage_Checkout_CartController {
        # overloaded addAction
        public function addAction()
        {
            // generate form_key if missing or invalid
            if ( ! ($formKey = $this->getRequest()->getParam('form_key', null)) or $formKey != Mage::getSingleton('core/session')->getFormKey())
            {
                $this->getRequest()->setParams(array('form_key' => Mage::getSingleton('core/session')->getFormKey()));
            }

            // do parent actions
            parent::addAction();
        }
    }

app/code/local/Namespace/AddProductFromUrl/etc/config.xml
<config>
    <frontend>
        <routers>
            <checkout>
                <args>
                    <modules>
                        <Namespace_AddProductFromUrl before="Mage_Checkout">Namespace_AddProductFromUrl_Checkout</Namespace_AddProductFromUrl>
                    </modules>
                </args>
            </checkout>
        </routers>
    </frontend>
</config>

A: I can verify that Gaz's code with above with Namespace_AddProductFromUrl does work on 1.8
In addition, if by chance your product is a bundled one, you have to use this format url:
http://domain.com/en/checkout/cart/add?product=24&qty=1&bundle_option[2]=4&bundle_option[3]=8


text:
Q: How do I write a SELECT .. WHERE IN clause using NodesJS and Postgresql? const deptCodes = ['001', '002', '003']

const getMembersQuery = {
   text: 'SELECT member_id FROM member_tbl WHERE dept_code IN ($1) AND delete_flg = 0',
   values: [deptCodes],
   rowMode: 'array'
};

const getMembersQuery Result = await client.query(getMembersQuery );

I am writing the above query but I am getting an error,
malformed array literal: "001,002,003"\

A: Try wrapping your depCodes in additional quotes
const deptCodes = ["'001'", "'002'", "'003'"]

or
const deptCodes = ['\'001\'', '\'002\'', '\'003\'']


text:
Q: Retrieving selected text from textarea when span is clicked in IE I want to get the selected text within the text area when 'span' is clicked. When I click button the selection works but not when I click on span.
Maybe because the selection is lost when span is clicked, but it's not happening when button is clicked?
How to fix it?
function Copy() {
  var theSelection = document.selection.createRange();
  alert(theSelection.text);
}

     <input type="button" value="Copy" onclick="Copy();" style="float:left;" />

    <textarea rows="2" cols="20" style="height:370px;width:800px;"></textarea>

IE only!
Online Example
Update:
This is how I do it in firefox:
if (window.getSelection){ // Firefox, Opera, Safari

   var textbox = document.getElementById("box");
   textbox.focus();
   theSelection = document.activeElement.value.substring(document.activeElement.selectionStart, document.activeElement.selectionEnd);

alert(theSelection);
}

A: Yes, that's exactly it: by the time the click event fires, the selection has been lost. It will work if you use onmousedown instead of onclick.
UPDATE
Another alternative that works in IE only is to add the following attribute to the . This prevents the span from affecting the selection by making it unselectable:
unselectable="on"

UPDATE 2
In other browsers, the way to get the selected text is to use the selectionStart and selectionEnd properties:
function Copy() {
    var textbox = document.getElementById("box");
    textbox.focus();
    var selectedText = "";
    if (typeof textbox.selectionStart == "number") {
        selectedText = textbox.value.slice(textbox.selectionStart, textbox.selectionEnd);
    } else if (document.selection) {
        selectedText = document.selection.createRange().text;
    }
    alert(selectedText);
}


text:
Q: Loop the onchange select option I would like to put the onchange function of select option in the loop. Particularly a for loop for me to change the id of the select tag with an incremental variable. The select tag in HTML is also in the loop with the id that is changing through an incremented PHP variable
$(function() {
  var row = document.getElementById("comments").textContent;
  var text = 1;

  for (var i = 1; i <= row; i++) {
    $('#part').html(text).change(function() {
      var display = $('#part').html(text).find(":selected").val();
      $('#resone').val(display);
    })
    text++;
  }
})

  Item Name Price Qty Total
  Discount

<?php
  $sql = "SELECT * FROM order_item WHERE order_id = {$edit['order_id']}";
  $rs = mysqli_query($con, $sql);

  $count = 1;
  $counts = mysqli_num_rows($rs);

  while ($row = mysqli_fetch_assoc($rs))
  { ?>

      <?php echo $counts; ?>

      <input type="text" readonly="readonly" id="resone">

        <?php echo ucfirst(getProductNameFromId($con, $row['product_id']));?>

        <?php echo $row['rate']; ?>

        <?php echo $row['quantity']; ?>

        <?php echo $row['total']; ?>

        <select name="artist_1" id="part<?php echo $count; ?>">
          <option value="" disabled selected>Select Category</option>
          <option value="1">lawa</option>
          <option value="2">laaswa</option>
        </select>

    <?php
    $count++;
  } ?>

A:         <?php
 $gategory = $_GET["gategory"];

 $sql = "SELECT * FROM order_item WHERE order_id = {$edit['order_id']}";
  $rs = mysqli_query($con, $sql);

  $count = 1;
  $counts = mysqli_num_rows($rs);

  while ($row = mysqli_fetch_assoc($rs))
  { ?>

      <?php echo $counts; ?>

      <input type="text" readonly="readonly" id="resone">

        <?php echo ucfirst(getProductNameFromId($con, $row['product_id']));?>

        <?php echo $row['rate']; ?>

        <?php echo $row['quantity']; ?>

        <?php echo $row['total']; ?>

        <select name="artist_1" id="part<?php echo $count; ?>">
          <option value="" disabled selected>Select Category</option>
          <option value="1">lawa</option>
          <option value="2">laaswa</option>
        </select>

    <?php
    $count++;
  } ?>

A: Be careful when you did a loop with html inside: the id must be unique. That's why javascript doesn't works
You could use getElementsByClassName and then you can iterate on each to put an event listener

A: @llea 123
I'm not using jQuery but you could do:
const squares = document.getElementsByClassName('square')

for (const square of squares) {
   square.addEventListener('click', (e) => {
      // do what you want with e.currentTarget
    })
}


text:
Q: Verifying end to end encryption on AWS ECS FARGATE containers How do I verify if I have secured end to end encryption on my AWS FARGATE container? Have mentioned the approach below :

Application Load balancer listening on 443. Uses a certificate from AWS Certificate Manager.
  Target group's protocol is HTTPS on port 8443. The health check protocol is HTTPS too.
  Spring boot application's docker image running on the container, host/container port is 8443. Have the same certificate in the classpath of the application in a PKCS12 file (has the certificate and private key in it).
  Docker image's and application's port is 8443.

It says a secure connection when I hit the application URL. I understand SSL offloading happens at the load balancer level in ALB.
But does the above approach mean an end to end encryption has been achieved? And how do I verify that?

A:
I understand SSL offloading happens at the load balancer level in ALB

SSL offloading is an option with an ALB, if you have target groups using HTTP protocol instead of HTTPS. Offloading implies you're terminating SSL at the load balancer, then using http between the ALB and the target, which isn't what's happening for you.

But does the above approach mean an end to end encryption has been achieved?

If you're using an HTTPS target group, like you are doing, you ought to have end to end encryption. You've got the right idea to verify though, so you can be sure.

And how do I verify that?

You can ensure the traffic to your ALB is using SSL by enabling access logs. You're also seeing SSL in your browser.
You can test the targets are receiving SSL traffic by running something like tcpdump or ssldump (or both!) on your target web server.


text:
Q: How to get an input event from child component to directive on parent component I have a directive to convert the input to uppercase
import { Directive, HostListener } from '@angular/core';

@Directive({
  selector: '[appUpperCase]',
})
export class UpperCaseInputDirective {
  @HostListener('input', ['$event']) onInput(event) {
    console.log("UpperCaseInputDirective::event",event);
    event.target.value = event.target.value.toUpperCase();
    return true;
  }
}

This works great on input fields, but now I want to build a custom component with some boilerplate code around the input field

  {{label}}
  <mat-form-field floatLabel="always" appearance="outline">
    <input
      [id]="internalId"
      matInput
      [formControl]="formControl"
      (input)="onInput($event)"
    />
    <mat-error *ngIf="formControl.invalid">{{
      getErrorMessage(formControl.errors)
      }}</mat-error>
  </mat-form-field>

To get the input event from the input field outside of my custom component I have forwarded this event with a EventEmitter
import { Component, EventEmitter, forwardRef, HostBinding, Input, Output } from '@angular/core';
import { ControlValueAccessor, FormControl, NG_VALUE_ACCESSOR } from '@angular/forms';
import { translateErrors } from '../../../translation/service/translation.service';

@Component({
  selector: 'app-input',
  templateUrl: './input.component.html',
  providers: [
    {
      provide: NG_VALUE_ACCESSOR,
      useExisting: forwardRef(() => InputComponent),
      multi: true
    }
  ]
})
export class InputComponent implements ControlValueAccessor {

  @HostBinding('attr.id')
  externalId = '';
  internalId = '';

  @Input()
  formControl: FormControl;

  @Input()
  label: string;

  @Input()
  set id(value: string) {
    this.internalId = value;
    this.externalId = null;
  }

  get id() {
    return this.internalId;
  }

  @Input('value') _value = '';
  onChange: any = () => {};
  onTouched: any = () => {};

  get value():string {
    return this._value;
  }

  set value(value: string) {
    this._value = value;
    this.onChange(value);
    this.onTouched();
  }

  @Output() input: EventEmitter<any> = new EventEmitter();

  control: FormControl;

  constructor() {
    this.control = new FormControl()
  }

  registerOnChange(fn) {
    this.onChange = fn;
  }

  writeValue(value) {
    if (value) {
      this.value = value;
    }
  }

  registerOnTouched(fn) {
    this.onTouched = fn;
  }

  getErrorMessage(errors: object): string {
    return translateErrors(errors);
  }

  onInput(event) {
    console.log("inputComponent::onInput",event);
    this.input.emit(event);
  }
}

Now I try to give my custom component that directive:
<app-input id="test-input-field" (input)="onInput($event)" [formControl]="test" appUpperCase label="Test" ></app-input>

But the directive is not called. When I input a char I see
inputComponent::onInput InputEvent {isTrusted: true, data: "d", isComposing: false, inputType: "insertText", dataTransfer: null, …}
customed.component.ts:94 paymentDetailsFormComponen::onInput InputEvent {isTrusted: true, data: "d", isComposing: false, inputType: "insertText", dataTransfer: null, …}
customed.component.ts:94 paymentDetailsFormComponen::onInput InputEvent {isTrusted: true, data: "d", isComposing: false, inputType: "insertText", dataTransfer: null, …}

I see the event once on the inputField component and twice from my component, but the handler of the directive is not called. How can I achieve that?


text:
Q: strange files in project I have problem with my page, is it normal that the files which normally should be image extension are txt?enter image description here
My javascript files are blocked, and this issue is simultaneous.
I`ve searched eventual virus but nothing was found.


text:
Q: List of available TikZ libraries with a short introduction Quick links:
Summary
 ❧ Intersections library
 ❧ Arrow tips library
 ❧ Decorations libraries
 ❧ Calc library
 ❧ Mindmap library
 ❧ Shapes library
 ❧ Paper Folding library
 ❧ Chains library
 ❧ Shapes library
 ❧ Miscelaneous contributions to TikZ

Very often I search a special library of TikZ. At the moment there is no package which loads every library.
Is there a list of all available libraries with a short introduction (2-3 sentences)?
 Maybe we can collect them here

A: Decoration libraries
Accessed by \usetikzlibrary{decorations.<name of decoration library>}
Description
As the name says, these libraries decorate a path. Sometimes the path is even substituted with a different path.
Every decoration library is stated below. Use Ctrl + F (Windows) to get to the library you need.

Path morphing decorations
Accessed by \usetikzlibrary{decorations.pathmorphing}
Description [from the TikZ manual]
A path morphing decoration "morphs" or "deforms" the to-be-decorated path. This means that what used to be a straight line might afterwards be a snaking curve and have bumps.
Example
\documentclass[tikz,margin=1]{standalone}
\usetikzlibrary{decorations.pathmorphing}
\def\y{0}
\newcommand\decorated[1]{
    \tikzset{decoration=#1}
    \draw[thin,red] (0,\y) to[bend left] (1,\y);
    \filldraw[decorate,fill=yellow!60,very thick] (0,\y) to[bend left] (1,\y)
        node[right,font=\ttfamily] {#1};
    \let\auxy\y
    \pgfmathsetmacro\y{\auxy+1}
}
\begin{document}
\begin{tikzpicture}[y=-1cm,x=3cm]
\decorated{lineto}
\decorated{straight zigzag}
\decorated{random steps}
\decorated{saw}
\decorated{zigzag}
% We are not able to use our command here :(
\tikzset{decoration=bent}
\draw[thin,red] (0,\y) -- (1,\y);
\filldraw[decorate,fill=yellow!60,very thick] (0,\y) -- (1,\y)
    node[right,font=\ttfamily] {bent};
\let\auxy\y
\pgfmathsetmacro\y{\auxy+1}
% %
\decorated{bumps}
\decorated{coil}
\decorated{curveto}
\decorated{snake}
\end{tikzpicture}
\end{document}

Path replacing decorations
Accessed by \usetikzlibrary{decorations.pathreplacing}
Description [from the TikZ manual]
This library defines decorations that replace the to-be-decorated path by another path. Unlike morphing decorations, the replaced path might be quite different, for instance a straight line might be replaced by a set of circles.
Example

*

*Most decorations
\documentclass[tikz,margin=1]{standalone}
\usetikzlibrary{decorations.pathreplacing}
\def\y{0}
\newcommand\decorated[1]{
    \tikzset{decoration=#1}
    \draw[thin,red] (0,\y) to[bend left] (1,\y);
    \draw[decorate,very thick] (0,\y) to[bend left] (1,\y)
        node[right,font=\ttfamily] {#1};
    \let\auxy\y
    \pgfmathsetmacro\y{\auxy+1}
}
\begin{document}
\begin{tikzpicture}[y=-1cm,x=3cm]
\decorated{border}
% We are not able to use our command here :(
\tikzset{decoration=brace}
\draw[thin,red] (0,\y) -- (1,\y);
\draw[decorate,very thick] (0,\y) -- (1,\y)
    node[right,font=\ttfamily] {brace};
\let\auxy\y
\pgfmathsetmacro\y{\auxy+3}
% %
\decorated{expanding waves}
\let\auxy\y
\pgfmathsetmacro\y{\auxy+1.5}
\decorated{ticks}
\decorated{waves}
\end{tikzpicture}
\end{document}

*The special decoration: show path construction.
% Source: The TikZ - PGF manual version 3.1.3, May 9 2019, page 636

\documentclass[tikz,margin=1]{standalone}
\usetikzlibrary{decorations.pathreplacing}
\begin{document}
\begin{tikzpicture}[
    >=stealth,
    every node/.style={midway, sloped, font=\tiny},
    decoration={
        show path construction,
        moveto code={
            \fill [red] (\tikzinputsegmentfirst) circle (2pt)
                node [fill=none, below] {moveto};},
        lineto code={
            \draw [blue,->] (\tikzinputsegmentfirst) -- (\tikzinputsegmentlast)
                node [above] {lineto};},
        curveto code={
            \draw [green!75!black,->] (\tikzinputsegmentfirst) .. controls
                (\tikzinputsegmentsupporta) and (\tikzinputsegmentsupportb)
                ..(\tikzinputsegmentlast) node [above] {curveto};},
        closepath code={
            \draw [orange,->] (\tikzinputsegmentfirst) -- (\tikzinputsegmentlast)
                node [above] {closepath};}
        }]

\draw [help lines] grid (3,2);
\path [decorate] (0,0) -- (3,1) arc (0:180:1.5 and 1) -- cycle;
\end{tikzpicture}
\end{document}

Arbitrary markings
Accessed by \usetikzlibrary{decorations.markings}
Description [from the TikZ manual]
A marking can be thought of a "little picture" or more precisely of "some scope contents" that is placed "on" a path at a certain position
Example
\documentclass[tikz,margin=1]{standalone}
\usetikzlibrary{decorations.markings}
\begin{document}
\colorlet{darkgreen}{green!70!black}
\begin{tikzpicture}[>=stealth]
\path (0,1) node[right,inner sep=0pt,font=\ttfamily] {markings};
\draw[postaction=decorate,decoration={
        markings,
        mark=at position 0.5 with \arrow{>}
      }] (0,0) -- (3,0) node[right=1ex] {One marking only};
\draw[postaction=decorate,decoration={
        markings,
        mark=at position 1/3 with {
          \draw[red,thick] (-2pt,-2pt) -- (2pt,2pt);
          \draw[red,thick] (-2pt,2pt) -- (2pt,-2pt);
        },
        mark=at position 2/3 with {
          \draw[darkgreen,thick] (-2pt,0) -- (0,-2pt) -- (2pt,2pt);
        }
      }] (0,-1) -- (3,-1) node[right=1ex] {Two markings};
\draw[postaction=decorate,decoration={
        markings,
        mark=between positions 0 and 1 step 0.2 with {
          \filldraw[fill=yellow]
            (-3pt,-3pt) -- (3pt,-3pt) -- (0,3pt) -- cycle;
          \draw (0,2pt) -- (0,-1pt);
          \fill (0,-2pt) circle (.5pt);
        }
      }] (0,-2) to[bend left] (3,-2) node[right=1ex] {Several markings};
\end{tikzpicture}
\end{document}

Foot prints markings
Accessed by \usetikzlibrary{decorations.footprints}
Description [from the TikZ manual]
The decorations of this library can be used to decorate a path with little footprints, as if someone had "walked" along the path.
Example
\documentclass[tikz,margin=1]{standalone}
\usetikzlibrary{decorations.footprints}
\begin{document}
\begin{tikzpicture}[y=-1.5cm,x=3cm]
\path (0,0) node[right,inner sep=0pt,font=\ttfamily] {footprints};
\foreach \i [count=\j] in {gnome,human,bird,felis silvestris} {
    \tikzset{decoration={footprints,foot of=\i}}
    \draw[thin,red] (0,\j) to[bend left] (1,\j);
    \draw[decorate] (0,\j) to[bend left] (1,\j) node[right] {\i};
}
\end{tikzpicture}
\end{document}

Shape background markings
Accessed by \usetikzlibrary{decorations.shapes}
Description [from the TikZ manual]
N/A
Example
\documentclass[tikz,margin=1]{standalone}
\usetikzlibrary{decorations.shapes}
\def\y{0}
\newcommand\decorated[1]{
    \tikzset{decoration=#1}
    \draw[thin,red] (0,\y) to[bend left] (1,\y);
    \draw[decorate] (0,\y) to[bend left] (1,\y)
        node[right,font=\ttfamily] {#1};
    \let\auxy\y
    \pgfmathsetmacro\y{\auxy+1}
}
\begin{document}
\begin{tikzpicture}[y=-1cm,x=3cm]
\decorated{crosses}
\decorated{triangles}
\decorated{shape backgrounds} % You can customize it. See more in the manual
\end{tikzpicture}
\end{document}

Text decorations
Accessed by \usetikzlibrary{decorations.text}
Description [from the TikZ manual]
The decoration in this library decorates the path with some text. This can be used to draw text that follows a curve.
Example
\documentclass[tikz,margin=2]{standalone}
\usetikzlibrary{decorations.text}
\begin{document}
\begin{tikzpicture}[y=-1cm,x=3cm]
\draw[postaction=decorate,decoration=text along path,
      /pgf/decoration/text={Hello world}]
    (0,0) to[bend left] (1,0) node[right=1ex,font=\ttfamily] {text along path};
% Source: The TikZ - PGF manual, version 3.1.3, 9 May 2019, page 652
\tikzset{
    decoration={
        text effects along path,
        text={Hello world},
        text align=center,
        text effects/.cd,
            character count=\i,
            characters={xslant=0.5, text along path, name=c-\i}
    }
}
\draw[postaction=decorate] (0,1) -- (1,3.5)
    node[right=1ex,font=\ttfamily] {text effects along path};
\end{tikzpicture}
\end{document}

Fractal decorations
Accessed by \usetikzlibrary{decorations.fractals}
Description [from the TikZ manual]
The decorations of this library can be used to create fractal lines.
Example
\documentclass[tikz,margin=1]{standalone}
\usetikzlibrary{decorations.fractals}
\def\y{0}
\newcommand\decorated[3][]{
    \tikzset{decoration=#2}
    \draw[ultra thin,red] (0,\y) -- (1,\y);
    \draw[#1] decorate {
                decorate {
                  decorate {
                    (0,\y) -- (1,\y)
                  }
                }
              };
    \path (1,\y) node[right=1ex,font=\ttfamily] {#2};
    \let\auxy\y
    \pgfmathsetmacro\y{\auxy+#3}
}
\begin{document}
\begin{tikzpicture}[y=-1cm,x=3cm]
\decorated{Koch curve type 1}{1.5}
\decorated{Koch curve type 2}{2}
\decorated{Koch snowflake}{1}
\decorated[ultra thick]{Cantor set}{0}
\end{tikzpicture}
\end{document}

A: Arrow tips library
Accessed by \usetikzlibrary{arrows.meta}
Description:
Provides various new and customizable arrow tips
Example
\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{arrows.meta}

\begin{document}
\begin{tikzpicture}
\foreach \arrowtipkind[count=\i from 0] in {
Circle,
Diamond,
Ellipse,
Kite,
Latex,
Rectangle,
Square,
Stealth,
Triangle,
Turned Square,
Arc Barb,
Bracket,
Hooks,
Tee Barb,
Parenthesis,
Implies,
Butt Cap,
Fast Round,
Fast Triangle,
Round Cap,
Triangle Cap}{\foreach \specs[count=\j from 0] in {round, open, fill=red, {round, fill=blue, length=2.5mm, slant=.5}}{\draw[-{\arrowtipkind[\specs]}, yshift=-1.5*\i cm -0.2*\j cm] (0,0) -- +(1,0)\ifnum\j=0 node[above,midway,font=\scriptsize\ttfamily]{\arrowtipkind}\fi;};};
%%% Tips with particular options:
% Arc Barb[sep, arc=<angle>, length=<dim>, line width=<dim>, width=<dim>, reversed, round, slant=<num>, harpoon, left, right, <color>]
% Bracket[sep, reversed, round, slant=<num>, left, right, harpoon, reversed, <color>]
% Hooks[sep, arc=<angle>, length=<dim>, line width=<dim>, width=<dim>, reversed, round, slant=<num>, harpoon, left, right, <color>]
% Tee Barb[sep, inset=<dim>, inset'=<dim> <num>, line width=<dim>, reversed, round, slant=<num>, harpoon, left, right, <color>] thin thick
% Implies[<color>]
\end{tikzpicture}
\end{document}

Reference
TikZ/PGF 3.1.5b Manual section Arrows.

A: Intersections library
Accessed by \usetikzlibrary{intersections}
Description
Allows automated calculation of path intersections.
Example 1
\documentclass{standalone}

\usepackage{tikz}
\usetikzlibrary{intersections}

\begin{document}
\begin{tikzpicture}
    % Draw to path and give a name to them
    \draw [red, name path={red line}] (0,0) -- (4,3);
    \draw [blue, name path={blue curve}] (1,-0.5) to[out=80, in=100] (3,2);
    % use the intersections on a path to giv them coordinates
    % and draw a line between them
    \draw [green, name intersections={of=red line and blue curve,
           by={first intersect, second intersect}}]
       (first intersect) -- (second intersect);
    % one can use the coordinates furtheron
    \node [above] at (first intersect) {A};
    \node [below] at (second intersect) {B};
\end{tikzpicture}
\end{document}

Example 2
\documentclass{standalone}% or wathever you want

% load packages
\usepackage{tikz, xcolor}
% load libraries
\usetikzlibrary{intersections,shapes.arrows,calc}

% define light and dark gray
\definecolor{lgray}{cmyk}{0,0,0,0.2}
\definecolor{dgray}{cmyk}{0,0,0,0.7}

% make some settings
\tikzset{%
    % style for the intersecting path, which
    % are nessesary for the calculation but
    % shouldn't be drawn in the final image
    ipath/.style={
%       draw,% comment this aout after construction
        red
    },
    % style for an arrow used as object
    optical arrow/.style={%
        fill=dgray,
        inner sep=3pt,
        shape=single arrow,
        minimum width=0.5cm,
        minimum height=1.5cm,
        outer sep=0pt,
        shape border rotate=90,
    },
    % style for the virtual image
    virtual optical arrow/.style={%
        fill=lgray,
        inner sep=3pt,
        shape=single arrow,
        minimum width=0.5cm,
        minimum height=1.5cm,
        outer sep=0pt,
        shape border rotate=90,
    },
    % style for the mirror
    mirror/.style={%
        line width=2pt,
    },
    % style for the axis
    optical axis/.style={%
        thin,
    },
    % style for light rays
    ray/.style={%
        thin,
        ->,
    },
    % style for imagined rays, which ar not real
    % but help by constructin the image
    imagined ray/.style={%
        ray, dgray, -,
    },
    % alias
    virtual ray/.style={imagined ray},
    % style for (focal) points
    point/.style={%
        fill=black,
        radius=0.8pt,
        inner sep=1pt,
        shape=circle,
        minimum size=2pt,
        outer sep=2pt
    },
}

% set three layers
\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background,main,foreground}
% and define shortcuts to access them
\newcommand{\bglayer}[1]{%
    \begin{pgfonlayer}{background}%
    #1%
    \end{pgfonlayer}%
}
\newcommand{\fglayer}[1]{%
    \begin{pgfonlayer}{foreground}%
    #1%
    \end{pgfonlayer}%
}

\begin{document}
\begin{tikzpicture}
    % define the bounding box is nessesarx because the ipaths
    % make it bigger than needed
    \path [use as bounding box] (-5.2,-5) rectangle (6.2,5);
    % define variables, you may vary them a little
    %% radius
    \def\radius{5}
    \def\radiusII{5.05}
    %% focal distancs = \radius/2
    \def\focal{2.5}
    %% object size
    \def\size{1.cm}
    %% object width
    \def\owidth{1.25}
    % draw mirror
    %% the extra ipath is nessesary to get nicer rays
    \path [ipath, name path=M] (\radius,0) ++(90:\radius)
          arc (90:270:\radius);
    \fglayer{%
        \draw [mirror] (\radiusII-0.05,0) ++(130:\radiusII)
              arc (130:240:\radiusII);
    }
    % draw focal point
    \node (B) at (\focal,0) [point] {};
    % draw object
    \node (O) [optical arrow,anchor=tail, minimum height=\size] %
          at (\owidth,0) {};
    %% description
    \node [above right] at (O.tip) {object};
    % rays
    %% draw axis ray
    \draw [ray] (O.tip) -- (0,0) -- ($(0,0)!3!(\owidth,-\size)$);
    %% draw parallel ray
    \path [ipath, name path=PS] (O.tip) -- ++(-3,0);
    \draw [ray, name intersections={of=M and PS, by=M-PS}]
        (O.tip) -- (M-PS) -- ($(M-PS)!2!(B)$);
    %% caculate virtual axis ray
    \path [ipath, name path=AS-V] ($(0,0)!-4!(\owidth,-\size)$) -- (0,0);
    %% calculate virtual parallel ray
    \path [ipath, name path=PS-V] ($(M-PS)!-4!(B)$) -- (M-PS);
    %% draw virtual axis ray
    \draw [imagined ray, name intersections={of=AS-V and PS-V, by=Tip-V}]
        (Tip-V) -- (0,0);
    %% draw virtual axis ray
    \draw [imagined ray] (Tip-V) -- (M-PS);
    % draw virtual object
    \bglayer{\path let \p{1}=(Tip-V) in
        (Tip-V) node (V) [minimum height=\size,
                          scale={\y{1}/\size*0.665},
                          virtual optical arrow,anchor=tip
                         ] {};}
    %% description
    \path (V.west) node [left] {virtual image};
    % draw optical axis
    \fglayer{\draw [optical axis] (-5,0) --++(11,0);}
\end{tikzpicture}
\end{document}

Reference
pgfmanual.pdf, pp. 143 et sec.

A: Calc library
Accessed by \usetikzlibrary{calc}
Description
Allows extended coordinate calculation
Example
\documentclass{standalone}

\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}
\begin{tikzpicture}
    % make some mathematical calculations
    \node (a) at (1,1) {A};
    \fill [red] ($(a) + 1/3*(1cm,0)$) circle (2pt);
    % draw a segment of a path between two points
    \coordinate (b) at (0,0);
    \coordinate (c) at (0.5,3);
    \fill (b) circle (1pt) (c) circle (1pt);
    \draw [blue!50!green, ->] (b) -- ($(b)!1.5!(c)$);
    \draw [blue, ->] (b) -- ($(b)!0.5!(c)$);
    % draw a parallel line
    \draw [green] (2,0) coordinate (d) -- (3,4) coordinate (e);
    \draw [green, dashed] (2.5,1) -- ++($(e)-(d)$);
\end{tikzpicture}
\end{document}

Reference
pgfmanual.pdf.

A: Shapes library
Accessed by \usetikzlibrary{shapes}
Description
Allows shapes to be placed as part of a flowchart
Example
\documentclass{standalone}

\usepackage{tikz, xcolor}
\usetikzlibrary{shapes,arrows}

\tikzstyle{decision} = [diamond, draw, text width=4.5em,
                        text badly centered, node distance=2cm,
                        inner sep=0pt]
\tikzstyle{block} = [rectangle, draw, text width=5em,
                     text centered, rounded corners,
                     minimum height=4em, node distance=3cm]
\tikzstyle{line} = [draw, -latex']
\tikzstyle{cloud} = [draw, ellipse, node distance=2.5cm, minimum height=2em]
\tikzstyle{blank} = [node distance=1cm]

\begin{document}
\begin{tikzpicture}[node distance = 3cm, auto]
    % Place nodes
    \node [cloud] (init) {n};
    \node [blank, below of=init] (sup) {};
    \node [decision, below of=sup] (square) {$n^2 \le 1$};
    \node [cloud, right of=square] (end) {End};
    \node [block, left of=square] (newN) {$n = \frac{2}{n}$};

    % Draw edges
    \path [line] (init) -- (square);
    \path [line] (square) -- node [near start] {yes} (end);
    \path [line] (square) -- node [near start] {no} (newN);
    \path [line] (newN) |- (sup);
\end{tikzpicture}
\end{document}

Reference
http://www.texample.net/tikz/examples/simple-flow-chart/
Used as a base to get started, additional style (blank) used as a support, example from a question asked at university interview.

A: Paper Folding Library
Accessed by \usetikzlibrary{folding}
Description
It contains a single command, but it is useful for producing real calendars (as used on a desktop).
Example
\documentclass{standalone}

\usepackage{tikz, xcolor}
\usetikzlibrary{folding,calendar}
\begin{document}
\sffamily\scriptsize
\begin{tikzpicture}[transform shape]
\tikzstyle{every calendar}=
[
    %Formats calendars and sets positions
    at={(-8ex,4ex)},
    week list,
    month label above centered,
    month text=\bfseries\textcolor{red}{\%mt} \%y0,
    if={(Sunday) [black!50]}
    ]
\tikzfoldingdodecahedron
[
    %Sets size of calendar
    folding line length=2.5cm,
    %Adds calendar image to each face
    face 1={ \calendar [dates=\the\year-01-01 to \the\year-01-last];},
    face 2={ \calendar [dates=\the\year-02-01 to \the\year-02-last];},
    face 3={ \calendar [dates=\the\year-03-01 to \the\year-03-last];},
    face 4={ \calendar [dates=\the\year-04-01 to \the\year-04-last];},
    face 5={ \calendar [dates=\the\year-05-01 to \the\year-05-last];},
    face 6={ \calendar [dates=\the\year-06-01 to \the\year-06-last];},
    face 7={ \calendar [dates=\the\year-07-01 to \the\year-07-last];},
    face 8={ \calendar [dates=\the\year-08-01 to \the\year-08-last];},
    face 9={ \calendar [dates=\the\year-09-01 to \the\year-09-last];},
    face 10={\calendar [dates=\the\year-10-01 to \the\year-10-last];},
    face 11={\calendar [dates=\the\year-11-01 to \the\year-11-last];},
    face 12={\calendar [dates=\the\year-12-01 to \the\year-12-last];},
];
\end{tikzpicture}
\end{document}

Reference
pgfmanual.pdf, pp. 202 et sec.

A: Mindmap Library
Accessed by \usetikzlibrary{mindmap}
Description
The main focus point, is placed in the middle, with sub-points branching off. Each node is defined, as are its children. Nodes can also be separate from each other, and each node can also be coloured differently and interconnected. Annotations are also available.
Example
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{mindmap,backgrounds}

\begin{document}
\tikzstyle{root concept}+=[concept color=blue!20,minimum size=2cm]
\tikzstyle{level 1 concept}+=[sibling angle=45]

\begin{tikzpicture}[mindmap]
\node [concept] (n1) {Stack Exchange Sites}
    child[concept color=red,grow=45] {node[concept] (c1) {Meta}}
    child[concept color=orange,grow=0] {node[concept] (c2) {Q \& A}}
    child[concept color=green,grow=-45] {node[concept] (c3) {Chat}};
\begin{pgfonlayer}{background}
\draw [concept connection] (c1) edge (c2)
                                edge (c3)
                           (c2) edge (c3);
\end{pgfonlayer}

\node [extra concept] at (0,10) (n2) {\TeX {} and \LaTeX {}Stack Exchange}
    child[concept color=red,grow=45] {node[concept] (s1) {Meta}}
    child[concept color=orange,grow=0] {node[concept] (s2) {Q \& A}}
    child[concept color=green,grow=-45] {node[concept] (s3) {Chat}};

\begin{pgfonlayer}{background}
    \draw [concept connection] (s1) edge (s2)
                                    edge (s3)
                               (s2) edge (s3)
                               (n1) edge (n2);
\end{pgfonlayer}
\end{tikzpicture}

\end{document}

Reference
pgfmanual.pdf, pp. 207 et sec.

A: Chains Library
Accessed by \usetikzlibrary{chains}
Description
Chains are sequences of nodes that are arranged in a row or a column and that are, typically, connected by edges. More generally, they can be used to position nodes of a branching network in a systematic manner. For the positioning of nodes in rows and columns you can also use matrices (see
Section 17 of pgfmanual.pdf) but chains can also be used to describe the connections between nodes that have already been connected using, say, matrices. Thus, it often makes sense to use matrices for the positioning of elements
and chains to describe the connections.
Example with Chains
\documentclass{standalone}

\usepackage{tikz}
\usetikzlibrary{shapes,% for the rectangle
                chains,% provides the chains
                scopes}% allows to replace \begin{scope} \end{scope} with {}

\begin{document}
\begin{tikzpicture}[
  nonterminal/.style={
    rectangle,
    minimum size=6mm,
    very thick,
    draw=red!50!black!50,
    top color=white, % a shading that is white at the top...
    bottom color=red!50!black!20, % and something else at the bottom
    font=\itshape
  },
  terminal/.style={
    rectangle,minimum size=6mm,rounded corners=3mm,
    very thick,draw=black!50,
    top color=white,bottom color=black!20,
    font=\ttfamily
  },
  node distance=5mm, every on chain/.style={join}, every join/.style={->}
]
{ [start chain]
  \node [on chain,nonterminal] {unsigned integer};
  \node [on chain,terminal] {.};
  \node [on chain,terminal] {digit};
  \node [on chain,terminal] {E};
  { [start branch=plus]
    \node (plus) [terminal,on chain=going above right] {+};
  }
  { [start branch=minus]
    \node (minus) [terminal,on chain=going below right] {-};
  }
  \node [on chain, nonterminal, join=with chain/plus-end, join=with chain/minus-end] {unsigned integer};
}
\end{tikzpicture}
\end{document}

Example with Matrix and Chains
\documentclass{standalone}

\usepackage{tikz}
\usetikzlibrary{shapes,% for the rectangle
                chains,% provides the chains
                scopes}% allows to replace \begin{scope} \end{scope} with {}

\begin{document}
\begin{tikzpicture}[
  nonterminal/.style={
    rectangle,
    minimum size=6mm,
    very thick,
    draw=red!50!black!50,
    top color=white, % a shading that is white at the top...
    bottom color=red!50!black!20, % and something else at the bottom
    font=\itshape
  },
  terminal/.style={
    rectangle,minimum size=6mm,rounded corners=3mm,
    very thick,draw=black!50,
    top color=white,bottom color=black!20,
    font=\ttfamily
  },
  every on chain/.style={join}, every join/.style={->}
]

\matrix[column sep=4mm] {
  % First row:
  & & & & \node (plus) [terminal] {+};&\\
  % Second row:
  \node (ui1)   [nonterminal] {unsigned integer};&
  \node (dot)   [terminal]    {.};               &
  \node (digit) [terminal]    {digit};           &
  \node (e)     [terminal]    {E};               &
  & % space in between
  \node (ui2) [nonterminal] {unsigned integer};\\
  % Third row:
  & & & & \node (minus)[terminal] {-};&\\
  };

{ [start chain]
  \chainin (ui1);
  \chainin (dot);
  \chainin (digit);
  \chainin (e);
  { [start branch=plus]
    \chainin (plus);
  }
  { [start branch=minus]
    \chainin (minus);
  }
  \chainin (ui2) [join=with chain/plus-end, join=with chain/minus-end];
}
\end{tikzpicture}
\end{document}

Chains with Labels
Some times one needs to add labes to the edges created by the chains library (it happened to me before). Although it is not supported natively by the library, you can do it by tweaking the library.
An example is:
\documentclass{standalone}

\usepackage{tikz}
\usetikzlibrary{shapes,% for the rectangle
                chains,% provides the chains
                scopes}% allows to replace \begin{scope} \end{scope} with {}

\makeatletter
\def\tikz@lib@parse@join#1{%
  \def\tikz@temp{#1}%
  \ifx\tikz@temp\pgfutil@empty%
    \tikz@lib@parse@join@by by \pgf@stop%
  \else%
    \pgfutil@in@{with }{#1}%
    \ifpgfutil@in@% 'with [by] [label]'
      \pgfutil@in@{by }{#1}%
      \ifpgfutil@in@% 'with by [label]'
        \pgfutil@in@{label }{#1}%
        \ifpgfutil@in@% 'with by label'
          \tikz@lib@parse@join@with@by@label#1\pgf@stop%
        \else% 'with by'
          \tikz@lib@parse@join@with@by#1\pgf@stop%
        \fi%
      \else% 'with [label]'
        \pgfutil@in@{label }{#1}%
        \ifpgfutil@in@% 'with label'
          \tikz@lib@parse@join@with@label#1\pgf@stop%
        \else% with
          \tikz@lib@parse@join@with@by#1 by \pgf@stop%
        \fi%
      \fi%
    \else% '[by] [label]'
      \pgfutil@in@{by }{#1}%
      \ifpgfutil@in@% 'by [label]'
        \pgfutil@in@{label }{#1}%
        \ifpgfutil@in@% 'by label'
          \tikz@lib@parse@join@by@label#1\pgf@stop%
        \else% 'by'
          \tikz@lib@parse@join@by#1\pgf@stop%
        \fi%
      \else% '[label]'
        \pgfutil@in@{label }{#1}%
        \ifpgfutil@in@% 'label'
          \tikz@lib@parse@join@label#1\pgf@stop%
        \else%
          \tikz@lib@parse@join@by#1 by \pgf@stop%
        \fi%
      \fi%
    \fi%
  \fi%
}
\def\tikz@lib@parse@join@with@by@label with #1 by #2 label #3\pgf@stop{%
  \tikzset{after node path={(#1)edge[every join,#2]#3(\tikzchaincurrent)}}%
}
\def\tikz@lib@parse@join@with@label with #1 label #2\pgf@stop{%
  \tikzset{after node path={(#1)edge[every join]#2(\tikzchaincurrent)}}%
}
\def\tikz@lib@parse@join@by@label by #1 label #2\pgf@stop{%
  \tikzset{after node path={\ifx\tikzchainprevious\pgfutil@empty\else(\tikzchainprevious)edge[every join,#1]#2(\tikzchaincurrent)\fi}}%
}
\def\tikz@lib@parse@join@label label #1\pgf@stop{%
  \tikzset{after node path={\ifx\tikzchainprevious\pgfutil@empty\else(\tikzchainprevious)edge[every join]#1(\tikzchaincurrent)\fi}}%
}
\makeatother

\begin{document}
\begin{tikzpicture}[
  nonterminal/.style={
    rectangle,
    minimum size=6mm,
    very thick,
    draw=red!50!black!50,
    top color=white, % a shading that is white at the top...
    bottom color=red!50!black!20, % and something else at the bottom
    font=\itshape
  },
  terminal/.style={
    rectangle,minimum size=6mm,rounded corners=3mm,
    very thick,draw=black!50,
    top color=white,bottom color=black!20,
    font=\ttfamily
  },
  every on chain/.style={join}, every join/.style={->}
]

\matrix[column sep=4mm] {
  % First row:
  & & & & \node (plus) [terminal] {+};&\\
  % Second row:
  \node (ui1)   [nonterminal] {unsigned integer};&
  \node (dot)   [terminal]    {.};               &
  \node (digit) [terminal]    {digit};           &
  \node (e)     [terminal]    {E};               &
  & % space in between
  \node (ui2) [nonterminal] {unsigned integer};\\
  % Third row:
  & & & & \node (minus)[terminal] {-};&\\
  };

{ [start chain]
  \chainin (ui1);
  \chainin (dot);
  \chainin (digit);
  \chainin (e);
  { [start branch=plus]
    \chainin (plus) [join=label {node[above left]{a label}}];
  }
  { [start branch=minus]
    \chainin (minus);
  }
  \chainin (ui2) [join=with chain/plus-end label {node[above right] {plus label}}, join=with chain/minus-end by dashed label {node [below right]{minus label}}];
}
\end{tikzpicture}
\end{document}

Reference
pgfmanual.pdf, pp. 284 et sec. The examples are a simplified version of the Tutorial: Putting a Diagram in Chains, of pp. 60

A: I created a PDF with all the libraries and a short definition from the pfdmanual.

You can find the PDF here table-library
It's a first version and I have not reread or corrected and I think the order is not fine. The last libraries about graphs need luatex.

A: Shapes library
Accessed by \usetikzlibrary{shapes, shapes.geometric, shapes.symbols, shapes.arrows, shapes.multipart, shapes.callouts, shapes.misc}
Description
Provide several shapes besides the standard ones
Example
\documentclass[parskip]{scrartcl}
\usepackage[margin=5mm,a3paper]{geometry}
\usepackage{kerkis}
\usepackage{tikz}
\usetikzlibrary{
    shapes,
    shapes.geometric,
    shapes.symbols,
    shapes.arrows,
    shapes.multipart,
    shapes.callouts,
    shapes.misc}

\begin{document}

\tikzset{every node/.style={draw=red!20!black,fill=orange!50!red!50!white,text=black,inner sep=2pt}}

{\LARGE \textbf{Standard shapes}}\\
\foreach \shape in {circle,rectangle}
{   \begin{tikzpicture}
        \node[shape=\shape] {\shape};
    \end{tikzpicture}
}
\\\hrule

{\LARGE \textbf{Geometric shapes}}\\
\foreach \shape in {diamond,ellipse,trapezium,semicircle,regular polygon,star,isosceles triangle,kite,dart,circular sector,cylinder}
{   \begin{tikzpicture}
        \node[shape=\shape] {\shape};
    \end{tikzpicture}
}
\\\hrule

{\LARGE \textbf{Symbol shapes}}\\
\foreach \shape in {forbidden sign,magnifying glass,cloud,starburst,signal,tape}
{   \begin{tikzpicture}
        \node[shape=\shape] {\shape};
    \end{tikzpicture}
}
\\\hrule

{\LARGE \textbf{Arrow shapes}}\\
\foreach \shape in {single arrow,double arrow,arrow box}
{   \begin{tikzpicture}
        \node[shape=\shape] {\shape};
    \end{tikzpicture}
}
\\\hrule

{\LARGE \textbf{Multipart shapes}}\\
\foreach \shape in {circle split,circle solidus,ellipse split,rectangle split}
{   \begin{tikzpicture}
        \node[shape=\shape] {\shape};
    \end{tikzpicture}
}
\\\hrule

{\LARGE \textbf{Callout shapes}}\\
\foreach \shape in {ellipse callout,rectangle callout,cloud callout}
{   \begin{tikzpicture}
        \node[shape=\shape] {\shape};
    \end{tikzpicture}
}
\\\hrule

{\LARGE \textbf{Miscellaneous shapes}}\\
\foreach \shape in {cross out,strike out,rounded rectangle,chamfered rectangle}
{   \begin{tikzpicture}
        \node[shape=\shape] {\shape};
    \end{tikzpicture}
}

\end{document}

Reference
pgfmanual.pdf, pages 419 to 461

A: Miscelaneous contributions to TikZ (total of 70)
Maybe this is not the proper place to put this answer but I think it may help someone.
Here is a link that contains several contributions made to TikZ, some of them have to be loaded as packages and some can be loaded commonly as libraries through \usetikzlibrary but are not documented at the TikZ/PGF manual, instead they have their own documentation like packages.
I'll list some of the packages/libraries and a very short description of what it does

*

*knots (tikz library): provide environment to draw knots easily computing intersection and automatically Splitting the path into several paths one over another.

*hobby (tikz library): an implementation of John Hobby's algorithm to produce a smooth curve through a given set of points, it allows further customization of the curve than the normal plot operator and its result without any customization is significantly better than plot.

*forest: offers highly improved tree drawing mechanism that than of just TikZ, should definetely be considered before drawing a tree with TikZ.

*tikz-cd: provides support through predefined macros and default settings for drawing commutative diagrams.

*prooftree: provides support for drawing prooftrees, the package is focused on math prooftrees used to teach math.

*pgf-spectra: uses easy syntax to draw the spectrum of elements (currently 99 available)

*bloques: provides set of macros to ease the drawing of block diagrams used in control theory (engineering).

*circuitikz: used to draw electronic circuits.

*tikzscale: provides some interface between tikzpictures and \includegraphics offering scaling methods for tikzpictures.

I have counted 65 contributions in the former link, the above cited are not the best nor special in any way, It's just the ones I've came across with.

Isolated contributions:
I've also found in user's @Qrrbrbirlbel (how do you say that?) 5 neet libraries (yep they're loaded with \usetikzlibrary), unfortunately without manuals and not available through CTAN (hopefully they'll get there) but can be downloaded in Qrrbrbirlbel's GitHub account, the below is a near copy paste of his "About me" profile text:

*

*node-families
The node-families library has been developed in response to "Dependent node size" where the OP asks for automatic re-sizing of related nodes so that they have the same minimum size. Use the following keys  to assign a node to a specific family of nodes that shall have the same dimensions. This works on a per-picture basis and uses the .aux file so you will need at least two compilations.
 - `Minimum Width=<family>`;
 - `Minimum Height=<family>`;
 - `Text Height=<family>`;
 - `Text Width=<family>`.

*

*paths.ortho (code file here and lib file here)

This library introduces path operators like the horizontal-vertical ones TikZ naturally has (|- and -|) but more advanced, like |-| and -|-. This answer and this one too contain more info on the library.

*

*paths.rectangle
The paths.rectangle library provides two similar timers (the functions that place nodes along paths) for the rectangle path operator. Usually when doing \draw (0,0) rectangle node[pos=x]{A} (1,1) the node A will be placed in a position along the line connecting the two coordinates, with paths.rectangle, x can assume values greater than 1 (up to 2) which represent the actual rectangle path, not the line between the coordinates, as better explained in this answer.

*

*patterns.images
This library allows shapes to be filled with image patterns, much useful to create images with textures. It's explained in this answer.

*

*positioning-plus
This one offers a way of positioning one node in respect with several others, providing also capability of making the node as large as the set of nodes it spans. Aside from that it has more positioning options than that of the original positioning library, since there is no manual the information has to be gathered from TeX.SX search engine (this link auto searches with the proper filters)

A: Summary
Here's the list of libraries, and a brief summary of the purpose of each (any code supplied is for LaTeX and/or Plain TeX, not ConTeXt):

*

*Arrow tip library with \usetikzlibrary{arrows.meta} (\usetikzlibrary{arrows} is deprecated). See details below.

*Automata Drawing Library, accessed by \usetikzlibrary{automata}, and is used for drawing "finite state automata and Turing Machines".  To draw these graphs, each node, its name and relative position is defined, as well as the types of path between each.

*Background Library, accessed by \usetikzlibrary{backgrounds}, and "defines background for pictures".  To use this in a Tikzpicture, an option is passed, e.g. \begin{tikzpicture}[show background rectangle], with a background rectangle style defined before the picture. (e.g. \tikzset{background rectangle/.style={<define background rectangle style here>}}

*Calc library, accessed through \usetikzlibrary{calc} to make complex coordinate calculations. See details below.

*Calendar Library, accessed through \usetikzlibrary{calendar}.  This library is used to display calendars (I guess it's a Ronseal thing).  You define a calendar as \calendar[display options and date options](Name (optional)).

*Chain library to align nodes o chains. See details below.

*Decorations libraries to decorate paths. See details below.

*Entity Relationship Diagram Library, accessed by \usetikzlibrary{er}, as in the automata drawing library, each node is defined, as is each edge between each node, as well as any attributes.  As a note of warning, underlining should be used for attributes, but this is not used as it is both ugly and difficult to implement.  Italics are used instead.

*Intersection library, accessed through \usetikzlibrary{intersections}, to calculate intersections of paths. See details below.

*Mind map library, accessed through \usetikzlibrary{mindmap}. See details below.

*Matrix Library, accessed through \usetikzlibrary{matrix}.  Matrices are defined in the same way as in maths mode, however, each item in the matrix as assigned a value as a node, starting from 1.  Each node can then be identified and manipulated.  Delimiters can also be selected in the matrix options and can be "any delimiter that is acceptable to TeX's \left command".

*Paper folding library \usetikzlibrary{folding}. See details below.

*Pattern Library \usetikzlibrary{patterns}.  This package "defines patterns for filling areas".  In the documentation, each pattern is named and an example given.

*Petri-Net Library. This is used to draw Petri Nets, as used for mathematical modelling.  As with other similar flowchart style diagrams, each node and edge is defined, as well as their style and position.  Tokens can also be embedded within nodes, by treating them as children and child nodes.

*Plot handler Library, accessed through \usetikzlibrary{plothandlers}.  TikZ loads this library automatically.  Each point is  defined (as a node) for the plot and the each point has a curve placed

*

*Plot Mark Library, accessed through \usetikzlibrary{plotmarks} is used to define additional styles for plots as used above.  Each point is defined as \pgfuseplotmark{Plot description}.

*Shape library, used to define shapes other than rectangle, circle and co-ordinate.  Accessed through either \usetikzlibrary{shapes} or \usetikzlibrary{shapes.shape type}.  The following additional types are available: geometric shapes, either named shapes (star, diamond, etc.) or polygons of specified side numbers; symbol shapes, e.g. "forbidden sign" as used in No Smoking signs; "multipart" shapes, with "multiple (text) parts"; and finally, "misc" shapes which "do not fit in the previous categories", such as strike-through crosses. See details below.

*Snake library, as accessed through \usetikzlibrary{snakes} and can be best described as curved lines, and are used either between nodes or as a border to a shape , or as independent shapes.

*To Path library, accessed through \usetikzlibrary{topaths}.  This library is used to define paths between two points, and is loaded automatically.  Additionally, it can take the form of curved lines between two shapes or as a loop back to a node.

*Tree library, accessed through \usetikzlibrary{trees}.  Each point on the tree is defined as a node, with children, and each child can have its own children.  The tree's direction can also be specified, as well as the angle at which children emerge, however, when left to its own devices, the results are acceptable.

Sources: Anything in inverted commas has been lifted from the tikzpgfmanual, as well as the calendar sample.


text:
Q: Why do these two constructors together not produce an ambiguity error? Consider the following:
class A
{
private:
    A() {}
public:
    A(int x = 0) {}
};

int main()
{
    A a(1);
    return 0;
}

I have two constructors, one is a default and the other one is converting constructor with a default argument. When I try to compile the code, I expected an ambiguity error, but the compiler doesn't produce one.
Even when I don't create an instance of A, it doesn't produce an ambiguity error either.
int main()
{
    return 0;
}

Why is that?

A: There is no compilation error because no error exists in your code. Just like defining two functions: they need to have different signatures, other than that, it's possible. The ambiguity compilation error appears only when you try to call one of those functions. Same will happen trying to call the default constructor of A, even if it is private:
class A
{
private:
    A() {}
public:
    A(int x = 0) {}
    void f() {}
    void f(int x = 0) {}
};

This compiles, trying to call f() with no parameters fails, which makes sense.
Also try:
class A
{
private:
    A() {}
public:
    A(int x = 0) {}
    void f() {}
    void f() const {}
};

Should this give an error? No, because the two f's have different signatures. In this case the compiler can resolve the ambiguity, if you call f on a const object, the const method will get called, and vice-versa.

A: Declaring potentially ambiguous functions in C++ does not produce any ambiguity errors. Ambiguity takes place when you attempt to refer to these functions in an ambiguous way. In your example ambiguity will occur if you try to default-construct your object.
Strictly speaking, it is perfectly normal to have declarations in C++ program that are potentially ambiguous (i.e. that can be referred to in an ambiguous way). For example, at the first sight these overloaded functions look fine
void foo(double);
void foo(int);

but calling foo(1u) will trigger ambiguity error. So, once again, ambiguity is the property of the way you refer to the previously declared functions, not the property of the function declarations themselves.

A: Your code compiles because there is no ambiguity.  You created a class with two constructors, one which always takes 0 arguments, and one which always takes one argument, an int.  You then unambiguously called the constructor taking an int value.  That this int has a default value does not matter, it is still a completely different signature.  That the constructors are potentially ambiguous doesn't matter, the compiler only complains when a particular call is actually ambiguous.
When you create an instance of A with no arguments, it doesn't know which constructor you want to call: the default constructor, or the constructor taking an int with a parameter value of 0. In this case it would be nice if C++ notices that the private constructor is ineligible, but that is not always possible.
This behavior ends up being useful in some circumstances (e.g. if you have a few overloads involving templates, some of which will overlap if given the right types), though for simple cases like this, I would just make the single constructor with the default argument (preferably marked explicit unless you have a really really good reason to leave it implicit, and then I would second guess that reason just to be sure!)
-- EDIT --
Let's have some fun with this and try to explore further what is happening.
// A.h
class A
{
public:
    A(); // declare that somewhere out there, there exists a constructor that takes no args.  Note that actually figuring out where this constructor is defined is the linker's job
    A(int x = 10); // declare that somewhere out there, there exists a constructor that take one arg, an integer. Figuring out where it is defined is still the linker's job. (this line does _not_ declare two constructors.)

    int x;
};

// A.cpp
#include "A.h"

A::A() { ... } // OK, provide a definition for A::A()
A::A(int x) { ... } // OK, provide a definition for A::A(int) -- but wait, where is our default param??

// Foo.cpp
#include "A.h"

void Foo()
{
    A a1(24); // perfectly fine
    A a2; // Ambigious!
}

// Bar.cpp
class A // What's going on? We are redefining A?!?!
{
public:
    A();
    A(int x); // this definition doesn't have a default param!
    int x;
};

void Bar()
{
    A a; // This works! The default constructor is called!
}

// Baz.cpp
class A // What's going on? We are redefining A again?!?!
{
public:
    //A(); // no default constructor!
    A(int x = 42); // this definition has a default param again, but wait, it's different!
    int x;
};

void Baz()
{
    A a; // This works! A::A(int) is call! (but with what parameter?)
}

Note that we are taking advantage of the fact that the compiler doesn't know about headers; by the time it looks at a .cpp file, the preprocessor has already substituted #includes with the body of the header.  I am playing at being my own preprocessor, doing some dangerous things like providing multiple, different definitions of a class.  Later on, one of the linker's jobs is to throw out all but one of these definitions.  If they do not align up in the exact right way, all kinds of bad things will happen, as you will be in the twilight zone of undefined behavior.
Note that I was careful to provide the exact same layout for my class in every compilation unit; every definition has exactly 1 int and 0 virtual methods. Note that I did not introduce any extra methods (though that might work; still doing things like this should be looked on with great suspicion), the only thing that changed were some non-virtual member functions (well constructors really) and then only to remove the default constructor.  Changing and removing the default value changed nothing about the definition of A::A(int).
I don't have a copy of the spec on me, so I can't say if my careful changes fall under undefined behavior or implementation specific behavior, but I would treat it as such for production code and avoid leveraging such tricks.
And the ultimate answer to what argument is used inside of Baz is,.... 42!

A: Here is a slightly modified example that I have tested with GCC on cygwin:
#include <iostream>

class A
{
  private:
    A();

  public:
    A(int x = 0);
};

A::A()
{
  std::cout << "Constructor 1.\n" << std::endl;
}

A::A(int x)
{
  std::cout << "Constructor 2 with x = " << x << std::endl;
}

int main()
{
  A a1(1);
  A a2;

  return 0;
}

The compiler gives the following error message:
$ g++ test.cc
test.cc: In function `int main()':
test.cc:28: error: call of overloaded `A()' is ambiguous
test.cc:20: note: candidates are: A::A(int)
test.cc:14: note:                 A::A()

Update
I understand how the C++ compiler works (thanks for the explanations given by others): the two declarations are different and therefore accepted, but when trying to reference the default constructor, the compiler cannot decide which of the two it should use.
However, the fact that the default constructor A() can never be invoked can be inferred from the declarations already. Apparently you have two functions with different signatures
A()
A(int x = 0)

but, in fact, A(int x = 0) implicitly defines two functions: A(int x) and A(). In the second function x is just an initialized local variable. Instead of writing
A(int x = 0)
{
   ...
}

you could write two functions:
A(int x)
{
  ...
}

A()
{
  int x = 0;
  ...
}

with the same body. The second of these two functions has the same signature as the default constructor A(). That's why you will always have a compilation error when you try to instantiate class A using the A() constructor. This could be detected even without an explicit declaration such as
A a;

So I totally agree with Ron_s that I would expect an ambiguity error in his example. IMHO it would be more consistent.

A: Ambiguity doesn't arise because the private constructor is not even considered when you write A a(1), as you pass an argument to it, and the private constructor doesn't take any argument.
However, if you write A a, then there will be ambiguity, because both constructors are candidates, and the compiler cannot decide which one to invoke.


text:
Q: How to display the grid over tiles in a geo map bokeh plot Grid is displayed under the tiles. Is there a way to display it over (z-index control) ?
from bokeh.plotting import figure, show
from bokeh.tile_providers import CARTODBPOSITRON, get_provider
from bokeh.models import MercatorAxis, Grid

tile_provider = get_provider(CARTODBPOSITRON)

# range bounds supplied in web mercator coordinates
p = figure(x_range=(-2000000, 6000000), y_range=(-1000000, 7000000),
           x_axis_type="mercator", y_axis_type="mercator")

p.add_layout(MercatorAxis(), 'above')
p.add_layout(MercatorAxis(), 'right')

# possible controls but not visible
p.grid.grid_line_dash = [6, 4]
p.grid.grid_line_alpha = 1
p.grid.grid_line_color = 'gray'

p.add_tile(tile_provider)

show(p)

A: I think you are looking for the level value as a keyword argument.
This is the line to change:
p.add_tile(tile_provider, level='image')
This is the result:

firts try
I first modified the alpha value (also a keyword argument).
This is the line I changed:
p.add_tile(tile_provider, alpha=0.7)
And this is the output:

A: FWIW, it seems to be the default behavior in Bokeh 2.3. You can try using a development version or just wait till it's released.


text:
Q: VSTS git build fails with git submodule I have a git repos A and B in a Visual Studio Team Services Project.
B is a submodule of A with the following config in .gitmodules:
[submodule "my_submodule"]
    path = somefolder/my_submodule
    url = https://xxx.visualstudio.com/xxx/_git/B

If I do a build with the option Repository/Checkout Submodules I get the following error:
Repository type=TfsGit
localPath=C:\a\1\s
clean=False
sourceBranch=refs/heads/submoduletest
sourceVersion=0378dd86db31e4d7bff8de86a482b3d8e72dd3ba
Syncing repository: A (Git)
repository url=https://xxx.visualstudio.com/_git/A
checkoutSubmodules=True
Starting clone
Checking out 0378dd86db31e4d7bff8de86a482b3d8e72dd3ba to C:\a\1\s with submodules
Checked out branch refs/heads/submoduletest for repository A at commit 0378dd86db31e4d7bff8de86a482b3d8e72dd3ba
##[error]LibGit2Sharp.NotFoundException: Failed to resolve path 'C:/a/1/s/xxx/somefolder/my_submodule/.git': The system cannot find the path specified.
##[error]   at LibGit2Sharp.Core.Ensure.HandleError(Int32 result)
##[error]   at LibGit2Sharp.SubmoduleCollection.Update(String name, SubmoduleUpdateOptions options)
##[error]   at Microsoft.TeamFoundation.DistributedTask.Task.Internal.Core.GitHelper.DoUpdateSubmodules(Repository repository, Int32 maxRecursionDepth, Int32 currentRecursionDepth, String username, String password, CancellationToken cancellationToken)
##[error]   at Microsoft.TeamFoundation.DistributedTask.Task.Internal.Core.GitHelper.UpdateSubmodules(ITaskEndpoint endpoint, Repository repository, Int32 maxRecursionDepth, CancellationToken cancellationToken)
##[error]   at Microsoft.TeamFoundation.DistributedTask.Task.Internal.Core.GitHelper.SyncAndCheckout(Boolean cleanRepository, String sourceBranch, String sourceVersion, Boolean checkoutSubmodules, CancellationToken cancellationToken)
##[error]   at Microsoft.TeamFoundation.DistributedTask.Plugin.Build.GitSourceProvider.<>c__DisplayClass3_0.<PrepareRepositoryAsync>b__0()
##[error]Microsoft.TeamFoundation.DistributedTask.Agent.Common.AgentExecutionTerminationException: Prepare repository failed with exception. ---> LibGit2Sharp.NotFoundException: Failed to resolve path 'C:/a/1/s/xxx/somefolder/my_submodule/.git': The system cannot find the path specified.
##[error]   at LibGit2Sharp.Core.Ensure.HandleError(Int32 result)
##[error]   at LibGit2Sharp.SubmoduleCollection.Update(String name, SubmoduleUpdateOptions options)
##[error]   at Microsoft.TeamFoundation.DistributedTask.Task.Internal.Core.GitHelper.DoUpdateSubmodules(Repository repository, Int32 maxRecursionDepth, Int32 currentRecursionDepth, String username, String password, CancellationToken cancellationToken)
##[error]   at Microsoft.TeamFoundation.DistributedTask.Task.Internal.Core.GitHelper.UpdateSubmodules(ITaskEndpoint endpoint, Repository repository, Int32 maxRecursionDepth, CancellationToken cancellationToken)
##[error]   at Microsoft.TeamFoundation.DistributedTask.Task.Internal.Core.GitHelper.SyncAndCheckout(Boolean cleanRepository, String sourceBranch, String sourceVersion, Boolean checkoutSubmodules, CancellationToken cancellationToken)
##[error]   at Microsoft.TeamFoundation.DistributedTask.Plugin.Build.GitSourceProvider.<>c__DisplayClass3_0.<PrepareRepositoryAsync>b__0()
##[error]   --- End of inner exception stack trace ---
##[error]   at Microsoft.TeamFoundation.DistributedTask.Plugin.Build.GitSourceProvider.<>c__DisplayClass3_0.<PrepareRepositoryAsync>b__0()
##[error]   at System.Threading.Tasks.Task.Execute()

The interesting error message seems to be:
LibGit2Sharp.NotFoundException: Failed to resolve path 'C:/a/1/s/xxx/somefolder/my_submodule/.git'

Doing a git clone xxx/A --recursive on my maschine works.
The fantastic docs point to an auth problems:
https://www.visualstudio.com/en-us/docs/build/define/repository
But this says nothing about auth and even using a relative path in .gitmodules does not result in a different error message.
Any ideas?
Update 1
For testing purposes I used a branch. I merged the changes (adding submodule) to master and retried - now with the following error:
##[error]LibGit2Sharp.NotFoundException: Object not found - no matching loose object (4fa408bc7b29e87b7032e0f78998516ff4a4da00)

That hash is the HEAD of my submodule - clearly available.

A: @eddie-msft was right with his comment: there was a folder with the same name on master. The checkout to my test branch did not remove the folder. While this works when I do it locally, VS Team Serivices seems to have a problem with that.
But there was another problem: Contrary to the documentation, I hat to provide the full url to the submodule (https://xxx.visualstudio.com/xxx/_git/B). The documentation states that I should use a relative url (../B or ../../B  - its a guessing game) but that does not work.

A: There is some issue with your .gitmodules file. Usually, the path in the file should be your submodule repository name("B" in your scenario).


text:
Q: Is it possible to have functions with multiple type signatures in Haskell I apologize for this question. I've been away for a while and feel like I've forgotten everything I knew.
I want to do something like this.
data X = X
data Y = Y

myEq X X = True
myEq Y Y = True
myEq _ _ = False

I've tried various declarations for myEq. I've also tried to define a type class that might do it. But nothing I could think of compiled.
Is something like this possible? And if so, how?
Thanks.

A: I think this will do it.
data X = X deriving (Show)
data Y = Y deriving (Show)

class (Show a) => MyEquatable a

instance MyEquatable X
instance MyEquatable Y

myEq :: (MyEquatable a, MyEquatable b) => a -> b -> Bool
myEq a b = show a == show b

Of course, if doesn't have to be show, but that's a simple way to do it.


text:
Q: Facebook PHP SDK getUser() returning 0 in Safari on Windows I am working on a Facebook iframe app. I am using both the PHP SDK and the JS SDK. In my index file I call on the PHP SDK for some information about the user. This includes the getUser() function, which always works in the index.
I have a number of other PHP files, however, that I use to populate divs in the index when the user clicks on certain links. I am using the FB PHP SDK in each one of these files to ensure that the user is still logged into FB. That is, when these files are executed I call on the getUser() function to get the user's ID and determine if the person is still logged in. I inject the content of these PHP files into the divs in index via jQuery's load() function.
This works under FFox, Opera, IE, and Chrome just fine but under certain installations of Safari it does not. Specifically, I've had major issues with 5.1.5 (7534.55.3). When the PHP files get called by the jQuery load function under this version of Safari the getUser() function always seems to return 0 (zero). I'm assuming this has something to do with the session cookies? I really don't know and was hoping someone on here could shed some light on this for me. Thanks..

A: you can add this to your site:
<?php
$uid = $facebook->getUser();

if ($uid==0) {

    $params = array(
      'scope' => 'read_stream, friends_likes',
      'redirect_uri' => 'https://www.myapp.com/post_login_page'
    );

    $loginUrl = $facebook->getLoginUrl($params);
    echo 'You need first to Login';
    exit();

} else {

     //Continue your site code

}

?>

A: Not sure if this is an issue any more but it impacted my Safari FB app development for some time. Check out this SA answer to fix it, I pretty much followed it exactly and it worked. Missing cookies on iframe in safari 5.1.5


text:
Q: How to force update CoreData Codefiles (Property Extension) in Swift 5? i am a bit confused with CoreData. In my xcdatamodeld I am able to create new properties and change some things about them, like whether they are optional or not.

For example, I created a property for my entity and called it descrip, the type is a String and I checked the Optional Field.

At some other point I try to create a new Object of this Entity and safe it to CoreData:
let newEntity = Entity(context: context)
newEntity.name = name
newEntity.descrip = descrip // descrip is an optional String
newEntity.filename = filename

I get the following error message: Value of optional type 'String?' must be unwrapped to a value of type 'String'

Then, I tried to create the NSManagedObjectSubclasses for my Entity. I discovered, that while all properties have been added and the type of all is set correctly, the ? indicating the Optionality of the property was messed up completely.

import Foundation
import CoreData

extension Entity {

    @nonobjc public class func fetchRequest() -> NSFetchRequest<Entity> {
        return NSFetchRequest<Entity>(entityName: "Entity")
    }

    @NSManaged public var name: String? // Should not be optional and was set so in xcdatamodeld
    @NSManaged public var descrip: String // Should be optional and set to optional in xcdatamodeld
    @NSManaged public var filename: String
}

Is there any way to force update this code file? Or how can I use optional strings to fill out my new Entity's optional values?

A: The error in that assignment is not a Core Data problem, it's pure Swift. You've declared descrip as String, yet you are trying to assign a String? value. That's not legal in Swift-- you must unwrap an optional before assigning it to a non-optional. It would be the same if you weren't using Core Data. For example this would produce the same error:
let foo: String? = "hello"
let bar: String = foo

The differences between the data model and the generated code happen because Swift optionals and Core Data optionals are completely different things. Core Data only cares if something is optional when you save changes. Swift cares about whether something is optional all the time. It's different because Core Data was around for a long time before Swift existed, so it doesn't always match up with what Swift expects.


text:
Q: Functions of the Glan-Taylor beam splitter cube Consider the Glan-Taylor prism.  I have 2 questions about it:

*

*Is the second half of the Glan-Taylor prism redundant? In the sense that, without it, the light be still polarised.

*Generally the reflected light will only be partially polarised.  Can I adjust it such that the p-mode contains no reflection so the the reflected light will be completely polarised?

A: *

*Yes, the light would still be polarized. The second half makes the output beam direction less sensitive to the input angle, and makes the polarizer symmetric so it can be used in reverse as well.

*Yes. The transmitted beam is always perfectly polarized because $s-$polarized light must reflect (total internal reflection); so whatever light is transmitted must be $p-$polarized. If, in addition, the reflection occurs at Brewster's angle for the $p-$polarization refractive index, then $p-$polarized light must transmit, so whatever light is reflected must be $s-$polarized. However, as probably_someone pointed out above, this requires that the input beam be collimated and aligned such that the reflection takes place at Brewster's angle.


text:
Q: How could I retrieve data from mysql in django to be shown in a modal wherein I could also update it? What I needed to do is after clicking the view modal button, it will show the information and then there is a button also wherein could update it.Can someone advice me which is the best thing to be done. Thanks.
Models.py
class Employee(models.Model):
first_name = models.CharField(max_length=100, blank=True, null=True)
last_name = models.CharField(max_length=100, blank=True, null=True)
middle_name = models.CharField(max_length=100, blank=True, null=True)
userid = models.CharField(max_length=45, blank=True, null=True)
email_address = models.CharField(max_length=100, blank=True, null=True)

I dont have views.py yet( Dont know where to start)
Modal Code:
{% for employee in employees %}

Employee

                            <button type="button" class="close" modalid="referral_modal" id="close_referral" aria-label="Close">
                                ×
                            </button>

Your Profile

                                        <form>

                                            User Name*

                                              <input id="username" name="username" placeholder="{{ employee.userid}}" class="form-control here" required="required" type="text">

                                            First Name

                                              <input id="name" name="name" placeholder="{{ employee.first_name}}" class="form-control here" type="text">

                                            Middle Name*

                                              <input id="text" name="text" placeholder="{{ employee.middle_name}}" class="form-control here" required="required" type="text">

                                            Last Name

                                              <input id="lastname" name="lastname" placeholder="{{ employee.last_name}}" class="form-control here" type="text">

                            <button name="submit" type="submit" class="btn btn-primary">Update</button>
                            <button type="button" class="btn btn-secondary" data-dismiss="modal" onclick="">Cancel</button>

    {% endfor %}
    {% endblock %}

MySQL DB

A: You can make your  tag readonly.
example:

and then in javascript on click "update button" you can make it editable again.
document.getElementById("name").readOnly = false;


text:
Q: ASP.NET/C#: Retrieving listview value and passing to C# via a checkbox I've seen various solutions to this on here, but for some reason it isn't working for me. Basically on the client side I'm generating Listview elements from a database and want to retrieve the value generated in the "catlbl" label value and pass to C# to add to an "int total variable", which already has a value in it when the page is generated. Here is my ASP.NET code:
<asp:ListView ID="elecMod_listview" runat="server" DataSourceID="elecModule_sqlDataSource">
     <ItemTemplate>

                <asp:Hyperlink ID="elecModuleDesc_hyperlink" runat="server" CssClass="pull-left" Text='<%# string.Concat(Eval("code"), " - ", Eval("name"))%>' NavigateURL='<%# "student_module_info.aspx?searchquery=" + Eval("code")%>' />

                 <asp:Label ID ="cat_lbl" runat="server" Text='<%# Eval("catPoints") %>'></asp:Label>

                <asp:Label ID="semester_lbl" runat="server" Text='<%# Eval("semesterNum") %>'></asp:Label>

                <asp:CheckBox ID="elective_checkbox" runat="server" CssClass="pull-left" OnCheckedChanged="elective_checkbox_CheckedChanged" AutoPostBack="true"/>

       </ItemTemplate>
</asp:ListView>

Here is my label code:

      Total CAT Points Selected: <asp:Label ID="catTotal_lbl" runat="server" Text="" />

And now here is my C# code:
//This value will be changed upon Page Load via other parts in the code and is displayed in the "catTotal_lbl"
int total = 0;
protected void elective_checkbox_CheckedChanged(object sender, EventArgs e)
{
    foreach (ListViewDataItem row in elecMod_listview.Items)
    {
        CheckBox catCheck = (CheckBox)row.FindControl("elective_checkbox");
        if(catCheck.Checked)
        {
            int elecCat = Convert.ToInt32(((Label)row.FindControl("cat_lbl")).Text);

            total += elecCat;
        }
    }

}

When I check the box, nothing happens. I basically want the value from "catPoints" added to the "catTotal_lbl" whenever I check the checkbox(s) and then stick that value in a database via C#. Been racking my brains on this for awhile! I'm still a newb so apologies if I broke any protocol.
EDIT:
I was able to make it work by adding this to the C#:
 protected void elective_checkbox_CheckedChanged(object sender, EventArgs e)
{

    foreach (ListViewDataItem row in elecMod_listview.Items)
    {
        CheckBox catCheck = (CheckBox)row.FindControl("elective_checkbox");
        if(catCheck.Checked)
        {
            int elecCat = Convert.ToInt32(((Label)row.FindControl("cat_lbl")).Text);

            total += elecCat;
            catTotal_lbl.Text = total.ToString();
        }
    }

}

But I would like to update the catTotal_lbl Label upon checking the checkbox in an UpdatePanel in AJAX. Is this feasible? Basically when I check the checkbox now, it reloads the whole page but it DOES change the label to the correct amount of CAT points now. I don't want it to reload the entire page, though.


text:
Q: got error Unable to find source file to my Windows-CE project i try to build cab from my windows-CE project
and i got this error:

Error 5 Unable to find source file 'D:\MySetup_Setup\System.Data.SqlServerCe.DLL' for assembly 'System.Data.SqlServerCe.DLL', located in '%CE1%\MySetup'   D:\MySetup_Setup.vddproj

all the dll are in place and the project works excellent
what can be the problem ?
thanks in advance

A: We'd have to see the source INF file that CABWIZ is using generate the CAB.  My guess is that system.data.sqlserverce.dll is not in the d:\mysetup_setup folder on the development machine.


text:
Q: How to properly set "0000-00-00 00:00:00" as a DateTime in PHP I have a column viewedAt which is a DATETIME and accept NULL values. It's a software restriction to set that column on each new record as 0000-00-00 00:00:00 so I go through the easy way using Symfony and Doctrine as show below:
$entEmail = new Email();
$entEmail->setViewedAt(new \DateTime('0000-00-00 00:00:00'));

But surprise PHP change that date to this -0001-11-30 00:00:00 and SQL mode in MySQL server is set to STRICT so query fails. I have read a lof of topics here as this, this and some other but didn't answer my doubt at all. I have made a few test with PHP alone and I got almost the same result:
$date = new DateTime("0000-00-00 00:00:00", new DateTimeZone('America/New_York'));
echo $date->format('Y-m-d h:i:s');

// outputs
// -0001-11-30 12:00:00

Even with MySQL mode set to STRICT I did test the following query and it works as image below shows:
INSERT INTO emails(`emails_category`, `deliveredAt`, `viewedAt`, `data`, `createdAt`, `updatedAt`, `reps_id`, `targets_id`) VALUES ("sent","2015-10-29 06:08:25","0000-00-00 00:00:00",null,"2015-10-29 06:08:25","2015-10-29 06:08:25","005800000058eYcAAI","0018000001GO8omAAD")

So viewedAt is accepting 0000-00-00 00:00:00 that value even if is not valid (I think it's kind of NULL or so)
How I can fix this? Is there any work around? What did you suggest me on this specific case where this is a software requirement and can't be changed?
I'm using Symfony 2.7.6, Doctrine 2.5.2 and PHP 5.5.30

A: Your architecture is wrong to begin with. The problem is not setting the date itself, which is so obviously invalid that both MySQL and PHP are right to reject it, as there is no year 0 and no day 0 of a month 0, and the output you see is just the correction to a sort-of-valid date (it's 1 year, 1 month and 1 day before 01/01/01). But you're also just missing the point that Doctrine abstracts this away if you just do it right:
$entEmail = new Email();
$entEmail->setViewedAt(null);

Doctrine will now happily put NULL in the database column as it should be.

A: $Date = date('Y-m-d H:i:s');

Isn't it easier to use the good old fashioned way at times?

A: It depends on your database field. In MySQL, a TIMESTAMP field is post 1970.
You should make the field allow null if you want it nullable. Even if you use the DATE field, it is supposed to be post 1000AD.
If you are going to put a real timestamp you can use the following:
date_default_timezone_set('America/New_York');
$date = date('Y-m-d H:i:s');

$entEmail = new Email();
$entEmail->setViewedAt( $date );

OR ( if you want it more concise )
date_default_timezone_set('America/New_York');

$entEmail = new Email();
$entEmail->setViewedAt( date('Y-m-d H:i:s') );

A: Your problem springs from the fact that MySQL offers three types of values for datetime:

*

*a valid date "2022-04-18 16:42:45"

*a null value, if your design allows null

*an unknown date value 0000-00-00 00:00:00
In the PHP paradigm there are only valid dates or null values. You could even dismiss null values. Your design would need to decide what to do with (3) when changing values from the MySQLto the PHP paradigm. Should it change to null or do some error (exception) handling? In the opposite direction there is less of a problem. Another way would be treating negative years in PHP as special case as well.