Tensors as multilinear maps

Question: Sean Carrol's in his book on GR introduces tensors as a multilinear map of a set of dual vectors and vectors onto R. I usually think of tensors as a multidimensional array of numbers with fixed transformation laws, and I am having trouble understanding how tensors could be a multilinear map of a set of dual vectors and vectors onto the set R. More specifically, I am having a hard time understanding the concept of a multilinear map.
Comment: Related: http://physics.stackexchange.com/q/32011/2451 and links therein.
Answer: First you must understand the idea of a linear map. To understand this, you must understand linearity. We say that an operation $O$ acting on a set of elements $\{v_n\}$ and scalars $a,b,...$ is linear if
$$O(av_1+bv_2)=aO(v_1)+bO(v_2)$$
Say we have some other map $E$ that takes two arguments. $E$ has two "slots". Each slot is linear. This is the idea of multilinearity.
Now why are tensors multilinear maps? You probably learned in an undergraduate setting that tensors are objects whose components transform a certain way under a change of coordinates. In a more rigorous text (Carroll is an introductory graduate text), we define tensors differently. Let $V$ be a finite dimensional vector space and let $V^*$ be its dual. A tensor, $T$, of type $(k,l)$ over $V$ is a multilinear map
$$T:\underbrace{V\times\cdots\times V}_l\times\underbrace{V^*\times\cdots\times V^*}_k\longrightarrow\mathbb{R}$$
In other words, $T$ is a machine with $k+l$ slots. You plug in $k$ vectors and $l$ covectors and get a real number (this definition can of course be extended to $\mathbb{C}$). It is fairly obvious that the set of all $(k,l)$ tensors, $\mathcal{T}^k_l$, is a vector space. If the manifold is of dimension $n$, then $\operatorname{dim}\mathcal{T}^k_l=n^{k+l}$ (Wald p.20). You probably know that $\{\partial_\mu\}$ forms a basis on $V$ and $\{dx^\mu\}$ forms a basis on $V^*$. (I have read Carroll, but I skipped the math in the first few chapters because I already knew it. Thus I'm not 100% sure what he covered.) Thus $\{\partial_{\mu_1}\otimes\cdots\otimes\partial_{\mu_k}\otimes dx^{\nu_1}\otimes\cdots\otimes dx^{\nu_l}\}$ is a set of $n^{k+l}$ objects that forms a basis on $\mathcal{T}^k_l$. Just as we expand a vector in terms of its components $X=X^\mu\partial_\mu$ and a covector in terms of its components $\omega=\omega_\mu dx^\mu$, we expand $T$ in terms of its components as
$$T=T^{\mu_1\cdots\mu_k}_{\nu_1\cdots\nu_l}\partial_{\mu_1}\otimes\cdots\otimes\partial_{\mu_k}\otimes dx^{\nu_1}\otimes\cdots\otimes dx^{\nu_l}$$
However, the above definition of $T$ as a multilinear map did not reference coordinates, let alone a basis. Thus $T$ should be a coordinate independent object. We know from calculus how the partial derivatives and differentials that form our basis transform. Convince yourself that we recover the standard tensor transformation requirement by demanding $T$ be left invariant by a coordinate change.
Comment: Thanks for this answer. I have not actually studied tensors or physics in the undergraduate level, though I have read the Feynman lectures and done the corresponding problems.
Comment: Does this answer your question? I just skimmed pages 63 to 69 in Carroll, which says what I just said with more words and some proofs in between. EDIT: Thanks, I guess that answers my question.
Comment: This answers my question, though I am still on page 24 in Carroll.
Comment: I see. Let me try to clarify something. I will show that the definition of a tensor you are currently more familiar with is compatible with the more abstract definition. Let $\omega_\mu$ be the components of a covector and let $v^\mu,w^\mu$ be the components of vectors and $a,b$ be scalars. You of course know that $\omega_\mu(av^\mu+bw^\mu)=a(\omega_\mu v^\mu)+b(\omega_\mu w^\mu)$. This is just the abstract statement that $\omega:V\longrightarrow\mathbb{R}$ is a linear map written in a simple notation. This directly generalizes to arbitrary rank tensors.
Comment: When you have mastered Carroll, if you still want to learn more GR, go with either Weinberg's G&C or Wald's GR. Both are listed in the back of Carroll. Once you finish Wald, go on to Hawking & Ellis. Once you finish Weinberg (1972), go to Weinberg (2008). If you really hate life and want to get headaches every equation, read Straumann. But be prepared to get an amazing understanding of the mathematics of GR. Hawking & Ellis does a pretty good job of this too, but makes little to no contact with experiment.
Comment: Thanks for the extra info. I definitely want to have a comprehensive understanding of GR because it is so fascinating.
Answer: Being a multilinear map and being an array that transforms a certain way aren't really very different.
For instance, if a dual vector $\omega$ sends a vector $v$ to the number $1$, then $\omega(v)=1$.  Since the dual vector $\omega$ is linear, it can be fully specified by saying what it does on the basis vectors $\omega_1=\omega(e_1)$, $\omega_2=\omega(e_2)$, etc.
And if $v$ can be written as a linear combination of the basis elements $v=v^1e_1+v^2e_2+ ... v^ne_n$ then $\omega(v)=1$ is the same as $v^1\omega_1+v^1\omega_1+v^2\omega_2+... +v^n\omega_n=1$.  You can think of the vector as a column vector and the dual vector as a row vector, and the action of one on the other as the normal 1xn times nx1 matrix multpilication.
Now lets get to transformations.  If the components of the vector transform in a certain way say by left multiplication by a matrix $T$, then we can make the dual vectors transform by right multiplication by $T^{-1}$.  Then the action of a dual vector on a vector will give the same number.  So if you say that a dual vector is a linear map of vectors, then it's just a function so it doesn't care about a basis, and with these transformations it now doesn't care.
For multilinear functions you now need more that n numbers, so multidimensional arrays of your basis elements to fully specify the function.  But now you want each one to transform according to the same rules so that the action (as a function) become insensitive to whether or not you changed the basis.  The idea is the same, just writing it is harder.

Tensors as multilinear maps


What features do basic particle engines have?

Question: I created a basic particle system for SDL in C++. It has some basic stuff like an emitter, as well as a simple particle class. It can load a image, or create a dot of a color. And that's it. What other features do most simple particle engines have? Keep in mind this is a 2D particle engine.
Comment: Remember that all your great features won't matter if you don't make your tool usable by artists.
Comment: Use google: http://en.wikipedia.org/wiki/Particle_system
Answer: This is a very broad question, but generally particle system features can be broken down into a few categories.  Here are some general ideas for the sorts of things you might want to have.
Emission features define how, when, and where particles are emitted.

Continuously generate particles at a fixed rate, or generate a cluster all at once when triggered by some in-game event.
Place newly-emitted particles at a point, or randomly within a region, such as a box or circle.  The point or region could be moving, e.g. attached to an object or  character.
Emit particles at a rate proportional to the velocity of a moving object, which can be useful for smoke trails and suchlike.
Give the particles a random initial speed and direction, within certain ranges.  For example, an explosion would send particles in all directions while a cannon would send them in the direction the cannon is pointing.
Optionally have particles inherit velocity from their emitter, when the emitter is itself moving.

Motion features control how particles move after they're emitted.

Gravity or buoyancy makes particles sink or rise.
Collision detection can be used to make particles respect walls, either by flowing along them or bouncing off.
Air drag causes fast-moving particles to slow down.
Particles also might move along a spline defined by the designer, or be attracted to a particular point or region (possibly attached to an object or character), etc.

Rendering features control how particles look.

You almost certainly want to have the particles change size, color, and alpha as they age.  Animation curves can be defined to control these.
For a 2D game, the Z-order of particles relative to other game objects should also be controllable.
For sprite particles, you might like to have the sprite rotate.  It could spin at a random speed, or rotate to face its direction of motion, or the direction its emitter was moving when it was emitted.
Also for sprite particles, you might want to have it run through a sequence of animation frames.

These are just a bunch of general ideas.  For your specific game you might only need a couple of these, or you might need other ideas that aren't on this list.
Comment: Add two more ideas: if you render the entire lifetime of the particle, you can get *static particles*, which can be used to generate hair or grass; let emitters generate emitters as well as plain particles - you can create some interesting explosions by generating debris which in turn generate smoke trails.
Comment: +1 This is exactly the feature list of my particle engine implementation. Later on, you might want to add some extras, like emitting along a line (for laserbeam effects),  or circle (a spaceship's shield, for example).
Comment: Awesome list! Really comprehensive. +1
Answer: Watch this video for some ideas that you can add to your system, in particular modifiers, which can be used to interpolate particle properties over time, such as color or opacity, or to apply complex gravitational forces to the system. These are often enough to create some really cool effects, when combined with a basic particle emitter.
Afterwards, you might want to check the documentation of some existing particle engine to see what else they provide. The first one that comes to my mind is the Mercury Particle Engine, which also seems to be built around the concept of particle emitters and modifiers. Give it a test drive and it should be enough to answer your question.


If I get to Kingsparrow Island with low chaos, can I go buckwild and kill everyone without ruining the ending?

Question: I've gotten to Kingsparrow with low chaos. Has the game stopped caring about chaos at this point, or will going on a murder spree tip the scale and wreck my ending?
Answer: No, going on a murder spree at this point will no longer affect the game.
Whatever happens in the mission is determined prior to loading the level (this is why the maps are also identified by the chaos level associated). The ending cutscene, then, is determined by the choices made in the final mission - therefore also unaffected by your changed chaos level.
Comment: Thanks! Time to go Helter Skelter on the hardworking watchmen of Kingsparrow Island.


Windows PowerShell ISE running old version

Question: I'm writing my PowerShell scripts with Windows PowerShell ISE. When I change someting in the script and run the script, not the last saved version of the script is executed but the older one. Only if I run the script a second time it uses the current version. What can I do to always run the newest version of the script?
Answer: This is a very old question, but I think I've stumbled across the same issue. In my case I've defined a function after invoking it. It appears to work, but only because "myfunc" still has the value from the previous invocation. If you change "Hello, World!", you'll find that the new value takes affect only on the second attempt.
Invoke-Command -ScriptBlock ${function:myfunc}

function myfunc() {
    Write-Host "Hello, World!"
}

To resolve the issue, simply define the function before you attempt to call it.
function myfunc() {
    Write-Host "Hello, World!"
}

Invoke-Command -ScriptBlock ${function:myfunc}

Comment: Ha amazing clearly a hiccup for people spending all their time in compiled languages.
Answer: After making an edit, you need to source the script again by dot sourcing it.  Assuming you have a file named MyScript.ps1 in the current directory, in the console you run the command below:
. .\MyScript.ps1

If you want to call a specific function in the script then you can just do:
. .\MyScript.ps1
MyFunction

Answer: My experience with ISE "caching" of old files:
The behaviour of ISE is different for PS modules ( .psm1 ) and simple PS scripts ( ps1 ). I am using PS&ISE with Win10Pro.
A)
My experience with modules ( . PSM1 )

Load a module file "hello.psm1" already placed in a proper module
directory
"C:\Users\MyUserName\Documents\WindowsPowerShell\Modules\Hello" by
ISE
Execute a function by "Run Selection" ( you may not execute
modules by "Run Script" )
Modify the file, e.g. the output of the
function 'Write-Host "Hello World!"' to 'Write-Host "Hello"' and save the
file.
Execute a function by "Run selection", and it will execute the
old function, with old output, e.g. "Hello World!". This is also true
if I repeat the "Run Selection" command.
Just if I leave ISE and load it again, the new function is executed by "Run Selection".

B)
My experience with scripts ( .PS1 ).

