问:
Why does Safari & Firefox cut off bottom of input text?

What I want

Chrome

On Chrome, the input text looks normal.

What is happening

Firefox

Safari

As you can see, the input text is being slightly cut off at the bottom on Firefox and majorly cut off on Safari. How can I fix that?

If anyone could help w/ this it would be greatly appreciated!

Code

HTML

```<code>        <div class="row page-header">
            <div class="col-xs-10">
                <div class="form-group">
                    <input type="text" name="Worksheet-Name" class="form-control input-lg" placeholder="Worksheet Name..." aria-label="Write worksheet name here"> </div>
            </div>
        </div>
</code>```

CSS

```<code>/*Add borders when hover or click on input boxes*/
input[type="text"] {
    outline: none;
    box-shadow:none !important;
    border: 1px solid white; /*make the borders invisble by turning same color as background*/
}

input[type="text"]:hover, input[type="text"]:focus{
    border: 1px solid #cccccc;
    border-radius: 8px;
}

/*Style input text boxes*/
input[type='text'][name='Worksheet-Name']{
    font-size: 36px;
    margin-top: 20px;
    margin-left: 15px;
}

input[type='text'][name='Worksheet-Problem']{
    font-size: 20px;
}

/*Change placeholder*/
input[type='text'][name='Worksheet-Name']::-webkit-input-placeholder { /* Chrome/Opera/Safari */
    font-weight: 500;
    font-size: 36px;
}
input[type='text'][name='Worksheet-Name']::-moz-placeholder { /* Firefox 19+ */
    font-weight: 500;
    font-size: 36px;
}
input[type='text'][name='Worksheet-Name']:-ms-input-placeholder { /* IE 10+ */
    font-weight: 500;
    font-size: 36px;
}
input[type='text'][name='Worksheet-Name']:-moz-placeholder { /* Firefox 18- */
    font-weight: 500;
    font-size: 36px;
}

/*Change placeholder*/
input[type='text'][name='Worksheet-Problem']::-webkit-input-placeholder { /* Chrome/Opera/Safari */
    font-weight: 400;
    font-size: 20px;
}
input[type='text'][name='Worksheet-Problem']::-moz-placeholder { /* Firefox 19+ */
    font-weight: 400;
    font-size: 20px;
}
input[type='text'][name='Worksheet-Problem']:-ms-input-placeholder { /* IE 10+ */
    font-weight: 400;
    font-size: 20px;
}
input[type='text'][name='Worksheet-Problem']:-moz-placeholder { /* Firefox 18- */
    font-weight: 400;
    font-size: 20px;
}
</code>```

JSFiddle

答: The cause is placing the line-height on the placeholder, if you remove that then it will no longer be cut</p>

Body:
What I want

Chrome

On Chrome, the input text looks normal.

What is happening

Firefox

Safari

As you can see, the input text is being slightly cut off at the bottom on Firefox and majorly cut off on Safari. How can I fix that?

If anyone could help w/ this it would be greatly appreciated!

Code

HTML

                    <input type="text" name="Worksheet-Name" class="form-control input-lg" placeholder="Worksheet Name..." aria-label="Write worksheet name here">

CSS

/*Add borders when hover or click on input boxes*/
input[type="text"] {
    outline: none;
    box-shadow:none !important;
    border: 1px solid white; /*make the borders invisble by turning same color as background*/
}

input[type="text"]:hover, input[type="text"]:focus{
    border: 1px solid #cccccc;
    border-radius: 8px;
}

/*Style input text boxes*/
input[type='text'][name='Worksheet-Name']{
    font-size: 36px;
    margin-top: 20px;
    margin-left: 15px;
}

input[type='text'][name='Worksheet-Problem']{
    font-size: 20px;
}

/*Change placeholder*/
input[type='text'][name='Worksheet-Name']::-webkit-input-placeholder { /* Chrome/Opera/Safari */
    font-weight: 500;
    font-size: 36px;
}
input[type='text'][name='Worksheet-Name']::-moz-placeholder { /* Firefox 19+ */
    font-weight: 500;
    font-size: 36px;
}
input[type='text'][name='Worksheet-Name']:-ms-input-placeholder { /* IE 10+ */
    font-weight: 500;
    font-size: 36px;
}
input[type='text'][name='Worksheet-Name']:-moz-placeholder { /* Firefox 18- */
    font-weight: 500;
    font-size: 36px;
}

/*Change placeholder*/
input[type='text'][name='Worksheet-Problem']::-webkit-input-placeholder { /* Chrome/Opera/Safari */
    font-weight: 400;
    font-size: 20px;
}
input[type='text'][name='Worksheet-Problem']::-moz-placeholder { /* Firefox 19+ */
    font-weight: 400;
    font-size: 20px;
}
input[type='text'][name='Worksheet-Problem']:-ms-input-placeholder { /* IE 10+ */
    font-weight: 400;
    font-size: 20px;
}
input[type='text'][name='Worksheet-Problem']:-moz-placeholder { /* Firefox 18- */
    font-weight: 400;
    font-size: 20px;
}

JSFiddle


来源: stackexchange

问:
time complexity of arr.delete() in ruby
```<code>arr = [5, 6, 5, 4, 3, 1, 2, 5, 4, 3, 3, 3]
</code>```

Delete all occurrences of a given element

```<code>arr.delete(5)
#  => [6, 3, 1, 2, 4, 3, 3]
</code>```

What is the time complexity of the above Ruby code and how it works internally?

答:
Array#delete runs in O(n). You can click on the "click to toggle source" button next to a function in the Ruby documentation to see its implementation:

```<code>               VALUE
rb_ary_delete(VALUE ary, VALUE item)
{
    VALUE v = item;
    long i1, i2;

    for (i1 = i2 = 0; i1 < RARRAY_LEN(ary); i1++) {
        VALUE e = RARRAY_AREF(ary, i1);

        if (rb_equal(e, item)) {
            v = e;
            continue;
        }
        if (i1 != i2) {
            rb_ary_store(ary, i2, e);
        }
        i2++;
    }
    if (RARRAY_LEN(ary) == i2) {
        if (rb_block_given_p()) {
            return rb_yield(item);
        }
        return Qnil;
    }

    ary_resize_smaller(ary, i2);

    return v;
}
</code>```

As you can see, the function iterates over the array only once.

ContentLicense: CC BY-SA 3.0

Title: time complexity of arr.delete() in ruby

Body:
arr = [5, 6, 5, 4, 3, 1, 2, 5, 4, 3, 3, 3]

Delete all occurrences of a given element

arr.delete(5)
#  => [6, 3, 1, 2, 4, 3, 3]

What is the time complexity of the above Ruby code and how it works internally?

Body:
Array#delete runs in O(n). You can click on the "click to toggle source" button next to a function in the Ruby documentation to see its implementation:

               VALUE
rb_ary_delete(VALUE ary, VALUE item)
{
    VALUE v = item;
    long i1, i2;

    for (i1 = i2 = 0; i1 < RARRAY_LEN(ary); i1++) {
        VALUE e = RARRAY_AREF(ary, i1);

        if (rb_equal(e, item)) {
            v = e;
            continue;
        }
        if (i1 != i2) {
            rb_ary_store(ary, i2, e);
        }
        i2++;
    }
    if (RARRAY_LEN(ary) == i2) {
        if (rb_block_given_p()) {
            return rb_yield(item);
        }
        return Qnil;
    }

    ary_resize_smaller(ary, i2);

    return v;
}

As you can see, the function iterates over the array only once.


问:
Algorithm for Rendering Long Text in a Text Editor
I've been thinking about writing a text editor control that can edit text that can have any arbitrary length (say, hundreds of megabytes), similar in some ways to the Scintilla editor. The goal is to lazy-read the file, so the user doesn't have to read five hundred megabytes of data just to view a small portion of it. I'm having two problems with this:

It seems to me to be impossible to implement any sensible scrolling feature for such an editor, unless I pre-read the entire file once, in order to figure out line breaks. Is this really true? Or is there a way to approximate things, that I'm not thinking of?

Because of various issues with Unicode (e.g. it allows many bytes to represent just one character, not just because of variable-length encoding but also because of accents and such), it seems nearly impossible to determine exactly how much text will fit on the screen -- I'd have to use TextOut() or something to draw one character, measure how big it was, and then draw the next character. And even then, that still doesn't say how I'd map the user's clicks back to the correct text position.

Is there anything I could read on the web regarding algorithms for handling these issues? I've searched, but I haven't found anything.

Thank you!

答:
You can set a "coarse" position based on data size instead of lines.  The "fine" position of your text window can be based on a local scan around an arbitrary entry point.

This means you will need to write functions that can scan locally (backwards and forwards) to find line starts, count Unicode characters, and so forth.  This should not be too difficult; UTF8 is designed to be easy to parse in this way.

You may want to give special consideration of what to do about extremely long lines.  Since there is no upper limit on how long a line can be, this makes finding the beginning (or end) of a line an unbounded task; I believe everything else you need for a screen editor display should be local.

Finally, if you want a general text editor, you need to figure out what you're going to do when you want to save a file in which you've inserted/deleted things.  The straightforward thing is to rewrite the file;  however, this is obviously going to take longer with a huge file.  You can expect the user to run into problems if there is not enough room for a modified copy, so at the very least, you will want to check to make sure there is enough room on the filesystem.

ContentLicense: CC BY-SA 2.5


问:
how to figure image size to fit below header and above footer
I want to center an image in the available space below the page header and above the page footer.
It needs to be responsive, so I want the picture to be as large as possible but not overlap the header and footer.

The ID of the image is #nMapImg.

I have these values:

```<code>var dh=$(document).height();
var dw=$(document).width();
var hh=$("#header").height();
var fh=$("#footer").height();
var w=$("#nMapImg").width();
var availHeight=h-hh-fh;
</code>```

I think this is just math to figure the max size I can have and then I'll center it. I just can't wrap my head around it.

答:
Since you said it is allowed to place a div between the header and footer the easiest way to have the largest image possible is:

```<code><div style="background-image: url('myimage.jpg'); background-size: contain"></div>
</code>```

You can also add background-position: center center; when needed

Body:
I want to center an image in the available space below the page header and above the page footer.
It needs to be responsive, so I want the picture to be as large as possible but not overlap the header and footer.

The ID of the image is #nMapImg.

I have these values:

var dh=$(document).height();
var dw=$(document).width();
var hh=$("#header").height();
var fh=$("#footer").height();
var w=$("#nMapImg").width();
var availHeight=h-hh-fh;

I think this is just math to figure the max size I can have and then I'll center it. I just can't wrap my head around it.

Body:
Since you said it is allowed to place a div between the header and footer the easiest way to have the largest image possible is:

<div style="background-image: url('myimage.jpg'); background-size: contain"></div>

You can also add background-position: center center; when needed


问:
Generating SAS to access Azure storage
I am trying to write a Bash script that would take backup of an Azure App service and save the backup into a container in Azure storage.

To do so, I need a SAS to access the storage and to generate one I would use the following command:

```<code>az storage blob generate-sas -c containername --account-name storage-account-name -n blob-name
</code>```

The problem here is, I also need to provide the blob name for the above command to work, but I would like my backup to be stored directly in the container.

