问:
How to push data from one div to another div(table) using angular js?
I am trying to add the json data to a table on clicking the + icon. There are 2 section namely Pick Stocks from where the stocks and price (which inturn are coming from data.json) has to be added to the table present in Manage Portfolio section.

First Section

Second Section

So I want the stock name i.e. ADFI, ALAN etc and its respective price to be added to respective stock and price columns of table in second section when a respective + icon is clicked.
I have tried adding but I am not entirely sure about how to go forward.
Thank you.
Here is the plunker

```<code>             <table>
                <tr>
                    <th>STOCK</th>
                    <th>PRICE</th>
                    <th>SHARES</th>
                    <th>WEIGHT</th>
                </tr>
                <tr ng-repeat="portfolio in portfolios">
                    <td ng-model="portfolio.stockfromdata"></td>
                    <td ng-model="portfolio.pricefromdata"></td>
                    <td>num</td>
                    <td ng-model="portfolio.weightfromprice"></td>
                </tr>
            </table>
</code>```

Script

```<code> $scope.portfolios = [];

    $scope.addStock = function() {
        $scope.portfolios.push([{
            "key": $scope.portfolio.stockfromdata,
            "value": $scope.portfolio.pricefromdata
            // "weightfromprice": $scope.weightfromprice
        }]);
    };
</code>```

答:
ng-model directive is used for a 2-way binding,
 so instead of

try using 	 or {{portfolio.stockfromdata}}

and if want to make it editable, then you can use your ng-model with input like
<input ng-model="portfolio.stockfromdata"/>

here ng-model will binfd your data to the input model, and change in UI will also reflect to JSON binded data in your controller, thats the purpose of ng-model

Body:
I am trying to add the json data to a table on clicking the + icon. There are 2 section namely Pick Stocks from where the stocks and price (which inturn are coming from data.json) has to be added to the table present in Manage Portfolio section.

First Section

Second Section

So I want the stock name i.e. ADFI, ALAN etc and its respective price to be added to respective stock and price columns of table in second section when a respective + icon is clicked.
I have tried adding but I am not entirely sure about how to go forward.
Thank you.
Here is the plunker

                    STOCK
                    PRICE
                    SHARES
                    WEIGHT

                    num

Script

 $scope.portfolios = [];

    $scope.addStock = function() {
        $scope.portfolios.push([{
            "key": $scope.portfolio.stockfromdata,
            "value": $scope.portfolio.pricefromdata
            // "weightfromprice": $scope.weightfromprice
        }]);
    };

Body:
ng-model directive is used for a 2-way binding,
 so instead of <td ng-model="portfolio.stockfromdata"></td>

try using <td ng-bind="portfolio.stockfromdata"></td> or <td>{{portfolio.stockfromdata}}</td>

and if want to make it editable, then you can use your ng-model with input like
<td ><input ng-model="portfolio.stockfromdata"/></td>

here ng-model will binfd your data to the input model, and change in UI will also reflect to JSON binded data in your controller, thats the purpose of ng-model


来源: stackexchange

问:
Know proportions of ggplot2 plot
I usually save the plots from ggplot2 using the the png device. The width and the height of the output are set by the arguments of the function. Blank zones are drawn when the "natural proportions" of the graph dont't suit the proportions of the device. In order to avoid this and use the whole defined canvas, the proportions of the plot must be known. ¿Is there a way to find out this value without trial and error?

This code can be  used as an example:

```<code>x <- seq(from = 0, to = 1, by = 0.1)
y <- seq(from = 1, to = 2, by = 0.1)
df <- expand.grid(x = x, y = y)
df <- cbind(df, z = rnorm(ncol(df), 0, 1))

p <- ggplot(df, aes(x,y, fill = z)) + geom_raster() + coord_fixed()

ppi <- 300

#Value 0.4 is used to change inches into milimeters
png("plot.png", width = 16*0.4*ppi, height = 20*0.4*ppi, res = ppi)
print(p)
dev.off()
</code>```

It can be seen that some blank space is added at the top and at the bottom to fill the png file. This could be easily corrected by using a proportion different from 20/16, which is not optimal.

答:
You can modify the ratio arg inside coord_fixed():

```<code>p <- ggplot(df, aes(x,y, fill = z)) +
       geom_raster() +
       coord_fixed(ratio = 20/16)
</code>```

Alteratively you can specify the aspect.ratio inside the theme():

```<code>p <- ggplot(df, aes(x,y, fill = z)) +
       geom_raster() +
       theme(aspect.ratio = 20/16)
</code>```

The result is the same:

ContentLicense: CC BY-SA 3.0

Title: Know proportions of ggplot2 plot

Body:
I usually save the plots from ggplot2 using the the png device. The width and the height of the output are set by the arguments of the function. Blank zones are drawn when the "natural proportions" of the graph dont't suit the proportions of the device. In order to avoid this and use the whole defined canvas, the proportions of the plot must be known. ¿Is there a way to find out this value without trial and error?

This code can be  used as an example:

x <- seq(from = 0, to = 1, by = 0.1)
y <- seq(from = 1, to = 2, by = 0.1)
df <- expand.grid(x = x, y = y)
df <- cbind(df, z = rnorm(ncol(df), 0, 1))

p <- ggplot(df, aes(x,y, fill = z)) + geom_raster() + coord_fixed()

ppi <- 300

#Value 0.4 is used to change inches into milimeters
png("plot.png", width = 16*0.4*ppi, height = 20*0.4*ppi, res = ppi)
print(p)
dev.off()

It can be seen that some blank space is added at the top and at the bottom to fill the png file. This could be easily corrected by using a proportion different from 20/16, which is not optimal.

Body:
You can modify the ratio arg inside coord_fixed():

p <- ggplot(df, aes(x,y, fill = z)) +
       geom_raster() +
       coord_fixed(ratio = 20/16)

Alteratively you can specify the aspect.ratio inside the theme():

p <- ggplot(df, aes(x,y, fill = z)) +
       geom_raster() +
       theme(aspect.ratio = 20/16)

The result is the same:


问:
how to increase limit for facebook insights api cursor
I am using async method to generate the insights report. In order to get data from it, I am iterating over the results where it gives me 25 values at a time. How can I increase this limit?

More details:

Logs:

```<code>2017-03-30 09:27:41.926362  DEBUG   171:0   facebook.py:get_ads_insight     insights type: <class 'facebookads.api.Cursor'>
2017-03-30 09:27:41.926979  DEBUG   176:0   facebook.py:get_ads_insight     insights present: 25
</code>```

Insights API facebook: https://developers.facebook.com/docs/marketing-api/insights/async/v2.8

Sample code:

```<code>from facebookads.adobjects.campaign import Campaign
from facebookads.adobjects.adsinsights import AdsInsights
from facebookads.adobjects.adreportrun import AdReportRun
import time

campaign = Campaign(<CAMPAIGN_ID>)
params = {
    'level': AdsInsights.Level.campaign,
}
async_job = campaign.get_insights(params=params, async=True)

async_job.remote_read()

while async_job[AdReportRun.Field.async_percent_completion] < 100:
    time.sleep(1)
    async_job.remote_read()

time.sleep(1)

print(async_job.get_result())
</code>```

答:
You can pass parameters to get_result(), for example:

async_job.get_result(params={'limit': '100',})

Body:
I am using async method to generate the insights report. In order to get data from it, I am iterating over the results where it gives me 25 values at a time. How can I increase this limit?

More details:

Logs:

2017-03-30 09:27:41.926362  DEBUG   171:0   facebook.py:get_ads_insight     insights type: <class 'facebookads.api.Cursor'>
2017-03-30 09:27:41.926979  DEBUG   176:0   facebook.py:get_ads_insight     insights present: 25

Insights API facebook: https://developers.facebook.com/docs/marketing-api/insights/async/v2.8

Sample code:

from facebookads.adobjects.campaign import Campaign
from facebookads.adobjects.adsinsights import AdsInsights
from facebookads.adobjects.adreportrun import AdReportRun
import time

campaign = Campaign(<CAMPAIGN_ID>)
params = {
    'level': AdsInsights.Level.campaign,
}
async_job = campaign.get_insights(params=params, async=True)

async_job.remote_read()

while async_job[AdReportRun.Field.async_percent_completion] < 100:
    time.sleep(1)
    async_job.remote_read()

time.sleep(1)

print(async_job.get_result())


问:
"From File" Simulink block called from Matlab .m file in loop
I am calling a Simulink simulation through a loop in Matlab. I am able to send many numerical parameters (initial conditions for integrators for example), but an error arises in my "From File" block.

I'm not quite sure how other people do it, but where I work we send it through a home-built function which takes a structure input. The fields of the structure are the variable names and the values of the fields are the variables themselves. for example:

```<code>pb = struct('preload',preload(pl_index),...
            'displacement',preload_displacement(pl_index),...
            'filename',fileList{m});
</code>```

The 'preload' and 'displacement' variables evaluate fine, but the filename gives an error:

```<code>filename.mat
</code>```

Does anyone know if you can pass the value of the variable filename (fileList{m}) in the 'From File' block and if so, how to do it. Thanks!

答:
Answering my own question!

I used the Simulink "From Workspace" block instead of "From File".

```<code>f = load(fileList{m});
fnames = fieldnames(f);
% The files were arranged weird, so I have one field inside the structures... and they all had different names.
    switch fnames{1}
        case 'first'
            filedata = f.first;
        case 'second'
            filedata = f.second;
        case 'third'
            filedata = f.third;
        case 'fourth'
            filedata = f.fourth;
    end
    t = filedata(1,:);
    u = filedata(2,:);

loaded_file = timeseries(u,t);
</code>```

And I pass loaded_file to my function.

Body:
I am calling a Simulink simulation through a loop in Matlab. I am able to send many numerical parameters (initial conditions for integrators for example), but an error arises in my "From File" block.

I'm not quite sure how other people do it, but where I work we send it through a home-built function which takes a structure input. The fields of the structure are the variable names and the values of the fields are the variables themselves. for example:

pb = struct('preload',preload(pl_index),...
            'displacement',preload_displacement(pl_index),...
            'filename',fileList{m});

The 'preload' and 'displacement' variables evaluate fine, but the filename gives an error:

filename.mat

Does anyone know if you can pass the value of the variable filename (fileList{m}) in the 'From File' block and if so, how to do it. Thanks!

Body:
Answering my own question!

I used the Simulink "From Workspace" block instead of "From File".

f = load(fileList{m});
fnames = fieldnames(f);
% The files were arranged weird, so I have one field inside the structures... and they all had different names.
    switch fnames{1}
        case 'first'
            filedata = f.first;
        case 'second'
            filedata = f.second;
        case 'third'
            filedata = f.third;
        case 'fourth'
            filedata = f.fourth;
    end
    t = filedata(1,:);
    u = filedata(2,:);

