instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>Take a very simple case as an example, say I have this URL:</p> <pre><code>http://www.example.com/65167.html </code></pre> <p>and I wish to serve that content under:</p> <pre><code>http://www.example.com/about </code></pre> <p><strong>UPDATE</strong>: Note that the 'bad' URL is the canonical one (it's produced b...
<p>Apache HTTPD's mod_rewrite can leave a browser showing a SEO-friendly URL in its location bar while redirecting to a numeric URL on the server:</p> <pre><code>RewriteEngine on RewriteRule ^/about$ /65167.html [L] </code></pre>
<p>I'm pretty sure Google understands <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.2" rel="nofollow noreferrer">301 Moved Permanently</a>.</p>
33,695
<p>I began an iPhone project the other day with a silly development code name, and now I want to change the name of the project since it's nearly finished. </p> <p>But I'm not sure how to do this with Xcode, trying the obvious of changing the application's name in the info.plist file, causes the signing process to go ...
<ol> <li>Go to <code>Targets</code> in <code>Xcode</code>.</li> <li><code>Build Settings</code> on your project's target (your current development name).</li> <li>Search for <code>Product Name</code> under <code>Packaging</code>. Change its value to what you want your new project name to be.</li> </ol> <p><a href="http...
<p>Use <em>Target</em> → <em>Build Setting</em> → <em>Product name</em>.</p>
29,565
<p><a href="http://thedailywtf.com/Articles/nice_num,-mean_programmer.aspx" rel="nofollow noreferrer">The Daily WTF</a> for 2008-11-28 pillories the following code:</p> <pre><code>static char *nice_num(long n) { int neg = 0, d = 3; char *buffer = prtbuf; int bufsize = 20; if (n &lt; 0) { n...
<p>If you're a seasoned C programmer, you'll realize this code isn't actually that bad. It's relatively straightforward (for C), and it's blazingly fast. It has three problems:</p> <ol> <li>It fails on the edge case of LONG_MIN (-2,147,483,648), since negating this number produces itself in twos-complement <ul> <li...
<p>In pure C:</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;limits.h&gt; static char *prettyNumber(long num, int base, char separator) { #define bufferSize (sizeof(long) * CHAR_BIT) static char buffer[bufferSize + 1]; unsigned int pos = 0; /* We're walking backwards because number...
42,398
<p>trying to implement a dialog-box style behaviour using a separate div section with all the stuff inside it.</p> <p>When the "dialog box" needs to be shown, it has to display at the center of the WINDOW, not in the center of the page, that is, REGARDLESS of the scroling position. Furthermore, the correct solution wi...
<p>If I were you I would do it using jQuery and I would suggest you try it out too. This should fit perfectly for jQuery based solution [jQuery Version][1] or try out</p> <pre><code>body { font: 80% verdana, arial, helvetica, sans-serif; text-align: center; /* for IE */ } #container { ...
<p>Use <code>overflow-y</code> and absolute positioning to emulate fixed positioning in IE6 using the following steps:</p> <ol> <li><p>Create an absolutely positioned div and give it the desired top and left coordinates on the page</p></li> <li><p>Set <code>html {overflow-y: }</code> to be hidden or visible instead of...
41,248
<p>When debugging in Internet Explorer, I first get an alert box with extremely limited if not useless information (sorry IE) and choose to debug it. After selecting yes, I get another option <em>every time</em> to choose between 'New instance of Microsoft script debugger' and 'New instance of Visual Studio'. I'm fed u...
<p>Apparently the problem happens if you do not uninstall the old (crappy) Microsoft Script Debugger before you install the newer Microsoft Script Editor.</p> <p>You would think that all you need to do is to uninstall the old debugger - however, according to a blog posting (which I can't recall at the moment), if you ...
<p>Maybe not the complete solution, but you could try to set the default script debugger can be set <strong>in the registry</strong> directly. To do so, follow these steps:</p> <ul> <li>Click Start, Run and type regedit.exe</li> <li>Navigate to the following branch:</li> </ul> <p>HKEY_CLASSES_ROOT \ CLSID \ {834128A2...
27,811
<p>I am adding some user controls dynamically to a PlaceHolder server control. My user control consists of some labels and some textbox controls. </p> <p>When I submit the form and try to view the contents of the textboxes (within each user control) on the server, they are empty.</p> <p>When the postback completes,...
<p>This is based on .NET v1 event sequence, but it should give you the idea:</p> <ul> <li>Initialize (Init event)</li> <li>Begin Tracking View State (checks if postback) <ul> <li>Load View State (if postback)</li> <li>Load Postback Data (if postback)</li> </ul></li> <li>Load (Load event) <ul> <li>Raise Changed Even...
<p>You have to create your controls in the Page_PreInit event handler. The ASP.NET server control model is tricky; you have to fully understand the <a href="http://msdn.microsoft.com/en-us/library/ms178472.aspx" rel="nofollow noreferrer">page lifecycle</a> to do it right.</p>
12,807
<p>I have an NSView subclass which has property which I want to be bindable. I've implemented the following in the subclass:</p> <p>myView.h:</p> <pre><code>@property (readwrite, retain) NSArray *representedObjects; </code></pre> <p>myView.m:</p> <pre><code>@synthesize representedObjects; +(void)initialize { [self...
<p>No, you shouldn’t need that glue code.</p> <p>What do you mean by “doesn’t seem to be the case”? What happens if you omit it?</p>
<p>You definitely DO need to implement <code>-bind:toObject:withKeyPath:options:</code> in a custom view if you want to implement bindings in that view. Your implementation in myView.m is pretty much spot on.</p>
47,896
<p>C# novice here, when the int 'max' below is 0 I get a divide by zero error, I can see why this happens but how should I handle this when max is 0? position is also an int.</p> <pre><code> private void SetProgressBar(string text, int position, int max) { try { int percent = (100 * ...
<pre><code>int percent = 0 if (max != 0) percent = (100*position) / max </code></pre>
<p>Well, if max is zero, then there is no progress to be made. Try catching the exception where this is called. That is probably the place to decide whether there is a problem or if the progress bar should be set at zero or at 100%.</p>
19,366
<p>With SQLServer, it seems to be generally accepted that adding a SELECT SCOPE_IDENTITY() to the end of your insert is the best way to return the PK of the newly-inserted record, assuming you're using an auto-increment field for the pk. </p> <p>However, I can't seem to find the equivalent for Oracle. </p> <p>Best pr...
<p>You can use the RETURNING clause to do this in Oracle stored procs.</p> <p>For example:</p> <p>TABLEA has NAME and EMP_ID. EMP_ID is populated internally when records are inserted.</p> <p>INSERT INTO TABLEA(NAME) VALUES ('BOB') RETURNING EMP_ID INTO o_EMP_ID;</p> <p>That's assuming that line is in a stored proc...
<p>The RETURNING clause is intended for just this kind of usage, so I would call it a best practice to use it.</p> <p>An alternative would be to select seq.CURRVAL after the insert. That returns the last value obtained from the sequence by <strong>this</strong> session.</p>
19,182
<p>I am writing a Browser Helper Object for ie7, and I need to detect DOM modification (i.e. via AJAX). So far I couldn't find any feasible solution.</p>
<p>You want to use <a href="http://msdn.microsoft.com/en-us/library/aa703624(VS.85).aspx" rel="nofollow noreferrer">IMarkupContainer2::CreateChangeLog</a>.</p>
<p>The best thing I could recommend is the <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=E59C3964-672D-4511-BB3E-2D5E1DB91038&amp;displaylang=en" rel="nofollow noreferrer">Internet Explorer Developer Toolbar</a> which allow you to view changes in the DOM.</p>
5,485
<p>Is there a side effect in doing this:</p> <p>C code:</p> <pre><code>struct foo { int k; }; int ret_foo(const struct foo* f){ return f.k; } </code></pre> <p>C++ code:</p> <pre><code>class bar : public foo { int my_bar() { return ret_foo( (foo)this ); } }; </code></pre> <p>There's an...
<p>This is entirely legal. In C++, classes and structs are identical concepts, with the exception that all struct members are public by default. That's the only difference. So asking whether you can extend a struct is no different than asking if you can extend a class.</p> <p>There is one caveat here. There is <em...
<p>I don't get why you don't simply make ret_foo a member method. Your current way makes your code awfully hard to understand. What is so difficult about using a real class in the first place with a member variable and get/set methods? </p> <p>I know it's possible to subclass structs in C++, but the danger is that oth...
15,488
<p>We need to provide a solution to do performance testing for our Web Services residing in our development environment. We were planning to create the test scripts using the object model of Microsoft Web Application Stress Tool. I have researched and not been able to find any examples. </p> <p>Can anyone, who may hav...
<p>So a year or two back I had the same problem and was able to apply my experience with the grinder to the problem: <a href="http://grinder.sourceforge.net/" rel="nofollow noreferrer">http://grinder.sourceforge.net/</a></p> <p>Others in my environment reported success using ACT: <a href="http://en.wikipedia.org/wiki/...
<p>You may have to stress test IIS itself since it's webservice, just loop open 5000 request.</p>
18,693
<p>How do I apply the MarshalAsAttribute to the return type of the code below?</p> <pre><code>public ISomething Foo() { return new MyFoo(); } </code></pre>
<p>According to <a href="http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.marshalasattribute.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.marshalasattribute.aspx</a>:</p> <pre><code>[return: MarshalAs(&lt;your marshal type&gt;)] public ISomething F...
<pre><code>[return:MarshalAs] public ISomething Foo() { return new MyFoo(); } </code></pre>
15,953
<p>Is there a way in MySQL to select rows which fall on a specific day, as in Mondays, using a date column?</p>
<p>MySQL <a href="http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_dayofweek" rel="nofollow noreferrer">DAYOFWEEK</a> function.</p> <p>E.g. to select Mondays:</p> <pre><code>SELECT * FROM foo WHERE DAYOFWEEK(bar) = 2 </code></pre>
<p>I assume you mean a specific Week Day Name, yes there is:</p> <p>In mysql you can use <strong>DAYOFWEEK()</strong> - <a href="http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html" rel="nofollow noreferrer">check the manual</a></p> <p>In PHP you can use getdate() and for example do:</p> <p>$date = g...
38,071
<p>I'm writing some disposable Haskell scripts to solve some of the <a href="http://projecteuler.net" rel="nofollow noreferrer">Project Euler</a> problems. I don't really want to have to compile them because of the number of changes I'm constantly having to make, but in a few cases I've found that I've run out of stack...
<p>I'm guessing you're using GHC. Chapter 4 of the User's Guide of the newly released 6.10.1 says: </p> <blockquote> <p>The only runghc flag currently is -f /path/to/ghc, which tells runghc which GHC to use to run the program.</p> </blockquote> <p>I don't see a bug logged at <a href="http://hackage.haskell.org...
<p>Just compile it.</p> <p>Problem123.hs:</p> <pre><code>module Main where main = do print solution solution = ... </code></pre> <p>Short and sweet command line:</p> <pre><code>ghc --make -O3 Problem123.hs ./Problem123 </code></pre> <p>Final note: I'm not sure I would call them "scripts".</p>
34,693
<p>I've worked out how to interact with IIS 6.0, but I can't find anything on the net about how to talk to IIS 5.0 - if indeed it's even possible?</p> <p>I would like to write a script to create a temporary application, so I can copy some ASP.NET files there, build them, and then remove the temporary application.</p> ...
<p>There use to be some installers on the ASP.NET downloads that would setup a project in IIS 5.0. I think it was the old ASP.NET Forums software. I know this wasn't an answer to your question. </p> <p>If I was a betting man I would say they probably created a batch file that used the VBScripts. Because I remember ...
<p><a href="https://stackoverflow.com/questions/371207/can-i-automate-creating-a-net-web-application-virtual-directory-in-iis-5#371264">Can I automate creating a .NET web application / virtual directory in IIS 5?</a></p>
48,969
<p>Given that indexing is so important as your data set increases in size, can someone explain how indexing works at a database-agnostic level?</p> <p>For information on queries to index a field, check out <a href="https://stackoverflow.com/questions/1156/">How do I index a database column</a>.</p>
<p><strong>Why is it needed?</strong></p> <p>When data is stored on disk-based storage devices, it is stored as blocks of data. These blocks are accessed in their entirety, making them the atomic disk access operation. Disk blocks are structured in much the same way as linked lists; both contain a section for data, a p...
<p>Just think of Database Index as Index of a book.</p> <p>If you have a book about dogs and you want to find an information about let's say, German Shepherds, you could of course flip through all the pages of the book and find what you are looking for - but this of course is time consuming and not very fast. </p> <...
2,354
<p>Has anyone seen a tool that will integrate code coverage results with SCM/VCS to attribute untested lines of code to developers? For example, is there a tool that will take NCover's Coverage.Xml, combine it with SVN blame, and produce a report that tells me things like developer who commits most untested code?</p>
<p>Try:</p> <pre><code>WScript.Quit n </code></pre> <p>Where n is the ERRORLEVEL you want to return</p>
<p>Try:</p> <pre><code>WScript.Quit n </code></pre> <p>Where n is the ERRORLEVEL you want to return</p>
22,646
<p>I need to be able to display some data in Eclipse in a grid/table control... I need things like paging, multiple column sorting, column choosing, etc. There is an SWT Table and the <a href="http://www.eclipse.org/nebula/widgets/grid/grid.php" rel="nofollow noreferrer">Nebula project has a grid in alpha</a>.</p> <p>...
<p>I haven't seen those features implemented in a reusable widget that I can think of, they are more application-level features.</p> <p><strong>Paging:</strong> If you were to use the JFace-type viewers (SWT Table or <a href="http://www.eclipse.org/nebula/widgets/grid/grid.php" rel="nofollow noreferrer">Nebula Grid</a...
<p>You could use the facilities of table presentation offered by the <a href="http://www.eclipse.org/birt/phoenix/intro/" rel="nofollow noreferrer">BIRT plugin</a>, that is if you are really advance <a href="http://java.sys-con.com/node/295339/print" rel="nofollow noreferrer">table layout needs</a>.<br> <a href="https:...
38,480
<p>I want to do something like this:</p> <pre><code>&lt;MyTemplate&gt; &lt;span&gt;&lt;%# Container.Title %&gt;&lt;/span&gt; &lt;MySubTemplate&gt; &lt;span&gt;&lt;%# Container.Username %&gt;&lt;/span&gt; &lt;/MySubTemplate&gt; &lt;/MyTemplate&gt; </code></pre> <p>Assuming I have a list of Titles th...
<p>If you have a list of titles, that each have their own list of UserNames, it seems like you want to do something with nested repeaters (or other controls), not templates...</p> <pre><code> &lt;asp:Repeater ID="rptTitle" runat="server" &gt; &lt;ItemTemplate&gt; &lt;%# Eval("Title") %&gt; ...
<p>You can do it this way. You can also use:</p> <ul> <li>Labels</li> <li>Span runat="server" and add them programmatically</li> <li>(ghetto) string.replace</li> </ul>
33,835
<p>I'm sure there is a quick and easy way to calculate the sum of a column of values on Unix systems (using something like <code>awk</code> or <code>xargs</code> perhaps), but writing a shell script to parse the rows line by line is the only thing that comes to mind at the moment.</p> <p>For example, what's the simple...
<pre><code>ipcs -mb | tail +4 | awk '{ sum += $7 } END { print sum }' </code></pre> <p>Or without tail:</p> <pre><code>ipcs -mb | awk 'NR &gt; 3 { sum += $7 } END { print sum }' </code></pre> <p>Using awk with bc to have arbitrary long results (credits to <code>Jouni K.</code>):</p> <pre><code>ipcs -mb | awk 'NR &g...
<p>Thanks for the Python one-liner above!. It helped me to easy check the used space on my drive. Here is a mixed shell / Python one-liner, that do this - counts used space on the device /dev/sda in megabytes. It took me some time, before I found it out, so, maybe someone finds this useful too.</p> <pre><code>df -h ...
37,818
<p>Our company (xyz) is moving a lot of our Flash code to Python.</p> <p>In Flash, we have a shared library between our Flash apps - package xyz. We can make changes to the package without fear of breaking other apps when they are deployed because Flash compiles their code and includes the contents of the library. We ...
<p>"explicitly tested against App1,2,3 every time there was a new library" actually isn't that onerous.</p> <p>Two things.</p> <ul> <li><p>You need a formal set of API unit tests that the library <em>must</em> pass. This is just the API, not every nuance of functionality. If this passes, then your changes are good ...
<p>I've used variations of this <a href="http://code.activestate.com/recipes/497000/" rel="nofollow noreferrer">cookbook entry</a> to distribute python apps. Basically it involves zipping all your python sources up into a zip file, then concatenating it with a shell script to import the source files.</p> <p>This can ...
44,516
<p>Say I am declaring a class <code>C</code> and a few of the declarations are very similar. I'd like to use a function <code>f</code> to reduce code repetition for these declarations. It's possible to just declare and use <code>f</code> as usual:</p> <pre><code>&gt;&gt;&gt; class C(object): ... def f(num): ... ...
<p>Quite simply, the solution is that f does not need to be a member of the class. I am assuming that your thought-process has gone through a Javaish language filter causing the mental block. It goes a little something like this:</p> <pre><code>def f(n): return '&lt;' + str(num) + '&gt;' class C(object): v =...
<p>Let's begin from the beginning.</p> <p>"declare a function in a class, use it during its declaration, and also use it later from within the class"</p> <p>Sorry. Can't be done. "In a class" contradicts "used during declaration".</p> <ul> <li>In a class means created as part of the declaration.</li> <li>Used duri...
39,157
<p>One thing that bugs me about IE is that when it goes to load a page with an iframe it will wait until the iframe has finished loading before it will render the page. Firefox by contrast will render all the other page elements while the iframe is loading which is really nice if the iframe takes a long time to load b...
<p>What if you were to load the page with an XmlHttpRequest and then replace the contents of the document as/when it loads?</p> <pre><code>&lt;!-- jQuery example: --&gt; &lt;div id='content'&gt;Loading...&lt;/div&gt; &lt;script type='text/javascript'&gt; $("#content").load(url); &lt;/script&gt; </code></pre>
<p>You could set the location of your iframe using JavaScript after the parent window has loaded.</p> <pre><code>&lt;body onload="document.getElementById('myIframe').location='someurl';"&gt; &lt;iframe id="myIframe"&gt; &lt;/body&gt; </code></pre> <p>Would be the most rudimentary way to do it. </p>
37,936
<p>Having a strange issue with some C# code - the Getter method for a property is showing up as virtual when not explicitly marked.</p> <p>The problem exhibits with the DbKey property on this class (code in full):</p> <pre><code>public class ProcessingContextKey : BusinessEntityKey, IProcessingContextKey { public...
<p>It's virtual because it implements an interface method. Interface implementation methods are always virtual as far as the CLR is concerned.</p>
<p>The DbKey property getter is virtual in the IL because it is in an interface. The setter is not virtual because it is not part of the interface but part of the concrete class. </p> <p><a href="http://www.ecma-international.org/publications/standards/Ecma-335.htm" rel="nofollow noreferrer">ECMA-335: Common Language ...
41,691
<p>I have loaded image into a new, initialized Oracle ORDImage object and am processing it by PL/SQL. I can read its properties, but cannot process it with the process() method. </p> <pre><code>vLocalImage ORDImage := ORDImage.init(); ... vLocalImage.source.localdata := PORTAL.wwdoc_admin.get_document_blob_content(pFi...
<p>Even though the documentation states that it should be possible to edit an ORDImage "in-place", I was unable to make it work. </p> <p>Instead, I created a new ORDImage object and used processCopy:</p> <pre><code> vNewImage ORDImage; ... vLocalImage.processCopy('maxScale 534 401', vNewImage); </code></pre>
<p>Can you please show the select statement you use to get l_ordimage? The main cause of this error seems to be if you don't have "for update" in your select statement, but I can't get intermedia going at the moment to test.</p>
11,053
<p>I've been coding alot of web-stuff all my life, rails lately. And i can always find a website to code, but i'm kind of bored with it. Been taking alot of courses of Java and C lately so i've become a bit interested in desktop application programming.</p> <p>Problem: I can't for the life of me think of a thing to co...
<p>I would say you should roam through github or some other open source site and find an existing young or old project that you can contribute to. Maybe there is something that is barely off the ground, or maybe there is a mature project that could use some improvement.</p>
<p>If you could make a Ruby <a href="http://en.wikipedia.org/wiki/ANSI_art" rel="nofollow noreferrer">ANSI</a> (and <a href="http://en.wikipedia.org/wiki/XBIN" rel="nofollow noreferrer">xbin</a>, and idf, and adf...) Editor, I would love you. Because that means you would have written ANSI parsing routines that I can ho...
11,403
<p>We need to move off traditional FTP for security purposes (it transmits it's passwords unencrypted). I am hearing SSH touted as the obvious alternative. However I have been driving FTP from an ASP.NET program interface to automate my web-site development, which is now quite a highly web-enabled process. </p> <p>Can...
<p>the question has three subquestions:</p> <p>1) choosing the secure transfer protocol</p> <p>The secure version of old FTP exists - it's called FTP/SSL (plain old FTP over SSL encrypted channel). Maybe you can still use your old deployment infrastructure - just check whether it supports the FTPS or FTP/SSL.</p> <p...
<p>G'day,</p> <p>You might like to look at <a href="http://www.proftpd.org/" rel="nofollow noreferrer">ProFPD</a>.</p> <p>Heavily customisable. Based on Apache module structure.</p> <p>From their web site:</p> <blockquote> <p>ProFTPD grew out of the desire to have a secure and configurable FTP server, and out of a sign...
6,012
<p>As a function argument I get a <code>vector&lt;double&gt;&amp; vec</code> (an output vector, hence non-const) with unknown length and values. I want to initialise this vector to a specific length n with all zeroes.</p> <p>This will work </p> <pre><code>vec.clear(); vec.resize( n, 0.0 ); </code></pre> <p>And this ...
<pre><code>std::vector&lt;double&gt;(n).swap(vec); </code></pre> <p>After this, vec is guaranteed to have size and capacity n, with all values 0.0.</p> <p>Perhaps the more idiomatic way since C++11 is</p> <pre><code>vec.assign(n, 0.); vec.shrink_to_fit(); </code></pre> <p>with the second line optional. In the case ...
<p>Well let's round out the ways to do this :)</p> <pre><code>vec.swap(std::vector&lt;double&gt;(n)); std::vector&lt;double&gt;(n).swap(vec); std::swap(vector&lt;double&gt;(n), vec); std::swap(vec, vector&lt;double&gt;(n)); </code></pre>
20,967
<p>Testing:</p> <pre><code>return request.getCookies() == null; </code></pre> <p>is not an appropriate way test. Is there another way?</p>
<p>You generally want to use JavaScript to determine if the client's browser has cookies enabled:</p> <pre><code>&lt;script type="text/javascript"&gt; var cookieEnabled=(navigator.cookieEnabled)? true : false //if not IE4+ nor NS6+ if (typeof navigator.cookieEnabled=="undefined" &amp;&amp; !cookieEnabled){ document....
<p>You generally want to use JavaScript to determine if the client's browser has cookies enabled:</p> <pre><code>&lt;script type="text/javascript"&gt; var cookieEnabled=(navigator.cookieEnabled)? true : false //if not IE4+ nor NS6+ if (typeof navigator.cookieEnabled=="undefined" &amp;&amp; !cookieEnabled){ document....
41,233
<p>I really enjoy Chrome, and the sheer exercise of helping a port would boost my knowledge-base.</p> <p>Where do I start?</p> <p>What are the fundamental similarities and differences between the code which will operated under Windows and Linux?</p> <p>What skills and software do I need?</p> <hr /> <h3>Note:</h3> <p>Th...
<p>EDIT: (2/6/10)</p> <p>A Beta version of Chrome has been released for Linux. Although it is labeled beta, it works great on my Ubuntu box. You can download it from Google:</p> <p><a href="http://www.google.com/chrome?platform=linux" rel="nofollow noreferrer">http://www.google.com/chrome?platform=linux</a></p> <p>E...
<p>Read this article on Chrome and Open Source on Linux:</p> <p><a href="http://arstechnica.com/journals/linux.ars/2008/09/02/google-unveils-chrome-source-code-and-linux-port" rel="noreferrer">http://arstechnica.com/journals/linux.ars/2008/09/02/google-unveils-chrome-source-code-and-linux-port</a></p> <p>The Google V...
7,060
<p>In my current application I have a form that requires the user to enter TONS of data. There are about 30 Textboxes and it happens that during development new ones get introduced or old ones get kicked out.</p> <p>One Requirement by my customer is that they are all navigable through pressing Tab, and so I'm currentl...
<p>When the forms designer is open go to View -> Tab Order this will allow you to set the tab order in a very simple and easy way.</p>
<p>Here is something you might want to give a try. From <a href="http://www.codeproject.com/KB/dotnet/TabOrderManager.aspx" rel="nofollow noreferrer">Code project</a>. This will organize your tab index by 2 logicals ways.</p> <p><img src="https://www.codeproject.com/KB/dotnet/TabOrderManager/TabOrderManager.gif" alt="...
40,559
<pre> <code> &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;title&gt;Calling a Web Service Using XmlHttpRequest&lt;/title&gt; &lt;script type="text/javascrip...
<p>XmlHttpRequest can only be used to call services local to the domain/server from where the page is being served.</p> <p>Thus, if you're serving a page from:</p> <pre><code>http://www.example.com/page1 </code></pre> <p>You cannot make an XmlHttpRequest to:</p> <pre><code>http://www.sample.com/webservice </code></...
<p>Since you're setting <code>Content-type</code>, you need to also set it to use <code>UTF-8</code>. And I think it's supposed to be <code>application/xml</code> (<a href="http://www.w3.org/TR/XMLHttpRequest/#xmlhttprequest" rel="nofollow noreferrer">source</a>).</p> <pre><code>xmlhttp.setRequestHeader("Content-Type"...
46,305
<p>I'm trying to load javascript code with a user web control into a page via a the Page.LoadControl method during an asyncron post back of an update panel.</p> <p>I've tried the specially for that scenario designed methods of the scriptmanager, but the javascript just doens't get returned to the user.</p> <p>To expl...
<p>For that you can do</p> <pre><code>string scr; scr = "&lt;script src='/scripts/myscript.js'&gt;&lt;/script&gt;" Page.ClientScript.RegisterStartupScript(GetType(Page), "key", scr, false) </code></pre> <p>HTH</p>
<p>Putting the RegisterStartupScript in the Page_PreRender event may not work if your control is nested in an asp.net modal popup. Instead, put it in the Page_Load when IsPostBack = False.</p>
38,678
<p>Does someone knows if it's possible to dynamically create a call chain and invoke it?</p> <p>Lets say I have two classes A &amp; B:</p> <pre><code>public class A public function Func() as B return new B() end function end class public class B public function Name() as string return "a str...
<p>Are you using .NET 3.5? If so, it should be relatively straightforward to build an expression tree to represent this. I don't have enough expression-tree-fu to easily write the relevant tree without VS open, but if you confirm that it's an option, I'll get to work in notepad (from my Eee... hence the lack of VS).</p...
<p>You need t add this line before the 1st expression:</p> <pre><code>Expression ctorCall = Expression.Constructor(A) </code></pre> <p>And pass that expression as the 1st parameter when creating fCall</p> <p>Otherwise we're missing a starting point for the chain and we'll get an exception when running the code</p>
45,564
<p>Is there a <code>Python</code> module for converting <code>wiki markup</code> to other languages (e.g. <code>HTML</code>)?</p> <p>A similar question was asked here, <a href="https://stackoverflow.com/questions/45991/whats-the-easiest-way-to-convert-wiki-markup-to-html">What's the easiest way to convert wiki markup ...
<p><a href="https://github.com/pediapress/mwlib" rel="nofollow noreferrer">mwlib</a> provides ways of converting MediaWiki formatted text into HTML, PDF, DocBook and OpenOffice formats.</p>
<p>with python-creole you can convert html to creole and creole to html... So you can convert other markups to html and then to creole...</p> <p><a href="https://code.google.com/p/python-creole/" rel="nofollow">https://code.google.com/p/python-creole/</a></p>
18,689
<p>I have been playing with Haml recently and really like the way the resulting code looks to me...the developer. I'm also not too worried about a designer being able to consume or change it...we're a small team. </p> <p>That said, beginning work on a project we believe will generate quite a bit of traffic (who doesn'...
<p>Haml rocks. I haven't seen any recent performance numbers but it is pretty close to erb these days. I think that it might be faster than erb if you turn on ugly mode (which prevents the pretty indentation) We're doing 2.8 million pageviews a day with Haml.</p> <p>There is a benchmarker checked into the Haml source...
<p>Well, Haml performance continues to improve with each release. Is it at an acceptable place at the current time? That's for you to decide (I'm inclined to say "Yes", but it's your choice based on your needs). If you like the templates and the readability they provide, then the performance drop (however negligible) s...
12,133
<p>I'm a rookie designer having a few troubles with this page: <a href="http://www.resolvegroup.co.nz/javasurvey.php" rel="nofollow noreferrer">http://www.resolvegroup.co.nz/javasurvey.php</a></p> <p>There are problems with the javascript operation of the expanded questions. For Internet Explorer (Version 7) the first...
<p>I'd recommend looking at using a pre-built Accordion script, like that built into the jQuery UI library: <a href="http://docs.jquery.com/UI/Accordion" rel="nofollow noreferrer">http://docs.jquery.com/UI/Accordion</a></p> <hr> <p>Also, there's a few things I could suggest. This code of yours:</p> <pre><code>$(".sc...
<p>If I'm not mistaken, your CSS has some wonkiness. ".question-container h3" and ".question-container h3 span" have relative and absolute positioning, respectively. Internet Explorer does not handle out-of-flow positioning very well. In result, it gets confused and tries to place these elements in weird places.</p> <...
28,771
<p>I am writing some G-code for my DIY 3D printer. From what I understand, <code>G4</code> is dwell and its expressed in milliseconds. So my extruder takes about 30 seconds to heat up. Do I just type </p> <pre><code>G04 30000 </code></pre>
<p>You are correct about needing to specify the dwell value in milliseconds. However, the RepRap Wiki indicates that you need to use the <code>Pn</code> argument, and not just an unadorned number as the argument to the command. To adapt the Wiki's own example, you will need to use:</p> <pre><code>G4 P30000 </code></pr...
<p>Depending on your G-code flavor you may be able to use <a href="https://reprap.org/wiki/G-code#M109:_Set_Extruder_Temperature_and_Wait" rel="nofollow noreferrer"><code>M109</code></a> (heat and wait) instead. If supported M109 will wait until the target temperature is achieved.</p>
716
<p>I am writing PHP code where I want to pass the session id myself using POST. I don't want a cookie to store the session, as it should get lost when the user gets out of the POST cycle.</p> <p>PHP automatically sets the cookie where available. I learned it is possible to change this behaviour by setting <code>sessio...
<p>Use <a href="http://php.net/ini_set" rel="noreferrer">ini_set()</a>:</p> <pre><code>ini_set('session.use_cookies', '0'); </code></pre> <p>Or in your php.ini file:</p> <pre><code>session.use_cookies = 0 </code></pre>
<p>The way to do it is to setup sessions yourself.</p> <p>In the central include file that all your other files are including (you do have one of those, right?), you need to do a few things as early as is practical. </p> <pre><code>if( !array_key_exists('sessionid', $_POST) ) { // recreate the sessionid $sess...
29,920
<p>I'm hearing that some people believe storing info on the server in a session is a bad idea, that its not secure.<br><br> As a result, in a multi-page business process function, the application is writing data to a db, then retrieving the info when its needed. Is there something necessarily unsafe about storing priva...
<p>There's not a security risk in storing attributes in a Session, as long as the session itself is safe from <a href="http://www.owasp.org/index.php/Session_hijacking_attack" rel="noreferrer">hijacking</a>. </p> <p>There are some serious issues involving concurrency and sessions. Since its extremely common for multip...
<p>As well as performance and concurrency issues, you should also think about usability. Do multiple open pages, the back button work, bookmarks, linking to your site, etc., work? I've ended up booking a flight on the wrong day on <code>aerlingus.ie</code> and almost booking the wrong hotel on <code>lastminute.com</cod...
44,089
<p>I want to create a <strong>List</strong> of <strong>KeyValuePair</strong>s in a managed C++ project. Here is the syntax I'm using</p> <pre><code>List&lt;KeyValuePair&lt;String^, String^&gt;^&gt;^ thing; </code></pre> <p>but I'm getting the following error:</p> <blockquote> <p>error C3225: generic type argument ...
<blockquote> <p>KeyValuePair does not itself need to be a handle. Duh.</p> </blockquote> <p>Because it's a value type, not a reference type (i.e. <code>struct</code> instead of <code>class</code> in C#).</p>
<p>Figured it out:</p> <pre><code>List&lt;KeyValuePair&lt;String^, String^&gt;&gt;^ thing; </code></pre> <p>KeyValuePair does not itself need to be a handle. Duh.</p>
44,388
<p>I just saw a really cool WPF twitter client that I think is developed by the Herding Code podcast guys <a href="http://www.herdingcode.com/" rel="noreferrer">HerdingCode</a> called <a href="http://code.google.com/p/wittytwitter/" rel="noreferrer">Witty</a>. (or at least, I see a lot of those guys using this client)...
<p>After you install Tortoise (separate SVN client not required), create a new empty folder for the project somewhere and right click it in Windows. There should be an option for <code>SVN Checkout</code>. Choosing that option will open a dialog box. Paste the URL you posted above in the first textbox of that dialog bo...
<p>The manual explains how to checkout code: </p> <p><a href="http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-dug-checkout.html" rel="nofollow noreferrer">http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-dug-checkout.html</a></p>
6,315
<p>I'm interested in selectively parsing Mediawiki XML markup to generate a customized HTML page that's some subset of the HTML produced by the actual PHP Mediawiki render engine.</p> <p>I want it for BzReader, an offline Mediawiki compressed dump reader written in C#. So a C# parser would be ideal, but any good code...
<p>There is a list of parsers on <a href="http://www.mediawiki.org/wiki/Alternative_parsers" rel="noreferrer">http://www.mediawiki.org/wiki/Alternative_parsers</a>, but a c# parser is not included there...</p>
<p>I had some words to say about Mediawiki templates <a href="http://hewgill.com/journal/entries/343-the-abomination-of-mediawiki-templates" rel="nofollow noreferrer">here</a>. Interesting that there's a list of alternative parsers now, I'll have to investigate that.</p>
42,055
<p>I have a table <code>UserAliases</code> (<code>UserId, Alias</code>) with multiple aliases per user. I need to query it and return all aliases for a given user, the trick is to return them all in one column.</p> <p>Example:</p> <pre><code>UserId/Alias 1/MrX 1/MrY 1/MrA 2/Abc 2/Xyz </code></pre> <p>I wan...
<p>You can use a function with COALESCE.</p> <pre><code>CREATE FUNCTION [dbo].[GetAliasesById] ( @userID int ) RETURNS varchar(max) AS BEGIN declare @output varchar(max) select @output = COALESCE(@output + ', ', '') + alias from UserAliases where userid = @userID return @output END GO SELECT...
<p>group_concat() sounds like what you're looking for.</p> <p><a href="http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html#function_group-concat" rel="nofollow noreferrer">http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html#function_group-concat</a></p> <p>since you're on mssql, i just googled "...
14,964
<p>I have a page that contains a user control that is just a personalized dropdown list . I assign to each item the attribute <code>onClick=__doPostBack('actrl',0)</code>.</p> <p>when I click the page postback fine and I got the expected results. However in IE6 my page doesn't change to the new values loaded from the...
<p>This is a known IE6 bug (#223) with magical HTTP get requests.</p> <p>See the bug here: <a href="http://webbugtrack.blogspot.com/2007/09/bug-223-magical-http-get-requests-in.html" rel="nofollow noreferrer">http://webbugtrack.blogspot.com/2007/09/bug-223-magical-http-get-requests-in.html</a></p> <p>It happens when ...
<p>The problem is that IE6 is not reloading the page from the server (its just grabbing the cached copy), however on a form post IE6 SHOULD reload. Why are you adding the _doPostBack as an attribute, those should be autogenerated on any asp.net control that needs to post back.</p>
25,310
<p>Is it possible (by using the stock c# TreeView) to have Multiline TreeNodes? </p> <p>Also, is it possible to add control characters to TreeNode's text e.g. '\t'? This same effect could also be achieved by adding columns to the TreeNode. is this possible?</p>
<p>I do not believe this is possible using WinForms, at least without drawing your own nodes. You may be able to use an "owner-drawn" treenode to accomplish this in WinForms, though, I don't know. </p> <p>This is natively supported with WPF, though.</p>
<p>It is not possible to use the tabulator effectively inside a TreeNode. Anyways, I have a workaround:</p> <p>The Font "Consolas" has equal space of each letter so you can space easily with blanks. The method GetEmptyInfoByIndex returns a custom lenght string of spaces to fill the gap until a specified length. Here =...
38,697
<p>Code I'm working on collects performance data (eg CPU usage) from the operating system. I'm wondering if I should bother to attempt to unit test this code. It seems that to unit test code, you need to design code that is isolated into units. My code is so closely tied to the OS though that if I isolated the code out...
<p>Do you have any business logic? Calculations? or are you just grabbing and displaying data?</p> <p>Unit testing is useful for, well, testing units. In other words are the any parts of you app that can work in isolation? If not, then theres not really anything to unit test.</p> <p>Functional tests are another story...
<p>Sounds like you could benefit from some basic tests, like: "Does this entire module squirt any out any data when I port it to another operating system?", but beyond that, be pragmatic.</p> <p>If doing it doesn't actually help you, don't do it. Tests for testing sake is an easy way to waste time to little avail.</p...
44,535
<p>I want to use typed parameters in the web methods. But when visual studio 2005 creates the web reference on for the client it automatically creates it's own types. I am using a .net web service and a .net client.</p> <p>For example:</p> <p>&lt; WebMethod > _ Public Function Foo() as ServerNamespace.Bar ... End ...
<p>If you can upgrade to .Net 3.0, I would suggest switching to WCF for your client proxy. Svcutil.exe is the tool to generate a WCF client proxy from the web service; it has an option /reference, which takes an assembly and reuses any shared types from it. (I would also suggest switchnig the service to WCF if it's und...
<p>I've asked the same question before, so the answers I got might be of help:</p> <p><a href="https://stackoverflow.com/questions/216884/force-net-webservice-to-use-local-object-class-not-proxy-class">Force .NET webservice to use local object class, not proxy class</a></p>
27,733
<p><strong>Is there any way that I can remove the Print item from the context menu when you right-click on an email with VBA?</strong></p> <p>I am forever right-clicking to reply to an email, only to accidentally click <code>Print</code> and have Outlook send it directly to the printer quicker than I can stop it.</p> ...
<p>Based on the link TcKs provide, that was pretty simple. In the example below I check the type of the item so that it only affects e-mails and not calendar items. To enter the code in outlook, Type Alt + F11, then expand the Microsoft Office Outlook Objects in the Project pane. Then double click the ThisOutlookSessi...
<p>Thera is sample how to programaticly working with Outlook: <a href="http://msdn.microsoft.com/en-us/library/bb176426.aspx" rel="noreferrer">How to: Customize an Item Context Menu</a></p>
14,812
<p>So most Java resources when speaking of packages mention a <code>com.yourcompany.project</code> setup. However, I do not work for a company, and don't have a website. Are there any naming conventions that are common? An email address, perhaps?</p>
<p>Use a top-level domain like 'bernard' or something else unique. The important part is that the domain is unique so that you avoid clashes, and not that it starts with a real Internet top-level domain like org or com. E.g.</p> <pre><code>import java.util.*; import bernard.myProject.*; import org.apache.commons.l...
<p>For my own personal work when I don't have a namespace, I go for something simple like <code>org.&lt;myname&gt;.*</code></p>
20,051
<p>I need to create a really basic Adobe Illustrator file on the clipboard that I can paste in Adobe Illustrator or Expression Design. I'm looking for code samples on how to programmatically generate Adobe Illustrator Files, preferably from C# or some other .NET language (but at the moment any language goes).</p> <p>I...
<p>I know that Inkscape is free and open source and can edit .ai files.</p> <p>This might be a place to start. <a href="http://www.inkscape.org/" rel="noreferrer">http://www.inkscape.org/</a></p> <p>Also, I think Illustrator can handle standard svg files, so maybe generating those would be a lot easier. (They are XML...
<p>SVG is probably the way to go.</p>
13,819
<p>There's an option to hide the version so it will display only nginx, but is there a way to hide that too so it will not show anything or change the header?</p>
<p>Like Apache, this is a quick edit to the source and recompile. From <a href="https://calomel.org/nginx.html" rel="noreferrer">Calomel.org</a>:</p> <blockquote> <p>The Server: string is the header which is sent back to the client to tell them what type of http server you are running and possibly what version...
<p>Are you asking about the Server header value in the response? You can try changing that with an add_header directive, but I'm not sure if it'll work. <a href="http://wiki.codemongers.com/NginxHttpHeadersModule" rel="nofollow noreferrer">http://wiki.codemongers.com/NginxHttpHeadersModule</a></p>
30,554
<p>I want to write a command that specifies "the word under the cursor" in VIM. For instance, let's say I have the cursor on a word and I make it appear twice. For instance, if the word is "abc" and I want "abcabc" then I could type: </p> <pre><code>:s/\(abc\)/\1\1/ </code></pre> <p>But then I'd like to be able to...
<p><code>&lt;cword&gt;</code> is the word under the cursor (:help <code>&lt;cword&gt;</code>).</p> <p>Sorry, I should have been more complete in this answer.</p> <p>You can nmap a command to it, or this series of keystrokes for the lazy will work:</p> <pre><code>b #go to beginning of current word yw #yank to registe...
<pre><code>" count word (case sensitive) nmap &lt;F4&gt; :%s/\(&lt;c-r&gt;=expand("&lt;cword&gt;")&lt;cr&gt;\)//gn&lt;cr&gt; </code></pre>
7,111
<p>For reasons that we won't discuss, I have determined that MAMP is a pile of crap that haunts my system, and unless I remove it fully, I will live in shame.</p> <p>I've done the obvious thing and removed the MAMP directory from my Applications folder, however, I don't like wandering files, and I have an itching feel...
<p>From their <a href="http://www.mamp.info/en/help.html" rel="noreferrer">help page</a>: </p> <blockquote> <p>To "uninstall" MAMP, you only have to delete the MAMP directory and everything returns to the original state (MAMP does not alter anything on the "normal" OS X).</p> </blockquote>
<p>AppZapper is a great tool that solves this problem. Search Google for it, it's free for the first 5 time you use it.</p>
30,672
<p>One of the web apps I'm working on has a fairly small web store / shopping cart. As the client company is physically located in CA and has a physical location there, they're required to collect CA sales tax on all orders shipped to locations in California.</p> <p>For those who don't know, CA has some fairly comple...
<p>Texas does something similar - the state tax is 6.25%, then there's a local tax (like, County-specific or something) of 1% and an additional "mass transit" tax of 1%. The net effect is that when you go somewhere in Texas you pay 8.25% sales tax. And 8.25% was the maximum. In theory there could be some districts that...
<p>There are third-party resources that are just about indispensible for these sorts of ever-changing rules.</p> <p><a href="http://www.avalara.com" rel="nofollow noreferrer">Here's one.</a> that's SaaS.</p>
38,890
<p>I have a 'foreach' macro I use frequently in C++ that works for most STL containers:</p> <pre><code>#define foreach(var, container) \ for(typeof((container).begin()) var = (container).begin(); \ var != (container).end(); \ ++var) </code></pre> <p>(Note that 'typeof' is a gcc extension.) It is used li...
<p>You can do this using two loops. The first declares the iterator, with a name which is a function of the container variable (and you can make this uglier if you're worried about conflicts with your own code). The second declares the value variable.</p> <pre><code>#define ci(container) container ## iter #define fo...
<p>You could define a template class that takes the type of mymap as a template parameter, and acts like an iterator over the values by overloading * and ->.</p>
10,414
<p>This simple code is not producing any sound on a couple of machines that I've used to test it. I'm running the code from within Eclipse, but I've also tried using the command line to no avail. </p> <pre><code>public static void main(String[] args) { try { Synthesizer synthesizer = MidiSystem.getSynthes...
<p>Some installs of the JRE do not include the JavaSound soundbank.gm (in order to save space) so your code would not have a sound source to trigger on those machines. </p> <p>Check for the existence of the soundbank on the machines that don't work. You can also put the soundbank in the same directory as your .class f...
<p>Have you tried to use different channel ? May be <a href="http://forums.sun.com/thread.jspa?threadID=5237086" rel="nofollow noreferrer">this discusson</a> will get you closer to a solution...</p>
49,812
<p>I arrive to output a string on multiple lines inside a retangle but haven't find a way to reduce or enlarge the line spacing. How to do that?</p>
<p><a href="http://msdn.microsoft.com/en-us/library/xwf9s90b.aspx" rel="noreferrer">This MSDN</a> should help you. Line spacing is a result of the Font you are using. You may need to break your DrawString commands up into multiple calls if you need custom line spacing.</p>
<p>This Microsoft forum posting may be helpful:</p> <p><a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1507414&amp;SiteID=1" rel="nofollow noreferrer">http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1507414&amp;SiteID=1</a></p> <p>This shows how MeasureString can be used to determine how much of ...
44,491
<p>A coworker has been struggling with this problem.</p> <p>The desired result is an installable plugin for Notes that will add a button emails with attachments that will let users save the attachment to a document management system.</p> <p>Finding documentation on doing this for Notes has been an uphill battle to sa...
<p>Both Lotus Notes 8+ and Lotus Symphony use the IBM Lotus Expeditor Toolkit. </p> <p>If you get the Lotus Symphony SDK <a href="http://symphony.lotus.com/software/lotus/symphony/developers.nsf/home" rel="nofollow noreferrer">here</a>.</p> <p>Their are one or two examples dealing with adding button's to the symphony...
<p>I had to do this once in Notes for a plugin I was developing. What I ended up doing was editing the Notes template in the designer, and then writing some LotusScript behind it that called a .NET class via a DLL. So when you clicked the button, it triggered the event in the LotusScript, and then called the DLL, and...
12,944
<p>I do my php work on my dev box at home, where I've got a rudimentary LAMP setup. When I look at my website on my home box, any numbers I echo are automatically truncated to the least required precision. Eg 2 is echoed as 2, 2.2000 is echoed as 2.2.</p> <p>On the production box, all the numbers are echoed with at ...
<p>And when you can't rely on the PHP configuration, don't forget about <a href="http://us.php.net/manual/en/function.number-format.php" rel="noreferrer">number_format()</a> which you can use to define how a number is returned, ex:</p> <pre><code>// displays 3.14 as 3 and 4.00 as 4 print number_format($price, 0); ...
<p>Just to rule out other possible causes: Where are the numbers coming from? Does it do this with literal values?</p> <p>It doesn't seem likely that the precision setting alone could cause this. Check also if anything might be interfering with the output via things like <code>auto_prepend_file</code> or <code>output_...
46,566
<p>I want to write a word addin that does some computations and updates some ui whenever the user types something or moves the current insertion point. From looking at the MSDN docs, I don't see any obvious way such as an TextTyped event on the document or application objects.</p> <p>Does anyone know if this is possib...
<p>As you've probably discovered, <a href="http://msdn.microsoft.com/en-us/library/aa269681(office.10).aspx" rel="nofollow noreferrer">Word has events</a>, but they're for really coarse actions like a document open or a switch to another document. I'm guessing MS did this intentionally to prevent a crappy macro from s...
<p>As you've probably discovered, <a href="http://msdn.microsoft.com/en-us/library/aa269681(office.10).aspx" rel="nofollow noreferrer">Word has events</a>, but they're for really coarse actions like a document open or a switch to another document. I'm guessing MS did this intentionally to prevent a crappy macro from s...
7,957
<p>In a VB.Net Windows Service I'm currently pooling units of work with: </p> <pre><code>ThreadPool.QueueUserWorkItem(operation, nextQueueID) </code></pre> <p>In each unit of work (or thread I'll use for ease of understanding), it will make a couple MSSQL operations like so: </p> <pre><code> Using sqlcmd As N...
<p>From the MS Docs -</p> <p>"Connections are pooled per process, per application domain, per connection string and when integrated security is used, per Windows identity"</p> <p><a href="http://msdn.microsoft.com/en-us/library/8xx3tyca.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/8xx3tyca....
<p>If the number of open connections offends you, take control in the <a href="http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectionstring.aspx" rel="nofollow noreferrer">connection string</a></p> <p>Notice: MinPoolSize and MaxPoolSize.</p>
15,902
<p>Our web application sends e-mails. We have lots of users, and we get lots of bounces. For example, user changes company and his company e-mail is no longer valid.</p> <p>To find bounces, I parse SMTP log file with log parser. The logs come from Microsoft SMTP server.</p> <p>Some bounces are great, like <code>550+#...
<p>This <a href="http://scriptolog.blogspot.com/2007/08/smtp-log-parsing.html" rel="noreferrer">article</a> is exactly what you are looking for. It is based on the great tool <a href="http://www.microsoft.com/technet/scriptcenter/tools/logparser/default.mspx" rel="noreferrer">log parser</a>.</p> <blockquote> <p>Log ...
<p>I based a bounce counter program on this post, only to find out later that this method doesn't actually work for high-volume senders because SMTP logs are not in sequential order. There's more about it in my blog post: <a href="http://phreakhead.livejournal.com/74871.html" rel="nofollow noreferrer">Email Bounce Dete...
25,097
<p>I have an asp.net server control (with the asp: in its definition). The button has been set to do post back.</p> <p>On the server side, I have the on click event handler e.g btnSave_click()</p> <p>On the client side, I have a javascript function to be invoked on the click event e.g btnSave.Attributes.Add("onclick"...
<p>First client side, second server-side.</p> <p>So you can use it.</p> <p>I also use it in some cases, like:</p> <pre><code>close.Attributes["OnClick"] = "return confirm('Are you sure?')"; </code></pre> <p>In this case if the user presses 'No' then the server-side event handler does not even play a role.</p>
<p>I think you need a much better understanding of what it means client side and what it means server side and how they all relate together. I've seen more and more developers make a mess of it.</p> <p>Of course the client side will execute first in your case. Actually there's no way to execute it after the server cod...
24,997
<p>I'm looking for an open-source SGML parser written in plain C. This is to parse bona-fide SGML, not malformed stuff.</p> <p>Any ideas?</p>
<p>There's OpenSP, which is part of the <a href="http://sourceforge.net/projects/openjade/" rel="noreferrer">OpenJade</a> project, but is implemented in C++. Might be close enough for your needs?</p>
<p>This came up on a fast Google search (<a href="http://www.google.com/search?q=sgml+c+parser" rel="nofollow noreferrer">sgml c parser</a>): <a href="http://www.w3.org/Library/src/SGML.html" rel="nofollow noreferrer">http://www.w3.org/Library/src/SGML.html</a>. Does that help? </p> <p>Or perhaps this one: <a href="ht...
37,558
<p>I have an http module on a sharepoint site and this module instantiates a custom class and add it to the session and does other initial things for my site. However, I'm noticing that the http module is being called for all request types (.aspx, .js, .png, .jpg).</p> <p>Is there any way to have an http module only b...
<p>you can also set the :dependent option to :delete_all. :delete_all will issue a single SQL statement to delete all child records. because of this using :delete_all may give you better performance.</p> <pre><code>has_many :memberships, dependent: :delete_all </code></pre>
<p>It looks like this plugin might give you what you're looking for if you want the cascading deletes reflected in the actual database structure:</p> <p><a href="http://www.redhillonrails.org/foreign_key_migrations.html" rel="noreferrer">http://www.redhillonrails.org/foreign_key_migrations.html</a></p> <p>Format for ...
42,937
<p>This might be a bit weird question, but I'll give it a shot:</p> <p>HELP, my Visual Studio 2008 / ASP.NET is giving me GERMAN error messages. Besides the fact that translations tend to be not as good as the original text, I can't search for those and find relevant answers to my problems on the internet.</p> <p>So:...
<p>Go to the Control Panel -> Software. There are language packs for .NET (for each version one). Uninstall them.</p>
<p>Check your system-wide language preferences - 'Regional and Language Options' in WinXP Control Panel. I have found when using VS that my keyboard would go from UK to US mode or even French because the SHIFT + ALT + F10 keystroke is used by VS for showing some context menus and it is also used by Windows as the keyst...
48,574
<p>I am updating a VBA program (excel). At startup the program checks if it can find a directory which is on the office file server using:</p> <pre><code>FileSystemObject.FolderExists("\\servername\path") </code></pre> <p>If this is not found the program switches to offline mode and saves its output to the local hard...
<p><strong>If you're on a domain:</strong></p> <p>Check the LOGONSERVER environmental variable.</p> <p>If there are two '\' symbols before the server name, it's connected to active directory and so you should do your check.</p> <p>Otherwise, it isn't logged into the office network, so you can bypass the check.</p> ...
<p>I use the <code>Dir</code> Command, targeting a shared folder on the server and trapping the error when not found.</p> <pre><code>Dir("\\Servername\aFolder\", vbDirectory) </code></pre>
31,125
<p>In my current 32-bit application, I check (very occasionally) for overflow by doing operations on 64-bit integers.</p> <p>However, on 64-bit systems there does not seem to be a standard 128-bit integer. Is there a simple way of checking for overflow, or a way of getting 128-bit integers, which works on all OSes and...
<p>Much of the discussion in this question applies:</p> <p><a href="https://stackoverflow.com/questions/199333/best-way-to-detect-integer-overflow-in-cc">How to detect integer overflow?</a></p> <p>Many of the techniques used for 32-bit overflow chacking apply to 64-bits as well (not all of the techniques discussed us...
<p>One solution would be to create a class around the 64-bit int which overrode the arithmetic operators to check before performing the operation.</p> <p>I can't remember the operatorX syntax off the top of my head (I switched from C++ to Java a long time ago) but a sample would be:</p> <pre><code>int64 myint64::add ...
25,049
<p>I have a 'generic' boiler plate static method for checking for InvokeRequired and invoking an associated action accordingly.</p> <p>If an unhandled exception is raised by the action, the stack trace isn't much help because it starts from here. I can get information about the control, but that isn't always much help...
<p>You should use WideCharToMultiByte. As an estimate for the output buffer size, you can use the Length field - but do consider the case of true multi-byte strings, in which case it will fail with ERROR_INSUFFICIENT_BUFFER, and you need to start over with a larger buffer. Or, you call it with an output buffer size of ...
<pre><code>WCHAR* UnicodeStringToNulTerminated(UNICODE_STRING* str) { WCHAR* result; if(str == NULL) return NULL; result = (WCHAR*)malloc(str-&gt;Length + 2); if(result == NULL) // raise? return NULL; memcpy(result, str-&gt;Buffer, str-&gt;Length); result[str-&gt;Length] = L'\0'; return result...
32,261
<p>In some my project I notice that during executing unit tests under VSTS2008 its VSTestHost's memory consuming grows. As I have very many tests in my solution it leads to OutOfMemroyException eventually. That looks very strange for me as I was sure that MSTest creates a new AppDomain for each unit test. Otherwise how...
<p>I don't think the unit test engine creates a new AppDomain for each test. Since creating an AppDomain is a relatively expensive operation, doing so for each test would slow down execution of unit tests considerably!</p> <p>Visual Studio 2008 uses a seperate executable called vstesthost.exe to run unit tests. VS c...
<p>This does not seem to be solved in MSTest 2010. I am experiencing a lot of similar issues like this. Why does garbage collection not work in unit test?</p> <p>My understanding was that the UT framework took care of disposing of all executed tests, but this does not seem to be the case with some singleton patterns t...
31,990
<p>What’s the best way to capitalize the first letter of each word in a string in SQL Server.</p>
<p>From <a href="http://www.sql-server-helper.com/functions/initcap.aspx" rel="noreferrer">http://www.sql-server-helper.com/functions/initcap.aspx</a></p> <pre><code>CREATE FUNCTION [dbo].[InitCap] ( @InputString varchar(4000) ) RETURNS VARCHAR(4000) AS BEGIN DECLARE @Index INT DECLARE @Char CHAR(...
<pre><code>IF OBJECT_ID ('dbo.fnCapitalizeFirstLetterAndChangeDelimiter') IS NOT NULL DROP FUNCTION dbo.fnCapitalizeFirstLetterAndChangeDelimiter GO CREATE FUNCTION [dbo].[fnCapitalizeFirstLetterAndChangeDelimiter] (@string NVARCHAR(MAX), @delimiter NCHAR(1), @new_delimeter NCHAR(1)) RETURNS NVARCHAR(MAX) AS BEGI...
7,875
<p>I'm trying to use the StringEscapeUtils.escapeXML() function from org.apache.commons.lang...</p> <p>There are two versions of that function, one which expects (Writer, String) and one which just expects (String)....</p> <p><a href="http://commons.apache.org/lang/api/org/apache/commons/lang/StringEscapeUtils.html#e...
<p>The error message is telling you that you are passing an Object into the method, not a String.</p> <p>If you are sure that the Object is a String, then you'll need to cast it to a String first.</p> <p>If this doesn't work, please post the actual code that is giving you trouble.</p>
<p>What exactly is the compiler error message?</p> <p>is it possible that you're using a different version of the commons library that does not have the 1-parameter method?</p>
48,568
<p>I've been given some code with commenting unlike anything I've come across before:</p> <pre><code>//{{{ Imports import imports; //}}} </code></pre> <p>It is the same for each method block, </p> <pre><code>//{{{ above the code block //}}} below the code block </code></pre> <p>Also see: <a href="http://en.wikip...
<p>A quick search for <em>"triple curly" comment</em> suggests it's "<a href="http://www.emacswiki.org/cgi-bin/wiki/FoldingMode" rel="noreferrer">Emacs folding mode</a>".</p> <p>Or some other code folding marker in any case.</p>
<p>Maybe it's to emphasize a code block?</p> <p><em>shrugs</em></p>
23,885
<p>I'm looking for a consistent way to structure my use of formatting strings throughout a large web application, and I'm looking for recommendations or best practices on which way to go.</p> <p>Up until now I've had a static class that does some common formatting e.g.</p> <p>Formatting.FormatCurrency</p> <p>Formatt...
<p>One option is to use a helper class with extension methods like</p> <pre><code>public static class MyWebAppExtensions { public static string FormatCurrency(this decimal d) { return d.ToString("c"); } } </code></pre> <p>Then anywhere you have a decimal value you do</p> <pre><code>Decimal d = 10...
<p>This answer can be combined with GeekyMonkey's answer.</p> <p>First of all, in ASP.NET you have the possibility to set the culture and UI culture in web.config using the <a href="http://msdn.microsoft.com/en-us/library/hy4kkhe0.aspx" rel="nofollow noreferrer"><code>globalization</code></a> element. The <code>resourc...
37,583
<p>Are C-style macro names subject to the same naming rules as identifiers? After a compiler upgrade, it is now emitting this warning for a legacy application:</p> <pre><code>warning #3649-D: white space is required between the macro name "CHAR_" and its replacement text #define CHAR_&amp; 38 </code>...
<p>Macro names should only consist of alphanumeric characters and underscores, i.e. <code>'a-z'</code>, <code>'A-Z'</code>, <code>'0-9'</code>, and <code>'_'</code>, and the first character should not be a digit. Some preprocessors also permit the dollar sign character <code>'$'</code>, but you shouldn't use it; unfor...
<p>The same rules that specify valid identifiers for variable names apply to macro names with the exception that macros may have the same names as keywords. Valid characters in identifier names include <code>digits</code> and <code>non-digits</code> and must not start with a digit. <code>non-digits</code> include the...
48,258
<p>How would I print a spinning curser in a utility that runs in a terminal using standard C?</p> <p>I'm looking for something that prints: \ | / - over and over in the same position on the screen?</p> <p>Thanks </p>
<p>You could use the backspace character (<code>\b</code>) like this:</p> <pre><code>printf("processing... |"); fflush(stdout); // do something printf("\b/"); fflush(stdout); // do some more printf("\b-"); fflush(stdout); </code></pre> <p>etc. You need the <code>fflush(stdout)</code> because normally stdout is buffer...
<p>There is no truly "standard" way to do this, since the C Standard Library (<a href="http://members.aol.com/wantondeb/" rel="nofollow noreferrer">http://members.aol.com/wantondeb/</a>) does not provide functions to do raw terminal/console output.</p> <p>In DOS/Windows console, the standard-ish way to do it is with <...
24,297
<p>We have a situation where users are allowed to upload content, and then separately make some changes, then submit a form based on those changes.</p> <p>This works fine in a single-server, non-failover environment, however we would like some sort of solution for sharing the files between servers that supports failov...
<p>At a former job we had a cluster of web servers with an F5 load balancer in front of them. We had a very similar problem in that our applications allowed users to upload content which might include photo's and such. These were legacy applications and we did not want to edit them to use a database and a SAN solutio...
<p>The best solution for this is usually to provide the shared area on some form of SAN, which will be accessible from all servers and contain failover.</p> <p>This also has the benefit that you don't have to provide sticky load balancing, the upload can be handled by one server, and the edit by another.</p>
4,263
<p>How do you open a path in explorer by code in c++. I googled and couldn't find any thing but systems commands to do this, however, i dont want it to block or show the console window.</p>
<p>You probably are looking for the <a href="http://msdn.microsoft.com/en-us/library/bb762153(VS.85).aspx" rel="nofollow noreferrer"><code>ShellExecute()</code></a> function in <code>shellapi.h</code>. It is called with an &quot;action verb&quot;, a path, and optional parameters. In your case this will want either &q...
<p>I'm now using VS2017, using as follows works:</p> <pre><code>ShellExecute(NULL, L&quot;open&quot;, L&quot;YourFolderPath\\YourFile.xxx&quot;, NULL, NULL, SW_RESTORE); </code></pre> <p>also reference <a href="https://stackoverflow.com/questions/46558259/shellexecute-to-open-an-exe-in-c">ShellExecute to open an .exe i...
46,247
<p>I have two tables: <code>foos</code> and <code>bars</code>, and there is a many-to-one relationship between them: each <code>foo</code> can have many <code>bars</code>. I also have a view <code>foobars</code>, which joins these two tables (its query is like <code>select foo.*, bar.id from foos, bars where bar.foo_id...
<p>Rysiek, if I understood correctly, you have text column in <code>foos</code> table that is parsed to extract foreign keys pointing to <code>bars</code> table. This approach to building relations may be justified in some cases, however almost every guide/tutorial to database programming would discourage doing so. Why...
<p>I don't think new.foo_id is correct in the context of a delete.</p> <p>Shouldn't it be DELETE FROM bars WHERE foo_id=old.foo_id?</p>
19,398
<p>I'm trying to get Python scripts, called from a web browser, to work. I keep getting the error: </p> <pre><code>500 Internal Server Error </code></pre> <p>When I check my error logs I see the message </p> <pre><code>Premature end of script headers </code></pre> <p>The only documentation of this error online says...
<p>This is the exact behavior you would get if your Python script does not have the executable permission set.</p> <p>Try:</p> <pre><code>chmod a+x foo.py </code></pre> <p>(where foo.py is your script name).</p> <p>See the <a href="http://httpd.apache.org/docs/1.3/howto/cgi.html#filepermissions" rel="noreferrer">Ap...
<p>This ended up being a <code>dos2unix</code> issue for me. Ran <code>dos2unix test.py test.py</code> and it worked. The <code>\r\n</code> combinations were the problem. Had to <code>yum install dos2unix</code> to get it installed.</p>
49,623
<p>This is my very first question so I am a bit nervous about it because I am not sure whether I get the meaning across well enough. Anyhow, here we go....</p> <p>Whenever new milestones in programming have been reached it seems they always have had one goal in common: to make it easier for programmers, well, to progr...
<p>Sorry, I don't agree at all. Code is ultimately a blueprint for making things (objects), so it <em>has</em> to be very precise and rule-governed in order to function reliably. Natural language won't take over programming any sooner than sketching ideas on napkins will take over mechanical engineering.</p>
<p>The current spurt of interest in Functional Programming result primarily of C# 3.0's cool new features is basically to enable parallelism and denotes a shift towards multi-core computing. IMHO, I don't think we can consider this a next step towards 'natural language programming'</p>
36,310
<p>I have a deceptively simple scenario, and I want a simple solution, but it's not obvious which is "most correct" or "most Java".</p> <p>Let's say I have a small authenticate(Client client) method in some class. The authentication could fail for a number of reasons, and I want to return a simple boolean for control ...
<p>Returning a small object with both the boolean flag and the String inside is probably the most OO-like way of doing it, although I agree that it seems overkill for a simple case like this.</p> <p>Another alternative is to always return a String, and have null (or an empty String - you choose which) indicate success...
<p>How about returning a string. Empty or Null for success. Error Message in case of failure. Simplest that would work. However not sure if it reads well.</p>
46,447
<p>Continuing my problem from yesterday, the Silverlight datagrid I have from this <a href="https://stackoverflow.com/questions/74461/silverlight-datagrid-control-selection-changed-event-interfering-with-sorting">issue</a> is now causing Stack Overflow errors when sorting a column with a large amount of data (Like the ...
<p>I'm only familiar with the WPF version of this datagrid, but try this:</p> <pre><code>&lt;data:DataGridTextColumn CanUserSort="False" Header="First Name" Binding="{Binding FirstName}" /&gt; </code></pre> <p>Add the CanUserSort="False" attribute on each column you don't want sorted.</p>
<p>Give this a shot:</p> <pre><code>dataGridView1.Columns[*Numberofthecolumnyoudontwantsorted*].SortMode = DataGridViewColumnSortMode.NotSortable; </code></pre>
11,315
<p>I'm programming an online game for two reasons, one to familiarize myself with server/client requests in a realtime environment (as opposed to something like a typical web browser, which is not realtime) and to actually get my hands wet in that area, so I can proceed to actually properly design one.</p> <p>Anywho, ...
<p><strong>The easiest thing</strong> </p> <p>for you to do, would be to simply invoke the windows API <strong>QueueUserWorkItem</strong>. All you have to specify is the function that the thread will execute and the input passed to it. A thread pool will be automatically created for you and the jobs executed in it. Ne...
<p>See it as a <a href="http://en.wikipedia.org/wiki/Producer-consumer_problem" rel="nofollow noreferrer">producer-consumer problem</a>: when receiving, your network communication thread is the producer whereas the UI thread is the consumer. When sending, it's just the opposite. Implement a simple buffer class which gi...
17,254
<p>I wonder if is possible to use FTS with LINQ using .NET Framework 3.5. I'm searching around the documentation that I didn't find anything useful yet.</p> <p>Does anyone have any experience on this?</p>
<p>Yes. However you have to create SQL server function first and call that as by default LINQ will use a like.</p> <p>This <a href="http://sqlblogcasts.com/blogs/simons/archive/2008/12/18/LINQ-to-SQL---Enabling-Fulltext-searching.aspx" rel="noreferrer">blog post</a> which will explain the detail but this is the extrac...
<p>I made a working prototype, for SQL Server's <em>CONTAINS</em> only and no wildcard columns. What it achieves is for you to use <em>CONTAINS</em> like ordinary LINQ functions:</p> <pre><code>var query = context.CreateObjectSet&lt;MyFile&gt;() .Where(file =&gt; file.FileName.Contains("pdf") &amp;&amp; Fu...
27,734
<p>I want to create a stand-alone (i.e. not hosted in IIS) web service in ASP.NET. Is this possible, and if so what's the best way to do it?</p>
<p>So, you want to use ASP.NET to generate a web service, but you don't want to host ASP.NET using IIS. (For those reading this, the question was made clearer in an comment to Sir Psycho's response).</p> <p>Then this article would be a good start:<br /> <a href="http://aspalliance.com/articleViewer.aspx?aId=220&amp;pI...
<p>I don't know if this answers the question exactly. If you want to create a webservice, is there a reasonable way to not require IIS but not have to handle data at a socket level.?</p>
31,468
<p>I have an msbuild project which builds a SLN file from visual studio which holds all the projects in (about 70+ project), and a lot of the projects are dependent on each other meaning they need to be build in order - sometimes a developer forgets to set the build order manually in visual studio in the solution file ...
<p>How are you calling MSBuild? If you point MSBuild to the solution file, it should be able to work out the dependencies. If you point it to individual project files, then it won't be able to resolve any project references.</p> <p>If you don't use project references you can still control the dependency order in a sol...
<p>While it is correct that MSBuild should observe the build order when you use project dependencies there is one caveat. It doesn't at present observe the reverse build order when building the clean target (as I have blogged about <a href="http://brumlemann.blogspot.com/2008/12/why-it-is-error-for-msbuild-to-build.htm...
36,558
<p>Similar to <a href="https://stackoverflow.com/questions/216710/call-openfiledialog-from-powershell">this question</a>, after running the following code the browser dialog does appear with all the correct buttons, but the selection area that usally displays available folders is missing:</p> <pre><code>[void] [Reflec...
<p>I encountered this problem a while back and found the following COM workaround on the MSDN forums:</p> <pre><code>$app = new-object -com Shell.Application $folder = $app.BrowseForFolder(0, "Select Folder", 0, "C:\") if ($folder.Self.Path -ne "") {write-host "You selected " $folder.Self.Path} </code></pre> <p><a hr...
<p>Just FYI, if you are looking to do Windows Forms stuff, there is one product currently out that will do windows forms for PowerShell (The <a href="http://www.adminscripteditor.com/" rel="nofollow noreferrer">Admin Script Editor</a>) and Sapien is working on a <a href="http://hosted.verticalresponse.com/172892/13e806...
26,652
<p>Does anyone know how to create a ClickOnce publication for a CD with the publish task in MSBuild?</p> <p>VS2008 has a 'publish wizard' with a publish to CD radio button choice. It publishes a click once install to a local folder that is suitable for burning to a CD.</p> <p>We are following a scheduled MSBuild wit...
<p>I've done a couple of things to give myself this functionality over the years. I build enterprise applicatons that may be distributed across many servers. I don't want to bury config settings in each services config file or each web server's web.config file. For application specific stuff I usually create an appl...
<p>Any VCS through a secure channel?</p> <p>For example, git through ssh (both available in cygwin).</p> <p>I think the first step is to have the secure channel (if you want the push ability, pulling might be different).</p> <p>As for managing the "versions" in different "branches", what's better than a version cont...
46,054
<p>is it possible to create java application that will work as background process on symbian smartphones?</p>
<p>You can approximate it but J2ME (the version of java on mobile phones) may not be the right technology to do this.</p> <ul> <li><p>starting a MIDlet (a Java application for mobile phones) when the phone is switched on is tricky at best without coding a small Symbian OS C++ module that will start it for you. If you ...
<p>You can approximate it but J2ME (the version of java on mobile phones) may not be the right technology to do this.</p> <ul> <li><p>starting a MIDlet (a Java application for mobile phones) when the phone is switched on is tricky at best without coding a small Symbian OS C++ module that will start it for you. If you ...
11,910
<p>I have a databases table with ~50K rows in it, each row represents a job that need to be done. I have a program that extracts a job from the DB, does the job and puts the result back in the db. (this system is running right now)</p> <p>Now I want to allow more than one processing task to do jobs but be sure that no...
<p>Here's what I've used successfully in the past:</p> <p>MsgQueue table schema</p> <pre><code>MsgId identity -- NOT NULL MsgTypeCode varchar(20) -- NOT NULL SourceCode varchar(20) -- process inserting the message -- NULLable State char(1) -- 'N'ew if queued, 'A'(ctive) if processing, 'C'ompleted, default 'N' --...
<p>You are trying to implement de "Database as IPC" antipattern. Look it up to understand why you should consider redesigning your software properly.</p>
38,031
<p>I am developing a piece of software in Python that will be distributed to my employer's customers. My employer wants to limit the usage of the software with a time-restricted license file.</p> <p>If we distribute the <code>.py</code> files or even <code>.pyc</code> files it will be easy to (decompile and) remove the...
<p>Python, being a byte-code-compiled interpreted language, is very difficult to lock down. Even if you use a exe-packager like <a href="http://py2exe.org" rel="noreferrer">py2exe</a>, the layout of the executable is well-known, and the Python byte-codes are well understood.</p> <p>Usually in cases like this, you hav...
<p>I documented how to obfuscate the python by converting it to .so file, and converting it to a python wheel file: <a href="https://github.com/UM-NLP/python-obfuscation" rel="nofollow noreferrer">https://github.com/UM-NLP/python-obfuscation</a></p>
32,728
<p>My asp.net mvc site needs some kind of authorization but it is rather different than the usual concept of users and thus membership. It will be used more for preferences then for authentication actually. Accounts without any password should be possible (and will initially be the only type) and an account can also be...
<p>You could use the standard Membership provider and using the Built in .Validate() method sending the Username and a Password that is "standard" for all accounts without authentication.</p> <p>Have 2 different User Controls 1 for "Validated Login with Password" and one for "Share Account without password", each uses...
<p>There is detailed information on the Membership Provider at <a href="http://msdn.microsoft.com/en-us/library/f1kyba5e.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/f1kyba5e.aspx</a>. Basically you need to create new provider, or derive from the existing, and overload the ValidateUser metho...
48,914
<p>How can I tell if SP1 has been installed on VS2008? e.g. If I'm working on a co-worker's machine - how can I tell if he/she has installed SP1 for VS2008?</p>
<p>In Help->About, you can view the installed products. You should see something similar to</p> <blockquote> <p>Microsoft Visual Studio Team System 2008 Team Suite - ENU Service Pack 1 (KB945140) KB945140</p> </blockquote> <p>in the list of entries.</p>
<p>It also puts a little '9' in a white box on the program icon. (Probably not dependable, of course)</p>
19,450
<p>Not sure what exactly is going on here, but seems like in .NET 1.1 an uninitialized event delegate can run without issues, but in .NET 2.0+ it causes a NullReferenceException. Any ideas why. The code below will run fine without issues in 1.1, in 2.0 it gives a NullReferenceException. I'm curious why does it behav...
<p>[updated] AFAIK, there was no change here to the fundamental delegate handling; the difference is in how DataTable behaves.</p> <p>However! Be very careful using static events, especially if you are subscribing from instances (rather than static methods). This is a good way to keep huge swathes of objects alive and...
<p>The way events work hasn't really changed from 1.1 to 2</p> <p>Although the syntax looks like normal aggregation it really isn't:</p> <pre><code>dt.RowChanged += TableEventHandler; dt.RowChanged += null; dt.RowChanged += delegate (object sender, DataRowChangeEventArgs e) { //anon }; </code></pre> <p>Will fire...
21,945
<p>In Microsoft IL, to call a method on a value type you need an indirect reference. Lets say we have an ILGenerator named "il" and that currently we have a Nullable on top of the stack, if we want to check whether it has a value then we could emit the following:</p> <pre><code>var local = il.DeclareLocal(typeof(Nulla...
<p>If the variable is already on the stack, you can go ahead and just emit the method call. </p> <p>It seems that the constructor doesn't push the variable on the stack in a typed form. After digging into the IL a bit, it appears there are two ways of using the variable after constructing it. </p> <p>You can load ...
<p>Just wrote a class that does what the OP is asking... here's the IL code that C# compiler produces:</p> <pre><code> IL_0008: ldarg.0 IL_0009: ldarg.1 IL_000a: newobj instance void valuetype [mscorlib]System.Nullable`1&lt;int32&gt;::.ctor(!0) IL_000f: stfld valuetype [mscorlib]System.Nullable`1&l...
10,187
<p>I want to send an array constructed in javascript with the selected values of a multiple select. Is there a way to send this array to a php script using ajax?</p>
<p>You can post back to your server with XML or JSON. Your javascript will have to construct the post, which in the case of XML would require you to create it in javascript. JSON is not only lighterweight but easier to make in javascript. Check out <a href="http://mike.teczno.com/json.html" rel="noreferrer">JSON-PHP<...
<p>You can create an array and send it, as Meador recommended: (following code is Mootooled, but similar in other libraries / plain old JS)</p> <pre><code>myArray.each(function(item, index) myObject.set('arrayItems['+index+']', item); myAjax.send(myObject.toQueryString()); </code></pre> <p>That will send to php an a...
38,396
<p>I'm creating HTML with a loop that has a column for Action. That column is a Hyperlink that when the user clicks calls a JavaScript function and passes the parameters...</p> <p>example:</p> <pre><code>&lt;a href="#" OnClick="DoAction(1,'Jose');" &gt; Click &lt;/a&gt; &lt;a href="#" OnClick="DoAction(2,'Juan');" &g...
<p>Using POST</p> <pre><code>function DoAction( id, name ) { $.ajax({ type: "POST", url: "someurl.php", data: "id=" + id + "&amp;name=" + name, success: function(msg){ alert( "Data Saved: " + msg ); } }); } </code></pre> <p>Using GET</...
<p>Do you want to pass parameters to another page or to the function only?</p> <p>If only the function, you don't need to add the $.ajax() tvanfosson added. Just add your function content instead. Like:</p> <pre><code>function DoAction (id, name ) { // ... // do anything you want here alert ("id: "+id+" -...
48,382