问:
Custom event on object to change button state
I have 3 buttons on my Data Entry form, OK, APPLY, CANCEL.

This form is used to edit a doctor's details, things like first name, phone # etc...

I have one object doctorObj which at any given time is either empty (a new doctor) or an object pulled from a Linq query.

I deep clone the doctorObj to EditCopyDoctor which is of the same type but used for form editing (so if Cancel is hit, the database do not need to update).

What I want to achieve is observe the EditCopyDoctor for changes against the original doctorObj so

```<code>If(doctor.Changed() && doctor.IsNotNew)
{
ApplyButton.Enabled = true;
}
else
{
ApplyButton.Enabled = false;
}
</code>```

So I thought writting an event to trigger when something changed on EditCopyDoctor is the best way to do it but I'm not sure how.

I can of course put the ApplyButton.Enabled code in the TextChanged events from the form but I was wondering if there are any quicker ways to do this, I don't really want to do this as there are 10+ textbox and other controls.

答: Since your "Doctor" type sounds like it's generated by LINQ to SQL/Entities you should find that it already implements the INotifyPropertyChanged interface. Therefore, you should just need to watch the PropertyChanged event and act accordingly.

ContentLicense: CC BY-SA 2.5

Body:
I have 3 buttons on my Data Entry form, OK, APPLY, CANCEL.

This form is used to edit a doctor's details, things like first name, phone # etc...

I have one object doctorObj which at any given time is either empty (a new doctor) or an object pulled from a Linq query.

I deep clone the doctorObj to EditCopyDoctor which is of the same type but used for form editing (so if Cancel is hit, the database do not need to update).

What I want to achieve is observe the EditCopyDoctor for changes against the original doctorObj so

If(doctor.Changed() && doctor.IsNotNew)
{
ApplyButton.Enabled = true;
}
else
{
ApplyButton.Enabled = false;
}

So I thought writting an event to trigger when something changed on EditCopyDoctor is the best way to do it but I'm not sure how.

I can of course put the ApplyButton.Enabled code in the TextChanged events from the form but I was wondering if there are any quicker ways to do this, I don't really want to do this as there are 10+ textbox and other controls.


来源: stackexchange

问:
Regular expression with multiline block of text (python)
I have the following file named seq.fasta:

```<code>>AAM15934.1| NtrX [Gluconacetobacter diazotrophicus]| NTRX1 | Response_reg - Sigma54_activat - HTH_8
MGHEILIVDDEPDIRLLVEGILRDEGYETRLAGDSDSAISAFRARRPSLVILDVWLQGSRLDGLGILQAI
QGEEPVVPTIMISGHGTIETAVAALQHGAYDFIEKPFQSDRLLLVVRRALEASRLARENAELRLRAGPEA
MLYGDSPVIAGVRNQIERVAPSGSRVLISGAAGAGKEVAARMIHARSPGPKAFIALNCATLAPGRFEEEL
FGIEGAPDGTGRRTGVLERAHGGTLLLDEVSDMPIETQGKIVRALQDQSFERVGGASRVKVDVRVLAATN
RDLQEAIAAGRFREDLYYRLAVVPLRVPSLRERREDIPGLARLFLRRAAENAGLPLRDLSGDAVAALQSY
DWPGNARELRNLMERLLIMMPGNGSDLIRAEMLPPSVGQGAPALLKFDPAADVMGLPLREARDLFETQYL
QAQLLRFGGNISRTAGFVGMERSALHRKLKQLGVTSEERGAG

>WP_002731145.1| NtrX [Phaeospirillum molischianum]| NTRX1 | Response_reg - Sigma54_activat - HTH_8
MAHDILIVDDEADIRVLIAGILEDEGHSTREAANADEALERIRARRPSLVIQDIWLQGSRLDGLGVLDEI
KREHPDVPVVMISGHGTIETAVQAIKQGAYDFIEKPFKADRLLLVVDRAIESARLKRENQELRVRSGSTG
DLVGISPALVQIRQTIERVAPTNSRVLITGPAGSGKEVAARMIHAHSRRTEGPFVVVNCAAMHPDRMEIE
LFGTEYGADGSTSPRKIGTFEQAHSGTLLLDEVADMPLETQGKIVRVLQDQTFERVGGGKRVEVDVRVIA
TTNRDLQSEMIAGHFREDLFYRLNVVPIRMPALRDGKEDIPLLARQFMQLAAQLAGVPPRPLGEDALAAL
QAYDWPGNVRQLRNAIDWLLIMAPGDWRDPVRADMLPSEIGAITPAVLRWEKSSEIMTLPLREARELFER
EYLLAQVNRFAGNISRTAAFVGMERSALHRKLKLLGINTDEKVR

>WP_002967695.1| NtrX  [Brucella abortus]| NTRX1 | Response_reg - Sigma54_activat - HTH_8
MAADILVVDDEVDIRDLVAGILSDEGHETRTAFDADSALAAINDRAPRLVFLDIWLQGSRLDGLALLDEI
KKQHPELPVVMISGHGNIETAVSAIRRGAYDFIEKPFKADRLILVAERALETSKLKREVSDLRKRTGDQL
ELVGTSLAMNQLRQTIERVAPTNSRIMITGPSGAGKELVARTIHAQSSRANGPFVTVNAATITPERMEIE
LFGTEMDGGERKVGALEEAHGGILYLDEVADMPRETQNKILRVLVDQQFERVGGTKRVKVDVRIISSTAQ
NLEGMIAEGTFREDLFHRLSVVPVQVPALAARREDIPSLVEFFMKQIAEQAGIKPRKIGPDAMAVLQAHS
WPGNLRQLRNNVERLMILTRGDDPDELVTADLLPAEIGDTLPRAPTESDQHIMALPLREARERFEKEYLI
AQINRFGGNISRTAEFVGMERSALHRKLKSLGV
</code>```

I want to put each block of letters in a list.
Example:

List Contents:

```<code>List[0] = MGHEILIVDDEPDIRLLVEGILRDEGYETRLAGDSDSAISAFRARRPSLVILDVWLQGSRLDGLGILQAI
QGEEPVVPTIMISGHGTIETAVAALQHGAYDFIEKPFQSDRLLLVVRRALEASRLARENAELRLRAGPEA
MLYGDSPVIAGVRNQIERVAPSGSRVLISGAAGAGKEVAARMIHARSPGPKAFIALNCATLAPGRFEEEL
FGIEGAPDGTGRRTGVLERAHGGTLLLDEVSDMPIETQGKIVRALQDQSFERVGGASRVKVDVRVLAATN
RDLQEAIAAGRFREDLYYRLAVVPLRVPSLRERREDIPGLARLFLRRAAENAGLPLRDLSGDAVAALQSY
DWPGNARELRNLMERLLIMMPGNGSDLIRAEMLPPSVGQGAPALLKFDPAADVMGLPLREARDLFETQYL
QAQLLRFGGNISRTAGFVGMERSALHRKLKQLGVTSEERGAG

List[1] = MAHDILIVDDEADIRVLIAGILEDEGHSTREAANADEALERIRARRPSLVIQDIWLQGSRLDGLGVLDEI
KREHPDVPVVMISGHGTIETAVQAIKQGAYDFIEKPFKADRLLLVVDRAIESARLKRENQELRVRSGSTG
DLVGISPALVQIRQTIERVAPTNSRVLITGPAGSGKEVAARMIHAHSRRTEGPFVVVNCAAMHPDRMEIE
LFGTEYGADGSTSPRKIGTFEQAHSGTLLLDEVADMPLETQGKIVRVLQDQTFERVGGGKRVEVDVRVIA
TTNRDLQSEMIAGHFREDLFYRLNVVPIRMPALRDGKEDIPLLARQFMQLAAQLAGVPPRPLGEDALAAL
QAYDWPGNVRQLRNAIDWLLIMAPGDWRDPVRADMLPSEIGAITPAVLRWEKSSEIMTLPLREARELFER
EYLLAQVNRFAGNISRTAAFVGMERSALHRKLKLLGINTDEKVR

List[2] = MAADILVVDDEVDIRDLVAGILSDEGHETRTAFDADSALAAINDRAPRLVFLDIWLQGSRLDGLALLDEI
KKQHPELPVVMISGHGNIETAVSAIRRGAYDFIEKPFKADRLILVAERALETSKLKREVSDLRKRTGDQL
ELVGTSLAMNQLRQTIERVAPTNSRIMITGPSGAGKELVARTIHAQSSRANGPFVTVNAATITPERMEIE
LFGTEMDGGERKVGALEEAHGGILYLDEVADMPRETQNKILRVLVDQQFERVGGTKRVKVDVRIISSTAQ
NLEGMIAEGTFREDLFHRLSVVPVQVPALAARREDIPSLVEFFMKQIAEQAGIKPRKIGPDAMAVLQAHS
WPGNLRQLRNNVERLMILTRGDDPDELVTADLLPAEIGDTLPRAPTESDQHIMALPLREARERFEKEYLI
AQINRFGGNISRTAEFVGMERSALHRKLKSLGV
</code>```

But i'm struggling to split and put them in a list, my code is like:

```<code>import re

myfile = open('seq.fasta', 'r').read()

regex = re.compile(r'^>([^\n\r]+)[\n\r]([A-Z\n\r]+)', re.MULTILINE)
matches = [m.groups() for m in regex.finditer(myfile)]

for m in matches:
    onlySequences = (m[1])

print(onlySequences)
</code>```

The variable onlySequences returns just the last one block of letters, how do i keep all of them, each one in a number of a list?

答:
You are overriding onlySequences within for loop. Perhaps you only need this:

```<code>matches = [m.groups()[1] for m in regex.finditer(myfile)]
print(matches)
</code>```

Or correction in your code:

```<code>matches = [m.groups() for m in regex.finditer(myfile)]
onlySequences = [m[1] for m in matches]
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I have the following file named seq.fasta:

>AAM15934.1| NtrX [Gluconacetobacter diazotrophicus]| NTRX1 | Response_reg - Sigma54_activat - HTH_8
MGHEILIVDDEPDIRLLVEGILRDEGYETRLAGDSDSAISAFRARRPSLVILDVWLQGSRLDGLGILQAI
QGEEPVVPTIMISGHGTIETAVAALQHGAYDFIEKPFQSDRLLLVVRRALEASRLARENAELRLRAGPEA
MLYGDSPVIAGVRNQIERVAPSGSRVLISGAAGAGKEVAARMIHARSPGPKAFIALNCATLAPGRFEEEL
FGIEGAPDGTGRRTGVLERAHGGTLLLDEVSDMPIETQGKIVRALQDQSFERVGGASRVKVDVRVLAATN
RDLQEAIAAGRFREDLYYRLAVVPLRVPSLRERREDIPGLARLFLRRAAENAGLPLRDLSGDAVAALQSY
DWPGNARELRNLMERLLIMMPGNGSDLIRAEMLPPSVGQGAPALLKFDPAADVMGLPLREARDLFETQYL
QAQLLRFGGNISRTAGFVGMERSALHRKLKQLGVTSEERGAG

>WP_002731145.1| NtrX [Phaeospirillum molischianum]| NTRX1 | Response_reg - Sigma54_activat - HTH_8
MAHDILIVDDEADIRVLIAGILEDEGHSTREAANADEALERIRARRPSLVIQDIWLQGSRLDGLGVLDEI
KREHPDVPVVMISGHGTIETAVQAIKQGAYDFIEKPFKADRLLLVVDRAIESARLKRENQELRVRSGSTG
DLVGISPALVQIRQTIERVAPTNSRVLITGPAGSGKEVAARMIHAHSRRTEGPFVVVNCAAMHPDRMEIE
LFGTEYGADGSTSPRKIGTFEQAHSGTLLLDEVADMPLETQGKIVRVLQDQTFERVGGGKRVEVDVRVIA
TTNRDLQSEMIAGHFREDLFYRLNVVPIRMPALRDGKEDIPLLARQFMQLAAQLAGVPPRPLGEDALAAL
QAYDWPGNVRQLRNAIDWLLIMAPGDWRDPVRADMLPSEIGAITPAVLRWEKSSEIMTLPLREARELFER
EYLLAQVNRFAGNISRTAAFVGMERSALHRKLKLLGINTDEKVR

>WP_002967695.1| NtrX  [Brucella abortus]| NTRX1 | Response_reg - Sigma54_activat - HTH_8
MAADILVVDDEVDIRDLVAGILSDEGHETRTAFDADSALAAINDRAPRLVFLDIWLQGSRLDGLALLDEI
KKQHPELPVVMISGHGNIETAVSAIRRGAYDFIEKPFKADRLILVAERALETSKLKREVSDLRKRTGDQL
ELVGTSLAMNQLRQTIERVAPTNSRIMITGPSGAGKELVARTIHAQSSRANGPFVTVNAATITPERMEIE
LFGTEMDGGERKVGALEEAHGGILYLDEVADMPRETQNKILRVLVDQQFERVGGTKRVKVDVRIISSTAQ
NLEGMIAEGTFREDLFHRLSVVPVQVPALAARREDIPSLVEFFMKQIAEQAGIKPRKIGPDAMAVLQAHS
WPGNLRQLRNNVERLMILTRGDDPDELVTADLLPAEIGDTLPRAPTESDQHIMALPLREARERFEKEYLI
AQINRFGGNISRTAEFVGMERSALHRKLKSLGV

I want to put each block of letters in a list.
Example:

List Contents:

List[0] = MGHEILIVDDEPDIRLLVEGILRDEGYETRLAGDSDSAISAFRARRPSLVILDVWLQGSRLDGLGILQAI
QGEEPVVPTIMISGHGTIETAVAALQHGAYDFIEKPFQSDRLLLVVRRALEASRLARENAELRLRAGPEA
MLYGDSPVIAGVRNQIERVAPSGSRVLISGAAGAGKEVAARMIHARSPGPKAFIALNCATLAPGRFEEEL
FGIEGAPDGTGRRTGVLERAHGGTLLLDEVSDMPIETQGKIVRALQDQSFERVGGASRVKVDVRVLAATN
RDLQEAIAAGRFREDLYYRLAVVPLRVPSLRERREDIPGLARLFLRRAAENAGLPLRDLSGDAVAALQSY
DWPGNARELRNLMERLLIMMPGNGSDLIRAEMLPPSVGQGAPALLKFDPAADVMGLPLREARDLFETQYL
QAQLLRFGGNISRTAGFVGMERSALHRKLKQLGVTSEERGAG

List[1] = MAHDILIVDDEADIRVLIAGILEDEGHSTREAANADEALERIRARRPSLVIQDIWLQGSRLDGLGVLDEI
KREHPDVPVVMISGHGTIETAVQAIKQGAYDFIEKPFKADRLLLVVDRAIESARLKRENQELRVRSGSTG
DLVGISPALVQIRQTIERVAPTNSRVLITGPAGSGKEVAARMIHAHSRRTEGPFVVVNCAAMHPDRMEIE
LFGTEYGADGSTSPRKIGTFEQAHSGTLLLDEVADMPLETQGKIVRVLQDQTFERVGGGKRVEVDVRVIA
TTNRDLQSEMIAGHFREDLFYRLNVVPIRMPALRDGKEDIPLLARQFMQLAAQLAGVPPRPLGEDALAAL
QAYDWPGNVRQLRNAIDWLLIMAPGDWRDPVRADMLPSEIGAITPAVLRWEKSSEIMTLPLREARELFER
EYLLAQVNRFAGNISRTAAFVGMERSALHRKLKLLGINTDEKVR

List[2] = MAADILVVDDEVDIRDLVAGILSDEGHETRTAFDADSALAAINDRAPRLVFLDIWLQGSRLDGLALLDEI
KKQHPELPVVMISGHGNIETAVSAIRRGAYDFIEKPFKADRLILVAERALETSKLKREVSDLRKRTGDQL
ELVGTSLAMNQLRQTIERVAPTNSRIMITGPSGAGKELVARTIHAQSSRANGPFVTVNAATITPERMEIE
LFGTEMDGGERKVGALEEAHGGILYLDEVADMPRETQNKILRVLVDQQFERVGGTKRVKVDVRIISSTAQ
NLEGMIAEGTFREDLFHRLSVVPVQVPALAARREDIPSLVEFFMKQIAEQAGIKPRKIGPDAMAVLQAHS
WPGNLRQLRNNVERLMILTRGDDPDELVTADLLPAEIGDTLPRAPTESDQHIMALPLREARERFEKEYLI
AQINRFGGNISRTAEFVGMERSALHRKLKSLGV

But i'm struggling to split and put them in a list, my code is like:

import re

myfile = open('seq.fasta', 'r').read()

regex = re.compile(r'^>([^\n\r]+)[\n\r]([A-Z\n\r]+)', re.MULTILINE)
matches = [m.groups() for m in regex.finditer(myfile)]

for m in matches:
    onlySequences = (m[1])

print(onlySequences)

The variable onlySequences returns just the last one block of letters, how do i keep all of them, each one in a number of a list?

Body:
You are overriding onlySequences within for loop. Perhaps you only need this:

matches = [m.groups()[1] for m in regex.finditer(myfile)]
print(matches)

Or correction in your code:

matches = [m.groups() for m in regex.finditer(myfile)]
onlySequences = [m[1] for m in matches]


问:
Kotlin reflection is not available
I was trying to learn higher order functions from the first example of this video. Here's my code and output.

Code

```<code>fun lowercase(value: String) = value.toLowerCase()

fun higherOrder(value:String, op: (String) -> String) : String {
    println("Executing higher order fun $op")
    return op(value)
}

fun main(args: Array<String>) {
    println(higherOrder("HELLO", ::lowercase))
    println(higherOrder("hello", {it -> lowercase(it)}))
    println(higherOrder("HeLlo", { x -> lowercase(x) }))
    println(higherOrder("Hello", { lowercase(it) }))
}
</code>```

Output

```<code>Executing higher order fun function lowercase (Kotlin reflection is not available)
hello
Executing higher order fun Function1<java.lang.String, java.lang.String>
hello
Executing higher order fun Function1<java.lang.String, java.lang.String>
hello
Executing higher order fun Function1<java.lang.String, java.lang.String>
hello

Process finished with exit code 0
</code>```

So my question is, why does it print Kotlin reflection is not available?

答:
Full reflection requires the kotlin-reflect library in addition to kotlin-stdlib.
If full reflection is available it will probably have a more comprehensive toString(), hence the message.

Title: Kotlin reflection is not available

Body:
I was trying to learn higher order functions from the first example of this video. Here's my code and output.

Code

fun lowercase(value: String) = value.toLowerCase()

fun higherOrder(value:String, op: (String) -> String) : String {
    println("Executing higher order fun $op")
    return op(value)
}

fun main(args: Array<String>) {
    println(higherOrder("HELLO", ::lowercase))
    println(higherOrder("hello", {it -> lowercase(it)}))
    println(higherOrder("HeLlo", { x -> lowercase(x) }))
    println(higherOrder("Hello", { lowercase(it) }))
}

Output

Executing higher order fun function lowercase (Kotlin reflection is not available)
hello
Executing higher order fun Function1<java.lang.String, java.lang.String>
hello
Executing higher order fun Function1<java.lang.String, java.lang.String>
hello
Executing higher order fun Function1<java.lang.String, java.lang.String>
hello

Process finished with exit code 0

So my question is, why does it print Kotlin reflection is not available?


问:
Pocketsphinx takes too much battery on android
I am using pocketsphinx to spot a keyword continuously in a service. The problem is, it takes up a huge amount of battery, making the app completely unusable for an average user.

Well, the original code is in B4A, but this is how it will look:

```<code>recognizer = defaultSetup()
        .setAcousticModel(new File(assetsDir, "en-us-ptm"))
        .setDictionary(new File(assetsDir, "cmudict-en-us.dict"))
        .setRawLogDir(assetsDir).setKeywordThreshold(1e-20f)
        .getRecognizer();
recognizer.addListener(this);
</code>```

For the keyword:

```<code>// Create keyword-activation search.
recognizer.addKeyphraseSearch(KWS_SEARCH, "extreme");
</code>```

I even excluded the following to decrease the CPU consumption. After all, my main goal is just to spot the keyword.

```<code>// Create grammar-based searches.
File menuGrammar = new File(assetsDir, "menu.gram");
recognizer.addGrammarSearch(MENU_SEARCH, menuGrammar);
// Next search for digits
File digitsGrammar = new File(assetsDir, "digits.gram");
recognizer.addGrammarSearch(DIGITS_SEARCH, digitsGrammar);
// Create language model search.
File languageModel = new File(assetsDir, "weather.dmp");
recognizer.addNgramSearch(FORECAST_SEARCH, languageModel);
</code>```

Is there any other way in which service could possibly use less battery?

答: Since you are using microphone, changes in your program code won't dramatically solve battery draining issue. You can figure out a way to stop using microphone for recognition in certain times when not necessary.</p>

Body:
I am using pocketsphinx to spot a keyword continuously in a service. The problem is, it takes up a huge amount of battery, making the app completely unusable for an average user.

Well, the original code is in B4A, but this is how it will look:

recognizer = defaultSetup()
        .setAcousticModel(new File(assetsDir, "en-us-ptm"))
        .setDictionary(new File(assetsDir, "cmudict-en-us.dict"))
        .setRawLogDir(assetsDir).setKeywordThreshold(1e-20f)
        .getRecognizer();
recognizer.addListener(this);

For the keyword:

// Create keyword-activation search.
recognizer.addKeyphraseSearch(KWS_SEARCH, "extreme");

I even excluded the following to decrease the CPU consumption. After all, my main goal is just to spot the keyword.

// Create grammar-based searches.
File menuGrammar = new File(assetsDir, "menu.gram");
recognizer.addGrammarSearch(MENU_SEARCH, menuGrammar);
// Next search for digits
File digitsGrammar = new File(assetsDir, "digits.gram");
recognizer.addGrammarSearch(DIGITS_SEARCH, digitsGrammar);
// Create language model search.
File languageModel = new File(assetsDir, "weather.dmp");
recognizer.addNgramSearch(FORECAST_SEARCH, languageModel);

Is there any other way in which service could possibly use less battery?


问:
A convenient way to update a project on server
There is a project (node.js - although it's not important), which is developed on the local machine and is periodically transferred to the server.
In principle, I could simply erase the project folder on the server each time and replace it with a new one - uploaded from the local machine.

The matter is, that some folders (specifically: node_modules), I do not need to rewrite. So I have to manually create an archive, excluding unnecessary folders from it. And on the server, too, pre-erase everything except for some folders and only then replace.

How can I automate this procedure?

(On the local machine - windows, on the server - Linux)

答:
You can pull the changes directly from your repo.

I do it like this:

I have different branches for different environments like dev, stage and production.

I commit the changes to the branch and pull that on the server.

This way, you don't need to commit unnecessary stuff (like node_modules, credentials etc) to your repo.

You can also easily automate this using CI tools. Look up CI tools.


问:
socket.io cannot communicate with back-end through express
I am using socket.io for fetching some data from the express app. Everything works fine on localhost:8080 but when i deploy my code to the server, client side socket.io cannot communicate with back-end socket.io through express server. I've an apache on the server that forwards everything to localhost:8080 including domain.com/socket.io/?transform=polling... and it extends the request to the express server but express returns a 404 (it comes from the express, not from apache). I am out of ideas, what could be the problem? Here is my code:

```<code>express = require "express"
jade = require "jade"
fs = require "fs"