loaded_file = timeseries(u,t);

And I pass loaded_file to my function.


问:
Why does the output differ for tm package and RTextTools package?
I have a dataset of 260 RTI applications. I am supposed to perform LDA on them. I have created the term-doc matrix using tm as well as RTextTools package. However, the output differs greatly. Tm package doesn't show any sparse entry counts. The number of total terms differs greatly.
Here is the code:

```<code>library("tm")
library("RTextTools")
<I read the data here into a variable called 'data'>
doc = Corpus(VectorSource(data))
m = create_matrix(data, language = "english", removeNumbers = TRUE, removePunctuation = TRUE, stemWords = TRUE, weighting = weightTf) #RtextTools statement
tdm <- TermDocumentMatrix(doc, control = list(removePunctuation = TRUE, removeNumbers = TRUE, language = "english", stemWords = TRUE, stopWords = TRUE, weighting = weightTf) #tm statement
>m
#<<DocumentTermMatrix (documents: 260, terms: 951)>>
Non-/sparse entries: 2669/244591
Sparsity           : 99%
>tdm
#<<TermDocumentMatrix (terms: 1024, documents: 1)>>
Non-/sparse entries: 1024/0
Sparsity           : 0%
</code>```

If you need the dataset to understand the problem better, let me know.

答: See ?termFreq - it has got to be stemming=TRUE, stopwords=TRUE instead of stemWords = TRUE, stopWords = TRUE. Also note that a SimpleCorpus object triggers a default behavior for TermDocumentMatrix that may override your control parameters.

Body:
I have a dataset of 260 RTI applications. I am supposed to perform LDA on them. I have created the term-doc matrix using tm as well as RTextTools package. However, the output differs greatly. Tm package doesn't show any sparse entry counts. The number of total terms differs greatly.
Here is the code:

library("tm")
library("RTextTools")

