How does database connection works in php-mysql

Question: Is it better to close the connection after each query is executed or put the connection as is it, then php will automatically close that connection.
Which one is better and why?
Answer: Open the connection just once. Opening and closing a connection takes time too. And as you already said, PHP closes open connections at the end of the runtime automatically.
So just call mysql_connect whenever you need a connection and let PHP close it at the end. mysql_connect checks for already existing connections so you don't need to worry that calling mysql_connect with the same parameters will open a new connection every time. You can also use persistent connections that can be used for more than just one script execution.
Answer: It doesn't really matter. If your PHP script is going to close the connection for you at the end of the script there isn't really much point doing it yourself.
The only reason you would want to put that extra code in the script to close the connection after you have done all your queries is if you want to free up a little memory, e.g. your script is already memory hungry using libraries like GD2.
Closing the connection after each query, and opening another to do another query IS memory hungry, and a huge waste of time. All in all, don't bother really!
Answer: Let the connection open, if your script use the connection randomly.
If there is group of jobs which are using the connection with certain time gap then you can close the connection after each group jobs.
Answer: From what I have the experience is better to leave the connection opened. But this is dependent on behaviour of your application. If you are doing huge number of calculations or connection external services which can take some time to finish, then is better to close the connection and open it again after you finish the time consuming part. If you don't have big number of visitors where you can hit the limit of number of sql connections then leave the connection opened all the time. It takes some time to open it again.
Answer: It may be better to use a persistent connection or a pool of connections.
Answer: It's usually good practice to close the connections that you open, tidying up as you go along.
Whether you want to open and close one for each query will depends on your application really. If it only interacts very infrequently with the database, then it might be best to do it this way. Or you might want to hold a pool of connections open for use by all, only opening a new one when all the other ones are currently being used.
Answer: Connect to your database once, during script initialization; keep the connection open during your script's execution and send further queries through it.
The above is a typical usage scenario, where you have a short-running PHP script (probably on a webserver) executing multiple SQL queries. Unless your script runs for longer than a few hours, don't worry about closing the connection between queries.
Every time you connect to the SQL server, both the PHP script and the server need to go through a (relatively) complex negotiation: establish a connection over the network, check that both sides want to speak MySQL, check that the script has permissions to connect, et cetera. Keep the db connection up, it's much faster and more efficient.


Jordan form, similarity and eigenvalues

Question: A complex matrix is always diagonalizable in the Jordan canonical form (right? ). also, two matrices have the same Jordan form if and only if they are similar. But two matrices who have the same eigenvalues might not be similar. SO, if A and B have the same eigenvalues, I say that they have the same Jordan blocks, so the same Jordan Form. But I am wrong, cause that would mean that they are similar. So could anyone explain me where I am wrong?
Comment: We don't say diagonalizable in JNF. We say similar to a JNF or something of the sort. The mistake is saying that they have the same jordan blocks.
Comment: could you explain a bit more please? why don t they have the same jordan blocks? cause a block is formed with eigenvalues . so , where am i wrong?
Comment: The same eigenvalue can have several jordan blocks.
Answer: Your main error is to confuse diagonalisability and having a Jordan normal form. Not all complex matrices are diagonalisable. Most Jordan normal forms are not diagonal matrices, and those are not diagonalisable either. Jordan block can have different eigenvalues and different sizes. Only if all Jordan blocks have size$~1$ is the matrix diagonalisable.
In terms of classifying matrices up to similarity, there is much more than just the set of eigenvalues. In order to be similar two matrices must have identical characteristic polynomials, so the same eigenvalues and the same algebraic multiplicities for each eigenvalue. But this is not sufficient: for each eigenvalue$~\lambda$ one can have a collection of Jordan blocks for$~\lambda$ whose sizes add up to the algebraic multiplicity of$~\lambda$. There is no imposed order of this collection of blocks, so one is free to order them say by weakly decreasing size so as to obtained a partition of the algebraic multiplicity; only if for each eigenvalue one obtained the same partition of the (same) algebraic multiplicity can one conclude that matrices are similar.

Jordan form, similarity and eigenvalues


Is there a list of doctrines and rationale in American common law that isn't based on codified laws and constitutional rules?

Question: It would also be interesting if there were lists of this nature at the state level too.
Answer: Short Answer

Is there a list of doctrines and rationale in American common law that
isn't based on codified laws and constitutional rules?

No.
There is really nothing so compact as a mere list.
Long Answer
West Key Numbers
Maybe the closest thing to a mere list of the topics and doctrines that are out there, without any of the substantive content of those topics and doctrines would be the West Key Number system which just lists the topics into which the legal publishing firm that operates under the brand name "West" organizes its headnotes in its legal digests of legal holdings of reported and selected unreported legal case opinions. West pays a small army of lawyers to prepare headnotes tied to the West key system by hand for every such case reported by West in its case reporters. But the West key system service that has started to become obsolete as more sophisticated search tools for the text in court cases has been developed with of the best search tools being specific to its online pay per view Westlaw legal resource search engine. A webpage at Stanford University explains how this works:

The West Key Number System is a classification system of U.S. law that
indexes cases into over 400 topics and more than 98,000 legal issues.
Westlaw assigns a topic and key number to each legal issue within a
case.  The West Key Number System allows you to efficiently find other
cases addressing your legal issue in any jurisdiction because all
federal and state cases included in the system are organized using the
same topics and by the same points of law.
Using the West Key Number System is particularly useful when you have
identified a relevant case and would like to find additional cases
addressing a certain point of law or legal issue from other
jurisdictions.
A key number consists of a topic number, followed by a number to
identify the issue within that topic.  For instance, 349k28 is
referring to the topic of Searches and Seizures (349) and the issue of
abandoned, surrendered, or disclaimed items (k28).

This list of 98,000 key numbers, however, is really a great oversimplification because the vast majority of key numbers of the West system have many numbered subtopics. At the finest grained level, the West key number system probably has something on the order of a million sub-topics (although many of those topics involve areas of law that are rooted in statutes or constitutions or treaties).
A mere table of contents, at the key number level (not the subtopic level), of the entire West Key Number system, is more than thousand pages long. Even a top level list of the 400 West top level topics would probably take more space that the Law.SE system allows in a single question or answer.
Relatively comprehensive compendiums of common law doctrines
You could buy full set of legal treatises, like the West digests, or a full set of law school textbooks, or famed subject-matter treaties in particular areas of the law and these would hit most of the high points, but there really isn't any truly comprehensive and compact list.
Perhaps the closest thing out there would be a full set of the Restatements of Law which are attempts to quasi-codify the majority or "better" rules of the common law in particular subject areas, which are drafted by a committee specialist law professors and legal experts in a legal subject led by a law professor chair of the committee called a "reporter" who writes most of the first draft, under a process sponsored by an affiliated with, but that is not formally a part of, the American Bar Association. There are Restatement of the law of torts, contracts, property, trusts, and judgments, for example.
Historically, there were other legal encyclopedias like Corpus Juris, in book form arranged by subject matter and running maybe 25-40 volumes, and there were also periodical publications like American Jurisprudence and ALR that did several fairly comprehensive summarizes of law on very specific topics each month. But almost all of these are now either defunct entirely, or have seen their share of the legal research resources market plummet to almost nothing.
The shortest comprehensive treatments would be encyclopedia length (e.g. perhaps 26 full sized volumes), and the shortest summary treatments would be perhaps 6-8 books long (e.g., a full set of law school student outlines for the main law school class common law topics, or a full set of bar exam review outlines covering the non-statutory subjects on the bar exam). You could only scratch the surface in a single book length treatment, like a single business law course textbook.
Fragments of the common law in the most commonly litigated issues in the most commonly litigated areas where there is a right to a jury trial, however, can be found in pattern jury instructions for civil cases for a particular state, which run to one or two full book length volumes in most cases. But a full set of civil pattern jury instructions omits lots common law subjects that are handled by judges alone in procedural matters and equity jurisprudence, and it omits common law subjects where even though there is a right to a jury trial  the subject is less frequently litigated. You could find almost all of the law relevant to routine, plain vanilla breach of contract cases, automobile accident cases, and slip and fall cases in pattern civil jury instructions, but would find little about property law or about less common kinds of contract and tort claims and defenses.
One of the reasons that most of the world other than long term British colonies use the civil law systems originating in Continental Europe, rather than the common law legal system, is that civil law systems compile their core legal doctrines of "private law" (i.e. the law governing dealings that don't involve the government) in one civil code, sometimes supplemented by one or two other codifications, like a commercial code, rather than from a sprawling, ill-defined, and unwieldy collection of appellate court precedents spanning centuries.
State common law

It would also be interesting if there were lists of this nature at the
state level too.

This is an upside down way to think about American common law.
American common law is, overwhelmingly and predominantly, state law (including the local law of self-governing territories of the U.S. like the Virgin Islands and the District of Columbia).
Common law rules differ from state to state and it isn't uncommon for their to be 2-6 different common law rules adopted in different jurisdictions on the same subject (e.g. an attorney's liability to a third-party as a third-party beneficiary of an attorney-client relationship). See also a related Law.SE answer to the question: What are the most prominent differences among the common law systems of the different states in the U.S.A.? to get a somewhat idiosyncratic list of the differences that can give you some of the flavor of how this plays out in practice.
For the most part, common law at the state level in the United States has a common origin in colonial era English common law, and there was lots of interstate borrowing of common law decisions up through roughly the 1920s (producing doctrines like the "American Rule" regarding attorney fee shifting in litigation). But since then, common law has developed largely on a state by state level with much more modest reference as persuasive authority to common law decisions of other U.S. jurisdictions.
In the late 1700s, and well into the 1800s, the prevailing view was that the common law was an organic form of "natural law" that was discovered rather than created by judges and was universal.
But the modern "positivist" view is that the common law is created by judges from a particular jurisdiction and is not "natural" or "universal". The modern positivist legal theory position, which is dominant, is that instead, the common law represents an intersubjective consensus about moral and ethical norms that are a product of the culture that they are created in. This culture is a set of cultural norms that both influences judges and is influenced and shaped by judges.
Federal common law
There is some federal common law separate from any constitutional or statutory foundation, but the scope of the federal common law is tiny and obscure relative to the scope of state common law.
Federal common law is primarily found in the subject areas of admiralty law, writ practice, evidentiary privileges in federal court litigation, customary international law, the law pertinent to disputes between states over water rights, some parts of choice of law doctrines, certain immunities from lawsuits, and employee benefits law in circumstances where the broadly pre-emptive ERISA statute does not apply.
More generally, in the United States, most law, both civil and criminal and statutory, arises at the state level, and federal law mostly supplements state law in specific subject-areas that are a product of the language of the U.S. constitution and the way that legislation and treaties and U.S. Constitutional interpretation have evolved over time.
State common law issues tried in federal courts
Federal courts only have jurisdiction over ordinary common law topics in diversity cases (i.e. large dollar lawsuits between people from different states or countries where a federal court forum was chosen by one of the parties), and in cases where state law claims are included as a part of a case which also has federal law claims (which are overwhelmingly statutory or constitutional in nature).
In these cases, federal courts generally apply the substantive state common law that a state court of general jurisdiction in the state where the federal court is located would apply, looking to state case law as controlling precedents. This is called the Erie doctrine after the U.S. Supreme Court case that clarified how this works.
On questions of first impression where there is no state case law on point, federal courts ask the state's supreme court how it would rule on the topic in a process call presenting a "certified question" to the state supreme court.
Comment: Note on that last point: that is indeed what is supposed to happen but I have encountered plenty of complains about federal courts in fact not doing so. Particularly where there are intermediate (or even district) state court opinions on the topic but nothing from the state supreme court.


