问:
How to correctly install wkhtmltopdf on debian 64 bit?
I am trying to install wkhtmltopdf, but when I do:

```<code>sudo dpkg -i wkhtmltox-0.12.1_linux-trusty-amd64.deb
</code>```

I get :

```<code>Preparing to unpack wkhtmltox-0.12.1_linux-trusty-amd64.deb ...
Unpacking wkhtmltox (0.12.1) over (0.12.1) ...
dpkg: dependency problems prevent configuration of wkhtmltox:
  wkhtmltox depends on libjpeg-turbo8; however:
  Package libjpeg-turbo8 is not installed.

dpkg: error processing package wkhtmltox (--install):
 dependency problems - leaving unconfigured
Processing triggers for man-db (2.7.0.2-5) ...
Errors were encountered while processing:
 wkhtmltox
</code>```

So I tried:

```<code>apt-get update
apt-get install libjpeg-turbo8
</code>```

Then I get

```<code>Reading package lists... Done
Building dependency tree
Reading state information... Done
Package libjpeg-turbo8 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or is only available from another source

E: Package 'libjpeg-turbo8' has no installation candidate
</code>```

I'm using a 64 bit debian.
I browsed the web to find a solution but infortunately didn't find any answers.
How can I get the libjpeg-turbo8?

EDIT:

So I tried apt-get install wkhtmltopdf despite the fact it wasn't recommended.

The probleme with apt-get install wkhtmltopdf is that the version isn't always the good one and we should use 0.12.1

But:

```<code>root@dev01:/opt/odoo/modules_scndf# apt-cache policy wkhtmltopdf
wkhtmltopdf:
  Installed: 0.12.1-2
  Candidate: 0.12.1-2
  Version table:
 *** 0.12.1-2 0
         500 http://ftp.debian.org/debian/ jessie/main amd64 Packages
         100 /var/lib/dpkg/status
</code>```

Version seems to be the good one even with apt-get install wkhtmltopdf but when I launch my print on odoo I still get

```<code>Unable to find Wkhtmltopdf on this system. The report will be shown in html.
</code>```

Which means he didn't installed as it should have.

EDIT 2:

Now when I try to print the report, I get a popup:

```<code>Wkhtmltopdf failed (Error code : -6). Message : The switch
--header-html, is not support using unpatched qt, and will be
ignored.The switch --footer-html, is not support using unpatched qt,
and will be ignored.QXcbConnection: Could not connect to display
</code>```

答:
I'm running Debian Stretch 9.2 64bit and I succeeded with the following:

```<code>    sudo apt update
    sudo apt install xfonts-75dpi xfonts-base gvfs colord glew-utils libvisual-0.4-plugins gstreamer1.0-tools opus-tools qt5-image-formats-plugins qtwayland5 qt5-qmltooling-plugins librsvg2-bin lm-sensors
    sudo wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.stretch_amd64.deb
    sudo dpkg -i wkhtmltox_0.12.5-1.stretch_amd64.deb
    sudo cp /usr/local/bin/wkhtmltopdf /usr/bin/
    sudo cp /usr/local/bin/wkhtmltoimage /usr/bin/
</code>```

Then check the installation with:

```<code>    wkhtmltopdf -V
</code>```

Which should return:

```<code>    wkhtmltopdf 0.12.5 (with patched qt)
</code>```

Body:
I am trying to install wkhtmltopdf, but when I do:

sudo dpkg -i wkhtmltox-0.12.1_linux-trusty-amd64.deb

I get :

Preparing to unpack wkhtmltox-0.12.1_linux-trusty-amd64.deb ...
Unpacking wkhtmltox (0.12.1) over (0.12.1) ...
dpkg: dependency problems prevent configuration of wkhtmltox:
  wkhtmltox depends on libjpeg-turbo8; however:
  Package libjpeg-turbo8 is not installed.

dpkg: error processing package wkhtmltox (--install):
 dependency problems - leaving unconfigured
Processing triggers for man-db (2.7.0.2-5) ...
Errors were encountered while processing:
 wkhtmltox

So I tried:

apt-get update
apt-get install libjpeg-turbo8

Then I get

Reading package lists... Done
Building dependency tree
Reading state information... Done
Package libjpeg-turbo8 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or is only available from another source

E: Package 'libjpeg-turbo8' has no installation candidate

I'm using a 64 bit debian.
I browsed the web to find a solution but infortunately didn't find any answers.
How can I get the libjpeg-turbo8?

EDIT:

So I tried apt-get install wkhtmltopdf despite the fact it wasn't recommended.

The probleme with apt-get install wkhtmltopdf is that the version isn't always the good one and we should use 0.12.1

But:

root@dev01:/opt/odoo/modules_scndf# apt-cache policy wkhtmltopdf
wkhtmltopdf:
  Installed: 0.12.1-2
  Candidate: 0.12.1-2
  Version table:
 *** 0.12.1-2 0
         500 http://ftp.debian.org/debian/ jessie/main amd64 Packages
         100 /var/lib/dpkg/status

Version seems to be the good one even with apt-get install wkhtmltopdf but when I launch my print on odoo I still get

Unable to find Wkhtmltopdf on this system. The report will be shown in html.

Which means he didn't installed as it should have.

EDIT 2:

Now when I try to print the report, I get a popup:

Wkhtmltopdf failed (Error code : -6). Message : The switch
--header-html, is not support using unpatched qt, and will be
ignored.The switch --footer-html, is not support using unpatched qt,
and will be ignored.QXcbConnection: Could not connect to display

Body:
I'm running Debian Stretch 9.2 64bit and I succeeded with the following:

    sudo apt update
    sudo apt install xfonts-75dpi xfonts-base gvfs colord glew-utils libvisual-0.4-plugins gstreamer1.0-tools opus-tools qt5-image-formats-plugins qtwayland5 qt5-qmltooling-plugins librsvg2-bin lm-sensors
    sudo wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.stretch_amd64.deb
    sudo dpkg -i wkhtmltox_0.12.5-1.stretch_amd64.deb
    sudo cp /usr/local/bin/wkhtmltopdf /usr/bin/
    sudo cp /usr/local/bin/wkhtmltoimage /usr/bin/

Then check the installation with:

    wkhtmltopdf -V

Which should return:

    wkhtmltopdf 0.12.5 (with patched qt)


来源: stackexchange

问:
ionic 3 html5 p tag not expanding for size of text content css not working also
I am trying to make a html5 p tag display minimum 3 lines of a description inside an ionic 3 ion-item tag as shown below:

```<code>             <ion-item>
                <ion-avatar item-start>
                  <img src="{{company.logo_url}}" alt="company_logo" *ngIf="company.logo_url">
                </ion-avatar>
                <h2>{{ company.company_name }}</h2>
                <p class="desc-line">{{ company.description_short }}</p>
              </ion-item>

</code>```

The scss I tried to use was:

```<code>.desc-line {
    display:inline-block;
  }
</code>```

Which didn't work so I also tried:

```<code>.desc-line {
display: -webkit-box;
overflow : hidden;
text-overflow: ellipsis;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
}
</code>```

Now I have no idea of what to try next that will make sense and haven't found any other similar solutions.

答:
You are not doing anything wrong.

I have created a demo as well here on Stackblitz.

You just need to add white-space: normal; to your .label CSS. Moreover, Stackblitz has not allowed me to change .label in SCSS file so I have added inline style to ion-label element.

```<code>.item {
  .label {
    white-space: normal;
  }
}
</code>```

Please let me know if this helps.

ContentLicense: CC BY-SA 4.0

Body:
I am trying to make a html5 p tag display minimum 3 lines of a description inside an ionic 3 ion-item tag as shown below:

             <ion-item>
                <ion-avatar item-start>

                </ion-avatar>

{{ company.company_name }}

{{ company.description_short }}

              </ion-item>

The scss I tried to use was:

.desc-line {
    display:inline-block;
  }

Which didn't work so I also tried:

.desc-line {
display: -webkit-box;
overflow : hidden;
text-overflow: ellipsis;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
}

Now I have no idea of what to try next that will make sense and haven't found any other similar solutions.

Body:
You are not doing anything wrong.

I have created a demo as well here on Stackblitz.

You just need to add white-space: normal; to your .label CSS. Moreover, Stackblitz has not allowed me to change .label in SCSS file so I have added inline style to ion-label element.

.item {
  .label {
    white-space: normal;
  }
}

Please let me know if this helps.


问:
Executing Karate scenarios calling external JAR from VScode
I use Karate as standalone JAR, and for writing scenarios I've installed Visual Source Code with the "karate-runner" plugin as IDE support.
I use an external jar for encryption treatments.
The trouble is that, when I execute a Karate scenario from Visual Source Code (for debuggig purpose), my external jar is not taken into account, and during execution, I get the message "java.lang.ClassNotFoundException: GenerateSign" in the console.
I've no problem when I launch the scenario directly in command line like :

```<code>Karate.bat mytest.feature
</code>```

With the content of karate.bat is :

```<code>java -cp karate.jar;Sign.jar;. com.intuit.karate.Main %*
</code>```

So, how to configure the tools in order to execute my karate scenarios from VScode taking into account my external jar too?
Thanks a lot.

答:
Maybe you simply are on the wrong version. Dir you try 0.9.5 ?

Here are the instructions: https://marketplace.visualstudio.com/items?itemName=kirkslota.karate-runner

For those coming across this in the future, you can use this as an additional reference: https://github.com/intuit/karate/wiki/Karate-Robot-Windows-Install-Guide

Body:
I use Karate as standalone JAR, and for writing scenarios I've installed Visual Source Code with the "karate-runner" plugin as IDE support.
I use an external jar for encryption treatments.
The trouble is that, when I execute a Karate scenario from Visual Source Code (for debuggig purpose), my external jar is not taken into account, and during execution, I get the message "java.lang.ClassNotFoundException: GenerateSign" in the console.
I've no problem when I launch the scenario directly in command line like :

Karate.bat mytest.feature

With the content of karate.bat is :

java -cp karate.jar;Sign.jar;. com.intuit.karate.Main %*

So, how to configure the tools in order to execute my karate scenarios from VScode taking into account my external jar too?
Thanks a lot.


问:
How to add an option for js code in grapesjs?

Now I want my JS code also to be exported? How is this done?
I have seen that in the block manager if we edit the content as follows

```<code>editor.BlockManager.add("sample input field", {
  label: "input-field",
  category: "sample",
  content: {
            script:"my script"
           }
});

</code>```