doc = Corpus(VectorSource(data))
m = create_matrix(data, language = "english", removeNumbers = TRUE, removePunctuation = TRUE, stemWords = TRUE, weighting = weightTf) #RtextTools statement
tdm <- TermDocumentMatrix(doc, control = list(removePunctuation = TRUE, removeNumbers = TRUE, language = "english", stemWords = TRUE, stopWords = TRUE, weighting = weightTf) #tm statement
>m
#<<DocumentTermMatrix (documents: 260, terms: 951)>>
Non-/sparse entries: 2669/244591
Sparsity           : 99%
>tdm
#<<TermDocumentMatrix (terms: 1024, documents: 1)>>
Non-/sparse entries: 1024/0
Sparsity           : 0%

If you need the dataset to understand the problem better, let me know.


问:
Can I make a button/icon in a MFC toolbar that can't be clicked?
I have a subclass of CMFCToolBar that contains a few buttons, one for toggling a setting and the others for displaying the current state (shown one at a time). I need the other buttons to not be clickable- if the user clicks on them, they should not depress. Is there a way to prevent a button from depressing without making it disabled (because then it is grayed out) or to add an icon to a toolbar that has no interaction?</p>

答: It's been a while since I've done MFC, so I'm not too sure of the name, of the control, but I think you can put an icon in a CLabel (or maybe CLabelImage).  You don't want to use a button for this because a button is supposed to be clicked, i.e., it looks push-able.  You want something like a label that just shows state, that's what labels are for.</p>

ContentLicense: CC BY-SA 2.5


问:
Error occurs when cocos 2d-x-3.15.1 project compiling in android studio
Don't know how to solve this problem of cocos 2d-x-3.15.1

```<code> Warning:android-validator: Suspicious module dependency proj.android -> android: Android application module depends on other application module. Possibly, you should change type of module 'android' to 'Library' or change the dependency scope to 'Provided'.
    Error:Android Pre Dex: [EngineDataManager.jar] at org.jetbrains.android.compiler.tools.AndroidDxRunner.runDex(AndroidDxRunner.java:139)
    Error:Android Pre Dex: [EngineDataManager.jar] Exception in thread "main" java.lang.NullPointerException
    Error:Android Pre Dex: [EngineDataManager.jar] at org.jetbrains.android.compiler.tools.AndroidDxRunner.main(AndroidDxRunner.java:336)
    Error:Android Pre Dex: [EngineDataManager.jar] at org.jetbrains.android.compiler.tools.AndroidDxRunner.loadDex(AndroidDxRunner.java:80)
    Error:Android Pre Dex: [EngineDataManager.jar] at org.jetbrains.android.compiler.tools.AndroidDxRunner.runDex(AndroidDxRunner.java:136)
    Error:Android Pre Dex: [EngineDataManager.jar] at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    Error:Android Pre Dex: [EngineDataManager.jar] at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    Error:Android Pre Dex: [EngineDataManager.jar] at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
    Error:Android Pre Dex: [EngineDataManager.jar] at java.security.AccessController.doPrivileged(Native Method)
    Error:Android Pre Dex: [EngineDataManager.jar] at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    Error:Android Pre Dex: [EngineDataManager.jar] at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
    Error:Android Pre Dex: [EngineDataManager.jar] Failed to load dx.jar
    Error:Android Pre Dex: [EngineDataManager.jar] java.lang.ClassNotFoundException: com.android.dx.command.DxConsole
</code>```

Installing android studio 2.3.3 than still its showing this some error same like android studio 2.1.1. I don't understand what was the problem in it.. Please help me out from that!!

```<code>Error:Android Pre Dex: [httpclient-4.4.1.1.jar] Failed to load dx.jar
Error:Android Pre Dex: [httpclient-4.4.1.1.jar] at org.jetbrains.android.compiler.tools.AndroidDxRunner.runDex(AndroidDxRunner.java:139)
Error:Android Pre Dex: [httpclient-4.4.1.1.jar] Exception in thread "main" java.lang.NullPointerException
Error:Android Pre Dex: [httpclient-4.4.1.1.jar] at org.jetbrains.android.compiler.tools.AndroidDxRunner.main(AndroidDxRunner.java:336)
Error:Android Pre Dex: [httpclient-4.4.1.1.jar] at org.jetbrains.android.compiler.tools.AndroidDxRunner.runDex(AndroidDxRunner.java:136)
Error:Android Pre Dex: [httpclient-4.4.1.1.jar] at org.jetbrains.android.compiler.tools.AndroidDxRunner.loadDex(AndroidDxRunner.java:80)
Error:Android Pre Dex: [httpclient-4.4.1.1.jar] at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
Error:Android Pre Dex: [httpclient-4.4.1.1.jar] at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
Error:Android Pre Dex: [httpclient-4.4.1.1.jar] at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
Error:Android Pre Dex: [httpclient-4.4.1.1.jar] java.lang.ClassNotFoundException: com.android.dx.command.DxConsole

Error Occur at the time of Compiling the project in android studio. Its showing some dx.jar file error and some error which are unable to understand it. So please help me out from this error!

Error:Android Pre Dex: [annotations.jar] at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
        Error:Android Pre Dex: [annotations.jar] at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
        Information:05/07/2017 12:24 PM - Compilation completed with 13 errors and 0 warnings in 5s 253ms
        Error:Android Pre Dex: [annotations.jar] Failed to load dx.jar
        Error:Android Pre Dex: [annotations.jar] at java.security.AccessController.doPrivileged(Native Method)
        Error:Android Pre Dex: [annotations.jar] java.lang.ClassNotFoundException: com.android.dx.command.DxConsole
        Error:Android Pre Dex: [annotations.jar] at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        Error:Android Pre Dex: [annotations.jar] at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
        Error:Android Pre Dex: [annotations.jar] at org.jetbrains.android.compiler.tools.AndroidDxRunner.loadDex(AndroidDxRunner.java:80)
        Error:Android Pre Dex: [annotations.jar] at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        Error:Android Pre Dex: [annotations.jar] at org.jetbrains.android.compiler.tools.AndroidDxRunner.runDex(AndroidDxRunner.java:136)
        Error:Android Pre Dex: [annotations.jar] Exception in thread "main" java.lang.NullPointerException
        Error:Android Pre Dex: [annotations.jar] at org.jetbrains.android.compiler.tools.AndroidDxRunner.main(AndroidDxRunner.java:336)
        Error:Android Pre Dex: [annotations.jar] at org.jetbrains.android.compiler.tools.AndroidDxRunner.runDex(AndroidDxRunner.java:139)
        Information:java: Some input files use unchecked or unsafe operations.
        Information:java: Recompile with -Xlint:unchecked for details.
        G:\Kunal\Gaming\cocos2d\cocos\platform\android\java\src\org\cocos2dx\lib\Cocos2dxSound.java
</code>```

答:
I have had same issue.
Followed this solution and worked!

The solution is for Ubuntu and OSX but I am sure it will work for Windows as well.

Body:
Don't know how to solve this problem of cocos 2d-x-3.15.1

 Warning:android-validator: Suspicious module dependency proj.android -> android: Android application module depends on other application module. Possibly, you should change type of module 'android' to 'Library' or change the dependency scope to 'Provided'.
    Error:Android Pre Dex: [EngineDataManager.jar] at org.jetbrains.android.compiler.tools.AndroidDxRunner.runDex(AndroidDxRunner.java:139)
    Error:Android Pre Dex: [EngineDataManager.jar] Exception in thread "main" java.lang.NullPointerException
    Error:Android Pre Dex: [EngineDataManager.jar] at org.jetbrains.android.compiler.tools.AndroidDxRunner.main(AndroidDxRunner.java:336)
    Error:Android Pre Dex: [EngineDataManager.jar] at org.jetbrains.android.compiler.tools.AndroidDxRunner.loadDex(AndroidDxRunner.java:80)
    Error:Android Pre Dex: [EngineDataManager.jar] at org.jetbrains.android.compiler.tools.AndroidDxRunner.runDex(AndroidDxRunner.java:136)
    Error:Android Pre Dex: [EngineDataManager.jar] at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    Error:Android Pre Dex: [EngineDataManager.jar] at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    Error:Android Pre Dex: [EngineDataManager.jar] at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
    Error:Android Pre Dex: [EngineDataManager.jar] at java.security.AccessController.doPrivileged(Native Method)
    Error:Android Pre Dex: [EngineDataManager.jar] at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    Error:Android Pre Dex: [EngineDataManager.jar] at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
    Error:Android Pre Dex: [EngineDataManager.jar] Failed to load dx.jar
    Error:Android Pre Dex: [EngineDataManager.jar] java.lang.ClassNotFoundException: com.android.dx.command.DxConsole

Installing android studio 2.3.3 than still its showing this some error same like android studio 2.1.1. I don't understand what was the problem in it.. Please help me out from that!!

Error:Android Pre Dex: [httpclient-4.4.1.1.jar] Failed to load dx.jar
Error:Android Pre Dex: [httpclient-4.4.1.1.jar] at org.jetbrains.android.compiler.tools.AndroidDxRunner.runDex(AndroidDxRunner.java:139)
Error:Android Pre Dex: [httpclient-4.4.1.1.jar] Exception in thread "main" java.lang.NullPointerException
Error:Android Pre Dex: [httpclient-4.4.1.1.jar] at org.jetbrains.android.compiler.tools.AndroidDxRunner.main(AndroidDxRunner.java:336)
Error:Android Pre Dex: [httpclient-4.4.1.1.jar] at org.jetbrains.android.compiler.tools.AndroidDxRunner.runDex(AndroidDxRunner.java:136)
Error:Android Pre Dex: [httpclient-4.4.1.1.jar] at org.jetbrains.android.compiler.tools.AndroidDxRunner.loadDex(AndroidDxRunner.java:80)
Error:Android Pre Dex: [httpclient-4.4.1.1.jar] at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
Error:Android Pre Dex: [httpclient-4.4.1.1.jar] at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
Error:Android Pre Dex: [httpclient-4.4.1.1.jar] at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
Error:Android Pre Dex: [httpclient-4.4.1.1.jar] java.lang.ClassNotFoundException: com.android.dx.command.DxConsole

Error Occur at the time of Compiling the project in android studio. Its showing some dx.jar file error and some error which are unable to understand it. So please help me out from this error!

Error:Android Pre Dex: [annotations.jar] at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
        Error:Android Pre Dex: [annotations.jar] at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
        Information:05/07/2017 12:24 PM - Compilation completed with 13 errors and 0 warnings in 5s 253ms
        Error:Android Pre Dex: [annotations.jar] Failed to load dx.jar
        Error:Android Pre Dex: [annotations.jar] at java.security.AccessController.doPrivileged(Native Method)
        Error:Android Pre Dex: [annotations.jar] java.lang.ClassNotFoundException: com.android.dx.command.DxConsole
        Error:Android Pre Dex: [annotations.jar] at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        Error:Android Pre Dex: [annotations.jar] at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
        Error:Android Pre Dex: [annotations.jar] at org.jetbrains.android.compiler.tools.AndroidDxRunner.loadDex(AndroidDxRunner.java:80)
        Error:Android Pre Dex: [annotations.jar] at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        Error:Android Pre Dex: [annotations.jar] at org.jetbrains.android.compiler.tools.AndroidDxRunner.runDex(AndroidDxRunner.java:136)
        Error:Android Pre Dex: [annotations.jar] Exception in thread "main" java.lang.NullPointerException
        Error:Android Pre Dex: [annotations.jar] at org.jetbrains.android.compiler.tools.AndroidDxRunner.main(AndroidDxRunner.java:336)
        Error:Android Pre Dex: [annotations.jar] at org.jetbrains.android.compiler.tools.AndroidDxRunner.runDex(AndroidDxRunner.java:139)
        Information:java: Some input files use unchecked or unsafe operations.
        Information:java: Recompile with -Xlint:unchecked for details.
        G:\Kunal\Gaming\cocos2d\cocos\platform\android\java\src\org\cocos2dx\lib\Cocos2dxSound.java


问:
Double value from sum query
I'm currently using access to keep track of my stockportfolio. It contains ~20 tables. I use a query to include the most important data to export into excel. Two data tables include two names each that are identical but with different values. This results in the sum om Mkt_Value, Contr and Vol (shown in code) to recieve a double valuation.

From googling I think it revolves around having to use subselects and something other than left join. The problem is I have mostly used query wizard for this query so I am unsure how to tackle the problem. Any guidance would be greatly appreciated!

I posted an excerpt of the code containg the four tables causing the problem: tbl_datum (Date table), tbl_positions, tbl_ARMSpositions and tbl_ARMSgreeks.

Thanks in advance!

```<code>SELECT
tbl_Positions.ARMSNAME,
tbl_Positions.Uploaddate,
Sum(tbl_ARMSpositions.Mkt_Value),
Sum(tbl_ARMSpositions.Contr),
Sum(tbl_ARMSgreeks.Vol)

FROM
((tbl_Datum INNER JOIN tbl_Positions ON tbl_Datum.Datum = tbl_Positions.UploadDate)

LEFT JOIN
tbl_ARMSpositions ON (tbl_Positions.Uploaddate = tbl_ARMSpositions.Value_Date) AND (tbl_Positions.ARMSNAME = tbl_ARMSpositions.Name))

LEFT JOIN
tbl_ARMSgreeks ON (tbl_Positions.Uploaddate = tbl_ARMSgreeks.Value_Date) AND (tbl_Positions.ARMSNAME = tbl_ARMSgreeks.Name)

GROUP BY
tbl_Positions.ARMSNAME,
tbl_Positions.Uploaddate;
</code>```

答:
Without seeing your data, I'll have to guess.  Based on your description and comment, it sounds like you have a Cartesian product because of the data in your table tbl_ARMSpositions. I think this modification to your query should fix it:

```<code>SELECT
   tbl_Positions.ARMSNAME,
   tbl_Positions.Uploaddate,
   Sum(tbl_ARMSpositions.Mkt_Value),
   Sum(tbl_ARMSpositions.Contr),
   Sum(tbl_ARMSgreeks.Vol)
FROM
   (  (tbl_Datum INNER JOIN tbl_Positions ON tbl_Datum.Datum = tbl_Positions.UploadDate)
      LEFT JOIN
      (SELECT DISTINCT Value_Date, Name FROM tbl_ARMSpositions) AS tbl_ARMSpositions ON (tbl_Positions.Uploaddate = tbl_ARMSpositions.Value_Date) AND (tbl_Positions.ARMSNAME = tbl_ARMSpositions.Name)
   )
   LEFT JOIN
   tbl_ARMSgreeks ON (tbl_Positions.Uploaddate = tbl_ARMSgreeks.Value_Date) AND (tbl_Positions.ARMSNAME = tbl_ARMSgreeks.Name)
GROUP BY
   tbl_Positions.ARMSNAME,
   tbl_Positions.Uploaddate;
</code>```

Title: Double value from sum query

Body:
I'm currently using access to keep track of my stockportfolio. It contains ~20 tables. I use a query to include the most important data to export into excel. Two data tables include two names each that are identical but with different values. This results in the sum om Mkt_Value, Contr and Vol (shown in code) to recieve a double valuation.

From googling I think it revolves around having to use subselects and something other than left join. The problem is I have mostly used query wizard for this query so I am unsure how to tackle the problem. Any guidance would be greatly appreciated!

I posted an excerpt of the code containg the four tables causing the problem: tbl_datum (Date table), tbl_positions, tbl_ARMSpositions and tbl_ARMSgreeks.

Thanks in advance!

SELECT
tbl_Positions.ARMSNAME,
tbl_Positions.Uploaddate,
Sum(tbl_ARMSpositions.Mkt_Value),
Sum(tbl_ARMSpositions.Contr),
Sum(tbl_ARMSgreeks.Vol)

FROM
((tbl_Datum INNER JOIN tbl_Positions ON tbl_Datum.Datum = tbl_Positions.UploadDate)

LEFT JOIN
tbl_ARMSpositions ON (tbl_Positions.Uploaddate = tbl_ARMSpositions.Value_Date) AND (tbl_Positions.ARMSNAME = tbl_ARMSpositions.Name))

LEFT JOIN
tbl_ARMSgreeks ON (tbl_Positions.Uploaddate = tbl_ARMSgreeks.Value_Date) AND (tbl_Positions.ARMSNAME = tbl_ARMSgreeks.Name)

GROUP BY
tbl_Positions.ARMSNAME,
tbl_Positions.Uploaddate;

Body:
Without seeing your data, I'll have to guess.  Based on your description and comment, it sounds like you have a Cartesian product because of the data in your table tbl_ARMSpositions. I think this modification to your query should fix it:

SELECT
   tbl_Positions.ARMSNAME,
   tbl_Positions.Uploaddate,
   Sum(tbl_ARMSpositions.Mkt_Value),
   Sum(tbl_ARMSpositions.Contr),
   Sum(tbl_ARMSgreeks.Vol)
FROM
   (  (tbl_Datum INNER JOIN tbl_Positions ON tbl_Datum.Datum = tbl_Positions.UploadDate)
      LEFT JOIN
      (SELECT DISTINCT Value_Date, Name FROM tbl_ARMSpositions) AS tbl_ARMSpositions ON (tbl_Positions.Uploaddate = tbl_ARMSpositions.Value_Date) AND (tbl_Positions.ARMSNAME = tbl_ARMSpositions.Name)
   )
   LEFT JOIN
   tbl_ARMSgreeks ON (tbl_Positions.Uploaddate = tbl_ARMSgreeks.Value_Date) AND (tbl_Positions.ARMSNAME = tbl_ARMSgreeks.Name)
GROUP BY
   tbl_Positions.ARMSNAME,
   tbl_Positions.Uploaddate;


问:
How to use header redirect in PHP AJAX Call In Pure Javascript?
I am creating a login form and I need to redirect the user to his/her profile page! I am using AJAX Requests so header redirect is not working at all. It just stays on the homepage.

 So how can I redirect the user to another page in pure javascript PHP ajax call? Please give the answer in pure javascript. I don't like to use jQuery at all!

Javascript:

```<code>function ajaxCall(){
    var xhttp;

    if(window.XMLHttpRequest){
        xhttp = new XMLHttpRequest();
    }

    xhttp.onreadystatechange = function(){
        if(this.readyState === 4 && this.status === 200){
            document.getElementById('error').innerHTML = this.responseText;
        }
    };

    var parameters = 'email='+document.getElementById('email')+'&password='+document.getElementById('password');
    xhttp.open('POST', 'login.php', true);
    xhttp.setRequestHeader('Content-type', 'application/x-www/form/urlencoded');
    xhttp.send(parameters);
}
</code>```

Login.php(PHP)

```<code><?php
if(isset($_POST['email']) && isset($_POST['password'])){
    $ema = $_POST['email'];
    $pass = $_POST['password'];

    if(!empty($ema) && !empty($pass)){
        if($ema === 'Bill' && $pass === 'Cool'){
            header('Location: https://www.google.com');
        }
    }
}
</code>```

答:
Make an ajax call.

```<code><?php
header('Content-Type: application/json');
echo json_encode(['location'=>'/user/profile/']);
exit;
?>
</code>```

The ajax response will return something like

```<code>{'location':'/user/profile/'}
</code>```

In your ajax success javascript function

```<code> xhr.onreadystatechange = function () {
            if (xhr.status >= 200 && xhr.status <= 299)
            {
                var response = JSON.parse(xhr.responseText);
                if(response.location){
                  window.location.href = response.location;
                }
            }

    }
</code>```

Body:
I am creating a login form and I need to redirect the user to his/her profile page! I am using AJAX Requests so header redirect is not working at all. It just stays on the homepage.

 So how can I redirect the user to another page in pure javascript PHP ajax call? Please give the answer in pure javascript. I don't like to use jQuery at all!

Javascript:

function ajaxCall(){
    var xhttp;

    if(window.XMLHttpRequest){
        xhttp = new XMLHttpRequest();
    }

    xhttp.onreadystatechange = function(){
        if(this.readyState === 4 && this.status === 200){
            document.getElementById('error').innerHTML = this.responseText;
        }
    };

    var parameters = 'email='+document.getElementById('email')+'&password='+document.getElementById('password');
    xhttp.open('POST', 'login.php', true);
    xhttp.setRequestHeader('Content-type', 'application/x-www/form/urlencoded');
    xhttp.send(parameters);
}

Login.php(PHP)

<?php
if(isset($_POST['email']) && isset($_POST['password'])){
    $ema = $_POST['email'];
    $pass = $_POST['password'];

    if(!empty($ema) && !empty($pass)){
        if($ema === 'Bill' && $pass === 'Cool'){
            header('Location: https://www.google.com');
        }
    }
}

Body:
Make an ajax call.

<?php
header('Content-Type: application/json');
echo json_encode(['location'=>'/user/profile/']);
exit;
?>

The ajax response will return something like

{'location':'/user/profile/'}

In your ajax success javascript function

 xhr.onreadystatechange = function () {
            if (xhr.status >= 200 && xhr.status <= 299)
            {
                var response = JSON.parse(xhr.responseText);
                if(response.location){
                  window.location.href = response.location;
                }
            }

    }

ContentLicense: CC BY-SA 4.0


问:
Rails: Factory Girl failing to sequence
Just getting started with factory girl, and I've come across a problem with sequencing: Specifically, it doesn't increment. I've tried changing the database type, updating from factory_girl 1.3.2 to 2.0.0.beta1 (And factory_girl_rails from 1.0 to 1.1.0.beta1), tried recreating the database, but same problem - the sequence won't increment and I get a validation error after the first time I insert a unique field.

Any assistance much appreciated. Code & trace stack below:

/spec/models/user.rb

```<code>require 'spec_helper'

describe User do   describe "test user factory is correct" do
    user = Factory(:user)

    it "should have an email ending in example.com" do
      #user.email.should match "test2@example.com"
    end

    it "should have a password of foobar" do
      user.password.should == 'foobar'
    end

    it "should have a password confirmation field of foobar" do
      user.password_confirmation.should == 'foobar'
    end
    end

end
</code>```

/spec/factories/user.rb

```<code>Factory.define :user do |f|
    f.sequence(:email) { |n| puts "Email ##{n}"; "factory_#{n}@example.com" }
    f.password 'foobar'
    f.password_confirmation { |p| p.password }
end
</code>```

Trace:

```<code>/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/validations.rb:49:in `save!': Validation failed: Email has already been taken (ActiveRecord::RecordInvalid)
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/attribute_methods/dirty.rb:30:in `save!'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/transactions.rb:242:in `block in save!'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/transactions.rb:289:in `block in with_transaction_returning_status'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/database_statements.rb:139:in `transaction'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/transactions.rb:204:in `transaction'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/transactions.rb:287:in `with_transaction_returning_status'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/transactions.rb:242:in `save!'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/factory_girl-1.3.2/lib/factory_girl/proxy/create.rb:6:in `result'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/factory_girl-1.3.2/lib/factory_girl/factory.rb:327:in `run'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/factory_girl-1.3.2/lib/factory_girl/factory.rb:270:in `create'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/factory_girl-1.3.2/lib/factory_girl/factory.rb:301:in `default_strategy'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/factory_girl-1.3.2/lib/factory_girl.rb:20:in `Factory'
    from /Users/john/Websites/Rails/InDevelopment/fastermanager/spec/models/user_spec.rb:5:in `block (2 levels) in <top (required)>'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.3.1/lib/rspec/core/example_group.rb:131:in `module_eval'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.3.1/lib/rspec/core/example_group.rb:131:in `subclass'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.3.1/lib/rspec/core/example_group.rb:118:in `describe'
    from /Users/john/Websites/Rails/InDevelopment/fastermanager/spec/models/user_spec.rb:4:in `block in <top (required)>'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.3.1/lib/rspec/core/example_group.rb:131:in `module_eval'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.3.1/lib/rspec/core/example_group.rb:131:in `subclass'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.3.1/lib/rspec/core/example_group.rb:118:in `describe'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.3.1/lib/rspec/core/extensions/object.rb:6:in `describe'
    from /Users/john/Websites/Rails/InDevelopment/fastermanager/spec/models/user_spec.rb:3:in `<top (required)>'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:235:in `load'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:235:in `block in load'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:225:in `block in load_dependency'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:596:in `new_constants_in'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:225:in `load_dependency'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:235:in `load'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.3.1/lib/rspec/core/configuration.rb:388:in `block in load_spec_files'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.3.1/lib/rspec/core/configuration.rb:388:in `map'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.3.1/lib/rspec/core/configuration.rb:388:in `load_spec_files'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.3.1/lib/rspec/core/command_line.rb:18:in `run'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.3.1/lib/rspec/core/runner.rb:55:in `run_in_process'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.3.1/lib/rspec/core/runner.rb:44:in `run'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.3.1/lib/rspec/core/runner.rb:10:in `block in autorun'
</code>```

答:
I'm not sure why that happens, but here are a couple suggestions:

Get a user that is not saved in the database:

user = Factory.build(:user)

Or,

use a before each block:

before(:each) do
  @user = Factory(:user)
end

(then change the "user" variables to "@user")

Title: Rails: Factory Girl failing to sequence

Body:
Just getting started with factory girl, and I've come across a problem with sequencing: Specifically, it doesn't increment. I've tried changing the database type, updating from factory_girl 1.3.2 to 2.0.0.beta1 (And factory_girl_rails from 1.0 to 1.1.0.beta1), tried recreating the database, but same problem - the sequence won't increment and I get a validation error after the first time I insert a unique field.

Any assistance much appreciated. Code & trace stack below:

/spec/models/user.rb

require 'spec_helper'

describe User do   describe "test user factory is correct" do
    user = Factory(:user)

    it "should have an email ending in example.com" do
      #user.email.should match "test2@example.com"
    end

    it "should have a password of foobar" do
      user.password.should == 'foobar'
    end

    it "should have a password confirmation field of foobar" do
      user.password_confirmation.should == 'foobar'
    end
    end

end

/spec/factories/user.rb

Factory.define :user do |f|
    f.sequence(:email) { |n| puts "Email ##{n}"; "factory_#{n}@example.com" }
    f.password 'foobar'
    f.password_confirmation { |p| p.password }
end

Trace:

/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/validations.rb:49:in `save!': Validation failed: Email has already been taken (ActiveRecord::RecordInvalid)
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/attribute_methods/dirty.rb:30:in `save!'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/transactions.rb:242:in `block in save!'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/transactions.rb:289:in `block in with_transaction_returning_status'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/database_statements.rb:139:in `transaction'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/transactions.rb:204:in `transaction'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/transactions.rb:287:in `with_transaction_returning_status'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/transactions.rb:242:in `save!'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/factory_girl-1.3.2/lib/factory_girl/proxy/create.rb:6:in `result'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/factory_girl-1.3.2/lib/factory_girl/factory.rb:327:in `run'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/factory_girl-1.3.2/lib/factory_girl/factory.rb:270:in `create'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/factory_girl-1.3.2/lib/factory_girl/factory.rb:301:in `default_strategy'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/factory_girl-1.3.2/lib/factory_girl.rb:20:in `Factory'
    from /Users/john/Websites/Rails/InDevelopment/fastermanager/spec/models/user_spec.rb:5:in `block (2 levels) in <top (required)>'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.3.1/lib/rspec/core/example_group.rb:131:in `module_eval'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.3.1/lib/rspec/core/example_group.rb:131:in `subclass'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.3.1/lib/rspec/core/example_group.rb:118:in `describe'
    from /Users/john/Websites/Rails/InDevelopment/fastermanager/spec/models/user_spec.rb:4:in `block in <top (required)>'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.3.1/lib/rspec/core/example_group.rb:131:in `module_eval'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.3.1/lib/rspec/core/example_group.rb:131:in `subclass'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.3.1/lib/rspec/core/example_group.rb:118:in `describe'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.3.1/lib/rspec/core/extensions/object.rb:6:in `describe'
    from /Users/john/Websites/Rails/InDevelopment/fastermanager/spec/models/user_spec.rb:3:in `<top (required)>'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:235:in `load'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:235:in `block in load'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:225:in `block in load_dependency'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:596:in `new_constants_in'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:225:in `load_dependency'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:235:in `load'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.3.1/lib/rspec/core/configuration.rb:388:in `block in load_spec_files'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.3.1/lib/rspec/core/configuration.rb:388:in `map'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.3.1/lib/rspec/core/configuration.rb:388:in `load_spec_files'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.3.1/lib/rspec/core/command_line.rb:18:in `run'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.3.1/lib/rspec/core/runner.rb:55:in `run_in_process'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.3.1/lib/rspec/core/runner.rb:44:in `run'
    from /Users/john/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.3.1/lib/rspec/core/runner.rb:10:in `block in autorun'


问:
SlideToggle doesn't work after ajax refreshed the div
So now I have set up the slideToggle function, which is working well. But after I filtered the results, the slide doesn't work anymore. On this page you can see it: https://staging.therapeutischefrauenmassage.de/therapeutinnen/

After you filtered the results with a radio button click, the slides won't slide at all. What is the issue? The code would be useless because the ajax loads the file, which was included before and worked...

答:
You may need to reattach the event listeners (like on(click,...), etc) once the ajax loads that section.  Since they are new to the DOM they will not have those listeners attached to them.

You could add a step at the end of the ajax load which detaches and reattaches the pertinent listeners.

Follow-up:

Here's your current code:

```<code>$('.show').click(function() {
    $(this).closest('h3').next('.slidetoggle').slideToggle();
});
</code>```

Do this to clear any remaining linked event handlers (since we will add them back in just a moment):

```<code>$('.show').off();
</code>```

Then I'd redo the click handler in this way (I prefer to use the 'on' syntax, since it pairs well with 'off'):

```<code>$('.show').on('click', function() {
    $(this).closest('h3').next('.slidetoggle').slideToggle();
});
</code>```

You could shove both in a function like so:

```<code>function relinkEvents() {
    $('.show').off();
    $('.show').on('click', function() {
        $(this).closest('h3').next('.slidetoggle').slideToggle();
    });
}
</code>```

Body:
You may need to reattach the event listeners (like on(click,...), etc) once the ajax loads that section.  Since they are new to the DOM they will not have those listeners attached to them.

You could add a step at the end of the ajax load which detaches and reattaches the pertinent listeners.

Follow-up:

Here's your current code:

$('.show').click(function() {
    $(this).closest('h3').next('.slidetoggle').slideToggle();
});

Do this to clear any remaining linked event handlers (since we will add them back in just a moment):

$('.show').off();

Then I'd redo the click handler in this way (I prefer to use the 'on' syntax, since it pairs well with 'off'):

$('.show').on('click', function() {
    $(this).closest('h3').next('.slidetoggle').slideToggle();
});

You could shove both in a function like so:

function relinkEvents() {
    $('.show').off();
    $('.show').on('click', function() {
        $(this).closest('h3').next('.slidetoggle').slideToggle();
    });
}


问:
Availability of BridgeConnect in Magento
One of our clients is thinking of buying an Enterprise Edition, due to his requirement of using the Exact CRM Services with Magento. But today, to my utter astonishment, I’m not finding any inclusion of ”BridgeConnect” module in either the ”Enterprise” or the ”Professional” Editions.

Can anybody from the SO please highlight, whether Magento still provides this ”BridgeConnect” module with the ”Enterprise” or the ”Professional” Editions?

If this module is not being provided, then when will Magento provide this module?
Or, is Magento planning to provide any better solution module, instead of the ”BridgeConnect” module?

This is very much urgent for us, and will be very very grateful for some quick responses.
Any help is really appreciated.

答:
According to this forum thread there is an official answer:

... we’re no longer offering Bridge Connect. We’re sorry for the inconvenience ...

This module was included in previous Enterprise versions, but they have removed it in the latest ones. Maybe they are going to release something new and more flexible, but who knows...

If you want to integrate with some particular ERP/CRM you should look closer on extensions available on Magento Connect or write your own.


问:
How to get specific index values and store in a array from multiple php arrays
I've multiple arrays received from db table. now i'm trying to check "is their birth date == current date" if yes then their contact numbers saved in a array called birthdays

Here is my try

```<code>$curr_date = date('m/d');

$birthday = array(); // array initialization
$anniversary = array(); // array initialization

$con=mysqli_connect("localhost","root","","birthdays");

$sql="SELECT * FROM users";

$result=mysqli_query($con,$sql);

$row=mysqli_fetch_assoc($result);

echo "```";

if ($result=mysqli_query($con,$sql))
{
    while ($row=mysqli_fetch_assoc($result))
    {
        print_r ($row);
    }
}
```

Here is a image of current code with expected description

I'm trying lot of time but unable to achieve exact result. kindly guide me. Thanks

答:
I think you need something like this?

```<code>$date1 = date('m-d', strtotime($row['birth_date']));
$date2 = date('m-d');

if ($date1 == $date2)   {
    echo 'Happy birthday!';
}
</code>```

See PHP date function for more info.

Body:
I've multiple arrays received from db table. now i'm trying to check "is their birth date == current date" if yes then their contact numbers saved in a array called birthdays

Here is my try

$curr_date = date('m/d');

$birthday = array(); // array initialization
$anniversary = array(); // array initialization

$con=mysqli_connect("localhost","root","","birthdays");

$sql="SELECT * FROM users";

$result=mysqli_query($con,$sql);

$row=mysqli_fetch_assoc($result);

echo "
";

if ($result=mysqli_query($con,$sql))
{
    while ($row=mysqli_fetch_assoc($result))
    {
        print_r ($row);
    }
}

Here is a image of current code with expected description

I'm trying lot of time but unable to achieve exact result. kindly guide me. Thanks

Body:
I think you need something like this?

$date1 = date('m-d', strtotime($row['birth_date']));
$date2 = date('m-d');

if ($date1 == $date2)   {
    echo 'Happy birthday!';
}

See PHP date function for more info.


问:
Bootstrap two apps in same page using angular 2
I am trying to bootstrap two angular2 apps in the same page. I have tried doing that using platformBrowserDynamic.bootstrapModule(). But it's throwing me error as "Tried to find the bootstrap code, but could not. Specify either statically analyzable bootstrap code or pass in an entryModule to the plugins options."

```<code>//Main.ts

import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { BrowserModule } from '@angular/platform-browser';

import { AppModule1 } from './app1/app.module1';
import { AppModule2 } from './app2/app.module2';

import { environment } from './environments/environment';

if (environment.production) {
  enableProdMode();
}

platformBrowserDynamic().bootstrapModule(AppModule1 );
platformBrowserDynamic().bootstrapModule(AppModule2 );
</code>```

So I tried bootstrapping AppModule2 through AppModule1 as given below which worked.

```<code>//app1.module.ts

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { AppService } from './app.service';

import { App1RoutingModule }  from '../app1/app1-routing.module';
import { App1Component } from '../app1/app1.component';

import { App2Module }  from '../app2/app2.module';

@NgModule({
  imports: [
    BrowserModule,
    FormsModule,
    HttpModule,
    App1RoutingModule,
App2Module
  ],
  declarations: [App1Component],
  providers: [AppService],
  bootstrap: [App1Component ]
})
export class App1Module { }

platformBrowserDynamic().bootstrapModule(AppModule2);
</code>```

Though above solution worked and I could create build, but when deployed on Tomcat it did not work.

How to bootstrap 2 apps in the same screen?

答:
You can bootstrap two different modules on the same page. Your first attempt should work. Here is the plnkr with two modules bootstrapped on the same page.

app.ts:

```<code>@Component({
  selector: 'my-app',
  template: `
    <div>
      <h2>Hello {{name}}</h2>
    </div>
  `,
})
export class App {
  name:string;
  constructor() {
    this.name = `Angular! v${VERSION.full}`
  }
}

@NgModule({
  imports: [ BrowserModule ],
  declarations: [ App ],
  bootstrap: [ App ]
})
export class AppModule {}

@Component({
  selector: 'my-app2',
  template: `
    <div>
      <h2>Hello2 {{name}}</h2>
    </div>
  `,
})
export class App2 {
  name:string;
  constructor() {
    this.name = `Angular! v${VERSION.full}`
  }
}

@NgModule({
  imports: [ BrowserModule ],
  declarations: [ App2 ],
  bootstrap: [ App2 ]
})
export class AppModule2 {}
</code>```

main.ts:

```<code>import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {AppModule, AppModule2 } from './app';

platformBrowserDynamic().bootstrapModule(AppModule)
platformBrowserDynamic().bootstrapModule(AppModule2)
</code>```

Body:
I am trying to bootstrap two angular2 apps in the same page. I have tried doing that using platformBrowserDynamic.bootstrapModule(). But it's throwing me error as "Tried to find the bootstrap code, but could not. Specify either statically analyzable bootstrap code or pass in an entryModule to the plugins options."

//Main.ts

import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { BrowserModule } from '@angular/platform-browser';

import { AppModule1 } from './app1/app.module1';
import { AppModule2 } from './app2/app.module2';

import { environment } from './environments/environment';

if (environment.production) {
  enableProdMode();
}

platformBrowserDynamic().bootstrapModule(AppModule1 );
platformBrowserDynamic().bootstrapModule(AppModule2 );

So I tried bootstrapping AppModule2 through AppModule1 as given below which worked.

//app1.module.ts

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { AppService } from './app.service';

import { App1RoutingModule }  from '../app1/app1-routing.module';
import { App1Component } from '../app1/app1.component';

import { App2Module }  from '../app2/app2.module';

@NgModule({
  imports: [
    BrowserModule,
    FormsModule,
    HttpModule,
    App1RoutingModule,
App2Module
  ],
  declarations: [App1Component],
  providers: [AppService],
  bootstrap: [App1Component ]
})
export class App1Module { }

platformBrowserDynamic().bootstrapModule(AppModule2);

Though above solution worked and I could create build, but when deployed on Tomcat it did not work.

How to bootstrap 2 apps in the same screen?

Body:
You can bootstrap two different modules on the same page. Your first attempt should work. Here is the plnkr with two modules bootstrapped on the same page.

app.ts:

@Component({
  selector: 'my-app',
  template: `
    <div>
      <h2>Hello {{name}}</h2>
    </div>
  `,
})
export class App {
  name:string;
  constructor() {
    this.name = `Angular! v${VERSION.full}`
  }
}

@NgModule({
  imports: [ BrowserModule ],
  declarations: [ App ],
  bootstrap: [ App ]
})
export class AppModule {}

@Component({
  selector: 'my-app2',
  template: `
    <div>
      <h2>Hello2 {{name}}</h2>
    </div>
  `,
})
export class App2 {
  name:string;
  constructor() {
    this.name = `Angular! v${VERSION.full}`
  }
}

@NgModule({
  imports: [ BrowserModule ],
  declarations: [ App2 ],
  bootstrap: [ App2 ]
})
export class AppModule2 {}

main.ts:

import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {AppModule, AppModule2 } from './app';

platformBrowserDynamic().bootstrapModule(AppModule)
platformBrowserDynamic().bootstrapModule(AppModule2)


问:
How to rotate nginx logs for windows based on file file size
I am not able to configure log rotation in nginx.
I have installed nginx service on windows machine using windows service wrapper.
I have tried reopening log file using nginx -s reopen but command giving me error.</p>

答:
Nginx does not have any built in module for rolover logs on windows or any other platform, you can reopen nginx log if you are running nginx using nginx.exe but if you are running nginx using installed service you have to stop service then rotate logs and then start service again,

Use below batch script to rotate nginx error logs and access logs on windows machine

```<code>REM script to rotates nginx logs from java/windows cmd prompt

REM rolloverNginxLogs.bat [maxFileSize in bytes] [retainCount]
REM e.g rolloverNginxLogs.bat 10000 5

@echo off
setlocal EnableDelayedExpansion
pushd C:\nginx\logs

set ERRORLEVEL=0
set maxFileSize=%1
set retainCount=%2
set errorLogFile=error.log
set accessLogFile=access.log

set rotateAccessLogFile=""
set rotateErrorLogFile=""
set rotateFile=""

REM set current time, replace " " with "0" for hours less than 10
set currentTime=%time:~0,2%%time:~3,2%%time:~6,2%
if %currentTime% LSS 100000 (set currentTime=%currentTime: =0%)

REM check if access.log file rotation required
for %%A in (%accessLogFile%) do (
    echo.Size of "%%A" is %%~zA bytes
    if /I %%~zA GTR %maxFileSize% (
        set rotateAccessLogFile=true
        set rotateFile=true
    )
)

REM check if error.log file rotation required
for %%A in (%errorLogFile%) do (
    echo.Size of "%%A" is %%~zA bytes
    if /I %%~zA GTR %maxFileSize% (
        set rotateErrorLogFile=true
        set rotateFile=true
    )
)

REM if required rotate logs otherwise exit
if "%rotateFile%" EQU "true" (
    goto ROTATELOG
) else (
    goto DONE
)

:ROTATELOG
REM check whether the service is running if running then stop service
for /F "tokens=3 delims=: " %%H in ('sc query "nginx" ^| findstr "STATE"') do (
  if /I "%%H" EQU "RUNNING" (
   net stop "nginx"
  )
)

REM rotate error log
if "%rotateErrorLogFile%" EQU "true" (
    ren error.log error-%DATE%-%currentTime%.log
    for /f "skip=%retainCount% eol=: delims=" %%F in ('dir /b /o-d /a-d error*.log') do @del "%%F"
)

REM rotate access log
if "%rotateAccessLogFile%" EQU "true" (
    ren access.log access-%DATE%-%currentTime%.log
    for /f "skip=%retainCount% eol=: delims=" %%F in ('dir /b /o-d /a-d access*.log') do @del "%%F"
)

REM check if the service is not running, start service
for /F "tokens=3 delims=: " %%H in ('sc query "nginx" ^| findstr "STATE"') do (
  if /I "%%H" NEQ "RUNNING" (

   echo starting nginx service
   net start "nginx"
  )
)

:DONE
popd
exit %ERRORLEVEL%
</code>```

Body:
Nginx does not have any built in module for rolover logs on windows or any other platform, you can reopen nginx log if you are running nginx using nginx.exe but if you are running nginx using installed service you have to stop service then rotate logs and then start service again,

Use below batch script to rotate nginx error logs and access logs on windows machine

REM script to rotates nginx logs from java/windows cmd prompt

REM rolloverNginxLogs.bat [maxFileSize in bytes] [retainCount]
REM e.g rolloverNginxLogs.bat 10000 5

@echo off
setlocal EnableDelayedExpansion
pushd C:\nginx\logs

set ERRORLEVEL=0
set maxFileSize=%1
set retainCount=%2
set errorLogFile=error.log
set accessLogFile=access.log

set rotateAccessLogFile=""
set rotateErrorLogFile=""
set rotateFile=""

REM set current time, replace " " with "0" for hours less than 10
set currentTime=%time:~0,2%%time:~3,2%%time:~6,2%
if %currentTime% LSS 100000 (set currentTime=%currentTime: =0%)

REM check if access.log file rotation required
for %%A in (%accessLogFile%) do (
    echo.Size of "%%A" is %%~zA bytes
    if /I %%~zA GTR %maxFileSize% (
        set rotateAccessLogFile=true
        set rotateFile=true
    )
)

REM check if error.log file rotation required
for %%A in (%errorLogFile%) do (
    echo.Size of "%%A" is %%~zA bytes
    if /I %%~zA GTR %maxFileSize% (
        set rotateErrorLogFile=true
        set rotateFile=true
    )
)

REM if required rotate logs otherwise exit
if "%rotateFile%" EQU "true" (
    goto ROTATELOG
) else (
    goto DONE
)

:ROTATELOG
REM check whether the service is running if running then stop service
for /F "tokens=3 delims=: " %%H in ('sc query "nginx" ^| findstr "STATE"') do (
  if /I "%%H" EQU "RUNNING" (
   net stop "nginx"
  )
)

REM rotate error log
if "%rotateErrorLogFile%" EQU "true" (
    ren error.log error-%DATE%-%currentTime%.log
    for /f "skip=%retainCount% eol=: delims=" %%F in ('dir /b /o-d /a-d error*.log') do @del "%%F"
)

REM rotate access log
if "%rotateAccessLogFile%" EQU "true" (
    ren access.log access-%DATE%-%currentTime%.log
    for /f "skip=%retainCount% eol=: delims=" %%F in ('dir /b /o-d /a-d access*.log') do @del "%%F"
)

REM check if the service is not running, start service
for /F "tokens=3 delims=: " %%H in ('sc query "nginx" ^| findstr "STATE"') do (
  if /I "%%H" NEQ "RUNNING" (

   echo starting nginx service
   net start "nginx"
  )
)

:DONE
popd
exit %ERRORLEVEL%


问:
Application resilience impact using Logstash/Graylog log appender
I have some question about the gelf module (http://logging.paluch.biz/) and in particular when the graylog server is not available for some reason.

Is log4j will cache the logs somewhere and will send them when the connection to the graylog is recovered?

Is the application using this module will stop to work during the issue with graylog server?

Thanks.

答:
Gelf-Appenders are online appenders without a cache. They connect directly do a remote service and submit log events as your application produces these.

If the remote service is down, log events get lost. There are a few options with different impacts:

TCP: TCP comes with transport reliability and requires a connection. If the remote service becomes slow/unresponsive, then your application gets affected, as soon as I/O buffer are saturated. logstash-gelf uses NIO in a non-blocking way if all data was sent. If the TCP connection drops, then you will run into connection timeouts, if the remote side is not reachable or connection refused states if the remote port is closed. In any case, you get reliability, but it will affect your application performance.

UDP: UDP has no connection notion, it's used for fire-and-forget communication. If the remote side becomes unhealthy, your application usually is not affected, but you encounter log event loss.

Redis: You can use Redis as an intermediate buffer if your Graylog instance is known to fail/been taken down for maintenance. Once Graylog is available again, it should catch up, and you prevent log event loss to some degree. If your Redis service becomes unhealthy, see Point 1.

HTTP: HTTP is another option that gives you a degree of flexibility. You can put your Graylog servers behind a load-balancer to improve availability and reduce the risk of failure. Log event loss is still possible.

If you want to ensure log continuity and reduce the probability of log event loss, then write logs to disk. It's still no 100% guarantee against loss (disk failure, disk full) but improves application performance. The log file (ideally some JSON-based format) can then be parsed and submitted to Graylog by maintaining a read offset to recover from a remote outage.


问:
Linq extract a count() value from a data object
I have divAssignments that has potential multiple rows by rNI, an official id, according to a compound key of Indictment and booking numbers.

```<code>rNI    Booking  Indictment
12345  954445   10 12345
12345  954445   10 12346
12345  954445   10 12347
</code>```

So ID has a count of 3 for a single booking number for this rni.

I get lost attempting to generate a count and a group by booking Number:

```<code>var moreThen = from dA in divAssignments
    select new { dA.rNI, IndictmentCount = dA.indictmentNumber.Count() };
</code>```

Most of the examples are dealing with static int[] and don't seem to work in my case.

How do I get a group and then a count?  If I could put in a having that would be fantastic.

from a t-sql POV I'd use this:

```<code>Select rni, bookingNumber, count(*) IndictmentCount
from divAssignments
group by rni, bookingNumber
having count(*) > 0
</code>```

TIA

答:
```<code>var query =
    from dA in divAssignments
    group dA by new { dA.rNI, dA.bookingNumber };

foreach(var grp in query)
{
    Console.WriteLine("rNI={0}, bookingNumber={1} => Count={2}", grp.Key.rNI, grp.Key.bookingNumber, grp.Count());
}
</code>```

Body:
I have divAssignments that has potential multiple rows by rNI, an official id, according to a compound key of Indictment and booking numbers.

rNI    Booking  Indictment
12345  954445   10 12345
12345  954445   10 12346
12345  954445   10 12347

So ID has a count of 3 for a single booking number for this rni.

I get lost attempting to generate a count and a group by booking Number:

var moreThen = from dA in divAssignments
    select new { dA.rNI, IndictmentCount = dA.indictmentNumber.Count() };

Most of the examples are dealing with static int[] and don't seem to work in my case.

How do I get a group and then a count?  If I could put in a having that would be fantastic.

from a t-sql POV I'd use this:

Select rni, bookingNumber, count(*) IndictmentCount
from divAssignments
group by rni, bookingNumber
having count(*) > 0

TIA


问:
docx4j - replacing a bookmark with text and style
I have a similar problem as XPages - docx4j - replacing a bookmark with text but I would like to keep the style.
My bookmark is not on a text (because it's a docx created by Google Docs), I'd like to keep the text after my bookmark to include it in the bookmark and keep its style.
For example :

```<code><w:bookmarkStart w:colFirst="0" w:colLast="0" w:name="3znysh7" w:id="2"/><w:bookmarkEnd w:id="2"/>
<w:r w:rsidDel="00000000" w:rsidR="00000000" w:rsidRPr="00000000">
    <w:rPr>
        <w:rFonts w:ascii="Calibri" w:cs="Calibri" w:eastAsia="Calibri" w:hAnsi="Calibri"/>
        <w:i w:val="1"/>
        <w:color w:val="1e4d78"/>
        <w:rtl w:val="0"/>
    </w:rPr>
    <w:t xml:space="preserve">MY_BOOKMARK</w:t>
</w:r>
</code>```

I found a solution to erase the text after the bookmark, I found a solution to add the text inside the bookmark, but I'm unable to keep the style.

I'm not native English speaker, so do not hesitate to ask me if I'm not clear.

答:
In this case, I create a new R and insert it between bookmarkStart and bookmarkEnd.
I had another problem with this kind of example :

```<code><w:bookmarkStart w:colFirst="0" w:colLast="0" w:name="30j0zll" w:id="1" />
      <w:bookmarkEnd w:id="1" />
      <w:p w:rsidR="00000000" w:rsidDel="00000000" w:rsidP="00000000" w:rsidRDefault="00000000" w:rsidRPr="00000000">
         <w:pPr>
            <w:pBdr />
            <w:tabs>
               <w:tab w:val="left" w:pos="1560" />
            </w:tabs>
            <w:spacing w:after="0" w:lineRule="auto" />
            <w:contextualSpacing w:val="0" />
            <w:rPr>
               <w:color w:val="2f5496" />
               <w:sz w:val="28" />
               <w:szCs w:val="28" />
            </w:rPr>
         </w:pPr>
         <w:r w:rsidDel="00000000" w:rsidR="00000000" w:rsidRPr="00000000">
            <w:rPr>
               <w:color w:val="2f5496" />
               <w:sz w:val="20" />
               <w:szCs w:val="20" />
               <w:rtl w:val="0" />
            </w:rPr>
            <w:t xml:space="preserve">MY_BOOKMARK1.</w:t>
         </w:r>
         <w:bookmarkStart w:colFirst="0" w:colLast="0" w:name="1fob9te" w:id="2" />
         <w:bookmarkEnd w:id="2" />
         <w:r w:rsidDel="00000000" w:rsidR="00000000" w:rsidRPr="00000000">
            <w:rPr>
               <w:color w:val="2f5496" />
               <w:sz w:val="20" />
               <w:szCs w:val="20" />
               <w:rtl w:val="0" />
            </w:rPr>
            <w:t xml:space="preserve">MY_BOOKMARK2</w:t>
         </w:r>
         <w:r w:rsidDel="00000000" w:rsidR="00000000" w:rsidRPr="00000000">
            <w:rPr>
               <w:rtl w:val="0" />
            </w:rPr>
         </w:r>
      </w:p>
</code>```

My solution :

Keep the bookmark with the name 0j0zll

Create a new bookmark (id is number of bookmark in the xml file ; id++) and insert it

Hope that could help others

Body:
I have a similar problem as XPages - docx4j - replacing a bookmark with text but I would like to keep the style.
My bookmark is not on a text (because it's a docx created by Google Docs), I'd like to keep the text after my bookmark to include it in the bookmark and keep its style.
For example :

<w:bookmarkStart w:colFirst="0" w:colLast="0" w:name="3znysh7" w:id="2"/><w:bookmarkEnd w:id="2"/>
<w:r w:rsidDel="00000000" w:rsidR="00000000" w:rsidRPr="00000000">
    <w:rPr>
        <w:rFonts w:ascii="Calibri" w:cs="Calibri" w:eastAsia="Calibri" w:hAnsi="Calibri"/>
        <w:i w:val="1"/>
        <w:color w:val="1e4d78"/>
        <w:rtl w:val="0"/>
    </w:rPr>
    <w:t xml:space="preserve">MY_BOOKMARK</w:t>
</w:r>

I found a solution to erase the text after the bookmark, I found a solution to add the text inside the bookmark, but I'm unable to keep the style.

I'm not native English speaker, so do not hesitate to ask me if I'm not clear.

Body:
In this case, I create a new R and insert it between bookmarkStart and bookmarkEnd.
I had another problem with this kind of example :

<w:bookmarkStart w:colFirst="0" w:colLast="0" w:name="30j0zll" w:id="1" />
      <w:bookmarkEnd w:id="1" />
      <w:p w:rsidR="00000000" w:rsidDel="00000000" w:rsidP="00000000" w:rsidRDefault="00000000" w:rsidRPr="00000000">
         <w:pPr>
            <w:pBdr />
            <w:tabs>
               <w:tab w:val="left" w:pos="1560" />
            </w:tabs>
            <w:spacing w:after="0" w:lineRule="auto" />
            <w:contextualSpacing w:val="0" />
            <w:rPr>
               <w:color w:val="2f5496" />
               <w:sz w:val="28" />
               <w:szCs w:val="28" />
            </w:rPr>
         </w:pPr>
         <w:r w:rsidDel="00000000" w:rsidR="00000000" w:rsidRPr="00000000">
            <w:rPr>
               <w:color w:val="2f5496" />
               <w:sz w:val="20" />
               <w:szCs w:val="20" />
               <w:rtl w:val="0" />
            </w:rPr>
            <w:t xml:space="preserve">MY_BOOKMARK1.</w:t>
         </w:r>
         <w:bookmarkStart w:colFirst="0" w:colLast="0" w:name="1fob9te" w:id="2" />
         <w:bookmarkEnd w:id="2" />
         <w:r w:rsidDel="00000000" w:rsidR="00000000" w:rsidRPr="00000000">
            <w:rPr>
               <w:color w:val="2f5496" />
               <w:sz w:val="20" />
               <w:szCs w:val="20" />
               <w:rtl w:val="0" />
            </w:rPr>
            <w:t xml:space="preserve">MY_BOOKMARK2</w:t>
         </w:r>
         <w:r w:rsidDel="00000000" w:rsidR="00000000" w:rsidRPr="00000000">
            <w:rPr>
               <w:rtl w:val="0" />
            </w:rPr>
         </w:r>
      </w:p>

My solution :

Keep the bookmark with the name 0j0zll

Create a new bookmark (id is number of bookmark in the xml file ; id++) and insert it

Hope that could help others


问:
Trouble styling divs on top of an image (css)
I have a rails app that i've been working on, and one of the functionality aspects I do with it is that I ask the user to import an image (i'm using the paperclip gem to do that). Once they do that and finish creating everything else, I'm taking that image that is imported and using it as a background image for their page.  Problem is.....i'm having serious problems actually doing that.

My html (haml) looks like this

```<code>#cafe_show
  .image_holding_div
    = image_tag @cafe.image.url(:medium)
    .cafe_info
      This is a quick test
</code>```

and my CSS is like so

```<code>#cafe_show {
  .image_holding_div {
    position: relative;
  }
  img {
    height: 100vh;
    width: 100%;
    position: relative;
    z-index: -1;
  }
}

