ES6 arrow functions arguments

export const emailMatcher = 
           (control: AbstractControl): {[key: string]: boolean} => {
  const email = control.get('email');
  const confirm = control.get('confirm');
  if (!email || !confirm) return null;
  return email.value === confirm.value ? null : { nomatch: true };

I understand the use-case for arrow functions, but can anyone explain me the below line:

export const emailMatcher = 
           (control: AbstractControl): {[key: string]: boolean} => {

We are creating a function emailMatcher to which we are passing control as a argument. What does this line {[key: string]: boolean} do? I am not really understanding how that applies to return type of the function.

Source: stackoverflow-javascript

Eikon Fingerprint Scanner PHP/SQL integration

Seeing if anyone has any good examples on how to integrate a fingerprint scanner into a php/sql database. We are working with two Eikon 710/510 fingerprint readers. We wish to be able to have a user scan their print, store that data in the db, and have them open a door connected to another reader.
We have not found much documentation on these. We have the SDK, unfortunetly it is all in C++ which we do not have much experience in. We were wondering if anyone would be able to point us to some examples?

Source: stackoverflow-php

Having trouble getting a counter reset function to work using sockets in express

I have a project I am working on for a coding bootcamp. For the project I need to create a website that has a button that when pressed adds +1 to a counter and displays how many times the button has been pressed. The project also needs a reset button that when pressed resets the count back to zero.

I created the project and everything is working well except for the reset function. Whenever I press the reset button nothing happens. I have looked over the code and I don’t see any errors in the reset function that I wrote. Could anyone out there give me any tips on something I may be overlooking as a newbie coder?

Here is my index.js page:

module.exports = function Route (app, server) {
    // this gets the module (below)
    var io = require("").listen(server)

    var counter = 0; //saves the count

    io.sockets.on("connection", function(socket){
        socket.on("push_button", function(data){
            counter +=1;
            io.emit("push_counter", {response: counter}); 
            /* io.emit is a full broadcast, thus sends data to all connectd clients
            will send counter number to index.ejs after increasing by 1 */

        socket.on("reset_counter", function(data){
            counter = 0;
            io.emit("reset_response", {response: counter});
            /* Will set counter to 0 and send to index.ejs */


    // root route to render the index.ejs view (below)
    app.get("/", function(request, response){

Here is my index.ejs file that I have stored in a views folder. This page contains the reset function:

<html lang ="en US">
    <meta charset="UTF-8">
    <title>Epic Button Game</title>
        $(document).ready(function (){
           // alert("jquery loaded");
           var socket = io.connect();

          //lets emit an event when somebody pushes the button
                socket.emit("push_button", {action: "Somebody pushed the button"});

          // this event will emit to the server to reset the counter into 0
                socket.emit("reset_counter", {action: 'Resetting the counter'});

          // listen to the push_counter event from server
          socket.on("push_counter", function (data){
             console.log(data); // 
        <h2 id="message">Reset needs to be fixed!</h2>
        <h4>Push the button to update the count!</h4>
        <button id="push">Push this awesome button</button>
        <button id="reset">Reset Count</button>

Here is my server.js page:

// require express, path, body-parser
var express = require("express");
var path = require("path");
var bodyParser = require('body-parser');
// create the express app
var app = express();

// static content
app.use(express.static(path.join(__dirname, "./static")));
// setting up ejs and our views folder
app.set('views', path.join(__dirname, './views'));
app.set('view engine', 'ejs');
// tell the express app to listen on port 3000
var server = app.listen(3000, function() {
    console.log("listening on port 3000");

//we're going to have /routes/index.js handle all of our routing
var route = require('./routes/index.js')(app, server);

Finally my package.json page which contains a list of dependencies I am using:

  "name": "epic_button_game",
  "version": "1.0.0",
  "description": "",
  "main": "server.js",
  "scripts": {
    "test": "echo "Error: no test specified" && exit 1",
    "start": "node server.js"
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "ejs": "^2.5.5",
    "express": "^4.14.1",
    "": "^1.7.2"

Thanks for in advance for any suggestions.

Source: stackoverflow-javascript

Symfony form event, change value on radio button

I have form for OutboundInvoice entity, in form I have customer choice field, with query_builder and when select customer I need change select data in radio button in field invoicingType. How can how to do it ?

Now I using symfony form event for change label for 'mapped' => false, field in form and I think this is close decision, bгt how correct realized I don’t know

class OutboundInvoiceForm extends AbstractType
 * @param FormBuilderInterface $builder
 * @param array $options
public function buildForm(FormBuilderInterface $builder, array $options)
        ->add('customer', 'entity', array(
            'class' => Customer::class,
            'property' => 'name',
            'empty_value' => 'Choice Customer',
            'query_builder' => function ($repository) {
                /** @var CustomerRepository $repository */
                return $repository->getAllQuery();
            'required' => true

    $formModifier = function (FormInterface $form, Customer $customer = null) {
        if (null === $customer) {
            $positions = '-';
            $label = $positions;
        } else {
            $positions = $customer->getInvoicingAddress()
                ? $customer->getInvoicingAddress()->getFormattedAddress()
                : '-';
            $label = $positions;

            ->add('invoicing_address', TextType::class, [
                'mapped' => false,
                'empty_data' => $positions,
                'label' => $label


        function (FormEvent $event) use ($formModifier) {
            $data = $event->getData();
            $formModifier($event->getForm(), $data->getCustomer());

        function (FormEvent $event) use ($formModifier) {
            $customer = $event->getForm()->getData();
            $formModifier($event->getForm()->getParent(), $customer);
        ->add('invoicingType', 'entity', array(
            'class' => InvoicingType::class,
            'property' => 'name',
            'query_builder' => function ($repository) {
                /** @var InvoicingTypeRepository $repository */
                return $repository->getAllQuery();
            'required' => false,
            'expanded' => true,

 * @param OptionsResolverInterface $resolver
public function setDefaultOptions(OptionsResolverInterface $resolver)
        'data_class' => OutboundInvoice::class,
        'csrf_protection' => false,
        'edit' => false,
        'terms_edit_data' => 0

 * @return string
public function getName()
    return 'economy_bundle_outbound_invoice';

this my js where replaced html with by element

var $customer = $('#economy_bundle_outbound_invoice_customer');

$customer.change(function() {   
var $form = $(this).closest('form');
var data = {};
data[$sport.attr('name')] = $sport.val();
    url : $form.attr('action'),
    type: $form.attr('method'),
    data : data,
    success: function(html) {

Source: stackoverflow-php

JS: request data from github repo in a loop

I need to retrieve data about users from github api but I always get max 30 items and there is over 160 of the items I want to retrieve.
I created a loop in javascript:

for(var i = 1; i < 4; i++) {
    var request = new XMLHttpRequest();'get', ''+i, true);
    request.onload = print;

and print is:

function printPeople() {
    var resObj = JSON.parse(this.responseText);
    var users = [];
    var index = 0;
    for (var i = 0; i < resObj.length; i++) {

        if(!document.getElementById('person'+i).innerHTML === "") {
            index += 30;
            document.getElementById('person' + index).innerHTML = resObj[i].login;
        } else {
            document.getElementById('person' + index).innerHTML = resObj[i].login;


but each iteration overwrites previous.

I have tried to add each user to a div like this:

but it still fills the first 30 divs.

How can I keep the data from he iterations and add new data from new iterations to the same list?

Source: stackoverflow-javascript

Return PHP Mysql query using AJAX onclick function

So, I’ve been looking for a variety of sources to answer my question the last few day and thus have found nothing that’s worked for me. I’ll preface this further by saying that in regards to PHP and Javascript I started learning them like a week ago. I also understand that there will likely be better ways to format/write the code I’m about to post so please bear with me! 🙂

Essentially, I am trying to use a page name play.php in combination with AJAX to echo MYSQL queries back onto the page inside certain page elements.

So the code for main.js which is linked directly to play.php. I’ve tried about three different way that I’ve seen in various answers and have not gotten the information I wanted. I either get no response or I get undefined in all of them.

    function selectChar(uname, cname) 
    var data = {
        username : uname,
        charname : cname
        data : data,
        type : 'Get',
        url : 'start.php',
        success : function (result) { 
        var data_character = JSON.parse(result);
        var cnamediv = document.getElementById('charactername');
        cnamediv.innerHTML = "";
        cnamediv.innerHTML = data_character[0].name;

The one above I see most often and the one below I just found earlier today. I get undefined when I attempt to call the array.

function selectChar(uname, cname) 
        var cnamediv = document.getElementById('charactername');
        cnamediv.innerHTML = "";
        cnamediv.innerHTML = data_character[0].name;

and finally the PHP code that queries the database and echos the data back.

    $conn = new mysqli($hostname,$username,$dbpassword, $dbname);

    if(!$conn) {
        die('Could not connect: ' . mysql_error());

    $username = $_GET['username'];
    $charname = $_GET['charname'];

    $sql = "SELECT `id`, `username` FROM `users` WHERE `username` ='$username'";
    $result = mysqli_query($conn,$sql);

    //Send the array back as a JSON object
    echo json_encode($result);

I’m not looking for someone to do work for me but I do require some guidance here. What would be an appropriate way to make this work? Is my code terribly incorrect? Am I missing an aspect of this altogether? Please, I would really seriously appreciate any help someone could give me!

P.S. I did just get done reviewing several other similar questions none of which seemed to help. Either there was never a conclusive outcome as to what worked for them or the solution didn’t work when I attempted it.

Source: stackoverflow-php

Remote serve not sending response to ajax post

I am using WAMP 3.0.8 PHP 7.0.10 Apache 2.4.23 and trying to build my first JSON API.

The ajax call does send the data to the server. I can see it stored in the text file.

My AJAX looks like this.


                 var send = {"name":"Jo Moe", "age":39, "city":"Meridian"};
                 var prescription = JSON.stringify(send);
                    type: 'POST',
                dataType: 'JSON',
                     url: '',
                    data: {"scripts": prescription},

                  success: function(data){



Server side looks like this:

    if(isset($_POST["scripts"]) && !empty($_POST["scripts"])){
        $sent = filter_input(INPUT_POST, "scripts", FILTER_SANITIZE_SPECIAL_CHARS);
        $scripts = html_entity_decode($sent);

        file_put_contents("jsonScript.txt", $scripts);

        $finish = "Message Received!";

        echo json_encode($finish);


Now this all worked when it was on the same server. When I separated the receive.php and put it on the remote server. It no longer shows the response.


Source: stackoverflow-php

PHP Crypt seems to create the same string for crypt(A,myhash) as crypt((A.B,myhash) where A is greater than 8 digits.

The title sort of says it all, but I’m wondering how to avoid this. My password validation currently does this frustrating thing where Password = Password works, but so does Password = Passwordssssssss

Shorter strings like Password = test don’t exhibit this behavior.

I feel like this means there’s no point in having a password longer than 8 digits which I find confusing… Thoughts?

Source: stackoverflow-php

how to passing callback function with multiple possible parameter lists

Here are two callback function:

function callback_a(){

function callback_b(p){
  alert('b says'+ p)'

If I want use callback_a

function test(callback){


But the function test isn’t applicable to callback_b, So how to implement a function that you can passing some callbacks function with multiple possible parameter lists.

Source: stackoverflow-javascript