instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>given the following class ...</p>
<pre><code>public class Category {
public string Name {get;set;}
public Category ParentCategory {get;set;}
}
</code></pre>
<p>What the most efficient way to output the following from a collection (<code>IList<Category></code>) of Category objects?</p>
<pre><code>+ Paren... | <p>You may wish to consider reversing your relationship. If a node can get to its parent but not vice versa, you have to have <em>all</em> the leaf nodes in order to print out the full tree. Compare this to the situation where you have each node know about its children - then you only need the root node.</p>
| <p>recently i read about Hierarchical Linq Queries, check out <a href="http://weblogs.asp.net/okloeten/archive/2006/07/09/Hierarchical-Linq-Queries.aspx" rel="nofollow noreferrer">http://weblogs.asp.net/okloeten/archive/2006/07/09/Hierarchical-Linq-Queries.aspx</a></p>
<p>but I tend to aggree with Jon Skeet.</p>
| 37,520 |
<p>It happens to me all the time. I accidentally version a file, I do not want to be versioned (i.e. developer/machine specific config-files).</p>
<p>If I commit this file, I will mess up the paths on all the other developer machines - they will be unhappy.</p>
<p>If I do delete the file from versioning, it will be d... | <p>SVN version 1.5 supports removing/deleting a file from a repository with out losing the local file</p>
<p>taken from <a href="http://subversion.tigris.org/svn_1.5_releasenotes.html" rel="noreferrer">http://subversion.tigris.org/svn_1.5_releasenotes.html</a> </p>
<p>New --keep-local option retains path after delete... | <p>As far as I know there is no easy way to remove an added file from versioning control in svn once it is committed.</p>
<p>You will have to save the file somewhere else and delete it from version control. Than copy the backup back again.</p>
<p>It's a version control system after all... ;)</p>
| 4,733 |
<p>Suppose I have a class 'Application'. In order to be initialised it takes certain settings in the constructor. Let's also assume that the number of settings is so many that it's compelling to place them in a class of their own.</p>
<p>Compare the following two implementations of this scenario.</p>
<p>Implementatio... | <p>I think it's fine. This is basically the builder pattern, and using nested classes works pretty well. It also lets the builder access private members of the outer class, which can be very useful. For instance, you can have a Build method on the builder which calls a private constructor on the outer class which takes... | <p>I don't know if this is considered bad design or not, but I've got some search classes I make where a user calls the Run() method, passing in an object that holds search criteria. It then returns a collection of search result objects. </p>
<p>These SearchCriteria and SearchResult classes have no utility outside o... | 43,740 |
<p>I am trying to make SVG XML documents with a mixture of lines and brief text snippets (two or three words typically). The major problem I'm having is getting the text aligning with line segments.</p>
<p>For horizontal alignment I can use <code>text-anchor</code> with <code>left</code>, <code>middle</code> or <code>... | <p>It turns out that you don't need explicit text paths. Firefox 3 has only partial support of the vertical alignment tags (<a href="http://groups.google.com/group/mozilla.dev.tech.svg/browse_thread/thread/1be0c56cfbfb3053?fwc=1" rel="noreferrer">see this thread</a>). It also seems that dominant-baseline only works whe... | <p>This effect can indeed be achieved by setting <code>alignment-baseline</code> to <code>central</code> or <code>middle</code>.</p>
| 8,032 |
<p>I have a situation where I have a bunch of SQL Update commands that all need to be executed. I know that DataSets can do batch updates, but the only way I've been able to accomplish it is to load the whole table into a dataset first. What if I want to only update a subset of the records in a table?</p>
| <p>The easiest way out here is load table with the required rows (rows you wan to update). Double check that the RowState is "Inserted".
Assign the InsertCommand property of the adapter with your stored procedure (wrapped in an SqlCommand) that does the "update", this tweak will ensure that all the rows present in the ... | <p>EDITED: Based on your comment, I'd recommend using the Bulk Copy method to go to a staging table first. Then you can do a single update on your real table based on the staging table. </p>
<p>=========</p>
<p>One way is to build the SQL Command yourself; however, I'd recommend reading about the SQL Injection possib... | 40,033 |
<p>I have experimented with Lisp (actually Scheme) and found it to be a very beautiful language that I am interested in learning more about. However, it appears that Lisp is never used in serious projects, and I haven't seen it listed as a desired skill on any job posting. I am interested in hearing from anyone who h... | <p>Franz, Inc. provides an inexhaustive <a href="http://www.franz.com/success/" rel="nofollow noreferrer">list of success stories</a> on their website. However:</p>
<blockquote>
<p>Please don't assume Lisp is only
useful for Animation and Graphics, AI,
Bioinformatics, B2B and E-Commerce,
Data Mining, EDA/Semi... | <p>It's a wonderful language, but it's crippled because (in my opinion as a software business owner and programmer) there are very few commercial Lisp packages, and the few that are out there demand a run-time fee (because a proper Lisp package can be used by end-users to write Lisp programs too).</p>
<p>I use Steel B... | 20,819 |
<p>As far as Google searches tell me, the maximum allowed number of cookies depends very much on the browser, however I cannot find any recent data as to how much cookies are allowed on modern browsers.</p>
<p>I need to store a somewhat large number of user preferences in cookies (for not-yet-registered users), so wha... | <p>From the <a href="http://www.ietf.org/rfc/rfc2109.txt" rel="noreferrer">rfc</a>:</p>
<ul>
<li><p>at least 300 cookies</p></li>
<li><p>at least 4096 bytes per cookie (as measured by the size of the
characters that comprise the cookie non-terminal in the syntax
description of the Set-Cookie header)</p></li>
<... | <p>Not sure how much sense it makes from their point of view, but <a href="http://webcookies.info/number-of-cookies/" rel="nofollow">I've seen websites in the wild</a> that were setting over 450 cookies and <a href="http://webcookies.info/third-party-domains/" rel="nofollow">reporting to over 140 distinctive third part... | 35,991 |
<p>I have a question on the best way of exposing an asynchronous remote interface.</p>
<p>The conditions are as follows:</p>
<ul>
<li>The protocol is asynchronous</li>
<li>A third party can modify the data at any time</li>
<li>The command round-trip can be significant</li>
<li>The model should be well suited for UI i... | <p>For the asynchronous bit, I would suggest checking into <code>java.util.concurrent</code>, and especially the <code>Future<T></code> interface. The future interface is used to represent objects which are not ready yet, but are being created in a separate thread. You say that objects can be modified at any time... | <p>@<a href="https://stackoverflow.com/questions/37041/exposing-a-remote-interface-or-object-model#37093">Staale</a>: Thanks a bunch!</p>
<p>Using Future for the async operations is interesting. The only drawback being that it is doesn't provide callbacks. But then again, I tried that approach, and look where that got... | 5,767 |
<p>When running a Java app from eclipse my ImageIcon shows up just fine.</p>
<p>But after creating a jar the path to the image obviously gets screwed up.</p>
<p>Is there a way to extract an image from the jar at runtime so I can then open it up? Or, is there a better way to do this?</p>
<p>I'd like to distribute a ... | <p>To create an <code>ImageIcon</code> from an image file within the same jars your code is loaded:</p>
<pre><code>new javax.swing.ImageIcon(getClass().getResource("myimage.jpeg"))
</code></pre>
<p><code>Class.getResource</code> returns a URL of a resource (or <code>null</code>!). <code>ImageIcon</code> has a constru... | <p>Load image in from Jar file during run time is the same as loading image when executed from IDE e.g netbeans the difference is that when loading image from JAR file the path must be correct and its <b>case sensitive</b> (very important).
This works for me</p>
<pre>
image1 = new javax.swing.ImageIcon(getClass().get... | 5,101 |
<p>We have a JavaEE server and servlets providing data to mobile clients (first JavaME, now soon iPhone). The servlet writes out data using the following code:</p>
<pre><code>DataOutputStream dos = new DataOutputStream(out);
dos.writeInt(someInt);
dos.writeUTF(someString);
</code></pre>
<p>... and so on</p>
<p>Thi... | <p>You'll have to do the demarshalling yourself; fortunately, it's fairly straightforward. Java's <code>DataOutputStream</code> class writes integers in big-endian (network) format. So, to demarshall the integer, we grab 4 bytes and unpack them into a 4-byte integer.</p>
<p>For UTF-8 strings, <code>DataOutputStream<... | <p>Don't forget that Objective-C is just C in a pretty dress--and C excels at this kind of bit-grovelling. To a large extent, you should be able to just define a C struct that looks like your data and cast the pointer to your data into a pointer to that struct. Now, exactly which types to use, and if you need to byte... | 41,832 |
<p>Ultimaker Cura offers a platform support type of “<em>touching buildplate</em>” which enables the printer to only make a raft for parts of the object that should be touching the build plate. It also offers “<em>everywhere</em>” for any object that might be hanging over the build plate.</p>
<p>I have a need to only ... | <blockquote>
<p>Is there a software that will enable this?</p>
</blockquote>
<p>Yes, as of Ultimaker Cura 3.3 Beta, Ultimaker Cura allows you to specify an area which will not be considered for adding supports. In your case you could define everything above 4 mm to be excluded from building support structures. ... | <blockquote>
<p>Is there a software that will enable this?</p>
</blockquote>
<p>I don't own a copy of it, but from talking with other 3D printing enthusiasts, I know <a href="https://www.simplify3d.com/" rel="nofollow noreferrer">simplify3d</a> is the slicer out there with the most granular control over support stru... | 866 |
<p>Is it possible to disable a trigger for a batch of commands and then enable it when the batch is done?</p>
<p>I'm sure I could drop the trigger and re-add it but I was wondering if there was another way.</p>
| <pre><code>DISABLE TRIGGER { [ schema_name . ] trigger_name [ ,...n ] | ALL }
ON { object_name | DATABASE | ALL SERVER } [ ; ]
</code></pre>
<p><a href="http://msdn.microsoft.com/en-us/library/ms189748(SQL.90).aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/ms189748(SQL.90).aspx</a></p>
<p>followed by ... | <pre><code>ALTER TABLE table_name DISABLE TRIGGER TRIGGER_NAME
-- Here your SQL query
ALTER TABLE table_name ENABLE TRIGGER TRIGGER_NAME
</code></pre>
| 15,031 |
<p>I'm in the process of writing a Java 2D game. I'm using the built-in Java 2D drawing libraries, drawing on a Graphics2D I acquire from a BufferStrategy from a Canvas in a JFrame (which is sometimes full-screened). The BufferStrategy is double-buffered. Repainting is done actively, via a timer. I'm having some perfor... | <p>I'm having the same issues as you are I think. Check out my post here:</p>
<p><a href="https://stackoverflow.com/questions/196890/java2d-performance-issues">Java2D Performance Issues</a></p>
<p>It shows the reason for the performance degradation and how to fix it. It's not guaranteed to work well on all platforms ... | <p>make sure you use double buffering, draw first to one big buffer in memory that you then flush to screen when all drawing is done.</p>
| 17,888 |
<p>In terms of the number of servers ready to receive an application written in the language, the number of people who can write code using the language, and so on?</p>
| <p>Now don't laugh, but I'd say PHP/MySQL stands out as its free and really easy to get running on a local windows or linux machine. Most shared hosting providers have these available in a reasonably configurable state.</p>
<p>If you need something that works, isn't too hard to begin with and costs <em>nothing</em>, y... | <p>With java it is pretty simple to deploy webapps.
You just package your application in a war file (web archive) and provide that war file to the appserver (tomcat, jboss, weblogic , ...) that will unpack the war and deploy it automatically.</p>
<p>Their are also a lot of coders who can write java so that will defini... | 29,652 |
<p>I'm looking to call a subprocess with a file descriptor opened to a given pipe such that the open() call does not hang waiting for the other side of the pipe to receive a connection.</p>
<p>To demonstrate:</p>
<pre><code>$ mkfifo /tmp/foobar.pipe
$ some_program --command-fd=5 5</tmp/foobar.pipe
</code></pre>
<... | <p>Opening the FD read/write rather than read-only when setting up the pipeline prevents blocking.</p>
<p>To be a bit more specific:</p>
<pre><code>$ mkfifo /tmp/foobar.pipe
$ some_program --command-fd=5 5<>/tmp/foobar.pipe
</code></pre>
<p>prevents the undesired blocking behavior, as <code>5<>/tmp/fooba... | <p>The only way I know getting this kind of result is a hack:</p>
<pre><code>mkfifo /tmp/foobar.in
mkfifo /tmp/foobar.out
( cat </tmp/foobar.in ) >/tmp/foobar.out &
some_program --command-fd=5 5</tmp/foobar.out
</code></pre>
<p>perhaps this helps :-)</p>
| 21,618 |
<p>I want to create a list of integers from 1 to <code>n</code>. I can do this in Python using <code>range(1, n+1)</code>, and in Haskell using: <code>take n (iterate (1+) 1)</code>.</p>
<p>What is the right OCaml idiom for this?</p>
| <p>There is no idiom that I know of, but here is a fairly natural definition using an infix operator:</p>
<pre class="lang-ml prettyprint-override"><code># let (--) i j =
let rec aux n acc =
if n < i then acc else aux (n-1) (n :: acc)
in aux j [] ;;
val ( -- ) : int -> int -> int list = <fun... | <p>If you don't need a "step" parameter, one easy way to implement this function would be:</p>
<pre><code>let range start stop =
List.init (abs @@ stop - start) (fun i -> i + start)
</code></pre>
| 30,218 |
<p>I have a plugin project I've been developing for a few years where the plugin works with numerous combinations of [primary application version, 3rd party library version, 32-bit vs. 64-bit]. Is there a (clean) way to use autotools to create a single makefile that builds all versions of the plugin. </p>
<p>As far ... | <p>As far as I know, you can't do that. However, are you stuck with autotools? Are neither <a href="http://www.cmake.org/" rel="noreferrer">CMake</a> nor <a href="http://www.scons.org/" rel="noreferrer">SCons</a> an option?</p>
| <p>Have you ever considered to use a single project with multiple build directories?
if your automake project is implemented in a proper way (i.e.: NOT like gcc)</p>
<p>the following is possible:</p>
<pre><code>mkdir build1 build2 build3
cd build1
../configure $(YOUR_OPTIONS)
cd build2
../configure $(YOUR_OPTIONS2)
[... | 41,973 |
<p>I have a <code>div</code> with two images and an <code>h1</code>. All of them need to be vertically aligned within the div, next to each other. One of the images needs to be <code>absolute</code> positioned within the <code>div</code>.</p>
<p>What is the CSS needed for this to work on all common browsers?</p>
<pre c... | <p>Wow, this problem is popular. It's based on a misunderstanding in the <code>vertical-align</code> property. This excellent article explains it:</p>
<p><a href="http://phrogz.net/CSS/vertical-align/index.html" rel="noreferrer">Understanding <code>vertical-align</code>, or "How (Not) To Vertically Center Content&... | <pre><code><div id="header" style="display: table-cell; vertical-align:middle;">
</code></pre>
<p>...</p>
<p>or CSS</p>
<pre><code>.someClass
{
display: table-cell;
vertical-align:middle;
}
</code></pre>
<p><a href="http://caniuse.com/#search=table-cell" rel="noreferrer"><strong>Browser Coverage</strong... | 10,482 |
<p>What tools would you recommend for setting up CI for build and deployment of multiple websites built on DotNetNuke using SVN for source control? </p>
<p>We are currently looking at configuring Cruise Control to work with NAnt, NUnit, NCover and Trac as a test case. What other combinations would worth investigating?... | <p>We use CruiseControl with NUnit, NCover, FxCop, SVN and some custom tools we wrote ourselves to produce the reports. In my opinion it has proven (over the last few years) to be an excellent combination.</p>
<p>It's frustrating that MS restricts <em>all</em> of its integration tools to VSTS. Its test framework is a... | <p>Microsoft loosened it's constraint on the Testing Platform by including it in Visual Studio 2008 Professional and allowing for the tests to be run from the command line with Framework 3.5 installed. We did a crossover for a client recently and so far they have been able to run all the tests without the need for NUni... | 2,879 |
<p>I have a java application that is connected to a view on a remote Oracle db. </p>
<p>Does anyone know of a way in Java to monitor this table for changes? I.e. if there are inserts of updates etc I would need to react.</p>
| <p>You can place a INSERT/UPDATE/DELETE trigger on the table to perform some action when 'data' changes are made to the table. (as opposed to changes to the structure of the table)</p>
<p>I believe 10g also supports triggers on views.</p>
<p>but I'm not sure how you can notifiy the java process of this other then by... | <p>Look at <a href="https://docs.oracle.com/cd/B19306_01/appdev.102/b14258/d_chngnt.htm#BABEECBE" rel="nofollow noreferrer">Oracle Change Notification</a>, a so interesting Oracle feature.</p>
<p>From the Oracle documentation: <em>"Database Change Notification is a feature that enables client applications to register ... | 43,772 |
<p>My company is going to be storing sensitive data for our customers, and will be encrypting data using one of the managed .NET encryption algorithm classes. Most of the work is done, but we haven't figured out how/where to store the key. I've done some light searching and reading, and it seems like a hardware solutio... | <p>There only two real solutions for (the technical aspect of) this problem.
Assuming it's only the application itself that needs access the key...</p>
<ol>
<li><p>Hardware Security Module (HSM) - usually pretty expensive, and not simple to implement. Can be dedicated appliance (e.g. nCipher) or specific token (e.g. ... | <p><a href="http://www.microsoft.com/rms" rel="nofollow noreferrer">Microsoft Rights Management Server (RMS)</a> has a similar problem. It just solves it by encrypting its configuration with a master password. ...A password on a password, if you will.</p>
| 7,280 |
<p>Let's say I have N pictures of an object, taken from N know positions. I also have the 3D geometry of the object, and I know all the characteristics of both the camera and the lens.</p>
<p>I want to generate a unique giant picture from the N pictures I have, so that it can be mapped/projected onto the object surfac... | <p>Not sure if it helps you directly, but these guys have some amazing demos of some related techniques: <a href="http://grail.cs.washington.edu/projects/videoenhancement/videoEnhancement.htm" rel="nofollow noreferrer">http://grail.cs.washington.edu/projects/videoenhancement/videoEnhancement.htm</a>.</p>
| <p>I'd suspect that this can be done using some variation of projection maps mixed with image reconstruction.</p>
| 12,719 |
<p>I run a website where users can post items (e.g. pictures). The items are stored in a MySQL database. </p>
<p>I want to query for the last ten posted items BUT with the constraint of a maximum of 3 items can come from any single user. </p>
<p>What is the best way of doing it? My preferred solution is a constraint ... | <p>It's pretty easy with a correlated sub-query:</p>
<pre><code>SELECT `img`.`id` , `img`.`userid`
FROM `img`
WHERE 3 > (
SELECT count( * )
FROM `img` AS `img1`
WHERE `img`.`userid` = `img1`.`userid`
AND `img`.`id` > `img1`.`id` )
ORDER BY `img`.`id` DESC
LIMIT 10
</code></pre>
<p>The query assumes that larger... | <p>I would first select 10 distinct users, then selecting images from each of those users with a LIMIT 3, possibly by a union of all those and limit that to 10.</p>
<p>That would atleast narrow down the data you need to process to a fair amount.</p>
| 34,185 |
<p>My Apache server runs on some non-default (not-root) account. When it tries to run a python script which in turn executes a subversion check-out command, 'svn checkout' fails with the following error message:</p>
<pre><code>svn: Can't open file '/root/.subversion/servers': Permission denied
</code></pre>
<p>At the... | <p>It sounds like the environment you apache process is running under is a little unusual. For whatever reason, svn seems to think the user configuration files it needs are in /root. You can avoid having svn use the root versions of the files by specifying on the command line which config directory to use, like so:</... | <p>Try granting the Apache user (the user that the apache service is running under) r+w permissions on that file.</p>
| 16,195 |
<p>I am using the EMMA tool for code coverage yet despite my best efforts, EMMA is refusing to see the original .java files and generate coverage on a line-by-line basis.</p>
<p>We are using ANT to build the code and debug is set to true. I know that EMMA is measuring coverage as the .emma files seem to be generating ... | <p>Are you setting the <code>sourcepath</code> in your <code>report</code> element?</p>
<pre><code><report>
<sourcepath>
<pathelement path="${java.src.dir}" />
</sourcepath>
<fileset dir="data">
<include name="*.emma" />
</fileset>
<txt ... | <p>does <code>{java.src.dir}</code> need to point to one specific <code>src</code> directory.</p>
<p>This is no one single src directory as I am compiling multiple projects. Each with their own build.xml file.</p>
<p>I believe this is the portion that generates all the coverage reports:</p>
<pre><code> <target n... | 31,670 |
<pre><code><?php
function data_info($data)
{
if ($data) {
while (!feof($data)) {
$buffer = fgets($data);
if (file_exists($buffer)) {
$bufferArray[$buffer]['Exists'] = (file_exists($buffer));
$bufferArray[$buffer]['Readable'] = (is_readable($buffer));
... | <p>Hmm, well that works in Linux (though I have to trim the filename <code>$buffer</code> first).</p>
| <p>Yeah, It works for me too if I have in ficheros.txt</p>
<pre><code>Existingfile.txt
AnotherExistingfile.txt
</code></pre>
<p>Or</p>
<pre><code>FakeFile.txt
FakeFile2.txt
</code></pre>
<p>But If I combine both of them:</p>
<pre><code>Fakefile.txt
Existingfile.txt
</code></pre>
<p>It won't work, the script in th... | 47,792 |
<p>My quick search reveals the reference implementation (<a href="http://stax.codehaus.org" rel="noreferrer">http://stax.codehaus.org</a>), the Woodstox implementation (<a href="http://woodstox.codehaus.org" rel="noreferrer">http://woodstox.codehaus.org</a>), and Sun's SJSXP implementation (<a href="https://sjsxp.dev.j... | <p>Woodstox wins every time for me. It's not just performance, either - sjsxp is twitchy and overly pedantic, woodstox just gets on with it.</p>
| <p><a href="http://javolution.org/" rel="nofollow noreferrer">http://javolution.org/</a> has a good StAX implementation</p>
| 14,749 |
<p>My style of coding includes the following idiom:</p>
<pre><code>class Derived : public Base
{
public :
typedef Base super; // note that it could be hidden in
// protected/private section, instead
// Etc.
} ;
</code></pre>
<p>This enables me to use "super" as ... | <p>Bjarne Stroustrup mentions in <em>Design and Evolution of C++</em> that <code>super</code> as a keyword was considered by the ISO C++ Standards committee the first time C++ was standardized.</p>
<p>Dag Bruck proposed this extension, calling the base class "inherited." The proposal mentioned the multiple inheritanc... | <p>This is a method I use which uses macros instead of a typedef. I know that this is not the C++ way of doing things but it can be convenient when chaining iterators together through inheritance when only the base class furthest down the hierarchy is acting upon an inherited offset.</p>
<p>For example:</p>
<pre><cod... | 21,788 |
<p>First, let me explain what I am doing. I need to take an order, which is split up into different databases, and print out this very large order. What I need from the orders is about 100 or so columns from different databases. The way I was doing in was querying with a join and assigning all of the column values to a... | <p>I would recommend an object-oriented solution to this. Presumably your database is designed with tables that represent logical groupings of data. Each of these tables can likely be mapped onto a class in your system, although in some cases, it may be more than one table that makes up an object or there might be mu... | <p>It really just sounds like your preference to me. How would you prefer to work with it? Would it be easier for you to work with it as separate C# objects, or would it be easier for you to work with it as several SQL tables?</p>
| 47,796 |
<p>I'm trying to do something that gets a cs file in runtime from user make it meaningful to assembly get its properties, methods etc. </p>
<p>Is there a way to do this by reflection in C#?</p>
| <p>To compile a file on the fly you'll need to do something along these lines (where sourceCode is a string containg the code to compile):</p>
<pre><code>CodeDomProvider codeProvider = new CSharpCodeProvider();
ICodeCompiler compiler = codeProvider.CreateCompiler();
// add compiler parameters
CompilerParameters compi... | <p>You can compile it reasonably easily using the <a href="http://msdn.microsoft.com/en-us/library/microsoft.csharp.csharpcodeprovider.aspx" rel="nofollow noreferrer">CSharpCodeProvider</a>. You can download the source code for my snippet compiler, Snippy, from the <a href="http://csharpindepth.com/Downloads.aspx" rel=... | 36,991 |
<p>I'm using <a href="http://jquery.com/" rel="noreferrer">jQuery</a> and <a href="http://www.ericmmartin.com/projects/simplemodal/" rel="noreferrer">SimpleModal</a> in an ASP.Net project to make some nice dialogs for a web app. Unfortunately, any buttons in a modal dialog can no longer execute their postbacks, which ... | <p>Both of you were on the right track. What I realized is that SimpleModal appends the dialog to the body, which is outside ASP.Net's <code><form></code>, which breaks the functionality, since it can't find the elements.</p>
<p>To fix it, I just modified the SimpleModal source to append eveything to <code>'for... | <p>if you don want modify the SimpleModal source.
try this..</p>
<p>After you call the modal() method add this:</p>
<pre><code>$("#simplemodal-overlay").appendTo('form');
$("#simplemodal-container").appendTo('form');
</code></pre>
<p>the SimpleModal plugin add two this to your markup. </p>
<ol>
<li>'simplemodal-ove... | 4,887 |
<p>I'm just in the middle of revisiting maven. Our team had a bad experience when we last looked at this, as it was during the period when maven was rearchitecting from 1.x to 2.x, so a lot of the dependencies we needed hadn't been moved across to the new repositories. However, I have the time to reconsider now.</p>
<... | <p>You can easily create a site (that contains documentation) with Maven using the mvn site command (i.e. using the <a href="http://maven.apache.org/plugins/maven-site-plugin/" rel="nofollow noreferrer">plugin site</a>).</p>
<p>This plugin creates technical reports (such as Javadoc, Unit tests reports, code coverage..... | <p>There is AFAIK no official or semi-official plugin that will process LaTeX or DocBook, but what you could do (besides using the aforementioned site plugin) is to configure the exec plugin to process your LaTeX/DocBook sources during the site lifecycle, i.e. at the same time that the project's website is built.</p>
... | 33,200 |
<p>Looking at the C# and VB.NET language specs I think it says that the logical Xor/Or/And operations have different precendence in the two languages. Am I reading that right? I was expecting them to have the same precendence.</p>
<p>For example in C#</p>
<pre><code>100 | 200 ^ 300 & 400
</code></pre>
<p>is the ... | <blockquote>
<p>Am I reading that right?</p>
</blockquote>
<p>Yes. Simple as that.</p>
| <blockquote>
<p>Am I reading that right?</p>
</blockquote>
<p>Yes. Simple as that.</p>
| 26,829 |
<p>So, lets say I have a number 123456. 123456 % 97 = 72. How can I determine what two digits need to be added to the end of 123456 such that the new number % 97 = 1? Note--it must always be two digits.</p>
<p>For example, 123456<strong>76</strong> % 97 = 1. In this case, I need to add the digits "76" to the end o... | <p>You calc the modulo of 123456<b>00</b> to 97 and add (97 - that + 1) to that number.
So you get what RoBorg explained whay cleaner above :)</p>
| <p>Modulo arithmetic is really not that different from regular arithmetic. The key to solving the kind of problem that you're having is to realize that what you would normally do to solve that problem is still valid (in what follows, any mention of number means integer number):</p>
<p>Say you have</p>
<p>15 + x = 20<... | 35,082 |
<p>Full disclaimer: I'm a CS student, and this question is related to a recently assigned Java program for Object-Oriented Programming. Although we've done some console stuff, this is the first time we've worked with a GUI and Swing or Awt. We were given some code that created a window with some text and a button that ... | <p>Instead of writing this:</p>
<pre><code>resetButton.addActionListener(this);
</code></pre>
<p>You could also write this:</p>
<pre><code>resetButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
resetButtonActionPerformed(evt);
}
});
</code></pre>
<p>And i... | <p>Ergh. Don't implement masses of unrelated interfaces in one mega class. Instead, use anoymous inner classes. They are a bit verbose, but are what you want. Use one for each event, then you wont need big if-else chain. I suggest keeping enough code within the inner class to decode the event and call methods that make... | 22,280 |
<p>In light of how ajax is actually used by most sites today; why is ajax embraced while frames are still regarded as a bad idea?</p>
| <p>AJAX, from where I'm sitting, is a sort of grand tradeoff. You are breaking things in the "document" model of the interwebs so that your site can behave more like an "application." If a site is using AJAx well, they will break the document model in subtle ways that add something of value to the application. The "vo... | <p>Ajax and frames are completely different from an accessibility standpoint (they're also completely different full stop).
Frames offer very little positive effect but bring with them a host of negative issues.
Ajax on the other hand makes the user interface more dynamic without compromising usability in most cases.</... | 19,789 |
<p>I have heard of apps not working properly on the simulator but working properly on the actual iPhone device. Has anyone experienced an app that runs perfectly in the simulator but not on the actual iPhone device?</p>
| <p>Filenames are case-sensitive on the iPhone, but not in the simulator.</p>
<p>So, for example, if you try to load an image with <code>UIImage *iconImage = [UIImage imageNamed:"MyIcon.png"]</code>, but your resource is actually named "myicon.png", then it will work on the simulator, but not on the device.</p>
| <p>Resource loading in the simulator is MUCH faster than in the device. For example, loading and displaying a sequence of full-screen <code>UIImages</code> (like a rudimentary video) can look very smooth in the simulator, and choppy on a device.</p>
<p>In fact, remember that there is a huge speed difference between di... | 49,805 |
<p>As you can see this is a question from a non web developer. I would like to have an ASPX page which, under certain circumstances, can generate a 401 error from code. Ideally it would show the IIS standard page.</p>
| <p>Set <a href="http://msdn.microsoft.com/en-us/library/system.web.httpresponse.statuscode.aspx" rel="noreferrer">Response.StatusCode</a> and then - if you need to stop execution - call <a href="http://msdn.microsoft.com/en-us/library/system.web.httpresponse.end.aspx" rel="noreferrer">Response.End()</a>.</p>
| <p>One additional comment.</p>
<p>If a portion of the page has already been written to the output buffer then it is important that you clear any buffered content or the page may not appear correctly.</p>
<p>This is quite likely in a templated environment. e.g. Master pages...</p>
<pre><code>Response.ClearContent();... | 26,750 |
<p>I want to build a LineChart component where the color of the line is indicative on how high the value is. I should be able to do this buy just using a gradient stroke (see below) but for some reason the gradient only goes from left to right and the "angle" property is being ignored. How could i do this?</p>
<pre><c... | <p>After encountering the same problem and using James Hay's explanation/example above, I constructed my own LineSegmentRenderer.</p>
<p>Basically I wanted to have a top-to bottom gradient stroke in my lineChart. I too found out that the angle or more accurately the rotation property of the LinearGradientStroke wasn't... | <p>I would expect that you would need to create a custom lineSegmentRenderer for the line series chart. The current lineSegmentRenderer is a ShadowLineRenderer. Without actually solving the entire problem myself, i would create a new class based on ShadowLineRenderer and change the updateDisplayList method to draw the... | 44,933 |
<p>What are the best algorithms (and explanations) for representing and rotating the pieces of a tetris game? I always find the piece rotation and representation schemes confusing.</p>
<p>Most tetris games seem to use a naive "remake the array of blocks" at each rotation:</p>
<p><a href="http://www.codeplex.com/Proj... | <p>There is a limited amount of shapes, so I would use a fixed table and no calculation. That saves time.</p>
<p>But there are rotation algorithms. </p>
<p>Chose a centerpoint and rotate pi/2. </p>
<p>If a block of a piece starts at (1,2) it moves clockwise to (2,-1) and (-1,-2) and (-1, 2).
Apply this for each bloc... | <p>I have used a shape position and set of four coordinates for the four points in all the shapes. Since it's in 2D space, you can easy apply a 2D rotational matrice to the points.</p>
<p>The points are divs so their css class is turned from off to on. (this is after clearing the css class of where they were last tu... | 28,945 |
<p>I would like to dynamically switch the video source in a streaming video application. However, the different video sources have unique image dimensions. I can generate individual SDP files for each video source, but I would like to combine them into a single SDP file so that the viewing client could automatically re... | <p>The parameters in your two sdp examples are very close - the stream name and the sprop-parameter-sets differ. I assume you don't care about the stream name. If you need separate sprop-parameter-sets and the clients support the standard well you can use separate dynamic payload types for each resolution and have a si... | <p>I think it depends on your decoder. If it supports parameters change inside the stream, then if you can tell the encoder to put the corresponding header when changing resolution, your decoder should automatically switch.</p>
<p>What is your question exactly ?
Is it : How can I change resolution without stopping / r... | 19,812 |
<p>What would be a good local database for a Silverlight application? The database's main purpose is for local data caching and synchronization services. I do not believe that SQL anywhere or SQLite will work since they use unmanaged code which will not run under the silverlight sandbox</p>
| <p>Why don't use a new feature in SL 2 called "Isolated Storage"? It is fully support in local database (like Google Gear) but of course It is not a database. You can use XML file format to keep it. </p>
<ul>
<li>pros; User just need to install SL runtime. </li>
<li>cons; It's not exactly a database</li>
</ul>
<h3>Fi... | <p>Yes, I think a LINQ provider is the optimal solution. As the storage space is limited, you don't really <em>need</em> tables and indexes, it would be convenient to have a simple way to store and query objects on the client via LINQ without having to deal with low-level file streams.</p>
| 13,635 |
<p>I have a defined MenuItem that I would like to share between two different menus on one page. The menu contains functionallity that is the same between both menus and I do not want two copies of it. Is there anyway to define a MenuItem in the Page.Resources and reference it in the ContextMenu XAML below?</p>
<pre><... | <p>I've done this by setting x:Shared="False" on the menu item itself. Resources are shared between each place that uses them by default (meaning one instance across all uses), so turning that off means that a new "copy" of the resource is made each time.</p>
<p>So:</p>
<pre><code><MenuItem x:Key="myMenuItem" x:Sh... | <p>A number of options:
a) Databind the ContextMenu or the Menu to the same underlying collection and use item templates et al to the work
b) Use commands, and databind to a set of command bindings</p>
| 18,093 |
<p>I have a string that represents a non indented XML that I would like to pretty-print. For example:</p>
<pre><code><root><node/></root>
</code></pre>
<p>should become:</p>
<pre><code><root>
<node/>
</root>
</code></pre>
<p>Syntax highlighting is not a requirement. To tackle t... | <p>From the text of the question <strong>I get the impression that a string result is expected</strong>, as opposed to an HTML-formatted result.</p>
<p>If this is so, <strong>the simplest way to achieve this is to process the XML document with the <a href="http://www.w3.org/TR/xslt#copying" rel="noreferrer">identity t... | <p><a href="https://github.com/javadev/xml-to-json" rel="nofollow noreferrer">Xml-to-json</a> library has method <code>formatXml(xml).</code> I am the maintainer of the project.</p>
<pre><code>var prettyXml = formatXml("<a><b/></a>");
// <a>
// <b/>
// </a>
</code></pre>
| 49,267 |
<p>When I used to write libraries in C/C++ I got into the habit of having a method to return the compile date/time. This was always a compiled into the library so would differentiate builds of the library. I got this by returning a #define in the code:</p>
<p>C++:</p>
<pre><code>#ifdef _BuildDateTime_
char* SomeCl... | <p><strong>I would favour the standards based approach.</strong> Put your version information (along with other useful publisher stuff such as build number, subversion revision number, author, company details, etc) in the jar's <a href="http://java.sun.com/developer/Books/javaprogramming/JAR/basics/manifest.html" rel=... | <blockquote>
<p>One suggestion I got from a co-worker
was to get the ant file to create a
file on the classpath and to package
that into the JAR and have it read by
the method. ... To my mind that's a
hack and could be circumvented/broken
by someone having a similarly named
file outside the JAR, but on ... | 12,669 |
<p>Pros. and cons? how long do you use it? What about jambi?</p>
| <p>I've used Qt on a couple of projects I did in c++ on several platforms over a period of seven years. I think it works pretty well and definitely was quicker for me to develop a decent GUI app on the Mac than plodding through a language I didn't know (Objective-C) at the time.</p>
<p>I think the signal/slot mechani... | <p>Don't use it, however...</p>
<p>Pro:
QT has an optional 3 phase layout, where as WX only allows for 2 currently (I believe they plan to do 3 phase, just have not worked it in yet).</p>
<p>One of the bigger problems with using layouts is static text and wrapping. WX asks how big is your min width/height and portion... | 14,973 |
<p>I am talking about Google Text Translation User Interface, in <a href="http://www.google.com/language_tools" rel="nofollow noreferrer">Google Language Tools</a>.</p>
<p>I like the fact that you can get translations of text for a lot of languages. However, I think is not so good always to show all options of transla... | <p>I think it's probably fine. There are only a little over 30 languages in the list, and close to half of them are pretty common languages, so I don't think it really makes sense to put the common ones first. It's not like a country list where you have to search through 180+ countries to find yours.</p>
<p>The only t... | <p>The simplest way to do what you are asking is to sort by request frequency and then by alpha/numeric. This will put languages where translation requests are most common to the top. It still won't solve your problem perfectly, but it would be an easy improvement, and one that would work better for most people. </p... | 23,536 |
<p>I have tried but for some reason the workflow is not triggered. </p>
| <p>Yes, it is allowed. I myself used it for Task list.</p>
| <p>It should works as for all other kinds of lists.</p>
| 31,194 |
<p>I'm trying to find out whether I should be using business critical logic in a trigger or constraint inside of my database.<br>
So far I've added logic in triggers as it gives me the control over what happens next and means I can provide custom user messages instead of an error that will probably confuse the users.</... | <p>Constraints hands down!</p>
<ul>
<li><p>With constraints you specify relational principles, i.e. facts about your data. You will never need to change your constraints, unless some fact changes (i.e. new requirements).</p></li>
<li><p>With triggers you specify how to handle data (in inserts, updates etc.). This is a... | <p>I agree with everyone here about constraints. Use them as much as possible.</p>
<p>There is a tendency to overuse triggers, especially with new developers. I have seen situations where a trigger fires another trigger which fires another trigger that repeats the first trigger, creating a cascading trigger that tie... | 17,847 |
<p>How to host the WCF service in windows service?</p>
<p>Thanks
Sekar</p>
| <p>I thought this article did a pretty good job of covering the steps required:
<a href="http://msdn.microsoft.com/en-us/library/ms733069.aspx" rel="nofollow noreferrer">WCF Link</a></p>
<p>To summarize:</p>
<ul>
<li>To start with you need to create a new visual studio project of the type "Windows Service". </li>
<li... | <p>I just saw this today come across Channel 9:</p>
<p><a href="http://channel9.msdn.com/shows/Endpoint/endpointtv-Screencast-Hosting-WCF-Services-in-Windows-Services/" rel="nofollow noreferrer">http://channel9.msdn.com/shows/Endpoint/endpointtv-Screencast-Hosting-WCF-Services-in-Windows-Services/</a></p>
| 31,123 |
<p>I'm looking for a Java library for SWIFT messages. I want to</p>
<ul>
<li>parse SWIFT messages into an object model</li>
<li>validate SWIFT messages (including SWIFT network validation rules)</li>
<li>build / change SWIFT messages by using an object model</li>
</ul>
<p>Theoretically, I need to support all SWIFT me... | <p>Have you looked at <a href="http://wife.sourceforge.net/" rel="noreferrer">WIFE</a>? We use that in our application which translates SWIFT messages to an internal XML format and back again. We haven't had any problems with it. Also, it's licensed under the LGPL, so you can hack it up if you need to. Check it out... | <p>I can not really help you out with a Java implementation. Microsoft of course, have their own Biztalk adapter for ISO15022 and 20022. And they will actually do the validation fairly well. But as you say you are actually looking for a java solution. </p>
<p>You might find, as I did when I researched this 6 years ag... | 4,482 |
<p>I am toying with the idea of creating an completely new operating system and would like to hear what everyone on this forums take is on that? First is it too late are the big boys so entrenched in our lives that we will never be able to switch (wow - what a terrible thought...). But if this is not the case, what s... | <p>To answer the first question: It's never too late. Especially when it comes to niche market segments and stuff like that. </p>
<p>Second though, before you start down the path of creating a new OS, you should understand the kind of undertaking it is: it'd be a massive project.</p>
<p>Is it just a normal programmer... | <p>You could also consider going with MINIX which is a good starting point.</p>
| 12,674 |
<p>Does anyone know if you can programmatically open a .webarchive on the iPhone? A .webarchive is Safari's way of packaging up a webpage and it's associated resources into a single file.</p>
<p>I tried creating one and browsing to a link to one in mobile safari, but it didn't work....</p>
<p>Note: I was kind of hop... | <p>webarchive is supported on iOS. Just load it on UIWebView. It just works!</p>
<p>for loading a webarchive on your bundle, just do</p>
<pre><code>NSURL *fileURL = [[NSBundle mainBundle] URLForResource:@"myFile"
withExtension:@"webarchive"];
[webView loadRequest:[NSURLRequest requestWithURL:fileURL]];
</code><... | <p>AirSharing on the iPhone will open webarchive files, but I've no idea if they are doing it all themselves or using native webarchive support.</p>
<p>See <a href="http://www.avatron.com/products/" rel="nofollow noreferrer">http://www.avatron.com/products/</a></p>
| 27,901 |
<p>I've got a project coming up that will involve connecting to one to many backend systems through the same interface; let's call it IBacksideProvider. </p>
<p>I'd like to use Unity to inject these providers at runtime. The problem is that since we're talking about 1...n backend systems, I'd need to register 1...n ... | <p>Any reason why this wouldn't work?
<a href="http://msdn.microsoft.com/en-us/library/cc440943.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/cc440943.aspx</a></p>
<blockquote>
<p>To retrieve a list of object instances from the container based on named registrations, use the ResolveAll meth... | <p><a href="http://www.codeproject.com/KB/cs/LinFu_IOC.aspx" rel="nofollow noreferrer" title="LinFu">LinFu.IOC</a> supports IEnumerable<T> and IList<T> injection for constructors, properties, methods, and even fields, all right out of the box. AFAIK, it's one of the very few containers on that blog that act... | 45,603 |
<p>I work on a desktop sales app that is run off a tablet and was wondering if this and other "traditional" desktop tablet applications could be viable as a offline web application. The main difference with tablet applications being the inking support. I think a web app can get close with browser gestures.</p>
| <p>I don't see the distinction between a tablet and a laptop. The decision to build an off line web application should be no different regardless of the medium.</p>
| <p>I don't see the distinction between a tablet and a laptop. The decision to build an off line web application should be no different regardless of the medium.</p>
| 31,477 |
<p>Does anyone have a good resource on dlls and how they are used / generated in Visual Studio? A few questions I'm rather hazy on specifically are:</p>
<ul>
<li>How refresh files work</li>
<li>How dll version numbers are generated</li>
<li>The difference between adding a reference by project vs browsing for the spec... | <p>See the question on <a href="https://stackoverflow.com/questions/124549/dll-information">DLL information</a> for some background.</p>
<p>Version numbers for unmanaged DLLs are stored in the DLL's rc file, same as for an exe. For managed DLLs I believe it uses AssemblyFileInfo attribute, usually in AssemblyInfo.cs ... | <p>See the question on <a href="https://stackoverflow.com/questions/124549/dll-information">DLL information</a> for some background.</p>
<p>Version numbers for unmanaged DLLs are stored in the DLL's rc file, same as for an exe. For managed DLLs I believe it uses AssemblyFileInfo attribute, usually in AssemblyInfo.cs ... | 20,436 |
<p>The JUnit framework contains 2 <code>Assert</code> classes (in different packages, obviously) and the methods on each appear to be very similar. Can anybody explain why this is?</p>
<p>The classes I'm referring to are: <a href="http://junit.org/junit/javadoc/4.5/junit/framework/Assert.html" rel="noreferrer"><code>j... | <p>The old method (of JUnit 3) was to mark the test-classes by extending <code>junit.framework.TestCase</code>. That inherited <code>junit.framework.Assert</code> itself and your test class gained the ability to call the assert methods this way.</p>
<p>Since version 4 of JUnit, the framework uses <code>Annotations</co... | <p>I did a rough source code compare and there are no serious changes. A lot of comments were added in <code>org.junit.Assert</code> and some refactorings are done. The only change is the comparison with <code>Arrays</code>. There are some code cleanups, but there's (imho) <strong>no functional change</strong>.</p>
| 37,112 |
<p>I printed a test cube with ABS on my Ender 3 and after some tuning, I still have a problem I cannot solve. Two of the vertical edges (I believe they are the ones on the X+ side) are slightly squished in. Could this be due to warping or something else? I printed it at 0.1 mm layer height, 235/110 °C hotend/bed temper... | <p>I think this is caused by the shape of the hole. The shape is parabolic or circular, this means that if you slice it as in the green part, the slicer determines the placing of the layers along the curvature. If it has a shallow curvature, and slicing layer height is relatively thick, the curvature of the object cann... | <p>I think this is caused by the shape of the hole. The shape is parabolic or circular, this means that if you slice it as in the green part, the slicer determines the placing of the layers along the curvature. If it has a shallow curvature, and slicing layer height is relatively thick, the curvature of the object cann... | 1,149 |
<p>I would like to document the file format of regedit utility, so data can be merged into the registry. </p>
<p>From the command-line you can (silently) merge data from a batch file like this:</p>
<pre><code>regedit /s file.reg
</code></pre>
<p>Exporting from a subkey goes like this:</p>
<pre><code>regedit /e file... | <p>Remove keys and values by using the minus sign (-).</p>
<pre><code>REGEDIT4
[-HKEY_CURRENT_USER\RemoveThisTree]
[HKEY_CURRENT_USER\RemoveValue]
"valueName"=-
</code></pre>
<h3>References</h3>
<ul>
<li><p>Minus sign to delete mentioned here: <a href="https://support.microsoft.com/en-us/kb/310516" rel="noreferrer">... | <p>Documenting the .reg file format is really more <a href="http://support.microsoft.com/kb/310516" rel="noreferrer">Microsoft's job</a>.</p>
| 43,329 |
<p>Is there any way to get the ID of the element that fires an event?</p>
<p>I'm thinking something like:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>$(document).ready... | <p>In jQuery <code>event.target</code> always refers to the element that triggered the event, where <code>event</code> is the parameter passed to the function. <a href="http://api.jquery.com/category/events/event-object/" rel="noreferrer">http://api.jquery.com/category/events/event-object/</a></p>
<pre><code>$(documen... | <p>I'm working with </p>
<blockquote>
<p>jQuery Autocomplete</p>
</blockquote>
<p>I tried looking for an <code>event</code> as described above, but when the request function fires it doesn't seem to be available. I used <code>this.element.attr("id")</code> to get the element's ID instead, and it seems to work fine.... | 7,061 |
<p>the function addresses (Rva+Base) in my MAP-file from visual studio doesn't match the one I see in the debugger (or when I manually inspect my stack frame).</p>
<p>What could be causing this?</p>
<p>/A.B.</p>
| <p>Is the problem in an executable or a DLL?</p>
<p>If it's a DLL what is its preferred load address? If this clashes with any other DLL then it will be rebased by the loader, and this can lead to what you're seeing. </p>
<p>As part of your build process, you should ensure that all your DLLs are rebased (there's a to... | <p>When you are in the debugger and stepping into the code, can you check if the code address is within the range that you see in the "Modules" window? Sometimes the same piece of code may exist in several modules of same / different names.</p>
<p>Once you identify the "Module" which contains the code, use the base ad... | 21,984 |
<p>I would like to keep a static counter in a garbage collected class and increment it using Interlocked::Increment. What's the C++/CLI syntax to do this?</p>
<p>I've been trying variations on the following, but no luck so far:</p>
<pre><code>ref class Foo
{
static __int64 _counter;
__int64 Next()
{
... | <p>You need to use a <a href="http://msdn.microsoft.com/en-us/library/8903062a(VS.80).aspx" rel="noreferrer">tracking reference</a> to your <code>_int64</code> value, using the % tracking reference notation:</p>
<pre><code>ref class Bar
{
static __int64 _counter;
__int64 Next()
{
__int64 %trackRef... | <p>The suggestion to use the <strong>native functions/macros</strong> (i.e. <code>InterlockedExchangePointer</code>, etc... plus a lot of cool ones I didn't know about such as <code>InterlockedXor64</code>) is severely hampered by the fact that doing so can cause an intrinsic (at least with the default compiler setting... | 44,475 |
<p>I'm building a <code>PHP</code> site, but for now the only <code>PHP</code> I'm using is a half-dozen or so includes on certain pages. (I will probably use some database queries eventually.)</p>
<p>Are simple <code>include()</code> statements a concern for speed or scaling, as opposed to static <code>HTML</code>? W... | <p>Certainly include() is slower than static pages. However, with modern systems you're not likely to see this as a bottleneck for a long time - if ever. The benefits of using includes to keep common parts of your site up to date outweigh the tiny performance hit, in my opinion (having different navigation on one page ... | <p>To add on what JayTee mentioned - loading functionality when you need it. If you're not using any of the frameworks that do this automatically, you might want to look into the __autoload() functionality that was introduced in PHP5 - basically, your own logic can be invoked when you instantiate a particular class if ... | 13,786 |
<p>Is there a site like "language shootout"'s (shootout.alioth.debian.org and dada.perl.it/shootout/), which show how to do simple/advanced things in different languages? I.e. how to use hashes in different languages, how to sort, how to write classes, how to connect to sites, etc.. Well, those two above ARE in fact ex... | <p>You should check out the <a href="http://code.google.com/p/easyhook-continuing-detours/" rel="noreferrer">easyhook-continuing-detours</a> project, which is a .NET port of the <a href="http://research.microsoft.com/sn/detours/" rel="noreferrer">Microsoft Detours</a> project. It will allow you to hook unmanaged APIs (... | <p>You can find out when processes start via using a real-time ETW consumer - however, to be able to take some action that could possibly <em>cancel</em> the process from starting, you'll have to do something shady / undocumented, like hooking CreateProcess, or using a kernel filter driver to block reads to the EXE.</p... | 37,478 |
<p>Suppose I have a table called Companies that has a DepartmentID column. There's also a Departaments table that has as EmployeeID column. Of course I have an Employee table as well. The problem is that I want to delete a company, so first i have to delete all the employees for every departament and then all the depar... | <p>I'm not sure why you need nested transactions here. You only need one actual transaction:</p>
<pre><code>BEGIN TRAN
DELETE FROM Employee
FROM Employee
INNER JOIN Department ON Employee.DepartmentID = Department.DepartmentID
INNER JOIN Company ON Department.CompanyID = Company.CompanyID
WHERE Compa... | <p>I'm not answering your question, but foreign Keys <em>is</em> the way to go, why is it not an option?</p>
<p>As for nested transactions they are:</p>
<pre><code>BEGIN
delete from Employee where departmentId = 1;
BEGIN
delete from Department where companyId = 2;
BEGIN
delete from Company where... | 8,336 |
<p>I'd like to add a custom title to one of the predefined UITabBarItems. Whenever I select the particular instance I like in Interface Builder -- if I modify the the title it gets preset back to a 'custom' identifier. Ideally I'd like the book icon from the 'Bookmarks' identifier with my own custom title.</p>
<p>Is t... | <p>Unfortunately, the only types of UITabBarItems are those supplied and described entirely by the OS (ie, it assigns them icons and titles), and those described entirely by the app, as you've discovered. By far the simplest solution is to pull the icon out of somewhere else and use it with <code>-initWithTitle:image:t... | <p>As for finding the icons online... I'm still looking for all the official Apple ones myself. Here's what I've found so far:</p>
<ul>
<li><a href="http://glyphish.com/" rel="nofollow noreferrer">http://glyphish.com/</a></li>
<li><a href="http://www.kombine.net/icon-store/iphone-tab-bar-icons" rel="nofollow noreferre... | 37,261 |
<p>On several of my usercontrols, I change the cursor by using</p>
<pre><code>this.Cursor = Cursors.Wait;
</code></pre>
<p>when I click on something.</p>
<p>Now I want to do the same thing on a WPF page on a button click. When I hover over my button, the cursor changes to a hand, but when I click it, it doesn't cha... | <p>Do you need the cursor to be a "wait" cursor only when it's over that particular page/usercontrol? If not, I'd suggest using <a href="http://msdn.microsoft.com/en-us/library/system.windows.input.mouse.overridecursor.aspx" rel="noreferrer">Mouse.OverrideCursor</a>:</p>
<pre><code>Mouse.OverrideCursor = Cursors.Wait;... | <p>The following worked for me:</p>
<pre><code>ForceCursor = true;
Cursor = Cursors.Wait;
</code></pre>
| 39,497 |
<p>How can I launch an application using C#?</p>
<p>Requirements:
Must work on <a href="http://en.wikipedia.org/wiki/Windows_XP" rel="noreferrer">Windows XP</a> and <a href="http://en.wikipedia.org/wiki/Windows_Vista" rel="noreferrer">Windows Vista</a>.</p>
<p>I have seen a sample from DinnerNow.net sampler... | <p>Use <a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.process.start.aspx" rel="noreferrer"><code>System.Diagnostics.Process.Start()</code></a> method.</p>
<p>Check out <a href="http://www.codeproject.com/KB/cs/start_an_external_app.aspx" rel="noreferrer">this article</a> on how to use it.</p>
<pr... | <p>Try this:</p>
<pre><code>Process.Start("Location Of File.exe");
</code></pre>
<p>(Make sure you use the System.Diagnostics library)</p>
| 29,728 |
<p>Really simple question - how do I do a search to find all records where the name starts with a certain string in ActiveRecord. I've seen all sorts of bits all over the internet where verbatim LIKE SQL clauses are used - but from what I've heard that isn't the 'correct' way of doing it.</p>
<p>Is there a 'proper' Ra... | <p>If you're looking to do the search in the database then you'll need to use SQL.</p>
<p>And, of course, you'll need to do the search in the database otherwise you need to load <em>all</em> the objects into Ruby (which isn't a good thing).</p>
<p>So, you will need something like</p>
<pre><code>MyModel.find(:all, :c... | <p>Dave Sag, I guess the first part of your code should be</p>
<pre><code>class User
scope :name_starts_with, (lambda do |str|
{:conditions => ['lower(name) like ?', "#{str.downcase}%"]}
end )
end
</code></pre>
| 31,296 |
<p>This seems like a pretty softball question, but I always have a hard time looking up this function because there seem there are so many variations regarding the referencing of char and tchar.</p>
| <p><a href="http://msdn.microsoft.com/en-us/library/dd319072(v=vs.85).aspx" rel="nofollow noreferrer">MultiByteToWideChar</a> but also see <a href="http://archives.miloush.net/michkap/archive/2005/04/19/409566.html" rel="nofollow noreferrer">"A few of the gotchas of MultiByteToWideChar"</a>.</p>
| <p>I realize this is an old thread, but it didn't get me the "right" answer, so am adding it now.</p>
<p>The way this appears to be done now is to use the TEXT macro. The example for FindFirstFile at msdn points this out.
<a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa364418%28v=vs.85%29.aspx" rel... | 19,284 |
<p>Or is there a chance that the operation will fail?</p>
<p>Thanks.</p>
<p>I chose the wrong term and what I really meant was rounding to 0, not truncation.</p>
<p>The point is, I need to compare the integer part of two doubles and I'm just casting them to int and then using ==, but, as someone pointed out in one o... | <p><a href="https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition" rel="nofollow noreferrer">Here's the updated site</a> which discusses the pros and cons of several methods of comparing floating point numbers. (You can still view the <a href="http://www.cygnus-software.com/papers/c... | <p>If your absolut value is less than 2^23 for single or 2^52 for double you can use round() and then do the compare.
Larger values can not be precisly stored and this opens for situations where N == N+1.</p>
| 29,264 |
<p>I'm attempting to use Mono to load a bitmap and print it on Linux but I'm getting an exception. Does Mono support printing on Linux? The code/exception are below:</p>
<p><strong>EDIT:</strong> No longer getting the exception, but I'm still curious what kind of support there is. Leaving the code for posterity or ... | <p>From the <a href="http://www.mono-project.com/FAQ:_General" rel="noreferrer">Mono docs</a>, I think yes:</p>
<blockquote>
<p>Managed.Windows.Forms (aka
System.Windows.Forms): A complete and
cross platform, System.Drawing based
Winforms implementation.</p>
</blockquote>
<p>It also useful if you run the <a h... | <p><a href="http://www.go-mono.com/archive/1.2/" rel="nofollow noreferrer">According to</a></p>
<p>System.Drawing is now complete, and in addition to being the underlying rendering engine for Windows.Forms, it has also been tested for using third party controls that heavily depend on it.</p>
| 4,705 |
<p>I have Perl script and need to determine the full path and filename of the script during execution. I discovered that depending on how you call the script <code>$0</code> varies and sometimes contains the <code>fullpath+filename</code> and sometimes just <code>filename</code>. Because the working directory can vary ... | <p>There are a few ways:</p>
<ul>
<li><a href="http://perldoc.perl.org/perlvar.html#$0" rel="noreferrer"><code>$0</code></a> is the currently executing script as provided by POSIX, relative to the current working directory if the script is at or below the CWD</li>
<li>Additionally, <code>cwd()</code>, <code>getcwd()</... | <p>On *nix, you likely have the "whereis" command, which searches your $PATH looking for a binary with a given name. If $0 doesn't contain the full path name, running whereis $scriptname and saving the result into a variable should tell you where the script is located.</p>
| 11,045 |
<p>I have a webapp that segfaults when the database in restarted and it tries to use the old connections. Running it under <code>gdb --args apache -X</code> leads to the following output:</p>
<pre><code>Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1212868928 (LWP 16098)]
0xb7471c20 in mys... | <p>What this probably means is that there's a difference between your mod_perl environment and the one you were testing via your script. Some things to check:</p>
<ul>
<li><p>Was your mod_perl compiled with the same version of Perl</p></li>
<li><p>Are the @INC's the same for both</p></li>
<li><p>Are you using threads ... | <p>What this probably means is that there's a difference between your mod_perl environment and the one you were testing via your script. Some things to check:</p>
<ul>
<li><p>Was your mod_perl compiled with the same version of Perl</p></li>
<li><p>Are the @INC's the same for both</p></li>
<li><p>Are you using threads ... | 22,067 |
<p>What is the correct way to check if a value is a date/number in Delphi?</p>
<p>I know other languages have functions like isDate and isNaN, but what is the Delphi equivalent? at the minute I have this</p>
<pre><code>function isNumeric(s1:string):boolean;
begin
// will throw exception if its not a number
/... | <p>For integers, you could use TryStrToInt to check and convert without throwing exceptions:</p>
<pre><code>function TryStrToInt(const s: string; out i : integer): boolean;
</code></pre>
<p>I'm not absolutely sure there is a full equivalent for floats, though, so you might need to use StrToFloat() and accept the poss... | <p>You CAN turn off the annoying exceptions you don't want by checking the "ignore this exception" box that pops up. Future exceptions will be then ignored for that exception class. To start asking again, just go to the Options|Debugger Options and uncheck the ones you are ignoring.</p>
| 29,674 |
<p>I have a <code>ListBox</code> where the number of items is added based on and integer property set by a user. The items are created from a <code>ControlTemplate</code> resource that which is comprised of a Label and a <code>TextBox</code> inside of a <code>DockPanel</code>. The label is not data bound but I would li... | <p>Can you not use a generic class to fix this?</p>
<p>I.e. instead of:</p>
<pre><code> private ExportController MyController
{
get { return base.Controller as ExportController; }
}
</code></pre>
<p>in the derived class. </p>
<p>Put:</p>
<pre><code> protected T MyController
{
get { return this a... | <p>I think there is a design problem here. </p>
<p>Are you sure that MyController is needed to be ExportControler (or any other) and not the base (or derivated class)? May an intermediate class, interface or generics avoid this? </p>
<p>Please, give details about why do you need redefinie MyControler all the time.</p... | 43,789 |
<p>The Zend Framework coding standard mentions the following:</p>
<blockquote>
For files that contain only PHP code, the closing tag ("?>") is never permitted. It is not required by PHP, and omitting it prevents the accidental injection of trailing whitespace into the response.
</blockquote>
<ul>
<li><a href="http://fr... | <p>Removing the closing tags when you can is probably a best practice really. The reason for that is because if you have any character (even whitespace) outside of the ?> in a php file it can stop thing such as headers to stop working if the character gets sent to the browser before the header gets set.</p>
| <p>Our office works with e-learning apps built in Flash and we discovered early on that if the closing tag is omitted from the server side scripts then it breaks our communication mechanism with the e-learnng apps.</p>
<p>One caveat to this would be that our debuggng process didn't first try it in a simplified environ... | 29,269 |
<p>I am trying to dynamically generate links to files on a network share that will work in both IE and safari. In IE, doing <code>href=\\networksharename\foldername\filename</code> works fine, and we thought this worked fine on safari in our initial testing, but our safari users are reporting page cannot be displayed.... | <p>First, you should replace the backslash (\) with slash (/). A full URL may also be helpfull (something like smb://server/shared-folder/...), but i do not know what share you have.</p>
| <p>Are the shares on a DFS? MacOS does not have DFS support.</p>
| 34,859 |
<p>I'm not asking this question because of the merits of garbage collection first of all. My main reason for asking this is that I do know that Bjarne Stroustrup has said that C++ will have a garbage collector at some point in time.</p>
<p>With that said, why hasn't it been added? There are already some garbage coll... | <p>Implicit garbage collection could have been added in, but it just didn't make the cut. Probably due to not just implementation complications, but also due to people not being able to come to a general consensus fast enough.</p>
<p>A quote from Bjarne Stroustrup himself:</p>
<blockquote>
<p>I had hoped that a garbag... | <p>Mainly for two reasons:</p>
<ol>
<li>Because it doesn't need one (IMHO)</li>
<li>Because it's pretty much incompatible with RAII, which is the cornerstone of C++</li>
</ol>
<p>C++ already offers manual memory management, stack allocation, RAII, containers, automatic pointers, smart pointers... That should be enoug... | 17,714 |
<p>If I call <code>os.stat()</code> on a broken <code>symlink</code>, python throws an <code>OSError</code> exception. This makes it useful for finding them. However, there are a few other reasons that <code>os.stat()</code> might throw a similar exception. Is there a more precise way of detecting broken <code>symlinks... | <p>A common Python saying is that it's easier to ask forgiveness than permission. While I'm not a fan of this statement in real life, it does apply in a lot of cases. Usually you want to avoid code that chains two system calls on the same file, because you never know what will happen to the file in between your two c... | <p>I had a similar problem: how to catch broken symlinks, even when they occur in some parent dir? I also wanted to log all of them (in an application dealing with a fairly large number of files), but without too many repeats.</p>
<p>Here is what I came up with, including unit tests.</p>
<p><strong>fileutil.py</stro... | 4,115 |
<p>I want to merge two dictionaries into a new dictionary.</p>
<pre><code>x = {'a': 1, 'b': 2}
y = {'b': 3, 'c': 4}
z = merge(x, y)
>>> z
{'a': 1, 'b': 3, 'c': 4}
</code></pre>
<p>Whenever a key <code>k</code> is present in both dictionaries, only the value <code>y[k]</code> should be kept.</p>
| <h2>How can I merge two Python dictionaries in a single expression?</h2>
<p>For dictionaries <code>x</code> and <code>y</code>, their shallowly-merged dictionary <code>z</code> takes values from <code>y</code>, replacing those from <code>x</code>.</p>
<ul>
<li><p>In Python 3.9.0 or greater (released 17 October 2020, <a... | <p>The question is tagged <code>python-3x</code> but, taking into account that it's a relatively recent addition and that the most voted, accepted answer deals extensively with a Python 2.x solution, I dare add a one liner that draws on an irritating feature of Python 2.x list comprehension, that is <em>name leaking</e... | 5,999 |
<p>I am new to Access. I have a table full of records. I want to write a function to check if any id is null or empty. If so, I want to update it with xxxxx.
The check for id must be run through all tables in a database.
Can anyone provide some sample code?</p>
| <p>I'm not sure if you are going to be able to find all tables in the database with Access SQL. Instead, you might want to write up some VBA to loop through the tables and generate some SQL for each table. Something along the lines of:</p>
<pre><code>update TABLE set FIELD = 'xxxxxx' where ID is null
</code></pre>
| <p>I'm calling it the <em>UpdateFieldWhereNull</em> Function, and shown is a Subroutine which calls it (<em>adapted from <a href="http://www.aislebyaisle.com/access/vba_backend_code.htm" rel="nofollow noreferrer">http://www.aislebyaisle.com/access/vba_backend_code.htm</a></em>)</p>
<p>It updates all tables in the <em>... | 29,505 |
<p>Is there an easy way to modify this code so that the target URL opens in the SAME window?</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><a href="javascript:q=(do... | <p>The second parameter of <em>window.open()</em> is a string representing the name of the target window. </p>
<p>Set it to: "_self".</p>
<pre><code><a href="javascript:q=(document.location.href);void(open('http://example.com/submit.php?url='+escape(q),'_self','resizable,location,menubar,toolbar,scrollbars,status... | <p>try</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><a href="#"
onclick="location='http://example.com/submit.php?url='+escape(location)"
>click here<... | 33,578 |
<p>I'm currently building a Gridview that has expandable rows. Each row contains a dynamically created Panel of Form elements. Right now, I have a javascript function that expands (or in my case, makes visible) the panel when an Image is clicked on the Gridview row.</p>
<p>My question is... is there a more efficient w... | <p>Actually, it isn't performing badly since my original SQL query can populate every single row and I have enabled paging on the Gridview. I'm just wondering if they can be built on the fly using PageMethods or some sort of JSON/AJAX solution. I haven't seen anything, but... worth a try in searching for it.</p>
| <p>Personally trying to create the data on the fly would most likely result in a slower user experience.</p>
<p>When I do things like what you are describing I typically use Repeaters, that way I can do a template layout that simply defines all of the needed elements right away, and it handles the binding actions.</p>... | 39,484 |
<p>If I have variable of type <code>IEnumerable<List<string>></code> is there a LINQ statement or lambda expression I can apply to it which will combine the lists returning an <code>IEnumerable<string></code>? </p>
| <p>SelectMany - i.e.</p>
<pre><code> IEnumerable<List<string>> someList = ...;
IEnumerable<string> all = someList.SelectMany(x => x);
</code></pre>
<p>For each item in someList, this then uses the lambda "x => x" to get an IEnumerable<T> for the inner items. In this case, eac... | <p>Make a simple method. No need for LINQ:</p>
<pre><code>IEnumerable<string> GetStrings(IEnumerable<List<string>> lists)
{
foreach (List<string> list in lists)
foreach (string item in list)
{
yield return item;
}
}
</code></pre>
| 18,113 |
<p>I am after a regular expression that validates a percentage from 0 100 and allows two decimal places. </p>
<p>Does anyone know how to do this or know of good web site that has example of common regular expressions used for client side validation in javascript?</p>
<p>@Tom - Thanks for the questions. Ideally there ... | <p>Rather than using regular expressions for this, I would simply convert the user's entered number to a floating point value, and then check for the range you want (0 to 100). Trying to do numeric range validation with regular expressions is almost always the wrong tool for the job.</p>
<pre><code>var x = parseFloat(... | <blockquote>
<p><code>(100|[0-9]{1,2})(\.[0-9]{1,2})?</code></p>
</blockquote>
<p>That should be the regex you want. I suggest you to read Mastering Regular Expression and download RegexBuddy or The Regex Coach.</p>
| 28,233 |
<p>What is the single best pretty-printing library for Java? I mean a library for printing formatted output with indentation, break hints, etc., <em>not</em> a library for beautifying/re-formatting Java code itself. Ideally, the library would "play nice" with <code>System.out.println</code> and friends.</p>
<p>For an ... | <p>Is it <a href="http://jpplib.sourceforge.net/" rel="nofollow noreferrer">jpplib</a>?</p>
| <p>Since you talk about boxes, break hints and so on I assume you mean to build a text-based windowing application. So I guess that you are looking for something similar to <a href="http://en.wikipedia.org/wiki/Ncurses" rel="nofollow noreferrer">Ncurses</a> but in Java. Maybe <a href="http://www.pitman.co.za/projects/c... | 43,029 |
<p>I'm working with a VB6 code base and I'm interested in beginning to generate documentation for future development efforts. I'm traditionally a Java developer and I've gotten quite used to the Javadoc system for generating such documentation. I found <a href="http://vb-doc.sourceforge.net/" rel="noreferrer">VB.DOC</a... | <p>There are <a href="http://www.doxygen.nl/helpers.html" rel="nofollow noreferrer">a few filters</a> that will allow you to use <a href="http://www.doxygen.nl/" rel="nofollow noreferrer">Doxygen</a> with VB6.</p>
| <p>I used <a href="http://www.innovasys.com/products/dx2008/overview.aspx" rel="nofollow noreferrer">Document! X</a> version 4, but I have to say it was not the most stable program to use and sometimes caused crashes in the IDE. Perhaps later versions have improved; they still seem to support VB 5&6.</p>
| 32,995 |
<p>I'd like to skip the tests and create a (default) Makefile.</p>
| <p>Of course you can write a makefile by hand. A quick googling shows LOTS of tutorials. <a href="http://mrbook.org/tutorials/make/" rel="nofollow noreferrer">This one</a> looks promising.</p>
<p>For the cliffs notes version, the example boils down this:</p>
<pre><code>CC=g++
CFLAGS=-c -Wall
LDFLAGS=
SOURCES=main.cpp... | <p>If you happen to be using Perl, there's always good ol' </p>
<pre><code>use ExtUtils::MakeMaker;
WriteMakefile(
'NAME' => 'Foo::Bar',
'DISTNAME' => 'Foo-Bar',
'EXE_FILES' => ["foobar.sh"],
'VERSION_FROM' => 'lib/Foo/Bar.pm',
);
</code></pre>
<p>However, your question is a bit shor... | 39,641 |
<p>I have two machines, speed and mass. speed has a fast Internet connection and is running a crawler which downloads a lot of files to disk. mass has a lot of disk space. I want to move the files from speed to mass after they're done downloading. Ideally, I'd just run:</p>
<pre><code>$ rsync --remove-source-files spe... | <p>How much control do you have over the download process? If you roll your own, you can have the file being downloaded go to a temp directory or have a temporary name until it's finished downloading, and then mv it to the correct name when it's done. If you're using third party software, then you don't have as much ... | <p>Rsync can exclude files matching certain patters. Even if you can't modify it to make it download files to a temporary directory, maybe it has a convention of naming the files differently during download (for example: <code>foo.downloading</code> while downloading for a file named <code>foo</code>) and you can use t... | 7,094 |
<p>Every time you start Visual Studio, the first time you click "Add Reference" to add a DLL reference to a project, by default, the .NET tab on that dialog box is selected. As most people reading this have probably noticed, it can take a long time -- often more than 30 seconds -- for the full list of .NET components ... | <p>I use this <a href="http://blogs.msdn.com/saraford/archive/2008/05/07/did-you-know-you-can-add-references-to-your-solution-directly-from-the-object-browser-210.aspx" rel="nofollow noreferrer">tip</a> to do this in a different way. Open your Object Browser (Cntrl + Alt + J). Change Browse dropdown to "My Solution". S... | <p>I am afraid the answer, as far as I can tell, is no. I even took a trip through the registry to determine if there was someway to reorder the tabs. You might be able to do it with a hex editor but I would advise against that. </p>
| 24,301 |
<p>Does a comparison sort have to compare the A[i] largest and A[i+1] largest values? I think any comparison sort must, but I'm not sure. I've checked out mergesort, insertion sort, and quicksort and in each of them the A[i] largest and A[i+1] largest values have to be compared.</p>
| <p>Every correct algorithm has to compare adjacent cells, unless they are equal. Proof: Assume otherwise. A[i] and A[i+1] in the final array have not been compared (A[i] < A[i+1). What happens if their positions are swapped in the original array? All the comparisons made by the algorithm give the same results as in... | <p>Quicksort and Mergesort will always compare neighboring elements. Only time two elements are not compared, is when the algorithm knows there is an element in between. I think the same holds for most other <em>O</em>(<em>n</em>log <em>n</em>) sorting algorithms.</p>
| 31,252 |
<p>I'm looking for a simple way to grab thumbnails of FLVs in ASP.NET, without having to change any permissions/settings on the server. Ideally, nothing is installed on the server machine, but if necessary, small tools such as FFmpeg are fine.</p>
<p>I've tried FFmpeg using the command-line tool with Process.Start, bu... | <p>If you can embed Flash on a page, the easiest way to show a thumbnail of a FLV is to put a video object on the stage, attach a video to it through a NetStream in actionscript, and then put in an event handler to pause the move immediately after it starts playing.</p>
<p>For example, if you have a video object on th... | <p>Try Media Manager Pro at <a href="http://www.all4dotnet.com/" rel="nofollow noreferrer">http://www.all4dotnet.com/</a></p>
| 24,556 |
<p>Have a n-tire web application and search often times out after 30 secs. How to detect the root cause of the problem?</p>
| <h2>General idea</h2>
<p>Option 1: Load both images as arrays (<code>scipy.misc.imread</code>) and calculate an element-wise (pixel-by-pixel) difference. Calculate the norm of the difference.</p>
<p>Option 2: Load both images. Calculate some feature vector for each of them (like a histogram). Calculate distance betwe... | <p>I think you could simply compute the euclidean distance (i.e. sqrt(sum of squares of differences, pixel by pixel)) between the luminance of the two images, and consider them equal if this falls under some empirical threshold. And you would better do it wrapping a C function.</p>
| 23,048 |
<pre><code>int x;
printf("hello %n World\n", &x);
printf("%d\n", x);
</code></pre>
| <p>It's not so useful for <code>printf()</code>, but it can be very useful for <code>sscanf()</code>, especially if you're parsing a string in multiple iterations. <code>fscanf()</code> and <code>scanf()</code> automatically advance their internal pointers by the amount of input read, but <code>sscanf()</code> does no... | <p>Here's something from the VS2005 CRT code:</p>
<pre><code>/* if %n is disabled, we skip an arg and print 'n' */
if ( !_get_printf_count_output() )
{
_VALIDATE_RETURN(("'n' format specifier disabled", 0), EINVAL, -1);
break;
}
</code></pre>
<p>which brings up this:</p>
<p><a href="http://www.shiny.co.il/shoo... | 46,061 |
<p>The following questions are about XML serialization/deserialization and schema validation for a .net library of types which are to be used for data exchange.</p>
<hr>
<p>First question, if I have a custom xml namespace say "<a href="http://mydomain/mynamespace" rel="nofollow noreferrer">http://mydomain/mynamespace... | <p>Just to add - the "xsi" etc is there to support things like xsi:nil on values later on - a well-known pattern for nullable values. It has to write the stream "forwards only", and it doesn't know (when it writes the first bit) whether it will need nil or not, so it assumes that writing it unnecessarily once is better... | <p>Tools,
- xsd.exe, with a command line like</p>
<pre><code>xsd /c /n:myNamespace.Schema.v2_0 myschema_v2_0.xsd
</code></pre>
<p>I put the schema in a separate project.</p>
<p><a href="http://www.liquid-technologies.com/Product_XmlDataBinding.aspx" rel="nofollow noreferrer">liqudXML</a> which is useful if there a... | 39,890 |
<p>I have created a form to add a user to a database and make user available for login.</p>
<p>Now I have two password fields (the second is for validation of the first). How can I add a validator for this kind of validation to zend_form?</p>
<p>This is my code for the two password fields:</p>
<pre><code> $passwo... | <p>The current version of Zend_Validate has this built in - while there are plenty of other answers, it seems that all require passing a value to <code>Zend_Validate_Identical</code>. While that may have been needed at one point, you can now pass the name of another element. </p>
<p>From the <a href="http://framework.... | <p>You can access all form fields from validator,
also you can use constructor to pass additional arguments</p>
<pre><code>class Example_Validator extends Zend_Validate_Abstract{
const NOT_IDENTICALL = 'not same';
private $testValue;
public function __construct( $arg ) {
$this->testValue = $arg;
... | 45,265 |
<p><strong>Update</strong> - for those of a facetious frame of mind, you can assume that Aggregate still produces the normal result whatever function is passed to it, including in the case being optimized.</p>
<p>I wrote this program to build a long string of integers from 0 to 19999 separate by commas.</p>
<pre><code>... | <p>Why not use one of the other forms of Aggregate?</p>
<pre><code>Enumerable.Range(0, size ).Aggregate(new StringBuilder(),
(a, b) => a.Append(", " + b.ToString()),
(a) => a.Remove(0,2).ToString());
</code></pre>
<p>You can specify any type for your seed, perform whatever formatting or custom c... | <p>Well, that would depend entirely on what code is in the MageAggregateGoFaster namespace now wouldn't it?</p>
<p>This namespace is not part of the .NET runtime, so you've linked in some custom code.</p>
<p>Personally I would think that something that recognizes string concatenation or similar, and builds up a list,... | 46,193 |
<p>I am thinking of changing my web site's homegrown search engine. Before I break out Visual Studio, I wondered if anyone can suggest an alternative that gives me what I need. This being:</p>
<ul>
<li>Works with an ASP.NET site (is a .NET project)</li>
<li>Creates a file-based index</li>
<li>Fast search across hundre... | <p>The <a href="http://incubator.apache.org/lucene.net/" rel="nofollow noreferrer">.NET version of Lucene</a> is what we've been using. It meets all of your criteria.</p>
| <p>Why can't you try out <a href="http://www.google.com/coop/cse/" rel="nofollow noreferrer">google custom search engine</a>? If you want ultimate control over the indexing you can create your own search engine using <a href="http://incubator.apache.org/lucene.net/" rel="nofollow noreferrer">lucene.net</a></p>
| 17,632 |
<p>I have to admit that I always forgot the syntactical intracacies of the naming patterns for Nant (eg. those used in filesets). The double asterisk/single asterisk stuff seems to be very forgettable in my mind.</p>
<p>Can someone provide a definitive guide to the naming patterns?</p>
| <p>The rules are:</p>
<ul>
<li>a single star (*) matches zero or more characters <em>within a path name</em></li>
<li>a double star (**) matches zero or more characters <em>across directory levels</em></li>
<li>a question mark (?) matches exactly one character within a path name</li>
</ul>
<p>Another way to think abo... | <p>Check out the <a href="http://nant.sourceforge.net/release/latest/help/types/fileset.html" rel="nofollow noreferrer">Nant reference</a>. The fileset patterns are:</p>
<p>'*' matches zero or more characters, e.g. *.cs<br>
'?' matches one character, e.g. ?.cs</p>
<p>And '**' matches a directory tree e.g. src/**/*.cs... | 9,522 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.