HTML Video - Actions OnEnd not Working

Question: I am having trouble getting the onended function to work with my HTML video. It doesnt have to be onended but basically I want a series of things to happen when the video has ended.
Code is as follows:

<button type="button" id="playpause" onclick="playVideo()">Play</button>

<video id="video" width="320" height="240">
    <source src="Video/movie.mp4" type="video/mp4">
    <source src="Video/movie.ogg" type="video/ogg">
    Your browser does not support HTML5 video.
</video>

<textarea id="videoinfo" cols="90">
Click the Play button to start the video.
</textarea>

Thanks for the help
EDIT: I cannot post my own answer for 8 hours with 10 or less reputation, so I have to edit:
After 2 days of trying to get this to work, I post a question on here so I can figure it out. Less than 10 mins later I manage to get it to work.
I used an onEnded function in the <video> tag and linked that to a javascript function called videoEnded().
See below:

Hope this can help someone else out. I have searched for days looking for an answer and nothing would work.
Thanks
Comment: You're adding the ended handler in the button click handler, so the button has to be clicked first before the handler is attached.
Comment: For what I see function videoEnded never gets called, I think you need to add the line I just wrote to you bellow before the button.onclick.
Answer: if(Video.ended)

 // Code when video ends.

EDIT: sorry for don't give any other explanation, but, have you tried by using .addEventListener method instead? and in which Browser do you develop / debug?
Comment: Thanks for your answer. Yes, I have tried using `.addEventListner` but couldnt get anything to fire. I finaly figured it out, by using the `onEnded` function in the `` tag. Check my edit out above. I couldnt answer my own question due to reputation being under 10.

HTML Video - Actions OnEnd not Working


Django reusable application with linked FK?

Question: I have the following scenario.
I have an existing application called 'Contacts' with it's model I have number and name.
I want to create a new application called 'unsubscribe' and I want to make it reusable.
This is my issue:
In the new app called unsubscribe it's model will need a foreign key relationg to the contact number. This now means that it is now tied to 'contacts' and I cannot use it for say my email app. How does Django deal with this from a reusable point of view?
Answer: You can make use of Generic Relations and create a Generic Foreign Key relationship from the unsubscribe model to the contacts model. This allows you to abstract the relationship between your unsubscriptions and other objects, connecting them to any instance of a model in your project.

A normal ForeignKey can only "point to" one other model, which means that if the TaggedItem model used a ForeignKey it would have to choose one and only one model to store tags for. The contenttypes application provides a special field type (GenericForeignKey) which works around this and allows the relationship to be with any model

<code>from django.db import models
from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes import generic

class Unsubscription(models.Model):
    name = ...

    # These two fields allow you to manage the model & instance of object that
    # this unsubscribe model instance is related to
    content_type = models.ForeignKey(ContentType)
    object_id = models.PositiveIntegerField()
    # This gives you an easy way to get access to the actual instance of the
    # instance above
    content_object = generic.GenericForeignKey('content_type', 'object_id')

# On the reverse end of the relationship you can add a Generic relation to
# easily get access to all unsubscriptions related to this contact via the GFK
from myapp.models import Unsubscription
class Contact(models.Model):
    name = ...

    unsubscribtions = generic.GenericRelation(Unsubscribtion)
</code>
Answer: Often it's ok to import models between apps.  This just creates a dependency, something many apps have.  Of course it's more flexible to have your app be independently pluggable, but  the important thing is that you document any dependencies for anyone else trying to use your app(s).
If you really want your app to be pluggable, consider reorganizing your app.  Simplicity is good, but going over-overboard and insisting on strict, literal adherence to principles can get in the way of functionality.
(Without specific details of your app, this is just speculation, but since all the apps you describe  revolve around Contacts, it seems like they could simply be repackaged into the same app with unsubscribe as boolean field in contacts and a view to set the attribute.  And depending on what exactly you want to do with Email, something similar)


Appropriate use of the Tuple Class

Question:
Possible Duplicate:
What problem was the tuple designed to solve?

Could someone please show/describe an appropriate use of the System.Tuple class?
I have looked on MSDN and the description there doesn't show any practical uses.
Comment: The suggestions that appear after you enter the title seem pretty reasonable as well.
Comment: I wish stackoverflows internal searching was better...
Answer: From the MSDN on the 2-tuple:

A tuple is a data structure that has a specific number and sequence of values. The Tuple class represents a 2-tuple, or pair, which is a tuple that has two components. A 2-tuple is similar to a KeyValuePair structure.

In the Tuple<T1, T2> case, It is a generalization of the KeyValuePair<,> data structure.
Tuples are basically generic data structures.  You can use them to avoid defining your own structure.  An example would be for returning multiple values from a function.
It is a very useful tool in function-oriented/functional programming.

Appropriate use of the Tuple Class


Derivatives and Integrals of Polynomials and more.

Question: I noticed that if I had a function $f(x)=x^n$ where $n$ is an integer, then $\lim_{m\to{n^+}}f^{(m)}(x)=n!$ where $f^{(m)}(x)$ is the $m$-th derivative.  Also, $$\lim_{m\to{n^-}}f^{(m)}(x)=\frac{(-1)^n\ln(x)}{n!}$$Where we have $m,n$ as integer numbers.
The limits I use in this question are not limits of the normal sense.  Instead, they are used to describe positives, negatives, and where it is heading.
$\lim_{m\to n^+}f^{(m)}(x)$ means that we are taking the $m^{th}$ derivative of $f(x)$ where we see $n$ is positive.
$\lim_{m\to n^-}f^{(m)}(x)$ means that we are taking the $m^{th}$ anti-derivative (it is negative) where we see $n$ is negative.
There is also a bridge between negative and positive $n$'s when $n$ is not an integer.
Which I though was pretty cool.
So I drew a little picture of what this was with an open circle in the middle for an unknown value at $\lim_{m\to{n}}f^{(m)}(x)$.
Basically, a number line for the powers of polynomials after the $n$-th derivative.  But I noticed something peculiar.
The integral of $\ln(x)$ looks a lot like $x^n$.  In fact, I deduced the following.
Let $g(x)=\ln(x)$$$g^{(-n)}(x)=\frac{x^n[\ln(x)-\sum_{i=1}^n\frac1i]}{n!}$$where the $-n$-th derivative is the $n$-th anti-derivative.
So I got curious and wondered that upon taking derivatives of such a function, I would return back to polynomials in the form $x^n$, but what if I approached this from the other side?  Like we did with polynomials.
We could try to find a sort of bridge, where $n$ was non-integer like we did before.  Then we could try to approach our original point which I will call $g_0(x)$ from the sort of negative side, in a sense that it is opposite of the other side.
My assumption is that it would result in something along the lines of $h(x)\approx x^n\ln^2(x)$ with a lot of extra constants.
But I have no way of proving this because my formula for the $n^{th}$ anti-derivative does not work for negative numbers.
So I hope someone can find this interesting value.
Lastly, if this is so true, then I wondered the opposite.  Why would taking the derivative of a polynomial eventually reach $0$?  If my assumptions are true, the derivatives of a polynomial from the positive side should reach $e(x)=x^ne^x$ (hehe, get it? e comes before f?)
EDIT: It would actually result in something along the lines of $\frac{x^n}{\ln(x)}$
Also, if you can repeat my pattern and find some $h(x)$, then what about an $i(x)$?  Possibly a pattern I can use?
December $25^{th}$
I've also noted that the growth rates of $x^n\ln(x)$ exceed the growth rates of $x^n$.
If my assumptions are correct, then the growth rate keeps increasing.
Again, December $25^{th}$
I've also noticed that the growth rates of $x^n\ln(x)$ are less than the growth rates of $x^{n+a}$, meaning it is a sort of in-between function as far as growth rates.  Is there anything we can conclude on where $x^n\ln(x)$ could exist on a number line with $x^{+n}$ on the left and $x^{-n}$ on the right?
I also can't find what this value $a$ is.
It is clear $x^a\ne\ln(x)$, but for $0<a<1$, we have almost logarithmic growth rates.
Actually, I have just realized that $a=1$.
That is: $$\lim_{a\to1^-}x^{n+a}<<x^n\ln(x)<<x^{n+1}$$ If I am using my symbols correctly.
What does this mean?
What other interesting properties can we deduce?
Comment: Regarding your first line: I don't know very much about fractional derivatives, and correspondingly I'm not entirely sure what the first two limits truly mean. But I'd be surprised if the two limits given did not both converge to the same thing (probably $n!$), presuming one defines the correct idea of convergence for them.
Comment: What you're doing is relatively close to the idea behind Taylor polynomials. Are you familiar with them?
Comment: @ConMan Oh yeah, I am totally familiar with them.  However, I don't see how they answer my question.  I understand your point though with full meaning.  They don't appear to help me though.
Comment: How do you define a derivative of noninteger order?
Comment: @user26977 I can't.  But it seems obvious in the polynomial example on what I am doing.
Comment: @user26977 If you can assist in improving this question, I'd be appreciative.
Comment: I think that $\lim_{m->n+} f^{(m)}(x)$ actually means $f^{n}(x)$
Comment: @user26977 Use \to for arrows.  I can't define $f^{n}(x)$ where $f(x)=x^n$.  So I decided to use limits to describe the left/right side-ness of the derivative/integral.
Comment: I don't understand the first paragraph. Is it a limit of function? Then, how do you define $f^{(2.5)}(x)$?
Comment: @kamil09875 I used limits to *describe* my problem.  I can't think of any other way to put it.  Perhaps I will change it to only integer numbers.
Comment: Please then explain from where you got $\frac{(-1)^n\ln(x)}{n!}$. I can see that $$f^{(0)}=x^n,f^{(1)}=nx^{n-1},f^{(2)}=n(n-1)x^{n-2},...,f^{(n)}=n!,f^{(n+1)}=0,...$$ I can't see where you got $\ln$ from
Comment: @kamil09875 If you integrate $x^n$ where $n$ is a negative integer, that is what you get.  In that, we are using the definition where a negative derivative is an integral.
Comment: @kamil09875 The $\ln$ comes from $\int\frac1xdx=\ln(x)$
Comment: @kamil09875 Please feel free to shoot for an answer.  I don't want my bounty to go to waste and answers are apparently hard to come by.
Comment: @kamil09875 What you have done is basically what I have done.  That is why I have a limit from the positive and negative side, because, interestingly enough, they are different.
Comment: I will include everything in my answer when I come back home in few hours :) your questions make me think hard by the way
Comment: Let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/33442/discussion-between-simple-art-and-kamil09875).
Answer: Part 1
I will start with your first paragraph. You misunderstood the notation of limits. First of all, you don't need limits to express what you mean.
Write down the derivatives of $x^n$ for $n\geqslant0$:
$$\underbrace{x^n}_{0-\text{th}}, nx^{n-1},n(n-1)x^{n-1},...,\underbrace{n!}_{n-\text{th}},...$$
We conclude that the general form of this is
$$\frac{d^k}{dx^k}x^n=\frac{n!}{(n-k)!}x^{n-k}$$ it implies that
$$\frac{d^n}{dx^n}x^n=n!$$
Now consider the case for $n<0$. Of course we need then negative derivatives, exactly as you defined. To make things simpler we do a substitution $m=-n$ to have $m>0$. Then we need a general form of $$\int^k\frac{1}{x^m}\,dx^k$$ where $$\int^k\cdot \;dx^k=\underbrace{\iint\cdots\int}_{k\text{ times}}\cdot\;\underbrace{dx\,dx...dx}_{k\text{ times}}$$
means $k$-th integral (we will skip constants for simplicity). Then we write down few integrals
$$\frac{1}{x^m},\frac{-1}{(m-1)x^{m-1}},\frac{1}{(m-1)(m-2)x^{m-2}},...,\frac{(-1)^{m+1}}{(m-1)!x},\frac{(-1)^{m+1}}{(m-1)!}\ln(x)$$
it follows that $$\int^m\frac1{x^m}\,dx^m=\frac{(-1)^{m+1}}{(m-1)!}\ln(x)$$
We can here define a function $$f(x,n)=x^n$$
and write down our two relations as
$$F(n)=\frac{\partial^n}{\partial x^n}f(x,n)=\begin{cases}
\displaystyle x\mapsto n!&\text{for } n\geqslant 0\\[0.7em]
\displaystyle x\mapsto\frac{(-1)^{n+1}}{(-n-1)!}\ln(x) & \text{for } n< 0
\end{cases}\tag1$$
Of course this is function $\mathbb Z\to\mathcal{C}^\infty(\mathbb R_+)$ but using analysis we are able to expand it to some bigger set. First note that we can expand $n!$ using $\Gamma(n+1)$ (by the way it is the only holomorphic logarithmically convex function satisfying $f(n+1)=n!$). The problem is when facing the $(-1)^{n+1}$ term. The only thing we can do is use the formula
$$(-1)^z=e^{\pi i z}=\cos(\pi z)+i\sin(\pi z)$$ so the function $(1)$ looks like
$$F(n)=\begin{cases}
\displaystyle x\mapsto\Gamma(n+1)&\text{for } n\geqslant 0\\[0.7em]
\displaystyle x\mapsto\frac{-\cos(\pi n)-i\sin(\pi n)}{\Gamma(-n)}\ln(x) & \text{for } n< 0
\end{cases}$$
It turns out that this function is not continuous1 at $n=0$. Function $n!$ tends to $x\mapsto1$ whereas the second one tends to $x\mapsto0$:
$$\lim_{n\to0^-} F(n)=x\mapsto0 \quad\ne\quad x\mapsto1=\lim_{n\to0^+}F(n)$$
You can see the graph here (move the slider $n$ - this is the argument, plot is the value). Keep in mind that I've deleted the imaginary part (by setting $i=0$) to make this visible, but it tends to $0$ anyway.
Part 2
Your formula is correct:
$$\int^n\ln(x)\,dx^n=\frac{x^n(\ln(x)-H_n)}{n!}\tag2$$
Nevertheless no element of this family of functions is close to $x^k$, you can see the plot here.
But you're right. We are able to get back differentiating $\ln(x)$ $n$ times
$$\frac{(-1)^{n+1}}{(n-1)!}\ln(x)\quad\xrightarrow{\text{diferentiate }n\text{ times}}\quad\frac{1}{x^n}\tag3$$
See the pattern for $n$-th derivative of $\ln(x)$:
$$\ln(x),\frac1x,-\frac1{x^2},\frac{2}{x^3},-\frac{3}{x^4},...$$
The general form looks like the following
$$\frac{d^n}{dx^n}\ln(x)=(-1)^{n+1}\frac{(n-1)!}{x^n}$$
And plugging into $(3)$ we get
$$\frac{d^n}{dx^n}\,\frac{(-1)^{n+1}}{(n-1)!}\ln(x)=
\frac{{(-1)^{n+1}}}{{(n-1)!}}\cdot {(-1)^{n+1}}\frac{{(n-1)!}}{x^n}$$
Part 3
In part 2 I said that $(2)$ is not close to $x^k$. One may consider why is that if the limit
$$\lim_{n\to\infty}\left(\ln(n)-H_n\right)$$
converges to a constant. This constant is equal to $-\gamma$ where $\gamma$ is the Euler–Mascheroni constant. Of course it is because $$\ln(n)-H_n\not\equiv\ln(x)-H_n$$
Here is the plot of $(2)$ and $-\gamma x^n/n!$. A different thing is when you consider a function
$$\frac{x^n(\ln(\color{red}{n})-H_\color{red}{n})}{n!}$$
it converges to $-\gamma x^n/n!$ as shown here.
Part 4
You said that
$$\lim_{a\to1^-}x^{n+a}\ll x^n\ln(x)\ll x^{n+1}$$
whereas I am pretty sure you meant
$$x^{n+a}\prec x^n\ln(x)\prec x^{n+1}\tag4$$
where $\alpha\prec\beta\iff\alpha\in o(\beta)$. The notation $\gg$ and $\ll$ is used in approximations and physics and means "much larger/smaller". To check whether $x^{n+1}$ grows faster than $x^n\ln(x)$, consider a limit
$$\lim_{x\to\infty} \frac{x^{n+1}}{x^n\ln(x)}=\infty$$
Indeed, we have $x^{n+1}\succ x^n\ln(x)$. Now the general form
$$L=\lim_{x\to\infty} \frac{x^{n+a}}{x^n\ln(x)}=\lim_{x\to\infty} \frac{x^a}{\ln(x)}$$
When $a=0$ we have of course $L=0$, but when $a>0$ we can use l'Hospital's rule to get
$$L=\lim_{x\to\infty} \frac{ax^{a-1}}{1/x}=\lim_{x\to\infty} ax^a=\infty$$
It means that only $a=0$ satisfies $(4)$.

