Is startkey pagination required for Mango queries in CouchDB 2.0

Question: I've been searching all over on this one. I'm running CouchDB 2.0 and understand I have a choice to make between using traditional views or the newer Mango query when retrieving a set of data.
So I'm currently using the Mango query syntax and getting the results I need - however I now need to implement pagination. When researching pagination in CouchDB 2.0 I found this excellent discussion around the topic:
http://docs.couchdb.org/en/2.0.0/couchapp/views/pagination.html
It suggests that the best way to paginate large data sets is not to use skip but instead to use startkey and perform a kind of linked list pagination from one page to the next.
So this makes sense to me and works for my application, but when I then turn to the Mango/_find API I can't see any way to pass in startkey:
http://docs.couchdb.org/en/2.0.0/api/database/find.html
Confusingly enough, it does accept a skip parameter, but there is no startkey.
Is anybody able to explain what is happening here? Are the performance characteristics much different in Mango/_find such that we can safely use skip on large data sets? Or should we be using views with startkey when traversing larger collections of data?
This particular question doesn't seem to get answered in any recent documentation AFAIK. Any help would be greatly appreciated.
Answer: You could perhaps work around the lack of startkey/endkey support by including a constraint in the selector:
"selector": {
    "_id": { "$gte": "myStartKey", "$lte": "myEndKey"}
}

(just my two cents; maybe somebody else has a more complete answer)
Answer: The CouchDB documented approach of pagination applies only to map-reduce/views kind of queries and cannot be applied to Mango queries. Primarily becos, for views, there is a single key field which is used for sorting, hence it's easy to skip previous doc by using that 'startkey' and in case of non-unique key by adding a startkey_docid.
For selector queries, to effectively skip previous records you will have to look at the sort keys specified in the original query and add another condition(s) to skip those docs which are already processed. For example, if you sorted (in asc) on a numeric field and processed till value = 10, then you could add a { "field" : { "$gte" : 10 } } as $and logic within original selector.  This becomes complicated if you have multiple sort fields. A skip/limit might be an easier approach to pagination for selector queries.


How to know a name of generated sprite with compass-rails?

Question: I am trying to find out how to know the name of the image which is generated using compass-rails.
Here what i`ve got in my .sass stylesheet:
<code>$asset-path: "/assets/"
@import "../images/icons/*.png"
@include all-icons-sprites
.icons-sprite,
.icons-doc,
.icons-enroll
  background: url('#{$asset-path}icons-s604efe6938.png') no-repeat
</code>
The image was called icons-s604efe6938.png when i used compass locally.
How to know how will it be called now on rails?
Answer: The folks at Compass can't think of a reason why a developer would need to know the filename of the generated sprite, as mentioned here. I can think of one: pre-loading the sprites with an img tag and capturing the onload event.
Seems like the best possible option is to hack Compass to keep it from generating the random string it appends at the end of the file. See here:
How to remove the hash from Compass's generated sprite image filenames?
Then you'll know the exact name of the generated sprite, which you can reference in your css urls or img src's.
Comment: also, you can query it on the Javascript side by creating a div with a class referring to the sprite and then look up the backgroundImage style using jQuery or CSS. Or you could look up the CSS rules directly without creating an element first.


Predictive performance depends more on expertise of data analyst than on method?

Question: I've come across a rumour that some study showed that the performance of predictive models depends more on the expertise of the data analyst with the chosen method than on the choice of the method.
In other words, the claim is that it is more important that the data analyst is familiar with the chosen method than how "appropriate" the method would seem for the problem from a more theoretical standpoint.
This was mentioned in the context of chemometrics, which involves typically problems of many variates (100s - 1000s), multiple collinearity, and of course, too few samples. Prediction may have been classification or regression.
My personal experience suggests that this is plausible, but a study was mentioned (I asked the person who mentioned that by email after a quick but unsuccessful search, but never received any answer). However, also with a more elaborate search, I was not able to track down any papers.
Is anyone aware of such findings? If not, what does the personal experience of Big Guys here say?
Comment: I'm more of a Little Guy around here, but what I have seen in Neural Networks supports this hypothesis: far from being an "out of the box" tool where "the machine learns" something, successful classification or prediction seems to depend *a lot* on how smart the person is that tells the network how to learn from the data - most importantly in terms of data preprocessing, but also in terms of network architecture etc.
Comment: I think that's figure 2.4 from [The Elements of Statistical Learning](http://www-stat.stanford.edu/~tibs/ElemStatLearn/) where they compare nearest neighbors with regession-type methods (and of course they provide multiple comparison points throughout the book, too).
Comment: @StasK: thanks for the reminder (shame on me for not remembering). They also report that in practice PCR, PLS and ridge regression are very similar, and LDA and logistic regression as well. However, the latter methods are also very similar from a theoretical point of view.
Answer: Actually, I have heard a rumor that decent learning machines are usually better than experts, because the human inclination is to minimize variance at the expense of bias (oversmooth), leading to poor predictive performance in new dataset. The machine is calibrated to minimize MSE, and thus tends to do better in terms of prediction in a new dataset.
Comment: In my experience it is certainly true that humans tend to overfit. However, in my experience you also need a decent expert who chooses the not-overfitting learning machine. Otherwise someone just chooses a learning machine that overfits.
Comment: MSE in general doesn't protect from overfitting unless you restrict the model very much - and there the expert comes in again. Nevertheless people try to optimize e.g. model hyperparameters. Particularly iterative optimization strategies overfit, (MSE or not), unless you can afford a completely new set of independent test data for each iteration. Maybe I should say that I come from a field where test cases are very rare. And, in any case you may argue that this a not a *decent* learning machine.


Mulesoft Http:Request - Receiving Error: HTTP packet header is too large

Question: I have a mule flow that uses the http:request and this flow is running multiple requests through it at the same time (synchronously). On only a few of the request I will receive the following error:
HTTP packet header is too large (java.lang.IllegalStateException)
The problem here is that the service I am sending the request to receives these like normal and then it blows up in mule so I don't get the correct response that I am looking for.
So in the other system it looks like the call was successful, but on my end it is a failure. I am fairly new to mule so go easy on me lol!
Any and all help would be greatly appreciated.
Answer: This is not a Mule error message. It looks like people report this issue with Grizzly.
I guess Mule sends a header that the server you're calling finds too big. I bet it's the serialized session. If you are using the http transport, this can be disabled like this:
<http:connector name="NoSessionConnector">
    <service-overrides sessionHandler="org.mule.session.NullSessionHandler"/>
</http:connector>

If you are using the new HTTP connector, well, someone else will have to tell you how to disable it...
EDIT: Adding comment from Anirban.
With the new HTTP connector, use:
<remove-property propertyName="MULE_SESSION" />

to remove the massive session header.
Comment: Hi @David, I guess with new HTTP, we can use `` or with **message-properties-transformer** like     `

