Powershell script to backup folders older than 7 days

Question: I have a folder X:/EmpInfo that contains many different folders. Each of these folders contains about 5-10 files.
I need to backup folders that have a modified date newer than 7 days ago. That is, modified would mean new files were added to the folder or an existing file was modified.
Example: If I run it today (11/08), it'll backup all folders in X:/EmpInfo with a modification date of 11/01 to current time today (when the script is run). It should move the entire folder, not just the modified files. Overwrite any existing folders.
Comment: @Gabe - what have you tried so far?
Comment: I did try creating a batch script but I'm mostly lost. I figured it'd be easier in Powershell. Not sure, this isn't my area of expertise.
Answer: It might not be "something for real like Perl" but PowerShell can handle that pretty easily.  This should get you started:
<code>$newFolders = dir X:\EmpInfo | ? {$_.PSIsContainer} | ? {$_.LastWriteTime -gt (Get-Date).AddDays(-7)}
$newFolders | % { copy $_.FullName  c:\temp\archive -Recurse -Force}
</code>
Have fun with the pipeline!
Answer: My answer is a combination of the answers of MrKWatkins and Eric Nicholson. In your question you clarify that what you actually want is to copy directories where new files were added or existing files were copied. The behaviour of the last modification date for the containing directory will be different on different filesystems:

NTFS:  On an NTFS file system, the modified date of a folder DOES change if the contents of the folder change.
FAT:  On a FAT file system, the modified date of a folder does not change if the contents of the folder change.

Description of NTFS date and time stamps for files and folders
Therefore ideally we should first test the filesystem type of the source directory before deciding on how to determine what directories to copy:
<code>function Copy-ModifiedSubdirectory {
  param ($sourcefolder, $destinationfolder, [DateTime] $modifieddate)

  # Escaping source folder for use in wmi query
  $escapedsourcefolder = $sourcefolder -replace "\\","\\"

  # Determine what filesystem our folder is on
  $FSName = (get-wmiobject -query "select FSName from CIM_Directory where name = '$escapedsourcefolder'").FSName

  if ($FSName -eq "NTFS") # The Eric Nicholson way
  {
    $FoldersToCopy = get-childitem $sourcefolder | where {$_.PSIsContainer} | where {$_.LastWriteTime -ge $modifieddate}
  }
  elseif ($FSName -eq "FAT32") # The MrKWatkins way
  {
    $FoldersToCopy = get-childitem $sourcefolder | where {$_.PSIsContainer} | ? { Get-ChildItem $($_.fullname) -Recurse | ? { $_.LastWriteTime -ge $modifieddate } }
  }
  else
  {
    Write-Error "Unable to Copy: File System of $sourcefolder is unknown"
  }

  # Actual copy
  $FoldersToCopy | % { copy $_.FullName $destinationfolder -Recurse -Force}
}
</code>
To use the function:
<code>$sevendaysago = ((get-date).adddays(-7))
copy-modifiedsubdirectory  X:\EmpInfo Y:\Archive $sevendaysago
</code>
Comment: Did not know that difference between NTFS/FAT32.
Comment: Is the 'write-host $folderstocopy' some debugging code that got left behind?
Comment: @MrKWatkins Yes, I just removed it.
Answer: Here is a rough and ready script to get you started. I'm sure there are better ways to a lot of this...
<code>$sevenDaysAgo = (Get-Date).AddDays(-7);

# Get the directories in X:\EmpInfo.
$directories = Get-ChildItem . | Where-Object { $_.PSIsContainer };

# Loop through the directories.
foreach($directory in $directories)
{
    # Check in the directory for a file within the last seven days.
    if (Get-ChildItem .\UnitTests -Recurse | Where-Object { $_.LastWriteTime -ge $sevenDaysAgo })
    {
        $directory
    }
}
</code>


Was the 2008 financial crisis caused more by the US subprime mortgage lending or more by an international energy and oil pricing crisis?