the script is embedded in my HTML file but if I edit it as follows

```<code>content:` some HTML code
<script type="text/javascript" myscript></script>`
</code>```

I do not get the script content in my HTML file....how to get the script embedded in the content?
Why is it not being displayed in the extracted HTML file?

答:
Create a custom code. You can check the default view code, in that buildEditor function is there where all config is done.  Along with HTML, CSS, pass Js also</p>

```<code>const oHtmlEd = buildEditor('htmlmixed', 'hopscotch', 'HTML', editor);
const oCsslEd = buildEditor('css', 'hopscotch', 'CSS', editor);
const oJSlEd = buildEditor('js', 'hopscotch', 'JS', editor);
</code>```

Body:
Now I want my JS code also to be exported? How is this done?
I have seen that in the block manager if we edit the content as follows

editor.BlockManager.add("sample input field", {
  label: "input-field",
  category: "sample",
  content: {
            script:"my script"
           }
});

the script is embedded in my HTML file but if I edit it as follows

content:` some HTML code
`

I do not get the script content in my HTML file....how to get the script embedded in the content?
Why is it not being displayed in the extracted HTML file?

Body:
Create a custom code. You can check the default view code, in that buildEditor function is there where all config is done.  Along with HTML, CSS, pass Js also

const oHtmlEd = buildEditor('htmlmixed', 'hopscotch', 'HTML', editor);
const oCsslEd = buildEditor('css', 'hopscotch', 'CSS', editor);
const oJSlEd = buildEditor('js', 'hopscotch', 'JS', editor);


问:
Right overflowed by 23 pixels in flutter listview

I created a listview But it shows OVERFLOWED BY PIXELS ERROR

Here is the listview for you

```<code>return ListView.builder(

      itemCount: titles.length,
      itemBuilder: (context, index) {
        return Card(
            elevation: 50,
            child: InkWell(

              splashColor: Colors.green,
              highlightColor: Colors.red,
              child: Row(
                children: <Widget>[

              Container(

                height: 100.0,
                  width:50.0,

                decoration: BoxDecoration(
                    gradient:LinearGradientStyle.linearGradient(
                        orientation:LinearGradientStyle.ORIENTATION_HORIZONTAL,
                        gradientType: LinearGradientStyle.GRADIENT_TYPE_AMIN
                    )
                ),),

                  Container(
                      margin: EdgeInsets.all(10),
                      child: Text(
                        numbers[index],
                      )),

                  Container(
                    margin: EdgeInsets.all(10),
                    child: GradientText((titles[index]),
                      gradient:gradient,

                      style:TextStyle(fontSize:20.0,fontWeight:FontWeight.bold, ),
                    ),
                    //Text(titles[index]),
                  )
                ],
              ),
              onTap: () => onTaps[index](),
            ));
      });

</code>```

If you need more code please comment ...

Instead of Overflow error It should come to 2nd line of the list.If you have any solution then please help me....

答:
I had a similar issue with DropdownButton. I was trying to create a dropdown for questions and answers, for that I had to create DropdownButton for a custom model.

My life was saved by isExpanded: true,

```<code>List<Question> questions;

   Widget buildDropDown() {
    return DropdownButton<Question>(
      isExpanded: true,
      value: _selectedQuestion,
      style: TextStyle(color: Colors.white),
      items: questions.map<DropdownMenuItem<Question>>((Question question) {
        return DropdownMenuItem(
          child: Text(
            question.title,
          ),
          value: question,
        );
      }).toList(),
      onChanged: (Question question) {
        setState(() {
          _selectedQuestion = question;
        });
      },
    );
  }

class Question {
  String title;
  String answer;
  int id;

  Question({this.id, this.title});

  void setAnswer(String answer) {
    this.answer = answer;
  }
}
</code>```

Body:
I created a listview But it shows OVERFLOWED BY PIXELS ERROR

Here is the listview for you

return ListView.builder(

      itemCount: titles.length,
      itemBuilder: (context, index) {
        return Card(
            elevation: 50,
            child: InkWell(

              splashColor: Colors.green,
              highlightColor: Colors.red,
              child: Row(
                children: <Widget>[

              Container(

                height: 100.0,
                  width:50.0,

                decoration: BoxDecoration(
                    gradient:LinearGradientStyle.linearGradient(
                        orientation:LinearGradientStyle.ORIENTATION_HORIZONTAL,
                        gradientType: LinearGradientStyle.GRADIENT_TYPE_AMIN
                    )
                ),),

                  Container(
                      margin: EdgeInsets.all(10),
                      child: Text(
                        numbers[index],
                      )),

                  Container(
                    margin: EdgeInsets.all(10),
                    child: GradientText((titles[index]),
                      gradient:gradient,

                      style:TextStyle(fontSize:20.0,fontWeight:FontWeight.bold, ),
                    ),
                    //Text(titles[index]),
                  )
                ],
              ),
              onTap: () => onTaps[index](),
            ));
      });

If you need more code please comment ...

Instead of Overflow error It should come to 2nd line of the list.If you have any solution then please help me....

Body:
I had a similar issue with DropdownButton. I was trying to create a dropdown for questions and answers, for that I had to create DropdownButton for a custom model.

My life was saved by isExpanded: true,

List<Question> questions;

   Widget buildDropDown() {
    return DropdownButton<Question>(
      isExpanded: true,
      value: _selectedQuestion,
      style: TextStyle(color: Colors.white),
      items: questions.map<DropdownMenuItem<Question>>((Question question) {
        return DropdownMenuItem(
          child: Text(
            question.title,
          ),
          value: question,
        );
      }).toList(),
      onChanged: (Question question) {
        setState(() {
          _selectedQuestion = question;
        });
      },
    );
  }

class Question {
  String title;
  String answer;
  int id;

  Question({this.id, this.title});

  void setAnswer(String answer) {
    this.answer = answer;
  }
}


问:
altbeacon detection of beacon RSSI values continuously at 10Hz
I created an android (java) application that uses the altbeacon library (github page) to detect beacons via the Bluetooth module.

The Beacons are configured with Eddystone UID, protocol with an advertising interval of 100ms and transmit power level of strong (10dBm).
What I would like to be able to do is to detect the RSSI value of the beacons with a frequency of 10Hz (i.e. 100ms).

I've already prepared a service that implements the altbeacon library, the relevant part are showed below:

mBeaconManager = BeaconManager.getInstanceForApplication(this);

        beaconRegion = new Region("beacon_region", null, null, null);

        // use Eddystone protocol
        mBeaconManager.getBeaconParsers().add(new BeaconParser().
                setBeaconLayout(BeaconParser.EDDYSTONE_UID_LAYOUT));

        mBeaconManager.setAndroidLScanningDisabled(true);
        mBeaconManager.setForegroundScanPeriod(100l); // scan frequency
        mBeaconManager.setForegroundBetweenScanPeriod(0);
```

<p>and the callback <code>didRangeBeaconsInRegion</code> from which I see the beacons and get the RSSI value is this:</p>

<pre class="lang-java prettyprint-override"><code>@Override
    public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
        Log.i(BeaconDataCollectorService.class.getSimpleName(), String.format("Found %s beacons in range", beacons.size()));
    }
</code>```

What's my problem?
  Running the app, I notice that within didRangeBeaconsInRegion, I often don't see all the beacons.

