问:
Logo will not overlap on top of background image
I'm trying to put the logo to overlap the background image (see screenshot below) div with

```<code>position: absolute;
</code>```

for the .header div and

```<code>position: relative;
</code>```

for the .logo-svrs div

It seems that the external div will not overlap the .bg-banner. The overflow: visible didn't work either. No success.

I had to show the header of the logo by putting the

```<code>display: visible;
</code>```

to be able to see the location of the logo. On the screenshot below, the right screenshot is what I need.

HTML

```<code><div class="header">
    <a href="http://www.svrs.com"><img src="imgs/logo-svrs.png" class="logo-svrs" alt="Sorenson VRS"></a>
</div>
<div class="bg-banner">
    <div class="notice-wrapper">
        <div class="notice-overlay">
            <div class="notices effect">
                <div class="box-left-bad">
                    <img src="imgs/exclamatory.png" alt="Warning! - Sorenson VRS">
                    <p class="good">WARNING!</p>
                </div>
                <div class="box-right-bad">
                    <p>We are currently experiencing a technical difficulty that may be impacting our service.  You may want to try restarting your device (VP, VP2, PC, Mac or mobile device) to see if this resolves the issue.  At this time, we do not know when the technical difficulty will be resolved.  We are working to quickly resolve the problem.  This message will no longer appear on this page when the issue is resolved.</p>
                    <p>Thank you for your patience.</p>
                </div>
            </div>
        </div>
    </div>
</code>```

CSS

```<code>@media screen and (max-width:732px) and (min-width:425px) {
.logo-svrs {
    position: relative !important;
    display: block !important;
    width: 114px;
    height: 29.5px;
    margin: 0 auto;
    z-index: 9999;
    border: solid #ff0000 3px !important;
    overflow: visible !important;
 }
.header {
    display: visible;
}
.bg-banner {
    position: absolute !important;
    background-image: url(../imgs/apply_header.jpg) !important;
    background-repeat: no-repeat;
    background-size: 100% 40% !important;
    z-index: 0;
}
.notices {
    position: relative !important;
    width: 370px !important;
    height: 350px !important;
    text-align: center;
    margin: 0 auto;
    margin-top: 200px !important;
    z-index: 9999;
    border-radius: 5px !important;
    box-shadow:  0 0 10px  rgba(0,0,0,0.5) !important;
    -moz-box-shadow: 0 0 10px  rgba(0,0,0,0.5) !important;
    -webkit-box-shadow: 0 0 10px  rgba(0,0,0,0.5) !important;
    -o-box-shadow: 0 0 10px  rgba(0,0,0,0.5) !important;
}
</code>```

答:
You could move the .header div inside the .bg-banner div and add this

css:

```<code>.header {
    display: visible; /*this is not valid*/
    position: absolute;
    top: 60px;
    left: 0px;
    right: 0px;
}
</code>```

Here is a possible solution:

https://jsfiddle.net/kd91t26L/3/

Body:
I'm trying to put the logo to overlap the background image (see screenshot below) div with

position: absolute;

for the .header div and

position: relative;

for the .logo-svrs div

It seems that the external div will not overlap the .bg-banner. The overflow: visible didn't work either. No success.

I had to show the header of the logo by putting the

display: visible;

to be able to see the location of the logo. On the screenshot below, the right screenshot is what I need.

HTML

WARNING!

We are currently experiencing a technical difficulty that may be impacting our service.  You may want to try restarting your device (VP, VP2, PC, Mac or mobile device) to see if this resolves the issue.  At this time, we do not know when the technical difficulty will be resolved.  We are working to quickly resolve the problem.  This message will no longer appear on this page when the issue is resolved.

Thank you for your patience.

CSS

