问:
Android 12 (API level 31) can't start ExoPlayer from the service
Hello folks,

I have an application that runs audio streaming via ExoPlayer, which will not run on the Android 12 platform.
My application details:

ExoPlayer runs in PlayerService.java:

```<code>public void startMyAudio () {
    Notification notification = new NotificationCompat.Builder (this, getPackageName ())
    ...
    startForeground (9573, notification);
    player.prepare ();
    player.play ();
}
</code>```

I run PlayerService.java from MainActivity.java, using the code:

```<code>private final ServiceConnection playerService_connection = new ServiceConnection () {
    @Override
    public void onServiceConnected (ComponentName classname, IBinder service) {
        playerService = IPlayerService.Stub.asInterface (service);
    }
    @Override public void onServiceDisconnected (ComponentName name) {playerService = null; }
};

@Override
protected void onCreate(Bundle savedInstanceState) {
    ...
    bindService(new Intent(this, PlayerService.class), playerService_connection, Context.BIND_AUTO_CREATE);
    ...
}
</code>```

And, of course, control the service with AIDL interface:

```<code>playerService.startMyAudio();
</code>```

Manifest permissions are:

```<code><uses-permission android:name = "android.permission.INTERNET" />
<uses-permission android:name = "android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name = "android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name = "android.permission.WAKE_LOCK" />
<uses-permission android:name = "android.permission.FOREGROUND_SERVICE" />
...
<service
    android:name=".PlayerService"
    android:enabled="true"
    android:exported="true"
    android:foregroundServiceType="mediaPlayback|dataSync"
    android:permission="android.permission.INTERNET" />
</code>```

I have no idea what to do next, because this works up to Android 12.
What do I need to enable this app to run on Android 12?
Was it enough to add Manifest permission as:

```<code><uses-permission android:name = "android.permission.START_FOREGROUND_SERVICES_FROM_BACKGROUND" />
</code>```

I ask this because I do not have the ability to run a virtual device on Android 12, nor an actual device on Android 12.

Thank you in advance.

答:
People,

I found a solution. You should first pin the notification when starting the service, and then anything is possible.
I do it like this. First, I bind the service when I need it:

```<code>bindService(new Intent(this, PlayerService.class), playerService_connection, Context.BIND_AUTO_CREATE);
</code>```

Else, everything is the same as above, except:

In MainActivity.java in ServiceConnection, I added only one line. Code below:

```<code>private final ServiceConnection playerService_connection = new ServiceConnection () {
    @Override
    public void onServiceConnected (ComponentName classname, IBinder service) {
        playerService = IPlayerService.Stub.asInterface (service);
        // This line below has been added
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { startForegroundService(new Intent(THIS, PlayerService.class)); }
    }
    @Override public void onServiceDisconnected (ComponentName name) { playerService = null; }
};
</code>```

Too, in PlayerService.java be sure to call this:

```<code>@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    setMyNotification("Stand by."); // Your code instead
    return START_STICKY;
}
</code>```

Now the foreground service is established, and I communicate with it via an interface. In this case, it is AIDL, although I prefer external ones that I personally create because that way I have more options at my disposal.

I came to this solution thanks to friends who helped with debugging online. Now I'm going to throw in the problem of installing AVD for Android 12 on my weird AMD processor.

Greeting.

Body:
Hello folks,

I have an application that runs audio streaming via ExoPlayer, which will not run on the Android 12 platform.
My application details:

ExoPlayer runs in PlayerService.java:

public void startMyAudio () {
    Notification notification = new NotificationCompat.Builder (this, getPackageName ())
    ...
    startForeground (9573, notification);
    player.prepare ();
    player.play ();
}

I run PlayerService.java from MainActivity.java, using the code:

private final ServiceConnection playerService_connection = new ServiceConnection () {
    @Override
    public void onServiceConnected (ComponentName classname, IBinder service) {
        playerService = IPlayerService.Stub.asInterface (service);
    }
    @Override public void onServiceDisconnected (ComponentName name) {playerService = null; }
};

@Override
protected void onCreate(Bundle savedInstanceState) {
    ...
    bindService(new Intent(this, PlayerService.class), playerService_connection, Context.BIND_AUTO_CREATE);
    ...
}

And, of course, control the service with AIDL interface:

playerService.startMyAudio();

Manifest permissions are:

<uses-permission android:name = "android.permission.INTERNET" />
<uses-permission android:name = "android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name = "android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name = "android.permission.WAKE_LOCK" />
<uses-permission android:name = "android.permission.FOREGROUND_SERVICE" />
...
<service
    android:name=".PlayerService"
    android:enabled="true"
    android:exported="true"
    android:foregroundServiceType="mediaPlayback|dataSync"
    android:permission="android.permission.INTERNET" />

I have no idea what to do next, because this works up to Android 12.
What do I need to enable this app to run on Android 12?
Was it enough to add Manifest permission as:

<uses-permission android:name = "android.permission.START_FOREGROUND_SERVICES_FROM_BACKGROUND" />

I ask this because I do not have the ability to run a virtual device on Android 12, nor an actual device on Android 12.

Thank you in advance.

Body:
People,

I found a solution. You should first pin the notification when starting the service, and then anything is possible.
I do it like this. First, I bind the service when I need it:

bindService(new Intent(this, PlayerService.class), playerService_connection, Context.BIND_AUTO_CREATE);

Else, everything is the same as above, except:

In MainActivity.java in ServiceConnection, I added only one line. Code below:

private final ServiceConnection playerService_connection = new ServiceConnection () {
    @Override
    public void onServiceConnected (ComponentName classname, IBinder service) {
        playerService = IPlayerService.Stub.asInterface (service);
        // This line below has been added
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { startForegroundService(new Intent(THIS, PlayerService.class)); }
    }
    @Override public void onServiceDisconnected (ComponentName name) { playerService = null; }
};

Too, in PlayerService.java be sure to call this:

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    setMyNotification("Stand by."); // Your code instead
    return START_STICKY;
}

Now the foreground service is established, and I communicate with it via an interface. In this case, it is AIDL, although I prefer external ones that I personally create because that way I have more options at my disposal.

I came to this solution thanks to friends who helped with debugging online. Now I'm going to throw in the problem of installing AVD for Android 12 on my weird AMD processor.

Greeting.


来源: stackexchange

问:
How to read a string with custom terminator as a pandas dataframe?
I was trying to read a text into a pandas DataFrame, but instead of 4 columns I got a lot of columns.

How to read the following text as pandas DataFrame?

```<code>txt="""2020-09-12, Budget, GD-0032-DD-XP, Ford,\\n 2020-04-22, Avis, D143123, Toyota,\\n 2020-04-03, Herz, 331029411, Jeep,\\n 2020-10-31, HERZ, , Hyundai,\\n 2020-09-10, Budget, Gd-1932-Ee-Rm, Chevrolet,\\n 2020-12-01, National, 9890001, Ford,\\n 2020-05-13, Alamo, W***, Hyundai,\\n 2020-01-21, Enterprise, GD-8888-TL-MP, Jeep,\\n"""
</code>```

My attempt:

txt="""2020-09-12, Budget, GD-0032-DD-XP, Ford,\n 2020-04-22, Avis, D143123, Toyota,\n 2020-04-03, Herz, 331029411, Jeep,\n 2020-10-31, HERZ, , Hyundai,\n 2020-09-10, Budget, Gd-1932-Ee-Rm, Chevrolet,\n 2020-12-01, National, 9890001, Ford,\n 2020-05-13, Alamo, W***, Hyundai,\n 2020-01-21, Enterprise, GD-8888-TL-MP, Jeep,\n"""

# input file with only ONE row
with open('input000.txt','w') as fo:
    txt = txt.replace('\n','\\n')
    fo.write(txt)

# read the data file
import io
import pandas as pd
df = pd.read_csv('input000.txt', lineterminator='\n')
df
```
<p>My output</p>
```2020-09-12  Budget  GD-0032-DD-XP   Ford    \n 2020-04-22   Avis    D143123 Toyota  \n 2020-04-03   Herz    ... Ford.1  \n 2020-05-13   Alamo   W***    Hyundai.1   \n 2020-01-21   Enterprise  GD-8888-TL-MP   Jeep.1  \n
0 rows × 33 columns
```
<p>Required output</p>
```    0           1       2               3
0   2020-09-12  Budget  GD-0032-DD-XP   Ford
1   2020-04-22  Avis    D143123 Toyota
2   2020-04-03  Herz    331029411   Jeep
3   2020-10-31  HERZ        Hyundai
4   2020-09-10  Budget  Gd-1932-Ee-Rm   Chevrolet
5   2020-12-01  National    9890001 Ford
6   2020-05-13  Alamo   W***    Hyundai
7   2020-01-21  Enterprise  GD-8888-TL-MP   Jeep
```

答:
You have to pass in the separator as well using sep parameter. Since the last element in each row also has a comma, this will result in a NaN column, so you can drop that one using drop:

```<code>df = pd.read_csv(io.StringIO(txt), lineterminator='\n', sep=',').drop(columns='Unnamed: 4')
</code>```

On a text file, \n seems to be converted to \\n and since c-engine of read_csv doesn't support \\n as a separator, perhaps it's better if we open it as a text file and build the DataFrame:

```<code>with open("input000.txt") as file:
    df = pd.DataFrame([line.split(',') for line in file.read().split('\\n')])
