问:
How to get drive letter of usb drive from vendor/product id?
I only know the Vendor and Product ID of a usb drive but I need to be able to get all drive letters associated to this device.

System.IO.DriveInfo doesn't give any IDs with which I can find the vid/pid.

LibUsb wrappers have the opposite problem -- tons of id information but nothing that I can connect to a mount point.

答:
Here is a solution that works for me, giving you all drives matching your vendor and product ids. Not all the code was written by me.</p>

```<code>#include <windows.h>
#include <stdio.h>
#include <setupapi.h>
#include <cfgmgr32.h>
#include <winioctl.h>

#define BUFFER_SIZE 256
#define MAX_DRIVES 26

// Finds the device interface for the CDROM drive with the given interface number.
DEVINST GetDrivesDevInstByDeviceNumber(long DeviceNumber)
{
   const GUID *guid = &GUID_DEVINTERFACE_DISK;

   // Get device interface info set handle
   // for all devices attached to system
   HDEVINFO hDevInfo = SetupDiGetClassDevs(guid, NULL, NULL, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
   if (hDevInfo == INVALID_HANDLE_VALUE)
      return 0;

   // Retrieve a context structure for a device interface of a device information set.
   BYTE buf[1024];
   PSP_DEVICE_INTERFACE_DETAIL_DATA pspdidd = (PSP_DEVICE_INTERFACE_DETAIL_DATA)buf;
   SP_DEVICE_INTERFACE_DATA spdid;
   SP_DEVINFO_DATA spdd;
   DWORD dwSize;

   spdid.cbSize = sizeof(spdid);

   // Iterate through all the interfaces and try to match one based on
   // the device number.
   for (DWORD i = 0; SetupDiEnumDeviceInterfaces(hDevInfo, NULL, guid, i, &spdid); i++)
   {
      // Get the device path.
      dwSize = 0;
      SetupDiGetDeviceInterfaceDetail(hDevInfo, &spdid, NULL, 0, &dwSize, NULL);
      if (dwSize == 0 || dwSize > sizeof(buf))
         continue;

      pspdidd->cbSize = sizeof(*pspdidd);
      ZeroMemory((PVOID)&spdd, sizeof(spdd));
      spdd.cbSize = sizeof(spdd);
      if (!SetupDiGetDeviceInterfaceDetail(hDevInfo, &spdid, pspdidd,
                                           dwSize, &dwSize, &spdd))
         continue;

      // Open the device.
      HANDLE hDrive = CreateFile(pspdidd->DevicePath, 0,
                                 FILE_SHARE_READ | FILE_SHARE_WRITE,
                                 NULL, OPEN_EXISTING, 0, NULL);
      if (hDrive == INVALID_HANDLE_VALUE)
         continue;

      // Get the device number.
      STORAGE_DEVICE_NUMBER sdn;
      dwSize = 0;
      if (DeviceIoControl(hDrive,
                          IOCTL_STORAGE_GET_DEVICE_NUMBER,
                          NULL, 0, &sdn, sizeof(sdn),
                          &dwSize, NULL))
      {
         // Does it match?
         if (DeviceNumber == (long)sdn.DeviceNumber)
         {
            CloseHandle(hDrive);
            SetupDiDestroyDeviceInfoList(hDevInfo);
            return spdd.DevInst;
         }
      }
      CloseHandle(hDrive);
   }

   SetupDiDestroyDeviceInfoList(hDevInfo);
   return 0;
}

// Returns true if the given device instance belongs to the USB device with the given VID and PID.
boolean matchDevInstToUsbDevice(DEVINST device, DWORD vid, DWORD pid)
{
   // This is the string we will be searching for in the device harware IDs.
   TCHAR hwid[64];
   sprintf(hwid, "VID_%04X&PID_%04X", vid, pid);

   // Get a list of hardware IDs for all USB devices.
   ULONG ulLen;
   CM_Get_Device_ID_List_Size(&ulLen, NULL, CM_GETIDLIST_FILTER_NONE);
   TCHAR *pszBuffer = malloc(sizeof(TCHAR) * ulLen);
   CM_Get_Device_ID_List(NULL, pszBuffer, ulLen, CM_GETIDLIST_FILTER_NONE);

   // Iterate through the list looking for our ID.
   for (LPTSTR pszDeviceID = pszBuffer; *pszDeviceID; pszDeviceID += _tcslen(pszDeviceID) + 1)
   {
      // Some versions of Windows have the string in upper case and other versions have it
      // in lower case so just make it all upper.
      for (int i = 0; pszDeviceID[i]; i++)
         pszDeviceID[i] = toupper(pszDeviceID[i]);

      if (_tcsstr(pszDeviceID, hwid))
      {
         // Found the device, now we want the grandchild device, which is the "generic volume"
         DEVINST MSDInst = 0;
         if (CR_SUCCESS == CM_Locate_DevNode(&MSDInst, pszDeviceID, CM_LOCATE_DEVNODE_NORMAL))
         {
            DEVINST DiskDriveInst = 0;
            if (CR_SUCCESS == CM_Get_Child(&DiskDriveInst, MSDInst, 0))
            {
               // Now compare the grandchild node against the given device instance.
               if (device == DiskDriveInst)
                  return TRUE;
            }
         }
      }
   }

   return FALSE;
}

int scan_drives(DWORD vid, DWORD pid)
{
   TCHAR caDrive[4] = TEXT("A:\\");
   TCHAR volume[BUFFER_SIZE];
   TCHAR volume_path_name[BUFFER_SIZE];
   DWORD dwDriveMask;

   int count = 0;

   // Get all drives in the system.
   dwDriveMask = GetLogicalDrives();

   if (dwDriveMask == 0)
   {
      printf("Error - GetLogicalDrives failed\n");
      return -1;
   }

   // Loop for all drives.
   for (int nLoopIndex = 0; nLoopIndex < MAX_DRIVES; nLoopIndex++, dwDriveMask >>= 1)
   {
      // If a drive is present,
      if (dwDriveMask & 1)
      {
         caDrive[0] = TEXT('A') + nLoopIndex;

         // If a drive is removable.
         if (GetDriveType(caDrive) == DRIVE_REMOVABLE)
         {
            //Get its volume info.
            if (GetVolumeNameForVolumeMountPoint(caDrive, volume, BUFFER_SIZE))
            {
               DWORD lpcchReturnLength;

               GetVolumePathNamesForVolumeName(volume, volume_path_name, BUFFER_SIZE, &lpcchReturnLength);

               char szVolumeAccessPath[] = "\\\\.\\X:";
               szVolumeAccessPath[4] = caDrive[0];

               long DeviceNumber = -1;

               HANDLE hVolume = CreateFile(szVolumeAccessPath, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);

               if (hVolume == INVALID_HANDLE_VALUE)
               {
                  return 1;
               }

               STORAGE_DEVICE_NUMBER sdn;
               DWORD dwBytesReturned = 0;

               long res = DeviceIoControl(hVolume, IOCTL_STORAGE_GET_DEVICE_NUMBER, NULL, 0, &sdn, sizeof(sdn), &dwBytesReturned, NULL);

               if (res)
               {
                  DeviceNumber = sdn.DeviceNumber;
               }

               CloseHandle(hVolume);

               if (DeviceNumber != -1)
               {
                  DEVINST DevInst = GetDrivesDevInstByDeviceNumber(DeviceNumber);

                  boolean match = matchDevInstToUsbDevice(DevInst, vid, pid);

                  if (match)
                  {
                     printf("%s\t0x%04x\t0x%04x\n", volume_path_name, vid, pid);
                  }
               }

               count++;
            }
         }
      }
   }

   return count;
}

int main(int argc, char *argv[])
{

   if (argc > 1)
   {

      if (argc % 2 == 0)
      {
         return -1;
      }

      for (int i = 1; i < argc - 1; i += 2)
      {
         int vid, pid;

         sscanf(argv[i], "%x", &vid);
         sscanf(argv[i + 1], "%x", &pid);

         scan_drives(vid, pid);
      }
   }

   return 0;
}
</code>```

