Is there a way to unit test if a function correctly executes stats and logs in Go?
Unit testing a method that calls another method
Working with IPv6 Addresses in PHP After searching around somewhat thoroughly, I noticed a slight lack of functions in PHP for handling . For my own personal satisfaction I created a few functions to help the transition.  The IPv6ToLong() function is a temporary solution to that brought up here: . It will split the IP in to two integers and return them in an array.  /**  * Convert an IPv4 address to IPv6  *  * @param string IP Address in dot notation (192.168.1.100)  * @return string IPv6 formatted address or false if invalid input  */ function IPv4To6($Ip) {     static $Mask = '::ffff:'; // This tells IPv6 it has an IPv4 address     $IPv6 = (strpos($Ip, '::') === 0);     $IPv4 = (strpos($Ip, '.') &gt; 0);      if (!$IPv4 &amp;&amp; !$IPv6) return false;     if ($IPv6 &amp;&amp; $IPv4) $Ip = substr($Ip, strrpos($Ip, ':')+1); // Strip IPv4 Compatibility notation     elseif (!$IPv4) return $Ip; // Seems to be IPv6 already?     $Ip = array_pad(explode('.', $Ip), 4, 0);     if (count($Ip) &gt; 4) return false;     for ($i = 0; $i &lt; 4; $i++) if ($Ip[$i] &gt; 255) return false;      $Part7 = base_convert(($Ip[0] * 256) + $Ip[1], 10, 16);     $Part8 = base_convert(($Ip[2] * 256) + $Ip[3], 10, 16);     return $Mask.$Part7.':'.$Part8; }  /**  * Replace '::' with appropriate number of ':0'  */ function ExpandIPv6Notation($Ip) {     if (strpos($Ip, '::') !== false)         $Ip = str_replace('::', str_repeat(':0', 8 - substr_count($Ip, ':')).':', $Ip);     if (strpos($Ip, ':') === 0) $Ip = '0'.$Ip;     return $Ip; }  /**  * Convert IPv6 address to an integer  *  * Optionally split in to two parts.  *  * @see https://stackoverflow.com/questions/420680/  */ function IPv6ToLong($Ip, $DatabaseParts= 2) {     $Ip = ExpandIPv6Notation($Ip);     $Parts = explode(':', $Ip);     $Ip = array('', '');     for ($i = 0; $i &lt; 4; $i++) $Ip[0] .= str_pad(base_convert($Parts[$i], 16, 2), 16, 0, STR_PAD_LEFT);     for ($i = 4; $i &lt; 8; $i++) $Ip[1] .= str_pad(base_convert($Parts[$i], 16, 2), 16, 0, STR_PAD_LEFT);      if ($DatabaseParts == 2)             return array(base_convert($Ip[0], 2, 10), base_convert($Ip[1], 2, 10));     else    return base_convert($Ip[0], 2, 10) + base_convert($Ip[1], 2, 10); }   For these functions I typically implement them by calling this function first:  /**  * Attempt to find the client's IP Address  *  * @param bool Should the IP be converted using ip2long?  * @return string|long The IP Address  */ function GetRealRemoteIp($ForDatabase= false, $DatabaseParts= 2) {     $Ip = '0.0.0.0';     if (isset($_SERVER['HTTP_CLIENT_IP']) &amp;&amp; $_SERVER['HTTP_CLIENT_IP'] != '')         $Ip = $_SERVER['HTTP_CLIENT_IP'];     elseif (isset($_SERVER['HTTP_X_FORWARDED_FOR']) &amp;&amp; $_SERVER['HTTP_X_FORWARDED_FOR'] != '')         $Ip = $_SERVER['HTTP_X_FORWARDED_FOR'];     elseif (isset($_SERVER['REMOTE_ADDR']) &amp;&amp; $_SERVER['REMOTE_ADDR'] != '')         $Ip = $_SERVER['REMOTE_ADDR'];     if (($CommaPos = strpos($Ip, ',')) &gt; 0)         $Ip = substr($Ip, 0, ($CommaPos - 1));      $Ip = IPv4To6($Ip);     return ($ForDatabase ? IPv6ToLong($Ip, $DatabaseParts) : $Ip); }   Someone please tell me if I'm reinventing the wheel here or I've done something wrong.  This implementation converts IPv4 to IPv6. Any IPv6 address it doesn't touch. Why do some adjectives follow the nouns they modify? Right now I can only think of one instance in which this regularly occurs.  The adjective proper is sometimes placed after the noun it modifies, e.g:      A class of cold-blooded oviparous or ovoviviparous vertebrated animals whose skin is covered with scales or scutes; the reptiles proper.   What is this word order called, and why is it ever used?  Edit: I really want to know about proper, and while the word hyperbaton relates to post-positivity when it is meant to be rhetorically impacting, it doesn't seem to fit with ubiquitous post-positivity, such as that of proper.  I've accepted hyperbaton as the correct term/reason for almost all post-positive constructions, but I'd like a complete answer to include proper. I already read it from manual but I can't see difference..  su - change user ID or become superuser  sudo -s [command]   The -s (shell) option runs the shell specified by the SHELL environment variable if it is set or the shell as specified in passwd(5).  If a                    command is specified, it is passed to the shell for execution.  Otherwise, an interactive shell is executed.  sudo -i disappear description in manual Bending of light - photon's inertia instead of mass Where are packages stored installed with APT in Ubuntu 16.04? What does "bad girls go backstage" mean? (sorry for my poor English)  I saw this phrase somewhere but I don't know what this means..     Good girls go to heaven, bad girls go backstage   What means 'bad girls go backstage'?   Maybe.. it's when good girls try to be good, but bad girls become famous?  Am I right? Why does holding something up cost energy while no work is being done? I read the definition of  as  $$W ~=~ \vec{F} \cdot \vec{d}$$  $$\text{ Work  =  (Force) $\cdot$ (Distance)}.$$ If a book is there on the table, no work is done as no distance is covered. If I hold up a book in my hand and my arm is stretched, if no work is being done, where is my energy going? I'm wondering how can I simulate a sample of n Weibull distribution lifetimes that include Type I right-censored observations. For instance lets have the n = 3, shape = 3, scale = 1 and the censoring rate = .15, and the censoring time = .88.  I know how to generate a Weibull sample but I do not know how to generate a censored data that have type I right-censored in R.  T = rweibull(3, shape=.5, scale=1) When did 5 foot squares become standard in D&D? What is the difference between re.search and re.match? What is the difference between the search() and match() functions in the ?  I've read the  (), but I never seem to remember it.  I keep having to look it up and re-learn it.  I'm hoping that someone will answer it clearly with examples so that (perhaps) it will stick in my head.  Or at least I'll have a better place to return with my question and it will take less time to re-learn it. Adding Arabic text to an English document Combine 4 cells in a table Here is a simple table.  I want to merge 4 cells. I want to combine the three "this" cells area in this table. I thought I have to use multirow and multicolum at same time. However, I could not find how to use it.  If possible, could you post the modified LaTeX source code?     My LaTeX code:  \documentclass{article} \usepackage{multirow}% http://ctan.org/pkg/multirow \usepackage{hhline}% http://ctan.org/pkg/hhline \begin{document}  \begin{table}[ph] \begin{center} \begin{tabular}{c|c|c|c|c} \hline \multirow{2}{*}{Raaa (k)} &amp; \multicolumn{4}{c}{C ()} \\ \hhline{~----}  &amp; 3.3 &amp; 2.5 &amp; 1 &amp; 0.5 \\ \hline \multirow{2}{*}{Raaa (k)} &amp; \multirow{2}{*}{this} &amp; this &amp; 0.5 &amp; 0.6\\ \hhline{~~~--}            &amp;                       &amp; this &amp; 0.7 &amp; 1.2 \\ \hline \end{tabular} \caption{R, C ripple size} \label{T:peak} \end{center} \end{table} \end{document} For about 2 days I'm trying to configure Ubuntu so that I can send an email, but when I type in:  echo "Subject: sendmail test" | sendmail -v my@email.com   I'll get:  postdrop: warning: unable to look up public/pickup: No such file or directory Mail Delivery Status Report will be mailed to &lt;andreigbr&gt;.   Even if I change my@email with mine, the inbox will be empty. Can somebody help me, please? I watched about 5 tutorial about how to send an email fom the command line but still doesn't work. I was just curious, why is epic a silver badge if only 73 users have been awarded with it?  For example: Silver Epic - 73  Gold Electorate - 193    Edit: My point was to reduce the level of epic, like "hit the daily reputation cap on 30 days" so it becomes some what at par with other silver badges. What does really attracts a water stream to a charged object? I saw  by  and I was not 100% sure about the third phenomena, a statically charged object attracting a stream of water, especially because he explicitly mentioned that it is not due to the  of the water. A week later he uploaded an  all five phenomena and he says it is because of repelled equally charged ions, back up the water flow, such that the water actually falling along the charged object would be oppositely charged and therefore attracted. Here is a still image from the video illustrating this:    However this explanation seems strange to me, since this would mean that this way you could build up a charge in the water which has exited the tap (as well as in the water inside the tap as well). Therefore it should get harder to push those ions back over time, and therefore there also would be a decrease in the attraction of the water (assuming there is no other way to discharge it). I have tried a simple similar experiment, where I catched the water leaving the tap in an insulated bowl, but I did not notice a decrease in attraction.  There a couple of reasons why my experiment does not rule out his theory:   I was holding the charged (plastic) object by hand, which caused that its distance to the water stream varied, making it difficult to observe a decrease in attraction. I only conducted my experiment for roughly 30 seconds, which might be enough time for a opposite charge to build up.   The reason that he mentioned why permittivity can't cause this phenomena is because the electric field would be homogeneous and therefore the attractive and repulsive force of both dipoles of a water molecule would cancel out. However the electric field would only be homogeneous if the charged object would be an infinitely large plate, which it isn't. Thus water molecules would be attracted to the charged object. In order to make the permittivity theory more plausible I thought of maybe doing a order of magnitude calculation to see if it could generate a large enough force would be able the water stream by the observed amount. However I do not know what a good guess would be for variables such as the amount charge on the charged object and how the electric field would fall off over distance.   So, my question is whether his theory is really correct, or if the permittivity of the water can cause it. Date and Time only partially visible in Big Sur Unchained Flurry of Blows with Natural Weapons and Feral Combat Training using natural attacks as primary Probability of flipping coin What is the probability of obtaining THT before HHH when a toss is tossed sequentially? Could someone solve using state diagram and law of total probability? Two players, $A$ and $B$, alternately and independently flip a coin and the first player to get a head wins. Assume player $A$ flips first.  If the coin is fair, what is the probability that $A$ wins?   So $A$ only flips on odd tosses. So the probability of winning would be $$ P =\frac{1}{2}+\left(\frac{1}{2} \right)^{2} \frac{1}{2} + \cdots+ \left(\frac{1}{2} \right)^{2n} \frac{1}{2}$$  Is that right? It seems that if $A$ only flips on odd tosses, this shouldn't matter. Either $A$ can win on his first toss, his second toss, ...., or his $n^{th}$ toss. So the third flip of the coin is actually $A$'s second toss. So shouldn't it be $$P = \frac{1}{2} + \left(\frac{1}{2} \right)^{2} + \left(\frac{1}{2} \right)^{3} + \cdots$$ Why we use $L_2$ Space In QM? I asked this question for many people/professors without getting a sufficient answer, why in QM Lebesgue spaces of second degree are assumed to be the one that corresponds to the Hilbert vector space of state functions, from where this arises? and why 2-order space that assumes the following inner product:  $\langle\phi|\psi\rangle =\int\phi^{*}\psi\,dx$  While there is many ways to define the inner product.  In Physics books, this always assumed as given, never explains it, also I tried to read some abstract math books on this things, and found some concepts like "Metric weight" that will be minimized in such spaces, even so I don't really understand what is behind that, so why $L_2$? what special about them? Who and how physicists understood that those are the one we need to use?