问:
Adapter Proxy for Restful APIs
this is a general 'what technologies are available' question.

My company provides a web application with a RESTful API.  However, it is too slow for my needs and some of the results are in an awkward format.

I want to wrap their restful server with a proxy/adapter server, so when you connect to the proxy you get the RESTful API I wish the real one provides.

So it needs to do a few things:

passthrough most requests

cache some requests

do some extra requests on the original server to detect if a request is cacheable

for instance: there is a request for a field in a record: GET /records/id/field which might be slow, but there is a fingerprint request GET /records/id/fingerprint which is always fast.  If there exists a cache of GET /records/1/field2 for the fingerprint feedbeef, then I need to check the original server still has the fingerprint feed beef before serving the cached version.

fix headers for some responses - e.g. content-type, based upon the path

do stream processing on some large content, for instance

GET /records/id/attachments/1234

returns a 100Mb log file in text format

remove null characters from files
optionally recode the log to filter out irrelevant lines, reducing the load on the client
cache the filtered version for later requests.

While I could modify the client to achieve this functionality, such code would not be re-usable for other clients (different languages), and complicates the client logic.

I had a look at whether clojure/ring could do it, and while there is a nice little proxy middleware for it, it doesn't handle streaming content as far as I can tell - the whole 100Mb would have to be downloaded.  Also it doesn't include any cache logic yet.

I took a look at whether squid could do it, but I'm not familiar with the technology, and it seems mostly concerned with passing through requests rather than modifying them on the fly.

I'm looking for hints where I might find the correct technology to implement this.  I'm mostly language agnostic if learning a new language gets me access to a really simple way to do it.

答:
Beeceptor does exactly what you want. It plugs in-between your web-app and original API to route requests.

For your use-case of caching a few responses, you can create a rule. That way it shall not hit the original endpoint.

The requests to original APIs can be mocked, and you can inspect response

You can simulate delays.

(Note: it is a shameless plug, I am the author of Beeceptor and thought it should help you and other developers.)

Title: Adapter Proxy for Restful APIs


来源: stackexchange

问:
Hide selected option from first dropdown on the next dropdown
I have a dynamic form that has dropdown select. I get the data from the option using ng repeat and then display it onthe dropdown. My code somewhat goes like this.

```<code><select name="languageCat" id="languageCat" ng-model="languageItem.languageCat" ng-required="true" required>
     <option value="">---Please select---</option>
     <option ng-repeat="item in scpLangCat" value="{{item.language_name}}">{{item.language_name}} - {{item.language_description}}</option>
 </select>
</code>```

I get the data from this API call.

```<code>Service.fetchDropdownData('language')
 .then(function(data){
     $scope.scpLangCat = data.data;
     localStorage.LanguageCategory = JSON.stringify(data.data);
 })
</code>```

This dropdown is in my dynamic form. I I selected a value in the first form in this dropdown, I need to hide that value on the second dropdown in the second form. The addition of dynamic form code is this.

```<code>scope.addLanguageItem = function() {
            $scope.LanguageFormData.language.push({ bName: null, pName: null, pNameSub: null, lFeature: null, lIngredient: null, lInstruction: null, languageCat: null });
            $scope.disablebrand=false;

    };
</code>```

How can I possibly do that?

答:
If you have forms created like this

```<code><div ng-repeat="(index,scpLangCat) in LanguageFormData">
    <select name="languageCat[index]" id="{{'languageCat_' + index}}" ng-model="languageItem.languageCat[index]" ng-required="true" required
    ng-options="item.language_name +' - ' + item.language_description as item.label for item in getCategories() track by item.language_name">
    </select>
</div>
</code>```

You can implement getCategories this way:

```<code>$scope.getCategories() = function() {
    return $scope.scpLangCat.filter(function(item){return $scope.languageItem.languageCat.indexOf(item.language_name)==-1);
}
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I have a dynamic form that has dropdown select. I get the data from the option using ng repeat and then display it onthe dropdown. My code somewhat goes like this.

<select name="languageCat" id="languageCat" ng-model="languageItem.languageCat" ng-required="true" required>
     <option value="">---Please select---</option>
     <option ng-repeat="item in scpLangCat" value="{{item.language_name}}">{{item.language_name}} - {{item.language_description}}</option>
 </select>

I get the data from this API call.

Service.fetchDropdownData('language')
 .then(function(data){
     $scope.scpLangCat = data.data;
     localStorage.LanguageCategory = JSON.stringify(data.data);
 })

This dropdown is in my dynamic form. I I selected a value in the first form in this dropdown, I need to hide that value on the second dropdown in the second form. The addition of dynamic form code is this.

scope.addLanguageItem = function() {
            $scope.LanguageFormData.language.push({ bName: null, pName: null, pNameSub: null, lFeature: null, lIngredient: null, lInstruction: null, languageCat: null });
            $scope.disablebrand=false;

    };

How can I possibly do that?

Body:
If you have forms created like this

<div ng-repeat="(index,scpLangCat) in LanguageFormData">
    <select name="languageCat[index]" id="{{'languageCat_' + index}}" ng-model="languageItem.languageCat[index]" ng-required="true" required
    ng-options="item.language_name +' - ' + item.language_description as item.label for item in getCategories() track by item.language_name">
    </select>
</div>

You can implement getCategories this way:

$scope.getCategories() = function() {
    return $scope.scpLangCat.filter(function(item){return $scope.languageItem.languageCat.indexOf(item.language_name)==-1);
}


问:
How to avoid warning of Unreachable code
I have the below

```<code>string currency = string.Empty;
Regex r = new Regex(@"~(\w*[a-zA-Z0-9$£~%]+)", RegexOptions.IgnoreCase | RegexOptions.Compiled);
for (Match m = r.Match(expression); m.Success; m = m.NextMatch())
{
      currency = (m.Groups[1].Value);
      break;
}
return currency;
</code>```

The intension is that, after the first match in the loop it should break.

The warning messge(Unreachable code) is happening  m = m.NextMatch() of the loop.

How to overcome this?

Thanks

答:
Your code is currently broken, basically. You're really never going to execute m = m.NextMatch(), so why have it?

I think you want:

```<code>Regex r = new Regex(@"~(\w*[a-zA-Z0-9$£~%]+)",
                    RegexOptions.IgnoreCase | RegexOptions.Compiled);

Match m = r.Match(expression);
string currency = m.Success ? m.Groups[1].Value : "";
</code>```

Personally I think this is rather clearer, in terms of what the final version of "currency" is.

ContentLicense: CC BY-SA 2.5

Body:
I have the below

string currency = string.Empty;
Regex r = new Regex(@"~(\w*[a-zA-Z0-9$£~%]+)", RegexOptions.IgnoreCase | RegexOptions.Compiled);
for (Match m = r.Match(expression); m.Success; m = m.NextMatch())
{
      currency = (m.Groups[1].Value);
      break;
}
return currency;

The intension is that, after the first match in the loop it should break.

The warning messge(Unreachable code) is happening  m = m.NextMatch() of the loop.

How to overcome this?

Thanks

Body:
Your code is currently broken, basically. You're really never going to execute m = m.NextMatch(), so why have it?

I think you want:

Regex r = new Regex(@"~(\w*[a-zA-Z0-9$£~%]+)",
                    RegexOptions.IgnoreCase | RegexOptions.Compiled);

Match m = r.Match(expression);
string currency = m.Success ? m.Groups[1].Value : "";

Personally I think this is rather clearer, in terms of what the final version of "currency" is.


问:
Every time edit build.gradle file Android studio will frozen
I am using Android studio 3.1 Canary 3 with gradle 4.3.1. It's very slow for me to visit maven.org, but when I edit build.gradle file in Android studio, it will send request to search.maven.org. As a result I must wait a minute or more for Android studio to response after edit build.gadle file, can anyone known how to fix it, I already try follow suggest:

1、Install Google Repository and Android support repository,

2、Set http and https proxy,

Setting http and https proxy works for me but still it is slow. While installing repository doesn't work at all, as the package is already installed before. So, I think preventing Android studio from sending request to search.maven.org is a good idea. If anyone known how to fix it, please let me known, thanks in advance.

答:
It seems that this issue mainly happens in China. Every time when we edit build.gradle file Android studio will send request to search.maven.org then frozen and after the server response the request Android studio will unfrozen. So add 127.0.0.1 search.maven.org to hosts file can solve this issue, but sometimes we also need to visit search.maven.org.

For me, I am using Chrome with SwitchyOmega plugin installed so I first add 127.0.0.1 search.maven.org to /etc/hosts then add pac rule for this site in Chrome and I find everything work fine, Android studio will not frozen and I still can visit search.maven.org.


问:
v-if for surrounding element
Let's say I have the following case

```<code><div class="entry">
  <img src="image1.png">
</div>
<div class="entry">
  <a href="#mylink">
    <img src="image2.png">
  </a>
</div>
</code>```

Now, items needs to be iterated, using  depending on a condition:

```<code><div class="entry" v-for="o in items">
  <a :href="o.url" v-if="o.url != ''">
    <img :src="o.image">
  </a>
  <img :src="o.image" v-else>
</div>
</code>```

With items = [{url: '', image: 'image1.png'}, {url: '#mylink', image: 'image2.png'}] this will correctly render to the same snippet from above:

```<code><div class="entry">
  <img src="image1.png">
</div>
<div class="entry">
  <a href="#mylink">
    <img src="image2.png">
  </a>
</div>
</code>```

But as you can see, I'm copy-pasting the  tag for the v-if directive. In this case I guess it's simple enough, but I want to know if there a more DRY approach.

I'm looking for something like:

```<code><div class="entry" v-for="o in items">
  <a :href="o.url" v-if-always-render-children="o.url != ''">
    <img :src="o.image">
  </a>
</div>
</code>```

Which should render to the same snippet. Of course the directive v-if-always-render-children doesn't exists.

How to avoid declaring the  tag (and possible children tags) more than once?

答:
v-else is fine, if you're really concerned about it and are worried about the size of the content, then make that content a component.

alternatively you can use render functions or jsx, but unless this thing gets quite a bit more complex, v-else is just fine

Title: v-if for surrounding element

Body:
Let's say I have the following case

Now, items needs to be iterated, using  depending on a condition:

With items = [{url: '', image: 'image1.png'}, {url: '#mylink', image: 'image2.png'}] this will correctly render to the same snippet from above:

But as you can see, I'm copy-pasting the  tag for the v-if directive. In this case I guess it's simple enough, but I want to know if there a more DRY approach.

I'm looking for something like:

Which should render to the same snippet. Of course the directive v-if-always-render-children doesn't exists.

How to avoid declaring the  tag (and possible children tags) more than once?


问:
React and react-router. If I create a component it calls render(). If not a component it is good without render(). It's crazy
Here is the link to Sandbox

I have simple code like this:

Sidebar.js:

```<code>import React, { Component } from "react";
import { BrowserRouter as Router, Route, NavLink } from "react-router-dom";