@media screen and (max-width:732px) and (min-width:425px) {
.logo-svrs {
    position: relative !important;
    display: block !important;
    width: 114px;
    height: 29.5px;
    margin: 0 auto;
    z-index: 9999;
    border: solid #ff0000 3px !important;
    overflow: visible !important;
 }
.header {
    display: visible;
}
.bg-banner {
    position: absolute !important;
    background-image: url(../imgs/apply_header.jpg) !important;
    background-repeat: no-repeat;
    background-size: 100% 40% !important;
    z-index: 0;
}
.notices {
    position: relative !important;
    width: 370px !important;
    height: 350px !important;
    text-align: center;
    margin: 0 auto;
    margin-top: 200px !important;
    z-index: 9999;
    border-radius: 5px !important;
    box-shadow:  0 0 10px  rgba(0,0,0,0.5) !important;
    -moz-box-shadow: 0 0 10px  rgba(0,0,0,0.5) !important;
    -webkit-box-shadow: 0 0 10px  rgba(0,0,0,0.5) !important;
    -o-box-shadow: 0 0 10px  rgba(0,0,0,0.5) !important;
}

Body:
You could move the .header div inside the .bg-banner div and add this

css:

.header {
    display: visible; /*this is not valid*/
    position: absolute;
    top: 60px;
    left: 0px;
    right: 0px;
}

Here is a possible solution:

https://jsfiddle.net/kd91t26L/3/


来源: stackexchange

问:
Why does adding and subtracting two #define'd macros not work on iPhone / Objective-c
In my iPhone app, I have this in my .h file

```<code>#define ORIENTATION_IS_PORTRAIT UIDeviceOrientationIsPortrait([[UIDevice currentDevice] orientation])
#define FULLSCREEN_MODE         ORIENTATION_IS_PORTRAIT?460:300
#define AD_HEIGHT               ORIENTATION_IS_PORTRAIT?50:32
#define FULLSCREEN_MODE_WITH_AD FULLSCREEN_MODE - AD_HEIGHT //doesn't work
</code>```

To sum it up, I have a macro to detect the orientation. I have another for the height of my UIWebView when it is in full screen mode (activated by a button press). I need to keep the ad at the bottom. However, to get the height of the UIWebView minus the ad height will only return the AD_HEIGHT.

For addition, (FULLSCREEN_MODE + AD_HEIGHT) returns the FULLSCREEN_MODE only.

Also, when using constants, where exactly do I put them. I searched and could only find answers like "in the .m file", but where??

答:
Alternately, avoid the preprocessor and it's confusion altogether, and use inline functions.

```<code>inline BOOL orientationIsPortait() {
    return UIDeviceOrientationIsPortrait([[UIDevice currentDevice] orientation]);
}

inline int fullscreenMode() {
    return orientationIsPortait() ? 460 : 300;
}
</code>```

... etc

These would go outside of your @implementation block.

For that matter, I'd bet you don't run these function but once in a great while, so thinking about optimizations like macros or inlining is highly premature, and probably never important.

ContentLicense: CC BY-SA 3.0

Body:
In my iPhone app, I have this in my .h file

#define ORIENTATION_IS_PORTRAIT UIDeviceOrientationIsPortrait([[UIDevice currentDevice] orientation])
#define FULLSCREEN_MODE         ORIENTATION_IS_PORTRAIT?460:300
#define AD_HEIGHT               ORIENTATION_IS_PORTRAIT?50:32
#define FULLSCREEN_MODE_WITH_AD FULLSCREEN_MODE - AD_HEIGHT //doesn't work

To sum it up, I have a macro to detect the orientation. I have another for the height of my UIWebView when it is in full screen mode (activated by a button press). I need to keep the ad at the bottom. However, to get the height of the UIWebView minus the ad height will only return the AD_HEIGHT.

For addition, (FULLSCREEN_MODE + AD_HEIGHT) returns the FULLSCREEN_MODE only.

Also, when using constants, where exactly do I put them. I searched and could only find answers like "in the .m file", but where??

Body:
Alternately, avoid the preprocessor and it's confusion altogether, and use inline functions.

inline BOOL orientationIsPortait() {
    return UIDeviceOrientationIsPortrait([[UIDevice currentDevice] orientation]);
}

inline int fullscreenMode() {
    return orientationIsPortait() ? 460 : 300;
}

... etc

These would go outside of your @implementation block.

For that matter, I'd bet you don't run these function but once in a great while, so thinking about optimizations like macros or inlining is highly premature, and probably never important.

ContentLicense: CC BY-SA 2.5


问:
AngularJS with jQuery for selecting parent element
I'm posting my html and directive code. I have two spans, which I have attached ng-click to. On ng-click I want to check the classes of their parents parent item (.parent-portlet), but what I have so far is not working correctly as all of the parent portlets get selected instead of only the current one.

     Remove

     Add Back

```

<p>this is what I have in my directive: </p>

<pre class="lang-js prettyprint-override"><code>scope.removePortlet = function(portlet) {
  var port = $('.remove').parent().parent();
  port.addClass('removed');
  port.addClass('edit-portlet');
};

scope.addPortlet = function(portlet) {
  var port = $('.add-back').parent().parent();
  if (portlet.hasClass('removed')) {
    port.removeClass('removed');
    port.removeClass('edit-portlet');
  }
};
</code>```

The problem with this code is that var portlet catches all of the portlets(parents) and I want to catch only the one related to the click action. How can I achieve that? I tried to pass this to my jquery select like so:

```<code>var portlet = $('.add-back', this).parent().parent();
</code>```

but that didn't work. Any ideas how this can be achieved?

Thanks in advance.

答:
You can inject the $element to your controller, then, use it as the context for the $ selector.

angular.module('app', []).controller('ctrl', function($scope, $element) {
  $scope.addPortlet = function(portlet) {
    console.log($('.add-back', $element));
  };
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>

<div ng-app="app" ng-controller="ctrl">
  <div class="parent-portlet">
    <div class="portlet-titlebar" ng-click="toggleCollapsed($event)">
      <span class="remove" ng-click="removePortlet(portlet)">
       Remove
      </span>
      <span class="add-back" ng-click="addPortlet(portlet)">
       Add Back
      </span>
    </div>
  </div>
</div></code>```

For more info about it

Body:
I'm posting my html and directive code. I have two spans, which I have attached ng-click to. On ng-click I want to check the classes of their parents parent item (.parent-portlet), but what I have so far is not working correctly as all of the parent portlets get selected instead of only the current one.

     Remove

     Add Back

this is what I have in my directive:

scope.removePortlet = function(portlet) {
  var port = $('.remove').parent().parent();
  port.addClass('removed');
  port.addClass('edit-portlet');
};

scope.addPortlet = function(portlet) {
  var port = $('.add-back').parent().parent();
  if (portlet.hasClass('removed')) {
    port.removeClass('removed');
    port.removeClass('edit-portlet');
  }
};

The problem with this code is that var portlet catches all of the portlets(parents) and I want to catch only the one related to the click action. How can I achieve that? I tried to pass this to my jquery select like so:

var portlet = $('.add-back', this).parent().parent();

but that didn't work. Any ideas how this can be achieved?

Thanks in advance.

Body:
You can inject the $element to your controller, then, use it as the context for the $ selector.

angular.module('app', []).controller('ctrl', function($scope, $element) {
  $scope.addPortlet = function(portlet) {
    console.log($('.add-back', $element));
  };
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>

<div ng-app="app" ng-controller="ctrl">
  <div class="parent-portlet">
    <div class="portlet-titlebar" ng-click="toggleCollapsed($event)">
      <span class="remove" ng-click="removePortlet(portlet)">
       Remove
      </span>
      <span class="add-back" ng-click="addPortlet(portlet)">
       Add Back
      </span>
    </div>
  </div>
</div>

For more info about it


问:
PHP's PDO::fetch() running out of memory
I'm selecting 19 columns from an AS400 (IBM iSeries database) table. The query runs fine, the total row count is less than 17,000.
However, as soon as I run

```<code>$row = $statement->fetch(PDO::FETCH_NUM)
</code>```

PHP runs out of memory (512 megs). The script doesn't even take a second to crash - something uses up every bit of memory immediately.

I can fetch more columns from a different table with a total of 150,000 rows returned (using the same fetch() command) and memory consumption remains stable at around 500 KB.
However something about that other select fetch completely annihilates the process.

I'm using the iSeries ODBC drivers from IBM on 64 bit linux.
Any suggestions for further troubleshooting would be greatly appreciated.

UPDATE: I've isolated the issue to the column causing this - it's a CHARACTER field with length of 4. The record breaking the fetch actually has a null in that field. Might be some misunderstanding on the part of the driver on how to handle nulls.

答:
This is apparently a known problem with IBM's 64 bit drivers:
https://bugs.php.net/bug.php?id=54007

In lieu of porting the fix suggested in the bug report and recompiling PHP, one can use workaround like adding an IFNULL function call to fields that can be nulls. Not exactly a solution but it'll have to do until IBM figure this out (if they do).

UPDATE: In case anyone runs into this issue, apparently while the iSeries odbc driver does have this issue (and is probably never getting updated), there is a new connection software called IBM i Access Client which comes with a better working ODBC driver.

Instructions on where to find the download are here: http://www-01.ibm.com/support/docview.wss?uid=nas8N1010355

Body:
I'm selecting 19 columns from an AS400 (IBM iSeries database) table. The query runs fine, the total row count is less than 17,000.
However, as soon as I run

$row = $statement->fetch(PDO::FETCH_NUM)

PHP runs out of memory (512 megs). The script doesn't even take a second to crash - something uses up every bit of memory immediately.

I can fetch more columns from a different table with a total of 150,000 rows returned (using the same fetch() command) and memory consumption remains stable at around 500 KB.
However something about that other select fetch completely annihilates the process.

I'm using the iSeries ODBC drivers from IBM on 64 bit linux.
Any suggestions for further troubleshooting would be greatly appreciated.

UPDATE: I've isolated the issue to the column causing this - it's a CHARACTER field with length of 4. The record breaking the fetch actually has a null in that field. Might be some misunderstanding on the part of the driver on how to handle nulls.

ContentLicense: CC BY-SA 4.0


问:
Remove unmixed numbers from file
Say I have a file called input.txt that looks like this

```<code>I listened to 4 u2 albums today
meet me at 5
squad 4ever
</code>```

I want to filter out the numbers that are on their own, so "4" and "5" should go but "u2" and "4ever" should remain the same. i.e the output should be

```<code>I listened to u2 albums today
meet me at
squad 4ever
</code>```

I've been trying to use this code

```<code>for line in fileinput.input("input.txt", inplace=True):
    new_s = ""
    for word in line.split(' '):
        if not all(char.isdigit() for char in word):
            new_s += word
            new_s += ' '
    print(new_s, end='')
</code>```

Which is pretty similar to the code I found here: Removing numbers mixed with letters from string

But instead of the wanted output I get

```<code>I listened to u2 albums today
 meet me at 5
 squad 4ever
</code>```

As you can see there are two problems here, first only the first line loses the digit I want it to lose, "5" is still present in the second line. The second problem is the extra white space at the beginning of a new line.

I've been playing around with the code for a while and browsing stackoverflow, but can't find where the problem is coming from. Any insights?

答:
You can use regex:

```<code>data = open('file.txt').read()
import re
data = re.sub('(?<=\s)\d+(?=$)|(?<=^)\d+(?<=\s)|(\s\d+\s)', '', data)
</code>```

Output:

```<code>I listened tou2 albums today
meet me at
squad 4ever
</code>```

Title: Remove unmixed numbers from file

Body:
Say I have a file called input.txt that looks like this

I listened to 4 u2 albums today
meet me at 5
squad 4ever

I want to filter out the numbers that are on their own, so "4" and "5" should go but "u2" and "4ever" should remain the same. i.e the output should be

I listened to u2 albums today
meet me at
squad 4ever

I've been trying to use this code

for line in fileinput.input("input.txt", inplace=True):
    new_s = ""
    for word in line.split(' '):
        if not all(char.isdigit() for char in word):
            new_s += word
            new_s += ' '
    print(new_s, end='')

Which is pretty similar to the code I found here: Removing numbers mixed with letters from string

But instead of the wanted output I get

I listened to u2 albums today
 meet me at 5
 squad 4ever

As you can see there are two problems here, first only the first line loses the digit I want it to lose, "5" is still present in the second line. The second problem is the extra white space at the beginning of a new line.

I've been playing around with the code for a while and browsing stackoverflow, but can't find where the problem is coming from. Any insights?

Body:
You can use regex:

data = open('file.txt').read()
import re
data = re.sub('(?<=\s)\d+(?=$)|(?<=^)\d+(?<=\s)|(\s\d+\s)', '', data)

Output:

I listened tou2 albums today
meet me at
squad 4ever


问:
Cannot build Unity project for HoloLens with IBM Watson SDK
I'm having troubles building my Unity project. I tried both a custom scene, created by me, and the example scenes located into Examples/ServiceExamples.
Basically, I want to take a picture with the HoloLens webcam and call IBM Watson visual recognition service. All Mixed Reality settings have been configured correctly. When I try to build the project I get lots of errors and they're all related to Watson SDK. For instance, the first error is the following:

Assets\Watson\ThirdParty\WebSocketSharp\Ext.cs(54,36): error CS0234: The type or namespace name 'X509Certificates' does not exist in the namespace 'System.Security.Cryptography' (are you missing an assembly reference?)

I tried to install directly from the solution some of these packages that i'm missing, but the error remains there. Do you think it could be due to my Visual Studio project settings (e.g.: .NET targets, ecc)?
Here are my Unity settings:

My settings imgur link

Am I missing something else? Any ideas? Thanks!

答: You have a Unity package recently added for this particular need, see https://github.com/watson-developer-cloud/unity-sdk/issues/173 I believe is not part of the official release as for now, but you can get it from GitHub.</p>


问:
c# mongodb driver how to cast a mongo double value to a c# decimal one
I have this bson document which I read from mongodb, using c# mongodb driver v2.4.4. I just need to convert some field in it to decimal in a c# code. I know there is a double value there, therefore I try to convert to a decimal value using:

```<code>monto = Convert.ToDecimal(document["monto"].AsDouble)
</code>```

But, as the value is 39330000, I suppose the driver assumes it is a Int32 and throws this exception:

Unable to cast object of type 'MongoDB.Bson.BsonInt32' to type
  'MongoDB.Bson.BsonDouble'.

Maybe because it doesn't come with the dot (.) in it.

So, I'm using this to convert to decimal:

```<code>monto = Convert.ToDecimal(document["monto"].ToString())
</code>```

And it works because c# can convert to decimal any string that contains a number.

My question is: is there a better way to convert a bson double to c# decimal, without converting it to a string first ?

Thanks and bye ...

答:
If that is the error you're getting, it seems that the type is stored as an integer, not as a double.

In either case, you can do it by converting instead of casting. That is, just use ToDouble() instead of AsDouble. This: document["monto"].ToDouble(); will get you back the double directly, though it still throws exceptions if the type can't be converted in an obvious way...

```<code>BsonDocument bdoc = new BsonDocument()
{
    { "three", 3 },
    { "pi", 3.14 },
    { "e", "2.71" },
    { "true", true },
    { "arr", new BsonArray() }
};
double three = bdoc["three"].ToDouble();    // three = 3.0
double pi = bdoc["pi"].ToDouble();       // pi = 3.14
double e = bdoc["e"].ToDouble();         // e = 2.71
double t = bdoc["true"].ToDouble(); // throws NotSupportedException
double arr = bdoc["arr"].ToDouble(); // throws NotSupportedException
</code>```

Body:
I have this bson document which I read from mongodb, using c# mongodb driver v2.4.4. I just need to convert some field in it to decimal in a c# code. I know there is a double value there, therefore I try to convert to a decimal value using:

monto = Convert.ToDecimal(document["monto"].AsDouble)

But, as the value is 39330000, I suppose the driver assumes it is a Int32 and throws this exception:

Unable to cast object of type 'MongoDB.Bson.BsonInt32' to type
  'MongoDB.Bson.BsonDouble'.

Maybe because it doesn't come with the dot (.) in it.

So, I'm using this to convert to decimal:

monto = Convert.ToDecimal(document["monto"].ToString())

And it works because c# can convert to decimal any string that contains a number.

My question is: is there a better way to convert a bson double to c# decimal, without converting it to a string first ?

Thanks and bye ...

Body:
If that is the error you're getting, it seems that the type is stored as an integer, not as a double.

In either case, you can do it by converting instead of casting. That is, just use ToDouble() instead of AsDouble. This: document["monto"].ToDouble(); will get you back the double directly, though it still throws exceptions if the type can't be converted in an obvious way...

BsonDocument bdoc = new BsonDocument()
{
    { "three", 3 },
    { "pi", 3.14 },
    { "e", "2.71" },
    { "true", true },
    { "arr", new BsonArray() }
};
double three = bdoc["three"].ToDouble();    // three = 3.0
double pi = bdoc["pi"].ToDouble();       // pi = 3.14
double e = bdoc["e"].ToDouble();         // e = 2.71
double t = bdoc["true"].ToDouble(); // throws NotSupportedException
double arr = bdoc["arr"].ToDouble(); // throws NotSupportedException


问:
Finding matches in python 3
I have two files with lots of columns and different information about a bunch of objects, that come with object IDs. I need to find matches between the two files, but the object IDs come in two different formats:

12-12-1 in one file will be written as 0012 00012 1 in the other. For instance, in one file I have:

```<code>0001 01531 1
0001 01535 1
0001 01538 1
</code>```

Which corresponds to this in the other:

```<code>1-1531-1
1-1535-1
1-1538-1
</code>```

Something as simple as

```<code>matches = open('matches.dat','w')
for j in range(len(file1)):
    for i in range(len(file2)):
        if file1[j] == file2[i]:
            matches.write('{}/n'.format(file1[j]))
</code>```

doesn't seem to do the trick.

file1 and file2 here are lists that contain all the object IDs from the different files.

What do I add to my code to find the matches?

答:
Converting your first format to the second:

```<code>import re

def convert(word):
    word = word.strip().replace(' ', '-')
    return re.sub('\\b0+', '', word)  # strip all 0s after a word boundary (space or beginning of line)
</code>```

Algorithmic Improvement

You can calculate the intersection in O(n+m) time by converting both to a list and computing the intersection

```<code>file1_ids = {convert(line) for line in file1}
file2_ids = {line for line in file2}

matches = file1_ids.intersection(file2_ids)
</code>```

Title: Finding matches in python 3

Body:
I have two files with lots of columns and different information about a bunch of objects, that come with object IDs. I need to find matches between the two files, but the object IDs come in two different formats:

12-12-1 in one file will be written as 0012 00012 1 in the other. For instance, in one file I have:

0001 01531 1
0001 01535 1
0001 01538 1

Which corresponds to this in the other:

1-1531-1
1-1535-1
1-1538-1

Something as simple as

matches = open('matches.dat','w')
for j in range(len(file1)):
    for i in range(len(file2)):
        if file1[j] == file2[i]:
            matches.write('{}/n'.format(file1[j]))

doesn't seem to do the trick.

file1 and file2 here are lists that contain all the object IDs from the different files.

What do I add to my code to find the matches?

Body:
Converting your first format to the second:

import re

def convert(word):
    word = word.strip().replace(' ', '-')
    return re.sub('\\b0+', '', word)  # strip all 0s after a word boundary (space or beginning of line)

Algorithmic Improvement

You can calculate the intersection in O(n+m) time by converting both to a list and computing the intersection

file1_ids = {convert(line) for line in file1}
file2_ids = {line for line in file2}

matches = file1_ids.intersection(file2_ids)


问:
C# Nullable Equality Operations, Why does null <= null resolve as false?
Why is it that in .NET

```<code>null >= null
</code>```

resolves as false, but

```<code>null == null
</code>```

resolves as true?

In other words, why isn't null >= null equivalent to null > null || null == null?

Does anyone have the official answer?

答:
This question was a Deja vu, oh wait here it is...

Why does >= return false when == returns true for null values?

The thing I remember from the other answer was :

Because Equality is defined separately
  from Comparability. You can test x ==
  null but x > null is meaningless. In
  C# it will always be false.

Body:
Why is it that in .NET

null >= null

resolves as false, but

null == null

resolves as true?

In other words, why isn't null >= null equivalent to null > null || null == null?

Does anyone have the official answer?


问:
MassTransit not using XmlDeserializer

MassTransit.RabbitMQ 4.0.0.1334-develop on netcoreapp2.0

It appears MassTransit is still trying to use the JsonDeserializer, even when the incoming message has a content_type of application/vnd.masstransit+xml.  My assumption (possibly wrong) is that MassTransit will use the correct deserializer based on the incoming content_type header.

Note: I am testing this by sending a message into the exchange directly in RabbitMQ Management Console.

Error is:

```<code>MT-Reason:  fault
MT-Fault-Message:   Unexpected character encountered while parsing value: <. Path '', line 0, position 0.
MT-Fault-Timestamp: 2017-11-14T22:28:23.9008730Z
MT-Fault-StackTrace:    at Newtonsoft.Json.JsonTextReader.ParseValue()
at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonSerializer.Deserialize[T](JsonReader reader)
at MassTransit.Serialization.JsonMessageDeserializer.MassTransit.IMessageDeserializer.Deserialize(ReceiveContext receiveContext)
</code>```

I have configured my receive endpoint (from Castle Windsor container) with the following code:

```<code>sbc.ReceiveEndpoint(host, "my-consumer", ep =>
{
  ep.UseMessageScope();
  ep.LoadFrom(container);
});
</code>```

Additional things I have tried:

1.

```<code>ep.UseXmlSerializer();
</code>```

2.

```<code>ep.AddEndpointSpecification(new SupportMessageDeserializerReceiveEndpointSpecification(XmlMessageSerializer.XmlContentType, () => new XmlMessageDeserializer(XmlMessageSerializer.XmlSerializer)));
</code>```

3.

```<code>ep.AddEndpointSpecification(new SupportMessageDeserializerReceiveEndpointSpecification(XmlMessageSerializer.XmlContentType, () => new XmlMessageDeserializer(JsonMessageSerializer.Deserializer)));
</code>```

4.

```<code>sbc.UseXmlSerializer();
</code>```

None of those seem to have any affect.

答:
Simple -
MassTransit does not use the standard RabbitMq property of content_type, but instead uses a header called Content-Type

Title: MassTransit not using XmlDeserializer

Body:
MassTransit.RabbitMQ 4.0.0.1334-develop on netcoreapp2.0

It appears MassTransit is still trying to use the JsonDeserializer, even when the incoming message has a content_type of application/vnd.masstransit+xml.  My assumption (possibly wrong) is that MassTransit will use the correct deserializer based on the incoming content_type header.

Note: I am testing this by sending a message into the exchange directly in RabbitMQ Management Console.

Error is:

MT-Reason:  fault
MT-Fault-Message:   Unexpected character encountered while parsing value: <. Path '', line 0, position 0.
MT-Fault-Timestamp: 2017-11-14T22:28:23.9008730Z
MT-Fault-StackTrace:    at Newtonsoft.Json.JsonTextReader.ParseValue()
at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonSerializer.Deserialize[T](JsonReader reader)
at MassTransit.Serialization.JsonMessageDeserializer.MassTransit.IMessageDeserializer.Deserialize(ReceiveContext receiveContext)

I have configured my receive endpoint (from Castle Windsor container) with the following code:

sbc.ReceiveEndpoint(host, "my-consumer", ep =>
{
  ep.UseMessageScope();
  ep.LoadFrom(container);
});

Additional things I have tried:

1.

ep.UseXmlSerializer();

2.

ep.AddEndpointSpecification(new SupportMessageDeserializerReceiveEndpointSpecification(XmlMessageSerializer.XmlContentType, () => new XmlMessageDeserializer(XmlMessageSerializer.XmlSerializer)));

3.

ep.AddEndpointSpecification(new SupportMessageDeserializerReceiveEndpointSpecification(XmlMessageSerializer.XmlContentType, () => new XmlMessageDeserializer(JsonMessageSerializer.Deserializer)));

4.

sbc.UseXmlSerializer();

None of those seem to have any affect.


问:
Strange exception after IChangeFeedObserver ProcessChangesAsync
I'm trying to create replication from CosmosDB to local CouchBase Lite database. For this I'm using Microsoft.Azure.Documents.ChangeFeedProcessor

But for some reason always after IChangeFeedObserver ProcessChangesAsync has ended I get following exception on console:

What does "Errors":["One of the specified pre-condition is not met"] mean? Replication is ended succesfully otherwise but this bothers me.

Updated with system.diagnostics

```<code>ChangeFeedEventHost Information: 53 : 09/25/2017 08:27:54: Host 'TESTIkiosk' starting to check for available leases.
ChangeFeedEventHost Information: 54 : 09/25/2017 08:27:54: Host 'TESTIkiosk' starting to check for available leases.
ChangeFeedEventHost Information: 55 : 09/25/2017 08:27:54: Host 'TESTIkiosk' 1 partitions, 1 hosts, 0 available leases, target = 1, min = 0, max = 0, mine = 1, will try to take 0 lease(s) for myself'.
ChangeFeedEventHost Information: 56 : 09/25/2017 08:27:54: Host 'TESTIkiosk' 1 partitions, 1 hosts, 0 available leases, target = 1, min = 0, max = 0, mine = 1, will try to take 0 lease(s) for myself'.
ChangeFeedEventHost Information: 57 : 09/25/2017 08:28:06: Host 'TESTIkiosk' starting renewal of Leases.
ChangeFeedEventHost Information: 58 : 09/25/2017 08:28:06: Host 'TESTIkiosk' renewing lease for PartitionId '0' with lease token '"0000fa04-0000-0000-0000-59c893d40000"'
ChangeFeedEventHost Information: 59 : 09/25/2017 08:28:06: Host 'TESTIkiosk' starting renewal of Leases.
ChangeFeedEventHost Information: 60 : 09/25/2017 08:28:06: Host 'TESTIkiosk' renewing lease for PartitionId '0' with lease token '"0000fb04-0000-0000-0000-59c893d40000"'
ChangeFeedEventHost Information: 61 : 09/25/2017 08:28:06: Host 'TESTIkiosk' attempted to renew lease for PartitionId '0' and lease token '"0000fa04-0000-0000-0000-59c893d40000"' with result: 'True'
ChangeFeedEventHost Information: 62 : 09/25/2017 08:28:06: Host 'TESTIkiosk' attempted to renew lease for PartitionId '0' and lease token '"0000fb04-0000-0000-0000-59c893d40000"' with result: 'True'
ChangeFeedEventHost Information: 63 : 09/25/2017 08:28:07: Host 'TESTIkiosk' starting to check for available leases.
ChangeFeedEventHost Information: 64 : 09/25/2017 08:28:07: Host 'TESTIkiosk' starting to check for available leases.
ChangeFeedEventHost Information: 65 : 09/25/2017 08:28:07: Host 'TESTIkiosk' 1 partitions, 1 hosts, 0 available leases, target = 1, min = 0, max = 0, mine = 1, will try to take 0 lease(s) for myself'.
ChangeFeedEventHost Information: 66 : 09/25/2017 08:28:07: Host 'TESTIkiosk' 1 partitions, 1 hosts, 0 available leases, target = 1, min = 0, max = 0, mine = 1, will try to take 0 lease(s) for myself'.
[08:28:15 INF] Change feed in Ingredients: total 1 doc(s)
[08:28:15 INF] Replicated 2614
ChangeFeedEventHost Information: 67 : 09/25/2017 08:28:15: Partition '0' update failed because the lease with token '"0000e804-0000-0000-0000-59c893b20000"' was updated by same/this host with token '"00000005-0000-0000-0000-59c893e50000"'. Will retry, 4 retry(s) left.
ChangeFeedEventHost Information: 68 : 09/25/2017 08:28:15: Checkpoint: partition 0, new continuation '"81"'

DocDBTrace Error: 0 : DocumentClientException with status code PreconditionFailed, message: Message: {"Errors":["One of the specified pre-condition is not met"]}, inner exception: null, and response headers: {
"x-ms-last-state-change-utc": "Sun, 24 Sep 2017 21:03:48.392 GMT",
"lsn": "954",
"x-ms-schemaversion": "1.3",
"x-ms-quorum-acked-lsn": "954",
"x-ms-current-write-quorum": "3",
"x-ms-current-replica-set-size": "4",
"x-ms-documentdb-partitionkeyrangeid": "0",
"x-ms-xp-role": "1",
"x-ms-request-charge": "1.24",
"x-ms-serviceversion": " version=1.17.52.1",
"x-ms-activity-id": "b9877abb-6203-4408-b1c3-92c9f52aad67",
}
DocDBTrace Error: 0 : Operation will NOT be retried. Current attempt 0, Exception: Microsoft.Azure.Documents.PreconditionFailedException: Message: {"Errors":["One of the specified pre-condition is not met"]}
ActivityId: b9877abb-6203-4408-b1c3-92c9f52aad67, Request URI: /apps/c9c8f510-0ca7-4702-aa6c-9c596d797367/services/75cca430-a307-47a0-89aa-82aabf32e065/partitions/53fb63ca-95ae-4d13-90be-d32f1a88843c/replicas/131504697049132845p/
   at Microsoft.Azure.Documents.TransportClient.ThrowIfFailed(String resourceAddress, StoreResponse storeResponse, Uri physicalAddress, Guid activityId)
   at Microsoft.Azure.Documents.RntbdTransportClient.<InvokeStoreAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Documents.ReplicatedResourceClient.<WriteAsync>d__1b.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Documents.ReplicatedResourceClient.<InvokeAsync>d__b.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Documents.ReplicatedResourceClient.<>c__DisplayClass1.<<InvokeAsync>b__0>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Documents.BackoffRetryUtility`1.<>c__DisplayClassf`1.<<ExecuteAsync>b__d>d__11.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Documents.BackoffRetryUtility`1.<ExecuteRetry>d__1b.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.Azure.Documents.BackoffRetryUtility`1.<ExecuteRetry>d__1b.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Documents.BackoffRetryUtility`1.<ExecuteAsync>d__18`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Documents.ReplicatedResourceClient.<InvokeAsync>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Documents.StoreClient.<ProcessMessageAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Documents.Client.DocumentClient.<UpdateAsync>d__305.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Documents.Client.DocumentClient.<ReplaceDocumentPrivateAsync>d__13d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Documents.Client.DocumentClient.<ReplaceDocumentPrivateAsync>d__135.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Documents.BackoffRetryUtility`1.<>c__DisplayClass2.<<ExecuteAsync>b__0>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Documents.BackoffRetryUtility`1.<ExecuteRetry>d__1b.MoveNext()
</code>```

Code for my Implementation:

```<code>    using Microsoft.Azure.Documents.ChangeFeedProcessor;
    using System;
    using System.Collections.Generic;
    using System.Threading;
    using System.Threading.Tasks;

    namespace Solteq.Pos.Repositories.Feeds
    {
        internal class MyHostFeed : IChangeFeedObserver
        {
            private int s_totalDocs = 0;
            private Func<dynamic, bool> replicate;
            private string name;

            public Func<dynamic, bool> Replicate { get => replicate; set => replicate = value; }
            public string Name { get => name; set => name = value; }

            public Task OpenAsync(ChangeFeedObserverContext context)
            {
                Console.WriteLine("Worker opened for {0}, {1}", name, context.PartitionKeyRangeId);
                return Task.CompletedTask;  // Requires targeting .NET 4.6+.
            }
            public Task CloseAsync(ChangeFeedObserverContext context, ChangeFeedObserverCloseReason reason)
            {
                Console.WriteLine("Worker closed for  {0}, {1}", name, context.PartitionKeyRangeId);
                return Task.CompletedTask;
            }

            public Task ProcessChangesAsync(ChangeFeedObserverContext context, IReadOnlyList<Microsoft.Azure.Documents.Document> docs)
            {
                Console.WriteLine("Change feed in {0}: total {1} doc(s)", name, Interlocked.Add(ref s_totalDocs, docs.Count));
                foreach (var one in docs)
                {
                    Console.WriteLine("Replicated: " + one.Id);
                    Replicate(one);
                }
                return Task.CompletedTask;
            }
        }
    }
</code>```

And initialization of Observer:

```<code>        public async void StartReplication(string replicateFrom, string hostName, Func<dynamic, bool> replicate)
        {

            // Customizable change feed option and host options
            ChangeFeedOptions feedOptions = new ChangeFeedOptions();

            // ie customize StartFromBeginning so change feed reads from beginning
            // can customize MaxItemCount, PartitonKeyRangeId, RequestContinuation, SessionToken and StartFromBeginning
            // feedOptions.StartFromBeginning = true;

            ChangeFeedHostOptions feedHostOptions = new ChangeFeedHostOptions();

            // ie. customizing lease renewal interval to 15 seconds
            // can customize LeaseRenewInterval, LeaseAcquireInterval, LeaseExpirationInterval, FeedPollDelay
            //feedHostOptions.LeaseRenewInterval = TimeSpan.FromSeconds(15);
            feedHostOptions.LeasePrefix = replicateFrom;
            feedHostOptions.FeedPollDelay = TimeSpan.FromSeconds(60);

            try
            {
                DocumentCollectionInfo documentCollectionLocation = new DocumentCollectionInfo
                {
                    Uri = new Uri(_databaseServiceUri),
                    MasterKey = _databaseAuthKey,
                    DatabaseName = _databaseId,
                    CollectionName = replicateFrom
                };
                DocumentCollectionInfo leaseCollectionLocation = new DocumentCollectionInfo
                {
                    Uri = new Uri(_databaseServiceUri),
                    MasterKey = _databaseAuthKey,
                    DatabaseName = _databaseId,
                    CollectionName = "leases"
                };
                DocumentFeedObserverFactory docObserverFactory = new DocumentFeedObserverFactory(replicate, replicateFrom);
                ChangeFeedEventHost host = new ChangeFeedEventHost(hostName, documentCollectionLocation, leaseCollectionLocation, feedOptions, feedHostOptions);

                await host.RegisterObserverFactoryAsync(docObserverFactory);
                hosts.Add(host);
            }
            catch (Exception e)
            {
                Console.WriteLine("Replication process halted for (" + replicateFrom + ") reason: " + e.ToString());
                //throw e;
            }
        }
</code>```

答:
This is part of the Tracing, not an error, it’s viewable in Visual Studio because tracing is on.

When the ProcessChangesAsync finishes, the Processor updates the lease. But there is a separate thread that also maintains leases updated. It’s natural that there is a chance that both threads try to write the same document and generate a concurrency exception (the Pre-condition message), so the Processor traces it and retries and moves on.

This is not an unexpected error, it’s a handled and expected one, the Library just makes sure to trace all the situations.

Body:
I'm trying to create replication from CosmosDB to local CouchBase Lite database. For this I'm using Microsoft.Azure.Documents.ChangeFeedProcessor

But for some reason always after IChangeFeedObserver ProcessChangesAsync has ended I get following exception on console:

What does "Errors":["One of the specified pre-condition is not met"] mean? Replication is ended succesfully otherwise but this bothers me.

Updated with system.diagnostics

ChangeFeedEventHost Information: 53 : 09/25/2017 08:27:54: Host 'TESTIkiosk' starting to check for available leases.
ChangeFeedEventHost Information: 54 : 09/25/2017 08:27:54: Host 'TESTIkiosk' starting to check for available leases.
ChangeFeedEventHost Information: 55 : 09/25/2017 08:27:54: Host 'TESTIkiosk' 1 partitions, 1 hosts, 0 available leases, target = 1, min = 0, max = 0, mine = 1, will try to take 0 lease(s) for myself'.
ChangeFeedEventHost Information: 56 : 09/25/2017 08:27:54: Host 'TESTIkiosk' 1 partitions, 1 hosts, 0 available leases, target = 1, min = 0, max = 0, mine = 1, will try to take 0 lease(s) for myself'.
ChangeFeedEventHost Information: 57 : 09/25/2017 08:28:06: Host 'TESTIkiosk' starting renewal of Leases.
ChangeFeedEventHost Information: 58 : 09/25/2017 08:28:06: Host 'TESTIkiosk' renewing lease for PartitionId '0' with lease token '"0000fa04-0000-0000-0000-59c893d40000"'
ChangeFeedEventHost Information: 59 : 09/25/2017 08:28:06: Host 'TESTIkiosk' starting renewal of Leases.
ChangeFeedEventHost Information: 60 : 09/25/2017 08:28:06: Host 'TESTIkiosk' renewing lease for PartitionId '0' with lease token '"0000fb04-0000-0000-0000-59c893d40000"'
ChangeFeedEventHost Information: 61 : 09/25/2017 08:28:06: Host 'TESTIkiosk' attempted to renew lease for PartitionId '0' and lease token '"0000fa04-0000-0000-0000-59c893d40000"' with result: 'True'
ChangeFeedEventHost Information: 62 : 09/25/2017 08:28:06: Host 'TESTIkiosk' attempted to renew lease for PartitionId '0' and lease token '"0000fb04-0000-0000-0000-59c893d40000"' with result: 'True'
ChangeFeedEventHost Information: 63 : 09/25/2017 08:28:07: Host 'TESTIkiosk' starting to check for available leases.
ChangeFeedEventHost Information: 64 : 09/25/2017 08:28:07: Host 'TESTIkiosk' starting to check for available leases.
ChangeFeedEventHost Information: 65 : 09/25/2017 08:28:07: Host 'TESTIkiosk' 1 partitions, 1 hosts, 0 available leases, target = 1, min = 0, max = 0, mine = 1, will try to take 0 lease(s) for myself'.
ChangeFeedEventHost Information: 66 : 09/25/2017 08:28:07: Host 'TESTIkiosk' 1 partitions, 1 hosts, 0 available leases, target = 1, min = 0, max = 0, mine = 1, will try to take 0 lease(s) for myself'.
[08:28:15 INF] Change feed in Ingredients: total 1 doc(s)
[08:28:15 INF] Replicated 2614
ChangeFeedEventHost Information: 67 : 09/25/2017 08:28:15: Partition '0' update failed because the lease with token '"0000e804-0000-0000-0000-59c893b20000"' was updated by same/this host with token '"00000005-0000-0000-0000-59c893e50000"'. Will retry, 4 retry(s) left.
ChangeFeedEventHost Information: 68 : 09/25/2017 08:28:15: Checkpoint: partition 0, new continuation '"81"'

DocDBTrace Error: 0 : DocumentClientException with status code PreconditionFailed, message: Message: {"Errors":["One of the specified pre-condition is not met"]}, inner exception: null, and response headers: {
"x-ms-last-state-change-utc": "Sun, 24 Sep 2017 21:03:48.392 GMT",
"lsn": "954",
"x-ms-schemaversion": "1.3",
"x-ms-quorum-acked-lsn": "954",
"x-ms-current-write-quorum": "3",
"x-ms-current-replica-set-size": "4",
"x-ms-documentdb-partitionkeyrangeid": "0",
"x-ms-xp-role": "1",
"x-ms-request-charge": "1.24",
"x-ms-serviceversion": " version=1.17.52.1",
"x-ms-activity-id": "b9877abb-6203-4408-b1c3-92c9f52aad67",
}
DocDBTrace Error: 0 : Operation will NOT be retried. Current attempt 0, Exception: Microsoft.Azure.Documents.PreconditionFailedException: Message: {"Errors":["One of the specified pre-condition is not met"]}
ActivityId: b9877abb-6203-4408-b1c3-92c9f52aad67, Request URI: /apps/c9c8f510-0ca7-4702-aa6c-9c596d797367/services/75cca430-a307-47a0-89aa-82aabf32e065/partitions/53fb63ca-95ae-4d13-90be-d32f1a88843c/replicas/131504697049132845p/
   at Microsoft.Azure.Documents.TransportClient.ThrowIfFailed(String resourceAddress, StoreResponse storeResponse, Uri physicalAddress, Guid activityId)
   at Microsoft.Azure.Documents.RntbdTransportClient.<InvokeStoreAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Documents.ReplicatedResourceClient.<WriteAsync>d__1b.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Documents.ReplicatedResourceClient.<InvokeAsync>d__b.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Documents.ReplicatedResourceClient.<>c__DisplayClass1.<<InvokeAsync>b__0>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Documents.BackoffRetryUtility`1.<>c__DisplayClassf`1.<<ExecuteAsync>b__d>d__11.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Documents.BackoffRetryUtility`1.<ExecuteRetry>d__1b.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.Azure.Documents.BackoffRetryUtility`1.<ExecuteRetry>d__1b.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Documents.BackoffRetryUtility`1.<ExecuteAsync>d__18`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Documents.ReplicatedResourceClient.<InvokeAsync>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Documents.StoreClient.<ProcessMessageAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Documents.Client.DocumentClient.<UpdateAsync>d__305.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Documents.Client.DocumentClient.<ReplaceDocumentPrivateAsync>d__13d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Documents.Client.DocumentClient.<ReplaceDocumentPrivateAsync>d__135.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Documents.BackoffRetryUtility`1.<>c__DisplayClass2.<<ExecuteAsync>b__0>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Documents.BackoffRetryUtility`1.<ExecuteRetry>d__1b.MoveNext()

Code for my Implementation:

    using Microsoft.Azure.Documents.ChangeFeedProcessor;
    using System;
    using System.Collections.Generic;
    using System.Threading;
    using System.Threading.Tasks;

    namespace Solteq.Pos.Repositories.Feeds
    {
        internal class MyHostFeed : IChangeFeedObserver
        {
            private int s_totalDocs = 0;
            private Func<dynamic, bool> replicate;
            private string name;

            public Func<dynamic, bool> Replicate { get => replicate; set => replicate = value; }
            public string Name { get => name; set => name = value; }

            public Task OpenAsync(ChangeFeedObserverContext context)
            {
                Console.WriteLine("Worker opened for {0}, {1}", name, context.PartitionKeyRangeId);
                return Task.CompletedTask;  // Requires targeting .NET 4.6+.
            }
            public Task CloseAsync(ChangeFeedObserverContext context, ChangeFeedObserverCloseReason reason)
            {
                Console.WriteLine("Worker closed for  {0}, {1}", name, context.PartitionKeyRangeId);
                return Task.CompletedTask;
            }

            public Task ProcessChangesAsync(ChangeFeedObserverContext context, IReadOnlyList<Microsoft.Azure.Documents.Document> docs)
            {
                Console.WriteLine("Change feed in {0}: total {1} doc(s)", name, Interlocked.Add(ref s_totalDocs, docs.Count));
                foreach (var one in docs)
                {
                    Console.WriteLine("Replicated: " + one.Id);
                    Replicate(one);
                }
                return Task.CompletedTask;
            }
        }
    }

And initialization of Observer:

        public async void StartReplication(string replicateFrom, string hostName, Func<dynamic, bool> replicate)
        {

            // Customizable change feed option and host options
            ChangeFeedOptions feedOptions = new ChangeFeedOptions();

            // ie customize StartFromBeginning so change feed reads from beginning
            // can customize MaxItemCount, PartitonKeyRangeId, RequestContinuation, SessionToken and StartFromBeginning
            // feedOptions.StartFromBeginning = true;

            ChangeFeedHostOptions feedHostOptions = new ChangeFeedHostOptions();

            // ie. customizing lease renewal interval to 15 seconds
            // can customize LeaseRenewInterval, LeaseAcquireInterval, LeaseExpirationInterval, FeedPollDelay
            //feedHostOptions.LeaseRenewInterval = TimeSpan.FromSeconds(15);
            feedHostOptions.LeasePrefix = replicateFrom;
            feedHostOptions.FeedPollDelay = TimeSpan.FromSeconds(60);

            try
            {
                DocumentCollectionInfo documentCollectionLocation = new DocumentCollectionInfo
                {
                    Uri = new Uri(_databaseServiceUri),
                    MasterKey = _databaseAuthKey,
                    DatabaseName = _databaseId,
                    CollectionName = replicateFrom
                };
                DocumentCollectionInfo leaseCollectionLocation = new DocumentCollectionInfo
                {
                    Uri = new Uri(_databaseServiceUri),
                    MasterKey = _databaseAuthKey,
                    DatabaseName = _databaseId,
                    CollectionName = "leases"
                };
                DocumentFeedObserverFactory docObserverFactory = new DocumentFeedObserverFactory(replicate, replicateFrom);
                ChangeFeedEventHost host = new ChangeFeedEventHost(hostName, documentCollectionLocation, leaseCollectionLocation, feedOptions, feedHostOptions);

                await host.RegisterObserverFactoryAsync(docObserverFactory);
                hosts.Add(host);
            }
            catch (Exception e)
            {
                Console.WriteLine("Replication process halted for (" + replicateFrom + ") reason: " + e.ToString());
                //throw e;
            }
        }


问:
Can I use variables on an IPython notebook markup cell?
I have an IPython notebook and I would like to use one of my variables inside a markup cell.  Is this even possible?  If so, how do you do it?</p>

答:
If you don't mind a code cell that does the job, there is a possibility without adding any extensions.

```<code>from IPython.display import Markdown as md

fr=2 #GHz

md("$f_r = %i$ GHz"%(fr))
</code>```

This will show a markdown cell in a nicely LaTeX formatted output

Body:
If you don't mind a code cell that does the job, there is a possibility without adding any extensions.

from IPython.display import Markdown as md

fr=2 #GHz

md("$f_r = %i$ GHz"%(fr))

This will show a markdown cell in a nicely LaTeX formatted output


问:
Image on the top of a multi-column layout with CSS
I have a two column layout (using the CSS multi-column layout module) and I'd like to have an image at the top of the second column. It seems like I have to place the image myself so that it's in the place in the text where the break will be.

The problem is I want the columns to be evenly filled as well.

Is there any way to solve this without JavaScript? This uses a div instead of an image but the idea is to place the red block at the top of its column.

.col-2 {
    -webkit-column-count:2;
    -moz-column-count:2;
    column-count:2;
    width:800px;
}

.block {
    width:100%;
    height:100px;
    background-color:red;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="col-2">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam blandit neque sed eros posuere molestie. Quisque mattis ante ac mauris iaculis semper vehicula nibh condimentum. Pellentesque scelerisque euismod metus a sodales. Praesent dolor nisl, consectetur at tincidunt eu, dapibus at orci. Etiam congue metus id sapien rutrum euismod. Proin porttitor rhoncus hendrerit. Phasellus pellentesque venenatis felis a eleifend. Suspendisse pretium placerat hendrerit. Praesent tempus risus in ligula condimentum egestas. Vivamus vitae nunc massa, luctus egestas lectus. Vivamus at turpis sed nisl molestie vulputate. Vivamus nec tortor et ante consectetur dignissim ac in odio. Cras et nisl non enim congue scelerisque. Curabitur in condimentum eros. Curabitur vehicula augue id neque dignissim vitae venenatis nisi feugiat.

Curabitur tristique ullamcorper neque, ac sodales eros suscipit eu. Nulla pretium accumsan lacus, non fermentum felis lacinia mattis. Sed quis turpis eros. Nullam ut turpis libero. Nam quis magna ac tortor elementum pulvinar. Quisque rutrum eleifend elit, eget consectetur nulla dapibus ac. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Aenean rhoncus commodo tellus, sit amet pulvinar mi vehicula non. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Morbi mollis dignissim felis, et posuere quam molestie nec. Duis sit amet pulvinar dui. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Ut lorem justo, lobortis id imperdiet nec, lobortis varius mauris. Nullam sit amet nulla arcu. Nullam ornare posuere leo vitae rhoncus.

Sed venenatis dui sapien. Praesent sed enim lacus, vitae venenatis metus. Aenean bibendum nibh a risus scelerisque blandit. Maecenas nibh enim, pulvinar in interdum quis, rhoncus ut orci. Vestibulum a ullamcorper ante. Nulla facilisi. Pellentesque placerat ullamcorper diam at mattis. Aliquam posuere suscipit metus sed sollicitudin. Phasellus in quam odio, ac scelerisque purus. Morbi at nunc odio, nec aliquam urna. Proin mi orci, varius vitae dapibus ac, consequat id purus. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Donec a dui lectus, ut congue nunc. Cras diam tortor, auctor in vehicula vitae, egestas eget neque. In nisi odio, laoreet a convallis in, varius at risus.
    <div class="block"></div>
</div></code>```

答:
If I understand what you are trying to do (make the div or image span the full with of all the columns) the way to do this with CSS is to specify column-span: all; on the element (img or div) you want to span across the full width. This is currently only supported in Opera however, and only in an internal build (hopefully we will have a public release with it included soon).

Without using column-span you will have to rely on script or move the mark up to be outside of the element you apply column-count on.

Body:
I have a two column layout (using the CSS multi-column layout module) and I'd like to have an image at the top of the second column. It seems like I have to place the image myself so that it's in the place in the text where the break will be.

The problem is I want the columns to be evenly filled as well.

Is there any way to solve this without JavaScript? This uses a div instead of an image but the idea is to place the red block at the top of its column.

.col-2 {
    -webkit-column-count:2;
    -moz-column-count:2;
    column-count:2;
    width:800px;
}

.block {
    width:100%;
    height:100px;
    background-color:red;
}

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam blandit neque sed eros posuere molestie. Quisque mattis ante ac mauris iaculis semper vehicula nibh condimentum. Pellentesque scelerisque euismod metus a sodales. Praesent dolor nisl, consectetur at tincidunt eu, dapibus at orci. Etiam congue metus id sapien rutrum euismod. Proin porttitor rhoncus hendrerit. Phasellus pellentesque venenatis felis a eleifend. Suspendisse pretium placerat hendrerit. Praesent tempus risus in ligula condimentum egestas. Vivamus vitae nunc massa, luctus egestas lectus. Vivamus at turpis sed nisl molestie vulputate. Vivamus nec tortor et ante consectetur dignissim ac in odio. Cras et nisl non enim congue scelerisque. Curabitur in condimentum eros. Curabitur vehicula augue id neque dignissim vitae venenatis nisi feugiat.

Curabitur tristique ullamcorper neque, ac sodales eros suscipit eu. Nulla pretium accumsan lacus, non fermentum felis lacinia mattis. Sed quis turpis eros. Nullam ut turpis libero. Nam quis magna ac tortor elementum pulvinar. Quisque rutrum eleifend elit, eget consectetur nulla dapibus ac. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Aenean rhoncus commodo tellus, sit amet pulvinar mi vehicula non. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Morbi mollis dignissim felis, et posuere quam molestie nec. Duis sit amet pulvinar dui. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Ut lorem justo, lobortis id imperdiet nec, lobortis varius mauris. Nullam sit amet nulla arcu. Nullam ornare posuere leo vitae rhoncus.

Sed venenatis dui sapien. Praesent sed enim lacus, vitae venenatis metus. Aenean bibendum nibh a risus scelerisque blandit. Maecenas nibh enim, pulvinar in interdum quis, rhoncus ut orci. Vestibulum a ullamcorper ante. Nulla facilisi. Pellentesque placerat ullamcorper diam at mattis. Aliquam posuere suscipit metus sed sollicitudin. Phasellus in quam odio, ac scelerisque purus. Morbi at nunc odio, nec aliquam urna. Proin mi orci, varius vitae dapibus ac, consequat id purus. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Donec a dui lectus, ut congue nunc. Cras diam tortor, auctor in vehicula vitae, egestas eget neque. In nisi odio, laoreet a convallis in, varius at risus.


问:
Android Studio - Failed to create keystore
I'm trying to run my app from inside Android Studio, but every time I try i get this error:

```<code>FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':android:validateSigningDebug'.
> java.util.concurrent.ExecutionException:
com.android.builder.utils.SynchronizedFile$ActionExecutionException:
com.android.ide.common.signing.KeytoolException: Failed to create
keystore.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 2s
</code>```

Searching for a solution online did not lead me to a suitable one.
Running it with the --debug option gives me this result:

```<code>15:21:41.278 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
15:21:41.278 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] FAILURE: Build failed with an exception.
15:21:41.278 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
15:21:41.278 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * What went wrong:
15:21:41.278 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Execution failed for task ':android:validateSigningDebug'.
15:21:41.278 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > java.util.concurrent.ExecutionException: com.android.builder.utils.SynchronizedFile$ActionExecutionException: com.android.ide.common.signing.KeytoolException: Failed to create keystore.
15:21:41.278 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
15:21:41.279 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Try:
15:21:41.279 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Run with --stacktrace option to get the stack trace.
15:21:41.279 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
15:21:41.279 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Get more help at https://help.gradle.org
15:21:41.279 [ERROR] [org.gradle.internal.buildevents.BuildResultLogger]
15:21:41.279 [ERROR] [org.gradle.internal.buildevents.BuildResultLogger] BUILD FAILED in 2s
</code>```

The OS I'm using is Archlinux and the permissions for the .android folder are:

```<code>$ ls -la
drwxr-xr-x  4 speedking speedking    4096 15 nov 11.59 .android
</code>```

Can anyone help me please?

Edit:
Building a signed apk does work, just running the app from Android Studio doesn't.

Running it with --stacktrace outputs this:

```<code>FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':android:validateSigningDebug'.
> java.util.concurrent.ExecutionException: com.android.builder.utils.SynchronizedFile$ActionExecutionException: com.android.ide.common.signing.KeytoolException: Failed to create keystore.

* Try:
Run with --info or --debug option to get more log output.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':android:validateSigningDebug'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:63)
at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88)
at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:124)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:80)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:105)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:99)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:625)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:580)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:99)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
Caused by: org.gradle.internal.UncheckedException: java.util.concurrent.ExecutionException: com.android.builder.utils.SynchronizedFile$ActionExecutionException: com.android.ide.common.signing.KeytoolException: Failed to create keystore.
at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:63)
at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:40)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:76)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.doExecute(DefaultTaskClassInfoStore.java:141)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:121)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:731)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:705)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:122)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:111)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
... 27 more
Caused by: java.util.concurrent.ExecutionException: com.android.builder.utils.SynchronizedFile$ActionExecutionException: com.android.ide.common.signing.KeytoolException: Failed to create keystore.
at com.android.builder.utils.SynchronizedFile.doActionWithMultiProcessLocking(SynchronizedFile.java:267)
at com.android.builder.utils.SynchronizedFile.write(SynchronizedFile.java:232)
at com.android.builder.utils.SynchronizedFile.createIfAbsent(SynchronizedFile.java:328)
at com.android.build.gradle.internal.tasks.ValidateSigningTask.validate(ValidateSigningTask.java:90)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
... 39 more
Caused by: com.android.builder.utils.SynchronizedFile$ActionExecutionException: com.android.ide.common.signing.KeytoolException: Failed to create keystore.
at com.android.builder.utils.SynchronizedFile.lambda$createIfAbsent$0(SynchronizedFile.java:336)
at com.android.builder.utils.SynchronizedFile.doActionWithMultiProcessLocking(SynchronizedFile.java:265)
... 43 more
Caused by: com.android.ide.common.signing.KeytoolException: Failed to create keystore.
at com.android.ide.common.signing.KeystoreHelper.createNewStore(KeystoreHelper.java:158)
at com.android.ide.common.signing.KeystoreHelper.createDebugStore(KeystoreHelper.java:105)
at com.android.build.gradle.internal.tasks.ValidateSigningTask.lambda$validate$0(ValidateSigningTask.java:111)
at com.android.builder.utils.SynchronizedFile.lambda$createIfAbsent$0(SynchronizedFile.java:334)
... 44 more
Caused by: java.lang.SecurityException: class "org.bouncycastle.jcajce.provider.symmetric.IDEA$Mappings"'s signer information does not match signer information of other classes in the same package
at org.bouncycastle.jce.provider.BouncyCastleProvider.loadAlgorithms(Unknown Source)
at org.bouncycastle.jce.provider.BouncyCastleProvider.setup(Unknown Source)
at org.bouncycastle.jce.provider.BouncyCastleProvider.access$000(Unknown Source)
at org.bouncycastle.jce.provider.BouncyCastleProvider$1.run(Unknown Source)
at org.bouncycastle.jce.provider.BouncyCastleProvider.<init>(Unknown Source)
at com.android.ide.common.signing.KeystoreHelper.generateKeyAndCertificate(KeystoreHelper.java:254)
at com.android.ide.common.signing.KeystoreHelper.createNewStore(KeystoreHelper.java:143)
... 47 more

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
</code>```

答: It looks like you are running some Gradle stuff, just change from whatever you have there, and choose what to run: Application or whatever you have, but not gradle.

Body:
I'm trying to run my app from inside Android Studio, but every time I try i get this error:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':android:validateSigningDebug'.
> java.util.concurrent.ExecutionException:
com.android.builder.utils.SynchronizedFile$ActionExecutionException:
com.android.ide.common.signing.KeytoolException: Failed to create
keystore.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 2s

Searching for a solution online did not lead me to a suitable one.
Running it with the --debug option gives me this result:

15:21:41.278 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
15:21:41.278 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] FAILURE: Build failed with an exception.
15:21:41.278 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
15:21:41.278 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * What went wrong:
15:21:41.278 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Execution failed for task ':android:validateSigningDebug'.
15:21:41.278 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > java.util.concurrent.ExecutionException: com.android.builder.utils.SynchronizedFile$ActionExecutionException: com.android.ide.common.signing.KeytoolException: Failed to create keystore.
15:21:41.278 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
15:21:41.279 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Try:
15:21:41.279 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Run with --stacktrace option to get the stack trace.
15:21:41.279 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
15:21:41.279 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Get more help at https://help.gradle.org
15:21:41.279 [ERROR] [org.gradle.internal.buildevents.BuildResultLogger]
15:21:41.279 [ERROR] [org.gradle.internal.buildevents.BuildResultLogger] BUILD FAILED in 2s

The OS I'm using is Archlinux and the permissions for the .android folder are:

$ ls -la
drwxr-xr-x  4 speedking speedking    4096 15 nov 11.59 .android

Can anyone help me please?

Edit:
Building a signed apk does work, just running the app from Android Studio doesn't.

Running it with --stacktrace outputs this:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':android:validateSigningDebug'.
> java.util.concurrent.ExecutionException: com.android.builder.utils.SynchronizedFile$ActionExecutionException: com.android.ide.common.signing.KeytoolException: Failed to create keystore.

* Try:
Run with --info or --debug option to get more log output.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':android:validateSigningDebug'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:63)
at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88)
at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:124)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:80)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:105)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:99)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:625)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:580)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:99)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
Caused by: org.gradle.internal.UncheckedException: java.util.concurrent.ExecutionException: com.android.builder.utils.SynchronizedFile$ActionExecutionException: com.android.ide.common.signing.KeytoolException: Failed to create keystore.
at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:63)
at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:40)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:76)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.doExecute(DefaultTaskClassInfoStore.java:141)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:121)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:731)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:705)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:122)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:111)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
... 27 more
Caused by: java.util.concurrent.ExecutionException: com.android.builder.utils.SynchronizedFile$ActionExecutionException: com.android.ide.common.signing.KeytoolException: Failed to create keystore.
at com.android.builder.utils.SynchronizedFile.doActionWithMultiProcessLocking(SynchronizedFile.java:267)
at com.android.builder.utils.SynchronizedFile.write(SynchronizedFile.java:232)
at com.android.builder.utils.SynchronizedFile.createIfAbsent(SynchronizedFile.java:328)
at com.android.build.gradle.internal.tasks.ValidateSigningTask.validate(ValidateSigningTask.java:90)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
... 39 more
Caused by: com.android.builder.utils.SynchronizedFile$ActionExecutionException: com.android.ide.common.signing.KeytoolException: Failed to create keystore.
at com.android.builder.utils.SynchronizedFile.lambda$createIfAbsent$0(SynchronizedFile.java:336)
at com.android.builder.utils.SynchronizedFile.doActionWithMultiProcessLocking(SynchronizedFile.java:265)
... 43 more
Caused by: com.android.ide.common.signing.KeytoolException: Failed to create keystore.
at com.android.ide.common.signing.KeystoreHelper.createNewStore(KeystoreHelper.java:158)
at com.android.ide.common.signing.KeystoreHelper.createDebugStore(KeystoreHelper.java:105)
at com.android.build.gradle.internal.tasks.ValidateSigningTask.lambda$validate$0(ValidateSigningTask.java:111)
at com.android.builder.utils.SynchronizedFile.lambda$createIfAbsent$0(SynchronizedFile.java:334)
... 44 more
Caused by: java.lang.SecurityException: class "org.bouncycastle.jcajce.provider.symmetric.IDEA$Mappings"'s signer information does not match signer information of other classes in the same package
at org.bouncycastle.jce.provider.BouncyCastleProvider.loadAlgorithms(Unknown Source)
at org.bouncycastle.jce.provider.BouncyCastleProvider.setup(Unknown Source)
at org.bouncycastle.jce.provider.BouncyCastleProvider.access$000(Unknown Source)
at org.bouncycastle.jce.provider.BouncyCastleProvider$1.run(Unknown Source)
at org.bouncycastle.jce.provider.BouncyCastleProvider.<init>(Unknown Source)
at com.android.ide.common.signing.KeystoreHelper.generateKeyAndCertificate(KeystoreHelper.java:254)
at com.android.ide.common.signing.KeystoreHelper.createNewStore(KeystoreHelper.java:143)
... 47 more

