Why would Aphrodite be armed?

Question: Pausanias tells us that the Spartans worshipped Aphrodite Hoplismeni (~armed) and Aphrodite Areia (~of Ares, warlike):

[Paus. 3.15.10] Not far from the theatre is a sanctuary of Poseidon God of Kin, and there are hero-shrines of Cleodaeus, son of Hyllus, and of Oebalus. The most famous of their sanctuaries of Asclepius has been built near Booneta, and on the left is the hero-shrine of Teleclus. I shall mention him again later in my history of Messenia. A little farther on is a small hill, on which is an ancient temple with a wooden image of Aphrodite armed. This is the only temple I know that has an upper storey built upon it.
[Paus. 3.17.5] On the left of the Lady of the Bronze House they have set up a sanctuary of the Muses, because the Lacedaemonians used to go out to fight, not to the sound of the trumpet, but to the music of the flute and the accompaniment of lyre and harp. Behind the Lady of the Bronze House is a temple of Aphrodite Areia (Warlike). The wooden images are as old as any in Greece.
[Paus. 3.23.1] Cythera lies opposite Boeae; to the promontory of Platanistus, the point where the island lies nearest to the mainland, it is a voyage of forty stades from a promontory on the mainland called Onugnathus. In Cythera is a port Scandeia on the coast, but the town Cythera is about ten stades inland from Scandeia. The sanctuary of Aphrodite Urania (the Heavenly) is most holy, and it is the most ancient of all the sanctuaries of Aphrodite among the Greeks. The goddess herself is represented by an armed image of wood.
Source: Pausanias. Pausanias Description of Greece with an English Translation by W.H.S. Jones, Litt.D., and H.A. Ormerod, M.A., in 4 Volumes. Cambridge, MA, Harvard University Press; London, William Heinemann Ltd. 1918

Why would the goddess of love, beauty, and procreation be armed? She wasn't exactly known for her military attributes. In fact, in Book 5 of the Iliad Zeus very bluntly dismisses her abilities as a warrior:

Of a surety now Cypris has been urging some one of the women of Achaea to follow after the Trojans, whom now she so wondrously loveth; and while stroking such a one of the fair-robed women of Achaea, she hath scratched upon her golden brooch her delicate hand." So spake she, but the father of men and gods smiled, and calling to him golden Aphrodite, said: "Not unto thee, my child, are given works of war; nay, follow thou after the lovely works of marriage, and all these things shall be the business of swift Ares and Athene."
Source: Homer. The Iliad with an English Translation by A.T. Murray, Ph.D. in two volumes. Cambridge, MA., Harvard University Press; London, William Heinemann, Ltd. 1924.

