qid int64 4 8.14M | question stringlengths 20 48.3k | answers list | date stringlengths 10 10 | metadata list | input stringlengths 12 45k | output stringlengths 2 31.8k |
|---|---|---|---|---|---|---|
78,847 | <p>ASP.NET 1.1 - I have a DataGrid on an ASPX page that is databound and displays a value within a textbox. The user is able to change this value, then click on a button where the code behind basically iterates through each DataGridItem in the grid, does a FindControl for the ID of the textbox then assigns the .Text va... | [
{
"answer_id": 79791,
"author": "Nathan Feger",
"author_id": 8563,
"author_profile": "https://Stackoverflow.com/users/8563",
"pm_score": 1,
"selected": false,
"text": "<p>Are you able to manage permissions on this database? Would adding a separate user who only has read access to a data... | 2008/09/17 | [
"https://Stackoverflow.com/questions/78847",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/710/"
] | ASP.NET 1.1 - I have a DataGrid on an ASPX page that is databound and displays a value within a textbox. The user is able to change this value, then click on a button where the code behind basically iterates through each DataGridItem in the grid, does a FindControl for the ID of the textbox then assigns the .Text value... | Are you able to manage permissions on this database? Would adding a separate user who only has read access to a database be sufficient for this type of scenario? This could be a read-only user on the main database, but is only effectively used on the snapshot db.
i.e. Add a new user, readerMan5000 who is only given se... |
78,849 | <p>I have an image (mx) and i want to get the uint of the pixel that was clicked.</p>
<p>Any ideas?</p>
| [
{
"answer_id": 79221,
"author": "enobrev",
"author_id": 14651,
"author_profile": "https://Stackoverflow.com/users/14651",
"pm_score": 3,
"selected": false,
"text": "<p>A few minutes on the <a href=\"http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/BitmapData.html\"... | 2008/09/17 | [
"https://Stackoverflow.com/questions/78849",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1748529/"
] | I have an image (mx) and i want to get the uint of the pixel that was clicked.
Any ideas? | Here's an even simpler implementation. All you do is take a snapshot of the stage using the **draw()** method of bitmapData, then use **getPixel()** on the pixel under the mouse. The advantage of this is that you can sample anything that's been drawn to the stage, not just a given bitmap.
```
import flash.display.Bitm... |
78,852 | <p>Mapping a collection of enums with NHibernate</p>
<p>Specifically, using Attributes for the mappings.</p>
<p>Currently I have this working mapping the collection as type Int32 and NH seems to take care of it, but it's not exactly ideal.</p>
<p>The error I receive is "Unable to determine type" when trying to map t... | [
{
"answer_id": 80485,
"author": "alvin",
"author_id": 15121,
"author_profile": "https://Stackoverflow.com/users/15121",
"pm_score": 1,
"selected": false,
"text": "<p>This is the way i do it. There's probably an easier way but this works for me.</p>\n\n<p>Edit: sorry, i overlooked that yo... | 2008/09/17 | [
"https://Stackoverflow.com/questions/78852",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/924607/"
] | Mapping a collection of enums with NHibernate
Specifically, using Attributes for the mappings.
Currently I have this working mapping the collection as type Int32 and NH seems to take care of it, but it's not exactly ideal.
The error I receive is "Unable to determine type" when trying to map the collection as of the ... | You will need to map your CEnum type directly. In XML mappings this would mean creating a new class mapping element in your NHibernate XML mappings file.
```
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="YourAssembly"
auto-import="true" default-lazy="false">
...
<class name="YourAssemblyNa... |
78,884 | <p>I have an xslt sheet with some text similar to below:</p>
<pre><code><xsl:text>I am some text, and I want to be bold</xsl:text>
</code></pre>
<p>I would like some text to be bold, but this doesn't work.</p>
<pre><code><xsl:text>I am some text, and I want to be <strong>bold<strong><... | [
{
"answer_id": 78904,
"author": "aku",
"author_id": 1196,
"author_profile": "https://Stackoverflow.com/users/1196",
"pm_score": 3,
"selected": false,
"text": "<p>Try this: </p>\n\n<pre><code><fo:inline font-weight=\"bold\"><xsl:text>Bold text</xsl:text></fo:inline&g... | 2008/09/17 | [
"https://Stackoverflow.com/questions/78884",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5989/"
] | I have an xslt sheet with some text similar to below:
```
<xsl:text>I am some text, and I want to be bold</xsl:text>
```
I would like some text to be bold, but this doesn't work.
```
<xsl:text>I am some text, and I want to be <strong>bold<strong></xsl:text>
```
The deprecated b tag doesn't work either. How do I f... | You don't. `xsl:text` can only contain text nodes and `<strong>` is an element node, not a string that starts with less-than character; XSLT is about creating node trees, not markup. So, you have to do
```
<xsl:text>I am some text, and I want to be </xsl:text>
<strong>bold<strong>
<xsl:text> </xsl:text>
``` |
78,913 | <p>What is the single most effective practice to prevent <a href="http://en.wikipedia.org/wiki/Arithmetic_overflow" rel="nofollow noreferrer">arithmetic overflow</a> and <a href="http://en.wikipedia.org/wiki/Arithmetic_underflow" rel="nofollow noreferrer">underflow</a>?</p>
<p>Some examples that come to mind are:</p>
... | [
{
"answer_id": 78936,
"author": "Eclipse",
"author_id": 8701,
"author_profile": "https://Stackoverflow.com/users/8701",
"pm_score": 3,
"selected": true,
"text": "<p>One possibility is to use a language that has arbitrarily sized integers that never overflow / underflow.</p>\n\n<p>Otherwi... | 2008/09/17 | [
"https://Stackoverflow.com/questions/78913",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3836/"
] | What is the single most effective practice to prevent [arithmetic overflow](http://en.wikipedia.org/wiki/Arithmetic_overflow) and [underflow](http://en.wikipedia.org/wiki/Arithmetic_underflow)?
Some examples that come to mind are:
* testing based on valid input ranges
* validation using formal methods
* use of invari... | One possibility is to use a language that has arbitrarily sized integers that never overflow / underflow.
Otherwise, if this is something you're really concerned about, and if your language allows it, write a wrapper class that acts like an integer, but checks every operation for overflow. You could even have it do th... |
78,924 | <p>I have written a message handler function in Outlook's Visual Basic (we're using Outlook 2003 and Exchange Server) to help me sort out incoming email. </p>
<p>It is working for me, except sometimes the rule fails and Outlook deactivates it. </p>
<p>Then I turn the rule back on and manually run it on my Inbox to ca... | [
{
"answer_id": 79000,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "<p>have written a message handler function in Outlook's Visual Basic (we're using Outlook 2003 and Exchange Server) to help me ... | 2008/09/17 | [
"https://Stackoverflow.com/questions/78924",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have written a message handler function in Outlook's Visual Basic (we're using Outlook 2003 and Exchange Server) to help me sort out incoming email.
It is working for me, except sometimes the rule fails and Outlook deactivates it.
Then I turn the rule back on and manually run it on my Inbox to catch up. The rule ... | This code showed me the different TypeNames that were in my Inbox:
```
Public Sub GetTypeNamesInbox()
Dim myOlItems As Outlook.Items
Set myOlItems = application.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Items
Dim msg As Object
For Each msg In myOlItems
Debug.Print TypeName(msg)
'emails are typename... |
78,932 | <p>I have the following HTML <code><select></code> element:</p>
<pre><code><select id="leaveCode" name="leaveCode">
<option value="10">Annual Leave</option>
<option value="11">Medical Leave</option>
<option value="14">Long Service</option>
<option value="17"&g... | [
{
"answer_id": 78945,
"author": "Mitchel Sellers",
"author_id": 13279,
"author_profile": "https://Stackoverflow.com/users/13279",
"pm_score": 11,
"selected": true,
"text": "<p>You can use this function:</p>\n<p><div class=\"snippet\" data-lang=\"js\" data-hide=\"false\" data-console=\"tr... | 2008/09/17 | [
"https://Stackoverflow.com/questions/78932",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6340/"
] | I have the following HTML `<select>` element:
```
<select id="leaveCode" name="leaveCode">
<option value="10">Annual Leave</option>
<option value="11">Medical Leave</option>
<option value="14">Long Service</option>
<option value="17">Leave Without Pay</option>
</select>
```
Using a JavaScript function with t... | You can use this function:
```js
function selectElement(id, valueToSelect) {
let element = document.getElementById(id);
element.value = valueToSelect;
}
selectElement('leaveCode', '11');
```
```html
<select id="leaveCode" name="leaveCode">
<option value="10">Annual Leave</option>
<option value="11">M... |
78,974 | <p>I've written a control that inherits from the <code>System.Web.UI.WebControls.DropDownList</code> and so I don't have any code in front for this control, but I still want to set the OutputCache directive. I there any way to set this in the C# code, say with an attribute or something like that? </p>
<p>I'm particu... | [
{
"answer_id": 79012,
"author": "dimarzionist",
"author_id": 10778,
"author_profile": "https://Stackoverflow.com/users/10778",
"pm_score": 1,
"selected": false,
"text": "<pre><code>Response.Cache.SetExpires(DateTime.Now.AddSeconds(60));\nResponse.Cache.SetCacheability(HttpCacheability.Se... | 2008/09/17 | [
"https://Stackoverflow.com/questions/78974",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2975/"
] | I've written a control that inherits from the `System.Web.UI.WebControls.DropDownList` and so I don't have any code in front for this control, but I still want to set the OutputCache directive. I there any way to set this in the C# code, say with an attribute or something like that?
I'm particularly hoping to be able... | I realize this is an incredibly old question but it is still worthy of an answer.
What you are talking about isn't a User Control it is a Custom Control. What you want to do with the OutputCache can be done simply with the Context Cache.
In your code where you are getting the data and binding to your DropDownList do ... |
78,978 | <p>I'm working on a regular expression in a <code>.NET</code> project to get a specific tag. I would like to match the entire DIV tag and its contents:</p>
<pre><code><html>
<head><title>Test</title></head>
<body>
<p>The first paragraph.</p>
<div id='... | [
{
"answer_id": 78985,
"author": "mopoke",
"author_id": 14054,
"author_profile": "https://Stackoverflow.com/users/14054",
"pm_score": 1,
"selected": false,
"text": "<p>Depends what language you're working in. \nFor example, in perl you'd use the regex modifier s:</p>\n\n<pre><code>m{<d... | 2008/09/17 | [
"https://Stackoverflow.com/questions/78978",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27870/"
] | I'm working on a regular expression in a `.NET` project to get a specific tag. I would like to match the entire DIV tag and its contents:
```
<html>
<head><title>Test</title></head>
<body>
<p>The first paragraph.</p>
<div id='super_special'>
<p>The Store paragraph</p>
</div>
</body>
... | Out-of-the-box, without special modifiers, most regex implementations don't go beyond the end-of-line to match text. You probably should look in the documentation of the regex engine you're using for such modifier.
I have one other advice: beware of greed! Traditionally, regex **are** greedy which means that your rege... |
79,041 | <p>I have a web system which has a classical parent-children menu saved in a database, with fields id as the PK, and parent_id to pointing to the owning menu. (Yes, I know this doesn't scale very well, but that's another topic). </p>
<p>So for these records (id-parent_id pairs):</p>
<pre><code>0-7 0-4 4-9 4-14 4-16 9... | [
{
"answer_id": 79067,
"author": "Blorgbeard",
"author_id": 369,
"author_profile": "https://Stackoverflow.com/users/369",
"pm_score": 2,
"selected": true,
"text": "<p>This is the perfect chance to use recursion!</p>\n\n<p>Pseudo-code:</p>\n\n<pre><code>nodeList = {}\nenumerateNodes(rootNo... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79041",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/861/"
] | I have a web system which has a classical parent-children menu saved in a database, with fields id as the PK, and parent\_id to pointing to the owning menu. (Yes, I know this doesn't scale very well, but that's another topic).
So for these records (id-parent\_id pairs):
```
0-7 0-4 4-9 4-14 4-16 9-6
```
I have thi... | This is the perfect chance to use recursion!
Pseudo-code:
```
nodeList = {}
enumerateNodes(rootNode, nodeList);
function enumerateNodes(node, nodeList) {
nodeList += node;
foreach ( childnode in node.children ) {
enumerateNodes(childnode, nodeList);
}
}
```
Edit: Didn't notice that your tree is in ... |
79,121 | <p>So, im trying to write some code that utilizes Nvidia's CUDA architecture. I noticed that copying to and from the device was really hurting my overall performance, so now I am trying to move a large amount of data onto the device.</p>
<p>As this data is used in numerous functions, I would like it to be global. Yes,... | [
{
"answer_id": 79256,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "<p>Spend some time focusing on the copious documentation offered by NVIDIA.</p>\n\n<p>From the Programming Guide:</p>\n\n<pre><... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79121",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14621/"
] | So, im trying to write some code that utilizes Nvidia's CUDA architecture. I noticed that copying to and from the device was really hurting my overall performance, so now I am trying to move a large amount of data onto the device.
As this data is used in numerous functions, I would like it to be global. Yes, I can pas... | Something like this should probably work.
```
#include <algorithm>
#define NDEBUG
#define CUT_CHECK_ERROR(errorMessage) do { \
cudaThreadSynchronize(); \
cudaError_t err = cudaGetLastError(); \
... |
79,126 | <p>I'm building a function to extend the <code>Enum.Parse</code> concept that</p>
<ul>
<li>Allows a default value to be parsed in case that an Enum value is not found</li>
<li>Is case insensitive</li>
</ul>
<p>So I wrote the following:</p>
<pre><code>public static T GetEnumFromString<T>(string value, T defaultVal... | [
{
"answer_id": 79148,
"author": "dimarzionist",
"author_id": 10778,
"author_profile": "https://Stackoverflow.com/users/10778",
"pm_score": 3,
"selected": false,
"text": "<p>Hope this is helpful:</p>\n\n<pre><code>public static TValue ParseEnum<TValue>(string value, TValue defaultVa... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79126",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5302/"
] | I'm building a function to extend the `Enum.Parse` concept that
* Allows a default value to be parsed in case that an Enum value is not found
* Is case insensitive
So I wrote the following:
```
public static T GetEnumFromString<T>(string value, T defaultValue) where T : Enum
{
if (string.IsNullOrEmpty(value)) re... | This feature is finally supported in C# 7.3!
--------------------------------------------
The following snippet (from [the dotnet samples](https://github.com/dotnet/samples/blob/3ee82879284e3f4755251fd33c3b3e533f7b3485/snippets/csharp/keywords/GenericWhereConstraints.cs#L180-L190)) demonstrates how:
```
public static... |
79,129 | <p>For the life of me, I cannot get the SqlProfileProvider to work in an MVC project that I'm working on.</p>
<p>The first interesting thing that I realized is that Visual Studio does not automatically generate the ProfileCommon proxy class for you. That's not a big deal since it's simpy a matter of extending the Pro... | [
{
"answer_id": 80594,
"author": "Mladen Mihajlovic",
"author_id": 11421,
"author_profile": "https://Stackoverflow.com/users/11421",
"pm_score": 3,
"selected": false,
"text": "<p>Not sure about the whole question, but one thing I noticed in your code:</p>\n\n<pre><code>ProfileCommon profi... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79129",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10792/"
] | For the life of me, I cannot get the SqlProfileProvider to work in an MVC project that I'm working on.
The first interesting thing that I realized is that Visual Studio does not automatically generate the ProfileCommon proxy class for you. That's not a big deal since it's simpy a matter of extending the ProfileBase cl... | Here's what you need to do:
1) In Web.config's section, add "inherits" attribute in addition to your other attribute settings:
```
<profile inherits="MySite.Models.ProfileCommon" defaultProvider="....
```
2) Remove entire `<properties>` section from Web.config, since you have already defined them in your custom Pro... |
79,165 | <p>I read the Git manual, FAQ, Git - SVN crash course, etc. and they all explain this and that, but nowhere can you find a simple instruction like:</p>
<p>SVN repository in: <code>svn://myserver/path/to/svn/repos</code></p>
<p>Git repository in: <code>git://myserver/path/to/git/repos</code></p>
<pre><code>git-do-the... | [
{
"answer_id": 79178,
"author": "jfm3",
"author_id": 11138,
"author_profile": "https://Stackoverflow.com/users/11138",
"pm_score": 10,
"selected": true,
"text": "<p>Magic:</p>\n\n<pre><code>$ git svn clone http://svn/repo/here/trunk\n</code></pre>\n\n<p>Git and SVN operate very different... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79165",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14690/"
] | I read the Git manual, FAQ, Git - SVN crash course, etc. and they all explain this and that, but nowhere can you find a simple instruction like:
SVN repository in: `svn://myserver/path/to/svn/repos`
Git repository in: `git://myserver/path/to/git/repos`
```
git-do-the-magic-svn-import-with-history \
svn://myserver/pa... | Magic:
```
$ git svn clone http://svn/repo/here/trunk
```
Git and SVN operate very differently. You need to learn Git, and if you want to track changes from SVN upstream, you need to learn `git-svn`. The `git-svn` [main page has a good examples section](https://git-scm.com/docs/git-svn):
```
$ git svn --help
``` |
79,197 | <p>What's a simple way to combine <strong>feed</strong> and <strong>feed2</strong>? I want the items from <strong>feed2</strong> to be added to <strong>feed</strong>. Also I want to avoid duplicates as <strong>feed</strong> might already have items when a question is tagged with both WPF and Silverlight.</p>
<pre><cod... | [
{
"answer_id": 79372,
"author": "David Thibault",
"author_id": 5903,
"author_profile": "https://Stackoverflow.com/users/5903",
"pm_score": 0,
"selected": false,
"text": "<p>If it's solely for stackoverflow, you can use this :<br>\n<a href=\"https://stackoverflow.com/feeds/tag/silverlight... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79197",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1133/"
] | What's a simple way to combine **feed** and **feed2**? I want the items from **feed2** to be added to **feed**. Also I want to avoid duplicates as **feed** might already have items when a question is tagged with both WPF and Silverlight.
```
Uri feedUri = new Uri("http://stackoverflow.com/feeds/tag/silverlight");
XmlR... | You can use LINQ to simplify the code to join two lists (don't forget to put System.Linq in your usings and if necessary reference System.Core in your project) Here's a Main that does the union and prints them to console (with proper cleanup of the Reader).
```
using System;
using System.Collections.Generic;
using Sys... |
79,215 | <p>For example, if I have a page located in Views/Home/Index.aspx and a JavaScript file located in Views/Home/Index.js, how do you reference this on the aspx page?</p>
<p>The example below doesn't work even though the compiler says the path is correct</p>
<pre><code><script src="Index.js" type="text/javascript">... | [
{
"answer_id": 79246,
"author": "Chris Pietschmann",
"author_id": 7831,
"author_profile": "https://Stackoverflow.com/users/7831",
"pm_score": 2,
"selected": false,
"text": "<p>You can use the VirtualPathUtility.ToAbsolute method like below to convert the app relative url of the .js file ... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79215",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10941/"
] | For example, if I have a page located in Views/Home/Index.aspx and a JavaScript file located in Views/Home/Index.js, how do you reference this on the aspx page?
The example below doesn't work even though the compiler says the path is correct
```
<script src="Index.js" type="text/javascript"></script>
```
The exact ... | For shared javascript resources using the Content folder makes sense. The issue was I was specifically trying to solve was aspx page specific javascript that would never be reused.
I think what I will just have to do is put the aspx page specific javascript right onto the page itself and keep the shared js resources ... |
79,258 | <p>Is there a tool that will find for me all the css classes that I am referencing in my HTML that don't actually exist?</p>
<p>ie. if I have <ul class="topnav" /> in my HTML and the topnav class doesn't exist in any of the referenced CSS files.</p>
<p>This is similar to <a href="https://stackoverflow.com/quest... | [
{
"answer_id": 79306,
"author": "Milan Babuškov",
"author_id": 14690,
"author_profile": "https://Stackoverflow.com/users/14690",
"pm_score": 1,
"selected": false,
"text": "<p>Error Console in Firefox. Although, it gives <strong>all</strong> CSS errors, so you have to read through it.</p>... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79258",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4640/"
] | Is there a tool that will find for me all the css classes that I am referencing in my HTML that don't actually exist?
ie. if I have <ul class="topnav" /> in my HTML and the topnav class doesn't exist in any of the referenced CSS files.
This is similar to [SO#33242](https://stackoverflow.com/questions/33242/how-can-i-... | You can put this JavaScript in the page that can perform this task for you:
```
function forItems(a, f) {
for (var i = 0; i < a.length; i++) f(a.item(i))
}
function classExists(className) {
var pattern = new RegExp('\\.' + className + '\\b'), found = false
try {
forItems(document.styleSheets, function(ss) ... |
79,264 | <p>Is there a program or API I can code against to extract individual files from a Windows Vista Complete PC Backup image?</p>
<p>I like the idea of having a complete image to restore from, but hate the idea that I have to make two backups, one for restoring individual files, and one for restoring my computer in the e... | [
{
"answer_id": 79306,
"author": "Milan Babuškov",
"author_id": 14690,
"author_profile": "https://Stackoverflow.com/users/14690",
"pm_score": 1,
"selected": false,
"text": "<p>Error Console in Firefox. Although, it gives <strong>all</strong> CSS errors, so you have to read through it.</p>... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79264",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2581/"
] | Is there a program or API I can code against to extract individual files from a Windows Vista Complete PC Backup image?
I like the idea of having a complete image to restore from, but hate the idea that I have to make two backups, one for restoring individual files, and one for restoring my computer in the event of a ... | You can put this JavaScript in the page that can perform this task for you:
```
function forItems(a, f) {
for (var i = 0; i < a.length; i++) f(a.item(i))
}
function classExists(className) {
var pattern = new RegExp('\\.' + className + '\\b'), found = false
try {
forItems(document.styleSheets, function(ss) ... |
79,275 | <p>I have a form like this:</p>
<pre><code><form name="mine">
<input type=text name=one>
<input type=text name=two>
<input type=text name=three>
</form>
</code></pre>
<p>When user types a value in 'one', I sometimes want to skip the field 'two', depending on what he typed. Fo... | [
{
"answer_id": 79317,
"author": "dimarzionist",
"author_id": 10778,
"author_profile": "https://Stackoverflow.com/users/10778",
"pm_score": 3,
"selected": true,
"text": "<p>Try to attach tabindex attribute to your elements and then programmaticaly (in javaScript change it):</p>\n\n<pre><c... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79275",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14690/"
] | I have a form like this:
```
<form name="mine">
<input type=text name=one>
<input type=text name=two>
<input type=text name=three>
</form>
```
When user types a value in 'one', I sometimes want to skip the field 'two', depending on what he typed. For example, if user types '123' and uses Tab to move to n... | Try to attach tabindex attribute to your elements and then programmaticaly (in javaScript change it):
```
<INPUT tabindex="3" type="submit" name="mySubmit">
``` |
79,292 | <p>Can databases (MySQL in particular, any SQL--MS, Oracle, Postgres--in general) do mass updates, and figure out on their own what the new value should be? Say for example I've got a database with information about a bunch of computers, and all of these computers have drives of various sizes--anywhere from 20 to 250 G... | [
{
"answer_id": 79305,
"author": "Tom Leys",
"author_id": 11440,
"author_profile": "https://Stackoverflow.com/users/11440",
"pm_score": 2,
"selected": false,
"text": "<p>Yeah:</p>\n\n<pre><code>update computers set total_disk_space = total_disk_space + 120;\n</code></pre>\n"
},
{
... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79292",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14701/"
] | Can databases (MySQL in particular, any SQL--MS, Oracle, Postgres--in general) do mass updates, and figure out on their own what the new value should be? Say for example I've got a database with information about a bunch of computers, and all of these computers have drives of various sizes--anywhere from 20 to 250 GB. ... | For the entire Table then:
```
Update Computers
Set Total_Disk_Space = Total_Disk_Space + 120;
```
If, you only want to update certain ones, then you'd need filters, for example:
```
Update Computers
Set Total_Disk_Space = Total_Disk_Space + 120
Where PurchaseDate BETWEEN '1/1/2008' AND GETDATE();
``` |
79,352 | <p>I have a method that can return either a single object or a collection of objects. I want to be able to run object.collect on the result of that method whether or not it is a single object or a collection already. How can i do this?</p>
<pre><code>profiles = ProfileResource.search(params)
output = profiles.collect ... | [
{
"answer_id": 79416,
"author": "Matt Haley",
"author_id": 14142,
"author_profile": "https://Stackoverflow.com/users/14142",
"pm_score": 1,
"selected": false,
"text": "<pre><code>profiles = [ProfileResource.search(params)].flatten\noutput = profiles.collect do |profile|\n profile.to_h... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79352",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1486/"
] | I have a method that can return either a single object or a collection of objects. I want to be able to run object.collect on the result of that method whether or not it is a single object or a collection already. How can i do this?
```
profiles = ProfileResource.search(params)
output = profiles.collect do | profile |... | Careful with the flatten approach, if search() returned nested arrays then unexpected behaviour might result.
```
profiles = ProfileResource.search(params)
profiles = [profiles] if !profiles.respond_to?(:collect)
output = profiles.collect do |profile|
profile.to_hash
end
``` |
79,367 | <p>I have a query:</p>
<pre><code>SELECT *
FROM Items
WHERE column LIKE '%foo%'
OR column LIKE '%bar%'
</code></pre>
<p>How do I order the results?</p>
<p>Let's say I have rows that match 'foo' and rows that match 'bar' but I also have a row with 'foobar'.</p>
<p>How do I order the returned rows so that the firs... | [
{
"answer_id": 79375,
"author": "Milan Babuškov",
"author_id": 14690,
"author_profile": "https://Stackoverflow.com/users/14690",
"pm_score": 0,
"selected": false,
"text": "<p>Which DBMS?</p>\n\n<p>It can be done via CTE or Union for example, but if you are using, for example, MySQL, then... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79367",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a query:
```
SELECT *
FROM Items
WHERE column LIKE '%foo%'
OR column LIKE '%bar%'
```
How do I order the results?
Let's say I have rows that match 'foo' and rows that match 'bar' but I also have a row with 'foobar'.
How do I order the returned rows so that the first results are the ones that matched more... | Case or the kind of conditional construct your RDBMS supports is a way to do it
```
select *, case when col like '%foo%' and col like '%bar%' then 2 end
else 1 end as ordcol
from items
where col like '%foo%' or col like '%bar%' order by ordcol
``` |
79,445 | <p>I'd like to write a simple C# application to monitor the line-in audio and give me the current (well, the rolling average) beats per minute.</p>
<p>I've seen <a href="http://www.gamedev.net/page/resources/_/technical/math-and-physics/beat-detection-algorithms-r1952" rel="noreferrer">this gamedev article</a>, and th... | [
{
"answer_id": 79480,
"author": "Thomas",
"author_id": 14637,
"author_profile": "https://Stackoverflow.com/users/14637",
"pm_score": 3,
"selected": false,
"text": "<p>This is by no means an easy problem. I'll try to give you an overview only.</p>\n\n<p>What you could do is something like... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79445",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14758/"
] | I'd like to write a simple C# application to monitor the line-in audio and give me the current (well, the rolling average) beats per minute.
I've seen [this gamedev article](http://www.gamedev.net/page/resources/_/technical/math-and-physics/beat-detection-algorithms-r1952), and that was absolutely no help. I went thro... | Calculate a powerspectrum with a sliding window FFT:
Take 1024 samples:
```
double[] signal = stream.Take(1024);
```
Feed it to an FFT algorithm:
```
double[] real = new double[signal.Length];
double[] imag = new double[signal.Length);
FFT(signal, out real, out imag);
```
You will get a real part and an imagina... |
79,454 | <p>Recently I've been experimenting with TDD while developing a GUI application in Python. I find it very reassuring to have tests that verify the functionality of my code, but it's been tricky to follow some of the recommened practices of TDD. Namely, writing tests first has been hard. And I'm finding it difficult to ... | [
{
"answer_id": 79667,
"author": "etchasketch",
"author_id": 14640,
"author_profile": "https://Stackoverflow.com/users/14640",
"pm_score": -1,
"selected": false,
"text": "<p>Unit tests are really useful when you refactor your code (ie. completely rewrite or move a module). As long as you ... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79454",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10840/"
] | Recently I've been experimenting with TDD while developing a GUI application in Python. I find it very reassuring to have tests that verify the functionality of my code, but it's been tricky to follow some of the recommened practices of TDD. Namely, writing tests first has been hard. And I'm finding it difficult to mak... | **If you are writing your tests after you've written your code and making them pass, you are not doing TDD** (nor are you getting any benefits of Test-First or Test-Driven development.. check out SO questions for definitive books on TDD)
>
> One of the things I've noticed with
> using mocker is that it's easier to
>... |
79,455 | <p>Given this example:</p>
<pre><code><img class="a" />
<img />
<img class="a" />
<img class="a" id="active" />
<img class="a" />
<img class="a" />
<img />
<img class="a" />
</code></pre>
<p><em>(I've just used img tags as an example, that's not what it is in my code)</... | [
{
"answer_id": 79471,
"author": "Xenph Yan",
"author_id": 264,
"author_profile": "https://Stackoverflow.com/users/264",
"pm_score": 2,
"selected": false,
"text": "<p>I believe looping is your best bet. But you could try, each active, and then move before and after until the condition bre... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79455",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9021/"
] | Given this example:
```
<img class="a" />
<img />
<img class="a" />
<img class="a" id="active" />
<img class="a" />
<img class="a" />
<img />
<img class="a" />
```
*(I've just used img tags as an example, that's not what it is in my code)*
Using jQuery, how would you select the img tags with class "a" that are adja... | Here's what I came up with in the end.
```
// here's our active element.
var $active = $('#active');
// here is the filter we'll be testing against.
var filter = "img.a";
// $all will be the final jQuery object with all the consecutively matched elements.
// start it out by populating it with the current object.
var... |
79,461 | <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... | [
{
"answer_id": 79513,
"author": "dimarzionist",
"author_id": 10778,
"author_profile": "https://Stackoverflow.com/users/10778",
"pm_score": -1,
"selected": false,
"text": "<pre><code><div id=\"header\" style=\"display: table-cell; vertical-align:middle;\">\n</code></pre>\n\n<p>...</... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79461",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5232/"
] | I have a `div` with two images and an `h1`. All of them need to be vertically aligned within the div, next to each other. One of the images needs to be `absolute` positioned within the `div`.
What is the CSS needed for this to work on all common browsers?
```html
<div id="header">
<img src=".." ></img>
<h1>testin... | Wow, this problem is popular. It's based on a misunderstanding in the `vertical-align` property. This excellent article explains it:
[Understanding `vertical-align`, or "How (Not) To Vertically Center Content"](http://phrogz.net/CSS/vertical-align/index.html) by Gavin Kistner.
**[“How to center in CSS”](http://howtoc... |
79,466 | <p>(sorry I should have been clearer with the code the first time I posted this. Hope this makes sense)</p>
<p>File "size_specification.rb"</p>
<pre><code>class SizeSpecification
def fits?
end
end
</code></pre>
<p>File "some_module.rb"</p>
<pre><code>require 'size_specification'
module SomeModule
def se... | [
{
"answer_id": 80075,
"author": "robertpostill",
"author_id": 11219,
"author_profile": "https://Stackoverflow.com/users/11219",
"pm_score": 0,
"selected": false,
"text": "<p>On second reading I'm a little confused, you seem to want to mix the class into module, which is porbably not so a... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79466",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14796/"
] | (sorry I should have been clearer with the code the first time I posted this. Hope this makes sense)
File "size\_specification.rb"
```
class SizeSpecification
def fits?
end
end
```
File "some\_module.rb"
```
require 'size_specification'
module SomeModule
def self.sizes
YAML.load_file(File.dirname(_... | Are your settings and ruby installation ok? I created those 3 files and wrote what follows in "test.rb"
```
require 'yaml'
require "some_module"
SomeModule.sizes.first.fits?
```
Then I ran it.
```
$ ruby --version
ruby 1.8.6 (2008-06-20 patchlevel 230) [i486-linux]
$ ruby -w test.rb
$
```
No errors! |
79,474 | <p>I've set up Passenger in development (Mac OS X) and it works flawlessly. The only problem came later: now I have a custom <code>GEM_HOME</code> path and ImageMagick binaries installed in <code>"/usr/local"</code>. I can put them in one of the shell rc files that get sourced and this solves the environment variables ... | [
{
"answer_id": 79615,
"author": "Brian Phillips",
"author_id": 7230,
"author_profile": "https://Stackoverflow.com/users/7230",
"pm_score": 1,
"selected": false,
"text": "<p>I've run into this issue as well. It <a href=\"http://groups.google.com/group/phusion-passenger/browse_thread/thre... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79474",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11687/"
] | I've set up Passenger in development (Mac OS X) and it works flawlessly. The only problem came later: now I have a custom `GEM_HOME` path and ImageMagick binaries installed in `"/usr/local"`. I can put them in one of the shell rc files that get sourced and this solves the environment variables for processes spawned fro... | I know of two solutions. The first (documented [here](http://www.viget.com/extend/rubyinline-in-shared-rails-environments/)) is essentially the same as manveru's—set the ENV variable directly in your code.
The second is to create a wrapper around the Ruby interpreter that Passenger uses, and is documented [here](http:... |
79,490 | <p>How can I get a history of uptimes for my debian box? After a reboot, I dont see an option for the uptime command to print a history of uptimes. If it matters, I would like to use these uptimes for graphing a page in php to show my webservers uptime lengths between boots.</p>
<p>Update:
Not sure if it is based on ... | [
{
"answer_id": 79503,
"author": "John Boker",
"author_id": 2847,
"author_profile": "https://Stackoverflow.com/users/2847",
"pm_score": 1,
"selected": false,
"text": "<p>i dont think this information is saved between reboots.</p>\n\n<p>if shutting down properly you could run a command on ... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79490",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/777/"
] | How can I get a history of uptimes for my debian box? After a reboot, I dont see an option for the uptime command to print a history of uptimes. If it matters, I would like to use these uptimes for graphing a page in php to show my webservers uptime lengths between boots.
Update:
Not sure if it is based on a length o... | You could create a simple script which runs uptime and dumps it to a file.
```
uptime >> uptime.log
```
Then set up a cron job for it. |
79,493 | <p>I want to use Apple's or RedHat's built-in Apache but I want to use Perl 5.10 and mod_perl. What's the least intrusive way to accomplish this? I want the advantage of free security patching for the vendor's Apache, dav, php, etc., but I care a lot about which version of Perl I use and what's in my @INC path. I do... | [
{
"answer_id": 79696,
"author": "Ian",
"author_id": 2311,
"author_profile": "https://Stackoverflow.com/users/2311",
"pm_score": 1,
"selected": false,
"text": "<p>You'll want to look into <a href=\"http://httpd.apache.org/docs/2.2/mod/mod_so.html\" rel=\"nofollow noreferrer\">mod_so</a></... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79493",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14783/"
] | I want to use Apple's or RedHat's built-in Apache but I want to use Perl 5.10 and mod\_perl. What's the least intrusive way to accomplish this? I want the advantage of free security patching for the vendor's Apache, dav, php, etc., but I care a lot about which version of Perl I use and what's in my @INC path. I don't m... | 1. Build your version of Perl 5.10 following any special instructions from the mod\_perl documentation. Tell Perl configurator to install in some non-standard place, like /usr/local/perl/5.10.0
2. Use the instructions to build a shared library (or dynamic, or .so) mod\_perl against your distribution's Apache, but make ... |
79,498 | <p>I have determined that my JSON, coming from the server, is valid (making the ajax call manually), but I would really like to use JQuery. I have also determined that the "post" URL, being sent to the server, is correct, using firebug. However, the error callback is still being triggered (parse error). I also tried da... | [
{
"answer_id": 79617,
"author": "Adam Weber",
"author_id": 9324,
"author_profile": "https://Stackoverflow.com/users/9324",
"pm_score": 5,
"selected": true,
"text": "<p>Here are a few suggestions I would try:</p>\n\n<p>1) the 'datatype' option you have specified should be 'dataType' (case... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79498",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2755/"
] | I have determined that my JSON, coming from the server, is valid (making the ajax call manually), but I would really like to use JQuery. I have also determined that the "post" URL, being sent to the server, is correct, using firebug. However, the error callback is still being triggered (parse error). I also tried datat... | Here are a few suggestions I would try:
1) the 'datatype' option you have specified should be 'dataType' (case-sensitive I believe)
2) try using the 'contentType' option as so:
```
contentType: "application/json; charset=utf-8"
```
I'm not sure how much that will help as it's used in the request to your post url, ... |
79,538 | <p>I just installed Ubuntu 8.04 and I'm taking a course in Java so I figured why not install a IDE while I am installing it. So I pick my IDE of choice, Eclipse, and I make a very simple program, Hello World, to make sure everything is running smoothly. When I go to use Scanner for user input I get a very odd error:</p... | [
{
"answer_id": 79551,
"author": "Thomas",
"author_id": 14637,
"author_profile": "https://Stackoverflow.com/users/14637",
"pm_score": 3,
"selected": true,
"text": "<p>The Scanner class is new in Java 5. I do not know what Hardy's default Java environment is, but it is not Sun's and theref... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79538",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/97220/"
] | I just installed Ubuntu 8.04 and I'm taking a course in Java so I figured why not install a IDE while I am installing it. So I pick my IDE of choice, Eclipse, and I make a very simple program, Hello World, to make sure everything is running smoothly. When I go to use Scanner for user input I get a very odd error:
**My... | The Scanner class is new in Java 5. I do not know what Hardy's default Java environment is, but it is not Sun's and therefore may be outdated.
I recommend installing the package sun-java6-jdk to get the most up-to-date version, then telling Eclipse to use it. |
79,602 | <p>I am writing a web application that requires user interaction via email. I'm curious if there is a best practice or recommended source for learning about processing email. I am writing my application in Python, but I'm not sure what mail server to use or how to format the message or subject line to account for aut... | [
{
"answer_id": 79670,
"author": "Jerub",
"author_id": 14648,
"author_profile": "https://Stackoverflow.com/users/14648",
"pm_score": 3,
"selected": true,
"text": "<p>There are some pretty serious concerns here for how to send email automatically, and here are a few:</p>\n\n<p>Use an email... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79602",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/322887/"
] | I am writing a web application that requires user interaction via email. I'm curious if there is a best practice or recommended source for learning about processing email. I am writing my application in Python, but I'm not sure what mail server to use or how to format the message or subject line to account for automate... | There are some pretty serious concerns here for how to send email automatically, and here are a few:
Use an email library. Python includes one called 'email'. This is your friend, it will stop you from doing anything tragically wrong. Read an example from [the Python Manual](http://docs.python.org/lib/node161.html).
... |
79,612 | <p>Looking for a <code>Linux application</code> <em>(or Firefox extension)</em> that will allow me to scrape an HTML mockup and keep the page's integrity.</p>
<p>Firefox does an almost perfect job but doesn't grab images referenced in the CSS.</p>
<p>The Scrapbook extension for Firefox gets everything, but flattens t... | [
{
"answer_id": 79623,
"author": "etchasketch",
"author_id": 14640,
"author_profile": "https://Stackoverflow.com/users/14640",
"pm_score": 2,
"selected": false,
"text": "<p>Have you tried <a href=\"http://linuxreviews.org/quicktips/wget/\" rel=\"nofollow noreferrer\">wget?</a></p>\n"
},... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79612",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13320/"
] | Looking for a `Linux application` *(or Firefox extension)* that will allow me to scrape an HTML mockup and keep the page's integrity.
Firefox does an almost perfect job but doesn't grab images referenced in the CSS.
The Scrapbook extension for Firefox gets everything, but flattens the directory structure.
I wouldn'... | See [Website Mirroring With wget](http://www.devarticles.com/c/a/Web-Services/Website-Mirroring-With-wget/1/)
```
wget --mirror –w 2 –p --HTML-extension –-convert-links http://www.yourdomain.com
``` |
79,632 | <p>I have a two tables joined with a join table - this is just pseudo code:</p>
<pre><code>Library
Book
LibraryBooks
</code></pre>
<p>What I need to do is if i have the id of a library, i want to get all the libraries that all the books that this library has are in.</p>
<p>So if i have Library 1, and Library 1 has b... | [
{
"answer_id": 79646,
"author": "Jim Puls",
"author_id": 6010,
"author_profile": "https://Stackoverflow.com/users/6010",
"pm_score": 2,
"selected": false,
"text": "<p>Perhaps:</p>\n\n<pre><code>l.books.map {|b| b.libraries}\n</code></pre>\n\n<p>or</p>\n\n<pre><code>l.books.map {|b| b.lib... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79632",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4322/"
] | I have a two tables joined with a join table - this is just pseudo code:
```
Library
Book
LibraryBooks
```
What I need to do is if i have the id of a library, i want to get all the libraries that all the books that this library has are in.
So if i have Library 1, and Library 1 has books A and B in them, and books A... | ```
l = Library.find(:all, :include => :books)
l.books.map { |b| b.library_ids }.flatten.uniq
```
Note that `map(&:library_ids)` is slower than `map { |b| b.library_ids }` in Ruby 1.8.6, and faster in 1.9.0.
I should also mention that if you used `:joins` instead of `include` there, it would find the library and rel... |
79,669 | <p>I need to copy about 40 databases from one server to another. The new databases should have new names, but all the same tables, data and indexes as the original databases. So far I've been: </p>
<p>1) creating each destination database<br>
2) using the "<a href="http://msdn.microsoft.com/en-us/library/ms140052.a... | [
{
"answer_id": 79673,
"author": "dimarzionist",
"author_id": 10778,
"author_profile": "https://Stackoverflow.com/users/10778",
"pm_score": 2,
"selected": false,
"text": "<p>Backup -> Restore is the simplest, if not to use the replication.</p>\n"
},
{
"answer_id": 79679,
"auth... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79669",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13728/"
] | I need to copy about 40 databases from one server to another. The new databases should have new names, but all the same tables, data and indexes as the original databases. So far I've been:
1) creating each destination database
2) using the "[Tasks->Export Data](http://msdn.microsoft.com/en-us/library/ms140052.asp... | Given that you're performing this on multiple databases -- you want a simple scripted solution, not a point and click solution.
This is a backup script that i keep around.
Get it working for one file and then modify it for many.
```
(on source server...)
BACKUP DATABASE Northwind
TO DISK = 'c:\Northwind.bak'
(tar... |
79,677 | <p>I need to speed up a program for the Nintendo DS which doesn't have an FPU, so I need to change floating-point math (which is emulated and slow) to fixed-point.</p>
<p>How I started was I changed floats to ints and whenever I needed to convert them, I used <strong>x>>8</strong> to convert the fixed-point variable x... | [
{
"answer_id": 79700,
"author": "jfm3",
"author_id": 11138,
"author_profile": "https://Stackoverflow.com/users/11138",
"pm_score": 0,
"selected": false,
"text": "<p>Whichever way you decide to go (I'd lean toward a typedef and some CPP macros for converting), you will need to be careful ... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79677",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/813/"
] | I need to speed up a program for the Nintendo DS which doesn't have an FPU, so I need to change floating-point math (which is emulated and slow) to fixed-point.
How I started was I changed floats to ints and whenever I needed to convert them, I used **x>>8** to convert the fixed-point variable x to the actual number a... | You can try my fixed point class (Latest available @ <https://github.com/eteran/cpp-utilities>)
```
// From: https://github.com/eteran/cpp-utilities/edit/master/Fixed.h
// See also: http://stackoverflow.com/questions/79677/whats-the-best-way-to-do-fixed-point-math
/*
* The MIT License (MIT)
*
* Copyright (c) 2015 ... |
79,688 | <p>What's the best way to calculate percentile rankings (e.g. the 90th percentile or the median score) in MSSQL 2005?</p>
<p>I'd like to be able to select the 25th, median, and 75th percentiles for a single column of scores (preferably in a single record so I can combine with average, max, and min). So for example, t... | [
{
"answer_id": 79758,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>i'd probably use a the sql server 2005 </p>\n\n<blockquote>\n <p>row_number() over (order by score ) / (select count(*) fr... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79688",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3420/"
] | What's the best way to calculate percentile rankings (e.g. the 90th percentile or the median score) in MSSQL 2005?
I'd like to be able to select the 25th, median, and 75th percentiles for a single column of scores (preferably in a single record so I can combine with average, max, and min). So for example, table output... | I would think that this would be the simplest solution:
```
SELECT TOP N PERCENT FROM TheTable ORDER BY TheScore DESC
```
Where N = (100 - desired percentile). So if you wanted all rows in the 90th percentile, you'd select the top 10%.
I'm not sure what you mean by "preferably in a single record". Do you mean calcu... |
79,693 | <p>How do you get all the classes in a namespace through reflection in C#?</p>
| [
{
"answer_id": 79706,
"author": "Ryan Farley",
"author_id": 1627,
"author_profile": "https://Stackoverflow.com/users/1627",
"pm_score": 5,
"selected": false,
"text": "<pre><code>using System.Reflection;\nusing System.Collections.Generic;\n//...\n\nstatic List<string> GetClasses(str... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79693",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How do you get all the classes in a namespace through reflection in C#? | Following code prints names of classes in specified `namespace` defined in current assembly.
As other guys pointed out, a namespace can be scattered between different modules, so you need to get a list of assemblies first.
```
string nspace = "...";
var q = from t in Assembly.GetExecutingAssembly().GetTypes()
... |
79,709 | <p>I have a function inside a loop inside a function. The inner function acquires and stores a large vector of data in memory (as a global variable... I'm using "R" which is like "S-Plus"). The loop loops through a long list of data to be acquired. The outer function starts the process and passes in the list of dataset... | [
{
"answer_id": 79741,
"author": "Jeffrey",
"author_id": 3259,
"author_profile": "https://Stackoverflow.com/users/3259",
"pm_score": -1,
"selected": false,
"text": "<p>It's tough to say definitively without knowing the language/compiler used. However, if you can simply pass a pointer/ref... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79709",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a function inside a loop inside a function. The inner function acquires and stores a large vector of data in memory (as a global variable... I'm using "R" which is like "S-Plus"). The loop loops through a long list of data to be acquired. The outer function starts the process and passes in the list of datasets t... | use variables in the outer function instead of global variables. This gets you the best of both approaches: you're not mutating global state, and you're not copying a big wad of data. If you have to exit early, just return the partial results.
(See the "Scope" section in the R manual: <http://cran.r-project.org/doc/ma... |
79,737 | <p>This question may be too product specifc but I'd like to know if anyone is exporting bug track data from HP Quality Center.</p>
<p>HP Quality Center (QC) has an old school COM API but I'd rather use a web service or maybe even screen scraper to export the data into an excel spreadsheet.</p>
<p>In any case, what's ... | [
{
"answer_id": 80813,
"author": "granth",
"author_id": 11210,
"author_profile": "https://Stackoverflow.com/users/11210",
"pm_score": 4,
"selected": true,
"text": "<p>You can use this QC API Code to modify bugs/requirements.</p>\n\n<pre><code>TDAPIOLELib.TDConnection connection = new TDAP... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79737",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3048/"
] | This question may be too product specifc but I'd like to know if anyone is exporting bug track data from HP Quality Center.
HP Quality Center (QC) has an old school COM API but I'd rather use a web service or maybe even screen scraper to export the data into an excel spreadsheet.
In any case, what's the best way to e... | You can use this QC API Code to modify bugs/requirements.
```
TDAPIOLELib.TDConnection connection = new TDAPIOLELib.TDConnection();
connection.InitConnectionEx("http://SERVER:8080/qcbin");
connection.Login("USERNAME", "PASSWORD");
connection.Connect("QCDOMAIN", "QCPROJECT");
TDAPIOLELib.BugFactory bugFactory = con... |
79,745 | <p>We have an application which needs to use Direct3D. Specifically, it needs at least DirectX 9.0c version 4.09.0000.0904. While this should be present on all newer XP machines it might not be installed on older XP machines. How can I programmatically (using C++) determine if it is installed? I want to be able to give... | [
{
"answer_id": 79801,
"author": "Adam Mitz",
"author_id": 2574,
"author_profile": "https://Stackoverflow.com/users/2574",
"pm_score": 0,
"selected": false,
"text": "<p>According to the DirectX 9.0 SDK (summer 2004) documentation, see the GetDXVer SDK sample at \\Samples\\Multimedia\\DXMi... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79745",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5022/"
] | We have an application which needs to use Direct3D. Specifically, it needs at least DirectX 9.0c version 4.09.0000.0904. While this should be present on all newer XP machines it might not be installed on older XP machines. How can I programmatically (using C++) determine if it is installed? I want to be able to give an... | Call DirectXSetupGetVersion: <http://msdn.microsoft.com/en-us/library/microsoft.directx_sdk.directsetup.directxsetupgetversion>
You'll need to include dsetup.h
Here's the sample code from the site:
```
DWORD dwVersion;
DWORD dwRevision;
if (DirectXSetupGetVersion(&dwVersion, &dwRevision))
{
printf("DirectX versi... |
79,754 | <p>No matter what I do sys.exit() is called by unittest, even the most trivial examples. I can't tell if my install is messed up or what is going on.</p>
<pre><code>IDLE 1.2.2 ==== No Subprocess ====
>>> import unittest
>>>
>>> class Test(unittest.TestCase):
def testA(self):
... | [
{
"answer_id": 79826,
"author": "Allen",
"author_id": 6043,
"author_profile": "https://Stackoverflow.com/users/6043",
"pm_score": 3,
"selected": false,
"text": "<p>Don't try to run <code>unittest.main()</code> from IDLE. It's trying to access <code>sys.argv</code>, and it's getting the a... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79754",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3176/"
] | No matter what I do sys.exit() is called by unittest, even the most trivial examples. I can't tell if my install is messed up or what is going on.
```
IDLE 1.2.2 ==== No Subprocess ====
>>> import unittest
>>>
>>> class Test(unittest.TestCase):
def testA(self):
a = 1
self.assertEq... | Your example is exiting on my install too. I can make it execute the tests and stay within Python by changing
```
unittest.main()
```
to
```
unittest.TextTestRunner().run(unittest.TestLoader().loadTestsFromTestCase(Test))
```
More information is available [here](http://docs.python.org/library/unittest.html#basic-... |
79,774 | <p>Ok - a bit of a mouthful. So the problem I have is this - I need to store a Date for expiry where <em>only</em> the date part is required and I don't want any timezone conversion. So for example if I have an expiry set to "08 March 2008" I want that value to be returned to any client - no matter what their timezone ... | [
{
"answer_id": 79792,
"author": "Yitzchok",
"author_id": 5723,
"author_profile": "https://Stackoverflow.com/users/5723",
"pm_score": 0,
"selected": false,
"text": "<p>You can send it as UTC Time</p>\n\n<p>dateTime1.ToUniversalTime()</p>\n"
},
{
"answer_id": 79810,
"author": "... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79774",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14871/"
] | Ok - a bit of a mouthful. So the problem I have is this - I need to store a Date for expiry where *only* the date part is required and I don't want any timezone conversion. So for example if I have an expiry set to "08 March 2008" I want that value to be returned to any client - no matter what their timezone is.
The p... | You could create a struct Date that provides access to the details you want/need, like:
```
public struct Date
{
public int Month; //or string instead of int
public int Day;
public int Year;
}
```
This is lightweight, flexible and gives you full control. |
79,780 | <p>I've had a new found interest in building a small, efficient web server in C and have had some trouble parsing POST methods from the HTTP Header. Would anyone have any advice as to how to handle retrieving the name/value pairs from the "posted" data?</p>
<pre><code>POST /test HTTP/1.1
Host: test-domain.com:7017
Use... | [
{
"answer_id": 79812,
"author": "Brian R. Bondy",
"author_id": 3153,
"author_profile": "https://Stackoverflow.com/users/3153",
"pm_score": 5,
"selected": true,
"text": "<p>You can retrieve the name/value pairs by searching for newline newline or more specifically \\r\\n\\r\\n (after this... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79780",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14877/"
] | I've had a new found interest in building a small, efficient web server in C and have had some trouble parsing POST methods from the HTTP Header. Would anyone have any advice as to how to handle retrieving the name/value pairs from the "posted" data?
```
POST /test HTTP/1.1
Host: test-domain.com:7017
User-Agent: Mozil... | You can retrieve the name/value pairs by searching for newline newline or more specifically \r\n\r\n (after this, the body of the message will start).
Then you can simply split the list by the &, and then split each of those returned strings between the = for name/value pairs.
See the [HTTP 1.1 RFC](https://www.rfc-e... |
79,789 | <p>I have a list of timesheet entries that show a start and stop time. This is sitting in a MySQL database. I need to create bar charts based on this data with the 24 hours of the day along the bottom and the amount of man-hours worked for each hour of the day.</p>
<p>For example, if Alice worked a job from 15:30 to 1... | [
{
"answer_id": 80125,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>I came up with a pseudocode solution, hope it helps.</p>\n\n<pre><code>create an array named timetable with 24 entries\ninit... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79789",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9867/"
] | I have a list of timesheet entries that show a start and stop time. This is sitting in a MySQL database. I need to create bar charts based on this data with the 24 hours of the day along the bottom and the amount of man-hours worked for each hour of the day.
For example, if Alice worked a job from 15:30 to 19:30 and B... | Create a table with just time in it from midnight to midnight containing each minute of the day. In the data warehouse world we would call this a time dimension. Here's an example:
```
TIME_DIM
-id
-time_of_day
-interval_15
-interval_30
```
an example of the data in the table would be
```
id time_of_day i... |
79,797 | <p>How do I convert a datetime <em>string in local time</em> to a <em>string in UTC time</em>?</p>
<p>I'm sure I've done this before, but can't find it and SO will hopefully help me (and others) do that in future.</p>
<p><strong>Clarification</strong>: For example, if I have <code>2008-09-17 14:02:00</code> in my lo... | [
{
"answer_id": 79808,
"author": "Chuck Callebs",
"author_id": 14877,
"author_profile": "https://Stackoverflow.com/users/14877",
"pm_score": 5,
"selected": false,
"text": "<pre><code>def local_to_utc(t):\n secs = time.mktime(t)\n return time.gmtime(secs)\n\ndef utc_to_local(t):\n ... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79797",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3715/"
] | How do I convert a datetime *string in local time* to a *string in UTC time*?
I'm sure I've done this before, but can't find it and SO will hopefully help me (and others) do that in future.
**Clarification**: For example, if I have `2008-09-17 14:02:00` in my local timezone (`+10`), I'd like to generate a string with... | Thanks @rofly, the full conversion from string to string is as follows:
```
import time
time.strftime("%Y-%m-%d %H:%M:%S",
time.gmtime(time.mktime(time.strptime("2008-09-17 14:04:00",
"%Y-%m-%d %H:%M:%S"))))
```
My summary of the `time`/`calendar` f... |
79,816 | <p>I'd like a short smallest possible javascript routine that when a mousedown occurs on a button it first responds just like a mouseclick and then if the user keeps the button pressed it responds as if the user was continously sending mouseclicks and after a while with the button held down acts as if the user was acce... | [
{
"answer_id": 79830,
"author": "Thomas",
"author_id": 14637,
"author_profile": "https://Stackoverflow.com/users/14637",
"pm_score": 2,
"selected": false,
"text": "<p>When the button is pressed, call <code>window.setTimeout</code> with your intended time and the function <code>x</code>, ... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79816",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14907/"
] | I'd like a short smallest possible javascript routine that when a mousedown occurs on a button it first responds just like a mouseclick and then if the user keeps the button pressed it responds as if the user was continously sending mouseclicks and after a while with the button held down acts as if the user was acceler... | ```
function holdit(btn, action, start, speedup) {
var t;
var repeat = function () {
action();
t = setTimeout(repeat, start);
start = start / speedup;
}
btn.mousedown = function() {
repeat();
}
btn.mouseup = function () {
clearTimeout(t);
}
};
/* t... |
79,843 | <p>The situation is this:</p>
<ul>
<li>You have a Hibernate context with an
object graph that has some lazy
loading defined. </li>
<li>You want to use
the Hibernate objects in your UI as
is without having to copy the data
somewhere. </li>
<li>There are different UI
contexts that require different
amounts of data. <... | [
{
"answer_id": 79933,
"author": "sirrocco",
"author_id": 5246,
"author_profile": "https://Stackoverflow.com/users/5246",
"pm_score": 3,
"selected": true,
"text": "<p>Let's say you have the Client and at one point you have to something with his Orders and maybe he has a Bonus for his Orde... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79843",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14893/"
] | The situation is this:
* You have a Hibernate context with an
object graph that has some lazy
loading defined.
* You want to use
the Hibernate objects in your UI as
is without having to copy the data
somewhere.
* There are different UI
contexts that require different
amounts of data.
* The data is too
big to just eage... | Let's say you have the Client and at one point you have to something with his Orders and maybe he has a Bonus for his Orders.
Then I would define a Repository with a fluent interface that will allow me to say something like :
```
new ClientRepo().LoadClientBy(id)
.WithOrders()
.WithBo... |
79,880 | <p>I'm looking for a variation on the <code>#save</code> method that will only save
attributes that do not have errors attached to them.
So a model can be updated without being valid overall, and this will
still prevent saving invalid data to the database.</p>
<p>By "valid attributes", I mean those attributes that ... | [
{
"answer_id": 79900,
"author": "Thomas",
"author_id": 14637,
"author_profile": "https://Stackoverflow.com/users/14637",
"pm_score": 3,
"selected": true,
"text": "<p>Since OpenSSL is Apache-licensed (i.e. BSD-style), you can simply distribute it as a DLL along with your application. (May... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79880",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14843/"
] | I'm looking for a variation on the `#save` method that will only save
attributes that do not have errors attached to them.
So a model can be updated without being valid overall, and this will
still prevent saving invalid data to the database.
By "valid attributes", I mean those attributes that give nil when calling... | Since OpenSSL is Apache-licensed (i.e. BSD-style), you can simply distribute it as a DLL along with your application. (Maybe build it yourself to have only the features you need and all in a single DLL.) Then use p/invoke calls to talk with this DLL.
(Maybe you can even link the native code straight into your .NET exe... |
79,935 | <p>Is there an equivalent to Java's Robot class (java.awt.Robot) for Perl?</p>
| [
{
"answer_id": 79976,
"author": "bmdhacks",
"author_id": 14032,
"author_profile": "https://Stackoverflow.com/users/14032",
"pm_score": 1,
"selected": false,
"text": "<p>There is on Linux/Unix:</p>\n\n<p><a href=\"http://sourceforge.net/projects/x11guitest\" rel=\"nofollow noreferrer\"><a... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79935",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14948/"
] | Is there an equivalent to Java's Robot class (java.awt.Robot) for Perl? | Alternatively, you can surely use the [WWW::Mechanize](http://search.cpan.org/~petdance/WWW-Mechanize-1.34/lib/WWW/Mechanize.pm) module to create an agent as we do here at work. We have a tool called AppMon that is really just a dramatized wrapper around Mechanize.
The Mechanize module allows you to use scripts that ... |
79,939 | <p>I have the following (pretty standard) table structure:</p>
<pre><code>Post <-> PostTag <-> Tag
</code></pre>
<p>Suppose I have the following records:</p>
<pre><code>PostID Title
1, 'Foo'
2, 'Bar'
3, 'Baz'
TagID Name
1, 'Foo'
2, 'Bar'
PostID TagID
1 1
1 2
2 2
</code>... | [
{
"answer_id": 79979,
"author": "sirrocco",
"author_id": 5246,
"author_profile": "https://Stackoverflow.com/users/5246",
"pm_score": 0,
"selected": false,
"text": "<p>I've answered this in another post : <a href=\"https://stackoverflow.com/questions/50169/optimizing-a-linq-to-sql-query#5... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79939",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have the following (pretty standard) table structure:
```
Post <-> PostTag <-> Tag
```
Suppose I have the following records:
```
PostID Title
1, 'Foo'
2, 'Bar'
3, 'Baz'
TagID Name
1, 'Foo'
2, 'Bar'
PostID TagID
1 1
1 2
2 2
```
In other words, the first post has two tags, the s... | Yay! It worked.
If anyone is having the same problem here's what I did:
```
public IList<Post> GetPosts(int page, int record)
{
var options = new DataLoadOptions();
options.LoadWith<Post>(p => p.PostTags);
options.LoadWith<PostTag>(pt => pt.Tag);
using (var db = new DatabaseDataContext(m_connectionSt... |
79,960 | <p>I have a code snippet written in PHP that pulls a block of text from a database and sends it out to a widget on a webpage. The original block of text can be a lengthy article or a short sentence or two; but for this widget I can't display more than, say, 200 characters. I could use substr() to chop off the text at... | [
{
"answer_id": 79986,
"author": "Grey Panther",
"author_id": 1265,
"author_profile": "https://Stackoverflow.com/users/1265",
"pm_score": 9,
"selected": true,
"text": "<p>By using the <a href=\"http://www.php.net/wordwrap\" rel=\"noreferrer\">wordwrap</a> function. It splits the texts in ... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79960",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14956/"
] | I have a code snippet written in PHP that pulls a block of text from a database and sends it out to a widget on a webpage. The original block of text can be a lengthy article or a short sentence or two; but for this widget I can't display more than, say, 200 characters. I could use substr() to chop off the text at 200 ... | By using the [wordwrap](http://www.php.net/wordwrap) function. It splits the texts in multiple lines such that the maximum width is the one you specified, breaking at word boundaries. After splitting, you simply take the first line:
```
substr($string, 0, strpos(wordwrap($string, $your_desired_width), "\n"));
```
On... |
79,968 | <p>I have a string which is like this:</p>
<pre><code>this is "a test"
</code></pre>
<p>I'm trying to write something in Python to split it up by space while ignoring spaces within quotes. The result I'm looking for is:</p>
<pre><code>['this', 'is', 'a test']
</code></pre>
<p>PS. I know you are going to ask &... | [
{
"answer_id": 79985,
"author": "Jerub",
"author_id": 14648,
"author_profile": "https://Stackoverflow.com/users/14648",
"pm_score": 10,
"selected": true,
"text": "<p>You want <code>split</code>, from the built-in <a href=\"https://docs.python.org/library/shlex.html\" rel=\"noreferrer\"><... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79968",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5324/"
] | I have a string which is like this:
```
this is "a test"
```
I'm trying to write something in Python to split it up by space while ignoring spaces within quotes. The result I'm looking for is:
```
['this', 'is', 'a test']
```
PS. I know you are going to ask "what happens if there are quotes within the quotes, wel... | You want `split`, from the built-in [`shlex`](https://docs.python.org/library/shlex.html) module.
```
>>> import shlex
>>> shlex.split('this is "a test"')
['this', 'is', 'a test']
```
This should do exactly what you want.
If you want to preserve the quotation marks, then you can pass the `posix=False` kwarg.
```
>... |
79,992 | <p>Ideally the reader has upgraded a native C++ program to Visual Studio 2008, which contains an OpenClipboard() block. Why not try setting a breakpoint just after getting a successful return-code from OpenClipboard() and step through your code. According to the Internet it may work on your system, but of course, not... | [
{
"answer_id": 79985,
"author": "Jerub",
"author_id": 14648,
"author_profile": "https://Stackoverflow.com/users/14648",
"pm_score": 10,
"selected": true,
"text": "<p>You want <code>split</code>, from the built-in <a href=\"https://docs.python.org/library/shlex.html\" rel=\"noreferrer\"><... | 2008/09/17 | [
"https://Stackoverflow.com/questions/79992",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10972/"
] | Ideally the reader has upgraded a native C++ program to Visual Studio 2008, which contains an OpenClipboard() block. Why not try setting a breakpoint just after getting a successful return-code from OpenClipboard() and step through your code. According to the Internet it may work on your system, but of course, not on m... | You want `split`, from the built-in [`shlex`](https://docs.python.org/library/shlex.html) module.
```
>>> import shlex
>>> shlex.split('this is "a test"')
['this', 'is', 'a test']
```
This should do exactly what you want.
If you want to preserve the quotation marks, then you can pass the `posix=False` kwarg.
```
>... |
80,031 | <p>I have a asp:menu object which I set up to use a <em>SiteMapDataSource</em> but everytime I try to run the site, I get a yellow screen from firefox saying it cannot find the <code>web.sitemap</code>. Here's the code for the <em>sitemapdatasource</em> and the menu. The Web.sitemap file is sitting in the root director... | [
{
"answer_id": 80060,
"author": "Encoder",
"author_id": 14629,
"author_profile": "https://Stackoverflow.com/users/14629",
"pm_score": 3,
"selected": true,
"text": "<p>I had a similar problem where I was specifying the path to the SiteMap from within my DataSource control. I tried removin... | 2008/09/17 | [
"https://Stackoverflow.com/questions/80031",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4298/"
] | I have a asp:menu object which I set up to use a *SiteMapDataSource* but everytime I try to run the site, I get a yellow screen from firefox saying it cannot find the `web.sitemap`. Here's the code for the *sitemapdatasource* and the menu. The Web.sitemap file is sitting in the root directory of the website.
```
<div>... | I had a similar problem where I was specifying the path to the SiteMap from within my DataSource control. I tried removing it and it worked.
Try removing the path from the SiteMapDataSource and ensure that web.sitemap is in the root directory and see if that fixes it. |
80,042 | <p>Can you provide an example of a byte buffer transferred between two java classes via UDP datagram?</p>
| [
{
"answer_id": 80071,
"author": "Dave Cheney",
"author_id": 6449,
"author_profile": "https://Stackoverflow.com/users/6449",
"pm_score": 3,
"selected": true,
"text": "<p>Hows' this ?</p>\n\n<pre>\nimport java.io.IOException;\nimport java.net.DatagramPacket;\nimport java.net.DatagramSocket... | 2008/09/17 | [
"https://Stackoverflow.com/questions/80042",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Can you provide an example of a byte buffer transferred between two java classes via UDP datagram? | Hows' this ?
```
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetSocketAddress;
public class Server {
public static void main(String[] args) throws IOException {
DatagramSocket socket = new DatagramSocket(new InetSocketAddress(5000));
... |
80,084 | <p>In JavaScript, the "this" operator can refer to different things under different scenarios. </p>
<p>Typically in a method within a JavaScript "object", it refers to the current object.</p>
<p>But when used as a callback, it becomes a reference to the calling object.</p>
<p>I have found that this causes problems i... | [
{
"answer_id": 80095,
"author": "Ash",
"author_id": 5023,
"author_profile": "https://Stackoverflow.com/users/5023",
"pm_score": 0,
"selected": false,
"text": "<p>I believe this may be due to how the idea of [closures](<a href=\"http://en.wikipedia.org/wiki/Closure_(computer_science)\" re... | 2008/09/17 | [
"https://Stackoverflow.com/questions/80084",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | In JavaScript, the "this" operator can refer to different things under different scenarios.
Typically in a method within a JavaScript "object", it refers to the current object.
But when used as a callback, it becomes a reference to the calling object.
I have found that this causes problems in code, because if you u... | In JavaScript, `this` always refers to the object invoking the function that is being executed. So if the function is being used as an event handler, `this` will refer to the node that fired the event. But if you have an object and call a function on it like:
```
myObject.myFunction();
```
Then `this` inside `myFunc... |
80,152 | <p>What are the potential pros and cons of each of these queries given different databases, configurations, etc? Is there ever a time when one would be more efficient than the other? Vice versa? Is there an even better way to do it? Can you explain why?</p>
<p>Query 1:</p>
<pre><code>SELECT
*
FROM
table_a, t... | [
{
"answer_id": 80169,
"author": "Encoder",
"author_id": 14629,
"author_profile": "https://Stackoverflow.com/users/14629",
"pm_score": -1,
"selected": false,
"text": "<p>I agree, it's sounding a bit too much like Homework!</p>\n\n<p>If it isn't homework then I guess the simplest answer is... | 2008/09/17 | [
"https://Stackoverflow.com/questions/80152",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | What are the potential pros and cons of each of these queries given different databases, configurations, etc? Is there ever a time when one would be more efficient than the other? Vice versa? Is there an even better way to do it? Can you explain why?
Query 1:
```
SELECT
*
FROM
table_a, table_b, table_c
WHERE
t... | Same query, different revision of SQL spec. The query optimizer should come up with the same query plan for those. |
80,175 | <p>This is somewhat similar to <a href="https://stackoverflow.com/questions/25653/hide-a-column-in-aspnet-dynamic-data">this question</a>.</p>
<p>However, rather than wanting to hide a column all together, I am just looking to hide the column on the List.aspx page.</p>
<p>My specific example is that fields that are l... | [
{
"answer_id": 81806,
"author": "Mark Pattison",
"author_id": 15519,
"author_profile": "https://Stackoverflow.com/users/15519",
"pm_score": 4,
"selected": true,
"text": "<p>You can create a custom page for the particular table you want to change. There's an example <a href=\"http://davi... | 2008/09/17 | [
"https://Stackoverflow.com/questions/80175",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/364/"
] | This is somewhat similar to [this question](https://stackoverflow.com/questions/25653/hide-a-column-in-aspnet-dynamic-data).
However, rather than wanting to hide a column all together, I am just looking to hide the column on the List.aspx page.
My specific example is that fields that are long (or at least nvarchar(MA... | You can create a custom page for the particular table you want to change. There's an example [here](http://davidhayden.com/blog/dave/archive/2007/12/30/ASPNETDynamicDataWebsitesCustomizingPagesValidation.aspx).
Within your custom page, you can then set `AutoGenerateColumns="false"` within the `asp:GridView` control, a... |
80,186 | <p>I can't seem to find much documentation on X-Sendfile or example code for PHP (there is some rails code).</p>
<p>Anyone used it before and would mind giving a quick snippet of code and a brief description?</p>
| [
{
"answer_id": 80201,
"author": "Don Neufeld",
"author_id": 13097,
"author_profile": "https://Stackoverflow.com/users/13097",
"pm_score": 5,
"selected": false,
"text": "<p>X-Sendfile is an HTTP header, so you want something like this:</p>\n\n<pre><code>header(\"X-Sendfile: $filename\");\... | 2008/09/17 | [
"https://Stackoverflow.com/questions/80186",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I can't seem to find much documentation on X-Sendfile or example code for PHP (there is some rails code).
Anyone used it before and would mind giving a quick snippet of code and a brief description? | X-Sendfile is an HTTP header, so you want something like this:
```
header("X-Sendfile: $filename");
```
Your web server picks it up if correctly configured. Here's some more details:
<http://www.jasny.net/articles/how-i-php-x-sendfile/> |
80,195 | <p>I would like to make 2 TB or so available via NFS and CIFS. I am looking for a 2 (or more) server solution for high availability and the ability to load balance across the servers if possible. Any suggestions for clustering or high availability solutions?</p>
<p>This is business use, planning on growing to 5-10 TB ... | [
{
"answer_id": 80211,
"author": "David Ackerman",
"author_id": 2504,
"author_profile": "https://Stackoverflow.com/users/2504",
"pm_score": 0,
"selected": false,
"text": "<p>Are you looking for an \"enterprise\" solution or a \"home\" solution? It is hard to tell from your question, beca... | 2008/09/17 | [
"https://Stackoverflow.com/questions/80195",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15020/"
] | I would like to make 2 TB or so available via NFS and CIFS. I am looking for a 2 (or more) server solution for high availability and the ability to load balance across the servers if possible. Any suggestions for clustering or high availability solutions?
This is business use, planning on growing to 5-10 TB over next ... | I've recently deployed hanfs using DRBD as the backend, in my situation, I'm running active/standby mode, but I've tested it successfully using OCFS2 in primary/primary mode too. There unfortunately isn't much documentation out there on how best to achieve this, most that exists is barely useful at best. If you do go a... |
80,202 | <p>I want to use javascript to insert some elements into the current page.
Such as this is the original document:
<p>Hello world!</p></p>
<p>Now I want to insert an element in to the text so that it will become:</p>
<p><p>Hello <span id=span1>new</span> world!</p></p>
<p>I need th... | [
{
"answer_id": 80228,
"author": "Sev",
"author_id": 83819,
"author_profile": "https://Stackoverflow.com/users/83819",
"pm_score": 0,
"selected": false,
"text": "<p>Include the class definition that's defined in CSS on your JavaScript version of the <code><span></code> tag as well.<... | 2008/09/17 | [
"https://Stackoverflow.com/questions/80202",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15023/"
] | I want to use javascript to insert some elements into the current page.
Such as this is the original document:
<p>Hello world!</p>
Now I want to insert an element in to the text so that it will become:
<p>Hello <span id=span1>new</span> world!</p>
I need the span tag because I want to handle it later.Show or hide.
B... | Simply override any span styles. Set layout properties back to browser defaults and set formating to inherit from the parent:
```
span#yourSpan {
/* defaults */
position: static;
display: inline;
margin: 0;
padding: 0;
background: transparent;
border: none;
/* inherit from parent node */
font: inher... |
80,247 | <p>How can I get all implementations of an interface through reflection in C#?</p>
| [
{
"answer_id": 80325,
"author": "Alex Duggleby",
"author_id": 5790,
"author_profile": "https://Stackoverflow.com/users/5790",
"pm_score": 1,
"selected": false,
"text": "<p>Do you mean all interfaces a Type implements?</p>\n\n<p>Like this:</p>\n\n<pre><code>ObjX foo = new ObjX();\nType tF... | 2008/09/17 | [
"https://Stackoverflow.com/questions/80247",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How can I get all implementations of an interface through reflection in C#? | The answer is this; it searches through the entire application domain -- that is, every assembly currently loaded by your application.
```
/// <summary>
/// Returns all types in the current AppDomain implementing the interface or inheriting the type.
/// </summary>
public static IEnumerable<Type> TypesImplementingInt... |
80,278 | <p>I am trying to use the Google Maps API in a ColdFusion template that is a border type cflayoutarea container. However, the map simply doesn't show up:</p>
<pre><code><cfif isdefined("url.lat")>
<cfset lat="#url.lat#">
<cfset lng="#url.lng#">
</cfif>
<head>
<script src= ... | [
{
"answer_id": 80298,
"author": "convex hull",
"author_id": 10747,
"author_profile": "https://Stackoverflow.com/users/10747",
"pm_score": 0,
"selected": false,
"text": "<p>Maybe the layout area doesn't have the right <strong>style</strong>. I think you may have to give the map_canvas a<... | 2008/09/17 | [
"https://Stackoverflow.com/questions/80278",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15007/"
] | I am trying to use the Google Maps API in a ColdFusion template that is a border type cflayoutarea container. However, the map simply doesn't show up:
```
<cfif isdefined("url.lat")>
<cfset lat="#url.lat#">
<cfset lng="#url.lng#">
</cfif>
<head>
<script src= "http://maps.google.com/m... | Success! (sort of...)
Finally got it working, but not in the way Adam suggested:
```
<script src= "http://maps.google.com/maps?file=api&v=2&key=xxxx" type="text/javascript"></script>
<script type="text/javascript">
getMap=function(lat,lng){
if (GBrowserIsCompatible()){
v... |
80,291 | <p>In Sql Server 2000/2005, I have a few NT user groups that need to be granted access to hundreds of stored procedures.</p>
<p>Is there a nice easy way to do that?</p>
| [
{
"answer_id": 80340,
"author": "Leon Bambrick",
"author_id": 49,
"author_profile": "https://Stackoverflow.com/users/49",
"pm_score": 2,
"selected": false,
"text": "<ul>\n<li>Create a role in sql server.</li>\n<li>Write a\nscript that grants that role\npermission to use those sprocs.</li... | 2008/09/17 | [
"https://Stackoverflow.com/questions/80291",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3276/"
] | In Sql Server 2000/2005, I have a few NT user groups that need to be granted access to hundreds of stored procedures.
Is there a nice easy way to do that? | Here's a script that I use for granting permissions to lots of procedures:
```
DECLARE @DB sysname ; set @DB = DB_NAME()
DECLARE @U sysname ; set @U = QUOTENAME('UserID')
DECLARE @ID integer,
@LAST_ID integer,
@NAME varchar(1000),
@SQL varchar(4000)
SET @LAST_ID... |
80,292 | <p>I was writing a database handler class in PHP using the mysqli class and prepared statements. I was attempting to print out the result. It didn't work right off the bat so I decided to do some debugging. I tried to use the <code>num_rows()</code> method from the <code>mysqli_statement</code> class, but it kept re... | [
{
"answer_id": 80382,
"author": "Cetra",
"author_id": 15087,
"author_profile": "https://Stackoverflow.com/users/15087",
"pm_score": -1,
"selected": false,
"text": "<p>It doesn't look like you've declared $name.</p>\n\n<p>Also, try removing bind_result() and fetch() so it reads something ... | 2008/09/17 | [
"https://Stackoverflow.com/questions/80292",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3831/"
] | I was writing a database handler class in PHP using the mysqli class and prepared statements. I was attempting to print out the result. It didn't work right off the bat so I decided to do some debugging. I tried to use the `num_rows()` method from the `mysqli_statement` class, but it kept returning 0. I decided to writ... | I wonder if num\_rows() is reporting relative to the current resultset. Try capturing num\_rows() prior to fetching the data. e.g.
```
if($statement->prepare($query))
{
$statement->execute();
$statement->store_result();
echo $statement->num_rows();
$statement->bind_result($name);
$statement->fetch(... |
80,307 | <p>I've read in a couple of places that the desktop wallpaper can be set to an HTML document. Has anyone had any success changing it programmatically? </p>
<p>The following snippet of VB6 helps me set things up for BMPs but when I try to use it for HTML, I get a nice blue background and nothing else.</p>
<pre><code>D... | [
{
"answer_id": 80334,
"author": "Blorgbeard",
"author_id": 369,
"author_profile": "https://Stackoverflow.com/users/369",
"pm_score": 2,
"selected": false,
"text": "<p>I think you need to make sure \"Active Desktop\" is turned on.</p>\n\n<p>You might try setting <code>HKCU\\Software\\Micr... | 2008/09/17 | [
"https://Stackoverflow.com/questions/80307",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/426/"
] | I've read in a couple of places that the desktop wallpaper can be set to an HTML document. Has anyone had any success changing it programmatically?
The following snippet of VB6 helps me set things up for BMPs but when I try to use it for HTML, I get a nice blue background and nothing else.
```
Dim reg As New StdRegi... | I'm not sure if there's an official API for this, but if you have your heart set on it you could use Sysinternal's [Process Monitor](http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx) and see what registry keys get touched when you set an HTML desktop background via the UI. Then you'd just need to repeat th... |
80,319 | <p>I have video durations stored in HH:MM:SS format. I'd like to display it as HH hours, MM minutes, SS seconds. It shouldn't display hours if it's less than 1.</p>
<p>What would be the best approach?</p>
| [
{
"answer_id": 80366,
"author": "Mladen Mihajlovic",
"author_id": 11421,
"author_profile": "https://Stackoverflow.com/users/11421",
"pm_score": 2,
"selected": false,
"text": "<p>Something like this?</p>\n\n<pre><code>$vals = explode(':', $duration);\n\nif ( $vals[0] == 0 )\n $result = ... | 2008/09/17 | [
"https://Stackoverflow.com/questions/80319",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have video durations stored in HH:MM:SS format. I'd like to display it as HH hours, MM minutes, SS seconds. It shouldn't display hours if it's less than 1.
What would be the best approach? | try using split
```
list($hh,$mm,$ss)= split(':',$duration);
``` |
80,348 | <p>In C++0x I would like to write a function like this:</p>
<pre><code>template <typename... Types>
void fun(typename std::tuple<Types...> my_tuple) {
//Put things into the tuple
}
</code></pre>
<p>I first tried to use a for loop on <code>int i</code> and then do:</p>
<pre><code>get<i>(my_tuple... | [
{
"answer_id": 80573,
"author": "Adam Mitz",
"author_id": 2574,
"author_profile": "https://Stackoverflow.com/users/2574",
"pm_score": 3,
"selected": true,
"text": "<p>Since the \"i\" in</p>\n\n<pre><code>get<i>(tup)\n</code></pre>\n\n<p>needs to be a compile-time constant, template... | 2008/09/17 | [
"https://Stackoverflow.com/questions/80348",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | In C++0x I would like to write a function like this:
```
template <typename... Types>
void fun(typename std::tuple<Types...> my_tuple) {
//Put things into the tuple
}
```
I first tried to use a for loop on `int i` and then do:
```
get<i>(my_tuple);
```
And then store some value in the result. However, `get` o... | Since the "i" in
```
get<i>(tup)
```
needs to be a compile-time constant, template instantiation is used to "iterate" (actually recurse) through the values. Boost tuples have the "length" and "element" meta-functions that can be helpful here -- I assume C++0x has these too. |
80,357 | <p>Is there a quick way to find every match of a regular expression in Ruby? I've looked through the Regex object in the Ruby STL and searched on Google to no avail.</p>
| [
{
"answer_id": 80387,
"author": "Jean",
"author_id": 7898,
"author_profile": "https://Stackoverflow.com/users/7898",
"pm_score": 11,
"selected": true,
"text": "<p>Using <a href=\"http://ruby-doc.org/core-1.9.3/String.html#method-i-scan\" rel=\"noreferrer\"><code>scan</code></a> should do... | 2008/09/17 | [
"https://Stackoverflow.com/questions/80357",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/422/"
] | Is there a quick way to find every match of a regular expression in Ruby? I've looked through the Regex object in the Ruby STL and searched on Google to no avail. | Using [`scan`](http://ruby-doc.org/core-1.9.3/String.html#method-i-scan) should do the trick:
```
string.scan(/regex/)
``` |
80,388 | <p>I'm trying to trigger a progress animation when ever the ViewModel/Presentation Model is Busy. I have an IsBusy Property, and the ViewModel is set as the DataContext of the UserControl. What is the best way to trigger a "progressAnimation" storyboard when the IsBusy property is true? Blend only lets me add... | [
{
"answer_id": 80455,
"author": "Jobi Joy",
"author_id": 8091,
"author_profile": "https://Stackoverflow.com/users/8091",
"pm_score": 1,
"selected": false,
"text": "<p>I would recommend to use RoutedEvent instead of your IsBusy property. Just fire OnBusyStarted and OnBusyStopped event and... | 2008/09/17 | [
"https://Stackoverflow.com/questions/80388",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1199387/"
] | I'm trying to trigger a progress animation when ever the ViewModel/Presentation Model is Busy. I have an IsBusy Property, and the ViewModel is set as the DataContext of the UserControl. What is the best way to trigger a "progressAnimation" storyboard when the IsBusy property is true? Blend only lets me add event trigge... | What you want is possible by declaring the animation on the progressWheel itself:
The XAML:
```
<UserControl x:Class="TriggerSpike.UserControl1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="300" Width="300">
<UserControl.Resources>
... |
80,415 | <p>I have a string which starts with <code>//#...</code> goes upto the newline characater. I have figured out the regex for the which is this <code>..#([^\n]*)</code>.</p>
<p>My question is how do you remove this line from a file if the following condition matches</p>
| [
{
"answer_id": 80444,
"author": "EricSchaefer",
"author_id": 8976,
"author_profile": "https://Stackoverflow.com/users/8976",
"pm_score": 0,
"selected": false,
"text": "<p>Read the file line by line and only write those lines to a new file that don't match the regex.\nYou cannot just remo... | 2008/09/17 | [
"https://Stackoverflow.com/questions/80415",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13046/"
] | I have a string which starts with `//#...` goes upto the newline characater. I have figured out the regex for the which is this `..#([^\n]*)`.
My question is how do you remove this line from a file if the following condition matches | Your regex is badly chosen on several points:
1. Instead of matching two slashes specifically, you use `..` to match two characters that can be anything at all, presumably because you don’t know how to match slashes when you’re also using them as delimiters. (Actually, dots match *almost* anything, as we’ll see in #3.... |
80,424 | <p>I have a few models that need to have custom find conditions placed on them. For example, if I have a Contact model, every time Contact.find is called, I want to restrict the contacts returned that only belong to the Account in use.</p>
<p>I found this via Google (which I've customized a little):</p>
<pre><code>d... | [
{
"answer_id": 80440,
"author": "Jean",
"author_id": 7898,
"author_profile": "https://Stackoverflow.com/users/7898",
"pm_score": 4,
"selected": true,
"text": "<p>You don't tell us which version of rails you are using [edit - it is on rails 2.1 thus following advice is fully operational],... | 2008/09/17 | [
"https://Stackoverflow.com/questions/80424",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14530/"
] | I have a few models that need to have custom find conditions placed on them. For example, if I have a Contact model, every time Contact.find is called, I want to restrict the contacts returned that only belong to the Account in use.
I found this via Google (which I've customized a little):
```
def self.find(*args)
... | You don't tell us which version of rails you are using [edit - it is on rails 2.1 thus following advice is fully operational], but I would recommand you use the following form instead of overloading find yourself :
```
account.contacts.find(...)
```
this will automatically wrap the find in a scope where the user c... |
80,427 | <p>Code I have:</p>
<pre><code>cell_val = CStr(Nz(fld.value, ""))
Dim iter As Long
For iter = 0 To Len(cell_val) - 1 Step 1
If Asc(Mid(cell_val, iter, 1)) > 127 Then
addlog "Export contains ascii character > 127"
End If
Next iter
</code></pre>
<p>This code doesn't work. Anyone know how to do thi... | [
{
"answer_id": 80457,
"author": "jan.vdbergh",
"author_id": 9540,
"author_profile": "https://Stackoverflow.com/users/9540",
"pm_score": 5,
"selected": true,
"text": "<p>I believe your problem is that in VBA string indexes start at 1 and not at 0. Try the following:</p>\n\n<pre><code>For ... | 2008/09/17 | [
"https://Stackoverflow.com/questions/80427",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/924607/"
] | Code I have:
```
cell_val = CStr(Nz(fld.value, ""))
Dim iter As Long
For iter = 0 To Len(cell_val) - 1 Step 1
If Asc(Mid(cell_val, iter, 1)) > 127 Then
addlog "Export contains ascii character > 127"
End If
Next iter
```
This code doesn't work. Anyone know how to do this? I've simply got no idea with ... | I believe your problem is that in VBA string indexes start at 1 and not at 0. Try the following:
```
For iter = 1 To Len(cell_val)
If Asc(Mid(cell_val, iter, 1)) > 127 Then
addlog "Export contains ascii character > 127"
End If
Next
``` |
80,476 | <p>I need to concatenate two <code>String</code> arrays in Java.</p>
<pre><code>void f(String[] first, String[] second) {
String[] both = ???
}
</code></pre>
<p>Which is the easiest way to do this?</p>
| [
{
"answer_id": 80503,
"author": "jeannicolas",
"author_id": 14981,
"author_profile": "https://Stackoverflow.com/users/14981",
"pm_score": 10,
"selected": false,
"text": "<p>Here's a simple method that will concatenate two arrays and return the result:</p>\n\n<pre><code>public <T> T... | 2008/09/17 | [
"https://Stackoverflow.com/questions/80476",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2948/"
] | I need to concatenate two `String` arrays in Java.
```
void f(String[] first, String[] second) {
String[] both = ???
}
```
Which is the easiest way to do this? | Here's a simple method that will concatenate two arrays and return the result:
```
public <T> T[] concatenate(T[] a, T[] b) {
int aLen = a.length;
int bLen = b.length;
@SuppressWarnings("unchecked")
T[] c = (T[]) Array.newInstance(a.getClass().getComponentType(), aLen + bLen);
System.arraycopy(a, ... |
80,486 | <p>I need to know how to turn on Code Coverage when running TFS builds on a solution with a .testrunconfig file. </p>
<p>There is an option in the testrunconfig file that is for code coverage, but when running a TFS build there is no code coverage results.</p>
<p>I am running my tests using the *Tests.dll mask and N... | [
{
"answer_id": 80600,
"author": "Martin Woodward",
"author_id": 6438,
"author_profile": "https://Stackoverflow.com/users/6438",
"pm_score": 5,
"selected": true,
"text": "<p>How are you running the tests? Are you using a .vsmdi file or just specifying that you run all tests in *Tests.dll... | 2008/09/17 | [
"https://Stackoverflow.com/questions/80486",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5132/"
] | I need to know how to turn on Code Coverage when running TFS builds on a solution with a .testrunconfig file.
There is an option in the testrunconfig file that is for code coverage, but when running a TFS build there is no code coverage results.
I am running my tests using the \*Tests.dll mask and NOT using Test Lis... | How are you running the tests? Are you using a .vsmdi file or just specifying that you run all tests in \*Tests.dll assemblies?
If it is the latter and you are using TFS 2008, then you need to add the following to the and of the first PropertyGroup in your TFSBuild.proj file for the build.
```
<RunConfigFile>$(Soluti... |
80,493 | <p>In C, using the standard Windows API, what is the best way to read an unformatted disk? Specifically, I have an <a href="http://en.wikipedia.org/wiki/MultiMediaCard" rel="nofollow noreferrer">MMC</a> or <a href="http://en.wikipedia.org/wiki/Secure_Digital_card" rel="nofollow noreferrer">SD card</a> with data, but no... | [
{
"answer_id": 80533,
"author": "Kasprzol",
"author_id": 5957,
"author_profile": "https://Stackoverflow.com/users/5957",
"pm_score": 1,
"selected": false,
"text": "<p>You have to open the device file with <a href=\"http://msdn.microsoft.com/en-us/library/aa363858(VS.85).aspx\" rel=\"nofo... | 2008/09/17 | [
"https://Stackoverflow.com/questions/80493",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3175/"
] | In C, using the standard Windows API, what is the best way to read an unformatted disk? Specifically, I have an [MMC](http://en.wikipedia.org/wiki/MultiMediaCard) or [SD card](http://en.wikipedia.org/wiki/Secure_Digital_card) with data, but no file system (not FAT16, not FAT32, just raw data). If there was a simple way... | I would go with
```
HANDLE drive = CreateFile(_T("\\.\PhysicalDrive0"), GENERIC_READ, FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0);
// error handling
DWORD br = 0;
DISK_GEOMETRY dg;
DeviceIOControl(drive, IOCTL_DISK_GET_DRIVE_GEOMETRY, 0, 0, &dg, sizeof(dg), &br, 0);
//
LARGE_INTEGER pos;
pos.QuadPart = static_cast<LONGL... |
80,541 | <p>The title is pretty much self explanatory. Given two dates what is the best way of finding the number of week days using PHP? Week days being Monday to Friday.</p>
<p>For instance, how would I find out that there are 10 week days in between <code>31/08/2008</code> and <code>13/09/2008</code>?</p>
| [
{
"answer_id": 80553,
"author": "erlando",
"author_id": 4192,
"author_profile": "https://Stackoverflow.com/users/4192",
"pm_score": 0,
"selected": false,
"text": "<p>One way would be to convert the dates to unix timestamps using strtotime(...), subtracting the results and div'ing with 86... | 2008/09/17 | [
"https://Stackoverflow.com/questions/80541",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/131/"
] | The title is pretty much self explanatory. Given two dates what is the best way of finding the number of week days using PHP? Week days being Monday to Friday.
For instance, how would I find out that there are 10 week days in between `31/08/2008` and `13/09/2008`? | ```
$datefrom = strtotime($datefrom, 0);
$dateto = strtotime($dateto, 0);
$difference = $dateto - $datefrom;
$days_difference = floor($difference / 86400);
$weeks_difference = floor($days_difference / 7); // Complete weeks
$first_day = date("w", $datefrom);
$da... |
80,592 | <pre><code>public class Test {
public static void main(String[] args) {
}
}
class Outer {
void aMethod() {
class MethodLocalInner {
void bMethod() {
System.out.println("Inside method-local bMethod");
}
}
}
}
</code></pre>
<p>Can someone tell me ... | [
{
"answer_id": 80615,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 4,
"selected": true,
"text": "<p>You can only instantiate <code>MethodLocalInner</code> within <code>aMethod</code>. So do </p>\n\n<pre><code>void aMethod() {... | 2008/09/17 | [
"https://Stackoverflow.com/questions/80592",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11193/"
] | ```
public class Test {
public static void main(String[] args) {
}
}
class Outer {
void aMethod() {
class MethodLocalInner {
void bMethod() {
System.out.println("Inside method-local bMethod");
}
}
}
}
```
Can someone tell me how to print the me... | You can only instantiate `MethodLocalInner` within `aMethod`. So do
```
void aMethod() {
class MethodLocalInner {
void bMethod() {
System.out.println("Inside method-local bMethod");
}
}
MethodLocalInner foo = new MethodLocalInner(); // Default Constructor
... |
80,593 | <p>I have a FlowDocument in a standard WPF application window where I have some text, and in this text some hyperlinks and buttons.</p>
<p>The problem is, if I put this FlowDocument inside anything <strong>except</strong> a <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.flowdocumentpageviewer.... | [
{
"answer_id": 80757,
"author": "Jobi Joy",
"author_id": 8091,
"author_profile": "https://Stackoverflow.com/users/8091",
"pm_score": 0,
"selected": false,
"text": "<p>I am wondering whether you expecing some thing like this?</p>\n\n<pre><code><TextBlock>\n<Hyperlink>\n <... | 2008/09/17 | [
"https://Stackoverflow.com/questions/80593",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8521/"
] | I have a FlowDocument in a standard WPF application window where I have some text, and in this text some hyperlinks and buttons.
The problem is, if I put this FlowDocument inside anything **except** a [FlowDocumentPageViewer](http://msdn.microsoft.com/en-us/library/system.windows.controls.flowdocumentpageviewer.aspx) ... | I'm using a FlowDocumentScrollViewer for my about box:
```
<FlowDocumentScrollViewer VerticalScrollBarVisibility="Auto">
<FlowDocument>
<Paragraph>
<!-- ... -->
```
I don't have any of the controls or issues you mention. |
80,609 | <p>I need to "merge" two XML documents, overwriting the overlapsed attributes and elements. For instance if I have <strong>document1</strong>:</p>
<pre><code><mapping>
<key value="assigned">
<a/>
</key>
<whatever attribute="x">
<k/>
<j/>
... | [
{
"answer_id": 80656,
"author": "moobaa",
"author_id": 3569,
"author_profile": "https://Stackoverflow.com/users/3569",
"pm_score": 1,
"selected": false,
"text": "<p>Unsure as to whether you want to do this programatically or not.</p>\n\n<p>Edit: Ah, I posted that before the Edit. Don't I... | 2008/09/17 | [
"https://Stackoverflow.com/questions/80609",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4690/"
] | I need to "merge" two XML documents, overwriting the overlapsed attributes and elements. For instance if I have **document1**:
```
<mapping>
<key value="assigned">
<a/>
</key>
<whatever attribute="x">
<k/>
<j/>
</whatever>
</mapping>
```
and **document2**:
```
<mapping>
<... | If you like XSLT, there's a nice merge script I've used before at:
[Oliver's XSLT page](http://web.archive.org/web/20160809092524/http://www2.informatik.hu-berlin.de/~obecker/XSLT/) |
80,619 | <p>While refactoring some old code I have stripped out a number of public methods that should actually of been statics as they a) don't operate on any member data or call any other member functions and b) because they might prove useful elsewhere.</p>
<p>This led me to think about the best way to group 'helper' functi... | [
{
"answer_id": 80636,
"author": "Don Neufeld",
"author_id": 13097,
"author_profile": "https://Stackoverflow.com/users/13097",
"pm_score": 2,
"selected": false,
"text": "<p>The main advantage to using a namespace is that you can reopen it and add more stuff later, you can't do that with a... | 2008/09/17 | [
"https://Stackoverflow.com/questions/80619",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9236/"
] | While refactoring some old code I have stripped out a number of public methods that should actually of been statics as they a) don't operate on any member data or call any other member functions and b) because they might prove useful elsewhere.
This led me to think about the best way to group 'helper' functions togeth... | Overhead is not an issue, namespaces have some advantages though
* You can reopen a namespace in another header, grouping things more logically while
keeping compile dependencies low
* You can use namespace aliasing to your advantage
(debug/release, platform specific helpers, ....)
e.g. I've done stuff like
```
nam... |
80,650 | <p>How do I register a custom protocol with Windows so that when clicking a link in an email or on a web page my application is opened and the parameters from the URL are passed to it?</p>
| [
{
"answer_id": 81954,
"author": "MSalters",
"author_id": 15416,
"author_profile": "https://Stackoverflow.com/users/15416",
"pm_score": 5,
"selected": false,
"text": "<p>The MSDN link is nice, but the security information there isn't complete. The handler registration should contain \"%1\... | 2008/09/17 | [
"https://Stackoverflow.com/questions/80650",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2189521/"
] | How do I register a custom protocol with Windows so that when clicking a link in an email or on a web page my application is opened and the parameters from the URL are passed to it? | 1. Go to `Start` then in `Find` type `regedit` -> it should open Registry editor
2. Click `Right Mouse` on `HKEY_CLASSES_ROOT` then `New` -> `Key`
[](https://i.stack.imgur.com/9boI6.png)
3. In the Key give the lowercase name by which you want urls to... |
80,653 | <p>I may be wrong, but if you are working with SmtpClient.SendAsync in ASP.NET
2.0 and it throws an exception, the thread processing the request waits
indefinitely for the operation to complete.</p>
<p>To reproduce this problem, simply use an invalid SMTP address for the host
that could not be resolved when sending... | [
{
"answer_id": 80887,
"author": "bzlm",
"author_id": 7724,
"author_profile": "https://Stackoverflow.com/users/7724",
"pm_score": 2,
"selected": false,
"text": "<p><strike></p>\n\n<blockquote>\n <p>Note that you should set Page.Async = true to use SendAsync.</p>\n</blockquote>\n\n<p>Plea... | 2008/09/17 | [
"https://Stackoverflow.com/questions/80653",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15186/"
] | I may be wrong, but if you are working with SmtpClient.SendAsync in ASP.NET
2.0 and it throws an exception, the thread processing the request waits
indefinitely for the operation to complete.
To reproduce this problem, simply use an invalid SMTP address for the host
that could not be resolved when sending an email.... | >
> Note that you should set Page.Async = true to use SendAsync.
>
>
>
Please explain the rationale behind this. Misunderstanding what Page.Async does may be the cause of your problems.
Sorry, I was unable to get an example working that reproduced the problem.
See <http://msdn.microsoft.com/en-us/magazine/cc1637... |
80,657 | <p>In the process of learning <a href="https://en.wikipedia.org/wiki/TinyOS" rel="nofollow noreferrer">TinyOS</a> I have discovered that I am totally clueless about makefiles.</p>
<p>There are many optional compile time features that can be used by way of declaring preprocessor variables.</p>
<p>To use them you have to... | [
{
"answer_id": 80689,
"author": "Ilya",
"author_id": 6807,
"author_profile": "https://Stackoverflow.com/users/6807",
"pm_score": 3,
"selected": false,
"text": "<p>Somewhere in the makefile the CFLAG will be used in compilation line like this:<br>\n<code>$(CC) $(CFLAGS) $(C_INCLUDES) $<... | 2008/09/17 | [
"https://Stackoverflow.com/questions/80657",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | In the process of learning [TinyOS](https://en.wikipedia.org/wiki/TinyOS) I have discovered that I am totally clueless about makefiles.
There are many optional compile time features that can be used by way of declaring preprocessor variables.
To use them you have to do things like:
`CFLAGS="-DPACKET_LINK"` this enab... | CFLAGS is a variable that is most commonly used to add arguments to the compiler. In this case, it define macros.
So the `-DPACKET_LINK` is the equivalent of putting `#define PACKET_LINK 1` at the top of all .c and .h files in your project. Most likely, you have code inside your project that looks if these macros are... |
80,677 | <p>One of the best tips for using vim that I have learned so far has been that one can press <kbd>Ctrl</kbd>+<kbd>C</kbd> or <kbd>Ctrl</kbd>+<kbd>[</kbd> instead of the <kbd>Esc</kbd> key. However I use a dvorak keyboard so <kbd>Ctrl</kbd>+<kbd>[</kbd> is a little out of reach for me as well so I mostly use <kbd>Ctrl</... | [
{
"answer_id": 80761,
"author": "jeannicolas",
"author_id": 14981,
"author_profile": "https://Stackoverflow.com/users/14981",
"pm_score": 4,
"selected": false,
"text": "<p>According to Vim's documentation, <kbd>Ctrl</kbd>+<kbd>C</kbd> does not check for abbreviations and does not trigger... | 2008/09/17 | [
"https://Stackoverflow.com/questions/80677",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13060/"
] | One of the best tips for using vim that I have learned so far has been that one can press `Ctrl`+`C` or `Ctrl`+`[` instead of the `Esc` key. However I use a dvorak keyboard so `Ctrl`+`[` is a little out of reach for me as well so I mostly use `Ctrl`+`C`. Now I've read somewhere that these two key combinations don't act... | According to Vim's documentation, `Ctrl`+`C` does not check for abbreviations and does not trigger the `InsertLeave` autocommand event while `Ctrl`+`[` does.
One option is to use the following to remap `Ctrl`+`C`
```
inoremap <C-c> <Esc><Esc>
``` |
80,691 | <p>I've started refactoring some legacy code recently and came across two functions for drawing a coordinate grid, the problem is that these functions differ only in orthogonal variables they treat, something like that</p>
<pre><code>void DrawScaleX(HDC dc, int step, int x0, int x1, int y0, int y1)
{
for(int x = x... | [
{
"answer_id": 80722,
"author": "Serge",
"author_id": 1007,
"author_profile": "https://Stackoverflow.com/users/1007",
"pm_score": 0,
"selected": false,
"text": "<p>Here is my own solution</p>\n\n<pre><code>\nclass CoordGenerator\n{\npublic:\n CoordGenerator(int _from, int _to, int _st... | 2008/09/17 | [
"https://Stackoverflow.com/questions/80691",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1007/"
] | I've started refactoring some legacy code recently and came across two functions for drawing a coordinate grid, the problem is that these functions differ only in orthogonal variables they treat, something like that
```
void DrawScaleX(HDC dc, int step, int x0, int x1, int y0, int y1)
{
for(int x = x0; x < x1; x +... | Drawing a line is simply joining two points, and drawing a scaling incrementing (x0,y0) and(x1,y1) in a particular direction, through X, and/or through Y.
This boils down to, in the scale case, which direction(s) stepping occurs (maybe both directions for fun).
```
template< int XIncrement, YIncrement >
struct DrawSca... |
80,692 | <pre><code>public static Logger getLogger() {
final Throwable t = new Throwable();
final StackTraceElement methodCaller = t.getStackTrace()[1];
final Logger logger = Logger.getLogger(methodCaller.getClassName());
logger.setLevel(ResourceManager.LOGLEVEL);
return logger;
}
</code></pre>
<p>This meth... | [
{
"answer_id": 80754,
"author": "Ian",
"author_id": 4396,
"author_profile": "https://Stackoverflow.com/users/4396",
"pm_score": 2,
"selected": false,
"text": "<p>You could of course just use Log4J with the appropriate pattern layout:</p>\n\n<blockquote>\n <p>For example, for the class n... | 2008/09/17 | [
"https://Stackoverflow.com/questions/80692",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15187/"
] | ```
public static Logger getLogger() {
final Throwable t = new Throwable();
final StackTraceElement methodCaller = t.getStackTrace()[1];
final Logger logger = Logger.getLogger(methodCaller.getClassName());
logger.setLevel(ResourceManager.LOGLEVEL);
return logger;
}
```
This method would return a l... | I guess it adds a lot of overhead for every class. Every class has to be 'looked up'. You create new Throwable objects to do that... These throwables don't come for free. |
80,706 | <p>I want to find 2<sup>nd</sup>, 3<sup>rd</sup>, ... n<sup>th</sup> maximum value of a column.</p>
| [
{
"answer_id": 80720,
"author": "TK.",
"author_id": 1816,
"author_profile": "https://Stackoverflow.com/users/1816",
"pm_score": 5,
"selected": true,
"text": "<p>You could sort the column into descending format and then just obtain the value from the nth row.</p>\n\n<p>EDIT::</p>\n\n<p>Up... | 2008/09/17 | [
"https://Stackoverflow.com/questions/80706",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15181/"
] | I want to find 2nd, 3rd, ... nth maximum value of a column. | You could sort the column into descending format and then just obtain the value from the nth row.
EDIT::
Updated as per comment request. ***WARNING*** completely untested!
```
SELECT DOB FROM (SELECT DOB FROM USERS ORDER BY DOB DESC) WHERE ROWID = 6
```
Something like the above should work for Oracle ... you might... |
80,726 | <pre><code>> jruby -S gem install warbler
JRuby limited openssl loaded. gem install jruby-openssl for full support.
Successfully installed warbler-0.9.11
1 gem installed
Installing ri documentation for warbler-0.9.11...
Installing RDoc documentation for warbler-0.9.11...
> jruby -S warble
<snip>/jruby-1.1.4... | [
{
"answer_id": 92779,
"author": "Andrew Burgess",
"author_id": 12096,
"author_profile": "https://Stackoverflow.com/users/12096",
"pm_score": 1,
"selected": false,
"text": "<p>The only thing that I can really think of is to ensure that your instance of JRuby is using gems by default. I r... | 2008/09/17 | [
"https://Stackoverflow.com/questions/80726",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14952/"
] | ```
> jruby -S gem install warbler
JRuby limited openssl loaded. gem install jruby-openssl for full support.
Successfully installed warbler-0.9.11
1 gem installed
Installing ri documentation for warbler-0.9.11...
Installing RDoc documentation for warbler-0.9.11...
> jruby -S warble
<snip>/jruby-1.1.4/bin/warble:1: unde... | The only thing that I can really think of is to ensure that your instance of JRuby is using gems by default. I ran into that problem a few times when using gems where I would forget to either set the environmental variable or pass in the switch to Ruby. I don't know if things are different for JRuby though. |
80,766 | <p>I got a typed (not connected) dataset, and many records (binary seriliazed) created with this dataset.
I've added a property to one of the types, and I want to convert the old records with the new data set.
I know how to load them: providing custom binder for the BinaryFormatter with the old schema dll.
The questio... | [
{
"answer_id": 81192,
"author": "paulwhit",
"author_id": 7301,
"author_profile": "https://Stackoverflow.com/users/7301",
"pm_score": 0,
"selected": false,
"text": "<p>Can you make the new class inherit from the old one? If so, maybe you can simply deserialize into the new one through cas... | 2008/09/17 | [
"https://Stackoverflow.com/questions/80766",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I got a typed (not connected) dataset, and many records (binary seriliazed) created with this dataset.
I've added a property to one of the types, and I want to convert the old records with the new data set.
I know how to load them: providing custom binder for the BinaryFormatter with the old schema dll.
The question i... | If the only difference between the existing dataset and the new one is an added field then you can "upgrade" them by writing out the old ones to XML and then reading that into the new ones. The value of the added field will be DBNull.
```
MyDataSet myDS = new MyDataSet();
MyDataSet.MyTableRow row1 = myDS.MyTable.NewMy... |
80,770 | <p>I have been reading a lot of XQuery tutorials on the website. Almost all of them are teaching me XQuery syntax. Let's say I have understood the XQuery syntax, how am I going to actually implement XQuery on my website?</p>
<p>For example, I have <strong>book.xml</strong>:</p>
<pre><code><?xml version="1.0&qu... | [
{
"answer_id": 82980,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<pre><code><table>\n<tr><td>Title<td><td>Author<td></tr>\n{\n let $authordoc := fn... | 2008/09/17 | [
"https://Stackoverflow.com/questions/80770",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have been reading a lot of XQuery tutorials on the website. Almost all of them are teaching me XQuery syntax. Let's say I have understood the XQuery syntax, how am I going to actually implement XQuery on my website?
For example, I have **book.xml**:
```
<?xml version="1.0" encoding="iso-8859-1" ?>
<books>
<book>
... | ```
(: file: titles.xqy :)
<table>
<tr><th>title</th><th>author</th></tr>
{
let $books-doc := doc("books.xml")
let $authors-doc := doc("authors.xml")
for $b in $books-doc//book,
$a in $authors-doc//author
where $a/@id = $b/authorid
return
<tr>
<td>{$b/title/text()}</td>
<td>{$a/text()}</td>
</tr>
}
``` |
80,787 | <p>Any ideas how to determine the number of active threads currently running in an <a href="https://docs.oracle.com/javase/9/docs/api/java/util/concurrent/ExecutorService.html" rel="noreferrer"><code>ExecutorService</code></a>?</p>
| [
{
"answer_id": 80809,
"author": "Daan",
"author_id": 197,
"author_profile": "https://Stackoverflow.com/users/197",
"pm_score": 7,
"selected": true,
"text": "<p>Use a <a href=\"http://java.sun.com/javase/6/docs/api/java/util/concurrent/ThreadPoolExecutor.html\" rel=\"noreferrer\">ThreadPo... | 2008/09/17 | [
"https://Stackoverflow.com/questions/80787",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8441/"
] | Any ideas how to determine the number of active threads currently running in an [`ExecutorService`](https://docs.oracle.com/javase/9/docs/api/java/util/concurrent/ExecutorService.html)? | Use a [ThreadPoolExecutor](http://java.sun.com/javase/6/docs/api/java/util/concurrent/ThreadPoolExecutor.html) implementation and call [getActiveCount()](http://java.sun.com/javase/6/docs/api/java/util/concurrent/ThreadPoolExecutor.html#getActiveCount()) on it:
```
int getActiveCount()
// Returns the approximate numb... |
80,788 | <p>I'm trying to get IKVM to build (see <a href="https://stackoverflow.com/questions/71599/how-to-get-ikvm-to-build-in-visual-studio-2008">this question</a>) but now have encountered a problem not having to do with IKVM so I'm opening up a new question:</p>
<p>When running nant on the IKVM directory with the Visual St... | [
{
"answer_id": 81226,
"author": "Epaga",
"author_id": 6583,
"author_profile": "https://Stackoverflow.com/users/6583",
"pm_score": 4,
"selected": true,
"text": "<p>OK here is the answer I ended up finding: rather than being on the Path, the directory with windows.h (in my case, C:\\Progra... | 2008/09/17 | [
"https://Stackoverflow.com/questions/80788",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6583/"
] | I'm trying to get IKVM to build (see [this question](https://stackoverflow.com/questions/71599/how-to-get-ikvm-to-build-in-visual-studio-2008)) but now have encountered a problem not having to do with IKVM so I'm opening up a new question:
When running nant on the IKVM directory with the Visual Studio 2008 Command Pro... | OK here is the answer I ended up finding: rather than being on the Path, the directory with windows.h (in my case, C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include) needed to be set in the Include environment variable. |
80,801 | <p>If I have a large number of SQLite databases, all with the same schema, what is the best way to merge them together in order to perform a query on all databases? </p>
<p>I know it is possible to use <a href="http://www.sqlite.org/lang_attach.html" rel="noreferrer">ATTACH</a> to do this but it has <a href="http://ww... | [
{
"answer_id": 80812,
"author": "Espo",
"author_id": 2257,
"author_profile": "https://Stackoverflow.com/users/2257",
"pm_score": 1,
"selected": false,
"text": "<p>If you only need to do this merge operation once (to create a new bigger database), you could create a script/program that wi... | 2008/09/17 | [
"https://Stackoverflow.com/questions/80801",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2183/"
] | If I have a large number of SQLite databases, all with the same schema, what is the best way to merge them together in order to perform a query on all databases?
I know it is possible to use [ATTACH](http://www.sqlite.org/lang_attach.html) to do this but it has [a limit](http://www.sqlite.org/limits.html#max_attached... | To summarize from the [Nabble post](https://web.archive.org/web/20120615034014/http://sqlite.1065341.n5.nabble.com/Attempting-to-merge-large-databases-td39548.html) in DavidM's answer:
```
attach 'c:\test\b.db3' as toMerge;
BEGIN;
insert into AuditRecords select * from toMerge.AuditRecords;
COMMIT;
detac... |
80,802 | <p>I've been wondering, is there a performance difference between using named functions and anonymous functions in Javascript? </p>
<pre><code>for (var i = 0; i < 1000; ++i) {
myObjects[i].onMyEvent = function() {
// do something
};
}
</code></pre>
<p>vs</p>
<pre><code>function myEventHandler() {
... | [
{
"answer_id": 80823,
"author": "Tom Leys",
"author_id": 11440,
"author_profile": "https://Stackoverflow.com/users/11440",
"pm_score": 2,
"selected": false,
"text": "<p>As a general design principle, you should avoid implimenting the same code multiple times. Instead you should lift comm... | 2008/09/17 | [
"https://Stackoverflow.com/questions/80802",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9021/"
] | I've been wondering, is there a performance difference between using named functions and anonymous functions in Javascript?
```
for (var i = 0; i < 1000; ++i) {
myObjects[i].onMyEvent = function() {
// do something
};
}
```
vs
```
function myEventHandler() {
// do something
}
for (var i = 0; i... | The performance problem here is the cost of creating a new function object at each iteration of the loop and not the fact that you use an anonymous function:
```
for (var i = 0; i < 1000; ++i) {
myObjects[i].onMyEvent = function() {
// do something
};
}
```
You are creating a thousand distinc... |
80,820 | <p>On a file path field, I want to capture the directory path like:</p>
<pre><code>textbox1.Text = directory path
</code></pre>
<p>Anyone?</p>
| [
{
"answer_id": 80824,
"author": "Espo",
"author_id": 2257,
"author_profile": "https://Stackoverflow.com/users/2257",
"pm_score": 3,
"selected": false,
"text": "<p>There is a FolderBrowserDialog class that you can use if you want the user to select a folder.</p>\n\n<p><a href=\"http://msd... | 2008/09/17 | [
"https://Stackoverflow.com/questions/80820",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10385/"
] | On a file path field, I want to capture the directory path like:
```
textbox1.Text = directory path
```
Anyone? | Well I am using VS 2008 SP1. This all I need:
```
private void button1_Click(object sender, EventArgs e)
{
FolderBrowserDialog profilePath = new FolderBrowserDialog();
if (profilePath.ShowDialog() == DialogResult.OK)
{
profilePathTextBox.Text = profilePath.SelectedPath;
}
else
... |
80,831 | <p>There is a <a href="http://support.microsoft.com/?scid=194627" rel="nofollow noreferrer">Microsoft knowledge base article</a> with sample code to open all mailboxes in a given information store. It works so far (requires a bit of <a href="http://blogs.msdn.com/jasonjoh/archive/2004/08/01/204585.aspx" rel="nofollow n... | [
{
"answer_id": 82342,
"author": "Duncan Smart",
"author_id": 1278,
"author_profile": "https://Stackoverflow.com/users/1278",
"pm_score": 0,
"selected": false,
"text": "<p>It'll be in Active Directory, so you'd use ADSI/LDAP to look at CN=Microsoft Exchange,CN=Services,CN=Configuration,DC... | 2008/09/17 | [
"https://Stackoverflow.com/questions/80831",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4097/"
] | There is a [Microsoft knowledge base article](http://support.microsoft.com/?scid=194627) with sample code to open all mailboxes in a given information store. It works so far (requires a bit of [copy & pasting](http://blogs.msdn.com/jasonjoh/archive/2004/08/01/204585.aspx) on compilers newer than VC++ 6.0).
At one poin... | Thinking there must be a pure MAPI solution, I believe I've figured out how OutlookSpy does it.
The following code snippet, inserted after
```
printf("Created MAPI session\n");
```
in the example from [KB194627](http://support.microsoft.com/kb/194627), will show the *Server DN*.
```
LPPROFSECT lpProfSect;
hr = lp... |
80,846 | <p>I am trying to use Zend_Db_Select to write a select query that looks somewhat like this:</p>
<pre><code>SELECT * FROM bar WHERE a = 1 AND (b = 2 OR b = 3)
</code></pre>
<p>However, when using a combination of where() and orWhere(), it seems impossible to use condition grouping like the above.</p>
<p>Are there any... | [
{
"answer_id": 80871,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": true,
"text": "<p>From <a href=\"http://framework.zend.com/manual/en/zend.db.select.html#zend.db.select.building.where\" rel=\"nofollow norefer... | 2008/09/17 | [
"https://Stackoverflow.com/questions/80846",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11568/"
] | I am trying to use Zend\_Db\_Select to write a select query that looks somewhat like this:
```
SELECT * FROM bar WHERE a = 1 AND (b = 2 OR b = 3)
```
However, when using a combination of where() and orWhere(), it seems impossible to use condition grouping like the above.
Are there any native ways in Zend Framework ... | From [the manual](http://framework.zend.com/manual/en/zend.db.select.html#zend.db.select.building.where) (Example 11.61. Example of parenthesizing Boolean expressions)
```
// Build this query:
// SELECT product_id, product_name, price
// FROM "products"
// WHERE (price < 100.00 OR price > 500.00)
// AND (pr... |