* Get more help at https://help.gradle.org

BUILD FAILED in 1s


问:
Retrieve specific field based on structure of file, awk
MyFile:

```<code>    1       Cufflinks       exon    162752  163607  .       +       .       gene_id "XLOC_000001"; transcript_id "TCONS_00000001"; exon_number "1"; oId "CUFF.1.1"; class_code "u"; tss_id "TSS1";
    1       Cufflinks       exon    177199  177399  .       +       .       gene_id "XLOC_000002"; transcript_id "TCONS_00000002"; exon_number "1"; oId "CUFF.3.1"; class_code "u"; tss_id "TSS2";
    1       Cufflinks       exon    178775  179390  .       +       .       gene_id "XLOC_000003"; transcript_id "TCONS_00000003"; exon_number "1"; gene_name "ENSORLG00000000007"; oId "CUFF.15.1"; nearest_ref "ENSORLT00000000006"; class_code "s"; tss_id "TSS3";
    1       Cufflinks       exon    218671  219224  .       +       .       gene_id "XLOC_000007"; transcript_id "TCONS_00000005"; exon_number "1"; gene_name "slc43a1b"; oId "CUFF.50.1"; nearest_ref "ENSORLT00000000013"; class_code "s"; tss_id "TSS7";
</code>```

Disired output:

```<code>    1       Cufflinks       exon    162752  163607  .       +       .       gene_id "XLOC_000001"; transcript_id "TCONS_00000001"; exon_number "1"; oId "CUFF.1.1"; class_code "u"; tss_id "TSS1";
    1       Cufflinks       exon    177199  177399  .       +       .       gene_id "XLOC_000002"; transcript_id "TCONS_00000002"; exon_number "1"; oId "CUFF.3.1"; class_code "u"; tss_id "TSS2";
    1       Cufflinks       exon    180630  180720  .       +       .       gene_id "XLOC_000003"; transcript_id "ENSORLT00000000006"; exon_number "5"; gene_name "ENSORLG00000000007"; oId "CUFF.15.1"; nearest_ref "ENSORLT00000000006"; class_code "s"; tss_id "TSS3";
    1       Cufflinks       exon    218671  219224  .       +       .       gene_id "XLOC_000007"; transcript_id "ENSORLT00000000013"; exon_number "1"; gene_name "slc43a1b"; oId "CUFF.50.1"; nearest_ref "ENSORLT00000000013"; class_code "s"; tss_id "TSS7";
</code>```

Explanation:

If there is a field nearest_ref, write it in field transcript_id, else, do nothing.

Field nearest_ref:

```<code>nearest_ref "XXXXXXX";
</code>```