import Menu from "./Menu";

class SidebarExample extends Component {
  render() {
    console.log("Sidebar - render()", new Date());
    return (
      <Router>
        <div>
          <div>
            If I uncomment the below component Menu the render() method of the component is called everytime I change the link. Why? In the Menu component the is the same html code below. What is going on?
            {/*<Menu />*/}
            <ul>
              <li>
                <NavLink exact to="/">
                  Home
                </NavLink>
              </li>
              <li>
                <NavLink to="/bubblegum">Bubblegum</NavLink>
              </li>
              <li>
                <NavLink to="/shoelaces">Shoelaces</NavLink>
              </li>
            </ul>
          </div>
        </div>
      </Router>
    );
  }
}

export default SidebarExample;
</code>```

Menu.js:

```<code>import React, { Component } from "react";
import { NavLink } from "react-router-dom";

class Menu extends Component {
  render() {
    console.log("Menu - render()", new Date());
    return (
      <ul>
        <li>
          <NavLink exact to="/">
            Home
          </NavLink>
        </li>
        <li>
          <NavLink to="/bubblegum">Bubblegum</NavLink>
        </li>
        <li>
          <NavLink to="/shoelaces">Shoelaces</NavLink>
        </li>
      </ul>
    );
  }
}

export default Menu;
</code>```

If I uncomment the  component the render() method of the component is called everytime I change the link. Why? In the Menu component there is the same html code below.

What is going on?

I'm loosing my mind!

答:
After testing this out for a while...I've come to the conclusion that the render() function, at least for v4, will apparently always run on route change...and technically, it has to run always in case there are routers in the child component.

However, just because render() is running on every route change, does not mean the actual component is being rebuilt. This is more apparent when you try to console log within componentDidMount(), componentWillUnmount(), or even the constructor().

Here's a test with that conclusion: https://codesandbox.io/s/oxz8j04vnz

Body:
Here is the link to Sandbox

I have simple code like this:

Sidebar.js:

import React, { Component } from "react";
import { BrowserRouter as Router, Route, NavLink } from "react-router-dom";

import Menu from "./Menu";

class SidebarExample extends Component {
  render() {
    console.log("Sidebar - render()", new Date());
    return (
      <Router>

            If I uncomment the below component Menu the render() method of the component is called everytime I change the link. Why? In the Menu component the is the same html code below. What is going on?
            {/*<Menu />*/}

                <NavLink exact to="/">
                  Home
                </NavLink>

                <NavLink to="/bubblegum">Bubblegum</NavLink>

                <NavLink to="/shoelaces">Shoelaces</NavLink>

      </Router>
    );
  }
}

export default SidebarExample;

Menu.js:

import React, { Component } from "react";
import { NavLink } from "react-router-dom";

class Menu extends Component {
  render() {
    console.log("Menu - render()", new Date());
    return (

          <NavLink exact to="/">
            Home
          </NavLink>

          <NavLink to="/bubblegum">Bubblegum</NavLink>

          <NavLink to="/shoelaces">Shoelaces</NavLink>

    );
  }
}

export default Menu;

If I uncomment the  component the render() method of the component is called everytime I change the link. Why? In the Menu component there is the same html code below.

What is going on?

I'm loosing my mind!


问:
Metadata version mismatch with Angular 4
I am working on Angular 4 application and getting below error with "npm start" command -

ERROR in Metadata version mismatch for module
  C:/gitRepo/gmdias/gmdais-frontend/node_modules/@angular/animations/browser/browser.d.ts,
  found version 4, expected 3, resolving symbol ɵf in
  C:/gitRepo/gmdias/gmdais-frontend/node_modules/@angular/platform-browser/animations/index.d.ts,
  resolving symbol BrowserAnimationsModule in
  C:/gitRepo/gmdias/gmdais-frontend/node_modules/@angular/platform-browser/animations/index.d.ts,
  resolving symbol BrowserAnimationsModule in
  C:/gitRepo/gmdias/gmdais-frontend/node_modules/@angular/platform-browser/animations/index.d.ts

here is my package.json file

```<code>{
  "name": "nucleus-web",
  "version": "1.0.0",
  "license": "MIT",
  "scripts": {
    "transpile": "ngc",
    "package": "rollup -c",
    "minify": "uglifyjs dist/bundles/datatable.umd.js --screw-ie8 --compress --mangle --comments --output dist/bundles/datatable.min.js",
    "build": "npm run transpile && npm run package && npm run minify && ng build",
    "ng": "ng",
    "start": "ng serve",
    "postinstall": "ng build",
    "test": "sh build.sh"
  },
  "private": true,
  "peerDependencies": {
    "@angular/core": "^4.0.1"
  },
  "dependencies": {
    "@angular/animations": "^5.0.0",
    "@angular/cdk": "^2.0.0-beta.12",
    "@angular/common": "^4.0.1",
    "@angular/compiler": "^4.0.0",
    "@angular/core": "^4.0.1",
    "@angular/forms": "^4.0.1",
    "@angular/http": "^4.0.0",
    "@angular/material": "^2.0.0-beta.12",
    "@angular/platform-browser": "^4.2.5",
    "@angular/platform-browser-dynamic": "^4.0.1",
    "@angular/platform-server": "^4.4.4",
    "@angular/router": "^4.0.0",
    "@ng-bootstrap/ng-bootstrap": "^1.0.0-beta.5",
    "bootstrap": "3.3.7",
    "core-js": "^2.4.1",
    "font-awesome": "^4.7.0",
    "jquery": "^3.2.1",
    "lodash": "^4.17.4",
    "ng2-file-upload": "^1.2.1",
    "ng2-toastr": "^4.1.2",
    "ngx-bootstrap": "^1.7.1",
    "ngx-treeview": "1.2.3",
    "ngx-webstorage": "^1.8.0",
    "rxjs": "^5.1.0",
    "zone.js": "^0.8.12"
  },
  "devDependencies": {
    "@angular/cli": "1.0.3",
    "@types/jasmine": "2.5.38",
    "@types/jquery": "^3.2.15",
    "@types/node": "~8.0.33",
    "codelyzer": "~2.0.0",
    "jasmine-core": "~2.5.2",
    "jasmine-spec-reporter": "~3.2.0",
    "karma": "~1.4.1",
    "karma-chrome-launcher": "~2.1.1",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^0.2.0",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.1.0",
    "ts-node": "~3.3.0",
    "tslint": "~4.5.0",
    "@angular/compiler": "^4.4.4",
    "@angular/compiler-cli": "^4.4.4",
    "rollup": "^0.50.0",
    "typescript": "^2.5.3",
    "uglify-js": "^3.1.3"
  },
  "repository": {
    "type": "git",
    "url": "ssh://git@stash.aexp.com/stash/scm/pzn/gmdais-frontend.git"
  }
}
</code>```

答: I got the same problem when updating angular from 4 to 5. The problem was that I updated only my prod dependencies but I forgot to update my dev dependencies too.</p>

Body:
I am working on Angular 4 application and getting below error with "npm start" command -

ERROR in Metadata version mismatch for module
  C:/gitRepo/gmdias/gmdais-frontend/node_modules/@angular/animations/browser/browser.d.ts,
  found version 4, expected 3, resolving symbol ɵf in
  C:/gitRepo/gmdias/gmdais-frontend/node_modules/@angular/platform-browser/animations/index.d.ts,
  resolving symbol BrowserAnimationsModule in
  C:/gitRepo/gmdias/gmdais-frontend/node_modules/@angular/platform-browser/animations/index.d.ts,
  resolving symbol BrowserAnimationsModule in
  C:/gitRepo/gmdias/gmdais-frontend/node_modules/@angular/platform-browser/animations/index.d.ts

here is my package.json file

{
  "name": "nucleus-web",
  "version": "1.0.0",
  "license": "MIT",
  "scripts": {
    "transpile": "ngc",
    "package": "rollup -c",
    "minify": "uglifyjs dist/bundles/datatable.umd.js --screw-ie8 --compress --mangle --comments --output dist/bundles/datatable.min.js",
    "build": "npm run transpile && npm run package && npm run minify && ng build",
    "ng": "ng",
    "start": "ng serve",
    "postinstall": "ng build",
    "test": "sh build.sh"
  },
  "private": true,
  "peerDependencies": {
    "@angular/core": "^4.0.1"
  },
  "dependencies": {
    "@angular/animations": "^5.0.0",
    "@angular/cdk": "^2.0.0-beta.12",
    "@angular/common": "^4.0.1",
    "@angular/compiler": "^4.0.0",
    "@angular/core": "^4.0.1",
    "@angular/forms": "^4.0.1",
    "@angular/http": "^4.0.0",
    "@angular/material": "^2.0.0-beta.12",
    "@angular/platform-browser": "^4.2.5",
    "@angular/platform-browser-dynamic": "^4.0.1",
    "@angular/platform-server": "^4.4.4",
    "@angular/router": "^4.0.0",
    "@ng-bootstrap/ng-bootstrap": "^1.0.0-beta.5",
    "bootstrap": "3.3.7",
    "core-js": "^2.4.1",
    "font-awesome": "^4.7.0",
    "jquery": "^3.2.1",
    "lodash": "^4.17.4",
    "ng2-file-upload": "^1.2.1",
    "ng2-toastr": "^4.1.2",
    "ngx-bootstrap": "^1.7.1",
    "ngx-treeview": "1.2.3",
    "ngx-webstorage": "^1.8.0",
    "rxjs": "^5.1.0",
    "zone.js": "^0.8.12"
  },
  "devDependencies": {
    "@angular/cli": "1.0.3",
    "@types/jasmine": "2.5.38",
    "@types/jquery": "^3.2.15",
    "@types/node": "~8.0.33",
    "codelyzer": "~2.0.0",
    "jasmine-core": "~2.5.2",
    "jasmine-spec-reporter": "~3.2.0",
    "karma": "~1.4.1",
    "karma-chrome-launcher": "~2.1.1",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^0.2.0",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.1.0",
    "ts-node": "~3.3.0",
    "tslint": "~4.5.0",
    "@angular/compiler": "^4.4.4",
    "@angular/compiler-cli": "^4.4.4",
    "rollup": "^0.50.0",
    "typescript": "^2.5.3",
    "uglify-js": "^3.1.3"
  },
  "repository": {
    "type": "git",
    "url": "ssh://git@stash.aexp.com/stash/scm/pzn/gmdais-frontend.git"
  }
}


问:
Ionic2 select text in ion-searchbar
In an ion-input focus event we can select all the text like this

```<code><ion-input (focus)="selectAll($event)></ion-input>
</code>```

But in an ion-searchbar it does not work:

```<code><ion-searchbar (focus)="selectAll($event)></ion-searchbar>
</code>```

The selectAll() code would be:

```<code>public selectAll(event): void {
    event.target.select();
}
</code>```

I have seen in ionic's Github that the input component returns a FocusEvent:

```<code>inputFocused(event) {
  this.focus.emit(event);
}
</code>```

On the other hand the ion-searchbar returns a searchbar (this):

```<code>inputFocused() {
  this.focus.emit(this);

  this.isFocused = true;
  this.shouldLeftAlign = true;
  this.setElementLeft();
}
</code>```

Why does it not return a FocusEvent too? How can we select all the text in an ion-searchbar when it is focused?

Thank you

答:
for ion-searchbar to use:

```<code><ion-searchbar click="selectAll($event)"></ion-searchbar>

