Use class variables as instance vars?

Question: What I would like to do there is declaring class variables, but actually use them as vars of the instance. I have a class Field and a class Thing, like this:
class Field(object):
    def __set__(self, instance, value):
        for key, v in vars(instance.__class__).items():
            if v is self:
                instance.__dict__.update({key: value})

    def __get__(self, instance, owner):
        for key, v in vars(instance.__class__).items():
            if v is self:
                try:
                    return instance.__dict__[key]
                except:
                    return None

class Thing(object):
    foo = Field()

So when I instantiate a thing and set attribute foo, it will be added to the instance, not the class, the class variable is never actually re-set.
new = Thing()
new.foo = 'bar'
# (foo : 'bar') is stored in new.__dict__

This works so far, but the above code for Field is rather awkward. It has too look for the Field object instance in the classes props, otherwise there seems no way of knowing the name of the property (foo) in __set__ and __get__. Is there another, more straight forward way to accomplish this?
Comment: Out of interest, what possible use does this have?
Comment: This is 2.7, vars() is similar to __dict__
Comment: It just returns the \_\_dict\_\_, in some situations I think it tends to look cleaner.
Comment: @Eelke By all means, it's much nicer than accessing `__dict__` directly. I'm still wondering what use you have for this though.
Comment: What's wrong with just setting attributes on the instance in `__init__`?
Comment: @Eelke I still have much to learn. Good to know there is a function doing this *built-in*.. Thanks!
Answer: Reread your question and realized I had it wrong:
You don't need to override the default python behavior to do this.  For example, you could do the following:
class Thing(object):
    foo = 5

>>> r = Thing()
>>> r.foo = 10
>>> s = Thing()
>>> print Thing.foo
5
>>> print r.foo
10
>>> print s.foo
5

If you want the default to be 'None' for a particular variable, you could just set the class-wide value to be None.  That said, you would have to declare it specifically for each variable.
Comment: @Lattyware , edited my answer to (hopefully) answer the actual question.
Comment: OK, I removed my -1, although I'm pretty sure the OP wanted to do this without doing it this way, I'm not really sure why though.
Answer: Every instance of Field (effectively) has a name. Its name is the attribute name (or key) which references it in Thing. Instead of having to look up the key dynamically, you could instantiate Fields with the name at the time the class attribute is set in Thing:
class Field(object):
    def __init__(self, name):
        self.name = name

    def __set__(self, instance, value):
        instance.__dict__.update({self.name: value})

    def __get__(self, instance, owner):
        if instance is None:
            return self
        try:
            return instance.__dict__[self.name]
        except KeyError:
            return None

def make_field(*args):
    def wrapper(cls):
        for arg in args:
            setattr(cls, arg, Field(arg))
        return cls
    return wrapper

@make_field('foo')
class Thing(object):
    pass

And it can be used like this:
new = Thing()

Before new.foo is set, new.foo returns None:
print(new.foo)
# None

After new.foo is set, 'foo' is an instance attribute of new:
new.foo = 'bar'
print(new.__dict__)
# {'foo': 'bar'}

You can access the descriptor (the Field instance itself) with Thing.foo:
print(Thing.foo)
# <__main__.Field object at 0xb76cedec>

PS. I'm assuming you have a good reason why
class Thing(object):
    foo = None

does not suffice.
Comment: @Eelke: Without the class decorator, you would have to write `foo = Field('foo')`. This forces you to repeat `foo` twice. I used the class decorator solely so that you do not have to repeat yourself.
Answer: The easiest way would be to call the attribute something else than the name of the descriptor variable - preferably starting with _ to signal its an implementation detail. That way, you end up with:
def __set__(self, instance, value):
    instance._foo = value

def __get__(self, instance, owner):
    return getattr(instance, '_foo', None)

The only drawback of this is that you can't determine the name of the key from the one used for the descriptor. If that increased coupling isn't a problem compared to the loop, you could just use a property:
class Thing:
    @property
    def foo(self):
       return getattr(self, '_foo', None)

    @foo.setter
    def foo(self, value):
       self._foo = value

otherwise, you could pass the name of the variable into the descriptor's __init__, so that you have:
class Thing:
    foo = Field('_foo')

Of course, all this assumes that the simplest and most Pythonic way - use a real variable Thing().foo that you set to None in Thing.__init__ - isn't an option for some reason. If that way will work for you, you should prefer it.

Use class variables as instance vars?


How to restore Okular default (toolbar) settings

Question: I've somehow managed to remove the toolbar and menu-bar from Okular. After I've found no way to reactivate them from "outside" – sice I can't click on Options anymore – I've tried to reinstall a clean version after removing it with apt-get remove --purge okular. However, it didn't work, the tool- and menu-bars were still unavailable. I also looked for any configuration files in the home directory, without success. How should I proceed now in order to restore a clean Okular.
Comment: 2021 ... menu '_gone_' (still?) My RC file says: `MenuBar=Disabled`.  Wild???!
Answer: The keyboard shortcut to show/hide the menu bar is Ctrl-m. I found the config file where the setting is stored at ~/.config/okularrc.
Comment: thank you for the keybinding -- at the time I've seached for it. Regarding the config file. It should be mentioned that then, as far I'm remembering right, it has not affected the setting, even if it was deleted.
Answer: So you have to open Okular without any document and right-click on the background surface of where the document is normally shown (for me grey). If -- and only if -- the toolbars are not visible you will provided with a context menu with the option to show the bars.
Comment: Thank you! Alternatively, just hit CTRL+M
Answer: You can find the config files in ~/.var/app/org.kde.okular
You can remove it manually or by entering this in your terminal
rm -R ~/.var/app/org.kde.okular

