text:
Q: Agile Web Development with Rails 5.1 Playground - Ch 15 Password Trouble I can't figure out something in Agile Web Development with Rails, Chapter 15 - Playgrounds question 1.
It asks Modify the user update function to require and validate the current
password before allowing a user's password to be changed.
I really can't understand how I can get the has_secure_password helper method to allow me to also seek the current password, if there is one, and see if it equals a hash before allowing a change of the password to be made.
I'm reading along with the book and when it gets to these Playgrounds, I feel like chewing glass alot of the time.
My _form partial looks like this:

Enter User Details

    <%= form.label :name, 'Name:' %>
    <%= form.text_field :name, id: :user_name, size: 40 %>

  <% if user.password_digest %>
    <%= form.label :password_digest, 'Current Password' %>
    <%= form.password_field :password_digest, id: :password_digest, size: 40 %>
  <% end %>

    <%= form.label :password, 'Password' %>
    <%= form.password_field :password, id: :user_password, size: 40 %>

    <%= form.label :password_confirmation, 'Confirm:' %>
    <%= form.password_field :password_confirmation,
                    id: :user_password_confirmation,
                    size: 40 %>

    <%= form.submit %>

I check whether the user at present has a password_digest property in the the instance-variable to see whether I display the form chunk that is all decked out with password_digest symbols.
In my user_controller's update function, looks like this
def update
    puts "update running"
    puts @user
    puts @user.name
    puts @user.password
    puts @user.password_confirmation
    respond_to do |format|
      if @user.update(update_params)
        # format.html { redirect_to @user, notice: 'User was successfully updated.' }
        format.html { redirect_to users_url, notice: "User #{@user.name} was successfully updated." }
        format.json { render :show, status: :ok, location: @user }
      else
        format.html { render :edit }
        format.json { render json: @user.errors, status: :unprocessable_entity }
      end
    end
  end

You'll notice the use of 'update_params'...I made another private method at the bottom of the file that differs from the standard 'user_params', I thought by substituting that into the mix I could get the whole thing to work.
To be honest, I'm so incredibly lost. If someone could please guide me on how to do this, I would be really grateful. I've googled and stackflow searched all over and I feel like in the search to find water to douse  fire, I can only find flammable liquids, each one more reactive to heat than the last.
Is there a repository out there that has all these extra 'Playgrounds' things done, so I can take a look at them and see what's going on?

A: *