If I execute "Run Selection", the same behaviour as with modules.
If I execute once "Run Script" and by that the function is called, the current version of the function is executed. Of course I call the function ( e.g. on line number 100 ) in the file "after" it is defined ( e.g. in lines 10-20 ). By this, there is no caching.
Especially and consequently, if I execute once "Run Script", while the executed code doesn't call the function, and then execute my function by "Run Selection", the current version of the function is executed.

C)
Here is my workaround to make module development more comfortable:

Simple scripts may be executed by "Run script".
If I want to develop a module ( .PSM1 ), I name it as simple script ( .PS1 ) during the development phase. I place the file ( e.g. "hello.ps1" ) already in
the proper module folder, e.g. "C:\Users\MyUserName\Documents\WindowsPowerShell\Modules\Hello" for a module "Hello". Of course by this I can´t execute the functions as module functions from PowerShell console. I just want to use ISE to call functions for testing.
As modules are not executed as script, there is no executable code in the file, but just functions ( AFAIK ). So I may safely execute a "Run Script" on my script.

So if I modify a module file under ISE development, I always first execute "Run Script", before I execute a function by "Run Selection".
By this I always execute the current version of a function.
Though my problem was a little bit different, this question and the answers were very helpful for me to find a solution. It is hard to find such questions about ISE "caching" and so helpful answers.
Sincerely
Rolf


How do you pump Creosote Oil out of a Coke Oven

Question: My Coke Oven has about 30k's worth of Creosote Oil, which I want to store in a tank, but I cannot get it out. I've tried putting Fluiducts all around it and it doesn't come out at all. Is there something special I need to do to get the oil out?
Answer: As said in the Feed The Beast wiki, you can take the creosote oil out with a bucket. Here's the quote:

Placing a Bucket in the Coke Oven's inventory (on the right) will fill the Bucket with Creosote Oil. Wooden Waterproof Pipes can also be used to take Creosote Oil into Tanks. The Coke Oven will not function if the inventory of the Coke Oven is full with Creosote Oil. Each time a coal is burned to produce a Coal Coke, 500 mB (half a bucket) of Creosete Oil will be produced.

If you absolutly want to use a pipe to get it out, you need to use Buildcraft pipes, otherwise it wont work.
Here is a video tutorial explaining how you can do it.
Answer: Just now discovered a way to do this without any extra mods, like BuildCraft:

Place a pump adjancent to the place you want the oven to be; do not place the oven itself yet. It won't require power, so don't bother with connectors.
Use the Engineer's Hammer once on the pump on the side where the oven will be. It will turn blue - it's the input side now.
Use the hammer again on any other side, twice. It will first turn blue, then orange - it's the output side now. You may now place fluid pipes here and stretch them to whenever you want - tanks work perfectly for that purpose.
Build the actual oven and activate with the hammer, as described on it's page in the manual.
Supply the pump with a redstone signal - placing a lever on it and toggling it on will suffice.

Done! The creosote oil is now going to whenever you want it to. Placing the pump first was necessary because later the oven would obstruct its clickable side.
Hope that helped. :)
Answer: Things to check:

Were the fluiducts set to extract?
Were they powered by redstone?
were they set so that redstone enabled them, or were they set so the redstone disabled them?
Answer: I have pumped creosote oil from the left and right sides in several packs.  I've used Fluiducts, Buildcraft waterproof wooden pipes and EnderIO Fluid Conduits.  Never had any problems.  The problems come when the tech you are using isn't configured right.
In your case your Fluiducts would need to be set to extract.  Basically hit the bigger part attached to the side of the Coke Oven with a wrench or crescent hammer until you see an arrow head facing away from the oven.  This is explicit extract mode.  Then you either need to install a Pneumatic Servo and configure it to ignore redstone, or you need to place lever below/above the arrow on the pipe and turn the lever on.  A redstone torch would do the same thing.
Answer: On the advanced coke oven, the liquid pull point  is the hole at the bottom of the large plate.  A servo and some fluiducts will draw the creosote out.


WannaCry attack

Question: The kill switch discovered by marcus hutchins the web security researcher, how did that kill switch actually work? ,domain name registration must have been done on the system of researcher , how did it prevent it's beacon to every other computer (this happened or not?)
Comment: a lot has been written on the kill switch - have you performed some research first before posting here?
Answer:
domain name registration must have been done on the system of researcher

No. The domain was actually registered and is available to everyone:
<code>~$ whois iuqerfsodp9ifjaposdfjhgosurijfaewrwergwea.com
   Domain Name: IUQERFSODP9IFJAPOSDFJHGOSURIJFAEWRWERGWEA.COM
   Registry Domain ID: 2123519849_DOMAIN_COM-VRSN
   Registrar WHOIS Server: whois.namecheap.com
   Registrar URL: http://www.namecheap.com
   Updated Date: 2017-06-22T16:05:38Z
   Creation Date: 2017-05-12T15:08:04Z
   Registry Expiry Date: 2023-05-12T15:08:04Z
</code>
The malware will try to connect to this domain. If it succeeds, it will abort, otherwise it will continue.
The researcher who registered the domain explains it here.
In his research, he first entered the domain in his host file, and after seeing that it stopped the malware on his local system, he registered the domain, thus preventing this specific version of the malware from doing harm on any system that could connect to the domain (this was actually more of an accident, the researcher originally wanted to collect further information on the malware).
The researcher also guesses at what the malware writers wanted to achieve with this "kill switch":

In certain sandbox environments traffic is intercepted by replying to all URL lookups with an IP address belonging to the sandbox rather than the real IP address the URL points to, a side effect of this is if an unregistered domain is queried it will respond as it it were registered (which should never happen).
I believe they were trying to query an intentionally unregistered domain which would appear registered in certain sandbox environments, then once they see the domain responding, they know they're in a sandbox the malware exits to prevent further analysis.
Answer: It worked because the code checked that the domain didn't respond to a connection. When he hooked it up to a server it responded causing the code to exit.
In other words when the domain was online the code didn't complete its execution.
As a side note many researchers do not believe it was a kill switch and was possibly a way for testing if it was in a sandbox.
Comment: How does no response imply not a sandbox?
Comment: Other way around. Many sandbox environments used for testing malware use a fake server and dns to respond to queries so the researchers can see what data is being sent and received.
Comment: the code should have exited from the system where the domain name registration was done, how did it prevent any further attack, other systems which were infected were also beaconing?
Comment: "the code should have exited from the system where the domain name registration was done" - Nothing to do with if it was registered or not. "how did it prevent any further attack, other systems which were infected were also beaconing?" - Don't understand the point. As @schroeder says have you done any research? There are 1000s of articles explaining how it worked in various depths. Some very good ones  :)
Comment: it's given that he registered a domain name, why we have nothing to do with that stuff?, the point is how did it prevent other systems from spreading the virus further because on those system domain name registration was not done ; i have done some research but was not able to get the exact point as these things are new for a unaccustomed student like me

WannaCry attack


'I came' vs. 'I went'

Question: I was recently speaking to my friend over the phone. She asked about the whereabouts of my other friend, to which I replied "I don't know. I went home already." (Keep in mind that while saying this, I was already at home. After hearing this, my mother proceeded to comment on my incorrect grammar in the above dialogue. I was just wondering if 'I came back home' should be used instead of 'I went back home', and if the latter is grammatically incorrect in my situation. Thank you for answering.
Comment: Your mother is incorrect. Your statement is perfectly grammatical, logical, and idiomatic. Some languages use their equivalents to the verbs _come_ and _go_ strictly based on where the speaker is located at the moment of utterance; English is not such a language. In English, the relevant location can be any location that is clear and within the scope of the current conversation—whether it's the present or past location of the speaker or the listener, or somewhere else entirely.
Comment: Come on: If you are at home, you say: I don't know, I'm already home. OR "I've already come home. **Your mother is right**: **I went home already** is wrong. Only it is not the grammar, it is usage for go and come.
Comment: 1. Are you a native speaker, (i think you are) or/and is your mother also? 2. Where are you from? 3. Which English dialect do you speak, e.g. American, British, Australian, etc. ?
Comment: IMO latter reveals your current location[home] and the first one doesn't
Comment: Even 'He went home already' sounds odd to my British ears; I'd expect 'He's gone home already'.
Comment: @EdwinAshworth Unfortunately, already and PP is a lost art.
Answer: In general you "come here" and "go there". As "went" is the past participle of "to go" I can see your mother's point. However, in my idiolect (I'm a native British English speaker) what you said sounds completely normal to me.
I think in "go home" from work (/school etc.), the focus is on leaving work rather than arriving at home. Hence it is "go {somewhere} from work" rather than "come here {from work}".
Comment: "I went home early" is likely the more idiomatic phrasing in the US, since it reflects that the decision to leave was (presumably) made at the site of this activity, vs having been predetermined or some such.  As such it more properly reflects the historical narrative.
Comment: @HotLicks That is completely inaccurate. If I am home, I would never, ever say: I went home early speaking on the phone. IF however, I was seeing the person outside my home, I would say: I don't know because yesterday I **went home early**.
Comment: @Lambie For once we're in total agreement (assuming 'outside my home' = 'still quite a long way from home').
Comment: @EdwinAshworth But I am sure some noble soul will disagree. :)
Answer: It really just depends on the frame of reference that you intended at the time of your statement.
If your point is that you were not in a viable location to be able to answer the question, ie. if you want to highlight the fact not only is your present state inadequate for answering the question, but it's been that way for some time so there's no way I can answer your question in good faith...then you nailed it.
A simpler analogous method to choose which one more precisely iterates the idea you wish to convey is:
Did you picture the place your friend still thought you were?
Or did you picture or actually look around at your contemporaneous environment (inside your house) while formulating your response?
In this latter case, the second one would be the more suitable.
Answer: The question has nothing to do with grammar: the sentence does not, even arguably, violate any rule of English grammar. It also has nothing to do with truthfulness: the sentence was obviously true at the time of its utterance. The question is a matter of pragmatics.
If your mother's objection were fully developed, it would probably be that 'I went home' does not convey whether you are still on your way or have already arrived, which makes it less informative than 'I came home'. Usually, she might argue, we don't choose a less informative expression when a more informative one could be used with the same amount of effort.
In your defence, you can argue that the extra information conveyed by 'I came home' would be distracting given the overall purpose of the communication. It is irrelevant to your point whether you are home or still in transit; the only thing that matters is that you have left the place where your friend might be. The communication is focused on that place, and 'I went home' arguably fits that focus better than 'I came home'.
Answer:
I replied "I don't know. I went home already."