Field transcript_id:

```<code>transcript_id "XXXXXXX";
</code>```

I would like a awk solution if possible.

I don't know how to retrive fields based on their name and not on their position :

```<code>awk -v FS=" " 'length($20)>20{$12=$20} 1' MyFile |less
</code>```

Note : File is tab separated, 9th column is space separated.

Edit: Found a way to do it, but it is really bad, I am still interested in a better way to do it:

```<code>awk -v FS=" " -v OFS="\t" 'length($20)>20{$12=$20} 1' MyFile | sed "s/;\t/; /g" | sed 's/\t"/ "/g'
</code>```

答:
simple enough for sed

```<code>$ sed -E 's/(transcript_id )[^;]+(.*nearest_ref )([^;]+);/\1\3\2\3;/' file
</code>```

output

```<code>    1       Cufflinks       exon    162752  163607  .       +       .       gene_id "XLOC_000001"; transcript_id "TCONS_00000001"; exon_number "1"; oId "CUFF.1.1"; class_code "u"; tss_id "TSS1";
    1       Cufflinks       exon    177199  177399  .       +       .       gene_id "XLOC_000002"; transcript_id "TCONS_00000002"; exon_number "1"; oId "CUFF.3.1"; class_code "u"; tss_id "TSS2";
    1       Cufflinks       exon    178775  179390  .       +       .       gene_id "XLOC_000003"; transcript_id "ENSORLT00000000006"; exon_number "1"; gene_name "ENSORLG00000000007"; oId "CUFF.15.1"; nearest_ref "ENSORLT00000000006"; class_code "s"; tss_id "TSS3";
    1       Cufflinks       exon    218671  219224  .       +       .       gene_id "XLOC_000007"; transcript_id "ENSORLT00000000013"; exon_number "1"; gene_name "slc43a1b"; oId "CUFF.50.1"; nearest_ref "ENSORLT00000000013"; class_code "s"; tss_id "TSS7";
</code>```