Was this militaristic version of Aphrodite a Lacedaemonian peculiarity? Could, perhaps, these images that are "are as old as any in Greece" be an allusion to Ishtar, an echo of Aphrodite's Mesopotamian origins?
Comment: But....but [she's NOT armed](https://goo.gl/images/lT9tgn)....
Comment: https://digitalt.uib.no/bitstream/handle/1956.2/2995/The%20transformations%20of%20the%20armed%20Aphrodite_Flemberg.pdf This essay might provide some answers.
Comment: Thank you @AlexeyNekrashevich, that is indeed a very interesting read. Perhaps you'd be interested in summarizing its key points in an answer?
Comment: "SPARTAN GODS. What is YOUR profession?" - "HA-OOH! HA-OOH! HA-OOH!" SCNR :D
Comment: This is an interesting paper, which suggests that either the statue of Aphrodite shows her holding her lover Ares' attributes, or that the artist wished to play with gender roles. (The Hellenistic fascination with the hermaphrodite is another such case.) [Another paper](https://www.scribd.com/document/176242337/Graf-War-Women-and-Warlike), by Fritz Graf, focuses on the gender inversion, noting other rituals and images that involve women and arms, suggesting that such images and the rituals or stories behind them may represent an attempt to "think the unthinkable".
Answer: Why would the goddess of love, beauty, and procreation be armed? (Note, all the links are the same source.)
The cult of an armed Aphrodite was present in Laconia in early Archaic times. (PG2) The first images of Aphrodite were armed. (PG3) The first can be traced back to 380 B.C. But it is carried in a way that characterizes Aphrodite as a love goddess. (PG7) There are images of Aphrodite taking part in the Gigantomachy, but the source doesn't count this as prove that Aphrodite was a "war goddess." There are seventeen copies of a statue with Aphrodite putting on a sword ("This is clearly not a war goddess, but the love goddess donning the sword of Ares."). (PG4) The source says, "If the sculptor got the idea of creating an 'armed Aphrodite' from the old xoana, he created exactly the same thing as the poets, changing a war goddess into the familiar love goddess and thereby reestablishing the normal gender roles of society." (PG5) The source believes that Aphrodite was armed because it was warranted, possibly as a city goddess and not as a war goddess. (PG12)
To sum up, she was not originally seen as a war goddess. It is believed that before the Greek Pantheon as we know it came to be, Athena, Artemis and Aphrodite were one goddess. But, because a whole lot of males didn't like a goddess being so active/involved, split them up. Then, when a few of the older images cropped up, poets and artists reinterpreted them. (PG12-13)
Comment: I was thinking about Ishtar, the Babylonian goddess of war and beauty.  And not surprised, the link to the chapter you provide talks of her.
Answer: Aphrodite is linked with Astarte, Near Eastern goddess of love and war. In Greece, her connection with war is through her affair with Ares. In one ancient sculpture, the Capuan Aphrodite, she may be holding Ares' shield, which in myth she took from him because she thought her reflection in it was so beautiful. She was also worshipped as Armed Aphrodite (Hoplitismenos) on AkroKorinth. A sculpture of her in Athens shows her with 1 bared breast, and a baldric and quiver for arrows. She would have held a bow in her left hand, now missing. Together, Aphrodite and Ares (Love and War), had a daughter, Harmonia (Harmony).

Why would Aphrodite be armed?


How to protect Flutter app from reverse engineering

Question: I am trying to develop a payment application using Flutter, is there any way to protect my application API's and Tokens or make app reverse engineering proof.
Comment: Note that protecting your code and protecting API and API key details are different things.
Comment: I am speaking in a way to provide the protection for the payment application
Comment: @venkat0107 One can extract any deterministic information by tracing and connecting the dots until the extreme end. Having read all the quality content out of the Answer thread, clicking that link backed by the phrasing in your comment somehow left an impression of clickbait. I am sure you did not mean to play jokes by commenting it but help the OP in a way you could at that point in time; however, I would have suggested to not hide the link under markdown in such link-oriented comments.
Answer:
I am trying to develop a payment application using Flutter, is there any way to protect my application API's and Tokens or make app reverse engineering proof.

If you are looking for bulletproof solutions in the sense they are 100% effective in preventing reverse engineering a mobile app binary to extract tokens or secrets from it then I have to tell you that unfortunately, this is not possible to achieve, but you can make it harder... How hard it will depend on the effort and resources you are willing to put in or required by law for your use case.
In the other hand protecting mobile API's from being accessed from others then a genuine instance of your mobile app it is possible to achieve with a very high degree of confidence.
How easy can it be to extract an API key from a Mobile APP?
Reverse engineering a mobile app binary to extract an API token from it is very easy with the plethora of Open-Source tools out there, as I demo in my article How to Extract an API key from a Mobile App with Static Binary Analysis:

The range of open source tools available for reverse engineering is huge, and we really can't scratch the surface of this topic in this article, but instead we will focus in using the Mobile Security Framework(MobSF) to demonstrate how to reverse engineer the APK of our mobile app. MobSF is a collection of open source tools that present their results in an attractive dashboard, but the same tools used under the hood within MobSF and elsewhere can be used individually to achieve the same results.

Alternatively, a Man in the Middle(MitM) attack can be used to extract the same API key, and for this, we also have Open-Source tools, like mitmproxy that I demo in my article Steal that Api Key with a Man in the Middle Attack:

In order to help to demonstrate how to steal an API key, I have built and released in Github the Currency Converter Demo app for Android, which uses the same JNI/NDK technique we used in the earlier Android Hide Secrets app to hide the API key.
So, in this article you will learn how to setup and run a MitM attack to intercept https traffic in a mobile device under your control, so that you can steal the API key. Finally, you will see at a high level how MitM attacks can be mitigated.

Defending against Reverse Engineering
Reverse engineering is a huge topic and you can learn more about the techniques used in reverse engineering by reading the markdown file 0x04c-Tampering-and-Reverse-Engineering.md in the Github repo for the OWASP Mobile Security Testing Guide(MSTG).
You cannot make the mobile app 100% reverse engineering proof, but you can have a lot of hardening code techniques to make it more difficult and/or use some runtime self-protection mechanisms, aka RASP:

Runtime application self-protection (RASP) is a security technology that uses runtime instrumentation to detect and block computer attacks by taking advantage of information from inside the running software.
RASP technology is said to improve the security of software by monitoring its inputs, and blocking those that could allow attacks, while protecting the runtime environment from unwanted changes and tampering.

You can read some of the possible anti-reversing defences in the OWASP MSTG repository:

Android - 0x05j-Testing-Resiliency-Against-Reverse-Engineering.md
iOS - https://github.com/OWASP/owasp-mstg/blob/master/Document/0x06j-Testing-Resiliency-Against-Reverse-Engineering.md

So, these are all approaches that make decisions in the client-side, thus prone to be bypassed by using instrumentation frameworks, like Frida:

Inject your own scripts into black box processes. Hook any function, spy on crypto APIs or trace private application code, no source code needed. Edit, hit save, and instantly see the results. All without compilation steps or program restarts.

Am I telling you that is worthless to use them? No, by the contrary you should add as many layers of defences as you can afford, just like how castles from the past centuries were doing to protect against the enemy breaching the outer layers of defence.
The Difference Between WHO and WHAT is Accessing the API Server
Before I dive into how you can defend your API server I would like to first clear a misconception that usually I find among developers of any seniority, that is about the difference between who and what is accessing an API server.
I wrote a series of articles around API and Mobile security, and in the article Why Does Your Mobile App Need An API Key? you can read in detail the difference between who and what is accessing your API server, but I will extract here the main takes from it:

The what is the thing making the request to the API server. Is it really a genuine instance of your mobile app, or is it a bot, an automated script or an attacker manually poking around your API server with a tool like Postman?

The who is the user of the mobile app that we can authenticate, authorize and identify in several ways, like using OpenID Connect or OAUTH2 flows.

So think about the who as the user your API server will be able to Authenticate and Authorize access to the data and think about the what as the software making that request in behalf of the user.
Lockdown the API server to the Mobile App
So, anything that runs on the client-side and needs some secret to access an API server can be abused in different ways and you can learn more on this series of articles about Mobile API Security Techniques. This articles will teach you how API Keys, User Access Tokens, HMAC and TLS Pinning can be used to protect the API and how they can be bypassed.
To solve the problem of what is accessing your mobile app you need to use one or all the solutions mentioned in the series of articles about Mobile API Security Techniques that I mentioned above and accepted that they can only make unauthorized access to your API server harder to bypass but not impossible.
A better approach can be employed by using a Mobile App Attestation solution that will enable the API server to know with a very high degree of confidence that only responds to requests from a genuine mobile app. I recommend you to read this answer I gave to the question How to secure an API REST for mobile app? that goes in more detail about it.
Do You Want To Go The Extra Mile?
In any response to a security question, I always like to reference the excellent work from the OWASP foundation.
For APIS
OWASP API Security Top 10

The OWASP API Security Project seeks to provide value to software developers and security assessors by underscoring the potential risks in insecure APIs, and illustrating how these risks may be mitigated. In order to facilitate this goal, the OWASP API Security Project will create and maintain a Top 10 API Security Risks document, as well as a documentation portal for best practices when creating or assessing APIs.

For Mobile Apps
OWASP Mobile Security Project - Top 10 risks

The OWASP Mobile Security Project is a centralized resource intended to give developers and security teams the resources they need to build and maintain secure mobile applications. Through the project, our goal is to classify mobile security risks and provide developmental controls to reduce their impact or likelihood of exploitation.

OWASP - Mobile Security Testing Guide:

The Mobile Security Testing Guide (MSTG) is a comprehensive manual for mobile app security development, testing and reverse engineering.
Answer: Unfortunately, you can't. There is no way to protect a "secret" from reverse engineering if you distribute it to users. The simplest way to think about this is that a dedicated reverse engineer will be able to perfectly emulate any encryption, obfuscation, or other measures that you take. If you don't want a user to have something (such as a secret token, password, key, etc.), don't distribute it to them.
Comment: how WhatsApp is protecting there code.
Answer: The reverse engineering protection is a gargantuan task since you have to cover both iOS and Android world specifics. Unless you decide to implement your own solution, there are various libraries (freeRASP, flutter_jailbreak_detection) solving this issue also. The downside is that if someone cracks (eg. Frida script, Magisk plugin) the library, all apps which depend on it are vulnerable also. Eg. many reverse engineering toolkits already contain bypass for popular RootBeer library. If you can't create a solution from scratch, you can use any RASP library and add your spices on top of it - RE protection should always contain as many layers as possible.
Disclaimer: I contribute to freeRASP.
Example (using freeRASP):
<code>  // For Android
  androidCallback: AndroidCallback(
      onRootDetected: () => exit(0),
      onEmulatorDetected: () => exit(0),
      onFingerprintDetected: () => exit(0),
      onHookDetected: () => exit(0),
      onTamperDetected: () => exit(0),
  ),

  // For iOS
  IOSCallback: IOScallback(
    onSignatureDetected: () => exit(0),
    onRuntimeManipulationDetected: () => exit(0),
    onJailbreakDetected: () => exit(0),
    onPasscodeChangeDetected: () => exit(0),
    onPasscodeDetected: () => exit(0),
    onSimulatorDetected: () => exit(0),
    onMissingSecureEnclaveDetected: () => exit(0),
  ),

  // Common for both platforms
  onDebuggerDetected: () => exit(0),
</code>
Hovewer, attacker can locate (in the native Android/iOS code) underlying checking methods and disable them, both statically and dynamically.
Comment: @Cordelia I did it wrong at the step converting the hash to base64. Check your code to make sure you don't do a base64Encode. Instead, the correct way is to convert to base64. They are different. not sure if you're the same case as mine.
Comment: I try the freeRASP and found that the onTamperDetected callback is always executed. I can't find out what's wrong here. The only thing that I think about is the expectedSigningCertificateHash. But I also try many times without luck. Could you help? thanks.
Comment: @Nero I have the same problem. Did you find the solution?
Comment: The proper way to obtain your signing certificate hash is documented on this page:

https://github.com/talsec/Free-RASP-Android/wiki/Getting-your-signing-certificate-hash-of-app


Why symmetry groups as opposed to e.g. monoid or ring?

Question: Why is it that symmetries of a system are usually realized as coming from groups (and categorified versions of it) and not other algebraic structures? Why are the terms "symmetry monoid" or "symmetry ring" not frequent (or existent) in the literature? Wouldn't, for instance, the former allow for a description of irreversible transformations? Is a ring structure for symmetries "too much" to require?
Comment: In QFT people have been discussing non-invertible symmetries for quite some time now. They are indeed described by rings.
Comment: This question is about physics in my view, though the subject is about the use of math in phys and this is the right place for it. To answer one should know more physics than mathematics. The definitions of ring and monoid can be immediately learned from Wikipedia, differently from the underpinning physics necessary to answer. So it should not be closed.
Comment: This isn't about physics, it should be asked over on [Mathematics](https://math.stackexchange.com/).
Comment: Possible duplicate: https://physics.stackexchange.com/q/561118/84967
Answer: Symmetries form groups because (a) they have an identity ("do nothing"), and (b) each operation is invertible. Non-invertible transformations would form a monoid, but such transformations do not describe a "symmetry" because some property of the system is destroyed by the transformation (you can't get back to the original state -- if you could you would have an inverse).
Rings and algebras do have applications in physics, but because they involve multiple operations they go beyond the simple requirements of a symmetry.
Answer: When we talk about "symmetries" of some object - we mean that the object "stays the same" under certain transformations. So, let us identify a set of such transformations $G$ and objects $X$. An element of the transformation set $g\in G$ should be able to act on an object $x \in X$. I'll denote this action as function application $g(x) \in X$.
From here, we naturally are able to able to compose these transformations:
$$ g_1,g_2 \in G\quad \Rightarrow \quad g_1g_2 \in G : (g_1g_2)(x) = g_1(g_2(x))$$
This composition is associative and has a unique unit $e \in G : \forall x\in X. e(x) = x$
(Notice the uniqueness of $e$ - important in the following.)
We can get the inverse axiom if we assume that $G$ is finite. In that case for every $g \in G$ there are two powers $a > b > 0$ such that $g^a = g^b$ as a result we've got $g^{a-b} = e$ so we've got the inverse $g^{a-b-1}$. This line of argument should also work for compact manifold structures to get the Lie groups like $SU(2)$.
In my experience, when physicists talk about "symmetry groups" they assume finiteness/compactness without stressing (or, sometimes, being aware of) it.
If we don't assume finiteness/compactness of $G$ then, generally, we don't have the inverse axiom. The most obvious example is fixed-increment translations:
$$T(f(x)) = f(x + 1)$$
Constant functions $f$ are symmetric under $T$, but $T$ and $e$ don't generate a group.
Comment: I'm not sure your last example makes sense. There is a group in question - the group $\mathbb{Z}$ of the integers under addition.
Comment: In particular, whilst physicists do often care about finite groups (in a crystallography setting) or compact groups (in a field theory setting) - this is more for reasons that depend on the specific case at hand, than an avoidance of non-compact groups. The Lorentz and Poincare groups are non-compact and physicists are perfectly happy with them.
Comment: @jacob1729 check out the difference between a *monoid* of natural numbers $\mathbb{N}$ and the *group* of integers $\mathbb{Z}$. I intentionally stated that only using $e$ and $T$ you won't be able to generate a group.
Comment: @jacob1729 My point was that quite often physicists state that "symmetry" implies invertibility. And that this is formally correct only when the transformation set is finite/compact.
Comment: Ah, this wasn't clear that you were only considering right translations (in group theory language you would definitely say that $\mathbb{Z}^+$ is generated by $1$). I'm not really clear what the point of this example is though since the left translations are also symmetries. Intuitively, if doing $X$ is a symmetry of a set $S$ then it should at least preserve the cardinality $|S|$ and is therefore a bijection and so has an inverse.
Comment: @jacob1729 $\mathbb{Z}^+$ is not a group, though, not even a monoid under addition. So, yeah left translations are symmetries but they don't form a group. I agree that if you assume invertibility then the whole discussion is trivial. I understood the OP question as "why we are assuming invertibility" - tried to address it.
Comment: Apologies for notation, I meant $(\mathbb{Z},+)$ which I agree could be confusing. Nonetheless, the word 'symmetry' is a natural language term, not a mathematical term. And I think its weird to consider symmetries that are not bijections - your example does not furnish one and so I think its artificial.
Answer: Physics uses mathematics as a tool to have theories that describe existing data and can predict new ones. It depends on observations and measurements.
The SU groups came into the study of data slowly. First SU(2), to describe the two baryon states of proton and neutron, that are almost of the same mass. It was useful in nuclear physics studies.
SU(3) first appeared as useful in describing particle data in the eightfold way,

The $Ω^-$ was a prediction , its discovery  it validated the quark model .
The  SU(3) color was found crucial for fitting strong interaction data. And so on.
If in the future experiments and data more complicated mathematical concepts will be needed to get a fit and predict new situations, they will be used.
The choice of the tools is indicated by the data, and not the other way around, at least until/if we have a theory of everything.


Uploading file with 45MB size using data loader keep failing

Question: I'm trying to upload files to Salesforce using data loader and the file size is around 45MB every time I'm trying to upload the file I got error with maximum retries reached, any idea how to deploy large file using data loader.
Screenshot:
Comment: Dataloader can handle up to 5 million records and upload file size is 50 MB and I suspect it shouldn't be a problem with dataloader.  Can you try using batch size limit to 1 (https://help.salesforce.com/articleView?id=000322505&type=1&mode=1).  Also if possible kindly add screenshot of the error message.
Comment: @Vinay I added screenshot.
Answer: The Data Loader uses the SOAP API, which has an inherent limit of 50MB. SOAP is an XML-based protocol, so binary data has to be Base64 encoded, which turns three bytes into four, effectively reducing the maximum payload for binary data by 25%. The actual maximum ends up being around 37.5MB (less than 39,321,600, as the bytes in the protocol itself reduce this number further). This is called out in the documentation in various places:

The maximum file size you can upload via the SOAP API is 50 MB. When a document is uploaded or downloaded via the API, it is converted to base64 and stored in VersionData. This conversion increases the document size by approximately 37%. Account for the base64 conversion increase so that the file you plan to upload is less than 50 MB after conversion.

If you want to upload files larger than that, you need something that can support large binary data (as described in Insert or Update Blob Data). You would either need to modify the source code or find another ETL tool that supports large files. You'll want to do your own research on this subject. I'm not aware of any specific tools out there that can support this.


G be a finite group and H be a non trivial proper subgroup of index 3, then G is not simple.

Question: If the index of a subgroup is the smallest prime dividing the order of group then that subgroup is normal, with this, I am done with the case order of group is odd. How to proceed when order is even.
Answer: $H < G$, $[G : H] = 3.$ This defines action of $G$ on cosets $G/H$ — so there's a homomorpism $G \to S_3$ to symmetric group on 3 elements. If $|G| > 6$, then kernel is nontrivial, so $G$ is not simple. If $|G| \leq 6$, then (as there's index 3 subgroup) $|G| = 1, 3, 6$. First two possibilities are ruled out by existence of nontrivial index 3 subgroup, and there are 2 groups of order 6 (let's leave this as exercise) neither of which are simple.
Answer: In general: if $G$ is a finite non-abelian simple group and $H$ is a subgroup, then $|G:H| \geq 5$.
Proof (Sketch) Assume $|G:H| \leq 4$. Let $G$ act by left multiplication on the left cosets of $H$. The kernel of this action is $core_G(H)=1$, since $G$ is simple. Hence $G$ can homomorphically be embedded in $S_{|G:H|}$. Since $S_4$ is solvable and $G$ is simple, it follows that $G=1$, a contradiction.
Observe that $A_5$ is the first example of a non-abelian simple group and that $|A_5:A_4|=5$.


ogr2ogr libcurl error in Mac OS

Question: I am working to run "ogr2ogr" command in terminal.
I got this error message.

dyld: Library not loaded: libcurl.4.dylib   Referenced from:
  /usr/local/bin/ogr2ogr   Reason: Incompatible library version: ogr2ogr
  requires version 8.0.0 or later, but libcurl.4.dylib provides version
  7.0.0

There is a mismatch between the system requirement and library requirement. As I can tell, the latest curl is version 7 http://curl.haxx.se/download.html,
why is this asking for version 8? I also tried to upgrade curl with brew
but couldn't symlink into /usr/local, because would cause conflicts with
the OS.
In order to figure this problem: I started by figuring out if the Curl is used by different
$$ Which curl
/usr/bin/curl
I installed GDAL on mac by fellowing these instructions (StackOverFlow Post).
To explore where the ogr2ogr is, I run the command.
$$ which ogr2ogr
/usr/local/bin/ogr2ogr
I fellowed these instructions :

Download curl sources: http://curl.haxx.se/download/curl-7.25.0.zip
Unarchive the zip file somewhere
Open a Terminal window and go to the directory containing curl sources
Type: CFLAGS=-m64 ./configure
Type: make
Type: sudo make install

Source :
But it doesn't work out.
Another approach
I downloaded this file, unzip it into the bin/ directory, but when I tried to run it. I got this problem
../../bin/libcurl.4.dylib: cannot execute binary fil

There is one answer I found that seems very helpful, but I couldn't find it very practical.

If you didn't define the --with-curl option when running GDAL
  ./configure, then
      GDAL will link with the curl library indicated by "curl-config --libs"
      You likley have several libcurl on your system and the one that got used when
      linking GDAL is not the one available at runtime.
      The 8.0.0 or 7.0.0 don't necessarily reflect the "human readable" version of
      the curl library. It might be some other numbering scheme related to how the
      API/ABI of the library evolves, or something linked to packaging.

How can we do that in a practical way.
I read many articles before posting this question here, Anyone have any ideas on how to solve this problem ?
Answer: Have you checked this out?
Python Anaconda linking
I did that, then simlinked some stuff:
ln -s libcurl.4.0.0.dylib libcurl.3.dylib

Another error came up, now pertaining to libxml2.
I did:
brew install libxml2 libxslt
brew link --force libxml2 libxslt

And now ogr2ogr is finally working

ogr2ogr libcurl error in Mac OS


What does the client do in Command Pattern?

Question: I am reading the headfirst design patterns book.
I observe that the client is shown analogous to a hotel customer, who creates an order(command) object, the waitress(invoker) picks it and calls its execute() method which in turn calls the chef's cook() method(chef=receiver)
In the command pattern class diagram, I can see client is associated with Receiver as well as the ConcreteCommand class. I am unable to get the example because in real world, a customer is not supposed to know about the cook and set the instructions for him. Other concern is that in the command pattern class diagram, I observe that Client is not shown associated with Invoker, but in the attached java program I can see the Invoker reference in the Client class.
Totally confused about what Client module does in the command pattern. Clear about the rest 4 modules.
Answer: Read this: http://www.oodesign.com/command-pattern.html

Client creates a ConcreteCommand object and sets its receiver [...] The Client asks for a command to be executed.

It even has sample code that show what the client does:

The client creates some orders for buying and selling stocks (ConcreteCommands). Then the orders are sent to the agent (Invoker). [...]
public class Client {
    public static void main(String[] args) {
        StockTrade stock = new StockTrade();
        BuyStockOrder bsc = new BuyStockOrder (stock);
        SellStockOrder ssc = new SellStockOrder (stock);
        Agent agent = new Agent();

        agent.placeOrder(bsc); // Buy Shares
        agent.placeOrder(ssc); // Sell Shares
    }
}

Comment: As per your example,
StockTrade is the receiver.
BuyStockOrder is a ConcreteCommand.
Agent is the invoker.

Client class is associated to all three of them

But according to the class diagram attached above Client does not know about the Invoker, i.e. the Agent.
Still confused
Comment: So you're confused because the diagram doesn't show a "calls" association between Client and Agent, where the client code calls the `placeOrder()` method? Yeah, it does seem to be missing from these diagrams.
Comment: yes, but i saw the same diagram in the book as well, so confused if i am missing something
Comment: You're not. The diagram is. If it has a line from Client to StockTrade, a similar line should exist from Client to Agent. In real (non-sample) code, both Receiver (StockTrade / Cook) and Invoker (Agent / Waiter) would exist prior to Client (Customer) arriving on the scene, so they would be obtained through means other than `new`.
Comment: Agreed to that. What I was thinking is that client is not going to talk to invoker, that code can be a part of invoker or some business class.Client is just responsible for creating the ConcreteCommand and setting the actual receiver in it. Invoker can execute the command at a later time once that wiring is done. Here they wanted to create a single demo program and hence assimilated all the stuff into a single program.
Answer: You've stumbled upon the challenge with demonstrating design patterns with analogy, by a single concrete example, or with object diagrams. Except for very simple patterns, the concepts and examples usually don't map perfectly to all useful instances of the pattern.
I highly recommend that you pick several sources to learn any of the more complex design patterns. Every explanation is going to have strengths and weaknesses, and you'll probably get a more accurate picture if you take several viewpoints into account. There are plenty of free sources available on the Internet, so you probably don't need to buy additional books (except, eventually, the original Design Patterns book, for reference purposes).
What isn't clear in the diagram is that the Client, the Invoker, and the Receiver are abstract concepts, and don't have a single form that always applies in every case. In any particular implementation of the command pattern, most of these roles are going to be present (except maybe the Receiver - it is possible that the command is self-contained). You may even be able to point out a specific bit of code that maps to each of these roles, but it's going to map differently in every application. It may even map differently in separate parts of the same application.
There are parts of the diagram you shared that I have problems with, because they are not always true. The Client might not directly access or even know about the Receiver. The Client might also not know about specific ConcreteCommand objects. The Client might know how to ask for an instance of a command, and it might know some information that helps pick the right command. However, the client might in some cases be oblivious to which ConcreteCommand object was executed, especially if you combine the command pattern with the AbstractFactory pattern.

in real world, a customer is not supposed to know about the cook and set the instructions for him

Analogies and models tend to break down or become confusing when you compare them strictly to reality. It is best to try to figure out what the model is trying to accomplish, and which possible interpretation of reality that the model is trying to account for.
Also, not all models/analogies are any good :) Sometimes they don't actually get the job done.

I observe that Client is not shown associated with Invoker

This is perfectly valid in some implementations of the pattern. The code that eventually calls execute() may not be the same code that is capable of accepting actions.
The diagram may show a single box, but in the restaurant analogy, the waiter, the cooks, the busboys, the host, the cashier, etc, are all a part of that Invoker role.
The problem with the diagram is that the client eventually has to pass the command off to the invoker. The invoker itself might have a way to accomplish this, or there may be some sort of system in between (like a command queue). Either way, in their explanation, the invoker role handles both things, and the client must therefore know about the invoker.
Finally:

What does the client do in Command Pattern?

The Client is responsible for knowing that it wants a command to be done
The Client is responsible for knowing how to pick which command gets done, and get an instance of it (even if the client delegates the actual construction of that ConcreteCommand to some other part of the system)
The Client is responsible for knowing how to pass off a command so that it will eventually be invoked (passing it to some object in the Invoker role, even if that command eventually gets passed off to some other object that actually calls execute())
The Client is responsible for actually handing off the command to the Invoker (whether it is directly handed off, or passed off to some intermediate part of the system first)
Answer: So the idea of a client is in opposition to the idea of a server. (for get the restaurant metaphor for a minute). The server is the centralized application, the client is the interface presented on a users machine. The client machine or GUI signals wither a receiver (middle man) or your program directly to make things happen.
I hope this makes things a little clearer.


How do you get the run parameters and runId within Databricks notebook?

Question: When running a Databricks notebook as a job, you can specify job or run parameters that can be used within the code of the notebook. However, it wasn't clear from documentation how you actually fetch them. I'd like to be able to get all the parameters as well as job id and run id.
Answer: Job/run parameters
When the notebook is run as a job, then any job parameters can be fetched as a dictionary using the dbutils package that Databricks automatically provides and imports. Here's the code:
run_parameters = dbutils.notebook.entry_point.getCurrentBindings()

If the job parameters were {"foo": "bar"}, then the result of the code above gives you the dict {'foo': 'bar'}.  Note that Databricks only allows job parameter mappings of str to str, so keys and values will always be strings.
Note that if the notebook is run interactively (not as a job), then the dict will be empty. The getCurrentBinding() method also appears to work for getting any active widget values for the notebook (when run interactively).
Getting the jobId and runId
To get the jobId and runId you can get a context json from dbutils that contains that information. (Adapted from databricks forum):
import json
context_str = dbutils.notebook.entry_point.getDbutils().notebook().getContext().toJson()
context = json.loads(context_str)
run_id_obj = context.get('currentRunId', {})
run_id = run_id_obj.get('id', None) if run_id_obj else None
job_id = context.get('tags', {}).get('jobId', None)

So within the context object, the path of keys for runId is currentRunId > id and the path of keys to jobId is tags > jobId.
Comment: py4j.security.Py4JSecurityException: Method public java.lang.String com.databricks.backend.common.rpc.CommandContext.toJson() is not whitelisted on class class com.databricks.backend.common.rpc.CommandContext
Comment: I've the same problem, but only on a cluster where credential passthrough is enabled. `spark.databricks.passthrough.enabled true`
Comment: @JorgeTovar I assume this is an error you encountered while using the suggested code. What version of Databricks Runtime were you using?
Answer: Nowadays you can easily get the parameters from a job through the widget API. This is pretty well described in the official documentation from Databricks. Below, I'll elaborate on the steps you have to take to get there, it is fairly easy.

Create or use an existing notebook that has to accept some parameters. We want to know the job_id and run_id, and let's also add two user-defined parameters environment and animal.
 # Get parameters from job
 job_id = dbutils.widgets.get("job_id")
 run_id = dbutils.widgets.get("run_id")
 environment = dbutils.widgets.get("environment")
 animal = dbutils.widgets.get("animal")

 print(job_id)
 print(run_id)
 print(environment)
 print(animal)

Now let's go to Workflows > Jobs to create a parameterised job. Make sure you select the correct notebook and specify the parameters for the job at the bottom. According to the documentation, we need to use curly brackets for the parameter values of job_id and run_id. For the other parameters, we can pick a value ourselves.

Note: The reason why you are not allowed to get the job_id and run_id directly from the notebook, is because of security reasons (as you can see from the stack trace when you try to access the attributes of the context). Within a notebook you are in a different context, those parameters live at a "higher" context.

Run the job and observe that it outputs something like:
 dev
 squirrel
 137355915119346
 7492
 Command took 0.09 seconds

You can even set default parameters in the notebook itself, that will be used if you run the notebook or if the notebook is triggered from a job without parameters. This makes testing easier, and allows you to default certain values.
 # Adding widgets to a notebook
 dbutils.widgets.text("environment", "tst")
 dbutils.widgets.text("animal", "turtle")

 # Removing widgets from a notebook
 dbutils.widgets.remove("environment")
 dbutils.widgets.remove("animal")

 # Or removing all widgets from a notebook
 dbutils.widgets.removeAll()

And last but not least, I tested this on different cluster types, so far I found no limitations. My current settings are:
 spark.databricks.cluster.profile serverless
 spark.databricks.passthrough.enabled true
 spark.databricks.pyspark.enableProcessIsolation true
 spark.databricks.repl.allowedLanguages python,sql

Comment: Might be worth looking into dbutils.job.taskValues.set
Comment: this one explains really good way to access the parameters. thanks @Cloudkollektiv
Comment: Hey @Cloudkollektiv is there a way to have these parameters be updated for the next run, say you want the animal:squirrel to be animal:wolf for the next job run is that possible?


How to connect OV7670 cam to Raspberry Pi Pico

Question: I have a raspberry pi pico and OV7670 cam. I want to connect them and get a camera output as a video, So I can use image recognition to identify objects (tennis balls) to collect them using a setup with motor drive+motor setup. Please help with your ideas and reference links. Thanks in advance.
Answer: You can use the RPI pico C sdk to write firmware code for reading image data pins of off ov7670.
This explains how to setup the PCIO C SDK https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf
Look at the ov7670 schematic here to figure out the ov7670 hookup/wiring to PICO http://web.mit.edu/6.111/www/f2016/tools/OV7670_2006.pdf
You'd realize that PICO's GPIO sampling rate is slower than ov7670 data rate. You might be able to do something to compensate for the data rate mismatch, maybe only read a few selective lines every frame. Might not work for video, but maybe stills, or video in grayscale on a lower resolution might work.
Let me know if you need more help!
Comment: I find out that pico can't read with ov7670 efficiently. So I barrow pi to do this work. Its a raspberry Pi 3 B model. The thing is I can't install  opencv in the board. When I tried to download all package its struck on middle and when I try to download zip. its very slow and download for 13 to 15mb then Its retiring to download. How should resolve this. can you help me.
Comment: YOCTO can be used for making custom Linux builds. Yocto uses meta layers making build builds for different targets / systems and adding different packages. There is is a meta layer for Raspberry Pi, you can look at it here https://github.com/agherzan/meta-raspberrypi Learn a little about YOCTO, and then use meta-rapberrypi to add opengl etc and other packages of your liking to your build.
Answer: Wiring tutorial in this link that shows how to wire the camera module to a pi pico and it provides a python code example for several camera models including ov7670:
https://learn.adafruit.com/capturing-camera-images-with-circuitpython/raspberry-pi-pico-wiring
Two (untested) c++ repositories that can be used as drivers/code samples:
https://github.com/usedbytes/camera-pico-ov7670
https://github.com/adafruit/Adafruit_OV7670/tree/pb-rp2040
You will have to dig into the code of whichever repository you choose in order to figure out or modify the pin connections and have it match the actual wiring.
Comment: While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference.  Link-only answers can become invalid if the linked page changes. - [From Review](/review/late-answers/129507)
Comment: Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer).


