i have a problem whit c#, please someone convert this javascript function to c#.  function mycrc(str) {         var c;         var crcTable = [];         for(var n = 0; n &lt; 256; n++){             c = n;             for(var k = 0; k &lt; 8; k++){                 c = ((c&amp;1) ? (0xEDB88320 ^ (c &gt;&gt;&gt; 1)) : (c &gt;&gt;&gt; 1));             }             crcTable[n] = c;         }        var crc = 0 ^ (-1);     for (var i = 0; i &lt; str.length; i++ ) {         crc = (crc &gt;&gt;&gt; 8) ^ crcTable[(crc ^ str.charCodeAt(i)) &amp; 0xFF];     }     return (crc ^ (-1)) &gt;&gt;&gt; 0; }
How do I calculate the CRC32 (Cyclic Redundancy Checksum) of a string in .NET?
When closing a question as a duplicate, it is becoming harder and harder to search for a good original as the pool of questions and answers grows and grows.  While the new dupe closing dialog is a huge step forward, it doesn't always work - if you've spent some time on the site, you know there are perfect answers to many new questions but you can't always find them. Or can't be bothered to, as your time is limited.  A way to further improve this could be introducing a vote for canonical answers.  It could, for example, work like this:   Answers get a new icon, the "canonical vote" (signified here by a cannon because I can't think of anything that makes sense right now.)     Only users with a certain minimum rep (maybe 1k+ or 2k+) see this icon. The icon would work like the favourite icon: You can toggle it on or off at any time. The hover message for the icon could read e.g.      This is a "canonical answer": It answers the question asked in the most extensive and general way, and is very likely to benefit other users with the same problem.    Questions that contain an answer with three or more canonical votes get special  treatment:      They show up on the top in search results; maybe even under a special heading ("Questions with canonical answers")  They show up prominently in the "close as dupe" dialog (i.e. the canonical votes influence the metric that is used to determine the questions shown there).  There could be some rewards for users whose answers receive "canonical" votes - maybe a badge if ten of your answers get at least three canonical votes, or a counter of canonical answers in your profile. It would be really interesting as it's a badge that you can't game your way to, but this whole rewarding part is entirely optional.  would be a great safeguard against over-use of this feature.    Dupe (but sans cannon):       Related: This week I saw the definition of a measurable set for an outer measure.     Let $\mu^*$ be an outer measure on a set $X$. We call $A \subseteq X$ measurable if $$\mu^*(E) = \mu^*(A\cap E) + \mu^*(A^c\cap E)$$ for every $E \subseteq X$.   This is not the first time I've seen this definition. Unlike most other things in mathematics, over time I have gained absolutely no intuition as to why this is the definition.   The only explanation I've ever seen is that a set is measurable if it 'breaks up' other sets in the way you'd want. I don't really see why this is the motivation though. One reason I am not comfortable with it is that you require a measurable set to break up sets which, according to this definition, are non-measurable; why would you require that? Of course, you can't say what a non-measurable set is without first defining what it means to be measurable so I suppose no matter what your condition is, it will have to apply to all subsets of $X$.     Is there an intuitive way to think about the definition of measurable sets? Is there a good reason why we should use this definition, aside from "it works"? How do I make protocol foo hostname-aware? This is a  about hostname-awareness and proxying.   I know that some protocols are hostname-aware; that is, when I connect to the HTTP server at www.example.com it knows I want www.example.com's HTTP service, not www.example.net's, even though they are on the same IP address.  How can I do this for protocol foo?  (Temporary note: this question appears pursuant to .) According to the official sources, is the radioactive green crystal that serves as Superman's Achilles' heel actually composed of the noble gas krypton, or is it supposed to be made out of some other substance? If so, what is that substance? Why didn't Harry die in the dark forest? Looking at the picture below, it's easy to see why the perimeter of a polygon inscribed in a circle is an underestimation of the circle's perimeter. This follows from the triangle inequality: Any side (say $AB$) of the polygon is shorter than the circular arc with the same endpoints ($\stackrel{\frown}{AB}$). Summing all these inequalities shows the perimeter of the inscribed polygon is indeed smaller than that of the circle.  I'm wondering if there is proof that the perimeter of a circumscribed polygon always overestimates the perimeter of the circle, which is as simple as that of the inscribed polygon case. Thanks! Why does Quantum Field Theory use usually Lagrangians rather than Hamiltonains?  I heard many reasons, but I'm not sure which is true.   Some say it's just a matter of beauty, so Lagrangians are more beautiful because they don't break/separate the space-time variables (so space-time is a single variable, like in the Klein-Gordon Lagrangian and Hamiltonian).  Some say that Hamiltonians are not always Lorentz invariant.  Could someone explain in a little bit more details? It has been a while since I read the Lord of the Rings novels (don't have a copy at the moment) but I seem to recall he went to Hobbiton at least once, as the young hobbits were always excited to see him.   Did he travel there often? Strip whitespace from jsp output How can I strip out extra whitespace from jsp pages' output?  Is there a switch I can flip on my web.xml?  Is there a Tomcat specific setting? Compilation problem with siunitx (returning error regarding ifnum) I'm trying to get siunitx working. For some reason I keep getting this error:  ! Missing = inserted for \ifnum. &lt;to be read again&gt;                     - l.3 \begin           {document}^^M   I have tried a minimal document to make sure it is not some kind of compatibility issue. And I get that same error in the most minimal document possible.  I'm using pdfLaTeX to compile, and have tried both from TeXWorks and from bash. I'm using TeXLive, if that matters. I have also tried reinstalling siunitx, l3packages, and l3kernel. There was an issue with l3kernel before this, due to an apparently old version. But all three packages are now up to date. I've also reinstalled expl3 while trying to debug the original issue.  My minimal document is:  \documentclass{article} \usepackage{siunitx} \begin{document} \end{document}   The output I get is:  This is pdfTeX, Version 3.14159265-2.6-1.40.16 (TeX Live 2015/Debian) (preloaded format=pdflatex) restricted \write18 enabled. entering extended mode (./untitled-2.tex LaTeX2e &lt;2016/02/01&gt; Babel &lt;3.9q&gt; and hyphenation patterns for 81 language(s) loaded. (/usr/share/texlive/texmf-dist/tex/latex/base/article.cls Document Class: article 2014/09/29 v1.4h Standard LaTeX document class (/usr/share/texlive/texmf-dist/tex/latex/base/size10.clo)) (/home/&lt;name&gt;/texmf/tex/latex/siunitx/siunitx.sty (/home/&lt;name&gt;/texmf/tex/latex/l3kernel/expl3.sty (/home/&lt;name&gt;/texmf/tex/latex/l3kernel/expl3-code.tex) (/home/&lt;name&gt;/texmf/tex/latex/l3kernel/l3pdfmode.def)) (/home/&lt;name&gt;/texmf/tex/latex/l3packages/xparse/xparse.sty) (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amstext.sty (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsgen.sty)) (/usr/share/texlive/texmf-dist/tex/latex/tools/array.sty) (/home/&lt;name&gt;/texmf/tex/latex/l3packages/l3keys2e/l3keys2e.sty) (/usr/share/texlive/texmf-dist/tex/latex/beamer/translator/translator.sty (/usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty) (/usr/share/texlive/texmf-dist/tex/latex/beamer/translator/translator-language- mappings.tex))) ! Missing = inserted for \ifnum. &lt;to be read again&gt;                    - l.3 \begin          {document}^^M ?   Does anyone have any idea what might be going wrong here? Having trouble indexing and executing a query in O (log n) time.  The query includes an INNER JOIN, an ORDER BY, and an equality operation. If I understand the laws of databases correctly, a query can be indexed and executed in O (log n) time (or thereabouts) if a non-equality operator is not used on more than one column. In this case, I believe the INNER JOIN does count as an equality operator and the non-equality operator would be the ORDER BY portion of the query. This table has upwards of 10,000,000 rows and needs to handle several reads and writes per second.  Using PostgreSQL. This is what the table looks like. As you can see, the column 'Names' is a list property and it is the column that the INNER JOIN goes against:  Age Names                       Date 34  ['carla', 'john', 'sam']    3/13/2011 26  ['json', 'cindy', 'joel']   3/13/2011 72  ['beth', 'amber', 'susie']  3/13/2011 14  ['john', 'jim', 'debie']    3/13/2011   This is the query that we are trying to do:  SELECT * FROM the_table WHERE Age==26 AND Names=='john' ORDER BY Date   My background is from using App Engine's Big Table, so I've used equality operators here to indicate that 'john' should be one of the names in the Names column. This would be an acceptable query in GAE's big table, it would execute in O (log N) time as all Big Table queries are reqyured to do. I am assuming there is a way to do this in PostgreSQL as well since PostgreSQL accepts list data types as columns.  Is this possible to do in PostgreSQL?  If so, how should the index be set up (we can't figure out how to set up an index that takes into account the three properties)? Markdown for ordered lists, starting with zero? I see that you can create an ordered list using Markdown notation like the following.  1. line 1 2. line 2 3. line 3 ... N. line N   The Markdown content supports starting each line with any arbitrary number and reorders the list starting with 1. I'd like to start an ordered list with zero. My use case for zero would be in describing capture groups from regular expressions where group zero always returns the entire string. So I'd like to display something like this:  # Groups 0. Entire string 1. The first capture group you were looking for 2. The second capture group 3. The third group with the string I heart Kittens   Markdown instead reorders the group and forces the ordered list to start at 1:    Trying to force the issue with inline HTML: &lt;ol start="0"&gt; or &lt;ol&gt;&lt;li value="0"&gt;entire string&lt;/li&gt;&lt;/ol&gt; doesn't work either. Any ideas on how I can create ordered list starting with zero?  If it's not possible to do so, then this is a feature-request. Show $\,p\mid 9^q -1 \implies q\mid p-1$ for odd primes $p$ and $q$ If $p$ and $q$ are odd primes show that $$p|(9^q -1) \implies q|(p-1).$$ ....  I am having difficulty to prove this.  Yes that was the question I have misunderstood between 9 and q!!! How do I add CSS files? Here is an example of my *.info file.      Why the page cannot load the CSS that I add myself? As the title asks, why didn't the basilisk bite received in the Chamber of Secrets destroy the Horcrux inside the bitten person?   Yes, I know Fawkes quite quickly healed the bite wound with his phoenix tears, but when Harry used the basilisk fang to destroy Tom Riddle's diary the destruction of that Horcrux was immediate. When Ron hit the locket with the Sword of Gryffindor, it was destroyed immediately. Although the destruction of the ring occurred off-page, Dumbledore used the Sword of Gryffindor to destroy it, so presumably, like the locket, it was gone right away. Nagini died straightaway when Neville decapitated her. The destruction of the Hufflepuff cup happens off-page. The diadem seems to have been destroyed by Fiendfyre immediately as well, as when Harry examined it outside the Room of Requirement it was already leaking a blood-like substance, and then it cracked in half. When Voldemort hit Harry with Avada Kedavra in the forest, Harry woke up in limbo with the last fragment of Voldemort's soul - that awful flayed baby-like being - separated from him immediately.   Is there a logical/canon-based explanation for why the fragment of Voldemort's soul residing in Harry wasn't destroyed upon Harry being bitten by the basilisk?  NOTE: I've read the HP Wiki's entry on Horcruxes; however, I find the HP Wiki to be inconsistent in its accuracy, so I'm hesitant to accept the Wiki's explanation on the matter. I'd prefer an explanation constructed from information in the books or a statement by JKR, or the like. How to run Java code using Java code? What is the difference between “do” and “make”? Get all categories and posts in those categories I am looking for a solution that allows me to print the following:  Cat 1        Cat 2        Cat 3  Post 1       Post 1       Post 1  Post 2       Post 2       Post 2  Post 3                    Post 3                            Post 4   EDIT  I am looking for something that will only require one database query! So if you have a foreach in your code followed by a new WP_Query then that is not what I am looking for (I am planning to put this onto my website's homepage). Adding arrows in curves No direct object in 'give thee faithfully to follow' ? (1670 UK, Isaac Penington)