Is there a class that can generate a random regex string if given the pattern?
Random string that matches a regexp
Executing Java programs through Python How do I do this? How to remove "onclick" with JQuery? Why is it "come" rather than "go" ? If we map every integer to a string that represents a rational number, and produce a number different from all the ones listed, we are essentially following Cantor's algorithm. But why does it not apply? Is it because we can't be certain that the number produced is a rational number? Do I have to buy or need a 3D-enabled phone to use Google Cardboard? Google cardboard comes with 3D glasses. Does that mean that we will be able to watch 3D videos using a smartphone like the Moto-G (1st edition) which is not 3D enabled? What are the eigenvalues of $\operatorname{ad}x$? Let $x\in \operatorname{gl}(n,F)$ have $n$ distinct eigenvalues $a_1,\ldots,a_n$ in $F$. Prove that the eigenvalues of $\text{ad }x$ are precisely the $n^2$ scalars $a_i-a_j$ ($1\leq i,j\leq n$), which of course need not be distinct.   So we can represent $x$ by an $n\times n$ matrix $X$. We have $Xv_1=a_1v_1,\ldots, Xv_n=a_nv_n$ for eigenvectors $v_1,\ldots,v_n$.   Now, $\operatorname{ad}x$ takes $y\in \operatorname{gl}(n,F)$ to $xy-yx$. I need to show that some $y$ is taken to a scalar multiple of itself, where that scalar is $a_i-a_j$. What could be that $y$? Why does printf not flush after the call unless a newline is in the format string? Metapost label based on variable value I want to label a scale based on a variable value and I wrote a metapost code like this.  $ := 1; for i = -.3cm step .6cm until 3.6cm:     label.bot(str$,(i,-3.7cm));     $ := incr($); endfor;   It just labels "$" instead of its value. How to output the variables value? Why doesn't grep using pipe work here? I have the following command:  find / -name libGL.so.1   Which returns lots of lines with "Permission denied". I want to exclude such lines, so I added the following:  find / -name libGL.so.1 | grep -v 'denied'   But the output is the same - my grep -v 'denied' is not filtering out the lines with Permission denied. I've tried many variations, looked over grep tutorials, but I cannot figure out the problem. Any suggestions? I did apt-get upgrade it never finishes at this point:  Searching for GRUB installation directory ... found: /boot/grub Searching for default file ... found: /boot/grub/default Testing for an existing GRUB menu.lst file ... found: /boot/grub/menu.lst Searching for splash image ... none found, skipping ... Found kernel: /boot/vmlinuz-3.2.0-24-virtual Updating /boot/grub/menu.lst ... done  You already have a NoLOADER configuration in /etc/grub.conf Running boot loader as requested Running /usr/sbin/grub  ...    The system does not freeze (Ctrl-Z works, I get my console back) just that that /usr/sbin/grub seems to never complete.  What should I do? If I calculate the median of a sufficiently large number of observations drawn from the same distribution, does the central limit theorem state that the distribution of medians will approximate a normal distribution? My understanding is that this is true with the means of a large number of samples, but is it also true with medians?  If not, what is the underlying distribution of sample medians? Why is there no article in "We are Family"? Perturbation property of Orthonormal basis for Hilbert space Mean and variance of Squared Gaussian: $Y=X^2$ where: $X\sim\mathcal{N}(0,\sigma^2)$? What is the mean and variance of Squared Gaussian: $Y=X^2$ where: $X\sim\mathcal{N}(0,\sigma^2)$?  It is interesting to note that Gaussian R.V here is zero-mean and non-central Chi-square Distribution doesn't work.  Thanks. learn how to [verb] vs. learn to [verb] "learn to [verb]" "learn how to [verb]"   Is [1] merely a less formal version of [2]? If not, does [1] communicate something subtly different? Consider the following:  In [2], the object of learning is explicitly "how to [verb]" (for instance, "I will learn how to speak French").  Is the object of learning in [1] "to [verb]" or is it something implicit and abstract that allows the subject "to [verb]"? For instance, in "I will learn to speak French", the object of learning would be the prerequisite elements for speaking French: "French phonemes, grammar, syntax, etc.". Is using only HTTPS bad in a SEO perspective? I would like to set up a new business site. I plan to direct www.example.com to example.com and only use that domain. My plan is also to only use HTTPS and not HTTP.   Does this affect the SEO for the site? E.g. do Google put lower or higher rank for sites that is only available via HTTPS? What makes a DSLR better than a Point & Shoot? Why should I put up with the inconvenience of lugging around a DSLR?  They look cool, but is there more substance to it? Finding UMVUE of $\theta$ when the underlying distribution is exponential distribution Hi I'm solving some exercise problems in my text : "A Course in Mathematical Statistics".  I'm in the chapter "Point estimation" now, and I want to find a UMVUE of $\theta$ where $X_1 ,...,X_n$ are i.i.d random variables with the p.d.f $f(x; \theta)=\theta e^{-\theta x}, x\gt0$.   I know that $E(X_i)=1/\theta,$ for each $i$, and also have that $\bar{X}$ (or equivalently $\sum_1^n X_i$) is a complete sufficient statistic for $\theta$. But I cannot go any further here. Somebody can help me? Best way to return multiple values from a function? The canonical way to return multiple values in languages that support it is often . Option: Using a tuple Consider this trivial example: def f(x):   y0 = x + 1   y1 = x * 3   y2 = y0 ** y3   return (y0, y1, y2)  However, this quickly gets problematic as the number of values returned increases. What if you want to return four or five values? Sure, you could keep tupling them, but it gets easy to forget which value is where. It's also rather ugly to unpack them wherever you want to receive them. Option: Using a dictionary The next logical step seems to be to introduce some sort of 'record notation'. In Python, the obvious way to do this is by means of a dict. Consider the following: def g(x):   y0 = x + 1   y1 = x * 3   y2 = y0 ** y3   return {'y0': y0, 'y1': y1 ,'y2': y2}  (Just to be clear, y0, y1, and y2 are just meant as abstract identifiers. As pointed out, in practice you'd use meaningful identifiers.) Now, we have a mechanism whereby we can project out a particular member of the returned object. For example, result['y0']  Option: Using a class However, there is another option. We could instead return a specialized structure. I've framed this in the context of Python, but I'm sure it applies to other languages as well. Indeed, if you were working in C this might very well be your only option. Here goes: class ReturnValue:   def __init__(self, y0, y1, y2):      self.y0 = y0      self.y1 = y1      self.y2 = y2  def g(x):   y0 = x + 1   y1 = x * 3   y2 = y0 ** y3   return ReturnValue(y0, y1, y2)  In Python the previous two are perhaps very similar in terms of plumbing - after all { y0, y1, y2 } just end up being entries in the internal __dict__ of the ReturnValue. There is one additional feature provided by Python though for tiny objects, the __slots__ attribute. The class could be expressed as: class ReturnValue(object):   __slots__ = [&quot;y0&quot;, &quot;y1&quot;, &quot;y2&quot;]   def __init__(self, y0, y1, y2):      self.y0 = y0      self.y1 = y1      self.y2 = y2  From the :  The __slots__ declaration takes a sequence of instance variables and reserves just enough space in each instance to hold a value for each variable. Space is saved because __dict__ is not created for each instance.  Option: Using a  (Python 3.7+) Using Python 3.7's new dataclasses, return a class with automatically added special methods, typing and other useful tools: @dataclass class Returnvalue:     y0: int     y1: float     y3: int  def total_cost(x):     y0 = x + 1     y1 = x * 3     y2 = y0 ** y3     return ReturnValue(y0, y1, y2)  Option: Using a list Another suggestion which I'd overlooked comes from Bill the Lizard: def h(x):   result = [x + 1]   result.append(x * 3)   result.append(y0 ** y3)   return result  This is my least favorite method though. I suppose I'm tainted by exposure to Haskell, but the idea of mixed-type lists has always felt uncomfortable to me. In this particular example the list is -not- mixed type, but it conceivably could be. A list used in this way really doesn't gain anything with respect to the tuple as far as I can tell. The only real difference between lists and tuples in Python is that lists are , whereas tuples are not. I personally tend to carry over the conventions from functional programming: use lists for any number of elements of the same type, and tuples for a fixed number of elements of predetermined types. Question After the lengthy preamble, comes the inevitable question. Which method (do you think) is best? I have two desktops (one of which I'm using as a server), my main machine has a weaker i5 cpu, my server has a stronger i7 cpu. On my main machine I am experiencing stutters because the CPU often runs at full load under regular use (strangely, I also use upwards of 10GB of RAM, no joke... The heaviest program I'm running is google chrome).  I was wondering if there was any possible way to share a cpu from one machine over network to another machine as an emulated processor, which could be used by the client machine in a similar sort of fashion as virtual machines use or "borrow" their host's cpu.  This way I could offload work onto the server's cpu when the main cpu is under full load to prevent annoyances like stutter, and possibly combine both of them for more intense tasks (like decryption, compilation, archiving or other multithreaded stuff)  Does this sort of software exist, or has anyone at least tried to make it? If not, is it feasible?  (This sort of program would also ideally be able to offload data onto the server's RAM for faster processing, since the now common gigabit connections get to have nearly the same speeds as a standard HDD this doesn't sound far fetched either)  To reiterate, what I am primarily looking for is the ability to offload work from a system's main cpu when it is under too much load and forwarding it to another computer's cpu over network.