</code>```

Output:

```<code>    2020-09-12       Budget   GD-0032-DD-XP        Ford
0   2020-04-22         Avis         D143123      Toyota
1   2020-04-03         Herz       331029411        Jeep
2   2020-10-31         HERZ                     Hyundai
3   2020-09-10       Budget   Gd-1932-Ee-Rm   Chevrolet
4   2020-12-01     National         9890001        Ford
5   2020-05-13        Alamo            W***     Hyundai
6   2020-01-21   Enterprise   GD-8888-TL-MP        Jeep
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I was trying to read a text into a pandas DataFrame, but instead of 4 columns I got a lot of columns.

How to read the following text as pandas DataFrame?

txt="""2020-09-12, Budget, GD-0032-DD-XP, Ford,\\n 2020-04-22, Avis, D143123, Toyota,\\n 2020-04-03, Herz, 331029411, Jeep,\\n 2020-10-31, HERZ, , Hyundai,\\n 2020-09-10, Budget, Gd-1932-Ee-Rm, Chevrolet,\\n 2020-12-01, National, 9890001, Ford,\\n 2020-05-13, Alamo, W***, Hyundai,\\n 2020-01-21, Enterprise, GD-8888-TL-MP, Jeep,\\n"""

My attempt:

txt="""2020-09-12, Budget, GD-0032-DD-XP, Ford,\n 2020-04-22, Avis, D143123, Toyota,\n 2020-04-03, Herz, 331029411, Jeep,\n 2020-10-31, HERZ, , Hyundai,\n 2020-09-10, Budget, Gd-1932-Ee-Rm, Chevrolet,\n 2020-12-01, National, 9890001, Ford,\n 2020-05-13, Alamo, W***, Hyundai,\n 2020-01-21, Enterprise, GD-8888-TL-MP, Jeep,\n"""

# input file with only ONE row
with open('input000.txt','w') as fo:
    txt = txt.replace('\n','\\n')
    fo.write(txt)

# read the data file
import io
import pandas as pd
df = pd.read_csv('input000.txt', lineterminator='\n')
df

My output

2020-09-12  Budget  GD-0032-DD-XP   Ford    \n 2020-04-22   Avis    D143123 Toyota  \n 2020-04-03   Herz    ... Ford.1  \n 2020-05-13   Alamo   W***    Hyundai.1   \n 2020-01-21   Enterprise  GD-8888-TL-MP   Jeep.1  \n
0 rows × 33 columns

Required output

    0           1       2               3
0   2020-09-12  Budget  GD-0032-DD-XP   Ford
1   2020-04-22  Avis    D143123 Toyota
2   2020-04-03  Herz    331029411   Jeep
3   2020-10-31  HERZ        Hyundai
4   2020-09-10  Budget  Gd-1932-Ee-Rm   Chevrolet
5   2020-12-01  National    9890001 Ford
6   2020-05-13  Alamo   W***    Hyundai
7   2020-01-21  Enterprise  GD-8888-TL-MP   Jeep

Body:
You have to pass in the separator as well using sep parameter. Since the last element in each row also has a comma, this will result in a NaN column, so you can drop that one using drop:

df = pd.read_csv(io.StringIO(txt), lineterminator='\n', sep=',').drop(columns='Unnamed: 4')

On a text file, \n seems to be converted to \\n and since c-engine of read_csv doesn't support \\n as a separator, perhaps it's better if we open it as a text file and build the DataFrame:

with open("input000.txt") as file:
    df = pd.DataFrame([line.split(',') for line in file.read().split('\\n')])

Output:

    2020-09-12       Budget   GD-0032-DD-XP        Ford
0   2020-04-22         Avis         D143123      Toyota
1   2020-04-03         Herz       331029411        Jeep
2   2020-10-31         HERZ                     Hyundai
3   2020-09-10       Budget   Gd-1932-Ee-Rm   Chevrolet
4   2020-12-01     National         9890001        Ford
5   2020-05-13        Alamo            W***     Hyundai
6   2020-01-21   Enterprise   GD-8888-TL-MP        Jeep


问:
How to stack circles in flutter

I would like to stack circles exactly like in the picture, I tried to do it with Stack widget but doesn't seems to work.

Is it the right widget to use ? If yes how do I properly set it, and if not what widget should I use ?

Thanks for your help.

答:
It is correct: you need to use a stack; I add an easy example:

Example

```<code>SizedBox(
      width: 400,
      height: 400,
      child: Stack(
        children: [
          Positioned(
            top: 0,
            child: ClipRRect(
              borderRadius: BorderRadius.circular(100),
              child: Image.network(
                'https://images.unsplash.com/photo-1529665253569-6d01c0eaf7b6?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxzZWFyY2h8Mnx8cHJvZmlsZXxlbnwwfHwwfHw%3D&w=1000&q=80',
                width: 100,
                height: 100,
                fit: BoxFit.cover,
              ),
            ),
          ),
          Positioned(
            left: 75,
            child: ClipRRect(
              borderRadius: BorderRadius.circular(100),
              child: Image.network(
                'https://media.istockphoto.com/photos/side-view-of-one-young-woman-picture-id1134378235?k=20&m=1134378235&s=612x612&w=0&h=0yIqc847atslcQvC3sdYE6bRByfjNTfOkyJc5e34kgU=',
                width: 100,
                height: 100,
                fit: BoxFit.cover,
              ),
            ),
          ),
          Positioned(
            left: 150,
            child: ClipRRect(
              borderRadius: BorderRadius.circular(100),
              child: Image.network(
                'https://images.unsplash.com/photo-1529665253569-6d01c0eaf7b6?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxzZWFyY2h8Mnx8cHJvZmlsZXxlbnwwfHwwfHw%3D&w=1000&q=80',
                width: 100,
                height: 100,
                fit: BoxFit.cover,
              ),
            ),
          ),
          Positioned(
            left: 225,
            child: ClipRRect(
              borderRadius: BorderRadius.circular(100),
              child: Image.network(
                'https://media.istockphoto.com/photos/side-view-of-one-young-woman-picture-id1134378235?k=20&m=1134378235&s=612x612&w=0&h=0yIqc847atslcQvC3sdYE6bRByfjNTfOkyJc5e34kgU=',
                width: 100,
                height: 100,
                fit: BoxFit.cover,
              ),
            ),
          )
        ],
      ),
    );

</code>```

Title: How to stack circles in flutter

Body:
It is correct: you need to use a stack; I add an easy example:

Example

SizedBox(
      width: 400,
      height: 400,
      child: Stack(
        children: [
          Positioned(
            top: 0,
            child: ClipRRect(
              borderRadius: BorderRadius.circular(100),
              child: Image.network(
                'https://images.unsplash.com/photo-1529665253569-6d01c0eaf7b6?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxzZWFyY2h8Mnx8cHJvZmlsZXxlbnwwfHwwfHw%3D&w=1000&q=80',
                width: 100,
                height: 100,
                fit: BoxFit.cover,
              ),
            ),
          ),
          Positioned(
            left: 75,
            child: ClipRRect(
              borderRadius: BorderRadius.circular(100),
              child: Image.network(
                'https://media.istockphoto.com/photos/side-view-of-one-young-woman-picture-id1134378235?k=20&m=1134378235&s=612x612&w=0&h=0yIqc847atslcQvC3sdYE6bRByfjNTfOkyJc5e34kgU=',
                width: 100,
                height: 100,
                fit: BoxFit.cover,
              ),
            ),
          ),
          Positioned(
            left: 150,
            child: ClipRRect(
              borderRadius: BorderRadius.circular(100),
              child: Image.network(
                'https://images.unsplash.com/photo-1529665253569-6d01c0eaf7b6?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxzZWFyY2h8Mnx8cHJvZmlsZXxlbnwwfHwwfHw%3D&w=1000&q=80',
                width: 100,
                height: 100,
                fit: BoxFit.cover,
              ),
            ),
          ),
          Positioned(
            left: 225,
            child: ClipRRect(
              borderRadius: BorderRadius.circular(100),
              child: Image.network(
                'https://media.istockphoto.com/photos/side-view-of-one-young-woman-picture-id1134378235?k=20&m=1134378235&s=612x612&w=0&h=0yIqc847atslcQvC3sdYE6bRByfjNTfOkyJc5e34kgU=',
                width: 100,
                height: 100,
                fit: BoxFit.cover,
              ),
            ),
          )
        ],
      ),
    );


问:
Wordpress on Docker: Could not create directory on mounted volume
Here is are the original files in the Wordpress Docker container on path /var/www/html:

```<code>$ docker exec 5b957c7b9c5ad054883694afbfb80d3c9df6707458d55011f471be0701f3890c ls -l
total 192
-rw-r--r--  1 www-data www-data   418 Sep 25  2013 index.php
-rw-r--r--  1 www-data www-data 19935 Jan  2 18:51 license.txt
-rw-r--r--  1 www-data www-data  7433 Jan 11 17:46 readme.html
-rw-r--r--  1 www-data www-data  5447 Sep 27  2016 wp-activate.php
drwxr-xr-x  9 www-data www-data  4096 May 16 21:50 wp-admin
-rw-r--r--  1 www-data www-data   364 Dec 19  2015 wp-blog-header.php
-rw-r--r--  1 www-data www-data  1627 Aug 29  2016 wp-comments-post.php
-rw-r--r--  1 www-data www-data  2764 May 29 22:19 wp-config-sample.php
-rw-r--r--  1 www-data www-data  3148 May 29 22:19 wp-config.php
drwxr-xr-x  4 www-data www-data  4096 May 16 21:50 wp-content
-rw-r--r--  1 www-data www-data  3286 May 24  2015 wp-cron.php
drwxr-xr-x 18 www-data www-data 12288 May 16 21:50 wp-includes
-rw-r--r--  1 www-data www-data  2422 Nov 21  2016 wp-links-opml.php
-rw-r--r--  1 www-data www-data  3301 Oct 25  2016 wp-load.php
-rw-r--r--  1 www-data www-data 33939 Nov 21  2016 wp-login.php
-rw-r--r--  1 www-data www-data  8048 Jan 11 05:15 wp-mail.php
-rw-r--r--  1 www-data www-data 16255 Apr  6 18:23 wp-settings.php
-rw-r--r--  1 www-data www-data 29896 Oct 19  2016 wp-signup.php
-rw-r--r--  1 www-data www-data  4513 Oct 14  2016 wp-trackback.php
-rw-r--r--  1 www-data www-data  3065 Aug 31  2016 xmlrpc.php
</code>```

I am trying to start the Wordpress container with a mounted Docker volume to be able to store the custom files persistently:

```<code>$ sudo docker run -p 80:80 --link some-mysql:mysql  -v /var/www:/var/www/html --name docker-wordpress -d wordpress
</code>```

The problem is that even when exactly replicating the ownership and priviledges on local files in /var/www:

```<code>$ sudo chown -R www-data:www-data /var/www
$ sudo find /var/www/ -type d -exec chmod 755 {} \;
$ sudo find /var/www/ -type f -exec chmod 644 {} \;
</code>```

I am still getting an error of this kind, when running Wordpress inside the container:

Could not create directory

How to set the privileges properly to make sure Wordpress is able to write into the mounted Docker volume?

答:
Building up on Mathias Asberg answer, you can simply create 2 folder i.e plugins and uploads update the permission to 777 and mount the volumes

Steps:

mkdir plugins uploads

chmod -R 777 plugins uploads

update docker-compose.yaml to mount volume

```<code>  volumes: #
  - ./plugins:/var/www/html/wp-content/plugins
  - ./uploads:/var/www/html/wp-content/uploads
</code>```

ContentLicense: CC BY-SA 3.0

Body:
Here is are the original files in the Wordpress Docker container on path /var/www/html:

$ docker exec 5b957c7b9c5ad054883694afbfb80d3c9df6707458d55011f471be0701f3890c ls -l
total 192
-rw-r--r--  1 www-data www-data   418 Sep 25  2013 index.php
-rw-r--r--  1 www-data www-data 19935 Jan  2 18:51 license.txt
-rw-r--r--  1 www-data www-data  7433 Jan 11 17:46 readme.html
-rw-r--r--  1 www-data www-data  5447 Sep 27  2016 wp-activate.php
drwxr-xr-x  9 www-data www-data  4096 May 16 21:50 wp-admin
-rw-r--r--  1 www-data www-data   364 Dec 19  2015 wp-blog-header.php
-rw-r--r--  1 www-data www-data  1627 Aug 29  2016 wp-comments-post.php
-rw-r--r--  1 www-data www-data  2764 May 29 22:19 wp-config-sample.php
-rw-r--r--  1 www-data www-data  3148 May 29 22:19 wp-config.php
drwxr-xr-x  4 www-data www-data  4096 May 16 21:50 wp-content
-rw-r--r--  1 www-data www-data  3286 May 24  2015 wp-cron.php
drwxr-xr-x 18 www-data www-data 12288 May 16 21:50 wp-includes
-rw-r--r--  1 www-data www-data  2422 Nov 21  2016 wp-links-opml.php
-rw-r--r--  1 www-data www-data  3301 Oct 25  2016 wp-load.php
-rw-r--r--  1 www-data www-data 33939 Nov 21  2016 wp-login.php
-rw-r--r--  1 www-data www-data  8048 Jan 11 05:15 wp-mail.php
-rw-r--r--  1 www-data www-data 16255 Apr  6 18:23 wp-settings.php
-rw-r--r--  1 www-data www-data 29896 Oct 19  2016 wp-signup.php
-rw-r--r--  1 www-data www-data  4513 Oct 14  2016 wp-trackback.php
-rw-r--r--  1 www-data www-data  3065 Aug 31  2016 xmlrpc.php

I am trying to start the Wordpress container with a mounted Docker volume to be able to store the custom files persistently:

$ sudo docker run -p 80:80 --link some-mysql:mysql  -v /var/www:/var/www/html --name docker-wordpress -d wordpress

The problem is that even when exactly replicating the ownership and priviledges on local files in /var/www:

$ sudo chown -R www-data:www-data /var/www
$ sudo find /var/www/ -type d -exec chmod 755 {} \;
$ sudo find /var/www/ -type f -exec chmod 644 {} \;

I am still getting an error of this kind, when running Wordpress inside the container:

Could not create directory

How to set the privileges properly to make sure Wordpress is able to write into the mounted Docker volume?

Body:
Building up on Mathias Asberg answer, you can simply create 2 folder i.e plugins and uploads update the permission to 777 and mount the volumes

Steps:

mkdir plugins uploads

chmod -R 777 plugins uploads

update docker-compose.yaml to mount volume

  volumes: #
  - ./plugins:/var/www/html/wp-content/plugins
  - ./uploads:/var/www/html/wp-content/uploads


问:
Material.Angular.io mat-autocomplete [displayWith] function update scope variables
I'm running into an issue where I can access locally declared variables in the component controller instantiating the mat-autocomplete. The problem I'm facing is the local variables are stuck in this scope and I can't update them.

Any ideas or thoughts on updating the mat-autocomplete scope variables.

Ultimately what I'm doing is concatenating the display string and a variable bound to the input model. This is giving me an autocomplete input that adds helper text for the user, ideally the text is up to date with clearing the input. The text is currently continuously concatenating, creating unusable text pretty quickly

html

```<code>  <input
   [(ngModel)]="filter>

  mat-autocomplete
    #auto="matAutocomplete"
    [displayWith]="displayFn">
    <mat-option
      *ngFor="let option of filteredOptions | async"
      [value]="option">
      {{ option }}
    </mat-option>
  </mat-autocomplete>
</code>```

component.ts

```<code>  displayFn(search): string | undefined {
    if(!search) return; //check if the search isn't already populated
    if(!search.match(/(=|\*)/)){
      if(this.filter){
        this.filter += ' ' + search + '==*term*';
      }else{
        this.filter = search +'==*term*';

      }
      return this.filter; //this isn't persisting across the lifecycle
    }
  }
</code>```

答:
If I use an example, MyClass, where

@Input() modeCity = false;

in ngOnInit() I can access the modeCity and change it. It is reflected over other methods in the class.

in HTML,

<mat-autocomplete #auto="matAutocomplete" autoActiveFirstOption
[displayWith]="itemDisplayFn" (optionSelected)="selected($event)">

then for method itemDisplayFn(item: ..) in the ts file, the modeCity is undefined.

I found that somehow the method itemDisplayFn() has static context. Therefore I created the property,

static staticModeCity = false;

staticModeCity can be set in the ngOnInit() like so,

MyClass.staticModeCity = true

and used in the Method itemDisplayFn() like so,

if(MyClass.staticModeCity) ....

I do not know why this is. Of course static can be conflicting, if the same component is used multiple times in the same parent component.

Body:
I'm running into an issue where I can access locally declared variables in the component controller instantiating the mat-autocomplete. The problem I'm facing is the local variables are stuck in this scope and I can't update them.

Any ideas or thoughts on updating the mat-autocomplete scope variables.

Ultimately what I'm doing is concatenating the display string and a variable bound to the input model. This is giving me an autocomplete input that adds helper text for the user, ideally the text is up to date with clearing the input. The text is currently continuously concatenating, creating unusable text pretty quickly

html

  <input
   [(ngModel)]="filter>

  mat-autocomplete
    #auto="matAutocomplete"
    [displayWith]="displayFn">
    <mat-option
      *ngFor="let option of filteredOptions | async"
      [value]="option">
      {{ option }}
    </mat-option>
  </mat-autocomplete>

component.ts

  displayFn(search): string | undefined {
    if(!search) return; //check if the search isn't already populated
    if(!search.match(/(=|\*)/)){
      if(this.filter){
        this.filter += ' ' + search + '==*term*';
      }else{
        this.filter = search +'==*term*';

      }
      return this.filter; //this isn't persisting across the lifecycle
    }
  }


问:
How do I move the panel in Visual Studio Code to the right side?
It's at the bottom by default.

For example in the following image ,panel(Section D) is at the bottom, instead I want it to move to the rightside i.e., in the area where README.md editior shown in Editor Groups(Section C).