It is the tense that is wrong. You are referring to your [lack of] knowledge about your friend. You intend to say "I don't know what happened to him, I had already gone home."
Thus "I don't know. I had already gone home [at that time]."
The past perfect is correct as it refers to a completed event in the past that gives context as to why you do not know.
Answer: go and come are about directionality and location of the speaker.
It is not about grammar, it's about pragmatics.
If I am home: I say on the phone to someone.

I've come home or I am home now.

If I am not at home: I say:

I'm going home now.

If I am not at home and speaking to someone about go + home, I say:

I went home at lunch time and came here afterwards.

Direction and the speaker:
If you are moving or have moved away from the place where you are, you use GO (away from it).
If you are moving or have moved to the place where you are, you use COME (to it).
And if you are at home and say went home, you are a dodo bird.    Because, really, you went to work or school or the office or the store and you then came home.
In short, if I am at home and say: "I went home" to someone there or on the phone, I'm a real dodo bird.
The same is true (in formal terms) of bring and take. Now, I shall be not going into that one here but am interested to see who can guess the most misused one (bring or take), which, has now been absorbed into the American idiom so thoroughly you need a special tool to remove it. [by the way, that is a joke]
And by the way, the same is true in French, Spanish and Portuguese.
venir/aller
venir(se)/ir(se)
vir/ir
You would never say on the phone to a person, if you are at home:
Je suis allée chez moi tôt aujourd'hui. [go]
You would say:
Je suis venue [ou rentrée] chez moi tôt aujourd'hui. [come]
Comment: I think it differs more on perspective. If Mom, who's home, asks you what you did, you can say "I went to school, then _came_ home", because you're talking to someone who is at the current location in question. If Mom, who meets you at the barber, asks you what you did, you can say, "I went to school, then _went_ home", implying that neither you nor the person you are talking to are at the mentioned location.
Comment: @williamfakespeare Yes, of course. In one, Mom is at home and in two, she isn't. Her location in the first instance is home and her location in the second is the barbershop. The barbershop is a location, too.
Answer: I am also confused. A European friend texted me today and said my family went to me today. It obviously doesn't not sound right and I corrected her by saying my family came to visit me. So I think her location is important unlike what I read above. They went to my house vs they came to my house is entirely dependent on one's location.
Comment: **You say to him/her**: "My family came to visit me", but **she** could correctly say: **Your family went to visit you today, right?**
Answer: You're using the past to answer in the present and that's where the issue is.  I would suggest that your answer should have been "I don't know, I'm at home/I'm back at home now".
If you were talking the next day however and were asked "when did Katie leave Sarah's?" you could have answered "I don't know, I'd already come/gone home", depending on your location either at home or not when having that specific conversation.
Hope that's helpful!

'I came' vs. 'I went'


Web3 Schema Update

Question: I understand that web3 smart contracts are decentralised and the code once written cannot be updated. They are immutable. Imagine my app stores user profile in a smart contract. It has name in it for now. Let's say we want to update the smart contract and now it takes not only name but also profilePictureURL. How do I go about it?
In a traditional web2 setup, I would run migrations or update the schema for the table.
How do things happen in web3 for updates in smart contract schema?
Thank you
Answer: Immutability doesn't mean you can change the data inside, it means you can't change the code.
To change the name you need to include a setter function.
For example:
<code>string name = NaMe;

function changeName(string calldata _name) external {
      name = _name;
}
</code>
Now if you didn't include this function before deployment, then that's a problem as the code is immutable.
Comment: Hey Thanks for the reply. I understand that we can store data in a smart contract. However, the question is how can I change the state variables of the contract. Like adding a new state variable in the smart contract. What's the strategy there?
Comment: No, you can't add new variables in a smart contract. You can only modify the existing. One way to add more variables is having upgradeable proxies, but those come with a higher risk of attacks.
Answer: To update contracts you can consider upgradeability in contracts
Refer this: https://docs.openzeppelin.com/contracts/4.x/api/proxy#ERC1967Proxy
This way you will be able to add new functions and state variables to the same contract without redeploying.
But you have to be careful about this approach, as you cant remove already initialised states & add new states at the end to maintain the storage.
If you are using hardhat... this should help: https://docs.openzeppelin.com/upgrades-plugins/1.x/writing-upgradeable
Also u can ask here to other solidity devs, they are very active - https://t.me/blockchainworldCo

Web3 Schema Update


Is it safe to change max_execution_time?

Question: Is it safe to change max_execution_time to something like 300? Why magento 2 need this gigantic max_execution_time (18000 = 5 hours) first place?
Answer: Yes you can you need to increase  execution time so that magento can interact  with database  easily. It required  increment because magento also run many heavy task in background like: product import and export, backup creation, backup roll back and many more so in order to make all process smooth we increase  execution time in php.ini file.
If this reply helpful please accept it as solution thanks.
Comment: This makes debugging very hard. I think, Lets say I have some infinite loop in my code which trigger at some random event. With this max_execution_time cpu rises up to 100% and stuck.
Comment: Yes it make debugging hard but also see the positive part that it makes execution faster and won't occur run time error due to less memory provided. Now if i talk about infinite loop then its different thing the reason it consume 100% cpu and stuck because as we know that tasks are executed according to their priority and when our cpu encounter an infinite loop then it dedicate its full resources to that task and other task get into pending and our cpu get confused that which task it should execute next that is why it stuck.. Please accept it as solution if this reply is helpful thanks.
Comment: I know why cpu consume 100%, max_execution_time there for to avoid such a incident. I think having this much execution time for each task is bad, They could've  default set max_execution_time to something smaller and set exclusively high value when necessary. Anyway I accepted your answer


What should I cover the ground in my garden with?

Question: I have not covered my garden all winter, did not know I was suppose to until now. I am ready to plant my garden but want to know best way to prepare the soil and should I cover garden with bark? I am beginning a compost pile now
Comment: What's your climate like (or where is it)? What are you wanting to grow? What kind of soil is it (sandy, clay, loam, clay loam, silt, caliche, etc.)? Have you had a soil test (fertility and pH)? Where did you hear you were supposed to cover your garden? What's the reason for it? Is it necessary in your area or is it something that just improves matters in a certain way somehow?
Comment: I 'm also surprised about the "you are supposed to cover" statement. Please [edit] your post with details, thanks! And: welcome to Gardening SE! The [tour] and the [help] will tell you more about how the site works.
Answer: Margie, I think I know where your going with this.In the fall,I generally leave the leaves in the flower beds.I think it helps protect the plants in case of a really hard winter. In the spring I clean them out real good then mulch. Depending on what you are planting, check with a local garden center and they can give you some ideas. You may want to amend the soil,(put nutrients back),your compost may take a while so,get some over the counter fertilizer if needed. Happy Spring!


Anticommutator of spin-1 matrices

Question: We know that in the spin-1/2 representation the anticommutation relation of the Pauli matrices is $\{\sigma_{a},\sigma_{b}\}=2\delta_{ab}I$. Does a similar relation hold for the spin-1 representation?
Comment: Related question: [Is there an anticommutator relation for orbital angular momentum?](https://physics.stackexchange.com/q/454715/)
Answer: Of course not, in general,  as the anticommutator is in the universal enveloping algebra: it is not even in the Lie algebra augmented by the identity, as evident in the specific example below.
For the spin 1 representation of the algebra, $J^a_{~~bc}=-i\epsilon_{abc}$, consisting of hermitean, imaginary, antisymmetric 3×3 matrices, i.e. the  adjoint representation, it is straightforward to compute all anticommutators explicitly,
$$
\{J^a,J^b  \}_{mk}= -\epsilon_{amn}  \epsilon_{bnk} -\epsilon_{bmn}\epsilon_{ank}= 2\delta_{ab}\delta_{mk} -(\delta_{am}\delta_{bk}+\delta_{bm}\delta_{ak}).
$$
You then see the r.h.s. are symmetric real matrices.

For $a\neq b$, they are traceless off-diagonal ones;
For $a=b$, they are diagonal, traceful ones, but with a 0 in the ab entry.

Anticommutator of spin-1 matrices


Short story about creating a fake alien to scare people into cleaning up Earth

Question: Earth has a serious pollution problem. Story is about a small group (couple?) of humans who create a simulacrum of an alien disguised in the body of a human. Purpose is to have it discovered and examined to show that aliens are secretly polluting Earth to make it more suitable for alien takeover.
Hopefully this will cause humans to reduce Earth pollution.
Comment: Roughly when would this have been written? Was it part of an anthology, if so which other stories were in it and what did the cover look like?
Answer: This is "Occam's Scalpel" by Theodore Sturgeon, also the answer to this question.
From my description there:

Two brothers, one a maker of medical dummies and the other the personal physician to the aging boss of a multinational company, stage a fake autopsy to convince the boss's anointed successor that he was actually a sulphur-breathing alien who wanted to pollute the atmosphere to make it more suitable for the rest of his species.
Comment: Ike, if this is the right answer, you can accept it by clicking the checkmark on the left. Please do; it will show everyone the mystery was solved, and reward both you and Daniel with some reputation :)