Comment: @matemethieu: Thank you very much. For Debian 9 it is in `~/.kde/share/apps`. However it doesen't work. Found a solution. See below.
Answer: For my Ubuntu 18.04, right-clicking on the content space of Okular without a document showed the option to turn on showing the menu bar
Comment: How exactly is this different from the [accepted answer](https://unix.stackexchange.com/a/519374/90878)?


Voice pick code

Question: I am relatively new to VBA coding in excel. I am trying to develop a backup system for labeling that is PTI compliant. I am wanting to establish a Voice pick code within an excel file.
I understand that the VPC calculator is a free download, but I am trying to make the VPC automatically update when a GTIN, LOT, or Date information changes in the excel file. I have been doing plenty of research and understand the formula when it is applied to JAVA. But I cant figure out how to implement it into a VBA format for excel. I understand people have already been able to create a CRC-16 Hash calculation before, but I am unable to get it to work where it matches up with the PTI voice pick calculator.
My goal is 2 create 2 functions. <code>=VPCS(GTIN,LOT,DATE) and =VPCL(GTIN,LOT,DATE)</code>. The GTIN, Lot, and date information would each be pulled out of their own cell. Then "VPCS" would gather the first 2 small numbers, while VPCL would gather the 2 large numbers of the same information. Though I'm not sure if this is even possible, if it could be done, it would help many other people who work with this kind of software.
Does anyone think this can be done? Also, just an add on, if anyone knows of any good sites in learning VBA, would you please post a link? I am trying to learn as much a possible about it.
Answer: hi i develop a simple system on vb.net using the harvestmark voicecode.dll to print labels, but i'm not shure if this work on excel:
Imports YottaMark.Utilities.VoiceCodeLib
Public Gtin As String
 Public Lots As String
 Public Datelot As DateTime
vcode = VoiceCode.Compute(Gtin, Lots, Datelot)

Voice pick code


How do you get music that you have already purchased into the new apple music?

Question: How do you get music that you have already purchased into the new apple music they just updated?
In the old one you had an option in settings to show all music but now that option is gone and i can't download music i have already bought onto my iphone? Anybody help? How do you do it?
Answer: Open iTunes, then (if on mac) click the word iTunes in the menu bar and turn on "iCloud Music Library" this will sync all music and playlists to your iCloud, and will be matched with content found on iTunes.
If on Windows, open iTunes. Then in the File menu, click preferences, and turn on iCloud Music Library.
After this, you will need to open settings on all of your other iOS devices, and turn on iCloud Music Library.
Please note that if you choose to download music from the Apple Music service it is DRMed and will not be editable as your iTunes purchases are.
Comment: If this answer is correct please mark it. I appreciate the reputation.


How to compute the semisimple part of the Jordan (SN) decomposition of a matrix

Question: How do you compute the semisimple part of the Jordan (SN) decomposition of a matrix $A\in M_n(K)$?  The method I believe is correct is this:

Compute the eigenvalues $a_1,\dots,a_r$ of $A$ and their generalized eigenspaces $\tilde{V}_{a_1},\dots,\tilde{V}_{a_r}$.
Compute a basis $(b_{k,1},\dots,b_{k,d_k})$ for each generalized eigenspace $\tilde{V}_{a_k}$, and let $P$ be a matrix $(b_{1,1},\dots,b_{1,d_1},\dots,b_{k,1},\dots,b_{k,d_k},\dots,b_{r,1},\dots,b_{r,d_r})$, where each vector is regarded as a column vector.
Let $B = a_1I_{d_1}\oplus\cdots\oplus a_rI_{d_r}$ and then $P^{-1}BP$ will be the semisimple part.

Is this a correct and convenient way to compute the semisimple part by hand?
Answer: Let $p$ be the minimal polynomial of $A$. Then there is a unique polynomial $s\in K[X]$ of degree less than $\deg p$ such that $s(A)$ is the semi-simple part of $A$.
Assume, as we may, that $p$ splits in $K$ as, say,
$$
p=\prod_{\lambda\in\Lambda}\ (X-\lambda)^{m(\lambda)}
$$
with $m(\lambda) > 0$ for all $\lambda$.
Then $s$ is the unique degree less than $\deg p$ solution to the congruences
$$
s\equiv\lambda\quad\bmod\quad(X-\lambda)^{m(\lambda)},\quad\lambda\in\Lambda,
$$
and it is given by
$$
s=\sum_{\lambda\in\Lambda}\ \lambda\ T_\lambda\left(\frac{(X-\lambda)^{m(\lambda)}}{p}\right)\frac{p}{(X-\lambda)^{m(\lambda)}}\quad,
$$
where $T_\lambda(f)$ means "order less than $m(\lambda)$ Taylor polynomial of $f$ at $\lambda$".
EDIT. Here is a proof. Put
$$
B_\lambda:=\frac{K[X]}{(X-\lambda)^{m(\lambda)}}\quad.
$$
(A) We have canonical $K[X]$-algebra isomorphisms
$$
K[A]\simeq\frac{K[X]}{(p)}\simeq\prod_{\lambda\in\Lambda}\ B_\lambda=:B,
$$
the second isomorphism being given by the Chinese Remainder Theorem.
We way (and will) work in $B$ instead of working in $K[A]$.
Let $x\in B$ be the canonical image of $X$, and $e_\lambda$ the element of $B$ whose $\lambda$ component is $1$, and whose other components are $0$.
We must find the semi-simple part of $x$. But this is clearly the sum of the $\lambda e_\lambda$. In view of (A), this shows that, as claimed, $s$ is the unique degree less than $\deg p$ solution to the congruences
$$
s\equiv\lambda\quad\bmod\quad(X-\lambda)^{m(\lambda)},\quad\lambda\in\Lambda,
$$
and we're left with solving these congruences.
It's not harder to solve the general congruence system
$$
s\equiv p_\lambda\quad\bmod\quad(X-\lambda)^{m(\lambda)},\quad\lambda\in\Lambda,
$$
where the $p_\lambda\in K[X]$ are arbitrary.
The trick is to use the Ansatz
$$
s:=\sum_{\lambda\in\Lambda}\ s_\lambda\ \frac{p}{(X-\lambda)^{m(\lambda)}}\quad,\quad\deg s_\lambda < m(\lambda),
$$
which gives the solution
$$
\sum_{\lambda\in\Lambda}\ T_\lambda\left(p_\lambda\ \frac{(X-\lambda)^{m(\lambda)}}{p}\right)\frac{p}{(X-\lambda)^{m(\lambda)}}\quad.
$$
[Recall that $A$ admits a Jordan decomposition if and only if its eigenvalues are separable over $K$ (Bourbaki, Algèbre, Théorème VII.5.9.1). We assume here that such is the case.]
Comment: Dear @Pteromys: I'll write a proof as soon as possible, but I'm very slow. Thanks in advance for your patience.
Comment: Dear @Pteromys: I tried to give a proof.
Comment: Could you give me more details about $T_\lambda$? (and what I really meant to ask was whether the method I described was correct.)
Answer: Your method is correct but requires to compute the root of the characteristic polynomial of $A$, which can't be done in general (there is no algorithm if $K=\mathbb{C}$, but if $K$ is finite there are algorithms such as Cantor-Zassenhaus).
The only way I know (but there may be other ones) to compute the semi-simple part of $A$ is the following : let $P(X) = \frac{\chi_A(X)}{GCD(\chi_A(X),\chi'_A(X))}$. Compute the sequence $(A_k)$ of matrices by $A_0=A$ and $A_{k+1} = A_k - P(A) P'(A)^{-1}$. Then for $k \geq \log_2 n$, $A_k$ is the semi-simple part of $A$ (the key point to prove this is to note that the semis-simple part of $A$ is a zero of $P(X)$).
Comment: Perhaps my wording was a bit confusing, but what I wanted to ask was all about computing it for matrices $\in M(\mathbb{R})$ by hand, e.g., when solving exercises on textbooks.


Lagrangian description of Brownian motion?

Question: I'm interested in the existence of a Lagrangian field theory description of Bronwnian motion, does such a thing exist? Given a particle of some spin $\sigma$, which has a  Lagrangian associated with it $\mathcal{L}_{\sigma}$ (which, using the Euler-Lagrange equations, produces Klein-Gordon for $\sigma$ = 0 etc) is there a way I can allow for Brownian type freedoms in this description? Hopefully such a stochastic freedom is allowed in the Lagrangian description.
Comment: This is not an answer to your question! You might want to take a look at the Feynman-Kac formula.
Comment: From what has already been said by others, take the partition function $Z = \int \mathcal{D}x e^S$ (in QM a "$i/\hbar$" also enters) where the action $S = \int_0^T dt \mathcal{L}$ and $\mathcal{L}$ is the "Lagrangian", often of the form $\dot{x}^2$. That it is a Lagrangian is true only for the semiclassical approximation, i.e. for the trajectory that doesn't have fluctuations. You might also be interested in Malliavin calculus, although I've never seen it used in physics. As it is supposed to be variational calculus with stochastic stuff, it might be related?
Comment: Thank you, @amlrg. I have encountered the Malliavin calculus before in the context of variational approaches for PDE with, say, $L^{1}$ measure data right hand sides. I hadn't thought of it in this context though
Comment: Look up the [Caldeira-Leggett model](http://www.scholarpedia.org/article/Caldeira-Leggett_model).
Answer: The Brownian motion $x(t)$ is non-differentiable, so a particular trajectory $x(t)$ can't extremize an action $S$ which would be a functional of $x(t)$ and its derivative, $\dot x(t)$, because the derivative isn't even well-defined and any expression of the type $\int [\dot x(t)]^2 dt$, the usual kinetic term in the action, diverges. (See e.g. middle of page 2 of this paper to see the statement that there is no Lagrangian, too. The paper does its best to construct something that is "as close as possible" to the normal Lagrangian formulation.)
However, when you mention field theory, it's interesting to point out that the typical trajectories $x(t)$ that contribute to Feynman's path integral computation of ordinary quantum mechanics do resemble the Brownian trajectories very closely. But the amount of zigzag motion is determined by the uncertainty principle and Planck's constant, not by adjustable collisions with the molecules of a liquid etc. There are many other differences in the physical interpretation, too.
Comment: Thank you @Lubos, I was hoping there might be a Wiener–Khinchin type theorem (such as Page-Lampard for non-stationary) that could be applied to bound $\int \dot{x}(t)^2 dt$, but perhaps not! I was thinking one could think of the quantum vacuum as a kind of fluid (by performing a kind of decomposition of, say, the Euler-Heisenberg Lagrangian into Maxwell + Magfluid) wherein we introduce a field whose excitations give rise to a kind of Brownian motion.
Comment: These are interesting research projects, I think, not questions about established science. ;-)
Comment: I realize this is over a year later, but I would like to add a comment. Brownian motion is not classically differentiable, thus the kinetic energy term diverges. However, it has been shown in various available papers that Browninan motion is fractional differentiable, and fractional derivatives are related to the fractal dimension of a non-rectifiable curve. It may be possible to calculate a finite kinetic energy using fractional calculus, which would allow for a Lagrangian for Brownian motion.
Comment: That's a very interesting proposal.


c++: Does a vtable contains pointers to non-virtual functions?

Question: vtable contains pointers to virtual functions of that class. Does it also contains pointers to non-virtual functions as well?
Thx!
Comment: First, a vtable is an implementation detail. Second, why would it? You'll always call the same thing anyways.
Answer: It's an implementation detail, but no. If an implementation put pointers to non-virtual functions into a vtable it couldn't use these pointers for making function calls because it would often cause incorrect non-virtual functions to be called.
When a non-virtual function is called the implementation must use the static type of the object on which the function is being called to determine the correct function to call. A function stored in a vtable accessed by a vptr will be dependent on the dynamic type of the object, not any static type of a reference or pointer through which it is being accessed.
Answer: No, it doesn't.
As calls to non-virtual methods can be resolved during compilation (since compiler knows the addresses of non virtual functions), the compiler generates instructions to call them 'directly' (i.e. statically).
There is no reason to go through vtable indirection mechanism for methods which are known during compiling.
Answer: Whether or not a "vtable" is used by any implementation isn't defined by the standard. Most implementations use a table of function pointers although the functions pointed to are typically not directly those being called (instead, the pointed to function may adjust the pointer before calling the actual function).
Whether or not non-virtual functions show up in this table is also not defined by standard. After all, the standard doesn't even require the existence of a vtable. Normally, non-virtual function are not in a virtual function table since any necessary pointer adjustments and call can be resolved at compile- or link-time. I could imagine an implementation treating all functions similarly and, thus, using a pointer in the virtual function table in all cases. I wouldn't necessary be very popular. However, it might be a good way to implement C++ in an environment where it seamlessly interacts with a more flexible object system, e.g., languages where individual functions can be replaced at run-time (my understanding is that something like this is possible, e.g., in python).
Comment: Are there in fact any known implementations that don't use a vtable? ( i know they don't have to, just curious)
Comment: I'm not aware of any implementation not using an embedded pointer.
Answer: No. A vtable only contains pointers to virtual functions in the same class or file.


Missing Ruby Development Libraries on OpenSuse

Question: I might have jumped off the deep end when getting back into Linux and am stuck trying to install a new version of Ruby on OpenSuse with rbenv.
me@linux-tzyj:~> rbenv install 2.4.0
Downloading ruby-2.4.0.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.4/ruby-2.4.0.tar.bz2
Installing ruby-2.4.0...

BUILD FAILED (openSUSE Tumbleweed 20180209 using ruby-build 20171226-3-g01e7b7b)

Inspect or clean up the working tree at /tmp/ruby-build.20180211014832.4210
Results logged to /tmp/ruby-build.20180211014832.4210.log

Last 10 log lines:
The Ruby openssl extension was not compiled.
The Ruby readline extension was not compiled.
The Ruby zlib extension was not compiled.
ERROR: Ruby install aborted due to missing extensions
Try running `apt-get install -y libssl-dev libreadline-dev zlib1g-dev` to fetch missing dependencies.

I tried finding any of those in apt-get and zypper with no luck.  Does OpenSuse handle these packages differently than Ubuntu does?  That is what I used to use years ago.
I tried running zypper in -t pattern devel_basis but that just removed the zlib1g-dev in the list of missing packages
Answer: They are indeed slightly different. Try zypper install libopenssl-devel readline-devel.


How can I identify a set based on one or more original sealed bags?

Question: I have recently come into possession of one or more sets in the form of factory-sealed individual bags made of transparent plastic, containing various LEGO elements. There is neither box nor any instruction booklets. I have checked the bags and the parts contained within them are definitely genuine LEGO pieces (all non-hollow studs have the LEGO logo relief). How could I determine which set(s) I own? The bags have different texts, numbers and codes printed on them.
Comment: Does this answer your question? [How can I identify LEGO sets from a box or bag of parts?](https://bricks.stackexchange.com/questions/404/how-can-i-identify-lego-sets-from-a-box-or-bag-of-parts)
Comment: I'm not the dv'er, but it's basically a duplicate of the linked Q.
Comment: I don't think that's an exact duplicate, as it's about opened, built and partially disassembled heap of sets - while this focuses specifically on unbuilt, unopened bags.
Comment: @Downvoter, what could be improved about this question?
Answer: First of all, congratulations on your new set(s)!
Second, let's just ignore anything printed on the plastic foil itself, as the numbers and codes are independent of the actual contents of the bags - those markings only serve to identify the plastic bag as a packaging material, not the filled bag as part of a set.
Now then, onto the contents of the bags. Take a bag and lay it flat on a surface - you want to see as much of the parts inside as possible without them obscuring each other.
Now try to identify the most unusual pieces, that are most likely to be unique to the set you have. Anything large, transparent, printed or having a complex form is a good starting point; but be prepared to backtrack if needed. Knowledge of the most common LEGO pieces and the most popular colours is a great help in this phase, but persistence can stand in for it just as well.
To identify the exact piece, visit Bricklink's part catalogue, where you can find all LEGO elements ever officially released (and a few more that were never sold!) in neat categories. This is just like a library, where you'll eventually find what you're looking for, but might need to search in a few different sections. Having the dimensions of the part is usually a good idea, as most parts have that in their name. Once you've identified a part in your bag, try to match its colour as well from the list of "Known Colors" under the tab "Color Info". Then count how many times can you see this exact piece in the bag. Note the following for each identified part: 1) Item number, 2) Colour, 3) Amount in your bag.