Image Credits: (https://code.visualstudio.com/images/codebasics_hero.png)

答:
By default, ⌘J toggles the (bottom) panel.  If all your views are on the side panel, make ⌘J toggle the side panel by doing:

Code > Preferences > Keyboard Shortcuts > "Command+J" > Right-click > Remove Keybinding

Code > Preferences > Keyboard Shortcuts > View: Toggle Side Panel > Add Keybinding > ⌘J


问:
How to retrieve all addresses with their relevant tokenIds
I've got an NFT collection with a maxSupply of 1000.
All the NFTs have been minted where totalSupply == maxSupply.

What is the best way to retrieve all 1000 addresses along with their relevant tokenIds?

I've tried the below, but the result is not working as expected. Where am I going wrong?

Any help is very much appreciated!

```<code> mapping(uint256 => address) private getMintedAddress;

 function getAllAddresses() public view returns (address[] memory) {
    uint256 totalMinted = totalSupply();
    address[] memory tokenAddresses = new address[](totalMinted);

    for (uint256 i = 1; i < totalMinted; i++) {
        tokenAddresses[i] = getMintedAddress[i];
    }
     return tokenAddresses;
  }

</code>```

答:
In solidity mappings, all values exist. In javascript, if we try to access a key that does not exist, objectName['keyThatDoesNotExist'] we get undefined. But in solidity, we get default value based on the values. If all values are strings, default value is empty string '', if all values are integers, default value is 0, if all values are booleans default value is false and if all values are address types, default values is 0x0000000000000000000000000000000000000000 which is the same as address(0);. That means getMintedAddress[i] does not exist so solidity is returning default address(0)

When you create an nft, update the

// since i did not initalize default would be 0
uint public indexForSenders;

```<code>function createNFT() public returns(bytes32){
       // setting id is important. easy way to start create a top level state
        // first item will start from 0: 0 -->address
        getMintedAddress[indexForSenders]=msg.sender;
        indexForSenders+=1
        .....
    }
</code>```

Body:
I've got an NFT collection with a maxSupply of 1000.
All the NFTs have been minted where totalSupply == maxSupply.

What is the best way to retrieve all 1000 addresses along with their relevant tokenIds?

I've tried the below, but the result is not working as expected. Where am I going wrong?

Any help is very much appreciated!

 mapping(uint256 => address) private getMintedAddress;

 function getAllAddresses() public view returns (address[] memory) {
    uint256 totalMinted = totalSupply();
    address[] memory tokenAddresses = new address[](totalMinted);

    for (uint256 i = 1; i < totalMinted; i++) {
        tokenAddresses[i] = getMintedAddress[i];
    }
     return tokenAddresses;
  }

Body:
In solidity mappings, all values exist. In javascript, if we try to access a key that does not exist, objectName['keyThatDoesNotExist'] we get undefined. But in solidity, we get default value based on the values. If all values are strings, default value is empty string '', if all values are integers, default value is 0, if all values are booleans default value is false and if all values are address types, default values is 0x0000000000000000000000000000000000000000 which is the same as address(0);. That means getMintedAddress[i] does not exist so solidity is returning default address(0)

When you create an nft, update the

// since i did not initalize default would be 0
uint public indexForSenders;

function createNFT() public returns(bytes32){
       // setting id is important. easy way to start create a top level state
        // first item will start from 0: 0 -->address
        getMintedAddress[indexForSenders]=msg.sender;
        indexForSenders+=1
        .....
    }


问:
Android C2DM port number choice
I noticed that the Google C2DM (push) tcp connection uses port 5228. I also know that some firewalls block ports other than 80 443 (because of htttp and https), which causes lots of users to complain that they can't use the Market app or GTalk on their phones using their company wifi for example.

Now my question is: why didn't Google choose port 443 or 80 for their persistent tcp connection?

答:
I suspect as they wanted to get the standard ports for something else and this way they can easily monitor traffic levels of C2DM traffic. </p>

<p>They are not alone and Apple do exactly the same for their push implementation.  </p>

Title: Android C2DM port number choice

Body:
I suspect as they wanted to get the standard ports for something else and this way they can easily monitor traffic levels of C2DM traffic.

They are not alone and Apple do exactly the same for their push implementation.


问:
Grid in Container is not displayed in a row but as a column
I code exactly like in a current YouTube video, in the video the cards are shown in a row, in my case they are strangely as a column.

Why? Default should actually be in line. Even if I explicitly enter direction="row" in the grid container, it still doesn't help.

App.js

```<code>import "./App.css";
import TourCard from "./components/TourCards";
import Container from "@mui/material/Container";
import { Grid } from "@mui/material";

function App() {
  return (
    <div className="App">
      <Container>
        <Grid Container spacing={4} direction="row">
          <TourCard />
          <TourCard />
          <TourCard />
          <TourCard />
        </Grid>
      </Container>
    </div>
  );
}

export default App;
</code>```

TourCards.js

```<code>import Paper from "@mui/material/Paper";
import { Grid, Typography } from "@mui/material";
import Logo from "../logo.svg";

const TourCard = () => {
  return (
    <Grid item xs={3}>
      <Paper elevation={3}>
        <img
          src={Logo}
          alt="logo"
          clasName="img"
        />
        <Typography>Nr.1</Typography>
      </Paper>
    </Grid>
  );
};

export default TourCard;
</code>```

答:
Check the capital C in <Grid Container spacing={4} direction="row"> -- it should be a lower case c for example:

```<code><Grid container spacing={4}>
  <TourCard />
  <TourCard />
  <TourCard />
  <TourCard />
</Grid>
</code>```

It is the container prop that causes display: flex to be applied to the Grid container.  Using improper case on a prop is the same as omitting it, as the props are case-sensitive.

Simplified reproduction of the error and correction: https://codesandbox.io/s/basicgrid-material-demo-forked-un6nk?file=/demo.js

Body:
I code exactly like in a current YouTube video, in the video the cards are shown in a row, in my case they are strangely as a column.

Why? Default should actually be in line. Even if I explicitly enter direction="row" in the grid container, it still doesn't help.

App.js

import "./App.css";
import TourCard from "./components/TourCards";
import Container from "@mui/material/Container";
import { Grid } from "@mui/material";

function App() {
  return (

      <Container>
        <Grid Container spacing={4} direction="row">
          <TourCard />
          <TourCard />
          <TourCard />
          <TourCard />
        </Grid>
      </Container>

  );
}

export default App;

TourCards.js

import Paper from "@mui/material/Paper";
import { Grid, Typography } from "@mui/material";
import Logo from "../logo.svg";

const TourCard = () => {
  return (
    <Grid item xs={3}>
      <Paper elevation={3}>

        <Typography>Nr.1</Typography>
      </Paper>
    </Grid>
  );
};

export default TourCard;

Body:
Check the capital C in <Grid Container spacing={4} direction="row"> -- it should be a lower case c for example:

<Grid container spacing={4}>
  <TourCard />
  <TourCard />
  <TourCard />
  <TourCard />
</Grid>

It is the container prop that causes display: flex to be applied to the Grid container.  Using improper case on a prop is the same as omitting it, as the props are case-sensitive.

Simplified reproduction of the error and correction: https://codesandbox.io/s/basicgrid-material-demo-forked-un6nk?file=/demo.js


问:
How to call function with arguments( char *, int *) in below code using node-ffi?
C++ third party library function

```<code>int getUCode( char* sample, int* size);
</code>```

Usage

```<code>char Code[256] = {0};
length = sizeof(Code);
ret = getUCode(Code, &length);
</code>```

Trying to Call above getUCode function using ffi-napi. But getting empty buffer.

```<code>const charPointer = ref.refType('char')

"getUCode": [
    "int32", [charPointer ,"int32"]

var str = Buffer.alloc(256)
var Len = 256
var val = lib.getUCode(str,Len);
</code>```

答:
We can use ref.refType to tell integer pointer in function signature

```<code>    var int = ref.types.int;
    var intPtr = ref.refType(int);
    var cstring = ref.types.CString;

    "getUCode": [
        "int32", [ cstring ,intPtr]
      ],
</code>```

Use Buffer to pass actual value in function calls

```<code>    var str = Buffer.alloc(256)
    const Len = ref.alloc(int, 256)
    var val =  lib.getUCode(str, len)
</code>```

Body:
C++ third party library function

int getUCode( char* sample, int* size);

Usage

char Code[256] = {0};
length = sizeof(Code);
ret = getUCode(Code, &length);

Trying to Call above getUCode function using ffi-napi. But getting empty buffer.

const charPointer = ref.refType('char')

"getUCode": [
    "int32", [charPointer ,"int32"]

var str = Buffer.alloc(256)
var Len = 256
var val = lib.getUCode(str,Len);

Body:
We can use ref.refType to tell integer pointer in function signature

    var int = ref.types.int;
    var intPtr = ref.refType(int);
    var cstring = ref.types.CString;

    "getUCode": [
        "int32", [ cstring ,intPtr]
      ],

Use Buffer to pass actual value in function calls

    var str = Buffer.alloc(256)
    const Len = ref.alloc(int, 256)
    var val =  lib.getUCode(str, len)


问:
Cannot convert return expression of type '[String : Any]' to return type 'Song?'
Yes, this question has been posted a million times but none of the answers are helping my specific scenario. My project is running fine but this error keeps coming up and it's extremely annoying, especially since the project is running perfectly.

here is my Song struct

```<code>import Foundation
import SwiftUI

struct Song: Identifiable, Codable {
    var album: String
    var artist: String
    var description: String
    let id: String
    var title: String
}
</code>```

Here is the class for getting data from Firestore (error is on line 31)
Cannot convert return expression of type '[String : Any]' to return type 'Song?' and
Argument passed to call that takes no arguments

```<code>import Foundation
import Firebase
import FirebaseFirestore
import FirebaseFirestoreSwift

class FirestoreManager: ObservableObject {
    @Published private(set) var songs: [Song] = []
    let db = Firestore.firestore()

    init() {
        fetchAllSongs()
    }

    func fetchAllSongs() {
        db.collection("Songs").addSnapshotListener { querySnapshot, error in
            guard let documents = querySnapshot?.documents else {
                print("Error")
                return
            }

            self.songs = documents.compactMap { document -> Song? in
                do {
                    print(document.data())
                    return try document.data(as: Song.self) // ERROR HERE
                } catch {
                    print("Error decoding document into Song: \(error)")

                    return nil
                }
            }

        }
    }
}

</code>```

Can someone please tell me why this is happening? I have searched Google for hours and I'm following this course down to the tee. I even copy and pasted the source code and replaced what I needed to match my project. Thank you in advance.

答:
Your need to cast a [String:Any] to type Song which won't work you need

```<code>let res = document.data()
let album = res["album"] as! String
let artist = res["artist"] as! String
.....
let content=  Song(...
return content
</code>```

Body:
Yes, this question has been posted a million times but none of the answers are helping my specific scenario. My project is running fine but this error keeps coming up and it's extremely annoying, especially since the project is running perfectly.

here is my Song struct

import Foundation
import SwiftUI

struct Song: Identifiable, Codable {
    var album: String
    var artist: String
    var description: String
    let id: String
    var title: String
}

Here is the class for getting data from Firestore (error is on line 31)
Cannot convert return expression of type '[String : Any]' to return type 'Song?' and
Argument passed to call that takes no arguments

import Foundation
import Firebase
import FirebaseFirestore
import FirebaseFirestoreSwift

class FirestoreManager: ObservableObject {
    @Published private(set) var songs: [Song] = []
    let db = Firestore.firestore()

    init() {
        fetchAllSongs()
    }

    func fetchAllSongs() {
        db.collection("Songs").addSnapshotListener { querySnapshot, error in
            guard let documents = querySnapshot?.documents else {
                print("Error")
                return
            }

            self.songs = documents.compactMap { document -> Song? in
                do {
                    print(document.data())
                    return try document.data(as: Song.self) // ERROR HERE
                } catch {
                    print("Error decoding document into Song: \(error)")

                    return nil
                }
            }

        }
    }
}

Can someone please tell me why this is happening? I have searched Google for hours and I'm following this course down to the tee. I even copy and pasted the source code and replaced what I needed to match my project. Thank you in advance.

Body:
Your need to cast a [String:Any] to type Song which won't work you need

let res = document.data()
let album = res["album"] as! String
let artist = res["artist"] as! String
.....
let content=  Song(...
return content


问:
Best Practises of @Repository in Spring boot framework
I have a Spring boot application which has a UserRepository but I have not annotated that repository with @Repository but still my application works fine.

Why @Repository annotation is optional in Spring boot and what is the best practise that should we annotate it or not in repository classes.

答:
For @Repository annotation even if you haven't mentioned Spring recognizes the repositories by the fact that they are extending Repository interfaces like JPARepository or CrudRepository.

So, it's not mandatory to mention annotation, you can check in your code whether you have mentioned @EnableJpaRepositories("packages") above Main class or not. That might also be one of the reasons why it is working.

As per best practices for annotations, they have a purpose to fulfill, @Repository is important from a database connection perspective, where it has lots of proper exceptions throw, or pre-defined methods.

If you do not use the proper annotations, you may face commit exceptions overridden by rollback transactions. You will see exceptions during the stress load test that is related to roll-back JDBC transactions.

For more clarity have a look at this post


问:
What's correct path to html pages for loading into WebView?
I know that there are a lot of questions about to load HTMl-pages into WebView.
What am I doing? I just put down the 1.html in assets folder in android-project and use

```<code>myWebView.loadUrl("file:///assets/"+selectedItem+".html");
</code>```

where
    selecteditem

is data from intent. As result I get the message in WebView that:

file:///assets/1.html  was not found.

UPD: sorry, I found the solution. the correct path should be the follow:

```<code>myWebView.loadUrl("file:///android_asset/"+selectedItem+".html");
</code>```

答:
I am not sure,but it may work:

```<code>webView.loadUrl("file:///android_asset/1.html");
</code>```

Know more about the same type of mistake: Loading existing .html file with android WebView

Body:
I know that there are a lot of questions about to load HTMl-pages into WebView.
What am I doing? I just put down the 1.html in assets folder in android-project and use

myWebView.loadUrl("file:///assets/"+selectedItem+".html");

where
    selecteditem

is data from intent. As result I get the message in WebView that:

file:///assets/1.html  was not found.

UPD: sorry, I found the solution. the correct path should be the follow:

myWebView.loadUrl("file:///android_asset/"+selectedItem+".html");

Body:
I am not sure,but it may work:

webView.loadUrl("file:///android_asset/1.html");

Know more about the same type of mistake: Loading existing .html file with android WebView


问:
How do I create an abstract base class in JavaScript?
Is it possible to simulate abstract base class in JavaScript? What is the most elegant way to do it?

Say, I want to do something like:

```<code>var cat = new Animal('cat');
var dog = new Animal('dog');

cat.say();
dog.say();
</code>```

It should output:

```<code>meow
bark
</code>```

答:
"use strict";

function Abstract (...arg){

    // create abstract constructor
    if(  this.constructor.name === 'Object' || this.constructor === Abstract ) throw { ErrorType : "can't call abstract class with new !" , }

    // ceate abstract method
    Object.defineProperty( this , 'config' , {
        value : function(){
            console.log('config parent')
        }
    });

    // or other
    return this ;
};

class Home extends Abstract{
    name = '';
    constructor(...arg){
        super(...arg) ;
    }

    config(){
        // this method not working
        console.log('config child')
    }
}

let y = new Home( "home" , 'dasd');
y.config();```

OwnerDisplayName: Sabya

Body:
Is it possible to simulate abstract base class in JavaScript? What is the most elegant way to do it?

Say, I want to do something like:

var cat = new Animal('cat');
var dog = new Animal('dog');

cat.say();
dog.say();

It should output:

meow
bark

LastEditorDisplayName: Eddie


问:
problem in layout display
I am build one app in which two swf are load

    1st is in background and

    2nd is in particular area

and also one textview & button are included

i want 1st swf in background and 2nd in front of 1st.

now when i load it i got only 1st swf and 2nd swf while textview and button are not display.

i put code ::

XML file::

```<code><?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:layout_width="fill_parent"
android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android"
android:gravity="center" android:orientation="horizontal">
<RelativeLayout android:id="@+id/rela_tranning"
    android:layout_width="480dp" android:layout_height="320dp"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:background="@drawable/trai_bg3">

    <!-- <ImageButton android:id="@+id/tran_btn_exit" android:layout_width="30dp"
        android:layout_height="30dp" android:layout_marginLeft="05dp" android:layout_marginTop="270dp"
        android:src="@drawable/exit_button"> </ImageButton> -->
    <LinearLayout android:layout_width="fill_parent"
        android:id="@+id/trans_linearll" android:layout_height="fill_parent"
        android:gravity="center">
        <WebView android:id="@+id/tranning_wv_girl"
            android:layout_width="fill_parent" android:layout_height="fill_parent">
        </WebView>
    </LinearLayout>

    <LinearLayout android:layout_width="195dp" android:id="@+id/trans_lin"
        android:layout_height="185dp" android:gravity="center"
        android:layout_marginLeft="37dp" android:layout_marginTop="75dp">
        <WebView android:id="@+id/tranning_wv_main"
            android:layout_height="fill_parent" android:layout_width="fill_parent" />
    </LinearLayout>
    <!-- <ImageView android:layout_width="480dp" android:layout_height="fill_parent"
        android:visibility="invisible" android:id="@+id/tran_imgwv_playnow" /> -->
    <LinearLayout android:layout_width="wrap_content"
        android:id="@+id/trans_linearll" android:layout_height="wrap_content"
        android:gravity="center" android:layout_marginLeft="390dp"
        android:layout_marginTop="20dp">
        <ImageButton android:id="@+id/tran_btn_skip"
            android:layout_width="70dp" android:layout_height="48dp">
        </ImageButton>
    </LinearLayout>

    <LinearLayout android:layout_width="200dp" android:id="@+id/trans_linearll"
        android:layout_height="wrap_content" android:gravity="center"
        android:layout_marginLeft="25dp" android:layout_marginTop="25dp">
        <TextView android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:id="@+id/tran_banner"
            android:textSize="19dp" android:textColor="#2557AA" />
        <!-- #FF0000 red color #2557AA for green color -->
    </LinearLayout>

</RelativeLayout>
</code>```

Java file

```<code>    package com.adySol;

import java.io.InputStream;
import java.net.URL;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Typeface;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.view.View;
import android.view.Window;
import android.webkit.WebSettings.PluginState;
import android.webkit.WebView;
import android.widget.ImageButton;
import android.widget.TextView;

public class tranning extends Activity {
    /** Called when the activity is first created. */
    WebView tranning_wv_main, girl, first_wv;
    boolean flag = false, flag2 = false;

    String first = "file:///android_asset/bike_route_two_h.swf";
    String second = "file:///android_asset/close_two_h.swf";
    String third = "file:///android_asset/exit_two_h.swf";
    String fourth = "file:///android_asset/no_parking _two_h.swf";
    String fifth = "file:///android_asset/one_way_two_h.swf";
    String sixth = "file:///android_asset/phone_two_h.swf";
    String seventh = "file:///android_asset/rail_crossing_two_h.swf";
    String eighth = "file:///android_asset/sale_two_h.swf";
    String nineth = "file:///android_asset/stop_two_h.swf";
    String tenth = "file:///android_asset/turn_off_the_tap_two_h.swf";
    Typeface face;
    String background = "file:///android_asset/screen2.swf";
    private MediaPlayer xmPlayer2 = new MediaPlayer(),
            xmPlayer3 = new MediaPlayer(), xmPlayer4 = new MediaPlayer(),
            xmPlayer5 = new MediaPlayer(), xmPlayer6 = new MediaPlayer(),
            xmPlayer7 = new MediaPlayer(), xmPlayer8 = new MediaPlayer(),
            xmPlayer9 = new MediaPlayer(), xmPlayer10 = new MediaPlayer(),
            xmPlayer11 = new MediaPlayer();
    CountDownTimer aCounter, aCounter2, aCounter3, aCounter4, aCounter5,
            aCounter6, aCounter7, aCounter8, aCounter9, aCounter10, aCounter11;
    Intent touchAndShow;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.tranning);

        face = Typeface.createFromAsset(this.getAssets(), "fonts/comic.TTF");

        ImageButton tran_btn_skip = (ImageButton) findViewById(R.id.tran_btn_skip);
        try {
            Bitmap bitmap = BitmapFactory.decodeStream((InputStream) new URL(
                    "http://203.109.115.55/MRESC/images/test/skip.png")
                    .getContent());
            tran_btn_skip.setImageBitmap(bitmap);
        } catch (Exception e) {
        }
        touchAndShow = new Intent(this, TouchandShow.class);
        tran_btn_skip.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                try {
                    flag = true;
                    /*
                     * xmPlayer2.stop(); xmPlayer3.stop(); xmPlayer4.stop();
                     * xmPlayer5.stop(); xmPlayer6.stop(); xmPlayer7.stop();
                     * xmPlayer8.stop(); xmPlayer9.stop(); xmPlayer10.stop();
                     * xmPlayer11.stop();
                     */
                    startActivity(touchAndShow);
                    touchAndShow.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
                    finish();
                } catch (Exception e) {
                }
            }
        });

        final TextView tran_banner;
        tran_banner = (TextView) findViewById(R.id.tran_banner);
        tran_banner.setTypeface(face, Typeface.BOLD);

        girl = (WebView) findViewById(R.id.tranning_wv_girl);
        girl.getSettings().setJavaScriptEnabled(true);
        girl.getSettings().setPluginState(PluginState.ON);
        girl.getSettings().setAllowFileAccess(true);
        girl.loadUrl(background);

        aCounter = new CountDownTimer(3000, 1000) {
            public void onTick(long millisUntilFinished) {
                tran_banner.setText("Route Sign");
                swfLoad(first, xmPlayer2, "bike_route.mp3", "Route Sign");
            }

            public void onFinish() {
                aCounter2 = new CountDownTimer(4000, 1000) {
                    public void onTick(long millisUntilFinished) {
                        tran_banner.setText("Closed Sign");
                        swfLoad(second, xmPlayer3, "closed.mp3", "Closed Sign");
                    }

                    public void onFinish() {

                        aCounter3 = new CountDownTimer(4000, 1000) {
                            public void onTick(long millisUntilFinished) {
                                tran_banner.setText("Exit Sign");
                                swfLoad(third, xmPlayer4, "exit.mp3",
                                        "Exit Sign");
                            }

                            public void onFinish() {
                                aCounter4 = new CountDownTimer(4000, 1000) {
                                    public void onTick(long millisUntilFinished) {
                                        tran_banner.setText("No Parking Sign");
                                        swfLoad(fourth, xmPlayer5,
                                                "no_parking.mp3",
                                                "No Parking Sign");
                                    }

                                    public void onFinish() {
                                        aCounter5 = new CountDownTimer(4000,
                                                1000) {
                                            public void onTick(
                                                    long millisUntilFinished) {

                                                swfLoad(fifth, xmPlayer6,
                                                        "one_way.mp3",
                                                        "One Way Sign");
                                            }

                                            public void onFinish() {
                                                aCounter6 = new CountDownTimer(
                                                        4000, 1000) {
                                                    public void onTick(
                                                            long millisUntilFinished) {

                                                        swfLoad(sixth,
                                                                xmPlayer7,
                                                                "phone.mp3",
                                                                "Phone Sign");
                                                    }

                                                    public void onFinish() {
                                                        aCounter7 = new CountDownTimer(
                                                                4000, 1000) {
                                                            public void onTick(
                                                                    long millisUntilFinished) {
                                                                swfLoad(seventh,
                                                                        xmPlayer8,
                                                                        "rail_cross_wav.wav",
                                                                        "Rail Crossing Sign");
                                                            }

                                                            public void onFinish() {
                                                                aCounter8 = new CountDownTimer(
                                                                        5000,
                                                                        1000) {
                                                                    public void onTick(
                                                                            long millisUntilFinished) {
                                                                        swfLoad(eighth,
                                                                                xmPlayer9,
                                                                                "sale.mp3",
                                                                                "Sale Sign");
                                                                    }

                                                                    public void onFinish() {
                                                                        aCounter9 = new CountDownTimer(
                                                                                4000,
                                                                                1000) {
                                                                            public void onTick(
                                                                                long millisUntilFinished) {
                                                                                swfLoad(nineth,
                                                                                xmPlayer10,
                                                                                "stop.mp3",
                                                                                "Stop Sign");

                                                                            }

                                                                            public void onFinish() {
                                                                                aCounter10 = new CountDownTimer(
                                                                                4000,
                                                                                1000) {
                                                                                public void onTick(
                                                                                long millisUntilFinished) {
                                                                                swfLoad(tenth,
                                                                                xmPlayer11,
                                                                                "turn_off_tap.mp3",
                                                                                "Turn off Tap Sign");

                                                                                }

                                                                                public void onFinish() {
                                                                                flag2 = true;
                                                                                first_wv.setVisibility(View.INVISIBLE);

                                                                                aCounter11 = new CountDownTimer(
                                                                                4000,
                                                                                1000) {
                                                                                public void onTick(
                                                                                long millisUntilFinished) {
                                                                                flag2 = true;
                                                                                // invisibleControl();
                                                                                }

                                                                                public void onFinish() {
                                                                                startActivity(touchAndShow);
                                                                                touchAndShow
                                                                                .addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
                                                                                finish();

                                                                                }
                                                                                };
                                                                                aCounter11
                                                                                .start();

                                                                                }
                                                                                };
                                                                                aCounter10
                                                                                .start();
                                                                            }
                                                                        };
                                                                        aCounter9
                                                                                .start();
                                                                    }
                                                                };
                                                                aCounter8
                                                                        .start();
                                                            }
                                                        };
                                                        aCounter7.start();
                                                    }
                                                };
                                                aCounter6.start();
                                            }
                                        };
                                        aCounter5.start();
                                    }
                                };
                                aCounter4.start();
                            }
                        };
                        aCounter3.start();
                    }
                };
                aCounter2.start();
            }
        };
        aCounter.start();

        /*
         * WebView third_wv = (WebView) findViewById(R.id.tranning_wv_main);
         * third_wv.getSettings().setJavaScriptEnabled(true);
         * third_wv.getSettings().setPluginState(PluginState.ON);
         * third_wv.getSettings().setAllowFileAccess(true);
         * third_wv.loadUrl(third);
         */
    }

    public void swfLoad(String xurl, final MediaPlayer player,
            final String music1, final String banner) {
        if (flag == false) {

            first_wv = (WebView) findViewById(R.id.tranning_wv_main);
            first_wv.getSettings().setJavaScriptEnabled(true);
            first_wv.getSettings().setPluginState(PluginState.ON);
            first_wv.getSettings().setAllowFileAccess(true);
            if (flag2 == true) {

                first_wv.setVisibility(View.INVISIBLE);
            } else {
                first_wv.loadUrl(xurl);
            }
            try {
                player.setAudioStreamType(AudioManager.STREAM_MUSIC);
                player.setDataSource("http://203.109.115.55/MRESC/images/test/"
                        + music1);
                player.prepare();
                player.start();

            } catch (Exception e) {

            }
        } else if (flag == true) {

        }
    }

}
</code>```

答:
Maybe you can use FrameLayout to resolve your problem, and not LinearLayout !
Check out this post :
Android Honeycomb: layout problem - hide/show FrameLayouts

Hope it helps you

Title: problem in layout display

Body:
I am build one app in which two swf are load

    1st is in background and

    2nd is in particular area

and also one textview & button are included

i want 1st swf in background and 2nd in front of 1st.

now when i load it i got only 1st swf and 2nd swf while textview and button are not display.

i put code ::

XML file::

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:layout_width="fill_parent"
android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android"
android:gravity="center" android:orientation="horizontal">
<RelativeLayout android:id="@+id/rela_tranning"
    android:layout_width="480dp" android:layout_height="320dp"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:background="@drawable/trai_bg3">

    <LinearLayout android:layout_width="fill_parent"
        android:id="@+id/trans_linearll" android:layout_height="fill_parent"
        android:gravity="center">
        <WebView android:id="@+id/tranning_wv_girl"
            android:layout_width="fill_parent" android:layout_height="fill_parent">
        </WebView>
    </LinearLayout>

    <LinearLayout android:layout_width="195dp" android:id="@+id/trans_lin"
        android:layout_height="185dp" android:gravity="center"
        android:layout_marginLeft="37dp" android:layout_marginTop="75dp">
        <WebView android:id="@+id/tranning_wv_main"
            android:layout_height="fill_parent" android:layout_width="fill_parent" />
    </LinearLayout>

    <LinearLayout android:layout_width="wrap_content"
        android:id="@+id/trans_linearll" android:layout_height="wrap_content"
        android:gravity="center" android:layout_marginLeft="390dp"
        android:layout_marginTop="20dp">
        <ImageButton android:id="@+id/tran_btn_skip"
            android:layout_width="70dp" android:layout_height="48dp">
        </ImageButton>
    </LinearLayout>

    <LinearLayout android:layout_width="200dp" android:id="@+id/trans_linearll"
        android:layout_height="wrap_content" android:gravity="center"
        android:layout_marginLeft="25dp" android:layout_marginTop="25dp">
        <TextView android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:id="@+id/tran_banner"
            android:textSize="19dp" android:textColor="#2557AA" />

    </LinearLayout>

</RelativeLayout>

Java file

    package com.adySol;

import java.io.InputStream;
import java.net.URL;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Typeface;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.view.View;
import android.view.Window;
import android.webkit.WebSettings.PluginState;
import android.webkit.WebView;
import android.widget.ImageButton;
import android.widget.TextView;

public class tranning extends Activity {
    /** Called when the activity is first created. */
    WebView tranning_wv_main, girl, first_wv;
    boolean flag = false, flag2 = false;

    String first = "file:///android_asset/bike_route_two_h.swf";
    String second = "file:///android_asset/close_two_h.swf";
    String third = "file:///android_asset/exit_two_h.swf";
    String fourth = "file:///android_asset/no_parking _two_h.swf";
    String fifth = "file:///android_asset/one_way_two_h.swf";
    String sixth = "file:///android_asset/phone_two_h.swf";
    String seventh = "file:///android_asset/rail_crossing_two_h.swf";
    String eighth = "file:///android_asset/sale_two_h.swf";
    String nineth = "file:///android_asset/stop_two_h.swf";
    String tenth = "file:///android_asset/turn_off_the_tap_two_h.swf";
    Typeface face;
    String background = "file:///android_asset/screen2.swf";
    private MediaPlayer xmPlayer2 = new MediaPlayer(),
            xmPlayer3 = new MediaPlayer(), xmPlayer4 = new MediaPlayer(),
            xmPlayer5 = new MediaPlayer(), xmPlayer6 = new MediaPlayer(),
            xmPlayer7 = new MediaPlayer(), xmPlayer8 = new MediaPlayer(),
            xmPlayer9 = new MediaPlayer(), xmPlayer10 = new MediaPlayer(),
            xmPlayer11 = new MediaPlayer();
    CountDownTimer aCounter, aCounter2, aCounter3, aCounter4, aCounter5,
            aCounter6, aCounter7, aCounter8, aCounter9, aCounter10, aCounter11;
    Intent touchAndShow;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.tranning);

        face = Typeface.createFromAsset(this.getAssets(), "fonts/comic.TTF");

        ImageButton tran_btn_skip = (ImageButton) findViewById(R.id.tran_btn_skip);
        try {
            Bitmap bitmap = BitmapFactory.decodeStream((InputStream) new URL(
                    "http://203.109.115.55/MRESC/images/test/skip.png")
                    .getContent());
            tran_btn_skip.setImageBitmap(bitmap);
        } catch (Exception e) {
        }
        touchAndShow = new Intent(this, TouchandShow.class);
        tran_btn_skip.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                try {
                    flag = true;
                    /*
                     * xmPlayer2.stop(); xmPlayer3.stop(); xmPlayer4.stop();
                     * xmPlayer5.stop(); xmPlayer6.stop(); xmPlayer7.stop();
                     * xmPlayer8.stop(); xmPlayer9.stop(); xmPlayer10.stop();
                     * xmPlayer11.stop();
                     */
                    startActivity(touchAndShow);
                    touchAndShow.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
                    finish();
                } catch (Exception e) {
                }
            }
        });

        final TextView tran_banner;
        tran_banner = (TextView) findViewById(R.id.tran_banner);
        tran_banner.setTypeface(face, Typeface.BOLD);

        girl = (WebView) findViewById(R.id.tranning_wv_girl);
        girl.getSettings().setJavaScriptEnabled(true);
        girl.getSettings().setPluginState(PluginState.ON);
        girl.getSettings().setAllowFileAccess(true);
        girl.loadUrl(background);

        aCounter = new CountDownTimer(3000, 1000) {
            public void onTick(long millisUntilFinished) {
                tran_banner.setText("Route Sign");
                swfLoad(first, xmPlayer2, "bike_route.mp3", "Route Sign");
            }

            public void onFinish() {
                aCounter2 = new CountDownTimer(4000, 1000) {
                    public void onTick(long millisUntilFinished) {
                        tran_banner.setText("Closed Sign");
                        swfLoad(second, xmPlayer3, "closed.mp3", "Closed Sign");
                    }

                    public void onFinish() {

                        aCounter3 = new CountDownTimer(4000, 1000) {
                            public void onTick(long millisUntilFinished) {
                                tran_banner.setText("Exit Sign");
                                swfLoad(third, xmPlayer4, "exit.mp3",
                                        "Exit Sign");
                            }

                            public void onFinish() {
                                aCounter4 = new CountDownTimer(4000, 1000) {
                                    public void onTick(long millisUntilFinished) {
                                        tran_banner.setText("No Parking Sign");
                                        swfLoad(fourth, xmPlayer5,
                                                "no_parking.mp3",
                                                "No Parking Sign");
                                    }

                                    public void onFinish() {
                                        aCounter5 = new CountDownTimer(4000,
                                                1000) {
                                            public void onTick(
                                                    long millisUntilFinished) {

                                                swfLoad(fifth, xmPlayer6,
                                                        "one_way.mp3",
                                                        "One Way Sign");
                                            }

                                            public void onFinish() {
                                                aCounter6 = new CountDownTimer(
                                                        4000, 1000) {
                                                    public void onTick(
                                                            long millisUntilFinished) {

                                                        swfLoad(sixth,
                                                                xmPlayer7,
                                                                "phone.mp3",
                                                                "Phone Sign");
                                                    }

                                                    public void onFinish() {
                                                        aCounter7 = new CountDownTimer(
                                                                4000, 1000) {
                                                            public void onTick(
                                                                    long millisUntilFinished) {
                                                                swfLoad(seventh,
                                                                        xmPlayer8,
                                                                        "rail_cross_wav.wav",
                                                                        "Rail Crossing Sign");
                                                            }

                                                            public void onFinish() {
                                                                aCounter8 = new CountDownTimer(
                                                                        5000,
                                                                        1000) {
                                                                    public void onTick(
                                                                            long millisUntilFinished) {
                                                                        swfLoad(eighth,
                                                                                xmPlayer9,
                                                                                "sale.mp3",
                                                                                "Sale Sign");
                                                                    }

                                                                    public void onFinish() {
                                                                        aCounter9 = new CountDownTimer(
                                                                                4000,
                                                                                1000) {
                                                                            public void onTick(
                                                                                long millisUntilFinished) {
                                                                                swfLoad(nineth,
                                                                                xmPlayer10,
                                                                                "stop.mp3",
                                                                                "Stop Sign");

                                                                            }

                                                                            public void onFinish() {
                                                                                aCounter10 = new CountDownTimer(
                                                                                4000,
                                                                                1000) {
                                                                                public void onTick(
                                                                                long millisUntilFinished) {
                                                                                swfLoad(tenth,
                                                                                xmPlayer11,
                                                                                "turn_off_tap.mp3",
                                                                                "Turn off Tap Sign");

                                                                                }

                                                                                public void onFinish() {
                                                                                flag2 = true;
                                                                                first_wv.setVisibility(View.INVISIBLE);

                                                                                aCounter11 = new CountDownTimer(
                                                                                4000,
                                                                                1000) {
                                                                                public void onTick(
                                                                                long millisUntilFinished) {
                                                                                flag2 = true;
                                                                                // invisibleControl();
                                                                                }

                                                                                public void onFinish() {
                                                                                startActivity(touchAndShow);
                                                                                touchAndShow
                                                                                .addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
                                                                                finish();

                                                                                }
                                                                                };
                                                                                aCounter11
                                                                                .start();

                                                                                }
                                                                                };
                                                                                aCounter10
                                                                                .start();
                                                                            }
                                                                        };
                                                                        aCounter9
                                                                                .start();
                                                                    }
                                                                };
                                                                aCounter8
                                                                        .start();
                                                            }
                                                        };
                                                        aCounter7.start();
                                                    }
                                                };
                                                aCounter6.start();
                                            }
                                        };
                                        aCounter5.start();
                                    }
                                };
                                aCounter4.start();
                            }
                        };
                        aCounter3.start();
                    }
                };
                aCounter2.start();
            }
        };
        aCounter.start();

        /*
         * WebView third_wv = (WebView) findViewById(R.id.tranning_wv_main);
         * third_wv.getSettings().setJavaScriptEnabled(true);
         * third_wv.getSettings().setPluginState(PluginState.ON);
         * third_wv.getSettings().setAllowFileAccess(true);
         * third_wv.loadUrl(third);
         */
    }

    public void swfLoad(String xurl, final MediaPlayer player,
            final String music1, final String banner) {
        if (flag == false) {

            first_wv = (WebView) findViewById(R.id.tranning_wv_main);
            first_wv.getSettings().setJavaScriptEnabled(true);
            first_wv.getSettings().setPluginState(PluginState.ON);
            first_wv.getSettings().setAllowFileAccess(true);
            if (flag2 == true) {

                first_wv.setVisibility(View.INVISIBLE);
            } else {
                first_wv.loadUrl(xurl);
            }
            try {
                player.setAudioStreamType(AudioManager.STREAM_MUSIC);
                player.setDataSource("http://203.109.115.55/MRESC/images/test/"
                        + music1);
                player.prepare();
                player.start();

            } catch (Exception e) {

            }
        } else if (flag == true) {

        }
    }

}


问:
what is onChange={(e) => setName(e.target.value)}? in React mean
I am new to React;I am learning about React Form. I understand the code but I do not really understand the concept behind and why we use this line "  onChange={(e) => setName(e.target.value)}".

Thank you for your help.

They used this example:

```<code>import ReactDOM from 'react-dom';

