qid
int64
4
19.1M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
376,557
<p>I have a class named Page with a private property currently called <code>_pageData</code> which stores all the information (such as title, content, keywords etc). </p> <p>However, this to me doesn't look so good when I refer to it <code>$this-&gt;_pageData</code>. I want to think of a better name, and I'd imagine there would probably be a standard or 'best practice' name/prefix/suffix for these sorts of things. I thought about '_assets'. </p> <p>May I ask what you have used in the past, an unambiguous name that hasn't made you down the track add some data to it and go "Oh no, now my array has data in it that's outside the scope of the variable name". This has happened to me a few times so I'd like to see what has been proven to work.</p>
[ { "answer_id": 376571, "author": "strager", "author_id": 39992, "author_profile": "https://Stackoverflow.com/users/39992", "pm_score": 3, "selected": true, "text": "class Page {\n public $title = '';\n public $keywords = array();\n public $content = '';\n // etc.\n}\n\n$page ...
2008/12/18
[ "https://Stackoverflow.com/questions/376557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31671/" ]
376,566
<p>In a file called index.asp, which is set up in IIS as a default document for the directory, I'm trying to determine via .asp VBScript if the page was called as the default document versus directly by name, i.e. I'm trying to distinguish between these two cases server-side:</p> <p><a href="http://someurl/" rel="nofollow noreferrer">http://someurl/</a></p> <p><a href="http://someurl/index.asp" rel="nofollow noreferrer">http://someurl/index.asp</a></p> <p>I know how to do this in ASP.NET, but the same "server variables" don't seem to be available. The server variables that do deal with the URL and script name (PATH_ INFO, SCRIPT_NAME, URL) all return "index.asp" regardless of which way the script is called. </p> <p>A Google search falls short on this one. Any ideas?</p>
[ { "answer_id": 376620, "author": "Diodeus - James MacFarlane", "author_id": 12579, "author_profile": "https://Stackoverflow.com/users/12579", "pm_score": 1, "selected": false, "text": "location.href" }, { "answer_id": 376929, "author": "rmdaustin", "author_id": 47260, ...
2008/12/18
[ "https://Stackoverflow.com/questions/376566", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47260/" ]
376,570
<p>Is there a best practice for instantiating / calling business logic layer service in a web app? I've got a large number services that I keep instantiating and then disposing for just one method call. </p> <p>Should these be implemented as providers? Or maybe accessed from a singleton?</p> <p>Example code:</p> <pre><code>void ShipProduct(){ ProductService service = new ProductService(); service.Ship(aProduct); } </code></pre> <p>Obviously it's a lot more complicated than that, I just don't know if I'm doing something wrong by creating new instances of these services everywhere.</p>
[ { "answer_id": 376575, "author": "Zachary Yates", "author_id": 8360, "author_profile": "https://Stackoverflow.com/users/8360", "pm_score": 2, "selected": false, "text": "Services.ProductService.Ship(aProduct)\n" }, { "answer_id": 376614, "author": "lomaxx", "author_id": 4...
2008/12/18
[ "https://Stackoverflow.com/questions/376570", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47261/" ]
376,582
<p>I'm having difficulty searching for this. How would I define an element in an XML schema file for XML that looks like this:</p> <pre><code>&lt;option value="test"&gt;sometext&lt;/option&gt; </code></pre> <p>I can't figure out how to define an element that is of type <code>xs:string</code> and also has an attribute. </p> <p>Here's what I've got so far:</p> <pre><code>&lt;xs:element name="option"&gt; &lt;xs:complexType&gt; &lt;xs:attribute name="value" type="xs:string" /&gt; &lt;/xs:complexType&gt; &lt;/xs:element&gt; </code></pre>
[ { "answer_id": 376713, "author": "David Norman", "author_id": 34502, "author_profile": "https://Stackoverflow.com/users/34502", "pm_score": 9, "selected": true, "text": " <xs:element name=\"option\" type=\"AttrElement\" />\n\n <xs:complexType name=\"AttrElement\">\n <xs:simpleConten...
2008/12/18
[ "https://Stackoverflow.com/questions/376582", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5291/" ]
376,598
<p>If I do something like this:</p> <pre><code>using (SqlCommand cmd = new SqlCommand("SELECT * FROM TBL")) { using (SqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { string s = reader.GetString(7); } } } </code></pre> <p>does the Read() call read the entire row into memory, or does the GetString(7) call mean that the reader only ever reads the data in column 7?</p>
[ { "answer_id": 6408341, "author": "jmoreno", "author_id": 234954, "author_profile": "https://Stackoverflow.com/users/234954", "pm_score": 1, "selected": false, "text": "select * from table" } ]
2008/12/18
[ "https://Stackoverflow.com/questions/376598", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14606/" ]
376,611
<p>I just don't know that, is there any technical reason for that? Is it more difficult to implement a compiler for a language with weak typing? What is it?</p>
[ { "answer_id": 376629, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": false, "text": "int a\n var a = 10; // a is probably a four byte int here\na = \"hello world\"; // now a is a 12 byte char array\n int a = 10...
2008/12/18
[ "https://Stackoverflow.com/questions/376611", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34134/" ]
376,622
<p>C#: How do you save a list of items like a Combobox to the .NET Settings file?</p>
[ { "answer_id": 376643, "author": "Zachary Yates", "author_id": 8360, "author_profile": "https://Stackoverflow.com/users/8360", "pm_score": 2, "selected": false, "text": "StringBuilder sb = new StringBuilder();\nforeach(var item in combo.Items){\n sb.Append(item.ToString() + \";\");\n}\n...
2008/12/18
[ "https://Stackoverflow.com/questions/376622", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
376,623
<p>I'm just wondering if there is a quick way to echo undefined variables without getting a warning? (I can change error reporting level but I don't want to.) The smallest I have so far is:</p> <p><code>isset($variable)?$variable:''</code></p> <p>I dislike this for a few reasons:</p> <ul> <li>It's a bit "wordy" and complex</li> <li><code>$variable</code> is repeated</li> <li>The echoing of a blank string always kind of annoys me.</li> <li>My variable names will probably be longer, eg <code>$arrayvar['parameter']</code></li> </ul>
[ { "answer_id": 376628, "author": "Eran Galperin", "author_id": 10585, "author_profile": "https://Stackoverflow.com/users/10585", "pm_score": 4, "selected": false, "text": "echo @$variable;\n" }, { "answer_id": 376641, "author": "Alexei Tenitski", "author_id": 45508, "...
2008/12/18
[ "https://Stackoverflow.com/questions/376623", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37947/" ]
376,642
<p>I'm not really sure how to title this question but basically I have an interface like this:</p> <pre><code>public interface IFoo { string ToCMD(); } </code></pre> <p>a couple of absract classes which implement IFoo like:</p> <pre><code>public abstract class Foo : IFoo { public abstract string ToCMD(); } public abstract class Bar : IFoo { public abstract string ToCMD(); } </code></pre> <p>then classes which inherit Foo and Bar:</p> <pre><code>public class FooClass1 : Foo { public override string ToCMD() {return "Test";} } ///there are about 10 foo classes. public class BarClass : Bar { public override string ToCMD() {return "BarClass";} } ///about the same for bar classes. </code></pre> <p>I am doing this so that when I have my custom list like:</p> <pre><code>public class Store&lt;T&gt; : List&lt;T&gt; where T : IFoo {} </code></pre> <p>I then can restrict the types that go in it but by having the interface it will still take any type of IFoo.</p> <p>Something like:</p> <pre><code>Store&lt;Foo&gt; store = new Store&lt;Foo&gt;(); //Only Foo types will work. store.Add(new FooClass1()); //Will compile. Store&lt;IFoo&gt; store = new Store&lt;IFoo&gt;(); //All IFoo types will work. store.Add(new FooClass1()); //Will compile. store.Add(new BarClass()); //Will compile. </code></pre> <p>My question is: Is this an ok way of going about this? or is there a better way?</p> <p>EDIT: Picture-> <img src="https://i.stack.imgur.com/RqPPj.jpg" alt="alt text"></p>
[ { "answer_id": 376650, "author": "gcores", "author_id": 40256, "author_profile": "https://Stackoverflow.com/users/40256", "pm_score": 1, "selected": false, "text": "public interface Foo : IFoo\n{\n}\n\n public interface Bar : IFoo\n{\n}\n" }, { "answer_id": 376651, "author":...
2008/12/18
[ "https://Stackoverflow.com/questions/376642", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6335/" ]
376,644
<p>When doing a Ajax call to an MVC action currently I have my javascript inside the View, not inside its own JS file.</p> <p>It is then very easy to do this:</p> <pre><code>var xhr = $.ajax({ url: '&lt;%= Url.Action("DisplayItem","Home") %&gt;/' + el1.siblings("input:hidden").val(), data: { ajax: "Y" }, cache: false, success: function(response) { displayMore(response, el1, xhr) } }); </code></pre> <p>...then including the URL in the ajax call using <code>Url.Action()</code> inside the JS is pretty easy. How could i move this do its own JS file when without hard coding the URL?</p>
[ { "answer_id": 376656, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 3, "selected": false, "text": "function doAjax( url, data, elem, callback )\n{\n return $.ajax({\n url: url,\n data: { ajax: data },\...
2008/12/18
[ "https://Stackoverflow.com/questions/376644", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29376/" ]
376,655
<p>I am having a problem setting the Authorize attribute Role value from a variable. The error message says it requires a const variable. When I create a const type variable it works fine but I am trying to load the value from the Web.Config file or anything else that will allow the end user to set this. I'm using integrated Windows authentication since this is an intranet only application.</p> <p>Is there a way to check the users role from a controller? I will use this in an if statement to authenticate instead of an attribute.</p> <pre><code>[Authorize(Roles = Config.GMPUser)] public ActionResult Index() { return View(); } </code></pre>
[ { "answer_id": 376670, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 3, "selected": true, "text": "User.InRole( \"RoleName\" ) var attributes = typeof(MyController).GetMethod(\"Index\")\n ...
2008/12/18
[ "https://Stackoverflow.com/questions/376655", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45509/" ]
376,657
<p>What's the best algorithm to find the smallest non zero positive value from a fixed number (in this case 3) of values or return 0 if there are no positive questions?</p> <p>My naive approach is below (in Delphi, but feel free to use whatever you like), but I think there's a more elegant way.</p> <pre><code>value1Temp := MaxInt; value2Temp := MaxInt; value3Temp := MaxInt; if ( value1T &gt; 0) then value1Temp := value1; if ( value2 &gt; 0) then value2Temp := value2; if ( value3 &gt; 0) then value3Temp := value3; Result := Min(value1Temp, Min(value2Temp, value3Temp)); if Result = MaxInt then Result := 0; </code></pre> <p><strong>Edit:</strong> Sorry added what's needed if there are no positive numbers. I thought I had it in there before, but must have missed it.</p>
[ { "answer_id": 376666, "author": "Adam Pierce", "author_id": 5324, "author_profile": "https://Stackoverflow.com/users/5324", "pm_score": 2, "selected": false, "text": "int maxPositiveValue(int *number, int listSize)\n{\n int i, result = 0;\n\n for(i = 0; i < listSize; i++)\n {\n...
2008/12/18
[ "https://Stackoverflow.com/questions/376657", "https://Stackoverflow.com", "https://Stackoverflow.com/users/233/" ]
376,677
<p>I'm currently designing a database for a project. Now I'm debating with myself whether I have to create a look-up table for example 'civil status' data which can only contain fixed values like Single, Married, Separated, Widow/Widower. I'm pretty sure that no other values will be added in the future. Should I put these on a separate table or just hardcode the values on the program code?</p>
[ { "answer_id": 376902, "author": "Ben Dempsey", "author_id": 10987, "author_profile": "https://Stackoverflow.com/users/10987", "pm_score": 0, "selected": false, "text": "Select * from People where MarriageStatus = \"single\" or is it \"Single\", or is it \"SINGLE\"\n" } ]
2008/12/18
[ "https://Stackoverflow.com/questions/376677", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40538/" ]
376,683
<p><strong>Problem:</strong> I am looking for a way to run a test that is able to disambiguate between select controls that have the same value in more than one place.</p> <p><strong>Example:</strong> </p> <p>I am trying to choose the third "monday" from a select control</p> <pre><code>ie.select_list( :id , 'choose-day' ).set( '-monday' ); </code></pre> <p>where the select control has a kind of "outline" format in the control itself:</p> <pre><code>alice -monday -tuesday bob -monday -tuesday charlie -monday -tuesday </code></pre> <p>Given that the text is identical (and I do not know what the option values are ahead of time) is there a way to code the test such that the monday under charlie is the one that gets selected?</p>
[ { "answer_id": 376957, "author": "Moss Collum", "author_id": 13210, "author_profile": "https://Stackoverflow.com/users/13210", "pm_score": 3, "selected": true, "text": "ie.select_list( :id , 'choose-day' ).select_value( whatever_the_value_was );\n" } ]
2008/12/18
[ "https://Stackoverflow.com/questions/376683", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42223/" ]
376,708
<p>When I have entities in my domain with lists of things, should they be exposed as ILists or IEnumerables? E.g. Order has a bunch of OrderLines. </p>
[ { "answer_id": 376721, "author": "Matt Hamilton", "author_id": 615, "author_profile": "https://Stackoverflow.com/users/615", "pm_score": 9, "selected": true, "text": "IEnumerable<T> IList<T> IList<OrderLine> IEnumerable<OrderLine>" } ]
2008/12/18
[ "https://Stackoverflow.com/questions/376708", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43836/" ]
376,717
<p>Considering there are so many draconian firewalls in the world, is there any reason I shouldn't run server software on port 80 to guarantee greatest possible accessibility? It seems that the most common firewall exception is to allow outbound connections on port 80. I understand that any sort of packet inspection would still block my non-HTTP traffic but if that is the case I'm sure the firewall wouldn't have any other open outgoing ports anyway.</p> <p>If the server already has a webserver on port 80 is it possible to use some sort of virtual host listening on port 80 (i.e. myDomain.com:80 <em>and</em> myApp.myDomain.com:80 on the same machine)?</p>
[ { "answer_id": 376768, "author": "Norman Ramsey", "author_id": 41661, "author_profile": "https://Stackoverflow.com/users/41661", "pm_score": 0, "selected": false, "text": "/etc/init.d/apache stop sshd" } ]
2008/12/18
[ "https://Stackoverflow.com/questions/376717", "https://Stackoverflow.com", "https://Stackoverflow.com/users/327/" ]
376,723
<p>I'm having trouble capturing this data:</p> <pre><code> &lt;tr&gt; &lt;td&gt;&lt;span class="bodytext"&gt;&lt;b&gt;Contact:&lt;/b&gt;&lt;b&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style='font-size:10.0pt;font-family:Verdana; mso-bidi-font-family:Arial'&gt;&lt;b&gt; &lt;/b&gt; &lt;span class="bodytext"&gt;John Doe&lt;/span&gt; &lt;/span&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;span class="bodytext"&gt;PO Box 2112&lt;/span&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;span class="bodytext"&gt;&lt;/span&gt;&lt;/td&gt; &lt;/tr&gt; &lt;!--********************************************************* --&gt; &lt;tr&gt; &lt;td&gt;&lt;span class="bodytext"&gt;&lt;/span&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;span class="bodytext"&gt;JOHAN&lt;/span&gt; NSW 9700&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;strong&gt;Phone:&lt;/strong&gt; 02 9999 9999 &lt;/td&gt; &lt;/tr&gt; </code></pre> <p>Basically, I want to grab everything after "Contact:" and before "Phone:" minus the HTML; however these two designations may not always exist so I need to really grab everything between the two colons (:) that isn't located inside a HTML tag. The number of <code>&lt;span class="bodytext"&gt;***data***&lt;/span&gt;</code> may actually vary so I need some sort of loop for matching these.</p> <p>I prefer to use regular expressions as I <em>could</em> probably do this using loops and string matches.</p> <p>Also, I'd like to know the syntax for non-matching groups in PHP regex.</p> <p>Any help would be greatly appreciated!</p>
[ { "answer_id": 376746, "author": "Jan Goyvaerts", "author_id": 33358, "author_profile": "https://Stackoverflow.com/users/33358", "pm_score": 2, "selected": false, "text": "$text = preg_replace('/<[^<>]+>/', '', $html);\n if (preg_match('/Contact:(.*?)Phone:/s', $text, $regs)) {\n $resul...
2008/12/18
[ "https://Stackoverflow.com/questions/376723", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24416/" ]
376,732
<p>The Zend Framework based site I have been working on is now being migrated to its production server. This server turns out to be nginx (surprise!). Naturally the site does not work correctly as it was developed on Apache and relies on an htaccess file. </p> <p>My question is... anyone have any experience with this? Any ideas on how to translate what the htaccess file does to an nginx.conf file? I'm researching this but am hoping someone already has experience with this. Thanks!</p> <p>EDIT: This is the current htaccess:</p> <pre><code>RewriteEngine On RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ - [NC,L] RewriteRule ^.*$ /index.php [NC,L] </code></pre>
[ { "answer_id": 376743, "author": "mooware", "author_id": 35951, "author_profile": "https://Stackoverflow.com/users/35951", "pm_score": 4, "selected": false, "text": "server {\n listen 80;\n server_name servername.com;\n\n root /var/www/zendapp/public;\n\n location / {\n index inde...
2008/12/18
[ "https://Stackoverflow.com/questions/376732", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11252/" ]
376,738
<p>I'm writing a PHP application with testability in mind, so my classes always ask in their constructors for the "collaborator objects" they depend on, in respect to the Dependency Injection pattern.</p> <p>That way, I'm able to pass in mocks or test implementations in my unit tests.</p> <p>What I want to achieve though, is to be able to instantiate a class with null values passed to its constructor arguments, in order to trigger a fallback mechanism which instantiates a default implementation class for each collaborator.</p> <p>Because object-type parameters cannot be given a default value in PHP, I have to do it inside the constructor. The following code is an example of the approach I'm currently using :</p> <pre><code>class Engine { private $loader; private $logger; public function __construct(ResourceLoader $loader = null, Logger $logger = null) { if ($loader == null) $loader = new DefaultResourceLoader; if ($logger == null) $logger = new DefaultLogger; $this-&gt;loader = $loader; $this-&gt;logger = $logger; } } </code></pre> <p>What do you think of this ? Should I use an IoC container instead or is there another way of giving object-type arguments a default value ?</p>
[ { "answer_id": 31315229, "author": "Victor Bocharsky", "author_id": 3190190, "author_profile": "https://Stackoverflow.com/users/3190190", "pm_score": 0, "selected": false, "text": "$logger = ValueResolver::resolve($logger, new DefaultLogger);\n use LapaLabs\\ValueResolver\\Resolver\\Valu...
2008/12/18
[ "https://Stackoverflow.com/questions/376738", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38072/" ]
376,751
<p>On top of my head, especially for C/Linux developer:</p> <ul> <li><a href="http://petdance.com/ack/" rel="nofollow noreferrer">ack</a></li> <li><a href="http://git.fishsoup.net/cgit/git-bz/plain/git-bz" rel="nofollow noreferrer">git-bz</a></li> <li><a href="http://schlueters.de/colorgcc.html" rel="nofollow noreferrer">colorgcc</a></li> <li><a href="http://colordiff.sourceforge.net/" rel="nofollow noreferrer">colordiff</a></li> <li><a href="https://thomas.apestaart.org/moap/trac" rel="nofollow noreferrer">moap</a> and <a href="http://svn.gnome.org/svn/releng/trunk/tools/prepare-ChangeLog.pl" rel="nofollow noreferrer">prepare-ChangeLog</a></li> </ul> <p>Is there some tool/script you couldn't work without, but that you feel others don't know so much?</p> <p>For instance, I just found:</p> <ul> <li><a href="http://cppcheck.wiki.sourceforge.net/" rel="nofollow noreferrer">cppcheck</a></li> </ul>
[ { "answer_id": 376859, "author": "Filip Dupanović", "author_id": 44041, "author_profile": "https://Stackoverflow.com/users/44041", "pm_score": 0, "selected": false, "text": "- ANT\n- Mylyn\n- TortoiseSVN\n- firebug (think console too!)\n- TextMate\n" } ]
2008/12/18
[ "https://Stackoverflow.com/questions/376751", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1277510/" ]
376,762
<p>I am running a query on Sybase ASE that produces a <code>ResultSet</code> that I then traverse and write the contents out to a file. Sometimes, this will throw a <code>NullPointerException</code>, stating that the <code>ResultSet</code> is <code>null</code>. However, it will do this after printing out one or two records. Other times, with the same exact input, I will receive no errors.</p> <p>I have been unable to consistently produce this error. The error message is pointing to a line:</p> <pre><code>output.print(rs.getString(1)); </code></pre> <p>It appears to happen when the query takes a little longer to run, for some reason. The recordset returns thus far have been very small (4 to 7 records). Sometimes I'll have to run the app 3 or 4 times, then the errors will just stop, as though the query was getting "warmed up". I've run the query manually and there doesn't appear to be any performance problems.</p> <p>Thanks again!</p>
[ { "answer_id": 376814, "author": "Paul Tomblin", "author_id": 3333, "author_profile": "https://Stackoverflow.com/users/3333", "pm_score": 2, "selected": false, "text": "preparedStatement.setLong(1, primaryKey);\nResultSet rs = preparedStatement.executeQuery();\nwhile (rs.next())\n{\n St...
2008/12/18
[ "https://Stackoverflow.com/questions/376762", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
376,773
<p>I begin a transaction, which is to insert several records into a table. Can I select the latest inserted record out of the database before the transaction commit?</p>
[ { "answer_id": 2656640, "author": "Noah", "author_id": 12113, "author_profile": "https://Stackoverflow.com/users/12113", "pm_score": 3, "selected": false, "text": "SQLite version 3.6.23\nEnter \".help\" for instructions\nEnter SQL statements terminated with a \";\"\n\nsqlite> create tabl...
2008/12/18
[ "https://Stackoverflow.com/questions/376773", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26404/" ]
376,785
<p>Delphi has a $WARN compiler directive that allows one to selectively enable or disable specific warnings. The Delphi 2009 help file describes the syntax:</p> <pre><code>{$WARN identifier ON|OFF} </code></pre> <p>But it only lists the identifiers for 6 warnings.</p> <p>I'd like to have a complete list of all the warning identifiers. In particular, I want to know the identifiers for the implicit string cast warnings W1057 and W1058 in Delphi 2009.</p> <p>I managed to guess the one for implicit Ansi->Unicode casts (W1057):</p> <pre><code>{$WARN IMPLICIT_STRING_CAST OFF} </code></pre> <p>Googling for that found me the other one:</p> <pre><code>{$WARN IMPLICIT_STRING_CAST_LOSS OFF} </code></pre> <p>Though that solves my immediate need, I'd still like to know the complete list of warning identifiers. Stuff like this should be documented.</p>
[ { "answer_id": 377034, "author": "Jan Goyvaerts", "author_id": 33358, "author_profile": "https://Stackoverflow.com/users/33358", "pm_score": 6, "selected": false, "text": "{$WARN ASG_TO_TYPED_CONST OFF} {$WARN BAD_GLOBAL_SYMBOL OFF} {$WARN BOUNDS_ERROR OFF} {$WARN CASE_LABEL_RANGE OFF} {...
2008/12/18
[ "https://Stackoverflow.com/questions/376785", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33358/" ]
376,786
<p>The code below continues many lines until it ends with a expected /veotherwise /vechoose. I started working on a development firm a little ago where they use this html version called vhtml. I have search the web but it brings different definitions for vhtml. I have seen some posts in Joomla about vhtml but they don't look like the code below. I was expecting to get a pointer on how to understand the language. </p> <p>It looks very similar to normal html with even very similar commands, or maybe smalltalk. But I just can decipher it. Any help will be appreciated. Please post comments if you want more information.</p> <pre><code>&lt;vechoose&gt; &lt;vewhen criteria='isPortalEdit'&gt; widget: practices-landing-page &lt;/vewhen&gt; &lt;veotherwise&gt; &lt;veinclude src='private/webportal/webtemplate-content.vhtml'&gt; &lt;vesection name='content-body'&gt; &lt;% // Determine portlet visibility %&gt; &lt;vecalc expression='isEmpty = false' output='none' /&gt; &lt;vechoose&gt; &lt;vewhen criteria='isEmpty'&gt; &lt;veif criteria='portlet.ifEmptyDo == "Hide"'&gt; &lt;script&gt;getTag( 'portlet_&lt;%=portlet.order%&gt;' ).style.display = "none";&lt;/script&gt; &lt;/veif&gt; &lt;veif criteria='portlet.ifEmptyDo == "Show Message"'&gt; &lt;%#portlet.ifEmptyMessage%&gt; &lt;/veif&gt; &lt;/vewhen&gt; ... </code></pre>
[ { "answer_id": 377034, "author": "Jan Goyvaerts", "author_id": 33358, "author_profile": "https://Stackoverflow.com/users/33358", "pm_score": 6, "selected": false, "text": "{$WARN ASG_TO_TYPED_CONST OFF} {$WARN BAD_GLOBAL_SYMBOL OFF} {$WARN BOUNDS_ERROR OFF} {$WARN CASE_LABEL_RANGE OFF} {...
2008/12/18
[ "https://Stackoverflow.com/questions/376786", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47222/" ]
376,793
<p>Can someone explain to me why my code:</p> <pre><code>string messageBody = "abc\n" + stringFromDatabaseProcedure; </code></pre> <p>where valueFromDatabaseProcedure is not a value from the SQL database entered as </p> <pre><code>'line1\nline2' </code></pre> <p>results in the string:</p> <pre><code>"abc\nline1\\nline2" </code></pre> <p>This has resulted in me scratching my head somewhat.</p> <p>I am using ASP.NET 1.1.</p> <p><strong>To clarify,</strong> </p> <p>I am creating string that I need to go into the body of an email on form submit. I mention ASP.NET 1.1 as I do not get the same result using .NET 2.0 in a console app.</p> <p>All I am doing is adding the strings and when I view the messageBody string I can see that it has escaped the value string.</p> <p><strong>Update</strong> What is not helping me at all is that Outlook is not showing the \n in a text email correctly (unless you reply of forward it). An online mail viewer (even the Exchange webmail) shows \n as a new line as it should.</p>
[ { "answer_id": 376800, "author": "George Stocker", "author_id": 16587, "author_profile": "https://Stackoverflow.com/users/16587", "pm_score": 0, "selected": false, "text": "<br /> \\n string value = \"line1<br />line2\";\nstring messageBody = \"abc<br />\" + value;\n string value = \"lin...
2008/12/18
[ "https://Stackoverflow.com/questions/376793", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13813/" ]
376,798
<p>I inherited an application which uses a java properties file to define configuration parameters such as database name. </p> <p>There is a class called MyAppProps that looks like this:</p> <pre><code>public class MyAppProps { protected static final String PROP_FILENAME = "myapp.properties"; protected static Properties myAppProps = null; public static final String DATABASE_NAME = "database_name"; public static final String DATABASE_USER = "database_user"; // etc... protected static void init() throws MyAppException { try { Classloader loader = MyAppException.class.getClassLoader(); InputStream is = loader.getResourceAsStream(PROP_FILENAME); myAppProps = new Properties(); myAppProps.load(is); } catch (Exception e) { threw new MyAppException(e.getMessage()); } } protected static String getProperty(String name) throws MyAppException { if (props==null) { throw new MyAppException("Properties was not initialized properly."); } return props.getProperty(name); } } </code></pre> <p>Other classes which need to get property values contain code such as:</p> <pre><code>String dbname = MyAppProps.getProperty(MyAppProps.DATABASE_NAME); </code></pre> <p>Of course, before the first call to MyAppProps.getProperty, MyAppProps needs to be initialized like this:</p> <pre><code>MyAppProps.init(); </code></pre> <p>I don't like the fact that <code>init()</code> needs to be called. Shouldn't the initialization take place in a static initialization block or in a private constructor?</p> <p>Besides for that, something else seems wrong with the code, and I can't quite put my finger on it. Are properties instances typically wrapped in a customized class? Is there anything else here that is wrong?</p>
[ { "answer_id": 376878, "author": "krosenvold", "author_id": 23691, "author_profile": "https://Stackoverflow.com/users/23691", "pm_score": 3, "selected": false, "text": "private static final String DATABASE_NAME = \"database_name\"\nprivate static final String DATABASE_USER = \"database_u...
2008/12/18
[ "https://Stackoverflow.com/questions/376798", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
376,812
<p>This is my code:</p> <pre class="lang-hs prettyprint-override"><code>type HoraAtendimento = (String, Int, Int) htmlHAtendimento :: [HoraAtendimento] -&gt; Html htmlHAtendimento [] = toHtml "" htmlHAtendimento ((da,hia,hfa):[]) = toHtml da +++ "feira " +++ show hia +++ "h - " +++ show hfa +++ "h" htmlHAtendimento ((da,hia,hfa):r) = toHtml da +++ "feira " +++ show hia +++ "h - " +++ show hfa +++ "h, " +++ htmlHAtendimento r </code></pre> <p>I'm looking for a way to use the map function and get rid of this recursive function. Is that possible and if so, how do I do it?</p>
[ { "answer_id": 376862, "author": "Apocalisp", "author_id": 3434, "author_profile": "https://Stackoverflow.com/users/3434", "pm_score": 5, "selected": true, "text": "map (a -> b) -> [a] -> [b] foldr htmlHAtendimento :: [HoraAtendimento] -> Html\nhtmlHAtendimento [] = toHtml \"\"\nhtmlHAte...
2008/12/18
[ "https://Stackoverflow.com/questions/376812", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40480/" ]
376,840
<p>I'm using Java and I'm coding a chess engine.</p> <p>I'm trying to find the index of the first 1 bit and the index of the last 1 bit in a byte.</p> <p>I'm currently using Long.numberOfTrailingZeros() (or something like that) in Java, and would like to emulate that functionality, except with bytes.</p> <p>Would it be something like:</p> <pre><code>byte b = 0b011000101; int firstOneBit = bitCount ((b &amp; -b) - 1); </code></pre> <p>If so, how would I implement bitCount relatively efficiently. I don't mind good explainations, please don't just give me code.</p>
[ { "answer_id": 376855, "author": "starmole", "author_id": 35706, "author_profile": "https://Stackoverflow.com/users/35706", "pm_score": 2, "selected": false, "text": "unsigned int bitcount ( unsigned int i ) {\nunsigned int r = 0;\nwhile ( i ) { r+=i&1; i>>=1; } /* bit shift is >>> in ja...
2008/12/18
[ "https://Stackoverflow.com/questions/376840", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13852/" ]
376,844
<p>I've been sharing image lists across multiple forms in Delphi for years now. I have a TImageList on the main form of my app and then I have other forms that have components where I set the Images property to the image list from the main form (e.g. MyMainForm.MyImageList) at design time.</p> <p>The problem I'm having is that randomly the Images property gets cleared on those forms that reference the image list on the main form.</p> <p>This seemed to have only start recently, but I haven't been able to pinpoint the exact cause yet. I can't seem to find a way to reproduce the issue at will; it just seems to happen randomly. I did notice it happens right when a form is opened. </p> <p>One thing that I did change recently in Delphi is I enabled the Autosave Project desktop and symbols feature. So now when I open this project it always remembers what forms were open. So because this issue happens when a form is opened, and because it now reopens all forms that were opened the last time the project was opened, it happens more often.</p> <p>We have a few developers working on this project, and we are using SVN for version control. One issue that enabling the Autosave Project desktop and symbols feature has led to is that when we do an SNV update on the project, the symbol file can become invalid (because we don't have the symbol file under version control). This just leads to an error message from Delphi, but other than that it seems harmless. We just recompile the project and it fixes the symbol file.</p> <p>Btw, I'm using Delphi 7.</p> <p>If you have questions or want clarifications, leave a comment, and I'll update the question.</p>
[ { "answer_id": 377347, "author": "DiGi", "author_id": 12042, "author_profile": "https://Stackoverflow.com/users/12042", "pm_score": 1, "selected": false, "text": " fMainForm in 'fMainForm.pas' {MainForm},\n" } ]
2008/12/18
[ "https://Stackoverflow.com/questions/376844", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62/" ]
376,851
<p>I am using the standard outputcache tag in my MVC app which works great but I need to force it to be dumped at certain times. How do I achieve this? The page that gets cached is built from a very simple route {Controller}/{PageName} - so most pages are something like this: /Pages/About-Us</p> <p>Here is the output cache tag that is at the top of my .aspx view page just to be clear:</p> <pre><code>&lt;@ OutputCache Duration="100" VaryByParam="None" %&gt; </code></pre> <p>So in another action on the same controller where content is updated I need to dump this cache, or even all of it - it's a very small app so not a big deal deal to dump all cached items.</p>
[ { "answer_id": 376875, "author": "Zachary Yates", "author_id": 8360, "author_profile": "https://Stackoverflow.com/users/8360", "pm_score": 4, "selected": false, "text": "HttpResponse.RemoveOutputCacheItem()" }, { "answer_id": 376899, "author": "Slee", "author_id": 34548, ...
2008/12/18
[ "https://Stackoverflow.com/questions/376851", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34548/" ]
376,910
<p>I have a ListBox and I want to add a context menu to each item in the list. I've seen the "solution" to have the right click select an item and suppress the context menu if on white space, but this solution feels dirty. </p> <p>Does anyone know a better way?</p>
[ { "answer_id": 378056, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 5, "selected": false, "text": "#region Private Members\nprivate ContextMenuStrip listboxContextMenu;\n#endregion\n\nprivate void Form1_Load( object sender, E...
2008/12/18
[ "https://Stackoverflow.com/questions/376910", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40887/" ]
376,911
<p>I'm new to both ASP.Net MVC and jQuery and what I'm trying to do is make a form that either adds a new RockBand or updates an existing RockBand based on if the rockbandid is an empty guid or not. I figured now is a good time to get rolling with jQuery. So the first step is to make a list of bands and put an edit link next to it. If the user clicks on the edit link I want to alter the value of the input box and the hidden field. The code below is the first step, trying to set the value of the input box (with a fixed string for the moment but eventually would be whatever the band name is). However I get an Object Required Error when I do so. (The jQuery include is on the Site.Master)</p> <pre><code>&lt;asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server"&gt; &lt;script type="text/javascript"&gt; function fillinbandname(thebandname) { $('#bandname').val(thebandname); } &lt;/script&gt; &lt;ul&gt; &lt;%foreach (DomainModel.RockBand rockband in ViewData.Model) %&gt; &lt;%{ %&gt; &lt;li&gt;&lt;%=rockband.BandName %&gt; &lt;a href='javascript:fillinbandname("somesamplevalue");'&gt;edit&lt;/a&gt;&lt;/li&gt; &lt;%} %&gt;&lt;/ul&gt; &lt;%Html.BeginForm("MakeOrUpdateRockBand", "Bands", FormMethod.Post); %&gt; &lt;input type="text" id="bandname" name="bandname" maxlength="30" /&gt; &lt;input type="hidden" id="bandid" name="bandid" value="00000000-0000-0000-0000-000000000000" /&gt; &lt;input type="submit" value="Add New Band" /&gt; &lt;%Html.EndForm(); %&gt; &lt;/asp:Content&gt; </code></pre> <p>It feels like I'm soooo close...but am missing something fundamental.</p>
[ { "answer_id": 378056, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 5, "selected": false, "text": "#region Private Members\nprivate ContextMenuStrip listboxContextMenu;\n#endregion\n\nprivate void Form1_Load( object sender, E...
2008/12/18
[ "https://Stackoverflow.com/questions/376911", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1975/" ]
376,915
<p>I recently took my Db initiating code out of the __construct of my Page class and placed it just after I initiate the Page class. I removed it from within the Page class because I want to be able to access it from anywhere (other classes for example). It also takes server, username, password and database arguments to it when initiated, and I don't wish to enter these every time.</p> <p>Is there a way I can access it from under the Page class now? I've tried a few methods, even global (which I have been told is an awful way to do things) and so far no avail. I am still new to OO, but I am teaching myself as best as I can.</p> <p>Should I make it a static class? Will this affect the lazy connector to the Db I have setup?</p> <p>Any help would be much appreciated.</p> <p>Thank you</p> <p><strong>[EDIT]</strong></p> <p>Similar Question: <a href="https://stackoverflow.com/questions/130878/global-or-singleton-for-database-connection">Global or Singleton for database connection?</a></p>
[ { "answer_id": 376920, "author": "nickf", "author_id": 9021, "author_profile": "https://Stackoverflow.com/users/9021", "pm_score": 0, "selected": false, "text": "$db =& JFactory::getDBO();\n" }, { "answer_id": 377338, "author": "troelskn", "author_id": 18180, "author_...
2008/12/18
[ "https://Stackoverflow.com/questions/376915", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31671/" ]
376,921
<p>What is the difference between the scalar and list contexts in Perl and does this have any parallel in other languages such as Java or Javascript? </p>
[ { "answer_id": 376932, "author": "nicerobot", "author_id": 23056, "author_profile": "https://Stackoverflow.com/users/23056", "pm_score": 0, "selected": false, "text": "sub = {\n return if ( ! defined wantarray ); # void: just return (doesn't make sense for =)\n return @_ if ( wantarray...
2008/12/18
[ "https://Stackoverflow.com/questions/376921", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47145/" ]
376,948
<p>I was coding with 2 CStringList objects. Each has its own data, for eg one has name and other the phoneno, and both are in sync, i.e, if there is a phoneno there is a name and viceversa.</p> <p>Now, i have 2 combobox in which i show the names and the respective phonenos. The name combobox is sorted, hence the sync between the two goes for a toss. hence for sorting i did the following:</p> <hr> <pre><code>int aComboElementNo = myNameComboBox.GetCount(); if( aComboElementNo &gt;= 1 ) { for( int aIndex = 0; aIndex &lt; aComboElementNo; aIndex++ ) { CString aTempStr; // Getting the string in the combobox myNameComboBox.GetLBText( aIndex, aTempStr ); // Getting the position where the name is present in the list POSITION aPos = aNameList.Find( aTempStr ); // setting the appropriate phoneno in the 2nd combobox myPhoneComboBox.AddString( aPhoneList.GetAt( aPos ) ); } } </code></pre> <hr> <p>When i executed this i got the names in the myPhoneComboBox rather than the phonenos.</p> <p>Now i have 2 qns:</p> <ol> <li><p>how come i get the name present in namelist when i am accessing the phonelist? isn't it a breach, as i am able to access some other variables data using some other variable.</p></li> <li><p>how to sort the 2nd list.</p></li> </ol>
[ { "answer_id": 395656, "author": "baash05", "author_id": 31325, "author_profile": "https://Stackoverflow.com/users/31325", "pm_score": 0, "selected": false, "text": "int aComboElementNo = myNameComboBox.GetCount();\nfor( int aIndex = 0; aIndex < aComboElementNo; aIndex++ )\n{\n int na...
2008/12/18
[ "https://Stackoverflow.com/questions/376948", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41518/" ]
376,953
<p>I am a beginner at SQL Server and I have a question about how best to do this.</p> <p>I have a table that looks like this:</p> <p>ID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Parent&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Level<br> 1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NULL&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0<br> 2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1<br> 3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1<br> 4&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2<br> 5&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2<br> 6&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2<br> 7&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2<br> 8&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;5&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4<br> 9&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3<br> 10&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;6&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3<br> 11&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;6&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3<br></p> <p>As you can see, all the entries have a Parent and a Level and the database is organized in a tree structure. There are some entries where the Level is set incorrectly such as entry ID #8. The Parent of 8 is 5 and ID 5 has a level of 2 so the level of 8 should be 3 and not 4. There are many incorrect Level values in my table and I'm not sure how to fix this. So far I have this:</p> <p>UPDATE myTable<br> SET level=level-1<br> FROM myTable<br> WHERE ???;<br></p> <p>I am not sure how to fill in the WHERE part or whether this is the best way to do this. Any suggestions are gladly appreciated.</p>
[ { "answer_id": 376974, "author": "LeppyR64", "author_id": 16592, "author_profile": "https://Stackoverflow.com/users/16592", "pm_score": 2, "selected": false, "text": "select\n a.id,\n a.level,\n b.level as parentlevel\nfrom\n tablename a\n join tablename b on a.parent = b.id\nwhere\...
2008/12/18
[ "https://Stackoverflow.com/questions/376953", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47299/" ]
376,954
<p>I'm using EPIC, but it seems to have some drawbacks. Are there any other Perl plugins for Eclipse?</p>
[ { "answer_id": 3305135, "author": "MJ.", "author_id": 243720, "author_profile": "https://Stackoverflow.com/users/243720", "pm_score": 0, "selected": false, "text": "use base qw/ Class::DBI /;\n" } ]
2008/12/18
[ "https://Stackoverflow.com/questions/376954", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47145/" ]
376,959
<p>Let's say I have the following function:</p> <pre><code>sumAll :: [(Int,Int)] -&gt; Int sumAll xs = foldr (+) 0 (map f xs) where f (x,y) = x+y </code></pre> <p>The result of <code>sumAll [(1,1),(2,2),(3,3)]</code> will be <code>12</code>.</p> <p>What I don't understand is where the <code>(x,y)</code> values are coming from. Well, I know they come from the <code>xs</code> variable but I don't understand how. I mean, doing the code above directly without the where keyword, it would be something like this:</p> <pre><code>sumAll xs = foldr (+) 0 (map (\(x,y) -&gt; x+y) xs) </code></pre> <p>And I can't understand, in the top code, how does the <code>f</code> variable and <code>(x,y)</code> variables represent the <code>(\(x,y) -&gt; x+y)</code> lambda expression.</p>
[ { "answer_id": 376983, "author": "Akusete", "author_id": 40175, "author_profile": "https://Stackoverflow.com/users/40175", "pm_score": 4, "selected": true, "text": "sumAll :: [(Int,Int)] -> Int\nsumAll xs = foldr (+) 0 (map myFunctionF xs)\n\nmyFunctionF :: (Int,Int) -> Int\nmyFunctionF ...
2008/12/18
[ "https://Stackoverflow.com/questions/376959", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40480/" ]
376,965
<p>What's the best way to view the data that LoadPostData event is loading to the controls in ASP.NET? </p>
[ { "answer_id": 377022, "author": "Strelok", "author_id": 2788, "author_profile": "https://Stackoverflow.com/users/2788", "pm_score": 3, "selected": true, "text": "HttpContext.Current.Request.Form" }, { "answer_id": 5759942, "author": "duozmo", "author_id": 134610, "au...
2008/12/18
[ "https://Stackoverflow.com/questions/376965", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5232/" ]
376,966
<p>Is it possible to have a C static library API, which uses C++ internally and hide this from users of the library?</p> <p>I have writen a portable C++ library I wish to statically link to an iPhone application.</p> <p>I have created an Xcode project using the Max OS X 'static library' template, and copied the source across, as well as writing a C wapper (to deal with exceptions) using (extern "C").</p> <p>I am trying to use the generated library (.a file) in another Cocoa iPhone application.</p> <p>Everything works well if the I use (.mm) extentions on the calling ObjectiveC file and (.cpp) on the implementation class in the library. </p> <p>But I get unresolved symbols on linking when I try and change the wrapper file to a (.c) extention, even though all the wrapper function files are only C functions.</p> <p>Just becuase C++ is used internally in a library, does it mean that externally it still must be treated as a C++ program. Is there not anyway to enforce this abstraction?</p> <p><strong>Edit:</strong> Thanks for the replies,</p> <p>I had been using extern "C", I was just unsure about what configurations where needed in the calling project. ie. if the calling projected would require to know if it used C++ or could be ignorant and think its a purely C library.</p> <p>It would seem I cannot, and I must use (.mm) files on my ObjectiveC classes.</p>
[ { "answer_id": 376987, "author": "coppro", "author_id": 16855, "author_profile": "https://Stackoverflow.com/users/16855", "pm_score": 2, "selected": false, "text": "extern \"C\" extern \"C\" __cplusplus extern \"C\"" }, { "answer_id": 377005, "author": "Martin York", "aut...
2008/12/18
[ "https://Stackoverflow.com/questions/376966", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40175/" ]
376,968
<p>Suppose I have a variable of type Int = 08, how can I convert this to String keeping the leading zero?</p> <p>For instance:</p> <pre><code>v :: Int v = 08 show v </code></pre> <p>Output: 8</p> <p>I want the output to be "08".</p> <p>Is this possible?</p>
[ { "answer_id": 376982, "author": "mipadi", "author_id": 28804, "author_profile": "https://Stackoverflow.com/users/28804", "pm_score": 5, "selected": false, "text": "Text.Printf.printf printf \"%02d\" v\n Text.Printf.printf" }, { "answer_id": 377061, "author": "Adeel Ansari", ...
2008/12/18
[ "https://Stackoverflow.com/questions/376968", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40480/" ]
376,979
<p>If you are going to start the development of an API for your web application. Is there any kind of guidelines, best practices or standard to build web services. I have seen a few discussions in this topic and I will like to get more information. </p> <p>At least get pointers on where to get the information.</p> <p>Thanks in advance.</p>
[ { "answer_id": 379039, "author": "Rob Williams", "author_id": 26682, "author_profile": "https://Stackoverflow.com/users/26682", "pm_score": 1, "selected": false, "text": "web = transported over HTTP(S)\nservice = remote procedure call (RPC)\n" } ]
2008/12/18
[ "https://Stackoverflow.com/questions/376979", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47222/" ]
376,988
<p>I remember reading in some Java book about any operator other than 'instanceof' for comparing the type hierarchy between two objects.</p> <p>instanceof is the most used and common. I am not able to recall clearly whether there is indeed another way of doing that or not.</p>
[ { "answer_id": 376996, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 3, "selected": false, "text": "Class.isInstance Class<?> stringClass = Class.forName(\"java.lang.String\");\nassert stringClass.isInstance(\"Some string\")...
2008/12/18
[ "https://Stackoverflow.com/questions/376988", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37626/" ]
376,998
<p>I want to redirect URLs from an old site that used raw URL requests to my new site which I have implemented in CodeIgniter. I simply want to redirect them to my index page. I also would like to get rid of &quot;index.php&quot; in my URLs so that my URLs can be as simple as example.com/this/that. So, this is the <code>.htaccess</code> file I have created:</p> <pre><code>RewriteEngine on Options FollowSymLinks RewriteBase / RewriteCond $1 ^assets RewriteRule ^(.*)$ example/production/$1 RewriteCond %{QUERY_STRING} .+ RewriteRule ^(.*)$ index.php? [R=301] RewriteCond $1 !^(index\.php|example|robots\.txt) RewriteRule ^(.*)$ index.php/$1 </code></pre> <p>It should also be noted that my index.php is actually a symlink to <code>example/production/index.php</code>.</p> <p>Now, the first rule works as expected - all my styles and images show up just fine, it's the second two rules I'm having trouble with. The second rule is basically to destroy the query string and redirect to my index page (externally). So, I found this in the Apache manual:</p> <blockquote> <p>Note: Query String</p> <p>The Pattern will not be matched against the query string. Instead, you must use a RewriteCond with the %{QUERY_STRING} variable. You can, however, create URLs in the substitution string, containing a query string part. Simply use a question mark inside the substitution string, to indicate that the following text should be re-injected into the query string. When you want to erase an existing query string, end the substitution string with just a question mark. To combine a new query string with an old one, use the [QSA] flag.</p> </blockquote> <p>However, when I try to access one of the old pages, instead of redirecting to my index page, I get a 404 page not found error. I have figured out a workaround by making it an internal redirect, but I would really like it to be external.</p> <p>The next problem, and the one that has been baffling me the most is with the third rule. I would expect this to do something like the following. If I type in:</p> <pre><code>http://example.com/this/thing </code></pre> <p>I would expect it to re-route to</p> <pre><code>http://example.com/index.php/this/thing </code></pre> <p>Unfortunately, this does not work. Instead, no matter what I type in, it always routes to my index page as if nothing else was in the URL (it just goes to <code>http://example.com/</code>).</p> <p>Furthermore, and even more confusing to me, if I replace that rule with the following:</p> <pre><code>RewriteCond $1 !^(index\.php|example|robots\.txt) RewriteRule ^(.*)$ index.php/this/thing </code></pre> <p>If I type in a URL such as <code>http://example.com/other/thing</code>, then it will go to <code>http://example.com/index.php/this/thing</code> as expected, BUT if I type in <code>http://example.com/this/thing</code> it goes to <code>http://example.com/</code> (my index page). I can't make heads or tails out of it. Any help would be greatly appreciated.</p>
[ { "answer_id": 376996, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 3, "selected": false, "text": "Class.isInstance Class<?> stringClass = Class.forName(\"java.lang.String\");\nassert stringClass.isInstance(\"Some string\")...
2008/12/18
[ "https://Stackoverflow.com/questions/376998", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3831/" ]
377,000
<p><a href="https://stackoverflow.com/questions/374572/need-help-variable-creation-in-python#374604">That</a> was helpful kgiannakakis. I'm facing a problem as below:</p> <pre><code>a = ['zbc','2.3'] for i in range(0,5): exec('E%d=%s' %(i,a[i])) </code></pre> <p>This results in:</p> <pre> Traceback (most recent call last): File "", line 2, in exec('E%d=%s' %(i,a[i])) File "", line 1, in NameError: name 'zbc' is not defined </pre>
[ { "answer_id": 377015, "author": "Charlie Martin", "author_id": 35092, "author_profile": "https://Stackoverflow.com/users/35092", "pm_score": 0, "selected": false, "text": "a = ['zbc','2.3']\nfor i in range(0,5): \n exec('E%d=%s' %(i,a[i]))\n >>> a\n['zbc', '2.3']\n>>> for i in range(...
2008/12/18
[ "https://Stackoverflow.com/questions/377000", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46646/" ]
377,017
<p>In Python, is there a portable and simple way to test if an executable program exists?</p> <p>By simple I mean something like the <code>which</code> command which would be just perfect. I don't want to search PATH manually or something involving trying to execute it with <code>Popen</code> &amp; al and see if it fails (that's what I'm doing now, but imagine it's <code>launchmissiles</code>)</p>
[ { "answer_id": 377028, "author": "Jay", "author_id": 20840, "author_profile": "https://Stackoverflow.com/users/20840", "pm_score": 9, "selected": true, "text": "def which(program):\n import os\n def is_exe(fpath):\n return os.path.isfile(fpath) and os.access(fpath, os.X_OK)\...
2008/12/18
[ "https://Stackoverflow.com/questions/377017", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38796/" ]
377,023
<p>Does anyone know the query the last synchronization date from sql server (2008).</p> <p>It is the same information displayed in replication monitor, but I want to be able to get that date from a query.</p>
[ { "answer_id": 377528, "author": "Philippe Grondier", "author_id": 11436, "author_profile": "https://Stackoverflow.com/users/11436", "pm_score": 3, "selected": true, "text": "select * from msMerge_sessions\n" }, { "answer_id": 8732082, "author": "RThomas", "author_id": 26...
2008/12/18
[ "https://Stackoverflow.com/questions/377023", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36902/" ]
377,026
<p>I have a Linq Query where I do the following:</p> <pre><code>query = context.Select(a =&gt; new { Course = (CourseType)a.CourseCode, CourseDetail = sting.Format("Course: {0}\r\nCourse Detail: {1}", ((CourseType)a.CourseCode).ToString(), a.CourseDetail) }); enum CourseType{ Unknown = 0, FullTime = 1, PartTime = 2 } </code></pre> <p>a.CourseCode is an int and a.CourseDetail is a string. I now bind a label inside a grid to this query. I set the Text to &lt;%# Eval("Course")%> and the Tooltip to &lt;%# Eval("CourseDetail")%>. Although the text in the label correctly displays the value expected from Enum.ToString(), the Tootip always shows the value of the integer value of the enum as 1,2,3...</p> <p>Whats causing this?</p> <p>Kind regards,</p>
[ { "answer_id": 377517, "author": "roomaroo", "author_id": 3464, "author_profile": "https://Stackoverflow.com/users/3464", "pm_score": 1, "selected": false, "text": "class Program\n{\n enum CourseType\n {\n Unknown = 0,\n Fulltime = 1,\n Parttime = 2\n }\n\n ...
2008/12/18
[ "https://Stackoverflow.com/questions/377026", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21586/" ]
377,030
<p>I have some data. I want to go through that data and change cells (for example - Background color), if that data meets a certain condition. Somehow, I've not been able to figure it out how to do this seemingly easy thing in Silverlight.</p>
[ { "answer_id": 378169, "author": "Simon Steele", "author_id": 4591, "author_profile": "https://Stackoverflow.com/users/4591", "pm_score": 4, "selected": true, "text": "<my:DataGrid x:Name=\"Grid\" Grid.Row=\"1\" Margin=\"5\" GridlinesVisibility=\"None\" PreparingRow=\"Grid_PreparingRow\"...
2008/12/18
[ "https://Stackoverflow.com/questions/377030", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26408/" ]
377,033
<p>Is it possible, using actionscript 3 to disable the right click menu?</p> <p>Any help greatly appreciated!</p>
[ { "answer_id": 377581, "author": "Iain", "author_id": 11911, "author_profile": "https://Stackoverflow.com/users/11911", "pm_score": 5, "selected": false, "text": "stage.showDefaultContextMenu = false;\n" }, { "answer_id": 1742155, "author": "Narusake", "author_id": 212059...
2008/12/18
[ "https://Stackoverflow.com/questions/377033", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1748529/" ]
377,035
<p>I'm building a photo gallery and what I would like to do is make it so that as the user rolls over an image (let's say for the purposes of this question it's a picture of an apple), all the other images of apples on the page also show their "over" state. </p> <p>Any and all help would be greatly appreciated, and thank you for your time in advance! </p>
[ { "answer_id": 377066, "author": "kgiannakakis", "author_id": 24054, "author_profile": "https://Stackoverflow.com/users/24054", "pm_score": 3, "selected": false, "text": "<img src='' class='apple fruit red' />\n $(\".apple\").mouseover(function() {\n $(\".apple\").addClass(\"overState\...
2008/12/18
[ "https://Stackoverflow.com/questions/377035", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
377,058
<p>I need a simple SQL to accomplish the below:</p> <p>Problem:</p> <p>When a petrol bunk runs out of fuel, the admin makes note of the DateTime (RunOutDate) when it ran out of fuel and notes also the DateTime (ResupplyDate) when the fuel supply was back on.</p> <p>I need to create a report on how many <em>days</em> the bunk ran out of fuel.</p> <p>eg.</p> <p>1/1/1 10:10 to 1/1/1 10:50 should be counted as 1 </p> <p>1/1/1 10:10 to 2/1/1 07:20 should be counted as 2 </p> <p>1/1/1 23:55 to 2/1/1 00:10 should be counted as 2 </p> <p>I can not bank using hours using DateDiff as 24 hours could have spanned across 2 days.</p> <p>TIA</p>
[ { "answer_id": 377068, "author": "gbn", "author_id": 27535, "author_profile": "https://Stackoverflow.com/users/27535", "pm_score": 2, "selected": false, "text": "DATEDIFF(day, '16 Dec 2008 10:10', '16 Dec 2008 10:50') + 1\n" }, { "answer_id": 377073, "author": "Joel Spolsky",...
2008/12/18
[ "https://Stackoverflow.com/questions/377058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4718/" ]
377,072
<p>I have received a content export of a MOSS 2007 site which I need to get replicated in my environment but I am having problems importing it using <code>stsadm</code>.</p> <p>The export was done using <code>stsadm</code> though a command similar to:</p> <blockquote> <p>stsadm -o export -url <a href="http://localhost" rel="nofollow noreferrer">http://localhost</a> -filename C:\Export</p> </blockquote> <p>I'm using the import command such as:</p> <blockquote> <p>stsadm -o import -url <a href="http://myServer" rel="nofollow noreferrer">http://myServer</a> -filename C:\Import</p> </blockquote> <p>Most things go fine until I get an error:</p> <blockquote> <p>Object Reference not set to an instance of an object. at Microsoft.SharePoint.Deployment.RolesImport..ctor(<em>and so on</em></p> </blockquote> <p>Essentially what appears to be the error is with the importing of the role groups from the other server. Because my system is a clean install of MOSS 2007 I don't have the user roles set up which they do, I was expecting the content import to handle that. But really, the roles are not important at all.</p> <p>Is it possible to do a content import but have the roles completely ignored?</p>
[ { "answer_id": 454422, "author": "Aaron Powell", "author_id": 11388, "author_profile": "https://Stackoverflow.com/users/11388", "pm_score": 1, "selected": true, "text": "-includeusersecurity" } ]
2008/12/18
[ "https://Stackoverflow.com/questions/377072", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11388/" ]
377,075
<p>I have a number of solutions with a large number of projects in them. I would like to be able to define global settings for the solution that are used by all projects. For example an include directory. I want to be able to change the include directory in one place for all projects in the solutions. </p> <p>When I searched for a solution I found a good description of the problem that <a href="http://www.eggheadcafe.com/software/aspnet/33334376/solutionglobal-settings.aspx" rel="noreferrer">matches mine exactly</a> but the solution suggested there, project property sheets, are defined per project and not per solutions. </p> <p>I could use environment variables or Visual studio settings, but then everyone that needs to compile the code has to define the exact same settings. </p> <p>Can anyone suggest a way to do this? Thanks.</p>
[ { "answer_id": 377856, "author": "Arnout", "author_id": 3496, "author_profile": "https://Stackoverflow.com/users/3496", "pm_score": 1, "selected": false, "text": "<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n <PropertyGroup>\n <WinUnitIncludeDir>C:\\...
2008/12/18
[ "https://Stackoverflow.com/questions/377075", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42086/" ]
377,078
<p>I'm trying to make a little function to interpolate between two values with a given increment.</p> <pre><code>[ 1.0 .. 0.5 .. 20.0 ] </code></pre> <p>The compiler tells me that this is deprecated, and suggests using ints then casting to float. But this seems a bit long-winded if I have a fractional increment - do I have to divide my start and end values by my increment, then multiple again afterwards? (yeuch!).</p> <p>I saw something somewhere once about using sequence comprehensions to do this, but I can't remember how.</p> <p>Help, please.</p>
[ { "answer_id": 377111, "author": "JaredPar", "author_id": 23283, "author_profile": "https://Stackoverflow.com/users/23283", "pm_score": 0, "selected": false, "text": "seq { 2 .. 40 } |> Seq.map (fun x -> (float x) / 2.0)\n" }, { "answer_id": 377618, "author": "Tomas Petricek"...
2008/12/18
[ "https://Stackoverflow.com/questions/377078", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11410/" ]
377,082
<p>I'm an OK C/C++ programmer. I find Haskell very intriguing. But it seems to me, that although it's relatively easy to write clean Haskell code, as it mimics math (which I'm very comfortable with) pretty well, it's very hard to write clean code in Haskell that runs fast.</p> <p>A faster version of quicksort of Haskell is very long and scary, which has no resemblance to the naive but short (two lines), clean and intuitive implementation. The long and scary version of Haskell is actually still much slower than the shorter and simpler C counter part.</p> <p>Is it because the current Haskell compiler is too dumb or is it just impossible for mortals (other than SJP of course) to write fast Haskell code?</p>
[ { "answer_id": 382904, "author": "Norman Ramsey", "author_id": 41661, "author_profile": "https://Stackoverflow.com/users/41661", "pm_score": 6, "selected": false, "text": "map filter fold" } ]
2008/12/18
[ "https://Stackoverflow.com/questions/377082", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47303/" ]
377,093
<p>Coming from C++, I find generic programming indispensable. I wonder how people approach that in Haskell?</p> <p>Say how do write generic swap function in Haskell?</p> <p>Is there an equivalent concept of partial specialization in Haskell?</p> <p>In C++, I can partially specialize the generic swap function with a special one for a generic map/hash_map container that has a special swap method for O(1) container swap. How do you do that in Haskell or what's the canonical example of generic programming in Haskell?</p>
[ { "answer_id": 377155, "author": "Daniel Earwicker", "author_id": 27423, "author_profile": "https://Stackoverflow.com/users/27423", "pm_score": 6, "selected": true, "text": "measure :: [a] -> Integer\n measure a measure [] = 0\n measure (h:r) = 1 + measure r\n" }, { "answer_id": ...
2008/12/18
[ "https://Stackoverflow.com/questions/377093", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47303/" ]
377,094
<p>I have a C++ application that uses the Win32 API for Windows, and I'm having a problem with GDI+ dithering, when I don't know why it should be.</p> <p>I have a custom control (custom window). When I receive the WM_PAINT message, I draw some Polygons using FillPolygon on a Graphics device. This Graphics device was created using the HDC from BeginPaint.</p> <p>When the polygons appear on the screen, though, they are dithered instead of transparent, and only seem to show few colors (maybe 256?) When I do the same thing in C# using the .NET interface into GDI+, it works fine, which is leaving me wondering what's going on.</p> <p>I'm not doing anything special, this is a simple example that should work fine, as far as I know. Am I doing something wrong?</p> <p>Edit: Nevermind. It only happens over Remote Desktop, even though the C# example doesnt Dither over remote desktop. Remote Desktop is set at 32-bit color, so I don't know what's up with that.</p>
[ { "answer_id": 377155, "author": "Daniel Earwicker", "author_id": 27423, "author_profile": "https://Stackoverflow.com/users/27423", "pm_score": 6, "selected": true, "text": "measure :: [a] -> Integer\n measure a measure [] = 0\n measure (h:r) = 1 + measure r\n" }, { "answer_id": ...
2008/12/18
[ "https://Stackoverflow.com/questions/377094", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3641/" ]
377,097
<p>I want to connect to DB using the iSeries Client Access driver. I use the following connection string:</p> <p>DRIVER=Client Access ODBC Driver (32-bit);QUERYTIMEOUT=0;PKG=QGPL/DEFAULT(IBM),2,0,1,0,512;LANGUAGEID=ENU;DFTPKGLIB=QGPL;DBQ=QGPL XXXXXXXX;SYSTEM=XXX.XXXXXXX.XXX;Signon=2</p> <p>I get an exception when connecting:</p> <p>ERROR [28000] [IBM][iSeries Access ODBC Driver]Communication link failure. comm rc=8015 - CWBSY1006 - User ID is invalid, Password length = 0, Prompt Mode = Never</p> <p>How can I make the application prompt the user for his credentials to the DB?</p>
[ { "answer_id": 377155, "author": "Daniel Earwicker", "author_id": 27423, "author_profile": "https://Stackoverflow.com/users/27423", "pm_score": 6, "selected": true, "text": "measure :: [a] -> Integer\n measure a measure [] = 0\n measure (h:r) = 1 + measure r\n" }, { "answer_id": ...
2008/12/18
[ "https://Stackoverflow.com/questions/377097", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
377,105
<p>In Delphi 2007, in a mouse move event, I try to change the mouse cursor with:</p> <pre><code>procedure TFr_Board_Display.PaintBox_Proxy_BoardMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); begin if left_mouse_button_down then begin if some_condition then begin Cursor := crDrag; end else begin Cursor := crNoDrop; end; end else begin if some_other_condition then begin Cursor := crHandPoint; end else begin Cursor := crDefault; end; end; end; </code></pre> <p>for example. However, when the left mouse button is down, and I move the mouse, the cursor doesn't change to either crDrag or crNoDrop. The code is executed (e.g. Cursor := crDrag;) but the cursor does not change. When the left mouse button is up, and I move the mouse, the cursor changes no problem. </p> <p>(I originally tried to use some Drag &amp; Drop events and properties, but couldn't get everything to work the way I wanted.)</p> <p>Edit: Clarified desired behavior, and formatted code.</p> <p>Edit: Thank you, Gamecat, but I want the cursor to change when the left mouse button is down and the while the mouse is moving the cursor should change back and forth between crDrag and crNoDrop.</p>
[ { "answer_id": 377158, "author": "Toon Krijthe", "author_id": 18061, "author_profile": "https://Stackoverflow.com/users/18061", "pm_score": 5, "selected": true, "text": "procedure TForm4.FormMouseDown(Sender: TObject; Button: TMouseButton;\n Shift: TShiftState; X, Y: Integer);\nbegin\n ...
2008/12/18
[ "https://Stackoverflow.com/questions/377105", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47309/" ]
377,109
<p>Hi I'm very new to sql but have been passed a job in which I need to query the db(MS SQL 2005) I need to return all workers where a HeadID is given.(tables below) So I need to get all the managers that match the HeadID and then all the workers that match those managers by ManagerID. How would I do this? Any help or any sql terminology that would help me better search for the solution would be much appreciated. Thanks</p> <p>tb_Head: HeadID</p> <p>tb_Manager: ManagerID, HeadID,</p> <p>tb_Worker: WorkerID, ManagerID,</p>
[ { "answer_id": 377115, "author": "Chaowlert Chaisrichalermpol", "author_id": 2398110, "author_profile": "https://Stackoverflow.com/users/2398110", "pm_score": 1, "selected": false, "text": "USE AdventureWorks;\nGO\nWITH DirectReports(ManagerID, EmployeeID, EmployeeLevel) AS \n(\n SELE...
2008/12/18
[ "https://Stackoverflow.com/questions/377109", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17510/" ]
377,114
<p>Partial template specialization is one of the most important concepts for generic programming in C++. For example: to implement a generic swap function:</p> <pre><code>template &lt;typename T&gt; void swap(T &amp;x, T &amp;y) { const T tmp = x; y = x; x = tmp; } </code></pre> <p>To specialize it for a vector to support O(1) swap:</p> <pre><code>template &lt;typename T, class Alloc&gt; void swap(vector&lt;T, Alloc&gt; &amp;x, vector&lt;T, Alloc&gt; &amp;y) { x.swap(y); } </code></pre> <p>So you can always get optimal performance when you call swap(x, y) in a generic function;</p> <p>Much appreciated, if you can post the equivalent (or the canonical example of partial specialization of the language if the language doesn't support the swap concept) in alternative languages.</p> <p><strong>EDIT</strong>: so it looks like many people who answered/commented really don't known what partial specialization is, and that the generic swap example seems to get in the way of understanding by some people. A more general example would be:</p> <pre><code>template &lt;typename T&gt; void foo(T x) { generic_foo(x); } </code></pre> <p>A partial specialization would be:</p> <pre><code>template &lt;typename T&gt; void foo(vector&lt;T&gt; x) { partially_specialized_algo_for_vector(x); } </code></pre> <p>A complete specialization would be:</p> <pre><code>void foo(vector&lt;bool&gt; bitmap) { special_algo_for_bitmap(bitmap); } </code></pre> <p>Why this is important? because you can call foo(anything) in a generic function:</p> <pre><code>template &lt;typename T&gt; void bar(T x) { // stuff... foo(x); // more stuff... } </code></pre> <p>and get the most appropriate implementation at compile time. This is one way for C++ to achieve abstraction w/ minimal performance penalty.</p> <p>Hope it helps clearing up the concept of "partial specialization". In a way, this is how C++ do type pattern matching without needing the explicit pattern matching syntax (say the match keyword in Ocaml/F#), which sometimes gets in the way for generic programming. </p>
[ { "answer_id": 380306, "author": "finnsson", "author_id": 24044, "author_profile": "https://Stackoverflow.com/users/24044", "pm_score": -1, "selected": false, "text": "void Swap<T>(ref T a, ref T b) { \n var c = a; \n a = b; \n b = c;\n}\n swap :: a -> b -> (b,a)\nswap a b = (b,...
2008/12/18
[ "https://Stackoverflow.com/questions/377114", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47303/" ]
377,117
<p>I must be dense. After asking several questions on StackOverflow, I am still at a loss when it comes to grasping the new routing engine provided with ASP.NET MVC. I think I've narrowed down the problem to a very simple one, which, if solved, would probably allow me to solve the rest of my routing issues. So here it is:</p> <p>How would you register a route to support a Twitter-like URL for user profiles?</p> <blockquote> <p><code>www.twitter.com/username</code></p> </blockquote> <p>Assume the need to also support:</p> <ul> <li><p>the default <code>{controller}/{action}/{id}</code> route. </p></li> <li><p>URLs like:</p> <blockquote> <p><code>www.twitter.com/login</code><br> <code>www.twitter.com/register</code></p> </blockquote></li> </ul> <p>Is this possible?</p>
[ { "answer_id": 377142, "author": "John Sheehan", "author_id": 1786, "author_profile": "https://Stackoverflow.com/users/1786", "pm_score": 0, "selected": false, "text": "routes.MapRoute(\n \"Root\",\n \"{controller}/{view}\",\n new { controller = \"Home\", action = \"Index\", vie...
2008/12/18
[ "https://Stackoverflow.com/questions/377117", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1574/" ]
377,135
<p>I want to display documents on my website. The server is hosted on a Debian machine. I was thinking I can allow the upload of support documents then use a Linux app or PHP app to convert the doc into PDF and display that in an HTML page. Are there any APIs or binaries that allow me to do this?</p>
[ { "answer_id": 378262, "author": "jjclarkson", "author_id": 46425, "author_profile": "https://Stackoverflow.com/users/46425", "pm_score": 1, "selected": false, "text": " function lpr($STR,$PRN,$TITLE) {\n\n $prn=(isset($PRN) && strlen($PRN))?\"$PRN\":C_DEFAULTPRN ;\n $title=(isset...
2008/12/18
[ "https://Stackoverflow.com/questions/377135", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
377,137
<p>I've been struggling with this for quite awhile and haven't been able to find a solution. I need a user to be able to view multiple top level domains with a single login.</p> <p>My understanding is that this needs to be set in <code>environment.rb</code> and called with <code>before_dispatch</code>. This is what I've come up with:</p> <pre><code>require 'activesupport' require 'dispatcher' module ActionController class Dispatcher def set_session_domain ActionController::Base.session_options.update :session_domain =&gt; "#{@request.host}" end before_dispatch :set_session_domain end end </code></pre> <p>However, this does not seem to be working when I try and pull the values from <code>session[:session_domain]</code>.</p> <p>Any help is greatly appreciated.</p>
[ { "answer_id": 2891676, "author": "Kris", "author_id": 22237, "author_profile": "https://Stackoverflow.com/users/22237", "pm_score": 2, "selected": false, "text": "ActionController::Base.session = { :domain => \".mydomain.com\" }\n" } ]
2008/12/18
[ "https://Stackoverflow.com/questions/377137", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
377,156
<p>Below is my table, a User could have multiple profiles in certain languages, non-English profiles have a higher priority.</p> <pre> +----------+--------+----------------+----------------+ |ProfileID |UserID |ProfileLanguage |ProfilePriority | +----------+--------+----------------+----------------+ |1 |1 |en-US |2 | +----------+--------+----------------+----------------+ |2 |1 |es-MX |1 | +----------+--------+----------------+----------------+ |3 |1 |ja-JP |1 | +----------+--------+----------------+----------------+ |4 |2 |es-MX |1 | +----------+--------+----------------+----------------+ |5 |2 |ja-JP |2 | +----------+--------+----------------+----------------+ |6 |2 |de-DE |1 | +----------+--------+----------------+----------------+ |7 |3 |en-US |2 | +----------+--------+----------------+----------------+ </pre> <p><br />For example: When a Spanish-speaking visitor requests my site (where ProfileLanguage = 'es-MX' or ProfilePriority = 2), I want the records like below:</p> <pre> +----------+--------+----------------+----------------+ |ProfileID |UserID |ProfileLanguage |ProfilePriority | +----------+--------+----------------+----------------+ |2 |1 |es-MX |1 | +----------+--------+----------------+----------------+ |5 |2 |ja-JP |2 | +----------+--------+----------------+----------------+ |7 |3 |en-US |2 | +----------+--------+----------------+----------------+ </pre> <p><br /> Below, is the basic SQL to get the users:</p> <pre><code>SELECT UserID, MIN(ProfilePriority) AS ProfilePriority FROM Profile WHERE ProfileLanguage = 'es-MX' OR ProfilePriority = 2 GROUP BY UserID </code></pre> <p>But as you know, I can only get the UserID, but I also need other column information, like ProfileID etc.. So I hope experts here could tell me the correct SQL expression to get the right records.</p>
[ { "answer_id": 377165, "author": "Samiksha", "author_id": 29515, "author_profile": "https://Stackoverflow.com/users/29515", "pm_score": 1, "selected": false, "text": "SELECT *\nFROM Profile as tb1 inner join\n(SELECT UserID, MIN(ProfilePriority) AS ProfilePriority\nFROM Profile\nWHERE Pr...
2008/12/18
[ "https://Stackoverflow.com/questions/377156", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
377,163
<p>How do you perform databinding against the MonthCalendar.SelectionRange property? Given the property is of type 'SelectionRange' which is a class I am not sure how to go about it. Any examples would be much appreciated.</p>
[ { "answer_id": 377350, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 3, "selected": true, "text": "MonthCalendar SelectionRange INotifyPropertyChanged Actual(...) using System;\nusing System.Collections.Generic;\nusin...
2008/12/18
[ "https://Stackoverflow.com/questions/377163", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6276/" ]
377,178
<p>What are all the other things the <code>new</code> operator does other than allocating memory and calling a constructor?</p>
[ { "answer_id": 377208, "author": "Michael Burr", "author_id": 12711, "author_profile": "https://Stackoverflow.com/users/12711", "pm_score": 5, "selected": true, "text": "<new>" }, { "answer_id": 390585, "author": "Johannes Schaub - litb", "author_id": 34509, "author_p...
2008/12/18
[ "https://Stackoverflow.com/questions/377178", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22076/" ]
377,181
<p>I have a unmanaged DLL (the scilexer.dll of Scintilla code editor, used by Scintilla.Net from <a href="http://www.codeplex.com/ScintillaNET" rel="noreferrer">CodePlex</a>) that is loaded from a managed application trough the Scintilla.Net component. The windows managed application runs without problem on both 32 and 64 bit environments, but I need to create different installations that uses the 64 or the 32 scilexer.dll.</p> <p>Is there a way to distribute both DLLs in 32 and 64 bit format so that the DLL loader of the .Net framework loads the unmanaged DLL in the 32 or 64 bit format depending on some .config option or some "path name magic" stuff?</p>
[ { "answer_id": 499190, "author": "SteinNorheim", "author_id": 19220, "author_profile": "https://Stackoverflow.com/users/19220", "pm_score": 2, "selected": false, "text": "public interface ICodec {\n int Decode(IntPtr input, IntPtr output, long inputLength);\n}\n public class CodecX86 ...
2008/12/18
[ "https://Stackoverflow.com/questions/377181", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11673/" ]
377,185
<p>The db I am querying from is returning some null values. How do I safeguard against this and make sure the caller gets some data back.</p> <p>The code I have is:</p> <p>Using DataReader</p> <pre><code> while (dr.Read()) { vo = new PlacementVO(); vo.PlacementID = dr.GetString(0); </code></pre> <p>If I use dataset, I can do it like this.</p> <pre><code> obj.email = (row["email"] == DBNull.Value) ? String.Empty : Convert.ToString(row["email"]); </code></pre> <p>Thanks</p>
[ { "answer_id": 377193, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 4, "selected": true, "text": "IsDBNull(int ordinal) string email = reader.IsDBNull(0) ? null : reader.GetString(0);\n GetOrdinal string GetSafeStrin...
2008/12/18
[ "https://Stackoverflow.com/questions/377185", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17510/" ]
377,187
<p>I currently have code in my ApplicationController to check if a user is logged in and has the required access to perform a given action (the tests take place in a before_filter).</p> <p>I require the same functionality in the views to decide if I should be showing the admin links in a list view, but how do I best avoid duplicating code in the controllers and views?</p> <p>The way I have chosen to do it now, is to have the user_can_edit_customers? essentially be a wrapper for 'can_edit_customers?' on my User class:</p> <p>ApplicationController:</p> <pre> class ApplicationController </pre> <p>And then do something similar in my view helpers.</p> <p>This way all functionality is encapsulated in the User model but I still need to define wrappers in my controllers and helpers, but are there smarter ways of doing this?</p> <p>Note, the user stuff is only an example - this also applies to other pieces of functionality.</p>
[ { "answer_id": 377251, "author": "Hates_", "author_id": 3410, "author_profile": "https://Stackoverflow.com/users/3410", "pm_score": 3, "selected": true, "text": "helper_method :current_user, :can_edit_customers?\n\ndef current_user\n @current_user ||= User.find_by_id(session[:user])\n...
2008/12/18
[ "https://Stackoverflow.com/questions/377187", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15512/" ]
377,195
<p>I have a C linux application (A) that spawns another process (P) when it is started. When I want to debug P I start A as usual and I connect with ddd/gdb to P.</p> <p>Problems appear when I want to debug the entry-point (start of main) of P. If I follow the usual approach when I connect the debugger to P is already to late. The solution I've found was to insert a sleep at the begining of the main of P so I have time to connect with gdb but this is not a very elegant solution.</p> <p>I've also tried using <code>asm("int $3")</code> but it doesn't seems to work.</p> <p>Do you have any idea how I could solve this problem? (preferably without altering the code of A or P)</p>
[ { "answer_id": 377252, "author": "codelogic", "author_id": 43427, "author_profile": "https://Stackoverflow.com/users/43427", "pm_score": -1, "selected": false, "text": "gdbserver gdbserver" }, { "answer_id": 377295, "author": "Nathan Fellman", "author_id": 1084, "auth...
2008/12/18
[ "https://Stackoverflow.com/questions/377195", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
377,202
<p>I recently had a problem in my app where some of the subviews I was creating in a UIViewController subclass's <code>-awakeFromNib</code> method were disappearing from the view. After some poking around I found that moving the code I had put in <code>-awakeFromNib</code> to <code>-viewDidLoad</code> solved the problem. Seems that <code>-awakeFromNib</code> gets called only once when the UIViewController is unarchived from the nib, and <code>-viewDidLoad</code> gets called every time the view is unarchived.</p> <p>So what's the best practice? It looks like UIViewController's <code>-awakeFromNib</code> shouldn't be adding any views to the view, that kind of stuff should be done in <code>-viewDidLoad</code>. Am I understanding this correctly? Or am I more confused than I thought?</p>
[ { "answer_id": 377209, "author": "mmx", "author_id": 33708, "author_profile": "https://Stackoverflow.com/users/33708", "pm_score": 4, "selected": false, "text": "awakeFromNib awakeFromNib viewDidLoad Load" }, { "answer_id": 377390, "author": "Lily Ballard", "author_id": 5...
2008/12/18
[ "https://Stackoverflow.com/questions/377202", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17188/" ]
377,203
<p>Why does it (apparently) make a difference whether I pass <code>null</code> as an argument directly, or pass an <code>Object</code> that I assigned the <em>value</em> <code>null</code>?</p> <pre><code>Object testVal = null; test.foo(testVal); // dispatched to foo(Object) // test.foo(null); // compilation problem -&gt; "The method foo(String) is ambiguous" public void foo(String arg) { // More-specific System.out.println("foo(String)"); } public void foo(Object arg) { // Generic System.out.println("foo(Object)"); } </code></pre> <p>In other words, why is the (commented-out) second call to <code>foo(...)</code> not dispatched to <code>foo(Object)</code>?</p> <p><strong>Update:</strong> I use Java 1.6. I could compile Hemal's code without problems, but mine still doesn't compile. The only difference I see is that Hemal's methods are static while mine are not. But I really don't see why this should make a difference...?</p> <p><strong>Update 2:</strong> Solved. I had another method foo(Runnable) in my class, so the dispatcher couldn't unambiguously select the single most specific method. (See my comment in Hemal's second answer.) Thanks everyone for your help.</p>
[ { "answer_id": 377238, "author": "Miserable Variable", "author_id": 18573, "author_profile": "https://Stackoverflow.com/users/18573", "pm_score": 6, "selected": true, "text": "foo(testVal) foo(Object) foo(null) foo(String) null nulltype nulltype String Object foo(null) String Object foo(...
2008/12/18
[ "https://Stackoverflow.com/questions/377203", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45018/" ]
377,204
<p>I use some wx.ListCtrl classes in wx.LC_REPORT mode, augmented with ListCtrlAutoWidthMixin.</p> <p>The problem is: When user double clicks the column divider (to auto resize column), column width is set to match the width of contents. This is done by the wx library and resizes column to just few pixels when the control is empty.</p> <p>I tried calling </p> <blockquote> <p>self.SetColumnWidth(colNumber, wx.LIST_AUTOSIZE_USEHEADER)</p> </blockquote> <p>while creating the list, but it just sets the initial column width, not the minimum allowed width. </p> <p>Anyone succeeded with setting column minimal width?</p> <p>EDIT: Tried catching </p> <pre> wx.EVT_LEFT_DCLICK </pre> <p>with no success. This event isn't generated when user double clicks column divider. Also tried with </p> <pre>wx.EVT_LIST_COL_END_DRAG </pre> <p>this event is generated, usually twice, for double click, but I don't see how can I retrieve information about new size, or how to differentiate double click from drag&amp;drop. Anyone has some other ideas?</p>
[ { "answer_id": 380378, "author": "Abgan", "author_id": 46308, "author_profile": "https://Stackoverflow.com/users/46308", "pm_score": 2, "selected": true, "text": "self.SetColumnWidth(colNum, wx.LIST_AUTOSIZE_USEHEADER)\n\nself.__columnWidth[colNum] = self.GetColumnWidth(c)\n wx.EVT_UPDAT...
2008/12/18
[ "https://Stackoverflow.com/questions/377204", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46308/" ]
377,213
<p>I want to know how to simply publish over http = much like <a href="http://en.wikipedia.org/wiki/Mercurial" rel="noreferrer">Mercurial</a>'s hg serve! On the Windows/work box do this:</p> <pre><code>git serve </code></pre> <p>and then on the Linux box SIMPLY go:</p> <pre><code>git clone http://project project </code></pre> <p>finished. </p>
[ { "answer_id": 377293, "author": "seanhodges", "author_id": 43662, "author_profile": "https://Stackoverflow.com/users/43662", "pm_score": 9, "selected": true, "text": "cd project\ngit daemon --reuseaddr --base-path=. --export-all --verbose\n [alias]\n serve = !git daemon --reuseaddr -...
2008/12/18
[ "https://Stackoverflow.com/questions/377213", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21537/" ]
377,217
<p>I am using the following methods:</p> <pre><code>public void M1(Int32 a) { // acquire MyMutex DoSomething(a); // release MyMutex } </code></pre> <p>and</p> <pre><code>public void M2(String s, String t) { // acquire MyMutex DoSomethingElse(s, t); // release MyMutex } </code></pre> <p>From what I have found so far it seems that it is not possible to use a single delegate for two methods with different signatures.</p> <p>Are there any other alternatives to write something like this:</p> <pre><code>public void UsingMutex(...) { // acquire MyMutex ... // release MyMutex } UsingMutex(M1); UsingMutex(M2); </code></pre> <p>All I can think for the moment is to use two delegates and a boolean flag to know which delegate to call, but it is not a long term solution.</p> <p>It is possible to combine generics with delegates? And if so, do you have some links for any kind of documentation?</p> <p>Environment: C# 2.0</p>
[ { "answer_id": 377224, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 5, "selected": true, "text": "Predicate<T> public delegate void Action();\n static void Main()\n {\n DoStuff(delegate {Foo(5);});\n...
2008/12/18
[ "https://Stackoverflow.com/questions/377217", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19756/" ]
377,218
<p>I've worked on a couple of projects where we spent a great deal of time discussing and writing elaborate coding standards covering everything from syntax layout to actual best practices. However, I have also found that these are rarely followed to the full extent. Many developers seem to hesitate to reject a code review based on coding standard violations alone. I.e. violations are committed to the repository on a regular basis. </p> <p>My questions are: Do you have coding standards? What do they cover? Are they followed by everyone? And what do you do (if anything) to make sure everybody is following the standards?</p> <p>I'm aware that there is a similar question <a href="https://stackoverflow.com/questions/167575/should-a-project-manager-enforce-coding-standards">here</a>, but my concern is not so much how you could do it, but how you are actually going about it and what are the perceived benefits?</p>
[ { "answer_id": 452304, "author": "Scottie T", "author_id": 6688, "author_profile": "https://Stackoverflow.com/users/6688", "pm_score": 0, "selected": false, "text": " static // Scope\n void // Type declaration \nfunc(\n\nchar al, //IN: Description of ...
2008/12/18
[ "https://Stackoverflow.com/questions/377218", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38206/" ]
377,219
<p>I'm studying an introductory course in databases and one of the exercises is to work with MS-Access. However I'm using Linux at home and although I can use the computer classes at the university it is far from convenient (limited open time - my studying time is mostly nights).</p> <p>So how can I use an Access file (<code>*.mdb</code>) in Linux? By use I mean changing tables, writing queries and so on.</p> <p>Are there tools to convert it to another database format (mysql, postgresql or even gadfly)?</p> <p>Also what problems may I encounter?</p>
[ { "answer_id": 377308, "author": "codelogic", "author_id": 43427, "author_profile": "https://Stackoverflow.com/users/43427", "pm_score": 4, "selected": false, "text": "mdbtools sudo apt-get install mdbtools\n" }, { "answer_id": 377485, "author": "Philippe Grondier", "auth...
2008/12/18
[ "https://Stackoverflow.com/questions/377219", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
377,228
<p>I'm currently using Magento 1.1.6. My store only sells unique items (shirts with exclusive designs) which means at any one time, only 1 unit is available for each items.</p> <p>How do I omit those items which are already sold from being displayed in the front page?</p> <p>BTW, I'm using these code to show products on the front page:</p> <pre><code>{{block type="catalog/product_list" category_id="3" template="catalog/product/list_home_batik.phtml"}} </code></pre>
[ { "answer_id": 449622, "author": "stunti", "author_id": 54949, "author_profile": "https://Stackoverflow.com/users/54949", "pm_score": 0, "selected": false, "text": "<?php if($_product->isSaleable()): ?>\n <?php foreach ($_productCollection as $_product): ?>\n <?php foreach ($_productColl...
2008/12/18
[ "https://Stackoverflow.com/questions/377228", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
377,231
<p>How do I handle the scenario where I making a synchronous request to the server using XMLHttpRequest and the server is not available?</p> <pre><code>xmlhttp.open("POST","Page.aspx",false); xmlhttp.send(null); </code></pre> <p>Right now this scenario results into a JavaScript error: "The system cannot locate the resource specified"</p>
[ { "answer_id": 377302, "author": "fasih.rana", "author_id": 46024, "author_profile": "https://Stackoverflow.com/users/46024", "pm_score": 2, "selected": false, "text": "xmlHTTP.TimeOut= 2000 \n" }, { "answer_id": 377606, "author": "coder_bro", "author_id": 46279, "aut...
2008/12/18
[ "https://Stackoverflow.com/questions/377231", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46279/" ]
377,237
<p>A long time ago I saw this trick in Ruby. Instead of doing (for example)</p> <pre><code>if array1.empty? and array2.empty? and array3.empty? </code></pre> <p>You could call all of the objects at once and append the operation at the end, kind of like</p> <pre><code>if %w(array1 array2 array3).each { |a| a.empty? } </code></pre> <p>But I think it was simpler than that... or, it could be that. I really don't know, but that's why I'm interested in finding out. Thanks.</p>
[ { "answer_id": 377280, "author": "J Cooper", "author_id": 38803, "author_profile": "https://Stackoverflow.com/users/38803", "pm_score": 5, "selected": true, "text": "if [array1, array2, array3].all? { |a| a.empty? }" }, { "answer_id": 377360, "author": "Gareth", "author_i...
2008/12/18
[ "https://Stackoverflow.com/questions/377237", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
377,243
<p>Using the code below, I am returning an nvarchar field from <em>MS SQL 2005</em> and keep getting a System.InvalidCastException.</p> <pre><code>vo.PlacementID = dr.IsDBNull(0) ? null : dr.GetString(0); </code></pre> <p>The vo.PlacementID variable is of type String so there shouldn't be a problem. The values I am trying to return are like this (number, number, letter): 00F, 02A, 01F, etc </p> <pre><code>System.InvalidCastException: Unable to cast object of type 'System.Int32' to type 'System.String'. at System.Data.SqlClient.SqlBuffer.get_String() at System.Data.SqlClient.SqlDataReader.GetString(Int32 i) </code></pre> <p>Any help much appreciated.</p>
[ { "answer_id": 377249, "author": "mmx", "author_id": 33708, "author_profile": "https://Stackoverflow.com/users/33708", "pm_score": 0, "selected": false, "text": "InvalidCastException PlacementID string string" }, { "answer_id": 377610, "author": "Kev", "author_id": 419, ...
2008/12/18
[ "https://Stackoverflow.com/questions/377243", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17510/" ]
377,257
<p>FxCops is something new to me, but as always I would like to get to know the new things.. From what I've read, FxCops is already included in VS2008. I guess it's the "Code Analysis" function. Whenever I try to run it though, it seems to start a rebuild and end in the "Finished Rebuilding" state.<br> I checked the output window and there are a bunch of warnings there. But if I'm not mistaking, there should be more of a GUI for this then the wall of text in my output window, right?<br> Am I missing a window that should have popped up? Can I open it somewhere? Or is there anything else I'm missing?</p>
[ { "answer_id": 377268, "author": "NikolaiDante", "author_id": 39643, "author_profile": "https://Stackoverflow.com/users/39643", "pm_score": 3, "selected": true, "text": "CA" }, { "answer_id": 378457, "author": "Patrick from NDepend team", "author_id": 27194, "author_p...
2008/12/18
[ "https://Stackoverflow.com/questions/377257", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11333/" ]
377,275
<p>I hope someone can guide me as I'm stuck... I need to write an emergency broadcast system that notifies workstations of an emergency and pops up a little message at the bottom of the user's screen. This seems simple enough but there are about 4000 workstations over multiple subnets. The system needs to be almost realtime, lightweight and easy to deploy as a windows service. </p> <p>The problem started when I discovered that the routers do not forward UDP broadcast packets x.x.x.255. Later I made a simple test hook in VB6 to catch net send messages but even those didn't pass the routers. I also wrote a simple packet sniffer to filter packets only to find that the network packets never reached the intended destination.</p> <p>Then I took a look and explored using MSMQ over HTTP, but this required IIS to be installed on the target workstation. Since there are so many workstations it would be a major security concern.</p> <p>Right now I've finished a web service with asynchronous callback that sends an event to subscribers. It works perfectly on a small scale but once there are more than 15 subscribers performance degrades considerably. Polling a server isn't really an option because of the load it will generate on the server (plus I've tried it too)</p> <p>I need your help to guide me as to what technology to use. has anyone used the comet way with so many clients or should I look at WCF?</p> <p>I'm using Visual C# 2005. Please help me out of this predicament.</p> <p>Thanks</p>
[ { "answer_id": 377985, "author": "Tim Farley", "author_id": 4425, "author_profile": "https://Stackoverflow.com/users/4425", "pm_score": 0, "selected": false, "text": "NET SEND computername \"This is a test message\"\n" } ]
2008/12/18
[ "https://Stackoverflow.com/questions/377275", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47329/" ]
377,294
<p>What's the best way to identify if a string (is or) might be UTF-8 encoded? The Win32 API <code>IsTextUnicode</code> isn't of much help here. Also, the string will not have an UTF-8 BOM, so that cannot be checked for. And, yes, I know that only characters above the ASCII range are encoded with more than 1 byte.</p>
[ { "answer_id": 6735792, "author": "Harry Wood", "author_id": 338265, "author_profile": "https://Stackoverflow.com/users/338265", "pm_score": 1, "selected": false, "text": "sudo gem install chardet\n require \"rubygems\"\nrequire 'UniversalDetector' #chardet gem\ninfile = $stdin.read()\n...
2008/12/18
[ "https://Stackoverflow.com/questions/377294", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6345/" ]
377,322
<p>I've seen a lot of example c++ code that wraps function calls in a FAILED() function/method/macro. Could someone explain to me how this works? And if possible does anyone know a c# equivalent?</p>
[ { "answer_id": 377325, "author": "Johann Gerell", "author_id": 6345, "author_profile": "https://Stackoverflow.com/users/6345", "pm_score": 4, "selected": true, "text": "HRESULT FAILED HRESULT S_OK S_FALSE HRESULT" }, { "answer_id": 377357, "author": "unwind", "author_id":...
2008/12/18
[ "https://Stackoverflow.com/questions/377322", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17540/" ]
377,354
<p>Is there an elegant way to do this:</p> <pre><code>SELECT Cols from MyTable WHERE zip = 90210 OR zip = 23310 OR zip = 74245 OR zip = 77427 OR zip = 18817 OR zip = 94566 OR zip = 34533 OR zip = 96322 OR zip = 34566 OR zip = 52214 OR zip = 73455 OR zip = 52675 OR zip = 54724 OR zip = 98566 OR zip = 92344 OR zip = 90432 OR zip = 91532 OR ... </code></pre> <p>(zip codes in this post are ficticious and bear no resemblance to actual zip codes living or dead)</p>
[ { "answer_id": 377358, "author": "Ben", "author_id": 11522, "author_profile": "https://Stackoverflow.com/users/11522", "pm_score": 5, "selected": false, "text": "Select cols from MyTable where zip in (90210, 23310, ... etc.)\n" }, { "answer_id": 377367, "author": "The Archety...
2008/12/18
[ "https://Stackoverflow.com/questions/377354", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18749/" ]
377,361
<p>2^15 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26.</p> <p>What is the sum of the digits of the number 2 power of 1000 (2^1000)?</p> <p>Can anyone provide the solution or algorithm for this problem in java?</p>
[ { "answer_id": 377384, "author": "Boojum", "author_id": 37555, "author_profile": "https://Stackoverflow.com/users/37555", "pm_score": 3, "selected": false, "text": "java.math.BigInteger" }, { "answer_id": 377401, "author": "soulmerge", "author_id": 44562, "author_prof...
2008/12/18
[ "https://Stackoverflow.com/questions/377361", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40945/" ]
377,362
<p>I have a block of code that basically intializes several classes, but they are placed in a sequential order, as later ones reference early ones.</p> <p>For some reason the last one initializes before the first one...it seems to me there is some sort of threading going on. What I need to know is how can I stop it from doing this? </p> <p>Is there some way to make a class init do something similar to sending a return value?</p> <p>Or maybe I could use the class in an if statement of some sort to check if the class has already been initialized?</p> <p>I'm a bit new to Python and am migrating from C, so I'm still getting used to the little differences like naming conventions.</p>
[ { "answer_id": 377384, "author": "Boojum", "author_id": 37555, "author_profile": "https://Stackoverflow.com/users/37555", "pm_score": 3, "selected": false, "text": "java.math.BigInteger" }, { "answer_id": 377401, "author": "soulmerge", "author_id": 44562, "author_prof...
2008/12/18
[ "https://Stackoverflow.com/questions/377362", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46981/" ]
377,377
<p>I have the following xsl that sorts my xml alphabetically:</p> <pre><code>&lt;xsl:template match="/"&gt; &lt;xsl:apply-templates /&gt; &lt;/xsl:template&gt; &lt;xsl:key name="rows-by-title" match="Row" use="translate(substring(@Title,1,1),'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')" /&gt; &lt;xsl:variable name="StartRow" select="string('&amp;lt;tr &amp;gt;')" /&gt; &lt;xsl:template name="Meunchian" match="/dsQueryResponse/Rows"&gt; &lt;table&gt; &lt;tr&gt; &lt;xsl:for-each select="Row[count(. | key('rows-by-title', translate(substring(@Title,1,1),'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ'))[1]) = 1]"&gt; &lt;xsl:sort select="translate(substring(@Title,1,1),'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')" /&gt; &lt;!-- Puts out the title --&gt; &lt;td&gt; &lt;xsl:value-of select="translate(substring(@Title,1,1),'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')" /&gt; &lt;/td&gt; &lt;!-- Now all it's children --&gt; &lt;xsl:for-each select="key('rows-by-title', translate(substring(@Title,1,1),'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ'))"&gt; &lt;xsl:value-of select="@Title" /&gt;&lt;br/&gt; &lt;/xsl:for-each&gt; &lt;/xsl:for-each&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/xsl:template&gt; </code></pre> <p>XML:</p> <pre><code>&lt;dsQueryResponse&gt; &lt;Rows&gt; &lt;Row Title="Agenda" /&gt; &lt;Row Title="Policy" /&gt; &lt;Row Title="Policy" /&gt; &lt;Row Title="Report" /&gt; &lt;Row Title="Report" /&gt; &lt;/Rows&gt; &lt;/dsQueryResponse&gt; </code></pre> <p>I now want to break the table row every 4 columns that are output so that the output looks something like:</p> <pre><code>ABCD EFGH IJKL MNOP QRST UVWX YZ </code></pre> <p>Can anyone suggest the best way to achieve this?</p> <p>Many Thanks</p>
[ { "answer_id": 380765, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 3, "selected": true, "text": "\"per-row\" \"show-empty\" <xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\">\n <xsl:outp...
2008/12/18
[ "https://Stackoverflow.com/questions/377377", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12318/" ]
377,393
<p>I got a templated control (a repeater) listing some text and other markup. Each item has a radiobutton associated with it, making it possible for the user to select ONE of the items created by the repeater.</p> <p>The repeater writes the radiobutton setting its id and name generated with the default ASP.NET naming convention making each radiobutton a full 'group'. This means all radiobuttons are independent on each other, which again unfortunately means I can select all radiobuttons at the same time. The radiobutton has the clever attribute 'groupname' used to set a common name, so they get grouped together and thus should be dependant (so I can only select one at a time). The problem is - this doesn't work - the repeater makes sure the id and thus the name (which controls the grouping) are different.</p> <p>Since I use a repeater (could have been a listview or any other templated databound control) I can't use the RadioButtonList. So where does that leave me?</p> <p>I know I've had this problem before and solved it. I know almost every ASP.NET programmer must have had it too, so why can't I google and find a solid solution to the problem? I came across solutions to enforce the grouping by JavaScript (ugly!) or even to handle the radiobuttons as non-server controls, forcing me to do a <code>Request.Form[name]</code> to read the status. I also tried experimenting with overriding the name attribute on the <code>PreRender</code> event - unfortunately the owning page and masterpage again overrides this name to reflect the full id/name, so I end up with the same wrong result.</p> <p>If you have no better solution than what I posted, you are still very welcome to post your thoughts - at least I'll know that my friend 'jack' is right about how messed up ASP.NET is sometimes ;)</p>
[ { "answer_id": 405414, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": false, "text": "function SetUniqueRadioButton(nameregex, current)\n{\n re = new RegExp(nameregex);\n for(i = 0; i < document.forms[0].elem...
2008/12/18
[ "https://Stackoverflow.com/questions/377393", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11619/" ]
377,400
<p>Currently i'm using pretty much Unix + Mysql + Perl + Apache with some javascript to make it more ajax like. and i've been looking at sites which are web 2.0 and stackoverflow and really like the simple design and the smooth flow from pages and action, etc.</p> <p>i'm trying to decide if learning catalyst, mason and the likes are going to be able to provide me with the capability to build powerful and smooth web 2.0 website with less effort and easier and cleaner code to maintain later.</p> <p>as of right now, i don't really like the website that i built as it's pretty much stale and slow. but <a href="https://stackoverflow.com/questions/105226/is-perl-still-a-viable-language-for-web-development">i've read from here</a> that if i want to build a career out of it, then LAMP would be a better choice?</p> <p>just wondering in terms of these three criterias, what would be my best step forward?</p> <ol> <li>career development</li> <li>ease of building powerful web 2.0 websites</li> <li>in what way is the Catalyst actually better than LAMP?</li> </ol> <p>thanks. ~steve</p>
[ { "answer_id": 378573, "author": "Brad Gilbert", "author_id": 1337, "author_profile": "https://Stackoverflow.com/users/1337", "pm_score": 2, "selected": false, "text": "EVAL_PERL" } ]
2008/12/18
[ "https://Stackoverflow.com/questions/377400", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38124/" ]
377,406
<p>This is a really basic question but this is the first time I've used MATLAB and I'm stuck. I need to simulate a simple series RC network using 3 different numerical integration techniques. I think I understand how to use the ode solvers, but I have no idea how to enter the differential equation of the system. Do I need to do it via an m-file?</p> <p>It's just a simple RC circuit in the form:</p> <pre><code>RC dy(t)/dt + y(t) = u(t) </code></pre> <p>with zero initial conditions. I have the values for R, C the step length and the simulation time but I don't know how to use MATLAB particularly well.</p> <p>Any help is much appreciated!</p>
[ { "answer_id": 378293, "author": "MatlabDoug", "author_id": 46439, "author_profile": "https://Stackoverflow.com/users/46439", "pm_score": 3, "selected": true, "text": "function dy = rigid(t,y)\n function dy = rigid(t,y)\n\ndy = sin(t);\n [T,Y] = ode45(@rigid,[0 2*pi],[0]);\n plot(T,Y)\n"...
2008/12/18
[ "https://Stackoverflow.com/questions/377406", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31168/" ]
377,407
<p>Assuming Windows, is there a way I can detect from within a batch file if it was launched from an open command prompt or by double-clicking? I'd like to add a pause to the end of the batch process if and only if it was double clicked, so that the window doesn't just disappear along with any useful output it may have produced.</p> <p>Any clever ways to do this? I'm looking for solutions I could rely on to work on a machine that was configured more or less with default settings.</p>
[ { "answer_id": 377472, "author": "foraidt", "author_id": 27596, "author_profile": "https://Stackoverflow.com/users/27596", "pm_score": 0, "selected": false, "text": "-nopause" }, { "answer_id": 377933, "author": "Patrick Cuff", "author_id": 7903, "author_profile": "ht...
2008/12/18
[ "https://Stackoverflow.com/questions/377407", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33346/" ]
377,417
<p>A common mistake when configuring the compilation/linking/etc. settings in VC++ 2008 is to set them in Release but not Debug (or vice versa) rather than setting them for "All Configurations". Any suggestions on how to avoid this kind of mistake?</p> <p>Some beginnings of ideas that I have:</p> <ul> <li><p>Find a way to make VC++ go to the "All Configurations" settings by default when you open the property pages rather than the active (Release / Debug) settings.</p></li> <li><p>Have a VB script that can be run (inside or outside VC++) to check the project settings and raise any inconsistencies detected.</p></li> </ul>
[ { "answer_id": 377472, "author": "foraidt", "author_id": 27596, "author_profile": "https://Stackoverflow.com/users/27596", "pm_score": 0, "selected": false, "text": "-nopause" }, { "answer_id": 377933, "author": "Patrick Cuff", "author_id": 7903, "author_profile": "ht...
2008/12/18
[ "https://Stackoverflow.com/questions/377417", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38659/" ]
377,423
<p>I just started writing tests for a lot of code. There's a bunch of classes with dependencies to the file system, that is they read CSV files, read/write configuration files and so on.</p> <p>Currently the test files are stored in the test directory of the project (it's a Maven2 project) but for several reasons this directory doesn't always exist, so the tests fail.</p> <p>Do you know best practices for coping with file system dependencies in unit/integration tests?</p> <p><strong>Edit:</strong> I'm not searching an answer for that specific problem I described above. That was just an example. I'd prefer general recommendations how to handle dependencies to the file system/databases etc.</p>
[ { "answer_id": 377500, "author": "jamesh", "author_id": 4737, "author_profile": "https://Stackoverflow.com/users/4737", "pm_score": 2, "selected": false, "text": "/tmp java.io.InputStream java.io.OutputStream InputStream getInputStream(File file) throws IOException {\n return new File...
2008/12/18
[ "https://Stackoverflow.com/questions/377423", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17473/" ]
377,425
<p>For learning and demonstrating, I need a macro which prints its parameter <strong>and</strong> evaluates it. I suspect it is a very common case, may be even a FAQ but I cannot find actual references.</p> <p>My current code is:</p> <pre><code>#define PRINT(expr) (fprintf(stdout, "%s -&gt; %d\n", __STRING(expr), (expr))) </code></pre> <p>and then:</p> <pre><code>PRINT(x &amp; 0x01); </code></pre> <p>It works fine but I am not sure of the legal status of the __STRING macro, specially since it is in the private __ namespace.</p> <p>So, my questions:</p> <ol> <li>Is there a better way to write this macro?</li> <li>Is __STRING standard/great/evil?</li> <li>How to use existing search tools to find about __STRING? SO's search engine just searches anything containing string :-(</li> </ol>
[ { "answer_id": 377441, "author": "aib", "author_id": 1088, "author_profile": "https://Stackoverflow.com/users/1088", "pm_score": 5, "selected": true, "text": "#include <stdlib.h>\n#include <stdio.h>\n\n#define STR(x) #x\n#define PRINT(expr) (fprintf(stdout, \"%s -> %d\\n\", STR(expr), (e...
2008/12/18
[ "https://Stackoverflow.com/questions/377425", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15625/" ]
377,454
<p>How do I get my Python program to sleep for 50 milliseconds?</p>
[ { "answer_id": 377460, "author": "Dan Olson", "author_id": 33346, "author_profile": "https://Stackoverflow.com/users/33346", "pm_score": 7, "selected": false, "text": "time.sleep() import time\ntime.sleep(50 / 1000)\n" }, { "answer_id": 377463, "author": "Will Boyce", "au...
2008/12/18
[ "https://Stackoverflow.com/questions/377454", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1816/" ]
377,457
<p>I have a rather large project developed on Sharepoint and Project Server, designed as a multi-tier application. I programmatically manage web parts on certain web part pages. According to the choices of the user in one of the web pages, appropriate web parts are added to the web part collection of another web part page. My problem is that I simply do no know where to manage the web parts, should I do it in the BLL and then have the assembly containing the business logic reference the UI assembly where the web parts are? (I need to instantiate the web parts when adding them to the collection, since I do not want to use hard coded strings representing the web part dwp.)</p>
[ { "answer_id": 377460, "author": "Dan Olson", "author_id": 33346, "author_profile": "https://Stackoverflow.com/users/33346", "pm_score": 7, "selected": false, "text": "time.sleep() import time\ntime.sleep(50 / 1000)\n" }, { "answer_id": 377463, "author": "Will Boyce", "au...
2008/12/18
[ "https://Stackoverflow.com/questions/377457", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1360/" ]