Why do we find flowers attractive?

Question: Given that we (humans) are not evolutionarily closely related to bees, why do we find flowers attractive?
Comment: Attractive to what sense, sight or smell?  Quite apart from individual preferences, there are some which have repulsive odors (notably Rafflesia, which is said to smell like rotting meat: https://en.wikipedia.org/wiki/Rafflesia ), many others which have an inconspicuous appearance.  Also note that many garden flowers have been selectively bred to be more attractive to humans than their wild progenitors.
Comment: I meant sight and, sometimes, smell.
Answer: Sure, flowers can be sign that the fruit is underway as @JonathanMoore said and viewing any trait as a result of selection is probably what the OP was waiting for. Thinking that if an organism produces a behaviour, then this behaviour must have been selected is wrong though.
The reality is that specific behaviours are affected by evolution of other behaviours and other traits as well as an by our environment (incl. social environment). It will be particularly difficult to hypothesize as for the different selection pressures that may have existed on a specific behaviour especially in animals with such high cognition as humans. Maybe we like flowers because we like colour contrast and maybe we like colour contrast because face with stronger colour contrast is more attractive because it is a sign of health. Maybe we like sunset because we like flowers. Maybe we like colour contrast because we like fresh fruits. Maybe, we like complex design because it makes us think about the possible complexity of shapes. Maybe we like complex shapes because we like to explore. Maybe we like simple design because we like clear skins. Maybe we like flowers because of the diversity of shapes. Maybe we like flowers because they are a sign of the end of the cold winter. Maybe we like flowers because we are being told that they are pretty things. Maybe we like flowers because it symbolizes abundance and reproduction. Anyone could formulate loads of hypotheses. Maybe we like flowers because we like any smell that is not the smell of something that is rotting. Maybe we like flowers because we like trees, leaves, mountains, rivers, lakes and pretty much anything else in our natural surrounding. Maybe we like flowers because flowers is a sign that there is not no pests in our garden or simply that the plant we are growing is healthy.
Comment: Re "...any smell that is not the smell of something that is rotting", there's for instance Fritillaria imperialis https://en.wikipedia.org/wiki/Fritillaria_imperialis which, while it's a striking flower, smells rather like a skunk.  Or some kinds of Iris which smell nice (to me) in moderation, but are rather sickening in quantity.
Answer: Flowers are a sign that fruit is on its way, so it would be advantageous for us to remember the place where we saw flowers.

Why do we find flowers attractive?


How to prevent Wordpress from abbreviating long slugs?

Question: By default, WordPress cut some words from long titles of posts, How to prevent Wordpress from abbreviating long slugs?
Comment: Could you please provide an example? On top of my head I am not sure why would it limit, other than possibly length limit on database field.
Answer: Without you sharing a post title and its resulting slug to see what is happening, I can only guess. But a lot of the time stop words, or extremely common words, are stripped from slugs. This would be words like the, a, an, etc. The plugin Yoast SEO will do this if you're running it as well.
You can override WordPress' behavior though with the save_post hook though.
function my_custom_slug( $post_id ) {
    if ( ! wp_post_revision( $post_id ) ) {

    // Temporarily Unhook to Prevent Infinite Loop
    remove_action( 'save_post', 'my_custom_slug' );

    // Set the new Post Slug
    $my_slug =  sanitize_title( get_the_post_title( $post_id ) );

    // Update the Slug
    wp_update_post( array(
        'ID' => $post_id,
        'post_name' => $my_slug,
    ) );

    // Rehook
    add_action( 'save_post', 'my_custom_slug' );

    }
}

add_action( 'save_post', 'my_custom_slug' );

So what this code will do is, when the post is saved, take the post_title (e.g. This is the title of my post), sanitize it by removing HTML/PHP code as well as special characters, making it all lower-case letters, and converting all white space to -, storing it as $my_slug. So using my example, the title would become this-is-the-title-of-my-post. Then it will update the post_name, which contains the slug with the value of $my_slug.
NOTE: If you're doing this with a custom post type, the procedure is a little bit different and will need some changes and additional code in order to work.


Compute how much memory is needed for a two level page table

Question: Im studying operating systems and i found an exercise that i cant solve. It asks to compute the memory space needed for a two level page table.
The logical addresses are 32 bit,
Page size is 4KB
and the page entry size is 4 bytes.
from the page size i found out that the offset is 12bits from the 32 of the memory address and that every page has 1024 entries. So the 32 bit memory address is like this: 10 bits | 10 bits | 12 bits for outer table, inner table and offset. How can i calculate the memory size i need? (assume that all inner tables are used)
Answer: This is a textbook exercise, maybe answering that exerise is part of your homework, so read your lessons, think about a possible answser, take a sheet of paper and draw rectangles and arrows representing memory, page tables, pointers...
First, an historical note, this arrangement 10 | 10 | 12 is the one used in 32bits x86 CPUs, which were fairly popular!

 4GB memory is divided into 1Million 4kB pages ( binary million = 2^20). Each "Page Table Entry" occupies 4 bytes. Total = 4MB. These entries are arranged in 1024 tables of 1024 entries. The indexes for the 1024 tables, "Page Directory Entries" each take 4 bytes (on x86, this is usually the same size as PTEs), so 4KB. Total size is therefore 4MB+4kB = 4100kB

A few remarks :

This size is only needed for mapping the whole 4GB address space. If there is less memory installed, the page tables can be smaller with "invalid" or "unmapped" entries in the first level page table.
A multitasking OS need to manage different memory maps for the different running applications, so there can be several copies of the page tables.
Answer: If we use just paging then it will contain 4MB to maintain table details
because (2^32/2^12) = 2^20 pages. we store this page table in physical memory . So 4MB is just wasted to store the page table and the access rate is very slow because if you are going to search a page in 1 million page is much more difficult task . So we can use two level paging , it makes easy to access and less memory to maintain the table . So there is no concern with the physical memory it will take in this example. It will take same physical memory it has taken in the paging without two level paging


How to translate a Lightning Component Tab label in different languages?

Question: I wonder how to translate Lightning Component Tab label? Why custom tab is not available at Rename Tabs and Labels in Setup. There is any special step to acheive translation here?
Answer: Rename Tabs and Labels are only for standard translations. To translate custom configurations, including tabs, picklist values, etc, use the Translation Workbench (Setup > User Interface > Translation Workbench > Translate).
Comment: Thanks @sfdcfox - Web Tab insted of Listghtning Component Tab or Custom Tab was confusing for me. Translation changed. Thanks again for explanation.


2003 Mazda Tribute Rear Wiper Fluid

Question: My rear wiper fluid sprayer isn't working.  Is there a separate fluid tank for the rear wiper?  Is there a separate pump for this that could be broken?
Answer: It appears from what I've been reading, there is only one fluid reservoir, which is in the front. There is, I believe a separate pump for the back end. If you are turning the switch and not hearing anything, most likely the pump is not functioning. If you turn the switch and nothing is coming out, I read where one person said to just hold it on for a longer period (60-120 seconds) of time to refill the line coming from the front. If that doesn't work you probably have a clogged line. Also, stupid thing to say, but ensure your front reservoir is full.
Answer: Okay, get a pin and insert it in the tiny hole of the wiper.. Dust or something else might have blocked the water from coming out.. This has worked for me before

2003 Mazda Tribute Rear Wiper Fluid


An implementation about multi thread TFHE

Question: recently I'm trying to use TFHE library for project(https://tfhe.github.io/tfhe/). In order to accelerate the whole program, I use pthread to make multi thread computation. However, I find that the encryption is getting slower with the number of thread increasing. The program is just using bootsSymEncrypt to encrypt each bit of a number. When I use 2 thread, the average encrypting time of one bit is about 0.04ms; when the number is 4, the encryption time is 0.07ms; when the number is 8, the encryption time is about 0.15ms. That's really strange for me. My machine is 4 cores with 8 threads, i7-9700 with Ubuntu 20.04, could someone help me explain this problem ?Thank you!
Answer: I am unfamiliar with the TFHE library; however my guess is that its execution time is bounded by DRAM accesses (that is, cache misses) and not by CPU computations (that is, the size of the memory it tries to access doesn't fit within the cache).
If that were the case, then (consistent with what you observed) adding more threads wouldn't speed things up; each thread would spend its time waiting for its turn to make a DRAM access, and having more threads wouldn't make the DRAM any faster.
Comment: Thank you for your answer. I'm reading a blog "https://www.codeproject.com/Articles/5755/Scaling-of-memory-intensive-multi-threaded-applica", which focused on the relation about memory and thread. I found that my program is memory-sensitive for the usage of index, and I think what you described is important. Could u tell me more about this problem?
Comment: @Kao Tou: even if my guess is correct, performance of caches is hard to summarize in 600 characters (and is worth studying in detail if you want to understand computer performance).  The TL;DR is that the cache is a fast memory that copies recent accesses to main memory (DRAM); if the CPU makes an access that's not in the cache, it's much slower.  The largest cache (there are typically several) is shared between cores.  If you run multiple threads that stress the cache, accesses by one thread will often throw out the data used by another, slower down the system.  This is called thrashing.


1995 Ford Thunderbird

Question: When I step on the brake pedal I hear a hissing sound and the pedal goes all the way to the floor and the brakes barely stop the car. This doesn't happen every time but most of the time. Any ideas of what this could be? My husband just put new brakes on the car right before this started happening.
Comment: What all did your husband change when he "put new brakes on the car"?
Comment: He said he only changed the front brake pads and routers (sp?)
Answer: If pumping the pedal until it's hard doesn't permanently fix it:
Because you say the pedal went to the floor and you heard a hissing, my guess is the master cylinder is bad or you have a brake fluid leak. The hissing is likely because the brake booster is being pushed farther than it was ever expected to (pedal to the floor) so the rubber membrane inside is slipping temporarily and causing a vacuum leak.
Either way, this is nothing to mess around with. Don't drive on it; get it addressed as soon as possible.
Answer: Try just pumping the brakes several times with the engine running and see if that doesn't help. It could just be the calipers need to be filled back up with fluid which will adjust them to where they need to be. When I say pump them several times, continue pumping/releasing until the brake pedal gets hard.
Comment: Do you mean like bleeding the line to get air out?
Comment: @JeanneO'MalleyWhitaker - No. I'm saying *just pump the brakes*. You are trying to ensure the caliper pistons are fully extended and actually pressing against the pads (which will now be pressing against the rotors). I'm thinking after they were installed, they were still collapsed. Just need to be pumped full of juice ... I don't know if that's what happened ... just thinking it could sure be a possibility, though.
Answer: Please make sure.
During the replacement of brake pads ., was the brake oil resiorver cap removed or not? , when caliper piston was being pushed.. If not may be its seals of master cylinder got damaged. Due to this padle is spongy or got down.
Comment: I am not sure if it was removed will check on that but when he first replaced then they worked great for about 4 to 5 days.

1995 Ford Thunderbird


Can we store a signing key in a Named Credential and use it via apex to generate a new JWT token

Question: I have a requirement where I need to generate a new JWT token for authentication but we cannot hard code the signing key in apex or store the signing key in a Custom Metadata or Settings. So wanted to check if Named Credentials be used to store security/signing keys and then can be accessed via apex when generating a new JWT token?
Comment: Does this answer your question? [Generate JWT token for external app](https://salesforce.stackexchange.com/questions/324426/generate-jwt-token-for-external-app)
Answer: Named Credentials are a feature in Salesforce that allows you to store the URL and authentication parameters of an external service in one definition, and then use it as the endpoint for callouts. Named Credentials can support different authentication protocols, such as OAuth 2.0, JWT Bearer Token, or Basic Authentication.
However, Named Credentials cannot be used to store security or signing keys for generating a new JWT token in Apex. This is because Named Credentials do not expose the stored credentials to Apex, and only use them internally when making a callout. Therefore, you cannot access the signing key from a Named Credential and use it to create a JWT token in Apex.
Instead, you can use the following methods to store and access the signing key for generating a JWT token in Apex:

Use a custom object or a custom setting to store the signing key as an encrypted field. You can then query the field value in Apex and decrypt it using the Crypto class. This method is more secure than hard-coding the signing key in Apex, but it still requires you to manage the encryption and decryption of the key.


How to add value of 5e^(-25/2t)u(t) to a voltage source in LTSpice?

Question: I want add the following value 5e^(-25/2t)u(t) as a Vin to my circuit in LTSpice. However I don't know how to do this - can someone help?
Answer: Use a voltage b-source with this:
V = 5*exp(-12.5*time)

U(t) is not needed because it is a step input and goes to 1 as soon as the simulation starts (at t=0 the b-source is considered on)
If you wanted a time offset (like 0.3s for the step function going from 0 to 1) then use an if statement)
V=if(time<0.3,0,5*exp(-12.5*(time-0.3)))

Answer: Another option is using a Behavioral Voltage Source with
V=if( time<0, 0, 5*exp(-12.5*time) )

This allows you to implement \$u(t-t_0)\$ as well.
Comment: Heh, I was thinking the same thing but you beat me to it.
Answer: You can get very close using just the built-in EXP source
From the Help file:
Syntax: Vxxx n+ n- EXP(V1 V2 Td1 Tau1 Td2 Tau2)

Time-dependent exponential voltage source

Name Description Units
V1   Initial value V
V2   Pulsed value V
Td1  Rise delay time sec
Tau1 Rise-time constant sec
Td2  Fall delay time sec
Tau2 Fall-time constant sec

For times less than Td1, the output voltage is V1. For times between Td1 and Td2 the voltage is given by

V1+(V2-V1)*(1-exp(-(time-Td1)/Tau1))

For times after Td2 the voltage is given by

V1+(V2-V1)*(1-exp(-(time-Td1)/Tau1))-(V2-V1)*(1-exp(-(time-Td2)/Tau2))

If you make Tau1 very short, and Td2 - Td1 maybe 5 or 6x Tau1, you get very close to the exponential pulse you want:

In any practical circuit, the fact that this model has a non-zero rise time will not cause any significant difference in the results compared to using the ideal exponential pulse. And if it does, it's likely that the results from this model are closer to reality than from the model using zero rise time.


My lighter fell into the hole at the handbrake

Question: my lighter fell into the hole at the handbrake and I cannot see it in order to remove it, will this cause any damage if I drive the car?
Answer: Probably not, most likely it will find some cavity and remain there for the life of the vehicle. However it is full of fuel, if it were get close to a heat source the results could be bad.
Often handbrake covers are removable, it depends on the car how much work it would be. You could try and use a magnetic pick-up tool to retrieve it as well.
Answer: Maybe, maybe not.. there can be lots of space under there and it can land somewhere harmless.
It can also land, or move during driving, at a point where it could be crushed, so it is best to find it.


Rails + Amazon API + Integration

Question: I'm a rails newb - in a little over my head and could use some help.
I have an existing rails app, and I'm trying to integrate the Amazon Products API with the gem "ruby-aaws"....i.e., place items inside a model, show them in the view, etc.
I've never worked with an external API before, so I'm not sure where to begin to start integration. Any help at all is much appreciated!
Here is some of the code that I've used to pull data with the API:
<code>require 'amazon/aws'
require 'amazon/aws/search'

include Amazon::AWS
include Amazon::AWS::Search

is = ItemSearch.new( 'Watches', { 'Keywords' => 'Gucci' } )
rg = ResponseGroup.new( 'Large' )

req = Request.new
req.locale = 'us'

resp = req.search( is, rg )

items = resp.item_search_response[0].items[0].item

# Available properties for first item:
#
puts items[0].properties

items.each do |item|
  attribs = item.item_attributes[0]
  puts attribs.label
  if attribs.list_price
    puts attribs.title, attribs.list_price[0].formatted_price, item.medium_image, ''
  end
end
</code>
Answer: I am also a newbie and trying to do something similar. I found this example on GitHub that looks really promising.
https://github.com/hundredwatt/Amazon-Product-Search-Example
But there are also some great related questions here that have answers for you:
Ruby Amazon book search
Good luck!

Rails + Amazon API + Integration


weighting scheme of gstat for fitting models to variograms

Question: I use R and the gstat package to construct variograms of temperature, and I would like to ask If anyone knows what weighting scheme does the gstat package use to fit a model to the sample variogram?
Answer: It depends on the fit.method chosen in the function fit.variogram. If you use:

fit.method = 0, no fit
fit.method = 1, weights are equal to Nj
fit.method = 2, weights are equal to Nj / {γ(hj)}2
fit.method = 5, REML (restricted maximum likelyhood)
fit.method = 6, no weights (OLS = Ordinary Least Squares)
fit.method = 7, Nj / hj2

Please see this:

Table 4.2: values for fit in the Gstat user's manual
Details section in the fit.variogram documentation


SlimDX Wrong Joystick State on startup

Question: I use SlimDX and DirectInput to handle a XBox 360 Gamepad for Windows. Everything is working fine but I have the following problem:
When a button is pressed while starting the application, the button state is NOT shown as pressed in the joystick state. The same with the analog sticks: if I hold the stick fully in one direction on startup, the position is shown as zero and changes upon first little movement of the stick.
Is there a way to get the real state of the joystick at startup ?
Answer: Using XInput instead of DirectInput solves the problem.

SlimDX Wrong Joystick State on startup


How to remove protective film from shower after being left in the sun

Question: How to remove protective film from shower after being baked in the sun
Answer: No doubt the adhesive (and maybe the sheeting itself) has permanently hardened at room temperature. You'll need to either warm it or use a solvent to soften the adhesive.
First, I'd try a heat lamp. An infrared flood light would do, or a halogen utility light in a pinch. Set it up so that it's no closer than maybe 24" from the tub at any point--you don't want to scorch the surface. Monitor it closely and often. Work one area at a time.
If that doesn't work, move to mild solvents like GooGone, depending on what the manufacturer says about cleaning solutions.
Comment: You can also use a heat gun. You just want to avoid heating up an area too quickly because you can ruin the finish of the tub. A heat setting of around 300 degrees F should do the job.


Error Reduction algorithm for single measurement intensity

Question: I'm trying to solve the phase problem from single intensity measurement. I implemented error reduction algorithm in Matlab for my problem but it does not give any result. Is there anybody uses this algorithm for phase problem?
Comment: Could you describe the problem you're trying to solve in more detail.  Also, it would be helpful if you describe your error reduction algorithm explicitly in terms of equations.  Posting relevant code portions may also help us to help you better.
Answer: I assume you refer to what's become known as the error reduction algorithm for phase retrieval (e.g. as defined in the Wikipedia article on Phase retrieval). I've used ER in several contexts, but since this algorithm relies on a very simpler alternating projections scheme between the two spaces, convergence tends to be slow. It also tends to get stuck in local minima, where the most direct developments (HIO is mentioned in the article, in my group we have been using RAAR quite a bit) can perform much better.
However, I would also look seriously into whether the problem, as you specify it, is expected to be solvable at all. You say very little on the structure of your problem, and it is very easy to specify something which is seriously underdetermined, at least when you take experimental noise into account. That is, there are a plethora of feasible "solution" which are nothing alike a proper recovery, and it can even be that the very best global optimum, would one find it, is too far removed from the true object to be of relevance. Having a proper support constraint, and possibly constraints on positivity/reality (no imaginary part) in the object space can make a significant difference, in practice.


Getting data from outside source during a transaction once per day

Question: Is it possible for a token contract to call an oracle to fetch data once every so many hours?  Let's say the token was going to use a random number for some decision it was going to make in its execution and that random number needed updated once a day.  Calling the Chainlink VRF to get the random number is easy enough, but is it possible that call only happens once a day?
Answer: Yes.
You'd want to use the sleep adapter from a network of chainlink nodes. This will allow you to call a function every X minutes.
Note, in version 0.6 of solidity its a little tricky to get the VRF and Alarm in the same contract. So an easy work around is to just put them in two separate contracts and have them call each other. Here is an example of a repo that does that.
Here is an example from remix on the kovan testnet.
<code>/** This example code is designed to quickly deploy an example contract using Remix.
 *  If you have never used Remix, try our example walkthrough: https://docs.chain.link/docs/example-walkthrough
 *  You will need testnet ETH and LINK.
 *     - Kovan ETH faucet: https://faucet.kovan.network/
 *     - Kovan LINK faucet: https://kovan.chain.link/
 */

pragma solidity ^0.6.0;

import "https://raw.githubusercontent.com/smartcontractkit/chainlink/develop/evm-contracts/src/v0.6/ChainlinkClient.sol";

contract AlarmClockSample is ChainlinkClient {

    bool public alarmDone;

    address private oracle;
    bytes32 private jobId;
    uint256 private fee;

    /**
     * Network: Kovan
     * Oracle: Chainlink - 0xAA1DC356dc4B18f30C347798FD5379F3D77ABC5b
     * Job ID: Chainlink - 982105d690504c5d9ce374d040c08654
     * Fee: 0.1 LINK
     */
    constructor() public {
        setPublicChainlinkToken();
        oracle = 0xAA1DC356dc4B18f30C347798FD5379F3D77ABC5b;
        jobId = "982105d690504c5d9ce374d040c08654";
        fee = 0.1 * 10 ** 18; // 0.1 LINK
        alarmDone = false;
    }

    /**
     * Create a Chainlink request to start an alarm and after
     * the time in seconds is up, return throught the fulfillAlarm
     * function
     */
    function requestAlarmClock(uint256 durationInSeconds) public returns (bytes32 requestId)
    {
        Chainlink.Request memory request = buildChainlinkRequest(jobId, address(this), this.fulfillAlarm.selector);
        // This will return in 90 seconds
        request.addUint("until", block.timestamp + durationInSeconds);
        return sendChainlinkRequestTo(oracle, request, fee);
    }

    /**
     * Receive the response in the form of uint256
     */
    function fulfillAlarm(bytes32 _requestId, uint256 _volume) public recordChainlinkFulfillment(_requestId)
    {
        alarmDone = true;
    }
</code>
You could also set up a network of cron jobs to call it at every X hour using the chainlink cron initiators.
Comment: Thank you so much Patrick Collins, this was perfect.

Lets say in the code example above I wanted to use Rinkeby instead of Kovan, how can I go about finding the oracle hash and jobId?  (I am very much a noob when it comes to both solidity and even more so when it comes to Chainlink integrations)
Comment: You'd need a different link address, oracle address, and jobId. You can find examples of all testnets here: https://docs.chain.link/docs/chainlink-alarm-clock


Does Newman's network modularity work for signed, weighted graphs?

Question: The modularity of a graph is defined on its Wikipedia page. In a different post, somebody explained that modularity can easily be computed (and maximized) for weighted networks because the adjacency matrix $A_{ij}$ can as well contain valued ties. However, I would like to know whether this would also work with signed, valued edges, ranging, for instance, from -10 to +10. Can you provide an intuition, proof or reference on this issue?
Answer: The straightforward generalization of the modularity for weighted networks does not work if those weights are signed. By straightforward, I mean: just using the weight matrix instead of the adjacency one, like Newman does, for instance, in (Newman 2004). You need a specific version, such as that cited by BenjaminLind, or that of (Gomez et al. 2009).
In both articles, they explain the reason for this. In summary: the modularity relies on the fact some normalized degrees (or strengths in the case of weighted networks) can be considered as probabilities. The probability a link exists between nodes $i$ and $j$ is estimated using $p_ip_j=w_iw_j/(2w)^2$, where $w_i$ and $w_j$ are the respective strengths of nodes $i$ and $j$ and $w$ is the total strength over all the network nodes. If some weights are negative, then the original normalization doesn't guarantee having values in $[0,1]$ anymore, so the above $p_ip_j$ quantity cannot be considered as a probability.
To solve this problem, Gomez et al. consider positive and negative links separately. They obtain two distinct modularity values: one for positive links, one for negative ones. They substract the latter from the former to get the overall modularity.
Comment: Yes, I think you'll find the source code here: http://deim.urv.cat/~sgomez/radatools.php
Comment: Thanks, this looks promising. I will take a look at the Gomez et al. article. Is there an implementation?
Comment: the code looks blackboxed to EXE files, but if all you need is modularity for positive and negative weights, why not just (1) convert your matrix to a weighted edge list, (2) split the list between positively and negatively signed weights, and (3) compute modularity with `igraph` using absolute weights in each partition?
Comment: That's a good idea, but the modularity processed for negative weights must be minimized, and the methods in igraph only do maximization (as far as I know). As for the source code, I think you're right. Maybe you can contact directly one of the authors?
Answer: Yes, it can. Spin-glass models for community detection can compute modularity from weighted, signed graphs. You'll want Traag and Bruggeman "Community detection in networks with positive and negative links" as a reference. The function "spinglass.community()" in igraph can find the communities and return the graph's modularity.
Comment: Thank you. I am not really interested in the communities but rather in the tendency of the signed network to be polarized/fragmented into communities. But as far as I can see, the modularity can be retrieved from the resulting ``communities`` object using the ``modularity`` function. I will definitely take a look at the Traag and Bruggeman article. Since the implementation seems to be based on simulated annealing: how well does it perform? Can I actually make sure that the algorithm really returns the _optimal_ modularity (since I want to measure polarization/fragmentation)?
Answer: We have pointed out the problem of Modularity[-alike] functions with signed networks in this paper. They tend to ignore the positive density of communities more as the absolute number of negative links in the network increases.
Also, here is our open source java project for weighted-signed networks, which is based on Constant Potts Model (similar to Modularity), fast Louvain algorithm, and community evaluation based on an extension of Map Equation.
Esmailian, P. and Jalili, M., 2015. Community detection in signed networks: the role of negative ties in different scales. Scientific reports, 5, p.14339


Problems installing Ubuntu Studio 17.10 in VirtualBox

Question: I've been trying to install Ubuntu Studio 17.10 in Virtualbox 5.2 using both Windows 10 and Ubuntu 17.10 host machines but to no avail.
When I attempt to install it using the 17.10 ISO it either freezes during the instillation setup, or gives me the 'Errno 5' error message. On one occasion it has just dumped me onto the bash screen and then froze.
When I attempt to install a previous version of Ubuntu Studio and upgrade from there the upgrade seems to work and then when I reboot the virtual machine all I get is a frozen black screen.
I am able to install other Ubuntu 17.10 distros without error, however I am interested in testing how Ubuntu Studio 17.10 is setup and configured (i.e the low latency kernel and the Pulse/Jack integration) and not just the main programs it comes with as I know I can install those easily on other distros.
Any help would be greatly appreciated. Thank you in advance :)
Answer: A few days after I posted this question I tried downloading a fresh ISO for Ubuntu Studio 17.10 and it installed. This doesn't quite answer why the update from 17.04 wasn't working however.
I assume it was just a corrupt ISO. Hope this helps someone.


Run Existing Web Start App Through IDE Using Existing JNLP(s)

Question: I have an existing application that I need to debug. On the web server it uses 2 JNLP files, one containing many parameter settings needed by the application. I am trying to get this to run through my IDE (netbeans) with no success. Netbeans allows me to set up the application as a web start app but creates the JNLP files itself (no good because I need the parameters). I am left with placing all of the parameters in an HTML  file and running the app through sun.applet.AppletViewer. I've scoured Google and the forums looking for an answer but am not seeing any.
Answer: You can edit your projects jnlp file "template" and add required params directly. The file is named master-application.jnlp and it should be in the root folder of your project.


Is it a breach of privacy to list the names of past interns and supervised students on your academic website?

Question: I've seen many personal web pages of (US/UK/EU) academics that have a list of all the PhD, MSc/BSc or internship students they've supervised before. Is this allowed or does it break privacy of the students?
Comment: Any student you have co-authored a paper with is linked to you quite publicly.
Comment: Unlike _undergrad_ teaching (in the U.S.), in _graduate_ mathematics, successful mentoring of a student through a PhD is a non-trivial accomplishment. It's "completing a major project", and is an important part of faculty function, and is _judged_ by administration. If a student told me that they did not want any public acknowledgement of my mentoring, while this wouldn't put the relationship out of the question, it would make me wonder what was going on, and I might feel short-changed... Of course, in harassment situations, I could understand. But, having connections is a professional plus.
Comment: @JonCuster Not just coauthored a paper... also written a thesis under your supervision. At least around here a thesis is a publication, in a way.
Comment: I note all the answers here were written before the coming into force of GDPR.  Can anyone comment on whether anything has changed?
Comment: Aside from the simple legal issue of privacy law, I doubt if you would find any "bad" information about a student on a supervisor's web page. Why would a supervisor want to advertise his/her *failed* students?
Comment: @skymningen - indeed. At least at my undergrad, the thesis were available in the library which likely means on the web now. But it is slightly more difficult to trace the lineage since you actually have to look inside the thesis to find the advisor's name. Masters and PhD usually have a good chance of an actual paper, indexing in Web of Science (or similar), etc...
Answer: The governing federal law in the USA is FERPA - the Family Educational Rights and Privacy Act. Under FERPA a school may generally disclose what is identified as "directory information," things such as names, email addresses, photographs, etc. However the student has the right to request that their directory information be excluded from public disclosure, so it's possible that they are not covered here.
Note that, as in most cases, individual states may have their own privacy statutes.
If you are really concerned then the prudent thing to do, regardless of legal jurisdiction, would be to ask the student in an email whether they are OK with the posting of their name and potentially other information. The email provides a reasonable level of proof that you did your due diligence prior to posting student information.
US DoE guide to FERPA: https://www2.ed.gov/policy/gen/guid/fpco/ferpa/students.html
Comment: I think the train of thought is that the student is (implicitly, but maybe it should be explicit) consenting to disclosing some information on a lab/group website because it's generally seen as positive for them and the lab to show some activity as maybe a form of advertising.
Comment: If a student has asked to have their directory information kept confidential, then FERPA would require the faculty member to keep it off their web page.  However, most graduate programs require the publication of a thesis or dissertation and the student doesn't have a FERPA right to keep that information private.
Answer: This not only allowed but is a good practice too towards transparency, and is definitely not a breach of privacy.
Supervision is a publically known position, not secretive and the website is only making it known to a wider audience.
If the student's private emails or personal information of their private travel, etc were revealed on a public site, that would be a breech on the reasonable expectation of privacy.
Answer: Many professors do this to establish the "academic family tree" of their lab. Most of the students are happy about it and proud. It only documents that you spent some time in that lab/group working on a topic, which I don't think violates your privacy. If you don't want that, you can contact the professor to get your name removed; shouldn't be a problem.
Answer: I don't know in the UK, but at least in Spain these data (at PhD level) are public. Not only student and supervisor, but also committee members, etc. Here an entry of the database: https://www.educacion.gob.es/teseo/mostrarRef.do?ref=1381779
I wouldn't consider that as a breach of privacy but actually good transparency.


Ubuntu 21.04. Newbie here. Please confirm correctness before I do a Timeshift system restore

Question: Newbie here. See pics. Some of my apps got messed up and I want to do a Timeshift system restore to yesterday (Aug 10th). Please look at the pics and see if I'm all set to do a restore. Will this restore take my apps back to yesterday? I want to make sure cuz I know a bad restore can trash my whole system. Thanks.
Comment: What do you mean "some of my apps got messed up"? Would it be fixable? To do a Timeshift restore, I believe that you've got to boot to a Ubuntu Live DVD/USB, install Timeshift, point it at where your Timeshift backup files are located, and then restore from there.
Comment: See my comments on your earlier question about VLC/Flameshot.
Answer: Issue Resolved.
I got it working. I took a deep breath and did my first Timeshift system restore and it worked! Flameshot and KDEConnect started working again, but my VLC snap was not working. I then removed the VLC snap and installed the VLC flatpak and that now is working normally. So I'm back to normal.
Thank goodness for Timeshift! Now I'll be doing system snapshots a lot more often (and properly commenting them).


Concept of using limits to find horizontal asymptotes.

Question: $$y=\dfrac{(\sin x)^3}{x^2}$$
My professor explained how to do this problem by using limits. I am a little confused as to why he used limits because in the past we were told to look at the coefficients of the biggest degrees. I have done some searching online and found that if you take the limit of a function as it approaches $\infty$ or $-\infty$, you would get the horizontal asymptotes. I have also came across someone saying that the coefficients do not matter and only the degrees matter. Is this true for all cases? In the past I was told to use the ratio of the coefficients of the largest degree and that would be the horizontal asymptote. Is this not the case when you are using limits to find the horizontal asymptotes? If not, could someone give me an example when the coeffcients are used?
Answer: You can look at the degrees if the numerator and denominator are both polynomials.  In general, it's not so simple; in general there isn't even anything you can identify as a "degree".  Here, the numerator is not a polynomial, and it's not so simple.
If you try to pretend that $(\sin x)^3$ is a third-degree polynomial, you will get the wrong answer.
You can use the coefficients of the highest-degree terms of the numerator and denominator when the  numerator and denominator are polymomials.  For example,
$$\frac{12x^2+7x+17}{3x^2-8}$$
has a horizontal asymptote at $y=4$, and
$$\frac{7x+17}{3x^2-8}$$
has one at $y=0$.
Comment: I know that the $sin$ function is bounded between $-1$ and $1$ so the limit of the function approaches $0$. I have a couple of questions that I asked and I was wondering if you could explain it to me.
Comment: Ahh I see now! Thank you for the explanation :).
Answer: Consider the degrees of the numerator and denominator when both are polynomials. If they have the same degree, we only need to consider the coefficients of the highest powers; however, if their degrees differ, then either the numerator has a higher power or a lower power. In the former case, the limit tends to $\infty$ or $-\infty$, depending on the sign of its coefficient ($+\infty$ if the coefficient is positive, and $-\infty$ if it is a negative coefficient). Consider, for example, $$\lim_{x\to\infty}\frac{x^2+1}{x+1}.$$ The numerator has a higher power, and the numerator and denominator are positive, hence the limit is $+\infty$.
In the latter case, the limit always goes to zero, as in the example $$\lim_{x\to\infty}\frac{x+1}{x^2+1}.$$
Note that if the numerator has a higher power by only $1$ degree, we can use long division of polynomials to actually calculate the oblique asymptote. Considering the first example, we can calculate $$\frac{x^2+1}{x+1}=x-1+\frac{2}{x+1}.$$ As $x$ gets big, the last term goes to zero, thus the oblique asymptote is $$x-1.$$
In cases where they're not both polynomials, we usually have to rely on some bounds. In your example, we know $-1\leq\sin(x)\leq 1$, and the limits become easy to calculate. That is, we have $$\lim_{x\to\infty}\frac{-1}{x^3}=0\leq\lim_{x\to\infty}\frac{\left(\sin x\right)^3}{x^3}\leq0=\lim_{x\to\infty}\frac{1}{x^3}$$
Comment: Is the $-1\leq\sin(x)\leq 1$ true for all trigonometric functions and are there any other types of bounds I should be aware of? I have an exam this Friday and I want to be sure I know this.
Comment: @StevenN: It is true only for sine and cosine; the tangent function has its range as $\Bbb R$, so there cannot be bounds for it, and secant and cosecant have their ranges as $(-\infty,-1]\cup[1,\infty)$.
Comment: I see, so if the $sin$ were replaced with $tan$, $csc$ and $sec$ in the problem above, the limits would also be $0$? Or would the power in the numerator play a role in this? Also, if the $sin$ and $x^2$ were switched, it would shoot up to infinity and have no horizontal asymptote right?
Comment: @StevenN: If $\sin$ were replaced by any of those, the problem changes drastically, as we no longer have the trig function bounded. For the second part, if we switched places for $x^3$ and $\sin(x)^3$, we would get that the limit diverges since no matter how you look at it, the denominator bounces back and forth between $1$ and $-1$, thus our limit has two subsequences, one 'converging' to $\infty$ and one converging to $-\infty$.
Comment: I guess I am getting a bit ahead of myself. I hope that the other trigonometric functions won't be on my test.


How to get an unbiased estimator

Question: Defining the sample mean as $\bar{x} = \frac{1}{N}\sum_{n=0}^{N-1}x_n$, and having $N$ realizations of a random variable $x$ with mean $\mu$ and variance $\sigma^2$
Defining  $\bar{x}^2=\hat{\mu^2}$, I get that $Bias(\bar{x}^2) = E[\bar{x}^2] - \mu^2=E[\bar{x}]^2+Var(\bar{x}) - \mu^2 = \mu^2+ \frac{\sigma^2}{N} - \mu^2 = \frac{\sigma^2}{N}$ is a biased estimator.
Would it be possible to obtain an unbiased estimator of $\mu^2$?
Any help is appreciated!
Comment: Why are you omitting the last observation in your definition of the sample mean? If you're trying to use [Bessel's correction](https://en.wikipedia.org/wiki/Bessel%27s_correction), that requires changing the divisor, not removing an observation, and it can only do you any good when estimating a variance, not a mean.
Comment: An alternative view to *unbiasedness* is presented in this Gelman blog post ... http://andrewgelman.com/2015/06/10/best-linear-unbiased-prediction-is-exactly-like-the-holy-roman-empire/
Comment: Please define $Bias(\bar{x}^2)$ and consider adding the self-study tag.
Answer: Suppose $X_1, \dots, X_N \sim (\mu, \sigma^2)$. Then observe that
$$\mu^2 = \mu_2 + \sigma^2$$
where I am using $\mu_2$ to represent the second moment $\mathbb{E}[X^2]$.
Then, a well-known unbiased estimator of $\sigma^2$ is
$$S^2 = \dfrac{1}{N-1}\sum_{i=1}^{N}(X_i-\bar{X})^2$$
where $\bar{X} = \dfrac{\sum_{i=1}^{N}X_i}{N}$.
Furthermore, in general, if we have a function $g$ such that $\mathbb{E}[g(X_i)] = k$ for each $i$ (i.e., the expected value is the same for each variable in the random sample), we can use
$$\mathbb{E}\left[\dfrac{1}{N}\sum_{i=1}^{N}g(X_i)\right] = \dfrac{1}{N}(Nk)=k\text{,}$$
which means, that, therefore, $\dfrac{1}{N}\sum_{i=1}^{N}g(X_i)$ is an unbiased estimator of $k$. Use this to find an unbiased estimator of $\mu_2$.

How to get an unbiased estimator


Can total throughput (read throughput + write throughput) exceed the bandwidth of a network?

Question: I was looking at the counters on a machine in production and found that the read throughput was 3.5 GBps and the write throughput was 4.5 GBps ( the counter measures the read bytes and write bytes per second for the network interface). The machine has one NIC  with 41Gbps i.e. ~5 GBps. How is this possible ? My understanding is that network bandwidth is the total ( read + write) bits that can be transferred per second.
Comment: "_My understanding is that network bandwidth is the total ( read + write) bits that can be transferred per second._" No, modern wired networks are full duplex. Each direction is independent of the other.
Comment: Basically yes - a 40G Ethernet link can carry 40Gbit/s up and 40Gbit/s down at the same time.
Comment: When you say independent of the other you mean the total throughput (read + write) can be greater than the n/w bandwidth  ?  i.e. the sum of both "read bytes per second" and "write bytes per second"   <=  (2*bandwidth)
Answer: A modern Ethernet link is generally full duplex: both directions work independently of each other. Full duplex has become the standard with fully switched Ethernet nearly 20 years ago.
For Ethernet, the nominal speed is generally the one used at the top of the physical layer (L1). The line code (8b/10b, 64b/66b, ...) is irrelevant, but the highest-level L1 overhead - preamble, SFD, IPG, 20 bytes total - already eats into that nominal speed. Also, depending on the actual protocol stack, all the higher-layer overheads also eat into the usable bandwidth.
Most commonly, a standard Ethernet frame has an minimum overhead of 18 bytes (DestMAC, SourceMAC, EtherType, FCS), with 1500 bytes maximum payload. If IPv4 is used that's another minimum overhead of 20 bytes. For TCP, it's another 20 bytes. All in all, 1460 usable bytes with a total of 1538 bytes on the wire result in a maximum efficiency of 94.9%.
So, for TCP over IPv4 over 40GBASE-X without any bottleneck, you could expect a peak throughput of 4.746 GB/s per direction.
Comment: corrected the question, it was 4.5 GB/s not 7.5 GB/s , thanks.
Comment: @thor_hayek Excellent, thanks for clarifying.


Factors to check if server is a SP Web Server or SP App Server

Question: How to determine and check if a server is a SharePoint Web front-end Server or a SharePoint Application Server?
Answer: A server is considered Web Front-end Server if its running "Microsoft SharePoint Foundation Web Application" service. The best way to check is under "Central Administration --> Services on Server" and then choose the server you are interested and check what kind of services are running on it.
Answer: There are several main criteria to consider an server a "Web Front-end Server" (WFE).
1) As others have mentioned, the "Microsoft SharePoint Foundation Web Application" must be running. However, just because this is running does not make it a WFE. Other servers in the farm, for various reasons, may also have the Microsoft SharePoint Foundation Web Application service started.
2) Condition two is that user traffic is directed to the WFEs (via DNS and/or load-balancing). That is, they are accessed by end users to get at the farm content.  Typically, even if the Microsoft SharePoint Foundation Web Application service is started, if no users hit that server directly, it is probably not a WFE. An exception would be if there was a dedicated WFE for handling search crawler traffic.
3) If the Microsoft SharePoint Foundation Web Application service is not started, it is not a WFE
Answer: This is not easy unless documented...
Couple of things to check to make decision..
1) from central admin > manage servers in farm...check which server is running central admin website...This is the evidence of app server.
2) check AAP settings, see which server is mentioned for your website....This is wfe.
Or.
3) ping the sharepoint Web address and see which server IP mentioned here...again this is your wfe.
Or.
4) you can check which server is running Web application services, this is required for wfe...but this one is not hard evidence because no body turn off this services for app servers.
.....
5) for app server, this server typically run the all services applications. ..so you can check from manage services on server...which server having these...