` ...                                                     ref :- http://stackoverflow.com/questions/33041725/override-sessionhandler-using-httplistener-config  and http://stackoverflow.com/questions/35978104/was-there-a-way-to-remove-mule-session-on-mule-3-7-or-later
Comment: In that case, use a proxy to inspect the HTTP request from Mule and find what exactly is making the receiving end choke. My answer was based on a wild guess, at this point you have to do some forensics.
Comment: Thanks @AnirbanSenChowdhary
Comment: Thank you both for your responses. So I need to place this inside of the new HTTP connector?
Comment: @DavidDossot I tried placing both

and

before the http call and I am still receiving the error when running the project.
Comment: @DavidDossot I am fairly new to Mule can you give me any tips on how to do this and what to look for?
Comment: What I'm suggesting has nothing to do with Mule. Using your favorite proxy (like TCPDump) or packet inspector (like WireShark) should work. Then check each HTTP header for anything out of the ordinary.
Comment: Oh alright. I will give that a shot. Thanks @DavidDossot


How to build script structure like Value = ClassName.Value?

Question: I have a class which name is Color and another class that it's name is Object that have a property with type of Color.
I want to assign this property like this:
 Object.Color = Color.Red

How can I do that?
Comment: `Color.Red` is a static property ([source](https://referencesource.microsoft.com/#System.Drawing/commonui/System/Drawing/Color.cs,1073)).
Answer: Theres a few ways you can do that, i'd probably suggest an enum for Color instead of a class:
using System;
namespace YourNameSpace
{
    public class Example
    {
        public static Colors Color;
    }

    public enum Colors {
        Red,
        Blue
    }
}

In the above you would be able to set the static property Object.Colors as you have described:
Example.Color = Colors.Red;

Comment: Yes it's true but can you help me for write another line of code ?
I have another property in Object that it's name is stringColor . How can i tell to compile when user changed the Color property that stringColor changing too
for example if user write this code "object.color = color.red " the string automaticly changing to "#ff0000"
Comment: You could either switch to using String values instead of an enum:
public class Object
    {
        public static String Color;
    }

    public static class Colors {
        public const String Red = "#FF0000";
        public const String Blue = "#0000FF";//etc
    }
Comment: Or add in a getter code for the colorString property:
public static String ColorString {
         get
            {
                switch (Color) {
                    case Colors.Red:
                        return "#FF00000";
                    case Colors.Blue:
                        return "#0000FF";
                    default:
                        return "unknown color...";
                }
            }
        }


Some of the pending updates cannot be applied because their dependencies were not met

Question: I have a Drupal 7 site that is giving me the above error.  I cannot for the life of me, figure out what dependency needs to be met.  And I can't not remember what I did, or if I did anything, to cause it.
Is there any way to get more info than that?
Comment: Which modules are the pending updates to be applied to?
Comment: That's the problem.  I can't see that info anywhere.  I don't know.  Is there a way to find out?  The watchdog says nothing.
Answer: For those who end up here with the same issue on a Drupal 8 web site, I found that using drush's updb command will give information that the UI does not:
<code> drush updb
 [warning] The following module is missing from the file system: media_bulk_upload bootstrap.inc:276
 [warning] The following module is missing from the file system: media_upload bootstrap.inc:276

</code>
Comment: I have this issue on a D8.8.1 site and drush updb says only: success - no pending updates
Answer: This may help: http://drupal.org/node/915216
Others that are more module specific may be:

http://drupal.org/node/1190294
http://drupal.org/node/1111524


OOP and forward declaration of structure in C

Question: I am studying C language and have recently learned how to write the OOP using C. Most part of it was not hard that much to understand for me except the name of structures type used to create new class.
My textbook used struct dummy_t for forward declaration and typedef struct {...} dummy_t for its definition. In my understanding, these are two different type because the former is struct dummy type and the later is struct type without a name tag but the sample code from the textbook worked well.
So I deliberately modified the sample code so that the difference in the names of structures will be much clearer. Below are the lines of code I tried.
//class.h

struct test_a;
struct test_a * test_init(void);
void test_print(struct test_a*);

//class.c
#include <stdio.h>
#include <stdlib.h>

typedef struct dummy{
    int x;
    int y;
} test_b;

test_b * test_init(void){
    test_b * temp = (test_b *) malloc(sizeof(test_b));
    temp->x = 10;
    temp->y = 11;
    return temp;
}

void test_print(test_b* obj){
    printf("x: %d, y: %d\n", obj->x, obj->y);
}

//main.c
#include "class.h"

int main(void){
    struct test_a * obj;
    obj = test_init();
    test_print(obj);

    return 0;
}
// It printed "x: 10, y: 10"

As you can see, I used struct test_a for forward declaration and typedef struct dummy {...} test_b for definition.
I am wondering why I did not get the compile error and it worked.
Comment: You will get the desired compiler error if you `#include` in class.c, since the compiler can compare the function signatures and tell you that they conflict.
Comment: @0___________ This is a well-known way to achieve private encapsulation in C. How is private encapsulation not OOP? OO is a way to _design_ programs, not a way to write them...
Comment: @0___________ I don't believe it is possible to simulate program design. Either you have a program design or you don't, regardless of language.
Comment: The code you have should generate a compiler warning that you are passing the wrong type to `test_print`, so perhaps you need to turn up the compiler diagnostics.
Comment: It's called undefined behavior... which includes the "appear to work" case.
Comment: ***`ow to write the OOP`*** it is not OOP. If you want OOP learn C++
Comment: I'd recommend to do `typedef struct test_a test_a;` in the header and then define the struct simply as `struct test_a { ... };`. The caller shouldn't know or care if the opaque object is a struct or not.
Comment: @Lundin I know what it is for. But I do not know why simply do not write it in C++.  Linux kernel I understand as Linus hates C++ so developers do not have any choice :)
Comment: In general, it goes like this: 1. forward declare in the interface header file (class.h in this case) 2. declare & implement in the implementation module (class.c in this case) 3. include the interface header (class.h) in all modules needing access to your class.
Comment: @0___________ Which is kind of like saying "hey why did you shoot yourself in the foot when you could have blown your whole leg off instead".
Comment: @Lundin Agreed. Simulating OOP in C is definitely like blowing the whole leg off.
Comment: @Lundin OK lets call it prothesis (as one has blown its legs off already)
Answer: It 'worked' because you did not include class.h in class.c. So the compiler can't see the implementation does not match the declaration.
The proper way is (but without the typedef for clarity):
// class.h
struct test_a;
struct test_a* test_init(void);

//class.c
#include "class.h"
struct test_a {
    int x;
    int y;
};

struct test_a* test_init(void)
{
   ...
}

The struct test_a in the header file makes the name test_a known to the compiler as being a struct. But as it does not now what is in the struct you can only use pointers to such a struct.
The members are defined in the implementation file and can only be used there.
If you want to use a typedef:
// header
typedef struct test_a_struct test_a;
test_a* test_init(void);

//implementation
struct test_a_struct {
    int x;
    int y;
};
test_a* test_init(void)
{
    ...
}

Answer:
I am wondering why I did not get the compile error

When you compile main.c the compiler is told via a forward declaration from class.h that there is a function with the signature struct test_a * test_init(void);
The compiler can't do anything other than just trusting that, i.e. no errors, no warnings can be issued.
When you compile class.c there is no forward declaration but only the function definition, i.e. no errors, no warnings.
It's always a good idea to include the .h file into the corresponding .c file. Had you had a #include "class.h" in class.c the compiler would have been able to detect the mismatch.

..and it worked

What happens is:

A pointer to test_b is assigned to a pointer to test_a variable

The variable is then passed as argument to a function expecting a pointer to test_b

So once you use the pointer it is used as it was created (i.e. as pointer to test_b). In between you just stored in a variable of another pointer type.
Is that ok? No
Storing a pointer to one type in a object defined for another pointer type is not ok. It's undefined behavior. In this case it "just happened to work". In real life it will "just happen to work" on most systems because most systems use the same pointer layout for all types. But according to the C standard it's undefined behavior.


Is there other way I can choose not to sort x-label