selectAll(event){
   event.target.select();
}
</code>```

Title: Ionic2 select text in ion-searchbar

Body:
In an ion-input focus event we can select all the text like this

<ion-input (focus)="selectAll($event)></ion-input>

But in an ion-searchbar it does not work:

<ion-searchbar (focus)="selectAll($event)></ion-searchbar>

The selectAll() code would be:

public selectAll(event): void {
    event.target.select();
}

I have seen in ionic's Github that the input component returns a FocusEvent:

inputFocused(event) {
  this.focus.emit(event);
}

On the other hand the ion-searchbar returns a searchbar (this):

inputFocused() {
  this.focus.emit(this);

  this.isFocused = true;
  this.shouldLeftAlign = true;
  this.setElementLeft();
}

Why does it not return a FocusEvent too? How can we select all the text in an ion-searchbar when it is focused?

Thank you

Body:
for ion-searchbar to use:

<ion-searchbar click="selectAll($event)"></ion-searchbar>

selectAll(event){
   event.target.select();
}


问:
Do I need to lock before read a shared variable?
I'm totally new to multiple processes/threads programming in C, i understand that if one process needs to modify a shared variable, it needs to lock before doing so.

If one process needs to read a shared variable, does it need to lock ?

答:
If that variable can be changed by another thread or process, then yes.  If you have a lot of reading processes/threads, you may consider implementing a read-write lock that allows many readers to access at once.

Depending on what exactly you are doing, you may also want to look into atomics as they do not require the use of locks.

https://en.cppreference.com/w/c/language/atomic

ContentLicense: CC BY-SA 4.0


问:
Manage NuGet Packages dialog missing VS2017
I discovered after opening a project I wrote 2 months ago, that the "Manage NuGet Packages" dialog when right-clicking a project is missing after the latest Visual Studio 2017 update version  15.4.4
Is this a bug? Or is MS ditching NuGet?

Regardless, if not a bug or abandonment, how do I get this option back?

I see the Manage Bower Packages as the only option (2 months ago both options were in the drop down).

答:
Manage NuGet Packages dialog missing VS2017

According to some of your own troubleshootings, it seems your Visual Studio/NuGet is corrupt.

So you can try to open the Visual Studio Installer, then navigate to individual components tab, find the checkbox NuGet Package manager, remove it by uncheck that checkbox. Reinstall this component again.

If reinstall NuGet Package manager not help you, you can try to repair your Visual Studio or reinstall Visual Studio.


问:
iPhone App Icons - Exact Radius?
I'm trying to create the icon for my iPhone app, but don't know how to get the exact radius that the iPhone's icons use. I've searched and searched for a tutorial or a template but can't find one.

I'm sure that I'm just a moron, but how do you get the rounded corners exactly right with your icon from Illustrator or Photoshop?

Edit:

What's the radius for the Retina iPad?

答:
People arguing about the corner radius being slightly increased but actually that's not the case.

From this blog:

A ‘secret’ of Apple’s physical products is that they avoid tangency (where a radius meets a line at a single point) and craft their surfaces with what’s called curvature continuity.

You don't need to apply corner radius to icons for iOS. Just provide square icons. But if you still want to know how, the actual shape is called Squircle and below is the formula:

Title: iPhone App Icons - Exact Radius?


问:
Finding Median in Sql Server
I want to get the median of unitRate from [dbo].[ReplaceCost_DirectCost_Details] view in Microsoft Sql Server Management Studio. I already got Min,Max and avg of it.But do not know about median. I tried following code, but did not get median .Thanks in advacen for your help.

 select
        JobName as JobName
       ,Client as Client
       ,AssetClass as AssetClass
       ,AssetType as AssetType
       ,AssetSubType as AssetSubType
       ,Component as Component
       ,ComponentType as ComponentType
       ,ComponentSubType as ComponentSubType
       ,UnitRate AS UnitRate
       ,Max(UnitRate) over (partition by JobName,Client,AssetClass,AssetType,AssetSubType,Component,ComponentType,ComponentSubType) as [MaxFinalUnitRate]
       ,Min(UnitRate) over (partition by JobName,Client,AssetClass,AssetType,AssetSubType,Component,ComponentType,ComponentSubType)  as [MinFinalUnitRate]
       ,AVG(UnitRate) over (partition by JobName,Client,AssetClass,AssetType,AssetSubType,Component,ComponentType,ComponentSubType) as [MeanFinalUnitRate]
       ,AVG (UnitRate)  over (partition by JobName,Client,AssetClass,AssetType,AssetSubType,Component,ComponentType,ComponentSubType)as Median
       from
        (
         Select top (10)
        JobName as JobName
       ,Client as Client
       ,AssetClass as AssetClass
       ,AssetType as AssetType
       ,AssetSubType as AssetSubType
       ,Component as Component
       ,ComponentType as ComponentType
       ,ComponentSubType as ComponentSubType
       ,UnitRate AS UnitRate
       ,ROW_NUMBER () over (partition by JobName,Client,AssetClass,AssetType,AssetSubType,Component,ComponentType,ComponentSubType order by UnitRate) as [RowNum]
       ,COUNT(*) OVER (PARTITION BY JobName,Client,AssetClass,AssetType,AssetSubType,Component,ComponentType,ComponentSubType ) AS RowCnt

     from [dbo].[ReplaceCost_DirectCost_Details] rdd
     where  client = 'APV_Ballina_Shire_Council_Old'  and  UnitRate is not Null and UnitRate <> 0
       ) x
       WHERE   RowNum IN ((RowCnt + 1) / 2, (RowCnt + 2) / 2)
```

答:
(sorry for using a second answer, but it will get lost if just added to the earlier one)

I am really not certain what the expected output of your query is. But I note that you are using TOP(10) and for that to work you must have an order by otherwise the result is indeterminate for the first 10 rows.

While the following may produce many more rows than you need, perhaps it will help lead to a solution.

```<code>WITH Basis as (
      SELECT
            JobName
          , Client
          , AssetClass
          , AssetType
          , AssetSubType
          , Component
          , ComponentType
          , ComponentSubType
          , UnitRate
          , ROW_NUMBER() OVER (PARTITION BY JobName, Client, AssetClass, AssetType, AssetSubType, Component, ComponentType, ComponentSubType
                               ORDER BY UnitRate)
            AS [rownum]
      FROM [dbo].[ReplaceCost_DirectCost_Details] rdd
      WHERE client = 'APV_Ballina_Shire_Council_Old'
      AND UnitRate IS NOT NULL
      AND UnitRate <> 0
     )
, Top10s as (
      SELECT
            JobName
          , Client
          , AssetClass
          , AssetType
          , AssetSubType
          , Component
          , ComponentType
          , ComponentSubType
          , UnitRate
          , rownum
          , COUNT(*) OVER (PARTITION BY JobName, Client, AssetClass, AssetType, AssetSubType, Component, ComponentType, ComponentSubType)
            AS rowcnt
      FROM Basis
      WHERE rownum <= 10
      )
, Medians as (
      SELECT
            JobName
          , Client
          , AssetClass
          , AssetType
          , AssetSubType
          , Component
          , ComponentType
          , ComponentSubType
          , AVG(UnitRate) AS Median
      FROM Top10s
      WHERE RowNum IN ((RowCnt + 1) / 2, (RowCnt + 2) / 2)
      GROUP BY
            JobName
          , Client
          , AssetClass
          , AssetType
          , AssetSubType
          , Component
          , ComponentType
          , ComponentSubType
          , AVG(UnitRate)
      )
SELECT
      JobName
    , Client
    , AssetClass
    , AssetType
    , AssetSubType
    , Component
    , ComponentType
    , ComponentSubType
    , UnitRate
    , rownum
    , rowcnt
    , MAX(UnitRate) OVER (PARTITION BY JobName, Client, AssetClass, AssetType, AssetSubType, Component, ComponentType, ComponentSubType) AS [maxfinalunitrate]
    , MIN(UnitRate) OVER (PARTITION BY JobName, Client, AssetClass, AssetType, AssetSubType, Component, ComponentType, ComponentSubType) AS [minfinalunitrate]
    , AVG(UnitRate) OVER (PARTITION BY JobName, Client, AssetClass, AssetType, AssetSubType, Component, ComponentType, ComponentSubType) AS [meanfinalunitrate]
    , Medians.Median
FROM Top10s t
JOIN Medians m ON t.JobName = m.JobName
    AND t.Client = m.Client
    AND t.AssetClass = m.AssetClass
    AND t.AssetType = m.AssetType
    AND t.AssetSubType = m.AssetSubType
    AND t.Component = m.Component
    AND t.ComponentType = m.ComponentType
    AND t.ComponentSubType = m.ComponentSubType
;
</code>```

Title: Finding Median in Sql Server

Body:
(sorry for using a second answer, but it will get lost if just added to the earlier one)

I am really not certain what the expected output of your query is. But I note that you are using TOP(10) and for that to work you must have an order by otherwise the result is indeterminate for the first 10 rows.

While the following may produce many more rows than you need, perhaps it will help lead to a solution.

