In Operating Systems, I can't understand why deadlock happens, why does a process not let go of a resource when it is done using it?

Question: I know deadlock occurs when Process A has resource R1 and is waiting for resource R2, while process B has resource R2 and is waiting for resource R1, however why don't both processes just let go of the resource they are currently owning before/while waiting for the other resource? How does A keep holding on to R1 even though it is waiting for R2.
Answer: To answer part of your question: Processes are not smart. Processes just execute the code of their program, so if the program of P1 has not been written to release R1 when it's done with it, it won't be released.
Besides, the classical setting in which a deadlock happens does not have to do with processes not releasing resources after they are done with them, but rather with competing processes trying to acquire the needed resources.
Process A needs both R1 and R2 to perform some task, so it starts acquiring them. It acquires R1, and tries to acquire R2.
Just before P1 gets to acquire R1, some process P2 that also needs both R1 and R2 tries to acquire them. This time P2 starts with acquiring R2, and succeeds.
At this point the following two things happen:

P1 tries to acquire R2 which is unavailable, so it waits for R2 be released.
P2 tries to acquire R1 which is unavailable, so it waits for R1 be released.

From this point on both P1 and P2 are stuck waiting for another resource that will never be released, i.e., they are in a deadlock.
Notice that no process ever held a lock on a resource that didn't intend to use.
The problem was that P1 and P2 tried to lock the resources in a different order.
Finally, you might think that when P1 tries to acquire R2, and finds that it is unavailable it could just temporarily release R1 and try to acquire both R1 and R2 at a later time.
However, without additional synchronization, this also doesn't ensure that P1 and P2 will manage to acquire the needed resources. The following could happen:

P1 acquires R1, P2 acquires R2.
P1 tries to acquire R2, and finds that R2 is unavailable.
P2 tries to acquire R1, and finds that R1 is unavailable.
P1 releases R1.
P2 releases R2.
P1 acquires R1 and is about to acquire R2.
P2 acquires R2 and is about to acquire R1.
P1 tries to acquire R2, and finds that R2 is unavailable.
P2 tries to acquire R1, and finds that R1 is unavailable.
....
Comment: Note that the "release R2 if R1 isn't immediately available" is not always feasible. Think *modifying* R2 in some way, and then refering to R1 to guide further changes to both. Releasing half-modified R2 is just wrong.
Comment: Thank you so much!
Answer: You run into a problem when thread A has aquired lock 1, and then decides that it needs both lock 1 and lock 2, and tries to aquire lock 2, while thread B has aquired lock 2, and then decides that it needs both lock 2 and lock 1.
Once a thread starts aquiring a lock, that operation can't be stopped - it hangs until the lock is available.
Answer: There are four necessary conditions for deadlock , and these are
1. Mutual Exclusion
2. Hold and Wait
3. No preemption
4. Circular wait
And to prevent deadlock we need to disable one of these four necessary conditions.Now the solution to no preemption is taking resources away ( which requires hardware support ). But this will cause inconsistency e.g., if a process P is using printer and now another process Q demands for it. And now if printer is given to Q , then for P we need to start the task again.


Check if Website is hidden from Search Engines?

Question: Any idea how to check if the website is hidden from search engines? The reason is I want to show a big red banner at the top of the homepage when this option is checked because I always forget that this option is checked.
Answer: The setting is stored in the option blog_public.
if( 0 == get_option( 'blog_public' ) ){
    echo 'search engines discouraged';
}

Answer: Pretty sure I stole borrowed the following piece of code from the very handy and useful Yoast Plugin:
/**
 * Check if Website is visible to Search Engines
 */
function wpse_check_visibility() {
    if ( ! class_exists( 'WPSEO_Admin' ) ) {
        if ( '0' == get_option( 'blog_public' ) ) {
            add_action( 'admin_footer', 'wpse_private_wp_warning' );
        }
    }
}
add_action( 'admin_init', 'wpse_check_visibility' );

/**
 * If website is Private, show alert
 */
function wpse_private_wp_warning() {
    if ( ( function_exists( 'is_network_admin' ) && is_network_admin() ) ) {
        return;
    }

    echo '
';
    echo '
' . __( 'Huge SEO Issue: You\'re blocking access to robots.', 'wpse-seo' ) . ' ' . sprintf( __( 'You must %sgo to your Reading Settings%s and uncheck the box for Search Engine Visibility.', 'wordpress-seo' ), '', '' ) . '

';
}

Pretty much on admin_init we check if our site is private. If it is we're going to use the footer and WordPress alert styles to tell us that the site is private. The WPSEO_Admin is Yoast as I believe they will also tell you the site is private if it's installed so we don't want to step on their toes.
Comment: Maybe an alternative would be to display the warning in the admin bar, both on frontend and backend? I'm sure we could find a suitable dashicon with it ;-)
Answer: Another way to see if your Website is hidden from Search Engines is going to Settings » Privacy Settings
The Site Privacy setting controls who can view your site, allowing you to make the site private or public. To access this setting, go to My Site → Settings and look for Privacy.

Privacy Options

Public: This is the setting used by most sites. It allows everyone to read your site and enables your site to be included in search engine results and other content sites.
Hidden: If you want all human visitors to be able to read your blog, but want to block web crawlers for search engines, this is the setting for you. (Please note, however, that not all search engines respect this setting.)
Private: Select this option to make your site private. If you want specific people to be able to view it (and add comments, if you've enabled them), you'll need to invite them to be a viewer.
Comment: You misunderstood the Question. It's about seeing it in the Frontend (so the customer can see it without checking the backend). More like an "alert", you know ... .
Comment: Ahh Ok, ok I totally understood something else. Thanks for explaining @henning-fischer
Answer: Using this since Milos answer on every WordPress project as a handy snippet (put it right after the opening body tag):
<?php if ( is_user_logged_in() ) { ?>

    <?php
        if( 0 == get_option( 'blog_public' ) ){
            echo '!G';
        }
    ?>
<?php } ?>


Inserting javascript with jQuery .html

Question: I'm experiencing an issue with a website I'm working on, where I originally believed I could simply replace $("main").html(this) which was originally code for a flash object, with a new and improved HTML5/Javascript version.
The original code:
$("#main").html('
<object width="100%" height="100%" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000">\
                    <param value="images/uploads/'+image_id+'.swf" name="movie">\
                    <param value="true" name="allowFullScreen">\
                    <param value="#737373" name="bgcolor">\
                    <param value="" name="FlashVars">\
                    <embed width="100%" height="100%" flashvars="" bgcolor="#737373" allowfullscreen="true" src="images/uploads/'+image_id+'.swf" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">\
                    </object>
\
                ');
            });

And my (failed) attempt at inserting my new code:
$("#main").html('');

It doesn't even work when I just put , so I know it's gotta be the javascript itself.
I've looked at the solutions out there, but I can't make sense in how to properly implement them here in the most efficient way.
Your help is much appreciated, thanks!
Comment: Are you getting any errors in console?
Answer: You can put your script in a external file and do something like this:
var scrpt = document.createElement("script");
scrpt.type = "text/javascript";
scrpt.src = "js/yourImprovedFile.js";
// Use any selector
$("#main").append(scrpt);

Inserting javascript with jQuery .html


sitting on a table with sifrei kodesh on it