I ran the data collection for a few seconds, creating a csv format of the data obtained, where you can see that I often have 0s (indicating that the beacon was not detected); I put the sharing of this csv on pastebin (https://pastebin.com/zkUZC5R4)

How can I improve the scan frequency by always being able to detect all the beacons?

altbeacon version used:

implementation 'org.altbeacon:android-beacon-library:2.16.3'
```

Android version: 9

Thanks

答:
Unfortunately, the library is not designed to do this, as the ranging APIs are modeled after iOS equivalents which give aggregate detections at fixed intervals as opposed to access to individual packets when they arrive.

The main reason you often get 0 beacons detected with such a short scan period is because the scan is turned on and off every 100ms, and it takes 10ms or so to start and stop. This gives a good probability of missing the detection.

Here's the good news: If the library ever detects two beacon packets in the same scan period then it will stop turning the scan off and your detection rate will improve. But getting it to detect two beacons in 100ms is nearly impossible of your beacon advertises at a nominal 10Hz.

One thing you might try is to start by setting the scan period to 1 second. After you have detected a finite number of your beacons for 10 secs or so, there is a very good chance you will have detected two beacons in one scan cycle and then you can switch to a scan period of 100ms and get a higher detection rate.

You will never get a 100% detection rate for two reasons:

Not all beacon packets transmitted are received due to collisions and radio noise. At close range 80-90% is typical.

"BLE advertisers do not advertise at regular intervals. They randomize when their packets are sent to avoid collisions. A nominal 10Hz transmitter might have anywhere between 70ms and 140ms between individual packets, so for fixed scan cycles of 100ms sometimes there will be 0, 1 or 2 Packers eligible to be received.

If you really need to get callbacks on every detection, you might try setting up a NonBeaconBleScanCallback in the BeaconManager, then calling BeaconManager.clearBeaconParsers(). This will cause all beacons detections to be sent to that callback immediately when detected. You will then have to construct a new BeaconParser for use inside that callback to decode the beacon from the raw packet. Use beaconParser.parse(...)

Body:
I created an android (java) application that uses the altbeacon library (github page) to detect beacons via the Bluetooth module.

The Beacons are configured with Eddystone UID, protocol with an advertising interval of 100ms and transmit power level of strong (10dBm).
What I would like to be able to do is to detect the RSSI value of the beacons with a frequency of 10Hz (i.e. 100ms).

I've already prepared a service that implements the altbeacon library, the relevant part are showed below:

mBeaconManager = BeaconManager.getInstanceForApplication(this);

        beaconRegion = new Region("beacon_region", null, null, null);

        // use Eddystone protocol
        mBeaconManager.getBeaconParsers().add(new BeaconParser().
                setBeaconLayout(BeaconParser.EDDYSTONE_UID_LAYOUT));

        mBeaconManager.setAndroidLScanningDisabled(true);
        mBeaconManager.setForegroundScanPeriod(100l); // scan frequency
        mBeaconManager.setForegroundBetweenScanPeriod(0);

and the callback didRangeBeaconsInRegion from which I see the beacons and get the RSSI value is this:

@Override
    public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
        Log.i(BeaconDataCollectorService.class.getSimpleName(), String.format("Found %s beacons in range", beacons.size()));
    }

What's my problem?
  Running the app, I notice that within didRangeBeaconsInRegion, I often don't see all the beacons.

I ran the data collection for a few seconds, creating a csv format of the data obtained, where you can see that I often have 0s (indicating that the beacon was not detected); I put the sharing of this csv on pastebin (https://pastebin.com/zkUZC5R4)

How can I improve the scan frequency by always being able to detect all the beacons?

altbeacon version used:

implementation 'org.altbeacon:android-beacon-library:2.16.3'

Android version: 9

Thanks


问:
How to direct the output of a process to stdout and pipe to another process in bash?
How to direct the output of a process to stdout and pipe to another process in bash?

I am using bash shell in mac

I have two python programs generate.py and sum.py

generate.py prints integers to stdout.

when run using python3 generate.py it generates

```<code>1
2
3
4
...
...
</code>```

sum.py just consumes the output of generate.py and keeps the counter and once the generate.py is done sum.py outputs the final value.

however when I run using the following bash command

python3 generate.py >&2 | python3 sum.py I cannot see the output of python3 sum.py

but if I do this python3 generate.py | python3 sum.py I can see the result from sum.py is printed to stdout but I dont see the output from generate.py in stdout.

so what I am looking is to see the output of both generate.py and sum.py while piping the data between them. any idea?

答:
I prefer this command:

```<code>( command1 | tee /dev/fd/3 | command2 ) 3>&1
</code>```

The advantage is, that the complete output is combined to stdout, and stderr as second channel is still intact. So this can be used as function or script with usual redirects outside.

Translated to your commands:

```<code>( python3 generate.py | tee /dev/fd/3 | python3 sum.py ) 3>&1
</code>```

Body:
How to direct the output of a process to stdout and pipe to another process in bash?

I am using bash shell in mac

I have two python programs generate.py and sum.py

generate.py prints integers to stdout.

when run using python3 generate.py it generates

1
2
3
4
...
...

sum.py just consumes the output of generate.py and keeps the counter and once the generate.py is done sum.py outputs the final value.

however when I run using the following bash command

python3 generate.py >&2 | python3 sum.py I cannot see the output of python3 sum.py

but if I do this python3 generate.py | python3 sum.py I can see the result from sum.py is printed to stdout but I dont see the output from generate.py in stdout.

so what I am looking is to see the output of both generate.py and sum.py while piping the data between them. any idea?

Body:
I prefer this command:

( command1 | tee /dev/fd/3 | command2 ) 3>&1

The advantage is, that the complete output is combined to stdout, and stderr as second channel is still intact. So this can be used as function or script with usual redirects outside.

Translated to your commands:

( python3 generate.py | tee /dev/fd/3 | python3 sum.py ) 3>&1


问:
How to display svg image on PDF file with jspdf in vuejs
how to add a logo properly in a pdf file with jspdf in vuejs?

I tried to use this addSvgAsImage function like this:

```<code>const doc = new jsPDF()
const logo = '/src/icons/svg/logo.svg'
doc.addSvgAsImage(logo, 20, 20, 50, 50, null, 'NONE', 0)
</code>```

and I have this error:

```<code>canvg is not defined
    at Object.et.addSvgAsImage
</code>```

答:
I finally used a png image like that:</p>
```<code>const logo = require('@/icons/png/logo.png')

const doc = new jsPDF()
var imgLogo = new Image()
imgLogo.src = logo
doc.addImage(imgLogo, 'PNG', xCord, yCord, 24, 8)
</code>```

Body:
how to add a logo properly in a pdf file with jspdf in vuejs?

I tried to use this addSvgAsImage function like this:

const doc = new jsPDF()
const logo = '/src/icons/svg/logo.svg'
doc.addSvgAsImage(logo, 20, 20, 50, 50, null, 'NONE', 0)

and I have this error:

canvg is not defined
    at Object.et.addSvgAsImage

Body:
I finally used a png image like that:

const logo = require('@/icons/png/logo.png')

const doc = new jsPDF()
var imgLogo = new Image()
imgLogo.src = logo
doc.addImage(imgLogo, 'PNG', xCord, yCord, 24, 8)


问:
How do I recover from failure when uploading multiple files via my server to S3?
New to NodeJS and S3, I wrote the following exploratory code to upload files to S3 via my NodeJS server without saving the file to disk or memory:

```<code>var express = require('express');
var Busboy = require('busboy');
var S3 = require('../utils/s3Util');
var router = express.Router(); // mounted at /uploads

router.post("/", function (req, res, next) {
    let bb = new Busboy({ headers: req.headers });
    const uploads = [];
    bb.on('file', (fieldname, stream, filename, encoding, mimeType) => {
        console.log(`Uploaded fieldname: ${fieldname}; filename: ${filename}, mimeType: ${mimeType}`);
        uploads.push(S3.svc.upload({ Bucket: 'my-test-bucket', Key: filename, Body: stream }).promise());
    });
    bb.on('finish', () => {
        console.log("# of promises:", uploads.length);
        Promise.all(uploads).then(retVals => {
            for (let i = 0; retVals && i < retVals.length; i++) {
                console.log(`File ${i + 1}::`, retVals[i]);
            }
            res.end();
        }).catch(err => {
            console.log("Error::", err);
            res.status(500).send(`${err.name}: ${err.message}`);
        });
    });
    req.pipe(bb);
});

module.exports = router;
</code>```

In the general failure case, how do I handle the scenario where the upload of 1 or more of x files being uploaded fails? Some uploads would have succeeded, some would have failed. However, in the catch clause I wouldn't know which ones have failed...

It would be good to be able to make this upload process somewhat transactional (i.e., either all uploads succeed, or none do). When errors happen, ideally I would be able to "rollback" the subset of successful uploads.

答:
I finally went with the following code, which is an expansion of @JoshWulf's answer:

```<code>function handleUpload(req, res, bucket, key) {
    let bb = new Busboy({ headers: req.headers });
    const uploads = [];
    bb.on('file', (fieldname, stream, filename, encoding, mimeType) => {
        console.log(`Uploaded fieldname: ${fieldname}; filename: ${filename}, mimeType: ${mimeType}`);
        const params = { Bucket: bucket, Key: key, Body: stream, ContentType: mimeType };
        uploads.push({ filename, result: S3.svc.upload(params).promise().then(data => data).catch(err => err) });
    });
    bb.on('finish', async () => {
        const results = await Promise.all(uploads.map(async (upload) => ({ ...upload, result: await upload.result })));
        // handle success/failure with their respective objects
    });
    req.pipe(bb);
}
</code>```

The difference here from @Josh Wulf's answer is that in my upload promise I am returning the returned data object (if successful) and the returned error object (in case of failure) as-is. This then enables me to later use them as I need.

Body:
New to NodeJS and S3, I wrote the following exploratory code to upload files to S3 via my NodeJS server without saving the file to disk or memory:

var express = require('express');
var Busboy = require('busboy');
var S3 = require('../utils/s3Util');
var router = express.Router(); // mounted at /uploads

router.post("/", function (req, res, next) {
    let bb = new Busboy({ headers: req.headers });
    const uploads = [];
    bb.on('file', (fieldname, stream, filename, encoding, mimeType) => {
        console.log(`Uploaded fieldname: ${fieldname}; filename: ${filename}, mimeType: ${mimeType}`);
        uploads.push(S3.svc.upload({ Bucket: 'my-test-bucket', Key: filename, Body: stream }).promise());
    });
    bb.on('finish', () => {
        console.log("# of promises:", uploads.length);
        Promise.all(uploads).then(retVals => {
            for (let i = 0; retVals && i < retVals.length; i++) {
                console.log(`File ${i + 1}::`, retVals[i]);
            }
            res.end();
        }).catch(err => {
            console.log("Error::", err);
            res.status(500).send(`${err.name}: ${err.message}`);
        });
    });
    req.pipe(bb);
});

module.exports = router;

In the general failure case, how do I handle the scenario where the upload of 1 or more of x files being uploaded fails? Some uploads would have succeeded, some would have failed. However, in the catch clause I wouldn't know which ones have failed...

It would be good to be able to make this upload process somewhat transactional (i.e., either all uploads succeed, or none do). When errors happen, ideally I would be able to "rollback" the subset of successful uploads.

Body:
I finally went with the following code, which is an expansion of @JoshWulf's answer:

function handleUpload(req, res, bucket, key) {
    let bb = new Busboy({ headers: req.headers });
    const uploads = [];
    bb.on('file', (fieldname, stream, filename, encoding, mimeType) => {
        console.log(`Uploaded fieldname: ${fieldname}; filename: ${filename}, mimeType: ${mimeType}`);
        const params = { Bucket: bucket, Key: key, Body: stream, ContentType: mimeType };
        uploads.push({ filename, result: S3.svc.upload(params).promise().then(data => data).catch(err => err) });
    });
    bb.on('finish', async () => {
        const results = await Promise.all(uploads.map(async (upload) => ({ ...upload, result: await upload.result })));
        // handle success/failure with their respective objects
    });
    req.pipe(bb);
}

The difference here from @Josh Wulf's answer is that in my upload promise I am returning the returned data object (if successful) and the returned error object (in case of failure) as-is. This then enables me to later use them as I need.


问:
What tool do you use for developing and administrating your database?
I have always used TOAD by Quest to do my development and administration work in Oracle and MS SQL Server. However, I am trying not to be myopic in my choices. Are there other tools that you would recommend that will allow me to connect to the database(s) and perform my development and administrative duties?</p>

答:
For Oracle (and MySQL it appears) you can use Oracle's free "SQL Developer", which being Java also runs on Mac OS X and Linux.

For PostgreSQL there is phpPgAdmin for an online solution, and the equivalent for MySQL. There are stand-alone applications like PgAdmin3 as well, but I haven't used them for a long time, having preferred the psql command line interface.

OwnerDisplayName: Ascalonian

ContentLicense: CC BY-SA 2.5

OwnerDisplayName: JeeBee


问:
Are there any other ways to record iotcl calls besides strace?
I'm trying to see if certain ioctl calls get called when I call a function(this is on linux).There no way to cause the kernel to write a log with this sort of data, is there?</p>

答:
On recent kernel, and if kernel is configured with support for tracing and dynamic tracing, ftrace can probably do what you need.

Another option is to write an ioctl wrapper, load it using LD_PRELOAD, and intercept the interesting ioctl in your wrapper.

ContentLicense: CC BY-SA 3.0


问:
Finding if a property inside a list inside a list doesnt contain a specific string
I have a huge product database im working with threw a api

The API returns a Product those Products have MetaData which are stuff like minQuantities Maxes ect

Now I noticed some products dont have "variation_maximum_allowed_quantity" or " maximum_allowed_quantity"

So for every Product I have to look threw That Products meta data to so something like

```<code> foreach (var item in VarProduct)
 {
   foreach (var metaItem in item.meta_data)
    {

    }

 }
</code>```

The issue is meta_data have Key's Id's and value's I need to check against every key inside of every meta_data inside of every Product if that makes sense? Im wrecking my brain atm, Anyone know how I can check against all of those to see if those 2 Strings are missing? I need to be able to do something like

```<code>if(mdDoesntcontain)
{
 //This means stock is Unlimiteed so need to set a value for stock
   item.stockquantity = 9999999; (or int.maxValue())
}

</code>```

Little tricky Posting this as a Block but:

```<code>
-item.meta_data count = w.e
 -[0]
   -base
     -id = 101231
     -key = "min_max_rules"
     -value = "no"

 -[1]
   -base
     -id = 123131
     -key = "variation_minimum_allowed_quantity"
     -value = ""(this means 1 usually)

</code>```

```<code>public class MetaData
{
    private object preValue;

    [DataMember (EmitDefaultValue = false)]
    public int? id {
        get;
        set;
    }

    [DataMember (EmitDefaultValue = false)]
    public string key {
        get;
        set;
    }

    [DataMember (EmitDefaultValue = false)]
    public object value {
        get;
        set;
    }
</code>```

答:
Would this be the solution you're looking for?</p>

```<code>foreach (var item in VarProduct)
{
    var hasQuantity = false;
    foreach (var metaItem in item.meta_data)
    {
        if (metaItem.key == "variation_maximum_allowed_quantity" || metaItem.key == "maximum_allowed_quantity") {
            item.stockQuantity = metaItem.value == "" ? 1 : int.Parse(metaItem.value);
            hasQuantity = true;
            break;
        }
    }
    if(!hasQuantity) {
        item.stockQuantity = int.MaxValue;
    }
}
</code>```

Body:
I have a huge product database im working with threw a api

The API returns a Product those Products have MetaData which are stuff like minQuantities Maxes ect

Now I noticed some products dont have "variation_maximum_allowed_quantity" or " maximum_allowed_quantity"

So for every Product I have to look threw That Products meta data to so something like

 foreach (var item in VarProduct)
 {
   foreach (var metaItem in item.meta_data)
    {

    }

 }

The issue is meta_data have Key's Id's and value's I need to check against every key inside of every meta_data inside of every Product if that makes sense? Im wrecking my brain atm, Anyone know how I can check against all of those to see if those 2 Strings are missing? I need to be able to do something like

if(mdDoesntcontain)
{
 //This means stock is Unlimiteed so need to set a value for stock
   item.stockquantity = 9999999; (or int.maxValue())
}

Little tricky Posting this as a Block but:

-item.meta_data count = w.e
 -[0]
   -base
     -id = 101231
     -key = "min_max_rules"
     -value = "no"

 -[1]
   -base
     -id = 123131
     -key = "variation_minimum_allowed_quantity"
     -value = ""(this means 1 usually)

public class MetaData
{
    private object preValue;

    [DataMember (EmitDefaultValue = false)]
    public int? id {
        get;
        set;
    }

    [DataMember (EmitDefaultValue = false)]
    public string key {
        get;
        set;
    }

    [DataMember (EmitDefaultValue = false)]
    public object value {
        get;
        set;
    }

Body:
Would this be the solution you're looking for?

foreach (var item in VarProduct)
{
    var hasQuantity = false;
    foreach (var metaItem in item.meta_data)
    {
        if (metaItem.key == "variation_maximum_allowed_quantity" || metaItem.key == "maximum_allowed_quantity") {
            item.stockQuantity = metaItem.value == "" ? 1 : int.Parse(metaItem.value);
            hasQuantity = true;
            break;
        }
    }
    if(!hasQuantity) {
        item.stockQuantity = int.MaxValue;
    }
}


问:
Getting error while getting view of RecyclerView in onActivityCreated()
I am following a tutorial on Udemy using RecyclerView using Fragments. Everything works fine until this line 44 recyclerView = view.findViewById(R.id.rcl)

I searched a lot on internet but did not get any solution related to this. I debugged the code and view was null. Either there was a problem in that tutorial or only i am having the problem.

1- Fragment_list.xml

```<code><?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".ListFrag">

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/rcl"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
</LinearLayout>
</code>```

2- ListFrag.jave

```<code> @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_list, container, false);
    // Inflate the layout for this fragment
    return view;
}

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    recyclerView = view.findViewById(R.id.rcl);
    recyclerView.setHasFixedSize(true);
    layoutManager = new LinearLayoutManager(this.getActivity());
    recyclerView.setLayoutManager(layoutManager);
    adapter = new PersonAdapter(this.getActivity(), ApplicationClass.people);
    recyclerView.setAdapter(adapter);
}
</code>```

3- This is the Error :

```<code>Error :
    java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.view.View.findViewById(int)' on a null object reference
            at com.example.recyclerfragments.ListFrag.onActivityCreated(ListFrag.java:44)
            at androidx.fragment.app.Fragment.performActivityCreated(Fragment.java:2619)
            at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:904)
            at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1238)
            at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1303)
            at androidx.fragment.app.FragmentManagerImpl.dispatchStateChange(FragmentManagerImpl.java:2659)
            at androidx.fragment.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManagerImpl.java:2613)
            at androidx.fragment.app.FragmentController.dispatchActivityCreated(FragmentController.java:246)
            at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:542)
            at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:201)
            at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1391)
            at android.app.Activity.performStart(Activity.java:7214)
            at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3189)
            at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:185)
            at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:170)
            at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:147)
            at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:73)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2031)
            at android.os.Handler.dispatchMessage(Handler.java:106)
            at android.os.Looper.loop(Looper.java:224)
            at android.app.ActivityThread.main(ActivityThread.java:7083)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:536)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:928)