Question: I know one way to not sort the x-label is using set_xticklabels, but I am wondering if there is another method to solve the problem. I mean, how can I not sort the x-label except using set_xticklabels?
    import pandas as pd
    import numpy as np
    import matplotlib.pyplot as plt
    import random
    url="https://archive.ics.uci.edu/ml/machine-learning-databases/adult/adult.data"
    df = pd.read_csv(url,header=None,names=['age', 'workclass', 'fnlwgt', 'education', 'education-num', 'marital-status', 'occupation', 'relationship', 'race', 'sex', 'capital-gain', 'capital-loss', 'hours-per-week','native-country', 'result'])

    fnlwgt=[0,0,0,0,0,0,0,0,0]

    for i in range(len(df)):
        if df.iloc[i,2]<=50000:
            fnlwgt[0]+=1
        elif df.iloc[i,2]<=100000:
            fnlwgt[1]+=1
        elif df.iloc[i,2]<=150000:
            fnlwgt[2]+=1
        elif df.iloc[i,2]<=200000:
            fnlwgt[3]+=1
        elif df.iloc[i,2]<=250000:
            fnlwgt[4]+=1
        elif df.iloc[i,2]<=300000:
            fnlwgt[5]+=1
        elif df.iloc[i,2]<=350000:
            fnlwgt[6]+=1
        elif df.iloc[i,2]<=400000:
            fnlwgt[7]+=1
        else:
            fnlwgt[8]+=1

    xs=['0~50k','50k~100k','100k~150k','150k~200k','200k~250k','250k~300k','300k~350k','350k~400k','400k~450k']

    plt.bar(xs,fnlwgt)
    plt.show()

Second question, When I use set_xticklabels, the figure showed a weird ratio. How can I solve it?

I just change
    plt.bar(xs,fnlwgt)
    plt.show()

to
    fig = plt.figure()
    ax1 = fig.add_subplot(131)
    ax1.bar(xs, fnlwgt)
    ax1.set_xticklabels(xs)
    plt.show()

No matter I zoomed in or opened to full screen, the figure still remained the same ratio. I know I can set the orientation but I just want to see whether I can get the same result without setting orientation.
Comment: Sorry, while you may have a valid question, this is not at all understandable. What exactly is the problem? What is the question?
Comment: @ImportanceOfBeingErnest This is my first result: https://imgur.com/HhkK3AA.jpg  and I want  `50k~100k` be the second x-label, not the last x-label.
Comment: Can you please [edit] the question, such that it becomes clear?
Comment: @ImportanceOfBeingErnest I just edited the questions and the second question has got the answer. Thanks for your comment and sorry that the questions were not clear.
Answer: You can change set the aspect ratio by changing the figure size. For example,
fig = plt.figure(figsize=(12, 5))

ax1 = fig.add_subplot(131)
ax1.bar(xs, fnlwgt)
ax1.set_xticklabels(xs)
plt.show()

However, the aspect ratio is probably caused by the fact that you are creating 3 subplots (ax1 = fig.add_subplot(131)) and only use one of the 3.
Comment: Thank you, you are right. I set the wrong parameter.
Answer: Are you trying to make the tick labels readable by changing the aspect ratio of the figure itself or by moving the tick labels themselves? The aspect ratio can be configured to make the labels more readable by:
graph = plt.figure(figsize=(x, y))

While you can simply configure the positioning of the labels themselves by rotation or a number of other methods:
plt.xticklabels(rotation=90)


PubSub acknowledge deadline

Question: I have a cloud function which publishes a message to PubSub and that triggers a cloud run to perform an archive file process. When there are large files, my cloud run python code takes some time to process the data it looks like PubSub is retrying the message after 20 seconds (default acknowledge deadline time) which is triggering another instance from my Cloud Run. I've increased the acknowledge deadline to 600s and redeployed everything but it's still retrying the message after 20 seconds. I am missing anything?
Cloud Function publishing the message code:
<code># Publishes a message
   try:
      publish_future = publisher.publish(topic_path, data=message_bytes)
      publish_future.result()  # Verify the publish succeeded
      return 'Message published.'
   except Exception as e:
      print(e)
      return (e, 500)
</code>
Here is the PubSub subscription config:

Logging showing a second instance being triggered after 20s:

Cloud Run code:
<code>@app.route("/", methods=["POST"])
def index():
    envelope = request.get_json()
    if not envelope:
        msg = "no Pub/Sub message received"
        print(f"error: {msg}")
        return f"Bad Request: {msg}", 400

    if not isinstance(envelope, dict) or "message" not in envelope:
        msg = "invalid Pub/Sub message format"
        print(f"error: {msg}")
        return f"Bad Request: {msg}", 400

    pubsub_message = envelope["message"]

    if isinstance(pubsub_message, dict) and "data" in pubsub_message:
        #Decode base64 event['data']
        event_data = base64.b64decode(pubsub_message['data']).decode('utf-8')
        message = json.loads(event_data)

        #logic to process data/archive
        return ("", 204)

</code>
Comment: Can you share how do you handle the PubSub message in Cloud Run?
Comment: Hi @guillaume, I've edited my main post. It's a very basic Flask app which will take the request and return 204 once done (same example as Google docs). Thank you!
Comment: Are you sure that comme from your PubSub push subscription? Do you have several subscription that send message to your Cloud Run service? Can you also try to purge the subscription and try again with new messages? And are you sure that is the same message?
Comment: Yes, it's coming from pubsub but pull subscription. I printed the request from variable request.get_json() and I saw the message coming in twice (same messageId). one thing though, I just changed the retry policy to have 60s min backoff and I no longer see the duplicated message but it might happen if it takes more than 60s.
Comment: You talk about pull but your screenshot is a push subscription. You lost me!!
Comment: my bad lol, I meant to say push not pull
Answer: You should be able to control the retries by setting the minimumBackoff retrypolicy. You can set the minimumBackoff time to the max of 600 seconds, like your ack deadline, so that redelivered messages will be more than 600 seconds old. This should lower the number of occurrences you see.
To handle duplicates, making your subscriber idempotent is recommended. You need to apply some kind of code check to see if the messageId was processed before.
You can find below in the documentation at-least-once-delivery :
Typically, Pub/Sub delivers each message once and in the order in which it was published. However, messages may sometimes be delivered out of order or more than once. In general, accommodating more-than-once delivery requires your subscriber to be idempotent when processing messages. You can achieve exactly once processing of Pub/Sub message streams using the Apache Beam programming model. The Apache Beam I/O connectors let you interact with Cloud Dataflow via controlled sources and sinks. You can use the Apache Beam PubSubIO connector (for Java and Python) to read from Cloud Pub/Sub. You can also achieve ordered processing with Cloud Dataflow by using the standard sorting APIs of the service. Alternatively, to achieve ordering, the publisher of the topic to which you subscribe can include a sequence token in the message.

PubSub acknowledge deadline


Ellipse Contour Integral