WITH Basis as (
      SELECT
            JobName
          , Client
          , AssetClass
          , AssetType
          , AssetSubType
          , Component
          , ComponentType
          , ComponentSubType
          , UnitRate
          , ROW_NUMBER() OVER (PARTITION BY JobName, Client, AssetClass, AssetType, AssetSubType, Component, ComponentType, ComponentSubType
                               ORDER BY UnitRate)
            AS [rownum]
      FROM [dbo].[ReplaceCost_DirectCost_Details] rdd
      WHERE client = 'APV_Ballina_Shire_Council_Old'
      AND UnitRate IS NOT NULL
      AND UnitRate <> 0
     )
, Top10s as (
      SELECT
            JobName
          , Client
          , AssetClass
          , AssetType
          , AssetSubType
          , Component
          , ComponentType
          , ComponentSubType
          , UnitRate
          , rownum
          , COUNT(*) OVER (PARTITION BY JobName, Client, AssetClass, AssetType, AssetSubType, Component, ComponentType, ComponentSubType)
            AS rowcnt
      FROM Basis
      WHERE rownum <= 10
      )
, Medians as (
      SELECT
            JobName
          , Client
          , AssetClass
          , AssetType
          , AssetSubType
          , Component
          , ComponentType
          , ComponentSubType
          , AVG(UnitRate) AS Median
      FROM Top10s
      WHERE RowNum IN ((RowCnt + 1) / 2, (RowCnt + 2) / 2)
      GROUP BY
            JobName
          , Client
          , AssetClass
          , AssetType
          , AssetSubType
          , Component
          , ComponentType
          , ComponentSubType
          , AVG(UnitRate)
      )
SELECT
      JobName
    , Client
    , AssetClass
    , AssetType
    , AssetSubType
    , Component
    , ComponentType
    , ComponentSubType
    , UnitRate
    , rownum
    , rowcnt
    , MAX(UnitRate) OVER (PARTITION BY JobName, Client, AssetClass, AssetType, AssetSubType, Component, ComponentType, ComponentSubType) AS [maxfinalunitrate]
    , MIN(UnitRate) OVER (PARTITION BY JobName, Client, AssetClass, AssetType, AssetSubType, Component, ComponentType, ComponentSubType) AS [minfinalunitrate]
    , AVG(UnitRate) OVER (PARTITION BY JobName, Client, AssetClass, AssetType, AssetSubType, Component, ComponentType, ComponentSubType) AS [meanfinalunitrate]
    , Medians.Median
FROM Top10s t
JOIN Medians m ON t.JobName = m.JobName
    AND t.Client = m.Client
    AND t.AssetClass = m.AssetClass
    AND t.AssetType = m.AssetType
    AND t.AssetSubType = m.AssetSubType
    AND t.Component = m.Component
    AND t.ComponentType = m.ComponentType
    AND t.ComponentSubType = m.ComponentSubType
;


问:
Entity Framework 4: How to enforce WHERE clause order in generated query
Assume the following table MyObjects:

```<code>Id (PK, int)
DecimalField (decimal)
TextField (nvarchar)
</code>```

I have put an additional index on DecimalField.

Consider the following LINQ to Entities query to retrieve an object:

```<code>db.MyObjects.FirstOrDefault(r => r.DecimalField == localValue1 && r.TextField == localValue2)
</code>```

Because of the index, it is important that the EF-generated query keeps the order of the properties in the WHERE clause the same (i.e. DecimalField first and TextField second), otherwise a table scan will occur and the index is useless. How can I enforce EF to keep a certain order in the WHERE clause? And is there a difference between ad hoc and compiled queries?

答: No, the order of where clause predicates does not matter. SQL Server will use the appropriate index if there is one, even if your where clause specifies the columns in a different order than they appear in the index.</p>

Body:
Assume the following table MyObjects:

Id (PK, int)
DecimalField (decimal)
TextField (nvarchar)

I have put an additional index on DecimalField.

Consider the following LINQ to Entities query to retrieve an object:

db.MyObjects.FirstOrDefault(r => r.DecimalField == localValue1 && r.TextField == localValue2)

Because of the index, it is important that the EF-generated query keeps the order of the properties in the WHERE clause the same (i.e. DecimalField first and TextField second), otherwise a table scan will occur and the index is useless. How can I enforce EF to keep a certain order in the WHERE clause? And is there a difference between ad hoc and compiled queries?


问:
Tar is not working in termux while extracting .tar.gz file
I have success fully installed Ubuntu proot in termux (Android App) but I m trying to reinstall Ubuntu proot amd I don't know how and why ....tar is giving error while extracting Ubuntu.tar.gz file.
Error is :-

```<code>tar: bin/rbash: Cannot change mode to rwxrwxrwx: No such file or directory tar: bin/ypdomainname: Cannot change mode to rwxrwxrwx: No such file or directory
</code>```

I m using android v5.1.1 aarch64, plz help me.

答: Solved by replacing tar with bsdtar</p>

Body:
I have success fully installed Ubuntu proot in termux (Android App) but I m trying to reinstall Ubuntu proot amd I don't know how and why ....tar is giving error while extracting Ubuntu.tar.gz file.
Error is :-

tar: bin/rbash: Cannot change mode to rwxrwxrwx: No such file or directory tar: bin/ypdomainname: Cannot change mode to rwxrwxrwx: No such file or directory

I m using android v5.1.1 aarch64, plz help me.

Body: Solved by replacing tar with bsdtar


问:
Swift 3.0 Dynamically Change Font of a Label
I am using a label to display text that the user has entered so the length of the label is variable. I am wondering if there is a way to dynamically change the font size of my text. Currently, I have constraint the vertical length of the label to 120, and checked off the "Automatically Adjust Font" in the Attributes Inspector but it doesn't scale it like I want. Not sure whether this is a programmatic or design method to do this.

Here's an example of the text being cut off:

答:
you can try, eg:

```<code>autoshrink -> minimum font scale -> 0.7
</code>```

Body:
you can try, eg:

autoshrink -> minimum font scale -> 0.7


问:
How to load local JS file with nuxt
I have multiples script in my folder /assets/js.
I added them to nuxt.config.js like that:

```<code>script: [
  { src: 'https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js' },
  { src: '~assets/js/bootstrap.min.js' },
  { src: '~assets/js/retina-1.1.0.js' },
  { src: '~assets/js/jquery.hoverdir.js' },
  { src: '~assets/js/jquery.hoverex.min.js' },
  { src: '~assets/js/jquery.prettyPhoto.js' },
  { src: '~assets/js/jquery.isotope.min.js' },
  { src: '~assets/js/custom.js' }
],
</code>```

There is no problem for the first one but for the local files none are loading.
I tried :
'@/assets', '/assets', 'js/', '~/assets', etc but nothing is working.

I always get this error:

```<code>GET http://localhost:3000/~assets/js/custom.js net::ERR_ABORTED
</code>```

So how can I load my files please ?
Thank you

答:
Try to put the JS files in the root of the assets directory. Otherwise, you need to create a static directory.
I hope this helps.

In your nuxt.config.js

```<code>head: {
    link: [{
        rel: 'icon',
        type: 'image/x-icon',
        href: '/favicon.png'
    }],
    script: [
        {
            type: 'text/javascript',
            src: 'js/jquery.min.js',
            body: true
        },
        {
            type: 'text/javascript',
            src: 'js/script.js',
            body: true
        }
    ]
}
</code>```

Title: How to load local JS file with nuxt

Body:
I have multiples script in my folder /assets/js.
I added them to nuxt.config.js like that:

script: [
  { src: 'https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js' },
  { src: '~assets/js/bootstrap.min.js' },
  { src: '~assets/js/retina-1.1.0.js' },
  { src: '~assets/js/jquery.hoverdir.js' },
  { src: '~assets/js/jquery.hoverex.min.js' },
  { src: '~assets/js/jquery.prettyPhoto.js' },
  { src: '~assets/js/jquery.isotope.min.js' },
  { src: '~assets/js/custom.js' }
],

There is no problem for the first one but for the local files none are loading.
I tried :
'@/assets', '/assets', 'js/', '~/assets', etc but nothing is working.

I always get this error:

GET http://localhost:3000/~assets/js/custom.js net::ERR_ABORTED

So how can I load my files please ?
Thank you

Body:
Try to put the JS files in the root of the assets directory. Otherwise, you need to create a static directory.
I hope this helps.

In your nuxt.config.js

head: {
    link: [{
        rel: 'icon',
        type: 'image/x-icon',
        href: '/favicon.png'
    }],
    script: [
        {
            type: 'text/javascript',
            src: 'js/jquery.min.js',
            body: true
        },
        {
            type: 'text/javascript',
            src: 'js/script.js',
            body: true
        }
    ]
}


问:
Unit test request-promise, promise() is not a function
I am trying to unit test this function with sinon/mocha which uses request-promise. I attach the .promise() to allow access to all the Bluebird promise methods.

According to the request-promise readme:

```<code>rp(...).promise() or e.g. rp.head(...).promise() which returns the underlying promise so you can access the full Bluebird API
</code>```

myModule.js
    var requestPromise = require('request-promise');

```<code>function requestWrapper(opts) {
   // Adds .promise() to allow access to Bluebird methods
   return requestPromise(opts).promise();
}

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

Unit test

```<code>var Promise = require('bluebird');
var requestPromise = sinon.stub().returns(Promise.resolve());
var rewire = require('rewire');
var myModule = rewire('./myModule');

myModule.__set__({
  requestPromise: requestPromise
});