.cafe_info {
  position: relative;
  float: center;
  height: 100px;
  width: auto;
  background-color: #808080;
  opacity:.9;
  text-align:center;
  color:white;
  }
</code>```

Problem I'm having is, the .cafe_info div sits below the image, and not on top of the image.  Would anyone have an idea what I can do for this?

答:
The two, img and cafe_info is position: relative.

You need to use position: fixed, or position: absolute (depending on what style you would like) to have the cafe_info div on top.

Read more here: look under position absolute

Good luck!

Note:

You could also do something like this:

if you made your css compatible with erb

```<code>#cafe_show.scss.erb
.image_holding_div {
  position: relative;
  background-image: url(<%= @cafe.image.url(:medium) %>);
}
</code>```

And then you don't need the image_tag.

Body:
I have a rails app that i've been working on, and one of the functionality aspects I do with it is that I ask the user to import an image (i'm using the paperclip gem to do that). Once they do that and finish creating everything else, I'm taking that image that is imported and using it as a background image for their page.  Problem is.....i'm having serious problems actually doing that.

My html (haml) looks like this

#cafe_show
  .image_holding_div
    = image_tag @cafe.image.url(:medium)
    .cafe_info
      This is a quick test

and my CSS is like so

#cafe_show {
  .image_holding_div {
    position: relative;
  }
  img {
    height: 100vh;
    width: 100%;
    position: relative;
    z-index: -1;
  }
}

.cafe_info {
  position: relative;
  float: center;
  height: 100px;
  width: auto;
  background-color: #808080;
  opacity:.9;
  text-align:center;
  color:white;
  }

Problem I'm having is, the .cafe_info div sits below the image, and not on top of the image.  Would anyone have an idea what I can do for this?

Body:
The two, img and cafe_info is position: relative.

You need to use position: fixed, or position: absolute (depending on what style you would like) to have the cafe_info div on top.

Read more here: look under position absolute

Good luck!

Note:

You could also do something like this:

if you made your css compatible with erb

#cafe_show.scss.erb
.image_holding_div {
  position: relative;
  background-image: url(<%= @cafe.image.url(:medium) %>);
}

And then you don't need the image_tag.


问:
Bash Scripting IF Conditions
I need to check if the picture has a resolution of 900x900 pixels and the filename is not allowed to contain _thumb or _v

What I am trying to do with this line:

If the picture ist 900x900 pixels and does not contain _v or _thumb => add the word _thumb to the end of the filename before the file extension.

The Line it's all about:

```<code>if file $picture | grep -q 900x900 && ! file $picture | grep -q _thumb && ! file $picture | grep -q _v;
</code>```

Script:

```<code>#Change to current .sh directory
cd -P -- "$(dirname -- "$0")"
for picture in */*/Templates/*.jpg
do
    filename=${picture##*/}
    filename1=$(echo "$filename" |sed 's/.\{4\}$//')
    parent_dir="$(dirname -- "$(/usr/local/bin/realpath "$picture")")"

    #Colors
    red=`tput setaf 1`
    green=`tput setaf 2`
    magenta=`tput setaf 5`
    reset=`tput sgr0`

    if file $picture | grep -q 900x900 && ! file $picture | grep -q _thumb && ! file $picture | grep -q _v;
        then
            mv -v "$picture" "$parent_dir/"$filename1"_thumb.jpg"
            echo "${green} [PASS] $filename1 Thumbnail 900x900 found and renamed ${reset}"
        else
            echo "${magenta} [WARNUNG] $filename1 contains _thumb already or is a _v picture or isn't 900x900 pixels ${reset}"
        fi