</code>```

答:
You are initializing view in onCreateView but using view  recyclerView = view.findViewById(R.id.rcl); in  onActivityCreated, thats why you are getting error.

There are multiple ways to resolve this error:

First One:

```<code>private RecyclerView mRecyclerView;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_list, container, false);
        recyclerView = view.findViewById(R.id.rcl);

        recyclerView.setHasFixedSize(true);
        layoutManager = new LinearLayoutManager(this.getActivity());
        recyclerView.setLayoutManager(layoutManager);
        adapter = new PersonAdapter(this.getActivity(), ApplicationClass.people);
        recyclerView.setAdapter(adapter);
        return view;
        }
</code>```

2nd :

```<code>private RecyclerView mRecyclerView;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_list, container, false);
        recyclerView = view.findViewById(R.id.rcl);
        return view;
        }

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);

        recyclerView.setHasFixedSize(true);
        layoutManager = new LinearLayoutManager(this.getActivity());
        recyclerView.setLayoutManager(layoutManager);
        adapter = new PersonAdapter(this.getActivity(), ApplicationClass.people);
        recyclerView.setAdapter(adapter);
        }
</code>```

Body:
I am following a tutorial on Udemy using RecyclerView using Fragments. Everything works fine until this line 44 recyclerView = view.findViewById(R.id.rcl)

I searched a lot on internet but did not get any solution related to this. I debugged the code and view was null. Either there was a problem in that tutorial or only i am having the problem.

1- Fragment_list.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".ListFrag">

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/rcl"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
</LinearLayout>

2- ListFrag.jave

 @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_list, container, false);
    // Inflate the layout for this fragment
    return view;
}

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    recyclerView = view.findViewById(R.id.rcl);
    recyclerView.setHasFixedSize(true);
    layoutManager = new LinearLayoutManager(this.getActivity());
    recyclerView.setLayoutManager(layoutManager);
    adapter = new PersonAdapter(this.getActivity(), ApplicationClass.people);
    recyclerView.setAdapter(adapter);
}

3- This is the Error :

Error :
    java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.view.View.findViewById(int)' on a null object reference
            at com.example.recyclerfragments.ListFrag.onActivityCreated(ListFrag.java:44)
            at androidx.fragment.app.Fragment.performActivityCreated(Fragment.java:2619)
            at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:904)
            at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1238)
            at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1303)
            at androidx.fragment.app.FragmentManagerImpl.dispatchStateChange(FragmentManagerImpl.java:2659)
            at androidx.fragment.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManagerImpl.java:2613)
            at androidx.fragment.app.FragmentController.dispatchActivityCreated(FragmentController.java:246)
            at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:542)
            at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:201)
            at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1391)
            at android.app.Activity.performStart(Activity.java:7214)
            at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3189)
            at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:185)
            at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:170)
            at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:147)
            at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:73)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2031)
            at android.os.Handler.dispatchMessage(Handler.java:106)
            at android.os.Looper.loop(Looper.java:224)
            at android.app.ActivityThread.main(ActivityThread.java:7083)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:536)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:928)

Body:
You are initializing view in onCreateView but using view  recyclerView = view.findViewById(R.id.rcl); in  onActivityCreated, thats why you are getting error.

There are multiple ways to resolve this error:

First One:

private RecyclerView mRecyclerView;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_list, container, false);
        recyclerView = view.findViewById(R.id.rcl);

        recyclerView.setHasFixedSize(true);
        layoutManager = new LinearLayoutManager(this.getActivity());
        recyclerView.setLayoutManager(layoutManager);
        adapter = new PersonAdapter(this.getActivity(), ApplicationClass.people);
        recyclerView.setAdapter(adapter);
        return view;
        }

2nd :

private RecyclerView mRecyclerView;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_list, container, false);
        recyclerView = view.findViewById(R.id.rcl);
        return view;
        }

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);

        recyclerView.setHasFixedSize(true);
        layoutManager = new LinearLayoutManager(this.getActivity());
        recyclerView.setLayoutManager(layoutManager);
        adapter = new PersonAdapter(this.getActivity(), ApplicationClass.people);
        recyclerView.setAdapter(adapter);
        }


问:
How to create multiple mount points with different playlists in icecast with mpd?
I have installed icecast and MPD with YMPD client on the server.

Currently It is running for single mount. I want to stream audio on different mounting like: /stream.ogg, /mp3, /audio with different playlists.

Below is my config files:

1. mpd.conf:

```<code># An example configuration file for MPD.
# Read the user manual for documentation: http://www.musicpd.org/doc/user/
# or /usr/share/doc/mpd/user-manual.html

