Can dasein repeat without a time

Question: Can dasein repeat without a time or is dasein necessarily in time. I recall that dasein is structured by care, but not if that always involves times
Comment: Is there a particular text or quote from Heidegger that helps to add context? Perhaps none is needed. Regardless, welcome to this SE!
Comment: You are right there is an idea of "repeat". Here is something on "repetition". 3. Dasein and Temporality.  "Dasein comports itself to the future by always coming back to its past". And key: "It is a movement through a world as a space of possibilities. The going back to the possibilities that have been in the moment of throwness..." This makes Dasein authentically historical. But still Dasein always carries death with it. There is a limit to this "going back". https://www.iep.utm.edu/heidegge/#H3
Comment: I took my answer down so you could await a better answer. I still think you have to hold the above in your head while considering also Being-toward-Death. Heideggerian Terminology. As stated,  there are limits to this repitition-throwness-resolution, and this is death.  https://en.m.wikipedia.org/wiki/Heideggerian_terminology  Also, again Werner Brock who gives a bigger picture of Heidegger's project in Being and Time. He covers other German philosophers also. https://archive.org/details/introductiontoco00broc/page/108
Comment: Welcome to Phil.SE! Please provide more context to your question, as currently it presents a question that's too vague, and general, to be properly answered.
Answer: Dasein is necessarily in time, because care is always directed towards the future. This is what Heidegger means when he says that dasein is "thrown" into the world. Dasein is always caught up in what it has to do next, and so it can never repeat itself in exactly the same way. There is always a sense of novelty and difference, because the future is never fully knowable.
Answer: The repetition occurs in primordial/authentic temporality, which is not 'in time' in the ordinary sense.  However, the moment of vision it produces coincides with the present-at-hand, 'in a time'.
First clarifying 'repetition', quoting from Being & Time (trans. Macquarrie & Robinson)

(H.386) the repetition makes a reciprocative rejoinder to the
possibility of that existence which has-been-there. But when such a
rejoinder is made to this possibility in a resolution, it is made in
a moment of vision; and as such it is at the same time a disavowal
of that which in the "today", is working itself out as the 'past'. 1 ...
We characterize repetition as a mode of that resoluteness which hands
itself down - the mode by which Dasein exists explicitly as fate.
(footnote 1. The idea seems to be that in resolute repetition one is
having, as it were, a conversation with the past, in which the past
proposes certain possibilities for adoption, but in which one makes a
rejoinder to this proposal by 'reciprocating' with the proposal of
other possibilities as a sort of rebuke to the past, which one now
disavows.)

And now the moment of vision's moment in time:

(H.338) Corresponding to the inauthentic future (awaiting), there is a
special way of Being-alongside the things with which one concerns
oneself. This way of Being-alongside is the Present - the
"waiting-towards"; ... That Present which is held in authentic
temporality and which thus is authentic itself, we call the "moment
of vision". ... as an authentic Present or waiting-towards, the
moment of vision permits us to encounter for the first time what can
be 'in a time' as ready-to-hand or present-at-hand.
Comment: I sometimes wonder if having a different native language gives rise to thoughts that are simply untranslatable? If you said that these passages were produced by a schizophrenic, I would have no objections. Do very many people find them obvious and amenable?
Comment: It's not readily obvious that authentic time - the time 'proper' to the psyche - is distinctly different to clock time.  It's essential to appreciate that, otherwise one assumes temporality always means clock time and nothing makes sense.  I found Derrida's seminar on the subject very explanatory: [Heidegger: The Question of Being and History](https://www.amazon.co.uk/Heidegger-Question-History-Seminars-Jacques/dp/022667892X/).
Comment: Thank you. I probably should have avoided reading this question at all, because I was not successful in absorbing the point of Existentialism long ago as a student. I thought I understood, but it never reconciled with the direction I went, which has turned out wonderfully for me and requires no books or debate. Derrida, similarly seemed to say what I had already found to be true, but then he kept going off in to the weeds at every opportunity and not get to the point, which is simple and obvious once you see it, and can never be conveyed in any amount of words if you don't. Like most things.

Can dasein repeat without a time


What is the difference between a Cluster and MPP supercomputer architecture?