</code>```

答:
I see a few issues. #3, #4, and #5 are the most important to take a look at.

Target shell in your first line

You need to finish the for loop with done

You need to escape the inner double quotes on $filename1. The surrounding quotes currently unquote this.

Double quote the variables in that line

Clarify if you're looking for image size or just that the file has 900x900 in it? Cause grep -q 900x900 won't find the image size. You'll need to combine it with imagemagik identifyas others have mentioned.

With the fixes:

```<code>#!/bin/bash
#Change to current .sh directory
cd -P -- "$(dirname -- "$0")"
for picture in */*/Templates/*.jpg
do
    filename=${picture##*/}
    filename1=$(echo "$filename" |sed 's/.\{4\}$//')
    parent_dir="$(dirname -- "$(/usr/local/bin/realpath "$picture")")"

    #Colors
    red=`tput setaf 1`
    green=`tput setaf 2`
    magenta=`tput setaf 5`
    reset=`tput sgr0`

    if file "$picture" | grep -q 900x900 && ! file "$picture" | grep -q _thumb && ! file "$picture" | grep -q _v;
        then
            mv -v "$picture" "$parent_dir/\"$filename1\"_thumb.jpg"
            echo "${green} [PASS] $filename1 Thumbnail 900x900 found and renamed ${reset}"
        else
            echo "${magenta} [WARNING] $filename1 contains _thumb already or is a _v picture or isn't 900x900 pixels ${reset}"
        fi