Question: Is there a halachik problem with sitting on a table or surface that has siddurim/chumashim on it? What about other sefarim? What about putting one's feet on a table that has such books on it?
Answer: this article on the Topic says there is a basic consensus of Poskim that say you may not sit or put your feet on a place with seforim as printed seforim have the same or slightly lesser level of kedusha and most be shown respect as such.
Source
Answer: A Jew is not supposed to sit on a table as a table is similar to a Mizbayach.
http://ravbaruch.com/AskTheRabbi.asp?QID=41
Comment: I was more wondering where the custom is recorded and by whom, and which communities rely upon it.
Comment: Gershon do you have a halakhic source for this?  I was fairly certain that this was just an Ashkenazi custom.
Comment: Gershon, that is a great source!  Thank you.
Comment: The source you linked to basically says the opposite of what you said in your answer (about sitting on tables in general), although he says that there might be some basis for those who want to avoid sitting on tables that are usually used for sefarim. In an [archived version of the original article](http://web.archive.org/web/20090326060210/http://afoksy.com/AskTheRabbi.asp?QID=180), R' Rubanowitz adds that it may be reasonable for a parent to tell a child not to climb on a (generic) table for derech eretz reasons, although the shulchan-as-mizbeiach idea would not be relevant.
Comment: mekubal, that it is an Ashkenazi custom can also be called a source.


how to eliminate interference in the same center frequency

Question: I'm trying to receive an ASK signal in the 433 MHz center frequency with a bandwidth of 100KHz. I'm using a CC1101 transceiver connected to a Raspberry Pi GPIO ports. However, there is an intermittent signal in the 433MHz center frequency coming from the sensors of my alarm system, so the RX doesn't get all the samples of my wanted signal and I'm not sure how I could filter the interference because both signals are "unknown" (they are not generated by me). I wonder how I could do this, at least in theory.
Comment: I am finding it a little bit difficult to understand what a "valid answer" would look like to the problem you presented. Did you have something specific in mind? How do you see this question answered? Could we safely say that it is answered in the negative? That it is impossible to do what you are after? What do you think?
Answer: First of all, the CC1101 supports a number of other frequencies, so as a trivial solution, you can switch to using those.
The other thing that you can do at the RF module level is to "shift" your data out of the problematic region. Now, I am assuming that the other module is on 433MHz and it is not a similar module with similar operation. Let's assume that the interfering module is different than the one you are using.
What you could do, is shift to 4-FSK with the highest DEVIATION_M (refer to the datasheet) but use it as 2-FSK. What you would be trying to do is use the two symbols that cause the largest deviation to the centre carrier frequency to avoid your data being contaminated by the interference. Usually, these two symbols would be 00 and 11 (notice these pairs). This is inefficient of course, but it might work as a quick workaround for you.
But what might be happening is that the other RF module is also behaving in the same way. It might also be doing Frequency Shift Keying, in which case, none of the frequencies your RF module might try to hop to is "safe" from noise.
In this case, you have to work with high levels of noise.
The number one way to guard against this kind of interference is with the use of coding.
This can take many forms and have various complexities. One of the simplest "encoding" schemes is a Repetition Code coupled with simple Majority Decoding scheme. You might notice above that your effective B-FSK used the symbols 00 and 11 which, effectively, is a bit like using a repetition code.
One of the issues you might face in this case is that you do not have access to the internals of the RF module. In other words, the only thing you would be doing here is repeat bits $N$ times and at the reception end, receive a frame and decide what bit was sent by assigning the frame to the majority of bits received (either $0$ or $1$).
Obviously the question now is, where does the frame start and where does it end?
To deal with this, you are now going to have to embed your data stream on some form of protocol that specifies that your actual message starts with something like 0000000000111111111100001111001101 followed by your encoded bits.
The frame start sequence has equal chances of being contaminated with noise as the rest of the data, but the idea is to be looking in to your incoming data stream for a sequence that looks as close as possible to the frame start sequence.
And thus, progressively, we are going closer and closer to convolutional codes where you would be inserting redundant 0s and 1s in a predictable way in your data stream to be able to decode the most likely sequence to have been sent. That is a bit more involved at the decoding side but convolutional codes are more powerful than plain repetition codes.
Hope this helps.
Comment: thanks for this, but our signal modulation is ASK, so I think we can't use the Deviation option. also, we can't alter any of the received signals. one of them is wanted and the other one is interference, but we don't generate any of them.
Answer: Have a model for the interference, if you can hopefully get the idea of amplitudes of the interference (you could get the idea using the following):
Since you mention that interference occurs at random times, get a spectrogram running on the received signal and watch for abrupt transitions (would occur when ur random interference occurs), then from the FFT knowledge about the interference you would get idea of interference power. Once you know this, model the random Interference as noise to your signal with appropriate variance and mean zero. The power of Interference is given by the FFT magnitude squared using parsevalls theorem.  Then as a second step once you have the overall signal and interference modelled you could use sequential least squares to estimate the signal.
Answer: The best way to share the same carrier is to use CDMA modulation.  The GPS satellite constellation all broadcast on the same carriers.
You mentioned that the interference was intermittent, so don't broadcast when it does.  The alarm sensors are either using a schedule or using collision detection-rebroadcast protocol, so fill the empty times.
There is a lot of work called cognitive radio which steals dead time.
Blocking a carrier while simultaneously receiving is hard to do.
Most new stuff is designed to be part of a network, conforming to a standard.  Roll your own protocols tend to be frowned on, unless there is a very good reason.  The non recurring costs are higher. The maintenance costs are higher.  Upgrade is rip out and replace.
Comment: the issue there is that the wanted signal comes at  random/unknown times, so we can't predict or wait for it.
Answer: As long as the post processing delay is acceptable another potential option is to puncture in time or puncture in frequency depending on the nature of the interference and your ability to detect it. If the interference is much shorter in time than the symbol pulse duration but clearly at a higher amplitude than the signal of interest then the strategy of blanking the interference will provide reception advantage. Alternatively if the interference is much narrower in frequency than the bandwidth of the signal but much larger in amplitude within an FFT bin then the strategy of taking an FFT and excising the interference followed by IFFT (frequency domain excision) will provide reception advantage. The imposed new interference of nulling in time or nulling in frequency and equalizing for that would need to be balanced with the advantage of removing the external interference.


Problem while compile less in custom theme of magento 2

Question: In folder app\design\frontend\Vendor\theme\web\css\_styles.less
It already @import 'source/lib/_lib.less' this will define variables/_colors.less
But i can't figure out why magento raise undefine variables in module Magento_Theme inside of my custom theme
Is it process compile less in module first then go to web folder of theme?

Testing with Magento 2.0.2 and xampp on windows 10
Answer: On your custom theme copy this file:
app/design/frontend/Magento/luma/web/css/source/_variables.less

to
app/design/frontend/[PACKAGE]/[THEME]/web/css/source/_variables.less

This file above contains the variable @copyright__background-color that you need.
Or you can add this variable on the top of your _styles.less but I don't recommend it.
So run these commands:
alias mage="php -d memory_limit=-1 -f bin/magento"

chmod -R 775 pub/static/ var/ pub/media/ &&
rm -rf var/view_preprocessed/ var/cache/ var/page_cache/ var/tmp/ var/generation/ pub/static/frontend/ ;
mage cache:clean &&
mage cache:flush &&
mage indexer:reindex &&
mage setup:static-content:deploy ; mage setup:static-content:deploy -f;
mage dev:source-theme:deploy &&
chmod -R 775 pub/static/ pub/media/ var/

Answer: you have to create
app\design\frontend\Vendor\theme\web\css\_theme.less
and also test this by putting some css in it.
.page-header {
    background-color: #000;
}

after this deploy the static content
php bin/magento setup:static-content:deploy

Answer: Understanding the use of LESS in Magento 2 is an important skill. First of all, check out that if you are using the correct syntax or not. When a LESS file runs, it automatically generates CSS. Here is the basic example to understand how a LESS converts into CSS.
Let's take a LESS file with the following code:
@radius: 20px;

#somediv {
    -webkit-border-radius: @radius;
    -moz-border-radius: @radius;
    border-radius: @radius;
}

The above code will be compiled in CSS as:
#somediv {
    -webkit-border-radius: 20px;
    -moz-border-radius: 20px;
    border-radius: 20px;
}