For example, take a look at this bag:

The key identifiable parts here were:

# on pic
Piece name
Piece number
Colour
Amount

1
Plate 6 x 6
3958
Black
1

2
Brick, Round 2 x 2 with Axle Hole
3941
Yellow
2

3
Brick, Modified 1 x 2 x 2/3 with Studs on Sides
4595
Black
1

4
Brick, Modified 1 x 1 with Headlight
4070
Red
8+

After you have done the above step at least three times, you're ready for the next step. Now open Bricklink's "Appears in" page, of the multi-part variety. Here you can enter the previously found part numbers, colours, and how many times that part appeared in your bag. When done, click the "View Appearance" button.

You'll get either a screen like this:

or one like this:

In the first case, the combination you've entered is not found in the database - most probably due to a mistake in the entered data. Many parts have extremely similar variants, some colours are really easy to confuse with each other and sometimes counting parts is not so straightforward either, so don't get discouraged just now. Try some other combination of parts you've found, maybe attempt to identify another part from the bag and plug that into the form.
In the second case your set might just be among those candidates displayed (but beware of false positives caused by misidentified parts!), so let's find which one. Open the "Inv"entory of the first set (the purple link in the picture) and start matching the parts in your bag to those of the candidate set. If you find a part in your bag that is not included in the set: you've successfully eliminated that candidate - return to the list and open the second "Inv"entory.

If all parts of the bag are found in the inventory, you're (partially) done. Why partially? Because if there are more candidate sets, they might be matches as well! So let's check them too. Note however, that most sets contain many bags which are seldom separated from each other, so check the other bags to help narrow your list of potential candidates.
After you've definitely found your set, it's time to remove from your pile of bags all that belong to this one. With the set inventory in front of you, this will be a breeze compared to the beginning as you just started to look for uncommon pieces and counted studs.
If there are bags that don't belong to that set, put them to the side for another iteration of this same process.
Having collected all bags in your possession to this set, you can fetch the instructions by scrolling to the bottom of the set page on Bricklink, and clicking through to Brickset under "Other Databases:" (or open Brickset and find your set there based on the set number). There you'll find the instruction manual for most sets.

Have fun and feel free to open a new question if you have problems or questions with any of the above steps!
Comment: Perfect answer... but the question already existed. :/
Comment: This is perfect - the canonical example of a canonical question/answer on how to do something yourself, rather than a plethora of separate "ID my set" questions.
Comment: @Downvoter, what could be improved about this answer?


Read the Data from Excel sheet into datatable without empty rows in C#

Question: I have a problem for reading data from Excel sheet using connection string. I am getting data. But problem is blank rows also coming. I don't want to get blank row. Can any body help me.
Thanks in Advance.
Mehar
Answer: If there are blank rows in your sheet, you will get blank rows when you read the Excel sheet. Either remove the blank rows from your sheet or add logic to detect and ignore blank rows.
Answer: If it's extra rows after the data you want, you will get them if there is formatting on the cells. Select the extra range, right click and do Clear Contents.


Why bootstrap-select plugin not working with ajax

Question: I have created dropdown list for category and from that category after that I  created another dropdown list for subcategory using ajax it works fine. But in second dropdown I want to select multiple option for that I am using bootstrap-select plugin. From this plugin I am using selectpicker class. On any file this plugin works fine but on ajax response page it does not show the effect of that plugin selectpicker class. Why is it so?
please help...
Answer: AJax does not work with bootstrap-select
populate the second drop down and use this to refresh it after ajax is complete and options are populated


Can the Stolz-Cesàro theorem be used to prove L'Hospital's rule, or viceversa?

Question: Stolz-Cesàro theorem is usually stated to be the discrete version of L'Hospital's rule. I was merely wondering whether one of these theorems could be used to prove the other (I couldn't find any proof that does this online).
Answer: I found a proof of L 'Hopital's rule that makes use of Stolz-Cesaro for the case $g(x)\rightarrow \infty$.
I've noticed recently that in the hypothesis of L'Hopital's rule it is often assumed that $f$ and $g$ need be defined and differentiable at the point $p$ which is being approached in the limit (this is done in the proof I mentioned and in baby Rudin). Yet the theorem still holds even when $f$ and $g$ are not defined nor differentiable at $p$, so I will rewrite the proof with care so as to prove the theorem in the more general case.

Theorem: Let $f$ and $g$ be real functions differentiable in the open interval $I$ except possibly at the point $p\in I$. Assume that $g'(x)\neq 0$ for every $x\in I-\{p\}$ and that $$\lim_{x\rightarrow p}\frac{f'(x)}{g'(x)}$$ exists and equals $L$. If either
i) $\lim_{x\rightarrow p}g(x)=\pm \infty$, or
ii) $\lim{x\rightarrow p}f(x)=g(x)=0$,
then $\lim_{x\rightarrow p}f(x)/g(x)$ exists and equals $L$.

Proof:
i) Suppose $\lim_{x\rightarrow p}g(x)=\infty$. Consider all points $x\in I$ less than $p$, since $g'(x)\neq 0$ we have that $g'$ is either positive or negative, yet $\lim_{x\rightarrow p}g(x)=\infty$ implies it can only be positive. We may also assume $g(x)\neq 0$ by making $I$ smaller if necessary.
It suffices to show that for any monotone sequence $x_n\rightarrow p$  we get $f(x_n)/g(x_n)\rightarrow L$, so let $x_n$ be such a sequence. Regardless of whether it is approaching $p$ from the right or the left, we have that $g(x_{n+1})>g(x_n)$. Stolz-Cesaro gives
$$\liminf \frac{f(x_{n+1})-f(x_n)}{g(x_{n+1})-g(x_n)}\leq \liminf \frac{f(x_n)}{g(x_n)}\leq \limsup \frac{f(x_n)}{g(x_n)}\leq \limsup \frac{f(x_{n+1})-f(x_n)}{g(x_{n+1})-g(x_n)}$$
By Cauchy's Mean Value Theorem there exists $y_n$ between $x_n$ and $x_{n+1}$ such that $$\frac{f(x_{n+1})-f(x_n)}{g(x_{n+1})-g(x_n)}=\frac{f'(y_n)}{g'(y_n)}$$
noting $\lim_{n\rightarrow \infty}f'(y_n)/g'(y_n)=L$ gives the desired result.
ii) Let $\epsilon >0$. Then there exists a neighborhood $U=(u,p)$ of $p$ such that $x\in U$ implies $$\Big| \frac{f'(x)}{g'(x)} -L\Big| <\epsilon$$
Let $y_n\rightarrow p$ be a monotone sequence in $U$. By Cauchy's Mean Value Theorem there is a sequence $z_n\in (x,y_n)$, so that $z_n\rightarrow p$, such that $$\frac{f(x)-f(y_n)}{g(x)-g(y_n)}=\frac{f'(z_n)}{g'(z_n)}\in (L-\epsilon,L+\epsilon)$$ therefore $\lim_{n\rightarrow \infty}\frac{f(x)-f(y_n)}{g(x)-g(y_n)}=\frac{f(x)}{g(x)}\in [L-\epsilon,L+\epsilon]$ for any $x\in U$, so $\lim_{x\rightarrow p^-}f(x)/g(x)=L$. The other direction is similar.


Reducing the output of AES to 64 bit

Question: Is it possible to reduce the output of AES after encryption into 64 bit with the possibility of a reversible before decryption Without any error
Comment: If you want to encrypt something non-block sized (vs get a 64 bit PRP) then consider using a mode such as CTR.
Comment: FFX mode. But it's slow and complicated.
Comment: What does "the possibility of a reversible before decryption Without any error" mean? Your question starts out reasonably, but seems to trail off into ungrammatical nonsense.
Comment: I would investigate Karnaugh Maps, and the Quine-McCluskey algorithm if you're interested in reducing Boolean expressions.                                                               https://en.wikipedia.org/wiki/Karnaugh_map   https://en.wikipedia.org/wiki/Quine%E2%80%93McCluskey_algorithm
Answer: There is no way to reduce the output of a single AES encryption operation to 64 bits with the possibility of decryption without error.
There are however ways to use AES to build a 64-bit cryptogram that can be decrypted without error. The simplest is: encipher the constant zero with AES, keep the first 64 bits, XOR with the plaintext to get the cryptogram. Problem is, that's insecure if the AES key is used more than once.
There are ways to allow several uses with the same key:

If an initial IV setup is tolerable (e.g. the IV overhead negligible compared to many later 64-bit cryptograms delivered in order), CTR mode is fine, as noted by Thomas M. DuBuisson.
Construct a 64-bit symmetric Feistel cipher using AES encryption for the round function (AES-encipher the concatenation of the round number and 32-bit input); with 10 rounds for good measure, and perhaps using addition modulo $2^{32}$ rather than XOR for combination of the output of the round function (so that the cipher is not always an even permutation, which would be noticeable after $2^{64}-2$ plaintext/ciphertext pairs), that's a secure 64-bit block cipher. Beware however that with this method (or any 64-bit block cipher) alone, identical 64-bit plaintexts will be recognizable as identical 64-bit ciphertexts.
FFX mode is another possibility, as noted by CodesInChaos.
Answer: The AES itself is an standard with a block size of 128 bits and 3 different key sizes (128, 192 and 256). The Rijndael, the winner of the AES contest, was proposed with this block size but with 5 different key sizes (add 160 and 224 to the previous 3).
This suggest a bigger flexibility in the Rijndael. In fact, playing with the parameters and the maths behind the Rijndael one can produce almost any arbitrary block and key size combination. Don't forget that this is not AES, but Rijndael.
Apart from this generalization, there are other algorithms designed designed to be 64 bit block like mCyrpton, present, katan/ktantan or Prince to mention some that I know. The cryptoanalysis made by the community is proportional to its impact. The the Rijndael has been more tested (on its original setup).
Apart from the CTR block cipher mode mention on a comment of a previous answer, you have other possibilities to think using an already tested implementation of the AES: Format preserving encryption.
Any solution you apply depends on where you apply, what are your needs. But focus, don't implement your crypto unless you are doing a research or it is going to be publicly review before and during production phase.

Reducing the output of AES to 64 bit


How to prevent fringing?

Question: When using my Tamron 16-300mm lens I frequently experience chromatic aberrations in my photos. how so I prevent this?
Answer: You can't, really, unless you want to change to a better lens (they'll have that too, to some amount, but probably less obvious). Super zoom lenses like the 16-300 do always have various optical problems, a trade-off you'll have to take for the long zoom range.
The good news: chromatic aberrations are really easy to correct in post processing, if you shoot in RAW: good post processing applications, like Lightroom, will offer simple one-click removal of CA, LR even gives you automatic profile based correction of other problems, like distortion and vignetting, provided a profile for your lens exists, or you can even create one yourself.
Answer: Chromatic Aberration is one of major aberrations that thwart us from making a faithful image. Violet light has the shortest wave length thus it is the most refractable, it comes to a focus nearest the lens. Red with its longer wave length comes to a focus furthest downstream. Orange, yellow, green and blue focus in-between In other words, each color has its own unique focal length. Now image size is a function of focal length thus the red image is the larger and the violet image is the smallest. What we get is superimposed images each a different size and color. This shows itself as a fringe of color with the red image rimming this cluster of images.
The lens maker can mitigate but not eliminate. This aberration (color fringing) will be most obvious when you zoom to achieve higher magnification. Your only resort is to use high end editing software. PhotoShop and others feature routines that mitigate Chromatic Aberration and others as well.

