qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
217,955
<p>What's the best way (or tool) on the Windows (Vista) command line to get size and modification time for a file on a remote webserver, without downloading it?</p>
[ { "answer_id": 217971, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 4, "selected": false, "text": "Invoke-WebRequest -Method Head" }, { "answer_id": 217972, "author": "Vinko Vrsalovic", "author_id": 5190, ...
2008/10/20
[ "https://Stackoverflow.com/questions/217955", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29549/" ]
217,957
<p>How do I print debug messages in the Google Chrome JavaScript Console?</p> <p>Please note that the JavaScript Console is not the same as the JavaScript Debugger; they have different syntaxes AFAIK, so the <strong>print</strong> command in JavaScript Debugger will not work here. In the JavaScript Console, <code>print()</code> will send the parameter to the printer.</p>
[ { "answer_id": 2757552, "author": "Delan Azabani", "author_id": 330644, "author_profile": "https://Stackoverflow.com/users/330644", "pm_score": 7, "selected": false, "text": "if (!window.console) console = {};\nconsole.log = console.log || function(){};\nconsole.warn = console.warn || fu...
2008/10/20
[ "https://Stackoverflow.com/questions/217957", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8954/" ]
217,960
<p>How do I generate friendly URLs within the ASP.NET MVC Framework? For example, we've got a URL that looks like this:</p> <pre>http://site/catalogue/BrowseByStyleLevel/1</pre> <p>The 1 is Id of the study level (Higher in this case) to browse, but I'l like to reformat the URL in the same way StackOverflow does it.</p> <p>For example, these two URLs will take you to the same place:</p> <blockquote> <p><a href="https://stackoverflow.com/questions/119323/nested-for-loops-in-different-languages">https://stackoverflow.com/questions/119323/nested-for-loops-in-different-languages</a></p> <p><a href="https://stackoverflow.com/questions/119323/">https://stackoverflow.com/questions/119323/</a></p> </blockquote> <p><strong>EDIT:</strong> The friendly part of the url is referred to as a <em>slug</em>.</p>
[ { "answer_id": 217991, "author": "Moran Helman", "author_id": 1409636, "author_profile": "https://Stackoverflow.com/users/1409636", "pm_score": 1, "selected": false, "text": " routes.MapRoute(\n \"Default\", // Route name\n \"{controller}/{action}/{...
2008/10/20
[ "https://Stackoverflow.com/questions/217960", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5791/" ]
217,961
<p>Is there a way to Deserialize Expressions in C#, I would like to store Expressions in a Database and load them at run time.</p>
[ { "answer_id": 3682878, "author": "Jonathan Parker", "author_id": 4504, "author_profile": "https://Stackoverflow.com/users/4504", "pm_score": 2, "selected": false, "text": "IQuerayble<T>" } ]
2008/10/20
[ "https://Stackoverflow.com/questions/217961", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18619/" ]
217,964
<p>I need to migrate Access databases to SQL Server 2005. Since this needs to be done from within a setup so that a customers' installation is transparently migrated to SQL Server 2005, I wonder if it is possible to automate the SSMA toolkit from Microsoft.</p>
[ { "answer_id": 3682878, "author": "Jonathan Parker", "author_id": 4504, "author_profile": "https://Stackoverflow.com/users/4504", "pm_score": 2, "selected": false, "text": "IQuerayble<T>" } ]
2008/10/20
[ "https://Stackoverflow.com/questions/217964", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23369/" ]
217,968
<p>I am using a satellite assembly to hold all the localization resources in a C# application.</p> <p>What I need to do is create a menu in the GUI with all the available languages that exists for the application. Is there any way to get information dynamically?</p>
[ { "answer_id": 1083120, "author": "Shimmy Weitzhandler", "author_id": 75500, "author_profile": "https://Stackoverflow.com/users/75500", "pm_score": 3, "selected": true, "text": "public static string[] GetInstalledCultures()\n{\n List<string> cultures = new List<string>();\n foreach...
2008/10/20
[ "https://Stackoverflow.com/questions/217968", "https://Stackoverflow.com", "https://Stackoverflow.com/users/66654/" ]
217,969
<p>I was trying to test code using com class to display Word files but I cannot seem to get the answer and still searching. I get errors and sometimes, programs do not display anything at all. Please give me some ideas. I'm working with PHP 4.</p>
[ { "answer_id": 217981, "author": "Paul de Vrieze", "author_id": 4100, "author_profile": "https://Stackoverflow.com/users/4100", "pm_score": 0, "selected": false, "text": "<object>" }, { "answer_id": 56308332, "author": "user11555821", "author_id": 11555821, "author_pr...
2008/10/20
[ "https://Stackoverflow.com/questions/217969", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
217,977
<p>I have an XML reader on this XML string:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt; &lt;story id="1224488641nL21535800" date="20 Oct 2008" time="07:44"&gt; &lt;title&gt;PRESS DIGEST - PORTUGAL - Oct 20&lt;/title&gt; &lt;text&gt; &lt;p&gt; LISBON, Oct 20 (Reuters) - Following are some of the main stories in Portuguese newspapers on Monday. Reuters has not verified these stories and does not vouch for their accuracy. &lt;/p&gt; &lt;p&gt;More HTML stuff here&lt;/p&gt; &lt;/text&gt; &lt;/story&gt; </code></pre> <p>I created an XSD and a corresponding class for deserialization.</p> <pre><code>[System.Xml.Serialization.XmlRootAttribute(Namespace="", IsNullable=false)] public class story { [System.Xml.Serialization.XmlAttributeAttribute()] public string id; [System.Xml.Serialization.XmlAttributeAttribute()] public string date; [System.Xml.Serialization.XmlAttributeAttribute()] public string time; public string title; public string text; } </code></pre> <p>I then create an instance of the class using the <code>Deserialize</code> method of XmlSerializer.</p> <pre><code>XmlSerializer ser = new XmlSerializer(typeof(story)); return (story)ser.Deserialize(xr); </code></pre> <p>Now, the <code>text</code> member of <code>story</code> is always null. How do I change my <code>story</code> class so that the XML is parsed as expected?</p> <p><strong>EDIT:</strong> </p> <p>Using an XmlText does not work and I have no control over the XML I'm parsing.</p>
[ { "answer_id": 218049, "author": "Sklivvz", "author_id": 7028, "author_profile": "https://Stackoverflow.com/users/7028", "pm_score": 1, "selected": false, "text": "// ...\n[XmlElement(\"HACK - this should never match anything\")]\npublic string text;\n// ...\n" }, { "answer_id": ...
2008/10/20
[ "https://Stackoverflow.com/questions/217977", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7028/" ]
217,980
<p>In the documentation of hardware that allows us to control it via UDP/IP, I found the following fragment:</p> <blockquote> <p>In this communication protocol, DWORD is a 4 bytes data, WORD is a 2 bytes data, BYTE is a single byte data. The storage format is little endian, namely 4 bytes (32bits) data is stored as: d7-d0, d15-d8, d23-d16, d31-d24; double bytes (16bits) data is stored as: d7-d0 , d15-d8.</p> </blockquote> <p>I am wondering how this translates to C#? Do I have to convert stuff before sending it over? For example, if I want to send over a 32 bit integer, or a 4 character string?</p>
[ { "answer_id": 217987, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 4, "selected": false, "text": "bool le = BitConverter.IsLittleEndian;\n" }, { "answer_id": 218004, "author": "gbjbaanb", "author_id"...
2008/10/20
[ "https://Stackoverflow.com/questions/217980", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28149/" ]
218,003
<p>I was wondering if there is a native C++ (or STL/Boost) function which will search a CString for a specified string?</p> <p>e.g.</p> <pre><code>CString strIn = "Test number 1"; CString strQuery = "num"; bool fRet = SomeFn(strIn, StrQuery); if( fRet == true ) { // Ok strQuery was found in strIn ... </code></pre> <p>I have found a small number of functions like CompareNoCase IndexOf etc... but so far they don't really do what I want them to do (or use CLR/.Net)</p> <p>Thanks!</p>
[ { "answer_id": 218014, "author": "gbjbaanb", "author_id": 13744, "author_profile": "https://Stackoverflow.com/users/13744", "pm_score": 5, "selected": true, "text": "CString strIn = \"test number 1\";\nint index = strIn.Find(\"num\");\nif (index != -1)\n // ok, found\n" } ]
2008/10/20
[ "https://Stackoverflow.com/questions/218003", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18664/" ]
218,023
<p>I have committed, and pushed, several patches: A1-->A2-->A3-->A4 (HEAD)</p> <p>Everyone's pulled these changesets into their local copy.</p> <p>Now we want to "roll back" to A2, and continue developing from there - essentially throwing away A3 and A4. What's the best way to do this?</p>
[ { "answer_id": 218050, "author": "freespace", "author_id": 8297, "author_profile": "https://Stackoverflow.com/users/8297", "pm_score": 3, "selected": false, "text": "git-revert" }, { "answer_id": 221137, "author": "Aristotle Pagaltzis", "author_id": 9410, "author_prof...
2008/10/20
[ "https://Stackoverflow.com/questions/218023", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18666/" ]
218,024
<p>I have a question with fluent interfaces.</p> <p>We have some objects that are used as parameter objects for a SQL interface, here's an example:</p> <pre><code>using (DatabaseCommand cmd = conn.CreateCommand( "SELECT A, B, C FROM tablename WHERE ID = :ID", SqlParameter.Int32(":ID", 1234))) { ... } </code></pre> <p>For some of these parameters, I'd like to enable some specialized options, but instead of adding more properties to the Int32 method (which is just one of many), I thought I'd look into fluent interfaces.</p> <p>Here's an example where I've added what I am looking into:</p> <pre><code>SqlParameter.Int32(":ID", 1234).With(SqlParameterOption .Substitute .Precision(15) ) </code></pre> <p>I know these two options doesn't make sense for this type of parameter, but that's not what the question is about.</p> <p>In the above case, Substitute would have to be a static property (or method if I just add some parenthesis) on the SqlParameterOption class, whereas Precision would have to be an instance method.</p> <p>What if I reorder them?</p> <pre><code>SqlParameter.Int32(":ID", 1234).With(SqlParameterOption .Precision(15) .Substitute ) </code></pre> <p>Then Substitute would have to be the instance property and Precision the static method. This won't compile of course, I can't have both a static and a non-static property or method with the same name.</p> <p>How do I do this? Am I completely on the wrong track here?</p> <p>While re-reading the question, I had an idea, would this different syntax below make more sense?</p> <pre><code>SqlParameter.Int32(":ID", 1234).With .Precision(15) .Substitute </code></pre> <p>In this case both would be instance methods on whatever With returns, which would be a specialized class or interface for SqlParameter options like this. I'm not sure I'd like to dump the <em>.With</em> part, as this would expose all methods of the object, instead of just the <em>fluent</em> ones.</p> <p>Advice and some good url's would be most welcome, I've scoured over many examples, but they tend to show examples like this:</p> <pre><code>order .AddFreeShipping() .IncludeItem(15) .SuppressTax(); </code></pre> <p>(lifted from <a href="http://blog.troyd.net/PermaLink,guid,5cdd4862-857a-488d-a577-c6d21b548f19.aspx" rel="nofollow noreferrer">this page</a>)</p> <hr> <p><strong>Edit</strong>: Followup after responses From <a href="https://stackoverflow.com/users/1659/marxidad">@marxidad</a>:</p> <pre><code>class SqlParameterOption { public SqlParameterOption Precision(int p) {/* ... */; return this;} public SqlParameterOption Substitute() {/* ... */; return this;} /* ... */ } /* ... */ SqlParameter.Int32(":ID", 1234).With(new SqlParameterOption() .Precision(15) .Substitute()); </code></pre> <p>With this approach, With would have to take the object, and apply it to the parameter. I'm fine with that.</p> <p>If I used the syntax I added as an example, it would be like this:</p> <pre><code>SqlParameter.Int32(":ID", 1234).With .Precision(15) .Substitute()); </code></pre> <p>In this case, With wouldn't know when the chain ended, so each option would have to apply its effect directly.</p> <p>What is preferred? That the options build up an effect object that will have to be applied later, or that each effect applies its effect directly?</p> <p><strong>My decision</strong>: As <a href="https://stackoverflow.com/users/1659/marxidad">@marxidad</a> says, if the changes are irreversible, and could potentially be subject to a reversal, building up state and failing at some point with an exception is the way I'll go.</p> <p>However, in this case, I'm going with a simpler approach that modifies the SqlParameter object directly.</p> <p>In this case, my code will look like this:</p> <pre><code>SqlParameter.Int32(":ID", 1234).With .Precision(15) .Substitute()); </code></pre> <p><strong>Edit:</strong> Gah, that's how it goes when I focus on just one thing.</p> <p>I can't use that syntax, I'll go with the following, as suggested by <a href="https://stackoverflow.com/users/1659/marxidad">@marxidad</a>:</p> <pre><code>SqlParameter.Int32(":ID", 1234).With(new SqlParameterOption() .Precision(15) .Substitute()); </code></pre> <p>The reason is of course that the method that takes the SqlParameter object as an argument is unable to cope with the object returned by With, so although the SqlParameter object is constructed and set up properly, it became incompatible with the intended usage.</p>
[ { "answer_id": 218036, "author": "Mark Cidade", "author_id": 1659, "author_profile": "https://Stackoverflow.com/users/1659", "pm_score": 4, "selected": true, "text": "SqlParameterOption's" } ]
2008/10/20
[ "https://Stackoverflow.com/questions/218024", "https://Stackoverflow.com", "https://Stackoverflow.com/users/267/" ]
218,025
<p>I quite often see on the Internet various complaints that other peoples examples of currying are not currying, but are actually just partial application.</p> <p>I've not found a decent explanation of what partial application is, or how it differs from currying. There seems to be a general confusion, with equivalent examples being described as currying in some places, and partial application in others.</p> <p>Could someone provide me with a definition of both terms, and details of how they differ?</p>
[ { "answer_id": 218055, "author": "Mark Cidade", "author_id": 1659, "author_profile": "https://Stackoverflow.com/users/1659", "pm_score": 9, "selected": true, "text": "function f(x,y,z) { z(x(y));}\n" }, { "answer_id": 10443057, "author": "dodgy_coder", "author_id": 507950...
2008/10/20
[ "https://Stackoverflow.com/questions/218025", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1577190/" ]
218,027
<p>When debugging, a trick I do whenever I want to exit the current method without running of its any statements, I move the current execution pointer to the end of the method, then click F10/11.</p> <p>Is there a keyboard shortcut (or can I program one) to accomplish this?</p> <p>(I don't mean shift-F11 (step out) - that does run all the code until the method's end, which I do not want).</p>
[ { "answer_id": 220528, "author": "Bradley Grainger", "author_id": 23633, "author_profile": "https://Stackoverflow.com/users/23633", "pm_score": 3, "selected": true, "text": "Ctrl+M, Ctrl+M" } ]
2008/10/20
[ "https://Stackoverflow.com/questions/218027", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11236/" ]
218,035
<p>Guys, can someone give me a brief run through of how to change the background colour of a CEdit control at runtime? I want to be able to change the background to red if the field is zero length and the normal white otherwise.</p>
[ { "answer_id": 218052, "author": "gbjbaanb", "author_id": 13744, "author_profile": "https://Stackoverflow.com/users/13744", "pm_score": 4, "selected": true, "text": "class CColorEdit : public CEdit\n{\n ....\n CBrush m_brBkgnd;\n afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor)\n ...
2008/10/20
[ "https://Stackoverflow.com/questions/218035", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18664/" ]
218,042
<p>I want to show the publish date in the About dialog.</p>
[ { "answer_id": 218114, "author": "splattne", "author_id": 6461, "author_profile": "https://Stackoverflow.com/users/6461", "pm_score": 2, "selected": false, "text": "FileInfo oMyFile = new\n FileInfo(Assembly.GetExecutingAssembly().Location);\n\nDateTime oBuildDate = oMyFile.LastWriteTi...
2008/10/20
[ "https://Stackoverflow.com/questions/218042", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11538/" ]
218,043
<p>I'm trying to get the start element and the end element of a selection and the offset of the selection in each, i do this in firefox as follows:</p> <pre><code>var delselection = window.getSelection(); var startOffset = delselection.anchorOffset; var endOffset = delselection.focusOffset; var startNode = delselection.anchorNode.parentNode; var endNode = delselection.focusNode.parentNode; </code></pre> <p>However i have no idea how to do this in IE6, anyone able to point me in the right direction?</p>
[ { "answer_id": 1945890, "author": "Roy Leban", "author_id": 189641, "author_profile": "https://Stackoverflow.com/users/189641", "pm_score": 1, "selected": false, "text": "var selObj = null;\nvar selSave = null;\nvar selSaveEnd = null;\n\nfunction SaveSelection(obj) {\n if (obj.selecti...
2008/10/20
[ "https://Stackoverflow.com/questions/218043", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11198/" ]
218,057
<p>Without routing, <code>HttpContext.Current.Session</code> is there so I know that the <code>StateServer</code> is working. When I route my requests, <code>HttpContext.Current.Session</code> is <code>null</code> in the routed page. I am using .NET 3.5 sp1 on IIS 7.0, without the MVC previews. It appears that <code>AcquireRequestState</code> is never fired when using the routes and so the session variable isn't instantiated/filled.</p> <p>When I try to access the Session variables, I get this error:</p> <p><code>base {System.Runtime.InteropServices.ExternalException} = {"Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive. Please also make sure that System.Web.SessionStateModule or a custom session state module is included in the &lt;configuration&gt;.</code></p> <p>While debugging, I also get the error that the <code>HttpContext.Current.Session</code> is not accessible in that context.</p> <p>--</p> <p>My <code>web.config</code> looks like this:</p> <pre><code>&lt;configuration&gt; ... &lt;system.web&gt; &lt;pages enableSessionState="true"&gt; &lt;controls&gt; ... &lt;/controls&gt; &lt;/pages&gt; ... &lt;/system.web&gt; &lt;sessionState cookieless="AutoDetect" mode="StateServer" timeout="22" /&gt; ... &lt;/configuration&gt; </code></pre> <p>Here's the IRouteHandler implementation:</p> <pre><code>public class WebPageRouteHandler : IRouteHandler, IRequiresSessionState { public string m_VirtualPath { get; private set; } public bool m_CheckPhysicalUrlAccess { get; set; } public WebPageRouteHandler(string virtualPath) : this(virtualPath, false) { } public WebPageRouteHandler(string virtualPath, bool checkPhysicalUrlAccess) { m_VirtualPath = virtualPath; m_CheckPhysicalUrlAccess = checkPhysicalUrlAccess; } public IHttpHandler GetHttpHandler(RequestContext requestContext) { if (m_CheckPhysicalUrlAccess &amp;&amp; !UrlAuthorizationModule.CheckUrlAccessForPrincipal( m_VirtualPath, requestContext.HttpContext.User, requestContext.HttpContext.Request.HttpMethod)) { throw new SecurityException(); } string var = String.Empty; foreach (var value in requestContext.RouteData.Values) { requestContext.HttpContext.Items[value.Key] = value.Value; } Page page = BuildManager.CreateInstanceFromVirtualPath( m_VirtualPath, typeof(Page)) as Page;// IHttpHandler; if (page != null) { return page; } return page; } } </code></pre> <p>I've also tried to put <code>EnableSessionState="True"</code> on the top of the aspx pages but still, nothing.</p> <p>Any insights? Should I write another <code>HttpRequestHandler</code> that implements <code>IRequiresSessionState</code>?</p> <p>Thanks.</p>
[ { "answer_id": 218068, "author": "Bogdan Maxim", "author_id": 23795, "author_profile": "https://Stackoverflow.com/users/23795", "pm_score": 0, "selected": false, "text": " <sessionstate mode=\"StateServer\" timeout=\"20\" server=\"127.0.0.1\" port=\"42424\" />\n" }, { "answer_id"...
2008/10/20
[ "https://Stackoverflow.com/questions/218057", "https://Stackoverflow.com", "https://Stackoverflow.com/users/57936/" ]
218,060
<p>Is there a class in the standard library of .NET that gives me the functionality to create random variables that follow Gaussian distribution? </p>
[ { "answer_id": 218600, "author": "yoyoyoyosef", "author_id": 25571, "author_profile": "https://Stackoverflow.com/users/25571", "pm_score": 9, "selected": true, "text": "Random rand = new Random(); //reuse this if you are generating many\ndouble u1 = 1.0-rand.NextDouble(); //uniform(0,1] ...
2008/10/20
[ "https://Stackoverflow.com/questions/218060", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23681/" ]
218,061
<p>I've recently searched how I could get the application's directory in Java. I've finally found the answer but I've needed surprisingly long because searching for such a generic term isn't easy. I think it would be a good idea to compile a list of how to achieve this in multiple languages.</p> <p>Feel free to up/downvote if you (don't) like the idea and <strong>please contribute</strong> if you like it.</p> <h2>Clarification:</h2> <p>There's a fine distinction between the <em>directory that contains the executable file</em> and the <em>current working directory</em> (given by <code>pwd</code> under Unix). I was originally interested in the former but feel free to post methods for determining the latter as well (clarifying which one you mean).</p>
[ { "answer_id": 218062, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 2, "selected": false, "text": "System.getProperty" }, { "answer_id": 218064, "author": "Konrad Rudolph", "author_id": 1968, "aut...
2008/10/20
[ "https://Stackoverflow.com/questions/218061", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1968/" ]
218,065
<p>I have a div with <code>overflow:hidden</code>, inside which I show a phone number as the user types it. The text inside the div is aligned to right and incoming characters are added to right as the text grows to left.</p> <p>But once the text is big enough not to fit in the div, last characters of the number is automatically cropped and the user cannot see the new characters she types.</p> <p>What I want to do is crop the left characters, like the div is showing the rightmost of its content and overflowing to the left side. How can I create this effect?</p> <p><img src="https://i.imgur.com/CRbCCPm.jpg" alt="overflowing phone number to left"></p>
[ { "answer_id": 218071, "author": "Rob Bell", "author_id": 2179408, "author_profile": "https://Stackoverflow.com/users/2179408", "pm_score": 8, "selected": true, "text": "direction: rtl;\n" }, { "answer_id": 678539, "author": "Community", "author_id": -1, "author_profi...
2008/10/20
[ "https://Stackoverflow.com/questions/218065", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31505/" ]
218,096
<p>We are monitoring the progress of a customized app (whose source is not under our control) which writes to a XML Manifest. At times , the application is stuck due to unable to write into the Manifest file. Although we are covering our traces by explicitly closing the file handle using File.Close and also creating the file variables in Using Blocks. But somehow it keeps happening. ( Our application is multithreaded and at most three threads might be accessing the file. ) Another interesting thing is that their app updates this manifest at three different events(add items, deleting items, completion of items) but we are only suffering about one event (completion of items). My code is listed here</p> <pre><code>using (var st = new FileStream(MenifestPath, FileMode.Open, FileAccess.Read)) { using (TextReader r = new StreamReader(st)) { var xml = r.ReadToEnd(); r.Close(); st.Close(); //................ Rest of our operations } } </code></pre>
[ { "answer_id": 218253, "author": "Zebra North", "author_id": 17440, "author_profile": "https://Stackoverflow.com/users/17440", "pm_score": 3, "selected": true, "text": "FILE_SHARE_READ | FILE_SHARE_WRITE" }, { "answer_id": 218315, "author": "Omer van Kloeten", "author_id"...
2008/10/20
[ "https://Stackoverflow.com/questions/218096", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17519/" ]
218,113
<p>One thing that always been a pain is to log SQL (JDBC) errors when you have a PreparedStatement instead of the query itself.</p> <p>You always end up with messages like:</p> <pre><code>2008-10-20 09:19:48,114 ERROR LoggingQueueConsumer-52 [Logger.error:168] Error executing SQL: [INSERT INTO private_rooms_bans (room_id, name, user_id, msisdn, nickname) VALUES (?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE room_id = ?, name = ?, user_id = ?, msisdn = ?, nickname = ?] </code></pre> <p>Of course I could write a helper method for retrieving the values and parsing/substitute the question marks with real values (and probably will go down that path if I don't get an outcome of this question), but I just wanted to know if this problem was resolved before by someone else and/or if is there any generic logging helper that would do that automagically for me.</p> <p><strong>Edited after a few answers:</strong></p> <p>The libraries provided so far seems to be suitable to logging the statements for debugging, which no doubt is useful. However, I am looking to a way of taking a PreparedStatement itself (not some subclass) and logging its SQL statement whenever an error occur. I wouldn't like to deploy a production app with an alternate implementation of PreparedStatement. </p> <p>I guess what I am looking for an utility class, not a PreparedStatement specialization.</p> <p>Thanks!</p>
[ { "answer_id": 3468960, "author": "user418544", "author_id": 418544, "author_profile": "https://Stackoverflow.com/users/418544", "pm_score": 4, "selected": true, "text": "jdbc.url=jdbc:log4jdbc:hsqldb:mem:sample\n" } ]
2008/10/20
[ "https://Stackoverflow.com/questions/218113", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14540/" ]
218,117
<p>Today when I was in computer organization class, teacher talked about something interesting to me. When it comes to talk about Why cache memory works, he said that:</p> <pre><code>for (i=0; i&lt;M; i++) for(j=0; j&lt;N; j++) X[i][j] = X[i][j] + K; //X is double(8 bytes) </code></pre> <p>it is not good to change the first line with the second. What is your opinions on this? And why it is like that?</p>
[ { "answer_id": 218152, "author": "Scottie T", "author_id": 6688, "author_profile": "https://Stackoverflow.com/users/6688", "pm_score": 2, "selected": false, "text": "do jj = 1,N\n do ii = 1,M\n x(ii,jj) = x(ii,jj) + K;\n enddo\nenddo\n" } ]
2008/10/20
[ "https://Stackoverflow.com/questions/218117", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26379/" ]
218,120
<p>I am interested in using Xaml with expression blend for creating user interfaces in an application. However, because of the limitations of the target architecture, I cannot use WPF or C#.</p> <p>So, what I am interested in is in any examples / existing projects or advice from anyone who has experiance of this technology on the use of Xaml in it's "Pure" form as a specification language not tied to WPF.</p> <p>Specific questions:</p> <p>1) Is it possible to use Blend + Xaml without the WPF elements, or without C# backing classes?</p> <p>2) Are there any other implementations of Xaml parsers etc. which use different architectures, and can they work with blend or similar tools.</p> <p>3) Are there alternative editor / designer tools which can help in this situation?</p> <p>I am aware of the MyXaml and MycroXaml projects, and have found a lot of resources on the web about Xaml, but 99% of it relates directly to WPF. This is fine for understanding the concepts of Xaml, but doesn't help with the implimentation I need.</p> <p>Many thanks!</p>
[ { "answer_id": 1030188, "author": "Andy Dent", "author_id": 53870, "author_profile": "https://Stackoverflow.com/users/53870", "pm_score": 1, "selected": false, "text": "windows = []\nREXML::XPath.each(doc, \"//Window\") do |xml|\n windows << Window.new(xml)\nend\n\n#... invoking ...\n\n...
2008/10/20
[ "https://Stackoverflow.com/questions/218120", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15667/" ]
218,122
<p>When using webforms the appropriate place to assign master pages to a page dynamically seems to be the pages PreInit event: </p> <pre><code>this.Master.MasterPageFile = "~/leaf.Master" </code></pre> <p>If nessasary, master pages in a hierarchy of nested master pages may be set here too:</p> <pre><code>this.Master.MasterPageFile = "~/leaf.Master" this.Master.Master.MasterPageFile = "~/root.Master" </code></pre> <p>Using the MVC framework you can set a single master page name dynamically using the controllers View method by passing the <em>masterName</em>, but how do you set other master pages higher up in the hierarchy?</p> <p><strong>Update</strong><br> Sorry I was not clear. </p> <p>By hierarchy i mean a chain of nested master pages, so how can i set the very top master page in a chain of nested master pages?</p> <p>For example we have a set up such that different customer types have different master pages and nested within this master page is an additional master page for specific user roles. We need to dynamically set the root customer master as well as the role master.</p>
[ { "answer_id": 218351, "author": "Craig Stuntz", "author_id": 7714, "author_profile": "https://Stackoverflow.com/users/7714", "pm_score": 2, "selected": false, "text": " ControllerBuilder.Current.SetControllerFactory(new MyControllerFactory());\n" } ]
2008/10/20
[ "https://Stackoverflow.com/questions/218122", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29547/" ]
218,123
<p>When I asked <a href="https://stackoverflow.com/questions/167575/should-a-project-manager-enforce-coding-standards">this question</a> I got almost always a definite yes you should have coding standards. </p> <p>What was the strangest coding standard rule that you were ever forced to follow?</p> <p>And by strangest I mean funniest, or worst, or just plain odd. </p> <p>In each answer, please mention which language, what your team size was, and which ill effects it caused you and your team.</p>
[ { "answer_id": 218135, "author": "Toon Krijthe", "author_id": 18061, "author_profile": "https://Stackoverflow.com/users/18061", "pm_score": 8, "selected": false, "text": "int appCount = 0; // Number of apples.\nint pearCount = 0; // Number of pears.\n" }, { "answer_id": 218142, ...
2008/10/20
[ "https://Stackoverflow.com/questions/218123", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3153/" ]
218,133
<p>I want to deserialize an object but don't know the class up front. So, consider the following code...</p> <pre><code>IFormatter formatter = new BinaryFormatter(); Stream stream = new FileStream("MyFile.bin", FileMode.Open, FileAccess.Read, FileShare.Read); MyObject obj = (MyObject)formatter.Deserialize(stream); </code></pre> <p>What could I do if I don't know the class up front? Say, for example "MyFile.bin" was a MyObject or a MyFoo. How do I determine which object to instantiate?</p> <p>Something like...</p> <pre><code>if (magic happens here == typeof(MyObject)) MyObject obj = (MyObject) formatter.Deserialize(stream); else if (more magic happens here == typeof(MyFoo)) MyFoo foo = (MyFoo)formatter.Deserialize(stream); </code></pre>
[ { "answer_id": 218141, "author": "leppie", "author_id": 15541, "author_profile": "https://Stackoverflow.com/users/15541", "pm_score": 4, "selected": true, "text": "object result = formatter.Deserialize(stream); \nType t = result.GetType();\n" }, { "answer_id": 218154, "author...
2008/10/20
[ "https://Stackoverflow.com/questions/218133", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3893/" ]
218,144
<p>I'm wrapping up a <code>Javascript</code> widget in a <code>Wicket</code> component. I want to let the JS side talk to the component. What I've got so far:</p> <p>Component in question goes like</p> <pre><code>talker = new GridAjaxBehavior(); this.add(talker); </code></pre> <p>in constructor</p> <p>and then, later on, puts something like</p> <pre><code>"var MyGridTalker = new talker(" + this.talker.getCallbackUrl() + ");"; </code></pre> <p>into the JS.</p> <p>where <code>GridAjaxBehavior</code> extends <code>AbstractDefaultAjaxBehavior</code>. I want GridAjaxBehavior to spit back some XML when the JS calls it. </p> <p>Am I doing this the right way? What should GridAjaxBehaviour do to spit back the XML?</p> <p>Thanks</p>
[ { "answer_id": 713544, "author": "Eric Ryan Harrison", "author_id": 79033, "author_profile": "https://Stackoverflow.com/users/79033", "pm_score": 0, "selected": false, "text": "\"var MyGridTalker = new talker(\" + this.talker.getCallbackUrl();" }, { "answer_id": 717457, "auth...
2008/10/20
[ "https://Stackoverflow.com/questions/218144", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29574/" ]
218,150
<p>If I need to throw an exception from within my application which of the built-in .NET exception classes can I use? Are they all fair game? When should I derive my own?</p>
[ { "answer_id": 218170, "author": "leppie", "author_id": 15541, "author_profile": "https://Stackoverflow.com/users/15541", "pm_score": 3, "selected": false, "text": "ArgumentException" }, { "answer_id": 218214, "author": "Konrad Rudolph", "author_id": 1968, "author_pro...
2008/10/20
[ "https://Stackoverflow.com/questions/218150", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1127460/" ]
218,155
<p>To put it simple, there's a simple java swing app that consists of JFrame with some components in it. One of the components is a JPanel that is meant to be replaced by another JPanel on user action.</p> <p>So, what's the correct way of doing such a thing? I've tried</p> <pre><code>panel = new CustomJPanelWithComponentsOnIt(); parentFrameJPanelBelongsTo.pack(); </code></pre> <p>but this won't work. What would you suggest?</p>
[ { "answer_id": 218259, "author": "Tom Hawtin - tackline", "author_id": 4725, "author_profile": "https://Stackoverflow.com/users/4725", "pm_score": 5, "selected": false, "text": "frame.setContentPane(newContents());\nframe.revalidate(); // frame.pack() if you want to resize.\n" }, { ...
2008/10/20
[ "https://Stackoverflow.com/questions/218155", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15187/" ]
218,156
<p>The following code</p> <pre><code>number=1 if [[ $number =~ [0-9] ]] then echo matched fi </code></pre> <p>works. If I try to use quotes in the regex, however, it stops:</p> <pre><code>number=1 if [[ $number =~ "[0-9]" ]] then echo matched fi </code></pre> <p>I tried <code>"\[0-9\]"</code>, too. What am I missing?</p> <p>Funnily enough, <a href="http://www.tldp.org/LDP/abs/html/abs-guide.html#REGEXMATCHREF" rel="noreferrer">bash advanced scripting guide</a> suggests this should work.</p> <p>Bash version 3.2.39.</p>
[ { "answer_id": 218217, "author": "Vinko Vrsalovic", "author_id": 5190, "author_profile": "https://Stackoverflow.com/users/5190", "pm_score": 8, "selected": true, "text": "$ bash --version\nGNU bash, version 3.2.39(1)-release (i486-pc-linux-gnu)\nCopyright (C) 2007 Free Software Foundatio...
2008/10/20
[ "https://Stackoverflow.com/questions/218156", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8437/" ]
218,158
<p>Is there a nicer way of styling a <code>&lt;hr /&gt;</code> tag using CSS, that is cross-browser consistent and doesn't involve wrapping a <code>div</code> around it? I'm struggling to find one.</p> <p>The best way I have found, is as follows:</p> <p><strong>CSS</strong></p> <pre><code>.hr { height:20px; background: #fff url(nice-image.gif) no-repeat scroll center; } hr { display:none; } </code></pre> <p><strong>HTML</strong></p> <pre><code>&lt;div class="hr"&gt;&lt;hr /&gt;&lt;/div&gt; </code></pre>
[ { "answer_id": 218165, "author": "vfilby", "author_id": 24279, "author_profile": "https://Stackoverflow.com/users/24279", "pm_score": 1, "selected": false, "text": "block" }, { "answer_id": 218221, "author": "Borgar", "author_id": 27388, "author_profile": "https://Sta...
2008/10/20
[ "https://Stackoverflow.com/questions/218158", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26107/" ]
218,162
<p>I have an XHTML strict page that has an invisible div that is controlled by Javascript. The div is set to transparent and visible by the script and a mouseover event to make the div opaque on hover.</p> <p>When someone using a browser (or firefox with noscript) without javascript the div simply remains invisible. The problem with this is that I do not want the content to be inaccessible. I also do not want to leave the div visible then use the script to make it transparent as the div is located at the bottom of the document and it causes a noticeable flicker whenever a page loads.</p> <p>I have tried using noscript tags to embed an additional style sheet that is only loaded for people without the luxury of Javascript but this fails the XHTML strict validation. Is there any other way to include extra styling information inside a noscript block that is XHTML valid?</p> <p><strong>Ed:</strong></p> <p>With a simple test case I get a validation error of: <strong>document type does not allow element "style" here.</strong> This is with an empty XHTML Strict document with a style element inside a noscript element. The noscript is inside the body.</p>
[ { "answer_id": 218176, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 0, "selected": false, "text": "<noscript>" }, { "answer_id": 218917, "author": "Bobby Jack", "author_id": 5058, "author_profile": "https...
2008/10/20
[ "https://Stackoverflow.com/questions/218162", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11753/" ]
218,174
<p>I have the following arrays in PHP (okay they are a bit bigger but the idea is what counts).</p> <pre><code>$array1 = array(1 =&gt; 'a', 2 =&gt; 'b'); $array2 = array(3 =&gt; 'c', 4 =&gt; 'd'); </code></pre> <p>Essentially I want to combine the two arrays as if it were something like this</p> <pre><code>$array3 = array(1 =&gt; 'a', 2 =&gt; 'b', 3 =&gt; 'c', 4 =&gt; 'd'); </code></pre> <p>Thanks</p>
[ { "answer_id": 218198, "author": "Stefan Gehrig", "author_id": 11354, "author_profile": "https://Stackoverflow.com/users/11354", "pm_score": 6, "selected": true, "text": "$array3 = $array1 + $array2;\n" } ]
2008/10/20
[ "https://Stackoverflow.com/questions/218174", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1384652/" ]
218,181
<p>Is there a built-in way to URL encode a string in Excel VBA or do I need to hand roll this functionality? </p>
[ { "answer_id": 218199, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 8, "selected": true, "text": "URLEncode()" }, { "answer_id": 3812363, "author": "Tom", "author_id": 460541, "author_profile": "https:...
2008/10/20
[ "https://Stackoverflow.com/questions/218181", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4023/" ]
218,190
<p>Object-relational mapping has been well discussed, including on here. I have experience with a few approaches and the pitfalls and compromises. True resolution seems like it requires changes to the OO or relational models themselves.</p> <p>If using a functional language, does the same problem present itself? It seems to me that these two paradigms should fit together better than OO and RDBMS. The idea of thinking in sets in an RDBMS seems to mesh with the automatic parallelism that functional approaches seem to promise. </p> <p>Does anyone have any interesting opinions or insights? What's the state of play in the industry?</p>
[ { "answer_id": 219446, "author": "Jonathan Tran", "author_id": 12887, "author_profile": "https://Stackoverflow.com/users/12887", "pm_score": 2, "selected": false, "text": "create table temp_foo_1 as select ...;\ncreate table temp_foo_2 as select ...;\n...\ncreate table foo_results as\n ...
2008/10/20
[ "https://Stackoverflow.com/questions/218190", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14663/" ]
218,208
<p>I have a Makefile building many C files with long long command lines and we've cleaned up the output by having rules such as:</p> <pre><code>.c${MT}.doj: @echo "Compiling $&lt;";\ $(COMPILER) $(COPTS) -c -o $@ $&lt; </code></pre> <p>Now this is great as the @ suppresses the compilation line being emitted. But when we get an error, all we get is the error message, no command line. Can anyone think of a "neat" way to emit the command line? All I can think of doing is echoing it to a file and have a higher level make catch the error and cat the file. Hacky I know.</p>
[ { "answer_id": 218295, "author": "Rajish", "author_id": 29576, "author_profile": "https://Stackoverflow.com/users/29576", "pm_score": 4, "selected": true, "text": ".c${MT}.doj:\n @echo \"Compiling $<\";\\\n $(COMPILER) $(COPTS) -c -o $@ $< \\\n || echo \"Error in c...
2008/10/20
[ "https://Stackoverflow.com/questions/218208", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
218,219
<p>I need to change in a text input the character '.' to ',' while typing. In IE I change the keyCode event property in the keypress event, like this</p> <pre><code>document.getElementById('mytext').onkeypress = function (evt) { var e = evt || window.event; if (e.keyCode &amp;&amp; e.keyCode==46) e.keyCode = 44; else if (e.which &amp;&amp; e.which==46) { e.which = 44; } }; </code></pre> <p>but it seemes that in Firefox it's impossible to change characters typed in key events. Any suggestions?</p>
[ { "answer_id": 218225, "author": "Ates Goral", "author_id": 23501, "author_profile": "https://Stackoverflow.com/users/23501", "pm_score": 3, "selected": false, "text": "window.onload = function () {\n var input = document.getElementById(\"mytext\");\n\n input.onkeypress = function ...
2008/10/20
[ "https://Stackoverflow.com/questions/218219", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27789/" ]
218,245
<p>Is there support in Ruby for (for lack of a better word) non-escaped (verbatim) strings?</p> <p>Like in C#:</p> <pre><code>@"c:\Program Files\" </code></pre> <p>...or in Tcl:</p> <pre><code>{c:\Program Files\} </code></pre>
[ { "answer_id": 218257, "author": "DevelopingChris", "author_id": 1220, "author_profile": "https://Stackoverflow.com/users/1220", "pm_score": 4, "selected": true, "text": "%" }, { "answer_id": 218271, "author": "Antonio Cangiano", "author_id": 6551, "author_profile": "...
2008/10/20
[ "https://Stackoverflow.com/questions/218245", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11545/" ]
218,255
<p>I'm a pretty active command line user and I have shell accounts all over the place. MacBooks, Linux desktop machines, Linux servers, Cygwin on XP, you name it.</p> <p>How can I keep my shell configuration (<code>.bashrc</code>, <code>.vimrc</code> etc.) in sync across all these machines using the limited tools available across all platforms?</p> <p>I have been using <code>rsync</code> in a pretty limited manner that involves manually copying some files over when I need them, but I want a standard way for setting up the same basic shell environment across all my machines. Tell me your shell account management strategy.</p>
[ { "answer_id": 6876048, "author": "mustpax", "author_id": 20476, "author_profile": "https://Stackoverflow.com/users/20476", "pm_score": 5, "selected": true, "text": "$ ls ~/Dropbox/shell/bash\nbashbootstrap bashrc\nbashrc-Darwin bashrc-Darwin-laptopname bashrc-Darwin-mininame\nbashrc-...
2008/10/20
[ "https://Stackoverflow.com/questions/218255", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20476/" ]
218,256
<p>I used to be able to do the following in Preview 3</p> <pre><code>&lt;%=Html.BuildUrlFromExpression&lt;AController&gt;(c =&gt; c.AnAction(par1, par2)%&gt; </code></pre> <p>How am I supposed to create urls in a strongly typed way with the MVC Beta? The only thing so far I have found is </p> <pre><code>&lt;%= Html.ActionLink("aName", "ActionName", "ControllerName")%&gt; </code></pre> <p>This is not strongly typed off course.</p>
[ { "answer_id": 218280, "author": "hangy", "author_id": 11963, "author_profile": "https://Stackoverflow.com/users/11963", "pm_score": 2, "selected": false, "text": "Microsoft.Web.Mvc" } ]
2008/10/20
[ "https://Stackoverflow.com/questions/218256", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11333/" ]
218,264
<p>What's a good way to survive abnormally high traffic spikes?</p> <p>My thought is that at some trigger, my website should temporarily switch into a "low bandwidth" mode: switch to basic HTML pages, minimal graphics, disable widgets that might put unnecessary load on the database, and so-on.</p> <p>My thoughts are:</p> <ul> <li>Monitor CPU usage</li> <li>Monitor bandwidth</li> <li>Monitor requests / minute</li> </ul> <p>I am familiar with options like caching, switching to static content or a content delivery network, and so on as a means to survive, so perhaps the question should focus more on how one detects when the website is about to become overloaded. (Although answers on other survival methods are of course still more than welcome.) Lets say that the website is running Apache on Linux and PHP. This is probably the most common configuration and should allow the maximum number of people to gain assistance from the answers. Lets also assume that expensive options like buying another server and load balancing are unavailable - for most of us at least, a mention on Slashdot is going to be a once-in-a-lifetime occurrence, and not something we can spend money preparing for.</p>
[ { "answer_id": 77012, "author": "Wedge", "author_id": 332, "author_profile": "https://Stackoverflow.com/users/332", "pm_score": 0, "selected": false, "text": "RewriteEngine on\nRewriteCond %{HTTP_REFERER} slashdot\\.org [NC]\nRewriteRule .* - [F]\n" }, { "answer_id": 83056, "...
2008/10/20
[ "https://Stackoverflow.com/questions/218264", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17440/" ]
218,284
<p>I'd like to be able to read the mac address from the first active network adapter using VB.net or C# (using .NET 3.5 SP1) for a winform application</p>
[ { "answer_id": 218314, "author": "Ilya Kochetov", "author_id": 15329, "author_profile": "https://Stackoverflow.com/users/15329", "pm_score": 2, "selected": false, "text": " Dim mc As System.Management.ManagementClass\n Dim mo As ManagementObject\n mc = New ManagementClass(\"Win32_Netw...
2008/10/20
[ "https://Stackoverflow.com/questions/218284", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
218,322
<p>If I have a property:</p> <pre><code>public list&lt;String&gt; names { get; set; } </code></pre> <p>How can I generate and handle a custom Event for arguments sake called 'onNamesChanged' whenever a name gets added to the list?</p>
[ { "answer_id": 218347, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 0, "selected": false, "text": "class Foo {}\nclass FooCollection : Collection<Foo>\n{\n protected override void InsertItem(int index, Foo item)\n...
2008/10/20
[ "https://Stackoverflow.com/questions/218322", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1816/" ]
218,335
<p>Is is possible to write MS SQL Server add-in? I'm thinking of some application integrated with database server available form SQL Server Enterprise Manager.</p>
[ { "answer_id": 218445, "author": "Martin Brown", "author_id": 20553, "author_profile": "https://Stackoverflow.com/users/20553", "pm_score": 0, "selected": false, "text": "C:\\WINDOWS\\system32\\mmc.exe /32 \"C:\\WINDOWS\\system32\\SQLServerManager.msc\"\n" } ]
2008/10/20
[ "https://Stackoverflow.com/questions/218335", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15640/" ]
218,337
<p>i'm fairly new to NHibernate and although I'm finding tons of infos on NHibernate mapping on the web, I am too silly to find this piece of information.</p> <p>So the problem is, i've got the following Model:</p> <p><img src="https://i.stack.imgur.com/DihaU.jpg" alt="Datamodel"></p> <p>this is how I'd like it to look. One clean person that has two Address Properties. </p> <p>In the database I'd like to persist this in one table. So the Person row would have a ShippingStreetname and a Streetname Column, the one mapped to ShippingAddress.Streetname and the other to Address.StreetName</p> <p>I found an <a href="http://nhforge.org/blogs/nhibernate/archive/2008/09/06/a-fluent-interface-to-nhibernate-part-2-value-objects.aspx" rel="nofollow noreferrer">article on fluent interfaces</a>, but still haven't figured out how to do this through the XML Configuration.</p> <p>Thanks in advance!</p> <p>Update: I found the solution to this by myself. This can be done through the node and works rather straightforward.</p> <p>To achieve the mapping of Address and ShippingAddress I just had to add the following to the </p> <pre><code>&lt;component name="Address" class="Address"&gt; &lt;property name="Streetname"&gt;&lt;/property&gt; &lt;property name="Zip"&gt;&lt;/property&gt; &lt;property name="City"&gt;&lt;/property&gt; &lt;property name="Country"&gt;&lt;/property&gt; &lt;/component&gt; &lt;component name="ShippingAddress" class="Address"&gt; &lt;property name="Streetname" column="ShippingStreetname" /&gt; &lt;property name="Zip" column="ShippingZip" /&gt; &lt;property name="City" column="ShippingCity" /&gt; &lt;property name="Country" column="ShippingCountry" /&gt; &lt;/component&gt; </code></pre>
[ { "answer_id": 218360, "author": "Joachim Kerschbaumer", "author_id": 20227, "author_profile": "https://Stackoverflow.com/users/20227", "pm_score": 0, "selected": false, "text": "<many-to-one name=\"ShippingAddress\" class=\"Yournamespace.Address\"/>\n<many-to-one name=\"Address\" class=...
2008/10/20
[ "https://Stackoverflow.com/questions/218337", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21699/" ]
218,350
<p>Does Java Connection.close rollback into a finally block?.</p> <p>I know .Net SqlConnection.close does it.</p> <p>With this I could make try/finally blocks without catch...</p> <p>Example:</p> <pre><code>try { conn.setAutoCommit(false); ResultSet rs = executeQuery(conn, ...); .... executeNonQuery(conn, ...); .... conn.commit(); } finally { conn.close(); } </code></pre>
[ { "answer_id": 223138, "author": "Paul Tomblin", "author_id": 3333, "author_profile": "https://Stackoverflow.com/users/3333", "pm_score": 4, "selected": false, "text": "try {\n conn.setAutoCommit(false);\n ResultSet rs = executeQuery(conn, ...);\n ....\n executeNonQuery(conn,...
2008/10/20
[ "https://Stackoverflow.com/questions/218350", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29600/" ]
218,359
<p>I have a custom class that implements that IComparable. This class is stored in a Generic List. I now need to compare to lists to see which objects are in list A but not in list B. </p> <p>I thought the most simple way of doing this would be to iterate through list B and do A.contains().</p> <p>I do not know how to get it to use my CompareTo() (or another method that I can override so that I can say if it contains a certain object or not). I could be wrong but as I understand it the contains checks if the objects are actually the same (i.e. points to the same place in memory).</p> <p>Could anyone help me please?</p>
[ { "answer_id": 218367, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 4, "selected": true, "text": "Equals" } ]
2008/10/20
[ "https://Stackoverflow.com/questions/218359", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6486/" ]
218,384
<p>What are Null Pointer Exceptions (<code>java.lang.NullPointerException</code>) and what causes them?</p> <p>What methods/tools can be used to determine the cause so that you stop the exception from causing the program to terminate prematurely?</p>
[ { "answer_id": 218390, "author": "Bill the Lizard", "author_id": 1288, "author_profile": "https://Stackoverflow.com/users/1288", "pm_score": 10, "selected": false, "text": "NullPointerException" }, { "answer_id": 218394, "author": "Jorge Ferreira", "author_id": 6508, ...
2008/10/20
[ "https://Stackoverflow.com/questions/218384", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29182/" ]
218,388
<p>I want to stitch 2 pieces of png side by side. In Cocoa, I would use [NSImage initWithSize], and then just drawInRect. </p> <p>But UIImage don't have initWithSize class, how would I do this now?</p>
[ { "answer_id": 218454, "author": "millenomi", "author_id": 6061, "author_profile": "https://Stackoverflow.com/users/6061", "pm_score": 4, "selected": true, "text": "UIGraphicsBeginImageContext()" } ]
2008/10/20
[ "https://Stackoverflow.com/questions/218388", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9774/" ]
218,399
<p>What's the advantage of passing data as parameters vs part of the URL in an Ajax GET request?</p> <p>Using parameters:</p> <pre><code>var ajax = new Ajax.Request('server.php',{ parameters: 'store=11200&amp;product=Meat', onSuccess: function(myData){whatever} }); </code></pre> <p>Using URL:</p> <pre><code>var ajax = new Ajax.Request('server.php?store=11200&amp;product=Meat',{ onSuccess: function(myData){whatever} }); </code></pre>
[ { "answer_id": 218417, "author": "Evan DiBiase", "author_id": 2399475, "author_profile": "https://Stackoverflow.com/users/2399475", "pm_score": 5, "selected": true, "text": "parameters" }, { "answer_id": 218437, "author": "nickf", "author_id": 9021, "author_profile": ...
2008/10/20
[ "https://Stackoverflow.com/questions/218399", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12579/" ]
218,405
<p>I've been testing an application using my machine as a server, and everything's going fine with it, but when I try to set it up to run on the test server, I get this error:</p> <blockquote> <p>Retrieving the COM class factory for component with CLSID {XXXX} failed due to the following error: 80040154.</p> </blockquote> <p>Any ideas?</p> <p>Thanks</p>
[ { "answer_id": 218423, "author": "ChaosSpeeder", "author_id": 205962, "author_profile": "https://Stackoverflow.com/users/205962", "pm_score": 3, "selected": true, "text": "HKEY_CLASSES_ROOT\\CLSID\\{xxxx}\n" } ]
2008/10/20
[ "https://Stackoverflow.com/questions/218405", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13244/" ]
218,439
<p>Suppose we have the following code:</p> <pre><code>ExpressionHelper.GetRouteValuesFromExpression&lt;AccountController&gt;(ax =&gt; ax.MyAction("a", "b")); </code></pre> <p>(from ASP.NET MVC Futures assembly). Method is reasonably fast - it executes 10k iterations in 150ms.</p> <p>Now, we change code to this:</p> <pre><code>string a = "a"; string b = "b"; ExpressionHelper.GetRouteValuesFromExpression&lt;AccountController&gt;(ax =&gt; ax.MyAction(a, b)); </code></pre> <p>This code will execute 10k iterations in 15 <strong>seconds</strong></p> <p>The problem is the following code:</p> <pre><code>Expression&lt;Func&lt;object&gt;&gt; lambdaExpression = Expression.Lambda&lt;Func&lt;object&gt;&gt;(Expression.Convert(arg, typeof (object))); Func&lt;object&gt; func = lambdaExpression.Compile(); value = func() </code></pre> <p>Is there a better way to get value from expression than compiling expression every time? This can greatly affect ASP.NET MVC link generation speed.</p>
[ { "answer_id": 218456, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 1, "selected": false, "text": "Dictionary<Expression<Action<T>>, Action<T>> m_Cache =\n new Dictionary<Expression<Action<T>>, Action<T>>();\n\npu...
2008/10/20
[ "https://Stackoverflow.com/questions/218439", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28912/" ]
218,451
<p>Part of my latest webapp needs to write to file a fair amount as part of its logging. One problem I've noticed is that if there are a few concurrent users, the writes <em>can</em> overwrite each other (instead of appending to file). I assume this is because of the destination file can be open in a number of places at the same time.</p> <p><code>flock(...)</code> is usually superb but it doesn't appear to work on NFS... Which is a huge problem for me as the production server uses a NFS array.</p> <p>The closest thing I've seen to an actual solution involves trying to create a lock dir and waiting until it can be created. To say this lacks elegance is understatement of the year, possibly decade.</p> <p>Any better ideas?</p> <p>Edit: I should add that I don't have root on the server and doing the storage in another way isn't really feasible any time soon, not least within my deadline.</p>
[ { "answer_id": 218460, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 3, "selected": true, "text": "flock()" }, { "answer_id": 218539, "author": "ConroyP", "author_id": 2287, "author_profile": "https://Stac...
2008/10/20
[ "https://Stackoverflow.com/questions/218451", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12870/" ]
218,461
<p>I would like to know what is the difference between initializing a static member inline as in:</p> <pre><code>class Foo { private static Bar bar_ = new Bar(); } </code></pre> <p>or initializing it inside the static constructor as in:</p> <pre><code>class Foo { static Foo() { bar_ = new Bar(); } private static Bar bar_; } </code></pre>
[ { "answer_id": 218477, "author": "Torbjørn", "author_id": 22621, "author_profile": "https://Stackoverflow.com/users/22621", "pm_score": 2, "selected": false, "text": "class Foo\n{\n private static IBar _bar;\n\n static Foo()\n {\n if(something)\n {\n _ba...
2008/10/20
[ "https://Stackoverflow.com/questions/218461", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10688/" ]
218,462
<p>Specifically, I want to copy a link (with text and location) and then to be able to paste it, e.g., into Word as a link.</p>
[ { "answer_id": 219223, "author": "Lev", "author_id": 7224, "author_profile": "https://Stackoverflow.com/users/7224", "pm_score": 3, "selected": false, "text": "var richText = \"<a href=\\\"\" + gContextMenu.linkURL + \"\\\">\" + gContextMenu.linkText() + \"</a>\";\nvar xfer = Components....
2008/10/20
[ "https://Stackoverflow.com/questions/218462", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7224/" ]
218,466
<p>I'm having a hard time coding understanding the format of the specifier and string functions.</p> <p>My aim is to use <code>%[]</code> to readin all characters and spaces and then use the strcpy function followed by the strcat function.</p> <p>So far i've managed to enter individual characters and print them out, excluding spaces.</p> <p>here's the code so far;</p> <pre><code>int main(int argc, char** argv) { char words[30]; int loops; printf("How many letters would you like to enter? - "); scanf("%d",&amp;loops); for(int i=0;i&lt;loops;i++){ printf("Provide some text as input:"); scanf("%s", &amp;words[i]); } printf("%d", strlen(words)); printf("%s",&amp;words); return (EXIT_SUCCESS); } </code></pre>
[ { "answer_id": 218517, "author": "Peter Olsson", "author_id": 2703, "author_profile": "https://Stackoverflow.com/users/2703", "pm_score": 0, "selected": false, "text": "scanf(\"%c\", &words[i]);\n" }, { "answer_id": 218607, "author": "Jorge Ferreira", "author_id": 6508, ...
2008/10/20
[ "https://Stackoverflow.com/questions/218466", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
218,472
<p>At a new job I started, we have both a Java application that handles most of the heavy lifting in the core business logic, and we also have a Rails application that of course handles the web interface to this server. Both of these access the same database.</p> <p>Up until now, most of the focus has been on the Java application, and as such, there are no migrations in the Rails project. The sql to update the shared database is managed in a file like changes.sql.</p> <p>As you can imagine, this makes it somewhat difficult to develop.</p> <p>My initial thought was to combine the codebases for the Java project and the Rails application, because there is a dependency there, and to manage that SQL file in the source. However, I thought I'd ask here to see if anyone else had tackled this issue with some degree of success.</p>
[ { "answer_id": 222753, "author": "rwc9u", "author_id": 7778, "author_profile": "https://Stackoverflow.com/users/7778", "pm_score": 1, "selected": false, "text": " # Use SQL instead of Active Record's schema dumper when creating the test database.\n # This is necessary if your schema ca...
2008/10/20
[ "https://Stackoverflow.com/questions/218472", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29104/" ]
218,488
<h2>Problem</h2> <p>I have timestamped data, which I need to search based on the timestamp in order to get the one existing timestamp which matches my input timestamp the closest.<br> Preferably this should be solved with the STL. boost::* or stl::tr1::* (from VS9 with Featurepack) are also possible.<br> Example of timestamped data:</p> <pre><code>struct STimestampedData { time_t m_timestamp; // Sorting criterion CData m_data; // Payload } </code></pre> <h2>Approach with <code>stl::vector</code>, <code>sort()</code> and <code>equal_range()</code></h2> <p>Since a <code>map</code> or <code>set</code> only allows me to find exact matches, I don't get any further using one of these. So now I have a <code>vector</code> to which I append data as it is coming in. Before searching I use <code>&lt;algorithm&gt;</code>'s <code>sort()</code> and supply it with a custom comparison function.<br> After that I use <code>&lt;algorithm&gt;</code>'s <code>equal_range()</code> to find the two neighbors of a specified value <code>x</code>. From these two values I check which one is closest to <code>x</code> and then I have my best match.</p> <p><br> While this is not too complex, I wonder if there are more elegant solutions to this.<br> Maybe the STL already has an algorithm which does exactly that so I'm not re-inventing something here?</p> <h2>Update: Linear vs. binary search</h2> <p>I forgot to mention that I have quite a lot of data to handle so I don't want to have to search linearly.<br> The reason I am sorting a vector with <code>sort()</code> is because it has random access iterators which is not the case with a <code>map</code>. Using a <code>map</code> would not allow <code>equal_range()</code> to do a search with twice logarithmic complexity.<br> Am I correct?</p>
[ { "answer_id": 218720, "author": "Mark Ransom", "author_id": 5987, "author_profile": "https://Stackoverflow.com/users/5987", "pm_score": 4, "selected": true, "text": "struct TimestampCompare\n{\n bool operator()(const STimestampedData & left, const STimestampedData & right) const\n ...
2008/10/20
[ "https://Stackoverflow.com/questions/218488", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27596/" ]
218,491
<p>Is it possible to configure Windows Servers that reside on the same domain such that when a web service call is made from a web app using an IP address, the request does not go via a proxy server?</p> <p>The web service is running on one of the servers on the domain. </p> <p>I want to configure IP based security on the server that hosts the web service such that it only allows connections from specific servers. Currently all requests go via the proxy server rendering IPSec problematic.</p> <p>Within the browser I can specify that requests following a specific pattern should bypass the proxy server. It's essentially this behaviour I want to replicate with the servers.</p> <p>Thanks</p>
[ { "answer_id": 287023, "author": "Reiwoldt", "author_id": 29588, "author_profile": "https://Stackoverflow.com/users/29588", "pm_score": 1, "selected": true, "text": "Set xmlhttp = Server.CreateObject(\"Msxml2.ServerXMLHTTP.4.0\") \n\nxmlhttp.SetProxy 2,\"proxyname:port\", \"addresses tha...
2008/10/20
[ "https://Stackoverflow.com/questions/218491", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29588/" ]
218,507
<p>I have a home project that really needs to be in Source Control. I tried installing Subversion, which I have some experience with, but couldn't get it working. I don't particularly want to use SourceSafe. I'm a bit nervous about Git/Mercury as being somewhat cryptic, although this is only based on opinion rather than my experience.</p> <p>Main requirements are:</p> <ol> <li>Must be open source (well, it needs to be free but that sounds a bit cheap!)</li> <li>Must run on Win32</li> <li>Would prefer a GUI interface if one is available</li> </ol> <p>Many thanks in advance!</p> <p><strong>edit:</strong> Just to let you all know, I installed VisualSVN and had it working in no time. Thanks for the great advice.</p>
[ { "answer_id": 237818, "author": "dbr", "author_id": 745, "author_profile": "https://Stackoverflow.com/users/745", "pm_score": 2, "selected": false, "text": "git" } ]
2008/10/20
[ "https://Stackoverflow.com/questions/218507", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25462/" ]
218,512
<p>I would like to use the ispell-buffer command in Emacs. It uses the English language by default. Is there an easy way to switch to another dictionary (for example, another language)?</p>
[ { "answer_id": 218576, "author": "Pierre", "author_id": 24449, "author_profile": "https://Stackoverflow.com/users/24449", "pm_score": 5, "selected": false, "text": "ispell" }, { "answer_id": 218630, "author": "stephanea", "author_id": 8776, "author_profile": "https://...
2008/10/20
[ "https://Stackoverflow.com/questions/218512", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4900/" ]
218,522
<p>I have a Java servlet which generates xml, translates it with an xslt stylesheet, and then displays the resulting HTML. This is the first time I've worked with xslt. What's a good way to debug xslt? I have (or can get) some sample XML files to apply the transform too. But I'm not really even sure of the syntax so something that would give me syntax warnings would be great.</p>
[ { "answer_id": 2319729, "author": "chiborg", "author_id": 130121, "author_profile": "https://Stackoverflow.com/users/130121", "pm_score": 4, "selected": false, "text": "<xsl:message>" } ]
2008/10/20
[ "https://Stackoverflow.com/questions/218522", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8092/" ]
218,531
<p>I have a situation where I want to create a signature of a data structure:</p> <pre><code>my $signature = ds_to_sig( { foo =&gt; 'bar', baz =&gt; 'bundy', boing =&gt; undef, number =&gt; 1_234_567, } ); </code></pre> <p>The aim should be that if the data structure changes then so should the signature.</p> <p>Is there an established way to do this?</p>
[ { "answer_id": 218558, "author": "Leon Timmermans", "author_id": 4727, "author_profile": "https://Stackoverflow.com/users/4727", "pm_score": 4, "selected": false, "text": "use Storable;\n$Storable::canonical = 1;\nsub ds_to_sig {\n my $structure = shift;\n return hash(freeze $struc...
2008/10/20
[ "https://Stackoverflow.com/questions/218531", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5349/" ]
218,535
<p>I have a database full of small HTML documents and I need to programmatically insert several into, say, a PDF document with <em>iText</em> or a Word document with <em>Aspose.Words</em>. I need to preserve any formatting within the HTML documents (within reason, honouring &lt;b&gt; tags is a must, CSS like &lt;span style="blah"&gt; is a nice-to-have). </p> <p>Both iText and Aspose work (roughly) along the lines:</p> <pre><code>Document document = new Document( Size.A4, Aspect.PORTRAIT ); document.setFont( "Helvetica", 20, Font.BOLD ); document.insert( "some string" ) document.setBold( true ); document.insert( "A bold string" ); </code></pre> <p>Therefore (I think) I need some kind of HTML parser which will I can inspect for strings and styles to insert into my document.</p> <p>Can anybody suggest a good library or a sensible approach to this problem? Platform is Java</p>
[ { "answer_id": 219780, "author": "Craig Angus", "author_id": 15352, "author_profile": "https://Stackoverflow.com/users/15352", "pm_score": 3, "selected": true, "text": "<br>" } ]
2008/10/20
[ "https://Stackoverflow.com/questions/218535", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29620/" ]
218,556
<p>I've been given a requirement for an internal web application to send documents to a printer transparently. The idea would be that the user can select their nearest printer, and the web application would send their print jobs to the printer they selected.</p> <p>The first printer we have to roll out against are Canons, so my questions is: How would I go about sending a document to print aross the network to a specific Canon? The type of Cannon is question is an iR5570 and the documents that will be said will mainly be Word and PDFs</p> <p>I'm currently working my way through the terrible, IE only Canon Developer site, but I'm kinda hoping someone can point me in the right direction or point me at a 3rd party assembly :)</p>
[ { "answer_id": 218677, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 4, "selected": true, "text": "System.Drawing.Printing" }, { "answer_id": 221818, "author": "Douglas Anderson", "author_id": 5678, ...
2008/10/20
[ "https://Stackoverflow.com/questions/218556", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5802/" ]
218,563
<p>How can I implement the "tap and hold" behavior in an MFC CListCtrl?</p> <p>I have an MFC CListCtrl in a CDialog and I need to add to the CListCtrl the "tap and hold" behavior.</p> <p>That is what I mean for "tap and hold":</p> <p>If the user clicks (a "standard" click with the left button of the mouse) on a CListCtrl item then function A will be called.</p> <p>If the user click on a CListCtrl item and keep pressed down the left button of the mouse for more than one second then function B will be called.</p>
[ { "answer_id": 222166, "author": "SmacL", "author_id": 22564, "author_profile": "https://Stackoverflow.com/users/22564", "pm_score": 1, "selected": false, "text": "BOOL CMyDialog::OnInitDialog() \n{\n MyListboxCtrl.SubclassDlgItem(ID_MYLISTBOX,this);\n CDialog::OnInitDialog();\n}\n" ...
2008/10/20
[ "https://Stackoverflow.com/questions/218563", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15485/" ]
218,573
<p>I've seen some developers put instance variable declarations at the end of classes though I mostly see them placed at the top. The only reasons I can think of for doing this are stylistic preference or maybe it somehow makes them easier to work with in an IDE. Is there a more legitimate reason for choosing this style?</p>
[ { "answer_id": 1411795, "author": "finnw", "author_id": 12048, "author_profile": "https://Stackoverflow.com/users/12048", "pm_score": 1, "selected": false, "text": "private" } ]
2008/10/20
[ "https://Stackoverflow.com/questions/218573", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1294/" ]
218,604
<p>For example, if I have a network spec like 172.20.10.0/24, "24" is the bitcount. What's the best way to convert that to a netmask like 0xffffff00 ?</p>
[ { "answer_id": 218620, "author": "Eric Hogue", "author_id": 4137, "author_profile": "https://Stackoverflow.com/users/4137", "pm_score": 2, "selected": false, "text": "whatmask 72.20.10.0/24\n" }, { "answer_id": 218648, "author": "tvanfosson", "author_id": 12950, "auth...
2008/10/20
[ "https://Stackoverflow.com/questions/218604", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19655/" ]
218,613
<p>I hope there's a SharePoint expert here on SO who can help with this.</p> <p>Here's the problem. My SharePoint logs contain this line, several times:</p> <p><code>An SPRequest object was not disposed before the end of this thread. To avoid wasting system resources, dispose of this object or its parent (such as an SPSite or SPWeb) as soon as you are done using it. This object will now be disposed. Allocation Id: {8D090AD2-5D55-42C2-9873-2D5486FE257C} To determine where this object was allocated, create a registry key at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\HeapSettings. Then create a new DWORD named SPRequestStackTrace with the value 1 under this key.</code></p> <p>I edited the registry and added the key, but the stacktrace is nowhere to be found. It's not in the SharePoint logs or in the Event Viewer. </p> <p>I really need to find the source of these SPSite/SPWeb leaks and fix them, but I can't just start editing code that may or may not be the source of the problem. Does anyone have any suggestions?</p>
[ { "answer_id": 219179, "author": "Jason Z", "author_id": 2470, "author_profile": "https://Stackoverflow.com/users/2470", "pm_score": 1, "selected": false, "text": "try \n{\n //instantiate the SPSite and SPWeb with elevated privileges: \n SPSecurity.RunWithElevatedPrivileges(dele...
2008/10/20
[ "https://Stackoverflow.com/questions/218613", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7565/" ]
218,616
<p>Given the Python function:</p> <pre><code>def a_method(arg1, arg2): pass </code></pre> <p>How can I extract the number and names of the arguments. I.e., given that I have a reference to <code>func</code>, I want the <code>func.[something]</code> to return <code>("arg1", "arg2")</code>.</p> <p>The usage scenario for this is that I have a decorator, and I wish to use the method arguments in the same order that they appear for the actual function as a key. I.e., how would the decorator look that printed <code>"a,b"</code> when I call <code>a_method("a", "b")</code>?</p>
[ { "answer_id": 218625, "author": "Jouni K. Seppänen", "author_id": 26575, "author_profile": "https://Stackoverflow.com/users/26575", "pm_score": 7, "selected": false, "text": "a_method.func_code.co_argcount\n" }, { "answer_id": 218709, "author": "Brian", "author_id": 9493...
2008/10/20
[ "https://Stackoverflow.com/questions/218616", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3355/" ]
218,623
<p>I've seen a couple of font topics on SO and it seems a majority of people use monospace fonts for programming tasks. I have been using Verdana for programming for a couple of years and I really like the enhanced readability, without missing anything monospace related.</p> <p>Why do you use a monospace font?</p>
[ { "answer_id": 218639, "author": "Ryan", "author_id": 17917, "author_profile": "https://Stackoverflow.com/users/17917", "pm_score": 7, "selected": false, "text": "Il 0O" }, { "answer_id": 218646, "author": "DGentry", "author_id": 4761, "author_profile": "https://Stack...
2008/10/20
[ "https://Stackoverflow.com/questions/218623", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5409/" ]
218,638
<p>Using the ClearCase find command, how do I find all files in a directory that do not have the name pom.xml? </p> <p>I'd like to pass other selection options to the ClearCase find command so I'd prefer not to execute another command.</p> <p>I am using a RedHat linux version of ClearCase. I have tried "cleartool find ! -name pom.xml -print" and that does not work.</p> <p>PS: I do not use ClearCase by choice, it's mandated on my project. This is one of the reasons I hate it. I've read the man pages several times and see no clear way to do this that works!</p>
[ { "answer_id": 218976, "author": "Dmitry Khalatov", "author_id": 18174, "author_profile": "https://Stackoverflow.com/users/18174", "pm_score": 2, "selected": false, "text": "cleartool ls -short -nxname | grep -v pom.xml\n" }, { "answer_id": 224759, "author": "VonC", "auth...
2008/10/20
[ "https://Stackoverflow.com/questions/218638", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4476/" ]
218,663
<p>I work for a custom cabinetry manufacturer and we write our own pricing program for our product. I have a form that has a pop-up box so the user can select which side the hinge will be on for ambiguous doors on that cabinet. I've got that to work so far, but when they copy an item and paste it at the bottom I don't want the pop-up box to come up. Is there any way in Access VBA to know whether the new record is being pasted or entered manually?</p>
[ { "answer_id": 218783, "author": "Fionnuala", "author_id": 2548, "author_profile": "https://Stackoverflow.com/users/2548", "pm_score": 2, "selected": false, "text": "Option Compare Database\nPublic gvarPasted As Boolean\n\nPrivate Sub txtText_AfterUpdate()\nIf Not gvarPasted Then\n 'O...
2008/10/20
[ "https://Stackoverflow.com/questions/218663", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4549/" ]
218,680
<p>I allow users to enter a regular expression to match IP addresses, for doing an IP filtration in a related system. I would like to validate if the entered regular expressions are valid as a lot of userse will mess op, with good intentions though.</p> <p>I can of course do a Regex.IsMatch() inside a try/catch and see if it blows up that way, but are there any smarter ways of doing it? Speed is not an issue as such, I just prefer to avoid throwing exceptions for no reason.</p>
[ { "answer_id": 218716, "author": "Mark Brackett", "author_id": 2199, "author_profile": "https://Stackoverflow.com/users/2199", "pm_score": 3, "selected": false, "text": "System.Text.RegularExpressions.RegexNode.ScanRegex()" }, { "answer_id": 1775017, "author": "Jeff Atwood", ...
2008/10/20
[ "https://Stackoverflow.com/questions/218680", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12469/" ]
218,681
<p>The following code snippet illustrates a memory leak when opening XPS files. If you run it and watch the task manager, it will grow and not release memory until the app exits.</p> <p>'****** Console application BEGINS.</p> <pre><code>Module Main Const DefaultTestFilePath As String = "D:\Test.xps" Const DefaultLoopRuns As Integer = 1000 Public Sub Main(ByVal Args As String()) Dim PathToTestXps As String = DefaultTestFilePath Dim NumberOfLoops As Integer = DefaultLoopRuns If (Args.Count &gt;= 1) Then PathToTestXps = Args(0) If (Args.Count &gt;= 2) Then NumberOfLoops = CInt(Args(1)) Console.Clear() Console.WriteLine("Start - {0}", GC.GetTotalMemory(True)) For LoopCount As Integer = 1 To NumberOfLoops Console.CursorLeft = 0 Console.Write("Loop {0:d5}", LoopCount) ' The more complex the XPS document and the more loops, the more memory is lost. Using XPSItem As New Windows.Xps.Packaging.XpsDocument(PathToTestXps, System.IO.FileAccess.Read) Dim FixedDocSequence As Windows.Documents.FixedDocumentSequence ' This line leaks a chunk of memory each time, when commented out it does not. FixedDocSequence = XPSItem.GetFixedDocumentSequence End Using Next Console.WriteLine() GC.Collect() ' This line has no effect, I think the memory that has leaked is unmanaged (C++ XPS internals). Console.WriteLine("Complete - {0}", GC.GetTotalMemory(True)) Console.WriteLine("Loop complete but memory not released, will release when app exits (press a key to exit).") Console.ReadKey() End Sub End Module </code></pre> <p>'****** Console application ENDS.</p> <p>The reason it loops a thousand times is because my code processes lots of files and leaks memory quickly forcing an OutOfMemoryException. Forcing Garbage Collection does not work (I suspect it is an unmanaged chunk of memory in the XPS internals).</p> <p>The code was originally in another thread and class but has been simplified to this.</p> <p>Any help greatly appreciated.</p> <p>Ryan</p>
[ { "answer_id": 219165, "author": "Ryan O'Neill", "author_id": 26221, "author_profile": "https://Stackoverflow.com/users/26221", "pm_score": 4, "selected": true, "text": " Using XPSItem As New Windows.Xps.Packaging.XpsDocument(PathToTestXps, System.IO.FileAccess.Read)\n ...
2008/10/20
[ "https://Stackoverflow.com/questions/218681", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26221/" ]
218,691
<p>Is there a way to temporary swap Flex's main application to another then switch back. Scenario : Main app started, display login box - then go on with main app. Login box is an application as well. </p> <p>Application.application is a read only property, that attempt failed.</p>
[ { "answer_id": 220714, "author": "Mitch Haile", "author_id": 28807, "author_profile": "https://Stackoverflow.com/users/28807", "pm_score": 0, "selected": false, "text": "<mx:Application>\n <mx:ViewStack>\n <mx:Box> <!-- or whatever for login-->\n </mx:Box>\n <mx:Box> <!-- appli...
2008/10/20
[ "https://Stackoverflow.com/questions/218691", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
218,696
<p>Is there a generic way to clone objects in VBA? So that i could copy x to y instead of copying just the pointer?</p> <pre><code> Dim x As New Class1 Dim y As Class1 x.Color = 1 x.Height = 1 Set y = x y.Color = 2 Debug.Print "x.Color=" &amp; x.Color &amp; ", x.Height=" &amp; x.Height </code></pre> <p>By generic i mean something like <code>Set y = CloneObject(x)</code> rather than having to create my own method for the class copying its properties one by one.</p>
[ { "answer_id": 220060, "author": "Mike Woodhouse", "author_id": 1060, "author_profile": "https://Stackoverflow.com/users/1060", "pm_score": 4, "selected": true, "text": "Option Explicit\n\nPublic prop1 As Long\nPrivate DontCloneThis As Variant\n\nPublic Property Get PrivateThing()\n P...
2008/10/20
[ "https://Stackoverflow.com/questions/218696", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4134/" ]
218,732
<p>In .NET, Windows Forms have an event that fires before the Form is loaded (Form.Load), but there is no corresponding event that is fired AFTER the form has loaded. I would like to execute some logic after the form has loaded.</p> <p>Can anyone advise on a solution?</p>
[ { "answer_id": 218740, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 6, "selected": false, "text": "this.BeginInvoke((MethodInvoker) delegate {\n // some code\n});\n" }, { "answer_id": 19086655, "author":...
2008/10/20
[ "https://Stackoverflow.com/questions/218732", "https://Stackoverflow.com", "https://Stackoverflow.com/users/324/" ]
218,733
<p>I have a <code>GridView</code> control in an Asp.net application, that has a <code>&lt;asp:buttonField&gt;</code> of <code>type="image"</code> and <code>CommandName="Delete"</code>.</p> <p>Is there any way to execute a piece of javascript before reaching the <code>OnRowDelete</code> event?</p> <p>I want just a simple confirm before deleting the row.</p> <p>Thanks!</p> <p><strong>EDIT</strong>: Please Note that <code>&lt;asp:ButtonField&gt;</code> tag <strong>does not have</strong> an <code>OnClientClick</code> attribute.</p>
[ { "answer_id": 218785, "author": "steve_c", "author_id": 769, "author_profile": "https://Stackoverflow.com/users/769", "pm_score": 6, "selected": true, "text": "<script type=\"text/javascript\">\n function confirmDelete()\n {\n return confirm(\"Are you sure you want to delete t...
2008/10/20
[ "https://Stackoverflow.com/questions/218733", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7595/" ]
218,744
<p>What are good reasons to prohibit inheritance in Java, for example by using final classes or classes using a single, private parameterless constructor? What are good reasons of making a method final?</p>
[ { "answer_id": 218774, "author": "Mecki", "author_id": 15809, "author_profile": "https://Stackoverflow.com/users/15809", "pm_score": 3, "selected": false, "text": " String blah = someOtherString;\n" } ]
2008/10/20
[ "https://Stackoverflow.com/questions/218744", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18722/" ]
218,747
<p>I have a problem with Visual C++ 2008. I have installed opencv and I've created a new program and I build it with no errors. However, it complains about not finding MSVCR90D.dll when debugging. In release mode there is no problem at all. </p> <p>I do have MSVCR90D.dll in one of Winsxs folders. Does anyone know a get-around to this problem? Is this a known bug? </p> <p>Gerard</p>
[ { "answer_id": 221238, "author": "MSalters", "author_id": 15416, "author_profile": "https://Stackoverflow.com/users/15416", "pm_score": 2, "selected": false, "text": "/pb your.debug.exe" }, { "answer_id": 693992, "author": "x_x", "author_id": 84155, "author_profile": ...
2008/10/20
[ "https://Stackoverflow.com/questions/218747", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
218,760
<p>Although elements like <code>&lt;div&gt;</code>s normally grow to fit their contents, using the <code>float</code> property can cause a startling problem for CSS newbies: <strong>If floated elements have non-floated parent elements, the parent will collapse.</strong></p> <p>For example:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div&gt; &lt;div style="float: left;"&gt;Div 1&lt;/div&gt; &lt;div style="float: left;"&gt;Div 2&lt;/div&gt; &lt;/div&gt;</code></pre> </div> </div> </p> <p>The parent div in this example will <strong>not expand</strong> to contain its floated children - it will appear to have <code>height: 0</code>.</p> <h1>How do you solve this problem?</h1> <p><em>I would like to create an exhaustive list of solutions here. If you're aware of cross-browser compatibility issues, please point them out.</em></p> <h2>Solution 1</h2> <p>Float the parent.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div style="float: left;"&gt; &lt;div style="float: left;"&gt;Div 1&lt;/div&gt; &lt;div style="float: left;"&gt;Div 2&lt;/div&gt; &lt;/div&gt;</code></pre> </div> </div> </p> <p><strong>Pros</strong>: Semantic code.<br /> <strong>Cons</strong>: You may not always want the parent floated. Even if you do, do you float the parents' parent, and so on? Must you float every ancestor element?</p> <h2>Solution 2</h2> <p>Give the parent an explicit height.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div style="height: 300px;"&gt; &lt;div style="float: left;"&gt;Div 1&lt;/div&gt; &lt;div style="float: left;"&gt;Div 2&lt;/div&gt; &lt;/div&gt;</code></pre> </div> </div> </p> <p><strong>Pros</strong>: Semantic code.<br /> <strong>Cons</strong>: Not flexible - if the content changes or the browser is resized, the layout will break.</p> <h2>Solution 3</h2> <p>Append a &quot;spacer&quot; element inside the parent element, like this:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div&gt; &lt;div style="float: left;"&gt;Div 1&lt;/div&gt; &lt;div style="float: left;"&gt;Div 2&lt;/div&gt; &lt;div class="spacer" style="clear: both;"&gt;&lt;/div&gt; &lt;/div&gt;</code></pre> </div> </div> </p> <p><strong>Pros</strong>: Straightforward to code.<br /> <strong>Cons</strong>: Not semantic; the spacer div exists only as a layout hack.</p> <h2>Solution 4</h2> <p>Set parent to <code>overflow: auto</code>.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div style="overflow: auto;"&gt; &lt;div style="float: left;"&gt;Div 1&lt;/div&gt; &lt;div style="float: left;"&gt;Div 2&lt;/div&gt; &lt;/div&gt;</code></pre> </div> </div> </p> <p><strong>Pros</strong>: Doesn't require extra div.<br /> <strong>Cons</strong>: Seems like a hack - that's not the <code>overflow</code> property's stated purpose.</p> <h1>Comments? Other suggestions?</h1>
[ { "answer_id": 218799, "author": "Bobby Jack", "author_id": 5058, "author_profile": "https://Stackoverflow.com/users/5058", "pm_score": 6, "selected": false, "text": "overflow: auto" }, { "answer_id": 218809, "author": "Konrad Rudolph", "author_id": 1968, "author_prof...
2008/10/20
[ "https://Stackoverflow.com/questions/218760", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4376/" ]
218,777
<p>Is it right to use a private constant in the following situation:</p> <p>Say I have a game with a lives variable and a startingLives variable. At the start of the game I set the lives variable to equal the startingLives variable. This is how I would normally do it:</p> <pre><code>private var lives:int = 0; private var startingLives:int = 3; private function startGame():void { lives = startingLives; } </code></pre> <p>(example code is ActionScript btw)</p> <p>My question is - should this really be:</p> <pre><code>private var lives:int = 0; private const STARTING_LIVES:int = 3; private function startGame():void { lives = STARTING_LIVES; } </code></pre> <p>StartingLives seems unlikely to change at runtime, so should I use a const, and change back to a variable if it turns out not to be constant? </p> <p>UPDATE: The consensus seems to be that this is a good use of a constant, but what about amdfan's suggestion that you may want to load the value in from a config file?</p>
[ { "answer_id": 218782, "author": "ine", "author_id": 4965, "author_profile": "https://Stackoverflow.com/users/4965", "pm_score": 3, "selected": true, "text": "DEFAULT_STARTING_LIVES" } ]
2008/10/20
[ "https://Stackoverflow.com/questions/218777", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11911/" ]
218,786
<p>I keep on hearing about concurrent programing every where. Can you guys throw some light on what it's and how c++ new standards facilitate doing the same?</p>
[ { "answer_id": 218817, "author": "Anthony Williams", "author_id": 5597, "author_profile": "https://Stackoverflow.com/users/5597", "pm_score": 7, "selected": true, "text": "std::thread" }, { "answer_id": 17737426, "author": "Marcus Thornton", "author_id": 2288882, "aut...
2008/10/20
[ "https://Stackoverflow.com/questions/218786", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22076/" ]
218,794
<p>I have a form that uses jQuery to submit an ajax post and it serializes the form that is sent up. The code looks like this:</p> <pre><code>var form = $("form"); var action = form.attr("action"); var serializedForm = form.serialize(); $.post(action, serializedForm, function(data) { ... }); </code></pre> <p>The problem here is that if a field has trailing white space, the serialize function will turn those spaces to plus (+) signs, when they should be stripped.</p> <p>Is there a way to get the fields trimmed <strong>without</strong> doing the following:</p> <pre><code>$("#name").val( jQuery.trim( $("#name") ) ); </code></pre>
[ { "answer_id": 219013, "author": "micahwittman", "author_id": 11181, "author_profile": "https://Stackoverflow.com/users/11181", "pm_score": 3, "selected": false, "text": "$('input, textarea').each(function(){\n $(this).val(jQuery.trim($(this).val()));\n});\n" }, { "answer_id":...
2008/10/20
[ "https://Stackoverflow.com/questions/218794", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24841/" ]
218,798
<p>The output of my JSON call can either be an Array or a Hash. How do I distinguish between these two?</p>
[ { "answer_id": 218833, "author": "Borgar", "author_id": 27388, "author_profile": "https://Stackoverflow.com/users/27388", "pm_score": 5, "selected": false, "text": "function isObject ( obj ) {\n return obj && (typeof obj === \"object\");\n}\n" }, { "answer_id": 218834, "au...
2008/10/20
[ "https://Stackoverflow.com/questions/218798", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29653/" ]
218,806
<p>I am wondering how the JBoss ExceptionSorter classes are able to check for database errors.</p> <p>The application (the EJB or persistence framework) is holding the reference to the database Connection, so SQLExceptions are caught by the application. How is JBoss able to see the contents of the exception?</p> <p>Does JBoss wrap the connection and intercept these messages or something like that?</p>
[ { "answer_id": 360041, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "<property name=\"exceptionSorterClassName\"><value>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</value></prope...
2008/10/20
[ "https://Stackoverflow.com/questions/218806", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25688/" ]
218,808
<p>I've got a <code>DateTime?</code> that I'm trying to insert into a field using a <code>DbParameter</code>. I'm creating the parameter like so:</p> <pre><code>DbParameter datePrm = updateStmt.CreateParameter(); datePrm.ParameterName = "@change_date"; </code></pre> <p>And then I want to put the value of the <code>DateTime?</code> into the <code>dataPrm.Value</code> while accounting for <code>null</code>s.</p> <p>I thought initially I'd be clever:</p> <pre><code>datePrm.Value = nullableDate ?? DBNull.Value; </code></pre> <p>but that fails with the error</p> <blockquote> <p>Operator '??' cannot be applied to operands of type 'System.DateTime?' and 'System.DBNull'</p> </blockquote> <p>So I guess that only works if the second argument is a non-nullable version of the first argument. So then I went for:</p> <pre><code>datePrm.Value = nullableDate.HasValue ? nullableDate.Value : DBNull.Value; </code></pre> <p>but that doesn't work either:</p> <blockquote> <p>Type of conditional expression cannot be determined because there is no implicit conversion between 'System.DateTime' and 'System.DBNull'</p> </blockquote> <p>But I don't want to convert between those types!</p> <p>So far the only thing I can get to work is:</p> <pre><code>if (nullableDate.HasValue) datePrm.Value = nullableDate.Value; else datePrm.Value = DBNull.Value; </code></pre> <p>Is that really the only way I can write this? Is there a way to get a one-liner using the ternary operator to work?</p> <p><strong>Update:</strong> I don't really get why the ?? version doesn't work. MSDN says:</p> <blockquote> <p>The ?? operator returns the left-hand operand if it is not null, or else it returns the right operand.</p> </blockquote> <p>That's exactly what I want!</p> <p><strong>Update2:</strong> Well it was kind of obvious in the end:</p> <pre><code>datePrm.Value = nullableDate ?? (object)DBNull.Value; </code></pre>
[ { "answer_id": 218843, "author": "dnolan", "author_id": 29086, "author_profile": "https://Stackoverflow.com/users/29086", "pm_score": 3, "selected": false, "text": "datePrm.Value = nullableDate.HasValue ? (object)nullableDate.Value : DBNull.Value;\n" }, { "answer_id": 218844, ...
2008/10/20
[ "https://Stackoverflow.com/questions/218808", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6408/" ]
218,813
<p>I have a static method in my code that I would like somehow to mock.</p> <p>I am using jmock.</p> <p>One way I suppose I could do this is to have "wrapper class" around the static method and mock this but I was hoping for a better solution.</p> <p>I am going about this the wrong way?</p> <p>FEEDBACK:</p> <p>I was going to have a interface and class that had a method that just called the static method. It would allow me to mock the logic by just mocking the call to this wrapper class. (I feel dirty even talking about it :) )</p>
[ { "answer_id": 1053272, "author": "Rogério", "author_id": 2326914, "author_profile": "https://Stackoverflow.com/users/2326914", "pm_score": 3, "selected": false, "text": "\n List<Person> peopleAboveAge = \n find(\"select p from Person p where p.age >= ?\", age);\n" } ]
2008/10/20
[ "https://Stackoverflow.com/questions/218813", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3050/" ]
218,825
<p>I have three Java <code>JCheckboxes</code> in a column, arranged by setting the layout of the container <code>JPanel</code> to <code>GridLayout(3, 1, 1, 1)</code>. When I run the program, there is too much vertical space between the JCheckBoxes; it looks like more than 1 pixel. Since I've already set the vertical space between the JCheckboxes in the layout to be 1 pixel, how else can I reduce the vertical space between these JCheckboxes?</p> <p>Thanks.</p>
[ { "answer_id": 219198, "author": "Alex B", "author_id": 6180, "author_profile": "https://Stackoverflow.com/users/6180", "pm_score": 2, "selected": false, "text": "GridLayout" }, { "answer_id": 221513, "author": "Steve McLeod", "author_id": 2959, "author_profile": "htt...
2008/10/20
[ "https://Stackoverflow.com/questions/218825", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
218,845
<p>I have a news site with articles tagged in categories.</p> <p>My Controller is called "Category" and this URL:</p> <blockquote> <p><code>http://mysite.com/Category/Sport</code></p> </blockquote> <p>passes <code>Sport</code> to action <code>Index</code> in controller <code>Category</code>.</p> <p>I want to allow the following URLs:</p> <blockquote> <p><code>http://mysite.com/Sport/Hockey</code><br> <code>http://mysite.com/Sport/Football</code><br> <code>http://mysite.com/Science/Evolution</code> </p> </blockquote> <p>Which passes all category information to action <code>Index</code> in controller <code>Category</code>.</p> <p>How do I create a catch-all route that handles all these and shuttles them to category?</p>
[ { "answer_id": 37267580, "author": "jgauffin", "author_id": 70386, "author_profile": "https://Stackoverflow.com/users/70386", "pm_score": 0, "selected": false, "text": "routes.MapRoute(\"Default\", \"{category}/{subcategory}\",\n new { controller = \"CategoryController\", action = \"D...
2008/10/20
[ "https://Stackoverflow.com/questions/218845", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29181/" ]
218,848
<p>I need to give users the ability to optionally add metadata to documents. Another way to state this is the fact that users need to add at least 5 categories to a document.</p> <p>Basically what I want to do is dynamically add metadata (or categories) to a document on an ad hoc basis. Here are the options that I have thought of:</p> <p><strong>Option 1:</strong> Should I do this by dynamically creating new table columns in the database? </p> <p><strong>Option 2:</strong> Should I define 5 columns called attirbute1,attirbute2,attirbute3,attirbute4,attirbute5 and then only use and show them if the user requires the attributes. </p> <p><strong>Option 3:</strong> Should I create a metadata table that keeps track of the columns and the data associated with them? </p> <p>What do you think is the best way to achieve this? Can you think of any other ways to easily add this functionality. The problem is that the functionality needs to be very generic.</p>
[ { "answer_id": 218993, "author": "Richard T", "author_id": 26976, "author_profile": "https://Stackoverflow.com/users/26976", "pm_score": 1, "selected": false, "text": "create table DocMetaData\n(\n DocumentHandle varchar NOT NULL,\n MetaDataName varchar NOT NULL,\n ...
2008/10/20
[ "https://Stackoverflow.com/questions/218848", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29441/" ]
218,857
<p>I have a class that contains a bunch of properties. It is a mistake by a programmer if they call ToString() on an object of that type. Take this example code:</p> <pre><code>using System; public class Foo { public int ID = 123; public string Name = "SomeName"; private string ToString() { return null; } } public class MyClass { public static void Main() { Foo myObj = new Foo(); WL("I want this to be a compiler error: {0}", myObj.ToString()); RL(); } #region Helper methods private static void WL(object text, params object[] args) { Console.WriteLine(text.ToString(), args); } private static void RL() { Console.ReadLine(); } #endregion } </code></pre> <p>You could reason that if ID is what most people want written out as a string, then I should implement ToString so that it returns the ID. However, I believe that is a bad practice because programmers will "accidentally" get working code. A programmer using my class should specify what they want.</p> <p>Instead, what I would like is if someone calls myObj.ToString() to have that show up as a compile time error. I thought I could do that by creating a private ToString() function, but that doesn't work.</p> <p>The reason I brought this up is that we ended up with a query string that contained the fully qualified class name rather then an ID. </p> <p>So the question is: <strong>Is there any way to "hide" the ToString() function so that calling it on an object of my class causes a compiler error?</strong></p>
[ { "answer_id": 218868, "author": "Sander", "author_id": 2928, "author_profile": "https://Stackoverflow.com/users/2928", "pm_score": 4, "selected": false, "text": "[Obsolete(\"Use the XYZ properties instead of .ToString() on Foobar\", true)]\n" }, { "answer_id": 218885, "autho...
2008/10/20
[ "https://Stackoverflow.com/questions/218857", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
218,866
<p>I have data from MySQL showing all organisations a customer got, with all details of employess in each organisation. I want to list each organisation name only once i.e. in a single cell ( row span) and all employees in that organisation against this name like:</p> <pre><code>Org1 Emp1 Name, Emp1 Phone, Emp1 Address Emp2 Name, Emp2 Phone, Emp2 Address Org2 Emp1 Name, Emp1 Phone, Emp1 Address Emp2 Name, Emp2 Phone, Emp2 Address </code></pre> <p>How do I display this data because the number of employess for each organisation is not known in advanced, so I do'nt about setting value of rowspan. Similarly how do I start a row for other organisation? Do I have to write two queries?</p> <p>Many Thanks.</p>
[ { "answer_id": 218900, "author": "Veynom", "author_id": 11670, "author_profile": "https://Stackoverflow.com/users/11670", "pm_score": 3, "selected": true, "text": "$currentOrg = '';\nwhile ($row = mysql_fetch_object($query)) {\n if ($row->org != $currentOrg) {\n echo \"$row->org\"...
2008/10/20
[ "https://Stackoverflow.com/questions/218866", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29656/" ]
218,888
<p>I have 3 classes that are essentially the same but don't implement an interface because they all come from different web services. </p> <p>e.g.</p> <ul> <li>Service1.Object1</li> <li>Service2.Object1</li> <li>Service3.Object1</li> </ul> <p>They all have the same properties and I am writing some code to map them to each other using an intermediary object which implements my own interface IObject1</p> <p>I've done this using generics</p> <pre><code>public static T[] CreateObject1&lt;T&gt;(IObject1[] properties) where T : class, new() { //Check the type is allowed CheckObject1Types("CreateObject1&lt;T&gt;(IObject1[])", typeof(T)); return CreateObjectArray&lt;T&gt;(properties); } private static void CheckObject1Types(string method, Type type) { if (type == typeof(Service1.Object1) || type == typeof(Service2.Object1) || type == typeof(Service3.Object1) || type == typeof(Service1.Object1[]) || type == typeof(Service2.Object1[]) || type == typeof(Service3.Object1[])) { return; } throw new ArgumentException("Incorrect type passed to ServiceObjectFactory::" + method + ". Type:" + type.ToString()); } </code></pre> <p>My client code looks like:</p> <pre><code>//properties is an array of my intermediary objects Object1[] props = ServiceObjectFactory.CreateObject1&lt;Object1&gt;(properties); </code></pre> <p>What I want to do is get rid of the CheckObject1Types method and use constraints instead so that I get a build error if the types aren't valid, because at the moment I can call this method with any type and the ArgumentException is thrown by the CheckObject1Types method.</p> <p>So I'd like to do something like:</p> <pre><code>public static T[] CreateObject1&lt;T&gt;(IObject1[] properties) where T : class, new(), Service1.Object1|Service2.Object1|Service3.Object1 { return CreateObjectArray&lt;T&gt;(properties); } </code></pre> <p>Any ideas?</p> <p><strong>Edit:</strong> I don't want to change the Reference.cs files for each webservice because all it takes is a team mate to update the web reference and BAM! broken code.</p>
[ { "answer_id": 218930, "author": "Scott Dorman", "author_id": 1559, "author_profile": "https://Stackoverflow.com/users/1559", "pm_score": 1, "selected": false, "text": "namespace TestServices\n{\n internal partial class Service1SoapClient : System.ServiceModel.ClientBase<T>, K\n {\n ...
2008/10/20
[ "https://Stackoverflow.com/questions/218888", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4950/" ]
218,904
<p>I am using TortoiseSVN for my Subversion repository held on a USB drive. When I move from one PC to another, is there a way to automatically identify that files are out of date (without using the Check for Modifications menu). It would be nice just to be able to see that the folder on my hard drive did not match that of the repository, rather than seeing the green tick.</p>
[ { "answer_id": 219033, "author": "onnodb", "author_id": 1037, "author_profile": "https://Stackoverflow.com/users/1037", "pm_score": 3, "selected": true, "text": "[autorun]\nopen=CheckForMods.bat\n" } ]
2008/10/20
[ "https://Stackoverflow.com/questions/218904", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21862/" ]
218,908
<p>Is there a best way to turn an integer into its month name in .net?</p> <p>Obviously I can spin up a datetime to string it and parse the month name out of there. That just seems like a gigantic waste of time.</p>
[ { "answer_id": 218927, "author": "leppie", "author_id": 15541, "author_profile": "https://Stackoverflow.com/users/15541", "pm_score": 4, "selected": false, "text": "somedatetime.ToString(\"MMMM\")" }, { "answer_id": 218947, "author": "Tokabi", "author_id": 315, "autho...
2008/10/20
[ "https://Stackoverflow.com/questions/218908", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1220/" ]
218,909
<p><strong>EDIT:</strong> See <a href="https://stackoverflow.com/questions/218909/returning-a-pdf-file-from-a-java-bean-to-a-jsp#221252">my working code</a> in the answers below.</p> <hr> <p><strong>In brief:</strong> I have a JSP file which calls a method in a Java Bean. This method creates a PDF file and in theory, returns it to the JSP so that the user can download it. However, upon loading the PDF, Adobe Reader gives the error: <em>File does not begin with '%PDF-'</em>.</p> <p><strong>In detail:</strong> So far, the JSP successfully calls the method, the PDF is created and then the JSP appears to give the user the finished PDF file. However, as soon as Adobe Reader tries to open the PDF file, it gives an error: <em>File does not begin with '%PDF-'</em>. Just for good measure, I have the method create the PDF on my Desktop so that I can check it; when I open it normally within Windows is appears fine. So why is the output from the JSP different?</p> <p>To create the PDF, I'm using <a href="http://xmlgraphics.apache.org/fop" rel="nofollow noreferrer">Apache FOP</a>. I'm following one of their most basic examples, with the exception of passing the resulting PDF to a JSP instead of simply saving it to the local machine. I have been following their <a href="http://xmlgraphics.apache.org/fop/0.95/embedding.html#basics" rel="nofollow noreferrer">basic usage pattern</a> and <a href="http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/examples/embedding/java/embedding/ExampleFO2PDF.java?view=markup" rel="nofollow noreferrer">this example code</a>.</p> <p>Here's my JSP file:</p> <pre><code>&lt;%@ taglib uri="utilTLD" prefix="util" %&gt; &lt;%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %&gt; &lt;%@ taglib uri="http://java.sun.com/jsp/jstl/xml" prefix="x" %&gt; &lt;%@ page language="java" session="false" %&gt; &lt;%@ page contentType="application/pdf" %&gt; &lt;%-- Construct and initialise the PrintReportsBean --%&gt; &lt;jsp:useBean id="printReportsBean" scope="request" class="some.package.printreports.PrintReportsBean" /&gt; &lt;jsp:setProperty name="printReportsBean" property="*"/&gt; &lt;c:set scope="page" var="xml" value="${printReportsBean.download}"/&gt; </code></pre> <p>Here's my Java Bean method:</p> <pre><code>//earlier in the class... private static FopFactory fopFactory = FopFactory.newInstance(); public File getDownload() throws UtilException { OutputStream out = null; File pdf = new File("C:\\documents and settings\\me\\Desktop\\HelloWorld.pdf"); File fo = new File("C:\\somedirectory", "HelloWorld.fo"); try { FOUserAgent foUserAgent = fopFactory.newFOUserAgent(); out = new FileOutputStream(pdf); out = new BufferedOutputStream(out); Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, out); TransformerFactory factory = TransformerFactory.newInstance(); Transformer transformer = factory.newTransformer(); //identity transformer Source src = new StreamSource(fo); Result res = new SAXResult(fop.getDefaultHandler()); transformer.transform(src, res); return pdf; } catch (Exception e) { throw new UtilException("Could not get download. Msg = "+e.getMessage()); } finally { try { out.close(); } catch (IOException io) { throw new UtilException("Could not close OutputStream. Msg = "+io.getMessage()); } } } </code></pre> <p>I realise that this is a very specific problem, but any help would be much appreciated!</p>
[ { "answer_id": 219102, "author": "Leonel Martins", "author_id": 26673, "author_profile": "https://Stackoverflow.com/users/26673", "pm_score": 0, "selected": false, "text": "<%@ page trimDirectiveWhitespaces=\"true\" %>\n" }, { "answer_id": 221252, "author": "Philip Morton", ...
2008/10/20
[ "https://Stackoverflow.com/questions/218909", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21709/" ]