# Files and directories #######################################################
#
# This setting controls the top directory which MPD will search to discover the
# available audio files and add them to the daemon's online database. This
# setting defaults to the XDG directory, otherwise the music directory will be
# be disabled and audio files will only be accepted over ipc socket (using
# file:// protocol) or streaming files over an accepted protocol.
#
music_directory     "/var/lib/mpd/music"
#
# This setting sets the MPD internal playlist directory. The purpose of this
# directory is storage for playlists created by MPD. The server will use
# playlist files not created by the server but only if they are in the MPD
# format. This setting defaults to playlist saving being disabled.
#
playlist_directory      "/var/lib/mpd/playlists"
#
# This setting sets the location of the MPD database. This file is used to
# load the database at server start up and store the database while the
# server is not up. This setting defaults to disabled which will allow
# MPD to accept files over ipc socket (using file:// protocol) or streaming
# files over an accepted protocol.
#
db_file         "/var/lib/mpd/tag_cache"
#
# These settings are the locations for the daemon log files for the daemon.
# These logs are great for troubleshooting, depending on your log_level
# settings.
#
# The special value "syslog" makes MPD use the local syslog daemon. This
# setting defaults to logging to syslog, otherwise logging is disabled.
#
log_file            "/var/log/mpd/mpd.log"
#
# This setting sets the location of the file which stores the process ID
# for use of mpd --kill and some init scripts. This setting is disabled by
# default and the pid file will not be stored.
#
pid_file            "/run/mpd/pid"
#
# This setting sets the location of the file which contains information about
# most variables to get MPD back into the same general shape it was in before
# it was brought down. This setting is disabled by default and the server
# state will be reset on server start up.
#
state_file          "/var/lib/mpd/state"
#
# The location of the sticker database.  This is a database which
# manages dynamic information attached to songs.
#
sticker_file                   "/var/lib/mpd/sticker.sql"
#
###############################################################################

# General music daemon options ################################################
#
# This setting specifies the user that MPD will run as. MPD should never run as
# root and you may use this setting to make MPD change its user ID after
# initialization. This setting is disabled by default and MPD is run as the
# current user.
#
#user               "mpd"
#
# This setting specifies the group that MPD will run as. If not specified
# primary group of user specified with "user" setting will be used (if set).
# This is useful if MPD needs to be a member of group such as "audio" to
# have permission to use sound card.
#
#group                          "nogroup"
#
# This setting sets the address for the daemon to listen on. Careful attention
# should be paid if this is assigned to anything other then the default, any.
# This setting can deny access to control of the daemon. Choose any if you want
# to have mpd listen on every address. Not effective if systemd socket
# activation is in use.
#
# For network
bind_to_address     "127.0.0.1"
#
# And for Unix Socket
#bind_to_address        "/run/mpd/socket"
#
# This setting is the TCP port that is desired for the daemon to get assigned
# to.
#
port                "6600"
#
# This setting controls the type of information which is logged. Available
# setting arguments are "default", "secure" or "verbose". The "verbose" setting
# argument is recommended for troubleshooting, though can quickly stretch
# available resources on limited hardware storage.
#
#log_level          "default"
#
# If you have a problem with your MP3s ending abruptly it is recommended that
# you set this argument to "no" to attempt to fix the problem. If this solves
# the problem, it is highly recommended to fix the MP3 files with vbrfix
# (available as vbrfix in the debian archive), at which
# point gapless MP3 playback can be enabled.
#
#gapless_mp3_playback           "yes"
#
# Setting "restore_paused" to "yes" puts MPD into pause mode instead
# of starting playback after startup.
#
#restore_paused "no"
#
# This setting enables MPD to create playlists in a format usable by other
# music players.
#
#save_absolute_paths_in_playlists   "no"
#
# This setting defines a list of tag types that will be extracted during the
# audio file discovery process. The complete list of possible values can be
# found in the mpd.conf man page.
#metadata_to_use    "artist,album,title,track,name,genre,date,composer,performer,disc"
#
# This setting enables automatic update of MPD's database when files in
# music_directory are changed.
#
#auto_update    "yes"
#
# Limit the depth of the directories being watched, 0 means only watch
# the music directory itself.  There is no limit by default.
#
#auto_update_depth "3"
#
###############################################################################

# Symbolic link behavior ######################################################
#
# If this setting is set to "yes", MPD will discover audio files by following
# symbolic links outside of the configured music_directory.
#
#follow_outside_symlinks    "yes"
#
# If this setting is set to "yes", MPD will discover audio files by following
# symbolic links inside of the configured music_directory.
#
#follow_inside_symlinks     "yes"
#
###############################################################################

# Zeroconf / Avahi Service Discovery ##########################################
#
# If this setting is set to "yes", service information will be published with
# Zeroconf / Avahi.
#
#zeroconf_enabled       "yes"
#
# The argument to this setting will be the Zeroconf / Avahi unique name for
# this MPD server on the network.
#
#zeroconf_name          "Music Player"
#
###############################################################################

# Permissions #################################################################
#
# If this setting is set, MPD will require password authorization. The password
# can setting can be specified multiple times for different password profiles.
#
#password                        "password@read,add,control,admin"
#
# This setting specifies the permissions a user has who has not yet logged in.
#
default_permissions             "read,add,control,admin"
#
###############################################################################

# Database #######################################################################
#

#database {
#       plugin "proxy"
#       host "other.mpd.host"
#       port "6600"
#}

# Input #######################################################################
#

input {
        plugin "curl"
#       proxy "proxy.isp.com:8080"
#       proxy_user "user"
#       proxy_password "password"
}

#
###############################################################################

# Audio Output ################################################################
#
# MPD supports various audio output types, as well as playing through multiple
# audio outputs at the same time, through multiple audio_output settings
# blocks. Setting this block is optional, though the server will only attempt
# autodetection for one sound card.
#
# An example of an ALSA output:
#
audio_output {
    type        "alsa"
    name        "My ALSA Device"
#   device      "hw:0,0"    # optional
#   mixer_type      "hardware"      # optional
#   mixer_device    "default"   # optional
#   mixer_control   "PCM"       # optional
#   mixer_index "0"     # optional
}
#
# An example of an OSS output:
#
#audio_output {
#   type        "oss"
#   name        "My OSS Device"
#   device      "/dev/dsp"  # optional
#   mixer_type      "hardware"      # optional
#   mixer_device    "/dev/mixer"    # optional
#   mixer_control   "PCM"       # optional
#}
#
# An example of a shout output (for streaming to Icecast):
#
audio_output {
    type        "shout"
    encoding    "mp3"           # optional
    name        "My Shout Stream"
    host        "localhost"
    port        "8000"
    bind_to_address "127.0.0.1"
    mount       "/mp3"
    password    "4getme!"
    quality     "5.0"
#   bitrate     "128"
    format      "44100:16:1"
#   protocol    "icecast2"      # optional
#   user        "USER"      # optional
    description "My Stream Description" # optional
#   url             "http://example.com"    # optional
#   genre       "jazz"          # optional
#   public      "no"            # optional
#   timeout     "2"         # optional
#   mixer_type      "software"              # optional
}
#
# An example of a recorder output:
#
#audio_output {
#       type            "recorder"
#       name            "My recorder"
#       encoder         "vorbis"                # optional, vorbis or lame
#       path            "/var/lib/mpd/recorder/mpd.ogg"
##      quality         "5.0"                   # do not define if bitrate is defined
#       bitrate         "128"                   # do not define if quality is defined
#       format          "44100:16:1"
#}
#
# An example of a httpd output (built-in HTTP streaming server):
#
#audio_output {
#   type        "httpd"
#   name        "My HTTP Stream"
#   encoder     "vorbis"        # optional, vorbis or lame
#   port        "8000"
#   bind_to_address "0.0.0.0"               # optional, IPv4 or IPv6
#   quality     "5.0"           # do not define if bitrate is defined
#   bitrate     "128"           # do not define if quality is defined
#   format      "44100:16:1"
#   max_clients     "0"                     # optional 0=no limit
#}
#
# An example of a pulseaudio output (streaming to a remote pulseaudio server)
# Please see README.Debian if you want mpd to play through the pulseaudio
# daemon started as part of your graphical desktop session!
#
audio_output {
    type        "pulse"
    name        "My Pulse Output"
#   server      "remote_server"     # optional
#   sink        "remote_server_sink"    # optional
}
#
# An example of a winmm output (Windows multimedia API).
#
#audio_output {
#   type        "winmm"
#   name        "My WinMM output"
#   device      "Digital Audio (S/PDIF) (High Definition Audio Device)" # optional
#       or
#   device      "0"     # optional
#   mixer_type  "hardware"  # optional
#}
#
# An example of an openal output.
#
#audio_output {
#   type        "openal"
#   name        "My OpenAL output"
#   device      "Digital Audio (S/PDIF) (High Definition Audio Device)" # optional
#}
#
## Example "pipe" output:
#
#audio_output {
#   type        "pipe"
#   name        "my pipe"
#   command     "aplay -f cd 2>/dev/null"
## Or if you're want to use AudioCompress
#   command     "AudioCompress -m | aplay -f cd 2>/dev/null"
## Or to send raw PCM stream through PCM:
#   command     "nc example.org 8765"
#   format      "44100:16:2"
#}
#
## An example of a null output (for no audio output):
#
#audio_output {
#   type        "null"
#   name        "My Null Output"
#   mixer_type      "none"                  # optional
#}
#
# If MPD has been compiled with libsamplerate support, this setting specifies
# the sample rate converter to use.  Possible values can be found in the
# mpd.conf man page or the libsamplerate documentation. By default, this is
# setting is disabled.
#
#samplerate_converter       "Fastest Sinc Interpolator"
#
###############################################################################

