Renege on signed job offer

Question: I received two job offers, accepted and signed the first contract that came through (was worried either job might fall through considering my previous experience with rescinded verbal offers). Now I'm regretting that decision, the recruiter for the other role does not know I signed the contract, I told him that I need to think through both offers. How should I back out of the signed contract? Another problem- both recruiters know the companies involved.
Comment: Just make sure you really want to do this, and aren't simply suffering a case of "buyer's remorse" and second-guessing yourself needlessly. Backing out after signing isn't great, but most contracts in most areas have a "cooling-down period" for exactly this sort of re-consideration. Backing out *twice* in rapid succession is much more likely to get you noticed as an annoying client. Yes, the recruiter will briefly hate you since you're taking money out of their pocket that they thought they'd already earned. They'll get over it. It's just part of what happens in their business.
Answer: Why does it matter that both recruiters know the companies involved?
To back out of a signed contract, you just say "I am backing out of a signed contract, sorry."
You don't need to tell them you are taking another offer, the offer you are taking, or any other details. The recruiter dealing with the contact that you are reneging will hate you, and will bad mouth you to everyone he or she can think of.
So whatever you do, do not tell them about the other contract, or the other company. If they call and are rude, just hang up. You owe them nothing.
You should check the contract (that you are reneging, but of course, check the other contract too!) for any odd pitfalls you might stumble into. Typically there isn't much anyone can do about you signing a contract then backing out (for workplace agreements). The notice period etc doesn't really matter as you are reneging on the entire contract.
They might try to scare you with a lawsuit (or, more likely, the threat of one) ~ I don't know where you are, but typically that kind of thing involves proving damages to the company in question. You are unlikely to have caused them any damages given you never started working there.
But to answer the unasked question "how can I make the recruiter/company that I am walking away from not totally hate me" - you cannot.
Comment: +1 good answer but if I were the hiring manager of the other company and the recruiter dealing with the contract that the OP is reneging, why would I care? I spend a lot of money and time to find a right candidate- that is OP. Even if OP is reneging- he's just reneging, not absconding a job altogether. Every company has a probation period anyways and if OP even left the other company after joining it and decided during probation that it's not a good fit, I'm fine with that! I would be watching out for that badmouthing recruiter though.
Comment: @JoeStrazzere- That was helpful. I'm from India, so perhaps my comment was totally India-specific.

Renege on signed job offer


Blender 2.8 can't find my intel gpu

Question: I was following a tutorial on YouTube when I realized that in render mode GPU is clickable but does not work. I tried doing what i saw online but couldn't find my GPU in the system preference. The information about my PC is: Intel(R) Core(TM) i3-5005U CPU @ 2.00GHZ. And the GPU i'm using is Intel(R) HD Graphics 5500 driver with OpenCl 2.0 and OpenGl 4.4.
Answer: Unfortunately your integrated graphics card doesn't fulfill the requirements for GPU rendering in Blender 2.8x. You would either need a

Nvidia graphics card with CUDA compute capability 3.0 or higher
AMD graphics card from GCN second generation or later

CUDA
CUDA requires graphics cards with compute capability 3.0 and higher. To make sure your GPU is supported, see the list of Nvidia graphics cards with the compute capabilities and supported graphics cards. CUDA GPU rendering is supported on Windows, macOS, and Linux.

AMD
OpenCL is supported for GPU rendering with AMD graphics cards. Blender supports graphics cards with GCN generation 2 and above. To make sure your GPU is supported, see the list of GCN generations with the GCN generation and supported graphics cards.
AMD OpenCL GPU rendering is supported on Windows and Linux, but not on macOS.
Comment: But the official website redirected me to this link https://en.wikipedia.org/wiki/List_of_Intel_graphics_processing_units saying it works
Comment: @UnSpecificCoding I assume you're referring to the [minimum requirements](https://www.blender.org/download/requirements/) page? The *Supported Graphics Cards* section is for the required GPU for *running* Blender 2.8x. As noted below on the same page, *GPU rendering* has higher requirements. "These requirements are for basic Blender operation, rendering using the graphics card requires slightly different requirements."
Comment: @RobertGützkow no, he means the developer blog: https://code.blender.org/2019/04/supported-gpus-in-blender-2-80/.
Comment: @EricXue The answer is still the same though. Those are the minimum requirements for the GPUs in order to run Blender. GPU rendering has higher minimum requirements.
Answer: As mentioned in the other answer, this will not work, for the mentioned reasons. But even if it was to work, you have to remember that the GPUs that are built into CPU are generally very weak. You have an i3, so even weaker. I have an i5 and i7 and these GPUs built in are useless for the heavy lifting that is rendering on Blender or any other 3D App.
And: Even if you could make it work, it would be super slow.
Intel integrated graphics are fine for running a desktop, but not for heavy 3D work or number crunching like done with Blender with OpenCL and CUDA on AMD GPUs and Nvidia.
You are better off using the CPU itself, instead of its tiny little GPU addon.
But remember that 3D rendering work is probably one of the most demanding work you can throw at a computer.
I have scenes that I render that take 10 hours to finish, just one frame, on relatively powerful hardware.

Blender 2.8 can't find my intel gpu


VC dimension of hypothesis space of finite union of intervals

Question: I have the following concept:
$$C = \left\{\bigcup_{i=1}^{k}(a_i, b_i): a_i, b_i \in {\Bbb R}, a_i < b_i, i=1,2,..,k\right\}
$$
and was wondering how to determine the VC dimension of C?
Answer: VC dimension is defined for a hypothesis space $H$, e.g. a set of binary classifiers $C \rightarrow \{0, 1\}$. For example, hypothesis space
$$H=\{{\Bbb 1}_{x \le \theta}: \theta \in {\Bbb R}\}$$
has VC dimension $1$, because for any $C=\{a<b\}$,  it does not contain a classifier that gives $\{a \rightarrow 0, b\rightarrow 1\}$.
For example, a classifier from $H$ would be $f(x)={\Bbb 1}_{x \le a}$ that gives  $\{a \rightarrow 1, b \rightarrow 0\}$.
From C to H
As you have illustrated in the comments, we can build a hypothesis space $H$ from $C$ as follows:
$$H=\left\{{\Bbb 1}_{x \in C}: C = \left\{\bigcup_{i=1}^{k}(a_i, b_i): a_i, b_i \in {\Bbb R}, a_i < b_i, i=1,2,..,k\right\}\right\}$$
Meaning, each classifier in $H$ is a union of $k$ intervals that labels a point inside the union as $1$ and outside as $0$.
VC dimension of this $H$ is $2k$:

For VC $\geq 2k$: Let $A$ be an arbitrary set , and $A \rightarrow \{0, 1\}$ be an arbitrary labeling. By going from minimum to maximum member of $A$, we can cover all adjacent $1$s with one interval, and only need to use another interval when there is a $0$ barrier. Therefore, we need $k$ intervals to cover $k$ isolated regions of $1$s. Furthermore, a set with  $2k$ members has at most $k$ isolated $1$s (since to have $k+1$ isolated $1$s there should be $k$ $0$ barriers in-between), and thus, needs at most $k$ intervals.
For VC $< 2k+1$ by contradiction: for any ordered set $A_{2k+1}=\{a_1<...<a_{2k+1}\}$, there is labeling $a_k \rightarrow 1_{\text{k odd}}$, i.e.  $\{a_1 \rightarrow 1, a_2 \rightarrow 0,...,a_{2k+1} \rightarrow 1\}$ with  $k+1$ isolated $1$s which cannot be covered with $k$ intervals.
Comment: Hi, thanks for the response. It turns out the problem C is actually the hypothesis set.  You can label an arbitrary number x using C in the following way: if x is in some interval, say, (a_i, b_i) \in C, its label is 1, otherwise, its label is -1.More concisely,  only the number in the union of k intervals would be labeled 1.
Comment: @LarsErik That works! Updated.


how to send an email from a windows batch file?

Question: How can I send an email from a Windows batch file, or otherwise receive notice of success or failure of a batch file?
Answer: I like blat for command line mail.
There is a plethora of notification mechanisms, limited to your environment and your imagination.  Other favorites of mine are net send (do be careful with this...) and Twitter (various commandline tools out there).
Answer: You can use bmail.
C:\>bmail /?

    Command Line SMTP Emailer V1.07
    Copyright(C) 2002-2004 email@example.com
    Usage: bmail [options]
         -s    SMTP Server Name
         -p    SMTP Port Number (optional, defaults to 25)
         -t    To: Address
         -f    From: Address
         -b    Text Body of Message (optional)
         -h    Generate Headers
         -a    Subject (optional)
         -m    Filename (optional) Use file as Body of Message
         -c    Prefix above file with CR/LF to separate body from header
         -d    Debug (Show all mail server communications)
using -d (debug) you can see if the sending of the message succeeded or not.
Answer: EDIT: I'm not familiar with executing Cygwin commands from a batch file I've seen reference to it elsewhere.  Depending on your experience with Cygwin, one of the other answers maybe more suited to your needs, but I'll leave this one here for posterity.

If you've already got Cygwin installed you can install the email package.
$ email --help
Options information is as follows
email [options] recipient1,recipient2,...

    -h, -help module          Print this message or specify one of the below options
    -V, -verbose              Display mailing progress.
    -f, -from-addr            Senders mail address
    -n, -from-name            Senders name
    -b, -blank-mail           Allows you to send a blank email
    -e, -encrypt              Encrypt the e-mail for first recipient before sending
    -s, -subject subject      Subject of message
    -r, -smtp-server server   Specify a temporary SMTP server for sending
    -p, -smtp-port port       Specify the SMTP port to connect to
    -a, -attach file          Attach file and base64 encode
    -c, -conf-file file       Path to non-default configuration file
    -t, -check-config         Simply parse the email.conf file for errors
    -x, -timeout              Set socket timeout.
        -cc email,email,...   Copy recipients
        -bcc email,email,...  Blind Copy recipients
        -sign                 Sign the email with GPG
        -html                 Send message in HTML format ( Make your own HTML! )
        -tls                  Use TLS/SSL
    -m, -smtp-auth type       Set the SMTP AUTH type (plain or login)
    -u, -smtp-user username   Specify your username for SMTP AUTH
    -i, -smtp-pass password   Specify your password for SMTP AUTH
    -g, -gpg-pass             Specify your password for GPG
    -H, -header string        Add header (can be used multiple times)
        -high-priority        Send the email with high priority
        -no-encoding          Don't use UTF-8 encoding