class Bootstrap
 _self = undefined
 routes:
   DEFAULT_PATH: "/"
   TEMPLATE_PATH: "/load/:view"
   DIRECTIVE_PATH: "/directive/:template"
 options:
   templatePath: "#{__dirname}/../src/templates"
   isDev: "#{__dirname}/../dev"
 contentPath: "#{__dirname}/../frontend"
 libraryPath: "#{__dirname}/../bower_components"
 port: 8080
 status:
   notFound: 404
 isDev: undefined

 constructor: ->
   _self = @
   @isDev = fs.existsSync @options.isDev
   @app = express()

   @app.use "/frontend", express.static(@options.contentPath)
   @app.use "/bower_components", express.static(@options.libraryPath)
   @app.set "views", @options.templatePath
   @app.set "view engine", "jade"
   @app.engine "jade", jade.__express

   @app.get @routes.DEFAULT_PATH, (request, response)->
     appData =
       data:
         isDev: _self.isDev
     response.render "index", appData
   @app.get @routes.TEMPLATE_PATH, (request, response)->
     view = request.param "view"
     response.render view
   @app.get @routes.DIRECTIVE_PATH, (request, response)->
     template = request.param("template").replace ".html", ""
     response.render "directives/"+template
   @app.use (request, response, next)->
     _self.logger.warning "404 Not Found!: " + request.originalUrl
     response.status(_self.options.status.notFound)
      appData =
        data:
          isDev : _self.isDev
          request: request
      response.render "404", appData

   @server = @app.listen @options.port
   @io = require("socket.io").listen @server

   @logger = require("./logger.js")
   @logger.init @isDev

   @socketConnector = require("./live.js")
   @socketConnector.init @io

   @

new Bootstrap()
</code>```

You can find the entire code here: https://github.com/eyurdakul/ejder.be

答:
Since you specifically said it works locally and I don't see anything special in your code, I really think the issue resides in your Apache config.

There is a module called mod_proxy_wstunnel you need to have and enable in order to get your WebSocket traffic to work and get proxied correctly to your express application. Either you have Apache 2.4 or, you'll need to apply this patch found in this blogpost and compile again. There is also another blog detailing step by step what you should do under Ubuntu.

After making sure you have the module and its loaded, you'll have to tweak your config to add some WebSocket proxying using the ProxyPass directive

```<code>ProxyRequests    Off
ProxyPass        "/socket-io/"  "ws://localhost:8080/socket.io/"
ProxyPassReverse "/socket-io/"  "ws://localhost:8080/socket.io/"
</code>```

You might also want to try to use a rewrite condition on the Upgrade header that is sent with WebSockets:

```<code>RewriteEngine On
RewriteCond %{HTTP:Connection} Upgrade [NC]
RewriteRule /(.*) ws://localhost:8000/$1 [P,L]
ProxyPass / http://localhost:8000/
</code>```

has seen in this comment or this specific thread in general, which exposes a few other possible solutions you can try.

Body:
I am using socket.io for fetching some data from the express app. Everything works fine on localhost:8080 but when i deploy my code to the server, client side socket.io cannot communicate with back-end socket.io through express server. I've an apache on the server that forwards everything to localhost:8080 including domain.com/socket.io/?transform=polling... and it extends the request to the express server but express returns a 404 (it comes from the express, not from apache). I am out of ideas, what could be the problem? Here is my code:

express = require "express"
jade = require "jade"
fs = require "fs"

class Bootstrap
 _self = undefined
 routes:
   DEFAULT_PATH: "/"
   TEMPLATE_PATH: "/load/:view"
   DIRECTIVE_PATH: "/directive/:template"
 options:
   templatePath: "#{__dirname}/../src/templates"
   isDev: "#{__dirname}/../dev"
 contentPath: "#{__dirname}/../frontend"
 libraryPath: "#{__dirname}/../bower_components"
 port: 8080
 status:
   notFound: 404
 isDev: undefined

 constructor: ->
   _self = @
   @isDev = fs.existsSync @options.isDev
   @app = express()

   @app.use "/frontend", express.static(@options.contentPath)
   @app.use "/bower_components", express.static(@options.libraryPath)
   @app.set "views", @options.templatePath
   @app.set "view engine", "jade"
   @app.engine "jade", jade.__express

   @app.get @routes.DEFAULT_PATH, (request, response)->
     appData =
       data:
         isDev: _self.isDev
     response.render "index", appData
   @app.get @routes.TEMPLATE_PATH, (request, response)->
     view = request.param "view"
     response.render view
   @app.get @routes.DIRECTIVE_PATH, (request, response)->
     template = request.param("template").replace ".html", ""
     response.render "directives/"+template
   @app.use (request, response, next)->
     _self.logger.warning "404 Not Found!: " + request.originalUrl
     response.status(_self.options.status.notFound)
      appData =
        data:
          isDev : _self.isDev
          request: request
      response.render "404", appData

   @server = @app.listen @options.port
   @io = require("socket.io").listen @server

   @logger = require("./logger.js")
   @logger.init @isDev

   @socketConnector = require("./live.js")
   @socketConnector.init @io

   @

new Bootstrap()

You can find the entire code here: https://github.com/eyurdakul/ejder.be

Body:
Since you specifically said it works locally and I don't see anything special in your code, I really think the issue resides in your Apache config.

There is a module called mod_proxy_wstunnel you need to have and enable in order to get your WebSocket traffic to work and get proxied correctly to your express application. Either you have Apache 2.4 or, you'll need to apply this patch found in this blogpost and compile again. There is also another blog detailing step by step what you should do under Ubuntu.

After making sure you have the module and its loaded, you'll have to tweak your config to add some WebSocket proxying using the ProxyPass directive

ProxyRequests    Off
ProxyPass        "/socket-io/"  "ws://localhost:8080/socket.io/"
ProxyPassReverse "/socket-io/"  "ws://localhost:8080/socket.io/"

You might also want to try to use a rewrite condition on the Upgrade header that is sent with WebSockets:

RewriteEngine On
RewriteCond %{HTTP:Connection} Upgrade [NC]
RewriteRule /(.*) ws://localhost:8000/$1 [P,L]
ProxyPass / http://localhost:8000/

has seen in this comment or this specific thread in general, which exposes a few other possible solutions you can try.


问:
SyntaxError: Unexpected token C in JSON at position 0 - Ionic 2 Http GET request
I am trying to perform a GET request and retrieve the data from the response.

```<code>this.http.get('http://localhost:8888/maneappback/more-items.php').subscribe(res => {
    console.log(res.json());
}, (err) => {
    console.log(err);
});
</code>```

I am getting the error SyntaxError: Unexpected token C in JSON at position 0. I am also assuming that the error is related to the request.

On my server side, I have the data being sent like this (PHP):

echo json_encode($array);

答:
The message you see is that your JSON response is not formatted correctly

GOOD JSON:

```<code>{ "name":"John", "age":31, "city":"New York" }
</code>```

BAD JSON

```<code>    { 'name': 'john' }
    { name: "john" }
</code>```

OR

```<code>{ 'name' = 'john' }
</code>```

In your case, the JSON begins with character C
keep in mind that a valid Javascript object could be invalid JSON form

Body:
I am trying to perform a GET request and retrieve the data from the response.

this.http.get('http://localhost:8888/maneappback/more-items.php').subscribe(res => {
    console.log(res.json());
}, (err) => {
    console.log(err);
});

I am getting the error SyntaxError: Unexpected token C in JSON at position 0. I am also assuming that the error is related to the request.

On my server side, I have the data being sent like this (PHP):

echo json_encode($array);

Body:
The message you see is that your JSON response is not formatted correctly

GOOD JSON:

{ "name":"John", "age":31, "city":"New York" }

BAD JSON

    { 'name': 'john' }
    { name: "john" }

OR

{ 'name' = 'john' }

In your case, the JSON begins with character C
keep in mind that a valid Javascript object could be invalid JSON form

ContentLicense: CC BY-SA 4.0


问:
More efficient algorithm to find OR of two sets
Given a matrix of n rows and m columns of 1's and 0's, it is required to find out the number of pairs of rows that can be selected so that their OR is 11111....m times.

Example:

```<code>1 0 1 0 1
0 1 0 0 1
1 1 1 1 0
</code>```

Answer:

```<code>2 ---> OR of row number [1,3] and [2,3]
</code>```

Given n and m can be an order upto <= 3000, how efficiently can this problem be solved?

PS: I already tried with a naive O(n*n*m) method. I was thinking of a better solution.

答:
1. trivial solution
The trivial algorithm (which you already discovered but did not post) is to take all (n choose 2) combinations of the n rows, OR them, and see if it works.  This is O(n^2 * m).  Coding would look like:

```<code>for (i = 0; i < n; ++i)
  for (j=i+1; j < n; ++ j) {
    try OR of row[i] with row[j] to see if it works, if so record (i,j)
  }
</code>```

2. constant speedup
You can improve the running time by a factor of the word size by packing bits into the words.  This still gives same asymptotic, but in practice a factor of 64-bit speedup on a 64-bit machine.  This has already been noted in comments above.

3. heuristic speedup
We can do heuristics to further improve the time in practice, but no asymptotic guarantee.  Consider sorting your rows by hamming weight, with smallest hamming weight in the front and largest hamming weight at the end (running time O(m * n * log m )).  Then you only need to compare low weight rows with high weight rows: specifically, the weights need to be >= m.  Then the search would look something like this:

```<code>for (i = 0; i < n; ++i)
  for (j=n-1; j > i; --j) /* go backwards to take advantage of hmwt */
  {
    if ( (hmwt(row[i]) + hmwt(row[j])) < m)
      break;
    try OR of row[i] with row[j] to see if it works, if so record (i,j)
  }