function MyForm() {
  const [name, setName] = useState("");

  const handleSubmit = (event) => {
    event.preventDefault();
    alert(`The name you entered was: ${name}`)
  }

  return (
    <form onSubmit={handleSubmit}>
      <label>Enter your name:
        <input
          type="text"
          value={name}
          onChange={(e) => setName(e.target.value)}
        />
      </label>
      <input type="submit" />
    </form>
  )
}

ReactDOM.render(<MyForm />, document.getElementById('root'));
</code>```

答: means e is the event that is happening which here is change, target is the element that triggered the event, which here is the input, and value is the value of the input element Onchange is as the name suggests  and setState is used to change the state you defined eariler you should read the documentation as well it would clear stuff up maybe an online explanation on youtube anyways all the best for your React journey</p>

Body:
I am new to React;I am learning about React Form. I understand the code but I do not really understand the concept behind and why we use this line "  onChange={(e) => setName(e.target.value)}".

Thank you for your help.

They used this example:

import ReactDOM from 'react-dom';

function MyForm() {
  const [name, setName] = useState("");

  const handleSubmit = (event) => {
    event.preventDefault();
    alert(`The name you entered was: ${name}`)
  }

  return (
    <form onSubmit={handleSubmit}>
      Enter your name:
        <input
          type="text"
          value={name}
          onChange={(e) => setName(e.target.value)}
        />

      <input type="submit" />
    </form>
  )
}

ReactDOM.render(<MyForm />, document.getElementById('root'));


问:
Kotlin: How to create a higher order function that works inside suspend and non-suspend functions? (other than inline)
So basically, I want to create a high order function like run, that works inside non-functions as it works in suspend functions.

What seems to make it work is the inline modifier, but I'm sure that comes with some sort of overhead, so I'm wondering if there's another way.

答:
I believe inline is the only way to achieve this. It is also a commonly used solution, both in stdlib and 3rd party code.

Regarding the overhead: it is actually the opposite. Higher-order functions are better to be inlined anyway - because of the performance. Drawback is the increased size of the resulting bytecode, so slightly increased memory usage. However, this shouldn't be a concern as long as the inlined function isn't really big.


问:
Accessing vector of axis ticks for an existing plot in ggplot2
I would like to get the vector of values for axis ticks in an existing plot in ggplot. I know that a ggplot object is a list with 9 elements and I was wondering if somehow I could extract the values for the axis ticks from that list. For example if I produce this toy example:

```<code>library(ggplot2)
g=ggplot(data=mtcars,aes(hp,mpg))+geom_point()
</code>```

What I want are the vectors

```<code> c(100,200,300)
 c(10,15,20,25,30,35)
