问:
Include subdomain when proxying in node
I've setup a simple HTTPS server to handle the following to situations:

Requests to https://localhost:5000/ that have a matching file in my directory are served via connect.static(__dirname). This works great for everything like my index.html and my CSS files and is working exactly as I need.

Requests to https://localhost:5000/api should redirect to https://subdomain.mydomain.com:443/api.

The proxy is properly transferring everything over HTTPS and the SSL handshake part seems to be working exactly as I would expect. The problem is that my API uses the subdomain to determine what database to connect to and what data to return. So, my API sees the request

```<code>https://localhost:5000/api/something
</code>```

instead of

```<code>https://subdomain.mydomain.com/api/something
</code>```

and is throwing an error telling me I have to supply the subdomain.

How can I tell the node proxy to forward (or use) the domain/subdomain when doing the proxy?

Here is my code:

```<code>var fs = require('fs');
var connect = require('connect'),
    https = require('https'),
    httpProxy = require('http-proxy'),
    options = {
      key: fs.readFileSync('key.pem'),
      cert: fs.readFileSync('cert.pem')
    },
    endpoint = {
        host: 'subdomain.mydomain.com',
        port: 443,
        prefix: '/api',
        target: { https: true }
    };

var proxy = new httpProxy.RoutingProxy();
var app = connect()
    .use(connect.logger('dev'))
    .use(function(req, res, next) {
        if (req.url.indexOf(endpoint.prefix) === 0) {
            proxy.proxyRequest(req, res, endpoint);
        } else {
            next();
        }
    })
    .use(connect.static(__dirname));

https.createServer(options, app).listen(5000);
console.log('Listening on port 5000');
</code>```

答: Just in case someone bumps into this old question, you should use http-proxy's changeOrigin option.</p>

Title: Include subdomain when proxying in node

Body:
I've setup a simple HTTPS server to handle the following to situations:

Requests to https://localhost:5000/ that have a matching file in my directory are served via connect.static(__dirname). This works great for everything like my index.html and my CSS files and is working exactly as I need.

Requests to https://localhost:5000/api should redirect to https://subdomain.mydomain.com:443/api.

The proxy is properly transferring everything over HTTPS and the SSL handshake part seems to be working exactly as I would expect. The problem is that my API uses the subdomain to determine what database to connect to and what data to return. So, my API sees the request

https://localhost:5000/api/something

instead of

https://subdomain.mydomain.com/api/something

and is throwing an error telling me I have to supply the subdomain.

How can I tell the node proxy to forward (or use) the domain/subdomain when doing the proxy?

Here is my code:

var fs = require('fs');
var connect = require('connect'),
    https = require('https'),
    httpProxy = require('http-proxy'),
    options = {
      key: fs.readFileSync('key.pem'),
      cert: fs.readFileSync('cert.pem')
    },
    endpoint = {
        host: 'subdomain.mydomain.com',
        port: 443,
        prefix: '/api',
        target: { https: true }
    };

var proxy = new httpProxy.RoutingProxy();
var app = connect()
    .use(connect.logger('dev'))
    .use(function(req, res, next) {
        if (req.url.indexOf(endpoint.prefix) === 0) {
            proxy.proxyRequest(req, res, endpoint);
        } else {
            next();
        }
    })
    .use(connect.static(__dirname));

https.createServer(options, app).listen(5000);
console.log('Listening on port 5000');


来源: stackexchange

问:
HQL: How to select all entities distinct by some column?

A simple question:

In this example I need to retrieve all objects, but these objects must have distinct msgFrom fields.

When I use

```<code>List<Message> list = getHibernateTemplate().find("select distinct m.msgFrom from Message m WHERE msgTo = ? AND msgCheck = 0", dinc);
</code>```

I get next error:

```<code>java.lang.ClassCastException: java.lang.Integer cannot be cast to com.example.model.Message
</code>```

I suppose it's because Hibernate retrieves only one column, but I need an object, not column.
How can I do this?
I think that I can just scroll through a comma, i.e.

```<code>List<Message> list = getHibernateTemplate().find("select distinct m.msgFrom, m.To, m.datetime, .......... from Message m WHERE msgTo = ? AND msgCheck = 0", dinc);
</code>```

But what if I have more than 20 fields here? Is there an easy solution?

Thanks!

答:
Below is the sample query :

```<code>select e from Message e
where e.msgFrom IN (select distinct m.msgFrom
                      from Message m
                      WHERE m.msgTo = ?
                      AND m.msgCheck = "0");
</code>```

Alternatively, you can also use Criteria API.

ContentLicense: CC BY-SA 2.5

Body:
A simple question:

In this example I need to retrieve all objects, but these objects must have distinct msgFrom fields.

When I use

List<Message> list = getHibernateTemplate().find("select distinct m.msgFrom from Message m WHERE msgTo = ? AND msgCheck = 0", dinc);

I get next error:

java.lang.ClassCastException: java.lang.Integer cannot be cast to com.example.model.Message

I suppose it's because Hibernate retrieves only one column, but I need an object, not column.
How can I do this?
I think that I can just scroll through a comma, i.e.

List<Message> list = getHibernateTemplate().find("select distinct m.msgFrom, m.To, m.datetime, .......... from Message m WHERE msgTo = ? AND msgCheck = 0", dinc);

But what if I have more than 20 fields here? Is there an easy solution?

Thanks!

Body:
Below is the sample query :

select e from Message e
where e.msgFrom IN (select distinct m.msgFrom
                      from Message m
                      WHERE m.msgTo = ?
                      AND m.msgCheck = "0");

Alternatively, you can also use Criteria API.

ContentLicense: CC BY-SA 3.0


问:
how to find extreme point of the contour opencv c++
I have this image:

How do i can implement the extreme point finder code in OpenCv c++ like in the picture?

Anyone have any idea please??

```<code># determine the most extreme points along the contour

leftmost = tuple(cnt [cnt[:,:,0].argmin()][0]);
rightmost = tuple(cnt [cnt[:,:,0].argmax()][0]);
topmost = tuple(cnt [cnt[:,:,1].argmin()][0]);
bottommost = tuple(cnt [cnt[:,:,1].argmax()][0]);
</code>```

答:
```<code>void thresh_callback(int, void* )
{
    Mat canny_output;
    vector<vector<Point> > contours;
    vector<Vec4i> hierarchy;

    Canny( src_gray, canny_output, thresh, thresh*2, 3 );
    findContours( canny_output, contours, hierarchy, RETR_TREE, CHAIN_APPROX_SIMPLE, Point(0, 0) );

    Mat drawing = Mat::zeros( canny_output.size(), CV_8UC3 );

    for( size_t i = 0; i< contours.size(); i++ )
    {
        Scalar color = Scalar( rng.uniform(0, 255), rng.uniform(0,255), rng.uniform(0,255) );
        drawContours( drawing, contours, (int)i, color, 2, 8, hierarchy, 0, Point() );
    }

    namedWindow( "Contours", WINDOW_AUTOSIZE );
    imshow( "Contours", drawing );
}
</code>```

to use this code how does above code works

Body:
I have this image:

How do i can implement the extreme point finder code in OpenCv c++ like in the picture?

Anyone have any idea please??

# determine the most extreme points along the contour

leftmost = tuple(cnt [cnt[:,:,0].argmin()][0]);
rightmost = tuple(cnt [cnt[:,:,0].argmax()][0]);
topmost = tuple(cnt [cnt[:,:,1].argmin()][0]);
bottommost = tuple(cnt [cnt[:,:,1].argmax()][0]);

Body:
void thresh_callback(int, void* )
{
    Mat canny_output;
    vector<vector<Point> > contours;
    vector<Vec4i> hierarchy;

    Canny( src_gray, canny_output, thresh, thresh*2, 3 );
    findContours( canny_output, contours, hierarchy, RETR_TREE, CHAIN_APPROX_SIMPLE, Point(0, 0) );

    Mat drawing = Mat::zeros( canny_output.size(), CV_8UC3 );

    for( size_t i = 0; i< contours.size(); i++ )
    {
        Scalar color = Scalar( rng.uniform(0, 255), rng.uniform(0,255), rng.uniform(0,255) );
        drawContours( drawing, contours, (int)i, color, 2, 8, hierarchy, 0, Point() );
    }

    namedWindow( "Contours", WINDOW_AUTOSIZE );
    imshow( "Contours", drawing );
}

to use this code how does above code works


问:
Serial number in Table Angular 2
I am getting data from api and want to show in a table and in table I have # column for serial number now i want to show the serial number I have done so far this but its shows 1 to 10 serial number on every page when I change the page it shows 1- 10 counting start from 1 when ever the next page is load

Image page 1

Image page 2

Code

                {{i + 1}}
                {{user.FirstName}}
                {{user.LastName}}
                {{user.Email}}

                    <button *ngIf="user.IsActive==false" class="btn btn-success btn-xs" (click)="changeStatus(user.Id)">  Active </button>
                    <button *ngIf="user.IsActive==true" class="btn btn-danger btn-xs" (click)="changeStatus(user.Id)"> Block</button>}}

```

答:
You may use it like this </p>

<blockquote>
  <p>{{$index +1}} </p>
</blockquote>

Title: Serial number in Table Angular 2

Body:
You may use it like this

{{$index +1}}


问:
Check failed: status == CUDNN_STATUS_SUCCESS (3 vs. 0) CUDNN_STATUS_BAD_PARAM for FASTER RCNN Library
I am testing Faster Rcnn. Installation is fine.
During the installation, I had one issue with cudnn5.1 and I followed the suggestion here and now installation is fine.

Now I test the demo code as

```<code>./tools/demo.py
</code>```

Then I have error as

```<code>I1117 09:48:41.011925 12503 net.cpp:51] Initializing net from parameters:
name: "VGG_ILSVRC_16_layers"
state {
  phase: TEST
  level: 0
}
.
.
.
layer {
  name: "cls_prob"
  type: "Softmax"
  bottom: "cls_score"
  top: "cls_prob"
}
I1117 09:48:41.012234 12503 layer_factory.hpp:77] Creating layer input
I1117 09:48:41.012251 12503 net.cpp:84] Creating Layer input
I1117 09:48:41.012259 12503 net.cpp:380] input -> data
I1117 09:48:41.012271 12503 net.cpp:380] input -> im_info
I1117 09:48:41.328574 12503 net.cpp:122] Setting up input
I1117 09:48:41.328608 12503 net.cpp:129] Top shape: 1 3 224 224 (150528)
I1117 09:48:41.328614 12503 net.cpp:129] Top shape: 1 3 (3)
I1117 09:48:41.328618 12503 net.cpp:137] Memory required for data: 602124
I1117 09:48:41.328624 12503 layer_factory.hpp:77] Creating layer conv1_1
I1117 09:48:41.328655 12503 net.cpp:84] Creating Layer conv1_1
I1117 09:48:41.328660 12503 net.cpp:406] conv1_1 <- data
I1117 09:48:41.328670 12503 net.cpp:380] conv1_1 -> conv1_1
F1117 09:48:41.676553 12503 cudnn.hpp:128] Check failed: status == CUDNN_STATUS_SUCCESS (3 vs. 0)  CUDNN_STATUS_BAD_PARAM
*** Check failure stack trace: ***
Aborted (core dumped)
</code>```

What is wrong with my installation for this faster rcnn?

I have cuda8.0 and libcudnn5_5.1.10-1+cuda8.0 is installed on Ubuntu16.04.
I have Qurdo K4200 graphic card.

答:
Now it works for me. Since libcudnn5_5.1 is for CUDA7.5. Can check in cudnn's user guide at GPU and driver requirements. So I changed to cudnnv6.0 for CUDA8.0.

Then you may face the issue of

```<code>Check failed: error == cudaSuccess (8 vs. 0)  invalid device function
</code>```

For that you will need to py-faster-rcnn/lib/fast_rcnn/config.py and change

```<code>__C.USE_GPU_NMS = True