Body:
MyFile:

    1       Cufflinks       exon    162752  163607  .       +       .       gene_id "XLOC_000001"; transcript_id "TCONS_00000001"; exon_number "1"; oId "CUFF.1.1"; class_code "u"; tss_id "TSS1";
    1       Cufflinks       exon    177199  177399  .       +       .       gene_id "XLOC_000002"; transcript_id "TCONS_00000002"; exon_number "1"; oId "CUFF.3.1"; class_code "u"; tss_id "TSS2";
    1       Cufflinks       exon    178775  179390  .       +       .       gene_id "XLOC_000003"; transcript_id "TCONS_00000003"; exon_number "1"; gene_name "ENSORLG00000000007"; oId "CUFF.15.1"; nearest_ref "ENSORLT00000000006"; class_code "s"; tss_id "TSS3";
    1       Cufflinks       exon    218671  219224  .       +       .       gene_id "XLOC_000007"; transcript_id "TCONS_00000005"; exon_number "1"; gene_name "slc43a1b"; oId "CUFF.50.1"; nearest_ref "ENSORLT00000000013"; class_code "s"; tss_id "TSS7";

Disired output:

    1       Cufflinks       exon    162752  163607  .       +       .       gene_id "XLOC_000001"; transcript_id "TCONS_00000001"; exon_number "1"; oId "CUFF.1.1"; class_code "u"; tss_id "TSS1";
    1       Cufflinks       exon    177199  177399  .       +       .       gene_id "XLOC_000002"; transcript_id "TCONS_00000002"; exon_number "1"; oId "CUFF.3.1"; class_code "u"; tss_id "TSS2";
    1       Cufflinks       exon    180630  180720  .       +       .       gene_id "XLOC_000003"; transcript_id "ENSORLT00000000006"; exon_number "5"; gene_name "ENSORLG00000000007"; oId "CUFF.15.1"; nearest_ref "ENSORLT00000000006"; class_code "s"; tss_id "TSS3";
    1       Cufflinks       exon    218671  219224  .       +       .       gene_id "XLOC_000007"; transcript_id "ENSORLT00000000013"; exon_number "1"; gene_name "slc43a1b"; oId "CUFF.50.1"; nearest_ref "ENSORLT00000000013"; class_code "s"; tss_id "TSS7";