</code>```

for x ticks and y ticks respectively w

Is there a way to to this?

Many thanks!

答:
To follow up on the comments on @Jota's answer, the methods mentioned appear to have changed. Using one of the following no longer appears to work:

```<code>ggplot_build(g)$layout$panel_ranges[[1]]$x.major_source
ggbld <- ggplot_build(g)
ggbld$layout$coord$labels(ggbld$layout$panel_params)[[1]]$x.labels
ggbld$layout$coord$labels(ggbld$layout$panel_params)[[1]]$x.major_source
</code>```

Using of ggplot2 version 3.5.5, I can extract the major tick marks, as per the original question, with:

```<code>(g1 <- ggplot_build(g)$layout$panel_params[[1]]$x$breaks)

</code>```

giving

```<code>[1]  NA 100 200 300  NA
</code>```

which we can subset with g1[which(!is.na(g1))].

In case of interest, the minor tick marks (visible as thin lines on the plot but not labelled on the axis) can be extracted with:

```<code>ggplot_build(g)$layout$panel_params[[1]]$x$minor_breaks
</code>```

giving

```<code>[1]  50 100 150 200 250 300
</code>```

Body:
I would like to get the vector of values for axis ticks in an existing plot in ggplot. I know that a ggplot object is a list with 9 elements and I was wondering if somehow I could extract the values for the axis ticks from that list. For example if I produce this toy example:

library(ggplot2)
g=ggplot(data=mtcars,aes(hp,mpg))+geom_point()

What I want are the vectors

 c(100,200,300)
 c(10,15,20,25,30,35)

for x ticks and y ticks respectively w

Is there a way to to this?

Many thanks!

Body:
To follow up on the comments on @Jota's answer, the methods mentioned appear to have changed. Using one of the following no longer appears to work:

ggplot_build(g)$layout$panel_ranges[[1]]$x.major_source
ggbld <- ggplot_build(g)
ggbld$layout$coord$labels(ggbld$layout$panel_params)[[1]]$x.labels
ggbld$layout$coord$labels(ggbld$layout$panel_params)[[1]]$x.major_source

Using of ggplot2 version 3.5.5, I can extract the major tick marks, as per the original question, with:

(g1 <- ggplot_build(g)$layout$panel_params[[1]]$x$breaks)

giving

[1]  NA 100 200 300  NA

which we can subset with g1[which(!is.na(g1))].

In case of interest, the minor tick marks (visible as thin lines on the plot but not labelled on the axis) can be extracted with:

ggplot_build(g)$layout$panel_params[[1]]$x$minor_breaks

giving

[1]  50 100 150 200 250 300


问:
How To Convert base64 String to PDF in React.js
I have a base 64 string that is coming from an API call. I am testing with a sample base64 string and I am trying to convert it to pdf or an image to view in my react.js website.

I've tried many solutions, but nothing seems to work. I found a react js package that is called base64topdf I installed it and tried to decode the base64 string to PDF, but it gives me this error "TypeError: fs.writeFileSync is not a function"

I don't know what i am doing wrong.

How can I convert a base64 string to a PDF or an image in reactjs?

Documentation to the package https://www.npmjs.com/package/base64topdf

Here is my code:

```<code> const base64 = require('base64topdf');

 const base64STR = "JVBERi0xLjQKJeLjz9M...." //base64 string

 const decodedBase64 = base64.base64Decode(base64STR, 'waybill');

 console.log(decodedBase64)
