Iterate two Arrays with ForEach statement in C#
Iterate two Lists or Arrays with one ForEach statement in C#
Easily measure elapsed time 16 GB USB flash drive capacity down to 938 MB After writing the FreeNAS IMG to a 16 GB USB flash drive, I can now only use 938 MB. I used the Win32 Disk Imager tool to write the IMG to the device. Then later, when I inserted the the USB drive into my Windows 7 computer it said that it had to be formatted, because it couldn't read it. I believe this is normal. So I formatted it inside Windows using the format option when prompted. So in Windows Explorer now, 938 MB is reported as capacity of this device.    Also, when i check the properties dialog box I can see the same numbers.    And when I check with diskmgmt.msc I can see there are several volumes I don't recognize and unallocated space of 12.79 GB.    Now, I have another 2 GB USB flash drive with the same problem. It too was used for FreeNAS, and it too has a reported capacity of only 938 MB. I thought it was broken there for a while, until I saw the same problem with this 16 GB model.  I tried using diskpart on the 2 GB model, and I saw that there were several partitions there (list partitions) just like on this one. So I used the clean option to try to wipe it, but that wiped off everything so it's totally useless now. I'm not sure how to rebuild it.  Is this a standard routine, like part of the whole "user experience", that whenever you make a bootable USB falsh drive with FreeNAS, it messes up your device? I am new to FreeNAS, so i wouldn't know. But it sure looks like it. Maybe it is in fact the format operation in Windows that messes things up... I don't know. It's not very nice.  How do I restore the capacity back to 16 GB-ish (14.9 GiB)? Error handling in C code What do you consider "best practice" when it comes to error handling errors in a consistent way in a C library.  There are two ways I've been thinking of:  Always return error code. A typical function would look like this:  MYAPI_ERROR getObjectSize(MYAPIHandle h, int* returnedSize);   The always provide an error pointer approach:  int getObjectSize(MYAPIHandle h, MYAPI_ERROR* returnedError);   When using the first approach it's possible to write code like this where the error handling check is directly placed on the function call:  int size; if(getObjectSize(h, &amp;size) != MYAPI_SUCCESS) {   // Error handling }   Which looks better than the error handling code here.   MYAPIError error; int size; size = getObjectSize(h, &amp;error); if(error != MYAPI_SUCCESS) {     // Error handling }   However, I think using the return value for returning data makes the code more readable, It's obvious that something was written to the size variable in the second example.  Do you have any ideas on why I should prefer any of those approaches or perhaps mix them or use something else? I'm not a fan of global error states since it tends to make multi threaded use of the library way more painful.  EDIT: C++ specific ideas on this would also be interesting to hear about as long as they are not involving exceptions since it's not an option for me at the moment... DKIM sign outgoing mail from any domain (with Postfix and Ubuntu) I got DKIM setup on my mail server (postfix and ubuntu) so it signs outgoing emails.  I used these instructions:   However, I need it to sign emails from any domain (in the From address) and not just my own.  I'm building an email newsletter service and clients will be sending their own email through the server.  First I set "Domain *" in /etc/dkim-filter.conf.  This got it to include the DKIM headers in all outgoing emails, no matter what the domain.  However, the verification check fails on gmail because it is checking the domain in the from address, and not my domain (and dns record).  Does anyone know how to do this? How do I make Endermen spawn more frequently? I'm playing vanilla Minecraft, and am getting ready to head to the end.  I need Eyes of Ender (and hence Ender Pearls), and in my main hunting grounds (a large desert area) as little as one Enderman may spawn per night.  Is there any way to "promote" Enderman spawning so I can get pearls more quickly? Recording claimable expenses in GnuCash I am new to accounting and trying to learn a few things as my accounts get more and more complicated.  I currently use GnuCash to record simple income/expenses/assets/liabilities and have had a new situation I don't know how to record.  I am currently billing some expenses for work and for my kayak club to my personal credit card.  Under normal circumstances I would do the following (my +/- may be backwards):  Expense +$100 Credit Card -$100  and then when the credit card bill comes I would pay it off  Credit Card +$100 Chequing Account -$100  For expenses that I get reimbursements for I would like to be able to note that I paid for the expense with my credit card and that I paid off my credit card with my chequing account.  At the same time, I would like to be able to create another parent account (maybe "claimable expenses") that shows that I purchased the item, and was then reimbursed so that an individual expense for work or my club has a zero balance.  I tried to look this up in previous threads but didn't quite understand how to apply this to my situation Any advice would be appreciated. Referencing bib files with spaces in the filename I am using a Mac with TeX Live and Mendeley for automatically generating .bib files, some of which have spaces in the file names. I would like to know how to reference such files from LaTeX as using "" or \ doesn't seem to work. How to filter a dictionary according to an arbitrary condition function? Using global variables in a function Good math books for physicists In his first lesson (transcripted in "Tips on Physics"), Feynman talks about math for physicists in a very cool and practical way. And at the end of the section he talks something like "so the first thing to do is to learn to learn derivative, integral and algebra" (I don't know how much precise I'm being because I've read it in Portuguese). I would to know if there is some book that deals with math as Feynman did it in this lesson (respecting formalities, but teaching how to use the practical rules)? Also, someone have any recommendations for algebra book (college level)? Bmp to jpg/png in C# Why does the order of summation of the terms of an infinite series influence its value? I was looking through my lecture notes and got puzzled by the following fact: if we want to find the value of some infinite series we are allowed to rearrange only the finite number of its terms. To visualize this consider the alternating harmonic series: $$\sum_{n=1}^\infty(-1)^{k-1}\frac1k=1-\frac12+\frac13-\frac14+\frac15-+\dots=0.693147...$$  But if we rearrange the terms as follows the value of the series gets influenced by this action: $$1+\frac13-\frac12+\frac15+\frac17-\frac14+\dots=1.03972...$$  So commutativity of addition isn't true on infinity? How was it obtained and how can it be proved? I have a laptop which I hook up to an external display when I'm at home. I also connected an external keyboard and mouse which makes it more comfortable for me.  I have noticed that pressing caps lock on the external keyboard does not light up the capslock indicator of the laptop keyboard (and vice versa).  When googling, I came across the setleds function, but when I type it into a console all I get is this:  KDGKBLED: Inappropriate ioctl for device Error reading current flags setting. Maybe you are not on the console?   Any idea if I can get this working? String concatenation: concat() vs "+" operator I have the following reference:  @MISC{EX2012,   author = {{S}ingle {A}uthor {O}rganization},   year = {2012},   title = {Example} }   A citation for this is breaking after "Author", but extending beyond the margin, as shown in the following example layout in the PDF:  Demo text demo text demo to margin Demo text which cites it (Single Author Organization, 2012) and flows over the margin.   How can I solve this? I am using natbib and citing with \citep{EX2012}. Diamond moderator privileges vs. 10k rep privileges? As we are in election period, I don't get the difference between getting to 10k reputation point and the diamond. What additional controls do you earn with the diamond ? Is it feasible to build a stream cipher from a cryptographic hash function? A few years ago I devised a symmetric-key system that worked like so:  H()   = some hashing function h     = the number of bits in the result of H() key   = bits to be used as a key ^     = the XOR operation +     = concatenation len() = the length function (in bits)  max = ceiling(len(cipertext) / h) pad = pad_0 + ... + pad_max pad_0 = H(key) ^ H(plaintext) pad_n = H(pad_(n-1)) cipherpart_n = plaintext_n ^ pad_n ciphertext = H(plaintext) + cipherpart_0  + ... cipherpart_max   Basically, it builds up a "pad" based on the hash of the message and hash of the key and XORs the message against it.  I am not actually an expert, so I was wondering why an approach like this isn't very common. Is it possible to access a 64-bit dll from a 32-bit application? Use property to show that if $f_n \rightarrow f$ in measure on finite measure set $E$ then $f_n^2 \rightarrow f^2$ in measure on $E$. Consider the following problem:     Let $E$ have finite measure, $\{f_n\} \rightarrow f$ in measure on $E$ and $g$ be a measurable function on $E$ that is finite almost everywhere. Use the fact that $\{f_n \cdot g\} \rightarrow f_n \cdot g$ to prove that $\{f_n^2 \} \rightarrow f^2$ in measure on $E$. Infer from this that if $\{g_n\} \rightarrow g$ in measure on $E$ then $\{f_n \cdot g_n \} \rightarrow f \cdot g$ in measure on $E$.   I'm struggling understand how I can apply the fact that $\{f_n \cdot g\} \rightarrow f_n \cdot g$ in measure to prove that $\{f_n^2 \} \rightarrow f^2$ in measure. I've been able to come up with a proof of the fact that if $\{g_n\} \rightarrow g$ in measure then $\{f_n \cdot g_n \} \rightarrow f \cdot g$ in measure, and this clearly implies the claim that $\{f_n^2 \} \rightarrow f^2$ in measure. Unfortunately my proof doesn't rely on the fact that $\{f_n \cdot g\} \rightarrow f_n \cdot g$ so it doesn't answer the problem since it explicitly asks us to prove it a certain way.  So far my best attempt to utilize the fact is as follows. Let $\eta &gt; 0$ then by triangle inequality and monotonicity of measure  \begin{align*}     \lim_{n\rightarrow \infty}\mu\left\{ \left|f_n^2 - f^2\right| &gt; \eta \right\} &amp;\leq \lim_{n\rightarrow \infty}\mu \left\{\left|f_n - f\right|\cdot \left|f_n\right| + \left|f_n - f\right| \cdot \left|f\right| &gt; \eta \right\} \\     &amp;\leq \lim_{n\rightarrow \infty}\mu\left\{\left|f_n - f\right|\cdot \left|f_n\right| &gt; \eta/2 \right\} + \lim_{n\rightarrow \infty}\mu\left\{\left|f_n - f\right| \cdot \left|f\right| &gt; \eta/2 \right\} \end{align*}  By the fact that $\{f_n \cdot f\} \rightarrow f \cdot f$ in measure \begin{equation*} \lim_{n\rightarrow \infty}\mu\left\{\left|f_n - f\right| \cdot \left|f\right| &gt; \eta/2 \right\} = \mu\left\{\left|f_n \cdot f - f\cdot f\right| &gt; \eta/2 \right\} = 0. \end{equation*} I don't see how to deal with the other limit without first proving the most general statement $\{f_n \cdot g_n \} \rightarrow f \cdot g$ in measure.   Any help or advice is greatly appreciated. I've discovered a rather weird behaviour of PdfLaTeX. In this example  \documentclass{article} \usepackage[breaklinks]{hyperref} \begin{document} \url{http://www.emarketer.com/blog/index.php/quick-stat-smartphone-users-account-38-mobile-phone-users/} \end{document}   PdfLaTeX won't break the URL and create a too long line. However, if I replace \url with \href like this:  \documentclass{article} \usepackage{hyperref} \begin{document} \href{http://www.emarketer.com/blog/index.php/quick-stat-smartphone-users-account-38-mobile-phone-users/}{http://www.emarketer.com/blog/index.php/quick-stat-smartphone-users-account-38-mobile-phone-users/} \end{document}   I get the line broken, but the font of the link is not right any more of course (normal instead of texttt). Why doesn't URL break the line at dashes and what could I do to get a nicely typeset line-broken link?