Regex to match URL, ends up matching URL plus closing brackets when URL is between brackets
What is the best regular expression to check if a string is a valid URL?
Mac mini Mac OS 10.6 server migration to new hardware I have a Mac Mini with Mac OS X 10.6 Server installed. It has two external drives attached to it. One is for Time Machine and other contains data. I have bought the latest Mac Mini with Mac OS X 10.7 and two new hard drives. I want to migrate to the new hardware (the new Mac Mini and the new hard disks). Can Migration Assistant do that for me or do I have to transfer the data in the external drive manually? Intuitive explanation for dividing by $n-1$ when calculating standard deviation? I was asked today in class why you divide the sum of square error by $n-1$ instead of with $n$, when calculating the standard deviation.  I said I am not going to answer it in class (since I didn't wanna go into unbiased estimators), but later I wondered - is there an intuitive explanation for this?! Lifting idempotents modulo a nilpotent ideal The problem is this:      Suppose $I \subseteq R$ is a nilpotent ideal and there is $r \in R$ with $r \equiv r^2 \pmod I$. Show $r \equiv e \pmod I$ for some $e \in R$ idempotent.   I have spent a few hours rolling around in abstracta with no destination. I believe that if I could write down a concrete example of this, the example could guide me through the abstract definitions and show me where to look for an idempotent in $R$. I have looked at 2x2 matrices and could not find any such examples. Might anybody have one? How do I animate time? Actual memory usage of a process The following are the memory usage of mysql and apache respectively on my server. As per the output of pmap say, mysql is using about 379M and apache is using 277M.   [root@server ~]# pmap 10436 | grep total  total           379564K  [root@server ~]# pmap 10515 | grep total  total           277588K   Comparing this with the output of top, I see the values are almost matching.    PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND 10515 apache    20   0  271m  32m 3132 S  0.0  6.6   0:00.73 /usr/sbin/httpd 10436 mysql     20   0  370m  21m 6188 S  0.0  4.3   0:06.07 /usr/libexec/mysqld --basedir=....   Now these values definitely are not the current memory usage of those two processes, since if it were it would've exceeded the 512M ram on my system and I understand the fact that these are the size of the pages assigned to these two processes and not really the size of the memory actively used by them. Now, when we use pmap -x, I see an extra coloumn Dirty which shows far less memory usage for the process. As seen in the example show below, the Dirty coloumn shows 15M as opposed to 379M in the first coloumn. My question is: Is the value under coloumn Dirty is the 'real' amount of memory actively used by that process? If its not, then how can we find out the real memory usage of a process? Not ps and top for the same reasons above. Do we have anything under /proc that will give this info?  [root@server ~]# pmap -x 10436 | grep total total kB          379564   21528   15340 [root@server ~]#   [root@server ~]# free -m              total       used       free     shared    buffers     cached Mem:           489        447         41          0         52        214 -/+ buffers/cache:        180        308 Swap:         1023          0       1023 [root@server ~]# I didn't find the difference between them by  googling  Edit: Thx litterally, authenticate, means prove its identity, which is a just a subprocess of global access authorization btw I forgot to mention "Sign In", that's another confusing term for me ;)  Edit 2 other useful answers: How should a bot earn enough reputation to perform the actions necessary for that bot? We all know it: bots that chat. There are also bots that flag, or perform other actions. And usually we like them for doing that, like . So every now and then, a new bot is created, and usually you would ask a question using that bot or suggest enough edits to get the reputation necessary for that bot to operate. Instead of suggesting 100 edits, Undo has found a more efficient way, namely by . Now someone could frown on this action or not, actually it is the least intrusive way to get the bot the reputation necessary (I guess no one really likes a bot to suggest 100 edits just for the sake of earning enough reputation). The question is: is this actually the best way? Was this action allowed or should we look away because it is Smokey? Should we maybe have a special bot user status which derives the privileges from its master user? Anything else you want to share on this? Related: How to pipe the result of 'date' command to 'mv' command I want to rename my file to the current timestamp.I know how to get the current timestamp("date +%s") but how can I pipe it to 'mv' command? A similar task for changing the desktop background, can be achieved using the following script:   FILE="/backgrounds/background.png" gsettings set org.gnome.desktop.background picture-uri "$FILE"   How would I achieve the same result, but with the user's avatar/profile picture? $\exp(A)$ is orthogonal iff $A$ is skew symmetric Let $A \in M_n(\mathbb R)$ and $\exp(A)=\sum_{i=0}^{\infty}\frac{A^i}{i!}$. How to prove $\exp(A)$ is an orthogonal matrix iff $A^t=-A$?  I can get that $\exp(A)$ is an orthogonal matrix iff $\exp(A^t)=\exp(-A)$, but how to get $A^t=-A$ from it?  What's more, is $\exp(A)$ injective or not? Lets say I have something like:   \[ Let x = number of cats \]   (This is a contrived example, but pretend we are actually inside a long align environment block...) "Let" and "number of cats" need to be written like normal text, while x= needs to be math type text.  I've seen this:  \[ \mbox{Let } x = \mbox{ number of cats} \]   and this:  \[ \textrm{Let } x = \textrm{ number of cats} \]   They seem to produce equivalent output, but I'm not sure which is the "correct" one. Also, they are not ideal in that the extra space needs to be placed inside the text mode block, otherwise it is ignored as math mode and butts the text right up against the math.  Ideally there would be some command which allowed embedding text into an equation, which correctly inserted leading and trailing space around the block as required without adding space inside the text block.  How does one do that "correctly"? Random weighted choice Consider the class below that represents a Broker:  public class Broker {     public string Name = string.Empty;     public int Weight = 0;      public Broker(string n, int w)     {         this.Name = n;         this.Weight = w;     } }   I'd like to randomly select a Broker from an array, taking into account their weights.  What do you think of the code below?  class Program     {         private static Random _rnd = new Random();          public static Broker GetBroker(List&lt;Broker&gt; brokers, int totalWeight)         {             // totalWeight is the sum of all brokers' weight              int randomNumber = _rnd.Next(0, totalWeight);              Broker selectedBroker = null;             foreach (Broker broker in brokers)             {                 if (randomNumber &lt;= broker.Weight)                 {                     selectedBroker = broker;                     break;                 }                  randomNumber = randomNumber - broker.Weight;             }              return selectedBroker;         }           static void Main(string[] args)         {             List&lt;Broker&gt; brokers = new List&lt;Broker&gt;();             brokers.Add(new Broker("A", 10));             brokers.Add(new Broker("B", 20));             brokers.Add(new Broker("C", 20));             brokers.Add(new Broker("D", 10));              // total the weigth             int totalWeight = 0;             foreach (Broker broker in brokers)             {                 totalWeight += broker.Weight;             }              while (true)             {                 Dictionary&lt;string, int&gt; result = new Dictionary&lt;string, int&gt;();                  Broker selectedBroker = null;                  for (int i = 0; i &lt; 1000; i++)                 {                     selectedBroker = GetBroker(brokers, totalWeight);                     if (selectedBroker != null)                     {                         if (result.ContainsKey(selectedBroker.Name))                         {                             result[selectedBroker.Name] = result[selectedBroker.Name] + 1;                         }                         else                         {                             result.Add(selectedBroker.Name, 1);                         }                     }                 }                   Console.WriteLine("A\t\t" + result["A"]);                 Console.WriteLine("B\t\t" + result["B"]);                 Console.WriteLine("C\t\t" + result["C"]);                 Console.WriteLine("D\t\t" + result["D"]);                  result.Clear();                 Console.WriteLine();                 Console.ReadLine();             }         }     }   I'm not so confident. When I run this, Broker A always gets more hits than Broker D, and they have the same weight.  Is there a more accurate algorithm?  Thanks! Should I format /sdcard and /data if I want to wipe all personal data with Cyanogenmod? I'm trying to completely wipe all personal data from my Nexus 4 with CM installed. I've seen different advice on different sites for making sure all my data is gone:   Just do 'Factory Reset'. Do 'Factory Reset' at least 3 times. Do 'Factory Reset' and wipe dalvik cache. ...   and so on... I'm interested in erasing all traces of my personal data from the device. It's a Nexus 4, so there is no removable storage to worry about.  My guess would be to 'wipe data/factory reset' and 'wipe cache partition' in the main recovery menu. In the mount/storage menu, I would choose 'format /cache', 'format /data', and 'format /data and /data/media (/sdcard)'. Finally, in the advanced menu, I would choose 'wipe dalvik cache'.   Is this thorough enough? Should I also choose 'format /system', 'format /firmware', etc? Are there any options I should steer clear from? I would like the phone to boot to a fresh Cyanogenmod after clearing all data. What kind of mortar should I use to point a fieldstone foundation?  The old mortar is crumbling, and sandy mortar is falling out onto the basement floor.  I plan to remove the crumbling mortar (see ), then point the foundation with new mortar.  But what kind of mortar should I use?    I have had a hard time finding definite answers about fieldstone foundations on the Internet, but I'll include some of what I've found here.  First,  has this to say about fieldstone foundations:     Most fieldstone foundations have, or had at some time, a thin mortar coating on the face of the stone. The purpose of this coating was to assist in holding the stones in place. This thin mortar coating will inevitably flake off from any moisture migration, revealing the surface of the stones. As this coating continues to erode, the mortar between the stones will begin to crumble and the soft, sandy mortar begins to slowly fall out onto the basement floor. It looks like a small pile of sand at the base of the foundation. When this occurs, tuck pointing is needed to refill the voids where the old mortar has fallen out. It's very important that you scrape away or chip away the crumbling mortar (in between the stones) in order to establish a small cavity or key way which can hold the new mortar that is being applied. Never apply new mortar over any old crumbling mortar, as this is a temporary fix and it will only last a couple years. All crumbling mortar must be removed in order for the newly applied surface to bond properly. While upgrading your field-stone foundation, only work on a section at a time. Do not remove the old mortar throughout the entire basement all at once. Complete all removal, tuck pointing and parging one section at a time.       To avoid annual tuck pointing, you should finish the foundation with a complete top coating of mortar. Be sure it is lime based. This top coat does not have to look like a stone artisan's creation: It merely has to serve the purpose of keeping the newly installed mortar in place. It's sort of like applying a frosting to a cake.    seems to suggest that I should be using not straight type-S hydrated lime, but type-S mortar, which consists of one part Portland cement, ¼ to ½ part lime, and an amount of sand equal to 2¼ to 3 times the total volume of cement and lime.  Do I need to analyze the existing mortar to make sure that the new mortar has the same lime content, as ?  Should I expect the new mortar to start crumbling and releasing dust soon, or should it stay solid and dust-free for many years? Why is my Spring @Autowired field null? What is a magic number, and why is it bad? How can I efficiently generate a Set from a List structure? I have a bit of code where I've written a SOQL query that returns a list of SObject records, however I need a Set&lt;Id&gt; structure to pass to another method that I don't have control of (and thus can't change the method signature of).  How can I turn my returned List&lt;SObject&gt; into a Set&lt;Id&gt;? Is the best option just a for loop? Get text from pressed button I am trying to mimic the interesting proof from  to give a generating set of the ideal correspond to the $d$-uple embedding: We fix the notation $\Delta = \big\{ (\nu_0, \dots, \nu_n) \in {\mathbb{N}}^{n+1}_0 ~:~ \nu_0 + \dots + \nu_n = d \big\}$. The polynomial map is $\theta : k[y_\nu : \nu \in \Delta] \rightarrow k[x_0, \dotsc, x_n]$ given by $$ \theta ( y_\nu ) := x^{\nu_0}_0 \cdots x^{\nu_n}_n $$ and we know that ${\mathrm{ker}}~\theta$ is the ideal of the $d$-uple embedding, i.e., $\rho_d({\mathbb{P}}^n) = Z({\mathrm{ker}}~\theta)$ (cf. Exercise I.2.12 Hartshorne). Now let $W \leq k[y_\nu : \nu \in \Delta]$ denote the ideal $$ W := \Big\langle y_{\tau_1} y_{\tau_2} - y_{\tau^{\prime}_1} y_{\tau^{\prime}_2} ~:~ \tau_1, \tau_2, \tau^{\prime}_1, \tau^{\prime}_2 \in \Delta, \tau_1 + \tau_2 = \tau^{\prime}_1 + \tau^{\prime}_2 \Big\rangle $$ Clearly, $W \subseteq {\mathrm{ker}}~\theta$. Using the lemma in the above link, we need to produce a $k$-subspace $T \subseteq k[y_\nu : \nu \in \Delta]$ with the conditions $$ T + W = k[y_\nu : \nu \in \Delta], \hspace{.2in} \theta \lvert_{T} = {\mathrm{injective}} $$ After a few thoughts it seems reasonable to think of the following subspace as a candidate for $T$: First define the equivalence relation on $\Delta \times \Delta$ given by $(\tau_1, \tau_2) \sim (\tau^{\prime}_1, \tau^{\prime}_2)$ if $\tau_1 + \tau_2 = \tau^{\prime}_1 + \tau^{\prime}_2$. Let $\Omega \subseteq \Delta \times \Delta$ be a subset with a unique representative from each class of $\sim$. Now let $T$ be the $k$-span of the monomials $y^{\alpha_1}_{\tau_1} \dotsc y^{\alpha_r}_{\tau_r}$ (with the distinct elements $\tau_1, \dotsc, \tau_r \in \Delta$ and $\alpha_1, \dotsc, \alpha_r \geq 1$) such that $(\tau_i, \tau_j) \in \Omega$ for each $i \neq j$. Clearly, $\theta$ is injective if restricted to $T$. I got lost in the step : Each monomial $M$ of $k[y_\nu : \nu \in \Delta]$ satisfy $M \equiv b$ mod $W$ for some $b \in T$. Did I do anything wrong? Why might one also use a blank constructor? I was reading some Java recently and came across something (an idiom?) new to me: in the program, classes with multiple constructors would also always include a blank constructor. For example:   public class Genotype {   private boolean bits[];   private int rating;   private int length;   private Random random;    public Genotype() {              //  &lt;= THIS is the bandit, this one right here     random = new Random();   }    /* creates a Random genetoype */   public Genotype(int length, Random r) {     random = r;     this.length = length;     bits = new boolean[length];      for(int i=0;i&lt;length;i++) {         bits[i] =random.nextBoolean();     }   }    /* copy constructor */   public Genotype(Genotype g,Random r) {     random = r;     bits = new boolean[g.length];     rating = g.rating;     length = g.length;      for(int i=0;i&lt;length;i++) {         bits[i] = g.bits[i];     }    } }   The first constructor doesn't seem to be a "real" constructor, it seems as though in every case one of the other constructors will be used. So why is that constructor defined at all?