1 By $F:\mathbb Z\to\mathcal C$ being continuous I mean that for $a,b$ such that $|a-b|$ is infinitesimal, the function $|F(a)-F(b)|$ is bounded by an infinitesimal.
Comment: Could you include a possibility where in **Part 2** we could find what should be the derivative assuming it doesn't reach $\frac1{x^n}$?  What I am asking is where we differentiate, for example, $x^{.5}$ and get $.5x^{-.5}$, making it continuous for anything except at $0$.  Could we do the same with the logarithm?
Comment: Could you also clarify my $n^{th}$ integral of the log?  I want to check my work.
Comment: @SimpleArt added general form of $\ln^{(n)}(x)$ but I can't understand your point of $(\sqrt x)'$.
Comment: While in part 1, we see that the derivative/integral is not continuous at $n=0$, we see it is continuous for all other $n$, even non-integer $n$.  I have also updated my question, you may see the edits at the bottom.
Comment: What I want to do is to make the $n^{th}$ integral of $\ln(x)$ continuous so that we can bypass the part where it becomes the form $x^n$.
Comment: @SimpleArt I will add this to my answer soon
Comment: To be honest, this is the first question that popped into my brain when I learned the integral of $1/x$.
Comment: @SimpleArt added part 3 where I am describing the polynomial approximation
Comment: In part 4, that was my bad.  Thank you for your answer.


C++ Static member function error C2556 overloaded function differs only by return type

Question: I want to write a static member function in my class CountInv, which should  have only this static function and no other members
//Inversions.h
<code>#ifndef INV_H
#define INV_H

#include <string>
#include <vector>

class CountInv
{
    static void count();
}

#endif
</code>
//Inversions.cpp
<code>#include "Inversions.h"

void CountInv::count() {    return; };
</code>
I get the following compiler error :
<code> Error  3   error C2556: 'CountInv CountInv::count(void)' :
overloaded function differs only by return type
from 'void CountInv::count(void)'   d:\...\inversions.cpp   4
</code>
What is wrong? Nowhere have I declared or defined 'CountInv CountInv::count(void)' !! Should I write class c-tors,..,d-tors, or maybe some static data members to return from this function? but this should not be the issue..
Comment: Have you saved the files before building? Are you building with the right files? In the right directory? Have you tried a clean rebuild?
Comment: Files are saved automatically. I've just cleaned and rebuilt solutions -- did not help.
Comment: add **;** to the end of class definition everything's goes fine!
Comment: I forgot the semicolon ; after the class definition in the header file.
Comment: Indeed Oleksandra: if only I knew how many hours I've wasted falling for that old chestnut. Note that Java does not require the `;` to close a class.
Answer: Don't forget the closing semicolon <code>;</code> after your class definition. That I think is causing the obscure compile error.
Comment: Yes it would do! Compilers find it difficult to detect this due to C++ grammar, so the compile errors you get are often very obtuse.
Answer: add ; to the end of class definition everything's goes fine!
Answer: I tried this on my local visual studio and adding semicoln in Inversions.h after class definition solves problem.
Thanks
Niraj Rathi


Using Variables Across Forms - VB

Question: I've got a fairly simple question (I think) on passing variables between forms using Visual Basic.
I've got a program with 2 forms (Form1 and Form2). Form1 has 3 radio buttons, which the user has to select one of and then loads Form2.
Now I've made it so that if radiobutton1 is picked, the Public Variable "radio_select" will equal "radiobutton1", if radiobutton2 is picked, "radio_select" will equal "radiobutton2".
But whenever I try call "radio_select" in my second form, it comes up blank. Why could this be? And how can I fix it.
I've tried using if form1.radiobutton1.checked = true but I keep getting the first radiobutton, regardless of the radio button I've selected.
I think the form is being unloaded, or there is an issue somewhere there, as it appears none of the variables get passed to the second form, once it has been initialized. Also note, the first form is hidden Me.Hide() when the second form is called.
Answer: Have you considered a slight re-design whereby you create a property on Form2 called RadioSelect and then set this from Form1 before showing Form2:
Class Form2
    Public Property RadioSelect As String
    ...
End Class

...

Dim f2 as new Form2()
f2.RadioSelect = "radiobutton2"

f2.Show() ' Or f2.ShowDialog()

This gets you away from an unnecessary public variable and should also ensure Form2 can see what it needs from Form1, or whoever calls it.
Edit:
The following works for me:
Public Class Form1
    Public Test As String

    Private Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click
        Test = "I'm Here"
        Me.Hide()
        Form2.ShowDialog()
    End Sub
End Class

Public Class Form2
    Private Sub Form2_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Text = Form1.Test
    End Sub
End Class

Comment: Hi David, your suggestion seems plausible, but I don't want to create Classes everytime I need a new variable passed between forms. Isn't there a simpler way to do this? Why doesn't just using `Public VariableName As String` Suffice? Why does it not retain its values?
Comment: Where is the public variable declared?
Comment: In Form1. Then I use Form1.VariableName to access it

Using Variables Across Forms - VB


cordova-plugin-purchase: iOS does not do anything even after calling order

