I am creating a static class that is used to asynchronously wait for some T targetValue to be "approximately" some T currentValue. I have already implemented a function to check for exact equality as shown below, but I am having a difficult time with an "approximate value"  public delegate T GetValueMethod&lt;T&gt;() where T: struct;  public static Task&lt;Boolean&gt; WaitForExactValueAsync&lt;T&gt;(GetValueMethod&lt;T&gt; getValue, T targetValue, CancellationToken cancelWaitToken, int msTimeout = 10000) where T: struct {     return Task.Run&lt;Boolean&gt;(async () =&gt;     {         // Create a CancellationToken that times out, then link it with the argument token that requests a the wait to be cancelled         var timeoutTokenSource = new CancellationTokenSource(TimeSpan.FromMilliseconds(msTimeout));         var timeoutAndCancelTokenSource = CancellationTokenSource.CreateLinkedTokenSource(timeoutTokenSource.Token, cancelWaitToken);          // Continually check to see if we reached the target value or have timed out         T currentValue = getValue();         while (!targetValue.Equals(currentValue) &amp;&amp; !timeoutAndCancelTokenSource.IsCancellationRequested)         {             try { await Task.Delay(500, timeoutAndCancelTokenSource.Token); }catch (Exception ex) { }             currentValue = getValue();         }          // If we got here and the token is not cancelled that means we have reached the target value         return !timeoutAndCancelTokenSource.IsCancellationRequested;     }); }   The methods I am creating are meant to only work with primitive types such as int, double, Boolean, etc. I do this by implementing  which describes a way to limit generic types to primitives by forcing the T to be a struct.   The function above seems to work nicely for my situation because (I think) we can always equate struct with Equals to determine equality. My issue when creating the approximately equal version is when the type of T is something like Boolean.   I plan to allow the user to pass in a "closeness" percentage to the function to specify when the two values are "approximately equal" (If the current is within x percentage of the target return true). If T is a numeric value I can do this with maths easily, but when its non-numeric it makes no sense to use this method but to simply use Equals.  Is there a way to tell from T (where T : struct) if I can perform the maths I need to on it (To implement the IsValueClose method below)?  private static Boolean ValueIsClose&lt;T&gt;(T target, T value, double percentAsDecimal)    where T: struct {     // if(value.CanDoTheMaths)     {         return Math.Abs((value / target) - target) &lt;= percentAsDecimal;     }     // else     {         return target.Equals(value);     } }   Furthermore once this happens how can I refer to target and value as a type that can perform these maths?  From asking somewhat relate questions before I do not think this is quite possible or good practice for generic methods. So from what I can currently tell, my only good solution is to make an "approximate" method for each type I plan to use (the best practice), or to check the Type of T in IsValueClose to see if it is something that I know I can do maths on and go from there (Bad practice for generics).   Though possibly there is a simpler more elegant solution that someone could suggest?
Can anyone tell me if there is a way with generics to limit a generic type argument T to only:   Int16 Int32 Int64 UInt16 UInt32 UInt64   I'm aware of the where keyword, but can't find an interface for only these types,  Something like:  static bool IntegerFunction&lt;T&gt;(T value) where T : INumeric
How to set environment variable in systemd service? I have an  and I've created my own service. The configuration service at /etc/systemd/system/myservice.service looks like this:  [Unit] Description=My Daemon  [Service] ExecStart=/bin/myforegroundcmd  [Install] WantedBy=multi-user.target   Now I want to have an environment variable set for the /bin/myforegroundcmd. How do I do that? From my , I learned that all tag related info on profile will be updated daily at UTC 03:00.  However, something is wrong here. It's now UTC 05:00+, but my tag number, say 93 (c++) is not updated against yesterday. I am pretty sure about this and I did earn some more points throughout the day. Sorry for not be able to capture the screenshot yesterday, but I did check this number 10 hours ago (which belongs to yesterday, also 93).  Is there a bug happening here? Or updating time different?    UPDATE: As of 24 Jan, the tags are still not updated with the proper values.  UPDATE2: Fixed around 25 Jan, UTC 03:00, at least for me. In Java, is there any way to use the JDK libraries to discover the private classes implemented within another class? Or do I need so use something like asm? How can I create a zip archive of a whole directory via terminal without hidden files? I have a project with lots of hidden folders / files in it. I want to create a zip-archive of it, but in the archive shouldn't be  any hidden folders / files. If files in a hidden folder are not hidden, they should also not be included.  I know that I can create a zip archive of a directory like this:  zip -r zipfile.zip directory   I also know that I can exclude files with the -x option, so I thought this might work:  zip -r zipfile.zip directory -x .*   It didn't work. All hidden directories were still in the zip-file. How to validate an email address using a regular expression? The -k option (or --convert-link) will convert links in your web pages to relative after the download finishes, such as the man page says:     After the download is complete,   convert the links in the document to   make them suitable for local viewing.   This affects not only the visible   hyperlinks, but any part of the   document that links to external   content, such as embedded images,   links to style sheets, hyperlinks to   non-HTML content, etc.   So, if I didn't specify -k, can I run wget again after the download and fix that, and if so, what would be the proper command? My guess is wget -c [previous options used] [url] and run it in the same working directory as the file were downloaded to. Proving the AM-GM inequality for 2 numbers $\sqrt{xy}\le\frac{x+y}2$ I am having trouble with this problem from my latest homework.  Prove the arithmetic-geometric mean inequality. That is, for two positive real numbers $x,y$, we have $$ \sqrt{xy}≤ \frac{x+y}{2} .$$ Furthermore, equality occurs if and only if $x = y$.  Any and all help would be appreciated. Suppose we have a situation like      A ball of some mass $m$ with some velocity collides with rod hinged at point $A$. Is momentum conserved in this situation? I know that hinge will give impulsive force on rod but that is internal force when we take ball and rod together as a system so that shouldn't stop us using conservation of momentum equation Is it possible to use the Lagrangian formalism involving physical terms to answer the question of why all planets are approximately spherical?  Let's assume that a planet is 'born' when lots of particles of uniform density are piled together, and constrained only by the Newtonian gravity of the $N$ particles with no external gravity.    My question is: Is it possible to use the variational calculus starting from this situation to prove that planets should be spherical? Geometric interpretation of $\frac {\partial^2} {\partial x \partial y} f(x,y)$ Are there any geometric interpretation for the second partial derivative? i.e.  $$f_{xy} = \frac {\partial^2 f} {\partial x \partial y}$$  In particular, I'm trying to understand the determinant from  for determining whether a critical point is a minima/maxima/saddle points:  $$D(a, b) = f_{xx}(a,b) f_{yy}(a,b) - f_{xy}(a,b)^2$$  I have no trouble understanding $f_{xx}(x,y)$ and $f_{yy}(x,y)$ as the of measure of concavity/convexity of f in the direction of x and y axis. But what does $f_{xy}(x,y)$ means? From 8th June there's been a  period for people entering the UK. From 10th July, travellers from  via a travel-corridor. If more countries are added to the list of exemptions then the date for each country will be later than the 10th July. If a traveller entered the UK from a country that is not on the exempt list and that country is added to the exempt list prior to the end of the 14 day self-isolation period does the self-isolation period end early? For example, if an individual entered the UK from France on the 5th July, should they remain in isolation for 14 days or does the isolation end on the 10th when France is added to the list of exempt countries? What exactly do quotation marks around the table name do? I thought that the quotation mark (") was simply a type of grouping marker but I'm debugging some NHibernate code and notice that while  SELECT * FROM site WHERE site_id = 3;   Works fine  SELECT * FROM "site" WHERE site_id = 3;   fails with a table or view does not exist error.  What gives? Argue by contradiction to show that there is no surjection... from $A$ to $\{0,1\}^A$. When $A$ is any (possibly infinite) set  How does one go about this? As I'm relatively new to the electronics world, I was wondering if you can connect multiple  ground terminals (corresponding to several different voltage outputs) to the same ground. Or do they each need their own?  In my case I have 5 lines, one 12V, one 3.3V, two 5V and one variable from a 12V in using a  voltage regulator that already has its own ground. So I'm guessing that each would need its own ground, but it is never bad to ask. (complex measures) $d\nu=d\lambda +f\,dm \Rightarrow d|\nu|=d|\lambda| +|f|\,dm$ and $f\in L^1(\nu)\Rightarrow f\in L^1(|\nu|)$ Two simple exercises on complex measures I don't know how to solve, from Folland's Real Analysis. I find it difficult to manipulate the definitions in computations. For context, if $\nu$ is a complex measure on $(X,\mathcal{M})$ then $|\nu|$ is defined as $d|\nu|=|g|\,d\mu$ where positive measure $\mu$ and $g\in L^1(\mu)$ are such that $\nu \ll \mu$ and $\nu = g\,d\mu$ (and in the textbook it's shown that this definition does not depend on the choice of $\mu$).     1) Let $\nu$ be a reguar complex Borel measure on $\mathbb{R}^n$, $m$ denote   Lebesgue measure, and   let $d\nu = d\lambda + f\,dm$ be its Lebesgue-Radon-Nikodym   representation. Then ("it is easily verified")   $d|\nu|=d|\lambda|+|f|\,dm$.      2) If $f\in L^1(\nu)$ then $f\in L^1(|\nu|)$. I was able to prove the   reverse implication, but not this one.   The definition of $|\nu|$ in the case of real signed measures (as $|\nu|=\nu^+ + \nu^-$) makes sense to me but I can't see intuitively into the definion of $|\nu|$ for complex measures as given in the textbook. Do you have any advice on this?  Thank you! Express js - can't redirect Currently I had built a file upload functionality in Lightning component which accepts the CSV file, read it as text(Each row in CSV is split using \n and each column in the row is split using ,). Then each columns in each row are validated in Javascript and if everything is fine,the data is saved in the backend. While uploading the data, if the file contains , in its data then it is taken as another column. Eg: X-36936,SS-341487,11-WT,414081,"LENDERS, THE HACK",2-Manage,,,,,,,,,,,,12/1/2013,3150,,0,,Dealing,2018,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,  Here "LENDERS, THE HACK" is a single column but it is taken as 2 columns (LENDERS --> 1st column and THE HACK --> 2nd column).Could anyone please help me how to resolve this issue? Dual boot => Triple boot A 256GB SSD has Windows-10 and 16.04 installed.  BIOS not UEFI.  A charity I work with requires me to use Quickbooks Desktop on Windows.  The plan is to ghost the existing system to a 512GB or larger SSD and create a third bootable Windows 7  partition for performing charity activities.   Is this possible to have a third partition? Is there a good example you have used as a guide? Is triple booting with two Windows partitions different from 2 Linux partitions?   If you have done this before ( with GRUB) please indicate this in your response: lessons-learned are appreciated.  Thank you When to use 'by' instead of 'at' or 'on' to specify time/date? Does Power Word Kill kill druids in wild-shape?