How do I run a not-so-old PC game on windows 10?

Question: There is an old PC game called SubTerra ( link ). It used to run perfectly on Windows XP but fails to do so in Windows 10. Compatibility troubleshooter also didn't help. DOSbox cannot emulate this game. Any suggestions as to how to run this game smoothly on Windows 10 ?
Comment: if you are installing older software in windows 10 then you will get too many driver and supported file issues. My suggestion is to deploy oracle virtual box(free :-)) in the same machine and run xp in that and continue gaming with out any issues
Answer: Kind of a circuitous route, but you could try installing Linux in a virtual machine with Wine. Some old Windows programs run better under Wine than they do on Windows 10. VirtualBox's Seamless Mode can (kind of) integrate the virtual machine's windows with your Windows desktop. Linux Mint would be one of the easiest distributions to set up.
Or, as @vembutech noted, you may be able to run an older version of Windows in a virtual machine (if you have access to a legal copy).


Why does $\frac{d}{dx}\sin(x) = \cos (x)$?

Question: Why? Can someone give me a link or explain below. Thanks
Comment: How do you define $\sin,\cos$?
Comment: This question has been asked [here](http://math.stackexchange.com/q/281893). I gave [this answer](http://math.stackexchange.com/a/282041), for example.
Answer: By the angle sum identities and the fact that $\lim_{h\to 0} \frac{\sin{h}}{h} = 1$ and $\lim_{h\to 0}\frac{\cos(h)-1}{h}=0$ it is straight forward
$$\begin{array}{rcl}
\frac{\sin(x+h)-\sin(x)}{h} &=& \frac{\sin(x)\cos(h)+\cos(x)\sin(h) - \sin(x)}{h}\\
&=&\frac{\sin(x)\left(\cos(h)-1\right)}{h}+\frac{\cos(x)\sin(h)}{h} \\
& \stackrel{h\to0}{\longrightarrow}&\cos(x)
\end{array}
$$
Answer: Here's one way to see it. Use the identity $\sin(x+\epsilon) = \sin(x)\cos(\epsilon) + \cos(x)\sin(\epsilon)$ in the definition of the derivative:
\begin{align*}
\frac{\sin(x+\epsilon) - \sin(x)}{\epsilon} &= \frac{\sin(x)\cos(\epsilon) + \cos(x)\sin(\epsilon) - \sin(x)}{\epsilon}\\
&=\sin(x)\bigg(\frac{\cos(\epsilon) - 1}{\epsilon}\bigg) + \cos(x)\frac{\sin(\epsilon)}{\epsilon}
\end{align*}
You know that
$$\lim_{\epsilon\to 0}\frac{\cos(\epsilon) - 1}{\epsilon}=0$$
and
$$\lim_{\epsilon\to 0}\frac{\sin(\epsilon)}{\epsilon} = 1.$$
(These should be in your textbook's chapter on limits and the squeeze theorem.)
Now take $\epsilon\to 0$ in the difference quotient, and, like magic -- voila!
$$\frac{d}{dx}\sin(x) = \cos(x).$$
Answer: All other answers are very good, but here is just another way to see it that can be very useful.
It is nice to use the definitions:
$$\cos(x)=\frac{e^{ix}+e^{-ix}}{2}$$
$$\sin(x)=\frac{e^{ix}-e^{-ix}}{2i}$$
With these definitions, you can immediately prove all of the great trigonometric identities you use everyday, from the sum formula to the product formula or sum of squares.  So these are very useful definitions to get comfortable with.  They will even come in handy to understand why, when you learn about infinite series, you skip odd or even terms in the expansions respectively.
Now, with these definitions, it should be clear using
$$\frac{d}{dx}e^{ix}=ie^{ix}$$
and
$$\frac{d}{dx}e^{-ix}=-ie^{-ix}$$
how you can directly get the formula for the derivatives of these two trigonometric functions.
Answer: The mapping $C:t\mapsto (\cos t,\sin t)$ defines a circular motion of a point along the unit circle: at time $t$ the point is at angle $t$ measured in radian from the right wing of $x$-axis.
Its derivative at moment $t$ intuitively (and eventually) is the velocity vector . Its length is $1$ (because the circumference of the passage taken so far at moment $t$ is just the angle multiplied by the radius, equals to $t$) and it is tangent to the circle at point $C(t)$, so it is just orthogonal to the vector $C(t)$ (coming from origin), heading to the direction of moving.
All in all, using $(a,b)\perp (-b,a)$, the velocity vector is $(-\sin(t),\cos(t))$ .
This illustrates why
$$(\cos(t),\sin(t))'=(\cos'(t),\sin'(t))=(-\sin(t),\cos(t))\,.$$
Comment: Exactly what I was going to say, I really wish I could work out a way to formulate this approach rigorously. It also explains in an instant why [this diagram](http://i.imgur.com/zQ2yCSa.gif) works.
Answer: A detailed and precise answer depends on the definition of $\sin$ and $\cos$ that you use, as well as on the properties of these functions that are already established.
In high school is it common to define these functions geometrically, by drawing certain triangles or by considering the unit circle. Then computing the derivative of $\sin(x)$ at any point $x$ can be reduced to computing it at $0$, by using some standard trigonometric identities which can easily be derived from the geometric definitions. Then, establishing that $\sin '(0)=\cos(0)=1$ boils down to proving that $\lim_{h\in 0}\sin(h)/h=1$. This limit is called the first fundamental limit and its proof requires some care and the use of the squeeze lemma for functions.
A more modern approach is to define both $\sin x$ and $\cos x$ in terms of converging series. Since such series can be derived term-wise, the proof of the above claim becomes a very easy computation, but I doubt you've seen series yet, but you will.
Answer: By definition for $\;(\sin x_0)'\;$ :
$$\frac{\sin x-\sin x_0}{x-x_0}=\frac2{x-x_0}\sin\left(\frac{x-x_0}2\right)\cos\left(\frac{x+x_0}2\right)=$$
$$\frac{\sin\frac{x-x_0}2}{\frac{x-x_0}2}\cos\frac{x+x_0}2\xrightarrow[x\to x_0]{}1\cdot\cos\frac{2x_0}2=\cos x_0$$
Answer: By the definition via power series:
http://en.wikibooks.org/wiki/Trigonometry/Power_Series_for_Cosine_and_Sine
(we could and should define them by these series)
the point is that these converge absolutely on $\mathbf{R}$, so that we may differentiate them term by term! do this
Comment: Explain please! I'm an higjschool student
Answer: For an intuitive and visual approach, I think it is best to take a look at the graphs of $\sin x$ and $\cos x$ to get the intuitive feel of why $\frac{d}{dx} \sin x = \cos x$ is true.
With $\sin x$, the maximum slope is $1$, when $x = 0$, and the minimum slope is $-1$, when $x = \pi$. Furthermore, the slope is $0$ when $x = \frac{\pi}{2}$ or when $x = \frac{3\pi}{2}$. Since the derivative at a point $x$ of a function is the slope of the tangeant line at that point, we can plot $\frac{d}{dx} \sin x$ with that information.
The function we get has a maximum of $1$, a minimum of $-1$, has a value of $1$ when $x=0$, is periodic on $2\pi$, etc. Now, it makes me think of the function $\cos x$, which also has a maximum of $1$, minimum of $-1$, has a value of $1$ when $x=0$, etc.
This is far from a rigorous explanation, but it is useful to see the relation between the derivative of sin and cos. If you forget wether $\frac{d}{dx} \sin x = \cos x$ or $\frac{d}{dx} \sin x = - \cos x$ during an exam (or it might me some other derivative), you can make a simple plot of the function and figure it out for yourself.
Answer: It's better to think of the derivative of a sinusoidal wave as a phase shift of a right angle.
$$\frac {d\sin(x)}{dx} =  \sin\left(x + \frac {\pi}{2}\right)$$
$$\frac {d^n\sin(x)}{dx^n} =  \sin\left(x + \frac {n\pi}{2}\right)$$
When you do work with AC circuit design, dealing with phase shifts and amplitude changes though circuit parts is much easier than trying to figure out signs and which sin/cos function you are on.
When you look at a Taylor expansion of a sinusoidal function, it's much more obvious where the $1, 0, -1, 0, 1, 0,...$ pattern for the coefficients comes from, it's just the shape of the sinusoid itself taken at right angle steps.
Your question could be answered rigorously using algebra and limits, but I think you are wanting a simpler more intuitive understanding so I'll offer a less rigorous suggestion.
Consider a point on a spinning wheel.  When is that point rising the fastest?  It's when the point a quarter turn away is highest.  When is falling the fasest?  It's when the point a quarter turn away is lowest.  When is the point not rising or falling (you would feel weightless for a moment if you were riding)?  It's when the point a quarter turn away is at zero height (not above or below the centerline).
The constant of proportionality just comes from choice of units.  Most people use radians so that you don't have an extra constant factor in the equation.


Masking a whole image in texture mode

Question: I'd like to know how I can mask (if possible) my whole image in texture paint mode, so at the end, I don't get unnecessary paint and colors in my diffuse texture.
I wanted to put the following image as a mask to my diffuse texture, but seems like I can't find the right place to do it
Comment: I don't think mask is what you are after. Using that image any texture painting you do to the axe will be applied to the white area. You can setup another image to use in texture paint so that that image doesn't get any paint.
Answer: Black and white images can be used as a Mask in the texture paint mode, setting them up in the Slots panel.
The cool thing is that you can use that image you have there as a mask, and invert it to paint outside that area as well.
video on mask use with mask tool and stencil mask

Masking a whole image in texture mode


Expressing output voltage in a circuit with zener diodes without any value given

Question:
I have this circuit and I need to find \$u_{o}(u_{i})\$ if \$ZD_{2}\$ and \$ZD_{1}\$ are ideal zener diodes with \$U_{z}\$ zener voltage and the op-amp is also ideal. My problem is that I have no values, I just need to find the expression for \$u_{o}\$, but how do I know if a diode is on or off or reverse-biased? I don't know where to start.
Comment: Now consider that if the (ideal) zeners are connected back to back (as they are shown) and  if the output voltage is less than the zener voltage would the zeners have any effect? What would happen if the output tries to exceed the zener voltage?
Comment: Start by noticing that the op-amp inverting input is a virtual ground.
Comment: If the zeners and R3 are removed what would be the gain?
Comment: So because it is ground, if \$u_{i}\$ is a positive voltage, then \$u_{o}\$ will be negative voltage. That leads me to the conclusion that ZD1 would be forward-biased and on, but how do I know that the reverse voltage on ZD2 is larger than Uz? That is what confuses me.
Comment: If the zeners and R3 are removed then \$u_{o}=-(u_{i}*R_{2})/R_{1}\$
Comment: So while output voltage is less than zener coltage, there will be no current through the diodes?
Answer: I do not want to simply provide the solution, but I can point you in the right starting direction.
I am assuming that you have already seen the fundamentals of an Inverting Op-Amp:

Inverting Op-Amp Fundamental Properties

Your circuit is of the same nature, but has a complex feedback resistor \$R_{f}\$.
Since you mentioned that these are ideal zener diodes, we can ignore their resistance, and only need to pay attention to the conditions when they are conducting current.
If at least one zener is not conducting, then the effective \$R_{f}\$ is equal to your \$R_{2}\$.
If both zeners are conducting, then the effective \$R_{f}\$ is equal to \$R_{2}\parallel\$\$R_{3}\$.
The final piece of the puzzle is to identify what circuit scenario is required in order for both zener's to conduct.
Each Zener will conduct current when either:
 - The forward voltage is more positive than its Zener Forward Voltage (\$V_{F}\$)
 - The reverse voltage more negative than its Zener_Breakdown_Voltage (\$V_{Z}\$)
(Fundamentals of Zener Diodes)
There are two scenarios when both Zeners are conducting:
- Scenario 1: (\$V_{ZD1}\geq\$ \$V_{F\_ZD1}\$) && (\$V_{ZD2}\leq\$ \$V_{Z\_ZD2}\$)
- Scenario 2: (\$V_{ZD1}\leq\$ \$V_{Z\_ZD1}\$) && (\$V_{ZD2}\geq\$ \$V_{F\_ZD2}\$)
Thus, the resulting \$u_{o}(u_{i})\$ will be comprised of two discrete equations:
- One equation for the voltage states where \$R_{f}\$ == \$R_{2}\$
- One equation for the voltage states where both zeners to be conducting
Comment: Set up a system of equations. One equation for scenario 0 (nonconducting), the second equation for scenario 1+2. Then you have to write the solution in the form "When V_negative_terminal>=some_voltage, the solution looks like so and so, When V_negative_terminal<=some_voltage, the solution looks like this, etc."
Comment: But how do I find when will Scenario 1 and Scenario 2 happen in respect to \$u_{i}\$? That is what I can't figure out.


Determining if some permutation of a vector satisfies a system of linear equations

Question: Let $A$ be a matrix and $x$ a fixed vector. How can we determine whether or not there exists a permutation matrix $P$ such that $APx=0$? Does this problem reduce to anything well-understood?
Comment: @GerryMyerson Not when the dimension is higher than about 12...
Comment: There are only so many permutation matrices. You could just try them all.
Comment: Then maybe, Jack, you should go into more detail about what you really want.
Comment: the obvious necessary condition is ${\rm det}\,A=0$.
Comment: @CarloBeenakker OP did not specify that $A$ is square.
Answer: Let's see if I can convince everyone that this problem is NP-complete.
First: it is in NP because a permutation $P$ can be guessed and checked in polynomial time.
I'll restate the problem:  Given a vector $x$ and a vector space $V$ (the null-space of $A$), is there a permutation of $x$ that lies in $V$?
I'll take the number of components of $x$ to be $2n$. I believe that any vector space is the null space of some matrix, so I'll take the vector space $V$ consisting of all vectors whose sum of the first $n$ components equals the sum of the other $n$ components.  It has dimension $2n-1$.
Now take $x$ to be a vector of integers. There is a permutation of $x$ that lies in $V$ iff the entries of $x$ can be divided into two halves of the same sum.  This is the PARTITION problem that we all teach our students to be NP-complete.
Comment: No need for belief, just take $A=(1,1,\dots,1,-1,-1,\dots,-1)$.
Comment: @JackM  See my addition "First..".
Comment: So my problem is a generalization of PARTITION. Doesn't this only show that the problem is NP-hard? I don't see how it shows NP-completeness.
Answer: This can be formulated and solved as a Mixed Integer Linear Programming (MILP) feasibility problem. Such NP-hard problems are routinely solved in practice, even to fairly large scale, despite being "intractable". For $P$ being $n$ by $n$ with $n$ in the hundreds, it should be easy to solve, and possible with $n$ into the thousands.
The problem is to find a $P$ such that all entries of $P$ are $0$ or $1$, all rows of $P$ sum to $1$, all columns of $P$ sum to $1$, and $APx = 0$.
Formulation in CVX under MATLAB
cvx_begin
variable P(n,n) binary
sum(P,1) == 1
sum(P,2) == 1
A*P*x == 0
cvx_end

Formulation in YALMIP under MATLAB
P = binvar(n,n,'full')
optimize([sum(P,1) == 1,sum(P,2) == 1,A*P*x == 0])

The specific solver to use may be optionally specified for either CVX or YALMIP.
I don't claim this is the fastest way to solve the problem, but it is a valid formulation, and if it meets your needs, then it has accomplished something useful, protestations of NP-completeness not withstanding.
Answer: This problem is known in the literature as permuted kernel problem, PKP. In 1989, Shamir proved NP-completeness by reduction from partition problem. In Garey and Johnson [1979], PKP was shown to be NP-complete in the strong sense by a reduction from 3-partition problem.
Shamir introduced a public-key scheme based on it. Post-quantum cryptography renewed interest in PKP-based Zero-Knowledge Identification scheme.
Answer: Let $\mathbb P_n$ be the set of $n \times n$ permutation matrices. Given matrix $\mathrm A \in \mathbb R^{m \times n}$ and vector $\mathrm v \in \mathbb R^n$, we would like to find a permutation matrix $\mathrm P \in \mathbb P_n$ such that
$$\mathrm A \mathrm P \mathrm v = 0_m$$
The convex hull of $\mathbb P_n$ is the Birkhoff polytope $\mathbb B_n$ (the set of all $n \times n$ doubly stochastic matrices)
$$\mathbb B_n := \left\{ \mathrm X \in \mathbb R^{n \times n} \mid \mathrm X \mathrm 1_n = \mathrm 1_n, \mathrm 1_n^\top \mathrm X = 1_n^\top, \mathrm X \geq \mathrm O_n \right\}$$
Thus, a convex relaxation of the original discrete feasibility problem in  $\mathrm P \in \mathbb P_n$ is the following continuous feasibility problem in $\mathrm X \in \mathbb B_n$
$$\begin{array}{ll} \text{minimize} & 0\\ \text{subject to} & \mathrm A \mathrm X \mathrm v = 0_m\\ & \mathrm X \mathrm 1_n = \mathrm 1_n\\ & \mathrm 1_n^\top \mathrm X = 1_n^\top\\ & \mathrm X \geq \mathrm O_n\end{array}$$
Let us look for a solution on the boundary of the feasible region. Hence, we generate a (nonzero) random matrix $\mathrm C \in \mathbb R^{n \times n}$ and minimize $\langle \mathrm C, \mathrm X \rangle$ instead. We have the following linear program (LP).
$$\begin{array}{ll} \text{minimize} & \langle \mathrm C, \mathrm X \rangle\\ \text{subject to} & \mathrm A \mathrm X \mathrm v = 0_m\\ & \mathrm X \mathrm 1_n = \mathrm 1_n\\ & \mathrm 1_n^\top \mathrm X = 1_n^\top\\ & \mathrm X \geq \mathrm O_n\end{array}$$
Although the vertices of the Birkhoff polytope are doubly stochastic matrices, the introduction of the equality constraints $\mathrm A \mathrm X \mathrm v = 0_m$ likely produces other vertices. We may have to generate several matrices $\rm C$ until we obtain an LP whose minimum is attained at a permutation matrix.

Numerical experiment
Suppose we are given
$$\rm A = \begin{bmatrix} 1 & 1 & 1 & 0 & 0\\ 0 & 1 & 1 & 1 & 0\\ 0 & 0 & 1 & 1 & 1\end{bmatrix}$$
$$\rm v = \begin{bmatrix} 1 & 1 & -1 & 0 & 0\end{bmatrix}^\top$$
Using NumPy to randomly generate matrix $\rm C$ and CVXPY to solve the LP:
from cvxpy import *
import numpy as np

A = np.array([[1,1,1,0,0],
              [0,1,1,1,0],
              [0,0,1,1,1]])
v = np.array([1,1,-1,0,0])

(m,n) = A.shape

C = np.random.rand(n,n)

ones_n = np.ones((n,1))

X = Variable(n,n)

# define optimization problem
prob = Problem( Minimize(trace(C.T * X)), [ A * X * v == np.zeros((m,1)), X * ones_n == ones_n, ones_n.T * X == ones_n.T, X >= 0 ])

# solve optimization problem
print prob.solve()
print prob.status

# print results
print "X = \n", np.round(X.value,2)

which outputs the following permutation matrix that exchanges the 2nd and 4th entries:
0.669610896837
optimal
X =
[[ 1.  0.  0.  0.  0.]
 [ 0.  0. -0.  1.  0.]
 [-0. -0.  1.  0. -0.]
 [ 0.  1.  0.  0.  0.]
 [ 0.  0.  0.  0.  1.]]

I ran the Python script a few (maybe $5$) times until I obtained a matrix $\rm X$ that is (close enough to) a permutation matrix. Unsurprisingly, the script does not produce such nice results for all choices of $\rm C$.
Running the script a few more times, I obtained another permutation matrix:
1.46656456314
optimal
X =
[[ 0.  0.  0.  1.  0.]
 [ 1.  0.  0.  0.  0.]
 [-0. -0.  1.  0. -0.]
 [ 0.  0. -0.  0.  1.]
 [ 0.  1.  0.  0.  0.]]


Can this question be re-opened?

Question: I edited this question to make it as less opinion-based as possible. I think this question would really be helpful for users more generally, and although the answers do have some opinion attached to them, I've found that to be the case for other open questions. I'm also considering adding my own answer to this question if it is re-opened. Could this question please be re-opened?
Comment: I rejected the edit, but voted to reopen. In my opinion, this question is one of those opinion-based that should not be closed, but possibly protected.
Answer: I doubt that it can be reopened unless people vote that way, but you raise an important general idea.
I think that some "opinion" based questions and answers are actually quite valuable on this site and this may be one of them. There are some things that are important, even vital, in academia for which there is no real consensus and a search for policy is valuable.
This site is, among other things, a gathering place for people with experience in all of the nooks and crannies of academia. We have seen success and failure. The advice of such folks as ourselves on questions like this are worth some flexibility in the rules (IMO). How to select a good advisor is a pretty vital question for many doctoral students. There are lots of posts here about the consequences of getting it wrong.
Some questions here, even those not opinion based, are looking for advice, not just answers to questions. We can ask whether this is the right site for that, but I know of no others with the same potential impact.
Comment: I agree with you and voted to re-open. Academia has several non-written rules that are learned by personal experience and transmitted person-to-person. Opinion based answers backed up by personal experience and supported by the community are still valuable, especially for those that are first generation academics.

Can this question be re-opened?


Observed Effects of Gravitational Lensing?

Question: If Gravitational lensing is real why cant we see the sun during a solar eclipse? Why doesn't the suns light follow the curve of space created by the moon and become visible to us?
Answer: It is because there is not enough mass to create a gravity effect that is large enough to see gravitational lensing. The majority of gravitational lensing that we see is from galaxies where there is massive amounts of matter between us and the source. During a solar eclipse there is only the moon between us in the sun while there can be several galaxies or dark matter between us and a galaxy.
Just to put some numbers to this the mass of the moon is 3.69*10^-8 solar mass and the mass of the milky way galaxy is estimated to have a mass on the order of 10^11 solar mass(source:https://www.quora.com/How-do-scientists-estimate-the-mass-of-the-Milky-Way-Galaxy).
Answer: The light is gravitationally lensed - by a very small amount. The fact that eclipses happen proves nothing one way or another; even if gravitational lensing did not occur, all that means is that the Moon could be slightly further away from the Earth and still block out the light from the Sun at a spot on the Earth.
A ray of light from the Sun passing close to the limb of the Moon is deflected by about $10^{-10}$ degrees.
Answer: The moon doesn't have enough mass for it's gravitational effect on light to be noticeable.


'out of something' usage

Question: I came across some sentences using out of something or someone and I can't make its meaning clear all the time, say I want to make a supersonic man out of you. How can I understand this sentence and out of here represent what?
Answer: You are currently not supersonic but I want to make you that way. This is from Queen's lyrics and the true meaning is that the singer wants to make you more that you currently are. He is full of life and wants you to be the same.
Answer: From this link:
It simply means to create/construct X (product/result) using Y (material/substance to be processed/utilized).

I want to make a supersonic man out of you

Supersonic Man = product/result
You = Material to be processed/utilized
You might be interested to see this discussion in EL&U.
PS: The example sentence seems like a science experiment to me. Reminds me of Captain America and the Hulk.

'out of something' usage


What happens on the STM32 when two pins are configured to have the same alternate function?

Question: Reading through the STM32F051 manual, it looks like it's possible to configure the same alternate function on two pins; for example, you could have multiple USART1_TX pins at the same time. Or for example the more problematic case of two USART_RX pins. The manual is silent on this case. Is this legal/safe? Is this useful?
Comment: Interesting question. I can see why it would sometimes be useful though, for example while debugging to get the TX output to another pin or to get buffered clocks in a few places. It might be worth adding in the relevant manual link though to save anyone having to search for it.
Comment: Again - Interesting question. But how about the case of assigning USART_RX from two different pins? One would hope that the chip designers had planned a priority scheme for one over the other as opposed to allowing for internal contention from the two sources.
Comment: I've never tried this, but based on what I recall from the pin diagrams, you would basically end up connecting the pins together internally.
Answer: On processors which use per-pin registers to select I/O functions, it is generally possible to route an output function to multiple pins without conflict; all pins will echo the same output.  The effect of having multiple pins connected to an input is often unspecified; if e.g. a UART had I/O pins 3 and 4 connected to a UART, it might behave as though the UART was connected to an "AND" gate which took pins 3 and 4 as inputs, or it might behave as though it was connected to one pin and ignore the other, or it might connect both pins to the UART's input buffer through transistors that had a moderate amount of resistance, or it might draw extra current when pin 3 is high and 4 is low or vice versa, or it might do just about anything else imaginable.  I don't recall having seen any particular guarantees that any of the STM32 family chips I looked at would favor any particular approach over any other.
A somewhat nicer design approach, used in some Microchip parts (perhaps some STM parts as well) is to have each I/O function include a multiplexer to select which pin it should accept input from, and have pin include a multiplexer to indicate the I/O function from which it should output data.  Such a design makes it possible to have one pin feed multiple I/O functions, while simultaneously eliminating any ambiguities posed by conflicting configurations.
Answer: Yes, it is usefull.
Result from experiment on STM32F407VGT6: Both AF pins can be used as AF simultaneously, at least if using these pins as AF inputs. The experiment was to trigger TIM1 on rising edge of external trigger - signal "TIM1_ETR". "TIM1_ETR" signal can be mapped to pins PE7 and/or PA12 of MCU package.
The experiment:
Initialize both pins PE7 and PA12 as AF "TIM1_ETR" for TIM1:
<code>{
    GPIO_InitTypeDef GPIO_InitStruct = { 0 };
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    GPIO_InitStruct.Alternate = GPIO_AF1_TIM1;
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

    GPIO_InitStruct.Pin = GPIO_PIN_7;
    HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); // configure PE7 as AF

    GPIO_InitStruct.Pin = GPIO_PIN_12;
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); // configure PA12 as AF
}
</code>
The result - TIM1 is started by rising edge on any of the pins PE7 or PA12.
This reveals the way to MUX (change) AF pins in run-time:
<code>main
{
  GPIO_InitTypeDef GPIO_InitStruct = { 0 };

// Deactivate PA12 input (set as regular input):
        GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
        GPIO_InitStruct.Pin = GPIO_PIN_12;
        HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

// select PE7 as a trigger source,
        GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
        GPIO_InitStruct.Pin = GPIO_PIN_7;
        HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);

// Arm the timer
    arm_tim1();

/* Now timer will be started by rising edge only on PE7 */

// ... later one can select PA12 as trigger source. Deactivate PE7 (set as regular input):
        GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
        GPIO_InitStruct.Pin = GPIO_PIN_7;
        HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);

// Activate PA12
        GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
        GPIO_InitStruct.Pin = GPIO_PIN_12;
        HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

// Arm the timer
    arm_tim1();
/* timer will be started by rising edge only on PA12 */
}
</code>
This can be helpfull then two different sources are needed for timer triggering, this can save us offboard MUX IC :).
Both inputs can be used simultaneously, if initialized as shown in the beginning of the post.
Inputs are not connected together, I mean signal on PA12 is not transfered to PE7 and vice versa (because GPIOs are set as inputs).
Code is generated by "STM32CubeF4 v5.3" + "Firmware Package V1.24.0 / 08-February-2019."
Answer: Basically, the pins are GPIOs which can be assigned to alternate functions, e.g. UART_RX. Every alternate function has it's default pin and alternative pins to which the function can be remapped. If you check out the reference manual of the STM32F103 in section 9.1.5, they say:

To optimize the number of peripheral I/O functions for different device packages, it is
  possible to remap some alternate functions to some other pins. This is achieved by
  software, by programming the corresponding registers (refer to AFIO registers on page 177.
  In that case, the alternate functions are no longer mapped to their original assignations.
Comment: It's not possible, because (at least on the F103, I haven't worked with the other derivatives of the STM32), the alternative pin cannot be assigned to the function without using the remap feature, even if you set it up as AF_Output in the GPIO setup. And after remapping, the function i no longer available on the original pin. I hope this clarifies what I meant.
Comment: The way this is done is **very different** on the different subfamilies.  The F1 register structure may prohibit it, but the F3 structure is different, where you configure the pin to an alternate function instead of the function to a pin, so duplicate mappings seem possible.  In effect, you are not answering the situation of the question asked, which seems to be about a part where the register structure permits it.
Comment: @Chris Stratton [STM32F302 Ref Manual](http://www.st.com/web/en/resource/technical/document/reference_manual/DM00043574.pdf) section 8.3.2: "The device I/O pins are connected to onboard peripherals/modules through a multiplexer
that allows only one peripheral's alternate function (AF) connected to an I/O pin at a time. In
this way, **there can be no conflict between peripherals** available on the same I/O pin."  But actually, this doesn't say anything about multiple I/O on one AF. Are there even multiple options for input pins?
Comment: I appreciate the F1x information too, I've used that one too :-)
Comment: The way I grok this is: once you assign the new pins, the previous assignment is removed, so you cannot technically have multiple pins connected to the same peripheral function.
Comment: Yes, there are multiple options for the I/O pins to which a given function block can be connected. The question concerns assigning the function to multiple pins. Proclaiming in bold that a pin can only be assigned to one function does nothing to further the discussion, since that is not what the question was about.
Comment: The original poster has specified the derivative he uses. The F051 seems to be similar to the F3 when it comes to the alternate functions. I checked again the available documentation and found nothing about this case. Probably it's worth to ask the technical support of STmicro.
Comment: This is still not an answer to the actually asked question, about giving multiple pins the same role on the F051 where the registers appear to make that possible.  Instead, it is just distraction about the fact that a pin generally can't be given different roles at the same time.


Solving equations of the following form

Question: I am currently studying resolution of concurrent forces and I have come across equations of the following type
$$P\cos \theta+Q\sin \phi=C_1$$
$$P\sin \theta+Q\cos \phi=C_2$$
where $P$,$Q$,$C_1$and $C_2$ are known and I have to find the angles. I usually get stuck at this point as I don't know how to solve the 2 equations to get $\theta$ and $\phi$ and I have to resort to looking for other geometrical relationships.
Answer: rewritten
$$P\cos \theta=-Q\sin \phi+C_1$$
$$P\sin \theta=-Q\cos \phi+C_2$$
then
$$P^2=C_1^2+C_2^2+Q^2 - 2Q(C_1\sin\phi+C_2\cos\phi)$$
or
$$C_1\sin\phi+C_2\cos\phi = \frac{C_1^2+C_2^2+Q^2-P^2}{2Q}.$$
Let $R= \sqrt{C_1^2+C^2_2}$. Now there exists $\psi\in[0,2\pi)$ (hint: $\arctan(C_2/C_1)$) such that $$C_1 = R\cos\psi,\quad C_2=R\sin\psi.$$
Therefore
$$\cos\psi\sin\phi+\sin\psi\cos\phi = \frac{R^2+Q^2-P^2}{2QR},$$
$$\sin(\phi+\psi)=\frac{R^2+Q^2-P^2}{2QR}.$$
This equation allows you to find $\phi$ or conclude that it doesn't exist. The equation on $\theta$ is obtained likewise.
Comment: short and nice answer, respect.
Comment: The final formula that you obtained looks like the cosine formula where the sides of a triangle are P,Q and R
Comment: @GTXOC it may very well be the case. You problem can be viewed as "how to rotate two vectors of magnitude $P$ and $Q$ in $\Bbb R^2$ such that their sum is a vector with coordinates $(C_1,C_2)$". The geometric interpretation of sum of vectors is essentially a triangle.

Solving equations of the following form


Is the set of all differentiable functions a vector space?

Question: Is the set of all differentiable functions $f: \Re \rightarrow \Re$ such that $f'(0) = 0$ is a vector space over $\Re$? I was given the answer yes by someone who is better at math than me and he tried to explain it to me, but I don't understand. I am having difficulty trying to conceptualize this idea of vector spaces with functions because I can't really visualize it like a plane in 3d space. I am also wondering what is the importance of having vector spaces set over a field? It seems trivial or maybe its just me being brainwashed by years of elementary mathematics
Comment: It's not trivial, but it does also sound like you have gotten locked into an incorrect mental model of a "vector space" by your education. Vector spaces are a lot more than just a way to describe 3D Euclidean space.
Comment: This may be relevant: http://math.stackexchange.com/questions/1847997/
Answer: A vector space is merely a set with two operations, addition and scalar multiplication, that satisfy certain conditions. In this case the scalars are real numbers. The addition operation is the pointwise sum, and scalar multiplication is multiplication by a real number.
Besides these properties it geometrically has little to do with vectors in three dimensional space, and the concept of a vector having "both a magnitude and direction" no longer makes much sense (without additional structure). This is the definition of a vector space that has been settled on, so getting used to it would be a good idea.
That said, vector spaces are incredibly well behaved and a great deal of algebraic material from the finite dimensional case generalizes to infinite dimensional vector spaces without modification. This is part of the utility of vector spaces; once you have a set that satisfies a few easy axioms you can do linear algebra in it.
Answer: To answer the second question: The importance of the vector space being over a field is that having a field makes many things easier. There exists "vector spaces" (called modules) over non-fields (for example, over the integers), but a lot of things we rely on when working with vector spaces don't necessarily hold for them. For example, a module might not even have a basis.
So basically we require the vector space to be over a field because that gives us useful properties.
Answer: The space P^3 of polynomials of the type a_1x+a_2x^2+a_3x^3 is the same as R^3 and  my be regarded as a 3D Euclidean space.


How do I make my Apple earphone's play button not launch iTunes and instead pause/play a video on YouTube?

Question: What the title says. I already have BeardedSpice for my media keys, but I wanted to know if there was a way to make the earbuds' play button not launch iTunes every time I press it.
Comment: My solution, for as long as I've been using macOS, is to sudo rm -rf /Applications/iTunes.app. Probably not actually the best idea, but it has never caused problems...
Answer: Taken from here: The short answer is that you can't select which media app has priority since they're all equally treated, but if there's nothing playing iTunes takes preference.
The linked answer also pointed to a patch for the Remote Control Daemon at https://github.com/thebitguru/play-button-itunes-patch, which might be what you were looking for. It's a 1 MB download and you will need at least El Capitan (OS 10.11). On that page it says:

This is a patch for removing the default OS X behavior of always starting iTunes when the play button on the keyboard is pressed. This feature can be useful for a lot of users, but it can also be annoying if you are using VLC, Nightingale or other similar programs that support the media keys.
The application will patch the Remote Control Daemon to prevent it from starting iTunes whenever you press the play button on the keyboard or an external remote control. This will only prevent iTunes from starting, all other functions (like play/pause while iTunes is running) will continue to work as before. The original file is backed up in case you would like to restore the original functionality.

It's unfortunately not a straight forward installation. You find the instructions and download on https://thebitguru.com/projects/itunes-patch.


How to make almond milk taste more like dairy

Question: I see natural flavor, sodium caseinate, and milk protein isolate on  a few non-dairy creamers. What give non-dairy creamers milk like flavor? Can this be added successfully to almond milk (homemade)?
Comment: I'm not so sure non-dairy creamers have a milk flavor.
Comment: Honestly, I wouldn't bother.  Almond milk has its own, good flavor, and has been a cooking ingredient for hundreds of years.  You'd just be taking good, homemade almond milk, and turning it into low-quality fake dairy.
Comment: Sounds like you might want to look at nextmilk.
Answer: I am not a nutmilk expert, but I do like milk more than most people I know, and I have dabbled in nutmilk.
First thing, non-dairy creamers don't taste like cream. That's why some people will use them as sweeteners/flavor and add real cream as well. It's the best of both worlds if you take your cream with a little coffee.
So saying, the only way to add milk flavor to your almond milk would be to add milk components. Lactose (sugar), whey and casein (proteins), butter fat, and more all contribute to the flavor of milk. The most noticeable factors affecting creaminess are going to be the proteins and fat. Proteins and fat are going to add texture as much as flavor though.
You can recognize the significance of fat by itself within dairy milk. In my experience most people who actively like nutmilk tend to prefer skim, 1%, or 2% milk when they choose to drink it. But most people who prefer dairy milk will prefer whole milk, which is around 4%. If someone has a preference for skim or whole milk, they will likely find the other unpleasant, even though it's all the same animal's milk. And in light of that, if someone brings me a glass of milk that's watery instead of creamy, I'm not going to like it. It's not just the flavor, it's the texture.
I've explored nutmilks because real milk is expensive and addictive (and I'm trying to lose weight. Why are cows do delicious?) Most of the nutmilks I have tried are lower fat, lower carb/sugar, and lower protein than cow milk. Many of them add sugar to improve the flavor. Many add stabilizer gums or emulsifiers to improve the texture.
As far as creaminess goes, I would say the award goes to soy milk. It has higher fat and protein content compared to most nutmilks, but very little sugar. I only enjoy it with added sugar, which I try to avoid for personal reasons. Almond milk is the best compromise between natural sweetness and creamy flavor/texture in my opinion, and that's what I typically buy. The other nutmilks I've tried, while varying degrees of pleasant, really don't come close.
However, I have to say I have not tried hemp milk or oat milk, but oat milk is getting a lot of hype for its creamy texture, and I would speculate it's due to the high fiber content. I can't talk much about it, but that might be worth looking into as well.
So, how do you make your almond milk more creamy without adulterating it with actual dairy? My suggestion would be to increase the amount of almond solids that remain in your final product, and plan to shake vigorously before enjoying. This will also make it taste more like almonds, which is a good thing.
If you explicitly want milk flavor as opposed to creaminess, then I'd suggest adding milk proteins (you should be able to get whey protein isolate pretty easily), lactose, or increasing the butter fat content with heavy cream.... But at that point, why not just buy regular milk?
The final alternative is to do what the big brands do: add sugar and vanilla and don't think too hard about it. People tend to associate vanilla with creamy desserts pretty strongly in the US at least. Sugar tastes good, and vanilla is associated with creaminess, even if it's not creamy itself. How much attention do people actually pay to their glass of not-water anyway?
Comment: "I've explored nutmilks because real milk is expensive and addictive" there are places where cow milk is more expensive than nut based milk?
Comment: Lol, for me yes, but probably not for most. Good point! I can easily drink a half-gallon of milk a day without meaning to, especially if it's fancy, most delicious grass-fed milk which is more expensive than most nutmilks. By comparison, my gallon of almond milk lasts for literal weeks. If something delicious is in my house, I will go for that first. Which means the most delicious things (like milk and ramen) are not allowed in my house very often.
Comment: Where do they get lactose and casein from? Milk? You might as well use milk - at least it's natural. Otherwise better to get used to natural nut milk flavours.
Comment: @kitukwfyer Sorry when I said where from I meant how is it produced. No criticism. Just curious. :)
Comment: @PotatoCrisp Ahh, I see now. My B!
Answer: https://www.naturesflavors.com/organic-flavor-oil/108898-milk-flavor-oil-organic.html
Haven't tried it. I use their diacetyl ie butter flavor.
Culturing a bit of almond milk with mesophilic starter to make buttermilk makes a nice addition in small amounts (not in coffee perhaps)


