qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
228,377
<p>I want to run a psychological study for which participants have to look at large images.</p> <p>The experiment is done on the web and therefore in a browser window. Is it possible to tell the browser to go into fullscreen, for example on button press?</p> <p>I know there is the possibility to open a fixed-size popup window. Do you think this would be a feasable alternative? And if, what would be the best way to do it? Are there elegant ways of detecting a popup-blocker, to fallback and run the study in the original browser window.</p> <p>The main concern is that the participants of this study are not familiar with technical details and should not be bothered by them.</p>
[ { "answer_id": 228390, "author": "Darryl Hein", "author_id": 5441, "author_profile": "https://Stackoverflow.com/users/5441", "pm_score": 3, "selected": false, "text": "<script type=\"text/javascript\">\n<!--\nfunction popup(url) \n{\n params = 'width='+screen.width;\n params += ', heigh...
2008/10/23
[ "https://Stackoverflow.com/questions/228377", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21974/" ]
228,404
<p>I'm writing in second-person just because its easy, for you. </p> <p>You are working with a game engine and really wish a particular engine class had a new method that does 'bla'. But you'd rather not spread your 'game' code into the 'engine' code.</p> <p>So you could derive a new class from it with your one new method and put that code in your 'game' source directory, but maybe there's another option?</p> <p>So this is probably completely illegal in the C++ language, but you thought at first, "perhaps I can add a new method to an existing class via my own header that includes the 'parent' header and some special syntax. This is possible when working with a namespace, for example..."</p> <p>Assuming you can't declare methods of a class across multiple headers (and you are pretty darn sure you can't), what are the other options that support a clean divide between 'middleware/engine/library' and 'application', you wonder?</p>
[ { "answer_id": 228546, "author": "Tom Barta", "author_id": 29839, "author_profile": "https://Stackoverflow.com/users/29839", "pm_score": 4, "selected": true, "text": "std::string" } ]
2008/10/23
[ "https://Stackoverflow.com/questions/228404", "https://Stackoverflow.com", "https://Stackoverflow.com/users/168235/" ]
228,424
<p>I have the following query:</p> <pre><code>SELECT c.* FROM companies AS c JOIN users AS u USING(companyid) JOIN jobs AS j USING(userid) JOIN useraccounts AS us USING(userid) WHERE j.jobid = 123; </code></pre> <p>I have the following questions:</p> <ol> <li>Is the USING syntax synonymous with ON syntax?</li> <li>Are these joins evaluated left to right? In other words, does this query say: x = companies JOIN users; y = x JOIN jobs; z = y JOIN useraccounts;</li> <li>If the answer to question 2 is yes, is it safe to assume that the companies table has companyid, userid and jobid columns?</li> <li>I don't understand how the WHERE clause can be used to pick rows on the companies table when it is referring to the alias "j"</li> </ol> <p>Any help would be appreciated!</p>
[ { "answer_id": 228473, "author": "luke", "author_id": 25920, "author_profile": "https://Stackoverflow.com/users/25920", "pm_score": 0, "selected": false, "text": "SELECT c.*\nFROM companies AS c \n JOIN (SELECT * FROM users AS u \n JOIN (SELECT * FROM jobs AS j USING(userid) \...
2008/10/23
[ "https://Stackoverflow.com/questions/228424", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2056/" ]
228,441
<p>I am working on rails project and I am trying to get exceptions to be logged to the rails log files. I know I can call <code>logger.error $!</code> to get the first line of the exception logged to the file. But, I want to get the entire trace stack logged as well. How do I log the entire trace back of an exception using the default rails logger?</p>
[ { "answer_id": 228467, "author": "Redbeard", "author_id": 14977, "author_profile": "https://Stackoverflow.com/users/14977", "pm_score": 3, "selected": false, "text": "logger.error caller.join(\"\\n\")" }, { "answer_id": 236350, "author": "Ian Terrell", "author_id": 9269, ...
2008/10/23
[ "https://Stackoverflow.com/questions/228441", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5004/" ]
228,476
<p>Taking over some code from my predecessor and I found a query that uses the Like operator:</p> <pre><code>SELECT * FROM suppliers WHERE supplier_name like '%'+name+%'; </code></pre> <p>Trying to avoid SQL Injection problem and parameterize this but I am not quite sure how this would be accomplished. Any suggestions ?</p> <p>note, I need a solution for classic ADO.NET - I don't really have the go-ahead to switch this code over to something like LINQ.</p>
[ { "answer_id": 228488, "author": "Matt Hamilton", "author_id": 615, "author_profile": "https://Stackoverflow.com/users/615", "pm_score": 3, "selected": false, "text": "SELECT * FROM suppliers WHERE supplier_name like '%' + @name + '%'\n" }, { "answer_id": 228490, "author": "v...
2008/10/23
[ "https://Stackoverflow.com/questions/228476", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10676/" ]
228,477
<p>I would like to determine the operating system of the host that my Java program is running programmatically (for example: I would like to be able to load different properties based on whether I am on a Windows or Unix platform). What is the safest way to do this with 100% reliability?</p>
[ { "answer_id": 228481, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 10, "selected": true, "text": "System.getProperty(\"os.name\")\n" }, { "answer_id": 228499, "author": "VonC", "author_id": 6309, "autho...
2008/10/23
[ "https://Stackoverflow.com/questions/228477", "https://Stackoverflow.com", "https://Stackoverflow.com/users/318/" ]
228,518
<p>The goal: Any language. The smallest function which will return whether a string is a palindrome. Here is mine in <b>Python</b>:</p> <pre><code>R=lambda s:all(a==b for a,b in zip(s,reversed(s))) </code></pre> <p>50 characters.</p> <p>The accepted answer will be the current smallest one - this will change as smaller ones are found. Please specify the language your code is in.</p>
[ { "answer_id": 228526, "author": "Menkboy", "author_id": 29539, "author_profile": "https://Stackoverflow.com/users/29539", "pm_score": 5, "selected": false, "text": "p\n" }, { "answer_id": 228530, "author": "Adam Rosenfield", "author_id": 9530, "author_profile": "http...
2008/10/23
[ "https://Stackoverflow.com/questions/228518", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15055/" ]
228,523
<p>Following on from <a href="https://stackoverflow.com/questions/223832/check-a-string-to-see-if-all-characters-are-hexadecimal-values">this question</a> what would be the best way to write a Char.IsHex() function in C#. So far I've got this but don't like it:</p> <pre><code>bool CharIsHex(char c) { c = Char.ToLower(c); return (Char.IsDigit(c) || c == 'a' || c == 'b' || c == 'c' || c == 'd' || c == 'e' || c == 'f') } </code></pre>
[ { "answer_id": 228531, "author": "Paige Ruten", "author_id": 813, "author_profile": "https://Stackoverflow.com/users/813", "pm_score": 5, "selected": true, "text": "bool is_hex_char = (c >= '0' && c <= '9') ||\n (c >= 'a' && c <= 'f') ||\n (c >= 'A' &&...
2008/10/23
[ "https://Stackoverflow.com/questions/228523", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1463/" ]
228,532
<p>What's the difference between <code>Char.IsDigit()</code> and <code>Char.IsNumber()</code> in C#?</p>
[ { "answer_id": 228538, "author": "Guy", "author_id": 1463, "author_profile": "https://Stackoverflow.com/users/1463", "pm_score": 6, "selected": false, "text": "DecimalDigitNumber" }, { "answer_id": 228565, "author": "Michael Burr", "author_id": 12711, "author_profile"...
2008/10/23
[ "https://Stackoverflow.com/questions/228532", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1463/" ]
228,534
<p>Is there someway to set the default file permission in Linux? That is, the file permission for a newly created file (regardless of the context for which it was created ). I know about putting umask in the shell startup but that only works for shell sessions. When I transfer files to a Linux box using <strong>pscp</strong>, the file is always created with permissions of 664 (rw-rw-r--). The has occurred across every flavor of Linux that I've used. This is especially annoying when I pscp a file to shared Linux machine (like my ISP). Until I can shell in and chmod the permission, the file is basically sitting there with read access for everyone, which is not exactly secure.</p>
[ { "answer_id": 228564, "author": "Matt Curtis", "author_id": 17221, "author_profile": "https://Stackoverflow.com/users/17221", "pm_score": 4, "selected": false, "text": ".bash_profile" } ]
2008/10/23
[ "https://Stackoverflow.com/questions/228534", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24396/" ]
228,544
<p>If I want to check for the null string I would do</p> <pre><code>[ -z $mystr ] </code></pre> <p>but what if I want to check whether the variable has been defined at all? Or is there no distinction in Bash scripting?</p>
[ { "answer_id": 228552, "author": "Vinko Vrsalovic", "author_id": 5190, "author_profile": "https://Stackoverflow.com/users/5190", "pm_score": 5, "selected": false, "text": "~> if [ -z $FOO ]; then echo \"EMPTY\"; fi\nEMPTY\n~> FOO=\"\"\n~> if [ -z $FOO ]; then echo \"EMPTY\"; fi\nEMPTY\n~...
2008/10/23
[ "https://Stackoverflow.com/questions/228544", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30636/" ]
228,545
<p>A legacy backend requires the email body with a .tif document, no tif and it fails. So i need to generate a blank .tif, is there a fast way to do this with ghostscript? </p> <hr> <p>edit: make once in project installation use when i need it.</p>
[ { "answer_id": 229044, "author": "PhiLho", "author_id": 15459, "author_profile": "https://Stackoverflow.com/users/15459", "pm_score": 3, "selected": true, "text": "gswin32c.exe -q -dNOPAUSE -sDEVICE=tiffpack -g1x1 -sOutputFile=small.tif -c newpath 0 0 moveto 1 1 lineto closepath stroke s...
2008/10/23
[ "https://Stackoverflow.com/questions/228545", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21537/" ]
228,549
<p>I have GridView which I can select a row. I then have a button above the grid called Edit which the user can click to popup a window and edit the selected row. So the button will have Javascript code behind it along the lines of</p> <pre><code>function editRecord() { var gridView = document.getElementById("&lt;%= GridView.ClientID %&gt;"); var id = // somehow get the id here ??? window.open("edit.aspx?id=" + id); } </code></pre> <p>The question is how do I retrieve the selected records ID in javascript?</p>
[ { "answer_id": 228556, "author": "Dave K", "author_id": 19864, "author_profile": "https://Stackoverflow.com/users/19864", "pm_score": 1, "selected": false, "text": "function editRecord(clientId)\n{ ....\n" }, { "answer_id": 228616, "author": "Craig", "author_id": 27294, ...
2008/10/23
[ "https://Stackoverflow.com/questions/228549", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27294/" ]
228,559
<p>currently i obtain the below result from the following C# line of code when in es-MX Culture</p> <pre><code> Thread.CurrentThread.CurrentCulture = Thread.CurrentThread.CurrentUICulture = new CultureInfo("es-mx"); &lt;span&gt;&lt;%=DateTime.Now.ToLongDateString()%&gt;&lt;/span&gt; </code></pre> <h1>miércoles, 22 de octubre de 2008</h1> <p>i would like to obtain the following</p> <h1>Miércoles, 22 de Octubre de 2008</h1> <p>do i need to Build my own culture?</p>
[ { "answer_id": 228582, "author": "jfs", "author_id": 718, "author_profile": "https://Stackoverflow.com/users/718", "pm_score": 1, "selected": false, "text": "dddd, dd' de 'MMMM' de 'yyyy" }, { "answer_id": 228597, "author": "jaircazarin-old-account", "author_id": 20915, ...
2008/10/23
[ "https://Stackoverflow.com/questions/228559", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14440/" ]
228,567
<p>I have a section of makefile that has this sort of structure:</p> <pre><code> bob: ifdef DEBUG @echo running endif @echo chug chug chug ifdef DEBUG @echo done endif bobit: @echo "before" @make bob @echo "after" </code></pre> <p>I'm simplifying greatly here, all the echo's are actually non trivial blocks of commands and there is more conditional stuff, but this captures the essence of my problem.</p> <p>For technical reasons I don't want to get into right now, I need to get rid of that submake, but because the echo's represent nontrivial amounts of code I don't want to just copy and past the body of bob in place of the submake.</p> <p>Ideally what I'd like to do is something like this</p> <pre><code> define BOB_BODY ifdef DEBUG @echo running endif @echo chug chug chug ifdef DEBUG @echo done endif endef bob: $(BOB_BODY) bobit: @echo "before" $(BOB_BODY) @echo "after" </code></pre> <p>Unfortunately the conditionals seem to be shafting me, they produce "ifdef: Command not found" errors, I tried getting around this with various combinations of eval and call, but can't seem to figure out a way to get it to work.</p> <p>How do I make this work? and is it even the right way to approach the problem?</p>
[ { "answer_id": 233014, "author": "Gordon Wrigley", "author_id": 10471, "author_profile": "https://Stackoverflow.com/users/10471", "pm_score": 3, "selected": true, "text": "\ndefine BOB_BODY\n @if [[ -n \"$(DEBUG)\" ]]; then \\\n echo running; \\\n fi;\n @echo chug chug ch...
2008/10/23
[ "https://Stackoverflow.com/questions/228567", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10471/" ]
228,574
<p>I am tasked with updating a family of web sites that promote scientific conferences that cater to a niche scientific field. The sites are currently written with some modest CSS layout for the shared common page template structure, but the details of each page are a mishmash of &lt;p&gt;, &lt;br&gt;, and &amp;nbsp; to position the content. This makes it tough to update the content, since the spacings are always changing, and the page ends up ugly at the slightest mod.</p> <p>So, I'd like to change this stuff into a more CSS-happy state. There are lots of sites that offer tips for specific CSS design goals, but I'm a developer without a lot of web site artistry capabilities and don't have a structure already in mind. Are there any good sites that teach CSS in the context of some relatively mundane -- but effectively presented -- business content? Stuff like the CSS zen garden is way cool, but I'm looking more for something that will both give me some simple text-heavy business data positioning ideas <em>and</em> present those ideas as a CSS learning opportunity.</p> <p>Does any such site exist?</p>
[ { "answer_id": 234895, "author": "Bryan M.", "author_id": 4636, "author_profile": "https://Stackoverflow.com/users/4636", "pm_score": 3, "selected": true, "text": "<br/>" }, { "answer_id": 242221, "author": "dewde", "author_id": 2640, "author_profile": "https://Stacko...
2008/10/23
[ "https://Stackoverflow.com/questions/228574", "https://Stackoverflow.com", "https://Stackoverflow.com/users/404/" ]
228,590
<p>A couple of the options are:</p> <pre><code>$connection = {my db connection/object}; function PassedIn($connection) { ... } function PassedByReference(&amp;$connection) { ... } function UsingGlobal() { global $connection; ... } </code></pre> <p>So, passed in, passed by reference, or using global. I'm thinking in functions that are only used within 1 project that will only have 1 database connection. If there are multiple connections, the definitely passed in or passed by reference.</p> <p>I'm thining passed by reference is not needed when you are in PHP5 using an object, so then passed in or using global are the 2 possibilities.</p> <p>The reason I'm asking is because I'm getting tired of always putting in $connection into my function parameters.</p>
[ { "answer_id": 228596, "author": "Paige Ruten", "author_id": 813, "author_profile": "https://Stackoverflow.com/users/813", "pm_score": 0, "selected": false, "text": "mysql" }, { "answer_id": 228652, "author": "Richard Harrison", "author_id": 19624, "author_profile": "...
2008/10/23
[ "https://Stackoverflow.com/questions/228590", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5441/" ]
228,595
<p>I have an ADO.Net Data Service that I am using to do a data import. There are a number of entities that are linked to by most entities. To do that during import I create those entities first, save them and then use .SetLink(EntityImport, "NavigationProperty", CreatedEntity). Now the first issue that I ran into was that the context did not always know about CreatedEntity (this is due to each of the entities being imported independently and a creation of a context as each item is created - I'd like to retain this functionality - i.e. I'm trying to avoid "just use one context" as the answer). </p> <p>So I have a .AddToCreatedEntityType(CreatedEntity) before attempting to call SetLink. This of course works for the first time, but on the second pass I get the error message "the context is already tracking the entity". </p> <p>Is there a way to check if the context is already tracking the entity (context.Contains(CreatedEntity) isn't yet implemented)? I was thinking about attempting a try catch and just avoiding the error, but that seems to create a new CreatedEntity each pass. It is looking like I need to use a LINQ to Data Services to get that CreatedEntity each time, but that seems innefficient - any suggestions?</p>
[ { "answer_id": 228800, "author": "Davy Landman", "author_id": 11098, "author_profile": "https://Stackoverflow.com/users/11098", "pm_score": 3, "selected": false, "text": "public static class EntityObjectExtensions\n{\n public static Boolean IsTracked(this EntityObject self)\n {\n ...
2008/10/23
[ "https://Stackoverflow.com/questions/228595", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25719/" ]
228,614
<p>This is a bit of a lazyweb question but you get the rep so :-)</p> <p>I have a Java class that returns instances of itself to allow chaining (e.g. ClassObject.doStuff().doStuff())</p> <p>For instance:</p> <pre><code>public class Chainer { public Chainer doStuff() { /* Do stuff ... */ return this; } } </code></pre> <p>I would like to extend this class. Is there a way, perhaps using generics, to extend this class without having to overwrite each method signature?</p> <p>E.g. not:</p> <pre><code>public class ChainerExtender extends Chainer { public ChainerExtender doStuff() { super.doStuff(); return this; } } </code></pre> <p>I have tried:</p> <pre><code>public class Chainer { public &lt;A extends Chainer&gt; A doStuff() { /* Do stuff ... */ return (A)this; } } public class ChainerExtender extends Chainer { public &lt;A extends Chainer&gt; A doStuff() { /* Do stuff ... */ return super.doStuff(); } } </code></pre> <p>But this didn't work giving the error:</p> <pre><code>type parameters of &lt;A&gt;A cannot be determined; no unique maximal instance exists for type variable A with upper bounds A,Chainer </code></pre> <p>Am I forced to have class declarations like:</p> <pre><code>public class Chainer&lt;T extends Chainer&lt;T&gt;&gt; {} public class ChainerExtender extends Chainer&lt;ChainerExtender&gt; </code></pre> <p>As per <a href="https://stackoverflow.com/questions/153994/generic-type-args-which-specificy-the-extending-class">this question</a>?</p>
[ { "answer_id": 228632, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 1, "selected": false, "text": "public class Test {\n\n public static void main(String[] args) {\n // TODO Auto-generated method stub\n Chaine...
2008/10/23
[ "https://Stackoverflow.com/questions/228614", "https://Stackoverflow.com", "https://Stackoverflow.com/users/364/" ]
228,617
<p>I need a cross platform solution for clearing the console in both Linux and Windows written in C++. Are there any functions in doing this? Also make note that I don't want the end-user programmer to have to change any code in my program to get it to clear for Windows vs Linux (for example if it has to pick between two functions then the decision has to be made at run-time or at compile-time autonomously).</p>
[ { "answer_id": 228621, "author": "worbel", "author_id": 62575, "author_profile": "https://Stackoverflow.com/users/62575", "pm_score": 2, "selected": false, "text": "#include <windows.h>" }, { "answer_id": 228625, "author": "coppro", "author_id": 16855, "author_profile...
2008/10/23
[ "https://Stackoverflow.com/questions/228617", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62575/" ]
228,620
<p>I keep hearing people complaining that C++ doesn't have garbage collection. I also hear that the C++ Standards Committee is looking at adding it to the language. I'm afraid I just don't see the point to it... using RAII with smart pointers eliminates the need for it, right?</p> <p>My only experience with garbage collection was on a couple of cheap eighties home computers, where it meant that the system would freeze up for a few seconds every so often. I'm sure it has improved since then, but as you can guess, that didn't leave me with a high opinion of it.</p> <p>What advantages could garbage collection offer an experienced C++ developer?</p>
[ { "answer_id": 229619, "author": "David Cournapeau", "author_id": 11465, "author_profile": "https://Stackoverflow.com/users/11465", "pm_score": 3, "selected": false, "text": "#include <signal.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <unistd.h>\n\n#include <memory>\n\nusing n...
2008/10/23
[ "https://Stackoverflow.com/questions/228620", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12193/" ]
228,623
<p>This may be a simple fix - but I'm trying to sum together all the nodes (Size property from the Node class) on the binary search tree. Below in my BST class I have the following so far, but it returns 0:</p> <pre><code> private long sum(Node&lt;T&gt; thisNode) { if (thisNode.Left == null &amp;&amp; thisNode.Right == null) return 0; if (node.Right == null) return sum(thisNode.Left); if (node.Left == null) return sum(thisNode.Right); return sum(thisNode.Left) + sum(thisNode.Right); } </code></pre> <p>Within my Node class I have Data which stores Size and Name in their given properties. I'm just trying to sum the entire size. Any suggestions or ideas?</p>
[ { "answer_id": 228631, "author": "Vinko Vrsalovic", "author_id": 5190, "author_profile": "https://Stackoverflow.com/users/5190", "pm_score": 1, "selected": false, "text": " if (thisNode.Left == null && thisNode.Right == null)\n return thisNode.Size;\n" }, { "answer_id":...
2008/10/23
[ "https://Stackoverflow.com/questions/228623", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30649/" ]
228,642
<p>Python is quite cool, but unfortunately, its debugger is not as good as perl -d. </p> <p>One thing that I do very commonly when experimenting with code is to call a function from within the debugger, and step into that function, like so:</p> <pre><code># NOTE THAT THIS PROGRAM EXITS IMMEDIATELY WITHOUT CALLING FOO() ~&gt; cat -n /tmp/show_perl.pl 1 #!/usr/local/bin/perl 2 3 sub foo { 4 print "hi\n"; 5 print "bye\n"; 6 } 7 8 exit 0; ~&gt; perl -d /tmp/show_perl.pl Loading DB routines from perl5db.pl version 1.28 Editor support available. Enter h or `h h' for help, or `man perldebug' for more help. main::(/tmp/show_perl.pl:8): exit 0; # MAGIC HAPPENS HERE -- I AM STEPPING INTO A FUNCTION THAT I AM CALLING INTERACTIVELY DB&lt;1&gt; s foo() main::((eval 6)[/usr/local/lib/perl5/5.8.6/perl5db.pl:628]:3): 3: foo(); DB&lt;&lt;2&gt;&gt; s main::foo(/tmp/show_perl.pl:4): print "hi\n"; DB&lt;&lt;2&gt;&gt; n hi main::foo(/tmp/show_perl.pl:5): print "bye\n"; DB&lt;&lt;2&gt;&gt; n bye DB&lt;2&gt; n Debugged program terminated. Use q to quit or R to restart, use O inhibit_exit to avoid stopping after program termination, h q, h R or h O to get additional info. DB&lt;2&gt; q </code></pre> <p>This is incredibly useful when trying to step through a function's handling of various different inputs to figure out why it fails. However, it does not seem to work in either pdb or pydb (I'd show an equivalent python example to the one above but it results in a large exception stack dump).</p> <p>So my question is twofold:</p> <ol> <li>Am I missing something?</li> <li>Is there a python debugger that would indeed let me do this?</li> </ol> <p>Obviously I could put the calls in the code myself, but I love working interactively, eg. not having to start from scratch when I want to try calling with a slightly different set of arguments.</p>
[ { "answer_id": 228653, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 6, "selected": false, "text": "~> cat -n /tmp/test_python.py\n 1 #!/usr/local/bin/python\n 2\n 3 def foo():\n 4 print \"hi\"\n 5 ...
2008/10/23
[ "https://Stackoverflow.com/questions/228642", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
228,648
<p>I'm new to ruby and I'm playing around with the IRB.</p> <p>I found that I can list methods of an object using the ".methods" method, and that self.methods sort of give me what I want (similar to Python's dir(<strong>builtins</strong>)?), but how can I find the methods of a library/module I've loaded via include and require?</p> <pre><code>irb(main):036:0* self.methods =&gt; ["irb_pop_binding", "inspect", "taguri", "irb_chws", "clone", "irb_pushws", "public_methods", "taguri=", "irb_pwws", "public", "display", "irb_require", "irb_exit", "instance_variable_defined?", "irb_cb", "equal?", "freeze", "irb_context ", "irb_pop_workspace", "irb_cwb", "irb_jobs", "irb_bindings", "methods", "irb_current_working_workspace", "respond_to?" , "irb_popb", "irb_cws", "fg", "pushws", "conf", "dup", "cwws", "instance_variables", "source", "cb", "kill", "help", "_ _id__", "method", "eql?", "irb_pwb", "id", "bindings", "send", "singleton_methods", "popb", "irb_kill", "chws", "taint", "irb_push_binding", "instance_variable_get", "frozen?", "irb_source", "pwws", "private", "instance_of?", "__send__", "i rb_workspaces", "to_a", "irb_quit", "to_yaml_style", "irb_popws", "irb_change_workspace", "jobs", "type", "install_alias _method", "irb_push_workspace", "require_gem", "object_id", "instance_eval", "protected_methods", "irb_print_working_wor kspace", "irb_load", "require", "==", "cws", "===", "irb_pushb", "instance_variable_set", "irb_current_working_binding", "extend", "kind_of?", "context", "gem", "to_yaml_properties", "quit", "popws", "irb", "to_s", "to_yaml", "irb_fg", "cla ss", "hash", "private_methods", "=~", "tainted?", "include", "irb_cwws", "irb_change_binding", "irb_help", "untaint", "n il?", "pushb", "exit", "irb_print_working_binding", "is_a?", "workspaces"] irb(main):037:0&gt; </code></pre> <p>I'm used to python, where I use the dir() function to accomplish the same thing:</p> <pre><code>&gt;&gt;&gt; dir() ['__builtins__', '__doc__', '__name__', '__package__'] &gt;&gt;&gt; </code></pre>
[ { "answer_id": 228903, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "self.methods" }, { "answer_id": 232272, "author": "two-bit-fool", "author_id": 23899, "author_profile": "h...
2008/10/23
[ "https://Stackoverflow.com/questions/228648", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24718/" ]
228,672
<p>I am part of a team creating a web application using PHP and MySQL. The application will have multiple users with different roles. The application will also be used in a geographically distributed manner. Accordingly we need to create an access control system that operates at the following two levels:</p> <ol> <li>Controls user permissions for specific php pages i.e. provides or denies access to specific pages (or user interface elements) based on the user's role. For example: a user may be allowed access to the "Students" page but not to the "Teachers" page.</li> <li>Controls user permissions for specific database records i.e. modifies database queries so that only specific records are displayed. For example, for a user at the city level, only those records should be displayed that relate to the user's particular city, while for a user at the national level, records for ALL CITIES in the country should be displayed.</li> </ol> <p>I need help on designing a system that can handle both these types of access control. Point no. 1 seems to be simple enough. However, I am completely at a loss on how to do point number 2 without hardcoding the information in the SQL queries.</p> <p>Any help would be appreciated. </p> <p>Thanks in advance</p> <p>Vinayak</p>
[ { "answer_id": 325805, "author": "Michał Niedźwiedzki", "author_id": 2169, "author_profile": "https://Stackoverflow.com/users/2169", "pm_score": 5, "selected": true, "text": "IAuthorizable" } ]
2008/10/23
[ "https://Stackoverflow.com/questions/228672", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22009/" ]
228,680
<p>How does one import CSV files via Excel VBA in a set, in groups or in multiple individual files, rather than one at a time?</p>
[ { "answer_id": 228973, "author": "dbb", "author_id": 25675, "author_profile": "https://Stackoverflow.com/users/25675", "pm_score": 1, "selected": false, "text": "Open \"myfile.csv\" For Input As 1\nDim Txt As String\nTxt = Input(LOF(1), 1)\nClose #1\nDim V As Variant\nV = Split(Txt, \",\...
2008/10/23
[ "https://Stackoverflow.com/questions/228680", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
228,684
<p>If I have a source.c file with a struct:</p> <pre><code>struct a { int i; struct b { int j; } }; </code></pre> <p>How can this struct be used in another file (i.e. <code>func.c</code>)?</p> <p>Should I create a new header file, declare the struct there and include that header in <code>func.c</code>?</p> <p>Or should I define the whole struct in a header file and include that in both <code>source.c</code> and <code>func.c</code>? How can the struct be declared <code>extern</code> in both files?</p> <p>Should I <code>typedef</code> it? If so, how?</p>
[ { "answer_id": 228689, "author": "fmsf", "author_id": 26004, "author_profile": "https://Stackoverflow.com/users/26004", "pm_score": 3, "selected": false, "text": "#ifndef A_H\n#define A_H\n\nstruct a { \n int i;\n struct b {\n int j;\n }\n};\n\n#endif\n" }, { "ans...
2008/10/23
[ "https://Stackoverflow.com/questions/228684", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
228,702
<p>Say I have the classic 4-byte signed integer, and I want something like</p> <pre><code>print hex(-1) </code></pre> <p>to give me something like</p> <blockquote> <p>0xffffffff</p> </blockquote> <p>In reality, the above gives me <code>-0x1</code>. I'm dawdling about in some lower level language, and python commandline is quick n easy.</p> <p>So.. is there a way to do it?</p>
[ { "answer_id": 228708, "author": "paxdiablo", "author_id": 14860, "author_profile": "https://Stackoverflow.com/users/14860", "pm_score": 6, "selected": true, "text": ">>> print(hex (-1 & 0xffffffff))\n0xffffffff\n" }, { "answer_id": 228785, "author": "Ignacio Vazquez-Abrams",...
2008/10/23
[ "https://Stackoverflow.com/questions/228702", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23648/" ]
228,705
<p>I know I'm gonna get down votes, but I have to make sure if this is logical or not.</p> <p>I have three tables A, B, C. B is a table used to make a many-many relationship between A and C. But the thing is that A and C are also related directly in a 1-many relationship</p> <p>A customer added the following requirement:</p> <p>Obtain the information from the Table B inner joining with A and C, and in the same query relate A and C in a one-many relationship</p> <p>Something like:</p> <p><a href="http://img247.imageshack.us/img247/7371/74492374sa4.png" rel="nofollow noreferrer">alt text http://img247.imageshack.us/img247/7371/74492374sa4.png</a></p> <p>I tried doing the query but always got 0 rows back. The customer insists that I can accomplish the requirement, but I doubt it. Any comments?</p> <p>PS. I didn't have a more descriptive title, any ideas?</p> <p>UPDATE: Thanks to rcar, In some cases this can be logical, in order to have a history of all the classes a student has taken (supposing the student can only take one class at a time)</p> <p>UPDATE: There is a table for Contacts, a table with the Information of each Contact, and the Relationship table. To get the information of a Contact I have to make a 1:1 relationship with Information, and each contact can have like and an address book with; this is why the many-many relationship is implemented.</p> <p>The full idea is to obtain the contact's name and his address book. Now that I got the customer's idea... I'm having trouble with the query, basically I am trying to use the query that jdecuyper wrote, but as he warns, I get no data back</p>
[ { "answer_id": 228739, "author": "jdecuyper", "author_id": 296, "author_profile": "https://Stackoverflow.com/users/296", "pm_score": 1, "selected": false, "text": "SELECT * FROM relAC RAC\n INNER JOIN tableA A ON A.id_class = RAC.id_class \n INNER JOIN tableC C ON C.id_class = RAC.id_c...
2008/10/23
[ "https://Stackoverflow.com/questions/228705", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23146/" ]
228,723
<p>Now that Silverlight 2 has finally shipped. I'm wondering if anyone has put together any logging frameworks for it, maybe something like <a href="http://msdn.microsoft.com/en-us/library/ff647183.aspx" rel="noreferrer">enterprise library logging</a> or <a href="http://logging.apache.org/log4net/" rel="noreferrer">log4net</a>? I'm interesting in something that can perform tracing client side and also log messages to the server.</p> <p>So far the only project I have found is <a href="http://clog.codeplex.com/" rel="noreferrer">Clog</a> on <a href="http://www.codeproject.com/KB/silverlight/SilverlightLogging.aspx" rel="noreferrer">CodeProject</a>. Has anyone used this? What were your thoughts on it?</p>
[ { "answer_id": 905607, "author": "Rene Schulte", "author_id": 79954, "author_profile": "https://Stackoverflow.com/users/79954", "pm_score": 3, "selected": false, "text": " // http://kodierer.blogspot.com.es/2009/05/silverlight-logging-extension-method.html\n public static string Lo...
2008/10/23
[ "https://Stackoverflow.com/questions/228723", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30664/" ]
228,724
<p>Im creating a report using crystal report in vb.net.</p> <p>The report contained a crosstab which I have 3 data: 1. Dealer - row field 2. Month - column 3. Quantity Sales - summarize field</p> <p>How can I arrange this by ascending order based on the Quantity Sales - summarize field?</p> <p>thanks</p>
[ { "answer_id": 234541, "author": "thismat", "author_id": 14045, "author_profile": "https://Stackoverflow.com/users/14045", "pm_score": 2, "selected": false, "text": "SELECT customer, sum(amountdue) AS total FROM invoices \nGROUP BY customer\nORDER BY total ASC\n" } ]
2008/10/23
[ "https://Stackoverflow.com/questions/228724", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
228,726
<p>The coding is done using VS2008 There are two divs in my page namely "dvLeftContent" and "dvRightContent". I cannot statically set the height of the pages since "dvRightContent" have variable heights on various pages (Master Pages are used here) Is there a client side function(javascript or jquery) that takes the height of the right div and assigns it to left div?</p>
[ { "answer_id": 234541, "author": "thismat", "author_id": 14045, "author_profile": "https://Stackoverflow.com/users/14045", "pm_score": 2, "selected": false, "text": "SELECT customer, sum(amountdue) AS total FROM invoices \nGROUP BY customer\nORDER BY total ASC\n" } ]
2008/10/23
[ "https://Stackoverflow.com/questions/228726", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17447/" ]
228,730
<p>As an example, lets say I wanted to list the frequency of each letter of the alphabet in a string. What would be the easiest way to do it?</p> <p>This is an example of what I'm thinking of... the question is how to make allTheLetters equal to said letters without something like allTheLetters = "abcdefg...xyz". In many other languages I could just do letter++ and increment my way through the alphabet, but thus far I haven't come across a way to do that in python.</p> <pre><code>def alphCount(text): lowerText = text.lower() for letter in allTheLetters: print letter + ":", lowertext.count(letter) </code></pre>
[ { "answer_id": 228734, "author": "Jacob Krall", "author_id": 3140, "author_profile": "https://Stackoverflow.com/users/3140", "pm_score": 2, "selected": false, "text": "for letter in range(ord('a'), ord('z') + 1):\n print chr(letter) + \":\", lowertext.count(chr(letter))\n" }, { ...
2008/10/23
[ "https://Stackoverflow.com/questions/228730", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1512/" ]
228,775
<p>I'm trying to do some async stuff in a webservice method. Let say I have the following API call: <a href="http://www.example.com/api.asmx" rel="nofollow noreferrer">http://www.example.com/api.asmx</a></p> <p>and the method is called <em>GetProducts()</em>.</p> <p>I this GetProducts methods, I do some stuff (eg. get data from database) then just before i return the result, I want to do some async stuff (eg. send me an email).</p> <p>So this is what I did.</p> <pre><code>[WebMethod(Description = "Bal blah blah.")] public IList&lt;Product&gt; GetProducts() { // Blah blah blah .. // Get data from DB .. hi DB! // var myData = ....... // Moar clbuttic blahs :) (yes, google for clbuttic if you don't know what that is) // Ok .. now send me an email for no particular reason, but to prove that async stuff works. var myObject = new MyObject(); myObject.SendDataAsync(); // Ok, now return the result. return myData; } } public class TrackingCode { public void SendDataAsync() { var backgroundWorker = new BackgroundWorker(); backgroundWorker.DoWork += BackgroundWorker_DoWork; backgroundWorker.RunWorkerAsync(); //System.Threading.Thread.Sleep(1000 * 20); } private void BackgroundWorker_DoWork(object sender, DoWorkEventArgs e) { SendEmail(); } } </code></pre> <p>Now, when I run this code the email is never sent. If I uncomment out the Thread.Sleep .. then the email is sent.</p> <p>So ... why is it that the background worker thread is torn down? is it dependant on the parent thread? Is this the wrong way I should be doing background or forked threading, in asp.net web apps?</p>
[ { "answer_id": 228798, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 5, "selected": true, "text": "BackgroundWorker" }, { "answer_id": 241708, "author": "Marc Gravell", "author_id": 23354, "author_...
2008/10/23
[ "https://Stackoverflow.com/questions/228775", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30674/" ]
228,783
<p>It's common in C++ to name member variables with some kind of prefix to denote the fact that they're member variables, rather than local variables or parameters. If you've come from an MFC background, you'll probably use <code>m_foo</code>. I've also seen <code>myFoo</code> occasionally.</p> <p>C# (or possibly just .NET) seems to recommend using just an underscore, as in <code>_foo</code>. Is this allowed by the C++ standard?</p>
[ { "answer_id": 228797, "author": "Martin York", "author_id": 14065, "author_profile": "https://Stackoverflow.com/users/14065", "pm_score": 11, "selected": true, "text": "std" }, { "answer_id": 228848, "author": "paercebal", "author_id": 14089, "author_profile": "https...
2008/10/23
[ "https://Stackoverflow.com/questions/228783", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8446/" ]
228,795
<p>If I have the following code (this was written in .NET)</p> <pre><code>double i = 0.1 + 0.1 + 0.1; </code></pre> <p>Why doesn't <code>i</code> equal <code>0.3</code>?<br> Any ideas?</p>
[ { "answer_id": 228802, "author": "paxdiablo", "author_id": 14860, "author_profile": "https://Stackoverflow.com/users/14860", "pm_score": 3, "selected": false, "text": "if (abs(a-b) < epsilon) { ...\n" }, { "answer_id": 228808, "author": "Nico", "author_id": 22970, "au...
2008/10/23
[ "https://Stackoverflow.com/questions/228795", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
228,796
<p>I want to write a odometer-like method in a C#-style-language, but not just using 0-9 for characters, but any set of characters. It will act like a brute-force application, more or less.</p> <p>If I pass in a char-array of characters from <strong>0</strong> to <strong>J</strong>, and set length to 5, I want results like <em>00000, 00001, 00002... HJJJJ, IJJJJJ, JJJJJ</em>.</p> <p>Here is the base, please help me expand:</p> <pre><code>protected void Main() { char[] chars = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J' }; BruteForce(chars, 5); } private void BruteForce(char[] chars, int length) { // for-loop (?) console-writing all possible combinations from 00000 to JJJJJ // (when passed in length is 5) // TODO: Implement code... } </code></pre>
[ { "answer_id": 228815, "author": "leppie", "author_id": 15541, "author_profile": "https://Stackoverflow.com/users/15541", "pm_score": 0, "selected": false, "text": "for (int i = 0; i < (1 << 24); i++)\n string s = i.ToString(\"X6\");\n" }, { "answer_id": 228825, "author": "J...
2008/10/23
[ "https://Stackoverflow.com/questions/228796", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2429/" ]
228,814
<p>I need a little help on this subject.</p> <p>I have a Web application written in ASP.NET plus I have the .bak file of the SQL Express database, my question is: How can I install this in a simple click and go way in the client?</p> <p>how can I write a script that will create a new database, restore the bak file into that database, set up IIS and ... well, that's it :)</p> <p>I do this all manually, and I do this a lot, so I was just asking if there is a way to prevent do all this steps manually.</p> <p>Thanks.</p>
[ { "answer_id": 232487, "author": "Adrian Clark", "author_id": 148, "author_profile": "https://Stackoverflow.com/users/148", "pm_score": 1, "selected": false, "text": "App_Data" } ]
2008/10/23
[ "https://Stackoverflow.com/questions/228814", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28004/" ]
228,835
<p>what is the best practice for multilanguage website using DOM Manipulating with javascript? I build some dynamic parts of the website using javascript. My first thought was using an array with the text strings and the language code as index. Is this a good idea?</p>
[ { "answer_id": 228879, "author": "nickf", "author_id": 9021, "author_profile": "https://Stackoverflow.com/users/9021", "pm_score": 7, "selected": true, "text": "// lang.en.js\nlang = {\n greeting : \"Hello\"\n};\n\n// lang.fr.js\nlang = {\n greeting : \"Bonjour\"\n};\n" }, { ...
2008/10/23
[ "https://Stackoverflow.com/questions/228835", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3214/" ]
228,851
<p>Has anybody tried creating <code>RawSocket</code> in <code>Android</code> and have succeeded ?</p>
[ { "answer_id": 246911, "author": "Alnitak", "author_id": 6782, "author_profile": "https://Stackoverflow.com/users/6782", "pm_score": 3, "selected": false, "text": "Socket" } ]
2008/10/23
[ "https://Stackoverflow.com/questions/228851", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
228,863
<p>I am considering creating some JSP-tags that will always give the same output. For example:</p> <pre><code>&lt;foo:bar&gt;baz&lt;/foo:bar&gt; </code></pre> <p>Will always output:</p> <pre><code>&lt;div class="bar"&gt;baz&lt;/div&gt; </code></pre> <p>Is there any way to get a JSP-tag to behave just like static output in the generated servlet?</p> <p>For example:</p> <pre><code>out.write("&lt;div class=\"bar\"&gt;"); ... out.write("&lt;/div&gt;"); </code></pre> <p>in stead of</p> <pre><code>x.y.z.foo.BarTag _jspx_th_foo_bar_0 = new x.y.z.foo.BarTag(); _jspx_th_foo_bar_0.setPageContext(pageContext); _jspx_th_foo_bar_0.setParent(null); _jspxTagObjects.push(_jspx_th_foo_bar_0); int _jspx_eval_foo_bar_0 = _jspx_th_foo_bar_0.doStartTag(); etc... etc... etc... </code></pre> <h2>Background</h2> <p>I'm worried about performance. I haven't tested this yet, but it looks like the generated servlet does a lot for something very simple, and performance is very important.</p> <p>But if the servlet behaves as if the output was written directly in the JSP, the cost in production will be zero.</p> <p>I see a few advantages by doing this. I can change the static HTML or even change to something more dynamic, without editing every portlet. In our setup it's easy to change a tag, but very time-consuming to change every JSP that uses a specific element.</p> <p>This also means I can force developers to not write something like</p> <pre><code>&lt;div class="bar" style="whatever"&gt;...&lt;/div&gt; </code></pre> <p>There is even more advantages, but if it costs performance on the production servers, it's probably not worth it.</p>
[ { "answer_id": 239624, "author": "myplacedk", "author_id": 28683, "author_profile": "https://Stackoverflow.com/users/28683", "pm_score": 2, "selected": true, "text": "package XX.XX.XX.XX\n\nimport java.io.IOException;\n\nimport javax.servlet.jsp.JspException;\nimport javax.servlet.jsp.ta...
2008/10/23
[ "https://Stackoverflow.com/questions/228863", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28683/" ]
228,875
<p>I have data coming from the database in the form of a <code>DataSet</code>. I then set it as the <code>DataSource</code> of a grid control before doing a <code>DataBind()</code>. I want to sort the <code>DataSet</code>/<code>DataTable</code> on one column. The column is to complex to sort in the database but I was hoping I could sort it like I would sort a generic list i.e. using a deligate.</p> <p>Is this possible or do I have to transfer it to a different data structure?</p> <p><strong>Edit</strong> I can't get any of these answer to work for me, I think because I am using <strong>.Net 2.0.</strong></p>
[ { "answer_id": 228890, "author": "Toby", "author_id": 291137, "author_profile": "https://Stackoverflow.com/users/291137", "pm_score": 2, "selected": false, "text": "var dt = new DataTable();\ngvWhatever.DataSource = dt.Select().ToList().Sort();\n" }, { "answer_id": 228892, "a...
2008/10/23
[ "https://Stackoverflow.com/questions/228875", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18107/" ]
228,908
<p>Recently, I noticed some people mentioning that <code>std::list::size()</code> has a linear complexity.<br> According to <a href="http://www.cplusplus.com/reference/stl/list/size.html" rel="noreferrer">some</a> <a href="http://bytes.com/forum/thread60248.html" rel="noreferrer">sources</a>, this is in fact implementation dependent as the standard doesn't say what the complexity has to be.<br> The comment <a href="http://ahlamnote.blogspot.com/2006/11/stl-list-size-method-is-slow.html" rel="noreferrer">in this blog entry</a> says:</p> <blockquote> <p>Actually, it depends on which STL you are using. Microsoft Visual Studio V6 implements size() as {return (_Size); } whereas gcc (at least in versions 3.3.2 and 4.1.0) do it as { return std::distance(begin(), end()); } The first has constant speed, the second has o(N) speed</p> </blockquote> <ol> <li>So my guess is that for the VC++ crowd <code>size()</code> has constant complexity as Dinkumware probably won't have changed that fact since VC6. Am I right there?<br></li> <li>What does it look like currently in <code>gcc</code>? If it is really O(n), why did the developers choose to do so?</li> </ol>
[ { "answer_id": 228914, "author": "Michael Burr", "author_id": 12711, "author_profile": "https://Stackoverflow.com/users/12711", "pm_score": 7, "selected": true, "text": "list::size()" }, { "answer_id": 230629, "author": "introp", "author_id": 8398, "author_profile": "...
2008/10/23
[ "https://Stackoverflow.com/questions/228908", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27596/" ]
228,912
<p>Using SQLite3 with Python 2.5, I'm trying to iterate through a list and pull the weight of an item from the database based on the item's name.</p> <p>I tried using the "?" parameter substitution suggested to prevent SQL injections but it doesn't work. For example, when I use:</p> <pre><code>for item in self.inventory_names: self.cursor.execute("SELECT weight FROM Equipment WHERE name = ?", item) self.cursor.close() </code></pre> <p>I get the error:</p> <blockquote> <p>sqlite3.ProgrammingError: Incorrect number of bindings supplied. The current statement uses 1, and there are 8 supplied.</p> </blockquote> <p>I believe this is somehow caused by the initial creation of the database; the module I made that actually creates the DB does have 8 bindings.</p> <pre><code>cursor.execute("""CREATE TABLE Equipment (id INTEGER PRIMARY KEY, name TEXT, price INTEGER, weight REAL, info TEXT, ammo_cap INTEGER, availability_west TEXT, availability_east TEXT)""") </code></pre> <p>However, when I use the less-secure "%s" substitution for each item name, it works just fine. Like so:</p> <pre><code>for item in self.inventory_names: self.cursor.execute("SELECT weight FROM Equipment WHERE name = '%s'" % item) self.cursor.close() </code></pre> <p>I can't figure out why it thinks I have 8 bindins when I'm only calling one. How can I fix it?</p>
[ { "answer_id": 228961, "author": "Blauohr", "author_id": 22176, "author_profile": "https://Stackoverflow.com/users/22176", "pm_score": 2, "selected": false, "text": "for item in self.inventory_names:\n t = (item,)\n self.cursor.execute(\"SELECT weight FROM Equipment WHERE name = ?\...
2008/10/23
[ "https://Stackoverflow.com/questions/228912", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18676/" ]
228,926
<p>How do you find out the local time of the user browsing your website in ASP.NET? </p>
[ { "answer_id": 229020, "author": "Dave Anderson", "author_id": 371, "author_profile": "https://Stackoverflow.com/users/371", "pm_score": 4, "selected": true, "text": "function setNow(hiddenInputId)\n{\n var now = new Date();\n var input = document.getElementById(hiddenInputId);\n...
2008/10/23
[ "https://Stackoverflow.com/questions/228926", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16628/" ]
228,931
<p>I'm using this code, to make a request to a given URL:</p> <pre><code>private static string GetWebRequestContent(string url) { string sid = String.Empty; HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(url); req.KeepAlive = false; using (HttpWebResponse res = (HttpWebResponse)req.GetResponse()) { using (StreamReader sr = new StreamReader(res.GetResponseStream())) { sid = sr.ReadToEnd().Trim(); } } return sid; } </code></pre> <p>I'm using it to test the stickyness of a Work Load Balancer, with 3 servers behind it. They all have a static HTM file called sid.htm, where the server's Server ID is written.</p> <p>For URL's with HTTP this works fine. But with HTTPS it doesn't work. I get this exception:</p> <blockquote> <p>The request was aborted: Could not create SSL/TLS secure channel.</p> </blockquote> <p>At the moment, I have only 2 servers behind the WLB and one on its own with a public IP behind a firewall. HTTPS requests works fine if I hit the stand-alone server - but when I hit the WLB I get the above error.</p> <p>One thing: In order to switch between hitting the single server, and the WLB I use my hosts file. The DNS records for my domain points to the single server at the moment. So I put a record in my hosts file to hit the WLB. This shouldn't be causing problems...</p> <p><strong>My question</strong>: Which SSL credentials/certificates does the HttpWebRequest use? If it uses 40 bit DES or 56 bit DES, that's the reason, because those are disabled in the WLB. But those certificates haven't been used in browsers since IE3 and Netscape 1 and 2.</p>
[ { "answer_id": 228954, "author": "MartinHN", "author_id": 2972, "author_profile": "https://Stackoverflow.com/users/2972", "pm_score": 4, "selected": true, "text": "ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;\n" } ]
2008/10/23
[ "https://Stackoverflow.com/questions/228931", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2972/" ]
228,945
<p>I find System.Monitor very confusing, although I understand threading, locks, deadlocks, race conditions, dining philosophers and all that jazz. Normally I use a ManualResetEvent() to do inter-thread co-ordination, but I know that that's a heavyweight kernel object, and that System.Monitor (Enter/Pulse, etc.) is much more efficient. I've Googled and Googled but cannot find a sensible example.</p> <p>I would be most grateful if the SO crew could explain this potentially wonderful construct to me :-)</p>
[ { "answer_id": 228983, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 4, "selected": true, "text": "Wait" } ]
2008/10/23
[ "https://Stackoverflow.com/questions/228945", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25462/" ]
228,969
<p>I am getting the following error when I post back a page from the client-side. I have JavaScript code that modifies an asp:ListBox on the client side.</p> <p>How do we fix this?</p> <p>Error details below:</p> <pre><code>Server Error in '/XXX' Application. -------------------------------------------------------------------------------- Invalid postback or callback argument. Event validation is enabled using &lt;pages enableEventValidation="true"/&gt; in configuration or &lt;%@ Page EnableEventValidation="true" %&gt; in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.ArgumentException: Invalid postback or callback argument. Event validation is enabled using &lt;pages enableEventValidation="true"/&gt; in configuration or &lt;%@ Page EnableEventValidation="true" %&gt; in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation. Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace: [ArgumentException: Invalid postback or callback argument. Event validation is enabled using &lt;pages enableEventValidation="true"/&gt; in configuration or &lt;%@ Page EnableEventValidation="true" %&gt; in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.] System.Web.UI.ClientScriptManager.ValidateEvent(String uniqueId, String argument) +2132728 System.Web.UI.Control.ValidateEvent(String uniqueID, String eventArgument) +108 System.Web.UI.WebControls.ListBox.LoadPostData(String postDataKey, NameValueCollection postCollection) +274 System.Web.UI.WebControls.ListBox.System.Web.UI.IPostBackDataHandler.LoadPostData(String postDataKey, NameValueCollection postCollection) +11 System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad) +353 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1194 -------------------------------------------------------------------------------- Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433 </code></pre>
[ { "answer_id": 245512, "author": "Andy C.", "author_id": 28541, "author_profile": "https://Stackoverflow.com/users/28541", "pm_score": 5, "selected": false, "text": "<select>" }, { "answer_id": 275724, "author": "Community", "author_id": -1, "author_profile": "https:/...
2008/10/23
[ "https://Stackoverflow.com/questions/228969", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13370/" ]
228,978
<p>I have this Perl script with many defined constants of configuration files. For example:</p> <pre><code>use constant { LOG_DIR =&gt; "/var/log/", LOG_FILENAME =&gt; "/var/log/file1.log", LOG4PERL_CONF_FILE =&gt; "/etc/app1/log4perl.conf", CONF_FILE1 =&gt; "/etc/app1/config1.xml", CONF_FILE2 =&gt; "/etc/app1/config2.xml", CONF_FILE3 =&gt; "/etc/app1/config3.xml", CONF_FILE4 =&gt; "/etc/app1/config4.xml", CONF_FILE5 =&gt; "/etc/app1/config5.xml", }; </code></pre> <p>I want to reduce duplication of "/etc/app1" and "/var/log" , but using variables does not work. Also using previously defined constants does not work in the same "use constant block". For example:</p> <pre><code>use constant { LOG_DIR =&gt; "/var/log/", FILE_FILENAME =&gt; LOG_DIR . "file1.log" }; </code></pre> <p>does not work.</p> <p>Using separate "use constant" blocks does workaround this problem, but that adds a lot of unneeded code.</p> <p>What is the correct way to do this?</p> <p>Thank you.</p>
[ { "answer_id": 228991, "author": "Leon Timmermans", "author_id": 4727, "author_profile": "https://Stackoverflow.com/users/4727", "pm_score": 2, "selected": false, "text": "constant->import" }, { "answer_id": 229061, "author": "Ovid", "author_id": 8003, "author_profile...
2008/10/23
[ "https://Stackoverflow.com/questions/228978", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13523/" ]
228,987
<p>We try to convert from string to <code>Byte[]</code> using the following Java code:</p> <pre><code>String source = "0123456789"; byte[] byteArray = source.getBytes("UTF-16"); </code></pre> <p>We get a byte array of length 22 bytes, we are not sure where this padding comes from. How do I get an array of length 20?</p>
[ { "answer_id": 229006, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 7, "selected": true, "text": "String source = \"0123456789\";\nbyte[] byteArray = source.getBytes(\"UTF-16LE\"); // Or UTF-16BE\n" } ]
2008/10/23
[ "https://Stackoverflow.com/questions/228987", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30704/" ]
229,007
<p>I am running the free version of Helicon ISAPI Rewrite on IIS and have several sites running through the same set of rewrite rules. Up 'til now this has been fine as all the rules have applied to all the sites. I have recently added a new site which I don't want to run through all the rules. Is there any way to make requests to this site break out of the rule set after it's executed its own rules.</p> <p>I've tried the following with no luck; all requests to mysite.com result in a 404. I guess what I'm looking for is a rule that does nothing and is marked as the last rule to execute [L].</p> <pre><code>## New site rule for mysite.com only RewriteCond Host: (?:www\.)?mysite\.com RewriteRule /content([\w/]*) /content.aspx?page=$1 [L] ## Break out of processing for all other requests to mysite.com RewriteCond Host: (?:www\.)?mysite\.com RewriteRule (.*) - [L] ## Rules for all other sites RewriteRule ^/([^\.\?]+)/?(\?.*)?$ /$1.aspx$2 [L] ... </code></pre>
[ { "answer_id": 229026, "author": "Zebra North", "author_id": 17440, "author_profile": "https://Stackoverflow.com/users/17440", "pm_score": 2, "selected": false, "text": "RewriteCond Host: (?:www\\.)?mysite\\.com\nRewriteRule ^(.*)$ $1 [QSA,L]\n" }, { "answer_id": 229523, "a...
2008/10/23
[ "https://Stackoverflow.com/questions/229007", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2179408/" ]
229,009
<p>Is there a way I can access (for printout) a list of sub + module to arbitrary depth of sub-calls preceding a current position in a Perl script?</p> <p>I need to make changes to some Perl modules (.pm's). The workflow is initiated from a web-page thru a cgi-script, passing input through several modules/objects ending in the module where I need to use the data. Somewhere along the line the data got changed and I need to find out where.</p>
[ { "answer_id": 229030, "author": "Ovid", "author_id": 8003, "author_profile": "https://Stackoverflow.com/users/8003", "pm_score": 7, "selected": true, "text": "use Devel::StackTrace;\nmy $trace = Devel::StackTrace->new;\nprint $trace->as_string; # like carp\n" }, { "answer_id": 2...
2008/10/23
[ "https://Stackoverflow.com/questions/229009", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15161/" ]
229,010
<pre><code>$("#dvMyDIV").bind("resize", function(){ alert("Resized"); }); </code></pre> <p>or</p> <pre><code>$("#dvMyDIV").resize(function(){ alert("Resized"); }); </code></pre> <p>The questions</p> <ol> <li>Why is this not working at FireFox, Chrome and Safari?</li> <li>Can this be considered a jQuery bug since the resize is not handled for other browsers?</li> <li>Could the only workaround be calling a SetTimeout function checking the clientHeight and clientWidth?</li> <li>Any workarounds using jQuery?</li> </ol>
[ { "answer_id": 229028, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 6, "selected": true, "text": "$(window).resize(function() { });" }, { "answer_id": 229054, "author": "Svante Svenson", "author_id": 19707, ...
2008/10/23
[ "https://Stackoverflow.com/questions/229010", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17447/" ]
229,012
<p>How can I convert a relative path to an absolute path in C on Unix? Is there a convenient system function for this?</p> <p>On Windows there is a <code>GetFullPathName</code> function that does the job, but I didn't find something similar on Unix...</p>
[ { "answer_id": 229038, "author": "xsl", "author_id": 11387, "author_profile": "https://Stackoverflow.com/users/11387", "pm_score": 7, "selected": true, "text": "realpath()" }, { "answer_id": 41212150, "author": "PADYMKO", "author_id": 6003870, "author_profile": "https...
2008/10/23
[ "https://Stackoverflow.com/questions/229012", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9280/" ]
229,015
<p>Is there any free java library which I can use to convert string in one encoding to other encoding, something like <a href="https://en.wikipedia.org/wiki/Iconv" rel="nofollow noreferrer"><code>iconv</code></a>? I'm using Java version 1.3.</p>
[ { "answer_id": 229022, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 5, "selected": false, "text": "CharsetDecoder" }, { "answer_id": 229023, "author": "Jon Skeet", "author_id": 22656, "author_profile": "htt...
2008/10/23
[ "https://Stackoverflow.com/questions/229015", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15878/" ]
229,021
<p>We want to show a hint for a JList that the user can select multiple items with the platform dependent key for multiselect. </p> <p>However I have not found any way to show the OS X COMMAND symbol in a JLabel, which means the symbol that's printed on the apple keyboard on the command key, also called apple key.</p> <p>Here's a picture of the symbol I want to display on OS X. <a href="https://i.stack.imgur.com/VKGb4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VKGb4.png" alt="COMMAND SYMBOL"></a><br> <sub>(source: <a href="https://upload.wikimedia.org/wikipedia/commons/thumb/0/0c/Command_key.svg/120px-Command_key.svg.png" rel="nofollow noreferrer">wikimedia.org</a>)</sub> </p> <p>Also I do want to have it platform independent.</p> <p>I.e. something like </p> <pre><code>component.add( new JList() , BorderLayout.CENTER ); component.add( new JLabel( MessageFormat.format("With {0} you can " + "select multiple items", KeyStroke.getKeyStroke( ... , ... ) ) ) , BorderLayout.SOUTH ); </code></pre> <p>Where instead of the <em>{0}</em> there should appear above seen symbol...</p> <p>Does any one of you guys know how to do this? I know it must be possible somehow since in the JMenuItems there is the symbol...</p> <p>My own (non graphical solutions) looks like this:</p> <pre><code>add( new JLabel( MessageFormat.format( "With {0} you can select multiple items" , System.getProperty( "mrj.version" ) != null ? "COMMAND" : "CTRL" ) ) , BorderLayout.SOUTH ); </code></pre>
[ { "answer_id": 232786, "author": "Steve McLeod", "author_id": 2959, "author_profile": "https://Stackoverflow.com/users/2959", "pm_score": 0, "selected": false, "text": "add( new JLabel( MessageFormat.format(\n \"With {0} you can select multiple items\", \n getMetaKeyHint(),\n BorderLa...
2008/10/23
[ "https://Stackoverflow.com/questions/229021", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16193/" ]
229,031
<p>I need to test a web form that takes a file upload. The filesize in each upload will be about 10 MB. I want to test if the server can handle over 100 simultaneous uploads, and still remain responsive for the rest of the site.</p> <p>Repeated form submissions from our office will be limited by our local DSL line. The server is offsite with higher bandwidth.</p> <p>Answers based on experience would be great, but any suggestions are welcome.</p>
[ { "answer_id": 229051, "author": "Henrik Paul", "author_id": 2238, "author_profile": "https://Stackoverflow.com/users/2238", "pm_score": 0, "selected": false, "text": "/dev/urandom" }, { "answer_id": 323983, "author": "Liam", "author_id": 18333, "author_profile": "htt...
2008/10/23
[ "https://Stackoverflow.com/questions/229031", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18333/" ]
229,058
<p>When using something like <code>object.methods.sort.to_yaml</code> I'd like to have irb interpret the \n characters rather than print them. </p> <p>I currently get the following output:</p> <pre><code>--- \n- "&amp;"\n- "*"\n- +\n- "-"\n- "&lt;&lt;"\n- &lt;=&gt;\n ... </code></pre> <p>What I'd like is something similar to this:</p> <pre><code>--- - "&amp;" - "*" - + - "-" - "&lt;&lt;" - &lt;=&gt; </code></pre> <p>Is this possible? Is there another method I can be calling which will interpret the string perhaps?</p>
[ { "answer_id": 229064, "author": "Jonathan Lonowski", "author_id": 15031, "author_profile": "https://Stackoverflow.com/users/15031", "pm_score": 0, "selected": false, "text": "return" }, { "answer_id": 229065, "author": "Konrad Rudolph", "author_id": 1968, "author_pro...
2008/10/23
[ "https://Stackoverflow.com/questions/229058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17453/" ]
229,069
<p>How would you go about dead code detection in C/C++ code? I have a pretty large code base to work with and at least 10-15% is dead code. Is there any Unix based tool to identify this areas? Some pieces of code still use a lot of preprocessor, can automated process handle that?</p>
[ { "answer_id": 562957, "author": "Thomas L Holaday", "author_id": 29403, "author_profile": "https://Stackoverflow.com/users/29403", "pm_score": 2, "selected": false, "text": "int foo() { \n return 21; // point a\n}\n\nint bar() {\n int a = 7;\n return a;\n a += 9; // point b\n re...
2008/10/23
[ "https://Stackoverflow.com/questions/229069", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3579/" ]
229,071
<p>how to show all values of a particular field in a text box ??? ie. for eg. when u run the SP, u'll be getting 3 rows. and i want to show the (eg.empname) in a textbox each value separated by a comma. (ram, john, sita). </p>
[ { "answer_id": 229282, "author": "CaRDiaK", "author_id": 15628, "author_profile": "https://Stackoverflow.com/users/15628", "pm_score": 1, "selected": false, "text": "Structure; \nID TYPE TEXT\n1 1 Ram\n2 1 Jon\n3 2 Sita\n4 2 Joe\n\n\nExpecteed Output;\nID TYPE TEXT\n1 1 Ram, Jon\n2 2 Sit...
2008/10/23
[ "https://Stackoverflow.com/questions/229071", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29867/" ]
229,078
<p>The code below gives me this mysterious error, and i cannot fathom it. I am new to regular expressions and so am consequently stumped. The regular expression should be validating any international phone number.</p> <p>Any help would be much appreciated.</p> <pre><code>function validate_phone($phone) { $phoneregexp ="^(\+[1-9][0-9]*(\([0-9]*\)|-[0-9]*-))?[0]?[1-9][0-9\- ]*$"; $phonevalid = 0; if (ereg($phoneregexp, $phone)) { $phonevalid = 1; }else{ $phonevalid = 0; } } </code></pre>
[ { "answer_id": 229089, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 2, "selected": true, "text": "preg" }, { "answer_id": 229095, "author": "Zebra North", "author_id": 17440, "author_profile": "ht...
2008/10/23
[ "https://Stackoverflow.com/questions/229078", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
229,080
<p>Is there a best-practice or common way in JavaScript to have class members as event handlers?</p> <p>Consider the following simple example:</p> <pre><code>&lt;head&gt; &lt;script language="javascript" type="text/javascript"&gt; ClickCounter = function(buttonId) { this._clickCount = 0; document.getElementById(buttonId).onclick = this.buttonClicked; } ClickCounter.prototype = { buttonClicked: function() { this._clickCount++; alert('the button was clicked ' + this._clickCount + ' times'); } } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;input type="button" id="btn1" value="Click me" /&gt; &lt;script language="javascript" type="text/javascript"&gt; var btn1counter = new ClickCounter('btn1'); &lt;/script&gt; &lt;/body&gt; </code></pre> <p>The event handler buttonClicked gets called, but the _clickCount member is inaccessible, or <em>this</em> points to some other object.</p> <p>Any good tips/articles/resources about this kind of problems?</p>
[ { "answer_id": 229110, "author": "pawel", "author_id": 4879, "author_profile": "https://Stackoverflow.com/users/4879", "pm_score": 6, "selected": true, "text": "ClickCounter = function(buttonId) {\n this._clickCount = 0;\n var that = this;\n document.getElementById(buttonId).onc...
2008/10/23
[ "https://Stackoverflow.com/questions/229080", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30056/" ]
229,117
<p>I <em>sometimes</em> get the following exception for a custom control of mine:</p> <p><code>XamlParseException occurred</code> <code>Unknown attribute Points in element SectionClickableArea [Line: 10 Position 16]</code></p> <p>The stack trace:</p> <pre><code>{System.Windows.Markup.XamlParseException: Unknown attribute Points on element SectionClickableArea. [Line: 10 Position: 16] at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator) at SomeMainDialog.InitializeComponent() at SomeMainDialog..ctor()} </code></pre> <p>The element declaration where this happens looks like this (the <strong>event handler</strong> referenced here is defined, of course):</p> <pre><code>&lt;l:SectionClickableArea x:Name="SomeButton" Points="528,350, 508,265, 520,195, 515,190, 517,165, 530,120, 555,75, 570,61, 580,60, 600,66, 615,80, 617,335, 588,395, 550,385, 540,390, 525,393, 520,385" Click="SomeButton_Click"/&gt; </code></pre> <p>This is part of the code of <code>SectionClickableArea</code>:</p> <pre><code>public partial class SectionClickableArea : Button { public static readonly DependencyProperty PointsProperty = DependencyProperty.Register("Points", typeof(PointCollection), typeof(SectionClickableArea), new PropertyMetadata((s, e) =&gt; { SectionClickableArea area = (SectionClickableArea) s; area.areaInfo.Points = (PointCollection) e.NewValue; area.UpdateLabelPosition(); })); public PointCollection Points { get { return (PointCollection) GetValue(PointsProperty); } set { SetValue(PointsProperty, value); } } </code></pre> <p>I use this control for something like a polygon-shaped button. Therefore I'm inheriting from button. I've had similar problems (<code>E_AG_BAD_PROPERTY_VALUE</code> on another <code>DependencyProperty</code> of type string, according to the line and column given, etc) with this control for weeks, but I have absolutely no idea why.</p> <hr> <p>Another exception for the same control occurred this morning for another user (taken from a log and translated from German):</p> <pre><code>Type: System.InvalidCastException Message: The object of type System.Windows.Controls.ContentControl could not be converted to type [...]SectionClickableArea. at SomeOtherMainDialog.InitializeComponent() at SomeOtherMainDialog..ctor() </code></pre> <p>Inner exception:</p> <pre><code>Type: System.Exception Message: An HRESULT E_FAIL error was returned when calling COM component at MS.Internal.XcpImports.CheckHResult(UInt32 hr) at MS.Internal.XcpImports.SetValue(INativeCoreTypeWrapper obj, DependencyProperty property, DependencyObject doh) at MS.Internal.XcpImports.SetValue(INativeCoreTypeWrapper doh, DependencyProperty property, Object obj) at System.Windows.DependencyObject.SetObjectValueToCore(DependencyProperty dp, Object value) at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet, Boolean isSetByStyle, Boolean isSetByBuiltInStyle) at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value) at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value) at System.Windows.Controls.Control.set_DefaultStyleKey(Object value) at System.Windows.Controls.ContentControl..ctor() at System.Windows.CoreTypes.GetCoreWrapper(Int32 typeId) at MS.Internal.ManagedPeerTable.EnsureManagedPeer(IntPtr unmanagedPointer, Int32 typeIndex, Type type, Boolean preserveManagedObjectReference) at MS.Internal.ManagedPeerTable.EnsureManagedPeer(IntPtr unmanagedPointer, Int32 typeIndex, Type type) at MS.Internal.ManagedPeerTable.GetManagedPeer(IntPtr nativeObject) at MS.Internal.FrameworkCallbacks.SetPropertyAttribute(IntPtr nativeTarget, String attrName, String attrValue, String attachedDPOwnerNamespace, String attachedDPOwnerAssembly) </code></pre> <p>Any ideas what's wrong with the control, or what I can do to find the source of these exceptions? As I said, these problem occur only every few dozen times the control is instantiated.</p>
[ { "answer_id": 1063206, "author": "Nikolay R", "author_id": 18635, "author_profile": "https://Stackoverflow.com/users/18635", "pm_score": 1, "selected": false, "text": "<UserControl.Resources>\n <customNamespace:InheritedControl x:Name=\"dummyInstance\"/>\n</UserControl.Resources>\n" ...
2008/10/23
[ "https://Stackoverflow.com/questions/229117", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23222/" ]
229,137
<p>This question is related to another question which I asked yesterday! </p> <p><a href="https://stackoverflow.com/questions/220796/list-all-links-in-web-site">List all links in web site</a></p> <p>I think renaming all the .html files to .asp and changing the links is not good for SEP purposes. Some one told me that isapi plug-in can be used to redirect(301) all .html files to .asp files. </p> <p>Can any one explain this for me? Searching did not help me much.</p> <p>Thanks</p>
[ { "answer_id": 293110, "author": "TAG", "author_id": 36400, "author_profile": "https://Stackoverflow.com/users/36400", "pm_score": 1, "selected": false, "text": "<redirect url=\"^(.+)\\.html(.+)$\" to=\"$1.aspx$2\" permanent='true' />\n" } ]
2008/10/23
[ "https://Stackoverflow.com/questions/229137", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12178/" ]
229,153
<pre><code>&lt;div&gt; &lt;h1&gt;Title&lt;/h1&gt; &lt;table&gt; ... &lt;/table&gt; &lt;/div&gt; </code></pre> <p>Now, the</p> <pre><code>&lt;h1&gt; </code></pre> <p>has a margin: 0; so it is at the top of the div. The height of the div is 300px.</p> <p>However I'd like the table to be placed at the bottom of the div, eg. valign="bottom" but for the whole table.</p>
[ { "answer_id": 229184, "author": "Darryl Hein", "author_id": 5441, "author_profile": "https://Stackoverflow.com/users/5441", "pm_score": 0, "selected": false, "text": "<style type=\"text/css\">\n#container { \n position: absolute; \n margin: 0;\n height:300px;\n border:1px so...
2008/10/23
[ "https://Stackoverflow.com/questions/229153", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21559/" ]
229,168
<p>I find print_r in PHP extremely useful, but wonder if there is anything remotely equivalent in Perl?</p>
[ { "answer_id": 229175, "author": "Vinko Vrsalovic", "author_id": 5190, "author_profile": "https://Stackoverflow.com/users/5190", "pm_score": 6, "selected": true, "text": "use Data::Dumper;\n\npackage Foo;\nsub new {bless {'a' => 1, 'b' => sub { return \"foo\" }}, $_[0]};\n\npackage Fuz; ...
2008/10/23
[ "https://Stackoverflow.com/questions/229168", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1693/" ]
229,186
<p>How do I limit <code>os.walk</code> to only return files in the directory I provide it?</p> <pre><code>def _dir_list(self, dir_name, whitelist): outputList = [] for root, dirs, files in os.walk(dir_name): for f in files: if os.path.splitext(f)[1] in whitelist: outputList.append(os.path.join(root, f)) else: self._email_to_("ignore") return outputList </code></pre>
[ { "answer_id": 229192, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 4, "selected": false, "text": "os.listdir()" }, { "answer_id": 229219, "author": "Yuval Adam", "author_id": 24545, "author_profile":...
2008/10/23
[ "https://Stackoverflow.com/questions/229186", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21537/" ]
229,201
<p>I would like to do remote deployment from my build machine onto a server. The remoting can be done via ssh commands from a script, but I would rather use phing and a deploy.xml file that would do the automation.</p> <p>What alternatives do I have to do ssh (and also scp) tasks from within a phing build file?</p>
[ { "answer_id": 229372, "author": "user30684", "author_id": 30684, "author_profile": "https://Stackoverflow.com/users/30684", "pm_score": 3, "selected": false, "text": "<exec command=\"scp -i keys/id_rsa myfile user@$server:myfile\" dir=\".\" />\n" }, { "answer_id": 26971137, ...
2008/10/23
[ "https://Stackoverflow.com/questions/229201", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26639/" ]
229,206
<p>I have some code which needs to ensure some data is in a mysql enum prior to insertion in the database. The cleanest way I've found of doing this is the following code:</p> <pre><code>sub enum_values { my ( $self, $schema, $table, $column ) = @_; # don't eval to let the error bubble up my $columns = $schema-&gt;storage-&gt;dbh-&gt;selectrow_hashref( "SHOW COLUMNS FROM `$table` like ?", {}, $column ); unless ($columns) { X::Internal::Database::UnknownColumn-&gt;throw( column =&gt; $column, table =&gt; $table, ); } my $type = $columns-&gt;{Type} or X::Panic-&gt;throw( details =&gt; "Could not determine type for $table.$column", ); unless ( $type =~ /\Aenum\((.*)\)\z/ ) { X::Internal::Database::IncorrectTypeForColumn-&gt;throw( type_wanted =&gt; 'enum', type_found =&gt; $type, ); } $type = $1; require Text::CSV_XS; my $csv = Text::CSV_XS-&gt;new; $csv-&gt;parse($type) or X::Panic-&gt;throw( details =&gt; "Could not parse enum CSV data: ".$csv-&gt;error_input, ); return map { /\A'(.*)'\z/; $1 }$csv-&gt;fields; } </code></pre> <p>We're using <a href="http://search.cpan.org/dist/DBIx-Class/" rel="noreferrer">DBIx::Class</a>. Surely there is a better way of accomplishing this? (Note that the $table variable is coming from our code, <em>not</em> from any external source. Thus, no security issue).</p>
[ { "answer_id": 229278, "author": "Leon Timmermans", "author_id": 4727, "author_profile": "https://Stackoverflow.com/users/4727", "pm_score": 2, "selected": false, "text": "my @fields = $type =~ / ' ([^']+) ' (?:,|\\z) /msgx;\n" }, { "answer_id": 229561, "author": "John Siracu...
2008/10/23
[ "https://Stackoverflow.com/questions/229206", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8003/" ]
229,254
<p>I have a server application that receives information over a network and processes it. The server is multi-threaded and handles multiple sockets at time, and threads are created without my control through BeginInvoke and EndInvoke style methods, which are chained by corresponding callback functions.</p> <p>I'm trying to create a form, in addition to the main GUI, that displays a ListBox item populated by items describing the currently connected sockets. So, what I'm basically trying to do is add an item to the ListBox using its Add() function, from the thread the appropriate callback function is running on. I'm accessing my forms controls through the Controls property - I.E:</p> <pre><code>(ListBox)c.Controls["listBox1"].Items.Add(); </code></pre> <p>Naturally I don't just call the function, I've tried several ways I've found here and on the web to communicate between threads, including <code>MethodInvoker</code>, using a <code>delegate</code>, in combination with <code>Invoke()</code>, <code>BeginInvoke()</code> etc. Nothing seems to work, I always get the same exception telling me my control was accessed from a thread other than the one it was created on.</p> <p>Any thoughts?</p>
[ { "answer_id": 229292, "author": "Hath", "author_id": 5186, "author_profile": "https://Stackoverflow.com/users/5186", "pm_score": 3, "selected": false, "text": " c = <your control>\n if (c.InvokeRequired)\n {\n c.BeginInvoke((MethodInvoker)delegate\n ...
2008/10/23
[ "https://Stackoverflow.com/questions/229254", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
229,269
<p>PHP 4.4 and PHP 5.2.3 under Apache 2.2.4 on ubuntu.</p> <p>I am running Moodle 1.5.3 and have recently had a problem when updating a course. The $_POST variable is empty but only if a lot of text was entered into the textarea on the form. If only a short text is entered it works fine.</p> <p>I have increased the post_max_size from 8M to 200M and increased the memory_limit to 256M but this has not helped. I have doubled the LimitRequestFieldSize and LimitRequestLine to 16380 and set LimitRequestBody to 0 with no improvement.</p> <p>I have googled for an answer but have been unable to find one.</p> <p>HTTP Headers on firefox shows the content size of 3816 with the correct data, so its just not getting to $_POST.</p> <p>The system was running fine until a few weeks ago. The only change was to /etc/hosts to correct a HELO issue with the exim4 email server.</p> <p>I can replicate the issue on a development machine that has exim4 not running so I think it is just coincidence.</p> <p>Thanks for your assistance.</p>
[ { "answer_id": 229431, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "file_get_contents('php://input');\n" }, { "answer_id": 229618, "author": "Till", "author_id": 2859, "autho...
2008/10/23
[ "https://Stackoverflow.com/questions/229269", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30738/" ]
229,272
<pre><code>&lt;div style="width: 300px"&gt; &lt;div id="one" style="float: left"&gt;saved&lt;/div&gt;&lt;input type="submit" id="two" style="float: right" value="Submit" /&gt; &lt;/div&gt; </code></pre> <p>I would like div#one to be centred in the space between the left edge of the parent div and the left edge of the submit button.</p>
[ { "answer_id": 229277, "author": "Paul Dixon", "author_id": 6521, "author_profile": "https://Stackoverflow.com/users/6521", "pm_score": 1, "selected": false, "text": "<div style=\"width: 300px\">\n<div id=\"one\" style=\"float: left;text-align:center;width:80%\">saved</div>\n<input type=...
2008/10/23
[ "https://Stackoverflow.com/questions/229272", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21559/" ]
229,310
<p>I'm trying to read a file to produce a DOM Document, but the file has whitespace and newlines and I'm trying to ignore them, but I couldn't:</p> <pre><code>DocumentBuilderFactory docfactory=DocumentBuilderFactory.newInstance(); docfactory.setIgnoringElementContentWhitespace(true); </code></pre> <p>I see in Javadoc that setIgnoringElementContentWhitespace method operates only when the validating flag is enabled, but I haven't the DTD or XML Schema for the document.</p> <p>What can I do?</p> <p>Update</p> <p>I don't like the idea of introduce mySelf &lt; !ELEMENT... declarations and i have tried the solution proposed in the <a href="http://forums.sun.com/thread.jspa?messageID=2054303#2699961" rel="noreferrer">forum</a> pointed by Tomalak, but it doesn't work, i have used java 1.6 in an linux environment. I think if no more is proposed i will make a few methods to ignore whitespace text nodes</p>
[ { "answer_id": 5851888, "author": "jjnguy", "author_id": 2598, "author_profile": "https://Stackoverflow.com/users/2598", "pm_score": 3, "selected": false, "text": "NodeList" }, { "answer_id": 19602644, "author": "huppyuy", "author_id": 528900, "author_profile": "https...
2008/10/23
[ "https://Stackoverflow.com/questions/229310", "https://Stackoverflow.com", "https://Stackoverflow.com/users/518/" ]
229,346
<p>I have a String which I would like to modify in some way. For example: reverse it or upcase it. </p> <p>I have discovered that the fastest way to do this is by using a unsafe block and pointers. </p> <p>For example: </p> <pre><code> unsafe { fixed (char* str = text) { *str = 'X'; } } </code></pre> <p>Are there any reasons why I should never ever do this? </p>
[ { "answer_id": 229351, "author": "Sam Saffron", "author_id": 17174, "author_profile": "https://Stackoverflow.com/users/17174", "pm_score": 5, "selected": true, "text": "String.intern" }, { "answer_id": 229354, "author": "Konrad Rudolph", "author_id": 1968, "author_pro...
2008/10/23
[ "https://Stackoverflow.com/questions/229346", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17174/" ]
229,352
<p>I am using Python to extract the filename from a link using rfind like below:</p> <pre><code>url = "http://www.google.com/test.php" print url[url.rfind("/") +1 : ] </code></pre> <p>This works ok with links without a / at the end of them and returns "test.php". I have encountered links with / at the end like so "<a href="http://www.google.com/test.php/" rel="nofollow noreferrer">http://www.google.com/test.php/</a>". I am have trouble getting the page name when there is a "/" at the end, can anyone help?</p> <p>Cheers</p>
[ { "answer_id": 229386, "author": "Tim Pietzcker", "author_id": 20670, "author_profile": "https://Stackoverflow.com/users/20670", "pm_score": -1, "selected": false, "text": "print url[url.rstrip(\"/\").rfind(\"/\") +1 : ]\n" }, { "answer_id": 229394, "author": "Steve Moyer", ...
2008/10/23
[ "https://Stackoverflow.com/questions/229352", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
229,353
<p>In my main page (call it <code>index.aspx</code>) I call </p> <pre><code>&lt;%Html.RenderPartial("_PowerSearch", ViewData.Model);%&gt; </code></pre> <p>Here the <code>viewdata.model != null</code> When I arrive at my partial:</p> <pre><code>&lt;%=ViewData.Model%&gt; </code></pre> <p>Says <code>viewdata.model == null</code></p> <p>What gives?!</p>
[ { "answer_id": 229367, "author": "Simon Steele", "author_id": 4591, "author_profile": "https://Stackoverflow.com/users/4591", "pm_score": 2, "selected": true, "text": " /// <summary>\n /// Renders a LoggingWeb user control.\n /// </summary>\n /// <param name=\"helper\">Helper...
2008/10/23
[ "https://Stackoverflow.com/questions/229353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11333/" ]
229,357
<p>What is the best way in <strong>Perl</strong> to copy files to a yet-to-be-created destination directory tree?</p> <p>Something like</p> <pre><code>copy("test.txt","tardir/dest1/dest2/text.txt"); </code></pre> <p>won't work since the directory <em>tardir/dest1/dest2</em> does not yet exist. What is the best way to copy with directory creation in Perl?</p>
[ { "answer_id": 229382, "author": "Leon Timmermans", "author_id": 4727, "author_profile": "https://Stackoverflow.com/users/4727", "pm_score": 3, "selected": false, "text": "use File::Basename qw/dirname/;\nuse File::Copy;\n\nsub mkdir_recursive {\n my $path = shift;\n mkdir_recursiv...
2008/10/23
[ "https://Stackoverflow.com/questions/229357", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6511/" ]
229,362
<p>I am trying to call out to a legacy dll compiled from FORTRAN code. I am new to Interop, but I've read some articles on it and it seems like my case should be fairly straightforward. </p> <p>The method I really want to call has a complex method signature, but I can't even call this simple GetVersion method without getting a protected memory violation.</p> <p>Here's my DllImport code:</p> <pre><code>[DllImport("GeoConvert.dll", EntryPoint="_get_version@4", CallingConvention=CallingConvention.StdCall)] public static extern void GetGeoConvertVersion([MarshalAs(UnmanagedType.LPStr, SizeConst=8)] ref string version); </code></pre> <p>Here's the FORTRAN code:</p> <pre><code>SUBROUTINE GetVer( VRSION ) C !MS$DEFINE MSDLL !MS$IF DEFINED (MSDLL) ENTRY Get_Version (VRSION) !MS$ATTRIBUTES DLLEXPORT,STDCALL :: Get_Version !MS$ATTRIBUTES REFERENCE :: VRSION !MS$ENDIF !MS$UNDEFINE MSDLL C CHARACTER*8 VRSION C VRSION = '1.0a_FhC' C RETURN END </code></pre> <p>Here's my unit test that fails:</p> <pre><code>[Test] public void TestGetVersion() { string version = ""; LatLonUtils.GetGeoConvertVersion(ref version); StringAssert.IsNonEmpty(version); } </code></pre> <p>Here's the error message I get:</p> <pre><code>System.AccessViolationException Message: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. </code></pre> <p>Other things I've tried:</p> <ul> <li>Using the default marshalling</li> <li>Passing a char[] instead of a string (get method signature errors instead)</li> </ul>
[ { "answer_id": 229525, "author": "brien", "author_id": 4219, "author_profile": "https://Stackoverflow.com/users/4219", "pm_score": 2, "selected": true, "text": "[DllImport(\"GeoConvert.dll\", \n EntryPoint=\"_get_version@4\", \n CallingConvention=CallingConv...
2008/10/23
[ "https://Stackoverflow.com/questions/229362", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4219/" ]
229,385
<p>Visual Studio gives many navigation hotkeys: <kbd>F8</kbd> for next item in current panel (search results, errors ...), <kbd>Control</kbd>+<kbd>K</kbd>, <kbd>N</kbd> for bookmarks, <kbd>Alt</kbd>+<kbd>-</kbd> for going back and more.</p> <p>There is one hotkey that I can't find, and I can't even find the menu-command for it, so I can't create the hotkey myself.</p> <p>I don't know if such exist: Previous and Next call-stack frame.</p> <p>I try not using the mouse when programming, but when I need to go back the stack, I must use it to double click the previous frame.</p> <p>Anyone? How about a macro that does it?</p>
[ { "answer_id": 1211782, "author": "Oleg Svechkarenko", "author_id": 148405, "author_profile": "https://Stackoverflow.com/users/148405", "pm_score": 4, "selected": false, "text": "PreviousStackFrame" }, { "answer_id": 26718512, "author": "Programmer Paul", "author_id": 248...
2008/10/23
[ "https://Stackoverflow.com/questions/229385", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
229,395
<p>I have an array of 1000 strings to load into a combo box. What is the fastest way to load the array of strings into the combo box?</p> <p>Is there some way other than iterating over the list of strings, putting each string into the combo box one at a time?</p> <p>And how to copy the combo box data once loaded to some 10 other combo boxes?</p>
[ { "answer_id": 229490, "author": "Hapkido", "author_id": 27646, "author_profile": "https://Stackoverflow.com/users/27646", "pm_score": 0, "selected": false, "text": "#define NB_ITEM 1000\n#define ITEM_LENGTH 10\n\nvoid CMFCComboDlg::InitMyCombo()\n{\n CString _strData;\n m_cbMyComb...
2008/10/23
[ "https://Stackoverflow.com/questions/229395", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22076/" ]
229,404
<p>I am trying to extract a table of values from an excel (2003) spreadsheet using vb6, the result of which needs to be stored in a (adodb) recordset. The table looks like this:</p> <pre> Name Option.1 Option.2 Option.3 Option.4 Option.5 Option.6 ----------------------------------------------------------------- Name1 2 3 4 Name2 2 3 4 Name3 2 3 4 Name4 2 3 4 Name5 2 3 4 Name6 2 3 4 Name7 2 3 4 Name8 2 3 4 Name9 2 3 4 5 6 7 </pre> <p>Upon connecting and executing the query "<code>SELECT * FROM [Sheet1$]</code>" or even a column-specific, "<code>SELECT [Option#6] FROM [Sheet1$]</code>" (see footnote 1) and looping through the results, I am given <code>Null</code> values for the row <code>Name9</code>, <code>Option.4</code> --&gt; <code>Option.6</code> rather than the correct values 5, 6, and 7. It seems the connection to the spreadsheet is using a "best guess" of deciding what the valid table limits are, and only takes a set number of rows into account. </p> <p>To connect to the spreadsheet, I have tried both connection providers <code>Microsoft.Jet.OLEDB.4.0</code> and <code>MSDASQL</code> and get the same problem.</p> <p>Here are the connection settings I use:</p> <pre><code>Set cn = New ADODB.Connection With cn .Provider = "Microsoft.Jet.OLEDB.4.0" .ConnectionString = "Data Source=" &amp; filePath &amp; ";Extended Properties=Excel 8.0;" - - - - OR - - - - .Provider = "MSDASQL" .ConnectionString = "Driver={Microsoft Excel Driver (*.xls)};" &amp; _ "DBQ=" &amp; filePath &amp; ";MaxScanRows=0;" .CursorLocation = adUseClient .Open End With Set rsSelects = New ADODB.Recordset Set rsSelects = cn.Execute("SELECT [Option#5] FROM " &amp; "[" &amp; strTbl &amp; "]") </code></pre> <p>This problem only occurs when there are more than 8 rows (excluding the column names), and I have set <code>MaxScanRow=0</code> for the <code>MSDASQL</code> connection, but this has produced the same results.</p> <p>Notable project references I have included are: </p> <ul> <li>MS ActiveX Data Objects 2.8 Library</li> <li>MS ActiveX Data Objects Recordset 2.8 Library</li> <li>MS Excel 11.0 Object Library</li> <li>MS Data Binding Collection VB 6.0 (SP4)</li> </ul> <p>Any help in this matter would be very appreciated!</p> <p>(1) For some reason, when including a decimal point in the column name, it is interpreted as a #.</p> <hr> <p>Thanks everyone! Halfway through trying to set up a <code>Schema.ini</code> "programmatically" from <a href="http://support.microsoft.com/kb/155512" rel="nofollow noreferrer">KB155512</a> <a href="https://stackoverflow.com/questions/229404/ignored-columns-using-vb6-to-extract-from-excel#229721">onedaywhen</a>'s excellent <a href="http://www.dailydoseofexcel.com/archives/2004/06/03/external-data-mixed-data-types/" rel="nofollow noreferrer">post</a> pointed me towards the solution:</p> <pre><code>.Provider = "Microsoft.Jet.OLEDB.4.0" .ConnectionString = "Data Source=" &amp; filePath &amp; ";Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1"";" </code></pre> <p>I would encourage anyone with similar problems to read the post and comments, since there are slight variations to a solution from one person to another.</p>
[ { "answer_id": 229477, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 2, "selected": false, "text": "MaxScanRows=0" } ]
2008/10/23
[ "https://Stackoverflow.com/questions/229404", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30757/" ]
229,423
<p>We have a need to take dozens of different protocols from systems such as security systems, fire alarms, camera systems etc.. and integrate them into a single common protocol.</p> <p>I would like this to be a messaging server that many systems could subscribe to and or communicate through.</p> <ul> <li>polling and non-polling "drivers" (protocol converters)</li> <li>handle RS232 / RS485 / tcp</li> <li>programmable "drivers" in a managed language like Java or C#</li> <li>rules engine capability</li> </ul> <p>Does biztalk fit this? </p> <p>Are there open source alternatives?</p> <p>Is there a Java / Java EE way to do this?</p> <p>At one end the system would be a SCADA system at the other is is kind of a middleware / messaging server.</p> <p>Any thoughts on the best way to proceed would be appreciated. I know that there will be a considerable amount of programming involved on the driver side, however as tempted as I am, building the whole system from scratch would not be appropriate.</p>
[ { "answer_id": 229793, "author": "James Strachan", "author_id": 2068211, "author_profile": "https://Stackoverflow.com/users/2068211", "pm_score": 3, "selected": true, "text": "// route all messages from foo\n// to a single queue on JMS\nfrom(\"foo://somehost:1234\").\n to(\"jms:MyQueue\...
2008/10/23
[ "https://Stackoverflow.com/questions/229423", "https://Stackoverflow.com", "https://Stackoverflow.com/users/445087/" ]
229,425
<p>I'm trying to populate a DataTable, to build a LocalReport, using the following:<br></p> <pre><code>MySqlCommand cmd = new MySqlCommand(); cmd.Connection = new MySqlConnection(Properties.Settings.Default.dbConnectionString); cmd.CommandType = CommandType.Text; cmd.CommandText = "SELECT ... LEFT JOIN ... WHERE ..."; /* query snipped */ // prepare data dataTable.Clear(); cn.Open(); // fill datatable dt.Load(cmd.ExecuteReader()); // fill report rds = new ReportDataSource("InvoicesDataSet_InvoiceTable",dt); reportViewerLocal.LocalReport.DataSources.Clear(); reportViewerLocal.LocalReport.DataSources.Add(rds); </code></pre> <p>At one point I noticed that the report was incomplete and it was missing one record. I've changed a few conditions so that the query would return exactly two rows and... <b>surprise</b>: The report shows only one row instead of two. I've tried to debug it to find where the problem is and I got stuck at</p> <pre><code> dt.Load(cmd.ExecuteReader()); </code></pre> <p>When I've noticed that the <code>DataReader</code> contains two records but the <code>DataTable</code> contains only one. By accident, I've added an <code>ORDER BY</code> clause to the query and noticed that this time the report showed correctly.<br><br> Apparently, the DataReader contains two rows but the DataTable only reads both of them if the SQL query string contains an <code>ORDER BY</code> (otherwise it only reads the last one). Can anyone explain why this is happening and how it can be fixed?</p> <p><b>Edit:</b> When I first posted the question, I said it was skipping the first row; later I realized that it actually only read the last row and I've edited the text accordingly (at that time all the records were grouped in two rows and it appeared to skip the first when it actually only showed the last). This may be caused by the fact that it didn't have a unique identifier by which to distinguish between the rows returned by MySQL so adding the <code>ORDER BY</code> statement caused it to create a unique identifier for each row.<br /> This is just a theory and I have nothing to support it, but all my tests seem to lead to the same result.</p>
[ { "answer_id": 241423, "author": "thismat", "author_id": 14045, "author_profile": "https://Stackoverflow.com/users/14045", "pm_score": 0, "selected": false, "text": " Dim deals As New DealsProvider()\n Dim adapter As New ReportingDataTableAdapters.ReportDealsAdapter\n ...
2008/10/23
[ "https://Stackoverflow.com/questions/229425", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26155/" ]
229,432
<p>Is there a way of programmatically determining a rough geographical position of a mobile phone using J2ME application, for example determining the current cell? This question especially applies to non-GPS enabled devices. </p> <p>I am not looking for a set of geographical coordinates, but an ability for a user to define location specific software behaviours.</p> <p>Solution for any hardware will be highly appreciated; however the more generic a solution is — the better. Many thanks!</p>
[ { "answer_id": 250008, "author": "user32691", "author_id": 32691, "author_profile": "https://Stackoverflow.com/users/32691", "pm_score": 3, "selected": false, "text": "System.getProperty(String arg)" } ]
2008/10/23
[ "https://Stackoverflow.com/questions/229432", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22088/" ]
229,438
<p>I am just embarking on my first large-scale refactor, and need to split an (unfortunately large) class into two, which then communicate only via an interface. (My Presenter has turned out to be a Controller, and needs to split GUI logic from App logic). Using C# in VisualStudio 2008 and Resharper, what is the easiest way to achieve this? </p> <p>What I am going to try is a) Collect the members for the new class and "extract new class" b) clean up the resulting mess c) "Extract Interface" d) chase down any references to the class and convert them to interface references</p> <p>but I have never done this before, and wonder whether anyone knows any good tips or gotchas before I start ripping everything apart... Thanks!</p>
[ { "answer_id": 229634, "author": "Ilya Ryzhenkov", "author_id": 18575, "author_profile": "https://Stackoverflow.com/users/18575", "pm_score": 0, "selected": false, "text": "class PresenterAndController\n {\n public void Control()\n {\n Present();\n }\n\n public void Pre...
2008/10/23
[ "https://Stackoverflow.com/questions/229438", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6091/" ]
229,441
<p>in my application (c# 3.5) there are various processes accessing a single xml file (read and write) very frequently. the code accessing the file is placed in an assembly referenced by quite a couple of other applications. for example a windows service might instanciate the MyFileReaderWriter class (locatied in the previously mentioned assembly) and use the read/write methods of this class. </p> <p>i'm looking for the best/fastest way to read and create/append the file with the least amount of locking. caching the files data and flushing new content periodically is not an option, since the data is critical.</p> <p>I forgot to mention that I currently use the XDocument (LInq2Xml infrastructure) for reading/writing the content to the file.</p>
[ { "answer_id": 229476, "author": "biozinc", "author_id": 30698, "author_profile": "https://Stackoverflow.com/users/30698", "pm_score": 1, "selected": false, "text": "public static object GetReadWriteToken(String fileName)\n{\n //use a hashtable to retreive an object, with filename as ...
2008/10/23
[ "https://Stackoverflow.com/questions/229441", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16440/" ]
229,443
<p>I've made a custom DataGridViewCell that displays a custom control instead of the cell; but if the DataGridView uses shared rows, then the custom control instance is also shared, so you get strange behaviour (for example, hovering over buttons highlights all the buttons). Also, I can't access the DataGridViewCell.Selected property, so I don't know what colour to paint the row.</p> <p>How do I prevent a DataGridView from sharing rows? I know I can add the rows using the Rows.Add(object[]) override, but then the first row is still shared (i.e. has index -1) so the problem with colours still applies.</p> <p>I need to be able to tell the DataGridView not to share a row containing a custom cell. Can that be done with attributes? Can it be done at all?</p>
[ { "answer_id": 1820040, "author": "Ptr", "author_id": 221369, "author_profile": "https://Stackoverflow.com/users/221369", "pm_score": 1, "selected": false, "text": "DataGridViewRowCollection.AddRange(params DataGridViewRow[] dataGridViewRows)\n" } ]
2008/10/23
[ "https://Stackoverflow.com/questions/229443", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15371/" ]
229,446
<p>On our site, we get a large amount of photos uploaded from various sources. </p> <p>In order to keep the file sizes down, we strip all <a href="http://en.wikipedia.org/wiki/Exif" rel="noreferrer">exif data</a> from the source using <a href="http://www.imagemagick.org/www/mogrify.html" rel="noreferrer">mogrify</a>:</p> <pre><code>mogrify -strip image.jpg </code></pre> <p>What we'd like to be able to do is to insert some basic exif data (Copyright Initrode, etc) back onto this new "clean" image, but I can't seem to find anything in the docs that would achieve this.</p> <p>Has anybody any experience of doing this? </p> <p>If it can't be done through imagemagick, a PHP-based solution would be the next best thing!</p> <p>Thanks.</p>
[ { "answer_id": 230480, "author": "Ciaran", "author_id": 5048, "author_profile": "https://Stackoverflow.com/users/5048", "pm_score": 5, "selected": true, "text": "2#110#Credit=\"My Company\"\n2#05#Object Name=\"THE_OBJECT_NAME\"\n2#55#Date Created=\"2011-02-03 12:45\"\n2#80#By-line=\"BY-L...
2008/10/23
[ "https://Stackoverflow.com/questions/229446", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2287/" ]
229,447
<p>How can I efficiently create a unique index on two fields in a table like this: create table t (a integer, b integer);</p> <p>where any unique combination of two different numbers cannot appear more than once on the same row in the table.</p> <p>In order words if a row exists such that a=1 and b=2, another row cannot exist where a=2 and b=1 or a=1 and b=2. In other words two numbers cannot appear together more than once in any order.</p> <p>I have no idea what such a constraint is called, hence the 'two-sided unique index' name in the title.</p> <p><strong>Update</strong>: If I have a composite key on columns (a,b), and a row (1,2) exists in the database, it is possible to insert another row (2,1) without an error. What I'm looking for is a way to prevent the same pair of numbers from being used more than once <strong><em>in any order</em></strong>...</p>
[ { "answer_id": 229521, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "BEFORE UPDATE" }, { "answer_id": 229527, "author": "Tony Andrews", "author_id": 18747, "author_profile": "...
2008/10/23
[ "https://Stackoverflow.com/questions/229447", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6475/" ]
229,468
<p>I am new to programming, and am wondering if there is a correct way to order your control structure logic.</p> <p>It seems more natural to check for the most likely case first, but I have the feeling that some control structures won't work unless they check everything that's false to arrive at something that's true (logical deduction?)</p> <p>It would be hard to adapt to this 'negative' view, I prefer a more positive outlook, presuming everything is true :)</p>
[ { "answer_id": 229493, "author": "Dave DuPlantis", "author_id": 8174, "author_profile": "https://Stackoverflow.com/users/8174", "pm_score": 3, "selected": false, "text": "if( condition is true ) {\n do something small;\n} else { \n do something;\n and something else; \n . . ....
2008/10/23
[ "https://Stackoverflow.com/questions/229468", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4196/" ]
229,491
<pre><code>foreach($arrayOne as $value){ do function } </code></pre> <p>In the above example, I'd like to pass $arrayOne into a loop, have a function operate that removes some elements of $arrayOne and then have the loop pass over the reduced $arrayOne on the elements that are left until the loop returns false.</p> <p>Recommendations?</p>
[ { "answer_id": 229799, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": true, "text": "$arrayOne = array('example', 'listing of', 'stuff');\n\nforeach ($arrayOne as $key => &$value) {\n $value .= ' alteration';\...
2008/10/23
[ "https://Stackoverflow.com/questions/229491", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1149/" ]
229,508
<p>Can anyone tell me why this code behaves the way it does? See comments embedded in the code...</p> <p>Am I missing something really obvious here?</p> <pre><code>using System; namespace ConsoleApplication3 { public class Program { static void Main(string[] args) { var c = new MyChild(); c.X(); Console.ReadLine(); } } public class MyParent { public virtual void X() { Console.WriteLine("Executing MyParent"); } } delegate void MyDelegate(); public class MyChild : MyParent { public override void X() { Console.WriteLine("Executing MyChild"); MyDelegate md = base.X; // The following two calls look like they should behave the same, // but they behave differently! // Why does Invoke() call the base class as expected here... md.Invoke(); // ... and yet BeginInvoke() performs a recursive call within // this child class and not call the base class? md.BeginInvoke(CallBack, null); } public void CallBack(IAsyncResult iAsyncResult) { return; } } } </code></pre>
[ { "answer_id": 229537, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 3, "selected": false, "text": "using System;\n\ndelegate void MyDelegate();\n\npublic class Program\n{\n static void Main(string[] args)\n {\n ...
2008/10/23
[ "https://Stackoverflow.com/questions/229508", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24207/" ]
229,534
<p>I have to migrate a table from MSSQL Server to MySql. The problem is that the table is quite big (65 millions records) and the whole process takes too much time. Does anyone have any idea how to speed things up ? Any useful tools that could improve this?</p>
[ { "answer_id": 229570, "author": "SWD", "author_id": 3034, "author_profile": "https://Stackoverflow.com/users/3034", "pm_score": 1, "selected": true, "text": "'/somefolder/text_file_with_data.txt'" }, { "answer_id": 230760, "author": "Serge Wautier", "author_id": 12379, ...
2008/10/23
[ "https://Stackoverflow.com/questions/229534", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29891/" ]
229,551
<p>I have a string in Bash:</p> <pre class="lang-sh prettyprint-override"><code>string=&quot;My string&quot; </code></pre> <p>How can I test if it contains another string?</p> <pre class="lang-sh prettyprint-override"><code>if [ $string ?? 'foo' ]; then echo &quot;It's there!&quot; fi </code></pre> <p>Where <code>??</code> is my unknown operator. Do I use <code>echo</code> and <code>grep</code>?</p> <pre class="lang-sh prettyprint-override"><code>if echo &quot;$string&quot; | grep 'foo'; then echo &quot;It's there!&quot; fi </code></pre> <p>That looks a bit clumsy.</p>
[ { "answer_id": 229585, "author": "Marcus Griep", "author_id": 28645, "author_profile": "https://Stackoverflow.com/users/28645", "pm_score": 9, "selected": false, "text": "case \"$string\" in \n *foo*)\n # Do stuff\n ;;\nesac\n" }, { "answer_id": 229606, "author": "Adam...
2008/10/23
[ "https://Stackoverflow.com/questions/229551", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30773/" ]
229,554
<p>Just wondering what the difference between <code>BeginInvoke()</code> and <code>Invoke()</code> are? </p> <p>Mainly what each one would be used for.</p> <p>EDIT: What is the difference between creating a threading object and calling invoke on that and just calling <code>BeginInvoke()</code> on a delegate? or are they the same thing?</p>
[ { "answer_id": 229558, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 10, "selected": true, "text": "Delegate.Invoke" }, { "answer_id": 12364477, "author": "Sujit", "author_id": 792713, "author_profile...
2008/10/23
[ "https://Stackoverflow.com/questions/229554", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6335/" ]
229,565
<p>The Mutex class is very misunderstood, and Global mutexes even more so.</p> <p>What is good, safe pattern to use when creating Global mutexes?</p> <p>One that will work</p> <ul> <li>Regardless of the locale my machine is in</li> <li>Is guaranteed to release the mutex properly</li> <li>Optionally does not hang forever if the mutex is not acquired</li> <li>Deals with cases where other processes abandon the mutex </li> </ul>
[ { "answer_id": 229567, "author": "Sam Saffron", "author_id": 17174, "author_profile": "https://Stackoverflow.com/users/17174", "pm_score": 10, "selected": true, "text": "using System.Runtime.InteropServices; //GuidAttribute\nusing System.Reflection; //Assembly\nusing Sys...
2008/10/23
[ "https://Stackoverflow.com/questions/229565", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17174/" ]
229,571
<p>I'm involved in creating a web based business solution. The idea is that the customers will use it, get their business processes and information into one place and also receive added business value by inter-system communication. In short they will use it as a core tool in their daily work and will depend highly upon it.</p> <p>One problem in need of a solution is how to get this web system secure enough to be an alternative which both we and the customers will find satisfactory. I am looking for good advice from others who have been or are in the same situation.</p> <p>In our specific scenario we're currently looking at using Java SE 6, Tomcat (as a Servlet container, needed as we will use Wicket), Hibernate (to interact with our database) and MySQL (as DBMS).</p> <p>I think the problem and advice will be of interest for other technology users as well. As many of the issues are general ones regarding HDD failure, network accessibility and other things.</p> <p>Feel free to give any advice you have! I still provide some questions and thoughts to get us going:</p> <ul> <li>The system needs to be reachable through the Internet. What should we think about when deciding on how to host it? (i.e. do we need our web host to have multiple physical paths connecting them to the Internet and similar questions.)</li> <li>Are there check lists for these kinds of things? Maybe ISO standards or some other way of seeing that we are on the right track by looking through an article/check list/academic paper/book?</li> <li>Later in the project we think it would be a good idea to get someone involved who has extensive experience in the field. In that case we're not looking for a normal web developer. It is likely that more consulting firms will tell us they are capable of providing this expertise then there actually are. Any tips on how we will get in contact with the right people? (We're based in Scandinavia, so it would be preferable to find someone there.)</li> <li>How high up time is good enough? 99.99% seems like a reasonable goal. But any downtime might result in loss of business for our customers.</li> <li>How do we guarantee that each customer only will be able to access its own data? As the system will be able to access it's own database, it seems hard. A proper development process, involving lots of testing, is really all we have regarding user privileges.</li> <li>How do we deal with HDD failures? Is RAID 5 in combination with a daily incremental backup and a weekly full backup enough? Or would you go for RAID 6?</li> <li>If one server is enough to serve the clients. Would you still use a cluster? (I would think so.) And in that case, how many nodes would you have in the cluster?</li> <li>Which backup strategy would you use?</li> <li>Do you think hosting the system in a computer cloud is a good alternative? (i.e. as provided by Amazon, Google or others.)</li> <li>Would you use hard disk encryption? And if so, which kind? (One clarification: Yes it's only good if someone steals the hard disk, but that's still added security and may prevent (physical) intruders access to vital client business data.)</li> <li>Is providing the customer with a way to do their own backups as well a good alternative? These customers won't be technically oriented. So in that case downloading the information in a ZIP archive containing Microsoft Office files might be a good way?</li> <li>How would you monitor the solution?</li> <li>Which of these things do you think we should do in house and which should be out sourced? We will develop the core system our self's, of course.</li> <li>If you feel that the system is secure, as a technical person. How do you convince a non technical person that it's safe and secure?</li> </ul> <p>Thank you for your time! I hope you have some input to share. More questions might be added later.</p>
[ { "answer_id": 229737, "author": "Blade", "author_id": 30004, "author_profile": "https://Stackoverflow.com/users/30004", "pm_score": 3, "selected": true, "text": "Which of these things do you think we should do in house and which should be out sourced? We will develop the core system our...
2008/10/23
[ "https://Stackoverflow.com/questions/229571", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
229,622
<p>I am working on a stored procedure with several optional parameters. Some of these parameters are single values and it's easy enough to use a WHERE clause like:</p> <pre><code>WHERE (@parameter IS NULL OR column = @parameter) </code></pre> <p>However, in some instances, the WHERE condition is more complicated:</p> <pre><code>WHERE (@NewGroupId IS NULL OR si.SiteId IN (SELECT gs.SiteId FROM [UtilityWeb].[dbo].[GroupSites] AS gs WHERE gs.GroupId = @NewGroupId)) </code></pre> <p>When I uncomment these complicated WHERE clauses, the query execution time doubles and the execution plan becomes remarkably more complicated. While the execution plan doesn't bother me, doubling the execution time of a query is a definite problem.</p> <p>Is there a best practice or pattern that others have found for working with optional parameters in their stored procedures?</p> <p>Is this one of those instances where dynamic SQL would be a better solution?</p>
[ { "answer_id": 229641, "author": "GvS", "author_id": 11492, "author_profile": "https://Stackoverflow.com/users/11492", "pm_score": 3, "selected": false, "text": "if (@parameter IS NULL) then begin\n select * from foo\nend\nelse begin\n select * from foo where value = @parameter\nend\...
2008/10/23
[ "https://Stackoverflow.com/questions/229622", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11780/" ]
229,623
<pre><code>&lt;input type="submit"/&gt; &lt;style&gt; input { background: url(tick.png) bottom left no-repeat; padding-left: 18px; } &lt;/style&gt; </code></pre> <p>But the bevel goes away, how can I add an icon to submit button and keep the bevel?<br> Edit: I want it to look like the browser default.</p>
[ { "answer_id": 229640, "author": "NotMe", "author_id": 2424, "author_profile": "https://Stackoverflow.com/users/2424", "pm_score": 0, "selected": false, "text": "INPUT.button {\n BORDER-RIGHT: #999999 1px solid;\n BORDER-TOP: #999999 1px solid;\n FONT-SIZE: 11px;\n BACKGROUND...
2008/10/23
[ "https://Stackoverflow.com/questions/229623", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21559/" ]
229,627
<p>I have looked over the Repository pattern and I recognized some ideas that I was using in the past which made me feel well.</p> <p>However now I would like to write an application that would use this pattern <strong>BUT I WOULD LIKE TO HAVE THE ENTITY CLASSES DECOUPLED</strong> from the repository provider.</p> <p>I would create several assemblies :</p> <ol> <li>an "Interfaces" assembly which would host common interfaces including the IRepository interface</li> <li>an "Entities" assembly which would host the entity classes such as Product, User, Order and so on. This assembly would be referenced by the "Interfaces" assembly since some methods would return such types or arrays of them. Also it would be referenced by the main application assembly (such as the Web Application)</li> <li>one or more Repository provider assembly/assemblies. Each would include (at least) a class that implements the IRepository interface and it would work with a certain Data Store. Data stores could include an SQL Server, an Oracle server, MySQL, XML files, Web / WCF services and so on.</li> </ol> <p>Studying LINQ to SQL which looks very productive in terms of time taken to implement all seems well until I discover the deep dependency between the generated classes and the CustomDataContext class.</p> <p>How can I use LINQ to SQL in such a scenario?</p>
[ { "answer_id": 232759, "author": "Mark Cidade", "author_id": 1659, "author_profile": "https://Stackoverflow.com/users/1659", "pm_score": 3, "selected": false, "text": " <?xml version=\"1.0\" encoding=\"utf-8\"?>\n <Database Name=\"DbName\" \n xmlns=\"http://schemas.microsoft.co...
2008/10/23
[ "https://Stackoverflow.com/questions/229627", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1796/" ]