When is it appropriate to use NOLOCK?

Question: I am having timeout issues and deadlocks from time to time with some long running queries.
I'm wondering when is it most appropriate to use NOLOCK and where?
Do I use it on the updates & inserts? or reads?
Answer: Note that you can specify nolock on a per table basis.
I typically used nolock in complex SELECT queries, but only for the little lookup tables that almost never changed, and for display-only data.  You know the tables that list the prices for the current half year, or lookups of ids to strings etc. Stuff that only changes with major updates after which the servers are usually restarted routinely anyway.
This improved performance significantly, reduced the chance of deadlock in the busiest times, and more importantly it was really noticable during the worst case moments for queries that touched a lot of tables (which is logical, they have to obtain less locks, and those sidetables are often used nearly everywhere, often decreasing from 7-8 to 4 tables that need to be locked)
But be very careful adding it, don't rush it, and don't do it routinely. It won't hurt when used properly, but it will hurt horribly when used improperly.
Don't use it for highly critical stuff, stuff that calculates etc, because it will get inconsistent, anything that leads to a write sooner or later.
Another such optimization is ROWLOCK, which only locks on row level. This is mainly useful when updating (or deleting in) tables where the rows are not related to eachother, like tables where you only put in log records (and the order in which they are inserted doesn't matter). If you have a scheme that somewhere in the end of an transaction a log record is written to some table, this can speed up considerably too.
If your database has a relatively low percentage writes it might not be worth it. I had a read:write ratio of under 2:1.
Some URLs I saved when working on this:
http://www.developerfusion.com/article/1688/sql-server-locks/4/
Comment: Regarding unfrequently updated tables at read committed level SQL Server can skip taking shared row locks on pages which don't have uncomitted changes anyway. Seems to me `NOLOCK` would give precisely the benefits you mention (faster performance, fewer deadlocks) in the cases where data **is** being updated and you are getting contention.
Comment: A bit late, but that was not what I was seeing. These were really read-only with months between updates.  I did some research, and IIRC it had something to do with row locks (read?) being updates to table locks too quickly in some scenarios that might frustrate other optimizations? But it might also have been simply the sqlserver being old.(MSSQL2005 and one version earlier )
Comment: Instead of NOLOCK, if the goal is to prevent entire table lock, then can ROWLOCK be used with SELECT?
Answer: There are four transaction isolation levels in SQL Server:

READ UNCOMMITTED
READ COMMITTED
REPEATABLE READ
SERIALIZABLE

For the tables it's applied to, NOLOCK is the equivalent of "read uncommitted".  That means you can see rows from transactions that might be rolled back in the future, and many other strange results.
Still, nolock works very well in practice. Especially for read-only queries where displaying slightly wrong data is not the end of the world, like business reports.  I'd avoid it near updates or inserts, or generally anywhere near decision making code, especially if it involves invoices.
As an alternative to nolock, consider "read committed snapshot", which is meant for databases with heavy read and less write activity.  You can turn it on with:
ALTER DATABASE YourDb SET READ_COMMITTED_SNAPSHOT ON;

It is available for SQL Server 2005 and higher.  This is how Oracle works by default, and it's what stackoverflow itself uses.  There's even a coding horror blog entry about it.
P.S. Long running queries and deadlocks can also indicate SQL Server is working with wrong assumptions. Check if your statistics or indexes are out of date:
SELECT
    object_name = Object_Name(ind.object_id),
    IndexName = ind.name,
    StatisticsDate = STATS_DATE(ind.object_id, ind.index_id)
FROM SYS.INDEXES ind
order by STATS_DATE(ind.object_id, ind.index_id) desc

Statistics should be updated in a weekly maintenance plan.
Answer: Use nolock as a last resort. Most deadlock problems can be fixed by tuning the queries and/or tuning the indexes. I think I've seen one deadlock in the last 5 years that couldn't be fixed by tuning one of the two.
Also note that NOLOCK is only honoured on select statements. Data modifications will always lock, that behaviour cannot be changed. So if you're got a writer/writer deadlock (quite common), no lock won't help at all.
Also be aware that nolock, in addition to returning dirty data can result in duplicate rows (rows read twice from the underlying table) and missing rows (rows in the underlying table that weren't read at all).
Nolock essentially means to SQL Server 'I don't mind if my results are slightly inaccurate'
Snapshot isolation is an option. Just make sure that you test carefully first as the increased load on TempDB can be quite severe, depending how frequent and long your transactions are. Also note that while you won't see deadlocks in snapshot isolation, you can get update conflicts. Again, test and make sure that your apps work properly and can handle any errors that they get.
Comment: Duplicate and missing rows (due to Index order change) can also be caused by the normal read committed isolation level. So this isn't problem specific to nolock.
Answer: Use it when it is acceptable to have dirty reads and phantom records I.e you may have non critical reports running regularly where the accuracy of the information is not a primary driver but having a view on volume of records is, or some other metric, for example
Comment: The fall out of failed transactions can be pretty bad too. If you study nolock, you are not in the ideal situation to begin with.
Comment: Phantom read is also caused by the normal read committed. So this isn't a problem specific to nolock (read uncommitted)
Answer: You should use nolock when it is ok to read dirty data. A large transaction that may make a number of changes to the database may still be in progress, using nolock will just return the data it has set so far. Should that transaction then rollback the data you are looking at could be wrong. Therefore, you should only use it when it doesn't matter that what you get back could be wrong.
Deadlocks are a common problem, but 9 times out of 10 are entirely caused by a developer problem. I would concentrate on finding the cause of the deadlocks rather than using nolock. It is more than likely just one transaction doing things in a different order to all the others. Fixing just that one may make all  your issues vanish.
Comment: Could you little elaborate "It is more than likely just one transaction doing things in a different order to all the others. Fixing just that one may make all your issues vanish."? This would be very helpful.
Answer: For a transactionally consistent view without read locks recommend enabling snapshot isolation in SQL Server.
This is slightly different than NOLOCK in that when you read information the results always reflect a version of committed data rather than the possibility of viewing uncommited data.  This provides the same locking concurrency as NOLOCK (no "read" locks) with clearer results.
One should always keep in mind even with transactional consistency the data you then go on to display or use at the time of it being displayed can possibly be wrong or outdated anyway.  I've seen too many people assume that if they use the data fast enough or if they use it within a query/transaction that it's OK. This is absurd -- it is my opinion repeatable consistency levels should never have been implemented in the first place as it just encourages bad behavior. They do not exist in Oracle.
Personally I'm fond of disabling locking for certain non-critical data views and reports as it puts less of a load on the system and the small proboablitiy of providing slightly inaccurate results is not an issue.
Taking advantage of repeatable read consistency levels and committing sins such as holding open transactions for user input might be a little easier on the developer in terms of initial development but will almost always lead to major road"blocks" to any hope of reasonably scaling your application.
My view is the best approach is always to "double check" conditions that still must be true in order to apply updates to any data.
Bad:
UPDATE myaccount SET balance = 2000

Better:
UPDATE myaccount SET balance = balance + 2000

Better still:
UPDATE myaccount SET balance = 2000 WHERE balance = 0 AND accountstatus = 1

Finally the application must check row count to make sure the expected number of rows were actually updated before presenting success feedback to the user.

When is it appropriate to use NOLOCK?


How to make closest possible to $n$ equidistant points in $\mathbb{R}^3$?

Question: Given $n$ points in $\mathbb{R}^3$, the most exactly equidistant points we can have is $n=4$. I was wondering for larger cases how to construct the closest possible situation to having all points equidistant. I was thinking of maybe having one point be the center of a sphere, and then the other points being on the surface of the sphere and being approximately mutually equidistant from each other. I'm not sure if this is the right idea, but even if it is I'm not sure exactly how to execute it. Any help would be appreciated.
Comment: The approach you mention for scattering them on the surface of a sphere can work (approximately) for each point to be the same distance from its neighbors.  You will still have pairs of points the diameter of the sphere apart.  An example would be the $20$ points of an icosohedron.  Maybe you would prefer distributing them in volume, which can reduce the discrepancy between maximum and minimum distances.  You need to specify what you want.  Then it becomes a packing problem and those are hard.
Comment: My first intuition is probably an ugly one one to implement, but here it is.  You're looking to minimize the sum of the pairwise distances between each of your points.  So,   calculate the n choose 2 distances as a formula in n variables (each 3 dimensional, so more like 3n),   then minimize that function.  Have fun! :).  I'm sure there's a better approach
Comment: @RossMillikan To specify, I was either thinking of having all points satisfying $d-\epsilon \leq \|x_i-x_j\|\leq d+\epsilon$ or having most points satisfying that property for a smaller $\epsilon$ and then a couple points can be further away
Comment: @Alan So like minimizing $\sum_{i\neq j} (\|x_i-x_j\|-d)$?
Comment: @user655866 Yep.
Answer: One sensible way to interpret your question is given $n$ points in the plane, what is the maximum number of pairs of points with distance between $d-\varepsilon$ and $d+\varepsilon$ between them? For $\varepsilon =0$ this is some discrete geometry problem that I would not know how to solve. But for $\varepsilon > 0$, I present the following possibly tight construction. Simply place four tight groups of points of size $n/4$ on the four vertices of a regular tetrahedron. Then $3/4$ of the pairs have the desired distance.
Answer: I do not think, that I understand your problem yet but I'm going to give it a try. But first, let us verify a bunch of stuff. Let $P^{(1)},\dots,P^{(n)}  \in \mathbb{R}^3$

What do you mean with distant? Assuming it would be the standard metric in $\mathbb{R}^3$, then let denote it by
$$ \left\lVert P^{(i)} - P^{(j)}\right\rVert = \sqrt{x^{(i)}x^{(j)} + y^{(i)}y^{(j)}+ z^{(i)}z^{(j)}} \qquad \text{ where } x,y,z \in \mathbb{R} \qquad \text{ for } i,j = 1,\dots, n$$
What do you mean by equidistant? Does it mean - for some constant $c \in \mathbb{R}$
$$  \left\lVert P^{(i)} - P^{(j)}\right\rVert = c \qquad \forall i,j = 1, \dots n $$
If this is the case. Then with $n = 2$ the points will make a segment, $n =3$ is a quilateral triangle and $n = 4$ is a triangular pyramid with all equilateral triangle. We can think of a way to generalize this for the case $\mathbb{R}^d$ by elaborating about the construction of equaliteral triangle but not with the sphere. The reason we can't use a sphere is, because the diameter is always twice the radius, thus any two points lying opposite to each other always have  a greater distance than that towards their neighbor. Instead one can guesses, that the figure as the result of the complete graph from all these points, may be shaped by a bunch of equiliteral triangles.
Comment: Yeah, this is pretty much what I was asking in the question. So are you saying to just put a bunch of equilateral triangles together for larger cases?
Comment: It is but an intuition. Since we have to generalize and define the concept of "just put a bunch of equilateral triangles together", which is not easy to achieve. To begin with, you cannot even imagine such a shape in $\mathbb{R}^4$ anymore. So you have to seriously put your hand deep in geometry (especially complex projective geometry).
Answer: Probably the simplest approach is to place your points in a hexagonal close packed array with outer envelope about a sphere.  It is like the centers of a bunch of tightly packed spheres.  Each point is the same distance from its neighbors and roughly speaking the maximum distance between any two points is the diameter of the sphere.  I suspect this is about the best you can do if your criterion is the ratio of maximum to minimum distance.  For small numbers of points there will be perturbations.  Packing problems are hard.


Is it compulsory for a linear regression analysis that a dependent as well as independent variable have equal variance?

Question: The literature suggests that we need to have dataset that meets the condition of homoscedasticity. However, it seems that such a condition is not proper.
Answer: The classical linear regression model is
$$Y_i = \beta_0 + \beta_1 X_{i,1} + \cdots + \beta_m X_{i,m} + \varepsilon_i$$
where the $\varepsilon_i$ are independent $\mathrm{normal}(0,\sigma^2)$ variables. The homoscedasticity requirement is a part of the condition on the $\varepsilon_i$, that they all have the same variance $\sigma^2$. This translates to the $Y_i$ having equal variance $\sigma^2$ given the $X_i$, i.e., the $Y_i$ at one value of $X$ has the same variance as $Y_i$ at another value of $X$. This does not imply that the sample variances of the dependent variable and independent variables are equal.
So no, homoscedasticity is a condition only on the dependent variable.
Comment: The residuals cannot all have the same variance, yes, but the $\varepsilon_i$ are the errors, which are assumed to be iid. The residuals are the observed values minus the fitted value, which is different from the errors, the observed values minus the unobservable true means of the $Y$ at the given value of $X$.
Comment: Residuals cannot "all have the same variance" for example, a not-randomly selected grouping of the 10 residuals closest in value will have lower variance than the 10 residuals most spread out across the range of residuals. Homoscedasticity is specifically the point that variance in *Y* is constant across values of *X*.
Answer: I don't know if this should go in a comment instead, but I wanted to point the following out:
Under the Gauss-Markov assumptions, the OLS estimator is the best linear unbiased estimator. Here, "best" means minimizing variance. However, if we deviate from the assumption of homoskedasticity, i.e. a constant variance on the errors, the following happens

OLS is still unbiased.
It is no longer the minimum-variance estimator, i.e. it is inefficient.
The estimate of the variance of the coefficients - $\hat{V(\hat{\beta})}$ becomes biased, which means that our standard inferential techniques - the $t$ and $F$-tests - becomes invalid.
Comment: @Alexis, that an estimate is wrong in a given sample does not imply that the estimator is biased. Consider a case, where we have a single outlier with much high variance: sometimes, this will lead to $\hat{\beta}$ being higher than $\beta$, sometimes lower. However, *on average*, it shouldn't make it differ (thus the unbiasedness).
Comment: @Alexis: "bias" is a characteristic of an estimator, not an estimate. Wiki has a good summary at http://en.wikipedia.org/wiki/Bias_of_an_estimator
Comment: That really clarifies... *bias* is one of those words with so many definitions.
Comment: But doesn't Anscombe's famous example illustrates precisely why $\beta$ itself is biased by heteroscedasticity? In his article the *entire* slope is defined by high-leverage (outlier on $x$ plus low variability on $y$); there is clearly zero slope for the vast majority of the data.
Answer: You misunderstand homoscedasticity. Y and X can certainly have different variances in ordinary least squares (OLS) regression. The homoscedasticity assumption simply means that variance in Y is constant across different values of X.
See Anscombe, F. J. (1973). Graphs in statistical analysis. The American Statistician, 27(1):17–21. For a good run down on this and three other OLS regression assumptions (he doesn't go into visuals on the independently and identically distributed assumption... no random walks, but it's a great introductory read).


A const big array needs to be initialized

Question: I have a static array of doubles inside my class, and I would like it to be const, but I need to initialize it somehow. What is the best way of ensuring that it will be "const" after the constructor returns?
class DFTDriver {
public:
    static const size_t tblsize = 16384;
    DFTDriver() {
        for (unsigned i = 0; i != tblsize; ++i) {
            sintbl[i] = std::sin(i * TAU / tblsize);
            costbl[i] = std::cos(i * TAU / tblsize);
        }
    }
private:
    static double sintbl[tblsize];
    static double costbl[tblsize];
};

I know I need a computation to initialize them, so it wouldn't be reasonable to ask them to be const; however, the array is clearly "semantically const".
I see that here there is an answer if I am initializing a vector instead of an array. Is it possible to use a similar approach?
I would like to be able to do it without appealing to new C++11 constructs, but if it's not possible, then let C++11 do it.
Comment: If it's static... why are you initializing it in the constructor (i.e a non-static function)
Comment: You don't make it const after initialization. You declare it const which means your only chance of deciding its values is at initialization. And btw, main is the wrong place to do that. P.S: I would suggest you use vector and follow the technique in the question you linked.
Comment: You can use an initializer list just like any other array in the definition. You'd have to compute the values, though.
Comment: That's right, I should be initializing it in the main() function, or something like this. Any way, my question remains, how to make them "const" after the "initializion" (which looks like an assingnment, but should be an initialization) ?
Answer: Make a program to generate the tables
FILE * file = fopen( "sintbl.cpp", "w" );
fprintf( file, "const double DFTDriver::sintbl[] = {\n" );
for (unsigned i = 0; i != tblsize; ++i) {
    fprint( file, "  %f , \n", std::sin(i * TAU / tblsize) );
}
fprintf( file, "};\n" );
fclose( file );

And then compile the generated file and link it into your program.
Comment: .. and you can run this generator program within your build system. An example for CMake: http://www.cmake.org/cmake/help/cmake_tutorial.html#s5
Answer: I know that a lot of people here would love to vote down my answer, nevertheless I hope they will think a bit before doing so.
Maybe this problem is exactly the case when simple casting should be used. The data field should be declared const. This will guarantee that it will not be accidentally changed somewhere. You should allocate non const pointer in your initialization function and point it to your data. Do casting, add detailed comment with explanation why you are doing this and you will be fine. Pros:

The code will be absolutely clear;
It will run without trouble on any platform/compiler;
Casting will be just in one place that is not likely to be changed.

p.s. I would recommend adding static instance of your class and making your ctor private. This will guarantee that the ctor will be called in the very beginning:
class DFTDriver
{
private:

    DFTDriver() { .... }

    static DTFDriver inst;

    static double sintbl[tblsize];
    static double costbl[tblsize];
};

The other answer with generated source also makes sense although the code will be more difficult to maintain.
Answer: This should work
class DFTDriver {
    template<class ElementType, size_t size>
    struct Buffer
    {
        Buffer(ElementType(*initializer)(size_t i)) {
            for(size_t i = 0; i < size; ++i) {
                data[i] = initializer(i);
            }
        }
        const ElementType operator[](size_t i) const {return data[i];}
        ElementType& operator[](size_t i) {return data[i];}
        ElementType data[size];
    };
    double initSinbl(size_t i) {
         return std::sin(i * TAU / tblsize);
    }
    double initCosbl(size_t i) {
        return std::cos(i * TAU / tblsize);
    }
public:
    static const size_t tblsize = 16384;
private:
    //initSinbl and initCosbl can be replaced with lambdas in c++11
    static const Buffer<double, tblsize> sintbl(&initSinbl);
    static const Buffer<double, tblsize> costbl(&initCosbl);
};


Creating Evernote Note from the command line

Question: Is there a way to create a Evernote note from the command line? At best I would like to be able to edit the same note later via the command line as well.
Answer: You can also use the Evernote Scripting command (ENScript).  I have the following in a batch file for adding a short note:

echo %* | c:\PROGRA~2\EVERNOTE\EVERNOTE\ENSCRIPT.EXE createNote /i %1 /t SHORTNOTE

This will create a note with the first parameter being the title, and the title and the remaining parameters go into the note.
Answer: You can try out http://geeknote.me/.
Geeknote is a command line tool for manipulating evernote. You can creating notes, list notebook, search notebooks etc.
I also has a feature to sync files a directory of text files with evernote.
Comment: Next Paragraph: "Geeknote is written in Python, so you can use the open source package anywhere you have Python, even in Windows if you like."..
Comment: Note that it's note Windows compatible.
Comment: @Isaac Kleinman, (assuming you mean not) I don't think that is correct. Its written in python, so I see no reason why it should not run on windows.
Comment: Freudian slip ;)
Comment: The README says "Geeknote is a command line client for Evernote that can be use on Linux, FreeBSD and OS X" but I guess perhaps that means "_even_ on Linux, FreeBSD and OS X"?


A tick box "same as home/primary address" when submitting Event/Contribution from Admin using paypal pro. way to fix it?

Question:
Although selected contact has an address in his profile (But No Billing address). It would be useful to have a tick box saying "same as home/primary address", admin doesn't need to type in all the info again. Can anyone suggest how to do it in a quick way?
Comment: CiviCRM thinks you need a street address because some credit card companies require it; if your CC processor is one of those (I've never hit one myself), then omitting the values might fail submission.
Comment: Thanks. But my point is how to prefill the address & name info in the billing block. As we can see from the form street address is mandatory filed for paypal pro.
Answer: You can remove the requirement of those fields using hook_civicrm_buildForm() - see CiviCRM hook reference
Here's an example from a couple of years ago, although this was written for user-facing forms:
/**
 * Implements hook_civicrm_buildForm().
 */
function example_civicrm_buildForm($formName, &$form) {
  switch ($formName) {
    case 'CRM_Contribute_Form_Contribution_Main':
      $fields_not_required = array(
        'billing_first_name',
        'billing_middle_name',
        'billing_last_name',
        'billing_street_address-5',
        'billing_city-5',
        'billing_state_province_id-5',
        'billing_postal_code-5',
        'billing_country_id-5',
      );
      foreach ($fields_not_required as $field) {
        $form->_paymentFields[$field]['is_required'] = FALSE;
      }
      break;
  }
}

Comment: sorry, if my question was not clear. I am not trying to avoid entering the address data, rather want to prefill from the existing address of contact profile.
Comment: The code above doesn't do what you want then, but perhaps you could build on it to pre-fill the data as you desire instead of changing the field's required setting.
Answer: What version are you on - I just checked a 4.6.6 site & a contact with a home address (only) is getting the prefill - although if you change processor that form is not prefilling. (there is an open ticket about that )
Comment: Thanks Eileen, I am on 4.6.6. and you are correct it prefills the name &  address data if I go from person's profile > Contribution > Submit Credit card contribution. it works, Even that person only has home/primary address & NO billing address.
However it does not work if used the link from the left CREATE NEW> Contribution> Contribution (credit Card). Bug may be!!??
Comment: can you also please post the link of that open ticket you are talking about?


Alfred keeps asking for Contacts permission

Question: I'm not sure what is going on. Every time I access Alfred, I get this dialog box, "Alfred would like to access your contacts." I always have to click "OK" before I can use the program. I have verified that the Alfred checkbox is checked in the Contacts settings in System Preferences. Does anyone have any other ideas?
Comment: You may want to consider asking the question here http://www.alfredforum.com/forum/2-v2-discussion-help/
Answer: Just like @nobody-in-particular said, your Alfred code was probably changed, therefore the signature that was in place for Alfred is no longer valid. What you have to do is sign the application after the changes to the code.
This worked for me:
sudo codesign --force --deep --sign - "/Applications/Alfred 2.app/Contents/Frameworks/Alfred Framework.framework/Versions/A/Alfred Framework"

Comment: still working on alfred 3. change app name like that : sudo codesign --force --deep --sign - "/Applications/Alfred 3.app/Contents/Frameworks/Alfred Framework.framework/Versions/A/Alfred Framework"
Answer: Are you running Alfred version 2.1.1?
If you open Alfred Preferences and check the Features pane you can click on Contacts and try toggling 'Open Contacts in Alfred'.
You might also try checking the Workflows pane and see if you have any workflows using Contacts.
Answer: Is your copy of Alfred properly licensed, or pirated?  I'll admit that mine was pirated, and the newest cracked version kept asking for contacts, presumably because the code signing required for the Mac Store also applies to contact permissions.  If the code is changed (which it is in the cracking process) Apple's contact permissions API will need to continually ask for permission, since it doesn't recognize the program.  You might try Quicksilver instead; it's like Alfred but free and does more, although it's also more complicated and less shiny.
Answer: Try running these commands in Terminal:
sqlite3 ~/Library/Application\ Support/com.apple.TCC/TCC.db
sqlite> INSERT or REPLACE INTO access values ('kTCCServiceAddressBook','com.runningwithcrayons.Alfred-2', 0, 1, 0, NULL);
sqlite> .exit

Comment: As l'L'L put it, please provide an explanation or reference of these commands that you are asking the OP to enter so that your answer becomes more credible.
Comment: what's that do?
Answer: You might want to look into Privacy Services Manager coming out of the University of Utah: https://github.com/univ-of-utah-marriott-library-apple/privacy_services_manager
Once you're set up, Terminal command: privacy_services_manager.py add contacts /Applications/Chess.app


TSQL Agent jobs owned by users

Question: I'm new to Brent Ozar's sp_blitz and am trying to do some cleanup in my new job.  I get tons of security findings about agent jobs owned by users.  Most of these hits are system-type accounts (reportexec, webexec, sqlservice), rather than employee-associated accounts.  Is there a problem with this approach?  I'd love to reduce the number of hits I'm getting with sp_blitz, but am not sure it's worth changing some of these things that were purposely set up like this.  Thanks for any help.
Answer: You should be fine as sp_blitz will highlight if jobs are owned by users since if their login is disabled or not available due to Active Directory problems, the job will stop working.
you can create your skip table and specify that to the sp_blitz <code>@SkipChecksTable</code> to skip checks.
BTW, sp_blitz is on github and you can view the code as well.
Comment: Thanks!   What is sp_blitz expecting the job ownership to be (where it wouldn't complain) ?

TSQL Agent jobs owned by users


That assembly does not allow partially trusted callers although the zone is fully trusted

Question: Since yesterday, I receive a security exception when I want to run a unit-test from within VS.NET 2008.
The error goes like this:
SecurityException: that assembly does not allow partially trusted callers
...
The assembly that failed was : file:///S:/MyProject/MyAssembly.dll

The S: drive is a mapped drive which points to a physical location on my disk.
What I find very strange, is that this used to work for months previously.  I mean, I did this all the time.
In order to get this to work, I 've created a new security zone with the caspol utility in order to give this S: network share drive FullTrust.
In other words, when I run
caspol -m -lg

I see this (I removed the other zones for the sake of brevity):
1.2.  Zone - Intranet: LocalIntranet
   1.2.1.  All code: Same site Web
   1.2.2.  All code: Same directory FileIO - 'Read, PathDiscovery'
   1.2.3.  Url - file://R:/*: FullTrust
   1.2.4.  Url - file://S:/*: FullTrust
   1.2.5.  Url - file:///S:/*: FullTrust

I've added the 1.2.5 zone just recently because the error that was given, mentionned file:///s:/....
Any ideas ?
Could it be that this has something to do with the installation of VS.NET 2010 or the .NET Framework version 4.0 ?
Answer: Try adding
<configuration>
  <system.web>
    <trust level="Full" />
  </system.web>
</configuration>

to your web.config.
Comment: It's not a web project, so i have no web.config. :)


Azure App Services - is it possible to unbind webapp from shared IP address?

Question: Good day,
As we know, creating IP based TLS binding (contrary to SNI binding) allocates a dedicated IP address to App Service webapp.
But it still remains accessible via the IP shared with other webapps (including webapps of other customers).
In some situations I'd prefer to allow traffic via the dedicated IP only, blocking traffic via the shared one. Is it possible somehow to unbind the webapp from the shared endpoint?
(Why would I prefer this? Let's say, I place a some WAF-as-a-service in front of this app, so it would inspect the traffic. I can use Access Restrictions to limit access to my app for WAF address ranges only, but this won't help, if an attacker opens an account on the same WAF and points his own site to my IP. A remedy for this - the WAF service can register this IP as dedicated for my account, so other WAF users won't be able to point their sites to it. But, of course, I cannot do this with the shared Azure IP, because then legitimate WAF users having sites on Azure App Services will be affected).
Thanks,
Mucius.
Answer: Apparently, it's cannot be done without additional components.
But if I do this:

place Application Gateway or some firewall on a IaaS VM  (or even some plain VM with port forwarding enabled) in a VNET subnet,
bind my webapp to the same VNET,
use "Access Restrictions" to
allow traffic to my webapp only from Gateway's subnet,
attach NSG to this subnet and use it to allow incoming traffic from CDN's ranges
only,
and the point the CDN to public IP of this Gateway -

then this
   problem is solved, since Gateway's IP is not shared with other
   customers.


A/C shuts off periodically; switch off and back on and will work again

Question: My Volvo XC90 runs well but periodically its A/C will shut off. I turn off the a/c for 30 seconds, then turn back on and seems to work well again. Could this be a compressor issue? Someone mentioned a low level of refrigerant?
Comment: How long between having to turn it off?
Answer: Does the air blow cold?  When refrigerant gets low air blows hot.  You can always buy a can of refrigerant with the installation nozzle, check the pressure and if low fill or if not return for refund.  This should help you start to diagnose your problem and check possibilities off the list.
From my experience the heater/ AC controller can go bad, swapping with a new controller deck in the dash fixes the problem.  Sometimes the AC fan overheats on import vehicles.  This causes the fan to shut off and the AC turns off as a result.  The fan will usually become louder as it gets closer to the end of its life.   Also the compressor will not kick on until there is enough pressure in the system as a safety feature to stop the compressor from failing due to lack of refrigerant or lubrication.  Even if the compressor kicks on but it blows hot, usually means low refrigerant level.  Hope this helps


Is the second part of dialogue capitalized or not?

Question: i.e. "It is important," his mother replied, "(a/A)nd we will all have a great time."
Comment: Since it's a report of a dialogue, it depends on what his mother actually **said**. That is, did she say "It is important. [full stop intonation] And we will ...", or did she say "It is important, [comma intonation] and we will ..."?
Answer: "Not unless the second part of the quote starts a new sentence," J.R. said. "In that case, you'd start with a capital letter.
"However, if both halves are part of the same sentence," J.R. continued, "then the second half begins with a lower-case letter."
See Rule 4 at the Purdue OWL:

If a direct quotation is interrupted mid-sentence, do not capitalize the second part of the quotation.
  "I didn't see an actual alien being," Mr. Johnson said, "but I sure wish I had."
Comment: But if a direct quotation is interrupted at the end of a sentence, capitalize the second part of the quotation. And the difference depends on the intonation.
Comment: ahh. just needed a clear-up.


Where should i post question

Question: I am very new to this site.Please can any one tell me where can i post my questions.I am trying using "Ask Question " link but it does not post my question and just gives suggested questions.
Comment: You just asked a question. It seems to have worked. What is the issue?
Comment: I think there is a button on the bottom of that page you need to click. I'm searching for the question that showed exactly what to do, but I've had no luck yet.
Answer:
just gives suggested questions.

That is a default setting. When you type the subject of the question it lists all the question which matches your question so that if your question has been already been answered then you can save all the trouble of asking a duplicate question.
See this screenshot

I would recommend visiting those suggestions if you see a match. And still if you do not find what you are looking for then ignore those suggestions and give a unique subject to your question, describe your question and then click on Post Your Question like you did for this question. :)
Comment: The screen for new users in SO is different than that.
Comment: @RalZarek: It could be but it still gives the same suggestions when you ask a question.
Answer: This is the site users with less than 10 rep are seeing when trying to ask a new question:
Check the Checkbox then click "proceed".
Comment: Now i got it.Thanks every one.

Where should i post question


Dependence of intensity of a LED on forward bias voltage

Question: Due to increase in forward bias voltage, the intensity of light increases but after a particular value the intensity decreases. Why?
Comment: I think that the intensity will rise up to a maximum voltage and after that increasing the voltage will not have any effect on the intensity. This may help you-http://www.isb.ac.th/hs/jop/vol2iss2/Papers/LED.pdf
Comment: Did you observe it yourself ? Read it somewhere ? Please mention from where you are getting this observation !
Comment: Depends a bit on how the LED is constructed.  The commercial manufacturers of LED lighting have dumped rather a lot of R&D money (directly and thru University grants) into finding ways to avoid this self-quenching problem.
Comment: @rijulgupta I have given the link.
Comment: The data I got was included the graph during normal operating mode.That's why it is linear. So, it doesn't answer the question but anyway Sir Olin Lathrop has given a nice answer.
Answer: The light output of a LED is pretty linear with the current through it, over its normal operating range.  Light does usually drop off from linear with current at the high end.  Sometimes that high end is not included in the normal operating range, so the graph you see in the datasheet will be linear.  Common T1-3/4 20 mA indicator LEDs are usually linear over their 0-20 mA operating range.  LEDs for lighting are pushed harder and operated closer to the limits, so you usually do see a smaller increase in light for the same current increase at high currents.
Note the D in "LED".  These things are diodes.  That means voltage will change little as a function of current.  However, that also means the current can change drastically as a function of voltage.  Furthermore, there is enough variation in forward voltage from part to part and due to temperature that you can't pick any one voltage to run a LED at.  Basically, LEDs should only be driven with controlled current, letting the voltage come out to whatever it comes out to.  Don't drive a LED with a fixed voltage.  You are asking for thermal runaway, and there is no way to pick the correct voltage up front to get anywhere near the maximum light outut.
Therefore, asking why strange things happen when you force a particular voltage accross a LED is pointless.  It is very easy to operate it outside its specified range by doing that, so there is no longer any guarantee what the device might to.  Most likely, you overstressed the LED to the point that it had too much current thru it.  That makes the die very hot, and can cause decreased light output and often cause a noticable color shift too.  At that point the LED is on the edge of total failure, and has probably been irrevesably damaged.  If you go back and measure its efficiency at intended currents, it will probably be lower than what it was originally.
Comment: @rijul: There are many ways to drive something while controlling the current more than voltage.  This is really a EE question, not about physics.  Just a sufficient resistance in series with a voltage source is one common way.  There are many.
Comment: Nice answer, just solve one query of mine, maybe add in the answer, hos does one run LED without fixing voltage and fixing current ? In normal circuits aren't the tok interdependent ?
Answer: Well LED internal quantum efficiency is highly temperature dependent, and generally even at CONSTANT CURRENT drive, the light will fall off at a higher junction Temperature.
Older technology, gallium arsenide phosphide (GaAsP) red LEDs generally are fairly linear with current (light output), and usually more efficient at higher currents, AT A CONSTANT JUNCTION TEMPERATURE.   This occurred, because there were significant non-radiative recombination currents, which lowered efficiency at lower current densities.  So those LEDs benefit from high current short duty cycle pulsing, which keeps the junction temperature down, but operates the LED at its higher efficiency higher current condition.
Modern gallium nitride LEDs, don't exhibit the same behavior and generally don't work better at higher current densities, and lower duty cycles.
So if you increase their current, and let them get hot, the light will go down.  GaN material is a very high temperature semi-conductor, so the higher junction temperature operation won't necessarily kill the diode.
The older LEDs would die under this condition, because the 1 mil gold bond wire (or aluminum) will melt.    Gan LEDs usually aren't wire bonded, so don't have that problem.


Asking for DSL Router password instead of showing my site when trying to connect to apache server?

Question: I'm trying to access an apache server hosted on my PC typing it's IP on my 3G notebook, but the browser is asking for the DSL Router password instead of showing my site. Weirdly, my friends can access my site from their computers. I have already accessed the router (a comtrend) and added port 80 to "NAT -- Virtual Servers Setup".
Answer: 'Sounds like you're typing in the IP address of your router instead of your PC.
Look at "ipconfig" in a command prompt (I'm guessing you're probably on Windows: otherwise type "ifconfig") to get your host's actual IP address.
Or take your notebook off your LAN (e.g. take it to a Starbuck's or something) and access your PC from an external network (like your friends are doing).


GPS for Raspberry Pi, which product is better in terms of technical specification and compatibility with Raspbian?

Question: I'm looking around for a GPS receiver and found 2 product that is frequently recommended; Adafruit Ultimate GPS and GlobalSat BU-353. In terms of technical specification and compatibility with Raspbian, which product is better?
Answer: BU-353 is a bit dated, you should definitely choose BU-353-S4 (SiRF4 instead of SiRF3), otherwise, the choice is between a breakout board, that require soldering, cables and enclosure from one side and complete plug-and-play solution from another side.
If you need a GPS to use, drop on your car roof and forget -- you should choose BU-353-S4, but if you prefer to solder things and play mostly indoors (why you need GPS indoors anyway?) -- then get one from Adafruit.
Comment: indoor navigation is a huge topic in geodesy and geoinformatics. most approaches work with wifi (!) hotspot triangulation, though, because GPS/GNSS signals are blocked by roofs.
Answer: gpsd (the GPS linux driver) does not work with the BU353-S4 in default binary mode (unless it has been fixed recently)... you have to switch it to NMEA with gpsctl -n (gpsd GPS control), actually it took me several days to figure that out. I'm not happy that SIRF binary mode doesn't work with gpsd.
The Adafruit works with gpsd NMEA Mode it has no binary mode. It also has 1pps for making your own NTP server for a laugh. It also picks up the Japanese QZSS satellites.
The S4 is magnetic suitable for attaching to a car... the Adafruit requires some soldering and the correct TTL to 3.3V level shifting usb cable or it can be connected to the GPIO ports directly. The adafruit is not weatherproof.
So for indoor projects and learning the Adafruit. If you're installing in a car as a tracker device then the S4 - as earlier answer.
I have both. The S4 was for a pc project and Adafruit for a NTP server on a Pi and other project ideas.


What social class would Marx consider himself a member of?

Question: Marx considers various social classes in The Manifesto of the Communist Party, among them: the bourgeoisie, the proletariat, the middle class, and the 'dangerous' classes of social scum. Marx was in a fairly high position in his life, but I do not believe he would call himself a member of the bourgeoisie. But I'm not sure he could justify himself being a member of the proletariat. Reading through the Communist Manifesto I didn't see him address this, but I admit I may have missed it. So, which class would Marx consider himself a member of?
Comment: As is frequently the case with Marxists specifically and progressives in general, he wanted to see himself as a member of what Russians called "intelligencia" class, but in reality aimed at being a member of ruling class (nobody I'm aware hopes to serve as a janitor in a glorious socialist future).
Comment: @user4012 This is a bad misunderstanding of Marxism and the differences between Marxism and its derivative ideologies like Leninism and Maoism, specifically w/respect to the idea of a vanguard party and the intelligentsia.
Comment: My understanding is that Marx believed that, during his lifetime, capitalism was going through a struggle to resolve its own internal contradictions. This struggle was something he saw as an ongoing, dynamical process, and part of the dynamic was that there was increasing polarization of society into two classes, the bourgeoisie (rich getting richer) and the proletariat (poor getting poorer). The end of this process would be a transition to socialism. Since the process was not yet complete, there would be no reason to expect the categories to be so clearcut that he could classify himself.
Comment: @user4012 I'm with Era on this one, Marx never saw himself becoming a leader per-say, but more as another voice to urge the abolition of an inherently unequal system.
Also, your note: "nobody I'm aware [of] hopes to serve as a janitor in a glorious socialist future" is very misleading. Marx and his fellow socialists did not think that people should aspire to menial labour, but that there should instead be afforded full and high educations in the end, and to everyone: I do not recall him saying people should work boring jobs, nor that the intelligencia would be "janitors".
Answer: The bourgeoisie in Marx' class theory was the caste of entrepreneurs which employed people from the proletariat to work for them and increase their capital.
Marx made most of his income as a self-employed writer. So he was neither a proletarian who was exploited by his employer nor an employer who exploited his workers.
However, his writing provided him with enough income to not being required to resort to criminal activity or begging to survive, so he was not a member of the social scum (unless, of course, you consider his writings themselves as criminal activity, as some of his opponents did).
This made him a member of the middle class or "petite bourgeoisie" as Marx called it.
Comment: @jamesqf And it's a good thing he did! This is an example of the apparent contradictions in a Hegelian "dialectic" - only through the free time afforded to the bourgeois could Marx have been able to decide what he worked on, and to use his labour time to study and think about capitalism, thus eventually producing history's most rigorous and impactful criticism of capitalism. This idea of circumstances being the necessary causative precursor to their own antithesis is something Marx himself wrote a lot about.
Comment: For much of his later career Marx seems to have sponged off his wealthy friend & collaborator Engels https://en.wikipedia.org/wiki/Friedrich_Engels and his aristocratic wife https://en.wikipedia.org/wiki/Jenny_von_Westphalen#Marriage
Comment: Note: apparently Marx considered the "petite bourgeoisie" to be one of the main classes who were enemies of the struggle towards communism, and who would be one of the economic losers when it was enacted. He considered them oppressors who would resort to fascism and terrorism to fight communism. https://en.wikipedia.org/wiki/Petite_bourgeoisie#Role_in_fascism
Comment: @Jonathon, it's worth saying that Marx only said the average tendency was such. There are always smaller numbers who deviate from what appear to be their self-interest. Also, the predicted reaction of the petite bourgeoisie was proven spectacularly in Nazi Germany.
Answer: Karl Marx would consider himself a member of the middle class. Marx was fortunate to be born into a wealthy middle-class family in Trier in the Prussian Rhineland. After studying at the universities of Bonn, Berlin and Jena, Marx developed theories about society, economics and politics with the help of his lifelong friend, Friedrich Engels (who was also born to a wealthy family).
Although he had an affluent upbringing, Marx developed philosophical ideas of socialism later in his life, especially after his university education. He first became interested in the ideas of the Young Hegelians, a group of German intellectuals who developed radical left-wing ideas of the Prussian political system. Later, he began to write for several radical newspapers when he met Engels. His radical views against the government caused him to be exiled to London, where he continued writing and formulating theories about social and economic systems, and also campaigned for socialist movements.
It may seem odd that two men born to wealthy families would grow up to write The Manifesto of the Communist Party, but it is not uncommon for people like Marx to stand up for the less fortunate. Marx's thinking can be compared to the "Enlightenment" thinking of the 18th century, in which people of all walks of life developed ideas of a radically different governmental or economic system.
Comment: Marx's theories of class were fundamentally related to the relation of a group to the dominant form of social reproduction. Not a cultural stratification.
Answer: Marx's theories of class are centred in a contradiction between on one hand the emergent economically dominant actual social relations of production; and, on the other hand the limited capacity of humans to describe actuality in theoretical models. For example, in capitalism, Marx describes "the value form" (Capital I, ch1) as the dominant social relationship in his surrounding society which is actively obliterating all prior social relationships by the imposition of wage labour and profit. So for his society Marx views capitalism, as a system of relationships, as both creating the two fundamental class positions: capitalist and proletarian; and the two key actual classes: capitalists and proletarians.
Next to this theoretical summary of a dominant relationship from what relationships Marx actually thinks exist; there are other non-dominant class relationships.  These include bound rent and tithe subsistence peasants. Small cash rent market tenant croppers. Large employing farmers who use premodern brutality on semi-peasants. Stipendiary priests and scholars. Bondage slaves not in modern production. Rentier aristocrats bound up with non-capitalist productive land. Small owner-maker petits-bourgeois who used to work in feudal cities. There are lots of actual class positions, but capitalism reduces these ways of being to wage labour or profiting off capital.
Marx as an individual has two contradictory relationships with class. Firstly he produces information for as a petits-bourgeois household. Second he was a kept man who Engels paid a stipend to, this stipend derived from Engels profit as a factory owner. Marx was simultaneously petits-bourgeois and bourgeois. Marx benefitted from primitive household production for market sale of information. Marx benefitted from profit from control of capital.
Marx according to his own views was thoroughly bourgeois.
Answer: To quote Marx and Marxism by Peter Worsley

Marx, it is true, was not a good manager when he did have money, largely
because of his bourgeois background: servants and piano lessons were
necessities (just as few of his followers, though they claim not to deify him,
admit that he could be quite racist in some of his more spontaneous utterances).
When young, he could enjoy a night out drinking with friends, on one
occasion quite riotously. But normally, he was a quite orthodox Victorian
paterfamilias. He hugely enjoyed family life, outings on Hampstead Heath,
evening poetry-readings and musical entertainments, and could even tell
an unfortunate suitor for his daughter's hand that he should cool his passionate
behaviour and adopt instead 'a manner that conforms with the latitude of
London', whilst haughtily inquiring whether his economic position was
adequate to support his daughter properly. At the end of his life, he was
able to resume a style of life more in keeping with his origins, and attempt
to recover his ruined health by visits to Carlsbad, Geneva, Monte Carlo and
even Algiers (where he shaved off his beard).

In other words, as the other answers have already described, Marx was not a proletarian - neither culturally nor in terms of his position in society and the occupation. What is worth adding however, is that this was the case of many of his collaborators and followers, and they have eventually built a whole theory of revolutionary vanguard, justifying the inclusion of intellectuals who possessed the theoretical knowledge and understanding necessary to wake up, educate and lead the masses:

The Communists, therefore, are, on the one hand, practically the most advanced and resolute section of the working-class parties of every country, that section which pushes forward all others; on the other hand, theoretically, they have over the great mass of the proletariat the advantage of clearly understanding the lines of march, the conditions, and the ultimate general results of the proletarian movement. The immediate aim of the Communists is the same as that of all other proletarian parties: Formation of the proletariat into a class, overthrow of the bourgeois supremacy, conquest of political power by the proletariat.

This logic would eventually culminate in the concept of the leading role of the communist party, as defined by Artcile 6 of the Soviet constitution:

The leading and guiding force of the Soviet society and the nucleus of its political system, of all state organisations and public organisations, is the Communist Party of the Soviet Union. The CPSU exists for the people and serves the people.
The Communist Party, armed with Marxism–Leninism, determines the general perspectives of the development of society and the course of the home and foreign policy of the USSR, directs the great constructive work of the Soviet people, and imparts a planned, systematic and theoretically substantiated character to their struggle for the victory of communism.
All party organisations shall function within the framework of the Constitution of the USSR.

Amending this article in 1990 was considered as a major step in transforming the USSR to a democratic state.


Are we looking at single stars, or solar systems?

Question: When looking at the night sky, the stars we can see just look like single dots. Are they alone in space- each one a single object? Or, when we look at a star, are we actually looking at a distant solar system within our galaxy?
Answer: What we see from the Earth's surface with our eyes are just stars, any planets surrounding them - indeed, entire planetary systems are not visible by the naked eye.
That does not mean that there aren't any planets around those stars, the exoplanets listed in this European based Exoplanet catalogue were detected using much more precise and sophisticated means, listed on NASA's Years of Exoplanets page as:

Doppler shift measurements
Astrometric measurements
Transit method
Direct observation
Gravitational Microlensing

The NASA page also describes why it is not possible to tell if a star has planets from observing with the naked eye:

The challenges of observing extrasolar planets stem from three basic facts:

Planets don't produce any light of their own, except when young.
They are an enormous distance from us.
They are lost in the blinding glare of their parent stars.

Asides from stars, looking up with the naked eye, we may also be looking at galaxies, systems of stars etc. - these would be resolved using instruments, not really discernable with the naked eye.
Comment: Actually, many of the dots in the night sky are themselves galaxies as well, not just single stars.  In addition, most of the stars we can resolve with telescopes are in binary or multi-star systems, thus not alone.
Comment: Have added a bit about that in the answer. I was answering from the point of view of when the OP asked `he stars we can see just look like single dots. Are they alone in space- each one a single object? Or, when we look at a star, are we actually looking at a distant solar system within our galaxy?`
Comment: Certainly the dots people see are not galaxies, just particularly bright and often quite nearby stars. One can see some diffuse galaxies with the naked eye, but only far away from cities (as in, most people on Earth have never been somewhere dark enough to see them).
Comment: Thank you for all the input. I realize that it is impossible to see with the naked eye, but to imagine that there is so much more than just a star when we look up is just unreal!
Comment: Yes, that is a wonder of looking up at the night sky... is to wonder, then discover what we are actually looking at!


Writing Unit Tests Later

Question: I know that TDD style is writing the test first, see it fails then go and make it green, which is good stuff. Sometimes it really works for me.
However especially when I was experimenting with some stuff (i.e. not sure about the design, not sure if it's going to work) or frantically writing code, I don't want to write unit tests, it breaks my flow.
I tend to write unit tests later on and especially just before stuff getting too complicated. Also there is another problem writing them later is generally more boring.
I'm not quite sure if this is a good approach (definitely not the best).
What do you think? Do you code write your unit tests later? Or how do you deal this flow problem or experimental design / code stage.
Answer: What I've learned is that there is no experimental code, at least not working in production environments and/or tight deadlines.  Experiments are generally carried out until something "works" at which point that becomes the production code.
The other side of this is that TDD from the start will result in better design of your code.  You'll be thinking more about it, reworking it, refactoring it more frequently than if you write the tests after the fact.
Answer: I've written tests after the fact. Better late then never. They are always worth having.
However, I have to say, the first time I wrote them before writing the tested code, it was extremely satisfying. No more fiddling around with manual testing. I was surprised just how good it felt.
Also, I tend to write unit tests before refactoring legacy code - which, almost by definition, means that I'm writing tests to test code that's already written. Provides a security blanket that makes me more comfortable with getting into big blocks of code written by others.
Answer: "I'm not quite sure if this is a good approach (definitely not the best)."
Not good?  Why not?
Are you designing for testability?  In that case, your design is test-driven.  What more can anyone ask for?
Whether the tests come first, in the middle or last doesn't matter as much as designing for testability.  In the end, changes to the design will make tests fail, and you can fix things.  Changes to the tests in anticipation of design changes will make the tests fail, also.  Both are fine.
If you get to the end of your design work, and there's something hard to test in the middle, then you failed to do TDD.  You'll have to refactor your design to make it testable.
Answer: I often take the same approach you're talking about. What seems to work well is to treat the exerimental code exactly as such, and then start a proper design based on what you've learned. From here you can write your tests first. Otherwise, you're left with lots of code that was written as temporary or experimental, and probably won't get around to writing tests for all of it.
Comment: I think putting experimental code aside and planning properly with TDD is a really good point.
Answer: I would say that for normal development, TDD works extremely well.  There are cases where you may not need to write the tests first (or even at all), but those are infrequent.  Sometimes, however, you need to do some exploration to see what will work.  I would consider this to be a "spike", and I don't necessarily think that TDD is absolutely necessary in this case.  I would probably not use the actual "spike" code in my project.  After all, it was just an exploration and now that I have a better idea of how it ought to work, I can probably write better code (and tests) than my "spike" code.  If I did decide to use my "spike" code, I'd probably go back and write tests for it.
Now, if you find that you've violated TDD and written some production code before your tests - it happens - then, too, I'd go back and write the tests.  In fact, on the occasions where this has happened to me I've often found things that I've neglected once I start writing the tests because more tests come to mind that aren't handled by the code.  Eventually, you get back in the TDD rythym (and vow never to do that again).
Answer: Consider the psychological tendencies associated with sunk cost. That is, when you get to the second part of the equation, that laziness gene we all have makes us want to protect the work we have already done. The consequences?
If you write the tests first...
You tend to write the code to fit the tests. This encourages the "simplest thing that solves the problem" type development and keeps you focused on solving the problem not working on meta-problems.
If you write the code first...
You will be tempted to write the tests to fit the code. In effect this is the equivalent of writing the problem to fit your answer, which is kind of backwards and will quite often lead to tests that are of lesser value.
Although I'd be surprised if 1 programmer out of 50 ALWAYS writes tests first, I'd still argue that it is something to strive for if you want to write good software.
Answer: I usually write my tests first but sometime while experimenting I write the code after. Once I get an idea of what my code is supposed to do, I stop the code and start the tests.
Answer: VS 2008 has a nice feature that will generate test classes for an object, the tests needs to me tweaked but it dose a lot of the grunt work for you. Its really nice for crating tests for your less then diligent co-workers.
Another good point for this is it help to prevent you from missing something, expectantly when your working on code that isn't yours.
if your using a different testing framework then MSUnitTest, it's fairly simple to convert then tests from MSUnit to Nunit, etc.  just do some copy and past.
Comment: :) That's lovely feature. But unfortunately (or fortunately!) I'm using nUnit
Comment: It takes a little bit of work, but you can convert MSUnitTest to nUnit test with some copy and past.
Comment: oddly enough going back isn't as easy, go figure
Answer: Writing the code first is natural when you're trying to figure out how your code is going to work. Writing the test first helps you determine what your code show do (not how it should do it). If you're writing the code first, you're trying to solve the problem without completely defining the problem. This isn't necessarily "bad", but you are using unit tests as a regression tool rather than a development tool (again, not "bad" - just not TDD).
Answer: I would like to say that I always write Unit tests first but of course I don't (for numerous reasons well known to any real programmer :-)). What I (ok, also not always...) do is to convert every bug which takes me more than five minutes to find into a unit test. Even before I fix it. This has the following advantages:

It documents the bug and alerts me if it shows up again at a later point of time.
It helps in finding the bug, since I have a well-defined place to put debugging code into (setting up my data structures, call the right methods, set breakpoints on etc.) Before I discovered unit testing I modified the main() function for this testing code resulting in strange results when I forgot to remove it afterwards ...
Usually it gives me good ideas what else could go wrong, so it  quite often evolves in a whole bunch of unit tests and resulting in more than one bug getting discovered resp. fixed.

Writing Unit Tests Later


Changing dpi without changing size

Question: I have tiff. files that are 72dpi. In order to put them into my book for publication they have to be 300dpi.  How do I increase the dpi without changing the size of the image.  When I go to PhotoShop and change the dpi the picture of course shrinks. Then when I put it into my document and enlarge it to the appropriate size the dpi goes back down.Is there a way to keep the size but put the dpi at a level the printer wants.
Comment: no way .. Increasing the dpi inversely proportional to the dimensions of the image
Answer: To put it plainly, you can't.
Or rather it doesn't work that way. An image has an existing number of pixels.
When you increase the PPI without resampling, you tell that image to condense the same number of pixels into a "tighter" field. Thus reducing the image size.
If you alter the PPI and use resample the application throws in all the extra pixels needed to maintain the dimensions as well as the new PPI you want. The application decides what pixels it should create. This most often results in an image of less quality.
The best option for you is to use higher PPI images from the start. I do realize this is not the answer you want. Your printer is telling you the images will look horrible unless you use better quality images from the beginning. You can't "repair" or "adjust" low resolution images to magically be high resolution and look the same.
Comment: I found http://www.dpiphoto.eu/dpi.htm to be a rather good guide to questions like that - near the end, the site even mentions the main reason for why there is so much confusion about this.
Answer: It's true you can't upscale the resolution of an image in terms of clarity because the information just isn't there (aside from Photoshop's clever upscaling extrapolation, which can smooth things over a bit).
However, if you just want to change the dpi settings without changing the size of the image (disregarding the resolution of the existing content), it's very easy to do (in Photoshop CC 2015, anyway):
Just click the little gear-looking settings icon in the upper right of the 'image size' dialogue box and you'll get an option to scale styles, which will allow you to change the resolution without changing the size of the image. Check the resample box. Cheers!
Comment: Uhm... "Scale Styles" has *nothing* to do with actual image dimensions as they relate to PPI. Scale Styles, uhm... scales any layer styles. And checking the resample box merely interpolates the image (adds automatic pixels, decreasing overall quality) It is the Resample option that keeps *dimensions* the same... but not the quality.
Answer: I realize that this is an old thread (cudos to the original posters) but I thought I would update it to reflect the innovations that now exist in image software (2022).
I've used Topaz Gigapixel AI to upscale images to as much as 6× with very good results. It won't fix a really terribly low res image, but it works reasonably well with images that aren't horrible, and the results are often shockingly good.
I find it works best in situations where I had to crop so much that the image results in a fairly low res image. The image will typically be OK, but a little "soft" on details. This can easily be fixed.
I also got pretty good results rescuing pics I shot with a much lower resolution camera. I understand that ON1 also has a similar thing, and I'm told it works very well, but I've never used it.
Answer: Create a new document blank at 300dpi. Copy and paste the 72dpi image into this canvas. Crop the canvas to fit. You will have converted the 72dpi image into a 300dpi image without adding any new pixels via the "image size" change option.
Comment: This is no different than just changing the PPI of the original image
Answer: this is wrong. there is a program called irfanview that allows you to resample an image and it also allows you to resize it. resampling an image reduces the number of pixels in an image and resizing changes the resolution of the image even if there are not enough pixels to make up that resolution. I often resample an image by half and then resize by double to improve performance in games I make. Don't misunderstand I don't actually know if there is a way to stretch an image to a new resolution decrease its file size and recover the quality of the original image. that is more computer science. what you can do is in infranview go to auto adjust colors and overcolorate the image. this is for even more extreme decreases in file sizes then ive mentioned in my example. for example if you were to resample an image to 25 percent of its original size you can auto adjust colors to degrade the saturation so when the image dulls due to it being overcompressed the image looks similar to the way it did originally. however resampling by half and resizing only has a slight perceptual decrease in quality of the image depending on your vision. I'm probably partially blind and have a stigmatism but editing images this way doesn't really look that bad to me. it definetly doesn't have the mark of quality you'd get from something like a bluray disc but images can look good this way if the original image was of high quality. It just can't every be modified again. I used the effect with an html5 game that always you to set the resolution of the html5 canvas to 4k and it works just fine but the quality of the image always stayed at the imperfections created in irfanview. beyond that it works really well. I know nothing about photoshop so maybe im not answering your question.

Changing dpi without changing size


'C:/Perl64/bin/' is not recognized as an internal or external command, operable program or batch file

Question: I installed active perl on my win2k12 server, I want to run a perl script but it showing this message,
'C:/Perl64/bin/' is not recognized as an internal or external command,
operable program or batch file.
I change environment variable path like C:\Perl\bin,C:\Perl\site\bin,C:\Perl64\bin.
but what ever path i changed same path is not recognised as an internal or external command.
Comment: How do you run the perl script? By double click or from the command line? Where are your perl binaries actually installed?
Comment: i am running perl by command line. and my perl binaries are on this path C:\Perl64\bin.
Answer: A) the script to be run
a) Slashes
Have a look at the script you want to run.
Most probably, the first line will look like
#!C:/Perl/bin/
or similar. Change the forward slashes to backslashes and try again.
b) Executable
Of course, the shebang above misses the executable binary. So if it is missing from your script, change it to
#!C:\Perl\bin\perl.exe
or
#!C:\Perl\bin\perl.exe -w
if you want to have Perl output warnings.
B) your Perl installation
Have a look at C:\Perl\bin\ and C:\Perl64\bin\ respectively. Do both exist? If not, change the shebang in your script to
#!C:\Perl64\bin\perl.exe -w
C) Alternative
I was assuming that you simply run or double click script.pl. If you want to tell Windows to run that script with a certain application (Perl, in your case), run your script via
C:\Perl64\bin\perl.exe -w C:\path\to\your\script.pl