*drop :password_digest from your form, it serves nothing (if you auto-populate it, it defeats the purpose, and if you don't, users can't type it in because they don't know the value).

*Add a regular password input for the current password, which the user will fill in.
<%= password_field_tag :current_password %>

*allow :password and :password_confirmation in your update_params, if you haven't already.

*In your controller add a check for the current password, using has_secure_password's authenticate method.
if user.authenticate(params[:current_password])
  # user provided valid current password, proceed with saving

I really can't understand how I can get the has_secure_password helper method to allow me to also seek the current password, if there is one, and see if it equals a hash before allowing a change of the password to be made.

You can't retrieve user's password from the database. So what you do instead is you ask the user what they think the current password is, hash their input and compare to the stored password hash (authenticate does the last two steps).


text:
Q: Is there a better way to hardcode shell script rather than a mix of cat and redirection? I wanted to make a hardcoded script automatically run as root and I came across this:
#!/bin/bash
cat >/tmp/convert.sh <<EOF

some script here

EOF
chmod +x /tmp/convert.sh
sudo /tmp/convert.sh
rm /tmp/convert.sh

Although this works well, the shell seems to read the script while cat stores the file and emits some messages. Is there a better way to do this so the shell won't read the script before it runs?

A: The script presented is a wrapper that writes a separate script in /tmp and uses the sudo command to execute that with elevated privileges.  The reason to do it that way would be to accommodate the possibility that root cannot access the original file, which might be the case if the file resides on a network file system, if mandatory access controls (e.g. SELinux) prevent it, or perhaps for other reasons.

Is there a better way to do this so the shell won't read the script before it runs?

Of course the shell needs to read the script in order to run it, so I take you to be asking about the creation of an additional script.  That is necessary if you want to accommodate the possibility that root cannot access the original script, though the example implementation is dangerously poor.  If you aren't worried about that possibility then no, it is not necessary to make a separate script.  In that case, one might instead do this:
#!/bin/bash

[[ $EUID -eq 0 ]] || exec sudo /bin/bash -c "${BASH_SOURCE[0]}"

some script here

That checks whether the script is running with effective user ID 0, and if not, uses sudo to relaunch itself.  It does not depend on the original script to be marked executable.  Like the example script, this will be subject to authentication and authorization via sudo, which is the only thing that makes the automatic privilege elevation at all reasonable as far as I am concerned.

A: In Bash I recommend using functions and declare -f to transfer properly escaped work to be done.
#!/bin/bash

work() {
   some script here
   normally escaped
}

{
   declare -p var1 var2     # transfer variables if any are needed
   declare -f work          # let bash handle the hard escaping
   echo 'work "$@"'         # actually call the 'work' function
} | sudo bash -s            # why create a file? Just forward to shell.

A: John is 100% correct with his answer to this, but I want to note one other possibility for using a heredoc to generate anther script.  There could be variable substitutions in the heredoc.  Even if the same thing could be done somehow without substituting variables during the heredoc stage you should review the code and test it thoroughly to make sure you're not introducing a bug by refactoring out that "oddity".

redpajama_set_name: RedPajamaStackExchange


text:
Q: Give combinatorial a proof that $\binom{n}{2}^2=\binom{n}{2}+6\binom{n}{3}+6\binom{n}{4}$
Give combinatorial a proof that $$\binom{n}{2}^2=\binom{n}{2}+6\binom{n}{3}+6\binom{n}{4}$$

I firstly thought it like classical commission questions consisting of $n$ men and $n$ women etc. However , i did not work. After that   , i thought about manipulating the question such that  $$\binom{n}{2}^2=\binom{n}{2}+6\binom{n}{3}+6\binom{n}{4}$$ $$\binom{n}{2}\binom{n}{n-2}=\binom{n}{2}+6\binom{n+1}{4}$$ However , i cannot still find anything. Can you help me ?
NOTE: Although @Phicar's answer get credit from you , i could not comprehend it :( So , i am open to other proofs.
NOTE 2: Do not write "HINTS" , if you want to write somethings , please be clear and elaborately

A: The other answer by Phicar is splendid, but I thought I should relate it more concretely to your attempt, picking two (unordered, but distinguishable) pairs from a group

consisting of $n$ men and $n$ women

Instead, try to pick two (not necessarily disjoint) pairs from a single group of $n$ people. The left-hand side is the direct approach, while the right-hand side splits into cases based on how many people were actually chosen.

A: It might help to explain the origin of the two sixes since they come from different origins.
The green part below consists of choosing one of three to be doubled, multiplied by the ways of choosing which of the other two goes where. The blue part is the number of ways we can split four into two pairs.
$$\binom{n}{2}^2=\color{purple}{\binom{n}{2}}+\color{green}{\binom{3}{1}\binom{2}{1}\binom{n}{3}}+\color{blue}{\binom{4}{2}\binom{n}{4}}$$
This is not a combinatoric proof, but just to confirm the answer:
$$
\frac12n(n-1)+6\frac16n(n-1)(n-2)+6\frac1{24}n(n-1)(n-2)(n-3)\\
=\frac14n(n-1)\left\{2+4(n-2)+(n-2)(n-3)\right\}\\
=\frac14n(n-1)\left\{n(n-1)\right\}\\
=\binom{n}{2}^2
$$

A: Hint:  Try the most natural thing: You are choosing ordered pairs of groups of 2 people out of $n$ people, this is the left hand side. You can either have the same group, that is, the pair share both people (in how many ways?) or you choosed two groups that share exactly one person (so you are choosing $3$ people, actually) or your pair has no one in common (so you are choosing 4 people).
Edit: You are asking for not a hint..well consider $\binom{[n]}{k}=\{A\subseteq [n]=\{1,2,\cdots ,n\}:|A|=k\},$ what you want is to find a bijection in between $\binom{[n]}{2}\times \binom{[n]}{2}$ and $\binom{[n]}{2}\bigcup \binom{[n]}{3}\times \binom{[3]}{1}\times\binom{[2]}{1}  \bigcup \binom{[n]}{4}\times\binom{[4]}{2}$, where those are disjoint unions. For that, consider the following function $$\varphi (A,B)=\begin{cases}A & \text{if }A=B\\
(A\cup B,A\cap B,A\setminus B) & \text{ if }|A\cap B|=1\\ (A\cup B,A) & \text{Otherwise, so}|A\cap B|=0\end{cases},$$
Just show that this is actually a bijection.


text:
Q: Android Studio - New virtual device fails during SD card creation I am trying to create a new virtual device using the AVD Manager on Android Studio, running on Windows 7.
When I click the finish button I receive an error message. Chechking the idea.log I see this:
2019-06-07 17:09:59,558 [ thread 48]   WARN - vdmanager.AvdManagerConnection - Invalid argument size '512M'
2019-06-07 17:09:59,558 [ thread 48]   WARN - vdmanager.AvdManagerConnection -
2019-06-07 17:09:59,558 [ thread 48]   WARN - vdmanager.AvdManagerConnection - mksdcard: create a blank FAT32 image to be used with the Android emulator
2019-06-07 17:09:59,558 [ thread 48]   WARN - vdmanager.AvdManagerConnection - usage: mksdcard [-l label] <size> <file>
2019-06-07 17:09:59,558 [ thread 48]   WARN - vdmanager.AvdManagerConnection -
2019-06-07 17:09:59,558 [ thread 48]   WARN - vdmanager.AvdManagerConnection -   if <size> is a simple integer, it specifies a size in bytes
2019-06-07 17:09:59,558 [ thread 48]   WARN - vdmanager.AvdManagerConnection -   if <size> is an integer followed by 'K', it specifies a size in KiB
2019-06-07 17:09:59,558 [ thread 48]   WARN - vdmanager.AvdManagerConnection -   if <size> is an integer followed by 'M', it specifies a size in MiB
2019-06-07 17:09:59,558 [ thread 48]   WARN - vdmanager.AvdManagerConnection -   if <size> is an integer followed by 'G', it specifies a size in GiB
2019-06-07 17:09:59,558 [ thread 48]   WARN - vdmanager.AvdManagerConnection -
2019-06-07 17:09:59,558 [ thread 48]   WARN - vdmanager.AvdManagerConnection - Minimum size is 9M. The Android emulator cannot use smaller images.
2019-06-07 17:09:59,559 [ thread 48]   WARN - vdmanager.AvdManagerConnection - Maximum size is 1099511627264 bytes, 1073741823K, 1048575M or 1023G
2019-06-07 17:09:59,559 [ thread 48]   WARN - vdmanager.AvdManagerConnection - Failed to create the SD card.
2019-06-07 17:09:59,559 [ thread 48]   WARN - vdmanager.AvdManagerConnection - Failed to create sdcard in the AVD folder.

I have tried different values and unit sizes without success.
Also tried to run the command manually with the same error:
mksdcard.exe 512M mysdcard.img

As I am using the IDE interface I don't have a lot of options and can not figure out the problem. Is there any soluton to it?


text:
Q: Nuclear norm of a block matrix Suppose that
$$
X = \begin{bmatrix} A & C^T \\ C & B \end{bmatrix}
$$
where $X, A, B \succeq 0$ are (real) positive semidefinite matrices.
Is it true that the Cauchy-Schwarz like inequality:
$$\|C\|_\ast \leq \sqrt{\|A\|_\ast \|B\|_\ast}$$
holds, where $\|\cdot\|_\ast$ denotes the sum of the singular values?

A: By padding the matrices with zeroes if necessary, we may assume that $A,B$ and $C$ are square matrices of the same sizes. If $C=USV^T$ is a singular value decomposition, by considering $(V\oplus U)^TX(V\oplus U)$, we may further assume that $C$ is a nonnegative diagonal matrix $\operatorname{diag}(c_1,c_2,\ldots,c_n)$. Hence $A,B,C$ are positive semidefinite and their nuclear norms are precisely their traces.
Since $X$ is positive semidefinite, its $2\times2$ principal minors are nonnegative. Hence $c_i^2\le a_{ii}b_{ii}$ for each $i$. It follows that
\begin{aligned}
\|C\|_\ast^2=\left(\sum_ic_i\right)^2
&\le\left(\sum_i\sqrt{a_{ii}b_{ii}}\right)^2\\
&\le\left[\sum_i(\sqrt{a_{ii}})^2\right]\left[\sum_i(\sqrt{b_{ii}})^2\right]
\ \text{(Cauchy-Schwarz inequality)}\\
&=\left(\sum_ia_{ii}\right)\left(\sum_ib_{ii}\right)=\|A\|_\ast\|B\|_\ast.
\end{aligned}


text:
Q: How to use Firebase IdToken to generate OAuth Access for Google drive? Update
In my Nativescript-Angular application I'm using @nativescript/firebase plugin which uses Firebase authentication and in the scope I have provided https://www.googleapis.com/auth/drive.
firebase
        .login({
          type: firebase.LoginType.GOOGLE,
          googleOptions: {
            scopes: ["email", "https://www.googleapis.com/auth/drive"],
          },
        })
        .then((user: firebase.User) => {
          //Firebase ID Token
          const idToken = value.providers[0].token;
        })
        .catch((err) => {
          console.log(err);
        });

While running application, it asked for user login along with user's consent for Google drive access. After successful authentication it returns a Firebase Id Token.
In the next step application requires to access user's Google Drive. As I know Google Drive API requires OAuth Access token while application has Firebase Token.
https://www.googleapis.com/drive/v3/files
My questions is: How to generate OAuth Access token which is capable to access user's Google drive?
OR
Is there any alternate solution for this?

A: From what I can determine, the FirebaseNativeScript library's getAuthToken() call returns an ID token.
Firebase Authentication users do not necessarily have access to Google Drive. Instead you'll need to use the user's OAuth2 token (the same one that is used to sign in to Firebase) to access Google Drive. In steps, you'll need to:

*

*request the additional OAuth scopes needed to access Drive,

*capture the OAuth token (not a Firebase token) and,

*use that to access Drive.

If you've tried this already, please edit your question to show what you've tried.

A: It has been resolved. Basically the problem is with @nativescript/firebase plugin which is not returning accessToken. I have customised the plugin which is now returning accessToken that I am able to authorise on Google APIs.


text:
Q: Store count of integers in order using javascript I have string like the following:
11222233344444445666

What I would like to do is output the number followed the times it was displayed:
112433475163
Question is, I want this to be efficient.  I can store this in an object as the following:
1: { id: 1, displayed: 2},
2: { id: 2, displayed: 1},
3: { id: 3, displayed: 2},

etc.
I can access this object and increment displayed.
My issues is, there is no guarantee in the order.  I would like to store the keys in the order they are in the string.  How do I accomplish the importance of the order in the object?

A: This is a proposal for run length coding with an array which holds infomation about one charcter and the count of it:

{
    "char": "1",
    "count": 2
},

var string = "11222233344444445666",
    array = function () {
        var r = [], o = {};
        string.split('').forEach(function (a, i, aa) {
            if (a !== aa[i - 1]) {
                o[a] = { char: a, count: 0 };
                r.push(o[a]);
            }
            o[a].count++;
        });
        return r;
    }(string);

document.write('<pre>' + JSON.stringify(array, 0, 4) + '</pre>');

A: Quick solution with for loop:
var str = "7771122229933344444445666",
    obj = {},
    len = str.length,
    val = null,
    count_str = "",
    key = "";

for (var i = 0; i < len; i++) {
    val = str[i], key = 'k' + val;
    if (!obj[key]) {
       obj[key] = {'id': val, 'displayed': 1};
    } else {
        obj[key].displayed++;
    }
}
for (var p in obj) {
    count_str += obj[p]['id'] + obj[p]['displayed'];
}

console.log(count_str); // "7312249233475163"

A: You could store an additional array with the order of the numbers, which you only append to if the object doesn't yet contain the given number. Then once you're done counting, iterate through that array and output the number and the count from the lookup dictionary.
var chars = "1234576123452345".split("");
var order = [];
var hash = {};
chars.forEach(function(char) {
  if (!hash[char]) {
    hash[char] = 1;
    order.push(char);
  } else {
    hash[char]++;
  }
});

console.log(order.map(function(char) {
  return char + hash[char];
}).join(""));

// "12233343537161"

A: because you have such a small set of distinct numbers, I seen no reason why you can't use a array (yeah it's not super ideal memorywise if you skip values and it becomes sparse, but for such a small subset it won't affect you enough to worry of it). Then you can use (number-1) as the index and increment that number as needed.
var counts = [];
var str = "11222233344444445666";
for(var i in str){
    var index = parseInt(str[i])-1
    counts[index] = (counts[index]||0)+1;
}
for(var i in counts){
        var which = 1+parseInt(i);
    var count = counts[i];
    console.log("# of " + which +"'s: "+count);
}

https://jsfiddle.net/ga0fqpqn/
note: You shouldn't need the parseInt(i)... just +i should work but I think jsfiddle has a bug with it about it defaulting i to handle like a string.


text:
Q: Celery beat not picking up periodic tasks I am trying to get started with celery, but I can't get my task up and running. I have installed django-celery-beat and celery4.
My settings file.
Installed apps (with celery packages)
...
'django_celery_beat',
'django_celery_results'

the celery configuration
CELERY_BROKER_URL = 'redis://localhost:6379/0'
CELERY_RESULT_BACKEND = 'redis://localhost:6379'
CELERY_ACCEPT_CONTENT = ['json']
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'

celery.py
from __future__ import absolute_import, unicode_literals
import os
from celery import Celery

# set the default Django settings module for the 'celery' program.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'sandbox.settings')

app = Celery('sandbox')

# Using a string here means the worker doesn't have to serialize
# the configuration object to child processes.
# - namespace='CELERY' means all celery-related configuration keys
#   should have a `CELERY_` prefix.
app.config_from_object('django.conf:settings', namespace='CELERY')

# Load task modules from all registered Django app configs.
app.autodiscover_tasks()

@app.task(bind=True)
def debug_task(self):
    print('Request: {0!r}'.format(self.request))

and my simple task, which i configured to run through the admin panel of django celery beat.
from __future__ import absolute_import, unicode_literals
from sandbox.celery import app

@app.task()
def try_celery():
    print "Trying out Celery"

I am trying to run this task as a periodic task (beat) with cron tab as */2 * * * *
The log I am getting is,
$ celery -A sandbox worker --loglevel=debug

[2017-10-24 14:28:02,999: DEBUG/MainProcess] | Worker: Preparing bootsteps.
[2017-10-24 14:28:03,001: DEBUG/MainProcess] | Worker: Building graph...
[2017-10-24 14:28:03,002: DEBUG/MainProcess] | Worker: New boot order: {Beat, Timer, Hub, Pool, Autoscaler, StateDB, Consumer}
[2017-10-24 14:28:03,017: DEBUG/MainProcess] | Consumer: Preparing bootsteps.
[2017-10-24 14:28:03,017: DEBUG/MainProcess] | Consumer: Building graph...
[2017-10-24 14:28:03,038: DEBUG/MainProcess] | Consumer: New boot order: {Connection, Events, Mingle, Tasks, Control, Agent, Gossip, Heart, event loop}

 -------------- celery@mypc v4.1.0 (latentcall)
---- **** -----
--- * ***  * -- Linux-4.9.0-kali3-amd64-x86_64-with-Kali-kali-rolling-kali-rolling 2017-10-24 14:28:03
-- * - **** ---
- ** ---------- [config]
- ** ---------- .> app:         sandbox:0x7fe519d38610
- ** ---------- .> transport:   redis://localhost:6379/0
- ** ---------- .> results:     redis://localhost:6379/
- *** --- * --- .> concurrency: 2 (prefork)
-- ******* ---- .> task events: OFF (enable -E to monitor tasks in this worker)
--- ***** -----
 -------------- [queues]
                .> celery           exchange=celery(direct) key=celery

[tasks]
  . celery.accumulate
  . celery.backend_cleanup
  . celery.chain
  . celery.chord
  . celery.chord_unlock
  . celery.chunks
  . celery.group
  . celery.map
  . celery.starmap
  . sandbox.applications.cats.try_celery
  . sandbox.celery.debug_task

[2017-10-24 14:28:03,053: DEBUG/MainProcess] | Worker: Starting Hub
[2017-10-24 14:28:03,053: DEBUG/MainProcess] ^-- substep ok
[2017-10-24 14:28:03,053: DEBUG/MainProcess] | Worker: Starting Pool
[2017-10-24 14:28:03,197: DEBUG/MainProcess] ^-- substep ok
[2017-10-24 14:28:03,198: DEBUG/MainProcess] | Worker: Starting Consumer
[2017-10-24 14:28:03,199: DEBUG/MainProcess] | Consumer: Starting Connection
[2017-10-24 14:28:03,216: INFO/MainProcess] Connected to redis://localhost:6379/0
[2017-10-24 14:28:03,217: DEBUG/MainProcess] ^-- substep ok
[2017-10-24 14:28:03,217: DEBUG/MainProcess] | Consumer: Starting Events
[2017-10-24 14:28:03,228: DEBUG/MainProcess] ^-- substep ok
[2017-10-24 14:28:03,229: DEBUG/MainProcess] | Consumer: Starting Mingle
[2017-10-24 14:28:03,229: INFO/MainProcess] mingle: searching for neighbors
[2017-10-24 14:28:04,255: INFO/MainProcess] mingle: all alone
[2017-10-24 14:28:04,256: DEBUG/MainProcess] ^-- substep ok
[2017-10-24 14:28:04,256: DEBUG/MainProcess] | Consumer: Starting Tasks
[2017-10-24 14:28:04,273: DEBUG/MainProcess] ^-- substep ok
[2017-10-24 14:28:04,274: DEBUG/MainProcess] | Consumer: Starting Control
[2017-10-24 14:28:04,277: DEBUG/MainProcess] ^-- substep ok
[2017-10-24 14:28:04,277: DEBUG/MainProcess] | Consumer: Starting Gossip
[2017-10-24 14:28:04,281: DEBUG/MainProcess] ^-- substep ok
[2017-10-24 14:28:04,282: DEBUG/MainProcess] | Consumer: Starting Heart
[2017-10-24 14:28:04,284: DEBUG/MainProcess] ^-- substep ok
[2017-10-24 14:28:04,284: DEBUG/MainProcess] | Consumer: Starting event loop
[2017-10-24 14:28:04,285: DEBUG/MainProcess] | Worker: Hub.register Pool...
[2017-10-24 14:28:04,294: WARNING/MainProcess] /home/alexd/.virtualenvs/skate/local/lib/python2.7/site-packages/celery/fixups/django.py:202: UserWarning: Using settings.DEBUG leads to a memory leak, never use this setting in production environments!
  warnings.warn('Using settings.DEBUG leads to a memory leak, never '
[2017-10-24 14:28:04,294: INFO/MainProcess] celery@mypc ready.
[2017-10-24 14:28:04,295: DEBUG/MainProcess] basic.qos: prefetch_count->8

why my tasks are not working?
Update
log of running celery as beat
$ celery -A sandbox beat --loglevel=debug
celery beat v4.1.0 (latentcall) is starting.
Stale pidfile exists - Removing it.
__    -    ... __   -        _
LocalTime -> 2017-10-24 15:07:20
Configuration ->
    . broker -> redis://localhost:6379/0
    . loader -> celery.loaders.app.AppLoader
    . scheduler -> celery.beat.PersistentScheduler
    . db -> celerybeat-schedule
    . logfile -> [stderr]@%DEBUG
    . maxinterval -> 5.00 minutes (300s)
[2017-10-24 15:07:20,216: DEBUG/MainProcess] Setting default socket timeout to 30
[2017-10-24 15:07:20,217: INFO/MainProcess] beat: Starting...
[2017-10-24 15:07:20,372: DEBUG/MainProcess] Current schedule:

[2017-10-24 15:07:20,373: DEBUG/MainProcess] beat: Ticking with max interval->5.00 minutes
[2017-10-24 15:07:20,373: DEBUG/MainProcess] beat: Waking up in 5.00 minutes.
[2017-10-24 15:15:43,232: DEBUG/MainProcess] beat: Synchronizing schedule...
[2017-10-24 15:15:43,245: DEBUG/MainProcess] beat: Waking up in 5.00 minutes.

creation of task

this is how the task is created as a periodic task in the admin.
ps. I changed to interval option, may be some problems with my cron tab? anyway still not working.

A: The root cause, in this case, is that the beat scheduler needs to be started with the appropriate arguments. You supplied the following command:
$ celery -A sandbox worker --loglevel=debug

However, to start celery with a beat schedule, (as opposed to a regular celery worker) you must specify beat rather than worker. Moreover, when using the django_celery_beat extension, it is necessary to use the Database scheduler django_celery_beat.schedulers:DatabaseScheduler rather than the default scheduler celery.beat.PersistentScheduler.
So the corrected command would be:
$ celery -A sandbox beat --loglevel=debug --scheduler django_celery_beat.schedulers:DatabaseScheduler

Supporting documentation

A: I think you did not define the cron shcedule. Where is it stored? Usually it is on disk or in database (django_celery). See http://docs.celeryproject.org/en/latest/userguide/periodic-tasks.html
Also, you have to run your worker with a beat option

A: Add below code in "init.py" which is in "sandbox" project to pick task to Django admin.
This will make sure the app is always imported when django starts so that task will use this app.
from __future__ import absolute_import, unicode_literals
from .celery import app as celery_app
__all__ = ('celery_app',)

A: If you want to run Beat & Worker together, use the --beat flag.
celery -A sandbox worker --beat --loglevel=debug


text:
Q: MS Excel for Mac - conditional formatting I would greatly appreciate help in writing the code to do the following:
cell B7 is the sum of H7+I7+J7
when the sum in B7 is greater than 2 and less than 5 (i.e. either 3 or 4), I would like B7 to have a green fill and display the word "LOW)
I know how to do the colour fill part, but not how to get B7 to display text when the sum is a certain number - I have tried a couple of options:

*

*I inserted a formula in B7 so that it = H7+I7+J7; and then created  a Conditional Format as follows: IF(AND(B7>2,B7<5),"LOW"

*I deleted the SUM formula from B7 and created a Conditional Formula as follows: IF(AND(H7+I7+J7>2,H7+I7+J7<5),"LOW"
I also tried it without the "IF", but nothing works
HELP (please)

A: First, both of your formulas are missing a close parethesis at the end and the FALSE statement.
Enter the following formula in B7,
=If(AND(sum(H7, I7, J7)>2, sum(H7, I7, J7)<5), "LOW", {enter false statement here})
As I think you have figured out, coloring a cell with conditional formatting and changing the value of a cell using If statements are usually two separate function.
Here is an example of nesting the IF statements:
=IF(AND(SUM(H7, I7, J7)>2, SUM(H7, I7, J7)<5), "LOW", IF(AND(SUM(H7, I7, J7)>4, SUM(H7, I7, J7)<8), "MEDIUM", IF(AND(.....{and so forth}
Look at these Microsoft Excel Course videos on advanced IF functions. Microsoft Support Excel Advanced If Functions
Good Luck.


text:
Q: Is being locally compact a topological property? I want to make sure that locally compact is a topological property. If it is right, then the rational number are not homeomorphic to positive integers numbers.

A: There are several slightly different definitions of local compactness; they are equivalent for Hausdorff spaces but not necessarily for non-Hausdorff spaces. All of them define topological properties, however. I'll prove this for one of the most common definitions: $X$ is locally compact if each point of $X$ has a local base of compact nbhds.
Suppose that $X$ is locally compact in this sense and that $f:X\to Y$ is a homeomorphism onto $Y$. Let $y\in Y$; there is an $x\in X$ such that $f(x)=y$. Let $\mathscr{B}$ be a local base of compact nbhds of $x$; continuous maps preserve compactness, so $\{f[B]:B\in\mathscr{B}\}$ is a family of compact sets, each of which contains $y$. Let $\mathscr{C}=\{f[B]:B\in\mathscr{B}\}$; we want to show that $\mathscr{C}$ is a local base at $y$.
Suppose that $U$ is any open nbhd of $y$. Then $f^{-1}[U]$ is an open nbhd of $x$, so there is a $B\in\mathscr{B}$ such that $x\in\operatorname{int}_XB\subseteq B\subseteq f^{-1}[U]$; clearly $y\in f[\operatorname{int}_XB]\subseteq f[B]\subseteq U$. Moreover, $f$ is a homeomorphism, so $f[\operatorname{int}_XB]$ is open in $Y$, and therefore $y\in\operatorname{int}_Yf[B]$. Thus, $f[B]$ is a compact nbhd of $y$ that is contained in $U$, and $\mathscr{C}$ is indeed a local base of compact nbhds of $y$.
However, there are easier ways to show that $\Bbb Z^+$ is not homeomorphic to $\Bbb Q$. The simplest is to note that $\{1\}$ is an open set in $\Bbb Z^+$. If $f:\Bbb Z^+\to\Bbb Q$ were a surjective homeomorphism, $f[\{1\}]=\{f(1)\}$ would be an open set in $\Bbb Q$, which it is not: $\Bbb Q$ has no isolated points.

A: Let $X,Y$ be topological spaces and $f$ be a homeomorphism between them, X - locally connected. Take a point $y\in Y$. There is a point $x\in X, f(x)=y$ and open, homeomorphic surroundings $x\in U_x\subset X$,$y\in U_y\subset Y$ such that $U_x$ is connected, but this is topological invariant, so $U_y$ is also connected. This is connected surrounding of a arbitrary point of $Y$.
There you go, I think it's ok.
You don't have to use local property here, there's no bijection between $\mathbb{R}$ and $\mathbb{Z_+}$, it's enough.

A: Yes, local compactness is a topological property, for it is defined purely in terms of set theory and open sets.
That homeomorphisms preserve this property is the definition of a topological property. The last question might depend on how you define "locally P" for a property P. If you say X is locally P iff every point has a neighbourhood (in the general sense) that has P, and P is itself a topological property, then yes, so is locally P, obviously. You need that a homeomorphisms preserves open sets and hence neighourhoods and is surjective, so that all points in the image are reached.


text:
Q: Removing eventhandlers not working: "this" context lost in Javascript? I have a problem with removing the eventhandlers for a slider element
If I don't use proxy for the handler, the "this" will point to the dom element
How do I remove the handler?
Relevant code:
var slider = (function (slider) {

var Sliderhandle = function(handle){
    EvtTarget.call(this);

    this.events = {
        start: ['touchstart', 'mousedown'],
        move: ['touchmove', 'mousemove'],
        end: ['touchend', 'touchcancel', 'mouseup']
    };

    this.options = {};
    this.element = $$('div.ui-slider');
    // set context for event handlers
    this.start = this.start.bind(this);
    this.move = this.move.bind(this);
    this.end = this.end.bind(this);

    this.proxy = function(func){
        var that = this;
        return(function(){
         return func.apply(that,arguments);
        });
    }

    Object.defineProperty(this, "__el",{
        value:handle
    });

};

    Sliderhandle.prototype = Object.create(EvtTarget.prototype,{
        init : {
            value:function(config){

                this.container = $$('div.ui-slider');
                this.track = this.container.getElementsByClassName('ui-slider-track')[0];

                this.value = (config && config.value) || 1;
                this.min = (config && config.min) || 1;
                this.max = (config && config.value) || 1000;
                this.change = (config && config.change) || null; // callback

                this.addEvents("start");
                this.setValue(this.value);

            },
            enumerable:true
        },

        addEvents : {
            value:function(name){
                var list = this.events[name],
                    handler = this[name],
                    all;
                handler = this.proxy(handler);
                for (all in list){
                  this.container.addEventListener(list[all], handler, false);
                }
            },
            enumerable:true
        },
        removeEvents:{
            value:function(name){
                var list = this.events[name],
                    handler = this[name],
                    all;
                //handler = this.proxy(handler);
                for (all in list){
                  this.container.removeEventListener(list[all], handler, false);
                }
            },
            enumerable:true
        },

A: The problem is because there's no event listener same with handler which passed to removeEventListener. this.proxy() generates new function for each call. It returns whole different function object even if you call it with same parameter, although the returned function will do semantically same job.
You should store proxy functions when add, then use that one when remove like this:
var Sliderhandle = function(handle){
    // ....
    this.proxyHandler = {};
}

// ....

addEvents : {
    value: function(name){
        var list = this.events[name],
            handler = this[name],
            all;
        this.proxyHandler[name] = handler = this.proxy(handler);
        for (all in list){
            this.container.addEventListener(list[all], handler, false);
        }
    },
    enumerable:true
},
removeEvents:{
    value:function(name){
        var list = this.events[name],
            handler = this.proxyHandler[name],
            all;
        for (all in list){
            this.container.removeEventListener(list[all], handler, false);
        }
        delete this.proxyHandler[name];
    },
    enumerable:true
},


text:
Q: Spring Integration webservice support I went through some documents relating to Spring Integration WebService support.
I currently have a sample webservice , but is not a spring based webservice.
Can I call this webservice from my sample SpringIntegrtion application or is there any rule that requires a webservice should be a Spring based WebService?

A: Yes, you can easily call the web service using the <int-ws:outbound-gateway/>; the target service does not need to be Spring-based.

A: You can invoke the web services in spring itself. You can read this article for further reference.
Hope this helps.


text:
Q: Equivalence or conversion matrix between .NET 4.0 Async CTP terms and their .NET 4.5 analogs? I am using Async CTP (Version 3) + SP1 to it for developing and testing in Visual Studio 2010 SP1 on Windows XP SP3 mainly because my clients (as well as I) are on Windows XP SP3. See related topics:

*

*on MSDN forum: "If I target .net 4.0 but run on a machine that has .net 4.5 will .net 4.0 WPF bugs still be there?"

*my question on SO: "What are the major risks vs. benefits of using VS2010 Async CTP??"
Let me cite here from Async CTP (Version 3) download page:

Includes a new EULA for production use. Note - This license does not
  constitute encouragement for you to use the CTP for your production
  code. The CTP remains an unsupported and use-at-your-own-risk
  Technology Preview. However, we've received many requests from
  developers to use the CTP for production code, and so have changed
  the license to allow that.

All MSDN docs and code samples online about .NET 4.5 (C# 5.) as well as what is new in them.
Currently, when they fail for my .NET 4.0+VS2010, I am searching through installed with Async CTP <My Documents>\Microsoft Visual Studio Async CTP\Samples for .NET 4.0 + VS2010.  I could not find any a conversion or comparison matrix or a list of differences (changes), between C# 4.0 (.NET 4.0, VS2010) and Async extensions and C# 5.0 (.NET 4.5 + VS 2012) or just articles
Is there any equivalence or conversion matrix between?
What are the known differences?
Related question:

*

*What is the difference between TaskEx.Run() and TaskEx.RunEx() methods


text:
Q: Capture screen -- chrome.desktopCapture.chooseDesktopMedia fails -- PNacl extension I'm trying to use the desktopCapture API in the following manner.
chrome.desktopCapture.chooseDesktopMedia(
            ["screen", "window"], onAccessApproved);

chrome.desktopCapture shows as undefined when I set a breakpoint and inspect it. Permissions in my manifest file are as follows:-
"permissions": ["desktopCapture", "notifications" ]

Common causes for failure of this API are listed here as

*

*a permission is missing in the application's manifest.json file

*the API is defined on a newer version of Chrome then the current runtime
docs inherited from ChromeApi

And I don't have those problems.

*

*My Chrome version is 43.0.2357.124 m

*Pepper version is 43

FYI, I am trying to develop a Chrome extension to capture the screen using PNacl, and have borrowed from the media_stream_video example downloaded from here.  But I haven't even gotten to sending a message to the pexe side yet. I'm still stuck at chrome.desktopCapture.chooseDesktopMedia returning undefined.

A: You need to call chrome.desktopCapture.chooseDesktopMedia from the background script running in the context of the extension. This Sample shows a simple method to use the extension to get screen media.
Keep in mind that this is callback based, so you get access to the stream id from the callback.
This runs in the context of your page (see full example here):
    // check that the extension is installed
    if (sessionStorage.getScreenMediaJSExtensionId) {
        // send a message to your extension requesting media
        chrome.runtime.sendMessage(sessionStorage.getScreenMediaJSExtensionId,
            {type:'getScreen', id: 1}, null,
            function (data) {
                if (data.sourceId === '') { // user canceled
                    // handle error
                } else {
                    constraints.video.mandatory.chromeMediaSourceId = data.sourceId;
                    getUserMedia(constraints, callback);
                }
            }
        );
    }

And this run in the context of your extension (see full example here):
chrome.runtime.onMessageExternal.addListener(function (message, sender, callback) {
    switch(message.type) {
        case 'getScreen':
            var pending = chrome.desktopCapture.chooseDesktopMedia(message.options || ['screen', 'window'],
                                                               sender.tab, function (streamid) {
                // communicate this string to the app so it can call getUserMedia with it
                message.type = 'gotScreen';
                message.sourceId = streamid;
                callback(message);
                return false;
            });
            return true; // retain callback for chooseDesktopMedia result
    }
});


text:
Q: Proving solution to a PDE remains nonnegative. The following problem is taken from Question 3, Chapter 5 of:
D.R. Durran, Numerical Methods for Fluid Dynamics: With Applications to Geophysics,. 1. Texts in Applied Mathematics 32, DOI 10.1007/978-1-4419-6412-0 1
It states the following:
Show that if $ \phi(x, 0) \ge 0 $
, the solution to
$ \frac{\partial \phi(x, t)}{\partial t} + \frac{\partial }{\partial x}(c(x)\phi(x, t)) = 0 $ remains nonnegative for all $ t \ge 0 $. Assume $ c(x) $ and $ \phi(x,t) $ have continuous derivatives to simplify argument. Does the result generalise to 2 and 3 spatial dimenions?
Hint:
For $ \phi(x,t) \lt 0 $, must have a first time  $ t_{0} $ and some point $ x_{0} $ s.t. $ \phi(x_{0}, t_{0}) = 0 $ and $ \frac{\partial \phi(x_{0}, t_{0})}{\partial t} \lt 0 $. Show that this is not possible.
My solution:
$$ \frac{\partial \phi(x, t)}{\partial t} = - c^´\phi(x, t) - c(x)\frac{\partial }{\partial x}\phi(x, t) $$
Evalutating above at $ (x_{0}, t_{0}) $ gives
$ \frac{\partial \phi(x_{0}, t_{0})}{\partial t} = - c(x_{0})\frac{\partial }{\partial x}\phi(x_{0}, t_{0}) $
Thus if $ \frac{\partial \phi(x_{0}, t_{0})}{\partial t} \lt 0 $ must have $ c(x_{0})\frac{\partial }{\partial x}\phi(x_{0}, t_{0}) \gt 0 $
At this point I do not know how to show this inequality. I haven`t used the relation $ \phi(x, 0) \ge 0 $ yet. But I cannot see how this can be used since we are looking for information at time $ t_{0} $, not $ t = 0 $. Furthermore, we know nothing about $ c(x) $.  Presumably I need to prove that if
$ c(x_{0}) \gt 0 $
then
$ \frac{\partial }{\partial x}\phi(x_{0}, t_{0}) \lt 0 $
and if
$ c(x_{0}) \lt 0 $
then
$ \frac{\partial }{\partial x}\phi(x_{0}, t_{0}) \gt 0 $ thus showing that it is impossible to obtain $ \frac{\partial \phi(x_{0}, t_{0})}{\partial t} \lt 0 $.
I have proved that indeed $ \phi(x, t) $ remains nonnegative by the method of characteristics but I wanted to try proving it following the hint. As for the question of whether this result extends to 2 and 3 spatial dimensions; I believe it does but I am struggling to come up with a convincing explanation.

A: If $\dfrac{\partial}{\partial x} \phi(x_0, t_0) > 0$ and $\phi(x_0, t_0) = 0$, then $\phi(x, t_0)<0$ for some $x$ slightly less than $x_0$.  Similarly if
$\dfrac{\partial}{\partial x} \phi(x_0, t_0) < 0$ and $\phi(x_0, t_0) = 0$ with some point $x$ slightly greater than $x_0$.
But the hint isn't quite so obvious as it seems.  For example, $\phi(x,t) = -t^2$ would not have such $x_0, t_0$.

A: If  $ \phi_{x}(x,t) \lt 0 $ then there exists an $ \epsilon \gt 0 $ with $ x_{1} + \epsilon $ such that $ \phi(x_{1},t_{0}) \lt 0 $. However, from the initial condition, $ \phi(x_{1},0) \gt 0 $ thus there must exist a $ t_{1} \in [0, t_{0}) $ s.t. $ \phi(x_{1},t_{1}) = 0 $ which is a contradiction against $ t_{0} $ being the first time s.t. $ \phi(x_{0}, t_{0}) = 0 $.
Similar argument applies for  $ \phi_{x}(x,t) \gt 0 $.
However, I still have not convinved myself for the case of 2 or 3 spatial dimensions where the governing equation is extended to:
$ \frac{\partial \phi(x, t)}{\partial t} + \nabla . (\textbf{c}(x)\phi(x, t)) = 0 $


text:
Q: Getting max record from vertical table and all verticals I have one table called jobs.  Each job gets posted to a certain site so a vertical record is created with the posted date and the site it was posted to.
Here's a basic example of my data
Jobs:

*

*jobid.

*positiontitle.

Posted:

*

*dateposted.

*active.

*jobid.

*sitename.

So I need three pieces of this data in my result set.  The position title, the max dateposted and the list of all the sitenames from the Posted table where active is true.  Does anyone know how I could do this in linq to sql with one query?

A: Something like this might do the trick.
the object with result like this:
public class MyObject
{
    public string positiontitle { get; set; }
    public DateTime? maxDatePosted { get; set; }
    public IEnumerable<string> SiteNames { get; set; }
}

The datetime needs to be of a nullable datetime for it to work. Then the queries like this:
var result=(
        from jobs in db.Jobs
        select new MyObject()
        {
            positiontitle=jobs.positiontitle,
            maxDatePosted=db.Posted
                            .Where(p =>p.jobid==jobs.jobid)
                            .Max(p =>p.dateposted),
            SiteNames=db.Posted
                        .Where (p =>p.jobid==jobs.jobid && p.active==true)
                        .Select (p =>p.siteName)
        }
    ).ToList();

If you want the max dateposted for the active ones as well. Then something like this:
var result=(
        from jobs in db.Jobs
        select new MyObject()
        {
            positiontitle=jobs.positiontitle,
            maxDatePosted=db.Posted
                            .Where(p =>p.jobid==jobs.jobid && p.active==true)
                            .Max(p =>p.dateposted),
            SiteNames=db.Posted
                        .Where (p =>p.jobid==jobs.jobid && p.active==true)
                        .Select (p =>p.siteName)
        }
    ).ToList();

Where db is the linq database context


text:
Q: Force 'Agenda' view in kendo ui Scheduler to display weekly Is there a way to force the Agenda View in Kendo ui scheduler to navigate by week when using the < > buttons in the navigation? Right now the buttons move the Agenda view by day.

A: Simple but working solution:
navigate: function(e) {
    if(e.view === "agenda"){
        if(e.action === "next"){
            e.date.setDate(e.date.getDate() + 6);
        }
        if(e.action === "previous"){
            e.date.setDate(e.date.getDate() - 6);
        }
    }
}

Here is telerik dojo fiddle for you: http://dojo.telerik.com/IrAxO.


text:
Q: (javascript) download SVG containing an image I have a visualization (created with d3) that produces an svg containing an image (xlink:href to the local image).
Is there any way to download this svg and the image it contains as one unit? If I download it as a png, the contained image doesn't appear. If I download it as an svg, the image is there, but displaced in relation to the other svg elements, for some reason.
Right now the only solution I can think of is asking the visualization user to take a screenshot, which is not ideal...


text:
Q: Density of an $n$-dimensional embedded submanifold Let $ M $ be a n-dimensional embedded $ C^1 $ submanifold in $ R^{n+k} $. Let  $ H^n $ be the n-dimensional Haussdorf measure of $ R^{n+k} $. I want to prove that
$$ \lim_{r \rightarrow 0} \frac{H^n(B_r(x)\cap M)}{\alpha(n)r^n}=1 \;\text{ for every } \;x \in M $$
where $ B_r(x) $ is the $(n+k)-$ dimensional ball of $ R^{n+k} $ and $ \alpha(n) $ is the n-dimensional Lebesgue measure of the unit ball of $ R^n $.
The most obvious approach is to use local charts and area formula. But i'm not able to conclude....
Moreover i'm looking for a proof without the use of area formula...
Thanks

A: Let $P$ be the tangent hyperplane to $M$ at $x$. Choose the coordinates on $\mathbb R^{n+k}$ so that $x=0$ and $P$ is the coordinate hyperplane of $x_1,\dots,x_n$. A neighborhood of $0$ in   $M$ can be written as the graph $x_{j}=f_j(x_1,\dots,x_n)$, $j=n+1,\dots,n+k$ where $\nabla f_j(0)=0$.
Consider the orthogonal projection $\pi:M\to P$. It is a $1$-Lipschitz map, therefore it does not increase any Hausdorff measure. Also, the inverse of $\pi$ is
$$(x_1,\dots,x_n)\mapsto (x_1,\dots,x_n,f_{n+1},\dots,f_{n+k})$$
which is $(1+\epsilon)$-Lipschitz, where $\epsilon$ can be made as small as you wish by choosing smaller neighborhood, due to $\nabla f_j=0$.
The above Lipschitz properties imply the following:

*

*$(1+\epsilon)^{-n}\mathcal H^n(E)\le \mathcal H^n(\pi(E))\le \mathcal H^n(E)$ for any set $E\subset M$ contained in the aforementioned neighborhood of $0$.

*$B_{r/(1+\epsilon)}(0)\cap P \subseteq \pi(B_r(0)\cap M)\subseteq B_r(0)\cap P$ for sufficiently small $r$.

From 1 and 2 it follows that
$$\lim_{r\to 0}\frac{\mathcal H^n(B_r(0)\cap M)}{\mathcal H^n(B_r(0)\cap P)}=1$$


text:
Q: Angular component field array is not filled by Observable I have problem with understanding rxjs Observable cooperation with Angular components and their lifecycles (?). I will now describe code pasted below.
I got CartComponent, which holds array of files that have been added to cart.
There is service that provides observables that add or remove files from filesArray (i use checkbox to add/remove). After adding a couple of files to cart, I expected that I would be able to use filesArray in SearchComponent (I used DI). Unfortunately, filesArray is empty in that scope, despite it's content is displayed in cart view properly. I don't understand such behavoir.
Why array is empty and how can I fix that problem? Please help.
CartComponent:

@Component({
  selector: 'app-cart',
  templateUrl: './cart.component.html',
  styleUrls: ['./cart.component.css']
})
export class CartComponent implements OnInit, OnDestroy {
  filesArray: file[] = [];

  constructor(private modalService: NgbModal, private cartService: CartService) {
  }

  open(content) {
    this.modalService.open(content);
  }

  ngOnInit(): void {
    this.cartService.addFileToCart$.pipe(
      takeUntil(this.componentDestroyed)
    ).subscribe(file => {
      this.filesArray = [...this.filesArray, file];
    });

    this.cartService.removeFileFromCart$.pipe(
      takeUntil(this.componentDestroyed)
    ).subscribe(file => {
      const fileIndex = this.filesArray.indexOf(file);
      this.filesArray.splice(fileIndex,1);
    });
  }

  private componentDestroyed: Subject<void> = new Subject();

  ngOnDestroy(): void {
    this.componentDestroyed.next();
    this.componentDestroyed.unsubscribe();
  }

}

SearchComponent:
@Component({
  selector: 'app-search',
  templateUrl: './search.component.html',
  styleUrls: ['./search.component.css']
})
export class SearchComponent implements OnInit {

  constructor(private cartComponent: CartComponent) {
  }

  private checkOrderedFiles() {
    console.log(this.cartComponent.pcFilesArray); //empty
  }

CartService:
@Injectable({
  providedIn: 'root'
})
export class CartService {

  addFileToCart$: Subject<PCFile> = new Subject();
  removeFileFromCart$: Subject<PCFile> = new Subject();

  constructor() { }
}

Checkbox change event handler - I emit values to subjects here:
addOrRemoveFileFromCart(checkbox, item) {
  if(checkbox.checked) {
    this.cartService.addFileToCart$.next(item);
  } else {
    this.cartService.removeFileFromCart$.next(item);
  }
}

EDIT:
public readonly files = this.cartService.addFileToCart$.pipe(
    scan((filesArray: any, file) => [...filesArray, file], []),
    share()
);

template
<div *ngFor="let file of files | async">
  {{file.id}}
</div>

A: Do not use Observables that way in CartComponent.  Instead write:
@Component({
  selector: 'app-cart',
  templateUrl: './cart.component.html',
  styleUrls: ['./cart.component.css']
})
export class CartComponent {
  public readonly files = biscan(
      this.cartService.addFileToCart$,
      this.cartService.removeFileFromCart$,
      (filesArray, file) => [filesArray, file],
      (filesArray, file) => filesArray.filter(f => f !== file),
      []
    ),
    startWith([]),
  );

  constructor(private modalService: NgbModal, private cartService: CartService) {
  }

  open(content) {
    this.modalService.open(content);
  }

}

In the template use files | async wherever you are currently using fileArray.
In other components, use files as an Observable wherever you are currently using fileArray or pcFileArray.
The underlying issue is that checkOrderedFiles is never invoked — if you write code invoking it, that code never knows when fileArray has changed.
Intuitively, you are trying to "escape" from the Observable, to get your changes back into the static world of the component.  That just isn't possible.  Once a calculation is in the asynchronous land of Observables, it stays there.

Unfortunately biscan() (a two-Observable variation of scan) is not currently in the library, but you can write it as
const biscan = (leftObs, rightObs, leftFcn, rightFcn, initialValue) =>
   new Observable(observer => {
     let acc = initialValue;
     // this function must be called *twice* (once for left,
     // once for right) before the observer is completed.
     let complete = () => {
       complete = () => observer.complete();
     };
     const makeSub = (obs, f) => obs.subscribe(v => {
         acc = f(acc, v);
         observer.next(acc);
       },
       e => observer.error(e),
       () => complete()
     );
     const leftSub  = makeSub(leftObs, leftFcn);
     const rightSub = makeSub(rightObs, rightFcn);
     return () => {
       leftSub.unsubscribe();
       rightSub.unsubscribe();
     };
   });

Edit: fixed typos in biscan()

A: I resolved that issue with help of Malvolio (wouldn't figure it out by myself for sure). I post working code below, because i suppose that piece posted had some syntax errors. I was having a problem with async pipe, i believe it's because content of CartComponent template is inside modal. I resolved it by manually subscribing.
export class CartComponent implements OnInit, OnDestroy {
    filesArray;
    private componentDestroyed: Subject<void> = new Subject();

    biscan = (leftObs, rightObs, leftFcn, rightFcn, initialValue) =>
      new Observable(observer => {
        let acc = initialValue;
        let complete = () => observer.complete();
        const makeSub = (obs, f) => obs.subscribe(v => {
            acc = f(acc, v);
            observer.next(acc);
          },
          e => observer.error(e),
          () => complete()
        );
        const leftSub = makeSub(leftObs, leftFcn);
        const rightSub = makeSub(rightObs, rightFcn);
        return () => {
          leftSub.unsubscribe();
          rightSub.unsubscribe();
        };
      });

    public readonly files = this.biscan(
      this.cartService.addFileToCart$,
      this.cartService.removeFileFromCart$,
      (filesArray, file) => {
        filesArray.push(file);
        return filesArray;
      },
      (filesArray, file) => {
        filesArray.splice(filesArray.indexOf(file), 1);
        return filesArray;
      },
      []
    ).pipe(takeUntil(this.componentDestroyed));

    constructor(private cartService: CartService) {}

    ngOnInit(): void {
        this.files.subscribe(files => this.filesArray = files);
    }

    ngOnDestroy(): void {
        this.componentDestroyed.next();
        this.componentDestroyed.unsubscribe();
    }
}


text:
Q: Total Least squares regression without intercept, with R I need to calculate the beta of a regression between two prices with:

*

*No intercept

*Using Total Least Squares estimate

In R there is the function prcomp to perform it.
After it, how can I extract the beta?
the code is
`library(quantmod)
# how to get closes
getCloses <- function(sym) {
    ohlc <- getSymbols(sym, from="2009-01-01", to="2011-01-01",
                       auto.assign=FALSE, return.class="zoo")
    Cl(ohlc)}
# how to import data (2 assets)
closes <- merge(IWM=getCloses("IWM"),
            VXZ=getCloses("VXZ"), all=FALSE)
# function for hedging ratio
tlsHedgeRatio <- function(p, q) {
    r <- princomp( ~ p + q+0)
    r$loadings[1,1] / r$loadings[2,1]
}
# get the hedging ratio
with(closes, {
    cat("TLS for VXZ vs. IWM =", tlsHedgeRatio(VXZ,IWM), "\n")
})`

In the code show how to perform TLS regression with intercept. I trying to perform the same without intercept.
While with lm function, adding +0 allow to perform regression without intercept, how could I do the same with prcompfunction?

A: If R is the matrix that contains the data
pcaresult <- prcomp(R)
eigenVect <- pcaresult$rotation
eigenVal <- (pcaresult$sdev)^2
coeff1 = as.numeric(coeff$eigenvectors[,"PC2"][1])
coeff2 = -as.numeric(coeff$eigenvectors[,"PC2"][2])
ratio = coeff2/coeff1

you can also check the function ?MethComp::Deming (in package MethComp) which gives similar result.


text:
Q: All about (co)algebras for the identity functor Any fact about these would be of interest. Has anyone seen an interesting structure constructed from a monad and comonad based on a single identity functor?
I am working on a very small example just so that I can do all the calculations.  In particular, suppose I have a category with one object that's a set with two elements. The morphisms are all endo-functions of this set. Now take the identity endo-functor and use it to generate a monad and comonad. Next, find the (co)algebra for these. Are these completely trivial?

A: Let's unwind the definition. A monad on the identity functor is just a pair of endomorphisms $\eta$ and $\mu$; the defining identities for a monad are automatically defined.
An algebra for this monad is an endomorphism $h$ such that:

*

*$h \circ h = \mu \circ h$

*$\eta \circ h = 1$

In your problem, the endomorphisms form a group, and so there is a unique algebra $h = \mu$ if $\eta \circ \mu = 1$, and no algebras otherwise.


text:
Q: Eclipse Android - App crashing when starting I just started learning Andriod app development, especially games with eclipse. I recently finished (prematurely) my project, and as soon as i try to run it on my samsung galaxy s4 the app crashes on the phone, saying it stopped. I would be grateful for any help. In the following u will see my LogCat and my Manifest.xml. Thank you. :
this is my LogCat:
07-16 16:12:17.565: E/AndroidRuntime(28886): FATAL EXCEPTION: main
07-16 16:12:17.565: E/AndroidRuntime(28886): Process: com.matinshah.fighter, PID: 28886
07-16 16:12:17.565: E/AndroidRuntime(28886): java.lang.RuntimeException: Unable to     instantiate activity ComponentInfo{com.matinshah.fighter/com.matinshah.fighter.Start}: java.lang.ClassNotFoundException: Didn't find class "com.matinshah.fighter.Start" on path: DexPathList[[zip file "/data/app/com.matinshah.fighter-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.matinshah.fighter-1, /vendor/lib, /system/lib]]
07-16 16:12:17.565: E/AndroidRuntime(28886):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2231)
07-16 16:12:17.565: E/AndroidRuntime(28886):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2363)
07-16 16:12:17.565: E/AndroidRuntime(28886):    at android.app.ActivityThread.access$900(ActivityThread.java:161)
07-16 16:12:17.565: E/AndroidRuntime(28886):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1265)
07-16 16:12:17.565: E/AndroidRuntime(28886):    at android.os.Handler.dispatchMessage(Handler.java:102)
07-16 16:12:17.565: E/AndroidRuntime(28886):    at android.os.Looper.loop(Looper.java:157)
07-16 16:12:17.565: E/AndroidRuntime(28886):    at android.app.ActivityThread.main(ActivityThread.java:5356)
07-16 16:12:17.565: E/AndroidRuntime(28886):    at java.lang.reflect.Method.invokeNative(Native Method)
07-16 16:12:17.565: E/AndroidRuntime(28886):    at java.lang.reflect.Method.invoke(Method.java:515)
07-16 16:12:17.565: E/AndroidRuntime(28886):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
07-16 16:12:17.565: E/AndroidRuntime(28886):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
07-16 16:12:17.565: E/AndroidRuntime(28886):    at dalvik.system.NativeStart.main(Native Method)
07-16 16:12:17.565: E/AndroidRuntime(28886): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.matinshah.fighter.Start" on path: DexPathList[[zip file "/data/app/com.matinshah.fighter-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.matinshah.fighter-1, /vendor/lib, /system/lib]]
07-16 16:12:17.565: E/AndroidRuntime(28886):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:67)
07-16 16:12:17.565: E/AndroidRuntime(28886):    at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
07-16 16:12:17.565: E/AndroidRuntime(28886):    at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
07-16 16:12:17.565: E/AndroidRuntime(28886):    at android.app.Instrumentation.newActivity(Instrumentation.java:1079)
07-16 16:12:17.565: E/AndroidRuntime(28886):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2222)
07-16 16:12:17.565: E/AndroidRuntime(28886):    ... 11 more

This is my Manifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest
 android:versionCode="4"
 android:versionName="1.41"
 package="com.matinshah.fighter"
  xmlns:android="http://schemas.android.com/apk/res/android">
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <application
    android:label="Fighter Chip"
    android:icon="@drawable/ic_launcher"
    android:allowBackup="true">
        <activity
        android:label="Fighter Chip"
        android:name="com.matinshah.fighter.Start">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="com.google.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode" />
    </application>
</manifest>

@Raghunandan This is Start.java:
package com.matinshah.fighter;

import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.preference.PreferenceManager;
import android.view.Display;
import android.view.WindowManager;
import java.io.IOException;
import org.andengine.audio.sound.Sound;
import org.andengine.audio.sound.SoundFactory;
import org.andengine.engine.Engine;
import org.andengine.engine.LimitedFPSEngine;
import org.andengine.engine.camera.Camera;
import org.andengine.engine.options.AudioOptions;
import org.andengine.engine.options.EngineOptions;
import org.andengine.engine.options.RenderOptions;
import org.andengine.engine.options.ScreenOrientation;
import org.andengine.entity.scene.Scene;
import org.andengine.opengl.font.BitmapFont;
import org.andengine.opengl.texture.TextureOptions;
import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlas;
import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlasTextureRegionFactory;
import org.andengine.opengl.texture.region.TextureRegion;
import org.andengine.opengl.texture.region.TiledTextureRegion;
import org.andengine.ui.IGameInterface.OnCreateResourcesCallback;
import org.andengine.ui.IGameInterface.OnCreateSceneCallback;
import org.andengine.ui.IGameInterface.OnPopulateSceneCallback;
import org.andengine.ui.activity.LayoutGameActivity;

public class Start
  extends LayoutGameActivity
{
  private static final int CAMERA_HEIGHT = 512;
  private static final int CAMERA_WIDTH = 288;
  private TextureRegion _bas;
  private TextureRegion _bouton_p;
  private TextureRegion[] _fond;
  private TextureRegion _haut;
  private TextureRegion[] _medaille;
  private TiledTextureRegion[] _player;
  private TextureRegion[] _sol;
  private BitmapTextureAtlas atlas;
  private TextureRegion bouton_s;
  private TextureRegion debut;
  private Sound die;
  Display display;
  private TextureRegion game_over;
  private TextureRegion get_ready;
  private Sound hit;
  private BitmapFont mBitmapFont;
  private Camera m_Camera;
  private TextureRegion noir;
  private TextureRegion nouveau;
  private BitmapFont petit;
  private Sound point;
  private TextureRegion tableau;
  private TextureRegion titre;
  private Sound transition;
  private Sound wing;

  protected int getLayoutID()
  {
    return 2130903063;
  }

  protected int getRenderSurfaceViewID()
  {
    return 2131034172;
  }

  public void loadGraphics()
  {
    this.atlas = new BitmapTextureAtlas(getTextureManager(), 1024, 1024, TextureOptions.NEAREST);
    this._fond[0] = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.atlas, getAssets(), "gfx/bg_day.png", 0, 0);
    this._fond[1] = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.atlas, getAssets(), "gfx/bg_night.png", 148, 0);
    this._fond[2] = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.atlas, getAssets(), "gfx/bg_grey.png", 296, 0);
    this._bouton_p = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.atlas, getAssets(), "gfx/boutonplay.png", 589, 0);
    this.bouton_s = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.atlas, getAssets(), "gfx/rate.png", 699, 0);
    this._sol[0] = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.atlas, getAssets(), "gfx/sol.png", 0, 518);
    this._sol[1] = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.atlas, getAssets(), "gfx/sol_gris.png", 323, 518);
    this._haut = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.atlas, getAssets(), "gfx/obs_haut.png", 817, 0);
    this._bas = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.atlas, getAssets(), "gfx/obs_bas.png", 874, 0);
    this.titre = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.atlas, getAssets(), "gfx/titre.png", 0, 763);
    this.noir = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.atlas, getAssets(), "gfx/noir.png", 720, 80);
    this._player[0] = BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(this.atlas, getAssets(), "gfx/jaune.png", 592, 80, 3, 1);
    this._player[1] = BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(this.atlas, getAssets(), "gfx/rouge.png", 592, 112, 3, 1);
    this._player[2] = BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(this.atlas, getAssets(), "gfx/bleu.png", 592, 144, 3, 1);
    this._player[3] = BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(this.atlas, getAssets(), "gfx/vert.png", 592, 176, 3, 1);
    this._player[4] = BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(this.atlas, getAssets(), "gfx/rose.png", 592, 208, 3, 1);
    this._player[5] = BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(this.atlas, getAssets(), "gfx/orange.png", 592, 240, 3, 1);
    this._player[6] = BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(this.atlas, getAssets(), "gfx/nul.png", 592, 272, 3, 1);
    this.game_over = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.atlas, getAssets(), "gfx/game_over.png", 0, 816);
    this.debut = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.atlas, getAssets(), "gfx/debut.png", 247, 768);
    this.get_ready = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.atlas, getAssets(), "gfx/get_ready.png", 0, 864);
    this.tableau = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.atlas, getAssets(), "gfx/tableau.png", 0, 636);
    this._medaille[0] = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.atlas, getAssets(), "gfx/bronze.png", 720, 130);
    this._medaille[1] = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.atlas, getAssets(), "gfx/argent.png", 720, 180);
    this._medaille[2] = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.atlas, getAssets(), "gfx/or.png", 720, 230);
    this._medaille[3] = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.atlas, getAssets(), "gfx/platine.png", 720, 280);
    this._medaille[4] = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.atlas, getAssets(), "gfx/rien.png", 720, 330);
    this.nouveau = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.atlas, getAssets(), "gfx/new.png", 720, 380);
    this.atlas.load();
    this.mBitmapFont = new BitmapFont(getTextureManager(), getAssets(), "font/fin.fnt", TextureOptions.NEAREST);
    this.mBitmapFont.load();
    this.petit = new BitmapFont(getTextureManager(), getAssets(), "font/petit.fnt", TextureOptions.NEAREST);
    this.petit.load();
  }

  public int loadSavedPreferences()
  {
    return PreferenceManager.getDefaultSharedPreferences(this).getInt("best", 0);
  }

  public void loadSounds()
    throws IOException
  {
    this.wing = SoundFactory.createSoundFromAsset(getSoundManager(), getApplicationContext(), "mfx/wing.ogg");
    this.point = SoundFactory.createSoundFromAsset(getSoundManager(), getApplicationContext(), "mfx/point.ogg");
    this.hit = SoundFactory.createSoundFromAsset(getSoundManager(), getApplicationContext(), "mfx/hit.ogg");
    this.die = SoundFactory.createSoundFromAsset(getSoundManager(), getApplicationContext(), "mfx/die.ogg");
    this.transition = SoundFactory.createSoundFromAsset(getSoundManager(), getApplicationContext(), "mfx/transition.ogg");
  }

  public Engine onCreateEngine(EngineOptions paramEngineOptions)
  {
    return new LimitedFPSEngine(paramEngineOptions, 60);
  }

  public EngineOptions onCreateEngineOptions()
  {
    this.m_Camera = new Camera(0.0F, 0.0F, 288.0F, 512.0F);
    EngineOptions localEngineOptions = new EngineOptions(true, ScreenOrientation.PORTRAIT_FIXED, new CropResolutionPolicy(288.0F, 512.0F), this.m_Camera);
    localEngineOptions.getAudioOptions().setNeedsSound(true);
    localEngineOptions.getRenderOptions().setDithering(true);
    this.display = getWindowManager().getDefaultDisplay();
    return localEngineOptions;
  }

  public void onCreateResources(IGameInterface.OnCreateResourcesCallback paramOnCreateResourcesCallback)
    throws IOException
  {
    if (this.display.getHeight() / this.display.getWidth() < 1.61D) {
      this.m_Camera.setCenter(144.0F, 220.0F);
    }
    this._player = new TiledTextureRegion[11];
    this._medaille = new TextureRegion[5];
    this._sol = new TextureRegion[2];
    this._fond = new TextureRegion[3];
    loadGraphics();
    loadSounds();
    paramOnCreateResourcesCallback.onCreateResourcesFinished();
  }

  public void onCreateScene(IGameInterface.OnCreateSceneCallback paramOnCreateSceneCallback)
    throws IOException
  {
    paramOnCreateSceneCallback.onCreateSceneFinished(new MenuScene(this._player, this._fond, this._sol, this._haut, this._bas, this._bouton_p, this.wing, this.point, this.hit, getVertexBufferObjectManager(), this.mBitmapFont, this.mEngine, this.bouton_s, this.game_over, this.get_ready, this.tableau, this.die, this.transition, this.titre, this.bouton_s, this, this.noir, this._medaille, this.debut, this.petit, this.nouveau));
  }

  public void onPopulateScene(Scene paramScene, IGameInterface.OnPopulateSceneCallback paramOnPopulateSceneCallback)
    throws IOException
  {
    paramOnPopulateSceneCallback.onPopulateSceneFinished();
  }

  public void savePreferences(int paramInt)
  {
    SharedPreferences.Editor localEditor = PreferenceManager.getDefaultSharedPreferences(this).edit();
    localEditor.putInt("best", paramInt);
    localEditor.commit();
  }
}

A: You have got the reference to your first class wrong in the manifest hence a classnotfoundexception is created. Make sure that you reference the right path totally accurately.


text:
Q: Why does one can here not apply the optional sampling theorem?(Brownian motion, first time hitting one) Let $B$ be a standard brownian motion  and let $T=\inf\{t\ge 0 \mid B_t\ge 1\}$.
Now we have $E(B_0)=0$, but $ E(B_T)=1$, i.e. the optional sampling theorem can't be applied. The only issue could be that $T$ is not bounded, but actually it is, since $P(T<\infty)=1$ or where is the error?
Any comments/help on this are welcome!

Theorem: Let $X$ adapted and right countinuous. Then $X$ is a martingale iff $E(X_T)=E(X_0)$ for all bounded stopping times $T$.


text:
Q: How do I overload the + operator to add 2 objects of same class (each with 3 numbers) to create 1 object with all 6 numbers? I am currently doing a programming project where I have declared 2 objects of a class called Statistician. The objects are called s1 and s2. Each object uses a function to read in 3 values of type double into the sequence. Then, for each sequence I compute and print results for: length of sequence, last number entered, sum of sequence, arithmetic mean, smallest number, largest number (each computation has it's own function, which returns the value.
I am currently trying to overload the + operator so that I can add both sequences (each with 3 numbers) together, into a 3rd class object which will have all 6 values. Then, I hope to be able to perform the computations I listed above on this new class. How do I overload the + operator to perform this task?
What I have so far:
Statistician operator +(const Statistician&)
{
//Postcondition: the sum of all numbers in sequences s1 and s2 is returned
}

Also, I have been told that I should make this a friend function to have access to variables I declared in the class. How do I declare the friend function correctly so it has access to do this?

A: You should just look up the Internet (using your preferred search engine) to figure out how a friend function is declared: http://en.cppreference.com/w/cpp/language/friend
class Statistician
{
   friend Statistician operator+(const Statistician&, const Statistician&);
   // other stuff
}

Furthermore, I can only give a skeleton. Would be helpful if you would add your class definition and implementation of Statistician to your question.
Statistician operator+(const Statistician& left, const Statistician& right)
{
    Statistician result;
    // put your code here to add data from "left" and "right" into "result"
    return result;
}


text: Q: Showing suspended (right-censored) data points in diagram (distributed on x-axis) How is it possible to show the suspended (right-censored) datapoints (distributed on x-axis without value for y-axis) in e.g. Probability Plot - Weibull CDF like the green triangles in attached image?


text:
Q: Angular multiple calls to same API in a loop I have a requirement to iterate through an array of objects and make an API call for each object. Based on the number of objects in the response, I'm creating new objects and pushing into an array.  Below is the sample code. For e.g., if there are 2 providers initially and each provider has 2 locations each, updatedProviderList will have 4 providers. This is working fine.
The problem is, updateProvidersInState has to be called only after all the API calls and the logic related to that are done. I have tried with the indices as shown below, but it doesn't work. Any ways to call the updateProvidersInState only after all the API calls are done ?
let providers = []; //assume this is already populated
let updatedProvider;
let updatedProviderList;
providers.forEach((prv, index) => {
  this.dataService.getLocation(prv.id).subscribe((response: LocationResults) => {
    response.locations.forEach((location, i) => {
      updatedProvider = cloneDeep(prv);
      updatedProvider.location = location;
      updatedProviderList.push(updatedProvider);
      if (index === providers.length - 1 && i === response.length - 1) {
        this.updateProvidersInState(updatedProviderList);
      }
    });
  });
});

A: The forkJoin() function allows you join a list of observables and continue once all requests complete. The benefit of this is that the requests will be made in parallel instead of sequentially.
import { forkJoin } from 'rxjs';

let providers: Provider[] = []; // assume this is populated, i made up the type Provider.

forkJoin(
  providers.map(p =>
    this.dataService.getLocation(p.id).pipe(
      // map each Location to a cloned provider object
      map((response: Location[]) => response.map(location => {
        const updatedProvider = cloneDeep(p);
        updatedProvider.location = location;
        return updatedProvider;
      }))
    )
  )
).subscribe((p: Provider[][]) => {
  // flatten the multi-dimensional array
  const updatedProviders = [].concat(...p);

  this.updateProvidersInState(updatedProviders);
});


text:
Q: When I click on one of my new responses in the StackExchange top bar dropdown, the other disappear and I don't know which site to check I am guessing there is a feature I simply don't know about which can get me around the issue I describe in my question: re-stating - sometimes I post to multiple stack exchange sites, say SO and Programmers.  Then replies come in on both.  I see the red circle with a "2" appear and I excitedly click on the first one but don't register what the second one was.  In this scenario it's possible I miss replies.
Is there an easy solution to the issue of my use case here?

A: If you click the Stack Exchange dropdown in the top left of the header, click on "Inbox". Even after the red circle telling you the number of new notifications has disappeared, those events are still listed in the inbox. Simply click on your inbox, and look down the list until you find the event you didn't click on yet. :)
Or, when you first open the global inbox when you have multiple replies, you can right-click each notification and open each one in a new tab, so you'll have them all open when the red circle goes away.

A: You can still re-open your inbox and check the messages, just click on the inbox link in the dropdown available from the little down-arrow next to the Stack Exchange logo:

Alternatively, your Stack Exchange profile also has a global inbox, as part of your profile at https://stackexchange.com/users/171254/aaron-anodide.


text:
Q: Does bind() change the function reference? | How to set permanently?
Possible Duplicate:
Removing event listener which was added with bind

I need to dynamically add and remove event listeners.  I also need to set the this.
Will this change the function reference?
element.addEventListener('click', funcA);
newFunc = funcA.bind(this);
element.removeEventListner('click', newFunc);

Will removeEventListener know that I want to remove funcA?
Or does it think I'm removing a new function all together?

A:
Or does it think I'm removing a new function all together?

Yes, .bind() returns a new function object.


text:
Q: how to get parameter names from an expression tree? I have a expression of this type:
Expression<Action<T>> expression

how do I get the parameters names from this expression (optional: and values) ?
example:
o => o.Method("value1", 2, new Object());

names could be str_par1, int_par2, obj_par3

A: You can get the parameter names from the Parameters property.
For example:
    Expression<Action<string, int>> expr = (a, b) => (a + b).ToString();
var names = expr.Parameters.Select(p => p.Name);  //Names contains "a" and "b"

For the second part, lambda expressions are just uncompiled functions.
Their parameters don't have values until you compile the expression and call the delegate with some values.
If you take the lambda expression i => i.ToString(), where are there any parameter values?

A: The parameters for Method? Get the MethodInfo from the expression (at a guess, MethodCallExpression.Method), and then use MethodBase.GetParameters() to get the parameters. (ParameterInfo has various useful properties, including Name).

A:
How do I get the parameters names from this expression ?

expression.Parameters[0].Name

For your future reference, the documentation is here:
http://msdn.microsoft.com/en-us/library/bb359453.aspx

(optional: and values) ?

This doesn't make any sense to me. Can you explain what you mean by "and values"?

A:
I actually wanted the names of the parameters of the method o => o.Method(par1, par2, par3)

You have some belief that we're psychic, perhaps.
Anyway, moving on.

I actually wanted the names of the parameters of the method o => o.Method(par1, par2, par3)

The name of the first formal parameter is:
(expression.Body as MethodCallExpression).Method.GetParameters()[0].Name

The expression which is the first argument is
(expression.Body as MethodCallExpression).Arguments[0]

For your future reference, the documentation is here:
http://msdn.microsoft.com/en-us/library/system.linq.expressions.methodcallexpression.arguments.aspx

A: Expression<Action<Thing>> exp = o => o.Method(1, 2, 3);
var methodInfo = ((MethodCallExpression)exp.Body).Method;
var names = methodInfo.GetParameters().Select(pi => pi.Name);