What are some problems in EXP not known to be EXPTIME-Complete, but also do not have any known algorithm in NP?

Question: These would be problems known to be in exp where there could hypothetically be a P or NP algorithm, but none have been discovered yet if one is possible.
Comment: The title doesn't match the body.  "not known to be in NP" is different from "there could hypothetically be a polynomial time algorithm, but none have been discovered yet if one is possible".  Please put the question in the body of the post.  The title should be a short summary.
Comment: @ D.W.♦
 I fixed it.
Comment: https://cstheory.stackexchange.com/q/799/5038
Answer: Any BQP-complete problem should suffice, since BQP is contained in EXPTIME but not believed to be contained in NP and not believed to be equal to EXPTIME.
Answer: Assuming that $NP\not= PSPACE$ and $PSPACE \not= EXPTIME$, all
$PSPACE$-complete problems are incomplete in $EXPTIME$


How to set up googleTest as a shared library on Linux

Question: Debian does not provide any precompiled packages for gTest anymore. They suggest you integrate the framework into your project's makefile. But I want to keep my makefile clean. How do I set up gTest like the former versions (<1.6.0), so that I can link against the library?
Comment: I guess not all users are as experienced as you. I recently came from Windows to Linux and I would have been happy to find something like this on StackOverflow.
Comment: Note that Google recommend that you DO NOT build a library, but instead include the GTest code into your project. See https://code.google.com/p/googletest/wiki/FAQ#Why_is_it_not_recommended_to_install_a_pre-compiled_copy_of_Goog
Comment: BTW, gtest builds are managed using autotools so the standard `./configure && make && make install` workflow should work just fine. I'm not sure if this warrants a post since it would be no different from compiling many other packages from source.
Comment: The link provided by @Mawg is broken (the wiki was removed), it seems to work but points to a page that isn't on topic anymore (quite confusing). The best that I can find as replacement are these build instructions: https://github.com/google/googletest/blob/master/googletest/README.md However that only explains how to build with cmake. For autotools, I found the following answer to work best: https://stackoverflow.com/a/36000856/1487069
Comment: Thats the first note in the answer.
Comment: If you want to build from source, you may check out [this answer on StackOverflow](https://stackoverflow.com/a/51833099/8385554).
Comment: Wow!! That ***is*** weird !!!  Thanks for pointing it out
Answer: Before you start make sure your have read and understood
this note from Google! This tutorial makes using gtest easy, but may introduce nasty bugs.
1. Get the googletest framework
wget https://github.com/google/googletest/archive/release-1.8.0.tar.gz

Or get it by hand. I won't maintain this little How-to, so if you stumbled upon it and the links are outdated, feel free to edit it.
2. Unpack and build google test
tar xf release-1.8.0.tar.gz
cd googletest-release-1.8.0
cmake -DBUILD_SHARED_LIBS=ON .
make

3. "Install" the headers and libs on your system.
This step might differ from distro to distro, so make sure you copy the headers and libs in the correct directory. I accomplished this by checking where Debians former gtest libs were located. But I'm sure there are better ways to do this.
sudo cp -a googletest/include/gtest /usr/include
sudo cp -a googlemock/gtest/libgtest_main.so googlemock/gtest/libgtest.so /usr/lib/

# The easiest/best way:
make install  # Note: before v1.11 this can be dangerous and is not supported

4. Update the cache of the linker
... and check if the GNU Linker knows the libs
sudo ldconfig -v | grep gtest

If the output looks like this:
libgtest.so.0 -> libgtest.so.0.0.0
libgtest_main.so.0 -> libgtest_main.so.0.0.0

then everything is fine.
gTestframework is now ready to use. Just don't forget to link your project against the library by setting -lgtest as linker flag and optionally, if you did not write your own test main() routine, the explicit -lgtest_main flag.
From here on you might want to go to Google's Googletest Primer documentation, and the old docs about the framework to learn how it works. Happy coding!
Edit:
This works for OS X too! See "How to properly setup googleTest on OS X"
Comment: Cite of the output of the makefile: `'make install' is dangerous and not supported. Instead, see README for how to integrate Google Test into your build system.`
Comment: Your post is out-of-date. Please do not mislead people, `sudo cp -a libgtest_main.so libgtest.so /usr/lib/` does not work anymore. The file isn't even there to begin with.
Comment: Is there no `make install` target that you can use instead of manually copying the library and headers?
Comment: Have the files been renamed in the 1.8.0 version? There is no `include/gtest` as far as I can tell.
Comment: I'd also like to know why debian removed a pre-installed shared library (they did so as per upstreams recommendations: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=802587). The wiki link given there does no longer exist though. So why was this the case?
Comment: your solution didn't work for me. The correct output of `ldconfig` didn't show up. `sudo make instal` worked for me.
Comment: Just run `make install` from 1.11 onward, this works on >=debian10
Comment: Why use `cp -a` instead of just `cp`?
Comment: Wouldn't it be safer and better to copy to `/usr/local/include` and `/usr/local/lib` instead of to `/usr/include` and `/usr/lib`, respectively?
Comment: The ["note from Google"](https://github.com/google/googletest/blob/36066cfecf79267bdf46ff82ca6c3b052f8f633c/googletest/docs/faq.md#why-is-it-not-recommended-to-install-a-pre-compiled-copy-of-google-test-for-example-into-usrlocal) you have at the top, which recommends not installing into `/usr/local`, no longer exists in the [latest FAQ](https://github.com/google/googletest/blob/main/docs/faq.md) from Google. In fact, `sudo make install` now installs into `/usr/local`, [as stated here](https://github.com/google/googletest/tree/main/googletest). I think that warning can safely be removed.
Comment: Here is the quote: `sudo make install    # Install in /usr/local/ by default`
Answer: Let me answer this specifically for ubuntu users.
First start by installing the gtest development package.
sudo apt-get install libgtest-dev

Note that this package only install source files. You have to compile the code yourself to create the necessary library files. These source files should be located at /usr/src/gtest. Browse to this folder and use cmake to compile the library:
sudo apt-get install cmake # install cmake
cd /usr/src/gtest
sudo mkdir build
cd build
sudo cmake ..
sudo make
sudo make install

Now to compile your programs that uses gtest, you have to link it with:
-lgtest -lgtest_main -lpthread

This worked perfectly for me on Ubuntu 14.04LTS.
Comment: "sudo make install" worked on Ubuntu 18.04, but didn't work on Ubuntu 16.04.
Comment: Actually you don't have to copy libraries manually, there is a target for that in Makefile. You can just do it like that:
sudo apt-get install cmake # install cmake
cd /usr/src/gtest
sudo cmake CMakeLists.txt
sudo make install
That should be built and copy /usr/local/lib/
Comment: @AlexanderZinovyev I get "make: *** No rule to make target 'install'.  Stop." when I execute the "sudo make install"
Comment: @AhmedNassar: "sudo make install" does just the same thing as "sudo cp *.a /usr/lib". So, if install option is not available in generated Makefile, you just copy them manually
Comment: There is no need to manually `sudo cp *.a /usr/lib`, just repalce it with `sudo make install` should be fine.
Comment: I had to compile with `-lgtest -lgtest_main -lpthread` to make it work.
Answer: It took me a while to figure out this because the normal "make install" has been removed and I don't use cmake. Here is my experience to share. At work, I don't have root access on Linux, so I installed the Google test framework under my home directory: ~/usr/gtest/.
To install the package in ~/usr/gtest/ as shared libraries, together with sample build as well:
$ mkdir ~/temp
$ cd ~/temp
$ unzip gtest-1.7.0.zip
$ cd gtest-1.7.0
$ mkdir mybuild
$ cd mybuild
$ cmake -DBUILD_SHARED_LIBS=ON -Dgtest_build_samples=ON -G"Unix Makefiles" ..
$ make
$ cp -r ../include/gtest ~/usr/gtest/include/
$ cp lib*.so ~/usr/gtest/lib

To validate the installation, use the following test.c as a simple test example:
    #include <gtest/gtest.h>
    TEST(MathTest, TwoPlusTwoEqualsFour) {
        EXPECT_EQ(2 + 2, 4);
    }

    int main(int argc, char **argv) {
        ::testing::InitGoogleTest( &argc, argv );
        return RUN_ALL_TESTS();
    }

To compile:
    $ export GTEST_HOME=~/usr/gtest
    $ export LD_LIBRARY_PATH=$GTEST_HOME/lib:$LD_LIBRARY_PATH
    $ g++ -I $GTEST_HOME/include -L $GTEST_HOME/lib -lgtest -lgtest_main -lpthread test.cpp

Comment: With the last line I get error: /usr/bin/ld: /tmp/cczG727X.o: undefined reference to symbol '_ZN7testing4TestC2Ev'. I fixed this placing test.cpp before the libraries. i.e: g++ test.cpp -I $GTEST_HOME/include -L $GTEST_HOME/lib -lgtest -lgtest_main -lpthread
Comment: If linking against gtest_main (`lgtest_main`), there is no need to define your own `main` in the test file.
Answer: If you happen to be using CMake, you can use ExternalProject_Add as described here.
This avoids you having to keep gtest source code in your repository, or installing it anywhere.  It is downloaded and built in your build tree automatically.
Answer: Update for Debian/Ubuntu
Google Mock (package: google-mock) and Google Test (package: libgtest-dev) have been merged. The new package is called googletest. Both old names are still available for backwards compatibility and now depend on the new package googletest.
So, to get your libraries from the package repository, you can do the following:
sudo apt-get install googletest -y
cd /usr/src/googletest
sudo mkdir build
cd build
sudo cmake ..
sudo make
sudo cp googlemock/*.a googlemock/gtest/*.a /usr/lib

After that, you can link against -lgmock (or against -lgmock_main if you do not use a custom main method) and -lpthread. This was sufficient for using Google Test in my cases at least.
If you want the most current version of Google Test, download it from github. After that, the steps are similar:
git clone https://github.com/google/googletest
cd googletest
sudo mkdir build
cd build
sudo cmake ..
sudo make
sudo cp lib/*.a /usr/lib

As you can see, the path where the libraries are created has changed. Keep in mind that the new path might be valid for the package repositories soon, too.
Instead of copying the libraries manually, you could use sudo make install. It "currently" works, but be aware that it did not always work in the past. Also, you don't have control over the target location when using this command and you might not want to pollute /usr/lib.
Answer: I was similarly underwhelmed by this situation and ended up making my own Ubuntu source packages for this. These source packages allow you to easily produce a binary package. They are based on the latest gtest & gmock source as of this post.
Google Test DEB Source Package
Google Mock DEB Source Package
To build the binary package do this:
tar -xzvf gtest-1.7.0.tar.gz
cd gtest-1.7.0
dpkg-source -x gtest_1.7.0-1.dsc
cd gtest-1.7.0
dpkg-buildpackage

It may tell you that you need some pre-requisite packages in which case you just need to apt-get install them.
Apart from that, the built .deb binary packages should then be sitting in the parent directory.
For GMock, the process is the same.
As a side note, while not specific to my source packages, when linking gtest to your unit test, ensure that gtest is included first (https://bbs.archlinux.org/viewtopic.php?id=156639)
This seems like a common gotcha.
Comment: Your package gives me errors when I try to compile.  Any reason why?? here is my log test.cpp:(.text+0x57): undefined reference to `testing::Message::Message()'
test.cpp:(.text+0x84): undefined reference to `testing::internal::AssertHelper::AssertHelper(testing::TestPartResult::Type, char const*, int, char const*)'
test.cpp:(.text+0x97): undefined reference to `testing::internal::AssertHelper::operator=(testing::Message const&) const'
... its so long that I can't post the entire thing.  I did this in a brand new Ubuntu 14.04 VM so nothing else was installed except the necessary dependencies.
Comment: @ddelnano Yeah i ran into this little google test gem too. Apparently the order of the shared libraries is important. When linking gtest to your unit test, try including gtest before other libraries.
When i hit this problem, this link solved it for me: https://bbs.archlinux.org/viewtopic.php?id=156639
Comment: @ddelnano, also if your test suite does not have a 'main' defined then don't forget to link against 'gtest_main'.
Comment: I didn't include any other libraries. this is all i had in my file     `#include
        TEST(MathTest, TwoPlusTwoEqualsFour) {
            EXPECT_EQ(2 + 2, 4);
        }

        int main(int argc, char **argv) {
            ::testing::InitGoogleTest( &argc, argv );
            return RUN_ALL_TESTS();
        }`
Comment: nevermind I didn't read the blog post until after I posted that comment.  It is now finally working!
Answer: Just in case somebody else gets in the same situation like me yesterday (2016-06-22) and also does not succeed with the already posted approaches - on Lubuntu 14.04 it worked for me using the following chain of commands:
git clone https://github.com/google/googletest
cd googletest
cmake -DBUILD_SHARED_LIBS=ON .
make
cd googlemock
sudo cp ./libgmock_main.so ./gtest/libgtest.so gtest/libgtest_main.so ./libgmock.so /usr/lib/
sudo ldconfig

Answer: This answer from askubuntu is what worked for me. Seems simpler than other options an less error-prone, since it uses package libgtest-dev to get the sources and builds from there: https://askubuntu.com/questions/145887/why-no-library-files-installed-for-google-test?answertab=votes#tab-top
Please refer to that answer, but just as a shortcut I provide the steps here as well:
sudo apt-get install -y libgtest-dev
sudo apt-get install -y cmake
cd /usr/src/gtest
sudo cmake .
sudo make
sudo mv libg* /usr/lib/

After that, I could build my project which depends on gtest with no issues.
Answer: This will build and install both gtest and gmock 1.7.0:
mkdir /tmp/googleTestMock
tar -xvf googletest-release-1.7.0.tar.gz -C /tmp/googleTestMock
tar -xvf googlemock-release-1.7.0.tar.gz -C /tmp/googleTestMock
cd /tmp/googleTestMock
mv googletest-release-1.7.0 gtest
cd googlemock-release-1.7.0
cmake -DBUILD_SHARED_LIBS=ON .
make -j$(nproc)
sudo cp -a include/gmock /usr/include
sudo cp -a libgmock.so libgmock_main.so /usr/lib/
sudo cp -a ../gtest/include/gtest /usr/include
sudo cp -a gtest/libgtest.so gtest/libgtest_main.so /usr/lib/
sudo ldconfig

Answer: The following method avoids manually messing with the /usr/lib directory while also requiring minimal change in your CMakeLists.txt file.  It also lets your package manager cleanly uninstall libgtest-dev.
The idea is that when you get the libgtest-dev package via
sudo apt install libgtest-dev

The source is stored in location /usr/src/googletest
You can simply point your CMakeLists.txt to that directory so that it can find the necessary dependencies
Simply replace FindGTest with add_subdirectory(/usr/src/googletest gtest)
At the end, it should look like this
add_subdirectory(/usr/src/googletest gtest)
target_link_libraries(your_executable gtest)

Answer: With buster and bullseye one can install the following three packages without compiling anything:
sudo apt-get install libgtest-dev libgmock-dev googletest

This includes gmock.
Answer: Looking at the excellent answers from @ManuelSchneid3r here and @amritkrs here, I have finally been able to put together (over more than 1 year of effort now) a more up-to-date set of instructions, as well as additional insight and information not provided by any other answer here, and which I have been trying to figure out for 5 years.
This includes a lot about gcc/g++ libraries, installing libraries, naming .a statically-linked library files, where g++ searches for includes, etc.
How to install Google Test (gtest) and Google Mock (gmock) as shared, static .a libraries, system-wide, on Linux/Unix
Tested on Ubuntu 20.04 with the latest (unreleased, git pulled) version of googletest (more recent than v1.13.0).
If in a hurry, just run the several commands in the install section, then look at the "Example usage" shortly after.
Note: googletest has undergone a variety of changes over the last few years. For example, gtest and gmock are now packaged under the same repo, here: https://github.com/google/googletest. So, following my instructions will install both for you.
1. Install the latest gtest and gmock from source
If you want the latest released version, find it here: https://github.com/google/googletest/releases.
You can download it with wget like this, for instance:
# Download release v1.13.0
wget https://github.com/google/googletest/archive/refs/tags/v1.13.0.tar.gz

I prefer to just get the most-up-to-date content from the repo itself, however. Here are my full instructions, doing that:
sudo apt update
sudo apt install cmake

# You can find some of these instructions, here:
# https://github.com/google/googletest/tree/main/googletest
time git clone https://github.com/google/googletest.git
cd googletest        # "Main directory of the cloned repository."
mkdir build          # "Create a directory to hold the build output."
cd build
time cmake ..        # "Generate native make build scripts for GoogleTest."
                        # Takes ~2 seconds.
time make            # Run those makefiles just autogenerated by cmake above.
                        # Takes ~10 seconds.
sudo make install    # Install the .a library files, and headers, into
                        # /user/local/.

Done!
You can now include the necessary headers into your files as shown above.
Note: here is the full output of what was copied over, or "installed", into /usr/local when you ran sudo make install:
googletest/build$ sudo make install
[ 25%] Built target gtest
[ 50%] Built target gmock
[ 75%] Built target gmock_main
[100%] Built target gtest_main
Install the project...
-- Install configuration: ""
-- Up-to-date: /usr/local/include
-- Installing: /usr/local/include/gmock
-- Installing: /usr/local/include/gmock/gmock.h
-- Installing: /usr/local/include/gmock/gmock-actions.h
-- Installing: /usr/local/include/gmock/gmock-more-matchers.h
-- Installing: /usr/local/include/gmock/gmock-spec-builders.h
-- Installing: /usr/local/include/gmock/gmock-function-mocker.h
-- Installing: /usr/local/include/gmock/internal
-- Installing: /usr/local/include/gmock/internal/gmock-pp.h
-- Installing: /usr/local/include/gmock/internal/gmock-internal-utils.h
-- Installing: /usr/local/include/gmock/internal/gmock-port.h
-- Installing: /usr/local/include/gmock/internal/custom
-- Installing: /usr/local/include/gmock/internal/custom/gmock-port.h
-- Installing: /usr/local/include/gmock/internal/custom/gmock-matchers.h
-- Installing: /usr/local/include/gmock/internal/custom/gmock-generated-actions.h
-- Installing: /usr/local/include/gmock/internal/custom/README.md
-- Installing: /usr/local/include/gmock/gmock-cardinalities.h
-- Installing: /usr/local/include/gmock/gmock-more-actions.h
-- Installing: /usr/local/include/gmock/gmock-matchers.h
-- Installing: /usr/local/include/gmock/gmock-nice-strict.h
-- Installing: /usr/local/lib/libgmock.a
-- Installing: /usr/local/lib/libgmock_main.a
-- Installing: /usr/local/lib/pkgconfig/gmock.pc
-- Installing: /usr/local/lib/pkgconfig/gmock_main.pc
-- Installing: /usr/local/lib/cmake/GTest/GTestTargets.cmake
-- Installing: /usr/local/lib/cmake/GTest/GTestTargets-noconfig.cmake
-- Installing: /usr/local/lib/cmake/GTest/GTestConfigVersion.cmake
-- Installing: /usr/local/lib/cmake/GTest/GTestConfig.cmake
-- Up-to-date: /usr/local/include
-- Installing: /usr/local/include/gtest
-- Installing: /usr/local/include/gtest/gtest-param-test.h
-- Installing: /usr/local/include/gtest/gtest-printers.h
-- Installing: /usr/local/include/gtest/gtest-test-part.h
-- Installing: /usr/local/include/gtest/internal
-- Installing: /usr/local/include/gtest/internal/gtest-port.h
-- Installing: /usr/local/include/gtest/internal/gtest-death-test-internal.h
-- Installing: /usr/local/include/gtest/internal/gtest-filepath.h
-- Installing: /usr/local/include/gtest/internal/custom
-- Installing: /usr/local/include/gtest/internal/custom/gtest-printers.h
-- Installing: /usr/local/include/gtest/internal/custom/gtest-port.h
-- Installing: /usr/local/include/gtest/internal/custom/gtest.h
-- Installing: /usr/local/include/gtest/internal/custom/README.md
-- Installing: /usr/local/include/gtest/internal/gtest-string.h
-- Installing: /usr/local/include/gtest/internal/gtest-type-util.h
-- Installing: /usr/local/include/gtest/internal/gtest-param-util.h
-- Installing: /usr/local/include/gtest/internal/gtest-port-arch.h
-- Installing: /usr/local/include/gtest/internal/gtest-internal.h
-- Installing: /usr/local/include/gtest/gtest_pred_impl.h
-- Installing: /usr/local/include/gtest/gtest-assertion-result.h
-- Installing: /usr/local/include/gtest/gtest-typed-test.h
-- Installing: /usr/local/include/gtest/gtest-spi.h
-- Installing: /usr/local/include/gtest/gtest_prod.h
-- Installing: /usr/local/include/gtest/gtest.h
-- Installing: /usr/local/include/gtest/gtest-message.h
-- Installing: /usr/local/include/gtest/gtest-death-test.h
-- Installing: /usr/local/include/gtest/gtest-matchers.h
-- Installing: /usr/local/lib/libgtest.a
-- Installing: /usr/local/lib/libgtest_main.a
-- Installing: /usr/local/lib/pkgconfig/gtest.pc
-- Installing: /usr/local/lib/pkgconfig/gtest_main.pc

2. Background: the above installation instructions have just:

Installed gtest and gmock *.a static library files into /usr/local/lib so that you can build and run your gtest and gmock programs using these simple g++ build flags (used by the linker, ld):

-lgtest
Link against the /usr/local/lib/libgtest.a static library file, which provides general googletest functionality.
-lgtest_main
Link against the /usr/local/lib/libgtest_main.a static library file, which provides a default main() function needed by googletest.
-lgmock
Link against the /usr/local/lib/libgmock.a static library file, which provides general googlemock functionality.
-lgmock_main
Link against the /usr/local/lib/libgmock_main.a static library file, which provides a default main() function needed by googlemock.
-pthread
Required by googletest, since it uses POSIX threads under the hood.

Notes:

Order matters. Ensure your flags above come after the files which need them.
If you were to set the necessary CMake define to build shared dynamically-linked .so libraries instead of the static .a libraries we are building, then the -l flags above would cause the run-time linker to link against those instead, at run-time. See @amritkrs's answer for more info. on that. Following my instructions, however, will cause those same -l flags to link at build-time instead, placing the entire pre-built .a static library file binaries into your executables.

Installed all gtest and gmock header files that you need to include in your programs into /usr/local/include/gtest and /usr/local/include/gmock, respectively.
This allows you to includes the necessary files in your programs, like this:
// Include in your unit tests
#include <gtest/gtest.h>
#include <gmock/gmock.h>

// Include in your production code to give gtest access to private members
// in your classes, as friends, via the
// `FRIEND_TEST(TestSuiteName, TestName);` macro, for instance.
#include <gtest/gtest_prod.h>

3. Example usage:
# Build and run an example googletest unit test that comes in the repo:
# - required in this case: `-pthread`, `-lgtest`, and `-lgtest_main`

mkdir -p bin

time g++ -Wall -Wextra -Werror -O3 -std=c++17 -pthread \
    googletest/googletest/samples/sample1_unittest.cc \
    googletest/googletest/samples/sample1.cc \
    -lgtest -lgtest_main -o bin/a && time bin/a

4. Run an example unit test
Manually test-build and run a sample test included in the repo:
# (run while still in the googletest/build dir)
time g++ -Wall -Wextra -Werror -O3 -std=c++17 -pthread \
    ../googletest/samples/sample1_unittest.cc \
    ../googletest/samples/sample1.cc \
    -lgtest -lgtest_main -o bin/a && time bin/a

Sample run and output:
googletest/build$ time g++ -Wall -Wextra -Werror -O3 -std=c++17 -pthread \
>     ../googletest/samples/sample1_unittest.cc \
>     ../googletest/samples/sample1.cc \
>     -lgtest -lgtest_main -o bin/a && time bin/a

real    0m1.879s
user    0m1.740s
sys 0m0.135s
Running main() from /home/gabriel/GS/dev/temp/googletest/googletest/src/gtest_main.cc
[==========] Running 6 tests from 2 test suites.
[----------] Global test environment set-up.
[----------] 3 tests from FactorialTest
[ RUN      ] FactorialTest.Negative
[       OK ] FactorialTest.Negative (0 ms)
[ RUN      ] FactorialTest.Zero
[       OK ] FactorialTest.Zero (0 ms)
[ RUN      ] FactorialTest.Positive
[       OK ] FactorialTest.Positive (0 ms)
[----------] 3 tests from FactorialTest (0 ms total)

[----------] 3 tests from IsPrimeTest
[ RUN      ] IsPrimeTest.Negative
[       OK ] IsPrimeTest.Negative (0 ms)
[ RUN      ] IsPrimeTest.Trivial
[       OK ] IsPrimeTest.Trivial (0 ms)
[ RUN      ] IsPrimeTest.Positive
[       OK ] IsPrimeTest.Positive (0 ms)
[----------] 3 tests from IsPrimeTest (0 ms total)

[----------] Global test environment tear-down
[==========] 6 tests from 2 test suites ran. (0 ms total)
[  PASSED  ] 6 tests.

real    0m0.003s
user    0m0.000s
sys 0m0.002s

5. Uninstall
To remove/uninstall gtest and gmock, just manually remove all of the files that were copied over by sudo make install. Hare are the commands to do that:
# remove the main libraries
sudo rm /usr/local/lib/libgtest.a \
        /usr/local/lib/libgtest_main.a \
        /usr/local/lib/libgmock.a \
        /usr/local/lib/libgmock_main.a

# remove the include dirs
sudo rm -r /usr/local/include/gtest \
           /usr/local/include/gmock

# extras

# remove the package config (whatever that is)
sudo rm /usr/local/lib/pkgconfig/gtest.pc \
        /usr/local/lib/pkgconfig/gtest_main.pc \
        /usr/local/lib/pkgconfig/gmock.pc \
        /usr/local/lib/pkgconfig/gmock_main.pc

# remove cmake GTest stuff
sudo rm -r /usr/local/lib/cmake/GTest

Going further: general information about libraries; debugging; gcc/g++ compiler flags; etc.

When compiling, g++ searches your include directories for all header files your code includes. The default C++ system-wide include paths can be found by running $(gcc -print-prog-name=cc1plus) -v and then pressing Ctrl + C after a second to kill it (see here: Where does gcc look for C and C++ header files?). They include primarily:
/usr/include        # system-added includes
/usr/local/include  # user-added includes

# as well as some more include paths to pull in compiler includes

Include directories also include any that you have passed to g++ via -I flags, such as -I"path/to/some/personal/include_dir1" -I"path/to/include_dir2", etc.
Storing gtest's includes in /usr/local/include directly means that you never have to pass custom -I flags to specify where they will be. The compiler just always has them available now!

Similar to the above "include" concept, library files, such as statically-linked .a files (or dynamically-linked .so files) can be linked to your executable by passing them as inputs to g++.
Example: this command, from my answer here, manually specifies the gtest and gmock include directories, as well as the pre-built .a files, and builds the googletest/googletest/samples/sample1_unittest.cc example program:
# Note: the specified .a files here must actually be locally stored in
# a local "bin" path, as specified in this command
time ( \
    time g++ -Wall -Wextra -Werror -O3 -std=c++17 -pthread \
    -I"googletest/googletest/include" -I"googletest/googlemock/include" \
    googletest/googletest/samples/sample1_unittest.cc \
    googletest/googletest/samples/sample1.cc \
    bin/libgtest.a bin/libgtest_main.a \
    -o bin/a \
    && time bin/a \
)

Or, by copying the includes to /usr/local/include and the .a static library files to /usr/local/lib, you can simplify that command greatly and run this instead! The include directories no longer need to be specified at all, and instead of passing path/to/libgtest.a and path/to/libgtest_main.a, you simply pass -lgtest and -lgtest_main, respectively, instead:
time g++ -Wall -Wextra -Werror -O3 -std=c++17 -pthread \
    googletest/googletest/samples/sample1_unittest.cc \
    googletest/googletest/samples/sample1.cc \
    -lgtest -lgtest_main -o bin/a && time bin/a

Instead of running sudo make install to install the gtest and gmock headers and libraries into /usr/local/include and /usr/local/lib, respectively, you can manually install the header files and libraries by copying them like this if you want:
# manually install the .a libraries, and header files

# give access to g++ flags `-lgtest`, `-lgtest_main`, `-lgmock`, and
# `-lgmock_main`, by copying over the .a static library files
sudo cp -i -t /usr/local/lib \
    lib/libgtest.a lib/libgtest_main.a lib/libgmock.a lib/libgmock_main.a
# give access to include header files `<gtest/gmock.h>` `<gtest/gtest.h>`,
# `<gtest/gtest_prod.h>`, etc.
# 1. gtest header file includes
sudo cp -a path/to/googletest/googletest/include/gtest /usr/local/include
# 2. gmock header file includes
sudo cp -a path/to/googletest/googlemock/include/gmock /usr/local/include

I first learned that concept in @ManuelSchneid3r's answer here. I tested it myself.

Without header files installed or a -I path specified to them, you'll see failures to include your desired headers, such as fatal error: gtest/gtest.h: No such file or directory here:
eRCaGuy_hello_world/cpp$ time g++ -Wall -Wextra -Werror -O3 -std=c++17 -pthread  googletest/googletest/samples/sample1_unittest.cc     googletest/googletest/samples/sample1.cc     -lgtest -lgtest_main     -o bin/a      && time bin/a
googletest/googletest/samples/sample1_unittest.cc:46:10: fatal error: gtest/gtest.h: No such file or directory
   46 | #include "gtest/gtest.h"
      |          ^~~~~~~~~~~~~~~
compilation terminated.

real    0m0.046s
user    0m0.039s
sys 0m0.007s

Without libraries (.a or .so files) installed, and if you try to use -lgtest for example instead of passing path/to/libgtest.a directly, you'll see failures to link via the ld linker, such as cannot find -lgtest here:
eRCaGuy_hello_world/cpp$ time g++ -Wall -Wextra -Werror -O3 -std=c++17 -pthread  googletest/googletest/samples/sample1_unittest.cc     googletest/googletest/samples/sample1.cc     -lgtest -lgtest_main     -o bin/a      && time bin/a
/usr/bin/ld: cannot find -lgtest
/usr/bin/ld: cannot find -lgtest_main
collect2: error: ld returned 1 exit status

real    0m1.895s
user    0m1.776s
sys 0m0.119s

If you copy your library files to a known g++ system-wide library path, such as /usr/local/lib (recommended for user-installed .a and .so libraries) or /usr/lib (for system-installed .a and .so libraries), the .a files must be named libwhatever.a, for instance, in order to be used as -lwhatever.
You cannot call them lwhatever.a, or libwhatever. They must be named libwhatever.a.
So, having file /usr/local/lib/libgtest.a enables the -lgtest library linker flag, but /usr/local/lib/lgtest.a does not.
If your name is wrong and then try to use the -lgtest flag, you'll see the /usr/bin/ld: cannot find -lgtest linker error as previously shown above, since this library is not properly named and "installed".
Again, this means if you call it /usr/local/lib/libwhatever.a, then you must use -lwhatever as the linker flag to that library.
Note that per ld --help, the -l (lowercase "L") flags are apparently passed to the ld linker, and presumably the l stands for library. See my question here: Meaning of -l (lowercase "L") flags in gcc/g++. From ld --help:

-l LIBNAME, --library LIBNAME
                            Search for library LIBNAME

Looking at library files inside /usr/local/lib and /usr/lib, the linker naming convention for libraries, whether static .a or dynamic .so files, seems to require that the library file name must be prefixed with lib!

Gtest uses POSIX threads (pthreads) under the hood, so you must always pass the -pthread flag to g++ too.

A google search for g++ "-lpthread" vs "-pthread" reveals this answer: Difference between -pthread and -lpthread while compiling, which says that the difference between -lpthread and -pthread is historical, so on today's gcc/g++ and clang compilers, you should always just use -pthread to bring in POSIX threads.
The -lpthread library is now an empty binary apparently and doesn't do anything except satisfy ancient requirements where that library must still be included in some places. But, -pthread handles that all for you, so just use -pthread alone and be done!

That about covers it. I now know more about g++, libraries, and gtest.
References:

Answer by @ManuelSchneid3r
Answer by @amritkrs
https://github.com/google/googletest

https://github.com/google/googletest/tree/main/googletest

My Q&A: How do I build and use googletest (gtest) and googlemock (gmock) with gcc/g++ or clang?
MY Q: Meaning of -l (lowercase "L") flags in gcc/g++
Answer: This will install google test and mock library in Ubuntu/Debian based system:
sudo apt-get install google-mock

Tested in google cloud in debian based image.
Comment: Hmm, no, I think this only installs `googlemock`, but it does not install `googletest` (gtest). At least that's what happened to me.
Answer: For 1.8.1 based on @ManuelSchneid3r 's answer
I had to do:
wget github.com/google/googletar xf release-1.8.1.tar.gz
tar xf release-1.8.1.tar.gz
cd googletest-release-1.8.1/
cmake -DBUILD_SHARED_LIBS=ON .
make

I then did make install which seemed to work for 1.8.1, but
following @ManuelSchneid3r it would mean:
sudo cp -a googletest/include/gtest /usr/include
sudo cp -a googlemock/include/gmock /usr/include
sudo cp `find .|grep .so$` /usr/lib/

Comment: Its been a while that I wrote this answer, let me know what is the problem with it if you think it has no value / is invalid.


Will devdays-2011 be available for download?

Question: A lot of people will get to see DevDays up and close, but a lot more won't. Will there be a free video download of all the sessions? If the goal is to make it as accessible as possible, this would really hit the spot (not to mention be wildly popular).
Comment: If it *is* going to be available for download, I wouldn't announce that until after the event.  Otherwise a lot of people might decide to stay home.
Comment: @Bill the Lizard - I don't think there would be a shortage of people who would like to experience the whole thing in person.
Comment: @Vilx: You might be right.  People still go to the movies when they know the DVD will be out in a few months.  It also seems to be working okay for [TED](http://www.ted.com/talks).
Comment: @Bill the Lizard - a lot of conferences are available as videos. For instance, Joel's favorite [Business of Software](http://businessofsoftware.org/prevyear.aspx). Doesn't seem to hurt them. Being there and watching the video later on are two completely different things. I'm also sure that many of the attendees will still download the videos for future reference.
Comment: @Bill - the videos will help spur interest in the live conference. It wasn't until I saw some of the videos that I started to lobby work to send me to BoS. Plus, if the goal is to make the internet better, why trap that knowledge in the confines of that one place at that one time? There is no substitute for being there, so I'm not sure any but the cheapest would make a "buy" decision based on if the videos were available.
Comment: @AnonJr: It's not really a matter of money, but it might come down to time (at least for me).  If a project deadline is coming near, I'm going to have a much more difficult time convincing my boss that I need time off to attend a conference.  If I know that the videos will be online soon after, I might not try so hard.
Comment: @Bill - I can see that, and I could counter with the fact that the videos can make the conference easier to sell by having something you can show your boss re: the quality of the conference. I've spent a lot of good money on bad presentations... most managers can appreciate a little prudence from their staff.
Comment: @Bill - Truth is, we can probably hash this out with valid examples from both sides of discussion, the root question that really needs to be answered is if publishing some or all videos would provide a net benifit. I think it would, but ultimately its up to Jeff/Joel.
Comment: You won't miss a thing, it has been cancelled.
Comment: I'm voting to close this question as off-topic because the event was cancelled and this post, asking for videos to be made available, adds nothing to this site (while other dev days Q&As *might*).
Comment: @Rob - Did you, ermm... check the date on this question?
Answer: I think that providing free downloads of the talks creates an unfair free-rider problem in which the attendees end up paying more money to subsidize the people that couldn't be bothered to pay and attend. And for everyone who decides not to go because the videos will be online later for free, the number of attendees is reduced and the very high fixed costs of the conference have be borne by a smaller number of people.
The Business of Software and TED are very different kinds of events, where a great deal of the value comes from the relationships that are formed among attendees in the hallways and at meals. That is true at this event too, of course, but not nearly to the same extent.
I expect that this year we will attempt to record some of the sessions and make them available to the general public, but not all of them.
Comment: For many people the cost will be prohibitive not because of the raw cost of attendance, but because of the [possibly several times] larger cost of travel and accomodation. I feel that if you don't provide these videos, that puts them at an unfair position. However I do see the reason of offering them for money. Though it would then have to be substantially less than actually attending, because you miss out on the opportunity to talk to the speakers and other attendees. Well, just my 2 cents. :)
Comment: What about charging a minor fee to download the videos? Just cross sell the videos.
Comment: @Hendrik: why would you pay for technical talks if almost everything is already available at channel9.com for free?
Comment: What about charging a significant fee for the videos? If the videos contain nearly the same value as being there in person, then that should be reflected in the price. This should more than offset the cost of the recording. Maybe release a few clips for free, and charge for the full thing.


Custom Close Reason - Musical Question

Question: Should we have a custom close reason for musician related questions?  If so, what should it be?
Answer: Sound Design is a site for sound design and production professionals and enthusiasts.  Music related sound design that would be done by musicians is off topic as this is not a Q/A site for musicians.
While musicians also design sounds, it is a different style with different requirements and needs than what is covered here.  You may have better luck at Musical Practice & Performance.
Comment: @EMV - yes, and made even more difficult since phrases like experienced are far too variable to give a concrete line for on or off topic, though, honestly, if we could rule out all the audiophile and home theater and music questions, we'd be much closer to where we want to be.  That's probably 80% of the bad questions right now.  It's also easy enough to write generic questions and answers to cover a lot of the basic stuff and then close overly simple questions as duplicates.  Most beginner questions are either too broad or generically answerable.
Comment: As said in the meta discussion, I would suggest removing the enthusiasts part.
Comment: @EMV - depending on how you define professional I might have to leave then.  I am more than capable of doing multiple forms of production sound at a professional level, but I don't often get paid for sound since I get paid more for doing other things and have a limited amount of time in the day.  I agree we need to be careful of the description and don't want home audio questions or audiophile content, but a large portion of our user base does not work full time in the industry nor do they intend to.
Comment: I see your point. So how can we describe people doing sound design at a professional level, without ruling out those that are not doing it full-time or as a paid job? I don't think "enthusiasts" covers this.
Answer: Now that we have the privilege scale sorted out, let's see what happens over the next 30 - 45 days, I'm going to run some queries to see what gets closed (and why) - folks can utilize the 'other' custom close reason to indicate that's why they're closing (in fact, they're welcome to use the very text you came up with).
At that time, I'd like to come back to this, and start formulating the close reasons we see a clear, repetitive use for.
Comment: Sounds good.  I'm pretty sure that it will still end up being one as it has appeared to be the single most common close reason other than being "too basic," which I have no idea how to make a workable standard reason for since why it is too basic tends to vary.  But it will be nice to have actual numbers on the close reasons too and see the broader community stance now that more people can VTC.

Custom Close Reason - Musical Question


How can I join a Yahoo! group if I don't have a cell number, Google, Facebook or Twitter account

Question: I have no cell number, no Google account and no Facebook account. Why can't I create a Yahoo! account so I can join a group?
Answer: Yahoo won't let you register a Yahoo ID without a mobile number. From their help page on the subject:

One of the ways Yahoo helps to protect accounts is by requiring a mobile number to sign up. If you don't provide a valid mobile number, you'll be unable to complete registration.

They also give three reasons why:

Greatly reduces the risk of an abuser accessing your account.
If you need to recover your password, this is the safest and most    effective method to recover it.
Yahoo will alert you through your mobile device when we suspect    unusual login activity on your Yahoo account.
Comment: I wonder how people in 3rd world countries who share computer access and sometimes don't have mobile phones would sign up for a yahoo account. Maybe this is only country specific?
Answer: Answer is, you can't. Not even with a Google Voice number as your "mobile" number.
The sad thing is there ARE valid reasons to have a Yahoo Account WITHOUT a cellphone.
EXAMPLE: You have your personal account, or perhaps an account for a company... but now you have a specific product or service that you want to promote via the social networks, using a Yahoo "product", say Flickr for example.
Comment: Can you make your answer a little less "rant-y"?
Answer: There is no need to create a Google, Facebook, or Yahoo! account to join a group on Yahoo! Groups—all you need is an e-mail address.  To join a group, simply send an e-mail to email@example.com, where groupname is the name of the group.  You will get mailed back a confirmation message containing a URL; to confirm your subscription you can either open the URL in a web browser or just reply to the message.
Once you are subscribed you can post messages to the group by e-mailing email@example.com; you can unsubscribe by sending an e-mail to firstname.lastname@example.com.
As you can see from the following annotated screenshot, all these addresses are posted on the home page of every group.


Are projects under NDA not allowed in portfolio?

Question: I've been doing freelance jobs lately that do not involve NDA. However I received an offer from a client that requires an NDA prior to project start. Does NDA projects restrict the project themselves from being put in my portfolio?
Comment: Check if the NDA covers silence only until the release or it says something like "6 months after release blahblah". If the product is released, you may putit.
Answer: Uhm, YES. They are not allowed.
Non-Disclosure means you can't tell anyone what you worked on. That includes showing it off in a portfolio.
If you would like to display the work in your portfolio you need to specifically discuss that with the client and get an written addendum to the NDA which specifically states what you can display in a portfolio. But I can't see any clients being okay with "Keep our secrets... but show them off in a portfolio".
Comment: The NDA may, or may not, have a specific time frame that covers what can be disclosed. Reading the specific NDA is the only way to know as it can go either way.
Answer: Depends on the NDA. NDA's I sign generally concern information I will receive or process in the course of the project, but that doesn't mean I can't put the project on my resume.
And when in doubt: just ask the client.
Answer: It very much depends on the content of the NDA.
Recently, I worked on a cutting-edge mobile payment app - and even without an NDA, it was pretty obvious that I (initially) was not allowed to mention it. However, after the launch, I could mention the project by name and elaborate on the technology stack.
Whenever in doubt, just ask the client. I usually send a sample description for them to approve, as that seems a simple and transparent way to avoid any legal pitfalls.


Prove that $\mathbb{Z}_{5}[x]/(x^2+1)$ is isomorphic to $\mathbb{Z}_{5} \times \mathbb{Z}_{5}$.

Question: I remember trying this problem a while ago and was unable to prove it. I think my idea was to create a surjective homomorphism from $\mathbb{Z}_{5}[x]$ to $\mathbb{Z}_{5} \times \mathbb{Z}_{5}$ and use the first isomorphism theorem but it wasn't working because none of my maps were well-defined. What is the correct way to approach this problem?
Answer: Note that $x^2+1=(x+2)(x+3)$ over $\mathbb{Z}/5\mathbb{Z}$, and so by the Chinese Remainder Theorem
$$ (\mathbb{Z}/5\mathbb{Z})[x]/(x^2+1)=(\mathbb{Z}/5\mathbb{Z})[x]/(x+2)(x+3)\simeq (\mathbb{Z}/5\mathbb{Z})[x]/(x+2)\times (\mathbb{Z}/5\mathbb{Z})[x]/(x+3)$$
$$\simeq \mathbb{Z}/5\mathbb{Z}\times \mathbb{Z}/5\mathbb{Z}$$
Answer: For a constructive approach, your idea for a strategy works. Here is how to think through building a well-defined map in this case.
First, instead of starting with the quotient $\mathbb Z_5[x]/(x^2+1)$, it is easier to try starting with $\mathbb Z_5[x]$. In order to get a homomorphism $\mathbb Z_5[x]\rightarrow \mathbb Z_5\times \mathbb Z_5$, we simply map $1\mapsto (1,1)$, and choose any value for $x$; say, $x\mapsto (a,b)$.
In order for the map to factor through $\mathbb Z_5/(x^2+1)$, we need the image of $x$ to satisfy the equation $x^2+1=0$, hence $(a,b)^2+(1,1)=0$. Solving this, we need $a^2=b^2=4$. The equation $z^2=4$ has solutions $z=2$ or $3$ in $\mathbb Z_5$, so $(a,b)=(2,2), (3,3), (2,3),$ or $(3,2)$
If $a=b$, then $f$ is not surjective (since its image only contains $(c,c)$ for $c\in \mathbb Z_5$), so we can assume $a=2$ and $b=3$ or vice versa.
Finally, note that the map $x\mapsto (2,3)$ is surjective: for instance, it is a $\mathbb Z_5$-linear map whose image contains the basis $(1,1),(2,3)$ of $\mathbb Z_5\times \mathbb Z_5$.
Thus an isomorphism $\mathbb Z_5[x]/(x^2+1)\rightarrow \mathbb Z_5\times \mathbb Z_5$ can explicitly be given by $a+bx\mapsto (a+2b,a+3b)$ for $a,b\in \mathbb Z_5$.


What do I do when coworkers are constantly asking to borrow money?

Question: Several times over the past two years coworkers have asked to borrow money from me.  I listen to the how, why, and what and I have loaned money out probably 6 or 7 times.  The amounts have varied from $40 to $1500.  A few times they were late paying me back but I have gotten back every cent I have loaned out.  I own several properties (in which one of them lives).  I am wondering if I have done something wrong in my relationships with them.  The latest request is from someone who took what sounded like a very expensive vacation.  I live within my means and always have.  They have a newer car, nicer phone, and go out for lunch every day.  I feel like saying no and telling them why but is it even worth it if the amount makes zero difference to me?  Have I done something wrong in my relationships with my coworkers and can it be corrected?
Comment: @JimG. I disagree. This is about coworkers in the workplace.
Comment: This question appears to be off-topic because it doesn't exclusively pertain to the workplace.
Comment: Whoa.  When I saw the title I thought "lunch money; forgot my wallet at home", not $1500 loans.  Is this part of the corporate culture where you work, or is it just you who gets asked for such loans?
Comment: The question is if you are close friends or not.  You are essentially functioning as a zero-interest bank, which I personally would only do to family and very close friends.
Comment: Dealing with coworkers is far different than dealing with family or fellow students.
Comment: Stop paying and "helping" the deadbeats around you. You owe them nothing. They are adults who threw themselves into a pit and want to have a ball on your dime. Just say NO to them.
Comment: This is not really a workplace issue (although it takes on an added dimension of difficulty when dealing with loans to/from coworkers); it's a personal finance issue.
Comment: If more than one person is asking for money from you it means at the moment you have a reputation as "the guy we can get money from".  If you keep doing this you're going to get screwed one day, and then you'll stop loaning people money for good.  Better to stop it before that happens.
Comment: @PaddyLandau: Just because the borrowers are coworkers doesn't make this on topic.  Substitute "friends" or "fellow students" or "family members" where you see "coworkers" and the questions doesn't really change.
Comment: Is it always the same coworkers asking for money? Or is it different each time as people think you are the 'go to' loan 'with no interest' guy?
Comment: @RhysW the loans have been to about 4 people.  A few repeats it hasn't been an issue until it has been someone I really didn't feel deserved it.
Comment: I don't see what the problem is, if you've got every cent back.  However, maybe you have an issue with it, and you don't want to do it.  Fine.  So say no if you don't want to do it.  Or say yes if you don't mind doing it.  It's entirely over to you.  There's no moral obligation to say yes just because someone asks nicely.
Comment: You are known as an easy touch. Tell them you have no extra cash at the moment, because you're saving for something big (you could say "A special holiday like you just had" ;-) ). After a while they'll give up bothering you.
Answer: I would tend towards not doing side business with co-workers; unless both parties are very good at compartmentalising their lives, relationship issues in the side business could easily bleed into the co-worker relationship.
I also think it's really silly to lend money to co-workers. Failure to pay back on time is going to strain the relationship. Failure to pay back at all will strain it further. You even mention in your question that you feel that they are spending the money unwisely, if you perceive them to be wasting your money (even if they intend to pay it back), it may make you react more negatively towards them.
All of this and you still have a responsibility to your common employer to not let it affect your work.
For loans you've already given out, that's done. Try not to let how they spend it bother you.
For the co-worker who is also your tenant, that's tricky. My best advice would be to hope they leave on good terms. Landlords and tenants don't always see eye-to-eye on things like rental increases or repairs, hopefully you continue to or can both keep it outside of work.
For future requests for loans, a response in the negative to the effect of "I'm sorry, but I feel lending money to co-workers was a bad idea because it risks hurting our working relationship. We've worked together for X years, and I have no reason to think you wouldn't pay the money back, so if you'd like I can act as a character reference". Your goal in the rejection should be to make it clear that you aren't rejecting this individual, but rather trying to correct the earlier mistake of lending money at all. This way, they will hopefully not be offended by the rejection of what may have previously been common practice; however, you must consistently reject all future loan requests, otherwise you are indeed rejecting this individual. Exceptions like "I buy coffee this morning, you buy it next" are fine, the level of abstraction (loaning coffee) is generally sufficient that people will not assume that they can also borrow money from you.
I don't know if this is something you do or not, but I would recommend not discussing things like your wage, liquid assets, or success of your investments (such as your properties). It may give them the impression, right or wrong, that you have money available, and they may incorrectly assume that it is okay for them to ask for a loan of some of this money. If you are particularly successful, they may think that the amount should be trivial to you. Like political beliefs, I don't feel that personal finances have much place in the workplace either.
Comment: In addition, I would add that you should never lend money to a coworker or a friend unless you can **absolutely** say that you won't care at all, and it will make positively **no** difference to you, if it is never repaid.
Comment: @ojblass I gave a presentation last Friday about this subject to some of my fellow coworkers. I wish you luck on your attempts, too, I have *very* similar perspectives :)
Comment: "I would tend towards not doing side business with co-workers" - in my company, it is expressly prohibited and engaging in such could lead to termination.
Comment: I am interested in personal finance and the conversations about money and how you are planning for the future have inevitably arise.  We have contests concerning who can contribute the most for the 401k.  For the younger employees I feel as though it is an important lesson that I wish someone was around to teach me.  I have been able to convince 3 or 4 of them to at least contribute the amount necessary to get the full company match.  Maybe this public service has come to bite me and I should mind my own business more.  I like this answer a great deal but not all of it.
Answer: You have gotten lucky so far. Loaning money to people you want to maintain relationships with is almost always a bad idea. You can find all sorts of horror stories about family/friends/coworkers and loans if you search online. This is why a lot of personal finance people are vehemently against them.

It causes the relationship dynamic to change. From your perspective, nothing changes, but they now owe you something. Which means they will perceive you differently. Suddenly you aren't just a friend/coworker but now someone owed money. This sucks, but it's just how it works. This might be the case already since they rent from you?
If they don't or can't pay you back, the relationship dynamic gets really difficult, really fast. Are you going to pursue them legally to get the money back? This will make life at work ridiculously complicated fast.
It's easy to not care about this as the person with the money. It primarily affects those who now are indebted to you and how they perceive you.

I feel like saying no and telling them why but is it even worth it if the amount makes zero difference to me?

I would absolutely do this and stop loaning money. Also consider whether you are effectively giving them a 0% interest payday loan to purchase luxury items. Do you want to be enabling that sort of behavior in any way? I most certainly don't.
Comment: I guess all of this parallels don't date your coworkers either... complications arise.  I guess I am lucky so far.
Comment: I feel like it is a lose lose situation as they might hold a grudge if I say no.
Answer: Bumming a buck off the person in the next cube over for the vending machine is no big deal, and most of the time people will pay it back in a day or so. But you're talking about non-trivial amounts of money here, and this is a big problem because they probably will not attempt to pay it back.
Short term: Your response should always be "I'm sorry, but I have a personal policy of not getting into financial arrangements with people I work with." Be firm and assertive. Remember, it's your money, they are asking you (not demanding). You are in no way obligated to say "yes." If they continue to pressure you, or their response gives you concern about your future career goals with the company, speak with HR.
Longer term: In my workplace, this sort of situation would not be allowed because it creates what they consider an inappropriate relationship or position of influence between two employees. Speak with HR and/or your corporate governance/compliance department about whether this is permitted or appropriate.
Answer: If you look deep within, do you get this question because the people who you lend money to appear to be living a materially satisfying life ?
Do you charge interest on the amount you lend ? If yes, then this seems to be a promising business arrangement. If not, when it comes to money, in my experience it always starts with small amounts which always get repaid. The borrower is also making grounds for a bigger loan amount in the future. When it comes to money, it is always best never to loan it out unless there seems to be a genuine and urgent need (for ex. medical expenses/death/etc) If I were you just for my peace of mind, I would stop this arrangement of providing loans.


Rio Dipladenia not making vines

Question: I have 2 diplandenia plants, one is making runners really well but the other is not, why? They are planted in the ground in different areas of my flower bed that does get different amounts of sunshine throughout the day.  Any idea why the one plant isn't making runners?
Answer: A photograph might be useful, but it's possible the plant you have which is climbing or 'making runners' is actually Mandevilla, and the other one is a true Dipladenia. These plants are often confused, even at point of sale, and do look fairly similar especially when young/small, but have different growth habits. Mandevilla is a vine and will climb up a trellis on its own, whereas Dipladenia tends to be smaller, shorter and won't climb unless trained and tied in. More info here https://www.gardeningknowhow.com/ornamental/vines/mandevilla/growing-a-dipladenia.htm. Otherwise, both these plants prefer full sun, so it may be the difference in conditions is having an impact on growth.

Rio Dipladenia not making vines


Oven spare parts - does serial code matter

Question: I need to replace the heating element on my whirlpool oven. The model number is AKZ451/IX/01 and the serial code is 858545115073.
When looking for spares online, I see heating elements listed as compatible for the same model but different serial codes - often for the same code but ending -072 or -074 rather than -073.
Will a heating element fit the same model but different serial code? Or do I need to find one that matches exactly?
Comment: I would suggest contacting the sellers you've identified. Tell them your model/serial and ask them if their part(s) will fit your oven. If they have a good return policy, they won't want to pay return shipping for something they know won't fit right from the start.
Answer: Yes, it often matters.  Manufacturers make design and parts changes through the life of a product and the heating element may come in multiple versions depending on which revision of the product you have.  The serial number or code is what gets you the right part for your unit.
I'll add that they generally don't list the serials like this unless it does matter.
Comment: If a retailer does not specify a serial code (i.e. only lists the part as fitting the model number), is it safe to assume it fits all versions of that model? Or is that too much to assume?
Comment: Yes, that's a good assumption.
Answer: I've worked on quite a few ovens over the years and yes, the serial code does matter. Take a heating element for example. One serial code might have spade connectors and another serial code might have screw terminals. the wattage and size/shape are the same but how they attach to the oven is quite different. If you have the experience you can modify one for the other but I wouldn't recommend it unless the original part just isn't manufactured anymore.
Answer: A model # and serial # for an appliance is similar to a VIN for a car. The difference is that VINs are standardized, and appliance model #s and serial #s are not. But the concept is the same. Typically the numbers identify:

Type of product - e.g., oven, cooktop, dishwasher, refrigerator
Functional type - e.g., single vs. double oven, convection (or not), self-cleaning (or not)
Size - e.g., wall ovens in the US are typically multiples of 3" - 27", 30", etc.
Style - particularly color, which is generally white, black, stainless steel and some form of beige/bisque/off-white
Version - nominally "model year" (which is largely the case for cars, though Tesla, for example, often makes significant changes within a "model year"), but sometimes identifying a particular control panel/electronics, which includes both hardware & firmware and therefore needs to all match when it comes to replacement parts.

Typically, but it can vary a lot by product type, manufacturer, version, etc., major parts will not vary much over the life of a product. On the other hand, some parts may vary depending on size (e.g., metal frame/enclosure and doors will differ based on size of an oven), style (any external parts will be different depending on color - for a car analogy, when you see a car with a door different from the rest of the car it is usually because they got one from a junkyard to match the make/model/year but couldn't find one matching the color) and other factors.
Electronics tend to be very specific to particular versions but may or may not vary by size and won't vary by style. Things like heating elements may not change at all over the life of the model, but they might if there were safety issues - e.g., changing the type of connector to make it more reliable, in which case the new heating element might not be compatible with the old oven (or vice versa).
An interesting twist to all of this is private-label products. Unlike small products (e.g., portable consumer electronics) where many different manufacturers will make substantially the same product but with their own unique designs (e.g., all the different Android phones - compatible software but each with their own specific battery, case, etc.), there are relatively few manufacturers of major appliances. Most house brands for major department stores such as Sears are made for them by GE, Whirlpool and other companies.
For example, many Sears Kenmore appliances are (or at least used to be, I have not checked recently) made by Whirlpool. Whirlpool also makes Kitchenaid as a higher-end product line. While the external parts vary to give each product line (e.g., Kenmore, Whirlpool, Kitchenaid) a different look and some different features, many of the internal parts are the same. A typical example is clothes dryer belts - the same belt and related parts will work on a bunch of Kenmore & Whirlpool dryers, matching only by size and by broad product range (range of years and group of brands/models).


Are there any options to let cat output with color?

Question: If I want to output a C source code file with syntax highlighting, can I use cat?
Comment: you could just use `bat` https://www.ostechnix.com/bat-a-cat-clone-with-syntax-highlighting-and-git-integration/
Answer: A GNU package, source-highlight, seems to do the trick (though isn't using cat -- as John T points out, this isn't possible with cat specifically). It's available via apt-get on Ubuntu, and requires the Boost regex library. Check your package manager to see if both are available, otherwise you can grab them from the web. The GNU page linked earlier has a link to Boost, I think.
After installation, I created a new script in my path called ccat. The script looks like:
#!/bin/bash
src-hilite-lesspipe.sh $1

Nothing fancy, just simplifying the less script they include with source-highlight. It acts just like cat when called in this fashion.
The included less script is a nice script to use as well, though. I just added the following to .bashrc:
export LESSOPEN="| /path/to/src-hilite-lesspipe.sh %s"
export LESS=' -R '

That script is included in the online manual for source-highlight, as well.
I guess you could alias cat to call src-hilite-lesspipe.sh $1 if you felt like ignoring cat altogether, but that might not be desirable.
Comment: I, personally, prefer an alias to one-line bash scripts ending with `$1` :).
Comment: Works on a Mac too with `brew install source-highlight` . Unable to color yaml :(
Comment: Yep, mitch_feaster, you're spot on. :]
Answer: To output syntax highlighted code with something like cat, I created a ccat command by following the instructions at http://scott.sherrillmix.com/blog/programmer/syntax-highlighting-in-terminal/.
#!/bin/bash
if [ ! -t 0 ];then
  file=/dev/stdin
elif [ -f $1 ];then
  file=$1
else
  echo "Usage: $0 code.c"
  echo "or e.g. head code.c|$0"
  exit 1
fi
pygmentize -f terminal -g $file

To output syntax highlighted code with something like less, I use vim as a less replacement.
alias less='/usr/share/vim/vim72/macros/less.sh'

Comment: How to install pygmentize: easy_install --install-dir $SOMEDIR  Pygments
Comment: I like this type of portable solutions. I added this script as a function to my bash `.functions` as `colorize(){...}`
Answer: To solve this, I used highlight. I made a function that tries to print the file with syntax highlighting, and if it fails it falls back to simply using cat to print the file. You can change the syntax highlighting theme to whatever you want.
function hl { # Overrides the cat command to use syntax highlighting
    # Highlight with 'moria' theme to terminal, and suppress errors
    highlight $1 -s moria -O xterm256 2> /dev/null

    if (($? != 0)); then # If the command had errors
        cat $1 # Just cat the file out instead
    fi
}

If you're on a Mac and you use Homebrew (highly recommended!), you can install highlight by running brew install highlight.  Otherwise, it should be available on most other package managers and can be downloaded here.
I also made a function to print out a file with syntax highlighting as html and open it in the browser to print (relies on the open command on OS X):
function hlprint {
    # Print with line numbers and 'moria' theme
    highlight $1 -l -o print.html -s moria
    open print.html # Open in browser
    sleep 5 # Give the browser time to open
    rm print.html highlight.css # Remove output files
}

Enjoy!
Answer: No, cat has no syntax highlighting abilities. If you'd like to view source code with syntax highlighting, pop it into vim or your editor of choice (that has syntax highlighting). This way, you can even page through the output if it's a long file using Ctrl + F (forward) and Ctrl + B (backwards).


SQL from/where or join?

Question: I was wondering performance wise what would be faster a join or a from and where query.
I am trying merge and update query but performance is terrible?
Comment: Post your [query plan](http://www.slideshare.net/Jackieken/explaining-the-explain-plan)
Comment: can you give more information about your problem?
Comment: Can you post your query?
Comment: Because you say your "performance is terrible" and provide nothing, we can't usefully speculate why the performance is terrible and an answer telling you that the `join` isn't different is too localized to be useful to anyone else. It's not about theory or syntax, it's about your application and you haven't revealed it.
Answer: If you are asking whether it is more efficient to use SQL 92 join syntax
SELECT empno, ename, dname
  FROM emp
       JOIN dept USING (deptno)

or to use the older join syntax
SELECT empno, ename, dname
  FROM emp  e,
       dept d
 WHERE e.deptno = d.deptno

the answer is that it doesn't matter.  The optimizer is automatically going to do an internal transformation from the SQL 92 syntax to the older syntax anyway.
If you have performance problems, it is highly unlikely that they are related to your choice of join syntax (though when Oracle first added support for SQL 92 join syntax, there were bugs relating to its ability to transform the SQL into the older style).
Comment: Just want to add to your answer that Oracle (at least Oracle 10)still has some problems with `JOIN` syntax. I can create `refresh fast on commit` materialized view using the old syntax (join condition in `where`), but I can't do the same with normal join.
Comment: @a1ex07 - still true in 11g (184.108.40.206, anyway).

SQL from/where or join?


When the loss outweighs the profit

Question: Let's say person A finds a chicken that its owner lost. He takes the chicken in and tries to find the owner. While he is attempting to find the owner he pays for the food of the chicken and is aware that the owner will pay him back for the food. Eventually, he finds the owner and hands him the chicken with the bill for all the food the chicken ate. The owner sees the bill is higher than the cost of the chicken. Who is liable for the bill for the chicken's food?
Comment: Do you mean to first ask if the finder was required to care for the chicken to that extent? Or is this assuming he mistakenly thought he needed to?
Comment: There's a similar incident in [Taanit 25a](https://hebrewbooks.org/shas.aspx?mesechta=10&daf=25&format=pdf).
Comment: אם יש שם בית דין, מתנה עימו בפני בית דין; ואם אין שם בפני מי יתנה, שלו קודם
Comment: @DoubleAA I thought he could care for the object then charge the owner for the care. Was I wrong?
Answer: It  would have the same Halacha as anything else that isn't cost effective to keep (eg it will rot) it's value is assessed by Beis Din and then it is sold with the money held for the one who lost it.
The Mishna (BM 28B) says anything  that eats but can not be used for productive work (to cover the cost of it's upkeep) should be sold in Beis Din. The Gemora (ibid) says you keep some ducks and chickens for thirty days before selling  them  (to give the owner a chance to re claim them - a chicken costs more than thirty days of chicken feed)
The Rambam (Gezalah V'Avaideh 13:15) says
מָצָא עֲגָלִים וּסְיָחִין שֶׁל רְעִי מְטַפֵּל בָּהֶן שְׁלֹשָׁה חֳדָשִׁים. וְשֶׁל בְּרִיאָה שְׁלֹשִׁים יוֹם. אֲוָזִים וְתַרְנְגוֹלִין גְּדוֹלִים מְטַפֵּל בָּהֶן שְׁלֹשִׁים יוֹם. מָצָא קְטַנִּים וְכָל דָּבָר שֶׁטִּפּוּלוֹ מְרֻבֶּה מִשְּׂכָרוֹ מְטַפֵּל בָּהֶן שְׁלֹשָׁה יָמִים. מִכַּן וְאֵילָךְ מוֹכְרָן בְּבֵית דִּין. וְכֵן פֵּרוֹת שֶׁהִתְחִילוּ לְהַרְקִיב וְכַיּוֹצֵא בָּהֶן מוֹכְרָן בְּבֵית דִּין
If one finds calves or ponies that pasture, he should care for them for three months. If he finds beasts that must be fed, he should care for them for 30 days.
If he finds large geese or roosters, he should care for them for 30 days. If he finds younger fowl and any other live being whose care is more costly than the wage that may be earned with it, he should care for them for three days. Afterwards, he should sell them in the presence of a court.
Similarly, if produce has begun to rot, or other similar things occur to a lost object, it should be sold in the presence of a court.

When the loss outweighs the profit


Best way to remove/delete all contacts in Marketing Cloud?

Question: Have a large amount of junk contacts that are not part of any data extensions that need to be deleted (400k) from the marketing cloud instance. What is the easiest way to go about doing this? If there is an option to delete all contacts and start with a fresh instance this is also an option we are considering.
Answer: To delete a large volume of contacts like this, you could query (or import) these records into a data extension and then call the REST API to delete all contacts within that data extension. Here's the endpoint for doing that.
This would only remove these records from sendable data extensions, in addition to deleting their contact information across channels in your account, so you'd need an additional process to remove these records from any other data extensions that they may be in. You can find an example here that could also be modified pretty easily to perform the delete w/ WS Proxy or suit any other requirements you have.
Comment: Thanks for your respone! Wanted to confirm this process will remove all contacts from the instance (Contact Builder) given they are not associated with any data extensions currently. What do you recommend as the best tool to use for executing REST API calls?
Comment: Yep, per the documentation: "This route deletes contact information from the account, including the Email, MobileConnect, and MobilePush apps. This deletion occurs at the enterprise level." I would recommend that you use Postman, which is a very helpful API testing tool that should allow you to get started quickly. Gortonington has a post on getting this going that you should find very useful: https://gortonington.com/introduction-to-making-api-calls-to-sfmc-from-postman/.


explain the cost function of scalar vector machine (SVM)

Question:
I am unable to understand the above cost function.
The two possible outputs ($y$) are $-1$ and $+1$.
As far as i know, $x_i$ values are individual training example values, $y_i$ are actual true values for that example and w is the weights that we are adjusting so as to minimise the cost.
if the actual output is $1$ and and my SVM predicts it as $-1$ my classifier is penalised, how will my SVM penalise?
how much will be the penalty?
I know this function gives cost 0 for that training example when prediction is correct and some penalty if predicted wrong.
I am also confused how $\max(0,1-y(wx+b))$ outputs the cost for one training example.
please enlighten me how this cost function works.
Comment: Does this answer your question? [Confusion on hinge loss and SVM](https://stats.stackexchange.com/questions/372999/confusion-on-hinge-loss-and-svm)
Answer: The following diagram I made illustrates the geometric meaning of $w \cdot x_i + b$ in a 2D plane:

where $w$ is a norm vector that controls the direction of the linear boundary $L$; for simplicity, let's assume $\|w\| = 1$, then $b$ represents an offset applied to $L$ along the opposite direction of $w$. The distance of a point $x_i$ to $L$ is therefore $w \cdot x_i - \left(-b\right) = w \cdot x_i + b$.
Let $\hat{y_i} = w \cdot x_i + b$ be the model's prediction for sample $i$; then we have:

If $y_i = +1$ and $\hat{y_i} \lt +1$, then $\mathrm{max}\left(0, 1 -  \hat{y_i}\right) = 1 - \hat{y_i} \gt 0$;
If $y_i = -1$ and $\hat{y_i} \gt -1$, then $\mathrm{max}\left(0, 1 - \hat{y_i}\right) = 1 + \hat{y_i} \gt 0$;
If $y_i = +1$ and $\hat{y_i} \ge +1$, then $\mathrm{max}\left(0, 1 -  \hat{y_i}\right) = 0$;
If $y_i = -1$ and $\hat{y_i} \le -1$, then $\mathrm{max}\left(0, 1 -  \hat{y_i}\right) = 0$;

The intuition here is that the penalty is $0$ only when the model's prediction is sufficiently correct (i.e. $y_i$ and $\hat{y_i}$ are of the same symbol and $\left|\hat{y_i}\right| \gt 1$).
Comment: ok thank u ..i get it now...but still i have a confusion about the 1−y(wx+b) part.
if i am not wrong yi in above equation is the actual output of training example xi.
so if suppose yi is -1 , the equation becomes 1+(wx+b) (replacing yi =-1). how this
equation will give a value less than or equal to zero so that no penalty is their for right prediction...plz give some intuition on "1−y(wx+b)" this part of equation
Comment: @rushikeshchaskar In the case where $y_i$ is $-1$, as you said, the second argument of the $\mathrm{max}$ function becomes $1 + \left(w x_i + b\right)$. For the loss to stay at $0$, $\left(w x_i + b\right)$ has to be less or equal to $-1$. To simplify things, let's assume we are working with 2-dimensional data, so the two parameters, $w$ and $b$ specifies a line on the 2D plane; the key here is to understand the expression $w x_i + b$ describe the "distance" from $x_i$ to the line defined by $w$ and $b$ (the unit of that distance is determined by $w$).
Comment: @rushikeshchaskar This "distance" has a direction. if $y_i$ is $-1$, then a "good" prediction that wouldn't incur penalty must have the same direction as $y_i$, i.e. $w x_i + b$ has to be negative; but this is not enough as SVM is a "maximum margin classifier"; this means the "distance" from $x_i$ to the linear boundary defined by the function $y = w x + b$ has to exceed the threshold of $1$ for the SVM algorithm to wavier the penalty --- when $y_i = -1$, this means $w x_i + b$ must be less than or equal to $-1$ (same direction as $y_i$ and magnitude is greater than or equal to $1$).
Comment: i know we shud avoid comments thanking others..but thank u so much for ur time.. i understood it well Xiubo Zhang