Comment: thank you !!! I tried this all but its not working. this path I have C:\Perl64\bin\ . In environment variable C:\Perl64\bin;C:\Perl64\site\bin; this both path are there. I tried by changing there sequence. but its showing that  "C:\Perl64\bin" is not recognized as an internal or external command. path is whatever I set first path into environment variable.
Comment: That's interesting. Could you add at least the first couple lines, shebang and included modules of your Perl script to your question? Also, however I am sure that it does not matter, try to add a backslash to the end of the elements in your path: `C:\Perl64\bin\ `. Does your script run with  `C:\Perl64\bin\perl.exe -w C:\path\to\your\script.pl`?
Comment: Does it work as expected meanwhile? Or could you post the beginning of your Perl script here?
Comment: thank you so much you stueja for helping me a lot.my issue is solved.
Comment: Good to hear that.  Feel free to `accept the answer` if I could help you or let me know what else we could try.
Answer: Actually it was an environment variable issue. I was using Oracle 11g r2. and its path didn't have oracle name in it. I am searching "oracle" word from perl script into environment variable, but I was getting the first path which was perl path, so perl was failing to run. The issue is solved. Thank you so much, stueja.


Is it possible to check the connectivity between 2 linux machines by pinging from a third machine?

Question: What is the ping and traceroute command option to use in order to check the connectivity between 2 machines (machine A and machine B) using my machine (machine C) ? How do I specify the source machine IP? ping -S machineAIP machineBIP or ping -I machineAIP machineBIP don't seem to work from my debian 8 machine.
Comment: Hello and welcome to the U&L stack exchange site! Please review the [Help Center](https://unix.stackexchange.com/help) to get information on how to best post to this site. To get to your question, neither of those options in ping do what you wish. Is it possible to connect to one of the servers and complete a ping from there? Depending on your network setup if your machine can ping both servers successfully, barring firewall rules on one or the other, they should also be able to communicate.
Comment: Is [this](https://networkengineering.stackexchange.com/questions/2027/is-icmp-spoofing-practical) what you have in mind?
Answer: While ping allows you to set intermediate hosts, I think you can only do this if the intermediate hosts are willing to accept traffic intended for the destination (i.e., they behave as gateways). See https://superuser.com/questions/311849/how-can-i-ping-via-an-alternate-gateway
In this situation, I'd just use SSH:
ssh machineA ping machineB

Comment: Thanks for your answer but then I can't use this since I'll have to keep track of  the passwords of all the machines I'm going to connect. I thought of running socket io node in machine A and B and then requesting from machine C to source machine(either A or B depending on the machine from where I want to ping) to ping the other machine and give me the result back.


Why use random value when overwriting files?

Question: Often when I see people talking about safe deletion, I see lots of advice's that you should use random values to overwrite. My question is why is it better or more efficient than filling all bytes with 0xFF that put all bits on?
Answer: Multiple overwrite passes with random values were recommended in the 1980s and 1990s, as described in the history recounted by @FlorianBidabe.  Back when data was encoded on disk platters that had physically wide read/write heads and space between the tracks to ensure data isolation, a write head might erase 80% of the magnetic media holding the bit, ensuring the drive's crude electronics couldn't read it.  But these loose tolerances left 20% of the magnetic domain behind, which were exploitable by someone looking to recover data from a disk.  Writing random data instead of all zeroes helped mask the original value of the bit.  It was discovered that multiple passes of writes increased the chances that more of that remaining 20% would be overwritten, giving people more confidence their data was truly unrecoverable.
This recommendation is no longer applicable to modern disk hardware.  The reason is that hard drive manufacturers have been improving manufacturing tolerances to increase the data density on disk drives.  That 80% sloppy write head of yesterday was replaced with more accurate motors, smaller read/write heads, and completely new technology such as vertical recording of magnetic fields.  Today, an encoded field occupies a tiny space of only a few atoms on the platter, which is how manufacturers can get data densities in the range of 2.5 TB/square inch or more.
But no matter how tiny the magnetic fields on the platters have become, drive manufacturers have been incorporating sophisticated computing techniques to improve drive performance and reliability.   These techniques are meant to preserve data, and actually can prevent the secure deletion of data using overwriting techniques.  For example, a drive will reserve an unused fraction of blocks just in case a part of the platter becomes unreliable, and in case of failure it will automatically migrate the data from the bad part of the platter to the good part.  That means it no longer matters if you overwrite the disk with zeros, 0xFFs, or random numbers.  If the sector that went bad used to hold a secret, that secret would never be overwritten by any pattern of wiping.
These continual improvements of hard drive technologies have created the need for more reliable techniques to sanitize disk drives.  Today, cryptographic wiping is recommended.  The data on the drive can be encrypted with a random key stored only in a flash chip on the drive.  To destroy the data, the flash memory is erased and the only copy of the key is wiped out of existence.  With no decryption key available, the encrypted data is securely and instantly destroyed.
For more information on acceptable disk sanitization techniques, I recommend reading the NIST standard 800-88, rev 1.
Answer: Data remanence is the residual representation of digital data that remains even after attempts have been made to remove or erase the data. This residue may result from data being left intact by a nominal file deletion operation, by reformatting of storage media that does not remove data previously written to the media, or through physical properties of the storage media that allow previously written data to be recovered.
The simplest overwrite technique writes the same data everywhere—often just a pattern of all zeros. At a minimum, this will prevent the data from being retrieved simply by reading from the media again using standard system functions.
In an attempt to counter more advanced data recovery techniques, specific overwrite patterns and multiple passes have often been prescribed. These may be generic patterns intended to eradicate any trace signatures, for example, the seven-pass pattern: 0xF6, 0x00, 0xFF, random, 0x00, 0xFF, random; sometimes erroneously[clarification needed] attributed to the US standard DOD 5220.22-M.
Feasibility of recovering overwritten data
Peter Gutmann investigated data recovery from nominally overwritten media in the mid-1990s. He suggested magnetic force microscopy may be able to recover such data, and developed specific patterns, for specific drive technologies, designed to counter such.[2] These patterns have come to be known as the Gutmann method.
Daniel Feenberg, an economist at the private National Bureau of Economic Research, claims that the chances of overwritten data being recovered from a modern hard drive amount to "urban legend".[3] He also points to the "18½ minute gap" Rose Mary Woods created on a tape of Richard Nixon discussing the Watergate break-in. Erased information in the gap has not been recovered, and Feenberg claims doing so would be an easy task compared to recovery of a modern high density digital signal.
As of November 2007, the United States Department of Defense considers overwriting acceptable for clearing magnetic media within the same security area/zone, but not as a sanitization method. Only degaussing or physical destruction is acceptable for the latter.[4]
On the other hand, according to the 2006 NIST Special Publication 800-88 (p. 7): "Studies have shown that most of today's media can be effectively cleared by one overwrite" and "for ATA disk drives manufactured after 2001 (over 15 GB) the terms clearing and purging have converged."[5] An analysis by Wright et al. of recovery techniques, including magnetic force microscopy, also concludes that a single wipe is all that is required for modern drives. They point out that the long time required for multiple wipes "has created a situation where many organisations ignore the issue all together – resulting in data leaks and loss."[6]
Source: https://en.m.wikipedia.org/wiki/Data_remanence
Answer: So not too too long ago this used to be a recommendation. The reason was that Peter Gutmann devised a way to recover (with > 50% odds) the previous state of a bit. Writing all the same values would essential make it possible to reverse the write. The accepted answer on this question has more details.

The origin lies in work by Peter Gutmann, who showed that there is some memory in a disk bit: a zero that's been overwritten with a zero can be distinguished from a one that's been overwritten with a zero, with a probability higher than 1/2. However, Gutmann's work has been somewhat overhyped, and does not extend to modern disks.

It's less of a concern these days.


What is the font used in Sega ads during the 90's?

Question: The font in which the phrase "GENESIS DOES WHAT NINTENDON'T" is written.
I want to use this font for the promotional material for the game I'm going to make. Can't find it anywhere on the internet. Please, help me if you know this!
Comment: In addition to what Ovaryraptor edit at my answer, the last two lines, I annex that the font identifiers by MyFont or Fontsquirrel don't work with distorted fonts. I tried it even by separating the characters. I think the Closing Tag is not applicable in this case.
Answer: Extension RR ExtraBold via myfonts.com

Note that the text in the magazine appears to have its width and spacing altered from the original font.


What factors affects the cold temperatures in high altitudes?

Question: Why it is that high altitude areas are colder than low altitude areas?  Is it because the air pressure or any other?
If we consider it with the sun rays, high altitudes receive sun rays earlier than low altitude so low altitudes must receive rays with less amount of energy relative to high altitude rays. Therefore low altitude must have low temperature. Can any one explain theory behind the scene?
Answer: The principal physical mechanisms in the troposphere, stratosphere, etc are different. Since it's the troposphere where we live, and where weather occurs, let's guess that's what you're asking about.
Then google  adiabatic lapse rate  for the somewhat elaborate thermodynamic explanation that's been exhaustively studied and worked out over the last hundred-plus years.
As often, wikipedia's https://en.wikipedia.org/wiki/Lapse_rate isn't a bad place to start. In particular, note the pretty straightforward derivation from the first law of thermodynamics in the https://en.wikipedia.org/wiki/Lapse_rate#Convection_and_adiabatic_expansion section. The first three paragraphs of that section contain an extremely clear and concise words-only explanation, which is then followed by the corresponding math.
Comment: does gravity affects temprature or not or what else affects. But in Lapse Rate equation there is ' g ' so i dont get it.
Comment: seems like you have knowledge about this matter, so can you please give me explanation for question.
Comment: @user7549997 Gravity affects temperature through hydrostatic equilibrium (as per the link on the page I already pointed you to). Briefly, hydrostatic equilibrium just says that the pressure at any place in the atmosphere is simply due to the **weight** of all the air above it. And weight is $\mbox{mass}\times g$. In other words, if the Earth's gravity suddenly doubled, so would atmospheric pressure. And that would indeed affect the $\Gamma_d$ lapse rate as shown at the bottom of that section. (But the change of gravitational force due to distance from the Earth's center is negligible.)
Answer: Reasons

The greater the altitude, the further the air molecules are from the ground.  This means that there is a weaker gravitational force, leading to air molecules accumulating at lower altitudes.  Thus, less molecules are at higher altitudes, so they retain less heat.  Hence, it is colder at higher altitudes.
Air also contains dust and water molecules, which trap heat.  However, the weaker gravitational force at high altitudes and stronger gravitational force at lower altitudes cause these molecules to be present in smaller amounts at higher altitudes.  This will allow heat to escape more easily at higher altitudes, and thus trapping less heat, leading to a lower temperature at higher altitudes.

Misconceptions
You said: "If we consider it with the sun rays, high altitudes receive sun rays earlier than low altitude so low altitudes must receive rays with less amount of energy relative to high altitude rays. Therefore low altitude must have low temperature. Can any one explain theory behind the scene?"
However, you have ignored the fact that gravity is different at different altitudes.  Furthermore, the distance between different altitudes is negligible when compared to how far the light from the sun travels before reaching Earth.  Hence, the about of heat and light energy received at different altitudes is negligible.  Thus, gravity is the main factor here.
Comment: you were downvoted because your answer is demonstrably incorrect; gravity has nothing to do with the tropospheric temperature profile, except inasmuch as it is responsible for holding the atmosphere in place around the earth. John Forkosh's answer (the adiabatic lapse rate) is correct.
Comment: First please note that I'm **>>not<<** the downvoter.  The extremely clear and concise words-only explanation is given by the first three paragraphs of that wikipdeia link I cited in my answer, https://en.wikipedia.org/wiki/Lapse_rate#Convection_and_adiabatic_expansion (which is then followed by the corresponding math). And maybe I'm missing something, but I'm not seeing those same ideas in your answer.
Comment: thnks for explanation, further can you explain, is gravity affecting changing seasons like autmn,summer, winter, spring.
Comment: Leave your answer up -- just to illustrate that teacher's sometimes don't know what they're talking about, especially when talking about topics which they're not qualified to teach. And maybe point out this question to other kids at your school. (P.S. And when you have your own kids, send them to a different school:)
Comment: And yeah, your "thenakedscientists" link is a simplified version of the third paragraph in my wikipedia llink.
Comment: I tried but my vote is locked. i will upvote your comment instead. sorry about that.


Confusing terminology for "normally closed/open" - It means the opposite in electronics (relays) versus fluids (valves)

Question: I'm an electrician and "normally open" / "normally closed" is well known to me. I recently started to also work on heating systems including the pneumatic system that controls some of the valves in the heating system.
In everything, other than the electrical world, normally closed means that no media/energy can pass in the resting state (of a valve).
Within the electrical world, normally closed means that current/energy can pass in the resting state (of a relay).

I understand the reasoning/history behind the terminology. But this difference in terminology must without any doubt have caused so much confusion/annoyance through time, and it surely must have caused both expensive and tragic misunderstandings too.
It's unthinkable, that "Off" and "On" would mean the opposite within the two disciplines, and yet it seems to have been accepted that NO/NC means the opposite.
I wonder if IEC/ISO or any industry organatizations have ever tried to introduce a new set of terminology that would mean the same across all disciplines? Or if there are any practices/conventions used in some industries to avoid having such misunderstandings?
It is not impossible reform terminology
Some of the comments seem to suggest that established conventions/terminology is impossible to reform. I disagree. Wire coloring schemes were different all across Europe/the world, but in the end IEC chose to standardize it, and at least all of Europe are following those conventions now. Sweden changed from driving in the left side to driving in the right side of the road. Those transitions were messy, but only for some time.
Example from the Danish language
And a transition does not need to be messy. In the language of Danish, the default translation, and the most used translation from English to Danish is

normalt åben (normally open)
normalt lukket (normally closed)

But some engineers/electricians have chosen to use the following terminology:

normalt sluttet (normally connected)
normalt brudt (normally broken
apart/disconnected)

They use this alternative terminology for the exact purpose of avoiding potential misunderstandings. This terminology leaves no room for misunderstandings. Its meaning is intuitive and it works for both fluids and electricity. This terminology never caused a misunderstanding, on the contrary, despite the fact that it is being used side by side with the NC/NO terminology.
Comment: If you think that's bad, wait until how you hear that electrons have negative charge and "saturation mode" means different things for different kinds of transistors. I like to think of a frankenstein switch: mechanically closed = conducting, mechanically open = not conducting. Or like a draw bridge where you are the car, not the ship.
Comment: I am an electrician and worked with hydraulics and found no issue. Perhaps one needs to pay attention the the different systems. The "old" water analogy for electricity does not always work well...
Comment: Obviously, it goes well most of the time. But that does not in any way mean that it has not caused both confusion and grave misunderstandings. To me, its quite obvious that it must have.
Comment: Well, I never had a problem fixing agricultural hydraulics on tractors from the circuit diagrams especially when IH aka Case had the nice mixing of electro-hydraulic...
Answer: It may help to think of the switch in terms of contact gap. A "closed" contact has no gap and conducts. An "open" contact has a gap and doesn't conduct.
In the case of valves it makes more sense to think of them in terms of a gate or door - open or closed to the passage of fluid.

It's unthinkable, that "Off" and "On" would mean the opposite within the two disciplines, and yet it seems to have been accepted that NO/NC means the opposite.

It's a fact of life! Start making it thinkable. It's too late to change it.
Comment: So why not just call a diode a backflow preventer... or one way valve.
Comment: @Transistor: I do understand the logic behind the naming, and the reason why they are named as they are. That does not mean that it wont cause confusion, misunderstandings and accidents.
Comment: @SolarMike, see what I've written here: http://lednique.com/what-is-an-led/.


monitor interprocess pipe traffic

Question: I have two Linux processes communicating via a nameless pipe. How can monitor the traffic in the pipe? How can I inject data into the pipe? I have root access and know the pipe inode.
Answer: A nameless pipe is by nature private to the applications that have the file descriptor. There's no principled way to observe or modify the traffic on the pipe. I don't think there's a way to look at the pipe directly on Linux, either.
There is an unprincipled way of more or less doing what you're after, though: through the ptrace system call. You wouldn't be tacking onto the pipe per se, but onto one of the processes. For observation, use strace, e.g.
strace -p1234 -s99999 -e write

where 1234 is the process ID of a process that writes on the pipe. Modifying the data is harder, but can be done. I think the easiest way would be to first set up an intermediate process that copies its standard input to its standard output, plus the data you want to inject (and minus any data you want to suppress). Create two named pipes and start that intermediate process with stdin on one pipe and stdout on the other. Then use a debugger (e.g. GDB) to make both target processes execute open on the appropriate named pipe, then dup to place the pipe on the appropriate file descriptor. Note that there's a chance you'll crash one of the processes in the process.
(If you don't understand the last paragraph, I'm sorry, but it does require a certain level of technicity. I don't think there is an easier way.)
Comment: @jackhab: Oh, I thought it didn't work for pipes. But as you found out it won't help you that much for monitoring traffic, because each byte from the producer will go to exactly one consumer and you can't control whether your monitor or the actual consumer will get it. You should be able to inject data that way then.
Comment: Thanks, I understand. What I actually tried is going to /proc/$PID/fd, where I found the file entries for the unnamed pipes of one of the processes and I managed to read and data using simple cat and echo in the shell, but the behavior somewhat inconsistent. I need to investigate further.
Answer: Some tools useful for monitoring a pipe :
Pipe Viewer
tee
For an already-running program where one doesn't control the piping, see the gdb method:
Redirecting Output from a Running Process.
Or one can use strace :
strace -ewrite -p $PID 2>&1 | grep "write(1"

shows only descriptor 1 calls. "2>&1" is to redirect stderr to stdout, as strace writes to stderr by default.
Comment: What I meant is wiretapping to the pipe of already running process. Process A launches process B and talks with it via a pipe so I have no way to use proxy utilities like tee or pv.
Comment: Added some more methods.
Comment: Rather than using grep, you can specify "-e write=1" to limit the output to data written to fd 1.
Answer: If either process is blocking on the pipe (either a blocking read ended by the other's write or a blocking write ended on the other's read because a buffer is full) there will be a wakeup event.  You can detect these with:
sudo perf record -a --call-graph dwarf -e 'sched:sched_wakeup' sleep 1
and then
sudo perf script -F trace:tid,comm,time,event,trace,sym,ip,dso > trace
The trace file will be long, but it will contain the timestamps at which each process woke the other.  And stack traces, if all goes well.

monitor interprocess pipe traffic


How do mirrors work?

Question: My physics professor explained to me that electromagnetic waves are consisted of two components - electric and magnetic - which cause each other.

Which part of the mirror actually reflects the wave?
Which of those two wave components? Both?
How come the wave doesn't get heavily distorted in the process?

I guess the actual electrons of atoms of silver play a role, but why isn't every material reflective, then? Because is isn't "perfectly" flat? If I lined up atoms of a non-metal element in a perfect plane (maybe several rows), would it reflect light just as mirrors do?
Comment: The accepted answer does not appear to be correct; the answer to this duplicate question is more accurate: https://physics.stackexchange.com/a/339896/68611
Comment: See also: Plasmons.
Answer: The reflection could be viewed as a two step process. The incident wave causes the electrons in the silver to vibrate like in an antenna. Though by vibrating they also emit the same light. So it's the electrons at the surface of the silver that reflect the incoming wave.  As you mentioned the wave is part electric and part magnetic, but these cannot be taken apart since they are each others cause and effect: without one the other wouldn't be there either, and therefore it must reflect both parts.
That silver (and all metals) don't distort is due to the fact that they are also very good conductors. This prevents the electromagnetic waves from entering the object. The boundary conditions which must hold (from being an conductor) result in the perfect reflection and that the resulting angle is equal to the incident angle.
Similar boundary conditions are there for non-conducting materials like plastic and glass. These similar conditions result in reflection of glass and the shine/reflection on other smooth surfaces (though there can be other causes too). Also Snell's law would follow from these boundary conditions.
In contrast to conducting materials it is possible for electromagnetic waves to enter non-conducting objects. As a consequence part of the incoming wave is transmitted into the material. The propagation or dampening of the wave through the material is largely dependent on the properties of the material. Some materials like glass hardly dampen the wave and you can see through them, while others like most plastics dampen them and thus are opaque.
Answer: Trying to separate electric and magnetic parts of a wave is not possible (Maxwell's equations couple them for propagation), so I will ignore your first two paragraphs.
The mirror conductivity is the key.  The electric field from light reaches the mirror's
metal and thereby causes a current to flow (which actually generates an opposite-moving
electro-magnetic wave to nearly-cancel the surface electric field).  The reflected image
you see really is generated by these induced currents.
"Flatness" does not matter.  "Free electrons to move" matters.

How do mirrors work?


Advantages of Elliptic Curve cryptography

Question: In digital signature schemes, what the security advantage of using Elliptic Curve over Integer Factorization and Discrete Logarithm schemes?
Comment: ECC still uses the discrete logarithm problem, it just gets there a different way.
Answer: A large advantage of EC vs RSA is a substantially shorter key (and data length due to padding). Starting to handle 4096-bit keys (512-bytes) is getting burdensome. Equivalent security of a 3072 RSA key can be achieved with a 256 bit EC key, source NIST.
If a large number of large keys are being stored there can be memory limitations and for a longer key and thus longer data this may be a communications issue.
For the same key size EC provides a higher level of security.
Comment: Also a shorter key is likely to fit in a faster CPU cache, making implementations on embedded systems faster and reducing the ease of side-channel attacks on larger systems.