qid int64 4 19.1M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
17,532 | <h2>Summary</h2>
<p>Hi All,<br />
OK, further into my adventures with custom controls...</p>
<p>In summary, here is that I have learned of three main "classes" of custom controls. Please feel free to correct me if any of this is wrong!</p>
<ol>
<li><strong>UserControls</strong> - Which inherit from <em>UserControl</em> and are contained within an <em>ASCX</em> file. These are pretty limited in what they can do, but are a quick and light way to get some UI commonality with designer support.</li>
<li><strong>Custom Composite Controls</strong> - These are controls that inherit from <em>WebControl</em> where you add pre-existing controls to the control within the <em>CreateChildControls</em> method. This provides great flexibility, but lack of designer support without additional coding. They are highly portable though since they can be compiled into a DLL.</li>
<li><strong>Custom Rendered Controls</strong> - Similar to Custom Composite Controls, these are added to a Web Control Library project. The rendering of the control is completely controlled by the programmer by overriding the <em>Render</em> method.</li>
</ol>
<h2>My Thoughts..</h2>
<p>OK, so while playing with custom composites, I found the following:</p>
<ul>
<li>You have little/no control over the HTML output making it difficult to "debug".</li>
<li>The <em>CreateChildControls</em> (and subsequent methods) can get real busy with <em>Controls.Add(myControl)</em> everywhere.</li>
<li>I found rendering tables (be it for layout or content) to be considerably awkward.</li>
</ul>
<h2>The Question(s)..</h2>
<p>So, I admit, I am new to this so I could be way off-base with some of my points noted above..</p>
<ul>
<li>Do you use Composites?</li>
<li>Do you have any neat tricks to control the HTML output?</li>
<li>Do you just say "to hell with it" and go ahead and create a custom rendered control?</li>
</ul>
<p><strong>Its something I am keen to get really firm in my mind since I know how much <em>good</em> control development can cut overall development time.</strong></p>
<p>I look forward to your answers ^_^</p>
| [
{
"answer_id": 17546,
"author": "Mark Cidade",
"author_id": 1659,
"author_profile": "https://Stackoverflow.com/users/1659",
"pm_score": 1,
"selected": false,
"text": "//Controls.Add(c1, c2, c3)\nstatic void Add(this ControlCollection coll, params Control[] controls)\n { foreach(Control c... | 2008/08/20 | [
"https://Stackoverflow.com/questions/17532",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/832/"
] |
17,533 | <p>For my C# app, I don't want to always prompt for elevation on application start, but if they choose an output path that is UAC protected then I need to request elevation.</p>
<p>So, how do I check if a path is UAC protected and then how do I request elevation mid-execution?</p>
| [
{
"answer_id": 90442,
"author": "Adrian Clark",
"author_id": 148,
"author_profile": "https://Stackoverflow.com/users/148",
"pm_score": 6,
"selected": true,
"text": "UnauthorizedAccessException"
}
] | 2008/08/20 | [
"https://Stackoverflow.com/questions/17533",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1147/"
] |
17,576 | <p>In C#, when you implement an interface, all members are implicitly public. Wouldn't it be better if we could specify the accessibility modifier (<code>protected</code>, <code>internal</code>, except <code>private</code> of course), or should we just use an abstract class instead?</p>
| [
{
"answer_id": 17598,
"author": "samjudson",
"author_id": 1908,
"author_profile": "https://Stackoverflow.com/users/1908",
"pm_score": 4,
"selected": false,
"text": "public interface IInterface {\n public void Method();\n}\n\npublic class A : IInterface {\n public void IInterface.Me... | 2008/08/20 | [
"https://Stackoverflow.com/questions/17576",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/718/"
] |
17,586 | <p>Word wrap is one of the must-have features in a modern text editor.</p>
<p>How word wrap be handled? What is the best algorithm for word-wrap?</p>
<p>If text is several million lines, how can I make word-wrap very fast?</p>
<p>Why do I need the solution? Because my projects must draw text with various zoom level and simultaneously beautiful appearance.</p>
<p>The running environment is Windows Mobile devices. The maximum 600 MHz speed with very small memory size.</p>
<p>How should I handle line information? Let's assume original data has three lines.</p>
<pre><code>THIS IS LINE 1.
THIS IS LINE 2.
THIS IS LINE 3.
</code></pre>
<p>Afterwards, the break text will be shown like this:</p>
<pre><code>THIS IS
LINE 1.
THIS IS
LINE 2.
THIS IS
LINE 3.
</code></pre>
<p>Should I allocate three lines more? Or any other suggestions?
</p>
| [
{
"answer_id": 17635,
"author": "ICR",
"author_id": 214,
"author_profile": "https://Stackoverflow.com/users/214",
"pm_score": 5,
"selected": false,
"text": "IndexOfAny static char[] splitChars = new char[] { ' ', '-', '\\t' };\n\nprivate static string WordWrap(string str, int width)\n{\n... | 2008/08/20 | [
"https://Stackoverflow.com/questions/17586",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1556/"
] |
17,612 | <p>Programmatic solution of course...</p>
| [
{
"answer_id": 17618,
"author": "Ishmaeel",
"author_id": 227,
"author_profile": "https://Stackoverflow.com/users/227",
"pm_score": 4,
"selected": false,
"text": "public static class Recycle\n{\n private const int FO_DELETE = 3;\n private const int FOF_ALLOWUNDO = 0x40;\n private... | 2008/08/20 | [
"https://Stackoverflow.com/questions/17612",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/580/"
] |
17,624 | <p>I have a table with a 'filename' column.
I recently performed an insert into this column but in my haste forgot to append the file extension to all the filenames entered. Fortunately they are all '.jpg' images.</p>
<p>How can I easily update the 'filename' column of these inserted fields (assuming I can select the recent rows based on known id values) to include the '.jpg' extension?</p>
| [
{
"answer_id": 17627,
"author": "Matt Mitchell",
"author_id": 364,
"author_profile": "https://Stackoverflow.com/users/364",
"pm_score": 6,
"selected": true,
"text": "UPDATE tablename SET [filename] = RTRIM([filename]) + '.jpg' WHERE id > 50\n"
},
{
"answer_id": 17629,
"author... | 2008/08/20 | [
"https://Stackoverflow.com/questions/17624",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/364/"
] |
17,664 | <p>I have an ASP.net Application that runs on the internal network (well, actually it's running on Sharepoint 2007). </p>
<p>I just wonder:</p>
<p>Can I somehow retrieve the name of the PC the Client is using? I would have access to Active Directory if that helps. The thing is, people use multiple PCs. So, I cannot use any manual/static mapping.</p>
<p>If possible, I do not want to use any client-side (read: JavaScript) code, but if it cannot be done server-side, JavaScript would be OK as well. ActiveX is absolutely out of question.</p>
| [
{
"answer_id": 17698,
"author": "Michael Stum",
"author_id": 91,
"author_profile": "https://Stackoverflow.com/users/91",
"pm_score": 3,
"selected": true,
"text": "System.Net.Dns.GetHostEntry(Page.Request.UserHostAddress).HostName\n"
}
] | 2008/08/20 | [
"https://Stackoverflow.com/questions/17664",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/91/"
] |
17,681 | <p>I have a <a href="http://www.visualsvn.com/server/" rel="nofollow noreferrer">VisualSVN Server</a> installed on a Windows server, serving several repositories.</p>
<p>Since the web-viewer built into VisualSVN server is a minimalistic subversion browser, I'd like to install <a href="http://websvn.tigris.org/" rel="nofollow noreferrer">WebSVN</a> on top of my repositories.</p>
<p>The problem, however, is that I can't seem to get authentication to work. Ideally I'd like my current repository authentication as specified in VisualSVN to work with WebSVN, so that though I see all the repository names in WebSVN, I can't actually browse into them without the right credentials.</p>
<p>By visiting the cached copy of the topmost link on <a href="http://www.google.com/search?q=WebSVN+authentication+with+IIS+and+VisualSVN" rel="nofollow noreferrer">this google query</a> you can see what I've found so far that looks promising.<br>
(the main blog page seems to have been destroyed, domain of the topmost page I'm referring to is the-wizzard.de)</p>
<p>There I found some php functions I could tack onto one of the php files in WebSVN. I followed the modifications there, but all I succeeded in doing was make WebSVN ask me for a username and password and no matter what I input, it won't let me in.</p>
<p>Unfortunately, php and apache is largely black magic to me.</p>
<p>So, has anyone successfully integrated WebSVN with VisualSVN hosted repositories?</p>
| [
{
"answer_id": 233587,
"author": "Kit Roed",
"author_id": 1339,
"author_profile": "https://Stackoverflow.com/users/1339",
"pm_score": 2,
"selected": false,
"text": "[components]\ntrac.ticket.* = disabled\ntrac.wiki.* = disabled\n [trac] default_handler = TimelineModule\n default_handler ... | 2008/08/20 | [
"https://Stackoverflow.com/questions/17681",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/267/"
] |
17,721 | <p>Have any of you tried Hadoop? Can it be used without the distributed filesystem that goes with it, in a Share-nothing architecture? Would that make sense?</p>
<p>I'm also interested into any performance results you have...</p>
| [
{
"answer_id": 30162186,
"author": "sras",
"author_id": 4324632,
"author_profile": "https://Stackoverflow.com/users/4324632",
"pm_score": 0,
"selected": false,
"text": " <property>\n <name>fs.defaultFS</name>\n <value>file:///</value>\n </property>\n <property>\n <name>fs.defa... | 2008/08/20 | [
"https://Stackoverflow.com/questions/17721",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/446497/"
] |
17,725 | <p>Hello again ladies and gents!</p>
<p>OK, following on from my other question on <a href="https://stackoverflow.com/questions/6681/aspnet-web-service-results-proxy-classes-and-type-conversion">ASP.NET Web Service Results, Proxy Classes and Type Conversion</a>. I've come to a part in my project where I need to get my thinking cap on.</p>
<p>Basically, we have a large, complex custom object that needs to be returned from a Web Service and consumed in the client application.</p>
<p>Now, based on the previous discussion, we know this is going to then take the form of the proxy class(es) as the return type. To overcome this, we need to basically copy the properties from one to the other.</p>
<p>In this case, that is something that I would really, really, <em>really!</em> like to avoid!</p>
<p>So, it got me thinking, <strong>how else could we do this?</strong></p>
<p>My current thoughts are to enable the object for complete serialization to XML and then return the XML as a string from the Web Service. We then de-serialize at the client. This will mean a fair bit of attribute decorating, but at least the code at both endpoints will be light, namely by just using the .NET XML Serializer.</p>
<h2>What are your thoughts on this?</h2>
| [
{
"answer_id": 17778,
"author": "Peter Short",
"author_id": 158302,
"author_profile": "https://Stackoverflow.com/users/158302",
"pm_score": 2,
"selected": false,
"text": "JSON jQuery jQuery ajax"
}
] | 2008/08/20 | [
"https://Stackoverflow.com/questions/17725",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/832/"
] |
17,732 | <p>There's a <a href="http://groups.google.com/group/comp.lang.c++.moderated/browse_thread/thread/8e0235d58c8635c2" rel="noreferrer" title="assertions: does it matter that they are disabled in production?">discussion</a> going on over at comp.lang.c++.moderated about whether or not assertions, which in C++ only exist in debug builds by default, should be kept in production code or not.</p>
<p>Obviously, each project is unique, so my question here is <strong>not</strong> so much <strong>whether</strong> assertions should be kept, <strong>but in which cases</strong> this is recommendable/not a good idea.</p>
<p>By assertion, I mean:</p>
<ul>
<li>A run-time check that tests a condition which, when false, reveals a bug in the software.</li>
<li>A mechanism by which the program is halted (maybe after really minimal clean-up work).</li>
</ul>
<p>I'm not necessarily talking about C or C++.</p>
<p>My own opinion is that if you're the programmer, but don't own the data (which is the case with most commercial desktop applications), you should keep them on, because a failing asssertion shows a bug, and you should not go on with a bug, with the risk of corrupting the user's data. This forces you to test strongly before you ship, and makes bugs more visible, thus easier to spot and fix.</p>
<p>What's your opinion/experience?</p>
<p>Cheers,</p>
<p>Carl</p>
<p>See related question <a href="https://stackoverflow.com/questions/419406/are-assertions-good">here</a></p>
<hr>
<p><strong>Responses and Updates</strong></p>
<p>Hey Graham,</p>
<blockquote>
<p>An assertion is error, pure and simple and therefore should be handled like one.
Since an error should be handled in release mode then you don't really need assertions.</p>
</blockquote>
<p>That's why I prefer the word "bug" when talking about assertions. It makes things much clearer. To me, the word "error" is too vague. A missing file is an error, not a bug, and the program should deal with it. Trying to dereference a null pointer is a bug, and the program should acknowledge that something smells like bad cheese.</p>
<p>Hence, you should test the pointer with an assertion, but the presence of the file with normal error-handling code.</p>
<hr>
<p>Slight off-topic, but an important point in the discussion.</p>
<p>As a heads-up, if your assertions break into the debugger when they fail, why not. But there are plenty of reasons a file could not exist that are completely outside of the control of your code: read/write rights, disk full, USB device unplugged, etc. Since you don't have control over it, I feel assertions are not the right way to deal with that.</p>
<p>Carl</p>
<hr>
<p>Thomas,</p>
<p>Yes, I have Code Complete, and must say I strongly disagree with that particular advice.</p>
<p>Say your custom memory allocator screws up, and zeroes a chunk of memory that is still used by some other object. I happens to zero a pointer that this object dereferences regularly, and one of the invariants is that this pointer is never null, and you have a couple of assertions to make sure it stays that way. What do you do if the pointer suddenly is null. You just if() around it, hoping that it works?</p>
<p>Remember, we're talking about product code here, so there's no breaking into the debugger and inspecting the local state. This is a real bug on the user's machine.</p>
<p>Carl</p>
| [
{
"answer_id": 17754,
"author": "roo",
"author_id": 716,
"author_profile": "https://Stackoverflow.com/users/716",
"pm_score": 0,
"selected": false,
"text": "file = create-some-file();\n_throwExceptionIf( file.exists() == false, \"FILE DOES NOT EXIST\");\n file = create-some-file();\nASSE... | 2008/08/20 | [
"https://Stackoverflow.com/questions/17732",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2095/"
] |
17,735 | <p>When I first started using revision control systems like <a href="http://en.wikipedia.org/wiki/Concurrent_Versions_System" rel="nofollow noreferrer">CVS</a> and <a href="http://en.wikipedia.org/wiki/Apache_Subversion" rel="nofollow noreferrer">SVN</a>, I didn't really understand the concepts of the "trunk", branching, merging and tagging. I'm now starting to understand these concepts, and really get the importance and power behind them.</p>
<p>So, I'm starting to do it properly. Or so I think... This is what I understand so far: The latest release/stable version of your code should sit in /trunk/ while beta versions or bleeding edge versions sit inside the /branches/ directory as different directories for each beta release, and then merged into the trunk when you release.</p>
<p>Is this too simplistic a view on things? What repository layouts do you guys recommend? If it makes a difference, I'm using Subversion.</p>
| [
{
"answer_id": 17782,
"author": "Greg Whitfield",
"author_id": 2102,
"author_profile": "https://Stackoverflow.com/users/2102",
"pm_score": 1,
"selected": false,
"text": "//MYPROJECT/MAIN/... - the top level folder for a complete build of all the product in main.\n//MYPROJECT/DEV/ArseKick... | 2008/08/20 | [
"https://Stackoverflow.com/questions/17735",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1951/"
] |
17,770 | <p>What do the clever programmers here do to keep track of handy programming tricks and useful information they pick up over their many years of experience? Things like useful compiler arguments, IDE short-cuts, clever code snippets, etc.</p>
<p>I sometimes find myself frustrated when looking up something that I used to know a year or two ago. My IE favorites probably represent a good chunk of the Internet in the late 1990s, so clearly that isn't effective (at least for me). Or am I just getting old?</p>
<p>So.. what do you do?
</p>
| [
{
"answer_id": 17792,
"author": "seanyboy",
"author_id": 1726,
"author_profile": "https://Stackoverflow.com/users/1726",
"pm_score": 0,
"selected": false,
"text": "//print spool stop.notes.txt\nIf the printer spooler stops, start it again by \n- Services > Provision Networks > Restart Se... | 2008/08/20 | [
"https://Stackoverflow.com/questions/17770",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1693/"
] |
17,772 | <p>This is probably best shown with an example. I have an enum with attributes:</p>
<pre><code>public enum MyEnum {
[CustomInfo("This is a custom attrib")]
None = 0,
[CustomInfo("This is another attrib")]
ValueA,
[CustomInfo("This has an extra flag", AllowSomething = true)]
ValueB,
}
</code></pre>
<p>I want to get to those attributes from an instance:</p>
<pre><code>public CustomInfoAttribute GetInfo( MyEnum enumInput ) {
Type typeOfEnum = enumInput.GetType(); //this will be typeof( MyEnum )
//here is the problem, GetField takes a string
// the .ToString() on enums is very slow
FieldInfo fi = typeOfEnum.GetField( enumInput.ToString() );
//get the attribute from the field
return fi.GetCustomAttributes( typeof( CustomInfoAttribute ), false ).
FirstOrDefault() //Linq method to get first or null
as CustomInfoAttribute; //use as operator to convert
}
</code></pre>
<p>As this is using reflection I expect some slowness, but it seems messy to convert the enum value to a string (which reflects the name) when I already have an instance of it.</p>
<p>Does anyone have a better way?</p>
| [
{
"answer_id": 17807,
"author": "JamesSugrue",
"author_id": 1075,
"author_profile": "https://Stackoverflow.com/users/1075",
"pm_score": 5,
"selected": true,
"text": "public delegate object FastPropertyGetHandler(object target); \n\nprivate static void EmitBoxIfNeeded(ILGenerator ilGen... | 2008/08/20 | [
"https://Stackoverflow.com/questions/17772",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/905/"
] |
17,781 | <p>I am running a number of SSL-encrypted websites, and need to generate certificates to run on these. They are all internal applications, so I don't need to purchase a certificate, I can create my own.</p>
<p>I have found it quite tedious to do everything using openssl all the time, and figure this is the kind of thing that has probably been done before and software exists for it.</p>
<p>My preference is for linux-based systems, and I would prefer a command-line system rather than a GUI.</p>
<p>Does anyone have some suggestions?</p>
| [
{
"answer_id": 31560,
"author": "paan",
"author_id": 2976,
"author_profile": "https://Stackoverflow.com/users/2976",
"pm_score": 3,
"selected": false,
"text": "CA"
}
] | 2008/08/20 | [
"https://Stackoverflow.com/questions/17781",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/277/"
] |
17,785 | <p>I know this is not programming directly, but it's regarding a development workstation I'm setting up.</p>
<p>I've got a Windows Server 2003 machine that needs to be on two LAN segments at the same time. One of them is a 10.17.x.x LAN and the other is 10.16.x.x</p>
<p>The problem is that I don't want to be using up the bandwidth on the 10.16.x.x network for internet traffic, etc (this network is basically only for internal stuff, though it does have internet access) so I would like the system to use the 10.17.x.x connection for anything that is external to the LAN (and for anything on 10.17.x.x of course, and to only use the 10.16.x.x connection for things that are on <em>that</em> specific LAN.</p>
<p>I've tried looking into the windows "route" command but it's fairly confusing and won't seem to let me delete routes tha tI believe are interfering with what I want it to do. Is there a better way of doing this? Any good software for segmenting your LAN access?</p>
| [
{
"answer_id": 17809,
"author": "kaa",
"author_id": 2105,
"author_profile": "https://Stackoverflow.com/users/2105",
"pm_score": 3,
"selected": true,
"text": "route add 0.0.0.0 MASK 0.0.0.0 <address of gateway on 10.17.x.x net>\n"
}
] | 2008/08/20 | [
"https://Stackoverflow.com/questions/17785",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/194/"
] |
17,786 | <p>When compiling my C++ .Net application I get 104 warnings of the type:</p>
<pre><code>Warning C4341 - 'XX': signed value is out of range for enum constant
</code></pre>
<p>Where XX can be</p>
<ul>
<li>WCHAR</li>
<li>LONG</li>
<li>BIT</li>
<li>BINARY</li>
<li>GUID</li>
<li>...</li>
</ul>
<p>I can't seem to remove these warnings whatever I do. When I double click on them it takes me to a part of my code that uses OdbcParameters - any when I try a test project with all the rest of my stuff but no OdbcParameters it doesn't give the warnings.</p>
<p>Any idea how I can get rid of these warnings? They're making real warnings from code I've actually written hard to see - and it just gives me a horrible feeling knowing my app has 104 warnings!</p>
| [
{
"answer_id": 17793,
"author": "Aidan Ryan",
"author_id": 1042,
"author_profile": "https://Stackoverflow.com/users/1042",
"pm_score": 3,
"selected": true,
"text": "#pragma warning( push )\n#pragma warning( disable: 4341 )\n\n// code affected by bug\n\n#pragma warning( pop )\n"
},
{
... | 2008/08/20 | [
"https://Stackoverflow.com/questions/17786",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1912/"
] |
17,795 | <p>I wanted to show the users Name Address (see <a href="http://www.ipchicken.com" rel="nofollow noreferrer">www.ipchicken.com</a>), but the only thing I can find is the IP Address. I tried a reverse lookup, but didn't work either:</p>
<pre><code>IPAddress ip = IPAddress.Parse(this.lblIp.Text);
string hostName = Dns.GetHostByAddress(ip).HostName;
this.lblHost.Text = hostName;
</code></pre>
<p>But HostName is the same as the IP address.</p>
<p>Who know's what I need to do?</p>
<p>Thanks.
Gab.</p>
| [
{
"answer_id": 17801,
"author": "seanyboy",
"author_id": 1726,
"author_profile": "https://Stackoverflow.com/users/1726",
"pm_score": 3,
"selected": true,
"text": " Dim sTmp As String\n Dim ip As IPHostEntry\n\n sTmp = MaskedTextBox1.Text\n Dim ipAddr As IPAddress = IPAddress.... | 2008/08/20 | [
"https://Stackoverflow.com/questions/17795",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2104/"
] |
17,806 | <p>I am currently developing a .NET application, which consists of 20 projects. Some of those projects are compiled using .NET 3.5, some others are still .NET 2.0 projects (so far no problem).</p>
<p>The problem is that if I include an external component I always get the following warning:</p>
<blockquote>
<p>Found conflicts between different versions of the same dependent assembly.</p>
</blockquote>
<p>What exactly does this warning mean and is there maybe a possibility to exclude this warning (like using #pragma disable in the source code files)?</p>
| [
{
"answer_id": 2137718,
"author": "Brian Low",
"author_id": 46039,
"author_profile": "https://Stackoverflow.com/users/46039",
"pm_score": 10,
"selected": true,
"text": "System.Windows.Forms System.Windows.Forms CopyLocal=true"
},
{
"answer_id": 13312274,
"author": "Gorgsenegg... | 2008/08/20 | [
"https://Stackoverflow.com/questions/17806",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2078/"
] |
17,870 | <p>Is there a way to select data where any one of multiple conditions occur on the same field?</p>
<p>Example: I would typically write a statement such as:</p>
<pre><code>select * from TABLE where field = 1 or field = 2 or field = 3
</code></pre>
<p>Is there a way to instead say something like:</p>
<pre><code>select * from TABLE where field = 1 || 2 || 3
</code></pre>
<p>Any help is appreciated.</p>
| [
{
"answer_id": 17872,
"author": "mercutio",
"author_id": 1951,
"author_profile": "https://Stackoverflow.com/users/1951",
"pm_score": 6,
"selected": true,
"text": "select foo from bar where baz in (1,2,3)\n"
},
{
"answer_id": 17873,
"author": "Michael Stum",
"author_id": 9... | 2008/08/20 | [
"https://Stackoverflow.com/questions/17870",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2116/"
] |
17,877 | <p>Just looking for the first step basic solution here that keeps the honest people out.</p>
<p>Thanks,
Mike</p>
| [
{
"answer_id": 17872,
"author": "mercutio",
"author_id": 1951,
"author_profile": "https://Stackoverflow.com/users/1951",
"pm_score": 6,
"selected": true,
"text": "select foo from bar where baz in (1,2,3)\n"
},
{
"answer_id": 17873,
"author": "Michael Stum",
"author_id": 9... | 2008/08/20 | [
"https://Stackoverflow.com/questions/17877",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/785/"
] |
17,906 | <p>I have a rather classic UI situation - two ListBoxes named <code>SelectedItems</code> and <code>AvailableItems</code> - the idea being that the items you have already selected live in <code>SelectedItems</code>, while the items that are available for adding to <code>SelectedItems</code> (i.e. every item that isn't already in there) live in <code>AvailableItems</code>.</p>
<p>Also, I have the <code><</code> and <code>></code> buttons to move the current selection from one list to the other (in addition to double clicking, which works fine).</p>
<p>Is it possible in WPF to set up a style/trigger to enable or disable the move buttons depending on anything being selected in either ListBox? <code>SelectedItems</code> is on the left side, so the <code><</code> button will move the selected <code>AvailableItems</code> to that list. However, if no items are selected (<code>AvailableItems.SelectedIndex == -1</code>), I want this button to be disabled (<code>IsEnabled == false</code>) - and the other way around for the other list/button.</p>
<p>Is this possible to do directly in XAML, or do I need to create complex logic in the codebehind to handle it?</p>
| [
{
"answer_id": 18026,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 7,
"selected": true,
"text": "<Button Name=\"btn1\" >click me \n <Button.Style> \n <Style> \n <Style.Triggers> ... | 2008/08/20 | [
"https://Stackoverflow.com/questions/17906",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2122/"
] |
17,911 | <p>I've been having some trouble parsing various types of XML within flash (specifically FeedBurner RSS files and YouTube Data API responses). I'm using a <code>URLLoader</code> to load a XML file, and upon <code>Event.COMPLETE</code> creating a new XML object. 75% of the time this work fine, and every now and again I get this type of exception:</p>
<pre><code>TypeError: Error #1085: The element type "link" must be terminated by the matching end-tag "</link>".
</code></pre>
<p>We think the problem is that The XML is large, and perhaps the <code>Event.COMPLETE</code> event is fired before the XML is actually downloaded from the <code>URLLoader</code>. The only solution we have come up with is to set off a timer upon the Event, and essentially "wait a few seconds" before beginning to parse the data. Surely this can't be the best way to do this.</p>
<p>Is there any surefire way to parse XML within Flash?</p>
<p><strong>Update Sept 2 2008</strong> We have concluded the following, the excption is fired in the code at this point:</p>
<pre><code>data = new XML(mainXMLLoader.data);
// calculate the total number of entries.
for each (var i in data.channel.item){
_totalEntries++;
}
</code></pre>
<p>I have placed a try/catch statement around this part, and am currently displaying an error message on screen when it occurs. My question is how would an incomplete file get to this point if the <code>bytesLoaded == bytesTotal</code>?</p>
<hr>
<p>I have updated the original question with a status report; I guess another question could be is there a way to determine wether or not an <code>XML</code> object is properly parsed before accessing the data (in case the error is that my loop counting the number of objects is starting before the XML is actually parsed into the object)?</p>
<hr>
<p>@Theo: Thanks for the ignoreWhitespace tip. Also, we have determined that the event is called before its ready (We did some tests tracing <code>mainXMLLoader.bytesLoaded + "/" + mainXMLLoader.bytesLoaded</code></p>
| [
{
"answer_id": 17963,
"author": "Re0sless",
"author_id": 2098,
"author_profile": "https://Stackoverflow.com/users/2098",
"pm_score": 1,
"selected": false,
"text": "URLLoader.bytesLoaded == URLLoader.bytesTotal\n"
},
{
"answer_id": 18365,
"author": "Brian Warshaw",
"author... | 2008/08/20 | [
"https://Stackoverflow.com/questions/17911",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1306/"
] |
17,928 | <p>I want to quickly test an ocx. How do I drop that ocx in a console application. I have found some tutorials in CodeProject and but are incomplete. </p>
| [
{
"answer_id": 19021,
"author": "Orion Edwards",
"author_id": 234,
"author_profile": "https://Stackoverflow.com/users/234",
"pm_score": 2,
"selected": false,
"text": "Alt+F11 Tools References Browse... Insert UserForm Toolbox Additional Controls Run"
}
] | 2008/08/20 | [
"https://Stackoverflow.com/questions/17928",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1781/"
] |
17,944 | <p>I'm thinking in particular of how to display pagination controls, when using a language such as C# or Java.</p>
<p>If I have <em>x</em> items which I want to display in chunks of <em>y</em> per page, how many pages will be needed?</p>
| [
{
"answer_id": 17954,
"author": "Nick Berardi",
"author_id": 17,
"author_profile": "https://Stackoverflow.com/users/17",
"pm_score": 6,
"selected": false,
"text": "int x = number_of_items;\nint y = items_per_page;\n\n// with out library\nint pages = x/y + (x % y > 0 ? 1 : 0)\n\n// with l... | 2008/08/20 | [
"https://Stackoverflow.com/questions/17944",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2084/"
] |
17,947 | <p>I cant post the code (proprietary issues) but does anyone know what types of things would cause the following error in C#. It is being thrown by a VOIP client that I wrote (using counterpath api) when the call is ended by the other client. The error is:</p>
<pre><code>System.AccessViolationException was unhandled
Message="Attempted to read or write protected memory. This is often an indication that other memory is corrupt."
Source="System.Windows.Forms"
StackTrace:
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at CollabAnalysisSF.Edge.GUI.Forms.Program.Main() in d:\data\beyerss\Desktop\client\GUI\ARGui\Program.cs:line 18
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: </code></pre>
<p><em>UPDATE:</em><br>
Turns out one of the libraries we were using was sending off an event that we didnt know about, and the problem was in there somewhere. Fixed now.</p>
| [
{
"answer_id": 17985,
"author": "Adam Lerman",
"author_id": 673,
"author_profile": "https://Stackoverflow.com/users/673",
"pm_score": 0,
"selected": false,
"text": "{IntPtr DispatchMessageW(MSG ByRef)}"
}
] | 2008/08/20 | [
"https://Stackoverflow.com/questions/17947",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/673/"
] |
17,960 | <p>Has anyone worked out how to get PowerShell to use <code>app.config</code> files? I have a couple of .NET DLL's I'd like to use in one of my scripts but they expect their own config sections to be present in <code>app.config</code>/<code>web.config</code>.</p>
| [
{
"answer_id": 5625350,
"author": "millerjs",
"author_id": 312103,
"author_profile": "https://Stackoverflow.com/users/312103",
"pm_score": 6,
"selected": true,
"text": "[appdomain]::CurrentDomain.SetData(\"APP_CONFIG_FILE\", $configpath)\nAdd-Type -AssemblyName System.Configuration\n"
... | 2008/08/20 | [
"https://Stackoverflow.com/questions/17960",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/419/"
] |
17,965 | <p>I have a process in Linux that's getting a segmentation fault. How can I tell it to generate a core dump when it fails?</p>
| [
{
"answer_id": 17994,
"author": "Eli Courtwright",
"author_id": 1694,
"author_profile": "https://Stackoverflow.com/users/1694",
"pm_score": 9,
"selected": true,
"text": "ulimit -c unlimited\n limit coredumpsize unlimited\n"
},
{
"answer_id": 18400,
"author": "Nathan Fellman",... | 2008/08/20 | [
"https://Stackoverflow.com/questions/17965",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1084/"
] |
17,980 | <p>I've searched for this a little but I have not gotten a particularly straight answer. In C (and I guess C++), how do you determine what comes after the % when using <code>printf</code>?. For example:</p>
<pre><code>double radius = 1.0;
double area = 0.0;
area = calculateArea( radius );
printf( "%10.1f %10.2\n", radius, area );
</code></pre>
<p>I took this example straight from a book that I have on the C language. This does not make sense to me at all. Where do you come up with <code>10.1f</code> and <code>10.2f</code>? Could someone please explain this?</p>
| [
{
"answer_id": 17987,
"author": "Eli Courtwright",
"author_id": 1694,
"author_profile": "https://Stackoverflow.com/users/1694",
"pm_score": 3,
"selected": false,
"text": "man 3 printf\n"
},
{
"answer_id": 17989,
"author": "robintw",
"author_id": 1912,
"author_profile"... | 2008/08/20 | [
"https://Stackoverflow.com/questions/17980",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2128/"
] |
17,984 | <p>Alright, this might be a bit of a long shot, but I have having problems getting AnkhSVN to connect from Visual Studio 2005 to an external SVN server. There is a network proxy in the way, but I can't seem to find a way in AnkhSVN to configure the proxy and doesn't seem to be detecting the Internet Explorer proxy configuration. Is there any way to resolve this issue, or will it likely just not work?</p>
| [
{
"answer_id": 17987,
"author": "Eli Courtwright",
"author_id": 1694,
"author_profile": "https://Stackoverflow.com/users/1694",
"pm_score": 3,
"selected": false,
"text": "man 3 printf\n"
},
{
"answer_id": 17989,
"author": "robintw",
"author_id": 1912,
"author_profile"... | 2008/08/20 | [
"https://Stackoverflow.com/questions/17984",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1185/"
] |
18,006 | <p>I've been asked to write a Windows service in C# to periodically monitor an email inbox and insert the details of any messages received into a database table.</p>
<p>My instinct is to do this via POP3 and sure enough, Googling for ".NET POP3 component" produces countless (ok, 146,000) results.</p>
<p>Has anybody done anything similar before and can you recommend a decent component that won't break the bank (a few hundred dollars maximum)?</p>
<p>Would there be any benefits to using IMAP rather than POP3?</p>
| [
{
"answer_id": 2383070,
"author": "Martin Vobr",
"author_id": 16132,
"author_profile": "https://Stackoverflow.com/users/16132",
"pm_score": 2,
"selected": false,
"text": "POP3 POP3 IMAP Imap Rebex.Net.Imap // create client, connect and log in \nImap client = new Imap();\nclient.Connect(\... | 2008/08/20 | [
"https://Stackoverflow.com/questions/18006",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2084/"
] |
18,010 | <p>I asked a couple of coworkers about <a href="http://ankhsvn.open.collab.net" rel="nofollow noreferrer">AnkhSVN</a> and neither one of them was happy with it. One of them went as far as saying that AnkhSVN has messed up his devenv several times.</p>
<p>What's your experience with AnkhSVN? I really miss having an IDE integrated source control tool.</p>
| [
{
"answer_id": 58518,
"author": "Sander Rijken",
"author_id": 5555,
"author_profile": "https://Stackoverflow.com/users/5555",
"pm_score": 0,
"selected": false,
"text": "originalFile deleted\nnewFile added (+)\n"
}
] | 2008/08/20 | [
"https://Stackoverflow.com/questions/18010",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/781/"
] |
18,034 | <p>How do I create a self signed SSL certificate for an Apache Server to use while testing a web app?</p>
| [
{
"answer_id": 18062,
"author": "Christian Hagelid",
"author_id": 202,
"author_profile": "https://Stackoverflow.com/users/202",
"pm_score": 6,
"selected": true,
"text": "openssl req -new -x509 -nodes -out server.crt -keyout server.key\n SSLCertificateFile /path/to/this/server.crt\nSSL... | 2008/08/20 | [
"https://Stackoverflow.com/questions/18034",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1310/"
] |
18,059 | <p>I'm using the <code>System.Windows.Forms.WebBrowser</code>, to make a view a-la Visual Studio Start Page. However, it seems the control is catching and handling all exceptions by silently sinking them! No need to tell this is a very unfortunate behaviour.</p>
<pre><code>void webBrowserNavigating(object sender, WebBrowserNavigatingEventArgs e)
{
// WebBrowser.Navigating event handler
throw new Exception("OMG!");
}
</code></pre>
<p>The code above will cancel navigation and swallow the exception.</p>
<pre><code>void webBrowserNavigating(object sender, WebBrowserNavigatingEventArgs e)
{
// WebBrowser.Navigating event handler
try
{
e.Cancel = true;
if (actions.ContainsKey(e.Url.ToString()))
{
actions[e.Url.ToString()].Invoke(e.Url, webBrowser.Document);
}
}
catch (Exception exception)
{
MessageBox.Show(exception.ToString());
}
}
</code></pre>
<p>So, what I do (above) is catch all exceptions and pop a box, this is better than silently failing but still clearly far from ideal. I'd like it to redirect the exception through the normal application failure path so that it ultimately becomes unhandled, or handled by the application from the root.</p>
<p>Is there any way to tell the <code>WebBrowser</code> control to stop sinking the exceptions and just forward them the natural and expected way? Or is there some hacky way to throw an exception through native boundaries?</p>
| [
{
"answer_id": 18138,
"author": "Judah Gabriel Himango",
"author_id": 536,
"author_profile": "https://Stackoverflow.com/users/536",
"pm_score": 1,
"selected": false,
"text": "browser.ScriptErrorsSuppressed"
},
{
"answer_id": 63057905,
"author": "eanv",
"author_id": 139836... | 2008/08/20 | [
"https://Stackoverflow.com/questions/18059",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42/"
] |
18,077 | <p>I wanted some of those spiffy rounded corners for a web project that I'm currently working on.</p>
<p>I thought I'd try to accomplish it using javascript and not CSS in an effort to keep the requests for image files to a minimum (yes, I know that it's possible to combine all required rounded corner shapes into one image) and I also wanted to be able to change the background color pretty much on the fly.</p>
<p>I already utilize jQuery so I looked at the excellent <a href="http://plugins.jquery.com/project/corners" rel="nofollow noreferrer">rounded corners plugin</a> and it worked like a charm in every browser I tried. Being a developer however I noticed the opportunity to make it a bit more efficient. The script already includes code for detecting if the current browser supports webkit rounded corners (safari based browsers). If so it uses raw CSS instead of creating layers of divs.</p>
<p>I thought that it would be awesome if the same kind of check could be performed to see if the browser supports the Gecko-specific <code>-moz-border-radius-*</code> properties and if so utilize them.</p>
<p>The check for webkit support looks like this:</p>
<pre><code>var webkitAvailable = false;
try {
webkitAvailable = (document.defaultView.getComputedStyle(this[0], null)['-webkit-border-radius'] != undefined);
}
catch(err) {}
</code></pre>
<p>That, however, did not work for <code>-moz-border-radius</code> so I started checking for alternatives.</p>
<p>My fallback solution is of course to use browser detection but that's far from recommended practice ofcourse.</p>
<p>My best solution yet is as follows.</p>
<pre><code>var mozborderAvailable = false;
try {
var o = jQuery('<div>').css('-moz-border-radius', '1px');
mozborderAvailable = $(o).css('-moz-border-radius-topleft') == '1px';
o = null;
} catch(err) {}
</code></pre>
<p>It's based on the theory that Gecko "expands" the composite -moz-border-radius to the four sub-properties</p>
<ul>
<li><code>-moz-border-radius-topleft</code></li>
<li><code>-moz-border-radius-topright</code></li>
<li><code>-moz-border-radius-bottomleft</code></li>
<li><code>-moz-border-radius-bottomright</code></li>
</ul>
<p>Is there any javascript/CSS guru out there that have a better solution?</p>
<p>(The feature request for this page is at <a href="http://plugins.jquery.com/node/3619" rel="nofollow noreferrer">http://plugins.jquery.com/node/3619</a>)</p>
| [
{
"answer_id": 19080,
"author": "M. Dave Auayan",
"author_id": 2007,
"author_profile": "https://Stackoverflow.com/users/2007",
"pm_score": 2,
"selected": false,
"text": "-moz-border-radius -webkit-border-radius"
},
{
"answer_id": 19203,
"author": "Nickolay",
"author_id": ... | 2008/08/20 | [
"https://Stackoverflow.com/questions/18077",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2114/"
] |
18,082 | <p>What's the cleanest, most effective way to validate decimal numbers in JavaScript?</p>
<p>Bonus points for:</p>
<ol>
<li>Clarity. Solution should be clean and simple.</li>
<li>Cross-platform.</li>
</ol>
<p>Test cases:</p>
<pre><code>01. IsNumeric('-1') => true
02. IsNumeric('-1.5') => true
03. IsNumeric('0') => true
04. IsNumeric('0.42') => true
05. IsNumeric('.42') => true
06. IsNumeric('99,999') => false
07. IsNumeric('0x89f') => false
08. IsNumeric('#abcdef') => false
09. IsNumeric('1.2.3') => false
10. IsNumeric('') => false
11. IsNumeric('blah') => false
</code></pre>
| [
{
"answer_id": 18085,
"author": "Michael Haren",
"author_id": 29,
"author_profile": "https://Stackoverflow.com/users/29",
"pm_score": 6,
"selected": false,
"text": "function IsNumeric(input){\n var RE = /^-{0,1}\\d*\\.{0,1}\\d+$/;\n return (RE.test(input));\n}\n const IsNumeric = (... | 2008/08/20 | [
"https://Stackoverflow.com/questions/18082",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29/"
] |
18,097 | <p>In C#, if I have an inherited class with a default constructor, do I have to explicitly call the base class' constructor or will it be implicitly called?</p>
<pre><code>class BaseClass
{
public BaseClass()
{
// ... some code
}
}
class MyClass : BaseClass
{
public MyClass() // Do I need to put ": base()" here or is it implied?
{
// ... some code
}
}
</code></pre>
| [
{
"answer_id": 18109,
"author": "Ian Nelson",
"author_id": 2084,
"author_profile": "https://Stackoverflow.com/users/2084",
"pm_score": 7,
"selected": true,
"text": "using System;\n\nnamespace ConsoleApplication1\n{\n class Program\n {\n static void Main(string[] args)\n ... | 2008/08/20 | [
"https://Stackoverflow.com/questions/18097",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1463/"
] |
18,119 | <p>In a world where manual memory allocation and pointers still rule (Borland Delphi) I need a general solution for what I think is a general problem:</p>
<p>At a given moment an object can be referenced from multiple places (lists, other objects, ...). Is there a good way to keep track of all these references so that I can update them when the object is destroyed?
</p>
| [
{
"answer_id": 18165,
"author": "Herms",
"author_id": 1409,
"author_profile": "https://Stackoverflow.com/users/1409",
"pm_score": 0,
"selected": false,
"text": "// Anything that will use one of your tracked objects implements this interface\ninterface ITrackedObjectUser {\n public void ... | 2008/08/20 | [
"https://Stackoverflow.com/questions/18119",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
18,166 | <p>I am attempting to POST against a vendor's server using PHP 5.2 with cURL. I'm reading in an XML document to post against their server and then reading in a response:</p>
<pre><code>$request = trim(file_get_contents('test.xml'));
$curlHandle = curl_init($servletURL);
curl_setopt($curlHandle, CURLOPT_POST, TRUE);
curl_setopt($curlHandle, CURLOPT_POSTFIELDS, array('XML'=>$request));
curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curlHandle, CURLOPT_HEADER, FALSE); # Have also tried leaving this out
$response = curl_exec($curlHandle);
</code></pre>
<p>That code, in an of itself, works OK, but the other server returns a response from it's XML parser stating:</p>
<blockquote>
<p>Content not allowed in prolog</p>
</blockquote>
<p>I looked that error up and this is normally caused by whitespace before the XML, but I made sure that the XML file itself has no whitespace and the trim() should clear that up anyway. I did a TCPDump on the connection while I ran the code and this is what is sent out:</p>
<pre><code>POST {serverURL} HTTP/1.1
Host: {ip of server}:8080
Accept: */*
Content-Length: 921
Expect: 100-continue
Content-Type: multipart/form-data; boundry:---------------------------01e7cda3896f
---------------------------01e7cda3896f
Content-Disposition: form-data; name="XML"
[SNIP - the XML was displayed]
---------------------------01e7cda3896f--
</code></pre>
<p>Before and after the [SNIP] line there is visible whitespace when I replay the session in Ethereal. Is this what is causing the problem and, if so, how can I remove it, or am I looking too far and this may be an issue with the server I'm posting against?</p>
| [
{
"answer_id": 18215,
"author": "mercutio",
"author_id": 1951,
"author_profile": "https://Stackoverflow.com/users/1951",
"pm_score": 2,
"selected": false,
"text": "$file = 'test.xml';\n$fileHandle = fopen($file, 'r');\n$request = fread($fileHandle, filesize($file));\nfclose($fileHandle);... | 2008/08/20 | [
"https://Stackoverflow.com/questions/18166",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/204/"
] |
18,167 | <p>I've got a database server that I am unable to connect to using the credentials I've been provided. However, on the staging version of the same server, there's a linked server that points to the production database. Both the staging server and the linked server have the same schema.</p>
<p>I've been reassured that I should expect to be able to connect to the live server before we go live. Unfortunately, I've reached a point in my development where I need more than the token sample records that are currently in the staging database. So, I was hoping to connect to the linked server.</p>
<p>Thus far in my development against this schema has been against the staging server itself, using Subsonic objects. That all works fine.</p>
<p>I can connect via SQL Server Management Studio to that linked server and execute my queries directly. I can also execute 'manual" queries in C# against the linked server by having my connection string hook up to the staging server and running my queries as </p>
<p>SELECT * FROM OpenQuery([LINKEDSERVER],'QUERY')</p>
<p>However, the Subsonic objects are what's enabling me to bring this project in on time and under budget, so I'm not looking to do straight queries in my code.</p>
<p>What I'm looking for is whether there's a way to state the connection string to the linked server. I've looked at lots of forum entries, etc. on the topic and most of the answers seem to completely gloss over the "linked server" portion of the question, focusing on basic connection string syntax.</p>
| [
{
"answer_id": 18695,
"author": "TheEmirOfGroofunkistan",
"author_id": 1874,
"author_profile": "https://Stackoverflow.com/users/1874",
"pm_score": 2,
"selected": false,
"text": "databaseA.dbo.tableName\n linkedServerName.databaseA.dbo.tableName\n"
}
] | 2008/08/20 | [
"https://Stackoverflow.com/questions/18167",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1124/"
] |
18,172 | <p>I am looking for a robust way to copy files over a Windows network share that is tolerant of intermittent connectivity. The application is often used on wireless, mobile workstations in large hospitals, and I'm assuming connectivity can be lost either momentarily or for several minutes at a time. The files involved are typically about 200KB - 500KB in size. The application is written in VB6 (ugh), but we frequently end up using Windows DLL calls.</p>
<p>Thanks!</p>
| [
{
"answer_id": 19606,
"author": "Mark Brackett",
"author_id": 2199,
"author_profile": "https://Stackoverflow.com/users/2199",
"pm_score": 4,
"selected": true,
"text": "sourceFile = Compress(\"*.*\");\ndestFile = \"X:\\files.zip\";\n\nint copyFlags = COPYFILEFAILIFEXISTS | COPYFILERESTART... | 2008/08/20 | [
"https://Stackoverflow.com/questions/18172",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2144/"
] |
18,216 | <p>I'm not quite sure if this is possible, or falls into the category of pivot tables, but I figured I'd go to the pros to see.</p>
<p>I have three basic tables: Card, Property, and CardProperty. Since cards do not have the same properties, and often multiple values for the same property, I decided to use the union table approach to store data instead of having a really big column structure in my card table.</p>
<p>The property table is a basic keyword/value type table. So you have the keyword ATK and the value assigned to it. There is another property called SpecialType which a card can have multiple values for, such as "Sycnro" and "DARK"</p>
<p>What I'd like to do is create a view or stored procedure that gives me the Card Id, Card Name, and all the property keywords assigned to the card as columns and their values in the ResultSet for a card specified. So ideally I'd have a result set like:</p>
<pre><code>ID NAME SPECIALTYPE
1 Red Dragon Archfiend Synchro
1 Red Dragon Archfiend DARK
1 Red Dragon Archfiend Effect
</code></pre>
<p>and I could tally my results that way.</p>
<p>I guess even slicker would be to simply concatenate the properties together based on their keyword, so I could generate a ResultSet like:</p>
<pre><code>1 Red Dragon Archfiend Synchro/DARK/Effect
</code></pre>
<p>..but I don't know if that's feasible.</p>
<p>Help me stackoverflow Kenobi! You're my only hope.</p>
| [
{
"answer_id": 18245,
"author": "James A. Rosen",
"author_id": 1190,
"author_profile": "https://Stackoverflow.com/users/1190",
"pm_score": 0,
"selected": false,
"text": "table cards\ninteger ID | string name | ... (other properties common to all Cards)\n\ntable property_types\ninteger ID... | 2008/08/20 | [
"https://Stackoverflow.com/questions/18216",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/71/"
] |
18,223 | <p>I have a table in a SQL Server 2005 database with a trigger that is supposed to add a record to a different table whenever a new record is inserted. It seems to work fine, but if I execute an Insert Into on the master table that uses a subquery as the source of the values, the trigger only inserts one record in the other table, even though multiple records were added to the master. I want the trigger to fire for each new record added to the master table. Is that possible in 2005?</p>
<p>The insert I'm doing is:</p>
<pre><code>INSERT INTO [tblMenuItems] ([ID], [MenuID], [SortOrder], [ItemReference], [MenuReference], [ConcurrencyID]) SELECT [ID], [MenuID], [SortOrder], [ItemReference], [MenuReference], [ConcurrencyID] FROM [IVEEtblMenuItems]
</code></pre>
<p>Here is what the trigger looks like:</p>
<pre><code>CREATE TRIGGER [dbo].[tblMenuItemInsertSecurity] ON [dbo].[tblMenuItems]
FOR INSERT
AS
Declare @iRoleID int
Declare @iMenuItemID int
Select @iMenuItemID = [ID] from Inserted
DECLARE tblUserRoles CURSOR FASTFORWARD FOR SELECT [ID] from tblUserRoles
OPEN tblUserRoles
FETCH NEXT FROM tblUserRoles INTO @iRoleID
WHILE (@@FetchStatus = 0)
BEGIN
INSERT INTO tblRestrictedMenuItems(
[RoleID],
[MenuItemID],
[RestrictLevel])
VALUES(
@iRoleID,
@iMenuItemID,
1)
FETCH NEXT FROM tblUserRoles INTO @iRoleID
END
CLOSE tblUserRoles
Deallocate tblUserRoles
</code></pre>
| [
{
"answer_id": 18230,
"author": "Martin",
"author_id": 770,
"author_profile": "https://Stackoverflow.com/users/770",
"pm_score": 1,
"selected": false,
"text": "SELECT COUNT(*) FROM inserted \n"
}
] | 2008/08/20 | [
"https://Stackoverflow.com/questions/18223",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/741/"
] |
18,224 | <p>So, in your experience, whats the best way? Is there a secure way that's also scriptable/triggerable in a build automation tool?</p>
<p>Edit: I should mention this is windows/.net and I'll be deploying to iis6</p>
| [
{
"answer_id": 18243,
"author": "Neall",
"author_id": 619,
"author_profile": "https://Stackoverflow.com/users/619",
"pm_score": 1,
"selected": false,
"text": "#!/bin/bash\n\nset -e\ncp -R /var/livesite /var/newversion\nrsync user@devserver:/var/readytogolive /var/newversion\nmv /var/live... | 2008/08/20 | [
"https://Stackoverflow.com/questions/18224",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1946/"
] |
18,265 | <p>What methods are there for automatically getting a stack trace on Unix systems? I don't mean just getting a core file or attaching interactively with GDB, but having a SIGSEGV handler that dumps a backtrace to a text file. </p>
<p>Bonus points for the following optional features:</p>
<ul>
<li>Extra information gathering at crash time (eg. config files).</li>
<li>Email a crash info bundle to the developers.</li>
<li>Ability to add this in a <code>dlopen</code>ed shared library</li>
<li>Not requiring a GUI</li>
</ul>
| [
{
"answer_id": 18406,
"author": "Derek Park",
"author_id": 872,
"author_profile": "https://Stackoverflow.com/users/872",
"pm_score": 4,
"selected": true,
"text": "backtrace backtrace #include <execinfo.h>\n#include <signal.h>\n#include <stdio.h>\n#include <stdlib.h>\n\nvoid sig_handler(i... | 2008/08/20 | [
"https://Stackoverflow.com/questions/18265",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/954/"
] |
18,272 | <p>Server Management Studio tends to be a bit un-intuitive when it comes to managing Extended Properties, so can anyone recommend a decent tool that improves the situation.</p>
<p>One thing I would like to do is to have templates that I can apply objects, thus standardising the nomenclature and content of the properties applied to objects.</p>
| [
{
"answer_id": 15105932,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo]. [snap_xpColumn_addUpdate]') AN... | 2008/08/20 | [
"https://Stackoverflow.com/questions/18272",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/770/"
] |
18,290 | <p>Within Ruby on Rails applications database.yml is a plain text file that stores database credentials.</p>
<p>When I deploy my Rails applications I have an after deploy callback in my Capistrano
recipe that creates a symbolic link within the application's /config directory to the database.yml file. The file itself is stored in a separate directory that's outside the standard Capistrano /releases directory structure. I chmod 400 the file so it's only readable by the user who created it.</p>
<ul>
<li>Is this sufficient to lock it down? If not, what else do you do?</li>
<li>Is anyone encrypting their database.yml files?</li>
</ul>
| [
{
"answer_id": 1001484,
"author": "Olly",
"author_id": 1174,
"author_profile": "https://Stackoverflow.com/users/1174",
"pm_score": 5,
"selected": false,
"text": "production:\n adapter: mysql\n database: my_db\n username: db_user\n password: <%= begin IO.read(\"/home/my_deploy_user/.d... | 2008/08/20 | [
"https://Stackoverflow.com/questions/18290",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1450/"
] |
18,291 | <p>I'm wondering how the few Delphi users here are doing unit testing, if any? Is there anything that integrates with the IDE that you've found works well? If not, what tools are you using and do you have or know of example mini-projects that demonstrate how it all works?</p>
<h3>Update:</h3>
<p>I forgot to mention that I'm using BDS 2006 Pro, though I occasionally drop into Delphi 7, and of course others may be using other versions.</p>
| [
{
"answer_id": 5653865,
"author": "Arnaud Bouchez",
"author_id": 458259,
"author_profile": "https://Stackoverflow.com/users/458259",
"pm_score": 3,
"selected": false,
"text": "type\n TTestNumbersAdding = class(TSynTestCase)\n published\n procedure TestIntegerAdd;\n procedure Test... | 2008/08/20 | [
"https://Stackoverflow.com/questions/18291",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1461/"
] |
18,326 | <p>I like a bit of TiVo hacking in spare time - TiVo uses a Linux variant and <a href="http://wiki.tcl.tk/299" rel="nofollow noreferrer">TCL</a>. I'd like to write TCL scripts on my Windows laptop, test them and then FTP them over to my TiVo.</p>
<p>Can I have a recommendation for a TCL debugging environment for Windows, please?</p>
| [
{
"answer_id": 471599,
"author": "ctd",
"author_id": 58133,
"author_profile": "https://Stackoverflow.com/users/58133",
"pm_score": 0,
"selected": false,
"text": "proc bp {{s {}}} {\n if ![info exists ::bp_skip] {\n set ::bp_skip [list]\n } elseif {[lsearch -exact ... | 2008/08/20 | [
"https://Stackoverflow.com/questions/18326",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1223/"
] |
18,391 | <p>There is previous little on the google on this subject other than people asking this very same question.</p>
<p>How would I get started writing my own firewall?</p>
<p>I'm looking to write one for the windows platform but I would also be interested in this information for other operating systems too.
</p>
| [
{
"answer_id": 18398,
"author": "wvdschel",
"author_id": 2018,
"author_profile": "https://Stackoverflow.com/users/2018",
"pm_score": 2,
"selected": false,
"text": "connect listens"
},
{
"answer_id": 312142,
"author": "Adam Liss",
"author_id": 29157,
"author_profile": ... | 2008/08/20 | [
"https://Stackoverflow.com/questions/18391",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/840/"
] |
18,407 | <p>If I have a variable in C# that needs to be checked to determine if it is equal to one of a set of variables, what is the best way to do this?</p>
<p>I'm not looking for a solution that stores the set in an array. I'm more curious to see if there is a solution that uses boolean logic in some way to get the answer.</p>
<p>I know I could do something like this: </p>
<pre><code>int baseCase = 5;
bool testResult = baseCase == 3 || baseCase == 7 || baseCase == 12 || baseCase == 5;
</code></pre>
<p>I'm curious to see if I could do something more like this:</p>
<pre><code>int baseCase = 5;
bool testResult = baseCase == (3 | 7 | 12 | 5);
</code></pre>
<p>Obviously the above won't work, but I'm interested in seeing if there is something more succinct than my first example, which has to repeat the same variable over and over again for each test value.</p>
<p><strong>UPDATE:</strong><br>
I decided to accept CoreyN's answer as it seems like the most simple approach. It's practical, and still simple for a novice to understand, I think.</p>
<p>Unfortunately where I work our system uses the .NET 2.0 framework and there's no chance of upgrading any time soon. Are there any other solutions out there that don't rely on the .NET 3.5 framework, besides the most obvious one I can think of: </p>
<pre><code>new List<int>(new int[] { 3, 6, 7, 1 }).Contains(5);
</code></pre>
| [
{
"answer_id": 18416,
"author": "Corey",
"author_id": 1595,
"author_profile": "https://Stackoverflow.com/users/1595",
"pm_score": 5,
"selected": true,
"text": " bool b = new int[] { 3,7,12,5 }.Contains(5);\n"
},
{
"answer_id": 153037,
"author": "Joe",
"author_id": ... | 2008/08/20 | [
"https://Stackoverflow.com/questions/18407",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/392/"
] |
18,413 | <p>I have a column of data that contains a percentage range as a string that I'd like to convert to a number so I can do easy comparisons.</p>
<p>Possible values in the string:</p>
<pre><code>'<5%'
'5-10%'
'10-15%'
...
'95-100%'
</code></pre>
<p>I'd like to convert this in my select where clause to just the first number, 5, 10, 15, etc. so that I can compare that value to a passed in "at least this" value.</p>
<p>I've tried a bunch of variations on substring, charindex, convert, and replace, but I still can't seem to get something that works in all combinations.</p>
<p>Any ideas?</p>
| [
{
"answer_id": 18451,
"author": "mercutio",
"author_id": 1951,
"author_profile": "https://Stackoverflow.com/users/1951",
"pm_score": 0,
"selected": false,
"text": "\"<5%\" => 0\n\"5-10%\" => 5\n\"95-100%\" => 95\n SELECT \"5-10%\" + 0 AS foo ...\n"
},
{
"answer_id": 18454,
... | 2008/08/20 | [
"https://Stackoverflow.com/questions/18413",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1097/"
] |
18,418 | <p>When I am writing code in Python, I often need to remove items from a list or other sequence type based on some criteria. I haven't found a solution that is elegant and efficient, as removing items from a list you are currently iterating through is bad. For example, you can't do this:</p>
<pre><code>for name in names:
if name[-5:] == 'Smith':
names.remove(name)
</code></pre>
<p>I usually end up doing something like this:</p>
<pre><code>toremove = []
for name in names:
if name[-5:] == 'Smith':
toremove.append(name)
for name in toremove:
names.remove(name)
del toremove
</code></pre>
<p>This is innefficient, fairly ugly and possibly buggy (how does it handle multiple 'John Smith' entries?). Does anyone have a more elegant solution, or at least a more efficient one? </p>
<p>How about one that works with dictionaries?</p>
| [
{
"answer_id": 18430,
"author": "pottedmeat",
"author_id": 2120,
"author_profile": "https://Stackoverflow.com/users/2120",
"pm_score": 2,
"selected": false,
"text": "names = filter(lambda x: x[-5:] != \"Smith\", names);\n"
},
{
"answer_id": 18431,
"author": "mk.",
"author... | 2008/08/20 | [
"https://Stackoverflow.com/questions/18418",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1892/"
] |
18,419 | <p>I've got a combo-box that sits inside of a panel in Flex 3. Basically I want to fade the panel using a Fade effect in ActionScript. I can get the fade to work fine, however the label of the combo-box does not fade. I had this same issue with buttons and found that their fonts needed to be embedded. No problem. I embedded the font that I was using and the buttons' labels faded correctly. I've tried a similar approach to the combo-box, but it does not fade the selected item label.</p>
<p>Here is what I've done so far:
Embed code for the font at the top of my MXML in script:</p>
<pre><code>[Embed("assets/trebuc.ttf", fontName="TrebuchetMS")]
public var trebuchetMSFont:Class;
</code></pre>
<p>In my init function</p>
<pre><code>//register the font.
Font.registerFont(trebuchetMSFont);
</code></pre>
<p>The combobox's mxml:</p>
<pre><code><mx:ComboBox id="FilterFields" styleName="FilterDropdown"
left="10" right="10" top="10"
fontSize="14">
<mx:itemRenderer>
<mx:Component>
<mx:Label fontSize="10" />
</mx:Component>
</mx:itemRenderer>
</mx:ComboBox>
</code></pre>
<p>And a style that I wrote to get the fonts applied to the combo-box:</p>
<pre><code>.FilterDropdown
{
embedFonts: true;
fontFamily: TrebuchetMS;
fontWeight: normal;
fontSize: 12;
}
</code></pre>
<p>The reason I had to write a style instead of placing it in the "FontFamily" attribute was that the style made all the text on the combo-box the correct font where the "FontFamily" attribute only made the items in the drop-down use the correct font.
</p>
| [
{
"answer_id": 18463,
"author": "Matt MacLean",
"author_id": 22,
"author_profile": "https://Stackoverflow.com/users/22",
"pm_score": 2,
"selected": false,
"text": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<mx:Application xmlns:mx=\"http://www.adobe.com/2006/mxml\" layout=\"absolute\" ... | 2008/08/20 | [
"https://Stackoverflow.com/questions/18419",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1290/"
] |
18,432 | <p>I am developing a Reporting Services solution for a DOD website. Frequently I'll have a report and want to have as a parameter the Service (in addition to other similar mundane, but repetitive parameters like Fiscal Year, Data Effective Date, etc). Basically everything I've seen of SSRS 2005 says it can't be done... but I personally refuse to believe that MS would be so stupid/naive/short-sited to leave something like sharing datasets out of reporting entirely.</p>
<p>Is there a clunky (or not so clunky way) to share datasets and still keep the reporting server happy? Will SSRS2008 do this?</p>
<p>EDIT:</p>
<p>I guess I worded that unclearly. I have a stack of reports. Since I'm in a DoD environment, one common parameter for these reports is Service (army, navy, etc. for those non US users). Since "Business rules" cause me to not be able to use stored procedures; is there a way I can make 1 dataset and link to it from the various reports? Will Reporting 2008 support something like this? I'm getting sick of re-typing the same query in a bunch of reports.</p>
| [
{
"answer_id": 18502,
"author": "csmba",
"author_id": 350,
"author_profile": "https://Stackoverflow.com/users/350",
"pm_score": 2,
"selected": true,
"text": "A B A A B"
}
] | 2008/08/20 | [
"https://Stackoverflow.com/questions/18432",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2156/"
] |
18,449 | <p>For those of us who use standard shared hosting packages, such as GoDaddy or Network Solutions, how do you handle datetime conversions when your hosting server (PHP) and MySQL server are in different time zones?</p>
<p>Also, does anybody have some best practice advice for determining what time zone a visitor to your site is in and manipulating a datetime variable appropriately?</p>
| [
{
"answer_id": 18607,
"author": "Željko Živković",
"author_id": 1926,
"author_profile": "https://Stackoverflow.com/users/1926",
"pm_score": 5,
"selected": true,
"text": "SET timezone = 'Europe/London';\n //Returns the offset (time difference) between Greenwich Mean Time (GMT) \n//and loc... | 2008/08/20 | [
"https://Stackoverflow.com/questions/18449",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2056/"
] |
18,450 | <p>Has anyone used Mono, the open source .NET implementation on a large or medium sized project? I'm wondering if it's ready for real world, production environments. Is it stable, fast, compatible, ... enough to use? Does it take a lot of effort to port projects to the Mono runtime, or is it really, <em>really</em> compatible enough to just take of and run already written code for Microsoft's runtime?</p>
| [
{
"answer_id": 18488,
"author": "FlySwat",
"author_id": 1965,
"author_profile": "https://Stackoverflow.com/users/1965",
"pm_score": 5,
"selected": false,
"text": "Path.Separator \"\\\" Environment.NewLine \"\\n\""
},
{
"answer_id": 19021501,
"author": "head_thrash",
"auth... | 2008/08/20 | [
"https://Stackoverflow.com/questions/18450",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2018/"
] |
18,460 | <p>What is the best way to authorize all users to one single page in a asp.net website.</p>
<p>For except the login page and one other page, I deny all users from viewing pages in the website. </p>
<p>How do you make this page accessible to all users?</p>
| [
{
"answer_id": 18469,
"author": "Dillie-O",
"author_id": 71,
"author_profile": "https://Stackoverflow.com/users/71",
"pm_score": 4,
"selected": true,
"text": "<location path=\"Login.aspx\">\n <system.web>\n <authorization>\n <allow users =\"*\" />\n </authorization>\n... | 2008/08/20 | [
"https://Stackoverflow.com/questions/18460",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2172/"
] |
18,465 | <p>In .Net you can read a string value into another data type using either <code><datatype>.parse</code> or <code>Convert.To<DataType></code>. </p>
<p>I'm not familiar with the fundamentals of parse versus convert so I am always at a loss when asked which one is better/faster/more appropriate. </p>
<p>So - which way is best in what type of circumstances?</p>
| [
{
"answer_id": 18523,
"author": "Keith",
"author_id": 905,
"author_profile": "https://Stackoverflow.com/users/905",
"pm_score": 5,
"selected": true,
"text": "Convert.ToXXX() .Parse() .TryParse() //o is actually a boxed int\nobject o = 12345;\n\n//unboxes it\nint castVal = (int) 12345;\n\... | 2008/08/20 | [
"https://Stackoverflow.com/questions/18465",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/149/"
] |
18,524 | <p>I have a list of integers, <code>List<Integer></code> and I'd like to convert all the integer objects into Strings, thus finishing up with a new <code>List<String></code>.</p>
<p>Naturally, I could create a new <code>List<String></code> and loop through the list calling <code>String.valueOf()</code> for each integer, but I was wondering if there was a better (read: <em>more automatic</em>) way of doing it?</p>
| [
{
"answer_id": 18529,
"author": "jsight",
"author_id": 1432,
"author_profile": "https://Stackoverflow.com/users/1432",
"pm_score": 7,
"selected": true,
"text": "List<Integer> oldList = ...\n/* Specify the size of the list up front to prevent resizing. */\nList<String> newList = new Array... | 2008/08/20 | [
"https://Stackoverflow.com/questions/18524",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/916/"
] |
18,533 | <p>I've found myself increasingly unsatisfied with the DataSet/DataTable/DataRow paradigm in .Net, mostly because it's often a couple of steps more complicated than what I really want to do. In cases where I'm binding to controls, DataSets are fine. But in other cases, there seems to be a fair amount of mental overhead.</p>
<p>I've played a bit with SqlDataReader, and that seems to be good for simple jaunts through a select, but I feel like there may be some other models lurking in .Net that are useful to learn more about. I feel like all of the help I find on this just uses DataSet by default. Maybe that and DataReader really are the best options.</p>
<p>I'm not looking for a best/worst breakdown, just curious what my options are and what experiences you've had with them. Thanks!</p>
<p>-Eric Sipple</p>
| [
{
"answer_id": 18581,
"author": "Keith",
"author_id": 905,
"author_profile": "https://Stackoverflow.com/users/905",
"pm_score": 2,
"selected": false,
"text": "IEnumerable<T>"
},
{
"answer_id": 18630,
"author": "Mike",
"author_id": 785,
"author_profile": "https://Stack... | 2008/08/20 | [
"https://Stackoverflow.com/questions/18533",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/111/"
] |
18,538 | <p>I'd like some sorthand for this:</p>
<pre><code>Map rowToMap(row) {
def rowMap = [:];
row.columns.each{ rowMap[it.name] = it.val }
return rowMap;
}
</code></pre>
<p>given the way the GDK stuff is, I'd expect to be able to do something like:</p>
<pre><code>Map rowToMap(row) {
row.columns.collectMap{ [it.name,it.val] }
}
</code></pre>
<p>but I haven't seen anything in the docs... am I missing something? or am I just way too lazy?</p>
| [
{
"answer_id": 18981,
"author": "danb",
"author_id": 2031,
"author_profile": "https://Stackoverflow.com/users/2031",
"pm_score": 1,
"selected": false,
"text": "ArrayList.metaClass.collectMap = {Closure callback->\n def map = [:]\n delegate.each {\n def r = callback.call(it)\... | 2008/08/20 | [
"https://Stackoverflow.com/questions/18538",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2031/"
] |
18,584 | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/9/how-do-i-calculate-someones-age-in-c">How do I calculate someone's age in C#?</a> </p>
</blockquote>
<p>Maybe this could be silly but and I don't have issues with my age but sometimes it is good to calculate the exact age of someone, I have introduced my birthdate in my profile (01/12/1975) "dd/mm/yyyy" and it calculated 33 and I'm 32 actually still, isn't it better to calculate the exact age? </p>
<p>Maybe</p>
<pre><code>DateTime dt1 = DateTime.Now;
TimeSpan dt2;
dt2 = dt1.Subtract(new DateTime(1975, 12, 01));
double year = dt2.TotalDays / 365;
</code></pre>
<p>The result of year is 32.77405678074</p>
<p>Could this code be OK?</p>
| [
{
"answer_id": 18610,
"author": "Kibbee",
"author_id": 1862,
"author_profile": "https://Stackoverflow.com/users/1862",
"pm_score": 0,
"selected": false,
"text": "Dim myAge AS Integer = DateTime.Now.year - BirthDate.year\nIf Birthdate.month < DateTime.Now.Month _\nOrElse BirthDate.Month =... | 2008/08/20 | [
"https://Stackoverflow.com/questions/18584",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1130097/"
] |
18,585 | <h3>Update: Solved, with code</h3>
<p><a href="https://stackoverflow.com/questions/18585/why-cant-you-bind-the-size-of-a-windows-form-to-applicationsettings#19056">I got it working, see my answer below for the code...</a></p>
<h3>Original Post</h3>
<p>As Tundey pointed out in <a href="https://stackoverflow.com/questions/18421/best-way-to-bind-windows-forms-properties-to-applicationsettings-in-c#18456">his answer</a> to my <a href="https://stackoverflow.com/questions/18421/best-way-to-bind-windows-forms-properties-to-applicationsettings-in-c">last question</a>, you can bind nearly everything about a windows forms control to ApplicationSettings pretty effortlessly. So is there really no way to do this with form Size? <a href="http://www.codeproject.com/KB/cs/UserSettings.aspx" rel="nofollow noreferrer">This tutorial</a> says you need to handle Size explicitly so you can save RestoreBounds instead of size if the window is maximized or minimized. However, I hoped I could just use a property like:</p>
<pre><code>public Size RestoreSize
{
get
{
if (this.WindowState == FormWindowState.Normal)
{
return this.Size;
}
else
{
return this.RestoreBounds.Size;
}
}
set
{
...
}
}
</code></pre>
<p>But I can't see a way to bind this in the designer (Size is notably missing from the PropertyBinding list).</p>
| [
{
"answer_id": 18659,
"author": "Rob Cooper",
"author_id": 832,
"author_profile": "https://Stackoverflow.com/users/832",
"pm_score": 1,
"selected": false,
"text": "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n<configuration>\n <appSettings>\n <add key =\"FormHeight\" value=\"50... | 2008/08/20 | [
"https://Stackoverflow.com/questions/18585",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/229/"
] |
18,608 | <p>I've got a group of inter-related classes that are all overridden together to create a particular implementation. I'm wondering if it is a good idea to enclose the interrelated subclasses in a namespace.</p>
<p>For example purposes, consider the following namespaces and classes:</p>
<pre><code>namespace Protocol
{
public abstract class Message { }
public abstract class Driver { }
}
namespace Protocol.Tcp
{
public class TcpMessage : Message { }
public class TcpDriver : Driver { }
}
namespace Protocol.Ftp
{
public class FtpMessage : Message { }
public class FtpDriver : Driver { }
}
</code></pre>
<p>What is the best way to structure the namespaces? It seems unavoidable to expose the inheritance in the namespace since the base classes don't really belong in either the Protocol.Tcp namespace or the Protocol.Ftp namespace.</p>
| [
{
"answer_id": 18616,
"author": "Rob Cooper",
"author_id": 832,
"author_profile": "https://Stackoverflow.com/users/832",
"pm_score": 4,
"selected": true,
"text": "using System.Data;\nusing System.Data.Sql;\n"
},
{
"answer_id": 18625,
"author": "mmattax",
"author_id": 1638... | 2008/08/20 | [
"https://Stackoverflow.com/questions/18608",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/327/"
] |
18,617 | <p>How do you configure tomcat to bind to a single ip address (localhost) instead of all addresses?</p>
| [
{
"answer_id": 18623,
"author": "ScArcher2",
"author_id": 1310,
"author_profile": "https://Stackoverflow.com/users/1310",
"pm_score": 8,
"selected": true,
"text": "tomcat/conf/server.xml"
}
] | 2008/08/20 | [
"https://Stackoverflow.com/questions/18617",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1310/"
] |
18,632 | <p>For debugging purposes in a somewhat closed system, I have to output text to a file.</p>
<p>Does anyone know of a tool that runs on windows (console based or not) that detects changes to a file and outputs them in real-time?</p>
| [
{
"answer_id": 18648,
"author": "Nelson Miranda",
"author_id": 1130097,
"author_profile": "https://Stackoverflow.com/users/1130097",
"pm_score": 1,
"selected": false,
"text": "public static void Main()\n{\nRun();\n\n}\n\n[PermissionSet(SecurityAction.Demand, Name=\"FullTrust\")]\npublic ... | 2008/08/20 | [
"https://Stackoverflow.com/questions/18632",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2011/"
] |
18,655 | <p>I really need to see some honest, thoughtful debate on the merits of the currently accepted <strong><em>enterprise application</em></strong> design paradigm.</p>
<p>I am not convinced that entity objects should exist.</p>
<p>By entity objects I mean the typical things we tend to build for our applications, like "Person", "Account", "Order", etc.</p>
<p>My current design philosophy is this:</p>
<ul>
<li>All database access must be accomplished via stored procedures.</li>
<li>Whenever you need data, call a stored procedure and iterate over a SqlDataReader or the rows in a DataTable</li>
</ul>
<p>(Note: I have also built enterprise applications with Java EE, java folks please substitute the equvalent for my .NET examples)</p>
<p>I am not anti-OO. I write lots of classes for different purposes, just not entities. I will admit that a large portion of the classes I write are static helper classes.</p>
<p>I am not building toys. I'm talking about large, high volume transactional applications deployed across multiple machines. Web applications, windows services, web services, b2b interaction, you name it.</p>
<p>I have used OR Mappers. I have written a few. I have used the Java EE stack, CSLA, and a few other equivalents. I have not only used them but actively developed and maintained these applications in production environments.</p>
<p>I have come to the battle-tested conclusion that entity objects are getting in our way, and our lives would be <em>so</em> much easier without them.</p>
<p>Consider this simple example: you get a support call about a certain page in your application that is not working correctly, maybe one of the fields is not being persisted like it should be. With my model, the developer assigned to find the problem opens <em>exactly 3 files</em>. An ASPX, an ASPX.CS and a SQL file with the stored procedure. The problem, which might be a missing parameter to the stored procedure call, takes minutes to solve. But with any entity model, you will invariably fire up the debugger, start stepping through code, and you may end up with 15-20 files open in Visual Studio. By the time you step down to the bottom of the stack, you forgot where you started. We can only keep so many things in our heads at one time. Software is incredibly complex without adding any unnecessary layers.</p>
<p>Development complexity and troubleshooting are just one side of my gripe.</p>
<p>Now let's talk about scalability.</p>
<p>Do developers realize that each and every time they write or modify any code that interacts with the database, they need to do a throrough analysis of the exact impact on the database? And not just the development copy, I mean a mimic of production, so you can see that the additional column you now require for your object just invalidated the current query plan and a report that was running in 1 second will now take 2 minutes, just because you added a single column to the select list? And it turns out that the index you now require is so big that the DBA is going to have to modify the physical layout of your files?</p>
<p>If you let people get too far away from the physical data store with an abstraction, they will create havoc with an application that needs to scale.</p>
<p>I am not a zealot. I can be convinced if I am wrong, and maybe I am, since there is such a strong push towards Linq to Sql, ADO.NET EF, Hibernate, Java EE, etc. Please think through your responses, if I am missing something I really want to know what it is, and why I should change my thinking.</p>
<p><strong><em>[Edit]</em></strong></p>
<p>It looks like this question is suddenly active again, so now that we have the new comment feature I have commented directly on several answers. Thanks for the replies, I think this is a healthy discussion.</p>
<p>I probably should have been more clear that I am talking about enterprise applications. I really can't comment on, say, a game that's running on someone's desktop, or a mobile app.</p>
<p>One thing I have to put up here at the top in response to several similar answers: orthogonality and separation of concerns often get cited as reasons to go entity/ORM. Stored procedures, to me, are the best example of separation of concerns that I can think of. If you disallow all other access to the database, other than via stored procedures, you could in theory redesign your entire data model and not break any code, so long as you maintained the inputs and outputs of the stored procedures. They are a perfect example of programming by contract (just so long as you avoid "select *" and document the result sets).</p>
<p>Ask someone who's been in the industry for a long time and has worked with long-lived applications: how many application and UI layers have come and gone while a database has lived on? How hard is it to tune and refactor a database when there are 4 or 5 different persistence layers generating SQL to get at the data? You can't change anything! ORMs or any code that generates SQL <strong><em>lock your database in stone</em></strong>.</p>
| [
{
"answer_id": 280560,
"author": "Pavel Feldman",
"author_id": 5507,
"author_profile": "https://Stackoverflow.com/users/5507",
"pm_score": 2,
"selected": false,
"text": "void exportOrder(Order order, String fileName){...};\n"
},
{
"answer_id": 397093,
"author": "Renaud Bompui... | 2008/08/20 | [
"https://Stackoverflow.com/questions/18655",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1219/"
] |
18,661 | <p>Is it possible to get UI text from an external application in C#. </p>
<p>In particular, is there a way to read Unicode text from a label (I assume it's a normal Windows label control) from an external Win32 app that was written by a 3rd party? The text is visible, but not selectable by mouse in the UI.</p>
<p>I assume there is some accessibility API (e.g. meant for screen readers) that allows this. </p>
<p>Edit: Currently looking into using something like the <a href="http://msdn.microsoft.com/en-us/magazine/cc163617.aspx" rel="nofollow noreferrer">Managed Spy App</a> but would still appreciate any other leads.</p>
| [
{
"answer_id": 18698,
"author": "Lars Truijens",
"author_id": 1242,
"author_profile": "https://Stackoverflow.com/users/1242",
"pm_score": 3,
"selected": false,
"text": "[DllImport(\"user32.dll\")]\npublic static extern int SendMessage (IntPtr hWnd, int msg, int Param, System.Text.StringB... | 2008/08/20 | [
"https://Stackoverflow.com/questions/18661",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/838/"
] |
18,671 | <p>Anyone know a quick easy way to migrate a SQLite3 database to MySQL?</p>
| [
{
"answer_id": 25860,
"author": "Richard Gourlay",
"author_id": 2674,
"author_profile": "https://Stackoverflow.com/users/2674",
"pm_score": 4,
"selected": false,
"text": "sqlite3 sample.db .dump > dump.sql\n mysql -p -u root -h 127.0.0.1 test < dump.sql\n BEGIN TRANSACTION;\n...\nCOMMIT;... | 2008/08/20 | [
"https://Stackoverflow.com/questions/18671",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/534/"
] |
18,676 | <p>I need to generate a random integer between 1 and n (where n is a positive whole number) to use for a unit test. I don't need something overly complicated to ensure true randomness - just an old-fashioned random number.</p>
<p>How would I do that?</p>
| [
{
"answer_id": 18680,
"author": "Kibbee",
"author_id": 1862,
"author_profile": "https://Stackoverflow.com/users/1862",
"pm_score": 7,
"selected": true,
"text": "CInt(Math.Ceiling(Rnd() * n)) + 1\n"
},
{
"answer_id": 18684,
"author": "Bill the Lizard",
"author_id": 1288,
... | 2008/08/20 | [
"https://Stackoverflow.com/questions/18676",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/225/"
] |
18,685 | <p>Can anyone tell me how I can display a status message like "12 seconds ago" or "5 minutes ago" etc in a web page?</p>
| [
{
"answer_id": 18693,
"author": "Niyaz",
"author_id": 184,
"author_profile": "https://Stackoverflow.com/users/184",
"pm_score": 7,
"selected": true,
"text": "function time_since($since) {\n $chunks = array(\n array(60 * 60 * 24 * 365 , 'year'),\n array(60 * 60 * 24 * 30 ... | 2008/08/20 | [
"https://Stackoverflow.com/questions/18685",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/184/"
] |
18,717 | <p>As far as I know, foreign keys (FK) are used to aid the programmer to manipulate data in the correct way. Suppose a programmer is actually doing this in the right manner already, then do we really need the concept of foreign keys?</p>
<p>Are there any other uses for foreign keys? Am I missing something here?</p>
| [
{
"answer_id": 18728,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 6,
"selected": false,
"text": "ON DELETE CASCADE"
},
{
"answer_id": 18760,
"author": "csmba",
"author_id": 350,
"author_profile": "ht... | 2008/08/20 | [
"https://Stackoverflow.com/questions/18717",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/184/"
] |
18,719 | <p>As part of our databuild run a 3rd party program (3D Studio Max) to export a number of assets. Unfortunately if a user is not currently logged in, or the machine is locked, then Max does not run correctly.</p>
<p>This can be solved for freshly booted machines by using a method such as TweakUI for automatic login. However when a user connects via Remote Desktop (to initiate a non-scheduled build, change a setting, whatever) then after the session ends the machine is left in a locked state with Max unable to run.</p>
<p>I'm looking for a way to configure windows (via fair means or foul) so either it does not lock when the remote session ends, or it "unlocks" itself a short while after. I'm aware of a method under XP where you can run a batchfile on the machine which kicks the remote user off, but this does not appear to work on Windows Server.</p>
| [
{
"answer_id": 154546,
"author": "Ed Haber",
"author_id": 2926,
"author_profile": "https://Stackoverflow.com/users/2926",
"pm_score": 0,
"selected": false,
"text": "myworkstation.mydomain.local /ADMIN\n"
}
] | 2008/08/20 | [
"https://Stackoverflow.com/questions/18719",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1043/"
] |
18,754 | <p>I'm writing some documentation in Markdown, and creating a separate file for each section of the doc. I would like to be able to convert all the files to HTML in one go, but I can't find anyone else who has tried the same thing. I'm on a Mac, so I would think a simple bash script should be able to handle it, but I've never done anything in bash and haven't had any luck. It seems like it should be simple to write something so I could just run:</p>
<pre><code>markdown-batch ./*.markdown
</code></pre>
<p>Any ideas?</p>
| [
{
"answer_id": 18775,
"author": "Julio César",
"author_id": 2148,
"author_profile": "https://Stackoverflow.com/users/2148",
"pm_score": -1,
"selected": false,
"text": "@echo off\nfor %i in (*.txt) python markdown.py \"%i\"\n"
},
{
"answer_id": 18831,
"author": "Patrick McElha... | 2008/08/20 | [
"https://Stackoverflow.com/questions/18754",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2185/"
] |
18,757 | <p>The Add view and the Edit view are often incredibly similar that it is unwarranted to write 2 views. As the app evolves you would be making the same changes to both.</p>
<p>However, there are usually subtle differences. For instance, a field might be read-only once it's been added, and if that field is a DropDownList you no longer need that List in the ViewData.</p>
<p>So, should I create a view data class which contains all the information for both views, where, depending on the operation you're performing, certain properties will be null?<br>
Should I include the operation in the view data as an enum?<br>
Should I surround all the subtle differences with <em><% if( ViewData.Model.Op == Ops.Editing ) { %></em> ?</p>
<p>Or is there a better way?</p>
| [
{
"answer_id": 18956,
"author": "Jim",
"author_id": 1208,
"author_profile": "https://Stackoverflow.com/users/1208",
"pm_score": 2,
"selected": false,
"text": "<%= Helper.ProfessionField() %>\n\nstring ProfessionField()\n{\n if(IsNewItem) { return /* some drop down code */ }\n else ... | 2008/08/20 | [
"https://Stackoverflow.com/questions/18757",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1851/"
] |
18,764 | <p>Since both a <code>Table Scan</code> and a <code>Clustered Index Scan</code> essentially scan all records in the table, why is a Clustered Index Scan supposedly better?</p>
<p>As an example - what's the performance difference between the following when there are many records?:</p>
<pre><code>declare @temp table(
SomeColumn varchar(50)
)
insert into @temp
select 'SomeVal'
select * from @temp
-----------------------------
declare @temp table(
RowID int not null identity(1,1) primary key,
SomeColumn varchar(50)
)
insert into @temp
select 'SomeVal'
select * from @temp
</code></pre>
| [
{
"answer_id": 18906,
"author": "Mark Brackett",
"author_id": 2199,
"author_profile": "https://Stackoverflow.com/users/2199",
"pm_score": 7,
"selected": true,
"text": "INSERT UPDATE DELETE RANGE SELECT * FROM TABLE WHERE Id BETWEEN 1 AND 100 WHERE INSERT UPDATE DELETE INSERT UPDATE DELET... | 2008/08/20 | [
"https://Stackoverflow.com/questions/18764",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/357/"
] |
18,765 | <p>I'm currently working on creating a new C# project that needs to interact with an older C++ application. There is an error enumeration that already exists in the C++ app that I need to use in the C# app.</p>
<p><em>I don't want to just re declare the enumeration in C# because that could cause sync issues down the line if the files aren't updated together</em>. </p>
<p>All that being said my question is this:
Is there a way for me to taken an enumeration declared like so:</p>
<pre><code>typedef enum
{
eDEVICEINT_ERR_FATAL = 0x10001
...
} eDeviceIntErrCodes;
</code></pre>
<p>and use it in a C# program like so:</p>
<pre><code>eDeviceIntErrCodes.eDEVICEINT_ERR_FATAL
</code></pre>
| [
{
"answer_id": 18786,
"author": "Brian Ensink",
"author_id": 1254,
"author_profile": "https://Stackoverflow.com/users/1254",
"pm_score": 5,
"selected": true,
"text": "\n public enum eDeviceIntErrCodes \n {\n /// eDEVICEINT_ERR_FATAL -> 0x10001\n eDEVICEINT_ERR_FATAL =... | 2008/08/20 | [
"https://Stackoverflow.com/questions/18765",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2191/"
] |
18,783 | <p>When you have a query or stored procedure that needs performance tuning, what are some of the first things you try?</p>
| [
{
"answer_id": 18792,
"author": "Mike",
"author_id": 1573,
"author_profile": "https://Stackoverflow.com/users/1573",
"pm_score": 2,
"selected": false,
"text": "where SomeComplicatedFunctionOf(table.Column) = @param --silly\n"
},
{
"answer_id": 18822,
"author": "Seibar",
"... | 2008/08/20 | [
"https://Stackoverflow.com/questions/18783",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/357/"
] |
18,787 | <p>When a controller renders a view based on a model you can get the properties from the ViewData collection using the indexer (ie. ViewData["Property"]). However, I have a shared user control that I tried to call using the following:</p>
<pre><code>return View("Message", new { DisplayMessage = "This is a test" });
</code></pre>
<p>and on my Message control I had this:</p>
<pre><code><%= ViewData["DisplayMessage"] %>
</code></pre>
<p>I would think this would render the DisplayMessage correctly, however, null is being returned. After a heavy dose of tinkering around, I finally created a "MessageData" class in order to strongly type my user control:</p>
<pre><code>public class MessageControl : ViewUserControl<MessageData>
</code></pre>
<p>and now this call works:</p>
<pre><code>return View("Message", new MessageData() { DisplayMessage = "This is a test" });
</code></pre>
<p>and can be displayed like this:</p>
<pre><code><%= ViewData.Model.DisplayMessage %>
</code></pre>
<p>Why wouldn't the DisplayMessage property be added to the ViewData (ie. ViewData["DisplayMessage"]) collection without strong typing the user control? Is this by design? Wouldn't it make sense that ViewData would contain a key for "DisplayMessage"?</p>
| [
{
"answer_id": 31726,
"author": "Haacked",
"author_id": 598,
"author_profile": "https://Stackoverflow.com/users/598",
"pm_score": 4,
"selected": true,
"text": "ViewData.Eval(\"DisplayMessage\") \n"
}
] | 2008/08/20 | [
"https://Stackoverflow.com/questions/18787",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/105/"
] |
18,803 | <p>In college I've had numerous design and <a href="http://en.wikipedia.org/wiki/Unified_Modeling_Language" rel="noreferrer">UML</a> oriented courses, and I recognize that UML can be used to benefit a software project, especially <a href="http://en.wikipedia.org/wiki/Use_case" rel="noreferrer">use-case</a> mapping, but is it really practical? I've done a few co-op work terms, and it appears that UML is not used heavily in the industry. Is it worth the time during a project to create UML diagrams? Also, I find that class diagrams are generally not useful, because it's just faster to look at the header file for a class. Specifically which diagrams are the most useful?</p>
<p><strong>Edit:</strong> My experience is limited to small, under 10 developer projects.</p>
<p><strong>Edit:</strong> Many good answers, and though not the most verbose, I belive the one selected is the most balanced.</p>
| [
{
"answer_id": 18839,
"author": "Pascal",
"author_id": 1311,
"author_profile": "https://Stackoverflow.com/users/1311",
"pm_score": 7,
"selected": true,
"text": "UML"
}
] | 2008/08/20 | [
"https://Stackoverflow.com/questions/18803",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2134/"
] |
18,836 | <p>I'm looking for shell scripts files installed on my system, but <strong>find</strong> doesn't work:</p>
<pre><code>$ find /usr -name *.sh
</code></pre>
<p>But I know there are a ton of scripts out there. For instance:</p>
<pre><code>$ ls /usr/local/lib/*.sh
/usr/local/lib/tclConfig.sh
/usr/local/lib/tkConfig.sh
</code></pre>
<p>Why doesn't <strong>find</strong> work?</p>
| [
{
"answer_id": 18837,
"author": "Jon Ericson",
"author_id": 1438,
"author_profile": "https://Stackoverflow.com/users/1438",
"pm_score": 7,
"selected": true,
"text": "$ find /usr -name \\*.sh\n $ find /usr -name '*.sh'\n $ find /usr -name tkConfig.sh\n $ cd /usr/local/lib\n$ find /usr -na... | 2008/08/20 | [
"https://Stackoverflow.com/questions/18836",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1438/"
] |
18,858 | <p>Does anyone here know of good batch file code indenters or beautifiers?</p>
<p>Specifically for PHP, JS and SGML-languages.</p>
<p>Preferably with options as to style.</p>
| [
{
"answer_id": 18837,
"author": "Jon Ericson",
"author_id": 1438,
"author_profile": "https://Stackoverflow.com/users/1438",
"pm_score": 7,
"selected": true,
"text": "$ find /usr -name \\*.sh\n $ find /usr -name '*.sh'\n $ find /usr -name tkConfig.sh\n $ cd /usr/local/lib\n$ find /usr -na... | 2008/08/20 | [
"https://Stackoverflow.com/questions/18858",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2118/"
] |
18,861 | <p>So I am writing a registration form and I need the display name to be only numbers, letters and underscores. </p>
<p>Have a look at my code and tell me what I'm doing wrong.</p>
<pre><code><form method="post" action="/" onsubmit="return check_form()">
<input type="text" id="display-name" name="display-name" maxlength="255" />
<input type="submit" />
</form>
<script type="text/javascript">
<!--
var name_regex = /^([a-zA-Z0-9_])+/
function check_form()
{
if (!name_regex.test(document.forms[0].elements[0].value))
{
document.forms[0].elements[0].focus()
alert("Your display name may only contain letters, numbers and underscores")
return false
}
}
-->
</script>
</code></pre>
<p>It's obviously been trimmed down to not include anything not related to the problem but even this snippet doesn't work.</p>
| [
{
"answer_id": 18874,
"author": "AnnanFay",
"author_id": 2118,
"author_profile": "https://Stackoverflow.com/users/2118",
"pm_score": 3,
"selected": false,
"text": "/^[a-zA-Z0-9_]+$/ $"
},
{
"answer_id": 18881,
"author": "samjudson",
"author_id": 1908,
"author_profile"... | 2008/08/20 | [
"https://Stackoverflow.com/questions/18861",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/428190/"
] |
18,869 | <p>I am running a Qt 4.5 commercial snapshot and want to use a plugin that I downloaded (it's a .so file) in my <code>QWebView</code>. Is there a specific location where I need to place this file? Can I grab it using the <code>QWebPluginFactory</code>?</p>
| [
{
"answer_id": 22203,
"author": "Ashwin Nanjappa",
"author_id": 1630,
"author_profile": "https://Stackoverflow.com/users/1630",
"pm_score": 0,
"selected": false,
"text": "/lib/\n/usr/lib/\n/usr/share/lib/\n/usr/local/lib/\n"
}
] | 2008/08/20 | [
"https://Stackoverflow.com/questions/18869",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1449/"
] |
18,889 | <p>Is anyone working on or know if there exists a SQL 2k8 Dialect for NHibernate? </p>
| [
{
"answer_id": 22203,
"author": "Ashwin Nanjappa",
"author_id": 1630,
"author_profile": "https://Stackoverflow.com/users/1630",
"pm_score": 0,
"selected": false,
"text": "/lib/\n/usr/lib/\n/usr/share/lib/\n/usr/local/lib/\n"
}
] | 2008/08/20 | [
"https://Stackoverflow.com/questions/18889",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1975/"
] |
18,912 | <p>I know in JavaScript, <em>objects</em> double as hashes, but I have been unable to find a built-in function to get the keys:</p>
<pre><code>var h = {a:'b', c:'d'};
</code></pre>
<p>I want something like</p>
<pre><code>var k = h.keys() ; // k = ['a', 'c'];
</code></pre>
<p>It is simple to write a function myself to iterate over the items and add the keys to an array that I return, but is there a standard cleaner way to do that?</p>
<p>I keep feeling it must be a simple built in function that I missed but I can't find it!</p>
| [
{
"answer_id": 18929,
"author": "danb",
"author_id": 2031,
"author_profile": "https://Stackoverflow.com/users/2031",
"pm_score": 4,
"selected": false,
"text": "var keys = [];\nfor (var k in h)keys.push(k);\n"
},
{
"answer_id": 18930,
"author": "palmsey",
"author_id": 521,... | 2008/08/20 | [
"https://Stackoverflow.com/questions/18912",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/238/"
] |
18,918 | <p>Im testing an ASP.NEt site. When I execute it, it starts the ASP.NET Development Server and opens up a page.</p>
<p>Now I want to test it in the intranet I have. </p>
<ol>
<li><p>Can I use this server or I need to configure IIS in this machine? </p></li>
<li><p>Do I need to configure something for it to work?</p></li>
</ol>
<p>I've changed the localhost to the correct IP and I opened up the firewall.</p>
<p>Thanks</p>
| [
{
"answer_id": 7394935,
"author": "strongriley",
"author_id": 561956,
"author_profile": "https://Stackoverflow.com/users/561956",
"pm_score": 7,
"selected": true,
"text": "java -jar tunnel.jar 80 localhost 1088\n"
}
] | 2008/08/20 | [
"https://Stackoverflow.com/questions/18918",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1013/"
] |
18,920 | <p>When opening a file from your hard drive into your browser, where is the document root? To illustrate, given the following HTML code, if the page is opened from the local machine <code>(file:///)</code> then where should the <code>css</code> file be for the browser to find it?</p>
<pre><code><link href="/temp/test.css" rel="stylesheet" type="text/css" />
</code></pre>
| [
{
"answer_id": 18924,
"author": "Andy",
"author_id": 1993,
"author_profile": "https://Stackoverflow.com/users/1993",
"pm_score": 3,
"selected": true,
"text": "C:/"
},
{
"answer_id": 19338,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflo... | 2008/08/20 | [
"https://Stackoverflow.com/questions/18920",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1858/"
] |
18,932 | <p>I need to remove duplicate rows from a fairly large SQL Server table (i.e. 300,000+ rows).</p>
<p>The rows, of course, will not be perfect duplicates because of the existence of the <code>RowID</code> identity field.</p>
<p><strong>MyTable</strong></p>
<pre><code>RowID int not null identity(1,1) primary key,
Col1 varchar(20) not null,
Col2 varchar(2048) not null,
Col3 tinyint not null
</code></pre>
<p>How can I do this?</p>
| [
{
"answer_id": 18934,
"author": "Jon Galloway",
"author_id": 5,
"author_profile": "https://Stackoverflow.com/users/5",
"pm_score": 7,
"selected": false,
"text": "DELETE dupes\nFROM MyTable dupes, MyTable fullTable\nWHERE dupes.dupField = fullTable.dupField \nAND dupes.secondDupField = fu... | 2008/08/20 | [
"https://Stackoverflow.com/questions/18932",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/357/"
] |
18,943 | <p>Typically in a large network a computer needs to operate behind an authenticated proxy - any connections to the outside world require a username/password which is often the password a user uses to log into email, workstation etc.</p>
<p>This means having to put the network password in the <code>apt.conf</code> file as well as typically the <code>http_proxy, ftp_proxy</code> and <code>https_proxy</code> environment variables defined in <code>~/.profile</code></p>
<p>I realise that with <code>apt.conf</code> that you could set <code>chmod 600</code> (which it isn't by default on Ubuntu/Debian!) but on our system there are people who need root priveleges .</p>
<p>I also realise that it is technically impossible to secure a password from someone who has root access, however I was wondering if there was a way of <i>obscuring</i> the password to prevent accidental discovery. Windows operates with users as admins yet somehow stores network passwords (probably stored deep in the registry obscured in some way) so that in typical use you won't stumble across it in plain text</p>
<p>I only ask since the other day, I entirely by accident discovered somebody elses password in this way when comparing configuration files across systems.</p>
<p>@monjardin - Public key authentication is not an alternative on this network I'm afraid. Plus I doubt it is supported amongst the majority of commandline tools.</p>
<p>@Neall - I don't mind the other users having web access, they can use my credentials to access the web, I just don't want them to happen across my password in plain text.</p>
| [
{
"answer_id": 20160,
"author": "T Percival",
"author_id": 954,
"author_profile": "https://Stackoverflow.com/users/954",
"pm_score": 2,
"selected": false,
"text": "-D -L"
},
{
"answer_id": 26896,
"author": "Jason Day",
"author_id": 737,
"author_profile": "https://Stac... | 2008/08/20 | [
"https://Stackoverflow.com/questions/18943",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/199/"
] |
18,955 | <p>Is there a way to disable entering multi-line entries in a Text Box (i.e., I'd like to stop my users from doing ctrl-enter to get a newline)?</p>
| [
{
"answer_id": 20255,
"author": "BIBD",
"author_id": 685,
"author_profile": "https://Stackoverflow.com/users/685",
"pm_score": 4,
"selected": true,
"text": "Private Sub SingleLineTextBox_ KeyPress(ByRef KeyAscii As Integer)\n If KeyAscii = 10 _\n or KeyAscii = 13 Then\n ... | 2008/08/20 | [
"https://Stackoverflow.com/questions/18955",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/685/"
] |
18,959 | <p>I'm writing an application that on some stage performs low-level disk operations in Linux environment. The app actually consists of 2 parts, one runs on Windows and interacts with a user and another is a linux part that runs from a LiveCD. User makes a choice of Windows drive letters and then a linux part performs actions with corresponding partitions. The problem is finding a match between a Windows drive letter (like C:) and a linux device name (like /dev/sda1). This is my current solution that I rate as ugly:</p>
<ul>
<li><p>store partitions information (i.e. drive letter, number of blocks, drive serial number etc.) in Windows in some pre-defined place (i.e. the root of the system partition).</p></li>
<li><p>read a list of partitions from /proc/partitions. Get only those partitions that has major number for SCSI or IDE hard drives and minor number that identifies them as real partitions and not the whole disks.</p></li>
<li><p>Try to mount each of them with either ntfs or vfat file systems. Check whether the mounted partition contains the information stored by Windows app.</p></li>
<li><p>Upon finding the required information written by the Windows app make the actual match. For each partition found in /proc/partitions acquire drive serial number (via HDIO_GET_IDENTITY syscall), number of blocks (from /proc/partitions) and drive offset (/sys/blocks/drive_path/partition_name/start), compare this to the Windows information and if this matches - store a Windows drive letter along with a linux device name. </p></li>
</ul>
<p>There are a couple of problems in this scheme:</p>
<ul>
<li><p>This is ugly. Writing data in Windows and then reading it in Linux makes testing a nightmare.</p></li>
<li><p>linux device major number is compared only with IDE or SCSI devices. This would probably fail, i.e. on USB or FireWire disks. It's possible to add these types of disks, but limiting the app to only known subset of possible devices seems to be rather bad idea.</p></li>
<li><p>looks like HDIO_GET_IDENTITY works only on IDE and SATA drives.</p></li>
<li><p>/sys/block hack may not work on other than IDE or SATA drives.</p></li>
</ul>
<p>Any ideas on how to improve this schema? Perhaps there is another way to determine windows names without writing all the data in windows app?</p>
<p>P.S. The language of the app is C++. I can't change this.</p>
| [
{
"answer_id": 2194258,
"author": "Bernhard",
"author_id": 265528,
"author_profile": "https://Stackoverflow.com/users/265528",
"pm_score": 0,
"selected": false,
"text": "HANDLE fileHandle = CreateFile(L\"\\\\\\\\.\\\\C:\", // or use syntax \"\\\\?\\Volume{GUID}\" \n ... | 2008/08/20 | [
"https://Stackoverflow.com/questions/18959",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2206/"
] |
18,985 | <p>I am writing a batch script in order to beautify JavaScript code. It needs to work on both <strong>Windows</strong> and <strong>Linux</strong>. </p>
<p>How can I beautify JavaScript code using the command line tools? </p>
| [
{
"answer_id": 27343,
"author": "Alan Storm",
"author_id": 2838,
"author_profile": "https://Stackoverflow.com/users/2838",
"pm_score": 7,
"selected": true,
"text": "java -cp js.jar org.mozilla.javascript.tools.shell.Main name-of-script.js\n //original code \n(function() { ... js_beaut... | 2008/08/20 | [
"https://Stackoverflow.com/questions/18985",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/486/"
] |
19,011 | <p>I am developing a J2ME application that has a large amount of data to store on the device (in the region of 1MB but variable). I can't rely on the file system so I'm stuck the Record Management System (RMS), which allows multiple record stores but each have a limited size. My initial target platform, Blackberry, limits each to 64KB.</p>
<p>I'm wondering if anyone else has had to tackle the problem of storing a large amount of data in the RMS and how they managed it? I'm thinking of having to calculate record sizes and split one data set accross multiple stores if its too large, but that adds a lot of complexity to keep it intact.</p>
<p>There is lots of different types of data being stored but only one set in particular will exceed the 64KB limit.</p>
| [
{
"answer_id": 1660340,
"author": "dhill",
"author_id": 69769,
"author_profile": "https://Stackoverflow.com/users/69769",
"pm_score": 2,
"selected": false,
"text": "List Thread InputStreamReader.skip()"
}
] | 2008/08/20 | [
"https://Stackoverflow.com/questions/19011",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/270/"
] |
19,014 | <p>I want to use Lucene (in particular, Lucene.NET) to search for email address domains.</p>
<p>E.g. I want to search for "@gmail.com" to find all emails sent to a gmail address.</p>
<p>Running a Lucene query for "*@gmail.com" results in an error, asterisks cannot be at the start of queries. Running a query for "@gmail.com" doesn't return any matches, because "foo@gmail.com" is seen as a whole word, and you cannot search for just parts of a word.</p>
<p>How can I do this?</p>
| [
{
"answer_id": 20468,
"author": "Judah Gabriel Himango",
"author_id": 536,
"author_profile": "https://Stackoverflow.com/users/536",
"pm_score": 5,
"selected": true,
"text": "class WhitespaceAndAtSymbolTokenizer : CharTokenizer\n{\n public WhitespaceAndAtSymbolTokenizer(TextReader inpu... | 2008/08/20 | [
"https://Stackoverflow.com/questions/19014",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/536/"
] |
19,030 | <p>I have a bunch of files (TV episodes, although that is fairly arbitrary) that I want to check match a specific naming/organisation scheme..</p>
<p>Currently: I have three arrays of regex, one for valid filenames, one for files missing an episode name, and one for valid paths.</p>
<p>Then, I loop though each valid-filename regex, if it matches, append it to a "valid" dict, if not, do the same with the missing-ep-name regexs, if it matches this I append it to an "invalid" dict with an error code (2:'missing epsiode name'), if it matches neither, it gets added to invalid with the 'malformed name' error code.</p>
<p>The current code can be found <a href="http://github.com/dbr/checktveps/tree/8a6dc68ad61e684c8d8f0ca1dc37a22d1c51aa82/2checkTvEps.py" rel="nofollow noreferrer">here</a></p>
<p>I want to add a rule that checks for the presence of a folder.jpg file in each directory, but to add this would make the code substantially more messy in it's current state.. </p>
<p>How could I write this system in a more expandable way?</p>
<p>The rules it needs to check would be..</p>
<ul>
<li>File is in the format <code>Show Name - [01x23] - Episode Name.avi</code> or <code>Show Name - [01xSpecial02] - Special Name.avi</code> or <code>Show Name - [01xExtra01] - Extra Name.avi</code></li>
<li>If filename is in the format <code>Show Name - [01x23].avi</code> display it a 'missing episode name' section of the output</li>
<li>The path should be in the format <code>Show Name/season 2/the_file.avi</code> (where season 2 should be the correct season number in the filename)</li>
<li>each <code>Show Name/season 1/</code> folder should contain "folder.jpg"</li>
</ul>
<p>.any ideas? While I'm trying to check TV episodes, this concept/code should be able to apply to many things..</p>
<p>The only thought I had was a list of dicts in the format:</p>
<pre><code>checker = [
{
'name':'valid files',
'type':'file',
'function':check_valid(), # runs check_valid() on all files
'status':0 # if it returns True, this is the status the file gets
}
</code></pre>
| [
{
"answer_id": 19389,
"author": "sven",
"author_id": 46,
"author_profile": "https://Stackoverflow.com/users/46",
"pm_score": 0,
"selected": false,
"text": "folder.jpg"
},
{
"answer_id": 21302,
"author": "Joseph Pecoraro",
"author_id": 792,
"author_profile": "https://S... | 2008/08/20 | [
"https://Stackoverflow.com/questions/19030",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/745/"
] |
19,035 | <p>I am working with both <a href="http://activemq.apache.org/ajax.html" rel="nofollow noreferrer">amq.js</a> (ActiveMQ) and <a href="http://code.google.com/apis/maps/documentation/reference.html" rel="nofollow noreferrer">Google Maps</a>. I load my scripts in this order</p>
<pre><code><head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<title>AMQ & Maps Demo</title>
<!-- Stylesheet -->
<link rel="stylesheet" type="text/css" href="style.css"></link>
<!-- Google APIs -->
<script type="text/javascript" src="http://www.google.com/jsapi?key=abcdefg"></script>
<!-- Active MQ -->
<script type="text/javascript" src="amq/amq.js"></script>
<script type="text/javascript">amq.uri='amq';</script>
<!-- Application -->
<script type="text/javascript" src="application.js"></script>
</head>
</code></pre>
<p>However in my application.js it loads Maps fine but I get an error when trying to subscribe to a Topic with AMQ. AMQ depends on prototype which the error console in Firefox says object is not defined. I think I have a problem with using the amq object before the script is finished loading. <strong>Is there a way to make sure both scripts load before I use them in my application.js?</strong> </p>
<p>Google has this nice function call <code>google.setOnLoadCallback(initialize);</code> which works great. I'm not sure amq.js has something like this.</p>
| [
{
"answer_id": 19067,
"author": "maxsilver",
"author_id": 1477,
"author_profile": "https://Stackoverflow.com/users/1477",
"pm_score": 2,
"selected": false,
"text": "application.js $(document).ready"
},
{
"answer_id": 19069,
"author": "danb",
"author_id": 2031,
"author... | 2008/08/20 | [
"https://Stackoverflow.com/questions/19035",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1992/"
] |
19,058 | <p>Example:</p>
<pre><code>select ename from emp where hiredate = todate('01/05/81','dd/mm/yy')
</code></pre>
<p>and </p>
<pre><code>select ename from emp where hiredate = todate('01/05/81','dd/mm/rr')
</code></pre>
<p>return different results</p>
| [
{
"answer_id": 19202,
"author": "mauriciopastrana",
"author_id": 547,
"author_profile": "https://Stackoverflow.com/users/547",
"pm_score": 3,
"selected": false,
"text": "USING\nENTERED\nSTORED\nSELECT of date column\n\n\nYY\n22-FEB-01\n22-FEB-1901\n22-FEB-01\n\n\nYYYY\n22-FEB-01\n22-FEB-... | 2008/08/20 | [
"https://Stackoverflow.com/questions/19058",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1782/"
] |
19,089 | <p>I have a view that has a list of jobs in it, with data like who they're assigned to and the stage they are in. I need to write a stored procedure that returns how many jobs each person has at each stage.</p>
<p>So far I have this (simplified):</p>
<pre><code>DECLARE @ResultTable table
(
StaffName nvarchar(100),
Stage1Count int,
Stage2Count int
)
INSERT INTO @ResultTable (StaffName, Stage1Count)
SELECT StaffName, COUNT(*) FROM ViewJob
WHERE InStage1 = 1
GROUP BY StaffName
INSERT INTO @ResultTable (StaffName, Stage2Count)
SELECT StaffName, COUNT(*) FROM ViewJob
WHERE InStage2 = 1
GROUP BY StaffName
</code></pre>
<p>The problem with that is that the rows don't combine. So if a staff member has jobs in stage1 and stage2 there's two rows in @ResultTable. What I would really like to do is to update the row if one exists for the staff member and insert a new row if one doesn't exist.</p>
<p>Does anyone know how to do this, or can suggest a different approach?
I would really like to avoid using cursors to iterate on the list of users (but that's my fall back option).</p>
<p>I'm using SQL Server 2005.</p>
<p><strong>Edit: @Lee:</strong> Unfortunately the InStage1 = 1 was a simplification. It's really more like WHERE DateStarted IS NOT NULL and DateFinished IS NULL.</p>
<p><strong>Edit: @BCS:</strong> I like the idea of doing an insert of all the staff first so I just have to do an update every time. But I'm struggling to get those UPDATE statements correct.</p>
| [
{
"answer_id": 19098,
"author": "Ryan Farley",
"author_id": 1627,
"author_profile": "https://Stackoverflow.com/users/1627",
"pm_score": 2,
"selected": false,
"text": "IF (EXISTS (SELECT * FROM MyTable WHERE StaffName = @StaffName))\nbegin\n UPDATE MyTable SET ... WHERE StaffName = @St... | 2008/08/20 | [
"https://Stackoverflow.com/questions/19089",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/233/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.