qid
int64
4
19.1M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
420,718
<p>I have a linq2sql setup where objects are sent from client side (flex via flourinefx) and attach them to a new datacontext a seen below: </p> <p>I also have a "global" datacontext that is used throughout the session.</p> <pre><code> public static void Update(Enquiry enquiry) { OffertaDataContext db = new OffertaDataContext(); db.Enquiries.Attach(enquiry); db.Refresh(RefreshMode.KeepCurrentValues, enquiry); db.SubmitChanges(); } </code></pre> <p>This approach usually works fine, but after a while I get the error "Cannot add an entity with a key that is already in use".</p>
[ { "answer_id": 421183, "author": "Noah", "author_id": 47496, "author_profile": "https://Stackoverflow.com/users/47496", "pm_score": 2, "selected": false, "text": "public static void Update(Enquiry enquiry)\n{\n JobsDataContext db = new JobsDataContext();\n\n var enquiries = from e ...
2009/01/07
[ "https://Stackoverflow.com/questions/420718", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40939/" ]
420,722
<p>[This is on an iSeries/DB2 database if that makes any difference]</p> <p>I want to write a procedure to identify columns that are left as blank or zero (given a list of tables).</p> <p>Assuming I can pull out table and column definitions from the central system tables, how should I check the above condition? My first guess is for each column generate a statement dynamically such as:</p> <pre><code>select count(*) from my_table where my_column != 0 </code></pre> <p>and to check if this returns zero rows, but is there a better/faster/standard way to do this?</p> <p>NB This just needs to handle simple character, integer/decimal fields, nothing fancy!</p>
[ { "answer_id": 452090, "author": "Cade Roux", "author_id": 18255, "author_profile": "https://Stackoverflow.com/users/18255", "pm_score": 2, "selected": false, "text": "SELECT\nREPLACE(REPLACE(REPLACE(\n'\n SELECT COUNT(*) AS [COUNT NON-EMPTY IN {TABLE_NAME}.{COLUMN_NAME}]\n FROM [{...
2009/01/07
[ "https://Stackoverflow.com/questions/420722", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23447/" ]
420,723
<p>I'm just learning the Model / View / ViewModel pattern and it's variations (DataModel / View / ViewModel, or Model / View / Presenter).</p> <p>What I wonder is: if I use this pattern with a WCF service, is the service the Model (DataModel), or do I need a separate Model to encapsulate the WCF service layer??</p> <p>When I use WCF as DataModel my ViewModel is not testable without mocking the whole WCF service, since the calls to WCF need to manage the connection. The calls in this ViewModel look like this:</p> <pre><code>List&lt;Sam.Alyza.WcfInterface.Website&gt; rc = null; Service&lt;Sam.Alyza.WcfInterface.IServiceWebsites&gt;.Use(alyzaSvc =&gt; { rc = new List&lt;Sam.Alyza.WcfInterface.Website&gt;(alyzaSvc.GetSites()); }); </code></pre> <p>To get my ViewModel testable I tried adding a separate DataModel to abstract WCF connection away. After this the ViewModel was testable, the calls looked like this:</p> <pre><code>List&lt;Sam.Alyza.WcfInterface.Website&gt; rc = new List&lt;Sam.Alyza.WcfInterface.Website&gt;(_datamodel.GetSites()); </code></pre> <p>Problem: most of the code that would need to be tested now had moved into the DataModel, which, again, needed WCF to be tested. What remained in the ViewModel was a thin shell, which can be tested. But since the main code moved into the DataModel, so testing the ViewModel was quite useless.</p> <p>So to me it seems adding a separate DataModel layer to a View / ViewModel application using WCF does add a lot of work, but the testability does not get any better.</p>
[ { "answer_id": 424711, "author": "Sam", "author_id": 7021, "author_profile": "https://Stackoverflow.com/users/7021", "pm_score": 3, "selected": true, "text": "public delegate void UseServiceDelegate<T>(T proxy);\n\npublic static class Service<T>\n{\n public static ChannelFactory<T> _cha...
2009/01/07
[ "https://Stackoverflow.com/questions/420723", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7021/" ]
420,726
<p>I have code similar to this in my application:</p> <pre><code>class A { public: int b; } class C { public: int d; } void DoThings (void *arg1, MYSTERYTYPE arg2); A obj_a; C obj_c; DoThings(&amp;obj_a, &amp;A::b); DoThings(&amp;obj_c, &amp;C::d); </code></pre> <p>The question is - What should MYSTERYTYPE be? neither void* nor int work, despite the value &amp;A::b being printed just fine if you output it through a printf.</p> <p>Clarifications: Yes, &amp;A::b is defined under C++. Yes, I am trying to get the offset to a class member. Yes, I am being tricky.</p> <p>Edit: Oh I can use offsetof(). Thanks anyway.</p>
[ { "answer_id": 420787, "author": "j_random_hacker", "author_id": 47984, "author_profile": "https://Stackoverflow.com/users/47984", "pm_score": 2, "selected": false, "text": "A C A C template <typename T>\nvoid DoThings(int T::*x);\n C A void DoThings(int A::*x);\n" }, { "answer_i...
2009/01/07
[ "https://Stackoverflow.com/questions/420726", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39702/" ]
420,727
<p>Consider:</p> <pre><code>class C { private: class T {int a, b;}; }; C::T *p; </code></pre> <p>As expected, this produces a compilation error saying that C::T is private in the context of Line 6.</p> <p>Now change this to pointer-to-member:</p> <pre><code>class C { private: class T {int a, b;}; }; int C::T::*p; </code></pre> <p>This time around, gcc version 3.2.3 still makes the same complaint, but gcc version 3.4.3 lets it pass. Which is the correct behavior according to the standard?</p>
[ { "answer_id": 420787, "author": "j_random_hacker", "author_id": 47984, "author_profile": "https://Stackoverflow.com/users/47984", "pm_score": 2, "selected": false, "text": "A C A C template <typename T>\nvoid DoThings(int T::*x);\n C A void DoThings(int A::*x);\n" }, { "answer_i...
2009/01/07
[ "https://Stackoverflow.com/questions/420727", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
420,732
<p>In my profiler reports I'm increasingly seeing the results of mock-based testing with dependency injection. Many of the dependencies were static, but because we want to test methods in isolation they are changed to instance members, like the following example:</p> <pre><code>class ShortLivedThing { IDependency1 dep1; IDependency1 dep2; IDependency1 dep3; ... int TheRealData; // Constructor used in production public ShortLivedThing() { dep1 = new Dep1(); dep2 = new Dep2(); dep3 = new Dep3(); } // DI for testing public ShortLivedThing(IDependency1 d1, IDependency2 d2, IDependency3 d3) { dep1 = d1(); dep2 = d2(); dep3 = d3(); } } </code></pre> <p>In turn the dependencies most of the time have other dependencies and so on. This results in the instantiation of a tree of (mostly "static") objects <em>every time</em> a method call is done outside of tests. Each of the objects are very small (just a few pointers), but the tree effect turns this into an ever increasing performance hit.</p> <p>What can we do about it?</p>
[ { "answer_id": 420763, "author": "krosenvold", "author_id": 23691, "author_profile": "https://Stackoverflow.com/users/23691", "pm_score": 4, "selected": true, "text": " A Singleton\n |\n B Singleton\n |\n C Prototype (per-invocation)\n |\n D Singleton\n |\n E Session scope (web app)\n |\...
2009/01/07
[ "https://Stackoverflow.com/questions/420732", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1324220/" ]
420,733
<p>I'm thinking about using asking sphinx to index many fields (in the hundreds), many of which will be null. My question is how much having many null fields will affect performance?</p> <p>This situation arises not from having incredibly denormalized data, but from requirements on the search interface and what can be searched. Basically I will be building the index config dynamically in the indexed model, and may end up with quite a few null fields from doing so.</p> <p>My guess is the performance/success of this depends on what Sphinx does with null values... if it simple ignores them, then I should be fine, but if it actually stores that the field is null in its index, I could have a problem.</p>
[ { "answer_id": 420763, "author": "krosenvold", "author_id": 23691, "author_profile": "https://Stackoverflow.com/users/23691", "pm_score": 4, "selected": true, "text": " A Singleton\n |\n B Singleton\n |\n C Prototype (per-invocation)\n |\n D Singleton\n |\n E Session scope (web app)\n |\...
2009/01/07
[ "https://Stackoverflow.com/questions/420733", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6705/" ]
420,741
<p>I'm looking at creating a basic ORM (purely for fun), and was wondering, is there a way to return the list of tables in a database and also the fields for every table?</p> <p>Using this, I want to be able to loop through the result set (in C#) and then say for each table in the result set, do this (e.g. use reflection to make a class that will do or contain xyz).</p> <p>Further to this, what are some good online blogs for SQL Server? I know this question is really about using system SPs and databases in Sql Server, and I am ok with general queries, so I'm interested in some blogs which cover this sort of functionality.</p> <p>Thanks</p>
[ { "answer_id": 420752, "author": "ZombieSheep", "author_id": 377, "author_profile": "https://Stackoverflow.com/users/377", "pm_score": 5, "selected": false, "text": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='BASE TABLE'\n SELECT * FROM INFORMATION_SCHEMA.COLUMNS \n SELECT...
2009/01/07
[ "https://Stackoverflow.com/questions/420741", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32484/" ]
420,749
<p>I'd like to have the full history of a large text field edited by users, stored using Django.</p> <p>I've seen the projects:</p> <ul> <li><a href="http://code.google.com/p/fullhistory/" rel="nofollow noreferrer">Django Full History (Google Code)</a></li> <li><a href="http://code.google.com/p/django-modelhistory/" rel="nofollow noreferrer">Django ModelHistory</a>, and</li> <li><a href="http://code.djangoproject.com/wiki/FullHistory" rel="nofollow noreferrer">Django FullHistory</a></li> </ul> <p>I've a special use-case that probably falls outside the scope of what these projects provide. Further, I'm wary of how well documented, tested and updated these projects are. In any event, here's the problem I face:</p> <p>I've a model, likeso:</p> <pre><code>from django.db import models class Document(models.Model): text_field = models.TextField() </code></pre> <p>This text field may be large - over 40k - and I would like to have an autosave feature that saves the field every 30 seconds or so. This could make the database unwieldly large, obviously, if there are a lot of saves at 40k each (probably still 10k if zipped). The best solution I can think of is to keep a difference between the most recent saved version and the new version.</p> <p>However, I'm concerned about race conditions involving parallel updates. There are two distinct race conditions that come to mind (the second much more serious than the first):</p> <ol> <li><p><strong>HTTP transaction race condition</strong>: User A and User B request document X0, and make changes individually, producing Xa and Xb. Xa is saved, the difference between X0 and Xa being "Xa-0" ("a less not"), Xa now being stored as the official version in the database. If Xb subsequently saves, it overwrite Xa, the diff being Xb-a ("b less a").</p> <p>While not ideal, I'm not overly concerned with this behaviour. The documents are overwriting each other, and users A and B may have been unaware of each other (each having started with document X0), but the history retains integrity.</p></li> <li><p><strong>Database read/update race condition</strong>: The problematic race condition is when Xa and Xb save at the same time over X0. There will be (pseudo-)code something like:</p> <pre><code> def save_history(orig_doc, new_doc): text_field_diff = diff(orig_doc.text_field, new_doc.text_field) save_diff(text_field_diff) </code></pre> <p>If Xa and Xb both read X0 from the database (i.e. orig_doc is X0), their differences will become Xa-0 and Xb-0 (as opposed to the serialized Xa-0 then Xb-a, or equivalently Xb-0 then Xa-b). When you try to patch the diffs together to produce the history, it will fail on either patch Xa-0 or Xb-0 (which both apply to X0). The integrity of the history has been compromised (or has it?).</p> <p>One possible solution is an automatic reconciliation algorithm, that detects these problems <em>ex-post</em>. If rebuilding the history fails, one may assume that a race condition has occurred, and so apply the failed patch to prior versions of the history until it succeeds.</p></li> </ol> <p>I'd be delighted to have some feedback and suggestions on how to go about tackling this problem.</p> <p>Incidentally, insofar as it's a useful way out, I've noted that Django atomicity is discussed here:</p> <ul> <li><a href="https://stackoverflow.com/questions/320096/django-how-can-i-protect-against-concurrent-modification-of-data-base-entries">Django: How can I protect against concurrent modification of data base entries</a>, and here: </li> <li><a href="https://stackoverflow.com/questions/280075/atomic-operations-in-django">Atomic operations in Django?</a></li> </ul> <p>Thank you kindly.</p>
[ { "answer_id": 433455, "author": "Brian M. Hunt", "author_id": 19212, "author_profile": "https://Stackoverflow.com/users/19212", "pm_score": 2, "selected": false, "text": "\"\"\"\nhistory/__init__.py\n\"\"\"\nfrom django.core import serializers\nfrom django.utils import simplejson as jso...
2009/01/07
[ "https://Stackoverflow.com/questions/420749", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19212/" ]
420,770
<p>I'm going to be brief because I'm short on time, so I apologize if this isn't as detailed as I'd like it to be.</p> <p>I have some code:</p> <pre><code>print("&lt;a href='#'&gt;Some text&lt;sup&gt;&amp;reg;&lt;/sup&gt; some more text&lt;/a&gt;"); </code></pre> <p>In FF, this works like I would like, the link as a whole is underlined. However in IE, the link is underlined except under the &reg; where it looks like a symbol above a hyphen and is rather ridiculous looking. </p> <p>I've tried several suggestions I found on Google, but none of them are very helpful in achieving the desired effect. Adding a border to the bottom is not an option unfortunately. So far the best solution is to break the underline completely at the sup tag with CSS which still leaves it working fine in FF while still looking less silly in IE.</p> <p>If anyone could help with this it would be most appreciated, I'd rather not go through the site removing <code>&lt;sup&gt;</code> tags as I've been told I will have to do should I not solve this dilemma. </p> <p>UPDATE: Went with the sup {"text-decoration:none" } solution, it'll do for now. There are reg marks everywhere, so the whole site would've had to have been updated, which was more trouble than it was worth we all decided. Thanks to those who replied.</p>
[ { "answer_id": 420812, "author": "Diodeus - James MacFarlane", "author_id": 12579, "author_profile": "https://Stackoverflow.com/users/12579", "pm_score": 4, "selected": true, "text": "<sup> <span style='font-size:75%;vertical-align:super;text-decoration:none'>&reg</span>\n .reg {\n fo...
2009/01/07
[ "https://Stackoverflow.com/questions/420770", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32641/" ]
420,774
<p>When <code>foreach</code>ing through a generic list I often want to do something different for the first element in the list:</p> <pre><code>List&lt;object&gt; objs = new List&lt;object&gt; { new Object(), new Object(), new Object(), new Object() }; foreach (object o in objs) { if (o == objs.First()) { System.Diagnostics.Debug.WriteLine("First object - do something special"); } else { System.Diagnostics.Debug.WriteLine("object Do something else"); } } </code></pre> <p>This will output:</p> <pre> First object - do something special object Do something else object Do something else object Do something else </pre> <p>This is all fine and dandy.</p> <p>However if my generic list is of a value type, this approach will fail.</p> <pre><code>List&lt;int&gt; ints = new List&lt;int&gt; { 0, 0, 0, 0 }; foreach (int i in ints) { if (i == ints.First()) { System.Diagnostics.Debug.WriteLine("First int - do something special"); } else { System.Diagnostics.Debug.WriteLine("int Do something else"); } } </code></pre> <p>This will output:</p> <pre> First int - do something special First int - do something special First int - do something special First int - do something special </pre> <p>Now I know I could recode this to add a <code>boolean</code> flag variable or traditional <code>for</code> loop, but I am wondering if there's any way to find out if a foreach loop is on the first iteration of its looping.</p>
[ { "answer_id": 420786, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 6, "selected": true, "text": "using(var iter = ints.GetEnumerator()) {\n if(iter.MoveNext()) {\n // do \"first\" with iter.Current\n\n whil...
2009/01/07
[ "https://Stackoverflow.com/questions/420774", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39709/" ]
420,791
<p>Just got a review comment that my static import of the method was not a good idea. The static import was of a method from a DA class, which has mostly static methods. So in middle of the business logic I had a da activity that apparently seemed to belong to the current class:</p> <pre><code>import static some.package.DA.*; class BusinessObject { void someMethod() { .... save(this); } } </code></pre> <p>The reviewer was not keen that I change the code and I didn't but I do kind of agree with him. One reason given for not static-importing was it was confusing where the method was defined, it wasn't in the current class and not in any superclass so it too some time to identify its definition (the web based review system does not have clickable links like IDE :-) I don't really think this matters, static-imports are still quite new and soon we will all get used to locating them.</p> <p>But the other reason, the one I agree with, is that an unqualified method call seems to belong to current object and should not jump contexts. But if it really did belong, it would make sense to extend that super class.</p> <p>So, when <em>does</em> it make sense to static import methods? When have you done it? Did/do you like the way the unqualified calls look?</p> <p>EDIT: The popular opinion seems to be that static-import methods if nobody is going to confuse them as methods of the current class. For example methods from java.lang.Math and java.awt.Color. But if abs and getAlpha are not ambiguous I don't see why readEmployee is. As in lot of programming choices, I think this too is a personal preference thing.</p>
[ { "answer_id": 420853, "author": "Joel", "author_id": 25501, "author_profile": "https://Stackoverflow.com/users/25501", "pm_score": 4, "selected": false, "text": "assertEquals java.lang.Math" }, { "answer_id": 421021, "author": "jjnguy", "author_id": 2598, "author_pro...
2009/01/07
[ "https://Stackoverflow.com/questions/420791", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18573/" ]
420,792
<p>I'm considering moving my code (around 30K LOC) from CPython to Jython, so that I could have better integration with my java code. </p> <p>Is there a checklist or a guide I should look at, to help my with the migration? Does anyone have experience with doing something similar?</p> <p>From reading the <a href="http://jython.sourceforge.net/docs/differences.html" rel="nofollow noreferrer">Jython site</a>, most of the problems seem too obscure to bother me.</p> <p>I did notice that:</p> <ul> <li>thread safety is an issue</li> <li>Unicode support seems to be quite different, which may be a problem for me</li> <li>mysqldb doesn't work and needs to be replaced with zxJDBC</li> </ul> <p>Anything else?</p> <p>Related question: <a href="https://stackoverflow.com/questions/53543/what-are-some-strategies-to-write-python-code-that-works-in-cpython-jython-and-i">What are some strategies to write python code that works in CPython, Jython and IronPython</a></p>
[ { "answer_id": 4482032, "author": "itsadok", "author_id": 7581, "author_profile": "https://Stackoverflow.com/users/7581", "pm_score": 4, "selected": true, "text": "open('file').read() with open('file') as fp mysqldb com.ziclix.python.sql.zxJDBC connection = MySQLdb.connect(host, user, pa...
2009/01/07
[ "https://Stackoverflow.com/questions/420792", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7581/" ]
420,800
<pre><code> Checkbox[,] checkArray = new Checkbox[2, 3]{{checkbox24,checkboxPref1,null}, {checkbox23,checkboxPref2,null}}; </code></pre> <p>I am getting error . How do I initialize it? </p>
[ { "answer_id": 420896, "author": "BFree", "author_id": 15861, "author_profile": "https://Stackoverflow.com/users/15861", "pm_score": 3, "selected": true, "text": " CheckBox[,] checkArray;\n public Form1()\n {\n InitializeComponent();\n checkArray = new CheckB...
2009/01/07
[ "https://Stackoverflow.com/questions/420800", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42564/" ]
420,813
<p>Can I create a private instance method that can be called by a class method?</p> <pre><code>class Foo def initialize(n) @n = n end private # or protected? def plus(n) @n += n end end class Foo def Foo.bar(my_instance, n) my_instance.plus(n) end end a = Foo.new(5) a.plus(3) # This should not be allowed, but Foo.bar(a, 3) # I want to allow this </code></pre> <p>Apologies if this is a pretty elementary question, but I haven't been able to Google my way to a solution.</p>
[ { "answer_id": 420837, "author": "Samuel", "author_id": 32465, "author_profile": "https://Stackoverflow.com/users/32465", "pm_score": 5, "selected": true, "text": "class Foo\n def Foo.bar(my_instance, n)\n my_instance.send(:plus, n)\n end\nend\n" }, { "answer_id": 422814, ...
2009/01/07
[ "https://Stackoverflow.com/questions/420813", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4812/" ]
420,825
<p>I was reading about threading and about locking. It is common practise that you can't (well should not) lock a value type.</p> <p>So the question is, what is the recommended way of locking a value type? I know there's a few ways to go about doing one thing but I haven't seen an example. Although there was a good thread on MSDN forums but I can't seem to find that now.</p> <p>Thanks</p>
[ { "answer_id": 420836, "author": "Jon B", "author_id": 27414, "author_profile": "https://Stackoverflow.com/users/27414", "pm_score": 6, "selected": true, "text": "int valueType;\nobject valueTypeLock = new object();\n\nvoid Foo()\n{\n lock (valueTypeLock)\n {\n valueType = 0...
2009/01/07
[ "https://Stackoverflow.com/questions/420825", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32484/" ]
420,832
<p>I want to strengthen a pattern to match only numbers which pass an additional validation function.</p> <pre><code>let (|IsValid|_|) n = ... let (|Nil|One|Two|) (l : int list) = match l with | a :: b :: t -&gt; Two(a + b) | a :: t -&gt; One(a) | _ -&gt; Nil </code></pre> <p>The 'One' case is easy:</p> <pre><code> | IsValid(a) :: t -&gt; One(a) </code></pre> <p>The 'Two' case isn't obvious to me. It needs to validate the sum of the numbers. Can I do this without using a when-guard?</p> <p>...</p> <p>Edit: I could use a when-guard (with a bool-returning isValid function) like this:</p> <pre><code> | a :: b :: t when isValid a + b -&gt; Two(a + b) </code></pre> <p>This is less elegant than just matching a pattern; worse, a + b is applied twice.</p> <p>Also note this is a simplified version of my actual code (I'm not trying to simply match against different lengths of list for example) - the question is about nested matching over the double cons pattern. </p>
[ { "answer_id": 420836, "author": "Jon B", "author_id": 27414, "author_profile": "https://Stackoverflow.com/users/27414", "pm_score": 6, "selected": true, "text": "int valueType;\nobject valueTypeLock = new object();\n\nvoid Foo()\n{\n lock (valueTypeLock)\n {\n valueType = 0...
2009/01/07
[ "https://Stackoverflow.com/questions/420832", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40759/" ]
420,838
<p>I am trying to install the "libxml" Gem (<a href="http://libxml.rubyforge.org/install.xml" rel="nofollow noreferrer">http://libxml.rubyforge.org/install.xml</a>) and it says that libxml requires a few other libraries to be installed in order to build and function properly:</p> <pre><code> * libm (math routines: very standard) * libz (zlib) * libiconv * libxml2 </code></pre> <p>I installed RubyGems but I wonder if "libiconv" for example is also a gem?</p> <p>What is the way to download and install these libraries above?</p> <p>Thanks!</p>
[ { "answer_id": 420836, "author": "Jon B", "author_id": 27414, "author_profile": "https://Stackoverflow.com/users/27414", "pm_score": 6, "selected": true, "text": "int valueType;\nobject valueTypeLock = new object();\n\nvoid Foo()\n{\n lock (valueTypeLock)\n {\n valueType = 0...
2009/01/07
[ "https://Stackoverflow.com/questions/420838", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51338/" ]
420,843
<p>I'm having some trouble understanding the purpose of a salt to a password. It's my understanding that the primary use is to hamper a rainbow table attack. However, the methods I've seen to implement this don't seem to really make the problem harder.</p> <p>I've seen many tutorials suggesting that the salt be used as the following:</p> <pre><code>$hash = md5($salt.$password) </code></pre> <p>The reasoning being that the hash now maps not to the original password, but a combination of the password and the salt. But say <code>$salt=foo</code> and <code>$password=bar</code> and <code>$hash=3858f62230ac3c915f300c664312c63f</code>. Now somebody with a rainbow table could reverse the hash and come up with the input "foobar". They could then try all combinations of passwords (f, fo, foo, ... oobar, obar, bar, ar, ar). It might take a few more milliseconds to get the password, but not much else.</p> <p>The other use I've seen is on my linux system. In the /etc/shadow the hashed passwords are actually stored <em>with</em> the salt. For example, a salt of "foo" and password of "bar" would hash to this: <code>$1$foo$te5SBM.7C25fFDu6bIRbX1</code>. If a hacker somehow were able to get his hands on this file, I don't see what purpose the salt serves, since the reverse hash of <code>te5SBM.7C25fFDu6bIRbX</code> is known to contain "foo".</p> <p>Thanks for any light anybody can shed on this.</p> <p><strong>EDIT</strong>: Thanks for the help. To summarize what I understand, the salt makes the hashed password more complex, thus making it much less likely to exist in a precomputed rainbow table. What I misunderstood before was that I was assuming a rainbow table existed for ALL hashes.</p>
[ { "answer_id": 421081, "author": "Ross", "author_id": 29173, "author_profile": "https://Stackoverflow.com/users/29173", "pm_score": 9, "selected": true, "text": "n n" }, { "answer_id": 421147, "author": "Community", "author_id": -1, "author_profile": "https://Stackove...
2009/01/07
[ "https://Stackoverflow.com/questions/420843", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42897/" ]
420,852
<p>Is there an easy way to read an application's already embedded manifest file?</p> <p>I was thinking along the lines of an alternate data stream?</p>
[ { "answer_id": 422063, "author": "Roger Lipscombe", "author_id": 8446, "author_profile": "https://Stackoverflow.com/users/8446", "pm_score": 7, "selected": true, "text": "BOOL CALLBACK EnumResourceNameCallback(HMODULE hModule, LPCTSTR lpType,\n LPWSTR lpName, LONG_PTR lParam)\n{\n ...
2009/01/07
[ "https://Stackoverflow.com/questions/420852", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3153/" ]
420,856
<p>I'm trying to load a div into a page based on a change in the drop down. I either want to show a div which has state/zip or province/postal_code, (each is a file) but I am getting a "406 Not Acceptable [<a href="http://localhost/profiles/residency]" rel="nofollow noreferrer">http://localhost/profiles/residency]</a>"</p> <p>Here is my JQuery code:</p> <pre><code>$(function(){ $("#profile_country").change(onSelectChange); }); function onSelectChange() { var selected = $("#profile_country option:selected"); var selectedText = selected.text(); if (selectedText == 'United States') { $("#residency").load("/profiles/residency"); } else { $("#residency").load("/profiles/residency"); } } </code></pre> <p>Now I am at loss, what should be in my "residency method"? what to put in my routes file?</p>
[ { "answer_id": 420916, "author": "roryf", "author_id": 270, "author_profile": "https://Stackoverflow.com/users/270", "pm_score": 2, "selected": false, "text": "406 Not Acceptable Content-Type Accept" } ]
2009/01/07
[ "https://Stackoverflow.com/questions/420856", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
420,860
<p>is there anything?</p>
[ { "answer_id": 421681, "author": "Drew Noakes", "author_id": 24874, "author_profile": "https://Stackoverflow.com/users/24874", "pm_score": 2, "selected": false, "text": "ConcurrentHashMap Hashtable.Synchronised(...) System.Collections.Generic if (collection.Contains(item))\n collectio...
2009/01/07
[ "https://Stackoverflow.com/questions/420860", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52478/" ]
420,863
<p>I have a problem with an application which uses the same stored procedure over and over again to populate people information in dropdown lists. The problem is that sometimes people aren't there anymore as the data changes. I have two views I can use to select from, but I want to dynamically change which view is being used based on the state of the application.</p> <p>For new records, I only want to see current people. If I'm updating an existing record, I may want to see all people since the existing record may reference someone who is not current anymore.</p> <p>How would I go about passing the view name in to my stored procedure so I can select from it?</p> <p>I've already tried adding:</p> <pre><code>@view varchar(50) select a, b from @view </code></pre> <p>But I get an error stating I must declare the variable @view.</p> <p>Is this even possible to do?</p>
[ { "answer_id": 420885, "author": "Rockcoder", "author_id": 5290, "author_profile": "https://Stackoverflow.com/users/5290", "pm_score": 3, "selected": true, "text": "@useFirstView bit\n\nIF @useFirstView = 1 \n -- select from firstView\nELSE\n -- select from secondView\n" }, { ...
2009/01/07
[ "https://Stackoverflow.com/questions/420863", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48478/" ]
420,864
<p>What is the best way to ensure that the proper RJS is being generated in a Controller action?</p> <p>For example, I want to ensure that a div is highlighted as such:</p> <pre><code>def new render :update do |page| page.visual_effect :highlight, :some_div end end </code></pre> <p><strong>Rant:</strong> This is quickly becoming one of the reasons I grow tired of RSpec after using it for a year. This should be an easy question, but it's one that no one seems to have an answer for.</p> <p>I've been told repeatedly that RSpec specifies behavior and what I'm trying to do here is just "test code". Highlighting of the :some_div is behavior as far as I can tell.</p>
[ { "answer_id": 420885, "author": "Rockcoder", "author_id": 5290, "author_profile": "https://Stackoverflow.com/users/5290", "pm_score": 3, "selected": true, "text": "@useFirstView bit\n\nIF @useFirstView = 1 \n -- select from firstView\nELSE\n -- select from secondView\n" }, { ...
2009/01/07
[ "https://Stackoverflow.com/questions/420864", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52283/" ]
420,867
<p>The snippet says it all :-)</p> <pre><code>UTF8Encoding enc = new UTF8Encoding(true/*include Byte Order Mark*/); byte[] data = enc.GetBytes("a"); // data has length 1. // I expected the BOM to be included. What's up? </code></pre>
[ { "answer_id": 420900, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 2, "selected": false, "text": "GetBytes() byte[] preamble = enc.GetPreamble();\n" }, { "answer_id": 420995, "author": "xyz", "author...
2009/01/07
[ "https://Stackoverflow.com/questions/420867", "https://Stackoverflow.com", "https://Stackoverflow.com/users/82/" ]
420,878
<p>Is there a way to hide/protect/obfuscate MS SQL Stored Procedures?</p>
[ { "answer_id": 36086842, "author": "InbetweenWeekends", "author_id": 902874, "author_profile": "https://Stackoverflow.com/users/902874", "pm_score": 2, "selected": false, "text": "CrEAtE Procedure spInsertOrUpdateProduct @ProductNumber nVarChar(25),\n@ListPrice Money aS IF exIsTS(selECt ...
2009/01/07
[ "https://Stackoverflow.com/questions/420878", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32183/" ]
420,888
<p>We use VS2008 with TFS for source control at my workplace and it works fine, however today we experienced a problem when trying to associate our pending changes with a work item. Usually when I want to associate changes with a work item I just go to the second tab from the top in the "pending changes" window, check the work item that fits the changes and check in. Today however, all my work items were gone from the list. I can select a suitable query from the drop down box and this works fine, so the projects are there.</p> <p>I think the problem might have something to do with the "My Work Items" query being associated with the wrong TFS project (there are two on our TFS-server) but I don't know how to fix this. The same problem occurred for most of my colleagues with some (possible) variations.</p> <p>So... <strong>how do I restore "My Work Items"</strong> to the pending changes window?</p> <p>EDIT: The problem still persists in a way but I worked my way around it by removing the second project in the Team Explorer. This is acceptable (for now) since that project is not currently active. I am not content with this being a good long term solution, however...</p> <p>EDIT: I know that I may not have provided enough information for anyone to understand what really is the problem, still, I'll keep it up for now in case someone has had the same problem and knows how to fix it :P</p>
[ { "answer_id": 36086842, "author": "InbetweenWeekends", "author_id": 902874, "author_profile": "https://Stackoverflow.com/users/902874", "pm_score": 2, "selected": false, "text": "CrEAtE Procedure spInsertOrUpdateProduct @ProductNumber nVarChar(25),\n@ListPrice Money aS IF exIsTS(selECt ...
2009/01/07
[ "https://Stackoverflow.com/questions/420888", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45704/" ]
420,891
<p>If I registered several components with Windsor.</p> <p>IAnimal provides BigAnimal IPerson provides SmellyPerson IWhale provides BlueWhale</p> <p>etc.. pretty standard component registeration</p> <p>all the above types implement IMustBeIntercepted, how do I tell the container add an interceptor to all types that implement IMustBeImplemented so that when Resolve is called it is returned a BigAnimal with an interceptor as defined since it matches. I know I can do this for each one but its extra XML config or programatic config which I want to avoid</p>
[ { "answer_id": 470774, "author": "Mikael Sundberg", "author_id": 4422, "author_profile": "https://Stackoverflow.com/users/4422", "pm_score": 3, "selected": false, "text": "public interface IMustBeIntercepted {}\n public class InterceptionFacility : AbstractFacility {\n protected overr...
2009/01/07
[ "https://Stackoverflow.com/questions/420891", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
420,895
<p>I'm working on creating a call back function for an ASP.NET cache item removal event.</p> <p>The documentation says I should call a method on an object or calls I know will exist (will be in scope), such as a static method, but it said I need to ensure the static is thread safe.</p> <p>Part 1: What are some examples of things I could do to make it un-thread safe?</p> <p>Part 2: Does this mean that if I have</p> <pre><code>static int addOne(int someNumber){ int foo = someNumber; return foo +1; } </code></pre> <p>and I call Class.addOne(5); and Class.addOne(6); simutaneously, Might I get 6 or 7 returned depending on who which invocation sets foo first? (i.e. a race condition)</p>
[ { "answer_id": 420914, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 5, "selected": false, "text": " class BadCounter\n {\n private static int counter;\n\n public static int Increment()\n {\n ...
2009/01/07
[ "https://Stackoverflow.com/questions/420895", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33264/" ]
420,948
<p>I recently started working at a company with an enormous "enterprisey" application. At my last job, I designed the database, but here we have a whole Database Architecture department that I'm not part of.</p> <p>One of the stranger things in their database is that they have a bunch of views which, instead of having the user provide the date ranges they want to see, join with a (global temporary) table "TMP_PARM_RANG" with a start and end date. Every time the main app starts processing a request, the first thing it does it "<code>DELETE FROM TMP_PARM_RANG</code>;" then an insert into it.</p> <p>This seems like a bizarre way of doing things, and not very safe, but everybody else here seems ok with it. Is this normal, or is my uneasiness valid?</p> <p><strong>Update</strong> I should mention that they use transactions and per-client locks, so it is guarded against most concurrency problems. Also, there are literally dozens if not hundreds of views that all depend on <code>TMP_PARM_RANG</code>.</p>
[ { "answer_id": 421011, "author": "Dave Costa", "author_id": 6568, "author_profile": "https://Stackoverflow.com/users/6568", "pm_score": 3, "selected": true, "text": "SELECT * FROM some_table, tmp_parm_rang\n WHERE some_table.date_column BETWEEN tmp_parm_rang.start_date AND tmp_parm_rang...
2009/01/07
[ "https://Stackoverflow.com/questions/420948", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3333/" ]
420,964
<p>I want to do the following query:</p> <pre><code>UPDATE `users` SET balance = (balance - 10) WHERE id=1 </code></pre> <p>But if the balance will become a negative number I want an error to be returned. Any ideas on if this is possible?</p>
[ { "answer_id": 420988, "author": "Paul Dixon", "author_id": 6521, "author_profile": "https://Stackoverflow.com/users/6521", "pm_score": 3, "selected": false, "text": "UPDATE `users` SET balance = (balance - 10) WHERE id=1 and balance >=10\n create table foo(val int unsigned default '0');...
2009/01/07
[ "https://Stackoverflow.com/questions/420964", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
420,976
<p>I have several tables that center around an organization table that simply holds a unique ID value. Each Organization can then be at a particular location and have a particular name. The tricky part is that the organizations support location and name changes with a specified effective date of each change. For this example I have 4 relevant tables:</p> <p>Organization: ID (PK, int, identity) </p> <p>Location: ID (PK, int, identity), Name (varchar), AltLat (float), AltLong (float)</p> <p>organization_locations: organization_id(FK, int), location (FK, int), eff_date (datetime)</p> <p>organization_names: organization_id (FK, int), name (ntext), eff_date (datetime), icon (nvarchar(100))</p> <p>What I need to retrieve is the list of all locations along with all organizations at a given location as of a specific date and project them into my business entities. In other words, I will have a date provided and need to return for each location, the organization related to the organization_location entry with the most recent eff_date that is less than the date provided. Same thing goes for each organization, I'd need the name as of the date. </p> <p>Here's what I started with but it doesn't seem to work:</p> <pre><code>Dim query = From loc In dc.Locations _ Where loc.AltLong IsNot Nothing And loc.AltLat IsNot Nothing _ Select New AnnexA.Entities.AnnexALocation With {.ID = loc.ID, .Name = loc.Location, .Y = loc.AltLat, .X = loc.AltLong, _ .Units = From ol In loc.organization_locations Let o = ol.Organization.organization_names.Where(Function(ed) (ol.eff_date &lt; Date.Parse("1/1/2011"))).OrderByDescending(Function(od) (od.eff_date)).First() Select New AnnexA.Entities.AnnexAMillitaryUnit With {.ID = o.ID, .Name = o.name, .IconPath = o.icon}} </code></pre> <p>I'd prefer VB syntax but if you can only give me a C# query I can work with that. I've tried a few other variations but I end up getting syntax errors about an expected "}" or members not being a part of an entity set no matter what combination of parenthesis I try.</p>
[ { "answer_id": 420988, "author": "Paul Dixon", "author_id": 6521, "author_profile": "https://Stackoverflow.com/users/6521", "pm_score": 3, "selected": false, "text": "UPDATE `users` SET balance = (balance - 10) WHERE id=1 and balance >=10\n create table foo(val int unsigned default '0');...
2009/01/07
[ "https://Stackoverflow.com/questions/420976", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31672/" ]
421,002
<p>I have an SQL Server 2005 table named 'EventTable' defined as such:</p> <p>EventID, EventTypeCode, EventStatusCode, EventDate</p> <p>Currently the table has a clustered index on the primary key 'EventID', there are no other indexes currently</p> <p>EventTypeCode and EventStatusCode columns are CHAR(3) (examples are 'NEW', 'SEN', 'SAL') and are foreign keys</p> <p>Common Selects will be...</p> <pre><code>select * from EventTable Where EventDate = @dateparam; select * from EventTable Where EventTypeCode = @eventtype; select * from EventTable Where EventStatusCode = @statustype; </code></pre> <p>What index strategy would you use to handle Select statements above?</p> <p>Is it better to have a covering (compound) index on the 3 columns? If so, what order should the compound index be in? </p> <p>Or a separate index on each of the 3 columns?</p> <p>The table will grow at the rate of about 300 events per day..</p> <hr> <p>It will also be common to execute queries such as <code><pre> where EventDate between '2008-12-01' and '2008-12-31' and EventTypeCode = 'todo' </pre> </code></p> <ul> <li>the table is more likely to grow at 500-800/records per day rather than 300</li> <li>the queries mentioned in the initial question will be run many times throughout the day, during normal use of the ASP.NET application</li> <li>NHibernate 'HQL' is used to perform such queries</li> <li>there is no initial load of data, the table only sits at about 10K records now because this is a new app</li> <li>...I'm more or less just trying to avoid the customer having to call us in a couple years to complain about the app becoming 'slow' since this table will be hit so much </li> </ul>
[ { "answer_id": 421054, "author": "Amy B", "author_id": 8155, "author_profile": "https://Stackoverflow.com/users/8155", "pm_score": 4, "selected": true, "text": "on EventTable(EventDate)\non EventTable(EventTypeCode)\non EventTable(EventStatusCode)\n on EventTable(EventDate, EventId,\n ...
2009/01/07
[ "https://Stackoverflow.com/questions/421002", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52212/" ]
421,013
<p>What is best practice to create dynamic sidebar or other non content layout places with zend framework. At this moment I created controller witch i called WidgetsController. In this controller i defined some actions with 'sidebar' response segment for my sidebar and in IndexController i call them with $this->view->action(); function but I don't think that is a best practice to create dynamic sidebar. Thanks for your answers.</p>
[ { "answer_id": 421043, "author": "Ali", "author_id": 49153, "author_profile": "https://Stackoverflow.com/users/49153", "pm_score": -1, "selected": false, "text": "<ul> <div> Model, View, Controller Header <html>\n<head>.......</head>\n<div id=\"header\">....</div>\n<?php $this->load->vie...
2009/01/07
[ "https://Stackoverflow.com/questions/421013", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43182/" ]
421,026
<p>Tomorrow, I will meet a client that is not working in technology but might ask if RubyOnRails is the right choice for his site. He might think that there's not enough RoR programmers and that he will be "hostage" of the language.</p> <p>I have good reasons to use RoR and the client has good reasons to like it (it costs less!).</p> <p>Do you have "official" sources I could show them?</p>
[ { "answer_id": 421305, "author": "Ethan", "author_id": 42595, "author_profile": "https://Stackoverflow.com/users/42595", "pm_score": 2, "selected": false, "text": "mod_rails" } ]
2009/01/07
[ "https://Stackoverflow.com/questions/421026", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42866/" ]
421,031
<p>Hi This is either a very specific or very generic quetion - I'm not sure, and I'm new to the Zend framework / oo generally. Please be patient if this is a stupid Q...</p> <p>Anyway, I want to create a model which does something like:</p> <pre><code>Read all the itmes from a table 'gifts' into a row set for each row in the table, read from a second table which shows how many have been bought, the append this as another "field" in the returned row return the row set, with the number bought included. </code></pre> <p>Most of the simple Zend examples seem to only use one table in a model, but my reading seems to suggest that I should do most of the work there, rather than in the controller. If this is too generic a question, any example of a model that works with 2 tables and returns an array would be great!</p> <p>thanks for your help in advance!</p>
[ { "answer_id": 421092, "author": "Brian Fisher", "author_id": 43816, "author_profile": "https://Stackoverflow.com/users/43816", "pm_score": 1, "selected": false, "text": "public function getGiftWithAdditionalField($giftId) {\n $select = $this->getAdapter()->select()\n ->from(array('g...
2009/01/07
[ "https://Stackoverflow.com/questions/421031", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52494/" ]
421,040
<p>I have a very simple HTML page (validates as XHTML 1.0 Strict):</p> <pre><code>&lt;div class="news-result"&gt; &lt;h2&gt;&lt;a href="#"&gt;Title&lt;/a&gt;&lt;/h2&gt;&lt;span class="date"&gt;(1-1-2009)&lt;/span&gt; &lt;p&gt;Some text...&lt;/p&gt; &lt;/div&gt; </code></pre> <p>with the following CSS:</p> <pre><code>.news-result { overflow: hidden; padding: 30px 0 20px; } .news-result h2 { float: left; margin: 0 10px 0 0; } .news-result span.date { margin: 1px 0 0; float : left; } .news-result p { padding: 3px 0 0 0; clear: left; } </code></pre> <p>Rendering this page in IE6 or FF3 render perfectly (the title and the date on a single line, followed by the paragraph). In IE7 however, there is a large space between the title and date, and the paragraph.</p> <p>We have a simple reset that clears every margin and padding on every element.</p> <p>Dropping the float on the date element fixes this problem, as does setting <code>zoom: 1</code> on the paragraph or removing <code>overflow: hidden</code> on the container, but all are not ideal. Why does a float followed by a paragraph trigger this additional top margin, only on IE7?</p>
[ { "answer_id": 421150, "author": "Grant Wagner", "author_id": 9254, "author_profile": "https://Stackoverflow.com/users/9254", "pm_score": 2, "selected": false, "text": "<p> .news-result p {\n margin-top: 0;\n padding: 3px 0 0 0;\n clear: left;\n}\n" }, { "answer_id": 421...
2009/01/07
[ "https://Stackoverflow.com/questions/421040", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4174/" ]
421,049
<p>If I have a few UNION Statements as a contrived example:</p> <pre><code>SELECT * FROM xxx WHERE z = 1 UNION SELECT * FROM xxx WHERE z = 2 UNION SELECT * FROM xxx WHERE z = 3 </code></pre> <p><strong>What is the default <code>order by</code> behaviour?</strong></p> <p>The test data I'm seeing essentially does not return the data in the order that is specified above. I.e. the data is ordered, but I wanted to know what are the rules of precedence on this.</p> <p>Another thing is that in this case xxx is a View. The view joins 3 different tables together to return the results I want.</p>
[ { "answer_id": 421446, "author": "BradC", "author_id": 21398, "author_profile": "https://Stackoverflow.com/users/21398", "pm_score": 3, "selected": false, "text": "SELECT ContactID FROM Person.Contact\nSELECT * FROM Person.Contact\n" }, { "answer_id": 425070, "author"...
2009/01/07
[ "https://Stackoverflow.com/questions/421049", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42124/" ]
421,050
<p>According to <a href="http://peak.telecommunity.com/DevCenter/setuptools#development-mode" rel="nofollow noreferrer">setuptools</a> documentation, setup.py develop is supposed to create the egg-link file and update easy_install.pth when installing into site-packages folder. However, in my case it's only creating the egg-link file. How does setuptools decide if it needs to update easy_install.pth?</p> <p>Some more info: It works when I have setuptools 0.6c7 installed as a folder under site-packages. But when I use setuptools 0.6c9 installed as a zipped egg, it does not work.</p>
[ { "answer_id": 495822, "author": "joeforker", "author_id": 36330, "author_profile": "https://Stackoverflow.com/users/36330", "pm_score": 2, "selected": false, "text": "easy_install --always-unzip --upgrade setuptools" } ]
2009/01/07
[ "https://Stackoverflow.com/questions/421050", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52490/" ]
421,107
<p>I have a code base where many of the classes I implement derive from classes that are provided by other divisions of my company. Working with these other devisions often have the working relationship as though they are third party middle ware vendors.</p> <p>I'm trying to write test code without modifying these base classes. However, there are issues with creating meaningful test objects due to the lack of interfaces:</p> <pre><code>//ACommonClass.h #include "globalthermonuclearwar.h" //which contains deep #include dependencies... #include "tictactoe.h" //...and need to exist at compile time to get into test... class Something //which may or may not inherit from another class similar to this... { public: virtual void fxn1(void); //which often calls into many other classes, similar to this //... int data1; //will be the only thing I can test against, but is often meaningless without fxn1 implemented //... }; </code></pre> <p>I'd normally extract an interface and work from there, but as these are "Third Party", I can't commit these changes.</p> <p>Currently, I've created a separate file that holds fake implementations for functions that are defined in the third-party supplied base class headers on a need to know basis, as has been described in the book "Working with Legacy Code".</p> <p>My plan was to continue to use these definitions and provide alternative test implementations for each third party class that I needed:</p> <pre><code>//SomethingRequiredImplementations.cpp #include "ACommonClass.h" void CGlobalThermoNuclearWar::Simulate(void) {}; // fake this and all other required functions... // fake implementations for otherwise undefined functions in globalthermonuclearwar.h's #include files... void Something::fxn1(void) { data1 = blah(); } //test specific functionality. </code></pre> <p>But before I start doing that I was wondering if any one has tried providing actual objects on a code base similar to mine, which would allow creating new test specific classes to use in place of actual third-party classes.</p> <p>Note all code bases in question are written in C++.</p>
[ { "answer_id": 778253, "author": "user29159", "author_id": 29159, "author_profile": "https://Stackoverflow.com/users/29159", "pm_score": 1, "selected": false, "text": "class ConcreteProductionClass { // regular everyday class\nprotected:\n ConcreteProductionClass(); // I've found the ...
2009/01/07
[ "https://Stackoverflow.com/questions/421107", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8908/" ]
421,119
<p>I have a weird design situation that I've never encountered before... If I were using Objective-C, I would solve it with categories, but I have to use C# 2.0.</p> <p>First, some background. I have two abstraction layers in this class library. The bottom layer implements a plug-in architecture for components that scan content (sorry, can't be more specific than that). Each plug-in will do its scanning in some unique way, but also the plug-ins can vary by what type of content they accept. I didn't want to expose Generics through the plug-in interface for various reasons not relevant to this discussion. So, I ended up with an IScanner interface and a derived interface for each content type.</p> <p>The top layer is a convenience wrapper that accepts a composite content format that contains various parts. Different scanners will need different parts of the composite, depending on what content type they are interested in. Therefore, I need to have logic specific to each IScanner-derived interface that parses the composite content, looking for the relevant part that is required.</p> <p>One way to solve this is to simply add another method to IScanner and implement it in each plug-in. However, the whole point of the two-layer design is so that the plug-ins themselves don't need to know about the composite format. The brute-force way to solve this is by having type-tests and downcasts in the upper layer, but these would need to be carefully maintained as support for new content types is added in the future. The Visitor pattern would also be awkward in this situation because there really is only one Visitor, but the number of different Visitable types will only increase with time (i.e. -- these are the opposite conditions for which Visitor is suitable). Plus, double-dispatch feels like overkill when really all I want is to hijack IScanner's single-dispatch!</p> <p>If I were using Objective-C, I would just define a category on each IScanner-derived interface and add the parseContent method there. The category would be defined in the upper layer, so the plug-ins wouldn't need to change, while simultaneously avoiding the need for type tests. Unfortunately C# extension methods wouldn't work because they are basically static (i.e. -- tied to the compile-time type of the reference used at the call site, not hooked into dynamic dispatch like Obj-C Categories). Not to mention, I have to use C# 2.0, so extension methods are not even available to me. :-P</p> <p>So is there a clean and simple way to solve this problem in C#, akin to how it could be solved with Objective-C categories?</p> <hr> <p>EDIT: Some pseudo-code to help make the structure of the current design clear:</p> <pre><code>interface IScanner { // Nothing to see here... } interface IContentTypeAScanner : IScanner { void ScanTypeA(TypeA content); } interface IContentTypeBScanner : IScanner { void ScanTypeB(TypeB content); } class CompositeScanner { private readonly IScanner realScanner; // C-tor omitted for brevity... It takes an IScanner that was created // from an assembly-qualified type name using dynamic type loading. // NOTE: Composite is defined outside my code and completely outside my control. public void ScanComposite(Composite c) { // Solution I would like (imaginary syntax borrowed from Obj-C): // [realScanner parseAndScanContentFrom: c]; // where parseAndScanContentFrom: is defined in a category for each // interface derived from IScanner. // Solution I am stuck with for now: if (realScanner is IContentTypeAScanner) { (realScanner as IContentTypeAScanner).ScanTypeA(this.parseTypeA(c)); } else if (realScanner is IContentTypeBScanner) { (realScanner as IContentTypeBScanner).ScanTypeB(this.parseTypeB(c)); } else { throw new SomeKindOfException(); } } // Private parsing methods omitted for brevity... } </code></pre> <hr> <p>EDIT: To clarify, I have thought through this design a lot already. I have many reasons, most of which I cannot share, for why it is the way it is. I have not accepted any answers yet because although interesting, they dodge the original question.</p> <p>The fact is, in Obj-C I could solve this problem simply and elegantly. The question is, can I use the same technique in C# and if so, how? I don't mind looking for alternatives, but to be fair that isn't the question I asked. :)</p>
[ { "answer_id": 778253, "author": "user29159", "author_id": 29159, "author_profile": "https://Stackoverflow.com/users/29159", "pm_score": 1, "selected": false, "text": "class ConcreteProductionClass { // regular everyday class\nprotected:\n ConcreteProductionClass(); // I've found the ...
2009/01/07
[ "https://Stackoverflow.com/questions/421119", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3121/" ]
421,137
<p>In .NET 1.x, you could use the <a href="http://msdn.microsoft.com/en-us/library/system.security.permissions.strongnameidentitypermissionattribute.aspx" rel="nofollow noreferrer">StrongNameIdentityPermissionAttribute</a> on your assembly to ensure that only code signed by you could access your assembly. According to the MSDN documentation, </p> <blockquote> <p>In the .NET Framework version 2.0 and later, demands for identity permissions are ineffective if the calling assembly has full trust.</p> </blockquote> <p>This means that any application with full trust can just bypass my security demands.</p> <p>How can I prevent unauthorized code from accessing my assembly in .NET 2.0?</p>
[ { "answer_id": 421923, "author": "Rob Prouse", "author_id": 30827, "author_profile": "https://Stackoverflow.com/users/30827", "pm_score": 4, "selected": true, "text": "EnsureAssemblyIsSignedByMyCompany( Assembly.GetCallingAssembly() );\n /// <summary>\n /// Ensures that the given asse...
2009/01/07
[ "https://Stackoverflow.com/questions/421137", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30827/" ]
421,139
<p>I am working in C to implement pseudo-code that says:</p> <pre><code>delay = ROUND(64*(floatDelay - intDelay)) where intDelay = (int) floatDelay </code></pre> <p>The floatDelay will always be positive. Is there an advantage to using the round function from math.h:</p> <pre><code>#inlcude &lt;math.h&gt; delay=(int) round(64*(floatDelay-intDelay)); </code></pre> <p>or can I use:</p> <pre><code>delay=(int)(64*(floatDelay - intDelay) + 0.5)) </code></pre>
[ { "answer_id": 421175, "author": "j_random_hacker", "author_id": 47984, "author_profile": "https://Stackoverflow.com/users/47984", "pm_score": 2, "selected": false, "text": "floatDelay round()" } ]
2009/01/07
[ "https://Stackoverflow.com/questions/421139", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48064/" ]
421,143
<p>I want to write a custom view engine that returns custom text (like coma delimited) does anyone know how I'd change the view engine on the fly to handle this? </p>
[ { "answer_id": 421172, "author": "mmx", "author_id": 33708, "author_profile": "https://Stackoverflow.com/users/33708", "pm_score": 0, "selected": false, "text": "return View(\"ViewName\");\n" }, { "answer_id": 421180, "author": "Eduardo Campañó", "author_id": 12091, "...
2009/01/07
[ "https://Stackoverflow.com/questions/421143", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
421,154
<p>In my script:</p> <pre><code>Function getDescript (strname, uname) Set MyUser = GetObject ("LDAP://cn=" &amp; uname &amp; ",ou=" &amp; strname &amp; ",DC=tms-1,DC=net") getDescript = myUser.Get("msExchOmaAdminWirelessEnable") End Function uname = "Bob Gardner" strname = "bgConsultants" WScript.Echo "wireless enable: " &amp; getDescript(strname, uname) </code></pre> <p>I have noticed some users in the same OU sometimes do and sometimes don't have the msExchOmaAdminWirelessEnable attribute when I check it in sysinternals' ACtive Directory Explorer. All users are in the same OU and the exchange 2003 server has sp2 installed.</p> <p>Anyone might know why this is? </p> <p><em>Update: I figured out that if I disable and re-enable the Outlook Mobile Access setting for each user, the msExchOmaAdminWirelessEnable attribute shows up again for those users missing that attribute...weird..</em> </p>
[ { "answer_id": 421172, "author": "mmx", "author_id": 33708, "author_profile": "https://Stackoverflow.com/users/33708", "pm_score": 0, "selected": false, "text": "return View(\"ViewName\");\n" }, { "answer_id": 421180, "author": "Eduardo Campañó", "author_id": 12091, "...
2009/01/07
[ "https://Stackoverflow.com/questions/421154", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18853/" ]
421,155
<p>If I want to loop over a Dictionary(Key, Value)... why cant I add a new key-value pair in the loop?</p> <pre><code>Dictionary&lt;string, string&gt; persons = new Dictionary&lt;string, string&gt;(); persons.Add("roger", "12"); persons.Add("mary", "13"); foreach (KeyValuePair&lt;string,string&gt; person in persons) { Console.WriteLine("Name: " + person.Key + ", Age: " + person.Value); persons.Add("Xico", "22"); } </code></pre>
[ { "answer_id": 421192, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "Dictionary<string, string> persons = new Dictionary<string, string>();\npersons.Add(\"roger\", \"12\");\npersons.Add(\"mary\",...
2009/01/07
[ "https://Stackoverflow.com/questions/421155", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50069/" ]
421,170
<p>I need to run a custom action during uninstallation of a ManagedCode which is a part of the installation (Before it is removed in the uninstall process) Is it possible in Install Shield 2009?</p>
[ { "answer_id": 422106, "author": "LanceSc", "author_id": 10012, "author_profile": "https://Stackoverflow.com/users/10012", "pm_score": 2, "selected": false, "text": "REMOVE=\"ALL\"" } ]
2009/01/07
[ "https://Stackoverflow.com/questions/421170", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
421,174
<p>I'm using Jeff Atwood's <a href="http://www.codinghorror.com/blog/archives/000656.html" rel="nofollow noreferrer">Last Configuration Section Handler You'll Ever Need</a>, but it only seems to work for the default app.config file. If I wanted to separate certain settings into another file, the deserializing doesn't work, since ConfigurationManager.GetSection only reads from the application's default app.config file. Is it possible to either change path of the default config file or point ConfigurationManager to a second config file?</p>
[ { "answer_id": 421216, "author": "Charles Bretana", "author_id": 32632, "author_profile": "https://Stackoverflow.com/users/32632", "pm_score": 4, "selected": true, "text": " <configSections>\n <section name=\"Connections\"\n type=\"BPA.AMP.Configuration.XmlConfigurator, BPA...
2009/01/07
[ "https://Stackoverflow.com/questions/421174", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52513/" ]
421,199
<p>I have a DataTable which is bound to a GridView. I also have a button that when clicked exports the DataTable to an Excel file. However, the following error is occuring:</p> <p>ErrMsg = "Thread was being aborted."</p> <p>Here is part of the code where the error is being thrown:</p> <pre><code>private static void Export_with_XSLT_Web(DataSet dsExport, string[] sHeaders, string[] sFileds, ExportFormat FormatType, string FileName) { try { // Appending Headers HttpContext.Current.Response.Clear(); HttpContext.Current.Response.Buffer = true; if(FormatType == ExportFormat.CSV) { HttpContext.Current.Response.ContentType = "text/csv"; HttpContext.Current.Response.AppendHeader("content-disposition", "attachment; filename=" + FileName); } else { HttpContext.Current.Response.ContentType = "application/vnd.ms-excel"; HttpContext.Current.Response.AppendHeader("content-disposition", "attachment; filename=" + FileName); } // XSLT to use for transforming this dataset. MemoryStream stream = new MemoryStream(); XmlTextWriter writer = new XmlTextWriter(stream, Encoding.UTF8); CreateStylesheet(writer, sHeaders, sFileds, FormatType); writer.Flush(); stream.Seek(0, SeekOrigin.Begin); XmlDataDocument xmlDoc = new XmlDataDocument(dsExport); //dsExport.WriteXml("Data.xml"); XslTransform xslTran = new XslTransform(); xslTran.Load(new XmlTextReader(stream), null, null); using(StringWriter sw = new StringWriter()) { xslTran.Transform(xmlDoc, null, sw, null); //Writeout the Content HttpContext.Current.Response.Write(sw.ToString()); writer.Close(); stream.Close(); HttpContext.Current.Response.End(); } } catch(ThreadAbortException Ex) { string ErrMsg = Ex.Message; } catch(Exception Ex) { throw Ex; } finally { } } </code></pre> <p>After changing HttpContext.Current.Response.End to HttpContext.Current.ApplicationInstance.CompleteRequest, it now just goes to the finally block and I can't figure out what error message is being thrown.</p>
[ { "answer_id": 421207, "author": "Darin Dimitrov", "author_id": 29407, "author_profile": "https://Stackoverflow.com/users/29407", "pm_score": 4, "selected": true, "text": "HttpContext.Current.Response.End();\n" }, { "answer_id": 3340229, "author": "Paul Edward", "author_i...
2009/01/07
[ "https://Stackoverflow.com/questions/421199", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33690/" ]
421,205
<p>What are the aspects of style sheets (CSS) that can lead to poor performance of web sites? Anything that can really choke up the CPU?</p> <p>thanks in advance.</p> <p>Sesh</p>
[ { "answer_id": 421224, "author": "annakata", "author_id": 13018, "author_profile": "https://Stackoverflow.com/users/13018", "pm_score": 4, "selected": true, "text": "* inherit div div" }, { "answer_id": 421256, "author": "Henrik Paul", "author_id": 2238, "author_profi...
2009/01/07
[ "https://Stackoverflow.com/questions/421205", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38212/" ]
421,206
<p>I have a Python script that calls an executable program with various arguments (in this example, it is 'sqlpubwiz.exe' which is the "Microsoft SQL Server Database Publishing Wizard"):</p> <pre><code>import os sqlpubwiz = r'"C:\Program Files\Microsoft SQL Server\90\Tools\Publishing\sqlpubwiz.exe"' server = 'myLocalServer' database = 'myLocalDatabase' connection_values = ['server=' + server, 'database=' + database, 'trusted_connection=true'] connection_string = ';'.join(connection_values) dbms_version = '2000' sqlscript_filename = 'CreateSchema.sql' args = [ sqlpubwiz, 'script', '-C ' + connection_string, sqlscript_filename, '-schemaonly', '-targetserver ' + dbms_version, '-f', ] cmd = ' '.join(args) os.system(cmd) </code></pre> <p>This code runs properly but I have would like to get into the habit of using <a href="http://docs.python.org/library/subprocess" rel="nofollow noreferrer">subprocess</a> since it is intended to replace os.system. However, after a few failed attempts, I can not seem to get it work properly. </p> <p>How would the above code look like if it was converted to use subprocess in place of os.system?</p>
[ { "answer_id": 421228, "author": "Carlos Rendon", "author_id": 43851, "author_profile": "https://Stackoverflow.com/users/43851", "pm_score": 4, "selected": true, "text": "import subprocess\np=subprocess.Popen(args, stdout=subprocess.PIPE)\nprint p.communicate()[0]\n" }, { "answer...
2009/01/07
[ "https://Stackoverflow.com/questions/421206", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4872/" ]
421,225
<p>I'm try to install the SQLite gem on a Fedora 9 Linux box with Ruby 1.8.6, Rails 2.2.2, gem 1.3, and sqlite-3.5.9. Here's the command I'm running and its results:</p> <pre><code>sudo gem install sqlite3-ruby Building native extensions. This could take a while... ERROR: Error installing sqlite3-ruby: ERROR: Failed to build gem native extension. /usr/bin/ruby extconf.rb install sqlite3-ruby can't find header files for ruby. Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.4 for inspection. Results logged to /usr/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.4/ext/sqlite3_api/gem_make.out </code></pre> <p><code>gem_make.out</code> just repeats what was already sent to the console. How can I install this gem?</p>
[ { "answer_id": 421341, "author": "Jörg W Mittag", "author_id": 2988, "author_profile": "https://Stackoverflow.com/users/2988", "pm_score": 8, "selected": true, "text": "<whatever>-dev ruby-dev libsqlite3-dev sqlite-devel libsqlite3-ruby" }, { "answer_id": 4477673, "author": "...
2009/01/07
[ "https://Stackoverflow.com/questions/421225", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27515/" ]
421,227
<p>In the process of fixing a poorly imported database with issues caused by using the wrong database encoding, or something like that.</p> <p>Anyways, coming back to my question, in order to fix this issues I'm using a query of this form:</p> <blockquote> <p>UPDATE <code>table_name</code> SET field_name = replace(field_name,’search_text’,'replace_text’);</p> </blockquote> <p>And thus, if the table I'm working on has multiple columns I have to call this query for each of the columns. And also, as there is not only one pair of things to run the find and replace on I have to call the query for each of this pairs as well.</p> <p>So as you can imagine, I end up running tens of queries just to fix one table.</p> <p>What I was wondering is if there is a way of either combine multiple find and replaces in one query, like, lets say, look for this set of things, and if found, replace with the corresponding pair from this other set of things.</p> <p>Or if there would be a way to make a query of the form I've shown above, to run somehow recursively, for each column of a table, regardless of their name or number.</p> <p>Thank you in advance for your support, titel</p>
[ { "answer_id": 421272, "author": "j_random_hacker", "author_id": 47984, "author_profile": "https://Stackoverflow.com/users/47984", "pm_score": 1, "selected": false, "text": "UPDATE replace() UPDATE table_name SET field_name =\n replace(\n replace(\n replace(\n ...
2009/01/07
[ "https://Stackoverflow.com/questions/421227", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43923/" ]
421,231
<p>I am using <a href="http://docs.jquery.com/UI/Resizable/resizable#options" rel="nofollow noreferrer"><code>jQuery-ui Resizable</code></a> - and i want to use a knob instead of the borders (my knob is a button in the bottom right). </p> <p>I see that in options I have a <code>KnobHandles</code>, that I have to set to <code>true</code>. </p> <p>Where do I set my handle? I tried to set it in the handles option but it is not working. </p> <p>Below is my code:</p> <pre><code>window.resizable({ 'handles':'handler-resize', 'knobHandles': true }); </code></pre> <p>UPDATE: just noticed that the knobhandles is some default stuff. I want to resize it with a customized button, is there a way?</p>
[ { "answer_id": 421272, "author": "j_random_hacker", "author_id": 47984, "author_profile": "https://Stackoverflow.com/users/47984", "pm_score": 1, "selected": false, "text": "UPDATE replace() UPDATE table_name SET field_name =\n replace(\n replace(\n replace(\n ...
2009/01/07
[ "https://Stackoverflow.com/questions/421231", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52016/" ]
421,232
<p>I have three arrays.</p> <ul> <li>@array1 containing filenames</li> <li>@array2 containing filenames</li> <li>@unique which I want to contain the unique items </li> </ul> <p>I use the following code to compare the two arrays and output a third array that contains the unique filenames.</p> <pre><code>@test{@array1} = (); @unqiue = grep {!exists $test{$_}} @array2; </code></pre> <p>However the output is case sensitive, how do I change it to be case insensitive?</p> <p>Thanks</p> <hr> <p>Hi, Sorry I think I didnt ask my question very well!</p> <p>I keep an old track array containing tracks I've already played and I then have a new track array I want to select from. I want to compare the new tracks against the old track array to ensure that I only get tracks that are unique to then choose from. </p> <p>So currently the output is;</p> <pre> Unique Tracks: \my Music\Corrupt Souls\b-corrupt.mp3 \My Music\gta4\10 - Vagabond.mp3 \My Music\gta4\14 - War Is Necessary.mp3 \My Music\Back To Black\05 Back to Black.mp3 </pre> <p>What I need is for the result to just return track 10, 14, and 05 as the first track, b-corrupt, is already in the old track array only the case is different.</p> <p>Thanks in advance for your help</p> <pre> #!/usr/bin/perl $element = '\\My Music\\Corrupt Souls\\b-corrupt.mp3'; push (@oldtrackarray, $element); $element = '\\My Music\\Back To Black\\03 Me and Mr Jones.mp3'; push (@oldtrackarray, $element); $element = '\\My Music\\Jazz\\Classic Jazz-Funk Vol1\\11 - Till You Take My Love [Original 12 Mix].mp3'; push (@oldtrackarray, $element); $element = '\\My Music\\gta4\\01 - Soviet Connection (The Theme From Grand Theft Auto IV).mp3'; push (@oldtrackarray, $element); $element = '\\My Music\\gta4\\07 - Rocky Mountain Way.mp3'; push (@oldtrackarray, $element); $element = '\\My Music\\gta4\\02 - Dirty New Yorker.mp3'; push (@oldtrackarray, $element); print "Old Track Array\n"; for($index=0; $index&lt;@oldtrackarray+1; $index++) { print "$oldtrackarray[$index]\n";} $element = '\\my Music\\Corrupt Souls\\b-corrupt.mp3'; push (@newtrackarray, $element); $element = '\\My Music\\gta4\\10 - Vagabond.mp3'; push (@newtrackarray, $element); $element = '\\My Music\\gta4\\14 - War Is Necessary.mp3'; push (@newtrackarray, $element); $element = '\\My Music\\Back To Black\\05 Back to Black.mp3'; push (@newtrackarray, $element); print "New Tracks\n"; for($index=0; $index&lt;@newtrackarray+1; $index++) { print "$newtrackarray[$index]\n"; } @test{@oldtrackarray} = (); @uninvited = grep {!exists $test{$_}} @newtrackarray; print "Unique Tracks:\n"; for($index=0; $index&lt;$#uninvited+1; $index++) { print "$uninvited[$index]\n"; } </pre>
[ { "answer_id": 421244, "author": "j_random_hacker", "author_id": 47984, "author_profile": "https://Stackoverflow.com/users/47984", "pm_score": 3, "selected": false, "text": "@test{ map { lc } @array1 } = ();\n@new_ones = grep { !exists $test{lc $_} } @array2;\n @new_ones @array1 push @ar...
2009/01/07
[ "https://Stackoverflow.com/questions/421232", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
421,247
<p>I have a flowpanel that I'm dynamically adding usercontrols to. I want it to keep adding them and use a vertical scroll bar. It instead wraps them to the top and places a horizontal scroll bar. I'm sure I'm just missing something, but how do I get it to do vertical scrolling?</p>
[ { "answer_id": 23769405, "author": "user2844126", "author_id": 2844126, "author_profile": "https://Stackoverflow.com/users/2844126", "pm_score": 1, "selected": false, "text": "flowLayoutPanel1.AutoScroll = true;" } ]
2009/01/07
[ "https://Stackoverflow.com/questions/421247", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12969/" ]
421,251
<p>I have to login into a https web page and download a file using Java. I know all the URLs beforehand:</p> <pre><code>baseURL = // a https URL; urlMap = new HashMap&lt;String, URL&gt;(); urlMap.put("login", new URL(baseURL, "exec.asp?login=username&amp;pass=XPTO")); urlMap.put("logout", new URL(baseURL, "exec.asp?exec.asp?page=999")); urlMap.put("file", new URL(baseURL, "exec.asp?file=111")); </code></pre> <p>If I try all these links in a web browser like firefox, they work.</p> <p>Now when I do:</p> <pre><code>urlConnection = urlMap.get("login").openConnection(); urlConnection.connect(); BufferedReader in = new BufferedReader( new InputStreamReader(urlConnection.getInputStream())); String inputLine; while ((inputLine = in.readLine()) != null) System.out.println(inputLine); in.close(); </code></pre> <p>I just get back the login page HTML again, and I cannot proceed to file download.</p> <p>Thanks!</p>
[ { "answer_id": 422038, "author": "McDowell", "author_id": 304, "author_profile": "https://Stackoverflow.com/users/304", "pm_score": 2, "selected": false, "text": "class MyCookieHandler extends CookieHandler {\n\n private Map<String, List<String>> cookies = new HashMap<String, List<Str...
2009/01/07
[ "https://Stackoverflow.com/questions/421251", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46726/" ]
421,258
<p>One of the most challenging thing I have felt while working on (complex) web application is the organizing the CSS.Here are the different approaches we have tried on multiple projects.</p> <p><strong>1: Have a different stylesheet for every web page/module.</strong></p> <p>Obviously we were very new to web apps then, and this approach resulted in too many style sheets and too much repetition of styles. We had a tough time to achieve consistency across the application.</p> <p><strong>2: Have a common style sheets which is shared across the similar web pages.</strong></p> <p>This worked well for sometime until it became too complex. Also we found that we had too many exceptions which still resulted in tweaking common styles for particular cases, which if done incorrectly can affect different parts of the application and at some point it becomes difficult. Also having a large development team (across different time zones) and tough project timeline didn't helped our cause.</p> <p>Although #2 works, but still we have seen our products still doesn't have the similar UI quality and consistency as we would like to.</p> <p>Are there any CSS style guidelines that one should refer for very complex web 2.0 application. How do other people maintain their stylesheets?</p>
[ { "answer_id": 421342, "author": "allesklar", "author_id": 19893, "author_profile": "https://Stackoverflow.com/users/19893", "pm_score": 1, "selected": false, "text": "/* \nThis is the CSS index page. It contains no CSS code but calls the other sheets\n*/\n@import url(\"main/reset.css\")...
2009/01/07
[ "https://Stackoverflow.com/questions/421258", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38997/" ]
421,275
<p>While developing a new query at work I wrote it and profiled it in SQL Query Analyzer. The query was performing really good without any table scans but when I encapsulated it within a stored procedure the performance was horrible. When I looked at the execution plan I could see that SQL Server picked a different plan that used a table scan instead of an index seek on TableB (I've been forced to obfuscate the table and column names a bit but none of the query logic has changed).</p> <p>Here's the query</p> <pre><code>SELECT DATEADD(dd, 0, DATEDIFF(dd, 0, TableA.Created)) AS Day, DATEPART(hh, TableA.Created) AS [Hour], SUM(TableB.Quantity) AS Quantity, SUM(TableB.Amount) AS Amount FROM TableA INNER JOIN TableB ON TableA.BID = TableB.ID WHERE (TableA.ShopId = @ShopId) GROUP BY DATEADD(dd, 0, DATEDIFF(dd, 0, TableA.Created)), DATEPART(hh, TableA.Created) ORDER BY DATEPART(hh, TableA.Created) </code></pre> <p>When I run the query "raw" I get the following trace stats</p> <pre> Event Class Duration CPU Reads Writes SQL:StmtCompleted 75 41 7 0 </pre> <p>And when I run the query as a stored proc using the following command</p> <pre><code>DECLARE @ShopId int SELECT @ShopId = 1 EXEC spStats_GetSalesStatsByHour @ShopId </code></pre> <p>I get the following trace stats</p> <pre> Event Class Duration CPU Reads Writes SQL:StmtCompleted 222 10 48 0 </pre> <p>I also get the same result if I store the query in an nvarchar and execute it using sp_executesql like this (it performs like the sproc)</p> <pre><code>DECLARE @SQL nvarchar(2000) SET @SQL = 'SELECT DATEADD(dd, ...' exec sp_executesql @SQL </code></pre> <p>The stored procedure does not contain anything except for the select statement above. What would cause sql server to pick an inferior execution plan just because the statement is executed as a stored procedure?</p> <p>We're currently running on <strong>SQL Server 2000</strong></p>
[ { "answer_id": 421288, "author": "Eric Z Beard", "author_id": 1219, "author_profile": "https://Stackoverflow.com/users/1219", "pm_score": 5, "selected": true, "text": "alter procedure p_myproc (@p1 int) as\ndeclare @p1_copy int;\nset @p1_copy = @p1;\n" } ]
2009/01/07
[ "https://Stackoverflow.com/questions/421275", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2114/" ]
421,280
<p>I need to find the caller of a method. Is it possible using stacktrace or reflection?</p>
[ { "answer_id": 421338, "author": "Adam Paynter", "author_id": 41619, "author_profile": "https://Stackoverflow.com/users/41619", "pm_score": 10, "selected": true, "text": "StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace()\n StackTraceElement getClassName() ge...
2009/01/07
[ "https://Stackoverflow.com/questions/421280", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51402/" ]
421,282
<p>I compiled 2 different binaries on the same GNU/Linux server using g++ version 4.2.3.</p> <p>The first one uses:</p> <pre><code>GLIBC_2.0 GLIBC_2.2 GLIBC_2.1 GLIBCXX_3.4 GLIBC_2.1.3 </code></pre> <p>The second one uses:</p> <pre><code>GLIBC_2.0 GLIBC_2.2 GLIBC_2.1 GLIBCXX_3.4.9 GLIBCXX_3.4 GLIBC_2.1.3 </code></pre> <p>Why the second binary uses GLIBCXX_3.4.9 that is only available on libstdc++.so.6.0.9 and <em>not</em> in libstdc++.so.6.0.8</p> <p>What is the new feature generated by g++ that require an ABI break and force the system to have GLIBCXX_3.4.9?</p> <p>Is there a way to disable this new feature to not require GLIBCXX_3.4.9?</p>
[ { "answer_id": 421435, "author": "Martin York", "author_id": 14065, "author_profile": "https://Stackoverflow.com/users/14065", "pm_score": 0, "selected": false, "text": "lib<X>.so.<ver> => /usr/lib/lib<X>.so.<verM> (<Addr>)\n > ls /usr/lilb/lib<X>.so.<verM>\nlrwxrwxrwx 1 root root ...
2009/01/07
[ "https://Stackoverflow.com/questions/421282", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6605/" ]
421,283
<p>I need to crawl and store locally for future analysis the contents of a finite list of websites. I basically want to slurp in all pages and follow all internal links to get the entire publicly available site.</p> <p>Are there existing free libraries to get me there? I've seen Chilkat, but it's for pay. I'm just looking for baseline functionality here. Thoughts? Suggestions?</p> <hr> <p>Exact Duplicate: <a href="https://stackoverflow.com/questions/419235/anyone-know-of-a-good-python-based-web-crawler-that-i-could-use">Anyone know of a good python based web crawler that I could use?</a></p>
[ { "answer_id": 421335, "author": "nosklo", "author_id": 17160, "author_profile": "https://Stackoverflow.com/users/17160", "pm_score": 4, "selected": true, "text": "class Torrent(ScrapedItem):\n pass\n\nclass MininovaSpider(CrawlSpider):\n domain_name = 'mininova.org'\n start_url...
2009/01/07
[ "https://Stackoverflow.com/questions/421283", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52522/" ]
421,326
<p>Sorry I couldn't be more descriptive with the title, I will elaborate fully below:</p> <p>I have a web application that I want to implement some AJAX functionality into. Currently, it is running ASP.NET 3.5 with VB.NET codebehind. My current "problem" is I want to dynamically be able to populate a DIV when a user clicks an item on a list. The list item currently contains a <code>HttpUtility.UrlEncode()</code> (ASP.NET) string of the content that should appear in the DIV. </p> <p>Example: </p> <pre><code> &lt;li onclick="setFAQ('The+maximum+number+of+digits+a+patient+account+number+can+contain+is+ten+(10).');"&gt; What is the maximum number of digits a patient account number can contain?&lt;/li&gt; </code></pre> <p>I can decode the string partially with the JavaScript function <code>unescape()</code> but it does not fully decode the string. I would much rather pass the JavaScript function the faq ID then somehow pull the information from the database where it originates.</p> <p>I am 99% sure it is impossible to call an ASP function from within a JavaScript function, so I am kind of stumped. I am kind of new to AJAX/ASP.NET so this is a learning experience for me. </p>
[ { "answer_id": 421377, "author": "Shawn", "author_id": 26, "author_profile": "https://Stackoverflow.com/users/26", "pm_score": 0, "selected": false, "text": "HttpUtility.HtmlEncode" }, { "answer_id": 428773, "author": "Crescent Fresh", "author_id": 45433, "author_prof...
2009/01/07
[ "https://Stackoverflow.com/questions/421326", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25515/" ]
421,329
<p>I have a DB table with the following structure: </p> <pre><code>Id int (identity) Company string Cluster string BU string Department string SalesPoint string </code></pre> <p><strong>The following LINQ query:</strong><br /></p> <pre><code>var chEntities = from a in dataContext.CompanyHierarchies let parent = (dataContext.CompanyHierarchies.Where(ch =&gt; ch.Id == companyHierarchyId).Single()) where ( (a.Company == (parent.Company == null ? a.Company : parent.Company)) &amp;&amp; (a.Cluster == (parent.Cluster == null ? a.Cluster : parent.Cluster)) &amp;&amp; (a.Company == (parent.BU == null ? a.BU : parent.BU)) &amp;&amp; (a.Company == (parent.Department == null ? a.Department : parent.Department)) &amp;&amp; (a.Company == (parent.SalesPoint == null ? a.SalesPoint : parent.SalesPoint)) ) select new CompanyHierarchyEntity { Id = a.Id, Name = a.SalesPoint == null ? (a.BU == null ? (a.Cluster == null ? (a.Company) : a.Cluster) : a.BU) : a.SalesPoint, CompanyHierarchyLevel = (CompanyHierarchyLevel)a.HierarchyLevel, Company = a.Company, Cluster = a.Cluster, BU = a.BU, Department = a.Department, Section = a.SalesPoint }; </code></pre> <p><strong>Generates the following SQL</strong></p> <pre><code>{SELECT (CASE WHEN [t0].[SalesPoint] IS NULL THEN (CASE WHEN [t0].[BU] IS NULL THEN (CASE WHEN [t0].[Cluster] IS NULL THEN [t0].[Company] ELSE [t0].[Cluster] END) ELSE [t0].[BU] END) ELSE [t0].[SalesPoint] END) AS [Name], [t0].[Id], [t0].[HierarchyLevel] AS [CompanyHierarchyLevel], [t0].[Company], [t0].[Cluster], [t0].[BU], [t0].[Department], [t0].[SalesPoint] AS [Section] </code></pre> <p><strong>The query is wrong after this. <code>Company</code> should be <code>Company</code>, <code>Cluster</code>, <code>BU</code>, etc. but it is <code>Company</code> in all cases.</strong></p> <pre><code>FROM [dbo].[CompanyHierarchy] AS [t0] WHERE ([t0].[Company] = ( (CASE WHEN (( SELECT [t1].[Company] FROM [dbo].[CompanyHierarchy] AS [t1] WHERE [t1].[Id] = @p0 )) IS NULL THEN [t0].[Company] ELSE ( SELECT [t2].[Company] FROM [dbo].[CompanyHierarchy] AS [t2] WHERE [t2].[Id] = @p0 ) END))) AND ([t0].[Cluster] = ( (CASE WHEN (( SELECT [t3].[Cluster] FROM [dbo].[CompanyHierarchy] AS [t3] WHERE [t3].[Id] = @p0 )) IS NULL THEN [t0].[Cluster] ELSE ( SELECT [t4].[Cluster] FROM [dbo].[CompanyHierarchy] AS [t4] WHERE [t4].[Id] = @p0 ) END))) AND ([t0].[Company] = ( (CASE WHEN (( SELECT [t5].[BU] FROM [dbo].[CompanyHierarchy] AS [t5] WHERE [t5].[Id] = @p0 )) IS NULL THEN [t0].[BU] ELSE ( SELECT [t6].[BU] FROM [dbo].[CompanyHierarchy] AS [t6] WHERE [t6].[Id] = @p0 ) END))) AND ([t0].[Company] = ( (CASE WHEN (( SELECT [t7].[Department] FROM [dbo].[CompanyHierarchy] AS [t7] WHERE [t7].[Id] = @p0 )) IS NULL THEN [t0].[Department] ELSE ( SELECT [t8].[Department] FROM [dbo].[CompanyHierarchy] AS [t8] WHERE [t8].[Id] = @p0 ) END))) AND ([t0].[Company] = ( (CASE WHEN (( SELECT [t9].[SalesPoint] FROM [dbo].[CompanyHierarchy] AS [t9] WHERE [t9].[Id] = @p0 )) IS NULL THEN [t0].[SalesPoint] ELSE ( SELECT [t10].[SalesPoint] FROM [dbo].[CompanyHierarchy] AS [t10] WHERE [t10].[Id] = @p0 ) END))) </code></pre> <p>}</p> <p>Has anyone else faced a similar issue?</p>
[ { "answer_id": 421366, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 2, "selected": false, "text": "(a.Company == (parent.BU == null ? a.BU : parent.BU)) &&\n(a.Company == (parent.Department == null ? a.Department : par...
2009/01/07
[ "https://Stackoverflow.com/questions/421329", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21586/" ]
421,337
<p>I'm wondering if there is any way to set a JPanel's background to an image instead of just a colour. Thanks and I'm working on dr. java</p>
[ { "answer_id": 423589, "author": "Lawrence Dol", "author_id": 8946, "author_profile": "https://Stackoverflow.com/users/8946", "pm_score": 0, "selected": false, "text": "public void setImage(Image img, int vs, int hs) {\n mmImage=img;\n mmVrtShift=vs;\n mmHrzShift=hs;\n mmSize...
2009/01/07
[ "https://Stackoverflow.com/questions/421337", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
421,339
<p>I have a List, it has Foo objects, and each Foo has a start date, and an end date. I want to insert a new Foo object, which has its own start and end date.</p> <p>I want the elements in the list to update their start and end dates accordingly, when the new Foo object is inserted, and for the new Foo object to find its correct place in the List. I'll wait and see if this is enough info for someone to understand my problem, and see if I need to explain further.</p>
[ { "answer_id": 421642, "author": "rtperson", "author_id": 16787, "author_profile": "https://Stackoverflow.com/users/16787", "pm_score": 2, "selected": true, "text": " 1) The new interval fits into an existing interval -- do nothing\n 2) The new interval begins and ends before the fir...
2009/01/07
[ "https://Stackoverflow.com/questions/421339", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13143/" ]
421,357
<p>I have a set of files. The set of files is read-only off a NTFS share, thus can have many readers. Each file is updated occasionally by one writer that has write access.</p> <p>How do I ensure that:</p> <ol> <li>If the write fails, that the previous file is still readable</li> <li>Readers cannot hold up the single writer</li> </ol> <p>I am using Java and my current solution is for the writer to write to a temporary file, then swap it out with the existing file using <code>File.renameTo()</code>. The problem is on NTFS, <code>renameTo</code> fails if target file already exists, so you have to delete it yourself. But if the writer deletes the target file and then fails (computer crash), I don't have a readable file.</p> <p><strike>nio's FileLock only work with the same JVM, so it useless to me.</strike></p> <p>How do I safely update a file with many readers using Java?</p>
[ { "answer_id": 421401, "author": "Adam Paynter", "author_id": 41619, "author_profile": "https://Stackoverflow.com/users/41619", "pm_score": -1, "selected": false, "text": "FileLock fileLock = filechannel.lock(position, size, shared);\nreentrantReadWriteLock.lock();\n\n// do stuff\n\nfile...
2009/01/07
[ "https://Stackoverflow.com/questions/421357", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21838/" ]
421,378
<p>Let's say I have a page called <code>display.php</code> and the user is viewing <code>display.php?page=3</code>. I want to allow the user to do an action like voting via a POST request and then bring them back to the page they were on. So, If I do a POST request to <code>display.php?page=3</code> would the page information also be available to the script?</p>
[ { "answer_id": 421439, "author": "allclaws", "author_id": 23977, "author_profile": "https://Stackoverflow.com/users/23977", "pm_score": 1, "selected": false, "text": "$_GET['page'] (for GET requests)\n$_POST['page'] (for POST requests)\n$_REQUEST['page'] (for either)\n <?php\n//vote.php\...
2009/01/07
[ "https://Stackoverflow.com/questions/421378", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25680/" ]
421,381
<p>I've built a form with Netbeans's visual editor. When I press one of the buttons it should do the following :</p> <ul> <li>set it to disabled</li> <li>perform a task that takes some time</li> <li>when the task finishes the button will be enabled again</li> </ul> <p>However, the following happens:</p> <ul> <li>the button remains in a pressed state until the task finishes</li> <li>when the task finishes, the enabling/disabling of buttons will be very fast (they will happen, but you won't notice them)</li> </ul> <p>This behaviour is not something I want. I tried using repaint on the JButton, on the JFrame and even on the JPanel containing the button, but I can't seem to get it to do what I want. Some hints?</p>
[ { "answer_id": 421416, "author": "Allain Lalonde", "author_id": 2443, "author_profile": "https://Stackoverflow.com/users/2443", "pm_score": 5, "selected": true, "text": "SwingUtilities.invokeLater() invokeLater button.setEnabled(false);\nnew Thread(new Runnable() {\n public void run() {\...
2009/01/07
[ "https://Stackoverflow.com/questions/421381", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31610/" ]
421,382
<p>I'm developing an Access 2003 Database that uses a MS SQLServer backend.</p> <p>I'm trying to do Form Validation and am experiencing some problems.</p> <ol> <li>ValidationRule for each field seems to be ignored</li> <li>I can't figure out what event I should override to enforce validation without having the database do it. (I'm not against this, it's just unknown to me how I'd catch Error Messages, instead of displaying them to the user)</li> </ol> <p>I've tried getting around number 2 by disallowing closing and enforcing the use of a "Close Button", but the user can side step it by pressing tab, or by pressing the "Next Record" button at the bottom.</p> <p>Any suggestions would be greatly appreciated.</p>
[ { "answer_id": 421416, "author": "Allain Lalonde", "author_id": 2443, "author_profile": "https://Stackoverflow.com/users/2443", "pm_score": 5, "selected": true, "text": "SwingUtilities.invokeLater() invokeLater button.setEnabled(false);\nnew Thread(new Runnable() {\n public void run() {\...
2009/01/07
[ "https://Stackoverflow.com/questions/421382", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2443/" ]
421,389
<p>I created a custom autocomplete control, when the user press a key it queries the database server (using Remoting) on another thread. When the user types very fast, the program must cancel the previously executing request/thread. </p> <p>I previously implemented it as AsyncCallback first, but i find it cumbersome, too many house rules to follow (e.g. AsyncResult, AsyncState, EndInvoke) plus you have to detect the thread of the BeginInvoke'd object, so you can terminate the previously executing thread. Besides if I continued the AsyncCallback, there's no method on those AsyncCallbacks that can properly terminate previously executing thread. </p> <p>EndInvoke cannot terminate the thread, it would still complete the operation of the to be terminated thread. I would still end up using Abort() on thread.</p> <p>So i decided to just implement it with pure Thread approach, sans the AsyncCallback. Is this thread.abort() normal and safe to you?</p> <pre><code>public delegate DataSet LookupValuesDelegate(LookupTextEventArgs e); internal delegate void PassDataSet(DataSet ds); public class AutoCompleteBox : UserControl { Thread _yarn = null; [System.ComponentModel.Category("Data")] public LookupValuesDelegate LookupValuesDelegate { set; get; } void DataSetCallback(DataSet ds) { if (this.InvokeRequired) this.Invoke(new PassDataSet(DataSetCallback), ds); else { // implements the appending of text on textbox here } } private void txt_TextChanged(object sender, EventArgs e) { if (_yarn != null) _yarn.Abort(); _yarn = new Thread( new Mate { LookupValuesDelegate = this.LookupValuesDelegate, LookupTextEventArgs = new LookupTextEventArgs { RowOffset = offset, Filter = txt.Text }, PassDataSet = this.DataSetCallback }.DoWork); _yarn.Start(); } } internal class Mate { internal LookupTextEventArgs LookupTextEventArgs = null; internal LookupValuesDelegate LookupValuesDelegate = null; internal PassDataSet PassDataSet = null; object o = new object(); internal void DoWork() { lock (o) { // the actual code that queries the database var ds = LookupValuesDelegate(LookupTextEventArgs); PassDataSet(ds); } } } </code></pre> <h3>NOTES</h3> <p>The reason for cancelling the previous thread when the user type keys in succession, is not only to prevent the appending of text from happening, but also to cancel the previous network roundtrip, so the program won't be consuming too much memory resulting from successive network operation.</p> <p>I'm worried if I avoid thread.Abort() altogether, the program could consume too much memory.</p> <p>here's the code without the thread.Abort(), using a counter:</p> <pre><code>internal delegate void PassDataSet(DataSet ds, int keyIndex); public class AutoCompleteBox : UserControl { [System.ComponentModel.Category("Data")] public LookupValuesDelegate LookupValuesDelegate { set; get; } static int _currentKeyIndex = 0; void DataSetCallback(DataSet ds, int keyIndex) { if (this.InvokeRequired) this.Invoke(new PassDataSet(DataSetCallback), ds, keyIndex); else { // ignore the returned DataSet if (keyIndex &lt; _currentKeyIndex) return; // implements the appending of text on textbox here... } } private void txt_TextChanged(object sender, EventArgs e) { Interlocked.Increment(ref _currentKeyIndex); var yarn = new Thread( new Mate { KeyIndex = _currentKeyIndex, LookupValuesDelegate = this.LookupValuesDelegate, LookupTextEventArgs = new LookupTextEventArgs { RowOffset = offset, Filter = txt.Text }, PassDataSet = this.DataSetCallback }.DoWork); yarn.Start(); } } internal class Mate { internal int KeyIndex; internal LookupTextEventArgs LookupTextEventArgs = null; internal LookupValuesDelegate LookupValuesDelegate = null; internal PassDataSet PassDataSet = null; object o = new object(); internal void DoWork() { lock (o) { // the actual code that queries the database var ds = LookupValuesDelegate(LookupTextEventArgs); PassDataSet(ds, KeyIndex); } } } </code></pre>
[ { "answer_id": 421436, "author": "Shog9", "author_id": 811, "author_profile": "https://Stackoverflow.com/users/811", "pm_score": 6, "selected": true, "text": "Thread.Abort() reset the timer on every keystroke" }, { "answer_id": 421445, "author": "P Daddy", "author_id": 36...
2009/01/07
[ "https://Stackoverflow.com/questions/421389", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11432/" ]
421,391
<p>Basically like using the out keyword. But the problem is with the out keyword, you still have to declare a variable outside the method call, like:</p> <pre><code>double result; Double.TryParse ( "76", out result ); </code></pre> <p>where as I want something like:</p> <pre><code>Double.TryParse ( "76", out result ); </code></pre> <p>and there I get a new variable called result.</p> <p>Is there a way to do this (by using out or not)?</p>
[ { "answer_id": 421424, "author": "Tamas Czinege", "author_id": 8954, "author_profile": "https://Stackoverflow.com/users/8954", "pm_score": 1, "selected": false, "text": "public void MyMethod(out int MyParam)\n{\n SomeMethod(out MyParam);\n}\n" }, { "answer_id": 421780, "au...
2009/01/07
[ "https://Stackoverflow.com/questions/421391", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51816/" ]
421,419
<p>I find myself needing to generate a checksum for a string of data, for consistency purposes. The broad idea is that the client can regenerate the checksum based on the payload it recieves and thus detect any corruption that took place in transit. I am vaguely aware that there are all kinds of mathematical principles behind this kind of thing, and that it's very easy for subtle errors to make the whole algorithm ineffective if you try to roll it yourself.</p> <p>So I'm looking for advice on a hashing/checksum algorithm with the following criteria:</p> <ul> <li>It will be generated by Javascript, so needs to be relatively light computationally.</li> <li>The validation will be done by Java (though I cannot see this actually being an issue).</li> <li>It will take textual input (URL-encoded Unicode, which I believe is ASCII) of a moderate length; typically around 200-300 characters and in all cases below 2000.</li> <li>The output should be ASCII text as well, and the shorter it can be the better.</li> </ul> <p>I'm primarily interested in something lightweight rather than getting the absolute smallest potential for collisions possible. Would I be naive to imagine that an eight-character hash would be suitable for this? I should also clarify that it's not the end of the world if corruption isn't picked up at the validation stage (and I do realise that this will not be 100% reliable), though the rest of my code is markedly less efficient for every corrupt entry that slips through.</p> <p>Edit - thanks to all that contributed. I went with the Adler32 option and given that it was natively supported in Java, extremely easy to implement in Javascript, fast to calculate at both ends and have an 8-byte output it was exactly right for my requirements.</p> <p>(Note that I realise that the network transport is unlikely to be responsible for any corruption errors and won't be folding my arms on this issue just yet; however adding the checksum validation removes one point of failure and means we can focus on other areas should this reoccur.)</p>
[ { "answer_id": 13413618, "author": "Keith Whittingham", "author_id": 1206873, "author_profile": "https://Stackoverflow.com/users/1206873", "pm_score": 1, "selected": false, "text": "function getCrc(s) {\n var result = 0;\n for(var i = 0; i < s.length; i++) {\n var c = s.char...
2009/01/07
[ "https://Stackoverflow.com/questions/421419", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45664/" ]
421,422
<p>I'm wondering if it's possible to get a handle on running instances of a given class. The particular issue that triggered this was an application that doesn't exit nicely because of a number of running threads. </p> <p>Yes, I know you can daemonize the theads, and they won't then hold up the application exit. But it did get me to wondering if this was possible. The closest thing I can is the classloaders (protected!) <a href="http://java.sun.com/javase/6/docs/api/java/lang/ClassLoader.html#findLoadedClass(java.lang.String)" rel="nofollow noreferrer">findLoadedClass</a>, although you'd have to run through your own classloader to do this. </p> <p>On a related note, is this how profiling tools manage to track object handles? by running through their own custom classloaders? or is there some nice tricky way that I'm not seeing? </p>
[ { "answer_id": 421745, "author": "Bombe", "author_id": 43582, "author_profile": "https://Stackoverflow.com/users/43582", "pm_score": 2, "selected": false, "text": "$ kill -QUIT <pid of java process>\n java.exe javaw.exe" }, { "answer_id": 422083, "author": "Jared", "autho...
2009/01/07
[ "https://Stackoverflow.com/questions/421422", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19479/" ]
421,486
<p>I'm trying to add a class to the selected radio input and then remove that class when another radio of the same type is selected</p> <p>The radio buttons have the class 'radio_button' but i can't get the class to change with the below code.</p> <pre><code> jQuery(".radio_button").livequery('click',function() { $('input.radio_button :radio').focus(updateSelectedStyle); $('input.radio_button :radio').blur(updateSelectedStyle); $('input.radio_button :radio').change(updateSelectedStyle); } function updateSelectedStyle() { $('input.radio_button :radio').removeClass('focused'); $('input.radio_button :radio:checked').addClass('focused'); } </code></pre>
[ { "answer_id": 421743, "author": "Rene Saarsoo", "author_id": 15982, "author_profile": "https://Stackoverflow.com/users/15982", "pm_score": 3, "selected": true, "text": "$('input.radio_button :radio')\n $('input.radio_button:radio')\n" }, { "answer_id": 421906, "author": "Ben...
2009/01/07
[ "https://Stackoverflow.com/questions/421486", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48973/" ]
421,494
<p>Could some one give an idea about how to convert an excel file into a CLOB in oracle through JDBC. I would like to know how to covert excel file into a String using API available as part of JDK and the conversion from string to clob should be straight forward. Thanks in advance. If a similar question was already raised, kindly provide me the link.</p>
[ { "answer_id": 421743, "author": "Rene Saarsoo", "author_id": 15982, "author_profile": "https://Stackoverflow.com/users/15982", "pm_score": 3, "selected": true, "text": "$('input.radio_button :radio')\n $('input.radio_button:radio')\n" }, { "answer_id": 421906, "author": "Ben...
2009/01/07
[ "https://Stackoverflow.com/questions/421494", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52542/" ]
421,501
<p>Some places state 2GB period. Some places state it depends up the number of nodes.</p>
[ { "answer_id": 422259, "author": "archaelus", "author_id": 9040, "author_profile": "https://Stackoverflow.com/users/9040", "pm_score": 7, "selected": true, "text": "disc_only_copies ram_copies disc_copies dets disc_copies local_content local_content 4Gb * <number of nodes> 4Gb * <number ...
2009/01/07
[ "https://Stackoverflow.com/questions/421501", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52543/" ]
421,509
<p>Basically this code below returns the right information, but I need to add the quantities together to bring back one record. Is there any way of doing this?</p> <pre><code>select category.category_name, (equipment.total_stock-equipment.stock_out) AS Current_Stock, equipment.stock_out from EQUIPMENT, CATEGORY WHERE EQUIPMENT.CATEGORY_ID = CATEGORY.CATEGORY_ID and category.category_name = 'Power Tools' </code></pre>
[ { "answer_id": 421522, "author": "Chris Allwein", "author_id": 50255, "author_profile": "https://Stackoverflow.com/users/50255", "pm_score": 4, "selected": true, "text": "select category.category_name, SUM((equipment.total_stock-equipment.stock_out)) AS Current_Stock, SUM(equipment.stock...
2009/01/07
[ "https://Stackoverflow.com/questions/421509", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
421,516
<p>I have a windows service written in C# that acts as a proxy for a bunch of network devices to the back end database. For testing and also to add a simulation layer to test the back end I would like to have a GUI for the test operator to be able run the simulation. Also for a striped down version to send out as a demo. The GUI and service do not have to run at the same time. What is the best way to achieve this duel operation?</p> <p>Edit: Here is my solution combing stuff from <a href="https://stackoverflow.com/questions/421516">this question</a> , <a href="https://stackoverflow.com/questions/200163/am-i-running-as-a-service">Am I Running as a Service</a> and <a href="https://stackoverflow.com/questions/255056/install-a-net-windows-service-without-installutil-exe/255062#255062">Install a .NET windows service without InstallUtil.exe</a> using <a href="http://groups.google.co.uk/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/4d45e9ea5471cba4/4519371a77ed4a74" rel="nofollow noreferrer">this excellent code</a> by <a href="https://stackoverflow.com/users/23354/marc-gravell">Marc Gravell</a></p> <p>It uses the following line to test if to run the gui or run as service.</p> <pre><code> if (arg_gui || Environment.UserInteractive || Debugger.IsAttached) </code></pre> <p>Here is the code.</p> <pre><code> using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; using System.ComponentModel; using System.ServiceProcess; using System.Configuration.Install; using System.Diagnostics; namespace Form_Service { static class Program { /// /// The main entry point for the application. /// [STAThread] static int Main(string[] args) { bool arg_install = false; bool arg_uninstall = false; bool arg_gui = false; bool rethrow = false; try { foreach (string arg in args) { switch (arg) { case "-i": case "-install": arg_install = true; break; case "-u": case "-uninstall": arg_uninstall = true; break; case "-g": case "-gui": arg_gui = true; break; default: Console.Error.WriteLine("Argument not expected: " + arg); break; } } if (arg_uninstall) { Install(true, args); } if (arg_install) { Install(false, args); } if (!(arg_install || arg_uninstall)) { if (arg_gui || Environment.UserInteractive || Debugger.IsAttached) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } else { rethrow = true; // so that windows sees error... ServiceBase[] services = { new Service1() }; ServiceBase.Run(services); rethrow = false; } } return 0; } catch (Exception ex) { if (rethrow) throw; Console.Error.WriteLine(ex.Message); return -1; } } static void Install(bool undo, string[] args) { try { Console.WriteLine(undo ? "uninstalling" : "installing"); using (AssemblyInstaller inst = new AssemblyInstaller(typeof(Program).Assembly, args)) { IDictionary state = new Hashtable(); inst.UseNewContext = true; try { if (undo) { inst.Uninstall(state); } else { inst.Install(state); inst.Commit(state); } } catch { try { inst.Rollback(state); } catch { } throw; } } } catch (Exception ex) { Console.Error.WriteLine(ex.Message); } } } [RunInstaller(true)] public sealed class MyServiceInstallerProcess : ServiceProcessInstaller { public MyServiceInstallerProcess() { this.Account = ServiceAccount.NetworkService; } } [RunInstaller(true)] public sealed class MyServiceInstaller : ServiceInstaller { public MyServiceInstaller() { this.Description = "My Service"; this.DisplayName = "My Service"; this.ServiceName = "My Service"; this.StartType = System.ServiceProcess.ServiceStartMode.Manual; } } } </code></pre>
[ { "answer_id": 421602, "author": "bozag", "author_id": 51842, "author_profile": "https://Stackoverflow.com/users/51842", "pm_score": 5, "selected": true, "text": "static void Main(string[] args)\n{\n Guts guts = new Guts();\n\n if (runWinForms)\n {\n System.Windows.Forms....
2009/01/07
[ "https://Stackoverflow.com/questions/421516", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32958/" ]
421,518
<p>I have to copy tables from an Oracle database to a db2 v7 one, and in order to do this (avoiding millions of drops and creates) I'd like to know if db2 has a feature like Oracle to enable / disable constraints temporarily without dropping them.</p> <p>Thanks in advance, Mauro.</p>
[ { "answer_id": 421590, "author": "Chris Allwein", "author_id": 50255, "author_profile": "https://Stackoverflow.com/users/50255", "pm_score": 1, "selected": false, "text": "set integrity for table_name off\nset integrity for table_name foreign key immediate unchecked\n set integrity for t...
2009/01/07
[ "https://Stackoverflow.com/questions/421518", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52017/" ]
421,530
<p>In C/C++, if a multi-byte wide character (wchar_t) value is transmitted from a big-endian system to a little-endian system (or vice-versa), will it come out the same value on the other side? Or will the bytes need to be swapped?</p>
[ { "answer_id": 421603, "author": "Martin York", "author_id": 14065, "author_profile": "https://Stackoverflow.com/users/14065", "pm_score": 4, "selected": true, "text": "ntohs Convert a 16-bit quantity from network byte order to host byte order\nntohl Convert a 32-bit quantity from ne...
2009/01/07
[ "https://Stackoverflow.com/questions/421530", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17035/" ]
421,553
<p>I have seen some guidance which recommends that you secure a database by layering all data access through stored procedures.</p> <p>I know that for SQL Server, you can secure tables, and even columns against CRUD operations. </p> <p>For example: </p> <pre><code> --// Logged in as 'sa' USE AdventureWorks; GRANT SELECT ON Person.Address(AddressID, AddressLine1) to Matt; GRANT UPDATE ON Person.Address(AddressLine1) to Matt; --// Logged in as 'Matt' SELECT * from Person.Address; --// Fail SELECT AddressID, AddressLine1 from Person.Address; --// Succeed UPDATE Person.Address SET AddressLine1 = '#____ 2700 Production Way' WHERE AddressID = 497; --// Succeed </code></pre> <p>Given that you can secure tables and even columns against CRUD operations, how does using a stored procedure provide additional security, or management of security?</p>
[ { "answer_id": 421594, "author": "Tom H", "author_id": 5696608, "author_profile": "https://Stackoverflow.com/users/5696608", "pm_score": 3, "selected": false, "text": "UPDATE Person.Address SET AddressLine1 = NULL\n" }, { "answer_id": 460878, "author": "Ken Yao", "author_...
2009/01/07
[ "https://Stackoverflow.com/questions/421553", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24970/" ]
421,570
<p>The boss wants the master page's menu to look nicer. I generated my gradient file with one of the tools available on the net, no problem there..</p> <p>I tried to make a CSS class for each menu item but when I use the background-image directive and the style builder, I get a line like:</p> <pre><code>background-image: url('file:///C:/Documents and Settings/Username/My Documents/Visual Studio 2008/WebSites/ThisSite/Images/Gradient.png') </code></pre> <p>...when what I <em>want</em> is</p> <pre><code>background-image: url('~/Images/Gradient.png') </code></pre> <p>The first url will, of course, only work when I'm debugging on my local machine - deploy this and I'm hosed. So many other ASP.NET objects work with "~/" to indicate the top-level directory of the website but my css file doesn't like it and I can't set a background image for the menu control or the menu items - seems like a GLARING omission when I can do it to so many other controls.</p> <p>What am I missing?</p>
[ { "answer_id": 421589, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 2, "selected": false, "text": " background-image: url( \"/images/menu.jpg\" );\n" }, { "answer_id": 421687, "author": "Bryan A", "...
2009/01/07
[ "https://Stackoverflow.com/questions/421570", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15891/" ]
421,573
<p>Suppose I have a <code>std::vector</code> (let's call it <code>myVec</code>) of size <code>N</code>. What's the simplest way to construct a new vector consisting of a copy of elements X through Y, where 0 &lt;= X &lt;= Y &lt;= N-1? For example, <code>myVec [100000]</code> through <code>myVec [100999]</code> in a vector of size <code>150000</code>.</p> <p>If this cannot be done efficiently with a vector, is there another STL datatype that I should use instead?</p>
[ { "answer_id": 421613, "author": "Anteru", "author_id": 39912, "author_profile": "https://Stackoverflow.com/users/39912", "pm_score": 5, "selected": false, "text": "std::vector<T>(input_iterator, input_iterator) foo = std::vector<T>(myVec.begin () + 100000, myVec.begin () + 150000);" }...
2009/01/07
[ "https://Stackoverflow.com/questions/421573", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17035/" ]
421,581
<p>If I have a user control defined:</p> <pre><code>public partial class MainFooter : UserControl { public System.Windows.Media.Color BkColor; } </code></pre> <p>and it's xaml:</p> <pre><code>&lt;UserControl x:Class="Test.MainFooter"&gt; &lt;Grid x:Name="LayoutRoot"&gt; &lt;Rectangle x:Name="rctBottom_Background2" HorizontalAlignment="Stretch" Grid.Row="2"&gt; &lt;Rectangle.Fill&gt; &lt;LinearGradientBrush EndPoint="0.82,0.895" StartPoint="0.911,-0.442"&gt; &lt;GradientStop Color="{**How can I bind this to the BkColor property?}"/**&gt; &lt;GradientStop Color="#00FFFFFF" Offset="1"/&gt; &lt;/LinearGradientBrush&gt; &lt;/Rectangle.Fill&gt; &lt;/Rectangle&gt; &lt;/Grid&gt; &lt;/UserControl&gt; </code></pre> <p>and used:</p> <pre><code>&lt;MyControls:MainFooter x:Name="rcrMainFooter" BkColor="#FFE2B42A"&gt; &lt;/MyControls:MainFooter&gt; </code></pre> <p>How would I go about binding the GradientStop Color in the Rectangle to the value of the it's user controls BkColor property?</p>
[ { "answer_id": 1798288, "author": "thisisjaiswal", "author_id": 208129, "author_profile": "https://Stackoverflow.com/users/208129", "pm_score": 0, "selected": false, "text": "<LinearGradientBrush EndPoint=\"0.82,0.895\" StartPoint=\"0.911,-0.442\"> \n <GradientStop Col...
2009/01/07
[ "https://Stackoverflow.com/questions/421581", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9266/" ]
421,604
<p>what's the best way to remove a row (QTreeWidgetItem) from a QTreeWidget?</p> <p>The QTreeWidget content has been set by:</p> <pre><code>myQTreeWidget-&gt;insertTopLevelItems(0, items); // items = QList&lt;QTreeWidgetItem*&gt; </code></pre> <p>then I remove an item from my QList "items" and I try to clear/reset the QTreeWidget</p> <pre><code>packList-&gt;clear(); packList-&gt;insertTopLevelItems(0, items); </code></pre> <p>but my app crashes here! Suggestions?</p>
[ { "answer_id": 421692, "author": "Soviut", "author_id": 46914, "author_profile": "https://Stackoverflow.com/users/46914", "pm_score": 1, "selected": false, "text": "packList->takeTopLevelItem(index);\n" }, { "answer_id": 421695, "author": "Caleb Huitt - cjhuitt", "author_...
2009/01/07
[ "https://Stackoverflow.com/questions/421604", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39339/" ]
421,616
<p>For the hope-to-have-an-answer-in-30-seconds part of this question, I'm specifically looking for C#</p> <p>But in the general case, what's the best way to strip punctuation in any language?</p> <p><strong>I should add:</strong> Ideally, the solutions won't require you to enumerate all the possible punctuation marks. </p> <p>Related: <a href="https://stackoverflow.com/questions/265960/best-way-to-strip-punctuation-from-a-string-in-python">Strip Punctuation in Python</a></p>
[ { "answer_id": 421633, "author": "Joachim Sauer", "author_id": 40342, "author_profile": "https://Stackoverflow.com/users/40342", "pm_score": 4, "selected": false, "text": "String stripped = input.replaceAll(\"\\\\p{Punct}+\", \"\");\n String stripped = input.replaceAll(\"\\\\p{P}+\", \"\...
2009/01/07
[ "https://Stackoverflow.com/questions/421616", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8435/" ]
421,618
<p>I'm attempting to code a script that outputs each user and their group on their own line like so:</p> <pre><code>user1 group1 user2 group1 user3 group2 ... user10 group6 </code></pre> <p>etc. </p> <p>I'm writing up a script in python for this but was wondering how SO might do this.</p> <p>p.s. Take a whack at it in any language but I'd prefer python.</p> <p>EDIT: I'm working on Linux. Ubuntu 8.10 or CentOS =)</p>
[ { "answer_id": 421651, "author": "d0k", "author_id": 52109, "author_profile": "https://Stackoverflow.com/users/52109", "pm_score": 4, "selected": false, "text": "grp grp.getgrall() import grp\ngroups = grp.getgrall()\nfor group in groups:\n for user in group[3]:\n print user, g...
2009/01/07
[ "https://Stackoverflow.com/questions/421618", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39061/" ]
421,619
<p>I have this sample text, which is retrieved from the class name on an html element:</p> <pre><code>rich-message err-test1 erroractive rich-message err-test2 erroractive rich-message erroractive err-test1 err-test2 rich-message erroractive </code></pre> <p>I am trying to match the "test1"/"test2" data in each of these examples. I am currently using the following regex, which matches the "err-test1" type of word. I can't figure out how to limit it to just the data after the hyphen(-).</p> <pre><code>/err-(\S*)/ig </code></pre> <p>Head hurts from banging against this wall.</p>
[ { "answer_id": 421665, "author": "Aron Rotteveel", "author_id": 11568, "author_profile": "https://Stackoverflow.com/users/11568", "pm_score": 3, "selected": true, "text": "Regex.exec() () var string = 'rich-message err-test1 erroractive';\nvar regex = new RegExp('err-(\\S*)', 'ig');\nvar...
2009/01/07
[ "https://Stackoverflow.com/questions/421619", "https://Stackoverflow.com", "https://Stackoverflow.com/users/68788/" ]
421,630
<p>Yo!</p> <p>I'm trying to copy a few chars from a char[] to a char*. I just want the chars from index 6 to (message length - 9).</p> <p>Maybe the code example will explain my problem more:</p> <pre><code>char buffer[512] = "GET /testfile.htm HTTP/1.0"; char* filename; // I want *filename to hold only "/testfile.htm" msgLen = recv(connecting_socket, buffer, 512, 0); strncpy(filename, buffer+5, msgLen-9); </code></pre> <p>Any response would help alot!</p>
[ { "answer_id": 421653, "author": "Roddy", "author_id": 1737, "author_profile": "https://Stackoverflow.com/users/1737", "pm_score": 4, "selected": true, "text": "strncpy(filename, buffer+5, msgLen-9);\n char filename[512];\n" }, { "answer_id": 421664, "author": "mmx", "aut...
2009/01/07
[ "https://Stackoverflow.com/questions/421630", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52355/" ]
421,631
<p>I've been wanting to learn assembly for a while now, and although I've tried a few times before, I haven't really been able to get past "Hello, world". Are there any good introductory tutorials to assembly (preferably using NASM, as I use Windows and Linux)?</p> <p>I do have a bit of C knowledge, but mainly code in higher-level languages such as Ruby, Python, C# and JavaScript.</p>
[ { "answer_id": 54257866, "author": "funnydman", "author_id": 9926721, "author_profile": "https://Stackoverflow.com/users/9926721", "pm_score": 2, "selected": false, "text": "nasm" } ]
2009/01/07
[ "https://Stackoverflow.com/questions/421631", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41981/" ]
421,655
<p>How do I stop a GDB execution without a breakpoint?</p>
[ { "answer_id": 421691, "author": "luke", "author_id": 25920, "author_profile": "https://Stackoverflow.com/users/25920", "pm_score": 5, "selected": false, "text": "SIGINT" }, { "answer_id": 6495811, "author": "Anonymous Coward", "author_id": 817749, "author_profile": "...
2009/01/07
[ "https://Stackoverflow.com/questions/421655", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52554/" ]
421,662
<p>I want to be able to detect when a computer connects to a network. The environment is Java 5 under Windows.</p>
[ { "answer_id": 421806, "author": "DaWilli", "author_id": 33974, "author_profile": "https://Stackoverflow.com/users/33974", "pm_score": 0, "selected": false, "text": "try {\n InetAddress inetAddr = InetAddress.getByName(host);\n setOnline();\n} catch (UnknownHostException e) {\n setOff...
2009/01/07
[ "https://Stackoverflow.com/questions/421662", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6013/" ]
421,683
<p>I'm quite confused with the whole animation stuff in iPhone SDK. I tried to study throught the SDK documentation, this website or tried googling it out without success. I'm unable to get my scenario work.</p> <ul> <li>I have single XIB file, with tab bar and a 4 tabs.</li> <li>In a special event i want to switch from one page to another "in code", so I call eg: <code>[tabController selectedIndex: 0]</code>.</li> <li>I need this transition to be animated. Is there a way?</li> <li>If user switches tabs manually, no animated transitions are needed</li> </ul> <p>Also I have one subquestion:</p> <ul> <li>In one of the tabs I have a UITableView with set of items. When user clicks any of these items, another set of items are beign shown (sort of hierarchy browser)</li> <li>I tried to animate this transition using <code>-deleteRowsAtIndexPaths:withRowAnimation:</code> and <code>-insertRowsAtIndexPaths:withRowAnimation:</code>, but without luck.</li> <li>Desired transition is shifting the old items set to the left side and the new items from the right side.</li> </ul> <p>This is first time of my iPhone development, when I got lost even with all the forums and documentation. :)</p> <p>Thanks in advance to anyone trying to help me!</p>
[ { "answer_id": 934044, "author": "David Salzer", "author_id": 1942189, "author_profile": "https://Stackoverflow.com/users/1942189", "pm_score": 2, "selected": false, "text": "tabBarController.delegate = self #import <QuartzCore/CAAnimation.h>\n#import <QuartzCore/CAMediaTimingFunction.h>...
2009/01/07
[ "https://Stackoverflow.com/questions/421683", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
421,720
<p>I am not a big fan of datasets so I use POCO to return data. I have achieved paging and sorting using custom methods that I create for a POCO type that work on page size and give me a set of the complete POCO collection at a time, I use methods that check for name of the DataItem clicked and sort order to do that sort. Creating such methods over and over for every POCO that you plan to use with an ASP.net data control like Gridview is pretty painful.</p> <p>Is there a technique to automate this so that I do not need to make such methods every time for a new POCO so that it works as if you were using a DataTable? I can provide some more explanation if required.</p> <p>NOTE: Some people may call POCO as DTOs .</p> <p>EDIT : I found this <a href="https://web.archive.org/web/20200127134338/http://geekswithblogs.net:80/czumbano/archive/2006/03/27/73532.aspx" rel="nofollow noreferrer">article</a> on this topic. Is this the only possible way to get to what i am trying to do??</p>
[ { "answer_id": 421800, "author": "Toran Billups", "author_id": 2701, "author_profile": "https://Stackoverflow.com/users/2701", "pm_score": 3, "selected": true, "text": "List<Supplier> SupplierList = mSupplierService.GetSuppliers();\nSupplierList.Sort(new GenericComparer<Supplier>(mView.S...
2009/01/07
[ "https://Stackoverflow.com/questions/421720", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37494/" ]
421,739
<p>Let's say I have DatabaseA with TableA, which has these fields: Id, Name.</p> <p>In another database, DatabaseB, I have TableA which has these fields: DatabaseId, Id, Name.</p> <p>Is it possible to setup a replication publication that will send:</p> <p>DatabaseA.dbid, DatabaseA.TableA.Id, DatabaseA.TableA.Name</p> <p>to DatabaseB.TableA?</p> <p>Edit: The reason I'm asking is that I need to combine multiple databases (with identical schemas) into a single database, with as little latency as possible. Replication seemed like a good place to start (need to replicate data from one place to another), but I'm just in the brainstorming phase. I would definitely be open to suggestions on how to accomplish this without using replication.</p>
[ { "answer_id": 421800, "author": "Toran Billups", "author_id": 2701, "author_profile": "https://Stackoverflow.com/users/2701", "pm_score": 3, "selected": true, "text": "List<Supplier> SupplierList = mSupplierService.GetSuppliers();\nSupplierList.Sort(new GenericComparer<Supplier>(mView.S...
2009/01/07
[ "https://Stackoverflow.com/questions/421739", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34720/" ]
421,751
<p>I figure one way to do a count is like this:</p> <pre><code>foo = db.GqlQuery("SELECT * FROM bar WHERE baz = 'baz') my_count = foo.count() </code></pre> <p>What I don't like is my count will be limited to 1000 max and my query will probably be slow. Anyone out there with a workaround? I have one in mind, but it doesn't feel clean. If only GQL had a real COUNT Function...</p>
[ { "answer_id": 422267, "author": "orip", "author_id": 37020, "author_profile": "https://Stackoverflow.com/users/37020", "pm_score": 0, "selected": false, "text": ".fetch() LIMIT=1000\ndef count(query):\n result = offset = 0\n gql_query = db.GqlQuery(query)\n while True:\n count...
2009/01/07
[ "https://Stackoverflow.com/questions/421751", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48988/" ]
421,757
<p>I have this regular expression: </p> <pre><code>^\$?(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?$ </code></pre> <p>however it is failing when i have an amount such as this: <code>41022095.6</code></p> <p>anything I am missing?</p>
[ { "answer_id": 421765, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 3, "selected": true, "text": "^\\$?(\\d{1,3}(\\,\\d{3})*|(\\d+))(\\.\\d{1,2})?$\n {2} {1,2} . \\. ." }, { "answer_id": 421769, "author": "Jo...
2009/01/07
[ "https://Stackoverflow.com/questions/421757", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41685/" ]
421,764
<p>I love programming with .NET, especially C# 3.0, .NET 3.5 and WPF. But what I especially like is that with Mono .NET is really platform-independent.</p> <p>Now I heard about the Olive Project in Mono. I couldn't find some kind of Beta. </p> <p>Does it already work? Have any of you made any experiences with it?</p> <p>Edit: I know about Moonlight. But I want a standalone WPF application. And <strong>because of</strong> Moonlight I hope WPF on Linux will become true.</p>
[ { "answer_id": 27940964, "author": "Dzmitry Lahoda", "author_id": 173073, "author_profile": "https://Stackoverflow.com/users/173073", "pm_score": 2, "selected": false, "text": "IlSpy Wine Ubuntu dotnet45 corefonts winetricks IlSpy loves programming with .NET" } ]
2009/01/07
[ "https://Stackoverflow.com/questions/421764", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52553/" ]
421,772
<p>What I'd like to do is to include settings from a file into my current interactive bash shell like this:</p> <p>$ . /path/to/some/dir/.settings</p> <p>The problem is that the .settings script also needs to use the "." operator to include other files like this:</p> <p>. .extra_settings</p> <p>How do I reference the relative path for .extra_settings in the .settings file? These two files are always stored in the same directory, but the path to this directory will be different depending on where these files were installed.</p> <p>The operator always knows the /path/to/some/dir/ as shown above. How can the .settings file know the directory where it is installed? I would rather not have an install process that records the name of the installed directory.</p>
[ { "answer_id": 421905, "author": "orip", "author_id": 37020, "author_profile": "https://Stackoverflow.com/users/37020", "pm_score": 2, "selected": false, "text": "# settings.sh\necho export CLASSPATH=${CLASSPATH}:/foo/bar\n eval $(/path/to/settings.sh)\n X=...; export X setenv X ..." }...
2009/01/07
[ "https://Stackoverflow.com/questions/421772", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52563/" ]