But if I am using Powershell and follow the document here it doesn't require a blob storage name to create a SAS.

So I was wondering if there's a way to generate SAS using Azure-CLI that is valid on the container level and not on the blob level.

答:
Please try az storage container generate-sas.

```<code>az storage container generate-sas --name <container-name> --expiry <sas-expiry> --permissions <permissions> --account-name <account-name> --account-key <account-key>
</code>```

To see all options with this command, please use:

```<code>az storage container generate-sas --help
</code>```

Title: Generating SAS to access Azure storage

Body:
I am trying to write a Bash script that would take backup of an Azure App service and save the backup into a container in Azure storage.

To do so, I need a SAS to access the storage and to generate one I would use the following command:

az storage blob generate-sas -c containername --account-name storage-account-name -n blob-name

The problem here is, I also need to provide the blob name for the above command to work, but I would like my backup to be stored directly in the container.

But if I am using Powershell and follow the document here it doesn't require a blob storage name to create a SAS.

So I was wondering if there's a way to generate SAS using Azure-CLI that is valid on the container level and not on the blob level.

Body:
Please try az storage container generate-sas.

az storage container generate-sas --name <container-name> --expiry <sas-expiry> --permissions <permissions> --account-name <account-name> --account-key <account-key>

To see all options with this command, please use:

az storage container generate-sas --help


问:
iOS Multitasking: Reductions performed by system upon entering background
I've watched the WWDC 2010 talks about adopting multitasking and I have started enabling our app, however I have a question regarding releasing non-visible views.

According to the talk (Session 105 - Adopting Multitasking on iPhone OS, Part 1 - 00:34:50) it is stated that the system releases "non-visible UIViewController views" when entering the background. However during my testing (in the simulator), I'm not seeing this happen.

The -viewDidUnload methods aren't being called, and after entering the foreground and viewing a previously hidden VC, the -loadView method is not being called either. So the hidden VC views in my UITabBarController aren't being released at all, contrary to what they said in the talk. Any ideas?

There's no mention of this in the "Moving to the Background" documentation, only in the talk.

Any clarification would be greatly appreciated.

答: Have you tried simulating a memory warning while your app is in the background?  I believe that the views are only released when other apps start requesting memory.  If memory consumption stays the same, your views are not released so that you can switch back quicker.</p>


问:
hide an element using angularjs
I using visjs, i want to hide the first image of the first div, how i can do that, i used ng-show but it doesnt work??</p>

```<code>storyboard.drawTimeLine = function (start, end, color, marg,km) {
        var elm = angular.element(document.querySelector('#vv'));
            elm.html("");
            item = {};
            item.id = start + '@' + end;
            item.start = start;
            item.end = end;
            item.title = elm.append($compile(
                '<div style="padding-left:0px;padding-bottom: 9px "><img src="../../../../assets/img/fuel.png"> -</div>'+
                '<div style="padding-left:0px;padding-bottom: 9px "><img src="../../../../assets/img/oil.png">  -</div>')($scope)).html();
                ;
            item.style ="top:"+ marg +"px;height:14px;background-color:" + color + ";border-color:" + color;
        };
</code>```

答:
Your problem is that you are injecting HTML.
In angular; HTML shall not be included into Javascripts but in templates.

However; if you want that your generated HTML to be interpreted as an Angular code (and add ng-hide); you shall "compile" it that is a complicated process (not for beginner)

https://docs.angularjs.org/guide/compiler

For an example; please have a look at that post : https://stackoverflow.com/a/11780658/3687474

Title: hide an element using angularjs

Body:
I using visjs, i want to hide the first image of the first div, how i can do that, i used ng-show but it doesnt work??