Explanation:

If there is a field nearest_ref, write it in field transcript_id, else, do nothing.

Field nearest_ref:

nearest_ref "XXXXXXX";

Field transcript_id:

transcript_id "XXXXXXX";

I would like a awk solution if possible.

I don't know how to retrive fields based on their name and not on their position :

awk -v FS=" " 'length($20)>20{$12=$20} 1' MyFile |less

Note : File is tab separated, 9th column is space separated.

Edit: Found a way to do it, but it is really bad, I am still interested in a better way to do it:

awk -v FS=" " -v OFS="\t" 'length($20)>20{$12=$20} 1' MyFile | sed "s/;\t/; /g" | sed 's/\t"/ "/g'

Body:
simple enough for sed

$ sed -E 's/(transcript_id )[^;]+(.*nearest_ref )([^;]+);/\1\3\2\3;/' file

output

    1       Cufflinks       exon    162752  163607  .       +       .       gene_id "XLOC_000001"; transcript_id "TCONS_00000001"; exon_number "1"; oId "CUFF.1.1"; class_code "u"; tss_id "TSS1";
    1       Cufflinks       exon    177199  177399  .       +       .       gene_id "XLOC_000002"; transcript_id "TCONS_00000002"; exon_number "1"; oId "CUFF.3.1"; class_code "u"; tss_id "TSS2";
    1       Cufflinks       exon    178775  179390  .       +       .       gene_id "XLOC_000003"; transcript_id "ENSORLT00000000006"; exon_number "1"; gene_name "ENSORLG00000000007"; oId "CUFF.15.1"; nearest_ref "ENSORLT00000000006"; class_code "s"; tss_id "TSS3";
    1       Cufflinks       exon    218671  219224  .       +       .       gene_id "XLOC_000007"; transcript_id "ENSORLT00000000013"; exon_number "1"; gene_name "slc43a1b"; oId "CUFF.50.1"; nearest_ref "ENSORLT00000000013"; class_code "s"; tss_id "TSS7";