In this example, the LESS file with a variable @radius will assign a value of 20px wherever @radius variable will be invoke in LESS file and generate the CSS file.
Now, if we talk about how to use custom LESS in a Magento 2 store, you will have to start with creating a basic module with custom.less file in app/code/Module_Namespace/Module_Name/view/frontend/web/ and after adding the custom code in it, enable the extension and perform necessary actions using below Magento 2 CLI commands:
rm -rf var/di/* var/generation/* var/cache/* var/log/* var/page_cache/* var/session/* var/view_preprocessed/* pub/static/*
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy
php bin/magento cache:clean
php bin/magento cache:flush
php bin/magento indexer:reindex

For the reference, please have a look at this blog post:
https://www.cloudways.com/blog/use-less-in-magento-2/
Answer: Make sure your own Less files don't have the same name as the Less files from the Luma theme! If so, they will overwrite the Luma files.
So, if you are using a file named variables.less, and it only contains three variables, it will, after deploying, overwrite the luma theme variables.less and all the Luma variables will be gone.
Answer: I have added
@copyright__background-color: @color-gray-middle4;
to my _theme.less file according following link, its worked for me.
https://github.com/magento/magento2/issues/12398


How does cooling scale with volume?

Question: What equation would give me the answer to the question, "If i have a cup of water at a tempature of say boiling, how long would that cup of water take to cool off compared to say half that size of a cup of water."  So the volume is in half.  Its a general question I am just looking for where to start.
Comment: Sean, google for "heat transfer", to learn about basics of a very complicated field, and that this is not a part of thermodynamics.
Answer: An actual cup is slightly complicated because there are 2–3 distinct types of surfaces. Let's deal with free-floating cubes of water instead, both at an initial temperature Ti  in an environment with temperature Te .
A cube with half the volume will have 50% the thermal mass C, but 63% of the surface area A. Newton's Law of Cooling implies $\frac{dT}{dt}=-h\frac{A}{C}(T-T_0\!)$ , where h is a property of the environment. So the smaller cube will cool 26% faster initially, when both cubes are at Ti .
If you want to know the temperature of a cube at any given time, the solution to the differential equation above is $\frac{T-T_e}{T_i-T_e}=\exp\left(-ht\frac{A}C\right)$. If you solve for t, it follows that when the small cube is at a given temperature, it will take the large cube 26% more time to reach it.
Comment: Vaporisation and convection (especially when not forced, but by Grashoff) are terribly nonlinear. To roll them up in a linear coefficient is misleading. (Especially to beginners!)
Comment: This is not wrong, but utterly misleading, because vaporizing is 99 % of heat transfer in the case of boiling water (and well below 100°C still), as asked for!
Comment: @Georg, vaporization and convection are both rolled up into the heat transfer coefficient. True, I assume that *h* is constant with temperature, but generally people aren't so anal about obvious back-of-the-envelope calculations. What's with the chip on your shoulder?
Comment: Not a physicist or even remotely scientifically literate, but I came here to ask a similar question and was directed here. Can you ELI5 this answer? Does the smaller cube or the larger cube become cooler faster?
Answer: It might help to start by looking at Newton's law of cooling.

How does cooling scale with volume?


What is the difference between $\bar x$ and $\bar X$?

Question: I'm reading "Statistics: Principles and Methods" by Johnson and Bhattacharyya (7th edition). I know $\bar x$ is sample mean, $\mu$ is population mean, $s^2$ is sample variance, $\sigma^2$ is population variance, $s$ is sample standard deviation, and $\sigma$ is population standard deviation. However, in the later chapters the authors seem to use capital letters $\bar X$ and $S$ (to denote the sample mean  and  sample standard deviation). Why is this so? Is there a (fundamental) difference between them?
Comment: kits -- my first guess would be that the $\overline{X}$ represents the random variable defined as $(X_1+X_2+...+X_n)/n$ and $S$ would be the corresponding random variable $\sqrt{\sum_i (X_i-\overline{X})^2/(n-1)}$, but as whuber says, I expect that this is explained somewhere in the book. These quantities are distinct from the observed sample values $\bar{x}$ and $s$ which can be thought of as samples from the distribution of the (upper-case) random variables.
Comment: Surely they explain their notation!  Have you looked closely through the text to find out what they say?  (Although there are some conventions about notation, they are not universal, so it is best to consult your original source--the text--rather than hoping that reasoned speculation will resolve your question.)
Comment: Also $\mu^2$ should probably be $\sigma^2$.
Comment: Trust me I am studying this book very seriously...I cannot find any explanation in there for this...my only guess is that X-bar is the sample mean of a random variable and S is the sample sd of a random variable.
Comment: @Michael Chernick. yes. Sir.
Comment: @MichaelChernick The $\sigma^2$ mistake is the result of my rushing through the $\LaTeX$ without paying attention on my prior edit.
Comment: That is not a problem.  I just thought it would be better to correct it through an edit.  So that is what I did.
Answer: My brief searching through the Statistics: Principles and Methods on books.google.com suggests that it is exactly as @Glen_b's comment describes (and most everyone is guessing): lowercase $\bar{x}$ is a number while $\bar{X}$ is a random variable.
Quick review of what's a random variable:

10, 2.1, $\pi$, etc... are real numbers.
A real valued random variable is a function from a sample space $\Omega$ to the space of real numbers $\mathbb{R}$.

Example of the sample mean as a random variable and as a number:
Let be $X_1, X_2, \ldots, X_5$ be random variables denoting the result of rolling a fair six sided die five times.
The sample mean of these five random variables is:
$$\bar{X} = \frac{X_1 + X_2 + X_3 + X_4 + X_5}{5} $$
$\bar{X}$ is also a random variable. $\bar{X} = 3.5$ is a possible outcome, $\bar{X} = 2$ is another possible outcome, etc...
Now imagine that we rolled a die 5 times and obtained the series of values $4, 6, 1, 5, 4$. The sample mean for these 5 values is given by:
$$\bar{x} = \frac{4 + 6 + 1 + 5 + 4}{5} = 4$$
The sample mean $\bar{x}$ of these 5 particular numbers is not a random variable. $\bar{x}$ is a single number.
An event occurred where $X_1 = 4, X_2 = 6, X_3 = 1, X_4 = 5, X_5 = 4$ and $\bar{X} = 4$.
General notation notes:
In the context of probability:

Lowercase letters are often numbers.
Uppercase letters are often random variables.

Of course there's a lot of different notation out there (upper case letters often denote vectors or matrices etc...) so neither of these bullet points are laws set in stone.
References:
Johnson, Richard A. and Gouri K. Bhattacharya, Statistics: Principles and Methods, 6th edition
Comment: @AntoniParellada Ahhh got it. Yeah, I'm using each $X_1$, $X_2$, $X_3$ here as different random variables. They could be $X$, $Y$, $Z$. I agree it can get a bit confusing sometimes what indices refer to. Eg. you can also use an $n$ dimensional vector $\mathbf{x}$ to define a function from $n$ possible outcomes to the space of real numbers. You'd use $x_i$ to refer to the $i$th row of vector $\mathbf{x}$. And $\mathbf{x}$ is basically a random variable: it's a function from $\{1, 2, \ldots, n\}$ to $\mathbb{R}$.
Comment: +1 Thank you, Matthew for sharing your knowledge, always so didactically. You know... I find the distinction between a random variable as a function, and the actualization into concrete values after an experiment a bit blurry when a well-defined experiment (tossing the coin) is expressed, as in this case, with subindices to signify multiple individual tosses. This is convenient and probably necessary (e.g. time series), but it is as though one was re-defining the function.
Comment: @AntoniParellada I'm not sure I fully follow? How does indexing the random variables seem to redefine them?
Comment: Or rather, it may seem as though each index refers to an individual outcome. Don't sweat it... If it doesn't resonate, it's just me as a hobbyist.


What is the highest Perception DC in each WotC-published adventure?

Question: I'm building a character and one of the pillars of his abilities should be a high passive perception. I've found enough ways to boost this that I highly doubt I need to take all of them, so I'd like to know what the highest perception DC is in each WotC-published adventure (otherwise spoiler-free) so I can avoid a "win more" level of effort towards this goal.
Comment: You are on the wrong internet site to make that demand, Kerrick.  Once you post it, you don't own it anymore. It becomes a part of the library which any of the SE stacks is.  We all curate that library with our inputs.
Comment: @Kerrick As well put by Korvin, you don't get to opt out of a particular user interacting on your posts. If you are experiencing rudeness/harassment from a user please flag it, though we're going to need more than "this particular user has interacted with my post".  I'd hope this gonna be the end of it on this question, though I implore you to reach out where-ever the actual perceived harassment has occurred.
Comment: If you are really using this information in a build it would probably be a good idea to understand the expected character level for each check. I am not sure if that is too big an update to the question though, or if you are bothered about it.
Answer: This is a response to the original version of the question, which was concerned with achieving a high enough passive Perception to meet all Perception DCs given in various adventures.
Frame challenge: The static DCs aren't the thing to worry about
The highest possible passive Perception you might need is not likely to be the fixed DCs, but rather, the Stealth checks made by opponents in ambush or hiding during combat. Even if the highest static Perception DC is 20, if the adventure includes an ambush by a monster with +6 Stealth (e.g. a CR 1/4 Goblin or CR 1 Bugbear; the Goblin can even Hide as a bonus action), you might need a passive Perception as high as 26 to detect them if they roll a Nat 20 on their check (ties default to not hidden, so you wouldn't need a 27). Sure, a Nat 20 is unlikely, but if they have any source of advantage (e.g. dim light, light fog, or any other form of lightly obscuring effect), the average natural roll is 13.825, plus whatever their modifier is, so many of your opponents will be able to semi-reliably exceed DC 20 (often significantly) if conditions favor them.
As you level, enemies will have higher Stealth modifiers as well; they generally don't progress as fast as a PC can progress (Expertise in Perception is hard to match), but it does go up, e.g.

Shadow Demon (CR 4): +7 Stealth (can Hide as bonus action in dim light/darkness)
Drow Elite Warrior (CR 5): +10 Stealth
Invisible Stalker (CR 6): +10 Stealth, and naturally invisible, so they can Hide in plain sight without needing cover
The Shadow Dragon template grants the base dragon the equivalent of Stealth Expertise and allows them to Hide as a bonus action; for example, from Wyrmling to Ancient Black Shadow Dragon, the Stealth modifier grows from +6 to +16

And that's just a sampling from the core Monster Manual. There are even better Stealth modifiers for some monsters you're less likely to fight (e.g. multiple fae creatures in the CR 1 and below range outclass Goblins and Bugbears), but that's the sort of thing you need to consider.
Point is, if you're trying to be Dr. Sees All, you can't just get passive Perception to X and be guaranteed you won't miss anything.
Comment: @SeriousBri Done, thanks
Comment: Love it! This is my favorite kind of frame challenge.
Comment: @Kerrick a frame challenge answer like this probably means you should roll back to the original question, otherwise it looks odd to those who don't look at the history.
Answer:

Adventure
Highest DC for Perception in Adventure
Notes

Baldur's Gate: Descent into Avernus
DC 15
1 in ch. 1, 1 in ch. 2, 2 in ch. 3

Curse of Strahd
DC 20
1 in ch. 1, 3 in ch. 4, 1 in ch. 13

Waterdeep: Dragon Heist
DC 20
2 in ch.4

A note on methodology for anyone that wants to pitch in: Starting in the first chapter of an adventure book on D&D Beyond, ctrl+f and Wisdom (Perception) will allow you to quickly navigate through the adventure's checks.
Comment: Getting it started with a community wiki answer.
Answer: Many players would consider this a form of cheating.
I am generally quite averse to the sort of answer I am about to give here, and bearing in mind that this site affirms a plurality of playstyles, we should observe that cheating is not a playstyle, and this sort of upfront investigation is something that many players and DMs, myself included, would consider to be a form of cheating. This question is asking us to read ahead in the adventures to provide you with information that you would not have without just reading ahead in whatever adventure you are playing. You are trying to optimally circumvent an adventure's challenges via game mechanics during character creation. This is something that I would consider to be a breach of trust, both as a player and a DM. As a player, I would feel it were unfair if I knew another player had read ahead in the adventure and used that knowledge to make more optimal decisions during character creation. As a DM, if I found out that you tailor-made your character to things you shouldn't know about, I would almost certianly ask you to build a new character, and may consider asking you to no longer be a part of that game.
Don't rob your future self of creative roleplaying opportunities.
One of the things that makes roleplaying games so fun is that they aren't videogames: there is no "right" way to complete a task. You are trying to find the least amount of effort required to auto-win a type of task, so that you can auto-win others as well. If that's the way you want to play the game, that's fine (as long as you do it without cheating), but please consider that you are robbing yourself of the opportunity to find more creative ways to resolve the adventure's tasks by leveraging high numbers on the game's mechanics. For me, one of the most rewarding aspects of D&D is solving problems despite the mechanical shortcomings of my character. You play the way you want, but at least consider these things when deciding how you want to play.


LOTR: TTT - Where was Fangorn Forest filmed?

Question: The scene I am thinking of is in Isengard when Saruman is ordering the forest to be burned. The forest is on the edge of the mountain.
Answer: http://www.virtualoceania.net/newzealand/culture/lotr/

Fangorn Forest and Nen Hithoel
Lake Te AnauThe Mavora Lakes was the location for Fangorn Forest and Nen Hithoel. The lakes are situated off the Te Anau Highway pass Mossburn or you can take an unpaved road near Te Anau which takes about 45 minutes by car. Just before the turn off to Mavora Lakes, you will see the Fangorn Forest to your left. The township of Te Anau is the gateway to to the spectacular Fiordland National Park.

An independent confirmation:

Fangorn Forest edge:
Mavora Lakes
Aragorn, Legolas and Gimli follow Merry and Pippin's trail from the mound of burnt orc bodies left by Eomer's Riders of Rohan.

In addition, Isengard itself was filmed here:

Isengard Gardens and the Orc Tree
Harcourt Park on the Akatarawa Road in Upper Hutt about 20 minutes from Wellington City was the location for Isengard Gardens and the Orc Tree. The Akatarawa Road cuts through the Rimutaka Mountains.

One more bonus location:

Fords of Isen
Lake Pukaki Kaitoke Regional Park was the location for Rivendale and the Fords of Isen. Kaitoke is north of Upper Hutt near Wellington. The park is sign posted on SH2 and offers BBQ areas. The position of Rivendale is sign posted at the entrance of the park. You can see the Fords of Isen from a bridge near the car park.
Comment: @cable - there's no guarantee that it was NOT special effects. I found no references to indicate either way.
Comment: So you're saying that Fangorn Forest at that point was Te Anau, not special effects?
Comment: http://www.cs.technion.ac.il/~gabik/Travels/NewZealand/LOTR/slides/17-Isengard.html seems to be the hill I was looking at. I will have to go back and look, though. I now think that it was most likely not special effects.
Answer: To add to DVK's answer, they also produced an artificial forest within the studio, complete with real leaves, soil, rocks, some trees (I forget if they were all artificial) and even the occasional insect (the Weta) that followed the leaves. They often contructed a back up studio version for real locations in case of elements out of their control.
My source for this is the Appendices of the LoTR Movies. I would recommend watching these if you are interested in the making of the series.


Anime about a girl that is saved from a strange life form in a forest by a man

Question: I watched an anime once about a girl with brown hair. She met a man in a forest that saved her from a strange life form. That man ends up being her soulmate from another time line. I believe they was reincarnations of gods? I think the man was tall with black hair? I also believe he had powers that relate to destruction or fire?
Comment: Please edit your question and try to answer the questions [here](https://scifi.meta.stackexchange.com/a/11875/21351)
Answer: Could it be Origin Spirit of the past ?

The story (from what I remember) is a girl waking up from hypersleep,  she lived in our near future. She awakes in a far away future, where apocalypse came and nature took its rights back. She meets a boy that becomes her soulmate, and is capable of fusing with a nature spirit to save her.
(I saw it a long time ago, sorry if it's not that exactly)
Answer: Have you looked for a anime movie called Mononoke? It is also about reincarnated gods in a forest. Even if it is not what you are looking for, it is a recommendation of mine. One of the best anime movies i've ever seen.
Comment: At the moment this is a recommendation rather than an answer to the question. Could you [edit] to reword it as an answer and explain how it matches the OPs description?
Comment: I've seen *Princess Mononoke* and I don't believe it matches. Prince Ashitaka has powers relating to his curse but they're not destruction or fire-related, and while there are gods, I don't recall there being any indication that Mononoke and Ashitaka themselves are reincarnations of gods.
Comment: By Mononoke did you mean [*Princess Mononoke*](https://en.wikipedia.org/wiki/Princess_Mononoke)?
Comment: Yes , *Princes Mononoke , i'm sorry.


Is there any material available whose strength changes with an input stimulus, say current or magnetic field etc?

Question: Is there any material available whose strength can be controlled by varying an input stimulus like current flowing through the material or magnetic field without actually deteriorating the material itself? We know with temperature material strength changes but that is not a stable solution as the material itself degrades for appreciable change in strength.
Comment: Is the strength mean its elasticity?
Answer: There are polymeres, that change size or shape when stimulated by an electric field They are called Electroactive Polymers. Those materials are used (among others) to create artificial muscles.
Depending on what you want to achieve, they might be the right solution. Another solution could be to use a bag of iron powder and an electro magnet. If there is no magnetic field, the powder in the bag is loose and the system has low strenght. If a magnetic field of sufficient strength is applied, the powder starts to clump together and form a realtively stiff shape.
It's a fairly low tec solution but depending on the use case might be just waht's needed.
A magnetic powder clutch uses a variant of this principle. They were among other places used in IBM tape drives and Curious Marc has a wonderful video where he repairs such a clutch for a tape drive in a museam.
Comment: I am looking for something that has the same strength as steel under unstimulated conditions and goes to higher strength (maybe equalling the strength of steel of a larger cross-section) under the application of the stimulus.
Comment: @rkn please put that information into your question. Be as specific as possible in your questions so others don't waste time trying to answer something you're not interested in.
Comment: Thanks for the suggestion.
Answer: If strength means elasticity, I am going out on a long shot here:
EuRu$_2$P$_2$ and EuPd$_2$Si$_2$ under go a valence transition at some combination of pressure and temperature, for EuRu$_2$P$_2$
(https://doi.org/10.1016/j.jallcom.2021.158753)
,this is in the GPa range. This valence transition is in turn accompanied by a change in the a)magnetic order
b) elastic constants
https://pubs.acs.org/doi/abs/10.1021/acs.cgd.2c00475
so at least near the phase transitions you can definitely influence the elastic constants of these two materials using magnetic fields. In fact EuRu$_2$P$_2$ may even exhibit critical elasticity! (https://journals.aps.org/prl/abstract/10.1103/PhysRevLett.115.025703) to read up on critical elasticity
Comment: Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer).
Comment: I am looking for something that has the same strength as steel under unstimulated conditions and goes to higher strength (maybe equalling the strength of steel of a larger cross-section) under the application of the stimulus.
Answer: Electromagnetic locks might be a solution.


postfix: Show destination port for incoming connection in the logs

Question: I have Postfix listening on several ports for incoming mail.  E.g. ports 25 and 587.  I'd like to see in the logs the destination port of each incoming connection.
Answer: Use syslog_name in the smtpd options in /etc/postfix/master.cf.  This changes the name of the process in the standard-format log line.  The default is postfix/smtpd.  So to change it for the submission line (port 587), add this to the options:
-o syslog_name=postfix-submission

Note that the default process name is kept as a prefix.  Don't include "/smtpd" because this is added automatically.
Example default log line:
Sep 28 01:22:28 XXXXXX postfix/smtpd[11737]: connect from unknown[22.214.171.124]

Example "augmented" log line:
Sep 28 01:22:28 XXXXXX postfix-submission/smtpd[11737]: connect from unknown[22.214.171.124]

Warning: Do not change this option in /etc/postfix/main.cf, or it will change the output for all of Postfix's listening ports.


What do you call the servants who follow a king during a procession?

Question: What do you call the servants who follow a king during a procession? I am pretty sure there was a word for it, but I don't know if the word only applied to the people in a procession or not.
Comment: Entourage - a group of people surrounding an important person.
Comment: I assume you mean 'officials in the King's service' rather than 'domestic servants'. Ram's suggestion is a good one; you could use 'courtiers' in a historical context. It might depend on what kind of procession it was.
Comment: Attendants? But servants wouldn't normally be in a royal procession; that was reserved for other nobles (including the king's family) and sometimes clerics, in order of rank.
Answer: One term is retinue for which Lexico has

retinue
NOUN
A group of advisers, assistants, or others accompanying an important person.
The scale and precise role of the retinue of officers and servants who travelled with a prince has not been established.
Comment: This word is not exclusive to a *procession* or to a *king*. Can you clarify the question, please.


How to hook text messages in iphone

Question: I'm trying to develope an iphone application which helps for filtering spam text messages.
But I don't know how to hook text messages.
Please help me.
Answer: You just can't. iOS API as of today does not give you access to text messages. Not to read them, not to send them, not to filter them. Sorry to break you bad news.
If your phone is jailbroken, you could do it by accessing the SQLITE database where text messages are stored. But you definitely won't be able to distribute your application through AppStore.
Answer: In order to do what you are trying to do, you are going to need to hook into the API. It is possible to jailbreak an iPhone without it being identified as 'jail-broken', though it's a bit tricky and a single screw up can deem your HID jailbroken for life.
If you're attempting to make a program usable for any user, this is not the method you want to use.
The only way this would be possible, is through a virus.

How to hook text messages in iphone


What is the native narrow string encoding on Windows?

Question: The Subversion API has a number of functions for converting from "natively-encoded" strings to strings that are encoded in UTF-8. My question is: what is this native encoding on Windows? Does it depend on locale?
Comment: There is only one native encoding in Windows: UTF-16. But probably that documentation rather talks about the legacy MBCS encoding.
Answer: "Natively encoded" strings are strings written in whatever code page the user is using. That is, they are numbers that are translated to the appropriate glyphs based on the correct code page. Assuming the file was saved that way and not as a UTF-8 file.
This is a candidate question for Joel's article on Unicode.
Specifically:

Eventually this OEM free-for-all got
  codified in the ANSI standard. In the
  ANSI standard, everybody agreed on
  what to do below 128, which was pretty
  much the same as ASCII, but there were
  lots of different ways to handle the
  characters from 128 and on up,
  depending on where you lived. These
  different systems were called code
  pages. So for example in Israel DOS
  used a code page called 862, while
  Greek users used 737. They were the
  same below 128 but different from 128
  up, where all the funny letters
  resided. The national versions of
  MS-DOS had dozens of these code pages,
  handling everything from English to
  Icelandic and they even had a few
  "multilingual" code pages that could
  do Esperanto and Galician on the same
  computer! Wow! But getting, say,
  Hebrew and Greek on the same computer
  was a complete impossibility unless
  you wrote your own custom program that
  displayed everything using bitmapped
  graphics, because Hebrew and Greek
  required different code pages with
  different interpretations of the high
  numbers.
Answer: Windows 1252. Jukka Korpela has an excellent page on character encodings, with an extensive discussion of the Windows character set.
Comment: Excellent page indeed! I don't think I could ever want a more detailed and comprehensive explanation of character encodings.
Comment: that page is nice but not as detailed as the Unicode standard. For example, it makes no distinction between abstract and encoded characters, or between encoding forms and encoding schemes.
Answer: From the header svn_string.h you can see that the relevant svn_strings are just plain old const char* + a length element.
I would guess that the "natively encoded" svn strings are interpreted according to your system locale (I do not know this for sure, but this is the convention). On Windows 7 you can check your locale by selecting "Start-->Control Panel-->Region and Language-->Administrative-->Change system locale" where any value of English would probably entail the character encoding Windows 1252. However, a different system locale, for example Hebrew (Israel), would entail a different character encoding (Windows 1255 for the case of Hebrew).
Answer: Sadly the MSVC version of the C library does not support UTF-8 and uses legacy codepages only, but cygwin provides a UTF-8 locale as part of its emulation layer. If your svn is built on cygwin, you should be able to use UTF-8 just fine.
Comment: Only the standard functions use the legacy encoding, many non-standard extensions use UTF-16.
Comment: Or an `#ifdef` that calls the UTF-16 functions on Windows and the standard functions elsewhere.


Assigning values to rows based on keywords

Question: My bank statement has a description column which tells me where I spent the money or where I got it from. Based on this information I fill a column manually to be able to catagroize these expenses - all the transactions of client A, all the transactions of amazon.
this is based on me reading the description and finding a keyword.
Can I automate this process.
I tried with a extremely long formula - if(search("amazon",a1),"Amazon"), elseif(search ........
It's too complex and prone to errors.
There would be around 20-30 catagories.
Comment: Look up `LOOKUP()`.
Comment: @scott: "amazon" is probably not the whole content of the cell, so I don't think `LOOKUP()` would work here. @Shitij: I'm not aware of any built in function, you probably would need VBA if you really want to get rid of the long formula.
Comment: What is the formula? We can't troubleshoot it unless you show us.. Also - try using mint.com
Comment: @MátéJuhász: Your guess is as good as mine until the OP provides us with more information.  … (Cont'd)
Comment: (Cont'd) …  OP: I deliberately wrote a very short comment six hours ago because of the vagueness of the information you posted in your question.  Please [edit] your question to show us some data.  It doesn't need to be a year's worth of data, or even a month's worth, or even 20 categories — or even *any **real*** data — just show a few rows of data that are representative of your real data.  See [here](http://superuser.com/q/889201/150988) and [here](http://superuser.com/q/892744/150988) for examples of how to post spreadsheet data in Super User without using screenshots.  … (Cont'd)
Comment: (Cont'd) …  But also, it is not our objective to be a code-writing service.  We're willing to *help* you with your problem, but that implies (as Raystafarian said) that we will be better able to help you if you show us what you've done so far.  It doesn't have to be a solution for all 20⁺ categories; just enough to illustrate what you're trying to do (e.g., three to five categories).  … (Cont'd)
Comment: possible duplicate of [MS Excel – assigning "categories" based on keywords](http://superuser.com/q/785128/150988).
Answer: The approach of your formula can get you close, but as you say, long formulas are hard to troubleshoot, and with SEARCH, you have to deal with error values when the target isn't found.  If you break the problem down into individual keywords, there is an easy solution.  Here is a version and I'll step through what I did.

Column A contains the descriptions.  Column B is the keyword found for the transaction.  Columns starting with C are for your keyword targets, one target as a column heading in each column.  As a one-time task, fill in your keywords.  You can add a keyword at any time and just copy the formulas into the new column from an adjacent column.
The formula in C2 can be copied across and down.  Each cell in these keyword columns looks for that column's keyword in that row's description.  The formula I used in C2 is:
<code>=IF(ISERROR(SEARCH(C$1,$A2)),"",C$1)
</code>
This searches for the target keyword and displays it if found.  Otherwise, it displays a blank.  If your target word is not always the keyword, you can replace the last parameter in the formula with the keyword.  However, you will then not be able to simply copy the formula into any cell without modification.
The formula in B2 is:
<code>=C2 & D2 & E2 &...
</code>
(Spaces added for readability.)  If you think you might add more keywords, you can concatenate some extra columns into the formula initially.  This just concatenates the results of the keyword searches for the row.  There should be only one matching keyword, so stringing that together with a bunch of blanks for the other keywords gives you the matching keyword for the transaction.  If none of the keywords match, the cell will be blank.  If you add more keywords later, make sure B2 contains the new column references and then copy that down the column.
Aesthetics
If you don't want to see the keyword helper columns, you can hide them or stick them in an area that is out of view.
If you want to do everything in a single formula that doesn't rely on helper columns, just start with this approach to build the formula.  This allows you to create a single, short formula, and copy it to other columns and rows to verify that everything is working.  At that point, you can turn B2 into a comprehensive formula by substitution.
In B2, replace the C2 reference with the formula in C2 (copy and paste the formula in C2, except the equal sign, to replace the C2 cell reference), and repeat for each cell reference.  Now you have a formula that refers to just a list of keywords (which you could move to a vertical list if you want).
If you don't want even the keyword list, replace the keyword cell references with the actual keywords.  You will then have a completely self-contained formula.  When B2 is to your liking, copy it down the column.


Tarski's Theorem and Gödel's Second Incompleteness Theorem

Question: I (think) that I once heard it said that from Tarski's Theorem on the undecidability of truth, Gödel's Second Incompleteness Theorem follows. Is this right?
Answer: Tarski's theorem is on the unDEFINability of truth, but yes, Goedel's results follow (and in some sense are the same thing): provability (in some particular system of interest) is definable, therefore truth cannot match provability, therefore (supposing the system of interest is consistent, and therefore sound for the relevant sentences) there is a sentence which is true but not provable. This is the first completeness theorem.
What would it mean for a predicate T to actually define truth? Just that T(s) and s are equivalent for each sentence s. Thus, Tarski's undefinability theorem tells us more specifically that, for any definable T, there is some sentence G such that T(G) and G are equivalent to each other's negation. The above is just what happens when we take T to define provability; we thus see more specifically that incompleteness arises from a sentence G equivalent to the negation of its provability, which is therefore (supposing the system of interest is consistent) true but not provable.
One can then argue, in the usual way, that our proof of the first incompleteness theorem, suitably internalized in the system of interest, yields the second incompleteness theorem. [Our argument shows that the consistency of the system of interest entails the non-provability of G. But this conclusion is just what it means for G to be true! Thus, if the system of interest proves its own consistency, it proves G, contra its own consistency.]
Comment: But all that really shows is that some of the ideas used in Tarski's result are also used in a proof of the 2nd incompleteness theorem, which is a pretty modest claim.

The question, I take it, is rather whether given the truth of Tarski's theorem, the truth of the 2nd incompleteness theorem follows by some clever argument or other.
Comment: I've modified the word of the second paragraph to alleviate this concern. The second incompleteness theorem follows from the simultaneous "external" and "internal" truth of Tarski's theorem (by which I mean, the fact that Tarski's theorem is both true and provable (or, just as well, true inside every model)).
Comment: Well, one caveat: One needs that Tarski's result is constructive enough that we have not just "For every T, for every model, there is a G such that...", but in fact "For every T, there is a G such that for every model...". But, basically, were Tarski's result phrased as strongly as its proof actually warranted, it would give us everything.
Answer: I got some very exciting new ideas from the reply of Sridhar Ramesh, for which I am very thankful. The question has a negative answer:
(i) Tarski's Undefinability Theorem is not about any (particular) theory; it says that there is no formula $\Psi(x)$ such that for any formula $\varphi$ can $\mathbb{N}\models \varphi \leftrightarrow \Psi(\overline{\varphi})$ hold. While Gödel's Second Incompleteness Theorem is about some theory $T$ for which
(A) $\qquad T\nvdash\textsf{Con}(T)$
holds for some "consistency predicate" $\textsf{Con}(-)$.
(ii) To make more sense of the question, let me formalize Tarski's Undefinability Theorem for a theory $T$ as follows:
(B) $\qquad \neg \exists \Psi\; \forall \varphi\; T\vdash \varphi\leftrightarrow \Psi(\overline{\varphi})$
Now, "some clever argument or other" should prove (B)$\Longrightarrow$(A), right?
The negative answer comes from a result of Dan E. Willard (http://dx.doi.org/10.1016/j.apal.2005.12.010 or http://www.jstor.org/stable/2695030) that for some (very weak and) consistent theory $S$ we can have $S\vdash\textsf{Con}(S)$.
Proof (of our claim):
 So, the theory $S$ does not satisfy (A). But it satisfies (B) since for an extension of $S$, say $\textsf{PA}$, the Diagonal Lemma holds. Thus, for any $\Psi(x)$ there exists some $\theta$ such that $\textsf{PA}\vdash \theta\leftrightarrow\neg\Psi(\overline{\theta})$ or equivalently $\textsf{PA}\vdash\neg\big[\theta\leftrightarrow\Psi(\overline{\theta})\big]$ (noting the propositional tautology $\neg(p\leftrightarrow q)\equiv p\leftrightarrow\neg q$) which implies that $S\nvdash\theta\leftrightarrow\Psi(\overline{\theta})$.
$\texttt{QED}$
Therefore, Tarski's Undefinability Theorem does not imply Gödel's Second Incompleteness Theorem. Even though, as was noted in the replies, there are some vivid connections between the two. For some computational connections I invite consulting (https://arxiv.org/abs/1509.00164).


advice for google api use as a CDN for phoneGap application

Question: I would like to create a phoneGap application which will browse through items on a google drive account. The idea is that I can push out new documents to users of the application when necessary.
I don't want the users to have to authenticate against the account ideally the application will automatically authenticate.

Is it possible to create a google drive account in which access is not publicly available but available for all users of the phoneGap application and the administrator?
Can you think of a better way to achieve my desired result?

Thanks
Answer:
You can't
Try Google App Engine,  Google Cloud Storage


win32api.dll Will Not Install

Question: I am trying to start a Buildbot Buildslave on a Windows XP virtual machine:
<code>python buildbot start .

ImportError: No module named win32api.
</code>
Google tells me that win32api is win32api.dll.  I downloaded the file from www.dll-files.com and followed the guide found on that site (http://www.dll-files.com/unzip.php).  When I try to run regvr32 win32api.dll, it tells me that the specified module could not be found.
tl;dr - Where do I put win32api.dll so Windows will install it?  Am I trying to use the wrong file?  (using python version 2.6)
Comment: You may want to try this question over at http://serverfault.com
Answer: win32api belongs Python for Windows extensions, Aka Pywn32.
have u installed it?
Answer: Install ActivePython (http://www.activestate.com/activepython/) - it's a Python distro that comes bundled with the Windows dlls.  It's what everyone else does.

win32api.dll Will Not Install


Does the EMH have perfect recall?

Question: Does the Emergency Medical Hologram have (or could have) perfect recall of past events, as Commander Data apparently does, or are there indeed limits to his "memory"?
Comment: I would speculate there is minimal incentive to design an EMH to have the kind of recall Data has as it has a job to do and any memories would be towards that job.  I speculate it would remember patient details but not the room's wall color for example.  Further the first EMH holomatrix was notoriously only meant for short term use - so implicitly that means dont waste memory.  See https://scifi.stackexchange.com/questions/27396/why-doesnt-the-doctors-matrix-degrade-again .  Voyager the series where the most interesting character is a hologram.
Comment: It's not enough to formulate an answer, but I think he has. He was programmed with extensive medical knowledge, there is no point in programming him with a feature that allows him forgetting. We never see him looking up medical files  or any information that he already learned before. And the times where he does forget something are critical plot points.
Answer: There are two episodes that suggest that the Doctor's does not have perfect recall.
Season 3 episode 4 The Swarm deals with the doctor's program degrading due to the memories and subroutines added over the 2 years it's been active. His program deteriorates and he cannot even remember who Kes is.
But there is a later episode that deals more significantly with the doctor's memory, season 5 episode 11 Latent Image, in which the doctor's memory of an event 18 months ago has been blocked from him. There is a scene that tells us a bit about how the doctor's memory works.
It comes after he has realised that he performed a procedure on Harry Kim that he does not remember, and goes to Seven for help. Someone erases his memory of the last hour in an attempt to keep him from investigating further:

EMH: Let's have a look at my program.
Seven: A deletion in your short term memory buffer.
EMH: Our chat in Astrometrics never got filed. That's why I can't remember it.

So this tells us that his program has a short term memory buffer that is processed in some way and then "filed" into long term storage.
Later in the same scene, Seven helps him access his memories of the event:

Seven: I've isolated your memory files from stardate 50979.
EMH: They weren't deleted?
Seven: No.
EMH: Then why can't I remember them?
Seven: The program was rewritten to deny you access to those memories. I'm trying to restore them.

And later:

Seven: The files are difficult to localise. The memories will be out of sequence.

This scene establishes that his long term memory is not optimised for "replay", but, similar to our own memory, optimised for some other form of recall. The changes in his recall during The Swarm reinforce this idea.
Compare this to Data, whose memory was unable to be altered, even by himself, in the TNG episode S4E14 Clues, and thus he had to be ordered to keep a secret.
Comment: Hmmmm. If anything these two sequences suggest that his memory is usually perfect, except on a couple of occasions (one, a technical fault, the other an intentional deletion) where it isn't.
Comment: @Valorum The dialog explicitly says that the memories are not deleted, but they are not perfect. We see them and they are blurry and have bad colour.
Comment: @Valorum as I said, seven says they weren't deleted, only the permissions were changed.
Comment: Because of the deletion and restoration process, presumably
Comment: We do see them better later in the episode once B'Elanna reversed the block, so I will concede he does have "good" recall, but I guess the key to my point was that he organises his memory like we do: "we had a surprise party", "I took pictures", and only with greater effort does he remember the rest. And still only (as far as we see), the key scenes.
Comment: Well, there was an actual block put in place to remove his access to those memories. She circumvents it somehow
Comment: I would go as far as suggesting that Latent Image is proof that The Doctor usually _has_ perfect recall. Once he realizes some memories are missing, he is deeply concerned and asks Seven to check his systems, at no point does someone suggest that he might have simply forgotten. On the other hand, the operation he performed on Kim would not be something one easily forgets.
Comment: @Philipp Yeah, I take it as he's concerned he doesn't remember doing it, not that he's worried he doesn't know how Janeway had her hair that day.

Does the EMH have perfect recall?


What happens if I pick up an upgrade for a fully upgraded item?

Question: Let's say I play on a stage that starts with passive items on the map (Clover, Spinach, etc). Typically if you already have an item, finding the same item on the map will upgrade it to the next level.
What happens if I pick up an item upgrade after I've already upgraded the item to max level? Does the item upgrade beyond max level?
Answer: It "upgrades" the item, but it doesn't gain any more stats.


How can I disable new plugin and theme install, but allow updates?

Question: I've already tried the DISALLOW_FILE_MODS constant, but it disables plugin updates as well, which is not what I need. I need automatic theme and plugin update checking, and the ability to install the found updates to work in the Wordpress dashboard, but disallow new plugin and theme installs. How could I achieve this?
Comment: seems that creating an user and give him a different role would do the same, the administrators will have access, but other roles will not. its an alternative
Comment: Well yes, that is true. However, I would like to disable it for everyone, so even the admins couldn't install new plugins (I was thinking about the reprecussions of an admin area intrusion, and was thinking of a way to protect the site's files, so the intruder couldn't just install a file manager plugin and access sensitive files, such as the WP-Config file and such).
Comment: I think wp doesnt have such a thing, the most alike is what you already have with the disallow_file_mods.  But I could be wrong,  But there are others ways to achieve such a task, one is for example activate by default disallow_file_mods, create a cron job that runs 1 time each day or whatever, that deactivates disallow_file_mods, do the updates if any, and activate disallow_file_mods again.
Comment: update, create a super admin, that way only super admin can have those functionalities, check point 6 of this page  https://themeisle.com/blog/wordpress-user-roles/
Answer: This would probably make a job done, although using die is not the pretty way
<code>add_filter( 'upgrader_package_options', function( $options ) {

    if (
        isset( $options['hook_extra']['action'] ) &&
        $options['hook_extra']['action'] === 'install' &&
        isset( $options['hook_extra']['type'] ) &&
        in_array( $options['hook_extra']['type'], [ 'plugin', 'theme' ]
    ) {
        die('Plugins & Themes installation disabled!');
    }

    return $options;
} );
</code>


Find base in isosceles triangle

Question:
If angle alpha and side $b$ is known in this isosceles triangle, how long is the base $a$? I know this is very basic but I don't know any trigonometry so I don't really know what to do here.
Answer: Law of Sines......
$$\frac{a}{\sin\alpha} = \frac{b}{\sin(\frac{180 - \alpha}{2})}$$
$$a = \frac{b\cdot \sin\alpha}{\sin(\frac{180 - \alpha}{2})}$$
Answer: hint: $a^2 = b^2+b^2-2b^2\cos(\alpha)$ is known as the law of cosine in a triangle. Can you take it from here?

Find base in isosceles triangle


what could be the reason for very inacurate strava tracks of my bike excursions?

Question: I'm not sure if this is the right "forum" to ask the question but I'll try anyway.
So I'm using strava to log my biking excursions. Recently I have noticed that my recorded tracks are very "ugly" - lots of straight lines across several roads and buildings, lots of zigzags and loops.
What could be the reason? I thought that some apps are disturbing gps but the same happens when I kill all the apps. GPS track from my garmin, if both are turned on at the same time, looks much better.
it was not so before, btw.
Comment: Slightly offtopic, right. but bicycles.stackexchange.com is rather silent anyway so why not put some life in it.
Comment: Kind-of not on topic because its a question about GPS performance, rather than bicycles.  That said, what other uses are there for bike GPS units?
Comment: totally - takes a while to brew up a complete answer hence the lag.   You can also check in with [chat] for more informal times.
Answer: GPS units have variable performance for a number of reasons

Bad satellite position - Simply put, all the satellites transmit "bing!" at exactly the same time.  Your received deals with the differences in the time between reception of each signal.  So the most accurate point will be calculated if the satellites are distributed over the sky.  If all the visible satellites are in the same quarter of the sky, you get a larger possible location, or one with more possible variance.
Urban Valley, regular valley and multipath - if you're in an area with big hills, or tall buildings, or sometimes even very wet trees the signal can be attenuated, slowed, or reflected.  If the signal is slowed by even 0.001% then that's 22 kilometres of variance, (assuming satellite orbits at 22,000 km.  This can be mitigated somewhat by putting your phone in a toptube bag rather than deep in your pocket.

I carry a folded thermal space blanket made of foil when on long rides, and it messes with the phone terribly if they're in the same pocket.  Doesn't matter which is on top.  Also if your clothing has a metallic weave this can interfere with transmission reception too.

Fudge factor - Some GPS, and the Strava app are known for "slewing" results.  They've used the last N seconds as an input to calculate the next point.

Here's an example.  Notice entering on the left at fairly decent speed, probably high 30 km/h.  The path slews out into the river, and then winds its way back to the road.   I have seen far worse at this corner but this was all I could find in a brief search.  I do this segment frequently.

Broken antenna/aerial(s)  Your GPS is on a bike and suffers a lot of vibration.  If the signal is not received clearly then that could add delays which impact processing, or could drop one/some of the time pulses from the satellites increasing error
Lagged CPU.  Historically a GPS was a standalone device with dedicated chips for calculating everything.  If you're using a smartphone, there will be dedicated GPU circuitry but it will still need time on the main CPU to do stuff.  If its busy playing songs and whatever else, then that could also delay the processing of point data.
Your speed - If you're going fast enough, minor discrepancies can multiply out to larger errors.   50 km/h is almost 14 metres per second, so a second's lag puts you out by 14 metres.

I'm not familiar with Garmins, but they're single purpose units and are unlikely to suffer CPU starvation. (other than garmin's rear-facing radar whatsits.)
That's all the causes I can think up now.

Solutions
The best solution is to tweak your strava recording using SNAP (strava needs a polish)   However I've noticed this site has become increasingly harder to get to.
When it does work, you can load your activity from strava, push the lines back onto the road, and it will create you a GPX file to download.
Then you upload that fixed file to strava and once its looking better you can delete the original ride.  Do it in that order for safety, I've lost one big ride by getting it wrong.
Second option is to use your garmin to to the logging and leave the cellphone recording as a backup, deleting the worst once once you return home.
Comment: wow, that was one quality answer, thank you. can you see this very activity? https://www.strava.com/activities/1126261828?fb_action_ids=297063874093267&fb_action_types=fitness.bikes the track seems to be all over the place and there are even sections where the gps did not work. this hasn't happened before  and I keep the gps exactly as I used to, in the side pocket of my shorts so my guess was that some apps disturb the gps unit/events. it would be easiest to use the  Garmin gps but frankly it would be too much effort for those short rides to/from work.
Comment: @Greg: The software (apps) running on your phone have no effect on the GPS. It's much more likely to be a physical effect, either poor satellite position, atmospheric effects, vegetation (trees), buildings, your own body position relative to satellites, etc.
Comment: @GregHewgill I'm drawing a distinction between the GPS components (which are dedicated and should not lag) vs the device's CPU which can certainly lag when loaded, or when on low power mode.


what is the difference between HSV and CIE-Lab color space?

Question: when do we use HSV color space and when do we use CIE-Lab color space?
Answer: HSV has very intuitive axes (hue, saturation, value) and is useful for manual choosing and adjustment of colors. It is defined in relation to an arbitrary RGB color space.
In CIELAB, only the lightness (L) axis has an intuitive meaning (in my opinion). Euclidean distances in CIELAB coordinates approximate perceptual distances of colors, which can be useful. It is defined in relation to the CIE 1931 XYZ color space, given a white point.


What is the licence in salesforce and How company buy licence?

Question:
we have few licenses as shown in picture. I would like to know that for every company is having same licenses or different licenses? and What is 60000 for partner community login. Is that limit of 60000 users or what? Can anyone please make me understand about this licenses.
Comment: I recommend you reach out to your Salesforce Account Executive who can help explain what each license means and how you got them if you're looking for a definitive answer specific to your org.
Answer: There are a wide range of different licence types available for Salesforce, see the documentation here. As you have Saleforce Communities, the details of the licence types for that product are here.
The number of licences available to any specific Salesforce customer will vary on what they have purchased and will not be the same across different customers orgs. The types of licence required depend on how the Saleforce customer uses the system.
The licence purchase is through usually dealing with an Account Executive working for Salesforce when you have the numbers of licences shown. Small companies may end up purchasing directly just using a credit card, but that would normally be for a very low number of licences where no discounting may apply, e.g. 5 users on Group Edition.
The 60,000 Customer Community Login is the number of unique logins that users on that licence type can make per month. It is not restrictive of the amount of logins per user on that licence type make each month, but is an upper limit to the number that can be made by the Community members without incurring any additional licencing fees for the Salesforce Org.
Your organisation has 1,411 actual Salesforce user licences, with 20 remaining to be allocated to users.
Comment: Hi Dave good Knowledge share. Can you please make me understand about this line:                                                                                The number of licences available to any specific Salesforce customer will vary on what they have purchased and will not be the same across different customers orgs
Comment: Each customer's instance of Salesforce is called an organisation or Org. When a customer buys licences from Salesforce there is no fixed number, instead they will buy as many of the different types of licences they need, e.g as a consultant I have worked for a customer that had 15,000 Saleforce licences and other customers that had maybe 100 or 200 licences depending on how big the company was and how many people within it needed to use Salesforce.
Comment: It means you're paying for 20 seats which you are not currently using. That's actually a lot in most orgs that I have worked on.
Comment: @AdrianLarson They are also paying for 1284 UNUSED Force.com licenses (Salesforce Platform)


Can't manipulate linked or appended objects that were made with 2.79 inside 2.8

Question: I'm using Blender 2.8 and my friend works in 2.79. Whenever I append or link his files there is something like a locked logo front of those objects and I can't manipulate these. What could be the issue?
Answer: The symbols resembling a chain link in front of an Object stand for linked objects.
They definitely only appear if you link to an object instead of appending it.
If you append an object, you create a local copy of an object from another .blend file, which can be manipulated like any other object. If you link to an object in another .blend file, you can't manipulate this linked object, instead you have to manipulate it in the original file.
To create a local copy of a linked object, click on the object with the chain link symbol, click on "Object" in the "Properties" panel, then hit the chain link symbol on the right side of the Object selector dropdown.
Answer: This is an issue with recent builds of 2.8. If you append files from 2.7 layers/collections come in linked. If your able to open the original 2.7 file in 2.8 (make a backup first) save it, then append it into the new project and it will be localised.
Comment: Never happened to me and I append objects from 2.7x files on a daily basis. The official bug tracker shows [one issue](https://developer.blender.org/T35608), that turned out to be a problem on the user's side.


Alternate links in a multilingual site Drupal 7

Question: I have a multilingual website currently on localhost. I want to add the alternate links to each page like this: rel="alternate" hreflang="x".
How do i do that?
What about the canonical urls? I have already installed SEO suite module enabled.
Answer: You can use Meta Tags module for canonical links.

The Meta tags module allows you to automatically provide structured
  metadata, aka "meta tags", about your website. In the context of
  search engine optimization, when people refer to meta tags, they are
  usually referring to the meta description tag and the meta keywords
  tag that may help improve the rankings and display of your site in
  search engine results.
Meta tags have additional uses like the Open Graph Protocol used by
  Facebook, specifying the canonical location of content across multiple
  URLs or domains.
Comment: Hmm i see. Would i have to add the canonical url my self for each page and for each language? or this can be done automatically? Maybe using the clean urls i have already set up ?
Answer: You might want to try Menu attributes module.

This simple module allows you to specify some additional attributes for menu items such as id, name, class, style, and rel.
  The module currently allows you to set the following attributes for each menu item:
   - Id
   - Name
   - Target
   - Rel
   - Class
   - Style
   - Accesskey
Comment: What happens when my main menu is a translatable block with my html code inside???
Answer: The Internationalization contributions module says that it adds the rel="alternative" hreflang="x" to multilingual pages:

Internationalization contributions is a set of modules that are add ons for Internationalization module to provide compatibility with other contributed modules or some other features.


Android In-App Billing - Repurchase after reinstallation of app

Question: My application uses the Android Market In-App Billing Support and it works well for the first purchase done by user. However, when an user removes and installs the app again, when he/she purchases the same item, the Market keeps showing the following statement: "Your order is processing, your item will be available in a few minutes". And the Response Code is "RESULT_SERVICE_UNAVAILABLE". What can I do to handle this?
Answer: After studying the Android Developer - In-app Billing http://developer.android.com/guide/market/billing/billing_overview.html, there is an operation called RESTORE_TRANSACTIONS, call it at the first launch of application solves the problem.


Blender video in which a scene is first untextured and then shows the textures as the video goes on

Question: I would like to make a video from a scene I have done in Blender. I would like these scene to first be renderend without textures, and then, as the video moves on, to get the textures on...Do you know how this could be done?
Comment: If the textures all fade in at the same time just render the scene twice, one with textures, one without, then fade between them in composition. Otherwise animate all materials one by one.
Answer: A simple version of this effect could be created using a combination of render layers and keyed compositing effects:

Step 1
Under the Render Layers panel, enable AO and Environment passes.

Step 2
In the Compositer, create this node setup and keyframe the Mix node property highlighted below to go from 1 to 0 over the course of your animation, or over whatever period you want your materials to appear.

For very complex scenes you may need to play around with rendering more layers and mixing in different nodes, but this method should get you most of the way there for a basic fade in effect.


What does "could use a friend" mean?

Question: I heard this word on some TV show and i have been trying to find its meaning(but they weren't of help much). Could someone please tell me ?
Comment: I could use a coffee.
Answer: If someone "could use a friend", it means that they would benefit from having the close companionship of friendship, oftentimes because they are perceived as being lonely or going through a difficult time. It is usually a kindhearted, well-meaning (nice) thing to say about someone.
Answer: I interpret it as the person saying the phrase, would like some help in the given situation and would regard the person giving a helping hand as a friend.
Answer: The phrase could use a friend means that the described person is either in trouble or very unhappy.
When stated about oneself, it is usually a gentle request for a show of affection or support, often addressed to someone who is already the friend of the speaker. It is sometimes akin to the phrase I could use a hug (meaning please comfort me).
When addressed to another, it is an acknowledgement of the difficulties or sadness of the person addressed. It is usually meant to imply and I will be that friend.
Occasionally, it is intended to startle someone into changing their tone and accepting help. Your self-destructive and alienating behavior is going to wreck your life! You could use a friend. Stop pushing me away.
In the phrase, the verb use means have use for. In a sense, it does mean take advantage of but only in the sense of utilize rather than take unfair advantage of.
Answer: "could use a X" is an American English idiom
"could do with a X" is the the British version
They both mean "would benefit from [having] an X".

"I could use a friend"
"I could do with a friend"
"I would benefit from [having] a friend.

The above are all equivalent.

What does "could use a friend" mean?


"Contemporaneously" vs "concurrently" - difference in legal verbiage?

Question: What's the difference in meaning between "contemporaneously" and "concurrently" in contract verbiage in general?  An example could be "the following contracts are being executed contemporaneously" vs "the following contracts are being executed concurrently".
Comment: There is not enough context in this question to know if there might be a difference. Most legal questions are fact rich.
Comment: @ohwilleke I was actually interested in the difference in meaning in those two words in general.  I'll revise my question to better reflect.
Comment: @g491 if you are looking for English meanings rather than legal ones, English se is a better fit.
Comment: @g491 If you are looking for different legal meanings of two words in general you are likely to lead yourself astray. The assumption that words have a general legal meaning that applies in the same way in different contexts is frequently incorrect. It is unsound to assume that because you know what a word means in one sentence of even the same document that it will mean the same thing in a different sentence of that document (e.g. the  word "significantly" has two different meanings when used in different sentences in Treas. Reg. 1.83-1 that was the subject to a recent question in this forum).
Answer: Absent some explicit definition to the contrary, words in contracts assume their conventional connotations.
Absent any particular context, contemporaneous is synonymous with concurrent.  However, one could argue that the latter connotes more strict simultaneity.
A good contract would specify its terms to avoid any such ambiguity.


General Relativity, Newtonian Mechanics and Gravity

Question: Gravity is considered to be the curvature of spacetime by Einstein and a force by Newton. So are both notions equally correct or Einstein's perspective completely replaced Newton's thinking?
Comment: This is answered on this site at https://physics.stackexchange.com/q/57495/
Comment: If your question is whether General Relativity is an improvement or simply a reformulation of Newtonian Gravity, the answer is: it is an improvement. These two give different predictions and Newtonian gravity was disproved experimentally implying the superiority of GR.
Comment: Related/possible duplicates: https://physics.stackexchange.com/q/61899/50583, https://physics.stackexchange.com/q/219306/50583
Answer: Einstein's relativity is more correct than Newton's equations for gravity. There are details to keep in mind, though.
For weak sources of gravity, like Earth, General Relativity and Newton's equations give indistinguishable answers. NASA scientists used Newton's equations to send astronauts to the moon and probes beyond our solar system because the math is easier and the answers the equations give are different by an immeasurable amounts.
However, as gravity gets stronger, like when you get close to a star, General Relativity and Newtonian equations start to give different answers. At the beginning of the 20th century, Newton's equations were failing to predict the motion of the planet Mercury. Einstein's relativity equations make correct predictions.
This often happens in science. Newton's equations are not wrong. It's better to say that we have found limits to where they give correct results. General Relativity has a larger area where it gives answers that agree with our measurements. At the moment, we have not found limits where General Relativity stops giving correct answers.
Comment: So is it true that we can consider gravity both as a force and a curvature in spacetime? What really confuses me is the validity of the saying that gravity is not a force.
Comment: @Benjamin It depends on what people mean by "force." In one sense, gravity is a force because it causes acceleration. In another sense, the acceleration is somewhat fictional because an object in a gravitational field is traveling in a straight line through curved space-time. This is similar to the way walking in a straight line on Earth will eventually cause you to walk in a circle due to the Earth being spherical. This is what people mean by "gravity is not a force." It's also fine to think of gravity as a force transmitted by curving space-time.
Comment: @Benjamin We say that gravity isn't a force because gravity affects everything equally (compare this with electromagnetism, which only affects charges/currents). So if you are in free-fall, you will not actually feel a force on you, because gravity affects all your particles equally. On the other hand, when you are sitting on your chair, you feel a force on your buttocks, even though you are "unaccelerating". So would it not be more natural to consider a freely falling object unaccelerated?

Obviously, there are more mathematical answers to this, but as heuristics go, this is it.
Comment: @Uldreth It depends on context whether calling gravity a force is useful. Gravity causes measurable acceleration, so the word "force" is very appropriate. On the other hand, the deeper you get into fundamental physics, the more the idea of force becomes less useful. Relativity is not unique in this since Quantum Mechanics also has little use for "force" as a quantity. When particles don't have definite positions or momenta, acceleration (and thus force) becomes a fuzzy concept.
Answer: Newton's Theory of Gravity, just stated it as a force that exists, and explained how the force works but it never interpreted the origin of Gravity. He himself stated in his paper of Philosophia Naturalis Principa Mathematica that he does not know the origin of the gravitational force and leaved the task to the reader.
Einstein's General Theory of Relativity explained the origins of the Gravitational Force along with its precise working. The General Theory of Relativity is considered to be more accurate and correct and it has replaced Newton's theory of gravity because of the following reasons :-
1.) Newtons's Theory of Gravity basically explained the nature of the gravitational force but nevertheless stated its origin.
2.) Newton's Theory of Gravity was not able to explain the precession of the perihelion of Mercury, that is the periodic shift in the perihelion (lowest point of an orbit) of Mercury.
3.) According to Newton's perspective, the force of gravity acting between two bodies is directly proportional to the product of their masses and inversely proportional to the distance between them squared. So according to his theory, since light particles - photons are massless, they would not be affected by a gravitational field. But General Relativity proved that the path of a light ray is influenced by a Gravitational Field, this phenomenon is known as - Gravitational Lensing.
4.) All the Newton's theories are based on absolute space and time, whereas both the Special and General Theory of Relativity are based on relative space and time.
Due to these reasons, General Relativity is used for making precise and accurate calculations. However, Newton's Theory of Gravity is still used in some cases for weak sources of gravity like Earth because of its simplicity.


Calculating luck as a factor in board games?

Question: I´m hooked on Carcassonne but feel that after you learned the basic tactics it is mostly a game of luck. This has me wondering, when designing board games how would one go about calculating the luck factor? Are there any known good methods?
Comment: @Pat, drawing the right tile is a huge random factor in Carcassonne.  Of course you do your best to plan for it and mitigate it, but sometimes you just aren't going to get the tiles you need, and others will.  Carcassonne is a good example of a game that takes skill, but still has a high luck factor, opposed to a game like Puerto Rico that has a small luck factor.
Comment: I´m just saying there is rarely more than one optimal way to play your turn making your luck with the tiles kind of important at least when meeting equally skilled opponents. Maybe not for the when and where you should take fields but for most of the game.
Comment: There isn't a whole lot of luck in Carcassonne.  That, or I'm incredibly lucky.  I played the xbox version for several months and I was able to maintain over a 8 to 1 win/loss ratio.  Some folks manage even better.
Comment: @Lance for me, more luck means a higher chance of a lower quality opponent winning the game.  In my experience, this just isn't the case with Carcassonne.  This sounds like ideal fodder for it's own question rather than thread-jacking the OP any further though!
Comment: @Pat, I was just trying to point out that Carcassonne was a good example of what he was trying to measure.
Comment: I agree with Pat: I don't think there's a whole lot of luck in Carcassonne.  Yes, there's a major element of adapting to the tiles you draw, and if you draw nothing but road tiles forever you are unlikely to do well, but in the overwhelming majority of games the luck factor will average out between the players, and skill will determine who gets the upper hand.  Carcassonne has no more luck in it than any other game involving dice or random draws from a deck, IMO.
Comment: "after you've learned the basic tactics it is mostly a game of luck" is false.  "rarely more than one optimal way to play your turn" is less so, but you might as well say that there is only one correct move for each position in chess (there is, but good luck finding it).  To me, the first sentence of your question is inflammatory and perhaps not even needed to ask your question.
Answer: A reasonable empirical measure of luck is the probability that the best player can beat a good player in a given game.  So if you can get data about a large player population (I have done this with Race for the Galaxy), you can get an implicit measure by looking at the Elo rating difference at various skill percentiles.
On the other hand, this only tells you about the amount of luck in the game as a whole, not in a particular game.
Comment: Thanks! That was exactly the kind of answer I was looking for.
Answer: It would depend on the game.  Certainly for games that involve rolling dice, the probability of certain events happening can be easily calculated.  For games where dice are thrown or cards or drawn, there are some games where some outcomes can really change the flow of the game.  There are also games where random events actually have minimal affect on the outcome of the game.
Monopoly has a strong aspect of how luck factors into the game.  Where you pieces land, makes or breaks the game for you.  In Settlers of Catan, luck exists, but good players do their best to maximize their odds so the luck of the dice is less of a factor for them.  Chess, is completely a game of skill, there is no random factors are all.
For games that combine luck and skill, experienced players make moves that are likely to benefit them the most.  Thus, their skill helps them depend less on luck to win.  That doesn't mean bad luck still can't keep them from winning.  You have to analyze how randomness created by dice or card drawing helps or hinders players when designing the game in order to determine how much luck affects the game.
There are books on the subject of game design you can look into and an entire course on the subject matter at one university.
Some books I've seen on the subject are:

The Art of Game Design: A Deck of Lenses
Challenges for Game Designers
A Theory of Fun for Game Design
Answer: Rob's answer on using a large population database to evaluate the roll of luck is absolutely the way to go--assuming this data is available. But the question also seems interested in how to evaluate the roll of luck during game design, when no such data is available. In this context, the question is about how to model or simulate a game to test the mechanics. The answer depends on the type of game being evaluated.
Trial and Error
The least satisfying method because it's so slow. Basically this means play testing to see if something rewards luck too much (based on the designers desire for luck/skill balance). Unfortunately since we're talking about luck you might have to play a lot to get a good feel for the balance. Basically you're generating Rob's database yourself. :(
Statistical analysis
This is more appropriate for modeling portions of games that involve dice--or a similar randomization mechanism. In a game like Arkham Horror (or even Risk) it's easy to test out individual battles (or write a computer program to do it) and quantify the impact of a change to the rules. This might be useful for making sure a custom Arkham character isn't too weak or too powerful, or if you were experimenting with a different Risk combat engine.
The easiest to implement computer-based method is Monte Carlo simulation: use a random number generator to simulate a single battle, then re-seed the generator and run it again; repeat tons of time and calculate statistics on the results. Such tools exist for games like Axis and Allies, but if you were savvy you could code one up yourself.
Situational analysis
I think I just made this term up, but it's supposed to explain looking at a certain game situation and determining to what extent luck could influence the outcome--usually by bounding the best and worst case outcomes and seeing how large the variance is. Similarly, you can evaluate the extent to which the player can tailor their game play to insulate themselves from risk. Games that enable or encourage conservative play and that ultimately reward the more skilled player can greatly reduce the influence of luck.
For example, in a game of Axis and Allies where multiple aircraft are being shot at by an AA gun, the swing between best- and worst-case outcomes is huge: its varies from total annihilation to no damage. Obviously in this case luck can play a huge factor. That said, an experienced player over-matched verses their opponent probably shouldn't use aircraft to attack territories defended with AA guns. They know if they wait it out they'll win eventually and shouldn't take the risk of letting the dice even the playing field.
Answer: Back to the root of your question, one way I've found to diminish the role of luck in Carcassonne is to have all players draw a "hand" of tiles (3 to 5 seems to work well), and then on each turn you draw a tile and then play any tile from your hand. When there are no more tiles to draw at the end of the game, you just play one of the tiles from your hand until everyone has played all of their tiles.
Luck will still play a part, but this gives the players a little more control over which tile they play at a given time.
Some other variants that affect the luck factor in Carcassonne are to deal out all of the tiles at the beginning of the game, play with the remaining tiles face up so you can choose exactly the tile you want as long as it's still available, or begin the game with a "draft" where you pick the tiles you want to have during the game.