qid
int64
4
19.1M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
416,752
<p>I'm using Zend_Form to output a set group of checkboxes:</p> <pre><code>&lt;label style="white-space: nowrap;"&gt;&lt;input type="checkbox" name="user_group[]" id="user_group-20" value="20"&gt;This Group&lt;/label&gt; </code></pre> <p>With a normal HTTP Post these values are passed as an array, but when I'm somewhat stumped on how to grab all the values using jQuery. I figured I can select the group using:</p> <pre><code>$("input[@name='user_group[]']").val() </code></pre> <p>but that just grabs the value of the first checkbox in the list regardless of if it is checked of not. Any ideas?</p>
[ { "answer_id": 416770, "author": "Ali", "author_id": 49153, "author_profile": "https://Stackoverflow.com/users/49153", "pm_score": 0, "selected": false, "text": "<head> <script type=\"text/javascript\">\nvar num_cboxes=<?php echo $number_of_checkboxes;?>;\n</script>\n user_group-1 user_g...
2009/01/06
[ "https://Stackoverflow.com/questions/416752", "https://Stackoverflow.com", "https://Stackoverflow.com/users/204/" ]
416,760
<p>I'm currently working on a hobby project, written in Java, containing about two different JFrames with about 3-4 JPanels each. The problem I'm facing is that I'm not so sure how to handle the interaction with my controller and different view classes.</p> <p>For instance, I've an article by Sun on <a href="http://java.sun.com/developer/technicalArticles/javase/mvc/" rel="nofollow noreferrer">Java App. design with MVC</a>, where they list the option to let all the communications between model and view go through the controller as the most modern one, a tactic I've been taught as well and should do just fine. However, it doesn't quite go as deep as to explain how to handle all the ActionListeners involved for all the elements and different panels. </p> <p>The 'way to go' I've been taught so far is to either use one controller and set the ActionListener to the various objects through getters and keep track of the active panel. The alternative my awesome Java book gives is to just stick to inner classes for each view class. Either method seems to result in pretty nasty code, while I'd prefer one or several controllers with as little bloat as possible.</p> <p>My question of course is; how would you assign the ActionListeners as neatly and efficiently as possible while keeping the controller(s) usable?</p>
[ { "answer_id": 416789, "author": "Markus Lausberg", "author_id": 39062, "author_profile": "https://Stackoverflow.com/users/39062", "pm_score": 1, "selected": true, "text": "public void addListener(ActionListener listener)\n{\n mActionListeners.add(listener);\n}\n\npublic void removeLis...
2009/01/06
[ "https://Stackoverflow.com/questions/416760", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52057/" ]
416,771
<p>I need to create a script that automatically setup a ssh tunnel. I think that a dedicated ssh key without password is a good start but I couldn't find if this is possible and how to do it. This key should have limited privileges (only set the tunnel up) but I need another private key (with a password) for myself.</p> <p>Thanks !</p>
[ { "answer_id": 416792, "author": "Mihai Limbășan", "author_id": 14444, "author_profile": "https://Stackoverflow.com/users/14444", "pm_score": 1, "selected": false, "text": "ssh-keygen" }, { "answer_id": 416896, "author": "ascobol", "author_id": 49886, "author_profile"...
2009/01/06
[ "https://Stackoverflow.com/questions/416771", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49886/" ]
416,773
<p>I am wondering where and when <a href="http://www.martinfowler.com/bliki/FluentInterface.html" rel="nofollow noreferrer">fluent interfaces</a> are a good idea, so I am looking for examples. So far I have found only 3 useful cases, e.g. Ruby's collections, like</p> <pre><code>unique_words = File.read("words.txt").downcase.split.sort.uniq.length </code></pre> <p>and <a href="http://code.google.com/p/fest/" rel="nofollow noreferrer">Fest</a> (Java) for unit testing:</p> <pre><code>assertThat(yoda).isInstanceOf(Jedi.class) .isEqualTo(foundJedi) .isNotEqualTo(foundSith); </code></pre> <p>and <a href="http://www.jmock.org/" rel="nofollow noreferrer">JMock</a>. Do you know of any other good examples that use a fluent interface?</p>
[ { "answer_id": 417702, "author": "AShelly", "author_id": 10396, "author_profile": "https://Stackoverflow.com/users/10396", "pm_score": 0, "selected": false, "text": "# bowling_spec.rb\nrequire 'bowling'\n\ndescribe Bowling do\n before(:each) do\n @bowling = Bowling.new\n end\n\n it...
2009/01/06
[ "https://Stackoverflow.com/questions/416773", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48181/" ]
416,805
<p>On an HTML page, a link like this:</p> <pre><code>&lt;a href=&quot;#pagelocation&quot;&gt;Location on Page&lt;/a&gt; </code></pre> <p>...should navigate to this spot on the page:</p> <pre><code>&lt;a name=&quot;pagelocation&quot;&gt; </code></pre> <p>But in my experience, it sometimes misses - especially when linking from another page (like <code>&lt;a href=&quot;somepage.html#pagelocation&quot;&gt;</code>). By &quot;misses,&quot; I mean it scrolls to the wrong spot on the page - maybe close, maybe not.</p> <p>Normally, the target location ends up at the top of the screen. I know this can fail if there's not enough room below the anchor to scroll it to the top of the screen.</p> <p>Why else would it fail? Does it depend on layout at all? <strong>How can I fix it?</strong></p> <p>(I'm keeping this general because I'd like a catch-all reference answer.)</p> <h2>Update 1</h2> <p>Thanks for the pointers so far about non-explicit image sizes. But what about on a page where all the elements have explicit size? (I'm dealing with one now.)</p>
[ { "answer_id": 416837, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 4, "selected": false, "text": "<head>" }, { "answer_id": 416913, "author": "Peter Hilton", "author_id": 2670, "author_profile": "https:/...
2009/01/06
[ "https://Stackoverflow.com/questions/416805", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4376/" ]
416,851
<p>Is there any Perl script to get the pages from a PDF file and convert the same to another PDF file?</p>
[ { "answer_id": 416864, "author": "gnud", "author_id": 27204, "author_profile": "https://Stackoverflow.com/users/27204", "pm_score": 3, "selected": false, "text": "~$ pdftk multi-page.pdf burst\n" }, { "answer_id": 417270, "author": "Andreas Thomas", "author_id": 1531, ...
2009/01/06
[ "https://Stackoverflow.com/questions/416851", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45284/" ]
416,854
<p>I have a minimal toy language similar to javascript. I generate an AST to try out some optimization techniques like escape analysis, type inference. I tried a few approaches like generalizing operator tokens instead of a class/function for each one, keeping type information on every node... But I still don't feel like I am going anywhere. It quickly becomes unwieldy to work on...</p> <p>I studied lua5, neko, v8 but.. well... I am sure not one of the brightest one around.</p> <p>Does anybody have experience designing AST and implementing transformations on a AST, which is easy to work on? I would appreciate tips and tricks that made life easier for you?</p> <p>(Please don't tell me to go read dragon book. I have it already.)</p>
[ { "answer_id": 1115707, "author": "Ira Baxter", "author_id": 120163, "author_profile": "https://Stackoverflow.com/users/120163", "pm_score": 0, "selected": false, "text": "optimize_increment(x:exp):statement\n= \" \\x=\\x+1; \" --> \" \\x++ \" if no_side_effects(x);\n" } ]
2009/01/06
[ "https://Stackoverflow.com/questions/416854", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7988/" ]
416,856
<p>How can I determine if a user, in say Access, is a member of an Active Directory Security Group?</p> <p>I'd rather not build a whole authentication system into my little Access DB.</p> <p>Thanks</p>
[ { "answer_id": 416889, "author": "Allain Lalonde", "author_id": 2443, "author_profile": "https://Stackoverflow.com/users/2443", "pm_score": 2, "selected": false, "text": "Function IsMember(strDomain As String, strGroup _\n As String, strMember As String) As Boolean\n Dim grp As Object\...
2009/01/06
[ "https://Stackoverflow.com/questions/416856", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2443/" ]
416,861
<p>I'm using a list of objects as the data source of my GridView and when I set columns to not be visible the updates fail because the value of those columns is changed to null (and the column doesn't allow nulls). The values do exist when the columns are visible but I really don't want to display these columns because, for the most part, they are ID columns that the user doesn't really need to see.</p> <p>EDIT: I've tried the hidden field option but it still sets the value to null. I've looked at the page source and the hidden field exists with the appropriate value...</p>
[ { "answer_id": 417822, "author": "Austin Salonen", "author_id": 4068, "author_profile": "https://Stackoverflow.com/users/4068", "pm_score": 3, "selected": true, "text": "protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)\n{\n e.Row.Cells[1].Visible = false;\n ...
2009/01/06
[ "https://Stackoverflow.com/questions/416861", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4068/" ]
416,873
<p>I'm using a WebBrowser control in my Visual C# (.net 2.0) application.<br /> Now I'd like to add a print button which shows the page setup dialog and then directly prints when the user presses the OK button or cancels the printing when the user presses the cancel button.<br /> However WebBrowser.ShowPageSetupDialog doesn't return DialogResult, but just void.<br /> Is there something I've missed or any other way to know the users action?</p>
[ { "answer_id": 417822, "author": "Austin Salonen", "author_id": 4068, "author_profile": "https://Stackoverflow.com/users/4068", "pm_score": 3, "selected": true, "text": "protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)\n{\n e.Row.Cells[1].Visible = false;\n ...
2009/01/06
[ "https://Stackoverflow.com/questions/416873", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34022/" ]
416,875
<p>I'm a ClearCase newbie and up until now have been used to SVN. Therefore, I'm a bit confused on the steps I need to take to create a new directory structure containing multiple files to ClearCase.</p> <p>So, say for example there is an existing directory structure within ClearCase as follows:</p> <pre><code>\ParentDirectory \ChildDirectory1 \File1 \File2 \ChildDirectory2 \ChildDirectory3 \File1 \ChildDirectory4 </code></pre> <p>If I want to add a new subdirectory to this structure, ChildDirectory5, which will contain a number of other files, how do I go about this? From what I have been reading, I will need to first of all check out the parent directory and then use the mkelem command to make each subdirectory and file.</p> <p>However, I have already created the necessary files and directories on my local machine so I just need to check them into ClearCase somehow. With SVN, all I would've needed to do was copy the parent folder into a checked out repo and do an add &amp; commit command sequence on it.</p>
[ { "answer_id": 418196, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 4, "selected": true, "text": "clearfsimport -preview -rec -nset c:\\sourceDir\\ChildDirectory5 m:\\MyView\\MyVob\\ParentDirectory\n" }, { "answer_id":...
2009/01/06
[ "https://Stackoverflow.com/questions/416875", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42435/" ]
416,881
<p>Using SQL Server 2005 and Management Studio how do I insert a picture into an <code>Image</code> type column of a table? </p> <p>Most importantly how do I verify if it is there?</p>
[ { "answer_id": 416918, "author": "Darin Dimitrov", "author_id": 29407, "author_profile": "https://Stackoverflow.com/users/29407", "pm_score": 8, "selected": true, "text": "CREATE TABLE Employees\n(\n Id int,\n Name varchar(50) not null,\n Photo varbinary(max) not null\n)\n\n\nIN...
2009/01/06
[ "https://Stackoverflow.com/questions/416881", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18631/" ]
416,893
<p>I've been reading <a href="http://filthyrichclients.org/" rel="nofollow noreferrer">Filthy Rich Clients</a> lately and noticed that, although the version of Java is 6, there is no mention of the Concurrent Framework. So, they talk about java.util.Timer and javax.swing.Timer but not about the ExecutorService.</p> <p>I read about the advantages of ExecutorService in the question "<a href="https://stackoverflow.com/questions/409932/java-timer-vs-executorservice">Java Timer vs ExecutorService</a>" and decided to use the latter over the former. But the book talks about javax.swing.Timer and it's advantages of being specific for Swing development.</p> <p>So, does this mean that, for Swing development (animating buttons etc.), javax.swing.Timer is still a better choice or is there a relevant class in the new Concurrent Framework that replaces it?</p>
[ { "answer_id": 417019, "author": "bruno conde", "author_id": 31136, "author_profile": "https://Stackoverflow.com/users/31136", "pm_score": 3, "selected": false, "text": "javax.swing.Timer ExecutorService" }, { "answer_id": 417095, "author": "Nicholas", "author_id": 43786,...
2009/01/06
[ "https://Stackoverflow.com/questions/416893", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2644/" ]
416,897
<p>I want to show a label rotated 90 degrees (so I can put a bunch of them at the top of a table as the headings). Is there an easy way to do this?</p>
[ { "answer_id": 416916, "author": "Bob", "author_id": 45, "author_profile": "https://Stackoverflow.com/users/45", "pm_score": 6, "selected": true, "text": "/// <summary>\n/// This is a lable, in which you can set the text in any direction/angle\n/// </summary>\n\n#region Orientation\n\n//...
2009/01/06
[ "https://Stackoverflow.com/questions/416897", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26874/" ]
416,904
<p>I am not familiar with this, and can use a kick start.</p> <p>I am using ATL (unmanaged C++) user control and would like to use the ShockWave ActiveX object. I need to know how to declare it so that I can set a property or call a method.</p> <p>For instance, if I could assign a variable to it, then I would like to call 'variable->LoadMovie()'</p> <p>I know this is super ridiculous... almost embarrassed to ask it here. ;) (almost)</p>
[ { "answer_id": 416943, "author": "Jordan Parmer", "author_id": 20133, "author_profile": "https://Stackoverflow.com/users/20133", "pm_score": 2, "selected": true, "text": "ISomeInterfacePtr pSomeInterface( CLSID_SomeComponent );\nHRESULT hr = pSomeInterface->SomeMethod();\n ISomeInterface...
2009/01/06
[ "https://Stackoverflow.com/questions/416904", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16794/" ]
416,914
<p>This post is not really a question, but it could be useful to share some coding tips.</p> <p>Here is the one I'd like to share with you. I'm going to show 4 examples that do the same thing. But only the last one will be the best.</p> <pre><code>$foo = 'John SMITH'; echo "Hello $foo, welcome on my website."; echo "Hello " . $foo . " welcome on my website."; echo 'Hello ' . $foo . ' welcome on my website.'; echo 'Hello ', $foo , ' welcome on my website.'; </code></pre> <p>I'm sure you all know that <code>echo '$foo'</code> won't work, but still, I'm pretty sure that you use double quote to display a simple information. <strong>This is bad</strong>.</p> <p>Well let's begin : The first one is bad (as well as the second) because using double quote forces php to scan the string to look for a substitution to be done (I mean a variable).</p> <p>The second one is a little better, since php has no replacement to do.</p> <p>The third one, is better because of simple quote, so that the language knows he can just send the text without processing, but the "bad" thing is the use of concatenation (dot operator, like in the second example).</p> <p>The last one uses simple quote, and the coma operator. Why is this solution better?</p> <p>Well, what happens when Using the third solution?</p> <p>php creates a string, containing <code>"Hello "</code>, then it has to enlarge it, to put the content of foo variable ("John SMITH"), and then, enlarge it again to put <code>" Welcome on my website."</code> sentence. Then, <code>echo</code> can use this, to ... echo it :)</p> <p>Whereas in the 4th one, the only thing to do for <code>echo</code> is to send "Hello ", then $foo's content, then " Welcome on my website." to the output, and that is all! Because echo just has to send the text, without creating a string that will have to be enlarged to contain the whole text (that would have been concave, which has to be grown (because of concatenation) and then displayed.</p> <p>I'll try to find back some benchmarks and put them here.</p> <p>Fell free to comment or react, and excuse my English, this is not my mother tongue.</p>
[ { "answer_id": 416955, "author": "Bombe", "author_id": 43582, "author_profile": "https://Stackoverflow.com/users/43582", "pm_score": 5, "selected": false, "text": "0.0022029876709\n0.00211095809937\n0.00213599205017\n0.00551700592041\n" } ]
2009/01/06
[ "https://Stackoverflow.com/questions/416914", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51760/" ]
416,926
<p>Say I have a list and I want it arranged so that the sum of a certain function operating over its consecutive elements is minimum. </p> <p>For example consider the list <code>{ 1, 2, 3, 4 }</code> and sum <code>a^b</code> for consecutive pairs <code>(a,b)</code> over the entire list. ie. <code>1^2 + 2^3 + 3^4 = 90</code>. By inspection, the minimum sum is achieved when the list is arranged as <code>{ 2, 3, 1, 4 } =&gt; (2^3 + 3^1 + 1^4 = 12</code>).</p> <p>Note that the sum is not looping (ie. I do not consider <code>last^first</code>) and order is important <code>(2^3 != 3^2)</code> and also <code>a^b</code> could be any function operating over any number of consecutive elements.</p> <p>Is there a name for such an algorithm and is there established ways of implementing it?</p> <p><strong>EDIT:</strong> I have reworded the question since I had incorrectly labeled this as a sorting problem. As pointed out, this is more of an optimization problem.</p>
[ { "answer_id": 417005, "author": "BenAlabaster", "author_id": 40650, "author_profile": "https://Stackoverflow.com/users/40650", "pm_score": 1, "selected": false, "text": "class Calc\n{\n private int[] items;\n private double total;\n public double Total \n { \n get\n ...
2009/01/06
[ "https://Stackoverflow.com/questions/416926", "https://Stackoverflow.com", "https://Stackoverflow.com/users/976/" ]
416,942
<p>I have a C# project in VS 2005, with a reference to Foo.dll, a library of C++ .NET code, at c:\Foo\Foo.dll. It shows the reference in the Object Browser properly, but for a given object + method, I can't figure out how to navigate to the source for it inside of Visual Studio. </p> <p>I've built Foo.dll myself from source on my local machine, and Foo.pdb is in the same location as Foo.dll, at c:\Foo\Foo.dll.pdb. I don't have a project for Foo in the solution I'm working within.</p> <p>Looking at a stack trace from my C# app, I can see that it knows exactly where the source is on my system - I see a line that looks like:</p> <p><strong>at mycompany.Foo.SomeClass.SomeMethod() in c:\src\foo\src\SomeClass.cc: line 123</strong></p> <p>This is the right location for that source file, but I can't figure out at all how to easily have VS open SomeClass.cc. Does Visual Studio require that Foo be setup as a project in my solution in order to easily navigate to the source code?</p> <p>Thanks!</p>
[ { "answer_id": 417005, "author": "BenAlabaster", "author_id": 40650, "author_profile": "https://Stackoverflow.com/users/40650", "pm_score": 1, "selected": false, "text": "class Calc\n{\n private int[] items;\n private double total;\n public double Total \n { \n get\n ...
2009/01/06
[ "https://Stackoverflow.com/questions/416942", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51705/" ]
416,944
<p>My problem is that I receive for example a date in a concatenated format:</p> <pre><code>Ex: 20050728 </code></pre> <p>And I have to retrieve it in a readable format through my xslt.</p> <pre><code>Ex. 28 July 2005 </code></pre> <p>I also have a similar question regards time.</p> <pre><code>Ex: 0004 </code></pre> <p>To be displayed as <code>00:04</code></p> <p>How is this done?</p>
[ { "answer_id": 417501, "author": "Dimitre Novatchev", "author_id": 36305, "author_profile": "https://Stackoverflow.com/users/36305", "pm_score": 3, "selected": true, "text": "substring() <xsl:stylesheet version=\"1.0\"\n xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\">\n <xsl:output m...
2009/01/06
[ "https://Stackoverflow.com/questions/416944", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44649/" ]
416,947
<p>Whenever I read about Swing they say they are light weight components. So I just googled Swing and found that it means Swing does not depend on native peers. Is that why they are called <strong>"light weight"</strong>? I mean by light weight I thought maybe the Swing components occupy less memory than the AWT components. Isn't that so?</p>
[ { "answer_id": 417012, "author": "coobird", "author_id": 17172, "author_profile": "https://Stackoverflow.com/users/17172", "pm_score": 5, "selected": true, "text": "JTable JList" } ]
2009/01/06
[ "https://Stackoverflow.com/questions/416947", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50940/" ]
416,956
<p>I have written the following function.. and executed using WinHugs</p> <pre><code>teneven = [x | x &lt;- [1..10], even x] </code></pre> <p>My output:</p> <pre><code>Main&gt; teneven [2,4,6,8,10] :: [Integer] (63 reductions, 102 cells) </code></pre> <p>is there anyway to print all the reductions.. so I can learn the core evaluation happening inside WinHugs?</p>
[ { "answer_id": 554391, "author": "A. Rex", "author_id": 3508, "author_profile": "https://Stackoverflow.com/users/3508", "pm_score": 4, "selected": true, "text": ":set +d main = {IO}\nteneven = [2,4,6,8,10]\n_foldr (\\..) [1,2,3,4,5,6,7,8, ...] [] = [2,4,6,8,10]\n(\\..) 1 [2,4,6,8,10] = [...
2009/01/06
[ "https://Stackoverflow.com/questions/416956", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49767/" ]
416,957
<p>I'm normally a Linux guy, but I need to write a batch script on Windows to change the target of some shortcuts. Is there a command to do that?</p>
[ { "answer_id": 417036, "author": "Tmdean", "author_id": 45084, "author_profile": "https://Stackoverflow.com/users/45084", "pm_score": 6, "selected": true, "text": "Set sh = CreateObject(\"WScript.Shell\")\nSet shortcut = sh.CreateShortcut(\"C:\\Wherever\\Shortcut.lnk\")\nshortcut.TargetP...
2009/01/06
[ "https://Stackoverflow.com/questions/416957", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1103052/" ]
416,967
<p>I have an app holding an array of instances of a class called SwimmingPool.</p> <p>At present my application persistence is dealt with by encoding everything into NSData and saving that to the iPhone. This is then reloaded everytime the app starts.</p> <p>I have a few friends populating their individual applications with instances of SwimmingPool. I want them to send me their application information. I will then import it all into my 'master' app, pooling everyones SwimmingPool instances and finally I will submit the app to the appStore.</p> <p>My question is, What is the best way for me to receive their data? Is it possible for my app to encode to an instance of NSData and then export that to mail on the iphone/ipod touch? (they can email it to me)</p> <p>I will then create an import method to parse the individual swimming pools into my main NSData. </p> <p>Is this possible?/the best solution?</p> <p>Thanks alot everyone who has answered my previous questions. I hope to contribute to this community as much as I can. (not just with questions!)</p> <p>Dan</p>
[ { "answer_id": 418226, "author": "jpm", "author_id": 35478, "author_profile": "https://Stackoverflow.com/users/35478", "pm_score": 1, "selected": true, "text": "NSURLConnection [NSData +dataWithContentsOfURL:]" } ]
2009/01/06
[ "https://Stackoverflow.com/questions/416967", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51420/" ]
416,968
<p>I am receiving dynamic xml where I won't know the attribute names, if you'll look at the xml and code... I tried to make a simple example, I can get the attribute values i.e. "myName", "myNextAttribute", and "blah", but I can't get the attribute names i.e. "name", "nextAttribute", and "etc1". Any ideas, I figure it has to be something easy I'm missing...but I'm sure missing it.</p> <pre><code> static void Main(string[] args) { string xml = "&lt;test name=\"myName\" nextAttribute=\"myNextAttribute\" etc1=\"blah\"/&gt;"; TextReader sr = new StringReader(xml); using (XmlReader xr = XmlReader.Create(sr)) { while (xr.Read()) { switch (xr.NodeType) { case XmlNodeType.Element: if (xr.HasAttributes) { for (int i = 0; i &lt; xr.AttributeCount; i++) { System.Windows.Forms.MessageBox.Show(xr.GetAttribute(i)); } } break; default: break; } } } } </code></pre>
[ { "answer_id": 417020, "author": "Dror", "author_id": 48317, "author_profile": "https://Stackoverflow.com/users/48317", "pm_score": 6, "selected": true, "text": "if (reader.HasAttributes) {\n Console.WriteLine(\"Attributes of <\" + reader.Name + \">\");\n while (reader.MoveToNextAttrib...
2009/01/06
[ "https://Stackoverflow.com/questions/416968", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36614/" ]
416,970
<p>Does the Hibernate API support object result sets in the form of a collection other than a List? </p> <p>For example, I have process that runs hundreds of thousands of iterations in order to create some data for a client. This process uses records from a Value table (for example) in order to create this output for each iteration. </p> <p>With a List I would have to iterate through the entire list in order to find a certain value, which is expensive. I'd like to be able to return a TreeMap and specify a key programmatically so I can search the collection for the specific value I need. Can Hibernate do this for me?</p>
[ { "answer_id": 416987, "author": "Elie", "author_id": 23249, "author_profile": "https://Stackoverflow.com/users/23249", "pm_score": 1, "selected": false, "text": "<map> java.util.HashMap java.util.SortedMap <map> java.util.TreeMap" }, { "answer_id": 417001, "author": "Michael...
2009/01/06
[ "https://Stackoverflow.com/questions/416970", "https://Stackoverflow.com", "https://Stackoverflow.com/users/318/" ]
416,974
<p>Lately all modern programming languages have a definitive web site to support, distribute, learn the programming language, as well as community forums, e-mail lists and so on. Java has java.sun.com, python has python.org, etc. </p> <p>However C/C++ does not seem to have such a site. Which site do you use, say in a document, to link for C or C++ programming language? Wikipedia entries don't count, although they might be perfect fit.</p> <p>Founder's web sites? Or any other ideas?</p>
[ { "answer_id": 417293, "author": "Johannes Schaub - litb", "author_id": 34509, "author_profile": "https://Stackoverflow.com/users/34509", "pm_score": 2, "selected": false, "text": "comp.lang.c++.moderated comp.lang.c++ comp.std.c++" } ]
2009/01/06
[ "https://Stackoverflow.com/questions/416974", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36830/" ]
416,978
<p>What's the best way to store a date value for which in many cases only the year may be known?</p> <p>MySQL allows zeros in date parts unless the NO_ZEROES_IN_DATE sql mode is enabled, which isn't by default. Is there any reason not to use a date field where if the month and day may be zero, or to split it up to 3 different fields for year, month and day (year(4), tinyint, tinyint)?</p>
[ { "answer_id": 417052, "author": "Mark", "author_id": 50262, "author_profile": "https://Stackoverflow.com/users/50262", "pm_score": 0, "selected": false, "text": "mysql> select * from test;\n+------------+------+\n| field | id |\n+------------+------+\n| 2007-00-00 | 1 | \n+---...
2009/01/06
[ "https://Stackoverflow.com/questions/416978", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41613/" ]
416,983
<p>I have a tcl script which 'exec' rpmbuild. When doing so, the 'topdir' used by rpmbuild is wrong. I have a .rpmmacros file in my home directory and if I call manually rpmbuild, it works fine, ie. the 'topdir' is not the default one. </p> <p>I added a <em>[exec rpmbuild "--showrc" ]</em> in the tcl script to check the value of <em>topdir</em> and it says '-14: _topdir %{_usrsrc}/redhat' which is the default value. </p> <p>Can someone explain me why is that situation and how to solve it ? </p> <p>I would prefer not to have to specify it with --define because it is actually done in a makefile and I don't want to touch it (if no other choice, I will do it).</p>
[ { "answer_id": 417572, "author": "Joseph Bui", "author_id": 3275, "author_profile": "https://Stackoverflow.com/users/3275", "pm_score": 1, "selected": false, "text": "cd ~username\n set env(topdir) whatever/you/want\n" }, { "answer_id": 464348, "author": "PeterS", "author...
2009/01/06
[ "https://Stackoverflow.com/questions/416983", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20986/" ]
417,000
<p>I am a bit stuck on the design of my seo friendly urls for mvc....Take for example the following url: <a href="http://myapp/venues/resturants.aspx?location=central&amp;orderBy=top-rated" rel="nofollow noreferrer">http://myapp/venues/resturants.aspx?location=central&amp;orderBy=top-rated</a></p> <p>With my mvc app i have mapped it as follows: <a href="http://myapp/venues/list/resturants/central/top-rated" rel="nofollow noreferrer">http://myapp/venues/list/resturants/central/top-rated</a><br> {controller}/{action}/{category}/{location}/{order}</p> <p>Now the only problem is that location and order are optional...so it should be possible to submit a request like: <a href="http://myapp/venues/list/resturants/top-rated" rel="nofollow noreferrer">http://myapp/venues/list/resturants/top-rated</a> . This proves to be a problem when the request hits the controller action, the location parameter has picked up "top-rated", naturally.</p> <p>Any suggestions? I' am considering using explicit querystrings to handle more than one parameter but this is really my last option as i dont want to sacrifice SEO too much.</p> <p>Has anyone eles run into such dilemmas? And how did you handle it?</p> <p>Thanks in advance!</p>
[ { "answer_id": 417241, "author": "Giraffe", "author_id": 50136, "author_profile": "https://Stackoverflow.com/users/50136", "pm_score": 3, "selected": true, "text": "{controller}/{action}/{param1}/{param2} public ActionResult MyAction(string param1, string param2)\n{\n string location;...
2009/01/06
[ "https://Stackoverflow.com/questions/417000", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
417,004
<p>We're having trouble setting window captions using cyrillic or japanese characters. We either see question marks or random garbage, but not the text we want. We've tried using different encodings, SetWindowText(), SetWindowTextW(), SetWindowTextA(), and so on. We can't even get it to work by passing a string literal to SetWindowText().</p> <p>Our Windows install does appear to have everything it needs - Internet Explorer and Firefox do show cyrillic and japanese captions correctly, for example. So I'm pretty sure we're not finding the correct encoding/method combination. Any suggestions?</p>
[ { "answer_id": 417434, "author": "Serge Wautier", "author_id": 12379, "author_profile": "https://Stackoverflow.com/users/12379", "pm_score": 1, "selected": true, "text": "SetWindowText() SetWindowTextA() CreateWindowExW()" } ]
2009/01/06
[ "https://Stackoverflow.com/questions/417004", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39301/" ]
417,017
<p>I am looking for a way to condense relatively small areas of text on a page in an effort to mimic a graphic button that was done with a non-standard font. Ideally, just the letters would get squished or made thinner, leaving the space between words more or less the same. I know there are some CSS attributes that do things like this, but they are more focused on spacing between the letters and not so much on the widths of the letters themselves. These CSS methods are also not very cross-browser friendly. The majority of the user base is using IE6, so that puts a large restriction on CSS-based methods out of the blocks.</p> <p>So, is there any way to control the character width/spacing that is cross-browser friendly? I know jQuery works across browsers quite well, so could this perhaps be done with jQuery by manipulating the location of the letters and possibly their widths? These are small bits of text, 5 words at a time, or so, so speed is something that can be dealt with later.</p> <hr> <p>EDIT: Ok, so, the CSS letter-spacing property, as well as the word-spacing property will allow me to control the space between letters/words. However, this makes things look squished. If this truly is the only option, then I'll have to make it work, but what I am really looking for is a way to squish the letters themselves, to make the characters thinner.</p>
[ { "answer_id": 417041, "author": "Ionuț Staicu", "author_id": 23810, "author_profile": "https://Stackoverflow.com/users/23810", "pm_score": 4, "selected": false, "text": "letter-spacing:-1px\n" }, { "answer_id": 417048, "author": "Adam Bellaire", "author_id": 21632, "...
2009/01/06
[ "https://Stackoverflow.com/questions/417017", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20770/" ]
417,024
<p>Suppose someone (other than me) writes the following code and compiles it into an assembly:</p> <pre><code>using (SqlConnection conn = new SqlConnection(connString)) { conn.Open(); using (var transaction = conn.BeginTransaction()) { /* Update something in the database */ /* Then call any registered OnUpdate handlers */ InvokeOnUpdate(conn); transaction.Commit(); } } </code></pre> <p>The call to InvokeOnUpdate(IDbConnection conn) calls out to an event handler that I can implement and register. Thus, in this handler I will have a reference to the IDbConnection object, but I won't have a reference to the pending transaction. Is there any way in which I can get a hold of the transaction? In my OnUpdate handler I want to execute something similar to the following:</p> <pre><code>private void MyOnUpdateHandler(IDbConnection conn) { var cmd = conn.CreateCommand(); cmd.CommandText = someSQLString; cmd.CommandType = CommandType.Text; cmd.ExecuteNonQuery(); } </code></pre> <p>However, the call to cmd.ExecuteNonQuery() throws an InvalidOperationException complaining that </p> <blockquote> <p>"ExecuteNonQuery requires the command to have a transaction when the connection assigned to the command is in a pending local transaction. The Transaction property of the command has not been initialized".</p> </blockquote> <p>Can I in any way enlist my SqlCommand cmd with the pending transaction? Can I retrieve a reference to the pending transaction from the IDbConnection object (I'd be happy to use reflection if necessary)?</p>
[ { "answer_id": 417080, "author": "lvaneenoo", "author_id": 24101, "author_profile": "https://Stackoverflow.com/users/24101", "pm_score": 2, "selected": false, "text": "System.Transactions using System.Transactions;\n\n class Foo\n { \n void Bar()\n {\n ...
2009/01/06
[ "https://Stackoverflow.com/questions/417024", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40348/" ]
417,032
<p>I created a simple report and uploaded it to my report server. It looks correct on the report server, but when I set up an email subscription, the report is much narrower than it is supposed to be.</p> <p>Here is what the report looks like in the designer. It looks similar when I view it on the report server: [<a href="http://img58.imageshack.us/img58/4893/designqj3.png]" rel="nofollow noreferrer">http://img58.imageshack.us/img58/4893/designqj3.png]</a></p> <p>Here is what the email looks like: [<a href="http://img58.imageshack.us/img58/9297/emailmy8.png]" rel="nofollow noreferrer">http://img58.imageshack.us/img58/9297/emailmy8.png]</a></p> <p>Does anyone know why this is happening?</p>
[ { "answer_id": 2489640, "author": "James Newton-King", "author_id": 11829, "author_profile": "https://Stackoverflow.com/users/11829", "pm_score": 1, "selected": false, "text": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" } ]
2009/01/06
[ "https://Stackoverflow.com/questions/417032", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52080/" ]
417,039
<p>I have some configuration data that I'd like to model in code as so:</p> <pre><code>Key1, Key2, Key3, Value null, null, null, 1 1, null, null, 2 9, null, null, 21 1, null, 3, 3 null, 2, 3, 4 1, 2, 3, 5 </code></pre> <p>With this configuration set, I then need to do lookups on bazillion (give or take) {Key1, Key2, Key3} tuples to get the "effective" value. The effective value to use is based on a Key/Priority sum whereby in this example:</p> <pre><code>Key1 - Priority 10 Key2 - Priority 7 Key3 - Priority 5 </code></pre> <p>So a specifc query which has a config entry on Key1=null, Key2=match, and Key3=match beats out one that has Key1=match, Key2=null, and Key3=null since Key2+Key3 priority > Key1 priority... That make sense?!</p> <pre><code>given a key of {1, 2, 3} the value should be 5. given a key of {3, 2, 3} the value should be 4. given a key of {8, 10, 11} the value should be 1. given a key of {1, 10, 11} the value should be 2. given a key of {9, 2, 3} the value should be 4. given a key of {8, 2, 3} the value should be 4. given a key of {9, 3, 3} the value should be 21. </code></pre> <p>Is there an easy way to model this data structure and lookup algorithm that is generic in that the # and types of keys is variable, and the "truth table" (the ordering of the lookups) can be defined dynamically? The types being generics instead of ints would be perfect (floats, doubles, ushorts, etc), and making it easy to expand to n number of keys is important too!</p> <p>Estimated "config" table size: 1,000 rows, Estimated "data" being looked up: 1e14</p> <p>That gives an idea about the type of performance that would be expected.</p> <p>I'm looking for ideas in C# or something that can translate to C# easily.</p>
[ { "answer_id": 417125, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 2, "selected": false, "text": "Dictionary<int, NextLevel> matches;\nNextLevel nonMatch;\n using System;\nusing System.Collections;\nusing System.Collec...
2009/01/06
[ "https://Stackoverflow.com/questions/417039", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18941/" ]
417,062
<p>It is often useful to have a field in a DAO whose value comes from a Java enumeration. A typical example is a login DAO where you usually have a field that characterises the user as "NORMAL" or "ADMIN". In Hibernate, I would use the following 2 objects to represent this relationship in a (semi-)typesafe way:</p> <pre><code>class User { String username; String passwd; UserType type; } class UserType { private enum Type {ADMIN, NORMAL}; private String type; //Setters/Getters for Hibernate public void setType(String type); public String getType(); //Setters/Getters for user public void setUserType(UserType.Type t); public UserType.Type getUserType(); public static UserType fromType(UserType.Type t); } </code></pre> <p>This works, but I find the UserType class ungly and requiring too much bureaucracy just to store a couple of values. Ideally, Hibernate should support enum fields directly and would create an extra table to store the enumeration values.</p> <p>My question is: Is there any way to directly map an enumeration class in Hibernate? If not, is my pattern for representing enumerations good enough or am I missing something? What other patterns do people use? </p>
[ { "answer_id": 417127, "author": "Craig", "author_id": 1611, "author_profile": "https://Stackoverflow.com/users/1611", "pm_score": 4, "selected": false, "text": "<type> <property name='suit'>\n <type name=\"EnumUserType\">\n <param name=\"enumClassName\">com.company.project.Sui...
2009/01/06
[ "https://Stackoverflow.com/questions/417062", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51681/" ]
417,072
<p>This is a bit special:<br /> I'm loading some HTML in string form into the WebBrowser control via the DocumentText property.<br /> Now when I print the page with a PDF printer (Bullzip PDF Printer in my case) it always takes the URL as document name which is "about:blank".<br /> Is there any way to change this to another value by either changing the URL property (it's read-only) or by changing the print behaviour to use another text rather than the URL as filename?</p>
[ { "answer_id": 417102, "author": "MSalters", "author_id": 15416, "author_profile": "https://Stackoverflow.com/users/15416", "pm_score": 0, "selected": false, "text": "Navigate DWebBrowserEvents::BeforeNavigate" } ]
2009/01/06
[ "https://Stackoverflow.com/questions/417072", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34022/" ]
417,074
<p>I downloaded the Eclipse PDT 2.0 GA release (Eclipse 3.4), however, it doesn't look like the Ant tools are included in this package. How can I install the eclipse Ant tools (editor, executable, etc...)?</p>
[ { "answer_id": 494145, "author": "Don Kirkby", "author_id": 4794, "author_profile": "https://Stackoverflow.com/users/4794", "pm_score": 0, "selected": false, "text": "<!DOCTYPE project>\n" } ]
2009/01/06
[ "https://Stackoverflow.com/questions/417074", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43816/" ]
417,078
<p>I have used ValidatorEnable to disable a RequiredFieldValidator in javascript. However on postback the control being validated by the validator is still validated ... even though I disabled the validator on the client.</p> <p>I understand why this is happening since I've only disabled the client validation ... however is there a nice way to determine that I've disabled the client validation and to then disable the server validation on postback?</p>
[ { "answer_id": 417414, "author": "Jay S", "author_id": 30440, "author_profile": "https://Stackoverflow.com/users/30440", "pm_score": 1, "selected": true, "text": "this.requiredValidator.Enabled = this.myRadioButton.Checked;\n" } ]
2009/01/06
[ "https://Stackoverflow.com/questions/417078", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47036/" ]
417,087
<p>I have a listbox of names, I want to click one of the names so that it is highlighted and then click a button that runs some code for the selected item. How do I call this selected item?</p> <pre><code> private void btnEcho_Click(object sender, EventArgs e) { listbox1.SelectedItem...... } </code></pre> <p>Many thanks</p>
[ { "answer_id": 417107, "author": "Elie", "author_id": 23249, "author_profile": "https://Stackoverflow.com/users/23249", "pm_score": 0, "selected": false, "text": "String s = listbox1.SelectedItem.Value.ToString();\n" }, { "answer_id": 417116, "author": "robertpnl", "autho...
2009/01/06
[ "https://Stackoverflow.com/questions/417087", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
417,097
<p>Hey. I've got some code from Agile Web Development that wraps some HTML around a method call as so:</p> <pre><code> # from tagged_builder.rb, included as a FormBuilder helper def self.create_tagged_field(method_name) define_method(method_name) do |label, *args| @template.content_tag("p", @template.content_tag("label" , label.to_s.humanize.capitalize, :for =&gt; "#{@object_name}_#{label}") + super) end end </code></pre> <p>I would like to nest a span tag within the label content_tag, so that the final output would be along the lines of:</p> <pre><code>&lt;p&gt;&lt;label&gt;Name &lt;span class="small"&gt;Add your name&lt;/span&gt; &lt;/label&gt; &lt;input type="text" name="textfield" id="textfield" /&gt; </code></pre> <p></p></p> <p>I am wondering how I go about including the span's content (say a variable such as 'warning')</p> <p>I have tried all sorts, to no avail. The methods call ok (such as f.text_field :name will produce </p> <pre><code>&lt;p&gt;&lt;label for="object_name"&gt;Name&lt;/label&gt;&lt;/p&gt; </code></pre> <p>Have tried this:</p> <pre><code> def self.create_tagged_field(method_name) define_method(method_name) do |label, warning, *args| @template.content_tag("p", @template.content_tag("label" , label.to_s.humanize.capitalize+ content_tag("span", warning), :for =&gt; "#{@object_name}_#{label}") + super) end end </code></pre> <p>But no luck. Can anyone steer me in the right direction? Thanks, A</p>
[ { "answer_id": 417107, "author": "Elie", "author_id": 23249, "author_profile": "https://Stackoverflow.com/users/23249", "pm_score": 0, "selected": false, "text": "String s = listbox1.SelectedItem.Value.ToString();\n" }, { "answer_id": 417116, "author": "robertpnl", "autho...
2009/01/06
[ "https://Stackoverflow.com/questions/417097", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52092/" ]
417,108
<p>Why are there dashes in a .NET GUID? Are there dashes in most implementations of a GUID, or is it just a Microsoft thing?</p> <p>Signed,</p> <p>741ecf77-9c92-4435-8e6b-85975bd13452</p>
[ { "answer_id": 417137, "author": "casperOne", "author_id": 50776, "author_profile": "https://Stackoverflow.com/users/50776", "pm_score": 7, "selected": true, "text": "public struct Guid\n{\n public ulong Data1;\n public ushort Data2;\n public ushort Data3;\n public fixed byte Data4[8...
2009/01/06
[ "https://Stackoverflow.com/questions/417108", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26/" ]
417,112
<p>I have an ASP.NET 2.0 application under IIS that has the functionnality of exporting some data to a software called HFM (Oracle Hyperion Financial Management). To perform that export, the .net application uses an API based on COM objects provided by the HFM client (the client is installed on the same machine that the server, etc.)</p> <p>My problem is that the API provides a method to connect to the HFM server but not to disconnect.<br> The documentation says that to disconnect, the application must call the method <strong>Marshal.ReleaseComObject()</strong> on each COM object created. But there are a lot of complex actions performed and I am not able to release all created object.<br> So my application doesn't disconnect.</p> <p>I've noticed that when I replace the ASP.NET application dll files (which seems to reinit the objects instanciated by .NET), the application automatically disconnects.</p> <p>I tried several times to call :</p> <pre><code>GC.Collect(); GC.WaitForPendingFinalizers(); </code></pre> <p>But the problem remains. I'm looking for a way to be sure that ANY object created, even COM objects are released. I tried with <strong>Marshal.FinalReleaseComObject()</strong> but it's not better.</p> <p>As I put a lock() on that section, there is always at most one user on that part so I can even use hardcore techniques to release the COM objects.</p> <p>Is there a way to know which object or at least the type of the object that has not been released ?</p> <p>Thanks for your help.</p>
[ { "answer_id": 1828865, "author": "AMissico", "author_id": 163921, "author_profile": "https://Stackoverflow.com/users/163921", "pm_score": 1, "selected": false, "text": "Dim cn As ADODB.Connection\ncn = New ADODB.Connection\ncn.Open(_cnnstr)\ncn.Execute(sbDML.ToString)\ncn.Close()\nSyste...
2009/01/06
[ "https://Stackoverflow.com/questions/417112", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28544/" ]
417,121
<p>The <strike>Windows default instalation comes with</strike> MSSQL client has a cliconfg application that is used to set aliases to Servers IP addresses and ports. Sometimes we use in our ConnectionStrings some of those aliases instead of IP address,port. How can I programatically translate that alias to an address using .NET?</p> <p><strong>Update:</strong> .NET + Windows automatically do this translation when we use the ConnectionString, but I don't know if the result of the translation (IP Address) is written in any public property where we can read it.</p> <p><strong>Update:</strong> I discovered that the cliconfg stores the aliases in the Windows Registry. I wonder if the Windows Registry is accessible from .NET</p> <pre><code>32bit HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Client\ConnectTo 64bit HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\MSSQLServer\Client\ConnectTo </code></pre>
[ { "answer_id": 420648, "author": "inferis", "author_id": 51998, "author_profile": "https://Stackoverflow.com/users/51998", "pm_score": 0, "selected": false, "text": "IPAddress[] ips = Dns.GetHostAddresses(\"myHostName\")" }, { "answer_id": 421766, "author": "Jader Dias", ...
2009/01/06
[ "https://Stackoverflow.com/questions/417121", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48465/" ]
417,122
<p>I have this string: <code>" Mimi loves Toto and Tata hate Mimi so Toto killed Tata"</code></p> <p>I want to write a code that print only the words that begin with capital letters, avoiding repetition</p> <p>the Output should be like</p> <pre><code>Mimi Toto Tata </code></pre> <p>I tried to do so but I'm sure its wrong even though no errors are showing.</p> <p>The code i wrote :</p> <pre><code>static void Main(string[] args) { string s = "Memi ate Toto and she killed Tata Memi also hate Biso"; Console.WriteLine((spliter(s))); } public static string spliter(string s) { string x = s; Regex exp = new Regex(@"[A-Z]"); MatchCollection M = exp.Matches(s); foreach (Match t in M) { while (x != null) { x = t.Value; } } return x; } } } </code></pre> <h2>Idea:</h2> <p>What if i split the string into an array, then apply a regex to check them word by word and then print the results ? I don't know - can any one help me in making this code work?</p>
[ { "answer_id": 417153, "author": "BFree", "author_id": 15861, "author_profile": "https://Stackoverflow.com/users/15861", "pm_score": 3, "selected": false, "text": " string[] foo = \"Mimi loves Toto and Tata hate Mimi so Toto killed Tata\".Split(' ');\n HashSet<string> words ...
2009/01/06
[ "https://Stackoverflow.com/questions/417122", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
417,131
<p>I have a page with two ContentPlaceHolders. One has a DropDown and another UpdatePanel with content. </p> <p>How can I trigger update to the UpdatePanel by the DropDown's selectedItemChanged event when they are in different ContentPlaceholders?</p> <p>The following would not work since UpdatePanel1 doesn't know about DropDown1:</p> <pre><code>&lt;asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true"&gt; &lt;ContentTemplate&gt; Some content that needs to be updated here... &lt;/ContentTemplate&gt; &lt;Triggers&gt; &lt;asp:AsyncPostBackTrigger ControlID="DropDown1" EventName="SelectedIndexChanged" /&gt; &lt;/Triggers&gt; &lt;/asp:UpdatePanel&gt; </code></pre> <p>One way is to make an ajax page method that would be called by javascript on the page when DropDown's item is selected. Then in code behind, inside that page method, call UpdatePanel1.Update(). </p> <p>Is there an easier alternative?</p>
[ { "answer_id": 417352, "author": "Robert C. Barth", "author_id": 9209, "author_profile": "https://Stackoverflow.com/users/9209", "pm_score": 2, "selected": false, "text": "ScriptManager.RegisterAsyncPostBackControl(dropdown1);\n" }, { "answer_id": 417754, "author": "Crescent ...
2009/01/06
[ "https://Stackoverflow.com/questions/417131", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37759/" ]
417,132
<p>I'm developing a new website (ASP.Net, VB codebehind pages, .Net 3.5) to replace a "Classic ASP" site.</p> <p>Some of the pages are 'public' and the rest require authentication - in this case it's done by reading DoD-issued CAC cards through the keyboard.</p> <p>Now, for 'production', they configure IIS so that it does the authentication challenge (reading the card and requesting a PIN) when it hits a certain directory (/secure in this case) so that all pages in that tree are secured.</p> <p>I'm coming ot the point where I need to see some of the information fomr the card - but when I "F5" the website I'm developing, all the Request.Clientcertificate stuff is empty - there's no 'challenge' happening with the Cassini ASP.Net development server. </p> <p>I see references to "configure IIS to put SSL on the target directory" - but I'm not running IIS on this development PC (nor is the other developer who's going to run into this shortly). The network support people will be doing this when the site is eventually copied into production but I need to test certain security features now.</p> <p>How can I configure the server that came with VS2008 to read the CAC card and 'load up' the server/session variables that I need to query? Alternatively, is there anything I can put into the .aspx or .aspx.vb pages themselves that can simulate or trigger the security challenge?</p> <p>Thanks in advance.</p>
[ { "answer_id": 1208014, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "response.write() response.end() request.clientcertificate()" } ]
2009/01/06
[ "https://Stackoverflow.com/questions/417132", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15891/" ]
417,133
<p>Is it possible to add rows to a dataset?</p>
[ { "answer_id": 417155, "author": "Stephen Wrighton", "author_id": 7516, "author_profile": "https://Stackoverflow.com/users/7516", "pm_score": 5, "selected": true, "text": "dim row as DataRow \nrow = ds.tables(0).NewRow \n' Add Values to Row here \nds.tables(0).rows.add(row)\n" }, { ...
2009/01/06
[ "https://Stackoverflow.com/questions/417133", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26087/" ]
417,142
<p>What is the maximum length of a URL for each browser?</p> <p>Is a maximum URL length part of the HTTP specification?</p>
[ { "answer_id": 417184, "author": "Paul Dixon", "author_id": 6521, "author_profile": "https://Stackoverflow.com/users/6521", "pm_score": 13, "selected": true, "text": "414 Too long request Browser Address bar document.location\n or anchor tag\n--------------...
2009/01/06
[ "https://Stackoverflow.com/questions/417142", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2172/" ]
417,152
<p>How do I set Java's min and max heap size through environment variables?</p> <p>I know that the heap sizes can be set when launching java, but I would like to have this adjusted through environment variables on my server.</p>
[ { "answer_id": 417183, "author": "a2800276", "author_id": 27408, "author_profile": "https://Stackoverflow.com/users/27408", "pm_score": 3, "selected": false, "text": "java -X -Xmx -Xms" }, { "answer_id": 417222, "author": "Todd", "author_id": 30841, "author_profile": ...
2009/01/06
[ "https://Stackoverflow.com/questions/417152", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14920/" ]
417,158
<p>Not sure if the terminology is correct, but are there rough equivalents to Java Servlet Filters in Ruby and PHP ? Are they actual concrete <em>classes</em> ?</p> <p>I assume there is also a number of common web app libraries/frameworks in Python. Is there an equivalent there ?</p> <p>Thanks.</p> <p><strong>=== ADDENDUM ===</strong></p> <p>On the good advice of <a href="https://stackoverflow.com/users/49993/kevin-davis">Kevin Davis</a>, I just want to quickly elaborate on what Java Servlet Filters are. It is basically an HTTP request interceptor. A chain of filters can be configured between the raw receipt of the request and the final destination of the request. The request parameters (and cookies, headers etc. etc.) are passed to the first filter in the chain and each filter does something with them (or not) and then passes them up the chain (or not. eg. a caching filter may simply return the result, bypassing the rest of the chain and the endpoint).</p> <p>One of the advantages is the ability to modify or enhance the web app without touching the original endpoint code.</p> <p>Cheers.</p>
[ { "answer_id": 420249, "author": "phihag", "author_id": 35070, "author_profile": "https://Stackoverflow.com/users/35070", "pm_score": 0, "selected": false, "text": ".htaccess" } ]
2009/01/06
[ "https://Stackoverflow.com/questions/417158", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43786/" ]
417,159
<p>I'm looking for different solutions to playing back SWF files on Windows, OSX and Linux using Python. Ideally I'd like to embed the player inside a wxPython frame/window.</p> <p>One possibility I'm investigating is the Mozilla XPCOM framework since its used by FireFox to load the Flash plugin within the browser.</p>
[ { "answer_id": 425445, "author": "importantshock", "author_id": 31548, "author_profile": "https://Stackoverflow.com/users/31548", "pm_score": 2, "selected": false, "text": "import webbrowser\nwebbrowser.open(your_swf_url)\n" } ]
2009/01/06
[ "https://Stackoverflow.com/questions/417159", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46914/" ]
417,178
<p>I have this problem I'm hoping someone knows the answer to. I have an oracle stored procedure that takes a customer id and returns all the customer's orders in a ref_cursor. Oversimplifying it, this is what I have:</p> <pre><code>Orders - orderId - siteID Customers - siteID - Name GetOrder(siteID, outCursor) /* returns all orders for a customer */ </code></pre> <p>Now, I need to write another procedure that takes a customer name and does a LIKE query to get all custIds, then I need to reuse the GetOrder method to return all the orders for the custIds found, something like this:</p> <pre><code> PROCEDURE GetOrderbyCustName( p_name IN VARCHAR2, curReturn OUT sys_refcursor ) IS siteid number; BEGIN FOR rec in SELECT site_id FROM customers WHERE name LIKE p_name LOOP -- This will replace curReturn in each iteration -- how do I append instead? GetOrder(rec.site_id, curReturn ); END LOOP; END GetOrderbyCustName; </code></pre> <p>My question is, how do I append the return of GetOrder to curReturn in each iteration? As it's written right now it overwrites it in each cycle of the loop. Thanks!!</p>
[ { "answer_id": 417573, "author": "Tony Andrews", "author_id": 18747, "author_profile": "https://Stackoverflow.com/users/18747", "pm_score": 3, "selected": false, "text": "PROCEDURE GetOrderbyCustName(\n p_name IN VARCHAR2,\n curReturn OUT sys_refcursor\n)\nIS\nB...
2009/01/06
[ "https://Stackoverflow.com/questions/417178", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19314/" ]
417,179
<p>Here is one more newbie question:</p> <pre><code>require 'tasks/rails' </code></pre> <p>I saw this line in Rakefile in the root path of every rails project. I guess this line is used to require vendor/rails/railties/lib/tasks/rails.rb to get all rake tasks loaded:</p> <pre><code>$VERBOSE = nil # Load Rails rakefile extensions Dir["#{File.dirname(__FILE__)}/*.rake"].each { |ext| load ext } # Load any custom rakefile extensions Dir["#{RAILS_ROOT}/lib/tasks/**/*.rake"].sort.each { |ext| load ext } Dir["#{RAILS_ROOT}/vendor/plugins/*/**/tasks/**/*.rake"].sort.each { |ext| load ext } </code></pre> <p>My question is why only 'tasks/rails' is specified for the require method, but not the full path of the file?</p> <p>Thanks in advance.</p>
[ { "answer_id": 417200, "author": "The Pied Pipes", "author_id": 52092, "author_profile": "https://Stackoverflow.com/users/52092", "pm_score": 2, "selected": false, "text": "require File.join(File.dirname(__FILE__), 'boot')\n" }, { "answer_id": 417376, "author": "Lolindrath", ...
2009/01/06
[ "https://Stackoverflow.com/questions/417179", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44512/" ]
417,187
<p>Here's a standard scenario:</p> <pre><code>if(string.IsNullOrEmpty(Configuration.AppSettings["foobar"])) throw new SomeStandardException("Application not configured correctly, bozo."); </code></pre> <p>The problem is, I am not entirely certain <em>which</em> exception <code>SomeStandardException</code> should be. </p> <p>I perused the 3.5 Framework and found two likely candidates: <a href="http://msdn.microsoft.com/en-us/library/system.configuration.configurationexception.aspx" rel="noreferrer"><code>ConfigurationException</code></a> and <a href="http://msdn.microsoft.com/en-us/library/system.configuration.configurationerrorsexception.aspx" rel="noreferrer"><code>ConfigurationErrorsException</code></a>.</p> <blockquote> <h2>System.Configuration.ConfigurationException</h2> <p>The exception that is thrown when a configuration system error has occurred.</p> <p><h3>Remarks</h3> The <code>ConfigurationException</code> exception is thrown if the application attempts to read or write data to the configuration file but is unsuccessful. Some possible reasons for this can include malformed XML in the configuration file, file permission issues, and configuration properties with values that are not valid.</p> <p><strong>Note:</strong></p> <p>The <code>ConfigurationException</code> object is maintained for backward compatibility. The <code>ConfigurationErrorsException</code> object replaces it for the configuration system.</p> </blockquote> <p>This exception actually sounds perfect for what I need, but it's been marked obsolete, so, ixnay on atthay.</p> <p>This brings us to the thoroughly puzzling <a href="http://msdn.microsoft.com/en-us/library/system.configuration.configurationerrorsexception.aspx" rel="noreferrer"><code>ConfigurationErrorsException</code></a>:</p> <blockquote> <h2>System.Configuration.ConfigurationErrorsException</h2> <p>The current value is not one of the EnableSessionState values.</p> </blockquote> <p>As you can see, its documentation is completely useless. (It's that way in both local and online help.) An examination of the class itself shows that it's drastic overkill for what I want. </p> <p>In a nutshell, I need a standard exception that should be thrown when an application configuration setting is missing or contains an invalid value. You'd think the Framework had such an exception baked into it for applications to use. (It apparently did, but it was marked obsolete, and was replaced by something <em>much</em> larger in scope.)</p> <p>What solutions, if any, are you guys using for this, and am I going to have to suck it up and roll my own exception for this?</p> <h2>Edit Addenda</h2> <p>Some have asked whether or not I could provide a default value, and continue. In certain cases, yes, and in those cases, the exception would not be thrown. However, for certain settings, this won't apply. For instance: database server names and credentials, authentication servers, and paths to installed third party applications. </p> <p>It is also worth noting that the application I'm primarily working on is a console application running in batch mode, and I want it to throw an exception that is caught by the main method and logged appropriately if the thing isn't appropriately configured. (It's legacy code I've inherited, and currently just <em>assumes</em> everything's peachy.)</p>
[ { "answer_id": 417201, "author": "Charles Bretana", "author_id": 32632, "author_profile": "https://Stackoverflow.com/users/32632", "pm_score": 1, "selected": false, "text": "[Serializable]\npublic class MyCustomApplicationException : ApplicationException\n{\n #region privates\n #en...
2009/01/06
[ "https://Stackoverflow.com/questions/417187", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47580/" ]
417,214
<p>I'm using the ValidatorCalloutExtender found in AjaxControlToolkit version 3.0.20299.9. The validation is occuring in a browser window that has resizable=0 set. The popout box is getting positioned mostly outside of the viewable window - off to the right.</p> <p>It had positioned correctly with AjaxControlToolkit version 1.0.10618.0. It actually floated over the textbox with the right of the popout just inside the right side of the viewable window with a margin of about 5px. Since we've upgraded versions of the AjaxControlToolkit it seems to render differently. Does anyone know what I need to do to get the popout to position correctly? I've been playing around with the .ajax__validatorcallout_* css classes, but everything I change seems to really screw up the display.</p>
[ { "answer_id": 425508, "author": "Aaron Palmer", "author_id": 24908, "author_profile": "https://Stackoverflow.com/users/24908", "pm_score": 4, "selected": true, "text": "<style>\n\n.CustomValidator {position:relative;margin-left:-80px;}\n\n.CustomValidator div {border:solid 1px Black;bac...
2009/01/06
[ "https://Stackoverflow.com/questions/417214", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24908/" ]
417,236
<p>I'm currently using the usual technique in my Makefile to install individual files:</p> <pre><code>install: install -D executable ${BIN_DIR} </code></pre> <p>But I just ran across a situation where I need to move a whole directory and all files underneath it into place. </p> <p>Is <code>cp -r</code> the best way or is there a more linux-y/unix-y way to do this?</p>
[ { "answer_id": 417321, "author": "Charlie Martin", "author_id": 35092, "author_profile": "https://Stackoverflow.com/users/35092", "pm_score": 4, "selected": true, "text": "cp -r cp src /path/to/target $ tar cf - src | (cd /path/to/target; tar xf -)\n" }, { "answer_id": 417326, ...
2009/01/06
[ "https://Stackoverflow.com/questions/417236", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7985/" ]
417,246
<p>I've got a list of People that are returned from an external app and I'm creating an exclusion list in my local app to give me the option of manually removing people from the list. </p> <p>I have a composite key which I have created that is common to both and I want to find an efficient way of removing people from my List using my List </p> <p>e.g </p> <pre><code>class Person { prop string compositeKey { get; set; } } class Exclusions { prop string compositeKey { get; set; } } List&lt;Person&gt; people = GetFromDB; List&lt;Exclusions&gt; exclusions = GetFromOtherDB; List&lt;Person&gt; filteredResults = People - exclustions using the composite key as a comparer </code></pre> <p>I thought LINQ was the ideal way of doing this but after trying joins, extension methods, using yields, etc. I'm still having trouble. </p> <p>If this were SQL I would use a <code>not in (?,?,?)</code> query.</p>
[ { "answer_id": 417258, "author": "Jason Jackson", "author_id": 13103, "author_profile": "https://Stackoverflow.com/users/13103", "pm_score": 1, "selected": false, "text": "public static bool In<T>(this T objToCheck, params T[] values)\n{\n if (values == null || values.Length == 0) \n ...
2009/01/06
[ "https://Stackoverflow.com/questions/417246", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
417,249
<p>Is there a way to make all character sequences UNICODE by default? For instance, now I have to say:</p> <pre><code>std::wstring wstr(L"rofl"); </code></pre> <p>instead, I'd like to say</p> <pre><code>std::wstring wstr("rofl"); </code></pre> <p>Thanks!</p> <p>Visual C++ 8.0</p>
[ { "answer_id": 417255, "author": "dalle", "author_id": 19100, "author_profile": "https://Stackoverflow.com/users/19100", "pm_score": 3, "selected": false, "text": "L\"\"" }, { "answer_id": 417274, "author": "coppro", "author_id": 16855, "author_profile": "https://Stac...
2009/01/06
[ "https://Stackoverflow.com/questions/417249", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47937/" ]
417,254
<p>I'm very new to creating macros and programming in general. I have a worksheet of 38 tabs. 31 tabs are for the days of the month. I would like to create a macro that will prompt users with a warning message any time "MCO" is selected in column N for each of these 31 tabs. Is that possible?</p> <p>Thanks</p>
[ { "answer_id": 418047, "author": "Jon Fournier", "author_id": 5106, "author_profile": "https://Stackoverflow.com/users/5106", "pm_score": 2, "selected": false, "text": "Option Compare Text\nPrivate Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)\n Dim Sele...
2009/01/06
[ "https://Stackoverflow.com/questions/417254", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
417,261
<p>It should first be noted that I am trying to avoid rewriting all my scripts to use msbuild.</p> <p>I have noticed that there are several problems when using NAnt with the VBC task and compiling a WinForms application. The main problem seems to be that VBC can't find Sub Main. This is odd, since from within VS, there is no indication that there is any sort of difference between my call to vbc and msbuild's call to vbc.</p> <p>Does anyone have any insight into a solution to this problem or a way to force the creation of the rest of the partial classes that might/might not be being produced by MSBuild/VS?</p> <p>Sample Build Script:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt; &lt;project xmlns="http://nant.sf.net/release/0.85/nant.xsd" name="Test" default="build"&gt; &lt;target name="build"&gt; &lt;vbc target="winexe" output="C:\Test.exe" main="WindowAppNantTest.My.MyApplication" verbose="true" rootnamespace="WindowAppNantTest"&gt; &lt;imports&gt; &lt;import namespace="Microsoft.VisualBasic"/&gt; &lt;import namespace="System.Windows.Forms"/&gt; &lt;/imports&gt; &lt;sources&gt; &lt;include name="**/**/*.vb"/&gt; &lt;/sources&gt; &lt;/vbc&gt; &lt;/target&gt; &lt;/project&gt; </code></pre> <p>Error(s): [vbc] vbc : error BC30420: 'Sub Main' was not found in 'WindowAppNantTest.My.MyApplication'.</p>
[ { "answer_id": 417399, "author": "Scott Saad", "author_id": 4916, "author_profile": "https://Stackoverflow.com/users/4916", "pm_score": 1, "selected": false, "text": "<vbc target=\"winexe\" output=\"C:\\Test.exe\" main=\"MyApplication\" verbose=\"true\" rootnamespace=\"WindowAppNantTest....
2009/01/06
[ "https://Stackoverflow.com/questions/417261", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8505/" ]
417,269
<p>I want to show a tooltip when hovering over a button and as long as the mouse is over the button the tooltip should follow the mouse. What is the correct way to achieve that?</p> <p>When I add a MouseMove event that calls tooltip.Show(...) with the updated mouse position it flickers extremely, and also redraws the tooltip when the mouse rests. And if it is an OwnerDraw tooltip I can see the default system tooltip style "fighting" with the self-drawn tooltip.</p>
[ { "answer_id": 417338, "author": "BFree", "author_id": 15861, "author_profile": "https://Stackoverflow.com/users/15861", "pm_score": 2, "selected": false, "text": "ListView v = new ListView();\n public Form1()\n {\n InitializeComponent();\n v.Items.Add...
2009/01/06
[ "https://Stackoverflow.com/questions/417269", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
417,275
<p>So I was playing around a little more with attributes in .NET, and realized that every call to Type.GetCustomAttributes() creates a new instance of my attribute. Why is that? I would think that the attribute instance would basically be a singleton-per-MemberInfo, with 1 instance bound to the Type, PropertyInfo, etc...</p> <p>Here is my test code:</p> <pre><code>using System; namespace AttribTest { [AttributeUsage(AttributeTargets.Class)] class MyAttribAttribute : Attribute { public string Value { get; set; } public MyAttribAttribute() : base() { Console.WriteLine("Created MyAttrib instance"); } } [MyAttrib(Value = "SetOnClass")] class MyClass { } class Program { static void Main(string[] args) { Console.WriteLine("Getting attributes for MyClass."); object[] a = typeof(MyClass).GetCustomAttributes(false); ((MyAttribAttribute)a[0]).Value = "a1"; Console.WriteLine("Getting attributes for MyClass."); a = typeof(MyClass).GetCustomAttributes(false); Console.WriteLine(((MyAttribAttribute)a[0]).Value); Console.ReadKey(); } } } </code></pre> <p>Now if <em>I</em> were to implement attributes, I would expect the output to be:</p> <pre><code>Created MyAttrib instance Getting attributes for MyClass. Getting attributes for MyClass. a1 </code></pre> <p>Where the "class loader" (sorry, I have more of a Java background, not 100% sure how .net loads its types) would compile MyClass, and create an instance of MyAttribAttribute, and store them together somewhere. (probably the Perm Gen in the heap if this were Java) The 2 calls to GetCustomAttributes() would then just return the same earlier created instance.</p> <p>But the actual output is:</p> <pre><code>Getting attributes for MyClass. Created MyAttrib instance Getting attributes for MyClass. Created MyAttrib instance SetOnClass </code></pre> <p>So... why? It seems like creating a new instance of all these objects for every call is a bit excessive, and not good for performance/memory management. Is there any way to always get the same instance over and over?</p> <p>Anyone have any ideas why it was designed this way?</p> <p>The reason I care at all is because I made a custom attribute that internally holds some validation information, so in the Attribute I basically have a "private bool Validated" that I set to true. The validation stuff takes a while, so I don't want to run it every time. Now the problem is that since it creates a new instance of the attribute each time I get the attributes, Validated is always "false".</p>
[ { "answer_id": 417302, "author": "yfeldblum", "author_id": 12349, "author_profile": "https://Stackoverflow.com/users/12349", "pm_score": 4, "selected": true, "text": "public class MyAttribute : Attribute {\n public virtual string MyText { get; set; }\n}\n [MyAttribute(MyText=\"some te...
2009/01/06
[ "https://Stackoverflow.com/questions/417275", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28278/" ]
417,276
<p>I have a situation where I'm loading some content using a URLLoader but the content could either be a video (flv or swf) an image(jpg or png or gif) or a swf. The trick is, I need to react in different ways based on the type of content that's loaded without necessarily knowing what type of content it is beforehand.</p> <p>I currently have concocted an elaborate solution (and by elaborate I mean a confusing series of if statements and try...catch blocks) involving trying to either load it into a control and catching the errors (for example: I'll create a Image instance, add an event listener for the ioError event and it's recieved I assume it's not an image or a swf...) but it kinda seems like a hack. </p> <p>Is there any clean way to determine the type of loaded content from a URLLoader? </p>
[ { "answer_id": 417991, "author": "Ronn", "author_id": 49684, "author_profile": "https://Stackoverflow.com/users/49684", "pm_score": 0, "selected": false, "text": "switch(your_request.url.split('.')[1]){\n case 'jpg':\n case 'swf':\n}\n" } ]
2009/01/06
[ "https://Stackoverflow.com/questions/417276", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3435/" ]
417,285
<p>While discussing a Java synchronization <a href="https://stackoverflow.com/questions/416183/in-java-critical-sections-what-should-i-synchronize-on#416324">question</a>, someone made a comment that the following snippets are not equivalent (and may compile to different bytecodes):</p> <pre><code>public synchronized void someMethod() { //stuff } </code></pre> <p>and</p> <pre><code>public void someMethod() { synchronized (this) { //stuff } } </code></pre> <p>Are they equivalent?</p>
[ { "answer_id": 417317, "author": "Yuval Adam", "author_id": 24545, "author_profile": "https://Stackoverflow.com/users/24545", "pm_score": 3, "selected": false, "text": "this public class A {\n public synchronized void doStuff()\n {\n // do stuff\n }\n}\n\npublic class B e...
2009/01/06
[ "https://Stackoverflow.com/questions/417285", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30316/" ]
417,292
<p>I have to analyze the memory accesses of several programs. What I am looking for is a profiler that allow me to see which one of my programs is more memory intensive insted of computing intensive. I am very interested in the number of accesses to the L1 data cache, L2, and the main memory.</p> <p>It needs to be for Linux and if it is possible only with command usage. The programming language is c++. If there is any problem with my question, such as I do not understand what you mean or we need more data please comment below.</p> <p>Thank you.</p> <p><strong>Update with the solution</strong></p> <p>I have selected the answer of Crashworks as favourited because is the only one that provided something of what I was looking for. But the question is still open, if you know a better solution please answer.</p>
[ { "answer_id": 417311, "author": "Alex B", "author_id": 6180, "author_profile": "https://Stackoverflow.com/users/6180", "pm_score": 0, "selected": false, "text": "top" } ]
2009/01/06
[ "https://Stackoverflow.com/questions/417292", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39160/" ]
417,309
<p>I need to use an ID in a URL hyperlink like this example:</p> <blockquote> <p><a href="http://www.wotnots.co.uk/property/images/property2402_image1.jpg" rel="nofollow noreferrer">http://www.wotnots.co.uk/property/images/property2402_image1.jpg</a> </p> </blockquote> <p>The ID here is <em>2402</em>. I want to change it to the ID number which is in the first column and is different on every row. I want to have the ID number to be the same as the number in the hyperlink.</p>
[ { "answer_id": 417325, "author": "Adam Lerman", "author_id": 673, "author_profile": "https://Stackoverflow.com/users/673", "pm_score": 1, "selected": false, "text": "=Concatenate(\"http://www.wotnots.co.uk/property/images/property\",$A1,\"_image1.jpg \")" }, { "answer_id": 417329...
2009/01/06
[ "https://Stackoverflow.com/questions/417309", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
417,320
<p>Another basic Rails question:</p> <p>I have a database table that needs to contain references to exactly two different records of a specific data type.</p> <p>Hypothetical example: I'm making a video game database. I have a table for "Companies." I want to have exactly one developer and exactly one publisher for each "Videogame" entry.</p> <p>I know that if I want to have one company, I can just do something like:</p> <pre><code>script/generate Videogame company:references </code></pre> <p>But I need to have both companies. I'd rather not use a join table, as there can only be exactly two of the given data type, and I need them to be distinct.</p> <p>It seems like the answer should be pretty obvious, but I can't find it anywhere on the Internet.</p>
[ { "answer_id": 417520, "author": "mlibby", "author_id": 13468, "author_profile": "https://Stackoverflow.com/users/13468", "pm_score": 3, "selected": false, "text": "create_table :videogames do |t|\n # all your other fields\n t.int :developer_id\n t.int :publisher_id\nend\n belongs_to ...
2009/01/06
[ "https://Stackoverflow.com/questions/417320", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34795/" ]
417,334
<pre><code>var alias:String = 'models.User'; registerClassAlias(alias, models.User); // If I have the alias, then // I can get the class like this: var klass:Class = flash.net.getClassByAlias(alias); // How do I do the reverse // (get the alias from the class)? // // I want to do this, but I can't find a // 'getAliasByClass' function. alias = getAliasByClass(klass); </code></pre>
[ { "answer_id": 419893, "author": "fenomas", "author_id": 10651, "author_profile": "https://Stackoverflow.com/users/10651", "pm_score": 1, "selected": false, "text": "alias = flash.utils.getQualifiedClassName( klass );\n// should return: \"models::User\"\n" }, { "answer_id": 17019...
2009/01/06
[ "https://Stackoverflow.com/questions/417334", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45476/" ]
417,363
<p>For a database assignment I have to model a system for a school. Part of the requirements is to model information for staff, students and parents. </p> <p>In the UML class diagram I have modelled this as those three classes being subtypes of a person type. This is because they will all require information on, among other things, address data.</p> <p>My question is: how do I model this in the database (mysql)?</p> <p>Thoughts so far are as follows:</p> <ol> <li>Create a monolithic person table that contains all the information for each type and will have lots of null values depending on what type is being stored. (I doubt this would go down well with the lecturer unless I argued the case <em>very</em> convincingly).</li> <li>A person table with three foreign keys which reference the subtypes but two of which will be null - in fact I'm not even sure if that makes sense or is possible?</li> <li><p>According to this <a href="http://code.djangoproject.com/wiki/ModelInheritance" rel="nofollow noreferrer">wikipage about django</a> it's possible to implement the primary key on the subtypes as follows:</p> <pre>"id" integer NOT NULL PRIMARY KEY REFERENCES "supertype" ("id")</pre></li> <li>Something else I've not thought of...</li> </ol> <p>So for those who have modelled inheritance in a database before; how did you do it? What method do you recommend and why?</p> <p>Links to articles/blog posts or previous questions are more than welcome.</p> <p>Thanks for your time!</p> <p>UPDATE</p> <p>Alright thanks for the answers everyone. I already had a separate address table so that's not an issue. </p> <p>Cheers,</p> <p>Adam</p>
[ { "answer_id": 417910, "author": "Blorgbeard", "author_id": 369, "author_profile": "https://Stackoverflow.com/users/369", "pm_score": 0, "selected": false, "text": "Person\nPersonId Name Address1 Address2 City Country\n\nStudent\nPersonId StudentId GPA Year ..\n\nStaff\nPersonId StaffId ...
2009/01/06
[ "https://Stackoverflow.com/questions/417363", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52116/" ]
417,371
<p>First check out this code. I seems like it should work for me, but it doesn't! (surprise!)</p> <p>Anyway, this is what I tried first:</p> <pre><code>SELECT Status as status, Address as ip, PCName as pc_name, (Numbers.Phone = 'CPU/' + PCName) as cpu_contact, (Numbers.Phone = 'PC/' + PCName) as pc_contact, (Numbers.Phone = 'LOGIN/' + PCName) as login_contact, FROM IPAddress WHERE $where --Generated In code JOIN Numbers ON ('CPU/' + PCName = Numbers.Phone) OR ('PC/' + PCName = Numbers.Phone) OR ('LOGIN/' + PCName = Numbers.Phone) </code></pre> <p>So what I want is some boolean calculated fields and to join on similar conditions. I would also like the result to collapse down to single rows. For example, I think the current setup would do something like this:</p> <pre><code>status ip cpu_contact pc_contact login_contact ----------------------------------------------- foo bar true false false foo bar false true false foo bar false false true </code></pre> <p>And obviously I'd rather</p> <pre><code>status ip cpu_contact pc_contact login_contact ----------------------------------------------- foo bar true true true </code></pre> <p>Any ideas? Database redesign isn't an option. If it were, I'd do that :-)</p>
[ { "answer_id": 417431, "author": "George Mastros", "author_id": 1408129, "author_profile": "https://Stackoverflow.com/users/1408129", "pm_score": 1, "selected": false, "text": "Convert(Bit, Case When Numbers.Phone = 'CPU/' + PCName Then 1 Else 0 End) as cpu_contact,\nConvert(Bit, Case Wh...
2009/01/06
[ "https://Stackoverflow.com/questions/417371", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12448/" ]
417,373
<p>I have a function (for ease, I'll just use count()) that I want to apply to maybe 4-5 different variables. Right now, I am doing this:</p> <pre><code>$a = count($a); $b = count($b); $c = count($c); $d = count($d); </code></pre> <p>Is there a better way? I know arrays can use the array_map function, but I want the values to remain as separate values, instead of values inside of an array.</p> <p>Thanks.</p>
[ { "answer_id": 417395, "author": "Ben", "author_id": 11522, "author_profile": "https://Stackoverflow.com/users/11522", "pm_score": 3, "selected": true, "text": "$arr = Array($a, $b, $c, $d);\n\nforeach ($arr as &$var)\n{\n $var = count($var);\n}\n" }, { "answer_id": 417404, ...
2009/01/06
[ "https://Stackoverflow.com/questions/417373", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29595/" ]
417,377
<p>I would like to determine what the <em>alphabet</em> for a given locale is, preferably based on the browser Accept-Language header values. Anyone know how to do this, using a library if necessary ?</p>
[ { "answer_id": 420430, "author": "Joachim Sauer", "author_id": 40342, "author_profile": "https://Stackoverflow.com/users/40342", "pm_score": 0, "selected": false, "text": "UScript" } ]
2009/01/06
[ "https://Stackoverflow.com/questions/417377", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23691/" ]
417,380
<p>I'm going to start coding some automated tests of our presentation soon. It seems that everyone recommends <a href="http://watin.sourceforge.net/index.html" rel="noreferrer">WatiN</a> and <a href="http://seleniumhq.org/" rel="noreferrer">Selenium</a>. Which do you prefer for automated testing of ASP.NET web forms? Which of these products work better for you?</p> <p>As a side note, I noticed that WatiN 2.0 has been in CTP since March 2008, is that something to be concerned about?</p>
[ { "answer_id": 6749866, "author": "penderi", "author_id": 32027, "author_profile": "https://Stackoverflow.com/users/32027", "pm_score": 4, "selected": false, "text": "browser.Visit(\"file:///C:/users/adiel/localstuff.htm\")\nbrowser.Select(\"toyota\").From(\"make\");\nbrowser.ClickButton...
2009/01/06
[ "https://Stackoverflow.com/questions/417380", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40161/" ]
417,384
<p>Using GTK, how do I query the current screen's dpi settings?</p>
[ { "answer_id": 417469, "author": "Sophie Alpert", "author_id": 49485, "author_profile": "https://Stackoverflow.com/users/49485", "pm_score": 1, "selected": false, "text": "get_height get_height_mm get_width get_width_mm" } ]
2009/01/06
[ "https://Stackoverflow.com/questions/417384", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16287/" ]
417,396
<p><a href="https://stackoverflow.com/questions/417265/what-does-sign-mean-in-django">This question</a> originally asked (wrongly) what does "|" mean in Python, when the actual question was about Django. That question had a wonderful answer by Triptych I want to preserve. </p>
[ { "answer_id": 417438, "author": "Kenan Banks", "author_id": 43089, "author_profile": "https://Stackoverflow.com/users/43089", "pm_score": 6, "selected": true, "text": "'|' set '|' a = set([1,2,3])\nb = set([2,3,4])\nc = a|b # = set([1,2,3,4])\n something.property __or__()" } ]
2009/01/06
[ "https://Stackoverflow.com/questions/417396", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5190/" ]
417,403
<p>According to the <a href="http://logging.apache.org/log4net/release/sdk/log4net.Appender.RollingFileAppender.html" rel="nofollow noreferrer">Log4Net documentation</a>, the RollingFileAppender will only roll the log file when a message is logged. I need to log to this file, but import it every day into another database. I cannot use a database appender because I need the files and I have to translate the data from the log file to the database (it isn't a direct copy). The problem is if there is no log activity after midnight, the log doesn't roll. The importer looks for the previous days file (and I can't change this code), so if there is no activity and the log hasn't rolled, the importer doesn't find the file. Is there anyway to force the log to roll at midnight without having another thread that wakes up and forces it to roll? Could a custom appender do this? I would like to avoid this if possible.</p>
[ { "answer_id": 418455, "author": "Aaron Powell", "author_id": 11388, "author_profile": "https://Stackoverflow.com/users/11388", "pm_score": 0, "selected": false, "text": "<appender name=\"RollingLogFileAppender\" type=\"log4net.Appender.RollingFileAppender\">\n <file value=\"logfile\"...
2009/01/06
[ "https://Stackoverflow.com/questions/417403", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4555/" ]
417,428
<p>Why do we need to create custom exceptions in <code>.NET?</code></p>
[ { "answer_id": 417448, "author": "lc.", "author_id": 44853, "author_profile": "https://Stackoverflow.com/users/44853", "pm_score": 2, "selected": false, "text": "ConnectionBrokenException UserSmellsBadException ConnectionBrokenException ConnectionTimeoutException" }, { "answer_id...
2009/01/06
[ "https://Stackoverflow.com/questions/417428", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50974/" ]
417,430
<p>In the following code I want to replace every occurrence of <code>"U.S.A"</code> with <code>"united states of America"</code> and every occurrence of <code>"uk"</code> with <code>"united kingdom"</code> in a string, but it does not seem to work. How do I fix it? </p> <pre><code>class Program { static void Main(string[] args) { string s = "the U.S.A love UK"; Console.WriteLine(replace(s)); } public static string replace(string s) { s = Regex.Replace(s, @"^U.S.A", " United state Of America"); s = Regex.Replace(s, @"^Uk", "United kingdom"); return s; } } </code></pre>
[ { "answer_id": 417447, "author": "annakata", "author_id": 13018, "author_profile": "https://Stackoverflow.com/users/13018", "pm_score": 2, "selected": false, "text": "^ ." }, { "answer_id": 417451, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https...
2009/01/06
[ "https://Stackoverflow.com/questions/417430", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
417,435
<p>I have a configuration XML file which contains an encrypted password. From time to time we need to reset this password, and the methodology for doing so involves stripping out the string which is effectively the password from the XML file and saving the file.</p> <p>The process also involves stopping and restarting a couple of services which I can manage, but I am yet to figure out a way of searching and replacing the string, as it can be different every time.</p> <p>I'd like to do this in VBS (because that's pretty much all I am familiar with in the scripting world) but am happy to consider doing it any other way.</p> <p>I have looked at the Replace function, but I am yet to find a way of putting a wildcard into the search criteria. I need to be able to search for:</p> <pre><code>&lt;A&gt;randomstuff&lt;/A&gt; </code></pre> <p>and replace with:</p> <pre><code>&lt;A&gt;&lt;/A&gt; </code></pre> <p>For those who may be familiar with the situation, I am resetting the password for Websense Enterprise Manager.</p> <p>The XML file appears to be v1.0:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; </code></pre> <p>Thanks. Tom</p>
[ { "answer_id": 421293, "author": "Tmdean", "author_id": 45084, "author_profile": "https://Stackoverflow.com/users/45084", "pm_score": 1, "selected": false, "text": "Set xml = CreateObject(\"Msxml2.DOMDocument.6.0\")\nxml.Load \"C:\\doc.xml\"\nSet password = xml.SelectSingleNode(\"//root/...
2009/01/06
[ "https://Stackoverflow.com/questions/417435", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
417,446
<p>I am storing objects in a buffer. Now I know that I cannot make assumptions about the memory layout of the object.</p> <p>If I know the overall size of the object, is it acceptible to create a pointer to this memory and call functions on it?</p> <p>e.g. say I have the following class:</p> <pre><code>[int,int,int,int,char,padding*3bytes,unsigned short int*] </code></pre> <p>1) if I know this class to be of size 24 and I know the address of where it starts in memory whilst it is not safe to assume the memory layout is it acceptible to cast this to a pointer and call functions on this object which access these members? (Does c++ know by some magic the correct position of a member?) </p> <p>2) If this is not safe/ok, is there any other way other than using a constructor which takes all of the arguments and pulling each argument out of the buffer one at a time?</p> <p>Edit: Changed title to make it more appropriate to what I am asking.</p>
[ { "answer_id": 417509, "author": "Eclipse", "author_id": 8701, "author_profile": "https://Stackoverflow.com/users/8701", "pm_score": 4, "selected": true, "text": "class Foo\n{\n int a;int b;int c;int d;char e;unsigned short int*f;\npublic:\n Foo(int A,int B,int C,int D,char E,unsig...
2009/01/06
[ "https://Stackoverflow.com/questions/417446", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16177/" ]
417,472
<p>I have an asp.net app and I am trying to save a text file to a folder that changes with each client. How can I write it to save the files to a folder that changes. For example one customer might be C:\inetpub\wwwroot\site1\ another might be C:\inetpub\wwwroot\site2. Relative paths don't seem to work, and I've tried GetCurrentDirectory but it kept giving me the wrong directory.</p> <p>Thanks</p>
[ { "answer_id": 417489, "author": "Sophie Alpert", "author_id": 49485, "author_profile": "https://Stackoverflow.com/users/49485", "pm_score": 0, "selected": false, "text": "Path.GetDirectoryName(Request.ServerVariables(\"SCRIPT_NAME\"))" }, { "answer_id": 417532, "author": "Ju...
2009/01/06
[ "https://Stackoverflow.com/questions/417472", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45429/" ]
417,480
<p>I am trying to write a JTextPane which supports some sort of coloring: as the user is typing the text, I am running some code that colors the text according to a certain algorithm. This works well.</p> <p>The problem is that the coloring operations is registered with the undo manager (a DefaultDocumentEvent with EventType.CHANGE). So when the user clicks undo the coloring disappears. Only at the second undo request the text itself is rolled back.</p> <p>(Note that the coloring algorithm is somewhat slow so I cannot color the text as it is being inserted).</p> <p>If I try to prevent the CHANGE events from reaching the undo manager I get an exception after several undo requests: this is because the document contents are not conforming to what the undoable-edit object expects.</p> <p>Any ideas?</p>
[ { "answer_id": 420685, "author": "Alan Moore", "author_id": 20938, "author_profile": "https://Stackoverflow.com/users/20938", "pm_score": 2, "selected": true, "text": "isSignificant() false JTextComponent View Document javax.swing.text" }, { "answer_id": 22397966, "author": "...
2009/01/06
[ "https://Stackoverflow.com/questions/417480", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27198/" ]
417,497
<p>I've got a hosted VPS hosted by a UK hosting company that for some reason is set to US settings. In fact, until recently, the regional settings were 'English - United States'. I've corrected the regional settings, but my application is still working with the wrong date format. See:</p> <p><a href="http://www.albaassoc.com/events/listevents.aspx" rel="noreferrer">http://www.albaassoc.com/events/listevents.aspx</a></p> <p>The default dates are supposed to be the current date to the date + 3 months, but as you can see, the dd and MM fields are swapped. Note: the AJAX calendar extender is manually set to dd/MM/yyyy so that is why the calendar pop thinks we are interested in June/July rather than January!</p> <p>I know there are various ways to set a page or an application to use a particular locale, but I'd rather go for a global approach.</p> <p>Is it possible to re-configure IIS to work in a different locale, or if not, can I tweak machine.config so that it is a once-only change?</p> <p>I've got a ticket open with the host but I'm not going to hold my breath - they aren't going to want to reinstall IIS...</p> <p>Thanks in advance.</p>
[ { "answer_id": 4241648, "author": "Chris", "author_id": 515535, "author_profile": "https://Stackoverflow.com/users/515535", "pm_score": 1, "selected": false, "text": "<globalization requestEncoding=\"utf-8\" responseEncoding=\"utf-8\" culture=\"en-GB\" />\n" }, { "answer_id": 22...
2009/01/06
[ "https://Stackoverflow.com/questions/417497", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6898/" ]
417,510
<h3>Question</h3> <hr /> <p>I'm trying to build a quick and easy ASP.NET page that redirects a user to a new URL using a meta redirect. Only trouble is that I need to also pass along the GET values of the current request. I've found a way to do this programatically in the code behind using the HtmlMeta object. However, I'd like to avoid using the code behind and just put this code directly into the ASPX page.</p> <p>Here is what I have so far:</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" &gt; &lt;head runat="server"&gt; &lt;title&gt;Untitled Page&lt;/title&gt; &lt;meta http-equiv="refresh" content='10;url=http://contact.test.net/main.aspx?&lt;%=Request.QueryString.ToString()%&gt;' /&gt; &lt;/head&gt; &lt;/html&gt; </code></pre> <p><br /> However, this spits out the following meta tag:</p> <pre><code>&lt;meta http-equiv="refresh" content="10;url=http://contact.test.net/main.aspx?&lt;%=Request.QueryString.ToString()%&gt;" /&gt; </code></pre> <p>So is there any way to escape the attribute so the ASP.NET code actually executes?</p> <h3>Solution 1</h3> <p><hr /> For the time being, I have fixed my problem by removing the quotes from the HTML attribute. Thus making the meta tag the following:</p> <pre> <code> &lt;meta http-equiv="refresh" content=10;url=http://contact.test.net/main.aspx?&lt;%=Request.QueryString.ToString()%&gt; /&gt; </code> </pre> <p><br /> Although this fixes the issue, I'd be curious if anyone knows of a more correct way to do it where I could escape the literal quotes of the HTML attribute. <br /><br /><br /></p> <h3>Solution 2 (Final Chosen Solution)</h3> <p><hr /> Per the much appreciated advise of Scott, I decided to go ahead and do this from the code behind. For anyone who is curious how this was implemented:</p> <pre> <code> Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim nRef As String = Request.QueryString("n") Dim sRef As String = Request.QueryString("s") Dim contentAttrBuilder As New StringBuilder("0;http://contact.cableone.net/main.aspx") contentAttrBuilder.Append("?n=") contentAttrBuilder.Append(nRef) contentAttrBuilder.Append("&s=") contentAttrBuilder.Append(sRef) Dim metaRedirect As New HtmlMeta() metaRedirect.HttpEquiv = "refresh" metaRedirect.Content = contentAttrBuilder.ToString() Me.Header.Controls.Add(metaRedirect) End Sub </code> </pre> <p>Thanks,<br /> Chris</p>
[ { "answer_id": 419118, "author": "Jorge Alves", "author_id": 6195, "author_profile": "https://Stackoverflow.com/users/6195", "pm_score": 3, "selected": true, "text": "<%= string.Format(\"<meta http-equiv='refresh' content='10;url=http://contact.test.net/main.aspx?{0}' />\", Request.Query...
2009/01/06
[ "https://Stackoverflow.com/questions/417510", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23869/" ]
417,517
<p>here is a rather newbie question, but it'll be very helpful if you give me some clues.</p> <p>I am running a Java application (with Gui). Every time I exit the Gui, the session (what I have done in the Gui) is saved, and next time when I start the Gui, the saved session is loaded. When I install the application in another directory, and run the executable file of the newly installed application, the saved session of the old application is loaded. Why does this happen? The applications are the same version, and have the same names, but I thought that when I start the executable file of the newly installed application, a freshly new session will start (and nothing about what I have done in the gui of the other application will be remembered). If I run the application for a second or n-th time, the previous application is saved, probably because there is an option the session to be saved, but why does this happen with the new executable file? </p> <p>Do I have to change/delete something somewhere in my computer in order this not to happen? (I am trying these things using windows machine).</p> <p>Regards</p>
[ { "answer_id": 418416, "author": "Miles D", "author_id": 3898, "author_profile": "https://Stackoverflow.com/users/3898", "pm_score": 1, "selected": false, "text": "SingleFrameApplication shutdown SingleFrameApplication @Override\nprotected void shutdown() {\n super.shutdown(); // rem...
2009/01/06
[ "https://Stackoverflow.com/questions/417517", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42155/" ]
417,549
<p>I have 100 million lines of data, the data is a word no longer than 15 chars,one word per line. Those data are stored in multiple files. </p> <p>My goal to to find the unique words among all files.</p> <p>One solution is to import all words into database and add a unique key for the field. but this is too slow for this large data set.</p> <p>Is there any faster solution? </p> <p>Thank you</p>
[ { "answer_id": 417570, "author": "Ben", "author_id": 11522, "author_profile": "https://Stackoverflow.com/users/11522", "pm_score": 3, "selected": true, "text": "cat * | sort | uniq\n" }, { "answer_id": 417732, "author": "Brent.Longborough", "author_id": 9634, "author_...
2009/01/06
[ "https://Stackoverflow.com/questions/417549", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52132/" ]
417,568
<p>I did some timing tests and also read some articles like <a href="http://www.cincomsmalltalk.com/userblogs/buck/blogView?showComments=true&amp;title=Smalltalk+performance+vs.+C%23&amp;entry=3354595110#3354595110" rel="noreferrer">this one</a> (last comment), and it looks like in Release build, float and double values take the same amount of processing time.</p> <p>How is this possible? When float is less precise and smaller compared to double values, how can the CLR get doubles into the same processing time?</p>
[ { "answer_id": 417591, "author": "P Daddy", "author_id": 36388, "author_profile": "https://Stackoverflow.com/users/36388", "pm_score": 8, "selected": true, "text": "float double float double float float" }, { "answer_id": 11467860, "author": "Bitterblue", "author_id": 144...
2009/01/06
[ "https://Stackoverflow.com/questions/417568", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51816/" ]
417,584
<p>I'm creating an app that I want to have an expandable set of properties (each a RatingProperty) I also want to validate that any dynamic properties are of the RatingProperty type. </p> <p>In the Expando documentation it says:</p> <blockquote> <p>Tip: If you want to validate a dynamic property value using a Property class, you can instantiate the Property class and call its validate() method on the value. </p> </blockquote> <p>So if I want to validate a dynamic property I need to know what the class's non-dynamic properties are. How can I ask my class what it's defined properties are?</p> <p>I've considered creating a class method that takes a string and returns true if that string is in a list of property names that I create and maintain, but it seems like a hack. I've searched the Google for tips, but haven't had any luck.</p> <p>Thanks, Pat</p>
[ { "answer_id": 418905, "author": "pat", "author_id": 46436, "author_profile": "https://Stackoverflow.com/users/46436", "pm_score": 1, "selected": false, "text": "test = db.RatingProperty()\nif test.validate(valueToSave):\n #do your thing\n if valueToSaveKey not in myObject.properties(...
2009/01/06
[ "https://Stackoverflow.com/questions/417584", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46436/" ]
417,590
<p>I have class B, which inherits from class A. The superclass A is abstract, containing one abstract method. I don't want to implement the abstract method in class B, therefore I need to declare class B as abstract as well. Declaring class B abstract, two things are working for me (the programs compile and run correctly):</p> <p>1.) I don't declare any abstract methods in class B, even thought the class is abstract. This works, I assume, because the class inherits the abstract method of class A, and this is enough for the class to be declared as abstract: we don't need any other abstract methods directly declared in the class.</p> <p>2.) I do declare the same abstract method in class B as it is declared in class A. This is some kind of overriding (?), not in the same sense as overriding in java (using the same header, but providing different implementation), here I just use again the same header of the method.</p> <p>Both things are working, and I am not sure whether they are both Ok, and whether some of them is preferred (more correct) that the other. Are the two ways the same (do they mean the same to Java)? </p> <p>Here I give some example classes, so that what I mean is more clear for you:</p> <p>Case 1.):</p> <pre><code>public abstract class A { public abstract String giveSum(); } public abstract class B extends A { } </code></pre> <p>Case 2.):</p> <pre><code>public abstract class A { public abstract String giveSum(); } public abstract class B extends A { public abstract String giveSum(); } </code></pre> <p>Regards</p>
[ { "answer_id": 417647, "author": "Jared", "author_id": 44757, "author_profile": "https://Stackoverflow.com/users/44757", "pm_score": 5, "selected": false, "text": "abstract abstract abstract abstract abstract abstract abstract" }, { "answer_id": 417787, "author": "Arne Burmei...
2009/01/06
[ "https://Stackoverflow.com/questions/417590", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42155/" ]
417,599
<p>I'm starting out with SVN. I know the basic commands and understand the base principles. I was wondering if anyone has any tips or best practices for working with Subversion in a team environment. </p> <p>I can see the benefit of adding reasonably verbose messages when committing code, but are there other things I should bear in mind?</p> <p><strong>Thanks for all the great answers - they've helped a lot.</strong></p>
[ { "answer_id": 8833530, "author": "altern", "author_id": 50962, "author_profile": "https://Stackoverflow.com/users/50962", "pm_score": 4, "selected": false, "text": "/trunk\n/tags\n /builds\n /PA\n /A\n /B\n /releases\n /AR\n /BR\n /RC\n ...
2009/01/06
[ "https://Stackoverflow.com/questions/417599", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32640/" ]
417,611
<p>I have seen several projects that use the Trace functionality to capture events and stream them out to a log file. I have been unsuccessful in finding a simple to follow guide that will show me how to configure Trace to capture and write said logfile. Does anyone have a link recommendations, or provide some simple steps to follow?</p>
[ { "answer_id": 417815, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 2, "selected": false, "text": "Trace TraceListeners System.Diagnostics TraceListener" } ]
2009/01/06
[ "https://Stackoverflow.com/questions/417611", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51949/" ]
417,632
<p>Using WCF in a RESTful way seems great. I’m a big fan of the big guns like simplicity and flexibility, but I also love the way the Urls end up looking. What can I say, I’m a programmer.</p> <p>The simple API for retrieving and editing resources is matched by an almost equally simple set of possible error responses, and I can’t help feeling that to keep to a “pure” RESTful approach I may be cutting my nose off to spite by face, or more specifically, the nose of my web service consumers. I could be wrong, but there doesn’t seem to be very many Http error codes that I can use, and no ways to pass back a custom error message.</p> <p>To clarify, I am talking about proper exceptional errors and not expected errors. I want to actually communicate a problem to the user to help them identify what they need to do to correct it.</p> <p>Possible options I am considering...</p> <ol> <li><p><strong>Just use the Http error codes</strong> – This seem like it would be too restrictive in what I am able to express, and won’t allow me to supply a custom message. Please(!) correct me if I am wrong.</p> </li> <li><p><strong>Always return Http Success but return custom error objects</strong> – Obviously the most flexible but certainly not the most RESTful.</p> </li> </ol> <p>I would really appreciate it if anyone could share some real world experience of this particular problem.</p> <hr /> <h3>Update</h3> <p>Thanks for the suggestion of using the <code>StatusDescription</code> property of the <code>OutgoingWebResponseContext</code> object. It seemed at first to be something that I could use.</p> <p>I have come to the conclusion that my second option above is not for me. I want to stick to the what Http can give me.</p> <p>I am having problems getting it to work, however. Regardless of the value I supply for this property, it doesn’t get returned in the response.</p> <p>My service method looks like this</p> <pre><code>public MyType GetMyTypes(string criteria) { try { return GetMyTypes(); } catch (Exception ex) { OutgoingWebResponseContext response = WebOperationContext.Current.OutgoingResponse; response.StatusCode = HttpStatusCode.Forbidden; response.StatusDescription = &quot;A Big fat error occurred&quot;; return null; } } </code></pre> <p>And here is the raw response message. There is no mention of the custom message...</p> <blockquote> <p>HTTP/1.1 403 Forbidden<br /> Server: ASP.NET Development Server/9.0.0.0<br /> Date: Wed, 07 Jan 2009 14:01:20 GMT<br /> X-AspNet-Version: 2.0.50727<br /> Cache-Control: private<br /> Content-Length: 0<br /> Connection: Close</p> </blockquote> <p>It's not as if I just need to access the correct property on the client. The information is simply not being sent across the link.</p> <p>What does this <code>StatusDescription</code> property actually do?</p> <hr /> <h3>Update</h3> <p>I never did find out how to set the StatusDescription property. I ended up not including any error message at all, and going solely with the Http status codes. I have chosen to expose both Soap and Restful endpoints for my services, and so clients can choose which they prefer to use – the simple Restful messages or the relatively richer Soap messages.</p>
[ { "answer_id": 417666, "author": "Crescent Fresh", "author_id": 45433, "author_profile": "https://Stackoverflow.com/users/45433", "pm_score": 2, "selected": false, "text": "OutgoingWebResponseContext response = WebOperationContext.Current.OutgoingResponse;\nresponse.StatusCode = System.N...
2009/01/06
[ "https://Stackoverflow.com/questions/417632", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3362/" ]
417,634
<p>I am having trouble with <a href="http://msdn.microsoft.com/en-us/library/ms182144.aspx" rel="noreferrer" title="FxCop warning CA1006">FxCop warning CA1006</a>, Microsoft.Design "DoNotNestGenericTypesInMemberSignatures". Specifically, I am designing a <code>ReportCollection&lt;T&gt;</code> class that inherits from <code>ReadOnlyCollection&lt;Report&lt;T&gt;&gt;</code>, and its <code>public</code> constructor takes an <code>IList&lt;Report&lt;T&gt;&gt;</code> as a parameter.</p> <p>The suggestion for fixing this warning is not very useful:</p> <blockquote> <p>"To fix a violation of this rule, change the design to remove the nested type argument." There are two ways I can see so far to change the design as suggested:</p> </blockquote> <ol> <li>Make the constructor <code>internal</code>. This doesn't work in my case. The constructor must be <code>public</code> because this collection class needs to be instantiable by code outside the assembly.</li> <li>Make the constructor take a <code>Report&lt;T&gt;[]</code> instead of an <code>IList&lt;Report&lt;T&gt;&gt;</code>. This is sub-optimal because external code should have the flexibility of using dynamically-sized data structures like <code>List&lt;T&gt;</code> instead of fixed-size arrays.</li> </ol> <p>At this point, I have given up and suppressed this warning. Is there a better solution?</p>
[ { "answer_id": 4252697, "author": "Darren", "author_id": 516950, "author_profile": "https://Stackoverflow.com/users/516950", "pm_score": 5, "selected": true, "text": "Func<IEnumerable<T>>\n" }, { "answer_id": 33124431, "author": "Roman Koshelev", "author_id": 3866271, ...
2009/01/06
[ "https://Stackoverflow.com/questions/417634", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3121/" ]
417,645
<p>Is there a way to convert variable names to strings in javascript? To be more specific:</p> <pre><code>var a = 1, b = 2, c = 'hello'; var array = [a, b, c]; </code></pre> <p>Now at some point as I go through the array, I need to get variable names (instead of their values) as strings - that would be 'a' or 'b' or 'c'. And I really need it to be a string so it is writeable. How can I do that?</p>
[ { "answer_id": 417652, "author": "Kenan Banks", "author_id": 43089, "author_profile": "https://Stackoverflow.com/users/43089", "pm_score": 6, "selected": true, "text": "var obj = {\n a: 1,\n b: 2,\n c: 'hello'\n};\n for (var key in obj){\n console.log(key, obj[key]);\n}\n con...
2009/01/06
[ "https://Stackoverflow.com/questions/417645", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2033475/" ]
417,648
<p>I've been using <a href="http://wakoopa.com" rel="nofollow noreferrer">Wakoopa</a> recently, and I find it quite amusing. </p> <p>I had no idea ( well I had an idea but never got real data about it ) on how much time I spend in SO until this:</p> <p><a href="http://img396.imageshack.us/img396/4699/wakoopaim1.png" rel="nofollow noreferrer">alt text http://img396.imageshack.us/img396/4699/wakoopaim1.png</a></p> <p>So my programming question is: </p> <blockquote> <p><em>How can I programmatically track the applications being used?</em> </p> </blockquote> <p>My initial though was to use something like "tasklist" command and "netstat" and pool every 15 minutes or something like that, but I don't think this is the way they're doing this. </p> <p>Is there a library in .NET ( in C# I guess ) to do this? Does windows provides some kind of service like this? What about java?</p> <p>I usually have at least some vague idea on how some programming task could be performed, but for this I don't have a clue. </p> <p>The wakoopa app tracker works on OSX and Linux too, but it is clear to me they are three different apps, one per platform </p> <p>BTW, how much do you used SO? :) </p>
[ { "answer_id": 417652, "author": "Kenan Banks", "author_id": 43089, "author_profile": "https://Stackoverflow.com/users/43089", "pm_score": 6, "selected": true, "text": "var obj = {\n a: 1,\n b: 2,\n c: 'hello'\n};\n for (var key in obj){\n console.log(key, obj[key]);\n}\n con...
2009/01/06
[ "https://Stackoverflow.com/questions/417648", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20654/" ]
417,657
<p>I have this legacy code that I am working with and there is code like this all over the place:</p> <pre> #If PRE611 = True Then 'Do Something #Else 'Something Else #End If </pre> <p>I am pretty sure the PRE611 has something to do with versioning, but I would like to know what specifically the # sign does. </p>
[ { "answer_id": 417670, "author": "George Stocker", "author_id": 16587, "author_profile": "https://Stackoverflow.com/users/16587", "pm_score": 0, "selected": false, "text": "PRE611" } ]
2009/01/06
[ "https://Stackoverflow.com/questions/417657", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42574/" ]
417,658
<p>How can i use Tomcat to serve image files from a public folder outside webapps? I dont want to use a 2nd Apache fileserver on a different port since the image files are part of the same app. And i dont want to create a symlink to the public folder inside webapps since my app is deployed as a war file....Is there a simpler solution similar to using default servlet for static content inside webapps, for static content outside outside webapps</p>
[ { "answer_id": 417695, "author": "sblundy", "author_id": 4893, "author_profile": "https://Stackoverflow.com/users/4893", "pm_score": 6, "selected": true, "text": "<servlet>\n <servlet-name>images</servlet-name>\n <servlet-class>com.example.images.ImageServlet</servlet-class>\n</ser...
2009/01/06
[ "https://Stackoverflow.com/questions/417658", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51402/" ]
417,665
<p>In my Flex application I call a web service that returns a few dozen "items" where each item has an associated image url. I create a model based on this data and bind the image components source property to the url string.</p> <p>I'd like to have more control over the loading of these images, particularly the order in which they are loaded. I'd also like to preload images that aren't necessarily bound to components yet. Essentially I'd like to load the images the user will see first, then load images in the background that they may see later.</p> <p>Is there a mechanism in Flex I can utilize to load images in the background?</p>
[ { "answer_id": 418549, "author": "Richard Haven", "author_id": 29420, "author_profile": "https://Stackoverflow.com/users/29420", "pm_score": 0, "selected": false, "text": "\n private var BackgroundLoaderIndex : int = -1;\n private var BackgroundImageLoader : Loader = null...
2009/01/06
[ "https://Stackoverflow.com/questions/417665", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36706/" ]
417,677
<p>I did the following to upper case the first letter in each word but it's only working on the first word. Could someone explain why?</p> <pre><code>static void Main(string[] args) { string s = "how u doin the dnt know about medri sho min shan ma baref shu"; string a = tocap(s); Console.WriteLine(a); } public static string tocap(string s) { if (s.Length == 1) return s.ToUpper(); string s1; string s2; s1 = s.Substring(0, 1).ToUpper(); s2 = s.Substring(1).ToLower(); return s1+s2; } </code></pre>
[ { "answer_id": 417681, "author": "Kenan Banks", "author_id": 43089, "author_profile": "https://Stackoverflow.com/users/43089", "pm_score": 3, "selected": false, "text": "string.split()" }, { "answer_id": 417716, "author": "OscarRyz", "author_id": 20654, "author_profil...
2009/01/06
[ "https://Stackoverflow.com/questions/417677", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
417,690
<p>When I call Server.CreateObject(), from my Classic ASP page, I get</p> <pre><code>Microsoft VBScript runtime (0x800A01B6) Object doesn't support this property or method </code></pre> <p>I've tried the following (separately):</p> <pre><code>Server.CreateObject("Microsoft.XMLHTTP") Server.CreateObject("MSXML2.XMLHTTP") Server.CreateObject("MSXML.DOMDocument") </code></pre> <p>I know the ActiveX objects are installed because the following javascript calls work</p> <pre><code>var test = new ActiveXObject("Microsoft.XMLHTTP"); var test = new ActiveXObject("MSXML2.XMLHTTP"); var test = new ActiveXObject("MSXML.DOMDocument"); </code></pre> <p>I'm calling it from my localhost IIS server. Any ideas how to troubleshoot this?</p>
[ { "answer_id": 417718, "author": "Roger Lipscombe", "author_id": 8446, "author_profile": "https://Stackoverflow.com/users/8446", "pm_score": 4, "selected": true, "text": "Dim x: x = Server.CreateObject(\"My.ProgID.Here\")\n Dim x: Set x = Server.CreateObject(\"My.ProgID.Here\")\n" } ]
2009/01/06
[ "https://Stackoverflow.com/questions/417690", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]