storyboard.drawTimeLine = function (start, end, color, marg,km) {
        var elm = angular.element(document.querySelector('#vv'));
            elm.html("");
            item = {};
            item.id = start + '@' + end;
            item.start = start;
            item.end = end;
            item.title = elm.append($compile(
                '
 -
'+
                '
  -
')($scope)).html();
                ;
            item.style ="top:"+ marg +"px;height:14px;background-color:" + color + ";border-color:" + color;
        };


问:
Neo4J OGM Java connection establishment issues
I am using Neo4J 3.2.0 community edition and I was able to connect and establish connection properly using traditional java driver and running Cypher queries.

However, I wanted to create rich data model, so I imported the following dependencies:

```<code><dependency>
    <groupId>org.neo4j</groupId>
    <artifactId>neo4j-ogm-core</artifactId>
    <version>2.1.3</version>
</dependency>
<dependency>
    <groupId>org.neo4j</groupId>
    <artifactId>neo4j-ogm-bolt-driver</artifactId>
    <version>2.1.3</version>
</dependency>
</code>```

Post that, I wrote the following code to establish the connection:

```<code>Configuration configuration = new Configuration();
configuration.driverConfiguration().setDriverClassName("org.neo4j.ogm.drivers.bolt.driver.BoltDriver")
        .setURI("bolt://localhost:7687");

SessionFactory sessionFactory = new SessionFactory(configuration, "org.neo4j.example.domain");
Session session = sessionFactory.openSession();
</code>```

But irrespective of weather my Neo4j server is turned on or not, it establish connection, and the logs dont show any errors, just the following three lines for the logging system:

```<code>SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
</code>```

Any help would be appreciated.

答:
Adding the following dependency fixes it:</p>

```<code>    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-simple</artifactId>
        <version>1.7.25</version>
    </dependency>
</code>```

Body:
I am using Neo4J 3.2.0 community edition and I was able to connect and establish connection properly using traditional java driver and running Cypher queries.

However, I wanted to create rich data model, so I imported the following dependencies:

<dependency>
    <groupId>org.neo4j</groupId>
    <artifactId>neo4j-ogm-core</artifactId>
    <version>2.1.3</version>
</dependency>
<dependency>
    <groupId>org.neo4j</groupId>
    <artifactId>neo4j-ogm-bolt-driver</artifactId>
    <version>2.1.3</version>
</dependency>

Post that, I wrote the following code to establish the connection:

Configuration configuration = new Configuration();
configuration.driverConfiguration().setDriverClassName("org.neo4j.ogm.drivers.bolt.driver.BoltDriver")
        .setURI("bolt://localhost:7687");

SessionFactory sessionFactory = new SessionFactory(configuration, "org.neo4j.example.domain");
Session session = sessionFactory.openSession();

But irrespective of weather my Neo4j server is turned on or not, it establish connection, and the logs dont show any errors, just the following three lines for the logging system:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

Any help would be appreciated.

Body:
Adding the following dependency fixes it:

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-simple</artifactId>
        <version>1.7.25</version>
    </dependency>


问:
Same search results page on back button
I have a search results page where i have forward link to see next 10 results.
say i have searched some thing and got 90 results then we are showing first 10 results(1 to 10) initially, on click on the link we show 10 to 20 and so on.this is happening with out the page load (js). we have a back to search button when you open each results. currently it is assigned as window.history.back which takes to page no 1 though i have navigated from page 4 or 5.
My requirement is to take the user to the same page(resutls) from where he came from, i.e 4 page if he clicks back to search from 42th result.

```<code><a id="product-detail-back" onclick="window.history.back();">
</a>
</code>```

答:
without seeing the code I am assuming the back button refreshes the search.
You might want to look into  working with parameters in url.
for example when you search on google and start moving forward in the results google adds a parameter:

https://www.google.com/search?q=test

moving to the next page brings in:

https://www.google.com/search?q=test#q=test&start=10

That parameter allows to keep track of pages.
If your code then handles getting start as a parameter you could jump to the specific page of your results. once your code handles parameters look into pushState()to research how to push the urls the user goes through to the history

Title: Same search results page on back button


问:
"Value cannot be null. Parameter name: userName" error when installing MSSQL 2014 Express in Docker
When I try installing MSSQL 2014 Express in Dockerfile, it fails with error "Value cannot be null. Parameter name: userName".

```<code>The following error occurred:
Value cannot be null.
Parameter name: userName

Error result: -2147467261
Result facility code: 0
Result error code: 16387

Please review the summary.txt log for further details
Microsoft (R) SQL Server 2014 12.00.5000.00
Copyright (c) Microsoft Corporation.  All rights reserved.

The command 'powershell -Command $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; cd extracted; ./setup.exe /q /ACTION=Install /INSTANCENAME=SQLEXPRESS /FEATURES=SQLEngine /UPDATEENABLED=0 /SQLSVCACCOUNT="NT AUTHORITY\System" /SQLSYSADMINACCOUNTS="BUILTIN\ADMINISTRATORS" /TCPENABLED=1 /NPENABLED=0 /IACCEPTSQLSERVERLICENSETERMS' returned a non-zero code: 1
</code>```

This is how my Dockerfile looks like (irrelevant parts omitted):

```<code>FROM microsoft/windowsservercore
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
COPY SQLEXPR_x64_ENU.exe ./
RUN .\SQLEXPR_x64_ENU.exe /x:extracted /u
RUN cd extracted; ./setup.exe /q /ACTION=Install /INSTANCENAME=SQLEXPRESS /FEATURES=SQLEngine /UPDATEENABLED=0 /SQLSVCACCOUNT="NT AUTHORITY\System" /SQLSYSADMINACCOUNTS="BUILTIN\ADMINISTRATORS" /TCPENABLED=1 /NPENABLED=0 /IACCEPTSQLSERVERLICENSETERMS
</code>```

The strange thing is, when I replace the last RUN command with ENTRYPOINT powershell, start the container and then run the exact same command, it works and the error isn't thrown.

The only thing I suspect to be a problem is that docker runs commands as "no user". But...

This is a result of whoami command in running container:
user manager\containeradministrator

I have tried putting RUN whoami to Dockerfile to confirm my hypothesis but the output is the same.

I have no idea what else to do, so thanks for any suggestions :).

答:
Microsoft used to maintain SQL Server 2014 images. You can find them in Git history here: https://github.com/Microsoft/sql-server-samples/tree/cc2402f91e37ce9ad7e108f3f51bbfe99f201e0b/samples/manage/windows-containers/mssql-server-2014-express-windows</p>

```<code>ENV sql_express_download_url "https://download.microsoft.com/download/1/5/6/156992E6-F7C7-4E55-833D-249BD2348138/ENU/x64/SQLEXPR_x64_ENU.exe"
ENV sa_password _
ENV attach_dbs "[]"

# make install files accessible
COPY . /
WORKDIR /

# download and install Microsoft SQL 2014 Express Edition in one step
RUN powershell -Command (New-Object System.Net.WebClient).DownloadFile('%sql_express_download_url%', 'sqlexpress.exe') && /sqlexpress.exe /qs /x:setup && /setup/setup.exe /q /ACTION=Install /INSTANCENAME=SQLEXPRESS /FEATURES=SQLEngine /UPDATEENABLED=0 /SQLSVCACCOUNT="NT AUTHORITY\System" /SQLSYSADMINACCOUNTS="BUILTIN\ADMINISTRATORS" /TCPENABLED=1 /NPENABLED=0 /IACCEPTSQLSERVERLICENSETERMS && del /F /Q sqlexpress.exe && rd /q /s setup

RUN powershell -Command \
        set-strictmode -version latest ; \
        stop-service MSSQL`$SQLEXPRESS ; \
        set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql12.SQLEXPRESS\mssqlserver\supersocketnetlib\tcp\ipall' -name tcpdynamicports -value '' ; \
        set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql12.SQLEXPRESS\mssqlserver\supersocketnetlib\tcp\ipall' -name tcpport -value 1433 ; \
        set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql12.SQLEXPRESS\mssqlserver\' -name LoginMode -value 2 ;

CMD powershell ./start -sa_password %sa_password% -attach_dbs \"%attach_dbs%\" -Verbose
</code>```

Body:
When I try installing MSSQL 2014 Express in Dockerfile, it fails with error "Value cannot be null. Parameter name: userName".

The following error occurred:
Value cannot be null.
Parameter name: userName

Error result: -2147467261
Result facility code: 0
Result error code: 16387

Please review the summary.txt log for further details
Microsoft (R) SQL Server 2014 12.00.5000.00
Copyright (c) Microsoft Corporation.  All rights reserved.

The command 'powershell -Command $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; cd extracted; ./setup.exe /q /ACTION=Install /INSTANCENAME=SQLEXPRESS /FEATURES=SQLEngine /UPDATEENABLED=0 /SQLSVCACCOUNT="NT AUTHORITY\System" /SQLSYSADMINACCOUNTS="BUILTIN\ADMINISTRATORS" /TCPENABLED=1 /NPENABLED=0 /IACCEPTSQLSERVERLICENSETERMS' returned a non-zero code: 1

This is how my Dockerfile looks like (irrelevant parts omitted):

FROM microsoft/windowsservercore
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
COPY SQLEXPR_x64_ENU.exe ./
RUN .\SQLEXPR_x64_ENU.exe /x:extracted /u
RUN cd extracted; ./setup.exe /q /ACTION=Install /INSTANCENAME=SQLEXPRESS /FEATURES=SQLEngine /UPDATEENABLED=0 /SQLSVCACCOUNT="NT AUTHORITY\System" /SQLSYSADMINACCOUNTS="BUILTIN\ADMINISTRATORS" /TCPENABLED=1 /NPENABLED=0 /IACCEPTSQLSERVERLICENSETERMS

The strange thing is, when I replace the last RUN command with ENTRYPOINT powershell, start the container and then run the exact same command, it works and the error isn't thrown.

The only thing I suspect to be a problem is that docker runs commands as "no user". But...

This is a result of whoami command in running container:
user manager\containeradministrator

I have tried putting RUN whoami to Dockerfile to confirm my hypothesis but the output is the same.

I have no idea what else to do, so thanks for any suggestions :).

Body:
Microsoft used to maintain SQL Server 2014 images. You can find them in Git history here: https://github.com/Microsoft/sql-server-samples/tree/cc2402f91e37ce9ad7e108f3f51bbfe99f201e0b/samples/manage/windows-containers/mssql-server-2014-express-windows

ENV sql_express_download_url "https://download.microsoft.com/download/1/5/6/156992E6-F7C7-4E55-833D-249BD2348138/ENU/x64/SQLEXPR_x64_ENU.exe"
ENV sa_password _
ENV attach_dbs "[]"

# make install files accessible
COPY . /
WORKDIR /

# download and install Microsoft SQL 2014 Express Edition in one step
RUN powershell -Command (New-Object System.Net.WebClient).DownloadFile('%sql_express_download_url%', 'sqlexpress.exe') && /sqlexpress.exe /qs /x:setup && /setup/setup.exe /q /ACTION=Install /INSTANCENAME=SQLEXPRESS /FEATURES=SQLEngine /UPDATEENABLED=0 /SQLSVCACCOUNT="NT AUTHORITY\System" /SQLSYSADMINACCOUNTS="BUILTIN\ADMINISTRATORS" /TCPENABLED=1 /NPENABLED=0 /IACCEPTSQLSERVERLICENSETERMS && del /F /Q sqlexpress.exe && rd /q /s setup

RUN powershell -Command \
        set-strictmode -version latest ; \
        stop-service MSSQL`$SQLEXPRESS ; \
        set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql12.SQLEXPRESS\mssqlserver\supersocketnetlib\tcp\ipall' -name tcpdynamicports -value '' ; \
        set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql12.SQLEXPRESS\mssqlserver\supersocketnetlib\tcp\ipall' -name tcpport -value 1433 ; \
        set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql12.SQLEXPRESS\mssqlserver\' -name LoginMode -value 2 ;

CMD powershell ./start -sa_password %sa_password% -attach_dbs \"%attach_dbs%\" -Verbose


问:
Why is an extra pixel added to firefox elements when I use `line-height: 1` in my reset?
I use this reset.

```<code>* {
    font-family: Arial, Helvetica, sans-serif;
    outline: 0;
    padding: 0;
    margin: 0;
    border: 0;
    text-decoration: none;
    vertical-align: baseline;
    white-space: normal;
    line-height: 1;
}
hr {display: none}
blockquote:before, blockquote:after, q:before, q:after {content: ''}
blockquote, q {quotes: "" ""}
ul {list-style-type: none}
ol {list-style-type: decimal}
a {text-decoration: none}

.clear {clear: both}
</code>```

The problem is that as long as I use line-height: 1 I see an extra pixel that does not go away no matter what I do in my block links even I tried setting height, line-height, font-size for it. nothing works. Please tell me what's going on with firefox line-height.

This is my css.

```<code>.tag {
    display: block;
    font-size: 11px;
    background: #fff;
    border: 1px solid #aaa;
    color: #555;
    text-transform: lowercase;
        padding: 3px 6px;
}
</code>```

Pretty simple yea? Seems not. Firefox will create a pixel on top of text I can clearly see it its not balanced even though I set top and bottom padding the same. Someone tell me why this happens, if I remove the line-height: 1 from my reset a whole lot of other things get screwed up.

答:
Try using line-height: normal;

This tells it to keep the same height as the text (which would seem to be the same as line-height:1 but perhaps firefox treats it differently).

Body:
I use this reset.

* {
    font-family: Arial, Helvetica, sans-serif;
    outline: 0;
    padding: 0;
    margin: 0;
    border: 0;
    text-decoration: none;
    vertical-align: baseline;
    white-space: normal;
    line-height: 1;
}
hr {display: none}
blockquote:before, blockquote:after, q:before, q:after {content: ''}
blockquote, q {quotes: "" ""}
ul {list-style-type: none}
ol {list-style-type: decimal}
a {text-decoration: none}

.clear {clear: both}

The problem is that as long as I use line-height: 1 I see an extra pixel that does not go away no matter what I do in my block links even I tried setting height, line-height, font-size for it. nothing works. Please tell me what's going on with firefox line-height.

This is my css.

.tag {
    display: block;
    font-size: 11px;
    background: #fff;
    border: 1px solid #aaa;
    color: #555;
    text-transform: lowercase;
        padding: 3px 6px;
}

Pretty simple yea? Seems not. Firefox will create a pixel on top of text I can clearly see it its not balanced even though I set top and bottom padding the same. Someone tell me why this happens, if I remove the line-height: 1 from my reset a whole lot of other things get screwed up.


问:
js - call the same value in body onload to an onclick function
i am trying to get the same value string that i get from the prompt box, to a function that run in onclick event.
is it possible in that kind of way?
Thanks in advance..</p>

```<code>    <!DOCOTYPE html>
    <html>
    <head>
    </head>
    <body onLoad = "h1();">

    <form>
    <input type="button" value="function h3()" onClick="h3()">
    </form>

    <script type="text/javascript">

        function h1(){
        var x = prompt("");
        console.log(x);
        return h2(x);
        }

        function h2(str){
        console.log("get value from h1 function" + "   " + str);
        }

        function h3(){
        console.log("return the value from h1 to h2");
        return h2(str);

        }
    </script>
    </body>
    </html>
</code>```

答:
You need to store the variable:

```<code>var answer;//store it in global scope
function ask(){
  answer=prompt("a question");
}

function h3(){
 alert(answer || "no answer yet...");
}

window.onload=ask;
</code>```

Variables inside of functions are garbage collected when the function returns. So you need to move the variable out of function scope into global scope. Then its persistent.

Body:
i am trying to get the same value string that i get from the prompt box, to a function that run in onclick event.
is it possible in that kind of way?
Thanks in advance..

    <!DOCOTYPE html>

    <form>
    <input type="button" value="function h3()" onClick="h3()">
    </form>

Body:
You need to store the variable:

var answer;//store it in global scope
function ask(){
  answer=prompt("a question");
}

function h3(){
 alert(answer || "no answer yet...");
}

window.onload=ask;

Variables inside of functions are garbage collected when the function returns. So you need to move the variable out of function scope into global scope. Then its persistent.


问:
Searching through code for a tag that is missing a variable
I am sure that what I am trying to do is very simple but I am new to regex.

I am searching through millions of lines of code. What I need to find are <cffunction> tags that are missing the output= attribute. For instance this should match:

```<code><cffunction name="qrySelectQuestions" access="public" returntype="query">
</code>```

However, this should not:

```<code><cffunction name="qrySelectQuestions" access="public" output="no" returntype="query">
</code>```

Note, the output attribute could be anywhere within the tag definition.

答:
Using this answer: https://stackoverflow.com/a/406408/4456875</p>

```<code><cffunction ((?!output).)*>
</code>```

Body:
I am sure that what I am trying to do is very simple but I am new to regex.

I am searching through millions of lines of code. What I need to find are <cffunction> tags that are missing the output= attribute. For instance this should match:

<cffunction name="qrySelectQuestions" access="public" returntype="query">

However, this should not:

<cffunction name="qrySelectQuestions" access="public" output="no" returntype="query">

Note, the output attribute could be anywhere within the tag definition.

Body:
Using this answer: https://stackoverflow.com/a/406408/4456875

<cffunction ((?!output).)*>


问:
Reading CSV file from url in Java
I'm trying to read a CSV file from a given URL and print in. I can't find where I was wrong but it doesn't print me anything. Can someone please help me to find what I need to fix so this program will work? Thanks. </p>

```<code>import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;

public class Main {

    public static void main(String[] args) throws IOException {

        URL url = new URL("http://gist.githubusercontent.com/yonbergman/7a0b05d6420dada16b92885780567e60/raw/114aa2ffb1c680174f9757431e672b5df53237eb/data.csv");
        URLConnection connection = url.openConnection();

        InputStreamReader input = new InputStreamReader(connection.getInputStream());
        BufferedReader buffer = null;
        String line = "";
        String csvSplitBy = ",";

        try {

            buffer = new BufferedReader(input);
            while ((line = buffer.readLine()) != null) {
                String[] room = line.split(csvSplitBy);
                System.out.println(line);
                System.out.println("room [capacity =" + room[0] + " , price=" + room[1]);
            }

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (buffer != null) {
                try {
                    buffer.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }

    }

}
</code>```

答:
The problem with your url.

Github uses specific policies in the request header to prevent getting content of your data.

See here how to get content from github

Title: Reading CSV file from url in Java

Body:
I'm trying to read a CSV file from a given URL and print in. I can't find where I was wrong but it doesn't print me anything. Can someone please help me to find what I need to fix so this program will work? Thanks.

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;

public class Main {

    public static void main(String[] args) throws IOException {

        URL url = new URL("http://gist.githubusercontent.com/yonbergman/7a0b05d6420dada16b92885780567e60/raw/114aa2ffb1c680174f9757431e672b5df53237eb/data.csv");
        URLConnection connection = url.openConnection();

        InputStreamReader input = new InputStreamReader(connection.getInputStream());
        BufferedReader buffer = null;
        String line = "";
        String csvSplitBy = ",";

        try {

            buffer = new BufferedReader(input);
            while ((line = buffer.readLine()) != null) {
                String[] room = line.split(csvSplitBy);
                System.out.println(line);
                System.out.println("room [capacity =" + room[0] + " , price=" + room[1]);
            }

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (buffer != null) {
                try {
                    buffer.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }

    }

}


问:
Android encoding PNG to base64 string producing invalid results
The app decodes base64 to PNG but when I encode the file back to base64 in order to send to a server the resulting base64 is different and does not produce an image.

Here is the start of the original base64 string:
/9j/4AAQSkZJRgABAQAASABIAAD/4QBMRXhpZgAATU0AKgAAAAgAAgESAAMAAAABAAYAAIdp

and here is the start of the base64 after it is encoded from and PNG file:
iVBORw0KGgoAAAANSUhEUgAAD8AAAAvQCAIAAABPl1n3AAAAA3NCSVQICAjb4U/gAAAgAElEQVR4nO

This is the code I'm using to encode the file to base64:

```<code>BitmapFactory.Options options = new BitmapFactory.Options();
        options.inDither = true;
        options.inScaled = false;
        options.inPreferredConfig = Bitmap.Config.ARGB_8888;
        options.inDither = false;

        File file = new File(root +"/saved_images/"+note.imageLocation );
        if(file.exists()){
            // TODO perform some logging or show user feedback
            try {
            Bitmap myBitmap = BitmapFactory.decodeFile(root +"/saved_images/"+note.imageLocation, options);
            ByteArrayOutputStream stream = new ByteArrayOutputStream();

            myBitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
            byte[] byteArray = stream.toByteArray();

            JSONObject object =new JSONObject();
                object.put("image_type", "image/png");
                object.put("image_data", Base64.encodeToString(byteArray, Base64.DEFAULT));

                if (note.serverID == -1) {
                    toReturn.put(String.valueOf(i), object);
                }else{
                    toReturn.put(String.valueOf(note.serverID), object);
                }
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            i--;
        }else{
            Log.i("File Not Found", "NoteModel - "+file);
        }
</code>```

答: Try my solution which explains how to encode bitmap to base64 and decode base64 back to bitmap successfully.</p>

Body:
The app decodes base64 to PNG but when I encode the file back to base64 in order to send to a server the resulting base64 is different and does not produce an image.

Here is the start of the original base64 string:
/9j/4AAQSkZJRgABAQAASABIAAD/4QBMRXhpZgAATU0AKgAAAAgAAgESAAMAAAABAAYAAIdp

and here is the start of the base64 after it is encoded from and PNG file:
iVBORw0KGgoAAAANSUhEUgAAD8AAAAvQCAIAAABPl1n3AAAAA3NCSVQICAjb4U/gAAAgAElEQVR4nO

This is the code I'm using to encode the file to base64:

BitmapFactory.Options options = new BitmapFactory.Options();
        options.inDither = true;
        options.inScaled = false;
        options.inPreferredConfig = Bitmap.Config.ARGB_8888;
        options.inDither = false;

        File file = new File(root +"/saved_images/"+note.imageLocation );
        if(file.exists()){
            // TODO perform some logging or show user feedback
            try {
            Bitmap myBitmap = BitmapFactory.decodeFile(root +"/saved_images/"+note.imageLocation, options);
            ByteArrayOutputStream stream = new ByteArrayOutputStream();

            myBitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
            byte[] byteArray = stream.toByteArray();

            JSONObject object =new JSONObject();
                object.put("image_type", "image/png");
                object.put("image_data", Base64.encodeToString(byteArray, Base64.DEFAULT));

                if (note.serverID == -1) {
                    toReturn.put(String.valueOf(i), object);
                }else{
                    toReturn.put(String.valueOf(note.serverID), object);
                }
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            i--;
        }else{
            Log.i("File Not Found", "NoteModel - "+file);
        }


问:
Maven commands are not working,but maven works in eclipse
When I type any Maven command like mvn -version, mvn clean install etc. they are not working. But the same maven installation is working properly in eclipse. In the command prompt I get the below option for all maven commands:

答:
It seems that in your Eclipse, you use different maven installation (maybe embedded one).
Firstly the problem is not with maven itself, but probably with wrong usage of java in maven or java is not set properly. If your maven would be properly installed and configured you should see something like this:

```<code>Apache Maven 3.2.5 (12a6b3acb947671f09b81f49094c53f426d8cea1; 2014-12-14T18:29:23+01:00)
Maven home: c:\apache-maven-3.2.5
Java version: 1.7.0_111, vendor: Oracle Corporation
Java home: C:\appl\JDK7\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
</code>```

please provide some more information about java -version and your environment paths. Also try to look at your mvn.bat.

Body:
It seems that in your Eclipse, you use different maven installation (maybe embedded one).
Firstly the problem is not with maven itself, but probably with wrong usage of java in maven or java is not set properly. If your maven would be properly installed and configured you should see something like this:

Apache Maven 3.2.5 (12a6b3acb947671f09b81f49094c53f426d8cea1; 2014-12-14T18:29:23+01:00)
Maven home: c:\apache-maven-3.2.5
Java version: 1.7.0_111, vendor: Oracle Corporation
Java home: C:\appl\JDK7\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"

please provide some more information about java -version and your environment paths. Also try to look at your mvn.bat.


问:
How can I check if a user's computer supports Emoji?
This question could be generalized to any character, I suppose; but my specific use-case are emoji.

I'm writing a command-line program, and I want to detect if the computer on which it is running has a font installed that can display emoji; and whether the current terminal application will display them in that font.

At the moment, I have a hack in place that simply filters them out on non-OS X; but I don't want to short-change Linux users who have an emoji-enabled setup. I'd prefer to do this the ‘right way.’

Thanks!

答:
Your script would have to:

know which system fonts are available, and where the font files are (for example C:\Windows\Fonts)

inspect these files for their content. I suppose inspecting them could be done in a technical way, unravelling file formats. But you could also simulate the visual use, by calculating the bounding box or simulate font usage for the Emoji characters.

If you're into PHP, you could calculate the bounding box of the TTF fonts that are known for the Emoji, and see if the value is what is to be expected of a font that supports it.

You could also simulate the font use by drawing in a black in-memory image with a white colored font using GD, and calculate the (average) amount of white pixels to see if it fits an expected threshold.

You also asked for a check if the current terminal application will display them. For that you need to be able to check the config, which is non trivial since you'd need to be able to differentiate on all terminal applications.
A practical solution would be to display some Emoji with the current font and just ask the user if it is visable. After all, you need to rely on the user anyway if the terminal application needs to support Emoji?


问:
Allocate record with variable at negative offset
When allocating memory for a pointer to a record I also need space for an integer pointer located just before the allocated record. This pointer cannot be part of the record itself and it cannot be placed after the record. My current approach is the following:

```<code>#include <stdlib.h>

static int n;
struct { int f; } *p;

p = malloc(sizeof (int *) + sizeof *p);
if (p != NULL) {
    p = (void *) ((int **) p + 1);
    *((int **) p - 1) = &n;
}
</code>```

Are the casts well defined? If not, what should I do instead?

Edit:

What I'm trying to achieve is to implement extensible records (OOP) and the integer pointer represent a type ID. An extended record should be compatible with its base type. However, I only need type ID:s for pointer to records. Here is a complete example:

```<code>#include <assert.h>
#include <stdlib.h>

struct T0 {
    int f;
};
int T0ID;

struct T1 {
    struct T0 base;
    int g;
};
int T1ID;

int main(void)
{
    struct T0 *x;
    struct T1 *y;

    y = malloc(sizeof (int *) + sizeof *y);
    if (y != NULL) {
        *((int **) y) = &T1ID;
        y = (void *) ((int **) y + 1);
        ((struct T0 *) y)->f = 1;
        y->g = 2;
    }
    x = (struct T0 *) y;
    assert(x->f == 1);
    return 0;
}
</code>```

答:
I'm not sure your approach is good. Especially I'm worried about changing the value of p. You'll need that value later when you need to free the memory.

I would wrap the int* and the struct together in another struct. Something like:

```<code>static int n;
struct someData { int f; };

struct wrapper {int* pn; struct someData data;};

struct someData* pd; // Pointer to the data struct

struct wrapper* pw = malloc(sizeof *pw);

if (pw != NULL) {
    pw->pn = &n;
    pd = &pw->data;
}
</code>```

Body:
When allocating memory for a pointer to a record I also need space for an integer pointer located just before the allocated record. This pointer cannot be part of the record itself and it cannot be placed after the record. My current approach is the following:

#include <stdlib.h>

static int n;
struct { int f; } *p;

p = malloc(sizeof (int *) + sizeof *p);
if (p != NULL) {
    p = (void *) ((int **) p + 1);
    *((int **) p - 1) = &n;
}

Are the casts well defined? If not, what should I do instead?

Edit:

What I'm trying to achieve is to implement extensible records (OOP) and the integer pointer represent a type ID. An extended record should be compatible with its base type. However, I only need type ID:s for pointer to records. Here is a complete example:

#include <assert.h>
#include <stdlib.h>

struct T0 {
    int f;
};
int T0ID;

struct T1 {
    struct T0 base;
    int g;
};
int T1ID;

int main(void)
{
    struct T0 *x;
    struct T1 *y;

    y = malloc(sizeof (int *) + sizeof *y);
    if (y != NULL) {
        *((int **) y) = &T1ID;
        y = (void *) ((int **) y + 1);
        ((struct T0 *) y)->f = 1;
        y->g = 2;
    }
    x = (struct T0 *) y;
    assert(x->f == 1);
    return 0;
}

Body:
I'm not sure your approach is good. Especially I'm worried about changing the value of p. You'll need that value later when you need to free the memory.

I would wrap the int* and the struct together in another struct. Something like:

static int n;
struct someData { int f; };

struct wrapper {int* pn; struct someData data;};

struct someData* pd; // Pointer to the data struct

struct wrapper* pw = malloc(sizeof *pw);

if (pw != NULL) {
    pw->pn = &n;
    pd = &pw->data;
}


问:
Multiple MAX values in a single query
I'm taking this data and inserting it into another table as part of a conversion process. Unfortunately I'm not able to modify the table schema in either my source or target location.

Schema is as follows (super simplified but the data types can't be modified, just obviously cast)

```<code>CREATE TABLE [dbo].[TestScores](
    [id] [INT] NOT NULL,
    [EXAMNE_ID] [VARCHAR](40) NULL,
    [TestName] VARCHAR(30) NULL,
    [PASS_STA] [VARCHAR](5) NULL,
    [TST_DTE] [VARCHAR](8) NULL,
    [STD_SCOR] [VARCHAR](3) NULL,
) ON [PRIMARY]
</code>```

I have the following source data: (Obviously just a snapshot of the data but for a single person)

```<code>+----+-----------+-----------------+----------+----------+----------+
| id | EXAMNE_ID |    TestName     | PASS_STA | TST_DTE  | STD_SCOR |
+----+-----------+-----------------+----------+----------+----------+
|  1 |     00001 | Social Studies  | Fail     | 20160608 |        7 |
|  2 |     00001 | Science         | Fail     | 20160608 |        8 |
|  3 |     00001 | Reading         | Fail     | 20160608 |        2 |
|  4 |     00001 | Math            | Fail     | 20160608 |        8 |
|  5 |     00001 | Writing         | Fail     | 20160608 |        7 |
|  6 |     00001 | Social Studies  | Fail     | 20160608 |        7 |
|  7 |     00001 | Science         | Fail     | 20160608 |        8 |
|  8 |     00001 | Reading         | Fail     | 20160608 |        2 |
|  9 |     00001 | Math            | Fail     | 20160608 |        8 |
| 10 |     00001 | Writing         | Fail     | 20160608 |        7 |
| 11 |     00001 | Social Studies  | Fail     | 20160608 |        7 |
| 12 |     00001 | Science         | Fail     | 20160608 |        8 |
| 13 |     00001 | Reading         | Fail     | 20160608 |        2 |
| 14 |     00001 | Math            | Fail     | 20160608 |        8 |
| 15 |     00001 | Writing         | Fail     | 20160608 |        7 |
| 16 |     00001 | Social Studies  | Fail     | 20160608 |        7 |
| 17 |     00001 | Social Studies  | Fail     | 20160930 |       10 |
| 18 |     00001 | Science         | Fail     | 20160608 |        8 |
| 19 |     00001 | Reading         | Fail     | 20160608 |        2 |
| 20 |     00001 | Reading         | Fail     | 20160930 |        5 |
| 21 |     00001 | Math            | Fail     | 20160608 |        8 |
| 22 |     00001 | Writing         | Fail     | 20160608 |        7 |
| 23 |     00001 | Writing         | Fail     | 20160930 |       10 |
| 24 |     00001 | Social Studies  | Fail     | 20160608 |        7 |
| 25 |     00001 | Social Studies  | Fail     | 20160930 |       10 |
| 26 |     00001 | Science         | Fail     | 20160608 |        8 |
| 27 |     00001 | Reading         | Fail     | 20160608 |        2 |
| 28 |     00001 | Reading         | Fail     | 20160930 |        5 |
| 29 |     00001 | Math            | Fail     | 20160608 |        8 |
| 30 |     00001 | Writing         | Fail     | 20160608 |        7 |
| 31 |     00001 | Writing         | Fail     | 20160930 |       10 |
| 32 |     00001 | Social Studies  | Fail     | 20160608 |        7 |
| 33 |     00001 | Social Studies  | Fail     | 20160930 |       10 |
| 34 |     00001 | Science         | Fail     | 20160608 |        8 |
| 35 |     00001 | Reading         | Fail     | 20160608 |        2 |
| 36 |     00001 | Reading         | Fail     | 20160930 |        5 |
| 37 |     00001 | Math            | Fail     | 20160608 |        8 |
| 38 |     00001 | Writing         | Pass     | 20160608 |        7 |
| 39 |     00001 | Writing         | Pass     | 20160930 |       10 |
| 40 |     00001 | Social Studies  | Pass     | 20160608 |        7 |
| 41 |     00001 | Social Studies  | Pass     | 20160930 |       10 |
| 42 |     00001 | Science         | Pass     | 20160608 |        8 |
| 43 |     00001 | Reading         | Pass     | 20160608 |        2 |
| 44 |     00001 | Reading         | Pass     | 20160930 |        5 |
| 45 |     00001 | Reading         | Pass     | 20161202 |        9 |
| 46 |     00001 | Math            | Pass     | 20160608 |        8 |
+----+-----------+-----------------+----------+----------+----------+
</code>```

My end result target data should look like this:

```<code>+----+-----------+-----------------+----------+----------+----------+
| id | EXAMNE_ID |    TestName     | PASS_STA | TST_DTE  | STD_SCOR |
+----+-----------+-----------------+----------+----------+----------+
| 39 |     00001 | Writing         | Pass     | 20160930 |       10 |
| 41 |     00001 | Social Studies  | Pass     | 20160930 |       10 |
| 42 |     00001 | Science         | Pass     | 20160608 |        8 |
| 45 |     00001 | Reading         | Pass     | 20161202 |        9 |
| 46 |     00001 | Math            | Pass     | 20160608 |        8 |
+----+-----------+-----------------+----------+----------+----------+
</code>```

I know I gave a ton of extra data since I'm really only looking for results that have a PASS_STA of 'Pass', but I wanted to give more of a complete picture.

Essentially the logic that occurs is that for a given person, when the exam is passed, pull out the greatest value of the TST_DTE and STD_SCOR columns. I'm trying this with what seems like multiple variants of max but it's heading in the wrong direction.

Currently this query isn't giving me what I'm looking for.

```<code>SELECT DISTINCT
EXAMNE_ID, PASS_STA, TestName, MAX(TST_DTE) AS 'TST_DTE', MAX(STD_SCOR) AS 'STD_SCOR'
FROM dbo.TestScores
GROUP BY EXAMNE_ID, PASS_STA, TestName, STD_SCOR
HAVING PASS_STA = 'Pass'
</code>```

Part of me is thinking I need to nest the query since I'm looking for two max values (plus one is a date - well, a date-ish, since it's in a varchar) and the other is a number (but again, stored in a varchar) or maybe somehow the RANK functionality?

I'd rather not have to do aggregate CASE statements for each of the five subject areas. There are actually a few dozen subject areas total, it's just this one test type that I'm showing here has five. So while I think aggregate case statements may work, it may be too cumbersome.

Any ideas?

Thanks in advance

Title: Multiple MAX values in a single query

Body:
I'm taking this data and inserting it into another table as part of a conversion process. Unfortunately I'm not able to modify the table schema in either my source or target location.

Schema is as follows (super simplified but the data types can't be modified, just obviously cast)

CREATE TABLE [dbo].[TestScores](
    [id] [INT] NOT NULL,
    [EXAMNE_ID] [VARCHAR](40) NULL,
    [TestName] VARCHAR(30) NULL,
    [PASS_STA] [VARCHAR](5) NULL,
    [TST_DTE] [VARCHAR](8) NULL,
    [STD_SCOR] [VARCHAR](3) NULL,
) ON [PRIMARY]

I have the following source data: (Obviously just a snapshot of the data but for a single person)

+----+-----------+-----------------+----------+----------+----------+
| id | EXAMNE_ID |    TestName     | PASS_STA | TST_DTE  | STD_SCOR |
+----+-----------+-----------------+----------+----------+----------+
|  1 |     00001 | Social Studies  | Fail     | 20160608 |        7 |
|  2 |     00001 | Science         | Fail     | 20160608 |        8 |
|  3 |     00001 | Reading         | Fail     | 20160608 |        2 |
|  4 |     00001 | Math            | Fail     | 20160608 |        8 |
|  5 |     00001 | Writing         | Fail     | 20160608 |        7 |
|  6 |     00001 | Social Studies  | Fail     | 20160608 |        7 |
|  7 |     00001 | Science         | Fail     | 20160608 |        8 |
|  8 |     00001 | Reading         | Fail     | 20160608 |        2 |
|  9 |     00001 | Math            | Fail     | 20160608 |        8 |
| 10 |     00001 | Writing         | Fail     | 20160608 |        7 |
| 11 |     00001 | Social Studies  | Fail     | 20160608 |        7 |
| 12 |     00001 | Science         | Fail     | 20160608 |        8 |
| 13 |     00001 | Reading         | Fail     | 20160608 |        2 |
| 14 |     00001 | Math            | Fail     | 20160608 |        8 |
| 15 |     00001 | Writing         | Fail     | 20160608 |        7 |
| 16 |     00001 | Social Studies  | Fail     | 20160608 |        7 |
| 17 |     00001 | Social Studies  | Fail     | 20160930 |       10 |
| 18 |     00001 | Science         | Fail     | 20160608 |        8 |
| 19 |     00001 | Reading         | Fail     | 20160608 |        2 |
| 20 |     00001 | Reading         | Fail     | 20160930 |        5 |
| 21 |     00001 | Math            | Fail     | 20160608 |        8 |
| 22 |     00001 | Writing         | Fail     | 20160608 |        7 |
| 23 |     00001 | Writing         | Fail     | 20160930 |       10 |
| 24 |     00001 | Social Studies  | Fail     | 20160608 |        7 |
| 25 |     00001 | Social Studies  | Fail     | 20160930 |       10 |
| 26 |     00001 | Science         | Fail     | 20160608 |        8 |
| 27 |     00001 | Reading         | Fail     | 20160608 |        2 |
| 28 |     00001 | Reading         | Fail     | 20160930 |        5 |
| 29 |     00001 | Math            | Fail     | 20160608 |        8 |
| 30 |     00001 | Writing         | Fail     | 20160608 |        7 |
| 31 |     00001 | Writing         | Fail     | 20160930 |       10 |
| 32 |     00001 | Social Studies  | Fail     | 20160608 |        7 |
| 33 |     00001 | Social Studies  | Fail     | 20160930 |       10 |
| 34 |     00001 | Science         | Fail     | 20160608 |        8 |
| 35 |     00001 | Reading         | Fail     | 20160608 |        2 |
| 36 |     00001 | Reading         | Fail     | 20160930 |        5 |
| 37 |     00001 | Math            | Fail     | 20160608 |        8 |
| 38 |     00001 | Writing         | Pass     | 20160608 |        7 |
| 39 |     00001 | Writing         | Pass     | 20160930 |       10 |
| 40 |     00001 | Social Studies  | Pass     | 20160608 |        7 |
| 41 |     00001 | Social Studies  | Pass     | 20160930 |       10 |
| 42 |     00001 | Science         | Pass     | 20160608 |        8 |
| 43 |     00001 | Reading         | Pass     | 20160608 |        2 |
| 44 |     00001 | Reading         | Pass     | 20160930 |        5 |
| 45 |     00001 | Reading         | Pass     | 20161202 |        9 |
| 46 |     00001 | Math            | Pass     | 20160608 |        8 |
+----+-----------+-----------------+----------+----------+----------+

My end result target data should look like this:

+----+-----------+-----------------+----------+----------+----------+
| id | EXAMNE_ID |    TestName     | PASS_STA | TST_DTE  | STD_SCOR |
+----+-----------+-----------------+----------+----------+----------+
| 39 |     00001 | Writing         | Pass     | 20160930 |       10 |
| 41 |     00001 | Social Studies  | Pass     | 20160930 |       10 |
| 42 |     00001 | Science         | Pass     | 20160608 |        8 |
| 45 |     00001 | Reading         | Pass     | 20161202 |        9 |
| 46 |     00001 | Math            | Pass     | 20160608 |        8 |
+----+-----------+-----------------+----------+----------+----------+

I know I gave a ton of extra data since I'm really only looking for results that have a PASS_STA of 'Pass', but I wanted to give more of a complete picture.

Essentially the logic that occurs is that for a given person, when the exam is passed, pull out the greatest value of the TST_DTE and STD_SCOR columns. I'm trying this with what seems like multiple variants of max but it's heading in the wrong direction.

Currently this query isn't giving me what I'm looking for.

SELECT DISTINCT
EXAMNE_ID, PASS_STA, TestName, MAX(TST_DTE) AS 'TST_DTE', MAX(STD_SCOR) AS 'STD_SCOR'
FROM dbo.TestScores
GROUP BY EXAMNE_ID, PASS_STA, TestName, STD_SCOR
HAVING PASS_STA = 'Pass'

Part of me is thinking I need to nest the query since I'm looking for two max values (plus one is a date - well, a date-ish, since it's in a varchar) and the other is a number (but again, stored in a varchar) or maybe somehow the RANK functionality?

I'd rather not have to do aggregate CASE statements for each of the five subject areas. There are actually a few dozen subject areas total, it's just this one test type that I'm showing here has five. So while I think aggregate case statements may work, it may be too cumbersome.

Any ideas?

Thanks in advance

Body:
;With cte(id , EXAMNE_ID ,    TestName     , PASS_STA , TST_DTE  , STD_SCOR )
AS
(
SELECT  1 , '00001' , 'Social Studies'  , 'Fail'     , '20160608',  7   Union all
SELECT  2 , '00001' , 'Science'         , 'Fail'     , '20160608',  8   Union all
SELECT  3 , '00001' , 'Reading'         , 'Fail'     , '20160608',  2   Union all
SELECT  4 , '00001' , 'Math'            , 'Fail'     , '20160608',  8   Union all
SELECT  5 , '00001' , 'Writing'         , 'Fail'     , '20160608',  7   Union all
SELECT  6 , '00001' , 'Social Studies'  , 'Fail'     , '20160608',  7   Union all
SELECT  7 , '00001' , 'Science'         , 'Fail'     , '20160608',  8   Union all
SELECT  8 , '00001' , 'Reading'         , 'Fail'     , '20160608',  2   Union all
SELECT  9 , '00001' , 'Math'            , 'Fail'     , '20160608',  8   Union all
SELECT 10 , '00001' , 'Writing'         , 'Fail'     , '20160608',  7   Union all
SELECT 11 , '00001' , 'Social Studies'  , 'Fail'     , '20160608',  7   Union all
SELECT 12 , '00001' , 'Science'         , 'Fail'     , '20160608',  8   Union all
SELECT 13 , '00001' , 'Reading'         , 'Fail'     , '20160608',  2   Union all
SELECT 14 , '00001' , 'Math'            , 'Fail'     , '20160608',  8   Union all
SELECT 15 , '00001' , 'Writing'         , 'Fail'     , '20160608',  7   Union all
SELECT 16 , '00001' , 'Social Studies'  , 'Fail'     , '20160608',  7   Union all
SELECT 17 , '00001' , 'Social Studies'  , 'Fail'     , '20160930', 10   Union all
SELECT 18 , '00001' , 'Science'         , 'Fail'     , '20160608',  8   Union all
SELECT 19 , '00001' , 'Reading'         , 'Fail'     , '20160608',  2   Union all
SELECT 20 , '00001' , 'Reading'         , 'Fail'     , '20160930',  5   Union all
SELECT 21 , '00001' , 'Math'            , 'Fail'     , '20160608',  8   Union all
SELECT 22 , '00001' , 'Writing'         , 'Fail'     , '20160608',  7   Union all
SELECT 23 , '00001' , 'Writing'         , 'Fail'     , '20160930', 10   Union all
SELECT 24 , '00001' , 'Social Studies'  , 'Fail'     , '20160608',  7   Union all
SELECT 25 , '00001' , 'Social Studies'  , 'Fail'     , '20160930', 10   Union all
SELECT 26 , '00001' , 'Science'         , 'Fail'     , '20160608',  8   Union all
SELECT 27 , '00001' , 'Reading'         , 'Fail'     , '20160608',  2   Union all
SELECT 28 , '00001' , 'Reading'         , 'Fail'     , '20160930',  5   Union all
SELECT 29 , '00001' , 'Math'            , 'Fail'     , '20160608',  8   Union all
SELECT 30 , '00001' , 'Writing'         , 'Fail'     , '20160608',  7   Union all
SELECT 31 , '00001' , 'Writing'         , 'Fail'     , '20160930', 10   Union all
SELECT 32 , '00001' , 'Social Studies'  , 'Fail'     , '20160608',  7   Union all
SELECT 33 , '00001' , 'Social Studies'  , 'Fail'     , '20160930', 10   Union all
SELECT 34 , '00001' , 'Science'         , 'Fail'     , '20160608',  8   Union all
SELECT 35 , '00001' , 'Reading'         , 'Fail'     , '20160608',  2   Union all
SELECT 36 , '00001' , 'Reading'         , 'Fail'     , '20160930',  5   Union all
SELECT 37 , '00001' , 'Math'            , 'Fail'     , '20160608',  8   Union all
SELECT 38 , '00001' , 'Writing'         , 'Pass'     , '20160608',  7   Union all
SELECT 39 , '00001' , 'Writing'         , 'Pass'     , '20160930', 10   Union all
SELECT 40 , '00001' , 'Social Studies'  , 'Pass'     , '20160608',  7   Union all
SELECT 41 , '00001' , 'Social Studies'  , 'Pass'     , '20160930', 10   Union all
SELECT 42 , '00001' , 'Science'         , 'Pass'     , '20160608',  8   Union all
SELECT 43 , '00001' , 'Reading'         , 'Pass'     , '20160608',  2   Union all
SELECT 44 , '00001' , 'Reading'         , 'Pass'     , '20160930',  5   Union all
SELECT 45 , '00001' , 'Reading'         , 'Pass'     , '20161202',  9  Union all
SELECT 46 , '00001' , 'Math'            , 'Pass'     , '20160608',  8
)
SELECT id
    ,EXAMNE_ID
    ,TestName
    ,PASS_STA
    ,TST_DTE
    ,STD_SCOR
FROM (
    SELECT *
        ,ROW_NUMBER() OVER (
            PARTITION BY TestName ORDER BY id DESC
            ) AS Rno
    FROM (
        SELECT *
            ,ROW_NUMBER() OVER (
                PARTITION BY TestName
                ,TST_DTE ORDER BY id DESC
                ) AS Seq
        FROM cte
        ) Dt
    WHERE Dt.Seq = 1
        AND PASS_STA = 'Pass'
    ) dt2
WHERE dt2.Rno = 1
ORDER BY dt2.id ASC

OutPut

+----+-----------+-----------------+----------+----------+----------+
| id | EXAMNE_ID |    TestName     | PASS_STA | TST_DTE  | STD_SCOR |
+----+-----------+-----------------+----------+----------+----------+
| 39 |     00001 | Writing         | Pass     | 20160930 |       10 |
| 41 |     00001 | Social Studies  | Pass     | 20160930 |       10 |
| 42 |     00001 | Science         | Pass     | 20160608 |        8 |
| 45 |     00001 | Reading         | Pass     | 20161202 |        9 |
| 46 |     00001 | Math            | Pass     | 20160608 |        8 |
+----+-----------+-----------------+----------+----------+----------+


问:
How to detect mouse moving while left button down?
I would like to detect mouse movement while the left button is pressed.

I'm simply creating a drawing application. I can detect mouse movement without any mouse being pressed. But I want to detect it WITH left mouse pressed.

I don't think there's a listener for this. So, what is the idea to do that?

答:
```<code>component.addmouseMotionListener(new MouseAdapter() {
    public void mouseDragged(MouseEvent evt) {
       if ( SwingUtilities.isLeftMouseButton(evt)) {
         // do your stuff here
       }
    }
});
</code>```

ContentLicense: CC BY-SA 4.0


问:
Toggle div, if already open then hide
I'm trying to build a toggling panel that once opened, if the active element is clicked again it closes yet if the sibling element is click the content is updated only I'm having mixed results. Can anybody see where im going wrong?

https://jsfiddle.net/9b3mecc2/

```<code>$('.sectors-list li').on('click', function(e){
  e.preventDefault();
  var order = $(this).index();
  $('.sub-sectors div').hide();
  $('.sub-sectors div').eq(order).show();
  if($('.digital-sectors').is(':visible')
  && order === 0){
    $('.sub-sectors').removeClass('active');
  } else {
      $('.sub-sectors').addClass('active');
  }
});
</code>```

答:
What you try to do is not complicated, just that your code is missing references from the event element to the element to show, so you can do with css, using the pseudo-selector : target

Check documentation :target

Browser support list

div{ display: none; }
div:target{ display: block; }```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<ul>
  <li>foo</li>
  <li>bar</li>
</ul>
<div id='data-foo'>data foo</div>
<div id='data-bar'>data bar</div></code>```

Title: Toggle div, if already open then hide

Body:
I'm trying to build a toggling panel that once opened, if the active element is clicked again it closes yet if the sibling element is click the content is updated only I'm having mixed results. Can anybody see where im going wrong?

https://jsfiddle.net/9b3mecc2/

$('.sectors-list li').on('click', function(e){
  e.preventDefault();
  var order = $(this).index();
  $('.sub-sectors div').hide();
  $('.sub-sectors div').eq(order).show();
  if($('.digital-sectors').is(':visible')
  && order === 0){
    $('.sub-sectors').removeClass('active');
  } else {
      $('.sub-sectors').addClass('active');
  }
});

Body:
What you try to do is not complicated, just that your code is missing references from the event element to the element to show, so you can do with css, using the pseudo-selector : target

Check documentation :target

Browser support list

div{ display: none; }
div:target{ display: block; }

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<ul>
  <li><a href='#data-foo'>foo</a></li>
  <li><a href='#data-bar'>bar</a></li>
</ul>
<div id='data-foo'>data foo</div>
<div id='data-bar'>data bar</div>


问:
Error: Server Error. connect ETIMEDOUT 104.197.85.31:443
i am using firebase cli and i try the following

```<code>$ firebase init
</code>```

the cli continue with the message :

You're about to initialize a Firebase project in this directory:
c:\Dev\Test
are you ready to proceed ?

i type y
and choose Hosting:Configure and deploy Firebase Hosting sites

after few second i get the error

```<code>Error: Server Error. connect ETIMEDOUT 104.197.85.31:443
</code>```

what can be the problem ?

my Enviroment specification:

```<code>CLI Version:  3.9.1
Platform:     win32
Node Version: v7.10.0
Time:Thu Jun 08 2017 18:03:14 GMT+0430 (Iran Daylight Time)
</code>```

i am useing PSIPHONE also as a proxy but i have also tried without PSIPHONE .

in both cases i get connection timeout

i have pinged 104.197.85.31 the connection is ok .

any suggestion to solve the issue ?

is it  because i am in IRAN ?

答: It's on the Firebase's end. You can check status here. </p>

Body:
i am using firebase cli and i try the following

$ firebase init

the cli continue with the message :

You're about to initialize a Firebase project in this directory:
c:\Dev\Test
are you ready to proceed ?

i type y
and choose Hosting:Configure and deploy Firebase Hosting sites

after few second i get the error

Error: Server Error. connect ETIMEDOUT 104.197.85.31:443

what can be the problem ?

my Enviroment specification:

CLI Version:  3.9.1
Platform:     win32
Node Version: v7.10.0
Time:Thu Jun 08 2017 18:03:14 GMT+0430 (Iran Daylight Time)

i am useing PSIPHONE also as a proxy but i have also tried without PSIPHONE .

in both cases i get connection timeout

i have pinged 104.197.85.31 the connection is ok .

any suggestion to solve the issue ?

is it  because i am in IRAN ?


问:
Check when script has loaded
I am trying to call a function that, on the load of the script above it, will run some JavaScript.

```<code><script src="../Layout/jquery.js" type="text/javascript"></script>
<script type="text/javascript" language="javascript" src="helperscript.js"></script>
<script type="text/javascript">
    $(document).ready(function(){
        var itemid = '1';
        if(itemid)
        {
            idselect(itemid);
        }
    })
</script>
</code>```

helperscript.js contains the function idselect.
When I load the page I get an error saying that 'idselect is undefined', even though it is in the above file. I suspect that this is due to helperscript not being fully loaded yet, but that is just a hunch.

Can anyone help me?

答:
Make sure your path to the script to the .js file is correct.

Also cut the language="javascript" part.

Title: Check when script has loaded

Body:
I am trying to call a function that, on the load of the script above it, will run some JavaScript.

helperscript.js contains the function idselect.
When I load the page I get an error saying that 'idselect is undefined', even though it is in the above file. I suspect that this is due to helperscript not being fully loaded yet, but that is just a hunch.

Can anyone help me?


问:
Python script that receives Jira Webhooks data
Jira Webhooks allows the user to specify the URL of an application that will receive data, in json format, when an event occurs. For example when an issue is updated in Jira. I want to create a python script that will receive this data and print it out. How is the best way to create this python script?  </p>

答:
There are many ways to skin a cat, but basically you need a Web server, which can receive POST requests and knows how to read corresponding parameters.
Several possibilities:

Write simple script using builtin SimpleHTTPServer

Use some web framework (Django, Flask)

Deploy your python script to AWS Lambda and configure API Gateway

And here is an example application from Atlassian which can help you get started.


问:
Why does calling Window.scroll() give a trusted event?
I have a Chrome extension that needs to produce human-like mouse and keyboard behavior (specifically, generate events that have a isTrusted value of true). I can do everything I need except for scrolling with the chrome.debugger APIs.

But it seems that the Window.scroll() method is sufficient for this purpose up to Chrome 52 and Firefox 48.0a1. This can be observed by attaching an event listener to the page as follows:

```<code>document.addEventListener("scroll", function (event) {
    console.log("event trusted? " + event.isTrusted);
});
</code>```

and then running something like window.scroll(0, 10); in the developer console. This will log event trusted? true to the developer console.

My question is: why is this the case? Shouldn't the isTrusted property be false in this case since the scroll event was clearly generated by a script?

答:
It seems that *.scroll or changing the scrollTop property does not construct the event correctly. As you can see in the example the isTrusted is false if I create the event on my own. I think it is a bug in the Engine

"use strict";
var event = new Event('scroll');

//target.addEventListener(type, listener[, options]);
//target.addEventListener(type, listener[, useCapture]);
//target.addEventListener(type, listener[, useCapture, wantsUntrusted  ]); // Gecko/Mozilla only
window.addEventListener('scroll', function(e) {
  console.log(e.isTrusted);
}, false);

console.log('JS engine event:');
window.scroll(10, 10);

setTimeout(function() {
  console.log('Selfmade event:');
  window.dispatchEvent(event);
}, 1000);

setTimeout(function() {
  console.log('Another event triggered by changing the scrollTop property:');
  window.scrollTop = '20px';
}, 2000);```
<pre class="snippet-code-css lang-css prettyprint-override"><code>#container {
  width: 100px;
  height: 10000px;
  overflow: scroll;
}</code>```

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata
  sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum.
  Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
```

Body:
I have a Chrome extension that needs to produce human-like mouse and keyboard behavior (specifically, generate events that have a isTrusted value of true). I can do everything I need except for scrolling with the chrome.debugger APIs.

But it seems that the Window.scroll() method is sufficient for this purpose up to Chrome 52 and Firefox 48.0a1. This can be observed by attaching an event listener to the page as follows:

document.addEventListener("scroll", function (event) {
    console.log("event trusted? " + event.isTrusted);
});

and then running something like window.scroll(0, 10); in the developer console. This will log event trusted? true to the developer console.

My question is: why is this the case? Shouldn't the isTrusted property be false in this case since the scroll event was clearly generated by a script?

Body:
It seems that *.scroll or changing the scrollTop property does not construct the event correctly. As you can see in the example the isTrusted is false if I create the event on my own. I think it is a bug in the Engine

"use strict";
var event = new Event('scroll');

//target.addEventListener(type, listener[, options]);
//target.addEventListener(type, listener[, useCapture]);
//target.addEventListener(type, listener[, useCapture, wantsUntrusted  ]); // Gecko/Mozilla only
window.addEventListener('scroll', function(e) {
  console.log(e.isTrusted);
}, false);

console.log('JS engine event:');
window.scroll(10, 10);

setTimeout(function() {
  console.log('Selfmade event:');
  window.dispatchEvent(event);
}, 1000);

setTimeout(function() {
  console.log('Another event triggered by changing the scrollTop property:');
  window.scrollTop = '20px';
}, 2000);

#container {
  width: 100px;
  height: 10000px;
  overflow: scroll;
}

<div id="container">Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata
  sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum.
  Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</div>


问:
Hide infoWindow when clicked marker second time (Google Map Android API V2)
To achieve this I feel I simply need to override onMarkerClick and check if the infoWindow of clicked marker has already been open, but to my surprise clickedMarker.isInfoWindowShown() always return false...

My codes:

```<code>@Override
public boolean onMarkerClick(final Marker clickedMarker) {
    if(clickedMarker.isInfoWindowShown()) {
        clickedMarker.hideInfoWindow();
        System.out.println("was showing");
    } else {
        clickedMarker.showInfoWindow();
        System.out.println("not showing");
    }
}
</code>```

It always tells me the infoWindow is "not showing" which is not right... I can get around this by keeping a reference of userLastClickedMarker but I'd like to know where I did wrong above.

Thanks!

Edit:

I changed my code to debug this issue:

```<code>    System.out.println(clickedMarker.isInfoWindowShown());
    if(clickedMarker.isInfoWindowShown()) {
        clickedMarker.hideInfoWindow();
        System.out.println(" showing");
    } else {
        clickedMarker.showInfoWindow();
        System.out.println("not showing");
    }
    System.out.println(clickedMarker.isInfoWindowShown());
</code>```

I found that isInfoWindowShown() does work correctly in onMarkerClick method but won't 'remember' it correctly. And I found this has been pointed out as a bug by someone already...

https://code.google.com/p/gmaps-api-issues/issues/detail?id=5408

答:
isInfoWindowShown always false, so I hide info window using the basic way </p>

```<code>int mLastIndex = -1
</code>```

<p>and on </p>

```<code>@Override
public boolean onMarkerClick(Marker marker) {
    int index = (int) marker.getTag();
    Log.i(TAG, "onMarkerClick: " + index);
    if(lastIndex != index){
        marker.showInfoWindow();
        lastIndex = index;
    }else{
        marker.hideInfoWindow();
        lastIndex = -1;
    }

    return true;
}
</code>```

Body:
To achieve this I feel I simply need to override onMarkerClick and check if the infoWindow of clicked marker has already been open, but to my surprise clickedMarker.isInfoWindowShown() always return false...

My codes:

@Override
public boolean onMarkerClick(final Marker clickedMarker) {
    if(clickedMarker.isInfoWindowShown()) {
        clickedMarker.hideInfoWindow();
        System.out.println("was showing");
    } else {
        clickedMarker.showInfoWindow();
        System.out.println("not showing");
    }
}

It always tells me the infoWindow is "not showing" which is not right... I can get around this by keeping a reference of userLastClickedMarker but I'd like to know where I did wrong above.

Thanks!

Edit:

I changed my code to debug this issue:

    System.out.println(clickedMarker.isInfoWindowShown());
    if(clickedMarker.isInfoWindowShown()) {
        clickedMarker.hideInfoWindow();
        System.out.println(" showing");
    } else {
        clickedMarker.showInfoWindow();
        System.out.println("not showing");
    }
    System.out.println(clickedMarker.isInfoWindowShown());

I found that isInfoWindowShown() does work correctly in onMarkerClick method but won't 'remember' it correctly. And I found this has been pointed out as a bug by someone already...

https://code.google.com/p/gmaps-api-issues/issues/detail?id=5408

Body:
isInfoWindowShown always false, so I hide info window using the basic way

int mLastIndex = -1

and on

@Override
public boolean onMarkerClick(Marker marker) {
    int index = (int) marker.getTag();
    Log.i(TAG, "onMarkerClick: " + index);
    if(lastIndex != index){
        marker.showInfoWindow();
        lastIndex = index;
    }else{
        marker.hideInfoWindow();
        lastIndex = -1;
    }

    return true;
}


问:
making line between 2 text regular
I have a class which has login /signup text. The text font-style is italic. I am wondering how I can make the line (|) between "login" and "sign up" regular but keep the remaining text italic. Also, can we get this by keeping the three things (login, |, Sign Up) in the same class?

At this moment, all three of things (login, |, Sign Up) are italic. The HTML and CSS codes which I have used are:

li.login-signup {
  font-style: italic;
  font-size: 12px;
  font-family: Adelle PE;
  letter-spacing: .30em;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><li class="login-signup">Log In | Sign up</li></code>```

答:
Only way to do it is:

Log In | Sign up

And then add class .regular {font-style: normal;}

Title: making line between 2 text regular

Body:
I have a class which has login /signup text. The text font-style is italic. I am wondering how I can make the line (|) between "login" and "sign up" regular but keep the remaining text italic. Also, can we get this by keeping the three things (login, |, Sign Up) in the same class?

At this moment, all three of things (login, |, Sign Up) are italic. The HTML and CSS codes which I have used are:

li.login-signup {
  font-style: italic;
  font-size: 12px;
  font-family: Adelle PE;
  letter-spacing: .30em;
}

Log In | Sign up

Body:
Only way to do it is:
<li class="login-signup">Log In <span class="regular">|</span> Sign up</li>

And then add class .regular {font-style: normal;}


问:
JRE not found by eclipse
I am having issues starting up my java neon, and it keeps saying saying "A Java Runtime Environment (JRE) or Java Development Kit (JDK) must be available in order to run eclipse. no java virtual machine was found after searching the following locations C:/Program Files/Java/jre1.8.0_45/bin" but i installed the jre1.8.0_131, as i dont know how to either downgrade mine or update eclipse's. I feel so silly for not even knowing how to do this but thanks for any help you guys have!</p>

答:
This is not a version problem, but a problem with where it is installed.  You need to do more than install the JDE or JDK.  You have to put it in a special location depending on your OS.

Here is a good step by step for installing JDK on MAC, Windows and Linux:
https://www3.ntu.edu.sg/home/ehchua/programming/howto/JDK_Howto.html

You might also need to look at what you gave eclipse access to in the setup stage.  There is a chance you didn't give it the option to look in the place it needs to.

I would reccommend you try to compile and run java from a text file and use the command prompt before an IDE.  If you can compile and run a test prompt then you know its in the right spot and the problem lies with eclipse location/locator.

To run from a text file.  Just open a text file, save it as something.java then type some code and navigate to the file, type javac name of file.java and then if that works  type java name of file  If this all works fine then it is a problem with eclipse.  If not you have a problem with where it is installed.

Title: JRE not found by eclipse


问:
Why is value undefined at .then() chained to Promise?
Given

function doStuff(n /* `n` is expected to be a positive number */) {
  return new Promise(function(resolve, reject) {
    setTimeout(function() {
      resolve(n * 10)
    }, Math.floor(Math.random() * 1000))
  })
  .then(function(result) {
    if (result > 100) {
      console.log(result + " is greater than 100")
    } else {
      console.log(result + " is not greater than 100");
    }
  })
}

doStuff(9)
.then(function(data) {
  console.log(data) // `undefined`,  why?
})```

Why is data undefined at .then() chained to doStuff() call?

答:
Because no Promise or other value is returned from .then() chained to Promise constructor.

Note that .then() returns a new Promise object.

The solution is to return a value or other function call which returns a value or Promise from .then().

function doStuff(n /* `n` is expected to be a positive number */) {
  return new Promise(function(resolve, reject) {
    setTimeout(function() {
      resolve(n * 10)
    }, Math.floor(Math.random() * 1000))
  })
  .then(function(result) {
    if (result > 100) {
      console.log(result + " is greater than 100")
    } else {
      console.log(result + " is not greater than 100");
    }
    // `return` `result` or other value here
    // to avoid `undefined` at chained `.then()`
    return result
  })
}

doStuff(9)
.then(function(data) {
  console.log("data is: " + data) // `data` is not `undefined`
});```

Body:
Given

function doStuff(n /* `n` is expected to be a positive number */) {
  return new Promise(function(resolve, reject) {
    setTimeout(function() {
      resolve(n * 10)
    }, Math.floor(Math.random() * 1000))
  })
  .then(function(result) {
    if (result > 100) {
      console.log(result + " is greater than 100")
    } else {
      console.log(result + " is not greater than 100");
    }
  })
}

doStuff(9)
.then(function(data) {
  console.log(data) // `undefined`,  why?
})

Why is data undefined at .then() chained to doStuff() call?


问:
Better Way to Remove Special Characters - Access SQL
I'm looking for a way to remove special characters from a field within my Access database. The field has both text and numbers along with dashes, underscores and periods. I want to keep the letters and numbers but remove everything else. There are multiple examples of VB scripts, and some in SQL, but the SQL examples I've seen are very lengthy and do not seem very efficient.

Is there a better way to write a SQL script to remove these characters without having to list each of the special characters such as the below example?

SELECT REPLACE([PolicyID],'-','')
FROM RT_PastDue_Current;

答:
If you are actually manipulating the data and executing code from the context of the MS Access application, then SQL calls can call any public function inside the modules in the MDB.   You could write a cleanup function, then

```<code>UPDATE Mytable SET MyField=Cleanup(MyField)
</code>```

Other than that, I have yet to encounter any RDBMS database engine that has much advanced string manipulation features beyond the simple Replace you've mentioned.

Body:
If you are actually manipulating the data and executing code from the context of the MS Access application, then SQL calls can call any public function inside the modules in the MDB.   You could write a cleanup function, then

UPDATE Mytable SET MyField=Cleanup(MyField)

Other than that, I have yet to encounter any RDBMS database engine that has much advanced string manipulation features beyond the simple Replace you've mentioned.


问:
Error in non existing file
I'm working on a .NET project, and I'm in a hard debugging period. I found a way to fix it, but when I read the error log in details, I realize that the error comes from a file that doesn't even exists ! </p>

```<code>dans C:\Users\Monstreur\Documents\Visual Studio 2015\Projects\HDPreDiag\ServiceWCF\Service1.svc.cs:ligne 56
</code>```

<p>I tried to search it or access it in command line, but as expected it says that the directory does not exists, how can it be possible ? </p>

答:
You have modified the source code after the application was compiled.

The source references from any stack traces are based on the binaries, if the source code has been modified since the binary was produced, you will need to refer back to the original source code to make sense of any source code line references.

You should re-compile the program.  I would recommend also running using an interactive debugger through your development environment to improve your debugging experience.

Title: Error in non existing file

Body:
I'm working on a .NET project, and I'm in a hard debugging period. I found a way to fix it, but when I read the error log in details, I realize that the error comes from a file that doesn't even exists !

dans C:\Users\Monstreur\Documents\Visual Studio 2015\Projects\HDPreDiag\ServiceWCF\Service1.svc.cs:ligne 56

I tried to search it or access it in command line, but as expected it says that the directory does not exists, how can it be possible ?


问:
How do I find out the path of the currently executing script?
Duplicate of: In Python, how do I get the path and name of the file that is currently executing?

I would like to find out the path to the currently executing script.
I have tried os.getcwd() but that only returns the directory I ran the script from not the actual directory the script is stored.

答:
In Python, __file__ identifies the current Python file. Thus:

```<code>print "I'm inside Python file %s" % __file__
</code>```

will print the current Python file. Note that this works in imported Python modules, as well as scripts.

OwnerDisplayName: Ashy

LastEditorDisplayName: Kev

Body:
In Python, __file__ identifies the current Python file. Thus:

print "I'm inside Python file %s" % __file__

will print the current Python file. Note that this works in imported Python modules, as well as scripts.

OwnerDisplayName: Brian Clapper


问:
Java array initialization within argument list
How come the first call to someMethod doesn't compile without being explicit that it's String[]?

It's fine to use an array initializer to create a String[] array but you can't use it to pass an argument.  Are the curly braces used in some other fashion for passing arguments that derails how I'd expect this to behave?

```<code>public void someMethod(String[] arr){
    //do some magic
}

public void makeSomeMagic(){

    String[] arr = {"cat", "fish", "cow"};

    //Does not compile!
    someMethod({"cat", "fish", "cow"});

    //This compiles!
    someMethod(new String[]{"cat", "fish", "cow"});

    //This compiles!
    someMethod(arr);
}
</code>```

The compiler error is the following:

The method someMethod(String[]) in the type Moo is not applicable for the arguments (String, String, String)

答: You can use the curly braces to initialize an array. In every else case it is used to define blocks of statments.</p>

Body:
How come the first call to someMethod doesn't compile without being explicit that it's String[]?

It's fine to use an array initializer to create a String[] array but you can't use it to pass an argument.  Are the curly braces used in some other fashion for passing arguments that derails how I'd expect this to behave?

public void someMethod(String[] arr){
    //do some magic
}

public void makeSomeMagic(){

    String[] arr = {"cat", "fish", "cow"};

    //Does not compile!
    someMethod({"cat", "fish", "cow"});

    //This compiles!
    someMethod(new String[]{"cat", "fish", "cow"});

    //This compiles!
    someMethod(arr);
}

The compiler error is the following:

The method someMethod(String[]) in the type Moo is not applicable for the arguments (String, String, String)


问:
How to fade out just one button with Jquery
I have a row of buttons: </p>

```<code> <div class="console_row1">
            <button class="button">TOFU</button>
            <button class="button">BEANS</button>
            <button class="button">RICE</button>
            <button class="button">PASTA</button>
            <button class="button">QUINOA</button>
            <button class="button">SOY MILK</button>
</div>
</code>```

<p>And I'm trying to make a program where if you click on one of the buttons, it ONLY fades out the button you clicked on. I have the following Jquery: </p>

```<code> $(document).ready(function(){
            $(".button").click(function(){
                $(".button").fadeOut()
            });
        });
</code>```

答:
Use $(this).this will give the reference to the member that invokes the current function.You can Read more  here

 $(document).ready(function(){
            $(".button").click(function(){
                $(this).fadeOut()
            });
        });```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="console_row1">
            <button class="button">TOFU</button>
            <button class="button">BEANS</button>
            <button class="button">RICE</button>
            <button class="button">PASTA</button>
            <button class="button">QUINOA</button>
            <button class="button">SOY MILK</button>
</div>
And I'm trying to make a program where if you click on one of the buttons, it ONLY fades out the button you clicked on. I have the following Jquery:</code>```

For fadeout using css

 $(document).ready(function(){
                $(".button").click(function(){
                    $(this).addClass('fadeOut')
                });
            });```
<pre class="snippet-code-css lang-css prettyprint-override"><code>.button{
  transition:all .5s linear;
}

.fadeOut{
  opacity:0;
}</code>```

                <button class="button">TOFU</button>
                <button class="button">BEANS</button>
                <button class="button">RICE</button>
                <button class="button">PASTA</button>
                <button class="button">QUINOA</button>
                <button class="button">SOY MILK</button>

 ```

Body:
I have a row of buttons:

            <button class="button">TOFU</button>
            <button class="button">BEANS</button>
            <button class="button">RICE</button>
            <button class="button">PASTA</button>
            <button class="button">QUINOA</button>
            <button class="button">SOY MILK</button>

And I'm trying to make a program where if you click on one of the buttons, it ONLY fades out the button you clicked on. I have the following Jquery:

 $(document).ready(function(){
            $(".button").click(function(){
                $(".button").fadeOut()
            });
        });

Body:
Use $(this).this will give the reference to the member that invokes the current function.You can Read more  here

 $(document).ready(function(){
            $(".button").click(function(){
                $(this).fadeOut()
            });
        });

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="console_row1">
            <button class="button">TOFU</button>
            <button class="button">BEANS</button>
            <button class="button">RICE</button>
            <button class="button">PASTA</button>
            <button class="button">QUINOA</button>
            <button class="button">SOY MILK</button>
</div>
And I'm trying to make a program where if you click on one of the buttons, it ONLY fades out the button you clicked on. I have the following Jquery:

For fadeout using css

 $(document).ready(function(){
                $(".button").click(function(){
                    $(this).addClass('fadeOut')
                });
            });

.button{
  transition:all .5s linear;
}

.fadeOut{
  opacity:0;
}

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <div class="console_row1">
                <button class="button">TOFU</button>
                <button class="button">BEANS</button>
                <button class="button">RICE</button>
                <button class="button">PASTA</button>
                <button class="button">QUINOA</button>
                <button class="button">SOY MILK</button>
    </div>


问:
Excel Cross referencing lists
What I would like is a formula to search column A and return a result from column J. Simple!

Not quite.

In column A is a list of names, some with first and last and some with middle names. I would like to search Column A for cells containing "John" and "Doe" and receive the result for a cell containing "John A Doe"

答:
You can use the wildcard (*) and Match to find the row your value is on.  You can then use INDEX to return the value from that row in column J.

If cell C1 contains John Doe you can substitute the space for a wildcard, add a wildcard at the start and end and search:

MATCH("*" & SUBSTITUTE($C$1," ","*") & "*",$A:$A,0)

returning the value from column J using INDEX:

=INDEX($J:$J,MATCH("*" & SUBSTITUTE($C$1," ","*") & "*",$A:$A,0))

If cell C1 contains John and D1 contains Doe:

MATCH("*" & C1 & "*" & D1 & "*",$A:$A,0)

returning the value from column J:

=INDEX($J:$J,MATCH("*" & C1 & "*" & D1 & "*",$A:$A,0))

Title: Excel Cross referencing lists