instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>The kind of simulation game that I have in mind is the kind where you have things to build in various locations and workers/transporters that connect such locations.</p> <p>Something more like the Settlers series.</p> <p>Let's assume I don't want any graphics at the moment, <strong>that</strong> I think I can mana...
<p>The normal approach does not use threading at all, but rather implements entities as state-machines. Then your mainloop looks like this:</p> <pre><code> while( 1 ) { foreach( entity in entlist ) { entity-&gt;update(); } render(); } </code></pre>
<p>I would avoid making a separate class for each entity because then you'll have situations where you're either repeating code for shared capabilities, or you'll have a funky inheritance tree.</p> <p>I'd argue that what you want is a single class and objects with functionality composed onto it. I saw an article on a ...
19,389
<p>I'd like to find all the types inheriting from a base/interface. Anyone have a good method to do this? Ideas?</p> <p>I know this is a strange request but its something I'm playing with none-the-less.</p>
<p>Use Assembly.GetTypes() to get all the types, and Type.IsAssignableFrom() to check for inheritance. Let me know if you need code - and also whether or not you're using .NET 3.5. (A lot of reflection tasks like this are simpler with LINQ to Objects.)</p> <p>EDIT: As requested, here's an example - it finds everything...
<p>Or for subclasses of a base class:</p> <pre><code>var a = Assembly.Load("My.Assembly"); foreach (var t in a.GetTypes().Where(t =&gt; t.IsSubClassOf(typeof(MyType))) { // there you have it } </code></pre>
39,822
<p>Are C# enums typesafe?</p> <p>If not what are the implications? </p>
<p>To give a slightly different answer... while the values are type-safe from the casting perspective, they are still unchecked once they have been cast - i.e.</p> <pre><code>enum Foo { A = 1, B = 2, C = 3 } static void Main() { Foo foo = (Foo)500; // works fine Console.WriteLine(foo); // also fine - shows...
<p>Yes.</p> <p>C#: enum types:</p> <p>-A type-safe enumeration of named values.</p> <p>-Prevents programming errors</p> <p>-User can control underlying type (defaults to int)</p> <p>-Also can control underlying values</p>
25,567
<p>I want to make a really simple iphone app: one screen with a single button... when the button is tapped a new screen appears. That's it. No animations, nothing,</p> <p>I've tried endlessly to make the NavBar sample project do this... and it works but only if I use a UINavigationController with a table that I can...
<p>One way you could do this is to create a new UIView and then when the button is pressed add that new UIVIew as a subview, therefore making it what you see.</p> <p>If you make the new view its own subclass of UIView you would do something like this.</p> <pre><code>LoginView *login = [[LoginView alloc] initWithFrame...
<p>The correct way to do this is set up your project with a <code>UINavigationController</code>. In your root view controller, add your button in the view controllers's view. Then in <code>viewDidLoad</code>, register for <code>UIControlEventTouchUpInside</code> events from you button. Then, in your event callback, cal...
29,494
<p>I'm trying to write a small app that monitors how much power is left in a notebook battery and I'd like to know which Win32 function I could use to accomplish that.</p>
<p>For Vista and up you can use <a href="http://msdn.microsoft.com/en-us/library/aa373196(VS.85).aspx" rel="noreferrer">RegisterPowerSettingNotification</a></p> <p>For earlier functions see the <a href="http://msdn.microsoft.com/en-us/library/aa373163(VS.85).aspx" rel="noreferrer">Power Management Functions</a> in thi...
<p>There is a very detailed article in the following link, as well as a n example project (tested working on Win8.1): <a href="http://www.codeproject.com/Articles/15829/Vista-Goodies-in-C-Monitoring-the-Computer-s-Power" rel="nofollow">http://www.codeproject.com/Articles/15829/Vista-Goodies-in-C-Monitoring-the-Computer...
28,896
<p>What is the difference in displaying xml data using html browser such as firefox,internet exporer,netscape navigator etc. in terms of how text, images etc are display on a computer screen?</p>
<p>The question is a little bit confusing, since XML is a base technology, it does not define how to represent anything so the question itself hasn't a lot of sense. </p> <p>A plain xml file will be displayed as a collapsable tree of text data since any xml file is just a structured text file that follows some basic a...
<p>some specialties of Internet Explorer (in contrast to simple text editors) is that you should be aware of are e.g. that white space is removed and empty tags are replaced by single elements ( becomes ).</p> <p>IE also will execute any XSL stylesheet included in your XML.</p>
42,216
<p>I have the following requirements:</p> <p>I need a api that works on CE (x86) + .NET Compact Framework to play videos (Similar to CorePlayer API... Just free)?</p> <p>Is their anything else available or must I use CorePlayer?</p>
<p>You could use the MediaPlayer with COM interop. Have a look at <a href="http://www.eggheadcafe.com/software/aspnet/30991558/windows-media-player-for.aspx" rel="nofollow noreferrer">this</a> and <a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=64938&amp;SiteID=1" rel="nofollow noreferrer">this</a>.</p> ...
<p>DirectShow? Check out <a href="http://www.geekpage.jp/en/programming/directshow/renderfile.php" rel="nofollow noreferrer">this page</a> for a starting point. Provided that DirectShow is present on your CE, which I don't know...</p> <p><strong>EDIT</strong>: Since you can use DirectShow, I'd like to add a bit.</p> ...
42,855
<p>I am looking for a concise way to check a value to see if it is nil or zero. Currently I am doing something like:</p> <pre><code>if (!val || val == 0) # Is nil or zero end </code></pre> <p>But this seems very clumsy.</p>
<p>Objects have a <a href="http://ruby-doc.org/core/Object.html#method-i-nil-3F" rel="noreferrer"><em>nil?</em> method</a>.</p> <pre><code>if val.nil? || val == 0 [do something] end </code></pre> <p>Or, for just one instruction:</p> <pre><code>[do something] if val.nil? || val == 0 </code></pre>
<pre><code>val ||= 0 if val == 0 # do something here end </code></pre>
25,711
<p>Are there any libraries out there that do this? Playing around with Common Lisp it seems like this would be one of the most useful things to lower barrier of entry for newcomers. ASDF seems mostly designed for deployment, not for rapid prototyping and development. Following threads on comp.lang.lisp it seems like ...
<p><a href="http://xach.livejournal.com/278047.html" rel="noreferrer">Zach Beane wrote</a> how he nowadays starts new Common Lisp projects by using Quicklisp and Quickproject. This might be along the lines you want.</p>
<blockquote> <p>it's designed for power not usability</p> </blockquote> <p>that's how most Lisp gurus like it.</p>
34,000
<p>What's a quick and easy way to view and edit ID3 tags (artist, album, etc.) using C#?</p>
<p>Thirding <a href="https://github.com/mono/taglib-sharp" rel="noreferrer">TagLib Sharp</a>.</p> <pre><code>TagLib.File f = TagLib.File.Create(path); f.Tag.Album = "New Album Title"; f.Save(); </code></pre>
<p>I wrapped mp3 decoder library and made it available for .net developers. You can find it here:</p> <p><a href="http://sourceforge.net/projects/mpg123net/" rel="nofollow noreferrer">http://sourceforge.net/projects/mpg123net/</a></p> <p>Included are the samples to convert mp3 file to PCM, and read ID3 tags.</p>
9,378
<p>I'm working on a .net post-commit hook to feed data into OnTime via their Soap SDK. My hook works on Windows fine, but on our production RHEL4 subversion server, it won't work when called from a shell script.</p> <pre> #!/bin/sh /usr/bin/mono $1/hooks/post-commit.exe "$@" </pre> <p>When I execute it with parameter...
<p>It is normal for some processes to hang around for a while after they close their stdout (ie. you get an end-of-file reading from them). You need to call <code>proc.WaitForExit()</code> after reading all the data but before checking ExitCode.</p>
<p>Just a random thought that might help with debugging. Try changing your shell script to:</p> <pre><code>#!/bin/sh echo /usr/bin/mono $1/hooks/post-commit.exe "$@" </code></pre> <p>Check and see if the line it prints matches the command you're expecting it to run. It's possible your command line argument handling...
7,811
<p>What are some good solutions for handling automatic web based software updates for windows forms projects? I am aware of microsoft one-click, but am not interested in it at this time.</p>
<p>ClickOnce is good for cookie cutter stuff, but has some limitations around security (i.e. can't create a desktop icon, no access to COM, etc)</p> <p>Assuming you are using MSI to install your application. Use WIX (<a href="http://wix.sourceforge.net/" rel="nofollow noreferrer">http://wix.sourceforge.net/</a>) to c...
<p>but <a href="http://msdn.microsoft.com/en-us/library/t71a733d(VS.80).aspx" rel="nofollow noreferrer">ClickOnce</a> is the best you can have and you can select if users need to download the new version, use the old ones, go back versions, etc...</p> <p>you can always built your own solution, check the version number...
25,220
<p>I want a table <a href="http://joomlicious.com/mootable/" rel="nofollow noreferrer">similar to this one</a>, but where the user can adjust the height of the table as well as sort it. How can I do this?</p>
<p>I found the good one here <a href="http://groups.google.com/group/flexigrid/?pli=1" rel="nofollow noreferrer">http://groups.google.com/group/flexigrid/?pli=1</a></p>
<p><a href="http://demos111.mootools.net/Resizable" rel="nofollow noreferrer">http://demos111.mootools.net/Resizable</a></p>
45,454
<p>I'm retrieving a gzipped web page via curl, but when I output the retrieved content to the browser I just get the raw gzipped data. How can I decode the data in PHP?</p> <p>One method I found was to write the content to a tmp file and then ...</p> <pre><code>$f = gzopen($filename,"r"); $content = gzread($filename,...
<p>I use curl and:</p> <pre><code>curl_setopt($ch, CURLOPT_ENCODING , &quot;gzip&quot;); </code></pre>
<p>Versatile GUNZIP function:</p> <pre> function gunzip($zipped) { $offset = 0; if (substr($zipped,0,2) == "\x1f\x8b") $offset = 2; if (substr($zipped,$offset,1) == "\x08") { # file_put_contents("tmp.gz", substr($zipped, $offset - 2)); return gzinflate(substr($zipped, $...
40,029
<p>My problem is that I set some breakpoints in my code and some of them aren't working. In some places it complains about "Unresolved Breakpoint". </p> <p>Does anyone have any clue why this is happening? I am using gdb, by the way.</p> <p>EDIT: Yes, of course is compiled with debug information. It only happens at so...
<p>Could it be that you are trying to set breakpoints in a shared library that has not been loaded yet. That won't work until the library has loaded. Newer gdb allow to set deferred breakpoints, but that may not (yet) be supported by CDT. A workaround is to set a breakpoint in a place that is available from the beginni...
<p>I have found that using F8 (resume) doesn't stop at my breakpoints. But, if I have Stop On Startup : main set then then step over my code (F5/F6) then my breakpoints are hit. I don't have any special compiler options other than -g or -g3. Hope that help...</p>
24,994
<p>Are there any libraries or guides for how to read and parse binary data in C?</p> <p>I am looking at some functionality that will receive TCP packets on a network socket and then parse that binary data according to a specification, turning the information into a more useable form by the code.</p> <p>Are there any ...
<p>The standard way to do this in C/C++ is really casting to structs as 'gwaredd' suggested</p> <p>It is not as unsafe as one would think. You first cast to the struct that you expected, as in his/her example, <strong>then</strong> you test that struct for validity. You have to test for max/min values, termination s...
<p>I'm not really understand what kind of library you are looking for ? Generic library that will take any binary input and will parse it to unknown format? I'm not sure there is such library can ever exist in any language. I think you need elaborate your question a little bit. </p> <p><strong>Edit</strong>:<br> Ok,...
41,604
<p>When restoring a SQL Server Database, I notice that there are 3 different Recovery States to choose from:</p> <ul> <li>Restore with Recovery</li> <li>Restore with No Recovery</li> <li>Restore with Standby</li> </ul> <p>I've always left it at it's default value, but what do they all mean?</p> <p>(Preferably in lay...
<p>GateKiller,</p> <p>In simple terms (and not a copy-paste out of the SQLBOL) so you can understand the concepts:</p> <p>RESTORE WITH RECOVERY uses the backup media file (eg. fulldata.bak) to restore the database to back to the time that backup file was created. This is great if you want to go back in time to resto...
<p>From Books On line, i think it is pretty clear after you read it</p> <p><strong>NORECOVERY</strong></p> <p>Instructs the restore operation to not roll back any uncommitted transactions. Either the NORECOVERY or STANDBY option must be specified if another transaction log has to be applied. If neither NORECOVERY, RE...
2,951
<p>Which one do you prefer to store text in your database? The original casing of the data, or some kind of normalization. Also, should I enforce this with triggers? or should I preprocess input data with client code?</p> <p>I ask you, because I'm not sure about if there is any difference, besides additional processin...
<p>Store in original case, unless there is a reason to do otherwise. The time spent to upper or lower case the data is likely very small, and you never know when you'll want the real, original data back in the future.</p>
<p>I wouldn't worry about it, just format it how you need it to be used on output.</p>
37,134
<p>Is it possible to reorder an already generated PDF file programmatically, and using as little resources as possible, as this will need to be ran on ~8000 PDFs every month or so?</p> <p>We are currently using iTextSharp to merge the PDF’s in to larger PDF’s, but iTextsharp’s Documentation does not really explain muc...
<p><a href="http://en.wikipedia.org/wiki/Multivariate_testing" rel="nofollow noreferrer">Multivariate testing</a> and reporting is a great way to actually measure these kind of things. </p> <p>It allows you to test what combination of page elements has the greatest conversion rate, providing continual improvement on ...
<p>The first way can be fully subjective or partly quantified: user complaints and positive feedbacks. The problem with this is that you may have some strong biases when it comes to filter those feedbacks, so you better make as quantitative as possible. Having some ticketing system to file every report from the users a...
18,893
<p>Trying to build a dashboard using Oracle's Brio. I have to access 6 different databases to grab the same type of data, aggregate it and display it. Except that when I do it, Brio grabs the data from the first source just fine. When I grab the data from the second data source, Brio replaces the original data with ...
<pre><code>bool isSubset = !t2.Except(t1).Any(); </code></pre>
<p>Try this</p> <pre><code>static bool IsSubSet&lt;A&gt;(A[] set, A[] toCheck) { return set.Length == (toCheck.Intersect(set)).Count(); } </code></pre> <p>The idea here is that Intersect will only return the values that are in both Arrays. At this point if the length of the resulting set is the same as the origina...
43,159
<p>I have two projects in CPP. One defines a function which I'd like to invoke from the other. I added a reference to the first project. I still get the message of "identifier not found". Assuming that the CPP file in the first project doesn't have a header, how do I make the second project know about its functions?</p...
<p>If the first project doesn't have a header and you don't want to add one, then use the <code>extern</code> keyword to declare a prototype for the function you want to call in the second project source:</p> <pre><code>extern function_in_first_project(int args_go_here); </code></pre> <p>Make 100% sure that the funct...
<p>you could probably just add this to the top of the .cpp file of the second project:</p> <pre><code>#include "first_project_header_file.h" </code></pre>
26,408
<p>A client of our has recently upgraded a ASP.NET 1.1 web application to ASP.NET that uses COM+ transaction processing and received the following exception while trying to process a transaction:</p> <blockquote> <p>Exception Type: System.Transactions.TransactionManagerCommunicationException<br /> Message: Comm...
<p>You'll need to have network DTC access enabled on both your XP workstation and your windows 2003 machine. Also, if your application is only published internally, you can turn off incoming caller authentication and set it to "no authentication".</p>
<p>In case you need help finding the MSDTC settings mentioned in the other answers (like I did), the following link explains how to configure MSDTC on server 2003.</p> <p><a href="http://itknowledgeexchange.techtarget.com/sql-server/how-to-configure-dtc-on-windows-2003/" rel="nofollow">http://itknowledgeexchange.techt...
24,680
<p>I've got a code that lists the running application on a win32 box, and then displays theirs icons.</p> <p>So far so good, I get the hwnd of the app, then call for GetClassLong(hwnd,GCL_HICONSM), and everything's fine.</p> <p>But the case of a java apps is a pain to deal with, as the process answering to my calls ...
<p>Mmm, it can be done, because <a href="http://www.teamcti.com/pview/prcview.htm" rel="nofollow noreferrer" title="Process Viewer">Process Viewer</a> has a Show Applications button which does that (even if the main view shows the Java's icon). Alas this freeware isn't open source, so it won't tell its secret... :-(</p...
<p>Mmm, it can be done, because <a href="http://www.teamcti.com/pview/prcview.htm" rel="nofollow noreferrer" title="Process Viewer">Process Viewer</a> has a Show Applications button which does that (even if the main view shows the Java's icon). Alas this freeware isn't open source, so it won't tell its secret... :-(</p...
26,079
<p>Hypothetical situation:</p> <p>Suppose I ran a hosting firm where I hosted subdomains for people. You could sign up and give me a few bucks a month, and I'd give you yourname.mycompany.com.</p> <p>Now, say I wanted mail.*.mycompany.com to point to one server and www.*.mycompany.com to point to another.</p> <p>Is ...
<p>A horizontal swipe on a table row is already a standard UI behavior that causes that row to be deleted. Don't go changing standard UI paradigms -- it confuses users and makes them dislike your app.</p>
<p>Just call a touch cancel method there check the swipe is occured ir not with touch points.Then do your functionality</p>
44,565
<p>I use Visual Studio's "Code Snippet" feature pretty heavily while editing c# code. I always wished I could use them while typing out my aspx markup. </p> <p>Is there a way to enable code snippet use in an aspx file editor window?</p> <p>Are there any third party tools that perform this?</p> <p>If you're familia...
<p>Perhaps you might think of trying <a href="http://devexpress.com/coderush" rel="nofollow noreferrer">Coderush</a> which has a lot more to offer than the basic snippets found in VS. It's template facility can operate in vb, cs, aspx, html, xml and sql files.</p>
<p>@Rory-Becker Coderush is exactly what I've been looking for!!</p> <p>I had previously posted that Coderush costs $99, but it costs $249.</p> <p>@harriyott </p> <p>Codesmith has something called Active Snippets. It only comes with the professional version, which costs $399</p> <p><a href="http://www.codesmitht...
25,189
<p>For example, if I have a page located in Views/Home/Index.aspx and a JavaScript file located in Views/Home/Index.js, how do you reference this on the aspx page?</p> <p>The example below doesn't work even though the compiler says the path is correct</p> <pre><code>&lt;script src="Index.js" type="text/javascript"&gt...
<p>You can use the VirtualPathUtility.ToAbsolute method like below to convert the app relative url of the .js file to an absolute one that can be written to the page:</p> <pre><code>&lt;script type="text/javascript" src="&lt;%=VirtualPathUtility.ToAbsolute("~/Views/Home/Index.js") %&gt;"&gt;&lt;/script&gt; </code></pr...
<p>If you re-route your pages to a custom RouteHandler, you can check for existence of files before handling the RequestContext to the MvcHandler class.</p> <p>Example (not complete):</p> <pre><code>public class RouteHandler : IRouteHandler { public IHttpHandler GetHttpHandler(RequestContext requestContext) ...
10,457
<p>I refactored a slow section of an application we inherited from another company to use an inner join instead of a subquery like:</p> <pre><code>WHERE id IN (SELECT id FROM ...) </code></pre> <p><strong>The refactored query runs about 100x faster.</strong> (~50 seconds to ~0.3) I expected an improvement, but can an...
<p>A "correlated subquery" (i.e., one in which the where condition depends on values obtained from the rows of the containing query) will execute once for each row. A non-correlated subquery (one in which the where condition is independent of the containing query) will execute once at the beginning. The SQL engine make...
<p>With a subquery, you have to re-execute the 2nd SELECT for each result, and each execution typically returns 1 row. </p> <p>With a join, the 2nd SELECT returns a lot more rows, but you only have to execute it once. The advantage is that now you can join on the results, and joining relations is what a database is ...
17,064
<p>I am trying to pass a member function within a class to a function that takes a member function class pointer. The problem I am having is that I am not sure how to properly do this within the class using the this pointer. Does anyone have suggestions?</p> <p>Here is a copy of the class that is passing the member ...
<p>To call a member function by pointer, you need two things: A pointer to the object and a pointer to the function. You need both in <code>MenuButton::SetButton()</code></p> <pre><code>template &lt;class object&gt; void MenuButton::SetButton(int xPos, int yPos, LPCWSTR normalFilePath, LPCWSTR hoverFilePath, L...
<p>In the rare case that you happen to be developing with Borland C++Builder and don't mind writing code specific to that development environment (that is, code that won't work with other C++ compilers), you can use the __closure keyword. I found a <a href="http://www.drbob42.com/cbuilder/lstfnd15.htm" rel="nofollow n...
15,825
<p>I am trying to automate functional testing of a server using a realistic frequency distribution of requests. (sort of load testing, sort of simulation)</p> <p>I've chosen the <a href="http://en.wikipedia.org/wiki/Weibull_distribution" rel="nofollow noreferrer">Weibull</a> distribution as it "sort of" matches the di...
<p>This is quick and probably not that accurate, but if you calculate the PDF yourself, then at least you make it easier to lay several smaller/larger ones on a single timeline. <code>dev</code> is the std deviation in the Guassian noise, which controls the roughness. Note that this is <em>not</em> the 'right' way to g...
<p>Instead of giving the number of requests as a fixed value, why not use a scaling factor instead? At the moment, you're treating requests as a limited quantity, and randomising the days on which those requests fall. It would seem more reasonable to treat your requests-per-day as independent.</p> <pre><code>from date...
7,732
<p>I know nothing about 3D printing and I was wondering if it is a good candidate for what I want to make.</p> <p>I want to make a custom game cartridge which looks like this: <a href="https://i.stack.imgur.com/k0RpQ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/k0RpQ.jpg" alt="enter image descrip...
<p>Typically, for FDM, the resolution is different for height compared with the x-y plane.</p> <p>In x-y, you will be constrained by the nozzle diameter (0.4mm is common), which effectively quantises your wall thickness (0.4, 0.8, 1.2 etc). These walls can be placed with maybe 0.05mm precision.</p> <p>In Z, the const...
<p>With the experience I have with my 3d printer you can make (almost) everything you can draw with it.</p> <p>0.6mm parts can be 3d printed but will not be very strong though.</p> <p>For joining the 2 halves when they are so thin, I think the best solution is to glue them together. With the things I make for myself ...
639
<p>When is white space not important in Python?</p> <p>It seems to be ignored inside a list, for example:</p> <pre><code>for x in range(5): list += [x, 1 ,2,3, 4,5] </code></pre>
<p>White space is only important for indentation of statements. You have a single statement across several lines, and only the indentation of the beginning of the statement on the first line is significant. See <em><a href="http://www.secnetix.de/~olli/Python/block_indentation.hawk" rel="nofollow noreferrer">Python: My...
<p>Your question is really about when Python implicitly joins lines of code.</p> <p>Python will implicitly join lines that are contained within (parentheses), {braces}, and [brackets], as in your example code. You can also explicitly join lines with a backslash (\) at the end of a line.</p> <p>More here on <a href="h...
48,621
<p>I am trying to install a Windows service using InstallUtil.exe and am getting the error message</p> <blockquote> <p>System.BadImageFormatException: Could not load file or assembly '<code>{xxx.exe}</code>' or one of its dependencies. An attempt was made to load a program with an incorrect format.</p> </blockquote>...
<p>Some more detail for completeness in case it helps someone...</p> <p>Note that the most common reason for this exception these days is attempting to load a 32 bit-specific (<code>/platform:x86</code>) DLL into a process that is 64 bit or vice versa (viz. load a 64 bit-specific (<code>/platform:x64</code>) DLL into ...
<p>I had the same issue. I using the standard command for execution. It was calling the X64 ro run against X86 tests. I needed to specify the X86 and not the X64 version of the nunit-runner.</p>
41,819
<p>I'm currently writing a simple .sh script to parse an Exim log file for strings matching " o' ". Currently, when viewing output.txt, all that is there is a 0 printed on every line(606 lines). I'm guessing my logic is wrong, as awk does not throw any errors.</p> <p>Here is my code(updated for concatenation and count...
<p>There is no real need for the grep here. Let awk select the matching lines for you (and fixing your concatenation bug as per ΤΖΩΤΖΙΟΥ):</p> <pre><code>awk '/o'\''/ { line = "&gt; "; for(i = 20; i &lt;= 33; i++) { line = line " " $i; } print line; ...
<p>"'" is not illegal in local parts. From <a href="http://www.ietf.org/rfc/rfc2821.txt" rel="nofollow noreferrer">RFC2821</a>, section 4.1.2:</p> <pre><code>Local-part = Dot-string / Quoted-string Dot-string = Atom *("." Atom) Atom = 1*atext </code></pre> <p>2821 further references <a href="http://www.ietf.org/rf...
19,283
<p>I have an ASP.NET 2.0 [no ajax...yet] web site that will be deployed in compiled form on multiple customer sites. Typically the site will be intranet only. Some customers trust all of their people and don't care about limiting access to the site and/or page functions, others trust no one and want only certain people...
<p>I prefer to grant access rights to AD groups rather than specific users. I find it's much more flexible.</p> <p>I don't know much about your application, but you might want to look at the authorization tag in the web.config file:</p> <pre><code>&lt;authorization&gt; &lt;!-- &lt;deny users="?" /&gt; ...
<p>i think i'm going to have to combine AD authorization with 'features and permissions' tables in the database in order to get the fine-grained control that we need -</p> <ul> <li>use the web.config file to allow only authorized users (via AD groups) to visit the web site</li> <li>make a 'features' table listing each...
21,244
<p>Is it possible to have two virtual directories under the same website in IIS but have the virtual directories be using different versions of the .net framework?</p> <p>For example, under the default website, can I have one virtual directory targeting the 2.0 framework and a second virtual directory targeting the 1....
<p>You are not saying which version of IIS you are using, but for 6.0 and up, just assign them to different application pools, and set the pools to use the right version of .Net.</p>
<p>It depends if you mark them as "applications". Application virtual directories can use different framework. Make sure you associate them to different application pools. Never mix two .NET framework versions in one application pool.</p> <p><em>One important note:</em> if you create a virtual directory as an applicat...
36,089
<p>I work on a large Visual C++ (MFC) project in VS.NET 2005.</p> <p>I have noticed strange behavior in Visual C++ 2005. Often, I will change one line of code in a .CPP file but many .CPP files will compile as a result of this. I have never seen this until VS.NET 2005. Theortically, changing a line of code in a .CPP f...
<p>I found <a href="http://untidy.net/blog/2006/07/10/vs-always-builds/" rel="nofollow noreferrer">this link</a> helpful when solving a similar problem, was under pressure at the time, I tried a few things and the issue went away, for the life of me I don't know (or can't remember) which - if any - helped.</p> <p>Hope...
<p>This is a strange bug in the VS2005 dependency behavior. To find out one suggestion would be to take the following steps:</p> <ol> <li><p>Go to <strong>Tools</strong> <strong>-> Options -> Projects and Solutions -> Build and Run -> MSBuild Project Build output Verbosity</strong> and select <strong>Detailed</strong>...
6,706
<p>I have an asp.net application directory, and I want to use anonymous authentication in the Directory Sercurity tab.</p> <p>If I use the pre-Windows 2000 style DOMAIN\USERNAME for the username, everything is fine.</p> <p>If I use the AD-style (UPN) usename@domain.local, then I get a 401.1 failed login.</p> <p>I've...
<p>UPN suffixes should work, althouh there is a bug which occurs when there is a service pack difference between the IIS box and the domain controller. There is a patch for it. This <a href="http://forums.iis.net/p/1149978/1872165.aspx" rel="nofollow noreferrer">link</a> discusses the issue in detail.</p>
<p><strong>Update 1:</strong> I have tried it on Windows 2003 sp 2. In the login "directory security" I have checked the enable anonymous access check box ( and only this box ) and put ausername@mydomain.com and the ausername password. The site is plain asp.net without sql backend.</p> <p>Are you able to login to the ...
45,559
<p>I know this is not programming directly, but it's regarding a development workstation I'm setting up.</p> <p>I've got a Windows Server 2003 machine that needs to be on two LAN segments at the same time. One of them is a 10.17.x.x LAN and the other is 10.16.x.x</p> <p>The problem is that I don't want to be using u...
<p>I'm no network expert but I have fiddled with the route command a number of times...</p> <pre><code>route add 0.0.0.0 MASK 0.0.0.0 &lt;address of gateway on 10.17.x.x net&gt; </code></pre> <p>Will route all default traffic through the 10.17.x.x gateway, if you find that it still routes through the other interface,...
<p>If you don't move your network cables around and can assign yourself a static IP address on the 10.16.x.x network, you can refrain from assigning a gateway address on that network. If there is no gateway, internet packets will not be routed on that interface.</p> <p>If you use DHCP, static record to recognize your...
3,837
<p>I know that using continuous integration improves the quality of my code base, and speeds up releases, but what is the best way to convince clients that they want it on their next project?</p>
<p>Say exactly what you've said in the question:</p> <ul> <li>Speeding up releases = earlier market penetration = more money</li> <li>Improving code quality = less time fixing bugs = less cost</li> </ul> <p>So long as you can help them set it up reasonably quickly and cheaply, I can't see why it would be a problem.</...
<p>You have made some assertions. If you want to sell the idea to you clients you are going to have to answer the questions:</p> <ul> <li><p>How does it improve your code quality?</p> <p>Compilation/build issues are identified on a regular basis. And if used in conjunction with automated integration and unit tests yo...
40,892
<p>I'm a Mac user and I've decided to learn Emacs. I've <a href="http://steve.yegge.googlepages.com/effective-emacs" rel="noreferrer">read</a> that to reduce hand strain and improve accuracy the <kbd>CTRL</kbd> and <kbd>CAPS LOCK</kbd> keys should be swapped. How do I do this in Leopard?</p> <p>Also, in Terminal I hav...
<p><strong>Swapping CTRL and CAPS LOCK</strong></p> <ol> <li>Go into <em>System Preferences</em></li> <li>Enter the <em>Keyboard &amp; Mouse</em> preference pane</li> <li>In the <em>Keyboard</em> tab, click <em>Modifier Keys...</em></li> <li>Swap the actions for <em>Caps Lock</em> and <em>Control</em>.</li> </ol> <p>...
<p>I've created a fairly comprehensive set of bindings <a href="https://github.com/cohenaarone/mac_osx_emacs_keybindings" rel="nofollow noreferrer">here</a> for use <em>outside</em> of Terminal.</p> <p>Personally, I can't use the mac laptop keyboard due to the absence of the right control key. </p> <p>Instead, I h...
19,697
<p>Can we have a SQL query which will basically help in viewing table and index sizes in SQl Server.</p> <p>How SQL server maintains memory usage for tables/indexes?</p>
<p>The <code>exec sp_spaceused</code> without parameter shows the summary for the whole database. The foreachtable solution generates one result set per table - which SSMS might not be able to handle if you have too many tables.</p> <p>I created a <a href="http://devio.wordpress.com/2007/10/11/how-much-space-do-my-sql...
<p>There is an extended stored procedure <code>sp_spaceused</code> that gets this information out. It's fairly convoluted to do it from the data dictionary, but <a href="http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=61762" rel="nofollow noreferrer">This link</a> fans out to a script that does it. <a href="https://...
40,912
<p>I'm really interested to hear what you think about Model-driven Software Development for Java and/or .NET.</p> <p>Does it save time? Does it improve quality?</p>
<p>I am using MDSD in a project with IBM Rational Rhapsody for C++. The model is pretty close to UML, so there we do not really have a Domain-Specific-Language. But still I would claim to use MDSD. From my experience, there are many benefits with MDSD:</p> <p>a) Using MDSD helps to bring a SW architecture to a sophist...
<p>MDA usually make difficult to integrate the business rules inside the server side layer, as the model view mapping is handled by generated code and functional hooks are provided as event responders. </p> <p>Still I've not seen a MDA tool as powerful as Forté (or UDS, now dead) + Express were. I imagine that a MDA w...
9,626
<p>Is there a better way I can fill out a spread sheet on a web server (using asp.net) than using interop?</p> <p>EDIT: I wasn't very clear as to what I require:</p> <p>I have a template that I must use that is provided by our customer. In the template are some macros that are password protected that I do not have ac...
<p>Office 2007 documents (Word, PowerPoint and Excel) are based on the OpenXML Formats. They are just zip files with a bunch of XML and binary parts (think files) inside. You can open them with the Packaging API (System.IO.Packaging in WindowsBase.dll) and manipulate them with any of the XML classes in the Framework.</...
<p>YES.</p> <p>If you have an existing spread sheet, and you want to add data to it based on user input where either one sheet is shared by every user or even one user periodically updates his own sheet, then you are going about it the wrong way. Excel can't handle concurrency or the interop load in a web situation. ...
33,438
<p>I knew stackoverflow would help me for other than know what is the "favorite programming cartoon" :P </p> <p>This was the accepted answer by: <a href="https://stackoverflow.com/questions/185327/oracle-joins-left-outer-right-etc-s#185439">Bill Karwin</a></p> <p>Thanks to all for the help ( I would like to double vo...
<p>Try something like this (I haven't tested it):</p> <pre><code>SELECT p_new.identifier, COALESCE(p_inprog.activity, p_new.activity) AS activity, p_inprog.participant, COALESCE(p_inprog.closedate, p_new.closedate) AS closedate FROM performance p_new LEFT OUTER JOIN performance p_inprog ON (p_new.identifier =...
<p>Firstly, you may have a design issue if you can have a customer with multiple tickets open at the same time. You should ideally have a ticket_id, and then you can perform Andy's query by using ticket_id instead of identifier.</p>
22,412
<p>I'm looking for an alternative to <a href="http://www.jsfmatrix.net/" rel="nofollow noreferrer">www.jsfmatrix.net</a> to get a better idea of what JSF libraries are out there and to avoid having to write my own grid/table components. Or are these 27 the best the world has to offer (really only 3 are worth their salt...
<p>have you looked at RichFaces? It comes with a lot really cool rich UI stuff. </p>
<p>I'll second RichFaces, but also point out IceFaces (which isn't free, but is also very nice).</p>
12,912
<p>I have created a reference to an IIS hosted WCF service in my ASP.NET website project on my local workstation through the "Add Service Reference" option in Visual Studio 2008. I was able to execute the service from my local workstation.</p> <p>When I move the ASP.NET web site using the "Copy Web Site" feature in V...
<p>@Sixto Saez: I was able to use the following resource similar to the one you provided to generate a proxy class using the ServiceModel Metadata Utility Tool (svcutil.exe).</p> <p>Here is the exact command line:</p> <pre><code>svcutil /t:code http://&lt;service_url&gt; /out:&lt;file_name&gt;.cs /config:&lt;file_nam...
<p>Unforunately, the WCF service web site and I can not use the svcutil solution (Unless you know of a way how...). Do you deploy you service or your web site with the service reference using Visual Studio 2008 publish web site feature?</p>
35,301
<p>You can embed the <a href="http://ipython.scipy.org/" rel="noreferrer">IPython</a> shell inside of your application so that it launches the shell in the foreground. Is there a way to embed a telnet server in a python app so that you can telnet to a certain port and launch a remote IPython shell? </p> <p>Any tips ...
<p>Python includes a <a href="http://www.python.org/doc/lib/module-telnetlib.html" rel="nofollow noreferrer">telnet client</a>, but not a telnet server. You can implement a telnet server using <a href="http://twistedmatrix.com" rel="nofollow noreferrer">Twisted</a>. <a href="http://twistedmatrix.com/pipermail/twisted...
<p>I think you should base your server class on the <a href="http://www.python.org/doc/lib/module-SocketServer.html" rel="nofollow noreferrer"><code>SocketServer</code></a> class from the standard library. You'll need to write a <code>RequestHandler</code> to read and echo input but a lot of the heavy lifting is alrea...
7,054
<p>Does a free .NET library exist with which I can upload a file to a SFTP (SSH FTP) server, which throws exceptions on problems with the upload and allows the monitoring of its progress?</p>
<p>Maybe you can script/control <a href="http://winscp.net/" rel="noreferrer">winscp</a>?</p> <p><strong>Update:</strong> winscp now has <a href="https://winscp.net/eng/docs/library" rel="noreferrer" title="a .NET library">a .NET library</a> available as a <a href="https://winscp.net/eng/docs/library_install#nuget" r...
<p>Unfortunately, it's not in the .NET Framework itself. My wish is that you could integrate with FileZilla, but I don't think it exposes an interface. They do have scripting I think, but it won't be as clean obviously.</p> <p>I've used CuteFTP in a project which does SFTP. It exposes a COM component which I creat...
11,196
<p>I have a Rails 2.0.2 application running with a postgresql db. The machine will receive data on a TCP port. I already have coded a working ruby multithreaded tcp server to receive the requests, but I need this code to run alongside my Rails app.</p> <p>So I guess I need to know how to span a new process inside Rail...
<p>Why complicate things? Just run the applications -- your TCP server and the Rails application -- side by side.</p> <p>Either pull the model tier (and ActiveRecord) into your TCP server (svn::externals or Piston might work well for that) and let the communication between the two applications happen through the data...
<p>I need the tcp server to run as a service on a Windows 2003 server. I use the mongrel_service to load Rails as a service, and I do not know of a way to do the same for pure ruby code. If I could get my tcp server started when the computer boots, I will look into your solution (which seems pretty good nevertheless). ...
15,790
<p>At work we write a small to moderate amount of scripts to aid us in normal development. We have some people that are more comfortable in python, some in perl, some in php, etc...</p> <p>Sometimes I think it is best to let people work in a language they are most comfortable with. This can mean that sometimes peopl...
<p>I would be inclined to let people choose, <em>and</em> hire people who are comfortable at learning new things. Gaining basic fluency with almost any language should be easy enough for a good developer. And for small scripts where the original author isn't far away, it's even easier.</p> <p>The second part of the ab...
<p>No. </p> <p>Your dev environment is hopefully a living entity that changes and is cultivated. New abilities (scripting languages) should be able to be accommodated, and older places that haven't been visited for years will someday get obviated by tools, or revisited from time to time and an evaluation will take p...
28,167
<p>When do you start to consider a code base to be getting too large and unwieldy? </p>
<p>When it's over 100 lines. Joke. This is probably the hardest question to answer, because it's very individual.</p> <p>But if you structure the application well and use different layers for i.e. interfaces, data, services and front-end you will automaticly get a nice "base"-structure. Then you can dividie each layer...
<p>If over years of development different people code change requests and bug fixes you will sooner or later get parts of code with duplicated functionality, very similar classes, some spaghetti etc. This is mostly due to the fact that a fix is needed fast and the "new guy" doesn't know the code base. So he happily co...
43,813
<p>I'm trying to learn scheme via SICP. Exercise 1.3 reads as follow: Define a procedure that takes three numbers as arguments and returns the sum of the squares of the two larger numbers. Please comment on how I can improve my solution.</p> <pre><code>(define (big x y) (if (&gt; x y) x y)) (define (p a b c) ...
<p>Using only the concepts presented at that point of the book, I would do it:</p> <pre><code>(define (square x) (* x x)) (define (sum-of-squares x y) (+ (square x) (square y))) (define (min x y) (if (&lt; x y) x y)) (define (max x y) (if (&gt; x y) x y)) (define (sum-squares-2-biggest x y z) (sum-of-squares (ma...
<p>I've had a go:</p> <pre><code>(define (procedure a b c) (let ((y (sort (list a b c) &gt;)) (square (lambda (x) (* x x)))) (+ (square (first y)) (square(second y))))) </code></pre>
19,544
<p>I'm trying to locate an open source business rules engine that has a decent interface for building the rules.</p> <p>OR at least one that works well on the .Net platform and has been updated sometime in the past 12 months. </p> <p>Thanks,</p>
<p>NxBRE is one option. </p> <p><a href="http://sourceforge.net/projects/nxbre/#item3rd-5" rel="noreferrer">http://sourceforge.net/projects/nxbre/#item3rd-5</a></p>
<p>I'm going to throw one more piece of software I ran across: <a href="http://ncalc.codeplex.com/" rel="nofollow">ncalc</a>.</p> <p>It's not exactly a "rules" engine; but it does do dynamic calculations where you can give it the expression to evaluate and all of the variables necessary. This was pretty much exactly...
4,187
<p>I am fascinated by the performance of applications such as "Rollercoaster Tycoon" and "The Sims" and FPS games. I would like to know more about the basic application architecture. (Not so concerned with the UI - I assume MVC/MVP piriciples apply here. Nor am I concerned with the math and physics at this point.)</p...
<p>There are two basic ways of doing this kind of simulation <a href="http://en.wikipedia.org/wiki/Agent_based_model" rel="noreferrer">Agent Based</a> and <a href="http://en.wikipedia.org/wiki/System_dynamics" rel="noreferrer">System Dynamics</a>. In and agent based simulation each entity in the game would be represent...
<p>@Cody Brocious</p> <p>This <a href="http://www.codeproject.com/KB/linq/linq-to-life.aspx" rel="nofollow noreferrer">CodeProject</a> uses Linq to demonstrate this practice. (Linq to Life)</p>
16,662
<p>I have a web service class that the rest of the framework depends on to grab its data, but the web service class needs to have different method attributes depending on what environment it's in. For instance...</p> <pre><code>[SoapDocumentMethodAttribute("https://example",...)] public string Test() { //doSomethi...
<p>Could you use conditional comments?</p> <pre><code>#if TESTING [SoapDocumentMethodAttribute(something)] #else [SoapDocumentMethodAttribute(someotherthing)] #endif </code></pre> <p>For your test configuration you would define the constant:</p> <pre><code>&lt;DefineConstants&gt;TESTING&lt;/DefineCon...
<p>In conjunction with Defining constants, and using #if directives,</p> <p>You can also write a custom build task -> Target BeforeBuild, then using the Engine.GlobalEngine.GetLoadedProject("projpath") in to Project object.</p> <p>Now you can manipulate the properties on the Project object however you want for differ...
37,871
<p>The company I work for writes a lot smallish Perl and Bash scripts to massage data into something usable for our software. These scripts, like any code, can change. I provided them CVS because of the file versioning rather than repository versioning. Anyway, I am thinking out a deploy tool to get the scripts from...
<p>if you going to write some kind of distribution script it should be relatively simple </p> <p>1) The script should be committed in your cvs repository </p> <p>2) I advice to call the script from your makefile (or any build system you use) something like this </p> <pre><code>make dist </code></pre> <p>and the...
<p>I worked on an internal tool that did deployments. It was designed for the enterprise (and to meet SOX regulations), and so it relied on approvals to deploy code.</p> <p>Because of this, we deployed the version of code the developer specified in the request, not the latest version. The reason is that a developer ma...
32,469
<p>I really love the way Ajax makes a web app perform more like a desktop app, but I'm worried about the hits on a high volume site. I'm developing a database app right now that's intranet based, that no more then 2-4 people are going to be accessing at one time. I'm Ajaxing the hell out of it, but it got me to wonde...
<p>On my current project, we do use Ajax and we have had scaling problems. Since my current project is a J2EE site that does timekeeping for the employees of a large urban city, we've found that it's best if the browser side can cache data that won't change for the duration of a user session. Fortunately we're moving ...
<p>The most common scaling issue of ajax apps is when they are to set up to check back with the server to see if the content got updated in the meantime without the need for user actively requesting it. 5 clients checking every 10 seconds is not 5000 clients checking every 10 sec.</p>
42,741
<p>The terms are used all over the place, and I don't know of crisp definitions. I'm pretty sure I know what a data mart is. And I've created reporting cubes with tools like Business Objects and Cognos.</p> <p>I've also had folks tell me that a datamart is more than just a collection of cubes.</p> <p>I've also had ...
<p><a href="http://en.wikipedia.org/wiki/Olap_cube" rel="nofollow noreferrer">Cube</a> can (and arguably should) mean something quite specific - OLAP artifacts presented through an <a href="http://en.wikipedia.org/wiki/MOLAP" rel="nofollow noreferrer">OLAP server</a> such as <a href="https://learn.microsoft.com/en-us/s...
<p>To me, a datamart is just place where data gets dumped in a relatively flat, unusable format.</p> <p>Cube is taking that data and making it dance.</p>
47,101
<p>For my school work, I do a lot of switching computers (from labs to my laptop to the library). I'd kind of like to put this code under some kind of version control. Of course the problem is that I can't always install additional software on the computers I use. Is there any kind of version control system that I c...
<p>You could use <a href="http://www.portablepython.com/" rel="noreferrer">Portable Python</a> and <a href="http://bazaar-vcs.org/" rel="noreferrer">Bazaar</a> (Bazaar is a Python app). I like to use Bazaar for my own personal projects because of its extreme simplicity. Plus, it can be portable because Python can be ...
<p>bitnami stack subversion it's easy to install. You can try to install so too xampp with portableapps.com and subversion.</p>
12,331
<p>I've the following rewrite rule in .htaccess:</p> <pre><code>RewriteRule ^groups/([^/\.]+)/?$ groupdetail.php?gname=$1 [L,NC] </code></pre> <p>This takes something like www.example.com/groups/groupname and calls www.example/groupdetail.php?gname=groupname. And it works just fine.</p> <p>But all the relative lin...
<p>If like me you had hundreds of relative links in the page, insert a <code>&lt;base href=""&gt;</code> in the <code>&lt;head&gt;</code> with an absolute path (could use relative too). You'll need to also make the path to .js files in the <code>&lt;head&gt;</code> absolute because IE and firefox deal with the base hr...
<p>Hop's answer is correct. The browser sees <strong><code>www.example.com/groups/groupname</code></strong> as the address, so considers that <strong><code>/groups</code></strong> is the current directory. So, any links like <strong><code>&lt;a href=link.php&gt;</code></strong> are assumed to be in the <strong><code>/g...
17,440
<p>I am building a WPF application. Inside that application I am using the XmlReader class to parse several local XML files. The code I have written <strong>works perfectly</strong> during debugging, but fails once I publish the application and install it.</p> <p>I have the XML documents as CONTENT in build action, an...
<p>By your publish description I assume you are using clickonce to install the application.</p> <p>Clickonce has different default behavior for xml files - it assumes they are data files and places them in a different install location from your other files.</p> <p>Please double check that your xml files really are be...
<p>Consider using IsolatedStorage to store your settings rather than in a relative Resources directory. This will give you a known location for different install scenarios (e.g., ClickOnce installs).</p>
32,011
<p>I need a method to return a random string in the format:</p> <p>Letter Number Letter Number Letter Number</p>
<p>Assuming you don't need it to be threadsafe:</p> <pre><code>private static readonly Random rng = new Random(); private static RandomChar(string domain) { int selection = rng.Next(domain.Length); return domain[selection]; } private static char RandomDigit() { return RandomChar("0123456789"); } private...
<p>Then just use the Random.NextBytes function together with Encoding.ASCII.GetString() to generate Characters.</p> <p>Or, alternatively, generate a String or char Array (string[]) and use Random.Next(0,array.Length) to get an index to it.</p> <p>Use a StringBuilder and Random.Next(0,9) to generate numbers and then g...
39,808
<p>I tried using the IHttpModule and managed to convert the urls just fine, but all of my images returned path error (all going through the new url directory).</p> <p>whats the solution?</p>
<p>You need to make sure that you use the "~/" path notation on your images and make sure that they are all server controls with runat='server'. Otherwise the images urls won't get rewritten.</p> <p>For example if you have a page that gets rewritten from:</p> <p>/Item/Bicycle.aspx</p> <p>to </p> <p>/Item.aspx?id=12...
<p>You can try using a URL rewriter such as <a href="http://cheeso.members.winisp.net/IIRF.aspx" rel="nofollow noreferrer">IIRF</a>.</p> <p>With IIRF you can use regular expressions to parse the incoming URL as you wish, then send it to the right place.</p> <p>They have examples built in on how to do all that in the ...
35,212
<p>I've got a backup made using the regular SQL Server 2005 backup command. Is there a way to restore just a single table, not the whole DB?</p>
<p>Restore the whole database to another machine (or temporary database), then copy the table seems like the easiest to me.</p>
<p>Detach the current database then restore the database with the date of the tbl you need to a new location (make a sub folder) to put it in keep it separate from your production databases, then restore the database to that sub folder, when completed find the tbl you need and script it to a create script file save to ...
38,055
<p>I'd like to add some pie, bar and scatter charts to my Ruby on Rails web application. I want want them to be atractive, easy to add and not introduce much overhead. </p> <p>What charting solution would you recommend?<br> What are its drawbacks (requires Javascript, Flash, expensive, etc)?</p>
<p><a href="http://code.google.com/apis/chart/" rel="noreferrer">Google Charts</a> is an excellent choice if you don't want to use Flash. It's pretty easy to use on its own, but for Rails, it's even easier with the <a href="http://badpopcorn.com/blog/2008/09/08/rails-google-charts-gchartrb/" rel="noreferrer">gchartrb</...
<p>We do this by shelling out to gnuplot to generate the charts as PNGs server-side. It's a bit old-school and the charts aren't interactive but it works and is cacheable.</p> <p>(The other reason we do this is so we can put exactly the same chart in the PDF version of the report).</p>
11,313
<p>This is something that comes up so often I almost stopped thinking about it but I'm almost certain that I'm not doing this the best way.</p> <p>The question: Suppose you have the following table</p> <pre><code>CREATE TABLE TEST_TABLE ( ID INTEGER, TEST_VALUE NUMBER, UPDATED DATE, FOREIGN_KEY...
<p>Analytic functions are your friends</p> <pre><code>SQL&gt; select * from test_table; ID TEST_VALUE UPDATED FOREIGN_KEY ---------- ---------- --------- ----------- 1 10 12-NOV-08 10 2 20 11-NOV-08 10 SQL&gt; ed Wrote file afiedt.buf 1* select * from ...
<pre><code>select test_value from ( select test_value from test_table where foreign_key=10 order by updated desc ) where rownum = 1 </code></pre> <p>Oracle is smart enough to realize it only needs a single row from the inner select and it will do this efficiently.</p>
36,240
<p>This is really two questions, but they are so similar, and to keep it simple, I figured I'd just roll them together:</p> <ul> <li><p><strong>Firstly</strong>: Given an established Java project, what are some decent ways to speed it up beyond just plain in-code optimization?</p></li> <li><p><strong>Secondly</strong>...
<p>Firstly : by code optimization, I would assume that you've done the right algorithms and right implementation of algorithms. In which case, you would use the profiler and look at how often your garbage collector(GC) is collecting garbage and how much time it is using for doing that. Then you start working on the GC ...
<p>Here is an (older) document by Peter Sestoft which is worth reading: <a href="http://www.dina.kvl.dk/~sestoft/papers/performance.pdf" rel="nofollow noreferrer">Performance in java</a>. Some of the advice is probably not true anymore since Java got a lot better with the later versions in optimizations. But there are ...
21,687
<p>I’ve got a brand new Django project. I’ve added one minimal view function to <code>views.py</code>, and one URL pattern to <code>urls.py</code>, passing the view by function reference instead of a string:</p> <pre><code># urls.py # ------- # coding=utf-8 from django.conf.urls.defaults import * from myapp import ...
<p>Got it!! The problem is that some of the imports are of <code>myproject.myapp.views</code>, and some are just of <code>myapp.views</code>. This is confusing the Python module system enough that it no longer detects the functions as the same object. This is because your main <code>settings.py</code> probably has a li...
<p>If your two code pastes are complete, then it doesn't look like the second, which makes the actual call to reverse(), ever imports the urls module and therefor if the url mapping is ever actually achieved.</p>
17,643
<p>I have a huge file that I must parse line by line. Speed is of the essence. </p> <p>Example of a line:</p> <blockquote> <pre><code>Token-1 Here-is-the-Next-Token Last-Token-on-Line ^ ^ Current Position Position after GetToken </code></pre> </bl...
<ul> <li>Use PChar incrementing for speed of processing</li> <li>If some tokens are not needed, only copy token data on demand</li> <li>Copy PChar to local variable when actually scanning through characters</li> <li>Keep source data in a single buffer unless you must handle line by line, and even then, consider handlin...
<p>Rolling your own is the fastest way for sure. For more on this topic, you could see <a href="http://synedit.sourceforge.net/" rel="nofollow noreferrer">Synedit's source code</a> which contains lexers (called highlighters in the project's context) for about any language on the market. I suggest you take one of those ...
36,617
<p>If I generate an exception on my own, I can include any info into the exception: a number of code line and name of source file. Something like this:</p> <pre><code>throw std::exception("myFile.cpp:255"); </code></pre> <p>But what's with unhandled exceptions or with exceptions that were not generated by me?</p>
<p>It seems everyone is trying to improve your code to throw exceptions in your code, and no one is attempting the actual question you asked.</p> <p>Which is because it can't be done. If the code that's throwing the exception is only presented in binary form (e.g. in a LIB or DLL file), then the line number is gone, ...
<p>Apart from using a custom class with a macro, as suggested by Frank Krueger, for your own exceptions, you might be interested in taking a look at the structured exception handling mechanism (you're programming under windows, right?)<br> Check <a href="http://msdn.microsoft.com/en-us/library/ms680657%28VS.85%29.aspx"...
45,386
<p>I'm using PIL (Python Imaging Library). I'd like to draw transparent polygons. It seems that specifying a fill color that includes alpha level does not work. Are their workarounds?</p> <p>If it can't be done using PIL I'm willing to use something else.</p> <p>If there is more than one solution, then performance...
<p>This is for Pillow, a more maintained fork of PIL. <a href="http://pillow.readthedocs.org/" rel="noreferrer">http://pillow.readthedocs.org/</a></p> <p>If you want to draw polygons that are transparent, relative to each other, the base Image has to be of type RGB, not RGBA, and the ImageDraw has to be of type RGBA. E...
<p>I had to draw an outside polygon with an outline, and subtract inner polygons (a common operation in GIS). Works like a charm using color <code>(255,255,255,0)</code>.</p> <pre><code>image = Image.new("RGBA", (100,100)) drawing = ImageDraw.Draw(i) for index, p in enumerate(polygons): if index == 0: opti...
46,924
<p>I have a really simple ASP.NET web application and a web setup project that deploys the project output and content files to a virtual directory in IIS.</p> <p>What I want is for the MSI to automatically disable Anonymouse Access for that virtual folder in IIS. </p> <p>I suspect it can probably be done by writing s...
<p><a href="http://www.microsoft.com/technet/security/guidance/identitymanagement/idmanage/P3ASPD_6.mspx?mfr=true" rel="nofollow noreferrer">Taken from technet</a></p> <blockquote> <p>The property for anonymous access is unfortunately not available through Web setup projects. For this reason, you must:</p> ...
<pre><code>&lt;configuration&gt; &lt;system.web&gt; &lt;compilation debug="true" targetFramework="4.0" /&gt; &lt;authentication mode="Forms"&gt; &lt;forms loginUrl="SignIn.aspx" defaultUrl="Welcome.aspx" protection="All"&gt; &lt;credentials passwordFormat="Clear"&gt; &lt...
38,199
<p>Please, I am new to webparts and I need help!!</p> <p>I have a custom web part that I created. I added MS Ajax to it using an UpdatePanel which works fine. I add all my controls to the CreateChildControls method. As soon as I add a UpdateProgress control my page breaks with the following error:</p> <p>Script contr...
<p>I encountered similar problem before, try to call EnsureChildControls method inside your on init method override. It should be called by system automatically, but sharepoint likes to forget about it from time to time.</p> <p>Like this:</p> <pre><code> protected override void OnInit(EventArgs e) { ba...
<p>You might have forgotten to call the base method of an overrided event, which is not necessarily the OnPreRender event.</p> <p>Check if the OnInit or OnLoad events are calling their base.On[...] method, e.g.:</p> <pre><code>protected override void OnLoad(EventArgs eventArgs) { base.OnLoad(eventArgs); // y...
41,824
<p>I'm having difficulty searching for this. How would I define an element in an XML schema file for XML that looks like this:</p> <pre><code>&lt;option value="test"&gt;sometext&lt;/option&gt; </code></pre> <p>I can't figure out how to define an element that is of type <code>xs:string</code> and also has an attribute...
<p>Try</p> <pre><code> &lt;xs:element name="option" type="AttrElement" /&gt; &lt;xs:complexType name="AttrElement"&gt; &lt;xs:simpleContent&gt; &lt;xs:extension base="xs:string"&gt; &lt;xs:attribute name="value" type="xs:string"&gt; &lt;/xs:attribute&gt; &lt;/xs:extension&gt; &l...
<p>I know it is not the same, but it works for me:</p> <pre><code>&lt;xsd:element name="option"&gt; &lt;xsd:complexType mixed="true"&gt; &lt;xsd:attribute name="value" use="optional" type="xsd:string"/&gt; &lt;/xsd:complexType&gt; &lt;/xsd:element&gt; </code></pre>
49,298
<p>I'm using .NET to make an application with a drawing surface, similar to Visio. The UI connects two objects on the screen with Graphics.DrawLine. This simple implementation works fine, but as the surface gets more complex, I need a more robust way to represent the objects. One of these robust requirements is determi...
<p>The representation of lines by y = mx + c is problematic for computer graphics, because vertical lines require m to be infinite.</p> <p>Furthermore, lines in computer graphics have a start and end point, unlike mathematical lines which are infinite in extent. One is usually only interested in a crossing of lines if...
<p>You can ask Dr. Math, see <a href="https://web.archive.org/web/20180211083203/http://mathforum.org/library/drmath/view/53254.html" rel="nofollow noreferrer">this link</a>.</p>
18,544
<p>What is the best way to add "copy to clipboard" functionality to a ListView control in WPF?</p> <p>I tried adding an ApplicationCommands.Copy to either the ListView ContextMenu or the ListViewItem ContextMenu, but the command remains disabled.</p> <p>Thanks, Peter</p> <p>Here is an xaml sample of one of my attemp...
<p>It looks like you need a CommandBinding.</p> <p>Here is how I would probably go about doing what you trying to do.</p> <pre><code>&lt;Window.CommandBindings&gt; &lt;CommandBinding Command="ApplicationCommands.Copy" Executed="CopyCommandHandler" CanExecute="CanCopyExecuteHandler" /&gt; &...
<p>It is also possible to achieve this functionality via an attached property, as I described it on my <a href="http://jannsblog.wordpress.com/2009/03/10/copy-a-listview%E2%80%99s-items-to-the-clipboard/" rel="nofollow noreferrer">blog</a>. The idea is to register the ApplicationCommands.Copy command with the ListView ...
32,961
<p><code>GNU sed version 4.1.5</code> seems to fail with International chars. Here is my input file:</p> <pre><code>Gras Och Stenar Trad - From Moja to Minneapolis DVD [G2007DVD] 7812 | X &lt;br&gt; Gras Och Stenar Trad - From Möja to Minneapolis DVD [G2007DVD] 7812 | Y </code></pre> <p>(Note the umlaut in the second...
<p>I think the error occurs if the input encoding of the file is different from the preferred encoding of your environment. </p> <p>Example: <code>in</code> is UTF-8</p> <pre><code>$ LANG=de_DE.UTF-8 sed 's/.*| //' &lt; in X Y $ LANG=de_DE.iso88591 sed 's/.*| //' &lt; in X Y </code></pre> <p>UTF-8 can safely be int...
<p><code>sed</code> is not very well setup for non-ASCII text. However you can use (almost) the same code in <code>perl</code> and get the result you want:</p> <pre><code>perl -pe 's/.*\| //' x </code></pre>
9,295
<p>When iterating over elements of a vector it is preferred to use iterators instead of an index (see <a href="https://stackoverflow.com/questions/131241/why-use-iterators-instead-of-array-indices">Why use iterators instead of array indices?</a>). </p> <pre><code>std::vector&lt;T&gt; vec; std::vector&lt;T&gt;::iterato...
<p>If you're planning on using exclusively a vector, you may want to switch back to the indexed loop, since it conveys your intent more clearly than iterator-loop. However, if evolution of your program in the future may lead to a change of container, you should stick to the iterators and use std::distance, which is gua...
<p>I would always tend towards keeping with iterators for future development reasons.</p> <p>In the above example, if you perhaps decided to swap out std::vector for std::set (maybe you needed a unique collection of elements), using iterators and distance() would continue to work.</p> <p>I pretty sure that any perfor...
16,044
<p>I haven't found an answer elsewhere and this doesn't appear to have been asked yet on SO.</p> <p>When creating an event binding in wxPython, is it possible to pass additional arguments to the event? For example, this is the normal way:</p> <pre><code>b = wx.Button(self, 10, "Default Button", (20, 20)) self...
<p>You can always use a lambda or another function to wrap up your method and pass another argument, not WX specific.</p> <pre><code>b = wx.Button(self, 10, "Default Button", (20, 20)) self.Bind(wx.EVT_BUTTON, lambda event: self.OnClick(event, 'somevalue'), b) def OnClick(self, event, somearg): self.lo...
<p>The nicest way would be to make a generator of event handlers, e.g.:</p> <pre><code>def getOnClick(self, additionalArgument): def OnClick(event): self.log.write("Click! (%d), arg: %s\n" % (event.GetId(), additionalArgument)) return OnClick </code></pre> <p>Now you bind it ...
20,928
<p>I'm trying to make a simple blackjack program. Sadly, I'm having problems right off the bat with generating a deck of cards.</p> <pre><code>#include &lt;iostream&gt; #include &lt;vector&gt; using namespace std; int main() { vector&lt;char&gt; deck; char suit[] = {'h','d','c','s'}; char card[] = {'2','...
<p>Try to create class of Card with suit and card as a member and set it as a type of vector. Like</p> <pre><code>public class Card { public: Card(char suit, char card); char suit, card; }; int main() { vector&lt;Card&gt; deck; char suit[] = {'h','d','c','s'}; char card[] = {'2','3','4','5','6','7','...
<p>I would go with Ross's suggestion to use integers. Most card games will involve some bits of math so that's a better representation.</p> <p>Convert to 'A' or 'ACE' etc. on output.</p>
29,014
<p>This may be a long shot, but I was wondering if the signals seen across a stepper motor's windings could indicate whether the stepper was being told to move over some short time period. This is in particular for the stepper used on extruders.</p> <p>I've read that PWM in used in stepper drivers and controls curren...
<blockquote> <p>So it would seem that there is always a pulsing waveform across the windings whenever the stepper is energized, correct?</p> </blockquote> <p>Correct.</p> <blockquote> <p>When the motor is holding its position, is there anything distinctive about the waveform?</p> </blockquote> <p><a href="https:...
<p>There is nothing you can do to monitor the extruder stepper motor to assure that filament is being fed when it should be fed. A common condition is where the filament binds but the extruder stepper continues to move as commanded. The drive pully strips the dents it presses in the filament, and grinds down the fila...
1,270
<p>example:</p> <p>I want to see if <code>array[5]</code> holds a value or is empty.</p>
<p>Elements in primitive arrays can't be empty. They'll always get initialized to something (usually <code>0</code> for <code>int</code> arrays, but depends on how you declare the array).</p> <p>If you declare the array like so (for example):</p> <pre><code>int [] myArray ; myArray = new int[7] ; </code></pre> <p>t...
<p>Create a constant to define the empty value, eg:</p> <pre><code>private static final int EMPTY = -1; </code></pre> <p>then create the array like this:</p> <pre><code>int[] myArray = new int[size]; Arrays.fill(myArray, EMPTY); </code></pre> <p>then to check if an element is 'empty', do this:</p> <pre><code>if (m...
36,358
<p>I want to build a dynamic floating window with close button at corner. Is it possible, and also i want to add some content dynamically into that window. </p> <p>Please help me.. It should be in javascript.. Better without AJAX..</p> <p>Thanks in Advance</p>
<p>jQuery UI has an awesome floating window. What's cool about the jQuery UI version is that you can also package it with the UI theme manager, which means less time styling.</p> <p>Check it out here : <a href="https://jqueryui.com/resources/demos/dialog/modal-form.html" rel="nofollow noreferrer" title="jQuery UI Moda...
<p>Well at the most basic just create a div and inject content by setting innerHTML to an HTML string. Positioning it can be tricky since you have to worry about scrolling and different browsers have different means of controlling this. You may also want to position relative to some originating element in the page whic...
49,831
<p>When I try to install a new instance of SQL Server 2008 Express on a development machine with SQL 2005 Express already up and running, the install validation fails because the "SQL 2005 Express tools" are installed and I'm told to remove them.</p> <p><strong>What exactly does that mean?</strong> </p> <p>After rea...
<p>Although you should have no problem running a 2005 instance of the database engine beside a 2008 instance, The tools are installed into a shared directory, so you can't have two versions of the tools installed. Fortunately, the 2008 tools are backwards-compatible. As we speak, I'm using SSMS 2008 and Profiler 2008 t...
<p>Just Remove the the Workstation Components from Add/Remove Programs - SQL Server 2005. Removing Workstation Components, SQL Server 2008 installation goes well.</p>
21,190
<p>From my understanding of FFF 3D printing, the glass state is usually used to heat the bed for better first layer adhesion. Other than that, does the extruder keep ex:PLA in a glass state for any reason?</p> <p>Is the transition of the filament straight from solid to liquid for extrusion without any real regard for t...
<p><em>Note that the extruder feeds filament it doesn't heat anything, you don't want heat in the extruder. The hot end is the part that adds heat well over the glass temperature.</em></p> <p>The <a href="https://en.m.wikipedia.org/wiki/Glass_transition" rel="nofollow noreferrer">glass transition temperature</a>, the t...
<p>The transition from solid to liquid is the important part.</p> <p>The bed is heated for adhesion and kept heated for the same reason, but the extruder is a lot hotter and just performs the task of solid to liquid, the fans and ambient temperature cool it to solid.</p> <p>Once a layer is solid it will heat up again w...
2,220
<p>How would you lay out the directory structure for a large C# solution, consisting of perhaps 20 to 30 projects, mostly C# but some C++? Where do you put external dependencies? When creating a branch in source control, do you branch absolutely everything? Do you override the defaults for where built files go?</p>
<p>Take a look at the <a href="http://www.codeplex.com/treesurgeon" rel="nofollow noreferrer">Tree Surgeon</a> CodePlex project.</p>
<p>Take a look at the <a href="http://www.codeplex.com/treesurgeon" rel="nofollow noreferrer">Tree Surgeon</a> CodePlex project.</p>
35,463
<p>I have built a 3D printer out of parts from my tip, a ramps board, arduino mega, and a hot end. However, after doing a test extrusion some plastic was spewed out and then the print jammed un-expectantly and my homemade extruder no longer had the strength to push the filament. </p> <p>I took the filament out and wha...
<p>You are suffering from what is called "heat creep". Molten filament is creeping up the heat break and into the bowden tube, where it is causing a jam. You need to install a proper radiator block that is cooled by a fan, not just a lump of wood as a "cold end". The cold end is not just a connector, its primary purpos...
<p>Hello it's seems that your hotend's barrel get's too hot when your ar printing, have you try to make a heat sink on the barrell, with some washers and nuts? That worked for me, like this<a href="https://i.stack.imgur.com/bmfpm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bmfpm.png" alt="enter i...
733
<p>I'm starting to learn ruby. I'm also a day-to-day C++ dev. For C++ projects I usually go with following dir structure</p> <pre><code>/ -/bin &lt;- built binaries -/build &lt;- build time temporary object (eg. .obj, cmake intermediates) -/doc &lt;- manuals and/or Doxygen docs -/src --/module-1 --/module-2 -- ...
<p>Bundler includes the necessary infrastructure to generate a gem:</p> <pre><code>$ bundle gem --coc --mit --test=minitest --exe spider Creating gem 'spider'... MIT License enabled in config Code of conduct enabled in config create spider/Gemfile create spider/lib/spider.rb create spider/lib/spid...
<p>I would stick to something similar to what you are familiar with: there's no point being a stranger in your own project directory. :-)</p> <p>Typical things I always have are lib|src, bin, test.</p> <p>(I dislike these monster generators: the first thing I want to do with a new project is get some code down, not w...
8,028
<p>I have a service app that creates AppDomain's during the course of its use for long running tasks. I've been tracking these by storing them in a Hashtable with a unique ID.</p> <p>After a task is completed the service app then unloads the AppDomain allocated to that task and then it's removed it from the appdomain ...
<p>I found the bug. The line</p> <pre><code>d1 = create_task(:parent_id =&gt; @root.id, :sort_order =&gt; 2) </code></pre> <p>creates d1. This calls the <code>before_save</code> callback, which in turn calls <code>self.children</code>. As Orion pointed out, this caches the children of d1.</p> <p>However, at this poi...
<p><code>children</code> <a href="http://github.com/rails/acts_as_tree/tree/master/lib/active_record/acts/tree.rb#L47" rel="nofollow noreferrer">is a simple has_many association</a></p> <p>This means, when you call <code>.children</code>, it will load them from the database (if not already present). It will then cache...
20,679
<p>I want to make an MVC route for a list of news, which can be served in several formats.</p> <ul> <li>news -> (X)HTML</li> <li>news.rss -> RSS</li> <li>news.atom -> ATOM</li> </ul> <p>Is it possible to do this (the more general "optional extension" situation crops up in several places in my planned design) with one...
<p>I made a method to support adding pairs like this as follows:</p> <pre><code>public static void MapRouteWithOptionalFormat(this RouteCollection routes, string name, string url, o...
<p>You can look into using constraints to make this work with normal routes.</p> <p>UPDATE: actually, I misread the question. The other answer is the correct thing to do for now. Or create a custom route. We're looking at the idea of optional segments as a possible future feature.</p>
31,928
<p>What's the best algorithm for comparing two arrays to see if they have the same members?</p> <p>Assume there are no duplicates, the members can be in any order, and that neither is sorted.</p> <pre><code>compare( [a, b, c, d], [b, a, d, c] ) ==&gt; true compare( [a, b, e], [a, b, c] ) ==&gt; false...
<p>Obvious answers would be:</p> <ol> <li>Sort both lists, then check each element to see if they're identical</li> <li>Add the items from one array to a hashtable, then iterate through the other array, checking that each item is in the hash </li> <li>nickf's iterative search algorithm</li> </ol> <p>Which one you'd u...
<p>The best I can think of is O(n^2), I guess.</p> <pre><code>function compare($foo, $bar) { if (count($foo) != count($bar)) return false; foreach ($foo as $f) { foreach ($bar as $b) { if ($f == $b) { // $f exists in $bar, skip to the next $foo continue 2; ...
30,457
<p>I've been working with Swing for a while now but the whole model/structure of <code>JFrame</code>s, <code>paint()</code>, <code>super</code>, etc is all murky in my mind. I need a clear explanation or link that will explain how the whole GUI system is organized.</p>
<p>The same happened to me. Actually to this day I don't quite get 100% how all it works.</p> <p>Swing is a very flexible framework - perhaps too flexible. With flexibility comes a lot of abstraction and with abstraction comes confusion. :)</p> <p>I've found the following articles worth reading. They helped me to bet...
<p><a href="http://filthyrichclients.org/" rel="nofollow noreferrer">Filthy Rich Clients</a> by Chet Haase and Romain Guy is a great book about Java UI. It covers some more advanced stuff too, but introduction and few first chapters explain fundamental things well.</p>
48,365
<p>I work on an application that uses DCOM to communicate between what are essentially several peers; in the course of normal use, instances on separate machines serve a variety of objects to one another. Historically, for this to work we have used some magic incantations, chief among which is that on every machine th...
<p><em>Programming Windows Security</em> by Keith Brown includes a thorough discussion of DCOM security. I can highly recommend this book.</p>
<p>You could also try to round up a copy of <em>Inside Distributed COM</em> by Guy and Henry Eddon (Microsoft Press) - It is out of print but amazon shows a number of used copies for sale:</p> <p><a href="https://rads.stackoverflow.com/amzn/click/com/157231849X" rel="nofollow noreferrer" rel="nofollow noreferrer">http...
7,229
<p>I have a DAV server (Oracle Portal in this case). If I open word and then enter the DAV URL of a document, I'm correctly prompted for username/password and the document is checked out. I can edit it and just click Save to save it back to the server. So far, so good.</p> <p>What I need is a link on a web page that w...
<p>According to <a href="http://www.gossamer-threads.com/lists/zope/dev/217568?page=last" rel="nofollow noreferrer">this thread</a>, you should be able to get DAV supported by adding special headers to your response so that word knows that it is editable via DAV.</p>
<p>No. The dav protocol uses standard HTTP transactions, and unless the client is aware of the support for DAV, it won't know to use it.</p> <p>Word is likely not DAV aware, and you're relying on people mounting DAV devices as a mounted network drive. </p> <p>IE: As far as words concerned, its just like any other URL...
35,064
<p>I have read in some of the ClickOnce posts that ClickOnce does not allow you to create a desktop icon for you application. Is there any way around this?</p>
<p>In Visual&nbsp;Studio&nbsp;2005, <a href="http://en.wikipedia.org/wiki/ClickOnce" rel="noreferrer">ClickOnce</a> does not have the ability to create a desktop icon, but it is now available in Visual&nbsp;Studio&nbsp;2008 SP1. In Visual&nbsp;Studio&nbsp;2005, you can use the following code to create a desktop icon fo...
<p>The desktop icon can be a shortcut to the <code>.application</code> file. Install this as one of the first things your application does.</p>
18,355
<p>I get obsessed with the best names for arrays and variables that I use, I'll look up words in the thesaurus, dictionary, etc..</p> <p>So I'm trying to name this array / structure:</p> <pre><code>$nameMe = array( '392' =&gt; TRUE, '234' =&gt; TRUE, '754' =&gt; TRUE, '464' =&gt; TRUE, ); </code></pre...
<pre><code>$hasProperty[$id] </code></pre> <p>or</p> <pre><code>$isSomething[$id] </code></pre> <p>What is the property exactly?</p> <pre><code>$isOdd[$id] $isWriteable[$id] $hasAssociatedFile[$id] </code></pre>
<p>propertyNameable, IspropertyNameable.</p>
24,884
<p>How would I compile the latest version of GTK# for Windows without using cygwin?</p> <p>Any and All help would be appreciated.</p>
<p>Well, if you have to have a more recent version, Medsphere provide a <a href="http://medsphere.org/projects/gtksharp/wiki" rel="nofollow noreferrer">newer version</a>, and <a href="http://medsphere.org/projects/gtksharp/wiki/CompilingGtkSharpOnCygwin" rel="nofollow noreferrer">building instructions</a> and there is ...
<p>Why would you need Cygwin to compile C# code?</p>
32,724
<p>So I have an object which has some fields, doesn't really matter what. I have a generic list of these objects.</p> <pre><code>List&lt;MyObject&gt; myObjects = new List&lt;MyObject&gt;(); myObjects.Add(myObject1); myObjects.Add(myObject2); myObjects.Add(myObject3); </code></pre> <p>So I want to remove objects from my...
<p>There's two options, an explicit delegate or a delegate disguised as a lamba construct:</p> <p>explicit delegate</p> <pre><code>myObjects.RemoveAll(delegate (MyObject m) { return m.X &gt;= 10; }); </code></pre> <p>lambda</p> <pre><code>myObjects.RemoveAll(m =&gt; m.X &gt;= 10); </code></pre> <hr /> <p>Performance wi...
<p>Predicate is a delegate which takes an param and returns a boolean.</p> <p>We can do the same in following ways</p> <p>1) <strong>Using inline Lambda expression</strong></p> <pre><code>RemoveAll(p=&gt; p.x &gt; 2); </code></pre> <p>2) <strong>Using anonymous function</strong></p> <pre><code>RemoveAll(delegate(m...
8,366
<p>Would there a more elegant way of writing the following syntax? </p> <pre><code> Thread t0 = new Thread(new ParameterizedThreadStart(doWork)); t0.Start('someVal'); t0.Join(); Thread t1 = new Thread(new ParameterizedThreadStart(doWork)); t1.Start('someDiffVal'); t1.Joi...
<p>Why would you start a thread and then join against it immediately?</p> <p>I'd normally do something like this:</p> <pre><code>List&lt;Thread&gt; threads = new List&lt;Thread&gt;(); foreach (string item in items) { string copy = item; // Important due to variable capture ThreadStart ts = () =&gt; DoWork(co...
<p>Why not have your parameters be part of the class, make them properties, and have the get/set methods lock around them? If you have enough parameters, make the parameter object itself a property of the object, and then lock that parameter block. As in:</p> <pre><code>class GonnaDoSomeThreading { private Object...
31,823
<p>I understand there is a HTTP response header directive to disable page caching:</p> <pre><code>Cache-Control:no-cache </code></pre> <p>I can modify the header by "hand":</p> <pre><code> &lt;%response.addHeader("Cache-Control","no-cache");%&gt; </code></pre> <p>But is there a "nice" way to make the JSP interprete...
<p>Also add </p> <pre> response.addHeader("Expires","-1"); response.addHeader("Pragma","no-cache"); </pre> <p>to your headers and give that a shot. </p>
<p>If you were using a servlet, then I believe what you posted in the question would be the correct approach. I'm not aware of any way to do this in the JSP.</p>
19,584