creating clusters of point data

Question: I have a map of stores for a retailer. I am trying to form clusters (of these stores) such that each member of a cluster is at most 5km  away from any other member and any non-member is at least 10 km from any member. I also would like to create a field in the point dataset indicating to which cluster a specific store beongs to. What would be the easiest way to do this?
Thanks
Comment: This problem needs to be framed differently, because its objectives can be contradictory.  E.g., what would be a solution for two stores that are 8 km apart?  They can't be part of the same cluster but they can't be put into separate clusters.
Comment: @Brad Putting stores 8 km apart into a group violates the first criterion.  I gave only the simplest example of the internal contradictions.  What would be done with 3 stores spaced 4 km apart on a line, for instance?  Or with a bunch of stores spaced along the perimeter of a 4 km radius circle around another store?
Comment: maybe single stores 8km apart are in their own group.
Comment: umut, IMHO it's a good idea to sketch (with paper and pencil) the clustering criteria, that will certainly help you to reach a better approach. Also, look for some clustering theory (http://en.wikipedia.org/wiki/Cluster_analysis) to understand the machine's interpretation of clusters.
Answer: As @whuber says, I think you're going to need to relax your criteria, because it won't work as stands. One possible algorithm would be:

for each point calculate the distance to the nearest other point - in Mapinfo this can be done using the Distance Calculator tool, or in MapBasic
arrange these distances in descending order
for the smallest nearest distance, select all points that are within 5km (or whatever parameter you choose) of that point -
draw a convex hull around these points (a shape that encloses all points)
remove those points from the list and continue down the descending list of nearest distances, only selecting those points which have not already been made into a convex hull

There are automated routines to do this sort of analysis in packages like ArcGIS or R, but processing time will be significant if you have a large number of points. You will probably have to experiment to get the best results, I don't think it's possible to lay down hard rules about clusters as you have above.

creating clusters of point data


Can you write any algorithm without an if statement?

Question: This site tickled my sense of humour - http://www.antiifcampaign.com/ but can polymorphism work in every case where you would use an if statement?
Comment: I think the title is a bit misleading. I suggest "Can you avoid explicit type checking with proper OO in every case?"
Comment: That sounds a bit like "Object Calisthenics": http://dubroy.com/blog/if-this-is-object-calisthenics-i-think-ill-stay-on-the-couch/
Comment: IF's the new GOTO ... just like the second could be misused so can the first. Reminds me of winchhunts ... ill informed people afraid of what they don't know ...
Comment: @Idigas: how do you hunt a winch?
Comment: @RCIX: You listen for the telltale clink...clink...clink... and look for something being pulled up. ;)
Comment: do you mean without comparisons or without using the if keyword? this question is ambiguous,
Comment: is that the latest "No-SQL" spinoff ??
Comment: if this were 4chan I'd `sage` this silly thread in all fields
Comment: @RCIX - Ups ... (just now realized) ... okey. My bad ;-)))
Answer: Smalltalk, which is considered as a "truly" object oriented language, has no "if" statement, and it has no "for" statement, no "while" statement. There are other examples (like Haskell) but this is a good one.
Quoting Smalltalk has no "if" statement:

Some of the audience may be thinking
  that this is evidence confirming their
  suspicions that Smalltalk is weird,
  but what I'm going to tell you is
  this:

An "if" statement is an abomination in an Object Oriented language.

Why? Well, an OO language is composed
  of classes, objects and methods, and
  an "if" statement is inescapably none
  of those. You can't write "if" in an
  OO way. It shouldn't exist.
  Conditional execution, like everything
  else, should be a method. A method of
  what? Boolean.
Now, funnily enough, in Smalltalk,
  Boolean has a method called
  ifTrue:ifFalse: (that name will look
  pretty odd now, but pass over it for
  now). It's abstract in Boolean, but
  Boolean has two subclasses: True and
  False. The method is passed two blocks
  of code. In True, the method simply
  runs the code for the true case. In
  False, it runs the code for the false
  case. Here's an example that hopefully
  explains:
(x >= 0) ifTrue: [
'Positive'
] ifFalse: [
'Negative'
]

You should be able to see ifTrue: and
  ifFalse: in there. Don't worry that
  they're not together.
The expression (x >= 0) evaluates to
  true or false. Say it's true, then we
  have:
true ifTrue: [
'Positive'
] ifFalse: [
'Negative'
]

I hope that it's fairly obvious that
  that will produce 'Positive'.
If it was false, we'd have:
false ifTrue: [
'Positive'
] ifFalse: [
'Negative'
]

That produces 'Negative'.
OK, that's how it's done. What's so
  great about it? Well, in what other
  language can you do this? More
  seriously, the answer is that there
  aren't any special cases in this
  language. Everything can be done in an
  OO way, and everything is done in an
  OO way.

I definitely recommend reading the whole post and Code is an object from the same author as well.
Comment: Which is not all that different from `if` for all intents and purposes
Comment: An if statement by another name.
Comment: @hasen the mean is similar but the way is **very** different.
Comment: @Andreas You are thinking too small. The key thing about smalltalk is that it's all objects (characters and integers, classes, methods, the browsers, the IDE itself) and this makes smalltalk uber powerful in terms of debugging, refactoring, TDD. More powerful than any recent language actually.
Comment: It is not a language statement, but a method. The  difference is that you can only use if for an expression that returns a boolean; it is also means that if SmallTalk doesn't implement a method like `isA(class)`, then you cannot use `ifTrue:` to verify the class of an object, which is what an OO language should avoid. Of course, not all the languages are pure OO, and they implement features that should make the language more powerful (although that doesn't mean the features make the language safer).
Comment: I'm affraid your link to "Code is an object" is broken.
Comment: So basically when I need an if i have to type more, great
Answer: That website is against using if statements for checking if an object has a specific type. This is completely different from if (foo == 5). It's bad to use ifs like if (foo instanceof pickle). The alternative, using polymorphism instead, promotes encapsulation, making code infinitely easier to debug, maintain, and extend.
Being against ifs in general (doing a certain thing based on a condition) will gain you nothing. Notice how all the other answers here still make decisions, so what's really the difference?
Explanation of the why behind polymorphism:
Take this situation:
void draw(Shape s) {
    if (s instanceof Rectangle)
        //treat s as rectangle
    if (s instanceof Circle)
        //treat s as circle
}

It's much better if you don't have to worry about the specific type of an object, generalizing how objects are processed:
void draw(Shape s) {
    s.draw();
}

This moves the logic of how to draw a shape into the shape class itself, so we can now treat all shapes the same. This way if we want to add a new type of shape, all we have to do is write the class and give it a draw method instead of modifying every conditional list in the whole program.
This idea is everywhere in programming today, the whole concept of interfaces is all about polymorphism. (Shape is an interface defining a certain behavior, allowing us to process any type that implements the Shape interface in our method.) Dynamic programming languages take this even further, allowing us to pass any type that supports the necessary actions into a method. Which looks better to you? (Python-style pseudo-code)
def multiply(a,b):
    if (a is string and b is int):
        //repeat a b times.
    if (a is int and b is int):
        //multiply a and b

or using polymorphism:
def multiply(a,b):
    return a*b

You can now use any 2 types that support the * operator, allowing you to use the method with types that haven't event been created yet.
See polymorphism and what is polymorhism.
Comment: That would be something for self-flagellating programmers.
Comment: +1 for answering the underlying question, not just answering the title.
Comment: The website's name suggests otherwise, though.
Comment: Your answer is well explained, but there is more to OOP than just avoiding type tags.  Most GoF patterns are about avoiding IFs and keeping cyclomatic complexity down, that is, avoiding other kinds IFs
Comment: Great answer! Ifs are much faster, but in the grand scheme you make a good argument against their marginal advantage.
Answer: Though not OOP-related: In Prolog, the only way to write your whole application is without if statements.
Comment: and it was my nightmare :( ... though somewhat fun :)
Answer: Yes actually, you can have a turing-complete language that has no "if" per se and only allows "while" statements:
http://cseweb.ucsd.edu/classes/fa08/cse200/while.html
As for OO design, it makes sense to use an inheritance pattern rather than switches based on a type field in certain cases... That's not always feasible or necessarily desirable though.
@ennuikiller: conditionals would just be a matter of syntactic sugar:
if (test) body;     is equivalent to    x=test; while (x) {x=nil; body;}

if-then-else is a little more verbose:
if (test) ifBody; else elseBody;

is equivalent to

x = test; y = true;
while (x) {x = nil; y = nil; ifBody;}
while (y) {y = nil; elseBody;}

the primitive data structure is a list of lists. you could say 2 scalars are equal if they are lists of the same length. you would loop over them simultaneously using the head/tail operators and see if they stop at the same point.
of course that could all be wrapped up in macros.
The simplest turing complete language is probably iota. It contains only 2 symbols ('i' and '*').
Comment: whats the conditional construct in this language?  how do you compare primitives?  thats you're if (or switch) statement!
Comment: In pure oo language you don't have "primitives"
Comment: Archived link: https://web.archive.org/web/20091116052048/semarch.linguistics.fas.nyu.edu/barker/Iota/
Answer: Yep. if statements imply branches which can be very costly on a lot of modern processors - particularly PowerPC. Many modern PCs do a lot of pipeline re-ordering and so branch mis-predictions can cost an order of >30 cycles per branch miss.
On console programming it's sometimes faster to just execute the code and ignore it than check if you should execute it!
Simple branch avoidance in C:
if (++i >= 15)
{
    i = 0;
)

can be re-written as
 i = (i + 1) & 15;

However, if you want to see some real anti-if fu then read this
Oh and on the OOP question - I'll replace a branch mis-prediction with a virtual function call? No thanks....
Comment: Of course, if you're optimizing away from if statements, you're probably wasting your optimization time that could be better spent on, oh, any more complex structure.
Comment: @Tchavalak : Depends.. The hit on the PS3 is very high so it's time well spent but on another architecture it's maybe not such a high gain. All depends on the HW which is the ultimate arbiter of truth!
Comment: Oh and cache friendly code is a much better investment of time all round. Especially as mem speed is often the bottleneck in most modern high-performance apps ( or even most apps )
Comment: This is what I liked about the itanium architecture. No branch prediction necessary for these short if statements.
Answer: The reasoning behind the "anti-if" campaign is similar to what Kent Beck said:

Good code invariably has small methods and
  small objects. Only by factoring the system into many small pieces of state
  and function can you hope to satisfy the "once and only once" rule. I get lots
  of resistance to this idea, especially from experienced developers, but no one
  thing I do to systems provides as much help as breaking it into more pieces.

If you don't know how to factor a program with composition and inheritance, then your classes and methods will tend to grow bigger over time.  When you need to make a change, the easiest thing will be to add an IF somewhere.  Add too many IFs, and your program will become less and less maintainable, and still the easiest thing will be to add more IFs.
You don't have to turn every IF into an object collaboration; but it's a very good thing when you know how to :-)
Comment: You nailed it with *"but it's a very good thing when you know how to"*. It's one thing for someone to refuse the idea for pragmatic purposes, but it's another to do it out of ignorance.
Answer: You can define True and False with objects (in a pseudo-python):
class True:
    def if(then,else):
        return then
    def or(a):
        return True()
    def and(a):
        return a
    def not():
        return False()

class False:
    def if(then,else):
        return false
    def or(a):
        return a
    def and(a):
        return False()
    def not():
        return True()

I think it is an elegant way to construct booleans, and it proves that you can replace every if by polymorphism, but that's not the point of the anti-if campaign. The goal is to avoid writing things such as (in a pathfinding algorithm) :
if type == Block or type == Player:
    # You can't pass through this
else:
    # You can

But rather call a is_traversable method on each object. In a sense, that's exactly the inverse of pattern matching. "if" is useful, but in some cases, it is not the best solution.
Comment: @ychaouche Look for implementations of the [specification pattern](https://en.wikipedia.org/wiki/Specification_pattern) in the wild for real-world examples.  The specification pattern is a generalization of the pattern in this answer, where there are not just two conditions but any number of them (each represented by a class).
Comment: Can you give an example using ifs and without ifs (using your classes) in a simple piece of code ?
Answer: I assume you are actually asking about replacing if statements that check types, as opposed to replacing all if statements.
To replace an if with polymorphism requires a method in a common supertype you can use for dispatching, either by overriding it directly, or by reusing overridden methods as in the visitor pattern.
But what if there is no such method, and you can't add one to a common supertype because the super types are not maintained by you? Would you really go to the lengths of introducing a new supertype along with subtypes just to get rid of a single if? That would be taking purity a bit far in my opinion.
Also, both approaches (direct overriding and the visitor pattern) have their disadvantages: Overriding the method directly requires that you implement your method in the classes you want to switch on, which might not help cohesion. On the other hand, the visitor pattern is awkward if several cases share the same code. With an if you can do:
if (o instanceof OneType || o instanceof AnotherType) {
    // complicated logic goes here
}

How would you share the code with the visitor pattern? Call a common method? Where would you put that method?
So no, I don't think replacing such if statements is always an improvement. It often is, but not always.
Comment: I don't disagree with the spirit of your answer, but the shared logic example is probably not the best (at least as described here, in such generic terms).  In this case it's very obvious that a new type should be added in the hierarchy between the base type and `OneType`/`AnotherType`.  If this can't be done, it *usually* suggests the design can be further improved (too often it's because of an SRP violation).  Thinking more functionally helps a lot.
Answer: I used to write code a lot as the recommend in the anti-if campaign, using either callbacks in a delegate dictionary or polymorphism.
It's quite a beguiling argument, especially if you are dealing with messy code bases but to be honest, although it's great for a plugin model or simplifying large nested if statements, it does make navigating and readability a bit of a pain.
For example F12 (Go To Definition) in visual studio will take you to an abstract class (or, in my case an interface definition).
It also makes quick visual scanning of a class very cumbersome, and adds an overhead in setting up the delegates and lookup hashes.
Using the recommendations put forward in the anti-if campaign as much as they appear to be recommending looks like 'ooh, new shiny thing' programming to me.
As for the other constructs put forward in this thread, albeit it has been done in the spirit of a fun challenge, are just substitutes for an if statement, and don't really address what the underlying beliefs of the anti-if campaign.
Answer: You can avoid ifs in your business logic code if you keep them in your construction code (Factories, builders, Providers etc.). Your business logic code would be much more readable, easier to understand or easier to maintain or extend. See: http://www.youtube.com/watch?v=4F72VULWFvc
Answer: Haskell doesn't even have if statements, being pure functional. ;D
Comment: Which is, for all intents and purposes, an if-statement.
Comment: Yes it does: `isZero x = if x == 0 then True else False`
Comment: thats an if expression, it is entirely equivalent to `cond True a b = a; cond False a b = b`, which is not dissimilar to the smalltalk ifTrue:ifFalse: method
Answer: You can do it without if per se, but you can't do it without a mechanism that allows you to make a decision based on some condition.
In assembly, there's no if statement. There are conditional jumps.
In Haskell for instance, there's no explicit if, instead, you define a function multiple times, I forgot the exact syntax, but it's something like this:
pseudo-haskell:
def posNeg(x < 0):
    return "negative"

def posNeg(x == 0):
    return "zero"

def posNeg(x):
    return "positive"