How to prevent fringing?


How to create service in Android and consume it?

Question: I am very new to the Android platform. Now in my app I want to create service and so please give me some info that how to create a service and consume it in my app. And how to start the service when the OS starts up?
Answer: All the information that should be necessary, including examples on how to create and consume services, is available directly from the Android documentation here.
It is doubtful that any answer could provide more insight into creating and consuming Services then that link.


What is the passport validity period requirement for a Kuwait employment visa?

Question: My passport is going to expire on 30 July 2020, and I have a job opportunity coming up in Kuwait. Will I be eligible to get this visa, which is for a 2-year contract?
Comment: Your nationality?
Answer: You will first get a normal visa (business visit) which will allow you to enter the country. Once you are landed, the company will then transfer you to the work visa category.
To get the initial visa, you just need to have a valid passport - for that, your passport's expiry is okay.
During the transfer process, the company will stamp your work visa. The regulation states that the visa duration cannot be more than the passport duration. Most likely the company will stamp you a 1 year visa, then renew it for the second year.
You must renew your passport before you can renew the visa - and you can approach your local embassy or representative mission in Kuwait to handle that formality.


Why does the C-C bond break earlier than the C-F bond in the pyrolysis of perfluroethane?

Question: According to me $\ce{C-F}$ bond is highly polar and thus is a weaker bond as compared to $\ce{C-C}$. Hence, $\ce{C-F}$ should break first in the pyrolysis of perfluroethane. Instead, in J. D. Lee, it is stated that $\ce{C-C}$ bond will break first. Why?
Comment: What makes you think the C-F bond is weaker?  In the tables of bond enthalpies I've seen, the C-F bond is considerably stronger than the C-C bond.
Comment: I would be cautious about the relationship between bond polarity and bond strength.   A bond can be strong and nonpolar (N2), strong and polar (C-F), weak and nonpolar (I2), or weak and polar (HI).  There's definitely correlation, but it isn't perfect, and should  be used with caution.  After all, the two phenomena arise from *related* but not identical causes.
Comment: I think that the main reason is that the CF3 radical would be delocalised (hyperconjugation?). Another reason could be stearic repulsion.
Comment: @Christopher Grayce i had misconception that high polarity always make a bond weak but now i got cleared that it can even make a bond strong by making bond ionic......
Answer: I got this explanation from one of my seniors.
It is true that $\ce{C-F}$ bond is highly polar as fluorine is more electronegative than carbon. In fact it is this very difference in electronegativity that makes C-F bond very strong. This is because, in addition to the covalent bond strength between carbon and fluorine, there is an additional electrostatic attraction between positive carbon and negative fluorine.
We can think of it has the $\ce{C-F}$ bond has both covalent  and ionic character. This makes C-F bond extremely stable and hard to break.
In fact in organic chemistry we usually say that the $\ce{C-F}$ bond is not broken in reactions.

We can also verify this from their bond energies:
$\ce{C-F}$: $\pu{544 kJ mol-1}$
$\ce{C-C}$: $\pu{346 kJ mol-1}$
Comment: Another way to think about the difference in bond energies is to think about the stability of radical species formed after bond homolysis, which is likely the process occurring during pyrolysis. The general trend is that free radical stability decreases with increasing electronegativity. See: https://www.masterorganicchemistry.com/2013/08/14/bond-strengths-radical-stability/electronegativity.
Comment: Lemal mentions that the charge on C is +0.76 while that on F is -0.19. This shows how large the separation of charge actually is and how strong the ionic contribution to the bond is. Lemal, D. M. (2004). Perspective on Fluorocarbon Chemistry [Abstract]. The Journal of Organic Chemistry,69(1), 1-11. doi:10.1021/jo0302556
Comment: One more reason is that-----Even CF being so polar bond but due to very small bond length and very small F size  IT IS MORE STRONG THAN CC BOND


Can't boot Fedora from Kali's Grub

Question: I've had Windows 10 and Fedora 24 installed, dual-booting, and it has been fine, but I just installed Kali in the remaining 200 GB, and the bootloader it installed can't boot Fedora. If I go into my UEFI setup and boot from the bootloader that Fedora installed, it boots perfectly, but if I try to boot Fedora from the bootloader that Kali installed, it says it's in emergency mode, and I get a login prompt, but no GUI whatsoever. I'd like to be able to boot my three operating systems in the same place. Is there any way to fix this?
Answer: I'm about to attempt this as well.  From what I've read elsewhere, Kali doesn't include lvm in their default initrd.  I'd suggest installing lvm and rebuilding initrd.  Alternatively, reinstalling Fedora will likely result in getting the Fedora grub image, which should boot Kali fine.

Can't boot Fedora from Kali's Grub


Is there a reason many EEE undergrad programms have a Complex Analysis Course?

Question: I know the very broad applications of complex numbers in engineering, although I don't understand the applications of complex functions of complex variables. Things such as the Residues, Cauchy Goursat, Cauchy integral formula are being used in advanced topics in Theoretical Physics. How about Electrical & Electronics Engineering?
Comment: One has to recognize that any effective higher education HAS to over educate you. So even if it does not particularily matter for your day to day job it might be a essential tool in some subfield research. So generally i dont need even a quarter of all the things they taught me. But its a good foundation to things they didnt teach me.
Comment: What about the reverse question: are they wasting your time by including a course you don't need?
Comment: All EEs at my university have to take a mechanical dynamics course in second year. It is by far the most difficult of our courses in that year. Our professor told us that one time, a student asked him why they had to take this course and his answer was because motors spin. So from that one three term equation $$v = \omega r$$ on the inside cover of our textbook which we need, we take the entire mechanical dynamics course. Well, it's helped me in other ways too such as calculating motor torque requirements for land vehicles on different terrain, inclines, accelerations, speeds, wheel diameters.
Comment: The future is unknown, so they prepare you with knowledge you may need.  It is easier to accept the brainwashing of education than fight it!
Answer: The obvious examples would be the solutions to Maxwells equations for wave guides.
Post WWII, MIT academics formed the opinion that Electrical and Electronics engineering was changing so fast that nothing practical they taught their students would be of any enduring value in their careers. The solution that was adopted was that professional engineering students should be taught underlying theory, which would remain true and provide the basis for ongoing continuing practice.  There was never the expectation that common practicing EE's would actually use the Cauchy residue theorem to solve electromagnetic wave equations on a daily basis: just that they would be able to understand the derivation and apply the results correctly.
Answer: Complex numbers come up in electronics or electrical engineering as soon as AC voltages meet inductors or capacitors.  With an inductive or capacitive load, the current ends up out of phase with the voltage.  A complex number can be treated as a phase and magnitude, just what you need to handle this situation.
So the impedance of a device to AC is the equivalent of the resistance to DC, but it's a complex number.  And the result of applying Ohm's law also ends up complex.
How complex this complex maths needs to be will depend a lot on what you're studying.
Answer: These are really the basics of ONE-variable complex analysis (so complex variable, not complex variables). Of course you need to know the stuff - going beyond the first two years of physics will be hard if you don't. (In fact, once you know more analysis, the way even very good introductory physics textbooks are written starts looking very funny in retrospect.)
More concretely: it should be pretty clear that an electrical engineer should have a solid grounding in Fourier analysis. Going beyond a certain basic level in Fourier analysis without knowing any complex analysis is... rather awkward.
(I was just wondering: how do you prove that the Gaussian is its own Fourier transform without using complex analysis? I looked it up, and yes, there is a short proof without complex analysis, but it must have been found by someone clever. With complex analysis, the proof is extremely natural.)


FZS600 won't start and gauges keep turning on and off

Question: I have a 2003 Yamaha FZS600 that lately started to drain the battery while it's not in use for 2-3 days. I bought the battery in this year's February and if I charge it it does its job.
Yesterday I wasn't able to start the motorcycle normally again so I jumpstarted it (works & goes perfectly that way). After a few miles I noticed that instruments are going off and on again. The headlight stays on, engine runs perfectly though.
When I hit the PASS light or switch on and off the headlights it does that almost everytime too.
Any ideas where to start checking things?
Comment: Welcome to Motor Vehicle Maintenance & Repair! It sounds like your bike isn't charging the battery. I don't know about a bike, but when the battery starts getting low on a car, it can cause the issues you're talking about with the gauges going wonky. Put a multimeter on the battery with the engine running and see what it reads.
Answer: Wiring harness, pull the tank and disconnect the main harness connection, visually inspection and contact cleaner might help. Sounds like you have a failing connection from battery to fuse block, the increased power draw when you energize the lights is an indication of improper current flow.
Answer: Thanks for the tips! I ended up at my mechanic and turned out the generator regulator was faulty. There was no charge on my battery so it drained totally, I had to replace that too. But finally with my new regulator and battery, everything just works fine.


Paying Off Credit Card, Scam?

