instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>So what I'm looking for here is something like PHP's <a href="http://us2.php.net/print_r" rel="noreferrer">print_r</a> function.</p> <p>This is so I can debug my scripts by seeing what's the state of the object in question.</p>
<p>You are really mixing together two different things.</p> <p>Use <a href="https://docs.python.org/3/library/functions.html#dir" rel="noreferrer"><code>dir()</code></a>, <a href="https://docs.python.org/3/library/functions.html#vars" rel="noreferrer"><code>vars()</code></a> or the <a href="https://docs.python.org/3/l...
<p>I like working with python object built-in types <a href="https://docs.python.org/2/library/stdtypes.html?highlight=keys#dict.keys" rel="nofollow noreferrer">keys</a> or <a href="https://docs.python.org/2/library/stdtypes.html?highlight=keys#dict.values" rel="nofollow noreferrer">values</a>. </p> <p>For attributes...
23,345
<p>There are certain Crystal Reports features that cannot be combined in the same report, for example SQL command objects and server side grouping. However, as far as I can find, the built-in help doesn't seem to clearly document these conflicts. For example, checking the help page for either of those features doesn't ...
<p>You could use sort() with a custom comparator if you kept a third array with the index, and sorted on that, leaving the data intact.</p> <p>Java code example:</p> <pre><code>Integer[] idx = new Integer[numbers.length]; for( int i = 0 ; i &lt; idx.length; i++ ) idx[i] = i; Arrays.sort(idx, new Compara...
<p>You need to sort the colors array by its relative item in the numbers array. Specify a comparator that compares numbers and use that as the comparison for the colors array.</p>
13,739
<p>I've got a php script. Most of the time the script returns html, which is working fine, but on one occasion (parameter ?Format=XML) the script returns XML instead of HTML.</p> <p>Is there any way to change the returned mime type of the php output on the fly from text/html to text/xml or application/xml?</p>
<pre><code>header('Content-type: application/xml'); </code></pre> <p>More information available at the PHP documentation for <a href="http://php.net/manual/en/function.header.php" rel="noreferrer"><code>header()</code></a></p>
<p>I just used the following:<br> NOTE: I am using "i" for sql improved extension. </p> <pre><code>Start XML file, echo parent node header("Content-type: text/xml"); echo "&lt;?xml version='1.0' encoding='UTF-8'?&gt;"; echo "&lt;marker&gt;"; </code></pre> <p>Iterate through the rows, printing XML nodes for each</p> ...
18,327
<p>I am having some trouble manipulating images using CodeIgniter 1.7. With the following code, the image is uploaded correctly. Alas, instead of a new image being made, and then modified; the existing image is modified. Any help?</p> <pre><code>//Upload image first $config['upload_path'] = './uploads/'; $config['all...
<p>The problem is simple, you have a typo in the line:</p> <pre><code>$imagemanip['new_img'] = './uploads/'.$thumbnail; </code></pre> <p>The the index should be "new_image", not "new_img", so the line becomes..</p> <pre><code>$imagemanip['new_image'] = './uploads/'.$thumbnail; </code></pre>
<pre><code>//Upload image first $config['upload_path'] = './uploads/'; $config['allowed_types'] = 'gif|jpg|png|bmp'; $this-&gt;load-&gt;library('upload', $config); $this-&gt;upload-&gt;do_upload(); //Now fix the image $picloc = $this-&gt;upload-&gt;data(); $picloc = $picloc['file_name']; $thumbnail = "thumb_...
31,891
<p>I want to filter the selectable dates on a datepicker. I basically need to filter by work days - i.e. make holidays and weekends not selectable.</p> <p>I know you can specify dates using a function in the beforeShowDate: and you can also use $.datepicker.noWeekends.</p> <p>Question is: can you do both?</p>
<p>$.datepicker.noWeekends is a pretty simple bit of code:</p> <pre><code>function (date) { var day = date.getDay(); return [day &gt; 0 &amp;&amp; day &lt; 6, ""]; } </code></pre> <p>Since you're going to have to write up the function for holidays, you can just include this logic in that function too.</p>
<p>Can you do the opposite and have the input what dates are selectable and leave all the rest filtered out?</p>
29,847
<p>There seems to have been some interest over the past year around COP within the .NET community (ala <a href="http://www.qi4j.org/" rel="noreferrer">Qi4j</a>). A few folks have rolled there own COP frameworks (<em>see links below</em>) and it would appear .NET 4.0's Dynamic Dispatch and MEF might have a potential rol...
<p>Aku - There is considerable difference between the CAB / Composite WPF guidance and COP which is a fundamentally different approach to the expression of object behavior via the assembly of 'fragments' based on [Domain] context. The appearance of Mixins, Concerns, Constraints, and SideEffects in .NET 4.0 variously mi...
<p>Check MEF <a href="http://mef.codeplex.com" rel="nofollow noreferrer">http://mef.codeplex.com</a>, currently shipped inside .NET 4, more in PDC session <a href="http://microsoftpdc.com/Sessions/FT24" rel="nofollow noreferrer">http://microsoftpdc.com/Sessions/FT24</a></p>
18,357
<p>I'm looking for a way to authenticate users through LDAP with PHP (with Active Directory being the provider). Ideally, it should be able to run on IIS 7 (<a href="http://adldap.sourceforge.net/" rel="noreferrer">adLDAP</a> does it on Apache). Anyone had done anything similar, with success?</p> <ul> <li>Edit: I'd pr...
<p>Importing a whole library seems inefficient when all you need is essentially two lines of code...</p> <pre><code>$ldap = ldap_connect("ldap.example.com"); if ($bind = ldap_bind($ldap, $_POST['username'], $_POST['password'])) { // log them in! } else { // error message } </code></pre>
<p>PHP has libraries: <a href="http://ca.php.net/ldap" rel="noreferrer">http://ca.php.net/ldap</a></p> <p>PEAR also has a number of packages: <a href="http://pear.php.net/search.php?q=ldap&amp;in=packages&amp;x=0&amp;y=0" rel="noreferrer">http://pear.php.net/search.php?q=ldap&amp;in=packages&amp;x=0&amp;y=0</a></p> <...
20,677
<p>Consider the following trivial HTML page that throws an error:</p> <pre><code>&lt;html&gt;&lt;head&gt;&lt;script&gt; throw new Error('oops'); alert('should not reach here'); &lt;/script&gt;&lt;/head&gt;&lt;/html&gt; </code></pre> <p>The user I am logged into Vista with is a member of both the Administrators an...
<p>You will probably see that the first 1000 chars will take almost no time opposed to the last 1000 chars. </p> <p>I would assume that the time-consuming part is the actual copying of the large string into a new memory-area every time you add a char that is the tough work for your computer.</p> <p>Your optimization ...
<p>Answer to the modified queston ("why does this non-obvious optimization work so well" and "is it true you shouldn't use + operator on strings"):</p> <p>I'm not sure which non-obvious optimization you are talking about. But the answer to the second question, I think, covers all of the bases.</p> <p>The way strings...
35,773
<p>There are many different printing technologies. While it might be clear to the asker that he's talking about his home 3D printing machine, that's not necessarily the case for those that try to answer the question.</p> <p>I think it would help to specify the scope of questions with tags, to allow future visitors to ...
<p>No, there will be many questions which are more general in nature, and have little to do with the actual process used to produce the part.</p> <p>We should encourage tag use for process when appropriate, but I don't think making it mandatory will work in the long term.</p>
<p>No, there will be many questions which are more general in nature, and have little to do with the actual process used to produce the part.</p> <p>We should encourage tag use for process when appropriate, but I don't think making it mandatory will work in the long term.</p>
1
<p>In Perl, I can type:</p> <pre><code>$|++; </code></pre> <p>and anything printed to STDOUT will be automatically fflush()ed.</p> <p>Is there an equivalent in C? In other words, is there some way I can tell stdio to automatically fflush stdout after every printf(), the way it automatically flushes stderr?</p>
<p>Try <code>setvbuf(stdout, NULL, _IONBF, 0)</code>. It changes <code>stdout</code> to unbuffered (<code>_IONBF</code>) mode.</p>
<p>Take a look at setbuf() and setvbuf().</p>
26,341
<p>Since <em>length</em> is a JavaScript property, does it matter whether I use</p> <pre><code>for( var i = 0; i &lt; myArray.length; i++ ) </code></pre> <p>OR</p> <pre><code>var myArrayLength = myArray.length; for( var i = 0; i &lt; myArrayLength ; i++ ) </code></pre> <p>­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­<...
<pre><code>for(var i = 0, iLen = myArray.length; i &lt; iLen; i++) </code></pre> <p>See <a href="http://blogs.oracle.com/greimer/resource/loop-test.html" rel="nofollow noreferrer">http://blogs.oracle.com/greimer/resource/loop-test.html</a> for benchmarks of various Javascript loop constructs.</p>
<p>While the second form may be faster:</p> <pre><code>function p(f) { var d1=new Date(); for(var i=0;i&lt;20;i++) f(); print(new Date()-d1) } p(function(){for(var i=0;i&lt;1000000; i++) ;}) p(function(){var a = new Array(1000000); for(var i=0;i&lt;a.length; i++) ;}) &gt; 823 &gt; 1283 </code></pre> <p>..it shouldn't...
20,340
<p>I am looking for a drawing library or code examples to draw images or vector shapes repeated along a path which could be curved.</p> <p>I found a cocoa library which is what I am looking for <a href="http://apptree.net/drawkitmain.htm" rel="nofollow noreferrer">http://apptree.net/drawkitmain.htm</a> but for .NET.</...
<p>I would use <a href="http://www.w3.org/Graphics/SVG/" rel="nofollow noreferrer">Scalable Vector Graphics</a> (SVG). This is ideal for manipulating vectorial images. You may want to look at <a href="http://www.jbrowse.com/svgnet/" rel="nofollow noreferrer">SvgNet</a>.</p>
<p>Or use native .Net in form of WPF. Using a DrawingBrush you can project whatever you like over any vector path you design.</p>
22,374
<p>We have a series of drop down controls that determine the sort order of columns. The problem we are having is when the user selects a column as the 2nd column the other dropdown lists need to have their values changed so that there is only one "2nd".</p> <ol> <li>Column A [1]</li> <li>Column B [2]</li>...
<p>Look at Javascript toolkits like <a href="http://script.aculo.us/" rel="nofollow noreferrer">Scriptaculous</a> for client side reordering.</p> <p>You add your elements as "<a href="http://github.com/madrobby/scriptaculous/wikis/sortable" rel="nofollow noreferrer">Sortables</a>" and code your own callbacks to execut...
<p>On a note on JavaScript frameworks; I highly recommend <a href="http://www.jquery.com" rel="nofollow noreferrer">jQuery</a>.</p>
18,796
<p>I had made some questions regarding PHP-GTK (there are only 4 <code>php-gtk</code> tagged questions and three are mine) and I end up answering myself because no one answer them.</p> <p>I know it is a strange language selection but I was attracted to it because it runs on several OSs and the fact that I can reuse so...
<p>Both Python and Ruby can work with the GTK libraries. These may be better chocies of languages for you (you'll certainly get more folk here answering your questions :)</p> <p>See <a href="https://stackoverflow.com/questions/115501/is-ruby-any-good-for-gui-development">Is Ruby any good for GUI development?</a> and <...
<p>To answer your question from the other side.</p> <p>Other GUI applications that can be coded in PHP include <a href="https://en.wikipedia.org/wiki/WxWidgets" rel="nofollow">wxWidgets</a> and <a href="https://en.wikipedia.org/wiki/Qt_(software)" rel="nofollow">Qt</a>, both of which have PHP bindings available: <a hr...
25,640
<p>I have drawn an image in the device context using python and I want to move it smoothly/animate either vertically or horizontally.</p> <p>What algorithm should I use? Where can I get info for this kind of tasks in python?</p>
<p>Once an object is drawn in a device context it stays there. If you want to move it you need to redraw it.</p> <p>You can keep a background that's fixed and only redraw the movable elements each time they move. Basically that's how it's done.</p> <p>To move an object smoothly over a line you have to do something li...
<p>To smoothly move object between starting coordinate <code>(x1, y1)</code> and destination coordinate <code>(x2,y2)</code>, you need to first ask yourself, how <em>long</em> the object should take to get to its destination. Lets say you want the object to get there in <code>t</code> time units (which maybe seconds, h...
15,417
<p>I'm building a project from the command line using WinCE platform builder, and I need RTTI to be enabled, so that my project works correctly. I tried setting the option <code>RTTI="YES</code>" in the sources and in the makefile of each dir, and I also tried to add it at the end of <code>CDEFINES</code>, but when I ...
<p><strong>Command-Line Warning D9025</strong></p> <p>If two options specify contradictory or incompatible directives, the directive specified or implied in the option farthest to the right on the command line is used.</p> <p>If you get this warning when compiling from the development environment, and are not sure wh...
<p>Start by looking in sources.cmn, which is a common sources file for the entire build system. If it's not there, keep in mind that every SOURCES file can alter compiler variables for it's folder, plus the makefiles can also alter things. To add to the fun, the system and platform build batch files can also play wit...
13,903
<p>I have been writing Flex applications for a few months now and luckily have not needed a full debugger as of yet, so far I have just used a few Alert boxes...</p> <p>Is there an available debugger that is included in the free Flex SDK? I am not using FlexBuilder (I have been using Emacs and compiling with ant).</p>...
<p>A debugger called <code>fdb</code> is included in the Flex SDK. Here's some documentation on how to use it:</p> <ul> <li><a href="http://www.adobe.com/devnet/flex/articles/client_debug_08.html" rel="nofollow noreferrer">Adobe DevCenter: Debugging Client-Side Code in Flex Applications</a></li> <li><a href="http://li...
<p>I had the same problem when programming with ActionScript and having to test it on a browser. Try <a href="http://www.flex888.com/649/debugging-flex-with-thunderbolt.html" rel="nofollow noreferrer">this</a>. It involves using Firefox (which I believe you do) and FireBug to receive the debug messages.</p>
8,070
<p>I'm trying to create a Python script that opens several databases and compares their contents. In the process of creating that script, I've run into a problem in creating a list whose contents are objects that I've created.</p> <p>I've simplified the program to its bare bones for this posting. First I create a new...
<p>You demonstrate a fundamental misunderstanding.</p> <p>You never created an instance of SimpleClass at all, because you didn't call it.</p> <pre><code>for count in xrange(4): x = SimpleClass() x.attr = count simplelist.append(x) </code></pre> <p>Or, if you let the class take parameters, instead, you c...
<p>If I understand correctly your question, you ask a way to execute a deep copy of an object. What about using copy.deepcopy?</p> <pre><code>import copy x = SimpleClass() for count in range(0,4): y = copy.deepcopy(x) (...) y.attr1= '*Bob* '* count </code></pre> <p>A deepcopy is a recursive copy of the entire...
45,307
<p>I want to have a map that has a homogeneous key type but heterogeneous data types.</p> <p>I want to be able to do something like (pseudo-code):</p> <pre><code>boost::map&lt;std::string, magic_goes_here&gt; m; m.add&lt;int&gt;("a", 2); m.add&lt;std::string&gt;("b", "black sheep"); int i = m.get&lt;int&gt;("a"); in...
<pre><code>#include &lt;map&gt; #include &lt;string&gt; #include &lt;iostream&gt; #include &lt;boost/any.hpp&gt; int main() { try { std::map&lt;std::string, boost::any&gt; m; m["a"] = 2; m["b"] = static_cast&lt;char const *&gt;("black sheep"); int i = boost::any_cast&lt;int&g...
<p>boost any surely works, but I think using Int to type Technology as the key type of fusion map is a better solution. No type erasure and possibly faster </p>
31,308
<p>I am converting from existing CVS repository to SVN repository. CVS repository has few brances and I'd like to rename branches while converting.</p> <p>Wanted conversion is like this:</p> <pre><code>CVS branch SVN branch HEAD -&gt; branches/branchX branchA -&gt; trunk branchB -&gt; ...
<blockquote>I am especially interested in preserving commit history. If I rename and move branches around in SVN after the conversion, will the history be preserved?</blockquote> <p>Yes. Subversion also keeps track of changes to the directory structure, and all version history is preserved even if a file is moved in t...
<p>I am especially interested in preserving commit history. If I rename and move branches around in SVN after the conversion, will the history be preserved?</p>
3,513
<p>Obviously I can use BCP but here is the issue. If one of the records in a Batch have an invalid date I want to redirect that to a separate table/file/whatever, but keep the batch processing running. I don't think SSIS can be installed on the server which would have helped.</p>
<p>Create a trigger that processes on INSERT. This trigger will do a validation check on your date field. If it fails the validation, then do an insert into your separate table, and you can also choose to continue the insert or not allow it to go through.</p> <p>an <strong>important</strong> note: by default triggers ...
<p>You're saying there's a column full of dates in the file, and you want that data to go into a column of type "datetime" in a table in a SQL database? And it'll blow up if one of the values from the file isn't a valid date? I just wanted to make sure I understand this right.</p> <p>You could create another, temporar...
13,555
<p>This question is about using getter methods of a singleton object in worker threads. Here is some pseudo code first:</p> <pre><code>// Singleton class which contains data class MyData { static MyData* sMyData ; int mData1[1024]; int mData2[1024]; int mData3[1024]; MyData* getInstance() ...
<p>Provided that no other thread will try to write to the data in your singleton object, you don't need to protect them: by definition, multiple readers in the absence of a writer is thread-safe. This is a common pattern where the program's initialization code sets up a singleton, which is then only read from by worker...
<p>For thread safety you need to look at the class as a whole. As written your class would not be thread safe. Whilst your getValues method is okay, the getData1 method has problems.</p> <p>You say they are (read-only) getter methods. However, neither are declared as const methods. The getData1 would not be valid as a...
34,217
<p>I've seen questions about (like <a href="https://3dprinting.stackexchange.com/q/2670/11157">What is stopping us from mixing 3d filament colors in an Extruder?</a>) and some solutions for mixing filament colors/materials at print time for multi-color printing, but my question is different: Are there any (affordable) ...
<p>OK, it just turned up on Thingiverse that someone has demonstrated a trivial machine to do exactly what I asked for: any FDM printer.</p> <blockquote> <p>Its sounds crazy, but it works! This technique will allow you to create one offs, and to color match your 3D-prints.</p> <p>It works by changing the filament (and ...
<h2>Making your own filament</h2> <p>Theoretically, this could be done with any filament producing equipment by taking the two filaments and shredding them into pellets and feeding them to the machine in the right mix for the color you want. Industrial setups like a <a href="https://www.filabot.com/" rel="nofollow nore...
1,296
<p>Emacs has a useful <code>transpose-words</code> command which lets one exchange the word before the cursor with the word after the cursor, preserving punctuation.</p> <p>For example, ‘<code>stack |overflow</code>’ + M-t = ‘<code>overflow stack|</code>’ (‘<code>|</code>’ is the cursor position).</p> <p><code>&lt;a&...
<p>These are from my .vimrc and work well for me.</p> <pre><code>" swap two words :vnoremap &lt;C-X&gt; &lt;Esc&gt;`.``gvP``P " Swap word with next word nmap &lt;silent&gt; gw "_yiw:s/\(\%#\w\+\)\(\_W\+\)\(\w\+\)/\3\2\1/&lt;cr&gt;&lt;c-o&gt;&lt;c-l&gt; *N* </code></pre>
<p>You can use dwwP or dWwP as Mark and CapnNefarious have said, but I have a few notes of my own: </p> <ul> <li>If the cursor is on the first letter of the second word, as in the example you gave, you can use dwbP (or dWbP to handle punctuation);</li> <li>If the cursor is in the middle of the word, you can use dawbP/...
17,082
<p>I have a datagridview with a DataGridViewComboboxColumn column with 3 values:</p> <p>"Small", "Medium", "Large"</p> <p>I get back the users default which in this case is "Medium"</p> <p>I want to show a dropdown cell in the datagridview but default the value to "Medium". i would do this in a regular combobox by...
<p>When you get into the datagridview it is probably best to get into databinding. This will take care of all of the selected index stuff you are talking about.</p> <p>However, if you want to get in there by yourself, </p> <pre><code>DataGridView.Rows[rowindex].Cells[columnindex].Value </code></pre> <p>will let yo...
<p>Are you retrieving the user data and attempting to set values in the DataGridView manually, or have you actually bound the DataGridVew to a data source? Because if you've bound the grid to a data source, you should just need to set the DataPropertyName on the column to be the string name of the object Property:</p> ...
11,753
<p>I´m creating a PDA app and I need to upload/download a lot of small files and my idea is to gather them in an <strong>uncompressed zip file</strong>.</p> <p>The question is: It´s a good idea to <strong>read those files from the zip</strong> without separating them? How can I do so? Or is it <strong>better to unzip ...
<p>Since there are two different Open-source libraries (<a href="http://icsharpcode.com/OpenSource/SharpZipLib/Default.aspx" rel="nofollow noreferrer">SharpZipLib</a> and <a href="http://www.codeplex.com/DotNetZip" rel="nofollow noreferrer">DotNetZip Library</a>) to handle writing &amp; extracting files from a zip fil...
<p>Sounds as if you want to use the archive to group your files.</p> <p>From a <em>reading the files</em> point of view, it makes very little difference if the files are handled one way or the other. You would need to implement the ability to read zip files, though. Even if you use a lib like James Curran suggested, i...
33,288
<p>I'm using <strong>DotNetNuke</strong>, so the whole site is basically dynamically driven and I'm clueless to how to go about creating a Google sitemap for it. </p> <p>Any help will be greatly appreciated.</p>
<p>Jeff Atwood has some good information on SiteMaps <a href="http://www.codinghorror.com/blog/archives/001174.html" rel="nofollow noreferrer">here</a>. You can also see more information on SiteMap formats <a href="http://sitemaps.org/protocol.php" rel="nofollow noreferrer">here</a>.</p>
<p>Thanks for the answers. I've found a great sitemap generator over at codeplex. If anyone is interested you can check it out here: <a href="http://www.codeplex.com/sitemapgenerator" rel="nofollow noreferrer">http://www.codeplex.com/sitemapgenerator</a></p> <p>Enjoy!</p>
27,023
<p>I have a table containing prices for a lot of different "things" in a MS SQL 2005 table. There are hundreds of records per thing per day and the different things gets price updates at different times.</p> <pre><code>ID uniqueidentifier not null, ThingID int NOT NULL, PriceDateTime datetime NOT NULL, Price decimal(1...
<p>I think the only solution with your table structure is to work with a subquery:</p> <pre><code>SELECT * FROM Thing WHERE ID IN (SELECT max(ID) FROM Thing WHERE ThingID IN (1,2,3,4) GROUP BY ThingID) </code></pre> <p>(Given the highest ID also means the newest price)</p>...
<p>maybe i missunderstood the taks but what about a: </p> <p><code>SELECT ID, ThingID, max(PriceDateTime), Price FROM Thing GROUP BY ThingID</code></p>
7,195
<p>Greetings. I have been looking at Literate Programming a bit now, and I do like the idea behind it: you basically write a little paper about your code and write down as much of the design decisions, the code probably surrounding the module, the inner workins of the module, assumptions and conclusions resulting from ...
<p>Excellent question. The motivation for literate programming will never go away, but I think it should be treated as fluid. It means "give the reader a break, and educate them to what you're trying to do". I don't think it means "make your code really wordy".</p> <p>That said, the reader will have to put some effort...
<p>Literate Programming was developed in an era where long variable and function names were simply not possible. Because of this, code really wasn't that readable.</p> <p>Obviously, a lot has happened since then. </p> <p>In today's world, the code itself is the documentation, hence the term "self documenting code."...
38,294
<p>I have to maintain a large number of classic ASP pages, many of which have tabular data with no sort capabilities at all. Whatever order the original developer used in the database query is what you're stuck with.</p> <p>I want to to tack on some basic sorting to a bunch of these pages, and I'm doing it all client s...
<p>There's &#9650;: <a href="http://www.fileformat.info/info/unicode/char/25b2/index.htm" rel="noreferrer">&amp;#9650;</a> and &#9660;: <a href="http://www.fileformat.info/info/unicode/char/25bc/index.htm" rel="noreferrer">&amp;#9660;</a></p>
<p>Could you just draw an svg path inside of a span using document.write? The span isn't required for the svg to work, it just ensures that the svg remains inline with whatever text the carat is next to. I used margin-bottom to vertically center it with the text, there might be another way to do that though. This is wh...
43,969
<p>Suppose I want to implement a reasonably efficient 'keyword recognition algorithm', that is first given a list of keyword, and must then answer if another given word was in the list. </p> <p>In an imperative language, I would store the keywords in a tree (one node per character). Then, when receiving a word to test...
<p>I think what you mean is a character per node... sort of like a simple hash tree scheme for keyword lookup. Assuming this or even another kind of tree... imagine doing something like this (in pseudo-LISP):</p> <pre><code>(defun buildtree (wordlist) ...code to build tree recursively returns the tree...) (define loo...
<p>I imagine you'd want something like a tree with a list of children, as described <a href="http://csus.cs.mcgill.ca/wiki/COMP-302_(Panangaden%2C_Pientka%2C_Winter_06)_Lectures#Trees_with_a_list_of_children" rel="nofollow noreferrer">here</a>.</p>
6,911
<p>I'm afraid my trial of VS 2008 is running out soon, and unless a client pays for it, I might be shelling out some cash for it. I've been looking through the <a href="http://msdn.microsoft.com/en-us/vs2008/products/cc149003.aspx" rel="nofollow noreferrer">comparison chart</a> to compare VS Professional to Standard, ...
<p>Developing Windows Mobile Applications and availability of Database Projects are the showstoppers for me (this applies to Visual Studio 2008).</p> <p>That's it really. This was a dealbreaker for me though since I wanted to join this mobile application programming contest and was floored when I found out I couldn't ...
<p>Very little difference between the two. The only one I can think of is remote debugging is not available in standard.</p>
12,447
<p>For example I have such query:</p> <pre><code>Query q = sess.createQuery("from Cat cat"); List cats = q.list(); </code></pre> <p>If I try to make something like this it shows the following warning </p> <pre><code>Type safety: The expression of type List needs unchecked conversion to conform to List&lt;Cat&gt; L...
<p>Using <code>@SuppressWarnings</code> everywhere, as suggested, is a good way to do it, though it does involve a bit of finger typing each time you call <code>q.list()</code>.</p> <p>There are two other techniques I'd suggest:</p> <p><strong>Write a cast-helper</strong></p> <p>Simply refactor all your <code>@Suppr...
<p>If you don't want to use @SuppressWarnings("unchecked") you can do the following.</p> <pre><code> Query q = sess.createQuery("from Cat cat"); List&lt;?&gt; results =(List&lt;?&gt;) q.list(); List&lt;Cat&gt; cats = new ArrayList&lt;Cat&gt;(); for(Object result:results) { Cat cat = (Cat) result; ...
14,103
<p>In the Visual Studio toolbar, you can enter commands into the search box by prefixing them with a > symbol. Is there any way to disable this? I've never used the feature, and it's slightly annoying when trying to actually search for something that you know is prefixed by greater-than in the code. It's particularly a...
<p>This is a really cool feature. I've poked through the <a href="http://msdn.microsoft.com/en-us/library/1665hyw1(VS.80).aspx" rel="nofollow noreferrer">feature documentation</a>, and the accompanying <a href="http://msdn.microsoft.com/en-us/library/c338aexd(VS.80).aspx" rel="nofollow noreferrer">command list</a>, and...
<blockquote> <p>Wow, I didn't know that. Where do I find the list of possible commands?</p> </blockquote> <p>The commands are the same as those you can enter in the command window, so you can pretty much drive the entire IDE and debugger using it. There are a load of predefined aliases for common commands. Open up...
3,555
<p>Is there a website/list of problems which can be used to practice OOP design skills? Let's say if I am a colleague graduate familiar with object-oriented-design theory, these problems should give me a chance to exercise the theory and improve my software design skills. </p>
<p>If you're wanting to try out a new methodology or something, try making a small application just for you, or perhaps for internal use only. eg: A timesheet application, a task manager, a grocery list organiser, etc. Make sure it's a <em>real</em> problem, so you're forced to deal with <em>real</em> requirements. I'v...
<p><a href="http://codekata.pragprog.com/" rel="nofollow noreferrer">CodeKata</a> is a place to start.</p> <p>It's not a web site, but Head First Design Patterns has a multitude of problems to solve. </p>
21,964
<p>I've got a class named <code>BackgroundWorker</code> that has a thread constantly running. To turn this thread off, an instance variable named <code>stop</code> to needs to be <code>true</code>. </p> <p>To make sure the thread is freed when the class is done being used, I've added <code>IDisposable</code> and a fin...
<p>First off, a <strong>severe warning</strong>. Don't use a finalizer like you are. You are setting yourself up for some very bad effects if you take locks within a finalizer. Short story is don't do it. Now to the original question.</p> <pre><code>public void Dispose() { Dispose(true); GC.SuppressFinaliz...
<p>Is the "stop" instance variable a property? If not, there's no particular point in setting it during the finalizer - nothing is referencing the object anymore, so nothing can query the member.</p> <p>If you're actually releasing a resource, then having Dispose() and the finalizer perform the same work (first testi...
18,204
<p>Most languages (Ruby included) allow number literals to be written in at least three bases: decimal, octal and hexadecimal. Numbers in decimal base is the usual thing and are written as (most) people naturally write numbers, 96 is written as <code>96</code>. Numbers prefixed by a zero are usually interpreted as octa...
<p>use 0b prefix</p> <pre><code>&gt;&gt; 0b100 =&gt; 4 </code></pre>
<p>From <a href="http://docs.huihoo.com/ruby/ruby-man-1.4/syntax.html#numeric" rel="noreferrer">this manual</a></p> <pre><code>0b01011 </code></pre> <p>binary integer </p>
12,694
<p>Basically what the title says...</p> <p>I need to have an image that when clicked, I call script.php for instance and in that PHP script file, I get the image coordinates where the mouse was clicked.</p> <p>Is this possible?</p> <p><strong>EDIT:</strong><br /> After a couple of answers I realized I didn't describ...
<p>If you can't:</p> <ol> <li>use JavaScript, or</li> <li>use input type="image", or</li> <li>add any attributes to your img tag (to do things like create an image map)</li> </ol> <p>then, no, you won't be able to do what you describe.</p>
<p>You can use an ajax request when "onclick" is performed to send a request to "script.php". Otherwise I would read up on php, which is a server-side language.</p>
46,735
<p>I am working on a geometry problem that requires finding the intersection of two parabolic arcs in any rotation. I was able to intesect a line and a parabolic arc by rotating the plane to align the arc with an axis, but two parabolas cannot both align with an axis. I am working on deriving the formulas, but I woul...
<p>I'd first define the equation for the parabolic arc in 2D without rotations:</p> <pre><code> x(t) = ax² + bx + c y(t) = t; </code></pre> <p>You can now apply the rotation by building a rotation matrix:</p> <pre><code> s = sin(angle) c = cos(angle) matrix = | c -s | | s c | </code></pre> <p>A...
<p>Unfortunately, the general answer requires solution of a fourth-order polynomial. If we transform coordinates so one of the two parabolas is in the standard form y=x^2, then the second parabola satisfies (ax+by)^2+cx+dy+e==0. To find the intersection, solve both simultaneously. Substituting in y=x^2 we see that the ...
15,768
<p>What options do I have to publish Flash video from webcams other than Adobe's Flash Media Server and Red5? I would prefer a solution in .NET, Python or PHP but can't find anything.</p>
<p>Besides another commercial product, like <a href="http://www.wowzamedia.com/" rel="nofollow noreferrer">Wowza Media Server</a>, you could go with a CDN (Content Delivery Network), like <a href="http://www.limelightnetworks.com/" rel="nofollow noreferrer">Limelight Networks</a> or <a href="http://www.voxel.net/" rel=...
<p>It looks like WebOrb can do it: <a href="http://www.themidnightcoders.com/weborb/dotnet/faq.shtm" rel="nofollow noreferrer">WebOrb FAQ</a> (last entry)</p> <blockquote> <p>Can I stream Flash video to a Flex/Flash client through WebORB? Yes, WebORB supports FLV video streaming. An example is included with the We...
6,581
<p>I've been asked to write code/design things in an interview. Sometimes even to provide code samples. Very reasonable and very wise (always surprised when this DOESN'T happen)</p> <p>I had a job a year or so back where the code was so awful that I would not have taken the job, if I'd seen the mess I had to deal wi...
<p>You can definitely ask. The answer may be "No," but nobody should consider that to be a bad or inappropriate question.</p> <p>If they won't show you the code, you should definitely take that into account when you decide whether you want to accept an offer. I would take it as a sign that at least one of the follow...
<p>I think this is a great idea; however, as an employer, I would be hesitant -- even with an NDA -- to provide an interview candidate samples of real, working code unless I was pretty sure I wanted to hire the person.</p>
19,649
<p>In a Flex / Java app stack using remoting (via BlazeDS), classes to hold data passed back and forth between client and server need to be maintained in both the client (in ActionScript) and server (in Java).</p> <p>I want a way to maintain theses classes in Java only, and have the corresponding ActionScript value ob...
<p>Check out the AS3 generator from the Granite Data Services project:</p> <p><a href="http://www.graniteds.org" rel="nofollow noreferrer">http://www.graniteds.org</a></p> <p>If I recall correctly it's an Eclipse plugin which should be quite easy to use. Just remember that if you exclude a property from the ActionSc...
<p><a href="http://xdoclet.codehaus.org/" rel="nofollow noreferrer">XDoclet2</a> includes an ActionScript plugin that can generate ActionScript classes from Javadoc comments in Java code.</p> <p>The downside is that it's based on Javadoc rather than Java annotations, and does not appear to be well-documented or very w...
27,428
<p>Is there anyone already implement memcached for production use in Windows environment? Because many blogs that I've read, it's not recommended to run memcached in Windows especially for production use, for example <a href="http://latebound.blogspot.com/2008/10/running-memcached-on-windows.html" rel="noreferrer">runn...
<p>Why do you need to run memcached on windows? It’s an expensive affair in a production environment. </p> <p>If your code needs to run in a Windows environment get a windows memcached client and talk to a *nix based memcached machine. </p> <p>In a production environment running memcached on Server 2003 or 2008 w...
<p>If you're interested in running a memcached client on Windows then there are two additional open source servers that can do the job. Both implement the standard memcached server protocol and are written in Java so they run on Windows. </p> <ul> <li><a href="http://code.google.com/p/jmemcache-daemon/" rel="nofollo...
45,786
<p>I'll go first.</p> <p>I'm 100% in the set-operations camp. But what happens when the set logic on the entire desired input domain leads to a such a large retrieval that the query slows down significantly, comes to a crawl, or basically takes infinite time?</p> <p>That's one case where I'll use a itty-bitty cursor...
<p>Sure, there are a number of places where cursors might be better than set-based operations.</p> <p>One is if you're updating a lot of data in a table (for example a SQL Agent job to pre-compute data on a schedule) then you might use cursors to do it in multiple small sets rather than one large one to reduce the amo...
<p>Well one operation where cursors are better than sets is when calculating a running total and similar stuff.</p>
20,789
<p>I want to write a program for this: In a folder I have <em>n</em> number of files; first read one file and perform some operation then store result in a separate file. Then read 2nd file, perform operation again and save result in new 2nd file. Do the same procedure for <em>n</em> number of files. The program reads ...
<pre><code>import sys # argv is your commandline arguments, argv[0] is your program name, so skip it for n in sys.argv[1:]: print(n) #print out the filename we are currently processing input = open(n, "r") output = open(n + ".out", "w") # do some processing input.close() output.close() </code><...
<p>This thing also works for reading multiple files, my file name is <code>fedaralist_1.txt</code> and <code>federalist_2.txt</code> and like this, I have 84 files till <code>fedaralist_84.txt</code></p> <p>And I'm reading the files as f.</p> <pre class="lang-py prettyprint-override"><code>for file in filename: ...
25,528
<p>I have a winforms application that normally is at about 2-4% CPU. We are seeing some spikes up to 27% of CPU for limited number of times. What is the best profiling tool to determine what is actually causing this spike. We use dottrace but i dont see how to map that to exactly the CPU spikes?</p> <p>Appreciate t...
<p>I've used 2 profiling tools before - RedGate's ANTS profiler, and the built in profiler found in Visual Studio Team System.</p> <p>It's been some time since I used RedGate's (<a href="http://www.red-gate.com/products/ants_profiler/index.htm" rel="nofollow noreferrer">http://www.red-gate.com/products/ants_profiler/i...
<p>I’ve found DevPartner from Compuware <a href="http://www.compuware.com/" rel="nofollow noreferrer">http://www.compuware.com/</a> to be an excellent profiling tool. Unfortunately it looks like at the present time they don’t support VS 2008.</p>
13,040
<p>I'm trying to get a user control working asynchronously, yet no matter what I do it continues to work synchronously. I've stripped it down to its bare minimum as a test web application. This would be the user control:</p> <pre><code>&lt;%@ Control Language="C#" %&gt; &lt;script runat="server"&gt; SqlConnection ...
<p>Looks like I can answer my own question. The user control should not be calling <code>Page.ExecuteRegisteredAsyncTasks</code>. By doing that, the control was adding the async task, running it, and waiting for it to complete.</p> <p>Instead, each instance of the user control should call only <code>Page.RegisterAsync...
<p>If I may add a little to the above post, we should not call the <code>ExecuteRegisteredAsyncTassk</code> explicitly unless there is a compelling reason. once you register the async task, the ASP.NET framework will execute all these tasks right after the <code>OnPrerender</code> event of the page lifecycle.</p> <p>A...
34,465
<p>We're having problem with a huge number of legacy stored procedures at work. Do you guys recommend any tool the can help better understand those procedures? Some kind of reverse engineering that indentifies inter-procedure dependencies and/or procedure vs. tables dependencies. Can be a free or commercial tool.</p> ...
<p>Redgate has a rather expensive product called <a href="http://www.red-gate.com/products/SQL_Dependency_Tracker/" rel="nofollow noreferrer">SQL Dependency Tracker</a> that seems to fulfill the requirements.</p>
<p>The single best tool for reverse engineering is by APEX. Its amazing. It can even trace into .NET assemblies and tell you where the procs are used. Its by far the deepest product of its kind. RedGate has great other tools but not in this case. </p>
9,533
<p>Is there an IE6/PNG fix that is officially developed by the jQuery team?</p> <p>If not which of the available plugins should I use?</p>
<p>I'm using <a href="http://jquery.andreaseberhard.de/pngFix/" rel="nofollow noreferrer">jquery.pngFix.js</a>. I don't know if it's officially sanctioned or not, I do know that it works. I chose it because it was the plugin included with FancyBox, no other reason. </p>
<p>Hey guys, just wanted to toss this one in. I was digging around for it again and it has one specific advantage over the rest: repeatable backgrounds, as well as background-position (the one thats flagged as the best answer here actually just scales the background image). </p> <p><a href="http://www.dillerdesign.co...
8,572
<p>I've just started writing unit tests for a legacy code module with large physical dependencies using the #include directive. I've been dealing with them a few ways that felt overly tedious (providing empty headers to break long #include dependency lists, and using #define to prevent classes from being compiled) and ...
<p>The depression in the responses is overwhelming... But don't fear, we've got <a href="https://rads.stackoverflow.com/amzn/click/com/0131177052" rel="noreferrer" rel="nofollow noreferrer">the holy book to exorcise the demons of legacy C++ code</a>. Seriously just buy the book if you are in line for more than a week o...
<p>If you keep writing stubs/mock/fake codes you risk doing unit testing on a class that has different behavior then when compiled on the main project.</p> <p>But if those includes are there and have no added behavior then it's Ok.</p> <p>I'd try not changing anything on the includes while doing the unit testing so y...
9,080
<p>How do I properly represent a different timezone in my timezone? The below example only works because I know that EDT is one hour ahead of me, so I can uncomment the subtraction of myTimeZone()</p> <pre><code>import datetime, re from datetime import tzinfo class myTimeZone(tzinfo): """docstring for myTimeZone"...
<p>I recommend <code>babel</code> and <code>pytz</code> when working with timezones. Keep your internal datetime objects naive and in UTC and convert to your timezone for formatting only. The reason why you probably want naive objects (objects without timezone information) is that many libraries and database adapters...
<h2>Python &gt;= 3.9</h2> <p>Python comes with <a href="https://docs.python.org/3/library/zoneinfo.html" rel="nofollow noreferrer">zoneinfo</a> as part of the standard lib. Example usage:</p> <pre><code>from datetime import datetime, timezone from zoneinfo import ZoneInfo UTC = datetime(2012,11,10,9,0,0, tzinfo=timezon...
14,316
<p>After creating a translucent window (<a href="http://stormsilver.net/itunescheck/browser/tags/0.91/TransparentWindow.m?rev=25" rel="noreferrer">based on example code by Matt Gemmell</a>) I want to get keyboard events in this window. It seems that there are only keyboard events when my application is the active appl...
<p>There are two options:</p> <ol> <li>Use <a href="http://developer.apple.com/documentation/Carbon/Reference/Carbon_Event_Manager_Ref/Reference/reference.html#//apple_ref/c/func/GetEventMonitorTarget" rel="nofollow noreferrer"><code>GetEventMonitorTarget()</code></a> with a tacked-on Carbon run loop to grab keyboard ...
<p>Update:<br> Apple actually seems to have changed everything again starting with 10.5 BTW (I recently upgraded and my sample code did not work as before).</p> <p>Now you can indeed only capture keydown events setting up an event tap if you are either root or assistive devices are enabled, regardless on which level y...
41,951
<p>Maybe this is a dumb question, but is there any way to convert a boolean value to a string such that 1 turns to "true" and 0 turns to "false"? I could just use an if statement, but it would be nice to know if there is a way to do that with the language or standard libraries. Plus, I'm a pedant. :)</p>
<p>How about using the C++ language itself?</p> <pre><code>bool t = true; bool f = false; std::cout &lt;&lt; std::noboolalpha &lt;&lt; t &lt;&lt; " == " &lt;&lt; std::boolalpha &lt;&lt; t &lt;&lt; std::endl; std::cout &lt;&lt; std::noboolalpha &lt;&lt; f &lt;&lt; " == " &lt;&lt; std::boolalpha &lt;&lt; f &lt;&...
<p>I agree that a macro might be the best fit. I just whipped up a test case (believe me I'm no good with C/C++ but this sounded fun):</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;stdarg.h&gt; #define BOOL_STR(b) (b?"true":"false") int main (int argc, char const *argv[]) { bool alpha = true; printf(...
4,903
<p>I'm looking at a new project and we are wanting to use Flex (to provide the easy integration with AIR and provide a desktop app for our project). How easy does CakePHP play with Flex or is there a better PHP framework to use with Flex, or should we use none?</p>
<p>If LINQ is in your toolbox, I would highly recommend using that to read/write xml as opposed to a DataTable. It's much more fluent and intuitive and you can control where the nodes go... wherever you add them to the collection is where they appear in the resulting XML.</p> <p>Here's a quick intro and there's a me...
<p>Your best option if you want a quick and dirty way is to load the users information into the dataset, call the "WriteXml" method to save and use "ReadXml" to pull it back in. The XML format that the DataSet uses on its own will come in and out in the same format.</p> <p>You also have many other options, but the Da...
29,548
<p>I need to add a paging, sortable table to my GWT application.</p> <p>I see lots of these out there so I'm looking for your experience to save me time by choosing the best one.</p> <p>So far I'm looking at...</p> <p><a href="http://code.google.com/p/gwt-advanced-table/" rel="noreferrer">http://code.google.com/p/gw...
<p>There's a new CellTable that has support for paging. It's in the GWT trunk right now and will, with any luck, make it into a 2.1 release later this year.</p>
<p>It's already been answered <a href="https://stackoverflow.com/questions/231407/gwt-paging-widget">here</a></p> <p>And unfortunately there is no satisfying implementation available. The best approach i have found has the <a href="http://gwt-widget.sourceforge.net/" rel="nofollow noreferrer">GWT widget library</a>. I...
43,536
<p>Is it possible to prevent the browser from following redirects when sending XMLHttpRequest-s (i.e. to get the redirect status code back and handle it myself)?</p>
<p>Not according to <a href="http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#infrastructure-for-the-send%28%29-method" rel="noreferrer">the W3C standard for the XMLHttpRequest object</a> (emphasis added):</p> <blockquote> <p>If the response is an HTTP redirect:</p> <blockquote> <p>If the origin of the ...
<p>It is not possible to handle redirect or 302 status at client side as answered in other comments. However you can prevent redirection. To do that you can set request header &quot;X-Requested-With&quot; with &quot;XMLHttpRequest&quot; xhttp.setRequestHeader(&quot;X-Requested-With&quot;, &quot;XMLHttpRequest&quot;); T...
28,246
<p>Feel free to edit the title if you know how to formulate the question better. (Tagging is a problem as well.) The problem may be too difficult in this general form, so let us consider a concrete example.</p> <p>You get a screenful of stackoverflow questions by requesting <code>/questions ?sort=newest</code> page. N...
<p>This can't be done an easy way. For instance, the "Unanswered" list here at stackoverflow is sorted by number of votes. So if you'd save the last ID of the page you're viewing (in a cookie, request, session, whereever) and someone upvotes a post while you're browsing page 2, page 3 isn't complete since the recently ...
<p>Most web sites I've seen don't solve this problem - they show you a page including some content you've already seen.</p> <p>You might consider that a feature - when you click "next" and see some content you're seen before, it's a signal that you want to go back to the front again because there's some new content.</...
5,963
<p>I read somewhere in the Microsoft documentation that the content of the ASP.NET's <strong>web.config is cached</strong>. If that is true, <strong>where</strong> is it cached - in <strong>memory or on disk</strong>?</p> <p>And a follow-up question: are there any performance considerations I have to make, if I have t...
<p>Its cached in memory, caching on disk doesn't make any sense, its already on disk.</p> <p>First of all in ASP.NET you want to ensure you access configuration sections through the HttpContext object's <code>GetSection</code> method (this uses the cached copies managed by ASP.NET).</p> <p>Performance of accessing co...
<p>My advice would be to use it just like anyother variable for the simple reason that data is cached. An if you create static variables in global.asax you are forcing yourself to write more code. No matter how planned you are, it is highly likely that you add variables in appconfig frequently during the development st...
34,617
<p>We have a rather simple site (minimal JS) with plain html and CSS. It is a simple mobile interface for our main application.</p> <p>We are running into trouble because we have more than one column and several browsers seem to force single columns.</p> <p>Through some searching I ran into 2 meta tags.</p> <pre><c...
<p>I wouldn't bother making a "medium" version for the iPhone etc, iPhone users can just look at your real web page easily enough. Have your full version and a single column version, and you'll reach the largest audience with minimal work.</p> <p>To answer your question though, there's no good way to make the Blackber...
<p>BlackBerry (from OS 4.6 and higher) supports both the meta-viewport tag as well as the meta-HandheldFriendly tag. See the "Content Design Guidelines" document at <a href="http://na.blackberry.com/eng/support/docs/subcategories/?userType=21&amp;category=BlackBerry+Browser" rel="nofollow noreferrer">http://na.blackber...
13,259
<p>When trying to invoke a method on an external webservice (over the Internet) it throws me "The remote server returned an error: (407) Proxy Authentication Required."</p> <p>To solve this, I used the following code to set the proxy we use in the office:</p> <pre><code>//Set the system proxy with valid server addres...
<p>This will use whatever the default proxy is for IE I believe (not deprecated):</p> <pre><code>Services.MyService service = new Services.MyService(); service.UseDefaultCredentials = true; service.Proxy = new System.Net.WebProxy(); service.Proxy.Credentials = service.Credentials; </code></pre>
<p>System.Net.WebProxy.GetDefaultProxy() although VS cautions its been deprecated.</p>
36,099
<p>I have a lot of changes in a working folder, and something screwed up trying to do an update.</p> <p>Now when I issue an 'svn cleanup' I get:</p> <pre><code>&gt;svn cleanup . svn: In directory '.' svn: Error processing command 'modify-wcprop' in '.' svn: 'MemPoolTests.cpp' is not under version control </code></pre...
<p>When starting all over is not an option...</p> <p>I deleted the log file in the <code>.svn</code> directory (I also deleted the offending file in <code>.svn/props-base</code>), did a cleanup, and resumed my update.</p>
<p>It might not apply in all situations, but when I recently encountered this problem my "fix" was to upgrade the Subversion package on my system. I had been running 1.4.something, and when I upgraded to the latest (1.6.6 in my case) the checkout worked.</p> <p>(I did try re-downloading it, but a checkout to a clean d...
19,191
<p>What techniques are available to profile services running in WebMethods Integration Server?</p> <p>That is, to obtain data which would indicate which parts would benefit most from optimisation.</p>
<p>Check the 'Service Profiler for webMethods Integration Server' from <a href="http://www.wrightia.com/serviceprofiler.html" rel="nofollow noreferrer">http://www.wrightia.com/serviceprofiler.html</a> </p>
<p>I was involved only in development phase so i dont know details but our system was tested with heavy load-testing and hardware was monitored during the process, it actually gave some feedback about bottlenecks. JMeter and sar were used.</p>
26,617
<p>I need to output some JavaScript in a WebControl based on some processing and some properties that the consumer can set, doing it on the load of the page will be to early.</p> <p>When is the latest I can call RegisterClientScriptBlock and still have it output on the page?</p>
<p>OnPreRender</p> <p>or, if you override Render.... before calling "base.Render"</p>
<p>Logically, your startup script needs to be rendered as well as registered on the page, so the Page_PreRender event would seem to be a good bet. After that the HTML and Script for the page is 'locked'.</p>
31,570
<p>I need to export a SL DataGrid to HTML so my users can then print it. Can someone put me in the right direction?</p> <p>Upate: After reading Rob's answer I am changing my question. Instead of Silverlight Grid to HTML, I now just want to export it to PDF. Has anyone used any 3rd party PDF generators with Silverlight...
<p>I did this and it seems to work:</p> <p>Handle the <code>SelectedIndexChanged</code> for the <code>tabControl</code>. Check if <code>tabControl1.SelectedIndex</code> == the one I want and call <code>textBox.Focus();</code></p> <p>I'm using VS 2008, BTW.</p> <hr> <p>Something like this worked:</p> <pre><code>pr...
<p>Try the TabPage.Enter something like</p> <pre> private void tabPage1_Enter(object sender, EventArgs e) { TabPage page = (TabPage)sender; switch (page.TabIndex) { case 0: textBox1.Text = "Page 1"; if (!textBox...
21,644
<p>I'm storing an object (<code>TTF_Font</code>) in a <code>shared_ptr</code> that is provided to me from a third-party API. I cannot use new or delete on the object, so the <code>shared_ptr</code> is also provided a "freeing" functor.</p> <pre><code>// Functor struct CloseFont { void operator()(TTF_Font* font) co...
<p>shared_ptr&lt;>::reset() will drop the refcount by one. If that results in the count dropping to zero, the resource pointed to by the shared_ptr&lt;> will be freed.</p> <p>So I think the answer for you is, yes that will work. Or you can simply let the screenFont variable be destructed due to dropping out of scope...
<p>Mike B's answered your question, so I'll just comment on your code. If <code>TTF_OpenFont</code> doesn't return null, or if <code>TTF_CloseFont</code> can handle nulls harmlessly, you don't need a <code>CloseFont</code> class at all, just use <code>&amp;TTF_CloseFont</code>.</p>
18,917
<p>I'd like to periodically run an arbitrary .NET exe under a specified user account from a Windows Service. </p> <p>So far I've got my windows service running with logic to decide what the target process is, and when to run it. The target process is started in the following manner:</p> <ol> <li>The Windows Service i...
<p>I seem to have a working implementation (Works On My Machine(TM)) for the following scenarios:</p> <p>Batch File, .NET Console Assembly, .NET Windows Forms application.</p> <p>Here's how:</p> <p>I have a windows service running as the Administrator user. I add the following policies to the Administrator user:</p>...
<p>You do not need a window handle to use CreateProcessWithLogonW, I'm not sure where your information came from.</p> <p>The application failed to initialize error has many causes, but it is almost always related to security or exhausted user resources. It is extremely difficult to diagnose this without a lot more inf...
47,297
<p>I wondered if anyone can give an example of a professional use of RSS/Atom feeds in a company product. Does anyone use feeds for other things than updating news?</p> <p>For example, did you create a product that gives results as RSS/Atom feeds? Like price listings or current inventory, or maybe dates of training le...
<p>Some of my team's new systems generate RSS feeds that the developers syndicate. These feeds push out events that interest the developers at certain times and the information is controlled using different loggers. Thus when debugging you can get the debugging feed, when you want to see completed transactions you go t...
<p>I have seen RSS used to syndicate gas prices from a service for a specific zip code.</p>
3,691
<p>I'm interested in tracing database calls made by LINQ to SQL back to the .NET code that generated the call. For instance, a DBA might have a concern that a particular cached execution plan is doing poorly. If for example a DBA were to tell a developer to address the following code...</p> <pre><code>exec sp_executes...
<p>These are my favorite shortcuts:</p> <ul> <li><kbd>cmd</kbd>+<kbd>t</kbd> Start typing name of a file to open it</li> <li><kbd>ctrl</kbd>+<kbd>w</kbd> Select word</li> <li><kbd>cmd</kbd>+<kbd>r</kbd> Run the ruby or php-script that is open</li> <li><kbd>cmd</kbd>+<kbd>opt</kbd>+<kbd>m</kbd> Define a new macro</li> ...
<p>(these are mostly html-related) </p> <ul> <li><kbd>cmd</kbd> + <kbd>option</kbd> <kbd>+</kbd> closes current open html tag </li> <li><kbd>shift</kbd> + <kbd>cmd</kbd> + <kbd>w</kbd> wrap selection in tags</li> <li><kbd>ctrl</kbd> + <kbd>return</kbd> insert escaped line end, i.e. <code>\n</code> or <code>&lt;br&gt...
12,504
<blockquote> <pre><code>List&lt;tinyClass&gt; ids = new List&lt;tinyClass(); ids.Add(new tinyClass(1, 2)); bool b = ids.IndexOf(new tinyClass(1, 2)) &gt;= 0; //true or false? </code></pre> </blockquote> <p>If it compares by value, it should return true; if by reference, it will return false.<br> If it compares by ref...
<p>From MSDN:</p> <blockquote> <p>This method determines equality using the default equality comparer EqualityComparer&lt;T&gt;.Default for T, the type of values in the list.</p> <p>The Default property checks whether type T implements the System.IEquatable&lt;T&gt; generic interface and if so returns an EqualityCompar...
<p>Be sure to implement .Equals(..) for your struct, as the default implementation may use reflection to compare each field, which is very expensive. </p> <p>Read more at: <a href="http://blogs.microsoft.co.il/blogs/sasha/archive/2007/08.aspx" rel="nofollow noreferrer">http://blogs.microsoft.co.il/blogs/sasha/archive/...
21,197
<p>I'm terrible with regex, but I've had a try and a Google (and even looked in reddit's source) and I'm still stuck so here goes:</p> <p>My aim is to match the following 'codes' and replace them with the HTML tags. It's just the regex I'm stuck with.</p> <pre><code>**bold text** _italic text_ ~hyperlink~ </code></pr...
<p>use:</p> <pre><code>\*\*(.[^*]*)\*\* </code></pre> <p>explanation:</p> <pre><code>\*\* // match two *'s (. // match any character [^*] // that is not a * *) // continuation of any character \*\* // match two *'s </code></pre> <p>in a character class "[ ]" "^" is only significant if i...
<pre><code>\*\*(.*?)\*\* </code></pre> <p>that will work for the <strong>bold text</strong>.</p> <p>just replace the ** with _ or ~ for the others</p>
39,011
<p>I know there is a Jackpot API <a href="http://jackpot.netbeans.org/docs/org-netbeans-modules-jackpot/overview-summary.html" rel="nofollow noreferrer">http://jackpot.netbeans.org/docs/org-netbeans-modules-jackpot/overview-summary.html</a> for programmatic access the the rules engine, has anyone had success seperating...
<p>It is impossible to prove anything without building upon guarentees, so the first thing you want to do is to get familiar with the memory model of your target platform; Java and x86 both have solid and standardized memory models - I'm not so sure about CLR, but if all else fails, you'll have build upon the memory mo...
<p>@Just in case: I is. But from what i learnt, doing so for a non trivial algorithm is a major pain. I leave that sort of a thing for brainier people. I learnt what i know from Parallel Program Design: A Foundation (1988) by K M Chandy, J Misra </p>
10,004
<p>I'm experimenting with an updated build system at work; currently, I'm trying to find a good way to set compiler &amp; flags depending on the target platform. </p> <p>What I would like to do is something like</p> <pre><code>switch $(PLATFORM)_$(BUILD_TYPE) case "Linux_x86_release" CFLAGS = -O3 case "Linux...
<p>How about:</p> <pre><code>CFLAGS_Linux_x86_release = -O3 CFLAGS_Linux_x86_debug = -O0 -g CFLAGS = ${CFLAGS_${PLATFORM}_${BUILD}} </code></pre>
<p>Switching to a system which does it for you (automake/autoconf) may be simpler...</p>
24,413
<p>I know there is a list-comprehension library for common lisp (<a href="http://superadditive.com/projects/incf-cl/" rel="noreferrer">incf-cl</a>), I know they're supported natively in various other functional (and some non-functional) languages (F#, Erlang, Haskell and C#) - is there a list comprehension library for ...
<ul> <li><a href="http://docs.plt-scheme.org/swindle/index.html" rel="noreferrer">Swindle</a> is primarily a CLOS emulator library, but it has list comprehensions too. I've used them, they're convenient, but the version I used was buggy and incomplete. (I just needed generic functions.)</li> <li>However, you probably w...
<p>You can use <a href="https://ironscheme.svn.codeplex.com/svn/IronScheme/IronSchemeConsole/ironscheme/linq.ss" rel="nofollow noreferrer">LINQ for R6RS Scheme</a> (although it could be made to run under 'older' implementations).</p>
15,911
<p>I would like a constraint on a SQL Server 2000 table column that is sort of a combination of a foreign key and a check constraint. The value of my column must exist in the other table, but I am only concerned with values in the other table where one of its columns equal a specified value. The simplified tables are...
<p>You can also do it this way:</p> <pre><code>select columnproperty(object_id('mytable'),'mycolumn','IsIdentity') </code></pre> <p>Returns 1 if it's an identity, 0 if not.</p>
<p>As expansion on @Blogbeard's answer</p> <p>If you like pure query and not inbuilt functions</p> <pre><code>select col_name(sys.all_objects.object_id, column_id) as id from sys.identity_columns join sys.all_objects on sys.identity_columns.object_id = sys.all_objects.object_id where sys.all_objects.name = 'system_f...
22,921
<p>In my Application_Start() method, how can I stop the execution of the ASP.NET application when certain conditions are not met?</p> <p>Throwing an exception doesn't appear to work.</p>
<p>i don't think that's possible; even if you could 'abort' the startup, the next attempt to access a URL from the site would try to start it again</p> <p>perhaps a static variable could be used to signal go/no-go, and begin_request could redirect to a placeholder page instead?</p>
<p>Do something that throws an unhandled error. Maybe throwing an Exception would be enough.</p>
49,800
<p>Or vice versa.</p> <p>Update:<br> Hmm, let's assume I have a shopping cart app, the user clicks on the Checkout button. The next thing I want to do is send the user to a Invoice.aspx page (or similar). When the user hits checkout, I could <code>Button.PostBackURL = "Invoice.aspx"</code></p> <p>or I could do </p> ...
<ul> <li>Server.TransferURL will not result in a roundtrip of HTTP request/response. The address bar will not update, as far as the browser knows it has received only one document. Server.Transfer also retains execution context, so the script "keeps going" as opposed to "starts anew".</li> <li>PostbackURL ensures an H...
<p>Server.Transfer is done entirely from the server. Postback is initiated from the client for posting form contents and postback url identifies the page to post to.</p> <p>Maybe you meant to compare with Response.Redirect, which forces the client to submit a new request for a new url.</p>
9,159
<p>I've been given the task of working with SAML to implement an SSO solution between my company and a third party provider. My only issue is that I can't seem to find how to implement SAML in C# 2.0. I've been able to find a few examples for .Net 3.0 and 3.5, but none for 2.0 (and the classes they use don't appear t...
<p>Unless you can find a third party implementation, you are going to have to upgrade beyond v2.0. Probobly not what you want to hear, sorry...</p>
<p>I'm sorry to be this late but I had the same problem you were having. But I've found an excellent solution in .NET 2.0 namely OIOSAML.NET (currently v. 1.4).</p> <p><a href="http://www.softwareborsen.dk/projekter/softwarecenter/brugerstyring/oiosaml.net/releases/1.4/oiosaml-dot-net-v1-4.zip" rel="nofollow noreferre...
38,410
<p>I'm using Tomcat 5.5 as my servlet container. My web application deploys via .jar and has some resource files (textual files with strings and configuration parameters) located under its WEB-INF directory. Tomcat 5.5 runs on ubuntu linux. The resource file is read with a file reader:<br> <code>fr = new FileReader("me...
<p>I'm guessing the problem is you're trying to use a relative path to access the file. Using absolute path should help (i.e. "/home/tomcat5/properties/messages.properties").</p> <p>However, the usual solution to this problem is to use the getResourceAsStream method of the ClassLoader. Deploying the properties file to...
<p>I did used for Jboss Seam: </p> <p><code>ServletLifecycle.getServletContext().getRealPath("")</code></p>
38,217
<p>I suppose this question could just as easily be applied to PHP with regard to MSSQL. However, with some versions of MSSQL being so expensive, I always wondered, what is the real advantage of choosing it over MySQL for .NET development? Is it really difficult to use .NET tools in conjunction with a MySQL database? Wh...
<p>Typically, the fact MySQL came so late to the stored procedure party has kept many away from the database. However, I do like the database and use it with some regularity in my "outside the office" time. Did you know the BO ships Crystal with MySQL as its choice datasource?</p> <p>As for .NET and what to do? If ...
<p>I've been using <a href="http://www.nhibernate.org/" rel="nofollow noreferrer">NHibernate</a> ORM as a way of abstracting MySQL, MSSQL and others. Perhaps it could work for you.</p>
31,810
<p>I am looking to do the following (see pseudo code); I want to select 4 rows for each gd.id (7, 11 or 9). I've incorrectly use limit because that only brings up 4 rows in total. Anyone have an idea on how to change this query to accomplish my goal? </p> <pre><code>SELECT gd.gid, gd.aid, li.ads, li.til FROM gd JOI...
<p>Okay I'm posting this second answer now that I understand the relationship between your tables.</p> <pre><code>CREATE TABLE gd ( aid INT AUTO_INCREMENT PRIMARY KEY, gid INT ); INSERT INTO gd (gid) VALUES (7), (7), (7), -- fewer than four rows (9), (9), (9), (9), -- exactly four row...
<p>the usual approach is:</p> <p>(SELECT * FROM table WHERE key=X LIMIT 4) UNION ALL (SELECT * FROM table WHERE key=Y LIMIT 4) UNION ALL (SELECT * FROM table WHERE key=Z LIMIT 4) ORDER BY ... LIMIT ...</p> <p>do note, it will materialize each subselect in the temptable, so isn't very efficient if your outer LIMIT is ...
38,913
<p>(MFC Question) What's the best way to determine the current displayed client area in a CScrollView? I only need the size of the visible portion, so GetClientRect() won't work here.</p>
<p>You do need to use GetClientRect(), but I think you're asking the wrong question. It is not so that in a scrolled view there is a very big client window that is physically scrolled. Instead, when you scroll, the DC's viewportext and mapping mode are adjusted, which make it seem like your view is bigger than it actua...
<p>Inside your OnDraw() function, you could call pDC->GetViewportOrg and pDC->GetViewportExt.</p> <p><strong>EDIT</strong>: Sorry, I forgot that Viewport extents are only scaling factors. I agree that what you really need here is the client rect.</p>
17,734
<p>I am searching for all drives and their contents. I don't want to search network drives. How can I determine if a given drive is network mounted? What I would want further is to get similar information one gets using NET USE command?</p>
<p>You want the <a href="http://msdn.microsoft.com/en-us/library/aa364939.aspx" rel="noreferrer">GetDriveType</a> function.</p>
<p>Also if you would like to add remove drives or check status, check this article out:</p> <p><a href="http://support.microsoft.com/kb/173011" rel="nofollow noreferrer">http://support.microsoft.com/kb/173011</a></p> <p>That's using the win32 api.</p>
16,701
<p>I'm making a simple jquery command:</p> <p><code>element.html("&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;");</code></p> <p>using the attributes/html method: <a href="http://docs.jquery.com/Attributes/html" rel="nofollow noreferrer">http://docs.jquer...
<p>You could try generating the space during run-time, so it won't be trimmed or whatever happens during transport:</p> <pre><code>element.html(String.fromCharCode(32)); </code></pre>
<p>Is there a possibility that the code is minified as part of the process of being deployed onto the App Engine?</p> <p>I would not expect any string of whitespace to be retained as written, perhaps you could actually escape the white space and force any minification to leave it:</p> <p>example:</p> <pre><code>elem...
17,824
<p>How can I pass arguments to a constructor in an IOC-framework? I want to do something like: (Trying to be IOC-framework agnostic ;) )</p> <pre><code>object objectToLogFor = xxx; container.Resolve&lt;ILogging&gt;(objectToLogFor); public class MyLogging : ILogging { public MyLogging(object objectToLogFor){} } <...
<p>In structure map you could achieve this using the With method:</p> <pre><code>string objectToLogFor = "PolicyName"; ObjectFactory.With&lt;string&gt;(objectToLogFor).GetInstance&lt;ILogging&gt;(); </code></pre> <p>See: <a href="http://codebetter.com/blogs/jeremy.miller/archive/2008/09/25/using-structuremap-2-5-to-i...
<p>Yes, other frameworks are more feature-rich - you need to use an ioc framework that allows for constructor injection. Spring is an example of a multi-language ioc container that allows constructor dependency injection.</p>
15,728
<p>I have a long URL with tons of parameters that I want to open in the default browser from Java on a Windows system using</p> <pre><code>Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler "+url) </code></pre> <p>For short URLs like "<a href="http://www.google.com" rel="nofollow noreferrer">http://www.g...
<p>You will be running up against <a href="https://web.archive.org/web/20190902193246/https://boutell.com/newfaq/misc/urllength.html" rel="nofollow noreferrer">this (archived)</a> operating system/browser specific maximum URL length problem:</p> <p>For "rundll32 url.dll" (i.e. Microsoft IE) you will be limited to 2,08...
<p>It will also depend on the version of windows, because you may be exceeding the operating system's <code>MAX_PATH</code> length on the command line?</p>
30,028
<p>I'm not sure if Jeff coined it but it's the joke/saying that people who say "oh, I know I'll use regular expressions!" now have <a href="http://www.codinghorror.com/blog/archives/001016.html" rel="nofollow noreferrer">two problems</a>. I've always taken this to mean that people use regular expressions in very <a hre...
<p>RexExprs are good for: </p> <ul> <li>Text Format Validations (email, url, numbers)</li> <li>Text searchs/substitution.</li> <li>Mappings (e.g. url pattern to function call)</li> <li>Filtering some texts (related to substitution)</li> <li>Lexical analysis during parsing.</li> </ul>
<p>Regular expressions are a great way to parse text that doesn't already have a parser (i.e. XML) I have used it to create a parser for the mod_rewrite syntax in the .htaccess file or in my URL Rewriter project <a href="http://www.codeplex.com/urlrewriter" rel="nofollow noreferrer">http://www.codeplex.com/urlrewriter...
28,511
<p>My company has an existing established WinForm application which in running on WinXP. The application does alot of sound processing using DirectSound.</p> <p>My company would like to evaluate Mono, as an alternative on a per workstation cost to Vista/Win Server 2008.</p> <p>I've heard that different estimates, ra...
<p>The WinForms part will be easy, you may have to do very little as Mono now claims to support Winforms 100%, however all the DirectSound calls will have to be rewritten to use an API available on Linux, ALSA being the obvious choice.</p> <p>I have written small apps in VS 2005 and ported them with ease to Mono. If y...
<p>Mono can help you move the managed code, but it will not help you move the audio layer.</p> <p>Sadly, the .NET framework does not provide a comprehensive API for audio processing. It merely provides a way of playing back a small sound sample, and it is not even very good at this (See Jeroen's post about audio gap...
25,394
<p>So apparently the wiring in my home is... questionable. Very rarely, plugging or unplugging things will cause a power dip. This is almost always the result of turning on a fan or something, is only for a moment before coming back, but its long enough to cause my printer to reset. I want to add a backup battery suppl...
<p>There are a couple of points to consider with this question. First, you will need to make sure the PSU is correctly adjusted to the float charge voltage of the 12V battery. SLA should be safe to float charge, but over voltage will damage it over time.</p> <p>One alternative solution (since powering the heaters will...
<p>This circuit is correct as it does the job (provides a charge and switch-over when needed). </p> <p>The only drawback could be that you need to ensure that the battery is sealed as during the charging process the electlorit will slowly evaporate and decrease battery capacity.</p> <p>I am personally using a UPC as ...
1,008
<p>I am a Web developer who spends 99% of his time in Linux, but I need to develop a super simple application with VB or possibly C# (.Net). The only version of Visual Studio I have is the most current free ones. There MIGHT be a copy of 2001 lying around somewhere. Anyways, the machine I need to develop this for is...
<p>I don't believe you can target .Net 1.1 in Visual Studio 2008. Here's one of the developer's explanations, from a comment in <a href="http://blogs.msdn.com/lukeh/archive/2007/06/29/net-framework-multitargeting-in-visual-studio-2008-aka-orcas.aspx" rel="nofollow noreferrer">this blog entry</a>:</p> <blockquote> <p...
<p>Have you tried <a href="http://msdn.microsoft.com/en-us/vs2005/aa718347.aspx" rel="nofollow noreferrer">MSBee</a>? This is an add-on to VS2005 (well, strictly speaking: MSBuild in 2.0), but it may well work with VS2008 too. Of course, you can always use the IDE to write code, and simply use MSBuild from the 2.0 fold...
34,828
<p>In .NET 3.5, I'm going to be working with System.Reflection to use AOP (probably in the context of Castle's Windsor Interceptors) to do things like define which security actions need to be performed at the method level, etc. I have heard that some parts of Reflection are slow (I've read the MSDN article around it),...
<p>Explicitly calling a MethodInfo is indeed slow - but you can make it much, <em>much</em> faster if you convert it into a delegate. See <a href="http://msmvps.com/blogs/jon_skeet/archive/2008/08/09/making-reflection-fly-and-exploring-delegates.aspx" rel="nofollow noreferrer">this blog post</a> for example. That doesn...
<p>I'd agree with most of Jon's post - a small note re the dictionary: from a performance perspective, you might want to benchmark this vs just a flat list. Last time I did a benchmark (dictionary vs flat list, checking each item until match found), the dividing point (for read access) was around 150 items; below that,...
23,564
<p>I have a table class that creates modifies a table of items. I want to display those items in a JTable using a table model. To me table model belongs to my GUI package but table needs table model in order to fire changes and table model needs table class in order to display it so I can not separate the two. if you n...
<p>A <code>TableModel</code> is an <em>adapter</em>. I always write the table model to extends <code>AbstractTableModel</code> and have it as a private inner class of my GUI panel class. You only have to fill in a few methods: <code>getRowCount</code>, <code>getColumnCount</code> and <code>getValueAt</code></p> <p>You...
<p>The table model doesn't need to know anything about the table that it's put in. I put the table model in the model package, and the table in the view package. The controller is responsible for asking the model package for the model, asking the view package for the table, and setting that model in the table.</p>
20,162
<p>I know how to move a layer based on touch. But I would also like to be able to rotate the image. </p> <p>Is there any sample code that shows how to do this? Or can anyone give me some advice?</p> <p>Thanks!</p>
<p>The simplest way to do this is using the layer's transform property:</p> <pre><code>float angle = M_PI; //rotate 180°, or 1 π radians layer.transform = CATransform3DMakeRotation(angle, 0, 0.0, 1.0); </code></pre> <p>The first argument to the CATransform3DMakeRotation function is the amount to rotate, in radians...
<p>You should look at Apple's <a href="https://developer.apple.com/iphone/library/samplecode/MoveMe/index.html" rel="nofollow noreferrer">MoveMe</a> example for how to move around a layer based on touch. It also applies some scaling transforms as you do it, so that should serve as a reasonable example of to apply rotat...
30,010
<p>How can I get the value between quotes with an RegEx</p> <p>for example I want to find all the parameters from the function test</p> <pre><code>&lt;html&gt; test("bla"); print("foo"); test("moo"); &lt;/html&gt; </code></pre> <p>The result must be { "bla", "moo" }</p>
<p>If you just want the args to <code>test</code>, you'll need to include that in the regex:</p> <pre><code> StringBuilder sb = new StringBuilder("{"); bool first = true; foreach (Match match in Regex.Matches(html, @"test\((""[^\""]*\"")\)")) { if(first) {first = false;} else {sb.Append(...
<p>edit: Removed old code and made a linq version...</p> <pre><code> var array = (from Match m in Regex.Matches(inText, "\"\\w+?\"") select m.Groups[0].Value).ToArray(); string json = string.Format("{{{0}}}", string.Join(",", array)); </code></pre>
36,499
<p>What <a href="http://en.wikipedia.org/wiki/CAPTCHA" rel="noreferrer">CAPTCHA</a> system is compatible with ASP.NET MVC? Are there any good examples out there?</p>
<p><a href="http://www.coderjournal.com/2008/03/aspnet-mvc-captcha/" rel="nofollow noreferrer">Try this post</a></p> <p>Source code can be found here if you don't have the patience to read the article: <a href="http://www.coderjournal.com/uploads/2008/03/captcha.zip" rel="nofollow noreferrer">zip file</a></p>
<p>Check out <a href="http://weblogs.asp.net/awilinsk/archive/2008/12/09/recaptchamvc.aspx" rel="nofollow noreferrer">RecaptchaMvc</a>. It's a framework that uses the reCAPTCHA service and ASP.NET MVC.</p>
32,329
<h3>Update: Solved, with code</h3> <p><a href="https://stackoverflow.com/questions/18585/why-cant-you-bind-the-size-of-a-windows-form-to-applicationsettings#19056">I got it working, see my answer below for the code...</a></p> <h3>Original Post</h3> <p>As Tundey pointed out in <a href="https://stackoverflow.com/question...
<p>I finally came up with a Form subclass that solves this, once and for all. To use it:</p> <ol> <li>Inherit from RestorableForm instead of Form.</li> <li>Add a binding in (ApplicationSettings) -> (PropertyBinding) to WindowRestoreState.</li> <li>Call Properties.Settings.Default.Save() when the window is about to clo...
<p>Well I have had a quick play with this and you are correct, while there is no way to directly <em>bind</em> the size of the form to AppSettings, you can add your own values and change the size on load.</p> <p>I would perhaps recommend that if this is a common feature, you subclass Form and make it automatically pro...
3,912
<p>I need to change the app name based on what configuration I'm using in Visual Studio. For example, if I'm in Debug configuration, I want the app name to show as 'App_Debug' in the Application field in the Elmah_Error table. Does anyone have any experience with this? Or is there another way to do it?</p>
<p>This can now be done purely in markup. Just add an <code>applicationName</code> attribute to the <code>errorLog</code> element in the <code>&lt;elmah&gt;</code> section of the web.config file. Example:</p> <pre><code>&lt;errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="connectionString" applicati...
<p>By default, Elmah uses the AppPool's application GUID as the default application name. It uses this as the key to identify the errors in the Elmah_Error table when you look at the web interface that's created through it's HTTP Module. </p> <p>I was tasked to explore this option for my company earlier this year. ...
18,469
<p>I want my Ruby program to do different things on a Mac than on Windows. How can I find out on which system my program is running?</p>
<p>Use the <code>RUBY_PLATFORM</code> constant, and optionally wrap it in a module to make it more friendly:</p> <pre><code>module OS def OS.windows? (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil end def OS.mac? (/darwin/ =~ RUBY_PLATFORM) != nil end def OS.unix? !OS.windows? ...
<p>When I just need to know if it is a Windows or Unix-like OS it is often enough to </p> <pre><code>is_unix = is_win = false File::SEPARATOR == '/' ? is_unix = true : is_win = true </code></pre>
20,618
<p>I'm checking for existing of a row in in_fmd, and the ISBN I look up can be the ISBN parameter, or another ISBN in a cross-number table that may or may not have a row.</p> <pre><code>select count(*) from in_fmd i where (description='GN') and ( i.isbn in ( select bwi_isbn from bw_isbn where orig_isbn...
<p>Why bother with the <code>UNION ALL</code></p> <pre><code>select count(*) from in_fmd i where (description='GN') and ( i.isbn in ( select bwi_isbn from bw_isbn where orig_isbn = ? ) or i.isbn = cast(? as varchar) ) </code></pre> <p>I would probably use a <code>LEFT JOIN<...
<pre><code>select count(*) from in_fmd i where description = 'GN' and exists (select 1 from bwi_isbn where bw_isbn.bwi_isbn = in_fmd.isbn) </code></pre>
30,821
<p>I'm having issues with color matching css background colors with colors in images on the same html page. What gives?</p>
<p>I'm guessing that you use a PNG image? This is a gamma correction “feature”. Mark Ransom has posted a <a href="https://stackoverflow.com/questions/115818/which-format-for-small-website-images-gif-or-png#128390">useful text</a> about this.</p> <p>Notice that the <code>pngcrush</code> solution listed somewhere hasn't...
<p>Probably the browser your testing, I've had a lot of trouble with ie 6. </p>
18,674
<p>I want to create a bundle from an arbitrary bundle identifier<br> e.g. <code>com.apple.iokit.IOStorageFamily</code> </p> <p>It's not an unreasonable thing to do as bundle IDs are supposed<br> to be unique, however the obvious code does not work:</p> <pre><code>NSString* bID = @"com.apple.iokit.IOStorageFamily"; N...
<p>Use this</p> <pre><code>NSString *path = [[NSWorkspace sharedWorkspace] absolutePathForAppBundleWithIdentifier:@"com.apple.TextEdit"]; </code></pre>
<p>If what you're looking for is definitely a kext, then you could look at the info dictionary for each bundle in the /S/L/Es/ folder until you find yours. There's no search for bundle by identifier apart from for Applications (where LaunchServices will do it), and loaded bundles as you've already found.</p>
24,018