Body:
Here is a solution that works for me, giving you all drives matching your vendor and product ids. Not all the code was written by me.

#include <windows.h>
#include <stdio.h>
#include <setupapi.h>
#include <cfgmgr32.h>
#include <winioctl.h>

#define BUFFER_SIZE 256
#define MAX_DRIVES 26

// Finds the device interface for the CDROM drive with the given interface number.
DEVINST GetDrivesDevInstByDeviceNumber(long DeviceNumber)
{
   const GUID *guid = &GUID_DEVINTERFACE_DISK;

   // Get device interface info set handle
   // for all devices attached to system
   HDEVINFO hDevInfo = SetupDiGetClassDevs(guid, NULL, NULL, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
   if (hDevInfo == INVALID_HANDLE_VALUE)
      return 0;

   // Retrieve a context structure for a device interface of a device information set.
   BYTE buf[1024];
   PSP_DEVICE_INTERFACE_DETAIL_DATA pspdidd = (PSP_DEVICE_INTERFACE_DETAIL_DATA)buf;
   SP_DEVICE_INTERFACE_DATA spdid;
   SP_DEVINFO_DATA spdd;
   DWORD dwSize;

   spdid.cbSize = sizeof(spdid);

   // Iterate through all the interfaces and try to match one based on
   // the device number.
   for (DWORD i = 0; SetupDiEnumDeviceInterfaces(hDevInfo, NULL, guid, i, &spdid); i++)
   {
      // Get the device path.
      dwSize = 0;
      SetupDiGetDeviceInterfaceDetail(hDevInfo, &spdid, NULL, 0, &dwSize, NULL);
      if (dwSize == 0 || dwSize > sizeof(buf))
         continue;

      pspdidd->cbSize = sizeof(*pspdidd);
      ZeroMemory((PVOID)&spdd, sizeof(spdd));
      spdd.cbSize = sizeof(spdd);
      if (!SetupDiGetDeviceInterfaceDetail(hDevInfo, &spdid, pspdidd,
                                           dwSize, &dwSize, &spdd))
         continue;

      // Open the device.
      HANDLE hDrive = CreateFile(pspdidd->DevicePath, 0,
                                 FILE_SHARE_READ | FILE_SHARE_WRITE,
                                 NULL, OPEN_EXISTING, 0, NULL);
      if (hDrive == INVALID_HANDLE_VALUE)
         continue;

      // Get the device number.
      STORAGE_DEVICE_NUMBER sdn;
      dwSize = 0;
      if (DeviceIoControl(hDrive,
                          IOCTL_STORAGE_GET_DEVICE_NUMBER,
                          NULL, 0, &sdn, sizeof(sdn),
                          &dwSize, NULL))
      {
         // Does it match?
         if (DeviceNumber == (long)sdn.DeviceNumber)
         {
            CloseHandle(hDrive);
            SetupDiDestroyDeviceInfoList(hDevInfo);
            return spdd.DevInst;
         }
      }
      CloseHandle(hDrive);
   }

   SetupDiDestroyDeviceInfoList(hDevInfo);
   return 0;
}

// Returns true if the given device instance belongs to the USB device with the given VID and PID.
boolean matchDevInstToUsbDevice(DEVINST device, DWORD vid, DWORD pid)
{
   // This is the string we will be searching for in the device harware IDs.
   TCHAR hwid[64];
   sprintf(hwid, "VID_%04X&PID_%04X", vid, pid);

   // Get a list of hardware IDs for all USB devices.
   ULONG ulLen;
   CM_Get_Device_ID_List_Size(&ulLen, NULL, CM_GETIDLIST_FILTER_NONE);
   TCHAR *pszBuffer = malloc(sizeof(TCHAR) * ulLen);
   CM_Get_Device_ID_List(NULL, pszBuffer, ulLen, CM_GETIDLIST_FILTER_NONE);

   // Iterate through the list looking for our ID.
   for (LPTSTR pszDeviceID = pszBuffer; *pszDeviceID; pszDeviceID += _tcslen(pszDeviceID) + 1)
   {
      // Some versions of Windows have the string in upper case and other versions have it
      // in lower case so just make it all upper.
      for (int i = 0; pszDeviceID[i]; i++)
         pszDeviceID[i] = toupper(pszDeviceID[i]);

      if (_tcsstr(pszDeviceID, hwid))
      {
         // Found the device, now we want the grandchild device, which is the "generic volume"
         DEVINST MSDInst = 0;
         if (CR_SUCCESS == CM_Locate_DevNode(&MSDInst, pszDeviceID, CM_LOCATE_DEVNODE_NORMAL))
         {
            DEVINST DiskDriveInst = 0;
            if (CR_SUCCESS == CM_Get_Child(&DiskDriveInst, MSDInst, 0))
            {
               // Now compare the grandchild node against the given device instance.
               if (device == DiskDriveInst)
                  return TRUE;
            }
         }
      }
   }

   return FALSE;
}

int scan_drives(DWORD vid, DWORD pid)
{
   TCHAR caDrive[4] = TEXT("A:\\");
   TCHAR volume[BUFFER_SIZE];
   TCHAR volume_path_name[BUFFER_SIZE];
   DWORD dwDriveMask;

   int count = 0;

   // Get all drives in the system.
   dwDriveMask = GetLogicalDrives();

   if (dwDriveMask == 0)
   {
      printf("Error - GetLogicalDrives failed\n");
      return -1;
   }

   // Loop for all drives.
   for (int nLoopIndex = 0; nLoopIndex < MAX_DRIVES; nLoopIndex++, dwDriveMask >>= 1)
   {
      // If a drive is present,
      if (dwDriveMask & 1)
      {
         caDrive[0] = TEXT('A') + nLoopIndex;

         // If a drive is removable.
         if (GetDriveType(caDrive) == DRIVE_REMOVABLE)
         {
            //Get its volume info.
            if (GetVolumeNameForVolumeMountPoint(caDrive, volume, BUFFER_SIZE))
            {
               DWORD lpcchReturnLength;

               GetVolumePathNamesForVolumeName(volume, volume_path_name, BUFFER_SIZE, &lpcchReturnLength);

               char szVolumeAccessPath[] = "\\\\.\\X:";
               szVolumeAccessPath[4] = caDrive[0];

               long DeviceNumber = -1;

               HANDLE hVolume = CreateFile(szVolumeAccessPath, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);

               if (hVolume == INVALID_HANDLE_VALUE)
               {
                  return 1;
               }

               STORAGE_DEVICE_NUMBER sdn;
               DWORD dwBytesReturned = 0;

               long res = DeviceIoControl(hVolume, IOCTL_STORAGE_GET_DEVICE_NUMBER, NULL, 0, &sdn, sizeof(sdn), &dwBytesReturned, NULL);

               if (res)
               {
                  DeviceNumber = sdn.DeviceNumber;
               }

               CloseHandle(hVolume);

               if (DeviceNumber != -1)
               {
                  DEVINST DevInst = GetDrivesDevInstByDeviceNumber(DeviceNumber);

                  boolean match = matchDevInstToUsbDevice(DevInst, vid, pid);

                  if (match)
                  {
                     printf("%s\t0x%04x\t0x%04x\n", volume_path_name, vid, pid);
                  }
               }

               count++;
            }
         }
      }
   }

   return count;
}

int main(int argc, char *argv[])
{

   if (argc > 1)
   {

      if (argc % 2 == 0)
      {
         return -1;
      }

      for (int i = 1; i < argc - 1; i += 2)
      {
         int vid, pid;

         sscanf(argv[i], "%x", &vid);
         sscanf(argv[i + 1], "%x", &pid);

         scan_drives(vid, pid);
      }
   }

   return 0;
}


来源: stackexchange

问:
Export and import foreign Keys
We've tranfered a site to a new server and now it's been running for three days without any foreign keys being active.

How can I:

Export the foreign keys from the old structure (100+ tables)

Import the keys while ignoring integrity problems

Discard all the records where the foreign key are missing

答:
Create two dumps (current/imported) and use a database diff tool, or generate the alter table statements by pulling the data from the information schema.

SET foreign_key_checks = 0; to disable, SET foreign_key_checks = 1; to enable.

Use left join statements and search for null values in the outer table.

ContentLicense: CC BY-SA 3.0

Title: Export and import foreign Keys


问:
Accessing Route URL Parameter in Middleware in Laravel 5.3
I am having a hard time accessing the Route URL Parameter in Middleware after updating from Laravel 5.1 to Laravel 5.3.

Here is my route file:

```<code>Route::group(['middleware' => ['app.access']], function()
{
    Route::resource('apps/{apps}/houses', 'HouseController',
                    ['except' => ['index', 'create', 'edit']]);

    Route::get('apps/{apps}/houses/colour/{colour}', 'HouseController@colourCheck');
    ...
}
</code>```

Kernel.php has RouteMiddleware updated like this:

```<code>protected $routeMiddleware = [
        'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
        'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
        'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
        'can' => \Illuminate\Auth\Middleware\Authorize::class,
        'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
        'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
        // Added ones....
        'jwt.auth' => \Tymon\JWTAuth\Middleware\GetUserFromToken::class,
        'jwt.refresh' => \Tymon\JWTAuth\Middleware\RefreshToken::class,
        // Custom Middleware
        'app.access' => \App\Http\Middleware\AppAccess::class,
    ];
</code>```

In Laravel 5.1 and I was able to access route parameter from middleware like this and I had no trouble:

```<code>public function handle($request, Closure $next)
{
        $appId = $request->route('apps');
        ...
}
</code>```

But, since upgrading to Laravel 5.3, the above code started returned $appId as null. I also tried accessing route parameter like $appId = $request->apps and this was not working as well.

So I then changed the Middleware to get the url parameter like this:

```<code>public function handle($request, Closure $next)
{
        $appId = $request->route()->parameters('apps');
        ...
}
</code>```

Since changing to the above, the middleware seems to be working for the first route. But then, I am having problem when going to the second route that has 2 parameters. For some reason, the above code fails and when returning $request->route()->parameters('apps') from middleware, I am getting an array like this:

```<code>Array
(
    [apps] => 1
    [colour] => green
)
</code>```

Why is that? Why is it not returning just the $appId which is 1? Am I missing something or is it a bug in Laravel 5.3? I want the Middleware to access only the appId parameter from the url and nothing else from the route. Can someone help me here please?

Update 1:

I tried changing the Middleware to get parameter like this:

```<code>$parameters = $request->route()->parameters();
$appId = $parameters['apps'];
</code>```

In the above, I am getting the error:

```<code>Undefined index: apps
</code>```

But when I print_r($parameters);, the output is like this:

```<code>Array
(
    [apps] => 1
    [day] => tuesday
)
[]
</code>```

Solution:

In the end, I found out the reason for this odd behaviour was due the parameter name in the url.

The following resources routes were generating route url parameter as app instead of apps. I dont know why though:

```<code>Route::resource('apps/{apps}/houses', 'HouseController',
                        ['except' => ['index', 'create', 'edit']]);
</code>```

Whereas the following routes were generating route url parameter as apps:

```<code>Route::get('apps/{apps}/houses/colour/{colour}', 'HouseController@colourCheck');
</code>```

Due to this odd behaviour, some routes were returning null for the parameter name apps and some where showing the parameter. Once I renamed all route parameters to {app} in the routes/api.php and Middleware, the Middleware started working the way it should.

I don't know why the resource routes were creating the parameter as app, but the above fixed the error for me, atleast for now.

答:
For me, this was the solution for Laravel 6.

In the routes file add ->middleware() like this:

```<code>Route::resource('orders', 'OrdersController')->middleware('roles:Admin,System');
</code>```

Now to retrieve the parameters in the middleware class:

```<code>public function handle($request, Closure $next, ...$roles)
{
     // now $roles contains: ['Admin, 'System']
}
</code>```

Body:
I am having a hard time accessing the Route URL Parameter in Middleware after updating from Laravel 5.1 to Laravel 5.3.

Here is my route file:

Route::group(['middleware' => ['app.access']], function()
{
    Route::resource('apps/{apps}/houses', 'HouseController',
                    ['except' => ['index', 'create', 'edit']]);

    Route::get('apps/{apps}/houses/colour/{colour}', 'HouseController@colourCheck');
    ...
}

Kernel.php has RouteMiddleware updated like this:

protected $routeMiddleware = [
        'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
        'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
        'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
        'can' => \Illuminate\Auth\Middleware\Authorize::class,
        'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
        'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
        // Added ones....
        'jwt.auth' => \Tymon\JWTAuth\Middleware\GetUserFromToken::class,
        'jwt.refresh' => \Tymon\JWTAuth\Middleware\RefreshToken::class,
        // Custom Middleware
        'app.access' => \App\Http\Middleware\AppAccess::class,
    ];

In Laravel 5.1 and I was able to access route parameter from middleware like this and I had no trouble:

public function handle($request, Closure $next)
{
        $appId = $request->route('apps');
        ...
}

But, since upgrading to Laravel 5.3, the above code started returned $appId as null. I also tried accessing route parameter like $appId = $request->apps and this was not working as well.

So I then changed the Middleware to get the url parameter like this:

public function handle($request, Closure $next)
{
        $appId = $request->route()->parameters('apps');
        ...
}

Since changing to the above, the middleware seems to be working for the first route. But then, I am having problem when going to the second route that has 2 parameters. For some reason, the above code fails and when returning $request->route()->parameters('apps') from middleware, I am getting an array like this:

Array
(
    [apps] => 1
    [colour] => green
)

Why is that? Why is it not returning just the $appId which is 1? Am I missing something or is it a bug in Laravel 5.3? I want the Middleware to access only the appId parameter from the url and nothing else from the route. Can someone help me here please?

Update 1:

I tried changing the Middleware to get parameter like this:

$parameters = $request->route()->parameters();
$appId = $parameters['apps'];

In the above, I am getting the error:

Undefined index: apps

But when I print_r($parameters);, the output is like this:

Array
(
    [apps] => 1
    [day] => tuesday
)
[]

Solution:

In the end, I found out the reason for this odd behaviour was due the parameter name in the url.

The following resources routes were generating route url parameter as app instead of apps. I dont know why though:

Route::resource('apps/{apps}/houses', 'HouseController',
                        ['except' => ['index', 'create', 'edit']]);

Whereas the following routes were generating route url parameter as apps:

Route::get('apps/{apps}/houses/colour/{colour}', 'HouseController@colourCheck');

Due to this odd behaviour, some routes were returning null for the parameter name apps and some where showing the parameter. Once I renamed all route parameters to {app} in the routes/api.php and Middleware, the Middleware started working the way it should.

I don't know why the resource routes were creating the parameter as app, but the above fixed the error for me, atleast for now.

Body:
For me, this was the solution for Laravel 6.

In the routes file add ->middleware() like this:

Route::resource('orders', 'OrdersController')->middleware('roles:Admin,System');

Now to retrieve the parameters in the middleware class:

public function handle($request, Closure $next, ...$roles)
{
     // now $roles contains: ['Admin, 'System']
}

ContentLicense: CC BY-SA 4.0


问:
Liquibase 3.8 inserts tinyint value with quotes
I am trying to insert a value into mysql using a liquibase script:

```<code><changeSet author="liquibase" id="6225">
    <insert tableName="master">
        <column name="id" value="7"/>
        <column name="insightname" value="topic_modelling"/>
        <column name="insighttype" value="1" valueBoolean="true"/>
    </insert>
</changeSet>
</code>```

But when I try this it gives me the error:

Error: Data truncation: Data too long for column 'insighttype' at row
  1 [Failed SQL: INSERT INTO db.master (id,
  insightname, insighttype) VALUES ('7', 'topic_modelling', '1')]

Is it because the value are passed with quotes? What is the solution?

My Create table statement looks like:

```<code>CREATE TABLE ss_insightmaster (
  id int(11) NOT NULL AUTO_INCREMENT,
  insightname varchar(255) NOT NULL,
  enabled tinyint(1) DEFAULT NULL,
  PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
</code>```

答:
Every Database handles Boolean values differently - Liquibase is expecting the insighttype of type BIT not TINYINT since you are using MySQL as you can see in the liquibase github.

OR

As a dirty hack you can run the changeset with another dbms where a NUMBERis expected:

```<code><changeSet author="liquibase" id="6225" dbms="oracle">
    <insert tableName="master">
        <column name="id" value="7"/>
        <column name="insightname" value="topic_modelling"/>
        <column name="insighttype" value="1" valueBoolean="true"/>
    </insert>
</changeSet>
</code>```

Body:
I am trying to insert a value into mysql using a liquibase script:

<changeSet author="liquibase" id="6225">
    <insert tableName="master">
        <column name="id" value="7"/>
        <column name="insightname" value="topic_modelling"/>
        <column name="insighttype" value="1" valueBoolean="true"/>
    </insert>
</changeSet>

But when I try this it gives me the error:

Error: Data truncation: Data too long for column 'insighttype' at row
  1 [Failed SQL: INSERT INTO db.master (id,
  insightname, insighttype) VALUES ('7', 'topic_modelling', '1')]

Is it because the value are passed with quotes? What is the solution?

My Create table statement looks like:

CREATE TABLE ss_insightmaster (
  id int(11) NOT NULL AUTO_INCREMENT,
  insightname varchar(255) NOT NULL,
  enabled tinyint(1) DEFAULT NULL,
  PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;

Body:
Every Database handles Boolean values differently - Liquibase is expecting the insighttype of type BIT not TINYINT since you are using MySQL as you can see in the liquibase github.

OR

As a dirty hack you can run the changeset with another dbms where a NUMBERis expected:

<changeSet author="liquibase" id="6225" dbms="oracle">
    <insert tableName="master">
        <column name="id" value="7"/>
        <column name="insightname" value="topic_modelling"/>
        <column name="insighttype" value="1" valueBoolean="true"/>
    </insert>
</changeSet>


问:
FFTW in Qt Creator
I try to make a program that computes FFTW from IQ data.
Windows 10 64 bits. Qt Creator 4.8.2 Based on Qt 5.12.2 (MSVC 2015, 32 bit)
The program crashed when I use

```<code>fftw_plan_dft_1d(N, in, out, FFT_FORWARD, FFTW_ESTIMATE);
</code>```

I download fftw-3.3.5-dll64 and dll32, with both the same result.

.pro

```<code>INCLUDEPATH += $$PWD/fftw-3.3.5-dll32
QMAKE_LIBDIR += $$PWD/fftw-3.3.5-dll32
LIBS += $$PWD/fftw-3.3.5-dll32/ -llibfftw3-3
LIBS += $$PWD/fftw-3.3.5-dll32/ -llibfftw3f-3
LIBS += $$PWD/fftw-3.3.5-dll32/ -llibfftw3l-3
</code>```

.cpp

```<code>include "fftw3.h"

int main()
{
    int N;
    fftw_complex *in, *out;
    fftw_plan myPlan;

    in = (fftw_complex*) fftw_malloc(sizeof(fftw_complex)* N);
    out = (fftw_complex*) fftw_malloc(sizeof(fftw_complex)* N);

    fftw_plan_dft_1d(N, in, out, FFT_FORWARD, FFTW_ESTIMATE);  //this line crashed the program.

    fftw_execute(myPlan);

    fftw_destroy_plan(myPlan);
    fftw_free(in);
    fftw_free(out);
}
</code>```

I hope some one can help me.
Thanks.

答:
This has neither to do with Windows nor with QtCreator. You have to write the program correctly.

fftw_plan_dft_1d(N, in, out, FFTW_FORWARD, FFTW_ESTIMATE);  //this line crashed the program.

This is not the line that crashes. This line is just fine. The next will crash totally expectedly, because you never assigned  myPlan.

myPlan = fftw_plan_dft_1d(N, in, out, FFTW_FORWARD, FFTW_ESTIMATE);

will correct your problem. That is provided that you set N to something reasonable. I'm sure that you also should set in at least. Ecept of course you want to Fourier transform whatever happens to be at in in your RAM. Which is a cool thing. :)

Title: FFTW in Qt Creator

Body:
I try to make a program that computes FFTW from IQ data.
Windows 10 64 bits. Qt Creator 4.8.2 Based on Qt 5.12.2 (MSVC 2015, 32 bit)
The program crashed when I use

fftw_plan_dft_1d(N, in, out, FFT_FORWARD, FFTW_ESTIMATE);

I download fftw-3.3.5-dll64 and dll32, with both the same result.

.pro

INCLUDEPATH += $$PWD/fftw-3.3.5-dll32
QMAKE_LIBDIR += $$PWD/fftw-3.3.5-dll32
LIBS += $$PWD/fftw-3.3.5-dll32/ -llibfftw3-3
LIBS += $$PWD/fftw-3.3.5-dll32/ -llibfftw3f-3
LIBS += $$PWD/fftw-3.3.5-dll32/ -llibfftw3l-3

.cpp

include "fftw3.h"

int main()
{
    int N;
    fftw_complex *in, *out;
    fftw_plan myPlan;

    in = (fftw_complex*) fftw_malloc(sizeof(fftw_complex)* N);
    out = (fftw_complex*) fftw_malloc(sizeof(fftw_complex)* N);

    fftw_plan_dft_1d(N, in, out, FFT_FORWARD, FFTW_ESTIMATE);  //this line crashed the program.

    fftw_execute(myPlan);

    fftw_destroy_plan(myPlan);
    fftw_free(in);
    fftw_free(out);
}

I hope some one can help me.
Thanks.


问:
Google Play Issue with Apps
I'm pretty new to developing android apps. I have published my first 2 apps on Google Play and the issue is that I can't have them both installed at the same time. I had the first one on my phone, but when I wanted to install my second one I couldn't do it unless I uninstalled the first app.

Anyone had this issue before?

The only thing the apps have in common is probably the .jks key used to generate the .aab bundle, but that shouldn't be the issue.

答: Do they somehow have the exact same package name? This sounds exactly like what would happen if it were that.</p>

Title: Google Play Issue with Apps


问:
Converting text range to single integer
if I had a set of data containing the following:

```<code>0-3
0-3
0-3
2-6
2-6
2-6
2-6
2-6
1-3
</code>```

How would I covert this into a single number, say the upper value, or even better the average of the two numbers either side of the hyphen?

Any help would be much appreciated!

答:
You could use tidyverse for this</p>

```<code>d <- c("0-1", "1-1","2-0")

data.frame(d) %>% separate(col = d, sep = "-", into = c("l", "r")) %>%
  mutate(average = (as.numeric(l) + as.numeric(r) / 2))

  l r averaged
1 0 1      0.5
2 1 1      1.5
3 2 0      2.0

</code>```

Title: Converting text range to single integer

Body:
if I had a set of data containing the following:

0-3
0-3
0-3
2-6
2-6
2-6
2-6
2-6
1-3

How would I covert this into a single number, say the upper value, or even better the average of the two numbers either side of the hyphen?

Any help would be much appreciated!

Body:
You could use tidyverse for this

d <- c("0-1", "1-1","2-0")

data.frame(d) %>% separate(col = d, sep = "-", into = c("l", "r")) %>%
  mutate(average = (as.numeric(l) + as.numeric(r) / 2))

  l r averaged
1 0 1      0.5
2 1 1      1.5
3 2 0      2.0


问:
Showing a single value from api call TextBlock (MVVM)
I have been stuck on this for a few hours now. I am using the IGDB api for the application I'm building. So, I'm trying to get the ListBox I have to show the Game Title, cover and Developer. I've managed to get all of them to show up in the list with no issues but the main issue comes in when I just want to show a single developer within the list, the list is showing all companies involved plus the developer because the API returns an array of Involved Companies and within those Involved Companies the developer body returns a Boolean value to say which one is the developer. I can see it in my head, if developer is true then show the developer and remove the other involved companies. Here is an image of what is showing up when I run my query:

Query Image

I have outlined it in red. From that list all I would need is Bungie since they're the developers. So in my view I have a ListBox and a ListView nested within it:

BrowseGamesView

```<code><ListBox ItemsSource="{Binding Games}"
             Width="390"
             Height="500"
             Grid.Row="4">
        <ListBox.ItemTemplate>
            <DataTemplate>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <Border Grid.Column="0"
                            Grid.Row="0"
                            Grid.RowSpan="2"
                            Margin="0 0 10 0">
                        <Image Source="{Binding cover.image_id, Converter={StaticResource stringToImage}}"
                               Stretch="Fill"
                               Height="70"
                               Width="60"/>
                    </Border>
                    <TextBlock Text="{Binding name}"
                               FontWeight="Bold"
                               Grid.Column="1"
                               Grid.Row="0"/>
                    <ListView Grid.Column="1"
                              Grid.Row="1"
                              ItemsSource="{Binding involved_companies}">
                        <ListView.ItemTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding company.name}"/>
                            </DataTemplate>
                        </ListView.ItemTemplate>
                    </ListView>
                </Grid>
            </DataTemplate>
        </ListBox.ItemTemplate>
    </ListBox>
</code>```

Within my ViewModel I have a method for making the query and also holds the ObservableCollection (Games).

BrowseGamesViewModel

```<code>public ObservableCollection<Game> Games { get; set; }

public async void MakeQuery()
        {
            var games = await IGDBHelper.GetGames(Query);

            Games.Clear();
            foreach(var game in games)
            {
                Games.Add(game);
            }
        }
</code>```

In my Helper class I get the games

IGDBHelper

```<code>public static async Task<List<Game>> GetGames(string query)
        {
            List<Game> games = new List<Game>();

            string myJson = "search \"{0}\"; fields name, cover.url, cover.image_id, involved_companies.developer, involved_companies.company.name; limit 500;";

            using (HttpClient client = new HttpClient())
            {
                client.DefaultRequestHeaders.Add("user-key", "key hidden");

                var response = await client.PostAsync(BASE_URL_GAMES, new StringContent(string.Format(myJson, query), Encoding.UTF8, "application/json"));

                var responseString = await response.Content.ReadAsStringAsync();

                games = JsonConvert.DeserializeObject<List<Game>>(responseString);
            }

            return games;
        }
</code>```

And all of models are concrete classes for the Json

```<code>public class Game
    {
        public int id { get; set; }
        public Cover cover { get; set; }
        public List<InvolvedCompany> involved_companies { get; set; }
        public string name { get; set; }
    }

public class InvolvedCompany
    {
        public int id { get; set; }
        public Company company { get; set; }
        public bool developer { get; set; }
    }

public class Company
    {
        public int id { get; set; }
        public string name { get; set; }
    }

public class Cover
{
    public int id { get; set; }
    public string image_id { get; set; }
    public string url { get; set; }
}
</code>```

So, to reiterate, I need to somehow just show the developers name by removing the rest of the involved companies from the list. I have tried several things from converters to trying it in the converter class and each time I get exceptions for null.

答:
I would add a new readonly property to the Game class:

```<code>public List<InvolvedCompany> DeveloperCompanies
{
    get
    {
        return involved_companies.Where(c => c.developer == true).ToList();
    }
}
</code>```

And then you can bind this new property to your ListView:

```<code><ListView Grid.Column="1"
          Grid.Row="1"
          ItemsSource="{Binding DeveloperCompanies}">
    <ListView.ItemTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding company.name}"/>
        </DataTemplate>
    </ListView.ItemTemplate>
</ListView>
</code>```

This way you would be showing only the developer companies but you would keep the information about all the involved companies as well, if you need to use them for another purpose.

I also suggest you to use PascalCase for the public members of a class. So, for example involved_companies would become InvolvedCompanies.

Body:
I have been stuck on this for a few hours now. I am using the IGDB api for the application I'm building. So, I'm trying to get the ListBox I have to show the Game Title, cover and Developer. I've managed to get all of them to show up in the list with no issues but the main issue comes in when I just want to show a single developer within the list, the list is showing all companies involved plus the developer because the API returns an array of Involved Companies and within those Involved Companies the developer body returns a Boolean value to say which one is the developer. I can see it in my head, if developer is true then show the developer and remove the other involved companies. Here is an image of what is showing up when I run my query:

Query Image

I have outlined it in red. From that list all I would need is Bungie since they're the developers. So in my view I have a ListBox and a ListView nested within it:

BrowseGamesView

<ListBox ItemsSource="{Binding Games}"
             Width="390"
             Height="500"
             Grid.Row="4">
        <ListBox.ItemTemplate>
            <DataTemplate>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <Border Grid.Column="0"
                            Grid.Row="0"
                            Grid.RowSpan="2"
                            Margin="0 0 10 0">
                        <Image Source="{Binding cover.image_id, Converter={StaticResource stringToImage}}"
                               Stretch="Fill"
                               Height="70"
                               Width="60"/>
                    </Border>
                    <TextBlock Text="{Binding name}"
                               FontWeight="Bold"
                               Grid.Column="1"
                               Grid.Row="0"/>
                    <ListView Grid.Column="1"
                              Grid.Row="1"
                              ItemsSource="{Binding involved_companies}">
                        <ListView.ItemTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding company.name}"/>
                            </DataTemplate>
                        </ListView.ItemTemplate>
                    </ListView>
                </Grid>
            </DataTemplate>
        </ListBox.ItemTemplate>
    </ListBox>

Within my ViewModel I have a method for making the query and also holds the ObservableCollection (Games).

BrowseGamesViewModel

public ObservableCollection<Game> Games { get; set; }

public async void MakeQuery()
        {
            var games = await IGDBHelper.GetGames(Query);

            Games.Clear();
            foreach(var game in games)
            {
                Games.Add(game);
            }
        }

In my Helper class I get the games

IGDBHelper

public static async Task<List<Game>> GetGames(string query)
        {
            List<Game> games = new List<Game>();

            string myJson = "search \"{0}\"; fields name, cover.url, cover.image_id, involved_companies.developer, involved_companies.company.name; limit 500;";

            using (HttpClient client = new HttpClient())
            {
                client.DefaultRequestHeaders.Add("user-key", "key hidden");

                var response = await client.PostAsync(BASE_URL_GAMES, new StringContent(string.Format(myJson, query), Encoding.UTF8, "application/json"));

                var responseString = await response.Content.ReadAsStringAsync();

                games = JsonConvert.DeserializeObject<List<Game>>(responseString);
            }

            return games;
        }

And all of models are concrete classes for the Json

public class Game
    {
        public int id { get; set; }
        public Cover cover { get; set; }
        public List<InvolvedCompany> involved_companies { get; set; }
        public string name { get; set; }
    }

public class InvolvedCompany
    {
        public int id { get; set; }
        public Company company { get; set; }
        public bool developer { get; set; }
    }

public class Company
    {
        public int id { get; set; }
        public string name { get; set; }
    }

public class Cover
{
    public int id { get; set; }
    public string image_id { get; set; }
    public string url { get; set; }
}

So, to reiterate, I need to somehow just show the developers name by removing the rest of the involved companies from the list. I have tried several things from converters to trying it in the converter class and each time I get exceptions for null.

Body:
I would add a new readonly property to the Game class:

public List<InvolvedCompany> DeveloperCompanies
{
    get
    {
        return involved_companies.Where(c => c.developer == true).ToList();
    }
}

And then you can bind this new property to your ListView:

<ListView Grid.Column="1"
          Grid.Row="1"
          ItemsSource="{Binding DeveloperCompanies}">
    <ListView.ItemTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding company.name}"/>
        </DataTemplate>
    </ListView.ItemTemplate>
</ListView>

This way you would be showing only the developer companies but you would keep the information about all the involved companies as well, if you need to use them for another purpose.

I also suggest you to use PascalCase for the public members of a class. So, for example involved_companies would become InvolvedCompanies.


问:
Remove of ADD in Dockerfile
I created a Dockerfile and use the ADD command to download an installer and execute it so I can prepare my docker container. But I can't find a delete counterpart. Am I missing something?

```<code># Dockerfile
ADD https://../file.zip file.exe
.. do something with file.exe
Delete file.exe
</code>```

答:
Use RUN instead.

```<code>RUN rm file.exe
</code>```

Title: Remove of ADD in Dockerfile

Body:
I created a Dockerfile and use the ADD command to download an installer and execute it so I can prepare my docker container. But I can't find a delete counterpart. Am I missing something?

# Dockerfile
ADD https://../file.zip file.exe
.. do something with file.exe
Delete file.exe

Body:
Use RUN instead.

RUN rm file.exe


问:
Go to particular revision
I cloned a git repository of a certain project. Can I turn the files to the initial state and when I review the files go to revision 2, 3, 4 ... most recent? I'd like to have an overview of how the project was evolving.</p>

答:
To get to a specific committed code, you need the hash code of that commit. You can get that hash code in two ways:

Get it from your github/gitlab/bitbucket account.
(It's on your commit url, i.e: github.com/user/my_project/commit/commit_hash_code), or you can

git log and check your recent commits on that branch. It will show you the hash code of your commit and the message you leaved while you were committing your code. Just copy and then do git checkout commit_hash_code

After moving to that code, if you want to work on it and make changes, you should make another branch with git checkout -b <new-branch-name>, otherwise, the changes will not be retained.

Title: Go to particular revision


问:
Server.UrlEncode vs. HttpUtility.UrlEncode
Is there a difference between Server.UrlEncode and HttpUtility.UrlEncode?</p>

答: HttpServerUtility.UrlEncode will use HttpUtility.UrlEncode internally. There is no specific difference. The reason for existence of Server.UrlEncode is compatibility with classic ASP.

OwnerDisplayName: Manu

ContentLicense: CC BY-SA 2.5

OwnerDisplayName: Mehrdad Afshari


问:
check username with bvalidator
Why the return value of my function always false

this is my function:

```<code>function checkUsername(username) {
    var ret=false;
    $.ajax({
        type: "POST",
        url: "user_validate.php",
        async: true,
        data: "username="+username,
        success: function(data){
            if(data == 0){
                ret = true;
            }else{
               ret = false;
            }
        },
        error:function() {
            alert("ERROR");
        }
    });
    return ret;
}
</code>```

Is var ret doesn't set the value?
Anything wrong with it..?
thanks before..!

答:
Because the AJAX call is asynchronpous, so you return the value of ret before it's assigned.

Use a callback method to handle the result:

```<code>function checkUsername(username, callback) {
  var ret=false;
  $.ajax({
    type: "POST",
    url: "user_validate.php",
    async: true,
    data: "username="+username,
    success: function(data){
      callback(data == 0);
    },
    error:function() {
      alert("ERROR");
    }
  });
}
</code>```

Usage:

```<code>checkUsername(username, function(success){
  if (success) {
    alert('User name is valid.');
  } else {
    alert('User name is not valid.');
  }
});
</code>```

Title: check username with bvalidator

Body:
Why the return value of my function always false

this is my function:

function checkUsername(username) {
    var ret=false;
    $.ajax({
        type: "POST",
        url: "user_validate.php",
        async: true,
        data: "username="+username,
        success: function(data){
            if(data == 0){
                ret = true;
            }else{
               ret = false;
            }
        },
        error:function() {
            alert("ERROR");
        }
    });
    return ret;
}

Is var ret doesn't set the value?
Anything wrong with it..?
thanks before..!

Body:
Because the AJAX call is asynchronpous, so you return the value of ret before it's assigned.

Use a callback method to handle the result:

function checkUsername(username, callback) {
  var ret=false;
  $.ajax({
    type: "POST",
    url: "user_validate.php",
    async: true,
    data: "username="+username,
    success: function(data){
      callback(data == 0);
    },
    error:function() {
      alert("ERROR");
    }
  });
}

Usage:

checkUsername(username, function(success){
  if (success) {
    alert('User name is valid.');
  } else {
    alert('User name is not valid.');
  }
});


问:
Presto 313 password-authenticator. properties doesn't work with file
I'm running presto in K8s and I'm trying to enable file based authentication for the service (using this as a guide https://prestosql.io/docs/current/security/password-file.html). However, as the application is starting up  I get an error saying:

java.lang.IllegalStateException: Password authenticator file is not registered

config.properties

```<code>coordinator=true
node-scheduler.include-coordinator=false
http-server.http.port=8080
query.max-memory=20GB
query.max-memory-per-node=10GB
query.max-total-memory-per-node=10GB
discovery-server.enabled=true
discovery.uri=http://presto-service.eap.svc.cluster.local:8080
http-server.authentication.type=PASSWORD
http-server.https.enabled=true
http-server.https.port=8443
http-server.https.keystore.path=/opt/presto-server/etc/presto.jks
http-server.https.keystore.key=*************
</code>```

password-authenticator.properties

```<code>password-authenticator.name=file
file.password-file=/opt/presto-server/etc/password.db
</code>```

The rest of the config looks perfectly sane so does anybody know what I might have missed here?
Thanks,

答:
Password file authentication was added in version 327, so you need to upgrade it.

Security Changes

  Add Password File Authentication. (#797)

You can get the latest version from https://prestosql.io/download.html.

Also, you can join the community Slack. https://prestosql.io/slack.html

Body:
I'm running presto in K8s and I'm trying to enable file based authentication for the service (using this as a guide https://prestosql.io/docs/current/security/password-file.html). However, as the application is starting up  I get an error saying:

java.lang.IllegalStateException: Password authenticator file is not registered

config.properties

coordinator=true
node-scheduler.include-coordinator=false
http-server.http.port=8080
query.max-memory=20GB
query.max-memory-per-node=10GB
query.max-total-memory-per-node=10GB
discovery-server.enabled=true
discovery.uri=http://presto-service.eap.svc.cluster.local:8080
http-server.authentication.type=PASSWORD
http-server.https.enabled=true
http-server.https.port=8443
http-server.https.keystore.path=/opt/presto-server/etc/presto.jks
http-server.https.keystore.key=*************

password-authenticator.properties

password-authenticator.name=file
file.password-file=/opt/presto-server/etc/password.db

The rest of the config looks perfectly sane so does anybody know what I might have missed here?
Thanks,


问:
Unable to import sumCashBy in Corda v4.3 branch [Kotlin]
Question is pretty self explanatory. I've tried the suggestions provided here and also here

To summarise, added :

```<code> cordaCompile "$corda_release_group:corda-finance-contracts:$corda_release_version"
</code>```

To build.gradle and attempted to add the following import.

```<code>import net.corda.finance.contracts.utils
</code>```

It is unable to import it. Is there another helper to do the following:

```<code> val received = tx.outputs.map { it.data }.sumCashBy(input.owner)
</code>```

答:
Try importing like this</p>

```<code>import net.corda.finance.contracts.utils.sumCashBy
</code>```

Body:
Question is pretty self explanatory. I've tried the suggestions provided here and also here

To summarise, added :

 cordaCompile "$corda_release_group:corda-finance-contracts:$corda_release_version"

To build.gradle and attempted to add the following import.

import net.corda.finance.contracts.utils

It is unable to import it. Is there another helper to do the following:

 val received = tx.outputs.map { it.data }.sumCashBy(input.owner)

Body:
Try importing like this

import net.corda.finance.contracts.utils.sumCashBy


问:
socket exception while running SonarQube
I am getting this error when I run npm run sonar for analyzing my nodejs code.

```<code>ERROR: Failed to get response while analyzing file:///newvolume/MTP/staging/mt_cloudplatform/backend/src/app/controllers/mockTestBookmarkController.js
java.io.InterruptedIOException: timeout
        at okhttp3.RealCall.timeoutExit(RealCall.java:108)
        at okhttp3.RealCall.execute(RealCall.java:97)
        at org.sonar.plugins.javascript.eslint.EslintBridgeServerImpl.call(EslintBridgeServerImpl.java:159)
        at org.sonar.plugins.javascript.eslint.EslintBasedRulesSensor.analyze(EslintBasedRulesSensor.java:124)
        at org.sonar.plugins.javascript.eslint.EslintBasedRulesSensor.execute(EslintBasedRulesSensor.java:100)
        at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:48)
        at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:85)
        at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:59)
        at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:77)
        at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:59)
        at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:82)
        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
        at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
        at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:400)
        at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:395)
        at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:358)
        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
        at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
        at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:141)
        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
        at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
        at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:73)
        at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
        at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.base/java.lang.reflect.Method.invoke(Unknown Source)
        at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
        at com.sun.proxy.$Proxy0.execute(Unknown Source)
        at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:185)
        at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:137)
        at org.sonarsource.scanner.cli.Main.execute(Main.java:112)
        at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
        at org.sonarsource.scanner.cli.Main.main(Main.java:61)
Caused by: java.net.SocketTimeoutException: Read timed out
        at java.base/java.net.SocketInputStream.socketRead0(Native Method)
        at java.base/java.net.SocketInputStream.socketRead(Unknown Source)
        at java.base/java.net.SocketInputStream.read(Unknown Source)
        at java.base/java.net.SocketInputStream.read(Unknown Source)
        at okio.Okio$2.read(Okio.java:140)
        at okio.AsyncTimeout$2.read(AsyncTimeout.java:237)
        at okio.RealBufferedSource.indexOf(RealBufferedSource.java:358)
        at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:230)
        at okhttp3.internal.http1.Http1Codec.readHeaderLine(Http1Codec.java:226)
        at okhttp3.internal.http1.Http1Codec.readResponseHeaders(Http1Codec.java:202)
        at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:101)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
        at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:45)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
        at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:94)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
        at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
        at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:125)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
        at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:264)
        at okhttp3.RealCall.execute(RealCall.java:93)
        ... 33 common frames omitted
</code>```

It was working fine earlier but now I am getting this error. What could be the issue?
I used this tutorial for setting up sonarqube,
https://arjunphp.com/how-to-integrate-sonar-for-a-node-js-project/

答:
I found that increasing available memory for Scanner may help, on GitHub issue page. It was sufficient in my case. Add this line with extended memory limit to your sonar-scanner.properties file

```<code>sonar.javascript.node.maxspace=4096
</code>```

As typescripts dependencies are blamed as part of the reason for the timeout you may try uninstall some dependencies before scanning.
Link to original issue

Body:
I am getting this error when I run npm run sonar for analyzing my nodejs code.

ERROR: Failed to get response while analyzing file:///newvolume/MTP/staging/mt_cloudplatform/backend/src/app/controllers/mockTestBookmarkController.js
java.io.InterruptedIOException: timeout
        at okhttp3.RealCall.timeoutExit(RealCall.java:108)
        at okhttp3.RealCall.execute(RealCall.java:97)
        at org.sonar.plugins.javascript.eslint.EslintBridgeServerImpl.call(EslintBridgeServerImpl.java:159)
        at org.sonar.plugins.javascript.eslint.EslintBasedRulesSensor.analyze(EslintBasedRulesSensor.java:124)
        at org.sonar.plugins.javascript.eslint.EslintBasedRulesSensor.execute(EslintBasedRulesSensor.java:100)
        at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:48)
        at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:85)
        at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:59)
        at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:77)
        at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:59)
        at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:82)
        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
        at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
        at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:400)
        at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:395)
        at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:358)
        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
        at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
        at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:141)
        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
        at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
        at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:73)
        at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
        at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.base/java.lang.reflect.Method.invoke(Unknown Source)
        at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
        at com.sun.proxy.$Proxy0.execute(Unknown Source)
        at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:185)
        at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:137)
        at org.sonarsource.scanner.cli.Main.execute(Main.java:112)
        at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
        at org.sonarsource.scanner.cli.Main.main(Main.java:61)