describe('myModule', function() {
  var testPromise;

  it('should...', function() {
      testPromise = myModule.requestWrapper({ method: 'GET', url: 'http://someurl.com' })
  });
});
</code>```

Error

I'm getting the following error: TypeError: requestPromise(...).promise is not a function.

答:
You're mocking is wrong (but close).

request-promise is a function that returns an object that has a function promise that returns the underlying promise.

What you've done with your stub & rewire is set request-promise to be a function that returns a promise.

A possible fix:

```<code>var requestPromise = sinon.stub().returns({ promise: () => Promise.resolve() });
</code>```

Body:
I am trying to unit test this function with sinon/mocha which uses request-promise. I attach the .promise() to allow access to all the Bluebird promise methods.

According to the request-promise readme:

rp(...).promise() or e.g. rp.head(...).promise() which returns the underlying promise so you can access the full Bluebird API

myModule.js
    var requestPromise = require('request-promise');

function requestWrapper(opts) {
   // Adds .promise() to allow access to Bluebird methods
   return requestPromise(opts).promise();
}

module.exports = requestWrapper;

Unit test

var Promise = require('bluebird');
var requestPromise = sinon.stub().returns(Promise.resolve());
var rewire = require('rewire');
var myModule = rewire('./myModule');

myModule.__set__({
  requestPromise: requestPromise
});

describe('myModule', function() {
  var testPromise;

  it('should...', function() {
      testPromise = myModule.requestWrapper({ method: 'GET', url: 'http://someurl.com' })
  });
});

Error

I'm getting the following error: TypeError: requestPromise(...).promise is not a function.

Body:
You're mocking is wrong (but close).

request-promise is a function that returns an object that has a function promise that returns the underlying promise.

What you've done with your stub & rewire is set request-promise to be a function that returns a promise.

A possible fix:

var requestPromise = sinon.stub().returns({ promise: () => Promise.resolve() });


问:
making a binary as little as possible
I have a program written in C and linked to a my static library (.a) in C too. How can I make this program as little as possible, without touch the code (I can recompile it etc)?</p>

答: There are a number of executable packers around that do what you want. First, strip any symbols like neuro suggested (if you have symbols compiled in), then use one of these executable packers: http://en.wikipedia.org/wiki/Executable_compression</p>

Title: making a binary as little as possible


问:
How to make that only one radio button can be selected in a repeater?
I am implementing a table in an aspx page using repeater, the table is shown correctly.

In every row of the table I want to add a radio button ( a radio button is selected, means that row is selected), when I execute my program the page showed is the following:

The problem is as you can see in the image is that many radio buttons can be selected at the same time, my purpose is to allow the user to select only one row (one radio button) if a radio button is checked the other shoul be unchekced automatically.

here is my code:

```<code>    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="DotNetRepeater.aspx.cs" Inherits="DotNetRepeater.DotNetRepeater" %>

<script type = "text/javascript">
    function RadioCheck(rb) {
        var gv = document.getElementById("<%=rptCustomers.ClientID%>");
        var rbs = gv.getElementsByTagName("input");

        var row = rb.parentNode.parentNode;
        for (var i = 0; i < rbs.length; i++) {
            if (rbs[i].type == "radio") {
                if (rbs[i].checked && rbs[i] != rb) {
                    rbs[i].checked = false;
                    break;
                }
            }
        }
    }
    </script>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
        body
        {
            font-family: Arial;
            font-size: 10pt;
        }
        table
        {
            border: 1px solid #ccc;
            border-collapse: collapse;
           background-color: #00FF00 ;

        }
        table th
        {
            background-color: #FF0000;
            color: #333;
            font-weight: bold;
        }
        table th, table td
        {
            padding: 5px;
            border: 2px solid black;
        }
        form {
             width: 100%;
             text-align: center;
            height: 371px;
        }
        #Button1 {
             background-color: yellow;
             font-size: 15pt;

            top: 355px;
            left: 800px;
        }
        /*#SelectRadio1{
            left: 461px;*/
        /*}*/
    </style>
</head>
<body>
    <div class="container">
        <form id="form1" runat="server">

        <asp:Repeater ID="rptCustomers" runat="server" OnItemCommand="rptCustomers_ItemCommand">

        <HeaderTemplate>

            <table cellspacing="0" rules="all" border="1"  align="center"; >

                <tr>
                       <th scope="col" style="background-color:white">

                    </th>

                    <th scope="col" style="width: 80px">
                        Name
                    </th>
                    <th scope="col" style="width: 120px">
                        CountryRegionCode
                    </th>
                    <th scope="col" style="width: 100px">
                        Group
                    </th>
                    <th scope="col" style="width: 100px">
                        SalesYTD
                    </th>
                </tr>

        </HeaderTemplate>

        <ItemTemplate>

            <tr >
                <td style="background-color:white">
                     <asp:RadioButton id="Radio1" Checked="False" GroupName="RadioGroup1" runat="server" />
                </td>
                <td>
                    <asp:Label ID="lblName" runat="server" Text='<%# Eval("Name") %>' />
                </td>
                <td>
                    <asp:Label ID="lblCountryRegionCode" runat="server" Text='<%# Eval("CountryRegionCode") %>' />
                </td>
                <td>
                    <asp:Label ID="lblGroup" runat="server" Text='<%# Eval("Group") %>' />
                </td>
                <td>
                    <asp:Label ID="Label1" runat="server" Text='<%# Eval("SalesYTD") %>' />
                </td>

            </tr>

        </ItemTemplate>
        <FooterTemplate>
            </table>
        </FooterTemplate>
    </asp:Repeater>
        <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Submit" Width="82px" />
    </form>
        </div>
</body>
</html>
</code>```

What should I add to the aspx code or to the code behind to make that only one radio button can be selected ?

Any help please ?

答:
To achieve this, it can be approached in two ways. One is client side using javascript (something like @VDWWD's answer) and other is server side as below.</p>

```<code>//Repeater ItemTemplate RadioButton
<asp:RadioButton ID="RadioButton1" runat="server" AutoPostBack="true"
            OnCheckedChanged="RadioButton1_CheckedChanged"/>

//Code Behind
protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
{
//Uncheck all RadioButtons of the rptCustomer
foreach (RepeaterItem item in rptCustomer.Items)
{
    if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem)
    {
        ((RadioButton)item.FindControl("RadioButton1")).Checked = false;
    }
}
//After foreach loop, set current selected checkbox checked
(sender as RadioButton).Checked = true;
}
</code>```

Body:
I am implementing a table in an aspx page using repeater, the table is shown correctly.

In every row of the table I want to add a radio button ( a radio button is selected, means that row is selected), when I execute my program the page showed is the following:

The problem is as you can see in the image is that many radio buttons can be selected at the same time, my purpose is to allow the user to select only one row (one radio button) if a radio button is checked the other shoul be unchekced automatically.

here is my code:

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="DotNetRepeater.aspx.cs" Inherits="DotNetRepeater.DotNetRepeater" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <title></title>

        <form id="form1" runat="server">

        <asp:Repeater ID="rptCustomers" runat="server" OnItemCommand="rptCustomers_ItemCommand">

        <HeaderTemplate>

                        Name

                        CountryRegionCode

                        Group

                        SalesYTD

        </HeaderTemplate>

        <ItemTemplate>

                     <asp:RadioButton id="Radio1" Checked="False" GroupName="RadioGroup1" runat="server" />

                    <asp:Label ID="lblName" runat="server" Text='<%# Eval("Name") %>' />

                    <asp:Label ID="lblCountryRegionCode" runat="server" Text='<%# Eval("CountryRegionCode") %>' />

                    <asp:Label ID="lblGroup" runat="server" Text='<%# Eval("Group") %>' />

                    <asp:Label ID="Label1" runat="server" Text='<%# Eval("SalesYTD") %>' />

        </ItemTemplate>
        <FooterTemplate>

        </FooterTemplate>
    </asp:Repeater>
        <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Submit" Width="82px" />
    </form>

What should I add to the aspx code or to the code behind to make that only one radio button can be selected ?

Any help please ?

Body:
To achieve this, it can be approached in two ways. One is client side using javascript (something like @VDWWD's answer) and other is server side as below.

//Repeater ItemTemplate RadioButton
<asp:RadioButton ID="RadioButton1" runat="server" AutoPostBack="true"
            OnCheckedChanged="RadioButton1_CheckedChanged"/>

//Code Behind
protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
{
//Uncheck all RadioButtons of the rptCustomer
foreach (RepeaterItem item in rptCustomer.Items)
{
    if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem)
    {
        ((RadioButton)item.FindControl("RadioButton1")).Checked = false;
    }
}
//After foreach loop, set current selected checkbox checked
(sender as RadioButton).Checked = true;
}


问:
VBA - Type mismatch on declaration of Excel.Range
I am trying to declare a range of cells as an Excel.Range variable in the BeforeSave() event of  my excel workbook.
The background is, that the values in this range are mandatory inputs and I want to validate that they are all filled on saving.

If I want to execute the function I get the error message

Runtime Error "13": Type Mismatch

Here's the code I tried.

```<code>Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    Dim r1 As Range
    Set r1 = Range("G11:G14")

        If Cells(10, 1).Value = "" Then
            MsgBox "Cell requires user input", vbInformation, "Please filled up the mandatory cells"
            Cancel = True
            Exit Sub
        ElseIf r1.Value = "" Then // runtime error "13": Type Mismatch
            MsgBox "Please make sure you had filled in all the Questionnire Answers.", vbInformation, "Missing Answer"
            Cancel = True
            Exit Sub
        End If
        Cancel = False
End Sub
</code>```

I am relatively new to VBA so please feel free to point out my mistake.
Thanks in advance!

答:
You will get this error:

Runtime Error "13": Type Mismatch

Because r1 is defined as a Range of multiple cells and you cannot check if a multiple-cell Range is simply empty string. You need to check each cell in the range.

Try this code - it is a Function that checks to see if any cell, in a group of cells, is "" and returns True if that is so:

```<code>Option Explicit

Function TestMultipleCellsAnyAreEmpty(rng As Range) As Boolean

    Dim rngCell As Range
    Dim blnAnyRangeIsEmpty

    blnAnyRangeIsEmpty = False

    For Each rngCell In rng
        If rngCell.Value = "" Then
            blnRangeIsEmpty = True
            Exit For
        End If
    Next rngCell

    TestMultipleCellsAreEmpty = blnRangeIsEmpty

End Function
</code>```

Combining this technique with your workbook event you can have this complete code:

```<code>Option Explicit

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    Dim r1 As Range
    Set r1 = ThisWorkbook.Worksheets("YOUR_SHEET").Range("G11:G14") '<-- specify the worksheet

    If ThisWorkbook.Worksheets("YOUR_SHEET").Cells(10, 1).Value = "" Then '<-- specify the worksheet
        MsgBox "Cell requires user input", vbInformation, "Please filled up the mandatory cells"
        Cancel = True
        Exit Sub
    ElseIf TestMultipleCellsAnyAreEmpty(r1) Then
        MsgBox "Please make sure you had filled in all the Questionnire Answers.", vbInformation, "Missing Answer"
        Cancel = True
        Exit Sub
    End If
    Cancel = False

End Sub

Function TestMultipleCellsAnyAreEmpty(rng As Range) As Boolean

    Dim rngCell As Range
    Dim blnAnyRangeIsEmpty

    blnAnyRangeIsEmpty = False

    For Each rngCell In rng
        If rngCell.Value = "" Then
            blnRangeIsEmpty = True
            Exit For
        End If
    Next rngCell

    TestMultipleCellsAreEmpty = blnRangeIsEmpty