What is the longest file path that Windows can handle?

Question: What is the longest file path that Windows can handle?
Comment: A similar question on Stack Overflow: https://stackoverflow.com/questions/265769/maximum-filename-length-in-ntfs-windows-xp-and-windows-vista. To be honest, I still don't understand whether the maximum length of an individual  filename is 255 or 256 characters. (Even after the discussion with @phuclv below.)
Answer: Maximum Path Length (from MSDN)

In the Windows API (with some exceptions discussed in the following paragraphs), the maximum length for a path is MAX_PATH, which is defined as 260 characters. A local path is structured in the following order: drive letter, colon, backslash, components separated by backslashes, and a terminating null character. For example, the maximum path on drive D is "D:\<some 256 character path string><NUL>" where "<NUL>" represents the invisible terminating null character for the current system codepage. (The characters < > are used here for visual clarity and cannot be part of a valid path string.)
Comment: You should mention that you can handle paths that exceed this limit by prefixing it with `\\?\` (I think it was that character sequence).
Comment: you should also state the limit for unicode-paths mentioned in the 2nd paragraph: ~32k
Comment: @Phoshi The APIs to use longer paths aren't used by the OS by default, because passing in arbitarily long strings to applications that were poorly written by developers who knew the path could never be longer than 260 chars and decided to allocate a fixed length array to hold it would result in a huge number of buffer overflows leading to applications crashing and/or being exploited.  Slightly better implementations by devs with the same mis-knowledge would abort because their path validation reported a too long error.
Comment: 260? 256 characters ignoring drive:\ and terminator. It's 2009, why do we only get a byte of characters to play around with?
Answer: XP file path - 250 characters
Vista file path - 260 characters
The longest path on a clean install of Windows XP is 152 characters.
The longest path on a semi-clean install of Windows Vista is 195 characters
Windows XP allows file names upto 255 characters in length
Windows Vista allows even longer filenames containing upto 260 characters.
http://www.codinghorror.com/blog/archives/000729.html
Comment: this is just true if you dont use the unicode-api, which extends the limit a bit (~32k, see http://msdn.microsoft.com/en-us/library/aa365247%28VS.85%29.aspx#maximum%5Fpath%5Flength)
Comment: hmmm.  at that rate, the limit in Win7 ought to be around 265 characters, no?
Comment: Why would they increase the limit by ten characters? Doesn't seem worth it, does it :\
Comment: this is **absolutely incorrect**. The maximum filename length is still 255 characters in any Windows, since that's the NTFS limit. And `MAX_PATH` has always been 260 characters
Comment: @Phoshi it's because MS didn't make that change. The limit is the same. This answer is just nonsense
Answer: The "classic" limit is 260 characters: drive letter + :\ + 255 characters of filename + \ (or for rounding) + null terminator as said in the other answers
However the real internal limit is 32767 characters which can be achieved by prepending \\?\ to get a fully qualified path

The Windows API has many functions that also have Unicode versions to permit an extended-length path for a maximum total path length of 32,767 characters. This type of path is composed of components separated by backslashes, each up to the value returned in the lpMaximumComponentLength parameter of the GetVolumeInformation function (this value is commonly 255 characters). To specify an extended-length path, use the "\\?\" prefix. For example, "\\?\D:\very long path".

If due to some reasons the fully-qualified paths cannot be used then deeper directories can be accessed by mounting to a drive letter with subst/diskpart or by creating a junction/symlink to shorten the path
Since Windows 10 version 1607 the MAX_PATH limit has also been removed although not by default

Starting in Windows 10, version 1607, MAX_PATH limitations have been removed from common Win32 file and directory functions. However, you must opt-in to the new behavior.
https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file

Note that Joe's answer is completely wrong. Max (long) file name length has always been 255 characters and MAX_PATH has always been 260
Comment: Prepend \\?\, don't append \\?\
Comment: The best answer here. The most accurate and easiest to understand. +1
Comment: However, it is not clear to me what does the \ after the `255 characters of filename` mean. As I know, a typical path looks like c:\foo\bar (or c:\foo\bar\a.txt), not c:\foo\bar\ (or c:\foo\bar\a.txt\\). There is no trailing backslash. Could you explain what you mean by it?
Comment: (There were some errors in my previous comment. Now all of them are fixed.)
Comment: @johnc.j. as I said, it can be a path to a folder with trailing slash, or simply for making the size an even number which is better for alignment
Answer: Windows constant MAX_PATH is equal to 260 as other answers says, however, the real longest path is 32767.
See here.
32k is while using UNICODE, but now we must use it, so we should also use such max path length.
Also, you can take a look into my answer in SO which explains some things more detailed about maximum path length.


Webserver and FreeNAS storage server

Question: I have a web server running currently which is low on free storage space and many more files are incoming.
I want to store files from that web server onto another server (NAS, FreeNAS server).
An example: someone wants to download a PDF file from the website (on the web server), but the file will be downloaded from the FreeNAS server.
Is this possible? Can I use FreeNAS for this?
Answer: Sure, just export storage from the FreeNAS server via NFS, which is then mounted on the web server. The web application then does not even need to be aware in any way that its storage is remote.
Answer: Yes, it's possible. Deploy FreNAS/NAS. Mount NAS to your web server. Use the mapped storage/volume/directory as storage for your websites. However, this kind of setup is okay for home media/web servers/lab, but for production usage, I would recommend you take more hardware and setup one more web server.

Webserver and FreeNAS storage server


add an Xcode project to an existing one

Question: I want to combine two Xcode projects into one app. I have project-one which is working fine and project-two w/c is also working fine. project-one is more like of an ebook gatherer and project-two is the ebook reader. The two works fine separately. I drag and drop project-two into project-one and add project-two as dependency for project-one. I get no errors when building the app and It runs normally until I open a tab(the whole app is a tabbarcontroller).
I have a 'books' tab and when I tap this, I want to run project-two in this tab. I tried calling the nib from project-two to load when the 'books' tab is tapped but it gives me a warning 'Unknown class RootViewController in Interface Builder file.'. So how can I successfully link the two projects so I can load project-two in my 'books' tab?
Thanks!
Answer: Despite the "Unknown class MyClass in Interface Builder file." error printed at runtime, this issue has nothing to do with Interface Builder, but rather with the linker, which is not linking a class because no code uses it directly.
"Unknown class  in Interface Builder file"
Comment: I already added the flags in my build settings but still the problem persist.
Comment: any help? :( been stuck on this for quite some time now.

add an Xcode project to an existing one


Changing parenthesis size for typography

Question: I am using Mathematica to layout some mathematical formulas for publication. The guidelines specify that in case of nested parentheses the encompassing ones need to be bigger than the inner ones. So is there a way to make parentheses bigger easily? Below is an example of what I want. It is made by inserting an invisible column at the beginning of the grouping, but that creates a ugly gap in the formula.
Comment: Please include copyable code in your post.
Comment: If you're using Mathematica just to set up the formulas to go into a publication, then you'd be better off exporting to LaTeX and then, if necessary, tweaking there.
Answer: It is a bit messy but you can manually fix this by highlighting the stuff to the left of the parenthesis, and the left hand parenthesis, and nudge the stuff to the right

The result will look like this:
Comment: Yeah that works, but is messy as you say. Wonder if it would be possible to automate this tough. I'm Accepting your answer for now as its enough for my current situation.
Comment: Yes you could automate this because the nudging is adjustment boxes so when you have something you like you can use show expression to have a look at the underlying box structure. But to go to the work of automating I would want to be doing several of these formulas with the same structure/format otherwise I'd just cut and paste.
Comment: Yeah your right I can just make a number of different sizes and copy paste them.
Answer: There is the way to insert a column consisting of three elements into the parantheses, and make the first and the third of them white (and thus, invisible). Namely,

Type (, type Ctrl+Enter, type Ctrl+Space, once more type Ctrl+Space, type ). You get a 3-element column enclosed by the parantheses.
Make the first and third elements white.
Mark the first element, go to Menu/Format/Font and choose a smaller font size, say, 6 pts. Make the same with the third column element.
Type your expression into the second element.

The snapshot one may see below. To my taste this method is not really satisfactory, since the outer parantheses are too large

Comment: Oh, yes. It might work better if you put it in grid with two elements center align and SpanFromAbove. Still needs tweak tough but is less buggy than what im finding the tweak to be. I must investigate further. Still not perfect.


Fluid simulation wont happen in a small pipe?

Question: Fluid simulation won't happen in my model pipe. I Got a project from my client in which fuel must pass through a pipe. so I tried to do the simulation but the simulation won't happen. I tried scaling the inflow and domain. Why is this happening?
Answer: Most likely your pipe/inflow is too narrow/small for your simulation resolution - it must be at least comparable to the size of the "cells" of your simulation.
You can determine the size of the "cells" by taking the longest dimension of your fluid domain and dividing it by the fluid domain's Resolution - your pipe should typically be at least three times the size of the cells, otherwise the flow of fluid can be blocked - especially on diagonal sections and curves; much higher resolution is preferable.
However, the overhead of the simulation will increase significantly with higher resolution, with an increase relative to the cube of the increase in resolution - so doubling the resolution will allow for pipes that are half as narrow but will take 8 times (ie, 2x2x2) the overhead (memory and CPU comutation time) to compute.