instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>I am using some C++ code that employs the <code>CreateDIBSection</code> function to create a bitmap and return a <code>HBITMAP</code> handle. What is the best way of getting this information into my .NET assembly?</p>
<p>The static method <a href="http://msdn.microsoft.com/en-us/library/k061we7x.aspx" rel="nofollow noreferrer">Image.FromHbitmap(IntPtr hbitmap)</a> might be what you are looking for.</p>
<p>Have you tried marshalling the byte array for your bitmap across, loading it into a MemoryStream and then using that stream to construct a Bitmap class?</p>
44,408
<p>I am parsing an Expression Tree. Given a NodeType of ExpressionType.MemberAccess, how do I get the value of that Field? </p> <p>From C# MSDN docs: MemberAccess is A node that represents reading from a field or property. </p> <p>A code snippet would be incredibly, incredibly helpful. Thanks in advance!!!</p> <p>M...
<p>[updated for clarity]</p> <p>First; cast the <code>Expression</code> to a <code>MemberExpression</code>.</p> <p>A <code>MemberExpression</code> has two things of interest:</p> <ul> <li>.Member - the <code>PropertyInfo</code> / <code>FieldInfo</code> to the member</li> <li>.Expression - the expression to evaluate ...
<p>thank you so so much to Marc Gravell above. I really appreciated his help. </p> <p>It turns out, in my case. the problem can be solved via:</p> <pre><code>object value = Expression.Lambda(expBody.Right).Compile().DynamicInvoke(); </code></pre> <p>Thanks again Mark!</p>
29,538
<p>Can anyone tell me, where on the web I can find an explanation for Bron-Kerbosch algorithm for clique finding or explain here how it works?</p> <p>I know it was published in "Algorithm 457: finding all cliques of an undirected graph" book, but I can't find free source that will describe the algorithm.</p> <p>I don...
<p>Try finding someone with an ACM student account who can give you a copy of the paper, which is here: <a href="http://portal.acm.org/citation.cfm?doid=362342.362367" rel="nofollow noreferrer">http://portal.acm.org/citation.cfm?doid=362342.362367</a></p> <p>I just downloaded it, and it's only two pages long, with an ...
<p>For what it is worth, I found a Java implementation: <a href="http://joelib.cvs.sourceforge.net/joelib/joelib2/src/joelib2/algo/clique/BronKerbosch.java?view=markup" rel="nofollow noreferrer">http://joelib.cvs.sourceforge.net/joelib/joelib2/src/joelib2/algo/clique/BronKerbosch.java?view=markup</a></p> <p>HTH.</p>
17,290
<p>I'm trying to find <a href="http://httpd.apache.org/docs/2.0/programs/ab.html" rel="noreferrer">ab - Apache HTTP server benchmarking tool</a> for Ubuntu, I'm hoping there's a package I can install for it. I decided I need to do some simple load testing on my applications.</p>
<pre><code>% sudo apt-get install apache2-utils</code></pre> <p>The command-not-found package in Ubuntu provides some slick functionality where if you type a command that can't be resolved to an executable (or bash function or whatever) it will query your apt sources and find a package that contains the binary you tri...
<p>Another way to search for missing files, e.g. if you use zsh, want to disable command-not-found (slows things down when you misstype commandnames), or are looking for a file that is not an executable:</p> <pre><code>$ sudo aptitude install apt-file $ sudo apt-file update $ apt-file search bin/ab </code></pre>
9,209
<p>In order to lighten Apache's load people often suggest using lighttpd to serve up static content.</p> <p>e.g. <a href="http://www.linux.com/feature/51673" rel="noreferrer">http://www.linux.com/feature/51673</a></p> <p>In this setup Apache passes requests for static content back to lighttpd via mod_proxy, while ser...
<p>Running Lighttpd <em>behind</em> Apache to serve static files certainly seems braindead to me. Apache still has to unpack the HTTP packets and parse the request through its parse tree, send proxy requests, and then Lighttpd has to re-unpack, hit the filesystem and send the files back through Apache. I've never heard...
<p>You don't have an Apache process spawned for each request - static files (images and the like) are fetched directly by lighttpd.</p>
21,968
<p>I am given a problem where I have been given N nodes in a graph that are interconnected to each other then given a matrix which lists down a node being connected to another (1 if it is, 0 if not). I am wondering how to best approach this problem. I think these are adjacency matrix? But how would I implement that ....
<p>You can implement this using a 2-dimensional array of booleans. So, if node i is connected to node j, then myarray[i][j] would be true. If your edges are not directional, then myarray[j][i] would be true whenever myarray[i][j] is.</p> <p>This can also be extended to weighted edges by using integers (or another nume...
<p>You might want to use <a href="http://www.sgi.com/tech/stl/bitset.html" rel="nofollow noreferrer">bitset</a> or <a href="http://www.sgi.com/tech/stl/bit_vector.html" rel="nofollow noreferrer">bit_vector</a> instead of bool[][].</p> <p>If you don't use a jagged array, and your connections are symmetric, consider wra...
45,468
<p>I need to send email through an (external) SMTP server from Java however this server will only accept CRAM-MD5 authentication, which is not supported by JavaMail.</p> <p>What would be a good way to get these emails to send? (It must be in Java.)</p>
<p>Here is <a href="http://lists.gnu.org/archive/html/classpathx-javamail/2010-10/msg00004.html" rel="noreferrer">thread</a> which says that you need to add the following property:</p> <pre><code>props.put("mail.smtp.auth.mechanisms", "CRAM-MD5") </code></pre> <p>Also in Geronimo implementation there is <a href="http...
<p><strong>Change:</strong></p> <pre><code>for (int i=0; i&lt;result.length; i++) hexString.append(Integer.toHexString(0xFF &amp; result[i])); </code></pre> <p><strong>To:</strong></p> <pre><code>for (int i=0;i &lt; result.length; i++) { hexString.append(Integer.toHexString((result[i] &gt;&gt;&gt; 4) &amp; 0x0F)...
22,613
<p>I'm looking to setup video uploads for users on a site and want to have them viewed through a Flash player. The site is already partially built (by someone else) and I'm wondering what kind of technologies there are to deal with the video files, specifically in PHP.</p> <p>I'm thinking the files need to be converte...
<p><a href="http://ffmpeg.mplayerhq.hu/" rel="nofollow noreferrer">ffmpeg</a> is the tool for you. It's a major opensource video encoding library that a lot of other tools are based on. It's a bit tricky to use directly, but I think there are a few wrappers around.</p>
<p>Use the YouTube API and let them do the heavy lifting for you.</p>
35,809
<p>Those of us who use multiple languages to solve problems can combine them in a lot of ways. Personally I use PL/SQL, XSLT, JavaScript, and Java plus the pseudo languages HTML, XML, CSS, Ant, and Bash. What do you use? </p>
<p>Paraphrasing one of my favorite quotes:</p> <blockquote> <p>Always write your code as if it were going to be maintained by a homicidal maniac that knows your home address.</p> </blockquote>
<p>I have a D/MySQL/JavaScript[1]/HTML/CPP[2] app.</p> <p>[1] compile time D template generated [2] C pre-processor used to generate apache configs and SQL sprocs</p> <p>Yes, I <em>am</em> trying to take things to the insane! ;)</p>
18,234
<p>I'm designing a database table which will hold filenames of uploaded files. What is the maximum length of a filename in NTFS as used by Windows XP or Vista?</p>
<p>Individual components of a filename (i.e. each subdirectory along the path, and the final filename) are limited to 255 characters, and the total path length is limited to approximately 32,000 characters.</p> <p>However, on Windows, you can't exceed <code>MAX_PATH</code> value (259 characters for files, 248 for fold...
<p>Actually it is 256, see <em><a href="http://msdn.microsoft.com/en-us/library/ee681827(VS.85).aspx#limits" rel="nofollow noreferrer">File System Functionality Comparison, Limits</a></em>.</p> <p>To repeat a post on <a href="http://fixunix.com/microsoft-windows/30758-windows-xp-file-name-length-limit.html" rel="nofol...
33,326
<p>Background: we have a system that was written in an older CMS based on Java back during the 2002-2003 days. We want to keep moving forward with our new stuff, using tomcat, stripes, and sitemesh. We have navigation, layouts, "pods", js, css, etc, that we've taken out of the old CMS and into a few of our new apps s...
<p>Five things I hate about Java:</p> <ul> <li>No first-class functions.</li> <li>No type inference.</li> <li>Lack of sane defaults in eg graphics.</li> <li>NullPointerException not containing more information about what is null.</li> <li>The proliferation of pointlessly "configurable" frameworks/service provider inte...
<p>Perl represents a horrid language.</p> <ol> <li>No "public" or "private" or "protected" declarations/definitions.</li> <li>The "my $variable_name;" does not declare a global outside of a subroutine.</li> <li>The "my $variable_name;" gets accessed by subroutines but "use strict;" or other "use " creates warnings.</l...
35,754
<p>Okay, here's the scenario. I have a utility that processes tons of records, and enters information to the Database accordingly.</p> <p>It works on these records in multi-threaded batches. Each such batch writes to the same log file for creating a workflow trace for each record. Potentially, we could be making close...
<p>I second the other answers here, <strong>depends on what you are doing with the data</strong>.</p> <p>We have two scenarios here:</p> <ol> <li><p>The majority of the logging is to a DB since admin users for the products we build need to be able to view them in their nice little app with all the bells and whistles....
<p>I think it depends greatly on what you are doing with the log files afterwards.</p> <p>Of the two operations writing to the log file will be faster - especially as you are suggesting writing to a database on another server.</p> <p>However if you are then trying to process and search the log files on a regular basi...
4,930
<p>In this thread, we look at examples of good uses of <code>goto</code> in C or C++. It's inspired by <a href="https://stackoverflow.com/questions/244445/best-refactoring-for-the-dreaded-while-true-loop#244644">an answer</a> which people voted up because they thought I was joking.</p> <p>Summary (label changed from ...
<p>Heres one trick I've heard of people using. I've never seen it in the wild though. And it only applies to C because C++ has RAII to do this more idiomatically. </p> <pre><code>void foo() { if (!doA()) goto exit; if (!doB()) goto cleanupA; if (!doC()) goto cleanupB; /* everyt...
<p>@Greg:</p> <p>Why not do your example like this:</p> <pre><code>void foo() { if (doA()) { if (doB()) { if (!doC()) { UndoA(); UndoB(); } } else { UndoA(); } } return; } </code></pre...
30,485
<p>I've been utlising a "web browser control" in desktop based applications (in my case Windows Forms .NET) for a number of years. I mostly use it to create a familiar flow-based user interface that also allows a seamless transition to the internet where required.</p> <p>I'm really tired of the IE browser control bec...
<p>hmm..Interestingly </p> <ol> <li><a href="http://www.iol.ie/~locka/mozilla/control.htm" rel="nofollow noreferrer">Mozilla</a> seems to provide ActiveX control</li> <li><a href="http://kmeleon.sourceforge.net/" rel="nofollow noreferrer">K-Melon</a> is another Gecko based browser control</li> </ol>
<p>Popular layout engines:</p> <ol> <li>Mozilla Gecko</li> <li>KHTML</li> <li>WebKit (based on KHTML)</li> </ol> <p>Though I'm not sure how easy it is to embed those in a .Net app.</p>
8,631
<p>I have 50+ kiosk style computers that I want to be able to get a status update, from a single computer, on demand as opposed to an interval. These computers are on a LAN in respect to the computer requesting the status.</p> <p>I researched WCF however it looks like I'll need IIS installed and I would rather not ins...
<p>Unless you have plans to scale this to several thousand clients I don't think WCF performance will even be a fringe issue. You can easily host WCF services from windows services or Winforms applications, and you'll find getting something working with WCF will be fairly simple once you get the key concepts.</p> <p>...
<p>For me its is better to learn networking.. or the manual way of socket communication.. web services are mush slower because it contains metadata..</p> <p>your clients and the servers can transform to multithreaded application. just imitate the request and response architecture. it is much easy to implement a networ...
29,425
<p>Let's say I have a class</p> <pre><code>public class ItemController:Controller { public ActionResult Login(int id) { return View("Hi", id); } } </code></pre> <p>On a page that is not located at the Item folder, where <code>ItemController</code> resides, I want to create a link to the <code>Logi...
<p>I think what you want is this:</p> <h2>ASP.NET MVC1</h2> <pre><code>Html.ActionLink(article.Title, "Login", // &lt;-- Controller Name. "Item", // &lt;-- ActionMethod new { id = article.ArticleID }, // &lt;-- Route arguments. null // &lt;-- htmlAr...
<p>This type use:</p> <p>@Html.ActionLink("MainPage","Index","Home")</p> <p>MainPage : Name of the text Index : Action View Home : HomeController</p> <p>Base Use ActionLink</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="s...
24,458
<p>I believe that Agile is nothing but another implementation of Spiral Model. I am a big supporter of Spiral (The spiral model is a software development process combining elements of both design and prototyping-in-stages, in an effort to combine advantages of top-down and bottom-up concepts) since its beginnings and h...
<p>Agile <strong>is</strong> spiral. Totally. In part, the name was changed for marketing purposes.</p> <p>The problem is that spiral tends to imply "big design up front" -- where you plan out many spirals, each in order of risk. Spiral, however, isn't Agile -- it's just incremental execution in order of risk.</p> ...
<p>First Agile is actually a number of different processes that follow a similar philosophy. One of the philosophy's that makes it different is that each iteration produces a working product. It could be described as iterative and incremental. A lot of emphasis is placed on the working product and on testing. In many a...
31,641
<p>I am trying to refactor some code I have for software that collects current status of agents in a call queue. Currently, for each of the 6 or so events that I listen to, I check in a Mnesia table if an agent exists and change some values in the row depending on the event or add it as new if the agent doesn't exist. ...
<p>I wrote some code a while ago that merges two records. Is not entirely dynamic, but whith macros you could easily use it for several records.</p> <p>It works like this: The merge/2 function takes two records and converts them to lists together with the empty record for reference (the record type is defined at compi...
<p>It is difficult to write generic access functions for records. One workaround for this is the <a href="http://forum.trapexit.org/viewtopic.php?p=21790#21790" rel="nofollow noreferrer">'exprecs'</a> library, which will generate code for low-level record access functions.</p> <p>The thing you need to do is to add the...
8,762
<p>I am trying to program a small server+client in Javascript on Firefox, using XPCOM.</p> <p>To get the HTTP message in Javascript, I am using the nsIScriptableInputStream interface. This f**ing component through the read() method randomly cut the message and I cannot make it reliable.</p> <p>Is anybody know a solut...
<p>I had the same problem with unreliability... I ended up using XMLHTTPRequest, which when used from the XPCOM component can do cross site requests. The second part of the <a href="http://developer.mozilla.org/en/XMLHttpRequest" rel="nofollow noreferrer">docs</a> detail how to instantiate the XPCOM version.</p> <p>If...
<p>If you control the protocol (that is, both the client and server) I would highly recommend using Javascript/JSON for your server-to-client messages. The client can open a stream either via dynamically adding a &lt;script&gt; tag to the DOM. The server can then send a stream of Javascript commands like:</p> <pre><...
9,857
<p>The Weblogic servers we are using have been configured to allow JNDI datasource names like "appds".</p> <p>For development (localhost), we might be running Tomcat and when declared in the &lt;context&gt; section of server.xml, Tomcat will hang JNDI datasources on "java:comp/env/jdbc/*" in the JNDI tree.</p> <p><st...
<p><code>JndiLocatorSupport</code> has a property <code>resourceRef</code>. When setting this true, "java:comp/env/" prefix will be prepended automatically. So I believe it would be correct to differentiate this parameter when moving from Tomcat to Weblogic.</p>
<p>My application also had a similar problem and this is how I solved it:</p> <p>1) <code>WEB-INF/classes/application.properties</code> contains the entry:</p> <pre> ds.jndi=java:comp/env/jdbc/tcds </pre> <p>2) On the WLS machine, I have an entry in the <code>/etc/sysenv</code> file:</p> <pre> ds.jndi=wlsds </pre> ...
6,992
<p>How are you supposed to unit test a web service in C# with Visual Studio 2008? When I generate a unit test it adds an actual reference to the web service class instead of a web reference. It sets the attributes specified in:</p> <p><a href="http://msdn.microsoft.com/en-us/library/ms243399(VS.80).aspx#TestingWebSe...
<p>What I usually do is not test directly against the web-service, but to try and put as little code as possible in the service, and call a different class which does all the real work. Then I write unit tests for that other class. It turns out that class can sometimes be useful outside of the web-service context, so t...
<p>Above my web method unit tests, I have the following:</p> <pre><code>// TODO: Ensure that the UrlToTest attribute specifies a URL to an ASP.NET page (for example, // http://.../Default.aspx). This is necessary for the unit test to be executed on the web server, // whether you are testing a page, web service, or a W...
48,616
<p>I have a very strange bug cropping up right now in a fairly massive C++ application at work (massive in terms of CPU and RAM usage as well as code length - in excess of 100,000 lines). This is running on a dual-core Sun Solaris 10 machine. The program subscribes to stock price feeds and displays them on "pages" conf...
<p>Stack corruption, 99.9% definitely.</p> <p>The smells you should be looking carefully for are:-</p> <ul> <li>Use of 'C' arrays</li> <li>Use of 'C' strcpy-style functions</li> <li>memcpy</li> <li>malloc and free</li> <li>thread-safety of anything using pointers</li> <li>Uninitialised POD variables.</li> <li>Pointer...
<p>Is something meaning to assign a value of 2 to a variable but instead is assigning its address to 2?</p> <p>The other details are lost on me but "2" is the recurring theme in your problem description. ;)</p>
31,399
<p>I'm using Microsoft Visual C++ 2008 Express, and have a pretty annoying problem. It doesn't seem to happen in XP but in Vista I can't find a way around it. Whenever I declare variables non-dynamically, if their combined size exceeds about 30mb, the program will crash immediately at start-up. I know that Vista limits...
<blockquote> <p>Is static allocation obsolete? </p> </blockquote> <p>You're not doing <em>static</em> allocation - you're doing <em>automatic</em> allocation and as the others have said, you're running out of stack.</p> <p>There are basically three common ways to reserve space for data in C++:</p> <ol> <li><p>On t...
<p>The problem is that non-dynamically allocated variables in methods are allocated on the stack, and the maximum stack size is MUCH less than the total available memory. I think it's around 30MB in Windows, yes. What you have done here is, ironically, this very site's namesake. A Stack Overflow.</p> <p>Edit: Accordin...
44,424
<p>Using jQuery, <strong>how do you match elements that are prior to the current element in the DOM tree?</strong> Using <code>prevAll()</code> only matches previous siblings.</p> <p>eg:</p> <pre><code>&lt;table&gt; &lt;tr&gt; &lt;td class="findme"&gt;find this one&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt...
<p>Ok, here's what I've come up with - hopefully it'll be useful in many different situations. It's 2 extensions to jQuery that I call <code>prevALL</code> and <code>nextALL</code>. While the standard <code>prevAll()</code> matches previous siblings, <code>prevALL()</code> matches ALL previous elements all the way up t...
<p>had the same problem, heres what i came up with. my function uses <a href="http://www.w3schools.com/jsref/met_node_comparedocumentposition.asp" rel="nofollow">compareDocumentPosition</a>. dont know how it compares to the other solutions in terms of performance though.</p> <pre><code>$.fn.findNext = function ( selec...
41,792
<p>I've got a JScript error on my page. I know where the error's happening, but I'm attempting to decipher the JScript on that page (to figure out where it came from -- it's on an ASPX page, so any number of user controls could have injected it).</p> <p>It'd be easier if it was indented properly. Are there any free JS...
<p>You really should use Firebug or some similar debugging tool to actually <em>find</em> the problem, but, if you want to just format your JavaScript code, <a href="http://javascript.about.com/library/blformat.htm" rel="nofollow noreferrer">here's a reformatter I found on Google</a>.</p>
<p>How about if you just run Firebug, it will tell you what the error is and will take you to where it is.</p> <p>Tools like phpDesigner (there's a free trial) have a code beautifier that will work on JavaScript, but nothing beats the good old TAB key (and shift tab to remove junk indention) :P</p>
46,524
<p>My application draws all its own window borders and decorations. It works fine with Windows taskbars that are set to auto-hide, except when my application window is maximized. The taskbar won't "roll up". It will behave normally if I have the application not maximized, even when sized all the way to the bottom of ...
<p>I found the problem. My application was handling the WM_GETMINMAXINFO message, and was overriding the values in the parameter MINMAXINFO record. The values that were in the record were inflated by 7 (border width) the screen pixel resolution. That makes sense in that when maximized, it pushes the borders of the w...
<p>This is dependant on whether 'Keep the taskbar on top of other windows' is checked on the taskbar properties. If it's checked then the taskbar will appear.</p> <p>But don't be tempted to programmatically alter this setting on an end users machine just to suit your needs, it's considered rude and bad practice. Your ...
16,573
<p>When modelling for 3D printing, can I distinguish somehow the type of infill in various areas of the model? Say there may be some areas in the model where I want 100% infill (maximum strength) but some areas where the infill can be less (maybe 25%).</p> <p>I am new to 3D printing, doing my first model (enclosure fo...
<p>To achieve additional localised stiffness, you can also insert small voids (gaps) inside the model. These become double thickness walls once sliced and can be used to support things like screw holes.</p> <p>See the 'negative' parts used with a cube, and the sliced result here: <a href="https://i.stack.imgur.com/eUL...
<p>I found out I misunderstood some principles of designing/modelling for 3D printing.</p> <p>I designed my object for 100% infill which is not really necessary. It turned out that one does not mostly have to take care of the infill % and just model the object for example as solid 3D cube and the printing service will...
1,050
<p>I was reading an article on MSDN Magazine about using the <a href="http://msdn.microsoft.com/en-us/magazine/cc700332.aspx" rel="noreferrer">Enumerable class in LINQ</a> to generate a random array. The article uses VB.NET and I'm not immediately sure what the equivalent is in C#:</p> <pre><code>Dim rnd As New System...
<p>The <a href="http://www.developerfusion.com/tools/convert/vb-to-csharp/" rel="noreferrer">Developer Fusion VB.Net to C# converter</a> says that the equivalent C# code is:</p> <pre><code>System.Random rnd = new System.Random(); IEnumerable&lt;int&gt; numbers = Enumerable.Range(1, 100).OrderBy(r =&gt; rnd.Next()); </...
<p>Best I can do off the top of my head without access to Visual Studio (crosses fingers):</p> <pre><code>System.Random rnd = New System.Random(); IEnumerable&lt;int&gt; numbers = Enumerable.Range(1, 100).OrderBy(rnd =&gt; rnd.Next); </code></pre>
31,793
<p>It is much more convenient and cleaner to use a single statement like</p> <pre><code>import java.awt.*; </code></pre> <p>than to import a bunch of individual classes</p> <pre><code>import java.awt.Panel; import java.awt.Graphics; import java.awt.Canvas; ... </code></pre> <p>What is wrong with using a wildcard in...
<p>The only problem with it is that it clutters your local namespace. For example, let's say that you're writing a Swing app, and so need <code>java.awt.Event</code>, and are also interfacing with the company's calendaring system, which has <code>com.mycompany.calendar.Event</code>. If you import both using the wildc...
<p>Importing all the classes in a package is considered a blind approach. A major reason for this is that it clutters the class namespace and could lead to conflicts between classes in different packages with the same name.</p> <p>Specifically populating the necessary classes avoids that problem and clearly shows which...
17,751
<p>Given a string as below, I need to convert:</p> <p>1 Dec 2008 06:43:00 +0100</p> <p>to</p> <p>MM/DD/YYYY HH:MM:SSAM</p> <p>using jython what is the best way to do this?</p>
<p>I don't have jython handy, but I'd expect something like this to work:</p> <pre><code>import java sdf = java.text.SimpleDateFormat fmt_in = sdf('d MMM yyyy HH:mm:ss Z') fmt_out = sdf('MM/dd/yyyy HH:mm:ssaa') fmt_out.format(fmt_in.parse(time_str)) </code></pre>
<p><a href="http://www.jython.org/" rel="nofollow noreferrer">Jython</a> 2.5b0 (beta) has an implementation of the <a href="http://www.python.org/doc/2.5.2/lib/module-time.html" rel="nofollow noreferrer">time module</a> that includes</p> <blockquote> <p><code>strptime(string[, format])</code>.</p> <p>Parse a string rep...
42,797
<p>What's the easiest way to play a sound file (.wav) in Python? By easiest I mean both most platform independent and requiring the least dependencies. pygame is certainly an option, but it seems overkill for just sound.</p>
<p>For Windows, you can use winsound. It's built in</p> <pre><code>import winsound winsound.PlaySound('sound.wav', winsound.SND_FILENAME) </code></pre> <p>You should be able to use ossaudiodev for linux:</p> <pre><code>from wave import open as waveOpen from ossaudiodev import open as ossOpen s = waveOpen('tada.wav'...
<p>For Linux user, if low level pcm data manipulation is needed, try <a href="http://pyalsaaudio.sourceforge.net/index.html" rel="nofollow">alsaaudio</a> module. There is a playwav.py example inside the package too. </p>
39,545
<p>I need to store database passwords in a config file. For obvious reasons, I want to encrypt them (preferably with AES). Does anyone know a Delphi implementation that is easy to introduce into an existing project with > 10,000 lines of historically grown (URGH!) source code?</p> <p>Clarification: Easy means adding t...
<p>I second the recommendation for David Barton's <a href="http://www.cityinthesky.co.uk/cryptography.html" rel="noreferrer">DCPCrypt library</a>. I've used it successfuly in several projects, and it won't take more than 15 minutes after you've read the usage examples. It uses MIT license, so you can use it freely in c...
<p>Nick is of course right - I just assume you know what you are doing when you say you want to spend all of 15 minutes on implementing a security solution. The DCPCrypt library also implements a number of hashing algorithms if you decide to go that (better) route.</p>
16,149
<p>You're building a web application. You need to store the state for a <em>shopping cart like</em> object during a user's session.</p> <p>Some notes:</p> <ul> <li>This is not exactly a shopping cart, but more like an itinerary that the user is building... but we'll use the word cart for now b/c ppl relate to it.</li...
<p>It's been my experience with the Commerce Starter Kit and MVC Storefront (and other sites I've built) that no matter what you think now, information about user interactions with your "products" is paramount to the business guys. There's so many metrics to capture - it's nuts.</p> <p>I'll save you all the stuff I've...
<p>If you care about supporting users without Javascript enabled, then the server side sessions will let you use URL rewriting.</p>
12,175
<p>We have an ASP.NET application that manages it's own User, Roles and Permission database and we have recently added a field to the User table to hold the Windows domain account. </p> <p>I would like to make it so that the user doesn't have to <strong>physically</strong> log in to our application, but rather would...
<p>I did pretty much exactly what you want to do a few years ago. Im trying to find some code for it, though it was at a previous job so that code is at home.</p> <p>I do remember though i used <a href="http://msdn.microsoft.com/en-us/library/ms998360.aspx" rel="nofollow noreferrer">this article</a> as my starting poi...
<p>You can use <code>System.Threading.Thread.CurrentPrincipal</code>.</p>
7,765
<p>I am evaluating BPEL engine for our high performance telecom application but performance seem to be very poor. We have evaluated Apache Ode, SunBPEL engine, Active BPEL etc. Do you know any faster BPEL engine implementation or BPEL implementation in C/C++ ?</p>
<p>I believe your performance measurements were very brief.</p> <p>For example, I'm familiar with Apache ODE and I must say there is quite a lot of possibilities to speed things up. After doing configuration optimizations, like using in-memory processes and disabling debug events, I got 60 TPS in SoapUI. After I did ...
<p>Have you looked at Oracle BPEL? If it's like their database, it's probably fast but hard to configure and administer.</p>
34,949
<p>I'm a VMware user and far too often I use keyboard shortcuts while programming. However, this has proved to be quite distressing as sometimes the VMware gets hold of it and turns off / pauses (<kbd>Ctrl</kbd>+<kbd>Z</kbd>) the virtual machine.</p> <p>Is there a way to disable keyboard shortcuts on VMware? Has anyon...
<p>I use AutoHotKey (are you running VMWare on Windows ?) to disable certain shortcuts. You can find this tool here:</p> <p><a href="http://www.autohotkey.com/" rel="noreferrer">http://www.autohotkey.com/</a></p> <p>It's open source and I quite like it. Can be used for automation tasks, but you can also have it respo...
<p>If it is Ok for you - here's a bit of hacky solution which is very simple - just use ResHacker program to get rid of those annoying accelerators (they are defined as resources in vmware.exe).</p>
18,449
<p>I have been working with Visual Studio (WinForm and ASP.NET applications using mostly C#) for several months now. For the most part my IDE is set up fairly standard but I have been wondering what are some suggestions in terms of plugins/settings that you find to be the most useful?</p> <p><strong>Update</strong>: ...
<p><strong><a href="http://www.jetbrains.com/resharper/" rel="nofollow noreferrer">Resharper</a></strong> is definitely a great tool. It has a moderate learning curve but is easy to pick up for some simple things and add mastery later. It is a good price for students and kinda expensive for the rest of us. Resharper...
<p>I have Resharper and SQL Prompt, both are excellent.</p>
6,331
<p>If you've worked on a project that stores data for use with the semantic web, do you use RDF or even OWL as the internal data format or do you have your own data model/ontology that you map to RDF for interoperability? </p> <p>If you use RDF, what are your experiences with implementing various things like cyclical ...
<p>I work alongside the Jena team at HP (indeed, have contributed to Jena myself), so using Jena is a fairly straightforward choice in our team. However, there are more reasons than just "next-bench" convenience. The various standards for the semantic web contain quite a bit of detail and complexity, and getting that r...
<p>I'm currently working on some really small projects in this area and I "mostly" use RDF there, although for parsing purposes I use a simple URI-registry in order to avoid cycles in the data structure itself. Although, I have to say that I'm still in the conceptual stage of these projects. In the end I rely mostly on...
16,737
<p>I ran across this situation this afternoon, so I thought I'd ask what you guys do.</p> <p>We have a randomized password generator for user password resets and while fixing a problem with it, I decided to move the routine into my (slowly growing) test harness.</p> <p>I want to test that passwords generated conform ...
<p>A unit test should do the same thing every time that it runs, otherwise you may run into a situation where the unit test only fails occasionally, and that could be a real pain to debug.</p> <p>Try seeding your pseudo-randomizer with the same seed every time (in the test, that is--not in production code). That way ...
<p>Well, considering they are random, there is no really way to make sure, but testing for 100 000 password should clear most doubts :)</p>
11,365
<p>I am looking for an app that will let me type in code ON my cellphone. I don't need to compile or anything, and its not to program for the cellphone. Just something nice to have when an idea pops in my head.</p> <p>Am I completely overlooking a simple code editor for Symbian S60v3 phones? </p> <p>I am looking for ...
<p>I've used <a href="http://users.tkk.fi/~lhuovine/mobile/python.html" rel="nofollow noreferrer">pyEdit</a> on my S60v2 phone, it looks like it's supported under v3 as well.</p> <p>It depends on the python runtime, so you'll need to install that first.</p>
<p>You can use visual studio :</p> <p><a href="http://wiki.forum.nokia.com/index.php/Using_Visual_Studio_6.0_with_S60_3rd_Edition" rel="nofollow noreferrer">http://wiki.forum.nokia.com/index.php/Using_Visual_Studio_6.0_with_S60_3rd_Edition</a></p>
17,176
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/144833/most-useful-attributes-in-c">Most Useful Attributes in C#</a> </p> </blockquote> <p>besides:</p> <pre><code>[DefaultValue(100)] [Description("Some descriptive field here")] public int MyProperty{get; se...
<pre><code>[Obsolete("This is an obsolete property")] </code></pre> <p>That's one of my favourites. Allows you to mark a property/method obsolete, which will cause a compiler warning (optionally, a compiler error) on build.</p>
<p><a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.localizableattribute(VS.71).aspx" rel="nofollow noreferrer">Localizable </a> as well as <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.listbindableattribute(VS.71).aspx" rel="nofollow noreferrer">ListBindable</a> may be in...
25,792
<p>Without using Javascript, is there a way to make a CSS property toggle on and off through nested elements.</p> <p>The problem I'm trying to solve is that I have a number of tags and classes which make some text italic (<code>&lt;em&gt;</code>, <code>&lt;blockquote&gt;</code>, <code>&lt;cite&gt;</code>, <code>&lt;q&...
<p>I couldn't tell you which browsers (if any) implement the CSS3 <code>:not</code> pseudo-class, but if we see it supported sometime it seems like we can do:</p> <pre> q:not(q, em, dfn, cite, blockquote), em:not(q, em, dfn, cite, blockquote), dfn:not(q, em, dfn, cite, blockquote), cite:not(q, em, dfn, cite, blockq...
<p>You say you have all sorts of elements that needs displaying as italic, but once nested they need to break previous italication. Forgive me for saying, but I am truly wondering if one should really want such behavior.</p> <p>Allow me to explain myself: you have different markup such as a quote, citation, emphasis e...
25,387
<p><strong>Background</strong>:</p> <p>I have a VB6 application I've "inherited" that generates a PDF for the user to review using unsupported Acrobat Reader OCX integration. The program generates an FDF file with the data, then renders the merged result when the FDF is merged with a PDF. It only works correctly wit...
<p>can't help with VB6 solution, can help with .net or java solution on the server.<br> Get iText or iTextSharp from <a href="http://www.lowagie.com/iText/" rel="nofollow noreferrer">http://www.lowagie.com/iText/</a>.<br> It has a PdfStamper class that can merge a PDF and FDF FDFReader/FDFWriter classes to generate F...
<p>Take my advice. Ditch PDF for XPS. I am working on two apps, both server based. One displays image-based documents as PDFs in a browser. The second uses FixedPage templates to construct XPS documents bound to data sources. </p> <p>My conclusion after working on both projects is that PDFs suck; XPS documents le...
7,844
<p>I am having some trouble with model adherence to my print bed. As shown in the attached photo, my model is pulled away at the sides leaving it bowed even though it is designed to be flat. Other than this &quot;bowing&quot;, the model is of good quality.</p> <p>The model is printed solid on an Anycubic Photon M3 Plus...
<h2>Print orientation</h2> <p>Your model is pulled up from the FEP film with a huge force. It releases from the film first at the corners, then progresses to the center. The force bends the model down as it is still flexible, so it creates a bent item.</p> <p>This can be mitigated by reducing the area that you pull at....
<h2>Print orientation</h2> <p>Your model is pulled up from the FEP film with a huge force. It releases from the film first at the corners, then progresses to the center. The force bends the model down as it is still flexible, so it creates a bent item.</p> <p>This can be mitigated by reducing the area that you pull at....
2,204
<p>I'm writing a PHP script and the script outputs a simple text file log of the operations it performs. How would I use PHP to delete the first several lines from this file when it reaches a certain file size?</p> <p>Ideally, I would like it to keep the first two lines (date/time created and blank) and start deletin...
<h2>Use the SPL, Luke</h2> <p>PHP 5 comes with plenty of iterators goodness :</p> <pre><code>&lt;?php $line_to_strip = 5; $new_file = new SplFileObject('test2.log', 'w'); foreach (new LimitIterator(new SplFileObject('test.log'), $line_to_strip) as $line) $new_file-&gt;fwrite($line); ?&gt; </code></pre> <p...
<p>Typical operating systems don't provide the capability to insert or delete content of a file "in-place". What you will need to do is write a function that reads the first file, and creates a <em>new</em> output file containing the lines you want to keep. Then when you're done, delete the old file and rename the new ...
26,537
<p>For a project I am working on in ruby I am overriding the method_missing method so that I can set variables using a method call like this, similar to setting variables in an ActiveRecord object:</p> <p><code>Object.variable_name= 'new value'</code> </p> <p>However, after implementing this I found out that many of ...
<p>Don't do it!</p> <p>Trying to create identifiers that are not valid in your language is not a good idea. If you really want to set variables like that, use attribute macros:</p> <pre><code>attr_writer :bar attr_reader :baz attr_accessor :foo </code></pre> <p>Okay, now that you have been warned, here's how to do i...
<p>If there's no hope of changing the canonical names, you could alias the getters and setters manually:</p> <pre><code>def variable_name send 'variable.name' end def variable_name=(value) send 'variable.name=', value end </code></pre>
7,173
<p>The reason I ask is that Stack Overflow has been <a href="http://slashdot.org/firehose.pl?op=view&amp;id=1170403" rel="nofollow noreferrer">Slashdotted</a>, and <a href="http://www.reddit.com/r/programming/comments/71i4v/stack_overflow_launched_into_public/" rel="nofollow noreferrer">Redditted</a>.</p> <p>First, wh...
<p>Unfortunately, if you haven't planned for this before it happens, it's probably too late and your users will have a poor experience. </p> <p>Scalability is your first immediate concern. You may start getting more hits per second than you were getting per month. Your first line of defense is good programming and d...
<p>The app designer needs to think about scaling up (larger machines with more cores and higher performance) and/or scaling out (distributing workload across multiple systems). The IT guy needs to work out how to best support that. The network is what you look at first, because obviously everything rides on top of it....
8,780
<p>I'm using flex builder to compile my SWF. Im using mp3's on my local machine and computeSpectrum() to analyze the mp3. </p> <p>After playing for 20secs, my computeSpectrum stops returning values, instead, it starts returning this error:</p> <pre><code>SecurityError: Error #2121: Security sandbox violation: SoundMi...
<p>The flash player thinks it's trying to open a local file from a website. This is ignored if you run it from the flash ide. It should also work as it is if you upload it to a webserver.</p> <p>To be able to test locally add access to your swf (or the entire project folder) using the security tab on <a href="http://w...
<p>Issues I've had with computeSpectrum in the past were caused by the global way Flash checks the audio sandbox, meaning other unrelated Flash content open in the browser (e.g. YouTube) is treated as if your swf was trying to load it - this means that if you run your app and then open YouTube you will get an error.</p...
27,465
<p>I'm writing a custom blog engine and would like to have trackbacks similar to Wordpress. I could look at the Wordpress source, but I'd really prefer a tutorial of some sort and so far I haven't been able to find one. Are there any good tutorials for implementing trackbacks or pingbacks in PHP5? </p>
<p>Trackbacks are fine, but they're very prone to spam, since there's no verification of their origin. You use a simple discovery method to find the trackpack entrypoint; look for RDF in the target site's source. Then it's simply a RESTful POST request to the destination site's trackback entrypoint passing the requis...
<p>Dunno what trackbacks are, all I've noticed of them is that they clutter up websites with messy blocks of text, often interpersed with article comments.</p> <p>But if they allow you to see who is linking to you in real time without log analysis:</p> <p>You could use the HTTP-Referer (sic) header to see if people h...
35,698
<p>I've seen a few sites that list related searches when you perform a search, namely they suggest other search queries you may be interested in.</p> <p>I'm wondering the best way to model this in a medium-sized site (not enough traffic to rely on visitor stats to infer relationships). My initial thought is to store t...
<p>Here are some interesting sources:</p> <ul> <li>the <a href="http://dddcommunity.org/books/index.html#DDD" rel="noreferrer">DDD</a> book by Eric Evans</li> <li>the free <a href="http://dddcommunity.org/books/index.html#DDD_quickly" rel="noreferrer">DDD Quickly</a> book</li> <li>the <a href="http://groups.yahoo.com/...
<p><a href="https://rads.stackoverflow.com/amzn/click/com/0321268202" rel="nofollow noreferrer" rel="nofollow noreferrer">Applying Domain-Driven Design and Patterns</a> is a very good book on the subject. Lots of good examples as well as discussion of related subjects like test driven development and how they apply.</p...
15,068
<p>The only reliable method that I a have found for using a script to download text from wikipedia is with cURL. So far the only way I have for doing that is to call <code>os.system()</code>. Even though the output appears properly in the python shell I can't seem to the function it to return anything other than the ex...
<p>From <a href="http://diveintopython.net/html_processing/extracting_data.html" rel="nofollow noreferrer">Dive into Python:</a> </p> <pre><code>import urllib sock = urllib.urlopen("http://en.wikipedia.org/wiki/Python_(programming_language)") htmlsource = sock.read() sock.close() print htmlsource </code></pre> <p>Th...
<p>As an alternetive to urllib, you could use the libCurl <a href="http://curl.haxx.se/libcurl/python/" rel="nofollow noreferrer">Python bindings</a>.</p>
45,756
<p>If I have an NSString with a text file in it, how do I get an NSArray of NSString with each NSString containing a line of the file.</p> <p>In 10.5 I did this:</p> <pre><code>NSArray* lines = [str componentsSeparatedByCharactersInSet: [NSCharacterSet newlineCharacterSet]]; </code></pre> <p>But that doesn't work in...
<p>The following code is straight from <a href="http://developer.apple.com/documentation/Cocoa/Conceptual/Strings/Articles/stringsParagraphBreaks.html" rel="nofollow noreferrer">Apple's documentation regarding paragraphs and line breaks</a>:</p> <pre><code>unsigned length = [string length]; unsigned paraStart = 0, par...
<p>You can also do <code>enumerateSubstringsInRange:</code> with the <code>NSStringEnumerationByLines</code> and/or <code>NSStringEnumerationByParagraphs</code> options.</p> <p>The benefit of doing it that way is that you get the NSRange of each substring, and can also set the initial range of the string to enumerate....
44,540
<p>Windows XP Disk Defragmenter report shows a constant <strong>gap</strong> in disk usage on a number of disk partitions on my system. I'm not referring to the little transitory gaps that occur. In disk D below, the gap in question is the one under the word "defragmentation". In disk P below, the gap is the one und...
<p>That is probably the space reserved for the <a href="http://en.wikipedia.org/wiki/Master_File_Table" rel="nofollow noreferrer">MFT</a>, which will only be used for files if the disk gets really full. This empty space allows it to grow for a while without getting fragmented.</p> <p>References:</p> <ul> <li><a href=...
<p>No idea what's causing this, but the defragger that comes with Win XP is Diskkeeper Lite, which is not very good. A better defragger might get rid of the gap if it's not being caused by anything. I personally use O&amp;O Defrag; it's not free, but there's a 30-day trial.</p>
32,193
<p>Here is a simplified version of my application showing what I'm doing. </p> <pre><code>/* in my app's main(): Runner run = new Runner(); run.dowork(); */ class Runner { private int totalWorkers = 2; private int workersDone = 0; public synchronized void workerDone() { workersDone...
<p>Working directly with <code>synchronized</code>, <code>wait()</code>, and <code>notify()</code> is definitely tricky.</p> <p>Fortunately the <a href="http://java.sun.com/javase/6/docs/api/java/util/concurrent/package-summary.html" rel="nofollow noreferrer">Java Concurrency API</a> provides some excellent control ob...
<p>IMHO you have improperly placed "workersDone = 0".</p> <pre><code>public synchronized void dowork() { // workersDone = 0; //&lt;code for opening a file here, other setup here, etc&gt; Worker a = new Worker(this); Worker b = new Worker(this); ...
45,679
<p>My team uses an internal team maven repo that is shared from a development server using Apache. We also run the Continuum CI server on the same machine. Maven builds in Continuum are run with the &quot;install&quot; goal, which copies the final artifact directly into the shared directory.</p> <p>The question is, wha...
<p>Ken, good question. I should be more explicit in the <a href="http://www.sonatype.com/books/maven-book/reference/public-book.html" rel="noreferrer">The Definitive Guide</a> about the difference. "install" and "deploy" serve two different purposes in a build. "install" refers to the process of installing an art...
<p>"matt b" has it right, but to be specific, the "install" goal copies your built target to the local repository on your file system; useful for small changes across projects not currently meant for the full group.</p> <p>The "deploy" goal uploads it to your shared repository for when your work is finished, and then ...
25,399
<p>Is it possible to have all the computing capacity of all the hardware nodes allocated to one instance (for eg. one basic linux installation)?</p> <p>How to manage the cloud?</p>
<p>I think you're confusing cloud computing and grid computing here. Although they do have similarities.</p> <p>Cloud computing is usually used to refer to solutions where data is stored somewhere on the internet and made available on any workstation that is online.</p> <p>Grid computing is used to refer to applicati...
<p>For a defenition of cloud computing,I like <a href="https://stackoverflow.com/questions/108037/what-is-cloud-computing#108042">blowdart's reply here</a>, it's basically using online resources, so you're not allocating the resources yourself on a LAN, but using 3rd party services (like amazon/google and maybe microso...
28,819
<p>I've so far dabbled in Flash doing 1-man shows for quite some time, but have never done any big projects with it, where actually source management and code-reuse was truly necessary. However I'm considering Flash for a new project, but this time around it's won't be a 1-man show, that's when it struck me that I had ...
<ul> <li>Good communication</li> <li>Don't work in .fla's. 100% of the code in .as files</li> <li>UML (at least discussed)</li> <li>Different tasks for everybody</li> <li>Comments in commits to code repository</li> <li>"Manage your code so that anybody can at any time take over your job"</li> <li>Consider <a href="http...
<p>Antti has a bunch of good ones, externalizing code and appointing a leader in particular, I'd just add that when you're picking different tasks for everyone, tell people to code their piece as a modular class that provides the functionality you'll need - that'll make the code more reuseable in the future, and make i...
23,161
<p>I have a main canvas 'blackboard' in a panel, this canvas has itself several children, like a toolbar (tiles), a label and some skinning.</p> <p>The problem is that when I move to the rectangle tool and I start drawing rectangles if I want to change the tool when I click on an other tool such as 'circle' or 'select'...
<p>Well, int64 uses 8 byte of memory storage, while int uses 4 byte... however, you pointed out most of the disadvantages already. Of course calculations performed will also be slower on many systems (a 64 bit system running in 64 bit mode can perform operations on 64 bit as fast as on 32 bit, but a 32 bit system needs...
<p>Portability... though C# isn't really know as lingua franca if you're going for portable, so this might be moot for your perspective?</p>
30,087
<p>When there are one of more columns that reference another, I'm struggling for the best way to update that column while maintaining referential integrity. For example, if I have a table of labels and descriptions and two entries:</p> <pre><code>Label | Description ------------------------------------ read | This it...
<p>If you have many rows referencing READ, you could alter the foreign key to be on cascade update, update that table set Label = 'read' where Label = 'READ' and everything will get automagically fixed. After that you can alter the constraint again to be as it was before.</p> <p>To find all the tables referencing the ...
<p>For the future you could create an unique index on the column "label", for example:</p> <pre><code>CREATE UNIQUE INDEX index_name ON table ((lower(label))); </code></pre> <p>Or check the <a href="http://www.postgresql.org/docs/current/static/sql-createindex.html" rel="nofollow noreferrer">manual</a>. That would he...
29,479
<p>I have a database table called "Posts" which stores all the information regarding an article submission on a website. There is a column named "Views" which is a value that gets incremented each time that particular post gets viewed. </p> <p>The process is this:</p> <ol> <li>Get the record from the database </li> <...
<p>Do it in one go:</p> <pre><code>UPDATE table SET views=views+1 WHERE myId=12; </code></pre>
<p>If your db context is called _db you can use this.</p> <pre><code>_db.ExecuteCommand("UPDATE posts SET views=views+1 WHERE id={0}", postId); </code></pre> <p>for further reading check out the Gu's post here.</p> <p><a href="http://weblogs.asp.net/scottgu/archive/2007/08/27/linq-to-sql-part-8-executing-custom-sql-...
49,284
<p>When trying to launch and run a flex/java project in eclipse I kept getting a "Out of Memory Exception" and "Java Heap Space" using Eclipse, Tomcat and a JRE.</p> <p>While researching trying to adjust the memory settings I found three places to adjust these:</p> <ul> <li><p>Eclipse.ini</p></li> <li><p>The JRE Sett...
<p>-xms is the start memory (at the VM start), -xmx is the maximum memory for the VM</p> <ul> <li>eclipse.ini : the memory for the VM running eclipse</li> <li>jre setting : the memory for java programs run from eclipse</li> <li>catalina.sh : the memory for your tomcat server</li> </ul>
<p>If you see an out of memory, consider if that is plausible: Do you really need that much memory? If not (i.e. when you don't have huge objects and if you don't need to create millions of objects for some reason), chances are that you have a memory leak.</p> <p>In Java, this means that you're keeping a reference to ...
43,312
<p>In my case, I have a number of column names coming from a form. I want to filter to make sure they're all true. Here's how I currently do it:</p> <pre><code>for op in self.cleaned_data['options']: cars = cars.filter((op, True)) </code></pre> <p>Now it <em>works</em> but there are are a possible ~40 columns to ...
<p>Build the query as a dictionary and use the ** operator to unpack the options as keyword arguments to the filter method.</p> <pre><code>op_kwargs = {} for op in self.cleaned_data['options']: op_kwargs[op] = True cars = CarModel.objects.filter(**op_kwargs) </code></pre> <p>This is covered in the <a href="http:/...
<p>Build the query as a dictionary and use the ** operator to unpack the options as keyword arguments to the filter method.</p> <pre><code>op_kwargs = {} for op in self.cleaned_data['options']: op_kwargs[op] = True cars = CarModel.objects.filter(**op_kwargs) </code></pre> <p>This is covered in the <a href="http:/...
46,038
<p>I am working on an ASP site hosted using SUN One (used to be called Chillisoft) server. I am having trouble loading in an XML file, the code I am using is below</p> <pre><code>dim directory set directory = Server.CreateObject("MSXML2.DOMDocument") if(directory.load(Server.MapPath("directory.xml"))) then Respo...
<p>I don't know much about Sun One but I do know it has a Bean that emulates MSXML.</p> <p>Oridinarily, you would use:-</p> <pre><code>Set directory = Server.CreateObject("MSXML2.DOMDocument") directory.async = false directory.load(Server.MapPath("directory.xml") </code></pre> <p>Otherwise load returns immeadiately ...
<p>The load likely returns false because it hasn't fully loaded the document yet. You need to find a way to set async to false. If the Sun One is emulating MSXML2.DOMDocument well then async should accept false but you could try -<code>1</code> or <code>Response.Write(directory.async)</code> to get an idea of what it...
19,480
<p>We need a good CMS that supports data clustering (managing and storing data on different servers). By "good" , I mean : reliable , minimum bugs , the faster the better. (Oh , and it should make coffee :) ) </p>
<p>Yes … kitchen sink + community + support: Plone. Development heading very much in the right direction. </p> <p>Plone is in some ways a different creature from many other systems. Depending on the environment, ultra-high performance may require some attention but in the community there's great expertise to steer any...
<p>I am not sure about "Performance-oriented" means for you. There are sites with Drupal and Joomla that receives million of visits month after month, and do not need special configurations like data clustering.</p> <p>I think you must ask yourself if you need all you said.</p> <p>For reliability, and no bugs or mini...
9,521
<p>How can I assign a keyboard shortcut to a VBA macro in Outlook 2007?</p> <p>I know how to create a tool for the macro and put it in a menu with an underscore shortcut. This solution requires me to use a shortcut of <kbd>Alt</kbd> + <kbd>{menu key}</kbd> + <kbd>{tool key}</kbd>. What if I want to assign it to <kbd>A...
<p>Since Outlook doesn't have the OnKey event, the easiest way is to assign a toolbar button to the macro and put an ampersand in its name somewhere. This only works if your shortcut letter doesn't conflict with an existing shortcut.</p> <p>You may also have luck with setting a global hotkey, but it's usually more pai...
<p>Since Outlook doesn't have the OnKey event, the easiest way is to assign a toolbar button to the macro and put an ampersand in its name somewhere. This only works if your shortcut letter doesn't conflict with an existing shortcut.</p> <p>You may also have luck with setting a global hotkey, but it's usually more pai...
8,127
<p>I use emacs for viewing and editing code and other text files. I wanted to know if there is a way to search forward or backward for text which is marked in the current buffer. Similar to what I can do in notepad or wordpad. As in can I mark some text in the buffer and do a C-s or C-r and be able to search with the m...
<p>@Alex nails it.</p> <p>Another option I use quite often is <code>C-s C-w</code> to search for the word after the current mark. Hitting <code>C-w</code> repeatedly increases the search with additional words (e.g., <code>C-s C-w C-w C-w</code> searches for the 3 words after the current mark).</p> <p>Similarly, <code...
<p>You can find C-s help by doing C-h k C-s, and it says:</p> <blockquote> <p>Type DEL to cancel last input item from end of search string. Type RET to exit, leaving point at location found. Type LFD (C-j) to match end of line. Type C-s to search again forward, C-r to search again backward. <strong><em>Type C-...
24,806
<p>It's been a while since I used Java in anger so please forgive me if this is silly.</p> <p>I have just got started on a Java project where we are using JAXB to de-serializing an incoming XML string (from Jetty Server). The project is only using JAXB for this situation.</p> <p>What are the alternatives to JAXB?<br>...
<p>I've found JAX-B pretty useful and actually like it better than many of the alternatives, especially if I'm starting from scratch and generating a schema from Java objects rather than Java objects from a schema. </p> <p>In my experience, for whatever reason, I've found good documentation hard to come by from just G...
<p>For alternatives to JAXB you might want to check out XFire (<a href="http://xfire.codehaus.org/" rel="nofollow noreferrer">http://xfire.codehaus.org/</a>) or Axis2 (<a href="http://ws.apache.org/axis2/" rel="nofollow noreferrer">http://ws.apache.org/axis2/</a>). Those seem to be 2 popular alternatives, and I believ...
48,583
<p>I've tried to the letter to search for mistakes in my code, but i can't myself get that autocomplete extender to work. Help wanted. </p> <p>Here's my code: (excerpt from my aspx page) </p> <pre><code> &lt;asp:TextBox ID="TextBox1" Width="120px" runat="server"&gt;&lt;/asp:TextBox&gt; &lt;cc1:AutoCompleteExtend...
<p>How to troubleshoot this:</p> <p>Comment out your SQL code. Just return an array with some test data. Does that work? Do you see it? If not, your webservice code is not getting called. If that works, your problem is with your database code.... Is your webservice code on the calling page?</p>
<p>I think your problem is that the <code>GetCompletionList</code> method is declared <code>static</code>.</p> <p>If you run up just the .asmx code in a debugger session (or browse to the .asmx file if you have deployed your code to a webserver) you should see a list of available operations for the web-service. When I...
40,253
<p>I know there is done some research on TDD at the North Carolina State University. They have published a paper called '<a href="http://collaboration.csc.ncsu.edu/laurie/Papers/TDDpaperv8.pdf" rel="nofollow noreferrer">An Initial Investigation of Test Driven Development in Industry</a>'. Other publications by NCSU can...
<p><a href="http://www.cs.du.edu/~snarayan/sada/teaching/COMP3705/lecture/p1/NRC-47445.pdf" rel="nofollow noreferrer">On the Effectiveness of the Test-First Approach to Programming</a>, by Hakan Erdogmus, Maurizio Morisio, and Marco Torchiano. </p> <p>Despite the name it covers TDD:</p> <p>Abstract:</p> <blockquote>...
<p>As a TDD Practitioner myself, I have launched a new site <a href="http://WeDoTDD.com" rel="nofollow">WeDoTDD.com</a> that lists just that. Companies practicing it, and stories behind how they practice Test Driven Development!</p>
19,868
<p>I have a stored procedure currently executing a complicated fetch that is frequently timing out when used. The proposed solution in my department has been to simply increase the timeout time length; which I don't really want to do. I'd like to refactor this sproc, but because it's so complicated and undocumented (ya...
<p>I have been faced with this situation in the past. The best thing to do is create a simple C# or VB .Net application. When you refactor the sp, give it a new name. Use the application to call both the old and new sp's. Then compare the output of the two sp's to ensure they return the exact same values in the sam...
<p>Use the <a href="http://msdn.microsoft.com/en-us/library/ms187929.aspx" rel="nofollow noreferrer">SQL Server Profiler</a> to study how the current SP runs; it will highlight inefficiencies and allow you to target just those specific areas to begin with, whilst leaving the more performant bits alone. You can then use...
27,001
<p>How do I use the softkeys with a CDialog based application in windows mobile 6 via MFC?</p> <p>I have a CDialog based Windows Mobile 6 (touchscreen) Professional app that I am workign on.</p> <p>The default behavior of a CDialog based app in WM6 Professional is to not use any softkeys by default... I want to map t...
<p>What's "not working" with the CCommandBar for you? You should be able to add a CCommandBar member to your dialog class, then in teh DIalog's InitDialog you call Create and InsertMenuBar on the command bar - something like this:</p> <pre><code>m_cmdBar.Create(this); m_cmdBar.InsertMenuBar(IDR_MENU_RESRC_ID); </code...
<p>thank you so much... I was going crazy with this...</p> <p>your code worked exactly as expected... </p> <p>At first I used it and had the same results, the softkey area would be blank except for the SIP input button.</p> <p>After an hour or so of debugging I tried putting those 2 lines of code at the END of my On...
13,127
<p>I'm have a ADO DataSet that I'm loading from its XML file via ReadXml. The data and the schema are in separate files.</p> <p>Right now, it takes close to 13 seconds to load this DataSet. I can cut this to 700 milliseconds if I don't read the DataSet's schema and just let ReadXml infer the schema, but then the res...
<p>It's not an answer, exactly (though it's better than nothing, which is what I've gotten so far), but after a long time struggling with this problem I discovered that it's completely absent when my program's not running inside Visual Studio. </p> <p>Something I didn't mention before, which makes this even more myst...
<p>Another dimesion to try is to read the dataset without the schema and then <a href="http://msdn.microsoft.com/en-us/library/06t089d7.aspx" rel="nofollow noreferrer"><strong><em>Merge</em></strong></a> it into a typed dataset that has the constraints enabled. That way it has all of the data on hand as it builds the ...
39,559
<p>I like LINQ to SQL, but it seems like the classes it generates are tightly coupled to the database they are stored in, which seems like a Bad Thing. </p> <p>For example, using ye olde Northwind database, if I create the dbml with the Products table, a <code>Product</code> class is generated. I can use this class in...
<p>All these answers and no links! Maybe I can help:</p> <p><a href="http://msdn.microsoft.com/en-us/library/bb425822.aspx#linqtosql_topic3" rel="nofollow noreferrer">The attributes thing that damieng mentioned</a></p> <p><a href="http://msdn.microsoft.com/en-us/library/bb546176.aspx" rel="nofollow noreferrer">The pa...
<p>Just copy the generated code into your own classes and switch off the code generation. The magic is in the attributes not anything else.</p> <p>Alternatively you can write your own plain CLR objects without the attributes and use an external XML mapping file to describe the relationship between the objects and the ...
27,507
<p>How can I retrieve the page title of a webpage (title html tag) using Python?</p>
<p>I'll always use <a href="http://lxml.de/" rel="nofollow noreferrer">lxml</a> for such tasks. You could use <a href="http://www.crummy.com/software/BeautifulSoup/" rel="nofollow noreferrer">beautifulsoup</a> as well.</p> <pre><code>import lxml.html t = lxml.html.parse(url) print(t.find(&quot;.//title&quot;).text) </c...
<p>Using lxml...</p> <p>Getting it from page meta tagged according to the Facebook opengraph protocol:</p> <pre><code>import lxml.html.parse html_doc = lxml.html.parse(some_url) t = html_doc.xpath('//meta[@property="og:title"]/@content')[0] </code></pre> <p>or using .xpath with lxml:</p> <pre><code>t = html_doc.xp...
7,423
<p>Stuggling a little bit with the RegEx, I've got 4 codes in a string</p> <p>CODE4:CODE3:CODE2:CODE1</p> <p>each code is optional apart from CODE1</p> <p>So I could have ab:bc:de:fg</p> <p>or</p> <p>bc::fg</p> <p>of </p> <p>ab:::fg</p> <p>In each case of the above CODE1 = fg dnd for the dear life of me I can't...
<p>There's no need to use a regular expression here.</p> <p>I don't know what language you're using, but split the string on ':' and you'll have an array of codes.</p> <p>If you really just want to validate whether a string is valid for this then</p> <pre><code>/(\w*:){0,3}\w+/ </code></pre> <p>matches your descrip...
<p>I'm not sure why you have to match the codes right to left. Simply use a regular expression to pick apart the string:</p> <pre><code>/(.*):(.*):(.*):(.+)/ </code></pre> <p>and then you have CODE1 in $4, CODE2 in $3, CODE3 in $2, CODE4 in $1.</p>
49,884
<p>I have printed a MPCNC machine. It has a print area of about 30" x 30" and up to 11" tall. (yes, those numbers are correct).</p> <p>I found a perfect piece of glass at a garage sale for $5.00 to use as my print bed. </p> <p>My problem now is how to heat the glass? I was wondering if there is some sort of tape ...
<p>Your best option may be to seek out a silicone rubber heating mat, using those terms for your web search. A quick search on my part shows many resources, some of which are known to the 3d printing manufacturing world, while others are equally suited for that purpose.</p> <p>Don't bond the heater to the glass. You'l...
<p>Maybe you can stick a <a href="https://en.wikipedia.org/wiki/Nichrome" rel="nofollow" title="nichrome">nichrome</a> wire under the glass using a heat resistant tape. You'll have to make the appropriate calcs (or just trial/error) to achieve the desired temperature at a consistent timing.</p>
370
<p>I've got this code:</p> <pre><code>rs1 = getResults(sSQL1) rs2 = getResults(sSQL2) </code></pre> <p>rs1 and rs2 and 2D arrays. The first index represents the number of columns (static) and the second index represents the number of rows (dynamic).</p> <p>I need to join the two arrays and store them in rs3. I don...
<p>I've figured it out. Turns out I was doing it the right way all along, I was just off by one. You don't need a third array either.</p> <pre><code> aRS_RU = rowsQuery(sSQL &amp; ", 'RU'") aRS_KR = rowsQuery(sSQL &amp; ", 'KR'") uboundRU1 = UBound(aRS_RU, 1) uboundRU2 = UBound(aRS_RU...
<p>I know this post is old, but I adapted the code to fix some errors I had during its execution. The following code sample works for me:</p> <pre><code>Sub ConcatRecordSets(ByRef avFirstRS As Variant, ByRef avSecondRS As Variant) Dim lIndex1 As Long, lIndex2 As Long Dim lFirstRSSize As Long, lSecondRSSize As...
21,086
<p>Due to the packaged nature of the release, a SQL Server script (well more of a statement) needs to be created that can execute correctly on SQL Server 7.0 thru 2008 which can essentially achieve this:</p> <pre><code>if exists(select * from sys.databases where name = 'Blah') </code></pre> <p>Reasons this is difficu...
<p>Try</p> <p>USE database </p> <p>and test @@ERROR.</p> <blockquote> <p>USE database<br> IF @@ERROR &lt;> 0 GOTO ErrExit</p> <p>logic ...</p> <p>RETURN 0</p> <p>ErrExit:<br> RETURN 1</p> </blockquote> <p>(or RAISERROR, or ...)</p>
<p>You could try a TRY... CATCH around a USE [DatabaseName].</p>
47,499
<p>I am trying to access Outlook 2007 from C#. I have installed the PIA msi after following the directions found on msdn. After a successful install nothing shows up in Visual Studio's references under the .net tab.</p>
<p>Office interaction is available through COM objects found on the 'COM' tab of the 'Add Reference' dialog window.</p>
<p>After you downloaded the installer and ran it, did you run the MSI installer it extracted and placed in the folder it asked you to create?</p>
18,849
<p>I've got an unmanaged Linux VPS running ubuntu that I'm using for the web server for a personal website. I'd like to get a barebones email server up and running. All the installation guides I've found so far are for a full-fledged email server with a webmail interface and everything. That's a lot more than I need...
<p><a href="http://msmtp.sourceforge.net/" rel="nofollow noreferrer">msmtp</a> or <a href="http://untroubled.org/nullmailer/" rel="nofollow noreferrer">nullmailer</a> sounds like it would fit the bill for the former. You could use google mail for domains for the latter.</p>
<p>Your web application needs a SMTP server. That server can be a hosted service like Google's or <a href="https://help.ubuntu.com/community/PostfixBasicSetupHowto" rel="nofollow noreferrer">MailHop</a>. If you really want to be an email administrator postfix should be installed <a href="http://www.dyndns.com/service...
26,529
<p>I'm currently having a major issue with a python script. The script runs arbitrary commands through a handler to convert incorrect error reporting into correct error reporting.</p> <p>The issue I'm having is getting the script to work correctly on windows with a command that contains ampersands in it's path. I've a...
<p>Make sure you are using lists and no shell expansion:</p> <pre><code>subprocess.Popen(['command', 'argument1', 'argument2'], shell=False) </code></pre>
<p>Try quoting the argument that contains the &amp;</p> <pre><code>wget "http://foo.com/?bar=baz&amp;amp;baz=bar" </code></pre> <p>Is usually what has to be done in a Linux shell</p>
14,674
<p>I have a database with one table, like so:</p> <pre><code>UserID (int), MovieID (int), Rating (real) </code></pre> <p>The userIDs and movieIDs are large numbers, but my database only has a sample of the many possible values (4000 unique users, and 3000 unique movies)</p> <p>I am going to do a matrix SVD (singular...
<pre><code>SELECT m.UserID, m.MovieID, r.Rating FROM (SELECT a.userid, b.movieid FROM (SELECT DISTINCT UserID FROM Ratings) AS a, (SELECT DISTINCT MovieID FROM Ratings) AS b ) AS m LEFT OUTER JOIN Ratings AS r ON (m.MovieID = r.MovieID AND m.UserID = r.UserID) ...
<p>If I understand your question correctly, you have all the data in your table, and you just want to extract it in the right order. Is that correct? If so, it should just be a mattter of:</p> <pre><code>select userid, movieid, rating from ratings order by userid, movieid </code></pre>
41,335
<p>In a <a href="https://stackoverflow.com/questions/194272">related question</a>, my team is about to (hopefully) start using LINQ, and I'd like to take advantage of anonymous types. What is the best way to mix VB.NET's Option Strict (which we've been using through the life of the project) and the new Option Infer dir...
<p>Option Strict and <a href="http://msdn.microsoft.com/en-us/library/bb384665.aspx" rel="noreferrer">Option Infer</a> do not conflict, so I see no harm in having both on.</p> <p>As a style guide, I prefer to put Option Strict, Explicit, and Infer at the top of each class file - this prevents differences in project or...
<p>Option Strict can be used without Option Infer, but Option Infer should not be used without Option Strict as that can lead to a difference in the resulting IL.</p> <p>Consider this line of code:</p> <pre><code>txtBox.Text = If(str="", Nothing, CDate(str)) </code></pre> <p>With Option Strict Off and Option Infer O...
23,603
<p>I have a small VB.NET application that I'm working on using the full version of Visual Studio 2005. In the <strong>Publish</strong> properties of the project, I have it set to <em>Automatically increment revision with each publish</em>.</p> <p>The issue is that it's only incrementing the revision in the Setup files...
<p>Change the code for the About box to </p> <pre><code>Me.LabelVersion.Text = String.Format("Version {0}", My.Application.Deployment.CurrentVersion.ToString) </code></pre> <p>Please note that all the other answers are correct for "how do I get my assembly version", not the stated question "how do I show my publish v...
<p>I'm no VB.NET expert, but have you tried to set the value to for example 1.0.0.*? This should increase the revision number (at least it does in the AssemblyInfo.cs in C#).</p>
3,242
<p>I am building my CoreXY 3D printer with 350x350 mm heated bed at about 4 mm thickness. I just found out that borosilicate glass is unavailable at the local glazier. He offered tempered or ceramic glass instead. Which one should I go for? I read that both are a more expensive option to borosilicate glass, but I worry...
<p>The primary advantage of borosilicate isn't that it's resistant to thermal shock -- as someone already noted, there's not much in the way of rapid heating or cooling in FDM printing (yes, the filament is hot, but its mass is low enough the glass it touches won't pick up much heat). Rather, it's the low expansion. ...
<p>People choose borosilicate because of its thermal properties.</p> <p>Between ceramic and tempered, I would suggest tempered glass, it's not good as borosilicate when comes to adapting to rapid temperatures but better than ceramic. The other option I would suggest will be &quot;Aluminium&quot;, which is much better.<...
2,015
<p>I have a working copy of my project, checked out using Subversion 1.5.1. When I attempt to run <a href="http://www.statsvn.org/" rel="nofollow noreferrer">StatSVN</a> against it, I get the following error:</p> <blockquote> <p>Sep 18, 2008 12:25:22 PM net.sf.statsvn.util.JavaUtilTaskLogger info INFO: StatSVN - S...
<p>Just guessing here, but are you sure that statSVN is compatible with working copies created with version 1.5 of the client? The format changed with svn 1.5...</p>
<p>@agnul</p> <p>You were right. Here's the <a href="http://sourceforge.net/tracker/index.php?func=detail&amp;aid=2016015&amp;group_id=164845&amp;atid=833327" rel="nofollow noreferrer">relevant feature request</a> from their bugzilla.</p>
11,985
<p>I have an single threaded, embedded application that allocates and deallocates lots and lots of small blocks (32-64b). The perfect scenario for a cache based allocator. And although I could TRY to write one it'll likely be a waste of time, and not as well tested and tuned as some solution that's already been on the ...
<p>I did some research on this very topic recently, as we had an issue with memory fragmentation. In the end we decided to stay with GNU libc's implementation, and add some application-level memory pools where necessary. There were other allocators which had better fragmentation behavior, but we weren't comfortable eno...
<p>I am writing a C memory allocator called tinymem that is intended to be able to defragment the heap, and re-use memory. Check it out:</p> <p><a href="https://github.com/vitiral/tinymem" rel="nofollow">https://github.com/vitiral/tinymem</a></p> <p>Note: this project has been discontinued to work on the rust impleme...
21,345
<p>What is your preferred way of keeping controls centered on its parent when the parent change width or height? </p>
<p>If by 'centered' you mean "it was already in the middle and you want to keep it there without resizing it", then remove all anchors. If it should be resized, gabr's solution is the one to with :)</p>
<p>If you mean a sort of "updating, please wait..." type thing, I manually move it in the Form's OnResize event. This allows me to keep a panel out of the way during design, and hidden normally, but I can make it visible when needed.</p> <pre><code>procedure TMyForm.FormResize(Sender: TObject); var nNewTop : Integer...
40,452
<p>My current place of employment is currently in a transition, new ownership has taken over, things are finally getting standardized and proper guidelines are being enforced. </p> <p>But we are still using VSS, there really isn't any reason for using it other then that's what whats initially setup. We don't use Visu...
<p>VSS totally relies on the clients to manage the database. If a client drops connection in the middle of a write over the network at just the wrong time, your file is trashed on the server. Not just the tip, but all the history. Hope you have a good backup. I've been through it. It's bad news.</p> <p>VSS usage over ...
<p>Even if it ain't broke, there's a potential benefit to migrating from VSS. First and most trivially, you won't have to buy new VSS licenses. Second, there are many examples of deficiencies in the VSS product (some also acknowledged by MS). The learning curve for SVN is at least as low as for VSS, and if you have ...
6,636
<pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" &gt; &lt;head runat="server"&gt; &lt;title&gt;Untitled Page&lt;/title&gt; &lt;link href="Stylesheet.css" rel="stylesheet" type...
<p>Please clarify the browser you are trying to fix this in.</p> <p>You should be using <code>&lt;div&gt;</code>'s anyway if you want to do things properly ;)</p>
<p>I'm no web dev, but isn't height just applicable to block objects? Hence try setting the TR's height, and not the TD's.</p>
46,788
<p>I am extending the bed of my TronXY X3 FDM RepRap printer.</p> <p>I am extending the bed from 220&nbsp;mm x 220&nbsp;mm to 220&nbsp;mm x 300&nbsp;mm. For now, I will keep the existing bed and add and aluminum sheet on top. That leaves 40mm on front and back of the original bed.</p> <p>Right now I only plan on ru...
<p>Main factors that control the process of the print bed selection are</p> <ul> <li>weight: too thick plate increases inertial force, limiting maximum acceleration/jerk (decreased print speed)</li> <li>stiffness: too thin plate will warp when heated or bend during calibration (decreased print quality/printer reliabil...
<p>I highly recommend aluminium tooling plates. They have a +/- 0.1 mm flatness tolerance on 1 meter. It's alloy 5083 offers a great stability. You can purchase such for example at aluminyumburada, which offers <a href="https://www.aluminyumburada.com/aluminum-cut-to-size" rel="nofollow noreferrer">custom cut piecees.<...
662
<p>Is it possible for an Subversion client to break a repository in any way? This could be any sort of destructive disruption, but it must be such that it cannot be recovered from without restoring the repository from a backup.</p> <p>Obviously, deleting everything and then checking that it is easy to fix simply with ...
<p>A Subversion client can either talk to a server to access the repository, or it can use a <code>file://</code> URL to access the repository directly. In the first case, the server is responsible for the repository so the client cannot directly "break" it. In the second case, the client is responsible for the reposit...
<p>If a client can break the repository in any way that requires a repository restore it's considered a very serious bug by the Subversion folks.</p> <p>A quick look on their bug-tracker shows that they do occasionally have repository corruption bugs, but in the absence of a bug, it's not possible for a client to comp...
47,741
<p>I have a script that slides a div down from behind the menu, when people click on the tab. However its in jquery and I want to use mootools (lots of reasons I wont go into here). However im stuck with mootools 1.1 at present. But for some reason my attempt is not working :(</p> <p>The html</p> <pre><code>print("co...
<p>I recommend using UrlRewriter:</p> <p><a href="http://urlrewriter.net/" rel="nofollow noreferrer">http://urlrewriter.net/</a></p> <p>This allows you to create all the mappings above that you desire. One thing that you'll have to do (if you're using IIS 6 or earlier) is configure IIS so that all extensions are han...
<p>You'll have to add an ASP.NET global.asax or HttpModule that maps the / request to default.aspx.</p>
29,176
<p>I've got TotroiseSVN installed and have a majority of my repositories checking in and out from C:\subversion\ <em>and a couple checking in and out from a network share (I forgot about this when I originally posted this question)</em>.</p> <p>This means that I don't have a "subversion" server per-se.</p> <p>How do ...
<p>I've been investigating this issue and have managed to get it working. There are a couple of minor problems but they can be worked-around.</p> <p>There are 3 distinct parts to this problem, as follows:</p> <ol> <li><p><strong>The TortoiseSVN part</strong> - getting TortoiseSVN to insert the Bugid and hyperlink in...
<p>I am not sure I follow you. Do you have the repositories on the network or on your C:\ drive? According to two of your posts, you have both, or neither, or one of them or...</p> <p>You can not get VisualSVN or Apache to safely serve repositories from a network share. Since you originally said you had the repositori...
2,568
<p>If have a set of classes that all implement an interface. </p> <pre><code>interface IMyinterface&lt;T&gt; { int foo(T Bar); } </code></pre> <p>I want to shove them all in a list and enumerate through them. </p> <pre><code> List&lt;IMyinterface&gt; list foreach(IMyinterface in list) // etc... </code></pre...
<p>There is no IMyinterface type there is only a IMyinterface`1 type which will require a type argument. You could create an IMyinterface type:-</p> <pre><code>interface IMyinterface { ... } </code></pre> <p>then inherit from it</p> <pre><code>interface IMyinterface&lt;T&gt; : IMyinterface { ... } </code></pre> <p...
<p>If you plan to invoke a method with T in the signature, the answer is that you cannot. Otherwise you can do as anthonywjones suggests</p>
40,118
<p>What is the simplest way to programmatically export Excel data to Matlab?</p>
<p>If you are running Matlab on Windows with Excel installed, try <a href="http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/ref/xlsread.html" rel="nofollow noreferrer">XLSREAD</a>.</p>
<p>For a bit of $$$, you can get the MATLAB add-on Excel Link, which provides a nice clean interface for transferring data back and forth between the two programs.</p>
24,195
<p>In VB6, I used a call to the Windows API, <strong>GetAsyncKeyState</strong>, to determine if the user has hit the ESC key to allow them to exit out of a long running loop.</p> <pre><code>Declare Function GetAsyncKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer </code></pre> <p>Is there an equivalent in pu...
<p>You can find the P/Invoke declaration for GetAsyncKeyState from <a href="http://pinvoke.net/default.aspx/user32/GetAsyncKeyState.html" rel="nofollow noreferrer">http://pinvoke.net/default.aspx/user32/GetAsyncKeyState.html</a></p> <p>Here's the C# signature for example:</p> <pre><code>[DllImport("user32.dll")] stat...
<p>Depending on your desired use there are a couple of options, including invoking the same method as described above). From a console app:</p> <pre><code>bool exitLoop = false; for(int i=0;i&lt;bigNumber &amp;&amp; !exitLoop;i++) { // Do Stuff. if(Console.KeyAvailable) { // Read the key and displa...
16,214
<p>I am curious to know where the "Don't Fragment" [DF] Bit of the IP Flags is used. As fragmentation is invisible to higher layers and they don't care too.</p> <p>I am also looking for an example. </p> <p>Thanks a lot in advance.</p>
<p>Fragmentation is not always invisible to all upper layers. Some early (and probably even current) micro-controller TCP/IP stacks did not implement the full capabilities such as fragmentation handling. Use of the flag in that situation would ensure that the packet arrived in its original form instead of a lot of frag...
<p>Do note that there is no standard way to set DF in C. On Linux, this code works:</p> <pre><code>result = setsockopt(mysocket, IPPROTO_IP, IP_MTU_DISCOVER, IP_PMTUDISC_DO, sizeof(int)); </code></pre> <p>but it does not on FreeBSD 6</p> <p>Also, Path MTU discovery is extremely unreliable on the rea...
45,812
<p>Which is more efficient?</p> <pre><code>SELECT theField FROM theTable GROUP BY theField </code></pre> <p>or</p> <pre><code>SELECT DISTINCT theField FROM theTable </code></pre>
<p>In your example, both queries will generate the same execution plan so their performance will be the same. </p> <p>However, they both have their own purpose. To make your code easier to understand, you should use distinct to <strong>eliminate duplicate rows</strong> and group by to <strong>apply aggregate operato...
<p>In MySQL, DISTINCT seems a bit faster than GROUP BY if theField is not indexed. DISTINCT only <strong>eliminate duplicate rows</strong> but GROUP BY seems to <strong>sort</strong> them in addition.</p>
49,058
<p>How do I import a Python module given its relative path?</p> <p>For example, if <code>dirFoo</code> contains <code>Foo.py</code> and <code>dirBar</code>, and <code>dirBar</code> contains <code>Bar.py</code>, how do I import <code>Bar.py</code> into <code>Foo.py</code>?</p> <p>Here's a visual representation:</p> <...
<p>Assuming that both your directories are real Python packages (do have the <code>__init__.py</code> file inside them), here is a safe solution for inclusion of modules relatively to the location of the script.</p> <p>I assume that you want to do this, because you need to include a set of modules with your script. I ...
<p>Call me overly cautious, but I like to make mine more portable because it's unsafe to assume that files will always be in the same place on every computer. Personally I have the code look up the file path first. I use Linux so mine would look like this:</p> <pre><code>import os, sys from subprocess import Popen, PI...
35,274