instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>I want find the index of a given DOM node. It's like the inverse of doing </p>
<pre><code>document.getElementById('id_of_element').childNodes[K]
</code></pre>
<p>I want to instead extract the value of <code>K</code> given that I already have the reference to the child node and the parent node. How do I do this? </... | <p>The shortest possible way, without any frameworks, in all versions of Safari, FireFox, Chrome and IE >= 9:</p>
<p><code>var i = Array.prototype.indexOf.call(e.childNodes, someChildEl);</code></p>
| <p>using a framework like prototype you could use this :</p>
<pre><code>$(el).up().childElements().indexOf($(el))
</code></pre>
| 49,555 |
<p>I recently inherited an old visual basic 6/ crystal reports project which connects to a sql server database. The error message I get (Error# -2147191803 A String is required here) when I attempt to run the project seems to be narrowed down to the .Printout command in the following code: </p>
<pre>
'Login ... | <p>What is the value of your selected variable?</p>
<p>Table.SetLogOnInfo ConnName, DBName, user, pass<br />
<strong>DomainName = selected</strong><br />
'Set parameter Fields<br /></p>
<p>If it is not a string, then that might be the problem. Crystal expects a string variable and when it doesn't receive what it exp... | <p>This can happen in crystal reports 8.5 if you changed the length of a string column you use in your report so that it exceeds 255 bytes. This can also happen if you change the column type from varchar to nvarchar (double byte string!)</p>
<p>The reason for this is that crystal reports 8.5 treats all strings longer ... | 12,881 |
<p>Well i am currently working on a project doing some UI mockups when certain users wanted to have two logo on the top left ot the website.
One is to indicate what is the website about then another is to indicate that this website is actually belong to this particular sector.</p>
<p>I thought that UI design wise this... | <p>It does sound rather confusing, though it may depend on the content of the logos as to whether they are difficult to figure out.</p>
<p>I would recommend getting someone who hasn't used the site to see the mockup and see what they think about it (without guidance)... ie some usability testing.</p>
<p>Check out <a ... | <p>Sounds dependent on the implementation to me.</p>
| 14,131 |
<p>I'm going to start a new project - rewriting an existing system (PHP + SQL Server) from scratch because of some very serious limitations by design.</p>
<p>We have some quite good knowledge of SQL Server (currently we're using SQL Server 2000 in existing system) and we would like to employ its newer version (2008 I ... | <p>I've worked on a project using MSQL Server in conjunction with a Java Stack. It works very well and as long, since JDBC shouldn't really care about your database. We used ehcache together with Hibernate and had problems with the MS JDBC Driver, so we switched to jtds and it works really good.</p>
<p>It's quite a wh... | <p>The JDBC driver works well with SQL Server 2008, I've not had any problems with it. The version that you need to download depends on the version of the JRE you have installed. JRE6 uses JDBC4, JRE7 uses JDBC4.1, etc. Once you download the correct driver from Microsoft and run the installer you will need to copy t... | 2,847 |
<p>i have a link to a media file such as an mp3, and i want it to get downloaded when the user clicks on it, instead of just having the file get played. the page i have in mind is just a plain static html page.</p>
<p>any ideas?</p>
| <p>In order to make that happen you need to send a header with <code>Content-disposition: attachment; filename=fname.ext</code> header in your favorite language before sending the file. </p>
<p>Without knowing the specifics such as what language and what control you have over your server configuration I cannot give y... | <p>While this is not a solution, change the file extension to anything other than MP3.
And, ask the user to rename it once downloaded.</p>
| 43,959 |
<p>I'm using Castle Windsor for dependency injection in my test project. I'm trying to create an instance one of my 'Repository' classes. "It works fine on my machine", but when I run a nightly build in TFS, my tests are not able to load said classes.</p>
<pre><code>private static readonly WindsorContainer _container ... | <p>Mac OS X's "Keychain Access" application gives you access to the nice OS X password generator. Hit command-N and click the key icon. You get to choose password style (memorable, numeric, alphanumeric, random, FIPS-181) and choose the length. It also warns you about weak passwords.</p>
| <pre><code><?php
print md5(rand(0, 99999));
?>
</code></pre>
| 12,684 |
<p>I want to limit my users to a directory and its sub directories but the "Parent Directory" button allows them to browse to an arbitrary directory.</p>
<p>How should I go about doing that?</p>
| <p>You can probably do this by setting your own <a href="https://docs.oracle.com/javase/8/docs/api/javax/swing/filechooser/FileSystemView.html" rel="noreferrer">FileSystemView</a>.</p>
| <p>No need to be that complicated. You can easily set selection mode of a JFileChooser like this</p>
<pre><code>JFileChooser fc = new JFileChooser();
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
fc.setMultiSelectionEnabled(false);
</code></pre>
<p>You can read more reference here <a href="http://docs.oracl... | 5,246 |
<p>I have a SharePoint site with multiple lists, some of which have the same fields - a choice of products or countries.</p>
<p>How can I build the lists in a way that I configure the choice field once and use it in multiple lists, so that in the future, if I add a value to the choice, I add it only once?</p>
| <p>If you go to Site Settings, under Galleries there is an option for Site Columns. You can create your choice list there. Then, under the Library Settings there is an option to Add From Existing Site Columns. You should be able to see and select your newly created column there.</p>
| <p>You should create a list which contains the countries. Then in the lists where you want to reuse the countries lookup, create a column of type Lookup and select the countries list in the "Get infomation from" dropdown.</p>
<p>Here is a link to a more visual guide:
<a href="http://blog.phase2int.com/?p=101" rel="no... | 10,797 |
<p>How does one check if a directory is already present in the PATH environment variable? Here's a start. All I've managed to do with the code below, though, is echo the first directory in %PATH%. Since this is a FOR loop you'd think it would enumerate all the directories in %PATH%, but it only gets the first one.</p>
... | <p>First I will point out a number of issues that make this problem difficult to solve perfectly. Then I will present the most bullet-proof solution I have been able to come up with.</p>
<p>For this discussion I will use lower case path to represent a single folder path in the file system, and upper case PATH to repre... | <p>This routine will search for a path\ or file.ext in the path variable.
It returns 0 if found. Path\ or file may contain spaces if quoted.
If a variable is passed as the last argument, it will be set to <code>d:\path\file</code>.</p>
<pre><code>@echo off&goto :PathCheck
:PathCheck.CMD
echo.PathCheck.CMD: Checks f... | 17,075 |
<p>What is an elegant way to sort objects in PHP? I would love to accomplish something similar to this.</p>
<pre><code>$sortedObjectArary = sort($unsortedObjectArray, $Object->weight);
</code></pre>
<p>Basically specify the array I want to sort as well as the field I want to sort on. I looked into multidimensional... | <p>Almost verbatim from the manual: </p>
<pre><code>function compare_weights($a, $b) {
if($a->weight == $b->weight) {
return 0;
}
return ($a->weight < $b->weight) ? -1 : 1;
}
usort($unsortedObjectArray, 'compare_weights');
</code></pre>
<p>If you want objects to be able to sort ... | <p>If you want to explore the full (terrifying) extent of lambda style functions in PHP, see:
<a href="http://docs.php.net/manual/en/function.create-function.php" rel="nofollow noreferrer">http://docs.php.net/manual/en/function.create-function.php</a></p>
| 15,116 |
<p>My company is using Python for a relatively simple embedded project. Is anyone else out there using Python on embedded platforms? Overall it's working well for us, quick to develop apps, quick to debug. I like the overall "conciseness" of the language.</p>
<p>The only real problem I have in day to day work is th... | <p>We use python in quite a lot of <a href="http://www.embeddedarm.com/products/arm-sbc.php" rel="noreferrer">embedded boards with ARM processors</a> and 16 MB of RAM (running linux).</p>
<p>It works really well and is really easy to make custom code quickly - one of the strong points of python.</p>
<p>As for reliabi... | <blockquote>
<p>Blockquote
The only real problem I have in day to day work is that the last of static checking vs a regular compiler can cause problems to be thrown at run-time, e.g. a simple accidental cat of a string and an int in a print statement can bring the whole application down</p>
</blockquote>
<p>To me ... | 29,820 |
<p>I have seen many programs consisting of structures like the one below</p>
<pre><code>typedef struct
{
int i;
char k;
} elem;
elem user;
</code></pre>
<p>Why is it needed so often? Any specific reason or applicable area?</p>
| <p>As Greg Hewgill said, the typedef means you no longer have to write <code>struct</code> all over the place. That not only saves keystrokes, it also can make the code cleaner since it provides a smidgen more abstraction.</p>
<p>Stuff like</p>
<pre><code>typedef struct {
int x, y;
} Point;
Point point_new(int x, ... | <p>At all, in C language, struct/union/enum are macro instruction processed by the C language preprocessor (do not mistake with the preprocessor that treat "#include" and other)</p>
<p>so :</p>
<pre><code>struct a
{
int i;
};
struct b
{
struct a;
int i;
int j;
};
</code></pre>
<p>struct b is expended as... | 31,491 |
<p>I am re-designing an application for a ASP.NET CMS that I really don't like. I have made som improvements in performance only to discover that not only does this CMS use MS SQL but some users "simply" use MS Access database.</p>
<p>The problem is that I have some tables which I inner join, that with the MS Access v... | <p>You don't need linked tables at all. There are two approaches to using data from different MDBs that can be used without a linked table. The first is to use "IN 'c:\MyDBs\Access.mdb'" in the FROM clause of your SQL. One of your saved queries would be like:</p>
<pre><code>SELECT MyTable.*
FROM MyTable IN 'c:\MyDBs\A... | <p>Within Access, you can add remote tables through the "Linked Table Manager". You could add the links to one Access file or the other, or you could create a new Access file that references the tables in both files. After this is done, the inner-join queries are no different than doing them in a single database. </p... | 14,320 |
<p>I'm at step 8 of the authentication overview found here: <a href="http://wiki.developers.facebook.com/index.php/How_Connect_Authentication_Works" rel="noreferrer">http://wiki.developers.facebook.com/index.php/How_Connect_Authentication_Works</a></p>
<p>In particular, the user has logged into facebook via Facebook C... | <p>I had a lot of trouble figuring out how to make server side calls once a user logged in with Facebook Connect. The key is that the Facebook Connect javascript sets cookies on the client once there's a successful login. You use the values of these cookies to perform API calls on the server.</p>
<p>The confusing pa... | <p>My two cents: a <strong>very</strong> simple project utilizing the "login with Facebook" feature - <a href="http://facebooklogin.codeplex.com/" rel="nofollow">facebooklogin.codeplex.com</a></p>
<p>Not a library, but shows how it all works.</p>
| 41,803 |
<p>When I try to use the code below I get a duplicate variable error because variables are immutable. How do I set the smaller of the two variables (<code>$nextSubPartPos</code> and <code>$nextQuestionStemPos</code>) as my new variable (<code>$nextQuestionPos</code>)?</p>
<pre><code> <xsl:variable name="nex... | <p>Don't close the xsl:variable node in the first line. That is, take the / out of it, then put an <code></xsl:variable></code> after <code></xsl:choose></code>. Next, change the <code><xsl:variable></code> nodes inside the choose to <code><xsl:value-of></code> nodes.</p>
<p>That is, you want t... | <p>Variables in XSLT are immutable. This has tripped me up so many times.</p>
| 41,135 |
<p>How do I list and export a private key from a keystore?</p>
| <p>You can extract a private key from a keystore with Java6 and OpenSSL. This all depends on the fact that both Java and OpenSSL support PKCS#12-formatted keystores. To do the extraction, you first use <code>keytool</code> to convert to the standard format. Make sure you <strong><em>use the same password for both file... | <p>Another less-conventional but arguably easier way of doing this is with <a href="http://jxplorer.org/" rel="nofollow">JXplorer</a>. Although this tool is designed to browse LDAP directories, it has an easy-to-use GUI for manipulating keystores. One such function on the GUI can export private keys from a JKS keystore... | 18,097 |
<p>When I run prints on my Creality CR-10S Pro 3D printer (using Ultimaker Cura as slicer), I set the heated bed to around 70 °C for PETG. after the first few layers, the heated bed set point changes to 0 °C. </p>
<p>Is it normal for a 3D printer to turn the heated bed off during a print, or is this ... | <p><strong>No</strong>, this is not common behavior, and <strong>yes</strong> this can cause your prints to warp or detach from the build plate.</p>
<p>The question is whether you instructed this (by accident) or not (e.g. it can be a result from slicing or some economy mode of the printer). This should be clear if yo... | <p>That is not normal behavior for the heated beds. I don't have that exact model, but when I print the heated bed will stay to whatever temp was set in the slicer program. Unless you override it manually on the printer itself during the print. I would check slicer settings ensuring temp doesn't change after it's first... | 1,205 |
<p>Sybase db tables do not have a concept of self updating row numbers. However , for one of the modules , I require the presence of rownumber corresponding to each row in the database such that max(Column) would always tell me the number of rows in the table.</p>
<p>I thought I'll introduce an int column and keep upd... | <p>You can easily assign a unique number to each row by using an identity column. The identity can be a numeric or an integer (in ASE12+).</p>
<p>This will <em>almost</em> do what you require. There are certain circumstances in which you will get a gap in the identity sequence. (These are called "identity gaps", the b... | <p>I'm not sure why you would want to do this. You could experiment with using temporary tables and <a href="http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.help.ase_12.5.sqlug/html/sqlug/sqlug345.htm" rel="nofollow noreferrer">"select into" with an Identity column</a> like below.</p>
<pre><code>create t... | 22,063 |
<p>I have binary data in a file that I can read into a byte array and process with no problem. Now I need to send parts of the data over a network connection as elements in an XML document. My problem is that when I convert the data from an array of bytes to a String and back to an array of bytes, the data is getting... | <p>If you encode it in base64, this will turn any data into ascii safe text, but base64 encoded data is larger than the orignal data</p>
| <p>How are you building your XML document? If you use java's built in XML classes then the string encoding should be handled for you.</p>
<p>Take a look at the javax.xml and org.xml packages. That's what we use for generating XML docs, and it handles all the string encoding and decoding quite nicely.</p>
<p>---EDIT... | 4,110 |
<p>I am implementing exception handling for our BizTalk services, and have run into a fairly major stumbling block.</p>
<p>In order to make the exception processing as generic as possible, and therefore to allow us to use it for any BizTalk application, our XML error schema includes an xs:any node, into which we can p... | <p>Does your xs:any element have a minOccurs > 0?</p>
<p><a href="http://msdn.microsoft.com/en-us/library/bb251017.aspx#UnsupportedConstructs" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/bb251017.aspx#UnsupportedConstructs</a></p>
<p>I've also read that due to the way that InfoPath works, it can... | <p>Does your xs:any element have a minOccurs > 0?</p>
<p><a href="http://msdn.microsoft.com/en-us/library/bb251017.aspx#UnsupportedConstructs" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/bb251017.aspx#UnsupportedConstructs</a></p>
<p>I've also read that due to the way that InfoPath works, it can... | 5,834 |
<p>Is it really viable to use GCJ to publish server-side applications? Webapps? </p>
<p>My boss is convinced that compiling our (<strong><em>my</em></strong>) webapp into a binary executable is a brilliant idea. (Then again, he likes nice, small simple things with blinky lights that he can understand.) He instinct... | <p>FWIW: I have never had good luck with GCJ, I have had a lot of problems using it and have had some obscure issues pop up that took forever to diagnose to GCJ rather than me (I am always very very reluctant to blame things on external libraries). I will openly admit this happened several years ago and I have never wa... | <p>I don't think that a large application like yours will compile to machine code. Remember that java is not only java syntax (might compile to machine code) but also a virtual machine which is more like an application / process environment. I would suggest making an <a href="http://classworlds.codehaus.org/uberjar.htm... | 9,071 |
<p>Has anyone used <a href="http://www.ayende.com/Blog/archive/2007/09/03/Rhino-Igloo-ndash-MVC-Framework-for-Web-Forms.aspx" rel="nofollow noreferrer">Rhino igloo</a> in a non-trivial project? I am curious if it's worth, what are its drawbacks, does it enhance testability a lot, is it easy to use. How would you compar... | <p>If you want, you can translate this VB.Net code to C#. The theory here is that you change the size of a tab in the control.</p>
<pre><code>Private Declare Function SendMessage _
Lib "user32" Alias "SendMessageA" _
(ByVal handle As IntPtr, ByVal wMsg As Integer, _
ByVal wParam As Integer, ByRef lParam As Inte... | <p>Don't the text boxes allow HTML usage? If that is the case, just use HTML to format the text into a table. Otherwise, try adding the text to a datagrid and then adding that to the form.</p>
| 9,782 |
<p>Yeah, I know the title is a mouthful...</p>
<p>What I mean is to say is how do you communicate with a subject matter expert who needs a theory coded and tested?</p>
<p>For example, weather simulation is a collaboration between meteorologists, computer scientists, and software engineers. The computer scientists an... | <p>The shortest possible answer is Continuous customer involvement. </p>
<p>All the pretty UML diagrams, crayola UI mockups, explanations-to-four-year-olds and other techniques will never give the full experience of using a working application. Keeping the consumer in the loop allows for a feedback cycle both to the ... | <p>With great care and patience. You cannot assume understanding so use a technique like prototyping or pictures to communicate.</p>
<p>When the customer makes a statement you need to implement what you think he says, or draw a picture of it and show him. It is easier for him to recognize your misunderstandings this w... | 33,062 |
<p>Is there an API to access Subversion from C#?</p>
| <p><a href="http://www.pumacode.org/projects/svndotnet/" rel="nofollow noreferrer"><strong>Svn.NET</strong></a> is a continuation (fork) of <a href="http://www.softec.st/en/OpenSource/ClrProjects/SubversionSharp/SubversionSharp.html" rel="nofollow noreferrer">SubversionSharp</a> mentioned in <a href="https://stackoverf... | <p>Check <a href="http://www.softec.st/en/OpenSource/ClrProjects/SubversionSharp/SubversionSharp.html" rel="nofollow noreferrer">SubversionSharp</a>, its basically a C# wrapper library that fully covers the client API of Subversion.</p>
| 36,630 |
<p>I would like to know your experience when you need to take over somebody else's software project - more so when the original software developer has already resigned.</p>
| <p>The most success that we've had with that is to "wiki" everything. During the notice period ask the leaving developer to help you document everything in the team/company wiki and see if you can do code reviews with him/her and add comments to the code while doing the reviews that explain sections. Best for the "taki... | <p>We actually have a specified set of "Deliverables" that has to be present for us to take over a project.</p>
<p>If we have the chance we try to push in one of our folks within the group developing the project at first. That way we get some firsthand knowledgde before our group takes over the code. (in the line of w... | 15,286 |
<p>Can you use windows hooks or other methods to do code injection with c#? I've seen lots of things about code injection but all of them are done in C/C++. I don't know either of those languages and have a really hard time translating. Does anyone have any ideas on how to do this?</p>
| <p>Kevin,
it is possible. You can create library with window hook proc using managed C++. All you need to do is to inject this hook into some application using standard WinAPI (SetWindowsHookEx etc.). Inside this hook you can call System::AppDomain::CurrentDomain->Load method to load your assembly into target applicati... | <p>Mike Stall has <a href="http://blogs.msdn.com/jmstall/archive/2006/09/28/managed-create-remote-thread.aspx" rel="nofollow noreferrer">this sample</a>, that uses CreateRemoteThread. It has the advantage of not requiring any C++. </p>
| 4,397 |
<p>The MSI stores the installation directory for the future uninstall tasks.</p>
<p>Using the <code>INSTALLPROPERTY_INSTALLLOCATION</code> property (that is <code>"InstallLocation"</code>) works only the installer has set the <code>ARPINSTALLLOCATION</code> property during the installation. But this property is option... | <p>Use a registry key to keep track of your install directory, that way you can reference it when upgrading and removing the product.</p>
<p>Using WIX I would create a Component that creates the key, right after the Directy tag of the install directory, declaration</p>
| <p>I would try to use Installer.OpenProduct(productcode). This opens a session, on which you can then ask for Property("TARGETDIR").</p>
| 31,938 |
<p>I seem to be missing something about LINQ. To me, it looks like it's taking some of the elements of SQL that I like the least and moving them into the C# language and using them for other things.</p>
<p>I mean, I could see the benefit of using SQL-like statements on things other than databases. But if I wanted to... | <p>LINQ is not about SQL. LINQ is about being apply functional programming paradigmns on objects.</p>
<p>LINQ to SQL is an ORM built ontop of the LINQ foundation, but LINQ is much more. I don't use LINQ to SQL, yet I use LINQ all the time.</p>
<p>Take the task of finding the intersection of two lists:</p>
<p>Before ... | <p>The point is that LINQ integrates your queries into your primary programming language, allowing your IDE to provide you with some facilities (Intellisense and debug support, for example) that you otherwise would not have, and to allow the compiler to type-check your SQL code (which is impossible with a normal string... | 4,151 |
<p>I've heard that enabling Link-Time Code Generation (the /LTCG switch) can be a major optimization for large projects with lots of libraries to link together. My team is using it in the Release configuration of our solution, but the long compile-time is a real drag. One change to one file that no other file depends o... | <p>It is hard to say, because that depends mostly on your project - and of course the quality of the LTCG provided by VS2005 (which I don't have enough experience with to judge). In the end, you'll have to measure.</p>
<p>However, I wonder why you have that much problems with the extra duration of the release build. Y... | <p>I also don't see problems with extra compilation time using link-time code generation with the release build. I only build my release version once per day (overnight), and use the unit-test and debug builds during the day.</p>
| 36,753 |
<p>In this sentence:</p>
<pre><code>myCommand.ExecuteReader(CommandBehavior.CloseConnection)
</code></pre>
<p>does it close connection in case of exception?</p>
| <p>There are plenty of ways that the command can go wrong.</p>
<p>Ultimately it is the Close method of the data reader that will close the connection, provided nothing has gone wrong before.</p>
<p>If there is an exception that occurs inside ExecuteReader or any of its called methods, before the actual DataReader obj... | <p>It depends where the exception occurs!</p>
<p>If you structure your try catch correctly, it will be fine.</p>
<p>For example:</p>
<pre><code>SqlCommand myCommand = new SqlCommand();
try
{
myCommand.dostuff();
}
catch(Exception ex)
{
// display error message
}
finally
{
myCommand.ExecuteReader(CommandBehav... | 27,230 |
<p>I have the following in a page e.g. <code>/mypage?myvar=oldvalue</code></p>
<pre><code>$_SESSION['myvar'] = $_GET['myvar'];
$myvar = 'a_new_string'
</code></pre>
<p>Now <code>$_SESSION['myvar']</code> has the value <code>'a_new_string'</code></p>
<p>Is this by design?</p>
<p>How can I copy the <em>value</em> of ... | <p>register_globals is the invention of the devil. Fortunately in PHP 6.0 it will be entirely disabled. It wasn't just a huge security problem, it makes people confuse. Please turn it off in your php.ini using
register_globals = Off
More information: <a href="http://us2.php.net/register_globals" rel="nofollow noreferr... | <p>After running this:</p>
<pre><code><?php
session_start();
$_GET['myvar'] = '';
$_SESSION['myvar'] = $_GET['myvar'];
$myvar = 'a_new_string';
var_dump($_SESSION);
?>
</code></pre>
<p>on PHP 5.2.6 I get this:</p>
<pre><code>array(1) { ["myvar"]=> string(0) "" }
</code></pre>
| 38,732 |
<p>Is there a way in MySQL 5 to show only the current user's processes(queries)?</p>
<p>The user has the <code>PROCESS</code> privilege, therefore <code>SHOW PROCESSLIST</code> displays running processes of all users. According to the documentation, <code>SHOW PROCESSLIST</code> does not allow any kind of <code>WHERE<... | <p>If you use MySQL 5.1.7 or newer, you can use the <a href="http://dev.mysql.com/doc/refman/5.1/en/processlist-table.html" rel="noreferrer">PROCESSLIST</a> table in the INFORMATION_SCHEMA. So you can query it with ordinary <code>SELECT</code> queries and apply filtering conditions in a <code>WHERE</code> clause.</p>
... | <p>If the user does not have <code>PROCESS</code>, then <code>SHOW PROCESSLIST</code> will only show their own threads.</p>
| 43,338 |
<p>Guys, I’ve been writing code for 15+ years, but managed to avoid “Web Development” until 3 months ago.</p>
<p>I have inherited a legacy Asp.net application (started in .net 1.1, we’re now on .Net 2.0), it’s the administration tool for our product.</p>
<p>In several places the admin tool simply maintains long lists... | <p>This could be achieved using Anchor Tags.
When you output your elements on Page A, set an anchor tag next to each element like follows:</p>
<pre><code><a name="#175"></a>
</code></pre>
<p>Where this item would be item id 175.
Then when you redirect back to PageA, add a "#175" onto the end of the url</p... | <p>The simplest way you can do is to pass back an id from PageB in the querystring in the URL while redirecting back to PageA after saving in PageB.</p>
<p>e.g. www.example.com/PageA.aspx?editedId=89</p>
<p>and in PageLoad of PageA, you can check if this is from the editing detail page by examineing whether there is... | 27,830 |
<p>What is the simplest (shortest, fewest rules, and no warnings) way to parse both valid dates and numbers in the same grammar? My problem is that a lexer rule to match a valid month (1-12) will match any occurrence of 1-12. So if I just want to match a number, I need a parse rule like:</p>
<pre><code>number: (MONTH|... | <p>The problem is that you seem to want to perform both syntactical and semantical checking in your lexer and/or your parser. It's a common mistake, and something that is only possible in very simple languages.</p>
<p>What you really need to do is accept more broadly in the lexer and parser, and then perform semantic... | <p>Using ANTLR4, here is a simple combined grammar that I used. It makes use of the lexer to match simple tokens only, leaving the parser rules to interpret dates vs numbers. </p>
<pre><code>// parser rules
date
: INT SEPARATOR month SEPARATOR INT
| INT SEPARATOR month SEPARATOR INT4
| INT SEPARATOR INT ... | 17,150 |
<p><strong><em>Skunk Works Project</em></strong>: A project carried out by one part of a company without the knowledge of the remainder of the company.</p>
<p>Looking for stories about any skunk works projects you've worked on or initiated:</p>
<ul>
<li>Was it successful? </li>
<li>Were you found out? </li>
<li>Were ... | <p>Excellent question. Very important question.</p>
<p>Geoffrey Moore (Inside the Tornado, Crossing the Chasm, etc.) has written that, as he lectured around the world, he had one question he would ask every client (including those like GE, Motorola, etc.)</p>
<p>The question was:</p>
<p><strong>"Can you give me even... | <p>I did one of these. It's actually how I ended up programming. </p>
<p>I was responsible for maintaining a legacy, er... "database". I won't go into gory details but it was the usual evil application. The company pretty much ran on it, it would sometimes go down for days. At the time the IS director (a friend) was a... | 48,232 |
<p>What is the best way to setup your pool with respect to:-</p>
<ol>
<li>When do you create connections?</li>
<li>When do you close connections, and would you close all of them?</li>
<li>Do you test connections are still good. When and how?</li>
<li>How do you figure out a good number for the maximum number of conne... | <p>I wrote a connection pool for the database in Java when it was just a design pattern and not a common library. Now I use the one built into Tomcat.</p>
<p>I used a thread to monitor several aspects of the pool and several parameters to control its behavior...</p>
<ol>
<li>minimumInPool="3"... These first three ar... | <p>Why re-invent the wheel?</p>
<p>Someone has already probably solved the problem, and better.</p>
<p>If you're in the Java world, you can use <a href="http://commons.apache.org/dbcp/" rel="nofollow noreferrer">Commons DBCP</a>.</p>
| 34,098 |
<p>I have several identical elements with different attributes that I'm accessing with SimpleXML:</p>
<pre><code><data>
<seg id="A1"/>
<seg id="A5"/>
<seg id="A12"/>
<seg id="A29"/>
<seg id="A30"/>
</data>
</code></pre>
<p>I need to remove a specific <stro... | <p>While <a href="http://de.php.net/manual/en/book.simplexml.php" rel="noreferrer">SimpleXML</a> provides <a href="https://stackoverflow.com/a/16062633/367456">a way to remove</a> XML nodes, its modification capabilities are somewhat limited. One other solution is to resort to using the <a href="http://de.php.net/manua... | <p>Your initial approach was right, but you forgot one little thing about foreach. It doesn't work on the original array/object, but creates a copy of each element as it iterates, so you did unset the copy. Use reference like this:</p>
<pre><code>foreach($doc->seg as &$seg)
{
if($seg['id'] == 'A12')
{
... | 32,829 |
<p>The simple HTML below displays differently in Firefox and WebKit-based browsers (I checked in Safari, Chrome and iPhone).</p>
<p>In Firefox both border and text have the same color (<code>#880000</code>), but in Safari the text gets a bit lighter (as if it had some transparency applied to it).</p>
<p>Can I somehow f... | <pre><code>-webkit-text-fill-color: #880000;
opacity: 1; /* required on iOS */
</code></pre>
| <p>Can you use a button instead of an input?</p>
<pre><code><html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<style type="text/css">
button:disabled{
border:solid 1px #880000;
background-color:#ffffff;
color:#880000;
}
</sty... | 32,801 |
<p>I downloaded a VM image of a web application that uses MySQL.</p>
<p>How can I monitor its space consumption and know when additional space must be added?</p>
| <p>I have some great big queries to share:</p>
<p>Run this to get the Total MySQL Data and Index Usage By Storage Engine</p>
<pre><code>SELECT IFNULL(B.engine,'Total') "Storage Engine",
CONCAT(LPAD(REPLACE(FORMAT(B.DSize/POWER(1024,pw),3),',',''),17,' '),' ',
SUBSTR(' KMGTP',pw+1,1),'B') "Data Size"... | <p>For MyISAM tables, I usually check the size of the /var/lib/mysql/mydatabasename/ directory. InnoDB tables use monolithic files, so you have to use SHOW TABLE STATUS.</p>
| 22,315 |
<p>What could the following line possibly mean?</p>
<pre><code>my $x = shift;
</code></pre>
| <p><code>shift()</code> is a built in Perl subroutine that takes an array as an argument, then returns and deletes the first item in that array. It is common practice to obtain all parameters passed into a subroutine with <code>shift</code> calls. For example, say you have a subroutine <code>foo</code> that takes thr... | <p>Do you still have questions after reading the output of <code>perldoc -f shift</code>?</p>
<p>(That is not a question; it is an answer ;-))</p>
<p>Another recommended reading is <code>man perlbook</code>.</p>
<p>Perl "shifts off" the first element from <code>@_</code>, returning it.
So <code>$x</code> is a... | 37,979 |
<p>I need to have my installer include the .NET Framework 3.5 SP1 as well as SQL Compact 3.5. I remember seeing a place somewhere in the Visual Studio IDE where these could be included in the install, but I can't find them. Does anyone know how to do this? Thanks!</p>
| <p>Found it! It looks like you can go to the "Properties" window of the Installer project and click on the "Prerequisites" button to see a list of prerequisite installers to include in your installer like SQL Server, SQL Compact, .NET Framework versions, etc.</p>
<p>It appears that the list is driven off of things th... | <p>You might also want to register for redistribution rights:</p>
<p><a href="http://www.microsoft.com/sqlserver/2005/en/us/compact-redistribute.aspx" rel="nofollow noreferrer">http://www.microsoft.com/sqlserver/2005/en/us/compact-redistribute.aspx</a></p>
| 37,810 |
<p>I'd like to know how to convert this vb script to C#</p>
<pre><code>Dim strFolder As String
Dim objShell As Object
strFolder = "C:\zz"
Set objShell = CreateObject("Wscript.Shell")
objShell.Run "%COMSPEC% /c Echo Y| cacls " & _
strFolder & _
" /t /c /g everyone:F ", 2, Tr... | <p>It's not possible to upgrade unfortunately - I work for a big company, so would mean updating loads of people - which would be a mission...</p>
<p>But - creating a process worked!</p>
<pre><code>System.Diagnostics.Process meProc = System.Diagnostics.Process.Start ("cmd.exe", " /c echo y| cacls C:\\zzz /t /c /g eve... | <p>Is upgrading to a newer version not possible? .NET 2.0 introduced classes in the <a href="http://msdn.microsoft.com/en-us/library/system.security.accesscontrol.aspx" rel="nofollow noreferrer">System.Security.AccessControl</a> namespace to handle this. If it's really not possible and you only have this one command ... | 48,954 |
<p>I'm using Windows Vista and C#.net 3.5, but I had my friend run the program on XP and has the same problem.</p>
<p>So I have a C# program that I have running in the background with an icon in the SystemTray. I have a low level keyboard hook so when I press two keys (Ctr+windows in this case) it'll pull of the appl... | <p>Try this (where <code>this</code> is your form):</p>
<pre><code>this.Bounds = Screen.PrimaryScreen.Bounds;
this.TopMost = true;
</code></pre>
<p>That'll set the form to fullscreen, and it'll cover the taskbar.</p>
| <p>As far as I know, the taskbar is either above or below windows based on the "Keep the taskbar on top of other windows" setting. (At least, that's the wording in XP.) I suppose you could try to see if you can detect this setting and toggle it if needed?</p>
| 14,379 |
<p>I'm having a strange problem.</p>
<p>I have to use <code>GetPostBackEventRefence</code> to force a Postback, but it works the first time, after the first postback, the .NET function is not rendered... any ideas?</p>
<p>This is what I'm missing after the postback:</p>
<pre><code><script language="javascript" ty... | <p>The first thing I would look at is whether you have any asp controls (such as linkbutton, comboboxes,that don't normally generate a submit but requre a postback) being displayed on the page.
<strong>The __doPostback function will only be put into the page if ASP thinks that one of your controls requires it.</strong... | <p>Well, following that idea I created a dummy function with the postbackreference, and it works... it still is weird though, because of it rendering correctly the first time</p>
<pre><code>this.Page.RegisterClientScriptBlock("DUMMY", "<script language='javascript'>function dummy() { " + this.Page.GetPostBackEve... | 7,340 |
<p>How can I know what encoding will be used by PHP when sending data to the browser? I.e. with the Cotent-Type header, for instance: iso-8859-1.</p>
| <p>Usually Apache + PHP servers of webhosters are configured to send out <strong>NO <code>charset</code> header</strong>.
The shortest way to test how your server is configured are these:</p>
<ul>
<li>Use <a href="http://www.seoconsultants.com/tools/headers" rel="nofollow">this tool to see the server header</a> by get... | <p>You can set your own with <code>header('Content-type: xxx/yyy');</code>, but I believe that text/html is sent by default.</p>
| 15,848 |
<p>Anyone knows of a good tool for developing add-ins for Word in .net?
Hopefully something that supports both office 2003 and 2007.</p>
<p>Thanks.</p>
| <p>There are lots of options for development tools for Office. The most obvious one is of course Office itself. It has rich support for macros and VBA. You could also use SharePoint to extend document sharing and management functionality. But if your add-in is more complex than can be handled inside of Office, I sugg... | <p>Visual Studio 2008. VB.NET.</p>
| 13,623 |
<p>I'm a self-taught developer and my experience is all in small applications that I've developed.</p>
<p>I'm currently working on an application that I've made public, and I've realized that I need to start doing good unit testing to catch regressions and generally make sure everything works.</p>
<p>I've read up on ... | <p>You don't specify which <a href="http://msdn.microsoft.com/en-us/subscriptions/subscriptionschart.aspx" rel="noreferrer">flavor of VS2008</a> you are using. If it is Pro or above, then MSTest is bundled, but a lot of people have issues with it - it isn't always very intuitive, and it takes far too much setup to do s... | <p>If you interested in more than just normal unit-tests, then take a look at <a href="http://research.microsoft.com/Pex/" rel="nofollow noreferrer">PEX</a></p>
| 34,893 |
<p>Does anyone have examples of how to use <a href="http://www.oracle-base.com/articles/8i/DBMS_APPLICATION_INFO.php" rel="nofollow noreferrer">DBMS_APPLICATION_INFO</a> package with JBOSS? </p>
<p>We have a various applications which run within JBOSS and share db pools. I would like, at the start of each session thes... | <p>yes, you can write a wrapper class around your connection pool, and a wraper around the connection
so lets say you have:</p>
<pre>
OracleConnection conn=connectionPool.getConnection("java:scott@mydb");
</pre>
<p>Change it to:</p>
<pre>
public class LoggingConnectionPool extends ConnectionPool{
public OracleCo... | <p>In your <em>-ds.xml</em>, you can set a connection property called <strong>v$session.program</strong> and the value of that property will populate the <strong>PROGRAM</strong> column of each session in the <strong>V$SESSION</strong> view created for connections originating from your connection pool. I usually set it... | 7,680 |
<p>Does anybody knows how can I get the max and min value of the 2nd and 3rd columns in PHP?</p>
<pre><code>$ar = array(array(1, 10, 9.0, 'HELLO'),
array(1, 11, 12.9, 'HELLO'),
array(3, 12, 10.9, 'HELLO'));
</code></pre>
<p>Output should be like:</p>
<p>max(12.9)
min(10)</p>
| <pre><code><?php
$ar = array(array(1, 10, 9.0, 'HELLO'),
array(1, 11, 12.9, 'HELLO'),
array(3, 12, 10.9, 'HELLO'));
function col($tbl,$col){
$ret = array();
foreach ($tbl as $row){
$ret[count($ret)+1] = $row[$col];
}
return $ret;
}
print (max(col($ar,2))."... | <pre><code><?php
$ar = array(array(1, 10, 9.0, 'HELLO'),
array(1, 11, 12.9, 'HELLO'),
array(3, 12, 10.9, 'HELLO'));
function col($tbl,$col){
$ret = array();
foreach ($tbl as $row){
$ret[count($ret)+1] = $row[$col];
}
return $ret;
}
print (max(col($ar,2))."... | 31,351 |
<p>Our coding standards ask that we minimise the use of C# var (suggests limiting it's use to being in conjunction with Linq). However there are times when using generics where it's reasonably convenient e.g.</p>
<pre><code>Dictionary<DateTime, Dictionary<string, float>> allValues = ...
// ...
foreach (var... | <p>I've got ReSharper 4.1, and it does offer this option (in either direction).</p>
<p>Actually, I'd recommend challenging the standard... the former is far more readable than the latter (especially if you call the variable <code>pair</code> or something similar). I would't use "var" for <code>var i = 0</code>, but it... | <p>I'd argue that where you have complex generic types on your domain objects you should typedef them</p>
<pre>
class DomainValueCollection : KeyValue<DateTime, Dictionary<string, float>>{}
</pre>
<p>where DomainValueCollection is somehting that makes sense in your domain context</p>
<p>the code then becomes</... | 36,911 |
<p>Test the following code:</p>
<pre><code>#include <stdio.h>
#include <stdlib.h>
main()
{
const char *yytext="0";
const float f=(float)atof(yytext);
size_t t = *((size_t*)&f);
printf("t should be 0 but is %d\n", t);
}
</code></pre>
<p>Compile it with:</p>
<pre><code>gcc -O3 test.c
</... | <p>Use the compiler flag -fno-strict-aliasing.</p>
<p>With strict aliasing enabled, as it is by default for at least -O3, in the line:</p>
<pre><code>size_t t = *((size_t*)&f);
</code></pre>
<p>the compiler assumes that the size_t* does NOT point to the same memory area as the float*. As far as I know, this is s... | <p>-O3 is not deemed "sane", -O2 is generally the upper threshold except maybe for some multimedia apps. </p>
<p>Some apps can't even go that far, and die if you go beyond -O1 . </p>
<p>If you have a new enough GCC ( I'm on 4.3 here ), it may support this command </p>
<pre><code> gcc -c -Q -O3 --help=optimizers >... | 10,949 |
<p>How can I convert an <code>Int64</code> to an <code>Int32</code> type in F# without using the <code>Microsoft.FSharp.Compatibility.Int32.of_int64</code>?</p>
<p>I'm doing this because interactive doesn't seem to work when I try:</p>
<pre><code>open Microsoft.FSharp.Compatibility
</code></pre>
<p>With <code>FSharp... | <p>F# 1.9.6 has a type conversion function so you can do this: </p>
<pre><code>let num = 1000
let num64 = int64(num)
</code></pre>
| <p>Note that the functions for converting to each integer type have the same names as the types themselves, and are defined in the library spec (see below). (With the release of the CTP (1.9.6.2), a lot of the library and the namespaces changed a bit compared to previous releases, but it will probably be more 'stable'... | 29,193 |
<p>I'm creating a UI that allows the user the select a date range, and tick or un-tick the days of the week that apply within the date range.</p>
<p>The date range controls are <code>DateTimePickers</code>, and the Days of the Week are <code>CheckBoxes</code></p>
<p>Here's a mock-up of the UI:</p>
<p><code>From Date... | <p>Here's how I would approach it:</p>
<ul>
<li>Find day of week (dow) of first and last date</li>
<li>Move first day forward to same dow as last. Store number of days moved that are to be included</li>
<li>Calculate number of weeks between first and last</li>
<li>Calculate number of included days in a week * number ... | <p>Looping through wouldn't be your only option - you could perform <a href="http://msdn.microsoft.com/en-us/library/8ysw4sby.aspx" rel="nofollow noreferrer">subtraction</a> to figure out the total number of days, and subtract one for each of your "skipped" dates every week range in between that contains one of those d... | 16,071 |
<p>We are designing a Payroll Generation System for a client.</p>
<p>The organization we are targeting has a hierarchy as follows:
Company -> Cluster -> Business Unit (BU) -> Department -> Employee</p>
<p>The salary for an employee is made up of various salary components.
Each salary component has 3 rules associated ... | <p>My only suggestion after looking at that is to check out the strategy pattern from the GoF design patterns book. You'd probably want the strategies done in a scripting language rather than your main compiled language though as then you will find editing them easier.</p>
| <p>Maybe you want to check <a href="http://www.amazon.ca/Agile-Principles-Patterns-Practices-C/dp/0131857258/ref=sr_1_29?ie=UTF8&s=books&qid=1224166307&sr=1-29" rel="nofollow noreferrer">Agile Principles, Patterns, and Practices in C# </a> The core example in the book is designing a payroll system the agile... | 25,607 |
<p>I have a volunteers_2009 table that lists all the volunteers and a venues table that lists the venues that a volunteer can be assigned to, they are only assigned to one.</p>
<p>What I want to do, is print out the number of volunteers assigned to each venue.</p>
<p>I want it to print out like this:</p>
<p>Name of ... | <p>Not a MySQL person so this may be really wrong, but when you give your table an alias, don't you then need to refer to it by that name.</p>
<pre><code>$sql = "SELECT ven.venue_name as 'Venue', COUNT(vol.id) as 'Number Of
Volunteers' FROM venues ven JOIN volunteers_2009 vol ON
(ven.id=vol.venue_id) GROUP BY ven.ve... | <pre><code>$query = "SELECT ven.venue_name AS 'Venue', count(*) AS 'Number of venues'
FROM volunteers_2009 AS vol, venues AS ven WHERE vol.venue_id = ven.id
GROUP BY ven.venue_name";
</code></pre>
| 28,732 |
<p>I would like to do something like add a nice-to-Excel-functions <code>Name</code> property to the <code>WorkBook</code> class. Is there a good way to do this?</p>
<p>More detailed problem: In VBA you can assign a formula to a range in an Excel worksheet. I want to do so, and I want my formula to refer to a second w... | <p>You don't need to make a separate class to extend the workbook class. You can add properties to the existing ThisWorkbook class module, like this:</p>
<pre><code>Public Property Get FunName() As String
FunName = Replace(Me.Name, "'", "''")
End Property
</code></pre>
<p>Then you call <code>ThisWorkbook.FunNa... | <p>Just do a replace to double up the single quotes</p>
<pre><code>WorksheetName = Replace(WB.Name, "'", "''")
</code></pre>
| 36,173 |
<p>I'm a long-time Windows developer, having cut my teeth on win32 and early COM. I've been working with .NET since 2001, so I'm pretty fluent in C# and the CLR. I'd never heard of Castle Windsor until I started participating in Stack Overflow. I've read the Castle Windsor "Getting Started" guide, but it's not click... | <p>Castle Windsor is an inversion of control tool. There are others like it.</p>
<p>It can give you objects with pre-built and pre-wired dependencies right in there. <strong>An entire object graph created via reflection and configuration rather than the "new" operator.</strong></p>
<p>Start here: <a href="h... | <p>Put simply. Imagine you have some class buried in your code that needs a few simple config values to do its job. That means everything that creates an instance of that class needs to get those dependencies, so you usually end up having to refactor loads of classes along the way to just pass a bit of config down to w... | 15,183 |
<p>My question is based off of inheriting a great deal of legacy code that I can't do very much about. Basically, I have a device that will produce a block of data. A library which will call the device to create that block of data, for some reason I don't entirely understand and cannot change even if I wanted to, wri... | <p>Your consumer must specify FileShare.ReadWrite.</p>
<p>By trying to open the file as FileShare.Read in the consumer you are saying "I want to open the file and let others read it at the same time" ... since there is <strong>already</strong> a writer that call fails, you have to allow concurrent writes with the read... | <p>I haven't had time to test this but I think you may need to call the Flush method of the BinaryWriter</p>
<pre><code>FileStream theFS = new FileStream(this.ScannerRawFileName,
FileMode.OpenOrCreate, FileAccess.Write, FileShare.Read);
//note that I need to be able to read this elsewhere...
BinaryWriter theBinaryW... | 15,189 |
<p>Is there a way to disable the drag&drop functionality for Solution Explorer?
Why would you ask? I'm using an wacom pen tablet for quite some years and I love
it. But when you use it in solution explorer in combination with a source control
like TFS or AnkhSvn it's a disaster when you accidentally move a file in... | <p>There is a plugin to Visual Studio 2010 that will prompt you drag & drop files in Solution Explorer: <a href="http://visualstudiogallery.msdn.microsoft.com/en-us/d491911d-97f3-4cf6-87b0-6a2882120acf" rel="noreferrer">http://visualstudiogallery.msdn.microsoft.com/en-us/d491911d-97f3-4cf6-87b0-6a2882120acf</a></p>... | <p>I looks like they have finally attempted to enable this functionality in 2017 Community (15.7.5)</p>
<p>Tools -> Options -> Projects and Solutions -> General -> "Prompt before moving files to a new location"</p>
<p>I say attempted because I have still had occasions where this setting hasn't displayed the dialog bo... | 43,635 |
<p>When I dynamically create a Datagrid and add in a new buttoncolumn how do I access the buttoncolumn_click event? </p>
<p>Thanks.</p>
| <pre><code>protected void Page_Load(object sender, EventArgs e)
{
DataGrid dg = new DataGrid();
dg.GridLines = GridLines.Both;
dg.Columns.Add(new ButtonColumn {
CommandName = "add",
HeaderText = "Event Details",
Text = "Details",
ButtonType = ButtonColumnType.PushButton
});
dg.DataSource = ... | <p>This article on the MSDN site clearly explains how to go about <a href="http://msdn.microsoft.com/en-us/library/aa984252(VS.71).aspx" rel="nofollow noreferrer">adding a button into a datagrid</a>. Instead of using the click event of the button you'll use the command event of the DataGrid. Each button will be passing... | 18,052 |
<p>In my spring application context file, I have something like:</p>
<pre><code><util:map id="someMap" map-class="java.util.HashMap" key-type="java.lang.String" value-type="java.lang.String">
<entry key="some_key" value="some value" />
<... | <p>Well, first of all, you're wasting memory with the new <code>HashMap</code> creation call. Your second line completely disregards the reference to this created hashmap, making it then available to the garbage collector. So, don't do that, use:</p>
<pre><code>private Map<String, String> someMap = (HashMap<S... | <p>Another solution, if you find yourself casting the same object a lot and you don't want to litter your code with <code>@SupressWarnings("unchecked")</code>, would be to create a method with the annotation. This way you're centralizing the cast, and hopefully reducing the possibility for error.</p>
<pre><code>@Suppr... | 32,834 |
<p>I'd like some sorthand for this:</p>
<pre><code>Map rowToMap(row) {
def rowMap = [:];
row.columns.each{ rowMap[it.name] = it.val }
return rowMap;
}
</code></pre>
<p>given the way the GDK stuff is, I'd expect to be able to do something like:</p>
<pre><code>Map rowToMap(row) {
row.columns.collectMap... | <p>I've recently came across the need to do exactly that: converting a list into a map. This question was posted before Groovy version 1.7.9 came out, so the method <a href="http://docs.groovy-lang.org/latest/html/api/org/codehaus/groovy/runtime/DefaultGroovyMethods.html#collectEntries(java.lang.Iterable,%20groovy.lang... | <p>What about something like this?</p>
<pre><code>// setup
class Pair {
String k;
String v;
public Pair(def k, def v) { this.k = k ; this.v = v; }
}
def list = [ new Pair('a', 'b'), new Pair('c', 'd') ]
// the idea
def map = [:]
list.each{ it -> map.putAt(it.k, it.v) }
// verify
println map['c']
</... | 3,910 |
<p>We encountered a problem with using Subversion on Windows. A developer committed a file <code>foo.Data.sql</code> and later another developer committed a file called <code>foo.data.sql</code>. Naturally, this caused a problem on Windows clients (all clients are Windows in our environments) because files are case sen... | <p>There is definitely a hook script that checks case sensitivity - Sourceforge have it as one of their options. A quick google turns up: <a href="http://www.subversionary.org/howto/using-check-case-insensitive-py-on-windows" rel="nofollow noreferrer">http://www.subversionary.org/howto/using-check-case-insensitive-py-o... | <p>1; It is possible, because the two files came from two developers. One is renaming or creating the file with different cases and during commit does not realise that it will be an add not a commit changes.</p>
<p>2; Check <a href="http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-dug-rename.html#tsvn-dug-renam... | 7,989 |
<p>We have a large database on which we have DB side pagination. This is quick, returning a page of 50 rows from millions of records in a small fraction of a second.</p>
<p>Users can define their own sort, basically choosing what column to sort by. Columns are dynamic - some have numeric values, some dates and some t... | <p>Most of the SQL-based solutions I have seen break when the data gets complex enough (e.g. more than one or two numbers in it). Initially I tried implementing a NaturalSort function in T-SQL that met my requirements (among other things, handles an arbitrary number of numbers within the string), but the performance wa... | <p>I still don't understand (probably because of my poor English).</p>
<p>You could try:</p>
<pre><code>ROW_NUMBER() OVER (ORDER BY dbo.human_sort(field_name) ASC)
</code></pre>
<p>But it won't work for millions of records.</p>
<p>That why I suggested to use trigger which <em>fills</em> <em>separate</em> column wit... | 5,477 |
<p>Is it possible to have a WPF window/element detect the drag'n'dropping of a file from windows explorer in C# .Net 3.5? I've found solutions for WinForms, but none for WPF.</p>
| <p>Unfortunately, TextBox, RichTextBox, and FlowDocument viewers always mark drag-and-drop events as handled, which prevents them from bubbling up to your handlers. You can restore drag-and-drop events being intercepted by these controls by force-handling the drag-and-drop events (use UIElement.AddHandler and set handl... | <p>I had similar Issue, The drop events and drag enter events were not fired. The issue was with the windows User Account Settings. Set it to least secure setting and try the same code it works. </p>
| 43,140 |
<p>I have a solution consisting of five projects, each of which compile to separate assemblies. Right now I'm code-signing them, but I'm pretty sure I'm doing it wrong. What's the best practice here?</p>
<ul>
<li>Sign each with a different key; make sure the passwords are different</li>
<li>Sign each with a different ... | <p>If your only objective is to stop FxCop from yelling at you, then you have found the best practice.</p>
<p>The best practice for signing your assemblies is something that is completely dependent on your objectives and needs. We would need more information like your intended deployment:</p>
<ul>
<li>For personal u... | <p>Signing is used to uniquely identify an assembly. More details are in <em><a href="http://msdn.microsoft.com/en-us/library/ms247123%28VS.80%29.aspx" rel="nofollow noreferrer">How to: Sign an Assembly (Visual Studio)</a></em>.</p>
<p>In terms of best practice, it's fine to use the same key as long as the assemblies ... | 5,585 |
<p>The Eclipse projects are all stored in the Eclipse Foundation CVS servers. Using the source is a great way to debug your code and to figure out how to do new things. </p>
<p>Unfortunately in a large software project like BIRT, it can be difficult to know which projects and versions are required for a particular ... | <p>Use <a href="https://docs.python.org/3/library/itertools.html#itertools.permutations" rel="noreferrer"><code>itertools.permutations</code></a> from the <strong>standard library</strong>:</p>
<pre><code>import itertools
list(itertools.permutations([1, 2, 3]))
</code></pre>
<hr />
<p>Adapted from <a href="http://code.... | <p>for Python we can use itertools and import both permutations and combinations to solve your problem</p>
<pre><code>from itertools import product, permutations
A = ([1,2,3])
print (list(permutations(sorted(A),2)))
</code></pre>
| 13,002 |
<p>Say you want a simple maze on an N by M grid, with one path through, and a good number of dead ends, but that looks "right" (i.e. like someone made it by hand without too many little tiny dead ends and all that). Is there a known way to do this?</p>
| <p>From <a href="http://www.astrolog.org/labyrnth/algrithm.htm" rel="noreferrer">http://www.astrolog.org/labyrnth/algrithm.htm</a></p>
<blockquote>
<p>Recursive backtracker: This is somewhat related to the recursive backtracker solving method described below, and requires stack up to the size of the Maze. When carvi... | <p>Here's the DFS algorithm written as pseudocode: </p>
<p>create a CellStack (LIFO) to hold a list of cell locations<br>
set TotalCells = number of cells in grid<br>
choose a cell at random and call it CurrentCell<br>
set VisitedCells = 1 </p>
<p>while VisitedCells < TotalCells
find all neighbors of CurrentCell... | 5,940 |
<p>Why is the following?:</p>
<pre><code> const int i0 = 5;
//int i1 = const_cast<int>(i0); // compilation error
int i2 = (int)i0; // okay
int i3 = 5;
//const int i4 = const_cast<const int>(i3); // compilation error
const int i5 = (const int)i3; ... | <pre><code> const int i0 = 5;
//int i1 = const_cast<int>(i0); // compilation error
int i2 = (int)i0; // okay
int i3 = 5;
//const int i4 = const_cast<const int>(i3); // compilation error
const int i5 = (const int)i3; // okay
</code></pre>
<p>The ... | <p>For the first error. const_cast can only be used on pointer or reference types. "int" is neither. This may or may not be the C++ standard (couldn't find a good reference). But it is the case for certain implementations such as MS's C++ compiler.</p>
<p>For the second error. const_cast can only be used to remov... | 48,414 |
<p>I have a strange bug with WPF Interop and an Excel Addin. I'm using .Net 3.5 SP1.</p>
<p>I'm using Add-in Express to create a Custom Task Pane for Excel 2003. Within that taskpane I'm using ElementHost to host a WPF UserControl. The UserControl simply contains a Grid with a TextBox and ComboBox. My problem is that ... | <p>Add-in Express looked into this for me, and it turns out to have something to do with the Window style of the Task Pane that gets added to Excel. If you turn off the WS_CHILD flag in the Windows CreateParams then Combo Boxes and other popups work as expected. </p>
<p>They gave me this snippet of code to add to my A... | <p>I had the same problem. I have a WPF user control hosted in a WinForm user control and the whole is an Excel AddIn. I work with Visual Studio 2010 and Excel 2007 and Excel 2010.</p>
<p>My problem was that when I clicked once in the Excel sheet, the AddIn never gains focus again.
I found a workaround. </p>
<ol>
<li... | 22,123 |
<p>I've been handing a design for a webpage which I'm trying to implement correctly. This design contains navigation elements which are partially or entirely duplicated all over the page - in particular, links to the main 3 categories for navigation are present on the page no less than 4 times.</p>
<p>I'm no web desi... | <h2>Sort of Possible, But Still Not Sure You Would Want To</h2>
<p><strong>And poses some serious challenges which varies depending on the context.</strong></p>
<p>One problem is that your stated goal is to reduce html clutter and redundancy. However, to have a link, you still need to have an anchor element (<code>&l... | <p>I think you will use HTML includes and SSI or server side includes to incorporate same methods on same pages,
this is the format for the which you will use.
<code><!--#include virtual="path to file/include-file.html" --></code>, always include that file in every pages that is similar..
just go to this link..<a... | 45,453 |
<p>I am facing a performance issue on a multi-core (8+) architecture with software written in C++ / VistualStudio / WindowsXP.</p>
<p>Suddenly I realized that I have no idea of the performances of my L1 and L2 cache and CPU->to->Memory bandwidth.</p>
<p>I have tested several tools (including VTune, Glowcode, etc, etc... | <pre><code>set WshShell = WScript.CreateObject("WScript.Shell")
WScript.Sleep(100)
WshShell.Run "%SystemRoot%\system32\sndrec32.exe"
WScript.Sleep(100)
WshShell.AppActivate "Sound - Sound Recorder"
WScript.Sleep(100)
WshShell.SendKeys " "
WScript.Sleep(100)
</code></pre>
<p>Save the above text as RunSoundRecorder.... | <p>Start-Programs-Accessories-System Tools-Scheduled Tasks</p>
| 20,045 |
<p>Let's say the first N integers divisible by 3 starting with 9.</p>
<p>I'm sure there is some one line solution using lambdas, I just don't know it that area of the language well enough yet.</p>
| <p>Just to be different (and to avoid using a where statement) you could also do:</p>
<pre><code>var numbers = Enumerable.Range(0, n).Select(i => i * 3 + 9);
</code></pre>
<p><strong>Update</strong> This also has the benefit of not running out of numbers.</p>
| <p>I can't say this is any good, I'm not a C# expert and I just whacked it out, but I think it's probably a canonical example of the use of <code>yield</code>.</p>
<pre><code>internal IEnumerable Answer(N)
{
int n=0;
int i=9;
while (true)
{
if (i % 3 == 0)
{
n++;
yield return i;
}
... | 9,302 |
<p>I am running a query from ASP using a MySQL database, I want to create a variable (ssResult) based on the result with a person's name (fullname), if the record does not exist I want to assign the text 'N/A' to the variable, code below, I currently use a function getOther for my database connections which passes the ... | <p>You could try changing the line</p>
<pre><code>if not rstemp.eof then
</code></pre>
<p>with</p>
<pre><code>if rstemp.RecordCount > 0 then
</code></pre>
| <p>Why not change the SQL to only pull out a result with a First Name, that way the "N/A" would apply:</p>
<pre>sResult = getOtherElse("SELECT fullname FROM table WHERE id=" & inArr(j), "fullname AND fullname<>''")</pre>
| 41,003 |
<p>I'd like to allow a user to open files in their own client applications via Silverlight. I'd like this to work similarly to WebDAV, in the sense that they could read/write the file back into Silverlight's isolated storage...</p>
<p>Is it possible to construct a file:// link to an isolated storage file?
Is there a u... | <p>You can use Windows server to create users that are allowed to access your SQL Server database. Then you can use integrated windows login in connection strings. </p>
<p>BTW Storing passwords in public MDB renders them irelevant. Same as they don't exist. </p>
| <p>Is it not possible to move to Window Integrated Security in the connection strings, then you do not have to worry about the security aspect as much (unless you need to secure the actual location of the connection I guess). </p>
| 41,034 |
<p>Other than using raw XML, is there an easy way in .NET to open and read a config file belonging to another assembly...? I don't need to write to it, just grab a couple of values from it.</p>
| <p><a href="http://msdn.microsoft.com/en-us/library/ms224437.aspx" rel="nofollow noreferrer">Here's</a> MSDN on OpenExeConfiguration.</p>
<p>Edit: <a href="http://www.eggheadcafe.com/software/aspnet/32181042/using-configurationmanage.aspx" rel="nofollow noreferrer">link</a> to a how-to on eggheadcafe.com disappeared. ... | <p>Or perhaps you could Serialize a simple class with the [Serializable()] attribute to a file... and deserialize in the other app...</p>
<p><a href="http://www.dotnetperls.com/serialize-list" rel="nofollow">http://www.dotnetperls.com/serialize-list</a><br />
<a href="http://msdn.microsoft.com/en-us/library/system.ser... | 29,664 |
<p>I am implementing a quite simple state-machine order processing application. It is a e-commerce application with a few twists. The users of the application will not be editing workflows by themselves.</p>
<p>Microsoft claims that asp.net and Windows Workflow is possible to combine. How hard is it to install and mai... | <p>Asp.net and WF get along just fine, and WF doesn't add much maintenance overhead.</p>
<p>Whether or not this is the right design for you depends a lot on your needs. If you have a lot of event driven actions then WF might be worthwhile, otherwise the overhead of rolling your own tracking would probably add less com... | <p>If your state machine is very simple, then I would say that you should just roll your own. You have more control over everything. You can deal with persistence on your own terms and not worry about how they do it.</p>
<p>WF does look pretty cool though, but I think that it's power probably lies in the fact that i... | 9,269 |
<p>I got this error when trying to run a query in SQL server query analyzer.
What is the reason?</p>
| <p>If you're using cursors, then you've probably closed the cursor. Check out MSDN for more information (<a href="http://support.microsoft.com/kb/15169" rel="nofollow noreferrer">http://support.microsoft.com/kb/15169</a>3)</p>
<p>If you're not using cursors, then it could be an issue with the server, check the log.</p... | <p>And before it's lost to the sands of time, the KB article:</p>
<hr />
<p>Article ID: 151693 - Last Review: October 3, 2003 - Revision: 3.0</p>
<h1><a href="https://web.archive.org/web/20091123103812/http://support.microsoft.com/kb/151693" rel="nofollow noreferrer">FIX: Err Msg "Unknown Token Received from SQL S... | 27,392 |
<p>Suppose I have this code:</p>
<pre><code>var myArray = new Object();
myArray["firstname"] = "Bob";
myArray["lastname"] = "Smith";
myArray["age"] = 25;
</code></pre>
<p>Now if I wanted to remove "lastname"?....is there some equivalent of
<code>myArray["... | <p>Objects in JavaScript can be thought of as associative arrays, mapping keys (properties) to values.</p>
<p>To remove a property from an object in JavaScript you use the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/delete" rel="noreferrer"><code>delete</code></a> operator:</p>... | <pre><code>var myArray = newmyArray = new Object();
myArray["firstname"] = "Bob";
myArray["lastname"] = "Smith";
myArray["age"] = 25;
var s = JSON.stringify(myArray);
s.replace(/"lastname[^,}]+,/g, '');
newmyArray = JSON.parse(p);
</code></pre>
<p>Without looping... | 45,025 |
<p>I need to check whether the user executing the script has administrative privileges on the machine.</p>
<p>I have specified the user executing the script because the script could have been executed with a user other than the logged on using something similar to "Runas".</p>
<p>@Javier: Both solutions work in a PC ... | <p>You can use script if you want to see if the logged on user is an administrator</p>
<pre><code>Set objNetwork = CreateObject("Wscript.Network")
strComputer = objNetwork.ComputerName
strUser = objNetwork.UserName
isAdministrator = false
Set objGroup = GetObject("WinNT://" & strComputer & "/Administrators")... | <pre><code>Function isAdmin
Dim shell
Set shell = CreateObject("WScript.Shell")
isAdmin = false
errorLevel = shell.Run("%comspec% /c net session >nul 2>&1", 0, True)
if errorLevel = 0
isAdmin = true
End If
End Function
</code></pre>
| 38,744 |
<p>I'm building an HTML UI with some text elements, such as tab names, which look bad when selected. Unfortunately, it's very easy for a user to double-click a tab name, which selects it by default in many browsers.</p>
<p>I might be able to solve this with a JavaScript trick (I'd like to see those answers, too) -- bu... | <p>In most browsers, this can be achieved using CSS:</p>
<pre class="lang-css prettyprint-override"><code>*.unselectable {
-moz-user-select: -moz-none;
-khtml-user-select: none;
-webkit-user-select: none;
/*
Introduced in IE 10.
See http://ie.microsoft.com/testdrive/HTML5/msUserSelect/
*/
... | <p>The following works in Firefox interestingly enough if I remove the write line it doesn't work.
Anyone have any insight why the write line is needed.</p>
<pre><code><script type="text/javascript">
document.write(".");
document.body.style.MozUserSelect='none';
</script>
</code></pre>
| 9,480 |
<p>I have an Ender 3 with a removeable build surface. The build surface backing has become warped - the center is at least 0.3 mm higher than the corners. I'm not sure what the material of this plate is - it's the part behind the BuildTak-clone surface that sits on the aluminum heat bed and is clipped to it. This makes... | <p>I measured mine with a thread gauge and it says the pitch is <strong>0.7 mm</strong>.</p>
<p>So, as the stock adjustment wheels have 14 bumps around their circumference, turning by one of those is an adjustment of exactly 0.05 mm (assuming no backlash).</p>
<p>I can't speak for anyone else's, but due to the availabi... | <p>I don't know what the value is, but there are a few ways to find out. It is very hard to measure this with a caliper, but it can be done, mark the upper and bottom of e.g. 10 windings and measure this with a caliper. Alternatively measure how much the screw drops after 10 full turns. </p>
<p>There are special tools... | 1,571 |
<p>For my program, I'm attempting to replace the value of a specific hash in an external file with a newly created value. The external file has the value tab-delimited from the key, and I had read the hash in from the external file. I've been looking around online, and this is the closest way I could figure out how to ... | <p><a href="http://search.cpan.org/perldoc?Tie::File" rel="nofollow noreferrer">Tie::File</a> can fix this for you.</p>
<pre><code>use Tie::File;
tie @array, 'Tie::File', $file or die "Could not tie $file: $!";
for (@array) {
s/$hash{$key}/$newvalue/;
}
untie @array;
</code></pre>
| <p>You are trying to read and write to the same file, that is not going to work. You have to read, substitute then write in another file. Afterwards, you can replace the input file by the one you've just written if you really want one file.</p>
| 49,715 |
<p>When adding a bookmark or favorite the browser uses the TITLE tag of the page to automatically populate the title of the bookmark. However, my web pages use SEO-friendly titles which are not really user-friendly. Is there a method to override the title when the browser makes a bookmark?</p>
<p>I am aware that I can... | <p>I can't see how that would be possible. The browser takes the Title loaded, which is the Title displayed on the top of the page. When saving a bookmark, it doesnt go through the code. It just adds the URL and takes the site Title.</p>
<p>You could check if the "bookmark"-pressing triggers a javascript event, though... | <p>You're trying to solve the wrong problem.</p>
<blockquote>
<p>However, my web pages use SEO-friendly titles which are not really user-friendly</p>
</blockquote>
<p>This is what you need to fix. Your page titles should be user friendly.</p>
<p>To be honest, if you're doing it right SEO and User friendly titles s... | 43,818 |
<p>I have a lot of XML files which have something of the form:</p>
<pre><code><Element fruit="apple" animal="cat" />
</code></pre>
<p>Which I want to be removed from the file.</p>
<p>Using an XSLT stylesheet and the Linux command-line utility xsltproc, how could I do this?</p>
<p>By this point in the script I... | <p>Using one of the most fundamental XSLT design patterns: "Overriding the <a href="https://www.w3.org/TR/1999/REC-xslt-19991116#copying" rel="noreferrer"><strong>identity transformation</strong></a>" one will just write the following:</p>
<pre>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/T... | <p>The answer by <a href="https://stackoverflow.com/users/36305/dimitre-novatchev">@Dimitre Novatchev</a> is certainly both correct and elegant, but there's a generalization (that the OP didn't ask about): what if the element you want to filter also has child elements or text that you want to <em>keep</em>? </p>
<p>I ... | 41,661 |
<p>I have an <code>NSArray</code> and I'd like to create a new <code>NSArray</code> with objects from the original array that meet certain criteria. The criteria is decided by a function that returns a <code>BOOL</code>.</p>
<p>I can create an <code>NSMutableArray</code>, iterate through the source array and copy over... | <p><code>NSArray</code> and <code>NSMutableArray</code> provide methods to filter array contents. <code>NSArray</code> provides <strong>filteredArrayUsingPredicate:</strong> which returns a new array containing objects in the receiver that match the specified predicate. <code>NSMutableArray</code> adds <strong>filterUs... | <p>Checkout this library</p>
<p><a href="https://github.com/BadChoice/Collection" rel="nofollow">https://github.com/BadChoice/Collection</a></p>
<p>It comes with lots of easy array functions to never write a loop again</p>
<p>So you can just do:</p>
<pre><code>NSArray* youngHeroes = [self.heroes filter:^BOOL(Hero *... | 13,557 |
<p>I'm told that the template system in C++ is Turing-complete at compile time. This is mentioned in <a href="https://stackoverflow.com/questions/75538/hidden-features-of-c#75627">this post</a> and also on <a href="http://en.wikipedia.org/wiki/C%2B%2B" rel="noreferrer">wikipedia</a>.</p>
<p>Can you provide a nontrivia... | <p>Example</p>
<pre><code>#include <iostream>
template <int N> struct Factorial
{
enum { val = Factorial<N-1>::val * N };
};
template<>
struct Factorial<0>
{
enum { val = 1 };
};
int main()
{
// Note this value is generated at compile time.
// Also note that most compil... | <p>A <a href="http://en.wikipedia.org/wiki/Turing_machine" rel="nofollow noreferrer">Turing machine</a> is Turing-complete, but that doesn't mean you should want to use one for production code.</p>
<p>Trying to do anything non-trivial with templates is in my experience messy, ugly and pointless. You have no way to "de... | 22,941 |
<p>This seems like the most basic question in the world, but damned if I can find an answer.</p>
<p>Is there a keyboard shortcut, either native to Visual Studio or through Code Rush or other third-party plug-in, to wrap the current selection with an HTML tag? I'm tired of typing the opening tag, cutting the misplaced ... | <p>Visual Studio 2015 comes with a new shortcut, Shift+Alt+W, that wraps the current selection with a div. This shortcut leaves the text "div" selected, making it seamlessly changeable to any desired tag. This coupled with the automatic end tag replacement makes for a quick solution.</p>
<h3>UPDATE</h3>
<p>Th... | <p>I know this is an old question but I was just struggling with the same thing. You can install the Emmet Keybindings extension by Andrés Gutiérrez. Once installed you can highlight text then use control + MW to wrap with any tag you'd like. To give each line an opening and closing tag include an * after the tag.</... | 23,253 |
<p>When I create a New Project of type ASP.Net MVC Web Application, I expect the dialog for unit test applications to show up, but it does not. I cannot find the Unit Test App among the product types I can create either. How do I set up my VS so that the dialog shows up?</p>
<p>I have installed Visual Studio 2008, .Ne... | <p>As @MrJavaGuy says, you need to install at least the Professional, not Express, version of VS2008. Alternatively, you can install nUnit and/or TestDriven.Net and get unit testing capabilities. Info on nUnit can be found at <a href="http://www.nunit.org/index.php" rel="nofollow noreferrer">http://www.nunit.org/</a>... | <p>Had the same problem with Visual Web Developer Express, I found this blog.</p>
<p><a href="http://blogs.msdn.com/webdevtools/archive/2008/05/30/asp-net-mvc-preview-3-tooling-updates.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/webdevtools/archive/2008/05/30/asp-net-mvc-preview-3-tooling-updates.aspx</a></p... | 37,543 |
<p>How would one create an iterative function (or iterator object) in python?</p>
| <p>Iterator objects in python conform to the iterator protocol, which basically means they provide two methods: <code>__iter__()</code> and <code>__next__()</code>. </p>
<ul>
<li><p>The <code>__iter__</code> returns the iterator object and is implicitly called
at the start of loops.</p></li>
<li><p>The <code>__next... | <blockquote>
<pre class="lang-py prettyprint-override"><code>class uc_iter():
def __init__(self):
self.value = 0
def __iter__(self):
return self
def __next__(self):
next_value = self.value
self.value += 2
return next_value
</code></pre>
</blockquote>
<p>Improving prev... | 3,964 |
<p>I'm a .Net developer and want to get into developing Silverlight applications. I have VS 2008 but wanted to know if I should/need expression blend. What are pros/cons of having blend along side VS? </p>
| <p>I don't mean to push my own questions, but this might help you a little, especially if you are not familiar with Expression Studio or Expression Blend: "<a href="https://stackoverflow.com/questions/28826/what-exactly-is-microsoft-expression-studio-and-how-does-it-integrate-with-visu">What exactly is Microsoft Expres... | <p>Blend is very useful for designing, and its new feature of control visual states editing it can be very useful. However, the XAML it generates might be more difficult to maintain than custom written one.</p>
<p>Personally, I use blend whenever I need to generate a certain visual effect, and then copy the XAML into ... | 14,873 |
<p>I am looking for the highest key value (a defined by the comparison operator) of a std::map.</p>
<p>Is this guaranteed to be </p>
<pre><code>map.rbegin()->first
</code></pre>
<p>? </p>
<p>(I am a bit shaky on reverse iterators, and how much freedom there is in the implementation of std::map) </p>
<p>If not, ... | <p>Yes. Map is a sorted container, the reverse iterator must return the elements in reverse (i.e. decreasing) order of their keys.</p>
<p>[Edit: as Charles Bailey points out in his answer, your code gives the greatest key <strong>if it exists</strong> - i.e. if the map is non-empty]</p>
| <p>Map store the key value pairs in sorted order so we can access the last element by :-</p>
<pre><code>auto it=m.end();
it--;
int element=it->first;
</code></pre>
| 36,903 |
<p>I wonder if someone knows if there is a pre-made solution for this: I have a List on an ASP.net Website, and I want that the User is able to re-sort the list through Drag and Drop. Additionally, I would love to have a second list to which the user can drag items from the first list onto.</p>
<p>So far, I found two ... | <p>The Mootools sortables plugin does just that, and best of all, it's free ;)</p>
<p><a href="http://demos.mootools.net/Sortables" rel="nofollow noreferrer">http://demos.mootools.net/Sortables</a></p>
| <p>I've evaluated the <a href="http://www.telerik.com/" rel="nofollow noreferrer">Telerik</a> grid as well as <a href="http://www.infragistics.com/Default.aspx" rel="nofollow noreferrer">Infragistics</a> version. In the end we took an approach similar to what tags2k suggested. We just wrote our own javascript and cal... | 3,453 |
<p>I need to make a Control which shows only an outline, and I need to place it over a control that's showing a video. If I make my Control transparent, then the video is obscured, because transparent controls are painted by their parent control and the video isn't painted by the control; it's shown using DirectShow o... | <p>You could try to make a Region with a hole inside and set the control region with SetWindowRgn.</p>
<p>Here is an <a href="http://www.java2s.com/Code/CSharp/GUI-Windows-Form/PictureButton.htm" rel="nofollow noreferrer">example</a> (I couldn't find a better one). The idea is to create two regions and subtract the in... | <p>You could try setting the <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.form.transparencykey.aspx" rel="nofollow noreferrer"><code>Form.TransparencyKey</code></a> property. Failing that, you could use DirectX to get access to the frame buffer and draw directly to it.</p>
| 39,766 |
<p>I'm curious about what it takes to program for mobile devices (Windows Mobile 6.1) and if I can use the IDE's we're already used to (RAD Studio 2009). </p>
<p>Is there a Mobile Development Community around where Delphi or C++Builder users can learn from? </p>
<p>Are there differences in development techniques, li... | <p>Use <a href="http://mail.google.com/support/bin/answer.py?answer=75725&topic=12891" rel="noreferrer">Gmail with IMAP</a>.</p>
| <p>You can get an <a href="https://mail.google.com/mail/feed/atom" rel="nofollow noreferrer">Atom Feed of your GMAIL</a>, which can be fetched with a regular web request, and parse as a regular XML document. I made a PHP page I could access from my phone (which doesn't support Atom Feeds, or pages as advanced as Google... | 44,468 |
<p>I need to find a bottleneck and need to accurately as possible measure time.</p>
<p>Is the following code snippet the best way to measure the performance?</p>
<pre><code>DateTime startTime = DateTime.Now;
// Some execution process
DateTime endTime = DateTime.Now;
TimeSpan totalTimeTaken = endTime.Subtract(startT... | <p>No, it's not. Use the <a href="http://msdn2.microsoft.com/en-us/library/system.diagnostics.stopwatch.aspx" rel="noreferrer">Stopwatch</a> (in <code>System.Diagnostics</code>)</p>
<pre><code>Stopwatch sw = Stopwatch.StartNew();
PerformWork();
sw.Stop();
Console.WriteLine("Time taken: {0}ms", sw.Elapsed.TotalMillise... | <p>Since I do not care to much about precision I ended up comparing them. I am capturing lots of packets on the network and I want to place the time when I receive each packet. Here is the code that tests 5 million iterations</p>
<pre><code> int iterations = 5000000;
// Test using datetime.now
{
var... | 4,824 |
<p>I have an Internet Explorer Browser Helper Object (BHO), written in c#, and in various places I open forms as modal dialogs. Sometimes this works but in some cases it doesn't. The case that I can replicate at present is where IE is running javascript to open other child windows... I guess it's getting a bit confused... | <p>It wasn't my intention to answer my own question, but...</p>
<p>It seems that if you pass in the correct IWin32Window to the ShowDialog() method it works fine. The trick is how to get this. Here's how I did this, where 'siteObject' is the object passed in to the SetSite() method of the BHO:</p>
<pre><code>IWebBrow... | <p>It wasn't my intention to answer my own question, but...</p>
<p>It seems that if you pass in the correct IWin32Window to the ShowDialog() method it works fine. The trick is how to get this. Here's how I did this, where 'siteObject' is the object passed in to the SetSite() method of the BHO:</p>
<pre><code>IWebBrow... | 15,444 |
<p>I have a table view setup which currently, when being flickered up, has its sections flush up against right underneath the status bar, instead of flushing against the the navigation bar. I'm not sure if this is the proper behavior, but most applications have the Section Title flush properly below the navigation bar ... | <p>Sounds like you either don't have the bounds set properly in IB, or your springs-and-struts aren't correct. Is this the top level of the UIViewController, or a subview? Are you using a UINavigationController? If you test the interface in IB, does it look okay?</p>
| <p>As I indicated in the other post, I suspect the hierarchy of views under the UINavigationController has become disrupted.</p>
<p>The layoutSubviews in the content view (which contains the navigation bar and your UITableView) of the UINavigationController should be sizing the UITableView such that it doesn't overlap... | 41,619 |
<p>So, bitfields. Specifically, large bitfields. I understand how to manipulate individual values in a bitfield, but how would I go about doing this on a large set, such as say:</p>
<pre><code>uint[] bitfield = new uint[4] { 0x0080000, 0x00FA3020, 0x00C8000, 0x0FF00D0 };
</code></pre>
<p>The specific problem I'm havi... | <p>What makes you think that BitArray uses bools internally? It uses Boolean values to represent the bits in terms of the API, but under the hood I believe it uses an int[].</p>
| <p>Using extension methods, you could do this:</p>
<pre><code>public static class BitArrayExtensions
{
public static void DownShift(this BitArray bitArray, int places)
{
for (var i = 0; i < bitArray.Length; i++)
{
bitArray[i] = i + places < bitArray.Length && bitArray[... | 21,467 |
<p>I am wondering how the HttpContext is maintained given that the request-response nature of the web is essentially stateless.</p>
<p>Is an identifier being for the HttpContext object being sent as part of the __EVENTTarget / __EVENTARGUMENTS hidden fields so that the HttpRuntime class can create the HttpContext clas... | <p>The HttpContext is recreated for each request. The HttpSession, however, is stored on the server across requests. Basically, HttpSession is a Dictionary<string, Dictionary<string, object>>. The initial key, the session id, is provided by either a cookie or a query string parameter (if using cookie-less s... | <p>I don't think there is one answer to your question, because I don't think everything under the HttpContext umbrella works the same way. In the example you chose, session state, both the key and value are stored on the server side. The way it knows how to hook up future requests to that session state is by using a ... | 34,396 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.