</code>```

4. towards a better approach
Another approach that may offer better returns is to choose a column of low hamming weight.  Then combine the rows into two groups: those with a 1 in that column (group A) versus those with a 0 in that column (group B).  Then you only need to consider combinations of rows where one come from group A and the other comes from group B, or both come from group A (Thanks @ruakh for catching my oversight).  Something along these lines should help a lot.  But again this is still asymptotically same worse case, however should be faster in practice (assuming that we're not in the case of all combinations being the answer).

5. the limits of what can be done
It is easy to construct examples where the number of vector pairs that work is O(n^2), and therefore it feels very hard to beat O(m*n^2) worse case.  What we should be seeking is a solution that is somehow related to the number of pairs that work.  The heuristics above are going this direction.  If there is a column with small hamming weight h, then point 4 above brings the running time down to O(h*n*m + h^2*m).  If h is significantly smaller than n, then you get big improvements.

Body:
Given a matrix of n rows and m columns of 1's and 0's, it is required to find out the number of pairs of rows that can be selected so that their OR is 11111....m times.

Example:

1 0 1 0 1
0 1 0 0 1
1 1 1 1 0

Answer:

2 ---> OR of row number [1,3] and [2,3]

Given n and m can be an order upto <= 3000, how efficiently can this problem be solved?

PS: I already tried with a naive O(n*n*m) method. I was thinking of a better solution.

Body:
1. trivial solution
The trivial algorithm (which you already discovered but did not post) is to take all (n choose 2) combinations of the n rows, OR them, and see if it works.  This is O(n^2 * m).  Coding would look like:

for (i = 0; i < n; ++i)
  for (j=i+1; j < n; ++ j) {
    try OR of row[i] with row[j] to see if it works, if so record (i,j)
  }

2. constant speedup
You can improve the running time by a factor of the word size by packing bits into the words.  This still gives same asymptotic, but in practice a factor of 64-bit speedup on a 64-bit machine.  This has already been noted in comments above.

3. heuristic speedup
We can do heuristics to further improve the time in practice, but no asymptotic guarantee.  Consider sorting your rows by hamming weight, with smallest hamming weight in the front and largest hamming weight at the end (running time O(m * n * log m )).  Then you only need to compare low weight rows with high weight rows: specifically, the weights need to be >= m.  Then the search would look something like this:

for (i = 0; i < n; ++i)
  for (j=n-1; j > i; --j) /* go backwards to take advantage of hmwt */
  {
    if ( (hmwt(row[i]) + hmwt(row[j])) < m)
      break;
    try OR of row[i] with row[j] to see if it works, if so record (i,j)
  }

4. towards a better approach
Another approach that may offer better returns is to choose a column of low hamming weight.  Then combine the rows into two groups: those with a 1 in that column (group A) versus those with a 0 in that column (group B).  Then you only need to consider combinations of rows where one come from group A and the other comes from group B, or both come from group A (Thanks @ruakh for catching my oversight).  Something along these lines should help a lot.  But again this is still asymptotically same worse case, however should be faster in practice (assuming that we're not in the case of all combinations being the answer).

5. the limits of what can be done
It is easy to construct examples where the number of vector pairs that work is O(n^2), and therefore it feels very hard to beat O(m*n^2) worse case.  What we should be seeking is a solution that is somehow related to the number of pairs that work.  The heuristics above are going this direction.  If there is a column with small hamming weight h, then point 4 above brings the running time down to O(h*n*m + h^2*m).  If h is significantly smaller than n, then you get big improvements.


问:
How to introduce the page break after pre-defined number of rows in the jr:table component?
I am using jasper report version 6.1 and wanted page break after pre-defined number of rows in the jr:table component. I have also tried doing the same in version 5 and it works fine but in version 6+ I am not able to do it.

Sharing the links which I followed if any one have other solution please let me know.

http://community.jaspersoft.com/wiki/ireport-how-introduce-page-break-after-pre-defined-number-rows-table-component

http://community.jaspersoft.com/questions/845487/inserting-break-table-print-only-10-rows-page-jasper-reports-372

This is what I have tried:

```<code><?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.1.0.final using JasperReports Library version 6.1.0  -->
<!-- 2017-05-29T15:29:33 -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Blank_A4_4" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="957c1fea-8994-4195-9d7a-2bbf0baf7180">
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="Max apex"/>
    <style name="Table_TH" mode="Opaque" backcolor="#F0F8FF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
            <topPen lineWidth="0.5" lineColor="#000000"/>
            <leftPen lineWidth="0.5" lineColor="#000000"/>
            <bottomPen lineWidth="0.5" lineColor="#000000"/>
            <rightPen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="Table_CH" mode="Opaque" backcolor="#BFE1FF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
            <topPen lineWidth="0.5" lineColor="#000000"/>
            <leftPen lineWidth="0.5" lineColor="#000000"/>
            <bottomPen lineWidth="0.5" lineColor="#000000"/>
            <rightPen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="Table_TD" mode="Opaque" backcolor="#FFFFFF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
            <topPen lineWidth="0.5" lineColor="#000000"/>
            <leftPen lineWidth="0.5" lineColor="#000000"/>
            <bottomPen lineWidth="0.5" lineColor="#000000"/>
            <rightPen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <subDataset name="Dataset1" uuid="435d51b0-6d3e-442e-9a96-ae7412b12278">
        <property name="com.jaspersoft.studio.data.defaultdataadapter" value="Max apex"/>
        <queryString>
            <![CDATA[select * from dept]]>
        </queryString>
        <field name="DEPTNO" class="java.math.BigDecimal"/>
        <field name="DNAME" class="java.lang.String"/>
        <field name="LOC" class="java.lang.String"/>
        <group name="DEPTNO">
            <groupExpression><![CDATA[$F{DEPTNO}]]></groupExpression>
        </group>
        <group name="DNAME">
            <groupExpression><![CDATA[$F{DNAME}]]></groupExpression>
        </group>
        <group name="LOC">
            <groupExpression><![CDATA[$F{LOC}]]></groupExpression>
        </group>
    </subDataset>
    <queryString>
        <![CDATA[select * from dept]]>
    </queryString>
    <field name="DEPTNO" class="java.math.BigDecimal"/>
    <field name="DNAME" class="java.lang.String"/>
    <field name="LOC" class="java.lang.String"/>
    <group name="DEPTNO">
        <groupExpression><![CDATA[$F{DEPTNO}]]></groupExpression>
    </group>
    <group name="DNAME">
        <groupExpression><![CDATA[$F{DNAME}]]></groupExpression>
    </group>
    <group name="LOC">
        <groupExpression><![CDATA[$F{LOC}]]></groupExpression>
    </group>
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band height="79" splitType="Stretch"/>
    </title>
    <pageHeader>
        <band height="35" splitType="Stretch"/>
    </pageHeader>
    <columnHeader>
        <band height="61" splitType="Stretch"/>
    </columnHeader>
    <detail>
        <band height="145" splitType="Stretch">
            <componentElement>
                <reportElement positionType="FixRelativeToBottom" x="10" y="0" width="500" height="110" uuid="b37c89ae-600a-4fb8-ac64-e142bfe22e13"/>
                <jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd">
                    <datasetRun subDataset="Dataset1" uuid="8f84378b-9508-4763-8265-69e68c41febe">
                        <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                    </datasetRun>
                    <jr:column width="100" uuid="00a00921-f5fa-4352-924c-f0531c919f71">
                        <jr:columnHeader style="Table_CH" height="30">
                            <staticText>
                                <reportElement x="0" y="0" width="100" height="30" uuid="d88580f8-05d2-4eb0-a098-00e877c58c39"/>
                                <text><![CDATA[DEPTNO]]></text>
                            </staticText>
                        </jr:columnHeader>
                        <jr:detailCell style="Table_TD" height="30">
                            <textField>
                                <reportElement x="0" y="0" width="90" height="30" uuid="15fda94a-b686-4808-b55c-3e08a8e86187"/>
                                <textFieldExpression><![CDATA[$F{DEPTNO}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                    <jr:column width="140" uuid="72e58aec-00f1-4937-8600-b32a6010d4d6">
                        <jr:columnHeader style="Table_CH" height="30">
                            <staticText>
                                <reportElement x="0" y="0" width="130" height="30" uuid="942c89ca-e914-4809-bb18-3b7065b413f7"/>
                                <text><![CDATA[DNAME]]></text>
                            </staticText>
                        </jr:columnHeader>
                        <jr:detailCell style="Table_TD" height="30">
                            <textField>
                                <reportElement x="0" y="0" width="130" height="30" uuid="8b936e63-5f84-4fd7-b21c-8c08fb9550a5"/>
                                <textFieldExpression><![CDATA[$F{DNAME}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                    <jr:column width="140" uuid="f312cbac-4554-492c-928f-dd84b5a55d42">
                        <jr:columnHeader style="Table_CH" height="30">
                            <staticText>
                                <reportElement x="0" y="0" width="120" height="30" uuid="ce385917-88aa-4e51-9cae-a7a142f78323"/>
                                <text><![CDATA[LOC]]></text>
                            </staticText>
                        </jr:columnHeader>
                        <jr:detailCell style="Table_TD" height="30">
                            <textField>
                                <reportElement x="0" y="0" width="120" height="30" uuid="0e43f425-558c-4001-9c44-ca14798bcb75"/>
                                <textFieldExpression><![CDATA[$F{LOC}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                </jr:table>
            </componentElement>
        </band>
    </detail>
    <columnFooter>
        <band height="45" splitType="Stretch"/>
    </columnFooter>
    <pageFooter>
        <band height="54" splitType="Stretch"/>
    </pageFooter>
    <summary>
        <band height="42" splitType="Stretch"/>
    </summary>
</jasperReport>
</code>```

答:
The solution to use a a group expression inside the subdatset works perfectly fine also in jasper reports v6+.

Example (built from code and data from this answer)

Adding groupExpression to the subDataset to break to new page every 2 records ($V{REPORT_COUNT}-1)/2)

```<code><subDataset name="tableDataset" uuid="7a53770f-0350-4a73-bfc1-48a5f6386594">
    <field name="User" class="java.lang.String"/>
    <field name="Rep" class="java.math.BigDecimal"/>
    <group name="pageBreakGroup" isStartNewPage="true">
        <groupExpression><![CDATA[(int)(($V{REPORT_COUNT}-1)/2)]]></groupExpression>
    </group>
</subDataset>
</code>```

Expand code snippet for full code.

<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="reputation" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="a88bd694-4f90-41fc-84d0-002b90b2d73e">
 <property name="com.jaspersoft.studio.data.defaultdataadapter" value="CVS"/>

 <subDataset name="tableDataset" uuid="7a53770f-0350-4a73-bfc1-48a5f6386594">
  <field name="User" class="java.lang.String"/>
  <field name="Rep" class="java.math.BigDecimal"/>
  <group name="pageBreakGroup" isStartNewPage="true">
   <groupExpression><![CDATA[(int)(($V{REPORT_COUNT}-1)/2d)]]></groupExpression>
  </group>
 </subDataset>
 <parameter name="displayRecordNumber" class="java.lang.Boolean">
  <defaultValueExpression><![CDATA[true]]></defaultValueExpression>
 </parameter>
 <queryString>
  <![CDATA[]]>
 </queryString>
 <title>
  <band height="50">
   <componentElement>
    <reportElement key="table" style="table" x="0" y="0" width="555" height="47" uuid="76ab08c6-e757-4785-a43d-b65ad4ab1dd5"/>
    <jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd">
     <datasetRun subDataset="tableDataset" uuid="07e5f1c2-af7f-4373-b653-c127c47c9fa4">
      <dataSourceExpression><![CDATA[$P{REPORT_DATA_SOURCE}]]></dataSourceExpression>
     </datasetRun>
     <jr:column width="90" uuid="918270fe-25c8-4a9b-a872-91299cddbc31">
      <printWhenExpression><![CDATA[$P{displayRecordNumber}]]></printWhenExpression>
      <jr:columnHeader style="table_CH" height="30" rowSpan="1">
       <staticText>
        <reportElement x="0" y="0" width="90" height="30" uuid="5cd6da41-01d5-4f74-99c2-06784f891d1e"/>
        <textElement textAlignment="Center" verticalAlignment="Middle"/>
        <text><![CDATA[Record number]]></text>
       </staticText>
      </jr:columnHeader>
      <jr:detailCell style="table_TD" height="30" rowSpan="1">
       <textField>
        <reportElement x="0" y="0" width="90" height="30" uuid="5fe48359-0e7e-44b2-93ac-f55404189832"/>
        <textElement textAlignment="Center" verticalAlignment="Middle"/>
        <textFieldExpression><![CDATA[$V{REPORT_COUNT}]]></textFieldExpression>
       </textField>
      </jr:detailCell>
     </jr:column>
     <jr:column width="90" uuid="7979d8a2-4e3c-42a7-9ff9-86f8e0b164bc">
      <jr:columnHeader style="table_CH" height="30" rowSpan="1">
       <staticText>
        <reportElement x="0" y="0" width="90" height="30" uuid="61d5f1b6-7677-4511-a10c-1fb8a56a4b2a"/>
        <textElement textAlignment="Center" verticalAlignment="Middle"/>
        <text><![CDATA[Username]]></text>
       </staticText>
      </jr:columnHeader>
      <jr:detailCell style="table_TD" height="30" rowSpan="1">
       <textField>
        <reportElement x="0" y="0" width="90" height="30" uuid="a3cdb99d-3bf6-4c66-b50c-259b9aabfaef"/>
        <box leftPadding="3" rightPadding="3"/>
        <textElement verticalAlignment="Middle"/>
        <textFieldExpression><![CDATA[$F{User}]]></textFieldExpression>
       </textField>
      </jr:detailCell>
     </jr:column>
     <jr:column width="90" uuid="625e4e5e-5057-4eab-b4a9-c5b22844d25c">
      <jr:columnHeader style="table_CH" height="30" rowSpan="1">
       <staticText>
        <reportElement x="0" y="0" width="90" height="30" uuid="e1c07cb8-a44c-4a8d-8566-5c86d6671282"/>
        <textElement textAlignment="Center" verticalAlignment="Middle"/>
        <text><![CDATA[Reputation]]></text>
       </staticText>
      </jr:columnHeader>
      <jr:detailCell style="table_TD" height="30" rowSpan="1">
       <textField pattern="#,##0">
        <reportElement x="0" y="0" width="90" height="30" uuid="6be2d79f-be82-4c7b-afd9-0039fb8b3189"/>
        <box leftPadding="3" rightPadding="3"/>
        <textElement textAlignment="Right" verticalAlignment="Middle"/>
        <textFieldExpression><![CDATA[$F{Rep}]]></textFieldExpression>
       </textField>
      </jr:detailCell>
     </jr:column>
    </jr:table>
   </componentElement>
  </band>
 </title>
</jasperReport>```

Result in JasperStudio version 6.2

As you can see 3 pages (2 records on each, total record count 5).

Body:
I am using jasper report version 6.1 and wanted page break after pre-defined number of rows in the jr:table component. I have also tried doing the same in version 5 and it works fine but in version 6+ I am not able to do it.

Sharing the links which I followed if any one have other solution please let me know.

http://community.jaspersoft.com/wiki/ireport-how-introduce-page-break-after-pre-defined-number-rows-table-component

http://community.jaspersoft.com/questions/845487/inserting-break-table-print-only-10-rows-page-jasper-reports-372

This is what I have tried:

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

<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Blank_A4_4" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="957c1fea-8994-4195-9d7a-2bbf0baf7180">
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="Max apex"/>

    <subDataset name="Dataset1" uuid="435d51b0-6d3e-442e-9a96-ae7412b12278">
        <property name="com.jaspersoft.studio.data.defaultdataadapter" value="Max apex"/>
        <queryString>
            <![CDATA[select * from dept]]>
        </queryString>
        <field name="DEPTNO" class="java.math.BigDecimal"/>
        <field name="DNAME" class="java.lang.String"/>
        <field name="LOC" class="java.lang.String"/>
        <group name="DEPTNO">
            <groupExpression><![CDATA[$F{DEPTNO}]]></groupExpression>
        </group>
        <group name="DNAME">
            <groupExpression><![CDATA[$F{DNAME}]]></groupExpression>
        </group>
        <group name="LOC">
            <groupExpression><![CDATA[$F{LOC}]]></groupExpression>
        </group>
    </subDataset>
    <queryString>
        <![CDATA[select * from dept]]>
    </queryString>
    <field name="DEPTNO" class="java.math.BigDecimal"/>
    <field name="DNAME" class="java.lang.String"/>
    <field name="LOC" class="java.lang.String"/>
    <group name="DEPTNO">
        <groupExpression><![CDATA[$F{DEPTNO}]]></groupExpression>
    </group>
    <group name="DNAME">
        <groupExpression><![CDATA[$F{DNAME}]]></groupExpression>
    </group>
    <group name="LOC">
        <groupExpression><![CDATA[$F{LOC}]]></groupExpression>
    </group>
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band height="79" splitType="Stretch"/>
    </title>
    <pageHeader>
        <band height="35" splitType="Stretch"/>
    </pageHeader>
    <columnHeader>
        <band height="61" splitType="Stretch"/>
    </columnHeader>
    <detail>
        <band height="145" splitType="Stretch">
            <componentElement>
                <reportElement positionType="FixRelativeToBottom" x="10" y="0" width="500" height="110" uuid="b37c89ae-600a-4fb8-ac64-e142bfe22e13"/>
                <jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd">
                    <datasetRun subDataset="Dataset1" uuid="8f84378b-9508-4763-8265-69e68c41febe">
                        <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                    </datasetRun>
                    <jr:column width="100" uuid="00a00921-f5fa-4352-924c-f0531c919f71">
                        <jr:columnHeader style="Table_CH" height="30">
                            <staticText>
                                <reportElement x="0" y="0" width="100" height="30" uuid="d88580f8-05d2-4eb0-a098-00e877c58c39"/>
                                <text><![CDATA[DEPTNO]]></text>
                            </staticText>
                        </jr:columnHeader>
                        <jr:detailCell style="Table_TD" height="30">
                            <textField>
                                <reportElement x="0" y="0" width="90" height="30" uuid="15fda94a-b686-4808-b55c-3e08a8e86187"/>
                                <textFieldExpression><![CDATA[$F{DEPTNO}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                    <jr:column width="140" uuid="72e58aec-00f1-4937-8600-b32a6010d4d6">
                        <jr:columnHeader style="Table_CH" height="30">
                            <staticText>
                                <reportElement x="0" y="0" width="130" height="30" uuid="942c89ca-e914-4809-bb18-3b7065b413f7"/>
                                <text><![CDATA[DNAME]]></text>
                            </staticText>
                        </jr:columnHeader>
                        <jr:detailCell style="Table_TD" height="30">
                            <textField>
                                <reportElement x="0" y="0" width="130" height="30" uuid="8b936e63-5f84-4fd7-b21c-8c08fb9550a5"/>
                                <textFieldExpression><![CDATA[$F{DNAME}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                    <jr:column width="140" uuid="f312cbac-4554-492c-928f-dd84b5a55d42">
                        <jr:columnHeader style="Table_CH" height="30">
                            <staticText>
                                <reportElement x="0" y="0" width="120" height="30" uuid="ce385917-88aa-4e51-9cae-a7a142f78323"/>
                                <text><![CDATA[LOC]]></text>
                            </staticText>
                        </jr:columnHeader>
                        <jr:detailCell style="Table_TD" height="30">
                            <textField>
                                <reportElement x="0" y="0" width="120" height="30" uuid="0e43f425-558c-4001-9c44-ca14798bcb75"/>
                                <textFieldExpression><![CDATA[$F{LOC}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                </jr:table>
            </componentElement>
        </band>
    </detail>
    <columnFooter>
        <band height="45" splitType="Stretch"/>
    </columnFooter>
    <pageFooter>
        <band height="54" splitType="Stretch"/>
    </pageFooter>

        <band height="42" splitType="Stretch"/>

</jasperReport>

Body:
The solution to use a a group expression inside the subdatset works perfectly fine also in jasper reports v6+.

Example (built from code and data from this answer)

Adding groupExpression to the subDataset to break to new page every 2 records ($V{REPORT_COUNT}-1)/2)

<subDataset name="tableDataset" uuid="7a53770f-0350-4a73-bfc1-48a5f6386594">
    <field name="User" class="java.lang.String"/>
    <field name="Rep" class="java.math.BigDecimal"/>
    <group name="pageBreakGroup" isStartNewPage="true">
        <groupExpression><![CDATA[(int)(($V{REPORT_COUNT}-1)/2)]]></groupExpression>
    </group>
</subDataset>

Expand code snippet for full code.

<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="reputation" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="a88bd694-4f90-41fc-84d0-002b90b2d73e">
 <property name="com.jaspersoft.studio.data.defaultdataadapter" value="CVS"/>
 <style name="table">
  <box>
   <pen lineWidth="1.0" lineColor="#000000"/>
  </box>
 </style>
 <style name="table_TH" mode="Opaque" backcolor="#F0F8FF">
  <box>
   <pen lineWidth="0.5" lineColor="#000000"/>
  </box>
 </style>
 <style name="table_CH" mode="Opaque" backcolor="#BFE1FF">
  <box>
   <pen lineWidth="0.5" lineColor="#000000"/>
  </box>
 </style>
 <style name="table_TD" mode="Opaque" backcolor="#FFFFFF">
  <box>
   <pen lineWidth="0.5" lineColor="#000000"/>
  </box>
 </style>
 <subDataset name="tableDataset" uuid="7a53770f-0350-4a73-bfc1-48a5f6386594">
  <field name="User" class="java.lang.String"/>
  <field name="Rep" class="java.math.BigDecimal"/>
  <group name="pageBreakGroup" isStartNewPage="true">
   <groupExpression><![CDATA[(int)(($V{REPORT_COUNT}-1)/2d)]]></groupExpression>
  </group>
 </subDataset>
 <parameter name="displayRecordNumber" class="java.lang.Boolean">
  <defaultValueExpression><![CDATA[true]]></defaultValueExpression>
 </parameter>
 <queryString>
  <![CDATA[]]>
 </queryString>
 <title>
  <band height="50">
   <componentElement>
    <reportElement key="table" style="table" x="0" y="0" width="555" height="47" uuid="76ab08c6-e757-4785-a43d-b65ad4ab1dd5"/>
    <jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd">
     <datasetRun subDataset="tableDataset" uuid="07e5f1c2-af7f-4373-b653-c127c47c9fa4">
      <dataSourceExpression><![CDATA[$P{REPORT_DATA_SOURCE}]]></dataSourceExpression>
     </datasetRun>
     <jr:column width="90" uuid="918270fe-25c8-4a9b-a872-91299cddbc31">
      <printWhenExpression><![CDATA[$P{displayRecordNumber}]]></printWhenExpression>
      <jr:columnHeader style="table_CH" height="30" rowSpan="1">
       <staticText>
        <reportElement x="0" y="0" width="90" height="30" uuid="5cd6da41-01d5-4f74-99c2-06784f891d1e"/>
        <textElement textAlignment="Center" verticalAlignment="Middle"/>
        <text><![CDATA[Record number]]></text>
       </staticText>
      </jr:columnHeader>
      <jr:detailCell style="table_TD" height="30" rowSpan="1">
       <textField>
        <reportElement x="0" y="0" width="90" height="30" uuid="5fe48359-0e7e-44b2-93ac-f55404189832"/>
        <textElement textAlignment="Center" verticalAlignment="Middle"/>
        <textFieldExpression><![CDATA[$V{REPORT_COUNT}]]></textFieldExpression>
       </textField>
      </jr:detailCell>
     </jr:column>
     <jr:column width="90" uuid="7979d8a2-4e3c-42a7-9ff9-86f8e0b164bc">
      <jr:columnHeader style="table_CH" height="30" rowSpan="1">
       <staticText>
        <reportElement x="0" y="0" width="90" height="30" uuid="61d5f1b6-7677-4511-a10c-1fb8a56a4b2a"/>
        <textElement textAlignment="Center" verticalAlignment="Middle"/>
        <text><![CDATA[Username]]></text>
       </staticText>
      </jr:columnHeader>
      <jr:detailCell style="table_TD" height="30" rowSpan="1">
       <textField>
        <reportElement x="0" y="0" width="90" height="30" uuid="a3cdb99d-3bf6-4c66-b50c-259b9aabfaef"/>
        <box leftPadding="3" rightPadding="3"/>
        <textElement verticalAlignment="Middle"/>
        <textFieldExpression><![CDATA[$F{User}]]></textFieldExpression>
       </textField>
      </jr:detailCell>
     </jr:column>
     <jr:column width="90" uuid="625e4e5e-5057-4eab-b4a9-c5b22844d25c">
      <jr:columnHeader style="table_CH" height="30" rowSpan="1">
       <staticText>
        <reportElement x="0" y="0" width="90" height="30" uuid="e1c07cb8-a44c-4a8d-8566-5c86d6671282"/>
        <textElement textAlignment="Center" verticalAlignment="Middle"/>
        <text><![CDATA[Reputation]]></text>
       </staticText>
      </jr:columnHeader>
      <jr:detailCell style="table_TD" height="30" rowSpan="1">
       <textField pattern="#,##0">
        <reportElement x="0" y="0" width="90" height="30" uuid="6be2d79f-be82-4c7b-afd9-0039fb8b3189"/>
        <box leftPadding="3" rightPadding="3"/>
        <textElement textAlignment="Right" verticalAlignment="Middle"/>
        <textFieldExpression><![CDATA[$F{Rep}]]></textFieldExpression>
       </textField>
      </jr:detailCell>
     </jr:column>
    </jr:table>
   </componentElement>
  </band>
 </title>
</jasperReport>

Result in JasperStudio version 6.2

As you can see 3 pages (2 records on each, total record count 5).


问:
Can not get return type of my function with string array
So guys, I try to call my function from my web service which has the return type List<string[]>:

```<code>SQLService.SQLServiceClient proxy = new SQLService.SQLServiceClient();
List<string[]> objekte = await proxy.GetObjekteAsync();
</code>```

but then I get this error:

The "System.Collections.ObjectModel.ObservableCollection< System.Collections.ObjectModel.ObservableCollection< string>>" type can not
  be converted to System.Collections.Generic.List< string[]>

Here is my function GetObjekte():

```<code>public List<string[]> GetObjekte()
{
    List<string[]> objektliste = new List<string[]>();
    sqlcon.Open();

    SqlCommand getObjekte = new SqlCommand("SELECT * FROM [demo]", sqlcon);
    SqlDataReader reader = getObjekte.ExecuteReader();
    while (reader.Read())
    {
        string[] stringarry = new string[3];

        stringarry[1] = reader["Beschreibung"].ToString();
        stringarry[2] = reader["Lief_ an Adresse"].ToString();
        stringarry[3] = Convert.ToString(reader["Lief_ an PLZ-Code"] + " " + reader["Lief_ an Ort"]);

        objektliste.Add(stringarry);
    }
    sqlcon.Close();

    return objektliste;
}
</code>```

I don't know why Visual Studio thinks that it has a:

System.Collections.ObjectModel.ObservableCollection<
  System.Collections.ObjectModel.ObservableCollection< string>>

as a return type... I don't see my mistake here. Maybe some of u can help me...

Whole code of my webservice class:

```<code>namespace SQLService

public class SQLService : ISQLService
{

    SqlConnection sqlcon = new SqlConnection("server=; Database=; Uid=; Pwd=");

    public List<string[]> GetObjekte()
    {
        List<string[]> objektliste = new List<string[]>();
        sqlcon.Open();

        SqlCommand getObjekte = new SqlCommand("SELECT * FROM [demo]", sqlcon);
        SqlDataReader reader = getObjekte.ExecuteReader();
        while (reader.Read())
        {
            string[] stringarry = new string[3];

            stringarry[1] = reader["Beschreibung"].ToString();
            stringarry[2] = reader["Lief_ an Adresse"].ToString();
            stringarry[3] = Convert.ToString(reader["Lief_ an PLZ-Code"] + " " + reader["Lief_ an Ort"]);

            objektliste.Add(stringarry);
        }
        sqlcon.Close();

        return objektliste;
    }
}
</code>```

my interface:

```<code>namespace SQLService
{
    [ServiceContract]
    public interface ISQLService
    {
        [OperationContract]
        List<string[]> GetObjekte();
    }
}
</code>```

答:
First update service reference to generate collection types as System.Array

Then update client code...

```<code>var proxy = new SQLService.SQLServiceClient();
List<string[]> objekte = (await proxy.GetObjekteAsync()).ToList();
</code>```

Body:
So guys, I try to call my function from my web service which has the return type List<string[]>:

SQLService.SQLServiceClient proxy = new SQLService.SQLServiceClient();
List<string[]> objekte = await proxy.GetObjekteAsync();

but then I get this error:

The "System.Collections.ObjectModel.ObservableCollection< System.Collections.ObjectModel.ObservableCollection< string>>" type can not
  be converted to System.Collections.Generic.List< string[]>

Here is my function GetObjekte():

public List<string[]> GetObjekte()
{
    List<string[]> objektliste = new List<string[]>();
    sqlcon.Open();

    SqlCommand getObjekte = new SqlCommand("SELECT * FROM [demo]", sqlcon);
    SqlDataReader reader = getObjekte.ExecuteReader();
    while (reader.Read())
    {
        string[] stringarry = new string[3];

        stringarry[1] = reader["Beschreibung"].ToString();
        stringarry[2] = reader["Lief_ an Adresse"].ToString();
        stringarry[3] = Convert.ToString(reader["Lief_ an PLZ-Code"] + " " + reader["Lief_ an Ort"]);

        objektliste.Add(stringarry);
    }
    sqlcon.Close();

    return objektliste;
}

I don't know why Visual Studio thinks that it has a:

System.Collections.ObjectModel.ObservableCollection<
  System.Collections.ObjectModel.ObservableCollection< string>>

as a return type... I don't see my mistake here. Maybe some of u can help me...

Whole code of my webservice class:

namespace SQLService

public class SQLService : ISQLService
{

    SqlConnection sqlcon = new SqlConnection("server=; Database=; Uid=; Pwd=");

    public List<string[]> GetObjekte()
    {
        List<string[]> objektliste = new List<string[]>();
        sqlcon.Open();

        SqlCommand getObjekte = new SqlCommand("SELECT * FROM [demo]", sqlcon);
        SqlDataReader reader = getObjekte.ExecuteReader();
        while (reader.Read())
        {
            string[] stringarry = new string[3];

            stringarry[1] = reader["Beschreibung"].ToString();
            stringarry[2] = reader["Lief_ an Adresse"].ToString();
            stringarry[3] = Convert.ToString(reader["Lief_ an PLZ-Code"] + " " + reader["Lief_ an Ort"]);

            objektliste.Add(stringarry);
        }
        sqlcon.Close();

        return objektliste;
    }
}

my interface:

namespace SQLService
{
    [ServiceContract]
    public interface ISQLService
    {
        [OperationContract]
        List<string[]> GetObjekte();
    }
}

Body:
First update service reference to generate collection types as System.Array

Then update client code...

var proxy = new SQLService.SQLServiceClient();
List<string[]> objekte = (await proxy.GetObjekteAsync()).ToList();


问:
Python Numpy Exponential Value from Array of BigFloats
I'm trying to compute the natural log of the exponential plus the median of an array but precision of the floating point numbers has to be at 2000 or the answer will always be 0.

Here is what I have so far:

```<code>import bigfloat
x = np.array([-15349.79, -15266.66, -15242.86])
answer = np.median(x) - bigfloat.log(np.mean(bigfloat.exp(x, precision(2000)) + np.median(x)))
</code>```

This code returns the following error because BigFloat.exp doesn't work on list types.

```<code>__main__:1: RuntimeWarning: invalid value encountered in log
    array([ nan,  nan,  nan])
    >>> np.median - bigfloat.log(np.mean(bigfloat.exp(x, precision(2000)) + np.median(x)))
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/usr/local/lib/python2.7/dist-packages/bigfloat/core.py", line 1446, in exp
        (BigFloat._implicit_convert(x),),
      File "/usr/local/lib/python2.7/dist-packages/bigfloat/core.py", line 800, in _implicit_convert
        "to BigFloat" % (arg, type(arg)))
    TypeError: Unable to convert argument [-15349.79 -15266.66 -15242.86] of type <type 'numpy.ndarray'> to BigFloat
</code>```

I then tried list comprehension to build exponentials with precision=2000 but the output loses precision.

```<code>>>>[bigfloat.exp(num, precision(2000)) + BigFloat(np.median(x), context=precision(2000)) for num in x]

[BigFloat.exact('-15266.660000000000', precision=53), BigFloat.exact('-15266.660000000000', precision=53), BigFloat.exact('-15266.660000000000', precision=53)]
</code>```

I can get exponential values from x with precision using list comprehension
like this:

```<code>>>> y = np.array([bigfloat.exp(num, precision(2000)) for num in x])
array([ BigFloat.exact('4.687104391719151845495683439738733373338442839115295629901427982078731632624437676931490944129698360820181432182432247030174990996132679553420878801399467284014932435857939862423137788809352433385343338286781879066456873472082636971652587852379587642184738259777920214145750081457830886095059600271300801524086458081526778407096875577469007859748418787409261916565428551066536598870494431653463691369520685259389041691328858076222360659135651318185915247243253437425313718584237418827954902711646850362440592578566737383074556346759332830833101196990845567845361685702120838400980658468192376607029699380e-6667', precision=2000),
       BigFloat.exact('5.940252515613784074556309936460240719247289162721506036367173706446251980105141516508485353816420203092949808160441872102510858074752258842471232457791645630942356791030979819957875784926363292788234347364203226596687259399429746917920741954706671428927952815041593801046941161417184730521922391569252658359604561007344640221209247257690437938341582528542446104212627600044421405229891732857592357725820529732658234033631318425476205945557122313924830225909708184718714804450362854280687393958953216361511561704836206669636791590655443171684811683402330053964681285971765503804198242627954802184910024902e-6631', precision=2000),
       BigFloat.exact('1.288289823457680769007768910906908351089465066737359292851136781233384628626343352992636825492031571595103435334370758196286825224816434202324210124540257467624499933926757723584914581286627071375803686797647455160335628799775858142489656885909172399293492295645703203222218182084249732700966821340431452575815746282651823925677898549539269454644804048695031225101971491985645951419388454738446335860070391719831039721150295437452237572831818257568221336263814212095143032293694959570063677473370798577031762607527221992020661837810811705007892502559603984057933079724597470162879821292957122400421187875e-6620', precision=2000)], dtype=object)
</code>```

So, how do I add np.median(x) to each item in the exponential array and how do I get the log of the elements in the final array? Is there an easier way to compute the equation given by variable answer in the first code snippet above?

I'm basically trying to convert this R code to Python:

```<code>llMed <- stats::median(x)
metric <- as.double(
  llMed - log( Rmpfr::mean( exp( -Rmpfr::mpfr(x, prec=2000L) + llMed )))
)
</code>```

Body:
I'm trying to compute the natural log of the exponential plus the median of an array but precision of the floating point numbers has to be at 2000 or the answer will always be 0.

Here is what I have so far:

import bigfloat
x = np.array([-15349.79, -15266.66, -15242.86])
answer = np.median(x) - bigfloat.log(np.mean(bigfloat.exp(x, precision(2000)) + np.median(x)))

This code returns the following error because BigFloat.exp doesn't work on list types.

__main__:1: RuntimeWarning: invalid value encountered in log
    array([ nan,  nan,  nan])
    >>> np.median - bigfloat.log(np.mean(bigfloat.exp(x, precision(2000)) + np.median(x)))
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/usr/local/lib/python2.7/dist-packages/bigfloat/core.py", line 1446, in exp
        (BigFloat._implicit_convert(x),),
      File "/usr/local/lib/python2.7/dist-packages/bigfloat/core.py", line 800, in _implicit_convert
        "to BigFloat" % (arg, type(arg)))
    TypeError: Unable to convert argument [-15349.79 -15266.66 -15242.86] of type <type 'numpy.ndarray'> to BigFloat

I then tried list comprehension to build exponentials with precision=2000 but the output loses precision.

>>>[bigfloat.exp(num, precision(2000)) + BigFloat(np.median(x), context=precision(2000)) for num in x]

[BigFloat.exact('-15266.660000000000', precision=53), BigFloat.exact('-15266.660000000000', precision=53), BigFloat.exact('-15266.660000000000', precision=53)]

I can get exponential values from x with precision using list comprehension
like this:

>>> y = np.array([bigfloat.exp(num, precision(2000)) for num in x])
array([ BigFloat.exact('4.687104391719151845495683439738733373338442839115295629901427982078731632624437676931490944129698360820181432182432247030174990996132679553420878801399467284014932435857939862423137788809352433385343338286781879066456873472082636971652587852379587642184738259777920214145750081457830886095059600271300801524086458081526778407096875577469007859748418787409261916565428551066536598870494431653463691369520685259389041691328858076222360659135651318185915247243253437425313718584237418827954902711646850362440592578566737383074556346759332830833101196990845567845361685702120838400980658468192376607029699380e-6667', precision=2000),
       BigFloat.exact('5.940252515613784074556309936460240719247289162721506036367173706446251980105141516508485353816420203092949808160441872102510858074752258842471232457791645630942356791030979819957875784926363292788234347364203226596687259399429746917920741954706671428927952815041593801046941161417184730521922391569252658359604561007344640221209247257690437938341582528542446104212627600044421405229891732857592357725820529732658234033631318425476205945557122313924830225909708184718714804450362854280687393958953216361511561704836206669636791590655443171684811683402330053964681285971765503804198242627954802184910024902e-6631', precision=2000),
       BigFloat.exact('1.288289823457680769007768910906908351089465066737359292851136781233384628626343352992636825492031571595103435334370758196286825224816434202324210124540257467624499933926757723584914581286627071375803686797647455160335628799775858142489656885909172399293492295645703203222218182084249732700966821340431452575815746282651823925677898549539269454644804048695031225101971491985645951419388454738446335860070391719831039721150295437452237572831818257568221336263814212095143032293694959570063677473370798577031762607527221992020661837810811705007892502559603984057933079724597470162879821292957122400421187875e-6620', precision=2000)], dtype=object)

So, how do I add np.median(x) to each item in the exponential array and how do I get the log of the elements in the final array? Is there an easier way to compute the equation given by variable answer in the first code snippet above?

I'm basically trying to convert this R code to Python:

llMed <- stats::median(x)
metric <- as.double(
  llMed - log( Rmpfr::mean( exp( -Rmpfr::mpfr(x, prec=2000L) + llMed )))
)

Body:
I think I was able to transpose the R code above, using gmpy2 instead of BigFloat but probably could have used either:

import gmpy2 as gp
import numpy as np
with gp.local_context(gp.context(), precision=2000) as ctx:
    x = np.array([gp.mpfr(-15349.79), gp.mpfr(-15266.66), gp.mpfr(-15242.86)])
    answer = np.median(x) - gp.log(np.mean([gp.exp(gp.add(np.median(x), -gp.mpfr(item))) for item in x]))

Output returns:

mpfr('-15348.69138771133276342351845677418587273364155071266454924792376077085597654860712492594599688058199377288639137666410888137048513058096745776113277020531535761588878042016412651412489608285582998650481415959482636259292554205272401992800167437149224493900214813760731711328834885525224938584036572786202764947113186177391441168267495103157033223800214492991771147327262071249020907408433551462034872024117419365924381891832161483692689444158313503155805562703358104122358438183824459422779020196496507161021965435781332319270106503099589290788685588200038739438059696970511568363022088057740627040541967',2000)


问:
Adding JButton with ActionListener to a JTabbedPane: ActionListener not working
New poster here; if I'm breaking any rules/screwing anything up, just tell me and I'll take the post down.

I have a MainMenu JFrame with a JPanel (mainMenu) inside it. mainMenu has one button that changes the display to the JTabbedPane Instructions. This part is working fine.

The problem comes in when I'm trying to add a button and new tab to Instructions. Although the new buttons and tab are added to the Instructions class, the button doesn't actually do anything despite having an ActionListener for that button.

Below are the Instructions class (extends JTabbedPane) and MainMenu (extends JFrame) for reference.

Thanks in advance.

Directly below: MainMenu class
`

```<code>/**
 * @Author Small Snake Studios (Nathan Lee)
 * @Date Feb 28, 2017
 * @Version 1.0
 * @Description This program is a JPanel for the Blockfinder Express game. Mostg of the work done this week has been in graphics rather than in coding this week.
 */

import javax.swing.*;
import java.awt.event.*;
import java.awt.FlowLayout;
import java.awt.event.ActionListener;
/**
 * This is a JPanel that represents the main menu of the program. Each of the buttons open up another JPanel in the main JFrame,
 * each JPanel representing a different screen. This JFrame is the main menu and you can open the other JPanels through this one.
 * Because it's a JFrame, it can hold and control the rest of the windows (splash screen, main menu, credits, the main game, instructions,
 * high scores and exit.
 **/

public class MainMenu extends JFrame implements ActionListener
{

    /**
     * This is a serialVersionUID. It is generated to avoid errors/warnings.
     */
    private static final long serialVersionUID = -3088890058631223710L;
    /*Name          use                                                                         type
     * splashScreen creates a splash screen that shows an animation                         SplashScreen
     * mainGame     a JPanel representing the main game                                     MainGame
     * instructions a JPanel representing the instructions screen                           Instructions
     * quit         a JPanel representing the quit screen                                   Quit
     * credits      a JPanel representing the credits screen                                Credits
     * mainMenu     a JPanel representing the main menu (built into the MainMenu class)     JPanel*/
    SplashScreen splashScreen = new SplashScreen ();
    JTabbedPane instructions = new Instructions ();
    JPanel credits = new Credits ();
    JPanel highScores = new HighScores ();
    JPanel mainMenu = new JPanel ();
    JMenuBar myMenus  = new JMenuBar ();
    JButton play = new JButton ("Play!");
    JButton howToPlay = new JButton ("Learn!");
    JButton leaderboards = new JButton ("Leaderboards!");
    JButton creds = new JButton ("Credits!");
    JMenu quitMenu = new JMenu ("Quit");
    JMenuItem quitMenuItem = new JMenuItem ("Quit");

    public MainMenu () //constructor
    {
        super ("Blockfinder Express"); //constructor adds all of these buttons to the JPanel
        init ();
    }

    public void actionPerformed (ActionEvent ae)
    {
        Frame f = null;
        if (ae.getActionCommand ().equals ("Play!"))
        {  if (f == null)
        {
            remove (mainMenu);
            f = new Frame ();
            repaint ();
        }
        }
        if (ae.getActionCommand ().equals("Quit"))
        {
            dispose ();
            f.dispose ();
        }
        if (ae.getActionCommand ().equals ("Return to Menu"))
        {
            System.out.println("returning to menu");
            remove (instructions);
            add (mainMenu);
            repaint ();
            revalidate ();
        }
        if (ae.getActionCommand ().equals ("Learn!"))
        {
            add (instructions);
            JPanel exit = new JPanel ();
            JButton returnButton = new JButton ("Return to Menu");
            exit.add(returnButton);
            instructions.add("Exit", exit);
            remove (mainMenu);
            repaint ();
            System.out.println ("Functional");
        }
    }
    public void init ()
    {
        play.addActionListener(this);
        howToPlay.addActionListener(this);
        leaderboards.addActionListener (this);
        creds.addActionListener (this);
        mainMenu.add (play);
        mainMenu.add (howToPlay);
        mainMenu.add(leaderboards);
        mainMenu.add(creds);
        myMenus.add(quitMenu);
        quitMenu.add(quitMenuItem);
        quitMenuItem.addActionListener(this);
        setJMenuBar (myMenus);
        setSize (1000,900);
        setResizable (false);
        setVisible (true);
        setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        add (splashScreen);
        splashScreen.animate ();
        remove (splashScreen);
        add (mainMenu);
        repaint ();
        revalidate ();
    }

    public static void main (String [] args)
    {
        MainMenu mm = new MainMenu ();
    }
}
</code>```

`
Below: Instructions class

```<code>    /**
 * @author Nathan
 * @version 1.0
 * @studio Small Snake Studios
 * @purpose: This is a JPanel representing the instructions screen. It functions by using a picture
 * the instructions screen as the way to display it on the JPanel. The driver class/main menu
 * adds an exit button to the JPanel so I can implement an ActionListener that closes this
 * tab from there. Probably works better that way, too. Uses a CardLayout to go from one
 * instruction page to another, allowing for easy readability and preventing me from having
 * to cram a lot of info in one screen. The pages of the CardLayout are done via nested classes
 * so I can implement paint and graphics in each of them.
 *
 * Things to do:
 * - Add actual pictures for the three instructions screen
 * - Run this code with everything else to ensure it works
 */

import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;

import javax.swing.*;
import java.io.*;
import javax.imageio.ImageIO;

public class Instructions extends JTabbedPane{
        class FirstScreen extends JPanel
    {
        /**
             *
             */
        private static final long serialVersionUID = -2674891692847531892L;
        BufferedImage instructions;
        public FirstScreen ()
        {
            importInfo ();
            repaint ();
        }
        public void importInfo (){
        try
        {
            instructions = ImageIO.read (new File ("Instructions1.png"));
        }
        catch (IOException e)
        {
        }
        }
        public void paint (Graphics g)
        {
            g.drawImage (instructions, 0, 0, null);
        }
    }
        class SecondScreen extends JPanel
    {
        private static final long serialVersionUID = -2840353661877108337L;
        BufferedImage instructions;
        public SecondScreen ()
        {
            importInfo ();
            repaint ();
        }
        public void importInfo ()
        {
            try
            {
            instructions = ImageIO.read (new File ("Instructions2.png"));
            }
            catch (IOException e)
            {
            }
        }
        public void paint (Graphics g)
        {
            g.drawImage (instructions, 0, 0, null);
        }
    }
        class ThirdScreen extends JPanel
        {
        /**
             *
             */
        private static final long serialVersionUID = -394248748993045880L;
        BufferedImage instructions;
        public ThirdScreen ()
        {
            importInfo ();
            repaint ();
        }
        public void importInfo ()
        {
            try
            {
                instructions = ImageIO.read (new File ("Instructions3.png"));
            }
            catch (IOException e)
            {
            }
        }
        public void paint (Graphics g)
        {
            g.drawImage (instructions, 0, 0, null);
        }
        }
public Instructions ()
{
    super ();
    FirstScreen card1 = new FirstScreen ();
    SecondScreen card2 = new SecondScreen ();
    ThirdScreen card3 = new ThirdScreen ();
    add ("Page 1", card1);
    add ("Page 2", card2);
    add ("Page 3", card3);
}
}
</code>```

答:
The returnButton you are referring to has no actionListener attached. So just add it.</p>

```<code>JButton returnButton = new JButton ("Return to Menu");
returnButton.addActionListener(this);
</code>```

Body:
New poster here; if I'm breaking any rules/screwing anything up, just tell me and I'll take the post down.

I have a MainMenu JFrame with a JPanel (mainMenu) inside it. mainMenu has one button that changes the display to the JTabbedPane Instructions. This part is working fine.

The problem comes in when I'm trying to add a button and new tab to Instructions. Although the new buttons and tab are added to the Instructions class, the button doesn't actually do anything despite having an ActionListener for that button.

Below are the Instructions class (extends JTabbedPane) and MainMenu (extends JFrame) for reference.

Thanks in advance.

Directly below: MainMenu class
`

/**
 * @Author Small Snake Studios (Nathan Lee)
 * @Date Feb 28, 2017
 * @Version 1.0
 * @Description This program is a JPanel for the Blockfinder Express game. Mostg of the work done this week has been in graphics rather than in coding this week.
 */

import javax.swing.*;
import java.awt.event.*;
import java.awt.FlowLayout;
import java.awt.event.ActionListener;
/**
 * This is a JPanel that represents the main menu of the program. Each of the buttons open up another JPanel in the main JFrame,
 * each JPanel representing a different screen. This JFrame is the main menu and you can open the other JPanels through this one.
 * Because it's a JFrame, it can hold and control the rest of the windows (splash screen, main menu, credits, the main game, instructions,
 * high scores and exit.
 **/

public class MainMenu extends JFrame implements ActionListener
{

    /**
     * This is a serialVersionUID. It is generated to avoid errors/warnings.
     */
    private static final long serialVersionUID = -3088890058631223710L;
    /*Name          use                                                                         type
     * splashScreen creates a splash screen that shows an animation                         SplashScreen
     * mainGame     a JPanel representing the main game                                     MainGame
     * instructions a JPanel representing the instructions screen                           Instructions
     * quit         a JPanel representing the quit screen                                   Quit
     * credits      a JPanel representing the credits screen                                Credits
     * mainMenu     a JPanel representing the main menu (built into the MainMenu class)     JPanel*/
    SplashScreen splashScreen = new SplashScreen ();
    JTabbedPane instructions = new Instructions ();
    JPanel credits = new Credits ();
    JPanel highScores = new HighScores ();
    JPanel mainMenu = new JPanel ();
    JMenuBar myMenus  = new JMenuBar ();
    JButton play = new JButton ("Play!");
    JButton howToPlay = new JButton ("Learn!");
    JButton leaderboards = new JButton ("Leaderboards!");
    JButton creds = new JButton ("Credits!");
    JMenu quitMenu = new JMenu ("Quit");
    JMenuItem quitMenuItem = new JMenuItem ("Quit");

    public MainMenu () //constructor
    {
        super ("Blockfinder Express"); //constructor adds all of these buttons to the JPanel
        init ();
    }

    public void actionPerformed (ActionEvent ae)
    {
        Frame f = null;
        if (ae.getActionCommand ().equals ("Play!"))
        {  if (f == null)
        {
            remove (mainMenu);
            f = new Frame ();
            repaint ();
        }
        }
        if (ae.getActionCommand ().equals("Quit"))
        {
            dispose ();
            f.dispose ();
        }
        if (ae.getActionCommand ().equals ("Return to Menu"))
        {
            System.out.println("returning to menu");
            remove (instructions);
            add (mainMenu);
            repaint ();
            revalidate ();
        }
        if (ae.getActionCommand ().equals ("Learn!"))
        {
            add (instructions);
            JPanel exit = new JPanel ();
            JButton returnButton = new JButton ("Return to Menu");
            exit.add(returnButton);
            instructions.add("Exit", exit);
            remove (mainMenu);
            repaint ();
            System.out.println ("Functional");
        }
    }
    public void init ()
    {
        play.addActionListener(this);
        howToPlay.addActionListener(this);
        leaderboards.addActionListener (this);
        creds.addActionListener (this);
        mainMenu.add (play);
        mainMenu.add (howToPlay);
        mainMenu.add(leaderboards);
        mainMenu.add(creds);
        myMenus.add(quitMenu);
        quitMenu.add(quitMenuItem);
        quitMenuItem.addActionListener(this);
        setJMenuBar (myMenus);
        setSize (1000,900);
        setResizable (false);
        setVisible (true);
        setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        add (splashScreen);
        splashScreen.animate ();
        remove (splashScreen);
        add (mainMenu);
        repaint ();
        revalidate ();
    }

    public static void main (String [] args)
    {
        MainMenu mm = new MainMenu ();
    }
}

`
Below: Instructions class

    /**
 * @author Nathan
 * @version 1.0
 * @studio Small Snake Studios
 * @purpose: This is a JPanel representing the instructions screen. It functions by using a picture
 * the instructions screen as the way to display it on the JPanel. The driver class/main menu
 * adds an exit button to the JPanel so I can implement an ActionListener that closes this
 * tab from there. Probably works better that way, too. Uses a CardLayout to go from one
 * instruction page to another, allowing for easy readability and preventing me from having
 * to cram a lot of info in one screen. The pages of the CardLayout are done via nested classes
 * so I can implement paint and graphics in each of them.
 *
 * Things to do:
 * - Add actual pictures for the three instructions screen
 * - Run this code with everything else to ensure it works
 */

import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;

import javax.swing.*;
import java.io.*;
import javax.imageio.ImageIO;

public class Instructions extends JTabbedPane{
        class FirstScreen extends JPanel
    {
        /**
             *
             */
        private static final long serialVersionUID = -2674891692847531892L;
        BufferedImage instructions;
        public FirstScreen ()
        {
            importInfo ();
            repaint ();
        }
        public void importInfo (){
        try
        {
            instructions = ImageIO.read (new File ("Instructions1.png"));
        }
        catch (IOException e)
        {
        }
        }
        public void paint (Graphics g)
        {
            g.drawImage (instructions, 0, 0, null);
        }
    }
        class SecondScreen extends JPanel
    {
        private static final long serialVersionUID = -2840353661877108337L;
        BufferedImage instructions;
        public SecondScreen ()
        {
            importInfo ();
            repaint ();
        }
        public void importInfo ()
        {
            try
            {
            instructions = ImageIO.read (new File ("Instructions2.png"));
            }
            catch (IOException e)
            {
            }
        }
        public void paint (Graphics g)
        {
            g.drawImage (instructions, 0, 0, null);
        }
    }
        class ThirdScreen extends JPanel
        {
        /**
             *
             */
        private static final long serialVersionUID = -394248748993045880L;
        BufferedImage instructions;
        public ThirdScreen ()
        {
            importInfo ();
            repaint ();
        }
        public void importInfo ()
        {
            try
            {
                instructions = ImageIO.read (new File ("Instructions3.png"));
            }
            catch (IOException e)
            {
            }
        }
        public void paint (Graphics g)
        {
            g.drawImage (instructions, 0, 0, null);
        }
        }
public Instructions ()
{
    super ();
    FirstScreen card1 = new FirstScreen ();
    SecondScreen card2 = new SecondScreen ();
    ThirdScreen card3 = new ThirdScreen ();
    add ("Page 1", card1);
    add ("Page 2", card2);
    add ("Page 3", card3);
}
}

Body:
The returnButton you are referring to has no actionListener attached. So just add it.

JButton returnButton = new JButton ("Return to Menu");
returnButton.addActionListener(this);


问:
Angular 2 - routing with path as parameter and BrowserSync
I've this on my code...

```<code>@RouteConfig([
{path: "/me", name: "Me", component: MeComponent, useAsDefault: true},
{path: "/me/edit", name: "EditProfile", component: EditProfileComponent},
{path: "/people/:group", name: "People", component: PeopleComponent}
])
</code>```

but in order to make something like /people/school I need to set the routes on the browserSync. My first attempt was a wildcard, like this:

```<code>browserSync.init({
   server: {
        baseDir: "./",
        routes: {
            "/me": "index.html",
            "/me/edit" : "index.html",
            "/people/*" : "index.html"
        }
    }
</code>```

It's not working. Any suggestion about how to configure browserSync to work with dynamic generated url paths ?

ty !

答:
You need to perform URL Rewrites, directing requests to your HTML 5 routes back to your index.html page.

var bsConfig = {
    "open": baseUrl,
    "server": {
        //...
    },
    middleware: function(req,res,next) {

        /*
            Re-write URL for each of our Angular routes, mapping them back to index.html (for single-page app, HTML5 routing)
        */
        switch (req.url) {
            //for all angular routes, re-rewrite to /index.html
            case baseUrl + '/customers' :
            case baseUrl + '/products' :
            case baseUrl + '/transactions' :

            req.url = '/index.html';

            default : {
                //for all other requests (e.g.: to static content such as .css files) don't make any URL re-writing.
                break;
            }

        }

        return next();
    }
};

browserSync.init(bsConfig);```

Credit to:
https://vinaygopinath.me/blog/tech/url-redirection-with-browsersync/

Body:
I've this on my code...

@RouteConfig([
{path: "/me", name: "Me", component: MeComponent, useAsDefault: true},
{path: "/me/edit", name: "EditProfile", component: EditProfileComponent},
{path: "/people/:group", name: "People", component: PeopleComponent}
])

but in order to make something like /people/school I need to set the routes on the browserSync. My first attempt was a wildcard, like this:

browserSync.init({
   server: {
        baseDir: "./",
        routes: {
            "/me": "index.html",
            "/me/edit" : "index.html",
            "/people/*" : "index.html"
        }
    }

It's not working. Any suggestion about how to configure browserSync to work with dynamic generated url paths ?

ty !

Body:
You need to perform URL Rewrites, directing requests to your HTML 5 routes back to your index.html page.

var bsConfig = {
    "open": baseUrl,
    "server": {
        //...
    },
    middleware: function(req,res,next) {

        /*
            Re-write URL for each of our Angular routes, mapping them back to index.html (for single-page app, HTML5 routing)
        */
        switch (req.url) {
            //for all angular routes, re-rewrite to /index.html
            case baseUrl + '/customers' :
            case baseUrl + '/products' :
            case baseUrl + '/transactions' :

            req.url = '/index.html';

            default : {
                //for all other requests (e.g.: to static content such as .css files) don't make any URL re-writing.
                break;
            }

        }

        return next();
    }
};

browserSync.init(bsConfig);

Credit to:
https://vinaygopinath.me/blog/tech/url-redirection-with-browsersync/


问:
Google App Engine - Datastore - Get an entity, not by it's key
I'm building an Android app, and I'm using Google App Engine to store user's data. I want users to be able to connect from other devices to their account, but I could not figure how.

The users table (kind) has 4 properties: id, email, nickname and level:

I have read this:
https://cloud.google.com/appengine/docs/standard/java/datastore/creating-entities

It's written their that I can only get entities by their key, and it's a problem for me, because in a new device, I can only get the user's email, not the key and Id. I need to get the key and id by their email.

Is this possible?
If it's not, is their any other solution?

答:
You just need to do a simple query.  What language are you using in the GAE backend?  For example, in Python, you would do something like:

```<code>def get_user_by_prop(prop, value):
    this_user = User.query(getattr(User, prop) == value).get()
    return this_user
</code>```

Judging from the link in your question, I assume you are using Java?  Here are the docs for a query:  https://cloud.google.com/appengine/docs/standard/java/datastore/retrieving-query-results

where they use the example:

```<code>Query q =
    new Query("User")
        .setFilter(new FilterPredicate("nickname", FilterOperator.EQUAL, "billybob"));

PreparedQuery pq = datastore.prepare(q);
Entity result = pq.asSingleEntity();
</code>```

Body:
You just need to do a simple query.  What language are you using in the GAE backend?  For example, in Python, you would do something like:

def get_user_by_prop(prop, value):
    this_user = User.query(getattr(User, prop) == value).get()
    return this_user

Judging from the link in your question, I assume you are using Java?  Here are the docs for a query:  https://cloud.google.com/appengine/docs/standard/java/datastore/retrieving-query-results

where they use the example:

Query q =
    new Query("User")
        .setFilter(new FilterPredicate("nickname", FilterOperator.EQUAL, "billybob"));

PreparedQuery pq = datastore.prepare(q);
Entity result = pq.asSingleEntity();


问:
How do I uninstall this buildpack in Heroku?
I installed heroku-buildpack-php-tyler on my Heroku app a few days ago, and it all seemed to work fine. I installed it by running the following command:

```<code>heroku config:set BUILDPACK_URL=git://github.com/iphoting/heroku-buildpack-php-tyler.git
</code>```

However I now want to remove it. I tried using the following command:

```<code>heroku config:unset BUILDPACK_URL=git://github.com/iphoting/heroku-buildpack-php-tyler.git
</code>```

But it returns the following error message:

Unsetting BUILDPACK_URL=git://github.com/iphoting/heroku-buildpack-php-tyler.git and restarting hnf-heroku... failed

!    Resource not found`

Because PHP isn't officially supported by Heroku, there's not much documentation about this. So how do I uninstall this buildpack?

答: Running heroku config:unset and heroku buildpacks:remove did not work for me. However, simply running heroku buildpacks:clear did restore everything to its default state. Then, on the next git push heroku, the appropriate buildpack is added on the fly.

Body:
I installed heroku-buildpack-php-tyler on my Heroku app a few days ago, and it all seemed to work fine. I installed it by running the following command:

heroku config:set BUILDPACK_URL=git://github.com/iphoting/heroku-buildpack-php-tyler.git

However I now want to remove it. I tried using the following command:

heroku config:unset BUILDPACK_URL=git://github.com/iphoting/heroku-buildpack-php-tyler.git

But it returns the following error message:

Unsetting BUILDPACK_URL=git://github.com/iphoting/heroku-buildpack-php-tyler.git and restarting hnf-heroku... failed

!    Resource not found`

Because PHP isn't officially supported by Heroku, there's not much documentation about this. So how do I uninstall this buildpack?


问:
Is WCF ready for real world?
As I read here http://arunatennakoon.blogspot.com/2010/11/things-i-learn-new-this-week.html

```<code>Friday, November 12, 2010
Things I learn new this week
1. Never ever use WCF.
---------------------

here is why
1. IIS 7 doesn't support .svc file format by default. So you need to
</code>```

install some extension files. so it's
  lot of work for a new product.

```<code>2. I found it very hard to configure security settings. when i
</code>```

tried to configure for the first time
  it threw all kind of errors.

```<code>3. After installing WCF in IIS, sometimes it's trowing an exception
</code>```

that refers to the temp directory. To
  solve this problem you have to re
  compile the application and
  re-distribute

```<code>and a lot more...
</code>```

So would you take the risk to use WCF ?

I'd like to hear about real world examples with hundred to billions of hit per year.

答:
Haven't had any problems deploying WCF projects so far. I'm building a very simple application with it (actually, the application isn't that simple but the Service layer is) and have deployed WCF to three environments (Development, Integration Tests and User Test) without any hassle.

I went with WCF because asmx can't deal with cyclic object graphs, whereas WCF can.

Title: Is WCF ready for real world?

Body:
As I read here http://arunatennakoon.blogspot.com/2010/11/things-i-learn-new-this-week.html

Friday, November 12, 2010
Things I learn new this week
1. Never ever use WCF.
---------------------

here is why
1. IIS 7 doesn't support .svc file format by default. So you need to

install some extension files. so it's
  lot of work for a new product.

2. I found it very hard to configure security settings. when i

tried to configure for the first time
  it threw all kind of errors.

3. After installing WCF in IIS, sometimes it's trowing an exception

that refers to the temp directory. To
  solve this problem you have to re
  compile the application and
  re-distribute

and a lot more...

So would you take the risk to use WCF ?

I'd like to hear about real world examples with hundred to billions of hit per year.