qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
130,803
<p>I'm not that up on VB.NET, the application I'm working on was not written by myself.<br> It works fine through the IDE but once I run it from the exe it gives me the above error.</p> <p>Any clues?</p> <p>This is really hacking me off!</p>
[ { "answer_id": 130831, "author": "MagicKat", "author_id": 8505, "author_profile": "https://Stackoverflow.com/users/8505", "pm_score": 3, "selected": false, "text": "Debugger.Break()\n" }, { "answer_id": 6346654, "author": "Michael Eakins", "author_id": 437301, "author...
2008/09/25
[ "https://Stackoverflow.com/questions/130803", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17579/" ]
130,829
<p>I have 3 points in a 3D space of which I know the exact locations. Suppose they are: <code>(x0,y0,z0)</code>, <code>(x1,y1,z1)</code> and <code>(x2,y2,z2)</code>.</p> <p>Also I have a camera that is looking at these 3 points and I know the 2D locations of those three points on camera view plane. So for example <code>(x0,y0,z0)</code> will be <code>(x0',y0')</code>, and <code>(x1,y1,z1)</code> will be <code>(x1',y1')</code> and <code>(x2,y2,z2)</code> will be <code>(x2',y2')</code> from the camera's point of view.</p> <p>What is the easiest way to find the projection matrix that will project those 3D points into 2D points on camera view plane. We don't know anything about the camera location.</p>
[ { "answer_id": 130909, "author": "tye", "author_id": 21496, "author_profile": "https://Stackoverflow.com/users/21496", "pm_score": 5, "selected": true, "text": "a*x0+b*y0+c*z0 = x0'\na*x1+b*y1+c*z1 = x1'\na*x2+b*y2+c*z2 = x2'\n\nd*x0+e*y0+f*z0 = y0'\nd*x1+e*y1+f*z1 = y1'\nd*x2+e*y2+f*z2 ...
2008/09/25
[ "https://Stackoverflow.com/questions/130829", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
130,837
<p>I'm still learning RegEx at the moment, but for the time being could someone help me out with this? I have a few special requirements for formatting the string:</p> <ol> <li>No directories. JUST the file name.</li> <li>File name needs to be all lowercase.</li> <li>Whitespaces need to be replaced with underscores.</li> </ol> <p>Shouldn't be hard, but I'm pressed for time and I'm not sure on the 'correct' way to ensure a valid file name (namely I forget which characters were supposed to be invalid for file names).</p>
[ { "answer_id": 130845, "author": "Grank", "author_id": 12975, "author_profile": "https://Stackoverflow.com/users/12975", "pm_score": 2, "selected": false, "text": "([0-9a-z_-]+[\\.][0-9a-z_-]{1,3})$\n" }, { "answer_id": 139301, "author": "bobince", "author_id": 18936, ...
2008/09/25
[ "https://Stackoverflow.com/questions/130837", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19825/" ]
130,843
<p>Using Prototype 1.6's "new Element(...)" I am trying to create a &lt;table&gt; element with both a &lt;thead&gt; and &lt;tbody&gt; but nothing happens in IE6.</p> <pre><code>var tableProto = new Element('table').update('&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Situation Task&lt;/th&gt;&lt;th&gt;Action&lt;/th&gt;&lt;th&gt;Result&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;a&lt;/td&gt;&lt;td&gt;b&lt;/td&gt;&lt;td&gt;c&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;'); </code></pre> <p>I'm then trying to inject copies of it like this:</p> <pre><code>$$('div.question').each(function(o) { Element.insert(o, { after:$(tableProto.cloneNode(true)) }); }); </code></pre> <p>My current workaround is to create a &lt;div&gt; instead of a &lt;table&gt; element, and then "update" it with all of the table HTML.</p> <p>How does one successfully do this?</p>
[ { "answer_id": 131460, "author": "Zack The Human", "author_id": 18265, "author_profile": "https://Stackoverflow.com/users/18265", "pm_score": 4, "selected": true, "text": "var tableProto = new Element('table', { class:'hide-on-screen'} ).update('<thead><tr><th>Situation Task</th><th>Acti...
2008/09/25
[ "https://Stackoverflow.com/questions/130843", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18265/" ]
130,877
<p>What function will let us know whether a date in VBA is in DST or not?</p>
[ { "answer_id": 130879, "author": "Lance Roberts", "author_id": 13295, "author_profile": "https://Stackoverflow.com/users/13295", "pm_score": 4, "selected": true, "text": "Public Function NDow(Y As Integer, M As Integer, _\n N As Integer, DOW As Integer) As Date \n\n' Retu...
2008/09/25
[ "https://Stackoverflow.com/questions/130877", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13295/" ]
130,878
<p>What is the benefit of using singleton instead of global for database connections in PHP? I feel using singleton instead of global makes the code unnecessarily complex.</p> <h2>Code with Global</h2> <pre><code>$conn = new PDO(...); function getSomething() { global $conn; . . . } </code></pre> <h2>Code with Singleton</h2> <pre><code>class DB_Instance { private static $db; public static function getDBO() { if (!self::$db) self::$db = new PDO(...); return self::$db; } } function getSomething() { $conn = DB_Instance::getDBO(); . . . } </code></pre> <p>If there's a better way of initializing database connection other than global or singleton, please mention it and describe the advantages it have over global or singleton.</p>
[ { "answer_id": 219599, "author": "Jon Raphaelson", "author_id": 27546, "author_profile": "https://Stackoverflow.com/users/27546", "pm_score": 8, "selected": true, "text": "class ConnectionFactory\n{\n private static $factory;\n private $db;\n\n public static function getFactory(...
2008/09/25
[ "https://Stackoverflow.com/questions/130878", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1897/" ]
130,894
<p>I have the source of a program (taken from cvs/svn/git/...) and I'd like to build a Debian/Ubuntu package for it. The package is present in the repositories, but:</p> <ul> <li>It is an older version (lacking features I need)</li> <li>I need slightly different compile options than the default.</li> </ul> <p>What is the easiest way of doing it? I am concerned about a couple of things</p> <ul> <li>How can I check if I have listed all the dependencies correctly? (I can get some hints by looking on what the older version depended, but new dependencies may have been added.)</li> <li>How I can I prevent the update system installing the older version in the repo on an update?</li> <li>How I can prevent the system installing a newer version (when its out), overwriting my custom package?</li> </ul>
[ { "answer_id": 131090, "author": "Daniel Bungert", "author_id": 21093, "author_profile": "https://Stackoverflow.com/users/21093", "pm_score": 5, "selected": false, "text": "dpkg-buildpackage -us -uc -nc\n" }, { "answer_id": 133844, "author": "Mark Baker", "author_id": 118...
2008/09/25
[ "https://Stackoverflow.com/questions/130894", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19922/" ]
130,898
<p>How can I perform list comprehensions in C#?</p>
[ { "answer_id": 130915, "author": "Ian P", "author_id": 10853, "author_profile": "https://Stackoverflow.com/users/10853", "pm_score": -1, "selected": false, "text": "public List<string> ValidUsers(List<User> users) {\n List<string> names = new List<string>();\n foreach(User user in user...
2008/09/25
[ "https://Stackoverflow.com/questions/130898", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21944/" ]
130,913
<p>Is it at the state where it is actually useful and can do more than rename classes?</p>
[ { "answer_id": 130926, "author": "Benoit", "author_id": 10703, "author_profile": "https://Stackoverflow.com/users/10703", "pm_score": 6, "selected": true, "text": "* Declare Method\n* Extract Baseclass\n* Extract Constant\n* Extract Method\n* Extract Subclass\n* Hide Method\n* Implement ...
2008/09/25
[ "https://Stackoverflow.com/questions/130913", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13760/" ]
130,916
<p>I need to keep as much as I can of large file in the operating system block cache even though it's bigger than I can fit in ram, and I'm continously reading another very very large file. ATM I'll remove large chunk of large important file from system cache when I stream read form another file.</p>
[ { "answer_id": 130983, "author": "Sufian", "author_id": 9241, "author_profile": "https://Stackoverflow.com/users/9241", "pm_score": 2, "selected": false, "text": "mount -t tmpfs none /mnt/point\n" }, { "answer_id": 154047, "author": "Don Neufeld", "author_id": 13097, ...
2008/09/25
[ "https://Stackoverflow.com/questions/130916", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15307/" ]
130,941
<p>In a VB.Net Windows Service I'm currently pooling units of work with: </p> <pre><code>ThreadPool.QueueUserWorkItem(operation, nextQueueID) </code></pre> <p>In each unit of work (or thread I'll use for ease of understanding), it will make a couple MSSQL operations like so: </p> <pre><code> Using sqlcmd As New SqlCommand("", New SqlConnection(ConnString)) With sqlcmd .CommandType = CommandType.Text .CommandText = "UPDATE [some table]" .Parameters.Add("@ID", SqlDbType.Int).Value = msgID .Connection.Open() .ExecuteNonQuery() .Connection.Close() 'Found connections not closed quick enough' End With End Using </code></pre> <p>When running a <code>netstat -a -o</code> on the server I'm seeing about 50 connections to SQL server sitting on <code>IDLE</code> or <code>ESTABLISHED</code>, this seems excessive to me especially since we have much larger Web Applications that get by with 5-10 connections. </p> <p>The connection string is global to the application (doesn't change), and has <code>Pooling=true</code> defined as well. </p> <p>Now will each of these threads have their own <code>ConnectionPool</code>, or is there one <code>ConnectionPool</code> for the entire .EXE process?</p>
[ { "answer_id": 131787, "author": "Joe", "author_id": 13087, "author_profile": "https://Stackoverflow.com/users/13087", "pm_score": 2, "selected": false, "text": "Using SqlConnection connection = New SqlConnection(ConnString)\n Using sqlcmd As New SqlCommand(\"\", connection) \n...
2008/09/25
[ "https://Stackoverflow.com/questions/130941", "https://Stackoverflow.com", "https://Stackoverflow.com/users/952/" ]
130,948
<p>I need an easy way to take a tar file and convert it into a string (and vice versa). Is there a way to do this in Ruby? My best attempt was this:</p> <pre><code>file = File.open("path-to-file.tar.gz") contents = "" file.each {|line| contents &lt;&lt; line } </code></pre> <p>I thought that would be enough to convert it to a string, but then when I try to write it back out like this...</p> <pre><code>newFile = File.open("test.tar.gz", "w") newFile.write(contents) </code></pre> <p>It isn't the same file. Doing <code>ls -l</code> shows the files are of different sizes, although they are pretty close (and opening the file reveals most of the contents intact). Is there a small mistake I'm making or an entirely different (but workable) way to accomplish this?</p>
[ { "answer_id": 130984, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": false, "text": "require 'base64'\n\nfile_contents = Base64.encode64(tar_file_data)\n" }, { "answer_id": 130987, "author": "Purfide...
2008/09/25
[ "https://Stackoverflow.com/questions/130948", "https://Stackoverflow.com", "https://Stackoverflow.com/users/422/" ]
131,014
<p>I have a table that has redundant data and I'm trying to identify all rows that have duplicate sub-rows (for lack of a better word). By sub-rows I mean considering <code>COL1</code> and <code>COL2</code> only. </p> <p>So let's say I have something like this:</p> <pre><code> COL1 COL2 COL3 --------------------- aa 111 blah_x aa 111 blah_j aa 112 blah_m ab 111 blah_s bb 112 blah_d bb 112 blah_d cc 112 blah_w cc 113 blah_p </code></pre> <p>I need a SQL query that returns this:</p> <pre><code> COL1 COL2 COL3 --------------------- aa 111 blah_x aa 111 blah_j bb 112 blah_d bb 112 blah_d </code></pre>
[ { "answer_id": 131018, "author": "Jerub", "author_id": 14648, "author_profile": "https://Stackoverflow.com/users/14648", "pm_score": 2, "selected": false, "text": "SELECT a.col3, b.col3, a.col1, a.col2 \nFROM tablename a, tablename b\nWHERE a.col1 = b.col1 AND a.col2 = b.col2 AND a.col3 ...
2008/09/25
[ "https://Stackoverflow.com/questions/131014", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10708/" ]
131,023
<p>I know there is a list-comprehension library for common lisp (<a href="http://superadditive.com/projects/incf-cl/" rel="noreferrer">incf-cl</a>), I know they're supported natively in various other functional (and some non-functional) languages (F#, Erlang, Haskell and C#) - is there a list comprehension library for Scheme?</p> <p>incf-cl is implemented in CL as a library using macros - shouldn't it be possible to use the same techniques to create one for Scheme?</p>
[ { "answer_id": 131246, "author": "Nathan Shively-Sanders", "author_id": 7851, "author_profile": "https://Stackoverflow.com/users/7851", "pm_score": 4, "selected": true, "text": "(require srfi/42)" } ]
2008/09/25
[ "https://Stackoverflow.com/questions/131023", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19784/" ]
131,025
<p>Is it possible to do at least one of the following:</p> <p>1) Detect a setting of a Local Security Policy (Accounts: Limit local account use of blank passwords to console logon only)</p> <p>2) Modify that setting</p> <p>Using Win32/MFC?</p>
[ { "answer_id": 131246, "author": "Nathan Shively-Sanders", "author_id": 7851, "author_profile": "https://Stackoverflow.com/users/7851", "pm_score": 4, "selected": true, "text": "(require srfi/42)" } ]
2008/09/25
[ "https://Stackoverflow.com/questions/131025", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20208/" ]
131,040
<p>I am creating a component and want to expose a color property as many flex controls do, lets say I have simple component like this, lets call it foo_label:</p> <pre> <code> &lt;mx:Canvas> &lt;mx:Script> [Bindable] public var color:uint; &lt;/mx:Script> &lt;mx:Label text="foobar" color="{color}" /> &lt;/mx:Canvas> </code> </pre> <p>and then add the component in another mxml file, something along the lines of:</p> <pre> <code> &lt;foo:foo_label color="red" /> </code> </pre> <p>When I compile the compiler complains: cannot parse value of type uint from text 'red'. However if I use a plain label I can do</p> <pre><code>&lt;mx:Label text="foobar" color="red"></code></pre> <p>without any problems, and the color property is still type uint. </p> <p>My question is how can I expose a public property so that I can control the color of my components text? Why can I use the string "red" as a uint field for the mx controls but cannot seem to do the same in a custom component, do I need to do something special?</p> <p>Thanks.</p>
[ { "answer_id": 132076, "author": "Borek Bernard", "author_id": 21728, "author_profile": "https://Stackoverflow.com/users/21728", "pm_score": 4, "selected": true, "text": "[Style(name=\"labelColor\", type=\"uint\", format=\"Color\" )]\n" }, { "answer_id": 7631250, "author": "t...
2008/09/25
[ "https://Stackoverflow.com/questions/131040", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1638/" ]
131,049
<p>I installed mediawiki on my server as my personal knowledge base. Sometimes I copy some stuff from Web and paste to my wiki - such as tips &amp; tricks from somebody's blog. How do I make the copied content appear in a box with border?</p> <p>For example, the box at the end of this blog post looks pretty nice:<br> <a href="http://blog.dreamhost.com/2008/03/21/good-reminiscing-friday/" rel="noreferrer">http://blog.dreamhost.com/2008/03/21/good-reminiscing-friday/</a></p> <p>I could use the pre tag, but paragraphs in a pre tag won't wrap automatically.. Any ideas?</p>
[ { "answer_id": 131330, "author": "Steve K", "author_id": 739, "author_profile": "https://Stackoverflow.com/users/739", "pm_score": 2, "selected": false, "text": "<div style=\"background-color: cyan; border-style: dashed;\">\nA bunch of text that will wrap.\n</div>\n" }, { "answer...
2008/09/25
[ "https://Stackoverflow.com/questions/131049", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14068/" ]
131,050
<p>Since AS3 does not allow private constructors, it seems the only way to construct a singleton and guarantee the constructor isn't explicitly created via "new" is to pass a single parameter and check it.</p> <p>I've heard two recommendations, one is to check the caller and ensure it's the static getInstance(), and the other is to have a private/internal class in the same package namespace.</p> <p>The private object passed on the constructor seems preferable but it does not look like you can have a private class in the same package. Is this true? And more importantly is it the best way to implement a singleton?</p>
[ { "answer_id": 131294, "author": "Adam Ness", "author_id": 21973, "author_profile": "https://Stackoverflow.com/users/21973", "pm_score": 0, "selected": false, "text": "public class Foo {\n private static var instance : Foo;\n\n public Foo() {\n if( instance != null ) { \n throw...
2008/09/25
[ "https://Stackoverflow.com/questions/131050", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14747/" ]
131,053
<p>I have been getting an error in <strong>VB .Net</strong> </p> <blockquote> <p>object reference not set to an instance of object.</p> </blockquote> <p>Can you tell me what are the causes of this error ?</p>
[ { "answer_id": 131055, "author": "Nescio", "author_id": 14484, "author_profile": "https://Stackoverflow.com/users/14484", "pm_score": 3, "selected": false, "text": "Option Strict On\nOption Explicit On\n" }, { "answer_id": 131098, "author": "Blair Conrad", "author_id": 11...
2008/09/25
[ "https://Stackoverflow.com/questions/131053", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21963/" ]
131,056
<p>Not sure how to ask a followup on SO, but this is in reference to an earlier question: <a href="https://stackoverflow.com/questions/94930/fetch-one-row-per-account-id-from-list">Fetch one row per account id from list</a></p> <p>The query I'm working with is:</p> <pre><code>SELECT * FROM scores s1 WHERE accountid NOT IN (SELECT accountid FROM scores s2 WHERE s1.score &lt; s2.score) ORDER BY score DESC </code></pre> <p>This selects the top scores, and limits results to one row per accountid; their top score.</p> <p>The last hurdle is that this query is returning multiple rows for accountids that have multiple occurrences of their top score. So if accountid 17 has scores of 40, 75, 30, 75 the query returns both rows with scores of 75.</p> <p>Can anyone modify this query (or provide a better one) to fix this case, and truly limit it to one row per account id?</p> <p>Thanks again!</p>
[ { "answer_id": 131060, "author": "Josh", "author_id": 11702, "author_profile": "https://Stackoverflow.com/users/11702", "pm_score": 0, "selected": false, "text": "SELECT DISTINCT UserID, score\nFROM scores s1\nWHERE accountid NOT IN (SELECT accountid FROM scores s2 WHERE s1.score < s2.sc...
2008/09/25
[ "https://Stackoverflow.com/questions/131056", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13636/" ]
131,062
<p>I've read numerous posts about people having problems with <code>viewWillAppear</code> when you do not create your view hierarchy <em>just</em> right. My problem is I can't figure out what that means.</p> <p>If I create a <code>RootViewController</code> and call <code>addSubView</code> on that controller, I would expect the added view(s) to be wired up for <code>viewWillAppear</code> events. </p> <p>Does anyone have an example of a complex programmatic view hierarchy that successfully receives <code>viewWillAppear</code> events at every level?</p> <p>Apple's Docs state:</p> <blockquote> <p>Warning: If the view belonging to a view controller is added to a view hierarchy directly, the view controller will not receive this message. If you insert or add a view to the view hierarchy, and it has a view controller, you should send the associated view controller this message directly. Failing to send the view controller this message will prevent any associated animation from being displayed.</p> </blockquote> <p>The problem is that they don't describe how to do this. What does "directly" mean? How do you "indirectly" add a view?</p> <p>I am fairly new to Cocoa and iPhone so it would be nice if there were useful examples from Apple besides the basic Hello World crap.</p>
[ { "answer_id": 135418, "author": "Josh Gagnon", "author_id": 7944, "author_profile": "https://Stackoverflow.com/users/7944", "pm_score": 3, "selected": false, "text": "[self.navigationController pushViewController:<view> animated:<BOOL>];\n" }, { "answer_id": 144935, "author"...
2008/09/25
[ "https://Stackoverflow.com/questions/131062", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21964/" ]
131,068
<p>The Date object in JavaScript performs differently machine to machine and browser to browser in respect to the function's resolution in milliseconds. I've found most machines have a resolution of about 16 ms on IE, where Chrome or Firefox may have a resolution as good as 1ms.</p> <p>Is there another function available to JavaScript in general or IE specifically that will give a better time resolution? I am trying to trap and record <code>keyDown</code> and <code>keyUp</code> times in milliseconds and need it in the +/- 10 ms range or less.</p> <p>To see an illustration of this, check out the "resolutions of new date()" section of this page. There is a table with a test button that evaluates the current machine/browser's JavaScript time resolution in milliseconds. Interestingly, Chrome regularly gets a resolution of 1ms. </p> <p><a href="http://www.merlyn.demon.co.uk/js-dates.htm#OV" rel="nofollow noreferrer">http://www.merlyn.demon.co.uk/js-dates.htm#OV</a> </p> <p>My quest is for a JavaScript date-time method that will give sub 10ms resolution across browsers. something to replace or improve Date().</p>
[ { "answer_id": 131262, "author": "coobird", "author_id": 17172, "author_profile": "https://Stackoverflow.com/users/17172", "pm_score": 2, "selected": false, "text": "System.currentTimeMillis()" } ]
2008/09/25
[ "https://Stackoverflow.com/questions/131068", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21965/" ]
131,085
<p>I would like to create a copy of a database with approximately 40 InnoDB tables and around 1.5GB of data with mysqldump and MySQL 5.1.</p> <p>What are the best parameters (ie: --single-transaction) that will result in the quickest dump and load of the data?</p> <p>As well, when loading the data into the second DB, is it quicker to:</p> <p>1) pipe the results directly to the second MySQL server instance and use the --compress option</p> <p>or</p> <p>2) load it from a text file (ie: mysql &lt; my_sql_dump.sql)</p>
[ { "answer_id": 131114, "author": "John Millikin", "author_id": 3560, "author_profile": "https://Stackoverflow.com/users/3560", "pm_score": 4, "selected": true, "text": "--compress" }, { "answer_id": 4383629, "author": "Dave Dopson", "author_id": 407731, "author_profil...
2008/09/25
[ "https://Stackoverflow.com/questions/131085", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16447/" ]
131,091
<p>I setup my own open id provider on my personal server, and added a redirect to https in my apache config file. When not using a secure connection (when I disable the redirect) I can log in fine, but with the redirect I can't log in with this error message:</p> <p>The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.</p> <p>I'm guessing that this is because I am using a self signed certificate.</p> <p>Can anyone confirm if the self signed certificate is the issue? If not does anyone have any ideas what the problem is?</p>
[ { "answer_id": 239138, "author": "Yang Zhao", "author_id": 31095, "author_profile": "https://Stackoverflow.com/users/31095", "pm_score": 3, "selected": false, "text": "checkid_immediate" } ]
2008/09/25
[ "https://Stackoverflow.com/questions/131091", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9940/" ]
131,110
<p>I am creating an HTTP handler that listens for calls to a specific file type, and handles it accordingly. My HTTP Handler listens for .bcn files, then writes a cookie to the user's computer and sends back an image... this will be used in advertising banners so that the user is tagged as seeing the banner, and we can then offer special deals when they visit our site later.</p> <p>The problem i'm having is getting access to the Page object... of course an HTTPHandler is not actually a page, and since the Response object lives within the Page object, I can't get access to it to write the cookie.</p> <p>Is there a way around this, or do i need to revert back to just using a standard aspx page to do this?</p> <p>Thanks heaps.. Greg</p>
[ { "answer_id": 131152, "author": "Jeeby", "author_id": 21969, "author_profile": "https://Stackoverflow.com/users/21969", "pm_score": 0, "selected": false, "text": "HttpContext.Current.Response.Cookies.Add(cookie);\n" } ]
2008/09/25
[ "https://Stackoverflow.com/questions/131110", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21969/" ]
131,116
<p>I'm wondering if updating statistics has helped you before and how did you know to update them?</p>
[ { "answer_id": 131168, "author": "Ben Hoffstein", "author_id": 4482, "author_profile": "https://Stackoverflow.com/users/4482", "pm_score": 3, "selected": true, "text": "exec sp_updatestats\n" } ]
2008/09/25
[ "https://Stackoverflow.com/questions/131116", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12261/" ]
131,121
<p>If I have a Range object--for example, let's say it refers to cell <code>A1</code> on a worksheet called <code>Book1</code>. So I know that calling <code>Address()</code> will get me a simple local reference: <code>$A$1</code>. I know it can also be called as <code>Address(External:=True)</code> to get a reference including the workbook name and worksheet name: <code>[Book1]Sheet1!$A$1</code>.</p> <p>What I want is to get an address including the sheet name, but not the book name. I really don't want to call <code>Address(External:=True)</code> and try to strip out the workbook name myself with string functions. Is there any call I can make on the range to get <code>Sheet1!$A$1</code>?</p>
[ { "answer_id": 131155, "author": "Ben Hoffstein", "author_id": 4482, "author_profile": "https://Stackoverflow.com/users/4482", "pm_score": 7, "selected": true, "text": "Dim cell As Range\nDim cellAddress As String\nSet cell = ThisWorkbook.Worksheets(1).Cells(1, 1)\ncellAddress = cell.Par...
2008/09/25
[ "https://Stackoverflow.com/questions/131121", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6209/" ]
131,128
<p>Short version: I'm wondering if it's possible, and how best, to utilise CPU specific instructions within a DLL?</p> <p>Slightly longer version: When downloading (32bit) DLLs from, say, Microsoft it seems that one size fits all processors.</p> <p>Does this mean that they are strictly built for the lowest common denominator (ie. the minimum platform supported by the OS)? Or is there some technique that is used to export a single interface within the DLL but utilise CPU specific code behind the scenes to get optimal performance? And if so, how is it done?</p>
[ { "answer_id": 131203, "author": "Adam Pierce", "author_id": 5324, "author_profile": "https://Stackoverflow.com/users/5324", "pm_score": 4, "selected": true, "text": "HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\CentralProcessor\n" }, { "answer_id": 131251, "author": "N...
2008/09/25
[ "https://Stackoverflow.com/questions/131128", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11694/" ]
131,164
<p>I have a number of code value tables that contain a code and a description with a Long id.</p> <p>I now want to create an entry for an Account Type that references a number of codes, so I have something like this:</p> <pre><code>insert into account_type_standard (account_type_Standard_id, tax_status_id, recipient_id) ( select account_type_standard_seq.nextval, ts.tax_status_id, r.recipient_id from tax_status ts, recipient r where ts.tax_status_code = ? and r.recipient_code = ?) </code></pre> <p>This retrieves the appropriate values from the tax_status and recipient tables if a match is found for their respective codes. Unfortunately, recipient_code is nullable, and therefore the ? substitution value could be null. Of course, the implicit join doesn't return a row, so a row doesn't get inserted into my table.</p> <p>I've tried using NVL on the ? and on the r.recipient_id. </p> <p>I've tried to force an outer join on the r.recipient_code = ? by adding (+), but it's not an explicit join, so Oracle still didn't add another row.</p> <p>Anyone know of a way of doing this?</p> <p>I can obviously modify the statement so that I do the lookup of the recipient_id externally, and have a ? instead of r.recipient_id, and don't select from the recipient table at all, but I'd prefer to do all this in 1 SQL statement.</p>
[ { "answer_id": 131183, "author": "oglester", "author_id": 2017, "author_profile": "https://Stackoverflow.com/users/2017", "pm_score": 6, "selected": true, "text": "INSERT INTO account_type_standard \n (account_type_Standard_id, tax_status_id, recipient_id) \nVALUES( \n (SELECT account_...
2008/09/25
[ "https://Stackoverflow.com/questions/131164", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5382/" ]
131,179
<p>Trying to install the RMagick gem is failing with an error about being unable to find ImageMagick libraries, even though I'm sure they are installed.</p> <p>The pertinent output from gem install rmagick is:</p> <pre><code>checking for InitializeMagick() in -lMagick... no checking for InitializeMagick() in -lMagickCore... no checking for InitializeMagick() in -lMagick++... no Can't install RMagick 2.6.0. Can't find the ImageMagick library or one of the dependent libraries. Check the mkmf.log file for more detailed information. *** extconf.rb failed *** </code></pre> <p>And looking in mkmf.log reveals:</p> <pre><code>have_library: checking for InitializeMagick() in -lMagick... -------------------- no "/usr/local/bin/gcc -o conftest -I. -I/usr/local/lib/ruby/1.8/i386-solaris2.10 -I. -I/usr/local/include/ImageMagick -I/usr/local/include/ImageMagick conftest.c -L. - L/usr/local/lib -Wl,-R/usr/local/lib -L/usr/local/lib -L/usr/local/lib -R/usr/local/lib -lfreetype -lz -L/usr/local/lib -L/usr/local/lib -lMagickCore -lruby-static - lMagick -ldl -lcrypt -lm -lc" ld: fatal: library -lMagick: not found ld: fatal: File processing errors. No output written to conftest </code></pre> <p>This is on Solaris 10 x86 with ImageMagick version 6.4.3 and RMagick version 2.6.0</p> <p>If I need to add something to LDFLAGS, its not clear to me what that would be. I installed ImageMagick from source and it should be in the usual places. ie,</p> <pre><code># ls -l /usr/local/lib/ | grep -i magick drwxr-xr-x 5 root root 512 Sep 24 23:09 ImageMagick-6.4.3/ -rw-r--r-- 1 root root 10808764 Sep 25 02:09 libMagickCore.a -rwxr-xr-x 1 root root 1440 Sep 25 02:09 libMagickCore.la* -rw-r--r-- 1 root root 2327072 Sep 25 02:09 libMagickWand.a -rwxr-xr-x 1 root root 1472 Sep 25 02:09 libMagickWand.la* </code></pre> <p>ImageMagick-6.4.3/ contains nothing interesting and I can't find any other files that I might be able to point gem install at.</p> <p>Any advice would be much appreciated!! googling hasn't been too helpful.</p> <p>thanks -</p>
[ { "answer_id": 149490, "author": "rory", "author_id": 8063, "author_profile": "https://Stackoverflow.com/users/8063", "pm_score": 3, "selected": true, "text": "--with-shared" } ]
2008/09/25
[ "https://Stackoverflow.com/questions/131179", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8063/" ]
131,196
<p>I am interested in calling <a href="http://sourceforge.net/projects/sox" rel="nofollow noreferrer">SoX</a>, an open source console application, from another Windows GUI program (written in Delphi naturally). Instead of dealing with scraping and hiding the console window, I would like to just convert the application to a DLL that I can call from my application. </p> <p>Before I start down this path I am curious how much work I should expect to be in for? Are we talking a major undertaking, or is there a straight forward solution? I know some C, but am by no means an expert. </p> <p>I am not expecting SoX specific details, just EXE console application conversion to DLL in general. If someone is familiar with SoX though, even better.</p>
[ { "answer_id": 131396, "author": "computinglife", "author_id": 17224, "author_profile": "https://Stackoverflow.com/users/17224", "pm_score": 2, "selected": false, "text": "LIBRARY \"name.DLL\" \n" } ]
2008/09/25
[ "https://Stackoverflow.com/questions/131196", "https://Stackoverflow.com", "https://Stackoverflow.com/users/255/" ]
131,241
<p>Take the following two lines of code:</p> <pre><code>for (int i = 0; i &lt; some_vector.size(); i++) { //do stuff } </code></pre> <p>And this:</p> <pre><code>for (some_iterator = some_vector.begin(); some_iterator != some_vector.end(); some_iterator++) { //do stuff } </code></pre> <p>I'm told that the second way is preferred. Why exactly is this?</p>
[ { "answer_id": 131254, "author": "Adam Pierce", "author_id": 5324, "author_profile": "https://Stackoverflow.com/users/5324", "pm_score": 3, "selected": false, "text": "for(size_t i = 0; i < myvector.size(); i++)\n{\n MyClass &item = myvector[i];\n\n // Do stuff to \"item\".\n}\n" ...
2008/09/25
[ "https://Stackoverflow.com/questions/131241", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2147/" ]
131,263
<p>As much as I generally don't like the discussion/subjective posts on SO, I have really come to appreciate the "Hidden Secrets" set of posts that people have put together. They provide a great overview of some commonly missed tools that you might now otherwise discover.</p> <p>For this question I would like to explore the Visual Studio .NET debugger. What are some of the "hidden secrets" in the VS.NET debugger that you use often or recently discovered and wish you would have known long ago?</p>
[ { "answer_id": 131265, "author": "Eric Schoonover", "author_id": 3957, "author_profile": "https://Stackoverflow.com/users/3957", "pm_score": 3, "selected": false, "text": "$exception" }, { "answer_id": 131268, "author": "Eric Schoonover", "author_id": 3957, "author_pr...
2008/09/25
[ "https://Stackoverflow.com/questions/131263", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3957/" ]
131,303
<p>How do you measure the memory usage of an application or process in Linux?</p> <p>From the blog article of <em><a href="http://virtualthreads.blogspot.com/2006/02/understanding-memory-usage-on-linux.html" rel="noreferrer">Understanding memory usage on Linux</a></em>, <code>ps</code> is not an accurate tool to use for this intent.</p> <blockquote> <p><strong>Why <code>ps</code> is &quot;wrong&quot;</strong></p> <p>Depending on how you look at it, <code>ps</code> is not reporting the real memory usage of processes. What it is really doing is showing how much real memory each process would take up <strong>if it were the only process running</strong>. Of course, a typical Linux machine has several dozen processes running at any given time, which means that the VSZ and RSS numbers reported by <code>ps</code> are almost definitely <em>wrong</em>.</p> </blockquote> <p><sub>(Note: This question is covered <a href="https://stackoverflow.com/q/63166/15161">here</a> in great detail.)</sub></p>
[ { "answer_id": 131346, "author": "ypnos", "author_id": 21974, "author_profile": "https://Stackoverflow.com/users/21974", "pm_score": 10, "selected": true, "text": "ps" }, { "answer_id": 131399, "author": "DustinB", "author_id": 7888, "author_profile": "https://Stackov...
2008/09/25
[ "https://Stackoverflow.com/questions/131303", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16139/" ]
131,326
<p>I'm looking for resources that can help me determine which approach to use in creating a 2d data structure with C#.</p>
[ { "answer_id": 131339, "author": "aku", "author_id": 1196, "author_profile": "https://Stackoverflow.com/users/1196", "pm_score": 2, "selected": false, "text": "<type>[,] <name> = new <type>[<first dimenison>,<second dimension>];\n" }, { "answer_id": 131347, "author": "CMPalme...
2008/09/25
[ "https://Stackoverflow.com/questions/131326", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
131,335
<p>For some of the customers that we develop software for, we are required to "guarantee" a certain amount of spare resources (memory, disk space, CPU). Memory and disk space are simple, but CPU is a bit more difficult.</p> <p>One technique that we have used is to create a process that consumes a guaranteed amount of CPU time (say 2.5 seconds every 5 seconds). We run this process at highest priority in order to guarantee that it runs and consumes all of its required CPU cycles. </p> <p>If our normal applications are able to run at an acceptable level of performance and can pass all of their functionality tests while the spare time process is running as well, then we "assume" that we have met our commitment for spare CPU time.</p> <p>I'm sure that there are other techniques for doing the same thing, and would like to learn about them.</p>
[ { "answer_id": 131427, "author": "ypnos", "author_id": 21974, "author_profile": "https://Stackoverflow.com/users/21974", "pm_score": 2, "selected": false, "text": "/sys/devices/system/cpu/cpu0/cpufreq/" } ]
2008/09/25
[ "https://Stackoverflow.com/questions/131335", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19853/" ]
131,367
<p>I am going to install SVN for my personal projects. Is it better to install it on a spare machine(Win XP) or will I save myself grief if I install it on the machine I use for development(Vista). </p>
[ { "answer_id": 131397, "author": "Brandon DuRette", "author_id": 17834, "author_profile": "https://Stackoverflow.com/users/17834", "pm_score": 0, "selected": false, "text": "svnadmin create c:\\repo" } ]
2008/09/25
[ "https://Stackoverflow.com/questions/131367", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1628/" ]
131,406
<p>There are several different methods for converting floating point numbers to Integers in JavaScript. My question is what method gives the best performance, is most compatible, or is considered the best practice?</p> <p>Here are a few methods that I know of:</p> <pre><code>var a = 2.5; window.parseInt(a); // 2 Math.floor(a); // 2 a | 0; // 2 </code></pre> <p>I'm sure there are others out there. Suggestions?</p>
[ { "answer_id": 131413, "author": "Jeff Hubbard", "author_id": 8844, "author_profile": "https://Stackoverflow.com/users/8844", "pm_score": -1, "selected": false, "text": "a | 0" }, { "answer_id": 131421, "author": "davenpcj", "author_id": 4777, "author_profile": "https...
2008/09/25
[ "https://Stackoverflow.com/questions/131406", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10942/" ]
131,433
<p>I've read <a href="http://www.xs4all.nl/~hipster/lib/scheme/gauche/define-syntax-primer.txt" rel="noreferrer">JRM's Syntax-rules Primer</a> for the Merely Eccentric and it has helped me understand syntax-rules and how it's different from common-lisp's define-macro. syntax-rules is only one way of implementing a syntax transformer within define-syntax.</p> <p>I'm looking for two things, the first is more examples and explanations of syntax-rules and the second is good sources for learning the other ways of using define-syntax. What resources do you recommend?</p>
[ { "answer_id": 133356, "author": "Nathan Shively-Sanders", "author_id": 7851, "author_profile": "https://Stackoverflow.com/users/7851", "pm_score": 4, "selected": true, "text": "syntax-case" }, { "answer_id": 54969998, "author": "Flux", "author_id": 5916915, "author_p...
2008/09/25
[ "https://Stackoverflow.com/questions/131433", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19784/" ]
131,439
<p>I want a C program to produce a core dump under certain circumstances. This is a program that runs in a production environment and isn't easily stopped and restarted to adjust other kinds of debugging code. Also, since it's in a production environment, I don't want to call abort(). The issues under investigation aren't easily replicated in a non-production environment. What I'd like is for the program, when it detects certain issues, to produce a core dump on its own, preferably with enough information to rename the file, and then continue.</p>
[ { "answer_id": 131492, "author": "njsf", "author_id": 4995, "author_profile": "https://Stackoverflow.com/users/4995", "pm_score": 2, "selected": false, "text": "$ gdb /path/to/exec 1234 # 1234 is the pid of the running process\n" }, { "answer_id": 131539, "author": "Ana Betts...
2008/09/25
[ "https://Stackoverflow.com/questions/131439", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14732/" ]
131,445
<p>What does it take to get C++ <strong>tr1</strong> members (shared_ptr especially, but we'd like function and bind and ALL the others) working with <strong>GCC 3.4.4</strong> (for the Nokia <strong>N810</strong> tablet computer). </p> <p>Has anyone done this? Attempted this? </p> <p>It may <strong>not</strong> be feasible for us to upgrade to GCC 4.x to cross-compile for this device (but if you've done that, we'd love to know). </p> <p>There may be many approaches, and I'd like to avoid dead ends others have hit.</p> <p>We're trying to avoid bringing in boost, since it can be pretty interdependent (you bring in one boost header and you end up with 20 more), and keeping code size down is important to us. </p> <p>Thank you!</p>
[ { "answer_id": 131457, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 2, "selected": false, "text": "std::tr1" }, { "answer_id": 131485, "author": "C. K. Young", "author_id": 13, "author_profile": "https:/...
2008/09/25
[ "https://Stackoverflow.com/questions/131445", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17055/" ]
131,448
<p>I have a ListView which sometimes I need to put around 10000 items in. ListViews don't really handle this well, and they lock up for a couple of seconds while they sort the items and draw them. If you add the items in individually, it's even worse, locking up for nearly a minute.</p> <p>To get around this, I thought I'd try populating the ListView before I need to display it, but unfortunately it has other ideas. It only starts drawing when I turn the panel that contains the ListView visible, making the program hang for a couple of seconds.</p> <p>Any ideas for how I can eliminate this delay? Or is there another component that's relatively easy to use that is better at showing large quantities of data?</p>
[ { "answer_id": 131496, "author": "Jack B Nimble", "author_id": 3800, "author_profile": "https://Stackoverflow.com/users/3800", "pm_score": 0, "selected": false, "text": "for (int ix=0; ix < 10000; ix ++)\n{\n listView1.Items.Add(ix.ToString());\n Application.DoEvents();\n}\n" } ]
2008/09/25
[ "https://Stackoverflow.com/questions/131448", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5133/" ]
131,449
<p>I have this code:</p> <pre><code>chars = #some list try: indx = chars.index(chars) except ValueError: #doSomething else: #doSomethingElse </code></pre> <p>I want to be able to do this because I don't like knowfully causing Exceptions:</p> <pre><code>chars = #some list indx = chars.index(chars) if indx == -1: #doSomething else: #doSomethingElse </code></pre> <p>Is there a way I can do this?</p>
[ { "answer_id": 131452, "author": "Jerub", "author_id": 14648, "author_profile": "https://Stackoverflow.com/users/14648", "pm_score": 3, "selected": false, "text": "if element in mylist:\n index = mylist.index(element)\n # ... do something\nelse:\n # ... do something else\n" },...
2008/09/25
[ "https://Stackoverflow.com/questions/131449", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2598/" ]
131,456
<p>How do I apply the MarshalAsAttribute to the return type of the code below?</p> <pre><code>public ISomething Foo() { return new MyFoo(); } </code></pre>
[ { "answer_id": 131467, "author": "Franci Penov", "author_id": 17028, "author_profile": "https://Stackoverflow.com/users/17028", "pm_score": 6, "selected": true, "text": "[return: MarshalAs(<your marshal type>)]\npublic ISomething Foo()\n{\n return new MyFoo();\n}\n" }, { "answ...
2008/09/25
[ "https://Stackoverflow.com/questions/131456", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21429/" ]
131,473
<p>G'day Stackoverflowers,</p> <p>I'm the author of Perl's <a href="http://search.cpan.org/perldoc?autodie" rel="nofollow noreferrer">autodie</a> pragma, which changes Perl's built-ins to throw exceptions on failure. It's similar to <a href="http://search.cpan.org/perldoc?Fatal" rel="nofollow noreferrer">Fatal</a>, but with lexical scope, an extensible exception model, more intelligent return checking, and much, much nicer error messages. It will be replacing the <code>Fatal</code> module in future releases of Perl (provisionally 5.10.1+), but can currently be downloaded from the CPAN for Perl 5.8.0 and above.</p> <p>The next release of <code>autodie</code> will add special handling for calls to <code>flock</code> with the <code>LOCK_NB</code> (non-blocking) option. While a failed <code>flock</code> call would normally result in an exception under <code>autodie</code>, a failed call to <code>flock</code> using <code>LOCK_NB</code> will merely return false if the returned errno (<code>$!</code>) is <code>EWOULDBLOCK</code>.</p> <p>The reason for this is so people can continue to write code like:</p> <pre><code>use Fcntl qw(:flock); use autodie; # All perl built-ins now succeed or die. open(my $fh, '&lt;', 'some_file.txt'); my $lock = flock($fh, LOCK_EX | LOCK_NB); # Lock the file if we can. if ($lock) { # Opportuntistically do something with the locked file. } </code></pre> <p>In the above code, a lock that fails because someone else has the file locked already (<code>EWOULDBLOCK</code>) is not considered to be a hard error, so autodying <code>flock</code> merely returns a false value. In the situation that we're working with a filesystem that doesn't support file-locks, or a network filesystem and the network just died, then autodying <code>flock</code> generates an appropriate exception when it sees that our errno is not <code>EWOULDBLOCK</code>.</p> <p>This works just fine in my dev version on Unix-flavoured systems, but it fails horribly under Windows. It appears that while Perl under Windows supports the <code>LOCK_NB</code> option, it doesn't define <code>EWOULDBLOCK</code>. Instead, the errno returned is 33 ("Domain error") when blocking would occur.</p> <p>Obviously I can hard-code this as a constant into <code>autodie</code>, but that's not what I want to do here, because it means that I'm screwed if the errno ever changes (or has changed). I would love to compare it to the Windows equivalent of <code>POSIX::EWOULDBLOCK</code>, but I can't for the life of me find where such a thing would be defined. If you can help, let me know.</p> <p>Answers I specifically don't want:</p> <ul> <li>Suggestions to hard-code it as a constant (or worse still, leave a magic number floating about).</li> <li>Not supporting <code>LOCK_NB</code> functionality at all under Windows.</li> <li>Assuming that any failure from a <code>LOCK_NB</code> call to <code>flock</code> should return merely false.</li> <li>Suggestions that I ask on p5p or <a href="http://perlmonks.org/" rel="nofollow noreferrer">perlmonks</a>. I already know about them.</li> <li>An explanation of how <code>flock</code>, or exceptions, or <code>Fatal</code> work. I already know. Intimately.</li> </ul>
[ { "answer_id": 131798, "author": "tye", "author_id": 21496, "author_profile": "https://Stackoverflow.com/users/21496", "pm_score": 5, "selected": true, "text": "ERROR_LOCK_VIOLATION" }, { "answer_id": 131867, "author": "cjm", "author_id": 8355, "author_profile": "http...
2008/09/25
[ "https://Stackoverflow.com/questions/131473", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19422/" ]
131,481
<p>I have a rails app that I have serving up XML on an infrequent basis. This is being run with mongrel and mysql. I've found that if I don't exercise the app for longer than a few hours it goes dead and starts throwing Errno::EPIPE errors. It seems that the mysql connection get timed out for inactivity or something like that.</p> <p>It can be restarted with 'mongrel_rails restart -P /path/to/the/mongrel.pid' ... but that's not really a solution. My collaborator expects the app to be there when he is working on his part (and I am most likely not around).</p> <p>My question is:</p> <ul> <li>What can I do to prevent this problem from occurring in the 1st place? (e.g. don't time me out!!).</li> <li>Failing that, is there some code I can insert somewhere to automatically remake the Db connection?</li> </ul>
[ { "answer_id": 143956, "author": "Mike Berrow", "author_id": 17251, "author_profile": "https://Stackoverflow.com/users/17251", "pm_score": 0, "selected": false, "text": " http://rubyforge.org/projects/zventstools/\n \"Reconnect to the MySQL server when you hit a lost connection error\".\...
2008/09/25
[ "https://Stackoverflow.com/questions/131481", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17251/" ]
131,516
<p>I've got a BPG file that I've modified to use as a make file for our company's automated build server. In order to get it to work I had to change </p> <pre> Uses * Uses unit1 in 'unit1.pas' * unit1 unit2 in 'unit2.pas' * unit2 ... * ... </pre> <p>in the DPR file to get it to work without the compiler giving me some guff about unit1.pas not found. This is annoying because I want to use a BPG file to actually see the stuff in my project and every time I add a new unit, it auto-jacks that in 'unitx.pas' into my DPR file.<p></p> <p>I'm running <code>make -f [then some options]</code>, the DPR's that I'm compiling are not in the same directory as the make file, but I'm not certain that this matters. Everything compiles fine as long as the <code>in 'unit1.pas</code> is removed. <p></p>
[ { "answer_id": 131526, "author": "Peter Turner", "author_id": 1765, "author_profile": "https://Stackoverflow.com/users/1765", "pm_score": 1, "selected": false, "text": "ifdef package" }, { "answer_id": 131927, "author": "gabr", "author_id": 4997, "author_profile": "ht...
2008/09/25
[ "https://Stackoverflow.com/questions/131516", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1765/" ]
131,518
<p>In my ASP.Net 1.1 application, i've added the following to my Web.Config (within the System.Web tag section):</p> <pre><code>&lt;httpHandlers&gt; &lt;add verb="*" path="*.bcn" type="Internet2008.Beacon.BeaconHandler, Internet2008" /&gt; &lt;/httpHandlers&gt; </code></pre> <p>This works fine, and the HTTPHandler kicks in for files of type .bcn, and does its thing.. however for some reason all ASMX files stop working. Any idea why this would be the case?</p> <p>Cheers Greg</p>
[ { "answer_id": 131531, "author": "Quintin Robinson", "author_id": 12707, "author_profile": "https://Stackoverflow.com/users/12707", "pm_score": 2, "selected": false, "text": "<add verb=\"*\" path=\"*.asmx\" type=\"System.Web.Services.Protocols.WebServiceHandlerFactory, System.Web.Service...
2008/09/25
[ "https://Stackoverflow.com/questions/131518", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21969/" ]
131,559
<p>Is there a way to search for multiple strings simultaneously in Vim? I recall reading somewhere that it was possible but somehow forgot the technique.</p> <p>So for example, I have a text file and I want to search for "foo" and "bar" simultaneously (not necessarily as a single string, can be in different lines altogether).</p> <p>How do I achieve that?</p>
[ { "answer_id": 131563, "author": "Ana Betts", "author_id": 5728, "author_profile": "https://Stackoverflow.com/users/5728", "pm_score": -1, "selected": false, "text": "/(foo|bar)\n" }, { "answer_id": 131574, "author": "Codeslayer", "author_id": 4021, "author_profile": ...
2008/09/25
[ "https://Stackoverflow.com/questions/131559", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17716/" ]
131,600
<p>I need to create an installer program that will do install the following:</p> <ol> <li>ASP.Net Website </li> <li>Windows Service</li> <li>SQL Express if it isn't installed and the user doesn't have a SQL Server</li> <li>Dundas Charts</li> <li>ASP.Net AJAX v.1.0</li> <li>ReportViewer control (for 2.0 Framework)</li> <li>Check Framework prerequisites (2.0)</li> <li>Configure IIS and app.config (data connection strings, etc.)</li> </ol> <p>Is it realistic to be able to do this with a VS Setup Project? Or, should I be looking at other install tools? </p>
[ { "answer_id": 931544, "author": "Yordan Georgiev", "author_id": 65706, "author_profile": "https://Stackoverflow.com/users/65706", "pm_score": 2, "selected": false, "text": "CreateDirectory $INSTDIR\nSetOutPath $INSTDIR\n; HERE UNZIP ACTUALLY THE FILES (ADD *.js files if needed ) \n; PAC...
2008/09/25
[ "https://Stackoverflow.com/questions/131600", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1865/" ]
131,605
<p>What version control systems have you used with MS Excel (2003/2007)? What would you recommend and Why? What limitations have you found with your top rated version control system?</p> <p>To put this in perspective, here are a couple of use cases:</p> <ol> <li>version control for VBA modules </li> <li>more than one person is working on a Excel spreadsheet and they may be making changes to the same worksheet, which they want to merge and integrate. This worksheet may have formulae, data, charts etc</li> <li>the users are not too technical and the fewer version control systems used the better</li> <li>Space constraint is a consideration. Ideally only incremental changes are saved rather than the entire Excel spreadsheet. </li> </ol>
[ { "answer_id": 132084, "author": "GUI Junkie", "author_id": 11498, "author_profile": "https://Stackoverflow.com/users/11498", "pm_score": 2, "selected": false, "text": "Sub SaveCodeModules()\n\n'This code Exports all VBA modules\nDim i%, sName$\n\n With ThisWorkbook.VBProject\n ...
2008/09/25
[ "https://Stackoverflow.com/questions/131605", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20879/" ]
131,619
<h2>Question</h2> <p>Using XSLT 1.0, given a string with arbitrary characters how can I get back a string that meets the following rules.</p> <ol> <li>First character must be one of these: a-z, A-Z, colon, or underscore</li> <li>All other characters must be any of those above or 0-9, period, or hyphen</li> <li>If any character does not meet the above rules, replace it with an underscore</li> </ol> <h2>Background</h2> <p>In an XSLT I'm translating some attributes into elements, but I need to be sure the attribute doesn't contain any values that can't be used in an element name. I don't care much about the integrity of the attribute being converted to the name as long as it's being converted predictably. I also don't need to compensate for <em>every</em> valid character in an element name (there's a bunch).</p> <p>The problem I was having was with the attributes having spaces coming in, which the translate function can easily convert to underscores:</p> <pre><code>translate(@name,' ','_') </code></pre> <p>But soon after I found some of the attributes using slashes, so I have to add that now too. This will quickly get out of hand. I want to be able to define a whitelist of allowed characters, and replace any non-allowed characters with an underscore, but translate works as by replacing from a blacklist.</p>
[ { "answer_id": 132240, "author": "JeniT", "author_id": 6739, "author_profile": "https://Stackoverflow.com/users/6739", "pm_score": 4, "selected": true, "text": "<xsl:template name=\"normalizeName\">\n <xsl:param name=\"name\" />\n <xsl:param name=\"isFirst\" select=\"true()\" />\n <xs...
2008/09/25
[ "https://Stackoverflow.com/questions/131619", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8507/" ]
131,628
<p>I wrote some code with a lot of recursion, that takes quite a bit of time to complete. Whenever I "pause" the run to look at what's going on I get: </p> <blockquote> <blockquote> <p>Cannot evaluate expression because the code of the current method is optimized.</p> </blockquote> </blockquote> <p>I think I understand what that means. However, what puzzles me is that after I hit step, the code is not "optimized" anymore, and I can look at my variables. How does this happen? How can the code flip back and forth between optimized and non-optimzed code?</p>
[ { "answer_id": 36870787, "author": "Raghavendra Prasad", "author_id": 6257514, "author_profile": "https://Stackoverflow.com/users/6257514", "pm_score": 3, "selected": false, "text": "Optimize Code" }, { "answer_id": 39897613, "author": "Guish", "author_id": 1456661, "...
2008/09/25
[ "https://Stackoverflow.com/questions/131628", "https://Stackoverflow.com", "https://Stackoverflow.com/users/781/" ]
131,653
<p>I know that embedding CSS styles directly into the HTML tags they affect defeats much of the purpose of CSS, but sometimes it's useful for debugging purposes, as in:</p> <pre><code>&lt;p style="font-size: 24px"&gt;asdf&lt;/p&gt; </code></pre> <p>What's the syntax for embedding a rule like:</p> <pre><code>a:hover {text-decoration: underline;} </code></pre> <p>into the style attribute of an A tag? It's obviously not this...</p> <pre><code>&lt;a href="foo" style="text-decoration: underline"&gt;bar&lt;/a&gt; </code></pre> <p>...since that would apply all the time, as opposed to just during hover.</p>
[ { "answer_id": 131660, "author": "Glenn Slaven", "author_id": 2975, "author_profile": "https://Stackoverflow.com/users/2975", "pm_score": 8, "selected": true, "text": "<a href=\"test.html\" style=\"{color: blue; background: white} \n :visited {color: green}\n :hover...
2008/09/25
[ "https://Stackoverflow.com/questions/131653", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7598/" ]
131,666
<p>What is the right place to store program data files which are the same for every user but have to be writeable for the program? What would be the equivalent location on MS Windows XP? I have read that C:\ProgramData is not writeable after installation by normal users. Is that true? How can I retrieve that directory programmatically using the Platform SDK?</p>
[ { "answer_id": 131684, "author": "Franci Penov", "author_id": 17028, "author_profile": "https://Stackoverflow.com/users/17028", "pm_score": 4, "selected": true, "text": "SHGetFolderPath()" }, { "answer_id": 131688, "author": "dennisV", "author_id": 20208, "author_prof...
2008/09/25
[ "https://Stackoverflow.com/questions/131666", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21683/" ]
131,681
<p>What techniques and/or modules are available to implement robust rate limiting (requests|bytes/ip/unit time) in apache?</p>
[ { "answer_id": 20356408, "author": "Diego Fernández Durán", "author_id": 709588, "author_profile": "https://Stackoverflow.com/users/709588", "pm_score": 5, "selected": false, "text": "SecRuleEngine On\n\n<LocationMatch \"^/somepath\">\n SecAction initcol:ip=%{REMOTE_ADDR},pass,nolog\n ...
2008/09/25
[ "https://Stackoverflow.com/questions/131681", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8171/" ]
131,704
<p>Eclipse 3.4[.x] - also known as <a href="http://www.eclipse.org/downloads/packages/" rel="noreferrer">Ganymede</a> - comes with this new mechanism of provisioning called <strong>p2</strong>.</p> <p>"Provisioning" is the process allowing to discover and update on demand some parts of an application, as explained in general in this article on the <a href="http://developers.sun.com/mobility/midp/articles/ota" rel="noreferrer">Sun Web site</a>.</p> <p>Eclipse has an extended <a href="http://wiki.eclipse.org/Category:Equinox_p2" rel="noreferrer">wiki section</a> in which p2 details are presented. Specifically, it says in this wiki page that p2 will look for new components However after reading it.</p> <p>I suppose (but you may confirm that point by your own experience), that p2 can function file "file://" protocol, which would allow it to provision with <strong>local</strong> file (either on your computer or on an UNC path '\server\path'), as <a href="http://wiki.eclipse.org/Equinox_p2_PDE_Integration" rel="noreferrer">illustrated here</a>, but also by the files:</p> <ul> <li>[eclipse-SDK-3.4-win32]\eclipse\configuration\.settings\org.eclipse.equinox.p2.artifact.repository.prefs</li> <li>[eclipse-SDK-3.4-win32]\eclipse\configuration\.settings\org.eclipse.equinox.p2.metadata.repository.prefs</li> </ul> <p>p2 mechanism is used to update eclipse itself, through an <a href="http://download.eclipse.org/eclipse/updates/3.4" rel="noreferrer">eclipse 3.4 update site</a>, and reference in those '.prefs' files with line like:</p> <blockquote> <p>repositories/file:_C:_jv_eclipse_eclipse-SDK-3.4-win32_eclipse/url=file:/C:/jv/eclipse/eclipse-SDK-3.4-win32/eclipse/</p> </blockquote> <p>Now, how could I replicate the eclipse components present in that update site into a local directory and reference those components through the mentioned '.prefs' files, <strong>in order to have an upgrade process entirely run locally</strong>, without having to access the web?<br> I suppose that some p2 metadata files present in the distant 'update site' need to be replicated and changed as well.</p> <p>Do you have any thoughts/advice/tips on that ? (i.e. on how to discover and retrieve and update the complete structure needed for a full eclipse installation, in order to run that installation locally)</p>
[ { "answer_id": 711754, "author": "lothar", "author_id": 44434, "author_profile": "https://Stackoverflow.com/users/44434", "pm_score": 5, "selected": true, "text": "./eclipse\\\n -nosplash -consolelog -debug\\\n -vm \"${VM}\"\\\n -application org.eclipse.equinox.p2.director...
2008/09/25
[ "https://Stackoverflow.com/questions/131704", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6309/" ]
131,718
<p>Is there a simple way to write a common function for each of the <code>CRUD (create, retreive, update, delete)</code> operations in <code>PHP</code> WITHOUT using any framework. For example I wish to have a single create function that takes the table name and field names as parameters and inserts data into a <code>mySQL database</code>. Another requirement is that the function should be able to support joins I.e. it should be able to insert data into multiple tables if required. </p> <p>I know that these tasks could be done by using a framework but because of various reasons - too lengthy to explain here - I cannot use them.</p>
[ { "answer_id": 131814, "author": "phatduckk", "author_id": 3896, "author_profile": "https://Stackoverflow.com/users/3896", "pm_score": 0, "selected": false, "text": "get_class()" }, { "answer_id": 133479, "author": "lewis", "author_id": 14442, "author_profile": "https...
2008/09/25
[ "https://Stackoverflow.com/questions/131718", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22009/" ]
131,728
<p>I'm using the Telerik RAD Controls RADEditor/WYSIWYG control as part of a Dynamic Data solution.</p> <p>I would like to be able to upload files using the Document Manager of this control.</p> <p>However, these files are larger than whatever the default setting is for maximum upload file size.</p> <p>Can anyone point me in the right direction to fix this?</p> <p><hr> Thanks Yaakov Ellis, see your answer + the answer I linked through a comment for the solution.</p>
[ { "answer_id": 131737, "author": "Yaakov Ellis", "author_id": 51, "author_profile": "https://Stackoverflow.com/users/51", "pm_score": 3, "selected": true, "text": "<system.web>\n <httpRuntime maxRequestLength=\"102400\" executionTimeout= \"3600\" />\n</system.web>\n" }, { "answe...
2008/09/25
[ "https://Stackoverflow.com/questions/131728", "https://Stackoverflow.com", "https://Stackoverflow.com/users/364/" ]
131,788
<p>I'm writing a Perl script and I've come to a point where I need to parse a Java source file line by line checking for references to a fully qualified Java class name. I know the class I'm looking for up front; also the fully qualified name of the source file that is being searched (based on its path). </p> <p>For example find all valid references to foo.bar.Baz inside the com/bob/is/YourUncle.java file.</p> <p>At this moment the cases I can think of that it needs to account for are:</p> <ol> <li><p>The file being parsed is in the same package as the search class. </p> <p>find foo.bar.Baz references in foo/bar/Boing.java</p></li> <li><p>It should ignore comments.</p> <pre><code>// this is a comment saying this method returns a foo.bar.Baz or Baz instance // it shouldn't count /* a multiline comment as well this shouldn't count if I put foo.bar.Baz or Baz in here either */ </code></pre></li> <li><p>In-line fully qualified references.</p> <pre><code>foo.bar.Baz fb = new foo.bar.Baz(); </code></pre></li> <li><p>References based off an import statement.</p> <pre><code>import foo.bar.Baz; ... Baz b = new Baz(); </code></pre></li> </ol> <p>What would be the most efficient way to do this in Perl 5.8? Some fancy regex perhaps?</p> <pre><code>open F, $File::Find::name or die; # these three things are already known # $classToFind looking for references of this class # $pkgToFind the package of the class you're finding references of # $currentPkg package name of the file being parsed while(&lt;F&gt;){ # ... do work here } close F; # the results are availble here in some form </code></pre>
[ { "answer_id": 131959, "author": "tye", "author_id": 21496, "author_profile": "https://Stackoverflow.com/users/21496", "pm_score": 4, "selected": true, "text": "\\bimport\\b" }, { "answer_id": 131970, "author": "Dave Sherohman", "author_id": 18914, "author_profile": "...
2008/09/25
[ "https://Stackoverflow.com/questions/131788", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3636/" ]
131,793
<p>I have an old Delphi codebase I have to maintain, lots of DLLs, some older than others. In some of these DLLs there is no version information in the Project Options dialog. The controls for adding a version are greyed out and I can't even add a version number by manually editing the .DOF file. How can I include a version number in these projects?</p>
[ { "answer_id": 131826, "author": "John Ferguson", "author_id": 8312, "author_profile": "https://Stackoverflow.com/users/8312", "pm_score": 4, "selected": true, "text": "library foolib; \n\nuses\n foo in 'foo.pas',\n baz in 'baz.pas';\n\n{$R *.RES}\n\nexports\n foofunc name 'f...
2008/09/25
[ "https://Stackoverflow.com/questions/131793", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8312/" ]
131,803
<p>I notice that modern C and C++ code seems to use <code>size_t</code> instead of <code>int</code>/<code>unsigned int</code> pretty much everywhere - from parameters for C string functions to the STL. I am curious as to the reason for this and the benefits it brings.</p>
[ { "answer_id": 131833, "author": "Remo.D", "author_id": 16827, "author_profile": "https://Stackoverflow.com/users/16827", "pm_score": 10, "selected": true, "text": "size_t" }, { "answer_id": 131860, "author": "azeemarif", "author_id": 14996, "author_profile": "https:/...
2008/09/25
[ "https://Stackoverflow.com/questions/131803", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9236/" ]
131,805
<p>What is the SQL command to copy a table from one database to another database? I am using MySQL and I have two databases x and y. Suppose I have a table in x called a and I need to copy that table to y database. Sorry if the question is too novice.</p> <p>Thanks.</p>
[ { "answer_id": 131824, "author": "bzlm", "author_id": 7724, "author_profile": "https://Stackoverflow.com/users/7724", "pm_score": 1, "selected": false, "text": "select into" }, { "answer_id": 131825, "author": "cagcowboy", "author_id": 19629, "author_profile": "https:...
2008/09/25
[ "https://Stackoverflow.com/questions/131805", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11193/" ]
131,811
<p>Can someone explain why how the result for the following unpack is computed?</p> <pre><code>"aaa".unpack('h2H2') #=&gt; ["16", "61"] </code></pre> <p>In binary, 'a' = 0110 0001. I'm not sure how the 'h2' can become 16 (0001 0000) or 'H2' can become 61 (0011 1101).</p>
[ { "answer_id": 131858, "author": "Bruno De Fraine", "author_id": 6918, "author_profile": "https://Stackoverflow.com/users/6918", "pm_score": 2, "selected": false, "text": "a" } ]
2008/09/25
[ "https://Stackoverflow.com/questions/131811", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18432/" ]
131,812
<p>I want to calculate the time span between 2 times which I saved in a database. So literally I want to know the length of time between the 2 values.</p> <p>14:10:20 - 10:05:15 = 02:05:05</p> <p>So the result would be 02:05:05.</p> <p>How would I be able to achieve this using C#?</p> <p>14:10:20 is the format I saved it in in my database.</p>
[ { "answer_id": 131820, "author": "cruizer", "author_id": 6441, "author_profile": "https://Stackoverflow.com/users/6441", "pm_score": 4, "selected": true, "text": ".Subtract()" }, { "answer_id": 131851, "author": "Niklas Winde", "author_id": 9077, "author_profile": "ht...
2008/09/25
[ "https://Stackoverflow.com/questions/131812", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
131,847
<p>I have an ellipse centered at (0,0) and the bounding rectangle is x = [-5,5], y = [-6,6]. The ellipse intersects the rectangle at (-5,3),(-2.5,6),(2.5,-6),and (5,-3)</p> <p>I know nothing else about the ellipse, but the only thing I need to know is what angle the major axis is rotated at.</p> <p>seems like the answer must be really simple but I'm just not seeing it... thanks for the help!</p>
[ { "answer_id": 131876, "author": "paxdiablo", "author_id": 14860, "author_profile": "https://Stackoverflow.com/users/14860", "pm_score": 2, "selected": false, "text": "(-2.5,6)\n *-----\n |\\x\n | \\\n | \\\n9 | \\\n | \\\n | x\\\n +------* (5,-3)\n 7.5\n" }, { ...
2008/09/25
[ "https://Stackoverflow.com/questions/131847", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
131,866
<p>I have a serializiable object with listeners registered. Currently the list of listeners is stored in the object as <code>transient</code>. When the object is serialized and then deserialized, obviously the listeners are no longer registered.</p> <p>What would be the safest and best way to go about re-registering the listeners automatically once the object is deserialized? Is there a good design pattern that would help here?</p>
[ { "answer_id": 133734, "author": "Alex Miller", "author_id": 7671, "author_profile": "https://Stackoverflow.com/users/7671", "pm_score": 2, "selected": false, "text": " private void readObject(ObjectInputStream in) \n throws ClassNotFoundException, IOException {\n // do norma...
2008/09/25
[ "https://Stackoverflow.com/questions/131866", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
131,871
<p>I'd love to figure it out myself but I was wondering <strong>roughly what's the algorithm for converting a function with yield statements into a state machine for an enumerator?</strong> For example how does C# turn this:</p> <pre><code>IEnumerator&lt;string&gt; strings(IEnumerable&lt;string&gt; args) { IEnumerator&lt;string&gt; enumerator2 = getAnotherEnumerator(); foreach(var arg in arg) { enumerator2.MoveNext(); yield return arg+enumerator.Current; } } </code></pre> <p>into this:</p> <pre><code>bool MoveNext() { switch (this.state) { case 0: this.state = -1; this.enumerator2 = getAnotherEnumerator(); this.argsEnumerator = this.args.GetEnumerator(); this.state = 1; while (this.argsEnumerator.MoveNext()) { this.arg = this.argsEnumerator.Current; this.enumerator2.MoveNext(); this.current = this.arg + this.enumerator2.Current; this.state = 2; return true; state1: this.state = 1; } this.state = -1; if (this.argsEnumerator != null) this.argsEnumerator.Dispose(); break; case 2: goto state1; } return false; } </code></pre> <p>Of course the result can be completely different depending on the original code.</p>
[ { "answer_id": 132085, "author": "Scott Wisniewski", "author_id": 1737192, "author_profile": "https://Stackoverflow.com/users/1737192", "pm_score": 7, "selected": true, "text": "foreach (var x in y)\n{\n //body\n}\n" } ]
2008/09/25
[ "https://Stackoverflow.com/questions/131871", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1659/" ]
131,901
<p>I am trying to copy a file using the following code:</p> <pre><code>File targetFile = new File(targetPath + File.separator + filename); ... targetFile.createNewFile(); fileInputStream = new FileInputStream(fileToCopy); fileOutputStream = new FileOutputStream(targetFile); byte[] buffer = new byte[64*1024]; int i = 0; while((i = fileInputStream.read(buffer)) != -1) { fileOutputStream.write(buffer, 0, i); } </code></pre> <p>For some users the <code>targetFile.createNewFile</code> results in this exception:</p> <pre><code>java.io.IOException: The filename, directory name, or volume label syntax is incorrect at java.io.WinNTFileSystem.createFileExclusively(Native Method) at java.io.File.createNewFile(File.java:850) </code></pre> <p>Filename and directory name seem to be correct. The directory <code>targetPath</code> is even checked for existence before the copy code is executed and the filename looks like this: <code>AB_timestamp.xml</code></p> <p>The user has write permissions to the <code>targetPath</code> and can copy the file without problems using the OS.</p> <p>As I don't have access to a machine this happens on yet and can't reproduce the problem on my own machine I turn to you for hints on the reason for this exception.</p>
[ { "answer_id": 133845, "author": "Alexander", "author_id": 16724, "author_profile": "https://Stackoverflow.com/users/16724", "pm_score": 4, "selected": true, "text": "File targetFile = new File(targetPath, filename);\n" }, { "answer_id": 204143, "author": "Turismo", "auth...
2008/09/25
[ "https://Stackoverflow.com/questions/131901", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5271/" ]
131,902
<p>I am wondering what security concerns there are to implementing a <code>PHP evaluator</code> like this:</p> <pre><code>&lt;?php eval($_POST['codeInput']); %&gt; </code></pre> <p>This is in the context of making a <code>PHP sandbox</code> so sanitising against <code>DB input</code> etc. isn't a massive issue.</p> <p>Users destroying the server the file is hosted on is.</p> <p>I've seen <code>Ruby simulators</code> so I was curious what's involved security wise (vague details at least).</p> <hr> <p>Thanks all. I'm not even sure on which answer to accept because they are all useful.</p> <p><a href="https://stackoverflow.com/questions/131902/what-are-the-security-concerns-of-evaluating-user-code-in-php#131911">Owen's answer</a> summarises what I suspected (the server itself would be at risk).</p> <p><a href="https://stackoverflow.com/questions/131902/what-are-the-security-concerns-of-evaluating-user-code-in-php#137019">arin's answer</a> gives a great example of the potential problems.</p> <p><a href="https://stackoverflow.com/questions/131902/what-are-the-security-concerns-of-evaluating-user-code-in-php#137167">Geoff's answer</a> and <a href="https://stackoverflow.com/questions/131902/what-are-the-security-concerns-of-evaluating-user-code-in-php#137118">randy's answer</a> echo the general opinion that you would need to write your own evaluator to achieve simulation type capabilities.</p>
[ { "answer_id": 137019, "author": "phatduckk", "author_id": 3896, "author_profile": "https://Stackoverflow.com/users/3896", "pm_score": 4, "selected": true, "text": "eval()" }, { "answer_id": 739930, "author": "Community", "author_id": -1, "author_profile": "https://St...
2008/09/25
[ "https://Stackoverflow.com/questions/131902", "https://Stackoverflow.com", "https://Stackoverflow.com/users/364/" ]
131,944
<p>How do I read a time value and then insert it into a TimeSpan variables?</p>
[ { "answer_id": 131960, "author": "TraumaPony", "author_id": 18658, "author_profile": "https://Stackoverflow.com/users/18658", "pm_score": 1, "selected": false, "text": "TimeSpan span = new TimeSpan(days,hours,minutes,seconds,milliseonds);\n" }, { "answer_id": 131963, "author"...
2008/09/25
[ "https://Stackoverflow.com/questions/131944", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
131,955
<p>Is there a keyboard shortcut for pasting the content of the clipboard into a command prompt window on Windows XP (instead of using the right mouse button)?</p> <p>The typical <kbd>Shift</kbd>+<kbd>Insert</kbd> does not seem to work here.</p>
[ { "answer_id": 133332, "author": "PabloG", "author_id": 394, "author_profile": "https://Stackoverflow.com/users/394", "pm_score": 8, "selected": true, "text": "; Redefine only when the active window is a console window \n#IfWinActive ahk_class ConsoleWindowClass\n\n; Close Command Window...
2008/09/25
[ "https://Stackoverflow.com/questions/131955", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4497/" ]
131,975
<p>I understand benefits of dependency injection itself. Let's take Spring for instance. I also understand benefits of other Spring featureslike AOP, helpers of different kinds, etc. I'm just wondering, what are the benefits of XML configuration such as:</p> <pre><code>&lt;bean id="Mary" class="foo.bar.Female"&gt; &lt;property name="age" value="23"/&gt; &lt;/bean&gt; &lt;bean id="John" class="foo.bar.Male"&gt; &lt;property name="girlfriend" ref="Mary"/&gt; &lt;/bean&gt; </code></pre> <p>compared to plain old java code such as:</p> <pre><code>Female mary = new Female(); mary.setAge(23); Male john = new Male(); john.setGirlfriend(mary); </code></pre> <p>which is easier debugged, compile time checked and can be understood by anyone who knows only java. So what is the main purpose of a dependency injection framework? (or a piece of code that shows its benefits.)</p> <hr> <p><strong>UPDATE:</strong><br/> In case of</p> <pre><code>IService myService;// ... public void doSomething() { myService.fetchData(); } </code></pre> <p>How can IoC framework guess which implementation of myService I want to be injected if there is more than one? If there is only one implementation of given interface, and I let IoC container automatically decide to use it, it will be broken after a second implementation appears. And if there is intentionally only one possible implementation of an interface then you do not need to inject it.</p> <p>It would be really interesting to see small piece of configuration for IoC which shows it's benefits. I've been using Spring for a while and I can not provide such example. And I can show single lines which demonstrate benefits of hibernate, dwr, and other frameworks which I use.</p> <hr> <p><strong>UPDATE 2:</strong><br/> I realize that IoC configuration can be changed without recompiling. Is it really such a good idea? I can understand when someone wants to change DB credentials without recompiling - he may be not developer. In your practice, how often someone else other than developer changes IoC configuration? I think that for developers there is no effort to recompile that particular class instead of changing configuration. And for non-developer you would probably want to make his life easier and provide some simpler configuration file.</p> <hr> <p><strong>UPDATE 3:</strong><br/></p> <blockquote> <p>External configuration of mapping between interfaces and their concrete implementations </p> </blockquote> <p>What is so good in making it extenal? You don't make all your code external, while you definitely can - just place it in ClassName.java.txt file, read and compile manually on the fly - wow, you avoided recompiling. Why should compiling be avoided?!</p> <blockquote> <p>You save coding time because you provide mappings declaratively, not in a procedural code </p> </blockquote> <p>I understand that sometimes declarative approach saves time. For example, I declare only once a mapping between a bean property and a DB column and hibernate uses this mapping while loading, saving, building SQL based on HSQL, etc. This is where the declarative approach works. In case of Spring (in my example), declaration had more lines and had the same expressiveness as corresponding code. If there is an example when such declaration is shorter than code - I would like to see it.</p> <blockquote> <p>Inversion of Control principle allows for easy unit testing because you can replace real implementations with fake ones (like replacing SQL database with an in-memory one)</p> </blockquote> <p>I do understand inversion of control benefits (I prefer to call the design pattern discussed here as Dependency Injection, because IoC is more general - there are many kinds of control, and we are inverting only one of them - control of initialization). I was asking why someone ever needs something other than a programming language for it. I definitely can replace real implementations with fake ones using code. And this code will express same thing as configuration - it will just initialize fields with fake values.</p> <pre><code>mary = new FakeFemale(); </code></pre> <p>I do understand benefits of DI. I do not understand what benefits are added by external XML configuration compared to configuring code that does the same. I do not think that compiling should be avoided - I compile every day and I'm still alive. I think configuration of DI is bad example of declarative approach. Declaration can be useful if is declared once AND is used many times in different ways - like hibernate cfg, where mapping between bean property and DB column is used for saving, loading, building search queries, etc. Spring DI configuration can be easily translated to configuring code, like in the beginning of this question, can it not? And it is used only for bean initialization, isn't it? Which means a declarative approach does not add anything here, does it?</p> <p>When I declare hibernate mapping, I just give hibernate some information, and it works based on it - I do not tell it what to do. In case of spring, my declaration tells spring exactly wht to do - so why declare it, why not just do it?</p> <hr> <p><strong>LAST UPDATE:</strong><br/> Guys, a lot of answers are telling me about dependency injection, which I KNOW IS GOOD. The question is about purpose of DI configuration instead of initializing code - I tend to think that initializing code is shorter and clearer. The only answer I got so far to my question, is that it avoids recompiling, when the configuration changes. I guess I should post another question, because it is a big secret for me, why compiling should be avoided in this case.</p>
[ { "answer_id": 132011, "author": "Borek Bernard", "author_id": 21728, "author_profile": "https://Stackoverflow.com/users/21728", "pm_score": 0, "selected": false, "text": "IService myService;\n// ...\npublic void doSomething() {\n myService.fetchData();\n}\n" }, { "answer_id": 1...
2008/09/25
[ "https://Stackoverflow.com/questions/131975", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5507/" ]
131,985
<p>See the question. I want to see the methods and classes offered by a DLLs library.</p>
[ { "answer_id": 55172723, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "ildasm" } ]
2008/09/25
[ "https://Stackoverflow.com/questions/131985", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6583/" ]
131,989
<p>I want to find out all the subdomains of a given domain. I found a hint which tells me to dig the authoritative Nameserver with the following option:</p> <pre><code>dig @ns1.foo.example example.com axfr </code></pre> <p>But this never works. Has anyone a better idea/approach</p>
[ { "answer_id": 132009, "author": "Midhat", "author_id": 9425, "author_profile": "https://Stackoverflow.com/users/9425", "pm_score": 3, "selected": false, "text": "nslookup" }, { "answer_id": 132014, "author": "TimB", "author_id": 4193, "author_profile": "https://Stack...
2008/09/25
[ "https://Stackoverflow.com/questions/131989", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22029/" ]
131,993
<p>Subversion is a great way to update our web applications on our servers. With a simple <code>svn update</code> all changed files get... well, changed.</p> <p>Except for the omnipresent configuration files such as <code>config.php</code> which hold the database access configuration, server paths etc. And are therefore different on my local development system and the remote server.</p> <p>With the <code>update</code> command, a file modified on the server won't get overwritten, but if I change the file locally and commit it, the server gets the wrong configuration file.</p> <p>But I don't want to set the <code>svn:ignore</code> property either, since the config file belongs to the project.</p> <p>Is there a Subversion-mechanism which will allow me to easily handle these kind of files? Or is the only way to solve this problem to make a system switch within the config file which will determine the executing system and sets the configuration accordingly?</p>
[ { "answer_id": 132036, "author": "Alister Bulman", "author_id": 6216, "author_profile": "https://Stackoverflow.com/users/6216", "pm_score": 2, "selected": true, "text": "[general]\ninfo=misc\ndb.password=secret\ndb.host=localhost\n\n[production : general]\ninfo=only on production system\...
2008/09/25
[ "https://Stackoverflow.com/questions/131993", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6260/" ]
132,030
<p>Right now I have a visual studio project which contains a custom content type that I made. It also contains all the necessary files for making a sharepoint solution (wsp) file and a script to generate this. </p> <p>Now, I would like to do 2 things. </p> <p>First, I'd like to create a custom display form for the content type and include it in my solution so that it is automatically deployed when I deploy my solution. How do I include this in my solution and make my content type use it?</p> <p>Secondly, you can query this type with the CQWP. I've thought about exporting it, adding more common view fields, and then modifying the XSL that is used to render it. How do I include this into my solution so that it is also deployed. I know i can export the CQWP webpart once it's all setup and include it in my project as a feature. But what abuot the XSL?</p> <p>Looking forward to see your suggestions, cheers.</p> <p>Did as described in the first answer. Worked like a charm.</p>
[ { "answer_id": 146879, "author": "Nat", "author_id": 13813, "author_profile": "https://Stackoverflow.com/users/13813", "pm_score": 2, "selected": true, "text": "<ElementManifest Location=\"mywebpartManifest.xml\">" } ]
2008/09/25
[ "https://Stackoverflow.com/questions/132030", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17577/" ]
132,038
<p>I am trying to implement in windows scripting host the same function as windows Send To/Mail Recipient does. Did not find anything usefull on google except steps to instantiate <code>Outlook.Application</code> and directly calling its methods.</p> <p>I need to go the same path as windows do, as there is a mix of Outlook and Lotus Notes installed, I don't see it good to perform some sort of testing and deciding which object to talk to...</p> <p>What I have found is that the actual work is done by <code>sendmail.dll</code>, there is a handler defined in registry under <code>HKEY_CLASSES_ROOT\CLSID\{9E56BE60-C50F-11CF-9A2C-00A0C90A90CE}</code>. I would like either to use this dll somehow or to simulate the same steps it does.</p> <p>Thanks for your input.</p>
[ { "answer_id": 146879, "author": "Nat", "author_id": 13813, "author_profile": "https://Stackoverflow.com/users/13813", "pm_score": 2, "selected": true, "text": "<ElementManifest Location=\"mywebpartManifest.xml\">" } ]
2008/09/25
[ "https://Stackoverflow.com/questions/132038", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10560/" ]
132,052
<p>I deploy a webapp on two different containers (Tomcat and Jetty), but their default servlets for serving the static content have a different way of handling the URL structure I want to use (<a href="http://issues.apache.org/bugzilla/show_bug.cgi?id=42411" rel="noreferrer">details</a>).</p> <p>I am therefore looking to include a small servlet in the webapp to serve its own static content (images, CSS, etc.). The servlet should have the following properties:</p> <ul> <li>No external dependencies</li> <li>Simple and reliable</li> <li>Support for <a href="http://www.freesoft.org/CIE/RFC/1945/58.htm" rel="noreferrer"><code>If-Modified-Since</code></a> header (i.e. custom <a href="http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/http/HttpServlet.html#getLastModified(javax.servlet.http.HttpServletRequest)" rel="noreferrer"><code>getLastModified</code></a> method)</li> <li>(Optional) support for gzip encoding, etags,...</li> </ul> <p>Is such a servlet available somewhere? The closest I can find is <a href="http://www.unix.org.ua/orelly/java-ent/servlet/ch04_04.htm#ch04-35758" rel="noreferrer">example 4-10</a> from the servlet book.</p> <p><strong>Update:</strong> The URL structure I want to use - in case you are wondering - is simply:</p> <pre class="lang-xml prettyprint-override"><code> &lt;servlet-mapping&gt; &lt;servlet-name&gt;main&lt;/servlet-name&gt; &lt;url-pattern&gt;/*&lt;/url-pattern&gt; &lt;/servlet-mapping&gt; &lt;servlet-mapping&gt; &lt;servlet-name&gt;default&lt;/servlet-name&gt; &lt;url-pattern&gt;/static/*&lt;/url-pattern&gt; &lt;/servlet-mapping&gt; </code></pre> <p>So all requests should be passed to the main servlet, unless they are for the <code>static</code> path. The problem is that Tomcat's default servlet does not take the ServletPath into account (so it looks for the static files in the main folder), while Jetty does (so it looks in the <code>static</code> folder).</p>
[ { "answer_id": 132932, "author": "Bruno De Fraine", "author_id": 6918, "author_profile": "https://Stackoverflow.com/users/6918", "pm_score": 5, "selected": true, "text": "StaticServlet" }, { "answer_id": 558771, "author": "yogman", "author_id": 24349, "author_profile"...
2008/09/25
[ "https://Stackoverflow.com/questions/132052", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6918/" ]
132,058
<p>I have this Python application that gets stuck from time to time and I can't find out where.</p> <p>Is there any way to signal Python interpreter to show you the exact code that's running? </p> <p>Some kind of on-the-fly stacktrace?</p> <p><strong><em>Related questions:</em></strong></p> <ul> <li><a href="https://stackoverflow.com/questions/1156023/print-current-call-stack-from-a-method-in-python-code">Print current call stack from a method in Python code</a></li> <li><a href="https://stackoverflow.com/questions/6849138/check-what-a-running-process-is-doing-print-stack-trace-of-an-uninstrumented-py">Check what a running process is doing: print stack trace of an uninstrumented Python program</a></li> </ul>
[ { "answer_id": 132114, "author": "gulgi", "author_id": 1109480, "author_profile": "https://Stackoverflow.com/users/1109480", "pm_score": 5, "selected": false, "text": "import traceback\n\ntraceback.print_stack()\n" }, { "answer_id": 132123, "author": "Torsten Marek", "aut...
2008/09/25
[ "https://Stackoverflow.com/questions/132058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/189/" ]
132,070
<p>I have a really big database (running on PostgreSQL) containing a lot of tables with sophisticated relations between them (foreign keys, on delete cascade and so on). I need remove some data from a number of tables, but I'm not sure what amount of data will be really deleted from database due to cascade removals.</p> <p>How can I check that I'll not delete data that should not be deleted?</p> <p>I have a test database - just a copy of real one where I can do what I want :)</p> <p>The only idea I have is dump database before and after and check it. But it not looks comfortable. Another idea - dump part of database, that, as I think, should not be affected by my DELETE statements and check this part before and after data removal. But I see no simple ways to do it (there are hundreds of tables and removal should work with ~10 of them). Is there some way to do it?</p> <p>Any other ideas how to solve the problem?</p>
[ { "answer_id": 132106, "author": "Vinko Vrsalovic", "author_id": 5190, "author_profile": "https://Stackoverflow.com/users/5190", "pm_score": 2, "selected": true, "text": "select table_catalog,table_schema,table_name,column_name,rc.* from\ninformation_schema.constraint_column_usage ccu, \...
2008/09/25
[ "https://Stackoverflow.com/questions/132070", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19101/" ]
132,092
<p>I think everyone would agree that the MATLAB language is not pretty, or particularly consistent. But nevermind! We still have to use it to get things done.</p> <p>What are your favourite tricks for making things easier? Let's have one per answer so people can vote them up if they agree. Also, try to illustrate your answer with an example.</p>
[ { "answer_id": 132096, "author": "Matt", "author_id": 15368, "author_profile": "https://Stackoverflow.com/users/15368", "pm_score": 4, "selected": false, "text": "% Build a list of args, like so:\nargs = {'a', 1, 'b', 2};\n% Then expand this into arguments:\noutput = func(args{:})\n" }...
2008/09/25
[ "https://Stackoverflow.com/questions/132092", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15368/" ]
132,116
<p>Please help! I'm really at my wits' end. My program is a little personal notes manager (google for "cintanotes"). On some computers (and of course I own none of them) it crashes with an unhandled exception just after start. Nothing special about these computers could be said, except that they tend to have AMD CPUs.</p> <p>Environment: Windows XP, Visual C++ 2005/2008, raw WinApi.</p> <p>Here is what is certain about this "Heisenbug":</p> <p>1) The crash happens only in the Release version.</p> <p>2) The crash goes away as soon as I remove all GDI-related stuff.</p> <p>3) BoundChecker has no complains.</p> <p>4) Writing a log shows that the crash happens on a declaration of a local int variable! How could that be? Memory corruption?</p> <p>Any ideas would be greatly appreciated!</p> <p><strong>UPDATE: I've managed to get the app debugged on a "faulty" PC. The results:</strong></p> <p>"Unhandled exception at 0x0044a26a in CintaNotes.exe: 0xC000001D: Illegal Instruction."</p> <p>and code breaks on</p> <p>0044A26A cvtsi2sd xmm1,dword ptr [esp+14h] </p> <p><strong>So it seems that the problem was in the "Code Generation/Enable Enhanced Instruction Set" compiler option. It was set to "/arch:SSE2" and was crashing on the machines that didn't support SSE2. I've set this option to "Not Set" and the bug is gone. Phew!</strong></p> <p>Thank you all very much for help!!</p>
[ { "answer_id": 132254, "author": "Johann Gerell", "author_id": 6345, "author_profile": "https://Stackoverflow.com/users/6345", "pm_score": 1, "selected": false, "text": "this" } ]
2008/09/25
[ "https://Stackoverflow.com/questions/132116", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22046/" ]
132,118
<p>When you're using Tiles with Struts and do...</p> <pre><code>request.getRequestURL() </code></pre> <p>...you get the URL to e.g. <code>/WEB-INF/jsp/layout/newLayout.jsp</code> instead of the real URL that was entered/clicked by the user, something like <code>/context/action.do</code>.</p> <p>In newer Struts versions, 1.3.x and after, you can use the <a href="http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&amp;f=58&amp;t=012300" rel="nofollow noreferrer">solution mentioned on javaranch</a> and get the real URL using the request attribute <a href="http://struts.apache.org/1.x/apidocs/org/apache/struts/Globals.html#ORIGINAL_URI_KEY" rel="nofollow noreferrer"><code>ORIGINAL_URI_KEY</code></a>.</p> <p>But how to do this in Struts 1.2.x?</p>
[ { "answer_id": 157120, "author": "Steve McLeod", "author_id": 2959, "author_profile": "https://Stackoverflow.com/users/2959", "pm_score": 1, "selected": false, "text": "private String getOriginalUri(HttpServletRequest request) {\n String targetUrl = request.getServletPath();\n if (...
2008/09/25
[ "https://Stackoverflow.com/questions/132118", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
132,121
<p>i'm working with a multi-threaded program (using pthreads) that currently create a background thread (PTHREAD_DETACHED) and then invokes pthread_exit(0). My problem is that the process is then listed as "defunct" and curiously do not seems to "really exists" in /proc (which defeats my debugging strategies)</p> <p>I would like the following requirements to be met:</p> <ul> <li>the program should run function A in a loop and function B once</li> <li>given the PID of the program /proc/$pid/exe, /proc/$pid/maps and /proc/$pid/fd must be accessible (when the process is defunct, they are all empty or invalid links)</li> <li>it must be possible to suspend/interrupt the program with CTRL+C and CTRL+Z as usual</li> </ul> <p><em>edit:</em> I hesitate changing the program's interface for having A in the "main" thread and B in a spawned thread (they are currently in the other way). Would it solve the problem ?</p>
[ { "answer_id": 133550, "author": "tsg", "author_id": 15685, "author_profile": "https://Stackoverflow.com/users/15685", "pm_score": 0, "selected": false, "text": " while(1) {\n pause();\n }\n" }, { "answer_id": 274657, "author": "Nicola Bonelli", "author_id": 19630, ...
2008/09/25
[ "https://Stackoverflow.com/questions/132121", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15304/" ]
132,136
<p>Does anyone know if IE6 ever misrenders pages with hidden <code>divs</code>? We currently have several <code>divs</code> which we display in the same space on the page, only showing one at a time and hiding all others.</p> <p>The problem is that the hidden <code>divs</code> components (specifically option menus) sometimes show through. If the page is scrolled, removing the components from view, and then scrolled back down, the should-be-hidden components then disappear.</p> <p>How do we fix this?</p>
[ { "answer_id": 132162, "author": "Santiago Cepas", "author_id": 6547, "author_profile": "https://Stackoverflow.com/users/6547", "pm_score": 2, "selected": false, "text": "MyDiv.style.left = \"-1000px\";\n" }, { "answer_id": 132193, "author": "Eran Galperin", "author_id": ...
2008/09/25
[ "https://Stackoverflow.com/questions/132136", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
132,164
<p>These <code>for</code>-loops are among the first basic examples of formal correctness proofs of algorithms. They have different but equivalent termination conditions:</p> <pre><code>1 for ( int i = 0; i != N; ++i ) 2 for ( int i = 0; i &lt; N; ++i ) </code></pre> <p>The difference becomes clear in the postconditions:</p> <ul> <li><p>The first one gives the strong guarantee that <code>i == N</code> after the loop terminates.</p></li> <li><p>The second one only gives the weak guarantee that <code>i &gt;= N</code> after the loop terminates, but you will be tempted to assume that <code>i == N</code>.</p></li> </ul> <p>If for any reason the increment <code>++i</code> is ever changed to something like <code>i += 2</code>, or if <code>i</code> gets modified inside the loop, or if <code>N</code> is negative, the program can fail:</p> <ul> <li><p>The first one may get stuck in an infinite loop. It fails early, in the loop that has the error. Debugging is easy.</p></li> <li><p>The second loop will terminate, and at some later time the program may fail because of your incorrect assumption of <code>i == N</code>. It can fail far away from the loop that caused the bug, making it hard to trace back. Or it can silently continue doing something unexpected, which is even worse.</p></li> </ul> <p>Which termination condition do you prefer, and why? Are there other considerations? Why do many programmers who know this, refuse to apply it?</p>
[ { "answer_id": 132175, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 1, "selected": false, "text": "!=" }, { "answer_id": 132180, "author": "Unsliced", "author_id": 2902, "author_profile": "https://Stacko...
2008/09/25
[ "https://Stackoverflow.com/questions/132164", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2686/" ]
132,186
<p>I wish to test a function that will generate <code>lorem ipsum</code> text, but it does so within html tags. So I cant know in advance the textual content, but i know the html structure. That is what I want to test. And maybe that the length of the texts are within certain limits. So what I am wondering is if the assertTags can do this in a way paraphrased bellow:</p> <pre><code>Result = "&lt;p&gt;Some text&lt;/p&gt;"; Expected = array( '&lt;p' , 'regex', '/p' ); assertTags(resutl, expected) </code></pre> <p>I am using SimpleTest with CakePHP, but I think it should be a general question.</p>
[ { "answer_id": 132420, "author": "Ken", "author_id": 20074, "author_profile": "https://Stackoverflow.com/users/20074", "pm_score": 0, "selected": false, "text": "class ValidIp extends SimpleExpectation {\n\n function test($ip) {\n return (ip2long($ip) != -1);\n }\n\n function testM...
2008/09/25
[ "https://Stackoverflow.com/questions/132186", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4013/" ]
132,231
<p>When I'm writing a Spring command line application which parses command line arguments, how do I pass them to Spring? Would I want to have my main() structured so that it first parses the command line args and then inits Spring? Even so, how would it pass the object holding the parsed args to Spring?</p>
[ { "answer_id": 132546, "author": "Bradley Beddoes", "author_id": 22087, "author_profile": "https://Stackoverflow.com/users/22087", "pm_score": 1, "selected": false, "text": "public static void main(String[] args) throws IOException, ConfigurationException {\n Deployer deployer = boots...
2008/09/25
[ "https://Stackoverflow.com/questions/132231", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22063/" ]
132,233
<p>Unfortunatly I have to work in a older web application on a <code>PHP4</code> server; It now needs to parse a lot of <code>XM</code>L for calling <code>webservices (custom protocol, no SOAP/REST)</code>;</p> <p>Under <code>PHP5</code> I would use <code>SimpleXML</code> but that isn't available; There is <code>Dom XML</code> in <code>PHP4</code>, but it isn't default any more in <code>PHP5</code>.</p> <p>What are the other options? I'm looking for a solution that still works on <code>PHP5</code> once they migrate.</p> <p>A nice extra would be if the <code>XML</code> can be validated with a schema.</p>
[ { "answer_id": 132291, "author": "ConroyP", "author_id": 2287, "author_profile": "https://Stackoverflow.com/users/2287", "pm_score": 2, "selected": false, "text": "$xml = ...; // Get your XML data\n$xml_parser = xml_parser_create();\n\n// _start_element and _end_element are two functions...
2008/09/25
[ "https://Stackoverflow.com/questions/132233", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3215/" ]
132,241
<p>I know there is a standard behind all C compiler implementations, so there should be no hidden features. Despite that, I am sure all C developers have hidden/secret tricks they use all the time.</p>
[ { "answer_id": 132274, "author": "ComSubVie", "author_id": 15709, "author_profile": "https://Stackoverflow.com/users/15709", "pm_score": 5, "selected": false, "text": "strncpy(to, from, count)\nchar *to, *from;\nint count;\n{\n int n = (count + 7) / 8;\n switch (count % 8) {\n c...
2008/09/25
[ "https://Stackoverflow.com/questions/132241", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21548/" ]
132,242
<p>Consider this case:</p> <pre><code>dll = LoadDLL() dll-&gt;do() ... void do() { char *a = malloc(1024); } ... UnloadDLL(dll); </code></pre> <p>At this point, will the 1k allocated in the call to malloc() be available to the host process again? The DLL is statically linking to the CRT.</p>
[ { "answer_id": 132309, "author": "INS", "author_id": 13136, "author_profile": "https://Stackoverflow.com/users/13136", "pm_score": 2, "selected": false, "text": "dll = DllLoad();\n\nptr = dll->alloc();\n\ndll->free(ptr);\n\nDllUnload(dll);\n" } ]
2008/09/25
[ "https://Stackoverflow.com/questions/132242", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17424/" ]
132,245
<p>The simple demo below captures what I am trying to do. In the real program, I have to use the object initialiser block since it is reading a list in a LINQ to SQL select expression, and there is a value that that I want to read off the database and store on the object, but the object doesn't have a simple property that I can set for that value. Instead it has an XML data store.</p> <p>It looks like I can't call an extension method in the object initialiser block, and that I can't attach a property using extension methods.</p> <p>So am I out of luck with this approach? The only alternative seems to be to persuade the owner of the base class to modify it for this scenario.</p> <p>I have an existing solution where I subclass BaseDataObject, but this has problems too that don't show up in this simple example. The objects are persisted and restored as BaseDataObject - the casts and tests would get complex.</p> <pre><code>public class BaseDataObject { // internal data store private Dictionary&lt;string, object&gt; attachedData = new Dictionary&lt;string, object&gt;(); public void SetData(string key, object value) { attachedData[key] = value; } public object GetData(string key) { return attachedData[key]; } public int SomeValue { get; set; } public int SomeOtherValue { get; set; } } public static class Extensions { public static void SetBarValue(this BaseDataObject dataObject, int barValue) { /// Cannot attach a property to BaseDataObject? dataObject.SetData("bar", barValue); } } public class TestDemo { public void CreateTest() { // this works BaseDataObject test1 = new BaseDataObject { SomeValue = 3, SomeOtherValue = 4 }; // this does not work - it does not compile // cannot use extension method in the initialiser block // cannot make an exension property BaseDataObject test2 = new BaseDataObject { SomeValue = 3, SomeOtherValue = 4, SetBarValue(5) }; } } </code></pre> <p>One of the answers (from mattlant) suggests using a fluent interface style extension method. e.g.:</p> <pre><code>// fluent interface style public static BaseDataObject SetBarValueWithReturn(this BaseDataObject dataObject, int barValue) { dataObject.SetData("bar", barValue); return dataObject; } // this works BaseDataObject test3 = (new BaseDataObject { SomeValue = 3, SomeOtherValue = 4 }).SetBarValueWithReturn(5); </code></pre> <p>But will this work in a LINQ query?</p>
[ { "answer_id": 132275, "author": "Tigraine", "author_id": 21699, "author_profile": "https://Stackoverflow.com/users/21699", "pm_score": 3, "selected": false, "text": "var x = new BaseDataObject { SomeValue = 3, SomeOtherValue = 4 };\n" }, { "answer_id": 132279, "author": "mat...
2008/09/25
[ "https://Stackoverflow.com/questions/132245", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5599/" ]
132,277
<p>I've got a web application that is running against Windows Authentication using our Active Directory. I've got a new requirement to pull some personal information through from the Active Directory entry. What would be the easiest way to get access to this information?</p>
[ { "answer_id": 132339, "author": "paul", "author_id": 11249, "author_profile": "https://Stackoverflow.com/users/11249", "pm_score": 3, "selected": false, "text": "public static bool IsUserInGroup(string lanid, string group)\n{\n DirectoryEntry entry = new DirectoryEntry(\"LDAP://\" + ...
2008/09/25
[ "https://Stackoverflow.com/questions/132277", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5802/" ]
132,305
<p>At work we have two servers, one is running an application a lot of people use which has an SQL Server 2000 back end. I have been free to query this for a long time but can't add anything to it such as stored procedures or extra tables. </p> <p>This has lead to us having a second SQL Server linked to the first one and me building up a library of stored procedures that query data from both sides using linked server. Some of these queries are taking longer than what I would like. </p> <p>Can someone point me to some good articles about using linked servers? I am particularly interested in finding out what data is being transferred between the two as usually the majority of the sql statement could be performed remotely but I have the feeling it may be transferring the full tables, it is usually just a join to a small final table locally.</p> <p>Also what do the linked server options do I currently have:</p> <ul> <li>Collation Compatible True</li> <li>Data Access True</li> <li>Rpc True</li> <li>Rpc Out True</li> <li>Use Remote Collation False</li> <li>Collation Name (Blank)</li> <li>Connection Timeout 0</li> <li>Query Timeout 0</li> </ul> <p><strong>EDIT:</strong></p> <p>Just thought I would update this post I used openqueries with dynamic parameters for a while to boost performance, thanks for the tip. However doing this can make queries more messy as you end up dealing with strings. finally this summer we upgraded SQL Server to 2008 and implemented live data mirroring. To be honest the open queries were approaching the speed of local queries for my tasks but the mirroring has certainly made the sql easier to deal with.</p>
[ { "answer_id": 143081, "author": "Ricardo C", "author_id": 232589, "author_profile": "https://Stackoverflow.com/users/232589", "pm_score": 3, "selected": false, "text": "SELECT loc.field1, lnk.field1\nFROM MyTable loc\nINNER JOIN RemoteServer.Database.Schema.SomeTable lnk\n ON loc.id = ...
2008/09/25
[ "https://Stackoverflow.com/questions/132305", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16989/" ]
132,318
<p>I have an ANSI encoded text file that should not have been encoded as ANSI as there were accented characters that ANSI does not support. I would rather work with UTF-8.</p> <p>Can the data be decoded correctly or is it lost in transcoding?</p> <p>What tools could I use?</p> <p>Here is a sample of what I have:</p> <pre><code>ç é </code></pre> <p>I can tell from context (café should be café) that these should be these two characters:</p> <pre><code>ç é </code></pre>
[ { "answer_id": 132327, "author": "Zsolt Botykai", "author_id": 11621, "author_profile": "https://Stackoverflow.com/users/11621", "pm_score": 3, "selected": false, "text": "vim -c \"set encoding=utf8\" -c \"set fileencoding=utf8\" -c \"wq\" filename\n" } ]
2008/09/25
[ "https://Stackoverflow.com/questions/132318", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18333/" ]
132,319
<p>I'm trying to determine a fast way of storing a set of objects, each of which have an x and y coordinate value, such that I can quickly retrieve all objects within a certain rectangle or circle. For small sets of objects (~100) the naive approach of simply storing them in a list, and iterating through it, is relatively quick. However, for much larger groups, that is expectedly slow. I've tried storing them in a pair of TreeMaps as well, one sorted on the x coordinate, and one sorted on the y coordinate, using this code:</p> <pre><code>xSubset = objectsByX.subSet( minX, maxX ); ySubset = objectsByY.subSet( minY, maxY ); result.addAll( xSubset ); result.retainAll( ySubset ); </code></pre> <p>This also works, and is faster for larger sets of objects, but is still slower than I would like. Part of the problem is also that these objects move around, and need to be inserted back into this storage, which means removing them from and re-adding them to the trees/lists. I can't help but think there must be better solutions out there. I'm implementing this in Java, if it makes any difference, though I expect any solution will be more in the form of a useful pattern/algorithm.</p>
[ { "answer_id": 133817, "author": "Milhous", "author_id": 17712, "author_profile": "https://Stackoverflow.com/users/17712", "pm_score": 0, "selected": false, "text": " TreeMap<Integer, TreeMap<Integer, Point>> xMap = new TreeMap<Integer, TreeMap<Integer, Point>>();\n for (in...
2008/09/25
[ "https://Stackoverflow.com/questions/132319", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22070/" ]
132,323
<p>When iterating over elements of a vector it is preferred to use iterators instead of an index (see <a href="https://stackoverflow.com/questions/131241/why-use-iterators-instead-of-array-indices">Why use iterators instead of array indices?</a>). </p> <pre><code>std::vector&lt;T&gt; vec; std::vector&lt;T&gt;::iterator it; for ( it = vec.begin(); it != vec.end(); ++it ) { // do work } </code></pre> <p>However, it can be necessary to use the index in the body of the loop. Which of the following would be preferable in that case, considering performance and flexibility/extensibility?</p> <ol> <li>Revert to the indexed loop<pre> std::vector vec; size_t i; for ( i = 0; i &lt; vec.size(); ++i ) { // use i } </pre></li> <li>Calculate offset<pre> std::vector vec; std::vector::iterator it; for ( it = vec.begin(); it != vec.end(); ++it ) { size_t i = it - vec.begin(); // use i } </pre></li> <li>Use std::distance <pre> std::vector vec; std::vector::iterator it; for ( it = vec.begin(); it != vec.end(); ++it ) { size_t i = std::distance( vec.begin(), it ); // use i } </pre></li> </ol>
[ { "answer_id": 133545, "author": "Carl Seleborg", "author_id": 2095, "author_profile": "https://Stackoverflow.com/users/2095", "pm_score": 3, "selected": false, "text": "std::distance(vec.begin(), it)" } ]
2008/09/25
[ "https://Stackoverflow.com/questions/132323", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19863/" ]
132,326
<p>My implementation of httpclient occasionally throws an exception when calling doGetConnection(). However, I have the following timeout set</p> <pre><code>_moHttpClient.setHttpConnectionFactoryTimeout(30000); </code></pre> <p>it looks almost like my timeout is not being picked up. Is there anywhere else I need to set a timeout to ensure this behaviour does not re-occur</p>
[ { "answer_id": 132335, "author": "JeeBee", "author_id": 17832, "author_profile": "https://Stackoverflow.com/users/17832", "pm_score": 3, "selected": false, "text": " HttpConnectionManagerParams cmparams = new HttpConnectionManagerParams();\n cmparams.setSoTimeout(10000);\n cmpar...
2008/09/25
[ "https://Stackoverflow.com/questions/132326", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
132,329
<p>Are there any good examples (websites or books) around of how to build a full text search engine in F#? </p>
[ { "answer_id": 132335, "author": "JeeBee", "author_id": 17832, "author_profile": "https://Stackoverflow.com/users/17832", "pm_score": 3, "selected": false, "text": " HttpConnectionManagerParams cmparams = new HttpConnectionManagerParams();\n cmparams.setSoTimeout(10000);\n cmpar...
2008/09/25
[ "https://Stackoverflow.com/questions/132329", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6264/" ]