to
__C.USE_GPU_NMS = False
</code>```

Then now it works.

Body:
I am testing Faster Rcnn. Installation is fine.
During the installation, I had one issue with cudnn5.1 and I followed the suggestion here and now installation is fine.

Now I test the demo code as

./tools/demo.py

Then I have error as

I1117 09:48:41.011925 12503 net.cpp:51] Initializing net from parameters:
name: "VGG_ILSVRC_16_layers"
state {
  phase: TEST
  level: 0
}
.
.
.
layer {
  name: "cls_prob"
  type: "Softmax"
  bottom: "cls_score"
  top: "cls_prob"
}
I1117 09:48:41.012234 12503 layer_factory.hpp:77] Creating layer input
I1117 09:48:41.012251 12503 net.cpp:84] Creating Layer input
I1117 09:48:41.012259 12503 net.cpp:380] input -> data
I1117 09:48:41.012271 12503 net.cpp:380] input -> im_info
I1117 09:48:41.328574 12503 net.cpp:122] Setting up input
I1117 09:48:41.328608 12503 net.cpp:129] Top shape: 1 3 224 224 (150528)
I1117 09:48:41.328614 12503 net.cpp:129] Top shape: 1 3 (3)
I1117 09:48:41.328618 12503 net.cpp:137] Memory required for data: 602124
I1117 09:48:41.328624 12503 layer_factory.hpp:77] Creating layer conv1_1
I1117 09:48:41.328655 12503 net.cpp:84] Creating Layer conv1_1
I1117 09:48:41.328660 12503 net.cpp:406] conv1_1 <- data
I1117 09:48:41.328670 12503 net.cpp:380] conv1_1 -> conv1_1
F1117 09:48:41.676553 12503 cudnn.hpp:128] Check failed: status == CUDNN_STATUS_SUCCESS (3 vs. 0)  CUDNN_STATUS_BAD_PARAM
*** Check failure stack trace: ***
Aborted (core dumped)

What is wrong with my installation for this faster rcnn?

I have cuda8.0 and libcudnn5_5.1.10-1+cuda8.0 is installed on Ubuntu16.04.
I have Qurdo K4200 graphic card.

Body:
Now it works for me. Since libcudnn5_5.1 is for CUDA7.5. Can check in cudnn's user guide at GPU and driver requirements. So I changed to cudnnv6.0 for CUDA8.0.

Then you may face the issue of

Check failed: error == cudaSuccess (8 vs. 0)  invalid device function

For that you will need to py-faster-rcnn/lib/fast_rcnn/config.py and change

__C.USE_GPU_NMS = True

to
__C.USE_GPU_NMS = False

Then now it works.


问:
Objectify - save order of Ref<?>-s
I have a system where I'm trying to minimize the number of Datastore writes (who wouldn't?), all the while using ancestor relations. Consider the following simplified classes:

```<code>public class Ancestor {
    @Id
    private String id;
    private String field;
    private Ref<Descendant> descendantRef;
    public Descendant getDescendant() {
        return this.descendantRef.get();
    }
    public void setDescendant(Descendant des) {
        this.descendantRef = Ref.create(des);
    }
}

public class Descendant {
    @Id
    private String id;
    private String field;
    @Parent
    private Key parent;
}
</code>```

My problem: even though I set the descendant ref, upon saving the Ancestor entity, a null is saved, but if I save the Descendant as well, Objectify complains Attempted to save a null entity.

My question: I gathered that Objectify optimizes the order of get() operations with the @Load annotation, so is there a way to make it do the same on save() operations as well, so that by the time the Ancestor is being sent to the Datastore, the Descendant ref is populated properly?

Thank you in advance for any advice!

答:
Objectify only complains that you Attempted to save a null entity if you literally pass a null value to the save() method.

This isn't an order-of-operations issue. FWIW, neither Objectify nor the underlying datastore provides any kind of referential integrity checks. It does not matter which you save first.

Title: Objectify - save order of Ref<?>-s

Body:
I have a system where I'm trying to minimize the number of Datastore writes (who wouldn't?), all the while using ancestor relations. Consider the following simplified classes:

public class Ancestor {
    @Id
    private String id;
    private String field;
    private Ref<Descendant> descendantRef;
    public Descendant getDescendant() {
        return this.descendantRef.get();
    }
    public void setDescendant(Descendant des) {
        this.descendantRef = Ref.create(des);
    }
}

public class Descendant {
    @Id
    private String id;
    private String field;
    @Parent
    private Key parent;
}

My problem: even though I set the descendant ref, upon saving the Ancestor entity, a null is saved, but if I save the Descendant as well, Objectify complains Attempted to save a null entity.

My question: I gathered that Objectify optimizes the order of get() operations with the @Load annotation, so is there a way to make it do the same on save() operations as well, so that by the time the Ancestor is being sent to the Datastore, the Descendant ref is populated properly?

Thank you in advance for any advice!


问:
Xdebug installed on EC2 Linux instance and using PhpStorm for remote debugging/development
Here is my setup:

Debugging/developing from local environment

```<code>IDE:  PhpStorm 10
url for setting up my PhpStorm debugging:  https://blog.jetbrains.com/phpstorm/2011/03/configure-php-debugging-in-phpstorm-2-0/
PHP interpreter version (local copy): 5.6
</code>```

Remote AWS ec2-linux setup:

```<code>xdebug for php56-devel

I used this SO answer for my xdebug setup:  https://stackoverflow.com/questions/37310833/installing-xdebug-on-php-5-6-amazon-linux-ami
</code>```

and this xdebug configuration in my php.ini file on the remote server (ec2-linux):

```<code>Add to /etc/php-5.6.ini the following line :
zend_extension = /usr/lib64/php/5.6/modules/xdebug.so
xdebug.remote_autostart=on
xdebug.remote_enable=on
xdebug.remote_enable=1
xdebug.remote_handler="dbgp"
xdebug.remote_host= THE.IP.ADRESS.OF.THE.COMPUTER.THAT.WILL.REMOTE.DEBUG.THE.SERVER
xdebug.remote_port=9000
xdebug.remote_mode=req
xdebug.idekey = xdebug
</code>```

but I'm still not getting any incoming connections in my PhpStorm from server or any debugging data I guess you call it.

What am I doing wrong? What did I miss?

答:
Using PHP 5.4, Amazon Linux EC2 Instance. Installed PhpStorm on my system. Configured a deployment server over SFTP to my EC2 instance. Made Xdebug to start listening for requests.

I added the following lines to /etc/php.d/xdebug.ini :

```<code>zend_extension=/usr/lib64/php/modules/xdebug.so
xdebug.remote_autostart=on
xdebug.remote_enable=on
xdebug.idekey=PhpStorm1
xdebug.remote_connect_back = On
</code>```

xdebug.remote_connect_back makes sure that it is configured to the IP of the machine that is sending the request, i.e, the system on which I'm developing.

Don't forget to restart the server. Eg,

```<code>sudo service httpd restart
</code>```

Also, you must install the Xdebug helper extension for the browser you're testing on and enable it.

Body:
Here is my setup:

Debugging/developing from local environment

IDE:  PhpStorm 10
url for setting up my PhpStorm debugging:  https://blog.jetbrains.com/phpstorm/2011/03/configure-php-debugging-in-phpstorm-2-0/
PHP interpreter version (local copy): 5.6

Remote AWS ec2-linux setup:

xdebug for php56-devel

I used this SO answer for my xdebug setup:  https://stackoverflow.com/questions/37310833/installing-xdebug-on-php-5-6-amazon-linux-ami

and this xdebug configuration in my php.ini file on the remote server (ec2-linux):

Add to /etc/php-5.6.ini the following line :
zend_extension = /usr/lib64/php/5.6/modules/xdebug.so
xdebug.remote_autostart=on
xdebug.remote_enable=on
xdebug.remote_enable=1
xdebug.remote_handler="dbgp"
xdebug.remote_host= THE.IP.ADRESS.OF.THE.COMPUTER.THAT.WILL.REMOTE.DEBUG.THE.SERVER
xdebug.remote_port=9000
xdebug.remote_mode=req
xdebug.idekey = xdebug

but I'm still not getting any incoming connections in my PhpStorm from server or any debugging data I guess you call it.

What am I doing wrong? What did I miss?

Body:
Using PHP 5.4, Amazon Linux EC2 Instance. Installed PhpStorm on my system. Configured a deployment server over SFTP to my EC2 instance. Made Xdebug to start listening for requests.

I added the following lines to /etc/php.d/xdebug.ini :

zend_extension=/usr/lib64/php/modules/xdebug.so
xdebug.remote_autostart=on
xdebug.remote_enable=on
xdebug.idekey=PhpStorm1
xdebug.remote_connect_back = On

xdebug.remote_connect_back makes sure that it is configured to the IP of the machine that is sending the request, i.e, the system on which I'm developing.

Don't forget to restart the server. Eg,

sudo service httpd restart

Also, you must install the Xdebug helper extension for the browser you're testing on and enable it.


问:
Coldfusion development server is slower than production
We've built a development server to test our web applications before moving them to deployment.

This is the configuration of the development server :

Win Server 2k8 - 32bit - Web edition

  Coldfusion 9 Entreprise

  MySQL 5

  IIS 6

This configuration is the replica of the production environment.
Unfortunately, we are faced with slow execution times.
Example: the execution time of an application, already launched on a production server, takes an average 45-60ms versus 500-600ms on development.
And when we must restart the application, which happens quite often in development, we lose a lot of time... 6500-7000ms :( (vs 1200ms)

I have tried the same application on my local server (my computer), and the response time is equivalent to the production server.

This is the JVM config of the development server:

-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005
  -server -Dsun.io.useCanonCaches=false -XX:MaxPermSize=192m -XX:+UseParallelGC -Xbatch -Dcoldfusion.rootDir={application.home}/../
  -Dcoldfusion.libPath={application.home}/../lib

The source files are hosted on a NAS; we had to create a user on the NAS, exactly the same as the admin user of the server. And we had to configure Coldfusion and IIS application pools to run as the created user to address access rights. But I don't think this is the problem because I did some tests, putting the files on a disk local to server, and the execution time remains the same.

I don't know where to look...

** The server monitor is shut down **

Someone would have any advice?

Thanks.

答: Answer seems to be pretty usual: try FusionReactor to find out the bottleneck. It is really hard to "guess" the reasons with this information... </p>


问:
ENI's registered to Elastic Load Balancer - AWS
When launching an Elastic Load Balancer in AWS, I happened to notice two ENI's get created that reference the ELB. The private IP's (assigned through the VPC subnet) for both of these ENI's appears in the httpd access log on my load balanced back-end instance during periodic health checks.

My questions are:

Do these ENI's belong to the ELB (or abstracted ELB instances)?

Are they solely for health check purposes?

Also, under what circumstance would more than two ENI's be created or do only two ENI's appear no matter the number of instances being monitored (I experimented with a single and dual instances and in both cases, only two ENI's were generated)?

答: We were experimenting with ELB's a bit and it may be that the number of ENIs depends on how many zones are being used by the ELB</p>


问:
Is there anyway to run iOS or Android code on a desktop application?
I would like to use an iOS or Android SDK (e.g. DJI Drone SDK), but instead of running it on a mobile device to connect to the hardware, is there a way to build a desktop application (e.g. Electron based) and be able to run their SDK to interact with the hardware?

答:
It is called DJI Assistant 2 but you still need your controller:
https://developer.dji.com/mobile-sdk/documentation/application-development-workflow/workflow-testing.html</p>


问:
Signed APK file not working while debug APK works
So I just finally finished my first app and wanted to put it in the google store and for an unknown reason it always says "You must import a valid .apk file.".

I really don't know what I'm doing, I looked everywhere and kinda understood that i had to build a signed APK, which I did multiple times and none of them works.

Plus, important detail I just noticed: The signed apk doesn't work while the debug apk works with my phone?

And when I build a signed apk it says this as an error in the Gradle Console :

"Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\Users\Lois\AndroidStudioProjects\iobner\app\src\main\java\com\lf\gt\knowy\suggestions.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details."

Can anyone help me? What do I have to do to make a working signed APK? And why does it not work while the debug works?! I have no experiences in this and learnt by myself to do the whole app but can't seem to find the problem by myself this time... Thank you!

答:
If you want to debug your release apk , add debuggable option in your manifest or gradle.

If you want to modify your AndroidManifest.xml

```<code> <application
            android:debuggable="true"
            android:name=".YourApplication"
            android:allowBackup="true"
            android:icon="@mipmap/your_icon"
            android:label="@string/app_name"
            android:theme="@style/AppTheme"/>