Question: What is the difference between a Cluster and MPP supercomputer architecture?
Answer: In a cluster, each machine is largely independent of the others in terms of memory, disk, etc. They are interconnected using some variation on normal networking. The cluster exists mostly in the mind of the programmer and how s/he chooses to distribute the work.
In a Massively Parallel Processor, there really is only one machine with thousands of CPUs tightly interconnected. MPPs have exotic memory architectures to allow extremely high speed exchange of intermediate results with neighboring processors.
The major variants are SIMD (Single Instruction, Multiple Data) and MIMD (Multiple Instruction, Multiple Data). In a SIMD system, every processor is executing the same instruction at the same time, only on different bits of memory. Essentially, there is only one Program Counter. In a MIMD machine, each CPU has it's own PC.
MPPs can be a bitch to program and are of use only on algorithms that are embarrassingly parallel (that's actually what they call it). However, if you have such a problem, then an MPP can be shockingly fast. They are also incredibly expensive.
Comment: I much more agree with the ang mo's answer below. Today's MPPs in TOP500 have (typically, if not all) hybrid distributed-shared memory architectures. For programmers there is no difference, MPI (+OpenMP,CUDA,...) is mostly used in practice. Sometimes, toplogy-aware codes can perform better, but at the cost of portability loss.
Comment: You are probably correct. Unfortunately the paper referenced by ang mo is behind a paywall, so I can't comment on it directly. My answer was, admittedly, based on my own experiences dating back quite a few years (e.g. 1990 MasPar machines). The present-day technology that is most closely related to my answer is probably the parallel [stream processing](https://en.wikipedia.org/wiki/Stream_processing) in a modern GPGPU. I believe that the one enduring constant is that using any sort of MPP requires the programmer to think very differently about how their problem should be attacked.
Comment: You are the LMGTFY answer now :)
Comment: @RonE: weirdly enough I also seem to have that status for a page I wrote about 7 or 8 years ago on fixing a [Kenmore Electric Dryer](http://www.techbuddy.us/dryer.php). I've received over a 100 "Thank You!" emails from people who found out they could save big bucks by doing a little diagnostic work on their own.
Comment: Dongarra et al. reference here: http://www.netlib.org/utk/people/JackDongarra/PAPERS/158_2005_high-performance-computing-clusters-conslellations-mpps-and-future-directions.pdf . @ang mo Thanks for the paper reference.
Comment: Sure, today's terminology is a bit different. Machines like BG/Q or Cray XC are considered MPPs. Wikipedia states that _MPPs have many of the same characteristics as clusters, but MPPs have specialized interconnect networks (whereas clusters use commodity hardware for networking)_, which is the terminology I would adopt.
Answer: The top500 list uses a slightly different distinction between an MPP and a cluster, as explained in Dongarra et al. paper:

[a cluster is a] parallel computer system comprising an integrated collection of independent nodes, each of which is a system in its own right, capable of independent operation and derived from products developed and marketed for other stand-alone purposes

Compared to a cluster, a modern MPP (such as the IBM Blue Gene) is more tightly-integrated: individual nodes cannot run on their own and they are connected by a custom network (like a multidimensional torus). But, similarly to a cluster, there is no single, shared memory spanning all the nodes (note: an MPP might be hierarchical and shared memory might be used inside a single node (NUMA), or between a handful of nodes).
I'd be thus extremely careful to use terms SIMD and MIMD in this context as they usually describe shared memory architectures (SMP).
Update:
Dongarra et al. link
Update:
MPP can have nodes that use shared memory internally; but the whole MPP memory is not shared.
Comment: I would refute that MPP don't have shared memories. Nodes in an MPP, for example in SGI Altix or Cray T3E which use CC-NUMA and NCC-NUMA technology implement/use a distributed shared memory (DSM).
Answer: A cluster is a bunch of machines, normally usually Ethernet interconnect (read: network), each running it's own and separate copy of an OS which happen to serve a single purpose.
An MPP supercomputer usually implies a faster propitiatory very fast interconnect (e.g. SGI NUMALink) that supports either Distributed Shared Memory (run processes on different MPP nodes that use shared memory over the fast interconnect to share data as if they were running on a single computer) or even a Single System Image (a single instance of an operating system, mostly Linux, running on all the nodes at the same time as if on a single machine - e.g. "ps aux" on any node will show you all the processes running on the MPP).
As you can see the definition is quite fluid, it's more a question of scale rather than clear cut differences.
Answer: I've searched in a lot of HPC literature and couldn't find a concrete definition of MPP. There is quite a concesus over a cluster consisting of multiple interconnected regular personal computers or workstations, usually coupled with standard technologies (like Ethernet or open-source operating systems). The term MPP is usually applied to more propietary approches for building distributed-memory computers, usually having propietary technologies.
For example: Tianhe-2 is considered a cluster because it uses x86-64 nodes and a regular operating system (Kylin Linux). Sunway TaihuLight is considered an MPP because its nodes have its particular architecture, SW26010, and work over his own operating system called Sunway Raise OS.
The most concrete explanation of this matter I found was in Sourcebook of Parallel Computing (Dongarra et al.):

We note that the term cluster can be applied both broadly (any system built with a significant number of commodity components) or narrowly (only commodity components and open-source software). In fact, there is no precise definition of a cluster. Some of the issues that are used to argue that a system is a massively parallel processor (MPP) instead of a cluster include proprietary interconnects (...), particularly ones designed for a specific
  parallel computer, and special software that treats the entire system as a single machine, particularly for the system administrators. Clusters may be built from personal computers or workstations (either single processors or symmetric multiprocessors (SMPs)) and may run either open-source or proprietary operating systems.


What is the gravitational force felt on Earth from the other planets in our solar system?

Question: How much gravitational force is felt on earth from the other planets in the solar system? The sun exerts the strongest g-force, holding us in it's orbit, followed by the moon which affects the tides on earth, but how much force do we feel from Jupiter, Saturn, Venus, etc?
Comment: Well, one could use $GM/r^2$, where $GM$ is the [standard gravitational parameter](https://en.wikipedia.org/wiki/Standard_gravitational_parameter) and $r$ is some typical distance. So the question is basically equivalent to asking for a typical distance between Earth and the body in question. For Earth-Sun or Earth-Moon, it's sensible to use the semi-major axis of the relevant orbit, but... how do you want to measure the rest? It's essentially easy to get a rough figure, but potentially hard if you want some spatial or temporal average, etc.
Comment: I know I can calculate with the mass of the planet and the distance from it, i was just hoping these are well known figures i could find on the internet, without having to calculate all of them myself. It is a simple calculation though, I will if I have to, just trying to save myself some time. though i probably could have done it by now myself :)
Comment: @MarcusQuinnRodriguezTenes : Please post your results if you decide to do the calculations yourself. I think I might be a little lazy... :p
Comment: @MarcusQuinnRodriguezTenes Remember that all planets form a corotational system together with the sun, so the distances between two planets - or a planet and a point of observation on Earth - *is not constant*. Henceforth, the values you calculate with and get for the gravity change with time, **but** you can fairly easily create a program to compute the exact values at a given time, as the "exact" positions of the planets with respect to time can be found on various freely available databases :)
Answer: Because of the inverse square law for Newtonian gravity we have the acceleration due the gravity $g_b$ at the surface of the Earth due to a body of mass $m_b$ at a distance $d_b \gg r_e$ (where $r_e\approx 6371 \mbox{km}$ denotes the radius of the Earth, note all distances will need be in $\mbox{km}$ in what follows) is:
$$
g_b=g\times \frac{m_b}{m_e}\times \left(\frac{r_e}{d_b}\right)^2
$$
where $g$ is the usual accelleration due to gravity (from the Earth at the Earth's surface $\approx 10 \mbox{m/s}^2$, and $m_e\approx 6.0 \times 10^{24} \mbox{kg}$. We get the maximum acceleration due to a body when that body is at its closest to the Earth, which is what we do from now on (except for the Sun and Moon where the mean distance is used).
Now for the Moon $r_b\approx 0.384 \times 10^6 \mbox{km}$, and $m_b\approx 7.3 \times 10^{22} \mbox{kg}$, so the accelleration at the Earth's surface due to the Moon $g_b\approx 3.3 \times 10^{-5} \mbox{m/s}^2$
Then putting this relation and Solar-System data into a spread sheet we get:
Comment: Small point to add to this, even those imperceptibly tiny g forces, the largest planetary one being Jupiter, 3.25E-7 *9.81 m/s^2, if you roughly calculate distance traveled using d = 1/2 a t^2, Jupiter does measurably move Earth every orbit, at least, the distance of a few earth diameters.   That's not much at all compared to 93 million miles, but it's still measurable.  That movement roughly, but not entirely, balances out every Jupiter orbit, 11 years and it's responsible for the orbital eccentricity variation which is one of the Milankovich cycles.
Comment: No, look at the exponents the Moon has a "g" of $\approx 6\times 10^{-3} \mbox{ m/s}^2 $ and Mars has a "g" of $\approx 7\times 10^{-9} \mbox{ m/s}^2 $, that is about six orders of magnitude lower.
Comment: @joseph.hainline  in layman's terms, a g force of 1.88e-7 couldn't be felt.  Not close.  A 200 lbs man under that low a g force would several times lighter than a feather, you could lift a truck, in that g-force, with your pinky.  You might be able to lift a 747.   Now, heavy objects still have inertia, so you couldn't, for example, throw a truck like a baseball, but you could hold it up, against a gravity that low easily.   The astronauts in "weightless orbit" likely feel significantly more g-forces than that, and they float around like nothing.
Comment: Thanks for this. Looking at column D, does this infer that when Mars is closed (every two years?), the gravitational effect on Earth is twice that of the moon?
Comment: You might want to add, that you actually can't "feel" the gravity of the sun, as earth is on a stable orbit around the sund the zentrifugal force ~= gravitational force (on the surface of the earth).
Comment: That clears it up. Ty
Comment: Any ideas what those forces would feel like in layman's terms? How little force is 1.88E-7 ?
Comment: really an useless answer for astroLOGISTs coming here to figure out how planets affect their lves...
Answer: The force any planet produces on a 75kg person is given by formula:
F = G * M * m / r^2
Hence:

<code>body    minimum distance (km)   Mass (kg)   Force (Newton)  % earth
Earth    6.341,00    6.000.000.000.000.000.000.000.000,00    746,488018227
Moon     384.000,00      73.000.000.000.000.000.000.000,00   0,002476552    0,000331760%
Sun  150.000.000,00      1.990.000.000.000.000.000.000.000.000.000,00    0,442443333    0,059269985%
Venus    42.000.000,00   4.900.000.000.000.000.000.000.000,00    0,000013896    0,000001861%
Mars     78.000.000,00   640.000.000.000.000.000.000.000,00      0,000000526    0,000000070%
Juipter  629.000.000,00      1.900.000.000.000.000.000.000.000.000,00    0,000024024    0,000003218%
Saturn   1.280.000.000,00    570.000.000.000.000.000.000.000.000,00      0,000001740    0,000000233%
Uranus   2.730.000.000,00    87.000.000.000.000.000.000.000.000,00   0,000000058    0,000000008%
Neptune  4.150.000.000,00    100.000.000.000.000.000.000.000.000,00      0,000000029    0,000000004%
</code>
Comment: Consider using scientific notation or a [Markdown table](/editing-help#tables).
Comment: no, I intentionally did not use scientific notation because the answer is for people not acquainted to it and which is not able to figure out that 2E06 is NOT the double of 1E09 (see comments to the other answer, indeed).


Can I resubmit my GPG key to a keyserver?

Question: I submitted my GPG key to the keyserver earlier. Now I got signatures on my key. Can I republish it? gpg --send-keys doesn't seem to alter my key any more, but doesn't spit out any error either.
Answer: Yes, of course. Sending should update the copy on the keyservers adding the new signatures (note that it is possible that they already had those signatures which would lead to no changes on their copy).
Additionally, while this would be the traditional action by the keyservers, please note that some keyservers may be read-only (not allowing you to upload keys by hkp), or even discard signatures automatically if they are from unknown keys.


Checkbox whether display Node title

Question: How can I add a checkbox when I create a new page to decide wheter the user want to display the node title or not, as like the hook_block_configure() function ?
Answer: There is now also this module:
https://www.drupal.org/project/exclude_node_title
Answer: To do this you need to follow the steps,

Edit the Page content type and add a new field "Show Content title" and add this one as checkbox, boolean.
In time of creating a new Page content check if you want to show the title or not.
Set the Page Content Type's "Show Content title" as hidden in Manage Display Settings page.
In your node.tpl.php you will see the following code
<h2<?php print $title_attributes; ?>><a href="<?php print $node_url; ?>"><?php print $title; ?>

Then add some check over there,

    <?php if($content['field_show_title'] == 1) : ?>
    <h2<?php print $title_attributes; ?>>
    <a href="<?php print $node_url; ?>"><?php print $title; ?>

    <?php endif; ?>

This can solve the issue.

Checkbox whether display Node title


Shut down issues in Ubuntu 16.04

Question: My Ubuntu 16.04 does not shut down. When I click on shut down option, it shuts down but it start by itself again even when there is no command for booting. I also want to know whether I can install HP Probook 4540s drivers on it or not.
Comment: Try this command int the terminal and see what happens:
shutdown -h now
Comment: Also, since you're on 16.04, the new command for shutdown is 'sudo systemctl poweroff', as everything is being managed by systemd.
Comment: Can you tell us more about the shutdown issue? It will shutdown automatically? Can you see it finishing the shutdown process? Or it's just powered off?
Comment: Do you mean it does 'reboot' if you choose 'shutdown'?
Comment: Do you have laptop-mode-tools installed? If not, check after installing it.
Answer: This is quite often a power management setting within your bios. Specifically, check your configurations on network devices (wifi & e-net).
Disable wake from sleep settings or power-management on wifi. If that solves it you can then iteratively try different settings until you have the desired result.

Shut down issues in Ubuntu 16.04


How strong is the connotation behind the word "implore"?

Question: For example, in the sentence "The social worker implored the child to express his feelings about his new home", does the word "implore" make it seem like the social worker is more or less on his/her hands and knees begging the child, almost in a gaudy way? Or could it simply be interpreted as the social worker asking, but with passion in his/her job, for feedback?
Comment: Nobody would interpret your sentence as involving the social worker on their hands and knees begging. It connotes a passionate appeal.
Comment: I would use "implore" somewhere between "ask" and "beg" in terms of intensity.  Usually only "begging" connotes someone on hands and knees.
Answer: I did not ever see implore being used in the sense of getting on one's knees.
I googled out of interest (after seeing your question) and did not find any dictionary offering that kind of a definition.
All definitions of implore that I saw were in the lines of (from Cambridge dictionary):

to ask someone to do or not do something in a very sincere, emotional,
  and determined way: She implored her parents not to send her away to
  school.

Alternative meaning (again from Cambridge dictionary) for literary context (not in conversational use):

to ask for something in a sincere and emotional way: She clasped her
  hands, and glancing upward, seemed to implore divine assistance.

In the accompanying example, you can see that action of clasping one's hands (analogous to getting on one's knees) is explicitly mentioned alongside implore.


Escalating privileges on linux programmatically

Question: I am creating a graphical installer that should run on Linux. Installing should consist of copying files to some places in /usr. Currently the installer is written in Python.
How can I escalate the privileges of my installer when I need to copy files? I looked at PolicyKit but

a) there doesn't seem to be a generic "install files" action-id for PolicyKit
b) of the action ids I can use, I don't think they are standard across distros

I also looked at PAM and I have code that uses libpam but I can't seem to do anything with it. After authenticating my user (by providing username and password) I don't have write access to /usr. I tried changing my user with os.setuid(0) after authentication but I get an error from the OS.
Also, strangely, it doesn't seem to matter what service I provide to pam_start. As long as the username and password are correct I can pass anything I want. I see I have /etc/pam.d/sudo. The below code is simplified, the password is correctly stored in a pam_conversation object and I do pass a handle object.
pam_start("my_user", "my_pass", "sudo_garbage_12345");

works just as well as
pam_start("my_user", "my_pass", "sudo");

