What is the difference between AMPScript function Now() and Now(1)?

Question: I've been using AMPScript and I've seen the documentation, run a few tests, and I've done a bit of Googling, but off-hand, I'm not really seeing a notable difference.
Answer: Now(P1)
Returns the current system date and time.
Arguments
P1    Optional parameter. Enter 1 or true to indicate true to preserve the email sent time for post-send resolution of Now.
Example
Given the date and time 10 a.m., March 1, 2008.
Now()

System returns:
3/1/2008  10:00:00
Source
So it would appear you'll only see a noticeable difference if a sizeable amount of time passes between email sent time and when the code runs.
Comment: Normally `Now()` (and any other AMPScript) will get re-evaluated when an SFMC email is viewed as a webpage.
Comment: Yes, this is what I saw in the documentation, and what I would assume it means.  I have run a few tests using both NOW() and NOW(1).  Based off of that I'm not seeing a notable difference so far.  I guess time (pun not completely intended) will tell.

That said, the documentation does not go into great detail.  To me it's pretty vague.  For starters, what do they mean by "post-send" resolution?  In what instances should I use which based off of what result I might want to get, or ultimately does it really matter which I use?
Comment: My understanding is that if you do now(1), any now() there-after will return the same value, and that is is thus stored in memory as a variable. (I'm however entirely inexperienced with actually using marketing cloud)
Comment: Ah ha!  Thanks @AdamSpriggs!  That helps tremendously :D
Answer: The static method Datetime.now() has no parameters so you should not use any. Attempts will be ignored by the system or cause en error.
Datetime Static Methods: NOW()

Returns the current Datetime based on a GMT calendar. Signature public
  static Datetime now()
Parameters None
Return Value Type: Datetime
The format of the returned datetime is: 'MM/DD/YYYY HH:MM PERIOD'
Example datetime myDateTime = datetime.now();
Comment: My apologies!  Yes, this would be my first post.  I've updated the question.  Thank you for the suggestion!
Comment: Actually, I was referring to the AMPScript function NOW(), but I did not realize there were other methods.  I will look into that.  Thanks!
Comment: This is what I thought until I saw it was tagged as AMPScript. @Kallie May be worth making it a bit clearer what you're asking for future questions. :) Easy thing to overlook though when you're nose deep in a particular language or something.
Answer: Now() will give current system date, If a user opens the e-mail again or views it as a webpage it gets updated. Now(1) will always return the sent date. Example:

Sent: Email is sent on Jan, 1, 2017 10 AM
Open 1: User first opens the email at Jan, 1, 2017 18 AM
Open 2: User opens the email at Jan, 2, 2017 16 AM

Now() =
Open 1: Jan, 1, 2017 18 AM
Open 2: Jan, 2, 2017 16 AM

Now(1) =
Open 1: Jan, 1, 2017 10 AM
Open 2: Jan, 1, 2017 10 AM


Is there an easy way to loop through all existing values of an entry field and store them in an array?

Question: Looking to loop through and filter based on possible values in a text entry field...I have a text field called storeBanner that has 11 possible values (but could have more). Just need a way to go through every entry and create an array with all possible values.
Comment: Can you provide more information? What have you tried so far?
Comment: Haven't tried anything yet. Not sure how best to go about that
Answer: I'm not sure about an array of the possible values. But you can get the actual values. You can do this with twig's merge filter. First get all the entries:
{% set allEntries = craft.entries.section('whatever') %}

Then loop over the entries and add them to an array:
{% set allValues = [] %}

{% for oneEntry in allEntries %}
  {% if oneEntry.storeBanner not in allValues %}
    {% set allValues = allValues | merge([oneEntry.storeBanner]) %}
  {% endif %}
{% endfor %}

Now allValues will be an array of the values
Things to notice:

You need to set allValues outside of the for-loop. Otherwise it will only exist in the scope of the for loop, and not afterwards - ouside it.
You need to pass an array as the parameter of merge. In this case an array with one value: [oneEntry.storeBanner]


IIR filters what does infinite mean?

Question: I am having difficulty understanding what "infinite" in IIR means in practice..In theory the impulse response is used for feedback..If this feedback never ends how output is generated?
Answer: To answer that question you have to know what "Impulse" and "Response" mean...
An "Impulse" is a simple pulse.  Digitally it would be a sample with a maximum value, while all of the other samples before and after it would be zero.  If you listened to this, you would hear something like a pop or firecracker.
The "Response" is the output of a filter (or something else) is given the impulse.
For example, you can listen to the "impulse response of a room" by going into the room, doing a simple hand clap, and listening to the echo.  It would take some practice to get the hand clap to be as "sharp" as possible.   Getting the impulse response of a filter is the same way but instead of a hand clap you use a simple pulse and instead of a room you have a filter.
If you look at the impulse response of a filter, or a room, you will see the output wiggle for a time after the impulse (and sometimes it wiggles before, too).  In the room you heard this wiggle as the echo.  In a filter this wiggling is directly related to the frequency and phase response of the filter.  In a room, the amount of time you hear the echo is called the "reverb time"-- there is no corresponding term for a filter, but it is part of the impulse response.
Now, a FIR filter (Finite Impulse Response) is finite because the impulse response time is limited by the math.  It's mathematically impossible for the impulse response time to extend beyond the number of taps in the filter-- therefore it is finite.
An IIR filter, on the other hand, does not have this mathematical limitation in the impulse response time.  If given an infinite mathematical precision, an IIR filter can wiggle the outputs forever.  Of course, in a practical sense it never goes on forever since at some point the wiggle gets smaller than the precision of the math used and so goes away.
Comment: @Parhs: the feedback takes place because the current output is derived from previous *input* **and** *output* values, whereas for FIR filter the output is derived only from previous *input* values.
Comment: @Parha  Feedback is a side effect of the topology.  And by topology, I mean something like a flow diagram or a "schematic" view of the filter.  Basically, the results of a math operation in one stage feeds another operation in a previous stage.  That's what the feedback is.  Most people find FIR's easier to use because they don't have that feedback.  That feedback is difficult to make work correctly, but has a great amount of efficiency in it.
Comment: thank you for the nice explanation! Where does feedback takes place in IIR?
Comment: An IIR system has internal state that 'remembers' previous input for all time. The way you model this is to either feed previous outputs back into the current output, such as this [direct form 1](http://upload.wikimedia.org/wikipedia/en/7/70/Biquad_direct_form1.png) biquad, or equivalently a feedback loop at the input, such as this [direct form 2](http://upload.wikimedia.org/wikipedia/en/e/ee/Biquad_direct_form2.png) canonical biquad.
Answer: The impulse response is the filter's signature. In the case of a FIR filter the impulse response gives you a direct image of the filter's coefficients. The impulse is a single sample with maximum amplitude, all samples before and after are zero. (This is the digital equivalent of a Dirac pulse.)
At the time of the pulse its value is multiply by \$b_0\$ (see bottom diagram). The other samples are zero, so the output \$y\$ equals \$b_0\$ (I'm presuming a maximum value for the pulse of 1). One sample later the pulse has moved one \$z^{-1}\$ block and is multiplied by \$b_1\$. Again, all other values are zero, so the output is \$b_1\$. And so on. While the pulse shifts through the filter you get the successive values for \$b_i\$ at the output. After N samples the pulse is shifted out of the filter, and the output becomes zero again.
For an IIR filter it's not so obvious to derive the filter coefficients from the impulse response.
IIR
In an IIR filter (part of) the processed signal is fed back to the input. That means that there will always be some residue of the signal looping around. Most of the time however this part of the signal will be ever smaller and end up being zero, but in theory it never disappears completely. The block diagram below shows a biquad filter, an often used implementation of an IIR filter. The left branch takes (delayed) input values, the right branch works with (delayed) output values. (A \$z^{-1}\$ block represents a 1 sample delay. Biquads are often cascaded.

FIR
FIR filters on the other hand have a linear path from input to output. After N samples the input signal (like a Dirac pulse) will have been shifted out and that's the end of it.
FIR filters are inherently stable, while IIR filters aren't necessarily.
Comment: It definitely can.  Use the wrong feedback paths or gains and you can make a unstable filter or one that puts out a sine waver of something forever.  That's generally not what you want a "filter" to do, so there are techniques to analyse stability and to avoid instability.
Comment: that looping singal cant be unsafe giving undesired results in some cases?
Comment: @supercat - It's sufficient to have some form of feedback to have an IIR filter. You don't have to go from the output or to the input, as the \$-a_1\$ and \$-a_2\$ paths in the biquad filter show.
Comment: Does the sum from all the feedback terms have to feed back to the beginning of the feedback chain, or can the output from later terms be summed into the input to later terms?  While I would expect that any filter that could be realized the latter way could transformed into the form you've illustrated, I would aver that there is a useful subclass of IIR filters which can be formed from cascaded first-order filters (where each the output of each right-side term can feed itself but none of its predecessors)
Comment: @stevenvh: As I noted in my answer, there's a useful subset of IIR filters where a stage can feed back to itself but to no previous stage; I don't know that I've read of a term to describe such filters, but they're much easier to characterize than generalized IIR filters.  Although they could with the right coefficients be rendered in the form above, it would be harder to recognize such a filter (is there a term for them?) in that form.
Comment: @supercat - "can feed back to itself but to no previous stage". Not sure if I understand this correctly, but wouldn't that lead to an infinite loop? The calculation for a sample would never end.
Comment: @stevenvh: No, because each stage feeds back into itself after a delay.  A typical single-stage example would be "new_output = new_input * 0.1 + prev_output * 0.9".
Comment: I think the first diagram is wrong, and it should be \$1/a_0\$, not \$-a_0\$
Answer: There are two broad classes of digital filters, infinite impluse response (IIR) and finite impulse response (FIR).  Again broadly, IIR filters are equation-based and FIR filters table-based.
IIR filters are more like real world analog filters.  For example, consider a simple exponential decay like you would get from a R-C analog low pass filter.  The output response to a step input is a exponential that gets ever closer to the input.  Note that this exponential never actually gets to the output, only close enough so that we don't care or can't measure the error.  In that sense, such a filter is inifinite.  A IIR filter has the same characteristics.
The very common single pole low pass IIR filter can be expressed as:
FILT <-- FILT + FF(NEW - FILT)
This means that each iteration the output if moved a fixed fraction (FF, the "filter fraction") of the distance to the input.  This is easy to visualize when FF = 1/2.  If everything is 0 and the input suddenly goes to 1 and stays there (a unit step), then the output will be 1/2, 3/4, 7/8, 15/16, etc.  This is a infinite series.  Eventually the value will get so close to 1 that it is expressed as 1 since the digital values in the computer don't have infinite precision.
FIR filters work on a totally different principle.  A finite recent snippet of the input signal is saved, and each of the saved values is multiplied by a different coefficient, then all the results added to make the filter output for that iteration.  The next iteration the oldest saved value is discard, the others are shifted one slot older, and the new input is put in the vacated slot.  The new saved snippet is then multiplied by the coeficients, etc.  This process is known as a "convolution", and the table of coefficients often referred to as the filter kernel.  Some fancy and useful things can be done with this kind of filter by getting creative with the coefficients.  That's a whole topic onto itself that I won't go into now.  However, since a finite snippet of the input is stored in memory, any part of the input signal can only effect the output for a finite time.  Once a input sample is shifted out the end of the stored snippet it's gone and no longer has any effect on the output.
There are whole books written on this stuff and you can spend several semesters of college courses devling into this deeper.  Hopefully my 30 second overview demystifies this enough to answer your question.
Answer: One point not yet mentioned is that IIR filters may be further subdivided into two styles: those where the stages can be ranked, such that each stage is entirely dependent upon its own previous value(s) and those of earlier stages, and those where the stages cannot be ranked (because two or more stages depend upon each other).  It's possible for the stages in an FIR filter to make reference to the previous outputs of other stages, provided that they can be ranked as in the former style of IIR, and no stage refers to its own previous output.
If the stages in an IIR filter can be ranked, and if the total magnitude of the self-feedback coefficients for a given stage is less than one, the IIR filter is guaranteed to be stable.  If, for example, a stage includes some amount of signal from previous stages, plus half of that stage's previous value and 1/4 of the value before that, minus 1/8 of the value before that, the total magnitude of the self-feedback will be 7/8, so absent further input from lower stages the magnitude of the contribution from the self-feedback would diminish by 12.5% every iteration.
Answer: An FIR, does its math on a finite number of elements, lets say 32 or 12 or some number, but that is what the math does, take a finite number of elements and perform the filter only on those.
An IIR, does its math on all the samples you feed it.  If you feed it 10 samples and stop it then it worked on 10 samples, if you feed it 1,000,000,000 samples then the math operated on 1,000,000,000 samples.  And if you leave the thing running indefinitely, approaching infinity (let it run forever) then the number of elements likewise is indefinite approaching infinity.  Because the word finite clearly applies to the other model, and the IIR model is intended to not have a finite number of samples, the word infinite as the opposite to finite just sounds better than indefinite or some other such word.
Comment: "operated on 1,000,000,000 samples". Well, not directly. Because part of the output is used in the calculation for the next sample there will always be traces of previous samples. The filter will always hold a very limited number of samples. And it's not "indefinite"; it's deterministic, even if it may be unstable.
Comment: that is what I was implying that each sample has some but small effects from all the samples that preceeded it, for IIR.
Comment: The infinite vs finite number of elements in the calculation is *not* the difference between IIR and FIR. The most simple IIR works on only 2 elements of data: 1 from the input, 1 from the output.
Comment: The infinite is not from the number of inputs but the number of cycles accumulated, finite only takes N number of samples for a single input in the math, infinite effectively operates on every cycle.  Finite number of cycles vs infinite number of cycles for a single input.

IIR filters what does infinite mean?


Migration from Active directory to OpenLDAP

Question: Im pretty new to LDAP and AD. I have to port our present authorization/authentication structure from AD to OpenLDAP.
Is it possible to run the entire setup in windows? What are the steps for migration of the policies and adjustments req.?
I'v read up a few tutorials, so should be able to follow the inputs.
Regards, Anthony G.
Comment: Active Directory does a lot more than just provide a directory service like OpenLDAP. Do you want to just migrate the directory part of AD or do you want a complete AD replacement with free software?
Comment: Hi, We are aiming for a full replacement of AD, hopefully on the windows environment itself using OpenLDAP.
Answer: My first answer would be don't...
What I think you are actually asking is:  How do I port from Microsoft AD Domain to a Samba/OpenLDAP/Kerberos setup.  It's Samba that actually handles the authentication/authorisation side of things - OpenLDAP is just a directory.
Samba barely does group policies - you need to use the NTPOL editor from Windows NT4 days - it only has 70-80% of the functionality of XP local group policy (before some wise guy pipes up about Samba 4 - it's not out yet, one day maybe).  You can apply Samba policy only to user groups not computer groups- the list goes on.
There are no easy migration wizards, pretty much every Samba tutorial does it from scratch, which is what you may end up doing.  And in the end you will end up with a setup that is not as good as before - I suggest you think long & hard about whether it is the right thing to do (and yes I do support a Samba domain, and wish every day I had a Windows one).
Comment: Have to agree with this. There's a few things that I think come under the heading of "If you have to ask how, then you probably shouldn't" and this is one of them.
Comment: Actually, Kerberos handles the authentication in that trio.  Samba provides filesharing, policy, and an SMB interface to the backend functions.  You can use LDAP/Kerberos directly without going through Samba.
PADL does have some migration scripts which might be helpful.
Comment: @Borealid - Kerberos doesn't have to do authentication it's optional.
Answer:
OpenLDAP can run on Windows, yes.  I wouldn't really recommend it; if you're running a Windows server OS you'll get better integration with AD.
I don't think OpenLDAP policies and Active Directory policies are entirely compatible.  At the very least, OpenLDAP has a "config" directory not present on AD, and AD handles server referrals differently.  The two implementations also support different extensions (for instance, until very recently, the WHOAMI extension wasn't supported on AD).  You'll probably have to go back to your policy document and create new ACLs for OpenLDAP.
If you use strict schema enforcement, which you should, you'll have to find the right objectclasses for your AD data.  If you're just migrating users, nothing more, it might be easier to dump/import them than to copy the whole LDAP tree.  Watch out for password salting/hash algorithms.

If you're using AD authentication, your actual auth is Kerberos, not LDAP.  The user principals are stored in LDAP, yes, but the auth step is Kerberos.  OpenLDAP alone won't give you feature parity (Single Sign On) with AD.  You'll need to pair it with a Kerberos server, such as Heimdal or MIT Kerberos, for that.
This is not a simple or easy process.  For an organization of any size, this is something that should be done by an MCSE with a solid handle on enterprise software architecture and some experience with UNIXish operating systems.
Comment: Thanks Borealid. Right now i have to create the POC of the same. Expected user count might come to 300 with later expandability accounted for. For now I have to forgo the MCSE cert. part, as there are none in sight.  I have looked at JSSO for the single sign on part, though.(I'm new to SSO as well.)


How can I fix a broken shower elbow?

Question: The shower elbow in the shower broke off at the copper pipe in the wall, leaving some of the plastic inside the copper pipe's threading. There seems to be some sort of sealant. How might you go about removing the remaining plastic from the pipe? Is replacing and resealing the shower elbow something a homeowner could do, or is a plumber required? How might you go about doing that?
Comment: Pictures are always helpful.
Answer: By shower elbow, you mean this part, right?

If so, then to remove any remaining part left in the copper, get yourself some LONG needle nose pliars

Use those to remove any remaining plastic from the copper.
You can buy a replacement at pretty much any Home Depot or Lowe's - so buy one AND some teflon tape

IMPORTANT DO not buy the yellow package - that is for GAS, not water.  Blue and white or red and white packaging only!!!
Wrap 2 or 3 layers of tape around the wall end of the elbow.  Wrap it so that the tape follows the threading - so hold the pipe with the threads near you, start near you and wrap CLOCKWISE around the pipe.  That way as you screw in the pipe it won't peel off the tape.  Not too much tape or you won't get the pipe to fit!
Insert the elbow and turn it COUNTER CLOCKWISE slowly at first, until you feel the threads kind of click into place (avoid cross threading) and then turn it clockwise.  Hand tighten only but make sure it's nice and snug and vertical.
Then reinstall your shower head per mfg instructions.
Comment: +1. I was confused... I've never heard it called a "shower elbow", nor have I encountered one that was plastic.
Comment: I have seen plastic ones on cheaper shower heads.  I didn't know the term either, but google returned that image, so...
Comment: Unfortunately, the original contractor used superglue or something to seal the plastic in the copper pipe, and my roommate's handyman stripped the plastic trying to get it out. So we have to replace the pipe.

How can I fix a broken shower elbow?


CSS website background

Question: I am looking for some info on CSS style used for many websites these days. Its a style where whole screen is occupied by one background and the websites content is posted on top of it under smaller dimensions.
Something like this website: http://www.obiweb.com.au/
        How do we achieve something like this?
Comment: Have you tried viewing the source of that website?
Answer: This is easily achieved by using the css background property on the body tag:
body {background:#fff url(image.png) repeat 0 0}

You can read up on this css property here: http://www.w3schools.com/css/css_background.asp
You would then have a div container inside your body tag that has a width and margin set to auto:
.container {margin:0 auto;width:900px}

Hope this helps
Answer: They apply background image to body tag. Here is for example CSS  used by the site you mentioned in your question:
body {
  background:url("/site/default/images/bg_860.png") repeat-y scroll center center transparent;
}

You may read more about background property and its uses here.

CSS website background


Does Time division duplexing work this way?

Question: During the course of research, I have found a really hard time understanding this short lines below. I will appreciate a short hint or explanation from any expert in this area.
Comment: Did any answer help you? If so, you should accept the answer so that the question doesn't keep popping up forever, looking for an answer. Alternatively, you can provide and accept your own answer.
Answer: Time division duplex (TDD) concerns at least a 2 way communication. For example, a discussion is taking place between two people, say a and b, a talks whilst b listens, then b talks whilst a listens. A and b can't talk at the same time, hence timely divided and both share a time unit. Full duplex can be imagined as if both a and b talk and listen at the same time which double the amount of the information exchanged. Hope this helps.
Comment: Thank you so much for your kind response. when we use 50 devices based on TDD, and we have a maximum of 30 relays (for example), 25 of those devices can be transmitting to relays while the relays also transmit to another 25? i.e The relay receives 'input' 25 in a time slot while it sends another 25 in the different time slot?
Comment: So for instance based on the modified diagram above, the relays can receive a total of $\lambda_1P_{re}$ which is shared into two halves (for reception and transmission)?


What to do with an invitation from a friend in UK whom I wish to visit during a short holiday there?

Question: I have a friend in England ready to welcome me for a short holiday. Where or which office should he approach with his invitation for my visa application?
Comment: i don't ask for which kind of visa i need, i mean my friend can make for my the visa process in UK or any documentation plus the invitation letter from UK.
Comment: The question is not clear to me. Are you trying to visit a friend who's a resident in UK and you want to know which visa to apply for?
Comment: @pnuts that's not a comment, that should be the answer.
Comment: @pnuts, that's fine what you wrote.
Answer: None. Your friend doesn't apply for a visa for you, you do. This letter will be one piece of documentation you need, you will also need to prove ties to your country and so forth. For example, this is the site to check for if you are in India, this is Saudi Arabia and so on.
In general, in almost all cases it is you who apply for the visa. There are a few work visas where the employer applies but both for visits and immigration, the fundamental rule is the visitor/immigrant files with the optional help from some  entities in the target country.
Comment: OK i need to know much must be in my account when i apply for visiting visa (bank statements for the last six months) iam in Egypt.


Problems using Anaconda in macOS Catalina

Question: I recently upgrade to macOS Catalina and I made a clean installation Anaconda Navigator.
I install again Anaconda but it didn't work. I also reinstall the OS but didn't work too. The permissions of the files are ok, I can read and write files. I don't know why I can't open a file from Spyder. This is the image of my terminal in Spyder:
Comment: @klanomath I add an image.
Comment: I tested Anaconda 2019.10 Python3,7 in a 10.15 VM yesterday and had no problems to run self-made code..... Now I'd have to get 2019_Twitter... somehow. Is it available online somewhere?
Comment: Possible duplicate of [Restore Access to File System for Emacs on MacOS Catalina](https://apple.stackexchange.com/questions/371888/restore-access-to-file-system-for-emacs-on-macos-catalina)
Comment: @ankii In fact it's somehow related to the linked q&a, but it's almost impossible to set some allow-file-read-exec policy for all files/execs involved. So I have written another answer...
Comment: @klanomath I intended to leave it as a comment for related questions, but went for duplicate. It serves the purpose, while having another benefit of community's (and OP's) response.
Answer: The problems observed are related to the new system policy for user owned "system folders" like Documents, Desktop etc.
Here is a related syslog entry me trying to execute or open some script/file in $USER/Documents/ with Spyder/iPython:
<code>Sandbox: python(2233) System Policy: deny(1) file-read-data /Users/admin/Documents
Violation:       System Policy: deny(1) file-read-data /Users/admin/Documents
Process:         python [2233]
Path:            /Users/admin/opt/anaconda3/python.app/Contents/MacOS/python
Load Address:    0x103cbc000
Identifier:      com.continuum.python
Version:         ??? (???)
Code Type:       x86_64 (Native)
Parent Process:  bash [2232]
Responsible:     /bin/sh [/Users/admin/opt/anaconda3/Anaconda-Navigator.app/Contents/MacOS/run.sh]
User ID:         501
</code>
I had no problems to execute scripts in subfolders of Documents though.
One may add an executable to System Preferences > Security & Privacy > Privacy > Full disk access (see this q&a), but since too many execs may be involved, it's much simpler to create a new folder (e.g Development, Dev, Anaconda-Dev etc.) in your user folder and move your dev files & folders in there. The permission errors should disappear afterwards.


I am getting java.net.unknownhostexception in jmeter on server

Question: I am getting java.net.unknownhostexception in jmeter on server , while same test case works fine on my local machine. Can you suggest what configuration item is missing ?
Answer: I can only think of one possible reason: your "server" doesn't have direct Internet connection and it's using a proxy server for accessing hosts outside of its intranet.
JMeter by default considers that it has direct connection to the application under test, if this is not the case you can specify an upstream proxy for JMeter to use, it can be done in 2 ways:

By passing the upstream proxy server details via command-line arguments like:
jmeter -H your_proxy host -P your_proxy port ....

By passing the upstream proxy server details via system.properties file (lives in "bin" folder of your JMeter installation:
http.proxyHost=your_proxy_host
http.proxyPort=your_proxy_port
https.proxyHost=your_proxy_host
https.proxyPort=your_proxy_port

More information: Using JMeter behind a proxy


Why should blackbody radiation emit all the absorbed energy?

Question: So it is said that a perfect blackbody absorbs all the energy and then emits all of that in the form of blackbody radition. Why should it emit all the absorbed energy? Why can it not emit some and keep rest within?
Comment: Since it absorbs all the wavelengths (in principle), every radiation arising from it must be emission instead of reflection.
Comment: More on it [here](https://physics.stackexchange.com/questions/166729/if-a-black-body-is-a-perfect-absorber-why-does-it-emit-anything).
Answer:
Why should it emit all the absorbed energy? Why can it not emit some and keep rest within?

It can, for a while. If it does so it will get hotter, emitting more, until it reaches equilibrium.
Answer:
Why should it emit all the absorbed energy.? Why can it not emit some and keep rest within.?

If an object were able to emit with a different emissivity than it absorbed (at a given frequency) then it could be used to transport energy at that wavelength against a temperature gradient. In other words it would violate the 2nd law of thermodynamics.
Answer: Atoms in a body with temperature above zero Kelvin are subject of vibrations and during the accelerations of the involved subatomic particles they emit photons.
Image a closed volume with perfect (idealized) reflecting walls and inside two bodies of the same material, mass and form with different temperatures. The body with the higher temperature contains atoms with higher vibrations and by this emits photons, which in sum have of bigger energy as the stream of photons from the cooler body. Emitting and receiving photons, after a while both bodies have the same temperature. That is what happens around us all the time between all temperature differences and it is called thermal equilibrium.
Every material has its own characteristic of the emitted photons over the full spectrum of wavelengths.

Metal halid lamp spectrum

So it is said that a perfect blackbody absorbs all the energy and then emits all of that in the form of blackbody radiation.

A black body, as any body, temporarily absorbs the energy from all the photons which hits the body. If the body is cooler than the surrounding, it re-emits less energy as the body receives. If the body is hotter, it re-emits more energy as he receives.
Specific for a block body is its characteristic emission spectrum which depends only from its temperature (and not from its material):


Design Calculations for the Seasoned EE

Question: Do seasoned designers tend to do a fair amount of calculations or are large parts of circuits designed intuitively? I'm asking because it seems like design engineers tend to have a sense of what value cap you want to have here, resistor there, for common parts of circuits. If that's the case is it because they're just recycling designs?
To the novice this is mind blowing. Though, books like the Art of Electronics seem to encourage the approach of making approximate calculations on the fly.
Comment: When a greybeard pulls a component value "from the sky" it generally isn't by calculation. Pure intuition, maybe, or a hunch, or a very rough empirical estimate. Not often by doing mental integrals. Past experience can be a cruel teacher after all...
Comment: @inbinder, you are probably learning more than you realize. At some point you will help someone fix a problem and they will look at you with gratitude and amazement that you were able to help so easily.
Comment: It is a mixture of experience (remembering values that worked in the past in similar situation) and cognitive shortcuts (simplifying calculations so that approximate answers can be generated very quickly). A cognitive shortcut would be pretending Pi = 3 to help quickly compute the value of a filter component. An example of experience might be choosing the value for a DC blocking capacitor in a headphone application. You are probably going to use the same value in all your designs. You just need to remember what it is.
Comment: The other thing is that there are only so many choices. If you put a series resistor in a digital clock line, it is probably going to be 0, 10, 22 or 33 Ohms. You could do calculations based on load capacitance and rise time and setup and hold, or you could just pick a value, then look at the signal on a scope. I am more of a pick-a-value then look at the signal type of person, mainly because you have to do that anyway (you cannot release a design to production without verifying your choices).
Comment: And when you do have to do them do you just use Matlab or do folks do it the old fashioned way?
Comment: Oof. This is both re-assuring and sad. I don't have enough intuitive experience to really do stuff on the fly and sometimes get bogged down on calculation. Or I just borrow designs because I'm not doing anything that hasn't been done before. The tradeoff is that I then don't really understand the HOW and WHY.
Answer: I'm a professional electrical engineer who routinely designs new circuits for volume production, and have been for over 35 years.
Yes, I frequently do calculations to determine the exact part specs.  There are also many cases where experience and intuition are good enough and the requirements loose enough that I just pick a value.  Don't confuse that with a random value, though.
For example, for a pulldown resistor on the MISO line of a SPI bus, I'll just spec 100 kΩ and be done with it.  10 kΩ would work fine too, and someone else picking that wouldn't be wrong either.  If I'm using a 20 kΩ resistor elsewhere, then I might spec another one on the MISO line to avoid adding another part to the BOM.  The point is sometimes you have a lot of leeway, and intuition and experience are good enough.
On the other hand, looking at the schematic of my latest design, which I'm in the middle of bringing up first boards of now, I see a case where I spent some time not only specifying the part value but calculating the result of variance on the rest of the system.  There were three cases of two resistors used in the feedback to a switching power supply.  Here is the problem worded like homework:
A powersupply chip feedback input threshold is 800 mV ±2%.  You are using three instances of this chip, to make the 12 V, 5 V, and 3.3 V power supplies.  You have previously decided to use around 10 kΩ for the bottom resistor of each voltage divider.  Determine the full resistor specs in each case, and determine the min/max resulting nominal supply voltage.  Stick to readily available resistor values.  Use 1% if suitable and spec accordingly.

That's a genuine real world problem that took a few minutes with a calculator.  By the way, I determined that 1% resistors were good enough.  That's actually what I expected, but did the calculations anyway to make sure.  I also noted the full nominal range for each supply right on the schematic.  Not only might this be useful to refer to later, but it also shows that this issue was considered and the calculations done.  I or someone else won't have to wonder a year later what the tolerance of the 3.3 V supply is, for example, and re-do the calculations.
Here is a snippet from the schematic showing the case described above:

I just picked R2, R4, and R6, but did the calculations to determine R1, R3, and R5, and the resulting power supply nominal ranges.
Added about the SHx parts (response to comment)
The SH parts are what I call "shorts".  These are just copper on the board.  Their purpose is to allow a single physical net to be broken into two logical nets in the software, which is Eagle in this case.  In all three cases above, the SH parts connect the local ground of a switching power supply to the board-wide ground plane.
Switching power supplies can have significant currents running across their grounds, and these currents can have high frequency components.
Much of this current just circulates locally.  By making the local ground a separate net connected to the main ground in only one place, these circulating currents stay in a small local net and do not cross the main ground plane.  The small local ground net radiates far less, and the currents don't cause offsets in the main ground.
Eventually power has to flow out of a power supply and return via the ground.  However, that current can be filtered much more than the high frequency internal currents of a switching power supply.  If done right, only the well behaved output current of the switcher makes it out of the immediate vicinity to other parts of the overall circuit.
You really want to keep local high frequency currents off the main ground plane.  Not only does that avoid the ground voltage offsets those currents can cause, but it prevents the main ground from becoming a patch antenna.  Fortunately, many of the nasty ground currents are also local.  That means they can be kept local by connecting the local ground net to the main ground in only one spot.
Good examples of this include the path between the ground side of a bypass cap and the ground pin of the IC it is bypassing.  That's exactly what you don't want running across the main ground.  Don't just connect the ground side of a bypass cap to the main ground thru a via.  Connect it back to the IC ground via its own track or local ground, then connect that to the main ground in one place.
Comment: Good thinking in having the nominal range of voltages on the schematic, BTW.
Comment: @Bip: See addition to answer.
Comment: Can you show us snippet of the layout? I am asking because of SH1/SH2/SH3. Is the ground of dc-dc connected with main ground plane in one point only?
Answer: I do mainly low volume commercial & industrial market stuff, so this may be different elsewhere.
At least 75% of a typical schematic is usually building block sort of engineering, "I need a 5V rail at 3A, 5% tol, I have 15V", there is nearly no point in designing that, when Ti/Linear/Micrel have all got perfectly good designs in their datasheets, it is just a case of picking one (And the choice usually does not much matter). I can of course design from first principles, but that is not what I get paid for.
Same thing applies for many other subsystems.
Then there are the "It just needs to have the right order of magnitude" cases, pull up and pull down for cmos, series resistors for indicator LEDs, stuff like that. My usual practise here is to leave figuring these out until I see what values I need in those few places it really matters, then pick something from those values if at all possible.
"Power on LED, green, 12V rail? Ok, led will drop a couple of volts more or less, and I probably want somewhere in the 1 - 10mA or so range, so anywhere in the couple of K region will be fine, oh look I needed a 3k9 resistor for that filter, one of those will get it done".
The real trick is knowing when that 'finger in the air' guess is NOT going to cut it, usually things like filters, matching networks and timing circuits, pll and other feedback things involving significant phase shifts are likely bad places for guessing. Places like that where you actually do need to get your math on (Usually matlab/scilab/ads will get the job done, no need to actually remember much of the standard tables of integrals beyond the very basic trig).
It is actually quite rare (and very nice when it happens) to end up in that place where the electronics meets the physics meets the maths, sure it happens, path loss calcs, noise calcs when doing analogue, that sort of thing, but that is maybe 10% of a design, the rest is usually cookie cutter stuff.
Comment: matlab/scilab/ads - what is ads here ?
Answer: Particularly when using an analog IC, there will typically be one or more suggested application circuits in the datasheet.  For example, I am currently designing a Qi receiver for a project.  The capacitors in the inductive loop are dependent on a number of variables, and the datasheet provides some equations for determining their values:

So it is just a matter of plugging in the numbers, breadboarding the circuit and trying it out.
Comment: And if the datasheet doesn't help you, don't forget to take a look at the application notes (AN-documents).
Answer: For analog design, we do the calculations for most part.  Some things, like coupling and bypass/filter capacitors we might just pick a "typical" value, knowing that it's going to work for the application.  But note that "typical" will be different for DC, audio, and radio circuits -- this is something we have to be familiar with.
For bias and gain resistors we usually do the calculations.  I do them by hand, since the equations are simple.  Often we want a "gain of about 10" circuit, so the ratios are simple enough to do in your head, and the values (1K vs 1Meg) are chosen for the type of circuit.
Answer: The accuracy required by your application, is what dictates the amount of reuse, intuitive design, and/or formal design that one would use.  One example of each is: audio amplifier, low noise amplifier for TV, and ultra low noise amplifier for a radio telescope, respectively. It should be clear that how "formal/accurate" your design should be, depends on how "critical" the application is (as well as how much time and money is available for the design).

Design Calculations for the Seasoned EE


What XLM asset markets allow for greater than 7 decimal places

Question: I am using lobstr and own Sovereign Gold Bond asset (SGB swisscustody.org). When I trade it says 0.0000000 XLM, but the dollar value of my holdings keeps fluctuating. Lobstr does not allow trading with values more than 7 decimal places. How can I trade the true value of assets? Thanks in advance.
Comment: Did you only add the trustline or also add funds of said asset?
In general please DYOR **before** interacting with assets as there are many scam assets (especially from the domain you mentioned).
Answer: Stellar amount representation uses a fixed 7 decimal digits, this cannot be changed by clients and this is a hard coded limit on stellar. The minimum exchangeable value is 0.0000001, also called a stroop.


Are all the paired sentences grammatically correct? And do all those sound natural to native speakers?

Question: I am an English teacher who has a duty to teach correct English to the students who want to learn it. That is why I think I have to know grammatically correct English because it can destroy my students' lives if I teach them wrong or incorrect English. And one of my students asked me which of the two is correct or if both are correct. But for me, passive sentences sound unnatural, but I am not sure about that. That is why I am asking native speakers or grammarians which of the two is grammatically correct or which of the two sounds more natural to native speaker.

The car is too old to repair.
=The car is so old that we cannot repair it.
The car is too old to be repaired.
=The car is so old that it cannot be repaired.
The coffee is too hot to drink.
=The coffee is so hot that we cannot drink it.
The coffee is too hot to be drunk.
=The coffee is so hot that it cannot be drunk.
Microbeads are too small to filter out during the waste water treatment process.
=Microbeads are so small that we can not filter them out during the waste water treatment process
Microbeads are too small to be filtered out during the waste water treatment process.
=Microbead are so small that they cannot be filtered out during the waste water treatment process.
Answer: All the sentences are grammatically correct, but I do have a few comments:

The sentences on the left are more concise, I would prefer them over the sentences on the right, even though both are correct and have the same meaning.
Sentences 1, 3 and 5 (left) use active voice, while 2, 4 and 6 (left) use passive voice.  (All the sentences on the right use active voice.)  Usually active voice is preferred, but passive voice is acceptable in most settings.
Sentences 1, 3 and 5 (right) sound unnatural, probably because you added "we".  It seems like these sentences have a lot of extra words and can be made simpler.

A few additional, unrelated notes

I'm assuming "filterout" in sentence 5 is supposed to be "filter out."  Use two separate words.
"Wastewater" is a compound word with no space in between.
Comment: I think the poster meant to say that the concise sentences on the left are preferable to those on the _right_!
Comment: •The sentences on the left are more concise, I would prefer them over the sentences on the left,- What do you mean by "them" in this sentence? I am confused.
Comment: Thanks for pointing that out, it has been fixed.


Light Switch Wiring Issue

Question: I have just received a set of light switches but have been unable to fit them because the small screw in the COM connector doesn't screw far enough to grip the live wire.  I'm sure it must be something I am misunderstanding.  Anyone offer any suggestions please?
Answer: Congrats on including a picture unprompted! You'd be shocked at how many people don't do that...
I presume you've stuck the wire in the plastic hole and have tightened the screw down only to discover that it doesn't touch the wire, much less hold it tightly. That's a good sign you're attempting to wire it incorrectly.
Back the screw out almost all the way. You'll see the little brass plate dropping down to create a gap. If the screw comes toward the screwdriver and the plate doesn't move, push down/wiggle on the screw until it pops loose. Now, put the wire above the brass plate and tighten the screw. That will pull the plate up and squeeze the wire in tight. This method applies, of course, to all the screw on connections, not just the COM wire.
Your switch should come with some instructions that include torque specs. You really should tighten the screw to the spec torque. If it's too loose, the wire can wiggle loose over time as the entire switch assembly moves every time you flip the switch. That looseness can begin to cause arcing and arcing can cause fires. If you can't find the torque specs on the switch itself or on the packaging/instructions, there should be some "generic" specs available online for your jurisdiction (assuming somewhere in the UK based on the "made in UK" labeling).
Comment: Thanks for your detailed response.  It all made perfect sense and I went back to the switches with renewed enthusiasm.  Alas nothing I do makes the bracket drop to enable a wire to be inserted.  Tried with two switches and even fully removed the screws and tried pushing the bracket down with the screwdriver from above.  Nothing moves at all.  I've put some markings on my picture to indicate my current understanding of what you said.  I was expecting that tiny gab to open up to enable me to insert the wire.
Comment: @PJW looking at your arrows, that's exactly what I would have expected to happen as well. To follow up with a potentially stupid question... Have you read the instructions? What do they say to do?
Comment: there were no instructions with them, other than a warning to earth the metal plate (which seems odd given they are plastic).  Anyway, and I apologise for my stupidity here, but after lots of messing about, shaking, screwing and unscrewing, the screws suddenly started to go in far enough to bite down on the wires.  Seems they were just very tight, or threaded badly, but they now work.  Thanks for your assistance.
Answer: Same issue for me and solved. They do screw down. They're just a bit stiff.

Light Switch Wiring Issue


Plural or singular: grammatical, not semantical

Question: I heard that a plural and a singular are not related to semantics but to grammar. Then If I ate two pizzas, it doesn't matter whether I say 'I ate a pizza or I ate pizzas'?
Comment: Whoever told you that "plural and a singular are not related to semantics but to grammar" was either talking complete rubbish or was saying something relevant to an extremely limited context that you haven't understood. If you ate two pizzas, you *could* validly refer to this by saying *I ate pizza* (uncountable; you could have eaten ***a tiny bit*** of just one pizza, or ***all of any number*** of pizzas).
Comment: @FumbleFingersReinstateMonica I believe I said something of that kind in a brief comment at https://ell.stackexchange.com/questions/271460/do-dictionaries-sometimes-say-nonsense .  It could have been much better expressed, but should be read in the context of that question's focus on "trousers" and whether the "natural" number of the item matched the grammatical number of the noun. My answer to the present question better explains the point I wanted to make.
Comment: @rjpond: oic. So that's my "something relevant to an extremely limited context" alternative. Syntactically, things like trousers and scissors are plural, even though *semantically* they're "singular". But for the vast majority of contexts, syntactic singular goes with semantic singular - and the same "principle of consistency" applies to the grammar and meaning of ***plurals***.
Answer: If you ate a pizza, you ate one pizza, however big or small.
If you ate pizzas, you ate more than one pizza.
If you ate pizza, you ate a certain amount of pizza, whether (slices of) one or more,
Answer: If you had eaten two pizzas:

You could say "I ate pizza" (using it as an uncountable or mass noun - such nouns are singular).  ("Rice" is another example of a mass noun.  It is very rare to use "rices", though you might occasionally come across it where two different types of rice are being compared.)
You could also say "I ate two pizzas".
"I ate pizzas" with no number specified would mean that you had eaten two or more, but is not a very common wording.  ("I ate some pizzas" is more common, but would suggest three or more.)
You could say "I ate a couple of pizzas".
You could say "I ate a pizza".  Some people would find it misleading, but many people would consider it technically correct.  "A" expresses a weaker sense of oneness than "one".  If you said "I ate one pizza" then you would definitely be misleading people.

Grammatical number is, as its name suggests, a matter of grammar.  However, this doesn't mean it can be divorced completely from meaning.  It does mean that the relationship is not a straightforward one - in the same way that we sometimes use the present tense to describe future events, so there is no simple equation between present tense (grammatical) and present time.  Similarly, the equation between grammatical number and real-world number comes with caveats.  You may consider trousers to be singular, but grammar considers them to be plural (until qualified as "a pair of", when the noun phrase as a whole then becomes singular, because the word "pair" is singular grammatically - even though it means "two"!).
Comment: It's very good, but it's better to say 'I ate pizzas is also right'!


Projective embedding of curves which preserves the degree

Question: Let $C$ be a projective curve (not necessarily reduced or irreducible).
Let $f:C \hookrightarrow \mathbb{P}^n$ be a closed immersion. Suppose that the degree of $f(C)$ is equal to $e$. How many ways are there to embed $C$ in $\mathbb{P}^{n+1}$ such that the degree of the image is equal to $e$? Can we "parametrize" such embeddings in any way?
Comment: Many ways! Let us say that $C$ is smooth of genus $g$, and take, say, $e>2g+5$. You can find an embedding in $\mathbb{P}^3$ of degree $e$ -- but every line bundle of degree $e$ will give you plenty of embedding of degree $e$ in $\mathbb{P}^4$.
Answer: These embeddings can indeed be parameterized. Explaining parameterizations of projective embeddings of a fixed degree is one of the main themes of the book: Geometry of Algebraic Curves: Volume I by Arbarello, Cornalba, Griffiths and Harris (ACGH).
You should especially read chapter IV: The Varieties of Special Linear Series on a Curve, where they describe the parameterization. Although the exposition in this chapter is for smooth curves over $\mathbb C$ the main approach generalizes. All that one needs is that the $Pic$ functor is representable.
Some results about "how many ways", i.e. the dimension of the parameterization can be found in chapter $V$. I don't know how these results generalize to non reduced or reducible curves.
The main approach of these kind of questions is as follows. If $g : C \to \mathbb P^n$ is a morphism then the pullback of the twisting sheaf $\mathcal O(1)$ on $\mathbb P^n$ gives a line bundle of degree equal to $e$. And if we write $\mathbb P^n = {\rm Proj \,} k[x_0,\ldots,x_n]$ then the $f^*(x_0),\ldots, f^*(x_n)$ are global section which will generate $f^*(\mathcal O(1))$. In fact from the linebundle $f^*(O(1))$ and the $n+1$ sections that generate it one can also contsruct the morphism $g$ again. So you see that your question is basically comes down to parameterizing linebundles together with a set of $n+1$ sections that generate it.
In particular the parameter space you are looking for will be an open subscheme of the scheme $G_e^n(C)$ in chapter IV of ACGH, it will not be all of $G_e^n(C)$ because you have to remove the closed part where the sections of de $g_e^n$ don't generate it.


Reliable UDP in a kernel module

Question: How can I develop a Linux kernel module in order to make UDP reliable? How to change the default UDP behaviour in linux kernel by loading a new kernel module? And how to program such kernel module?
Comment: @suresh: since this is a college assignment (as you commented below), please edit your question and tell us what you were thinking of doing. Just asking outright for an answer will not be well received.
Comment: you cant change the nature of an existing on the wire protocol. The thing that makes UDP 'unreliable' is that routers along the way between your two endpoints are free to drop UDP datagrams when traffic gets heavy. You can't change this by changing the systems at either end.

Do you mean you want to invent a module 'on top' of UDP?
Comment: Take hints/features from TCP. Things like acknowledging received packets.
Comment: It might help for you to define what is meant by "reliable".
Answer: Reliable UDP is not the same as just using TCP. There are a number of differences but the most predominant is that you are guaranteed to always receive an entire UDP message or not receive it at all.  Whereas, it is not only possible but very common to receive partial TCP messages.
Since this is just a homework assignment I would suggest just implementing a single send message, wait for an ACK, send next message routine with a timeout.  If the timeout kicks in then resend message some number of times before declaring a failure.  Yes, this will be slower than necessary.  There are lots of techniques to improve throughput, but for your assignment the odds are that you don't need to use them.
Comment: I'm voting this up but you will most likely need to add sequence numbers to correlate the messages with the ACKs.
Answer: There actually is reliable UDP, it's called RUDP, and it was invented for Plan 9. However, there really is no point to this, just use TCP.
Edit: Also, UDT might be useful. It is based on UDP, but is reliable.
Comment: How did this get 10 upvotes? Downloading someone else's code and handing it in as your own assignment will get you a fail grade incredibly fast.
Comment: @paxdiablo: I was not suggesting that the OP use this code for his assignment, but it would be good to look at to get an idea where to start. I also wanted to combat all the posts that claim that there is no such thing as reliable UDP (of course, there really isn't, the abstraction is "leaky", but it would be as reliable as TCP is).
Comment: @Zifre: RUDP does not "make UDP reliable", as asked by the question.  It's a completely different protocol.
Answer: Those who keep telling the poor guy to "just use TCP" ignore that there are good reasons why a reliable UDP implementation would be used over TCP - and it's not datagram semantics (which dead easy to layer on top of TCP)
A primary legit driver is connectionless communications to/between many nodes that could otherwise require carrying excessive connection multiplicity
This is often used for broadcast datafeeds, intra-cluster system software communications, etc.
Comment: UDP is better for software-based network redundancy mechanisms, like dual link failover.
Answer: I use UDP a lot, and the main "reliability" issue I end up seeing is lost packets (particularly in fragmented IP packets). You could probably do 90% of what needs to be done by preventing fragmenting (add a layer that chops up datagrams into IP-sized chunks), and by having the recipeint detect and request resends for lost "chunks".
However, this kind of thing is really what TCP was invented for. UDP is best used for time-sensitive data that would be stale on a resend anyway.
There is a network topological solution. Just arrange things so that there can't be any collisions (the #1 source of lost packets on a LAN). Here's what we do where I work to make UDP reliable:

Put one client and server on a dedicated ethernet link (perhaps a switch between them, but no other systems on their private LAN).
Keep a strict client-server communications protocol on the UDP LAN. The server is never allowed to talk, except in response to the client.
Turn off all exteranious networking garbage on that UDP link (Netbios, etc).
Make ARP entries on both ends static (so ARP won't interfere once every 10 minutes).

(Note: The last one is particularly important. On many systems IP packets that cause an ARP request are just thrown away, rather than sent after ARP is resolved).
Comment: The big reason we use UDP over TCP is the number of connections. We have thousands of devices sending small packets to one location to be put into a db and that number of connection kills the server.
Comment: Well, our "network topological solution" certianly wouldn't work for you Rex. It requires a separate physical network for each client. I'd say you just need a less limited implementation of TCP. Sad if you have to implement it yourself, rather than tweak a setting somewhere.
Answer: The techniques for reliable transmission of data are collectively known as "ARQ", which stands for Automatic Repeat reQuest.
It's too verbose a subject to explain here, but the wikipedia pages are a good place to start, but little more than that. I recommend you pick up one of the text books on computer networking (e.g. Tanenbaum or Kurose/Ross) and go from there. If you think it suffices for your assignment, implement basic stop-and-wait ARQ and forget about the more advanced ARQ schemes, they're a lot more work to build.
I have no experience developing Linux kernel modules, but if you go for one of the more advanced ARQ schemes I wouldn't be surprised if the implementation of the ARQ mechanism turns out to be more work than packing that as a kernel module.
Good luck with your assignment.
Answer: I think asking how to make UDP reliable may be approaching the question the wrong way.  UDP is unreliable more or less by definition - ipso facto.  You aren't going to get anywhere making the OS-side implementation of the protocol more "reliable."
A great many applications that use UDP use it because they need the low-overhead, low-latency nature of it much more than they need the precise reliability of TCP.  But almost all of these applications still need some mechanism for verifying end-to-end receipt of certain types of messages, and perhaps even reassembly and/or initial handshaking.  Think about SIP in VoIP telephony, for example;  TCP's latent three-way handshake and very gradual congestion control aren't really acceptable for decent call setup time or QoS, but some way of acknowledging messages is definitely needed (that's what provisional responses are for, in SIP terminology).  Or various protocols in use by online games -- same basic idea.
It is very likely that the real intent of the assignment - even if is not stated clearly - is not so much to make UDP reliable as to create a simple program that uses UDP and has some primitive reliability abstraction layer within its own communication scheme, encapsulated in UDP as it were.
Answer: Overlay TCP on top of UDP, as TCP already does. 'Reliable UDP' is an oxymoron. It's not designed to be such.
Comment: Minor nitpick, TCP isn't a layer on top of UDP, it's a layer on top of IP.  UDP is a very thin layer on top of IP.
Comment: +1 You *can* put whole IP packets on top of UDP as shown by openvpn. There is NO fundamental reason you cannot do this.
Comment: @Marcelo: It's possible, yes.  But TCP does not do this.
Comment: It's been a long time since I was down in the guts of the networking stack :-)
Answer: If you absolutely need a message-based transport layer protocol where you can turn off some of the TCP reliability features like head-of-line blocking, check out SCTP. The API even has a "UDP mode" that masks the underlying connections.
It's still a work in progress, so you can't expect users to have it -- but if you only need it for computers you maintain, it should be fine. It's implemented in various flavors of unix, though FreeBSD is where most of the development work happens. YMMV.
Comment: And -1 since it's a homework assignment. That means OP needs to write their *own*.
Answer: If you want more information on how to modify the Linux Kernel, my first response is to google "linux kernel" and maybe even add "socket" to it.  The Linux Kernel website looks like it might have some other leads for you to follow.
My suggestions are that
1) Look at how UDP is implemented in Linux
2) Look at how RUDP is implemented (as somebody already mentioned)
3) ... (you make magic happen here)
4) Profit! err... Finished Homework!
Comment: I have some idea to make udp reliable.. but dunno how to do it via module... how the default udp behaviour is changed by loadin a kernel module....
Comment: The only real suggestion I can give you is to go look at how the current code is implemented in Linux for sockets.  Then, see about compiling your own derived kernel and drop it in as a replacement.  Bootloaders allow multiple kernels, so drop yours in as an alternative for testing and debugging.
Answer: I'm not sure that there is a simple way to modify the behaviour of the existing UDP code via a new module.
What would be simpler is to take the UDP code (net/ipv4/udp.c) and create a new module with a new IP protocol number, and modify this code to implement your reliable UDP protocol. You will need to rename all the external symbols so the names dont clash with the existing symbols, find out where it registers the protocol number (17) and change that, and then update the Makefile to build your new module and probably put an entry in Kconfig.
Have a look in /etc/protocols to see what protocol IDs are allocated already.
Edit: It looks like that udp.c cannot be built as a module. You will need to look at some of the other protocols (such as ipip.c or ip_gre.c) to see how to make your code into a module.
Answer: To be honest I wonder if this is a trick question.  It takes two parties to communicate and absolutely nothing you do can ensure the sender knows (or cares) that you want it to resend a packet unless you have already established a protocol to communicate this wish.  If UDP itself can do this, I strongly suspect the kernel already supports it.
What you're left with is identifying and implementing a module that implements a new protocol. There's nothing wrong with that, others have already given you suggestions, and I'm sure that you can use the UDP implementation to handle the actual packet transport.  But just remember that it's an implementation of a new protocol, not just twisting UDP a little to get new functionality in it.
Answer: You need to think about what reliable means.  Also you need to decide if you need the packets in order or if out of order is ok. If out of order is ok you need to come up with an ACK, re-transmit, and timeout scheme. Also you need to decide if you are going to handle packet fragmentation.  If you can get away with it yo might want to limit the size of a packet to prevent fragmentation.
Answer: Possibly what you may be getting stuck on is the concept 'reliable'.  Do you have a clear concept of what, exactly, in technical terms, you mean by that?  (Or, more relevantly I suppose, what your instructor means by it.)
When you have a precise idea of what characteristics a protocol has to have for you to call it reliable, that's likely to provide directions for you to work in.  Building to that as a minimal requirement, rather than getting lost in more fully-featured real-world implementations, may also make completing your homework more feasible.
Comment: I need to know to make module to do it...I have some idea to make udp reliable.. but dunno how to do it via module... how the default udp behaviour is changed by loadin a kernel module....
Answer: If you want a reliable UDP, your best choice is to use the SCTP (Stream Control Transmission Protocol). It is now a well-established protocol used everywhere.
Answer: If for some reason you MUST use UDP (seriously, just use TCP) some quick and easy reliability features would be a presence heartbeat, acks, and xor'ed checksums.
Comment: -1. "Seriously, just use TCP" - and will you go up during the evaluation and explain to OPs professor why he chose to do a totally unrelated assignment? Instant fail.

Reliable UDP in a kernel module


How to power STM8(S105C4) chip? Is decoupling needed?

Question: I have a MCU STM8(S105C4) with which I need to design a PCB to power from a USB. But I don't know how to power it. I've tried searching the specification for this MCU but all that I could find is that the input voltage should be from -0.3 to 6.5 V. The interesting thing it that for STM32 MCU's that the specification has a power scheme included. If anyone has any ideas that could help me out, that would be great.
Comment: You need to read the datasheet again. No MCU will operate at -0.3 V.
Comment: Also, assume that decoupling is always needed for every IC you use until proven otherwise. And welcome to EE.SE!
Comment: Ah, i now see that i was looking at absolute voltage characteristics. So Im guessing that operating voltage should be 3.3 volts. Thanks and thanks again.
Comment: While the STM8 and the STM32 are fairly different parts, if you find a schematic for a USB-powered STM32 board (or pretty one with pretty much any other 3v3 MCU), the same 3v3 regulator setup would work for you.
Answer: The voltages you are referring to are the absolute maximum limits where the part will not be damaged if you apply said voltages.
What you want is the operating voltage, which in your case is 2.95 to 5.5 V as stated on the datasheet. This value is usually shown on the first page of the datasheet, and again a few pages further down, in section called Operating conditions, in your case page 54 of the datasheet.
It is then down to you to decide how to power the MCU, depending on what you connect to it, and your power source.


Time Limit for Negligent Charges

Question: If it was just discovered that, 8 years ago, someone unknowingly gave medicine to another to cure an STD - that they weren't aware they had - is it still possible to press charges in the state of Illinois?
Comment: "Someone [..] gave medicine to another"... is one of those someone's you, or your dependent?
Comment: What charges do you contemplate? Do you mean to sue for money damages (and if so what were the damages) or to prosecute some for a crime which is usually what "press charges" refers to. "Negligent charges" doesn't really make sense in this context.
Answer: The statute of limitations for criminal prosecution has passed in Illinois (3 years for a felony). There are some exceptions if the crime is murder, or the accused has fled the state. This is based on when the act occurred. A civil action for personal injury is also possible, which has a statute of limitations of 2 years. This is "within 2 years next after the cause of action accrued": the statute does not specify what that means. Illinois follows what is known as the "discovery rule", meaning after the injury was discovered (for example a brain injury caused by a hit on the head), specifically (Knox College v. Celotex, 88 Ill.2d 407)

when a party knows or reasonably should know both that an injury has
  occurred and that it was wrongfully caused, the statute begins to run
  and the party is under an obligation to inquire further to determine
  whether an actionable wrong was committed.

So the two primary question are, has an injury been suffered (probably, but not definitely), and is a lawsuit time-barred – that depends on the specifics of the case (hence consultation with an attorney is necessary).

Time Limit for Negligent Charges


Strange event crosstalk: Mouse & Keyboard, WPF & Rx?

Question: I've written a really tiny WPF + Rx program in VS 2010, and it has some unexpected behavior -- seemingly picking up alt-key events in the mouse-event observables. I'd be grateful for advice on any of

what's specifically wrong
ideas or tools on how to diagnose it further on my own [e.g., are there some tools that instruments the code to track and log all events that get fired so I can see more clearly what's happening?]
how to understand the behavior -- is it "by design"? Am I misusing WPF or Rx or both?
how to get the behavior I'd rather have, described below

First, what it does correctly is fire mouse move observers starting from a mouse down and ending with a mouse up. The particular test observer I have just puts the proper mouseDown + mouseUp coordinates in the TitleBar of the Window (see code + XAML below).
The strangeness starts if I press and release the alt key while the mouse is down. That seems immediately to stop the mouseMove event observers. Now, if I release the mouseButton, the mouseMove event observers start up again, and continue until I either generate a new mouseDown or press and release alt again. Further more, if I go through this sequence, namely
mouseDown
mouseMove
alt-key down
alt-key up
mouseUp
alt-key down
alt-key up

and then, the normal
mouseDown
mouseMove

the print in the Title bar has some odd flashing, telling me that there are other, extraneous events getting tracked and pumped through my observer lambda.
I haven't been able to make this fail with keys other than alt, deepening the mystery.
The desired behavior could be

either checking for alt key state explicitly in the mouse-move handlers
or separate event streams for the keyDown and keyUp events, and I'll figure out the interleaving in my code

But, for sure, having this behavior and, worse, having no clue how to proceed to understand it, is really bad. I'll be grateful for any ideas!
(NOTE: add references to System.coreex, System.Reactive, and System.Interactive)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Input;

namespace DownAndMoveTest
{
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            (from mDown in this.GetLeftMouseDownObservable().
                 Do(e => this.Title = "DOWN: " + e.EventArgs.GetPosition(this).ToString())
             let mDownP = mDown.EventArgs.GetPosition(this)
             from mMove in this.GetMouseMoveObservable().TakeUntil(this.GetLeftMouseUpObservable())
             select new
             {
                 D = mDownP,
                 M = mMove.EventArgs.GetPosition(this)
             }).Subscribe(ps =>
             {
                 this.Title = String.Format(
                   "Window MouseDown({0:G}, {1:G}), MouseMove({2:G}, {3:G})",
                   ps.D.X, ps.D.Y,
                   ps.M.X, ps.M.Y);
             });
        }
    }
    public static partial class UIElementExtensions
    {
        public static IObservable<IEvent<MouseButtonEventArgs>>
            GetLeftMouseDownObservable(this UIElement uiElement)
        {
            return Observable.FromEvent<MouseButtonEventHandler, MouseButtonEventArgs>(
               h => new MouseButtonEventHandler(h),
               h => uiElement.MouseLeftButtonDown += h,
               h => uiElement.MouseLeftButtonDown -= h);
        }

        public static IObservable<IEvent<MouseEventArgs>>
            GetMouseMoveObservable(this UIElement uiElement)
        {
            return Observable.FromEvent<MouseEventHandler, MouseEventArgs>(
               h => new MouseEventHandler(h),
               h => uiElement.MouseMove += h,
               h => uiElement.MouseMove -= h);
        }

        public static IObservable<IEvent<MouseButtonEventArgs>>
            GetLeftMouseUpObservable(this UIElement uiElement)
        {
            return Observable.FromEvent<MouseButtonEventHandler, MouseButtonEventArgs>(
               h => new MouseButtonEventHandler(h),
               h => uiElement.MouseLeftButtonUp += h,
               h => uiElement.MouseLeftButtonUp -= h);
        }
    }
}

and its XAML
<Window x:Class="DownAndMoveTest.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525">
    <Grid>
    </Grid>
</Window>

Answer: Does your application have a main menu? Pressing the alt key focuses the menu bar, and pressing alt again returns focus to whatever had focus before. This would explain the functionality you are seeing. (It does not look like an Rx issue)
Comment: I'll take a look at that, Richard. I didn't do anything to specifically put a menu in the app (the XAML above is the whole thing), but the whole WPF "Command" infrastructure seems to be active and that may be doing it. The snoop tool is helping me a bit. blois.us/snoop.


Is there a mathematical relationship between the spread on a collection of individual assets and the spread of a portfolio?

Question: If the spread on each individual asset in a portfolio is known (and the duration and market value of these assets is also known), is there a relationship that can be used to deduce the spread on the overall portfolio containing these assets?
Comment: Hi,could you please define 'spread'?
Comment: The additional gross redemption yield on the asset/portfolio above the risk free rate of interest
Comment: So we are talking yield spread, ok. I'll think on it :)
Answer: You need to define what you mean by the portfolio spread. Here I define it as if the portfolio is itself a single bond and you want to calculate its yield spread over the risk-free rate $r$. Here I consider the gross redemption yield and the yield-to-maturity. You choose which is better. This makes the resulting spread comparable to that of other fixed income securities of the same maturity and similar credit quality.
If you have a portfolio of $N$ fixed income securities each with a yield spread $s_i$, full price $p_i$ and portfolio weight $w_i$, then the yield spread of each security equals $s_i=y_i-r$ where $y_i$ is the yield of each asset $i$.
We can calculate $y_i$ if the full price of asset $i$ is $p_i$ and the coupon of asset $i$ is $c_i$ using either the gross redemption formula
$y_i = c_i/p_i$
or you solve for the YTM $y_i$ using the standard price-yield formula
$p_i = \sum_{t=1}^T \frac{c_i}{(1+y_i)^t} + \frac{1}{(1+y_i)^T}$.
BONDS PRICED AT PAR
In the simplifying case when all the assets are priced at par $p_i=1$, and have the same maturity date, we have $y_i=c_i$. Note that $\sum_{i=1}^N w_i = 1$. Hence the value of the total portfolio $p$ is also par as
$p= \sum_{i=1}^N w_i p_i = 1$
The total coupon is $c = \sum_{i=1}^N w_i c_i$. As the bonds are priced at par, the gross redemption yield spread of the portfolio equals
$s = \sum_{i=1}^N w_i c_i - r$.
This is also the same if we are using the YTM in the spread definition. Note that if $c_i$ is the same for all assets then $s=s_i$ as all yield spreads are the same.
BONDS NOT PRICED AT PAR
When the bonds are not priced at par, you must find the portfolio yield. Using the gross redemption yield gives
$y = c/p-r$
and for the YTM you need to solve for $y$ using
$p = \sum_{t=1}^T \frac{c}{(1+y)^t} + \frac{1}{(1+y)^T}$
where $p, c$ are the portfolio value and coupon as defined above. From this you can get a yield spread $y-r$. In this case it's not a simple formula of the coupons. Instead you need to calculate $c$, $p$ to calculate $y$ and then $s$. This is simple to do in a spreadsheet. The portfolio yield spread will of course be related to the values of the $y_i$, but not in a simple formula.
If the bonds have different maturities then this complicates matters a bit but the method is basically the same. In this case the YTM is preferable.
Answer: If you have access to the spread duration of each asset in the portfolio then it is possible to estimate the spread on the portfolio. You can get an even better estimate with spread convexities. Let $s^{*}$ be the spread of the portfolio. The key observation is that when the individual bonds are PV'd at $s^{*}$, the sum of the changes in the values must add up to zero. For example, in a simple two bond case:
$$
\Delta \mbox{Spread} (A_1) \times \mbox{Spread Duration} (A_1) \times \mbox{Market Value} (A_1) +  \Delta \mbox{Spread} (A_2) \times \mbox{Spread Duration} (A_2) \times \mbox{Market Value} (A_2)= 0
$$
Since $\Delta \mbox{Spread} (A_i) = s^{*} - s_{A_i}$, where $s_{A_i}$ is the prevailing spread on asset $A_i$, we can solve for $s^{*}$.
In words, the spread of a portfolio is approximately equal to the weighted-average of the spreads of the individual assets, with the weights being equal to the spread duration weights as defined above. For example, given two bonds with spread values of 100bps and 30bps respectively, spread durations of 3 and 6, and equal market values, the portfolio spread is 53.3.


Getting localized strings for DayOfWeek values

Question: This code isn't localized:
Enum.GetNames(typeof(DayOfWeek))

I want a method that returns a list of localized strings, starting on an arbitrary DayOfWeek, that is localized, and I want to use the built in resources to do so.  So far, I've come up with the below code, but I feel like this should be supported in an way that doesn't feel like a hack.
    public List<String> GetLocalizedDayOfWeekValues(DayOfWeek startDay = DayOfWeek.Sunday)
    {
        var days = new List<String>();
        DateTime date = DateTime.Today;

        while (date.DayOfWeek != startDay)
            date.AddDays(1);

        for (int i = 0; i < 7; i++)
            days.Add(date.ToString("dddd"));

         return days;
    }

Know of a better way of doing this, please share.  Thanks!
Answer: I think you're looking for DateTimeFormatInfo.DayNames. Sample code:
using System;
using System.Globalization;

class Program
{
    public static void Main()
    {
        var french = new CultureInfo("FR-fr");
        var info = french.DateTimeFormat;
        foreach (var dayName in info.DayNames)
        {
            // dimanche, lundi etc
            Console.WriteLine(dayName);
        }
    }
}

Answer: These methods will give you a list of day names, defaulting to the specified culture's first day of the week:
public List<String> GetLocalizedDayOfWeekValues(CultureInfo culture)
{
    return GetLocalizedDayOfWeekValues(culture, culture.DateTimeFormat.FirstDayOfWeek);
}

public List<String> GetLocalizedDayOfWeekValues(CultureInfo culture, DayOfWeek startDay)
{
    string[] dayNames = culture.DateTimeFormat.DayNames;
    IEnumerable<string> query = dayNames
        .Skip((int) startDay)
        .Concat(
            dayNames.Take((int) startDay)
        );

    return query.ToList();
}

Compare...
List<string> dayNames = GetLocalizedDayOfWeekValues(new CultureInfo("fr-fr"));

...to...
List<string> dayNames = GetLocalizedDayOfWeekValues(new CultureInfo("fr-ca"));

Answer: I'll throw this in. The original post appears to want the day names in the current language. This may come from the Culture set in:
System.Threading.Threads.CurrentThread.CurrentCulture
The DateTimeFormatInfo object for this culture is easily retrieve, and you can use GetDayName:
DateTimeFormatInfo.CurrentInfo.GetDayName(dayOfWeek)

However, if you utilize the CurrentUICulture/CurrentCulture paradigm, for getting just the day name, CurrentUICulture is more appropriate. It is entirely possible that the CurrentCulture is set to en-US for somebody living in the united states, but CurrentUICulture is set to es-MX or es-US for somebody speaking/reading spanish. The dateformat should use the culture setting: mm/dd/yyyy but for day names it should use the UIculture settings: Lunes, Martes, etc.
For this reason, I suggest using this technique:
public String getLocalDayName( DayOfWeek dayOfweek) {
    var culture = System.Threading.Thread.CurrentThread.CurrentUICulture;
    var format = culture.DateTimeFormat;
    return format.GetDayName(dayOfweek);
}


Changed terminal permissions

Question: For no known reason I suddenly have to execute most terminal commands using sudo. For example, I have always been able to run "git pull/push" etc. without any trouble. Now, I get "permission denied". Is there any way of resetting the permissions to default? I'm using OS X Yosemite.
Answer: As in the first answer you have run various commands with the elevated command, sudo, in your personal space.  Now you have directories in your personal space that are owned, not by you, but by root.  If you type cd with no parameters you'll be taken to the bottom of your personal space (where it starts) and be able to see it with the pwd command.
On many system by default your personal space will be /home/[your username].
You can fix this have to execute most terminal commands using sudo by recovering access to your whole home directory.
Do this by first going to your home directory, then back out a level with cd ...
Now execute this command:
$ sudo chown -R [your username] [your username]

If your username is ljames you can do this with this sequence:
$ cd ~ljames
$ cd ..
$ sudo chown -R ljames ljames

There are a number of ways to do this.  I went thought those details to help you to see where the changes are taking place.  You can effectively do this in one command line with:
$ sudo chown -R ljames ~ljames

Now when you are working in your own personal space you shouldn't get the permission denied errors.  You should only be denied permission when you're working outside your personal area in what is called system wide.  You'll have to use the elevated command sudo to make changes in those areas.
Comment: Yes.  It's the first line of my answer.  I'll elaborate more if it's still not clear.
Comment: Thank you, that solves the problem! Any ideas how the permissions could have been changed in the first place? Seems a bit scary...
Answer: This will depend on the permissions of the folders/files you are trying to modify and not on the commands themselves. You probably ran a git command as sudo once and that changed the ownership to root. I could give you a more specific answer if you posted the output of ls -l on your git repository.
Assuming the problem is what I described above, you can fix it by changing the ownership back to your user (replace UserFoo with your actual user name):
chown -R UserFoo /path/to/git/folder

Comment: Ok, here's the output:

`drwxr-xr-x  5 root  staff     170 20 Okt 13:07 data
-rw-r--r--@ 1 Erik  staff      21 17 Okt 14:26 hello.m
-rw-r--r--  1 root  staff    2282 24 Okt 15:37 hello.py
-rw-r--r--  1 Erik  staff      24 17 Okt 15:25 import csv
-rw-r--r--  1 root  staff    4619 24 Okt 15:33 result.txt
-rwxr-xr-x  1 Erik  staff  117234  8 Okt 11:13 testing.csv`

However, this is not exclusive to git. I have the same problem with most commands which used to work previously.
Comment: @user89161 please [edit] your question to add extra information, it is hard to read and easy to miss in the comments. That said, the issue is indeed what I suspected and my answer should solve it. Note the `root` in the output, that means that the files belong to root and you don't have access to them. The command I gave will change the ownership back to your user.

Changed terminal permissions


Input value on a form not showing HTML WordPress

Question: I am working on a website and for some reason the input value is not working. It was just working about an hour ago and have made no changes to the site since then. For example: https://www.albright.edu/about-albright/offices-departments/registrar/transcript-requests/ at the bottom of that page, there are two buttons. One is for submit and one is for clear. Neither are showing the "value" part of the input so they both look blank.
Answer: There seems to be a plugin in your theme ( maybe AutoOptimize) that's causing the color of the button to be transparent.
input[value] {
    color: transparent;
}

Try setting the color on your css.
Comment: Ahhh perfect, no idea why that is there. Thank you!
Answer: If you inspect the element with developer tools the text is present but the color is set to transparent (apparently from the plugin autoptimize).
You could try to use
<button type="submit">Submit</button>

or style these inputs with a custom class to set the color of the text
I hope this helps


The easy way: Install Nvidia drivers, CUDA, CUDNN and Tensorflow GPU on Ubuntu 18.04

Question: How can I easily get tensorflow gpu running?
Answer: I just installed Tensorflow GPU on Ubuntu 18.04. There are a lot instructions for it, however I think the fastest and easiest way is usually not used and I want to share it:
NVIDIA DRIVER:
ubuntu-drivers devices
sudo ubuntu-drivers autoinstall
nvidia-smi

CUDA:
Normally: "sudo apt install nvidia-cuda-toolkit"
However this installs version 9.1, too new at the moment and tensorflow will not run. Instead download CUDA 9.0: https://developer.nvidia.com/cuda-90-download-archive?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1704&target_type=runfilelocal
Then run (Additional Details on the first line can be found at: How can I install CUDA 9 on Ubuntu 17.10):
sudo sh cuda_9.0.176_384.81_linux.run --override
sudo ln -s /usr/bin/gcc-6 /usr/local/cuda/bin/gcc
sudo ln -s /usr/bin/g++-6 /usr/local/cuda/bin/g++
cd ~
sudo nano .bashrc

add at the end of the file:
export PATH=/usr/local/cuda-9.0/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
CTL+X to save and exit

CuDNN:
register at nvidia developers https://developer.nvidia.com/cudnn
Download 9.1 runtime & developer library for 16.04 (Files cuDNN v7.1.3 Runtime Library for Ubuntu16.04 (Deb) & cuDNN v7.1.3 Developer Library for Ubuntu16.04 (Deb))
Open the files with software manager and install them.
Check with:
cat /usr/include/x86_64-linux-gnu/cudnn_v*.h | grep CUDNN_MAJOR -A 2

Install libraries and tensorflow:
sudo apt-get install libcupti-dev
pip3 install tensorflow-gpu

Check:
in tensorflow check for GPU support
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))

Note: Start tensorflow or your development environment from terminal, otherwise for me it does not load the PATH variables.
Comment: is there anyway to get cuda 10.1 working?
Comment: at nvidia's wesite, I saw no cudnn package for version 9.1. 9.0,9.2,10.0,10.1 is all i saw, oh, and a source version
Answer: Just to extend Jonny's answer:  when following Jonny's method for installing CUDA, I had to choose "No" for "Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 384.81?" (yes or default for everything else). Otherwise the CUDA driver installation would fail saying "ERROR: An NVIDIA kernel module 'nvidia-drm' appears to already be loaded in your kernel"
Then you can test your CUDA installation by running the samples.
First install their dependencies:
sudo apt-get install freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libgl1-mesa-glx libglu1-mesa libglu1-mesa-dev libglfw3-dev libgles2-mesa-dev

These won't compile with the new compilers on Ubuntu 18, so you'll need to downgrade to gcc/g++ 6:
sudo apt-get install gcc-6 g++-6
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-6 10
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 10

Compile the samples by navigating to:
~/NVIDIA_CUDA-9.0_Samples/bin/x86_64/linux/release

And compile using:
make -k

Run one of the samples like:
./nbody


Is there any theological reason that Eastern Orthodox clergy tend to maintain long beards?

Question: I have minimal familiarity with the Eastern Orthodox tradition, but I can typically guess by seeing a photo that a person is an Eastern Orthodox clergyman.
Answer: It's a tradition derived from two sources: first of all, Jesus had long beard - second, from Leviticus 19:27 "You shall not round off the hair on your temples or mar the edges of your beard"
However, it's not a prescription for ortodox clergy to do that: it's only a (widely observed) tradition
Note that catholic clergy usually not maintain long beards, for a different tradition: Romans used to shave their beards, and to consider men with long beards as uncivilized (barbarians).
Anyway, there is no prescription about beards (exept for some monks)
Comment: [Ion Creanga](http://en.wikipedia.org/wiki/Ion_Creanga) was defrocked for shaving his beard; not only was it a requirement for clergy, it was a requirement for all grownup males; [Old Believers](http://en.wikipedia.org/wiki/Old_Believers) are notorious in this respect; the social reforms of Peter the Great caused quite a stir among the Russian nobility, who, after being forced, under threat of punishment, to shave their faces, so as to better resemble their Western counterparts, kept their cut hair, so as to present it to Saint Nicholas on [judgment day](http://www.imdb.com/title/tt0103064).


How does moving your legs forward on a swing propel it forward instead of backward?

Question: Moving your weight back is equivalent to moving the pivot forward, like having a ball on a string and moving your hand forward, then, when it moves forward, moving your hand back.
What I don't understand is how you can propel it forward by only moving your legs forward, which should propel it back.
Answer: You are not actually propelling it forward as such. What you are doing is that each time you swing you  raise your legs at the top of each swing. This moves your bodies centre-of-mass to a greater height creating more potential energy. This potential energy is in turn transferred into kinetic energy, meaning after each swing you will go faster and higher and so on. EDIT Added: Note that you are swinging your feet in phase with the swing to make it go higher, making this a resonance effect. (added edit thanks to David white' comment below - thanks David)
Comment: Dr jh, you could also add that you swing your feet in phase with the swing to make it go higher, making this a resonance effect.
Comment: @DavidWhite Thanks David. Good point and I added it as you asked.
Comment: Thanks Dr dj & Dave. Since I posed the question, I worked out how moving your legs forward shifts your centre of gravity back, It is because your legs are further from the fulcrum (pivots), and have more leverage than your upper body, so the "mass x displacement" is greater for it, like somebody about to fall off a cliff leaning over it to regain their balance. Also, I noticed that your legs and/or body are rotating, which tries to rotate the swing and push the pivots forward, pushing you back. I wrote an explanation & sent to 1 of 4  of us trying to work it out. I'll show it below.
Answer: It seems counterintuitive, somebody moving a swing forward by only swinging their legs forward: If somebody is standing on a frictionless base on a level surface and they thrust something forward without letting go of it, the combined centre of gravity remains the same. Mass times displacement is the same. But, when one object is above the other on a pivoting lever, the object furthest from the fulcrum has the most leverage, so, if they are the same size, the object nearer the fulcrum will move further back, shifting the centre of gravity back.
Regardless of the size, the mass times displacement is greater for the object nearest the fulcrum. So when somebody on a swing swings their legs forward, because their legs are below the rest of their body, they actually shift their centre of gravity back slightly. It is the same as somebody about to fall over a cliff leaning over it to regain their balance.
Because their legs rotate forward and/or body rotates back, there is also a moment of rotational inertia which rotates the swing back slightly more, by trying to push the pivots forward as you press on the chains. When you lean back and swing your legs forward, everything except the bit on the seat rotates backwards, giving you maximum  forward propulsion, both from rotational inertia, and shift of centre of gravity which is equivalent to moving the pivot forward.
Comment: I strongly suspect that these answers about center of gravity are in fact wrong. If they were correct then one would expect that the part of the body to get exhausted first would be the legs or the back, when it is in fact the arms. And it seems to continue even when you are doing whatever you are doing on the upswing, kids do not tilt forwards until the apex. It seems to me like one must ultimately describe the action as a very surprising act of "pulling yourself forwards with your arms" but it is not clear to me how this manifests in the actual operation of the swing.
Comment: It is your arms that are doing most of the work moving your back. How it moves the  swing is all to do with the weight distribution along the lever formed by the swing. Along the path round the circle you are essentially weightless, like an object thrown into the air. If the object extended part of itself without releasing it, there would be no effect on its motion (like the girl). But if the object is on a pivoting lever and the outer part moves, the mass x displacement of the inner part, which has less leverage will be more. U R also pushing on the pivot via the chain to rotate yourself.


Speed gaseous planets

Question: Why do gaseous planets spin faster than telluric planets? I've seen thats because of primitive nebula but I didn't understand why? Could someone help me? I would appreciate a lot!
Comment: Just out of interest, have you found a lot of data on non-Solar planets and their rotational speed?
Answer: There isn't such a great difference between Earth and Mars (at about 25 hours) and the gas/ice giants (between 10 and 20 hours). Earth had a day of about 6 hours in the early Solar system, but has been slowed by lunar tides. Small planets will not accrete gas in their early formation, and so will not pick up angular momentum from accretion discs, which can explain why Jupiter and Saturn have rapid rotation rates.
Mercury and Venus are slowed by Solar tides. In the case of Mercury, it is in a resonance between its orbit and the solar tide. In the case of Venus, there are significant atmospheric tides, that slow it down (It actually spins backwards, and the full explanation is incomplete.)
So the answer is three-fold: Distant gas giants pick up lots of momentum in their formation, they are not much affected by Solar tides, and the differences between them and the rocky planets are not actually so great anyway.

Speed gaseous planets