Caused by: java.net.SocketTimeoutException: Read timed out
        at java.base/java.net.SocketInputStream.socketRead0(Native Method)
        at java.base/java.net.SocketInputStream.socketRead(Unknown Source)
        at java.base/java.net.SocketInputStream.read(Unknown Source)
        at java.base/java.net.SocketInputStream.read(Unknown Source)
        at okio.Okio$2.read(Okio.java:140)
        at okio.AsyncTimeout$2.read(AsyncTimeout.java:237)
        at okio.RealBufferedSource.indexOf(RealBufferedSource.java:358)
        at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:230)
        at okhttp3.internal.http1.Http1Codec.readHeaderLine(Http1Codec.java:226)
        at okhttp3.internal.http1.Http1Codec.readResponseHeaders(Http1Codec.java:202)
        at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:101)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
        at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:45)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
        at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:94)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
        at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
        at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:125)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
        at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:264)
        at okhttp3.RealCall.execute(RealCall.java:93)
        ... 33 common frames omitted

It was working fine earlier but now I am getting this error. What could be the issue?
I used this tutorial for setting up sonarqube,
https://arjunphp.com/how-to-integrate-sonar-for-a-node-js-project/

Body:
I found that increasing available memory for Scanner may help, on GitHub issue page. It was sufficient in my case. Add this line with extended memory limit to your sonar-scanner.properties file

sonar.javascript.node.maxspace=4096

As typescripts dependencies are blamed as part of the reason for the timeout you may try uninstall some dependencies before scanning.
Link to original issue


问:
Is there a way to create Numberic Textboxes using WPF xaml code?
I am new to WPF. I need to create textboxes which is only accept digits. Not accepted any special characters, letters .

And the important thing is , the code is only xaml not c#.

I googled lot of websites , but i only get the code used c#. But i want in XAML code. Because i enclosed it like styles in controls.

Is there any way to do this? And if it is not possible Why?

答:
No, it's not possible because XAML is a markup language. It has no support for distinguishing between digits and other type of characters.

You should use a programming language such as C# to implement this kind of logic.