End Function
</code>```

Body:
I am trying to declare a range of cells as an Excel.Range variable in the BeforeSave() event of  my excel workbook.
The background is, that the values in this range are mandatory inputs and I want to validate that they are all filled on saving.

If I want to execute the function I get the error message

Runtime Error "13": Type Mismatch

Here's the code I tried.

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    Dim r1 As Range
    Set r1 = Range("G11:G14")

        If Cells(10, 1).Value = "" Then
            MsgBox "Cell requires user input", vbInformation, "Please filled up the mandatory cells"
            Cancel = True
            Exit Sub
        ElseIf r1.Value = "" Then // runtime error "13": Type Mismatch
            MsgBox "Please make sure you had filled in all the Questionnire Answers.", vbInformation, "Missing Answer"
            Cancel = True
            Exit Sub
        End If
        Cancel = False
End Sub

I am relatively new to VBA so please feel free to point out my mistake.
Thanks in advance!

Body:
You will get this error:

Runtime Error "13": Type Mismatch

Because r1 is defined as a Range of multiple cells and you cannot check if a multiple-cell Range is simply empty string. You need to check each cell in the range.

Try this code - it is a Function that checks to see if any cell, in a group of cells, is "" and returns True if that is so:

Option Explicit

Function TestMultipleCellsAnyAreEmpty(rng As Range) As Boolean

    Dim rngCell As Range
    Dim blnAnyRangeIsEmpty

    blnAnyRangeIsEmpty = False

    For Each rngCell In rng
        If rngCell.Value = "" Then
            blnRangeIsEmpty = True
            Exit For
        End If
    Next rngCell

    TestMultipleCellsAreEmpty = blnRangeIsEmpty

End Function

Combining this technique with your workbook event you can have this complete code:

Option Explicit

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    Dim r1 As Range
    Set r1 = ThisWorkbook.Worksheets("YOUR_SHEET").Range("G11:G14") '<-- specify the worksheet

    If ThisWorkbook.Worksheets("YOUR_SHEET").Cells(10, 1).Value = "" Then '<-- specify the worksheet
        MsgBox "Cell requires user input", vbInformation, "Please filled up the mandatory cells"
        Cancel = True
        Exit Sub
    ElseIf TestMultipleCellsAnyAreEmpty(r1) Then
        MsgBox "Please make sure you had filled in all the Questionnire Answers.", vbInformation, "Missing Answer"
        Cancel = True
        Exit Sub
    End If
    Cancel = False

End Sub

Function TestMultipleCellsAnyAreEmpty(rng As Range) As Boolean

    Dim rngCell As Range
    Dim blnAnyRangeIsEmpty

    blnAnyRangeIsEmpty = False

    For Each rngCell In rng
        If rngCell.Value = "" Then
            blnRangeIsEmpty = True
            Exit For
        End If
    Next rngCell

    TestMultipleCellsAreEmpty = blnRangeIsEmpty

End Function


问:
Angular - Change css using ng-style
I am trying to change top position of a DIV on Scroll event -

In controller i have-

```<code>    angular.element($window).on("scroll", function(e) {
        vm.scrollTop = angular.element($window).scrollTop()+'px';
        console.log(vm.scrollTop);
    });
</code>```

In html -

```<code><div ng-style="{'top': vm.scrollTop}">
    Hello World
</div>
</code>```

On scroll event is printing scrollTop values in console but "Div" style never gets updated.

Please correct me if this is syntactically incorrect.

答:
You can use $scope.$apply or $scope.$watch.

Here's snippet using $scope.$apply.

function TodoCtrl($scope, $document, $window) {
   $scope.scrollTop = 30;
     $document.bind('scroll', function(){
        $scope.$apply(function(){
   $scope.scrollTop = $window.scrollY;
      });
   });
   $scope.getStyle = function(){
        var styles = {}
        styles['margin-top'] = $scope.scrollTop + 'px';
        return styles;
  }
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.min.js"></script>
<div ng-app>
  <h2>Top</h2>
  <div ng-controller="TodoCtrl">
     <div ng-style="getStyle()">
         Hello World
     </div>
  </div>
 <div style="height: 1000px; border: solid 2px red;"></div>
</div></code>```

Title: Angular - Change css using ng-style

Body:
I am trying to change top position of a DIV on Scroll event -

In controller i have-

    angular.element($window).on("scroll", function(e) {
        vm.scrollTop = angular.element($window).scrollTop()+'px';
        console.log(vm.scrollTop);
    });

In html -

    Hello World

On scroll event is printing scrollTop values in console but "Div" style never gets updated.

Please correct me if this is syntactically incorrect.

Body:
You can use $scope.$apply or $scope.$watch.

Here's snippet using $scope.$apply.

function TodoCtrl($scope, $document, $window) {
   $scope.scrollTop = 30;
     $document.bind('scroll', function(){
        $scope.$apply(function(){
   $scope.scrollTop = $window.scrollY;
      });
   });
   $scope.getStyle = function(){
        var styles = {}
        styles['margin-top'] = $scope.scrollTop + 'px';
        return styles;
  }
}

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.min.js"></script>
<div ng-app>
  <h2>Top</h2>
  <div ng-controller="TodoCtrl">
     <div ng-style="getStyle()">
         Hello World
     </div>
  </div>
 <div style="height: 1000px; border: solid 2px red;"></div>
</div>


问:
Update TensorFlow
I'm working with Ubuntu 14.04 , I had a TensorFlow V0.10 but I want to update this version.
if i do:

```<code>$ pip install --upgrade $TF_BINARY_URL
</code>```

but it prints:

```<code>Exception:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 122, in main
    status = self.run(options, args)
  File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 278, in run
    requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
  File "/usr/lib/python2.7/dist-packages/pip/req.py", line 1198, in prepare_files
    do_download,
  File "/usr/lib/python2.7/dist-packages/pip/req.py", line 1376, in unpack_url
    self.session,
  File "/usr/lib/python2.7/dist-packages/pip/download.py", line 572, in unpack_http_url
    download_hash = _download_url(resp, link, temp_location)
  File "/usr/lib/python2.7/dist-packages/pip/download.py", line 433, in _download_url
    for chunk in resp_read(4096):
  File "/usr/lib/python2.7/dist-packages/pip/download.py", line 421, in resp_read
    chunk_size, decode_content=False):
  File "/usr/share/python-wheels/urllib3-1.7.1-py2.py3-none-any.whl/urllib3/response.py", line 225, in stream
    data = self.read(amt=amt, decode_content=decode_content)
  File "/usr/share/python-wheels/urllib3-1.7.1-py2.py3-none-any.whl/urllib3/response.py", line 174, in read
    data = self._fp.read(amt)
  File "/usr/lib/python2.7/httplib.py", line 573, in read
    s = self.fp.read(amt)
  File "/usr/lib/python2.7/socket.py", line 380, in read
    data = self._sock.recv(left)
  File "/usr/lib/python2.7/ssl.py", line 341, in recv
    return self.read(buflen)
  File "/usr/lib/python2.7/ssl.py", line 260, in read
    return self._sslobj.read(len)
SSLError: The read operation timed out

Storing debug log for failure in /home/brm17/.pip/pip.log
</code>```

答:
```<code>(tensorflow)$ pip install --upgrade pip  # for Python 2.7
(tensorflow)$ pip3 install --upgrade pip # for Python 3.n

(tensorflow)$ pip install --upgrade tensorflow      # for Python 2.7
(tensorflow)$ pip3 install --upgrade tensorflow     # for Python 3.n
(tensorflow)$ pip install --upgrade tensorflow-gpu  # for Python 2.7 and GPU
(tensorflow)$ pip3 install --upgrade tensorflow-gpu # for Python 3.n and GPU

(tensorflow)$ pip install --upgrade tensorflow-gpu==1.4.1 # for a specific version
</code>```

Details on install tensorflow.

Title: Update TensorFlow

Body:
I'm working with Ubuntu 14.04 , I had a TensorFlow V0.10 but I want to update this version.
if i do:

$ pip install --upgrade $TF_BINARY_URL

but it prints:

Exception:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 122, in main
    status = self.run(options, args)
  File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 278, in run
    requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
  File "/usr/lib/python2.7/dist-packages/pip/req.py", line 1198, in prepare_files
    do_download,
  File "/usr/lib/python2.7/dist-packages/pip/req.py", line 1376, in unpack_url
    self.session,
  File "/usr/lib/python2.7/dist-packages/pip/download.py", line 572, in unpack_http_url
    download_hash = _download_url(resp, link, temp_location)
  File "/usr/lib/python2.7/dist-packages/pip/download.py", line 433, in _download_url
    for chunk in resp_read(4096):
  File "/usr/lib/python2.7/dist-packages/pip/download.py", line 421, in resp_read
    chunk_size, decode_content=False):
  File "/usr/share/python-wheels/urllib3-1.7.1-py2.py3-none-any.whl/urllib3/response.py", line 225, in stream
    data = self.read(amt=amt, decode_content=decode_content)
  File "/usr/share/python-wheels/urllib3-1.7.1-py2.py3-none-any.whl/urllib3/response.py", line 174, in read
    data = self._fp.read(amt)
  File "/usr/lib/python2.7/httplib.py", line 573, in read
    s = self.fp.read(amt)
  File "/usr/lib/python2.7/socket.py", line 380, in read
    data = self._sock.recv(left)
  File "/usr/lib/python2.7/ssl.py", line 341, in recv
    return self.read(buflen)
  File "/usr/lib/python2.7/ssl.py", line 260, in read
    return self._sslobj.read(len)
SSLError: The read operation timed out

Storing debug log for failure in /home/brm17/.pip/pip.log

Body:
(tensorflow)$ pip install --upgrade pip  # for Python 2.7
(tensorflow)$ pip3 install --upgrade pip # for Python 3.n

(tensorflow)$ pip install --upgrade tensorflow      # for Python 2.7
(tensorflow)$ pip3 install --upgrade tensorflow     # for Python 3.n
(tensorflow)$ pip install --upgrade tensorflow-gpu  # for Python 2.7 and GPU
(tensorflow)$ pip3 install --upgrade tensorflow-gpu # for Python 3.n and GPU

(tensorflow)$ pip install --upgrade tensorflow-gpu==1.4.1 # for a specific version

Details on install tensorflow.


问:
Eclipse GWT Java Tomcat - Serialisation policy issue when I upload to the hosting server
I have made a change to my application using Eclipse (4.3.2) and GWT and tested it on my local Tomcat where it works. However when I upload it to the hosting server (I do a full upload not just the classes I changed) I get the following error in the logs when I try to use it (login):