Question: We are using Ionic and cordova-plugin-purchase (also known as In App Purchase 2) to implement purchasing subscriptions. Android is working perfectly fine--it's iOS that is giving us a lot of problems.
Calling the order function with the name of the product should show iOS purchase popup and the purchase should just continue as usual.
However, after calling the order function, the subscription product's status becomes requested but nothing happens after that. No pop-ups appear. The weird thing is that, just yesterday, we were able to purchase the product, and after that subscription expired, we were able to purchase it again. It worked just fine. However, today, after the product expired again, clicking the order function just updates the product's status to requested but nothing happens after that. Purchase is also working perfectly fine on Android--it's just iOS that is extremely weird and always producing errors and problems. Sometimes, when we change sandbox accounts and use a new one, it works, but sometimes, it just suddenly stops working.
We tried simplifying the code as much as possible to the point that only these are the important parts:
    // this just automatically sets the validator to the correct URL which changes depending on the user's ID.
    this.subscriptions.add(
      this.status.userData.subscribe(data => {
        this.userData = data;
        this.store.validator = `https://xxxxxxxxxxx/api/app/users/${ data.id }/purchased`;
      })
    );

    this.store.register([
      {
        id: this.MONTHLY_SUBSCRIPTION,
        type: this.store.PAID_SUBSCRIPTION
      },
      {
        id: this.YEARLY_SUBSCRIPTION,
        type: this.store.PAID_SUBSCRIPTION
      }
    ]);

    this.store.error((error) => {
      console.log('ERROR', error);
    });

    this.store.when(this.YEARLY_SUBSCRIPTION).updated((p) => {
      this.yearly = p;
      console.log('yearly', p.state);
    });

    this.store.when(this.MONTHLY_SUBSCRIPTION).updated((p) => {
      this.monthly = p;
      console.log('month', p.state);
    });

    this.store.when(this.YEARLY_SUBSCRIPTION)
        .approved(p => p.verify())
        .verified(p => p.finish())
        .owned(p => this.continue(true, p.id));

    this.store.when(this.MONTHLY_SUBSCRIPTION)
        .approved(p => p.verify())
        .verified(p => p.finish())
        .owned(p => this.continue(true, p.id));

    this.store.refresh();

Calling this.store.order(this.MONTHLY_SUBSCRIPTION); does not do anything. The funny part is calling this.store.order(this.YEARLY_SUBSCRIPTION); does show iOS purchase pop-up. There are no error outputs or anything. We also did try using this.store.autoFinishTransactions = true; before this.store.refresh(); but that didn't seem to do anything.
We have been getting no luck lately and if anyone could offer suggestions or tips on how to fix this (maybe it's an error in the plugin? I did try submitting an issue, but...)
Thank you very much in advance, and I would gladly provide any further information if needed.
Answer: According to the plugin's documentation, store.register() takes an object, not an array. That could be why it is only registering the last product.
store.register({
    id: "cc.fovea.inapp1",
    alias: "full version",
    type: store.NON_CONSUMABLE
});

https://github.com/j3k0/cordova-plugin-purchase/blob/master/doc/api.md#register
Another possibility I can think of is your MONTHLY_SUBSCRIPTION's value may not be matching the Product Id of your In App Purchase item on app store connect.
Comment: This is not true anymore https://github.com/j3k0/cordova-plugin-purchase/blob/master/api/classes/CdvPurchase.Store.md#register


Why do I get attacked by Thalmor Justicars in Skyrim when I have done nothing to offend them as far as I know?

Question: I was out in the wilds of Skyrim when three Thalmor Justicasrs attacked me for no reason and when I looted their bodies I discovered a note entitled Justicar Execution Order that said:

Be on the look out for the Nord called Markus. He is an enemy of the Thalmor, and has actively disrupted our activities and caused great harm. If spotted you are to execute him with extreme hatred.

Why did this happen?
Comment: @JonathanDrapeau Did you link the right question? That one doesn't seem to have any relation to this one.
Comment: @Batophobia Ah, so tangentially related, but not a duplicate.
Comment: Related : http://gaming.stackexchange.com/questions/52128/whos-telling-the-truth-saadia-or-kematu/52130#52130 ... or actually a duplicate
Comment: @SevenSidedDie Correct, though the cited source also states: `Execution Orders are normally issued because of the assault on the Thalmor Embassy in the main questline during the quest Diplomatic Immunity. Thalmor Justiciars that carry a Justiciar Execution Order also appear after attacking and killing any wandering Thalmor agents.`
Comment: @SevenSidedDie Note this quote from the linked answer: "If you accept Kematu's request and help him capture Saadia, **you may encounter a group of Thalmor Justiciars in the wild that carry a Justiciar Execution Order with your race and name**"
Comment: @Batophobia Sounds like the makings of an answer here.
Comment: @sevensideddie Yes the question is different, the answer is totally appropriate. Might not be a duplicate after all but that answer is valid for this question.
Answer: It seems there are a number of reasons you can be spontaneously attacked by Thalmor Justicars.  As the comments have mentioned, it may be related to your actions during the quest In My Time of Need.  The wiki for that quest states:

If Kematu's request is accepted, and the Dragonborn helps him capture Saadia, the Dragonborn may encounter a group of Thalmor Justiciars in the wild that carry a Justiciar Execution Order with the Dragonborn's race and name.

Afterwards, it clarifies when these orders are commonly given:

Execution Orders are normally issued because of the assault on the Thalmor Embassy in the main questline during the quest Diplomatic Immunity. Thalmor Justiciars that carry a Justiciar Execution Order also appear after attacking and killing any wandering Thalmor agents.

The wiki on Thalmor Justicars states:

The Justiciars may also attack immediately if the Dragonborn is wearing an Amulet of Talos.

I suspect that last reason would not include the note you mentioned, but it is another reason why you might be attacked in a seemingly unprovoked manner.
Comment: There must be even more reasons, because none of these were true for me the first time a group attacked me carrying an execution order.
Answer: It's a random event that happens after Level 8. It IS a bit odd that it happens for no reason, but it is just a random event.
Answer: If you help the Gray-Manes in the quest Missing In Action, the Justicars will come for you at some point soon in the future. Even if you never assault Northwatch Keep, simply helping gather the evidence will brand you a wanted man with the Thalmar.
Answer: After completing 'Darkness Returns' main quest for the Thieves guild will also cause the justicar to come after you. I noticed an execution note on one right after I left the Twilight Seplicar. The note stating that I am an enemy and to destroy me with extreme caution and that I'm capable of fending for myself so be carful. So I assume I'm wanted now by them ha ha


DateFormatter with AM/PM returns nil

Question: I know that this topic is fully discussed here and in other forums.
Unfortunately, I still cannot understand why the Date is nil.
Note that when I run the code in the Debugger or in Playground then it works totally fine.
It's something to do with the fact that it runs on the device.
<code>   var dateString = "2019-12-17 3:48:02 PM"
   let dateFormatter = DateFormatter()
   dateFormatter.locale = Locale.current
   dateFormatter.timeZone = TimeZone.current
   dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss a"
   let date = dateFormatter.date(from: dateString) // date is nil
</code>
Comment: Try setting Locale to something that you know supports AM/PM, like "en_US_POSIX" or "en_GB" etc
Comment: The 12 hour format is hh, not HH. See also https://stackoverflow.com/q/40692378/1187415
Comment: Thanks for the reply guys, @MartinR I actually tried it with both HH and hh but it didn't work. I set it up to hh anyway since I'm using 12-hour clock.
Answer: Add en_US as your Locale, like this:
<code>dateFormatter.locale =  NSLocale(localeIdentifier: "en_US")
</code>

DateFormatter with AM/PM returns nil


Showing $\left(\frac{-1+\sqrt{3}i}{2}\right)^3=1$

Question: In my textbook they asked me to show that
$$\left(\frac{-1+\sqrt{3}i}{2}\right)^3=1$$
but this is not true, I think.
I put down
$$\begin{align}
\frac12(-1+\sqrt{3}i)(-1+\sqrt{3}i)(-1+\sqrt{3}i)&=\frac12\left[(1-2\sqrt3i-3)(-1+\sqrt3i\right)]\\
&=\frac12\left[-1+2\sqrt3i+3+\sqrt3i+6-3\sqrt3i\right]\\
&=4\\
\end{align}$$
I checked it twice and I got $4$ what am I doing wrong?
Comment: You didn't cube the denominator
Comment: @DavidPeterson ohhhh thank you!!!
Comment: Also, this is simple with http://en.wikipedia.org/wiki/De_Moivre%27s_formula.
Comment: thank you @vadim123 i will look at it. i don't know what to do with that yet integrator, but i will look into it. i think you want me to use the $x^3$ as $\sqrt3i$ and i have $-1$ already
Answer: HINT: $$\left(\frac{-1+i\sqrt3}{2}\right)=\cos2\pi/3+i\sin2\pi/3=e^{i\frac{2\pi}{3}}$$
Comment: oh i had never seen that, really simple!
Answer:
Now you know your mistake!
  But there is an alternative way to show that

Consider this cubic
$$x^3-1=0$$
$$(x-1)(x^2+x+1)=0$$
By applying quadratic formula to
$x^2+x+1=0$
$$x=\frac{-1- i\sqrt{3}}{2} \quad\text{or}\quad x=\frac{-1+ i\sqrt{3}}{2}$$
Since $x=\dfrac{-1+ i\sqrt{3}}{2}$ is root of $x^3-1=0$ we have
$$\left(\dfrac{-1+ i\sqrt{3}}{2}\right)^3=1$$
Comment: oh that is cool. what is the name of that second step? that is a really cool way to do it thanks!
Answer: $$\left(\frac{-1+\sqrt{3}i}{2}\right)^3=1$$
$$\frac{1}{2^3}(-1+\sqrt{3}i)(-1+\sqrt{3}i)(-1+\sqrt{3}i)=\frac12\left[(1-2\sqrt3i-3)(-1+\sqrt3i\right]$$
$$=\frac18\left[-1+2\sqrt3i+3+\sqrt3i+6-3\sqrt3i\right]$$
Comment: @Integrator it says in $2$ days, but maybe someone will put up a nicer one that is a line or less :)


Can I set a property like $invalid myself?

Question: I would like to set a property (blurred in this case) on an input element, just like AngularJs sets $invalid, $valid etc. on elements.
Is this possible from a directive, and if so, how?
Comment: Did you take a look at my answer below ? Did it work for you ?
Answer: Angular set's properties on the element's controller, not on the element itself.
Controls (e.g. inputs, selects etc) have an NgModelController, while forms/ngForms have a FormController.
The NgModelController is responsible for informing the parent FormController (if any) about changes in properties like $invalid.
The directives that use NgModelController (e.g. input, select etc) are responsible for determining when a value is valid or not and call the appropriate methods of their NgModelController.

For something as simple as setting a property on the controller, you need a directive that gets access to the controller instance (by require-ing it) and you are good to go:
.directive('blurMonitor', function () {
    return {
        restrict: 'A',
        require:  'ngModel',   // to get access to the controller
        link: function postLink(scope, elem, attrs, ctrl) {   // ctrl===NgModelController
            /* Initialize the property */
            ctrl.$blurred = true;

            /* Update the property value on focus */
            elem.on('focus', function () {
                /* Since JS events fire asynchronously and outside
                 * of the "Angular context" we need to call `$apply()` */
                scope.$apply(function () {
                    ctrl.$blurred = false;
                });
            });

            /* Update the property value on blur */
            elem.on('blur', function () {
                /* Since JS events fire asynchronously and outside
                 * of the "Angular context" we need to call `$apply()` */
                scope.$apply(function () {
                    ctrl.$blurred = true;
                });
            });
        }
    };
});

<form name="form1">
    <input type="text" name="text1" ng-model="something" blur-monitor />

Blurred: {{form1.text1.$blurred}}

</form>

See, also, this short demo.


Mysql query is not returning articles with no likes or no comments

Question: Before downvoting, have a look at my question.
I am working on my article website. There is a section on my website where popular articles are shown. The popular articles are based on likes and comments. I am using below query to show popular articles:
<code>select
    s.id as story_id,
    s.title as story_title,
    COUNT(l.id) as total_likes,
    COUNT(cm.id) as total_comments
from
    stories s
right outer join
    likes l
on
    s.id = l.type_id
right outer join
    comments cm
on
    cm.story_id = s.id

group by s.id

order by total_likes desc,total_comments desc
</code>
I am receiving the popular articles but only 5.The articles are showing but there are only 5, I want articles with no likes or comments after the last one Here is a screenshot

Here you can observe that the only articles are shown up who have at least 1 like or comment. I want to get articles with no likes or comments too
Can anyone solve my problem, Thanks in advance?
Answer: This will return also the stories without likes or comments (you should use left join):
<code>  select
      s.id as story_id,
      s.title as story_title,
      COUNT(l.id) as total_likes,
      COUNT(cm.id) as total_comments
  from stories s
  left  join  likes l on  s.id = l.type_id
  left  join comments cm on  cm.story_id = s.id

  group by s.id, s.title
  order by total_likes desc,total_comments desc
</code>
Answer: You've to use left join for this. This should work:
<code> select
      s.*,
      COUNT(l.id) as total_likes,
      COUNT(cm.id) as total_comments
  from stories articles
  left  join  likes l on  articles.id = l.type_id
  left  join comments cm on  cm.story_id = s.id

  group by articles.id, articles.title
  order by total_likes desc,total_comments desc
</code>
Hope it helps


An aggregate function not appear in the set list of an UPDATE statement

Question: <code>UPDATE PSO_UltraCoatRolls
SET TotalInSeries=
COUNT(pd.PINSerialNumber)
FROM PINDetail pd
WHERE pd.PINSerialNumber
BETWEEN (SELECT pr.StratSerial FROM PSO_UltraCoatRolls pr) AND
(SELECT pr1.EndSerial FROM PSO_UltraCoatRolls pr1)
</code>
Comment: *In general*, don't *store* data that you can *compute*. That just leads to the possibility that the stored result is no longer consistent with the base data. If you *do* need to store the computed value, if possible have the database engine do it automatically for you. If you're using e.g. [tag:sql-server], then an indexed view would seem appropriate here.
Comment: Tag dbms used! (That UPDATE - FROM syntax is not ANSI SQL compliant.) Or do you perhaps want `UPDATE t SET c = (SELECT... )`?
Answer: It seems you are missing the key word SELECT before  Count(pd.PINSerialNumber)


Using charAt() to change a char array

Question: I'm utterly boggled as to why charAt() works in some scenarios but not others. I am doing exercises while learning Java and one of them was to take a string, and return it in reverse order.
My working code:
public String reverseString(String tempStr){
    int initialindex = tempStr.length()-1;
    int reverseindex = 0;
    char tmp;
    char[] array = new char[tempStr.length()];

    for(int tempchar : array){
        tmp = tempStr.charAt(initialindex);
        array[reverseindex] = tmp;
        initialindex--;
        reverseindex++;
    }
    String returnstr = new String(array);
    return returnstr;
}

The problem I ran into is using the following for statement prints gibberish:
for(int tempchar : array){
    array[reverseindex] = tempStr.charAt(initialindex);
    initialindex--;
    reverseindex++;
}

There were perhaps a dozen different variants of using while loops, standard for loops and a few other versions of code that were ugly and didn't work. Why did my making a char tmp field, putting the inspected characrer in said field, and then using said field to enter the data into an array work?
Also, why am I unable to just return the string using return array.toString();?
Edit: I'm using the latest Eclipse I downloaded today, switched from netbeans.
Answer:
I copied your code into my editor and it performed fine using either version, with tmp field or without. You must have made some other error using the other method.
Java doesn't support pretty .toString() for arrays; any object which does not override toString will produce the hashCode of the object rather than the contents/fields of the object, and arrays are no exception here. Whilst it might seem sensible for character arrays, the same operation on an int array would produce nonsense; See the difference between Arrays.toString() and String.valueOf(array). In this case, you probably want to use the String.valueOf method.
Comment: Hmmm...I tried the other method and I am irked. It works now. In regards to the second answer, I had the value `[C@3956f14c` returned. Is that the hashCode of the object you mentioned?
Comment: Depending on the implementation, Object.toString()'s default function will return `this.getClass().getName() + '@' + Integer.toHexString(this.hashCode());` (or some similar variant). So I guess in this case, `[C` is 'array' (because they're kind of a special object) and `3956f14c` is the hashcode
Answer: As a hint to get you started: if you want to convert a char array into a String use the String constructor that takes a char array.
Update: I see you already did that in your edit. Does it work as expected now?
Your loop looks a little bit weird since you never use your loop variable. you could try this:
char[] initialArray = initialStr.toCharArray();
char[] array = new char[tempStr.length()];