done
</code>```

Title: Bash Scripting IF Conditions

Body:
I need to check if the picture has a resolution of 900x900 pixels and the filename is not allowed to contain _thumb or _v

What I am trying to do with this line:

If the picture ist 900x900 pixels and does not contain _v or _thumb => add the word _thumb to the end of the filename before the file extension.

The Line it's all about:

if file $picture | grep -q 900x900 && ! file $picture | grep -q _thumb && ! file $picture | grep -q _v;

Script:

#Change to current .sh directory
cd -P -- "$(dirname -- "$0")"
for picture in */*/Templates/*.jpg
do
    filename=${picture##*/}
    filename1=$(echo "$filename" |sed 's/.\{4\}$//')
    parent_dir="$(dirname -- "$(/usr/local/bin/realpath "$picture")")"

    #Colors
    red=`tput setaf 1`
    green=`tput setaf 2`
    magenta=`tput setaf 5`
    reset=`tput sgr0`

    if file $picture | grep -q 900x900 && ! file $picture | grep -q _thumb && ! file $picture | grep -q _v;
        then
            mv -v "$picture" "$parent_dir/"$filename1"_thumb.jpg"
            echo "${green} [PASS] $filename1 Thumbnail 900x900 found and renamed ${reset}"
        else
            echo "${magenta} [WARNUNG] $filename1 contains _thumb already or is a _v picture or isn't 900x900 pixels ${reset}"
        fi

Body:
I see a few issues. #3, #4, and #5 are the most important to take a look at.

Target shell in your first line

You need to finish the for loop with done

You need to escape the inner double quotes on $filename1. The surrounding quotes currently unquote this.

Double quote the variables in that line

Clarify if you're looking for image size or just that the file has 900x900 in it? Cause grep -q 900x900 won't find the image size. You'll need to combine it with imagemagik identifyas others have mentioned.

With the fixes:

#!/bin/bash
#Change to current .sh directory
cd -P -- "$(dirname -- "$0")"
for picture in */*/Templates/*.jpg
do
    filename=${picture##*/}
    filename1=$(echo "$filename" |sed 's/.\{4\}$//')
    parent_dir="$(dirname -- "$(/usr/local/bin/realpath "$picture")")"

    #Colors
    red=`tput setaf 1`
    green=`tput setaf 2`
    magenta=`tput setaf 5`
    reset=`tput sgr0`

    if file "$picture" | grep -q 900x900 && ! file "$picture" | grep -q _thumb && ! file "$picture" | grep -q _v;
        then
            mv -v "$picture" "$parent_dir/\"$filename1\"_thumb.jpg"
            echo "${green} [PASS] $filename1 Thumbnail 900x900 found and renamed ${reset}"
        else
            echo "${magenta} [WARNING] $filename1 contains _thumb already or is a _v picture or isn't 900x900 pixels ${reset}"
        fi
done


问:
Program is not inserting into the database
My program doesn't insert into the database, tried various means, I'm new to php and tried to test myself with this but I'm finding it difficult to get. i think the problem is at the connection to the database but I'm not getting it </p>

```<code><!DOCTYPE html>
<html>
    <head>
        <title>LIST</title>
    </head>
    <body>
        <h1> TODO LIST </h1>
        <?php
            if(isset($_POST["submit"])){
                $servername = "localhost";
                $username = "root";
                $password = "";

                try {
                    //create a database conneection
                    $conn = mysqli_connect("localhost", "root", "");
                    if(!$conn){
                        die("Database connection failed: ". mysql_error());
                    }
                    $sql = "INSERT INTO tasks (task, date, time) VALUES (:task, :date, :time)";
                    $query = $conn->prepare($sql);
                    $query->execute(array(':task'=>$task,
                        ':date'=>$date,':time'=>$time));
                }
                catch(PDOException $e)
                {
                    echo "Connection failed: " . $e->getMessage();
                }
            }
        ?>

        <form action = "todolist.php" method = "post">
          Task: <input type="text" name="task" id="task"><br/>
          Date: <input type="date" name="date" id="date"><br/>
          Time: <input type="time" name="time" id="time"><br/>
        <input type = "submit" value = "submit" name="submit">
        </form>
    </body>