# Normalization automatic volume adjustments ##################################
#
# This setting specifies the type of ReplayGain to use. This setting can have
# the argument "off", "album", "track" or "auto". "auto" is a special mode that
# chooses between "track" and "album" depending on the current state of
# random playback. If random playback is enabled then "track" mode is used.
# See <http://www.replaygain.org> for more details about ReplayGain.
# This setting is off by default.
#
#replaygain         "album"
#
# This setting sets the pre-amp used for files that have ReplayGain tags. By
# default this setting is disabled.
#
#replaygain_preamp      "0"
#
# This setting sets the pre-amp used for files that do NOT have ReplayGain tags.
# By default this setting is disabled.
#
#replaygain_missing_preamp  "0"
#
# This setting enables or disables ReplayGain limiting.
# MPD calculates actual amplification based on the ReplayGain tags
# and replaygain_preamp / replaygain_missing_preamp setting.
# If replaygain_limit is enabled MPD will never amplify audio signal
# above its original level. If replaygain_limit is disabled such amplification
# might occur. By default this setting is enabled.
#
#replaygain_limit       "yes"
#
# This setting enables on-the-fly normalization volume adjustment. This will
# result in the volume of all playing audio to be adjusted so the output has
# equal "loudness". This setting is disabled by default.
#
#volume_normalization       "no"
#
###############################################################################

# Character Encoding ##########################################################
#
# If file or directory names do not display correctly for your locale then you
# may need to modify this setting.
#
filesystem_charset      "UTF-8"
#
# This setting controls the encoding that ID3v1 tags should be converted from.
#
id3v1_encoding          "UTF-8"
#
###############################################################################

# SIDPlay decoder #############################################################
#
# songlength_database:
#  Location of your songlengths file, as distributed with the HVSC.
#  The sidplay plugin checks this for matching MD5 fingerprints.
#  See http://www.c64.org/HVSC/DOCUMENTS/Songlengths.faq
#
# default_songlength:
#  This is the default playing time in seconds for songs not in the
#  songlength database, or in case you're not using a database.
#  A value of 0 means play indefinitely.
#
# filter:
#  Turns the SID filter emulation on or off.
#
#decoder {
#       plugin                  "sidplay"
#       songlength_database     "/media/C64Music/DOCUMENTS/Songlengths.txt"
#       default_songlength      "120"
#       filter "true"
#}
#
###############################################################################
</code>```

2. icecast.xml

```<code><icecast>
    <!-- location and admin are two arbitrary strings that are e.g. visible
         on the server info page of the icecast web interface
         (server_version.xsl). -->
    <location>Earth</location>
    <admin>icemaster@localhost</admin>

    <!-- IMPORTANT!
         Especially for inexperienced users:
         Start out by ONLY changing all passwords and restarting Icecast.
         For detailed setup instructions please refer to the documentation.
         It's also available here: http://icecast.org/docs/
    -->

    <limits>
        <clients>100</clients>
        <sources>2</sources>
        <queue-size>524288</queue-size>
        <client-timeout>30</client-timeout>
        <header-timeout>15</header-timeout>
        <source-timeout>10</source-timeout>
        <!-- If enabled, this will provide a burst of data when a client
             first connects, thereby significantly reducing the startup
             time for listeners that do substantial buffering. However,
             it also significantly increases latency between the source
             client and listening client.  For low-latency setups, you
             might want to disable this. -->
        <burst-on-connect>1</burst-on-connect>
        <!-- same as burst-on-connect, but this allows for being more
             specific on how much to burst. Most people won't need to
             change from the default 64k. Applies to all mountpoints  -->
        <burst-size>65535</burst-size>
    </limits>

    <authentication>
        <!-- Sources log in with username 'source' -->
        <source-password>4getme!</source-password>
        <!-- Relays log in with username 'relay' -->
        <relay-password>4getme!</relay-password>

        <!-- Admin logs in with the username given below -->
        <admin-user>admin</admin-user>
        <admin-password>4getme!</admin-password>
    </authentication>

    <!-- set the mountpoint for a shoutcast source to use, the default if not
         specified is /stream but you can change it here if an alternative is
         wanted or an extension is required
    <shoutcast-mount>/live.nsv</shoutcast-mount>
    -->

    <!-- Uncomment this if you want directory listings -->

    <directory>
        <yp-url-timeout>15</yp-url-timeout>
        <yp-url>/var/lib/mpd/music</yp-url>
    </directory>
    -->
    <!-- This is the hostname other people will use to connect to your server.
         It affects mainly the urls generated by Icecast for playlists and yp
         listings. You MUST configure it properly for YP listings to work!
    -->
    <hostname>localhost</hostname>

    <!-- You may have multiple <listener> elements -->
    <listen-socket>
        <port>8000</port>
        <!-- <bind-address>127.0.0.1</bind-address> -->
        <!-- <shoutcast-mount>/stream</shoutcast-mount> -->
    </listen-socket>

    <listen-socket>
        <port>8005</port>
    <bind-address>127.0.0.1</bind-address>
        <shoutcast-mount>/stream</shoutcast-mount>
    </listen-socket>

    <listen-socket>
        <port>8006</port>
    </listen-socket>

    <listen-socket>
        <port>8007</port>
        <shoutcast-mount>/live.mp3</shoutcast-mount>
    </listen-socket>

    <!--
    <listen-socket>
        <port>8443</port>
        <ssl>1</ssl>
    </listen-socket>
    -->

    <!-- Global header settings
         Headers defined here will be returned for every HTTP request to Icecast.

         The ACAO header makes Icecast public content/API by default
         This will make streams easier embeddable (some HTML5 functionality needs it).
         Also it allows direct access to e.g. /status-json.xsl from other sites.
         If you don't want this, comment out the following line or read up on CORS.
    -->
    <http-headers>
        <header name="Access-Control-Allow-Origin" value="*" />
    </http-headers>

    <!-- Relaying
         You don't need this if you only have one server.
         Please refer to the config for a detailed explanation.
    -->
    <!--<master-server>127.0.0.1</master-server>-->
    <!--<master-server-port>8001</master-server-port>-->
    <!--<master-update-interval>120</master-update-interval>-->
    <!--<master-password>hackme</master-password>-->

    <!-- setting this makes all relays on-demand unless overridden, this is
         useful for master relays which do not have <relay> definitions here.
         The default is 0 -->
    <!--<relays-on-demand>1</relays-on-demand>-->

    <!--
    <relay>
        <server>127.0.0.1</server>
        <port>8080</port>
        <mount>/example.ogg</mount>
        <local-mount>/different.ogg</local-mount>
        <on-demand>0</on-demand>

        <relay-shoutcast-metadata>0</relay-shoutcast-metadata>
    </relay>
    -->

    <!-- Mountpoints
         Only define <mount> sections if you want to use advanced options,
         like alternative usernames or passwords
    -->

    <!-- Default settings for all mounts that don't have a specific <mount type="normal">.
    -->
    <!--
    <mount type="default">
        <public>0</public>
        <intro>/server-wide-intro.ogg</intro>
        <max-listener-duration>3600</max-listener-duration>
        <authentication type="url">
                <option name="mount_add" value="http://auth.example.org/stream_start.php"/>
        </authentication>
        <http-headers>
                <header name="foo" value="bar" />
        </http-headers>
    </mount>
    -->

    <!-- Normal mounts -->

    <mount type="normal">
        <mount-name>/stream.ogg</mount-name>

        <username>admin</username>
        <password>4getme!</password>

        <max-listeners>1</max-listeners>
        <dump-file>/tmp/dump-example1.ogg</dump-file>
        <burst-size>65536</burst-size>
        <fallback-mount>/example2.ogg</fallback-mount>
        <fallback-override>1</fallback-override>
        <fallback-when-full>1</fallback-when-full>
        <intro>/example_intro.ogg</intro>
        <hidden>1</hidden>
        <public>1</public>
        <authentication type="htpasswd">
                <option name="filename" value="myauth"/>
                <option name="allow_duplicate_users" value="0"/>
        </authentication>
        <http-headers>
                <header name="Access-Control-Allow-Origin" value="http://webplayer.example.org" />
                <header name="baz" value="quux" />
        </http-headers>
        <on-connect>/home/icecast/bin/stream-start</on-connect>
        <on-disconnect>/home/icecast/bin/stream-stop</on-disconnect>
    </mount>

    <!--
    <mount type="normal">
        <mount-name>/auth_example.ogg</mount-name>
        <authentication type="url">
            <option name="mount_add"       value="http://myauthserver.net/notify_mount.php"/>
            <option name="mount_remove"    value="http://myauthserver.net/notify_mount.php"/>
            <option name="listener_add"    value="http://myauthserver.net/notify_listener.php"/>
            <option name="listener_remove" value="http://myauthserver.net/notify_listener.php"/>
            <option name="headers"         value="x-pragma,x-token"/>
            <option name="header_prefix"   value="ClientHeader."/>
        </authentication>
    </mount>
    -->

    <fileserve>1</fileserve>

    <paths>
        <!-- basedir is only used if chroot is enabled -->
        <basedir>/usr/share/icecast2</basedir>

        <!-- Note that if <chroot> is turned on below, these paths must both
             be relative to the new root, not the original root -->
        <logdir>/var/log/icecast2</logdir>
        <webroot>/usr/share/icecast2/web</webroot>
        <adminroot>/usr/share/icecast2/admin</adminroot>
        <pidfile>/usr/share/icecast2/icecast.pid</pidfile>

        <!-- Aliases: treat requests for 'source' path as being for 'dest' path
             May be made specific to a port or bound address using the "port"
             and "bind-address" attributes.
          -->
        <!--
        <alias source="/foo" destination="/bar"/>
        -->
        <!-- Aliases: can also be used for simple redirections as well,
             this example will redirect all requests for http://server:port/ to
             the status page
        -->
        <alias source="/" destination="/status.xsl"/>
        <!-- The certificate file needs to contain both public and private part.
             Both should be PEM encoded.
        <ssl-certificate>/usr/share/icecast2/icecast.pem</ssl-certificate>
        -->
    </paths>

    <logging>
        <accesslog>access.log</accesslog>
        <errorlog>error.log</errorlog>
        <!-- <playlistlog>playlist.log</playlistlog> -->
        <loglevel>3</loglevel> <!-- 4 Debug, 3 Info, 2 Warn, 1 Error -->
        <logsize>10000</logsize> <!-- Max size of a logfile -->
        <!-- If logarchive is enabled (1), then when logsize is reached
             the logfile will be moved to [error|access|playlist].log.DATESTAMP,
             otherwise it will be moved to [error|access|playlist].log.old.
             Default is non-archive mode (i.e. overwrite)
        -->
        <!-- <logarchive>1</logarchive> -->
    </logging>

    <security>
        <chroot>0</chroot>
        <!-- <changeowner>
            <user>icecast2</user>
            <group>icecast</group>
        </changeowner> -->
    </security>