for(int srcIndex = 0, destIndex = array.length-1; destIndex >= 0; srcIndex++, destIndex--) {
    array[destIndex] = initialArray[srcIndex];
}

Comment: Yeah, I should have used it. But at the time I felt like hammering a square peg in a round hole, so I just used blunt force to get it done. Bad practice, but my patience was wearing thin for a seemingly simple problem.
Answer: The array.toString() return string representation of the object. You need to use char[] constructor of String new String(array) to create String from the char[].
Answer:    public String reverse(String str)
        {
            if(str == null)
            {
               return null;
             }
           byte[] byteArray=  str.getBytes();
           int arrayLastIndex = byteArray.length -1 ;

           for(int i=0 ; i < byteArray.lenght/2: i++)
           {
              byte temp = byteArray[i];
              byteArray[i] = byteArray[arrayLastIndex -i ]
              byteArray[arrayLastIndex - i] = temp;
           }

           return new String(byteArray);
        }

Using charAt() to change a char array


Docker compose nginx permissions problem using fedora and podman

Question: I am trying to create a boilerplate project with docker, php & nginx.
After I run build & up commands, I'm trying to access localhos:8080 (my exposed port on nginx), but I get this error in logs:

[crit] 24#24: *1 open() "/var/www/app/public/" failed (13: Permission
denied), client: 127.0.0.1, server: api.boilerplate.local, request:
"GET / HTTP/1.1", host: "localhost:8080" 2020/11/21  [error] 24#24: *1
connect() failed (111: Connection refused) while connecting to
upstream, client: 127.0.0.1, server: api.boilerplate.local, request:
"GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9001", host:
"localhost:8080"

This is my docker-compose.yml:
version: "3.8"
services:
  db:
    image: mysql
    command: ["--default-authentication-plugin=mysql_native_password"]
    restart: unless-stopped
    ports:
      - 3306:3306
    env_file:
      - ${PATH_CORE}/.env
    volumes:
      - mysql:/var/lib/mysql
    networks:
      - backend

  api:
    build: ${PATH_CORE}/docker/api
    restart: unless-stopped
    depends_on:
      - db
    env_file:
      - ${PATH_CORE}/.env
    volumes:
      - ${PATH_CORE}:/var/www/app
    networks:
      - backend
      - frontend

  nginx:
    build: ${PATH_CORE}/docker/nginx
    restart: unless-stopped
    depends_on:
      - api
    ports:
      - 8080:80
    volumes:
      - ${PATH_CORE}/public:/var/www/app/public
    networks:
      - backend

volumes:
  mysql:

networks:
  frontend:
  backend:

This is my nginx Dockerfile:
FROM nginx:alpine

COPY nginx.conf /etc/nginx/
COPY default.conf /etc/nginx/conf.d/default.conf

RUN apk add shadow && set -x && usermod -u 1000 nginx && groupmod -g 1000 nginx

WORKDIR /etc/nginx/

EXPOSE 80 443

And default.conf file:
server {
    listen 80;
    server_name api.boilerplate.local;
    root /var/www/app/public;

    location / {
        try_files $uri @rewriteapp;
    }

    location @rewriteapp {
        rewrite ^(.*)$ /index.php/$1 last;
    }

    location ~ ^/index\.php(/|$) {
        fastcgi_pass api:9001;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param HTTPS off;
        internal;

    }

    # return 404 for all other php files not matching the front controller
    # this prevents access to other php files you don't want to be accessible.
    location ~ \.php$ {
     return 404;
    }

    error_log /var/log/nginx/error.log;
    access_log /var/log/nginx/access.log;
}

What do I do wrong?
PS: I'm using Fedora and podman
Answer: Your nginx container fails to bind to the port 80 as this is a privileged port and requires a super user rights. Simply change the port number to 8080 and update the compose file to match the new port mapping.
And note, that you need to adjust selinux settings when passing volumes on selinux enabled systems.


OpenIddict 4 WebProviders does not configure external authentication schemes

Question: I am just wondering if anyone has some experience with this. I am trying out OpenIddict 4.0.0 to put together a real-life solution with the new Identity UI and razor pages approach. However when I register an external auth provider using the suggested unified OpenIddict.Client.WebIntegration package, I cannot see the providers on the default login page external section.
I also tried to use the openiddict-core sandbox aspnet.core server app but that as well does not show the configured GitHub external login option.
I could explicitly create links for the providers, however I do not see that as a convenient solution. The default code segment that calls SignInManager.GetExternalAuthenticationSchemesAsync() does not seem to collect the external providers registered using
options.UseWebProviders().UseGitHub() ...

What am I missing here? Thanks
Answer: Edit: to improve interoperability, a native authentication scheme forwarding mechanism was added to the OpenIddict client in 4.7.0: OpenIddict providers are now automatically returned by SignInManager.GetExternalAuthenticationSchemesAsync() and listed by the default UI.
See https://github.com/openiddict/openiddict-core/releases/tag/4.7.0 for more information.

It's a deliberate design choice, explained in [this post comparing the aspnet-contrib providers with the OpenIddict providers](https://github.com/aspnet-contrib/AspNet.Security.OAuth.Providers/issues/694#issue-1280661329):

The aspnet-contrib providers use an authentication scheme per
provider, which means you can do [Authorize(AuthenticationSchemes = "Facebook")] to trigger an authentication dance. In contrast, the
OpenIddict client uses a single authentication scheme and requires
setting the issuer as an AuthenticationProperties item if multiple
providers are registered.
For the same reason, the providers registered via the OpenIddict
client are not listed by Identity's
SignInManager.GetExternalAuthenticationSchemesAsync() and so don't
appear in the "external providers" list returned by the default
Identity UI. In practice, many users will prefer customizing this part
to be more user-friendly, for instance by using localized provider
names or logos, which is not something you can natively do with
SignInManager.GetExternalAuthenticationSchemesAsync() anyway.
Comment: It makes total sense now, thanks for the link, I missed that part.


