qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
214,441
<p>I would like to show a set of consecutive numbers in a UIPickerView component but have it wrap around like the seconds component of the Clock->Timer application. The only behavior I can enable looks like the hours component of the Timer application, where you can scroll in only one direction.</p>
[ { "answer_id": 221955, "author": "David", "author_id": 28275, "author_profile": "https://Stackoverflow.com/users/28275", "pm_score": 5, "selected": false, "text": "return [rows objectAtIndex:(row % [rows count])];\n" }, { "answer_id": 367436, "author": "squelart", "author...
2008/10/18
[ "https://Stackoverflow.com/questions/214441", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28275/" ]
214,491
<p>I'm working with a JavaScript API where most of the functions are asynchronous. The API is the <a href="http://webkit.org/blog/126/webkit-does-html5-client-side-database-storage/" rel="noreferrer">WebKit JavaScript Database API</a> which is a binding to a subset of functionality to manipulate SQLite3 databases. I understand the design decision to make things async as to not block and provide a responsive user interface. In my situation I know that my usage of the async API calls will execute fast. Since this is the case I'd like to provide my developers a cleaner and easier to use wrapper API that forces synchronous calls.</p> <p>Here's the async call</p> <pre><code>db.executeSql(sqlStatement, function(result) { // do something with result }); </code></pre> <p>And here's what I'd like to be able to do</p> <pre><code>var result = dbWrapper.executeSql(sqlStatement); // do something with result </code></pre> <p>Is there a design pattern/way to do this? A written or linked to code example is preferred. The target platform/broswer is Mobile Safari on the iPhone.</p> <p>Thank you</p>
[ { "answer_id": 214973, "author": "johnstok", "author_id": 27929, "author_profile": "https://Stackoverflow.com/users/27929", "pm_score": 1, "selected": false, "text": "callA(function(resultA) {\n callB(resultA, function(resultB) {\n callC(); //etc.\n });\n});\n" }, { ...
2008/10/18
[ "https://Stackoverflow.com/questions/214491", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29148/" ]
214,500
<p>LINQ is one of the greatest improvements to .NET since generics and it saves me tons of time, and lines of code. However, the fluent syntax seems to come much more natural to me than the query expression syntax.</p> <pre><code>var title = entries.Where(e =&gt; e.Approved) .OrderBy(e =&gt; e.Rating).Select(e =&gt; e.Title) .FirstOrDefault(); var query = (from e in entries where e.Approved orderby e.Rating select e.Title).FirstOrDefault(); </code></pre> <p>Is there any difference between the two or is there any particular benefit of one over other?</p>
[ { "answer_id": 214610, "author": "Jay Bazuzi", "author_id": 5314, "author_profile": "https://Stackoverflow.com/users/5314", "pm_score": 6, "selected": false, "text": "var titlesQuery = from e in entries\n where e.Approved\n orderby e.Rating\n ...
2008/10/18
[ "https://Stackoverflow.com/questions/214500", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16340/" ]
214,517
<p>The following Perl statements behave identically on Unixish machines. Do they behave differently on Windows? If yes, is it because of the magic \n?</p> <pre><code> split m/\015\012/ms, $http_msg; split m/\015\012/s, $http_msg; </code></pre> <p>I got a <a href="http://www.nntp.perl.org/group/perl.cpan.testers/2008/10/msg2450019.html" rel="nofollow noreferrer">failure</a> on one of my CPAN modules from a Win32 smoke tester. It looks like it's an \r\n vs \n issue. One change I made recently was to add //m to my regexes.</p>
[ { "answer_id": 214800, "author": "bart", "author_id": 19966, "author_profile": "https://Stackoverflow.com/users/19966", "pm_score": 5, "selected": true, "text": "m/\\015\\012/ms\nm/\\015\\012/s\n" }, { "answer_id": 215256, "author": "brian d foy", "author_id": 2766176, ...
2008/10/18
[ "https://Stackoverflow.com/questions/214517", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14783/" ]
214,536
<p>What are some good templating engines for web designers? I definitely have my preferences as to what I'd prefer to work with as a programmer. But web designers seem to have a different way of thinking about things and thus may prefer a different system.</p> <p>So:</p> <ul> <li>Web designers: what templating engine do you prefer to work with?</li> <li>programmers: what templating engines have you worked with that made working with web designers easy?</li> </ul>
[ { "answer_id": 214932, "author": "S.Lott", "author_id": 10661, "author_profile": "https://Stackoverflow.com/users/10661", "pm_score": 4, "selected": true, "text": "${...}" }, { "answer_id": 214956, "author": "nosklo", "author_id": 17160, "author_profile": "https://Sta...
2008/10/18
[ "https://Stackoverflow.com/questions/214536", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2147/" ]
214,537
<p>I just moved a project to the the beta release of <code>ASP.net MVC</code> framework and the only problem I am having is with <code>jQuery</code> and <code>jQueryUI</code>. </p> <p>Here's the deal:</p> <p>In <code>Site.Master</code> are the following script references:</p> <pre><code>&lt;script src="../../Scripts/jquery-1.2.6.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="../../Scripts/jquery-ui.js" type="text/javascript"&gt;&lt;/script&gt; </code></pre> <p>And using those, the <code>accordian UI</code> that I have on one of the views works perfectly, except for one problem: the images from <code>ThemeRoller</code> aren't included on the page. If I comment out the jQuery references, the ThemeRoller images are there. All of the css is in the <code>Content folder</code> and all of the scripts are in the <code>Scripts folder</code>.</p> <p>I know this is a silly path problem, but it's making me twitch.</p> <p>What am I missing?</p> <p><strong>Update</strong></p> <p>I tried the first answer to no avail, read the comment for details. Thanks again for those who are viewing. </p> <p>The second approach is not working either. I'm baffled.</p> <p><strong>Another Update</strong></p> <p>Using the <code>Url.Content</code> tags for the scripts does indeed allow the scripts to run properly. Using a regular tag for the stylesheet gets all of the styles onto the page EXCEPT for all of those related to ThemeRoller. </p> <p>The <code>jquery-ui-themeroller.css</code> file is in the Content folder and when I inspect an element, the css is present. I suspect the problem is in the mapping from this css file to the images folder for the themeroller, which is in the Content folder as well. Image links in this file as specified as: <code>background: url(images/foo.gif)</code></p> <p>Do the links in this file need to change? </p>
[ { "answer_id": 215395, "author": "Adhip Gupta", "author_id": 384, "author_profile": "https://Stackoverflow.com/users/384", "pm_score": 0, "selected": false, "text": "background: url(images/foo.gif)\n" }, { "answer_id": 656066, "author": "chris", "author_id": 79203, "a...
2008/10/18
[ "https://Stackoverflow.com/questions/214537", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13139/" ]
214,549
<p>On the Python side, I can create new numpy record arrays as follows:</p> <pre><code>numpy.zeros((3,), dtype=[('a', 'i4'), ('b', 'U5')]) </code></pre> <p>How do I do the same from a C program? I suppose I have to call <code>PyArray_SimpleNewFromDescr(nd, dims, descr)</code>, but how do I construct a <code>PyArray_Descr</code> that is appropriate for passing as the third argument to <code>PyArray_SimpleNewFromDescr</code>?</p>
[ { "answer_id": 214574, "author": "Adam Rosenfield", "author_id": 9530, "author_profile": "https://Stackoverflow.com/users/9530", "pm_score": 3, "selected": false, "text": "[('a', 'i4'), ('b', 'U5')]" }, { "answer_id": 215090, "author": "Vebjorn Ljosa", "author_id": 17498,...
2008/10/18
[ "https://Stackoverflow.com/questions/214549", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17498/" ]
214,553
<p>When I enable common control visual style support (InitCommonControls()) and I am using any theme other then Windows Classic Theme, buttons inside a group box appear with a black border with square corners. </p> <p>Windows Classic Theme appears normal, as well as when I turn off visual styling.</p> <p>I am using the following code:</p> <pre><code>group_box = CreateWindow(TEXT("BUTTON"), TEXT("BS_GROUPBOX"), WS_CHILD | WS_VISIBLE | BS_GROUPBOX | WS_GROUP, 10, 10, 200, 300, hwnd, NULL, hInstance, 0); push_button = CreateWindow(TEXT("BUTTON"), TEXT("BS_PUSHBUTTON"), WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 40, 40, 100, 22, group_box, NULL, hInstance, 0); </code></pre> <p>EDIT: The issue occurs with radio buttons as well</p> <p>EDIT: I am not using any dialogs/resources, only CreateWindow/Ex. </p> <p>I am compiling under Visual C++ 2008 Express SP1, with a generic <a href="http://msdn.microsoft.com/en-us/library/ms997646.aspx" rel="nofollow noreferrer">manifest</a> file</p> <p><a href="http://img.ispankcode.com/black_border_issue.png" rel="nofollow noreferrer">Screenshot http://img.ispankcode.com/black_border_issue.png</a></p>
[ { "answer_id": 214685, "author": "SmacL", "author_id": 22564, "author_profile": "https://Stackoverflow.com/users/22564", "pm_score": 1, "selected": false, "text": "WS_EX_STATICEDGE, WS_EX_WINDOWEDGE and WS_EX_CLIENTEDGE" }, { "answer_id": 296594, "author": "efotinis", "au...
2008/10/18
[ "https://Stackoverflow.com/questions/214553", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2067/" ]
214,568
<p>Is there a good way to add a .swf programatically to a panel on an asp.net page - ie: I know i could just insert the html tags:</p> <p>ie: </p> <pre><code>&lt;object type="application/x-shockwave-flash" data="yourflash.swf" width="" height=""&gt; &lt;param name="movie" value="yourflash.swf"&gt; &lt;/object&gt; </code></pre> <p>But is there an existing .net or free FLASH component already that you just set the properties on, or do i need to create a custom web control myself (not preferred) so i dont have to continously do this?</p> <p>Thank you. </p>
[ { "answer_id": 214685, "author": "SmacL", "author_id": 22564, "author_profile": "https://Stackoverflow.com/users/22564", "pm_score": 1, "selected": false, "text": "WS_EX_STATICEDGE, WS_EX_WINDOWEDGE and WS_EX_CLIENTEDGE" }, { "answer_id": 296594, "author": "efotinis", "au...
2008/10/18
[ "https://Stackoverflow.com/questions/214568", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26685/" ]
214,583
<p>In the default asp.net mvc project, in the Site.Master file, there is a menu navigation list:</p> <pre><code>&lt;div id="menucontainer"&gt; &lt;ul id="menu"&gt; &lt;li&gt;&lt;%= Html.ActionLink("Home", "Index", "Home")%&gt;&lt;/li&gt; &lt;li&gt;&lt;%= Html.ActionLink("About Us", "About", "Home")%&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre> <p>This renders in the browser to:</p> <pre><code>&lt;div id="menucontainer"&gt; &lt;ul id="menu"&gt; &lt;li&gt;&lt;a href="/"&gt;Home&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="/Home/About"&gt;About Us&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre> <p>I want to be able to dynamically set the active list item, based on the view that is being called. That is, when the user is looking at the home page, I would want the following HTML to be created:</p> <pre><code>&lt;div id="menucontainer"&gt; &lt;ul id="menu"&gt; &lt;li class="active"&gt;&lt;a href="/"&gt;Home&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="/Home/About"&gt;About Us&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre> <p>I would expect that the way to do this would be something like:</p> <pre><code>&lt;div id="menucontainer"&gt; &lt;ul id="menu"&gt; &lt;li &lt;% if(actionName == "Index"){%&gt; class="active"&lt;%}%&gt;&gt;&lt;%= Html.ActionLink("Home", "Index", "Home")%&gt;&lt;/li&gt; &lt;li &lt;% if(actionName == "About"){%&gt; class="active"&lt;%}%&gt;&gt;&lt;%= Html.ActionLink("About Us", "About", "Home")%&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre> <p>The key bit here is the <code>&lt;% if(actionName == "Index"){%&gt; class="active"&lt;%}%&gt;</code> line. I do not know how to determine what the current actionName is.</p> <p>Any suggestions on how to do this? Or, if I'm on completely the wrong track, is there a better way to do this?</p>
[ { "answer_id": 215385, "author": "Jason Whitehorn", "author_id": 27860, "author_profile": "https://Stackoverflow.com/users/27860", "pm_score": 0, "selected": false, "text": "public ActionResult Index(){\n ViewData[\"currentAction\"] = \"Index\";\n //... other code\n return Vie...
2008/10/18
[ "https://Stackoverflow.com/questions/214583", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29092/" ]
214,590
<p>I'm looking for something that will let me parse Atom and RSS in Ruby and Rails. I've looked at the standard RSS library, but is there one library that will auto-detect whatever type of feed it is and parse it for me?</p>
[ { "answer_id": 214611, "author": "Pistos", "author_id": 28558, "author_profile": "https://Stackoverflow.com/users/28558", "pm_score": 4, "selected": false, "text": "require 'simple-rss'\nrequire 'open-uri'\nrss = SimpleRSS.parse open('http://slashdot.org/index.rdf')\nrss.channel.title # ...
2008/10/18
[ "https://Stackoverflow.com/questions/214590", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4322/" ]
214,622
<p>I have a webservice, which takes java.lang.object objects as parameters (because at runtime only know hte type of object)...after doing process, reply response setting java.lang.Object to it.</p> <p>I am able to send the reuest objects to webservice from calling program, but getting NotSerializable exception while building the response from webservice.</p> <p>I came to know that 'if we implement, java.io.serializable, the mebmers also should be serializable objects'... here Object isnot a serializable object..it doesn't impllement Serializable....</p> <p>If anyone could guide mw with right solution..I wouold be thankful.</p> <p>Thanks Bhaskar</p>
[ { "answer_id": 214813, "author": "myplacedk", "author_id": 28683, "author_profile": "https://Stackoverflow.com/users/28683", "pm_score": 1, "selected": false, "text": "private void writeObject(java.io.ObjectOutputStream out) throws IOException;\nprivate void readObject(java.io.ObjectInpu...
2008/10/18
[ "https://Stackoverflow.com/questions/214622", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
214,640
<p>It's just so much <code>HRESULT E_FAIL</code>, if you know what I'm talking about. </p> <p>And if you use Visual Studio, you know what I'm talking about.</p> <p>Similar thread, but not a duplicate: <a href="https://stackoverflow.com/questions/196001/is-the-design-view-for-aspx-pages-in-visual-studio-useful">Is the design view for aspx pages in Visual Studio useful?</a></p> <p>Any insight, including input from Microsoft MVPs (oh, I know you're out there) would be super cool.</p>
[ { "answer_id": 3284130, "author": "ItsPronounced", "author_id": 355754, "author_profile": "https://Stackoverflow.com/users/355754", "pm_score": -1, "selected": false, "text": "masterpages" }, { "answer_id": 21383444, "author": "Suhaib Janjua", "author_id": 3240038, "a...
2008/10/18
[ "https://Stackoverflow.com/questions/214640", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13578/" ]
214,642
<p>I know it's by design that you can't control what happens when an object is destroyed. I am also aware of defining some class method as a finalizer.</p> <p>However is the ruby idiom for C++'s RAII (Resources are initialized in constructor, closed in destructor)? How do people manage resources used inside objects even when errors or exceptions happen?</p> <p>Using <em>ensure</em> works:</p> <pre><code>f = File.open("testfile") begin # .. process rescue # .. handle error ensure f.close unless f.nil? end </code></pre> <p>but users of the class <strong>have to remember to do the whole begin-rescue-ensure chacha</strong> everytime the open method needs to be called. </p> <p>So for example, I'll have the following class:</p> <pre><code>class SomeResource def initialize(connection_string) @resource_handle = ...some mojo here... end def do_something() begin @resource_handle.do_that() ... rescue ... ensure end def close @resource_handle.close end end </code></pre> <p>The resource_handle won't be closed if the exception is cause by some other class and the script exits.</p> <p>Or is the problem more of I'm still doing this too C++-like?</p>
[ { "answer_id": 214648, "author": "John Millikin", "author_id": 3560, "author_profile": "https://Stackoverflow.com/users/3560", "pm_score": -1, "selected": false, "text": "ensure" }, { "answer_id": 214663, "author": "bk1e", "author_id": 8090, "author_profile": "https:/...
2008/10/18
[ "https://Stackoverflow.com/questions/214642", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26374/" ]
214,644
<p>I have two windows services running on the same machine. Both the services uses</p> <p>private HttpListener listener;</p> <p>I specify the baseURL as "<a href="http://IPAddress:8080/" rel="noreferrer">http://IPAddress:8080/</a>" &amp; "<a href="http://IPAddress:8081/" rel="noreferrer">http://IPAddress:8081/</a>" respectively for each of the services. Then I do the needful and call</p> <p>listener.Start();</p> <p>The first service starts successfully at 8080 port. But when I now start the 2nd service, I get HTTPListenerException "The process cannot access the file because it is being used by another process" for listener object.</p> <p>Could anybody please tell me: 1) If it is possible to start two HTTP listeners on the same IIS at two different ports. 2) If yes, how can we achecive this? 3) Is there any other way of doing this?</p> <p>For your information: I am using C#.NET 2.0 and IIS 6.0 server.</p> <p>Thanks &amp; Regards,</p> <p>Hari</p>
[ { "answer_id": 214754, "author": "s3v1", "author_id": 17554, "author_profile": "https://Stackoverflow.com/users/17554", "pm_score": 2, "selected": false, "text": "String[] prefixes = { \"http://localhost:8280/\", \"http://localhost:8281/\"};\n\nHttpListener listener = new HttpListener();...
2008/10/18
[ "https://Stackoverflow.com/questions/214644", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
214,645
<p>Is there a clever way of adding XML serialization instructions without modifying the serialized class?</p> <p>I don’t like the default serialization and I can’t modify the class. I was considering inheriting the class, and using Shadows (VB.NET) to re-implement the properties (with the serialization instructions), but it results in a lot of duplicate code and just looks terrible.</p> <p>The ideal solution I'm looking for is basically a method to keep all the serialization instructions in a separate file.</p>
[ { "answer_id": 214673, "author": "benPearce", "author_id": 4490, "author_profile": "https://Stackoverflow.com/users/4490", "pm_score": 0, "selected": false, "text": "PropertyInfo[] properties = control.GetType().GetProperties();\nforeach (PropertyInfo property in properties)\n{\n object...
2008/10/18
[ "https://Stackoverflow.com/questions/214645", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10932/" ]
214,661
<p>Essentially what I want is a BlockingQueue of size=1. I have a "listener" thread that simply waits, blocking until an object is put into the queue, and then retrieves it--and a "producer" thread that actually puts the object into the queue.</p> <p>I can implement this with some synchronized blocks and a BlockingQueue implementation, but that seems like overkill. Is there a better, simpler way to do what I want?</p> <p>Example interface:</p> <pre><code>public interface Wait&lt;T&gt; { /** * If "put" has never been called on this object, then this method will * block and wait until it has. Once "put" has been called with some T, this * method will return that T immediately. */ public T get() throws InterruptedException; /** * @param object The object to return to callers of get(). If called more * than once, will throw an {@link IllegalStateException}. */ public void put(T object); } </code></pre>
[ { "answer_id": 214673, "author": "benPearce", "author_id": 4490, "author_profile": "https://Stackoverflow.com/users/4490", "pm_score": 0, "selected": false, "text": "PropertyInfo[] properties = control.GetType().GetProperties();\nforeach (PropertyInfo property in properties)\n{\n object...
2008/10/18
[ "https://Stackoverflow.com/questions/214661", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29173/" ]
214,688
<p>Apparently, they're "confusing". Is that seriously the reason? Can you think of any others?</p>
[ { "answer_id": 215371, "author": "Cristian Libardo", "author_id": 16526, "author_profile": "https://Stackoverflow.com/users/16526", "pm_score": -1, "selected": false, "text": "int myValue;\nReadFromSomewhere(ref myValue);\n" }, { "answer_id": 215918, "author": "user23117", ...
2008/10/18
[ "https://Stackoverflow.com/questions/214688", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18658/" ]
214,700
<p>In the following case I'm calling a <code>Func</code> with pointer passed to it, but in the called function, the parameter shows the pointer value as something totally bogus. Something like below.</p> <pre><code>bool flag = Func(pfspara);--&gt; pfspara = 0x0091d910 bool Func(PFSPARA pfspara) --&gt; pfspara = 0x00000005 { return false; } </code></pre> <p>Why does <code>pfspara</code> change to some bogus pointer? I can't reproduce the problem in debug, only in production.</p> <p>Thanks.</p>
[ { "answer_id": 214711, "author": "Rasmus Faber", "author_id": 5542, "author_profile": "https://Stackoverflow.com/users/5542", "pm_score": 3, "selected": false, "text": "bool Func(PFSPARA pfspara)\n{\n printf(\"%x\\n\", pfspara);\n return false;\n}\n" } ]
2008/10/18
[ "https://Stackoverflow.com/questions/214700", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13432/" ]
214,714
<p>I'm trying to get my head around mutable vs immutable objects. Using mutable objects gets a lot of bad press (e.g. returning an array of strings from a method) but I'm having trouble understanding what the negative impacts are of this. What are the best practices around using mutable objects? Should you avoid them whenever possible?</p>
[ { "answer_id": 214718, "author": "Daniel Spiewak", "author_id": 9815, "author_profile": "https://Stackoverflow.com/users/9815", "pm_score": 9, "selected": true, "text": "Person" }, { "answer_id": 18922685, "author": "supercat", "author_id": 363751, "author_profile": "...
2008/10/18
[ "https://Stackoverflow.com/questions/214714", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6651/" ]
214,722
<p>I'm using the contentEditable attribute on a DIV element in Firefox 3.03. Setting it to true allows me to edit the text content of the DIV, as expected.</p> <p>Then, when I set contentEditable to "false", the div is no longer editable, also as expected. </p> <p>However the flashing caret (text input cursor) remains visible even though the text is no longer editable. The caret is now also visible when I click on most other text in the same page, even in normal text paragraphs.</p> <p>Has anyone seen this before? Is there any way to force the caret hidden? </p> <p>(When I either resize the browser or click within another application, and come back, the caret magically disappears.)</p>
[ { "answer_id": 215170, "author": "Borgar", "author_id": 27388, "author_profile": "https://Stackoverflow.com/users/27388", "pm_score": 4, "selected": true, "text": "if ($.browser.mozilla) { // replace with browser detection of your choice\n window.getSelection().removeAllRanges();\n}\n" ...
2008/10/18
[ "https://Stackoverflow.com/questions/214722", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5023/" ]
214,730
<p>I'm creating a gem which has</p> <ul> <li>several scripts in the bin directory</li> <li>the utility classes in the lib directory</li> <li>and several tests in the test directory</li> </ul> <pre> supertool bin toolA toolB lib supertool supertool.rb helper.rb test tc_main.rb tc_etc.rb </pre> <p>Now, to run the tests before I even install the gem, I have the following snippet at the top of my tests:</p> <pre><code>base = File.basename(Dir.pwd) if base == 'test' || base =~ /supertool/ Dir.chdir('..') if base == 'test' $LOAD_PATH.unshift(Dir.pwd + '/lib') Dir.chdir('test') if base =~ /supertool/ end </code></pre> <p>This seems tedious though, especially if I have to put these in the scripts in the bin directory too. Is there a better way of setting up the environment so we can test gems before they are installed? I'm sure it's something simple that I just can't find. A simple link to the right place would help a lot :)</p>
[ { "answer_id": 259783, "author": "Orion Edwards", "author_id": 234, "author_profile": "https://Stackoverflow.com/users/234", "pm_score": 3, "selected": true, "text": "ruby tc_main.rb" } ]
2008/10/18
[ "https://Stackoverflow.com/questions/214730", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26374/" ]
214,741
<p>What is a <code>StackOverflowError</code>, what causes it, and how should I deal with them?</p>
[ { "answer_id": 214756, "author": "Khoth", "author_id": 20686, "author_profile": "https://Stackoverflow.com/users/20686", "pm_score": 6, "selected": false, "text": "int foo()\n{\n // more stuff\n foo();\n}\n" }, { "answer_id": 11531095, "author": "Vikram", "author_id...
2008/10/18
[ "https://Stackoverflow.com/questions/214741", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29182/" ]
214,746
<p>I am writing an .NET wrapper API for the Netflix API.</p> <p>At this point I can choose to represent URLs as either strings or URI objects. Seems to me there is a good case for both.</p> <p>So if you were using an API, which would you prefer?</p>
[ { "answer_id": 214801, "author": "Domenic", "author_id": 3191, "author_profile": "https://Stackoverflow.com/users/3191", "pm_score": 0, "selected": false, "text": "string" } ]
2008/10/18
[ "https://Stackoverflow.com/questions/214746", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5274/" ]
214,748
<p>Please bear with me here, I'm a student and new to Java Server Pages. If I'm being a complete idiot, can someone give me a good link to a tutorial on JSP, since I've been unable to find info on this anywhere. </p> <p>Okay, here goes... </p> <p>I'm using Netbeans and trying to pass an object that connects to a database between the pages, otherwise I'd have to reconnect to the database every time a new page is displayed. </p> <p>Using Netbeans, you can view each page as "jsp", in "design" view, or view the Java code. In the Java code is the class that extends an AbstractPageBean. The problem is that I'd like to pass parameters, but there is no object representing the class and so I can't just access the instance variables. </p> <p>Can anyone tell me how to do this? </p>
[ { "answer_id": 214835, "author": "extraneon", "author_id": 24582, "author_profile": "https://Stackoverflow.com/users/24582", "pm_score": 3, "selected": true, "text": "public class FooRepo {\n public static Foo getFoo(Long id) {\n // Read resultSet into foo\n }\n }\n" } ]
2008/10/18
[ "https://Stackoverflow.com/questions/214748", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25280/" ]
214,764
<p>In my Java development I have had great benefit from the <a href="http://en.wikipedia.org/wiki/JAD_%28JAva_Decompiler%29" rel="noreferrer">Jad/JadClipse</a> decompiler. It made it possible to <em>know</em> why a third-party library failed rather than the usual guesswork.</p> <p>I am looking for a similar setup for C# and Visual Studio. That is, a setup where I can point to any class or variable in my code and get a code view for that particular class.</p> <p>What is the best setup for this? I want to be able to use the usual "jump to declaration/implementation" that I use to navigate my own code. It doesn't <em>have</em> to be free, but it would be a bonus if it was.</p> <p>It should support Visual&nbsp;Studio&nbsp;2008 or Visual&nbsp;Studio&nbsp;2005 and .NET 2 and 3(.5).</p>
[ { "answer_id": 214784, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 1, "selected": false, "text": "bin" }, { "answer_id": 214788, "author": "splattne", "author_id": 6461, "author_profile": "https:...
2008/10/18
[ "https://Stackoverflow.com/questions/214764", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24610/" ]
214,777
<p>For example, I'm trying to convert 2008-09-26T01:51:42.000Z to 09/26/2008. What's the simplest way of accomplishing this?</p>
[ { "answer_id": 214786, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 5, "selected": false, "text": ">>> import time\n>>> timestamp = \"2008-09-26T01:51:42.000Z\"\n>>> ts = time.strptime(timestamp[:19], \"%Y-%m-%dT%H:%M:%S...
2008/10/18
[ "https://Stackoverflow.com/questions/214777", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10708/" ]
214,825
<p>My colleague insists on explicitly specifying the namespace in code as opposed to using the <a href="http://msdn.microsoft.com/en-us/library/sf0df423.aspx" rel="noreferrer">using directive</a>. In other words he wants to use the fully qualified name for each type every time this type occurs in code. Something like </p> <pre><code>public class MyClass { public static void Main() { System.Console.WriteLine("Foo"); } } </code></pre> <p>instead of:</p> <pre><code>using System; public class MyClass { public static void Main() { Console.WriteLine("Foo"); } } </code></pre> <p>You can imagine the consequences.</p> <p>The pros he gives: </p> <ol> <li>It's simpler to copy and paste code into other source files. </li> <li>It is more readable (you see the namespaces right away). </li> </ol> <p>My cons:</p> <ol> <li>I have to write more </li> <li>The code is less readable (I guess de gustibus non disputandum est) </li> <li>No one does it! </li> </ol> <p>What do you think about this?</p>
[ { "answer_id": 214827, "author": "gimel", "author_id": 6491, "author_profile": "https://Stackoverflow.com/users/6491", "pm_score": 0, "selected": false, "text": "Law of Demeter" }, { "answer_id": 214828, "author": "Jesper Blad Jensen", "author_id": 11559, "author_prof...
2008/10/18
[ "https://Stackoverflow.com/questions/214825", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28722/" ]
214,843
<p>I have two projects in CPP. One defines a function which I'd like to invoke from the other. I added a reference to the first project. I still get the message of "identifier not found". Assuming that the CPP file in the first project doesn't have a header, how do I make the second project know about its functions?</p>
[ { "answer_id": 214846, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 1, "selected": false, "text": "extern" }, { "answer_id": 216307, "author": "Nathan Fellman", "author_id": 1084, "author_profile": "h...
2008/10/18
[ "https://Stackoverflow.com/questions/214843", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
214,850
<p>What is the best solution to sanitize output HTML in Rails (to avoid XSS attacks)?</p> <p>I have two options: white_list plugin or sanitize method from Sanitize Helper <a href="http://api.rubyonrails.com/classes/ActionView/Helpers/SanitizeHelper.html" rel="nofollow noreferrer">http://api.rubyonrails.com/classes/ActionView/Helpers/SanitizeHelper.html</a> . For me until today the white_list plugin worked better and in the past, Sanitize was very buggy, but as part of the Core, probably it will be under development and be supported for a while.</p>
[ { "answer_id": 237778, "author": "derfred", "author_id": 10286, "author_profile": "https://Stackoverflow.com/users/10286", "pm_score": 2, "selected": true, "text": "<%= h @user.profile %>\n" }, { "answer_id": 239336, "author": "Gareth", "author_id": 31582, "author_pro...
2008/10/18
[ "https://Stackoverflow.com/questions/214850", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18642/" ]
214,852
<p>Is there a way to make a python module load a dll in my application directory rather than the version that came with the python installation, without making changes to the python installation (which would then require I made an installer, and be careful I didn't break other apps for people by overwrting python modules and changing dll versions globaly...)?</p> <p>Specifically I would like python to use my version of the sqlite3.dll, rather than the version that came with python (which is older and doesn't appear to have the fts3 module).</p>
[ { "answer_id": 214855, "author": "André", "author_id": 9683, "author_profile": "https://Stackoverflow.com/users/9683", "pm_score": 0, "selected": false, "text": "PYTHONPATH" }, { "answer_id": 214868, "author": "Glyph", "author_id": 13564, "author_profile": "https://St...
2008/10/18
[ "https://Stackoverflow.com/questions/214852", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6266/" ]
214,862
<p>I have an Internet Explorer only web application.</p> <p>I'm exploring what we can do to automate the testing. </p> <p>Selenium looks like a good tool, but to be able to activate links etc. I need to tell it where they are. The application wasn't built with this kind of testing in mind, so there generally aren't <code>id</code> attributes on the key elements.</p> <p>No problem, I think, I can use XPath expressions. But finding the correct XPath for, say, a button, is a royal pain if done by inspecting the source of the page.</p> <p>With Firefox / Firebug, I can select the element then use "Copy XPath" to get the expression.</p> <p>I have the IE Developer Toolbar and it's frustratingly close. I can click to select the element of interest and display all sorts of information about it. but I can't see any convenient way of determining the XPath for it.</p> <p>So is there any way of doing this with IE?</p>
[ { "answer_id": 215091, "author": "PhiLho", "author_id": 15459, "author_profile": "https://Stackoverflow.com/users/15459", "pm_score": 4, "selected": true, "text": "function getNode(node)\n{\n var nodeExpr = node.tagName;\n if (nodeExpr == null) // Eg. node = #text\n return null;\n ...
2008/10/18
[ "https://Stackoverflow.com/questions/214862", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21755/" ]
214,881
<p>Can you add new statements (like <code>print</code>, <code>raise</code>, <code>with</code>) to Python's syntax?</p> <p>Say, to allow..</p> <pre><code>mystatement "Something" </code></pre> <p>Or,</p> <pre><code>new_if True: print "example" </code></pre> <p>Not so much if you <em>should</em>, but rather if it's possible (short of modifying the python interpreters code)</p>
[ { "answer_id": 215042, "author": "dbr", "author_id": 745, "author_profile": "https://Stackoverflow.com/users/745", "pm_score": 2, "selected": false, "text": "Python/ast.c" }, { "answer_id": 215697, "author": "Brian", "author_id": 9493, "author_profile": "https://Stack...
2008/10/18
[ "https://Stackoverflow.com/questions/214881", "https://Stackoverflow.com", "https://Stackoverflow.com/users/745/" ]
214,884
<p>I have a class on which I want to allow several (~20+) configuration options. Each option turns on or off a piece of functionality, or otherwise alters operations. To facilitate this, I coded a separate options class with default values. However, I had to litter my code with guard conditions to determine how methods should behave. I am almost done, but now the code seems to smell.</p> <p>Is there a preferred method/pattern to implement a class like this?</p> <p><strong>EDIT:</strong> More specifically, I am working on a parsing class. Each option configures mutually exclusive portions of the basic parsing algorithm. For example I have several areas in my class that look like the below:</p> <pre><code> if (this.Option.UseIdAttribute) attributeIDs = new Hashtable(); else attributeIDs = null; public Element GetElementById(string id) { if (string.IsNullOrEmpty (id)) throw new ArgumentNullException("id"); if (attributeIDs == null) throw new Exception(ExceptionUseIdAttributeFalse); return attributeIDs[id.ToLower()] as Element; } </code></pre>
[ { "answer_id": 214949, "author": "extraneon", "author_id": 24582, "author_profile": "https://Stackoverflow.com/users/24582", "pm_score": 0, "selected": false, "text": " public class MyClass {\n\n interface Command {\n void execute(int a);\n }\n\n static class DoThisSimpleCommand im...
2008/10/18
[ "https://Stackoverflow.com/questions/214884", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14484/" ]
214,886
<p>I want to keep my website/s in version control (Subversion specifically) and use <code>svn co</code> to update it when there are stable versions to update, but I'm concerned about the security of doing so, as all the <code>.svn</code> folders will be public, and these include all sorts of private data, not least of which is complete source code to my website! </p> <p>Is there anything I can I do to prevent this?</p>
[ { "answer_id": 214887, "author": "Matthew Scharley", "author_id": 15537, "author_profile": "https://Stackoverflow.com/users/15537", "pm_score": 3, "selected": false, "text": ".htaccess" }, { "answer_id": 214908, "author": "Vinko Vrsalovic", "author_id": 5190, "author_...
2008/10/18
[ "https://Stackoverflow.com/questions/214886", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15537/" ]
214,891
<p>Please write a list of tasks that a copy constructor and assignment operator need to do in C++ to keep exception safety, avoid memory leaks etc. </p>
[ { "answer_id": 214925, "author": "Nazgob", "author_id": 3579, "author_profile": "https://Stackoverflow.com/users/3579", "pm_score": -1, "selected": false, "text": "Array(const Array& rhs)\n {\n mData = NULL;\n mSize = rhs.size();\n *this = rhs;\n }\n\n Array...
2008/10/18
[ "https://Stackoverflow.com/questions/214891", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1640962/" ]
214,899
<p>Is it possible, with Javascript or some other technology to determine which hyperlink a user has clicked on, without changing the hyperlink source code.</p> <p>For example: Can you click on a 'tag' button, then click on a hyperlink hosted in a different iframe, and be able to calculate which hyperlink the user clicked on, without changing any of the source code in that iframe?</p>
[ { "answer_id": 214962, "author": "bobince", "author_id": 18936, "author_profile": "https://Stackoverflow.com/users/18936", "pm_score": 0, "selected": false, "text": "<iframe id=\"framedpage\" src=\"framedpage.html\"></iframe>\n<button type=\"button\" id=\"tagbutton\">Tag</button>\n<scrip...
2008/10/18
[ "https://Stackoverflow.com/questions/214899", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13911/" ]
214,903
<p>I have a small command line program that uses the Team System API. When the correct Team System isn't installed on the machine, the program prints a traceback with System.IO.FileNotFoundException, but it also <strong>crashes</strong> and shows the standard error messasge:</p> <blockquote> <p>XXX has encountered a problem and needs to close. We are sorry for the inconvenience.</p> </blockquote> <p>I just want my program to print a "The program requires Team System 2008" message to the console and quit without crashing.</p> <p>From what I understand this whole loading process is happening before the first line of my C# code is run. Is there any way to control this?</p>
[ { "answer_id": 214921, "author": "Joe", "author_id": 13087, "author_profile": "https://Stackoverflow.com/users/13087", "pm_score": 0, "selected": false, "text": "public class Program\n{\n static void Main()\n {\n try\n {\n WrapperClass.CallApi(...);\n ...
2008/10/18
[ "https://Stackoverflow.com/questions/214903", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15109/" ]
214,913
<p>I can enumerate many features of functional programming, but when my friend asked me Could you define functional programming for me? I couldn't.</p>
[ { "answer_id": 215057, "author": "Cervo", "author_id": 16219, "author_profile": "https://Stackoverflow.com/users/16219", "pm_score": -1, "selected": false, "text": "list is some list of items\nOutList is some empty list\nforeach item in list\n OutList.append(function(item))\nreturn O...
2008/10/18
[ "https://Stackoverflow.com/questions/214913", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11439/" ]
214,915
<p>I'm trying to assign application pool to one web site in IIS7 using vb script:</p> <pre><code>' Connect to the WMI WebAdministration namespace.' Set oWebAdmin = GetObject("winmgmts:root\WebAdministration") ' Retrieve the application and display its Web site name and path.' Set oApp = oWebAdmin.Get("Application.SiteName='Default Web Site',Path='/site'") ' Specify a new application pool name and save it.' oApp.ApplicationPool = "NewAppPool" oApp.Put_ </code></pre> <p>the above script is not working!</p> <p>Is there is a better way to assign application pool to web site under IIS (Using script)?</p>
[ { "answer_id": 214935, "author": "Jim Fiorato", "author_id": 650, "author_profile": "https://Stackoverflow.com/users/650", "pm_score": 1, "selected": false, "text": "Set oWebAdmin = GetObject(\"winmgmts:root\\WebAdministration\")\nSet oSite = oWebAdmin.Get(\"Site.Name='Site'\")\noSite.Ap...
2008/10/18
[ "https://Stackoverflow.com/questions/214915", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
214,927
<p>When using C++ namespaces, do you prefer to explicitly name them, like this:</p> <pre><code>std::cout &lt;&lt; "Hello, world!\n"; </code></pre> <p>Or do you prefer <code>using namespace</code>:</p> <pre><code>using namespace std; cout &lt;&lt; "Hello, world!\n"; </code></pre> <p>And if if you prefer the latter, do you declare your usings at file or function scope?</p> <p>Personally I prefer to explicitly name them - it's more typing but when using a mixture of namespaces (e.g. <code>std</code> and <code>boost</code>) I find it more readable.</p>
[ { "answer_id": 214933, "author": "Ferruccio", "author_id": 4086, "author_profile": "https://Stackoverflow.com/users/4086", "pm_score": 5, "selected": true, "text": "using namespace" }, { "answer_id": 214961, "author": "Konrad Rudolph", "author_id": 1968, "author_profi...
2008/10/18
[ "https://Stackoverflow.com/questions/214927", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9236/" ]
214,998
<p>How to dynamically bind data to <code>&lt;%Html.Dropdownlist....</code> in ASP.NET MVC?</p>
[ { "answer_id": 215023, "author": "hangy", "author_id": 11963, "author_profile": "https://Stackoverflow.com/users/11963", "pm_score": 4, "selected": false, "text": "<%= Html.DropDownList(string.Empty, \n \"myDropDownList\", \n new SelectList((IEnumerable)ViewData[\"stuff\"], \n ...
2008/10/18
[ "https://Stackoverflow.com/questions/214998", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29215/" ]
215,011
<p>How do I make sure the correct encoding (UTF-8) is used by Grails?</p>
[ { "answer_id": 217352, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "\nresponse.setContentType(\"text/html; charset=UTF-8\");\nrequest.setCharacterEncoding(\"UTF-8\");\n" } ]
2008/10/18
[ "https://Stackoverflow.com/questions/215011", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6583/" ]
215,026
<p>I am trying to run some unit tests in a C# Windows Forms application (Visual Studio 2005), and I get the following error:</p> <blockquote> <p>System.IO.FileLoadException: Could not load file or assembly 'Utility, Version=1.2.0.200, Culture=neutral, PublicKeyToken=764d581291d764f7' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)**</p> <p>at x.Foo.FooGO()</p> <p>at x.Foo.Foo2(String groupName_) in Foo.cs:line 123</p> <p>at x.Foo.UnitTests.FooTests.TestFoo() in FooTests.cs:line 98**</p> <p>System.IO.FileLoadException: Could not load file or assembly 'Utility, Version=1.2.0.203, Culture=neutral, PublicKeyToken=764d581291d764f7' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)</p> </blockquote> <p>I look in my references, and I only have a reference to <code>Utility version 1.2.0.203</code> (the other one is old).</p> <p>Any suggestions on how I figure out what is trying to reference this old version of this DLL file?</p> <p>Besides, I don't think I even have this old assembly on my hard drive. Is there any tool to search for this old versioned assembly?</p>
[ { "answer_id": 215054, "author": "Lars Truijens", "author_id": 1242, "author_profile": "https://Stackoverflow.com/users/1242", "pm_score": 10, "selected": true, "text": "gacutil /i \"path/to/my.dll\"\n" }, { "answer_id": 220029, "author": "Seth Petry-Johnson", "author_id"...
2008/10/18
[ "https://Stackoverflow.com/questions/215026", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4653/" ]
215,030
<p>The picture below explains all:</p> <p><a href="http://img133.imageshack.us/img133/4206/accentar9.png" rel="nofollow noreferrer">alt text http://img133.imageshack.us/img133/4206/accentar9.png</a></p> <p>The variable textInput comes from <code>File.ReadAllText(path);</code> and characters like : ' é è ... do not display. When I run my UnitTest, all is fine! I see them... Why?</p>
[ { "answer_id": 215059, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 2, "selected": false, "text": "System.IO.StreamReader" } ]
2008/10/18
[ "https://Stackoverflow.com/questions/215030", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13913/" ]
215,052
<p>What is the best choice for a Python GUI application to display large number of thumbnails, e.g. 10000 or more? For performance reasons such thumbnail control must support virtual items, i.e. request application for those thumbnails only which are currently visible to user. </p>
[ { "answer_id": 215257, "author": "Toni Ruža", "author_id": 6267, "author_profile": "https://Stackoverflow.com/users/6267", "pm_score": 2, "selected": false, "text": "class GridData(wx.grid.PyGridTableBase):\n def GetColLabelValue(self, col):\n pass\n\n def GetNumberRows(self...
2008/10/18
[ "https://Stackoverflow.com/questions/215052", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29219/" ]
215,056
<p>I just added asp.net calendar control in new page under sample folder in asp.net mvc beta application. when i execute the particaular page that i need and it shows the error following </p> <p>Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.</p> <p>that points to here . It's in site.master of asp.net mvc </p> <pre><code>&lt;div id="logindisplay"&gt; &lt;% Html.RenderPartial("LoginUserControl"); %&gt; &lt;/div&gt; </code></pre> <p>usually to avoid this error, we give </p> <pre><code>&lt;pages validateRequest="false" enableEventValidation="false" viewStateEncryptionMode ="Never" &gt; </code></pre> <p>but, it doesn't work for me.</p>
[ { "answer_id": 215078, "author": "splattne", "author_id": 6461, "author_profile": "https://Stackoverflow.com/users/6461", "pm_score": 2, "selected": false, "text": "<pages enableeventvalidation=\"false\" viewstateencryptionmode=\"Never\">\n" }, { "answer_id": 894988, "author"...
2008/10/18
[ "https://Stackoverflow.com/questions/215056", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29215/" ]
215,063
<p>I want to be able to use a function such as <code>writefln()</code> but without having to add <code>import std.stdio</code> at the top of the file.</p> <p>Another way to explain it is the way you do it in C++. You can type <code>std::cout &lt;&lt; "Test";</code> and that will stop you from having to add <code>using namespace std;</code>. I want to do the same thing, but in D.</p>
[ { "answer_id": 215067, "author": "Ferruccio", "author_id": 4086, "author_profile": "https://Stackoverflow.com/users/4086", "pm_score": 2, "selected": false, "text": "import" }, { "answer_id": 593068, "author": "zildjohn01", "author_id": 66341, "author_profile": "https...
2008/10/18
[ "https://Stackoverflow.com/questions/215063", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
215,110
<p>What is the best way to graph scatter plots in C++? </p> <p>Do you write data to a file and use another tool? Is there a library like matplotlib in Python?</p>
[ { "answer_id": 215117, "author": "freespace", "author_id": 8297, "author_profile": "https://Stackoverflow.com/users/8297", "pm_score": 6, "selected": true, "text": "gnuplot" } ]
2008/10/18
[ "https://Stackoverflow.com/questions/215110", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14069/" ]
215,114
<p>I am using running a simple find all and paginating with willpaginate, but I'd also like to have the query sorted by the user. The first solution that came to mind was just use a params[:sort]</p> <pre><code>http://localhost:3000/posts/?sort=created_at+DESC @posts = Post.paginate :page =&gt; params[:page], :order =&gt; params[:sort] </code></pre> <p>But the problem with his approach is that the query is defaulting as sorting by ID and I want it to be created_at. </p> <p>Is this a safe approach to sorting and is there a way to default to created_at?</p>
[ { "answer_id": 215126, "author": "Avdi", "author_id": 20487, "author_profile": "https://Stackoverflow.com/users/20487", "pm_score": 2, "selected": false, "text": "fetch" }, { "answer_id": 215145, "author": "Rômulo Ceccon", "author_id": 23193, "author_profile": "https:...
2008/10/18
[ "https://Stackoverflow.com/questions/215114", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10258/" ]
215,115
<p>I have an old ASP.NET 1.1 site that I am maintaining. We are working with Google to place analytics code on all pages. Since I can't take advantage of master pages in 1.1, I have my pages include headers/footers/sidebars with User Controls.</p> <p>What came to mind first is to place the JavaScript in my footer ascx control so it appears on every page. But I don't think I can link to a JavaScript file from a user control. </p> <p>Any ideas on what I can do to get this js code placed on every page in my site?</p>
[ { "answer_id": 215121, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 3, "selected": false, "text": "<asp:SomeControl ID=\"SomeControl1\" runat=\"server>\n <script src=\"some.js\" type=\"text/javascript\"></script>\n</asp:...
2008/10/18
[ "https://Stackoverflow.com/questions/215115", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3047/" ]
215,119
<p>Is there a reliable equivalent of xkill for Windows?</p> <p>For those who don't know what xkill is: it is a Unix tool which basically kills the process of any windows you click on.</p> <p>A Windows port can be downloaded <a href="http://solo-dev.deviantart.com/art/Windows-xKill-100737525" rel="noreferrer">here</a>.</p>
[ { "answer_id": 215172, "author": "JosephStyons", "author_id": 672, "author_profile": "https://Stackoverflow.com/users/672", "pm_score": 3, "selected": false, "text": "taskkill /im ProcessName.exe /f\n" } ]
2008/10/18
[ "https://Stackoverflow.com/questions/215119", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8954/" ]
215,132
<p>I have a ListCtrl that displays a list of items for the user to select. This works fine except that when the ctrl is not large enough to show all the items, I want it to expand downwards with a vertical scoll bar rather than using a horizontal scroll bar as it expands to the right.</p> <p>The ListCtrl's creation:</p> <pre><code>self.subjectList = wx.ListCtrl(self, self.ID_SUBJECT, style = wx.LC_LIST | wx.LC_SINGLE_SEL | wx.LC_VRULES) </code></pre> <p>Items are inserted using wx.ListItem:</p> <pre><code>item = wx.ListItem() item.SetText(subject) item.SetData(id) item.SetWidth(200) self.subjectList.InsertItem(item) </code></pre>
[ { "answer_id": 215216, "author": "Toni Ruža", "author_id": 6267, "author_profile": "https://Stackoverflow.com/users/6267", "pm_score": 3, "selected": true, "text": "import wx\n\nclass Test(wx.Frame):\n def __init__(self):\n wx.Frame.__init__(self, None)\n self.test = wx....
2008/10/18
[ "https://Stackoverflow.com/questions/215132", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6266/" ]
215,139
<p>Can someone tell me how i can change the .xml file that a flash movie loads using c#. ie: i would like an ActionScript variable that defines the location of the flash movie. I would like to be able to change this variable using c# if possible.</p> <p>i dont really know how it would look, but something like:</p> <pre><code>&lt;object xmlpath='" + myCSharpVar + "'" ...&gt;&lt;/object&gt; </code></pre> <p>I just starting this, but my ultimate goal is to create a .swf movie that can load an xml file that specifies images, etc. However i want to use the same .swf file in multiple places and only have to change a ref to what xml file it uses - and my Flash/ActionScript skills are very rusty.</p> <p>To clear it up a bit, in AS you can do something like: </p> <pre><code>loader.load( new URLRequest("IWantThisNameDynamic.xml") ); </code></pre> <p>how can i define that xml file in my c# code?</p>
[ { "answer_id": 215176, "author": "Argelbargel", "author_id": 2992, "author_profile": "https://Stackoverflow.com/users/2992", "pm_score": 2, "selected": true, "text": "\n <object ...>\n <param name=\"flashvars\" value=\"&xmlpath=<path to xml>\"/>\n </object>\n" }, { "answer_i...
2008/10/18
[ "https://Stackoverflow.com/questions/215139", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26685/" ]
215,144
<p>I wanted to derive a class from Predicate&lt;IMyInterface>, but it appears as if Predicate&lt;> is sealed. In my case I wanted to simply return the inverted (!) result of the designated function. I have other ways to accomplish the goal. My question is what might the MS designers have been thinking when deciding to seal Predicate&lt;>?</p> <p>Without much thought I came up with: (a) simplified their testing, just a time vs cost trade off (b) "no good" could come from deriving from Predicate&lt;></p> <p>What do you think?</p> <p>Update: There are n predicates that are dynamically added to a list of Predicates during an initialization phase. Each is mutually exclusive (if Abc is added, NotAbc wont be added). I observed a pattern that looks like:</p> <pre><code>bool Happy(IMyInterface I) {...} bool NotHappy(IMyInterface I) { return !Happy(I); } bool Hungry(IMyInterface I) {...} bool NotHungry(IMyInterface I) { return !Hungry(I); } bool Busy(IMyInterface I) {...} bool NotBusy(IMyInterface I) { return !Busy(I); } bool Smart(IMyInterface I) {...} bool NotSmart(IMyInterface I) {...} //Not simply !Smart </code></pre> <p>Its not that I can't solve the problem, its that I wonder why I couldn't solve it a certain way.</p>
[ { "answer_id": 215152, "author": "Omer van Kloeten", "author_id": 4979, "author_profile": "https://Stackoverflow.com/users/4979", "pm_score": 2, "selected": false, "text": "Predicate<T> p;\nPredicate<T> inverted = t => !p(t);\n" }, { "answer_id": 215153, "author": "Jon Skeet"...
2008/10/18
[ "https://Stackoverflow.com/questions/215144", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27068/" ]
215,160
<p>I have the following javascript:</p> <pre><code>$.ajax({ type: "POST", dataType: "json", url: "/Home/Submit", data: { email: strEmail, message: strMessage }, success: function(result) { //alert('here'); alert(result.message); }, error: function(error) { alert(error); } }); </code></pre> <p>This makes a call to this function:<BR></p> <pre><code>public JsonResult Submit(string Email, string Message) { return Json(new { message = "yep" }); } </code></pre> <p>This works fine in debug mode on the inbuilt webserver.</p> <p>However if I go to the virtual dir directly it does not and hits the error bit. I attached to the process and the code behind never gets hit. </p> <p>I am using Vista. </p> <p>Additionally how do you get the error description in the bit where it says alert(error);</p> <p>Thanks,</p> <p>Alex</p>
[ { "answer_id": 215152, "author": "Omer van Kloeten", "author_id": 4979, "author_profile": "https://Stackoverflow.com/users/4979", "pm_score": 2, "selected": false, "text": "Predicate<T> p;\nPredicate<T> inverted = t => !p(t);\n" }, { "answer_id": 215153, "author": "Jon Skeet"...
2008/10/18
[ "https://Stackoverflow.com/questions/215160", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23066/" ]
215,183
<p>For example, I want just the "filename" of a file in a field. Say I have myimage.jpg I only want to display "myimage" How do I get just that? </p>
[ { "answer_id": 215244, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 4, "selected": true, "text": "<cfset FileName = ListDeleteAt(FileFullName, ListLen(FileFullName, \".\"), \".\")>\n" }, { "answer_id": 215258, ...
2008/10/18
[ "https://Stackoverflow.com/questions/215183", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26121/" ]
215,211
<p>Is there a way to change the colors used by plain Win32 menus (background, text, and highlight) for a single process, <em>without</em> using SetSysColors?</p> <p>(SetSysColors does a global change, which is bad, and if you crash or forget to set the colors back with SetSysColors again before exiting, they will not be restored until you logout.)</p>
[ { "answer_id": 215249, "author": "Serge Wautier", "author_id": 12379, "author_profile": "https://Stackoverflow.com/users/12379", "pm_score": 4, "selected": false, "text": "MENUINFO mi = { 0 }; \nmi.cbSize = sizeof(mi); \nmi.fMask = MIM_BACKGROUND|MIM_APPLYTOSUBMENUS; \nmi.hbrBack = hBrus...
2008/10/18
[ "https://Stackoverflow.com/questions/215211", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28258/" ]
215,213
<p>I'm trying this:</p> <pre><code>Type ThreadContextType = typeof(Application).GetNestedType("ThreadContext", System.Reflection.BindingFlags.NonPublic); MethodInfo FDoIdleMi = ThreadContextType.GetMethod("FDoIdle", BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[] { typeof(Int32) }, null); </code></pre> <p>ThreadContextType is ok but FDoIdleMi is null. I know there is something wrong in the GetMethod call because FDoIdle comes from the UnsafeNativeMethods.IMsoComponent interface.</p> <p>How to do that? Thanks.</p>
[ { "answer_id": 215230, "author": "Charlie", "author_id": 18529, "author_profile": "https://Stackoverflow.com/users/18529", "pm_score": 3, "selected": true, "text": "Type type = typeof( Application ).GetNestedType( \"ThreadContext\",\n BindingFlags.NonPublic );\nMethodInfo doIdle = typ...
2008/10/18
[ "https://Stackoverflow.com/questions/215213", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29244/" ]
215,219
<p>I have a really long 3 column table. I would like to </p> <pre><code>&lt;table&gt; &lt;tr&gt;&lt;td&gt;Column1&lt;/td&gt;&lt;td&gt;Column2&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;Column1&lt;/td&gt;&lt;td&gt;Column2&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;Start&lt;/td&gt;&lt;td&gt;Hiding&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;Column1&lt;/td&gt;&lt;td&gt;Column2&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;Column1&lt;/td&gt;&lt;td&gt;Column2&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;Column1&lt;/td&gt;&lt;td&gt;Column2&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;End&lt;/td&gt;&lt;td&gt;Hiding&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;Column1&lt;/td&gt;&lt;td&gt;Column2&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;Column1&lt;/td&gt;&lt;td&gt;Column2&lt;/td&gt;&lt;/tr&gt; &lt;/table&gt; </code></pre> <p>This is the result I'm trying to obtain using jQuery.</p> <pre><code>Column1 Column2 Column1 Column2 ...Show Full Table... Column1 Column2 Column1 Column2 </code></pre> <p>I would like to use jQuery's show/hide feature to minimize the table but still show part of the top and bottom rows. The middle rows should be replace with text like "Show Full Table" and when clicked will expand to show the full table from start to finish.</p> <p>What is the best way to do this in jQuery?</p> <p>BTW I've already tried adding a class "Table_Middle" to some of the rows but it doesn't hide it completely the space it occupied is still there and I don't have the text to give the user a way to expand the table fully.</p> <p><strong>[EDIT] Added Working Example HTML inspired by Parand's posted answer</strong></p> <p><strong><em>The example below is a complete working example, you don't even need to download jquery. Just paste into a blank HTML file.</em></strong></p> <p><em>It degrades nicely to show only the full table if Javascript is turned off. If Javascript is on then it hides the middle table rows and adds the show/hide links.</em></p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=windows-1252"&gt; &lt;title&gt;Example Show/Hide Middle rows of a table using jQuery&lt;/title&gt; &lt;script src="http://code.jquery.com/jquery-latest.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function() { $("#HiddenRowsNotice").html("&lt;tr&gt;&lt;td colspan='2'&gt; &lt;a href='#'&gt;&gt;&gt; some rows hidden &lt;&lt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;"); $("#ShowHide").html("&lt;tr&gt;&lt;td colspan='2'&gt;&lt;a href='#'&gt;show/hide middle rows&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;"); $("#HiddenRows").hide(); $('#ShowHide,#HiddenRowsNotice').click( function() { $('#HiddenRows').toggle(); $('#HiddenRowsNotice').toggle(); }); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;table&gt; &lt;tbody id="ShowHide"&gt;&lt;/tbody&gt; &lt;tr&gt;&lt;th&gt;Month Name&lt;/th&gt;&lt;th&gt;Month&lt;/th&gt;&lt;/tr&gt; &lt;tbody&gt; &lt;tr&gt;&lt;td&gt;Jan&lt;/td&gt;&lt;td&gt;1&lt;/td&gt;&lt;/tr&gt; &lt;/tbody&gt; &lt;tbody id="HiddenRowsNotice"&gt;&lt;/tbody&gt; &lt;tbody id="HiddenRows"&gt; &lt;tr&gt;&lt;td&gt;Feb&lt;/td&gt;&lt;td&gt;2&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;Mar&lt;/td&gt;&lt;td&gt;3&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;Apr&lt;/td&gt;&lt;td&gt;4&lt;/td&gt;&lt;/tr&gt; &lt;/tbody&gt; &lt;tbody&gt; &lt;tr&gt;&lt;td&gt;May&lt;/td&gt;&lt;td&gt;5&lt;/td&gt;&lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>[EDIT] Link my <a href="http://www.developerbuzz.com/2008/10/use-jquery-to-show-and-hide-part-of.html" rel="nofollow noreferrer">blog post</a> and working example.</p>
[ { "answer_id": 215227, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 2, "selected": false, "text": "<tbody>" }, { "answer_id": 215231, "author": "Parand", "author_id": 13055, "author_profile": "https://Sta...
2008/10/18
[ "https://Stackoverflow.com/questions/215219", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3747/" ]
215,236
<p>In Java, is there a programmatic way to find out how many concurrent threads are supported by a CPU?</p> <p><strong>Update</strong></p> <p>To clarify, I'm not trying to hammer the CPU with threads and I am aware of Runtime.getRuntime().availableProcessors() function, which provides me part of the information I'm looking for.</p> <p>I want to find out if there's a way to automatically tune the size of thread pool so that:</p> <ul> <li>if I'm running on a 1-year old server, I get 2 threads (1 thread per CPU x an arbitrary multiplier of 2)</li> <li>if I switch to an Intel i7 quad core two years from now (which supports 2 threads per core), I get 16 threads (2 logical threads per CPU x 4 CPUs x the arbitrary multiplier of 2).</li> <li>if, instead, I use a eight core Ultrasparc T2 server (which supports 8 threads per core), I get 128 threads (8 threads per CPU x 8 CPUs x the arbitrary multiplier of 2)</li> <li>if I deploy the same software on a cluster of 30 different machines, potentially purchased at different years, I don't need to read the CPU specs and set configuration options for every single one of them.</li> </ul>
[ { "answer_id": 215259, "author": "pipTheGeek", "author_id": 28552, "author_profile": "https://Stackoverflow.com/users/28552", "pm_score": 4, "selected": false, "text": "availableProcessors()" } ]
2008/10/18
[ "https://Stackoverflow.com/questions/215236", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20689/" ]
215,248
<p>I'm using a ListView in C# to make a grid. I would like to find out a way to be able to highlight a specific cell, programatically. I only need to highlight one cell.</p> <p>I've experimented with Owner Drawn subitems, but using the below code, I get highlighted cells, but no text! Are there any ideas on how to get this working? Thanks for your help.</p> <pre><code>//m_PC.Location is the X,Y coordinates of the highlighted cell. void listView1_DrawSubItem(object sender, DrawListViewSubItemEventArgs e) { if ((e.ItemIndex == m_PC.Location.Y) &amp;&amp; (e.Item.SubItems.IndexOf(e.SubItem) == m_PC.Location.X)) e.SubItem.BackColor = Color.Blue; else e.SubItem.BackColor = Color.White; e.DrawBackground(); e.DrawText(); } </code></pre>
[ { "answer_id": 215269, "author": "Charlie", "author_id": 18529, "author_profile": "https://Stackoverflow.com/users/18529", "pm_score": 5, "selected": true, "text": "// create a new list item with a subitem that has white text on a blue background\nListViewItem lvi = new ListViewItem( \"i...
2008/10/18
[ "https://Stackoverflow.com/questions/215248", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29249/" ]
215,252
<p>I get a "UUID mismatch" warning at the console when I try to build and run my app on my iPhone.</p> <blockquote> <p>warning: UUID mismatch detected with the loaded library - on disk is: /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.1.sdk/usr/lib/liblockdown.dylib =uuid-mismatch-with-loaded-file,file="/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.1.sdk/usr/lib/liblockdown.dylib</p> </blockquote> <p>Anyone has this issue and managed to resolve the warning ?</p>
[ { "answer_id": 2374659, "author": "Sam Soffes", "author_id": 118631, "author_profile": "https://Stackoverflow.com/users/118631", "pm_score": 2, "selected": false, "text": "$ sudo /Developer/Library/uninstall-devtools --mode=all\n" }, { "answer_id": 4289323, "author": "Andrew ...
2008/10/18
[ "https://Stackoverflow.com/questions/215252", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1987/" ]
215,267
<p>We've been using Trac for task/defect tracking and things were going well enough, but this morning it started serving up a 500 error. Looking in the Apache error_log, I get a stack trace that culminates in:</p> <pre> PythonHandler trac.web.modpython_frontend: ExtractionError: Can't extract file(s) to egg cache The following error occurred while trying to extract file(s) to the Python egg cache: [Errno 13] Permission denied: '/.python-eggs' The Python egg cache directory is currently set to: /.python-eggs Perhaps your account does not have write access to this directory? You can change the cache directory by setting the PYTHON_EGG_CACHE environment variable to point to an accessible directory </pre> <p>So I explicitly set PYTHON_EGG_CACHE to /srv/trac/plugin-cache. I restarted Apache. Yet I get the same error (it still says "egg cache directory current set to: \n\n /.python_eggs.")</p> <p>How should I proceed? Is the simplest thing to do to reinstall Trac? If I go that route, what steps do I need to take to ensure that I don't lose existing data?</p>
[ { "answer_id": 215298, "author": "agnul", "author_id": 6069, "author_profile": "https://Stackoverflow.com/users/6069", "pm_score": 4, "selected": true, "text": "export PYTHON_EGG_CACHE=/tmp/python_eggs\n" }, { "answer_id": 215303, "author": "Bob Nadler", "author_id": 2514...
2008/10/18
[ "https://Stackoverflow.com/questions/215267", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10116/" ]
215,271
<p>I've got a <strong>large</strong> array of primitive types (double). How do I sort the elements in <strong>descending order</strong>?</p> <p>Unfortunately the Java API doesn't support sorting of <strong>primitive</strong> types with a Comparator.</p> <p>The first approach that probably comes to mind is to convert it to a list of objects (boxing):</p> <pre><code>double[] array = new double[1048576]; Arrays.stream(array).boxed().sorted(Collections.reverseOrder())… </code></pre> <p>This solution is probably good enough for many (or even most) use cases but <strong>boxing</strong> each primitive in the array is <strong>too slow and causes a lot of GC pressure</strong> if the array is large!</p> <p>Another approach would be to sort and then reverse:</p> <pre><code>double[] array = new double[1048576]; ... Arrays.sort(array); // reverse the array for (int i = 0; i &lt; array.length / 2; i++) { // swap the elements double temp = array[i]; array[i] = array[array.length - (i + 1)]; array[array.length - (i + 1)] = temp; } </code></pre> <p><strong>This approach can also be too slow</strong> if the array is already sorted quite well.</p> <p>What's a better alternative if the arrays are large and performance is the major optimization goal?</p>
[ { "answer_id": 215280, "author": "Jason Cohen", "author_id": 4926, "author_profile": "https://Stackoverflow.com/users/4926", "pm_score": 2, "selected": false, "text": "toList()" }, { "answer_id": 215283, "author": "Eli Courtwright", "author_id": 1694, "author_profile"...
2008/10/18
[ "https://Stackoverflow.com/questions/215271", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4308/" ]
215,302
<p>I am trying to create a file in the <code>/tmp</code> directory (working on a Linux UBUNTU 7.10), that has read/write/execute access for any user.</p> <p>So I am using the</p> <pre><code>open(fileName,O_CREAT|O_RDWR,0777) </code></pre> <p>function to create the file (from a C program) in <code>user1</code> account and I would like <code>user2</code> to be able to write to the specific file.</p> <p>However, when I check the <code>/tmp</code> directory, using</p> <pre><code>ls -l </code></pre> <p>I see that I do not have the <strong>write access permission</strong> for <code>user2</code> (considering the fact that <code>user1</code> created it, I have write access for <code>user1</code>, but <code>user2</code>, who is considered to be &quot;others&quot; does not have any access).</p> <p>I have tried to use mode <code>0766</code> in the <code>open</code> function (and such combinations of <code>7</code> and <code>6</code> for modes), so that I may get write access for <code>user2</code>, but I still don't have the required access.</p>
[ { "answer_id": 215318, "author": "Jonathan Leffler", "author_id": 15168, "author_profile": "https://Stackoverflow.com/users/15168", "pm_score": 2, "selected": false, "text": " mode_t oldmask = umask(0);\n fd = open(...);\n oldmask = umask(oldmask);\n assert(oldmask == 0);\n" }, { ...
2008/10/18
[ "https://Stackoverflow.com/questions/215302", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23486/" ]
215,316
<p>I've got a tomcat 6 web app running with Apache httpd as the front end. I'm using mod_proxy and mod_proxy_ajp to forward the requests to tomcat. My server is running Ubuntu. Now I'm trying to use mod_rewrite to remove the leading www, so that my canonical website URL is <code>http://example.com</code> rather than <code>http://www.example.com</code></p> <p>I've read a number of tutorials on using mod_rewrite, but I can't get any rewriting to work. I've tried putting the rewrite rule in an <code>.htaccess</code> file (after modifying my <code>/etc/apache/sites-available/default</code> file to set AllowOverride all). I've tried putting the rewrite rule in <code>apache2.conf</code>, <code>httpd.conf</code>, and <code>rewrite.conf</code>. I've tried all of these with rewrite logging turned on. The log file gets created, but Apache has written nothing to it. I thought maybe mod_proxy was somehow preventing the rewrite rules from being used, so I tried disabling that as well...and I still get no rewrite, and nothing to the log.</p> <p>At this point I have absolutely no idea what to try next. How do I go about troubleshooting why Apache isn't using my rewrite rules?</p> <p>For reference, here are my rewrite directives:</p> <pre><code>&lt;IfModule mod_rewrite.c&gt; RewriteEngine on RewriteCond %{HTTP_HOST} ^www.example.com$ [NC] RewriteRule ^(.*)$ http://example.com/$1 [R=301,L] RewriteLog &quot;/var/log/apache2/rewrite.log&quot; RewriteLogLevel 3 &lt;/IfModule&gt; </code></pre> <p>the responses below are helpful to my particular case, but probably not as helpful to the community-at-large as answers about how you troubleshoot Apache directives in general. For example, is there a way to enable logging to the point where it would tell me which directives are being applied in which order as the request comes in?</p> <p><strong>Edit 2</strong>: I've gotten things to work now. My virtual hosts weren't quite set up right, and I also didn't quite have the rewrite regex right. Here is the final rewrite directives I got to work:</p> <pre><code>&lt;IfModule mod_rewrite.c&gt; RewriteEngine On RewriteCond %{HTTP_HOST} ^www\.example\.com [NC] RewriteRule ^(.*)$ http://example.com$1 [L,R=301] &lt;/IfModule&gt; </code></pre>
[ { "answer_id": 215345, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 0, "selected": false, "text": "RewriteRule .* www.google.com [RL]" }, { "answer_id": 215359, "author": "K Prime", "author_id": 29270, "a...
2008/10/18
[ "https://Stackoverflow.com/questions/215316", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29262/" ]
215,361
<p>I need a regex that matches all strings ending in .cs, but if they end in .g.cs they should not match. I'm using .NET regular expressions.</p>
[ { "answer_id": 215366, "author": "thr", "author_id": 452521, "author_profile": "https://Stackoverflow.com/users/452521", "pm_score": 4, "selected": true, "text": "(?<!\\.g)\\.cs$\n" }, { "answer_id": 215502, "author": "ephemient", "author_id": 20713, "author_profile":...
2008/10/18
[ "https://Stackoverflow.com/questions/215361", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7532/" ]
215,383
<p>I have a custom UIView that generates a set of subviews and display them in rows and columns like tiles. What I am trying to achieve is to allow the user to touch the screen and as the finger move, the tiles beneath it disappears. </p> <p>The code below is the custom UIView that contains the tiles:</p> <pre><code>- (id)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { int i, j; int maxCol = floor(self.frame.size.width/TILE_SPACING); int maxRow = floor(self.frame.size.height/TILE_SPACING); CGRect frame = CGRectMake(0, 0, TILE_WIDTH, TILE_HEIGHT); UIView *tile; for (i = 0; i&lt;maxCol; i++) { for (j = 0; j &lt; maxRow; j++) { frame.origin.x = i * (TILE_SPACING) + TILE_PADDING; frame.origin.y = j * (TILE_SPACING) + TILE_PADDING; tile = [[UIView alloc] initWithFrame:frame]; [self addSubview:tile]; [tile release]; } } } return self; } - (void)touchesBegan: (NSSet *)touches withEvent:(UIEvent *)event { UIView *tile = [self hitTest:[[touches anyObject] locationInView:self] withEvent:nil]; if (tile != self) [tile setHidden:YES]; } - (void)touchesMoved: (NSSet *)touches withEvent:(UIEvent *)event { UIView *tile = [self hitTest:[[touches anyObject] locationInView:self] withEvent:nil]; if (tile != self) [tile setHidden:YES]; } </code></pre> <p>This approach works but however if the tiles get denser (i.e. small tiles and more tiles on the screen). The iPhone is less responsive as the finger move. It may be the hitTest taking a toll on the processor as it struggles to keep up but would like some opinions.</p> <p>My questions are:</p> <ol> <li><p>Is this an efficient way / right way to implement the touchesMoved?</p></li> <li><p>If it isn't, what would be the recommended approach?</p></li> <li><p>I tried moving the functionality into a custom Tile class (a sub UIView) which the class above would create and add as a subview. This subview Tile can handle the TouchesBegan but as the finger move, the other tiles does not receive the TouchesBegan even since the touches are still part of the initial touch sequence. Is there a way to implement it through the subview Tile class, how do other tiles receive the TouchesBegan/TouchesMoved event as the finger move?</p></li> </ol>
[ { "answer_id": 215531, "author": "Ben Gottlieb", "author_id": 6694, "author_profile": "https://Stackoverflow.com/users/6694", "pm_score": 5, "selected": true, "text": "" }, { "answer_id": 472095, "author": "Corey Floyd", "author_id": 48311, "author_profile": "https://...
2008/10/18
[ "https://Stackoverflow.com/questions/215383", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1987/" ]
215,392
<p>I am busy writing my thesis (so, I guess this could count as a homework question). Now, one of the things that came up was the Unix <code>select</code> system call. I would like to add a reference to the appropriate man page, but all I can find that seems the slight bit official is the Single Unix Specification site that wants my money first. Sure, the Linux guys all have man pages, but they have real geeky urls that don't look like they will stay around forever. What to do? So far I am referring to <em>See SELECT(2) UNIX man page</em>...</p>
[ { "answer_id": 215402, "author": "warren", "author_id": 4418, "author_profile": "https://Stackoverflow.com/users/4418", "pm_score": 0, "selected": false, "text": "man <command>" } ]
2008/10/18
[ "https://Stackoverflow.com/questions/215392", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2260/" ]
215,399
<p>Suppose I have a class where I want the user to be able to have a reference to one of my members. Which is preferred?</p> <pre><code>class Member; class ClassWithWeakPtr { private: boost::shared_ptr&lt;Member&gt; _member; public: boost::weak_ptr&lt;Member&gt; GetMember(); }; </code></pre> <p>or</p> <pre><code>class Member; class ClassWithCppReference { private: Member _member; public: Member&amp; GetMember() {return _member;} }; </code></pre> <p>What do you think? When is one better than another?</p>
[ { "answer_id": 215428, "author": "Michael Burr", "author_id": 12711, "author_profile": "https://Stackoverflow.com/users/12711", "pm_score": 4, "selected": false, "text": "shared_ptr<>" }, { "answer_id": 215553, "author": "Sol", "author_id": 27029, "author_profile": "h...
2008/10/18
[ "https://Stackoverflow.com/questions/215399", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8123/" ]
215,412
<p>Is there a way to programmatically change the screen resolution or enable/disable multiple monitors in Windows XP? For example to change from 1024x768 with one monitor to 1280x1024 on two monitors? I would be most interested in a win32 function to do this but anything that can be tied to a windows shortcut would suffice.</p>
[ { "answer_id": 9828304, "author": "a7drew", "author_id": 4239, "author_profile": "https://Stackoverflow.com/users/4239", "pm_score": -1, "selected": false, "text": "#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.\n#Warn ; Recommended for catching...
2008/10/18
[ "https://Stackoverflow.com/questions/215412", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6320/" ]
215,430
<p>I have to use unsigned integers that could span to more than 4 bytes, what type should I use?</p> <p>PS Sorry for the "noobism" but that's it :D</p> <p>NB: I need integers because i have to do divisions and care only for the integer parts and this way int are useful</p>
[ { "answer_id": 215459, "author": "An̲̳̳drew", "author_id": 17035, "author_profile": "https://Stackoverflow.com/users/17035", "pm_score": 2, "selected": false, "text": "long long" } ]
2008/10/18
[ "https://Stackoverflow.com/questions/215430", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22963/" ]
215,458
<p>The calculations in my code are well-tested, but because there is so much GUI code, my overall code coverage is lower than I'd like. Are there any guidelines on unit-testing GUI code? Does it even make sense?</p> <p>For example, there are graphs in my app. I haven't been able to figure out how to automate the testing of the graphs. It takes a human eye, AFAIK, to check if the graph is correct.</p> <p>(I'm using Java Swing)</p>
[ { "answer_id": 1001011, "author": "Dema", "author_id": 407003, "author_profile": "https://Stackoverflow.com/users/407003", "pm_score": 3, "selected": false, "text": " Scenario: Dialog manipulation\n Given the frame \"SwingSet\" is visible\n When I click the menu \"File/About\"\n ...
2008/10/18
[ "https://Stackoverflow.com/questions/215458", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2959/" ]
215,471
<p>In VS2008 I have written a C# service, an installer, and have created a setup package to install it. The service needs to load an xml file to operate. Where is the best place to put this file in the various filesystem folders offered by the VS setup project, and how do I then refer to these paths from my code?</p> <p>I should point out the the service runs as <code>LocalService</code>, which means that the ApplicationData folder offered by the &quot;User's Application Data Folder&quot; item in the VS setup project is not accessible, even when &quot;Install for all users&quot; is used during installation. I could easily hack around this, but would like to understand best practice.</p>
[ { "answer_id": 215538, "author": "mohammedn", "author_id": 29268, "author_profile": "https://Stackoverflow.com/users/29268", "pm_score": 3, "selected": true, "text": "string path = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);\n" }, { "answer_id": 7052450, ...
2008/10/18
[ "https://Stackoverflow.com/questions/215471", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14357/" ]
215,497
<p>In Java, are there clear rules on when to use each of access modifiers, namely the default (package private), <code>public</code>, <code>protected</code> and <code>private</code>, while making <code>class</code> and <code>interface</code> and dealing with inheritance?</p>
[ { "answer_id": 215505, "author": "David Segonds", "author_id": 13673, "author_profile": "https://Stackoverflow.com/users/13673", "pm_score": 14, "selected": true, "text": "public" }, { "answer_id": 12401576, "author": "Mechanical snail", "author_id": 319931, "author_p...
2008/10/18
[ "https://Stackoverflow.com/questions/215497", "https://Stackoverflow.com", "https://Stackoverflow.com/users/625/" ]
215,515
<p>I have a simple class that essentially just holds some values. I have overridden the <code>ToString()</code> method to return a nice string representation.</p> <p>Now, I want to create a <code>ToXml()</code> method, that will return something like this:</p> <pre><code>&lt;Song&gt; &lt;Artist&gt;Bla&lt;/Artist&gt; &lt;Title&gt;Foo&lt;/Title&gt; &lt;/Song&gt; </code></pre> <p>Of course, I could just use a <code>StringBuilder</code> here, but I would like to return an <code>XmlNode</code> or <code>XmlElement</code>, to be used with <code>XmlDocument.AppendChild</code>.</p> <p>I do not seem to be able to create an <code>XmlElement</code> other than calling <code>XmlDocument.CreateElement</code>, so I wonder if I have just overlooked anything, or if I really either have to pass in either a <code>XmlDocument</code> or <code>ref XmlElement</code> to work with, or have the function return a String that contains the XML I want?</p>
[ { "answer_id": 215565, "author": "Panos", "author_id": 8049, "author_profile": "https://Stackoverflow.com/users/8049", "pm_score": 4, "selected": false, "text": "XmlNode" }, { "answer_id": 215568, "author": "mohammedn", "author_id": 29268, "author_profile": "https://S...
2008/10/18
[ "https://Stackoverflow.com/questions/215515", "https://Stackoverflow.com", "https://Stackoverflow.com/users/91/" ]
215,516
<p>I am working on a winforms html editor with multiple editor windows as each editor window will be written to a database field.</p> <p>I am creating the editor windows as a control array and was hoping to just have one toolbar above them that would handle the events such as apply bold, italic... based on the window I was currently in. Unfortunately obviously the event handler of an event on the toolbar doesn't know what the control selected before it was. </p> <p>Is there a way to get this or should I be adding an onenter event to each editor window and storing statically the last editor window used.</p>
[ { "answer_id": 215637, "author": "Blair Conrad", "author_id": 1199, "author_profile": "https://Stackoverflow.com/users/1199", "pm_score": 0, "selected": false, "text": "[SerializableAttribute]\n[ComVisibleAttribute(true)]\npublic delegate void EventHandler(\n Object sender,\n Event...
2008/10/18
[ "https://Stackoverflow.com/questions/215516", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16989/" ]
215,517
<p>Does anyone know of any code or tools that can strip literal values out of SQL statements?</p> <p>The reason for asking is I want to correctly judge the SQL workload in our database and I'm worried I might miss out on bad statements whose resource usage get masked because they are displayed as separate statements. When, in reality, they are pretty much the same thing except for different IDs being passed in. </p> <p>I'd prefer a database independent solution if any exists. I had thought there might be a nifty Perl module for this but I haven't found any.</p> <p>Thanks for your help.</p>
[ { "answer_id": 215527, "author": "Cade Roux", "author_id": 18255, "author_profile": "https://Stackoverflow.com/users/18255", "pm_score": 0, "selected": false, "text": "SQL" }, { "answer_id": 215543, "author": "John Nilsson", "author_id": 24243, "author_profile": "http...
2008/10/18
[ "https://Stackoverflow.com/questions/215517", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29286/" ]
215,524
<p>Some iPhone applications, such as Pandora seem to directly manipulate the hardware volume and respond to physical volume button. How is this done?</p> <p>AudioSessionServices allows you to get the current hardware output volume with the <code>kAudioSessionProperty_CurrentHardwareOutputVolume</code> property, but it is (allegedly) read-only.</p>
[ { "answer_id": 215614, "author": "catlan", "author_id": 23028, "author_profile": "https://Stackoverflow.com/users/23028", "pm_score": 4, "selected": true, "text": "MPVolumeView *volumeView = [[MPVolumeView alloc] initWithFrame:CGRectMake(25, 378, 270, 30)];\n[self.view addSubview:volumeV...
2008/10/18
[ "https://Stackoverflow.com/questions/215524", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4468/" ]
215,537
<p>So am I crazy for considering doing a beta/production release on Glassfish V3 Prelude? Since all of my content is dynamic, I'm not even thinking of bothering to set up apache in front either. Doing so complicates the setup by requiring something like AJP or mod_jk and will not offer us much in terms of capability.</p> <p>So there will be three war files on deployment. 3 JNDI data sources with about 90 connections parked, scaling up to 160 to a PGSQL datastore....</p> <p>The three wars comprise a CMS system and a grails application?</p> <p>Is my logic fatally flawed that I don't need to put apache in front of this setup?</p>
[ { "answer_id": 215614, "author": "catlan", "author_id": 23028, "author_profile": "https://Stackoverflow.com/users/23028", "pm_score": 4, "selected": true, "text": "MPVolumeView *volumeView = [[MPVolumeView alloc] initWithFrame:CGRectMake(25, 378, 270, 30)];\n[self.view addSubview:volumeV...
2008/10/18
[ "https://Stackoverflow.com/questions/215537", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1129162/" ]
215,548
<p>Background: Over the next month, I'll be giving three talks about or at least including <code>LINQ</code> in the context of <code>C#</code>. I'd like to know which topics are worth giving a fair amount of attention to, based on what people may find hard to understand, or what they may have a mistaken impression of. I won't be specifically talking about <code>LINQ</code> to <code>SQL</code> or the Entity Framework except as examples of how queries can be executed remotely using expression trees (and usually <code>IQueryable</code>).</p> <p>So, what have you found hard about <code>LINQ</code>? What have you seen in terms of misunderstandings? Examples might be any of the following, but please don't limit yourself!</p> <ul> <li>How the <code>C#</code> compiler treats query expressions</li> <li>Lambda expressions</li> <li>Expression trees</li> <li>Extension methods</li> <li>Anonymous types</li> <li><code>IQueryable</code></li> <li>Deferred vs immediate execution</li> <li>Streaming vs buffered execution (e.g. OrderBy is deferred but buffered)</li> <li>Implicitly typed local variables</li> <li>Reading complex generic signatures (e.g. <a href="http://msdn.microsoft.com/en-us/library/bb549267.aspx" rel="nofollow noreferrer">Enumerable.Join</a>)</li> </ul>
[ { "answer_id": 215572, "author": "smaclell", "author_id": 22914, "author_profile": "https://Stackoverflow.com/users/22914", "pm_score": 7, "selected": false, "text": "LINQ" }, { "answer_id": 215580, "author": "Tim Jarvis", "author_id": 10387, "author_profile": "https:...
2008/10/18
[ "https://Stackoverflow.com/questions/215548", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22656/" ]
215,557
<p>How do I implement a circular list that overwrites the oldest entry when it's full? </p> <p>For a little background, I want to use a circular list within GWT; so using a 3rd party lib is <strong>not</strong> what I want.</p>
[ { "answer_id": 215575, "author": "Adam Davis", "author_id": 2915, "author_profile": "https://Stackoverflow.com/users/2915", "pm_score": 7, "selected": true, "text": "/* Very simple queue\n * These are FIFO queues which discard the new data when full.\n *\n * Queue is empty when in == out...
2008/10/18
[ "https://Stackoverflow.com/questions/215557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22992/" ]
215,581
<p>What is the purpose of the colon before a block in Python?</p> <p>Example:</p> <pre><code>if n == 0: print "The end" </code></pre>
[ { "answer_id": 215676, "author": "tzot", "author_id": 6899, "author_profile": "https://Stackoverflow.com/users/6899", "pm_score": 7, "selected": true, "text": "if a == b \n print a\n" }, { "answer_id": 1464645, "author": "Yoo", "author_id": 37664, "author_profile":...
2008/10/18
[ "https://Stackoverflow.com/questions/215581", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14732/" ]
215,584
<p>I am currently a student and trying to design a Visual C++ application to allow me to visually insert an oriented graph in order to create a text file with the graph's matrix. At this point I have created an onClick event to create nodes and have used the form's Paint event to draw the nodes. I have also inserted the conditions to avoid nodes from overlapping.</p> <p>I am currently working on creating the links between nodes. The problem that I have encountered is that the line that unites two nodes crosses another node. I consider that writing an algorithm to detect overlapping and calculate how much the line needs to arch in order to avoid that is too tedious in this situation.</p> <p>Therefore I thought about creating a line that can be arched by the user by clicking and dragging it to the left or right, however I have had problems finding any tutorials on how to do this. So if anyone has ever had to introduce this kind of arching line in a project or has any idea where I could find some information about this I would deeply appreciate it.</p> <p>Mentions:</p> <ol> <li>please do not recommend any fancy graphics libraries for doing this, as I am not interested in installing 3rd party stuff for this program. The function I want to insert the code into is named something like form1_onPaint, so I would like to keep it strictly to the C++ standard libraries.</li> <li>I know I said I am interested in arching a line through click and drag, however if someone could suggest another viable solution to this, such as a function that detects overlapping in onPaint events or anything else that could be of use to solve this it would be of great help.</li> </ol>
[ { "answer_id": 215676, "author": "tzot", "author_id": 6899, "author_profile": "https://Stackoverflow.com/users/6899", "pm_score": 7, "selected": true, "text": "if a == b \n print a\n" }, { "answer_id": 1464645, "author": "Yoo", "author_id": 37664, "author_profile":...
2008/10/18
[ "https://Stackoverflow.com/questions/215584", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29293/" ]
215,615
<p>Erlang support to partition its nodes into groups using the <a href="http://erlang.org/doc/man/global_group.html" rel="nofollow noreferrer">global_group</a> module. Further, Erlang supports adding nodes on the fly to the node-network. Are these two features usable with each other?<br> As far as I understand, you have to name every node on startup to use the global groups.</p>
[ { "answer_id": 2736872, "author": "TBBle", "author_id": 166389, "author_profile": "https://Stackoverflow.com/users/166389", "pm_score": 2, "selected": true, "text": "application:set_env( kernel, global_groups, [GroupTuple|GroupTuples] ),\nkernel:config_change( [ { global_groups, [GroupTu...
2008/10/18
[ "https://Stackoverflow.com/questions/215615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23760/" ]
215,620
<p>How do I load MS Word document (.doc and .docx) to memory (variable) without doing this?:</p> <p><em>wordApp.Documents.Open</em> </p> <p>I don't want to open MS Word, I just want that text inside. </p> <p>You gave me answer for DOCX, but what about DOC? I want free and high performance solution - not to open 12.000 instances of Word to process all of them. :( Aspose is commercial product, and 900$ is a way too much for what I do.</p>
[ { "answer_id": 25975734, "author": "edi9999", "author_id": 1993501, "author_profile": "https://Stackoverflow.com/users/1993501", "pm_score": 0, "selected": false, "text": "DocxTemplater=require('docxtemplater');\ndoc=new DocxTemplater().loadFromFile(\"input.docx\");\nresult=doc.getFullTe...
2008/10/18
[ "https://Stackoverflow.com/questions/215620", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21209/" ]
215,624
<p>I am trying to use some pinvoke code to call a C function. The function fills a buffer with data.</p> <p>The structure is set up as a DWORD for the length, followed by a string. How do I extract the string from the IntPtr?</p> <pre><code> IntPtr buffer = Marshal.AllocHGlobal(nRequiredSize); PInvokedFunction(buffer, nRequiredSize); string s = Marshal.PtrToStringAuto(buffer + 4); //this is an error. Marshal.FreeHGlobal(buffer); </code></pre>
[ { "answer_id": 215627, "author": "Adam Tegen", "author_id": 4066, "author_profile": "https://Stackoverflow.com/users/4066", "pm_score": 0, "selected": false, "text": " IntPtr buffer = Marshal.AllocHGlobal((int)nRequiredSize);\n PInvokedFunction(buffer, nRequiredSize);\n UnmanagedMemorySt...
2008/10/18
[ "https://Stackoverflow.com/questions/215624", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4066/" ]
215,636
<p>I'm having some trouble with Visual Studio 2008 on my Windows XP SP2 laptop.</p> <p>What happens is that when I start a program with a few textboxes and stuff like that, the boxes are see-through. I can litteraly see through them and see what's on the underlaying screen. Like if I only have this Form showing and behind that my wallpaper, I can see my wallpaper through the Textbox, ComboBox, even through the small cracks between various elements.</p> <p>i've searched the web but haven't encountered info on this yet. Does anybody know what might be causing this and how to solve it? I'm in the process of trying to see how the text in my TextBoxes is parsed, but I can't since I can't even enter anything. I click on the textbox and I'm focused on the desktop...</p>
[ { "answer_id": 215646, "author": "Cameron", "author_id": 21475, "author_profile": "https://Stackoverflow.com/users/21475", "pm_score": 3, "selected": true, "text": "Reset" } ]
2008/10/18
[ "https://Stackoverflow.com/questions/215636", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11795/" ]
215,638
<p>I'm trying to access the message in a jthrowable while handing an exception generated when I fail to find a class. However, I am unable to access the message ID of getMessage() on the jthrowable object, and I don't know why. I've tried changing the signature of getMessage to "()Ljava/lang/String" (without the semicolon at the end, but that's necessary, right?) with no joy. I'm confused as hell about this. I even tried replacing getMessage with toString, and <em>that</em> didn't work. Obviously I'm doing something trivially wrong here.</p> <p>Here's the code I'm using:</p> <pre><code>jthrowable java_exception; jclass java_class; jmethodID method; java_exception = (*jEnv)-&gt;ExceptionOccurred(jEnv); assert (java_exception != NULL); java_class = (*jEnv)-&gt;GetObjectClass (jEnv, java_exception); assert (java_class != NULL); method = (*jEnv)-&gt;GetMethodID (jEnv, java_class, "getMessage", "()Ljava/lang/String;"); if (method == NULL) { printf ("Seriously, how do I get here?!\n"); (*jEnv)-&gt;ExceptionDescribe (jEnv); return; } </code></pre> <p>The output of this code (amongst other things) looks like this:</p> <blockquote> <p>Seriously, how do I get here?!<br> Exception in thread "main" java.lang.NoClassDefFoundError: com/planet/core360/docgen/Processor</p> </blockquote> <p><code>javap -p -s java.lang.Throwable</code> gives me this:</p> <blockquote> <p>Compiled from "Throwable.java"<br> public class java.lang.Throwable extends java.lang.Object implements java.io.Serializable{<br> ...<br> public java.lang.String getMessage();<br> Signature: ()Ljava/lang/String;<br> ... </p> </blockquote>
[ { "answer_id": 215662, "author": "Chris R", "author_id": 23309, "author_profile": "https://Stackoverflow.com/users/23309", "pm_score": 4, "selected": true, "text": "GetObjectClass" }, { "answer_id": 215681, "author": "C. K. Young", "author_id": 13, "author_profile": "...
2008/10/18
[ "https://Stackoverflow.com/questions/215638", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23309/" ]
215,667
<p>I am trying to develop a script to pull some data from a large number of html tables. One problem is that the number of rows that contain the information to create the column headings is indeterminate. I have discovered that the last row of the set of header rows has the attribute border-bottom for each cell with a value. Thus I decided to find those cells with the attribute border-bottom. As you can see I initialized a list. I intended to find the parent of each of the cells that end up in the borderCells list. However, when I run this code only one cell, that is the first cell in allCells with the attribute border-bottom is added to the list borderCells. For your information allCells has 193 cells, 9 of them have the attr border-bottom. Thus I was expecting nine members in the borderCells list. Any help is appreciated.</p> <pre><code>borderCells=[] for each in allCells: if each.find(attrs={"style": re.compile("border-bottom")}): borderCells.append(each) </code></pre>
[ { "answer_id": 215720, "author": "pantsgolem", "author_id": 9261, "author_profile": "https://Stackoverflow.com/users/9261", "pm_score": 2, "selected": false, "text": "borderCells = soup.findAll(\"td\", style=re.compile(\"border-bottom\")})" }, { "answer_id": 215727, "author":...
2008/10/18
[ "https://Stackoverflow.com/questions/215667", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
215,672
<p>Does anyone have experience with a query language for the web?</p> <p>I am looking for project, commercial or not, that does a good job at making a webpage queryable and that even follows links on it to aggregate information from a bunch of pages.</p> <p>I would prefere a sql or linq like syntax. I could of course download a webpage and start doing some XPATH on it but Im looking for a solution that has a nice abstraction.</p> <p>I found websql </p> <p><a href="http://www.cs.utoronto.ca/~websql/" rel="nofollow noreferrer">http://www.cs.utoronto.ca/~websql/</a></p> <p>Which looks good but I'm not into Java</p> <pre><code>SELECT a.label FROM Anchor a SUCH THAT base = "http://www.SomeDoc.html" WHERE a.href CONTAINS ".ps.Z"; </code></pre> <p>Are there others out there? </p> <p>Is there a library that can be used in a .NET language?</p>
[ { "answer_id": 215788, "author": "Pistos", "author_id": 28558, "author_profile": "https://Stackoverflow.com/users/28558", "pm_score": 2, "selected": false, "text": "# load the RedHanded home page\ndoc = Hpricot(open(\"http://redhanded.hobix.com/index.html\"))\n# change the CSS class on l...
2008/10/18
[ "https://Stackoverflow.com/questions/215672", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25145/" ]
215,684
<p>I have a std::multimap where key is a custom class. Something like this:</p> <pre><code>Class X { public: std::string s; int x; operator &lt;(const X&amp; other) const { return s &lt; other.s; } }; std::multimap&lt;X, int&gt; mymap; </code></pre> <p>Now, I'd like to use upper_bound and lower_bound to iterate over all elements with the same value of "s". Do I need to implement some other operator for X (for example: ==). Or it will work properly just like this?</p> <p>Also, what should I supply as argument for <em>upper_bound</em> and <em>lower_bound</em>? I assume I should create a dummy object with desired value of "s"?</p>
[ { "answer_id": 215692, "author": "Michael Burr", "author_id": 12711, "author_profile": "https://Stackoverflow.com/users/12711", "pm_score": 4, "selected": true, "text": "class X" } ]
2008/10/18
[ "https://Stackoverflow.com/questions/215684", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14690/" ]
215,685
<p>I often find myself trying to come up with good names for complementary pairs of variables; where two variables denote opposing concepts, two participants in some sort of duologue, and so on.</p> <p>This might be better explained by a counter-example - I maintain an app that prints two graphics as part of a print advertisement. They're stored in the database as <code>TopLogo</code> and <code>LowerLogo</code>, which I have to stop and double-check every time I use them because I'm expecting <code>top</code> to complement <code>bottom</code>, and <code>lower</code> should complement <code>upper</code>. </p> <p>There's some obvious examples that I think work well:</p> <p><code>client / server</code><br> <code>source / target</code> for copying/moving data or files from one variable to another<br> <code>minimum / maximum</code> </p> <p>but there's some concepts that just don't lend themselves to such neat naming schemes. For example, when paging through records, does 'last' mean 'final' or 'previous' ? I recently saw some code that used <code>firstPage</code>, <code>previousPage</code>, <code>nextPage</code> and <code>finalPage</code> to avoid the ambiuous <code>lastPage</code> completely, which I thought was very beat, hence this question.</p> <p>Do you have any particularly neat variable name pairs you'd care to share with us? (Bonus points if they're the same length, which makes the code so much neater in monospaced fonts.)</p>
[ { "answer_id": 215724, "author": "Dan Rosenstark", "author_id": 8047, "author_profile": "https://Stackoverflow.com/users/8047", "pm_score": 1, "selected": false, "text": "Connection" }, { "answer_id": 218553, "author": "onedaywhen", "author_id": 15354, "author_profile...
2008/10/18
[ "https://Stackoverflow.com/questions/215685", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5017/" ]
215,689
<p>I still haven't got my head around decorators in Python.</p> <p>I've already started using a lot of closures to do things like customize functions and classes in my coding.</p> <p>Eg.</p> <pre><code>class Node : def __init__(self,val,children) : self.val = val self.children = children def makeRunner(f) : def run(node) : f(node) for x in node.children : run(x) return run tree=Node(1,[Node(2,[]),Node(3,[Node(4,[]),Node(5,[])])]) def pp(n) : print "%s," % n.val printTree = makeRunner(pp) printTree(tree) </code></pre> <p>As far as I can see, decorators are just a different syntax for doing something similar. </p> <p>Instead of </p> <pre><code>def pp(n) : print "%s," % n.val printTree = makeRunner(pp) </code></pre> <p>I would write :</p> <pre><code>@makeRunner def printTree(n) : print "%s," % n.val </code></pre> <p>Is this all there is to decorators? Or is there a fundamental difference that I've missed? </p>
[ { "answer_id": 215782, "author": "tzot", "author_id": 6899, "author_profile": "https://Stackoverflow.com/users/6899", "pm_score": 3, "selected": false, "text": "def run(rootnode, func):\n def _run(node): # recursive internal function\n func(node)\n for x in node.children...
2008/10/18
[ "https://Stackoverflow.com/questions/215689", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8482/" ]
215,718
<p>How do I revert a modified file to its previous revision at a specific commit hash (which I determined via <a href="https://git-scm.com/docs/git-log" rel="noreferrer"><code>git log</code></a> and <a href="https://git-scm.com/docs/git-diff" rel="noreferrer"><code>git diff</code></a>)?</p>
[ { "answer_id": 35288, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 8, "selected": false, "text": "git checkout -- foo\n" }, { "answer_id": 35335, "author": "Aaron Maenpaa", "author_id": 2603, "author_...
2008/10/18
[ "https://Stackoverflow.com/questions/215718", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3410/" ]
215,719
<p>I'm following the <a href="http://www.asp.net/learn/mvc-videos/video-395.aspx" rel="nofollow noreferrer">ASP.Net MVC "TaskList" example video</a> and on clicking Run in Visual Studio (~14:00 min into the video) I'm getting the following error message in the browser:</p> <pre><code>Server Error in '/' Application. Bad IL format. Description: An unhandled exception occurred during the execution of the current webrequest. Please review the stack trace for more information about the error andwhere it originated in the code. Exception Details: System.BadImageFormatException: Bad IL format. Source Error: Line 12: ' (2) URL with parameters Line 13: ' (3) Parameter defaults Line 14: routes.MapRoute( _ Line 15: "Default", _ Line 16: "{controller}/{action}/{id}", _ Source File: C:\Users\...\TaskList\TaskList\Global.asax.vb Line: 14 Stack Trace: [BadImageFormatException: Bad IL format.] VB$AnonymousType_0`3..ctor(T0 controller, T1 action, T2 id) +0 TaskList.MvcApplication.RegisterRoutes(RouteCollection routes) in C:\Users\...\TaskList\TaskList\Global.asax.vb:14 TaskList.MvcApplication.Application_Start() in C:\Users\...\TaskList\TaskList\Global.asax.vb:23 Version Information: Microsoft .NET Framework Version:2.0.50727.1434; ASP.NET Version:2.0.50727.1434 </code></pre> <p>I've double-checked the code I've typed in, what am I missing?</p> <p>Thank you!</p> <p>Versions:</p> <ul> <li>ASP.Net MVC Beta (16th October 2008)</li> <li>Visual Studion 2008 (9.0.21022.8 RTM)</li> <li>Vista Ultimate SP1</li> <li>IIS 7.0.6000.16386</li> </ul>
[ { "answer_id": 216512, "author": "Nick Berardi", "author_id": 17, "author_profile": "https://Stackoverflow.com/users/17", "pm_score": 0, "selected": false, "text": "routes.MapRoute( _\n \"Default\", _\n \"{controller}/{action}/{id}\", _\n New With { .controller = \"Home\", .acti...
2008/10/18
[ "https://Stackoverflow.com/questions/215719", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5662/" ]
215,729
<p>What is the state of native SVG support in the most popular browsers in their latest releases?</p> <ul> <li>Internet explorer</li> <li>Firefox</li> <li>Opera</li> <li>Safari</li> <li>Chrome</li> <li>Konqueror</li> <li>Camino</li> </ul>
[ { "answer_id": 19298539, "author": "iconoclast", "author_id": 241142, "author_profile": "https://Stackoverflow.com/users/241142", "pm_score": 2, "selected": false, "text": "Time.now" } ]
2008/10/18
[ "https://Stackoverflow.com/questions/215729", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3153/" ]
215,735
<p>I am trying to draw a domain model or class diagram in UML for car dealership. I am stuck with how to present test drive in the model. One way is to have appointment class and then test-drive as sub class. A dealer also offers after-sale vehicle service so i could have appointment/booking class as super class and then vehicle service and test-drive as two sub classes.</p> <p>Another way is to have the customer class have a direct relationship with test drive class and vehicle service class under appointment class.</p> <p>A dealer also sells new and used cars and their parts.</p> <p>A dealer also offers finance for car sale.</p> <p>Would testdrive class have relationship with vehicle class or there is separate class for display and testdrive class?</p> <p>Another question is how do I show potential customers and their inquiries about sale and service in the model. A dealer wants to save details of potential customers if they allow for marketing purposes. Shall I have two classes: one for customers and one for potential customers or it can be achieved just by using an attribute in customer class?</p>
[ { "answer_id": 6307687, "author": "Novalis", "author_id": 778894, "author_profile": "https://Stackoverflow.com/users/778894", "pm_score": 0, "selected": false, "text": "-- What kind of entities you have in yor domain?\n-- If they are important for your system under desing, \n what kind...
2008/10/18
[ "https://Stackoverflow.com/questions/215735", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29312/" ]
215,741
<p>MTOM is the W3C Message Transmission Optimization Mechanism, a method of efficiently sending binary data to and from web services.</p> <p>How does it work in general?</p>
[ { "answer_id": 15572342, "author": "Jops", "author_id": 1551022, "author_profile": "https://Stackoverflow.com/users/1551022", "pm_score": 7, "selected": false, "text": "<soap:Envelope>\n <soap:Body>\n <tns:data>\n <xop:include href=\"SomeUniqueID-ThatLeadsToTheImage\...
2008/10/18
[ "https://Stackoverflow.com/questions/215741", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3153/" ]