```<code>INFO: Server startup in 20107 ms
Nov 04, 2014 5:41:33 PM org.apache.catalina.core.ApplicationContext log
INFO: mySQLConnection: ERROR: The serialization policy file '/org.AwardTracker.AwardTracker/C7227FD579DD02DA4BB5B3EBAD09AE79.gwt.rpc' was not found; did you forget to include it in this deployment?
Nov 04, 2014 5:41:33 PM org.apache.catalina.core.ApplicationContext log
INFO: mySQLConnection: WARNING: Failed to get the SerializationPolicy 'C7227FD579DD02DA4BB5B3EBAD09AE79' for module 'http://tc1165.metawerx.com.au/org.AwardTracker.AwardTracker/'; a legacy, 1.3.3 compatible, serialization policy will be used.  You may experience SerializationExceptions as a result.
Nov 04, 2014 5:41:40 PM org.apache.catalina.core.ApplicationContext log
SEVERE: Exception while dispatching incoming RPC call
com.google.gwt.user.client.rpc.SerializationException: Type 'org.AwardTracker.client.ViewData' was not assignable to 'com.google.gwt.user.client.rpc.IsSerializable' and did not have a custom field serializer.For security purposes, this type will not be serialized.: instance = org.AwardTracker.client.ViewData@62066d5c

    at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serialize(ServerSerializationStreamWriter.java:667)
    at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter.writeObject(AbstractSerializationStreamWriter.java:130)
    at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter$ValueWriter$8.write(ServerSerializationStreamWriter.java:153)
    at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeValue(ServerSerializationStreamWriter.java:587)
    at com.google.gwt.user.server.rpc.RPC.encodeResponse(RPC.java:605)
    at com.google.gwt.user.server.rpc.RPC.encodeResponseForSuccess(RPC.java:471)
    at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:563)
    at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:265)
    at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:305)
    at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:277)
    at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:274)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAsPrivileged(Subject.java:536)
    at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:309)
    at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:169)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:297)
    at org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:55)
    at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:191)
    at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:187)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:186)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:277)
    at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:274)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAsPrivileged(Subject.java:536)
    at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:309)
    at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:249)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
    at org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:55)
    at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:191)
    at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:187)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:186)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.

java:745)

0    [catalina-exec-12] INFO  gwtupload.server.UploadServlet  - UPLOAD-SERVLET init: maxSize=3145728, slowUploads=0, isAppEngine=false, corsRegex=^$
2    [catalina-exec-12] INFO  gwtupload.server.UploadServlet  - UPLOAD-ACTION init: removeSessionFiles=false, removeData=false
</code>```

The change I made was to:
 AccountUpdateView.java where I added a Label and a TextBox to display the "Group" (client side)
 AccountAndCubs.java where I added the new field (get and set) to be displayed in AccountUpdateView.java (client side)
 MySQLConnection.java where I added the new field to the sql call (server side)

In my searches I found some information relating to this that suggested that I add "static final long serialVersionUID = 1L;" to the class I changed (AccountUpdateView.java) which I did however I still get this error.

I noticed this line:

```<code>SEVERE: Exception while dispatching incoming RPC call
com.google.gwt.user.client.rpc.SerializationException: Type 'org.AwardTracker.client.ViewData' was not assignable to 'com.google.gwt.user.client.rpc.IsSerializable' and did not have a custom field serializer.For security purposes, this type will not be serialized.: instance = org.AwardTracker.client.ViewData@62066d5c
</code>```

Which indicates an issue with "ViewData.java" which I have not changed and does already have:

```<code>package org.AwardTracker.client;

import java.io.Serializable;

public class ViewData implements Serializable {
    private static final long serialVersionUID = 1L;
</code>```

Your help with this would be greatly appreciated. Also, I am not very technical and am still learning so please be patient with me and use simple language.

Added as requested:

ViewData code:

```<code>package org.AwardTracker.client;

import java.io.Serializable;

public class ViewData implements Serializable {
    private static final long serialVersionUID = 1L;

    private String accountId;
    private String accountLevel;
    private String ymId;
    private String awId;
    private String adAwardGroup;
    private String adScoutGroup;

    public ViewData() {
        //just here because GWT wants it.
    }

    public String getaccountId() {
        return accountId;
    }
    public void setaccountId(String accountId) {
        this.accountId = accountId;
    }

    public String getaccountLevel() {
        return accountLevel;
    }
    public void setaccountLevel(String accountLevel) {
        this.accountLevel = accountLevel;
    }

    public String getymId() {
        return ymId;
    }
    public void setymId(String ymId) {
        this.ymId = ymId;
    }

    public String getawId() {
        return awId;
    }
    public void setawId(String awId) {
        this.awId = awId;
    }

    public String getadAwardGroup() {
        return adAwardGroup;
    }
    public void setadAwardGroup(String adAwardGroup) {
        this.adAwardGroup = adAwardGroup;
    }

    public String getadScoutGroup() {
        return adScoutGroup;
    }
    public void setadScoutGroup(String adScoutGroup) {
        this.adScoutGroup = adScoutGroup;
    }

}
</code>```

AccountsAndCubs.java code ("group" has been added):

```<code>package org.AwardTracker.client;

import com.google.gwt.user.client.rpc.IsSerializable;
import java.util.Date;

public class AccountAndCubs implements IsSerializable {

    static final long serialVersionUID = 1L;

    //@SuppressWarnings("unused")
    private String accountId;
    //@SuppressWarnings("unused")
    private String emailaddress;
    //@SuppressWarnings("unused")
    private String password;
    //@SuppressWarnings("unused")
    private String level;
    //@SuppressWarnings("unused")
    private String pack;
    //@SuppressWarnings("unused")
    private Integer enabled;
    //@SuppressWarnings("unused")
    private Date archived;
    //@SuppressWarnings("unused")
    private String group;
    //@SuppressWarnings("unused")
    private String acaId;
    //@SuppressWarnings("unused")
    private String cdId;
    //@SuppressWarnings("unused")
    private String surname;
    //@SuppressWarnings("unused")
    private String firstname;

    @SuppressWarnings("unused")
    private AccountAndCubs() {
        //just here because GWT wants it.
    }
    public AccountAndCubs(String accountId, String emailaddress, String password, String level, String pack,
            Integer enabled, Date archived, String group, String acaId, String cdId, String surname, String firstname) {
        this.accountId = accountId;
        this.emailaddress = emailaddress;
        this.password = password;
        this.level = level;
        this.pack = pack;
        this.enabled = enabled;
        this.archived = archived;
        this.group = group;
        this.acaId = acaId;
        this.cdId = cdId;
        this.surname = surname;
        this.firstname = firstname;
    }

    public String getAccountId() {
        return accountId;
    }
    public void setAccountId(String accountId) {
        this.accountId = accountId;
    }

    public String getEmailAddress() {
        return emailaddress;
    }
    public void setEmailAddress(String emailaddress) {
        this.emailaddress = emailaddress;
    }

    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }

    public String getLevel() {
        return level;
    }
    public void setLevel(String level) {
        this.level = level;
    }

    public String getPack() {
        return pack;
    }
    public void setPack(String pack) {
        this.pack = pack;
    }

    public Integer getEnabled() {
        return enabled;
    }
    public void setEnabled(Integer enabled) {
        this.enabled = enabled;
    }

    public Date getArchived() {
        return archived;
    }
    public void setArchived(Date archived) {
        this.archived = archived;
    }

    public String getGroup() {
        return group;
    }
    public void setGroup(String group) {
        this.group = group;
    }

    public String getAcaId() {
        return acaId;
    }
    public void setAcaId(String acaId) {
        this.acaId = acaId;
    }

    public String getCdId() {
        return cdId;
    }
    public void setCdId(String cdId) {
        this.cdId = cdId;
    }

    public String getSurname() {
        return surname;
    }
    public void setSurname(String surname) {
        this.surname = surname;
    }

    public String getFirstName() {
        return firstname;
    }
    public void setFirstName(String firstname) {
        this.firstname = firstname;
    }

}
</code>```

答:
Though, I haven't figured out the actual fix (can't try yours , because can't delete ROOT.war in testing environments) , I got some workaround which might be useful for others.

Main issue in the above question is :

The serialization policy file '/org.AwardTracker.AwardTracker/C7227FD579DD02DA4BB5B3EBAD09AE79.gwt.rpc' was not found; did you forget to include it in this deployment?

Normally this is happening because deployed WAR file contains app folder and inside of it there is a rpc file. However due to some issues with tomcat cache or any other , it still looking for old rpc file that is used in previous deployment.

So work around is, take a backup of previous file and copy to app folder again.

Body:
I have made a change to my application using Eclipse (4.3.2) and GWT and tested it on my local Tomcat where it works. However when I upload it to the hosting server (I do a full upload not just the classes I changed) I get the following error in the logs when I try to use it (login):

INFO: Server startup in 20107 ms
Nov 04, 2014 5:41:33 PM org.apache.catalina.core.ApplicationContext log
INFO: mySQLConnection: ERROR: The serialization policy file '/org.AwardTracker.AwardTracker/C7227FD579DD02DA4BB5B3EBAD09AE79.gwt.rpc' was not found; did you forget to include it in this deployment?
Nov 04, 2014 5:41:33 PM org.apache.catalina.core.ApplicationContext log
INFO: mySQLConnection: WARNING: Failed to get the SerializationPolicy 'C7227FD579DD02DA4BB5B3EBAD09AE79' for module 'http://tc1165.metawerx.com.au/org.AwardTracker.AwardTracker/'; a legacy, 1.3.3 compatible, serialization policy will be used.  You may experience SerializationExceptions as a result.
Nov 04, 2014 5:41:40 PM org.apache.catalina.core.ApplicationContext log
SEVERE: Exception while dispatching incoming RPC call
com.google.gwt.user.client.rpc.SerializationException: Type 'org.AwardTracker.client.ViewData' was not assignable to 'com.google.gwt.user.client.rpc.IsSerializable' and did not have a custom field serializer.For security purposes, this type will not be serialized.: instance = org.AwardTracker.client.ViewData@62066d5c

    at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serialize(ServerSerializationStreamWriter.java:667)
    at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter.writeObject(AbstractSerializationStreamWriter.java:130)
    at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter$ValueWriter$8.write(ServerSerializationStreamWriter.java:153)
    at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeValue(ServerSerializationStreamWriter.java:587)
    at com.google.gwt.user.server.rpc.RPC.encodeResponse(RPC.java:605)
    at com.google.gwt.user.server.rpc.RPC.encodeResponseForSuccess(RPC.java:471)
    at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:563)
    at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:265)
    at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:305)
    at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:277)
    at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:274)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAsPrivileged(Subject.java:536)
    at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:309)
    at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:169)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:297)
    at org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:55)
    at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:191)
    at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:187)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:186)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:277)
    at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:274)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAsPrivileged(Subject.java:536)
    at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:309)
    at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:249)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
    at org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:55)
    at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:191)
    at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:187)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:186)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.