Adding a 50a breaker in main panel to feed 30a rv breaker and plug

Question: I recently purchased a prewired 30a rv subpanel to plug in a travel trailer while sitting at home. The subpanel is complete with a 30a breaker and receptacle. Is it acceptable to run the romex (10-2) to a new 50a breaker in the main panel having the 50a feed the 30a breaker?
Comment: If you're going to go to the trouble of installing an RV power post, I *highly* recommend just using 6/4 and putting in a panel with both 50A service (14-50 receptacle) and 30A (TT-30) service. The parts/wire cost is really not that big of a deal compared to the cost (in either dollars or time) of the installation labor. You'll need a 50A two-pole breaker in the main panel to feed the 6/4 and then the RV subpanel will likely have a 50A two-pole for the 14-50, a 30A single pole for the TT-30, and a 20A single pole for a 5-20 duplex.
Answer: If you want to wire in 50A for a future, larger RV, then you need to run the cabling with 6/3 UF cable (not NM/Romex, you cannot use Romex because you will be going outdoors).
If you were to do that with e 6/3 cable, with the panel you have bought, that would be fine.
However, it's a common case for someone to buy the wrong thing and then go into backflips doing even more wrong things trying to make the wrong thing work.  Don't bother; get the right thing.  If you are mail ordering this stuff, thats a mistake - local electricians must shop somewhere; shop there.
They make RV panels which have all the breakers and sockets necessary to support all of

