问:
Calculating the cumulative ttl (Time to live) for a series of requests
I have a series of requests and asked to calculate a the cumulative ttl of the series and given these requests .

```<code>let requests = [
{requestId: 't2',  startedAt: 1489744808, ttl: 8},
{requestId: 't3',  startedAt: 1489744803, ttl: 3},
{requestId: 't1', startedAt: 1489744806, ttl: 12},
{requestId: 't4',  startedAt: 1489744810, ttl: 1}
]
</code>```

What is the algorithm to solve this as I know that the answer should be 15 in the end.

I would assume that the earliest request 1489744803 should have the largest ttl but thats not the case, instead the 1489744806 request has the largest here so why is it like that?

Thanks :D

答:
```<code>let minStart = requests.reduce((v, obj) => Math.min(v, obj.startedAt), Number.MAX_SAFE_INTEGER)
let result = requests.reduce((r, obj) => Math.max(r, obj.startedAt - minStart + obj.ttl), 0)
</code>```

or

```<code>let minMax = requests.reduce((o, obj) => { return { min: Math.min(o.min, obj.startedAt), max: Math.max(o.max, obj.startedAt + obj.ttl)}}, { min: Number.MAX_SAFE_INTEGER, max: 0 })
console.log(minMax.max - minMax.min)
</code>```

(solution 2 looks a bit more ugly, but needs only one loop over the array.)

Body:
I have a series of requests and asked to calculate a the cumulative ttl of the series and given these requests .

let requests = [
{requestId: 't2',  startedAt: 1489744808, ttl: 8},
{requestId: 't3',  startedAt: 1489744803, ttl: 3},
{requestId: 't1', startedAt: 1489744806, ttl: 12},
{requestId: 't4',  startedAt: 1489744810, ttl: 1}
]

What is the algorithm to solve this as I know that the answer should be 15 in the end.

I would assume that the earliest request 1489744803 should have the largest ttl but thats not the case, instead the 1489744806 request has the largest here so why is it like that?

Thanks :D

Body:
let minStart = requests.reduce((v, obj) => Math.min(v, obj.startedAt), Number.MAX_SAFE_INTEGER)
let result = requests.reduce((r, obj) => Math.max(r, obj.startedAt - minStart + obj.ttl), 0)

or

let minMax = requests.reduce((o, obj) => { return { min: Math.min(o.min, obj.startedAt), max: Math.max(o.max, obj.startedAt + obj.ttl)}}, { min: Number.MAX_SAFE_INTEGER, max: 0 })
console.log(minMax.max - minMax.min)

(solution 2 looks a bit more ugly, but needs only one loop over the array.)


来源: stackexchange

问:
How to disable/remove JSON native support in Oracle 12.2
I'm working on a Oracle 12.2 database and I want to turn it off/remove/disable the default JSON support.

The project I'm working on already had a JSON library for all the JSON interactions. My database has recently been updated from 12.1 to 12.2 and now the original JSON library will not compile anymore. After some searching I found that is has conflicts with default implementation of JSON in 12.2, and this didn't occur in 12.1. Some syntax is shared between the old library and the new JSON support.

It is gone be a lot of work to change all my old code to work with the new JSON support, so I would rather disable the JSON support and keep using my old library. But I was not able to find on the internet how do this.

答: The JSON support is native, eg it is part of the RDBMS 'C' code. It is not possible to remove it. Can you post the details of the library you were using and the conflicts so we can document them and make recommendations on how to migrate. It was introduced starting with 12.1.0.2.0 (which 12.1 version were you working with ?). Assuming your library is a set of PL/SQL functions you should be able to avoid conflicts by properly qualifying your function names with a schema, which might be less work than doing a full migration, however I would strongly recommend migrating to the native JSON support ASAP, as it is probably much more performant.</p>

ContentLicense: CC BY-SA 4.0

ContentLicense: CC BY-SA 3.0


问:
iPhone: Using Alerts to Help Debugging
I've been building a rather complex system and there's come the time now where I want more concise debugging. I would like to display the contents of a variable (for this example an NSString called v_string) in a notification window (the kind of window that appear when you receive an SMS text).

Is there an easy way to just call an alert with a variable?

Thanks in Advance,

Dan

答:
NSLog does not do? If not (like if you need to debug an application running on a disconnected device), you can extend the UIAlertView with a category:

```<code>@implementation UIAlertView (Logging)

+ (void) log: (id <NSObject>) anObject
{
    NSString *message = [anObject description];
    UIAlertView *alert = [[self alloc] initWith…];
    [alert show];
    [alert release];
}
</code>```

And then in code:

```<code>NSString *anInterestingString = …;
[UIAlertView log:anInterestingString];
</code>```

ContentLicense: CC BY-SA 2.5

Title: iPhone: Using Alerts to Help Debugging

Body:
NSLog does not do? If not (like if you need to debug an application running on a disconnected device), you can extend the UIAlertView with a category:

@implementation UIAlertView (Logging)

+ (void) log: (id <NSObject>) anObject
{
    NSString *message = [anObject description];
    UIAlertView *alert = [[self alloc] initWith…];
    [alert show];
    [alert release];
}

And then in code:

NSString *anInterestingString = …;
[UIAlertView log:anInterestingString];


问:
Multiple IBOutlets to another VC
I'm using IBOutlet Collection where all the buttons will pop another VC, how do I link multiple button to the same VC?

