How can I efficiently extract repeated elements in a Ruby array?
How to find and return a duplicate value in array
I'm trying to prove commutativity of addition for vector spaces, using the axioms for vector spaces. Apparently commutativity can be proven! Im having trouble getting a good feel for what is allowed and what is not. Here's my work so far:  $u+v+u+v = 2(u+v) = 2u + 2v = u+u+v+v = u+(u+v)+v$  Here I just wanna claim that $u+(v+u)+v = u+(u+v)+v$   $\Rightarrow -u+u+(v+u)+v+(-v) = -u+u+(u+v)+v+(-v)$ : here im just adding -u to the right, and -v to the left. Question: is this "adding to both sides" really legit in this context? Why?   Quick help proof: $-v+v = (-1)v+(1)v = (-1+1)v = 0v = 0 = v-v$  And another: $ 0+v = v+(-v) + v = (1)v + (-1)v + v = (1-1)v + v = v = v+0$  We have $0 + (u+v) + 0 = 0+(v+u)+0 \Rightarrow u+v = v+u$  This feels ugly and not at all elegant, especially the great leap "add -u to both sides" feels completely out of place. Do I need more lemmas? Is there a more elegant way?   //not homework or anything, just for my own pleasure, feel free to provide theory, as it is more insightful than solutions. :) Thanks!   EDIT: corrected notation a little. Manganese has more unpaired electrons than Iron so why is Iron ferromagnetic Manganese paramagnetic? Manganese has five unpaired electrons, but Iron has four, then why is Iron ferromagnetic and Manganese paramagnetic? What's that property I'm missing? Typing the ZIP code doesn't yield the company page To hyphenate or not? As a non-native speaker of English and an engineer by training, I always get confused about hyphenation and almost always end up referring to Google every time I need to make that decision.  Does anybody know of a concise, comprehensive style guide to hyphenation that explains this rather complex issue, once and for all? Is there a dollar amount that, when adding Massachusetts Sales Tax, precisely equals $200? singlespacing in table with no indent LaTeX seems to be having problems handling nested optional arguments. I've included a minimal code example that generates the error:  \documentclass[12pt,oneside]{book} \begin{document}  \newcommand{\termbad}[2][]{#2#1} \newcommand{\termgood}[2][]{#2#1}  \newcommand{\up}[1]{#1} \newcommand{\dd}[1][]{#1}  \termgood{\up{Tart}}{Pop} \termbad[\up{Tart}]{Pop}      \termgood{\dd[Tart]}{Pop} \termbad[{\dd[Tart]}]{Pop} %\termbad[\dd[Tart]]{Pop}   \end{document}   If you run this code, it works. If you remove the % in the second to last line, it fails with:  Runaway argument?  Tart{Pop} \par \par \end {document}  !File ended while scanning use of \dd.   After further tinkering, I have discovered the problem: LaTeX is reading the ] for the inner optional argument as the end of the outer optional argument and then passing a malformed argument in. So it is passing in \dd[Tart as the optional argument to \termbad instead of \dd[Tart].  This still feels like a bug to me. Nesting braces in arguments works, brackets should as well. The following are workarounds:   Enclose the inner optional argument in braces (as in the line before %). Redefine your inner function to require its argument instead of using optional arguments. Redefine your outer function to require its argument instead of using optional arguments.   Any one of the three works around the issue.  (Reposted here; question was originally posted to stackexchange and then closed instead of being migrated.) How to prevent iTerm2 from creating overlaps and broken lines after pasting multiline chunks of text? If I paste multiline chunks of text into iTerm2, I always a get mess of output. It seems limited to only some programs running interactively (such as Bash, IRB - Python / VIM work flawlessly). Using Apple's native Terminal, I can paste whatever I want wherever I want - it works. For example, this sample text ():  echo Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. echo Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit. echo Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. echo Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. echo Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ut gravida lorem. Ut turpis felis, pulvinar a semper sed, adipiscing id dolor. echo Pellentesque auctor nisi id magna consequat sagittis. Curabitur dapibus enim sit amet elit pharetra tincidunt feugiat nisl imperdiet. echo Ut convallis libero in urna ultrices accumsan. Donec sed odio eros. Donec viverra mi quis quam pulvinar at malesuada arcu rhoncus. [snip]   pasted into IRB produces this in iTerm2:    while it produces this in native Terminal:    I am running the latest versions of OSX and iTerm2. What's going wrong here? How to search the internet for terms with special characters What is the probability that when you place 8 towers on a chess-board, none of them can beat the other. What is the probability that when you place 8 towers on a chess-board, none of them can beat the other.  Attempt: ${64 \choose 8}^{-1} \approx1$ in $4\ 400\ 000\ 000$  Correct answer: ${64 \choose 8}^{-1} \cdot 8! \approx 1$ in $9\ 000\ 000$.  I disagree with the $8!$. If there's combinations (binomial coefficient) in the denominator, why would there be permutations i.e. the order counts, in the numerator? I  and while on other sites I did not get a 'Reputation Notification' to explain that I was given 2 upvotes for my answer - yet if I manually check my Profile here at meta.SE my total Reputation is in agreement with the amount there.  I'm not knowledgeable about the intercommunication between the servers and sites but I would explain it this way: Super User either failed to send or other sites failed to receive the message the I had a reputation update on Super User.  I should have received either two green star trophies (🏆) of 10 reputation each or one of 20; depending on when I returned to one of the Stack Exchange / Stack Overflow / Super User / etc. sites.  Here's a screenshot showing no reputation change notification for Super User:    Here's a screenshot of my Profile over at Super User showing that I was silently credited:    I'm bringing this up on Meta.SE in case the communication is broken between more sites than just Super User and everywhere else. jQuery/JavaScript: accessing contents of an iframe I would like to manipulate the HTML inside an iframe using jQuery.  I thought I'd be able to do this by setting the context of the jQuery function to be the document of the iframe, something like:  $(function(){ //document ready     $('some selector', frames['nameOfMyIframe'].document).doStuff() });   However this doesn't seem to work. A bit of inspection shows me that the variables in frames['nameOfMyIframe'] are undefined unless I wait a while for the iframe to load. However, when the iframe loads the variables are not accessible (I get permission denied-type errors).  Does anyone know of a work-around to this? Currently the migration path options from SO are:   Meta.SO Serverfault SuperUser Webmasters Programmers   If we are going to be limited to 5 options, shouldn't we periodically re-evaluate which sites are most appropriate?   (10k only) indicate that the top sites for the last 90 days are:   Superuser - 564 - 5% rejected ServerFault - 278 - 10% rejected Tex - 157 - 13% rejected DBA - 144 - 2% rejected Sharepoint - 127 - 1% rejected Programmers - 126 - 26% rejected CodeReview - 100 - 3% rejected Meta.SO - 81 - 18% rejected Wordpress - 75 - 14% rejected Webmasters - 58 - 8% rejected   All these migrations for sites out of the list required a flag and a moderator to process it.  This is just extra work for the mod team!  If we had the top 5 destinations by volume as the 5 options, we would have had a net savings of 160 flags to be processed.  I suspect we will actually see these numbers change quite a bit if it's easier for users to put questions in the appropriate spot without moderator intervention.  Can we have a review of the migration path list based on migration volume?  Think of the flags! Can't format / delete locked partition from GParted? Add the font changes as options in our preferences Check if email exist php Cleaning ‘staining’ off bottom of MacBook screen A couple months ago, I started to see some very small stain spots on the bottom of my MacBook Pro early 2015 screen. It's very annoying to see while I'm using it. When the screen is turned off, I see it as in the picture below. But when it's turned on, I see it as very small water-ish drops. I tried to clean it using water, screen cleaner, and even alcohol, but it didn't go away.  Also that area doesn't feel as smooth as the unaffected area. So, I think it's on the outside of my screen not inside.  Have you ever seen this before? Any suggestions on how to remove it without the need of replacing the whole screen? Will Ubuntu get patched against Meltdown and Spectre? The following is a canonical post that attempts to cover a broad number of Meltdown and Spectre questions.  It is being maintained by Thomas Ward who is in contact with the Security and Kernel teams on this matter for other reasons as well.   I recently read about the  vulnerabilities.  I was wondering, will Ubuntu be patching against the vulnerabilities?  And is there an ETA on a fix? How to express trigonometric equation in terms of of given trigonometric function? “Unable to Connect to World” Minecraft PE 1.16.201 So my brother and I have been playing Minecraft together on our iPads for years now, but in September I got a new iPad Pro 3rd Generation and I’ve been having issues with Minecraft ever since. Every time we have tried to join each other’s worlds we get the message “Unable to connect to world”. Recently after the update on December 16th, it worked for about a week without having any issues, but now it has gone back to not letting us connect to the worlds. Both of us are able to connect to other people’s worlds, but not each other’s, we’ve tried many things to fix this but so far nothing has worked. If you have any ideas for what we should do please let me know, thank you so much!