How does dueling work in Red Dead Redemption?

Question: I missed the instructions during my first duel, but I didn't really worry about it since I just shot a lot at the guy's head, and he died.  Many duels went the same way...I could shoot the opponent easily.  But during tougher duels, that doesn't work.  It seems like you have to have your meter on the right end up higher than your opponents meter...but it's not clear to me exactly how the meter works.  And the one bit of advice I remember the game giving me, to "not draw too quickly, because my shots would be inaccurate" or something, doesn't seem to make any sense, since I can manually control where the shots go.
What is the secret to a successful duel?
Comment: yeah i have the same doubt to me it just looks like its completely random
Answer: I had trouble with dueling too. Perhaps try shooting where your crosshair lights up red. Also wait until dead-eye automatically engages and it tells you to draw. (?)
You can also try disarming the guy by shooting him in the hand. Some people, usually story related, cannot be disarmed, as such aiming for the hand will only get you killed instead, which can be frustrating.
Rockstar discussed it a little here, hopefully this is helpful: http://www.rockstargames.com/newswire/article/5991/rockstar_game_tips_dueling_like_a_pro_in_red_dead_redemption.article
Comment: That link was actually quite useful! I knew you had to fill the bar.. but I had no idea how it worked.. I never noticed the aim changing color!!!
Answer: As an addendum to Teebery's 4 points:
5.. Every trigger pull increases your duel meter, which needs to be higher than the other guy's to win.
6.. You get more duel meter off some parts of the body than others -- like head or gun hand. You also get more from a white crosshair than red.
7.. Shooting the opponent's gun hand will often instantly end the fight. The opponent will remain alive, be disarmed, and you'll get significantly more Fame points.
Answer:
Don't pull your gun until the "draw" command.
Put the cross hair on a fatal part of the body (chest is easiest).
Wait until the cross hair turns white and then fire.
Repeat until he dies.
Answer: You have to do a couple of things to correctly duel. First, when it says draw, you need to pull down on the stick until John grabs his gun. Then, line up the crosshairs until they turn white, the enemies gun hand or head arethe easiest, and fire. I recommend NOT using a pistol but a revolver for a duel. Most duels you have to go to the starting point to initiate the duel. Switch to a revolver. In the little that I dueled with the semi-auto or the mauser, since they can hold quite a few bullets, they take a bit longer to fire.
Comment: Red means DEAD.


How to force installation of standard-width blinds for window with nonstandard dimensions?

Question: I want to install blinds on a window that has a 27.5-inch width. But it looks as though 27.5inches is not a standard width; it's easy to find widths of 23, 27, 29, 30, I don't see 27.5 inch blinds anywhere. I did just find these 27 inch blinds, however. Is there a DIY way to customize 27 inch blinds so that they can be installed on a 27.5-inch wide window?
Alternatively, would buying 28-29 inch blinds, and sawing them down to 27.5 inches work?
Please remember to keep answers specific to the problem at hand. Thanks.
Answer: Those 27 inch blinds you link to are top mount and will fit in a 27.5 inch opening without modification. But there are also side mount ones that would also work but you would need to add a 1/4 inch shim to both sides or a 1/2 inch shim to one side.
Most blinds can't be simply cut down in width except those that are designed to be cut to length.
Comment: I see unfinished wood shims are available, but the color would contrast with my white walls. What about plummer's putty?


DNF conversion of this statement

Question: How to convert this to DNF?
$(x\lor{\neg{y}\lor{z}})\land{(\neg{x}\lor{\neg{z}})}$
I have tried de morgans and have got no where. I'm pretty sure its the distributive law but cant work out the steps to get in the form to do that.
Comment: Hello and welcome to MSE! Can you show your progress so far and where do you get stuck?
Comment: Ah i see, i can just distribute each element on the LHS as its just  a single term all different from the RHS
Comment: Yes, use distributive law to get the DNF, and apply Consensus theorem to get the Minimal DNF, if you attempted, but still don't get it, please show your work (edit the question) and tell us where you don't understand.
Comment: But in the form its in , I cannot apply the distributive law.
Comment: There are two directions to apply distributive law, if you can't distributive any term out, try distributive in.
Answer: I never heard of DNF before, looked it up here. I take it you just want the simplest boolean out of this.
This is a case that works like distributive multiplication of two sums.
$$(x\lor{\neg{y}\lor{z}})\land{(\neg{x}\lor{\neg{z}})}\\
=x(\neg x\lor \neg z)\lor \neg y(\neg x\lor \neg z)\lor z(\neg x\lor \neg z)\\
=(x\neg x \lor x\neg z)\lor (\neg y\neg x \lor \neg y\neg z)\lor z\neg x \lor z\neg z)\\
$$
If there were no mistakes in this expansion, the Veitch diagram below helps with the solution. For shorthand, a slightly different notation is used. Note that hte conditions $x\neg x$ and $z\neg z$ cannot exist so they are to be ignored.

DNF conversion of this statement


A game played on graphs by "flipping" the state of a vertex and its neighbors

Question: This is a well-known game: We are given a finite undirected graph $G=(V,E)$ whose vertices are labeled by "0". At each turn, we pick a vertex, and then it and all its neighbors flip their label (0 becomes 1, 1 becomes 0). The goal is to reach a state where all labels are 1.
Although this is a known game, I don't know how it's called.
I know that the game is always solvable, regardless of the graph; I wish to know as many proofs to this fact as possible. I'm most interested in constructive proofs which are simple to program.
Comment: http://en.wikipedia.org/wiki/Lights_Out_(game)  -- David Radcliffe had a nice write up of this somewhere, but I can't find it.  A very related, perhaps equivalent game is called "chip firing" and you'll find lots of combinatorics papers talking about that, as it happens to give an algebraic structure to set of spanning trees of the graph.
Answer: A constructive proof uses the following Lemma:

Lemma: If $G(V,E)$ is an undirected, connected, graph, the vertex set $V$ can be partitioned into two sets $V_1$ and $V_2$ such that in
  the two subgraphs induced by $V_1$ and $V_2$, the degree of each
  vertex is even.

To use this lemma to your problem, suppose $H$ is your given graph and suppose $H$ has at least one vertex of even degree. We add a new vertex $O$ and make it adjacent to each such vertex. If there is no vertex of even degree, we do nothing. Every vertex (except possibly $O$) is of odd degree in the new graph.
This new graph has a partition $V_1,V_2$ according to the above Lemma. Pick the partition which does not contain $O$ (say $V_1$) as your flipping set. Since any vertex in $V_1$ is incident to an even number of vertices in $V_1$, they flip, and since any vertex in $V_2$ (except possibly $O$) is incident to an odd number of vertices in $V_2$, they flip too.
The lemma has an inductive proof (which can be converted to an algorithm).
Proof of Lemma:
We proceed by induction on $|V|$. Bases cases are easy to verify.
Suppose $G(V,E)$ is an undirected connected graph with $|V| = n+1$.
If all vertices of $G$ are of even degree, we are done by taking $V_1 = V$ and $V_2 = \emptyset$
Suppose $v$ is a vertex with odd degree, whose neighbours are $v_1, v_2, \dots, v_k$.
Form a new graph $G'$ as follows:
If $v_i$ and $v_j$ are adjacent in $G$, delete the edge joining them. If $v_i$ and $v_j$ are not adjacent in $G$, add a new edge joining them.
Delete $v$.
Apply induction hypothesis to $G'$, say getting $V'_1$ and $V'_2$. One of $V'_1$, $V'_2$ must contain an even number of $v_i$, say $V'_1$.
It is easy to verify that the partition of $G$ we are looking for is $V_1 = V'_1 \cup \{v\}$ and $V_2 = V'_2$.
$\square$
The above inductive proof can be used to give an $\mathcal{O}(|V|^3)$ time algorithm, I believe. (Of course, the linear algebra way of solving this specific lights out might give the same). Perhaps a better/clever representation/way can make it sub-cubic.
There is also an elegant Linear algebra (existential) proof due to Noga Alon, which shows that the diagonal vector (making a vector out of the main diagonal) of an $nxn$ matrix $A$ over $\mathbb{F}_2$ is in its row space.
Both the proofs (the above writeup and the Linear Algebra Proof by Noga Alon) can be found in the book: "Combinatorial Problems and Exercises" by Laci Lovasz.
Comment: Very cool problem and proof!  Just wanted to point out, in case this confuses anyone else, is in the passage " since any vertex in $V_2$ (except possibly $O$) is incident to an odd number of vertices in $V_2$, they flip too", the second $V_2$ should be a $V_1$.


c++ - COM object that has been separated from its underlying RCW cannot be used

Question: My problem is the error message in the title:
COM object that has been separated from its underlying RCW cannot be used.

I have tried to google it, but i could find only solutions related to destructors/releasing objects.
It is not something i want to do.
First, here is my code:
String^ filename="c:\\wb.xlsx";
Microsoft::Office::Interop::Excel::Application^ exApp= gcnew Microsoft::Office::Interop::Excel::ApplicationClass();
exApp->Visible=false;
exApp->Workbooks->Open(filename, 2, true, Type::Missing, Type::Missing, Type::Missing, true, Type::Missing, Type::Missing, Type::Missing, Type::Missing, Type::Missing, Type::Missing, Type::Missing, Type::Missing);
Worksheet^  exWss;
for (int x = 0; x <= checkedListBox1->CheckedItems->Count - 1; x++){
    for (int p=0; p<checkedListBox1->Items->Count; p++){
        if (checkedListBox1->CheckedItems[x]->ToString()->Equals(checkedListBox1->Items[p]->ToString())){
            p++;
            exWss  = safe_cast<Worksheet^> (exApp->ActiveWorkbook->Sheets[p]);
        }
    }
}

In short: i have a checkedlistbox, this part of code is ran when the necessary stuff have been selected. In the checkedlistbox the different sheets of the Excel workbook are listed. I am trying to select the sheet from the workbook according to the selected item in the checkedlistbox.
At the last code line (exWss  = safe_cast (exApp->ActiveWorkbook->Sheets[p]);) I get the mentioned error message.
I have seen that Marshal releasing can cause such problems. In another function although i run Marshal.Releasecomobject, but it is completely separated, and i get the same error without it also.
Any ideas would be appreciated.
Answer: It seems for some reason the 'for' block separates completely the Interop object from the rest of the code. I managed to solve the problem by initializing the Interop object within the 'for' block.
(I have introduced a bool variable, indicating if the workbook has been opened already - if it is false, it opens it within the 'for' block - otherwise it continues)
Interestingly however the object is accessible out of the 'for' block without a problem. I am sure there is an explanation for that, that i do not know - I am newbie, hobby programmer only.


Ground wires absent from circuits exiting apartment panel