java:745)

0    [catalina-exec-12] INFO  gwtupload.server.UploadServlet  - UPLOAD-SERVLET init: maxSize=3145728, slowUploads=0, isAppEngine=false, corsRegex=^$
2    [catalina-exec-12] INFO  gwtupload.server.UploadServlet  - UPLOAD-ACTION init: removeSessionFiles=false, removeData=false

The change I made was to:
 AccountUpdateView.java where I added a Label and a TextBox to display the "Group" (client side)
 AccountAndCubs.java where I added the new field (get and set) to be displayed in AccountUpdateView.java (client side)
 MySQLConnection.java where I added the new field to the sql call (server side)

In my searches I found some information relating to this that suggested that I add "static final long serialVersionUID = 1L;" to the class I changed (AccountUpdateView.java) which I did however I still get this error.

I noticed this line:

SEVERE: Exception while dispatching incoming RPC call
com.google.gwt.user.client.rpc.SerializationException: Type 'org.AwardTracker.client.ViewData' was not assignable to 'com.google.gwt.user.client.rpc.IsSerializable' and did not have a custom field serializer.For security purposes, this type will not be serialized.: instance = org.AwardTracker.client.ViewData@62066d5c

Which indicates an issue with "ViewData.java" which I have not changed and does already have:

package org.AwardTracker.client;

import java.io.Serializable;

public class ViewData implements Serializable {
    private static final long serialVersionUID = 1L;

Your help with this would be greatly appreciated. Also, I am not very technical and am still learning so please be patient with me and use simple language.

Added as requested:

ViewData code:

package org.AwardTracker.client;

import java.io.Serializable;

public class ViewData implements Serializable {
    private static final long serialVersionUID = 1L;

    private String accountId;
    private String accountLevel;
    private String ymId;
    private String awId;
    private String adAwardGroup;
    private String adScoutGroup;

    public ViewData() {
        //just here because GWT wants it.
    }

    public String getaccountId() {
        return accountId;
    }
    public void setaccountId(String accountId) {
        this.accountId = accountId;
    }

    public String getaccountLevel() {
        return accountLevel;
    }
    public void setaccountLevel(String accountLevel) {
        this.accountLevel = accountLevel;
    }

    public String getymId() {
        return ymId;
    }
    public void setymId(String ymId) {
        this.ymId = ymId;
    }

    public String getawId() {
        return awId;
    }
    public void setawId(String awId) {
        this.awId = awId;
    }

    public String getadAwardGroup() {
        return adAwardGroup;
    }
    public void setadAwardGroup(String adAwardGroup) {
        this.adAwardGroup = adAwardGroup;
    }

    public String getadScoutGroup() {
        return adScoutGroup;
    }
    public void setadScoutGroup(String adScoutGroup) {
        this.adScoutGroup = adScoutGroup;
    }

}

AccountsAndCubs.java code ("group" has been added):

package org.AwardTracker.client;

import com.google.gwt.user.client.rpc.IsSerializable;
import java.util.Date;

public class AccountAndCubs implements IsSerializable {

    static final long serialVersionUID = 1L;

    //@SuppressWarnings("unused")
    private String accountId;
    //@SuppressWarnings("unused")
    private String emailaddress;
    //@SuppressWarnings("unused")
    private String password;
    //@SuppressWarnings("unused")
    private String level;
    //@SuppressWarnings("unused")
    private String pack;
    //@SuppressWarnings("unused")
    private Integer enabled;
    //@SuppressWarnings("unused")
    private Date archived;
    //@SuppressWarnings("unused")
    private String group;
    //@SuppressWarnings("unused")
    private String acaId;
    //@SuppressWarnings("unused")
    private String cdId;
    //@SuppressWarnings("unused")
    private String surname;
    //@SuppressWarnings("unused")
    private String firstname;

    @SuppressWarnings("unused")
    private AccountAndCubs() {
        //just here because GWT wants it.
    }
    public AccountAndCubs(String accountId, String emailaddress, String password, String level, String pack,
            Integer enabled, Date archived, String group, String acaId, String cdId, String surname, String firstname) {
        this.accountId = accountId;
        this.emailaddress = emailaddress;
        this.password = password;
        this.level = level;
        this.pack = pack;
        this.enabled = enabled;
        this.archived = archived;
        this.group = group;
        this.acaId = acaId;
        this.cdId = cdId;
        this.surname = surname;
        this.firstname = firstname;
    }

    public String getAccountId() {
        return accountId;
    }
    public void setAccountId(String accountId) {
        this.accountId = accountId;
    }

    public String getEmailAddress() {
        return emailaddress;
    }
    public void setEmailAddress(String emailaddress) {
        this.emailaddress = emailaddress;
    }

    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }

    public String getLevel() {
        return level;
    }
    public void setLevel(String level) {
        this.level = level;
    }

    public String getPack() {
        return pack;
    }
    public void setPack(String pack) {
        this.pack = pack;
    }

    public Integer getEnabled() {
        return enabled;
    }
    public void setEnabled(Integer enabled) {
        this.enabled = enabled;
    }

    public Date getArchived() {
        return archived;
    }
    public void setArchived(Date archived) {
        this.archived = archived;
    }

    public String getGroup() {
        return group;
    }
    public void setGroup(String group) {
        this.group = group;
    }

    public String getAcaId() {
        return acaId;
    }
    public void setAcaId(String acaId) {
        this.acaId = acaId;
    }

    public String getCdId() {
        return cdId;
    }
    public void setCdId(String cdId) {
        this.cdId = cdId;
    }

    public String getSurname() {
        return surname;
    }
    public void setSurname(String surname) {
        this.surname = surname;
    }

    public String getFirstName() {
        return firstname;
    }
    public void setFirstName(String firstname) {
        this.firstname = firstname;
    }

}


问:
efficient filter rows by multi column patterns
I have a big data frame (104029 x 142).

I want to filter rows which value>0 by multi specific column names.

```<code>df
         word abrasive abrasives abrasivefree abrasion slurry solute solution ....
1 composition     -0.2       0.2         -0.3    -0.40    0.2      0.1         0.20 ....
2       ceria      0.1       0.2         -0.4    -0.20   -0.1     -0.2         0.20 ....
3     diamond      0.3      -0.5         -0.6    -0.10   -0.1     -0.2        -0.15 ....
4        acid     -0.1      -0.1         -0.2    -0.15    0.1      0.3         0.20 ....
....
</code>```

Now I have tried to use filter() function to do, and it's OK.

But I think this way is not efficient for me.

Because I need to define each column name, it makes hard work when I need to maintain my process.

```<code>column_names <- c("agent", "agents", "liquid", "liquids", "slurry",
                  "solute", "solutes", "solution", "solutions")

df_filter <- filter(df,  agents>0 | agents>0 | liquid>0 | liquids>0 | slurry>0 | solute>0 |
                    solutes>0 | solution>0 | solutions>0)

df_filter
         word abrasive abrasives abrasivefree abrasion  slurry solute solution ....
1 composition     -0.2       0.2         -0.3    -0.40    0.2      0.1         0.20 ....
2       ceria      0.1       0.2         -0.4    -0.20   -0.1     -0.2         0.20 ....
4        acid     -0.1      -0.1         -0.2    -0.15    0.1      0.3         0.20 ....
....
</code>```

Is there any more efficient way to do?

答:
This line will return vector of True/False for the condition you are testing

```<code>filter_condition <- apply(df[ , column_names], 1, function(x){sum(x>0)} )>0
</code>```

Then you can use

```<code>df[filter_condition, ]
</code>```

I'm sure there is something nicer in dplyr.

Body:
I have a big data frame (104029 x 142).

I want to filter rows which value>0 by multi specific column names.

df
         word abrasive abrasives abrasivefree abrasion slurry solute solution ....
1 composition     -0.2       0.2         -0.3    -0.40    0.2      0.1         0.20 ....
2       ceria      0.1       0.2         -0.4    -0.20   -0.1     -0.2         0.20 ....
3     diamond      0.3      -0.5         -0.6    -0.10   -0.1     -0.2        -0.15 ....
4        acid     -0.1      -0.1         -0.2    -0.15    0.1      0.3         0.20 ....
....

Now I have tried to use filter() function to do, and it's OK.

But I think this way is not efficient for me.

Because I need to define each column name, it makes hard work when I need to maintain my process.

column_names <- c("agent", "agents", "liquid", "liquids", "slurry",
                  "solute", "solutes", "solution", "solutions")

df_filter <- filter(df,  agents>0 | agents>0 | liquid>0 | liquids>0 | slurry>0 | solute>0 |
                    solutes>0 | solution>0 | solutions>0)

df_filter
         word abrasive abrasives abrasivefree abrasion  slurry solute solution ....
1 composition     -0.2       0.2         -0.3    -0.40    0.2      0.1         0.20 ....
2       ceria      0.1       0.2         -0.4    -0.20   -0.1     -0.2         0.20 ....
4        acid     -0.1      -0.1         -0.2    -0.15    0.1      0.3         0.20 ....
....

Is there any more efficient way to do?

Body:
This line will return vector of True/False for the condition you are testing

filter_condition <- apply(df[ , column_names], 1, function(x){sum(x>0)} )>0

Then you can use

df[filter_condition, ]

I'm sure there is something nicer in dplyr.


问:
What does assignment to *this do (*this = val)?
I was browsing Qt sources, and noticed this

```<code>QUuid &operator=(const GUID &guid)
{
    *this = QUuid(guid);
    return *this;
}
</code>```

I've never seen assignment to "this" before. What does assignment to "this" do?

答: That is not an assignment to this but to the object pointed by this. That will effectively call operator=( QUuid const & ) on the current object.

Body:
I was browsing Qt sources, and noticed this

QUuid &operator=(const GUID &guid)
{
    *this = QUuid(guid);
    return *this;
}

I've never seen assignment to "this" before. What does assignment to "this" do?