</icecast>
</code>```

how can I mount with different streaming file or different playlists?

答:
I have done multiple mounting on the icecast. For this I have create multiple instances of mpd on the server.

And start each mpd separated on different ports. Port added in configuration file.
For example:

```<code>mpd /etc/mpd.conf    # mpd's configuration file path for start mpd
</code>```

After that I have started new YMPD instance on new port as mpd's client.

For example:

```<code>./ympd --port 6600 --webport 8085  # 6600 is mpd's port and 8085 is ympd's port.
</code>```

Now each mpd have different playlist and different mount url for streaming audio.

Body:
I have installed icecast and MPD with YMPD client on the server.

Currently It is running for single mount. I want to stream audio on different mounting like: /stream.ogg, /mp3, /audio with different playlists.

Below is my config files:

1. mpd.conf:

# An example configuration file for MPD.
# Read the user manual for documentation: http://www.musicpd.org/doc/user/
# or /usr/share/doc/mpd/user-manual.html

# Files and directories #######################################################
#
# This setting controls the top directory which MPD will search to discover the
# available audio files and add them to the daemon's online database. This
# setting defaults to the XDG directory, otherwise the music directory will be
# be disabled and audio files will only be accepted over ipc socket (using
# file:// protocol) or streaming files over an accepted protocol.
#
music_directory     "/var/lib/mpd/music"
#
# This setting sets the MPD internal playlist directory. The purpose of this
# directory is storage for playlists created by MPD. The server will use
# playlist files not created by the server but only if they are in the MPD
# format. This setting defaults to playlist saving being disabled.
#
playlist_directory      "/var/lib/mpd/playlists"
#
# This setting sets the location of the MPD database. This file is used to
# load the database at server start up and store the database while the
# server is not up. This setting defaults to disabled which will allow
# MPD to accept files over ipc socket (using file:// protocol) or streaming
# files over an accepted protocol.
#
db_file         "/var/lib/mpd/tag_cache"
#
# These settings are the locations for the daemon log files for the daemon.
# These logs are great for troubleshooting, depending on your log_level
# settings.
#
# The special value "syslog" makes MPD use the local syslog daemon. This
# setting defaults to logging to syslog, otherwise logging is disabled.
#
log_file            "/var/log/mpd/mpd.log"
#
# This setting sets the location of the file which stores the process ID
# for use of mpd --kill and some init scripts. This setting is disabled by
# default and the pid file will not be stored.
#
pid_file            "/run/mpd/pid"
#
# This setting sets the location of the file which contains information about
# most variables to get MPD back into the same general shape it was in before
# it was brought down. This setting is disabled by default and the server
# state will be reset on server start up.
#
state_file          "/var/lib/mpd/state"
#
# The location of the sticker database.  This is a database which
# manages dynamic information attached to songs.
#
sticker_file                   "/var/lib/mpd/sticker.sql"
#
###############################################################################

# General music daemon options ################################################
#
# This setting specifies the user that MPD will run as. MPD should never run as
# root and you may use this setting to make MPD change its user ID after
# initialization. This setting is disabled by default and MPD is run as the
# current user.
#
#user               "mpd"
#
# This setting specifies the group that MPD will run as. If not specified
# primary group of user specified with "user" setting will be used (if set).
# This is useful if MPD needs to be a member of group such as "audio" to
# have permission to use sound card.
#
#group                          "nogroup"
#
# This setting sets the address for the daemon to listen on. Careful attention
# should be paid if this is assigned to anything other then the default, any.
# This setting can deny access to control of the daemon. Choose any if you want
# to have mpd listen on every address. Not effective if systemd socket
# activation is in use.
#
# For network
bind_to_address     "127.0.0.1"
#
# And for Unix Socket
#bind_to_address        "/run/mpd/socket"
#
# This setting is the TCP port that is desired for the daemon to get assigned
# to.
#
port                "6600"
#
# This setting controls the type of information which is logged. Available
# setting arguments are "default", "secure" or "verbose". The "verbose" setting
# argument is recommended for troubleshooting, though can quickly stretch
# available resources on limited hardware storage.
#
#log_level          "default"
#
# If you have a problem with your MP3s ending abruptly it is recommended that
# you set this argument to "no" to attempt to fix the problem. If this solves
# the problem, it is highly recommended to fix the MP3 files with vbrfix
# (available as vbrfix in the debian archive), at which
# point gapless MP3 playback can be enabled.
#
#gapless_mp3_playback           "yes"
#
# Setting "restore_paused" to "yes" puts MPD into pause mode instead
# of starting playback after startup.
#
#restore_paused "no"
#
# This setting enables MPD to create playlists in a format usable by other
# music players.
#
#save_absolute_paths_in_playlists   "no"
#
# This setting defines a list of tag types that will be extracted during the
# audio file discovery process. The complete list of possible values can be
# found in the mpd.conf man page.
#metadata_to_use    "artist,album,title,track,name,genre,date,composer,performer,disc"
#
# This setting enables automatic update of MPD's database when files in
# music_directory are changed.
#
#auto_update    "yes"
#
# Limit the depth of the directories being watched, 0 means only watch
# the music directory itself.  There is no limit by default.
#
#auto_update_depth "3"
#
###############################################################################

# Symbolic link behavior ######################################################
#
# If this setting is set to "yes", MPD will discover audio files by following
# symbolic links outside of the configured music_directory.
#
#follow_outside_symlinks    "yes"
#
# If this setting is set to "yes", MPD will discover audio files by following
# symbolic links inside of the configured music_directory.
#
#follow_inside_symlinks     "yes"
#
###############################################################################

# Zeroconf / Avahi Service Discovery ##########################################
#
# If this setting is set to "yes", service information will be published with
# Zeroconf / Avahi.
#
#zeroconf_enabled       "yes"
#
# The argument to this setting will be the Zeroconf / Avahi unique name for
# this MPD server on the network.
#
#zeroconf_name          "Music Player"
#
###############################################################################

# Permissions #################################################################
#
# If this setting is set, MPD will require password authorization. The password
# can setting can be specified multiple times for different password profiles.
#
#password                        "password@read,add,control,admin"
#
# This setting specifies the permissions a user has who has not yet logged in.
#
default_permissions             "read,add,control,admin"
#
###############################################################################

# Database #######################################################################
#

#database {
#       plugin "proxy"
#       host "other.mpd.host"
#       port "6600"
#}

# Input #######################################################################
#

input {
        plugin "curl"
#       proxy "proxy.isp.com:8080"
#       proxy_user "user"
#       proxy_password "password"
}

#
###############################################################################

# Audio Output ################################################################
#
# MPD supports various audio output types, as well as playing through multiple
# audio outputs at the same time, through multiple audio_output settings
# blocks. Setting this block is optional, though the server will only attempt
# autodetection for one sound card.
#
# An example of an ALSA output:
#
audio_output {
    type        "alsa"
    name        "My ALSA Device"
#   device      "hw:0,0"    # optional
#   mixer_type      "hardware"      # optional
#   mixer_device    "default"   # optional
#   mixer_control   "PCM"       # optional
#   mixer_index "0"     # optional
}
#
# An example of an OSS output:
#
#audio_output {
#   type        "oss"
#   name        "My OSS Device"
#   device      "/dev/dsp"  # optional
#   mixer_type      "hardware"      # optional
#   mixer_device    "/dev/mixer"    # optional
#   mixer_control   "PCM"       # optional
#}
#
# An example of a shout output (for streaming to Icecast):
#
audio_output {
    type        "shout"
    encoding    "mp3"           # optional
    name        "My Shout Stream"
    host        "localhost"
    port        "8000"
    bind_to_address "127.0.0.1"
    mount       "/mp3"
    password    "4getme!"
    quality     "5.0"
#   bitrate     "128"
    format      "44100:16:1"
#   protocol    "icecast2"      # optional
#   user        "USER"      # optional
    description "My Stream Description" # optional
#   url             "http://example.com"    # optional
#   genre       "jazz"          # optional
#   public      "no"            # optional
#   timeout     "2"         # optional
#   mixer_type      "software"              # optional
}
#
# An example of a recorder output:
#
#audio_output {
#       type            "recorder"
#       name            "My recorder"
#       encoder         "vorbis"                # optional, vorbis or lame
#       path            "/var/lib/mpd/recorder/mpd.ogg"
##      quality         "5.0"                   # do not define if bitrate is defined
#       bitrate         "128"                   # do not define if quality is defined
#       format          "44100:16:1"
#}
#
# An example of a httpd output (built-in HTTP streaming server):
#
#audio_output {
#   type        "httpd"
#   name        "My HTTP Stream"
#   encoder     "vorbis"        # optional, vorbis or lame
#   port        "8000"
#   bind_to_address "0.0.0.0"               # optional, IPv4 or IPv6
#   quality     "5.0"           # do not define if bitrate is defined
#   bitrate     "128"           # do not define if quality is defined
#   format      "44100:16:1"
#   max_clients     "0"                     # optional 0=no limit
#}
#
# An example of a pulseaudio output (streaming to a remote pulseaudio server)
# Please see README.Debian if you want mpd to play through the pulseaudio
# daemon started as part of your graphical desktop session!
#
audio_output {
    type        "pulse"
    name        "My Pulse Output"
#   server      "remote_server"     # optional
#   sink        "remote_server_sink"    # optional
}
#
# An example of a winmm output (Windows multimedia API).
#
#audio_output {
#   type        "winmm"
#   name        "My WinMM output"
#   device      "Digital Audio (S/PDIF) (High Definition Audio Device)" # optional
#       or
#   device      "0"     # optional
#   mixer_type  "hardware"  # optional
#}
#
# An example of an openal output.
#
#audio_output {
#   type        "openal"
#   name        "My OpenAL output"
#   device      "Digital Audio (S/PDIF) (High Definition Audio Device)" # optional
#}
#
## Example "pipe" output:
#
#audio_output {
#   type        "pipe"
#   name        "my pipe"
#   command     "aplay -f cd 2>/dev/null"
## Or if you're want to use AudioCompress
#   command     "AudioCompress -m | aplay -f cd 2>/dev/null"
## Or to send raw PCM stream through PCM:
#   command     "nc example.org 8765"
#   format      "44100:16:2"
#}
#
## An example of a null output (for no audio output):
#
#audio_output {
#   type        "null"
#   name        "My Null Output"
#   mixer_type      "none"                  # optional
#}
#
# If MPD has been compiled with libsamplerate support, this setting specifies
# the sample rate converter to use.  Possible values can be found in the
# mpd.conf man page or the libsamplerate documentation. By default, this is
# setting is disabled.
#
#samplerate_converter       "Fastest Sinc Interpolator"
#
###############################################################################

# Normalization automatic volume adjustments ##################################
#
# This setting specifies the type of ReplayGain to use. This setting can have
# the argument "off", "album", "track" or "auto". "auto" is a special mode that
# chooses between "track" and "album" depending on the current state of
# random playback. If random playback is enabled then "track" mode is used.
# See <http://www.replaygain.org> for more details about ReplayGain.
# This setting is off by default.
#
#replaygain         "album"
#
# This setting sets the pre-amp used for files that have ReplayGain tags. By
# default this setting is disabled.
#
#replaygain_preamp      "0"
#
# This setting sets the pre-amp used for files that do NOT have ReplayGain tags.
# By default this setting is disabled.
#
#replaygain_missing_preamp  "0"
#
# This setting enables or disables ReplayGain limiting.
# MPD calculates actual amplification based on the ReplayGain tags
# and replaygain_preamp / replaygain_missing_preamp setting.
# If replaygain_limit is enabled MPD will never amplify audio signal
# above its original level. If replaygain_limit is disabled such amplification
# might occur. By default this setting is enabled.
#
#replaygain_limit       "yes"
#
# This setting enables on-the-fly normalization volume adjustment. This will
# result in the volume of all playing audio to be adjusted so the output has
# equal "loudness". This setting is disabled by default.
#
#volume_normalization       "no"
#
###############################################################################

# Character Encoding ##########################################################
#
# If file or directory names do not display correctly for your locale then you
# may need to modify this setting.
#
filesystem_charset      "UTF-8"
#
# This setting controls the encoding that ID3v1 tags should be converted from.
#
id3v1_encoding          "UTF-8"
#
###############################################################################

# SIDPlay decoder #############################################################
#
# songlength_database:
#  Location of your songlengths file, as distributed with the HVSC.
#  The sidplay plugin checks this for matching MD5 fingerprints.
#  See http://www.c64.org/HVSC/DOCUMENTS/Songlengths.faq
#
# default_songlength:
#  This is the default playing time in seconds for songs not in the
#  songlength database, or in case you're not using a database.
#  A value of 0 means play indefinitely.
#
# filter:
#  Turns the SID filter emulation on or off.
#
#decoder {
#       plugin                  "sidplay"
#       songlength_database     "/media/C64Music/DOCUMENTS/Songlengths.txt"
#       default_songlength      "120"
#       filter "true"
#}
#
###############################################################################

2. icecast.xml

<icecast>

    <location>Earth</location>
    <admin>icemaster@localhost</admin>

    <limits>
        <clients>100</clients>
        <sources>2</sources>
        <queue-size>524288</queue-size>
        <client-timeout>30</client-timeout>
        15
        <source-timeout>10</source-timeout>

        <burst-on-connect>1</burst-on-connect>

        <burst-size>65535</burst-size>
    </limits>

    <authentication>

        <source-password>4getme!</source-password>

        <relay-password>4getme!</relay-password>

        <admin-user>admin</admin-user>
        <admin-password>4getme!</admin-password>
    </authentication>

    <directory>
        <yp-url-timeout>15</yp-url-timeout>
        <yp-url>/var/lib/mpd/music</yp-url>
    </directory>
    -->

    <hostname>localhost</hostname>

    <listen-socket>
        <port>8000</port>

    </listen-socket>

    <listen-socket>
        <port>8005</port>
    <bind-address>127.0.0.1</bind-address>
        <shoutcast-mount>/stream</shoutcast-mount>
    </listen-socket>

    <listen-socket>
        <port>8006</port>
    </listen-socket>

    <listen-socket>
        <port>8007</port>
        <shoutcast-mount>/live.mp3</shoutcast-mount>
    </listen-socket>

    <http-headers>

    </http-headers>

    <mount type="normal">
        <mount-name>/stream.ogg</mount-name>

        <username>admin</username>
        <password>4getme!</password>

        <max-listeners>1</max-listeners>
        <dump-file>/tmp/dump-example1.ogg</dump-file>
        <burst-size>65536</burst-size>
        <fallback-mount>/example2.ogg</fallback-mount>
        <fallback-override>1</fallback-override>
        <fallback-when-full>1</fallback-when-full>
        <intro>/example_intro.ogg</intro>
        <hidden>1</hidden>
        <public>1</public>
        <authentication type="htpasswd">
                <option name="filename" value="myauth"/>
                <option name="allow_duplicate_users" value="0"/>
        </authentication>
        <http-headers>

        </http-headers>
        <on-connect>/home/icecast/bin/stream-start</on-connect>
        <on-disconnect>/home/icecast/bin/stream-stop</on-disconnect>
    </mount>

    <fileserve>1</fileserve>

    <paths>

        <basedir>/usr/share/icecast2</basedir>

        <logdir>/var/log/icecast2</logdir>
        <webroot>/usr/share/icecast2/web</webroot>
        <adminroot>/usr/share/icecast2/admin</adminroot>
        <pidfile>/usr/share/icecast2/icecast.pid</pidfile>

        <alias source="/" destination="/status.xsl"/>

    </paths>

    <logging>
        <accesslog>access.log</accesslog>
        <errorlog>error.log</errorlog>

        <loglevel>3</loglevel>
        <logsize>10000</logsize>

    </logging>

    <security>
        <chroot>0</chroot>

    </security>
</icecast>

how can I mount with different streaming file or different playlists?

Body:
I have done multiple mounting on the icecast. For this I have create multiple instances of mpd on the server.

And start each mpd separated on different ports. Port added in configuration file.
For example:

mpd /etc/mpd.conf    # mpd's configuration file path for start mpd

After that I have started new YMPD instance on new port as mpd's client.

For example:

./ympd --port 6600 --webport 8085  # 6600 is mpd's port and 8085 is ympd's port.

Now each mpd have different playlist and different mount url for streaming audio.


问:
Scrolling down a webpage using selenium chromedriver
I am trying to retrieve all relevant URLs from a site, however in order to render them all I have to scroll down the webpage, otherwise it returns 500 URLs.

I have two key functions.
One that gets all od the relevant URLs:

```<code>from bs4 import BeautifulSoup