a 240V, 50A large RV (with NEMA 14-50 receptacle)
a 120V, 30A small RV (with TT30 receptacle)
typically a 120V/20A plain old outlet for hand tools etc.

This works off a 50A breaker because it is presumed you will only be powering one RV at a time.  But you still need 6/3 outdoor cable; 10/3 won't do.
Comment: Thanks @Josh. The 10-50 was a typo.  I thought I had seen a 14-30 on an RV stand but I was mistaken.
Comment: There are exactly two types of RV plugs in North America, and neither of them are a NEMA 10-anything. The 30A service (120V) RV plug is a TT-30 (line, neutral, ground), and the 50A service (120/240 split phase) RV plug is a 14-50 (line 1, line 2, neutral, ground). 30A on 120/240V is non-standard and will not be found in any modern RV park, and perhaps not in any RV park period.

As a side note, the NEMA 10- receptacles are line 1, line 2, neutral and do *not* have a ground conductor. They are deprecated and cannot and should not be used in any new installations.
Comment: Some temporary power outlets provide other types of receptacles, but that's mostly for jobsite use and such
Answer: No, you can't do that. The 10-2 romex has a 30 to 35 amp maximum depending on the insulation. The breaker in the main panel's job is to protect the 10-2 so it has to be a 30 AMP breaker, not the 50 AMP.
If this is going to be a permanent type installation you need to think about running your cable in such a way that it's not a safety hazard or a code violation. You can't have it lying on the ground running from you panel to the trailer.... maybe conduit from the panel to the outside wall and have a receptacle.... then a plug from you subpanel.
Comment: If I'm understanding this correctly, I can use a 30a breaker in the main panel to feed another 30a breaker in the rv subpanel? I can also go to an 8-2 romex if needed.
Comment: Yes, two 30's are ok. The 8-2 is good for 40 to 50 AMPS depending on the insulation. You don't need the extra capacity and the larger wire size would cost more than getting a 30 AMP breaker.