Question: I'm having trouble with the following complex contour integral:
$$g(w) = \int \frac{z e^{z^3}}{(z-w)^3} dz$$
where $C$ is a positively oriented ellipse
$$\frac{x^2}{9} + \frac{y^2}{4} = 1$$
Find $g(2+3i)$ in the form $a +bi$
I know that $z(t) = 3\cos(t)+2i\sin(t)$. However, when I substitute this in (along with the $z '(t)$) the integral becomes a mess. Is there a quicker way to do this problem?
Comment: Your edit is correct. Thank you!
Answer: One result of the Cauchy integral formula is that for each $n$, the $n$th derivative is given by
$$f^{(n)}(w) = \frac{n!}{2\pi i} \int_C \frac{f(z)}{(z - w)^{n + 1}} \, dz$$
where $C$ is a circular contour around $w$, and there are some conditions on where $f$ is holomorphic. Now, two things to consider:

Does a careful choice of $f$ satisfy the theorem?
Does it matter that the contour is an ellipse, and not a circle?

The answers are yes and no, respectively.
Comment: I'm sorry, I don't quite understand how I can find f that will satisfy the theorem. I assumed to solve the problem I could just parameterize my z and simply substitute f(z(t)) z '(t) dt into the integrand.
Comment: @user299020 To find $f$, you should just match pieces: The denominator in your problem looks like the denominator in my answer with a choice of $n$, and the numerator in your problem looks like the numerator in my answer if $f$ is chosen to be ____
Comment: This would just give the second derivative of g(w) though when I'm looking for g(2+3i)? Would it not? I apologize if I'm not exactly following along.
Comment: @user299020 The point is that if you choose $f$ correctly, then $g$ is the second derivative of $f$.
Comment: Well that would make the problem far easier. Assuming I am following you correctly.  If I let f(z) = z exp(z^3) and solve for f '' (z) I get g (w)? g would be independent of w then would it not?
Comment: @user299020 Yes, that is the correct choice of $f$ (up to a multiplication by some factor involving $\pi i$). Then $f''(z) = g(z)$.
Comment: So for g(2+3i) you would substitute the 2+3i in for each z? Not any w's (as there are none)?
Comment: @user299020 The letter used as the variable doesn't matter; the point is that the second derivative of $f$ is $g$.

Ellipse Contour Integral


Postfix error "Sender address rejected"

Question: My company is using Oempro to send out some emails to our clients.  It looks like when we try to send emails to a large number of people, Oempro sets Mail From to be something like: bounce-[some number here]@mydomain.com.  I believe that that number is based on the mailing list that we are sending our emails to.  This allows Oempro to see which emails in which list are not valid.
The problem is that my postfix looks to verify that the sender actually has a mail account.  I've checked some files and config but I am really confused.  Is there someway to add a regular expression that tells postfix to allow things like email@example.com to go through?  I looked at the /etc/postfix/access file but didn't really understand how to use it with regular expressions.  Is this where I should be looking?  Thanks!
Answer: From the Postfix documentation, it appears you need to modify this section in your main.cf file:
http://www.postfix.org/ADDRESS_VERIFICATION_README.html
/etc/postfix/main.cf:
    smtpd_sender_restrictions =
        permit_mynetworks
        ...
        check_sender_access hash:/etc/postfix/sender_access
        reject_unknown_sender_domain
        warn_if_reject reject_unverified_sender
        ...
    # Postfix 2.6 and later.
    # unverified_sender_reject_reason = Address verification failed

    # Default setting for Postfix 2.7 and later.
    # Note 1: Be sure to read the "Caching" section below!
    # Note 2: Avoid hash files here. Use btree instead.
    address_verify_map = btree:/var/lib/postfix/verify

This will put warning messages in your logs when a sender fails verification, but it won't reject it. You can remove the warn_if_reject line if you don't want to pollute your log files.
UPDATE:
If you want regular expressions, you'll need to compile PCRE support into Postfix (if it's not there already):
http://www.postfix.org/PCRE_README.html
Then, you can simply replace the line check_sender_access hash:/etc/postfix/sender_access with: check_sender_access pcre:/etc/postfix/sender_access and it will check for regex's in that file. If you're using Debian/Ubuntu, there's a package called postfix-pcre that will install support for PCRE.
http://www.postfix.org/pcre_table.5.html

Postfix error "Sender address rejected"


Specific property of kernel of a homomorphism

Question: Let $\mu$ be a homomorphism and $\alpha$ an endomorphism with appropriate domains and codomains.
Suppose $\alpha (\ker \mu) \subseteq \ker \mu$. Why does this imply that there is some endomorphism $\beta$ such that $\beta \circ \mu = \mu \circ \alpha$?
This seems like something involving the universal property of the kernel.
Comment: What's the context? Groups, modules, algebras?
Answer: By the given inclusion, $\mu\circ\alpha$ is $0$ on $\ker\mu$, i.e., $\ker\mu\subseteq \ker(\mu\circ\alpha)$. Hence $\mu\circ\alpha$ factors over $\mu$.


App saving multiple images into gallery

Question: I want to use a Button in my app to enable users to click and store multiple pictures.
Once clicked, the picture is saved into a folder inside the phone Gallery.
How can I store multiple images and specify a path in the Gallery?
Answer: you can use following code if you are fecthing images with url from web-
<code>class DownloadFile extends AsyncTask<String,Integer,Long> {
ProgressDialog mProgressDialog = new ProgressDialog(MainActivity.this);// Change Mainactivity.this with your activity name.
String strFolderName;
@Override
protected void onPreExecute() {
    super.onPreExecute();
    mProgressDialog.setMessage("Downloading");
    mProgressDialog.setIndeterminate(false);
    mProgressDialog.setMax(100);
    mProgressDialog.setCancelable(true);
    mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    mProgressDialog.show();
}
@Override
protected Long doInBackground(String... aurl) {
    int count;
    try {
        URL url = new URL((String) aurl[0]);
        URLConnection conexion = url.openConnection();
        conexion.connect();
        String targetFileName="Name"+".rar";//Change name and subname
        int lenghtOfFile = conexion.getContentLength();
        String PATH = Environment.getExternalStorageDirectory()+ "/"+downloadFolder+"/";
        File folder = new File(PATH);
        if(!folder.exists()){
            folder.mkdir();//If there is no folder it will be created.
        }
        InputStream input = new BufferedInputStream(url.openStream());
        OutputStream output = new FileOutputStream(PATH+targetFileName);
        byte data[] = new byte[1024];
        long total = 0;
        while ((count = input.read(data)) != -1) {
            total += count;
                   publishProgress ((int)(total*100/lenghtOfFile));
            output.write(data, 0, count);
        }
        output.flush();
        output.close();
        input.close();
    } catch (Exception e) {}
    return null;
}
protected void onProgressUpdate(Integer... progress) {
     mProgressDialog.setProgress(progress[0]);
     if(mProgressDialog.getProgress()==mProgressDialog.getMax()){
        mProgressDialog.dismiss();
        Toast.makeText(fa, "File Downloaded", Toast.LENGTH_SHORT).show();
     }
}
protected void onPostExecute(String result) {
}
</code>
}
now in your manifest add the following permissions-
<code>     <uses-permission android:name="android.permission.INTERNET"> </uses- permission>
  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
 <uses-permission android:name="android.permission.READ_PHONE_STATE"></uses-permission>
</code>
for Reference follow this link

App saving multiple images into gallery


Sitecore Navigation Start Point

Question: I was wondering if there is a way to set an item as the "navigational starting" point as far as the left-hand nav is concerned.
http://internal.simmons.edu/students/slis
On this page, there is a section for our School of Library and Information Science and the subitems that fall within it. As you can see in the nav, this SLIS section is a subsection to a main "Students" section.
Without moving the SLIS item in tree, is there a way to tell sitecore to set this page/item as the navigation starting point? Basically, I'd like the left-nav to have the "STUDENTS" nav header be replaced with the "Simmons Library and Information Science" and the nav to be only the SLIS navigation.
Is there a built-in setting that allows this (again without moving it in the tree or changing the URL)?
Thanks!
-mike
Comment: As with most things in Sitecore there is a way to achieve what you want. Do you have any code to share? It all depends on how the breadcrumb is being rendered.
Comment: Does the control rendering the nav accept a datasource or is it setup to render down from the homepage?
Comment: As graham says, post up some code, depending on how it's written it could be a fairly small change.
Comment: Thanks all. This all sounds way out of my league haha - but we will be working with some folks that should be able to help us out. Thanks again!
Answer: There is no "built-in" functionality for the end website in Sitecore. Anything you see on your website is either custom code, an installed module, or a development accelerator. As such, you can achieve your desired goals by making changes to the definition or logic of the sublayout that renders your navigation.
Likely, you will need to find the ASCX code behind (or XSL rendering, or CSHTML rendering) that handles the navigation output and make the necessary code changes to alter where it considers the 'root' of the tree.
Depending on the requirements, you may need to consider changing the sublayout to be driven by a datasource, and not the current page. This would allow authors to change on any given page the 'root' of the menu. This is recommended if you want to have different root behaviour in different pages, since you cannot write a single algorithm in the code to work everywhere. In that scenario, you would change the code to load the datasource item and use it as the root instead of the current item it is using.