</html>
</code>```

答:
I am using this way in one of my project. Create a connect.php file and create connection like this:

```<code><?php
$conn = mysqli_connect("localhost", "root", "", "Yourdatabasename");
?>
</code>```

Now in index.php file check if the submit button is pressed:

```<code><?php

if(isset($_POST["submit"]))

{

// include connection file
include("connect.php");

// get values
$subject = mysqli_real_escape_string($con, $_POST["subject"]);
$comment = mysqli_real_escape_string($con, $_POST["comment"]);

// Insert in database

$query = "INSERT INTO comments(comment_subject, comment_text)VALUES ('$subject', '$comment')";

mysqli_query($con, $query);

}

?>
</code>```

Body:
My program doesn't insert into the database, tried various means, I'm new to php and tried to test myself with this but I'm finding it difficult to get. i think the problem is at the connection to the database but I'm not getting it

<!DOCTYPE html>

        <title>LIST</title>

 TODO LIST

        <?php
            if(isset($_POST["submit"])){
                $servername = "localhost";
                $username = "root";
                $password = "";

                try {
                    //create a database conneection
                    $conn = mysqli_connect("localhost", "root", "");
                    if(!$conn){
                        die("Database connection failed: ". mysql_error());
                    }
                    $sql = "INSERT INTO tasks (task, date, time) VALUES (:task, :date, :time)";
                    $query = $conn->prepare($sql);
                    $query->execute(array(':task'=>$task,
                        ':date'=>$date,':time'=>$time));
                }
                catch(PDOException $e)
                {
                    echo "Connection failed: " . $e->getMessage();
                }
            }
        ?>

        <form action = "todolist.php" method = "post">
          Task: <input type="text" name="task" id="task">

          Date: <input type="date" name="date" id="date">

          Time: <input type="time" name="time" id="time">

        <input type = "submit" value = "submit" name="submit">
        </form>

Body:
I am using this way in one of my project. Create a connect.php file and create connection like this:

<?php
$conn = mysqli_connect("localhost", "root", "", "Yourdatabasename");
?>

Now in index.php file check if the submit button is pressed:

<?php

if(isset($_POST["submit"]))

{

// include connection file
include("connect.php");

// get values
$subject = mysqli_real_escape_string($con, $_POST["subject"]);
$comment = mysqli_real_escape_string($con, $_POST["comment"]);

// Insert in database

$query = "INSERT INTO comments(comment_subject, comment_text)VALUES ('$subject', '$comment')";

mysqli_query($con, $query);

}

?>


问:
How a pattern can be applied for a spring boot application running in 2 modes initialize and server?
I am seeking a pattern 2 days for develoing my spring boot web on 2 modes of initialize and server.

I'll get a parameter from program arguments or yaml file.

If this parameter is initialize program running on initialize mode. Initialize mode will do some settings, creating hibernate table, adding default users to db after that stop. Yes, I'll run and finish this works after that it'll stop.

If this parameter is server, program run normally spring boot web application.

Do you know a pattern like I said or Could offer any solution to me?

Thanks.

答:
Spring Profiles

Spring Profiles provide a way to segregate parts of your application configuration and make it only available in certain environments. Any @Component or @Configuration can be marked with @Profile to limit when it is loaded:

n the normal Spring way, you can use a spring.profiles.active Environment property to specify which profiles are active. You can specify the property in any of the usual ways, for example you could include it in your application.properties:

```<code>spring.profiles.active=dev,hsqldb
</code>```

or specify on the command line using the switch

```<code>--spring.profiles.active=dev,hsqldb.
</code>```

You can programmatically set active profiles by calling SpringApplication.setAdditionalProfiles(…) before your application runs. It is also possible to activate profiles using Spring’s ConfigurableEnvironment interface.

Profile-specific variants of both application.properties (or application.yml) and files referenced via @ConfigurationProperties are considered as files are loaded. See Section 24.4, “Profile-specific properties” for details.

In addition to application.properties files, profile-specific properties can also be defined using the naming convention application-{profile}.properties. The Environment has a set of default profiles (by default [default]) which are used if no active profiles are set (i.e. if no profiles are explicitly activated then properties from application-default.properties are loaded).

Profile-specific properties are loaded from the same locations as standard application.properties, with profile-specific files always overriding the non-specific ones irrespective of whether the profile-specific files are inside or outside your packaged jar.

If several profiles are specified, a last wins strategy applies. For example, profiles specified by the spring.profiles.active property are added after those configured via the SpringApplication API and therefore take precedence.

The following is example of yml file. which contains 2 profiles.

```<code>#Production Configuration values
spring:
  profiles: prod

  datasource:
    url: jdbc:mysql://localhost:3306/production

    username: userName
    password: password
  main:
    banner-mode: "off"
  jpa:
    show-sql: false