</code>```

答:
try this
<embed src={`data:application/pdf;base64,${base64STR}`} />

Body:
I have a base 64 string that is coming from an API call. I am testing with a sample base64 string and I am trying to convert it to pdf or an image to view in my react.js website.

I've tried many solutions, but nothing seems to work. I found a react js package that is called base64topdf I installed it and tried to decode the base64 string to PDF, but it gives me this error "TypeError: fs.writeFileSync is not a function"

I don't know what i am doing wrong.

How can I convert a base64 string to a PDF or an image in reactjs?

Documentation to the package https://www.npmjs.com/package/base64topdf

Here is my code:

 const base64 = require('base64topdf');

 const base64STR = "JVBERi0xLjQKJeLjz9M...." //base64 string

 const decodedBase64 = base64.base64Decode(base64STR, 'waybill');

 console.log(decodedBase64)


问:
Having issues displaying forms in Visual Studio
I am creating a project using Windows Forms on the .NET framework.
It's created and everything looks fine.

But when I close and reopen the project, the form designer is gone (form.cs and form.Designer.cs are still there but the actual form template is gone).

Can someone help?

i have uploaded a picture for better understanding.

enter image description here

答:
You're in folder view. From VS you probably did File > Open > Folder. From here, you need to actually open the solution. Double click on the .sln file within the Solution Explorer of VS. That will open up the solution and load the projects, and do the proper nesting of your code behind and designer files.

Next time, you can just open the solution file directly from Windows File Explorer or in VS via File > Open > Project/Solution, then you won't have to waste time in folder view.


问:
Sum variable number of columns with multiple criteria on multiple columns
Looking for some help on creating a formula (ideally Google Sheets compatible) that will allow me to define criteria range for multiple columns and define how many columns to sum.

For example, in the screenshot provided, I am interested in:

Names A, B, and C

Program X and Z

Sum of the first two months (Jan and Feb)

I would expect the result to give 1050, and if I change the Months criteria to 3, it would add in March as well and total to 550

Example

Thanks!

答:
=SUM(FILTER(INDEX(C2:F5,SEQUENCE(ROWS(C2:F5)),SEQUENCE(1,C12)),(COUNTIF(A12:A14,A2:A5))*(COUNTIF(B12:B13,B2:B5))))

Requires Office Excel 365.
The filter is set over the number of columns as mentioned in C12 and it filters the rows that meet the COUNTIF conditions.

If you have an older version of Excel I could workaround the SEQUENCE part using double INDEX.