qid int64 4 19.1M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
375,590 | <p>I'm loading an XML document in my C# application with the following:</p>
<pre><code>XDocument xd1 = new XDocument();
xd1 = XDocument.Load(myfile);
</code></pre>
<p>but before that, I do test to make sure the file exists with:</p>
<pre><code>File.Exists(myfile);
</code></pre>
<p>But... is there an (easy) way to test the file before the XDocument.Load() to make sure it's a valid XML file? In other words, my user can accidentally click on a different file in the file browser and trying to load, say, a .php file causes an exception. </p>
<p>The only way I can think of is to load it into a StreamWriter and simple do a text search on the first few characters to make sure they say "
<p>Thanks!</p>
<p>-Adeena</p>
| [
{
"answer_id": 375617,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 4,
"selected": false,
"text": "File.Exists() File.Exists()"
},
{
"answer_id": 375646,
"author": "Jennifer",
"author_id": 22360,
"... | 2008/12/17 | [
"https://Stackoverflow.com/questions/375590",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44004/"
] |
375,598 | <p>Is there any way that I can find the container pointed to by an iterator? Specifically, I want to be able to find the <code>std::vector</code> pointed to by a particular <code>std::vector::iterator</code> so that I can check the range, without having to actually pass references to that vector around.</p>
<p>If (as I suspect) the answer is no, why not? </p>
<p>edit: thanks for a number of quick and (largely) accurate answers. <a href="https://stackoverflow.com/questions/375598/finding-the-owner-of-an-stl-iterator#375608">Evan Teran</a> nails it. I wasn't thinking about optimization at all, but it's obvious now. </p>
<p>A couple of people asked what I want to do this for. It's nothing terribly important. I have an object which is initialized with a vector and an iterator pointing into the vector. It would be cute and convenient if I could initialize the object just with an iterator because then I could convert <code>vector::iterator</code>s directly to this object (this sounds strange but does make sense in the particular case). But it's not crucial at all.</p>
| [
{
"answer_id": 375627,
"author": "Judge Maygarden",
"author_id": 1491,
"author_profile": "https://Stackoverflow.com/users/1491",
"pm_score": 2,
"selected": false,
"text": "#include <algorithm>\n#include <cstdio>\n#include <cstring>\n\nint\nmain(int argc, char *argv[])\n{\n const c... | 2008/12/17 | [
"https://Stackoverflow.com/questions/375598",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45170/"
] |
375,605 | <p>I need to keep a couple of <a href="http://jena.sf.net" rel="nofollow noreferrer">Jena</a> Models (OntModels, specifically) synchronized across a socket, and I'd like to do this one change at a time (for various reasons -- one being that each Statement added or removed from the OntModels is also adapting a JESS rule base.). I am able to listen to the add/remove events on the OntModels and then create simple event instances that wrap the added / removed Statements along with a ChangeType that indicates that the Statement was added or removed, but serializing the Statement has proven to be a problem.</p>
<p>Unfortunately, all of the JENA serialization documentation that I've found relates to serializing an entire model to xml / rdf / n3 / etc. Since statements are simply triples of Strings (at one level, anyway) it seems like it should be trivial to serialize the data at the Statement level. However, <a href="http://jena.sf.net" rel="nofollow noreferrer">Jena</a> doesn't seem to provide an API for creating Statements with plain strings that "does the right thing". Problems arise with typed literals. eg:</p>
<p>I can create the statement:</p>
<pre><code><http://someuri/myont#foo> <http://someuri/myont#weight> "50.7"^^www.w3.org/2001/XMLSchema#double
</code></pre>
<p>but the string version that I can get out looks like this:</p>
<pre><code>"http://someuri/myont#foo" "http://someuri/myont#weight" "50.7^^www.w3.org/2001/XMLSchema#double"
</code></pre>
<p>(note the absence of a " before the ^^)</p>
<p>This wouldn't be that much of a problem, since the literal can still be parsed out with a regex, but I've been unable to create a Statement with the proper literal. The obvious approach (ModelCon.createStatement(Resource, Property, String)) generates an untyped string literal with the full value of the String passed in.</p>
<p>Does anyone know how I can reliably serialize (and deserialize, of course) individual Jena Statements?</p>
| [
{
"answer_id": 430289,
"author": "Ian Dickinson",
"author_id": 6716,
"author_profile": "https://Stackoverflow.com/users/6716",
"pm_score": 3,
"selected": true,
"text": "yourOntModel.add( changesModel )"
},
{
"answer_id": 441402,
"author": "rcreswick",
"author_id": 3446,
... | 2008/12/17 | [
"https://Stackoverflow.com/questions/375605",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3446/"
] |
375,647 | <p>I've used some very large scale systems and never seen a required order, but came across it recently. Does the STL or STD library or even Boost have any cases where certain includes must come in a certain order?</p>
| [
{
"answer_id": 375663,
"author": "pyon",
"author_id": 46571,
"author_profile": "https://Stackoverflow.com/users/46571",
"pm_score": 2,
"selected": false,
"text": "// A.h\n#pragma once\n// or the #ifndef trick\n#include \"B.h\"\n\n// A.cpp\n#include \"A.h\"\n // A.h\n#pragma once\n// or t... | 2008/12/17 | [
"https://Stackoverflow.com/questions/375647",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44996/"
] |
375,651 | <p>One of my favorite vim features is the ability to do</p>
<pre><code>set path=/my/project/root/**
</code></pre>
<p>and then use</p>
<pre><code>:find SomeClassFile.java
</code></pre>
<p>Only problem is, I've got some generated directories at that level that I cannot move and wish to exclude from such searches. I can't seem to figure out how to exclude those dirs. Anyone know how/if this can be done?</p>
| [
{
"answer_id": 375699,
"author": "Paul Tomblin",
"author_id": 3333,
"author_profile": "https://Stackoverflow.com/users/3333",
"pm_score": 3,
"selected": true,
"text": "\"**\" set path=/my/project/root/src/**,/my/project/root/com/**,/my/project/root/foo/**\n"
},
{
"answer_id": 378... | 2008/12/17 | [
"https://Stackoverflow.com/questions/375651",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3029/"
] |
375,710 | <p>I can detect when the content of an iframe has loaded using the <em>load</em> event. Unfortunately, for my purposes, there are two problems with this:</p>
<ul>
<li>If there is an error loading the page (404/500, etc), the load event is never fired.</li>
<li>If some images or other dependencies failed to load, the load event is fired as usual.</li>
</ul>
<p>Is there some way I can reliably determine if either of the above errors occurred?</p>
<p>I'm writing a semi-web semi-desktop application based on Mozilla/XULRunner, so solutions that only work in Mozilla are welcome.</p>
| [
{
"answer_id": 375759,
"author": "splattne",
"author_id": 6461,
"author_profile": "https://Stackoverflow.com/users/6461",
"pm_score": 4,
"selected": false,
"text": "var iFrameLoaded = false; true (setIFrameLoaded(); iFrameLoaded timer"
},
{
"answer_id": 386677,
"author": "Chr... | 2008/12/17 | [
"https://Stackoverflow.com/questions/375710",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31662/"
] |
375,764 | <p>I have an datetime object that I want to remove one hour to display the corect time in a different time zone. I am using datetime.addhours(-1) with the -1 being a config value. This works in most cases except when I set the time to 12:59 AM today it displays 11:59 AM today. When it should display 11:59 PM. Is it possible to have addDays() repect the date?</p>
| [
{
"answer_id": 375777,
"author": "Yaakov Ellis",
"author_id": 51,
"author_profile": "https://Stackoverflow.com/users/51",
"pm_score": 2,
"selected": true,
"text": "DateTime.Now.Subtract(new TimeSpan(1, 0, 0));\n"
},
{
"answer_id": 375793,
"author": "Bill",
"author_id": 14... | 2008/12/17 | [
"https://Stackoverflow.com/questions/375764",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
375,765 | <p>I have an application that uses DataTables to perform grouping, filtering and aggregation of data. I want to replace datatables with my own data structures so we don't have any unnecessary overhead that we get from using datatables. So my question is if Linq can be used to perform the grouping, filtering and aggregation of my data and if it can is the performance comparable to datatables or should I just hunker down and write my own algorithms to do it?</p>
<p>Thanks</p>
<p>Dan R.</p>
| [
{
"answer_id": 375824,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 3,
"selected": true,
"text": "DataTable var qry = from row in [someDataSource]\n group row by row.Category into grp\n select new {... | 2008/12/17 | [
"https://Stackoverflow.com/questions/375765",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8219/"
] |
375,784 | <p>I have an aspx page with 1 table containing 2 rows:</p>
<pre><code><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style>
html, body
{
height: 100%;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<table style="height:100%; width:100%">
<tr>
<td>
<img src="img/Logo.png" />
</td>
</tr>
<tr>
<td style="height:100%;">
<asp:Silverlight
ID="sllUI"
runat="server"
Source="~/ClientBin/My.Silverlight.UI.xap"
MinimumVersion="2.0.31005.0"
Width="100%"
Height="100%"
OnPluginLoaded="sllUI_OnPluginLoaded"
PluginBackground="Transparent"
Windowless="true">
</asp:Silverlight>
</td>
</tr>
</table>
</div>
</form>
<body>
</html>
</code></pre>
<p>The table fills the page correctly, and the bottom row fills grows to the remaining height of the table that the top row doesn't fill, which is what I want. The problem is that the silverlight control takes on the height of the page, not the height of the row that it is in, which causes my page to get scroll bars because the top of the silver light control is at the top of the row it's in, but it's hight is 100% of the browser. I don't know if this is caused by my html or by silverlight. All my silverlight user controls are set to auto height & width. I've also tried using divs instead of the table and I get the same result. How can I fix this?</p>
<p>I've found that (at least in IE7) the doctype I've specified causes it to use standards mode IE6, but if I take the doctype out it goes into quirks mode IE5 (I find the mode by using DebugBar v5.1.1). Quirks mode causes it to display properly, but I think I'd rather avoid quirks mode if I can get the display correct in standard mode.</p>
| [
{
"answer_id": 375844,
"author": "Skubs",
"author_id": 25609,
"author_profile": "https://Stackoverflow.com/users/25609",
"pm_score": 0,
"selected": false,
"text": "\nfunction getWindowHeight() {\n var windowHeight = 0;\n if (typeof(window.innerHeight) == 'number') {\n window... | 2008/12/17 | [
"https://Stackoverflow.com/questions/375784",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9266/"
] |
375,820 | <p>I'm writing a GUI application in Python using wxPython and I want to display an image in a static control (<code>wx.StaticBitmap</code>).</p>
<p>I can use <a href="http://www.wxpython.org/docs/api/wx-module.html#ImageFromStream" rel="nofollow noreferrer"><code>wx.ImageFromStream</code></a> to load an image from a file, and this works OK:</p>
<pre><code>static_bitmap = wx.StaticBitmap(parent, wx.ID_ANY)
f = open("test.jpg", "rb")
image = wx.ImageFromStream(f)
bitmap = wx.BitmapFromImage(image)
static_bitmap.SetBitmap(bitmap)
</code></pre>
<p>But, what I really want to be able to do is create the image from data in memory. So, if I write</p>
<pre><code>f = open("test.jpg", "rb")
data = f.read()
</code></pre>
<p>how can I create a <code>wx.Image</code> object from <code>data</code>?</p>
<p>Thanks for your help!</p>
| [
{
"answer_id": 375852,
"author": "codelogic",
"author_id": 43427,
"author_profile": "https://Stackoverflow.com/users/43427",
"pm_score": 4,
"selected": true,
"text": "StringIO ...\nimport StringIO\n\nbuf = open(\"test.jpg\", \"rb\").read()\n# buf = get_image_data()\nsbuf = StringIO.Strin... | 2008/12/17 | [
"https://Stackoverflow.com/questions/375820",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3853/"
] |
375,841 | <p>I've been <a href="https://stackoverflow.com/questions/279557/how-do-i-keep-the-wpf-gridsplitter-from-changing-the-size-of-my-grid">struggling with the GridSplitter</a>. It seems to be incompatible with the WPF WebBrowser control.</p>
<p>If I resize my window and move the GridSplitter, then I can make my grid wider than my window and non-viewable.</p>
<p>Before:</p>
<p><a href="http://img239.imageshack.us/img239/4061/grid1vn8.gif" rel="nofollow noreferrer">WPF GridSplitter WebBrowser Before http://img239.imageshack.us/img239/4061/grid1vn8.gif</a></p>
<p>After: (note scrollbars)</p>
<p><a href="http://img101.imageshack.us/img101/4303/grid2so0.gif" rel="nofollow noreferrer">WPF GridSplitter WebBrowser After http://img101.imageshack.us/img101/4303/grid2so0.gif</a></p>
<p>My XAML...</p>
<pre><code><Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
MinWidth="450"
Width="450"
Height="300"
Title="Window3">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition MinWidth="200" Width="*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition MinWidth="200" Width="*"/>
</Grid.ColumnDefinitions>
<Button Name="Button2"
Grid.Column="0"
Margin="5"
Content="Button2"/>
<GridSplitter
Width="2"
Grid.Column="1"
HorizontalAlignment="Center"
Margin="5"
Panel.ZIndex="1"
VerticalAlignment="Stretch"
ResizeBehavior="PreviousAndNext"
ResizeDirection="Columns"/>
<WebBrowser
Grid.Column="2"
Margin="5"
Source="http://www.google.com"/>
</Grid>
</Window>
</code></pre>
<p>Steps to reproduce the problem...</p>
<ol>
<li>Drag the window's right edge to the right to about double its width</li>
<li>Drag the splitter to the left as far as it'll go</li>
<li>Drag the window's right edge to the left as far as it'll go.</li>
</ol>
<p>How do I keep the GridSplitter from changing the size of my Grid beyond what the Window can contain?</p>
<p>Does anyone know more about this problem? ...or have a workaround?</p>
| [
{
"answer_id": 376480,
"author": "Robert Macnee",
"author_id": 19273,
"author_profile": "https://Stackoverflow.com/users/19273",
"pm_score": 3,
"selected": true,
"text": "<Window xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"\n xmlns:x=\"http://schemas.microso... | 2008/12/17 | [
"https://Stackoverflow.com/questions/375841",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/83/"
] |
375,860 | <p>How can I obtain the .NET Framework directory path inside my C# application?</p>
<p>The folder that I refer is "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727"</p>
| [
{
"answer_id": 375882,
"author": "Christian C. Salvadó",
"author_id": 5445,
"author_profile": "https://Stackoverflow.com/users/5445",
"pm_score": 2,
"selected": false,
"text": "using System;\nusing Microsoft.Win32;\n public static string GetFrameworkDirectory()\n{\n // This is the locat... | 2008/12/17 | [
"https://Stackoverflow.com/questions/375860",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47196/"
] |
375,868 | <p>I haven't got a unique problem, but for the life of me I can't figure out what I'm doing wrong.</p>
<p>I have a page that has a series of sections. Part of the section is a little image. When the image is clicked, I want to show a custom control. Showing the control is trivial, set the z-index a bit higher to ensure the control is on top of everything.</p>
<p>But the user can still interact with the sections behind the control.</p>
<p>To stop that, I added a "blanket". Basically a div that is the size of the document with the following CSS (in jQuery syntax) - </p>
<pre><code>{
position: 'absolute',
top: 0,
left: 0,
width: '100%',
height: $(document).height(),
display: 'none',
zIndex: 1,
backgroundColor: '#FF0000'
};
</code></pre>
<p>Yeah...the background is red so I can see it for testing. I set opacity to 0.1 (light blur). I then set the z-index of my custom control to 2 so that it is on top of the blanket.</p>
<p>This works perfectly in FireFox, Chrome, and Safari, but not in IE.</p>
<p>The custom control is not a child of the blanket.</p>
<p>The goal is to have the following document covered by blanket with control on top of blanket to interact with it. This is what I get on all browsers except IE. On ie...it goes document with control and both are covered by the blanket.</p>
<p><strong>Answer</strong></p>
<p><a href="https://stackoverflow.com/users/6144/scunliffe">scunliffe</a> was the closest (answered in a comment I can't link to). The custom control is inside of a relatively positioned div (several down actually). the blanket was simply appended onto the end of the body. Therefore it was outside the relatively positioned div and started it's own z-index stack (as documented <a href="http://aplus.rs/lab/z-pos/" rel="nofollow noreferrer">here</a>). Since IE 6/7 are broken in this regard, no matter what I set the z-index to, it would always be below the blanket.</p>
<p>So I moved the blanket to be the first child inside the relatively positioned div. This isn't 100% complete yet because if you scroll (which I can't stop with this solution), the blanket div is only the height of the visible content. I now have to figure out how to get the complete height of the content (visible and non-visible).</p>
| [
{
"answer_id": 375947,
"author": "Jason Jackson",
"author_id": 13103,
"author_profile": "https://Stackoverflow.com/users/13103",
"pm_score": 0,
"selected": false,
"text": ".SomeStyle\n{\nfilter:alpha(opacity=10);\n-moz-opacity:.10;\nopacity:.10;\n}\n"
},
{
"answer_id": 375972,
... | 2008/12/17 | [
"https://Stackoverflow.com/questions/375868",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12968/"
] |
375,869 | <p>When I first setup the SVN structure for my different projects, I decided to place each different project in a separate repository.</p>
<p>This has worked well for a while, but I'm staring to think that I would like to merge all of those repositories into one overall "company-wide" repository so when I have employees check out the source code, they can just checkout from the top and have all the code from all the different projects.</p>
<p>I found the <code>svn-merge-repos</code> command online, but not a lot of user feedback or helpful tips for using it. Is this the best way to join repositories so I don't loose my history data, or is there a better way? Are there any pitfalls that I should watch out for?</p>
<p>Thanks.</p>
| [
{
"answer_id": 375917,
"author": "Christian C. Salvadó",
"author_id": 5445,
"author_profile": "https://Stackoverflow.com/users/5445",
"pm_score": 2,
"selected": false,
"text": "svnadmin load --ignore-uuid"
},
{
"answer_id": 3141938,
"author": "Umar Farooq Khawaja",
"autho... | 2008/12/17 | [
"https://Stackoverflow.com/questions/375869",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10420/"
] |
375,887 | <p>I have an existing fairly large classic asp website, with virtual directories configured to centralize certain resources. My problem is for some reason I can't access any of my namespaces and classes. I tried adding a reference to another project where I have classes in a namespace "DAL" and even though intellisense sees the classes and the website compiles fine, it errors when I try to access any page that references a class in the "DAL" namespace. </p>
<p>I get the following error message in my browser "CS0103: The name 'CMS' does not exist in the current context". Part of the problem is website project's root is not the same folder/level as the web root in IIS. So my libraries are in the website root "/bin" folder, but iis is looking for these files in the IIS webroot which is at a lower level. So how can I get .net to see my binaries without putting them in the lower IIS website root directory? I tried setting up a virtual directory to my .dll file but it seems to have no effect.</p>
<p>thank you for your help!<br /><br />
======================CLARIFICATION====================<br /><br /><br /><br />
What I'm trying to do is keep the .dll files I want my website to use in a higher level directory then the folder I have set as the web root in IIS. So say the library i want to use it "DAL" it in the projects /bin folder, but under IIS the default site's Local Path is set to "/site/default". The only way I can seem to use the "DAL" library is by putting the /bin folder into "/site/default/bin", which for this project is not an option. Does this help?</p>
| [
{
"answer_id": 8185359,
"author": "JamesD",
"author_id": 64028,
"author_profile": "https://Stackoverflow.com/users/64028",
"pm_score": 1,
"selected": false,
"text": "/bin <- this is the actual 'bin' folder\n/app1\n/app1/bin <- this is a junction point\n/app2\n/app2/bin ... | 2008/12/17 | [
"https://Stackoverflow.com/questions/375887",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42987/"
] |
375,894 | <p>When a .Net service crashes, does the ServiceBase.OnStop method get called? Will the service be marked as stopped regardless of whether or not the OnStop method is called?</p>
| [
{
"answer_id": 2192278,
"author": "LaustN",
"author_id": 93044,
"author_profile": "https://Stackoverflow.com/users/93044",
"pm_score": 0,
"selected": false,
"text": "OnShutdown() OnStop() OnStop() OnShutdown() ServiceBase.Run()"
}
] | 2008/12/17 | [
"https://Stackoverflow.com/questions/375894",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7756/"
] |
375,895 | <p>An html template is compiled into the application as a resource. A <strong>fragment</strong> of the HTML template looks like:</p>
<pre><code><A href="%PANELLINK%" target="_blank">
<IMG border="0" src="%PANELIMAGE%" style="%IMAGESTYLE%">
</A><BR>
%CAPTIONTEXT%
</code></pre>
<p>i like it like this because the larger resource HTML file contains styling, no-quirks mode, etc.</p>
<p>But as is always the case, they now want the option that the Anchor tag should be omitted if there is no link. Also if there is no caption, then the BR tag should be omitted.</p>
<hr>
<h2>Considered Technique Nº1</h2>
<p>Given that i don't want to have to build entire HTML fragments in C# code, i <em>considered</em> something like:</p>
<pre><code>%ANCHORSTARTTAGPREFIX%<A href="%PANELLINK%" target="_blank">%ANCHORSTARTTAGPOSTFIX%
<IMG border="0" src="%PANELIMAGE%" style="%IMAGESTYLE%">
%ANCHORENDTAGPREFIX%</A>%ANCHORENDTAGPOSTFIX%CAPTIONPREFIX%<BR>
%CAPTIONTEXT%%CAPTIONPOSTFIX%
</code></pre>
<p>with the idea that i could use the pre and postfixes to turn the HTML code into:</p>
<pre><code><!--<A href="%PANELLINK%" target="_blank">-->
<IMG border="0" src="%PANELIMAGE%" style="%IMAGESTYLE%">
<!--</A>--><!--<BR>
%CAPTIONTEXT%-->
</code></pre>
<p>But that is just rediculous, plus one answerer reminds us that it wastes bandwith, and can be buggy.</p>
<hr>
<h2>Considered Technique Nº2</h2>
<p>Wholesale replacement of tags:</p>
<pre><code>%AnchorStartTag%
<IMG border="0" src="%PANELIMAGE%" style="%IMAGESTYLE%">
%AnchorEndTag%%CaptionStuff%
</code></pre>
<p>and doing a find-replace to change</p>
<pre><code>%AnchorStartTag%
</code></pre>
<p>with</p>
<pre><code>"<A href=\"foo\" target=\"blank\""
</code></pre>
<hr>
<h2>Considered Technique Nº3</h2>
<p>i considered giving an ID to the important HTML elements:</p>
<pre><code><A id="anchor" href="%PANELLINK%" target="_blank">
<IMG border="0" src="%PANELIMAGE%" style="%IMAGESTYLE%">
</A><BR id="captionBreak">
%CAPTIONTEXT%
</code></pre>
<p>and then using an HTML DOM parser to programatically delete nodes. But there is no easy access to a trustworthy HTML DOM parser. If the HTML was instead xhtml i would use various built-in/nativly available xml DOM parsers.</p>
<hr>
<h2>Considered Technique Nº4</h2>
<p>What i actually have so far is:</p>
<pre><code>private const String htmlEmptyTemplate =
@"<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.01//EN\"""+Environment.NewLine+
@" ""http://www.w3.org/TR/html4/strict.dtd"">"+Environment.NewLine+
@"<HTML>"+Environment.NewLine+
@"<HEAD>"+Environment.NewLine+
@" <TITLE>New Document</TITLE>"+Environment.NewLine+
@" <META http-equiv=""X-UA-Compatible"" content=""IE=edge"">"""+Environment.NewLine+
@" <META http-equiv=""Content-Type"" content=""text/html; charset=UTF-8"">"+Environment.NewLine+
@"</HEAD>"+Environment.NewLine+
@""+Environment.NewLine+
@"<BODY style=""margin: 0 auto"">"+Environment.NewLine+
@" <DIV style=""text-align:center;"">"+Environment.NewLine+
@" %ContentArea%"+Environment.NewLine+
@" </DIV>" + Environment.NewLine +
@"</BODY>" + Environment.NewLine +
@"</HTML>";
private const String htmlAnchorStartTag =
@"<A href=""%PANELLINK%"" target=""_blank"">";
//Image is forbidden from having end tag
private const String htmlImageTag =
@"<IMG border=""0"" src=""%PANELIMAGE%"" style=""%IMAGESTYLE%"">";
private const String htmlCaptionArea =
@"<BR>%CAPTIONTEXT%";
</code></pre>
<p>And i already want to gouge my eyeballs out. Building HTML in code is a nightmare. It's a nightmare to write, a nightmare to debug, and a nightmare to maintain - and it will makes things difficult on the next guy. i'm hoping for another solution - since i <strong>am</strong> the next guy.</p>
| [
{
"answer_id": 375975,
"author": "scunliffe",
"author_id": 6144,
"author_profile": "https://Stackoverflow.com/users/6144",
"pm_score": 0,
"selected": false,
"text": "//using PHP in this example\nfunction HTMLImage($imageData, $linkData){\n var str = '';\n //if there is link data, start... | 2008/12/17 | [
"https://Stackoverflow.com/questions/375895",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12597/"
] |
375,913 | <p>How do I find areas of my code that run slowly in a C++ application running on Linux?</p>
| [
{
"answer_id": 375930,
"author": "Nazgob",
"author_id": 3579,
"author_profile": "https://Stackoverflow.com/users/3579",
"pm_score": 9,
"selected": false,
"text": "-pg cc -o myprog myprog.c utils.c -g -pg\n gprof"
},
{
"answer_id": 378024,
"author": "Mike Dunlavey",
"autho... | 2008/12/17 | [
"https://Stackoverflow.com/questions/375913",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1473493/"
] |
375,915 | <p>I'm playing around with some Linq-SQL stuff, doing something like this:</p>
<pre><code>var foo = from f in db.Foo where f.Bar > 5 select f;
</code></pre>
<p>which is all fine and dandy, and I know I can also do this:</p>
<pre><code>var foo = from f in db.Foo where f.Bar > 5 select new { f.Bar, f.Baz };
</code></pre>
<p>What I want to know, is can I factor out the select part of that query, if I want to determine at runtime what parts of Foo to select? Such as:</p>
<pre><code>var foo = from f in db.Foo where f.Bar > 5 select SomeMethodThatReturnsThePropertiesOfFooIReallyWant();
</code></pre>
<p>Edit to clarify: I'm looking for the syntax and return type of SomeMethod...(). </p>
<p>If I wanted to do this some times:</p>
<pre><code>select new { f.Bar, f.Baz };
</code></pre>
<p>but other times do this:</p>
<pre><code>select new { f.Baz, f.Other };
</code></pre>
<p>Based on data in memory (without doing a giant case statement), how would i do that, if possible?</p>
| [
{
"answer_id": 375931,
"author": "James Curran",
"author_id": 12725,
"author_profile": "https://Stackoverflow.com/users/12725",
"pm_score": 2,
"selected": false,
"text": "var query_foo = db.Foo.Where(f=>f.Bar > 5);\n// :\nvar foo =query_foo.Select(f=>SomeMethodThatReturnsEtc(f));\n"
... | 2008/12/17 | [
"https://Stackoverflow.com/questions/375915",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5480/"
] |
375,928 | <p>Does anyone have an example (code or a link) that will allow me to export a gridview template field to excel? Here is an example of what I mean. Assume I have the following GridView Declaration:</p>
<pre><code><asp:GridView Id="gvResults" runat="server">
<Columns>
<asp:TemplateField HeaderText="Contact Info">
<ItemTemplate>
<b>Name:</b><%# Eval("Name") %><br/>
<b>Address:</b><%# Eval("Address") %><br/>
<b>Phone:</b><%# Eval("Phone") %><br/>
<b>E-mail:</b><%# Eval("Email") %>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</code></pre>
<p>When I export to excel, I want to export the fields in the template field to columns in the excel file, so it will look similar to this:</p>
<p>Name Address Phone E-mail</p>
<p>==== ======= ==== =====</p>
<p>John 123 Rd 40330 J@j.com</p>
<p>Mark 456 St 22039 M@M.com</p>
| [
{
"answer_id": 375931,
"author": "James Curran",
"author_id": 12725,
"author_profile": "https://Stackoverflow.com/users/12725",
"pm_score": 2,
"selected": false,
"text": "var query_foo = db.Foo.Where(f=>f.Bar > 5);\n// :\nvar foo =query_foo.Select(f=>SomeMethodThatReturnsEtc(f));\n"
... | 2008/12/17 | [
"https://Stackoverflow.com/questions/375928",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33690/"
] |
375,940 | <p>I have an XML feed (which I don't control) and I am trying to figure out how to detect the volume of certain attribute values within the document.</p>
<p>I am also parsing the XML and separating attributes into Arrays (for other functionality) </p>
<p>Here is a sample of my XML</p>
<pre><code><items>
<item att1="ABC123" att2="uID" />
<item att1="ABC345" att2="uID" />
<item att1="ABC123" att2="uID" />
<item att1="ABC678" att2="uID" />
<item att1="ABC123" att2="uID" />
<item att1="XYZ123" att2="uID" />
<item att1="XYZ345" att2="uID" />
<item att1="XYZ678" att2="uID" />
</items>
</code></pre>
<p>I want to find the volume nodes based on each att1 value. Att1 value will change. Once I know the frequency of att1 values I need to pull the att2 value of that node.</p>
<p>I need to find the TOP 4 items and pull the values of their attributes.</p>
<p>All of this needs to be done in C# code behind.</p>
<p>If I was using Javascript I would create an associative array and have att1 be the key and the frequency be the value. But since I'm new to c# I don't know how to duplicate this in c#.</p>
<p>So I believe, first I need to find all unique att1 values in the XML. I can do this using:</p>
<pre><code>IEnumerable<string> uItems = uItemsArray.Distinct();
// Where uItemsArray is a collection of all the att1 values in an array
</code></pre>
<p>Then I get stuck on how I compare each unique att1 value to the whole document to get the volume stored in a variable or array or whatever data set. </p>
<p>Here is the snippet I ended up using:</p>
<pre><code> XDocument doc = XDocument.Load(@"temp/salesData.xml");
var topItems = from item in doc.Descendants("item")
select new
{
name = (string)item.Attribute("name"),
sku = (string)item.Attribute("sku"),
iCat = (string)item.Attribute("iCat"),
sTime = (string)item.Attribute("sTime"),
price = (string)item.Attribute("price"),
desc = (string)item.Attribute("desc")
} into node
group node by node.sku into grp
select new {
sku = grp.Key,
name = grp.ElementAt(0).name,
iCat = grp.ElementAt(0).iCat,
sTime = grp.ElementAt(0).sTime,
price = grp.ElementAt(0).price,
desc = grp.ElementAt(0).desc,
Count = grp.Count()
};
_topSellers = new SalesDataObject[4];
int topSellerIndex = 0;
foreach (var item in topItems.OrderByDescending(x => x.Count).Take(4))
{
SalesDataObject topSeller = new SalesDataObject();
topSeller.iCat = item.iCat;
topSeller.iName = item.name;
topSeller.iSku = item.sku;
topSeller.sTime = Convert.ToDateTime(item.sTime);
topSeller.iDesc = item.desc;
topSeller.iPrice = item.price;
_topSellers.SetValue(topSeller, topSellerIndex);
topSellerIndex++;
}
</code></pre>
<p>Thanks for all your help!</p>
| [
{
"answer_id": 375964,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 2,
"selected": true,
"text": " XDocument doc = XDocument.Parse(xml);\n var query = from item in doc.Descendants(\"item\")\n ... | 2008/12/17 | [
"https://Stackoverflow.com/questions/375940",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30408/"
] |
375,962 | <p>I have a little trouble with RAD Studio 2009.<br>
As you know, it is possible to switch Unicode support off in MSVS (right click on solution->properties->character set=not set). I need to find this feature in RAD Studio, I know it exists but do not know where exactly.<br>
It`s the only thing that stops my work on a Socket Chat university project.<br>
P.S. The problem appeared after I have installed the update from CodeGear official site.<br></p>
| [
{
"answer_id": 376228,
"author": "chester89",
"author_id": 28298,
"author_profile": "https://Stackoverflow.com/users/28298",
"pm_score": 0,
"selected": false,
"text": "\n wchar_t* str = Form2->Edit1->Text.w_str();\n char* mystr = new char [Form2->Edit1->Text.Length() + 1];\n Wid... | 2008/12/17 | [
"https://Stackoverflow.com/questions/375962",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28298/"
] |
375,968 | <p>I recently started working on a large complex application, and I've just been assigned a bug due to this error:</p>
<pre><code>ORA-04091: table SCMA.TBL1 is mutating, trigger/function may not see it
ORA-06512: at "SCMA.TRG_T1_TBL1_COL1", line 4
ORA-04088: error during execution of trigger 'SCMA.TRG_T1_TBL1_COL1'
</code></pre>
<p>The trigger in question looks like </p>
<pre><code> create or replace TRIGGER TRG_T1_TBL1_COL1
BEFORE INSERT OR UPDATE OF t1_appnt_evnt_id ON TBL1
FOR EACH ROW
WHEN (NEW.t1_prnt_t1_pk is not null)
DECLARE
v_reassign_count number(20);
BEGIN
select count(t1_pk) INTO v_reassign_count from TBL1
where t1_appnt_evnt_id=:new.t1_appnt_evnt_id and t1_prnt_t1_pk is not null;
IF (v_reassign_count > 0) THEN
RAISE_APPLICATION_ERROR(-20013, 'Multiple reassignments not allowed');
END IF;
END;
</code></pre>
<p>The table has a primary key "<code>t1_pk</code>", an "appointment event id"
<code>t1_appnt_evnt_id</code> and another column "<code>t1_prnt_t1_pk</code>" which may or may
not contain another row's <code>t1_pk</code>.</p>
<p>It appears the trigger is trying to make sure that nobody else with the
same <code>t1_appnt_evnt_id</code> has <strike>referred to the same one this row is referring to</strike> a referral to another row, if this one is referring to another row.</p>
<p>The comment on the bug report from the DBA says "remove the trigger, and perform the check in the code", but unfortunately they have a proprietary code generation framework layered on top of Hibernate, so I can't even figure out where it actually gets written out, so I'm hoping that there is a way to make this trigger work. Is there?</p>
| [
{
"answer_id": 376029,
"author": "Dave Costa",
"author_id": 6568,
"author_profile": "https://Stackoverflow.com/users/6568",
"pm_score": 4,
"selected": true,
"text": "dev> create or replace function f( a number, b number ) return number deterministic as\n 2 begin\n 3 if a is null th... | 2008/12/17 | [
"https://Stackoverflow.com/questions/375968",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3333/"
] |
375,976 | <p>For some reason when I download a zip folder from my server's folder it is always corrupted. Here is the code: </p>
<pre><code> protected void gvFiles_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e)
{
string fileUrl = String.Empty;
if(e.CommandName.Equals("DownloadFile"))
{
fileUrl = e.CommandArgument as String;
string fileName = Path.GetFileName(fileUrl);
Response.AppendHeader("content-disposition",
"attachment; filename=" + fileName);
Response.ContentType = "application/zip";
Response.WriteFile(fileUrl);
Response.End();
}
}
</code></pre>
<p>And here is how the GridView is populated: </p>
<pre><code>private void BindData()
{
List<SampleFile> files = new List<SampleFile>();
for(int i=1;i<=3;i++)
{
SampleFile sampleFile = new SampleFile();
sampleFile.Name = "File " + i;
sampleFile.Url = Server.MapPath("~/Files/File"+i+".txt");
files.Add(sampleFile);
}
SampleFile file = new SampleFile();
file.Name = "Zip File";
file.Url = Server.MapPath("~/Files/WebSiteNestedMasters.zip");
files.Add(file);
gvFiles.DataSource = files;
gvFiles.DataBind();
}
</code></pre>
| [
{
"answer_id": 376141,
"author": "azamsharp",
"author_id": 3797,
"author_profile": "https://Stackoverflow.com/users/3797",
"pm_score": 0,
"selected": false,
"text": "fileUrl = e.CommandArgument as String;\n string fileName = Path.GetFileName(fileUrl);\n\n Fi... | 2008/12/17 | [
"https://Stackoverflow.com/questions/375976",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3797/"
] |
375,977 | <p>What would be the best way to call a method in the code-behind of parent page from the code behind of the child page in the ASP.NET 2.0 Web Site model?</p>
<p><b>Scenario:</b> User clicks a link in the parent page to view a data record's detail in child page (The parent and child are tow seperate pages). The user will modified the data in the client page. Once the child page has processed the update, the child page will close and I need to rebind the parent page to reflect the update.</p>
<p>I did something similar, but it was calling the parent page from a user control that was included in the parent page</p>
<pre><code>if(Page.GetType().ToString().Contains("ASP.Default_aspx"))
{
MethodInfo MyMethod = this.Parent.TemplateControl.GetType().GetMethod("MyMethod");
MyMethod.Invoke(this.Page, null);
MyMethod = null;
}
</code></pre>
<p><b>UPDATE:</b> I have to do this from the code behind because the child page closes after the data has been updated. </p>
| [
{
"answer_id": 375994,
"author": "Matt Briggs",
"author_id": 10771,
"author_profile": "https://Stackoverflow.com/users/10771",
"pm_score": 1,
"selected": false,
"text": "document.opener.location.href = \"url\"; \n"
},
{
"answer_id": 375999,
"author": "Kon",
"author_id": 2... | 2008/12/17 | [
"https://Stackoverflow.com/questions/375977",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26327/"
] |
375,991 | <p>I have an Excel spreadsheet that I want to import select columns into my SQL Server 2008 database table. The wizard didn't offer that option.</p>
<p>Do any easy code options exist?</p>
| [
{
"answer_id": 376017,
"author": "Ian G",
"author_id": 31765,
"author_profile": "https://Stackoverflow.com/users/31765",
"pm_score": 5,
"selected": false,
"text": "INSERT INTO [tblTemp] ([Column1], [Column2], [Column3], [Column4])\n\nSELECT A.[Column1], A.[Column2], A.[Column3], A.[Colum... | 2008/12/17 | [
"https://Stackoverflow.com/questions/375991",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47206/"
] |
375,992 | <p>I read this:
<a href="https://stackoverflow.com/questions/184254/type-systemwebuiwebcontrolssessionparameter-does-not-have-a-public-property-nam">link text</a></p>
<p>My dev box , everything runs fine. On production server, they installed V3.5 framework and i got to my site and i got this error.</p>
<p>Do I have to do something to get it to read the V3.5 assemblies?</p>
| [
{
"answer_id": 376017,
"author": "Ian G",
"author_id": 31765,
"author_profile": "https://Stackoverflow.com/users/31765",
"pm_score": 5,
"selected": false,
"text": "INSERT INTO [tblTemp] ([Column1], [Column2], [Column3], [Column4])\n\nSELECT A.[Column1], A.[Column2], A.[Column3], A.[Colum... | 2008/12/17 | [
"https://Stackoverflow.com/questions/375992",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38230/"
] |
375,996 | <p>I have two complex (i.e. objects with string, int, double, List and other home made data type) objects of the same type. I would like to compare the content of both of them to ensure that they are identical. Note: The object doesn't implement .Equals (I have no control on that) and doesn't implement IComparable. </p>
<p>Is there a generic way (reflection?) to compare the content of the two objects?</p>
<p>Thanks!</p>
| [
{
"answer_id": 376011,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 2,
"selected": false,
"text": "Equals EqualityComparer<T> List<T>"
},
{
"answer_id": 17033865,
"author": "Detlef Kroll",
"author_id"... | 2008/12/17 | [
"https://Stackoverflow.com/questions/375996",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42024/"
] |
376,003 | <p>I have a problem related to the <a href="http://en.wikipedia.org/wiki/Subset_sum_problem" rel="noreferrer">subset sum problem</a> and am wondering if the differences make it easier, i.e. solvable in a reasonable amount of time.</p>
<p>Given a value V, a set size L, and a sequence of numbers [1,N] S, how many size L subsets of S sum to less than V?</p>
<p>This is different than the subset sum problem in three ways: </p>
<ol>
<li>I care how many subsets are <strong>less</strong> than a given value, not how many are <strong>equal</strong>.</li>
<li>The subset sizes are fixed. </li>
<li>I care <strong>how many</strong> sets sum to less than V, not just whether any exist.</li>
</ol>
<p>Is there any reasonably efficient algorithm to solve this?</p>
<p>Edit:
Obviously, this can be done in O(N choose L) using a combination generating algorithm. What I'm really interested in is clever hacks to significantly speed it up past that.</p>
| [
{
"answer_id": 376085,
"author": "ShreevatsaR",
"author_id": 4958,
"author_profile": "https://Stackoverflow.com/users/4958",
"pm_score": 5,
"selected": true,
"text": " num[0][0][i] = 1\n for v = 1 to V:\n for k = 1 to L:\n num[v][k][i] = num[v][k][i-1] + num[v-S[i... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376003",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23903/"
] |
376,006 | <p>Can I put my "bin" folder with all of its .dll files at a higher level then the IIS Local Path/web root for the site? I need to keep my dll files in a directory outside of my project is this possible, I tried to use a virtual directory but .net seems to ignore it. </p>
<p>Can I use a virtual directory for my bin folder?</p>
<p><strong>DUPLICATE:</strong> More info provided here: <a href="https://stackoverflow.com/questions/375887/adding-net-code-to-a-classic-asp-website-cant-reference-namespaces-in-dll-file">adding .net code to a classic asp website, can't reference namespaces in .dll file</a></p>
| [
{
"answer_id": 376089,
"author": "schmoopy",
"author_id": 26685,
"author_profile": "https://Stackoverflow.com/users/26685",
"pm_score": 0,
"selected": false,
"text": "<runtime>\n <assemblyBinding xmlns=\"urn:schemas-microsoft-com:asm.v1\">\n <probing privatePath=\"MyCoolNewPath/bin\"... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376006",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42987/"
] |
376,019 | <p>I would like information on algorithms that can help identify commonality and differences between sets of overlapping data. </p>
<p>Using stackoverflow's tag system as an example:</p>
<p>Let's say this question has been given 5 tags. Let's say there are 1000 other questions that have at least one of these tags. Of these 1000 questions, how many of these questions have tags in common that my original post does not have?</p>
<p>Another more simple way of describing this is an auto-suggest tagging system :</p>
<p>"You tagged your question with [5 tags I selected]. Other similiar questions were tagged with [list of tags that might be of interest]. where [list of tags that might be of interest] are frequently occuring tags that aren't in my orginal list.</p>
<p>Code examples in c# if possible :)</p>
| [
{
"answer_id": 376207,
"author": "Paul W Homer",
"author_id": 43371,
"author_profile": "https://Stackoverflow.com/users/43371",
"pm_score": 1,
"selected": true,
"text": "for each entry\n if any tag in original_tags\n tag_list[tag]++\nend\n\nfor next in tag_list\n tag_count[t... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376019",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47207/"
] |
376,021 | <p>Consider this sample code:</p>
<pre><code><div class="containter" id="ControlGroupDiv">
<input onbeforeupdate="alert('bingo 0'); return false;" onclick="alert('click 0');return false;" id="Radio1" type="radio" value="0" name="test" checked="checked" />
<input onbeforeupdate="alert('bingo 1'); return false;" onclick="alert('click 1');return false;" id="Radio2" type="radio" value="1" name="test" />
<input onbeforeupdate="alert('bingo 2'); return false;" onclick="alert('click 2');return false;" id="Radio3" type="radio" value="2" name="test" />
<input onbeforeupdate="alert('bingo 3'); return false;" onclick="alert('click 3');return false;" id="Radio4" type="radio" value="3" name="test" />
<input onbeforeupdate="alert('bingo 4'); return false;" onclick="alert('click 4');return false;" id="Radio5" type="radio" value="4" name="test" />
<input onbeforeupdate="alert('bingo 5'); return false;" onclick="alert('click 5');return false;" id="Radio6" type="radio" value="5" name="test" />
</div>
</code></pre>
<p>On FireFox 2 and 3, putting the <code>return false</code> on the click event of a radio button prevents the value of it and of all the other radio buttons in the group from changing. This effectively makes it read-only without disabling it and turning it gray.</p>
<p>On Internet Explorer, if another radio button is checked and you click on a different one in the group, the checked one clears before the click event fires on the one you clicked. However, the one you clicked on does not get selected because of the 'return false' on the click event. </p>
<p><a href="http://msdn.microsoft.com/en-us/library/ms536913(VS.85).aspx" rel="noreferrer">According to MSDN</a>, the <a href="http://msdn.microsoft.com/en-us/library/ms536908(VS.85).aspx" rel="noreferrer"><code>onbeforeupdate</code></a> event fires on all controls in the control group before the click event fires and I assumed that was where the other radio button was being cleared. But if you try the code above, no alert is ever shown from the <code>onbeforeupdate</code> event - you just get the click event alert. Evidently that event is never getting fired or there isn't a way to trap it.</p>
<p>Is there any event you can trap that allows you to prevent other radio buttons in the group from clearing?</p>
<p>Note that this is a simplified example, we are actually using jQuery to set event handlers and handle this.</p>
<p><strong>Update:</strong> </p>
<p>If you add this event to one of the radio buttons:</p>
<pre><code>onmousedown="alert('omd'); return false;"
</code></pre>
<p>The alert box pops up, you close it, and the click event <em>never fires</em>. So we thought we had it figured out, but no, it couldn't be that easy. If you remove the alert and change it to this: </p>
<pre><code>onmousedown="return false;"
</code></pre>
<p>It doesn't work. The other radio button clears and the click event on the button you clicked on fires. <code>onbeforeupdate</code> still never fires.</p>
<p>We thought it might be timing (that's always a theory even though it's rarely true), so I tried this:</p>
<pre><code>onmousedown="for (i=0; i<100000; i++) {;}; return false;"
</code></pre>
<p>You click, it pauses for a while, then the other radio button clears and then the click event fires. Aaargh!</p>
<p><strong>Update:</strong></p>
<p>Internet Explorer sucks. Unless someone comes up with a good idea, we're abandoning this approach and going with the checkbox jQuery extension which does do what we want, but puts a heavier client-side script burden on the page and requires more recoding of the HTML because of the ASP.Net server control rendering and master-page name mangling.</p>
| [
{
"answer_id": 376096,
"author": "Diodeus - James MacFarlane",
"author_id": 12579,
"author_profile": "https://Stackoverflow.com/users/12579",
"pm_score": 2,
"selected": false,
"text": "<form name=\"f1\">\n<input type=radio onmouseover=\"recordMe()\" onclick=\"clickCheck();return false\" ... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376021",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14894/"
] |
376,022 | <p>I'm pretty much into lisp at the moment, and unfortunately i'm only available to code on windows. Is is possible to let Notepad++ take care of the interpreting of my scripts, and display the output in the compiler window?</p>
<p>If yes, what interpreter would be the best to use?</p>
<p>Thanks!</p>
| [
{
"answer_id": 376456,
"author": "Tamara Wijsman",
"author_id": 47064,
"author_profile": "https://Stackoverflow.com/users/47064",
"pm_score": 2,
"selected": false,
"text": "CLISP sourceFile\n"
},
{
"answer_id": 62080991,
"author": "Patrik Gustafsson",
"author_id": 4727552... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376022",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
376,036 | <p>I have two raw sound streams that I need to add together. For the purposes of this question, we can assume they are the same bitrate and bit depth (say 16 bit sample, 44.1khz sample rate).</p>
<p>Obviously if I just add them together I will overflow and underflow my 16 bit space. If I add them together and divide by two, then the volume of each is halved, which isn't correct sonically - if two people are speaking in a room, their voices don't become quieter by half, and a microphone can pick them both up without hitting the limiter.</p>
<ul>
<li>So what's the correct method to add these sounds together in my software mixer? </li>
<li>Am I wrong and the correct method is to lower the volume of each by half? </li>
<li>Do I need to add a compressor/limiter or some other processing stage to get the volume and mixing effect I'm trying for?</li>
</ul>
<p>-Adam</p>
| [
{
"answer_id": 377433,
"author": "Mark Heath",
"author_id": 7532,
"author_profile": "https://Stackoverflow.com/users/7532",
"pm_score": 4,
"selected": false,
"text": "short sample1 = ...;\nshort sample2 = ...;\nfloat samplef1 = sample1 / 32768.0f;\nfloat samplef2 = sample2 / 32768.0f;\nf... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376036",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2915/"
] |
376,040 | <p>Currently I am designing a website and I am finding it VERY difficult to display the website perfect on ALL browsers. </p>
<p>Is there any rules, suggestions etc to follow?</p>
<p>Thanks</p>
| [
{
"answer_id": 376211,
"author": "Ben Blank",
"author_id": 46387,
"author_profile": "https://Stackoverflow.com/users/46387",
"pm_score": 5,
"selected": false,
"text": "text/html font-size: 10px; font-size: smaller; font-size: 80%;"
},
{
"answer_id": 376624,
"author": "Bobby C... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376040",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44973/"
] |
376,068 | <p>If I wrap a SQLConnection in a Using, should I close it or does the end using handle it?</p>
<pre><code>using cn as new system.data.sqlclient.sqlconnection()
cn.open
'{do a bunch of other stuff with commands and datareaders here}
cn.close 'Do I need this?
end using
</code></pre>
| [
{
"answer_id": 376070,
"author": "matt b",
"author_id": 4249,
"author_profile": "https://Stackoverflow.com/users/4249",
"pm_score": 8,
"selected": true,
"text": "cn"
},
{
"answer_id": 376087,
"author": "Matt Briggs",
"author_id": 10771,
"author_profile": "https://Stac... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376068",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1616/"
] |
376,071 | <p>My windows service is creating a directory on a shared folder, and I am getting a error:</p>
<pre><code>at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.Directory.InternalCreateDirectory(String fullPath, String path,DirectorySecurity dirSecurity)
at System.IO.Directory.CreateDirectory(String path, DirectorySecurity directorySecurity)
at System.IO.Directory.CreateDirectory(String path) at
</code></pre>
<p>I referencing the shared folder like: <code>\\255.255.255.255\myfolder.uploads\</code></p>
<p>Any ideas on what I have to do to be able to write to this folder? The share has Everyone and fullcontrol setup on it.</p>
<p><b>Updates</b></p>
<p>Do I have to impersonate a user on the other server somehow?</p>
| [
{
"answer_id": 1168666,
"author": "Jonathan Escobedo",
"author_id": 1388553,
"author_profile": "https://Stackoverflow.com/users/1388553",
"pm_score": 0,
"selected": false,
"text": "string DIR_CONTA = \"\\\\\\\\192.168.0.X\\\\folder\\\\subfolder\";\n"
}
] | 2008/12/17 | [
"https://Stackoverflow.com/questions/376071",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39677/"
] |
376,081 | <p>I am trying to work out how to get the value of table cell for each row using jQuery.</p>
<p>My table looks like this:</p>
<pre><code><table id="mytable">
<tr>
<th>Customer Id</th>
<th>Result</th>
</tr>
<tr>
<td>123</td>
<td></td>
</tr>
<tr>
<td>456</td>
<td></td>
</tr>
<tr>
<td>789</td>
<td></td>
</tr>
</table>
</code></pre>
<p>I basically want to loop through the table, and get the value of the <code>Customer Id</code> column for each row.</p>
<p>In the code below I have worked out that I need to do this to get it looping through each row, but I'm not sure how to get the value of the first cell in the row.</p>
<pre><code>$('#mytable tr').each(function() {
var cutomerId =
}
</code></pre>
| [
{
"answer_id": 376091,
"author": "Strelok",
"author_id": 2788,
"author_profile": "https://Stackoverflow.com/users/2788",
"pm_score": 3,
"selected": false,
"text": "$('#mytable tr').each(function() {\n // need this to skip the first row\n if ($(this).find(\"td:first\").length > 0) {\n ... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376081",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47212/"
] |
376,090 | <p>I have an NSDictionary (stored in a plist) that I'm basically using as an associative array (strings as keys and values). I want to use the array of keys as part of my application, but I'd like them to be in a specific order (not really an order that I can write an algorithm to sort them into). I could always store a separate array of the keys, but that seems kind of kludgey because I'd always have to update the keys of the dictionary as well as the values of the array, and make sure they always correspond. Currently I just use [myDictionary allKeys], but obviously this returns them in an arbitrary, non-guaranteed order. Is there a data structure in Objective-C that I'm missing? Does anyone have any suggestions on how to more elegantly do this?</p>
| [
{
"answer_id": 376925,
"author": "Ashley Clark",
"author_id": 4556,
"author_profile": "https://Stackoverflow.com/users/4556",
"pm_score": 3,
"selected": false,
"text": "-count -objectForKey: -keyEnumerator -removeObjectForKey: -setObject:forKey: -copyWithZone: -mutableCopyWithZone: -enco... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376090",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44858/"
] |
376,093 | <pre><code>@Column(name="DateOfBirth")
private Date dateOfBirth;
</code></pre>
<p>I specifically need the above code to create a column named "DateOfBirth," instead Hibernate gives me a column named date_of_birth. How can I change this? Is there a web.xml property? I came across DefaultNamingStrategy and ImprovedNamingStrategy, but not sure how to specify one or the other.</p>
| [
{
"answer_id": 376118,
"author": "Ryan Anderson",
"author_id": 13308,
"author_profile": "https://Stackoverflow.com/users/13308",
"pm_score": 3,
"selected": false,
"text": "@Column(name=\"DateOfBirth\")\npublic Date getDateOfBirth() {\n...\n}\n"
},
{
"answer_id": 376275,
"auth... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376093",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31172/"
] |
376,101 | <p>I did see the question about setting the proxy for the JVM but what I want to ask is how one can utilize the proxy that is already configured (on Windows).</p>
<p>Here is a demonstration of my issue: </p>
<blockquote>
<blockquote>
<ol>
<li>Go to your Control Panel->Java and set a proxy address. </li>
<li>Run the following simple applet code (I'm using the Eclipse IDE): </li>
</ol>
</blockquote>
</blockquote>
<pre><code>import java.awt.Graphics;
import javax.swing.JApplet;
import java.util.*;
public class Stacklet extends JApplet {
private String message;
public void init(){
Properties props = System.getProperties();
message = props.getProperty("http.proxyHost", "NONE");
message = (message.length() == 0)? "NONE": message;
}
public void paint(Graphics g)
{
g.drawString(message, 20, 20);
}
}
</code></pre>
<p>The Applet displays "NONE" without regard to the settings you've placed in the Java Control Panel. What would be best would be if the Windows proxy settings (usually set in Internet Explorer) were what I could determine but doing an extra configuration step in the Java Control Panel would still be an acceptable solution.</p>
<p>Thanks!</p>
| [
{
"answer_id": 381698,
"author": "t3rse",
"author_id": 64,
"author_profile": "https://Stackoverflow.com/users/64",
"pm_score": 6,
"selected": true,
"text": "System.setProperty(\"java.net.useSystemProxies\", \"true\");\nSystem.out.println(\"detecting proxies\");\nList l = null;\ntry {\n ... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376101",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/64/"
] |
376,103 | <p>I am looking to distribute an open source iPhone app and I have a few questions about making the source distribution:</p>
<ol>
<li><p>How can I automate creating the source archive (or diskimage) with XCode? I want something along the lines of a build target which archives the source (cleaning targets first if necessary, but it would be nice if it didn't have to). I also have an external netbeans project with a ruby script that is used to build an SQL database that the program needs (but can make a separate archive of that if necessary).</p></li>
<li><p>What's the best way to identify the files that constitute the 'source'? Is it simply anything that's left after cleaning all targets? Any caveats with that approach (I don't quite trust IDEs to clean up all the cruft they seem to make - also is this liable to include any codesigning stuff that it shouldn't)?</p></li>
</ol>
| [
{
"answer_id": 843619,
"author": "Wanderer",
"author_id": 104115,
"author_profile": "https://Stackoverflow.com/users/104115",
"pm_score": 0,
"selected": false,
"text": "rm -f \"$APPFILE.zip\" && zip -ry \"$APPFILE.zip\" \"$APPFILE\" && open .\n rm -rf \"$IPAFILE\" iTunesArtwork Payload &... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376103",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42404/"
] |
376,104 | <p>I placed a UITextField into a UIAlertView and moved it up so the keyboard wouldn't cover it up with the following code:</p>
<pre><code>[dialog setDelegate:self];
[dialog setTitle:@"Enter Name"];
[dialog addButtonWithTitle:@"Cancel"];
[dialog addButtonWithTitle:@"OK"];
UITextField * nameField = [[UITextField alloc] initWithFrame:CGRectMake(20.0, 45.0, 245.0, 25.0)];
[nameField setBackgroundColor:[UIColor whiteColor]];
[dialog addSubview:nameField];
CGAffineTransform moveUp = CGAffineTransformMakeTranslation(0.0, 100.0);
[dialog setTransform: moveUp];
[dialog show];
</code></pre>
<p>I also have the following code to deal with the alert view:</p>
<pre><code>- (void) alertView:(UIAlertView *)alert clickedButtonAtIndex:(NSInteger)buttonIndex{
NSLog(@"%d", (int) buttonIndex);
if (buttonIndex == 1) { // OK pushed
NSLog([alert textField].text); // does not log anything
} else {
// Cancel pushed
}}
</code></pre>
<p>I also have a UIAlertViewExtended.h file that contains:</p>
<pre><code>@class UITextField, UILabel;
@interface UIAlertView(Extended)
-(UITextField *)textField;
@end
</code></pre>
<p>My question is how do I get the text the user entered and how do I dismiss the keyboard?</p>
<p>Thanks,
Ben</p>
| [
{
"answer_id": 376546,
"author": "user21293",
"author_id": 21293,
"author_profile": "https://Stackoverflow.com/users/21293",
"pm_score": 6,
"selected": true,
"text": "UIAlertView* dialog = [[UIAlertView alloc] init];\n[dialog setDelegate:self];\n[dialog setTitle:@\"Enter Name\"];\n[dialo... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376104",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21293/"
] |
376,105 | <p>I'm attempting to use Assembly.GetType("MyCompany.Class1.Class2") to dynamically get a type from a string.</p>
<pre><code>Assembly.GetType("MyCompany.Class1");
</code></pre>
<p>works as expected.</p>
<p>If I embed a class within another class such as:</p>
<pre><code>namespace MyCompany
{
public class Class1
{
//.....
public class Class2
{
//.....
}
}
}
</code></pre>
<p>and try to get the type Class2</p>
<pre><code>Assembly.GetType("MyCompany.Class1.Class2")
</code></pre>
<p>will return a null.</p>
<p>I'm using the .NET Frameworks 3.5 SP1</p>
<p>Does anyone know what I'm doing incorrectly and what I can do to fix this?</p>
<p>Thanks in advance</p>
<p>Kevin D. Wolf
Tampa, FL</p>
| [
{
"answer_id": 376113,
"author": "Christian C. Salvadó",
"author_id": 5445,
"author_profile": "https://Stackoverflow.com/users/5445",
"pm_score": 5,
"selected": true,
"text": " Assembly.GetType(\"MyCompany.Class1+Class2\");\n"
},
{
"answer_id": 376124,
"author": "plinth",
... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376105",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2723/"
] |
376,111 | <p>I would like to set some vim options in one file in the comments section.</p>
<p>For example, I would like to set this option in one file</p>
<pre><code>set syntax=python
</code></pre>
<p>The file does not have a .py extension and I am not interested in making my vim installation recognise all files with this extension as python files.</p>
<p>I know this can be done because I have seen it, but my googling for this has not yet been fruitful.</p>
| [
{
"answer_id": 376200,
"author": "Harper Shelby",
"author_id": 21196,
"author_profile": "https://Stackoverflow.com/users/21196",
"pm_score": 7,
"selected": true,
"text": "# vim: set syntax=python:\n"
},
{
"answer_id": 376225,
"author": "Ben Blank",
"author_id": 46387,
... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376111",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3045/"
] |
376,128 | <p>I have a dotnet windows service that's currently hung, but running. Is there anyway to attach a debugger to it, despite the lack of symbols; and that it's already running?</p>
| [
{
"answer_id": 376173,
"author": "Shog9",
"author_id": 811,
"author_profile": "https://Stackoverflow.com/users/811",
"pm_score": 4,
"selected": true,
"text": ".loadby sos mscorwks\n !clrstack"
}
] | 2008/12/17 | [
"https://Stackoverflow.com/questions/376128",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7756/"
] |
376,130 | <p>I Have following code:</p>
<p>Controller:</p>
<pre><code>public ActionResult Step1()
{
return View();
}
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Step1(FormCollection form)
{
TempData["messageStatus"] = new Random().Next(1, 1000);
return RedirectToAction("Step1");
}
</code></pre>
<p>View:</p>
<pre><code><%=TempData["messageStatus"]%>
</code></pre>
<p>in first time in view im getting <strong>12345</strong> for example, but when i request second time of course i must get something else instead <strong>12345</strong> for example <strong>54321</strong> but not, im getting same result <strong>12345</strong>, how can u explain it? <strong>RedirectToAction</strong> cache pages?</p>
<p>where does it mean i must put Guid in my urls for resolving problems with cache? what do u think about this issue?</p>
| [
{
"answer_id": 376148,
"author": "Todd Smith",
"author_id": 31624,
"author_profile": "https://Stackoverflow.com/users/31624",
"pm_score": 0,
"selected": false,
"text": "TempData[\"messageStatus\"] = new Random(DateTime.Now.Millisecond).Next(1, 1000);\n"
},
{
"answer_id": 376291,
... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376130",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2246271/"
] |
376,135 | <p>I've got a C# program with values in a config file. What I want is to store ampersands for an url value like...</p>
<pre><code><appSettings>
<add key="myurl" value="http://www.myurl.com?&cid=&sid="/>
</appSettings>
</code></pre>
<p>But I get errors building my site. The ampersand is not allowed. I've tried various forms of escaping the ampersands to no avail. Anyone know of the correct form to do this? All suggestions are welcome.</p>
| [
{
"answer_id": 376140,
"author": "Eric Rosenberger",
"author_id": 41624,
"author_profile": "https://Stackoverflow.com/users/41624",
"pm_score": 10,
"selected": true,
"text": "&"
},
{
"answer_id": 376152,
"author": "BenAlabaster",
"author_id": 40650,
"author_profil... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376135",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7285/"
] |
376,136 | <p>I have a Windows C++ program that is doing something like:<br></p>
<pre>
FILE* pf = ...;
*stdout = *pf; // stdout is defined in stdio.h
</pre>
<p>I'm looking for an explanation about what happens when you change the value of the stdout file handle. Is this just a way of redirecting stdout?</p>
<p>-cr</p>
| [
{
"answer_id": 376151,
"author": "Adam Rosenfield",
"author_id": 9530,
"author_profile": "https://Stackoverflow.com/users/9530",
"pm_score": 3,
"selected": false,
"text": "freopen() <stdio>"
},
{
"answer_id": 376172,
"author": "Jonathan Leffler",
"author_id": 15168,
"... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376136",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47154/"
] |
376,142 | <p>Is it possible to get a list of events (with recurring events expanded) out of Sharepoint's Calendar using the Web Service exposed through Lists.aspx?</p>
<p>This is evidently possible if you are using C# or VB, as described <a href="http://blogs.msdn.com/sharepoint/archive/2007/05/14/understanding-the-sharepoint-calendar-and-how-to-export-it-to-ical-format.aspx" rel="nofollow noreferrer">here</a> using a snippet like this:</p>
<pre><code>SPQuery query = new SPQuery();
query.ExpandRecurrence = true;
query.Query = "<Where><DateRangesOverlap><FieldRef Name=\"EventDate\" /><FieldRef Name=\"EndDate\" /><FieldRef Name=\"RecurrenceID\" /><Value Type=\"DateTime\"><Month /></Value></DateRangesOverlap></Where>";
</code></pre>
<p>I am trying to do the same using plain XML via cURL with this query:</p>
<pre><code><GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<listName>{my guid goes here}</listName>
<query>
<Query xmlns="">
<Where>
<DateRangesOverlap>
<FieldRef Name="EventDate" />
<FieldRef Name="EndDate" />
<FieldRef Name="RecurrenceID" />
<Value Type="DateTime"><Month/></Value>
</DateRangesOverlap>
</Where>
</Query>
</query>
<queryOptions>
<QueryOptions>
<ExpandRecurrence>TRUE</ExpandRecurrence>
</QueryOptions>
</queryOptions>
</code></pre>
<p></p>
<p>This kinda works - it gets all the list items, but recurring items are not expanded. The key seems to be the ExpandRecurrence property. Surprisingly, Google does not seem to have a lot to say on the matter beyond a couple of blog posts. Scouring the web, I've read a few comments indicating that the ExpandRecurrence property does not work, but others say it works fine and nothing I've read has struck me as definitive.</p>
<p>Has anybody tried this and gotten it to work without using C# or VB - just straight XML? </p>
| [
{
"answer_id": 4555158,
"author": "user557264",
"author_id": 557264,
"author_profile": "https://Stackoverflow.com/users/557264",
"pm_score": 3,
"selected": false,
"text": "<GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>\n<listName>{your GUID goes here}</listName>\n<q... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376142",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23977/"
] |
376,144 | <p>I'm writing some routes for a REST service. One of my resource's URI looks like this</p>
<p>resources/user/:id</p>
<p>I also want to give access to individual attributes of a user, which would look like this</p>
<p>resources/user/:id/:attribute</p>
<p>But when I try to define that latter route, it doesn't work. Here's my ini where the routes are defined</p>
<pre><code>routes.user.route = "resources/user/:id"
routes.user.defaults.controller = user
routes.user.defaults.action = get
routes.user.defaults.id = 0
routes.user.reqs.id = "\d+"
routes.user_attribute.route = "resources/user/:id/:attribute/"
routes.user_attribute.defaults.controller = user
routes.user_attribute.defaults.action = getAttribute
routes.user_attribute.defaults.id = 0
routes.user_attribute.defaults.attribute = ""
routes.user_attribute.reqs.id = "\d+"
routes.user_attribute.reqs.id = "reviews|lists"
</code></pre>
<p>When I try to access resources/user/4/reviews in my browser, I get the following output</p>
<pre><code>An error occurred
Page not found
Exception information:
Message: Invalid controller specified (resources)
Stack trace:
#0 /usr/local/lib/ZendFramework/ZendFramework-1.7.1-minimal/library/Zend/Controller/Front.php(934): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#1 /home/baileyp/public_html/web/index.php(50): Zend_Controller_Front->dispatch()
#2 {main}
Request Parameters:
array(4) {
["controller"]=>
string(9) "resources"
["action"]=>
string(4) "user"
[10]=>
string(7) "reviews"
["module"]=>
string(7) "default"
}
</code></pre>
<p>So, it's clearly not processing my 2nd route correctly, since it things the controller is "resources" and the action is "user". What am I doing wrong here? There's no examples on the Zend site that I've found that illustrate how to implement this.</p>
<p>And I don't want to use modules just to get this done - avoiding the creation of folders and such just to match a URI is the entire purpose of a routing system.</p>
| [
{
"answer_id": 4555158,
"author": "user557264",
"author_id": 557264,
"author_profile": "https://Stackoverflow.com/users/557264",
"pm_score": 3,
"selected": false,
"text": "<GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>\n<listName>{your GUID goes here}</listName>\n<q... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376144",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8815/"
] |
376,154 | <p>This is a follow-up to my <a href="https://stackoverflow.com/questions/372695/is-there-a-standard-c-function-object-for-taking-apart-a-stdpair">question from yesterday</a>. I have Scott Meyers' warning about write-only code on my mind. I like the idea in principle of using standard algorithms to access the keys or values of a std::map, but the syntax required is a little baroque IMHO. Let's say I want to dump all the keys of a map to a vector. Given following declarations,</p>
<pre><code>typedef std::map<int, int> MyMap;
MyMap m;
std::vector<int> v;
</code></pre>
<p>which code is more maintainable (i.e., potentially less confusing)?</p>
<p>Option #1:</p>
<pre><code>std::transform(m.begin(),
m.end(),
std::back_inserter(v),
std::tr1::bind(&MyMap::value_type::first, _1));
</code></pre>
<p>Option #2:</p>
<pre><code>for (MyMap::iterator i = m.begin(); i != m.end(); ++i)
{
v.push_back(i->first);
}
</code></pre>
<p>Option 1 is more standard library-ish but I have to mentally decompose it to understand what's going on. Option 2 seems easier to read at the expense of a possible small runtime penalty. I'm not hurting for CPU time so I'm leaning toward option 2. Does you guys agree? Is there a third option I should consider?</p>
<p>P.S. Over the course of writing this question I concluded that the best way (for my project) to read the keys of a std::map is to store them off in a side container and iterate over that. The maintainability question still stands though.</p>
| [
{
"answer_id": 376177,
"author": "Nemanja Trifunovic",
"author_id": 8899,
"author_profile": "https://Stackoverflow.com/users/8899",
"pm_score": 2,
"selected": false,
"text": "m.end()"
},
{
"answer_id": 376244,
"author": "Head Geek",
"author_id": 12193,
"author_profile... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376154",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46821/"
] |
376,156 | <p>I don't really get it and it's driving me nuts.
i've these 4 lines:</p>
<pre><code>Image img = Image.FromFile("F:\\Pulpit\\soa.bmp");
MemoryStream imageStream = new MemoryStream();
img.Save(imageStream, ImageFormat.Bmp);
byte[] contentBuffer = new byte[imageStream.Length];
imageStream.Read(contentBuffer, 0, contentBuffer.Length);
</code></pre>
<p>when debugging i can see the bytes values in imageStream. after imageStream.Read i check content of contentBuffer and i see only 255 values.
i can't get why is it happening? there is nothing to do wrong in these few lines!
if anyone could help me it would be greatly appreciated!
thanks,
agnieszka</p>
| [
{
"answer_id": 376171,
"author": "Joel Lucsy",
"author_id": 645,
"author_profile": "https://Stackoverflow.com/users/645",
"pm_score": 5,
"selected": false,
"text": "imageStream.Seek( 0, SeekOrigin.Begin );\n"
},
{
"answer_id": 376191,
"author": "BenAlabaster",
"author_id"... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376156",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40872/"
] |
376,170 | <p>Visual Studio fails to deploy reports or data sources on remote MSRS instance. Error message is</p>
<blockquote>
<p>Unable to connect to the remote server.</p>
</blockquote>
<p>The server is up and running and <code>TargetServerURL</code> property of the project points to correct url which works in the browser.</p>
<p>I googled around but and found a few forum threads discussing the same issue but none of them had any relevant resolution. </p>
<p>I am using <code>VS2008</code> and <code>MSRS 2008</code>.</p>
<p>Has anyone seen this before? Any ideas how to fix this?</p>
| [
{
"answer_id": 376224,
"author": "Rex Morgan",
"author_id": 46429,
"author_profile": "https://Stackoverflow.com/users/46429",
"pm_score": 2,
"selected": false,
"text": "http://server/ReportServer/ http://server/Reports/"
},
{
"answer_id": 3860131,
"author": "Aftab",
"auth... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376170",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
376,174 | <p>I am having an issue with linq updating in linqtosql</p>
<p>from the code below</p>
<pre><code>Dim lqPatientTable As New lqHospitalDataContext
Dim strPatientId As String
strPatientId = Me.ucboPatientInfo.SelectedRow.Cells(5).Value
Dim lqPatientName = (From lqp In lqPatientTable.Patients _
Where lqp.PatientID = strPatientId _
Select lqp.FirstName, lqp.LastName)
For Each row In lqPatientName
row.LastName = utxtPatientLastName.Text
row.FirstName = utxtPatientFirstName.Text
Next
lqPatientTable.SubmitChanges()
</code></pre>
<p>Visual Studio tells me that row.LastName is readonly I have not made that asignment anywhere, and I cannot see where the issue is.</p>
| [
{
"answer_id": 376198,
"author": "JaredPar",
"author_id": 23283,
"author_profile": "https://Stackoverflow.com/users/23283",
"pm_score": 1,
"selected": false,
"text": "Dim x = New With { Key .Name =\"foo\" }\n"
}
] | 2008/12/17 | [
"https://Stackoverflow.com/questions/376174",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5578/"
] |
376,188 | <p>I have a class that extends Zend_Form like this (simplified):</p>
<pre><code>class Core_Form extends Zend_Form
{
protected static $_elementDecorators = array(
'ViewHelper',
'Errors',
array('Label'),
array('HtmlTag', array('tag' => 'li')),
);
public function loadDefaultDecorators()
{
$this->setElementDecorators(self::$_elementDecorators);
}
}
</code></pre>
<p>I then use that class to create all of my forms:</p>
<pre><code>class ExampleForm extends Core_Form
{
public function init()
{
// Example Field
$example = new Zend_Form_Element_Hidden('example');
$this->addElement($example);
}
}
</code></pre>
<p>In one of my views, I have a need to display <em>only</em> this one field (without anything else generated by Zend_Form). So in my view I have this:</p>
<pre><code><?php echo $this->exampleForm->example; ?>
</code></pre>
<p>This works fine, except for it generates the field like this:</p>
<pre><code><li><input type="hidden" name="example" value=""></li>
</code></pre>
<p>This is obviously because I set the element decorators to include HtmlTag: tag => 'li'.</p>
<p><strong>My question is: How can I disable all decorators for this element. I don't need decorators for hidden input elements.</strong></p>
| [
{
"answer_id": 376487,
"author": "Barrett Conrad",
"author_id": 1227,
"author_profile": "https://Stackoverflow.com/users/1227",
"pm_score": 2,
"selected": false,
"text": "<?php echo $this->exampleForm->example->setDecorators(array('ViewHelper')) ; ?>\n"
},
{
"answer_id": 377554,
... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376188",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3765/"
] |
376,201 | <p>Normally to attach a debuger to a running jvm you would need start the jvm with arguments such as the following:</p>
<pre><code>> java -Xdebug -Xrunjdwp:transport=dt_socket,address=1000,server=y,suspend=n
</code></pre>
<p>Now if I want to debug a process that wasn't started in debug mode, what can I do?</p>
<p>This situation arrises when a production system (i.e. started without debug args) exhibits a 'random' (I use the term loosely) bug. So I can't restart the jvm with the appropriate arguments, because nobody knows how to reproduce the bug again. Is it impossible to attach to the JVM in this situation?</p>
<p>Just to clarify it is not possible to use tools like jdb to attach to already running JVMs unless they were started in debug mode</p>
<p>from the JVM man page</p>
<blockquote>
<p><strong>Another way to use jdb is by attaching it to a Java VM that is
already running. A VM that is to be
debugged with jdb must be started with
the following options:</strong></p>
</blockquote>
| [
{
"answer_id": 376276,
"author": "McDowell",
"author_id": 304,
"author_profile": "https://Stackoverflow.com/users/304",
"pm_score": 7,
"selected": true,
"text": "jsadebugd <pid>\njdb -connect sun.jvm.hotspot.jdi.SADebugServerAttachingConnector:debugServerName=localhost\n jdb -listconnect... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376201",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42303/"
] |
376,208 | <p>I'm trying to connect to a remote private MSMQ queue using the path:</p>
<pre><code>"FormatName:DIRECT=OS:remoteMachineName\Private$\MyQueue"
</code></pre>
<p>and I'm getting the following error: </p>
<pre><code>"The specified format name does not support the requested operation. For example, a direct queue format name cannot be deleted."
</code></pre>
<p>I'm obviously doing something wrong. However this does work using a local queue.</p>
<p>I'm using Spring.Net's <a href="http://www.springframework.net/doc-latest/reference/html/msmq.html" rel="nofollow noreferrer">Messaging</a>. Here's my config</p>
<pre class="lang-xml prettyprint-override"><code><objects xmlns="http://www.springframework.net">
<object id="myQueue" type="Spring.Messaging.Support.MessageQueueFactoryObject, Spring.Messaging">
<property name="Path" value="FormatName:DIRECT=OS:remoteMachineName\Private$\MyQueue"/>
</object>
<object id="messageQueueTemplate" type="Spring.Messaging.Core.MessageQueueTemplate, Spring.Messaging">
<property name="DefaultMessageQueueObjectName" value="myQueue"/>
</object>
<object id="messageGateway" type="My.MessageGateway, My.Assembly">
<property name="MessageQueueTemplate" ref="messageQueueTemplate"/>
</object>
</objects>
</code></pre>
| [
{
"answer_id": 412620,
"author": "Erich Eichinger",
"author_id": 51264,
"author_profile": "https://Stackoverflow.com/users/51264",
"pm_score": -1,
"selected": false,
"text": "\"FormatName:DIRECT=OS:remoteMachineName\\Private$\\MyQueue\"\n \"FormatName:Direct=OS:remoteMachineName\\\\priva... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376208",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2311/"
] |
376,221 | <p>I'd like to automate data entry into Excel spreadsheets. User data will exist on a web site, and when the user requests it, that data will need to be injected into an Excel spreadsheet. The complication is that the format of the Excel spreadsheet can vary significantly between users - it'll be user defined.</p>
<p>I've been thinking of this as a templating problem - the excel spreadsheet provides the template, and the task s to inject data into specific user defined cells within that template.</p>
<p>I've looked at xlwt and xlrd for python, as well as jexcelapi and POI-HSSF for Java. They seem like they could work, but given that I simply want to put values into certain cells, they seem like overkill. I'm also worried about re-writing the user's spreadsheet after processing; seems like an opportunity to introduce errors into the process.</p>
<p>Is there a way to tell excel to merge the data from one sheet into another? I'm thinking I could produce a simple spreadsheet that has only the data, and somehow get Excel to merge it into the user's existing spreadsheet.</p>
<p>Make sense? Better approaches?</p>
| [
{
"answer_id": 376396,
"author": "Fionnuala",
"author_id": 2548,
"author_profile": "https://Stackoverflow.com/users/2548",
"pm_score": 1,
"selected": false,
"text": "Dim HttpReq As Object\n\n' Create the WinHTTPRequest ActiveX Object.'\nSet HttpReq = New WinHttpRequest\n\n' Open an HTTP ... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376221",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13055/"
] |
376,232 | <p>I'm using C++ .NET 2.0</p>
<p>I have 2 forms</p>
<p>the first one is declared as follow</p>
<pre><code>#include "stdafx.h"
namespace myNamespace{
public ref class frmMain : public System::Windows::Forms::Form {
/*... snip ...*/
public void addNewRow(String^ text){ /*... snip... */ }
public void launchSubForm() { SubForm^ sf = gcnew SubForm(this); sf->Show(); }
};
}
</code></pre>
<p>the second one goes like this </p>
<pre><code>#include stdafx.h
namespace myNamespace{
ref class frmMain;
public ref class SubForm : public System::Windows::Forms::Form {
frmMain^ myMain;
SubForm ( frmMain^ pMain){
myMain = pMain;
}
/*... snip ...*/
public void exportRows(String^ text){ /*... snip... */ }
myMain->addNewRow("myNewText"); <--- This line causes compile error
};
}
</code></pre>
<p>in stdafx.h i have</p>
<pre><code>/*... snip... */
#include "SubForm.h"
#include "frmMain.h"
</code></pre>
<p>Now to the question!
The line in SubForm causes the compiler to tell me "use of undefined type myNamespace::frmMain</p>
<p>I really have no clue about why the "ref class frmMain" doesnt solve this problem</p>
| [
{
"answer_id": 376287,
"author": "e.James",
"author_id": 33686,
"author_profile": "https://Stackoverflow.com/users/33686",
"pm_score": 3,
"selected": true,
"text": "public void exportRows(String^ text); public void SubForm::exportRows(String^ text)\n{\n /*... snip ...*/\n myMain->a... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376232",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6367/"
] |
376,234 | <p>System.Drawing.Color objects apparently won't serialize with XmlSerializer. What is the best way to xml serialize colors?</p>
| [
{
"answer_id": 376254,
"author": "BenAlabaster",
"author_id": 40650,
"author_profile": "https://Stackoverflow.com/users/40650",
"pm_score": 6,
"selected": true,
"text": "String HtmlColor = System.Drawing.ColorTranslator.ToHtml(MyColorInstance);\n Color MyColor = System.Drawing.ColorTrans... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376234",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28343/"
] |
376,236 | <p>I have a basically sql select question that people gave me different answers over the years. Say I have a couple of tables designed each with over 40 columns and potentially will hold ten and thousands of row, I'm using SqlServer2005.</p>
<p>On joining these tables, in the where clause if I have things like</p>
<pre><code>select * from t1, t2
where t1.UserID = 5
and t1.SomeID = t2.SomeOtherID
</code></pre>
<p>some people say you should alwasys have the constant "t1.UserID = 5" up front rather than after the "t1.SomeID = t2.SomeOtherID", it boosts the select performance. While others say it doesn't matter.</p>
<p>What is the correct answer?</p>
<p>Also, if I use ADO.NET Entity Framework to implement my DAL, will modeling tables that have over 40 columns and doing CRUD operations be a performance issue to it?</p>
<p>Thank you,</p>
<p>Ray.</p>
| [
{
"answer_id": 376326,
"author": "Craig Stuntz",
"author_id": 7714,
"author_profile": "https://Stackoverflow.com/users/7714",
"pm_score": 2,
"selected": false,
"text": "SELECT * \nFROM t1\n INNER JOIN t2\n ON t1.SomeID = t2.SomeOtherID\nWHERE\n t1.UserID = 5 \n"
},
{
"answer... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376236",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32240/"
] |
376,237 | <p>We have an HTML page which displays a bunch of pretty bars using divs and repeating backgrounds. We are in the process of making a report out of this that can be printed nicely, but this may take some time because we don't have a reporting framework in place. As an interm solution we'd like to make the HTML version printable. The background of the divs are the only problem, and they don't print because of the default setting (which can't be enabled because the workstations are locked down). </p>
<p>I have <a href="http://www.web-graphics.com/mtarchive/001703.php" rel="nofollow noreferrer">found a work around</a> for printing background images, but this doesn't work when the background needs to be repeated. </p>
<p>Are there any other work arounds which might be able to help? I have also been trying to insert an image inside the dive and stretch it, but this is throwing off all the other relative positions and is proving to be very difficult to fix. I am still looking into this however.</p>
| [
{
"answer_id": 376326,
"author": "Craig Stuntz",
"author_id": 7714,
"author_profile": "https://Stackoverflow.com/users/7714",
"pm_score": 2,
"selected": false,
"text": "SELECT * \nFROM t1\n INNER JOIN t2\n ON t1.SomeID = t2.SomeOtherID\nWHERE\n t1.UserID = 5 \n"
},
{
"answer... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376237",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45/"
] |
376,239 | <p>I have an aspx page with a gridview. In my page load event, I load a datatable with all the data like so:</p>
<pre><code>HistoricalPricing historicalPricing = new HistoricalPricing();
DataTable dtHistoricalPricing = new DataTable();
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
dtHistoricalPricing = historicalPricing.GetAuctionData();
}
}
</code></pre>
<p>The above loades the data into the datatable fine. I also have a listbox which contains a list of auctions. When I click on an auction, I use the RowFilter on a DataView to display a Gridview with the data that was selected, but the DataTable seems to loose its value and I can't figure out why. Here is the code below:</p>
<pre><code>protected void lstAuctions_SelectedIndexChanged(object sender, EventArgs e)
{
DataView dvPricing = new DataView(dtHistoricalPricing); // Loses Value
dvPricing.RowFilter = "Auction = 1"; //Hard-Coded for Test
gvPricing.DataSource = dvPricing.ToTable();
gvPricing.DataBind();
}
</code></pre>
| [
{
"answer_id": 376283,
"author": "JamesSugrue",
"author_id": 1075,
"author_profile": "https://Stackoverflow.com/users/1075",
"pm_score": 1,
"selected": false,
"text": "DataTable dtHistoricalPricing = null;\n if (!Page.IsPostBack)\n{\n if (dtHistoricalPosting == null)\n {\n //sh... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376239",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33690/"
] |
376,242 | <p>What approach is the best way to make content-types restricted to a user in Django?</p>
<p>Let us say I want all users with the user-role "blogger" to have its own blog.</p>
<p>I have created a weblog app. How do I restrict it so that the user logged in can only post in his "own" blog, and how do I make views that shows only a user's blog?</p>
| [
{
"answer_id": 376739,
"author": "rombarcz",
"author_id": 47267,
"author_profile": "https://Stackoverflow.com/users/47267",
"pm_score": 3,
"selected": true,
"text": "class BlogEntry(models.Model):\n user = models.ForeignKey(User, related_name='blog_entries')\n other_field_1 = ...\n... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376242",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42546/"
] |
376,248 | <p>Simple question, and probably reflects my inexperience with CSS, but...</p>
<p>When creating a style sheet I like to explicitly specify the '*' wild card, so:</p>
<pre><code>*.TitleText {
</code></pre>
<p>instead of just</p>
<pre><code>.TitleText {
</code></pre>
<p>I find it reminds me that TitleText is applied to "any" tag, and can be overridden by a subsequent h1.TitleText. Maybe I just like this because for the longest time I didn't get that whole CSS selector concept properly and when I realized that the second (above) was just shorthand for the first, a lot of things "clicked".</p>
<p>Is what I do bad practice, good practice, or neither here nor there?</p>
| [
{
"answer_id": 376303,
"author": "WillCodeForCoffee",
"author_id": 31197,
"author_profile": "https://Stackoverflow.com/users/31197",
"pm_score": 0,
"selected": false,
"text": "span.style { color: red; }\n*.style { color: blue; }\n span#id { ... }\n*#id { ... }\n"
},
{
"answer_id"... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376248",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8946/"
] |
376,253 | <p>Is there a way to get a background in CSS to stretch or scale to fill its container?</p>
| [
{
"answer_id": 376270,
"author": "Vilx-",
"author_id": 41360,
"author_profile": "https://Stackoverflow.com/users/41360",
"pm_score": 3,
"selected": false,
"text": "<img> background-size"
},
{
"answer_id": 388817,
"author": "SolidSmile",
"author_id": 37630,
"author_pro... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376253",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8946/"
] |
376,278 | <p>Can it be assumed a evaluation order of the function parameters when calling it in C ? According to the following program, it seems that there is not a particular order when I executed it. </p>
<pre><code>#include <stdio.h>
int main()
{
int a[] = {1, 2, 3};
int * pa;
pa = &a[0];
printf("a[0] = %d\ta[1] = %d\ta[2] = %d\n",*(pa), *(pa++),*(++pa));
/* Result: a[0] = 3 a[1] = 2 a[2] = 2 */
pa = &a[0];
printf("a[0] = %d\ta[1] = %d\ta[2] = %d\n",*(pa++),*(pa),*(++pa));
/* Result: a[0] = 2 a[1] = 2 a[2] = 2 */
pa = &a[0];
printf("a[0] = %d\ta[1] = %d\ta[2] = %d\n",*(pa++),*(++pa), *(pa));
/* a[0] = 2 a[1] = 2 a[2] = 1 */
}
</code></pre>
| [
{
"answer_id": 376333,
"author": "Robert Gamble",
"author_id": 25222,
"author_profile": "https://Stackoverflow.com/users/25222",
"pm_score": 5,
"selected": false,
"text": "pa $ gcc -Wall -W -ansi -pedantic test.c -o test\ntest.c: In function ‘main’:\ntest.c:9: warning: operation on ‘pa’ ... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376278",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44808/"
] |
376,279 | <p>I have a script that needs to run after tomcat has finished starting up and is ready to start deploying applications. I'm using <code>$TOMCAT_HOME/bin/startup.sh</code> which returns immediately. How can I wait until tomcat has finished starting up?</p>
| [
{
"answer_id": 376305,
"author": "Matt Solnit",
"author_id": 6198,
"author_profile": "https://Stackoverflow.com/users/6198",
"pm_score": 6,
"selected": true,
"text": "#!/bin/bash\n\nuntil [ \"`curl --silent --show-error --connect-timeout 1 -I http://localhost:8080 | grep 'Coyote'`\" != \... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376279",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14481/"
] |
376,296 | <p>I have a number of native C++ libraries (Win32, without MFC) compiling under Visual Studio 2005, and used in a number of solutions. </p>
<p>I'd like to be able to choose to compile and link them as either static libraries or DLLs, depending on the needs of the particular solution in which I'm using them.</p>
<p>What's the best way to do this? I've considered these approaches:</p>
<h2>1. Multiple project files</h2>
<ul>
<li>Example: "foo_static.vcproj" vs "foo_dll.vcproj"</li>
<li>Pro: easy to generate for new libraries, not too much manual vcproj munging.</li>
<li>Con: settings, file lists, etc. in two places get out of sync too easily.</li>
</ul>
<h2>2. Single project file, multiple configurations</h2>
<ul>
<li>Example: "Debug | Win32" vs "Debug DLL | Win32", etc.</li>
<li>Pro: file lists are easier to keep in sync; compilation options are somewhat easier to keep in sync</li>
<li>Con: I build for both Win32 and Smart Device targets, so I already have multiple configurations; I don't want to make my combinatorial explosion worse ("Static library for FooPhone | WinMobile 6", "Dynamic library for FooPhone | WinMobile 6", "Static library for BarPda | WinMobile 6", etc. </li>
<li>Worse Con: VS 2005 has a bad habit of assuming that if you have a configuration defined for platform "Foo", then you really need it for all other platforms in your solution, and haphazardly inserts all permutations of configuration/platform configurations all over the affected vcproj files, whether valid or not. (Bug filed with MS; closed as WONTFIX.)</li>
</ul>
<h2>3. Single project file, selecting static or dynamic via vsprops files</h2>
<ul>
<li>Example: store the appropriate vcproj fragments in property sheet files, then apply the "FooApp Static Library" property sheet to config/platform combinations when you want static libs, and apply the "FooApp DLL" property sheet when you want DLLs.</li>
<li>Pros: <strong>This is what I really want to do!</strong></li>
<li>Cons: <strong>It doesn't seem possible.</strong> It seems that the .vcproj attribute that switches between static and dynamic libraries (the ConfigurationType attribute of the Configuration element) isn't overrideable by the .vsprops file. Microsoft's published schema for these files lists only <Tool> and <UserMacro> elements.</li>
</ul>
<p><strong>EDIT</strong>: In case someone suggests it, I've also tried a more "clever" version of #3, in which I define a .vsprops containing a UserMacro called "ModuleConfigurationType" with a value of either "2" (DLL) or "4" (static library), and changed the configuration in the .vcproj to have <code>ConfigurationType="$(ModuleConfigurationType)"</code>. Visual Studio silently and without warning removes the attribute and replaces it with <code>ConfigurationType="1"</code>. So helpful!</p>
<p>Am I missing a better solution?</p>
| [
{
"answer_id": 7182014,
"author": "Bill",
"author_id": 910576,
"author_profile": "https://Stackoverflow.com/users/910576",
"pm_score": 3,
"selected": false,
"text": "lib /NOLOGO /OUT:<your_lib_pathname> @<<\n<list_all_of_your_obj_paths_here>\n<<\n"
}
] | 2008/12/17 | [
"https://Stackoverflow.com/questions/376296",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14942/"
] |
376,306 | <p>Is '' a valid piece of XML?
Can '' insert into oracle xblob column or XML column from MSSQL?</p>
| [
{
"answer_id": 376325,
"author": "David Norman",
"author_id": 34502,
"author_profile": "https://Stackoverflow.com/users/34502",
"pm_score": 3,
"selected": false,
"text": "document ::= prolog element Misc*\n element ::= EmptyElemTag\n | STag content ETag \n"
},
{
"... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376306",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11413/"
] |
376,335 | <p>I'm in the process of implementing a binary tree in C++. Traditionally, I'd have a pointer to left and a pointer to right, but manual memory management typically ends in tears. Which leads me to my question...</p>
<p>Are data structures an appropriate place to use shared_ptr?</p>
| [
{
"answer_id": 376389,
"author": "Daniel Earwicker",
"author_id": 27423,
"author_profile": "https://Stackoverflow.com/users/27423",
"pm_score": 2,
"selected": false,
"text": "shared_ptr shared_ptr"
},
{
"answer_id": 376409,
"author": "Harper Shelby",
"author_id": 21196,
... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376335",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1473493/"
] |
376,338 | <p>The same as <a href="https://stackoverflow.com/questions/367633/what-are-all-the-common-undefined-behaviour-that-c-programmer-should-know-about">this</a> question but for java</p>
<p><strong>Update</strong>
Based on the comments and responses of a few people, Its clear that Java has very little undefined behaviour.</p>
<p>So I'd like to ask as well what behaviour is not <em>obvious.</em> Please when answering make the distinction between the two :)</p>
| [
{
"answer_id": 376365,
"author": "OscarRyz",
"author_id": 20654,
"author_profile": "https://Stackoverflow.com/users/20654",
"pm_score": 1,
"selected": false,
"text": "new String(\"test\") == new String(\"test\") \n new String(\"test\").equals( new String(\"test\") )\n String a = \"test\... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376338",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42303/"
] |
376,344 | <p>I have a simple piece of code:</p>
<pre><code>public string GenerateRandomString()
{
string randomString = string.Empty;
Random r = new Random();
for (int i = 0; i < length; i++)
randomString += chars[r.Next(chars.Length)];
return randomString;
}
</code></pre>
<p>If i call this function to generate two strings, one after another, they are identical... but if i debug through the two lines where the strings are generated - the results are different.
does anyone know why is it happening?</p>
| [
{
"answer_id": 376387,
"author": "Jamie Penney",
"author_id": 68230,
"author_profile": "https://Stackoverflow.com/users/68230",
"pm_score": 3,
"selected": false,
"text": "public string GenerateRandomString(int length)\n{\n StringBuilder randomString = new StringBuilder(length);\n\n ... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376344",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40872/"
] |
376,346 | <p>Hi I'm doing the Collatz sequence problem in project Euler (problem 14). My code works with numbers below 100000 but with numbers bigger I get stack over-flow error. </p>
<p>Is there a way I can re-factor the code to use tail recursion, or prevent the stack overflow. The code is below:</p>
<pre><code>import java.util.*;
public class v4
{
// use a HashMap to store computed number, and chain size
static HashMap<Integer, Integer> hm = new HashMap<Integer, Integer>();
public static void main(String[] args)
{
hm.put(1, 1);
final int CEILING_MAX=Integer.parseInt(args[0]);
int len=1;
int max_count=1;
int max_seed=1;
for(int i=2; i<CEILING_MAX; i++)
{
len = seqCount(i);
if(len > max_count)
{
max_count = len;
max_seed = i;
}
}
System.out.println(max_seed+"\t"+max_count);
}
// find the size of the hailstone sequence for N
public static int seqCount(int n)
{
if(hm.get(n) != null)
{
return hm.get(n);
}
if(n ==1)
{
return 1;
}
else
{
int length = 1 + seqCount(nextSeq(n));
hm.put(n, length);
return length;
}
}
// Find the next element in the sequence
public static int nextSeq(int n)
{
if(n%2 == 0)
{
return n/2;
}
else
{
return n*3+1;
}
}
}
</code></pre>
| [
{
"answer_id": 376408,
"author": "Jimmy",
"author_id": 4435,
"author_profile": "https://Stackoverflow.com/users/4435",
"pm_score": 3,
"selected": false,
"text": "public static int seqCount(int n)\n{\n if(hm.get(n) != null) {\n return hm.get(n);\n }\n if (n < 1) {\n // th... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376346",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
376,352 | <p>I have a feeling I'm being too "webforms" with this, but I'll ask anyway. I have a form in an ASP.NET MVC project that has some input fields and two buttons on it. One button is used to 'filter' one of the list boxes. The other is used to submit the form. My view looks something like this:</p>
<pre><code><%using (Html.BeginForm())
{%>
<%=Html.TextBox("SearchItems") %>
<input type="submit" name="Command" value="Find" />
<%=Html.ListBox("SelectedItems", new MultiSelectList(model.AvailableItems,"Id", "Name", model.SelectedItems))%>
//Some other form fields.
<input type="submit" name="Command" value="Send" />
<%} %>
</code></pre>
<p>My action looks something like this:</p>
<pre><code>[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Index([Bind(Prefix = "")]SendMessageRequest model)
{
if (model.Command == "Find")
return SearchItems(model);
if (model.Command == "Send")
return Send(model);
throw new Exception("Invalid command.");
}
</code></pre>
<p>This works- the controller chooses the correct action based on the button that was clicked. However, it is not ideal, because the input button's value is also the displayed text. If I wanted to translate this app, then the action would break. To get around this, I can use a <button> element, which allows the text and value to be different. However, this app is for Pocket IE, and apparently Pocket IE handles these differently - it submits <em>both</em> values for Command, which breaks the action.</p>
<p>Since this is for Pocket IE, I'm also pretty limited in terms of what I can do with JavaScript. Ajax is out, but I could possibly set a hidden field from the buttons' onClick.</p>
<p>So, my question is what's the best way to allow for a single form with multiple buttons on an MVC view? Alternatively, should I be breaking up my view into multiple forms somehow? </p>
| [
{
"answer_id": 376382,
"author": "Odd",
"author_id": 11908,
"author_profile": "https://Stackoverflow.com/users/11908",
"pm_score": 1,
"selected": false,
"text": "$(\"#myForm\").attr(\"action\", \"mvcaction\");\n$(\"#myForm\").submit();\n"
},
{
"answer_id": 1389446,
"author": ... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376352",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47225/"
] |
376,361 | <p>I'm currently using winforms databinding to wire up a data editing form. I'm using the netTiers framework through CodeSmith to generate my data objects. For database fields that allow nulls it creates nullable types. I've found that using winforms databinding the controls won't bind properly to nullable types.</p>
<p>I've seen solutions online suggesting that people create new textbox classes that can handle the nullable types but that could be a pain having to swap out the textboxes on the forms I've already created.</p>
<p>Initially I thought it would be great to use an extension method to do it. Basically creating an extension property for the textbox class and bind to that. From my limited extension method experience and doing a bit of checking online it looks like you can't do an extension property. As far as I can tell, binding has to be through a property since it needs to be able to get or set the value so an extension method wouldn't work.</p>
<p>I'd love to find a clean way to retrofit these forms using something like extension methods but if I have to create new textbox and combo box controls that's what I'll do. </p>
<p>My project is currently limited to .Net 2.0 due to the requirement to run on Windows 2000.</p>
<p>Any suggestions?</p>
| [
{
"answer_id": 3524691,
"author": "shindigo",
"author_id": 283936,
"author_profile": "https://Stackoverflow.com/users/283936",
"pm_score": 7,
"selected": true,
"text": "textBox1.DataBindings.Add(\"Text\", myClass, \"MyTextProperty\");\n textBox1.DataBindings.Add(\"Text\", myClass, \"MyTe... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376361",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10221/"
] |
376,369 | <p>Can I with ASP.NET Resources/Localization translate strings to depend on one or other (the English grammar) in a easy way, like I pass number 1 in my translate, it return "You have one car" or with 0, 2 and higher, "You have %n cars"?</p>
<p>Or I'm forced to have logic in my view to see if it's singular or plural?</p>
| [
{
"answer_id": 376926,
"author": "coder_bro",
"author_id": 46279,
"author_profile": "https://Stackoverflow.com/users/46279",
"pm_score": 0,
"selected": false,
"text": "class MyResource\n {\n\n private List<string> literals = new List<string>();\n public MyResource() { literals.Add(... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
376,372 | <p>In my application I have a <code>UITextField</code> inside a <code>UITableViewCell</code>. If I click inside the text field and add some text I find that if try to move the insertion point it works the first time but fails on subsequent attempts. I am completely unable to move the selection; no "magnifying glass" appears.</p>
<p>Even more curious, this "setting" seems to be permanent until I restart the application. And it affects all <code>UITextFields</code> on that screen and not just the one that I originally tried to edit.</p>
<p>If you want to see it yourself, try the "UICatalog" sample that comes with the iPhone SDK. Click "text fields" and then "edit" and play around with the text boxes.</p>
<p>I've done a lot of digging on this but it's pretty hard to Google for! The best references I've found are on <a href="http://discussions.apple.com/thread.jspa?messageID=8280094" rel="noreferrer">Apple's support board</a> and <a href="http://forums.macrumors.com/showthread.php?t=521818" rel="noreferrer">MacRumors formum</a> (both reference a solution that apparently used to work on iPhone 2.0 but does work not with contemporary versions -- I did try).</p>
<p>My feeling that is that this is a bug in the OS, but I thought I'd throw this out to the SO crowd for a second opinion and to see if there are any workarounds. Any ideas?</p>
<p>Following benzado's suggestion, I tried building my application using the 2.0, 2.1 and 2.2 SDKs. I got the same behaviour in all versions. (Actually, something related but not the same broke in 2.2 but that's probably another question!)</p>
| [
{
"answer_id": 386227,
"author": "Stephen Darlington",
"author_id": 2998,
"author_profile": "https://Stackoverflow.com/users/2998",
"pm_score": 5,
"selected": true,
"text": "editing YES"
},
{
"answer_id": 698132,
"author": "Brian Criscuolo",
"author_id": 84727,
"autho... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376372",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2998/"
] |
376,373 | <p>I have a string that represents a non indented XML that I would like to pretty-print. For example:</p>
<pre><code><root><node/></root>
</code></pre>
<p>should become:</p>
<pre><code><root>
<node/>
</root>
</code></pre>
<p>Syntax highlighting is not a requirement. To tackle the problem I first transform the XML to add carriage returns and white spaces and then use a <a href="http://www.w3.org/TR/html401/struct/text.html#h-9.3.4" rel="noreferrer"><em>pre</em></a> tag to output the XML. To add new lines and white spaces I wrote the following function: </p>
<pre><code>function formatXml(xml) {
var formatted = '';
var reg = /(>)(<)(\/*)/g;
xml = xml.replace(reg, '$1\r\n$2$3');
var pad = 0;
jQuery.each(xml.split('\r\n'), function(index, node) {
var indent = 0;
if (node.match( /.+<\/\w[^>]*>$/ )) {
indent = 0;
} else if (node.match( /^<\/\w/ )) {
if (pad != 0) {
pad -= 1;
}
} else if (node.match( /^<\w[^>]*[^\/]>.*$/ )) {
indent = 1;
} else {
indent = 0;
}
var padding = '';
for (var i = 0; i < pad; i++) {
padding += ' ';
}
formatted += padding + node + '\r\n';
pad += indent;
});
return formatted;
}
</code></pre>
<p>I then call the function like this:</p>
<pre><code>jQuery('pre.formatted-xml').text(formatXml('<root><node1/></root>'));
</code></pre>
<p>This works perfectly fine for me but while I was writing the previous function I thought that there must be a better way. So my question is do you know of any better way given an XML string to pretty-print it in an html page? Any javascript frameworks and/or plugins that could do the job are welcome. My only requirement is this to be done on the client side.</p>
| [
{
"answer_id": 376503,
"author": "Dimitre Novatchev",
"author_id": 36305,
"author_profile": "https://Stackoverflow.com/users/36305",
"pm_score": 7,
"selected": true,
"text": "<xsl:output indent=\"yes\"/>"
},
{
"answer_id": 1200866,
"author": "Touv",
"author_id": 147186,
... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376373",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29407/"
] |
376,375 | <p>I am working on someone else's PHP code and seeing this pattern over and over:</p>
<p>(pseudocode)</p>
<pre><code>result = SELECT blah1, blah2, foreign_key FROM foo WHERE key=bar
if foreign_key > 0
other_result = SELECT something FROM foo2 WHERE key=foreign_key
end
</code></pre>
<p>The code needs to branch if there is no related row in the other table, but couldn't this be done better by doing a LEFT JOIN in a single SELECT statement? Am I missing some performance benefit? Portability issue? Or am I just nitpicking?</p>
| [
{
"answer_id": 376400,
"author": "BenAlabaster",
"author_id": 40650,
"author_profile": "https://Stackoverflow.com/users/40650",
"pm_score": 2,
"selected": false,
"text": "Select a.blah1, a.blah2, b.something From foo a Left Join foo2 b On a.foreign_key = b.key Where a.Key = bar;\n"
},
... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376375",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17410/"
] |
376,376 | <p>I found this question: How to find out which CVS tags cover which files and paths?</p>
<p>However, the results are not at all what I'm expecting.
I'm using the following:</p>
<pre><code>cvs -n -q update -r ET30908
</code></pre>
<p>I'm looking for every file tagged with 'ET30908'.</p>
| [
{
"answer_id": 380351,
"author": "Oliver Giesen",
"author_id": 9784,
"author_profile": "https://Stackoverflow.com/users/9784",
"pm_score": 0,
"selected": false,
"text": "cvs -q rlog -SR -rET30908 .\n -S"
},
{
"answer_id": 474285,
"author": "Sally",
"author_id": 6539,
... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376376",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
376,384 | <p>I am not able to use the breakpoint in Studio with Javascript. I'm able to debug if I use the debugger; </p>
<p>I've seen this <a href="https://stackoverflow.com/questions/163133/breakpoint-not-hooked-up-when-debugging-in-vsnet-2005">Breakpoint not hooked up when debugging in VS.Net 2005</a> question already. I tried the answer and it didn't work.</p>
<p>Looking in the Modules window, V.Mvc.Jobtrakt.PDB is loaded properly, but it points to a temp folder
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\dbc0c0c5\f64a99b3\assembly\dl3\9de055b3\eb1303b1_9760c901\V.Mvc.Jobtrak.pdb: Symbols loaded.</p>
<p>I would have thought that it would point to:
\JobTrak\Website\V.Mvc.Jobtrak\V.Mvc.Jobtrak\obj\Debug ( this is within the project directory)</p>
<p>But regardless of the location I closed VS 2008 and then blew away the temp folder (listed above), the bin and obj folders. </p>
<p>Opened VS 2008 and did a clean. I set a break point in the js and it seemed like it would work now ( The breakpoint was filled in)
Started to debug and it never breaks on the breakpoint. Look at the break point and it now is a red circle with a red dot and a warning indicator. Hovering over the breakpoint gives me this useful information: The breakpoint will not currently be hit. The location could not be mapped to a client side script. See help for ASPX Breakpoint mapping. I am not being redirected, the breakpoint is with in a function. blah blah blah this should be working.</p>
<p>So I was wondering if anyone has any ideas?
Is anyone able to set breakpoints in VS2008 and have them work?</p>
| [
{
"answer_id": 4770470,
"author": "Andre Juliano",
"author_id": 585917,
"author_profile": "https://Stackoverflow.com/users/585917",
"pm_score": 1,
"selected": false,
"text": "<%=..%> .ASPX <%=..> .ASPX"
},
{
"answer_id": 31289538,
"author": "Praneeth",
"author_id": 509330... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376384",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7617/"
] |
376,403 | <p>In the application I'm writing using a combination of development environments and languages, I have need of accessing a cookie from two different subdomains, each on a separate host.</p>
<p>The cookie is being set on <code>www.mydomain.com</code> using the PHP code that follows, and I'm attempting to access it from <code>distant.mydomain.com</code> on a separate host.</p>
<pre><code>setcookie('token', base64_encode(serialize($token)), time()+10800, '/', '.mydomain.com');
</code></pre>
<p>I'm trying to access the cookie from <code>distant.mydomain.com</code> using the following code: </p>
<pre><code>if (isset($_COOKIE['token'])) { /* do stuff */ }
</code></pre>
<p><strong>The problem: <code>distant.mydomain.com</code> is not finding the cookie.</strong> The <code>if</code> statement just mentioned returns false, even though the cookie exists.</p>
<p>I have verified that the cookie that is set is for <code>mydomain.com</code> (by checking my Firefox cookies). I can't think of any reason this wouldn't be working. </p>
<p>Using the same <code>setcookie</code> code, I have an old application running exclusively on the <code>www.mydomain.com</code> host, and that application is able to access the cookie across domains. This makes me suspect that the problem has to do with separate hosts.</p>
<p>Just in case any of the following information is pertinent:<br>
- <code>www.mydomain.com</code> is IIS 6.0<br>
- <code>distant.mydomain.com</code> is Apache 2.2.9<br>
- Both servers use PHP 5.2.x<br>
- Both servers are operating on Windows Server 2003 </p>
<p>If there is any further information I can provide in order to better describe the problem, please let me know!</p>
| [
{
"answer_id": 376757,
"author": "nmjk",
"author_id": 35579,
"author_profile": "https://Stackoverflow.com/users/35579",
"pm_score": 5,
"selected": true,
"text": "$_COOKIE $_SERVER $_GET $_GET"
},
{
"answer_id": 5294382,
"author": "FYA",
"author_id": 614098,
"author_pr... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376403",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35579/"
] |
376,404 | <p>Can I load an stand alone aspx page in another stand alone aspx page using System.Reflection? </p>
<p>I am using the ASP.NET 2.0 Web site project model.</p>
| [
{
"answer_id": 376599,
"author": "Mauricio Scheffer",
"author_id": 21239,
"author_profile": "https://Stackoverflow.com/users/21239",
"pm_score": 4,
"selected": true,
"text": "Page p = BuildManager.CreateInstanceFromVirtualPath(\"~/Default.aspx\", typeof(Page))\n"
},
{
"answer_id"... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376404",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26327/"
] |
376,437 | <p>How can I determine if I'm in the final loop of a For Each statement in VB.NET?</p>
| [
{
"answer_id": 376453,
"author": "Strelok",
"author_id": 2788,
"author_profile": "https://Stackoverflow.com/users/2788",
"pm_score": 4,
"selected": false,
"text": "yourCollection.Count - 1"
},
{
"answer_id": 376462,
"author": "Lasse V. Karlsen",
"author_id": 267,
"aut... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376437",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47167/"
] |
376,452 | <p>Is there a way to enforce explicit cast for typedefs of the same type? I've to deal with utf8 and sometimes I get confused with the indices for the character count and the byte count. So it be nice to have some typedefs:</p>
<pre><code>typedef unsigned int char_idx_t;
typedef unsigned int byte_idx_t;
</code></pre>
<p>With the addition that you need an explicit cast between them:</p>
<pre><code>char_idx_t a = 0;
byte_idx_t b;
b = a; // compile warning
b = (byte_idx_t) a; // ok
</code></pre>
<p>I know that such a feature doesn't exist in C, but maybe you know a trick or a compiler extension (preferable gcc) that does that.</p>
<hr>
<p><strong>EDIT</strong>
I still don't really like the Hungarian notation in general. I couldn't use it for this problem because of project coding conventions, but I used it now in another similar case, where also the types are the same and the meanings are very similar. And I have to admit: it helps. I never would go and declare every integer with a starting "i", but as in Joel's example for overlapping types, it can be life saving.</p>
| [
{
"answer_id": 376470,
"author": "lillq",
"author_id": 2064,
"author_profile": "https://Stackoverflow.com/users/2064",
"pm_score": 4,
"selected": false,
"text": "typedef struct {\n unsigned int c_idx;\n} char_idx;\n\ntypedef struct {\n unsigned int b_idx;\n} byte_idx;\n char_idx a;... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376452",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18687/"
] |
376,454 | <p>I have an application (ASP.NET 3.5) that allows users to rerun a particular process if required. The process inserts records into an MS SQL table. I have the insert in a Try / Catch and ignore the catch if a record already exists (the error in the Title would be valid). This worked perfectly using ADO but after I conveted to LINQ I noticed an interesting thing. If on a re-run of the process there was already records in the table, any new records would be rejected with the same error even though there was no existing record.
The code is as follows:</p>
<pre><code> Dim ins = New tblOutstandingCompletion
With ins
.ControlID = rec.ControlID
.PersonID = rec.peopleID
.RequiredDate = rec.NextDue
.RiskNumber = 0
.recordType = "PC"
.TreatmentID = 0
End With
Try
ldb.tblOutstandingCompletions.InsertOnSubmit(ins)
ldb.SubmitChanges()
Catch ex As Exception
' An attempt to load a duplicate record will fail
End Try
</code></pre>
<p>The DataContext for database was set during Page Load .</p>
<p>I resolved the problem by redefining the DataContext before each insert:</p>
<pre><code> ldb = New CaRMSDataContext(sessionHandler.connection.ToString)
Dim ins = New tblOutstandingCompletion
</code></pre>
<p>While I have solved the problem I would like to know if anyone can explain it. Without the DataContext redefinition the application works perfectly if there are no duplicate records.</p>
<p>Regards
James</p>
| [
{
"answer_id": 376470,
"author": "lillq",
"author_id": 2064,
"author_profile": "https://Stackoverflow.com/users/2064",
"pm_score": 4,
"selected": false,
"text": "typedef struct {\n unsigned int c_idx;\n} char_idx;\n\ntypedef struct {\n unsigned int b_idx;\n} byte_idx;\n char_idx a;... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376454",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
376,461 | <p>In Python, the where and when of using string concatenation versus string substitution eludes me. As the string concatenation has seen large boosts in performance, is this (becoming more) a stylistic decision rather than a practical one?</p>
<p>For a concrete example, how should one handle construction of flexible URIs:</p>
<pre><code>DOMAIN = 'http://stackoverflow.com'
QUESTIONS = '/questions'
def so_question_uri_sub(q_num):
return "%s%s/%d" % (DOMAIN, QUESTIONS, q_num)
def so_question_uri_cat(q_num):
return DOMAIN + QUESTIONS + '/' + str(q_num)
</code></pre>
<p>Edit: There have also been suggestions about joining a list of strings and for using named substitution. These are variants on the central theme, which is, which way is the Right Way to do it at which time? Thanks for the responses!</p>
| [
{
"answer_id": 376508,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 7,
"selected": true,
"text": ">>> import timeit\n>>> def so_q_sub(n):\n... return \"%s%s/%d\" % (DOMAIN, QUESTIONS, n)\n...\n>>> so_q_sub(1000)\n'... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376461",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38140/"
] |
376,468 | <p>I'm using selenium to run some functional tests on the UI for our current application. </p>
<p>I want to ensure that strings from the resource files in the Web project are being displayed at the correct time and place.</p>
<p>Simple (I thought) all I have to do is reference the assembly of the web application and assert that the text selenium is reading from the UI matches the test in the approriate resource file.</p>
<p>The problem is the ASP.Net does some precomilation processing on the resource files and compiles them into an assembly called App_GlobalResources, which isn't created by the normal build process so the functional tests fail because that can't find the App_GlobalResources assembly to look the string up from.</p>
<p>So, any suggestions? Do I need to abandon the App_GlobalResources approach and do something manual that I have control over? </p>
<p>Do you understand the problem or do I need to provide more info?</p>
| [
{
"answer_id": 376508,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 7,
"selected": true,
"text": ">>> import timeit\n>>> def so_q_sub(n):\n... return \"%s%s/%d\" % (DOMAIN, QUESTIONS, n)\n...\n>>> so_q_sub(1000)\n'... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376468",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42975/"
] |
376,471 | <p>I have two routes:</p>
<pre><code>routes.MapRoute(
"FetchVenue",
"venue/fetchlike/{q}",
new { controller = "venue", action = "fetchlike" }
);
routes.MapRoute(
"venue",
"venue/{venueId}",
new { controller = "Venue", action = "Index" }
);
</code></pre>
<p>The url /venue/fetchlike/test is passed to the correct controller
The url /venue/fetchlike/?q=test is however passed to the index action.</p>
<p>I want to be able to pass data as a querystring.</p>
<p>What am I doing wrong?</p>
| [
{
"answer_id": 376476,
"author": "Strelok",
"author_id": 2788,
"author_profile": "https://Stackoverflow.com/users/2788",
"pm_score": 2,
"selected": false,
"text": "/venue/fetchlike?q=test /venue/fetchlike/?q=test"
},
{
"answer_id": 389757,
"author": "iasksillyquestions",
... | 2008/12/17 | [
"https://Stackoverflow.com/questions/376471",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46616/"
] |
376,502 | <p>I have a database table called "Posts" which stores all the information regarding an article submission on a website. There is a column named "Views" which is a value that gets incremented each time that particular post gets viewed. </p>
<p>The process is this:</p>
<ol>
<li>Get the record from the database </li>
<li>Increment the current by one</li>
<li>Save the changes to the database.</li>
</ol>
<p>Pretty straightforward. My concern is that if multiple people click the link at the same time, the updates wont be accurate. How should I approach this? Should this only be done ina stored procedure?</p>
<pre><code> /// <summary>
/// Updates the view count of a post.
/// </summary>
/// <param name="postId">The Id of the post to update</param>
public bool UpdateViewCount(int postId)
{
Repository repository = new Repository();
Post p = repository.Posts.Where(p => p.Id == postId).SingleOrDefault();
if (p != null)
{
p.Views++;
}
repository.SubmitChanges(System.Data.Linq.ConflictMode.ContinueOnConflict);
}
</code></pre>
| [
{
"answer_id": 376509,
"author": "Martijn Laarman",
"author_id": 47020,
"author_profile": "https://Stackoverflow.com/users/47020",
"pm_score": 4,
"selected": true,
"text": "UPDATE table SET views=views+1 WHERE myId=12;\n"
},
{
"answer_id": 376654,
"author": "Schotime",
"a... | 2008/12/18 | [
"https://Stackoverflow.com/questions/376502",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17744/"
] |
376,504 | <p>We upgraded our machines with a microsoft patch listed above and are now having issues with some winsock controls. While moving on to the new component library there were two issues that we faced: </p>
<ul>
<li>We are creating a Winsock control dynamically using Form.Controls.Add(...). With the new dlls it gave us a run time error 731 stating that we needed to add the license.</li>
</ul>
<p>This issue was resolved by adding a line License.Add(PrgID of the control) before adding the control.</p>
<p>Now the issue is when we try setting this control to an object of type mWinsock we get a runtime error Type Mismatch. Any thoughts?</p>
| [
{
"answer_id": 1369805,
"author": "Templar",
"author_id": 799,
"author_profile": "https://Stackoverflow.com/users/799",
"pm_score": 0,
"selected": false,
"text": "Option Explicit\nDim WithEvents objExt As VBControlExtender\n\nPrivate Sub LoadControl()\n Licenses.Add \"MSWinsockLib.Wins... | 2008/12/18 | [
"https://Stackoverflow.com/questions/376504",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
376,513 | <p>When I get exceptions, it is often from deep within the call stack. When this happens, more often than not, the actual offending line of code is hidden from me:</p>
<pre class="lang-none prettyprint-override"><code>tmp.rb:7:in `t': undefined method `bar' for nil:NilClass (NoMethodError)
from tmp.rb:10:in `s'
from tmp.rb:13:in `r'
from tmp.rb:16:in `q'
from tmp.rb:19:in `p'
from tmp.rb:22:in `o'
from tmp.rb:25:in `n'
from tmp.rb:28:in `m'
from tmp.rb:31:in `l'
... 8 levels...
from tmp.rb:58:in `c'
from tmp.rb:61:in `b'
from tmp.rb:64:in `a'
from tmp.rb:67
</code></pre>
<p>That "... 8 levels..." truncation is causing me a great deal of trouble. I'm not having much success googling for this one: How do I tell ruby that I want dumps to include the full stack?</p>
| [
{
"answer_id": 376521,
"author": "Gareth",
"author_id": 31582,
"author_profile": "https://Stackoverflow.com/users/31582",
"pm_score": 9,
"selected": true,
"text": "def do_division_by_zero; 5 / 0; end\nbegin\n do_division_by_zero\nrescue => exception\n puts exception.backtrace\n raise ... | 2008/12/18 | [
"https://Stackoverflow.com/questions/376513",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30997/"
] |
376,516 | <p>What I want to do is take a certain stock pattern (defined as a series of x and y coordinates) and compare it against historical stock prices. If I find anything in the historical prices similar to that pattern I defined, I would like to return it as a match.</p>
<p>I'm not sure how to determine how similar two curved lines are. I did some research, and you can find the similarity of two straight lines (with linear regression), but I haven't yet come across a good way to compare two curved lines.</p>
<p>My best approach right now is get several high and low points from the historical data range I'm looking at, find the slopes of the lines, and compare those to the slopes of the pattern I'm trying to match to see if they're roughly the same.</p>
<p>Any better ideas? I'd love to hear them!</p>
<p><strong>Edit:</strong> Thanks for the input! I considered the least squares approach before, but I wasn't sure where to go with it. After the input I received though, I think computing the least squares of each line first to smooth out the data a little bit, then scaling and stretching the pattern like James suggested should get me what I'm looking for.</p>
<p>I plan on using this to identify certain technical flags in the stock to determine buy and sell signals. There are already sites out there that do this to some degree <a href="http://www.stockfetcher.com" rel="nofollow noreferrer">(such as stockfetcher)</a>, but of course I'd like to try it myself and see if I can do any better.</p>
| [
{
"answer_id": 376540,
"author": "warren",
"author_id": 4418,
"author_profile": "https://Stackoverflow.com/users/4418",
"pm_score": 0,
"selected": false,
"text": "epsilon"
}
] | 2008/12/18 | [
"https://Stackoverflow.com/questions/376516",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43019/"
] |
376,518 | <p>Although this question looks simple, it is kind of tricky.</p>
<p>Consider the following table:</p>
<pre><code>CREATE TABLE A (
id INT,
value FLOAT,
"date" DATETIME,
group VARCHAR(50)
);
</code></pre>
<p>I would like to obtain the <code>ID</code> and <code>value</code> of the records that contain the maximum <code>date</code> grouped by the column <code>group</code>. In other words, something like <em>"what is the newest value for each group?"</em> What query will answer that question?</p>
<p>I can get each group and its maximum date:</p>
<pre><code>SELECT group, MAX(date)
FROM A
GROUP BY group; -- I also need the "ID" and "value"`
</code></pre>
<p>But I would like to have the "ID" and value of the record with the highest date.</p>
<p>Making a <code>JOIN</code> between <code>A</code> and the result could be the answer, but there is no way of knowing which record <code>MAX(date)</code> refers to (in case the <code>date</code> repeats).</p>
<p>Sample data:</p>
<pre><code>INSERT INTO A
VALUES
(1, 1.0, '2000-01-01', 'A'),
(2, 2.0, '2000-01-02', 'A'),
(3, 3.0, '2000-01-01', 'B'),
(4, 2.0, '2000-01-02', 'B'),
(5, 1.0, '2000-01-02', 'B')
;
</code></pre>
| [
{
"answer_id": 376539,
"author": "Andrew Kennan",
"author_id": 22506,
"author_profile": "https://Stackoverflow.com/users/22506",
"pm_score": 0,
"selected": false,
"text": "SELECT A.ID, A.Value\nFROM A\n INNER JOIN (SELECT Group, MAX(Date) As MaxDate FROM A GROUP BY Group) B\n ON A.Gr... | 2008/12/18 | [
"https://Stackoverflow.com/questions/376518",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10833/"
] |
376,519 | <p>Opinions: I want to disallow direct invocation of certain scripts, that have functionality accessible from a menu, via Web at the OS level (Linux). </p>
<p>I was hoping to call a authorize.pl script that checks the session validity, checks user privileges etc. Then it will redirect to the target script. </p>
<p>Does this get around permissions? Could I restrict execute on the target scripts from public, but set target scripts accessible to group to which <code>authorize.pl</code> belongs? Does this reflect any current practice?</p>
| [
{
"answer_id": 376539,
"author": "Andrew Kennan",
"author_id": 22506,
"author_profile": "https://Stackoverflow.com/users/22506",
"pm_score": 0,
"selected": false,
"text": "SELECT A.ID, A.Value\nFROM A\n INNER JOIN (SELECT Group, MAX(Date) As MaxDate FROM A GROUP BY Group) B\n ON A.Gr... | 2008/12/18 | [
"https://Stackoverflow.com/questions/376519",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
376,524 | <p>I am trying to send some data from a LINQ query in C# to an Excel speed sheet using OLE</p>
<p>I have a query like this:</p>
<pre><code>Var data = from d in db.{MyTable}
where d.Name = "Test"
select d;
</code></pre>
<p>I have the Excel OLE object working fine, I just can't figure out how to populate the cells in Excel with the data from the LINQ query.</p>
<p>PS: I am using Excel 2003 if that makes any difference.</p>
<p>Can anyone help me with this?</p>
| [
{
"answer_id": 376754,
"author": "Damien",
"author_id": 29823,
"author_profile": "https://Stackoverflow.com/users/29823",
"pm_score": 3,
"selected": true,
"text": "int noOfRows = data.Count - 1;\nint noOfColumns = mydataclass.GetType().GetProperties().Count() - 1;\nObject[noOfRows, noOfC... | 2008/12/18 | [
"https://Stackoverflow.com/questions/376524",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6335/"
] |
376,544 | <p>How do I increase the maxPoolSize in Grails when using mysql? It appears to be using a default connection pool only 8 connections. </p>
| [
{
"answer_id": 377493,
"author": "Siegfried Puchbauer",
"author_id": 46301,
"author_profile": "https://Stackoverflow.com/users/46301",
"pm_score": 4,
"selected": true,
"text": "beans = {\n\n dataSource(org.apache.commons.dbcp.BasicDataSource) {\n driverClassName = \"com.mysql.jdbc... | 2008/12/18 | [
"https://Stackoverflow.com/questions/376544",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6580/"
] |
376,551 | <p>I'm trying to checkout a repository via command line (the 'svn co' command), using the svn+ssh protocol. I need to checkout as a different user than what I currently am. The command <code>svn co svn+ssh://username@server/repo/</code> would make sense, however when it prompts for a password, it never accepts it.</p>
<p>How do I checkout a repository over svn+ssh with a different user?</p>
<p>Edit to clarify a concern that this is off topic:
I'm trying to create a script to update a website to the current version. This is where the script fails.</p>
| [
{
"answer_id": 52334806,
"author": "Wei",
"author_id": 2501385,
"author_profile": "https://Stackoverflow.com/users/2501385",
"pm_score": 0,
"selected": false,
"text": "svn checkout svn+ssh://your.remote-server.com/home/svn/test\n"
}
] | 2008/12/18 | [
"https://Stackoverflow.com/questions/376551",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12930/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.