[

I've tried ctrl and drag selected buttons to the new VC but only one button connects

答:
You should make an IBAction in your code (dragging from one of the buttons to your code) and then inside that function call                     self?.present(toVC, animated: true, completion: nil) (fill in what you need)
once you've done that, just drag from the dot (next to the function) to your buttons.

Title: Multiple IBOutlets to another VC


问:
ffmpeg mix 20 audio streams without making it quieter
I want to mix about 20 audio streams with ffmpeg amix, however as described here, amix has a weired way of making the input streams quieter the more of them you mix together:

"amix scales each input's volume by 1/n where n = no. of active inputs. This is evaluated for each audio frame. So when an input drops out, the volume of the remaining inputs is scaled by a smaller amount, hence their volumes increase"

How can I get rid of this anoying behaviour?
I just want the audio streams to keep the same loudness, since only one of them has actual audio in it at any give time anyway..

At the moment I end up with a file that is about 1/20 the loudness of the original, making it effectively unusable.

答:
Adjust the volume of each stream by multiplying by n (20 in your case)

https://ffmpeg.org/ffmpeg-filters.html#volume


问:
XQuery transform multiple xml elements into one target element concatenated
I am looking to transform source xml and combine couple of fields into single target string element in comma separated text.

Conditions Source Inputs (Engg1 to 5) are boolean type, only if value true it should be included in target list

E.g. XML

```<code><Root-Element>
<EnggTypes>
<EnggFN>ABC<EnggFN>
<EnggLN>XYZ<EnggLN>
<EnggEML>abc.xyz@junk.com</EnggEML>
<Engg1>true</Engg1>
<Engg2>true</Engg2>
<Engg3>false</Engg3>
<Engg4>false</Engg4>
<Engg5>true</Engg5>
</EnggTypes>
</Root-Element>
</code>```

Expected Transform

```<code><Root-Element>
<EnggFN>ABC<EnggFN>
<EnggLN>XYZ<EnggLN>
<EnggEML>abc.xyz@junk.com</EnggEML>
<RoleTypes>Role1,Role2,Role5</RoleTypes>
</Root-Element>
</code>```

Looking to achieve same in XQuery 1.0

I started overthinking and tried to use a local variable to see if I can do some if then else if to construct the string using previous value and concatenate but seems like that will not work as variable value cannot be changed once set!

```<code>{ if (Engg1/text()="true")
                      then (let $roleType:='Role1' return roleType)
                  else if (Engg2/text()="true")
                      then (let $roleType:=fn:concat($roleType,",","Role2") return roleType)
                  else if (Engg3/text()="true")
                      then (let $roleType:=fn:concat($roleType,",","Role3") return roleType)
                  else if (Engg4/text()="true")
                      then (let $roleType:=fn:concat($roleType,",","Role4") return roleType)
                  else if (Engg5/text()="true")
                      then (let $roleType:=fn:concat($roleType,",","Role5") return roleType)
                  else (fn:data($roleType))
                  }
</code>```

Any inputs appreciated.

Thanks in advance

答:
You can dynamically generate the list by parsing the role number out of the local-name of the element:</p>

```<code>let $roles :=
  for $e in $doc/EnggTypes/*
  let $local-name := local-name($e)
  let $regex := '^Engg(\d+)$'
  let $number := replace($local-name, '^Engg(\d+)$', '$1')
  where ($e eq 'true')
  return concat('Role', $number)
return string-join($roles, ',')
</code>```

Body:
I am looking to transform source xml and combine couple of fields into single target string element in comma separated text.

Conditions Source Inputs (Engg1 to 5) are boolean type, only if value true it should be included in target list

E.g. XML

<Root-Element>
<EnggTypes>
<EnggFN>ABC<EnggFN>
<EnggLN>XYZ<EnggLN>
<EnggEML>abc.xyz@junk.com</EnggEML>
<Engg1>true</Engg1>
<Engg2>true</Engg2>
<Engg3>false</Engg3>
<Engg4>false</Engg4>
<Engg5>true</Engg5>
</EnggTypes>
</Root-Element>

Expected Transform

<Root-Element>
<EnggFN>ABC<EnggFN>
<EnggLN>XYZ<EnggLN>
<EnggEML>abc.xyz@junk.com</EnggEML>
<RoleTypes>Role1,Role2,Role5</RoleTypes>
</Root-Element>

Looking to achieve same in XQuery 1.0

I started overthinking and tried to use a local variable to see if I can do some if then else if to construct the string using previous value and concatenate but seems like that will not work as variable value cannot be changed once set!

{ if (Engg1/text()="true")
                      then (let $roleType:='Role1' return roleType)
                  else if (Engg2/text()="true")
                      then (let $roleType:=fn:concat($roleType,",","Role2") return roleType)
                  else if (Engg3/text()="true")
                      then (let $roleType:=fn:concat($roleType,",","Role3") return roleType)
                  else if (Engg4/text()="true")
                      then (let $roleType:=fn:concat($roleType,",","Role4") return roleType)
                  else if (Engg5/text()="true")
                      then (let $roleType:=fn:concat($roleType,",","Role5") return roleType)
                  else (fn:data($roleType))
                  }

Any inputs appreciated.

Thanks in advance

Body:
You can dynamically generate the list by parsing the role number out of the local-name of the element:

let $roles :=
  for $e in $doc/EnggTypes/*
  let $local-name := local-name($e)
  let $regex := '^Engg(\d+)$'
  let $number := replace($local-name, '^Engg(\d+)$', '$1')
  where ($e eq 'true')
  return concat('Role', $number)
return string-join($roles, ',')


问:
What is the meaning of `X{code}` in Drop-wizard log format
Sorry if I am asking very basic question here. But i am using a dropwizard application in which log format is given as "%-6level [%d{HH:mm:ss.SSS}] [%t] %logger{5} - %X{code} %msg %n".

And application logs contains below lines :-

```<code>INFO  [2017-06-07 13:54:43,828] com.foo.Bar: In Get Method
</code>```

I understood that meaning of %-6level , date and %t and %msg %n in log format but couldn't get the meaning of %X{code} and %logger{5} and don't see these printing in my logs.

Can someone point me to a proper doc where each of these parameters of log format is explained in details.

答:
Here is a nice documentation about layouts in logback : Layouts

For the logger{length} part :

Outputs the name of the logger at the origin of the logging event.
  This conversion word takes an integer as its first and only option.
  The converter's abbreviation algorithm will shorten the logger name,
  usually without significant loss of meaning. Setting the value of
  length option to zero constitutes an exception. It will cause the
  conversion word to return the sub-string right to the rightmost dot
  character in the logger name. The next table provides examples of the
  abbreviation algorithm in action.

For the X{key:-defaultVal} part :

Outputs the MDC (mapped diagnostic context) associated with the thread
  that generated the logging event.

More information about MDC can be found here : Mapped Diagnostic Context

With your configuration you would call it like e.g :

```<code>MDC.put("code", "whateverCode");
</code>```

Body:
Sorry if I am asking very basic question here. But i am using a dropwizard application in which log format is given as "%-6level [%d{HH:mm:ss.SSS}] [%t] %logger{5} - %X{code} %msg %n".

And application logs contains below lines :-

INFO  [2017-06-07 13:54:43,828] com.foo.Bar: In Get Method

I understood that meaning of %-6level , date and %t and %msg %n in log format but couldn't get the meaning of %X{code} and %logger{5} and don't see these printing in my logs.

Can someone point me to a proper doc where each of these parameters of log format is explained in details.

Body:
Here is a nice documentation about layouts in logback : Layouts

For the logger{length} part :

Outputs the name of the logger at the origin of the logging event.
  This conversion word takes an integer as its first and only option.
  The converter's abbreviation algorithm will shorten the logger name,
  usually without significant loss of meaning. Setting the value of
  length option to zero constitutes an exception. It will cause the
  conversion word to return the sub-string right to the rightmost dot
  character in the logger name. The next table provides examples of the
  abbreviation algorithm in action.

For the X{key:-defaultVal} part :

Outputs the MDC (mapped diagnostic context) associated with the thread
  that generated the logging event.

More information about MDC can be found here : Mapped Diagnostic Context

With your configuration you would call it like e.g :

MDC.put("code", "whateverCode");


问:
Error when I want to remove folder names from the URL
I classify my files like this:

```<code>- root
    - javascript
    - stylesheets
    - views
        - users
            - login.php
            - logout.php
            - editprofile.php
            - dashboard.php
        - datas
        - etc ...
</code>```

The current links are:

```<code>http://example.com/views/users/login.php
http://example.com/views/users/editprofile.php
</code>```

But I would like to remove the folder name "views" in the links so that the url looks like this:

```<code>http://example.com/users/login.php
http://example.com/users/editprofile.php
</code>```

I have to search on stackoverflow a solution, I tried this one:

```<code>RewriteEngine On
RewriteRule ^ views/(.*)$ /$1 [L]
</code>```

But I can not access the pages with any url (.../users/login.php or .../views/users/login.php)

```<code>Not Found
The requested URL /users/login.php was not found on this server.
</code>```

With :

```<code>RewriteEngine On
RewriteRule ^ views /(.*)$ /$1 [L,NC,R]
</code>```

The link changes in the address bar but I have the same error

Do you have a solution ?
I just wish that the user does not see this folder

Thank you

答:
here is the share solution with htaccess tester

http://htaccess.mwl.be/?share=be357d78-a41b-54e4-a578-10aceb8c6033

you can see the new url generated with the views inside.

regards.

Body:
I classify my files like this:

- root
    - javascript
    - stylesheets
    - views
        - users
            - login.php
            - logout.php
            - editprofile.php
            - dashboard.php
        - datas
        - etc ...

The current links are:

http://example.com/views/users/login.php
http://example.com/views/users/editprofile.php

But I would like to remove the folder name "views" in the links so that the url looks like this:

http://example.com/users/login.php
http://example.com/users/editprofile.php

I have to search on stackoverflow a solution, I tried this one:

RewriteEngine On
RewriteRule ^ views/(.*)$ /$1 [L]

But I can not access the pages with any url (.../users/login.php or .../views/users/login.php)

Not Found
The requested URL /users/login.php was not found on this server.

With :

RewriteEngine On
RewriteRule ^ views /(.*)$ /$1 [L,NC,R]

The link changes in the address bar but I have the same error

Do you have a solution ?
I just wish that the user does not see this folder

Thank you


问:
Open/Edit/Save from on the host with app running in container
We recently have a lot of problem deploying the Linux version of our app for the client (updated libraries, missing libraries, install path), and we are looking to use Docker for deployment.

Our app as a UI, so we naturally map that using

```<code>-e DISPLAY:$DISPLAY -v /tmp/X11-unix:/tmp/X11-unix
</code>```

and we can actually see the UI popping up.

But when it's time to open a file, the problem start there. We want to only browse the host system and save any output file on the host (output directory is determined by the location of the opened file).

Which strategy would you suggest for this?

We want the client to not see the difference between the app running locally or inside Docker. We are working on a launch script so it looks like the client would still be double-clicking on it to start the app. We can add all the configuration we need in there for the docker run command.

答:
As you may know, the container hast its own filesystem that is provided by the image where it runs on top.

You can map a host's directory or file to a path inside the container, where your program expects it to be. This is known as docker volume. You're already doing that with the X11 socket communication (the -v flag).

For instance, for a file:

```<code>docker run -v /absolute/path/in/the/host/some.file:/path/inside/container/some.file
</code>```

For a directory:

```<code>docker run -v /absolute/path/in/the/host/some/dir:/path/inside/container/some/dir
</code>```

You can provide as many -v flags as you might need.

Here you can find more useful information.

Body:
We recently have a lot of problem deploying the Linux version of our app for the client (updated libraries, missing libraries, install path), and we are looking to use Docker for deployment.

Our app as a UI, so we naturally map that using

-e DISPLAY:$DISPLAY -v /tmp/X11-unix:/tmp/X11-unix

and we can actually see the UI popping up.

But when it's time to open a file, the problem start there. We want to only browse the host system and save any output file on the host (output directory is determined by the location of the opened file).

Which strategy would you suggest for this?

We want the client to not see the difference between the app running locally or inside Docker. We are working on a launch script so it looks like the client would still be double-clicking on it to start the app. We can add all the configuration we need in there for the docker run command.

Body:
As you may know, the container hast its own filesystem that is provided by the image where it runs on top.

You can map a host's directory or file to a path inside the container, where your program expects it to be. This is known as docker volume. You're already doing that with the X11 socket communication (the -v flag).

For instance, for a file:

docker run -v /absolute/path/in/the/host/some.file:/path/inside/container/some.file

For a directory:

docker run -v /absolute/path/in/the/host/some/dir:/path/inside/container/some/dir

You can provide as many -v flags as you might need.

Here you can find more useful information.


问:
Error when updating eclipse
I click update in eclipse and I get an error, it's because I updated eclipse more than once. Is there any way to fix eclipse and have the ability to use update?</p>

```
An error occurred while collecting items to be installed
  No repository found containing: org.eclipse.jem/osgi.bundle/2.0.202.v200810282000
  No repository found containing: org.eclipse.jem.workbench/osgi.bundle/2.0.102.v200810230530
  No repository found containing: org.eclipse.jpt.core/osgi.bundle/2.1.0.v200812160210
  No repository found containing: org.eclipse.jpt.doc.user/osgi.bundle/1.0.300.v200812110000
  No repository found containing: org.eclipse.jpt.eclipselink.core/osgi.bundle/1.1.0.v200812110000
  No repository found containing: org.eclipse.jpt.eclipselink.core.ddlgen/osgi.bundle/1.0.100.v200811030000
  No repository found containing: org.eclipse.jpt.eclipselink.feature/org.eclipse.update.feature/2.1.0.v200812180210-318Y9oA55S8_795555
  No repository found containing: org.eclipse.jpt.eclipselink.ui/osgi.bundle/1.1.0.v200812100000
  No repository found containing: org.eclipse.jpt.feature/org.eclipse.update.feature/2.1.0.v200812180210-7979AgCYQCD4IRJdCEDC
  No repository found containing: org.eclipse.jpt.ui/osgi.bundle/2.1.0.v200812080000
  No repository found containing: org.eclipse.jst.common.frameworks/osgi.bundle/1.1.201.v200810161330
  No repository found containing: org.eclipse.jst.ejb.doc.user/osgi.bundle/1.1.100.v200810092245
  No repository found containing: org.eclipse.jst.ejb.ui/osgi.bundle/1.1.203.v200810010400
  No repository found containing: org.eclipse.jst.enterprise_core.feature/org.eclipse.update.feature/3.0.3.v200810010400-42E_4_kE77c_FAP7X99
  No repository found containing: org.eclipse.jst.enterprise_ui.feature/org.eclipse.update.feature/3.0.3.v200810010400-7Y7BFSrEPOwQPnUuwhYV60NEQtTn
  No repository found containing: org.eclipse.jst.enterprise_userdoc.feature/org.eclipse.update.feature/3.0.3.v200810131754-52EFBAgI99mAV9oGIHb
  No repository found containing: org.eclipse.jst/org.eclipse.update.feature/3.0.3.v200809250443-7U-9-9LJGGJebgG8HYgv5FBP0NUr
  No repository found containing: org.eclipse.jst.j2ee/osgi.bundle/1.1.204.v200811130630
  No repository found containing: org.eclipse.jst.j2ee.core/osgi.bundle/1.1.202.v200811111600
  No repository found containing: org.eclipse.jst.j2ee.ejb/osgi.bundle/1.1.203.v200811060500
  No repository found containing: org.eclipse.jst.j2ee.jca/osgi.bundle/1.1.203.v200811060900
  No repository found containing: org.eclipse.jst.j2ee.navigator.ui/osgi.bundle/1.1.202.v200810222000
  No repository found containing: org.eclipse.jst.j2ee.ui/osgi.bundle/1.1.204.v200811041823
  No repository found containing: org.eclipse.jst.j2ee.web/osgi.bundle/1.1.202.v200811060500
  No repository found containing: org.eclipse.jst.j2ee.webservice.ui/osgi.bundle/1.1.201.v200811062130
  No repository found containing: org.eclipse.jst.jee/osgi.bundle/1.0.102.v200811060500
  No repository found containing: org.eclipse.jst.jee.ejb/osgi.bundle/1.0.102.v200810230722
  No repository found containing: org.eclipse.jst.jee.ui/osgi.bundle/1.0.103.v200811131900
  No repository found containing: org.eclipse.jst.jee.web/osgi.bundle/1.0.101.v200810230738
  No repository found containing: org.eclipse.jst.jsp.core/osgi.bundle/1.2.120.v200810301812
  No repository found containing: org.eclipse.jst.jsp.ui/osgi.bundle/1.1.311.v200810210016
  No repository found containing: org.eclipse.jst.server.core/osgi.bundle/1.1.2.v20080930
  No repository found containing: org.eclipse.jst.server.tomcat.core/osgi.bundle/1.1.104.v20081006
  No repository found containing: org.eclipse.jst.server_adapters.feature/org.eclipse.update.feature/3.0.3.v20081006b-787KEKFDUUEFDFrPa7AMQ
  No repository found containing: org.eclipse.jst.server_core.feature/org.eclipse.update.feature/3.0.3.v20080930b-377Ap9oA55S5N_C35AC
  No repository found containing: org.eclipse.jst.server_ui.feature/org.eclipse.update.feature/3.0.3.v20081001-79-EDn9wKSZRCCNQMfVnIG8BHD
  No repository found containing: org.eclipse.jst.servlet.ui/osgi.bundle/1.1.203.v200810222000
  No repository found containing: org.eclipse.jst.web_core.feature/org.eclipse.update.feature/3.0.3.v200810020322-7M7AEX2EFp_acwkiuz-bTpl
  No repository found containing: org.eclipse.jst.web_ui.feature/org.eclipse.update.feature/3.0.3.v200810020322-7E4EArDgvY1en0e_Bm21-ljvz00c
  No repository found containing: org.eclipse.jst.ws.axis.consumption.core/osgi.bundle/1.0.306.v200810082309
  No repository found containing: org.eclipse.jst.ws.axis.consumption.ui/osgi.bundle/1.0.305.v200809301934
  No repository found containing: org.eclipse.jst.ws.axis2.core/osgi.bundle/1.0.104.v200810151442
  No repository found containing: org.eclipse.jst.ws.axis2tools.feature/org.eclipse.update.feature/1.0.2.v200810151341-77-E_ECYQCD4FdMjLXVW
  No repository found containing: org.eclipse.jst.ws.consumption/osgi.bundle/1.0.306.v200810012118
  No repository found containing: org.eclipse.jst.ws.consumption.ui/osgi.bundle/1.1.3.v200810012118
  No repository found containing: org.eclipse.jst.ws.consumption.ui.doc.user/osgi.bundle/1.0.500.v200810082020
  No repository found containing: org.eclipse.jst.ws.creation.ui/osgi.bundle/1.0.307.v200810012118
  No repository found containing: org.eclipse.wst.command.env/osgi.bundle/1.0.307.v200810082309
  No repository found containing: org.eclipse.wst.common.emf/osgi.bundle/1.1.203.v200811022047
  No repository found containing: org.eclipse.wst.common.emfworkbench.integration/osgi.bundle/1.1.202.v200811131900
  No repository found containing: org.eclipse.wst.common.frameworks/osgi.bundle/1.1.201.v200811060900
  No repository found containing: org.eclipse.wst.common.frameworks.ui/osgi.bundle/1.1.201.v200810020330
  No repository found containing: org.eclipse.wst.common.modulecore/osgi.bundle/1.1.204.v200811062000
  No repository found containing: org.eclipse.wst.common.project.facet.core/osgi.bundle/1.3.4.v200810151458
  No repository found containing: org.eclipse.wst.common.ui/osgi.bundle/1.1.302.v200810160107
  No repository found containing: org.eclipse.wst.common_core.feature/org.eclipse.update.feature/3.0.3.v200809301154-7C7_EVIE_EkMNrTtU7X4h2
  No repository found containing: org.eclipse.wst.common_ui.feature/org.eclipse.update.feature/3.0.3.v200809301154-7C78ELcE8VrRVouGlyiT4DsUuV8Y
  No repository found containing: org.eclipse.wst/org.eclipse.update.feature/3.0.3.v200809250443-7A-8i8Qqcz0FaVgjXSD6brFQN64Z
  No repository found containing: org.eclipse.wst.html.core/osgi.bundle/1.1.203.v200810291731
  No repository found containing: org.eclipse.wst.html.ui/osgi.bundle/1.0.302.v200810291731
  No repository found containing: org.eclipse.wst.jsdt.core/osgi.bundle/1.0.103.v200811042159
  No repository found containing: org.eclipse.wst.jsdt.doc/osgi.bundle/1.0.103.v200810081720
  No repository found containing: org.eclipse.wst.jsdt.feature/org.eclipse.update.feature/1.0.3.v200810020426-6-E73BcMAAwFIFUHpRJ
  No repository found containing: org.eclipse.wst.jsdt.support.firefox/osgi.bundle/1.0.103.v200810021840
  No repository found containing: org.eclipse.wst.jsdt.support.ie/osgi.bundle/1.0.103.v200810021840
  No repository found containing: org.eclipse.wst.jsdt.ui/osgi.bundle/1.0.103.v200810301820
  No repository found containing: org.eclipse.wst.jsdt.web.core/osgi.bundle/1.0.103.v200810021840
  No repository found containing: org.eclipse.wst.jsdt.web.support.jsp/osgi.bundle/1.0.103.v200810081720
  No repository found containing: org.eclipse.wst.jsdt.web.ui/osgi.bundle/1.0.103.v200810021840
  No repository found containing: org.eclipse.wst.server.core/osgi.bundle/1.1.2.v20081020
  No repository found containing: org.eclipse.wst.server.ui/osgi.bundle/1.1.3.v20080930
  No repository found containing: org.eclipse.wst.server.ui.doc.user/osgi.bundle/1.1.100.v200810082048
  No repository found containing: org.eclipse.wst.server_core.feature/org.eclipse.update.feature/3.0.3.v20080930b-20Al8s733I48671256
  No repository found containing: org.eclipse.wst.server_ui.feature/org.eclipse.update.feature/3.0.3.v20080930b-791CO9vESQmvbHKYENNI76CH
  No repository found containing: org.eclipse.wst.server_userdoc.feature/org.eclipse.update.feature/3.0.100.v200810082053-108Y7w311921193159
  No repository found containing: org.eclipse.wst.sse.ui/osgi.bundle/1.1.3.v200810301815
  No repository found containing: org.eclipse.wst.validation/osgi.bundle/1.2.3.v200811101716
  No repository found containing: org.eclipse.wst.validation.ui/osgi.bundle/1.2.2.v200810221105
  No repository found containing: org.eclipse.wst.web/osgi.bundle/1.1.205.v200811132030
  No repository found containing: org.eclipse.wst.web_core.feature/org.eclipse.update.feature/3.0.3.v200810010400-7G2EAsAM214fK_RKaovH35PiPtaH
  No repository found containing: org.eclipse.wst.web_ui.feature/org.eclipse.update.feature/3.0.3.v200810010400-7R0EOzE8Ks9uCz0nqrQF6yCFSQyI
  No repository found containing: org.eclipse.wst.ws.explorer/osgi.bundle/1.0.308.v200811062250
  No repository found containing: org.eclipse.wst.ws_core.feature/org.eclipse.update.feature/3.0.3.v200810012109-7H7QECgED69XqKg9nufm2_7C5J
  No repository found containing: org.eclipse.wst.ws_ui.feature/org.eclipse.update.feature/3.0.3.v200810012109-7E2EFVC-2f_FDJhnGKZmULIbsTaU
  No repository found containing: org.eclipse.wst.ws_userdoc.feature/org.eclipse.update.feature/3.0.2.v200810081944-34EDe9oA55S6I5S8KCS
  No repository found containing: org.eclipse.wst.ws_wsdl14.feature/org.eclipse.update.feature/1.4.1.v200809302010-13-7w311917141518
  No repository found containing: org.eclipse.wst.ws_wsdl15.feature/org.eclipse.update.feature/1.5.2.v200809302010-1407w311917141519
  No repository found containing: org.eclipse.wst.wsdl/osgi.bundle/1.1.202.v200809291819
  No repository found containing: org.eclipse.wst.wsdl.ui/osgi.bundle/1.2.103.v200810301738
  No repository found containing: org.eclipse.wst.wsdl.ui.doc.user/osgi.bundle/1.0.501.v200810081958
  No repository found containing: org.eclipse.wst.xml.core/osgi.bundle/1.1.306.v200810210016
  No repository found containing: org.eclipse.wst.xml.ui/osgi.bundle/1.0.420.v200810220345
  No repository found containing: org.eclipse.wst.xml_core.feature/org.eclipse.update.feature/3.0.3.v200810021802-7A7NEH0E7QYGHNIxPlGgVY
  No repository found containing: org.eclipse.wst.xml_ui.feature/org.eclipse.update.feature/3.0.3.v200809292000-7F2ENZCwum8U9-9yPhHnPkSb2VAc
  No repository found containing: org.eclipse.wst.xml_userdoc.feature/org.eclipse.update.feature/3.0.3.v200810090336-40EJs_kE77c8P_TALGS
  No repository found containing: org.eclipse.wst.xmleditor.doc.user/osgi.bundle/1.0.500.v200810081958
  No repository found containing: org.eclipse.wst.xsd.core/osgi.bundle/1.1.302.v200810020300
  No repository found containing: org.eclipse.wst.xsd.ui/osgi.bundle/1.2.104.v200810020602
  No repository found containing: org.eclipse.jpt.db/osgi.bundle/1.2.0.v200810300000
  No repository found containing: org.eclipse.jpt.db.ui/osgi.bundle/1.1.0.v200808210000
  No repository found containing: org.eclipse.jpt.gen/osgi.bundle/1.2.0.v200810080000
  No repository found containing: org.eclipse.jpt.utility/osgi.bundle/1.3.0.v200811030000
  No repository found containing: org.eclipse.jst.ws/osgi.bundle/1.0.306.v200810020426
  No repository found containing: org.eclipse.jst.ws.axis2.consumption.core/osgi.bundle/1.0.104.v200810151442
  No repository found containing: org.eclipse.jst.ws.axis2.creation.core/osgi.bundle/1.0.104.v200810151442
```

答:
Yet another solution -

Instead exporting all managed sites and importing them back,
click on 'edit' on each checked site and add '//' at the end

If you just add a '/' it says duplicate site therefore the '//'

How a small bug in a huge carefully architected application
can be so hard to debug yet simple to solve

OwnerDisplayName: mark

Title: Error when updating eclipse

Body:
I click update in eclipse and I get an error, it's because I updated eclipse more than once. Is there any way to fix eclipse and have the ability to use update?

An error occurred while collecting items to be installed
  No repository found containing: org.eclipse.jem/osgi.bundle/2.0.202.v200810282000
  No repository found containing: org.eclipse.jem.workbench/osgi.bundle/2.0.102.v200810230530
  No repository found containing: org.eclipse.jpt.core/osgi.bundle/2.1.0.v200812160210
  No repository found containing: org.eclipse.jpt.doc.user/osgi.bundle/1.0.300.v200812110000
  No repository found containing: org.eclipse.jpt.eclipselink.core/osgi.bundle/1.1.0.v200812110000
  No repository found containing: org.eclipse.jpt.eclipselink.core.ddlgen/osgi.bundle/1.0.100.v200811030000
  No repository found containing: org.eclipse.jpt.eclipselink.feature/org.eclipse.update.feature/2.1.0.v200812180210-318Y9oA55S8_795555
  No repository found containing: org.eclipse.jpt.eclipselink.ui/osgi.bundle/1.1.0.v200812100000
  No repository found containing: org.eclipse.jpt.feature/org.eclipse.update.feature/2.1.0.v200812180210-7979AgCYQCD4IRJdCEDC
  No repository found containing: org.eclipse.jpt.ui/osgi.bundle/2.1.0.v200812080000
  No repository found containing: org.eclipse.jst.common.frameworks/osgi.bundle/1.1.201.v200810161330
  No repository found containing: org.eclipse.jst.ejb.doc.user/osgi.bundle/1.1.100.v200810092245
  No repository found containing: org.eclipse.jst.ejb.ui/osgi.bundle/1.1.203.v200810010400
  No repository found containing: org.eclipse.jst.enterprise_core.feature/org.eclipse.update.feature/3.0.3.v200810010400-42E_4_kE77c_FAP7X99
  No repository found containing: org.eclipse.jst.enterprise_ui.feature/org.eclipse.update.feature/3.0.3.v200810010400-7Y7BFSrEPOwQPnUuwhYV60NEQtTn
  No repository found containing: org.eclipse.jst.enterprise_userdoc.feature/org.eclipse.update.feature/3.0.3.v200810131754-52EFBAgI99mAV9oGIHb
  No repository found containing: org.eclipse.jst/org.eclipse.update.feature/3.0.3.v200809250443-7U-9-9LJGGJebgG8HYgv5FBP0NUr
  No repository found containing: org.eclipse.jst.j2ee/osgi.bundle/1.1.204.v200811130630
  No repository found containing: org.eclipse.jst.j2ee.core/osgi.bundle/1.1.202.v200811111600
  No repository found containing: org.eclipse.jst.j2ee.ejb/osgi.bundle/1.1.203.v200811060500
  No repository found containing: org.eclipse.jst.j2ee.jca/osgi.bundle/1.1.203.v200811060900
  No repository found containing: org.eclipse.jst.j2ee.navigator.ui/osgi.bundle/1.1.202.v200810222000
  No repository found containing: org.eclipse.jst.j2ee.ui/osgi.bundle/1.1.204.v200811041823
  No repository found containing: org.eclipse.jst.j2ee.web/osgi.bundle/1.1.202.v200811060500
  No repository found containing: org.eclipse.jst.j2ee.webservice.ui/osgi.bundle/1.1.201.v200811062130
  No repository found containing: org.eclipse.jst.jee/osgi.bundle/1.0.102.v200811060500
  No repository found containing: org.eclipse.jst.jee.ejb/osgi.bundle/1.0.102.v200810230722
  No repository found containing: org.eclipse.jst.jee.ui/osgi.bundle/1.0.103.v200811131900
  No repository found containing: org.eclipse.jst.jee.web/osgi.bundle/1.0.101.v200810230738
  No repository found containing: org.eclipse.jst.jsp.core/osgi.bundle/1.2.120.v200810301812
  No repository found containing: org.eclipse.jst.jsp.ui/osgi.bundle/1.1.311.v200810210016
  No repository found containing: org.eclipse.jst.server.core/osgi.bundle/1.1.2.v20080930
  No repository found containing: org.eclipse.jst.server.tomcat.core/osgi.bundle/1.1.104.v20081006
  No repository found containing: org.eclipse.jst.server_adapters.feature/org.eclipse.update.feature/3.0.3.v20081006b-787KEKFDUUEFDFrPa7AMQ
  No repository found containing: org.eclipse.jst.server_core.feature/org.eclipse.update.feature/3.0.3.v20080930b-377Ap9oA55S5N_C35AC
  No repository found containing: org.eclipse.jst.server_ui.feature/org.eclipse.update.feature/3.0.3.v20081001-79-EDn9wKSZRCCNQMfVnIG8BHD
  No repository found containing: org.eclipse.jst.servlet.ui/osgi.bundle/1.1.203.v200810222000
  No repository found containing: org.eclipse.jst.web_core.feature/org.eclipse.update.feature/3.0.3.v200810020322-7M7AEX2EFp_acwkiuz-bTpl
  No repository found containing: org.eclipse.jst.web_ui.feature/org.eclipse.update.feature/3.0.3.v200810020322-7E4EArDgvY1en0e_Bm21-ljvz00c
  No repository found containing: org.eclipse.jst.ws.axis.consumption.core/osgi.bundle/1.0.306.v200810082309
  No repository found containing: org.eclipse.jst.ws.axis.consumption.ui/osgi.bundle/1.0.305.v200809301934
  No repository found containing: org.eclipse.jst.ws.axis2.core/osgi.bundle/1.0.104.v200810151442
  No repository found containing: org.eclipse.jst.ws.axis2tools.feature/org.eclipse.update.feature/1.0.2.v200810151341-77-E_ECYQCD4FdMjLXVW
  No repository found containing: org.eclipse.jst.ws.consumption/osgi.bundle/1.0.306.v200810012118
  No repository found containing: org.eclipse.jst.ws.consumption.ui/osgi.bundle/1.1.3.v200810012118
  No repository found containing: org.eclipse.jst.ws.consumption.ui.doc.user/osgi.bundle/1.0.500.v200810082020
  No repository found containing: org.eclipse.jst.ws.creation.ui/osgi.bundle/1.0.307.v200810012118
  No repository found containing: org.eclipse.wst.command.env/osgi.bundle/1.0.307.v200810082309
  No repository found containing: org.eclipse.wst.common.emf/osgi.bundle/1.1.203.v200811022047
  No repository found containing: org.eclipse.wst.common.emfworkbench.integration/osgi.bundle/1.1.202.v200811131900
  No repository found containing: org.eclipse.wst.common.frameworks/osgi.bundle/1.1.201.v200811060900
  No repository found containing: org.eclipse.wst.common.frameworks.ui/osgi.bundle/1.1.201.v200810020330
  No repository found containing: org.eclipse.wst.common.modulecore/osgi.bundle/1.1.204.v200811062000
  No repository found containing: org.eclipse.wst.common.project.facet.core/osgi.bundle/1.3.4.v200810151458
  No repository found containing: org.eclipse.wst.common.ui/osgi.bundle/1.1.302.v200810160107
  No repository found containing: org.eclipse.wst.common_core.feature/org.eclipse.update.feature/3.0.3.v200809301154-7C7_EVIE_EkMNrTtU7X4h2
  No repository found containing: org.eclipse.wst.common_ui.feature/org.eclipse.update.feature/3.0.3.v200809301154-7C78ELcE8VrRVouGlyiT4DsUuV8Y
  No repository found containing: org.eclipse.wst/org.eclipse.update.feature/3.0.3.v200809250443-7A-8i8Qqcz0FaVgjXSD6brFQN64Z
  No repository found containing: org.eclipse.wst.html.core/osgi.bundle/1.1.203.v200810291731
  No repository found containing: org.eclipse.wst.html.ui/osgi.bundle/1.0.302.v200810291731
  No repository found containing: org.eclipse.wst.jsdt.core/osgi.bundle/1.0.103.v200811042159
  No repository found containing: org.eclipse.wst.jsdt.doc/osgi.bundle/1.0.103.v200810081720
  No repository found containing: org.eclipse.wst.jsdt.feature/org.eclipse.update.feature/1.0.3.v200810020426-6-E73BcMAAwFIFUHpRJ
  No repository found containing: org.eclipse.wst.jsdt.support.firefox/osgi.bundle/1.0.103.v200810021840
  No repository found containing: org.eclipse.wst.jsdt.support.ie/osgi.bundle/1.0.103.v200810021840
  No repository found containing: org.eclipse.wst.jsdt.ui/osgi.bundle/1.0.103.v200810301820
  No repository found containing: org.eclipse.wst.jsdt.web.core/osgi.bundle/1.0.103.v200810021840
  No repository found containing: org.eclipse.wst.jsdt.web.support.jsp/osgi.bundle/1.0.103.v200810081720
  No repository found containing: org.eclipse.wst.jsdt.web.ui/osgi.bundle/1.0.103.v200810021840
  No repository found containing: org.eclipse.wst.server.core/osgi.bundle/1.1.2.v20081020
  No repository found containing: org.eclipse.wst.server.ui/osgi.bundle/1.1.3.v20080930
  No repository found containing: org.eclipse.wst.server.ui.doc.user/osgi.bundle/1.1.100.v200810082048
  No repository found containing: org.eclipse.wst.server_core.feature/org.eclipse.update.feature/3.0.3.v20080930b-20Al8s733I48671256
  No repository found containing: org.eclipse.wst.server_ui.feature/org.eclipse.update.feature/3.0.3.v20080930b-791CO9vESQmvbHKYENNI76CH
  No repository found containing: org.eclipse.wst.server_userdoc.feature/org.eclipse.update.feature/3.0.100.v200810082053-108Y7w311921193159
  No repository found containing: org.eclipse.wst.sse.ui/osgi.bundle/1.1.3.v200810301815
  No repository found containing: org.eclipse.wst.validation/osgi.bundle/1.2.3.v200811101716
  No repository found containing: org.eclipse.wst.validation.ui/osgi.bundle/1.2.2.v200810221105
  No repository found containing: org.eclipse.wst.web/osgi.bundle/1.1.205.v200811132030
  No repository found containing: org.eclipse.wst.web_core.feature/org.eclipse.update.feature/3.0.3.v200810010400-7G2EAsAM214fK_RKaovH35PiPtaH
  No repository found containing: org.eclipse.wst.web_ui.feature/org.eclipse.update.feature/3.0.3.v200810010400-7R0EOzE8Ks9uCz0nqrQF6yCFSQyI
  No repository found containing: org.eclipse.wst.ws.explorer/osgi.bundle/1.0.308.v200811062250
  No repository found containing: org.eclipse.wst.ws_core.feature/org.eclipse.update.feature/3.0.3.v200810012109-7H7QECgED69XqKg9nufm2_7C5J
  No repository found containing: org.eclipse.wst.ws_ui.feature/org.eclipse.update.feature/3.0.3.v200810012109-7E2EFVC-2f_FDJhnGKZmULIbsTaU
  No repository found containing: org.eclipse.wst.ws_userdoc.feature/org.eclipse.update.feature/3.0.2.v200810081944-34EDe9oA55S6I5S8KCS
  No repository found containing: org.eclipse.wst.ws_wsdl14.feature/org.eclipse.update.feature/1.4.1.v200809302010-13-7w311917141518
  No repository found containing: org.eclipse.wst.ws_wsdl15.feature/org.eclipse.update.feature/1.5.2.v200809302010-1407w311917141519
  No repository found containing: org.eclipse.wst.wsdl/osgi.bundle/1.1.202.v200809291819
  No repository found containing: org.eclipse.wst.wsdl.ui/osgi.bundle/1.2.103.v200810301738
  No repository found containing: org.eclipse.wst.wsdl.ui.doc.user/osgi.bundle/1.0.501.v200810081958
  No repository found containing: org.eclipse.wst.xml.core/osgi.bundle/1.1.306.v200810210016
  No repository found containing: org.eclipse.wst.xml.ui/osgi.bundle/1.0.420.v200810220345
  No repository found containing: org.eclipse.wst.xml_core.feature/org.eclipse.update.feature/3.0.3.v200810021802-7A7NEH0E7QYGHNIxPlGgVY
  No repository found containing: org.eclipse.wst.xml_ui.feature/org.eclipse.update.feature/3.0.3.v200809292000-7F2ENZCwum8U9-9yPhHnPkSb2VAc
  No repository found containing: org.eclipse.wst.xml_userdoc.feature/org.eclipse.update.feature/3.0.3.v200810090336-40EJs_kE77c8P_TALGS
  No repository found containing: org.eclipse.wst.xmleditor.doc.user/osgi.bundle/1.0.500.v200810081958
  No repository found containing: org.eclipse.wst.xsd.core/osgi.bundle/1.1.302.v200810020300
  No repository found containing: org.eclipse.wst.xsd.ui/osgi.bundle/1.2.104.v200810020602
  No repository found containing: org.eclipse.jpt.db/osgi.bundle/1.2.0.v200810300000
  No repository found containing: org.eclipse.jpt.db.ui/osgi.bundle/1.1.0.v200808210000
  No repository found containing: org.eclipse.jpt.gen/osgi.bundle/1.2.0.v200810080000
  No repository found containing: org.eclipse.jpt.utility/osgi.bundle/1.3.0.v200811030000
  No repository found containing: org.eclipse.jst.ws/osgi.bundle/1.0.306.v200810020426
  No repository found containing: org.eclipse.jst.ws.axis2.consumption.core/osgi.bundle/1.0.104.v200810151442
  No repository found containing: org.eclipse.jst.ws.axis2.creation.core/osgi.bundle/1.0.104.v200810151442


问:
Confusing correlation output from stats::cor() with dichotomous data in R
I have the data.frame df with three variables with values of "1" or "0" and no rows with more than one of the variables with a "1":

```<code>> df <- structure(list(var1 = c(0, 0, 0, 0, 1, 0, 0, 1, 0, 0), var2 = c(1,
0, 0, 0, 0, 0, 0, 0, 0, 0), var3 = c(0, 1, 0, 1, 0, 1, 0, 0,
0, 1)), .Names = c("var1", "var2", "var3"), row.names = c(NA,
-10L), class = c("tbl_df", "tbl", "data.frame"))

> df

   var1 var2 var3
1     0    1    0
2     0    0    1
3     0    0    0
4     0    0    1
5     1    0    0
6     0    0    1
7     0    0    0
8     1    0    0
9     0    0    0
10    0    0    1
</code>```

The row sums are less than 1 for all of the rows:

```<code>> rowSums(df)
 [1] 1 1 0 1 1 1 0 1 0 1
</code>```

When I look at the correlations (I used the "spearman" argument because the data are "1"s and "0"s), the output is confusing because there are correlations that are non-zero:

```<code>cor(df, method = "spearman")
           var1       var2       var3
var1  1.0000000 -0.1666667 -0.4082483
var2 -0.1666667  1.0000000 -0.2721655
var3 -0.4082483 -0.2721655  1.0000000
</code>```

I wondered if this was some strange side-effect of stats::cor(), so I tried Hmisc::rcorr() with the same result:

```<code>> Hmisc::rcorr(as.matrix(df), type = "spearman")
      var1  var2  var3
var1  1.00 -0.17 -0.41
var2 -0.17  1.00 -0.27
var3 -0.41 -0.27  1.00
</code>```

Shouldn't the correlations between all three variables be 0 because there are no rows in which more than one variable has a value of "1"? Am I misunderstanding how correlations work in some profound way? Or am I using these functions incorrectly?

答:
Your observation of the row sums to be all smaller than 1 actually implies that there is some negative correlation between the variables, because the meaning of negative correlation is one variable bigger (in your case 1), one variable smaller (in your case 0), which is in agree with your results.

Your confusion might arise because of the inner product of any of the two variables to be zero, but inner product to be zero doesn't mean there is no correlation (it only means there is no linear correlation only when every variable is standardized to have mean zero, which your case certainly is not).

Body:
I have the data.frame df with three variables with values of "1" or "0" and no rows with more than one of the variables with a "1":

> df <- structure(list(var1 = c(0, 0, 0, 0, 1, 0, 0, 1, 0, 0), var2 = c(1,
0, 0, 0, 0, 0, 0, 0, 0, 0), var3 = c(0, 1, 0, 1, 0, 1, 0, 0,
0, 1)), .Names = c("var1", "var2", "var3"), row.names = c(NA,
-10L), class = c("tbl_df", "tbl", "data.frame"))

> df

   var1 var2 var3
1     0    1    0
2     0    0    1
3     0    0    0
4     0    0    1
5     1    0    0
6     0    0    1
7     0    0    0
8     1    0    0
9     0    0    0
10    0    0    1

The row sums are less than 1 for all of the rows:

> rowSums(df)
 [1] 1 1 0 1 1 1 0 1 0 1

When I look at the correlations (I used the "spearman" argument because the data are "1"s and "0"s), the output is confusing because there are correlations that are non-zero:

cor(df, method = "spearman")
           var1       var2       var3
var1  1.0000000 -0.1666667 -0.4082483
var2 -0.1666667  1.0000000 -0.2721655
var3 -0.4082483 -0.2721655  1.0000000

I wondered if this was some strange side-effect of stats::cor(), so I tried Hmisc::rcorr() with the same result:

> Hmisc::rcorr(as.matrix(df), type = "spearman")
      var1  var2  var3
var1  1.00 -0.17 -0.41
var2 -0.17  1.00 -0.27
var3 -0.41 -0.27  1.00

Shouldn't the correlations between all three variables be 0 because there are no rows in which more than one variable has a value of "1"? Am I misunderstanding how correlations work in some profound way? Or am I using these functions incorrectly?


问:
How to apply functional programming to remove two nested for i in?
originally I had this awful piece of code with two for i in. To sum up, the idea is to get a list of AMI's ID of some AMIS with a particular tag. To do so, I iterate over list (wrong!) and I get a list of IDS.

```<code>def aws_get_images_exceptions(connection, exceptions):
 list_exceptions = []
    for ex in exceptions:
        images = connection.get_all_images(filters={ "tag-key":"Name","tag-value":ex})
        for ami in images:
            list_exceptions.append(ami.id)
    return list_exceptions
</code>```

Over each iteration I get the complete list of "exceptions" based on the fixed tag Role that I provide to function and then I append the right AMIS.

Ok, I was able to remove the second for i in with the next code:

```<code>def aws_get_images_exceptions(connection, exceptions):
for ex in exceptions:
        images = connection.get_all_images(filters={ "tag-key":"Name","tag-value":ex})
       list_exceptions = list(map(lambda x: x.id, images)) + list_exceptions
return list_exceptions
</code>```

I've checked and I get the same amount of AMIS, same IDS, etc. But I don't get the way to do it in a functional way removing the very first for. As you notice I do a manual call to get_all_images because I iterate over a list of "exceptions" which I give to the function.

Do you know how I can remove this first for i in?

Thanks to all!

答:
It's certainly possible, simply by nesting fors in your list comprehension:

```<code>def aws_get_images_exceptions(connection, exceptions):
    list_exceptions = [ami.id for ex in exceptions for ami in connection.get_all_images(filters={ "tag-key":"Name","tag-value":ex})]
    return list_exceptions
</code>```

However, that doesn't mean it's good code. I find your original function much easier to read than my own abomination here.

Body:
originally I had this awful piece of code with two for i in. To sum up, the idea is to get a list of AMI's ID of some AMIS with a particular tag. To do so, I iterate over list (wrong!) and I get a list of IDS.

def aws_get_images_exceptions(connection, exceptions):
 list_exceptions = []
    for ex in exceptions:
        images = connection.get_all_images(filters={ "tag-key":"Name","tag-value":ex})
        for ami in images:
            list_exceptions.append(ami.id)
    return list_exceptions

Over each iteration I get the complete list of "exceptions" based on the fixed tag Role that I provide to function and then I append the right AMIS.

Ok, I was able to remove the second for i in with the next code:

def aws_get_images_exceptions(connection, exceptions):
for ex in exceptions:
        images = connection.get_all_images(filters={ "tag-key":"Name","tag-value":ex})
       list_exceptions = list(map(lambda x: x.id, images)) + list_exceptions
return list_exceptions

I've checked and I get the same amount of AMIS, same IDS, etc. But I don't get the way to do it in a functional way removing the very first for. As you notice I do a manual call to get_all_images because I iterate over a list of "exceptions" which I give to the function.

Do you know how I can remove this first for i in?

Thanks to all!

Body:
It's certainly possible, simply by nesting fors in your list comprehension:

def aws_get_images_exceptions(connection, exceptions):
    list_exceptions = [ami.id for ex in exceptions for ami in connection.get_all_images(filters={ "tag-key":"Name","tag-value":ex})]
    return list_exceptions

However, that doesn't mean it's good code. I find your original function much easier to read than my own abomination here.


问:
Dealing with non-trivial command and event payloads in Axon
Whenever I take a look at Axon Bank I start wondering whether I should follow a set of design rules for events and commands.

In Axon Bank both events and commands exclusively consist of primitives. In my applications I tend to avoid primitive usage as much as possible, mainly to build an expressive domain and to have type safety wherever I can get it.

Axon itself comes around with some DDD references but no matter which documents I browse, not a single example makes use of compound objects as part of event/command payloads.

Which confuses me. There is built-in-support for full-blown xml and json serialization capable of more than just having some key-value pairs.

I understand that especially events tend to be small and simple structures since they only reflect incremental state changes but there will always be some kind of gap between a complex domain model and an event (entry).

In my domain I could have a bunch of Classes like OverdraftLimit, CurrentBalance, Deposit and AccountIdentifier.

Now there are two possible ways to design events and commands:

1. Primitives and extensive converting

Treat Events as raw data with a nice label on it

Convert raw data to powerful objects as soon as it "enters" the application

When creating events simply strip them down again.

```<code>public class BankAccountcreatedEvent {
    private final String accountIdentifier;
    private final int overdraftLimt;

    // ...
}
</code>```

And somewhere else:

```<code>public void on (BankAccountCreatedEvent event) {
    this.accountIdentifier = AccountIentifier.fromString(event.getAccountIdentifier());
    this.overdraftLimit = new OverdraftLimit(event.getOverdraftLimit());
}
</code>```

Pros:

Simple command/event API that does not have any weird dependencies

Makes distribution easier

Upcasters will only be needed if the actual event structure changes and therefore can be anticipated easily.

Cons:

A huge conversion layer needs to be written and maintained

Decoupling events/commands and the rest of the domain model for mainly technical reasons introduces a new, artificial, contextual gap

2. Expressive Payloads

Use sophisticated types directly as attributes

```<code>public class BankAccountCreatedEvent {
    private final BankAccountIdentifier bankAccountIdentifier;
    private final OverdraftLimit overdraftLimit;

    //..
}
</code>```

Pros:

Less to write, easier to read

Keep together what naturally belongs together

Cons:

Domain logic influences event structure indirectly, upcasting will be needed more frequently and will be less predictable.

I need a second opinion. Is there a recommended way?

答:
The primary thing to keep in mind is that the serialized form of the Event is your formal contract. How you represent that in Java classes is up to each application, in the end. If you configure your serializer to ignore unknown fields, you can leave fields you don't care about out, for example.

Personally, I don't mind primitives in Events. However, I do understand the value of using explicit Value Objects for certain fields, as they allow you to express the "mathematics" involved with each of them. In the case of identifiers, they prevent a "mix-up" where an identifier is used to accidentally attempt to identify another type of object.

In the end, it doesn't matter that much. With a few simple Jackson annotations, you can translate these Value Objects to a simple value in JSON. Check out @JsonValue, for example.

```<code>public class BankAccountCreatedEvent {
    private final BankAccountIdentifier bankAccountIdentifier;
    private final OverdraftLimit overdraftLimit;

    //..
}
</code>```

would map to:

```<code>{
    "bankAccountIdentifier": "abcdef1234",
    "overdraftLimit" : 1000
}
</code>```

If the BankAccountIdentifier and OverdraftLimit classes would both have an @JsonValue annotated method that would return their 'simple' value.

Body:
Whenever I take a look at Axon Bank I start wondering whether I should follow a set of design rules for events and commands.

In Axon Bank both events and commands exclusively consist of primitives. In my applications I tend to avoid primitive usage as much as possible, mainly to build an expressive domain and to have type safety wherever I can get it.

Axon itself comes around with some DDD references but no matter which documents I browse, not a single example makes use of compound objects as part of event/command payloads.

Which confuses me. There is built-in-support for full-blown xml and json serialization capable of more than just having some key-value pairs.

I understand that especially events tend to be small and simple structures since they only reflect incremental state changes but there will always be some kind of gap between a complex domain model and an event (entry).

In my domain I could have a bunch of Classes like OverdraftLimit, CurrentBalance, Deposit and AccountIdentifier.

Now there are two possible ways to design events and commands:

1. Primitives and extensive converting

Treat Events as raw data with a nice label on it

Convert raw data to powerful objects as soon as it "enters" the application

When creating events simply strip them down again.

public class BankAccountcreatedEvent {
    private final String accountIdentifier;
    private final int overdraftLimt;

    // ...
}

And somewhere else:

public void on (BankAccountCreatedEvent event) {
    this.accountIdentifier = AccountIentifier.fromString(event.getAccountIdentifier());
    this.overdraftLimit = new OverdraftLimit(event.getOverdraftLimit());
}

Pros:

Simple command/event API that does not have any weird dependencies

Makes distribution easier

Upcasters will only be needed if the actual event structure changes and therefore can be anticipated easily.

Cons:

A huge conversion layer needs to be written and maintained

Decoupling events/commands and the rest of the domain model for mainly technical reasons introduces a new, artificial, contextual gap

2. Expressive Payloads

Use sophisticated types directly as attributes

public class BankAccountCreatedEvent {
    private final BankAccountIdentifier bankAccountIdentifier;
    private final OverdraftLimit overdraftLimit;

    //..
}

Pros:

Less to write, easier to read

Keep together what naturally belongs together

Cons:

Domain logic influences event structure indirectly, upcasting will be needed more frequently and will be less predictable.

I need a second opinion. Is there a recommended way?

Body:
The primary thing to keep in mind is that the serialized form of the Event is your formal contract. How you represent that in Java classes is up to each application, in the end. If you configure your serializer to ignore unknown fields, you can leave fields you don't care about out, for example.

Personally, I don't mind primitives in Events. However, I do understand the value of using explicit Value Objects for certain fields, as they allow you to express the "mathematics" involved with each of them. In the case of identifiers, they prevent a "mix-up" where an identifier is used to accidentally attempt to identify another type of object.

In the end, it doesn't matter that much. With a few simple Jackson annotations, you can translate these Value Objects to a simple value in JSON. Check out @JsonValue, for example.

public class BankAccountCreatedEvent {
    private final BankAccountIdentifier bankAccountIdentifier;
    private final OverdraftLimit overdraftLimit;

    //..
}

would map to:

{
    "bankAccountIdentifier": "abcdef1234",
    "overdraftLimit" : 1000
}

If the BankAccountIdentifier and OverdraftLimit classes would both have an @JsonValue annotated method that would return their 'simple' value.


问:
Parsing arguments in python with any order
I am trying to parse command line arguments and I have never done it before. I have tried a few things. The code below is the last thing that I tried, but I received the error: "unrecognized arguments". I want to be able to put something like

```<code>copy-column-csv.py cname=Quiz source=source.csv target=target.csv out=out.csv
</code>```

on the command line, but also have the ability to have it in any order. I am not sure how to go about this. Below is my code:

```<code>import argparse
import sys, re
import numpy as np
import smtplib
from random import randint
import csv
import math
import pandas as pd

parser = argparse.ArgumentParser()
parser.add_argument('-cname')
parser.add_argument('-source')
parser.add_argument('-target')
parser.add_argument('-out')
args = parser.parse_args()

#col = sys.argv[1]
#source = sys.argv[2]
#target = sys.argv[3]
#newtarg = sys.argv[4]

sourceFile = pd.read_csv(source)
targetFile = pd.read_csv(target)
del targetFile[cname]
targetFile[col] = pd.Series(sourceFile[col])
targetFile.to_csv(out, index = False)
</code>```

答:
Here is an example of how I'm doing it.

```<code>from optparse import OptionParser
from optparse import OptionGroup

parser = OptionParser(usage)

required = OptionGroup(parser, "Required Arguments")
required.add_option("--genome", dest="genome_file", help="File representing genome. FASTA nucleotide format. ")
required.add_option("--anno", dest="anno_file", help="File containing genome annotation information in GTF/GFF3 format. ")
required.add_option("--output", dest="prefix", help="Creates a folder named with the supplied prefix containing output files. ")

parser.add_option_group(required)

if len(args) != 0 or not options.genome_file or not options.anno_file or not options.prefix:
    parser.error("Required arguments have not been supplied.  \n\t\tUse -h to get more information.")
    sys.exit()
</code>```

You'll pass the arguments when you run it, for example, with --genome=myfile.txt, and in the code that value becomes options.genome_file.

Body:
I am trying to parse command line arguments and I have never done it before. I have tried a few things. The code below is the last thing that I tried, but I received the error: "unrecognized arguments". I want to be able to put something like

copy-column-csv.py cname=Quiz source=source.csv target=target.csv out=out.csv

on the command line, but also have the ability to have it in any order. I am not sure how to go about this. Below is my code:

import argparse
import sys, re
import numpy as np
import smtplib
from random import randint
import csv
import math
import pandas as pd

parser = argparse.ArgumentParser()
parser.add_argument('-cname')
parser.add_argument('-source')
parser.add_argument('-target')
parser.add_argument('-out')
args = parser.parse_args()

#col = sys.argv[1]
#source = sys.argv[2]
#target = sys.argv[3]
#newtarg = sys.argv[4]

sourceFile = pd.read_csv(source)
targetFile = pd.read_csv(target)
del targetFile[cname]
targetFile[col] = pd.Series(sourceFile[col])
targetFile.to_csv(out, index = False)

Body:
Here is an example of how I'm doing it.

from optparse import OptionParser
from optparse import OptionGroup

parser = OptionParser(usage)

required = OptionGroup(parser, "Required Arguments")
required.add_option("--genome", dest="genome_file", help="File representing genome. FASTA nucleotide format. ")
required.add_option("--anno", dest="anno_file", help="File containing genome annotation information in GTF/GFF3 format. ")
required.add_option("--output", dest="prefix", help="Creates a folder named with the supplied prefix containing output files. ")

parser.add_option_group(required)

if len(args) != 0 or not options.genome_file or not options.anno_file or not options.prefix:
    parser.error("Required arguments have not been supplied.  \n\t\tUse -h to get more information.")
    sys.exit()

You'll pass the arguments when you run it, for example, with --genome=myfile.txt, and in the code that value becomes options.genome_file.


问:
Can't access 'plans' section when creating service broker in Pivotal Cloud Foundry
Documentation for Service Broker API:

https://docs.pivotal.io/pivotalcf/1-10/services/api.html#authentication

The documentation above claims to implement /v2/catalog to return a json similar to the following:

```<code>{
"services": [{
"name": "fake-service",
"id": "acb56d7c-XXXX-XXXX-XXXX-feb140a59a66",
"description": "fake service",
"tags": ["no-sql", "relational"],
"requires": ["route_forwarding"],
"bindable": true,
"metadata": {
  "provider": {
    "name": "The name"
  },
  "listing": {
    "imageUrl": "http://example.com/cat.gif",
    "blurb": "Add a blurb here",
    "longDescription": "A long time ago, in a galaxy far far away..."
  },
  "displayName": "The Fake Broker"
},
"dashboard_client": {
  "id": "398e2f8e-XXXX-XXXX-XXXX-19a71ecbcf64",
  "secret": "277cabb0-XXXX-XXXX-XXXX-7822c0a90e5d",
  "redirect_uri": "http://localhost:1234"
},
"plan_updateable": true,
"plans": [{
  "name": "fake-plan-1",
  "id": "d3031751-XXXX-XXXX-XXXX-a42377d3320e",
  "description": "Shared fake Server, 5tb persistent disk, 40 max concurrent connections",
  "max_storage_tb": 5,
  "metadata": {
    "costs":[
        {
           "amount":{
              "usd":99.0
           },
           "unit":"MONTHLY"
        },
        {
           "amount":{
              "usd":0.99
           },
           "unit":"1GB of messages over 20GB"
        }
     ],
    "bullets": [
        "Shared fake server",
        "5 TB storage",
        "40 concurrent connections"
    ],
  }
}, {
  "name": "fake-plan-2",
  "id": "0f4008b5-XXXX-XXXX-XXXX-dace631cd648",
  "description": "Shared fake Server, 5tb persistent disk, 40 max concurrent connections. 100 async",
  "max_storage_tb": 5,
  "metadata": {
    "costs":[
        {
           "amount":{
              "usd":199.0
           },
           "unit":"MONTHLY"
        },
        {
           "amount":{
              "usd":0.99
           },
           "unit":"1GB of messages over 20GB"
        }
     ],
    "bullets": [
      "40 concurrent connections"
    ]
  }
}]
}]
}
</code>```

I have successfully created this endpoint in our PCF application and ran the command:

```<code>cf create-service-broker p-service myemail@whatever.com somethingSecure http://broker.url.com --space-scoped
Creating service broker p-service in org ourOrg / space dev as myemail@whatever.com...
OK
</code>```

I can then see the service-broker in our Org. But when I click on the broker to view the 'plans' section I get the following errors in the console and the page does not direct.

```<code>Uncaught (in promise) TypeError: Cannot read property 'name' of undefined
    at t.value (application.js:20)
    at p._renderValidatedComponentWithoutOwnerOrContext (react.js:13)
    at p._renderValidatedComponent (react.js:13)
    at performInitialMount (react.js:13)
    at p.mountComponent (react.js:13)
    at Object.mountComponent (react.js:15)
    at h.mountChildren (react.js:14)
    at h._createInitialChildren (react.js:13)
    at h.mountComponent (react.js:13)
    at Object.mountComponent (react.js:15)
react.js:15 Uncaught (in promise) TypeError: Cannot read property 'getHostNode' of null
    at Object.getHostNode (react.js:15)
    at p.getHostNode (react.js:13)
    at Object.getHostNode (react.js:15)
    at Object.updateChildren (react.js:13)
    at h._reconcilerUpdateChildren (react.js:14)
    at h._updateChildren (react.js:14)
    at h.updateChildren (react.js:14)
    at h._updateDOMChildren (react.js:14)
    at h.updateComponent (react.js:13)
    at h.receiveComponent (react.js:13)
</code>```

Is the only requirement for a working service broker the /v2/catalog api endpoint? Or do we need to implement the other endpoints from the documentation linked above? Any help would be appreciated.

答: This ended up being a PCF version issue. Needed version 247 but had version 246.</p>

Body:
Documentation for Service Broker API:

https://docs.pivotal.io/pivotalcf/1-10/services/api.html#authentication

The documentation above claims to implement /v2/catalog to return a json similar to the following:

{
"services": [{
"name": "fake-service",
"id": "acb56d7c-XXXX-XXXX-XXXX-feb140a59a66",
"description": "fake service",
"tags": ["no-sql", "relational"],
"requires": ["route_forwarding"],
"bindable": true,
"metadata": {
  "provider": {
    "name": "The name"
  },
  "listing": {
    "imageUrl": "http://example.com/cat.gif",
    "blurb": "Add a blurb here",
    "longDescription": "A long time ago, in a galaxy far far away..."
  },
  "displayName": "The Fake Broker"
},
"dashboard_client": {
  "id": "398e2f8e-XXXX-XXXX-XXXX-19a71ecbcf64",
  "secret": "277cabb0-XXXX-XXXX-XXXX-7822c0a90e5d",
  "redirect_uri": "http://localhost:1234"
},
"plan_updateable": true,
"plans": [{
  "name": "fake-plan-1",
  "id": "d3031751-XXXX-XXXX-XXXX-a42377d3320e",
  "description": "Shared fake Server, 5tb persistent disk, 40 max concurrent connections",
  "max_storage_tb": 5,
  "metadata": {
    "costs":[
        {
           "amount":{
              "usd":99.0
           },
           "unit":"MONTHLY"
        },
        {
           "amount":{
              "usd":0.99
           },
           "unit":"1GB of messages over 20GB"
        }
     ],
    "bullets": [
        "Shared fake server",
        "5 TB storage",
        "40 concurrent connections"
    ],
  }
}, {
  "name": "fake-plan-2",
  "id": "0f4008b5-XXXX-XXXX-XXXX-dace631cd648",
  "description": "Shared fake Server, 5tb persistent disk, 40 max concurrent connections. 100 async",
  "max_storage_tb": 5,
  "metadata": {
    "costs":[
        {
           "amount":{
              "usd":199.0
           },
           "unit":"MONTHLY"
        },
        {
           "amount":{
              "usd":0.99
           },
           "unit":"1GB of messages over 20GB"
        }
     ],
    "bullets": [
      "40 concurrent connections"
    ]
  }
}]
}]
}

I have successfully created this endpoint in our PCF application and ran the command:

cf create-service-broker p-service myemail@whatever.com somethingSecure http://broker.url.com --space-scoped
Creating service broker p-service in org ourOrg / space dev as myemail@whatever.com...
OK

I can then see the service-broker in our Org. But when I click on the broker to view the 'plans' section I get the following errors in the console and the page does not direct.

Uncaught (in promise) TypeError: Cannot read property 'name' of undefined
    at t.value (application.js:20)
    at p._renderValidatedComponentWithoutOwnerOrContext (react.js:13)
    at p._renderValidatedComponent (react.js:13)
    at performInitialMount (react.js:13)
    at p.mountComponent (react.js:13)
    at Object.mountComponent (react.js:15)
    at h.mountChildren (react.js:14)
    at h._createInitialChildren (react.js:13)
    at h.mountComponent (react.js:13)
    at Object.mountComponent (react.js:15)
react.js:15 Uncaught (in promise) TypeError: Cannot read property 'getHostNode' of null
    at Object.getHostNode (react.js:15)
    at p.getHostNode (react.js:13)
    at Object.getHostNode (react.js:15)
    at Object.updateChildren (react.js:13)
    at h._reconcilerUpdateChildren (react.js:14)
    at h._updateChildren (react.js:14)
    at h.updateChildren (react.js:14)
    at h._updateDOMChildren (react.js:14)
    at h.updateComponent (react.js:13)
    at h.receiveComponent (react.js:13)

Is the only requirement for a working service broker the /v2/catalog api endpoint? Or do we need to implement the other endpoints from the documentation linked above? Any help would be appreciated.


问:
Android AlarmManager RTC doesn't pause while device is sleeping
I wrote a little widget for Android devices.

The widget uses AlarmManager to set recurring updates.
I'm using the RTC clock for the AlarmManager.

According to the documentation, if the device is sleeping, the RTC clock won't wake up the device and the next update will be when the device is woken.

I have a log file for the widget which shows when it was updated.

Even when I don't touch the device , I still see updates in the log file.

Why is that? shouldn't the device be sleeping and thus my widget shouldn't update?

I'm using System.currentTimeMillis() for the starting time so it should be correct for RTC clock.

答: You need to disconnect device from your desktop. When device is charging it doesn't go to sleep mode even when screen is black.</p>


问:
Auth0-js and usePostMessage flag
I am having problems compiling an Angular app that uses auth0-js package. The renewAuth(options: RenewAuthOptions, callback: Auth0Callback<any>): void; method used in the code (but also in the examples) uses a parameter {usePostMessage: true}, which is not compatible with the RenewAuthOptions interface found in "@types/auth0-js": "^8.3.0" which does not include that property.

How should I solve the problem?

答:
You can use declaration merging to add properties to the interface. You can add this to a separate custom *.d.ts file or in the same *.ts file where you need it:

```<code>declare module "auth0-js" {
    interface RenewAuthOptions {
        usePostMessage: boolean
    }
}
</code>```

But if you think that this is a valid property supported by the library you can raise a PR against the DefinitelyTyped repo with the updated property so it is available for everyone.

Title: Auth0-js and usePostMessage flag

Body:
You can use declaration merging to add properties to the interface. You can add this to a separate custom *.d.ts file or in the same *.ts file where you need it:

declare module "auth0-js" {
    interface RenewAuthOptions {
        usePostMessage: boolean
    }
}

But if you think that this is a valid property supported by the library you can raise a PR against the DefinitelyTyped repo with the updated property so it is available for everyone.


问:
How to render a variable in a django template?
My goal is to write dynamically some urls of images in the HTML page. Urls are stored in a database.

To do so, first I am trying to render a simple varable in a template.  Reading the docs and other sources, it should be done in 3 steps:

For the configuration: in settings.py

```<code>TEMPLATES = [
{
    'OPTIONS': {
        'debug': DEBUG,
        'context_processors': [
            …
            'django.template.context_processors.request',
            'django.template.context_processors.debug',
            'django.template.context_processors.i18n',
            'django.template.context_processors.media',
            'django.template.context_processors.static',
            'django.template.context_processors.tz',
            'django.contrib.messages.context_processors.messages',            ],
    },
},
</code>```

]

The variable name in the template: In MyHTMLFile.html is foo

```<code>…
<td>MyLabel</td><td><p>{{ foo }}</p></td><td>-----------</td>
…
</code>```

in the view.py, one of the lines

```<code>myvar1 ="BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
context = {foo: myvar1,}

return render_to_response("MyHTMLFile.html", context, context_instance = RequestContext(request) )
return render(request, 'MyHTMLFile.html', {foo: myvar1})
return render_to_response("MyHTMLFile.html", context , context_instance=RequestContext(request) )
return render(request, 'MyHTMLFile.html', context)
</code>```

The html page is well rendered, but no data in the html table.

Do you have an idea ? I am curious to know what i misunderstand.

Regarding the versio, i am using:
python: Python 2.7.13
django: 1.10.5

Thank you

答:
```<code>context = {foo: myvar1,}
</code>```

This should give you a NameError unless ofcourse you have a variable named foo in which case it may or may not hold a string foo. So in short you are not sending the right data to the template. It should be

```<code>context = {'foo': myvar1,}
</code>```

And then

```<code>return render_to_response("MyHTMLFile.html", context, context_instance = RequestContext(request) )
# Below this line code will not be executed.
return render(request, 'MyHTMLFile.html', {foo: myvar1})
return render_to_response("MyHTMLFile.html", context , context_instance=RequestContext(request) )
return render(request, 'MyHTMLFile.html', context)
</code>```

note that the return keyword returns from the function. Code after that doesn't get executed.

lastly render_to_response is deprecated. render is the current function to use.

Body:
My goal is to write dynamically some urls of images in the HTML page. Urls are stored in a database.

To do so, first I am trying to render a simple varable in a template.  Reading the docs and other sources, it should be done in 3 steps:

For the configuration: in settings.py

TEMPLATES = [
{
    'OPTIONS': {
        'debug': DEBUG,
        'context_processors': [
            …
            'django.template.context_processors.request',
            'django.template.context_processors.debug',
            'django.template.context_processors.i18n',
            'django.template.context_processors.media',
            'django.template.context_processors.static',
            'django.template.context_processors.tz',
            'django.contrib.messages.context_processors.messages',            ],
    },
},

]

The variable name in the template: In MyHTMLFile.html is foo

…
MyLabel
{{ foo }}
	-----------
…

in the view.py, one of the lines

myvar1 ="BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
context = {foo: myvar1,}

return render_to_response("MyHTMLFile.html", context, context_instance = RequestContext(request) )
return render(request, 'MyHTMLFile.html', {foo: myvar1})
return render_to_response("MyHTMLFile.html", context , context_instance=RequestContext(request) )
return render(request, 'MyHTMLFile.html', context)

The html page is well rendered, but no data in the html table.

Do you have an idea ? I am curious to know what i misunderstand.

Regarding the versio, i am using:
python: Python 2.7.13
django: 1.10.5

Thank you

Body:
context = {foo: myvar1,}

This should give you a NameError unless ofcourse you have a variable named foo in which case it may or may not hold a string foo. So in short you are not sending the right data to the template. It should be

context = {'foo': myvar1,}

And then

return render_to_response("MyHTMLFile.html", context, context_instance = RequestContext(request) )
# Below this line code will not be executed.
return render(request, 'MyHTMLFile.html', {foo: myvar1})
return render_to_response("MyHTMLFile.html", context , context_instance=RequestContext(request) )
return render(request, 'MyHTMLFile.html', context)

note that the return keyword returns from the function. Code after that doesn't get executed.

lastly render_to_response is deprecated. render is the current function to use.


问:
How can I remove a commit on GitHub?
I "accidentally" pushed a commit to GitHub.

Is it possible to remove this commit?

I want to revert my GitHub repository as it was before this commit.

答:
In case you like to keep the commit changes after deletion:

Note that this solution works if the commit to be removed is the last committed one.

1 - Copy the commit reference  you like to go back to from the log:

```<code>git log
</code>```

2 - Reset git to the commit reference:

```<code> git reset <commit_ref>
</code>```

3 - Stash/store the local changes from the wrong commit to use later after pushing to remote:

```<code> git stash
</code>```

4 - Push the changes to remote repository, (-f or --force):

```<code>git push -f
</code>```

5 - Get back the stored changes to local repository:

```<code>git stash apply
</code>```

7 - In case you have untracked/new files in the changes, you need to add them to git before committing:

```<code>git add .
</code>```

6 - Add whatever extra changes you need, then commit the needed files, (or use a dot '.' instead of stating each file name, to commit all files in the local repository:

```<code>git commit -m "<new_commit_message>" <file1> <file2> ...
</code>```

or

```<code>git commit -m "<new_commit_message>" .
</code>```

OwnerDisplayName: hectorsq

Title: How can I remove a commit on GitHub?

Body:
In case you like to keep the commit changes after deletion:

Note that this solution works if the commit to be removed is the last committed one.

1 - Copy the commit reference  you like to go back to from the log:

git log

2 - Reset git to the commit reference:

 git reset <commit_ref>

3 - Stash/store the local changes from the wrong commit to use later after pushing to remote:

 git stash

4 - Push the changes to remote repository, (-f or --force):

git push -f

5 - Get back the stored changes to local repository:

git stash apply

7 - In case you have untracked/new files in the changes, you need to add them to git before committing:

git add .

6 - Add whatever extra changes you need, then commit the needed files, (or use a dot '.' instead of stating each file name, to commit all files in the local repository:

git commit -m "<new_commit_message>" <file1> <file2> ...

or

git commit -m "<new_commit_message>" .


问:
How to read S3 part files into pandas dataframe
I have unloaded data from redshift to S3, after unloading I got xx_0000_part_00 multiple file.

Now I want to read these file into pandas dataframe.

How can I do that?

Thanks,
Som

答:
You will have to import the file from s3 to your local or ec2 using

aws s3 cp

command. Once you have the file locally, just read it through pandas library.

```<code>import pandas as pd
df = pd.read_csv('/file-path/filename')
</code>```

PS - S3 part file is just a regular csv file with your chosen delimiter.

If I’ve made a bad assumption please comment and I’ll refocus my answer.

Body:
You will have to import the file from s3 to your local or ec2 using

aws s3 cp

command. Once you have the file locally, just read it through pandas library.

import pandas as pd
df = pd.read_csv('/file-path/filename')

PS - S3 part file is just a regular csv file with your chosen delimiter.

If I’ve made a bad assumption please comment and I’ll refocus my answer.


问:
Swift 3: how can I detect the touch event on UIScrollView?
I used the below function to detect the touch event on scroll view.

```<code>override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?)
</code>```

But this can't detect any touch event.
How can I detect touch event on scroll view?

答:
In order to override the touch events you have to subclass the scroll view, like this:

```<code>class MyScrollView: UIScrollView {

    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        print("began")
    }
}
</code>```

Then use MyScrollView as class instead of UIScrollView, like this:

```<code>class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        let myScrollView = MyScrollView(frame: self.view.frame)
        myScrollView.backgroundColor = UIColor.blue
        self.view.addSubview(myScrollView)
    }
}
</code>```

I set the background to blue so you can see that the scroll view is working.

Body:
I used the below function to detect the touch event on scroll view.

override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?)

But this can't detect any touch event.
How can I detect touch event on scroll view?

Body:
In order to override the touch events you have to subclass the scroll view, like this:

class MyScrollView: UIScrollView {

    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        print("began")
    }
}

Then use MyScrollView as class instead of UIScrollView, like this:

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        let myScrollView = MyScrollView(frame: self.view.frame)
        myScrollView.backgroundColor = UIColor.blue
        self.view.addSubview(myScrollView)
    }
}

I set the background to blue so you can see that the scroll view is working.


问:
Any better Fibonacci series generator using pure Oracle SQL?
I wonder if there is any way to generate Fibonacci numbers that beat in simplicity and efficiency this one I wrote:

```<code>WITH d (seq) AS
       (SELECT     LEVEL
        FROM       DUAL
        CONNECT BY LEVEL < 195)
SELECT   seq
        ,fib
FROM     d
MODEL
  DIMENSION BY(seq)
  MEASURES(0 AS fib)
  RULES
    (fib [1] = 0,
    fib [2] = 1,
    fib [seq BETWEEN 3 AND 194] = fib[CV(seq) - 2] + fib[CV(seq) - 1],
    fib [seq > 194] = NULL)
ORDER BY 1
/
Execution Plan
----------------------------------------------------------
Plan hash value: 2245903385

---------------------------------------------------------------------------------------
| Id  | Operation                      | Name | Rows  | Bytes | Cost (%CPU)| Time     |
---------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT               |      |     1 |    13 |     2   (0)| 00:00:01 |
|   1 |  SQL MODEL ORDERED             |      |     1 |    13 |            |          |
|   2 |   VIEW                         |      |     1 |    13 |     2   (0)| 00:00:01 |
|*  3 |    CONNECT BY WITHOUT FILTERING|      |       |       |            |          |
|   4 |     FAST DUAL                  |      |     1 |       |     2   (0)| 00:00:01 |
---------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   3 - filter(LEVEL<195)

Statistics
----------------------------------------------------------
          0  recursive calls
          0  db block gets
          0  consistent gets
          0  physical reads
          0  redo size
       4798  bytes sent via SQL*Net to client
        500  bytes received via SQL*Net from client
         14  SQL*Net roundtrips to/from client
          1  sorts (memory)
          0  sorts (disk)
        194  rows processed

SQL>
</code>```

Note: LEVEL < 195 was not arbitrarily chosen, higher values make the algorithm lose precision so I decided not to include them in order to keep correct results only.

答:
You can use a recursive sub-query factoring clause:</p>

```<code>WITH fib ( lvl, value, next ) AS (
  SELECT 1, 0, 1
  FROM DUAL
UNION ALL
  SELECT lvl + 1, next, value + next
  FROM fib
  WHERE lvl < 195
)
SELECT lvl, value FROM fib
</code>```

Body:
I wonder if there is any way to generate Fibonacci numbers that beat in simplicity and efficiency this one I wrote:

WITH d (seq) AS
       (SELECT     LEVEL
        FROM       DUAL
        CONNECT BY LEVEL < 195)
SELECT   seq
        ,fib
FROM     d
MODEL
  DIMENSION BY(seq)
  MEASURES(0 AS fib)
  RULES
    (fib [1] = 0,
    fib [2] = 1,
    fib [seq BETWEEN 3 AND 194] = fib[CV(seq) - 2] + fib[CV(seq) - 1],
    fib [seq > 194] = NULL)
ORDER BY 1
/
Execution Plan
----------------------------------------------------------
Plan hash value: 2245903385

---------------------------------------------------------------------------------------
| Id  | Operation                      | Name | Rows  | Bytes | Cost (%CPU)| Time     |
---------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT               |      |     1 |    13 |     2   (0)| 00:00:01 |
|   1 |  SQL MODEL ORDERED             |      |     1 |    13 |            |          |
|   2 |   VIEW                         |      |     1 |    13 |     2   (0)| 00:00:01 |
|*  3 |    CONNECT BY WITHOUT FILTERING|      |       |       |            |          |
|   4 |     FAST DUAL                  |      |     1 |       |     2   (0)| 00:00:01 |
---------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   3 - filter(LEVEL<195)

Statistics
----------------------------------------------------------
          0  recursive calls
          0  db block gets
          0  consistent gets
          0  physical reads
          0  redo size
       4798  bytes sent via SQL*Net to client
        500  bytes received via SQL*Net from client
         14  SQL*Net roundtrips to/from client
          1  sorts (memory)
          0  sorts (disk)
        194  rows processed

SQL>

Note: LEVEL < 195 was not arbitrarily chosen, higher values make the algorithm lose precision so I decided not to include them in order to keep correct results only.

Body:
You can use a recursive sub-query factoring clause:

WITH fib ( lvl, value, next ) AS (
  SELECT 1, 0, 1
  FROM DUAL
UNION ALL
  SELECT lvl + 1, next, value + next
  FROM fib
  WHERE lvl < 195
)
SELECT lvl, value FROM fib


问:
Button Position in Xaml
I am trying to position a button at the bottom of the screen using Xaml or the code behind. This is what I am trying to achieve:

Here is the Xaml:

```<code><StackLayout>

            <Label Text="Identification"
                   x:Name="DriverLabel"/>

            <Image x:Name="VigoLogo"/>

            <Entry Placeholder="Driver Name"
                   Text="{Binding driverID}"/>

    <Button Text="Submit"
            Command="{Binding Submit}"
            x:Name="SubmitButton"
            HorizontalOptions="CenterAndExpand"
            ></Button>

</StackLayout>
</code>```

and the code behind:`

```<code>// Styling and resources
            // *************************
            // Whole page ino
            BackgroundColor = Color.White;
            // ID Label at top of screen styles
            DriverLabel.BackgroundColor = Color.LightBlue;
            DriverLabel.HorizontalTextAlignment = TextAlignment.Center;
            DriverLabel.VerticalTextAlignment = TextAlignment.Center;
            DriverLabel.FontSize = 20;
            DriverLabel.HeightRequest = 80;
            DriverLabel.TextColor = Color.Black;

            //VigoLogo Information
            VigoLogo.Source = "Resources/vigo_sign.png";

            // Submit button
            SubmitButton.BackgroundColor = Color.LightBlue;
            SubmitButton.VerticalOptions = LayoutOptions.End;`
</code>```

I have tried various things with relative and absolute positioning but because I am new to Xamarin I am getting in a mess more than anything else.
I got somewhere using AbsoluteLayout but it seems that only hard coding x and y coordinates works but it needs to be more dynamic than that for different devices.

Any help would be appreciated.

答:
There are a few options.

One of them is you using a StackLayout wrapping your other views and setting the VerticalOptions to FillAndExpands. This will push the button to the bottom.

```<code><StackLayout>
    <StackLayout VerticalOptions="FillAndExpand">

            <Label Text="Identification"
                   x:Name="DriverLabel"/>

            <Image x:Name="VigoLogo" />

            <Entry Placeholder="Driver Name"
                   Text="{Binding driverID}"/>

    </StackLayout>

    <Button Text="Submit"
            Command="{Binding Submit}"
            x:Name="SubmitButton"
            HorizontalOptions="CenterAndExpand" />

</StackLayout>
</code>```

Title: Button Position in Xaml

Body:
I am trying to position a button at the bottom of the screen using Xaml or the code behind. This is what I am trying to achieve:

Here is the Xaml:

<StackLayout>

            <Image x:Name="VigoLogo"/>

            <Entry Placeholder="Driver Name"
                   Text="{Binding driverID}"/>

    <Button Text="Submit"
            Command="{Binding Submit}"
            x:Name="SubmitButton"
            HorizontalOptions="CenterAndExpand"
            ></Button>

</StackLayout>

and the code behind:`

// Styling and resources
            // *************************
            // Whole page ino
            BackgroundColor = Color.White;
            // ID Label at top of screen styles
            DriverLabel.BackgroundColor = Color.LightBlue;
            DriverLabel.HorizontalTextAlignment = TextAlignment.Center;
            DriverLabel.VerticalTextAlignment = TextAlignment.Center;
            DriverLabel.FontSize = 20;
            DriverLabel.HeightRequest = 80;
            DriverLabel.TextColor = Color.Black;

            //VigoLogo Information
            VigoLogo.Source = "Resources/vigo_sign.png";

            // Submit button
            SubmitButton.BackgroundColor = Color.LightBlue;
            SubmitButton.VerticalOptions = LayoutOptions.End;`

I have tried various things with relative and absolute positioning but because I am new to Xamarin I am getting in a mess more than anything else.
I got somewhere using AbsoluteLayout but it seems that only hard coding x and y coordinates works but it needs to be more dynamic than that for different devices.

Any help would be appreciated.

Body:
There are a few options.

One of them is you using a StackLayout wrapping your other views and setting the VerticalOptions to FillAndExpands. This will push the button to the bottom.

<StackLayout>
    <StackLayout VerticalOptions="FillAndExpand">

            <Label Text="Identification"
                   x:Name="DriverLabel"/>

            <Image x:Name="VigoLogo" />

            <Entry Placeholder="Driver Name"
                   Text="{Binding driverID}"/>

    </StackLayout>

    <Button Text="Submit"
            Command="{Binding Submit}"
            x:Name="SubmitButton"
            HorizontalOptions="CenterAndExpand" />

</StackLayout>


问:
How the recursion get expanded
I have following function, that do the function composition:

```<code>applyTimes :: (Eq a, Num a) => a -> (b -> b) -> b -> b
applyTimes 0 f b = b
applyTimes n f b = f . applyTimes (n-1) f $ b
</code>```

and I have following expression:

```<code>applyTimes 5 (+1) 5
</code>```

Could someone please write out the evaluation?

It is difficult to imaging, how it will be expanded.

答:
```<code>applyTimes 5 (+1) 5 =
  (+1) . applyTimes 4 (+1) $ 5

applyTimes 5 (+1) 5 =
  (+1) . (
    (+1) . applyTimes 3 (+1)
  ) $ 5

-- ...

applyTimes 5 (+1) 5 =
  (+1) . (                -- 4
    (+1) . (              -- 3
      (+1) . (            -- 2
        (+1) . (          -- 1
          (+1) . const    -- 0
        )
      )
    )
  ) $ 5
</code>```

I put in const because that's what you get after last applyTimes 0 f is evaluated.

Or, in flattened form:

```<code>applyTimes 5 (+1) 5 = (+1) . ((+1) . ((+1) . ((+1) . ((+1) . const))))) $ 5
                    = (+1) .  (+1) .  (+1) .  (+1) .  (+1) . const      $ 5
</code>```

The name can be kind of misleading, since the "apply f n times"1  is actually done by applying  a function composed of n repetitions of f, once.

What I could also see as confusing is where the actual application happens; perhaps eta-reducing it makes it clearer:

```<code>applyTimes n f = f . applyTimes (n-1) f
</code>```

1You could imagine  a perhaps simpler implementation:

```<code>applyTimes 0 f x = x
applyTimes n f x = f $ applyTimes (n-1) x
</code>```

Title: How the recursion get expanded

Body:
I have following function, that do the function composition:

applyTimes :: (Eq a, Num a) => a -> (b -> b) -> b -> b
applyTimes 0 f b = b
applyTimes n f b = f . applyTimes (n-1) f $ b

and I have following expression:

applyTimes 5 (+1) 5

Could someone please write out the evaluation?

It is difficult to imaging, how it will be expanded.

Body:
applyTimes 5 (+1) 5 =
  (+1) . applyTimes 4 (+1) $ 5

applyTimes 5 (+1) 5 =
  (+1) . (
    (+1) . applyTimes 3 (+1)
  ) $ 5

-- ...

applyTimes 5 (+1) 5 =
  (+1) . (                -- 4
    (+1) . (              -- 3
      (+1) . (            -- 2
        (+1) . (          -- 1
          (+1) . const    -- 0
        )
      )
    )
  ) $ 5

I put in const because that's what you get after last applyTimes 0 f is evaluated.

Or, in flattened form:

applyTimes 5 (+1) 5 = (+1) . ((+1) . ((+1) . ((+1) . ((+1) . const))))) $ 5
                    = (+1) .  (+1) .  (+1) .  (+1) .  (+1) . const      $ 5

The name can be kind of misleading, since the "apply f n times"1  is actually done by applying  a function composed of n repetitions of f, once.

What I could also see as confusing is where the actual application happens; perhaps eta-reducing it makes it clearer:

applyTimes n f = f . applyTimes (n-1) f

1You could imagine  a perhaps simpler implementation:

applyTimes 0 f x = x
applyTimes n f x = f $ applyTimes (n-1) x


问:
print pdf horizontal half page half empty
hi I want to print powerpoint slides (available as pdf) so that I will have one slide on each page but only half the page, so I have the other have for personal notes.
Hase someone an idea on how to accomplish this without manually adding empty pages after each page?
enter image description here</p>

答: Try printing from Acrobat and selecting a Custom Scale: 50% (adjust as needed). The Custom Scale option is found in the Page Size & Handling section of the Acrobat print dialog box.    </p>


问:
Read/write XML with C#/.NET
What are the best functions, practices, and/or techniques to read/write XML with C#/.NET?</p>

答: In a performance critical application XmlReader/XmlWriter are a good choice (see here) for the sake of simplicity which is offered by Linq to XML and XmlDocument.</p>

Title: Read/write XML with C#/.NET

OwnerDisplayName: darin


问:
Why first xpage opened stop responding after open two tabs on browser? In my case i'm opening two different xpages but with same components
I'm heaving some trouble with xpages. When i open two or more tabs with xpages using the same component, in my case a CustomControl,  the first xpage opened stops responding. I have no clue about this, i'm a beginner with xpages. Is this an issue caused by Dojo? Ps. The custom controls have some viewScope variables shared too. I'm counting on you guys.</p>

答:
There's a "Maximum pages in memory" setting. You need to set that to more than the number of tabs open.

What I did was Ah set it manually in the xsp.properties source as e.g. xsp.persistence.tree.maxviews=5

It solved my problem.


问:
replacing a unicode character
I can't figure out how to remove a Unicode character using .replace(...) here's what I've tried

```<code> $(elem).click(function () {
   var display = $("." + target).css('display');
   var lastChar = display == 'none' ? 'a' : '8';
   $("." + target).slideToggle(500);
   alert('index: ' + $(this).text().indexOf('⇈'));
   $(this).html($(this).html().replace('⇈','').replace('⇊','') + ' &#x21c' + lastChar + ';');
 });
</code>```

It is adding my double arrow up and down, but indexOf is always -1, and my replace calls are not removing the Unicode character. I'm looking at this now and thinking that if I start off with one of these Unicode chars I could just replace it with the other one... If I could get replace to work at all ;-)

What am I doing wrong? Thanks!

答:
HTML entities get converted to actual unicode characters. Example:

document.body.innerHTML = "⇈";

console.log(document.body.innerHTML === "\u21c8"); // true

// Instead of a unicode esape sequence, you can write the
// actual unicode character. This is safe as long as you
// specify the correct encoding for your JavaScript files:
console.log(document.body.innerHTML === "⇈"); // true
 ```

So when you read the innerHTML via $(this).html() or the textContent via $(this).text(), you need to look for the actual unicode character given by its unicode escape sequence "\u21c8" or directly "⇈" and not its entity "⇈".

Title: replacing a unicode character

Body:
I can't figure out how to remove a Unicode character using .replace(...) here's what I've tried

 $(elem).click(function () {
   var display = $("." + target).css('display');
   var lastChar = display == 'none' ? 'a' : '8';
   $("." + target).slideToggle(500);
   alert('index: ' + $(this).text().indexOf('⇈'));
   $(this).html($(this).html().replace('⇈','').replace('⇊','') + ' &#x21c' + lastChar + ';');
 });

It is adding my double arrow up and down, but indexOf is always -1, and my replace calls are not removing the Unicode character. I'm looking at this now and thinking that if I start off with one of these Unicode chars I could just replace it with the other one... If I could get replace to work at all ;-)

What am I doing wrong? Thanks!

Body:
HTML entities get converted to actual unicode characters. Example:

document.body.innerHTML = "&#x21c8;";

console.log(document.body.innerHTML === "\u21c8"); // true

// Instead of a unicode esape sequence, you can write the
// actual unicode character. This is safe as long as you
// specify the correct encoding for your JavaScript files:
console.log(document.body.innerHTML === "⇈"); // true

So when you read the innerHTML via $(this).html() or the textContent via $(this).text(), you need to look for the actual unicode character given by its unicode escape sequence "\u21c8" or directly "⇈" and not its entity "&#x21c8;".