That is, they both succeed.
As a last resort I can probably execute gksudo or kdesudo but I don't want to be tied to those programs. Requiring users to invoke my installer with sudo is a (very) last resort.
Comment: so, let me get this straight... You want to be able to give any user unrestricted (root) access?
Comment: I want to emulate sudo by allowing users to type in their password. If a user can't gain privileges by using sudo they should not be able to do it using my installer either. I just want to give them a noob-friendly way to use sudo.
Answer: You might be better off wrapping RPM with a front end that takes the user options and invokes RPM to do the hard work.  This also gives you infrastructure for managing dependencies and plays nicely with the existing package management system.  If you need to run on a .deb based system (Debian or Ubuntu) you may also need to consturct a .deb and put some mechanism in the front end that works out which package management system is active.
Granting random users access to root privilege is generally viewed as bad form on Linux or Unix systems (or any multi-user system for that matter) as it is a significant security risk.  However you do have the option of letting the user install it under their home directory (~/bin) if they don't have root access or sudo permissions that allow them to write to system areas.  In this case you can require them to install it as root if they want to install in /usr/bin but permit them to install it under their home directory for their own use if they don't have root privileges.
Answer: For a graphical installer, stick with a graphical environment.  Use gksudo or kdesudo if they are available, otherwise fail with an error dialog saying they need root.  People (newbies in particular) will download your installer and double-click to launch it from their desktop, and you need a graphical way to ask them for their password.  You don't want to pop open a terminal on them.
Given that, don't do sudo for them even if they are running from the terminal.  Just output an error saying you need root and exit.  If the user is already at the command prompt (like I most likely would be), I already know how to sudo or su myself into root if I want to do so.  I promise you you will most likely ruffle some feathers if you attempt to make an experienced user root when they can do it themselves.
If you INSIST on doing a sudo yourself from within your installer, for God's sake please force a 'sudo -K' before you do to remove the previous timestamp.  If you don't do this, and I have sudo'd recently, you will run your installer with me as root without my knowledge (since I don't expect that to happen).  A 'sudo -K' will force a prompt that I can then decide whether I want to proceed as root or not.
Answer: The best way in this case is to use su within your program. Redirect inputs/outputs and you're good to go!


When combining number in Parchesse

Question: May I use a 6+4 in substitution of a double 5 to enter two pieces into play in Parchessi? Since I may use any combination which adds up to five to enter one piece and I am allowed to enter two pieces with a double 5, the rules been vague in this, It seems only logical that it may be allowed.
Answer: No. Each die is used in toto of itself. You cannot re-combine the pips in other combinations. As for the special case of entering, the rules are clear on this.

Pieces may only leave the nest with a roll of a five on a single die or the sum of the dice. A double five can be used to move two pieces from the nest simultaneously.
Comment: Thank you for the replay. As the rule stated: "...the sum of the dice." It is acceptable a 4-1 or a 3-2; to enter one piece. Therefore, it is the same math, a 6-4 to enter two pieces. Isn't it?
Comment: You can use one of the dice or both, but not part of a die (whether you add that part to the other die or not). A 6-4 allows one pawn to move 6 and the other 4, or one pawn to move 10. It won't allow one pawn to move 5, nor two pawns to move 5 each.
Comment: The sum may not me multiples of five to move peices from the nest. it may only be five.

When combining number in Parchesse


Pull Down resistors value for unused pin for MCU

Question: According to the datasheet, it is preferred to have MCU's unused pins connected to GND. That's the only thing suggested in the datasheet. I think it would not be a wise decision to directly connect the unused pins to GND. I am planning to use a resistor (pull-down). However, I am not sure what value for the resistance I should use. In the datasheet, I couldn't find the IIH(Max input current for logic low). That's why I cannot calculate the pull-down resistor value.
Comment: Which MCU? Why can't the unused pins be outputs so there is no need to add extra resistors? Or why can't internal resistors be used?
Comment: "I think it would not be a wise decision to directly connect the unused pins to GND" Why not? Do you have any argument why this would be bad?
Comment: @Lundin There might be many reasons or none. Without knowing which MCU it is it might be a disaster or irrelevant. And depending on the MCU, there might be a solution not yet mentioned here.
Answer: A resistor to ground (or VCC) is useful not only for ensuring that the pin is not floating but as a connection point if you later need to modify the design.
The actual value is relatively unimportant.
Zero ohms could be used but would cause high currents if the output was accidentally set as a high output. I would normally use something in the range of 10k-100k.
A CMOS IC such as used in all microprocessors will have leakage currents in the nano-amp range so can be ignored in most situations.
For non-production designs you can leave the pin open and ensure in software that it is set either as an output or an input with the MCU internal pull-up or pull-down enabled. Most modern MCU GPIOs have internal pull-up and many have internal pull-downs. It does not usually matter whether the pin is pulled up or down, just that it is not floating as it may acquire an intermediate voltage where it increases the supply current or causes erratic triggering of internal functions.
Answer: The purpose of this exercise is to limit your leakage currents for unused pins. This in turn depends entirely on how much you care about micro- or nano-amps.
If your application doesn't care too much about minor current leakages, then it kind of doesn't really matter what you do here.  I wouldn't connect them to ground directly in case software tries to set them as outputs and to a logic high output, in which case damage may result.  If your micro includes internal pull-downs, or pull-ups, those would suffice in this case, if you even need to bother with going that far.  For example, if this is a hobby project powered from an AC-mains derived source, then I wouldn't bother at all with an external pull resistor.
If you do care about minor leakage currents, then yes a resistor will come into play to reduce that amount of leakage.  It depends on exactly what pin setup you have, and that would require letting us know the part number.
Answer: Input current will be negligible for modern CMOS inputs, and any value resistor, from zero to 10MΩ, is likely to work fine. Current through that resistor, or even a direct short circuit, won't reach even nanoamps.
It isn't input current that you should worry about, it's oscillation caused by floating inputs picking up signals from the environment (anything from mains to neighbouring signals), and causing the input's internal buffer to switch erratically. Those transitions can cause significant current draw from the power supply, and has nothing to do with input current. Any resistor to ground/Vcc from 0Ω to 1MΩ will put a stop to oscillation, with the caveat that smaller is better is this respect, especially if you have large transients occurring nearby.
Presumably you wish to protect the I/O circuitry from excessive current draw, in case you accidentally configure it as an output. If so then you're concerned with keeping the resulting current to a minimum. If 10μA is acceptable, then \$ R = \frac{3.3V}{10\mu A} = 330k\Omega \$ would do the trick.
If I absolutely must use a resistor, I would be happy with 10kΩ or 100kΩ, considering that any current in that resistor would occur only briefly, at startup. Otherwise it's a design problem, which should be fixed in software. A value in that range will keep short-duration output current in check, while also inhibiting oscillation.
That said, I would not use a resistor, I'd just short the thing to ground or Vcc. Extra resistors add cost and require space, and it's very unlikely that an MCU would start up with I/O pins as outputs.
Answer: Use 5 or 10k ohms and preferably have the firmware set the GPIO pins to low.
The main limitation is the leakage current which should be specified in the datasheet and typically will be something like +/-1 microampere over the entire operating temperature range. Typically it will be much less, particularly at room temperature.


Identifying the source of encryption used by UDP packets in a PCAP file

Question:
I have a PCAP file (mediafire link to the file) which basically represents packet captures between 2 machines running the same game connected to each other via LAN inside RPCS3 using RPCN.

One of them has the inet address 192.168.0.104 and the other one is 192.168.0.100.

Many UDP packets are being transmitted between both which I believe is the game data.

If you filter the packets by "tls" there are 2 TLS handshakes of which I have been able to decrypt the first one using session keys.

It has data related to RPCS3 connection.

My question is that are the UDP packets encrypted with the keys generated in the 2nd handshake or are they using some custom encryption that the game itself manages in its code?

The second SSL handshake mostly(90% sure) represents the act of logging into the RPCN network inside RPCS3.

How come there are no SSL handshakes between the 2 LAN machines?
Answer: To your first question, you'd have to look at the code. There may be encryption, but some of the UDP packets have very small payloads, and using encryption would slow down packet processing which is the opposite of the key purpose for using UDP.. which is speed.
For your second question, the LAN game is using UDP, and TLS needs TCP. If you think about the use case.. TLS/SSL is to verify that at least one end of the connection is who it says it is. If you're on the LAN, you don't know who is who (no DNS) and you don't care.. TLS makes no sense in this case.
I think you're correct that the TLS connections are being used during user authN to the game servers. However, given that the session keys negotiated between 192.168.0.104 <--> game server are used to secure only communication between those 2 hosts, they would not be used between 192.168.0.104 <--> 192.168.0.100 on the LAN as they provide no value. They do not identify either host, and they slow down game performance.
This is a little wordy but I hope it helps.
Comment: I am not SSL expert which is why I hope I am correct about this, as per the second SSL connection the handshake happens between 192...104 and some other IP address so I am guessing that only these 2 addresses would actually use session keys to encrypt data between each other. So its weird that the LAN packets are encrypted


Can I teach my iPhone to autocapitalize?

Question: My name is not an English word or common enough name to be in whatever list of proper nouns it has, and I always have to capitalize it manually. It doesn't even show up as an autocorrect option. Is there a way around this? It seems like a phone that can do so many things should at least be able to learn my name. iPhone 4 with iOS up to date.
Answer: I would define your name as a keyboard shortcut, so if your name were nisht, I would set the phrase to be Nisht and the shortcut to be nisht.
To add a keyboard shortcut: Settings -> General -> Keyboard -> Shortcuts.
Answer: Do you have yourself in the contacts application and have that contact selected as yourself? I believe that will add your name to the autocorrect list.


Can't setup Google Analytics for a Google Site