When you call posNeg(a), the interpreter will look at the value of a, if it's < 0 then it will choose the first definition, if it's == 0 then it will choose the second definition, otherwise it will default to the third definition.
So while languages like Haskell and SmallTalk don't have the usual C-style if statement, they have other means of allowing you to make decisions.
Comment: If anyone wants to fix the syntax to match that of haskell, feel free to edit and fix (if you have enough points, of course)
Comment: The exact syntax you are looking for is pattern matching, which (I think) in turn is syntactic sugar for a case expression.
Answer: This is actually a coding game I like to play with programming languages. It's called "if we had no if" which has its origins at: http://wiki.tcl.tk/4821
Basically, if we disallow the use of conditional constructs in the language: no if, no while, no for, no unless, no switch etc.. can we recreate our own IF function. The answer depends on the language and what language features we can exploit (remember using regular conditional constructs is cheating co no ternary operators!)
For example, in tcl, a function name is just a string and any string (including the empty string) is allowed for anything (function names, variable names etc.). So, exploiting this we can do:
proc 0 {true false} {uplevel 1 $false; # execute false code block, ignore true}
proc 1 {true false} {uplevel 1 $true;  # execute true code block, ignore flase}

proc _IF {boolean true false} {
    $boolean $true $false
}

#usage:
_IF [expr {1<2}] {
    puts "this is true"
} {
  #else:
    puts "this is false"
}

or in javascript we can abuse the loose typing and the fact that almost anything can be cast into a string and combine that with its functional nature:
function fail (discard,execute) {execute()}
function pass (execute,discard) {execute()}
var truth_table = {
    'false' : fail,
    'true' : pass
}
function _IF (expr) {
  return truth_table[!!expr];
}

//usage:
_IF(3==2)(
    function(){alert('this is true')},
//else
    function(){alert('this is false')}
);

Not all languages can do this sort of thing. But languages I like tend to be able to.
Comment: Somebody I had to work with once stated that "in true OO, you don't need if's", but his code looked quite the opposite. I came up with a similar solution.
Answer: The idea of polymorphism is to call an object without to first verify the class of that object.
That doesn't mean the if statement should not be used at all; you should avoid to write
if (object.isArray()) {
  // Code to execute when the object is an array.
} else if (object.inString()) {
  // Code to execute if the object is a string.
}

Answer: It depends on the language.
Statically typed languages should be able to handle all of the type checking by sharing common interfaces and overloading functions/methods.
Dynamically typed languages might need to approach the problem differently since type is not checked when a message is passed, only when an object is being accessed (more or less).  Using common interfaces is still good practice and can eliminate many of the type checking if statements.
While some constructs are usually a sign of code smell, I am hesitant to eliminate any approach to a problem apriori.  There may be times when type checking via if is the expedient solution.
Note: Others have suggested using switch instead, but that is just a clever way of writing more legible if statements.
Answer: Well, if you're writing in Perl, it's easy!
Instead of
if (x) {
    # ...
}

you can use
unless (!x){
    # ...
}

;-)
Answer: In answer to the question, and as suggested by the last respondent, you need some if statements to detect state in a factory. At that point you then instantiate a set of collaborating classes that solve the state specific problem. Of course, other conditionals would be required as needed, but they would be minimized.
What would be removed of course would be the endless procedural state checking rife in so much service based code.
Interesting smalltalk is mentioned, as that's the language I used before being dragged across into Java. I don't get home as early as I used to.
Answer: I thought about adding my two cents: you can optimize away ifs in many languages where the second part of a boolean expression is not evaluated when it won't affect the result.
With the and operator, if the first operand evaluates to false, then there is no need to evaluate the second one. With the or operator, it's the opposite - there's no need to evaluate the second operand if the first one is true. Some languages always behave like that, others offer an alternative syntax.
Here's an if - elseif - else code made in JavaScript by only using operators and anonymous functions.

document.getElementById("myinput").addEventListener("change", function(e) {

  (e.target.value == 1 && !function() {
    alert('if 1');
  }()) || (e.target.value == 2 && !function() {
    alert('else if 2');
  }()) || (e.target.value == 3 && !function() {
    alert('else if 3');
  }()) || (function() {
    alert('else');
  }());

});
<input type="text" id="myinput" />

This makes me want to try defining an esoteric language where blocks implicitly behave like self-executing anonymous functions and return true, so that you would write it like this:
(condition && {
  action
}) || (condition && {
  action
}) || {
  action
}

Comment: While it could be amusing, note that the question is explicitly about polymorphism, so this doesn't strictly answer it.


Generalizing $\,r(n^2) = r(n)^2,\,$ for $\,r(n) := $ reverse the digits of $n$

Question: I'm assuming this theorem was found by someone else before, but I found this relationship between square numbers of 3 digits or less. The theorem is this: If you reverse the digits in a square number, then the result will also be a square number. Take the square 961. It is 31 squared, and if you reverse the digits you will get 169, which is also a square number. Plus, 31 and 13(the roots of these reversed squares) are also reverses of eachother. The problem is this breaks with 4 or more digits. If I take the square 1024 and reverse the digits, I get 4201, which is not a square. How can I expand this theorem to fit 4 or more digits?
Comment: $15^2=225$. $522$ is not a square number.
Comment: This is only true if the digits of the square root are small; they need to both be $\le 3$ and their product needs to be $\le 4$.
Comment: Also $14^2,16^2,17^2,...$
Comment: It can't be true because squares never end in the digits $2,3,7,8$ but it's easy to find squares that have those as their starting digits, and hence after reversing digits you don't get a square.
Comment: I added an answer which shows where it comes from (and where it does hold true without constraint, i.e. for polynomials).
Answer: Congratulations, you have essentially discovered an interesting property of polynomials - as (partially) manifested in their evaluations (here radix $10$ polynomials). Namely, reversing the coefficients of a polynomial is a multiplicative operation.
Let $\,f = a_n x^n +\cdots a_1 x + a_0\,$ be a polynomial in $x.\,$ Reversing its coefficients yields
$\ \ r(f) = a_0 x^n + \cdots a_{n-1}x + a_n = x^n f(x^{-1}),\ $ the reverse (or reciprocal) of $\,f.$
It is easy to show $\,r(fg)\, =\, r(f)r(g),\,$ i.e. polynomial reversal is multiplicative. For example
$\qquad \begin{align}
(x+2)\ (x+3)\, &=\ \ x^2+5x+6\, \overset{\large x\, =\, 10}\Longrightarrow\,  12\cdot 13\, =\, 156\\
\overset{\rm reverse}\Longrightarrow (2x+1)(3x+1)\, &= 6x^2+5x+1\ \ \Longrightarrow\,\ \ 21\cdot 31\, =\, 651
\end{align}$
Your examples are special cases when the product is a square (of polynomials of degree $\le 3),\,$ but from above we see it generalizes to arbitrary degree polynomials. However, for the polynomials to yield integer reversals when evaluated at the radix $\,x=10\,$ it is necessary that all polynomials (including the product) have nonnegative coefficients less than the radix (so no carries occur; in the OP squaring case such integers are sometimes called skinny).
Note that reversing twice yields the original polynomial  when the reverse has the same degree $(\!\!\iff\! f(0)\neq 0),\,$ i.e. in this case reversing is an involution or reflection $\,r^2 f = f\,$ since we have $r(r(f(x)) = x^n r(f(x^{-1})) = x^n ((x^{-1})^nf((x^{-1})^{-1}) = f(x).\,$ In particular $\,f(0)\neq 0\,$ is true when $\,f = rg\,$ is a reversal, so $\,r^2(rg) = rg,\,$ i.e. $\,r^3g = rg\,$ for all $\,g$.
Remark $ $ Generally the evaluation map helps relate (ring-theoretic) properties of polynomials to properties of their evaluations. For example, in some contexts we can deduce that if a polynomial takes a value with few factors then the polynomial must have few factors too (this is often used in contest problems since it is not as well-known as it should be).
One can push this idea to the hilt to obtain a simple algorithm for polynomial factorization using factorization of its integer values and Lagrange interpolation (using ideas going back to Bernoulli, Schubert and Kronecker).
Comment: So what you are saying is that this will work for non-square real numbers? Does it work with coefficients greater than 3?
Comment: @Trevor Square the general degreed  trinomial polynomial with undetermined coefs, then find the values of the coefs that are small enough that all the polynomials (including product) have coefs less that the radix [else carries may happen which make the reversal no longer hold for integer (vs. polynomials)]. Note that the same works for any products, not only squares, as the example above shows (reversing $12\cdot 13)\ \ $
Comment: That makes sense. Is there a way to do this if one or multiple of the coefficients is larger than the radix?
Comment: @Trevor There may be some special (paramterized) classes that one can work out nicely, but it's probably not tractable to account for the effect of carries in general.
Comment: Alright, thanks. I realized I can just make the radix larger so its larger than all the coeffs. For the equation (2x+9)(x+2) a radix of 10 didn't work, but a radix of 20 did.
Comment: @Trevor Yes. that will work. I added a related remark that you may find of interest.
Answer: Hint: If a 3-digit square equals $(10x+y)^2 (1 \leq x,y \leq 9)$, what are the conditions on $x,y$ for the 3 digits in reverse order to form a square?  Can you extend this to, for example, a 5-digit square equalling $(100x+y)^2$?
Answer: The point is that $(10a+b)^2=100a^2+20ab+b^2$.  The reversal will work as long as $a^2,2ab,b^2$ are all less than $10$ so there is no carry.  If you try to go to four digit squares you need $a^2$ or $2ab$ to carry, which will make the reversal fail.
If you go to three digit square roots, we have $(100a+10b+c)^2=10000a^2+2000ab+100(b^2+2ac)+20bc+c^2$.  To make the reversal work, you need no carries here, so all the digits need to be small.


embed codebehind results in javascript mvc3

Question: I have a mvc3 view (map.cshtml) that has a javascript section in it.
I have a controller (MapController.cs) that has a function that will return a string.
I need to call the function from within the javascript area of the cshtml page,
and have it render the results directly into the javascript block prior to being processed and displayed.
The whole task is to create a series or infowindows for the google map, and because the data is so scattered around the system, the codebehind function gathers this data, and places it into html code and i need this html code to be injected into the javascript block prior to being displayed.
whew...
thanks
Here is the actual code block i am currently using...
@functions
{
  private string getContent()
  {
    return "testing";
  }
}

  var map;
function initialize() {
    var myLatlng1 = new google.maps.LatLng(29.64032, -82.363129);
    var myLatlng2 = new google.maps.LatLng(29.64032, -81.363129);
var myOptions = {
  zoom: 10,
  center: myLatlng1,
  mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('map_canvas'), myOptions);

var test = 'X@{getContent();}';

So - in the var test....  i would like it to read....    Xtesting
Comment: What are you going to use the variable test for? Do you intend to have plain text as value for the variable test?
Answer: You can use jQuery ajax to get data from your Controller actions, in your javascript code.
Include jQuery library in your view (or layout view) and include the below script in your view(map.cshtml).

You need an Action method called GetName in your MapController now to handle this ajax request.
public ActionResult GetName()
{
   return Content("mvc is awesome");
}

Answer: Is this what you want?
var test = 'X@(getContent())';


Why is a set of p-functions added to the minimum basis sets of Li and Be?

Question: The minimum basis set consists of the smallest number of functions necessary to contain the electrons of the neutral system. In the book Introduction to Computational Chemistry, Second Edition, by Frank Jensen, it is stated that "a set of p-functions" usually is added to the minimum basis sets of Li and Be atoms, despite them containing 3 and 4 electrons respectively and thus would require 2 s-functions. I can not, however, understand why.
Comment: A minimal basis includes a single basis function for each orbital assumed to be relevant to the atom (or molecules that include that atom), which are usually those in the same shell. Think about Be; you might be able to describe a lone Be atom with just the 1s and 2s orbital, but you would describe bonding very poorly without including 2p orbitals.
Answer: By your definition, any minimal basis set would only include as many orbitals (including spin state) as there are electrons. This implies that each atom would be described as a single determinant and therefore the entire system would be described by a single determinant. Without unoccupied orbitals, there is no binding. Hence, a minimum basis set has to fulfill a few more constraints. A common requirement is the inclusion of the full valence shell and invariance under spin-flip. For second period elements, this includes p-orbitals.


How do I render out a clear render with no blurs?

Question:
When I render a picture in blender the render doesn't come out clean and clear with the materials it's always blurry. And I've tried to increase the samples and reduced the denoiser I've  checked my camera settings but there still no change. I can only use Photoshop to sharpen the image which isn't bad but not as expected. Where as I look online and see very clean and clear renders with the materials.
Answer: To me it doesn't look really blurry, but more like a (too) heavy denoising.
How many samples are in this render?
To me, it looks like there is not enough in the first place, so the denoiser doesn't have enough detail to work with, and basically roughly washes out the pixels to get rid of the noise.
Out of my head, I would say such render would require a few hundreds of samples. So try like 300 first, then increase per hundred.
Just so you don't spend your entire day making test renders for nothing, don't hesitate to use the render border tool ⎈ CtrlB to render only small parts of your shot. So it will be fast to render & re-render.
Another thing you can do is to set a crazy amount of samples you will never reach and enable Progressive refine:

That way, it will render the entire frame sample per sample instead of fully rendering every sample of little portions. So you can render a portion of your frame via render border and see how the render quality improves along with the samples.
Once you're happy with the result (don't forget you have a denoise after), you look which sample amount has been rendered and you set that value for the final render samples.
Don't forget to disable progressive refine and render border (⎈ Ctrl⎇ AltB) for that one. Progressive refine is slower, and you don't want to let that render border on when you think you render the entire frame.
Comment: I rendered the image with over 2500 samples
Comment: Have you changed your denoising settings? The default parameters are ok most of the time, but not always. Especially if you make it too strong. Can you provide a screenshot?


AMPscript to hide code if transactional send?

Question: Right now I have two sets of templates, one for commercial sends, and one for transactional sends. My commercial template has a table with my opt-out/manage profile links. Is it possible to use AMPscript to hide that table if the send is transactional?
Answer: Since the Send Classification is defined at the Send Definition level (e.g. Guided, User-Initiated, Triggered Send), not on the Email level, the only scripting option you have is to do an API retrieve on the Send Definition using the AMPScript API functions.  Those may be restricted to Landing Pages.
How are you Send Definitions configured?  Are there data elements in the send that you can use to classify emails as Transactional vs Commercial?
EDIT 2023-01-16
If you don't mind the overhead of a lookup, you can use something like this to determine the Send Classification:
<code>if not empty(attributevalue("jobid")) and jobid > 0 then

  set @sendclassification0 = lookup("_job","sendclassificationtype","jobid", jobid)
  set @sendclassification = 'Commercial'

  if not empty(@sendclassification0) and indexof(@sendclassification0,"trans") > 0 then
    set @sendclassification = 'Transactional'
  endif

endif
</code>
Comment: Thank you for your useful idea and information! I did not know the data view can be treated like a DE for AMPscript function. Your example code above is missing an "endif" statement by the way
Comment: Added the missing endif.  Thanks


Arduino to Beaglebone black

Question: I have an Arduino uno3 which gets data from a digital caliper and shows the data in serial monitor. Now I should make a connection between this Arduino and my Beaglebone black through SPI to get the data sent from caliper in Beaglebone black. and I don't know what to do and how to create codes related to this purpose.
Answer: Have a look at the first several links from googling for Arduino and my Beaglebone black through SPI.  Here are a few comments on those first few links:
• SPI - Beaglebone Black Master Arduino Uno Slave (forum.arduino.cc topic 446924.0) – This page asks your question in more detail, and includes Beaglebone master code and Arduino Slave code.  However, the poster makes an egregious error in the Arduino code by saying Serial.println("SPI"); within the SPI interrupt service routine.
• Communicate Beaglebone Black and Arduino via SPI
(ulasdikme.com) – This page addresses your question in rather more detail, and apparently shows working code.  It also explains how to enable SPI in the Beaglebone device tree.  Note, this poster too makes an egregious error in the Arduino code by saying Serial.println(c); within the SPI interrupt service routine.
• SPI communication: BeagleBone Black (as Master) to 4 Arduinos (as Slaves) (adurthi.com) – This page covers level shifting and device tree setup and provides ok code.  It seems to cover BeagleBone concerns nicely, and has ok Arduino code as well.
One or two of the above also make reference to Nick Gammon's excellent SPI pages:
• SPI - Serial Peripheral Interface - for Arduino (gammon.com.au forum id=10892) – This page is where you should start if you have questions about how SPI works.  After you are familiar with SPI basics, scroll down to the "How to make an SPI slave" heading, and set up the master-slave example with two Arduinos.  When you have that working, you can substitute or add a BeagleBone as master.  Other code examples further down the page include  "How to get a response from a slave", slave SS pin interrupt examples, SPI via USART, speed settings, SPI on ATtinys, sending data structures, and (under the heading "SPI under IDE 1.6.0 and later"), exegesis of SPI library methods.
• Debugging using SPI/I2C and a second processor (gammon.com.au forum id=11329) – This page illustrates master-slave communication between two Arduinos, using one as a slave to forward information sent from a system being debugged.  Also illustrates use of I2C for similar purpose.  Note, Debugging The Arduino With The SPI Interface Instead Of Serial.println() (utopiamechanicus.com) is a follow-on article, by another author, about this debugging technique.

Arduino to Beaglebone black


Setup adwords cross-domain(subdomain) conversion tracking

Question: How can i setup cross domain conversion tracking with adwords?
My main site is "www.mainsite.com"
My conversion goal is visit "apply.mainsite.com" and login.
Comment: It sounds like you have a subdomain situation not a cross-domain.   For a subdomain you can have GA set the cookie at the domain level and tracking across both works seamlessly.
Answer: Adwords does not support cross domain tracking however Google Analytics (AKA GA) does. Simply link your adwords account to your GA account. Below are quotes from Google's Answer pages, they are snippets and for full information you should visit each source.
Link Adwords With Google Analytics

SOURCE
Link AdWords and Analytics
The linking wizard makes it easy to link your AdWords account(s) to multiple views of your Analytics property. If you have multiple Analytics properties that want to link to your AdWords account(s), complete the linking process for each property.

Sign in to Google Analytics. Note: You can also open Analytics from within your AdWords account. Click the Tools tab, select Analytics, and then follow the rest of these instructions.
Click Admin and navigate to the property you want to link.
In the PROPERTY column, click AdWords Linking.
Click + NEW LINK GROUP
Select the AdWords accounts you want to link, then click Continue.
Turn linking ON for each view in the property in which you want AdWords data.
Optionally, select Enable Google Display Network Impression Reporting to also include that data in each view.
If you've already enabled auto-tagging in your AdWords accounts, or if you want to let the linking process automatically enable auto-tagging in your AdWords accounts, skip to the next step (9). However, if you want to manually tag your AdWords links, click Advanced settings > Leave my auto-tagging settings as they are.
Click Link accounts.

Congratulations! Your accounts are now linked. If you opted to
  use auto-tagging (recommended), Analytics will start
  automatically associating your AdWords data with customer clicks.

Setup Cross Domain Tracking in GA

SOURCE
Set up cross-domain tracking (analytics.js)
Cross-domain tracking makes it possible for Analytics to see sessions on two related sites (such as an ecommerce site and a separate shopping cart site) as a single session. This is sometimes called site linking.
To set up cross-domain tracking, you'll need to be comfortable editing HTML and coding in JavaScript, or have help from an experienced web developer.
Set up cross-domain tracking by modifying the tracking code
To set up cross-domain tracking for multiple top-level domains, you need to modify the Analytics tracking code on each domain. You should have a basic knowledge of HTML and JavaScript or work with a developer to set up cross domain tracking. The examples in this article use the Universal Analytics tracking code snippet (analytics.js).
<code>  ga('create', 'UA-XXXXXXX-Y', 'auto', {'allowLinker': true});
  ga('require', 'linker');
  ga('linker:autoLink', ['example-2.com']);
</code>

E.g use linker using <code>['shop.example.com', 'www.example.com']);</code>


Which is the best way to use binded service?

Question: I have few activities and a single service in my app. Most of these activities need to bind to this service and use the services offered by it. There is only one entry point into the app and that activity binds to this service. Once the service is bound i get the instance of my service and save it in a static reference. Would it be okay if i use this same static reference in other activities to make use of the services offered by the service? Or do I have to bind to the service from every activity that wants to use the service?
Answer: No. You should update each individual Activity to bind to the service. You should not count on a static reference being retained in memory.
Answer: Maybe it is even better to start service from "entry point activities" and then to bind other activities to the service when u need it later..


Can the prefix re- be added to nouns?

Question: I am a little confused about what affix to add first to the stem "elect". The word is re-election. If I add the suffix -ion first, then it turns the verb into a noun. The affix 're-' attaches best to verbs (if I'm not mistaken). Should I just attach the prefix first then?
Comment: If _re_- can be added to the verbs that the nouns come from, then they can appear on the nouns that are derived from them. _Re-elect_ is a verb, so _re-election_ is the derived noun.
Comment: _Re_- is a verbal prefix. The _re_- appears on the verb. And the verb gets made into a noun. There's no "first" -- this isn't what happens when you talk, it's what happened when the verb was borrowed from Latin.
Comment: so it doesnt matter which one i add first? or i could check in a corpus which on is the most common?
Answer: The first test you should apply is whether re- can be added to a noun and give another noun – *re-tree, *re-pig and so on should persuade you that re- does not attach to nouns. Second is to verify that re- attaches to verb, e.g. re-take, re-think, re-elect. Then when faced with a derivation from noun to verb or verb to noun, if on the surface you find a word of one category X which takes an affix that only attaches to category Y, and if the word also has an affix that converts a Y to an X, then you should assume that the restricted affix is added to the category Y stem first, and then Y changes to X.
Words like "first", "then" are used by linguists in different ways — either literally, meaning in time (i.e. there is a claim about processing) or else in terms of lower versus higher levels of attachment in a structural tree (in case you want to avoid any implications about processing). To really put your theory to the test, you should also try to find newly-generated forms, like "re-macadamize" or even "re-pre-macadamize", which can't reasonably be accused of being historical archaisms (unless you build roads for a living). "Re-think" is a good example since unlike re-elect, it couldn't have been pre-constructed in Latin.

Can the prefix re- be added to nouns?


sun setting in the south

Question: In the last 5 minutes of San Andreas, there are at least 2 shots where the camera looks down the length of the Golden Gate Bridge (in San Francisco), and the sun is setting over the hills past it. The Bridge runs north-south, so the sun must be setting in the south. Was that a production gaffe, or was the implication that all of the San Francisco Peninsula had rotated 90 degrees so it now runs east-west?
Comment: Can you find video of this that we could look at?
Comment: Good suggestion, but the movie just came out last night so I couldn't find any pics of that. There are plenty of promotional stills of the destruction though!
Comment: Ah, I thought that might have been the one... I'm not a huge fan of disaster films, so I tend to ignore when they're released. :P
Answer: I'd categorize this as a production gaffe. A Google Image search confirms that when you look directly into the sunset, the Golden Gate Bridge is in profile, since it runs north-south, as you said.

If the bridge is still standing, more than just the San Francisco peninsula would have to rotate 90 degrees. The landmass on the northern side of the bridge (Sausalito) would have to rotate with it.
If you zoom in on a map of the San Andreas Fault, you can see that it actually runs a few miles west of the bridge. So even if it did open up the way it did in the film, it shouldn't cause the whole region to the east to spin around 90 degrees. I think this is a well-spotted gaffe.
Comment: That movie was PACKED with gaffes.  But a whole lot of fun!!
Answer: There are at least 13 OBVIOUS gaffes in this movie. As a San Franciscan I was embarrassed and annoyed. They filmed here so there are no excuses for these mistakes.
1. When they enter 555 California the view outside the window is the Bay Bridge. You can't see the Bay Bridge at this angle; the Bay Bridge is not a truss bridge; and none of the buildings in view are SF buildings.
2. There is a shot where people are walking through downtown buildings toward the Golden Gate bridge. Downtown and the GGB are on opposite sides of the city as opposed to popular belief.
3. If you're driving north from Bakersfield you're taking the 5. The San Andreas fault is shown spanning east to west across the 5. It doesn't. And Bakersfield is not an 1.5 hour from SF.
4. Lombard STREET, not Avenue.
5. Nob Hill is not the highest point in the city. Mount Davidson is.
6. Lombard is only a 15 minute walk from Nob Hill and you would not walk through Chinatown to get there.
7. Probably most disrespectful, the tallest building under construction in this movie was NOT EVEN A SAN FRANCISCO BUILDING. It is the under construction Wilshire Grand of Los Angeles. Our tallest building under construction is the Transbay Salesforce Tower. Hollywood dissed SF.
8. AT&T Park is on King St. Not the Embarcadero.
9. The San Andreas Fault is inland and could never trigger a tsunami in the direction of the Bay.
10. Bryant St is not located in the Financial District.
11. Not to do with SF but for as long as that girl was under water and without oxygen to her brain she would be brain dead, at best. She didn't breathe for about 4 minutes. You're dead after 2.
12. The Marin Headlands are incredibly windy, up to 60mph. You could never set up tents there.
13. And lastly, someone attached a flag on the defunct bridge. Ain't nobody shimming up those cables to hang no flags during an earthquake. Not accessible how it was portrayed.
Comment: and how does it answer the question?
Comment: It would have been best if you stayed to question asked.

sun setting in the south


Numerical references in the detailed description of a provisional patent application?

Question: In reference to the detailed description for my provisional patent application, I believe my description does not need numerical references back to the drawings. Am I correct in that the numerical references are not required in the provisional patent application but are required in the nonprovisional application?
Answer: While the "formalities" requirements of a provisional application are low, if you ever need to actually make use of the rights a provisional provides, the content of the provisional will be subject to the same scrutiny as a non-provisional. For example - does it teach someone skilled in the art how to make and use the invention? If lack of reference numbers means that one skilled in the art can't clearly understand what you are disclosing, then the provisional will have failed to do its job.
Comment: George White, thank you so much for your help. I am writing my provisional patent application to the standards of a nonprovisional application however the time that it is taking me to reference each element of the process is quite cumbersome, 5 pages yesterday out of 24 pages of detailed description.


Samsung Knox locked and possibly removed all the data stored inside it. Can I recover it?

Question: I have been using Samsung knox for over 6 months now and a few days back, decided to change my older password. Did so and also changed the security pin. Now I have forgotten both password and the pin to the account. I entered wrong password 20 times in a period of 2 days. As a result my knox got deleted. Now if someone could help, I would like to know if I can recover my data of the account.
Thank you for helping.
Answer: Short answer: no. Knox is meant to be secure, so short of taking the chip out of the phone and scanning it to get the fingerprint of fragments of info, you can't recover it.


Looking to create an ensemble of CNNs for segmentation

Question: I'm looking to create an ensemble of CNNs for segmentation. Do you know how many CNNs I should have in my ensemble? Would I be tuning this or is there a general amount that I should have? I noticed that papers tend to have between 10-30 CNNs. How about 100? Or 1000? Are the limitations here just resource constraints? Just from reading online it seems there's a drop-off after a certain point, which makes sense because if you assume using a single classifier may vary from the mean from a certain amount, increasing the number of samples would more closely approximate the mean up until you reach a good sample size, if you're doing model averaging. Is there any resource for the number of classifiers used for ensemble methods, especially for segmentation? Also, clearly there are other types of ensemble methods as well - is there any systematic study on using different types of ensemble methods with CNNs (bagging, adaboost, etc.) and which are advantageous, especially for segmentation?
Comment: Here are some slides in regards to the effect of the number of classifiers on test error in bagging and boosting: http://www.ic.unicamp.br/~wainer/cursos/1s2012/mc906/ensembles.pdf. Based on the slides, it seems to suggest there's a dropping off point after a certain sample size so perhaps I can evaluate my ensemble in 5-10 classifier increments or something. I guess it wouldn't hurt to potentially have more classifiers obviously than less.
Answer: I am unfamiliar with using ensembles of CNNS, but you might be interested in Hinton, Geoffrey E., et al. "Improving neural networks by preventing co-adaptation of feature detectors." arXiv preprint arXiv:1207.0580 (2012).

Dropout can be seen as an extreme form of bagging in which each model is trained on a single case and each parameter of the model is very strongly regularized by sharing it with the corresponding parameter in all the other models.

So, if you equate dropout to bagging, then ensemble methods are used extensively for neural networks in the form of dropout. It is probably much easier (and less expensive) to tune the degree of dropout than to tune an actual ensemble of CNNs.
If you do want to use an ensemble, the number of estimators would have to be chosen as a hyperparameter using a validation set or cross validation because the best number of estimators would be highly dependent on the data (although perhaps if there are networks trained on images you could use their choice as it seems that insights from working with one set of images tend to generalize, perhaps because processing pixels is kind of more general than processing structured attributes).  Finding the number of estimators would be difficult because now the hyperparameters of each estimator would be conditioned on the number of estimators.  This might not be so bad when they are decision trees, but when they are CNNs it might be really difficult to train.
In terms of boosting, generally that is used to combine weak estimators while CNNs are high capacity models (although it might be a good idea to boost them, don't know).


What alternate ways are there to get into a garage when you don't have the opener?

Question: I am locked out of the garage without a remote opener.  There are no windows and no doors to get in.  What are some ways to open the garage door without breaking down the door?
Comment: Cut a whole in the side of the garage the same size as a door. Then, when you're done, stick a door in that hole.
Comment: Is this one of those Non-linear thinking problems?
Comment: I can't believe there is a garage with no windows and doors- what would you do during a power outage?
Comment: You might call a local garage door installer and ask for suggestions.  But essentially you need to get into a locked building with no doors or windows - you either have to break something or cut a hole in something.
Comment: Why can't you go through the house?
Answer: Typically, garage openers have a release pull that hangs down from the track.  When closed, this release will be close enough to the door to get if you drill a 5/8 inch hole about a foot under the where the opener attaches to the door.  Fish for the line with a wire coat hanger and then pull to release.  It will take a couple of tries but you should be able to do it.
Once open, go to your hardware store and get a garage door quick release lock and install it into the hole you just drilled.  In the future if you have a power outage or a failed garage door opener you will be able to get back in.
Comment: This may well be the best idea, but it's hardly a sure thing: my garage door opener doesn't have a lanyard attached to the release latch. Also mine requires a fair amount of force; it might be hard to pull at an angle like that, even if you could reach the cord.
Answer: All you need do is borrow (since you can't get inside to access your own supply of tools) a regular, flathead screwdriver.  Place the blade of the screwdriver against the keyhole of the garage lock, just like you are attempting to unlock it with a regular key.  Then, bash the back of the screwdriver, driving it into the lock.  This will be sufficient enough to jar the lock open, without damaging the lock.  You may need to use a hammer to hit the handle of the screwdriver.
Comment: I don't think the lock is the issue - they need to disengage the opener mechanism to manually open the door, which you can't do if you're locked out


Are sweet potatoes and yams treated different in terms of cooking?

Question: I saw this this question, and a few others, but there aren't any explanations I can find that say whether the two are treated differently or not. In other words, can they be used as a direct substitute?
Answer: It depends on what you mean by "yam".
Once upon a time, in the deep south of the US, there was a tuber known as the sweet potato, and it was good.   And then one particular grower decided to sell theirs under the trade name "yam" to get better marketing recognition.  This lead to some folks in the US calling sweet potatoes by the name yam, especially in the context of candied yams (a sweet casserole of spiced sweet potato).
So if the word "yam" is being used to mean a variety of sweet potato, then they are culinary identical.  Sweet potatoes of all variety are, well, potato sized (or a bit bigger than the average potato), and their color can range from whitish through yellow, orangish or reddish.  Most grocery store varieties are fairly orange in color.
True yams originate from Africa, and are far more starchy and fibrous than sweet potatoes, no matter what they are called, and are used in entirely different ways.  They can be very large, football to basketball sized or larger.  There are also a tremendous variety of true yams.
Comment: No, these are yams http://en.wikipedia.org/wiki/Oxalis_tuberosa ... maybe there is no standardi(s/z)ed world language yet :-)
Comment: Actually, that is a 3rd vegetable by that name.  From the context of the question, however, I assumed US usages.


Shutting off water during extra-long term vacancy

Question: If vacating a condo (for context, high floor apartment-style unit in hi-rise) that will not be used for quite a while, is it ok to shut off it's water for as long as TWO YEARS?
Comment: You should seriously weigh the pros and cons of packing up all your belongings you'd be leaving behind, place them in storage (climate controlled if you like) and renting the place out through a local management company, .vs. a two year vacancy.
Answer: There's nothing wrong with shutting off the water for that length of time provided you take the proper precautions. The water in all your traps for the sinks, toilets and showers will evaporate and allow sewer gas and bugs to get into your condo. They should be adequately sealed to prevent this. If you have a water heater, you should drain it and shut off the breaker if it's electric. Drain the water from your fridge, and very importantly use tape or something else to ensure the door is slightly ajar the entire time (otherwise you get terrible stink).
Have your maintenance department shut off the water from outside your unit so a leaky valve won't be your problem.
Or, hire a management company and let it be listed on AirBnB.
Answer: You can shut off the water and drain the system, but as part of recommissioning after 2 years the system will have to be flushed through and disinfected, with special attention paid to any dead legs where stagnant water has accumulated. Legionella is the main risk.


Metric tensor coordinate transformation with off-diagonal components

Question: I know there is already an answer for this type of question given here: Computing the metric tensor under a coordinate transformation but the answer is not satisfactory as it is not clear to me how I could modify the existing code since I can not tell where the transformation laws are for the metric. For background, I know if I want to transform the metric tensor (and any rank-2 tensor for that manner), I use the following formula
\begin{equation}
g_{\mu\nu}' = \frac{\partial x^\alpha}{\partial x^{\mu '}}\frac{\partial x^\beta}{\partial x^{\nu '}}g_{\alpha\beta}
\end{equation}
where the initial metric is $g_{\alpha\beta}$ and the new metric is $g_{\mu\nu}'$. Now, for example, I wanted to transform the flat (Minkowski) metric from $(1,-1,-1,-1)$ to a spherically symmetric system $(t,r,\theta,\varphi)$ with the following transformation rules, $t = t'$, $x = r\sin(\theta)\cos(\varphi)$, $y = r\sin(\theta)\sin(\varphi)$, and $z = r\cos(\theta)$.How would I write this in Mathematica (or modify the linked question's code)? (I am very new to Mathematica...) The answer should be $\text{Diagonal}(1,-1,-r^2,-r^2\sin(\theta)^2)$ (in this metric signature).
This is my first step, since really I want to be able to do this for a metric with any components (in $d=4$ dimensions) that also has off-diagonal components. For example, if I had the metric that can be represented as the line element

for some functions (which I can specify if need be) $G(r)$, $F(r)$, and $C(r)$ (you can see why I want to transform this metric to spherical coordinates since the symmetry is manifest in the first term and I want to see if the second term simplifies greatly). This is also why I want to try to write code for the top example since the answer is well known (and I don't know the answer for the second one).
My trouble in writing the code is that there is two implicit sums in the tensor transformation rule that need to take all the possible combinations of derivatives of the transformation rules. So I could write something along the lines of using the sum, D, and define my coordinates with coord and with maybe the table function over all possible coordinates? (Like I said I am very new to Mathematica).
Thanks for any help (or even the code that could do this)!
Answer: First define the old and new coordinates and the old metric:
var = {t, x, y, z};
var1 = {t, r, θ, φ};
g = -IdentityMatrix[4]; g[[1, 1]] = 1;

Then define the transformation:
x = r Sin[θ] Cos[φ];
y = r Sin[θ] Sin[φ];
z = r Cos[θ];

Now we can define the new metric:
(g1 = Table[
     Sum[D[var[[i]], var1[[i1]]] D[var[[j]],
        var1[[j1]]] g[[i, j]], {i, 4}, {j, 4}], {i1, 4}, {j1, 4}] //
    Simplify ) // TableForm


What to do when spray foam has been removed and still have bad smell?

Question: Several years ago my dad was talked into spray foaming the ceiling of the attic with spray foam.  Ever since there has been a tremendous amount of dust and bad smell.  Lots of health problems have also occurred.  We had foam tested and it was offgassing.  Company finally came in and removed most of the foam.  Unfortunately the house was built in 1920's and has tongue and groove under sheet rock.  There is still a bad smell.  Dust is not so bad.  Health issues include severe burning of lips, pain in gums and teeth
, throat, and eyes.  Stomach problems are not as bad as before.  Vents were added to roof.  What else can we do?  Also we put sheep wool insulation in attic ceiling thus covering whatever residue is left.  Is that a bad idea to cover the foam?
Appreciate any input.
Comment: you did not exactly "cover" the foam, you only obstructed it from view
Answer: Where isocyanate comes from
Epoxy has 2 toxic halves that react with each other.  When they do, the result is so non-toxic it's used to line food and soda cans.  They are reacting to form a very long-chain molecule, which is very strong and tough.
The 2 parts "hold hands" like this:  A-B-A-B-A-B-A-B-(repeat a lot)-A-B-A. They don't have to be infinitely long, just long enough to entangle.
Formed-in-place polyurethane works the same way.  You have a toxic "A" part and "B" part that react to form a non-toxic long-chain molecule that is very strong and tough. (you're not interested in those properties in foam, but I work a lot with polyurethane paints, and if water contacts it before it cures, it will foam up).
If properly mixed, the isocyanates will be 100% consumed.  The only way that doesn't happen is if

The person used too much B-part, either by accident or on purpose because of a misunderstanding of how polyurethane works.
The person didn't blend/mix enough, and so inside the bucket are zones too rich in B-part.

If the stuff is turning to powder, that raises some serious questions about whether it was mixed properly.  It might be worth obtaining a small amount of it and intentionally mixing it with too much "B" part and see if that makes it behave like yours.  If so, I'd consider lawyering up and going after the installer for the health problems.
What isocyanate does
Read the MSDS and the CDC page, but isocyanate is an immune system irritant that can cause anything from "allergy to isocyanates" to some real immune system damage if you get a major slug of it.
However, as the CDC page discusses, isocyanate is very chemically aggressive so it is also very short-lived in the environment. It really wants to hook onto "A-parts" and will grab almost anything, including water vapor.  So the isocyanates should have entirely reacted within a week or so.  It's not a vapor itself, so it won't waft down.
But if you were exposed to a lot of it due to improper mixing, that might have done some damage.
But otherwise, any long-term health problems must be caused by other chemicals - the isocyanate is gone now.
What to do about it
Don't fall into the trap of "doing what is easy instead of what is effective". If you want to stop being sick, you need to do what it takes.  You alone must decide what your health is worth.
So it sounds like somebody chiseled out the bulk of the foam material. But I presume a lot of it was in direct contact with the wood, and I gather the part touching the wood is still there.
Well, that's not good enough.  You will need to encapsulate it.

First, remove all the material you can.  I would use a wire-brush or whatever else works.  Use a shop-vac that has a HEPA filter so you aren't spreading it around even more.  Wear a dust mask yourself, preferably an N95 if you can obtain one during the pandemic.
Then, with dust removed and after a water wipe-down and letting that dry, seal the surfaces with a primer.  Now my favorite primer is - ironically - a 2-part epoxy, but it is VERY fumey.  My second go-to is KILZ Original, but that is also quite fumey, being an alkyd primer.  So to minimize environmental sensitivity I'd use KILZ 2 preferably in a low-VOC form.
Prime all surfaces that ever  had foam. I recommend 2 coats, and in any case use all the paint. Never keep old latex paint around - now with the low-VOC requirements it is very susceptible to mold and fungus - and if you think you have problems now, try stopping the foul stench of moldy paint!

You'd be working in the attic a lot. I gather it doesn't have floorboards.  Take some plywood sheets up there (cut them down as needed to bring up there) and screw them down temporarily so you have a comfortable work area and aren't having to play Spider-man across the joists carrying tools and vacuums.
Answer: Spray Polyurethane Foam (SPF) insulation systems used formaldehyde and other volatile chemicals called "isocyanates" that "cured" the foam once it was sprayed. In theory, the curing chemicals were supposed to become inert after a period of time, often listed as 24-48 hours from initial installation. Over the years this has been suspected of being wrong, and there is "outgassing" taking place for years.
That said, if the foam was removed, the small amount remaining would be unlikely to have significant amounts of outgassing taking place in a ventilated attic. The foam itself, expanded polyurethane, is considered inert; you have polyurethane on a lot of furniture, hardwood flooring, wall paneling, etc. etc. The only potentially bad stuff was the stuff that made the polyurethane get foamy.
What kind of smell is it? Formaldehyde has a vaguely pickle-like smell, isocyanates have a fruity odor to them (when strong). If what you are smelling is more like ammonia or urine, you may have rats in your attic or inside of your walls.
Comment: Isocyanates are **part and parcel of polyurethane**. They are not the foaming agent, they are *half of* the polyurethane - the "B" part specifically (it works like epoxy).  I work a lot with isocyanate based paint, which does not foam at all (unless water contacts it, then oh yeah).  If the 2 parts are mixed properly, the isocyanate is entirely consumed in the chemical reaction known as "curing".  If you're heavy-handed with the B-part, or mix inadequately, cure can finish with isocyanate left over, and then, you've got a problem.
Comment: Well, off gassing was legally proven.  The smell at first was an extremely sweet old urine smell.  Now it smells like old stinky paint, and it is a strong strong smell.  But the health issues are the same. Lips blister like a burn, gums swell, breathing issues, extremely salty taste in mouth.  No mice or rats.  I recognize that smell.  And have professionally treated property for rats and mice anyway.  The house has also tested high for acetates.  One builder told me that was from the spray foam.
Answer: We had sprayfoam done at our house, but the contractor messed up 4 ways for the installation that warranted removal of all the foam.

mixed open cell and closed cell
sprayed too thick
sprayed pure resin
delaminating from the substrates

We had an expert do the testing.
Currently we removed the foam ourselves but there still is fishy smell that lingers in the air on hot days or when we have the windows closed for too long. We will try priming using killz original to see if it will block the smell that might've gotten in the studs and wood. We will look into an ERV or whole house air exhanger.
Contractor has refused to do anything. Licensing agency has blacklisted contractor, but another agency gave him new membership.
Comment: HI this site does not work like a forum,. we expect only answers in this section.


Find duplicates in two different tabs

Question: This is what I would like to do: Tab A Column A has a mass of numbers, Tab B Column B will have numbers inputted into it. I need to have the Tab B Column B highlight showing a match to a number in Tab A or have a 'Yes' or 'No' answer appear in Tab B column A indicating a match. Any ideas how to do this?
Comment: Is this for Microsoft Excel?  If so, please add the tag for it.
Answer: I'm not sure whether you want to check for a duplicate on the corresponding row in Sheet A or whether any cell in Column A on Sheet A has the value in the corresponding row in Sheet B. I'm assuming your first sheet is named Sheet1,  the second sheet is named Sheet2, and both data sets start on the first row of their sheet.
Testing for duplicates in the entire column
Place =IF(COUNTIF(Sheet1!A:A,B1)>0,"YES","NO") in A1 on Sheet2. It will say "YES" or "NO" depending on whether any cell in column A on Sheet1 has the value in B1 on Sheet2. Drag the cell down to adjust it for more rows.
How it works: COUNTIF returns the number of cells in a range that satisfy a condition. The range Sheet1!A:A includes all cells in column A of Sheet1. They are tested for equality with B1 (which will be adjusted when you drag the cell). The IF function returns a value depending on the value of its condition, which is whether the number of cells from COUNTIF is nonzero.
Highlighting duplicates from the entire column
Added in response to a comment.
To highlight based on the presence of duplicates, conditional formatting needs to be applied. Click on the B column header in the second sheet to select the entire column, then choose Manage Rules under the Conditional Formatting button. Add a new rule with the type "Use a formula to determine which cells to format." Press the Format button to select what formatting will be applied. (Highlights can be done with the Fill tab.) Place =(COUNTIF(Sheet1!A:A,B1)>0) in the formula box, then click OK.
Testing for duplicates in the corresponding row
Place =IF(Sheet1!A1=B1,"YES","NO") in A1 on Sheet2. Again, it says "YES" or "NO" and you can drag it down to more rows.
How it works: the = between Sheet1!A1 (which refers to A1 on Sheet1) and B1 tests whether those cells' values are equal. IF functions the same as above.
Comment: Tried either, not what i was looking for. Wanted to basically have Sheet 2 Column B1 highlight if I type in the same number that was in Sheet 1 Column A:A (entire column).
Comment: @RRobertson I updated my answer, "highlighting duplicates from the entire column" should do what you want.

Find duplicates in two different tabs


Hash of a ciphertext

Question: Would hashing a ciphertext (so $H(Enc(pk,m))$) compromise it in any way if both schemes are secure by themselves? This doesn't seem to be the case but I couldn't find a definitive answer.
Comment: What raised this possibility in your mind?
Comment: Consider stream ciphers, consider what you can do if you know that the message contains some "location address to meet" at some known location in ciphertext.  Let's say you know the location and want to alter it. Think about how you can alter it in a way the receiver will still accept, i.e. Hash checking passes and all. It is difficult to do with block ciphers but not impossible based on cipher mode used and known plaintext/ciphertext blocks with same key.
Answer: No.
Any adversary could simply perform the hash themselves and so you are providing them with no additional resources.
Comment: It's theoretically possible (and very dumb) to make a custom hash function and block cipher pair such that for a single particular key and IV and a single-block message the hash's fixed IV ends up reversing the encryption, yet for all other cases each is secure alone (collision-resistant hash, IND-CPA cipher). Utterly useless, and would be very obviously a weird set of designs, but it could be a fun art project or something.
Comment: @SAIPeregrinus: Ye-e-e-es, but semantically I'd argue that it's the design rather than the evaluation of the hash that would constitute the compromise. I'd still like to come to the opening of your exhibition though.
Answer:
Would hashing a ciphertext (so $H(Enc(pk,m))$) compromise it in any way if both schemes are secure by themselves? This doesn't seem to be the case but I couldn't find a definitive answer.

I can read this two ways

You only reveal the $H(Enc(pk,m))$ to the attackers;

then the attackers need to execute pre-image attack on the secure hash function to find $Enc(pk,m)$. This can be executed with some pre-known plaintext since the key is public or can be executed with the generic pre-image attack.

If the public key is Ind-CPA secure, then the search will fail.

You will send your message as encrypt then hash $C = (Enc(pk,m) \mathbin\|H(Enc(pk,m)))$

In this case, the hash doesn't provide any authentication. Since the attacker can calculate an encryption $Enc(pk,m')$ of the message $m'$ of their choice and hash it to send on their advantage $$C' = (Enc(pk,m') \mathbin\|H(Enc(pk,m')))$$. This is vary dangerous and can have catastrophic results.

This will not reveal the original message, however, in public-key cryptography, the encryption is free therefore to mitigate either a digital signature is required to a mutual authentication like HMAC.
Answer: Note that for many encryption schemes, the cypher text is not deterministic, that is the same clear text, the same key, everything the same, can lead to different cipher text. In that case the hash code may have very little value.
Comment: The question is "would hashing a ciphertext ... compromise it". You've answered it for the non-deterministic case and you say "**in that case** the hash code may have very little value". I'm asking about the other case, which your answer seems to indicate is different.
Comment: This begs the question: if the ciphertext generation **is** deterministic, then what information is leaked by hashing it (and under which conditions?)
Comment: What makes you think that the hash is leaking information, @MaartenBodewes? Don't know all hashes, but at least the SHA-hashes should leak any info. (Whether the ciphertext is deterministic or not.)
Comment: What kind of value does this hash need to have and why

Hash of a ciphertext


javascript created choice field values wont save

Question: Im using jquery and getJSON to populate a drop down list based on user input in a custom modified NewForm.aspx. The dropdown populates just fine but when the form is saved the selected choice value is not saved. Ideas?
Thanks
Answer: Without seeing your code it's difficult to pinpoint it exactly. But at a high level, the selected value in the generated drop down needs to be pushed to a hidden list field so it can be submitted and saved.
Comment: Thanks Pirate, That is what I am figuring out. Can you access/update the hidden field list with just jquery or do you need to use the SP COM for js? Also how do you find the hidden list? Thanks for your time
Comment: You can use jQuery for that so long as you get the right selector for your form field.
Comment: Anyway to find the corresponding hidden field? A lookup field will have an optHid attribute that gives the id of its hidden field but the choice field does not have one. I did a search on the html output on all the input type='hidden' and could not find anything.


Why we needed to relate internal resistive forces with area (stress)?

Question: When we load a body, say a prismatic bar, axially, internal resistive forces are developed within it to oppose the elongation or compression. What was the need of relating these internal resistive forces with area to define a quantity like stress. Wasn't these internal resistive forces enough?
Comment: Can you clarify your question? It's not clear what you mean by "enough." Or are you asking why we sometimes analyze a problem in terms of forces and sometimes in terms of stresses?
Comment: Probably because we are concerned about the size of things, long gone are the Victorian values of made it so it lasts (nearly) forever, now we have the age of the accountant - how cheap and minimum material.
Answer: A good reading about that is the:  History of strength of materials by Timoshenko.
It describes the history behind Galileo Galilei and Hooke until the era of Cauchy, and the intermediate steps
Galileo (sometime between 1592 and 1610) figured out that for tension, when you double the cross-section the load to break also doubles. But run into problem with Bending (second moment of area wasn't "invented" by then.
The story fast forwards to Hook (1678) (there are a few mention for Euler and others). Hooke realised that every material essentailly behaves as a spring. Therefore the greater the displacement the greater the force in a component.
$$ F= kX$$
However, Hooke never really tried to decouple the Geometry from the material. And nowadays we know that the spring constant k can be derived (at least in an bar of isotropic material ) from:
$$K = \frac{E\cdot A}{L}$$

K is the spring constant
E is the Young's modulus (material)
A is the cross-section  (geometry)
L is the Length. (geometry)

This discovery is really important because by decoupling the effects its possible to predict the behaviour more easily. If a different material is selected then you only need to change the modulus E. If you double the cross-section then only A needs to change.
Young "patented" the Youngs modulus (in 1807) (although Leonard Euler had conceived it already in 1727).
Finally, 200 years after Hooke, Cauchy in 1820s proposed the idea that you can divide the force by the cross-section to get a quantity representative of the material.
(I'll refresh my notes and come back to this when I get my hands on the book).
Comment: The most complete history of the development of these ideas that I've come across is "Mechanics of Solids: Volume I: The Experimental Foundations of Solid Mechanics" by J. F. Bell (1973).  It's a shame that this work is not easily available.  https://www.springer.com/gp/book/9783540131601
Answer: First courses on engineering statics tend to start from the forces where the structure is loaded and constrained, and at the interface between components, because in simple situations (for example statically determinate structures) the forces can be calculated independently of the internal stresses in the structure. The stresses can then by found (approximately) from the forces.
However in general the stress and strain distribution is are more important. As a simple example, consider a rectangular plate of material with tensile forces applied to each end. You can easily calculate the average tensile stress as "force/area".
However, consider what happens if there is a hole cut in the bar for some reason. Assume there are no forces applied around the circumference of the hole.
It should be obvious that the stress in the material near the hole will change in some way, and the change might be important. In fact, for a single small hole, the maximum stress is increased to 3 times the average stress. For a larger hole comparable with the width of the bar, or for several holes close together, the stress pattern is even more  complicated.
Another example is a rectangular section cantilever beam. You can calculate the approximate stress distribution in the structure by finding the applied loads and moments and then, making some assumptions about the deformed shape of the beam.
For many purposes those assumptions are good enough, but in fact they are not even self-consistent. For example, suppose you know the material has non-zero Poisson's ratio (because you have measured it, not from some theoretical argument!). When the beam bends, you assume there is an axial tensile stress on one surface and a compressive stress on the opposite surface.
Therefore, because of Poisson's ratio, the width of the beam on the surface with tensile stress will decrease and the width on the opposite surface will increase. That means the beam section is no longer a rectangle, and in fact it is curved from one side to the other.
Google for "anticlastic curvature* for pictures - for example https://www.researchgate.net/figure/The-phenomenon-of-anticlastic-curvature-arises-from-Poisson-effects-When-a-beam-is-bent_fig4_11057987
Again because of Poisson's ratio, the volume of the material in tension is different from the volume in compression. Therefore the neutral axis of the beam is no longer at its geometrical center when the beam is bent.
Also, because of the shear stress through the depth of the beam, the assumption that a plane section remains plane is also false, and in fact the original plane section deforms into an S-shape viewed from the side.
None of this could be calculated just by considering the forces applied to the beam and then working out the "average" stress in the material.
Answer: In the mechanics of material, the most important strength parameters are measured and expressed in terms of "stress" rather than force.
For instance, the "yield" strength of a Grade 60 steel is 60 ksi, which is a well-known standard in the engineering community. However, how much force a piece of grade 60 steel can sustain at yield is unknown until the area is made known, that is $F_y = f_y*A$.
For your case, if the steel bar has a cross-sectional area of 1 in^2, and it is stretched by a tension force of 50 kips, will it yield if the bar is made of 1) grade 60 steel and 2) grade 40 steel? In addition, if the bar is 3' long, what is the elongation of each case?
The general equations for stress and deflection are $\sigma_a = F/A$, and $\delta = \dfrac{PL}{EA}$, respectively.
$1)$ For grade 60 bar, $f_y = 60 ksi > \sigma_a = 50 kips/1 in^2 = 50 ksi$, thus the stress is below the yield point, more load can be applied before the bar begins to yield.
For steel, the "Young's Modulus (E)" is 29,000 ksi, so the elongation of the bar:
$\delta = \dfrac{50 ksi*3 ft*12 in/ft}{29000 ksi*1 in^2} = 0.062"$
$2)$ For grade 40 bar, $f_y = 40 ksi < \sigma_a = 50 kips/1 in^2 = 50 ksi$, thus the bar has stretched beyond yield. For such condition, the general equation can't be used to calculate the elongation, since the Young's Modulus ($E = \dfrac{\sigma}{\epsilon}$) is valid in the elastic range only
Hope this explains why the area of an element is required in defining the strength of the element.
Comment: "For most of the metals, the "Young's Modulus (E)" is 29,000 ksi," - only for steel alloys. Other engineering metals (aluminum or titanium, alloys etc) have very different values for E. Not to mention non-metals used in engineering, like plastics, ceramics, etc.
Comment: @alephzero Agreed. But I think to be precisely correct, you should leave the last sentence out unless you misunderstood the plastics and ceramics are also "metals". Can I assume you are not?!


What is the correct way to tell if a screen is compatible with my laptop?

Question: I have an old IBM thinkpad Z61t, and I want to upgrade the screen to one from an even older Toshiba laptop.  The screens are both very different sizes, and probably different resolutions, but the same aspect ratio (16:9).  The connectors are all the same and it plugs in just fine, but I haven't booted it up yet because I don't know if its a good idea.  I don't know whether or not it'll work, and I don't want to risk wrecking the screen.  I do know a bit about hardware - I've completely dissected a number of laptops and scavenged parts to build one that's better than any of the original ones were, so I do know what I'm doing.  I'm just wondering if it'll work, and, if not, what the worst that can happen would be.
Comment: This a serious question?  If the screens are different sizes, even if the connectors are the same, how do you expect to use the laptop if the physical size of the display cannot be mounted in the laptop?
Comment: I don't care about the size or whether or not I can close my laptop, I'm just wondering if its compatible
Answer: It should work - and if it doesn't, the screen just won't turn on.
Computers query the resolutions of monitors to negotiate the best possible resolution supported by the monitor (even for VGA connections - using EDID).   EDID predates your laptop.
Unless you specifically override the negotiation, the screen can't be damaged, and even then, its most likely a modern screen will handle it - either by not turning on or by scaling the content.
Comment: It works! :) Although, as Ramhound stated, it doesn't fit in the laptop casing, so using it is a bit of a hassle.