Question: I have someone who wants to pay off my credit card for me and all he asked for was my username and password for my online account to make the payments. I've checked my account and I can't find any important information that he could find from just having those two things but I'm still a bit unsure. Advice?
Comment: Welcome to Money.SE. This is a scam, and a common one. Never give anyone any login details. Does this answer your question? [Sugar daddy wants my online banking login info to make deposits — is it a scam?](https://money.stackexchange.com/questions/97274/sugar-daddy-wants-my-online-banking-login-info-to-make-deposits-is-it-a-scam)
Comment: Is there a way to change the address and request a new card ? Is there a way to change the password ?
Answer: No. Never share your username/password with anyone. Go look on your bank's Terms of Service, it specifically forbids that. When you signed up for your account, you agreed to never share your password.  Keep your word.
All they need to pay off your card is a payment slip.  There's one on every statement; so go get a PDF of your credit card statement. Page 1 will have a payment slip meant to be printed out; it's intended for making payments via postal mail.  That's all they need.  Attach a paper cheque and mail it in.  A real friend/family member could make do with that.
They want your username/password for nefarious reasons.  If you send a payment slip, they wil give you some sing-song about how that won't work for them - just watch!
--
Honestly, the happiest possiblity here is that the money is quasi-real, but is being laundered: it is either proceeds of unrelated crime, or stolen out of someone's bank account.  Once they pay off your credit card, now comes the confidence game: they will ask you to buy things for them e.g. iTunes gift cards, Visa gift cards, etc.  You will send along the relevant codez off the cards, they say "thanks" and then, the credit card payoff payment will reverse. The victim will claw it back, or the government will seize it.  Boom, you're suddenly late and overlimit.  The crooks' logic is they're stealing from your bank, but actually, you are on the hook for it. Your credit rating gets burned, and you get sued.
Comment: none that you can trust a scammer with @Marie They are experts at this game, you are not. Don't play chess with Bobby Fischer and expect to win.  *Lemme guess, the scammer did not like the idea of a payment slip...*
Comment: @Marie There is no safe way to receive money from an untrusted source.  Even if the money is **really** real, it could have been stolen or obtained through illegal means, making you an accomplice (and likely the one left holding the bag when the cops show up, no less.)
Comment: Yes, prosecutors are getting very fed up with innocent shills doing money laundering.  Their view is increasingly that the shill should have smelled a rat when theey were getting something for nothing, and should have investigated... As you, in fact, are.
Comment: Do you know if there are other ways to receive payments safely and easily other than Venmo and PayPal? Besides the payment slips?
Answer: This is a scam. There are plenty of ways to transfer money to you that you could then use to pay off your credit card that don't involve you giving anyone any passwords.
Once someone has control of your account they could probably

change the password
change your address
order a new card
run up bills on the new card
reset the address again
Comment: Yes, they can completely steal the OP's identity and do major damage to their credit history and run up a lot of charges. No one should ever give out their login credentials to anyone, even their spouse or other family members. There are ways to make 2nd logins on some accounts, but most times even that isn't needed.

Paying Off Credit Card, Scam?


Category theoretic proof of Stone's representation theorem

Question: Can Stone's representation theorem about Boolean algebras that every Boolean algebra $B$ is isomorphic to the algebra of clopen subsets of its Stone space $S(B)$, be proven categorically using Yoneda lemma ?
Comment: Is there some reason you would expect there to be such a proof?  I'm sure you could find a way to phrase the proof so that it uses Yoneda's lemma somehow, but ultimately it's a theorem about the actual algebraic structure of Boolean algebras and is not going to have a proof that is purely abstract nonsense.
Answer: Here is a category-theoretic proof of a version of Stone's theorem; the idea is that we will deduce Stone's theorem for all Boolean algebras from Stone's theorem for finite Boolean algebras. So, first prove in any way you like that the category of finite Boolean algebras is equivalent to the opposite of the category of finite sets. Next, the category of Boolean algebras is, for general categorical reasons, the ind-category of the category of finite Boolean algebras, so its opposite is
$$(\text{Ind}(\text{FinBool}))^{op} \cong \text{Pro}(\text{FinBool}^{op}) \cong \text{Pro}(\text{FinSet})$$
so the opposite of the category of Boolean algebras is the category of profinite sets. There's some additional work to do to match this up with the usual statement of Stone's theorem.


How to smooth the separation between 2 hardboards on the floor?

Question: When fitting hardboard on the floor (for gluing vinyl above it) there are obviously more than one piece of hardboard. Is it recommended to do something about the separation between the different pieces of hardboard, such as putting some duct tape on top of the edge of each piece?
Comment: how does this differ from your other question?
Comment: This one is about separation between any two pieces of hardboard, the other one is about general problems (yes, located at the edges but that's the only similarity) that could arise from a difference in thickness between two pieces of hardboard. I thought I could ask them both at the same time, but then this would go against the rules of this site I guess. If what I actually did is also against the rules then I don't know what I should have done.
Answer: The spacing you leave between the sheets of hardboard (or whatever other underlayment that you put down) will be determined from the manufacturer's instructions. Some materials need to have room for minor expansion over temperature and humidity ranges. If the proper gap is not left then the sheets of the material may buckle and create an uneven floor with bumps during some seasons. As such, if gaps are recommended then it would be advised to not try to fill them in with other materials.
The material expansion characteristics of the underlayment need to be taken into careful account when considering what material types that you would lay and glue down over the underlayment. Make sure that the material (hardboard) that you are using is compatible with your vinyl material.
If large expansion gaps between your sheets of underlayment are say more than 1/8 inch (~3mm) then that may not be suitable for use under vinyl. Top load on the vinyl could cause the material to crack in places where it is pressed into the cracks.
If you have a compatible underlayment material but have large gaps due to poor installation then you will have to either remove and replace the underlayment and bring gaps in line with 1/16" to 1/8". It may also be possible to trowel in a crack filler material between the sheets but that all depends upon the manufacturer's instructions regarding the expansion requirements for the underlayment material as stated previously.


Why were Andrew Garfield and Tobey Maguire Peter Parker?

Question: Generally the concept of the multiverse is a possibly infinite collection of universes of identical composition that only differ because of alternate choices its inhabitants make. So was there any in-universe explanation as to why in the MCU there are parallel universes that agree in form, but not in substance? In other words why do the universes all have a Peter Parker, an Aunt May, a Spider-Man, and presumably an Electro, Dr. Octopus etc, but they are all actually different people in each universe?
Comment: What's the point of a universe without Spider-Man?  Who would want to live there?
Comment: You're asking why Marvel's multiverse doesn't follow a rule that it never established in the first place?
Comment: i think they call spider-man universe a Spider-verse, no? It's a bunch of parallel universes centered around spiderman/girl. If it's called Antverse it should be centered around Ant-man and not necessarily have spiderman in it. To sum it all up, it would be money, if Marvel need to reboot or fuse new idea with existing characters, making an alternate universe is easier than creating whole new characters.
Comment: More of an in-universe answer. I mean why Andrew and Tobey were in the movie is obvious. I haven't seen DS2 or any of the TV shows yet so I am curious if there has been any explanation of the nature of the Multiverse that would allow basically different people to be the same person.
Comment: I'm practically sure the answer is because they decided so. It's not so different from Marvel comics in which you have different variations with more or less some differences (I'm mostly thinking about Earth-616 and Earth-1610). They may be the "same people", but that doesn't mean everything in their respective universe is identical.
Comment: At the risk of a minor spoiler, Doctor Strange 2 establishes that there's a universe where everything is made of paint, so I guess it's not a wild stretch if there are universes where Peter Parker and Aunt May look a bit different.
Comment: Strange very clearly stated that the spell inadvertently started to pull in "everyone who knows Peter Parker is Spider-Man"... That includes the other Peter Parker Spider-Men. Notice how it didn't pull in Miles Morales...
Comment: If you're looking for a multiverse that follows a more structured logic, I recommend short novel "The infinite assassin", the first short novel in Greg Egan's collection [Axiomatic](https://www.goodreads.com/book/show/156783.Axiomatic)
Answer: As we see in Loki, there's a universe (or possibly just a timeline, although that's probably over-complicating things) where Loki is blonde and female (plus one where he's an alligator). And as we see in Doctor Strange and the Multiverse of Madness (very mild spoiler):

 there's a universe where everyone and everything is made of paint.

Apparently in Marvel's multiverse, someone can have the same name and abilities as someone in the universe we've been watching, but have a different physical appearance, which makes just as much sense as anything else multiverse-related.
Comment: @Clockwork: There's your Phase 5 unlikely hero right there.
Comment: _someone can have the same name and abilities as someone in the universe we've been watching, but have a different physical appearance_ You mean there's a universe out there in which Thanos has Richard Marx' haircut?
Comment: That was taken from Rick and Morty. I'm 99.99% certain.
Answer: Your interpretation of the multiverse is not correct or doesn't explore the full range of possibilities.
Generally speaking infinite choices make infinite possibilities and that opens the possibility for the writers to write any story changing anything. In that sense, in universe, Miles Morales as Spider-Man is a clear indication as it is all the different variations of Spider-Man (and other heroes) on the multiverse, where Spider-Man is not Peter Parker (or vice versa).
Note not ALL universes have an Electro or a Miles Morales. In fact in the other universes there's an explicit mention that there is no Avengers. It is made explicit in the movie that certain villains have not appeared in certain universes, Electro not being present in the Tobey Maguire OR Tom Holland universe.
While this is not specifically stated in the movie it is clearly hinted by the fact that Aunt May never married. This means she never met uncle Ben and in fact it is made as a point in the movie for her to be the one that quotes the famous "with great power comes great responsibility".
If Aunt May never married or met uncle Ben, if follows that Richard Parker may have met someone different than Mary Parker. Furthermore, Mary or Richard parents may have been different, therefore making the physical appearance of Peter Parker completely different.
Obviously this is an in universe answer. Given the fact there are infinite parallel realities (as each reality is formed by a branch in decision), that in itself justifies that there're infinite possibilities to chose from, including the ones that are chosen by the writers.
Comment: Ben does exist in the main MCU universe. We have various mentions of him, it's just they didn't feel the need to do the whole Ben death thing again so we just never see him.
Comment: "the fact that Aunt May _never married_" — when do they say that in _No Way Home_?
Comment: There's also that moment when they start comparing the different kind of stuffs they fought in their respective universe, and they only mention stuffs that never existed in the others.
Comment: @TheLethalCarrot - Indeed; https://scifi.stackexchange.com/a/258702/20774


Time -- Gone Eight?

Question: I'm reading a novel set in the UK (I'm in Maryland, USA).  In the novel, someone asks the time; the reply is, "gone eight."  What does this mean, please?  Thank you.
Comment: *gone eight = **past** eight [o'clock]*
Comment: [Oxford Dictionary](http://www.oxforddictionaries.com/definition/english/gone#gone__14)
Comment: @Andrew Leach Have you found anything to touch the answer below in a dictionary?
Answer: gone with a time means later than, so gone eight means after eight o'clock.
You'd more often use it in circumstances to emphasise the lateness -

It's already gone 9.30, I was supposed to be in work half an hour ago.

and although you can use it for things which have not yet happened

I don't think he'll arrive 'till gone midnight

... you wouldn't use it to make plans:

Let's meet up gone lunchtime

you'd use after in this case.
Comment: I was about to say this is genref. Then I read your answer. Much better than the bare bones in Collins. At least I agree with their classification as an adverb here (makes a change). But it's almost certainly the remains of a verbal construction.

Time -- Gone Eight?


Why would banks offer negative interest rates?

Question: I recently saw news that Danish bank Danske Bank is going to be offering -1% return on balances over $16,000. Obviously nobody wants a negative return on their balances so nobody is going to want this. Why is a bank disincentivizing their customers to hold balances with them? Does that have to do with central bank policies controlling the available returns that can be offered? If not, why would a bank be electing to do this themselves?
Comment: What's the difference between a negative interest rate and an account maintenance fee?
Comment: It rather comes down to whether you think 1% of $16,000 dollars is better than losing it all if the burglars find it under your mattress doesn't it? I.e. if you have a large amount of money what risk free options do you have to keep it?
Comment: Does this answer your question? [Why would I buy a Bond at a Negative Interest rate?](https://money.stackexchange.com/questions/15963/why-would-i-buy-a-bond-at-a-negative-interest-rate)
Answer: Because the Danish central bank is charging banks negative interest on the deposits they hold.

Since the central bank is charging member banks for the assets they hold to be able to pay depositors, the banks don't want to incentivize customers to park assets with them and charge a negative interest rate in order to convince customers to move their assets elsewhere.
This is similar to what is happening in other European countries such as Germany at the moment where banks are unable to continue absorbing the negative interest rates they are charged by the central bank and are passing the costs on to customers in the form of negative rates on large balances.
Comment: @Runeaway3 - That's likely a separate question and probably more appropriate for the economics stack.  Danish interest rates aren't substantially different from the rates set by the ECB so most European countries are in roughly the same boat.
Comment: Ok this makes sense. What does it say about the state of monetary policy/currency strength/national debt/etc... that the Danish central bank is charging banks those negative rates?
Comment: The use of negative interest rates by central banks is to force banks to make more loans and stimulate economic activity.


How to transfer Clash of Clans from one iOS device to another

Question: I have two iPhones and an iPad 2. One of the phones is an iPhone 3GS running iOS 6.1.6 and the other is an iPhone 4 running iOS 7. Under the same Game Center account they each have a separate village for Clash of Clans. I just got my iPad and wanted to transfer the game on the iOS 6.1.6 device to my iPad. What I was wondering was, if it's even possible to link a game on Clash of Clans from an iOS 6 device to an iOS 7 device, and if so how do I do so?
Comment: We really didn't get a good answer on [this similar question](http://apple.stackexchange.com/questions/114951/transferring-clash-of-clans). Perhaps we need someone to just [ask the developer how to move a village](http://clashofclans.wikia.com/wiki/Device_Linking_Guide) and pop up an answer here?
Comment: This is old but it's recently changed I have have had to do this recently.  In iOS there is now a 'connect Supercell ID' option.  I moved my account from my iPhone to my iPad by clicking this button in the in game settings.  I had to do the normal register email mumbo jumbo.  Once done I installed CoC on my iPad; completed the tutorial; went into settings and clicked the same 'Supercell ID' button and logged in using the same email.  It promted me "are you sure you want to overwrite this new villiage. I clicked yes and boom.  Done.
Answer: Yes it is possible. All you need to do is have both your devices next to that you want to make the transfer with. Then tap the settings button in clash of clans and you will see "link a device". Follow the on screen instructions after that.
If you have a new account already made on your new device past town hall 4 you are unable to link them. You will need to contact supercell for further information, which is what I had to do.
Answer: With a 3rd party USB iPhone file viewing application on your Mac or PC, such as iExplorer or DiskAid, one can try copying all the files from an app on one iOS device to your Mac, and then copy them all of them onto the other iOS device.  To be safe, force-quit the apps on both devices first and do a complete backup of the target device before trying this method, as it can potentially completely mess up an app, and require it to be deleted and re-installed.
Answer: CoC can be transferred with the "link a device"-option.
Another way to do this is by using the same apple id for gamecenter.
You can change the apple id under Game Center in settings>game center.
Via this way it will also be possible to transfer account that are linked to gamecenter, but do not have an "link a device" option built in.
Answer:
Download iExplore on your computer.
Connect your old iOS device to your computer, browse to /private/var/mobile/Containers folder then copy the Clash of Clans folder to somewhere in your computer.
Connect the new device then copy that folder to /private/var/mobile/Containers (iOS7) or /var/mobile/Containers/Bundle/Application (iOS8).
Login with your related Game Center ID.
It will ask you if you want to play that Clash of Clans account or not.

Source: http://cocland.com/tutorials/transfer-clash-of-clans-from-old-ios-devices
Answer: The new version will fix the problem is not loaded games
Answer: Maybe can be possible making a backup with iTools and restoring into the new one.
Comment: Good start, can you expand your answer with more details please


Asymptotic variance for averages of trajectory functionals of Markov chain

Question: I am looking for references on theory for convergence rates of ergodic averages of a Markov chain in the more general setting where the functional is over multiple states or even a whole trajectory, but I am struggling to find the right keywords or even instances of these problems being considered.
Let $(X_n)_{n \in \mathbb N_0}$ be a Markov chain on a general state space $(\mathsf X, \mathscr B(\mathsf X))$, and let $\pi$ be an invariant distribution. There are several approaches to establishing a Markov chain law of large numbers; one of them is Birkhoff's ergodic theorem, whence under some mixing conditions one forms a dynamical system of paths of the Markov chain and obtains $\frac 1n\sum_{k=0}^{n-1} f(X_k) \to \mathbb{E}_{\pi}[f]$ a.s. and in $L^1$ for $\pi$-a.e. $X_0$.
Many presentations stop there, but in fact the theorem holds for functionals of paths, so that
$$\frac 1n \sum_{k=0}^{n-1} F(X_k, X_{k+1}, \dotsc) \xrightarrow[n \to \infty]{\text{a.s.}, L^1} \mathbb{E}_{\mathbb{P}_\pi}[F].$$
Now we might want to quantify the rate of this convergence, for example by the asymptotic variance
$$\lim_{n \to \infty} n \mathrm{Var}_{\mathbb{P}_\pi}\left(\frac 1n \sum_{k=0}^{n-1} F(X_k, X_{k+1}, \dotsc)\right).$$
Question: Under what conditions on the chain and $F$ is this limit finite?
My setting has a "nice" geometrically ergodic Markov chain, and so I am interested even in quite strong conditions, but it is not reversible.
Fairly simple sufficient conditions have been developed in connection to the CLT in the "usual" setting where $F(X_k)$ only depends on the current state, see e.g. these notes by Eberle (2023) or this survey by Jones (2004). I have found a slight generalization in Jensen (1989) for the case $F(X_k,X_{k+1})$.
For "finite horizons" i.e. $F(X_k,X_{k+1},\dotsc,X_{k+\ell})$ one might hope to connect to theory for strongly mixing sequences as in this question; there is a well-known AR(1) counterexample where strong mixing fails with infinite horizons, although for my purpose it would suffice with finite (but not independent) random horizon.
Answer: Obviously asking the question caused my literature search to uncover exactly the right reference. Essentially the common hypotheses as in the "usual" setting suffice for a finite horizon, but remarkably also if one has a stopping time horizon (making it a finite but random horizon).
Ben Alaya, M., & Pagès, G. (1998). Rate of Convergence for Computing Expectations of Stopping Functionals of an $\alpha$-Mixing Process. Advances in Applied Probability, 30(2), 425–448. http://www.jstor.org/stable/1427976


Do buck converters increase the ampere hours of a battery?

Question: I've read that they are 90% efficient compared to linear regulators so given the relationship between volts and amperes and that I want to power the project off of a 12V battery that has 18Ah and is charged using a small solar cell. The project itself only needs 5V, so if I buck the voltage down to less than half the required voltage, wouldn't the ampere hours close to double giving me 36+ Ah, or am I missing something about the relationships between volts and ampetes and the mechanism of the buck converter?
Comment: To answer the titular question: the *law of conservation of energy* says that nothing can increase the amp hours of the battery.
Comment: Not much can change the amp hours of the battery short of getting a new battery. But there's also nothing saying the amp hours of the (battery + buck converter) have to equal the amp hours of the battery.
Comment: And if you get a buck/boost converter, you can really bleed that battery dry.
Comment: @JoelB, yes, easily to the point where it won't recharge properly.
Answer: You are kind of on the right track.
The amp-hour rating of the battery specifies how many hours you could pull a certain rated current from the battery.
The buck converter to 5V won't change the amp-hour rating of the battery at all. But if you were to only pull half of the current from the battery then the battery will last twice as long.
So let's make an example here. As you stated you have a 12V 18AH battery. Let us consider, for sake of example, that your load at the stated 5V required 500mA (i.e. 0.5A) to run.
If you were to use a linear regulator to drop the battery 12V down to 5V the linear regulator would pull 0.5A from the battery and radiate (12V-5V)*0.5A = 3.5 Watts of energy as heat whilst delivering the 5V to the load. The 12V battery delivering the 0.5A would supply the regulator for 18AH/0.5A = 36 hours. The efficiency of such a system is EnergyOut / EnergyIn = (5V * 0.5A)/(12V * 0.5A) = 41.6% efficiency.
So if instead you used the buck switching regulator at 90% efficiency we can evaluate the battery life. The buck regulator operates as:
Energy Out = 0.9 * Energy In.
With a load of 5V @ 0.5A the energy being delivered out of the buck regulator is 5V*0.5A = 2.5W. Applying the 90% efficiency formula the regulator input energy would be 2.5W/0.9 = 2.78W. This wattage at 12V corresponds to 2.78W/12V = 0.231A draw from the battery. At this lower current the battery would last 18AH/0.231A = 77.9 hours.
As you can see the battery usage is hugely more efficient.
Comment: @zeffur - Actually the buck regulator power is included in the switcher efficiency figure. If I neglected anything is was the power consumed by a linear regulator. However for IC type linear regulators that power is typically very small compared to overall power being demanded that the linear regulator to dissipate.
Comment: One more wrinkle to this is that the battery voltage will change over time depending on the type of battery, so amp-hours * nominal voltage is not the watt-hour rating of the battery.  For a linear regulator, you really only care about amp-hours, but a switching regulator will draw more current as the battery voltage drops to maintain constant output power.
Comment: @Evan - You are totally right. But I had to position my answer so that the approximation that it represents was understandable by the OP who needs a gentle introduction how all this stuff works.
Comment: @Michael Karas - You also do not seem to have accounted for the power that is consumed by the buck switching regulator in your calculations.
Comment: After I wrote the question it I realized how I phrased the question wrong. Of course you can't get more power out of a battery, duh! What I was asking is will my battery last longer using a buck converter _relative_ to other topologies? And you got the gist of my question. Thanks, great explanation.
Comment: @Michael Karas - I see: "2.5W/0.9 = 2.78W" -->  2.78W - 2.5W  =0.28W.  Sorry about that.
Answer: Amp hours are not a great way of measuring battery capacity.  Watt hours is a much better figure.  If you stick a buck converter after the battery, the equivalent watt hours of the battery will decrease by the loss in the converter.  However, since the converter will draw fewer amps from the battery, the equivalent amp hours will increase.  This isn't necessarily the greatest comparison, though, as in this case the equivalent amp hours are at a different voltage after the converter.
Answer: To expand on what alex.forencich said, since it was apparently not well understood, what you are missing is that amp-hours is a good way of comparing batteries at the same output voltage. It's not a good way to compare batteries at different output voltages... or once you buck or boost the voltage.

When you pass the output of a battery through a theoretical DC-DC converter that has 100% efficiency, the Watt-hour rating stays the same; the amp-hour rating being Watt-hour/volts can go up or down depending whether the converter is buck or boost. E.g. 3Wh battery (1.5V*2Ah) can become 0.2Ah if we boost the voltage 10 times [to 15V] or can become 20Ah if we buck the voltage 10 times [to 0.15V]. And to address what Nick Alexeev said; this is as the battery is seen through the other (=output) side of the converter. Of course the Ah of the battery itself doesn't change.
But no practical DC-DC converter has 100% efficiency, so the converted power needs to be adjusted (multiplied) by the converter's efficiency. E.g. if the converter has 90% efficiency, the 3Wh rating becomes 2.7Wh after conversion. That's regardless of what the voltage you convert to is.
And regarding "90% efficient compared to linear regulators", you probably mean they can have 90% absolute efficiency. Linear regulators have maximum theoretical efficiency given by Vout/Vin; so for 12V to 5V conversion, a linear regulator cannot exceed 41.66% efficiency, and in practice will be less than that. And indeed a linear regulator cannot boost amp-hours because of this. Let's say you have X Wh at the Vin (inpt) voltage. This becomes XVout/Vin Wh at the Vout voltage; Vout is always less than Vin for a linear regulator. Now divide this XVout/Vin Wh by the output voltage to obtain X/Vin Ah at the output; that's exactly the same Ah rating as at the original/input voltage [for an ideal linear regulator], but note we have a [usually large] loss of energy/power because Vout is [significantly] lower than Vin.
So to summarize; no converter [switching or linear] can increase the Wh rating. A linear one cannot increase the Ah rating either.


Load Center in Kitchen Cabinet

Question: We just purchased a home built in 1965.  The house is very small and the Federal Pacific load center is installed in a kitchen cabinet.  I'm considering replacing it and moving it outside at generally the same location but to save cost wondered about the code for replacing in the same location inside the kitchen cabinet.  I assume the cabinet would have to remain empty to be compliant but not sure even that would make it ok.  It isn't ideal but there is literally no where else to install except where it is or directly on the outside of the house.
Comment: Yes, it is mounted inside the kitchen cabinet.
Comment: Is the existing loadcenter surface mounted or flush mounted?  And just to clarify, you have to reach *inside* the kitchen cabinet to access the loadcenter, correct?
Comment: How tall is the existing cabinet, and how many a) 120V and b) 240V circuits does the panel have currently? Also, how many amps is your main breaker?
Answer: Panels need a working space that is entirely kept clear at all times:

the width of the panel but at least 30" (no need to center).
36" depth for stand back room
78" (6'6") high
flat, not on steps.

Inspectors will generally let you slide on a tasteful cabinet door which conceals the panel but invades the working space as little as possible.
Junction boxes have no such restriction, and are allowed to be in the back of kitchen cabinets. (as long as they remain accessible).
Your best bet will be to find an appropriate location for the panel, and use the existing panel as a large junction box to splice extension wires.  Homemade junction box covers are permitted at the discretion of the inspector, so take your Federal Pacific dead-front to a guy with sheetmetal skills and have them make a new blank cover at least the same thickness and with edge screw holes in the same places.  Hit it with a coat of rattle-can Rustoleum.
As far s location of a new panel, think around the working space.  Places that sit on entries, halls and thresholds - so the working space is passively kept clear simply because it's a passageway.   Indoors is better than outdoors - weather is hard on costly breakers such as GFCI, AFCI and the smart breakers that I expect will be coming soon. (driven next-gen demand management and also the benefit of being able to add stuff without a service upgrade).
Answer: The cabinet must go. And also a counter, if there's one below. A breaker panel requires free working space in front at least 30 inches wide, 36 inches deep, and from floor to at least 6 1/2 ft high.
Answer: In a class action lawsuit, a New Jersey State Court ruled that the Federal Pacific Electric (FPE) Company "violated the Consumer Fraud Act because FPE knowingly and purposefully distributed circuit breakers which were not tested to meet UL standards…" (To see the Class Action Settlement Notice issued for New Jersey Residents, click here.) An expert who investigated the potential hazards of Federal Pacific Electric panels stated under UL 489 test conditions, that FPE panels fail to trip at a much higher rate than standard panels

We just purchased a home built in 1965. The house is very small and the Federal Pacific load center is installed in a kitchen cabinet.

If you paid for a home inspector to do a home inspection before buying, get your money back.
Further:  You should have this panel looked at and/or replaced by a competent electrical professional immediately.  "To be on the safe side, it's a good idea to replace any Federal Pacific breakers in your home."[1]

Load Center in Kitchen Cabinet


not publishing the form in Sharepoint site as a new form(Infopath) after changes are made to the existing form when opened

Question: How do I edit a Infopath form and not publish it onto the sharepoint library as a new form? I just want to make change to the old one and save it but not as as a new form.
I'm working on a workflow where I send a mail with the link of the form to the manager. He has to open the form and change a particular field. Once, that's done, he should send a mail to second level approvers. I'm able to send a mail to the manager but when manager clicks on the link, it opens the form and the changes he made is saved into another new form. Now because of this, since a new form is created, the workflow is altered.
Any help?
Answer: Create a Hidden Field
Add a Submit data connection
Add Custom Rules to Submit action
create a hidden field ->Drag-and-drop a text box control onto the form template's view. Rename the text box to 'filename' and click OK. Then select the filename text box and hit delete to remove the field from the view.
Go to Tools, Data Connections and click Add. Create a new Connection to Submit data to a SharePoint document library.

Enter the document library, and click the fx button and Insert the field 'fileName' in order to give the form submitted the name stored under 'fileName'. Select 'Allow overwrite if file exists'.

Give the data connection a name example "UniqueName"

Goto Tools, Submit Options, and click on Rules select perform actions using custom rules

Add rules as below

RULE1: Set condition: when filename is blank
Set Action1 Set field's value filename = concat (Myfield, now()); where myfield could be the field name you want to show on the form name(like title, contactname,date etc...)
in the filename=concat (Title, now());
Set  Action2 Submit using dataconnection use the one we created earlier i.e. "UniqueName"
Rule2 : Condition when filename is not blank
Action: submit using dataconnection same as in step 6
Once you have the two rules you can save and publish your form and will have no issues.
Comment: Can you please explain what the fileName is?  Is it a column in the library? If yes, can you also explain how does it get populated.
Thanks!
Comment: Updated the answer


MFC ActiveX keystrokes

Question: I have created an mfc activex control and want to handle the keystrokes. To handle keystrokes in child dialog. I override the pretranslate message in my child dialog class. To use pretranslate function in an activex control I have added hook.
As solution for the similar problem described at http://support.microsoft.com/kb/194294.
Now pretranslate function is calling but the problem when I press the ESC key or enter key, an assertion come at ASSERT(::IsWindow(m_hWnd));at wincore.cpp line 880.
Answer: I guess you use a function in PreTranslateMessage that assumes that the window is created. Put
<code>if (!::IsWindow(m_hWnd)) { return 0; }
</code>
in the beginning of your PreTranslateMessage and see if that helps.

MFC ActiveX keystrokes


Type Casting in Apps Script

Question: First time on StackOverFlow!
I am working on building an app that takes in a value through a UI Form TextBox. Once that form is submitted it calls a method that then appends a "/" to the value. The problem is that .append() is not available, because getElementById() returns a GenericWidget object and thus cannot be operated on as if it were a string. I have tried type casting it use .toString() in the var userinput = app.getElementById('input').toString; call and afterward using userinput = userinput.toString.
I have been working with Apps Script for about a month and a few days now and I think that casting to a different type other than GenericWidget would be helpful for anyone who wants to modify a value in a type specific way after passing the value to another method.
I have also done a good bit of research trying to find a solutiong for my problem but like a couple times in the past working with Apps Script I find that since it is a younger language there isn't as much helpful information as there is with languages like Javascript, HTML, and XML. Any help is appreciated.
Answer: You have to get the textBox value using e.parameter.textBoxName an then re-assign a value to the textBox. A short example will be more explicit
<code>function doGet(){
 var app = UiApp.createApplication();
 var textbox = app.createTextBox().setName('txt').setId('txt')
// add other elements, handlers, callBackElements, etc...
}

function changetext(e){
var app = UiApp.getActiveApplication();
var textBoxValue = e.parameter.txt ; // get the value in the text box
var txtBoxWidget = app.getElementById('txt') ; get the widget by its ID
txtBoxWidget.setText(textBoxValue+'/'):// assign the modified value
return app ;// update the UI with new value
}
</code>
Comment: Awesome. I didn't think to pull the parameter directly from the box. I've just been dealing with passing things by ElementById(). Thanks a ton!

Type Casting in Apps Script


url completion in cartoDB info windows

Question: By far the most of my data is taken up a column of long strings pointing to the source of the data for each point. I need to keep that. However, it would be neat if CartoDB could use this information (i.e. build the URL) without me providing the full URL, only the relevant ending (and save on the size of the table by not repeating the common part as a long string). Is this doable in their info window?
Answer: You can use the custom HTML editor of the infowindows to build something like:

 Go to {{adm0_a3}}

So if you have the endings of the URL stored in some column, you can avoid repeating the fixed part along all the table.
Comment: Thanks, I would love to try this, but I am not sure what is happening to my table. When I deleted the common string, the text file I upload shrank by 10 MB. When I try to change column types, nothing changed: `year` and `decision_date` can be changed easily, `hufvalue` cannot, because *then* I am notified I am still over the limit. Why didn't the extra 10 MB help? The table is at `https://sandorl.cartodb.com/tables/location_of_winners25mb/`
Answer: Try running a vacuum full (http://wiki.postgresql.org/wiki/VACUUM_FULL) in your table. There is an issue calculating the file sizes when an update is done in the table (https://groups.google.com/forum/#!msg/cartodb/XANeWhq9IMc/jV7oNfZXmAgJ).
Cheers!
Comment: Thanks, is this the response I should expect? `{"time":9.656,"fields":{},"total_rows":null,"rows":[]}`
Comment: OK, I found the way to run queries from the table view, without the API, sorry I overlooked it before. Now I am confident I ran `VACUUM FULL`, but it only saved me 0.1 MB. I deleted an entire column of strings (length: 10 chars), which still only saved me 0.6 MB out of 37 MB. I still don't know where all the space went, which is unfortunate for a service with a freemium model based mainly based on space constraints…
Comment: Hey Laszlo, could you share with me your table (if it is public of course) ?
Comment: How could I do that?

url completion in cartoDB info windows


Tightening sequence for water pump bolts (Peugeot 406 1.8 16V)

Question: I'm curious about the tightening sequence of this water pump. The manual says nothing about it. I have included 2 pictures and assigned numbers to the bolts. What sequence do you recommend for this type of water pump?
Answer: If there is no tightening sequence listed in the service manual, I would just use a star pattern.
Probably 1,3,5,2,4.
Comment: Can I use a pattern like cylinder head bolts? Starting from the middle and going towards the ends.
Comment: @NarimanAsgharian which order would you suggest that is like a cylinder head?  A cylinder head is not circular like this water pump.
Comment: @HandyHowie - I was thinking about the common cylinder head tightening sequence for most cars. What is your suggestion for the above water pump?
Comment: @NarimanAsgharian. I would do it very similar to what this answer says.  I upvoted this answer.
Comment: @HandyHowie  - So, you also agree with the star pattern. Ok, I'll go for it.
Answer: Tighten evenly, and to the torque specified but you have that from the manual.
Comment: Some manuals have a page of bolt sizes and associated torques. The manuals I have bought - from the dealer / manufacturer do have the torques listed and they include Peugeot, Citroen and Talbot as well as Chrysler, Rolls Royce, Bentley, Jaguar, Hillman, Landrover to name but a few. Don't have them all to hand but I do know Peugeot does list torques as I used to work on them.
Comment: A google search can work wonders: https://static.piecesauto.com/images//medias/docs/0050/nt03012en0914.pdf Now you **do** have a torque wrench and know how to use it I presume...
Comment: Unfortunately, the manual says nothing. It just simply says install or remove the water pump! In some Peugeot forums, they say tightening torque is 10 nm but others say 15 nm.
Comment: Yes, Peugeot definitely lists torque specs and I have the specs for most bolts. That's why I wonder why they haven't listed water pump torque specs for my specific engine. I have a torque wrench but I think I have to use my hands because there is not enough room around some bolts.


Are questions about games on topic here?

Question: This question was migrated here from Math.SE. Is it on-topic here?
Comment: I didn't feel strongly enough about it to say one way or another, but I am very interested what the community has to say about it.  One thing to note is that 'game' is not really a problem, as a computational physics engine for a 3D first person shooter would be highly appropriate here.  The issue is more to do with handling not-well-posed statistics/graph exploration problems.
Answer: A Math.SE moderator asked me about this question before migrating it. I took a look at the question, and saw that it had to do with data structures (how do I enumerate and store all of the possible legal configurations), and probability. Abstracting out the Sudoku part, enumerating configurations and assigning probabilities is a lot like statistical mechanics, which is used to model real-world phenomena, and when the configuration space gets large enough, enumerating all possibilities becomes impossible to do by hand.
Also, Sudoku solving was the topic of a previous MATLAB programming contest sponsored by Mathworks as well as a column by Cleve Moler on MATLAB.
As for the topic of games, if there is an underlying computational/algorithmic aspect of the problem, that topic isn't something that would go into Math or CS Theory (artificial intelligence, proof-by-enumeration, winnability of games), and it isn't so obviously off-topic here (a question for Role Playing.SE, for example) then I think it would be on topic here.
Answer: It's not the game aspect that makes me think it's off topic as much as the sudoku aspect. I agree with Aron Ahmadia in the comments that a physics engine would be on topic, but it's on topic because of the physics, not because it's part of a game. Computational science, at least to me, is about modelling real-world phenomena. That includes a physics engine but not a totally abstract game like sudoku.
Answer: I'd agree with Geoff and Aron: so long as the question focuses on some aspect of computation within games—a multiphysics engine, for instance, or on an algorithm used within games (perhaps a random number generator that decides actions by the computer?), then that should be considered on topic. The fact that the game is somewhat "artificial" doesn't change the fact that it's still an interesting computational science problem. (For instance, discussing how we solve ODE's is considered a core part of the area, even if the ODE is not directly tied to some particular phenomena.)


Prusa i3 Z axis not moving up

Question: I just got a Hictop Prusa i3 printer and I have it fully assembled. When I tested out the motors to check them the Z-axis motors were not moving and it was making a grinding sound. I have lifted the screw rods out of the coupling to see if the motor would move the coupling would move and it did. I can move the screw rods manually and it works. How can I make the Z-axis work?
Thank you in Advance!
Edit
Here is the vidoe of the problem https://www.dropbox.com/s/93g0pg0qfhq965d/IMG_0369.MOV?dl=0
Comment: Are you sure the extruder & drive assembly are mounted at the same height on both Z-screws?  If they're cocked, that'll cause a lot of binding.
Comment: @CarlWitthoft I second that. Bubble level Everything.
Comment: If you wouldn't mind uploading the video to youtube so that the question will be of use for future people. Dropbox is not known for its long term use.
Comment: At this point we can take it into Chat http://chat.stackexchange.com/?tab=site&host=3dprinting.stackexchange.com Or I might suggest a few groups that can add more interactive answering. As there is a need of a bit of back N forth.
Answer: Welcome to the group! A video would help. Or at least some photos.
Are both the motors connected? If you remove them from the coupling do they move? Likely it is binding (too much friction, not level etc) or you need to adjust your voltage controller. I am going to say 80% confident you need to play with the voltage.
Chances are it's just the voltage. I do not know what electronics you have but if they are RAMPS 1.4 then you are looking for these

Also here is the wiki on the 1.4. Just turn the screw gently. One direction will give it more power. The other less. When it has too much power your motors will start making a thud noise.
EDIT post adding the video
Oh yeah that is binding. If you wouldn't mind putting the video on youtube to that the video can help people for years to come? Dropbox is a bit volitle.
I would also in addition to my advice in your other question take a bubble leveler to all the rods. It could be a distortion on your camera but it looks like the rod is a bit bent. Also in my Prusa (original) I used to have to make the motor mounts lose, as it did not fit all that well and had binding issues. Try making the screws loose enough so that they float and can move around a lot. The lead screws are less important to the overall stability.
Comment: I found out the issue. Thank you for your answer. I have posted another question (http://3dprinting.stackexchange.com/questions/3294/is-there-a-problem-with-removing-a-polished-rod-from-the-z-axis) seeing if what I did is okay.
Comment: The rod is very slightly bent. I have put the rod back into the printer and it is not aligned with the hole. I was thinking of cutting the acrylic piece so the rod would fit into the hole, since I have tried running the z-axis when the rod was out of the hole and there was not problems, is this a bad idea? I have updated my question with a picture of this.
Comment: I would replace the rod. Should only be a couple bucks from mcm or other online sites. You can cut it to length with a saw or Demel. Changing the mount won't fix the issue which is the rod is bent.

Prusa i3 Z axis not moving up


Best way to detect when I'm home

Question: I'm working on a home automation setup and I'm trying to find the best way for the system to know when I'm home. A motion sensor won't work because my wife or my dogs may be home when I'm not. The two things I almost always carry with me are my keys and my cell phone and I liked this solution which pings the phone to see if it has joined the home wifi network. The only problem is that my phone goes to sleep very quickly when not used. This would make it good at detecting when I get home (if I just wake the phone for a few seconds on entering), but not when I leave. My other thought would be a bluetooth tag on my keys with a reader near the door, but how could it tell arriving from leaving? Anyone have any suggestions?
Comment: Why not have a button you press when you get home and when you leave?
Comment: Have you considered a pressure plate beneath a mat just at the inside of your home's entrance? I imagine every occupant has a different weight which can be measured. This way, you need not carry any additional devices. If you use two sensors beneath the mat/plate then you can determine the direction of travel.
Answer: Why don't you just hang your keys on a hook connected to a microswitch? There are some problems that do not require a smart phone or RF communications.
Answer: A keyfob(-sized) device, based on an RF transceiver (Zigbee, perhaps) that spends 99% of its time asleep, periodically waking up and listening for "query" messages from one or more corresponding base stations located around your home.  On receipt of a "query" the keyfob responds with an  "acknowledge" message.  If there is an extended period (say, 5 minutes) during which no base station receives an "acknowledge" message then you can assume that your keyfob is not at home.
A useful extension to the concept is to have the keyfob report its battery status in the "acknowledge" messages, and have the base stations tell you when to replace the battery.
Comment: The "alertme" home security system did exactly this. It's a little tricky to get the right battery life on the fob; they managed 6 months.
Answer: How about an RFID tag or smallest RFID object embedded in your FLESH! :)
JK,You could use an RFID based system, more like a tag. But the problem to differentiate between leaving and coming back will be there. Maybe 2 of those,so if one is activated, and the other is activated as well after a small time, then the order could help the system figure out if you are leaving or are back.
Another expensive option would be to use an Image detection system.
I think, using your phone would be the best option, dont they have the option to still check if the phone goes to the sleep mode?
Another stupid way would be to have a system says Hi, when someone steps in, and as you reply, it does voice pitch detection to figure out who it is.
Answer: BLE is a good option or regular bluetooth. I plan on using the wifi method you mentioned but thought about a BLE option too.

Best way to detect when I'm home


Filter Explorer pane for specific file types?

Question: I've just installed Visual Studio Code and am using it to browse a folder for a project written in Python. Is there a way for me to tell Visual Studio Code to filter the view in the Explorer pane to show only certain files -- specifically, only those files with a .py extension which are Python source code files?
Brandon Taylor
Answer: Kind of. First I would suggest to open the settings and set workbench.list.keyboardNavigation to filter (so your list get filtered immediately).
Be sure to have the focus on the explorer window and not in the editor then. Now simply start to type .py. It will filter all files that contain the filter string in its filenames. It seems that you can't use regex to be sure to just find files that end with .py. You would also find a file like animal.python.js. But  I think this is a good start and fits most cases.
You can enable, disable and clear the filter when hovering over the filter string on the right side of the explorer window and click the appropriate buttons.
Additional information can be found here.