Question: I had performed steps as described here , 24 hours passed but Analytics site still shows "Tracking Not Installed" status. Ideas?
Comment: Can you give me the link to the Google Site for debugging?
Comment: http://sites.google.com/site/testing328/
Comment: seemingly analytics loads but it does not report . I think you can follow what Drew says http://www.google.com/support/forum/p/Google%20Analytics/thread?tid=49d5b624719688b8&hl=en
Answer: Apparently, It started working. It seems my mistake was in setting site url as the full path, but it was necessary to set site url to "sites.google.com" part only.
Answer: The last answer by Gombessa on this page should solve your problem: http://www.google.com/support/forum/p/Google%20Analytics/thread?tid=49d5b624719688b8&hl=en
Comment: I've tried it, but after 1 hour it shows "Tracking Not Installed" again. How I can check if Analytics is really installed on my site? I've found my web property id in the body of main page, but the code looks different - not the same as tracking code sample proposed on the GA site.


What are the differences between carnitine forms?

Question: I've heard of L-carnitine, acetyl L-carnitine and L-carnitine L-tartrate. What form(s) occur in meat? What form does the human body manufacture?
Is L-carnitine just a shortened name for L-carnitine L-tartrate?
Comment: L-carnitine and L-tartrate are two separate compounds - though a lot of "nutritional supplements" will package them together and seem to refer to them like they are one compound.
Answer: Carnitine tartrate is a salt between carnitine (cation) and tartrate (the conjugate base of tartaric acid, anion). So in this case, tartaric acid is not covalently bound to carnitine.
The salt formulation is a little tricky, because carnitine is itself a zwitterion at physiological pH (it has both a positive and negative charge) and so is overall uncharged in pure form. I think the tartrate salt is formed because tartaric acid is more acidic (first pKa = 2.89) than the carboxyl group of carnitine (pKa = 4.09), which leads carnitine to become protonated and therefore +1 charged in a concentrated mixture. The formulation sold by Lonza (which seems to be a major provider) appears to be a ratio of 2 cartinine (68%) to 1 tartrate (32%), which would indicate that tartrate acts as a -2 anion in this mixture (this is a bit surprising as the second pKa of tartaric acid has pKa = 4.40, but maybe I'm missing something).
You can recognize that this is a salt from the naming: the form tartrate indicate a conjugate base of an acid (as in lactate, acetate), and when used in a two-component name like carnitine tartrate (or, sodium acetate) refers to a salt. On the other hand, a carboxylic acid covalently bound to another group is given the suffix -yl, so tartryl carnitine would indicate tartaric acid bound to carnitine, as in fatty acid oxidation.
Answer: Carnitine is a molecule that allows transport of carboxylic acids (including fatty acids) across mitochondrial membranes and is involved in fatty acid metabolism. Like many biomolecules it exists as the L-enantiomer in the cells. It can be coupled to any carboxylic acid and in that case is called acyl-carnitine. L-Carnitine L-tartrate is a drug formulation and is a mixture of L-carnitine and L-tartarate (tartarate is not covalently coupled to tartaric acid).


Why Have Some of My Widgets Disappeared After Switching Launchers?

Question: I recently changed my launcher from the default TouchWiz (I have an AT&T SGS3, with the official 4.1.1 installed) to Nova Launcher. I enjoy Nova, but I've noticed something strange: the Calendar and Weather widgets that were available under TouchWiz aren't there anymore. They're still there in TouchWiz (Home Switcher makes it easy to switch back and forth). What's going on?
Answer: The widgets referred to in the question are TouchWiz-specific widgets. They will only show up in TouchWiz because they don't use the standard Android widget interface. I've found some references to Samsung releasing a TouchWiz SDK to develop such widgets, but those articles are from 2009 and the links they contain now lead to Samsung's developer home page, rather than to a specific page. I've also seen references to some of the widgets being ported to work on any Android phone, but I can't confirm as XDA seems to be down at the moment.
Comment: Btw: Same applies to other "specific UIs", e.g. Blur widgets (Motorola) or Sense widgets (HTC).
Comment: Good point, @Izzy. Should I incorporate that int the answer or tags, somehow?
Comment: As you like. If you do, a "list" would be nice to make that more obvious. Last "dash" should be one with 3 dots ("..."), as that list will never be complete. Even I forgot to include the Sony XPeria's Timescape, LG also seems to use an "own thing" (I could not use some of its widgets with different launchers), and who knows what else we've overlooked...


sound hardware on Windows 7

Question: I have Windows 7 installed on seperate partitioned hard drive. Xp Pro still on C drive.
I do not have sound on Windows 7. I worked on XP. I never got sound when I tried the Windows 7 RC Beta this past summer. Now that I have the new release installed...HOW DO I Get SOUND?
Answer: Install the driver for it. Look up your computer on the manufacturer's website and get the Win 7 audio driver. If there isn't one, a Vista one should do.

sound hardware on Windows 7


What's the difference between backtracking and depth first search?

Question: What's the difference between backtracking and depth first search?
Answer: Backtracking is a more general purpose algorithm.
Depth-First search is a specific form of backtracking related to searching tree structures.  From Wikipedia:

One starts at the root (selecting some node as the root in the graph case) and explores as far as possible along each branch before backtracking.

It uses backtracking as part of its means of working with a tree, but is limited to a tree structure.
Backtracking, though, can be used on any type of structure where portions of the domain can be eliminated - whether or not it is a logical tree.  The Wiki example uses a chessboard and a specific problem - you can look at a specific move, and eliminate it, then backtrack to the next possible move, eliminate it, etc.
Comment: Responding to an ancient post here.  Good answer, but... couldn't the chessboard problem be represented as a tree also? :-)  From any position on a chessboard for a given piece, is there not a tree of possible moves extending into the future?  Part of me feels like any case where backtracking could be used, could also be modeled as a tree, but I'm not sure if I'm correct in that intuition.
Comment: @The111: Indeed, *any* search problem can be represented as a tree -- you have a node for each possible partial solution, and an edge from each node to the one or more possible alternative choices that could be made at this state. I think lcn's answer, that backtracking usually means DFS on the (usually implicit) search tree generated during recursion, comes closest to the truth.
Comment: @j_random_hacker So, a DFS is a way to explore a tree (or graph more generally), while backtracking is a way to solve a problem (which employs a DFS along with pruning). :-)
Comment: Confusingly, Wikipedia [describes backtracking as a depth-first search algorithm](https://en.wikipedia.org/w/index.php?title=Backtracking&oldid=832060927#Description_of_the_method), apparently conflating these two concepts.
Comment: A good explanation! It is really helpful.
Comment: I think you mean a graph instead of a tree. Trees can't contain circles that a chessboard, as a planer graph, could have.
Answer: I think this answer to another related question offers more insights.
For me, the difference between backtracking and DFS is that backtracking handles an implicit tree and DFS deals with an explicit one. This seems trivial, but it means a lot. When the search space of a problem is visited by backtracking, the implicit tree gets traversed and pruned in the middle of it. Yet for DFS, the tree/graph it deals with is explicitly constructed and unacceptable cases have already been thrown, i.e. pruned, away before any search is done.
So, backtracking is DFS for implicit tree, while DFS is backtracking without pruning.
Comment: I think it's confusing to think of backtracking as handling an implicit tree. When I first read this I agreed but digging deeper I realized the "implicit tree" is really.. the recursion tree.. Take any example that uses backtracking, like permuting a string of characters, there is no logical tree (no implicit tree) whatsoever regarding to the problem but we do have a recursion tree that models the incremental string building process. As for pruning, that's the pruning done to the recursion tree where a total brute force is performed... (to be continued)
Comment: (continued) E.g. print all permutation of "answer" string and let say the 3rd char has to be character "a". The first 2 level of the recursion tree obey O(n!) but at the 3rd level all branch except those that are appending "a" are pruned (backtracked).
Comment: @GangFang agreed, I like pointing out that it is usually a recursion tree. Even though I guess it's a conceptual tree of solution space, I don't know of a situation where recursion isn't used to create that solution space
Answer: IMHO, most of the answers are either largely imprecise and/or without any reference to verify. So let me share a very clear explanation with a reference.
First, DFS is a general graph traversal (and search) algorithm. So it can be applied to any graph (or even forest). Tree is a special kind of Graph, so DFS works for tree as well. In essence, let's stop saying it works only for a tree, or the likes.
Based on [1], Backtracking is a special kind of DFS used mainly for space (memory) saving. The distinction that I'm about to mention may seem confusing since in Graph algorithms of such kind we're so used to having adjacency list representations and using iterative pattern for visiting all immediate neighbors (for tree it is the immediate children) of a node, we often ignore that a bad implementation of get_all_immediate_neighbors may cause a difference in memory uses of the underlying algorithm.
Further, if a graph node has branching factor b, and diameter h (for a tree this is the tree height), if we store all immediate neighbors at each steps of visiting a node, memory requirements will be big-O(bh). However, if we take only a single (immediate) neighbor at a time and expand it, then the memory complexity reduces to big-O(h). While the former kind of implementation is termed as DFS, the latter kind is called Backtracking.
Now you see, if you're working with high level languages, most likely you're actually using Backtracking in the guise of DFS. Moreover, keeping track of visited nodes for a very large problem set could be really memory intensive; calling for a careful design of get_all_immediate_neighbors (or algorithms that can handle revisiting a node without getting into infinite loops).
[1] Stuart Russell and Peter Norvig, Artificial Intelligence: A Modern Approach, 3rd Ed
Comment: +1 Totally agree. Both lcn, Reed, and so on referred DFS as a **tree** search algorithm, which is too narrow (if not wrong) and is misleading to beginners.
Answer: According to Donald Knuth, it's the same.
Here is the link on his paper about Dancing Links algorithm, which is used to solve such "non-tree" problems as N-queens and Sudoku solver.

...backtrack programs...enumerate all solutions to a given set of constraints. Backtracking, also called depth-first search, will be the focus of the present paper.
(...)
In general, the key problem of backtrack programming can be regarded
as the task of deciding how to narrow the search and at the same time
to organize the data that controls the decisions. Each step in the
solution to a multistep problem changes the remaining problem to be
solved.
(...)
...we often need to work with global data structures, which are modified whenever the search enters a new level and restored when the search returns to a previous level.

Source: Donald E. Knuth - Dancing Links
Comment: Mentioned in page 1 of the linked pdf.
Answer: Backtracking is usually implemented as DFS plus search pruning. You traverse search space tree depth-first constructing partial solutions along the way. Brute-force DFS can construct all search outcomes, even the ones, that do not make sense practically. This can be also very inefficient to construct all solutions (n! or 2^n). So in reality as you do DFS, you need to also prune partial solutions, which do not make sense in context of the actual task, and focus on the partial solutions, which can lead to valid optimal solutions. This is the actual backtracking technique - you discard partial solutions as early as possible, make a step back and try to find local optimum again.
Nothing stops to traverse search space tree using BFS and execute backtracking strategy along the way, but it doesn't make sense in practice because you would need to store search state layer by layer in the queue, and tree width grows exponentially to the height, so we would waste a lot of space very quickly. That's why trees are usually traversed using DFS. In this case search state is stored in the stack (call stack or explicit structure) and it can't exceed tree height.
Answer: Usually, a depth-first-search is a way of iterating through an actual graph/tree structure looking for a value, whereas backtracking is iterating through a problem space looking for a solution.  Backtracking is a more general algorithm that doesn't necessarily even relate to trees.
Answer: I would say, DFS is the special form of backtracking; backtracking is the general form of DFS.
If we extend DFS to general problems, we can call it backtracking.
If we use backtracking to tree/graph related problems, we can call it DFS.
They carry the same idea in algorithmic aspect.
Comment: The relation between DFS and Backtracking is, in fact, just the converse. Check my response which details this.
Answer: DFS describes the way in which you want to explore or traverse a graph.  It focuses on the concept of going as deep as possible given the choice.
Backtracking, while usually implemented via DFS, focuses more on the concept of pruning unpromising search subspaces as early as possible.
Answer: The way I look at DFS vs. Backtracking is that backtracking is much more powerful. DFS helps me answer whether a node exists in a tree, while backtracking can help me answer all paths between 2 nodes.
Note the difference: DFS visits a node and marks it as visited since we are primarily searching, so seeing things once is sufficient. Backtracking visits a node multiple times as it's a course correction, hence the name backtracking.
Most backtracking problems involve:
def dfs(node, visited):
  visited.add(node)
  for child in node.children:
    dfs(child, visited)
  visited.remove(node) # this is the key difference that enables course correction and makes your dfs a backtracking recursion.

Comment: this is a great observation!
Answer: IMO, on any specific node of the backtracking, you try to depth firstly branching  into each of its children, but before you branch into any of the child node, you need to "wipe out" previous child's state(this step is equivalent to back walk to the parent node). In other words, each siblings state should not impact each other.  On the contrary, during normal DFS algorithm, you don't usually have this constraint, you don't need to wipe out(back track) previous siblings state in order to construct next sibling node.
Answer: Depth first is an algorithm for traversing or searching a tree. See here. Backtracking is a much more broad term that is used whereever a solution candidate is formed and later discarded by backtracking to a former state. See here. Depth first search uses backtracking to search a branch first (solution candidate) and if not successful search the other branch(es).
Answer: Depth first search(DFS) and backtracking are different searching and traversing algorithms. DFS is more broad and is used in both graph and tree data structure while DFS is limited to tree. With that being said,it does not mean DFS can't be used in graph. It is used in graph as well but only produce spanning tree, a tree without loop(multiple edge starting and ending at same vertex). That is why it is limited to tree.
Now coming back to backtracking, DFS use backtracking algorithm in tree data structure so in tree, DFS and backtracking are similar.
Thus,we can say, they are in same in tree data structure whereas in graph data structure, they are not same.
Answer: Idea - Start from any point, check if its the desired endpoint, if yes then we found a solution else goes to all next possible positions and if we can't go further then return to the previous position and look for other alternatives marking that current path wont lead us to the solution.
Now backtracking and DFS are 2 different names given to the same idea applied on 2 different abstract data types.
If the idea is applied on matrix data structure we call it backtracking.
If the same idea is applied on tree or graph then we call it DFS.
The cliche here is that a matrix could be converted to a graph and a graph could be transformed to a matrix. So, we actually apply the idea. If on a graph then we call it DFS and if on a matrix then we call it backtracking.
The idea in both of the algorithm is same.
Answer: Backtracking is just depth first search with specific termination conditions.
Consider walking through a maze where for each step you make a decision, that decision is a call to the call stack (which conducts your depth first search)... if you reach the end, you can return your path. However, if you reach a deadend, you want to return out of a certain decision, in essence returning out of a function on your call stack.
So when I think of backtracking I care about

State
Decisions
Base Cases (Termination Conditions)

I explain it in my video on backtracking here.
An analysis of backtracking code is below. In this backtracking code I want all of the combinations that will result in a certain sum or target. Therefore, I have 3 decisions which make calls to my call stack, at each decision I either can pick a number as part of my path to reach the target num, skip that number, or pick it and pick it again. And then if I reach a termination condition, my backtracking step is just to return. Returning is the backtracking step because it gets out of that call on the call stack.
class Solution:

"""

Approach: Backtracking

State
    -candidates
    -index
    -target

Decisions
    -pick one --> call func changing state: index + 1, target - candidates[index], path + [candidates[index]]
    -pick one again --> call func changing state: index, target - candidates[index], path + [candidates[index]]
    -skip one --> call func changing state: index + 1, target, path

Base Cases (Termination Conditions)
    -if target == 0 and path not in ret
        append path to ret
    -if target < 0:
        return # backtrack

"""

def combinationSum(self, candidates: List[int], target: int) -> List[List[int]]:
    """
    @desc find all unique combos summing to target
    @args
        @arg1 candidates, list of ints
        @arg2 target, an int
    @ret ret, list of lists
    """
    if not candidates or min(candidates) > target: return []

    ret = []
    self.dfs(candidates, 0, target, [], ret)
    return ret

def dfs(self, nums, index, target, path, ret):
    if target == 0 and path not in ret:
        ret.append(path)
        return #backtracking
    elif target < 0 or index >= len(nums):
        return #backtracking

    # for i in range(index, len(nums)):
    #     self.dfs(nums, i, target-nums[i], path+[nums[i]], ret)

    pick_one = self.dfs(nums, index + 1, target - nums[index], path + [nums[index]], ret)
    pick_one_again = self.dfs(nums, index, target - nums[index], path + [nums[index]], ret)
    skip_one = self.dfs(nums, index + 1, target, path, ret)

Answer: In my opinion, the difference is pruning of tree. Backtracking can stop (finish) searching certain branch in the middle by checking the given conditions (if the condition is not met). However, in DFS, you have to reach to the leaf node of the branch to figure out if the condition is met or not, so you cannot stop searching certain branch until you reach to its leaf nodes.
Answer: In a depth-first search, you start at the root of the tree and then explore as far along each branch, then you backtrack to each subsequent parent node and traverse it's children
Backtracking is a generalised term for starting at the end of a goal, and incrementally moving backwards, gradually building a solution.
Comment: Backtracking does not mean to start at the end and move backwards. It keeps a log of visited nodes to backtrack if a dead end is found.
Comment: "starting at the end ...", huh!!
Answer: The difference is: Backtracking is a concept of how an algorithm works, DFS (depth first search) is an actual algorithm that bases on backtracking. DFS essentially is backtracking (it is searching a tree using backtracking) but not every algorithm based on backtracking is DFS.
To add a comparison: Backtracking is a concept like divide and conqueror. QuickSort would be an algorithm based on the concept of divide and conqueror.


How can I save my eShop games when making a new NNID?

Question: I have a very complicated situation, so I'll try to be fast. In order to correct the things my last one got wrong, I plan on making a new NNID, but I found out that the purchases I made are linked to the account and will be deleted along with the account. I know Nintendo Support says something about formatting, but they don't go in to detail, so I was wondering if anyone could tell me about my options. Could I sign in and out to different accounts and have games on both accounts, or is there any way for me to save my old games (don't care about save data) and put them on a new NNID?
Answer: Strictly speaking, there's no way to transfer purchases from one NNID to another.
Additionally, you will need to format the system in order to un-link it from the existing NNID. This will remove any games from the system.
Therefore it will not be possible to retain your existing games if you decide to create a new NNID.
Comment: So I'm basically screwed? No way to make a backup, or anything? Dang.
Comment: Unfortunately not. Really burned me when I got the MH4 3DS, linking it to a NNID by accident before formatting it to put my own NNID. That's gotta be the easiest $40 Nintendo ever made off of me :(


Why is it harder to situp on solid floor?

Question: When I situp on solid floor it is harder for me to lift my body upwards versus on a soft/foamy floor which I can do a lot.
Comment: because your butt sinks into the floor
Answer: There are obviously many biological factors contributing to this, but from a physics point of view one could talk about degrees of freedom: since a foamy floor has more of them it is easier for yourself to get in the optimal position to get up. I would also like to add a simple biological factor: it hurts more to move around when you are trying to get up on a solid floor, which you will perceive as "harder"
On the other hand you can most certainly take the softness too such an extreme that it gets more difficult to get up (e.g. if you're lying on quicksand). Here the degrees of freedom have become too large for you to control, i.e. all stability is lost.
Answer: When you do a sit-up on a hard floor, your abdominal muscles are doing all the work to bring your upper body to a certain height above the floor. On a springy surface, as you start to sit up, the weight of your body becomes concentrated on the part of the floor beneath your hips, causing it to sink. This gives two advantages:

The final height of your upper body is not as high as it would be on a hard floor, meaning your muscles have to do less work.
A part of the floor remains in contact with your lower back for a longer time, providing some push to aid your ascent.


How to autoplay an audio stream at startup?

Question: I'm trying to use a Raspberry Pi create an internet radio player that only needs to play one station, but always plays that station on startup. I know I need mpd and mpc and to enter the URL of the stream, but how do I make that particular stream always play on startup?
Answer: you'd want to edit the start up script below
/etc/rc.local
and launch the program.
see this for more details.
Comment: that's really only a link-only answer. You do have to be a bit careful with rc.local, as it's running with elevated privileges and you have to ensure that your task forks to allow other startup items to run
Answer: You can put your command to run the app in autostart for the lxsession manager. For example, I use the following to setup the autostart script putting with my command :
echo "@lxterminal -e 'audioInjector.RCA.thruTest.sh'" >> ~/.config/lxsession/LXDE-pi/autostart
The "@lxterminal" fires up an lxterminal to execute a bash script once the window manager starts.
You can change that to whatever you want to start by first logging into the Pi or getting up a terminal there and :
echo "yourCommand" >> ~/.config/lxsession/LXDE-pi/autostart
This will add "yourCommand" to the autostart script.
Comment: This will work as long as the user Pi has autologin enabled. Otherwise this won't work at boot until Pi logs in.
Answer: Another option that runs as a regular user and doesn't rely on LXDE is cron. Anything in a @reboot clause will be run as soon as possible after boot. To edit your cron jobs, enter crontab -e.
An example entry I recently set up for an art exhibition plays an mp3 as a continuous loop:
@reboot    sleep 29; nohup mpg321 -l 0 /home/pi/Music/background.mp3 2>&1 > /dev/null

Though it's not a stream player, it should help give you an idea of another way of doing it. The command breaks down as:

sleep 29 - a not-very-scientific way of waiting until other jobs have started. This answer might help if you need to understand when various jobs start relative to cron.
nohup … 2>&1 > /dev/null - a wrapper to fully detach and silence any console output from the task I want to run. All output and error messages disappear.
mpg321 -l 0 /home/pi/Music/background.mp3 - the player task itself. As with all cron jobs, you need to specify full paths for any data and non-system commands. (As an aside for anyone trying to loop an mp3: you may need to make some special preparations, and iTunes uses its own loop/gapless tags that are generally incompatible with Linux players.)
Answer: You could create a watchdog script that runs in crontab every minute. This will also restart the stream if for some reason it crashed.

#!/bin/bash

if [ -z $(ps aux | grep "[the command that runs your stream]" | grep -v grep) ]; then
 [the command that runs your stream] &
 else exit
fi

exit


FTB Server Friends can't connect

Question: I am having a problem where I can connect to my FTB Server with locahost and also with my internal ip address. However, my friends cannot connect with my external ip. I have watched numerous videos about how to port forward and how to set the server up, but my friends still cannot connect.
Comment: Look at my post [here](http://gaming.stackexchange.com/questions/176828/how-do-i-make-a-ftb-server/176832#176832). Mainly the part where I mention Evolve.
Comment: If local works, and external doesn't, chances are extremely good it's a port forwarding issue.  I would recommend asking on SuperUser, but I suspect port forwarding in general has already been covered extensively.
Answer: I don't know what you did exactly to activate port forwarding but my guess is that the description you used does not mention that some routers have an internal firewall too where you have to open the port aswell.
In addition to that, you might need to open the port in your local (PC) firewall too.
(This might also be the case if you use a VPN, like Hamachi which was already mentioned by Flaunting.)
Answer: Either follow the port forwarding route and make sure your router is properly port forwarding or the alternative is to use LogMeIn's Hamachi client which will create an artificial lan connection and your friends will be able to coonect to your internal IP.
The link to instructions for this are Here
Hamachi is free and i think pretty easy to use.

FTB Server Friends can't connect


what do you think about that comment delete screen UX/UI?

Question: we have an android app that lets you share thoughts with friends without revealing who you are. It's in developing processes now!
I designed comments delete screen, but I'm not sure it's good for UX.
What do you think about?
Comment: It is better to delete without confirmation but provide an ability to undo the deletion (using a small notification or something). It's much more convenient way for deletion.
Answer: The major issue here is I don't know how to answer the question about deletion. You've asked the question in plain English, but I assume you are expecting me to answer in symbolic form. Do I click the 'trash symbol' to delete the message? It would be much clearer if the symbol was appended with the words "Yes, delete this comment". How do I cancel? There's no button to do that.
Also, you should perhaps place the comment under the question, and place the buttons last. Using the word "this" in your question is referring to something that is 2 objects away. Whenever you use the word "this", the object to which you are referring to should be adjacent to the sentence.
Answer: The final word on confirmation dialogs is given in the article Never use a warning when you mean undo by Aza Raskin on A List Apart. Here's the key idea:

People habituate: they press 'yes' without thinking, because 99% of the time that's what they want. The confirmation dialog isn't effective at asking for the required attention.
People shouldn't have to give their attention to the task, if it's a mindless flow 99% of the times.
An undo option is much better. People can follow their flow mindlessly and when they've accidentally deleted something, you give them the undo option.

The undo option actually eliminates the risk, instead of providing false safety and annoying users.
Comment: While undo is certainly better - sometimes it's not always feasible to technological constraints / limitations. Of course in that case the decision is a trade off between tech vs. better experience.
Answer: I like your design, but in my opinion it seems a little dangerous to place an invitation to delete content above the content itself. There are exceptions to this rule but generally I think it would be safer to place it beneath.
Further to Brendon's answer, I think you could condense this further to just the one button: the word "Delete", with the trash icon to the left / above it. It's maybe just me, but I would be comfortable just tapping in the greyed out area to cancel / go back.
Comment: A cancel option should have more visual weight than an irreversible action such as delete, so that the user doesn't accidentally click the irreversible action. Clicking on the greyed out area is too ambiguous.
Answer: There are two options...
1- Change the text to alert the user to what he is about to do " Are you sure you want to delete, because, you will lose this information..." as an example. Then give the user two options: "No" / "Yes". But in this situation, the user will probably click the "yes" option as Peter mentioned, because users do not read and are used to the "yes" as if it was a "Continue" action.
2 - Therefore having a screen where the user has an undo option would be the best solution in my opinion. In this case we wouldn't need the screen A1 at all.
In the examples below I created a screen where the user is being asked if he wants to save. If he clicks "yes" he will only get an automatic confirmation message that the information was not saved.
The best option is a screen with a "undo" option... Option B.
I want to get some ground biography about these points and would be happy if someone would list some books and sources here, please.


What should I do if my Dependent Care FSA amounts are inconsistent?

Question: Box 10 (for dependent care FSA) shows $4423. I elected, contributed, and was reimbursed 5000 according to the benefit provider, but only actually had 4423 withheld according to the payroll provider. That's 3 paychecks worth of missing contributions. I'm wondering if there's something wrong that I need to get corrected, or if I'm just not understanding how this works. Does that mean my employer picked up the tab for the remainder? What implications does that have for taxes?
Comment: Go back to your pay stubs and tally up what they say.  (Are you salaried or hourly?)
Answer: Definitely follow up with your employer on that one.  A common issue I suspect this year will be people who went on restricted or part-time status for a period of the year (due to budget cuts / office closure/ etc.) may not have had their FSA contributions removed (or, at least, accounted for) for those paychecks properly, and that may lead to issues like this in payroll reconciliation or when you get your W-2.
Talk to HR (or accounting, or whomever is the primary contact in your office for paycheck issues), and ask them to verify what your actual contribution was.  If you end up claiming only $4423 on your 1040, it increases your taxable income slightly, and if you claim $5000 but the W-2 says $4423, the IRS will want to know why the amounts are discrepant.
It's very possible you didn't actually have $5000 withdrawn, but spent it, and as a result you may end up owing the balance when HR/Accounting figures it out down the line - you don't want a rude surprise.  If you can verify the full amounts were withdrawn from every single paycheck, that would be ideal, but your employer should be able to tell you as well.
Ultimately, your hope is that everything was done right, and they just messed up the W-2, in which case they will issue you a corrected W-2.
Comment: @Octavian there might be a tax ramification in that the reporting may need to be updated. Your company (and you) will report the $4423 dependent care FSA as deductible. No issues there. However, if you don't pay the $577 back to the company, in theory they should tack that amount on to your W2 as additional compensation received.
Comment: All deductions were still fully withheld when I went on furlough for a week.  That's not a guarantee of everyone, but i wouldn't be surprised if it is, especially for salaried workers.
Comment: Thank you - this led me down the right rabbit hole. There was a while where our paid schedule got disrupted, and it does look like the payments were not deducted then. So the 4423 is correct, and I owe my company some money that they paid on my behalf to the benefits company. Assuming they tell me not to worry about it (which happened last time when there was a different insurance mistake), does that have any tax ramifications? I spent well over 5000 on childcare.


Can not get all SOAP services in Postman

Question: I can not get all SOAP services in Postman.
when I send: http://magento2.url/soap?wsdl_list=1
I get the following response:
Answer: Base on the message in the response

Internal Error. Details are available in Magento log file. Report ID:`

It looks like you have an internal Magento issue.
You can check Magento log files and find what is went wrong. Hint grep for Report ID: webapi-604...686.
And take a look at this answer https://magento.stackexchange.com/a/261670/94440.
Answer: Your URL is wrong. The correct one is http://magento2.url/soap/all?wsdl_list=1
As per https://devdocs.magento.com/guides/v2.4/get-started/soap/soap-web-api-calls.html:

If you want an overview to all the available Web Services, use the following URL format to get a list of all SOAP Services: http://<magento.host>/soap/all?wsdl_list=1


How to lock this closet with a non-standard knob size?

Question: We have a small closet in a spare room that we'd like to be able to lock with a key. It has a small, non-standard doorknob. I thought of using a hasp with a padlock, but that's ugly and more security than we actually need. Will I need to upgrade to a full-size doorknob, or is there another solution?
Comment: Bolt hasp. https://duckduckgo.com/?t=ffsb&q=bolt+hasp&iax=images&ia=images
Answer: I can't tell what the existing backset (distance from front-side edge of door to center of knob shaft) is, but you can buy mortise locksets that lock. A bit of chisel work would expand the existing mortise.
I shudder to offer this link, but as an example of widely available things, mortise lockset
The linked one appears to have a 2-1/2" backset.
I'd suggest an architectural scrap yard, except that their locksets don't always come with keys...
Answer: One other solution is to "simply" add a lock, ignoring the details of the current doorknob.
The padlock is actually dubious or an actual code violation, and the lock you choose to add should be releasable from inside the closet (which is why that's probably a code violation - locking people in closets is not safe.) It may be a "not uncommon" violation but I'm pretty sure it is one, these days, most places.


list_item and single_list_item containing different XML tags (RSS)

Question: I'm using RSS with different tags for my app and I want to show, for example, <title> and <pubDate> in my List, but when I click on specific item it suppose to open new layout which contains <title> and <description>.
I would appreciate any kind of help, link, hint or whatever :)
Thanks
Comment: I've tried using ListAdapter but the only thing i knew to do was to put same tags (for example title and date) both on list_item and single_list_item.
Answer: ListViews are tricker. The ListAdapter you use has to specify a layout that describes a single entry in the list, the source data items, and for each item the destination View in the single entry layout. There has to be a one-to-one correspondence between source item and destination View. HOWEVER, the array/Cursor/whatever that contains the source data can have more data in it. For a SimpleCursorAdapter, for instance, the Cursor itself can contain 15 items, but you only have to show 2. For a SimpleCursorAdapter, source items are specified as column names in an array of String, and destination Views are specified as resourceIDs in an array of int.
The most friendly way to display the details of a single list entry is to have an onClickListener that opens a new Activity/Fragment when clicked. The Listener is passed the index of the entry that was clicked. From this, you can work back to the Cursor row that backs that entry, then pass the necessary data to the new Activity/Fragment.
I used Cursor because that's the most common use case, but the same pattern works for arrays, lists, etc.


The best way to calculate the height in a binary search tree? (balancing an AVL-tree)

Question: I'm looking for the best way to calculate a nodes balance in an AVL-tree. I thought I had it working, but after some heavy inserting/updating I can see that it's not working correct (at all).
This is kind of a two-part question, the first part would be how to calculate the height of a sub-tree, I know the definition "The height of a node is the length of the longest downward path to a leaf from that node." and I understand it, but I fail at implementing it. And to confuse me further this quote can be found on wikipedia on tree-heights "Conventionally, the value -1 corresponds to a subtree with no nodes, whereas zero corresponds to a subtree with one node."
And the second part is getting the balance factor of a sub-tree in an AVL tree, I've got no problem understanding the concept, "get the height of your L and R sub-trees and subtract R from L". And this is defined as something like this: BALANCE = NODE[L][HEIGHT] - NODE[R][HEIGT]
Reading on wikipedia says this on the first few lines describing insertions into an AVL tree: "If the balance factor becomes -1, 0, or 1 then the tree is still in AVL form, and no rotations are necessary."
It then goes on, saying this "If the balance factor becomes 2 or -2 then the tree rooted at this node is unbalanced, and a tree rotation is needed. At most a single or double rotation will be needed to balance the tree." - which I have no trouble grasping.
But (yes, there's always a but).
Here's where it gets confusing, the text states "If the balance factor of R is 1, it means the insertion occurred on the (external) right side of that node and a left rotation is needed". But from m understanding the text said (as I quoted) that if the balance factor was within [-1, 1] then there was no need for balancing?
I feel I'm so close to grasping the concept, I've gotten the tree rotations down, implemented a normal binary search tree, and on the brink of grasping AVL-trees but just seem to be missing that essential epiphany.
Edit: Code examples are preferred over academic formulas as I've always had an easier time grasping something in code, but any help is greatly appreciated.
Edit: I wish I could mark all answers as "accepted", but for me NIck's answer was the first that made me go "aha".
Answer:  Part 1 - height
As starblue says, height is just recursive. In pseudo-code:
height(node) = max(height(node.L), height(node.R)) + 1

Now height could be defined in two ways. It could be the number of nodes in the path from the root to that node, or it could be the number of links. According to the page you referenced, the most common definition is for the number of links. In which case the complete pseudo code would be:
height(node):
   if node == null:
        return -1
   else:
        return max(height(node.L), height(node.R)) + 1

If you wanted the number of nodes the code would be:
height(node):
   if node == null:
        return 0
   else:
        return max(height(node.L), height(node.R)) + 1

Either way, the rebalancing algorithm I think should work the same.
However, your tree will be much more efficient (O(ln(n))) if you store and update height information in the tree, rather than calculating it each time. (O(n))
 Part 2 - balancing
When it says "If the balance factor of R is 1", it is talking about the balance factor of the right branch, when the balance factor at the top is 2. It is telling you how to choose whether to do a single rotation or a double rotation. In (python like) Pseudo-code:
if balance factor(top) = 2: // right is imbalanced
     if balance factor(R) = 1: //
          do a left rotation
     else if balance factor(R) = -1:
          do a double rotation
else: // must be -2, left is imbalanced
     if balance factor(L) = 1: //
          do a left rotation
     else if balance factor(L) = -1:
          do a double rotation

I hope this makes sense
Comment: Nick: http://en.wikipedia.org/wiki/Tree_height#Height
The end of the second paragraph of the "Terminolog" headline *"Conventionally, the value -1 corresponds to a subtree with no nodes, whereas zero corresponds to a subtree with one node."*
Comment: About height, should I stay true to the "node with zero children is considered -1 and node with one child is considered 0" ?
Comment: Try height(node) = max(height(node.L), height(node.R)) + 1;
Comment: In other words, how would the height() function look in python-like pseudo code? (sorry for two comments, hit add comment by mistake)
Comment: @Josh DOH! cheers.
@fredrikholmstrom - some pseudo code there now
Comment: @fredriksholmstrom - can you give a reference to this "node with zero children is considered -1" I can't see it in the referenced wikipediaarticle and it's new to me
Comment: @fredriksholmstrom - ok seen that reference. I think I've edited my answer to explain the -1/0 more clearly. Does it make sense now?
Comment: Nick, yes it does - thanks so much, I gave you correct answer for this question also.

Regards, Fredrik.
Comment: @NickFortescue I think your code in Part 2 is wrong. The `1` and `-1` in the outer `else` should be inverted, and in the first case it should do a right rotation, not a left one, like so: `else: // must be -2... if balance = -1: do a right rotation else if balance == 1 do a double rotation`. Also, the outer `else` should be an `else if`, because if `top`'s balance factor isn't `2`, that does not necessarily mean its balance factor is `-2`, it could be `-1`, 0` or `1`. Fix: `if balance factor(top) = 2: // right is imbalanced ... else if balance factor(top) = -2: // left is imbalanced`.
Comment: @NickFortescue why do you add 1 to max(height(node.L), height(node.R))?
Answer: You do not need to calculate tree depths on the fly.
You can maintain them as you perform operations.
Furthermore, you don't actually in fact have to maintain track of depths; you can simply keep track of the difference between the left and right tree depths.
http://www.eternallyconfuzzled.com/tuts/datastructures/jsw_tut_avl.aspx
Just keeping track of the balance factor (difference between left and right subtrees) is I found easier from a programming POV, except that sorting out the balance factor after a rotation is a PITA...
Answer:
Height is easily implemented by recursion, take the maximum of the height of the subtrees plus one.
The "balance factor of R" refers to the right subtree of the tree which is out of balance, I suppose.
Answer:
Here's where it gets confusing, the text states "If the balance factor of R is 1, it
means the insertion occurred on the (external) right side of that node and a left
rotation is needed". But from m understanding the text said (as I quoted) that if the
balance factor was within [-1, 1] then there was no need for balancing?

Okay, epiphany time.
Consider what a rotation does.  Let's think about a left rotation.
 P = parent
 O = ourself (the element we're rotating)
 RC = right child
 LC = left child (of the right child, not of ourself)

 P              10
  \               \
   O               15
    \                \
     RC               20
    /                /
   LC               18

          ↓
 P              10
   \               \
     RC              20
   /               /
  O              15
   \               \
   LC              18

 basically, what happens is;

 1. our right child moves into our position
 2. we become the left child of our right child
 3. our right child's left child becomes our right

Now, the big thing you have to notice here - this left rotation HAS NOT CHANGED THE DEPTH OF THE TREE.  We're no more balanced for having done it.
But - and here's the magic in AVL - if we rotated the right child to the right FIRST, what we'd have is this...
 P                  10
  \                   \
   O                  15
    \                   \
     LC                 18
      \                   \
       RC                 20

And NOW if we rotate O left, what we get is this...
 P                     10
   \                     \
     LC                  18
    /  \                /  \
   O   RC              15  20

Magic!  we've managed to get rid of a level of the tree - we've made the tree balanced.
Balancing the tree means getting rid of excess depth, and packing the upper levels more completely - which is exactly what we've just done.
That whole stuff about single/double rotations is simply that you have to have your subtree looking like this;
 P
  \
   O
    \
     LC
      \
       RC

before you rotate - and you may have to do a right rotate to get into that state.  But if you're already in that state, you only need to do the left rotate.
Answer: Here's an alternate way of finding height. Add an additional attribute to your node called height:
class Node
{
data value; //data is a custom data type
node right;
node left;
int height;
}

Now, we'll do a simple breadth-first traversal of the tree, and keep updating the height value for each node:
int height (Node root)
{
Queue<Node> q = Queue<Node>();
Node lastnode;
//reset height
root.height = 0;

q.Enqueue(root);
while(q.Count > 0)
{
   lastnode = q.Dequeue();
   if (lastnode.left != null){
      lastnode.left.height = lastnode.height + 1;
      q.Enqueue(lastnode.left);
   }

   if (lastnode.right != null){
      lastnode.right.height = lastnode.height + 1;
      q.Enqueue(lastnode.right);
   }
}
return lastnode.height; //this will return a 0-based height, so just a root has a height of 0
}

Cheers,
Answer: Well, you can compute the height of a tree with the following recursive function:
int height(struct tree *t) {
    if (t == NULL)
        return 0;
    else
        return max(height(t->left), height(t->right)) + 1;
}

with an appropriate definition of max() and struct tree.  You should take the time to figure out why this corresponds to the definition based on path-length that you quote.  This function uses zero as the height of the empty tree.
However, for something like an AVL tree, I don't think you actually compute the height each time you need it.  Instead, each tree node is augmented with a extra field that remembers the height of the subtree rooted at that node.  This field has to be kept up-to-date as the tree is modified by insertions and deletions.
I suspect that, if you compute the height each time instead of caching it within the tree like suggested above, that the AVL tree shape will be correct, but it won't have the expected logarithmic performance.
Answer:
Here's where it gets confusing, the text states "If the balance factor of R is 1, it means the insertion occurred on the (external) right side of that node and a left rotation is needed". But from m understanding the text said (as I quoted) that if the balance factor was within [-1, 1] then there was no need for balancing?

R is the right-hand child of the current node N.
If balance(N) = +2, then you need a rotation of some sort. But which rotation to use? Well, it depends on balance(R): if balance(R) = +1 then you need a left-rotation on N; but if balance(R) = -1 then you will need a double-rotation of some sort.
Answer: Give BinaryTree<T, Comparator>::Node a subtreeHeight data member, initialized to 0 in its constructor, and update automatically every time with:
template <typename T, typename Comparator>
inline void BinaryTree<T, Comparator>::Node::setLeft (std::shared_ptr<Node>& node) {
    const std::size_t formerLeftSubtreeSize = left ? left->subtreeSize : 0;
    left = node;
    if (node) {
        node->parent = this->shared_from_this();
        subtreeSize++;
        node->depthFromRoot = depthFromRoot + 1;
        const std::size_t h = node->subtreeHeight;
        if (right)
            subtreeHeight = std::max (right->subtreeHeight, h) + 1;
        else
            subtreeHeight = h + 1;
    }
    else {
        subtreeSize -= formerLeftSubtreeSize;
        subtreeHeight = right ? right->subtreeHeight + 1 : 0;
    }
}

template <typename T, typename Comparator>
inline void BinaryTree<T, Comparator>::Node::setRight (std::shared_ptr<Node>& node) {
    const std::size_t formerRightSubtreeSize = right ? right->subtreeSize : 0;
    right = node;
    if (node) {
        node->parent = this->shared_from_this();
        subtreeSize++;
        node->depthFromRoot = depthFromRoot + 1;
        const std::size_t h = node->subtreeHeight;
        if (left)
            subtreeHeight = std::max (left->subtreeHeight, h) + 1;
        else
            subtreeHeight = h + 1;
    }
    else {
        subtreeSize -= formerRightSubtreeSize;
        subtreeHeight = left ? left->subtreeHeight + 1 : 0;
    }
}

Note that data members subtreeSize and depthFromRoot are also updated.
These functions are called when inserting a node (all tested), e.g.
template <typename T, typename Comparator>
inline std::shared_ptr<typename BinaryTree<T, Comparator>::Node>
BinaryTree<T, Comparator>::Node::insert (BinaryTree& tree, const T& t, std::shared_ptr<Node>& node) {
    if (!node) {
        std::shared_ptr<Node> newNode = std::make_shared<Node>(tree, t);
        node = newNode;
        return newNode;
    }
    if (getComparator()(t, node->value)) {
        std::shared_ptr<Node> newLeft = insert(tree, t, node->left);
        node->setLeft(newLeft);
    }
    else {
        std::shared_ptr<Node> newRight = insert(tree, t, node->right);
        node->setRight(newRight);
    }
    return node;
}

If removing a node, use a different version of removeLeft and removeRight by replacing subtreeSize++; with subtreeSize--;.  Algorithms for rotateLeft and rotateRight can be adapted without much problem either.  The following was tested and passed:
template <typename T, typename Comparator>
void BinaryTree<T, Comparator>::rotateLeft (std::shared_ptr<Node>& node) {  // The root of the rotation is 'node', and its right child is the pivot of the rotation.  The pivot will rotate counter-clockwise and become the new parent of 'node'.
    std::shared_ptr<Node> pivot = node->right;
    pivot->subtreeSize = node->subtreeSize;
    pivot->depthFromRoot--;
    node->subtreeSize--;  // Since 'pivot' will no longer be in the subtree rooted at 'node'.
    const std::size_t a = pivot->left ? pivot->left->subtreeHeight + 1 : 0;  // Need to establish node->heightOfSubtree before pivot->heightOfSubtree is established, since pivot->heightOfSubtree depends on it.
    node->subtreeHeight = node->left ? std::max(a, node->left->subtreeHeight + 1) : std::max<std::size_t>(a,1);
    if (pivot->right) {
        node->subtreeSize -= pivot->right->subtreeSize;  // The subtree rooted at 'node' loses the subtree rooted at pivot->right.
        pivot->subtreeHeight = std::max (pivot->right->subtreeHeight, node->subtreeHeight) + 1;
    }
    else
        pivot->subtreeHeight = node->subtreeHeight + 1;
    node->depthFromRoot++;
    decreaseDepthFromRoot(pivot->right);  // Recursive call for the entire subtree rooted at pivot->right.
    increaseDepthFromRoot(node->left);  // Recursive call for the entire subtree rooted at node->left.
    pivot->parent = node->parent;
    if (pivot->parent) {  // pivot's new parent will be its former grandparent, which is not nullptr, so the grandparent must be updated with a new left or right child (depending on whether 'node' was its left or right child).
        if (pivot->parent->left == node)
            pivot->parent->left = pivot;
        else
            pivot->parent->right = pivot;
    }
    node->setRightSimple(pivot->left);  // Since pivot->left->value is less than pivot->value but greater than node->value.  We use the NoSizeAdjustment version because the 'subtreeSize' values of 'node' and 'pivot' are correct already.
    pivot->setLeftSimple(node);
    if (node == root) {
        root = pivot;
        root->parent = nullptr;
    }
}

where
inline void decreaseDepthFromRoot (std::shared_ptr<Node>& node) {adjustDepthFromRoot(node, -1);}
inline void increaseDepthFromRoot (std::shared_ptr<Node>& node) {adjustDepthFromRoot(node, 1);}

template <typename T, typename Comparator>
inline void BinaryTree<T, Comparator>::adjustDepthFromRoot (std::shared_ptr<Node>& node, int adjustment) {
    if (!node)
        return;
    node->depthFromRoot += adjustment;
    adjustDepthFromRoot (node->left, adjustment);
    adjustDepthFromRoot (node->right, adjustment);
}

Here is the entire code:  http://ideone.com/d6arrv
Answer: This BFS-like solution is pretty straightforward. Simply jumps levels one-by-one.
def getHeight(self,root, method='links'):
    c_node = root
    cur_lvl_nodes = [root]
    nxt_lvl_nodes = []
    height = {'links': -1, 'nodes': 0}[method]

    while(cur_lvl_nodes or nxt_lvl_nodes):
        for c_node in cur_lvl_nodes:
            for n_node in filter(lambda x: x is not None, [c_node.left, c_node.right]):
                nxt_lvl_nodes.append(n_node)

        cur_lvl_nodes = nxt_lvl_nodes
        nxt_lvl_nodes = []
        height += 1

    return height


What are references for learning type theory?

Question: What could be a good set of references for starting to learn type theory? We can assume that the students have a computer science background but not specifically on functional programming or lambda calculus, and that they know propositional and first-order logic but not constructive logic or proof theory (natural deduction or sequent calculi).
Answer: First, "type theory" is a broad concept encompassing many kinds of type theories and many use cases.  For example, since this is the Proof Assistant Stack Exchange, there are two main kinds of type theories used for proof assistants:

Simple type theory, including typed lambda calculus and Higher Order Logic (HOL): HOL is the basis for HOL-Light, HOL4, and Isabelle/HOL.
Dependent type theory (DTT): DTT is the basis for Coq, Lean, Agda, Arend, and other proof assistants.  Almost all of them use some variation on the Calculus of Inductive Constructions (CIC) which is a way to add computational rules to DTT to make it more automatic to generate some proofs.  Also, a common extension of dependent type theory is Homotopy Type Theory (HoTT) which is used for some Coq projects, many Agda projects, and all of Arend.  (Lean used to support HoTT, but mostly doesn't anymore.)

There are also many things you can do with type theory:

Mathematics

Type theory is used practically to build proof assistants and prove theorems in math (as already mentioned above).
Type theory provides an alternative foundation of mathematics similar to set theory, but which more easily incorporates constructive logic and universe levels.  Just like set theory, one can study the meta-logical properties of type theory such as its consistency and the properties of various extra rules and axioms (like univalence axiom and the axiom of choice).
Type theory provides a way to describe special kinds of categories in category theory, including Cartesian-closed categories and Topos categories, as well as their higher-category versions.
Conversely, category theory provides models of various type theories.  (A major area of research is models of HoTT.)

Computer science

Type theory provides a framework for practically building functional programming languages. Simple type theory provides the framework for statically typed functional languages like OCaml, Haskell, and Scala.  DTT provides a framework for dependently types languages like Idris and Lean 4.
Type theories are closely related to computation, and as such there are a lot of computational questions about type theories such as if they compute or normalize.  This is both theoretical, but also practical, since many theorem provers and programming languages use the computational properties of type theory and trust that terms in the language will reduce/compute and types in the language will type-check.
Just as there are categorical models to type theories, there are also computational models which describe the type theory as a programming language.

Having said all this, you can see that there isn't just one aspect to type theory, and maybe unlike logic, there isn't an established Introduction to Type Theory curriculum that I'm aware of.
Here are a few suggestions:

Look at the The MathOverflow question Good Introductory Book to Type Theory? which is basically an older duplicate of this question.
If you are interested in HOL, look at the question The Proof Assistant StackExchange question Reference request for an introduction to higher order logic.
Since you are on the proof assistant stack exchange, I would just recommend starting by learning a theorem prover or two.  Lean, Coq, and Agda would be good for learning DTT, and they have good tutorials.  (For Lean 4, look at Theorem Proving in Lean 4. For HoTT in Agda, see Introduction to Univalent Foundations of Mathematics with Agda
.  For HoTT in Arend, see the Arend Tutorial.)  Isabelle/HOL and HOL-Light have good tutorials for learning HOL. (For Isabelle/HOL, see Programming and Proving in Isabelle/HOL).
My advisor, Jeremy Avigad, has written a logic book, Mathematical Logic and Computation.  It covers (or will when it is released) both simple typed lambda calculus, as well as dependent type theory.
The standard dependent type theory introduction is now the first chapter to The HoTT Book.  This goes deeper into DTT than many theorem prover tutorials, and if you are interested in HoTT, you can read the rest of the book.
If you are interested in learning about the duality between category theory and type theory, I've found Steve Awodey's Category Theory helpful, especially the section 6.6 on lambda calculus.  After that, you can look at the article From Sets to Types to Categories to Sets.
Comment: Thank you for the answer, alsp because I was not aware of Arend and I was precisely looking for a proof assistant based on HoTT.
Comment: not aware of Arend either .. wonder where there is a comparison of all those provers : lean, coq, agda, arend if that makes any sense. last I checked Agda was nice but buggy, whereas coq was robust and closer to ocaml