instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>In some code I've inherited, I see frequent use of <code>size_t</code> with the <code>std</code> namespace qualifier. For example:</p> <pre><code>std::size_t n = sizeof( long ); </code></pre> <p>It compiles and runs fine, of course. But it seems like bad practice to me (perhaps carried over from C?).</p> <p>Isn...
<p>There seems to be confusion among the stackoverflow crowd concerning this</p> <p><code>::size_t</code> is defined in the backward compatibility header <code>stddef.h</code> . It's been part of <code>ANSI/ISO C</code> and <code>ISO C++</code> since their very beginning. Every C++ implementation has to ship with <cod...
<p>Sometimes other libraries will define their own size_t. For example boost. std::size_t specifies that you definitely want the c++ standard one. </p> <p>size_t is a c++ standard type and it is defined within the namespace std.</p>
29,379
<p>I'd love to do this:</p> <pre><code>UPDATE table SET blobCol = HTTPGET(urlCol) WHERE whatever LIMIT n; </code></pre> <p>Is there code available to do this? I known this should be possible as the <a href="http://dev.mysql.com/doc/refman/5.0/en/udf-compiling.html" rel="nofollow noreferrer">MySQL Docs</a> include an ...
<p>No, thank goodness — it would be a security horror. Every SQL injection hole in an application could be leveraged to start spamming connections to attack other sites.</p> <p>You could, I suppose, write it in C and compile it as a UDF. But I don't think it really gets you anything in comparison to just SELECTing in ...
<p>Proly not. Best practises in a web-enviroment is to have database-servers isolated from the outside, both ways, meaning that the db-server wouldn't be allowed to fetch stuff from the internet.</p>
37,204
<p>I wish we have "Usable" pattern in C#, when code block of using construct would be passed to a function as delegate:</p> <pre><code>class Usable : IUsable { public void Use(Action action) // implements IUsable { // acquire resources action(); // release resources } } </code></pre> <p>and in use...
<p>IMHO, I don't see any great use for this pattern because:</p> <ol> <li>using block already requires the object to have IDisposable interface, so we can use the IDisposable interface for controlled execution</li> <li>From where do we pass the Action object here?</li> </ol> <p>I had already used this kind of pattern...
<p>You can already have most of this by using an anonymous delegate like this:</p> <pre><code>using(new Usable(delegate() { // actions here }) {} </code></pre> <p>Of course, wrapping that away in some function, or directly implementing the try/finally might make this not only useful, but even a bit pretty.</p>
27,305
<p>In the recent update of java (6.10) <a href="http://java.sun.com/javase/6/webnotes/6u10.html" rel="nofollow noreferrer">http://java.sun.com/javase/6/webnotes/6u10.html</a><a href="http://java.sun.com/javase/6/webnotes/6u10.html" rel="nofollow noreferrer">link text</a> the way that unsigned applets was changed. A war...
<p>I recommend structuring your command line tool's code so that the command line utility is a client to a library of functions and/or classes. </p> <p>Rather than simply using std::cout to print output, have the libraries function take an ostream reference that defaults to std::cout. When you are testing, provide a s...
<p>You can do this from a batch file oder windows scripting host.</p> <p>But i promise to use a task scheduler like (<a href="http://www.splinterware.com/products/wincron.htm" rel="nofollow noreferrer">http://www.splinterware.com/products/wincron.htm</a>) or other free/professional software.</p> <p>There you can easy...
45,999
<p>I've frequently encountered sites that put all of their JavaScript inside a <code>namespace</code> structure along the lines of:</p> <pre><code>namespaces = { com : { example: { example.com's data} } </code></pre> <p>However, setting this up safely with respect to other namespaced frameworks seems to require a rel...
<p>Javascript doesn't have stand-alone namespaces. It has functions, which can provide scope for resolving names, and objects, which can contribute to the named data accessible in a given scope. </p> <p>Here's your example, corrected:</p> <pre><code>var namespaces = { com: { example: { /* example.com's data */ } } } ...
<p>Use an object literal and either the <code>this</code> object or the explicit name to do namespacing based on the sibling properties of the local variable which contains the function. For example:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snipp...
3,406
<p>I have a string with possible command line arguments (using an Read-Eval-Print-Loop program) and I want it to be parsed similar to the command line arguments when passed to Getopt::Long.</p> <p>To elaborate:</p> <p>I have a string</p> <pre><code>$str = '--infile /tmp/infile_location --outfile /tmp/outfile' </code...
<p>Check out the section <a href="http://perldoc.perl.org/Getopt/Long.html#Parsing-options-from-an-arbitrary-string" rel="nofollow noreferrer">parsing options from an arbitrary string</a> in the <a href="http://perldoc.perl.org/Getopt/Long.html" rel="nofollow noreferrer">man page for Getopt::Long</a>, I think it does e...
<p>When you use Getopt::Long on something other than user input, be aware that some features are different based on the POSIXLY_CORRECT environment variable. You can override this with the appropriate call to Configure.</p> <p><a href="http://everything2.com/node/877243" rel="nofollow noreferrer">Obligatory POSIXLY_C...
14,399
<p>How can I set the location (as it's picked up in CoreLocation services) in the iPhone Simulator? </p>
<p>As of iOS 5, the simulator has a configurable location.</p> <p>Under the Debug menu, the last entry is "Location"; this gives you a sub menu with:</p> <ul> <li>None</li> <li>Custom Location</li> <li>Apple Stores</li> <li>Apple</li> <li>City Bicycle Ride</li> <li>City Run</li> <li>Freeway Drive</li> </ul> <p>Custo...
<p>Better late than never :)</p> <p>I just came across this <a href="http://www.vimov.com/isimulate/features/" rel="nofollow noreferrer">iSimulate</a> which allows you to send Fake location to the app. The solution is NOT free. </p> <pre><code>&gt; Q: How does iSimulate work? &gt; A: When added to your project, the...
26,355
<p>How can I distribute a standalone Python application in Linux?</p> <p>I think I can take for granted the presence of a recent Python interpreter in any modern distribution. The problem is dealing with those libraries that do not belong to the standard library, i.e. wxPython, scipy, python cryptographic toolkit, rep...
<p>Create a deb (for everything Debian-derived) and an rpm (for Fedora/SuSE). Add the right dependencies to the packaging and you can be reasonably sure that it will work.</p>
<p>Nope.</p> <p>Python is notoriously flaky with respect to different setups. The only sane way to deploy a python app is to ship the whole bundle of interpreter and libraries that you are relying on with your code. That will most likely work.</p> <p>Update 2019: I stand by this. Virtualenv is a way of packaging libr...
23,465
<p>There is a standard two-pass algorithm mentioned in RFC 1942: <a href="http://www.ietf.org/rfc/rfc1942.txt" rel="nofollow noreferrer">http://www.ietf.org/rfc/rfc1942.txt</a> however I haven't seen any good real-world implementations. Anyone know of any? I haven't been able to find anything useful in the Mozilla or W...
<p>html table rendering is non-trivial due to the various ways that the sizes of the cells may be specified, tables nested within tables, etc.</p> <p>if all you want is the image, a simple solution would be the .NET browser control (which is basically the COM component for IE) and a screen-capture function</p> <p>if ...
<p>I'm not sure if this will meet your constraints or not, but you can try using IE or an IE control with MSHTML and the <a href="http://msdn.microsoft.com/en-us/library/aa752274(VS.85).aspx" rel="nofollow noreferrer">IHTMLElementRender</a> interface to render the table to a device context.</p>
23,889
<p>I have built a CFC designed to serve as a dynamic, aging cache intended for almost everything worth caching. LDAP queries, function results, arrays, ojects, you name it. Whatever takes time or resources to calculate and is needed more than once. I'd like to be able to do a few things:</p> <ul> <li><strong>share the...
<p>Okay - since I misunderstood your question initially I've deleted my previous answer as to not cause any further confusion.</p> <p>To answer your question about locking:</p> <p>Named locks should be fine because they don't have to always have the same name. You can name them dynamically depending on what cache you...
<p>Okay - since I misunderstood your question initially I've deleted my previous answer as to not cause any further confusion.</p> <p>To answer your question about locking:</p> <p>Named locks should be fine because they don't have to always have the same name. You can name them dynamically depending on what cache you...
18,929
<p>This question is for a web application.</p> <p>And maybe it's a stupid question but I was wondering if there is a way to generate a polygon with 4 points, so that the user can himself drag each point to create it's own (As an example, let's say that we want to remove a window from an image that it is not at a nor...
<p>If you're willing to do a little coding, you want to take a look at QTKit, the QuickTime framework for Cocoa. QTKit will let you easity set up an input source from the webcam (intro <a href="http://developer.apple.com/quicktime/qtkit.html" rel="nofollow noreferrer">here</a>). You can also apply Core Image filters to...
<p>Found a cross platform tool called 'Processing', actually ran the windows version to avoid further complications getting the webcams to work.</p> <p>Had to install quick time, and something called gVid to get it to work but after the initial hurdle coding seems like C; (I think it gets "compiled" into Java), and it...
27,996
<p>What's the difference between the two and when should I use each:</p> <pre><code>&lt;person&gt; &lt;firstname&gt;Joe&lt;/firstname&gt; &lt;lastname&gt;Plumber&lt;/lastname&gt; &lt;/person&gt; </code></pre> <p>versus</p> <pre><code>&lt;person firstname="Joe" lastname="Plumber" /&gt; </code></pre> <p>Tha...
<p>There are element centric and attribute centric XML, in your example, the first one is element centric, the second is attribute centric.</p> <p>Most of the time, these two patterns are equivalent, however there are some exceptions.</p> <p><strong>Attribute centric</strong></p> <ul> <li>Smaller size than element cent...
<p>In my company, we would favour the 2nd approach.</p> <p>The way we think about it is that "firstname" and "lastname" are <em>attributes</em> of the "person" node, rather than <em>sub-fields</em> of the "person" node. It's a subtle difference. </p> <p>In my opinion the 2nd approach is more concise, and readabilit...
29,931
<p>I'm attempting to use LINQ to insert a record into a child table and I'm receiving a "Specified cast is not valid" error that has something to do w/ the keys involved. The stack trace is:</p> <blockquote> <p>Message: Specified cast is not valid.</p> <p>Type: System.InvalidCastException Source: System.Da...
<p>Post up the schema of the parent table.</p> <p>if you look here, some other people have had your problem. <a href="http://forums.microsoft.com/msdn/ShowPost.aspx?PostID=3493504&amp;SiteID=1" rel="nofollow noreferrer">http://forums.microsoft.com/msdn/ShowPost.aspx?PostID=3493504&amp;SiteID=1</a></p> <p>It appears t...
<pre><code>ResponseCode rc = new ResponseCode() { SurveyQuestionName = "Q11", Code = 3, Description = "Yet another code" }; </code></pre> <p>and:</p> <pre><code>INSERT INTO tblResponseCode (responseCodeTableId, surveyQuestionName, code, description) VALUES (13683, 'Q11', 3, 'Yet another ...
29,388
<p>What is the maximum length in characters a CString object can hold?</p>
<p>Up to your available memory or INT_MAX-1 (whichever is less).</p>
<p><a href="http://msdn.microsoft.com/en-us/library/8a994dfk(VS.80).aspx" rel="nofollow noreferrer">2,147,483,647</a> characters</p>
21,820
<p>I have a Flex <code>ComboBox</code> that gets populated by a <code>dataprovider</code> all is well...</p> <p>I would now like to add a default " -- select a item --" option at the 0 index, how can I do this and still use a <code>dataprovider</code>? I have not seen any examples of such, but I can't imagine this bei...
<p>If you don't need the default item to be selectable you can use the <code>prompt</code> property of <code>ComboBox</code> and set the <code>selectedIndex</code> to -1. That will show the string you set <code>propmt</code> to as the selected value until the user chooses another. It will not appear in the list of opti...
<p>This can be used following code for selected default value of combobox</p> <pre><code>var index:String = "foo"; for(var objIndex:int = 0; objIndex &lt; comboBox.dataProvider.length; objIndex++) { if(comboBox.dataProvider[objIndex].label == index) { comboBox.selectedIndex = objIndex; break; } } &lt;m...
5,566
<p>Say I have class A with</p> <pre><code>class A { final String foo() { // .. computing result, contacting database, whatever .. return "some computed value"; } // ... and a bazillion other methods, some of them final. } </code></pre> <p>Now I have class B with</p> <pre><code>class B { String method...
<p>You can try the <a href="http://jmockit.org" rel="nofollow noreferrer">JMockit</a> mocking library. </p>
<p>I'd remove the "final" and just put in a comment "Don't override this method!!". If you can't trust coworkers not to follow simple instructions, it's hopeless anyway.</p>
23,132
<p>In Visual Studio, I can select the "Treat warnings as errors" option to prevent my code from compiling if there are any warnings. Our team uses this option, but there are two warnings we would like to keep as warnings. </p> <p>There is an option to suppress warnings, but we DO want them to show up as warnings, so t...
<p>You can add a <code>WarningsNotAsErrors</code>-tag in the project file.</p> <pre><code>&lt;PropertyGroup&gt; ... ... &lt;WarningsNotAsErrors&gt;618,1030,1701,1702&lt;/WarningsNotAsErrors&gt; &lt;/PropertyGroup&gt; </code></pre> <p>Note: <code>612</code> and <code>618</code> are both warnings about Obso...
<p>It seems to me the root problem is really a combination of your treating warnings as errors, when they are clearly not, and your apparent policy of permitting check-ins which violate this. As you say, you want to be able to continue working despite a warning. You've only mentioned a few warnings you want to be able ...
33,505
<p>I search an implementation of a network (or distributed) file system like NFS in Java. The goal is to extend it and do some research stuff with it. On the web I found some implementation e.g. <a href="http://users.csc.calpoly.edu/~jbergami/projects/djnfs/" rel="noreferrer">DJ NFS</a>, but the open question is how ma...
<p>Have a look at <a href="http://www.dcache.org" rel="nofollow noreferrer">dcache.org</a>. They implement a NFSv4.1 server in Java.</p> <ul> <li><a href="https://www.dcache.org/manuals/dcache-whitepaper-light.pdf" rel="nofollow noreferrer">whitepaper</a></li> <li><a href="https://github.com/dCache/nfs4j" rel="nofollo...
<p>I can't say I've actually played with anything other than HDFS, but here are some links that might help you.</p> <ul> <li><a href="http://www.hirednetwork.com/?p=61" rel="nofollow noreferrer">http://www.hirednetwork.com/?p=61</a></li> <li><a href="http://ieeexplore.ieee.org/xpl/freeabs_all.jsp?arnumber=1266109" rel...
22,991
<p>I am being powerfully tempted to use an unchecked exception as a short-circuit control-flow construct in a Java program. I hope somebody here can advise me on a better, cleaner way to handle this problem.</p> <p>The idea is that I want to cut short the recursive exploration of sub-trees by a visitor without having ...
<p>I think this is a reasonable approach for a few reasons:</p> <ul> <li>You are using a 3rd party and are unable to add the checked exception</li> <li>Checking return values everywhere in a large set of visitors when it's only necessary in a few is an unnecessary burden</li> </ul> <p>Also, there are those that have ...
<p>Is there a reason you aren't just returning a value? Such as NULL, if you really want to return nothing? That would be a lot simpler, and wouldn't risk throwing an unchecked runtime exception.</p>
48,253
<p>I'm a Java developer and I have a question about automating a task I've been given. </p> <p>I'm having to 3 times daily, login to this website we have at work, select a few form elements and then click on submit to get a report printed out. </p> <p>I'm wondering how I can write some sort of script that will automa...
<p>Check out <a href="http://php.net/curl" rel="nofollow noreferrer">cURL</a> in PHP. It allows you to do all the normal functions of a web browser with code (other than moving the mouse). And yes, you'll need to do screen scraping.</p>
<p>It's called "web scraping" or "screen scraping", and there are a lot of libraries out there to do this. I couldn't speak to a Java-specific tool, though: I'm a .Net guy (the .Net way would be System.Net.WebClient or System.Net.HttpWebRequest/System.Net.HttpWebResponse). But I'm sure there's something.</p> <p>In t...
22,953
<p>Simply put:</p> <p>foo.h:</p> <pre><code>#include "bar.h" class foo { private: bar it; void DoIt(); } </code></pre> <p>bar.h:</p> <pre><code>class bar { public: void Test(); } </code></pre> <p>foo.cpp:</p> <pre><code>void foo::DoIt() { it.Test(); } </code></pre> <p>This will result in a:</p> ...
<p>You have not written the code for <code>bar::Test()</code> method.</p>
<p>I'm dumb! I did define Test() in the class definition but did not actually have an existing Test() function :( </p> <p>Sorry.</p>
48,873
<p>I'm building Desktop Software for over 10 years now, mostly it's simple Data-Input Software. My problem is, it's always looking the same: A Treeview on the Left and a lot of Text/Data Fields to the right, depending on the type of data currently is worked on. Are there any fresh ideas how such software nowadays shoul...
<p>Having all of your software look the same thing is a <em>good</em> thing. One of the best ways to make it easy for people to use your software is to make it look exactly the same as other software your users already know how to use.</p> <p>There are basically two common strategies for how to handle entry of a lot ...
<p>If it works...</p> <p>Depending on what you've got happening with the data (that is, is it hierarchical, or fairly flat), you might want to try a tab-based metaphor, or perhaps the "Outlook-style", with a sidebar showing the sections of an application. One other notion I've played with lately is the "Object desktop...
17,429
<p>I'm using an NSTimer to do some rendering in an OpenGL based iPhone app. I have a modal dialog box that pops up and requests user input. While the user is providing input I'd like to "pause" i.e. something like this:</p> <pre><code>[myNSTimer pause]; </code></pre> <p>I'm using this syntax because I've been doing...
<p>From here:</p> <p><a href="http://discussions.apple.com/thread.jspa?threadID=1811475&amp;tstart=75" rel="noreferrer">http://discussions.apple.com/thread.jspa?threadID=1811475&amp;tstart=75</a></p> <p>"You can store the amount of time that has passed since the timer started... When the timer starts store the date i...
<p>I was also in need of pausable NSTimer. After reading this thread and your answers and realizing that only thing I need is to set timer's fireDate to distant future and then back to Now I made category to NSTimer with Pause and Resume methods. So I can simply pause timer by calling [myTimer pause]; and resume by cal...
45,176
<p>Is there a Perl module that allows me to view diffs between actual and reference output of programs (or functions)? The test fails if there are differences.</p> <p>Also, in case there are differences but the output is OK (because the functionality has changed) I want to be able to commit the actual output as future...
<p>Perl has excellent utilities for doing testing. The most commonly used module is probably Test::More, which provides all the infrastructure you're likely to need for writing regression tests. The prove utility provides an easy interface for running test suites and summarizing the results. The Test::Differences modul...
<p>I tend to use more of the Test::Simple and Test::More functionality. I looked at PerlUnit and it seems to provide much of the functionality which is already built into the standard libraries with the Test::Simple and Test::More libraries.</p>
9,186
<p>How can I add an instance variable to a defined class at <b>runtime</b>, and later get and set its value from outside of the class?</p> <p>I'm looking for a metaprogramming solution that allows me to modify the class instance at runtime instead of modifying the source code that originally defined the class. A few ...
<p>Ruby provides methods for this, <code>instance_variable_get</code> and <code>instance_variable_set</code>. (<a href="http://www.ruby-doc.org/core/classes/Object.html" rel="noreferrer">docs</a>)</p> <p>You can create and assign a new instance variables like this:</p> <pre><code>&gt;&gt; foo = Object.new =&gt; #&lt;...
<p>Readonly, in response to your edit:</p> <blockquote> <p>Edit: It looks like I need to clarify that I'm looking for a metaprogramming solution that allows me to modify the class instance at runtime instead of modifying the source code that originally defined the class. A few of the solutions explain ho...
18,242
<p>I have an <code>ActiveRecord</code> model, <code>Foo</code>, which has a <code>name</code> field. I'd like users to be able to search by name, but I'd like the search to ignore case and any accents. Thus, I'm also storing a <code>canonical_name</code> field against which to search:</p> <pre><code>class Foo vali...
<p>Rails has already a builtin for normalizing, you just have to use this to normalize your string to form KD and then remove the other chars (i.e. accent marks) like this:</p> <pre><code>&gt;&gt; "àáâãäå".mb_chars.normalize(:kd).gsub(/[^\x00-\x7F]/n,'').downcase.to_s =&gt; "aaaaaa" </code></pre>
<p>lol.. i just tryed this.. and it is working.. iam still not pretty sure why.. but when i use this 4 lines of code:</p> <ul> <li>str = str.gsub(/[^a-zA-Z0-9 ]/,"")</li> <li>str = str.gsub(/[ ]+/," ")</li> <li>str = str.gsub(/ /,"-")</li> <li>str = str.downcase</li> </ul> <p>it automaticly removes any accent from fi...
27,867
<p>I'm trying to write a quick little java application to read the contents of a pcap file (from Wireshark) and play the data back on the network on a linux box. The file will only contain UDP broadcast packets, so my application only really needs the timestamp, port number, and data from the packet to do what I need....
<p>Add -Djava.net.preferIPv4Stack=true to your Java application runtime properties.</p>
<p>Also you can use this command (as root) and you will not need to add the -Djava.net.preferIPv4Stack=true parameter in every java application:</p> <pre><code> # echo 0 &gt; /proc/sys/net/ipv6/bindv6only </code></pre> <p>If you want to keep this configuration forever you can write it in some initial script.</p>
37,057
<pre><code>#include &lt;stdio.h&gt; int main() { unsigned long long int num = 285212672; //FYI: fits in 29 bits int normalInt = 5; printf("My number is %d bytes wide and its value is %ul. A normal number is %d.\n", sizeof(num), num, normalInt); return 0; } </code></pre> <p>Output:</p> <pre><code>My nu...
<p>Use the ll (el-el) long-long modifier with the u (unsigned) conversion. (Works in windows, GNU).</p> <pre><code>printf("%llu", 285212672); </code></pre>
<p>Well, one way is to compile it as x64 with VS2008</p> <p>This runs as you would expect:</p> <pre><code>int normalInt = 5; unsigned long long int num=285212672; printf( "My number is %d bytes wide and its value is %ul. A normal number is %d \n", sizeof(num), num, normalInt); </code></pre> ...
2,499
<p>In the uncompressed situation I know I need to read the wav header, pull out the number of channels, bits, and sample rate and work it out from there: (channels) * (bits) * (samples/s) * (seconds) = (filesize)</p> <p>Is there a simpler way - a free library, or something in the .net framework perhaps?</p> <p>How wo...
<p>You may consider using the mciSendString(...) function (error checking is omitted for clarity):</p> <pre><code>using System; using System.Text; using System.Runtime.InteropServices; namespace Sound { public static class SoundInfo { [DllImport("winmm.dll")] private static extern uint mciSend...
<pre><code>Imports System.IO Imports System.Text Imports System.Math Imports System.BitConverter Public Class PulseCodeModulation ' Pulse Code Modulation WAV (RIFF) file layout ' Header chunk ' Type Byte Offset Description ' Dword 0 Always ASCII "RIFF" ' Dword 4 Number...
10,799
<p>So, I was reading the Google testing blog, and it says that global state is bad and makes it hard to write tests. I believe it--my code is difficult to test right now. So how do I avoid global state?</p> <p>The biggest things I use global state (as I understand it) for is managing key pieces of information betwee...
<p>Dependency injection is what you're looking for. Rather than have those functions go out and look for their dependencies, inject the dependencies into the functions. That is, when you call the functions pass the data they want to them. That way it's easy to put a testing framework around a class because you can simp...
<p>An example of dependency injection in an MVC setting, here goes:</p> <p>index.php</p> <pre><code>$container = new Container(); include_file('container.php'); </code></pre> <p>container.php</p> <pre><code>container.add("database.driver", "mysql"); container.add("database.name","app"); </code></pre> <p>...</p> <...
6,611
<p>Based on <a href="https://stackoverflow.com/questions/6209/split-a-string-ignoring-quoted-sections#6243">"Split a string by spaces in Python"</a>, which uses <em>shlex.split</em> to split a string with quotes smartly, I would be interested in hearing about other common tasks solved by non-obvious standard library fu...
<p>I was quite surprised to learn that you could use the bisect module to do a very fast binary search in a sequence. It's documentation doesn't say anything about it:</p> <blockquote> <p>This module provides support for maintaining a list in sorted order without having to sort the list after each insertion.</p> </b...
<p>I've found <a href="http://docs.python.org/lib/module-sched.html" rel="nofollow noreferrer">sched module</a> to be helpful in cron-like activities. It simplifies things a lot. Unfortunately I found it too late. </p>
11,797
<p>I have a very frustrating problem, my extruder clogs up pretty much immediately after cleaning it from the previous clog and I cannot figure out what the hell is going wrong.</p> <p>I use a genuine E3D V6 in direct drive configuration (dual drive) and I print only PLA. I have tried many nozzle offsets from the bed ...
<p>I have had one roll of filament that did this. I'd get a jam, clean it out, and immediately jam again.</p> <p>I got the filament from a friend who had reported problems using it, but I thought, "I have a Prusa3D i3m3-mmu2, I can print with anything." Unfortunately, I could not.</p> <p>I threw away the filament (...
<p>It turned out that the stepper driver on my duet 2 wifi board is defective which resulted in the extruder motor being poorly controlled which in turn caused the clogs, using a different stepper driver fixed the issue.</p> <p>I am a bit bummed out that one of my drivers turned out to be defective since the board has...
1,658
<p>I have an ASP.NET (2.0) site. I am on my dev box using V Studio 2008 and IIS. I have a separate User Control project that gets called from a javascript function in the default.aspx page. The User Control project is in another solution.</p> <p>The application is running as expected. The user control is being called ...
<ul> <li>Add the user control project to the solution you want to debug in.</li> <li>Remove the reference you have to the user control project</li> <li>Then set the reference of the calling project, to be the local user control project</li> </ul> <p>Edit: You might also have to do a clean after you remove the referenc...
<p>This is an old question, but it still googles up, so here's something that might help. <a href="http://weblogs.asp.net/ianrobinson/archive/2008/10/15/creating-dotnetnuke-modules-using-a-web-application-project-wap.aspx" rel="nofollow noreferrer">This post</a> talks about dotnetnuke modules, but I think the concept i...
43,679
<p>Can I use <a href="http://struts.apache.org/" rel="nofollow noreferrer">Struts</a> as a backend and PHP as front end for a web application? If yes, what may be the implications.</p>
<p>The first thing to came to mind is <a href="http://www.caucho.com/resin-3.0/quercus/" rel="nofollow noreferrer">Quercus</a> (from the makers of the Resin servlet engine), as Jordi mentioned. It is a Java implementation of the PHP runtime and purportedly allows you to access Java objects directly from your PHP (part ...
<p>What do you mean by backend and and frontend?</p> <p>If you mean using Java for the admin side of your site and PHP for the part that the public will see then there is nothing stopping you.</p> <p>The implications are that you will have to maintain two applications in different languages.</p>
5,995
<p>We have an internal application that is using a service account and fine-grained table and field control is controlled by permissions tables in the application.</p> <p>If we wanted to use pass-through security with Active Directory, we have a problem in that a user with odbc access could modify tables outside of b...
<p>You could use stored procedures and only give the rights to the stored procedures, ensuring either that the basic business rules cannot be violated (if they are simple and unchanging, they can go in the SPs) or at the very least (if they are complex or changing, they don't work well in SPs), all modifications have t...
<p>Logon triggers could be possible, if it's SQL 2005 +.</p> <ul> <li>Use HOST_ NAME or APP_NAME to limit who the connection to a server or application</li> <li>Use sys.dm_ exec_ sessions to test "client_ interface_name"</li> </ul>
34,428
<pre><code>'''use Jython''' import shutil print dir(shutil) </code></pre> <p>There is no, shutil.move, how does one move a file with Jython? and while we at it, how does one delete a file with Jython?</p>
<p><code>os.rename()</code> to move, and <code>os.unlink()</code> to delete -- just like Python pre-<code>shutil</code>.</p>
<pre><code>f1 = File(filename_old) f1.nameTo(File(filename_new)) </code></pre>
30,982
<p>I'm writing a asp.net MVC site and I have written some extensions to the Html class to generate some html for me. </p> <p>From within the extension method is it better to write directly to the Response.Output stream or have the extension method return a string?</p> <p>What are the advantages / disadvantages of usi...
<p>Returning a string gives you the option of modifying/inspecting/capturing the result before it gets dumped to Response.Write().</p>
<p>First, I wouldn't use OutputStream for text output, I would use Response.Write().</p> <p>Second, returning a string to &lt;%= calls Response.Write() anyhow (look at the compiled output of an ASPX in your Temp ASP.NET files folder sometime).</p>
47,494
<p>I'm looking into writing a wxWidget that displays a graphical node network, and therefore does a lot of drawing operations. I know that using Python to do it is going to be slower, but I'd rather get it working and port it later when its functional. Ideally, if the performance hit isn't too great, I'd prefer to ke...
<p>By naming your <code>select</code> with trailing square brackets, PHP (and likely other server languages) will put the data in an array</p> <p>ex:</p> <pre><code>&lt;form action="process.php" method="post"&gt; &lt;select name="multiSelects[]" multiple="multiple" size="5"&gt; &lt;option value="0"&gt;Zero&lt;/...
<p>Below you find an example of a page.</p> <p>Note that:</p> <ul> <li>the select element (and any form element) needs a name to be included in the post. </li> <li>only selected options in the select element will be posted.</li> </ul> <p><em>What values are selected in the box by the user?</em></p> <p>When the use...
49,713
<p>I have a large amount of audio stored on my web server in a very custom format that can't be replayed by anything other than my own application. That application is a Win32 app that can connect to my web server and stream and replay that audio. </p> <p>I'd really like to be able to do the streaming and replaying ...
<p>Apart from converting server-side: Implement a decoder for your format in ActionScript or Java. Then you can write a Flash movie or Java applet that plays it. Both languages/runtimes should be fast enough to decode in realtime unless your format is very complex. Flash would be the more accessible of the two, since n...
<p>I'd go with converting the audio to WAV (or MP3) on the server. Writing your own cross-platform browser component would be a lot of work, thanks to the different ways the major OSes handle their audio APIs.</p>
19,640
<p>How would I go about adding the "Spent Time" as a column to be displayed in the issues list?</p>
<p>You can also do this by adding the column at runtime. This will add the spent hours column without modifying the Redmine core. Just drop the following code into a file in lib/</p> <p>Adapted from:</p> <ul> <li><a href="http://github.com/edavis10/redmine-budget-plugin/tree/master/lib/query_patch.rb" rel="noreferr...
<p>Since no one answered, I just poked the source until it yielded results. Then I started a blog to explain how I did it.</p> <p><a href="http://joelmeador.tumblr.com/post/45927797301/add-spent-time-spent-hours-column-to-redmines" rel="nofollow noreferrer">Add spent time column to default issues list in Redmine</a><...
41,598
<p>Ok, Regex wizards. I want to be able to search through my logfile and find any sessions with the word 'error' in it and then return the entire session log entry.</p> <p>I know I can do this with a string/array but I'd like to learn how to do it with Regex but here's the question. If I decide to do this with Regex ...
<p><p>It looks as if your sessions are delimited by blank lines (in addition to the start/end markers). If that's the case, this is a one liner:</p> <p><code> perl -ne 'BEGIN{$/=""} print if /error/i' &lt; logfile </code></p>
<p>Like the last guy said, perl from the command line will work. So will awk from the command line:<br> <code>awk '/-Start of Session-/ { text=""; gotError=0; } /Error/{gotError=1;}/-End of Session-/{ if(gotError) {print text}} { text=text "\n" $0}' logFileName.txt</code></p> <p>Basically, start recording on a line w...
18,707
<p>Can a firefox XPCOM component read and write page content across multiple pages? </p> <p>Scenario: A bunch of local HTML and javascript files. A "Main.html" file opens a window "pluginWindow", and creates a plugin using:<br><br> <code> netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');<br> va...
<p>What type of repo do you have? FSFS or BDB?</p> <p>(Let's assume FSFS for now, since that's the default.)</p> <p>In the case of FSFS, each revision is stored as a diff against the previous. So, you would think that yes, after many revisions, it would be very slow.</p> <p>However, this isn't the case. FSFS uses...
<p>I am not sure..... I am using SVN with apache on Centos 5.2. Works ok. Revision number was 8230 something like that... And on all client machines Commit was so slow that we had to wait at least 2min for a file that is 1kb. I am talking about 1 file that has no big filesize. </p> <p>Then I made a new repository. Sta...
15,542
<p>I've written a web service using ASP.NET (in C#) and I'm attempting to write an example PHP client using NuSOAP. Where I'm tripped up on are examples of how to do this; some show <code>soapval</code> being used (and I don't quite understand the parameters - for example passing <code>false</code> as <code>string</co...
<p>You have to wrap things in tons of nested arrays.</p> <pre><code>&lt;?php require_once('lib/nusoap.php'); $client = new nusoap_client('http://localhost:3333/Service.asmx?wsdl'); $params = array( 'anId' =&gt; 3, 'action' =&gt; 'OMNOMNOMNOM', 'parameters' =&gt; array( 'Param' =&gt; ar...
<p>Here the sample with native SOAP support:</p> <pre><code> // Create a new soap client based on the service's metadata (WSDL) $client = new SoapClient("http://some.wsdl", array('location' =&gt; 'http://127.0.0.100:80/IntegrationService/php')); $params = array(); $params['lead']['Firstname'] ...
35,271
<p>I have an initialization class that preloads content into a variable (probably a list or array). There will only be one instance of this initialization class but there will be many classes that need to access the preloaded content.</p> <p>The problem is not many of them are related and none of them extend my initi...
<p>what you are doing is known as <a href="http://en.wikipedia.org/wiki/Singleton_pattern" rel="nofollow noreferrer">singleton</a>. here are some previous discussions on this:</p> <ul> <li><a href="https://stackoverflow.com/questions/246710/how-to-implement-a-singleton-in-c">How to implement a singleton in C#</a></li>...
<p>To avoid static/global scope you could use some kind of Registry class. This means you have one class which you initialize at program startup. This class holds references to all other classes that need to be accessed globally. Now you pass the initialized instance of your registry class to all instances in your appl...
34,888
<p>Currently I am working on a project where goto statements are heavely used. The main purpose of goto statements is to have one cleanup section in a routine rather than multiple return statements. Like below:</p> <pre><code>BOOL foo() { BOOL bRetVal = FALSE; int *p = NULL; p = new int; if (p == NULL) ...
<p>I am not sure what do you mean by clean up code but in C++ there is a concept called "<em>resource acquisition is initialization</em>" and it should be the responsibility of your destructors to clean up stuff.</p> <p>(Note that in C# and Java, this is usually solved by try/finally)</p> <p>For more info check out t...
<p>I don't know where this thing about goto come from...</p> <p>In a compiled language each and every conditional instructions (<code>if</code>, <code>switch</code>, <code>for</code>, <code>while</code>, etc.) resolve in "cmp" "jmp" or "j??" in machine code (jmp IS goto).</p> <p>In fact, a really well optimised code ...
49,672
<p>What is a very good jsp framework to use with Spring MVC. Are the only candidates SiteMesh and Tiles, and others?</p>
<p>To disable login prompt opening office documents from SharePoint 2010 do the following settings in web.config</p> <pre><code>&lt;system.webServer&gt; &lt;security&gt; &lt;requestFiltering allowDoubleEscaping="true"&gt; &lt;!-- here's where the magic happens --&gt; &lt;verbs allowUnlisted="true"&gt...
<p>My guess is that the Office client is loading the underlying document template from another location where anonymous access is enabled. This also explains why you can still open the document as the Office client can also work without loading the template the document was originally created from. To see the template ...
49,126
<p>I've only been using VS 2008 Team Foundation for a few weeks. Over the last few days, I've noticed that sometimes one of my objects/controls on my page just disappears from intellisense. The project builds perfectly and the objects are still in the HTML, but I still can't find the object. </p> <p>Any one else notic...
<p>I am also having a number of problems with VS 2008. Who would guess that I don't ever need to select multiple controls on a web form...</p> <p>Anyway, a lot has been fixed in Service Pack 1, which is in Beta currently. Might be worth installing that. It has gone a little way to fixing absolute positioning. This...
<p>I occasionally get this in Visual Studio 2005.</p> <p>A method I use to get the controls back, is to switch the web page between code view and design view. I know it's not a fix but it's a little quicker than restarting Visual Studio.</p>
2,805
<p>Is it possible to to take a screenshot of a webpage with JavaScript and then submit that back to the server?</p> <p>I'm not so concerned with browser security issues. etc. as the implementation would be for <a href="http://msdn.microsoft.com/en-us/library/ms536471(vs.85).aspx" rel="noreferrer">HTA</a>. But is it po...
<p>Google is doing this in Google+ and a talented developer reverse engineered it and produced <a href="http://html2canvas.hertzen.com/" rel="noreferrer">http://html2canvas.hertzen.com/</a> . To work in IE you'll need a canvas support library such as <a href="http://excanvas.sourceforge.net/" rel="noreferrer">http://e...
<p>A great solution for screenshot taking in Javascript is the one by <a href="https://grabz.it" rel="nofollow noreferrer">https://grabz.it</a>. </p> <p>They have a flexible and simple-to-use screenshot API which can be used by any type of JS application.</p> <p>If you want to try it, at first you should get the auth...
8,532
<p>Please note that this question is from 2008 and now is of only historic interest.</p> <hr> <p>What's the best way to create an iPhone application that runs in landscape mode from the start, regardless of the position of the device?</p> <p>Both programmatically and using the Interface Builder.</p>
<h1>Historic answer only. Spectacularly out of date.</h1> <p>Please note that this answer is now hugely out of date/</p> <p>This answer is <strong>only a historical curiosity</strong>.</p> <hr /> <p>Exciting news! As discovered by Andrew below, this problem has been fixed by Apple in 4.0+.</p> <p>It would appear it is ...
<p>See this answer: <a href="https://stackoverflow.com/questions/2647786/landscape-mode-only-for-iphone-or-ipad/2647807#2647807">Landscape Mode ONLY for iPhone or iPad</a></p> <ol> <li>add orientation to plist</li> <li>shouldAutorotateToInterfaceOrientation = YES in all files</li> </ol> <p>Although if you're using mi...
2,288
<p>I am trying to give a ListBox drag and drop ordering functionality and I have hit a wall. I got it to work when I specify the list box items in xaml but it does not work when I bind to a list it no longer works because the items are no longer of a listboxitem type.</p> <p>I found this code <a href="http://blog.doba...
<p>Try finding out more info by <a href="http://weblogs.asp.net/scottgu/archive/2005/12/14/433194.aspx" rel="nofollow noreferrer">Logging ASP.NET Application Shutdown Events</a> </p>
<p>If after checking the logs and all the standard "App Pool Health" settings (the obvious), I would look for other processes that might be mucking around with your web.config file (check the timestamp on it), which of course causes the app to restart.</p> <p>I was once at a customer site and we couldn't figure out wh...
22,410
<p>Like in Windows Forms:</p> <p>Dim myForm as New AForm(Constr-arg1, Constr-arg2)</p> <p>myForm.Show</p> <p>... is there a similar way to Load a Page in ASP.Net. I would like to overload the Page Constructor and instantiate the correct Page Contructor depending on the situation.</p>
<p>Can you just link to the page passing parameters in the QueryString (after the ? in the URL) and then use them in the constructor (more likely PageLoad)</p>
<p>I think the best approach here for ASP.NET is to write User Control (*.ascx file) that represents page content, and load different controls based on current situation using Page.LoadControl() method. This solution is flexible enough, because only reference to control is its name. And this approach is much more usefu...
13,796
<p>I need to determine when my Qt 4.4.1 application receives focus.</p> <p>I have come up with 2 possible solutions, but they both don’t work exactly as I would like.</p> <p>In the first possible solution, I connect the focusChanged() signal from qApp to a SLOT. In the slot I check the ‘old’ pointer. If it ‘0’, the...
<p>I think you need to track the <a href="http://doc.qt.io/qt-4.8/qevent.html#Type-enum" rel="nofollow noreferrer">QEvent::ApplicationActivate</a> event.</p> <p>You can put an <a href="http://doc.qt.io/qt-4.8/qobject.html#eventFilter" rel="nofollow noreferrer">event filter</a> on your QApplication instance and then lo...
<p>Looking at the Qt docs it seems that focus events are created each time a widget gets the focus, so the sample code you posted won't work for the reasons you stated. </p> <p>I am guessing that QApplication::focusedChanged does not work the way you want because some widgets don't accept keyboard events so also retur...
8,813
<p>I enjoy developing algorithms using the STL, however, I have this recurring problem where my data sets are too large for the heap. </p> <p>I have been searching for drop-in replacements for STL containers and algorithms which are disk-backed, i.e. the data structures on stored on disk rather than the heap. </p> <p...
<p>I have implemented some thing very similar. Implementing the iterators is the most challenging. I used <strong><a href="http://www.boost.org/doc/libs/1_36_0/libs/iterator/doc/iterator_facade.html" rel="noreferrer">boost::iterator_facade</a></strong> to implement the iterators. Using <code>boost::iterator_facade</cod...
<p>I don't know much about the subject, but it might be possible to write an STL-like interface to a memory mapped file?</p> <p>edit: This approach might be suitable if you're trying to get at a specific part of a huge file. If you're attempting to do something with the entire file, you'll likely generate a huge numb...
18,014
<p>I'm building a web application that uses the Entity Framework. The files are located on a remote machine, the same is for the database and the web server.</p> <p>In visual studio (2k8sp1), the path to the project is: \\Server\Web\XXXX</p> <p>Now, I've generated the EF entities from the database, and later I've upd...
<p>I think you might be using the Entity Framework incorrectly. The edmx files are source code, and should be treated as such. They should be added to your project, checked into source control, and edited locally on the development machine.</p> <p>Try importing your model from your database into a local edmx and see i...
<p>You can also use <a href="http://blogs.msdn.com/adonet/archive/2008/06/20/edm-tools-options-part-1-of-4.aspx" rel="nofollow noreferrer">EDMTools2</a> tool for update your EDM Schema like that. Also you can use this tools routines in your code it's open source. Just copy inside of your project and call some functions...
27,355
<p>IVR Systems are so expensive and proprietary. </p> <p>The vendor systems I've used are all pretty weak... What is a good alternative to Genesys, Intervoice, etc.?</p>
<p><a href="http://www.asterisk.org/" rel="nofollow noreferrer">Asterisk</a> is open source and it includes the capability of defining and running IVR interactions.</p> <p>They have proprietary hardware for interaction with the PSTN or you can build services on top of VoiceOverIP protocols such as SIP (i.e. IP only).<...
<p>I would recommend Katalina 'VoiceGuide' - a windows-based CTI, IVR and dialler system at a reasonable price, supporting both tradtional POTS/ISDN telephony cards and VoIP. see: www.voiceguide.com</p>
45,839
<p>Currently, we're storing the user's HTTP_REFERER so we can redirect the user back to the previous page they were browsing before they logged in.</p> <p>Http Referer comes from the client and can be spoofed or blank. Is there a more secure/reliable method to deliver this handy user redirect?</p>
<p>Do you have sessions?</p> <p>If so, you can track on the server side which pages they have accessed in this session and send them back to the previous one.</p> <p>(Caching might mess this up, but you could set the cache-control: header appropriately)</p> <p>But this all seems more pain than gain. Is there any rea...
<p>Usually I pass it through with the login form.</p> <pre><code>&lt;form action="login" method="post"&gt; &lt;input type="hidden" name="url" value="... whatever the current url is ..."&gt; &lt;input type="text" name="username"&gt; &lt;input type="text" name="password"&gt; &lt;/form&gt; </code></pre>
39,860
<p>I use the commercial version of Jalopy for my Java projects but it doesn't work on Groovy files. IntelliJ has a serviceable formatter but I don't like requiring a particular IDE.</p>
<h1>Try &quot;BUSL&quot;</h1> <p><strong>2022-10-26 NOTE:</strong> HISTORIC. &quot;BUSL&quot; seems to be dead. <a href="https://web.archive.org/web/20200701144255/http://busl.tigris.org/" rel="nofollow noreferrer">Last archived webpage is from 2020</a>.</p> <p>I've found that <a href="http://busl.tigris.org/" rel="nof...
<p>I have yet to find a good solution for this, and I really wish that there was one. Regarding @Gizmomogwai's tip, it doesn't exactly work as you'd think.</p> <p>First of all, you need to export <code>JAVA_OPTS=-Dantlr.ast:groovy</code>. However, the file produced by <code>groovyc</code> is clearly not "pretty" in th...
15,843
<p>I've seen a number of 'code metrics' related questions on SO lately, and have to wonder what the fascination is? Here are some recent examples:</p> <ul> <li><a href="https://stackoverflow.com/questions/187289/what-code-metrics-convince-you-that-provided-code-is-crappy">what code metrics convince you that provided c...
<p>The answers in this thread are kind of odd as they speak of:</p> <ul> <li>"the team", like "the one and only beneficiary" of those said metrics;</li> <li>"the metrics", like they mean anything in themselves. </li> </ul> <p>1/ Metrics is not for <em>one</em> population, but for <em>three</em>:</p> <ul> <li>develop...
<p>We're programmers. We like numbers.</p> <p>Also, what are you going to do, NOT describe the size of the codebase because "lines of code metrics are irrelevant"?</p> <p>There is definitely a difference between a codebase of 150 lines and one of 150 million, to take a silly example. And it's not a hard number to g...
23,807
<p>Do you know of well designed open source applications that are instructive to analyse?</p> <p>Of course this question is strictly related to <a href="https://stackoverflow.com/questions/234276/open-source-examples-of-well-designed-applications">this other post</a>, but I am specifically interested in applications w...
<p><a href="http://www.djangoproject.com/" rel="nofollow noreferrer">Django</a> is a python package that is very nicely coded and designed.</p>
<p>Pyramid is Great !</p> <p><strong><a href="http://www.pylonsproject.org/" rel="nofollow">Pyramid - Web Framework</a></strong></p>
29,008
<p>Is it possible to write a template that changes behavior depending on if a certain member function is defined on a class?</p> <p>Here's a simple example of what I would want to write:</p> <pre><code>template&lt;class T&gt; std::string optionalToString(T* obj) { if (FUNCTION_EXISTS(T-&gt;toString)) retu...
<p>Yes, with SFINAE you can check if a given class does provide a certain method. Here's the working code:</p> <pre><code>#include &lt;iostream&gt; struct Hello { int helloworld() { return 0; } }; struct Generic {}; // SFINAE test template &lt;typename T&gt; class has_helloworld { typedef char one; s...
<pre><code>template&lt;class T&gt; auto optionalToString(T* obj) -&gt;decltype( obj-&gt;toString(), std::string() ) { return obj-&gt;toString(); } template&lt;class T&gt; auto optionalToString(T* obj) -&gt;decltype( std::string() ) { throw "Error!"; } </code></pre>
32,103
<p>I've seen N/A (always caps) used most often but I don't know if there is a standard. My data will be seen on Google so I would like to use the most recognized value.</p>
<p>'null' is a common term I've seen quite often, especially when it involves programming.</p>
<p>N/A is used for when there can't be a value, as the field/property does not apply in the context of the data item.</p> <p>Usually, when the field/property applies in the context of the data item, but it does not have a value, people either leave it blank. (Or put (empty), though that's certainly less often)</p>
20,382
<p>I'm looking for a fast language (ie. a language that can be compiled natively to achieve performance not more than 3 or 4 times slower than C), which supports portable continuations. By this I mean a continuation that can be serialized on one computer, and deserialized on another.</p> <p>I know that SISC can do th...
<p>Scala 2.8.0 will allow continuations, and they'll be portable.</p>
<p>Its possible to do serializable continuations in Java using Apache JavaFlow - if you do go that route then the Swing Continuations library at:</p> <p><a href="http://www.exploringexcellence.com/swingcontinuations/download.html" rel="nofollow noreferrer">http://www.exploringexcellence.com/swingcontinuations/download...
36,848
<p><strong>Is it possible to use <code>OpenID</code> for <em>both</em> <code>.NET</code> web sites and <code>PHP</code> websites (Apache/Linux)?</strong> </p> <p>I have a manager that wants <em>single sign-on for access to any/all web sites, regardless of which web server hosts a web site</em>. </p> <p>I create <co...
<p>For .NET: <a href="http://code.google.com/p/dotnetopenid/" rel="nofollow noreferrer">http://code.google.com/p/dotnetopenid/</a></p> <p>For PHP: <a href="http://openidenabled.com/php-openid/" rel="nofollow noreferrer">http://openidenabled.com/php-openid/</a></p>
<p>use the following library:</p> <p><a href="http://code.google.com/p/dotnetopenid" rel="nofollow noreferrer">http://code.google.com/p/dotnetopenid</a></p>
9,124
<p>If you have to use String.Replace() to replace test 50 times, you essentially have to create a new string 50 times. Does StringBuilder.Replace() do this more efficiently? E.g., should I use a StringBuilder if I'm going to be replacing a lot of text, even while I won't be appending any data to it?</p> <p>I'm using...
<p>This is exactly the type of thing StringBuilder is for - repeated modification of the same text object - it's not just for repeated concatenation, though that appears to be what it's used for most commonly.</p>
<p>Yes, it is. <code>String.Replace</code> always creates a new string – <code>StringBuilder.Replace</code> doesn't.</p>
36,625
<p>I have two classes, Foo and Bar, that have constructors like this:</p> <pre><code>class Foo { Foo() { // do some stuff } Foo(int arg) { // do some other stuff } } class Bar : Foo { Bar() : base() { // some third thing } } </code></pre> <p>Now I want to introd...
<p>No, this isn't possible. If you use Reflector to examine the IL that's generated for each constructor, you'll see why -- you'd end up calling both of the constructors for the base class. In theory, the compiler could construct hidden methods to accomplish what you want, but there really isn't any advantage over yo...
<p>You can use this code:</p> <pre><code>public Foo { public Foo() { this.InitializeObject(); } public Foo(int arg) : this() { // do something with Foo's arg } protected virtual void InitializeObject() { // initialize object Foo } } public Bar : Foo { ...
43,485
<p>I believe strongly in using unit-tests as part of building large multi-platform applications. We currently are planning on having our unit-tests within a separate project. This has the benefit of keeping our code base clean. I think, however, that this would separate the test code from the implementation of the unit...
<p>There are many Test Unit frameforks for C++. CppUnit is certainly not the one I would choose (at least in its stable version 1.x, as it lacks many tests, and requires a lot of redundant lines of codes). So far, my preferred framework is <a href="http://cxxtest.sf.net/" rel="noreferrer">CxxTest</a>, and I plan on eva...
<p>Cppunit is a direct equivalent of Junit for C++ applications <a href="http://cppunit.sourceforge.net/cppunit-wiki" rel="nofollow noreferrer">http://cppunit.sourceforge.net/cppunit-wiki</a></p> <p>Personally, I created the unit tests in a different project, and created a separate build configuration which built all ...
11,708
<p>I'm new to PHP and before I waste a lot of time doing things the hard way, I wanted to find out if there are shortcuts/techniques to creating PHP web forms apps. All this app will do is display web forms with data from 1 or more tables. In addition to displaying data, the user must be able to update the form and a...
<blockquote> <p>Unfortunately, I can't use any of the fancy PHP libraries such as CakePHP for this. I'm restricted to using the core PHP framework,</p> </blockquote> <p>Most PHP frameworks are written in PHP. So you wouldn't have to install anything to use them.</p> <p>That said, forms are rather non-trivial. Treat...
<p>I build all of my forms on top of a "fillInFormValues($html, $request, $formErrors);" function. See <a href="http://www.onlamp.com/pub/a/php/2006/03/16/autofill-forms.html" rel="nofollow noreferrer">my article at OnLamp</a> for details and full source code.</p>
32,062
<p>I'm a Lisp beginner. I'm trying to memoize a recursive function for calculating the number of terms in a <a href="http://en.wikipedia.org/wiki/Collatz_conjecture" rel="noreferrer">Collatz sequence</a> (for problem 14 in <a href="http://projecteuler.net/index.php?section=problems&amp;id=14" rel="noreferrer">Project E...
<p>I assume you're using Common-Lisp, which has separate namespaces for variable and function names. In order to memoize the function named by a symbol, you need to change its function binding, through the accessor `fdefinition':</p> <pre><code>(setf (fdefinition 'collatz-steps) (memoize #'collatz-steps)) (defun p14...
<p>A while ago I wrote a little memoization routine for Scheme that used a chain of closures to keep track of the memoized state:</p> <pre><code>(define (memoize op) (letrec ((get (lambda (key) (list #f))) (set (lambda (key item) (let ((old-get get)) (set! get (lambda...
32,008
<p>I am designing a new System and I have a lot of Interfaces that will grow over time with the system. What is the best practice to name this interfaces</p> <pre><code>ISomethingV01 ISomethingV02 etc </code></pre> <p>and I do this</p> <pre><code>public interface ISomething{ void method(); } </code></pre> <p>...
<p>Ideally, you shouldn't be changing your interfaces very often (if at all). If you do need to change an interface, you should reconsider its purpose and see if the original name still applies to it.</p> <p>If you still feel that the interfaces will change, and the interfaces changes are small (adding items) and yo...
<p>The purpose of an interface is to define an abstract pattern that at type must implement.</p> <p>It would be better implement as:</p> <pre><code>public interface ISomething public class Something1 : ISomething public class Something2 : ISomething </code></pre> <p>You do not gain anything in the form of code reus...
6,692
<p>As I understand it, anything created with an <strong>alloc</strong>, <strong>new</strong>, or <strong>copy</strong> needs to be manually released. For example:</p> <pre><code>int main(void) { NSString *string; string = [[NSString alloc] init]; /* use the string */ [string release]; } </code></pre> ...
<p>Yes, your second code snippit is perfectly valid.</p> <p>Every time -autorelease is sent to an object, it is added to the inner-most autorelease pool. When the pool is drained, it simply sends -release to all the objects in the pool.</p> <p>Autorelease pools are simply a convenience that allows you to defer sendin...
<p>Yes and no. You would end up releasing the string memory but "leaking" the NSAutoreleasePool object into memory by using drain instead of release if you ran this under a garbage collected (not memory managed) environment. This "leak" simply makes the instance of NSAutoreleasePool "unreachable" like any other object ...
9,113
<p>We're a distributed team of 5 developers working on rather large integrations project. We currently use SourceSafe (yes I <em>know</em> it sucks but it has just worked until recently and we've used it forever). Our biggest problem has recently become performance. Checking in and out project just takes forever and we...
<p>The <strong>check in</strong> of VSS is called <strong>commit</strong> in SVN. This operation is many times faster, as SVN will only transfer the changes (aka the "diff")you made to the files, while VSS will send the whole file and difference it on the server. </p> <p>the <strong>check out</strong> in SVN (getting ...
<p>I agree with @relentless about subversion, but I prefer to use command line. It takes a bit to learn but once you've learned you will be faster.</p> <p>Also, if performance is an important issue you might want to take a look at <a href="http://git.or.cz/" rel="nofollow noreferrer">http://git.or.cz/</a>, it is claim...
29,628
<p>I have a svn repository, R, that depends on a library, l, in another repository.</p> <p>The goal is that when someone checks out R, they also check out l. We want l to still be in its own repository so that l can be updated without dependence on R.</p> <p>I don't know much about external svn links, but I believe t...
<p>I suggest using a script wrapper for svn co. </p> <pre><code>#!/bin/sh svn co path://server/R svn-R git clone path://server/l git-l </code></pre> <p>Or similar.</p>
<p>I suggest using a script wrapper for svn co. </p> <pre><code>#!/bin/sh svn co path://server/R svn-R git clone path://server/l git-l </code></pre> <p>Or similar.</p>
9,834
<p>Does dot net have an interface like IEnumerable with a count property? I know about interfaces such as IList and ICollection which do offer a Count property but it seems like these interfaces were designed for mutable data structures first and use as a read only interface seems like an afterthought - the presence of...
<p>The key difference between the ICollection family and the IEnumerable family is the absence of certainty as to the count of items present (quite often the items will be generated/loaded/hydrated as needed) - in some cases, an Enumerable may not ever finish generating results, which is why the Count is missing.</p> ...
<p>You can get .Count on IEnumerable with an extension method if you add a reference to System.Linq (in 3.5 anyway).</p>
44,664
<p>I need to add a web part zone to a wiki page. I'm opening the page using SharePoint Designer, but there doesn't seem to be an obvious way (such as a menu) to add a Web Part Zone.</p>
<p>from: <a href="http://office.microsoft.com/en-us/sharepointdesigner/HA101513941033.aspx" rel="noreferrer">http://office.microsoft.com/en-us/sharepointdesigner/HA101513941033.aspx</a></p> <blockquote> <p>Insert a Web Part zone</p> <ol> <li>In Office SharePoint Designer 2007, open the page where you want to ...
<p>open your site in SPD -->insert-->sharepoint controls--> web part zone. Note that you are unable to add a web part zone in master pages</p>
6,041
<p>I do work in theoretical chemistry on a high performance cluster, often involving molecular dynamics simulations. One of the problems my work addresses involves a static field of N-dimensional (typically N = 2-5) hyper-spheres, that a test particle may collide with. I'm looking to optimize (read: overhaul) the the...
<p>How best to approach this for your problem depends on several factors that you have not described: - Will the same hypersphere arrangement be used for many particle collision calculations? - Are the hyperspheres uniform size? - What is the movement of the particle (e.g. straight line/curve) and is that movement affe...
<p>A Quad tree is a 2 dimensional tree, in which at each level a node has 4 children, each of which covers 1/4 of the area of the parent node.</p> <p>An Oct tree is a 3 dimensional tree, in which at each level a node has 8 children, each of which contains 1/8th of the volume of the parent node. Here is picture to hel...
10,347
<p>I have an ASP.NET webpage running under IIS that uses a common assembly that contains a singleton class. Should I implement a locking mechanism on the singleton to make it thread-safe? Or, will any connection to the webserver use the same instance of the singleton?</p> <p>Hopefully I'm asking this coherently.</p>...
<p>The usual pattern for .NET singletons creates a single instance per app domain. The usual situation in asp.net is that you have multiple threads running through the same app domain. This means you could very well have multiple threads running code in your singleton at the same time.</p> <p>You have to examine th...
<p>In .NET it is possible to implement a <a href="http://en.csharp-online.net/Singleton_design_pattern:_Thread-safe_Singleton" rel="nofollow noreferrer">Thread-safe Singleton</a> without using locks.</p>
43,051
<p>I am currently using osql with nant by calling a batch file with arguments. Here are the properties that are defined in my nant script (no, not real username/password values):</p> <pre><code>&lt;property name="project.config" value="debug" /&gt; &lt;property name="server" value="(local)" /&gt; &lt;property name="da...
<p>Here are a few suggestions</p> <ol> <li>To help diagnose the problem with the nant/batch script it would be helpful to echo out the full osql command (from the batch script) that is being executed. This is of course to make sure the osql.connection is being expanded properly when a username/pass is provided. </li> ...
<p>I think you might want to experiment with the ORDER of your parameters... I seem to remember being bitten in the past by OSQL sensitivities to parameter order.</p> <p>That's all I have for now... sorry.</p>
39,817
<p>Everything I can find in linq for aggregation has a "group by" clause. How would I write this query in LINQ? I have a list of date-value pairs, and I want to take the average of the values:</p> <pre><code>SELECT AVG(MySuff.Value) AS AvgValue FROM MyStuff </code></pre>
<p>morning Alan:</p> <pre><code>int count = (from a in myContext.MyStuff select a).Count(); </code></pre> <p>Assuming myContext is the DataContext.</p> <p>Note that is gives you immediate execution, which you may not want.</p> <p>You could instead store the results of the query in a var:</p> <pre><code...
<p>Thank you all for the help. Here is what I settled on, which works.</p> <pre><code>(from s in series select s).Average( a =&gt; a.Value ) </code></pre> <p>Regards, Alan...R</p>
38,306
<p>I know that garbage collection is automated in Java. But I understood that if you call <code>System.gc()</code> in your code that the JVM may or may not decide to perform garbage collection at that point. How does this work precisely? On what basis/parameters exactly does the JVM decide to do (or not do) a GC when i...
<p>In practice, it <em>usually</em> decides to do a garbage collection. The answer varies depending on lots of factors, like which JVM you're running on, which mode it's in, and which garbage collection algorithm it's using. </p> <p>I wouldn't depend on it in your code. If the JVM is about to throw an OutOfMemoryEr...
<p>I can't think of a specific example when it is good to run explicit GC. </p> <p>In general, running explicit GC can actually cause more harm than good, because an explicit gc will trigger a full collection, which takes significantly longer as it goes through every object. If this explicit gc ends up being called r...
9,206
<p>We all know that you can overload a function according to the parameters:</p> <pre><code>int mul(int i, int j) { return i*j; } std::string mul(char c, int n) { return std::string(n, c); } </code></pre> <p>Can you overload a function according to the return value? Define a function that returns different things ac...
<pre><code>class mul { public: mul(int p1, int p2) { param1 = p1; param2 = p2; } operator int () { return param1 * param2; } operator std::string () { return std::string(param2, param1 + '0'); } private: int param1; int param2; }; </code></pr...
<p>You could use a template, but then you'd have to specify the template parameter when you make the call.</p>
27,958
<p>Given a NxN matrix with 0s and 1s. Set every row that contains a <code>0</code> to all <code>0</code>s and set every column that contains a <code>0</code> to all <code>0</code>s.</p> <p>For example</p> <pre><code>1 0 1 1 0 0 1 1 1 0 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 </code></pre> <p>results in</p> <pre><code>0 0 0 0...
<p>Ok, so I'm tired as it's 3AM here, but I have a first try inplace with exactly 2 passes on each number in the matrix, so in O(NxN) and it is linear in the size of the matrix.</p> <p>I use 1rst column and first row as markers to know where are rows/cols with only 1's. Then, there are 2 variables l and c to remember ...
<p>While impossible given the constraints, the most space efficient way to do it is by traversing the matrix in an overlaping, alternating row/column fashion, which would make a pattern similar to laying bricks in a zig-zag fashion:</p> <pre><code>----- |---- ||--- |||-- ||||- </code></pre> <p>Using this, you would g...
44,057
<p>A beginner question, bear with me: I'm just wondering under what circumstances one should use a build tool like nant or msbuild? I'm working on a medium sized application (.net 3.0), every developer is doing his work and builds on his machine checking his code changes into the repository as he goes. Once we're all d...
<p>The short answer is always.</p> <p>Each developer should be building using the build script before checking code in. The people building the release should be using the build script to build the release. Your buildbots should be using the build script to build and test the code that's been checked in.</p> <p>Doing...
<p>If you want to automate anything it's good to use nant/msbuild. For example: 1. check in 2. build 3. test and code coverage</p>
24,544
<p>I was wondering about the best practices for indicating invalid argument combinations in Python. I've come across a few situations where you have a function like so:</p> <pre><code>def import_to_orm(name, save=False, recurse=False): """ :param name: Name of some external entity to import. :param save: S...
<p>I would just raise <a href="https://docs.python.org/3/library/exceptions.html#ValueError" rel="noreferrer">ValueError</a>, unless you need a more specific exception..</p> <pre><code>def import_to_orm(name, save=False, recurse=False): if recurse and not save: raise ValueError("save must be True if recurs...
<p>I'm not sure I agree with inheritance from <code>ValueError</code> -- my interpretation of the documentation is that <code>ValueError</code> is <em>only</em> supposed to be raised by builtins... inheriting from it or raising it yourself seems incorrect.</p> <blockquote> <p>Raised when a built-in operation or fu...
31,972
<p>I created a custom login page using Forms Authentication and using a sQL DB to store user data. I am able to create a session variable from the username, but wondering if it is possible to pull a separate field and create a session variable based on that. I would like the session variable to be based off a SalesNu...
<p>Service Pack 1 added the following feature:</p> <p>If you "anyfile.js" and "anyfile-vsdoc.js" in the same directory, then any references to "anyfile.js" will automagically be converted to a reference to "anyfile-vsdoc.js" behind the scenes.</p> <p>Add an empty file next to your plugin with "-vsdoc" appended to the...
<p>It could be that third party JavaScript plugin you're using has some errors in it.<br> I would check the code in <a href="http://www.jslint.com/" rel="nofollow noreferrer">JSLint</a> and directed this question to the author of the plugin.<br> As for the question itself: I don't think you can exclude it if it's a par...
36,249
<p>My print popped out from the bed and glued to the nozzle. As the printer was printing next hour or so, a lot of pla was extruded and formed on the nozzle. </p> <h2>I'm wondering what will be the best way to remove pla from the nozzle without overheating wires?</h2> <p>a remark: was trying to heat the nozzle over 1...
<p>If you grab the blob with a pliers and twist, all or most of it may pop off. If not, heat the extruder up perhaps 10 degrees higher than usual, and wait for the external gunk to soften up and then pull it off.</p> <h3>edit :</h3> <p>Well, if it won't get hot enough, then try using an external source such as a sold...
<p>I would suggests to use a heat gun and carefully warm up the PLA to be soft and remove it carefully like a big piece of Play-Doh. Using the extruder to heat up the PLA don't sound like the best idea, for me, because the inner PLA will be fluid and it could be a bigger mess than it is up to now.</p>
898
<p>I need a modal dialog to gather some user input. I then need the same data to be consumed by the application MainFrame.</p> <p>Usually my Modal Dialog would have a pointer to some DataType able to store what I need, and I'd be passing this object by reference from the MainFrame in order to be able to recover data ...
<p>Since you are passing data once the user has closed the dialog (presumably on DialogResult.OK), you can easily do this without having a MainFrame reference.</p> <p>So say you have a TextBox on your dialog, called userNameTextBox and a button that ends the dialog with the OK result. You can either make the userNameT...
<p>Normally you can use a single class or other datatype to transfer data. So the dialog is used to change the properties of the class. Why doesn't this feel right?</p> <p>[humor] With mainframe, I assume you don't mean the big old (althoug still alive and kicking) computers. Else, I think TCP/IP will be a good choise...
31,913
<p>Is there a way to set/change the keyboard input language in Java (eg from English to German)? </p> <p>Example Use Case: Script to be used for playback is recorded (typed in) on a German keyboard. The automated playback is done on a English keyboard...fails if keyboard is not set to German automatically before scrip...
<p>The keyboard input map is managed entirely by the operating system on every platform that I'm familiar with. Java provides no APIs for manipulating this in a cross-platform manner. I would investigate native APIs that you could manipulate via <a href="https://github.com/twall/jna" rel="nofollow noreferrer">JNA</a>...
<p>In java, you can use the InputContext class. See its API or do google search on InputContext.</p>
35,613
<p>I have been looking into IKVMing Apache's FOP project to use with our .NET app. It's a commercial product, and looking into licensing, IKVM runs into some sticky areas because of its use of GNU Classpath. From what I've seen, no one can say for sure if this stuff can be used in a commercial product. Has anyone us...
<p>There are multiple issues here as ikvm is currently being transitioned away from the GNU classpath system to Sun's OpenJDK. Both are licensed as GPL+Exceptions to state explicitly that applications which merely use the OpenJDK libraries will not be considered derived works.</p> <p>Generally speaking, applications ...
<p>I'm not a lawyer but all licenses mentioned are okay to be used in commercial products as long as you don't make any changes and claim the code is yours. </p> <p>I think if you don't wanna risk anything you should consult a lawyer.</p>
3,217
<p>It is to my understanding that one should use a forward-class declaration in the event ClassA needs to include a ClassB header, and ClassB needs to include a ClassA header to avoid any circular inclusions. I also understand that an <code>#import</code> is a simple <code>ifndef</code> so that an include only happens ...
<p>If you see this warning:</p> <blockquote> <p>warning: receiver 'MyCoolClass' is a forward class and corresponding @interface may not exist</p> </blockquote> <p>you need to <code>#import</code> the file, but you can do that in your implementation file (.m), and use the <code>@class</code> declaration in your head...
<p>Forward declaration just to the prevent compiler from showing error.</p> <p>the compiler will know that there is class with the name you've used in your header file to declare.</p>
41,752
<p>I've seen a few sites that have a flash app which takes video from the users webcam and manipulates it. One example is the flash barcode reader <a href="http://www.renaun.com/flex2/BarcodeReader/BarcodeReader.html" rel="noreferrer">http://www.renaun.com/flex2/BarcodeReader/BarcodeReader.html</a> .</p> <p>I want us...
<p>There are several articles with sample code for this on adobes site. I would recommend you to go through this tutorial as it will guide you through all the necessary steps along with sample code:</p> <p><a href="http://www.adobe.com/devnet/flash/articles/webcam_motion.html" rel="nofollow noreferrer"><a href="http:/...
<p>What you need is <a href="http://www.adobe.com/products/flashmediainteractive/" rel="nofollow noreferrer">Adobe Flash Media Interactive Server 3</a> . Just download it and take a look at "sample_guestbook" sample application.</p>
34,625
<p>I'm creating an installation script for an application that I'm developing and need to create databases dynamically from within PHP. I've got it to create the database but now I need to load in several .sql files. I had planned to open the file and mysql_query it a line at a time - until I looked at the schema files...
<p>I'm getting the feeling that everyone here who's answered this question doesn't know what it's like to be a web application developer who allows people to install the application on their own servers. Shared hosting, especially, doesn't allow you to use SQL like the "LOAD DATA" query mentioned previously. Most share...
<p>I use this all the time:</p> <pre><code>$sql = explode(";",file_get_contents('[your dump file].sql'));// foreach($sql as $query) mysql_query($query); </code></pre>
17,800
<p>How do I append the contents of one list at the end of another list?</p>
<p><a href="http://java.sun.com/javase/6/docs/api/java/util/List.html#addAll(java.util.Collection)" rel="noreferrer"><code>List.addAll()</code></a></p>
<pre><code>List finalist = a + b </code></pre> <p>Example:</p> <pre><code>List a = [1,4] List b = [2,3] List c = a+b </code></pre> <p>Result:</p> <pre><code>c = [1, 4, 2, 3] </code></pre>
48,994
<p>I'm looking into integrating jBPM with my current project, so far so good just including the jpdl jar in my ear and using the spring modules 0.8 jbpm module, however I've got to have a reasonable way of going from my changes to to the process definition in the designer to deployment in production.</p> <p>The path ...
<p>If you want to avoid going down the <code>.par</code> route, it's easy to write some simple Java code to deploy a new process definition version to your database. Something like</p> <pre><code>JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance("jbpm.cfg.xml")); ProcessDefinition processDefinition =...
<p>Why not use the ant task extensions provided by JBPM specifically <a href="http://docs.jboss.org/jbpm/v3/javadoc/org/jbpm/ant/DeployProcessTask.html" rel="nofollow noreferrer"><code>DeployProcessTask</code></a>. You can deploy to different environments having just a single <code>.par</code> file and the correspondin...
33,091
<p>Is there a generic container implementing the 'set' behaviour in .NET?</p> <p>I know I could just use a <code>Dictionary&lt;T, Object&gt;</code> (and possibly add <code>nulls</code> as values), because its keys act as a set, but I was curious if there's something ready-made.</p>
<p><code>HashSet&lt;T&gt;</code> in .NET 3.5</p>
<p>I use the Iesi.Collections. namespace that comes with NHibernate (docs <a href="http://monogis.org/monogis_doc/html/Iesi.Collections.html" rel="nofollow noreferrer">here</a>) - maybe worth considering if you are in .NET &lt; 3.5</p>
46,098
<p>I have a regex call that I need help with.</p> <p>I haven't posted my regex, because it is not relevant here. What I want to be able to do is, during the Replace, I also want to modify the ${test} portion by doing a Html.Encode on the entire text that is effecting the regex.</p> <p>Basically, wrap the entire text ...
<p>Heres an implementation of this I've used to pick out special replace strings from content and localize them.</p> <pre><code> protected string FindAndTranslateIn(string content) { return Regex.Replace(content, @"\{\^(.+?);(.+?)?}", new MatchEvaluator(TranslateHandler), RegexOptions.Ignore...
<p>If you do a Regex.Match, the resulting match objects group at the 0th index, is the subset of the intput that matched the regex.</p> <p>you can use this to stitch in the bold tags and encode it there.</p>
6,892
<p>Does anyone have a trusted Proper Case or PCase algorithm (similar to a UCase or Upper)? I'm looking for something that takes a value such as <code>"GEORGE BURDELL"</code> or <code>"george burdell"</code> and turns it into <code>"George Burdell"</code>.</p> <p>I have a simple one that handles the simple cases. Th...
<p>Unless I've misunderstood your question I don't think you need to roll your own, the TextInfo class can do it for you.</p> <pre><code>using System.Globalization; CultureInfo.InvariantCulture.TextInfo.ToTitleCase("GeOrGE bUrdEll") </code></pre> <p>Will return "George Burdell. And you can use your own culture if th...
<p>You do not mention which language you would like the solution in so here is some pseudo code.</p> <pre><code>Loop through each character If the previous character was an alphabet letter Make the character lower case Otherwise Make the character upper case End loop </code></pre>
5,208
<p>What are the key differences between <a href="http://www.w3.org/TR/REC-html40/" rel="noreferrer">HTML4</a> and <a href="http://www.w3.org/html/wg/html5/" rel="noreferrer">HTML5 draft</a>?</p> <p>Please keep the answers related to changed syntax and added/removed html elements.</p>
<p>HTML5 has several goals which differentiate it from HTML4.</p> <h1>Consistency in Handling Malformed Documents</h1> <p>The primary one is <em>consistent, defined error handling</em>. As you know, HTML purposely supports 'tag soup', or the ability to write malformed code and have it corrected into a valid document...
<p>HTML 5 invites you give add a lot of semantic value to your code. What's more, there are natives solution to embed multimedia content.</p> <p>The rest is important, but it's more technical sugar that will save you from doing the same stuff with a client programming language.</p>
16,311
<p>I am developing RoR application that works with legacy database and uses ActiveScaffold plugin for fancy CRUD interface.</p> <p>However one of the tables of my legacy db has composite primary key. I tried using Composite Keys plugin to handle it, but it seems to have conflicts with ACtiveScaffold: I get the followi...
<p>I think your best bet may be checking the <a href="http://groups.google.com/group/activescaffold" rel="nofollow noreferrer">ActiveScaffold Google Group</a> as it's monitored by core developers of ActiveScaffold and they would ultimately be able to solve your problem and explain why composite keys with the plugin won...
<p>No, I have not received any reply from the group and I am not sure if ActiveScaffold is actively maintained yet.</p> <p>After some time playing with ActiveScaffold, I ended up implementing my own CRUD interface from the scratch.</p>
27,448
<p>I've got some RadioButtons in my XAML...</p> <pre><code>&lt;StackPanel&gt; &lt;RadioButton Name="RadioButton1" GroupName="Buttons" Click="ButtonsChecked" IsChecked="True"&gt;One&lt;/RadioButton&gt; &lt;RadioButton Name="RadioButton2" GroupName="Buttons" Click="ButtonsChecked"&gt;Two&lt;/RadioButton&gt; ...
<p>In order for commands to work you need to set up bindings in either your xaml or code behind. These command bindings must reference public static fields that have been previously declared. </p> <p>Then in your buttons Command attribute you will then need to also reference these same commands.</p> <pre><code>&lt;Wi...
<p><strong>Better Solution using WPF MVVM Design Pattern:</strong></p> <p>Radio Button Control XAML to Modelview.vb/ModelView.cs :</p> <pre><code>XAML Code: &lt;RadioButton Content="On" IsEnabled="True" IsChecked="{Binding OnJob}"/&gt; &lt;RadioButton Content="Off" IsEnabled="True" IsChecked="{Binding OffJob}"/&gt; <...
31,815
<p>For example</p> <pre><code>int f(int a) { ... return a &gt; 10; } </code></pre> <p>is that considered acceptable (not legal, I mean is it ``good code''), or should it always be in a conditional, like this</p> <pre><code>int f(int a) { ... if (a &gt; 10) return 1; else return 0; } </code...
<p>This is absolutely acceptable! In fact, Joel mentioned this on the latest stackoverflow podcast. He said it was the one thing he's had to show almost every programmer that starts at Fog Creek.</p>
<p>I'll typically do the former over the latter.</p>
16,589