Question: I'm taking a look at the (only) panel in my apartment (7 apartments in building, NYC) and I'm noticing that out of all the circuits leaving the panel, not a single one of them contains a ground wire. Only hot(s) and neutral. On closer inspection I can see the ground wire coming in through the top, it connects to the ground bar, but there are no other wires attached to the ground bar.
The 120v circuits leave the panel with just a hot and a neutral and the 240v circuits exit in bunches of 2 hot and 1 neutral.
Are all these circuits ungrounded? Is it likely or possible that these circuits get their ground from somewhere else that is not the panel in my apartment? Are these circuits meeting up with ground each on their own somewhere on the way to the outlets or is it another common point?
Comment: Is your house wired in conduit by any chance?  The conduit itself is a valid ground conductor, so in that case there won't be any actual ground wires, but everything will still be grounded.
Comment: That work is so beautifully done that if I was an electrical inspector, and I saw something in this panel that didn't meet code, I'd assume that the panel was correct and I was misreading the code.
Comment: @GeorgeAnderson, photos added. It is difficult to see above the panel through the crack in the drywall for me to know the presence/absence of conduit. The apartment is in NYC. I am not having any issues. I decided to go back to school and just started a residential electrician course and I was curious about the state of my own panel.
Comment: Please take a picture of the innards of your panel so we can better assist you.  Also, if wires are in metal conduit, that serves as a proper grounding method.  Also, where are you, it helps bc people are more aware of local codes.   BTW, what made you decide to open up the panel and inspect?  Are you having issues?
Comment: Can you post photos of the inside of the panel please, especially ones that show where the various bunches leave the panel at?
Comment: There's a lot of paper on those wires. doesn't look like conduit but is probably BX  with some duplex connectors.  What type of outlets do you have?
Comment: Can you get a photo in that small gap above the panel it must be a metal flex, but the type may be apparent if a clear shot through that gap. Conduit is regularly used in larger / commercial, industrial buildings as the equipment ground, another identification of this method is metal boxes at the receptacles and switches.
Comment: That's an awesomely great set of photos - thank you.
Answer: Your building is most likely wired using armored cable (Type AC), so it's grounded, alright
Given the presence of per-conductor paper packing protruding into the panel through the cable connectors, the lack of cable jacketing protruding into the panel through the same route, the lack of ground wires, the vintage of the panel and apparent vintage of the wiring (rather new), and the context of the building and its locale and use (apartment in NYC), my most likely guess as to the wiring method used in your building would be "new style" Type AC (armored cable).  This cable uses the metal armor in conjunction with a thin aluminum bonding strip as the grounding path; the metal cable armor provides a low-resistance path generally, while the bonding strip shorts adjacent turns of the spiral-wound armor to each other to avoid any potential for "choking" of fault currents.  (Very old BX lacked that bonding strip, and there have been various tales of BX armor overheating under low, sustained fault current conditions as a result of the "choke" effect not allowing enough fault current to pass to trip the breaker.)
As an aside: whoever wired that panel was proud of their work, and for the most part deservedly so, so you might as well take this learning opportunity
As an aside, what you are looking at here is a panel that's been quite neatly and professionally wired, by and large.  About the only thing I cannot see in your pictures are the anti-short "redhead" bushings on the connectors. Otherwise, the feeder to this panel looks to be a proper four-wire feed with the panel's bonding screw pulled, as is proper for a subpanel (if this was a main panel, the bonding screw would sit in that "notch" in the top right of the neutral bar).  Furthermore, the branch circuit wiring was done in a very tidy fashion, looping down along the side gutters and back up to the breaker and neutral lugs/screws to provide excess length in case a rearrangement is called for, and all the wiring's been neatly tagged with what circuit it goes to.  Finally, note that all the white wires used as hots in 240V-only circuits, as well as the B leg of the incoming feeder, have been wrapped with red phase tape to prevent confusion.
Best of luck and wishes for your schooling!
Comment: Agreed, beautiful job in the panel. I dk why there are so many wire nutted connections in the panel, but other than that, it looks great. Also appreciate copper mains rather than AL.   +
Comment: @nobody -- all I see is the paper wrap, and NYC AIUI doesn't permit NM anyway; also, duplex AC connectors are a thing
Comment: If you zoom in, it sure looks like there's plenty of NM-B jacket present, just trimmed short. There are also up to three black/white pairs coming in a single knockout, which doesn't make sense for AC.
Comment: I agree, probably armored cable. A great job on the panel. +1
Comment: Amazing answer! I tried to get a pic in between the drywall crack but none were any good. Are the armored cables and aluminum bonding strip connected to the ground bar in the panel, or the water pipes, or a ground rod or something? Or is the armored cable itself the only source of ground?
Comment: @natsuki_2002 -- they're connected to the panel cabinet itself, which is metal, and connected to the ground bar
Comment: @ThreePhaseEel Got it, and on the outlet side in the rooms, the ground wire coming out of a light fixture would be connected to the outlet box, which is connected to armor of the AC?
Comment: @natsuki_2002 -- yes, that'll be how it works :)
Comment: @nobody -- also, the paper wrap in NM is directly under the jacket, covering all the conductors, while the paper wraps in AC/BX cover each conductor individually


GRUB still showing windows 7 boot instead of windows 10

Question: So, I have dual boot on my notebook which are Ubuntu and Windows 7.
But recently, I upgraded my windows 7 to windows 10. But when I startup my notebook, it still shows Windows 7 instead of Windows 10. Although, if I choose Windows 7 boot from it, it will boot windows 10.
How can I fix this?
Comment: possible duplicate of [GRUB2 shows Windows 7 instead of Windows 10](http://askubuntu.com/questions/666317/grub2-shows-windows-7-instead-of-windows-10)
Comment: have you tried editing the grub file?
Comment: @gingamann Oh I can do that? sorry I am still so newb in Ubuntu.. Ill try that too..
Comment: Hey choz, that's really smooth. I'm holding off the update as it might overwrite the MBR with Windows boot loader. Except for the old grub label entry (Windows 7) displayed issue, did you face any other issue?
Comment: @zuke nope so far, its just during installation u have to wait for it to keep restarting and in my case, i have to wait to choose the windows loader on boot up which is pretty sucky.. :)
Answer: you have dual boot system in which you are using ubuntu grub . you have upgraded window but ubuntu system grub don't know about your change . it is simply searching in particular disk that you assign and loading window . so you have to change manually in grub.cfg file . open terminal in ubuntu and run command  sudo gedit /boot/grub/grub.cfg . here you need to search entry like:
menuentry "Windows 7 (on /dev/sda1)" {
insmod ntfs
set root='(hd0,1)'

change Window 7 to window 10 or whatever name you want to give and save file and restart system next time you will see change .
Answer: You can  try manually editing the Grub file to rename the Microsoft instance from 7 to 10.
sudo gedit /boot/grub/grub.cfg

Comment: Tq.. it works..
Comment: cool stuff bud :)
Comment: The file `/boot/grub/grub.cfg` is normally auto-generated by `update-grub` / `grub-mkconfig`, so any changes you make to the file directly will be lost when you install software updates that need a grub update.
Answer: It is just a name and you can easily change that!

sudo add-apt-repository ppa:danielrichter2007/grub-customizer
sudo apt-get update
sudo apt-get install grub-customizer


Openshift3 Does free hosting work

Question: I have created a small Web Application using struts/tiles/mysql/tomcat.
I dont intend to earn any money. Once it is online, it might help parents of my school.
Answer: There is a free layer for Openshift Online and you should be able to deploy your application there with very limited resources.
You can find here more information:
  https://www.openshift.com/pricing/plan-comparison.html
Or you can setup your own server and run Openshift Online in it with

oc cluster up

https://github.com/openshift/origin/blob/master/docs/cluster_up_down.md

Openshift3 Does free hosting work


Are my thumbs up and thumbs down buttons clear enough for the user?

Question: They are basically like the the ones you see in Digg.

I also thought about using arrows (like in StackExchange sites),
but I think people are more used to thumbs these days (due to Youtube, Facebook and Digg).
I didn't make the thumbs-up button green because I couldn't find a green that looks good with the main red color. I also think that probably the thumbs icons are too small.
I would like to know if the user will notice the meaning of those buttons at first glance?
EDIT:
Is this better?
Comment: @GUI Not everywhere in the world green means good/go and red means bad/stop... Especially as janoChen is designing a site for a mainly asian (Taiwan to be precise), red may wel be viewed in a much more positive light than you might think.
Comment: @GUI: Yes, traffic signs/colors are quite international, though I think Mao once said that red can't mean stop...
Comment: @GUI: not a lot :-) But I guess he was around when traffic lights made it into China...
Comment: I'd make them a bit bigger. Maybe make up green, keep down red.
Comment: @Marjan, you are ever so right. The idea should be clear however; to distinguish the two icons also by color. I believe the traffic signs/colors are pretty international, though.
Comment: @Marjan, what on earth did Mao know about web design? :)
Comment: While red and green aren't universally good/bad, they have been used enough to be considered convention pretty globally. I'd be more worried about color clash than culture clash
Answer: I don't think they are very clear actually. They seem to be on the smaller side too. You could go the You Tube way and have something 'like' or 'vote up' text next to the 'Thumbs up'.

I would make them 'green' at-least on hover with a 'tooltip'.@janoChen had mentioned that the site is for non-Taiwanese to interact (in another post), so the 'green' should be clear atleast to them.
Also, the cursor must change to 'pointer' when hovering over the buttons, doesn't look like it from the screenshot.
Answer: If you ask yourself the question, "is this clear enough", you already have an answer: it could be clearer.
Firstly, they don't look like buttons. It's only when you hover over them that you discover: oh, I am suppossed to click this image? A 3D-Effect would help.
Secondly, I didn't recognize the icon as a thumb at first, the YouTub-Thumbs (see @Kashyap) are much clearer.
Thirdly, if you want to stress that the only difference between the thumb up and the thumb down is that, well, one is up and one if down, you could put both on the same baseline, even if this needs more space:

(Oh, and if your question really is: "Is it clear enough?", then the answer is: ask your user. It depends.)
Answer: Your contrast is too low between background and foreground on your icons. Check out this side:
http://www.snook.ca/technical/colour_contrast/colour.html
Even though it's mostly ment for text color contrasts, it's applicable for more situations, such like yours.
Comment: Green/Red seems like a good color combination.
Answer: Don't forget that the thumbs up isn't universally a good thing:

"Thumbs up" traditionally translates as the foulest of gesticular insults in some Middle Eastern countries — the most straightforward interpretation is 'Up yours, pal!'[5] The sign has a similarly pejorative meaning in parts of West Africa, South America, Iran, and Sardinia, according to Roger E. Axtell's book Gestures: The Do's and Taboos of Body Language Around the World."[5]
In Bangladesh, Iran it is traditionally an obscene gesture, equivalent to the use of the middle finger in the Western world.

Source - Wikipedia
Though that doesn't seem to have stopped Facebook from using it.
Comment: +1 this really feels important and is almost always overlooked. Also scales using bronze, silver and gold and other local stuff should probably be reconsidered in a global online world.
Answer: Also: just draw the hand. Don't draw the sleeve.