Question: I recently read The Big Short by Michael Lewis in which the depiction of the role of subprime mortgage lending in the US and then run away speculation on CDOs are shown to be the central and primary cause of the 2008 financial crisis.  Then today I watched a lecture called The Third Industrial Revolution (https://www.youtube.com/watch?v=QX3M8Ka9vUA) by Jeremy Rifkin in which he portrays the 2008 subprime mortgage crash as being an "aftershock" of the real financial "earthquake" which was international oil prices hitting $147/barrel 6 months prior to the 2008 crisis.  He continues this analogy by insisting global policy makers are, when they bail out the banks who invested in subprime mortgages or change investing laws, "trying to address the aftershock rather than the earthquake."  I have never heard this view of the situation and am ignorant as to how international oil pricing functions and affects the world economy.  How do people in the know square the relative significance of the US subprime mortgage investment bubble with this international oil price situation when trying to label the root causes of the 2008 global financial crisis?
Comment: There have been many accounts of the Global Financial Crisis. Most give at most a passing mention of the role of oil prices (rightly so in my opinion). It may have been an aggravating factor but not much more than that.
Answer: It's worth differentiating between the financial crisis of 2007-2009, and the recession that began in December 2007.
The financial crisis was indeed caused by a run on wholesale funding that was precipitated by significant losses on real estate, both subprime and otherwise. As noted in the first link, stresses in wholesale funding first appeared in August 2007. At that time, oil prices (WTI) were still \$70-\$80/barrel.
Losses to financial institutions during the crisis that can reasonably be linked to oil are limited, and the timing is all wrong, so it's not credible to suggest that the increase in oil prices would have led to a financial crisis absent the actual mechanism (run on wholesale funding, significant losses on real estate assets) by which the financial crisis occurred.
That said, it's certainly likely that oil prices contributed to the recession that began in December 2007, as documented by James Hamilton, though the severity of this recession was in large part due to the fact that there was a financial crisis:

Recessions associated with financial crises have been more severe and
  longer lasting than recessions associated with other shocks.
  Recoveries from such recessions have been typically slower, associated
  with weak domestic demand and tight credit conditions.

Thus, oil prices are likely to have contributed to pushing the economy into recession, which may have worsened credit losses, fueling the stresses in the financial sector, but it's not credible to claim that they were a primary factor in causing the financial crisis, as compared to the structural vulnerabilities relating to wholesale funding and securitized assets.
Comment: [Was the financial crash of 2008 caused by top graduates of the American Ivy Leagues working at wall street banks?](https://economics.stackexchange.com/questions/46001/was-the-financial-crash-of-2008-caused-by-top-graduates-of-the-american-ivy-leag)
Answer: Decrease in oil discovery & production itself linked to 'peak' oil levels having been reached globally is what caused it.
Its getting much harder to get oil and we are producing less of it, whilst population levels keep increasing, and citizens globally keep aiming for and reaching for much higher levels of energy consumption.
This crisis was therefore only a precursor to much worse environmental, civil, economic and geopolitical crisis to come, as we are unable to extract more and more fossil fuels from the earth, but are instead extracting less and less, and are consequently incapable of replacing those types of fuel sources with greener alternatives, due to instrinsic limitations attached to renewables for example.
Our economies and our populations will have to learn to operate with less energy, and learn to live in a state of constant decreasing economic output (technical recessions).
I doubt we will have robots and driveless cars in this scenario, and anticipate we will instead have to increase our manual workforce across essential industries such as agriculture, manufacturing. Whilst service industries will mostly collapse due to reduced transformative-type industries requiring services, and individuals will evade cities to get closer to food sources (the cost of transporting resources will explode).
This is only a short list of what is to come.
Watch out for the signals that demonstrate that certain individuals, organisations, and countries - who have understood all this - are preparing for it.
And let's ask yourselves the question...are we preparing too ?
Comment: https://yearbook.enerdata.net/crude-oil/world-production-statistics.html, global oil production increased steadily in the last 40 years, ignoring the drop caused by COVID.
Comment: https://www.energypolicy.columbia.edu/research/report/oil-intensity-curiously-steady-decline-oil-gdp#:~:text=By%202019%2C%20oil%20consumption%20per,number%20giving%20pause%20for%20thought). and oil intensity, the use of oil per GDP declines significantly. The recession in 2008 was almost certainly not caused because of oil


Get the Monitor sink of the current active output in PulseAudio

Question: I am trying to record desktop audio using the simple API from libpulse. Audio playback works fine with the simple API, but what I need to do is:
Find the correct Monitor sink for the current active output to use it with pa_simple_new as dev.
Anyone some points I could check? E.g. enumerating devices?
Answer: The monitor of a device is "device.monitor" (e.g. "Nullmodule01" -> "Nullmodule01.monitor"). Just append ".monitor" to the device name.


Look back at/on/to

Question: I need to know what is the difference between "look back at", "look back on" and "look back to". I have understood that they all mean "to remember" so I don't know where I should use each one.
Answer: The differences in meaning are subtle but real. "Look back on" suggests rumination or reflection, and often has a hint of summing things up or even of nostalgia.

As I look back on our organization's 125-year history...

"Look back to" is often used in contexts involving trying to figure out how to handle some situation where the notion is to find ideas, guidance, or inspiration by considering how a similar situation was handled in the past.

In preparing his inaugural address, Barack Obama looked back to those of Lincoln, FDR, and JFK.

"Look back at" sort of straddles the other two.
Answer: Look back at the picture before you answer the question.
To see the answer, look back on the screen.
For me, I think it's good to look back to the past.
Answer: To 'Look back' is to remember, but it also carries a sense of remembering for a purpose - to examine the past.
I don't think that the 'at/on/to' part is as important to understand than what it means to look back.  They would simply be used to complete your thought and as a matter of style.
For example:

When I look back to the way I behaved that fateful day, The regret becomes overwhelming.
When I look back on my actions that fateful day, The regret becomes overwhelming.
When I look back at what I did that fateful day, The regret becomes overwhelming.

Look back at/on/to


Can government agencies trace if I mine bitcoin?

Question: I live in a country where the government has strict rules against using bitcoin. in fact, they are trying to find out the citizens who are related to bitcoin. I was just wondering if they can catch me if I just mine bitcoin without doing any transaction? if yes then I wanted to know if there are any alternatives which can make me untraceable.
Answer: Data linking is the only way there is any question of privacy. When you transact with Bitcoin, the goods or service you order will need to have a delivery address. Also, if you send your BTC to any merchant, service or, an exchange that has your personal data there will be a presumption that the sender was the owner of the inputs used and is the person that they have records for. There is no known way around this.
Apart from that question which exists for all cryptocurrencies, you may wish to consider implementing some of the configuration for privacy from here for your mining setup. Sound advice is, do not break the law.
Answer: If you are going to mine any significant amount, you'll consume a substantial amount of energy, which may be noticed.  For instance, if I were to install a single AntMiner S9 at my home, my electricity consumption would go up about 400%.  If the government runs your electric company or can monitor their records, this sort of thing could prompt an investigation.
Answer: When a new block is mined, newly generated coins are placed in whichever address they are mined to. If you do not transact from the mining address to somewhere like an exchange that has your personally identifying information, there is no way to know who mined the coins based on the address alone.
As there is no easy way to determine who actually mined a block, and who is just relaying it to other nodes, you might suspected of mining simply by connecting to nodes in your area. Depending on the monitoring done by your government, connecting to any node in the world that your government is aware of may lead to suspicion.


Best practice to synchronize button states

Question: I would like to know if there is some recommended way to synchronize some buttons states in ios. For example I have 5 buttons that i want to use as a filter on my data - they should all work in sync. So when one is selected i want the other other ones unselected. I could simply unselect all buttons and reselect only the one i want each time i select a button. Is there a better way to achieve this? I was thinking to take a look to the Key Value Observing mechanism too but any advice is very welcome here.
Answer: One answer given by GeneralMike to a different question on deselecting all buttons
was to use UISegmentedControl or UISwitches.  While that was a different situation, it might be plausible for your requirements.


Applying to MPhil in Advanced Computer Science at the University of Cambridge

Question: Is participating in the international competitive programming contests and achieving an excellence degree graduation compensation for the low rank of your university when you apply to MPhil in Advanced Computer Science at the University of Cambridge?
Comment: The admissions department will answer that definitively, we can but guess it may help...
Answer: The admission requirements and international equivalents make no mention of university rank. (Disclaimer: I haven't checked every single country in the international equivalents). You can check for yourself whether your degree results meet the required standard.
I haven't found specific statistics for CS, but the overall ratio of applications to admissions for graduate study overall at Cambridge is about 6 to 1. (The ratio of applications to conditional offers is about 3 to 1, but it sounds as though you have your results already and would get an unconditional offer or a rejection). If you meet the basic requirements you could expect an interview.
The interview is where things like participating in Informatics Olympiads may be useful. If you've mentioned it in the application, you may get a question about it. But that kind of thing is more useful to undergraduate applicants than to graduates, unless you can show direct relevance (e.g. good results in undergrad-level security competitions, when you've mentioned in your application that you want to focus your studies on security topics). The reason that it's less useful for graduate applicants is that you will probably have done some kind of individual project in the final year of your undergraduate degree, and that project tells the interviewer more about your interests and abilities than Olympiad results.
Comment: Thank you for these details. I have another question about your answer: What is the best place to write about my individual project in the final year of my undergraduate degree (CV, application, portfolio, ... etc.), and where can I attach the report of this project?


What is the motivation for quaternions?

Question: I know imaginary numbers solve $x^2 +1=0$, but what is the motivation for quaternions?
Comment: Computer graphics. Hamilton was a visionary.
Comment: Frankly, after the complexes, the idea that solving equations is the primary motivation for number systems breaks down. You can be forgiven for thinking that since apparently that seems to be the primary motivation given in schools...
Comment: He wanted something that his students couldn't search on Wikipedia for their homework assignment.
Comment: @Asal: When the donkey claims something came from the horse's mouth, I'm not sure if that's a good thing. :-)
Comment: From the horse's mouth: http://www.maths.tcd.ie/pub/HistMath/People/Hamilton/Letters/BroomeBridge.html and http://www.maths.tcd.ie/pub/HistMath/People/Hamilton/QLetter/QLetter.pdf
Comment: Btw the related questions have good stuff to answer this. http://math.stackexchange.com/questions/821002/what-is-a-good-geometric-interpretation-of-quaternion-multiplication?rq=1
Answer: Hamilton (and Graves) wanted to generalize $\mathbb C$ - if viewed as $\mathbb R^2$ with a multiplication that turns it into a field with a multiplicative absolute value.  They were looking for something similar in $\mathbb{R}^n$ for $n>2$.  It turns out that Hamilton spent 13 years in vain with $n=3$ although it was essentially known since Diophantus that what he was looking for was impossible.  He finally figured out that he could succeed for $n=4$ if he gave up commutativity.
(This is a short summary of chapter 20 of Stillwell's wonderful "Mathematics and Its History".)
Comment: @metacompactness: "Multiplicative absolute value" above means that you want multiplication to be defined such that $|\mathbf x_1|\cdot|\mathbf x_2|=|\mathbf x_1{\color{red}\cdot}\mathbf x_2|$ holds for all $\mathbf x_i \in \mathbb{R}^3$ no matter how $\color{red}\cdot$ is defined.  So, if $(a_1,a_2,a_3){\color{red}\cdot}(b_1,b_2,b_3)$ where defined to be $(C_1,C_2,C_3)$ with the $C_i$ being arbitrary terms depending on the $a_i$ and $b_i$, then by squaring $(a_1^2+a_2^2+a_3^2)(b_1^2+b_2^2+b_3^2)=C_1^2+C_2^2+C_3^2$, but e.g. $15=(1^2+1^2+1^2)\cdot(0^2+1^2+2^2)$  is not the sum of three squares.
Comment: @Frunobulax does that argument really work? If the $C_i$ are truly arbitrary functions of the $a_i$ and $b_i$, then they don't necessarily have to be integers.
Comment: Just for information, if memory serves me correctly the last line (which is pretty illegible here) reads "...and carved it on a stone of this bridge".
Comment: Why $n=3$ isn't possible?
Comment: @metacompactness: Suppose each number was expressed as $a_0+a_1i+a_2j$. Then letting $ij=a_0+a_1i+a_2j$ and  multiplying on both sides by $i$ using field axioms shows that $j$ is a complex number. So unless we drop some of the field axioms we cannot get anything beyond complex numbers.
Comment: @echinodermata: I had used up all characters in my previous comment, so I couldn't be more precise... :)

You are right.  The idea was that the $C_i$ should be (to quote Stillwell) "combinations of the $a_i$ and $b_i$ with integer coefficients".
Comment: @Shahab and frunobulax Thanks, I should do some geometric algebra soon.
Answer: With the complex numbers in hand, it's natural to wonder what other systems of numbers containing the real numbers one might have. Before constructing the quaternions, Hamilton tried in vain to construct a $3$-dimensional system; it turns out that this is impossible, and you can see a reproduction of Hamilton's own proof in this recent question: Why should I consider the components $j^2$ and $k^2$ to be $=-1$ in the search for quaternions?
In fact, if you require that your "number system" be a division algebra (over the real numbers), it turns out that there are just four such systems: the real numbers, the complex numbers, the quaternions, and the octonions, so each of these is quite special. John Baez' paper "The Octonions" is a superb starting place for exploring this circle of ideas.
(NB there are plenty of interesting "number systems containing the real numbers", i.e., finite-dimensional algebras over $\mathbb{R}$; in other words, division algebras are not the only interesting thing we can ask for.)
Comment: +1 Just feel like remarking that insisting on having a division algebra is not a problem at all, if you don't insist that it contains the reals. For example over rationals there are infinitely many non-isomorphic non-commutative division algebras of dimensions 4,9,16,25,... (any square will do) with center $\Bbb{Q}$. The problems begin when you combine the requirements of *division algebra* and *contains $\Bbb{R}$*.
Comment: @rscwieb: Class field theory includes results (Grunwald-Wang and Albert-Brauer-Hasse-Noether) telling that the division algebras over a number field are all *cyclic division algebras*. The structure of cyclic algebras as well as the condition for them to be division algebras together with examples are outlined in [Matt Emerton's answer](http://math.stackexchange.com/a/45065/11619) and an [answer by yours truly](http://math.stackexchange.com/a/45086/11619). I picked up this bit of theory from N.Jacobson's *Basic Algebra II*, chapter 8.
Comment: I'll point out that you can instead weaken the requirement of having a division algebra over the reals by asking for a composition algebra. Here we allow zero divisors in our rings, and we still require a quadratic form that respects multiplication, but we don't ask for it to be positive. What's interesting is that this weakening only allows for three more algebras over $\mathbb{R}$, namely, the split complex numbers, the split quaternions, and the split octonions, the lattermost of which has attracted a good deal of attention in the field of geometric structures in the last few years.
Comment: @JyrkiLahtonen Hmm that's interesting: can you point me toward consructions of these finite dimensional division algebras over $\Bbb Q$?  With all the finite *field* extensions of $\Bbb Q$ available, I guess I never sat down to think about the division ring extensions :)
Answer:
$\qquad\qquad\qquad\qquad\qquad$ What is the motivation for quaternions?

Hamilton knew that the complex numbers could be interpreted as points in a plane, and he was looking for a way to do the same for points in three-dimensional space. However, $[$he$]$ had been stuck on the problem of multiplication and division for a long time. He could not figure out how to calculate the quotient of the coordinates of two points in space.

$\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad$ — Quaternions: History

$\quad$ In $1843$, Hamilton knew that the complex numbers could be viewed as points in a plane and that they could be added and multiplied together using certain geometric operations. $~$ Hamilton sought to find a way to do the same for points in space. But $[$he$]$  had been stuck on defining the appropriate multiplication. According to a letter Hamilton wrote later to his son Archibald:

$\quad$ Every morning in the early part of October $1843$, on my coming down to breakfast, your brother William Edward and yourself used to ask me: "Well, Papa, can you multiply triples?" Whereto I was always obliged to reply, with a sad shake of the head, "No, I can only add and subtract them."

$\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\quad$ — History of Quaternions: Hamilton's Discovery
Answer: Two important applications come to mind:

They model rotations of the sphere, much like the complex numbers model rotations of the circle.
You can get the four squares theorem, that every integer $n$ can be represented as $n=a^2+b^2+c^2+d^2$ for some integers $a,b,c,d \geq 0$, using unique factorization-like properties of the quaternions. This has to do with thinking of the norm of a quaternion $N(a+bi+cj+dk):= (a+bi+cj+dk)(a-bi-cj-dk) = a^2+b^2+c^2+d^2$.
Similarly, you can prove that in any commutative ring $R$, if $a$
and $b$ are each the sum of four squares, then $ab$ is the sum of
four squares, using an algebraic identity that actually doesn't
involve the quaternions, but is completely absurd to discover except
by proving that for quaternions $N(\alpha\beta) =
    N(\alpha)N(\beta)$.

In short, they have both important geometric and algebraic properties, particularly at the intersection.
Answer: A modern motivation is to model 3D orientation and rotation in computer graphics. If you use the simple model of Euler angles, you may run into a problem: gimbal lock. Quaternions (and rotation matrices) avoid this.
Answer: Complex numbers do indeed enable us to solve certain previously unsolvable condition equations; but that is not the motivation for them. It is unfortunately common to confuse application with motivation.
Complex numbers extends the idea of quantity as algebraically-expressed-location to two dimensions after "negation" introduces it in one dimension.
The obvious next extension is to three dimensions; but alas, the same neat properties from one and two dimensions don't hold in three dimensions, as related by others above. That doesn't mean three dimensions is uninteresting; but just that this notational device for representation is less interesting.
Comment: Historically, complex numbers were discovered/invented in order to solve cubic equations.
Comment: Do you mean the historical motivation?  I would consider applications to be very motivating.
Comment: One, application is frequently motivation. Two, I don't understand the rest of this answer. What's quantity as algebraically-expressed-location to two dimensions after "negation"?
Comment: @djechlin My understanding is that the construction of natural numbers does not create the real line; integers must first be constructed such that positive quantities have additive inverses. After construction of the rationals and reals, the real number line contains positive quantities and negative quantities in a single dimension. The imaginary axis orthogonal to the real line adds a second dimension; both dimensions establish the [complex plane](https://en.wikipedia.org/wiki/Complex_plane).

What is the motivation for quaternions?


The number of prime factors of a natural number

Question: It seems to be true that OEIS sequences A001222 and A257091 are closely related. First one is the number of prime divisors of n counted with multiplicity. The second one is the logarithms to the base 5 of the denominators of the Dirichlet series of zeta(s)^(1/5). Actually first terms of these sequences satisfy A257091(n)-A001222(n)= 1 if n is a multiple of 32, and 0 otherwise. Is it true, obvious, known or somthing else?
Comment: What is the reason to choose $5$ as compared with A046644, A256689, A256691 etc?
Comment: The reason is very simple: A257091 coincide with A001222 in first 31 terms.
Answer: Robert Israel's guess is almost correct, actually for $n=\prod p_j^{e_j}$ we have
$$
A257091(n)−A001222(n)=\sum_j \nu_5(e_j!)=\sum_j \sum_{m=1}^{\infty} \lfloor e_j/5^m\rfloor
$$
(where $\nu_5(N)$ denotes the largest $k$ for which $5^k$ divides $N$).
Indeed, expanding as binomial each Euler multiple in $\zeta^{1/5}$  we get $$(1-p^{-s})^{-1/5}=\sum_{k=0}^\infty (-1)^k\binom{-1/5}k p^{-ks}.$$
Thus if $n=\prod p_i^{e_i}$, coefficient of $n^{-s}$ in $\zeta(s)^{1/5}$ equals $$\prod_j (-1)^{e_j}\binom{-1/5}{e_j}=\prod_{j}\frac{1(1+5)(1+2\cdot 5)\dots (1+(e_j-1)5)}{5^{e_j} e_j!}$$
This rational number have only 5's in the denominator (because for other prime $p$ we may replace $-1/5$ to some integer like $(p^{4n}-1)/5$ without changing $p$-adic valuation of all multiples $-1/5-t$, $t=0,1,\dots,e_j-1$.) And 5 arises in the power $\sum e_k$ plus exponent of 5 in $\prod e_j!$.
Answer: The first two exceptions to your rule:  $A257091(243) - A001222(243) = 6 - 5 = 1$ and $A257091(486) - A001222(486) = 7 - 6 = 1$, but $243$ and $486$ are not multiples of $32$.
EDIT: Of course $243 = 3^5$.  From computing the results up to $n=10000$, it
looks to me like if $n = \prod_{j} p_j^{e_j}$ is the prime factorization of $n$, $A257091(n) - A001222(n) = \sum_j \lfloor e_j/5 \rfloor$.
  Thus $7776 = 2^5 \cdot 3^5$ and
$A257091(7776) - A257091(7776) = 12 - 10 = 2$.


Impedance matching, don't reflections just happen somewhere else?

Question:
I understand that when I have a line transmitting a signal, it may be important depending on the length of the line and the wavelength of the signal to have matching impedances at the ends of the line to avoid reflections and standing waves. However, what I do not understand is why I wouldn't just have reflections before Zs and after ZL in the figure above, shouldn't "everything" in the circuits on both ends always be impedance matched?
Comment: Yes, in a real circuit (say a ~10 Ω CMOS output with an additional ~40 Ω resistor in series to match a 50 Ω microstrip), there will be reflections between the trace that connects the resistor and the CMOS chip. Thus, the design rule is to put the resistor as close to the output pin as possible, so that the distance is too short to matter and they can be seen as a lumped circuit as a whole.
Comment: Using ground symbols is misleading. Transmission lines have two conductors, and the characteristic impedance comes from the geometry of both conductors combined. There's nothing "after" ZL.
Answer:
what I do not understand is why I wouldn't just have reflections
before Zs and after ZL

You have to keep the length of those wires short compared to the wavelength of the signals used. By short, we usually mean that the load and source connection wires to the transmission line have a length less than one-tenth of the shortest wavelength.

I understand that when I have a line transmitting a signal, it may be
important depending on the length of the line and the wavelength of
the signal to have matching impedances at the ends of the line to
avoid reflections and standing waves.

You don't need to have matching impedances at both ends. Only one is necessary to maintain signal integrity. For instance if ZL's impedance matches the cable's Z0 then there won't be a reflection. Alternatively, if ZL is open circuit then there will be a reflection but, that can be totally absorbed by ZS if its impedance matches Z0. This latter situation is used by high-speed digital drivers all the time.
Comment: On [CSMA/CD](https://en.wikipedia.org/wiki/Carrier-sense_multiple_access_with_collision_detection) systems like coaxial Ethernet, you cannot afford reflections on either side of the line since transmission will be aborted if an incoming reflection.is detected.  And of course with anything but point-to-point connections, one-sided reflections will be problematic.  Even with non-sensing point-to-point connections, reflections may cause driver voltages/currents to be exceeded. resulting in clipping.
Comment: Yes, what I said applies to point-to-point data connections.
Answer: You are perhaps missing a not-oft-told, subtle aspect of schematic notation.
When we draw a schematic (that is, a pictorial connection of component pins and wires or nets), it is implied that traditional circuit analysis techniques (such as nodal analysis) can be used on it.
In practical cases, it may be less about analysis at all (good luck doing nodal analysis on some random unspecified IC), and just used to generate a connectivity map for drawing the PCB, or the wiring inside a machine.  And indeed in these cases, it may be that "nodes" are not in fact nodes, but transmission lines (PCB traces, cabling), and connections cannot be made randomly but must be in a specific order (which may simply be implied through experience, or can be described by various means).
In this case, it seems implied to me that there is some element in the middle, whose physical nature eludes traditional analysis and is therefore drawn as a graphical element (the transmission line) rather than an RLC component, meanwhile the circuits (or subcircuits if you like) at either end are expressed as schematic symbols and wiring, implying their suitability for analysis, at least locally if nothing else.
The critical thing is this: nodal analysis has no visibility of dimensionality, of physical size or the speed of light.  Such circuits/analyses are pointlike, or alternately the speed of light is infinite.
This is a direct contradiction to the transmission line in the middle, which has a linear dimension (length), and a speed of light (c * velocity factor).  At best, the two ends can be analyzed with nodal analysis, but the two sides together cannot, not at all frequencies anyway.  (It does reduce to the usual case at low frequencies, where the line can be converted into equivalent capacitance and/or inductance, and resistance.)

Related: are the ground symbols the same on the left and right sides?  Should they be?  Does it matter?  -- When would it matter?  Presumably, we should join all left-side grounds together, and all right-side grounds together, but something interesting happens when joining left and right: specifically, at frequencies where the shield conductor's resistance matters, we no longer have current returning strictly through the transmission line (signal and shield currents equal and opposite), but there is a common mode current (the sum of currents) that prefers to follow the zero-ohm path; or equivalently, there is a small voltage drop between left and right sides, at low frequencies.
Going back to practical cases -- critical length depends on frequency.  If we can make a length of transmission line shorter than the maximum wavelengths we're working with, it can be reduced to an equivalent L/C element, and we can use a pointlike analysis in the local area.  This is why it is suggested to place termination resistors adjacent to transmitter/receiver pins on the board, for example: the small transmission line stub between pin and resistor can be of negligible length.
Answer: In the diagram above, the source is probably an ideal voltage source, so the voltage at Vs is equal to Vs at all times, also Vs can source infinite amounts of current. This also means no reflections affect Vs, they might affect the voltage other side of Zs, but not Vs. So that is why you don't get reflections to Vs.
The series resistance Zs gives Vs some source resistance and matches it to the transmission line. It also makes Vs look more like a real world voltage source with limited current sourcing.

However what I do not understand is why I wouldn't just have
reflections before Zs and after ZL in the figure above, shouldn't
"everything" in the circuits on both ends always be impedance matched
?

You will get reflections at VL if Zl is not matched to Zc, that voltage is dependent on the ratio of Zc and Zl. You will also have reflections between Zs and Zc if they are not matched.
You can think of a transmission line kind of like a trough of water, if the impedance is matched the water is flat and you can send a wave from one end to the other. If you don't match impedances, it's like putting a bar in the water, the wave will reflect and possibly go over it to the other end but it will not be a perfect wave.
Also keep in mind that most real world transmission lines are lossy, so you lose some of the wave to heating and magnetic losses as it moves along.
Answer: Let's first understand how a transmission line behaves:
Signals travelling forward
If we look at one point in the transmission line, and one moment in time, then the local, momentary voltage Uf and current If behave like a Zc resistor, meaning Uf = Zc * If. And this travels forward along the line with some speed v, specific to the cable type.
Signals travelling backward
If we look at one point in the transmission line, and one moment in time, then the local, momentary voltage Ub and current Ib also behave like a Zc resistor, meaning Ub = Zc * Ib (only now the current is counted in the opposite orientation!). And this travels backward along the line with v.
Signal combinations
If you have both, forward and backward travelling signals, they simply superimpose by addition. BUT: voltages add normally, currents have to be subtracted because of their different orientation.
Reflection
A forward-travelling signal now reaches the end of the line, where there's a Zl load. This travelling signal has both its voltage and its current. And they both must match the load, otherwise we'd break Kirchhoff's laws. They match if the transmission lines impedance Zc and the load's impedance Zl are equal.
If they don't match, an element must be missing so we comply with Kirchhoff, and this missing element is a backward-travelling signal. If the load impedance isn't zero or infinite, the backward-travelling signal will have a lower amplitude than the original one. Some time later, the backward one will arrive at the beginning of the line, and again, depending on the impedance found there, it can either be completely consumed there or cause another reflection, and so on and on and on. But, as the amplitude decays with every reflection, after some of these bounces, the reflected signal can be neglected.
Short and long lines
In principle, there's no difference between shorter and longer transmission lines.
So, even a millimeter of wire is a transmission line. But if we assume e.g. 10 reflections to be enough for the signal to drop below the noise level, then it takes 10 times the 1-millimeter travelling time, being maybe 0.05 ns. If your signal doesn't have components above 1 GHz, so short a distortion won't matter. The behaviour is close enough to that of an ideal connection that we ignore the "connection line" properties.
But if your line is one meter, then ten reflections will mean 50 ns, and already signals with a few MHz will see a noticeable distortion.
Your circuit
You can model the Zl side as having a few short transmission lines, e.g. from the cable to the Zl resistor, or from the Zl resistor's ground connector to the cable's ground connector. But we assume them to be short enough so they don't matter.
Having a matched impedance at the source side is a safeguard against a non-perfect match of the load side. the source-side impedance matters for signals travelling backwards through the cable, and decides whether they are again reflected at this source end of the cable. If the load-side is perfectly matched, there will be no backward-travelling signals, and then it doesn't matter what would happen to a backward-travelling signal at the source end.
As a safeguard, it might help to improve signal quality, but it also costs half the power (one half lost in the Zs impedance, only the other half getting into the cable).
Answering your questions:

why I wouldn't just have reflections before Zs and after ZL

If the connections are long enough to matter, you'll have reflections, and you should be careful to design the connections with a geometry that provides a constant impedance over the whole connection length.
And that's the reason why designing a 1 MHz circuit, where you can treat everything shorter than a meter as irrelevant, is much easier than reaching multiple GHz.


How does Fourier transform convert from time domain to frequency domain

Question: I understand the formula, but what does it even mean for a Fourier transform to convert from time domain to frequency domain? And how is it doing so?
Even, in the field of image processing, why do they say that it converts from spatial to frequency domain?
Answer: The Fourier transform decomposes a signal into the weights of orthonormal basis functions: sines and cosines of different frequencies.
An analogy would be decomposing a vector in the x-y plane into its x and y components, which are the weights applied to the unit vectors along the x axis and y axis (the orthonormal basis vectors of the x-y plane).
Sinusoidal functions can be functions of space as well as time.  For image processing you're still decomposing the signal in terms of sines and cosines, the frequencies just correspond to changing in space vs changing in time.
Comment: As to how:  the integral of a product of two cosines or two sines of different frequency or of a product of sine and cosine goes to 0 (they are orthogonal in that sense).  When the frequencies match, you get a nonzero answer for the integral.  It is this property that plucks off the signed amplitude of that component at that frequency.  So the whole transform gives you signed amplitude for the sine and cosine components at all frequencies.  From that, treating the signed amplitudes at any one frequency as a complex number (the sine amplitude is imaginary) you can get phase and magnitude.
Comment: As for why frequency domain: sinusoidal functions are orthogonal in frequency (and 90 degree phase: sine vs cosine).  They are not strictly orthogonal in amplitude or in phase in general.  The orthogonality of sine vs cosine is reflected in the imaginary and real parts of the transform.
Comment: @ShuvoSarker: It's called frequency domain because the axes represent frequencies, just like in the spatial domain they represent location in space. Isolate one particular point in the frequency domain, and you isolate one particular frequency. At that point you do have a complex value, which you can separate into amplitude and phase, but that should not name the domain, just like the spatial domain is not called the "intensity domain", even though it represents an intensity at each spatial location.
Comment: Great! But how does it do it? Why, for example, the signal is not transformed into the amplitude domain or phase domain instead of frequency domain?


Why include the host in the signature of the Amazon HMAC scheme?

Question: The Amazon's HMAC schemes includes the hash of the canonical request in the string to sign in order to create the signature, and the canonical request in turn includes the host. What is the security implication of not including the host in this scheme?
Comment: I'm not sure that we can answer questions about HMAC schemes in general. HMAC is an operation that has many uses.
Comment: Good point about HMAC in general, I will modify the question.
Answer: In general, you use an HMAC to ensure that a value isn't changed (ie: it doesn't lose integrity). So including the URL in the HMAC means that Amazon doesn't want to allow it to be changed once the HMAC is created.
In this case, including the URL ensures that a request targeted for one URL but somehow sent to another can be detected because the recipient's recalculation of the HMAC will use the actual URL, not the original URL, and the HMACs won't match.
This check will be in addition to whatever security is provided by encrypted communications (eg: SSL).
Comment: Redirecting the message to another host. I don't really see that being a likely scenario, especially with SSL being used, but it adds an extra layer of protection.
Comment: I understand that including host in this case adds the extra security, what I don't understand is: what does it protect against? Suppose Amazon doesn't include the host, as an attacker, what does being able to change host give me?
Comment: But the Amazon scheme authenticates with an access key, suppose the attacker redirect to another host, there will still be a key mismatched.


Principal component analysis with group data

Question: In my experiment I have used 30 different accessions of a species. One group is challenged drought and the other group is control. I have collected data on 6 different parameters. I want to know which accession is more tolerant or susceptible, which accession is more affected by which variable (parameter), and which variable is most critical etc. Can I use principal component analysis? Should I combine data during PCA analysis or subtract treatment data from control group? or how can I do PCR with both group data?
Answer: In general, I wouldn't see a problem why you couldn't do a PCA to visualize and interpret your multivariate dataset (however since you didn't provide data, I cannot say for sure). As for your second question, I would keep the two groups (drought, control) and not subtract them from each other. That way you will be able to see if the component scores (illustrated as points in the plot) will cluster and how the component loadings (illustrated as vectors in the plot) relate to them.
Here an example to illustrate what I mean (also your third question):
Generate an example dataset (based on your description):
set.seed(13)
d <- data.frame(
  treatment = rep(c("drought", "control"), each = 15),
  y1 = rnorm(30, 3, 1),
  y2 = rnorm(30, 6, 3),
  y3 = rnorm(30, 4, 2),
  y4 = rnorm(30, 9, 4),
  y5 = rnorm(30, 5, 2),
  y6 = rnorm(30, 12, 5)
)

The following steps can be achieved in a lot of different ways (also perhaps better and more efficient) with different R packages. But here is what usually works for me:
PCA using FactoMineR:
require(FactoMineR)
my.pca = PCA(d[, c(2:7)], scale.unit = T, graph = F)

# EXTRACTING VALUES FROM my.pca FOR PLOT BELOW
PC1.ind <- my.pca$ind$coord[,1]
PC2.ind <- my.pca$ind$coord[,2]
PC1.var <- my.pca$var$coord[,1]
PC2.var <- my.pca$var$coord[,2]
PC1.expl <- round(my.pca$eig[1,2],2)
PC2.expl <- round(my.pca$eig[2,2],2)
Treatment <- factor(d$treatment,levels=c('drought', 'control'))
labs.var<- rownames(my.pca$var$coord)

Build the plot with the ggplot2 package:
require(ggplot2)
require(grid)
ggplot() +
  geom_point(aes(x = PC1.ind, y = PC2.ind, fill = Treatment), colour='black', pch = 21,size = 2.2) +
  scale_fill_manual(values = c("red", "blue")) +
  coord_fixed(ratio = 1) +
  geom_segment(aes(x = 0, y = 0, xend = PC1.var*2.8, yend = PC2.var*2.8), arrow = arrow(length = unit(1/2, 'picas')), color = "grey30") +
  geom_text(aes(x = PC1.var*3.2, y = PC2.var*3.2),label = labs.var, size = 3) +
  xlab(paste('PC1 (',PC1.expl,'%',')', sep ='')) +
  ylab(paste('PC2 (',PC2.expl,'%',')', sep ='')) +
  ggtitle("Some title")

The vectors represent components loadings, which are the correlations of the principal components with the original variables. The strength of the correlation is indicated by the vector length, and the direction indicates which accessions have high values for the original variables.
Also I would suggest having a look here for more information on how to interpret PCAs in general (if that's needed at all).
Also since you have predetermined groups, i.e. drought and control you might also have a look at linear discriminant analysis (LDA). Both, PCA and LDA, are rotation-based techniques. While PCA tries to maximize total variance explained in the dataset, LDA maximizes the separation (or discriminates) between groups. For more information you could have a look at the candisc function in the candisc package, or the lda() function in the MASS package for example (both in R).


Electric boiler and dryer same breaker?

Question: I'm adding an electric boiler 240 volt. Can I use the same breaker from the dryer? I don't have room to add another breaker on my electric panel.
Comment: Where are you on this planet?
Comment: Is it a gas dryer?
Comment: Also, what make and model is your panel?
Answer: If you live in the US. Then NEC Article 210.23(2) states that you cannot exceed the circuit ampere rating more than 50% of the total rating of the dryer. NEC Article 220.54 states you shall rate the dryer at 5000W (V/A) or the name plate rating of the dryer whichever is larger.
So 5000W/240V = 20.8A (more than 50% of 30A). That means NO you cannot use the circuit to power both your boiler and the dryer on the same circuit.
You might try to revisit your Panel and see if it accepts half size breakers and see if you can create some space in it, or the only other practical solution I can see, would be to install a subpanel.
Hope this helps.
Answer: The short answer is no.  You will either have to replace your panel with a new larger one, install a sub panel for additional space or install twin style breakers.
Answer: If not violating local codes, there might be a solution via load shedding relay, which avoids parallel use, what should be no problem in this case unless both the electronic control systems - if any - of the units are incompatible. The unit having lower prioritization must be compatible, since only that unit will be shut on/off via the relay or contactor. Older units without any electronics should be fine with those power interruptions.
This relay could be installed in the unit with higher power (2nd option would be to choose the incompatible unit for the installation to control the compatible one), and a second normal relay or contactor in the other unit, a cable has to be run between the devices. Thus no  space is needed in the panel. The English Wikipedia entry seems to be missing (maybe that is an indication that it is not allowed in most english language areas), here is a translation from the German page:Load Shedding Relay
Comment: "Relay" or "relays" is the English spelling (for those who were confused as I was at first).
Comment: @FreeMan Thanks for the hint.
Comment: no problem! Since you linked a German page, I thought maybe that was the correct German spelling and didn't want to step on your toes. (Even though you brought 'em in here:)

Electric boiler and dryer same breaker?


Are there any bugs or fish to be found on main street?

Question: On Main Street in Animal Crossing: New Leaf are there ever any bugs around or any fish in the pond?
Answer: No, bugs won't spawn there. The trees and pond are fake, I don't believe you can even cast your rod in the pond. Bugs/fish only spawn in town, on the Island or during Island Tours (and only certain tours have catchable animals.)
Comment: Edits shouldn't change the information presented in a post, even if incorrect.


Want to stop instantiating objects when timescale is set to zero

Question: I have my enemies being instantiated from both left and right sides and I've used Time.timescale=0; for the pause menu script so whenever i pause my game everything stop other than the instantiating objects and when i resume the game all the instantiated objects come as bunch. I really need a solution.
Comment: Show us teh codez pl0x! How do you instantiate your enemies?
Answer: just put this line of code on first line of function that instantiates enemies:
  if (Time.timeScale == 0) return;

time scale basically work for objects Movement if you have used delta-Time in their movement function as delta time is multiplied with movement amount.
Answer: The other answer will work for your current need, but it will not work when you'll actually start using the timescale for purposes other than pausing the game, such as creating slow motion effects or when you'll want to debug and accelerate the process to attain certain events faster.
The first thing to do is decide the rate at which your enemies spawn: you can use "enemies per minute".
At the initialization, translate this value to a "per second" value.
Then every update, accumulate your deltaTime, and while the accumulator is higher than the spawn rate, spawn an enemy.
Pseudo code:
float spanwRatePerSecond = spawnRatePerMinute/60.0;
float spawnAccumulator = 0.0;

update()
{
  spawnAccumulator += Time.deltaTime
  while ( spawnAccumulator >= spanwRatePerSecond )
  {
    spawn()
    spawnAccumulator -= spanwRatePerSecond
  }
}

Keep in mind that using the timescale variable to pause your game has its disadvantages: at some point, you might want to keep some things moving and animated on the screen when you'll pause the game. Using timeScale = 0 will make it harder to achieve.

Finlay, as it's stated in the documentation, you could prevent the spawning of your enemies by putting the spawn code in the FixedUpdate function, because it is not called when the timeScale is zero.


Why doesn't the electric potential constantly decrease in a circuit as the current moves from the positive to the negative terminal?

Question: Why doesn't the electric potential constantly decrease in a circuit as the current moves from the positive to the negative terminal?
Details and Assumptions:
 1. The wires show no resistance.
Comment: That totally depends on the circuit. In a circuit with a capacitor the potential will decrease, in a circuit with a power supply that has a virtually infinite capacity to supply energy to the circuit, it does not have to.
Comment: It does........
Comment: Current only moves from positive to negative in the power source, not in an external circuit. Maybe the battery is going dead.
Answer: In a normal electric circuit, with copper wires at ambient temperature, electric potential does decrease around the circuit, as there will be some resistance and so there has to be a voltage/potential gradient for the current to flow.  Copper wires DO have some resistance, so your assumption is invalid in that case.
However, your assumption would be valid for superconducting wires below their critical temperature. Here, the resistance is zero, which means that you can have a current flowing without needing to have any potential gradient or EMF to push it along.
Answer: Leaving aside superconductors, wires will always have some resistance, and the potential always does reduce continuously as the current moves around the circuit. However, the assumption reflects the fact that the wires connecting resistors have low resistance so you can ignore them for the purpose of your calculations. In other words, is a practical approximation to reality that makes the sums easier without an appreciable lack of precision in the answer.
Answer: It does as others mentioned. For example, suppose you have a source with two poles, one pole being at potential 0 (zero) and the other one at a value V. if you insert two resistors in series between the two poles, with resistance R1 and R2, the current in the circuit is I = V/(R1+R2). There is a potential drop of V1 = R1 I across the first resistor and a drop of V2 = R2 I across the second resistor. Note that the total potential drop is V = V1 + V2. If the resistor with resistance R1 is the one that is connected to the 0 potential pole, then the potential at the junction between the two resistors is V1 = R1 V/(R1+R2), which is of course smaller than V, but larger than 0. I ignored wire resistance and the source internal resistance, as per the assumption of an ideal situation. Of course, the total potential between the two poles does not change. However, if you measure the voltage between the 0 pole and the junction of the two resistors, you will see that the value is smaller than V.


How to figure out which parts of a track don't have enough markers

Question: I'm tracking a shot where none of the markers stay in frame the whole time, so I make up for the markers lost by adding new ones. I make sure there's at least 9 active markers every frame, but it still tells me I need 8 common tracks on each keyframe. How can I figure out which parts of my shot don't have enough markers?
Comment: Possible duplicate of [How to pick good keyframes for motion tracking?](https://blender.stackexchange.com/questions/27630/how-to-pick-good-keyframes-for-motion-tracking)
Answer: You don't need the markers to stay in the frame for the duration of the shot, but you do need to have at least 8 successful trackers for a section from which blender can solve the scene.
The range of frames used for solving can be set in the solve section Keyframe A and B

If you can't decide which range of frames is best, you can let Blender decide for you by enabling the Keyframe option on the solve tab.
Please read through the following link: How can I get better results when doing camera motion tracking?


Circular dependencies that cannot be fulfilled. PHP packages on CentOS 7 to support Drupal 8

Question: I am trying to install Drupal 8.0.5 on Apache 2.4.6 on CentOS 7, with PHP 5.6.19.  I get an error that PHP extensions are disabled.  The detail I get is that it pertains to "gd."
I have installed, with yum install these packages: gd, gd-devel, php-gd, php-pdo php-mbstring, php-xml.
I have installed various other packages.  I have no reason to think that PHP gd extensions have not been enabled.  They've certainly been installed.  I've restarted Apache services and MariaDB services. I've rebooted the sever.
I reinstalled Drupal and PHP.  I created a php.ini file with "extension=gd.so" as the content.
What should I do to get Drupal working for the first time?  I have never done this before.  How do I enable the PHP Extensions?  Or is the message false?  If it is, what should I do?
Main problem (circular dependencies that can never be fulfilled):
To ensure that I have the correct versions of the packages, I tried to install php56-php-common-5.6.19-2.fc24.remi.x86_64.rpm.  But I get an error that it requires php56-php-pecl-jsonc(x86-64).  To handle this requirement, I tried to install this package.  I then tried to install php56-php-pecl-jsonc-1.3.9-1.el7.remi.x86_64.rpm.  But I got an error that I needed php56-php(zend-abi).  This package seems to be the php56-php-common one above.  When I search for php56-php(zend-abi), I get brought to this URL: https://www.rpmfind.net/linux/rpm2html/search.php?query=php56-php%28zend-abi%29
What should I do?
Answer: All this package comes from this SCL: https://www.softwarecollections.org/en/scls/rhscl/rh-php56/ You need to enable this repo. Then you need to operate with SCL similarly as this tutorial  http://developers.redhat.com/blog/2013/08/01/php-5-4-on-rhel-6-using-rhscl/ (just replace php54 with php56).


What Software can I use to clean up scanned slide images?

Question: I would like to to clean up damage to and retouch under/overexposed scanned slide images, prepare the digital images with copyright symbols for use on web pages and add tags to allow image files to be 'searched' on a website under key words. I read a lot about Illustrator and that seems the right software to get on a budget, but Adobe keep pushing Photoshop CS6, which is too costly for me right now. Is Illustrator what I need to look at or is there other comparative non-Adobe software I can get that is just as good?
Comment: If you are absolutely on a budget you need to put hardware first. If you don't have one get a Wacom tablet. I use an Intuous 3. You can use it with Gimp if you can't afford Photoshop, but quality restore work is very difficult without pressure sensitive input.
Comment: @Kris And finally, Adobe Illustrator isn't so much an image editor as a vector graphics design tool to create for example posters.
Comment: @Phil a graphics tablet is unintuitive to some people - some are very good with a mouse and are better off using that. Additionally, for me a graphics tablet never worked well on my laptop while on my desktop it is usable. In theory a graphics tablet is just a "different mouse" but somehow it is a tad more demanding...
Comment: @Kris Besides Photoshop CS there is Elements as well which possibly does most of what you want to do, but would lack Bridge which is very useful for easy CameraRAW control. Exposure and colours can be corrected very well using Lightroom, some light scratches possibly too, but nothing "heavy". Depending on how important pixel level work is to you, Lightroom may be a good choice.
Answer: I don't know where you're getting your information about Adobe Illustrator, but you've been misled.
Photoshop costs about the same as Illustrator at the moment on Amazon.com, so I don't see how Illustrator is the "budget" choice. Maybe you're comparing with Photoshop Extended, but there are no features in Extended relative to standard Photoshop that you need for this.
Even if Illustrator were a lot cheaper than Photoshop, it would still not be something you should be considering for your task. Illustrator is powerful software, and it can certainly be made to do at least some of what you want, but only in the same sort of way that you can drive a nail with a Crescent wrench. It simply is not the right tool for this job.
Someone suggested Lightroom as a possible choice here, and it seems you're thinking that, too, from the <code>[lightroom-3]</code> tag you added to your question. It's a fair choice for this. There are two limitations in Lightroom that make it less than ideal for your application however:

Lightroom has no built-in way to talk to a scanner. Most image editing programs support WIA, TWAIN or both, so that you can scan something straight into the application. Not Lightroom. You'll have to scan with separate software and import that into Lightroom somehow.
There are ways to automate this scan-and-import procedure so that it works mostly like WIA or TWAIN. For example, if you use VueScan as your scanner software, you can configure it so that its scan-to-file directory is the same as Lightroom's auto-import folder.

A much bigger problem is that Lightroom's ability to remove dust and speckles is limited compared to a full-blown pixel editor like Photoshop. Lightroom's quick heal tool is fine for removing small dust specks, but when you get fibers and such — very common when scanning slides, if only as sheddings from the cardboard frame — the inability to heal non-circular areas means you have to enlarge the tool to cover much more area than is strictly necessary. Sometimes you can get away with this, but other times the limitation effectively prevents you from fixing the problem within Lightroom.
Lightroom lets you configure it to work nicely with an external photo editor, and of course it works especially nice with Photoshop or Photoshop Elements.

If you find yourself needing a pixel editor, there are many choices that will cost you less money than Photoshop. In fact, every alternative I'm aware of costs so much less than Photoshop that you can get Lightroom as well and still pay less for the combination. Examples:

Corel PHOTO-PAINT: ~$320 street as part of CorelDRAW! graphics suite
Paintshop Pro: ~$80 street
Photoshop Elements: ~$65 street
Gimp: free
Paint.net: free

(I've listed only Windows software on purpose, since you mentioned the Windows-only Paintshop Pro in another comment. Other platforms have additional alternatives.)
Photoshop is more powerful than all of these, by a considerable margin. You will find some people online who will try to tell you that Gimp is just as good as Photoshop, but these people clearly have never used both for extended periods. The others are even less powerful than Gimp. Nevertheless, you can do all of what you ask with all of them.
It's a question of what other features you need. If your question lists every feature you will want from a photo editor, you can pick any of them that you like. If you need other things, or expect to need other things, look at the feature lists and decide if you're willing to pay the asking price to get those features.
Something to consider about Photoshop is the ecosystem. You will find more books, more training, more plug-in software, etc. for it than for any of the others.
If I had to select something for you, knowing nothing else about you, I'd choose Photoshop Elements. (Optionally coupled with Lightroom.) It's about $65 online, it will do everything you ask, and it will likely do everything you need for quite some time. If the time comes that you outgrow it, you can directly transfer your skills to "real" Photoshop. The user interfaces are somewhat different, but the tool sets are the same, the keyboard shortcuts are the same, the file format is the same, etc.
Comment: Good point about Lightroom's limitation in dust removal. It struggles with black and white film scans for this reason, in fact scratch and booger removal is about all I use Photoshop Elements for these days and it is a royal pain in the neck. For positive and colour negatives I find that the scanner's infrared dust removal does such a good job that my need for manual dust-spotting in post is very limited indeed. In fact, if there is so much gunk on the (non-B&W) negative that Lightroom can't deal with it after this one really should physically clean the film and re-scan.
Comment: @StaaleS: There are two problems with automatic dust removal. First, our OP may not have a scanner with this feature. Second, even when you have it, it's not something you want to turn on all the time, because it usually results in a softer scan. Unless time is tight or you don't need large output, I'd recommend turning automatic dust removal off, cleaning the film as well as you reasonably can before scanning, and fixing what you can't brush off in a pixel editor. Yes it takes more time. The results may be worth it to you, however.
Comment: I must say I disagree - provided the scanner provides proper infrared dust removal. (If not - get one that does!) Spotting individual dust grains off a slide or negative takes _forever_.
Answer: Its unclear, can you rescan the photos with a tool that can eliminate dust at scan time? Both VueScan and SilverFast can use a special IR scan on most slide scanners to remove scratches directly.
I've used both Aperture 3 and Lightroom4 to fix images after they have been scanned. Both work. And they are, of course, great for post-processing photos when you don't need the full blown Photoshop.
Photoshop, of course, in the right hands, can do anything.
Answer: Sounds like a poster-boy case for Adobe Lightroom to me.
Comment: Thanks for the response. I compared Lightroom features to Paintshop ProX4 just now and the Paintshop seems to have a whole lot more functionality, what's your opinion on the Corel product? Any experience using it?
Comment: Argh, pressed Enter... Anyway: Photoshop CS or Paintshop Pro are general purpose image editing programs. They do all things for all people, where "people" probably mean graphics artists. Lightroom is a highly specialized single-purpose editing and organizing tool for working with _photos_ for _photographers_. It does 10% of what the others do, but those 10% it is very, very, very good at and those 10% are exactly what you need - for photos. I frankly have not even started up Photoshop in any variant for the past year, but use Lightroom all the time.
Comment: You are comparing a school-bus and a dump-truck. Different beasts, even if they both have four wheels and a motor.


How to handle workplace lies

Question: How should I handle a situation where the owner of a company is lying to my coworkers?  An example scenario would be "The company took a loss last year". The reality is that the private company actually recorded a profit and both the owner and I know that.
Comment: I'd also be careful about asserting the company made a profit unless you have seen _all_ the numbers. Do you know all the company's debts, all the details of which sales actually booked in which year, and so on? All the accounting details that go into the company's tax statement? The consequences of being right here are bad; the consequences of being wrong are worse.
Comment: So telling the truth wouldn't ever be an option then @joe?
Comment: @JoeStrazzere to the people being lied to. Keeping quiet is implicitly supporting the lie.
Comment: (Sorry, one of my comments was directed toward another question. I've moved it.)
Answer: As commented, you could stand up and shout in front of everyone that the owner is lying, but I think we all know that's not going to end well.
If you feel you can't ignore the issue, perhaps the best thing would be to have a private conversation with the owner:

I thought the company made a profit last year, so I was surprised to hear you say it made a loss. Is there something I'm missing here?

Answers could range from "actually, it did make a loss, here's the evidence" through "none of your business" to "you're fired", so be slightly careful before asking.
Answer: If you have access to financial records/statements then I suggest you keep that on the need to know basis. Remember your obligation lies to the owner, shareholders, and government. Employees who are not cleared to know those statements or accounts are not to be included on that information without approval from the owner or shareholders (or board of directors if applicable). I would just keep quiet and depending on your position in the company, maybe talk to a higher up financial director or CFO and see if what the owner said is true. Try to throw it into a casual conversation as a per chance kind of thing (around the water cooler):
"Hey [name], I heard a rumor saying that we recorded a loss last [year/quarter/month]. How bad is it?"
The response will tell you if things are going badly or what. Be careful of asking this if you are supposed to know. Try adding a small amount of humor to lighten it.
NOTE: My answer comes with the understanding of US laws and US GAAP. Not applicable in all countries.

How to handle workplace lies


What is encapsulation with simple example in php?

Question: What is encapsulation with simple example in php?
Answer: Encapsulation is just wrapping some data in an object. The term "encapsulation" is often used interchangeably with "information hiding". Wikipedia has a pretty thorough article.
Here's an example from the first link in a Google search for 'php encapsulation':
<?php

class App {
     private static $_user;

     public function User( ) {
          if( $this->_user == null ) {
               $this->_user = new User();
          }
          return $this->_user;
     }

}

class User {
     private $_name;

     public function __construct() {
          $this->_name = "Joseph Crawford Jr.";
     }

     public function GetName() {
          return $this->_name;
     }
}

$app = new App();

echo $app->User()->GetName();

?>

Comment: Hi fiXedd, I dont think this is a good and simple example of encapsulation in php. For beginners it is hard to understand the concept of Singleton.
Comment: Please note example link is now broken. Also Singletons are considered anti-pattern.
Comment: The naming App->User() is not really a good one is it? It's confusing for people reading the code, as well as learners. App->getUser() I think would be better.
Comment: Got it, $app->User() is calling the function of class "APP", hence it returning the object of User class so we can call methods of User class with it.
Answer: Encapsulation is protection mechanism for your class and data structure. It makes your life much easier. With Encapsulation you have a control to access and set class parameters and methods. You have a control to say which part is visible to outsiders and how one can set your objects parameters.
Access and sett class parameters
(Good Way)
<?php

class User
{
    private $gender;

    public function getGender()
    {
        return $this->gender;
    }

    public function setGender($gender)
    {
        if ('male' !== $gender and 'female' !== $gender) {
            throw new \Exception('Set male or female for gender');
        }

        $this->gender = $gender;
    }
}

Now you can create an object from your User class and you can safely set gender parameters. If you set anything that is wrong for your class then it will throw and exception. You may think it is unnecessary but when your code grows you would love to see a meaningful exception message rather than awkward logical issue in the system with no exception.
$user = new User();
$user->setGender('male');

// An exception will throw and you can not set 'Y' to user gender
$user->setGender('Y');

(Bad Way)
If you do not follow Encapsulation roles then your code would be something like this. Very hard to maintain. Notice that we can set anything to the user gender property.
<?php

class User
{
    public $gender;
}

$user = new User();
$user->gender = 'male';

// No exception will throw and you can set 'Y' to user gender however
// eventually you will face some logical issue in your system that is
// very hard to detect
$user->gender = 'Y';

Access class methods
(Good Way)
<?php

class User
{
    public function doSomethingComplex()
    {
        $this->doThis(...);
        ...
        $this->doThat(...);
        ...
        $this->doThisExtra(...);
    }

    private function doThis(...some Parameters...)
    {
      ...
    }

    private function doThat(...some Parameters...)
    {
      ...
    }

    private function doThisExtra(...some Parameters...)
    {
      ...
    }
}

We all know that we should not make a function with 200 line of code instead we should break it to some individual function that breaks the code and improve the readability of code. Now with encapsulation you can get these functions to be private it means it is not accessible by outsiders and later when you want to modify a function you would be sooo happy when you see the private keyword.
(Bad Way)

class User
{
    public function doSomethingComplex()
    {
        // do everything here
        ...
        ...
        ...
        ...
    }
}

Comment: Simply validating the data passed to a setter (male/female) isn't really encapsulation. Encapsulation in your example would be a private setter for the `private $gender` property (`private function setGender(string $gender)`) and you'd have `public function setGenderMale()` and `public function setGenderFemale()` that would in turn pass "male" or "female" to the `setGender()`
Answer: Encapsulation is the mechanism that binds together code and the data it manipulates, and keeps both safe from outside interference and misuse. The wrapping up of data and methods into a single unit (called class) is known as encapsulation. The benefit of encapsulating is that it performs the task inside without making you worry.
Answer: Encapsulation is a way of storing an object or data as a property within another object, so that the outer object has full control over what how the internal data or object can be accessed.
For example
class OuterClass
{
  private var $innerobject;

  function increment()
  {
    return $this->innerobject->increment();
  }
}

You have an extra layer around the object that is encapsulated, which allows the outer object to control how the inner object may be accessed.  This, in combination with making the inner object/property private, enables information hiding.
Answer: /* class that covers all ATM related operations */
class ATM {

    private $customerId;
    private $atmPinNumber;
    private $amount;

    // Verify ATM card user
    public function verifyCustomer($customerId, $atmPinNumber) {
        ... function body ...
    }

    // Withdraw Cash function
    public function withdrawCash($amount) {
        ... function body ...
    }

    // Retrieve mini statement of our account
    public function miniStatement() {
        ... function body ...
    }
}

In the above example, we have declared all the ATM class properties (variables) with private access modifiers. It simply means that ATM class properties are not directly accessible to the outer world end-user. So, the outer world end-user cannot change or update them directly.
The only possible way to change a class property (data) is a method (function). That's why we have declared ATM class methods with public access modifier. The user can pass the required arguments to a class method to do a specific operation.
It means users do not have whole implementation details for ATM class. It's simply known as data hiding.
Reference:
http://www.thecreativedev.com/php-encapsulation-with-simple-example/
Answer: People seem to be mixing up details of object orientation with encapsulation, which is a much older and wider concept.  An encapsulated data structure

can be passed around with a single reference, eg increment(myDate)
rather than increment(year,month,day)
has a set of applicable operations stored in a single program unit
(class, module, file etc)
does not allow any client to see or manipulate its sub-components
EXCEPT by calling the applicable operations

You can do encapsulation in almost any language, and you gain huge benefits in terms of modularisation and maintainability.
Answer: Wrapping up data member and method together into a single unit (i.e. Class) is called Encapsulation.
Encapsulation is like enclosing in a capsule. That is enclosing the related operations and data related to an object into that object.
Encapsulation is like your bag in which you can keep your pen, book etc. It means this is the property of encapsulating members and functions.
<?php
 class YourMarks
  {
   private $mark;
   public Marks
  {
   get { return $mark; }
   set { if ($mark > 0) $mark = 10; else $mark = 0; }
  }
  }
?>

I am giving an another example of real life (daily use) that is "TV operation". Many peoples operate TV in daily life.
It is encapsulated with cover and we can operate with remote and no need to open TV and change the channel.
Here everything is in private except remote so that anyone can access not to operate and change the things in TV.
Answer: The opposite of encapsulation would be something like passing a variable to every method (like a file handle to every file-related method) or global variables.
Comment: Another alternative to encapsulation is inheritance - ie "extend"ing the object containing the data rather than encapsulating it.
Answer: Encapsulation is the process of hidding the data of the object from outside world and accessed to it is restricted to members of the class.
Answer: Simply I prefer that is visibility of your class's property and method. For example-
 - public
 - private
 - protected
Let's take a look real life example for encapsulation.
 class MyClass{
    private $name;

    public function showName($newName){
        $this->name = $newName;
        return $this->name;
    }
 }

 //instantiate object

 $obj = new MyClass();
 echo $obj->showName("tisuchi");

In this case, encapsulation means, we restrict some properties. Like, name property, we can not access from outside of the class. On the other hand, we can access public function entitled showName() with one private parameter.
Simply what I prefer of encapsulation is-
visibility of your property and method.
Although, if you have any intension to understand encapsulation further, I refer to my special tutorial based on encapsulation.
http://tisuchi.com/object-oriented-php-part-3-encapsulation-php/
Hope, it will make your concept more clear. Have fun!
Answer: In basic terms, it's the way we define the visibility of our properties and methods. When you're creating classes, you have to ask yourself what properties and methods can be accessed outside of the class. Let's say we had a property named foo. If a class extends your class, is it allowed to manipulate and access foo? What if someone creates an instances of your class? Are they allowed to manipulate and access foo?
Answer: Encapsulation is just how you wanted your objects/methods or properties/variables to be visible in your application.
for example, :

class ecap {

public $name;

private $id;

protected $tax;

}

If you want to access private or protected properties, then you have to use getter and setter methods in your class that will be accessible from outside of your class. Meaning, you cannot access your private or protected properties directly from outside of your class but you can use through any methods. Let's take a look-
in the class, add the following method:

class ecap
{
 public function userId(){
 return $this->id;
 }
}

and we can access it like:
 $obj = new ecap();
 echo $obj->userId();

Answer: Another approach for encapsulation with function (without class) + usage of "use"(optional), to use outer variables inside encapsulation function
<?php

$abc = 'ABC';

// Encapsulation Function
(function () use ($abc){
echo $abc; // prints ABC
$xyz = 'XYZ';
})();

echo $xyz; // warning: undefined

Comment: Well, yes and no. It is arguably a form of encapsulation but without a pre written class you're just writing throw-away code that's not reusable and locking an inner variable.
Answer: Wrapping up of data inside single unit is called encapsulation. Means class members such as method and properties binds together inside a class to avoid  accessibility from outside.This is done by making variables and functions of class private.
Comment: Yes you gave a definition for encapsulation? Can you add PHP example?


Ugly spacing around f in math mode

Question: My paper contains many math expressions like $abcde$ or $abdefv$.  Unfortunately, the latter looks very ugly, particularly in regards to the spacing around the f.  In particular, there is a significant amount of space around the f which is not present around the other letters.
Is there a method to make that spacing tighter?
Note: Joseph Wright suggested using \! to get a negative thin space.  This does seem to help.  But I'm still a bit curious as to why the problem occurs at all.  For example, it looks fine in $acdfv$ before the f but not after.  If anyone has some more details on why the spacing ends up as it does, please comment.  Thanks.
Comment: Sounds like tensor calculus, which leads to, as Spivak calls it in his differential geometry tome, "The debauch of indicies."
Comment: Seems like a very unlikely product - do you really mean this? If so, perhaps try `\!` to back the spacing up.
Comment: @Joseph Wright: Yes, that's an actual example from my paper, but $efv$ has the same problem and isn't as unlikely.  Thanks for the $\!$ advice -- I guess I should have thought about that.  That works before the $f$ quite well.  Is there a predefined way to get an even thinner negative space (for after the $f$) or should I use $\hspace{-..}$?
Answer: For a detailed answer why this is happening you can read this answer of mine (shameless plug indeed): In short, the italic correction of the f has a great part in this. But the italic correction only explains the spacing after the f, not before. For this you have to look at the bounding boxes of the letters:

The first f is a text italic letter in its bounding box, the second one is math italic (in its bounding box together with its italic correction). As you can see, the text letter protrudes a bit to the left (and a lot to the right); the math letter has a tiny bit of white space in the left (and also in the right, because of the italic correction). For a bit more about the bounding boxes see this question of mine (another shameless plug :-)).
I first noticed the problem when typing $Vf$, which doesn't yield a nice output. My resort is using $V\hspace{-0.1em}f$ instead (in a macro, of course), which I like much better. You could even use $V\!f$, but this I find too narrow. Compare these three:

I would not encourage you to follow Caramdir's (now removed) suggestion to use $\mathit{Vf}$ since this uses a different font (text italic, not math italic). You can see quite clearly that the V is narrower (in other words, the angle at the bottom of the V is more acute):

If you use a different math font (like Euler), then the difference is even more noticeable.
(For a case where \textit could be a good solution, see this answer of TH.)
Answer: Math mode considers each symbol a separate variable, not part of a "word". If you want word-like behaviour, use \mathrm{...} or \mathit{...}. If this really is a product, perhaps using \cdot between factors (or reorganizing, or changing variable names, perhaps distinguished by subindices) helps.

Ugly spacing around f in math mode


Another Domain Under My Domain

Question: Say my domain is foo.com and there is another domain bar.com. When people go to, say, xyz.foo.com - I want them to see bar.com. Is this possible to configure somehow. I think I've seen an option like this for some SaaS systems, but I can't recall which. This would be something done for white labeling, etc.
Comment: White labeling requires the cooperation of the site being white labeled.   The site has to be configured to serve up different logos, contact info, and any other differences.   Yes, it also has to be served from a different URL, but doing that is one of the easier things that need to change.
Answer: Use a CNAME record in your DNS zone file:
<code>xyz.foo.com.        CNAME  bar.com.
</code>
Remember, MX and NS records cannot point to a CNAME. And your CNAME must always point to a domain, not an IP. Once you do this the alias "bar.com" cannot be used in any other resource records (like MX).
Comment: I like your answer, but I'm a bit confused about your last sentence.  `A` records never involve aliases, they always involve an IP address, so I'm not sure why you imply that a domain could be used in an `A` record somehow.

Another Domain Under My Domain


Detecting traps in chess

Question: Are there any ways to detect if the opponent is setting a trap, without explicitly just "knowing" the position?
Comment: I recommend the book "Tune your chess tactics antenna" by Emmanuel Neiman.  It is for developing this tactical sense and I found it helpful.
Answer: The most important thing to have is a sense of tactical danger, and this comes about as a combination of tactical intuition, and calculation ability. Intuition comes from playing lots of games, winning about half and losing about half --- from the losses, many of those will be from tactical blunders, which will train your brain emotionally to be averse to such blunders, and eventually it enters your subconscious and becomes intuition. Calculation ability can be trained by similarly playing lots of games, but also specific tactical training e.g. solving puzzles, analysing complicated middlegame positions or solving studies, etc.
Concretely, it is helpful to be aware of the idea of "compensation". If your opponent is giving away pawns or pieces in the opening, you should always be on high alert and ask yourself: did they just blunder that, or do they have a plan? If they have a follow-up plan, is it good? This follow-up might be in the form of a 1-move tactic that wins back the material, or it might be some kind of "long term compensation", meaning e.g. a strong mating attack.
<code>    [title ""]
    [fen ""]

    1.e4 e5 2.Nf3 Nc6 3. Nc3 Nf6 4. Bc4 Nxe4
</code>
This is a mild example of a "trap" that happens very often in beginner games, where 4.Bc4 is already an inaccuracy because of 4...Nxe4 seemingly giving up a piece. The "trap" is that after 5. Nxe4, black has 5...d5 to win back the piece, and black is already equal and white is not better. So, if you have a good sense of tactical danger, you will know to avoid this "center fork trick" and not play 4.Bc4. (This line is playable, and apparently has even been played by Wesley So in a rapid game, but it is really not good for White.)
But even more serious are the traps that lead to a losing position for one side.
<code>    [title ""]
    [fen ""]
    1. d4 e5 2. dxe5 Nc6 3. Nf3 Qe7 4. Bf4 Qb4+ 5. Bd2 Qxb2 6. Bc3 Bb4 7. Qd2 Bxc3 8. Qxc3 Qc1#
</code>
For example there is this famous trap in the Englund gambit. How to avoid falling for such things? Well, you should first notice as White the existence of the forcing move Qb4+ forking the bishop and the pawn on b2. (A lot of people at beginner level would play a move like 5.Nbd2 hanging the bishop.) Then, you should notice that 6.Nc3 is the only move, because this line with 6...Bb4 is losing, given the pin to your king.
There is obviously no one size fits all solution to never ever fall into an opening trap again. Famously, GM Elshan Moradiabadi lost in 10 moves against GM Lenier Dominguez Perez in the US Championships 2022!
<code>[title "Dominguez vs Moradiabadi, US Champs 2022"]
[fen ""]
1. e4 e5 2. Nf3 Nf6 3. Nxe5 d6 4. Nf3 Nxe4 5. d4 d5 6. Bd3 Be7 7. O-O Bf5
8. c4 O-O 9. cxd5 Qxd5 10. Bxe4 1-0
</code>
The big mistake was 8...O-O and the game was well and truly lost after 9...Qxd5. Black resigned because Re1 is coming to pick up the hanging bishop on e7, either on the next move if Qxe4, or two moves later after Nc3, queen moves, and Nxe4.
The only advice that can be given is to strengthen your tactical sense of danger, so that you are more aware to traps like these. Another point is to simply keep playing chess, and after thousands of painful losses, you will eventually learn so many traps that you are unlikely to fall into those again. Once you're strong enough, maybe 2000+, it could be worth the energy to invest time into studying openings specifically as well, which will further improve your opening play so you don't lose to such traps again. However, as we have seen from the previous example, you will never stop making blunders, you can only seek to decrease their frequency. :)
Answer: You might not have alluded to Possibility B, but I add it for completeness: If you know the opponent good enough, you can scan for "Poker tells".
I give no warranties though, as this little story proves:
I played a dude in the chess club. Selfsame dude was...well, a certified jerk. Pet theory: The more jerkish you are, the better you can "read" the opponent (evolution at work). I was the stronger player, but I stood abysmal and tried a last trap: Played my move and ohbotherthatwasalousyoneimsuchapatzer-ed. He looked into the position - man, what a lame trap. Of course he immediately looked through my body language and played another move.
Which was actually far worse than accepting the "trap", which would have royally backfired if calculating a bit deeper. Or in one word:

Detecting traps in chess


Does Fedora 15 still use suid bits?

Question: I heard that Fedora 15 will not use suid bits.  Is that true?

Is the suid bit a security design bug?
Answer: Correct, see this feature posted by Dan Walsh, the SELinux maintainer for Fedora/Redhat.
Summary: Fedora 15 will not ship with binaries with the setuid flag set on them, preferring instead to set the capabilities these binaries need via POSIX Filesystem Capabilities. setuid etc can still be set on binaries. Anything that absolutely must have setuid can still have it. At this time I can't confirm (my rawhide is dead) what happens with sudo/su - it is possible for an application to use capabilities to get to root via CAP_SETUID but I don't know if they will use this technique or simply have +s set.
"suid bit = security design bug?". Well, I guess that's a matter of opinion; basically it's about giving a program that a low-privilege user uses the abilitity to run, temporarily, a privileged operation. Unfortunately, any vulnerability in that program may allow you to exploit it in order to gain higher privileges i.e. root access. Technically, it isn't a bug or a security threat; software with exploitable bugs is the issue. But writing bug free software is much more difficult than it sounds.
In terms of what posix file system capabilities are, here's a FAQ. Quoting the pertinent parts:

Then there is something quite
  different called "POSIX capabilities"
  which is what Linux uses.  These
  capabilities are a partitioning of the
  all powerful root privilege into a set
  of distinct privileges (but look at
  securelevel emulation to find out that
  this isn't necessary the whole truth).
  Users familiar with VMS or "Trusted"
  versions of other UNIX variants will
  know this under the name "privileges".
  The name "capabilities" comes from the
  now defunct POSIX draft 1003.1e which
  used this name.

And:

When a process tries to do a
  privileged operation, the operating
  system will check the appropriate bit
  in the effective set of the process
  (instead of checking whether the
  effective uid of the process is 0 as is
  normally done).  For example, when a
  process tries to set the clock, the
  Linux kernel will check that the
  process has the CAP_SYS_TIME bit
  (which is currently bit 25) set in its
  effective set.

And:

6) How can I use capabilities to make
  sure Mr. Evil Luser (eluser) can't
  exploit my "suid" programs?
This is the general outline of how
  this works given filesystem capability
  support exists.  First, you have a PAM
  module that sets the inheritable
  capabilities of the login-shell of
  eluser.  Then for all "suid" programs
  on the system, you decide what
  capabilities they need and set the
  allowed set of the executable to that set of capabilities.  The
  capability rules
new permitted = forced | (allowed &
  inheritable)
means that you should be careful about
  setting forced capabilities on
  executables.  In a few cases, this can
  be useful though.  For example the
  login program needs to set the
  inheritable set of the new user and
  therefore needs an almost full
  permitted set.  So if you want eluser
  to be able to run login and log in as
  a different user, you will have to set
  some forced bits on that executable.

In other words, you've got a partitioning effect for root privileges, so a setuid binary has less chance of being exploited for privilege escalation. This is good news, especially where users of Fedora turn SELinux off.
However, in a SELinux system, setuid/setguid bits are largely redundant, since selinux will apply the policy regardless of unix permissions (capabilities or otherwise). I'm going to quote a comment in the kernel source for this one:

* Since setuid only affects the current process, and since the SELinux
* controls are not based on the Linux identity attributes, SELinuxdoes not
* need to control this operation.  However, SELinux does control the use of
* the CAP_SETUID and CAP_SETGID capabilities using the capable hook.

In short, there is no need for SELinux given a properly written policy to control/restrict capability influenced behaviour, but it is used.
I'll rephrase that for clarity. In a system with a properly written SELinux policy, restricting the setting of capabilities is a non-issue since SELinux will block the activity granted by the capability if it is not also allowed in the policy. This applies to setuid/gid bits too - you might well be executing as another user, but the policy ought to stop the program doing anything outside of the defined context anyway.
An example users might be able to better appreciate/reconstruct; take a fedora box and write a basic file upload script that puts data in /var/www/html/uploads. Taking a look at that folder you can run:
$ ls -alZ
drwxrwxrwx. root   root   system_u:object_r:httpd_sys_content_t:s0 uploads

I'm assuming here you've run chmod 777 on said folder. So now try your upload via Apache. You should see an AVC message; if you're running the GUI you'll find it via setroubleshoot. Basically, until you set the context of that folder to httpd_sys_rw_content_t SELinux will deny httpd write access, regardless of the unix permissiosn.
Want an interactive demo? Log in to this guy's machine as root.
However, there exists a concept of permissions stacking too. See this (specifically:

Add secondary calls in selinux/hooks.c
  to task_setioprio and
    task_setscheduler so that selinux and
  capabilities with file    cap support
  can be stacked).

These discussed features are implemented in the above quoted source code. In other words, setting that directory to chmod 755 yet having httpd_sys_rw_content_t as the context will still deny write. This is because the basic unix level permissions have been denied first and so SELinux context checking is never needed.
Comment: The referenced page doesn't say suid isn't used any more.  It says "Replace setuid apps where possible with file capabilities".  So presumably suid still works at least for non-distro packages.  I'd be surprised if they succeeded in converting everything.  Do you know if any are left?  But maybe I'm wrong: [tracker bug](https://bugzilla.redhat.com/show_bug.cgi?id=646440)
Comment: @Gilles Yes, you *can* still use setXid bits if you want to. What they're saying is that for as many packages as possible, they *won't* use setuid, preferring to use capabilities. From here: http://forums.grsecurity.net/viewtopic.php?f=7&t=2522 it looks like there is in fact a `CAP_SETUID` anyway, so I expect su/sudo will use that. My rawhide is completely broken, so I can't confirm it.
Comment: @nealmcb I imagine it will both still work and still be used by third party repositories, standalone RPMs etc and you probably aren't stopped from setting the suid bits yourself. I think the aim is to encourage the main fedora repos to use this feature and package this way. Quite a lot of system services run as constrained in the targeted policy anyway (e.g. `httpd_t`) rather than `unconfined_t` anyway, so this is only a real advantage for `unconfined_t` domain software and people who turn off selinux.
Comment: After reading this answer and the linked resources, I'm still confused. Does Fedora 15 still use setxid bits? Does it completely remove the feature? Ship without any setxid executable but still support them? Use capabilities wherever possible but still have a few setuid programs (how do `su` and `sudo` work?)?
Comment: @Ninefingers, thanks for the detailed answer!  A minor comment: your statement "there is no need for SELinux..." did not sound right to me.  Perhaps a cut-and-paste error, or the sentence was phrased the wrong away?
Comment: @D.W. Yep, I think I changed what I wanted to say or missed out some words. I've edited in another sentence for clarity.

Does Fedora 15 still use suid bits?


Printer randomly going offline

Question: I have 6 networked computers running Windows XP Pro, 2 of which have a Shinko CHC-S2145 attached and shared. The driver in use is v1.4 and, although I can't find reference to it on the website, was supplied with the printer.
Most of the time 5 of the computers will send print jobs to the printer on the 6th, which is dedicated to printing. The 2nd printer is used as an overflow. The print jobs are approximately 13MB in size, according to the printer management dialog box. At times there can be 5-10 jobs entering the queue per minute but they are all single photos.
A few times a day the printer will just go offline. It's hard to tell if:

a job was corrupt, or
there was a problem with the driver

By the time I am involved there are 20-30 jobs in the queue but this could just be the result of the processing coming to a sudden halt. The situation is usually rectified by clearing the queue and restarting the print spooler - usually be restarting the computer.
EDIT: After experiencing this a few more times and testing various recovery options it seems that the printer will return to an 'online' state when an offending job or two or three is removed from the top of the queue. I haven't been able to find out if the jobs are related when there are multiple bad jobs but I suspect they are.
What can I do to identify the cause of the printer going offline? Can I blame the driver for not being able to properly deal with a job?
Answer: To possibly identify your problem you can see if Windows have registered any useful information in the event viewer.
MyComputer(right click)->Manage->SystemTools->EventViewer

Printer randomly going offline