qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
155,544
<p>I need to create a unique ID for a given location, and the location's ID must be sequential. So its basically like a primary key, except that it is also tied to the locationID. So 3 different locations will all have ID's like 1,2,3,4,5,...,n</p> <p>What is the best way to do this? I also need a safe way of getting the nextID for a given location, I'm guessing I can just put a transaction on the stored procedure that gets the next ID?</p>
[ { "answer_id": 155557, "author": "Chris Marasti-Georg", "author_id": 96, "author_profile": "https://Stackoverflow.com/users/96", "pm_score": 1, "selected": false, "text": "transaction {\n id = getId\n}\n\n... other processing\n\ntransaction {\n createRowWithNewId\n}\n" }, { "...
2008/09/30
[ "https://Stackoverflow.com/questions/155544", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1368/" ]
155,560
<p>I want a function like GetCurrentThread which returns a TThread object of the current executing thread. I know there is a Win32 API call GetCurrentThread, but it returns the thread Id. If there is a possibility to get TThread object from that ID that's also fine.</p>
[ { "answer_id": 155773, "author": "Hugh Allen", "author_id": 15069, "author_profile": "https://Stackoverflow.com/users/15069", "pm_score": 5, "selected": false, "text": "if Windows.GetCurrentThreadId() = System.MainThreadID then\n// ...\n" } ]
2008/09/30
[ "https://Stackoverflow.com/questions/155560", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
155,566
<p>Please provide tips for effectively using git with svn. What are your "best practices"?</p>
[ { "answer_id": 155577, "author": "1800 INFORMATION", "author_id": 3146, "author_profile": "https://Stackoverflow.com/users/3146", "pm_score": 2, "selected": false, "text": "git svn rebase" }, { "answer_id": 155643, "author": "andy", "author_id": 21482, "author_profile...
2008/09/30
[ "https://Stackoverflow.com/questions/155566", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3146/" ]
155,584
<p>I need a way to allow each letter of a word to rotate through 3 different colors. I know of some not so clean ways I can do this with asp.NET, but I'm wondering if there might be a cleaner CSS/JavaScript solution that is more search engine friendly.</p> <p>The designer is including <a href="http://stlartworks.efficionconsulting.com/Portals/6/Skins/ArtWorks/img/ProgramsHeading.png" rel="noreferrer">a file like this</a> for each page. I'd rather not have to manually generate an image for every page as that makes it hard for the non-technical site editors to add pages and change page names.</p>
[ { "answer_id": 155595, "author": "Brendan Kidwell", "author_id": 13958, "author_profile": "https://Stackoverflow.com/users/13958", "pm_score": 3, "selected": false, "text": "// This server-side code example is in JavaScript because that's\n// what I know best.\nvar words = split(message,...
2008/09/30
[ "https://Stackoverflow.com/questions/155584", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4318/" ]
155,586
<p>We use the DesignSurface and all that good IDesignerHost goodness in our own designer. The designed forms are then persisted in our own bespoke format and all that works great. WE also want to export the forms to a text-based format (which we've done as it isn't that difficult).</p> <p>However, we also want to import that text back into a document for the designer which involves getting the designer code back into a CodeCompileUnit. Unfortunately, the Parse method is not implemented (for, no doubt, good reasons). Is there an alternative? We don't want to use anything that wouldn't exist on a standard .NET installation (like .NET libraries installed with Visual Studio).</p> <p>My current idea is to compile the imported text and then instantiate the form and copy its properties and controls over to the design surface object, and just capture the new CodeCompileUnit, but I was hoping there was a better way. Thanks.</p> <hr> <p>UPDATE: I though some might be interested in our progress. So far, not so good. A brief overview of what I've discovered is that the Parse method was not implemented because it was deemed too difficult, open source parsers exist that do the work but they're not complete and therefore aren't guaranteed to work in all cases (NRefactory is one of those from the SharpDevelop project, I believe), and the copying of controls across from an instance to the designer isn't working as yet. I believe this is because although the controls are getting added to the form instance that the designer surface wraps, the designer surface is not aware of their inclusion. Our next attempt is to mimic cut/paste to see if that solves it. Obviously, this is a huge nasty workaround, but we need it working so we'll take the hit and keep an eye out for alternatives.</p>
[ { "answer_id": 155595, "author": "Brendan Kidwell", "author_id": 13958, "author_profile": "https://Stackoverflow.com/users/13958", "pm_score": 3, "selected": false, "text": "// This server-side code example is in JavaScript because that's\n// what I know best.\nvar words = split(message,...
2008/09/30
[ "https://Stackoverflow.com/questions/155586", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23234/" ]
155,593
<p>Is there a way to determine the number of users that have active sessions in an ASP.NET application? I have an admin/tools page in a particular application, and I would like to display info regarding all open sessions, such as the number of sessions, and perhaps the requesting machines' addresses, or other credential information for each user.</p>
[ { "answer_id": 659879, "author": "Eduardo Molteni", "author_id": 2385, "author_profile": "https://Stackoverflow.com/users/2385", "pm_score": 4, "selected": false, "text": "void Application_Start(object sender, EventArgs e)\n{\n // Code that runs on application startup\n Application...
2008/09/30
[ "https://Stackoverflow.com/questions/155593", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23886/" ]
155,609
<p>Can someone provide a simple explanation of <strong>methods</strong> vs. <strong>functions</strong> in OOP context?</p>
[ { "answer_id": 155648, "author": "Statement", "author_id": 2166173, "author_profile": "https://Stackoverflow.com/users/2166173", "pm_score": 3, "selected": false, "text": "class Example\n{\n public int data = 0; // Each instance of Example holds its internal data. This is a \"field\", ...
2008/09/30
[ "https://Stackoverflow.com/questions/155609", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23973/" ]
155,610
<p>I have a trivial console application in .NET. It's just a test part of a larger application. I'd like to specify the "exit code" of my console application. How do I do this?</p>
[ { "answer_id": 155611, "author": "palehorse", "author_id": 312, "author_profile": "https://Stackoverflow.com/users/312", "pm_score": 5, "selected": false, "text": "int code = 2;\nEnvironment.Exit( code );\n" }, { "answer_id": 155613, "author": "albertein", "author_id": 23...
2008/09/30
[ "https://Stackoverflow.com/questions/155610", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22471/" ]
155,615
<p>I understand that server-side validation is an absolute must to prevent malicious users (or simply users who choose to disable javascript) from bypassing client-side validation. But that's mainly to protect your application, not to provide value for those who are running browsers with javascript disabled. Is it reasonable to assume visitors have javascript enabled and simply have an unusable site for those who don't?</p>
[ { "answer_id": 157042, "author": "James", "author_id": 21677, "author_profile": "https://Stackoverflow.com/users/21677", "pm_score": 2, "selected": false, "text": "<noscript>" }, { "answer_id": 4316596, "author": "Master Morality", "author_id": 304299, "author_profile...
2008/09/30
[ "https://Stackoverflow.com/questions/155615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1574/" ]
155,649
<p>What's the best way to add the coordinates of a circle to an array in JavaScript? So far I've only been able to do a half circle, but I need a formula that returns the whole circle to two different arrays: <code>xValues</code> and <code>yValues</code>. (I'm trying to get the coordinates so I can animate an object along a path.)</p> <p><strong>Here's what I have so far:</strong></p> <pre><code>circle: function(radius, steps, centerX, centerY){ var xValues = [centerX]; var yValues = [centerY]; for (var i = 1; i &lt; steps; i++) { xValues[i] = (centerX + radius * Math.cos(Math.PI * i / steps-Math.PI/2)); yValues[i] = (centerY + radius * Math.sin(Math.PI * i / steps-Math.PI/2)); } } </code></pre>
[ { "answer_id": 155653, "author": "shoosh", "author_id": 9611, "author_profile": "https://Stackoverflow.com/users/9611", "pm_score": 1, "selected": false, "text": "+ sin(...)" }, { "answer_id": 155662, "author": "dlamblin", "author_id": 459, "author_profile": "https://...
2008/09/30
[ "https://Stackoverflow.com/questions/155649", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13281/" ]
155,669
<p>I have Flex based consumer <a href="http://www.rollingrazor.com" rel="nofollow noreferrer">website</a> where I would like to change various look and feel type settings based on random and other criteria, and then track these through to what results in the most sales. </p> <p>For instance I might completely switch out the homepage, show different things depending upon where people come from. I might show or hide certain features, or change certain text. The things i might change are as yet undefined and will likely become quite complicated.</p> <p>I want to design the most flexible database schema but it must be efficient and easy to search. Currently I have a 'SiteVisit' table which contains information about each distinct visitor.</p> <p>I want to find the right balance between a single table with columns for each setting, and a table containing just key value pairs.</p> <p>Any suggestions? </p>
[ { "answer_id": 627904, "author": "David Pokluda", "author_id": 223, "author_profile": "https://Stackoverflow.com/users/223", "pm_score": 2, "selected": false, "text": "+----------------\n| User\n+----------------\n| UserId (PK)\n| ...\n+----------------\n" } ]
2008/10/01
[ "https://Stackoverflow.com/questions/155669", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16940/" ]
155,670
<p>I want to invert a 4x4 matrix. My numbers are stored in fixed-point format (1.15.16 to be exact).</p> <p>With floating-point arithmetic I usually just build the adjoint matrix and divide by the determinant (e.g. brute force the solution). That worked for me so far, but when dealing with fixed point numbers I get an unacceptable precision loss due to all of the multiplications used. </p> <p>Note: In fixed point arithmetic I always throw away some of the least significant bits of immediate results.</p> <p>So - What's the most numerical stable way to invert a matrix? I don't mind much about the performance, but simply going to floating-point would be to slow on my target architecture.</p>
[ { "answer_id": 155705, "author": "Adrian", "author_id": 23624, "author_profile": "https://Stackoverflow.com/users/23624", "pm_score": 4, "selected": false, "text": "[ux vx wx tx]\n[uy vy wy ty]\n[uz vz wz tz]\n[ 0 0 0 1]\n" } ]
2008/10/01
[ "https://Stackoverflow.com/questions/155670", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15955/" ]
155,681
<p>I have saved input from a textarea element to a TEXT column in MySQL. I'm using PHP to pull that data out of the database and want to display it in a p element while still showing the whitespace that the user entered (e.g. multiple spaces and newlines). I've tried a pre tag but it doesn't obey the width set in the containing div element. Other than creating a PHP function to convert spaces to &amp;nbsp and new lines to br tags, what are my options? I'd prefer a clean HTML/CSS solution, but any input is welcome! Thanks!</p>
[ { "answer_id": 155698, "author": "Vincent McNabb", "author_id": 16299, "author_profile": "https://Stackoverflow.com/users/16299", "pm_score": 5, "selected": true, "text": "pre" } ]
2008/10/01
[ "https://Stackoverflow.com/questions/155681", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23976/" ]
155,685
<p>I need to replace the contents of a node in an XElement hierarchy when the element name and all the attribute names and values match an input element. (If there is no match, the new element can be added.)</p> <p>For example, if my data looks like this:</p> <pre><code>&lt;root&gt; &lt;thing1 a1="a" a2="b"&gt;one&lt;/thing1&gt; &lt;thing2 a1="a" a2="a"&gt;two&lt;/thing2&gt; &lt;thing2 a1="a" a3="b"&gt;three&lt;/thing2&gt; &lt;thing2 a1="a"&gt;four&lt;/thing2&gt; &lt;thing2 a1="a" a2="b"&gt;five&lt;/thing2&gt; &lt;root&gt; </code></pre> <p>I want to find the last element when I call a method with this input:</p> <pre><code>&lt;thing2 a1="a" a2="b"&gt;new value&lt;/thing2&gt; </code></pre> <p>The method should have no hard-coded element or attribute names - it simply matches the input to the data.</p>
[ { "answer_id": 155787, "author": "Mark Cidade", "author_id": 1659, "author_profile": "https://Stackoverflow.com/users/1659", "pm_score": 4, "selected": true, "text": "public static void ReplaceOrAdd(this XElement source, XElement node)\n{\n var q = from x in source.Elements()\n ...
2008/10/01
[ "https://Stackoverflow.com/questions/155685", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14842/" ]
155,706
<p>I have been looking at a few options for enabling localization and internationalization of a dynamic php application. There appears to be a variety of tools available such as gettext and Yahoo's R3 and I am interested in hearing from both developers and translators about which tools are good to use and what functionality is important in easing the task of implementation and translation.</p>
[ { "answer_id": 426915, "author": "Gabriel Sosa", "author_id": 31039, "author_profile": "https://Stackoverflow.com/users/31039", "pm_score": 1, "selected": false, "text": "<?php\ninclude('lang/en.php');\ninclude('lang/en_us.php'); // this file overrides few keys from the last one.\n?>\n" ...
2008/10/01
[ "https://Stackoverflow.com/questions/155706", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11979/" ]
155,712
<p>Here's my problem - I have some code like this:</p> <pre><code>&lt;mx:Canvas width="300" height="300"&gt; &lt;mx:Button x="800" /&gt; &lt;/mx:Canvas&gt; </code></pre> <p>So the problem is that the Button inside the canvas has an x property way in excess of the Canvas's width - since it's a child of the Canvas, the Canvas masks it and creates some scrollbars for me to scroll over to the button.</p> <p>What I'd like is to display the button - 800 pixels to the left of the Canvas without the scrollbars while still leaving the button as a child of the Canvas. How do I do that?</p>
[ { "answer_id": 155817, "author": "Paul Mignard", "author_id": 3435, "author_profile": "https://Stackoverflow.com/users/3435", "pm_score": 4, "selected": true, "text": "<mx:Canvas width=\"300\" height=\"300\" clipContent=\"false\" >\n <mx:Button x=\"800\" />\n</mx:Canvas>\n" } ]
2008/10/01
[ "https://Stackoverflow.com/questions/155712", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3435/" ]
155,719
<p>Internationalizing web apps always seems to be a chore. No matter how much you plan ahead for pluggable languages, there's always issues with encoding, funky phrasing that doesn't fit your templates, and other problems.</p> <p>I think it would be useful to get the SO community's input for a set of things that programmers should look out for when deciding to internationalize their web apps.</p>
[ { "answer_id": 157833, "author": "Kip", "author_id": 18511, "author_profile": "https://Stackoverflow.com/users/18511", "pm_score": 4, "selected": false, "text": "Click here\n" } ]
2008/10/01
[ "https://Stackoverflow.com/questions/155719", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14032/" ]
155,721
<p>Please post a working source code example (or link) of how to search string in another process memory and getting offset of match if found. The similar way its done in game cheating utils which search for values in game memory using ReadProcessMemory.</p>
[ { "answer_id": 157833, "author": "Kip", "author_id": 18511, "author_profile": "https://Stackoverflow.com/users/18511", "pm_score": 4, "selected": false, "text": "Click here\n" } ]
2008/10/01
[ "https://Stackoverflow.com/questions/155721", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21582/" ]
155,739
<p>I have a requirement to implement an "Unsaved Changes" prompt in an ASP .Net application. If a user modifies controls on a web form, and attempts to navigate away before saving, a prompt should appear warning them that they have unsaved changes, and give them the option to cancel and stay on the current page. The prompt should not display if the user hasn't touched any of the controls.</p> <p>Ideally I'd like to implement this in JavaScript, but before I go down the path of rolling my own code, are there any existing frameworks or recommended design patterns for achieving this? Ideally I'd like something that can easily be reused across multiple pages with minimal changes.</p>
[ { "answer_id": 155760, "author": "Wayne", "author_id": 8236, "author_profile": "https://Stackoverflow.com/users/8236", "pm_score": 4, "selected": false, "text": "<script language=\"javascript\">\n var isDirty = false;\n\n function setDirty() {\n isDirty = true;\n }\n\n ...
2008/10/01
[ "https://Stackoverflow.com/questions/155739", "https://Stackoverflow.com", "https://Stackoverflow.com/users/637/" ]
155,740
<p>I am working on an application that will sport a web-based point of sale interface.</p> <p>The point of sale PC (I am not sure as of now whether it will run on Linux or Windows) must have a fiscal printer attached to it, but like any web app, it is the server which processes all stuff. Both server and PoS machines are on the same LAN.</p> <p>I must send the sale data in real time, and via the fiscal printer which uses the serial port, so printing a PDF or even a web page is not an option.</p> <p>I've been told I could have a little app listening on web services on the client, which in turn talks to the printer instead of the server or the browser, but don't have a clue how to do it. Also, I'll most likely need to listen to any printer feedback (coupon number, for instance, which is generated by the printer) and hand it back to the server.</p> <p>Any ideas?</p>
[ { "answer_id": 155782, "author": "OscarRyz", "author_id": 20654, "author_profile": "https://Stackoverflow.com/users/20654", "pm_score": 1, "selected": false, "text": "DocFlavor flavor = DocFlavor.INPUT_STREAM.POSTSCRIPT;\nPrintRequestAttributeSet aset = new HashPrintRequestHashAttributeS...
2008/10/01
[ "https://Stackoverflow.com/questions/155740", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22116/" ]
155,751
<p>In my php web app, suppose I want to go the extra mile and in addition to going gang-busters and being anal-retentive about sanitizing my inputs, I also want to ensure that no JavaScript is being output in strings I am inserting into html templates. </p> <p>Is there a standard way to make sure I don't put JavaScript in the generated html content?</p>
[ { "answer_id": 155768, "author": "dlamblin", "author_id": 459, "author_profile": "https://Stackoverflow.com/users/459", "pm_score": 0, "selected": false, "text": "<img src=\"${path}\">" }, { "answer_id": 158346, "author": "Kent Brewster", "author_id": 1151280, "author...
2008/10/01
[ "https://Stackoverflow.com/questions/155751", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8123/" ]
155,780
<p>What is SafeHandle? how does it differ from IntPtr? When should I use one? What are its advantages?</p>
[ { "answer_id": 27453342, "author": "Mike Ness", "author_id": 4286419, "author_profile": "https://Stackoverflow.com/users/4286419", "pm_score": 4, "selected": false, "text": "static class Examples\n{\n static void Example1_SafeUserToken()\n {\n const string user = \"SomeLocal...
2008/10/01
[ "https://Stackoverflow.com/questions/155780", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7418/" ]
155,792
<p>I'm working on a method that accepts an expression tree as a parameter, along with a type (or instance) of a class.</p> <p>The basic idea is that this method will add certain things to a collection that will be used for validation.</p> <pre><code>public interface ITestInterface { //Specify stuff here. } private static void DoSomething&lt;T&gt;(Expression&lt;Func&lt;T, object&gt;&gt; expression, params IMyInterface[] rule) { // Stuff is done here. } </code></pre> <p>The method is called as follows:</p> <pre><code>class TestClass { public int MyProperty { get; set; } } class OtherTestClass : ITestInterface { // Blah Blah Blah. } static void Main(string[] args) { DoSomething&lt;TestClass&gt;(t =&gt; t.MyProperty, new OtherTestClass()); } </code></pre> <p>I'm doing it this way because I'd like for the property names that are passed in to be strong typed.</p> <p>A couple of things I'm struggling with..</p> <ol> <li>Within DoSomething, I'd like to get a <code>PropertyInfo</code> type (from the body passed in) of T and add it to a collection along with rule[]. Currently, I'm thinking about using expression.Body and removing [propertyname] from &quot;Convert.([propertyname])&quot; and using reflection to get what I need. This seems cumbersome and wrong. Is there a better way?</li> <li>Is this a specific pattern I'm using?</li> <li>Lastly, any suggestions or clarifications as to my misunderstanding of what I'm doing are appreciated and / or resources or good info on C# expression trees are appreciated as well.</li> </ol> <p>Thanks!</p> <p>Ian</p> <h1>Edit:</h1> <p>An example of what <code>expression.Body.ToString()</code> returns within the DoSomething method is a string that contains &quot;Convert(t.MyProperty)&quot; if called from the example above.</p> <p>I do need it to be strongly typed, so it will not compile if I change a property name.</p> <p>Thanks for the suggestions!</p>
[ { "answer_id": 155845, "author": "Jason Jackson", "author_id": 13103, "author_profile": "https://Stackoverflow.com/users/13103", "pm_score": 2, "selected": false, "text": "DoSomething(\"MyProperty\", new OtherClass());\n" } ]
2008/10/01
[ "https://Stackoverflow.com/questions/155792", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10853/" ]
155,797
<p>ADO.NET has the notorious DataRow class which you cannot instantiate using new. This is a problem now that I find a need to mock it using Rhino Mocks. </p> <p>Does anyone have any ideas how I could get around this problem?</p>
[ { "answer_id": 155813, "author": "Josh", "author_id": 11702, "author_profile": "https://Stackoverflow.com/users/11702", "pm_score": 5, "selected": true, "text": "SetupResult.For(someMockClass.GetDataRow(input)).Return(GetReturnRow());\n\npublic DataRow GetReturnRow()\n{\n DataTable ta...
2008/10/01
[ "https://Stackoverflow.com/questions/155797", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5056/" ]
155,810
<p>When you double click on a class (in 'solution explorer')... if that class happens to be an .asmx.cs webservice... then you get this...</p> <blockquote> <p>To add components to your class, drag them from the Toolbox and use the Properties window to set their properties. To create methods and events for your class, click here to switch to code view.</p> </blockquote> <p>...it's a 'visual design surface' for webservices.</p> <p>(Who actually uses that surface to write webservices?)</p> <p>So what I want to know, how do I configure visual studio to never show me that design view?</p> <p>Or at least, to show me the code view by default?</p>
[ { "answer_id": 3196200, "author": "Bob Sidie", "author_id": 385681, "author_profile": "https://Stackoverflow.com/users/385681", "pm_score": 1, "selected": false, "text": "<System.ComponentModel.DesignerCategory(\"\")>\n" }, { "answer_id": 4246213, "author": "Steinar Herland",...
2008/10/01
[ "https://Stackoverflow.com/questions/155810", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49/" ]
155,829
<p>I am getting this error but only very occasionally. 99.9% of the time it works fine:</p> <p>Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.</p> <p>Does anyone have any idea on what the cause could be? I only use that datatable for viewing and not updating so is it possible to easily turn off all constraints somehow?</p>
[ { "answer_id": 38776066, "author": "Nick", "author_id": 1931573, "author_profile": "https://Stackoverflow.com/users/1931573", "pm_score": 0, "selected": false, "text": "varchar(100)" } ]
2008/10/01
[ "https://Stackoverflow.com/questions/155829", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10102/" ]
155,848
<p>I need to create an access (mdb) database without using the ADOX interop assembly. </p> <p>How can this be done?</p>
[ { "answer_id": 155851, "author": "Sam Saffron", "author_id": 17174, "author_profile": "https://Stackoverflow.com/users/17174", "pm_score": 5, "selected": true, "text": "if (!File.Exists(DB_FILENAME))\n{\n var cnnStr = \"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\" + DB_FILENAME;\n\...
2008/10/01
[ "https://Stackoverflow.com/questions/155848", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17174/" ]
155,852
<p>I have created a non-visual component in C# which is designed as a placeholder for meta-data on a form.<br> The component has a property which is a collection of custom objects, this object is marked as Serializable and implements the GetObjectData for serilizing and public constuctor for deserilizing.<br></p> <p>In the resx file for the form it will generate binary data for storing the collection, however any time I make a change to the serialized class I get designer errors and need to delete the data manually out of the resx file and then recreate this data.</p> <p>I have tried changing the constuctor to have a try / catch block around each property in the class</p> <pre><code>try { _Name = info.GetString("Name"); } catch (SerializationException) { this._Name = string.Empty; } </code></pre> <p>but it still crashes. The last error I got was that I had to implement IConvertible.<br></p> <p>I would prefer to use xml serialization because I can at least see it, is this possible for use by the designer?<br></p> <p>Is there a way to make the serialization more stable and less resistant to changes?</p> <p>Edit:<br> More information...better description maybe<br> I have a class which inherits from Component, it has one property which is a collection of Rules. The RulesCollection seems to have to be marked as Serializable, otherwise it does not retain its members.<br> </p> <p>The Rules class is also a Component with the attribute DesignTimeVisible(false) to stop it showing in the component tray, this clas is not marked Serializable.<br></p> <p>Having the collection marked as Serializable generates binary data in the resx file (not ideal) and the IDE reports that the Rules class is not Serializable.<br></p> <p>I think this issue is getting beyond a simple question. So I will probably close it shortly.<br> If anyone has any links to something similar that would help a lot.</p>
[ { "answer_id": 199307, "author": "benPearce", "author_id": 4490, "author_profile": "https://Stackoverflow.com/users/4490", "pm_score": 3, "selected": true, "text": "private List<Rule> _Rules;\n[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]\npublic List<Rule> R...
2008/10/01
[ "https://Stackoverflow.com/questions/155852", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4490/" ]
155,864
<p>I have a controller with an action method as follows:</p> <pre><code>public class InventoryController : Controller { public ActionResult ViewStockNext(int firstItem) { // Do some stuff } } </code></pre> <p>And when I run it I get an error stating:</p> <blockquote> <p>The parameters dictionary does not contain a valid value of type 'System.Int32' for parameter 'firstItem'. To make a parameter optional its type should either be a reference type or a Nullable type.</p> </blockquote> <p>I had it working at one point and I decided to try the function without parameters. Finding out that the controller was not persistant I put the parameter back in, now it refuses to recognise the parameter when I call the method.</p> <p>I'm using this url syntax to call the action:</p> <pre><code>http://localhost:2316/Inventory/ViewStockNext/11 </code></pre> <p>Any ideas why I would get this error and what I need to do to fix it? </p> <p>I've tried adding another method that takes an integer to the class it it also fails with the same reason. I've tried adding one that takes a string, and the string is set to null. I've tried adding one without parameters and that works fine, but of course it won't suit my needs.</p>
[ { "answer_id": 155895, "author": "Jarrett Meyer", "author_id": 5834, "author_profile": "https://Stackoverflow.com/users/5834", "pm_score": 8, "selected": true, "text": "{controller}/{action}/{firstItem}" }, { "answer_id": 155902, "author": "Matt Mitchell", "author_id": 36...
2008/10/01
[ "https://Stackoverflow.com/questions/155864", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11908/" ]
155,869
<p>The Interwebs are no help on this one. We're encoding data in ColdFusion using <code>serializeJSON</code> and trying to decode it in PHP using <code>json_decode</code>. Most of the time, this is working fine, but in some cases, <code>json_decode</code> returns <code>NULL</code>. We've looked for the obvious culprits, but <code>serializeJSON</code> seems to be formatting things as expected. What else could be the problem?</p> <p>UPDATE: A couple of people (wisely) asked me to post the output that is causing the problem. I would, except we just discovered that the result set is all of our data (listing information for 2300+ rental properties for a total of 565,135 ASCII characters)! That could be a problem, though I didn't see anything in the PHP docs about a max size for the string. What would be the limiting factor there? RAM?</p> <p>UPDATE II: It looks like the problem was that a couple of our users had copied and pasted Microsoft Word text with "smart" quotes. Those pesky users...</p>
[ { "answer_id": 171521, "author": "Ates Goral", "author_id": 23501, "author_profile": "https://Stackoverflow.com/users/23501", "pm_score": 2, "selected": false, "text": "json_decode" }, { "answer_id": 1184143, "author": "Stewart Robinson", "author_id": 47424, "author_p...
2008/10/01
[ "https://Stackoverflow.com/questions/155869", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11577/" ]
155,884
<p>What is a realistic use for VB.Net's MyClass keyword?</p> <p>I understand the <a href="http://msdn.microsoft.com/en-us/library/b3b35kyk.aspx" rel="noreferrer">technical usage of MyClass</a>; I don't understand the practical usage of it in the real world.</p> <p>Using MyClass only makes sense if you have any virtual (overridable) members. But it also means that you want to ignore the overridden implementations in sub classes. It appears to be self-contradicting.</p> <p>I can think of some contrived examples, but they are simply bad design rather than practical usage.</p>
[ { "answer_id": 169787, "author": "Jonathan Allen", "author_id": 5274, "author_profile": "https://Stackoverflow.com/users/5274", "pm_score": -1, "selected": false, "text": "Public Sub New(ByVal accountKey As Integer)\n MyClass.New(accountKey, Nothing)\nEnd Sub\n\nPublic Sub New(ByVal a...
2008/10/01
[ "https://Stackoverflow.com/questions/155884", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6375/" ]
155,891
<p>Can't seem to rename an existing Verity collection in ColdFusion without deleting, recreating, and rebuilding the collection. Problem is, I have some very large collections I'd rather not have to delete and rebuild from scratch. Any one have a handy trick for this conundrum?</p>
[ { "answer_id": 158948, "author": "Ben Doom", "author_id": 12267, "author_profile": "https://Stackoverflow.com/users/12267", "pm_score": 2, "selected": false, "text": "<cfcollection action=\"map\" ...>\n" }, { "answer_id": 571061, "author": "crb", "author_id": 51691, "...
2008/10/01
[ "https://Stackoverflow.com/questions/155891", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10750/" ]
155,908
<p>I have defined tomcat:catalina:5.5.23 as a dependency to the cargo plugin, however I still get the following exception:</p> <pre><code>java.lang.ClassNotFoundException: org.apache.catalina.Connector at java.net.URLClassLoader$1.run(URLClassLoader.java:200) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:316) at org.codehaus.classworlds.RealmClassLoader.loadClassDirect(RealmClassLoader.java:195) at org.codehaus.classworlds.DefaultClassRealm.loadClass(DefaultClassRealm.java:255) at org.codehaus.classworlds.DefaultClassRealm.loadClass(DefaultClassRealm.java:274) at org.codehaus.classworlds.RealmClassLoader.loadClass(RealmClassLoader.java:214) at java.lang.ClassLoader.loadClass(ClassLoader.java:251) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:374) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:247) at org.codehaus.cargo.container.tomcat.internal.Tomcat5xEmbedded.preloadEmbedded(Tomcat5xEmbedded.java:232) </code></pre> <p>It looks like the RealmClassLoader is not finding the class, possibly due to java.security.AccessController.doPrivileged denying access. </p> <p>Has anyone got tomcat to run in embedded mode from within maven?</p>
[ { "answer_id": 169029, "author": "Hugo", "author_id": 972, "author_profile": "https://Stackoverflow.com/users/972", "pm_score": 1, "selected": false, "text": "mvn jetty6:run\n" }, { "answer_id": 640436, "author": "Nathan Feger", "author_id": 8563, "author_profile": "h...
2008/10/01
[ "https://Stackoverflow.com/questions/155908", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2767300/" ]
155,911
<p>During software development, there may be bugs in the codebase which are known issues. These bugs will cause the regression/unit tests to fail, if the tests have been written well.</p> <p>There is constant debate in our teams about how failing tests should be managed:</p> <ol> <li><p>Comment out failing test cases with a REVISIT or TODO comment.</p> <ul> <li><strong>Advantage</strong>: We will always know when a <em>new</em> defect has been introduced, and not one we are already aware of.</li> <li><strong>Disadvantage</strong>: May forget to REVISIT the commented-out test case, meaning that the defect could slip through the cracks.</li> </ul></li> <li><p>Leave the test cases failing.</p> <ul> <li><strong>Advantage</strong>: Will not forget to fix the defects, as the script failures will constantly reminding you that a defect is present.</li> <li><strong>Disadvantage</strong>: Difficult to detect when a <em>new</em> defect is introduced, due to failure noise.</li> </ul></li> </ol> <p>I'd like to explore what the best practices are in this regard. Personally, I think a tri-state solution is the best for determining whether a script is passing. For example when you run a script, you could see the following:</p> <ul> <li>Percentage passed: 75%</li> <li>Percentage failed (expected): 20%</li> <li>Percentage failed (unexpected): 5%</li> </ul> <p>You would basically mark any test cases which you <em>expect</em> to fail (due to some defect) with some metadata. This ensures you still see the failure result at the end of the test, but immediately know if there is a <em>new</em> failure which you weren't expecting. This appears to take the best parts of the 2 proposals above.</p> <p>Does anyone have any best practices for managing this?</p>
[ { "answer_id": 155942, "author": "Mark", "author_id": 4405, "author_profile": "https://Stackoverflow.com/users/4405", "pm_score": 4, "selected": true, "text": "// TODO: fix test case\n" }, { "answer_id": 155971, "author": "Georgi", "author_id": 13209, "author_profile...
2008/10/01
[ "https://Stackoverflow.com/questions/155911", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22489/" ]
155,912
<p>Calling <code>Validate()</code> on an <strong>XmlDocument</strong> requires passing in a <code>ValidationEventHandler</code> delegate. That event function gets a <code>ValidationEventArgs</code> parameter which in turn has an <code>Exception</code> property of the type <code>XmlSchemaException</code>. Whew!</p> <p>My current code looks like this:</p> <pre><code>ValidationEventHandler onValidationError = delegate(object sender, ValidationEventArgs args) { throw(args.Exception); } doc.Validate(onValidationError); </code></pre> <p>Is there some other method I'm overlooking which simply <em>throws</em> the <code>XmlSchemaException</code> if validation fails (warnings ignored entirely)?</p>
[ { "answer_id": 57436064, "author": "Adam Porad", "author_id": 21353, "author_profile": "https://Stackoverflow.com/users/21353", "pm_score": 0, "selected": false, "text": "null" } ]
2008/10/01
[ "https://Stackoverflow.com/questions/155912", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9642/" ]
155,913
<p>The project I'm working is using n-tier architecture. Our layers are as follows:</p> <ul> <li>Data Access</li> <li>Business Logic</li> <li>Business Entities</li> <li>Presentation</li> </ul> <p>The Business Logic calls down into the data access layer, and the Presentation layer calls down into the Business Logic layer, and the Business entities are referenced by all of them. </p> <p>Our business entities essentially match our data model 1-1. For every table, we have a class. Initially when the framework was designed, there was no consideration for managing master-detail or child-parent relationships. So all of the Business logic, data access, and business entities, only referenced a single table in the database. Once we started developing the application it quickly became apparent that not having these relationships in our object model was severely hurting us.</p> <p>All of your layers (including the database) are all generated from an in-house metadata-database which we use to drive our home-grown code generator.</p> <p>The question is what is the best way to load or lazy load the relationships in our entities. For instance Let's say we have a person class that has a master-child relationship to an address table. This shows up in the business entity as a collection property of Addresses on the Person object. If we have a one-to-one relationship then this would show up as a single entity property. What is the best approach for filling and saving the relationship objects? Our Business entities have no knowledge of the Business Logic layer, so it can't be done internally when the property get's called.</p> <p>I'm sure there is some sort of standard patter out there for doing this. Any suggestions?</p> <p>Also, one caveat is that the DataAcess layer uses reflection to build our entities. The stored procedures return one result selt based on one table, and using reflection we populate our business object by matching the names of the properties with the names of the columns. So doing joins would be difficult.</p>
[ { "answer_id": 155965, "author": "Andrew Kennan", "author_id": 22506, "author_profile": "https://Stackoverflow.com/users/22506", "pm_score": 1, "selected": false, "text": "public class Relation<T>\n{\n private T _value;\n\n private void FetchData()\n {\n if( LoadData != null ) {\n ...
2008/10/01
[ "https://Stackoverflow.com/questions/155913", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17744/" ]
155,920
<p>I have one of those "I swear I didn't touch the server" situations. I honestly didn't touch any of the php scripts. The problem I am having is that php data is not being saved across different pages or page refreshes. I know a new session is being created correctly because I can set a session variable (e.g. $_SESSION['foo'] = "foo" and print it back out on the same page just fine. But when I try to use that same variable on another page it is not set! Is there any php functions or information I can use on my hosts server to see what is going on?</p> <p>Here is an example script that does not work on my hosts' server as of right now:</p> <pre><code>&lt;?php session_start(); if(isset($_SESSION['views'])) $_SESSION['views'] = $_SESSION['views']+ 1; else $_SESSION['views'] = 1; echo "views = ". $_SESSION['views']; echo '&lt;p&gt;&lt;a href="page1.php"&gt;Refresh&lt;/a&gt;&lt;/p&gt;'; ?&gt; </code></pre> <p>The 'views' variable never gets incremented after doing a page refresh. I'm thinking this is a problem on their side, but I wanted to make sure I'm not a complete idiot first.</p> <p>Here is the phpinfo() for my hosts' server (PHP Version 4.4.7): <img src="https://i.stack.imgur.com/3bv0K.png" alt="alt text"></p>
[ { "answer_id": 155941, "author": "vIceBerg", "author_id": 17766, "author_profile": "https://Stackoverflow.com/users/17766", "pm_score": 3, "selected": false, "text": "phpinfo()" }, { "answer_id": 155945, "author": "nickf", "author_id": 9021, "author_profile": "https:/...
2008/10/01
[ "https://Stackoverflow.com/questions/155920", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13556/" ]
155,930
<p>I have an application that launches a webpage in the "current" browser when the user selects it. This part of my app works fine in the Windows version but I can't figure out how to do this in Linux build.</p> <p>Right now the Linux version is hardcoded for Firefox in a specific directory and runs a new instance of it each time and doesn't show the URL that I pass in. I would like it to NOT launch a new version each time but just open a new page in the current open one if it is already running. </p> <p>For windows I use:</p> <pre><code>ShellExecute(NULL,"open",filename,NULL,NULL,SW_SHOWNORMAL); </code></pre> <p>For Linux I currently use:</p> <pre><code>pid_t pid; char *args[2]; char *prog=0; char firefox[]={"/usr/bin/firefox"}; if(strstri(filename,".html")) prog=firefox; if(prog) { args[0]=(char *)filename; args[1]=0; pid=fork(); if(!pid) execvp(prog,args); } </code></pre>
[ { "answer_id": 155946, "author": "John Millikin", "author_id": 3560, "author_profile": "https://Stackoverflow.com/users/3560", "pm_score": 4, "selected": true, "text": "xdg-open" }, { "answer_id": 159102, "author": "matli", "author_id": 23896, "author_profile": "https...
2008/10/01
[ "https://Stackoverflow.com/questions/155930", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13676/" ]
155,932
<p>I would like to know how to loop through each line in a text file using a Windows batch file and process each line of text in succession.</p>
[ { "answer_id": 155937, "author": "Michael Ratanapintha", "author_id": 1879, "author_profile": "https://Stackoverflow.com/users/1879", "pm_score": 3, "selected": false, "text": "cmd.exe" }, { "answer_id": 155950, "author": "Ash", "author_id": 5023, "author_profile": "h...
2008/10/01
[ "https://Stackoverflow.com/questions/155932", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5132/" ]
155,934
<p>What GNU/Linux command-line tool would I use for performing a search and replace on a file? </p> <p>Can the search text, and replacement, be specified in a regex format?</p>
[ { "answer_id": 155939, "author": "Michael Cramer", "author_id": 1496728, "author_profile": "https://Stackoverflow.com/users/1496728", "pm_score": 5, "selected": false, "text": "perl -pi -e 's/foo/bar/g;' *.txt\n" }, { "answer_id": 155956, "author": "Cristian Ciupitu", "au...
2008/10/01
[ "https://Stackoverflow.com/questions/155934", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2045/" ]
155,959
<p>The following code executes a simple insert command. If it is called 2,000 times consecutively (to insert 2,000 rows) an OleDbException with message = "System Resources Exceeded" is thrown. Is there something else I should be doing to free up resources?</p> <pre><code>using (OleDbConnection conn = new OleDbConnection(connectionString)) using (OleDbCommand cmd = new OleDbCommand(commandText, conn)) { conn.Open(); cmd.ExecuteNonQuery(); } </code></pre>
[ { "answer_id": 155961, "author": "FlySwat", "author_id": 1965, "author_profile": "https://Stackoverflow.com/users/1965", "pm_score": 4, "selected": true, "text": "using (OleDBConnection conn = new OleDBConnection(connstr))\n{\n while (IHaveData)\n {\n using (OldDBCommand cmd...
2008/10/01
[ "https://Stackoverflow.com/questions/155959", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2669/" ]
155,964
<p>I know about the <a href="http://developer.apple.com/library/mac/#documentation/UserExperience/Conceptual/AppleHIGuidelines/Intro/Intro.html" rel="noreferrer">HIG</a> (which is quite handy!), but what programming practices do you use when writing Objective-C, and more specifically when using Cocoa (or CocoaTouch).</p>
[ { "answer_id": 155966, "author": "JamesSugrue", "author_id": 1075, "author_profile": "https://Stackoverflow.com/users/1075", "pm_score": 6, "selected": false, "text": "alloc" }, { "answer_id": 156098, "author": "Kendall Helmstetter Gelner", "author_id": 6330, "author_...
2008/10/01
[ "https://Stackoverflow.com/questions/155964", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21804/" ]
155,977
<p>I have the following markup, and I want to make the <code>All</code> radio button checked.</p> <pre><code>&lt;ul&gt; &lt;li&gt;&lt;input type="radio" value="All" name="Foo"/&gt;All&lt;/li&gt; &lt;li&gt;&lt;input type="radio" value="New" name="Foo"/&gt;New&lt;/li&gt; &lt;li&gt;&lt;input type="radio" value="Removed" name="Foo"/&gt;Removed&lt;/li&gt; &lt;li&gt;&lt;input type="radio" value="Updated" name="Foo"/&gt;Updated&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>I'd like to match via attribute, but I need to match on 2 attributes, <code>@name='Foo'</code> and <code>@value='All'</code>.</p> <p>Something like this:</p> <pre><code>$("input[@name='Foo' @value='all']").attr('checked','checked'); </code></pre> <p>Can someone show how this can be done?</p>
[ { "answer_id": 156027, "author": "paxdiablo", "author_id": 14860, "author_profile": "https://Stackoverflow.com/users/14860", "pm_score": 7, "selected": true, "text": "<html>\n <head>\n <script type=\"text/javascript\" src=\"jquery-1.2.6.pack.js\"></script>\n <script type=\"text/ja...
2008/10/01
[ "https://Stackoverflow.com/questions/155977", "https://Stackoverflow.com", "https://Stackoverflow.com/users/410357/" ]
155,996
<p>I have an MDI application. When I show a message box using MessageBox.Show(), the entire application disappears behind all of my open windows when I dismiss the message box.</p> <p>The code is not doing anything special. In fact, here is the line that invokes the message box from within an MDI Child form:</p> <pre><code>MessageBox.Show(String.Format("{0} saved successfully.", Me.BusinessUnitTypeName), "Save Successful", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly) </code></pre> <p>Me.BusinessUnitTypeName() is a read only property getter that returns a string, depending upon the value of a member variable. There are no side effects in this property.</p> <p>Any ideas?</p>
[ { "answer_id": 156039, "author": "DaveK", "author_id": 4244, "author_profile": "https://Stackoverflow.com/users/4244", "pm_score": 2, "selected": false, "text": "MessageBoxOptions.DefaultDesktopOnly" }, { "answer_id": 156040, "author": "Mitch Wheat", "author_id": 16076, ...
2008/10/01
[ "https://Stackoverflow.com/questions/155996", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10224/" ]
155,998
<p>Given this:</p> <pre><code>Public Sub timReminder_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) If DateTime.Now() &gt; g_RemindTime Then Reminders.ShowDialog() timReminder.Enabled = False End If End Sub </code></pre> <p>I want to be able to say this (as I would in Delphi):</p> <pre><code>timReminder.Tick = timReminder_Tick </code></pre> <p>But I get errors when I try it.</p> <p>Does anyone know how I can assign a custom event to a timer's on-tick event at runtime in VB.NET?</p>
[ { "answer_id": 354784, "author": "Jon Winstanley", "author_id": 42106, "author_profile": "https://Stackoverflow.com/users/42106", "pm_score": 0, "selected": false, "text": "addHandler" } ]
2008/10/01
[ "https://Stackoverflow.com/questions/155998", "https://Stackoverflow.com", "https://Stackoverflow.com/users/672/" ]
156,002
<p>I have a very basic question about MVC web applications in Java.</p> <p>Since the olden days of raw JSP up until current technologies like Seam, a very basic pattern has always been the internal dispatch from the controller that initially accepted the request to the view layer that creates the output to be sent to the client.</p> <p>This internal dispatch is generally done (although the mechanism may be hidden through an extra layer of configuration) by asking the servlet container for a new resource using a URL. The mapping of these URL are done by the same web.xml that also defines the "real" URL to the outside.</p> <p>Unless special measures are taken, it is often possible to directly access the view layer directly. Witness the Seam "registration" demo, where you can bypass "register.seam" and directly go to "registered.xhtml". This is a potential security problem. At the very least, it leaks view template source code. </p> <p>I am aware that this is only a basic sample application, but it is also strange that any extra measures should need to be taken to declare these internal resources invisible to the outside.</p> <p>What is the easiest way to restrict URL entry points?</p> <p>Is there maybe something like the "WEB-INF" directory, a magic URL path component that can only be accessed by internal requests?</p>
[ { "answer_id": 453374, "author": "Simon Lieschke", "author_id": 2766, "author_profile": "https://Stackoverflow.com/users/2766", "pm_score": 2, "selected": false, "text": "security-constraint" }, { "answer_id": 2046033, "author": "Thilo", "author_id": 14955, "author_pr...
2008/10/01
[ "https://Stackoverflow.com/questions/156002", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14955/" ]
156,009
<p>Because of the more tedious way of adding hosts to be monitored in Nagios (it requires defining a host object, as opposed to the previous program which only required the IP and hostname), I figured it'd be best to automate this, and it'd be a great time to learn Perl, because all I know at the moment is C/C++ and Java. </p> <p>The file I read from looks like this:</p> <pre><code>xxx.xxx.xxx.xxx hostname #comments. i.dont. care. about </code></pre> <p>All I want are the first 2 bunches of characters. These are obviously space delimited, but for the sake of generality, it might as well be anything. To make it more general, why not the first and third, or fourth and tenth? Surely there must be some regex action involved, but I'll leave that tag off for the moment, just in case.</p>
[ { "answer_id": 156020, "author": "David Nehme", "author_id": 14167, "author_profile": "https://Stackoverflow.com/users/14167", "pm_score": 3, "selected": false, "text": "perl -nae 'print \"$F[0] $F[1]\\n\";'\n" }, { "answer_id": 156025, "author": "C. K. Young", "author_id...
2008/10/01
[ "https://Stackoverflow.com/questions/156009", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3879/" ]
156,013
<p>I can't quite figure out this syntax problem with a <code>case</code> expression in a <code>do</code> block.</p> <p>What is the correct syntax? </p> <p>If you could correct my example and explain it that would be the best.</p> <pre><code>module Main where main = do putStrLn "This is a test" s &lt;- foo putStrLn s foo = do args &lt;- getArgs return case args of [] -&gt; "No Args" [s]-&gt; "Some Args" </code></pre> <p>A little update. My source file was a mix of spaces and tabs and it was causing all kinds of problems. Just a tip for any one else starting in Haskell. If you are having problems check for tabs and spaces in your source code.</p>
[ { "answer_id": 156050, "author": "wnoise", "author_id": 15464, "author_profile": "https://Stackoverflow.com/users/15464", "pm_score": 6, "selected": true, "text": "module Main where \nimport System(getArgs)\n\nmain = do \n putStrLn \"This is a test\"\n s <- foo\n putStrLn s...
2008/10/01
[ "https://Stackoverflow.com/questions/156013", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8965/" ]
156,032
<p>Java &amp; Oracle both have a <em>timestamp</em> type called Date. Developers tend to manipulate these as if they were <em>calendar</em> dates, which I've seen cause nasty one-off bugs.</p> <ol> <li><p>For a basic date quantity you can simply chop off the time portion upon input, i.e., reduce the precision. But if you do that with a date range, (e.g.: <strong>9/29-9/30</strong>), the difference between these two values is 1 day, rather than 2. Also, range comparisons require either 1) a truncate operation: <code>start &lt; trunc(now) &lt;= end</code>, or 2) arithmetic: <code>start &lt; now &lt; (end + 24hrs)</code>. Not horrible, but not <a href="http://www.artima.com/intv/dry.html" rel="nofollow noreferrer">DRY</a>.</p></li> <li><p>An alternative is to use true timestamps: <strong>9/29</strong> 00:00:00 - <strong>10/1</strong> 00:00:00. (midnight-to-midnight, so does not include any part of Oct). Now durations are intrinsically correct, and range comparisons are simpler: <code>start &lt;= now &lt; end</code>. Certainly cleaner for internal processing, however end dates do need to be converted upon initial input (+1), and for output (-1), presuming a calendar date metaphor at the user level.</p></li> </ol> <p>How do you handle date ranges on your project? Are there other alternatives? I am particularly interested in how you handle this on both the Java and the Oracle sides of the equation.</p>
[ { "answer_id": 156038, "author": "Alan", "author_id": 17205, "author_profile": "https://Stackoverflow.com/users/17205", "pm_score": 0, "selected": false, "text": "java.util.Date" }, { "answer_id": 156041, "author": "David Aldridge", "author_id": 6742, "author_profile"...
2008/10/01
[ "https://Stackoverflow.com/questions/156032", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14749/" ]
156,046
<p>I'm using a Form to show notifications (it appears at the bottom right of the screen), but when I show this form it steals the focus from the main Form. Is there a way to show this "notification" form without stealing focus?</p>
[ { "answer_id": 156067, "author": "Matthew Scharley", "author_id": 15537, "author_profile": "https://Stackoverflow.com/users/15537", "pm_score": 3, "selected": false, "text": "this.TopMost = true; // as a result the form gets thrown to the front\nthis.TopMost = false; // but we don't act...
2008/10/01
[ "https://Stackoverflow.com/questions/156046", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4386/" ]
156,051
<p>I've got a dropdown list that is being populated via a webservice using ASP>NET AJAX. On the success callback of the method in javascript, I'm populating the dropdown via a loop:</p> <pre><code>function populateDropDown(dropdownId, list, enable, showCount) { var dropdown = $get(dropdownId); dropdown.options.length = 1; for (var i = 0; i &lt; list.length; i++) { var opt = document.createElement("option"); if (showCount) { opt.text = list[i].Name + ' (' + list[i].ChildCount + ')'; } else { opt.text = list[i].Name; } opt.value = list[i].Name; dropdown.options.add(opt); } dropdown.disabled = !enable; } </code></pre> <p>However when I submit the form that this control is on, the control's list is always empty on postback. How do I get the populated lists data to persist over postback?</p> <p><strong>Edit:</strong> Maybe I'm coming at this backwards. A better question would probably be, how do I populate a dropdown list from a webservice without having to use an updatepanel due to the full page lifecycle it has to run through?</p>
[ { "answer_id": 156065, "author": "Aaron Powell", "author_id": 11388, "author_profile": "https://Stackoverflow.com/users/11388", "pm_score": 3, "selected": true, "text": "AjaxControlToolkit.CascadingDropDownBehavior.callBaseMethod(this, 'set_ClientState', [ this._selectedValue+':::'+text ...
2008/10/01
[ "https://Stackoverflow.com/questions/156051", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2975/" ]
156,083
<p>I hear people writing these programs all the time and I know what they do, but how do they actually do it? I'm looking for general concepts.</p>
[ { "answer_id": 156312, "author": "micahwittman", "author_id": 11181, "author_profile": "https://Stackoverflow.com/users/11181", "pm_score": 2, "selected": false, "text": "//Show My SO Reputation Score\nvar repval = $('span.reputation-score:first'); alert('StackOverflow User \"' + repval....
2008/10/01
[ "https://Stackoverflow.com/questions/156083", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17744/" ]
156,084
<p>Using VBA i have a set of functions that return an <code>ADODB.Recordset</code> where all the columns as <code>adVarChar</code>. Unfortunately this means numerics get sorted as text. So 1,7,16,22 becomes 1,16,22,7</p> <p>Is there any methods that can sort numerics as text columns without resorting to changing the type of the column?</p> <pre><code>Sub TestSortVarChar() Dim strBefore, strAfter As String Dim r As ADODB.RecordSet Set r = New ADODB.RecordSet r.Fields.Append "ID", adVarChar, 100 r.Fields.Append "Field1", adVarChar, 100 r.Open r.AddNew r.Fields("ID") = "1" r.Fields("Field1") = "A" r.AddNew r.Fields("ID") = "7" r.Fields("Field1") = "B" r.AddNew r.Fields("ID") = "16" r.Fields("Field1") = "C" r.AddNew r.Fields("ID") = "22" r.Fields("Field1") = "D" r.MoveFirst Do Until r.EOF strBefore = strBefore &amp; r.Fields("ID") &amp; " " &amp; r.Fields("Field1") &amp; vbCrLf r.MoveNext Loop r.Sort = "[ID] ASC" r.MoveFirst Do Until r.EOF strAfter = strAfter &amp; r.Fields("ID") &amp; " " &amp; r.Fields("Field1") &amp; vbCrLf r.MoveNext Loop MsgBox strBefore &amp; vbCrLf &amp; vbCrLf &amp; strAfter End Sub </code></pre> <p>NB: I am using Project 2003 and Excel 2003 and referencing <strong>Microsoft ActiveX DataObject 2.8 Library</strong></p>
[ { "answer_id": 157741, "author": "Chris OC", "author_id": 11041, "author_profile": "https://Stackoverflow.com/users/11041", "pm_score": 2, "selected": false, "text": "SELECT ID, Field1\nFROM tablename\nORDER BY Val(Field1);\n" } ]
2008/10/01
[ "https://Stackoverflow.com/questions/156084", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4134/" ]
156,089
<p>I am just starting with SL and WPF. I am using the DataGrid control and I need to remove the mouseover effect (I actually will need to do more customizations than that). How do I do this. I think I need to do it with a control template but not sure how. I'm researching and reading right now. Any help would be appreciated.</p>
[ { "answer_id": 183936, "author": "Jobi Joy", "author_id": 8091, "author_profile": "https://Stackoverflow.com/users/8091", "pm_score": 2, "selected": false, "text": "<vsm:VisualState x:Name=\"MouseOver\">" }, { "answer_id": 1681462, "author": "Scott", "author_id": 38832, ...
2008/10/01
[ "https://Stackoverflow.com/questions/156089", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23663/" ]
156,113
<p>I have some linq entities that inherit something like this:</p> <pre><code>public abstract class EntityBase { public int Identifier { get; } } public interface IDeviceEntity { int DeviceId { get; set; } } public abstract class DeviceEntityBase : EntityBase, IDeviceEntity { public abstract int DeviceId { get; set; } } public partial class ActualLinqGeneratedEntity : DeviceEntityBase { } </code></pre> <p>In a generic method I am querying DeviceEnityBase derived entities with:</p> <pre><code>return unitOfWork.GetRepository&lt;TEntity&gt;().FindOne(x =&gt; x.DeviceId == evt.DeviceId); </code></pre> <p>where TEntity has a contraint that is it a DeviceEntityBase. This query is always failing with an InvalidOperationException with the message "Class member DeviceEntityBase.DeviceId is unmapped". Even if I add some mapping info in the abstract base class with</p> <pre><code>[Column(Storage = "_DeviceId", DbType = "Int", Name = "DeviceId", IsDbGenerated = false, UpdateCheck = UpdateCheck.Never)] </code></pre>
[ { "answer_id": 156365, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 3, "selected": true, "text": "static Expression<Func<T, bool>> BuildWhere<T>(int deviceId) {\n var id = Expression.Constant(deviceId, typeof(int)...
2008/10/01
[ "https://Stackoverflow.com/questions/156113", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2281/" ]
156,114
<p>When paging through data that comes from a DB, you need to know how many pages there will be to render the page jump controls.</p> <p>Currently I do that by running the query twice, once wrapped in a <code>count()</code> to determine the total results, and a second time with a limit applied to get back just the results I need for the current page.</p> <p>This seems inefficient. Is there a better way to determine how many results would have been returned before <code>LIMIT</code> was applied?</p> <p>I am using PHP and Postgres.</p>
[ { "answer_id": 8242764, "author": "Erwin Brandstetter", "author_id": 939860, "author_profile": "https://Stackoverflow.com/users/939860", "pm_score": 8, "selected": true, "text": "SELECT foo\n , count(*) OVER() AS full_count\nFROM bar\nWHERE <some condition>\nORDER BY <some col>\n...
2008/10/01
[ "https://Stackoverflow.com/questions/156114", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20851/" ]
156,116
<p>I'm using CSS Filters to modify images on the fly within the browser. These work perfectly in Internet Explorer, but aren't supported in Firefox.</p> <p>Does anyone know what the CSS Filter equivalent for these is for Firefox? An answer that would work cross browser (Safari, WebKit, Firefox, etc.) would be preferred.</p> <pre><code>&lt;style type="text/css"&gt; .CSSClassName {filter:Invert;} .CSSClassName {filter:Xray;} .CSSClassName {filter:Gray;} .CSSClassName {filter:FlipV;} &lt;/style&gt; </code></pre> <p>Update: I know Filter is an IE specific feature. Is there any kind of equivalent for any of these that is supported by Firefox?</p>
[ { "answer_id": 156142, "author": "John Millikin", "author_id": 3560, "author_profile": "https://Stackoverflow.com/users/3560", "pm_score": 2, "selected": false, "text": "filter" }, { "answer_id": 156238, "author": "Steven Oxley", "author_id": 3831, "author_profile": "...
2008/10/01
[ "https://Stackoverflow.com/questions/156116", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7831/" ]
156,230
<p>Is there a framework equivalent to Guice (<a href="http://code.google.com/p/google-guice" rel="noreferrer">http://code.google.com/p/google-guice</a>) for Python?</p>
[ { "answer_id": 34346267, "author": "Aigrefin", "author_id": 1014321, "author_profile": "https://Stackoverflow.com/users/1014321", "pm_score": 0, "selected": false, "text": "from py3njection import inject\nfrom some_package import ClassToInject\n\nclass Demo:\n @inject\n def __init_...
2008/10/01
[ "https://Stackoverflow.com/questions/156230", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9940/" ]
156,243
<p>What is the difference between the following 2 ways to allocate and init an object?</p> <pre><code>AController *tempAController = [[AController alloc] init]; self.aController = tempAController; [tempAController release]; </code></pre> <p>and</p> <pre><code>self.aController= [[AController alloc] init]; </code></pre> <p>Most of the apple example use the first method. Why would you allocate, init and object and then release immediately?</p>
[ { "answer_id": 156289, "author": "benzado", "author_id": 10947, "author_profile": "https://Stackoverflow.com/users/10947", "pm_score": 7, "selected": true, "text": "@property (retain)" }, { "answer_id": 156516, "author": "Kendall Helmstetter Gelner", "author_id": 6330, ...
2008/10/01
[ "https://Stackoverflow.com/questions/156243", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1987/" ]
156,256
<p>The sample below has two TextBoxes. The second TextBox has a handler for the LostFocus event which calls Clear() on itself. Changing focus between the two text boxes works fine; however, if the focus is on the second text box when the window is closed, TextBox.Clear() generates a NullReferenceException. Is this a bug in WPF? How can I easily detect this situation so I can avoid calling Clear() when the window is closing?</p> <p>Edit: Possibly relevant - The window is the application's main window. Test is not null at the time Clear() is called. The exception is thrown from somewhere within the call.</p> <pre><code>using System.Windows; namespace TextBoxClear { public partial class Window1 : Window { public Window1() { InitializeComponent(); } private void Test_LostFocus(object sender, RoutedEventArgs e) { Test.Clear(); } } } &lt;Window x:Class="TextBoxClear.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"&gt; &lt;StackPanel&gt; &lt;TextBox /&gt; &lt;TextBox LostFocus="Test_LostFocus" Name="Test" /&gt; &lt;/StackPanel&gt; &lt;/Window&gt; </code></pre> <p>Assembly references:</p> <ul> <li>mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</li> <li>PresentationCore, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35</li> <li>PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35</li> <li>System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</li> <li>WindowsBase, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35</li> </ul>
[ { "answer_id": 156277, "author": "Jason Anderson", "author_id": 5142, "author_profile": "https://Stackoverflow.com/users/5142", "pm_score": 2, "selected": false, "text": " private void Test_LostFocus(object sender, RoutedEventArgs e)\n {\n if (Test != null)\n Test...
2008/10/01
[ "https://Stackoverflow.com/questions/156256", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
156,257
<p>In an AI application I am writing in C++, </p> <ol> <li>there is not much numerical computation </li> <li>there are lot of structures for which run-time polymorphism is needed </li> <li>very often, several polymorphic structures interact during computation</li> </ol> <p>In such a situation, are there any optimization techniques? While I won't care to optimize the application just now, one aspect of selecting C++ over Java for the project was to enable more leverage to optimize and to be able to use non-object oriented methods (templates, procedures, overloading). </p> <p>In particular, what are the optimization techniques related to virtual functions? Virtual functions are implemented through virtual tables in memory. Is there some way to pre-fetch these virtual tables onto L2 cache (the cost of fetching from memory/L2 cache is increasing)? </p> <p>Apart from this, are there good references for data locality techniques in C++? These techniques would reduce the wait time for data fetch into L2 cache needed for computation. </p> <p><em>Update</em>: Also see the following related forums: <a href="https://stackoverflow.com/questions/113830/performance-penalty-for-working-with-interfaces-in-c#171549">Performance Penalty for Interface</a>, <a href="https://stackoverflow.com/questions/99510/does-several-levels-of-base-classes-slow-down-a-classstruct-in-c">Several Levels of Base Classes</a> </p>
[ { "answer_id": 156420, "author": "loudej", "author_id": 6056, "author_profile": "https://Stackoverflow.com/users/6056", "pm_score": 6, "selected": true, "text": "classptr -> [vtable:4][classdata:x]\nvtable -> [first:4][second:4][third:4][fourth:4][...]\nfirst -> [code:x]\nsecond -> [code...
2008/10/01
[ "https://Stackoverflow.com/questions/156257", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19501/" ]
156,275
<p>Is there a good reason why there is no <code>Pair&lt;L,R&gt;</code> in Java? What would be the equivalent of this C++ construct? I would rather avoid reimplementing my own.</p> <p>It seems that <strong>1.6</strong> is providing something similar (<code>AbstractMap.SimpleEntry&lt;K,V&gt;</code>), but this looks quite convoluted.</p>
[ { "answer_id": 156286, "author": "cletus", "author_id": 18393, "author_profile": "https://Stackoverflow.com/users/18393", "pm_score": 4, "selected": false, "text": "Map<String, Object> map = ... ; // just an example\nfor (Map.Entry<String, Object> entry : map.entrySet()) {\n System.out....
2008/10/01
[ "https://Stackoverflow.com/questions/156275", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13673/" ]
156,278
<p>Yet again, my teacher was unable to answer my question. I knew who may be able to...</p> <p>So, I've never really learned C. In C++, I would, obviously, use a cout statement all of the time. In a recent assignment, my teacher told us to make sure to put </p> <pre><code>setbuf( stdout , NULL ); </code></pre> <p>at the top of main() in order to get an unbuffered output, thus allowing us to see the output properly.</p> <p>My question is this: will this statement affect a cout statement, or simply a printf() statement that I call? </p> <p>Thanks in advance!</p>
[ { "answer_id": 156321, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 4, "selected": true, "text": "std::endl" }, { "answer_id": 156413, "author": "Greg Rogers", "author_id": 5963, "author_profile": "https...
2008/10/01
[ "https://Stackoverflow.com/questions/156278", "https://Stackoverflow.com", "https://Stackoverflow.com/users/73/" ]
156,279
<p>The title is self explanatory. Is there a way of directly doing such kind of importing?</p>
[ { "answer_id": 156479, "author": "Richard Harrison", "author_id": 19624, "author_profile": "https://Stackoverflow.com/users/19624", "pm_score": 7, "selected": true, "text": "sqlcmd -S <COMPUTERNAME>\\SQLExpress" }, { "answer_id": 7179605, "author": "Andrew", "author_id": ...
2008/10/01
[ "https://Stackoverflow.com/questions/156279", "https://Stackoverflow.com", "https://Stackoverflow.com/users/131/" ]
156,280
<p>When using mercurial, I'd like to be able to diff the working copy of a file with the tip file in my default remote repository. Is there an easy way to do this?</p> <p>I know I can do an "hg incoming -p" to see the patch sets of changes coming in, but it'd be nice to just directly see the actual changes for a particular file that I'd get if I do a pull of the latest stuff (or what I might be about put push out).</p> <p>The easiest thing I can think of right now is to create a little script that takes a look at the default location in .hg/hgrc and downloads the file using curl (if it's over http, otherwise scp it over ssh, or just do a direct diff if it's on the local file system) and then to diff the working copy or the tip against that temporary copy.</p> <p>I'm trying to sell mercurial to my team, and one of my team members brought this up today as something that they're able to do easily in SVN with their GUI tools.</p>
[ { "answer_id": 157642, "author": "nlucaroni", "author_id": 157, "author_profile": "https://Stackoverflow.com/users/157", "pm_score": 2, "selected": false, "text": "-R" }, { "answer_id": 164566, "author": "Ted Naleid", "author_id": 8912, "author_profile": "https://Stac...
2008/10/01
[ "https://Stackoverflow.com/questions/156280", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8912/" ]
156,292
<p>I'm a bit of a DI newbie, so forgive me if this is the wrong approach or a silly question.</p> <p>Let's say I have a form which creates/updates an order, and I know it's going to need to retrieve a list of products and customers to display. I want to pass in the Order object that it's editing, but I also want to inject the ProductsService and CustomersService as dependencies. </p> <p>So I will want my IoC container (whichever one I go with) to supply the services, but it'll be up to the calling code to supply the Order object to edit.</p> <p>Should I declare the constructor as taking the Order object as the first parameter and the ProductsService and CustomersService after that, eg:</p> <pre><code>public OrderForm(Order order, ProductsService prodsSvc, CustomersService custsSvc) </code></pre> <p>... or should the dependencies come first and the Order object last, eg:</p> <pre><code>public OrderForm(ProductsService prodsSvc, CustomersService custsSvc, Order order) </code></pre> <p>Does it matter? Does it depend on which IoC container I use? Or is there a "better" way?</p>
[ { "answer_id": 63869152, "author": "Efran Cobisi", "author_id": 904178, "author_profile": "https://Stackoverflow.com/users/904178", "pm_score": 0, "selected": false, "text": "*Service" } ]
2008/10/01
[ "https://Stackoverflow.com/questions/156292", "https://Stackoverflow.com", "https://Stackoverflow.com/users/615/" ]
156,322
<p>fossil <a href="http://www.fossil-scm.org" rel="noreferrer">http://www.fossil-scm.org</a><br> I found this recently and have started using it for my home projects. I want to hear what other people think of this VCS. </p> <p>What is missing in my mind, is IDE support. Hopefully it will come, but I use the command line just fine.</p> <p>My favorite things about fossil: single executable with built in web server wiki and bug tracking. The repository is just one SQLite (<a href="http://www.sqlite.org" rel="noreferrer">http://www.sqlite.org</a>) database file, easy to do backups on. I also like that I can run fossil from and keep the repository on my thumb drive. This means my software development has become completely portable. </p> <p>Tell me what you think....</p>
[ { "answer_id": 265829, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "for /r %i in (*.*) do fossil add \"%i\"\n" } ]
2008/10/01
[ "https://Stackoverflow.com/questions/156322", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3576/" ]
156,329
<p>I need to pad numbers with leading zeros (total 8 digits) for display. I'm using oracle.</p> <pre><code>select to_char(1011,'00000000') OPE_NO from dual; select length(to_char(1011,'00000000')) OPE_NO from dual; </code></pre> <p>Instead of '00001011' I get ' 00001011'. Why do I get an extra leading blank space? What is the correct number formatting string to accomplish this?</p> <p>P.S. I realise I can just use <code>trim()</code>, but I want to understand number formatting better.</p> <p>@Eddie: I already read the documentation. And yet I still don't understand how to get rid of the leading whitespace. </p> <p>@David: So does that mean there's no way but to use <code>trim()</code>?</p>
[ { "answer_id": 156670, "author": "Steve Bosman", "author_id": 4389, "author_profile": "https://Stackoverflow.com/users/4389", "pm_score": 6, "selected": true, "text": "select to_char(1011,'FM00000000') OPE_NO from dual;" } ]
2008/10/01
[ "https://Stackoverflow.com/questions/156329", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3751/" ]
156,330
<p>I'm just trying to time a piece of code. The pseudocode looks like:</p> <pre><code>start = get_ticks() do_long_code() print "It took " + (get_ticks() - start) + " seconds." </code></pre> <p>How does this look in Python?</p> <p>More specifically, how do I get the number of ticks since midnight (or however Python organizes that timing)?</p>
[ { "answer_id": 156335, "author": "blackwing", "author_id": 9107, "author_profile": "https://Stackoverflow.com/users/9107", "pm_score": 5, "selected": false, "text": "time()" }, { "answer_id": 156339, "author": "Harley Holcombe", "author_id": 1057, "author_profile": "h...
2008/10/01
[ "https://Stackoverflow.com/questions/156330", "https://Stackoverflow.com", "https://Stackoverflow.com/users/432/" ]
156,331
<p>I was inserting data into a MS Access database using JDBC-ODBC driver. The blank mdb file was 2KB. After populating this database, the size grew to 155MB. Then I was deleting the data. But I found the size of mdb remains the same as 155MB. I don't get any errors. But is it normal this way? I would expect the file size reduces. If it is designed in this way, what is the idea behind it? Thanks</p>
[ { "answer_id": 156346, "author": "Jon Cahill", "author_id": 10830, "author_profile": "https://Stackoverflow.com/users/10830", "pm_score": 5, "selected": false, "text": "msaccess.exe \"target database.accdb\" /compact \n" } ]
2008/10/01
[ "https://Stackoverflow.com/questions/156331", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24020/" ]
156,360
<p>I have one thread that writes results into a Queue.</p> <p>In another thread (GUI), I periodically (in the IDLE event) check if there are results in the queue, like this:</p> <pre><code>def queue_get_all(q): items = [] while 1: try: items.append(q.get_nowait()) except Empty, e: break return items </code></pre> <p>Is this a good way to do it ? </p> <p><strong>Edit:</strong></p> <blockquote> <p>I'm asking because sometimes the waiting thread gets stuck for a few seconds without taking out new results.</p> </blockquote> <p>The "stuck" problem turned out to be because I was doing the processing in the idle event handler, without making sure that such events are actually generated by calling <code>wx.WakeUpIdle</code>, as is recommended.</p>
[ { "answer_id": 156564, "author": "Brian", "author_id": 9493, "author_profile": "https://Stackoverflow.com/users/9493", "pm_score": 4, "selected": false, "text": "from __future__ import with_statement\nimport threading\n\nclass ItemStore(object):\n def __init__(self):\n self.loc...
2008/10/01
[ "https://Stackoverflow.com/questions/156360", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8206/" ]
156,362
<p>Just getting my head around Ruby metaprogramming. The mixin/modules always manage to confuse me. </p> <ul> <li><strong>include</strong>: mixes in specified module methods as <strong>instance methods</strong> in the target class</li> <li><strong>extend</strong>: mixes in specified module methods as <strong>class methods</strong> in the target class</li> </ul> <p><em>So is the major difference just this or is a bigger dragon lurking?</em> e.g.</p> <pre><code>module ReusableModule def module_method puts "Module Method: Hi there!" end end class ClassThatIncludes include ReusableModule end class ClassThatExtends extend ReusableModule end puts "Include" ClassThatIncludes.new.module_method # "Module Method: Hi there!" puts "Extend" ClassThatExtends.module_method # "Module Method: Hi there!" </code></pre>
[ { "answer_id": 156927, "author": "domgblackwell", "author_id": 16954, "author_profile": "https://Stackoverflow.com/users/16954", "pm_score": 9, "selected": true, "text": "Klazz" }, { "answer_id": 5008349, "author": "John Douthat", "author_id": 2774, "author_profile": ...
2008/10/01
[ "https://Stackoverflow.com/questions/156362", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1695/" ]
156,369
<p>It seems quite a few mainstream languages support <a href="http://en.wikipedia.org/wiki/First-class_function" rel="noreferrer">function literals</a> these days. They are also called <a href="http://en.wikipedia.org/wiki/Anonymous_function" rel="noreferrer">anonymous functions</a>, but I don't care if they have a name. The important thing is that a function literal is an expression which yields a function which hasn't already been defined elsewhere, so for example in C, <code>&amp;printf</code> doesn't count.</p> <p>EDIT to add: if you have a genuine function literal expression <code>&lt;exp&gt;</code>, you should be able to pass it to a function <code>f(&lt;exp&gt;)</code> or immediately apply it to an argument, ie. <code>&lt;exp&gt;(5)</code>. </p> <p>I'm curious which languages let you write function literals which are <em>recursive</em>. Wikipedia's "<a href="http://en.wikipedia.org/wiki/Anonymous_recursion" rel="noreferrer">anonymous recursion</a>" article doesn't give any programming examples.</p> <p>Let's use the recursive factorial function as the example.</p> <p>Here are the ones I know:</p> <ul> <li><p>JavaScript / ECMAScript can do it with <code>callee</code>:</p> <pre><code>function(n){if (n&lt;2) {return 1;} else {return n * arguments.callee(n-1);}} </code></pre></li> <li><p>it's easy in languages with <code>letrec</code>, eg Haskell (which calls it <code>let</code>):</p> <blockquote> <p><code>let fac x = if x&lt;2 then 1 else fac (x-1) * x in fac</code></p> </blockquote> <p>and there are equivalents in Lisp and Scheme. Note that the binding of <code>fac</code> is local to the expression, so the whole expression is in fact an anonymous function.</p></li> </ul> <p>Are there any others?</p>
[ { "answer_id": 156374, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 2, "selected": false, "text": "labels" }, { "answer_id": 156393, "author": "John Millikin", "author_id": 3560, "author_profile": "https...
2008/10/01
[ "https://Stackoverflow.com/questions/156369", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15069/" ]
156,373
<p>I'm storing an object (<code>TTF_Font</code>) in a <code>shared_ptr</code> that is provided to me from a third-party API. I cannot use new or delete on the object, so the <code>shared_ptr</code> is also provided a "freeing" functor.</p> <pre><code>// Functor struct CloseFont { void operator()(TTF_Font* font) const { if(font != NULL) { TTF_CloseFont(font); } } }; boost::shared_ptr&lt;TTF_Font&gt; screenFont; screenFont = boost::shared_ptr&lt;TTF_Font&gt;( TTF_OpenFont("slkscr.ttf", 8), CloseFont() ); </code></pre> <p>If, later, I need to explicitly free this object is it correct to do this:</p> <pre><code>screenFont.reset(); </code></pre> <p>And then let <code>screenFont</code> (the actual <code>shared_ptr</code> object) be destroyed naturally?</p>
[ { "answer_id": 156386, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 0, "selected": false, "text": "TTF_OpenFont" } ]
2008/10/01
[ "https://Stackoverflow.com/questions/156373", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18265/" ]
156,394
<p>How is it that Ruby allows a class access methods outside of the class implicitly?</p> <p>Example:</p> <pre><code>class Candy def land homer end end def homer puts "Hello" end Candy.new.land #Outputs Hello </code></pre>
[ { "answer_id": 161113, "author": "Grant Hutchins", "author_id": 6304, "author_profile": "https://Stackoverflow.com/users/6304", "pm_score": 2, "selected": false, "text": "homer" }, { "answer_id": 8286738, "author": "Linuxios", "author_id": 1008938, "author_profile": "...
2008/10/01
[ "https://Stackoverflow.com/questions/156394", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
156,395
<p>As a Java developer who is reading Apple's Objective-C 2.0 documentation: I wonder what "<em>sending a message to nil</em>" means - let alone how it is actually useful. Taking an excerpt from the documentation:</p> <blockquote> <p>There are several patterns in Cocoa that take advantage of this fact. The value returned from a message to nil may also be valid:</p> <ul> <li>If the method returns an object, any pointer type, any integer scalar of size less than or equal to sizeof(void*), a float, a double, a long double, or a long long, then a message sent to nil returns 0.</li> <li>If the method returns a struct, as defined by the Mac OS X ABI Function Call Guide to be returned in registers, then a message sent to nil returns 0.0 for every field in the data structure. Other struct data types will not be filled with zeros.</li> <li>If the method returns anything other than the aforementioned value types the return value of a message sent to nil is undefined.</li> </ul> </blockquote> <p>Has Java rendered my brain incapable of grokking the explanation above? Or is there something that I am missing that would make this as clear as glass?</p> <p>I do get the idea of messages/receivers in Objective-C, I am simply confused about a receiver that happens to be <code>nil</code>.</p>
[ { "answer_id": 156415, "author": "Rich", "author_id": 22003, "author_profile": "https://Stackoverflow.com/users/22003", "pm_score": 4, "selected": false, "text": "[someNullNSArrayReference count] => 0\n" }, { "answer_id": 156463, "author": "Michael Buckley", "author_id": ...
2008/10/01
[ "https://Stackoverflow.com/questions/156395", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9931/" ]
156,412
<p><code>GWT</code> gets locale from either the locale property or the locale query string. If neither is specified, it uses the "default" (ie <code>en_US</code>) locale.</p> <p>Why doesn't it get it from the browser settings?</p> <p>It seems the only solution to this is to replace your static html launch page with something like a JSP that reads the browser locales and sets the locale or redirects using the query string. There has to be a better solution than this or simply hard-coding a locale, surely?</p>
[ { "answer_id": 161313, "author": "Drejc", "author_id": 6482, "author_profile": "https://Stackoverflow.com/users/6482", "pm_score": 2, "selected": false, "text": "<!-- Slovenian in Slovenia -->\n<extend-property name=\"locale\" values=\"sl\"/>\n\n<!-- English language, independent of coun...
2008/10/01
[ "https://Stackoverflow.com/questions/156412", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18393/" ]
156,430
<p>I recently read somewhere that writing a regexp to match an email address, taking into account all the variations and possibilities of the standard is extremely hard and is significantly more complicated than what one would initially assume.</p> <p>Why is that?</p> <p>Are there any known and proven regexps that actually do this fully?</p> <p>What are some good alternatives to using regexps for matching email addresses?</p>
[ { "answer_id": 156449, "author": "janm", "author_id": 7256, "author_profile": "https://Stackoverflow.com/users/7256", "pm_score": 3, "selected": false, "text": "\" @ \"@example.com\n" }, { "answer_id": 156455, "author": "Mike Thompson", "author_id": 2754, "author_prof...
2008/10/01
[ "https://Stackoverflow.com/questions/156430", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9611/" ]
156,436
<p>It's quite a simple question - how do I sort a collection?</p> <p>I've got a CSV file with rows in a random order. I'd like to sort the rows according to the date in one column. Do I add the rows to a recordset? Can I sort with a Scripting.Dictionary?</p> <p>I've clearly been spoilt with .NET and Linq, and now I find myself back in the land of classic asp, realising I must have known this 7 years ago, and missing generics immensely. I feel like a complete n00b.</p>
[ { "answer_id": 156496, "author": "Wayne", "author_id": 8236, "author_profile": "https://Stackoverflow.com/users/8236", "pm_score": 2, "selected": false, "text": "<%\n\nDim strConnection, conn, rs, strSQL\n\nstrConnection = \"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\inetpub\\wwwro...
2008/10/01
[ "https://Stackoverflow.com/questions/156436", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5744/" ]
156,438
<p>See title: what does it mean for a C++ function to be inline?</p>
[ { "answer_id": 156453, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 0, "selected": false, "text": "if" }, { "answer_id": 156511, "author": "Simon Buchan", "author_id": 20135, "author_profile": "https://S...
2008/10/01
[ "https://Stackoverflow.com/questions/156438", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7545/" ]
156,457
<p>Is it possible to enumerate all the current errors being displayed through an "Error Provider" without having to access the controls?</p>
[ { "answer_id": 2297261, "author": "Aidan Ryan", "author_id": 1042, "author_profile": "https://Stackoverflow.com/users/1042", "pm_score": 2, "selected": false, "text": "foreach (Control ctrl in errProv.ContainerControl.Controls)\n{\n Console.WriteLine(errProv.GetError(ctrl));\n}\n" }...
2008/10/01
[ "https://Stackoverflow.com/questions/156457", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4490/" ]
156,467
<p>I've been looking at F# recently, and while I'm not likely to leap the fence any time soon, it definitely highlights some areas where C# (or library support) could make life easier.</p> <p>In particular, I'm thinking about the pattern matching capability of F#, which allows a very rich syntax - much more expressive than the current switch/conditional C# equivalents. I won't try to give a direct example (my F# isn't up to it), but in short it allows:</p> <ul> <li>match by type (with full-coverage checking for discriminated unions) [note this also infers the type for the bound variable, giving member access etc]</li> <li>match by predicate</li> <li>combinations of the above (and possibly some other scenarios I'm not aware of)</li> </ul> <p>While it would be lovely for C# to eventually borrow [ahem] some of this richness, in the interim I've been looking at what can be done at runtime - for example, it is fairly easy to knock together some objects to allow:</p> <pre><code>var getRentPrice = new Switch&lt;Vehicle, int&gt;() .Case&lt;Motorcycle&gt;(bike =&gt; 100 + bike.Cylinders * 10) // "bike" here is typed as Motorcycle .Case&lt;Bicycle&gt;(30) // returns a constant .Case&lt;Car&gt;(car =&gt; car.EngineType == EngineType.Diesel, car =&gt; 220 + car.Doors * 20) .Case&lt;Car&gt;(car =&gt; car.EngineType == EngineType.Gasoline, car =&gt; 200 + car.Doors * 20) .ElseThrow(); // or could use a Default(...) terminator </code></pre> <p>where getRentPrice is a Func&lt;Vehicle,int&gt;.</p> <p>[note - maybe Switch/Case here is the wrong terms... but it shows the idea]</p> <p>To me, this is a lot clearer than the equivalent using repeated if/else, or a composite ternary conditional (which gets very messy for non-trivial expressions - brackets galore). It also avoids a <em>lot</em> of casting, and allows for simple extension (either directly or via extension methods) to more-specific matches, for example an InRange(...) match comparable to the VB Select...Case "x To y" usage.</p> <p><strong>I'm just trying to gauge if people think there is much benefit from constructs like the above (in the absence of language support)?</strong></p> <p>Note additionally that I've been playing with 3 variants of the above:</p> <ul> <li>a Func&lt;TSource,TValue&gt; version for evaluation - comparable to composite ternary conditional statements</li> <li>an Action&lt;TSource&gt; version - comparable to if/else if/else if/else if/else</li> <li>an Expression&lt;Func&lt;TSource,TValue&gt;&gt; version - as the first, but usable by arbitrary LINQ providers</li> </ul> <p>Additionally, using the Expression-based version enables Expression-tree re-writing, essentially inlining all the branches into a single composite conditional Expression, rather than using repeated invocation. I haven't checked recently, but in some early Entity Framework builds I seem to recall this being necessary, as it didn't like InvocationExpression very much. It also allows more efficient usage with LINQ-to-Objects, since it avoids repeated delegate invocations - tests show a match like the above (using the Expression form) performing at the same speed [marginally quicker, in fact] compared to the equivalent C# composite conditional statement. For completeness, the Func&lt;...&gt; based-version took 4 times as long as the C# conditional statement, but is still very quick and is unlikely to be a major bottleneck in most use-cases.</p> <p>I welcome any thoughts / input / critique / etc on the above (or on the possibilities of richer C# language support... here's hoping ;-p).</p>
[ { "answer_id": 156566, "author": "Brian", "author_id": 19299, "author_profile": "https://Stackoverflow.com/users/19299", "pm_score": 5, "selected": false, "text": "let getRentPrice (v : Vehicle) = \n match v with\n | :? Motorcycle as bike -> 100 + bike.Cylinders * 10\n | :? Bicy...
2008/10/01
[ "https://Stackoverflow.com/questions/156467", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23354/" ]
156,478
<p>I'm implementing a cache in a class library that i'm using in an asp.net application. </p> <p>I created my cache object as a singleton pattern with a static method to update the cache which is really just loading a member variable/property with a collection of data i need cached (got some locking logic ofcourse). I figured it was a nice way to go since i can just access my data by calling </p> <pre><code>MyCacheObject.Instance.MyDataCollection </code></pre> <p>I'm creating a new cache object to store a pretty big amount of data partitioned by some key. What i'm saying is i'm creating a new cache but this one will not load all of the data at once, but rather store a collection for each key accessed.</p> <pre><code>MyOtherCacheObject.Instance.MyOtherDataCollection(indexkey) </code></pre> <p>This time the question about garbage collection was brought up. Since i'm storing a huge amount of data, wouldn't it be a waste if it got gc'ed all of a sudden? Since it's just a singleton pattern there is nothing ensuring data will stay in cache.</p> <p>So my question is - what is best practice for implemeting a cache to handle this situation? I really don't like a huge complex solution to this, and i know there is caching in System.Web but that seems a bit 'off' since this is just a class library, or what do you think?</p>
[ { "answer_id": 156506, "author": "Sergio Acosta", "author_id": 2954, "author_profile": "https://Stackoverflow.com/users/2954", "pm_score": 4, "selected": true, "text": "public interface ICacheService \n{\n AddItem(...);\n}\n" } ]
2008/10/01
[ "https://Stackoverflow.com/questions/156478", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11619/" ]
156,492
<p>I have built a CFC designed to serve as a dynamic, aging cache intended for almost everything worth caching. LDAP queries, function results, arrays, ojects, you name it. Whatever takes time or resources to calculate and is needed more than once. I'd like to be able to do a few things:</p> <ul> <li><strong>share the CFC between applications</strong></li> <li><strong>define the scope of the cache (server / application / session / current request only)</strong></li> <li>use different cache instances at the same time, in the same request</li> <li>be independent from CFCs using the cache component</li> <li>generally adhere to common sense (decoupling, encapsulation, orthogonality, locking)</li> </ul> <p>I would of course be using a different cache instance for every distinct task, but I'd like to be able to use the same CFC across applications. The cache itself is (what else) a Struct, private to the cache instance. How would I properly implement caching and locking when the scope itself is subject to change?</p> <p>For locking, I use named locks (<code>'CacheRead'</code>, <code>'CacheWrite'</code>) currently, this is safe but strikes me as odd. Why would I want a server-wide lock for, say, a session-only operation? (Yes, maybe this <em>is</em> academic, but anyway.)</p> <p>Passing in the APPLICATION scope as a reference when I want application level caching also seems the wrong thing to do. Is there a better way?</p>
[ { "answer_id": 240702, "author": "Adam Tuttle", "author_id": 751, "author_profile": "https://Stackoverflow.com/users/751", "pm_score": 2, "selected": true, "text": "<cfcomponent>\n <cfset variables.cacheScope = \"session\" /><!--- default to session --->\n <cfset variables.cache = ...
2008/10/01
[ "https://Stackoverflow.com/questions/156492", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18771/" ]
156,503
<p>How can I use JUnit idiomatically to test that some code throws an exception?</p> <p>While I can certainly do something like this:</p> <pre><code>@Test public void testFooThrowsIndexOutOfBoundsException() { boolean thrown = false; try { foo.doStuff(); } catch (IndexOutOfBoundsException e) { thrown = true; } assertTrue(thrown); } </code></pre> <p>I recall that there is an annotation or an Assert.xyz or <em>something</em> that is far less kludgy and far more in-the-spirit of JUnit for these sorts of situations.</p>
[ { "answer_id": 156515, "author": "Johan", "author_id": 11347, "author_profile": "https://Stackoverflow.com/users/11347", "pm_score": 5, "selected": false, "text": "public void testFooThrowsIndexOutOfBoundsException() {\n Throwable e = null;\n\n try {\n foo.doStuff();\n } catch (Thr...
2008/10/01
[ "https://Stackoverflow.com/questions/156503", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1666/" ]
156,504
<p>I'm trying to insert some import lines into a python source file, but i would ideally like to place them right after the initial docstring. Let's say I load the file into the lines variable like this:</p> <pre><code>lines = open('filename.py').readlines() </code></pre> <p>How to find the line number, where the docstring ends?</p>
[ { "answer_id": 156513, "author": "John Millikin", "author_id": 3560, "author_profile": "https://Stackoverflow.com/users/3560", "pm_score": 3, "selected": true, "text": "count = 0\nfor line in lines:\n if line.startswith ('\"\"\"'):\n count += 1\n if count < 3:\n ...
2008/10/01
[ "https://Stackoverflow.com/questions/156504", "https://Stackoverflow.com", "https://Stackoverflow.com/users/985/" ]
156,508
<p>Alright, I have been doing the following (variable names have been changed):</p> <pre><code> FileInputStream fis = null; try { fis = new FileInputStream(file); ... process ... } catch (IOException e) { ... handle error ... } finally { if (fis != null) fis.close(); } </code> </pre> <p>Recently, I started using FindBugs, which suggests that I am not properly closing streams. I decide to see if there's anything that can be done with a finally{} block, and then I see, oh yeah, close() can throw IOException. What are people supposed to do here? The Java libraries throw too many checked exceptions.</p>
[ { "answer_id": 156520, "author": "Max Stewart", "author_id": 18338, "author_profile": "https://Stackoverflow.com/users/18338", "pm_score": 5, "selected": false, "text": "FileInputStream fis = null;\ntry\n{\n fis = new FileInputStream(file);\n\n ... process ...\n\n\n}\ncatch (IOExce...
2008/10/01
[ "https://Stackoverflow.com/questions/156508", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18049/" ]
156,510
<p>Is there a way to increase the stack size of a Windows application at compile/link time with GCC?</p>
[ { "answer_id": 156730, "author": "Jonas Engström", "author_id": 7634, "author_profile": "https://Stackoverflow.com/users/7634", "pm_score": 5, "selected": false, "text": "gcc -Wl,--stack,16777216 -o file.exe file.c\n" } ]
2008/10/01
[ "https://Stackoverflow.com/questions/156510", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1597/" ]
156,532
<p>I need to import largish (24MB) text files into a MySQL table. Each line looks like this:</p> <pre><code>1 1 0.008 0 0 0 0 0 </code></pre> <p>There are one or more spaces after each field, and the last field is tailed by about 36 spaces before the newline.</p> <p>How do I import such a file into MySQL? From the documentation it seems that LOAD DATA expects all fields to be terminated by exactly the same string. I have tried</p> <pre><code>LOAD DATA INFILE 'filename' INTO TABLE mytable FIELDS TERMINATED BY ' '; </code></pre> <p>but MySQL will interpret a sequence of more than one space as delimiting an empty field.</p> <p>Any ideas?</p>
[ { "answer_id": 156550, "author": "Jauco", "author_id": 6874, "author_profile": "https://Stackoverflow.com/users/6874", "pm_score": 4, "selected": true, "text": "sed 's/ \\+/ /g' thefile > thefile.new\n" }, { "answer_id": 156578, "author": "Ian", "author_id": 4396, "au...
2008/10/01
[ "https://Stackoverflow.com/questions/156532", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1428/" ]
156,552
<p>I want to implement a two-pass cache system:</p> <ul> <li><p>The first pass generates a PHP file, with all of the common stuff (e.g. news items), hardcoded. The database then has a cache table to link these with the pages (eg "index.php page=1 style=default"), the database also stores an uptodate field, which if false causes the first pass to rerun the next time the page is viewed.</p></li> <li><p>The second pass fills in the minor details, such as how long ago something(?) was, and mutable items like "You are logged in as...".</p></li> </ul> <p>However I'm not sure on a efficient implementation, that supports both cached and non-cached (e.g., search) pages, without a lot of code and several queries.</p> <p>Right now each time the page is loaded the PHP script is run regenerating the page. For pages like search this is fine, because most searches are different, but for other pages such as the index this is virtually the same for each hit, yet generates a large number of queries and is quite a long script.</p> <p>The problem is some parts of the page do change on a per-user basis, such as the "You are logged in as..." section, so simply saving the generated pages would still result in 10,000's of nearly identical pages.</p> <p>The main concern is with reducing the load on the server, since I'm on shared hosting and at this point can't afford to upgrade, but the site is using a sizeable portion of the servers CPU + putting a fair load on the MySQL server.</p> <p>So basically minimising how much has to be done for each page request, and not regenerating stuff like the news items on the index all the time seems a good start, compared to say search which is a far less static page.</p> <p>I actually considered hard coding the news items as plain HTML, but then that means maintaining them in several places (since they may be used for searches and the comments are on a page dedicated to that news item (i.e. news.php), etc).</p>
[ { "answer_id": 156561, "author": "Oli", "author_id": 12870, "author_profile": "https://Stackoverflow.com/users/12870", "pm_score": 1, "selected": false, "text": "if filename exists\n include filename\nelse\n generate results\n render to html (as string)\n write to file\n o...
2008/10/01
[ "https://Stackoverflow.com/questions/156552", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6266/" ]
156,563
<p>How do you setup an asp.net sql membership role/membership provider on a production machine? I'm trying to setup BlogEngine.NET and all the documentation says to use the ASP.NET Website Administration tool from Visual Studio but that isn't available on a production machine. Am I the first BlogEngine user to use it on a non-development box?</p> <p>The SQL server is completely blocked off from everything but the production box, I do have SQL Management Studio on there though.</p> <p>EDIT: I mean, how do you add new users/roles, not how do you create the tables. I've already ran aspnet_regsql to create the schema.</p> <p>EDIT2: MyWSAT doesn't work because it requires an initial user in the database as well. I need an application that will allow me to create new users in the membership database without any authentication, just a connection string.</p>
[ { "answer_id": 158238, "author": "ThatBloke", "author_id": 7050, "author_profile": "https://Stackoverflow.com/users/7050", "pm_score": 4, "selected": true, "text": "\n void Application_Start(object sender, EventArgs e) \n {\n // Code that runs on application startup\n\n ...
2008/10/01
[ "https://Stackoverflow.com/questions/156563", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17176/" ]
156,575
<p>I'm looking for a good TraceListener for .Net that supports rolling over the log file based on size limits. </p> <p><strong>Constraints</strong></p> <ul> <li>Uses .Net built in Trace logging</li> <li>Independent class or binary that's not part of some gigantic library</li> <li>Allows rolling over a log file based on size</li> </ul>
[ { "answer_id": 36406938, "author": "Ostati", "author_id": 2654100, "author_profile": "https://Stackoverflow.com/users/2654100", "pm_score": 4, "selected": false, "text": "<system.diagnostics>\n <sources>\n <source name=\"System.Net\">\n <listeners>\n <add name=\"System.Ne...
2008/10/01
[ "https://Stackoverflow.com/questions/156575", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17222/" ]
156,582
<p>I started using <a href="http://www.codeplex.com/SHFB" rel="noreferrer">Sandcastle</a> some time ago to generate a Documentation Website for one of our projects. It's working quite well but we've always only written documentation for classes, methods, properties (...) in our project and had completely separate documentation for the overall project and project parts/modules/namespaces. It would be nice if I could merge that documentation together and add respective documentation to the generated helper files but I can't figure out how to do it.</p> <p>Just adding comments to the namespace declaration doesn't seem to work (C#):</p> <pre><code>/// &lt;summary&gt; /// My short namespace description /// &lt;/summary&gt; namespace MyNamespace { ... } </code></pre> <p>Does anyone know how to do this? I know it's possible somehow and it would be really nice to have... :)</p>
[ { "answer_id": 156726, "author": "Rinat Abdullin", "author_id": 47366, "author_profile": "https://Stackoverflow.com/users/47366", "pm_score": 3, "selected": false, "text": "<namespaceSummaryItem name=\"System\" isDocumented=\"True\">\n Generic interfaces and helper classes.\n</namespa...
2008/10/01
[ "https://Stackoverflow.com/questions/156582", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5005/" ]
156,584
<p>I've seen a few examples on how to do build deployment, however I have something unique that I'd like to do:</p> <ol> <li>Deploy the build to a folder that has the build number (eg. Project\Builds\8423)</li> <li>Alter the version number in the .NET AssmblyInfo.cs to match the build number</li> </ol> <p>Has anyone done this before with .NET projects using NAnt + CruiseControl.net?</p>
[ { "answer_id": 163518, "author": "Mike", "author_id": 2848, "author_profile": "https://Stackoverflow.com/users/2848", "pm_score": 0, "selected": false, "text": "<AssemblyInfo CodeLanguage=\"C#\"\n OutputFile=\"%(YourProjects.RootDir)%(Directory)Properties\\AssemblyInfo.cs\"\n Assem...
2008/10/01
[ "https://Stackoverflow.com/questions/156584", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17222/" ]
156,585
<p>I'm just wondering if there can be a case where the hostname can be successfully resolved but the returned hostEntry.AddressList is empty.</p> <p>Currently I'm doing something like this:</p> <pre><code>IPHostEntry hostEntry = Dns.GetHostEntry("some.hostname.tld"); if (hostEntry.AddressList.Count() &lt; 1) { // can that ever happen? throw new ArgumentException("hostName has no assigned IP-Address"); } TcpClient client = new TcpClient(hostEntry.AddressList[0], 1234); </code></pre> <p>My assumption is that Dns.GetHostEntry either throws an exception if the hostname is not found or otherwise the AddressList is nonempty, but I'm not sure about that.</p>
[ { "answer_id": 156638, "author": "mdb", "author_id": 8562, "author_profile": "https://Stackoverflow.com/users/8562", "pm_score": 2, "selected": true, "text": "InternalGetHostByName(string hostName, bool includeIPv6)" } ]
2008/10/01
[ "https://Stackoverflow.com/questions/156585", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21038/" ]
156,586
<p>We are using fmt:setBundle to load a resource bundle from a database (we extended the ResourceBundle class to do that). When we modify a value in database, we have to reload the web server to display the new value on the web app.</p> <p>Is there any simple way to use the new value without restarting the web server ?</p> <p>(We do <strong>not</strong> want to always look up the value from database but we would like to invalidate the cache, for example by calling a special 'admin' URL)</p> <p>EDIT : We are using JDK 1.4, so I would prefer a solution on that version. :)</p>
[ { "answer_id": 156675, "author": "WMR", "author_id": 2844, "author_profile": "https://Stackoverflow.com/users/2844", "pm_score": 3, "selected": false, "text": "getTimeToLive()" }, { "answer_id": 55914608, "author": "y.hussain", "author_id": 5874302, "author_profile": ...
2008/10/01
[ "https://Stackoverflow.com/questions/156586", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3122/" ]
156,610
<p>I have a requirement to be able to provide a flex component in English and several asian languages. I have looked at the flex documentation and it seems that I have to build several swf's, which feels wrong. </p> <p>Does anyone know of a straightforward and practical way of bundling string resources in different languages and handling the fonts?</p>
[ { "answer_id": 156631, "author": "Nadav", "author_id": 23094, "author_profile": "https://Stackoverflow.com/users/23094", "pm_score": 0, "selected": false, "text": "ResourceBundle" }, { "answer_id": 156718, "author": "Theo", "author_id": 1109, "author_profile": "https:...
2008/10/01
[ "https://Stackoverflow.com/questions/156610", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24039/" ]
156,641
<p>I have a table of users which has a username column consisting of a six digit number e.g 675381, I need to prepend a zero to each of these usernames e.g. 0675381 would be the final output of the previous example, is there a query that could handle this?</p>
[ { "answer_id": 156656, "author": "daniels", "author_id": 9789, "author_profile": "https://Stackoverflow.com/users/9789", "pm_score": 6, "selected": true, "text": "UPDATE Tablename SET Username = Concat('0', Username);\n" }, { "answer_id": 156657, "author": "f13o", "author...
2008/10/01
[ "https://Stackoverflow.com/questions/156641", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13658/" ]
156,650
<p>When reviewing, I sometimes encounter this kind of loop:</p> <pre><code>i = begin while ( i != end ) { // ... do stuff if ( i == end-1 (the one-but-last element) ) { ... do other stuff } increment i } </code></pre> <p>Then I ask the question: would you write this?</p> <pre><code>i = begin mid = ( end - begin ) / 2 // (the middle element) while ( i != end ) { // ... do stuff if ( i &gt; mid ) { ... do other stuff } increment i } </code></pre> <p>In my opinion, this beats the intention of writing a loop: you loop because there is something common to be done for each of the elements. Using this construct, for some of the elements you do something different. So, I conclude, you need a separate loop for those elements:</p> <pre><code>i = begin mid = ( end - begin ) / 2 //(the middle element) while ( i != mid ) { // ... do stuff increment i } while ( i != end ) { // ... do stuff // ... do other stuff increment i } </code></pre> <p>Now I even saw a <a href="https://stackoverflow.com/questions/151046/c-last-loop-iteration-stl-map-iterator">question</a> on SO on how to write the <code>if</code>-clause in a nice way... And I got sad: something isn't right here.</p> <p>Am I wrong? If so, what's so good about cluttering the loop body with special cases, which you are aware of upfront, at coding time?</p>
[ { "answer_id": 156669, "author": "Matthias Winkelmann", "author_id": 4494, "author_profile": "https://Stackoverflow.com/users/4494", "pm_score": 4, "selected": false, "text": "for(i=0;i<elements.size;i++) {\n if (i>0) {\n string += ','\n }\n string += elements[i]\n}\n" }, {...
2008/10/01
[ "https://Stackoverflow.com/questions/156650", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6610/" ]
156,683
<p>I would like to know what of the many XSLT engines out there works well with Perl.</p> <p>I will use Apache (2.0) and Perl, and I want to obtain PDFs and XHTMLs.</p> <p>I'm new to this kind of projects so any comment or suggestion will be welcome.</p> <p>Thanks.</p> <hr> <p>Doing a simple search on Google I found a lot and I suppose that there are to many more.</p> <ul> <li><a href="http://www.mod-xslt2.com/" rel="noreferrer">http://www.mod-xslt2.com/</a></li> <li><a href="http://xml.apache.org/xalan-j/" rel="noreferrer">http://xml.apache.org/xalan-j/</a></li> <li><a href="http://saxon.sourceforge.net/" rel="noreferrer">http://saxon.sourceforge.net/</a></li> <li><a href="http://www.dopscripts.com/xslt_parser.html" rel="noreferrer">http://www.dopscripts.com/xslt_parser.html</a></li> </ul> <p>Any comment on your experiences will be welcome.</p>
[ { "answer_id": 156870, "author": "Penfold", "author_id": 11952, "author_profile": "https://Stackoverflow.com/users/11952", "pm_score": 6, "selected": true, "text": " use XML::LibXSLT;\n use XML::LibXML;\n\n my $parser = XML::LibXML->new();\n my $xslt = XML::LibXSLT->new();\n\n my $s...
2008/10/01
[ "https://Stackoverflow.com/questions/156683", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19689/" ]