from selenium import webdriver

def scrapeCategory(url):
    url1 = url + "?max=10000"
    html = getHtmlHeadless(url1)
    site = htmlParser(html)
    links = site.findAll('a', {'class':'itemImage', 'data-e2e':'product-listing'}, href=True)
    url_list = []
    for link in links:
        url_list.append("https://www.size.co.uk"+link['href'])
    return url_list
</code>```

By specifying that max=10000 I ensure that all of the listings are on 1 page (rather than having to jump from page to page).

```<code>url1 = url + "?max=10000"
</code>```

And a function that retrieves the HTML, employing a headless chromedriver:

```<code>def getHtmlHeadless(url):
    user_agent = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.50 Safari/537.36'
    options = webdriver.ChromeOptions()

    # specify headless mode
    options.add_argument('headless')

    # specify the desired user agent
    options.add_argument(f'user-agent={user_agent}')
    driver = webdriver.Chrome(executable_path='./chromedriver',options=options)

    # Ensure it is a string
    if ( type (url)!= str):
        print("The input must be a string or list of strings")
    driver.get(url)
#     driver.send_keys(Keys.PAGE_DOWN)
    driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
    html = driver.page_source
    return html
</code>```

Following advice given in other similar queries I have tried applying

```<code>driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
</code>```

and

```<code>driver.send_keys(Keys.PAGE_DOWN)
</code>```

However it does not seem to be doing the job as I either get a maximum of 500 URLs, or in the latter case I get an error.

Error:

```<code><AttributeError: 'WebDriver' object has no attribute 'send_keys'>
</code>```

I am suspecting that I am not placing the

```<code>driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
</code>```

in the correct place. However I do not know where else to place it.

答:
I know this is old. If someone's still looking for executing the scroll page through Selenium without send keys method.</p>

```<code>last_height = driver.execute_script("return document.body.scrollHeight")

while True:
    driver.execute_script("window.scrollTo(0, document.body.scrollHeight*0.90);")

    time.sleep(SCROLL_PAUSE_TIME)

    new_height = driver.execute_script("return document.body.scrollHeight")
    if new_height == last_height:
        break
    last_height = new_height
</code>```

Body:
I am trying to retrieve all relevant URLs from a site, however in order to render them all I have to scroll down the webpage, otherwise it returns 500 URLs.

I have two key functions.
One that gets all od the relevant URLs:

from bs4 import BeautifulSoup

from selenium import webdriver

def scrapeCategory(url):
    url1 = url + "?max=10000"
    html = getHtmlHeadless(url1)
    site = htmlParser(html)
    links = site.findAll('a', {'class':'itemImage', 'data-e2e':'product-listing'}, href=True)
    url_list = []
    for link in links:
        url_list.append("https://www.size.co.uk"+link['href'])
    return url_list

By specifying that max=10000 I ensure that all of the listings are on 1 page (rather than having to jump from page to page).

url1 = url + "?max=10000"

And a function that retrieves the HTML, employing a headless chromedriver:

def getHtmlHeadless(url):
    user_agent = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.50 Safari/537.36'
    options = webdriver.ChromeOptions()

    # specify headless mode
    options.add_argument('headless')

    # specify the desired user agent
    options.add_argument(f'user-agent={user_agent}')
    driver = webdriver.Chrome(executable_path='./chromedriver',options=options)

    # Ensure it is a string
    if ( type (url)!= str):
        print("The input must be a string or list of strings")
    driver.get(url)
#     driver.send_keys(Keys.PAGE_DOWN)
    driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
    html = driver.page_source
    return html

Following advice given in other similar queries I have tried applying

driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")

and

driver.send_keys(Keys.PAGE_DOWN)

However it does not seem to be doing the job as I either get a maximum of 500 URLs, or in the latter case I get an error.

Error:

<AttributeError: 'WebDriver' object has no attribute 'send_keys'>

I am suspecting that I am not placing the

driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")

in the correct place. However I do not know where else to place it.

Body:
I know this is old. If someone's still looking for executing the scroll page through Selenium without send keys method.

last_height = driver.execute_script("return document.body.scrollHeight")

while True:
    driver.execute_script("window.scrollTo(0, document.body.scrollHeight*0.90);")

    time.sleep(SCROLL_PAUSE_TIME)

    new_height = driver.execute_script("return document.body.scrollHeight")
    if new_height == last_height:
        break
    last_height = new_height