</code>```

Update

Signing APK Guide:

https://developer.android.com/studio/publish/app-signing.html

Body:
If you want to debug your release apk , add debuggable option in your manifest or gradle.

If you want to modify your AndroidManifest.xml

 <application
            android:debuggable="true"
            android:name=".YourApplication"
            android:allowBackup="true"
            android:icon="@mipmap/your_icon"
            android:label="@string/app_name"
            android:theme="@style/AppTheme"/>

Update

Signing APK Guide:

https://developer.android.com/studio/publish/app-signing.html


问:
Ember JS best way to show a full screen loading screen button press
I'm new with Ember and I would like to show a full screen overlay when a user presses a "get stuff from the server" button.

What is the best way to achieve this?

Does Ember already provide something built-in? Or is it that the only way is to have a piece of HTML in one of my templates, to show/hide it when the promise where I make the AJAX call returns?

答:
You could use ember-modal-dialog to create a loading screen component that gets rendered when you're waiting for your ajax request.

For example:

```<code>// view.js
showLoadingScreen: true

// view.html
{{#if showLoadingScreen}}
  {{loading-screen}}
{{/if}}

// loading-screen.html
{{#ember-modal-dialog}}
  <div class="loader-full-screen-class"></div>
{{/modal-dialog}}
</code>```

The advantage of the component/ember-modal-dialog is that this pattern is usually implemented as a modal, and this library is the standard in ember. The component then allows you to put it anywhere you need it to be.

Body:
You could use ember-modal-dialog to create a loading screen component that gets rendered when you're waiting for your ajax request.

For example:

// view.js
showLoadingScreen: true

// view.html
{{#if showLoadingScreen}}
  {{loading-screen}}
{{/if}}

// loading-screen.html
{{#ember-modal-dialog}}
  <div class="loader-full-screen-class"></div>
{{/modal-dialog}}

The advantage of the component/ember-modal-dialog is that this pattern is usually implemented as a modal, and this library is the standard in ember. The component then allows you to put it anywhere you need it to be.


问:
clang - error: non-ASM statement in naked function is not supported
```<code>$ clang --version
clang version 5.0.0 (tags/RELEASE_500/final)
</code>```

.

```<code>CC ../../py/nlrthumb.c
../../py/nlrthumb.c:79:5: error: non-ASM statement in naked function is not supported
    return 0; // needed to silence compiler warning
</code>```

Why doesn't Clang support non-ASM statement in naked function?

This works fine on gcc.

The mailing list explains it as

Naked functions don't have prologues or epilogues, so doing
  codegen for anything other than inline assembly would be completely
  hit or miss.

so then how can gcc do it?

答:
I should have written this as an answer instead of a comment.  The question was:

Why doesn't Clang support non-ASM statement in naked function?  This works fine on gcc.

The answer is that this doesn't work fine in gcc.  Quoting from the gcc docs for the naked attribute:

Only basic asm statements can safely be included in naked functions. While using extended asm or a mixture of basic asm and C code may appear to work, they cannot be depended upon to work reliably and are not supported.

If there is a less ambiguous way to phrase this, I couldn't come up with it.

Note that while the specific link above is for ARM (which is what I'm guessing the OP is using), I believe the same text applies to all platforms that support naked.

Body:
$ clang --version
clang version 5.0.0 (tags/RELEASE_500/final)

.

CC ../../py/nlrthumb.c
../../py/nlrthumb.c:79:5: error: non-ASM statement in naked function is not supported
    return 0; // needed to silence compiler warning

Why doesn't Clang support non-ASM statement in naked function?

This works fine on gcc.

The mailing list explains it as

Naked functions don't have prologues or epilogues, so doing
  codegen for anything other than inline assembly would be completely
  hit or miss.

so then how can gcc do it?


问:
Open Source (Free) ASP.NET Site Seacrch
Does anybody know of an easy to implement site search engine for asp.net? The less complicated the better.

Probably just needs a crawler and backend to store results. Some sort of API to get the search results back would be handy but I can get it straight from the DB as well.

答: If you want to search in database behind site, Full Text Search can also help.</p>

OwnerDisplayName: William

Title: Open Source (Free) ASP.NET Site Seacrch

OwnerDisplayName: dmajkic


问:
Google visualization: annotated time line with wmode="opaque" doesn't recognize mouse scroll in most browser
As stated in the title, I am now trying to create a chart using Google visualization: annotated time line. It's very easy to use and the documentation is fairly easy to understand as well. You can find the documentation here.

I run into a problem about the wmode of the chart which is a flash object.
The default value of the chart's wmode is "window" and it will always overlay all HTML objects in the same page. That is very annoying, because even the jquery block() method doesn't work on it.

When I change the chart's wmode into "opaque" or "transparent" the chart will not overlay HTML objects with higher z-index, but it doesn't recognize the mouse scroll event. It still catch the mouse click event though.

I have tried it in the following browser:

Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12 (.NET CLR 3.5.30729)

Opera/9.80 (Windows NT 5.2; U; en) Presto/2.7.62 Version/11.00

Safari 4.0.5 (531.22.7)

IE 7.0.5730.13

Only the IE can catch the mouse scroll even, the others couldn't recognize it.
Is anyone experiencing the same problem as me? or is anyone not experiencing that problem?

I've been looking for the solution over the internet and no solutions is working for me.
Any solutions (or work around) would be appreciated.

Thanks a lot.

答:
Since no one seems to have the solution, I decided to answer my own question in case someone run into the same problem as me, :)
Well I actually don't know the solution for it yet, but I found a work around. :p

First, I set the wmode of the chart into 'opaque'.
Then, following the advice from jpea, I used the javascript mouse wheel event listener to handle the mouse wheel event in the div element where the chart resides.
The delta value obtained from the event is then used to change the chart's visible range using setVisibleChartRange() method.

See here to find out how to use the mouse wheel event in different browsers.

I hope this answer is useful, :D

Note: If you sure the chart would not be overlapped by any objects by any chance, then you don't need to do anything about the wmode.


问:
How to set updated value in textfield
I have set a value in text field. If I change the value in textfield how to set updated value in text field in javafx?</p>

答:
You can do it like this:

```<code>TextField notification = new TextField ();
notification.setText("Label");
</code>```

By calling setText method of textfield object.

Title: How to set updated value in textfield

Body:
You can do it like this:

TextField notification = new TextField ();
notification.setText("Label");

By calling setText method of textfield object.


问:
Jenkins doesn't seem to be cloning GitHub repo -- no files found on npm install
My Jenkins setup is successfully triggering on push from the GitHub. It runs this Jenkinsfile:

```<code>node {
  sh 'npm install'
}
</code>```

Which spits out this error:

npm WARN saveError ENOENT: no such file or directory, open 'C:\Program Files (x86)\Jenkins\workspace\PROJECT_FOLDER_NAME\package.json'

Looking at that folder, there are no contents. While I assumed that the cloned repository would've been there.

In the configuration within Jenkins, the Branch Source is set up and is using the credentials.

Am I missing a step? Do I have to explicitly tell it to clone within the Jenkinsfile?

Please let me know if I can provide any other information.

答:
Yes - you'll need to checkout the repository.</p>

```<code>#!groovy
node {
    stage "Checkout Repo"
    checkout scm

    stage "Install Dependencies"
    sh 'npm install'
}
</code>```

Body:
My Jenkins setup is successfully triggering on push from the GitHub. It runs this Jenkinsfile:

node {
  sh 'npm install'
}

Which spits out this error:

npm WARN saveError ENOENT: no such file or directory, open 'C:\Program Files (x86)\Jenkins\workspace\PROJECT_FOLDER_NAME\package.json'

Looking at that folder, there are no contents. While I assumed that the cloned repository would've been there.

In the configuration within Jenkins, the Branch Source is set up and is using the credentials.

Am I missing a step? Do I have to explicitly tell it to clone within the Jenkinsfile?

Please let me know if I can provide any other information.

Body:
Yes - you'll need to checkout the repository.

#!groovy
node {
    stage "Checkout Repo"
    checkout scm

    stage "Install Dependencies"
    sh 'npm install'
}


问:
What are extensions need to run cakePHP
Im new to cakePHP. With it upload function not working now. I got already developed project to work. What are PHP extensions I need to enable for cakePHP ? </p>

答:
According to their documentation for 3.x:

mbstring

intl

simplexml

However if you are unable to upload I would also make sure you actually have permissions to upload into whatever folder it is you are trying to put stuff.

Title: What are extensions need to run cakePHP


问:
Styling a Button in javascript
I have a button which is generated in this list. I want to style the button to be a bootstrap button. How would I go about doing so? I have posted my javascript below. (This cannot be done in HTML because the button is generated after another JS method executes.) I would also like to make the JS methods re-usable (where I don't need to make 4 methods to do the same thing.) If anyone could help me out it would be awesome!!

// Create a "close" button and append it to each list item
var myNodelist = document.getElementsByTagName("LI");
var i;
for (i = 0; i < myNodelist.length; i++) {
  var span = document.createElement("SPAN");
  var txt = document.createTextNode("\u00D7");
  span.className = "close";
  span.appendChild(txt);
  myNodelist[i].appendChild(span);
}

// Click on a close button to hide the current list item
var close = document.getElementsByClassName("close");
var i;
for (i = 0; i < close.length; i++) {
  close[i].onclick = function() {
    var div = this.parentElement;
    div.style.display = "none";
  }
}

// Create a new list item when clicking on the "Add" button
function newElement1() {
  var li = document.createElement("div");
  var inputValue = document.getElementById("myInput1").value;
  var inputValueB = document.getElementById("myInput1B").value;

  var t = document.createTextNode(inputValue);
  var space = document.createTextNode("             ");
  var tB = document.createTextNode(inputValueB);

  li.appendChild(tB);
  li.appendChild(space);
  li.appendChild(t);

  if (inputValue === '') {
    alert("You must input an item!");
  } else {
    document.getElementById("myUL1").appendChild(li);
  }
  document.getElementById("myInput1").value = "";
  document.getElementById("myInput1B").value = ""

  // here is the button logic
  var btn = document.createElement("button");

  var txt = document.createTextNode("Bought");
  btn.appendChild(txt);
  li.appendChild(btn);

  var span = document.createElement("SPAN");
  var txt = document.createTextNode("\u00D7");
  span.className = "close";
  span.appendChild(txt);
  li.appendChild(span);

  for (i = 0; i < close.length; i++) {
    close[i].onclick = function() {
      var div = this.parentElement;
      div.style.display = "none";
    }
  }
}```
<pre class="snippet-code-css lang-css prettyprint-override"><code>/* Create three equal columns that floats next to each other */

.column {
  float: left;
  width: 25%;
  padding: 10px;
  height: 300px;
  /* Should be removed. Only for demonstration */
}

/* Clear floats after the columns */

.row:after {
  content: "";
  display: table;
  clear: both;
}

.logo {
  right: 90%;
}

/* Remove margins and padding from the list */

ul {
  margin: 0;
  padding: 0;
}

/* Style the list items */

ul li {
  cursor: pointer;
  position: relative;
  padding: 12px 8px 12px 40px;
  background: rgba(0, 143, 149, 0.6);
  font-size: 18px;
  font-family: "Avenir W01", "futura", "Lucida grande", sans-serif;
  transition: 0.2s;
  /* make the list items unselectable */
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

ul>div {
  cursor: pointer;
  position: relative;
  padding: 12px 8px 12px 40px;
  background: rgba(0, 143, 149, 0.59);
  font-size: 18px;
  font-family: "Avenir W01", "futura", "Lucida grande", sans-serif;
  transition: 0.2s;
  /* make the list items unselectable */
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* Style the close button */

.close {
  position: absolute;
  right: 0;
  top: 0;
  padding: 12px 16px 12px 16px;
}

.close:hover {
  background-color: rgba(233, 176, 0, 0.85);
  color: black;
  padding: 12px 16px 12px 16px;
}

/* Style the header */

.header1 {
  background-color: rgba(0, 143, 149, 0.76);
  padding: 30px 40px;
  color: white;
  text-align: center;
}

.header2 {
  background-color: rgba(233, 176, 0, 0.85);
  padding: 30px 40px;
  color: white;
  text-align: center;
}

.header3 {
  background-color: rgba(226, 78, 66, 0.76);
  padding: 30px 40px;
  color: white;
  text-align: center;
}

/* Clear floats after the header */

.header1:after,
.header2:after,
.header3:after {
  content: "";
  display: table;
  clear: both;
}

/* Style the input */

input {
  border: none;
  width: 75%;
  padding: 10px;
  float: left;
  font-size: 16px;
}

/* Style the "Add" button */

.addBtn {
  padding: 10px;
  width: 75%;
  background: rgb(254, 166, 128);
  color: #fff1d9;
  float: left;
  text-align: center;
  font-size: 16px;
  font-family: "Avenir W01", "futura", "Lucida grande", sans-serif;
  cursor: pointer;
  transition: 0.3s;
}

.addBtn:hover {
  background-color: rgb(228, 148, 122);
}

/********* USER PROFILE ********/

#myInput {
  border-box: box-sizing;
  background-position: 14px 12px;
  background-repeat: no-repeat;
  font-size: 16px;
  font-family: "Avenir W01", "futura", "Lucida grande", sans-serif;
  padding: 14px 20px 12px 45px;
  border: none;
}

.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-content {
  display: none;
  position: absolute;
  background-color: rgba(254, 166, 128, 0.68);
  min-width: 230px;
  overflow: auto;
  box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
  z-index: 1;
  font-family: "Avenir W01", "futura", "Lucida grande", sans-serif;
}

.dropdown-content a {
  color: black;
  padding: 12px 16px;
  text-decoration: none;
  display: block;
}

.dropdown a:hover {
  background-color: rgba(235, 110, 128, 0.65)
}

.show {
  display: block;
}

/* The Modal (background) */

.modal {
  display: none;
  /* Hidden by default */
  position: fixed;
  /* Stay in place */
  z-index: 1;
  /* Sit on top */
  padding-top: 100px;
  /* Location of the box */
  left: 0;
  top: 0;
  width: 100%;
  /* Full width */
  height: 100%;
  /* Full height */
  overflow: auto;
  /* Enable scroll if needed */
  background-color: rgb(0, 0, 0);
  /* Fallback color */
  background-color: rgba(0, 0, 0, 0.4);
  /* Black w/ opacity */
}</code>```

Amir's List

      <input type="text" id="myInput1" placeholder="Item...">
      <input type="text" id="myInput1B" placeholder="Brand/Quantity...">
      Add

```

答:
To make the function generic you can do something like this:

```<code>function newElement(myInput, myInputB, myUL) {
                var li = document.createElement("div");
                var inputValue = document.getElementById(myInput).value;
                var inputValueB = document.getElementById(myInputB).value;

                var t = document.createTextNode(inputValue);
                var space = document.createTextNode("             ");
                var tB = document.createTextNode(inputValueB);

                li.appendChild(tB);
                li.appendChild(space);
                li.appendChild(t);

                if (inputValue === '') {
                    alert("You must input an item!");
                } else {
                    document.getElementById(myUL).appendChild(li);
                }
                document.getElementById(myInput).value = "";
                document.getElementById(myInputB).value = ""

                // here is the button logic
                var btn = document.createElement("button");
                // When the user clicks the button, open the modal
                btn.onclick = function () {
                    modal.style.display = "block";
                }
                var txt = document.createTextNode("Bought");
                btn.classList.add('btn');
                btn.classList.add('btn-primary');
                btn.appendChild(txt);
                li.appendChild(btn);

                var span = document.createElement("SPAN");
                var txt = document.createTextNode("\u00D7");
                span.className = "close";
                span.appendChild(txt);
                li.appendChild(span);

                for (i = 0; i < close.length; i++) {
                    close[i].onclick = function () {
                        var div = this.parentElement;
                        div.style.display = "none";
                    }
                }
            }
</code>```

Plus I added 2 classList.add() To your btn to give you that Bootstrap button

Then to call on click:

```<code>   <div class="column">
                <div id="myDIV1" class="header1">
                    <h2 style="font-size: 250%; color:#fff1d9; font-family:Avenir W01, futura, Lucida grande, sans-serif !important;">Amir's List</h2>
                    <input type="text" id="myInput1" placeholder="Item...">
                    <input type="text" id="myInput1B" placeholder="Brand/Quantity...">
                    <span onclick="newElement('myInput1', 'myInput1B', 'myUL1')" class="addBtn">Add</span>
                </div>
                <ul id="myUL1">
                </ul>
            </div>
</code>```

Change the variables in onclick="newElement()" to the appropriate variable names.

Title: Styling a Button in javascript

Body:
I have a button which is generated in this list. I want to style the button to be a bootstrap button. How would I go about doing so? I have posted my javascript below. (This cannot be done in HTML because the button is generated after another JS method executes.) I would also like to make the JS methods re-usable (where I don't need to make 4 methods to do the same thing.) If anyone could help me out it would be awesome!!

// Create a "close" button and append it to each list item
var myNodelist = document.getElementsByTagName("LI");
var i;
for (i = 0; i < myNodelist.length; i++) {
  var span = document.createElement("SPAN");
  var txt = document.createTextNode("\u00D7");
  span.className = "close";
  span.appendChild(txt);
  myNodelist[i].appendChild(span);
}

// Click on a close button to hide the current list item
var close = document.getElementsByClassName("close");
var i;
for (i = 0; i < close.length; i++) {
  close[i].onclick = function() {
    var div = this.parentElement;
    div.style.display = "none";
  }
}

// Create a new list item when clicking on the "Add" button
function newElement1() {
  var li = document.createElement("div");
  var inputValue = document.getElementById("myInput1").value;
  var inputValueB = document.getElementById("myInput1B").value;

  var t = document.createTextNode(inputValue);
  var space = document.createTextNode("             ");
  var tB = document.createTextNode(inputValueB);

  li.appendChild(tB);
  li.appendChild(space);
  li.appendChild(t);

  if (inputValue === '') {
    alert("You must input an item!");
  } else {
    document.getElementById("myUL1").appendChild(li);
  }
  document.getElementById("myInput1").value = "";
  document.getElementById("myInput1B").value = ""

  // here is the button logic
  var btn = document.createElement("button");

  var txt = document.createTextNode("Bought");
  btn.appendChild(txt);
  li.appendChild(btn);

  var span = document.createElement("SPAN");
  var txt = document.createTextNode("\u00D7");
  span.className = "close";
  span.appendChild(txt);
  li.appendChild(span);

  for (i = 0; i < close.length; i++) {
    close[i].onclick = function() {
      var div = this.parentElement;
      div.style.display = "none";
    }
  }
}

/* Create three equal columns that floats next to each other */

.column {
  float: left;
  width: 25%;
  padding: 10px;
  height: 300px;
  /* Should be removed. Only for demonstration */
}

/* Clear floats after the columns */

.row:after {
  content: "";
  display: table;
  clear: both;
}

.logo {
  right: 90%;
}

/* Remove margins and padding from the list */

ul {
  margin: 0;
  padding: 0;
}

/* Style the list items */

ul li {
  cursor: pointer;
  position: relative;
  padding: 12px 8px 12px 40px;
  background: rgba(0, 143, 149, 0.6);
  font-size: 18px;
  font-family: "Avenir W01", "futura", "Lucida grande", sans-serif;
  transition: 0.2s;
  /* make the list items unselectable */
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

ul>div {
  cursor: pointer;
  position: relative;
  padding: 12px 8px 12px 40px;
  background: rgba(0, 143, 149, 0.59);
  font-size: 18px;
  font-family: "Avenir W01", "futura", "Lucida grande", sans-serif;
  transition: 0.2s;
  /* make the list items unselectable */
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* Style the close button */

.close {
  position: absolute;
  right: 0;
  top: 0;
  padding: 12px 16px 12px 16px;
}

.close:hover {
  background-color: rgba(233, 176, 0, 0.85);
  color: black;
  padding: 12px 16px 12px 16px;
}

/* Style the header */

.header1 {
  background-color: rgba(0, 143, 149, 0.76);
  padding: 30px 40px;
  color: white;
  text-align: center;
}

.header2 {
  background-color: rgba(233, 176, 0, 0.85);
  padding: 30px 40px;
  color: white;
  text-align: center;
}

.header3 {
  background-color: rgba(226, 78, 66, 0.76);
  padding: 30px 40px;
  color: white;
  text-align: center;
}

/* Clear floats after the header */

.header1:after,
.header2:after,
.header3:after {
  content: "";
  display: table;
  clear: both;
}

/* Style the input */

input {
  border: none;
  width: 75%;
  padding: 10px;
  float: left;
  font-size: 16px;
}

/* Style the "Add" button */

.addBtn {
  padding: 10px;
  width: 75%;
  background: rgb(254, 166, 128);
  color: #fff1d9;
  float: left;
  text-align: center;
  font-size: 16px;
  font-family: "Avenir W01", "futura", "Lucida grande", sans-serif;
  cursor: pointer;
  transition: 0.3s;
}

.addBtn:hover {
  background-color: rgb(228, 148, 122);
}

/********* USER PROFILE ********/

#myInput {
  border-box: box-sizing;
  background-position: 14px 12px;
  background-repeat: no-repeat;
  font-size: 16px;
  font-family: "Avenir W01", "futura", "Lucida grande", sans-serif;
  padding: 14px 20px 12px 45px;
  border: none;
}

.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-content {
  display: none;
  position: absolute;
  background-color: rgba(254, 166, 128, 0.68);
  min-width: 230px;
  overflow: auto;
  box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
  z-index: 1;
  font-family: "Avenir W01", "futura", "Lucida grande", sans-serif;
}

.dropdown-content a {
  color: black;
  padding: 12px 16px;
  text-decoration: none;
  display: block;
}

.dropdown a:hover {
  background-color: rgba(235, 110, 128, 0.65)
}

.show {
  display: block;
}

/* The Modal (background) */

.modal {
  display: none;
  /* Hidden by default */
  position: fixed;
  /* Stay in place */
  z-index: 1;
  /* Sit on top */
  padding-top: 100px;
  /* Location of the box */
  left: 0;
  top: 0;
  width: 100%;
  /* Full width */
  height: 100%;
  /* Full height */
  overflow: auto;
  /* Enable scroll if needed */
  background-color: rgb(0, 0, 0);
  /* Fallback color */
  background-color: rgba(0, 0, 0, 0.4);
  /* Black w/ opacity */
}

Amir's List

      <input type="text" id="myInput1" placeholder="Item...">
      <input type="text" id="myInput1B" placeholder="Brand/Quantity...">
      Add

Body:
To make the function generic you can do something like this:

function newElement(myInput, myInputB, myUL) {
                var li = document.createElement("div");
                var inputValue = document.getElementById(myInput).value;
                var inputValueB = document.getElementById(myInputB).value;

                var t = document.createTextNode(inputValue);
                var space = document.createTextNode("             ");
                var tB = document.createTextNode(inputValueB);

                li.appendChild(tB);
                li.appendChild(space);
                li.appendChild(t);

                if (inputValue === '') {
                    alert("You must input an item!");
                } else {
                    document.getElementById(myUL).appendChild(li);
                }
                document.getElementById(myInput).value = "";
                document.getElementById(myInputB).value = ""

                // here is the button logic
                var btn = document.createElement("button");
                // When the user clicks the button, open the modal
                btn.onclick = function () {
                    modal.style.display = "block";
                }
                var txt = document.createTextNode("Bought");
                btn.classList.add('btn');
                btn.classList.add('btn-primary');
                btn.appendChild(txt);
                li.appendChild(btn);

                var span = document.createElement("SPAN");
                var txt = document.createTextNode("\u00D7");
                span.className = "close";
                span.appendChild(txt);
                li.appendChild(span);

                for (i = 0; i < close.length; i++) {
                    close[i].onclick = function () {
                        var div = this.parentElement;
                        div.style.display = "none";
                    }
                }
            }

Plus I added 2 classList.add() To your btn to give you that Bootstrap button

Then to call on click:

   <div class="column">
                <div id="myDIV1" class="header1">
                    <h2 style="font-size: 250%; color:#fff1d9; font-family:Avenir W01, futura, Lucida grande, sans-serif !important;">Amir's List</h2>
                    <input type="text" id="myInput1" placeholder="Item...">
                    <input type="text" id="myInput1B" placeholder="Brand/Quantity...">
                    <span onclick="newElement('myInput1', 'myInput1B', 'myUL1')" class="addBtn">Add</span>
                </div>
                <ul id="myUL1">
                </ul>
            </div>

Change the variables in onclick="newElement()" to the appropriate variable names.


问:
How to take the updated data backup?
I have a database at mysql and the same with on the device, i want to synchronize the updated data once in a period on my device, how can i achieve this ? Please advise.
I got one worst case solution that is writing triggers for each table and update the details to another table, but i have 20 tables i need to write 4 trigger operations on each table, so overall 80 triggers i need to write, can anyone tell me the solution.Please help </p>

答: Look at the mysqldump command (It's not an SQL command, it's a command-line tool).</p>

Title: How to take the updated data backup?


问:
Rails calculate and display average
I'm trying to average scores within a particularly category. I have a table that contains a list of directors, movies, genres, ratings and scores. When the user clicks on a movie I'd like them to be able to see the average score for all other movies in that genre.

I think that I have to use the average method in conjunction with a condition. That said I haven't been able to find any useful documentation online regarding this specific topic. If someone could point me in the direction of a guide or article that explains how to calculate averages with conditions and display them in a view, I would greatly appreciate it!

答:
How about you move SQL raw query to a database view:

```<code># movies_view
SELECT m.id, AVG(m.score) avg_score, c.category_id
FROM movies m
JOIN category c
ON m.category_id
</code>```

So you will need to query from the MovieView

```<code>MovieView.find(:movie_id).avg_score
</code>```

Title: Rails calculate and display average

Body:
How about you move SQL raw query to a database view:

# movies_view
SELECT m.id, AVG(m.score) avg_score, c.category_id
FROM movies m
JOIN category c
ON m.category_id

So you will need to query from the MovieView

MovieView.find(:movie_id).avg_score


问:
Jest in Meteor?
I want to run Jest test cases for snapshot testing React components in my Meteor client app.

Install packages:

npm i --save-dev jest react-test-renderer

And I simply write something like:

```<code>import React from 'react';
import renderer from 'react-test-renderer';
import { expect } from 'meteor/practicalmeteor:chai';
import CoolComponent from '../some/where';

if (Meteor.isClient) {
  it('renders correctly', () => {
    const tree = renderer.create(<CoolComponent />).toJSON();
    expect(tree).toMatchSnapshot();
  });
}
</code>```

Run the test case:

meteor test --driver-package practicalmeteor:mocha

And get this error:

TypeError: expect(...).toMatchSnapshot is not a function

I'm not sure how to pick up the jest's version of expect to use the toMatchSnapshot method

Please help

答:
You can't run Jest tests with the practicalmeteor:mocha driver package. That package runs your tests with Mocha (and Mocha doesn't recognize .toMatchSnapshot().

I've had nominal success running Jest tests by installing the Jest cli...

npm i -g jest

...and running the tests from the command line without going through Meteor.

Of course, you will need to mock Meteor's dependencies. For this, I used jest-meteor-stubs, but stubbing everything by hand proved to be inhibitive.

Until someone writes an official Jest driver package for Meteor, you might be better off sticking to Mocha.

Title: Jest in Meteor?

Body:
I want to run Jest test cases for snapshot testing React components in my Meteor client app.

Install packages:

npm i --save-dev jest react-test-renderer

And I simply write something like:

import React from 'react';
import renderer from 'react-test-renderer';
import { expect } from 'meteor/practicalmeteor:chai';
import CoolComponent from '../some/where';

if (Meteor.isClient) {
  it('renders correctly', () => {
    const tree = renderer.create(<CoolComponent />).toJSON();
    expect(tree).toMatchSnapshot();
  });
}

Run the test case:

meteor test --driver-package practicalmeteor:mocha

And get this error:

TypeError: expect(...).toMatchSnapshot is not a function

I'm not sure how to pick up the jest's version of expect to use the toMatchSnapshot method

Please help


问:
scan doesn't work with rtl8723 driver for realtek module
After cloning and compiling rtl8723be driver, I get rtl8723.ko. But upon installing it, along with its dependency cfg80211, wpa_cli doesn't scan the device.</p>

答:
Adding the solution which I did face and solved.

```<code>modprobe cfg80211
insmod 8723be.ko
</code>```

Create udev rule to create network interface driver expects, wlan0

```<code>vi /etc/udev/rules.d/80-net-setup-link.rules
 "SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="xx:xx:xx:xx:xx:xx", ATTR{type}=="1", KERNEL=="sit*", NAME="wlan0""
</code>```

Now reload the rule and start wpa_supplicant daemo

```<code>udevadm control --reload-rules
iwconfig
//should show wlan0 inerface
# wpa_supplicant -Dwext -c/etc/wpa_supplicant.conf -d -B -i wlan0
</code>```

Let's scan now for available APs around

```<code>wpa_cli
>scan
>scan_result
</code>```

Things will start working now.
To scan and add AP, refer https://gist.github.com/buhman/7162560, explaining very nicely.

Body:
Adding the solution which I did face and solved.

modprobe cfg80211
insmod 8723be.ko

Create udev rule to create network interface driver expects, wlan0

vi /etc/udev/rules.d/80-net-setup-link.rules
 "SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="xx:xx:xx:xx:xx:xx", ATTR{type}=="1", KERNEL=="sit*", NAME="wlan0""

Now reload the rule and start wpa_supplicant daemo

udevadm control --reload-rules
iwconfig
//should show wlan0 inerface
# wpa_supplicant -Dwext -c/etc/wpa_supplicant.conf -d -B -i wlan0

Let's scan now for available APs around

wpa_cli
>scan
>scan_result

Things will start working now.
To scan and add AP, refer https://gist.github.com/buhman/7162560, explaining very nicely.


问:
What is external linkage and internal linkage?
I want to understand the external linkage and internal linkage and their difference.

I also want to know the meaning of

const variables internally link by default unless otherwise declared as extern.

答:
Linkage determines whether identifiers that have identical names refer to the same object, function, or other entity, even if those identifiers appear in different translation units. The linkage of an identifier depends on how it was declared.
There are three types of linkages:

Internal linkage : identifiers can only be seen within a translation unit.

External linkage : identifiers can be seen (and referred to) in other translation units.

No linkage : identifiers can only be seen in the scope in which they are defined.
Linkage does not affect scoping

C++ only : You can also have linkage between C++ and non-C++ code fragments, which is called language linkage.

Source :IBM Program Linkage


答: Create a program in your favorite programming language and let it copy the data, the program is started via cron job every X period.</p>

Title: How to take the updated data backup?

Body:
I have a database at mysql and the same with on the device, i want to synchronize the updated data once in a period on my device, how can i achieve this ? Please advise.
I got one worst case solution that is writing triggers for each table and update the details to another table, but i have 20 tables i need to write 4 trigger operations on each table, so overall 80 triggers i need to write, can anyone tell me the solution.Please help


问:
How to remove the category from the page url?
Is there any way to remove the "Project" term from the below permalink/url?
www.fourmanteam.com/project/camping

I want the url in below order.
www.fourmanteam.com/camping

I tried the custom structure. But, no help.

Thanks.

答: You may want to consider using a Redirection plugin (or other similar). It won't change the permalink itself, but at least it will allow you to have a shorter link to the category page.</p>


问:
make two side-by-side divs of equal heights
This is my final layout

I want to keep the left column height same as the right one. I am simplifying my html so would be easy for you.

```<code><div id="graphsWindow" style="height:100%; ">
<div class="table" style="height: 100%">
    <div class="row" style="margin-left:0px;margin-top:0px; padding-top:0px; padding-bottom:0px; height:100%;">

   <div style="border:groove; margin-left:10px; margin-bottom:0px; padding-bottom:0px; margin-right:2px; border:groove; height:100%" class="col-md-2">
   </div>
   <div class="col-md-9" style="padding-bottom:0px; padding-top:0px; margin-top:0px; margin-left:15px; height:100%">
   </div>

</div>
</div>
</code>```

The div with class col-md-2 contains the picture, the prev/next buttons and the list with check boxes

The div with class col-md-9 contains the graphs and the buttons, labels at the bottom.

I have not specified a fixed height any where inside. How can I make the two divs of equal height?

UPDATES

Default Popup Window

Maximized Window

答:
I use of jquery, i hope help you:</p>

```<code>$(document).ready(function(){
  var col9Height = $('.col-md-9').height();
  $('.col-md-2').height(col9Height);
})
</code>```

Body:
This is my final layout

I want to keep the left column height same as the right one. I am simplifying my html so would be easy for you.

The div with class col-md-2 contains the picture, the prev/next buttons and the list with check boxes

The div with class col-md-9 contains the graphs and the buttons, labels at the bottom.

I have not specified a fixed height any where inside. How can I make the two divs of equal height?

UPDATES

Default Popup Window

Maximized Window

Body:
I use of jquery, i hope help you:

$(document).ready(function(){
  var col9Height = $('.col-md-9').height();
  $('.col-md-2').height(col9Height);
})


问:
"JACC Policy Provider:Failed Permission Check" on security constrained login page that has no authorization constraint
I am getting this outcome from the netbeans glassfish output window when a request is made from the internet to a login page:

INFO: JACC Policy Provider:Failed Permission Check: context (" WebApplication2/WebApplication2 ") , permission (" ("javax.security.jacc.WebUserDataPermission" "/login.xhtml" "GET") ")

This does not happen when a request is made from the LAN or localhost and the page is served over HTTPS as required.

I am trying to configure a login page to use transport layer security to protect user passwords during the login request. I am hoping this can be achieved using only the Faces Servlet with declarative security in the web.xml deployment descriptor.

I am using form-based authentication with a non j_security_check custom Facelet form for programmatic login through request.login method. The login form has the following security constraint in the web.xml:

 <security-constraint>
    <display-name>secure login</display-name>
    <web-resource-collection>
        <web-resource-name>login.xhtml</web-resource-name>
        <description/>
        <url-pattern>/login.xhtml</url-pattern>
    </web-resource-collection>
    <user-data-constraint>
        <description/>
        <transport-guarantee>CONFIDENTIAL</transport-guarantee>
    </user-data-constraint>
</security-constraint>
```

There is not an authorization constraint element as this form is obviously intended for unauthenticated users. The only reason there is a security constraint at all is so that the  sub element can be set to CONFIDENTIAL assuring a secure connection.

The Java EE 6 tutorial states here that:

If there is no authorization constraint, the container must accept the request without requiring user authentication

and

The user data constraint is handy to use in conjunction with basic and form-based user authentication. When the login authentication method is set to BASIC or FORM, passwords are not protected, meaning that passwords sent between a client and a server on an unprotected session can be viewed and intercepted by third parties. Using a user data constraint with the user authentication mechanism can alleviate this concern. Configuring a user authentication mechanism is described in Specifying an Authentication Mechanism in the Deployment Descriptor.

Why is JACC doing a permission check when no such check should be required to access this resource? Why does it fail only from the internet and not on the LAN?

答: Simply clean the project and restart the server !! This worked fine for me !! Sometimes there would be a certain files that would be cought up in cache!! These files may cause this error!! So on cleaning the project the error will get fixed!!</p>

Body:
I am getting this outcome from the netbeans glassfish output window when a request is made from the internet to a login page:

INFO: JACC Policy Provider:Failed Permission Check: context (" WebApplication2/WebApplication2 ") , permission (" ("javax.security.jacc.WebUserDataPermission" "/login.xhtml" "GET") ")

This does not happen when a request is made from the LAN or localhost and the page is served over HTTPS as required.

I am trying to configure a login page to use transport layer security to protect user passwords during the login request. I am hoping this can be achieved using only the Faces Servlet with declarative security in the web.xml deployment descriptor.

I am using form-based authentication with a non j_security_check custom Facelet form for programmatic login through request.login method. The login form has the following security constraint in the web.xml:

 <security-constraint>
    <display-name>secure login</display-name>
    <web-resource-collection>
        <web-resource-name>login.xhtml</web-resource-name>
        <description/>
        <url-pattern>/login.xhtml</url-pattern>
    </web-resource-collection>
    <user-data-constraint>
        <description/>
        <transport-guarantee>CONFIDENTIAL</transport-guarantee>
    </user-data-constraint>
</security-constraint>

There is not an authorization constraint element as this form is obviously intended for unauthenticated users. The only reason there is a security constraint at all is so that the  sub element can be set to CONFIDENTIAL assuring a secure connection.

The Java EE 6 tutorial states here that:

If there is no authorization constraint, the container must accept the request without requiring user authentication

and

The user data constraint is handy to use in conjunction with basic and form-based user authentication. When the login authentication method is set to BASIC or FORM, passwords are not protected, meaning that passwords sent between a client and a server on an unprotected session can be viewed and intercepted by third parties. Using a user data constraint with the user authentication mechanism can alleviate this concern. Configuring a user authentication mechanism is described in Specifying an Authentication Mechanism in the Deployment Descriptor.

Why is JACC doing a permission check when no such check should be required to access this resource? Why does it fail only from the internet and not on the LAN?


问:
How to organize search architecture on large amount of data about 10 million in .net
I have a table, which store about 10 million records(items), each record have itemtype(it's a reference key to table types). On my site i have a search functionality which based on fulltext search, it was ok, but a few days ago my customer want to show on the site not only all items but the itemtypes too.

I try to do two parallel request to different servers(one to repl server and one to main):

-- first request - group items by itemtypeid(with using fulltext search) and return list of itemtypeid

--second request - search keywords in database(fulltext search)

on the web server i aggregate results from these requests and push it to the web browser.
Problem: first request run not so fast as i want :) (it's very slow) and after six(eight) month there will be more than 11 million items, so, first request will be slower and slower.

Show me, please, the right way.

答:
From what I understand, you have two tables: Item and ItemType. Each record in table Item has a foreign key to the table ItemType. You want to search for records in the table Item, and display both the Item and the ItemType in the result list.

If this is correct, just use a JOIN clause in your initial request.


问:
Swift 4 JSON Decodable with multidimensional and multitype array
```<code>{
"values":[
[1,1,7,"Azuan Child","Anak Azuan","12345","ACTIVE","Morning",7,12,"2017-11-09 19:45:00"],
[28,1,0,"Azuan Child2","Amran","123456","ACTIVE","Evening",1,29,"2017-11-09 19:45:00"]
]
}
</code>```

Ok, this is my json format that i received from the server

Right now i want to decode it into my struct but still have no luck on it.

```<code>struct ChildrenTable: Decodable {
    var values: [[String]]?
}
</code>```

And my caller method on URLSession look like this

```<code>URLSession.shared.dataTask(with: request) { (data, response, err) in
        guard let data = data else { return }

        let dataAsString = String(data: data, encoding: .utf8)
        print(dataAsString)

        do {
            let children  = try
                JSONDecoder().decode(ChildrenTable.self, from: data)
                print (children)
        } catch let jsonErr {
            print ("Error serializing json: ", jsonErr)
        }
    }.resume()
</code>```

And the error that i got are

```<code>Error serializing json:
typeMismatch(Swift.String, Swift.DecodingError.Context(codingPath: [Vito_Parent.ChildrenTable.(CodingKeys in _1B826CD7D9609504747BED0EC0B7D3B5).values, Foundation.(_JSONKey in _12768CA107A31EF2DCE034FD75B541C9)(stringValue: "Index 0", intValue: Optional(0)),
Foundation.(_JSONKey in _12768CA107A31EF2DCE034FD75B541C9)(stringValue: "Index 0", intValue: Optional(0))],
debugDescription: "Expected to decode String but found a number instead.", underlyingError: nil))
</code>```

I know there's an int in the array  and i only cast String for the values var values: [[String]]? ( the reason why this error popup), but i simply cannot use any multidimensional array or tuples in my structs since it follow the protocol of Decodable.

I also cannot convert the data into dictionary since it will throw error "Expected to decode Dictionary but found array instead"

Any ideas on solving this problem? i tried casting string type on data but still no luck...

p/s: if all the json format are in string type, there would be no problem, but i dont have the permission on changing  that since i call it from API.

答:
I've tried use your solution on my project, and its work like a charm. Below i've modified a bit so it can be use for single string, single array, and multidimensional array

```<code>struct TripModel: Decodable {
var tx_result: Any
var columns: [Any]
var values: [[Any]]

enum CodingKeys : String, CodingKey {
    case tx_result
    case columns
    case values
}

init(from decoder: Decoder) throws {
    var bigarr = [[Any]]()
    var arrColumn = [Any]()
    // get the dictionary
    let con = try! decoder.container(keyedBy: CodingKeys.self)

    let conResult = try! con.decode(String.self, forKey: CodingKeys.tx_result)

    var conColumns = try! con.nestedUnkeyedContainer(forKey: CodingKeys.columns)
    //print(String(describing: conColumns.count))

    // get the "values" array of array
    var con2 = try! con.nestedUnkeyedContainer(forKey: CodingKeys.values)

    for _ in 0..<con2.count! {
        // get a nested array
        var con3 = try! con2.nestedUnkeyedContainer()
        // decode all the elements of the nested array
        var arr = [Any]()
        arr.append(try! con3.decode(Int.self))
        arr.append(try! con3.decode(Int.self))
        arr.append(try! con3.decode(Int.self))
        arr.append(try! con3.decode(Int.self))
        arr.append(try! con3.decode(String.self))
        arr.append(try! con3.decode(String.self))
        arr.append(try! con3.decode(String.self))
        arr.append(try! con3.decode(Int.self))
        arr.append(try! con3.decode(Int.self))
        arr.append(try! con3.decode(Double.self))
        arr.append(try! con3.decode(String.self))
        bigarr.append(arr)
    }

        arrColumn.append(try! conColumns.decode(String.self))
        arrColumn.append(try! conColumns.decode(String.self))
        arrColumn.append(try! conColumns.decode(String.self))
        arrColumn.append(try! conColumns.decode(String.self))
        arrColumn.append(try! conColumns.decode(String.self))
        arrColumn.append(try! conColumns.decode(String.self))
        arrColumn.append(try! conColumns.decode(String.self))
        arrColumn.append(try! conColumns.decode(String.self))
        arrColumn.append(try! conColumns.decode(String.self))
        arrColumn.append(try! conColumns.decode(String.self))
        arrColumn.append(try! conColumns.decode(String.self))

    // all done! finish initialization
    self.tx_result = conResult
    self.columns = arrColumn
    self.values = bigarr
}
</code>```

}

Body:
{
"values":[
[1,1,7,"Azuan Child","Anak Azuan","12345","ACTIVE","Morning",7,12,"2017-11-09 19:45:00"],
[28,1,0,"Azuan Child2","Amran","123456","ACTIVE","Evening",1,29,"2017-11-09 19:45:00"]
]
}

Ok, this is my json format that i received from the server

Right now i want to decode it into my struct but still have no luck on it.

struct ChildrenTable: Decodable {
    var values: [[String]]?
}

And my caller method on URLSession look like this

URLSession.shared.dataTask(with: request) { (data, response, err) in
        guard let data = data else { return }

        let dataAsString = String(data: data, encoding: .utf8)
        print(dataAsString)

        do {
            let children  = try
                JSONDecoder().decode(ChildrenTable.self, from: data)
                print (children)
        } catch let jsonErr {
            print ("Error serializing json: ", jsonErr)
        }
    }.resume()

And the error that i got are

Error serializing json:
typeMismatch(Swift.String, Swift.DecodingError.Context(codingPath: [Vito_Parent.ChildrenTable.(CodingKeys in _1B826CD7D9609504747BED0EC0B7D3B5).values, Foundation.(_JSONKey in _12768CA107A31EF2DCE034FD75B541C9)(stringValue: "Index 0", intValue: Optional(0)),
Foundation.(_JSONKey in _12768CA107A31EF2DCE034FD75B541C9)(stringValue: "Index 0", intValue: Optional(0))],
debugDescription: "Expected to decode String but found a number instead.", underlyingError: nil))

I know there's an int in the array  and i only cast String for the values var values: [[String]]? ( the reason why this error popup), but i simply cannot use any multidimensional array or tuples in my structs since it follow the protocol of Decodable.

I also cannot convert the data into dictionary since it will throw error "Expected to decode Dictionary but found array instead"

Any ideas on solving this problem? i tried casting string type on data but still no luck...

p/s: if all the json format are in string type, there would be no problem, but i dont have the permission on changing  that since i call it from API.

Body:
I've tried use your solution on my project, and its work like a charm. Below i've modified a bit so it can be use for single string, single array, and multidimensional array

struct TripModel: Decodable {
var tx_result: Any
var columns: [Any]
var values: [[Any]]

enum CodingKeys : String, CodingKey {
    case tx_result
    case columns
    case values
}

init(from decoder: Decoder) throws {
    var bigarr = [[Any]]()
    var arrColumn = [Any]()
    // get the dictionary
    let con = try! decoder.container(keyedBy: CodingKeys.self)

    let conResult = try! con.decode(String.self, forKey: CodingKeys.tx_result)

    var conColumns = try! con.nestedUnkeyedContainer(forKey: CodingKeys.columns)
    //print(String(describing: conColumns.count))

    // get the "values" array of array
    var con2 = try! con.nestedUnkeyedContainer(forKey: CodingKeys.values)

    for _ in 0..<con2.count! {
        // get a nested array
        var con3 = try! con2.nestedUnkeyedContainer()
        // decode all the elements of the nested array
        var arr = [Any]()
        arr.append(try! con3.decode(Int.self))
        arr.append(try! con3.decode(Int.self))
        arr.append(try! con3.decode(Int.self))
        arr.append(try! con3.decode(Int.self))
        arr.append(try! con3.decode(String.self))
        arr.append(try! con3.decode(String.self))
        arr.append(try! con3.decode(String.self))
        arr.append(try! con3.decode(Int.self))
        arr.append(try! con3.decode(Int.self))
        arr.append(try! con3.decode(Double.self))
        arr.append(try! con3.decode(String.self))
        bigarr.append(arr)
    }

        arrColumn.append(try! conColumns.decode(String.self))
        arrColumn.append(try! conColumns.decode(String.self))
        arrColumn.append(try! conColumns.decode(String.self))
        arrColumn.append(try! conColumns.decode(String.self))
        arrColumn.append(try! conColumns.decode(String.self))
        arrColumn.append(try! conColumns.decode(String.self))
        arrColumn.append(try! conColumns.decode(String.self))
        arrColumn.append(try! conColumns.decode(String.self))
        arrColumn.append(try! conColumns.decode(String.self))
        arrColumn.append(try! conColumns.decode(String.self))
        arrColumn.append(try! conColumns.decode(String.self))

    // all done! finish initialization
    self.tx_result = conResult
    self.columns = arrColumn
    self.values = bigarr
}

}


问:
coldfusion pagination (Next & Previous)
I have to do pagination in my project:

below code working fine just I'm not able to figure out for (next / prev) buttons how can i handle. im using mysql database
it will be great help if you give me some best practice tips &
if there is any other easy way? please give me reference it will be great help

here is my code:

```<code><script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" type="application/javascript"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<!---
<cfquery name="data" datasource="#application.dsn#">
    select * from yourTable
</cfquery>

--->

<!--- Generate fake data --->
<cfset data = queryNew("id,name","integer,varchar")>
<cfloop index="x" from="1" to="80">
    <cfset queryAddRow(data, {id:x,name:"User #x#"})>
</cfloop>

    <cfparam name="URL.PageId" default="0">
<cfset RecordsPerPage = 5>

<cfset TotalPages = (data.Recordcount/RecordsPerPage)-1>
<cfset StartRow = (URL.PageId*RecordsPerPage)+1>
<cfset EndRow = StartRow+RecordsPerPage-1>
<cfoutput>
 <table border="1">
   <tr>
      <th>No.</th>
      <th>PARKNAME</th>
      <th>REGION </th>
      <th>STATE</th>
   </tr>
   <cfloop query="data">
    <cfif CurrentRow gte StartRow >
       <tr>
          <td>#CurrentRow#</td>
          <td>#name#</td>
          <td>US</td>
          <td>MO</td>
       </tr>
    </cfif>
    <cfif CurrentRow eq EndRow>
       <cfbreak>
    </cfif>
   </cfloop>
</cfoutput>
   <tr>
      <td colspan="4">
       <cfloop index="Pages" from="0" to="#TotalPages#">
        <cfoutput>
           <cfset DisplayPgNo = Pages+1>
           <cfif URL.PageId eq pages>
              <strong>#DisplayPgNo#</strong>
           <cfelse>
              <a href="?PageId=#Pages#">#DisplayPgNo#</a>
           </cfif>
        </cfoutput>
       </cfloop>
      </td>
   </tr>
</table>

 <nav aria-label="...">
  <ul class="pagination">
    <li class="page-item disabled">
      <a class="page-link" href="#" tabindex="-1">Previous</a>
    </li>
      <cfloop index="Pages" from="0" to="#TotalPages#">
        <cfoutput>
           <cfset DisplayPgNo = Pages+1>
           <cfif URL.PageId eq pages>
                <li class="page-item">
                    <li class="page-item active">
                    <a class="page-link" href="##">#DisplayPgNo#</a>
               </li>
           <cfelse>
               <li class="page-item"><a class="page-link" href="?PageId=#Pages#">#DisplayPgNo#</a></li>
           </cfif>
        </cfoutput>
       </cfloop>
        <li class="page-item">
            <a class="page-link" href="#">Next</a>
        </li>
  </ul>
</nav>
</code>```

答:
Here is a full pagination solution. Though you'd probably want to put the paginateBS function in a reusable application variable.

```<code><!--- CURRENT PAGE --->
<cfparam name="url.page" default="1">
<cfparam name="request.PAGI_pagenum" default="#url.page#">
<!--- RECORDS PER PAGE (ON ALL PAGES) --->
<cfparam name="request.PAGI_allperpage" default="20">
<!--- RECORDS PER PAGE (ON FIRST PAGE) --->
<cfparam name="request.PAGI_firstperpage" default="#request.PAGI_allperpage#">
<!--- NUMBER OF PAGE LINKS AT A TIME --->
<cfparam name="request.PAGI_blocksof" default="5">

<cfset fromRecord = request.PAGI_firstperpage+(request.PAGI_allperpage*(request.PAGI_pagenum-1))-request.PAGI_allperpage>
<cfquery name="quotes" >
SELECT SQL_CALC_FOUND_ROWS first_name, last_name, email, id, datetime, published
FROM quotes
ORDER by datetime DESC
LIMIT #fromRecord#,
    <cfif request.PAGI_pagenum is 1>
        #request.PAGI_firstperpage#
    <cfelse>
        #request.PAGI_allperpage#
    </cfif>
</cfquery>
<Cfquery name="result_count" >
SELECT FOUND_ROWS() as totalRecords
</cfquery>

<div class="pull-right" id="page">
    <div class="pagination pagination-custom">
        <ul>
            <cfoutput>#paginateQuotes(totalRecords=result_count.totalRecords)#</cfoutput>
        </ul>
    </div>
</div>

<cffunction name="paginateBS">
    <cfargument name="totalRecords" default="0">
    <cfparam name="request.PAGI_attribute" default="">
    <!--- 'TOP' IS THE LAST PAGE NUMBER LINK --->
    <Cfset top = request.PAGI_blocksof * ceiling((request.PAGI_pagenum)/request.PAGI_blocksof)>

    <cfoutput>

    <!--- IF WE'RE PAST THE FIRST BLOCK OF PAGES, SHOW THE PREV LINK --->
    <cfif request.PAGI_pagenum gt request.PAGI_blocksof>
        <li>
            <a href="?page=#top-request.PAGI_blocksof#<cfif request.PAGI_attribute neq ''>&#request.PAGI_attribute#=#request.PAGI_attributevalue#</cfif>">
                <i class="icon-double-angle-left"></i>
            </a>
        </li>
    </cfif>

    <!--- LOOP THROUGH THE PAGES IN THIS BLOCK --->
    <cfloop from="#top-request.PAGI_blocksof+1#" to="#top#" index="a">
        <li <cfif request.PAGI_pagenum is not a>class="active"</cfif>>
            <a href="?page=#a#<cfif request.PAGI_attribute neq ''>&#request.PAGI_attribute#=#request.PAGI_attributevalue#</cfif>">#a#</a>
        </li>
        <!--- IF WE'RE ON THE LAST BLOCK AND DON'T HAVE ENOUGH RECORDS TO COMPLETE THE BLOCK,
            STOP CREATING THE LINKS FOR MORE PAGES, AND SET A FLAG TO NOT SHOW THE LINK FOR THE NEXT BLOCK --->
        <cfif ((a-1) * request.PAGI_allperpage) + request.PAGI_firstperpage gte arguments.totalRecords>
            <cfset arguments.noNext=1>
            <cfbreak>
        </cfif>
    </cfloop>

    <!--- IF WE RAN OUT OF RECORDS, DO NOT SHOW THE LINK FOR THE NEXT BLOCK OF PAGES --->
    <cfif not isdefined("arguments.noNext")>
        <li>
            <a href="?page=#top+1#<cfif request.PAGI_attribute neq ''>&#request.PAGI_attribute#=#request.PAGI_attributevalue#</cfif>">
                <i class="icon-double-angle-right"></i>
            </a>
        </li>
    </cfif>

    </cfoutput>
</cffunction>
</code>```

Title: coldfusion pagination (Next & Previous)

Body:
I have to do pagination in my project:

below code working fine just I'm not able to figure out for (next / prev) buttons how can i handle. im using mysql database
it will be great help if you give me some best practice tips &
if there is any other easy way? please give me reference it will be great help

here is my code:

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

<cfset data = queryNew("id,name","integer,varchar")>
<cfloop index="x" from="1" to="80">
    <cfset queryAddRow(data, {id:x,name:"User #x#"})>
</cfloop>

    <cfparam name="URL.PageId" default="0">
<cfset RecordsPerPage = 5>

<cfset TotalPages = (data.Recordcount/RecordsPerPage)-1>
<cfset StartRow = (URL.PageId*RecordsPerPage)+1>
<cfset EndRow = StartRow+RecordsPerPage-1>
<cfoutput>

      No.
      PARKNAME
      REGION
      STATE

   <cfloop query="data">
    <cfif CurrentRow gte StartRow >

          #CurrentRow#
          #name#
          US
          MO

    </cfif>
    <cfif CurrentRow eq EndRow>
       <cfbreak>
    </cfif>
   </cfloop>
</cfoutput>

       <cfloop index="Pages" from="0" to="#TotalPages#">
        <cfoutput>
           <cfset DisplayPgNo = Pages+1>
           <cfif URL.PageId eq pages>
              #DisplayPgNo#
           <cfelse>
              #DisplayPgNo#
           </cfif>
        </cfoutput>
       </cfloop>

      Previous

      <cfloop index="Pages" from="0" to="#TotalPages#">
        <cfoutput>
           <cfset DisplayPgNo = Pages+1>
           <cfif URL.PageId eq pages>

                    #DisplayPgNo#

           <cfelse>

#DisplayPgNo#

           </cfif>
        </cfoutput>
       </cfloop>

            Next

Body:
Here is a full pagination solution. Though you'd probably want to put the paginateBS function in a reusable application variable.

<!--- CURRENT PAGE --->
<cfparam name="url.page" default="1">
<cfparam name="request.PAGI_pagenum" default="#url.page#">
<!--- RECORDS PER PAGE (ON ALL PAGES) --->
<cfparam name="request.PAGI_allperpage" default="20">
<!--- RECORDS PER PAGE (ON FIRST PAGE) --->
<cfparam name="request.PAGI_firstperpage" default="#request.PAGI_allperpage#">
<!--- NUMBER OF PAGE LINKS AT A TIME --->
<cfparam name="request.PAGI_blocksof" default="5">

<cfset fromRecord = request.PAGI_firstperpage+(request.PAGI_allperpage*(request.PAGI_pagenum-1))-request.PAGI_allperpage>
<cfquery name="quotes" >
SELECT SQL_CALC_FOUND_ROWS first_name, last_name, email, id, datetime, published
FROM quotes
ORDER by datetime DESC
LIMIT #fromRecord#,
    <cfif request.PAGI_pagenum is 1>
        #request.PAGI_firstperpage#
    <cfelse>
        #request.PAGI_allperpage#
    </cfif>
</cfquery>
<Cfquery name="result_count" >
SELECT FOUND_ROWS() as totalRecords
</cfquery>

<div class="pull-right" id="page">
    <div class="pagination pagination-custom">
        <ul>
            <cfoutput>#paginateQuotes(totalRecords=result_count.totalRecords)#</cfoutput>
        </ul>
    </div>
</div>

<cffunction name="paginateBS">
    <cfargument name="totalRecords" default="0">
    <cfparam name="request.PAGI_attribute" default="">
    <!--- 'TOP' IS THE LAST PAGE NUMBER LINK --->
    <Cfset top = request.PAGI_blocksof * ceiling((request.PAGI_pagenum)/request.PAGI_blocksof)>

    <cfoutput>

    <!--- IF WE'RE PAST THE FIRST BLOCK OF PAGES, SHOW THE PREV LINK --->
    <cfif request.PAGI_pagenum gt request.PAGI_blocksof>
        <li>
            <a href="?page=#top-request.PAGI_blocksof#<cfif request.PAGI_attribute neq ''>&#request.PAGI_attribute#=#request.PAGI_attributevalue#</cfif>">
                <i class="icon-double-angle-left"></i>
            </a>
        </li>
    </cfif>

    <!--- LOOP THROUGH THE PAGES IN THIS BLOCK --->
    <cfloop from="#top-request.PAGI_blocksof+1#" to="#top#" index="a">
        <li <cfif request.PAGI_pagenum is not a>class="active"</cfif>>
            <a href="?page=#a#<cfif request.PAGI_attribute neq ''>&#request.PAGI_attribute#=#request.PAGI_attributevalue#</cfif>">#a#</a>
        </li>
        <!--- IF WE'RE ON THE LAST BLOCK AND DON'T HAVE ENOUGH RECORDS TO COMPLETE THE BLOCK,
            STOP CREATING THE LINKS FOR MORE PAGES, AND SET A FLAG TO NOT SHOW THE LINK FOR THE NEXT BLOCK --->
        <cfif ((a-1) * request.PAGI_allperpage) + request.PAGI_firstperpage gte arguments.totalRecords>
            <cfset arguments.noNext=1>
            <cfbreak>
        </cfif>
    </cfloop>

    <!--- IF WE RAN OUT OF RECORDS, DO NOT SHOW THE LINK FOR THE NEXT BLOCK OF PAGES --->
    <cfif not isdefined("arguments.noNext")>
        <li>
            <a href="?page=#top+1#<cfif request.PAGI_attribute neq ''>&#request.PAGI_attribute#=#request.PAGI_attributevalue#</cfif>">
                <i class="icon-double-angle-right"></i>
            </a>
        </li>
    </cfif>

    </cfoutput>
</cffunction>


问:
& is valid in an HTML attribute?
While writing a series of music options, he called me to attention as Atom expected me to close with a ; after putting a & in the value section.

```<code><option value="R&B/Soul">R&B/Soul</option>
<option value="R&B/Soul">R&B/Soul</option>
</code>```

Is the first line correct, or is it just an atom error?

答:
Yes, it's correct.1 It's pretty clear that you did in fact terminate the character reference with a ; in the right spot, so I don't know why Atom is complaining.

1 In fact, both lines are valid, even if the latter is incredibly bad practice.

Title: & is valid in an HTML attribute?

Body:
While writing a series of music options, he called me to attention as Atom expected me to close with a ; after putting a & in the value section.

<option value="R&B/Soul">R&B/Soul</option>
<option value="R&B/Soul">R&B/Soul</option>

Is the first line correct, or is it just an atom error?


问:
Selenium Web Driver issue in Threading. C#
Here's the code.

```<code>browser = new FirefoxDriver();
browser.Navigate().GoToUrl("https://www.vicroads.vic.gov.au/registration/buy-sell-or-transfer-a-vehicle/buy-a-vehicle/check-vehicle-registration/vehicle-registration-enquiry");
Thread.Sleep(5000);
browser.FindElement(By.Name("ph_pagebody_0$phthreecolumnmaincontent_1$panel$VehicleSearch$RegistrationNumberCar$RegistrationNumber_CtrlHolderDivShown")).SendKeys("asdf");
</code>```

It works ok but if I run in thread it shows element not visible.... why it's throwing in a thread?

答:
Going by the xpath you tried out, it seems the name attribute is dynamic. To locate the text box for Registration number You can try either of the following options :

CssSelector :

```<code>browser.FindElement(By.CssSelector("input[class=text text xlong v_registrationNumber v_required][id^=ph_pagebody_)]")).SendKeys("asdf");
</code>```

XPath :

```<code>browser.FindElement(By.XPath("//input[@class='text text xlong v_registrationNumber v_required'][starts-with(@id, 'ph_pagebody_')]")).SendKeys("asdf");
</code>```

Body:
Here's the code.

browser = new FirefoxDriver();
browser.Navigate().GoToUrl("https://www.vicroads.vic.gov.au/registration/buy-sell-or-transfer-a-vehicle/buy-a-vehicle/check-vehicle-registration/vehicle-registration-enquiry");
Thread.Sleep(5000);
browser.FindElement(By.Name("ph_pagebody_0$phthreecolumnmaincontent_1$panel$VehicleSearch$RegistrationNumberCar$RegistrationNumber_CtrlHolderDivShown")).SendKeys("asdf");

It works ok but if I run in thread it shows element not visible.... why it's throwing in a thread?

Body:
Going by the xpath you tried out, it seems the name attribute is dynamic. To locate the text box for Registration number You can try either of the following options :

CssSelector :

browser.FindElement(By.CssSelector("input[class=text text xlong v_registrationNumber v_required][id^=ph_pagebody_)]")).SendKeys("asdf");

XPath :

browser.FindElement(By.XPath("//input[@class='text text xlong v_registrationNumber v_required'][starts-with(@id, 'ph_pagebody_')]")).SendKeys("asdf");


答:
The essential packages for cakephp3.x are (if you are using CentOS):

```<code>$ sudo yum -y install php-intl php-mbstring php-xml
</code>```

Then restart Apache:

```<code>$ sudo service httpd restart
</code>```

You can check here for what packages are needed:

https://book.cakephp.org/3.0/en/installation.html

But if uploading is not working, I think somewhere else has a problem.

Maybe your form doesn't have 'multipart/form-data'?

```<code><?= $this->Form->create($tests, ['enctype' => 'multipart/form-data']) ?>
<?= $this->Form->end() ?>
</code>```

Title: What are extensions need to run cakePHP

Body: Im new to cakePHP. With it upload function not working now. I got already developed project to work. What are PHP extensions I need to enable for cakePHP ?

Body:
The essential packages for cakephp3.x are (if you are using CentOS):

$ sudo yum -y install php-intl php-mbstring php-xml

Then restart Apache:

$ sudo service httpd restart

You can check here for what packages are needed:

https://book.cakephp.org/3.0/en/installation.html

But if uploading is not working, I think somewhere else has a problem.

Maybe your form doesn't have 'multipart/form-data'?

<?= $this->Form->create($tests, ['enctype' => 'multipart/form-data']) ?>
<?= $this->Form->end() ?>


问:
Problems reading text file - non-breaking space character
I am trying to read some text file with the following line:

```<code>"WE BUY  : 10 000.00 USD"
</code>```

First I have opened this file in binary editor and the 13th character (or 12th by 0-based C# indexing) (thousand separator) is "160 code in decimal" or "A0 code in hex" in Windows-1251 encoding.

However after I read this line into string using File.ReadAllLines
in the debugger I can see the the character now has 65533 code.

"lines[9][12]   65533 '�'   char"

The default encoding Encoding.Default for my PC is "Windows-1251".

How come?

UPDATE

Tryed open the file with UTF-8 encoding, still the same result.

UPDATE 2

The problem is that file encoding is 8bit but the debugger shows for 8bit character 'A0' 16 bit value of 65533.

答:
The one argument File.ReadAllLines will assume the input is UTF-8, whatever the system default encoding.

For anything else you need to specify the encoding:

```<code>var lines = File.ReadAllLines(filename, Encoding.GetEncoding(name));
</code>```

You can get name from your Encoding.Default.WebName ("Windows-1252" is what I get here, but check locally).

Body:
I am trying to read some text file with the following line:

"WE BUY  : 10 000.00 USD"

First I have opened this file in binary editor and the 13th character (or 12th by 0-based C# indexing) (thousand separator) is "160 code in decimal" or "A0 code in hex" in Windows-1251 encoding.

However after I read this line into string using File.ReadAllLines
in the debugger I can see the the character now has 65533 code.

"lines[9][12]   65533 '�'   char"

The default encoding Encoding.Default for my PC is "Windows-1251".

How come?

UPDATE

Tryed open the file with UTF-8 encoding, still the same result.

UPDATE 2

The problem is that file encoding is 8bit but the debugger shows for 8bit character 'A0' 16 bit value of 65533.

Body:
The one argument File.ReadAllLines will assume the input is UTF-8, whatever the system default encoding.

For anything else you need to specify the encoding:

var lines = File.ReadAllLines(filename, Encoding.GetEncoding(name));

You can get name from your Encoding.Default.WebName ("Windows-1252" is what I get here, but check locally).


问:
Using $_POST values in CodeIgniter
Application makes an AJAX request to a method in a controller.

The controller then calls a method in the model to run a query on the DB and then return the results.

AJAX "type" specified as POST.

Even though $_POST superglobal values are available for use in model, should one still list the $_POST values in the model method signature?

I'm thinking this is best practice so people dissecting a system can quickly see inputs going into model methods

```<code>$this->Students_table_model->attendance_history_get($_POST['students_id'],$_POST['start_date'],$_POST['end_date']);

public function attendance_history_get($students_id,$start,$end)
</code>```

VS

```<code>$this->Students_table_model->attendance_history_get();
</code>```

and then just using the available $_POST values in model method attendance_history_get()

答:
I think you should use the codeigniter custom function $this->input->post(); to get the post value</p>

```<code>$student_id = $this->input->post('students_id');
$start_date = $this->input->post('start_date');
$end_date = $this->input->post('end_date');
</code>```

Title: Using $_POST values in CodeIgniter

Body:
Application makes an AJAX request to a method in a controller.

The controller then calls a method in the model to run a query on the DB and then return the results.

AJAX "type" specified as POST.

Even though $_POST superglobal values are available for use in model, should one still list the $_POST values in the model method signature?

I'm thinking this is best practice so people dissecting a system can quickly see inputs going into model methods

$this->Students_table_model->attendance_history_get($_POST['students_id'],$_POST['start_date'],$_POST['end_date']);

public function attendance_history_get($students_id,$start,$end)

VS

$this->Students_table_model->attendance_history_get();

and then just using the available $_POST values in model method attendance_history_get()

Body:
I think you should use the codeigniter custom function $this->input->post(); to get the post value

$student_id = $this->input->post('students_id');
$start_date = $this->input->post('start_date');
$end_date = $this->input->post('end_date');


问:
Edittext as spinner
I have a editext which I would like to show as drop down. SO for that I have background.xml file:

```<code><?xml version="1.0" encoding="utf-8" ?>

<selector xmlns:android="http://schemas.android.com/apk/res/android">

  <item>
    <layer-list>
      <item>
        <shape>
          <solid android:color="#ffffff" />
          <stroke android:width="1dp" android:color="#000000" />
          <padding android:bottom="3dp" android:left="3dp" android:right="3dp" android:top="3dp" />
        </shape>
      </item>
      <item>
        <bitmap android:gravity="right" android:src="@drawable/ic_arrow_drop_down" />
      </item>
    </layer-list>
  </item>

</selector>
</code>```

And added that as background for my edittext. This is what I get:

As you can see there is slight gap between the image and editext border. I would like to make my edittext like this:

How can I achieve this?

答:
Create a RelativeLayout with EditText and ImageView UI Components :).
Don't complicate yourself.</p>

Title: Edittext as spinner

Body:
I have a editext which I would like to show as drop down. SO for that I have background.xml file:

<?xml version="1.0" encoding="utf-8" ?>

<selector xmlns:android="http://schemas.android.com/apk/res/android">

  <item>
    <layer-list>
      <item>
        <shape>
          <solid android:color="#ffffff" />
          <stroke android:width="1dp" android:color="#000000" />
          <padding android:bottom="3dp" android:left="3dp" android:right="3dp" android:top="3dp" />
        </shape>
      </item>
      <item>
        <bitmap android:gravity="right" android:src="@drawable/ic_arrow_drop_down" />
      </item>
    </layer-list>
  </item>

</selector>

And added that as background for my edittext. This is what I get:

As you can see there is slight gap between the image and editext border. I would like to make my edittext like this:

How can I achieve this?