Sitecore Navigation Start Point


O que é motor de template?

Question: A pouco, fiquei sabendo sobre o motor de template em PHP. Por alto, eu entendi o que é, mas tenho dúvidas.
• É uma "linguagem de programação?" Coloquei entre aspas pôs li isso em um site:

Propósito
A princípio, uma linguagem ou motor de templates é usado para, entre
  outras coisas, agilizar o trabalho de quem vai fazer a parte visual de
  um projeto Web.

• O que realmente é um motor de template? Pra que serve? É o que está escrito na citação acima ou é outra coisa?
• Pode ser criado em outras linguagens ou só em PHP?
Poderiam dar exemplos, se possível de como criar um em PHP? Pois não tenho ideia de como fazer.
Comment: Template engine se aplica a qualquer linguagem. Ele utiliza recursos da linguagem logo chamar de linguagem de programção é meio forte o mais adequado seria "uma notação simplificada/melhorada". [Nessa pergunta](https://pt.stackoverflow.com/q/12661/91) tem um exemplo bem basico de template engine e outras considerações.
Answer: Não gosto da palavra motor para engine neste contexto, prefiro mecanismo.
O PHP já é um mecanismo de gabarito (já que é pra traduzir). Ele pega um texto que em tese é um HTML e permite inserir algumas coisas externas que serão definidas no momento da sua execução.
Por isso é um pouco estranho ter outros mecanismos para uso com PHP. Tá, até entendo que as pessoas queriam algo mais flexível e principalmente com sintaxe mais fácil.
O template engine é o software que pega um texto e faz a substituição de partes deste texto por alguma informação a ser definida, seja por um código, seja por um padrão que será determinado por alguma regra fixa.
Em geral eles operam com base em uma convenção de que um determinado caractere ou sequência de caracteres especifica que ali não é um texto e sim é algo que deverá obter um resultado que será inserido no texto.
A forma de operar de cada um é algo que ele define.
É possível que ele carregue uma linguagem de programação nele, mas ele não é a linguagem de programação.
A função deste mecanismo é dar facilidade de escrever um texto da forma mais ou menos natural como uma pessoa faria e permitir a personalização de trechos dele.
A alternativa é ter que programar tudo e usar o texto como literais string no código, que não é ruim para um programador, mas pode ser trágico para uma pessoa que tenha outra função, como um designer ou mesmo outro usuário mais leigo, até porque esses mecanismo podem ser usados em diversos contextos.
Até no Word da Microsoft ou outros fornecedores possui um mecanismo de gabarito que interpreta o texto e pode preencher as lacunas deixadas no texto, o que curiosamente quase ninguém sabe da existência disto, muitas vezes reinventado a roda em suas aplicações.
Então não é que pode ser usado em outras linguagens, pode ser usado em qualquer coisa que exija que um texto seja gerado com base fixa mas que tenha lacunas a serem preenchidas dinamicamente.
Na verdade nem precisa ser texto, mas ele é bem mais comum e mais simples de realizar.
Para web pode facilitar a criação de páginas por tornar o fluxo mais próximo de como se faria se a página não tivesse conteúdo dinâmico.
Como criar um mecanismo é algo muito amplo, embora um bem simples pode ser feito até com Regex. Basta dizer o padrão que encontrará no texto que é o que deve ser substituído, pegar o conteúdo que está ali dentro, interpretar, no caso mais simples pode ser só um if, switch ou um array associativos* com palavras-chave que devem ser substituídas.
$template=file_get_contents('template.php');
$re = "/%(\\w*?)%/";
$subst = "<?php $1(); ?>";
$result = preg_replace($re, $subst, $template);
file_put_contents('template.php',$result);

Exemplo retirado dessa resposta no SO.
Coloquei no GitHub para referência futura.
Tem outra pergunta lá com um outro exemplo.
Comment: Só a primeira frase já vale +1

O que é motor de template?


"Juntar" elementos de um único vetor

Question: Eu tenho um vetor com quatro elementos que são números representados em forma hexadecimal.
O que eu preciso fazer é concatenar esses quatro elementos (creio que essa não seja a palavra certa, mas não encontrei outra melhor)?
Por exemplo:
int v[4]={0xA, 0xBB, 0x4B, 0x18};

Eu preciso de um resultado que seja semelhante a:
int resultado=0xABB4B18;

Answer: Tem uma forma só para imprimir e outra que realmente calcula corretamente e imprime:
#include <stdio.h>

int main(void) {
    int v[4] = {0x0A, 0xBB, 0x4B, 0x18};
    for (int i = 0; i < 4; i++) printf("%02X", v[i]);
}

Veja funcionando no ideone. E no repl.it. Também coloquei no GitHub para referência futura.
#include <stdio.h>

int main(void) {
    int v[4] = {0x0A, 0xBB, 0x4B, 0x18};
    int resultado = 0;
    for (int i = 0; i < 4; i++) {
        resultado *= 256;
        resultado += v[i];
    }
    printf("%08X", resultado);
}

Veja funcionando no ideone. E no repl.it. Também coloquei no GitHub para referência futura.
Comment: O primeiro `printf` devia ter preenchimento com zeros (pelo menos para os bytes a partir do segundo): `printf(i?"%02X":"%X", v[i]);`
Comment: @pmg de fato ambos poderia ter esta formatação, está feito.
Answer: Bom, se você multiplicar um número em HEXA por 100 em HEXA, você "desloca" pra direita.
Por exemplo:

em DECIMAL ->  13 * 100 = 1300
  em HEXADEC -> 0x13 * 0x100 = 0x1300

Tente aplicar este conceito para "concatenar" os valores em HEXA.
Outro exemplo:

Se A = 0xE3, B = 0x4C, então A*0x100 + B = 0xE34C.

"Juntar" elementos de um único vetor


Knex.js SQL syntax error near 'select'

Question: I'm getting an odd error:
<code>{ __cid: '__cid9',
  method: 'insert',
  options: undefined,
  bindings:
   [ 500,
     'Dinner',
     '10/02/2015 7:57 PM',
     '09/29/2015 8:00 PM',
     'Grand Plaza',
     1 ],
  sql: 'insert into "expense" ("amount", "description", "due_date", "payment_date", "vendor_id") values ($1, $2, $3, $4, select "vendor_id" from "vendor" where "name" = $5 limit $6)',
  returning: undefined }
error: syntax error at or near "select"
at [object Object].Connection.parseE (/.../node_modules/pg/lib/connection.js:534:11)
  at [object Object].Connection.parseMessage (/.../node_modules/pg/lib/connection.js:361:17)
  at Socket.<anonymous> (/.../node_modules/pg/lib/connection.js:105:22)
  at Socket.emit (events.js:107:17)
  at readableAddChunk (_stream_readable.js:163:16)
  at Socket.Readable.push (_stream_readable.js:126:10)
  at TCP.onread (net.js:538:20)
</code>
I have run the raw SQL with those value cut and paste and it works just fine.
This is the code thats generating the error:
<code>Promise.each subbudget.expenses, (expense) ->
    vendor.get(expense.vendor).then (vendor_id) ->
        knex('expense').insert(
            due_date: expense.dueDate
            vendor_id: (knex.first("vendor_id").from("vendor").where({name: vendor_id}))
            amount: expense.amount
            description: expense.description
            payment_date: expense.paidDate
        )
</code>
Edit (Partial Solution):
The issue seems to be parentheses missing around the SELECT statement. Knex offers .wrap(), which only works on raw, and .as(), which only works on nested statements; for some reason this does not qualify as a nested statement, so I can't get parentheses around it.  Any ideas?
Answer: knex.raw("(" + knex.first("vendor_id").from("vendor").where({name: vendor_id}).toString() + ")")
Not the cleanest, but use .toString(), then wrap it in .raw()

Knex.js SQL syntax error near 'select'


Resource for an explanation of Sample size calculation when $\alpha$, Power and Effect Size for t-Test are given

Question: For a simple z-Test or t-Test (one-sample or two-independent-sample with $n_1 = n_2$ and equal variance) I want to calculate the required sample size $n$ when the significance level $\alpha$, power and effect size are given.
Can someone point me to a resource where this is explained (not only software or a table with given values)? This would be very much appreciated, thank you!
Answer: In addition to significance level $\alpha$ and target power, you will need an estimated population standard deviation, and an 'effect size' (difference between null and alternative values of $\mu).$
Many statistical software packages have 'power and sample size' procedures (e.g., R and Minitab, for sure). And there are on-line 'sample size calculators' of various degrees of trustworthyness.
Here is output from Minitab, for which I provided $\alpha, \sigma,$and target powers .8 and .9:
Power and Sample Size
<code>2-Sample t Test

Testing mean 1 = mean 2 (versus ≠)
Calculating power for mean 1 = mean 2 + difference
α = 0.05  Assumed standard deviation = 4.5

            Sample  Target
Difference    Size   Power  Actual Power
         5      14     0.8      0.807761
         5      19     0.9      0.914970

The sample size is for each group.
</code>

Notes: Power of a t test requires computing probabilities and quantiles  of non-central t distributions. Power for z tests can be found using printed standard normal tables; sonm intermediate-level applied statistics books have formulas (Ott & Longnecker, for sure), otherwise you can use the definition of power,
;


Managing Active Directory Group Membership with a Non-Administrator Account In Server 2008

Question: I am running Server 2008 R2 in an Active Directory Domain Environment.
I have created a group in Active Directory and I have delegated management authority to that group to a user.
I want this user to be able to add and remove accounts as needed from that group so that they are exercising some measurement of control without giving them other authority.
When I have the user attempt to access the Active Directory Users & Computers Console it prompts them for Administrator credentials. They are using Remote Desktop to access the server, because they do not have Windows 7, and firewall rules prevent using the Remote Management Kit.
I do not want to provide them with any level of Administrative rights except the minimum required for them to add/remove users from this group.
There are two servers that 'talk' to each other in this isolated environment, a domain controller and a member server, both are only reachable through RDP.
Any suggestions?
Answer: Per the comments on this question, have you tried perhaps adding the user to the "Power Users" group?
Also, what happens if they just say "No" at the UAC prompt? I would expect that the MMC opens properly still; is that not the case? If it opens still, you could use TweakUAC to disable the prompt.
My guess is that running ADUC is twigging a built-in automatic privilege elevation rule, either from that snap-in or from mmc.exe as a whole. If neither of the above suggestions works, I'd try variations on running the tool: running the snap-in .msc file directly, copying the .msc somewhere and then running that, etc.
Answer: Thank you for the above suggestions, this is how I ended up solving the problem.
In order to even open the Active Directory Users and Computers MMC console in Windows Server 2008 R2 the user needs at minimum to be part of the 'account operators' permissions group.
So, I placed the user in a group and placed that group in the account operators group. This allowed him to open the console.
In order to restrict him to only manipulate the one group that I needed I went in and specifically added the 'Deny-Read' permission to every other OU in the domain to the group the user resides in. So when the user opens the ADU&C console, the only thing he sees is the one OU and the one Group that he actually has management control over.
Not exactly the most elegent solution, but it worked.
Answer: You could add the managedby property to a security group, the user account who is that has the permissions to add/remove users from that certain group.
Answer: Add the user in Allow logon locally in Default domain controller policy.
Group Policy Management --> Default Domain Controller policy
Edit
Computer Configuration/Policies/Windows Settings/Security Settings/Local Policies/User Rights Assignment/Allow Logon locally
After doing gpupdate in command prompt, Login in DC with that user account and give the user credentials.
Now your requirement will be fulfilled.


Ajax AutoCompleteExtender to fire C# event

Question: I would like my AutoCompleteExtender selection to fire an event in code behind. I've fired onClick events from javascript code before, but that seems like extra steps in this case.
Ultimately when the user selects a name from the AutoCompleteExtender list, I want to take the ID associated with that name, call a service to get more data, then add to a GridView on the page. What I have so far...
<ajaxToolkit:AutoCompleteExtender ID="StudentNameSearchTextBox_AutoCompleteExtender" runat="server"
    TargetControlID="StudentNameSearchTextBox"
    ServicePath="~/Scripts/AutoComplete.asmx"
    ServiceMethod="GetStudents"
    OnClientItemSelected="onStudentSelected"
    MinimumPrefixLength="2"
    CompletionSetCount="30"
    UseContextKey="True"
    CompletionListCssClass="autocomplete_completionListElement"
    CompletionListHighlightedItemCssClass="autocomplete_highlightedListItem"
    CompletionListItemCssClass="autocomplete_listItem" >
</ajaxToolkit:AutoCompleteExtender>

The javascript:

Code behind:
    protected void SingleStudentSelected(object sender, EventArgs e)
    {
        ///TODO: get data from service and add to grid
    }

Can I do this directly, or do I need to have a hidden button or textbox to fire an OnChange event? I would like to accomplish this the cleanest way possible.
Thanks.
Update-
This is the target textbox--
<asp:TextBox ID="StudentNameSearchTextBox" runat="server"
    CssClass="StudentNameSearch" OnTextChanged="StudentNameSearchTextBox_TextChanged"
    ViewStateMode="Inherit"></asp:TextBox>

Added this to the javascript:
    __doPostBack(sender.get_element().name, selectedStudent);

And this is the event:
    protected void StudentNameSearchTextBox_TextChanged(object sender, EventArgs e)
    {
        ///TODO: get data from service and add to grid
    }

So, I need a hidden field to hold the selectedStudent (VALUE of the selected item) so I can use it in the StudentNameSearchTextBox_TextChanged event?
Answer: In my opinion the cleanest way is to save selected value to HiddenField's value, fire PostBack from hidden button and do all staff in button's click event handler.
Comment: Funny, I was just looking at your post here: http://stackoverflow.com/questions/12838552/detect-autocompleteextender-select-event  it is very close, -- I'll edit my question to show what I did.
Comment: Solution, suggested in that post will hit server even if user enter any text into target textbox, doesn't select any option and then do submit form to server (e.g. click on any Button).
Comment: In your case you need to handle not just text of target textbox but only value selected from suggestions list. So in my opinion, TextChanged event of textbox not very well option in this situation.
Comment: I see what you mean. Button it is then. Thank you.


When does hook_menu run?

Question: I need to edit the hook_menu function in my  module.  I need to add a new link to a menu, and edit the path for an existing link.  Is this possible without creating a whole new module?
The only example in the docs for when hook_menu runs is when the module is enabled.  Is there any other time it runs?
Comment: `hook_menu()`, together `hook_menu_alter()`, is invoked when menu definitions needs to be rebuild, which normally happens when any module is installed, removed, enabled, or disabled. The question is a little unclear, though. What do you mean by _I need to edit the hook_menu() function in my module_? Disable the module, edit the code, and re-enable the module.
Comment: @kiamlaluno Editing the code doesn't require disabling the module. If you edit the hook implementation, the menu will not show any updates. That is probably why the OP is asking. How do you rebuild the menu after editing a module's hook_menu()
Comment: @mbomb007 Editing the code of a module doesn't tell Drupal that the menu definitions need to be rebuild. Drupal doesn't check the last time a module file has been changed, so it will not know the `hook_menu()` implementation has been possibly changed.
Comment: When a module is disabled, enabled, uninstalled, or installed, Drupal will rebuild the menu definitions. To do that, it will need to invoke every `hook_menu()` and `hook_menu_alter()` implementations. That is why disabling a module works.
Comment: It doesn't work for me.
Answer: Clearing the cache the menu and routing tables will be reconstructed.
In the admin UI, go to:
/admin/config/development/performance
Using drush:
drush cache-clear all

Other methods are described here: How do I call the menu_rebuild function in Drupal 7?

When does hook_menu run?


display and hide text using hover in jquery

Question: I'm trying to implement a simple functionality using the hover property in jQuery. When I hover on the div, some text must be displayed in the span element. That is pretty much the concept.

This code is not working! Can someone enlighten me?
Comment: Wrap your javascript with `$(document).ready(function() { ... });`
Comment: On the moment of call `$(".logo")` you div with `.logo` does not exit. That is why you have to run this code when DOM is loaded or below the part of the page with needed div.  `tried it. Did not work` show it.
Comment: tried it. Did not work
Comment: Did you forgot to load jQuery? See working demo here: http://jsfiddle.net/8as30y06/
Comment: @Cheery : are you saying that I have to put my javascript after the html code?
Comment: @SriRamGopal either below the part in html where all your elements are set or use, as everybody is telling you, the `$(document).ready()` to run your code when html code of the page is loaded.
Answer: Change your code like this way:
$(document).ready(function() {
    $(".logo").hover(
        function() {
            $("#span_hover").html("Please visit http://www.gmu.edu for more information.");
        },
        function() {
            $("#span_hover").html("");
        }
    );
});

With $(document).ready(...); your javascript code will wait for DOM and if it's completely loaded it will start.
http://jsfiddle.net/8as30y06/
Comment: I tried this. I see that the code is working in the fiddle. I think the code is correct. Do you know what other errors could be possible? I'm new to this stuff :(
Comment: @SriRamGopal Open your web inspector in your browser and see what's going on in the console...
Answer: Your script does actually work: http://jsfiddle.net/g2n403zs/ . Are you sure you are loading jquery before you are calling it's functions? What does the error console say?
$(".logo").hover(
    function() { $("#span_hover").html("Please visit http://www.gmu.edu for more information.") },
    function() { $("#span_hover").html(""); } );

Comment: the text does not appear when I hover
Answer: This seems to work ( you were missing a semicolon)
Here is fiddle:
jsFiddle
$(".logo").hover(function() {
$("#span_hover").html("Please visit http://www.gmu.edu for more information."); },
function() { $("#span_hover").html(""); });


Running a background process with Node.JS

Question: I'm trying to use Node.JS to provide a set of web services through restify. One of those services receives some params and then launches a process in background on Linux by using the method exec of child-process, passing as param to exec something like: "nohup program &". The process is launched without any problem, but it is killed after short interval even using nohup. I wonder if there is another way to launch a process in background through Node.JS. I've also tried to use the method spawn of child-process, but it seems that the process is not launched.
Comment: Possible duplicate of [Node.js workers/background processes][1].

  [1]: http://stackoverflow.com/questions/4762016/node-js-workers-background-processes
Answer: So both nohup and the & are not appropriate in this context. Those are utilities for when a human is using an interactive shell. When launching child processes programmatically as you are doing, you don't need them. Just launch your process by executable path/name directly. It will be in the "background" by default. The concept of "foreground" and "background" come from the notion of a single user with a single terminal screen, but remember that the OS normally runs many processes in parallel so calling something a "background" job is conceptually not quite right.
You also don't want nohup since again that is a special-purpose tool for allowing you to exit a parent shell process and leave a child process running, but in your case you want the default behavior that if your parent node.js process exits, the child worker processes should also exit.


Confidence intervals and meta-analysis

Question: I've heard that meta-analytical needs are actually a good argument for using confidence intervals in most applicable figures. Could someone explain this to a non-statistician?
I suppose it has something to do with the fact that CIs can be interpreted the same way regardless of n, unlike Standard Errors.
I understand that using CIs would encourage meta-analytical thinking. Meta-papers usually present a figure that contains all of the individual results from several studies, as well as a pooled estimate, like in this effect size -figure I found off Google...

But can confidence interval figures alone (with just the point estimator and the CIs), without access to more data, somehow be used for meta-analytical synthesis? Can you somehow combine the information in these figures from several studies into a single new figure, thus creating a figure with narrower CIs?
Therefore, are these figures intrinsically advantageous, or is the argument for using CIs mainly that they discourage unnecessary null hypothesis significance testing?
Answer: The estimate and the confidence intervals can be used. The approach would be to back-calculate the standard error from the confidence interval and then weight the estimates using the inverse of the variance. That is all you really need. There is a host of material on Wolfgang Viechtbauer's pages http://www.metafor-project.org/doku.php which give many examples using his metafor package in R but which are full of good advice even if you use some other software. The forest plot you show also gives information about how much information each study contributes by the size of the symbol: big symbol = more information.

Confidence intervals and meta-analysis


How to transform one state space model into different state space model?

Question: First of all I would like to apologize if I have chosen wrong forum. My question is related to the electrical engineering but basically it is a mathematical problem.
I have the state space model of the three phase squirrel cage induction motor. The state space model contains in the system matrix parameters of the $T$ equivalent circuit (the equivalent circuit is basically an electrical circuit modeling the machine)
$$
\frac{\mathrm{d}}{\mathrm{d}t}
\begin{bmatrix}
\hat{\mathbf{i}}^{\alpha,\beta}_{sT} \\
\hat{\mathbf{\psi}}^{\alpha,\beta}_{rT}
\end{bmatrix}
=
\begin{bmatrix}
-\alpha\cdot\mathbf{E} & \beta\cdot\mathbf{E}-\gamma\cdot p_p\cdot\omega_m\cdot\mathbf{J} \\
R_r\cdot\frac{L_h}{L_r}\cdot\mathbf{E} & -\frac{R_r}{L_r}\cdot\mathbf{E} + \omega_m\cdot p_p\cdot \mathbf{J}
\end{bmatrix}
\cdot
\begin{bmatrix}
\hat{\mathbf{i}}^{\alpha,\beta}_{sT} \\
\hat{\mathbf{\psi}}^{\alpha,\beta}_{rT}
\end{bmatrix}
+
\begin{bmatrix}
\delta\cdot\mathbf{E} \\
\mathbf{Z}
\end{bmatrix}
\cdot
\hat{\mathbf{u}}^{\alpha,\beta}_{sT}
$$
$$
\hat{\mathbf{i}}^{\alpha,\beta}_{sT}
=
\begin{bmatrix}
\mathbf{E} & \mathbf{Z}
\end{bmatrix}
\cdot
\begin{bmatrix}
\hat{\mathbf{i}}^{\alpha,\beta}_{sT} \\
\hat{\mathbf{\psi}}^{\alpha,\beta}_{rT}
\end{bmatrix}
$$
where the auxiliary variables $\alpha, \beta, \gamma, \delta$ have following values
$\alpha = \frac{R_s + R_r\cdot\frac{L^2_h}{L^2_r}}{L_{s\sigma} + \frac{L_h}{L_r}\cdot L_{r\sigma}}$, $\beta = \frac{\frac{R_r\cdot L_h}{L^2_r}}{L_{s\sigma} + \frac{L_h}{L_r}\cdot L_{r\sigma}}$, $\gamma = \frac{\frac{L_h}{L_r}}{L_{s\sigma} + \frac{L_h}{L_r}\cdot L_{r\sigma}}$, $\delta = \frac{1}{L_{s\sigma} + \frac{L_h}{L_r}\cdot L_{r\sigma}}$. The parameter $R_s$ is the resistance of the stator winding, $R_r$ is the resistance of the rotor winding, $L_h$ is the magnetizing inductance, $L_r$ is the rotor inductance, $L_{s\sigma}$ is the leakage inductance of the stator winding and $L_{r\sigma}$ is the leakage inductance of the rotor winding.
T equivalent circuit

The $\mathbf{E}, \mathbf{J}, \mathbf{Z}$ matrices have following meaning
$$
\mathbf{E}
=
\begin{bmatrix}
1 & 0 \\
0 & 1
\end{bmatrix}
$$
$$
\mathbf{J}
=
\begin{bmatrix}
0 & -1 \\
1 & 0
\end{bmatrix}
$$
$$
\mathbf{Z}
=
\begin{bmatrix}
0 & 0 \\
0 & 0
\end{bmatrix}
$$
My intention is to transform the above given state space model to a different state space model which will contain parameters of the $\Gamma$ equivalent circuit of the induction motor.
$\Gamma$ equivalent circuit

This transformation basically means that the state variables changes due to the fact that the leakage inductance of the stator winding has been moved onto the rotor side
\begin{equation}
\hat{\mathbf{i}}^{\alpha,\beta}_{s\Gamma} = \hat{\mathbf{i}}^{\alpha,\beta}_{sT}
\end{equation}
\begin{equation}
\hat{\mathbf{\psi}}^{\alpha,\beta}_{s\Gamma} = b\cdot\hat{\mathbf{\psi}}^{\alpha,\beta}_{rT} = \frac{L_s}{L_h}\cdot\hat{\mathbf{\psi}}^{\alpha,\beta}_{rT}
\end{equation}
or in matrix form
\begin{equation}
\begin{bmatrix}
\hat{\mathbf{i}}^{\alpha,\beta}_{s\Gamma} \\
\hat{\mathbf{\psi}}^{\alpha,\beta}_{r\Gamma}
\end{bmatrix}
=
\begin{bmatrix}
\mathbf{E} & \mathbf{Z} \\
\mathbf{Z} & b\cdot\mathbf{Z}
\end{bmatrix}
\cdot
\begin{bmatrix}
\hat{\mathbf{i}}^{\alpha,\beta}_{sT} \\
\hat{\mathbf{\psi}}^{\alpha,\beta}_{rT}
\end{bmatrix}
\end{equation}
which means
\begin{equation}
\mathbf{x}_T
=
\begin{bmatrix}
\hat{\mathbf{i}}^{\alpha,\beta}_{sT} \\
\hat{\mathbf{\psi}}^{\alpha,\beta}_{rT}
\end{bmatrix}
=
\begin{bmatrix}
\mathbf{E} & \mathbf{Z} \\
\mathbf{Z} & \frac{1}{b}\cdot\mathbf{Z}
\end{bmatrix}
\cdot
\begin{bmatrix}
\hat{\mathbf{i}}^{\alpha,\beta}_{s\Gamma} \\
\hat{\mathbf{\psi}}^{\alpha,\beta}_{r\Gamma}
\end{bmatrix}
=
\mathbf{T}
\cdot
\mathbf{x}_{\Gamma}
\end{equation}
The last matrix equation enables to move from the $T$ based state space model to the $\Gamma$ state space model. Because in case we use it in the $T$ based state space model
\begin{eqnarray}
\dot{\mathbf{x}}_T &=& \mathbf{A}_T\cdot \mathbf{x}_T + \textbf{B}_T\cdot \mathbf{u} \nonumber \\
\mathbf{y}_T &=& \mathbf{C}_T\cdot\mathbf{x}_T \nonumber
\end{eqnarray}
we have
$$
\frac{\mathrm{d}}{\mathrm{d}t}\left(\mathbf{T}\cdot\mathbf{x}_{\Gamma}\right)
=
\mathbf{A}_T\cdot\left(\mathbf{T}\cdot\mathbf{x}_{\Gamma}\right) + \mathbf{B}_T\cdot \mathbf{u}_T
$$
$$
\dot{\mathbf{x}}_{\Gamma} = \mathbf{T}^{-1}\cdot\mathbf{A}_T\cdot\mathbf{T}\cdot\mathbf{x}_{\Gamma} + \mathbf{T}^{-1}\cdot\mathbf{B}_T\cdot\mathbf{u}_T
$$
$$
\mathbf{y}_{T}
=
\mathbf{y}_{\Gamma}
=
\mathbf{C}_T\cdot\mathbf{T}\cdot\mathbf{x}_{\Gamma}
$$
From the last set of the matrix equations we can write formulas for transforming the matrices of the $T$ based state space model into the $\Gamma$ based state space model
$$
\mathbf{A}_{\Gamma} = \mathbf{T}^{-1}\cdot\mathbf{A}_T\cdot\mathbf{T}
$$
$$
\mathbf{B}_{\Gamma} = \mathbf{T}^{-1}\cdot\mathbf{B}_T
$$
$$
\mathbf{C}_{\Gamma} = \mathbf{C}_T\cdot\mathbf{T}
$$
My problem is how to write the matrices of the $\Gamma$ based state space model i.e. $\mathbf{A}_{\Gamma}, \mathbf{B}_{\Gamma}, \mathbf{C}_{\Gamma}$ in such a manner that they contain in their elements only the parameters of the $\Gamma$ equivalent circuit i.e. stator resistance $R_S$, magnetizing inductance $L_M$, total leakage inductance $L_L$ and rotor resistance $R_R$. There are following formulas for conversion of the parameters of the $T$ equivalent circuit into the parameters of the $\Gamma$ equivalent circuit
$$
R_S = R_s
$$
$$
L_M = L_s
$$
$$
L_L = L_r\cdot\frac{L^2_s}{L^2_h} - L_s
$$
$$
R_R = R_r\cdot\frac{L^2_s}{L^2_h}
$$
I have attempted to made some modifications in the elements of the matrices aiming to exploit the formulas for the $R_S$,$L_M$,$L_L$ $R_R$ but I always stuck in a situation where let's
say $R_r$ is multiplied by the desired "transform" coefficient $b=\frac{L_s}{L_h}$ but the necessary modifications create very complex expression from the rest of the matrix element which doesn't contain none of the formulas for the $R_S$,$L_M$,$L_L$,$R_R$. I have also attempted to use the wxMaxima software for the symbolic calculations but without success.
One observation I have made. If I chose different transform coefficient $b=\frac{L_h}{L_r}$ which corresponds to the another equivalent circuit called $\Gamma^{-1}$
$\Gamma^{-1}$ equivalent circuit

I am able to get correct state space model based on the above mentioned steps and below given formulas for conversion of the parameters of the $T$ equivalent circuit into the parameters of the $\Gamma^{-1}$ equivalent circuit
$$
R_S = R_s
$$
$$
L_M = L_h\cdot\frac{L_h}{L_r}
$$
$$
L_L = L_{s\sigma} + \frac{L_h}{L_r}\cdot L_{r\sigma}
$$
$$
R_R = R_r\cdot\frac{L^2_h}{L^2_r}
$$
This fact proofs in my opinion the correctness of the derived formulas for the transformation of the matrices.
Answer: I hope I am not wrong but I think that the solution is very simple. Due to the fact that the transition between both the state space models has been done via application of the transform matrix $\mathbf{T}$ on the system matrix $\mathbf{A_T}$ and the input matrix $\mathbf{B_T}$ I think that I can simply substitute the following formulas into the elements of the $\mathbf{A_{\Gamma}}$ and $\mathbf{B_{\Gamma}}$ matrices and get the state space model related to the $\Gamma$ equivalent circuit
$$L_{s\sigma} = L_s - L_h$$
$$L_{r\sigma} = L_r - L_h$$
$$L_r = L_L + L_M$$
$$R_s = R_S$$
$$L_h = L_M$$
$$R_r = R_R$$
$$L_s = L_M$$