---

#Development  Configuration values
spring:
  profiles: development

  datasource:
    url: jdbc:mysql://localhost:3306/development?useSSL=false
    username: userName
    password: password

... Other settings can be here like creating tables, configure liquibase or hibernate auto ddl to true.
</code>```

To run your project with development mode,you can run the below

```<code>java -jar -Dspring.profiles.active=development springbootproject.jar
</code>```

Body:
Spring Profiles

Spring Profiles provide a way to segregate parts of your application configuration and make it only available in certain environments. Any @Component or @Configuration can be marked with @Profile to limit when it is loaded:

n the normal Spring way, you can use a spring.profiles.active Environment property to specify which profiles are active. You can specify the property in any of the usual ways, for example you could include it in your application.properties:

spring.profiles.active=dev,hsqldb

or specify on the command line using the switch

--spring.profiles.active=dev,hsqldb.

You can programmatically set active profiles by calling SpringApplication.setAdditionalProfiles(…) before your application runs. It is also possible to activate profiles using Spring’s ConfigurableEnvironment interface.

Profile-specific variants of both application.properties (or application.yml) and files referenced via @ConfigurationProperties are considered as files are loaded. See Section 24.4, “Profile-specific properties” for details.

In addition to application.properties files, profile-specific properties can also be defined using the naming convention application-{profile}.properties. The Environment has a set of default profiles (by default [default]) which are used if no active profiles are set (i.e. if no profiles are explicitly activated then properties from application-default.properties are loaded).

Profile-specific properties are loaded from the same locations as standard application.properties, with profile-specific files always overriding the non-specific ones irrespective of whether the profile-specific files are inside or outside your packaged jar.

If several profiles are specified, a last wins strategy applies. For example, profiles specified by the spring.profiles.active property are added after those configured via the SpringApplication API and therefore take precedence.

The following is example of yml file. which contains 2 profiles.

#Production Configuration values
spring:
  profiles: prod

  datasource:
    url: jdbc:mysql://localhost:3306/production

    username: userName
    password: password
  main:
    banner-mode: "off"
  jpa:
    show-sql: false
---

#Development  Configuration values
spring:
  profiles: development

  datasource:
    url: jdbc:mysql://localhost:3306/development?useSSL=false
    username: userName
    password: password

... Other settings can be here like creating tables, configure liquibase or hibernate auto ddl to true.

To run your project with development mode,you can run the below

java -jar -Dspring.profiles.active=development springbootproject.jar


问:
Using JDBCBatchItemWriter for calling an Oracle Procedure gets EmptyResultDataAccessException
I am using Java based configuration for my Spring Batch. I am calling a stored procedure "writer.setSql("call proc (:_name)");"
The data is getting inserted through the procedure. However, I am getting exception " <<<<<<<<<

Thanks

Note: I am skipping "Exception.class" in my step.

答:
I use Java Configuration. Set the writer to avoid 'assert updates' does the job. </p>

```<code>writer.setAssertUpdates(false);
</code>```

Body:
I use Java Configuration. Set the writer to avoid 'assert updates' does the job.

writer.setAssertUpdates(false);