Django app - deploy using UWSGI or Phusion Passenger

Question: Which way of deploying Django app is better (or maybe the better question would be what are pros and cons):

using UWSGI,
using Phusion Passenger?

In my particular case the most important advantage for using Passenger is ease of use (on my hosting I need to place single file in project directory and it's done), but what with performance things, etc.?
What do you think?
Answer: Production performance is pretty the same, so I wouldn't worry about that. uWSGI has some advanced builtin features like clustering and a cron API while Phusion Passenger is more minimalist, but Phusion Passenger provides more friendly tools for administration and inspection (e.g. passenger-status, passenger-memory-stats, passenger-config system-metrics).


Metric Given by Riemann integral

Question: Let $L_p([a,b];\mathbb{R}) = \{f:[a,b]\to\mathbb{R} | f$ is Riemann-integrable $\}$. I want to prove that
$$
d_p(f,g) = \left(\int_a^b |f(x)-g(x)|^p dx\right)^{1/p}
$$
defines a metric in $L_p([a,b],\mathbb{R}).$
Given $f,g$ integrable I easily see that $d_p(f,g)$ exists and that $d_p(f,f)=0$ and $d_p(f,g) = d_p(g,f)$. I also proved the triangle inequality  by proving the Hölder inequality for positive real functions. I'm just stuck in the condition $f\neq g \to d_p(f,g)>0$. For simplicity I'm assuming $f \neq 0$ and trying to prove $\int |f|^p \neq 0$.
I know that $f\ge 0$ implies $\int f \ge 0$ but I don't see how to get the strict inequality. Any help or hint will be appreciated.
Comment: Actually the space should be altered a bit, since $f =0 $ almost everywhere on $[a,b]$ would deduce that $\int_a^b |f|^p = 0$.
Comment: Yes, that would avoid the possibility that $\int |f - g|^p = 0$ but $f \neq g$, since $\int |f|^p = 0$ and $f$ be continuous would deduce that $f \equiv 0$. This claim could be proved by contradiction.
Comment: Not exactly. Actually $L$ stands for "Lebesgue" integration. Generally $R$ would be used for Riemann integrals. For continuous functions, try $C$, or $C_p$ to indicate the metric.
Comment: Will continuos functions work?
Comment: So the usual notation $L_p$ are used for spaces of continuous functions?
Answer: You can't prove it because it is not true. If$$f(x)=\begin{cases}1&\text{ if }x=a\\0&\text{ otherwise,}\end{cases}$$then $d_p(f,0)=0$, but $f\neq0$. The function $d_p$ is a pseudometric, but not a metric.
Comment: @AnalyticHarmony Yes, if you restrict $d_p$ to the space $\mathcal{C}([a,b])$, then it becomes a metric.
Comment: If I change the set for continuous functions then it'll be a metric? Or is the problem in the defining function per se?

Metric Given by Riemann integral


Creating a UI for brightness/gamma calibration

Question: I'm working on a game where we, at start up, display a brightness calibration screen that users can use to adjust the brightness of their screen so that the game appears more or less consistent across monitors.
A few designs have been mocked up. There is generally a set of bars ranging from nearly black to white (with a note saying you should be able to see each one distinctly) and three blurbs of text reading "Clearly Visible", "Slightly Visible" and "Barely Visible" (and each one is of appropriate brightness). There are also three interactable elements on screen, a slider and text entry which control the brightness, and an OK button for confirmation. Over the course of discussions there has been disagreement on various issues, like

How important is it for the screen to be monochromatic? e.g. should the controls be completely gray scale, or is it okay to use the normal in-game skin?
Should there be a screenshot? Will that affect your perception of brightness on the screen?

If there is a screenshot, should players be adjusting according to the screenshot, or according to the text and boxes?

Should the gray scale boxes have text on them with numbers (so you know how many you should be seeing) or should it just say how many you should be seeing?
Expanding on that, how isolated should the gray boxes be from other elements (one mock up had them next to a screen shot, for example)
There is a slider that adjusts the monitor's gamma, is it preferable to have players move that slider, or adjust the monitor settings manually?
Answer:
If you are using the text method you've suggested, I would recommend grayscale controls. The focus is brightness/gamma, so the controls should reflect that. Unnecessary skinning only complicates the issue.
If your text method is calibrated in a way that you and your test users find satisfactory, text should be sufficient.

If, on the other hand, you wish for a more user-specific calibration method, a screenshot may be quite useful, as long as it is representative of the overall experience of the game. It's no use calibrating with a well-lit screenshot if most of the game happens in caves.

I'm not sure what you mean with this point.
Ideally, they should be isolated as much as possible. No need to confuse the user. If you like, you could provide the box and text method on one screen for gross manipulation, and then a screenshot on the next screen for fine tuning.
This depends on your target audience. If you are targeting a technically inclined audience, manually adjusting the gamma is well within their skills. If you are targeting a general audience, it would probably be best to automate the process.
Comment: To clarify the what I meant for the numbers, here is a snippet from on of the mock ups we had at one point: http://i.imgur.com/8pOFD.png The other option is to place text somewhere that says something to the effect of "There should be 11 distinct boxes below"
Comment: My preference would probably be for the explanatory text, either onscreen with the boxes, or on a preliminary screen (so the text won't skew the results).
Answer:
In this application the gamma correction set-up is actually part of the game.  It is done early in the game and this early experience affects the user's perception of the whole product.

You are not just designing a control screen that does the job of gamma correction with the least fuss and greatest accuracy.  If it's dull and boring they'll think the game is too - and a bit cheap.  Instead give the user a feeling of being in control, and that this step is enabling them to get the very best out of the game.  This answers the 'should I have a screenshot' part of the question.  Absolutely yes.  And add a game element - dungeon bars seen from a distance - anti-forgery stamp in a passport - that particularly benefits visually from setting gamma correction, and then use that element in the screenshot.  Setting the gamma is part of the game.

How important is it for the screen to be monochromatic? e.g. should the controls be completely gray scale, or is it okay to use the normal in-game skin?

Don't go full-screen gray.  Use, say, 1/3 of the screen for the test area with a frame inside say 80px wide that is neutral.  You will then be more than OK with having colorful elements like a screenshot and dials and skinned controls and other branding outside.  Making the gray area through a window of some kind is good.  It means you don't have to worry about mixing grayscale and normal game skin in the same area.

If there is a screenshot, should players be adjusting according to the screenshot, or according to the text and boxes?

They should adjust as per the text and boxes.  Otherwise your players will ask why are you having those grayscale elements at all?  Your microcopy on the page will need a lot of care.  You must get across that they get the most accurate adjustment of gamma by working with the grayscale, and imply that the screenshot is just to indicate how that affects the game - meanwhile the reality is that the screenshot is really there to motivate tweaking the gamma.

Should the gray scale boxes have text on them with numbers (so you know how many you should be seeing) or should it just say how many you should be seeing?

Numbers.  Players want to know what the right answer is.  It is not good to have them worrying 'did I pass the test'?
But I am wondering is counting number of bars a good design for the gamma correction?  Shouldn't it be more about making a dithered, or actually horizontally striped, area match a monochrome area when seen from a distance?  Or pick the curved line that looks smoothest first black on white, then white on black?  I'd like to see a screenshot of the bars to understand exactly what you intend.

There is a slider that adjusts the monitor's gamma, is it preferable to have players move that slider, or adjust the monitor settings manually?

If this is a PC game, surely the user needs to adjust both monitor settings and game settings?  I cannot set contrast and brightness of my monitor programmatically.  Those MUST be right before I start working on gamma.  From a program I can only change the pixel values sent.
Perfection, for print-production, would dictate setting a lot of settings on both monitor and in-program, and a careful order to the setting to avoid setting hell - one adjustment throwing out another.  This is not gamer territory however.  In the end you do not even care if the user sets up the screen 'hot' - if that is what they prefer.  It's totally different to setting up for a print-production application.
I would take a shortcut and assume the monitor settings are fixed, and that you are only changing pixel values.  You do not want to include instructions for all possible monitor OSDs.

Take Home
Just because you appear to be in print-production territory, don't forget that you are actually writing a game.  Apply everything you know about game psychology.  Put the user in control.


Should I cap off my clogged kitchen pipe at the wall or after the p-trap?

Question: A member of my household thought our garbage disposal was a magic ray gun that obliterated anything poured down its black hole. The plumber cleared a glue-like substance from the pipes underneath the sink with a screwdriver but his auger barely penetrated 5 inches into the main wall pipe that leads to the sewer. I cannot afford to have my pipes cut out and new ones installed so I was just going to use the sink in the basement to clean dishes.
So which is the better option so sewage fumes do not overrun my house:

Easy option: Cap off the sink hole & garbage disposal.
Remove all the pipes under sink & garbage disposal and cap off main pipe at wall.
Leave the P-Trap and cap the pipe off after that.
Answer: Any of those options will work, let me reorder them to:

Easy option: Cap off the sink hole & garbage disposal.
Leave the P-Trap and cap the pipe off after that.
Remove all the pipes under sink & garbage disposal and cap off main pipe at wall.

Now they're in order of ease and how temporary you want. If you want to simply stop the sewage fumes, the P-Trap (filled with water) will do just that so #1 & #2 will do that. #2 & #3 are good but might be a bit overkill especially if you leave the sink in place, even with the sink faucet off you'll have the occasional pot drained/strained in the sink and glass dumped in there. So if you have any drainage left, I'd just leave it and probably just turn off the faucets. If not, personally I'd removed the P-Trap back and cap it, then put a 5-gallon bucket under there.


Unable to build/publish Azure Data Factory application

Question: Every Data Factory application I try to create in visual studio 2015, even the sample ones, are unable to build or publish due to:
"Object reference not set to an instance of an object." error on every .json file.
Is there some important configuration I'm missing or some dependencies I need to add to the project? Thanks
Answer: We have an open bug on this and will fix in our next release.  The error is thrown during build, but you still should be able to go ahead and publish.  We'll look into this further to see why you are also blocked from publishing.  Thanks for the feedback!
Comment: See my answer on this question. In my case it seems like VS recognizes different version of Azure SDK than WebPI.
Answer: It's a bug in the extension. I have the same error in Visual Studio 2015 but if you open this project from VS 2013 (you need to download separate extension) it should build and publish correctly.
Answer: Reinstall Your Azure SDK for Visual Studio.
Answer: I've got the same issue. Visual Studio 2015 is offering Microsoft Azure SDK 2.8.2 as an update and telling the currently installed version is 2.8.1 and while I try to update it, Web Platform Installer tells 2.8.2 is installed and refuses to install it again.

Also, when I try to rebuild the DataFactory project, I get the following alert.

Going through the logs, I find the following message:
<code>Microsoft.VisualStudio.Composition.CompositionFailedException: An exception was thrown while initializing part "Microsoft.VisualStudio.JSON.Package.Schema.CatalogJSONSchemaSelector".
---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.VisualStudio.Html.Package.Host.IdleTimeSource..ctor() at Microsoft.VisualStudio.Html.Package.Host.VsWebEditorHost..ctor()
--- End of inner exception stack trace

--- at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) at System.Activator.CreateInstance(Type type, Boolean nonPublic) at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark) at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) at System.Reflection.Assembly.CreateInstance(String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) at Microsoft.Web.Editor.Host.WebEditor.get_Host() at Microsoft.Web.Editor.Host.WebEditor.GetSettings(String contentTypeName) at Microsoft.JSON.Editor.Settings.JSONSettings.get_Storage() at Microsoft.JSON.Editor.Settings.JSONSettings.get_SchemaCatalogs() at Microsoft.VisualStudio.JSON.Package.Schema.CatalogJSONSchemaSelector..ctor()
--- End of inner exception stack trace
--- at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.RuntimePartLifecycleTracker.CreateValue() at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.Create() at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.MoveNext(PartLifecycleState nextState) at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.MoveToState(PartLifecycleState requiredState) at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.GetValueReadyToExpose() at Microsoft.VisualStudio.Composition.ExportProvider.<>c__DisplayClass53_0.<CreateExport>b__0() at System.Lazy`1.CreateValue() at System.Lazy`1.LazyInitValue() at System.Lazy`1.get_Value() at Microsoft.VisualStudio.Composition.NetFxAdapters.MefV1ExportProvider.<>c__DisplayClass12_0.<UnwrapExport>b__1() at System.ComponentModel.Composition.Primitives.Export.GetExportedValueCore() at System.ComponentModel.Composition.Primitives.Export.get_Value() at System.ComponentModel.Composition.ExportServices.GetCastedExportedValue[T](Export export) at System.ComponentModel.Composition.ExportServices.<>c__DisplayClass11_0`2.<CreateStronglyTypedLazyOfTM>b__1() at System.Lazy`1.CreateValue() at System.Lazy`1.LazyInitValue() at System.Lazy`1.get_Value() at Microsoft.Web.Editor.Composition.ComponentLocatorWithOrderingAndUnorderedParts`1.ImportMany()
</code>
Answer: I was facing the same issue and it was because of the fips Algorithm policy enabled on the machine.
Resolution:
Disable FIPS Algoirthm policy via regedit and restart the Visual Studio.
Location:

HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Lsa\FipsAlgorithmPolicy


Gas dryer flame not always igniting

Question: Brand: whirlpool
Model: senseon ggw9868kq2
Lately the dryer will not always heat up. I pulled off the front panel and watched the igniter while I started the drying cycle. It will always glow bright, but sometimes I will not get a flame. I'm guessing that either it's not getting gas consistently or that the igniter is not always getting hot enough to ignite... but I don't know much about this and am not sure what is wrong.
What would cause this behavior?
Video of when it starts:
https://www.youtube.com/watch?v=WDKW8EdmNnI
Video of when it doesn't:
https://www.youtube.com/watch?v=UcwPH2upVxY
I also noticed that right before and during the glow, there is a bunch of clicking like sound coming from that area.

Edit 9/24
I tried holding a flame near the igniter while the igniter was glowing but it still didn't ignite.
Here is a video with me using a multimeter (not sure if I used it correctly though):
https://www.youtube.com/watch?v=t8Lpgdmsqjo
and a video trying to get a good look at the pipe/igniter area:
https://www.youtube.com/watch?v=Kfgy49R24zI
Comment: Do you have any other gas appliances, and if so are they OK? If they are, either the gas feed to the dryer is plugged, as EdBeal suggests, or something else is wrong.  If nothing lights up, then you're out of gas.
Comment: @CarlWitthoft, interesting that you ask that. We have a gas stove as well that has some issues. The stovetop burners seem to work fine and the oven always starts... but sometimes I think it fails to reignite because I've went to take something out of the oven and the oven was much cooler than what I had it set at and the food wasn't cooked properly :( ..but usually when this happens I flick the stove top igniters I'll hear the oven flame turn on as well.
Answer: Igniters do go bad but the ones I have had trouble with don't work at all or have area that is dark. I have had more problems with the gas mix. I have seen cases where the jets in the burner have gotten plugged or partly plugged causing problems. I have had success using a piece of wire small enough to push through each port opened them up enough. The other possible problem can be where the air is drawn in to the burner sometimes there is a screen to keep dust and spiders out if this screen gets coated with dryer lint the air/gas mix is not correct and the burner may not light. The last problem I have had is the very small orifice just after the gas valve but before the burner gets plugged. This small orifice is difficult to clean but there are usually replacements available for a couple of bucks if you change this make to get the same size there are different sizes for natural gas and propane.
Comment: Thanks for your response, I'll look into those things when I get back home. In the meantime I've added some videos to see if they'd offer more insight into the problem.
Comment: Looking at the video + by the way the flame color or air/gas balance looks off at the start. I would look for a screen prior to the burner that may have a layer of lint on it. Causing the hard start.
Comment: I'll see if I can figure out a way to get there, might need to try taking that whole unit out.
Comment: I guess taking the unit out is not an easy task, especially considering the pipe is all attached and going through a ring with no way I can tell to disassemble
Answer: Make sure the gas is on
The first thing to check, is to make sure the gas is on. Check any valves, and make sure they're in the full open position.
Clean the orifice
An orifice obstruction could prevent the proper amount of gas from being injected into the system. Check the orifice to make sure it's clean and free of debris.
Check the gas valve solenoids
Start by checking the gas valve solenoids.  There should be two solenoids on top of the gas valve, one of which can be seen in your video. The second solenoid should be just next to the first.

It's recommended to remove the solenoids for testing, but it can be done with them in place if you can reach. To test the solenoids:
1. Remove the wire harness.

Removing the harness will reveal two or three terminals.
2. Measure coil resistance
For a two terminal solenoid, simply measure the resistance between the two terminals.  A good solenoid should have a resistance between 1000-2000 ohms (check with manufacturer for exact values).
If the solenoid has three terminals, one of the terminals will be common (COM, C, etc.) It may be marked in some way, or you'll have to check with the manufacturer to determine which terminal is common.  Once you've located common, simply check the resistance between common and each of the other terminals.  A good solenoid should measure between 300-2000 ohms between common and each other terminal (again, check with the manufacturer for exact values).
Check the gas valve
If the solenoids test good, you'll want to make sure the valve is actually opening when it's supposed to.  Since the rotating drum is so noisy, it will make it difficult to hear the valve open. Also, since there's a spinning drum in close proximity, you'll not want to stick your hand in to feel if the valve opens.
It's possible to apply a test voltage to the solenoid, to see if it pulls open the valve. However, you'll want to have the gas turned off, so as not to release gas into the home.  You'll also want to electrically isolate the solenoids from the circuit, to avoid accidentally damaging other components. Be sure to apply the correct voltage to the solenoid, as you'll not want to damage it during the test.
Check the schematic
In most equipment, you'll find a schematic printed or stashed inside the unit. Study the schematic, and try to determine if there are any safety sensors that could be preventing the gas valve from opening.  Locate and test each one, to verify they are all in good working order.
Check the gas supply
If all else fails, you might want to have the gas supply checked out by a professional (or the utility).  If you're on Propane, make sure the tank is not low or empty.  If you have a natural gas feed, have the utility check the supply pressure as well as the pressure after the regulator. Also ask them to do a load calculation, to make sure the supply is suitable for the number of appliances you have.
Comment: thanks for the reply, i'll take a look at the dryer this weekend and see how it goes
Comment: I updated the post with a video of me checking the coils, first time I've ever used a multimeter so I'm not sure if I used the correct setting on the dial or what the measurement means.
Comment: Seems okay, but if it's intermittent you might get good readings sometimes. The first reading was 555 ohms, while the second reading was 1200 ohm.  If it's possible to run the dryer with the drum motor disconnected, that might let you hear if the valve is getting pulled open.  Just don't run it like that long.
Comment: I can't find a service manual for your dryer, so I'm not sure what the exact coil resistance should be. However, the readings are within the typical range.  If it was really low, it would show a short-circuit. An open circuit means a broken coil.
Comment: I'm wondering if it is just that something needs to be cleaned or unplugged as it was definitely very dusty in there at first. But I am having trouble finding what to clean. It is very hard to access anything in there. I've used my vacuum to clean it out as much as I could and sprayed that area as good as I could with an air duster, but no luck.
Comment: ended up having someone come, it did need a new coil
Answer: Had this problem with my Whirlpool Gas Dryer GGQ9800PW1. Replaced the two solenoid coils (ten minutes) and dryer works perfectly. With bad coils heard chattering noise which was caused by a weak coil.

Gas dryer flame not always igniting


Convert an array of image physical paths on server to array of urls

Question: I'm using Web Api to return a list of URLs to a client application. Since the Image files get created on the server, when a request comes in I need to respond with a list of the Image path URLs. Right now, I'm using the code below to accomplish this but it's returning physical paths rather than URLs.
string[] imagePaths = Directory.GetFiles(outputImgPath,"*.png");
response.Images = new List<string>(imagePaths);

How could I go about returning the actual urls of the image on the server? I figure I could loop through all the files in the directory and convert them but I'm not sure how to go about that in a performant way.
Comment: Unless you have millions of paths then performance shouldn't be a concern.
Answer: You can retrieve all file name from directory and add them with web URL
string[] imagePaths = Directory.GetFiles(outputImgPath,"*.png");
imagePaths.Select(x => string.Format("http://DOMAIN/Path/{0}" , Path.GetFileName(x)))

Comment: Yes it is, you can use Path APIs to get filename
Comment: wouldn't the `x` in this case contain the server path still and just append it to the `http://DOMAIN/path/`  ?


Cyclops power cells: order in which power cells deplete

Question: I'm certain the cyclops' power cells deplete one at a time.  However, I seem to be having trouble determining which cell depletes 1st.  I'm starting to wonder whether or not it might be random and I suspect it also differs if one of the six power cells is absent.
First, it's useful to name the positions of the cells so they are fixed, using (for reference see the image below) 'P' for port 'S' for starboard as well as the numbers 0-2 to indicate distance from the stern with 0 being closest to the stern and 2 the farthest.  Using this naming system the six power cell slots will be referred P0-P2 and S0 to S2.  Henceforth, the slots themselves will be referred to as power cells since it's them that we're interested in and not the actual game item.

It's likely a new cell is randomly chosen after one has been depleted but otherwise I suspect it behaves as follows:

The cyclops has rules which precisely determine which power cell to drain next based exactly on the positions of depleted cells.
The game treats empty power cells and absent ones as equivalent and therefore for the remainder of this description I will refer only to empty/depleted cells.
If all power cells are depleted then the next non-depleted cell will be the one to be drained.

If anyone can refute or prove some/all of these claims it would be much appreciated!
P.S. If you're uncertain why I named the cell slots if I never mention them it's simply because someone might've noticed a set sequence in which cells are used and this allows them to unambiguously describe it.
Answer: Power cells deplete in the order they are inserted. If you remove one and replace it, this one will go to the end of the list.
They charge in the reverse order, so the first to deplete will be the last charged up using the thermal regeneration module and the last one depleted will be the first charged.
(tested during many hundreds of hours of play)