问:
Display product attachment in prestashop
In prestashop when I add a picture as an attachment to a product it saves file in download/filename but the problem is that the filename is without extension

eg. b112ddf78daac05a027abd52e67e8d2d6e6dee0a

How to display picture in html () if filename does not have an extension?

答:
I'm assuming you're using the $attachments array to display the image on the product page? Since the extension doesn't matter (the browser looks for the mime type, see more here), you could do the following :

```<code>{foreach from=$attachments item=attachment name=attachments}
  <img src="{$link->getPageLink('attachment', true, NULL, "id_attachment={$attachment.id_attachment}")|escape:'html':'UTF-8'}">
{/foreach}
</code>```

Body:
I'm assuming you're using the $attachments array to display the image on the product page? Since the extension doesn't matter (the browser looks for the mime type, see more here), you could do the following :

{foreach from=$attachments item=attachment name=attachments}
  <img src="{$link->getPageLink('attachment', true, NULL, "id_attachment={$attachment.id_attachment}")|escape:'html':'UTF-8'}">
{/foreach}


问:
Looping through a recordset to output Ms-Access report to a pdf file
I'm trying to get pdf file by tenant_id using docmd.outputTo. Unfortunately this routine produce output pdf file that all are in a same single tenant_id. If I remove docmd.outputTo last parameter pathName & fileName then it's require file name through dialogue and output file nicely filtered by tenant_id. Any help would be appreciated.

Here's the query of invoice: SELECT * FROM tblInvoice WHERE tenant_id = CurTenantID()

```<code>Public Sub Output()
    Dim MyRs As DAO.Recordset
    Dim rpt As Report
    Dim fileName As String, pathName As String, todayDate As String

    pathName = "C:\Users\abzalali\Dropbox\tenant_db\Invoice\"
    todayDate = Format(Date, "MMDDYYYY")
    Set MyRs = CurrentDb.OpenRecordset("SELECT tenant_id, name, company, email FROM qryEmailClientList")

    DoCmd.OpenReport "Invoice", acPreview, , , acHidden
    Set rpt = Reports("Invoice")

    With MyRs
        .MoveFirst
            Do While Not .EOF
                fileName = "Invoice_" & todayDate & !tenant_id & ".pdf"
                rpt.Filter = "[tenant_id] = " & !tenant_id
                rpt.FilterOn = True
                DoCmd.OutputTo acOutputReport, "Invoice", acFormatPDF, pathName & fileName
               .MoveNext
            Loop
    End With

End Sub
</code>```

答:
Simply use the DoCmd.OpenReport method to filter report and then leave the report name blank in DoCmd.OutputTo as per the docs:

ObjectName > Optional > Variant: If you want to output the active object, specify the object's type for the ObjectType argument and leave this argument blank.

```<code>With MyRs
    .MoveFirst
    Do While Not .EOF
        fileName = "Invoice_" & todayDate & !tenant_id & ".pdf"

        DoCmd.OpenReport "Invoice", acViewReport, , "[tenant_id] = " & !tenant_id, acHidden
        DoCmd.OutputTo acOutputReport, , acFormatPDF, pathName & fileName
        .MoveNext
    Loop
End With
</code>```

Body:
I'm trying to get pdf file by tenant_id using docmd.outputTo. Unfortunately this routine produce output pdf file that all are in a same single tenant_id. If I remove docmd.outputTo last parameter pathName & fileName then it's require file name through dialogue and output file nicely filtered by tenant_id. Any help would be appreciated.

Here's the query of invoice: SELECT * FROM tblInvoice WHERE tenant_id = CurTenantID()

Public Sub Output()
    Dim MyRs As DAO.Recordset
    Dim rpt As Report
    Dim fileName As String, pathName As String, todayDate As String

    pathName = "C:\Users\abzalali\Dropbox\tenant_db\Invoice\"
    todayDate = Format(Date, "MMDDYYYY")
    Set MyRs = CurrentDb.OpenRecordset("SELECT tenant_id, name, company, email FROM qryEmailClientList")

    DoCmd.OpenReport "Invoice", acPreview, , , acHidden
    Set rpt = Reports("Invoice")

    With MyRs
        .MoveFirst
            Do While Not .EOF
                fileName = "Invoice_" & todayDate & !tenant_id & ".pdf"
                rpt.Filter = "[tenant_id] = " & !tenant_id
                rpt.FilterOn = True
                DoCmd.OutputTo acOutputReport, "Invoice", acFormatPDF, pathName & fileName
               .MoveNext
            Loop
    End With

End Sub

Body:
Simply use the DoCmd.OpenReport method to filter report and then leave the report name blank in DoCmd.OutputTo as per the docs:

ObjectName > Optional > Variant: If you want to output the active object, specify the object's type for the ObjectType argument and leave this argument blank.

With MyRs
    .MoveFirst
    Do While Not .EOF
        fileName = "Invoice_" & todayDate & !tenant_id & ".pdf"

        DoCmd.OpenReport "Invoice", acViewReport, , "[tenant_id] = " & !tenant_id, acHidden
        DoCmd.OutputTo acOutputReport, , acFormatPDF, pathName & fileName
        .MoveNext
    Loop
End With


问:
jQuery Hover question
here:

http://www.jsfiddle.net/JEXru/1/

i don't know how to make it so if you hover over the slide it stays active ... help?

答:
For what you want, you don't need any Javascript. Add these to your CSS:

```<code>#horzAccordion ul li.slide { display: none; }
#horzAccordion ul:hover li.slide { display: block; }
</code>```

Then remove your hover jQuery function and $('.slide').hide();.

Title: jQuery Hover question

Body:
For what you want, you don't need any Javascript. Add these to your CSS:

#horzAccordion ul li.slide { display: none; }
#horzAccordion ul:hover li.slide { display: block; }

Then remove your hover jQuery function and $('.slide').hide();.