Include customer group selection on registration form - Magento 2

Question: I'm using Magento 2.2.3 and what I want to achieve is to put a dropdown selection for customer group on the registration page because some of them are resellers. Is this possible and if so, how do we do this?
Answer: What you're talking about is perfectly possible and the best approach here would be to create a custom module to do so. Without going in super depth, here's a summary of what you'd need to do:
1: Create the basic module structure
(see https://devdocs.magento.com/videos/fundamentals/create-a-new-module/)
2: Override the register form block to use a custom version of the register template. To do that you would create a view/frontend/customer_account_create.xml with the following contents:
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">

        <referenceBlock name="customer_form_register" template="Your_Module::register.phtml" />

</page>

Then copy the contents of vendor/magento/module-customer/view/frontend/templates/form/register.phtml to /path/to/magento/app/code/Your/Module/view/frontend/templates/register.phtml
3: Add custom html & php to your override of the register.phtml form to show the dropdown of customer groups.
I would recommend using a ViewModel as a mechanism to get the customer group data. So for example, in the layout xml above you would do:
<referenceBlock name="customer_form_register" template="Namespace_Module::register.phtml" >
    <arguments>
        <argument name="view_model" xsi:type="object">Your\Module\ViewModel\CustomerGroups</argument>
    </arguments>
</referenceBlock>

This would then allow you to do the following in your register.phtml:
$viewModel = $block->getViewModel();
$groups = $viewModel->getCustomerGroups();

Your view model should use the inject the Magento\Customer\Model\Api\Data\GroupRepositoryInterface class and use that to get the customer groups and return them as an array. You can then use the array in the template to build the select & options.
Also ensure the name of the select dropdown is set to group_id as this should then feed through to the data processing correctly (havent tested this though)
Comment: I had trouble on the view model part. Couldn't get it right.


A problem of Age

Question:
Recently I met a women which said: Do you know something funny? If you reverse my own age, the figures represent my husbands age. He is, of course, senior to me, and the difference between our age is $\frac{1}{11}$ of their sum.

Can you find out the women's age  as well as her husband's age?
Answer: Their ages are:

 Wife: $45$, Husband: $54$

Reason:

 Let wife's age be represented as: $10x+y$ where $x$ and $y$ are single digit natural numbers. Now, husband's age is $10y+x$. So, now, difference of their ages: $9y-9x = \frac{1}{11}(11x+11y) = x+y = k$. So, $9x+9y=9k$ and $9y-9x = k$. Thus, $y=\frac{5k}{9}, x=\frac{4k}{9}$. So, since $x, y$ are digits and are strictly integers, the only possible answer is $k=9$. Thus leading us to the answer.
Comment: In fact, it is not mention in the problem that the ages are two-digit numbers.

Other answers include $495, 4995, 49995, \dots$ and there are even more, such as $4545$ and $495495$. It is easy to show that any answer must begin with $4$ and end with $5$.
Comment: And actually it is [this OEIS sequence](http://oeis.org/A193434).

A problem of Age


Was Olaf One-Eye a fraud?

Question: According to King Olaf's Verse he was a fraud. If this is true, then why was he in Shor's hall in Sovngarde, if only heroes can go there?
Answer: It's difficult to say. The Dragonborn encounters resistance during the quest to recover King Olaf's Verse for the Bard's College, including a duel with Olaf's re-animated corpse (or at the last, an observation of such a duel between Olaf and Svaknir's ghost).
One could argue that Olaf's desire to prevent anybody from seeing the verse must mean that the verse describes the truth; why else would he want to suppress it?
But it's also possible that Olaf sought to keep the verse buried because it was libelous and threatened to damage his heritage, which is an important cultural touchstone of the Nord race.
Further, it's possible that Olaf himself did not arrange to be re-animated in guardianship of the verse, and that some third-party forcibly re-animated him as a form of (perhaps ironic) revenge.
The game doesn't offer much evidence either way. If you speak to Olaf in Sovngarde under certain conditions, he will say:

You freed Svaknir, a fool of a poet, but an honest enemy who has
  earned my respect. Sadly, he's now lost in the soul-snaring mist -
  defeat Alduin, and his doom avert - I hope to greet him in this Hall
  as a friend.

Unfortunately this doesn't offer much clarification - only that Svaknir and Olaf did not particularly like each other, which could be the attributable to any of the above possibilities. The dialog does suggest, however, that Olaf is (or at least became before death) an honorable warrior, which leads me to address your second point:
If we assume for the sake of argument that Olaf did fabricate (or more specifically, embellished upon) the tale of Numinex's capture, that doesn't necessarily preclude him from reaching Sovngarde after death.
The Road to Sovngarde states that "Nords who prove themselves in battle awaken in the realm after death." Further, from Sovngarde, a Reexamination we can read that "Sovngarde [was] built by the god Shor to honor those Nords who have proven their mettle in war," and later that "in the end, all valiant Nords can enter Sovngarde."
There appears to be no lore suggesting that a single instance of dishonesty disqualifies one for entrance to Sovngarde: you only need to die bravely, in battle. You do not necessarily need to be a good person.
Even if you don't buy that argument, Olaf was known (after the Numinex events) for subjugating the wilds of the Reach and for helping to restore Skyrim after the War of Succession, which can be considered pretty "heroic" deeds.
Answer: Ever thought about that maybe the Olaf in the tomb are not really the same one in Sovngarde? Maybe Olaf died honorably during the battle while capturing the dragon, than his identity was presumed by some dragon priest (or someone in the cult), and everyone else in the scene were bribed to keep the secret (like the legend said).
The "Olaf " that Svaknir's fighting before and after his death is never the real one, hence Olaf calls Svaknir "a fool of a poet but honest enemy", since he only discovered part of the truth and just stick with it.

Was Olaf One-Eye a fraud?