qid
int64
4
19.1M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
407,956
<p>I never touch <code>routes.rb</code> beyond calling <code>map.root</code> to set a default route. I've always been content to use URLs of the form...</p> <pre><code>/controller/action/perhaps_an_id </code></pre> <p>and it works fine.</p> <p>Does this make me a bad person? Am I missing out on something totally awesome?</p> <p>What if I try to adopt RESTful design? Would that mean I have to edit <code>routes.rb</code> or could I continue to pleasantly ignore it?</p> <p>(I tried to read up on this topic in The Rails Way but it was unbearable.)</p>
[ { "answer_id": 407993, "author": "allesklar", "author_id": 19893, "author_profile": "https://Stackoverflow.com/users/19893", "pm_score": 3, "selected": false, "text": "map.resources :posts\n" }, { "answer_id": 407996, "author": "Ronn", "author_id": 49684, "author_prof...
2009/01/02
[ "https://Stackoverflow.com/questions/407956", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42595/" ]
407,964
<p>I need to play an MP3 in the background while generating animation. The audio drives the animation timeline so I have to track MS from the start of the file to keep things in sync. In VB6 I used the MMControl which raised an event at certain intervals and could count the frames from the beginning to always determine my position. Just can not figure out the .Net way to do this.</p> <p>Thanks.</p>
[ { "answer_id": 407993, "author": "allesklar", "author_id": 19893, "author_profile": "https://Stackoverflow.com/users/19893", "pm_score": 3, "selected": false, "text": "map.resources :posts\n" }, { "answer_id": 407996, "author": "Ronn", "author_id": 49684, "author_prof...
2009/01/02
[ "https://Stackoverflow.com/questions/407964", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38349/" ]
407,970
<p>Years ago I learned the hard way about precision problems with floats so I quit using them. However, I still run into code using floats and it make me cringe because I know some of the calculations will be inaccurate.</p> <p>So, when is it appropriate to use a float?</p> <p><strong>EDIT:</strong> As info, I don't think that I've come across a program where the accuracy of a number isn't important. But I would be interested in hearing examples.</p>
[ { "answer_id": 407981, "author": "mmx", "author_id": 33708, "author_profile": "https://Stackoverflow.com/users/33708", "pm_score": 3, "selected": false, "text": "float double float double decimal float double decimal double decimal" } ]
2009/01/02
[ "https://Stackoverflow.com/questions/407970", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47576/" ]
407,977
<p>If you have an elliptic curve in the form of:</p> <pre><code>y^2 = x^3 + a*x + b (mod p) </code></pre> <p>Is there a good program to calculate the number of points on this curve?</p> <p>I have read about Schoof's and Schoof-Elkies-Atkin (SEA) algorithm, but I'm looking for open source implementations. Does anyone know a good program that can do this?</p> <p>Also if a is 1 and b is 0, the SEA algorithm can't be used because the j-invariant is 0. Is this correct?</p>
[ { "answer_id": 408645, "author": "Bobby Moretti", "author_id": 51100, "author_profile": "https://Stackoverflow.com/users/51100", "pm_score": 2, "selected": false, "text": "sage: k = GF(next_prime(10^20))\nsage: E = EllipticCurve(k.random_element())\nsage: E.cardinality() ...
2009/01/02
[ "https://Stackoverflow.com/questions/407977", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51011/" ]
407,980
<p>I'd like to implement database caching functionality in PHP based on reference counts. For example, code to access the record in table <code>foo</code> with an ID of 1 might look like:</p> <pre><code>$fooRecord = $fooTable-&gt;getRecord(1); </code></pre> <p>The first time this is called, <code>$fooTable</code> fetches the appropriate record from the database, stores it in an internal cache, and returns it. Any subsequent calls to <code>getRecord(1)</code> will return another reference to the same object in memory. <code>$fooRecord</code> signals <code>$fooTable</code> when it destructs, and if there are no remaining references, it stores any changes back to the database and removes it from the cache.</p> <p>The problem is that PHP's memory management abstracts away the details about reference counts. I've searched PECL and Google for an extension to do so, but found no results. So question #1 is: does such an extension exist?</p> <p>In an alternative approach, $fooTable returns a super-sneaky fake object. It pretends to be the record by forwarding <code>__call()</code>, <code>__set()</code>, and <code>__get()</code>, and its constructor and destructor provide the appropriate hooks for reference counting purposes. Tests, works great, except that it breaks type-hinting. All my methods that were expecting a FooRecord object now get a Sneaky object, or maybe a FooSneaky if I feel like creating an empty subclass of Sneaky for <em>every one of my tables</em>, which I do not. Also, I'm afraid it will confuse maintenance programmers (such as myself).</p> <p>Question #2: Is there another approach I've missed?</p>
[ { "answer_id": 408004, "author": "Eran Galperin", "author_id": 10585, "author_profile": "https://Stackoverflow.com/users/10585", "pm_score": 1, "selected": false, "text": "public function getRecord($id) {\n $cache = $this -> getCache(); //Retrieves an instanced Zend_Cache object or c...
2009/01/02
[ "https://Stackoverflow.com/questions/407980", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25213/" ]
407,983
<p>I am wondering why the C# 3.0 compiler is unable to infer the type of a method when it is passed as a parameter to a generic function when it can implicitly create a delegate for the same method.</p> <p>Here is an example:</p> <pre><code>class Test { static void foo(int x) { } static void bar&lt;T&gt;(Action&lt;T&gt; f) { } static void test() { Action&lt;int&gt; f = foo; // I can do this bar(f); // and then do this bar(foo); // but this does not work } } </code></pre> <p>I would have thought that I would be able to pass <code>foo</code> to <code>bar</code> and have the compiler infer the type of <code>Action&lt;T&gt;</code> from the signature of the function being passed but this does not work. However I can create an <code>Action&lt;int&gt;</code> from <code>foo</code> without casting so is there a legitimate reason that the compiler could not also do the same thing via type inference?</p>
[ { "answer_id": 408008, "author": "Amy B", "author_id": 8155, "author_profile": "https://Stackoverflow.com/users/8155", "pm_score": 5, "selected": true, "text": "public class SomeClass\n{\n static void foo(int x) { }\n static void foo(string s) { }\n static void bar<T>(Action<T> ...
2009/01/02
[ "https://Stackoverflow.com/questions/407983", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34211/" ]
407,987
<p>I'm interested in implementing a Forth system, just so I can get some experience building a simple VM and runtime.</p> <p>When starting in Forth, one typically learns about the stack and its operators (DROP, DUP, SWAP, etc.) first, so it's natural to think of these as being among the primitive operators. But they're not. Each of them can be broken down into operators that directly manipulate memory and the stack pointers. Later one learns about store (!) and fetch (@) which can be used to implement DUP, SWAP, and so forth (ha!).</p> <p>So what are the primitive operators? Which ones must be implemented directly in the runtime environment from which all others can be built? I'm not interested in high-performance; I want something that I (and others) can learn from. Operator optimization can come later.</p> <p>(Yes, I'm aware that I can start with a Turing machine and go from there. That's a bit extreme.)</p> <p>Edit: What I'm aiming for is akin to bootstrapping an operating system or a new compiler. What do I need do implement, at minimum, so that I can construct the rest of the system out of those primitive building blocks? I won't implement this on bare hardware; as an educational exercise, I'd write my own minimal VM.</p>
[ { "answer_id": 408072, "author": "plinth", "author_id": 20481, "author_profile": "https://Stackoverflow.com/users/20481", "pm_score": 6, "selected": true, "text": "SetPixel GetPixel DOES> DOES>" }, { "answer_id": 408285, "author": "Charlie Martin", "author_id": 35092, ...
2009/01/02
[ "https://Stackoverflow.com/questions/407987", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17312/" ]
407,989
<p>I grabbed a database of the zip codes and their langitudes/latitudes, etc from this <a href="http://www.populardata.com/downloads.html" rel="noreferrer">This page</a>. It has got the following fields:</p> <blockquote> <p>ZIP, LATITUDE, LONGITUDE, CITY, STATE, COUNTY, ZIP_CLASS</p> </blockquote> <p>The data was in a text file but I inserted it into a MySQL table. My question now is, how can i utilise the fields above to calculate the distance between two zip codes that a user can enter on the website? Working code in PHP will be appreciated</p>
[ { "answer_id": 408000, "author": "Mike Paterson", "author_id": 42933, "author_profile": "https://Stackoverflow.com/users/42933", "pm_score": 3, "selected": false, "text": "function calc_distance($point1, $point2)\n{\n $distance = (3958 * 3.1415926 * sqrt(\n ($point1['lat'] ...
2009/01/02
[ "https://Stackoverflow.com/questions/407989", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49153/" ]
408,002
<p>Inside VS2005, our whole programming staff gets this error message <strong>sporadically</strong> and it is always on the <strong>BeneControls</strong> project. This error message happens multiple times a day and it occurs when going into DESIGN mode for a control. Normally rebuilding the <strong>BeneControls</strong> fixes the problem but somtime the whole solution has to be rebuilt. </p> <p>Has anyone else solved this problem yet?</p> <p>Any recommendations or web sites that outlines what needs to be done?</p> <p>Sometimes I just wish MS would add a rebuild button to the error message screen.</p> <p>We are using Visual Studio 2005, VB.NET and DevExpress Controls.</p> <p>Here is the whole error message:</p> <hr> <pre><code>One or more errors encountered while loading the designer. The errors are listed below. Some errors can be fixed by rebuilding your project, while others may require code changes. Could not load file or assembly 'BeneControls, Version=1.0.3289.23008, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified. Hide at System.Signature._GetSignature(SignatureStruct&amp; signature, Void* pCorSig, Int32 cCorSig, IntPtr fieldHandle, IntPtr methodHandle, IntPtr declaringTypeHandle) at System.Signature.GetSignature(SignatureStruct&amp; signature, Void* pCorSig, Int32 cCorSig, RuntimeFieldHandle fieldHandle, RuntimeMethodHandle methodHandle, RuntimeTypeHandle declaringTypeHandle) at System.Signature..ctor(RuntimeFieldHandle fieldHandle, RuntimeTypeHandle declaringTypeHandle) at System.Reflection.RtFieldInfo.get_FieldType() at System.ComponentModel.Design.InheritanceService.AddInheritedComponents(Type type, IComponent component, IContainer container) at System.Windows.Forms.Design.DocumentDesigner.Initialize(IComponent component) at System.ComponentModel.Design.DesignerHost.AddToContainerPostProcess(IComponent component, String name, IContainer containerToAddTo) at System.ComponentModel.Design.DesignerHost.Add(IComponent component, String name) at System.ComponentModel.Design.DesignerHost.System.ComponentModel.Design.IDesignerHost.CreateComponent(Type componentType, String name) at System.ComponentModel.Design.Serialization.DesignerSerializationManager.CreateInstance(Type type, ICollection arguments, String name, Boolean addToContainer) at System.ComponentModel.Design.Serialization.DesignerSerializationManager.System.ComponentModel.Design.Serialization.IDesignerSerializationManager.CreateInstance(Type type, ICollection arguments, String name, Boolean addToContainer) at System.ComponentModel.Design.Serialization.TypeCodeDomSerializer.Deserialize(IDesignerSerializationManager manager, CodeTypeDeclaration declaration) at System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager manager) at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager serializationManager) at System.ComponentModel.Design.Serialization.BasicDesignerLoader.BeginLoad(IDesignerLoaderHost host) </code></pre> <hr> <p>Thanks in advance, Gerhard</p>
[ { "answer_id": 408043, "author": "Otávio Décio", "author_id": 48684, "author_profile": "https://Stackoverflow.com/users/48684", "pm_score": 4, "selected": true, "text": "[assembly: AssemblyVersion(\"1.0.*.*\")]\n [assembly: AssemblyVersion(\"1.0.0.0\")]\n" } ]
2009/01/02
[ "https://Stackoverflow.com/questions/408002", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4964/" ]
408,032
<p>I'm looking for a fast way to turn an associative array in to a string. Typical structure would be like a URL query string but with customizable separators so I can use '<code>&amp;amp;</code>' for xhtml links or '<code>&amp;</code>' otherwise.</p> <p>My first inclination is to use <code>foreach</code> but since my method could be called many times in one request I fear it might be too slow.</p> <pre><code>&lt;?php $Amp = $IsXhtml ? '&amp;amp;' : '&amp;'; $Parameters = array('Action' =&gt; 'ShowList', 'Page' =&gt; '2'); $QueryString = ''; foreach ($Parameters as $Key =&gt; $Value) $QueryString .= $Amp . $Key . '=' . $Value; </code></pre> <p>Is there a faster way?</p>
[ { "answer_id": 408040, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 9, "selected": true, "text": "http_build_query()" }, { "answer_id": 507195, "author": "Community", "author_id": -1, "author_profile": "h...
2009/01/02
[ "https://Stackoverflow.com/questions/408032", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51021/" ]
408,042
<p>We use iText to generate PDFs from Java (based partly on recommendations on this site). However, embedding a copy of our logo in an image format like GIF results in it looking a bit strange as people zoom in and out.</p> <p>Ideally we'd like to embed the image in a vector format, such as EPS, SVG or just a PDF template. The website claims that EPS support has been dropped, that embedding a PDF or PS within a PDF can result in errors, and it doesn't even mention SVG.</p> <p>Our code uses the Graphics2D API rather than iText directly, but we'd be willing to break out of AWT mode and use iText itself if it achieved the result. How can this be done?</p>
[ { "answer_id": 408098, "author": "David Koelle", "author_id": 2197, "author_profile": "https://Stackoverflow.com/users/2197", "pm_score": 3, "selected": false, "text": "Document document = new Document(PageSize.LETTER);\nPdfWriter writer = null;\ntry {\n writer = PdfWriter.getInstance...
2009/01/02
[ "https://Stackoverflow.com/questions/408042", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1000/" ]
408,046
<p>I've been inspired by <a href="https://stackoverflow.com/questions/405724/modifying-microsoft-outlook-contacts-from-python">Modifying Microsoft Outlook contacts from Python</a> -- I'm looking to try scripting some of my more annoying Outlook uses with the <code>win32com</code> package. I'm a Linux user trapped in a Windows users' cubicle, so I don't know much about COM.</p> <p>I'm looking for information on whether COM allows for reflection via <code>win32com</code> or whether there's documentation on the Outlook 2007 COM objects. Any other pointers that you think will be helpful are welcome!</p> <p>I've found <a href="http://wiki.exchange4linux.org/e4lwiki/n-h.support.wiki/uploads/programming_outlook_with_python.pdf" rel="nofollow noreferrer">Programming Outlook With Python</a>, but I'm using Outlook 2007 so I'd like some more information on how much of the Outlook 2000 information is still applicable.</p> <p>TIA!</p>
[ { "answer_id": 9816622, "author": "ebt", "author_id": 376763, "author_profile": "https://Stackoverflow.com/users/376763", "pm_score": 1, "selected": false, "text": "import win32com.client,os,re\nfrom utils.autoencode import autoencode \ngenerated='2D5E2D34-BED5-4B9F-9793-A31E26E6806Ex0x4...
2009/01/02
[ "https://Stackoverflow.com/questions/408046", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3594/" ]
408,051
<p>So if my JPA query is like this: Select distinct p from Parent p left join fetch p.children order by p.someProperty</p> <p>I correctly get results back ordered by p.someProperty, and I correctly get my p.children collection eagerly fetched and populated. But I'd like to have my query be something like "order by p.someProperty, p.children.someChildProperty" so that the collection populated inside each parent object was sub-ordered by someChildProperty.</p> <p>This seems intuitive when I think in terms of the sql that is actually generated for these calls, but I guess less so when it tries to map back to hierarchical objects.</p>
[ { "answer_id": 408522, "author": "Adeel Ansari", "author_id": 42769, "author_profile": "https://Stackoverflow.com/users/42769", "pm_score": 5, "selected": true, "text": "@javax.persistence.OrderBy(value = \"fieldName\")\n @org.hibernate.annotations.OrderBy(clause = \"FIELD_NAME asc\")\n ...
2009/01/02
[ "https://Stackoverflow.com/questions/408051", "https://Stackoverflow.com", "https://Stackoverflow.com/users/409/" ]
408,055
<p>What would result from something like the following:</p> <pre><code>p(X,Y) :- q(X). p(X,Y) :- r(Y). q(a). r(b). </code></pre> <p>I don't have a Prolog compiler handy, so I can't test what would happen if you then asked <code>p(X,Y)</code>. Would the code even compile? Would <code>p</code> return two answers, each with one of the variables unbound?</p> <p>In a real world scenario, I don't think <code>p(X,Y)</code> would make much sense (one would probably rather want <code>p(X)</code> to follow from either <code>q(X)</code> or <code>r(X)</code>), but I'm interested in what actually happens here, and peripherally, what <em>should</em> happen in such a degenerate case.</p>
[ { "answer_id": 408694, "author": "John Boker", "author_id": 2847, "author_profile": "https://Stackoverflow.com/users/2847", "pm_score": 1, "selected": false, "text": "p(X,Y) :- q(X).\np(X,Y) :- r(Y).\nq(a).\nr(b).\n $ gprolog\nGNU Prolog 1.3.0\nBy Daniel Diaz\nCopyright (C) 1999-2007 Dan...
2009/01/02
[ "https://Stackoverflow.com/questions/408055", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18160/" ]
408,059
<p>I thought I'd use Boost.Interprocess's <a href="http://www.boost.org/doc/libs/1_37_0/doc/html/interprocess/synchronization_mechanisms.html#interprocess.synchronization_mechanisms.message_queue" rel="noreferrer">Message Queue</a> in place of sockets for communication within one host. But after digging into it, it seems that this library for some reason eschews the POSIX message queue facility (which my Linux system supports), and instead is implemented on top of POSIX shared memory. The interface is similar enough that you might not guess this right away, but it seems to be the case.</p> <p>The downside for me is that shared memory obtained via <code>shm_open(3)</code> does not appear to be usable with <code>select(2)</code>, as opposed to POSIX message queues obtained via <code>mq_open(3)</code>.</p> <p>It seems like Boost's library loses in this case. Does anyone understand know why this should be? Even if it POSIX message queues are only available on some systems, I'd expect Boost to use that facility where it is available, and reimplement it only where necessary. Is there some pitfall of the POSIX system which I do not yet recognize?</p>
[ { "answer_id": 13693844, "author": "zaufi", "author_id": 1655064, "author_profile": "https://Stackoverflow.com/users/1655064", "pm_score": 2, "selected": false, "text": "boost::asio boost::interprocess boost::asio" } ]
2009/01/02
[ "https://Stackoverflow.com/questions/408059", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4323/" ]
408,079
<p>I want to do this: </p> <pre><code> findstr /s /c:some-symbol * </code></pre> <p>or the grep equivalent</p> <pre><code> grep -R some-symbol * </code></pre> <p>but I need the utility to autodetect files encoded in UTF-16 (and friends) and search them appropriately. My files even have the byte-ordering mark FFEE in them so I'm not even looking for heroic autodetection.</p> <p>Any suggestions?</p> <hr> <p>I'm referring to Windows Vista and XP.</p>
[ { "answer_id": 408177, "author": "Mark A. Nicolosi", "author_id": 1103052, "author_profile": "https://Stackoverflow.com/users/1103052", "pm_score": 1, "selected": false, "text": "for f in `find . -type f | xargs -I {} file {} | grep UTF-16 | cut -f1 -d\\:`\n do iconv -f UTF-16 -t ...
2009/01/02
[ "https://Stackoverflow.com/questions/408079", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51029/" ]
408,080
<p>Is there a foreach structure in MATLAB? If so, what happens if the underlying data changes (i.e. if objects are added to the set)?</p>
[ { "answer_id": 408092, "author": "Jason S", "author_id": 44330, "author_profile": "https://Stackoverflow.com/users/44330", "pm_score": 4, "selected": false, "text": ">> A = zeros(4); A(:) = 1:16\n\nA =\n\n 1 5 9 13\n 2 6 10 14\n 3 7 11 15\n ...
2009/01/02
[ "https://Stackoverflow.com/questions/408080", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18511/" ]
408,101
<p>In VB.NET, which is faster to use for method arguments, <code>ByVal</code> or <code>ByRef</code>?</p> <p>Also, which consumes more resources at runtime (RAM)? </p> <hr> <p>I read through <a href="https://stackoverflow.com/questions/290189/best-practice-byref-or-byval-in-net">this question</a>, but the answers are not applicable or specific enough.</p>
[ { "answer_id": 408107, "author": "Paul", "author_id": 37865, "author_profile": "https://Stackoverflow.com/users/37865", "pm_score": 1, "selected": false, "text": "ByVal ByRef ByVal" }, { "answer_id": 408131, "author": "user50612", "author_id": 50612, "author_profile":...
2009/01/02
[ "https://Stackoverflow.com/questions/408101", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41021/" ]
408,116
<p>I'm looking for an easy way to track time I work on a project using the command line. I do</p> <pre><code>echo "$(date) : Start" &gt;&gt;worktime.txt </code></pre> <p>When I start working and</p> <pre><code>echo "$(date) : End" &gt;&gt;worktime.txt </code></pre> <p>When I stop working. The result is a file of the form:</p> <pre><code>kent@rat:~/work$ cat worktime.txt Fri Jan 2 19:17:13 CET 2009 : Start Fri Jan 2 19:47:18 CET 2009 : End Fri Jan 2 21:41:07 CET 2009 : Start Fri Jan 2 22:39:24 CET 2009 : End </code></pre> <p>"Start" and "End" are meant as descriptions and could have been <em>any</em> other text. <strong>It is certain</strong> that every <em>odd</em> line contains a start date and time before : and every <em>even</em> line contains an end date and time.</p> <p>What I would like to do is sum up my worked time by parsing the text file using bash, tr, sed, awk and the other common Unix/Linux tools. I prefer using this approach instead of using Python, Perl, Haskell, Java etc. </p> <p>All ideas welcome!</p>
[ { "answer_id": 408132, "author": "wilhelmtell", "author_id": 456, "author_profile": "https://Stackoverflow.com/users/456", "pm_score": 3, "selected": false, "text": "date +%s echo $(date +%s) : Start\n #!/bin/bash\n\ntotal=0\nwhile read LINE; do\n t1=$(echo $LINE |cut -d' ' -f1)\n read...
2009/01/02
[ "https://Stackoverflow.com/questions/408116", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
408,133
<p>I am wondering if someone can help me figure out the best approach to the following problem. I'm building a web application which uses Django templating to construct its web UI component. There are a number of common HTML elements such as the header / footer, HTML head, masthead etc. I'd like to code these once and "include/combine" them with other templates representing the core application functionality.</p> <p>Is this possible using Django Templates? If so how might I go about accomplishing that?</p>
[ { "answer_id": 408176, "author": "S.Lott", "author_id": 10661, "author_profile": "https://Stackoverflow.com/users/10661", "pm_score": 3, "selected": false, "text": "{% include %}" }, { "answer_id": 408181, "author": "kristina", "author_id": 4243, "author_profile": "ht...
2009/01/02
[ "https://Stackoverflow.com/questions/408133", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26241/" ]
408,139
<p>Now I must be missing something here, as this seems a very basic issue that would be addressed in any "Getting started with Flex charting" tutorial. However, all that I could find was hints that the chart should update automatically whenever the dataProvider changes. Mind you, hints.</p> <p>This is my markup:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" title="econemon Sensor Simulator"&gt; &lt;!-- ... --&gt; &lt;mx:Script source="SimulatorFunctions.as" /&gt; &lt;mx:HDividedBox left="0" top="0" bottom="0" right="0"&gt; &lt;!-- ... --&gt; &lt;mx:VDividedBox width="75%" height="100%"&gt; &lt;mx:PlotChart width="100%" height="33%" dataProvider="{xmlDataTest}"&gt; &lt;mx:horizontalAxis&gt; &lt;mx:DateTimeAxis dataUnits="seconds" displayLocalTime="true" parseFunction="dtFromUnixtime"/&gt; &lt;/mx:horizontalAxis&gt; &lt;mx:series&gt; &lt;mx:LineSeries xField="dt" yField="fltValue" displayName="Testkurve" /&gt; &lt;/mx:series&gt; &lt;/mx:PlotChart&gt; &lt;mx:Panel width="100%" height="66%"&gt; &lt;mx:Button label="Start" click="vDataStart()" /&gt; &lt;mx:Button label="Stop" click="vDataStop()" /&gt; &lt;/mx:Panel&gt; &lt;/mx:VDividedBox&gt; &lt;/mx:HDividedBox&gt; &lt;/mx:WindowedApplication&gt; </code></pre> <p>And this is part of my ActionScript:</p> <pre><code>[Bindable] public var xmlDataTest:Array = [ { dt: "1230908694", fltValue: "50.4" }, // ... { dt: "1230909594", fltValue: "35.4" } ] public var dflt:Number = 10.0; public var timData:Timer = new Timer(3000); // ... public function vDataStart():void { if (!timData.running) { timData.addEventListener(TimerEvent.TIMER, vAppendDatum); timData.start(); } } public function vDataStop():void { if (timData.running) { timData.stop(); } } public function vAppendDatum(evt:Event):void { var dtNew:String; var fltNew:String; var fltT: Number; dtNew = String(Number(xmlDataTest[xmlDataTest.length - 1].dt) + 100); fltT = Number(xmlDataTest[xmlDataTest.length - 1].fltValue); if (fltT &lt; 10.0 || fltT &gt; 70) { dflt *= -1; } fltNew = String(fltT + dflt); xmlDataTest.push({ dt: dtNew, fltValue: fltNew }); //trace("Datenpunkte: " + xmlDataTest.length); } </code></pre> <p>On clicking the "Start" button, the data array is extended every 3 seconds, but the chart on the screen remains the same.</p>
[ { "answer_id": 408173, "author": "rmeador", "author_id": 10861, "author_profile": "https://Stackoverflow.com/users/10861", "pm_score": 4, "selected": true, "text": "Array addItem() ArrayCollection xmlDataTest" }, { "answer_id": 408182, "author": "Brandon", "author_id": 23...
2009/01/02
[ "https://Stackoverflow.com/questions/408139", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2077/" ]
408,167
<p>As a programmer who is new to .NET and C#, I find that using .NET Reflector is an incredible utility to use to see how the "professionals" write their code.</p> <p>Can anyone suggest good .NET based applications to use Reflector on for Desktop Applications - any application examples would be appreciated.</p>
[ { "answer_id": 408235, "author": "Dmitri Nesteruk", "author_id": 9476, "author_profile": "https://Stackoverflow.com/users/9476", "pm_score": 0, "selected": false, "text": "Parallel.Invoke mscorlib" } ]
2009/01/02
[ "https://Stackoverflow.com/questions/408167", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
408,170
<p>I have table with 50 entries (users with such details like Name Surname Location etc)</p> <p>I want to create a query that give me users from row 1 to row 10. Then another query that give me users from 11 to 20 and so on.</p> <p>Is there any way how to do that?</p> <p>Thanks</p>
[ { "answer_id": 408771, "author": "Ian Varley", "author_id": 37539, "author_profile": "https://Stackoverflow.com/users/37539", "pm_score": 1, "selected": false, "text": "\"ROW_NUMBER() OVER (...)\" SELECT \n *,\n ROW_NUMBER() OVER (ORDER BY LastName, FirstName) AS RowNumber\n FROM\...
2009/01/02
[ "https://Stackoverflow.com/questions/408170", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44973/" ]
408,192
<p>When trying to compile my class I get an error: </p> <blockquote> <p>The constant <code>'NamespaceName.ClassName.CONST_NAME'</code> cannot be marked static.</p> </blockquote> <p>at the line:</p> <pre><code>public static const string CONST_NAME = "blah"; </code></pre> <p>I could do this all of the time in Java. What am I doing wrong? And why doesn't it let me do this?</p>
[ { "answer_id": 408197, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 11, "selected": true, "text": "const static" }, { "answer_id": 15513193, "author": "Meowmaritus", "author_id": 1890257, "author_p...
2009/01/02
[ "https://Stackoverflow.com/questions/408192", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2598/" ]
408,207
<p>We have a ASP.NET application that uses the Exception Handling Application block to log our exception to a database (using logging block indirectly). This all working perfect. However, since it is using the exception handling block to log data, everytime we wanted to log, we'll have to new'd a System.Exception object. Since we are not throwing exception, there are no performance issue. However, we do have to create a new exception object everytime we want to log something. Is this a bad design?</p>
[ { "answer_id": 408343, "author": "Don", "author_id": 46074, "author_profile": "https://Stackoverflow.com/users/46074", "pm_score": 2, "selected": false, "text": "<categorySources> \n<add switchValue=\"All\" name=\"Database Events\">\n <listeners>\n <add name=\"Formatted E...
2009/01/02
[ "https://Stackoverflow.com/questions/408207", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31206/" ]
408,211
<p>Whats the best way handle exception from a WCF service? How can you throw the exception from a WCF service? </p>
[ { "answer_id": 409485, "author": "Krzysztof Kozmic", "author_id": 13163, "author_profile": "https://Stackoverflow.com/users/13163", "pm_score": 2, "selected": false, "text": "FaultContract<ArgumentException> FaultContract<NameCanNotHaveDigitsFault> NameCanNotHaveDigitsFault" } ]
2009/01/02
[ "https://Stackoverflow.com/questions/408211", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43049/" ]
408,217
<p>After googling a bit there is no definite answer of whether Visual Studio 2008 uses svcutil.exe or not? Visual Studio 2005 did use it, but do the RTM versions of Visual Studio 2008 use svcutil? A few blogs say it doesn't (and make it seem surprising)</p> <ul> <li><a href="https://web.archive.org/web/20120103021621/http://blog.donnfelker.com:80/2008/12/02/svcutil-vs2008/" rel="nofollow noreferrer">SVCUtil &amp; VS2008</a></li> <li><a href="https://web.archive.org/web/20200114134417/http://geekswithblogs.net:80/DavidBarrett/archive/2008/06/30/equivalent-svcutil.exe-command-for-vs2008-add-service-reference.aspx" rel="nofollow noreferrer">Equivalent svcutil.exe command for VS2008 Add Service Reference</a></li> <li><a href="https://web.archive.org/web/20110908050720/http://blogs.microsoft.co.il:80/blogs/oshvartz/archive/2008/09/06/svcutil-generating-wcf-client-and-the-is-field-specified-issue.aspx" rel="nofollow noreferrer">SVCUtil Generating WCF client and the is field specified issue</a></li> </ul> <p>and other sites say it does.</p> <p>The reason I'm asking is we are flattening our WCF wsdl with a custom endpoint behavior extension (an implementation of IWsdlExportExtension/IEndpointBehavior) and using the flattened wsdl via Visual Studio 2008's Add Reference gives us compile errors as it is duplicating Types/Classes. The reference is added without any errors. SvcUtil, on the other hand, throws the duplicate class into a seperate namespace which fixes the build issue.</p> <p>So SvcUtil works, but Visual Studio 2008 doesn't on some of our flatten wsdls. We are fine with continueing to use svcutil if the Add Service Reference in Visual Studio doesn't work, but are wondering if anyone knows if there are any implications in doing so. I couldn't find any evidence that we &quot;shouldn't&quot; be using svcutil, just that it isn't as easy as using the Add Service Reference in Visual Studio 2008.</p>
[ { "answer_id": 411696, "author": "Philippe", "author_id": 920, "author_profile": "https://Stackoverflow.com/users/920", "pm_score": -1, "selected": false, "text": "//------------------------------------------------------------------------------\n// <auto-generated>\n// This code was ...
2009/01/02
[ "https://Stackoverflow.com/questions/408217", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49861/" ]
408,225
<p>On my page I have a drop-down select box, with a default value of (empty). When the user selects an entry, the appropriate form for that entry type is displayed.</p> <p>Couple of problems..</p> <ol> <li>The code is not DRY and seems more verbose than it needs to be, so not easily maintainable / extensible.</li> <li>When a user selects something, fills in the form, goes to the next page, and then hits the Back button, the select field is pre-selected with their choice, but since there has been no <code>.change()</code> event, the form box is not displayed. They have to select a different <code>&lt;option&gt;</code>, then click back to their original choice to get their forum back.</li> </ol> <p>Here's the code:</p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function(){ $('#select_type').change(function () { $('fieldset').css('display','none'); # hide all the forms on the page var selectval = $('#select_type').val(); if (selectval == 'instance') { $('#instance').toggle(); } if (selectval == 'mob') { $('#mob').toggle(); } if (selectval == 'dailyquest') { $('#dailyquest').toggle(); } if (selectval == 'repeatablequest') { $('#repeatablequest').toggle(); } if (selectval == 'zonequest') { $('#zonequest').toggle(); } if (selectval == 'reward') { $('#reward').toggle(); } }); }); &lt;/script&gt; </code></pre> <p>Help JS gurus of SO!</p>
[ { "answer_id": 408231, "author": "Eran Galperin", "author_id": 10585, "author_profile": "https://Stackoverflow.com/users/10585", "pm_score": 4, "selected": true, "text": "$(document).ready(function(){\n var select = $('#select_type');\n $('#' + select.val()).toggle(); // Toggle t...
2009/01/02
[ "https://Stackoverflow.com/questions/408225", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39539/" ]
408,255
<p>I need your help,</p> <p>For example I have a decimal type variable and I want to round up this way.</p> <p>Eg</p> <p>3.0 = 3</p> <p>3.1 = 4</p> <p>3.2 = 4</p> <p>3.3 = 4</p> <p>3.4 = 4</p> <p>3.5 = 4</p> <p>3.6 = 4</p> <p>3.7 = 4</p> <p>3.8 = 4</p> <p>3.9 = 4</p> <p>4.0 = 4</p> <p>4.1 = 5</p> <p>4.2 = 5</p> <p>etc....</p> <p>How can I do that?</p>
[ { "answer_id": 408274, "author": "Andreas Grech", "author_id": 44084, "author_profile": "https://Stackoverflow.com/users/44084", "pm_score": 1, "selected": false, "text": "dim rounded as int = Math.Ceiling(4.1)\n" }, { "answer_id": 436606, "author": "Shiva", "author_id": ...
2009/01/02
[ "https://Stackoverflow.com/questions/408255", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44973/" ]
408,265
<p>I have a form that is dynamically generated, and has dynamically generated id's (and potentially classes). The forms are the same but they have the related id tacked on to the end.</p> <p>How can I select each set of inputs and apply code to each one?</p> <p>I was experimenting with $('input[id^=@id_airline_for_]') but could not get it to fly. I suspect I am missing some fundamental jQuery knowledge that is holding me back since I am sure this is a common problem with dynamic forms. </p> <pre><code>&lt;form method='POST'&gt; &lt;label for="id_airline_for_8"&gt;Airline&lt;/label&gt;: &lt;input id="id_airline_for_8" class="arrival_transfer_toggle_8" type="text" maxlength="30" name="airline_for_8"/&gt; &lt;label for="id_flight_number_for_8"&gt;Flight Number&lt;/label&gt;: &lt;input id="id_flight_number_for_8" class="arrival_transfer_toggle_8" type="text" maxlength="30" name="flight_number_for_8"/&gt; &lt;label for="id_airline_for_17"&gt;Airline&lt;/label&gt;: &lt;input id="id_airline_for_17" class="arrival_transfer_toggle_17" type="text" maxlength="30" name="airline_for_17"/&gt; &lt;label for="id_flight_number_for_17"&gt;Flight Number&lt;/label&gt;: &lt;input id="id_flight_number_for_17" class="arrival_transfer_toggle_17" type="text" maxlength="30" name="flight_number_for_17"/&gt; -- snip -- &lt;/form&gt; </code></pre> <p>EDIT: I should update that i want to be able to perform some action when the input is clicked but only for classes with a matching id at the end.</p> <p>To make it easy, lets say I want all inputs with a matching id at the end of the #id to disappear when one is clicked (just for arguments sake).</p>
[ { "answer_id": 408272, "author": "Sophie Alpert", "author_id": 49485, "author_profile": "https://Stackoverflow.com/users/49485", "pm_score": 2, "selected": false, "text": "$(\"input#id_airline_for\" + id) id $(\"#id_airline_for\" + id);\n" }, { "answer_id": 408282, "author": ...
2009/01/02
[ "https://Stackoverflow.com/questions/408265", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22306/" ]
408,269
<p>Is it possible to animate the change of a <code>UIProgressView</code> such that the display will move smoothly to the new value?</p> <p>Kinda like NSProgressIndicator does.</p>
[ { "answer_id": 409195, "author": "catlan", "author_id": 23028, "author_profile": "https://Stackoverflow.com/users/23028", "pm_score": 7, "selected": true, "text": "UIProgressView setProgress:(float)value animated:(BOOL)animated UIProgressView should setProgress:(float)value animated:(BOO...
2009/01/02
[ "https://Stackoverflow.com/questions/408269", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49485/" ]
408,286
<p>I'm trying to do what I think is a simple thing under Linux. I have a bash script which runs various test programs, and I want to determine which files in the current directory were created by the test programs. So I am doing something like this:</p> <pre> touch timestamp-file run the test find -newer timestamp-file -type f > list-of-files rm -f timestamp-file </pre> <p>Turns out the granularity of find -newer is poor, so what typically happens is that some files which were generated by the test program show up as OLDER than the timestamp file. So then I tried this:</p> <pre> ls -tr1 | sed '1,/timestamp-file/d' </pre> <p>to generate the same list. This <em>usually</em> works, but not always. I still end up with the situation where files which were generated by the test show up as older than the timestamp file.</p> <p>Thanks!</p> <p>P.S. I can accomplish this another way by taking two snapshots of the directory, one before the test program runs, and then one after, and comparing them. Any files in the second list which are not in the first must have been created by the test program (I'm not concerned with background jobs or other users writing to the dir). But this method is not what I want because if an output file wasn't removed prior to running the test (they're supposed to be, but in some cases they may not be), this method will say it was not created by the test program because it was in the dir before the test program was run.</p>
[ { "answer_id": 408311, "author": "paxdiablo", "author_id": 14860, "author_profile": "https://Stackoverflow.com/users/14860", "pm_score": 2, "selected": false, "text": "touch -t 200801010000.00 *\n find -newer touch -t (current time - 10 minutes) *\ntouch -t (current time - 5 minutes) ti...
2009/01/02
[ "https://Stackoverflow.com/questions/408286", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51048/" ]
408,310
<p>I've got some code that looks like this:</p> <pre><code>using (DBDataContext dc = new DBDataContext(ConnectionString)) { Main main = new Main { ClientTime = clientTime }; dc.Mains.InsertOnSubmit(main); dc.SubmitChanges(); return main.ID; } </code></pre> <p>If I return from inside a "using", will the using still clean up?</p>
[ { "answer_id": 408313, "author": "Otávio Décio", "author_id": 48684, "author_profile": "https://Stackoverflow.com/users/48684", "pm_score": 6, "selected": true, "text": "using" }, { "answer_id": 408317, "author": "Jon Skeet", "author_id": 22656, "author_profile": "htt...
2009/01/02
[ "https://Stackoverflow.com/questions/408310", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1463/" ]
408,316
<p>Has anything useful come out of Intentional or "Language Oriented" Programming?</p> <p>This isn't a rhetorical question. I'm looking for people who've tried these tools (ie. representing programs in some "higher level" format than mere text and using different editors for different domain specific subsets) and have some comments about how it was, Or recommendations for good tools.</p> <p>( <a href="http://www.onboard.jetbrains.com/is1/articles/04/10/lop/" rel="nofollow noreferrer">http://www.onboard.jetbrains.com/is1/articles/04/10/lop/</a> , <a href="https://stackoverflow.com/questions/201386/what-exactly-is-intentional-programming">What exactly is Intentional Programming</a> )</p>
[ { "answer_id": 408371, "author": "OscarRyz", "author_id": 20654, "author_profile": "https://Stackoverflow.com/users/20654", "pm_score": 3, "selected": true, "text": "package a;\nimport static a.Help.*;\n\npublic class Test { \n\n public void test(){\n Object value = \"\";\n ...
2009/01/02
[ "https://Stackoverflow.com/questions/408316", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8482/" ]
408,320
<p>I am adding items to a <code>ListBox</code> like so:</p> <pre><code>myListBox.Items.addRange(myObjectArray); </code></pre> <p>and I also want to select some of the items I add by the following:</p> <pre><code>foreach(MyObject m in otherListOfMyObjects) { int index = myListBox.Items.IndexOf(m); myListBox.SelectedIndices.Add(index); } </code></pre> <p>however <code>index</code> is always <code>-1</code>.</p> <p>Is there a different way to get the index of an object in a <code>ListBox</code>?</p>
[ { "answer_id": 408327, "author": "Neil Barnwell", "author_id": 26414, "author_profile": "https://Stackoverflow.com/users/26414", "pm_score": 4, "selected": true, "text": "MyObject Equals() GetHashCode() ToString() IndexOf() ToString()" }, { "answer_id": 408328, "author": "Kon...
2009/01/02
[ "https://Stackoverflow.com/questions/408320", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2598/" ]
408,336
<p>I have the following use case , lot of code which was tightly coupled on a concrete type (say Concrete1). Later figured out the concrete type needs to be changed, so defined an interface . E.g</p> <pre><code>Class ABC { virtual int foo() = 0; virtual int getType() = 0; } class Concrete1 : public ABC { int foo() { ... } int getType() { return 1; } } class Concrete2 : public ABC { int foo() { ... } int getType() { return 2; } } </code></pre> <p>A static factory pattern was used for creation of the objects. So all places where the object new Concrete1 was created is replaced with ABCFactory::createType(). </p> <p>Now there are a lot of places in code where I need to check if the object returned by createType is whether Concrete1 or Concrete2 and accordingly do the relevant logic (So a lot of if else in the code :( ). </p> <p>I want to avoid a lot of if else in the code as part of this change. Any suggestions? </p> <p>The thing which bothers me a lot is </p> <pre><code>if (abc.getType() == 1) { ... } else if (abc.getType() ==2) { ... } </code></pre>
[ { "answer_id": 408370, "author": "IAmCodeMonkey", "author_id": 27613, "author_profile": "https://Stackoverflow.com/users/27613", "pm_score": 4, "selected": true, "text": "void Main(string[] args)\n{\n Bird bird = BirdFactory.GetPigeon();\n if (bird.GetType().Equals(typeof(Duck)))\n ...
2009/01/02
[ "https://Stackoverflow.com/questions/408336", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43756/" ]
408,342
<p>I'm creating a website for my church and I'm having problems making it display right in IE. It seems that my div "sidebox" is having its background position overridden by the "margin: 0 auto;" as the background displays centered rather than on the right, which is shifting the site to the right.</p> <p>Here's the code:</p> <pre><code>.sidebox { margin: 0 auto; background-image: url(images/bg-container-right.jpg); background-repeat: no-repeat; background-position: bottom right !important; position: absolute; left: 0px; width: 960px; </code></pre> <p>}</p> <pre><code>.boxhead { background-image: url(images/bg-container-top.jpg); background-repeat: no-repeat; background-position: top right; height: 37px; } .boxbody { background-image: url(images/bg-container-left.jpg); background-repeat: no-repeat; background-position: bottom left !important; width: 25px !important; } .boxtopcorner { background-image: url(images/bg-container-top-right.jpg); background-repeat: no-repeat; background-position: top left; width: 25px; height: 37px; } &lt;div class='sidebox' style='border: 1px solid;'&gt; I'm in the box &lt;div class='boxhead'&gt; &lt;div class='boxtopcorner'&gt;&lt;/div&gt; &lt;/div&gt; &lt;div class='boxbody' style='height: 750px;'&gt; &lt;!-- Content Goes Here --&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>Below is a link to the running site. You can see it run fine in FF and Safari, but not in IE. My code above is without the content and removing it doesn't fix the problem. <a href="http://victoryregina.com/newSite/church.html" rel="nofollow noreferrer">Running page</a></p>
[ { "answer_id": 408368, "author": "Abram Simon", "author_id": 46204, "author_profile": "https://Stackoverflow.com/users/46204", "pm_score": 2, "selected": false, "text": ".header { width: 960px; height: 20px; background: url(top.jpg) no-repeat; }\n\n.footer { width: 960px; height: 20px; b...
2009/01/02
[ "https://Stackoverflow.com/questions/408342", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16437/" ]
408,358
<p>I'm coding a game, and I'd like to be able to find the center of mass of an arbitrary shape on a black and white bitmap such as this:</p> <pre> 012345678 0.XX...... 1..XXX.... 2...XXX... 3..XXXXXXX 4...XXX... </pre> <p>All "cells" have the same weight. Diagonally adjacent cells are not considered to be connected, and the shape will always be a single one since it's already split by another function before this.</p> <p>It's only going to be used for reasonably low resolution (maybe 50x50 at most) images and it doesn't need to be super accurate, speed is preferable. </p> <p>I get a feeling there's a proper way to do this, but I don't really know what to google for. </p> <p>I'm coding this in Actionscript 3, but examples in any language are appreciated, moreso if they're made to be understood by humans.</p> <p>EDIT: Feel free to assume that the data is stored in whatever data structure you think is most convenient for your example. I'm using bitmaps, but two-dimensional arrays or even a single array is just fine too!</p> <p>EDIT: This is the code I ended up using, it can most likely be done faster, but I find this to be very readable:</p> <pre><code>// _bmp is a private BitmapData instance public function getCenterOfMass():Point { var avg :Point = new Point(0, 0); var points :uint = 0; for (var ix:uint = 0; ix &lt; _bmp.width; ix++) { for (var iy:uint = 0; iy &lt; _bmp.height; iy++) { if (_bmp.getPixel(ix, iy) == ACTIVE_COLOR) { avg.x += ix; avg.y += iy; points++; } } } avg.x /= points; avg.y /= points; return avg; } </code></pre>
[ { "answer_id": 408376, "author": "Yuval Adam", "author_id": 24545, "author_profile": "https://Stackoverflow.com/users/24545", "pm_score": 5, "selected": true, "text": "xSum = 0\nySum = 0\npoints = 0\n\nfor point in matrix\n if point is marked\n xSum += pointX\n ySum += p...
2009/01/03
[ "https://Stackoverflow.com/questions/408358", "https://Stackoverflow.com", "https://Stackoverflow.com/users/914/" ]
408,378
<p>I'm using the ASP net Ajax toolkit and have a <code>GridView</code> within the <code>UpdatePanel</code>, everything works fine.</p> <p>When I attempt to run some <code>JQuery</code> against the table that should be generated, there isn't any sign of the <code>GridView</code> (or table <code>HTML</code>) in the DOM that is returned. I am assuming this is all done by ASP generated <code>Javascript</code>?</p> <p>How can I perform any actions on a <code>GridView</code> that lies within an <code>UpdatePanel</code>?</p>
[ { "answer_id": 538608, "author": "Dave Baghdanov", "author_id": 45194, "author_profile": "https://Stackoverflow.com/users/45194", "pm_score": 0, "selected": false, "text": "protected void Page_Load(object sender, EventArgs e)\n{\n string js = \"$(document).ready(function(){$(\\\"#\" +...
2009/01/03
[ "https://Stackoverflow.com/questions/408378", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16642/" ]
408,394
<p>Has anybody tried doing GSP design with Adobe Dreamweaver CS4? It has support for JSPs, but it doesn't recognize the gsp extension, and even if it did I think there would be problems regarding the gsp tags that it would not recognize. I found a little cookbook here (<a href="http://www.bitwalker.nl/blog/using-groovyserver-pages-in-dreamweaver" rel="nofollow noreferrer">http://www.bitwalker.nl/blog/using-groovyserver-pages-in-dreamweaver</a>) for getting GSPs partially working with Dreamweaver CS3, but many of the files and directories it references no longer appear to exist in CS4.</p>
[ { "answer_id": 4667847, "author": "igor", "author_id": 497648, "author_profile": "https://Stackoverflow.com/users/497648", "pm_score": 3, "selected": true, "text": "<documenttype id=\"GSP\" servermodel=\"JSP\" internaltype=\"Dynamic\" winfileextension=\"gsp\" macfileextension=\"gsp\" fil...
2009/01/03
[ "https://Stackoverflow.com/questions/408394", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33752/" ]
408,405
<p>I'm teaching myself some basic scraping and I've found that sometimes the URL's that I feed into my code return 404, which gums up all the rest of my code.</p> <p>So I need a test at the top of the code to check if the URL returns 404 or not.</p> <p>This would seem like a pretty straightfoward task, but Google's not giving me any answers. I worry I'm searching for the wrong stuff.</p> <p>One blog recommended I use this:</p> <pre><code>$valid = @fsockopen($url, 80, $errno, $errstr, 30); </code></pre> <p>and then test to see if $valid if empty or not.</p> <p>But I think the URL that's giving me problems has a redirect on it, so $valid is coming up empty for all values. Or perhaps I'm doing something else wrong.</p> <p>I've also looked into a "head request" but I've yet to find any actual code examples I can play with or try out. </p> <p>Suggestions? And what's this about curl?</p>
[ { "answer_id": 408414, "author": "Ross", "author_id": 29173, "author_profile": "https://Stackoverflow.com/users/29173", "pm_score": 3, "selected": false, "text": "if(($twitter_XML_raw=file_get_contents($timeline))==false){\n // Retrieve HTTP status code\n list($version,$status_code...
2009/01/03
[ "https://Stackoverflow.com/questions/408405", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
408,415
<p>I recently implemented a class like:</p> <pre><code>class TestClass : IDisposable { RegistryKey m_key; public TestClass() { m_key = Registry.CurrentUser.OpenSubKey("Software", false); } public void Dispose() { // m_key.Dispose(); IDisposable disp = m_key; disp.Dispose(); } } </code></pre> <p>If I uncomment the direct call to Dispose, I get error CS0117 ("'Microsoft.Win32.RegistryKey' does not contain a definition for 'Dispose'"). Some Googling led me to <a href="http://bytes.com/groups/net-c/521478-interface-implementation" rel="noreferrer">this thread</a>, where I learned what was going on, so I now understand the mechanics of it. The <a href="http://msdn.microsoft.com/en-us/library/microsoft.win32.registrykey.system.idisposable.dispose(VS.80).aspx" rel="noreferrer">MSDN</a> documentation suggests that the author would prefer that I call Close() instead of Dispose(), but doesn't explain why.</p> <p>What is the purpose of this pattern (which I think I've seen it in the IO classes as well)? In light of the fact that this was an intentional decision by the class author, how bad is the code above (the call to Dispose through the IDisposable interface)? It can't be too bad - after all, it's what would happen in a using statement, right?</p> <p>[edits: 1) changed title from "non-public" to "explicit" 2) removed the explicit implementation from my code, accidentally left in from experimentation]</p>
[ { "answer_id": 408424, "author": "Mark A. Nicolosi", "author_id": 1103052, "author_profile": "https://Stackoverflow.com/users/1103052", "pm_score": 5, "selected": true, "text": "public clas SomeClass : IEnumerable<SomeOtherClass>\n{\n public IEnumerator<SomeOtherClass> GetEnumerator (...
2009/01/03
[ "https://Stackoverflow.com/questions/408415", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10558/" ]
408,444
<p>I have noticed that my geocoder is inconsistent in the code shown below because before the "getLatLng" method is called I show 10 valid locations, but after this line of code the number of points that actually show up is different each time I search (same search criteria - fyi) Between 5 and 10 at random .. very strange</p> <p>Anyone have issues similar to this? If so how did you solve them?</p> <pre><code>geocoder = new GClientGeocoder(); geocoder.getLatLng(address, function(point) { if (point) { var icon = new GIcon(); var marker = new GMarker(point, { icon: icon }); GEvent.addListener(marker, 'click', function() { marker.openInfoWindowHtml(html); }); map.addOverlay(marker); </code></pre>
[ { "answer_id": 429111, "author": "Toran Billups", "author_id": 2701, "author_profile": "https://Stackoverflow.com/users/2701", "pm_score": 1, "selected": true, "text": "function preGeoCodeLookup(_xaddr, _xid, _xindex, _xhtml, _xstatus) {\n addPreCount();\n\n //don't change ...
2009/01/03
[ "https://Stackoverflow.com/questions/408444", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2701/" ]
408,452
<p>The code below is checking performance of three different ways to do same solution.</p> <pre><code> public static void Main(string[] args) { // for loop { Stopwatch sw = Stopwatch.StartNew(); int accumulator = 0; for (int i = 1; i &lt;= 100000000; ++i) { accumulator += i; } sw.Stop(); Console.WriteLine("time = {0}; result = {1}", sw.ElapsedMilliseconds, accumulator); } //Enumerable.Range { Stopwatch sw = Stopwatch.StartNew(); var ret = Enumerable.Range(1, 100000000).Aggregate(0, (accumulator, n) =&gt; accumulator + n); sw.Stop(); Console.WriteLine("time = {0}; result = {1}", sw.ElapsedMilliseconds, ret); } //self-made IEnumerable&lt;int&gt; { Stopwatch sw = Stopwatch.StartNew(); var ret = GetIntRange(1, 100000000).Aggregate(0, (accumulator, n) =&gt; accumulator + n); sw.Stop(); Console.WriteLine("time = {0}; result = {1}", sw.ElapsedMilliseconds, ret); } } private static IEnumerable&lt;int&gt; GetIntRange(int start, int count) { int end = start + count; for (int i = start; i &lt; end; ++i) { yield return i; } } } </code></pre> <p>The results are:</p> <pre><code>time = 306; result = 987459712 time = 1301; result = 987459712 time = 2860; result = 987459712 </code></pre> <p>It is not surprising that the "for loop" is faster than the other two solutions, because Enumerable.Aggregate takes more method invocations. However, it really surprises me that "Enumerable.Range" is faster than the "self-made IEnumerable". I thought that Enumerable.Range would have more overhead than the simple GetIntRange method.</p> <p>What are the possible reasons for this?</p>
[ { "answer_id": 408494, "author": "yfeldblum", "author_id": 12349, "author_profile": "https://Stackoverflow.com/users/12349", "pm_score": 5, "selected": true, "text": "Enumerable.Range GetIntRange Enumerable.Range public static class Enumerable {\n public static IEnumerable<int> Range(...
2009/01/03
[ "https://Stackoverflow.com/questions/408452", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26349/" ]
408,456
<p>I'm using Hibernate's implementation of JPA and am seeing poor performance as multiple SQL queries are issued for each entity that is fetched. If I use a joined JPA query it generates just one SQL query but doesn't find rows will null relationship.</p> <p>Example, consider this simple schema. A person lives at an address and is employed by a company. Both address and employer are optional and can thus be null.</p> <pre><code>@Entity public class Person { public name; @ManyToOne @Column(nullable=true) public Address address @ManyToOne @Column(nullable=true) public Company employer } @Entity public class Address { address attributes ... } @Entity public class Company { company attributes ... } </code></pre> <p>Not shown above is that each JPA entity has some sort of ID (key):</p> <pre><code>@Id public Integer id; </code></pre> <p>The problem I'm seeing is that a single JPA query on Person results in multiple SQL queries on the database. For example, the following JPA query:</p> <pre><code>select p from Person p where ... </code></pre> <p>results in the SQL query:</p> <pre><code>select ... from Person where ... </code></pre> <p>and also the following pair of SQL queries for <strong>each</strong> retrieved person:</p> <pre><code>select ... from Address a where a.id=xxx select ... from Company c where c.id=yyy </code></pre> <p>This has a huge impact on performance. If the query result set is 1000 people, then it generates 1+1000+1000=2001 SQL queries.</p> <p>So I tried optimizing the JPA query by forcing it to join:</p> <pre><code>select p from Person p join p.address a join p.employer e where ... </code></pre> <p>or:</p> <pre><code>select p, a, e from Person p join p.address a join p.employer e where ... </code></pre> <p>This results in one single SQL query with a bunch of joins. The problem is if address or employer is null, then the joined query won't find it.</p> <p>So I'm left with either using the join-less query which is slow, or the fast joined query that doesn't retrieve rows will null relationships. I must be missing something here. Surely there's a way for fast and complete querying.</p>
[ { "answer_id": 408518, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": true, "text": "SELECT p FROM Person p LEFT JOIN p.address a LEFT JOIN p.employer e WHERE...\n" } ]
2009/01/03
[ "https://Stackoverflow.com/questions/408456", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24396/" ]
408,467
<p>The MySQL documentation isn't very clear on this. I want to add an index to an existing table. The table is a user table with the login id and password and I want to create an index for this to optimize logging in.</p> <p>This is how I thought I would try it: </p> <pre><code>mysql&gt; ALTER TABLE `users` ADD INDEX(`name`,`password`); </code></pre> <p>This created:</p> <pre><code>mysql&gt; show index from karmerd.users; +-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+ | Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | +-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+ | users | 0 | PRIMARY | 1 | id | A | 2 | NULL | NULL | | BTREE | | | users | 1 | name | 1 | name | A | 2 | NULL | NULL | | BTREE | | | users | 1 | name | 2 | password | A | 2 | NULL | NULL | YES | BTREE | | +-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+ </code></pre> <p>Did this achieve what I was trying to do? (Optimize logging in?) Previously I only had a primary key on an a field called 'id'.</p>
[ { "answer_id": 408479, "author": "Bill Karwin", "author_id": 20860, "author_profile": "https://Stackoverflow.com/users/20860", "pm_score": 4, "selected": true, "text": "name name password EXPLAIN" } ]
2009/01/03
[ "https://Stackoverflow.com/questions/408467", "https://Stackoverflow.com", "https://Stackoverflow.com/users/66475/" ]
408,480
<p>Ever since Microsoft has introduced the application blocks, I've been bumping into people who use the <a href="http://msdn.microsoft.com/en-us/library/dd203116.aspx" rel="noreferrer">Exception Handling Application Block</a>. I've recently had a closer look myself and would summarize the basic functionality as follows (skip the following block if you already know what it does):</p> <blockquote> <p>The exception handling application block aims to centralize and make fully configurable with config files the following <a href="http://msdn.microsoft.com/en-us/library/dd203198.aspx" rel="noreferrer">key exception handling tasks</a>:</p> <ul> <li>Logging an Exception</li> <li>Replacing an Exception</li> <li>Wrapping an Exception</li> <li>Propagating an Exception</li> <li>etc.</li> </ul> <p>The library does that by having you modify your try catch blocks as follows:</p> <pre><code>try { // Run code. } catch(DataAccessException ex) { bool rethrow = ExceptionPolicy.HandleException(ex, "Data Access Policy"); if (rethrow) { throw; } } </code></pre> <p>Based on what is specified in the app.config for the policy name (<a href="http://msdn.microsoft.com/en-us/library/dd139868.aspx" rel="noreferrer">see here for docs</a>), HandleException will either ...</p> <ul> <li>throw a completely new exception (replace the original exception)</li> <li>wrap the original exception in a new one and throw that</li> <li>swallow the exception (i.e. do nothing)</li> <li>have you rethrow the original exception</li> </ul> <p>Additionally you can also configure it to do more stuff beforehand (e.g. log the exception).</p> </blockquote> <p>Now here's my problem: I completely fail to see how it can be beneficial to make it configurable whether an exception is replaced, wrapped, swallowed or rethrown. In my experience, this decision must be made at the time you write the code because you'll typically have to change the surrounding or calling code when you change the exception handling behavior.</p> <p>For example, your code will likely start to behave incorrectly when you reconfigure such that a particular exception thrown at a particular point is now swallowed instead of rethrown (there might be code after the catch block that must not be executed when the exception occurs). The same goes for all other possible changes in exception handling (e.g. replace -> rethrow, swallow -> wrap).</p> <p>So, to me the bottom line is that the exception handling block solves problems that really don't exist in practice. The exception logging and notifying bit is fine, but isn't all the other stuff just a perfect example for overengineering?</p>
[ { "answer_id": 408506, "author": "yfeldblum", "author_id": 12349, "author_profile": "https://Stackoverflow.com/users/12349", "pm_score": 5, "selected": true, "text": "ArgumentException MyLibraryException" }, { "answer_id": 2107843, "author": "Randy Levy", "author_id": 114...
2009/01/03
[ "https://Stackoverflow.com/questions/408480", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
408,482
<p>I'm stuck on a RegEx problem that's seemingly very simple and yet I can't get it working.</p> <p>Suppose I have input like this:</p> <pre><code>Some text %interestingbit% lots of random text lots and lots more %anotherinterestingbit% Some text %interestingbit% lots of random text OPTIONAL_THING lots and lots more %anotherinterestingbit% Some text %interestingbit% lots of random text lots and lots more %anotherinterestingbit% </code></pre> <p>There are many repeating blocks in the input and in each block I want to capture some things that are always there (%interestingbit% and %anotherinterestingbit%), but there is also a bit of text that may or may not occur in-between them (OPTIONAL_THING) and I want to capture it if it's there.</p> <p>A RegEx like this matches only blocks with OPTIONAL_THING in it (and the named capture works):</p> <pre><code>%interestingbit%.+?((?&lt;OptionalCapture&gt;OPTIONAL_THING)).+?%anotherinterestingbit% </code></pre> <p>So it seems like it's just a matter of making the whole group optional, right? That's what I tried:</p> <pre><code>%interestingbit%.+?((?&lt;OptionalCapture&gt;OPTIONAL_THING))?.+?%anotherinterestingbit% </code></pre> <p>But I find that although this matches all 3 blocks the named capture (OptionalCapture) is empty in all of them! How do I get this to work?</p> <p>Note that there can be a lot of text within each block, including newlines, which is why I put in ".+?" rather than something more specific. I'm using .NET regular expressions, testing with The Regulator.</p>
[ { "answer_id": 408524, "author": "strager", "author_id": 39992, "author_profile": "https://Stackoverflow.com/users/39992", "pm_score": 0, "selected": false, "text": "%interestingbit%.+?(?<OptionalCapture>OPTIONAL_THING)?.+?%anotherinterestingbit%\n %interestingbit%.+?(?<OptionalCapture>O...
2009/01/03
[ "https://Stackoverflow.com/questions/408482", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20336/" ]
408,501
<p>I need to do this.</p> <pre><code>public class MyClass{ private static IDictionary&lt;String, Type&gt; databaseAccessClasses = new Dictionary&lt;String, Type&gt;(); private static IDictionary&lt;String, Type&gt; DatabaseAccessClasses { get { return DataAccessFactory.databaseAccessClasses; } set { DataAccessFactory.databaseAccessClasses = value; } } } </code></pre>
[ { "answer_id": 411001, "author": "mmmmmmmm", "author_id": 44086, "author_profile": "https://Stackoverflow.com/users/44086", "pm_score": 3, "selected": false, "text": "CSharpCodeProvider codeProvider = new CSharpCodeProvider();\nCodeCompileUnit compileUnit = new CodeCompileUnit();\nCodeNa...
2009/01/03
[ "https://Stackoverflow.com/questions/408501", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45481/" ]
408,530
<p>I'm trying to learn some C# over the weekend and am following the 15 exercises found here: <a href="http://www.jobsnake.com/seek/articles/index.cgi?openarticle&amp;8533" rel="nofollow noreferrer">http://www.jobsnake.com/seek/articles/index.cgi?openarticle&amp;8533</a></p> <p>Yesterday I asked a similar question for the Fibonacci sequence and received some great responses which introduced me to elements of C# which I'd not encountered before: <a href="https://stackoverflow.com/questions/406446/refactoring-fibonacci-algorithm">Refactoring Fibonacci Algorithm</a></p> <p>Today I would like to see how a C# Jedi would refactor the following code:</p> <pre><code>static string Reynolds(int d, int v, int rho, int mu) { int number = (d*v*rho) / mu; if (number &lt; 2100) return "Laminar Flow"; else if (number &lt; 2100 &amp;&amp; number &lt; 4000) return "Transient Flow"; else return "Turbulent Flow"; } </code></pre> <p>So more simple than yesterday, but is there any nice way to deal with the multiple conditionals?</p> <p>Regards,</p> <p>Chris</p>
[ { "answer_id": 408540, "author": "Charles Bretana", "author_id": 32632, "author_profile": "https://Stackoverflow.com/users/32632", "pm_score": 2, "selected": false, "text": " static string Reynolds(int d, int v, int rho, int mu)\n { \n int number = (d*v*rho) / mu; \n ...
2009/01/03
[ "https://Stackoverflow.com/questions/408530", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37196/" ]
408,541
<p>Last couple of days we were discussing at <a href="https://stackoverflow.com/questions/401191/how-to-return-random-items-restfully">another question</a> the best to manage randomness in a RESTful way; today I went to play a little bit with some ideas in Django only to find that there is no easy standard way of returning a 303 response (nor a 300 one, btw), that is, there doesn't seem to exist an HttpResponseSeeOther inside django.HTTP or in another place. </p> <p>Do you know any means for achieving this?</p>
[ { "answer_id": 408549, "author": "gak", "author_id": 11125, "author_profile": "https://Stackoverflow.com/users/11125", "pm_score": 6, "selected": true, "text": "class HttpResponseSeeOther(HttpResponseRedirect):\n status_code = 303\n\nreturn HttpResponseSeeOther('/other-url/')\n" }, ...
2009/01/03
[ "https://Stackoverflow.com/questions/408541", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34479/" ]
408,556
<p>I have an application that imports information from a CSV file or from a database and exports it to XML. This XML is currently being persisted to a file. However due to project needs I have decided it may be better to persist this XML to a database.</p> <p>Currently I have CSV, XML and SQL repositories that deal with importing/exporting data. The XML repository persists the passed in object to a file. It currently is where the mapping of the object to XML is stored, hence it is the only place that knows about this structure (likewise, the other repositories for their respective structures).</p> <p>Now that I want to store the XML in the database I am beginning to question this architecture. In order to do an insert into the database, the structure of the XML must be accessible from the SQL repository (n.b. data in other columns can be inserted into the DB along with the XML). This leads me to wonder if the XML representation should be stored in the object itself, or in a service layer or somewhere else.</p> <p>What are the best ways to implement a solution to this problem?</p> <p>UPDATE: A clarification to my question. The XML repository currently persists to a file. It seems to me that this is the wrong level to keep the knowledge of the structure of the XML at, as then I don't have flexibility in persisting the XML representation to whatever medium I desire. Is it poor design to let the object have knowledge of it's XML representation (or CSV representation, etc)? Should the knowledge of that structure be kept at another level, and what level would that be?</p>
[ { "answer_id": 408867, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 0, "selected": false, "text": "XmlSerializer" } ]
2009/01/03
[ "https://Stackoverflow.com/questions/408556", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34991/" ]
408,570
<p>I'm trying to parse an array of JSON objects into an array of strings in C#. I can extract the array from the JSON object, but I can't split the array string into an array of individual objects.</p> <p>What I have is this test string:</p> <pre><code>string json = "{items:[{id:0,name:\"Lorem Ipsum\"},{id:1,name" + ":\"Lorem Ipsum\"},{id:2,name:\"Lorem Ipsum\"}]}"; </code></pre> <p>Right now I'm using the following regular expressions right now to split the items into individual objects. For now they're 2 separate regular expressions until I fix the problem with the second one:</p> <pre><code>Regex arrayFinder = new Regex(@"\{items:\[(?&lt;items&gt;[^\]]*)\]\}" , RegexOptions.ExplicitCapture); Regex arrayParser = new Regex(@"((?&lt;items&gt;\{[^\}]\}),?)+" , RegexOptions.ExplicitCapture); </code></pre> <p>The <code>arrayFinder</code> regex works the way I'd expect it but, for reasons I don't understand, the <code>arrayParser</code> regex doesn't work at all. All I want it to do is split the individual items into their own strings so I get a list like this:</p> <blockquote> <p><code>{id:0,name:"Lorem Ipsum"}</code><br> <code>{id:1,name:"Lorem Ipsum"}</code><br> <code>{id:2,name:"Lorem Ipsum"}</code> </p> </blockquote> <p>Whether this list is a <code>string[]</code> array or a <code>Group</code> or <code>Match</code> collection doesn't matter, but I'm stumped as to how to get the objects split. Using the <code>arrayParser</code> and the <code>json</code> string declared above, I've tried this code which I assumed would work with no luck:</p> <pre><code>string json = "{items:[{id:0,name:\"Lorem Ipsum\"},{id:1,name" + ":\"Lorem Ipsum\"},{id:2,name:\"Lorem Ipsum\"}]}"; Regex arrayFinder = new Regex(@"\{items:\[(?&lt;items&gt;[^\]]*)\]\}" , RegexOptions.ExplicitCapture); Regex arrayParser = new Regex(@"((?&lt;items&gt;\{[^\}]\}),?)+" , RegexOptions.ExplicitCapture); string array = arrayFinder.Match(json).Groups["items"].Value; // At this point the 'array' variable contains: // {id:0,name:"Lorem Ipsum"},{id:1,name:"Lorem Ipsum"},{id:2,name:"Lorem Ipsum"} // I would have expected one of these 2 lines to return // the array of matches I'm looking for CaptureCollection c = arrayParser.Match(array).Captures; GroupCollection g = arrayParser.Match(array).Groups; </code></pre> <p>Can anybody see what it is I'm doing wrong? I'm totally stuck on this.</p>
[ { "answer_id": 408579, "author": "casperOne", "author_id": 50776, "author_profile": "https://Stackoverflow.com/users/50776", "pm_score": 3, "selected": false, "text": "DataContractJsonSerializer" }, { "answer_id": 1318189, "author": "Community", "author_id": -1, "auth...
2009/01/03
[ "https://Stackoverflow.com/questions/408570", "https://Stackoverflow.com", "https://Stackoverflow.com/users/392/" ]
408,582
<p>I have to call domain A.com (which sets the cookies with http) from domain B.com. All I do on domain B.com is (javascript): </p> <pre><code>var head = document.getElementsByTagName("head")[0]; var script = document.createElement("script"); script.src = "A.com/setCookie?cache=1231213123"; head.appendChild(script); </code></pre> <p>This sets the cookie on A.com on every browser I've tested, except Safari. Amazingly this works in IE6, even without the P3P headers.</p> <p>Is there any way to make this work in Safari?</p>
[ { "answer_id": 408942, "author": "roenving", "author_id": 23142, "author_profile": "https://Stackoverflow.com/users/23142", "pm_score": -1, "selected": false, "text": "<script type=\"text/javascript\">\n var head = document.getElementsByTagName(\"head\")[0];\n var script = document.cre...
2009/01/03
[ "https://Stackoverflow.com/questions/408582", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50394/" ]
408,592
<p>Is it possible to write a C function that does the following?</p> <ol> <li>Allocate a bunch of memory in the heap</li> <li>Writes machine code in it</li> <li>Executes those machines instructions</li> </ol> <p>Of course, I would have to restore the state of the stack to what it was prior to the execution of those machine instructions manually, but I want to know if this is feasible in first place.</p>
[ { "answer_id": 408599, "author": "Johannes Schaub - litb", "author_id": 34509, "author_profile": "https://Stackoverflow.com/users/34509", "pm_score": 2, "selected": false, "text": "mprotect man mprotect char *mem = malloc(sizeof(code));\nmprotect(mem, sizeof(code), PROT_READ|PROT_WRITE|P...
2009/01/03
[ "https://Stackoverflow.com/questions/408592", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46571/" ]
408,618
<p>I would like to know that i have an excel file with 18 sheets and it should be opend with any other versions.</p> <p>for example if i right click on the file and select open with open office the same is being opened. i would like to lock this.</p>
[ { "answer_id": 408599, "author": "Johannes Schaub - litb", "author_id": 34509, "author_profile": "https://Stackoverflow.com/users/34509", "pm_score": 2, "selected": false, "text": "mprotect man mprotect char *mem = malloc(sizeof(code));\nmprotect(mem, sizeof(code), PROT_READ|PROT_WRITE|P...
2009/01/03
[ "https://Stackoverflow.com/questions/408618", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
408,627
<p>I didn't give a lot of info in my last question.</p> <p>I've built llv8call from <a href="http://code.google.com/p/llv8call/" rel="nofollow noreferrer">http://code.google.com/p/llv8call/</a>, v0.4. I've gotten the known dependencies installed, being libxml-2.0 and libreadline. My dev system is Mac OS X 10.5. llv8call is built with Scons.</p> <p>When I attempt to run llv8call via ./llv8call, I get this error:</p> <pre><code>library loading error: org.coderepos.env is not found in : (loadBinary) </code></pre> <p>I am not sure how to troubleshoot this error. The author hasn't responded to me yet. I need some tips on how to troubleshoot this more than an explicit answer, though if someone has one it's very welcome.</p> <p>The files are installed to /usr/local/llv8call. There is a directory structure under llv8call/lib/llv8call/org/coderepos but it doesn't contain an "env" directory. My first guess is that whatever library its looking for at org.coderepos.env is supposed to be in this path, but "env" doesn't exist. If this sounds reasonable, it might be a place that I should start looking at but I need confirmation.</p>
[ { "answer_id": 408649, "author": "Paul", "author_id": 51102, "author_profile": "https://Stackoverflow.com/users/51102", "pm_score": 2, "selected": true, "text": "grep -r \"org.coderepos\" *|less\n Handle<Value> args[1];\nargs[0] = String::New(\"org.coderepos.fs\");\nloadBinary->Call(v8ex...
2009/01/03
[ "https://Stackoverflow.com/questions/408627", "https://Stackoverflow.com", "https://Stackoverflow.com/users/68788/" ]
408,646
<p>I have the following XAML code, which displays a <em>picture</em> (image inside borders) and a logo. Right now, the logo appears below the picture. This is expected, however <strong>my goal is to have the logo on top of the picture</strong> (precisely at the bottom-right corner). <strong>Does someone has an idea how to do that?</strong> Do we have layers in WPF?</p> <p>Note: I absolutely need to keep the WrapPanel.</p> <pre><code>&lt;WrapPanel&gt; &lt;Border BorderBrush="Gray" BorderThickness="1" Margin="3"&gt; &lt;Border BorderBrush="White" BorderThickness="3"&gt; &lt;Border BorderBrush="LightGray" BorderThickness="0.5"&gt; &lt;Image Source="http://farm1.static.flickr.com/2/1703693_687c42c89f_s.jpg" Stretch="Uniform" /&gt; &lt;/Border&gt; &lt;/Border&gt; &lt;/Border&gt; &lt;Image Source="http://l.yimg.com/g/images/flickr_logo_gamma.gif.v59899.14" Height="10" /&gt; &lt;/WrapPanel&gt; </code></pre>
[ { "answer_id": 408811, "author": "Steven Robbins", "author_id": 26507, "author_profile": "https://Stackoverflow.com/users/26507", "pm_score": 5, "selected": true, "text": "<WrapPanel>\n <Grid>\n <Border BorderBrush=\"Gray\" BorderThickness=\"1\" Margin=\"3\">\n <Bord...
2009/01/03
[ "https://Stackoverflow.com/questions/408646", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42024/" ]
408,652
<p>In eclipse, when I want to document a function (in java or javascript source) I can just type /**, then hit enter, and I get a comment like this</p> <pre><code> /** * * Fluctuates all variables to more compatibly foo all the bars * * @PARAM {int} foo */ function flucvar (foo) { } </code></pre> <p>When hitting enter inside the comment, eclipse automatically adds extra * at the beginning of each line.</p> <p>Now I'm just getting into my textmate groove, and finding myself missing this little bit of functionality. Is there an equivilent bundle or command or something that would allow me to produce similar comments in textmate?</p>
[ { "answer_id": 408714, "author": "mipadi", "author_id": 28804, "author_profile": "https://Stackoverflow.com/users/28804", "pm_score": 1, "selected": false, "text": "Help -> TextMate Help" }, { "answer_id": 408940, "author": "Niko Nyman", "author_id": 36817, "author_pr...
2009/01/03
[ "https://Stackoverflow.com/questions/408652", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51101/" ]
408,659
<pre><code>typeof(int).Name </code></pre> <p>Will return System.Int32 does anyone know of a way to return "int"</p>
[ { "answer_id": 48271526, "author": "Kody", "author_id": 1754995, "author_profile": "https://Stackoverflow.com/users/1754995", "pm_score": 2, "selected": false, "text": "CSharpCodeProvider" } ]
2009/01/03
[ "https://Stackoverflow.com/questions/408659", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45909/" ]
408,661
<p>When the Java compiler autoboxes a primitive to the wrapper class, what code does it generate behind the scenes? I imagine it calls:</p> <ul> <li>The valueOf() method on the wrapper</li> <li>The wrapper's constructor</li> <li>Some other magic?</li> </ul>
[ { "answer_id": 408668, "author": "Adam Rosenfield", "author_id": 9530, "author_profile": "https://Stackoverflow.com/users/9530", "pm_score": 7, "selected": true, "text": "javap public class AutoboxingTest\n{\n public static void main(String []args)\n {\n Integer a = 3;\n ...
2009/01/03
[ "https://Stackoverflow.com/questions/408661", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23572/" ]
408,670
<p>I've searched, but I've not understood very well these three concepts. When do I have to use dynamic allocation (in the heap) and what's its real advantage? What are the problems of static and stack? Could I write an entire application without allocating variables in the heap? </p> <p>I heard that others languages incorporate a "garbage collector" so you don't have to worry about memory. What does the garbage collector do? </p> <p>What could you do manipulating the memory by yourself that you couldn't do using this garbage collector?</p> <p>Once someone said to me that with this declaration:</p> <pre><code>int * asafe=new int; </code></pre> <p>I have a "pointer to a pointer". What does it mean? It is different of:</p> <pre><code>asafe=new int; </code></pre> <p>?</p>
[ { "answer_id": 408691, "author": "Johannes Schaub - litb", "author_id": 34509, "author_profile": "https://Stackoverflow.com/users/34509", "pm_score": 6, "selected": false, "text": "if(some condition) {\n int a[3]; // array a has automatic storage duration\n fill_it(a);\n print_i...
2009/01/03
[ "https://Stackoverflow.com/questions/408670", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50754/" ]
408,675
<p>I have an ASP.net project I'm looking at and they want to use MySQL. I'm used to SQL server but using mySQL shouldn't be a problem.</p> <p>Normally the control would like a SqlDataSource to bind to but that's not available with MySQL (from other posts on this site).</p> <p>What's the best way to connect MySQL and the DevExpress ASPxScheduler so that you can create appointments?</p>
[ { "answer_id": 419109, "author": "Jaydel Gluckie", "author_id": 2019606, "author_profile": "https://Stackoverflow.com/users/2019606", "pm_score": 1, "selected": false, "text": "protected void appointmentsDataSource_ObjectCreated(object sender, ObjectDataSourceEventArgs e)\n {\n ...
2009/01/03
[ "https://Stackoverflow.com/questions/408675", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2019606/" ]
408,712
<p>Is anyone aware of a sane way to get tablet/stylus pressure information on Windows?</p> <p>It's possible to distinguish stylus from mouse with ::GetMessageExtraInfo, but you can't get any more information beyond that. I also found the WinTab API in a out of the way corner of the Wacom site, but that's not part of windows as far as i can tell, and has a completely distinct event/messaging system from the message queue.</p> <p>Given all I want is the most basic pressure information surely there is a standard Win32/COM API, is anyone aware of what it might be?</p>
[ { "answer_id": 43852005, "author": "kalbr", "author_id": 1761726, "author_profile": "https://Stackoverflow.com/users/1761726", "pm_score": 2, "selected": false, "text": "const WORD wid = GET_POINTERID_WPARAM(wParam);\nPOINTER_INFO piTemp = {NULL};\nGetPointerInfo(wid, &piTemp);\nif (piTe...
2009/01/03
[ "https://Stackoverflow.com/questions/408712", "https://Stackoverflow.com", "https://Stackoverflow.com/users/784/" ]
408,734
<p>I need a very quick fix in a mod_rewrite expression for drupal we have</p> <pre><code> RewriteCond %{REQUEST_URI} !(\.gif)|(\.jpg)|(\.png)|(\.css)|(\.js)|(\.php)$ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !=/favicon.ico RewriteRule ^(.*)$ index.php?q=$1 [L,QSA] </code></pre> <p>But i need to redirect the value of the subdomain in get too so i need something that will give:</p> <pre><code> RewriteCond %{REQUEST_URI} !(\.gif)|(\.jpg)|(\.png)|(\.css)|(\.js)|(\.php)$ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !=/favicon.ico RewriteRule ^(.*)$ index.php?subdomain=THE SUBDOMAIN HERE&amp;q=$1 [L,QSA] </code></pre> <p>Don't know how to do it, please help!</p>
[ { "answer_id": 408737, "author": "gnud", "author_id": 27204, "author_profile": "https://Stackoverflow.com/users/27204", "pm_score": 0, "selected": false, "text": "'SERVER_NAME'\n The name of the server host under which the\n current script is executing. If the script\n is runnin...
2009/01/03
[ "https://Stackoverflow.com/questions/408734", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47846/" ]
408,744
<p>F12 is a wonder for tracking down UI blocking operations, but I can't figure out how to make it work with VS 2008 and managed code.</p> <p>Help! Or not...</p> <p>Edit: turns out it doesn't work in VS 2005 either on Vista x64, so I guess that either widens or narrows it down, depending on your perspective :(</p> <p>MSN</p>
[ { "answer_id": 446967, "author": "Milan Gardian", "author_id": 23843, "author_profile": "https://Stackoverflow.com/users/23843", "pm_score": 1, "selected": false, "text": "using System;\nusing System.Diagnostics;\nusing System.Drawing;\nusing System.Runtime.InteropServices;\nusing System...
2009/01/03
[ "https://Stackoverflow.com/questions/408744", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6210/" ]
408,749
<p>Is it possible to enforce uniqueness across two tables in MySQL?</p> <p>I have two tables, both describing users. The users in these tables were for two different systems previously, however now we're merging our authentication systems and I need to make sure that there are unique usernames across these two tables. (it's too much work to put them all into one table right now).</p>
[ { "answer_id": 408781, "author": "kmkaplan", "author_id": 50902, "author_profile": "https://Stackoverflow.com/users/50902", "pm_score": 2, "selected": false, "text": "create table users1 (\n user_id integer primary key,\n username varchar(8) not null unique\n);\ncreate table users2...
2009/01/03
[ "https://Stackoverflow.com/questions/408749", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9021/" ]
408,779
<p>I have 2 tables which in simplified form look like this:</p> <pre><code>Products( id: int, name: varchar ); ProductSpecs( product_id: int, spec_name: varchar, spec_value: int ); </code></pre> <p>Now I need to sort products (in linq to sql) by value of some specification item (eg. "price"). So I do something like this</p> <pre><code>var products = from p in db.Products from ps in p.ProductsSpecs where ps.spec_name == "price" orderby ps.spec_value select p; </code></pre> <p>The problem is that if there's no such ProductSpec with spec_name "price" the product is not included at all. I can add these products with Union or Concat but this way the sorting of the first part is not preserved.</p> <p>What is the best way to deal with this?</p> <p>Thanks.</p>
[ { "answer_id": 408861, "author": "Noah", "author_id": 47496, "author_profile": "https://Stackoverflow.com/users/47496", "pm_score": 4, "selected": true, "text": "select p.*\nfrom products p\nleft outer join productspecs ps on\n p.id = ps.product_id\n and ps.spec_name = 'Price'\nord...
2009/01/03
[ "https://Stackoverflow.com/questions/408779", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19546/" ]
408,810
<p>I have a wxPython application that relies on an external config file. I want provide friendly message dialogs that show up if there are any config errors. I've tried to make this work by wrapping my app.MainLoop() call in a try/except statement.</p> <p>The code below works for the init code in my MainWindow frame class, but doesn't catch any exceptions that occur within the MainLoop. How can I catch these exceptions as well?</p> <pre><code>if __name__ == '__main__': app = MyApp(0) try: MainWindow(None, -1, 'My Cool App') app.MainLoop() except ConfigParser.Error, error_message: messagebox = wx.MessageDialog(None, error_message, 'Configuration Error', wx.OK | wx.ICON_ERROR) messagebox.ShowModal() </code></pre> <p>I've read some mention of an OnExceptionInMainLoop method that can be overridden in the wx.App class, but the source I read must be out of date (2004) since wx.App no longer seems to have a method by that name.</p> <p><strong>EDIT:</strong></p> <p>I need to be able to catch unhandled exceptions during my mainloop so that I can further handle them and display them in error dialogs, not pass silently, and not terminate the app.</p> <p>The sys.excepthook solution is too low level and doesn't play nice with the wxPython mainloop thread. While the link to the other answer does the same try/except wrapping around the mainloop which doesn't work due, once again, to wxPython spawning a different thread for the app/ui.</p>
[ { "answer_id": 409266, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "(type, value, traceback)" }, { "answer_id": 12109646, "author": "bitman", "author_id": 415075, "author_pro...
2009/01/03
[ "https://Stackoverflow.com/questions/408810", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46914/" ]
408,820
<p>Can someone please explain me what's the difference between Swing and AWT?</p> <p>Are there any cases where AWT is more useful/advised to use than swing or vice-versa?</p>
[ { "answer_id": 16810355, "author": "Surendra Bharadwaj", "author_id": 2431861, "author_profile": "https://Stackoverflow.com/users/2431861", "pm_score": 3, "selected": false, "text": "JDialog JFrame JButton JTextArea" } ]
2009/01/03
[ "https://Stackoverflow.com/questions/408820", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29515/" ]
408,821
<p>I've seen this questions <a href="https://stackoverflow.com/questions/159366/is-there-a-best-coding-style-for-identations-same-line-next-line">here</a>. I'm wondering if there exists an official name for the following indent style:</p> <pre><code>void fooBar(String s) { while (true) { // ... do something } } </code></pre> <p>When the opening brace is in the same line as the control statement, the statements within are indented and the closing brace is on the same indentation level as the control statement, the style is called K&amp;R-Style. So is there a name for the indent style for the this code sample above?</p>
[ { "answer_id": 408829, "author": "Eli Bendersky", "author_id": 8206, "author_profile": "https://Stackoverflow.com/users/8206", "pm_score": 2, "selected": false, "text": "ansi" } ]
2009/01/03
[ "https://Stackoverflow.com/questions/408821", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49786/" ]
408,825
<p>I have a column which has a datatype : datetime. But now i want to convert it to datatype varchar. Can i alter the datatype without droppping the column? If yes, then please explain how?</p>
[ { "answer_id": 408832, "author": "capotej", "author_id": 1263, "author_profile": "https://Stackoverflow.com/users/1263", "pm_score": 3, "selected": false, "text": "ALTER TABLE YourTableNameHere ALTER COLUMN YourColumnNameHere VARCHAR(20)\n" }, { "answer_id": 408833, "author":...
2009/01/03
[ "https://Stackoverflow.com/questions/408825", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29515/" ]
408,834
<p>I have a form with checkboxes, each one has a value. When the registered user select any checkbox the value is incremented (the summation) and then then registred user save his</p> <p>selection of checkbox if he satisfied with the result of summation into database all this work fine ...i want to enable the registred user to view his selection history by retriving and displaying the checkboxes he selected in a page with thier values ... How I can do that? </p> <p>I'm just able to save the selected checkboxes as choice 1, choice 2, for example ..</p> <p>I want to view the selected checkboxes that is saved in database as the appear in the page when the user first select them: for example if the registred user selects these 3 options</p> <ul> <li>LEAD DEEP KEEL (1825)</li> <li>FULLY BATTENED MAINSAIL (558)</li> <li>TEAK SIDE DECKS (2889)</li> </ul> <p>They will be saved as for example (choice1, choice2, choice3).</p> <p>But if he want to view selected checkboxes the appear exactly as first he selects them:</p> <ul> <li>LEAD DEEP KEEL (1825)</li> <li>FULLY BATTENED MAINSAIL (558)</li> <li>TEAK SIDE DECKS (2889)</li> </ul> <p>This is my user table:</p> <pre><code>$query="CREATE TABLE User( user_id varchar(20), password varchar(40), user_type varchar(20), firstname varchar(30), lastname varchar(30), street varchar(50), city varchar(50), county varchar(50), post_code varchar(10), country varchar(50), gender varchar(6), dob varchar(15), tel_no varchar(50), vals varchar(50), email varchar(50))"; </code></pre> <p>and the code to inser the options selected to database</p> <pre><code>&lt;?php include("databaseconnection.php"); $str = ''; foreach($_POST as $key =&gt; $val) if (strpos($key,'choice') !== false) $str .= $key.','; $query = "INSERT INTO User (vals) VALUES('$str')"; $result=mysql_query($query,$conn); if ($result) { (mysql_error(); } else { echo " done"; } ?&gt; </code></pre> <p>And this is my form:</p> <p> function checkTotal() { document.listForm.total.value = ''; var sum = 0; for (i=0;i</p> <pre><code>&lt;form name="listForm" method="post" action="insert_options.php" &gt; &lt;TABLE cellPadding=3 width=600 border=0&gt; &lt;TBODY&gt; &lt;TR&gt; &lt;TH align=left width="87%" bgColor=#b0b3b4&gt;&lt;SPAN class=whiteText&gt;Item&lt;/SPAN&gt;&lt;/TH&gt; &lt;TH align=right width="13%" bgColor=#b0b3b4&gt;&lt;SPAN class=whiteText&gt;Select&lt;/SPAN&gt;&lt;/TH&gt;&lt;/TR&gt; &lt;TR&gt; &lt;TD bgcolor="#9da8af"colSpan=2&gt;&lt;SPAN class=normalText&gt;&lt;B&gt;General&lt;/B&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt; &lt;TR&gt; &lt;TD bgcolor="#c4c8ca"&gt;&lt;SPAN class=normalText &gt;TEAK SIDE DECKS (2889)&lt;/SPAN&gt;&lt;/TD&gt; &lt;TD align=right bgColor=#c4c8ca&gt;&lt;input name="choice" value="2889" type="checkbox" onchange="checkTotal()" /&gt;&lt;/TD&gt;&lt;/TR&gt; &lt;TR&gt; &lt;TD bgColor=#c4c8ca&gt;&lt;SPAN class=normalText&gt;LEAD DEEP KEEL (1825)&lt;/SPAN&gt;&lt;/TD&gt; &lt;TD align=right bgColor=#c4c8ca&gt;&lt;input name="choice" value="1825" type="checkbox" onchange="checkTotal()"&gt;&lt;/TD&gt;&lt;/TR&gt; &lt;TR&gt; &lt;TD bgColor=#c4c8ca&gt;&lt;SPAN class=normalText&gt;FULLY BATTENED MAINSAIL (558)&lt;/SPAN&gt;&lt;/TD&gt; &lt;TD align=right bgColor=#c4c8ca&gt;&lt;input name="choice" value="558" type="checkbox" onchange="checkTotal()"&gt;&lt;/TD&gt;&lt;/TR&gt; &lt;TR&gt; &lt;TD bgColor=#c4c8ca&gt;&lt;SPAN class=normalText&gt;HIGH TECH SAILS FOR CONVENTIONAL RIG (1979)&lt;/SPAN&gt;&lt;/TD&gt; &lt;TD align=right bgColor=#c4c8ca&gt;&lt;input name="choice" value="1979" type="checkbox" onchange="checkTotal()"&gt;&lt;/TD&gt;&lt;/TR&gt; &lt;TR&gt; &lt;TD bgColor=#c4c8ca&gt;&lt;SPAN class=normalText&gt;IN MAST REEFING WITH HIGH TECH SAILS (2539)&lt;/SPAN&gt;&lt;/TD&gt; &lt;TD align=right bgColor=#c4c8ca&gt;&lt;input name="choice" value="2539" type="checkbox" onchange="checkTotal()"&gt;&lt;/TD&gt;&lt;/TR&gt; &lt;TR&gt; &lt;TD bgColor=#c4c8ca&gt;&lt;SPAN class=normalText&gt;SPlNNAKER GEAR (POLE LINES DECK FITTINGS) (820)&lt;/SPAN&gt;&lt;/TD&gt; &lt;TD align=right bgColor=#c4c8ca&gt;&lt;input name="choice" value="820" type="checkbox" onchange="checkTotal()"&gt;&lt;/TD&gt;&lt;/TR&gt; &lt;TR&gt; &lt;TD bgColor=#c4c8ca&gt;&lt;SPAN class=normalText&gt;SPINNAKER POLE VERTICAL STOWAGE SYSTEM (214)&lt;/SPAN&gt;&lt;/TD&gt; &lt;TD align=right bgColor=#c4c8ca&gt;&lt;input name="choice" value="214" type="checkbox" onchange="checkTotal()"&gt;&lt;/TD&gt;&lt;/TR&gt; &lt;TR&gt; &lt;TD bgColor=#c4c8ca&gt;&lt;SPAN class=normalText&gt;GAS ROD KICKER (208)&lt;/SPAN&gt;&lt;/TD&gt; &lt;TD align=right bgColor=#c4c8ca&gt;&lt;input name="choice" value="208" type="checkbox" onchange="checkTotal()"&gt;&lt;/TD&gt;&lt;/TR&gt; &lt;TR&gt; &lt;TD bgColor=#c4c8ca&gt;&lt;SPAN class=normalText&gt;SIDE RAIL OPENINGS (BOTH SIDES) (392)&lt;/SPAN&gt;&lt;/TD&gt; &lt;TD align=right bgColor=#c4c8ca&gt;&lt;input name="choice" value="392" type="checkbox" onchange="checkTotal()"&gt;&lt;/TD&gt;&lt;/TR&gt; &lt;TR&gt; &lt;TD bgColor=#c4c8ca&gt;&lt;SPAN class=normalText&gt;SPRING CLEATS MIDSHIPS -ALUMIMIUM (148)&lt;/SPAN&gt;&lt;/TD&gt; &lt;TD align=right bgColor=#c4c8ca&gt;&lt;input name="choice" value="148" type="checkbox" onchange="checkTotal()"&gt;&lt;/TD&gt;&lt;/TR&gt; &lt;TR&gt; &lt;TD bgColor=#c4c8ca&gt;&lt;SPAN class=normalText&gt;ELECTRIC ANCHOR WINDLASS (1189)&lt;/SPAN&gt;&lt;/TD&gt; &lt;TD align=right bgColor=#c4c8ca&gt;&lt;input name="choice" value="1189" type="checkbox" onchange="checkTotal()"&gt; &lt;/TD&gt;&lt;/TR&gt; &lt;TR&gt; &lt;TD bgColor=#c4c8ca&gt;&lt;SPAN class=normalText&gt;ANCHOR CHAIN GALVANISED (50m) (202)&lt;/SPAN&gt;&lt;/TD&gt; &lt;TD align=right bgColor=#c4c8ca&gt;&lt;input name="choice" value="202" type="checkbox" onchange="checkTotal()"&gt; &lt;/TD&gt;&lt;/TR&gt; &lt;TR&gt; &lt;TD bgColor=#c4c8ca&gt;&lt;SPAN class=normalText&gt;ANCHOR CHAIN GALVANISED (50m) (1141)&lt;/SPAN&gt;&lt;/TD&gt; &lt;TD align=right bgColor=#c4c8ca&gt;&lt;input name="choice" value="1141" type="checkbox" onchange="checkTotal()"&gt;&lt;/TD&gt;&lt;/TR&gt; &lt;TR&gt; &lt;TD bgcolor="#9da8af"colSpan=2&gt;&lt;SPAN class=normalText&gt;&lt;B&gt;NAVIGATION &amp; ELECTRONICS&lt;/B&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt; &lt;TR&gt; &lt;TD bgcolor="#c4c8ca"&gt;&lt;SPAN class=normalText &gt;WIND VANE (STAINLESS STEEL)(41)&lt;/SPAN&gt;&lt;/TD&gt; &lt;TD align=right bgColor=#c4c8ca&gt;&lt;input name="choice" value="41" type="checkbox" onchange="checkTotal()" /&gt;&lt;/TD&gt;&lt;/TR&gt; &lt;TR&gt; &lt;TD bgColor=#c4c8ca&gt;&lt;SPAN class=normalText&gt;RAYMARINE ST6O LOG &amp; DEPTH (SEPARATE UNITS)(226)&lt;/SPAN&gt;&lt;/TD&gt; &lt;TD align=right bgColor=#c4c8ca&gt;&lt;input name="choice" value="226" type="checkbox" onchange="checkTotal()"&gt;&lt;/TD&gt;&lt;/TR&gt; &lt;TR&gt; &lt;TD bgcolor="#9da8af"colSpan=2&gt;&lt;SPAN class=normalText&gt;&lt;B&gt;ENGINES &amp; ELECTRICS&lt;/B&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt; &lt;TR&gt; &lt;TD bgColor=#c4c8ca&gt;&lt;SPAN class=normalText&gt;SHORE SUPPLY (220V) WITH 3 OUTLETS (EXCLUDJNG SHORE CABLE) (327)&lt;/SPAN&gt;&lt;/TD&gt; &lt;TD align=right bgColor=#c4c8ca&gt;&lt;input name="choice" value="327" type="checkbox" onchange="checkTotal()"&gt;&lt;/TD&gt;&lt;/TR&gt; &lt;TR&gt; &lt;TD bgColor=#c4c8ca&gt;&lt;SPAN class=normalText&gt;3rd BATTERY(14OA/H)(196)&lt;/SPAN&gt;&lt;/TD&gt; &lt;TD align=right bgColor=#c4c8ca&gt;&lt;input name="choice" value="196" type="checkbox" onchange="checkTotal()"&gt;&lt;/TD&gt;&lt;/TR&gt; &lt;TD bgColor=#c4c8ca&gt;&lt;SPAN class=normalText&gt;24 AMP BATTERY CHARGER (475)&lt;/SPAN&gt;&lt;/TD&gt; &lt;TD align=right bgColor=#c4c8ca&gt;&lt;input name="choice" value="475" type="checkbox" onchange="checkTotal()"&gt;&lt;/TD&gt;&lt;/TR&gt; &lt;TD bgColor=#c4c8ca&gt;&lt;SPAN class=normalText&gt;2 BLADED FOLDING PROPELLER (UPGRADE)(299)&lt;/SPAN&gt;&lt;/TD&gt; &lt;TD align=right bgColor=#c4c8ca&gt;&lt;input name="choice" value="299" type="checkbox" onchange="checkTotal()"&gt;&lt;/TD&gt;&lt;/TR&gt; &lt;TR&gt; &lt;TD bgcolor="#9da8af"colSpan=2&gt;&lt;SPAN class=normalText&gt;&lt;B&gt;BELOW DECKS/DOMESTIC&lt;/B&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt; &lt;TD bgColor=#c4c8ca&gt;&lt;SPAN class=normalText&gt;WARM WATER (FROM ENGINE &amp; 220V)(749)&lt;/SPAN&gt;&lt;/TD&gt; &lt;TD align=right bgColor=#c4c8ca&gt;&lt;input name="choice" value="749" type="checkbox" onchange="checkTotal()"&gt;&lt;/TD&gt;&lt;/TR&gt; &lt;TD bgColor=#c4c8ca&gt;&lt;SPAN class=normalText&gt;SHOWER IN AFT HEADS WITH PUMPOUT(446)&lt;/SPAN&gt;&lt;/TD&gt; &lt;TD align=right bgColor=#c4c8ca&gt;&lt;input name="choice" value="446" type="checkbox" onchange="checkTotal()"&gt;&lt;/TD&gt;&lt;/TR&gt; &lt;TD bgColor=#c4c8ca&gt;&lt;SPAN class=normalText&gt;DECK SUCTION DISPOSAL FOR HOLDINGTANK(166)&lt;/SPAN&gt;&lt;/TD&gt; &lt;TD align=right bgColor=#c4c8ca&gt;&lt;input name="choice" value="166" type="checkbox" onchange="checkTotal()"&gt;&lt;/TD&gt;&lt;/TR&gt; &lt;TD bgColor=#c4c8ca&gt;&lt;SPAN class=normalText&gt;REFRIGERATED COOLBOX (12V)(666)&lt;/SPAN&gt;&lt;/TD&gt; &lt;TD align=right bgColor=#c4c8ca&gt;&lt;input name="choice" value="666" type="checkbox" onchange="checkTotal()"&gt;&lt;/TD&gt;&lt;/TR&gt; &lt;TD bgColor=#c4c8ca&gt;&lt;SPAN class=normalText&gt;LFS SAFETY PACKAGE (COCKPIT HARNESS POINTS STAINLESS STEEL JACKSTAYS)(208)&lt;/SPAN&gt;&lt;/TD&gt; &lt;TD align=right bgColor=#c4c8ca&gt;&lt;input name="choice" value="208" type="checkbox" onchange="checkTotal()"&gt;&lt;/TD&gt;&lt;/TR&gt; &lt;TD bgColor=#c4c8ca&gt;&lt;SPAN class=normalText&gt;UPHOLSTERY UPGRADE IN SALOON (SUEDETYPE)(701)&lt;/SPAN&gt;&lt;/TD&gt; &lt;TD align=right bgColor=#c4c8ca&gt;&lt;input name="choice" value="701" type="checkbox" onchange="checkTotal()"&gt;&lt;/TD&gt;&lt;/TR&gt; &lt;TR&gt; &lt;TD bgcolor="#9da8af"colSpan=2&gt;&lt;SPAN class=normalText&gt;&lt;B&gt;NAVIGATION ELECTRONICS &amp; ELECTRICS&lt;/B&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt; &lt;TD bgColor=#c4c8ca&gt;&lt;SPAN class=normalText&gt;VHF RADIO AERIAL CABLED TO NAVIGATION AREA(178)&lt;/SPAN&gt;&lt;/TD&gt; &lt;TD align=right bgColor=#c4c8ca&gt;&lt;input name="choice" value="178" type="checkbox" onchange="checkTotal()"&gt;&lt;/TD&gt;&lt;/TR&gt; &lt;/table&gt; </code></pre>
[ { "answer_id": 408837, "author": "kmkaplan", "author_id": 50902, "author_profile": "https://Stackoverflow.com/users/50902", "pm_score": 1, "selected": false, "text": "UPDATE INSERT user_id $query = \"update User set val = '\" . mysql_real_escape_string($str)\n . \"' where user_id =...
2009/01/03
[ "https://Stackoverflow.com/questions/408834", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
408,855
<p>I have a database populated with 1 million objects. Each object has a 'tags' field - set of integers.</p> <p>For example:</p> <pre><code>object1: tags(1,3,4) object2: tags(2) object3: tags(3,4) object4: tags(5) </code></pre> <p>and so on.</p> <p>Query parameter is a set on integers, lets try q(3,4,5)</p> <pre><code>object1 does not match ('1' not in '3,4,5') object2 does not match ('2' not in '3,4,5') object3 matches ('3 and 4' in '3,4,5' ) object4 matches ('5' in '3,4,5' ) </code></pre> <p>How to select matched objects efficiently?</p>
[ { "answer_id": 408893, "author": "Vinko Vrsalovic", "author_id": 5190, "author_profile": "https://Stackoverflow.com/users/5190", "pm_score": 2, "selected": false, "text": ">>> a = set([1,2,3])\n>>> a\nset([1, 2, 3])\n>>> 1 in a\nTrue\n>>> set([1,2]) in a\nFalse\n>>> set([2,3]) & a\nset([...
2009/01/03
[ "https://Stackoverflow.com/questions/408855", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21152/" ]
408,866
<p>I need to store Python structures made of lists / dictionaries, tuples into a human-readable format. The idea is like using something similar to <a href="http://docs.python.org/library/pickle.html" rel="nofollow noreferrer">pickle</a>, but pickle is not human-friendly. Other options that come to my mind are <a href="http://en.wikipedia.org/wiki/Yaml" rel="nofollow noreferrer">YAML</a> (through <a href="http://pyyaml.org/" rel="nofollow noreferrer">PyYAML</a> and <a href="http://www.json.org/" rel="nofollow noreferrer">JSON</a> (through <a href="http://pypi.python.org/pypi/simplejson/" rel="nofollow noreferrer">simplejson</a>) serializers.</p> <p>Any other option that comes to your mind?</p>
[ { "answer_id": 408889, "author": "PEZ", "author_id": 44639, "author_profile": "https://Stackoverflow.com/users/44639", "pm_score": 5, "selected": true, "text": ">>> d = {'age': 27,\n... 'name': 'Joe',\n... 'numbers': [1, \n... 2, \n... 3,\n... 4,\...
2009/01/03
[ "https://Stackoverflow.com/questions/408866", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42636/" ]
408,868
<p>This is regarding SSRS engine. For my project we are not going to buy SQL server software. Instead of what I just want to know, is there any posibility to use only SSRS engine. So that I can have the ref. (DLL) And then I can use wherever I want.</p> <p>Please help on this.</p>
[ { "answer_id": 45571797, "author": "Ajay Kumar", "author_id": 6451051, "author_profile": "https://Stackoverflow.com/users/6451051", "pm_score": 0, "selected": false, "text": " using (Microsoft.Reporting.WebForms.LocalReport report = new LocalReport())\n {\n ...
2009/01/03
[ "https://Stackoverflow.com/questions/408868", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
408,872
<p>New to both Ruby and Rails but I'm book educated by now (which apparently means nothing, haha).</p> <p>I've got two models, Event and User joined through a table EventUser</p> <pre><code>class User &lt; ActiveRecord::Base has_many :event_users has_many :events, :through =&gt; :event_users end class EventUser &lt; ActiveRecord::Base belongs_to :event belongs_to :user #For clarity's sake, EventUser also has a boolean column "active", among others end class Event &lt; ActiveRecord::Base has_many :event_users has_many :users, :through =&gt; :event_users end </code></pre> <p>This project is a calendar, in which I have to keep track of people signing up and scratching their name out for a given event. I figure the many to many is a good approach, but I can't do something like this:</p> <pre><code>u = User.find :first active_events = u.events.find_by_active(true) </code></pre> <p>Because events don't actually HAVE that extra data, the EventUser model does. And while I could do:</p> <pre><code>u = User.find :first active_events = [] u.event_users.find_by_active(true).do |eu| active_events &lt;&lt; eu.event end </code></pre> <p>This seems to be contrary to "the rails way". Can anyone enlighten me, this has been bugging me for a long time tonight (this morning)?</p>
[ { "answer_id": 408913, "author": "Milan Novota", "author_id": 26123, "author_profile": "https://Stackoverflow.com/users/26123", "pm_score": 8, "selected": true, "text": "has_many :active_events, :through => :event_users, \n :class_name => \"Event\", \n :source => :even...
2009/01/03
[ "https://Stackoverflow.com/questions/408872", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13257/" ]
408,898
<p>intro: I am pretty sure this is my fault. But I just don't see it and before tearing my hair out, I thought I should ask here ;)</p> <p>I have a button which looks like this in my ASPX:</p> <pre><code>&lt;input onClick="ELB_ClearSelection('DropDownList___00178');" type="Button" value="Clear" /&gt; </code></pre> <p>The HTML that is generated says:</p> <pre><code>&lt;input onClick="ELB_ClearSelection("DropDownList___00178");" type="Button" value="Clear" /&gt; </code></pre> <p>...which obviously does not work :(</p> <p>I ran the thing through HTML Validator and apart from the 'usual' complaints (related to it not fully 'understanding' ASPX) I did not see anything special, I have progrrammatically checked for balanced quotes and did not see anything suspicious, so I have no ideas where to look further :(</p> <p>In case it helps, here is the full ASPX:</p> <pre><code>&lt;%@ Register tagPrefix="des" assembly="PeterBlum.DES" namespace="PeterBlum.DES" %&gt; &lt;%@ Register tagPrefix="despval" assembly="PeterBlum.DES.NativeToDES" namespace="PeterBlum.DES.NativeToDES" %&gt; &lt;%@Page Language="apl" Debug="true" Inherits="COPA" src="COPA_MS.dws" %&gt; &lt;%@ Register TagPrefix="mbcbb" Namespace="MetaBuilders.WebControls" Assembly="MetaBuilders.WebControls.ComboBox" %&gt; &lt;%@ Register TagPrefix="ELB" Namespace="ELB" Assembly="EasyListBox" %&gt; &lt;html&gt;&lt;head&gt; &lt;meta name="date" content="2009-01-03T10:55:39" /&gt; &lt;meta name="generator" content="COPA_MS.DWS" defs="(11)(13)(14)" /&gt; &lt;meta name="publisher" content="Dynamic Logistics Systems GmbH" /&gt; &lt;meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" /&gt; &lt;title&gt; COPA_MS - Dispogruppen &lt;/title&gt; &lt;link rel="stylesheet" type="text/css" href="./copa.css" /&gt; &lt;script language="javascript" type="text/javascript" src="custom-form-elements.js"&gt;&lt;/script&gt; &lt;/head&gt;&lt;body&gt; &lt;h1&gt; &lt;span class="copa"&gt;COPA-&lt;/span&gt;&lt;span class="ms"&gt;MS:&lt;/span&gt; Dispogruppen &lt;/h1&gt; &lt;form runat=server&gt;&lt;des:PageSecurityValidator id="PageSecurityValidator1" runat="server" &gt; &lt;/des:PageSecurityValidator&gt; &lt;input runat="server" type="hidden" NAME="SelMaskeId" value="11" ID=SelMaskeID&gt; &lt;input runat="server" type="hidden" NAME="TreffId" value="13" ID=TreffID&gt; &lt;table&gt; &lt;tr&gt; &lt;td valign="top"&gt;&lt;asp:Label runat="server" ID="Label__________00176" Text="Code Dispogruppe" /&gt; &lt;/td&gt;&lt;td&gt;&lt;elb:EasyListBox runat="server" ID="ComboBox_______00176" Text="" MaxLength="6" Width="100" SelectQuery="***" ConnectionStringSqlServer="xxx" DataValueField="code" DataTextField="code" DisplayMode="Combo" LimitToList="false" &gt;&lt;/elb:EasyListBox&gt;&lt;/td&gt; &lt;/tr&gt;&lt;tr&gt; &lt;td valign="top"&gt;&lt;asp:Label runat="server" ID="Label__________00177" Text="Bezeichnung" /&gt; &lt;/td&gt;&lt;td&gt;&lt;elb:EasyListBox runat="server" ID="ComboBox_______00177" Text="" MaxLength="50" Width="210" SelectQuery="***" ConnectionStringSqlServer="xxx" DataValueField="bez" DataTextField="bez" DisplayMode="Combo" LimitToList="false" &gt;&lt;/elb:EasyListBox&gt;&lt;/td&gt; &lt;/tr&gt;&lt;tr&gt; &lt;td valign="top"&gt;&lt;asp:Label runat="server" ID="Label__________00178" Text="Lieferant" /&gt; &lt;/td&gt;&lt;td&gt;&lt;elb:EasyListBox runat="server" ID="DropDownList___00178" Text="" MaxLength="0" Width="210" SelectQuery="***" ConnectionStringSqlServer="xxx" DataValueField="id" DataTextField="bez"&gt;&lt;/elb:EasyListBox&gt; &lt;input type="Button" value='Auswahl entfernen' onClick='ELB_ClearSelection("DropDownList___00178");' /&gt; &lt;/td&gt; &lt;/tr&gt;&lt;tr&gt; &lt;td valign="top"&gt;&lt;asp:Label runat="server" ID="Label__________00182" Text="Dispo-Verfahren" /&gt; &lt;/td&gt;&lt;td&gt;&lt;elb:EasyListBox runat="server" ID="DropDownList___00182" Text="" MaxLength="0" Width="280 " Tref_Width="280" Tref_MaxLength="200" s_left="" s_top="" s_position="" css_sl="" css_tl="" css_dt="" SelectQuery="***" ConnectionStringSqlServer="xxx" DataValueField="id" DataTextField="bez"&gt;&lt;/elb:EasyListBox&gt; &lt;input type="Button" value="Auswahl entfernen" onClick="ELB_ClearSelection('DropDownList___00182');" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt;&lt;br /&gt;&lt;br /&gt; &lt;asp:Button runat="server" ID="Button_Suchen" Text="Suchen" onClick="CatchAll_onClick" /&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
[ { "answer_id": 408921, "author": "OJ.", "author_id": 611, "author_profile": "https://Stackoverflow.com/users/611", "pm_score": 2, "selected": true, "text": "onClick='ELB_ClearSelection(\"DropDownList___00178\")'\n onClick=\"ELB_ClearSelection('DropDownList___00178')\"\n" } ]
2009/01/03
[ "https://Stackoverflow.com/questions/408898", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51127/" ]
408,908
<p>Are there any preprocessor symbols which allow something like</p> <pre><code>#if CLR_AT_LEAST_3.5 // use ReaderWriterLockSlim #else // use ReaderWriterLock #endif </code></pre> <p>or some other way to do this?</p>
[ { "answer_id": 408918, "author": "Frederick The Fool", "author_id": 32688, "author_profile": "https://Stackoverflow.com/users/32688", "pm_score": 5, "selected": true, "text": "VERSION2 VERSION3" }, { "answer_id": 408937, "author": "Marc Gravell", "author_id": 23354, "...
2009/01/03
[ "https://Stackoverflow.com/questions/408908", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9204/" ]
408,917
<p>I am creating an application in iPhone and I have several UIViews and layers in it. I am doing some animations using CAKeyframeAnimation class and since the animations have to be chained, I have overridden the animationDidStop method in UIView.</p> <p>I am getting the callbacks properly, however I just couldn't figure out how I can find which animation was ended so that I can start the next one. Only parameters to the callback function is a CAAnimation object and a boolean.</p> <p>I can workaround this problem by setting a property in the class and using an enum for the various animations I use. However I just wanted to know if there is any built in attributes in the callbacks which I can set in the CAKeyframeAnimation object and then refer the same in the callback.</p> <p>Any help would be greatly appreciated!</p>
[ { "answer_id": 409734, "author": "Brad Larson", "author_id": 19679, "author_profile": "https://Stackoverflow.com/users/19679", "pm_score": 4, "selected": false, "text": "[UIView beginAnimations:nil context:NULL];\n[UIView setAnimationDuration:ANIMATIONDURATIONINSECONDS];\n[UIView setAnim...
2009/01/03
[ "https://Stackoverflow.com/questions/408917", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51130/" ]
408,965
<p>I see console apps print colors and seen apps such as ffmpeg print text over itself instead of a new line. How do I print over an existing line? I want to display fps in my console app either at the very top or very bottom and have regular printfs go there and scroll normally.</p> <p>I need this for windows, but this is meant to be cross platform, so I will eventually have a linux and mac implementation.</p>
[ { "answer_id": 408968, "author": "kmkaplan", "author_id": 50902, "author_profile": "https://Stackoverflow.com/users/50902", "pm_score": 2, "selected": false, "text": "putchar(8); putchar(13);" }, { "answer_id": 408973, "author": "lImbus", "author_id": 32490, "author_p...
2009/01/03
[ "https://Stackoverflow.com/questions/408965", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
408,975
<p>The following code gives </p> <blockquote> <p>[: -ge: unary operator expected</p> </blockquote> <p>when </p> <pre><code>i=0 if [ $i -ge 2 ] then #some code fi </code></pre> <p>why?</p>
[ { "answer_id": 605138, "author": "vladr", "author_id": 66516, "author_profile": "https://Stackoverflow.com/users/66516", "pm_score": 8, "selected": false, "text": "$i if [ \"$i\" -ge 2 ] ; then\n ...\nfi\n if [ $i -ge 2 ] ; then ...\n $i $i $i $i if [ -ge 2 ] ; then ...\n -gt $i if ...
2009/01/03
[ "https://Stackoverflow.com/questions/408975", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39106/" ]
408,978
<p>I'm trying to find any JavaScript frameworks whose sole aim is to standardize the DOM and JavaScript across all browsers.</p> <p>What I'm not looking for is frameworks which create their own API to solve these common problems. I want something that will allow me to call for example myElement.dispatchEvent("click") in Internet Explorer. Not something that creates its own observer pattern with its own API.</p> <p>At the moment the closest thing I can find is www.flowjs.com, this looks good and covers a lot but is missing document.createEvent and a few other features and supplies no contact information from the author.</p> <p>Regards,</p> <p>Chris</p>
[ { "answer_id": 409081, "author": "Alcides", "author_id": 28516, "author_profile": "https://Stackoverflow.com/users/28516", "pm_score": 0, "selected": false, "text": "window.alert = function(i) {};" } ]
2009/01/03
[ "https://Stackoverflow.com/questions/408978", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37196/" ]
408,985
<p>when i run this code :</p> <pre><code>CONADefinitions.CONAPI_FOLDER_INFO2 FolderInfo; int iResult = 0; IntPtr Buffer = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(CONADefinitions.CONAPI_FOLDER_INFO2))); iResult = CONAFileSystem.CONAFindNextFolder(hFindHandle, Buffer); while (iResult == PCCSErrors.CONA_OK ) { FolderInfo = (CONADefinitions.CONAPI_FOLDER_INFO2)Marshal.PtrToStructure(Buffer,typeof(CONADefinitions.CONAPI_FOLDER_INFO2)); //......................... i got an error msg here as follows: // Error Messege: FatalExecutionEngineError was detected Message: The runtime has encountered a fatal error. The address of the error was at 0x7a0ba769, on thread 0x1294. The error code is 0xc0000005. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack. </code></pre> <p>how to use CONADefinitions.CONAPI_FOLDER_INFO2, coz when i use CONADefinitions.CONAPI_FOLDER_INFO it only gives me the name and lable of the device but when is use CONADefinitions.CONAPI_FOLDER_INFO2 it gives me freeSize and TotalSize</p> <p>please help</p>
[ { "answer_id": 409040, "author": "Leon Tayson", "author_id": 18413, "author_profile": "https://Stackoverflow.com/users/18413", "pm_score": 3, "selected": true, "text": " DriveInfo di = new DriveInfo(\"f\"); //Put your mobile drive name\n long totalBytes = di.TotalSize;\n ...
2009/01/03
[ "https://Stackoverflow.com/questions/408985", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42782/" ]
408,987
<p>Can anybody clarify if Microsoft has released a [draft] specification of C# 4.0 yet? If so, where can I find/download it?</p>
[ { "answer_id": 409043, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 2, "selected": false, "text": "dynamic dynamic Expression" } ]
2009/01/03
[ "https://Stackoverflow.com/questions/408987", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28413/" ]
408,989
<p>I want to build a dialog in Java with a List and a couple of buttons underneath it. The list ends up with the same height as the buttons (about one line) and the whole dialog is about two lines of height.</p> <p>However, I'd like the dialog to be taller (maybe 10 lines) and the JList to take up most of the space .. I've played around with the parameters, but for the life of it can't get it to work. Any ideas? </p> <p>Here's my current code:</p> <pre><code>//layout setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.BOTH; int y = 0; //List gbc.gridx = 0; gbc.gridy = y; gbc.weighty = 3; gbc.weightx = 1; gbc.gridwidth= 3; add(new JScrollPane(_myList), gbc); _myList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // Buttons gbc.gridx = 1; gbc.gridy = ++y; gbc.gridwidth = 1; gbc.weighty = 0; add(_Save, gbc); gbc.gridx = 2; add(_Cancel, gbc); </code></pre>
[ { "answer_id": 412061, "author": "jfpoilpret", "author_id": 1440720, "author_profile": "https://Stackoverflow.com/users/1440720", "pm_score": 2, "selected": false, "text": "_myList.setVisibleRowCount(n)" } ]
2009/01/03
[ "https://Stackoverflow.com/questions/408989", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25320/" ]
408,998
<p>I'm playing around with MCE, I was wondering if there was the possibility of letting the user enter source code into a post, much like the 101010 button in this form.</p>
[ { "answer_id": 27865292, "author": "Midnightly Coder", "author_id": 1572717, "author_profile": "https://Stackoverflow.com/users/1572717", "pm_score": 5, "selected": false, "text": "tinymce.init({\n plugins: \"code\"\n});\n" }, { "answer_id": 48633699, "author": "Moji", ...
2009/01/03
[ "https://Stackoverflow.com/questions/408998", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
409,012
<p>i want to add tracking to my website. I saw google analytics which seems to track what i need. </p> <p>So do i stick the google analytics snippet in each page, in a master page, just in my default page? what is the best practice here to get the best metrics.</p>
[ { "answer_id": 409015, "author": "M4N", "author_id": 19635, "author_profile": "https://Stackoverflow.com/users/19635", "pm_score": 4, "selected": true, "text": "<!-- #include file=\"file_containing_google_analytics_code.js\" -->\n" } ]
2009/01/03
[ "https://Stackoverflow.com/questions/409012", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4653/" ]
409,025
<p>I want to make a mini timeline with jquery and for this timeline to have a width more than 32767 px. When I change it with jquery <code>$(".timelinecontainer").width(32767);</code> in Opera does not change it, but in others browsers it works. </p> <p>Can you give me advice on getting it to work in Opera ? </p>
[ { "answer_id": 410075, "author": "Borgar", "author_id": 27388, "author_profile": "https://Stackoverflow.com/users/27388", "pm_score": 0, "selected": false, "text": "width:9999em overflow:hidden scrollLeft() scrollLeft()" } ]
2009/01/03
[ "https://Stackoverflow.com/questions/409025", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51142/" ]
409,046
<p>We are using MySQL version 5.0 and most of the tables are InnoDB. We run replication to a slave server. We are thinking of backing up the MySQL log files on a daily basis.</p> <h1>Questions</h1> <ul> <li>Is there any other way of doing an incremental backup without using the log files?</li> <li>What are the best practices when doing incremental backups?</li> </ul>
[ { "answer_id": 64774206, "author": "Ivan", "author_id": 9210727, "author_profile": "https://Stackoverflow.com/users/9210727", "pm_score": 2, "selected": false, "text": "xtrabackup --backup --target-dir=/data/backups/inc1 --incremental-basedir=/data/backups/base\n mysqlbackup --incrementa...
2009/01/03
[ "https://Stackoverflow.com/questions/409046", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17560/" ]
409,049
<p>I have a controller action which I would like to call another controller action.</p> <p>Is this a valid thing to do. Is it possible?</p>
[ { "answer_id": 409051, "author": "yfeldblum", "author_id": 12349, "author_profile": "https://Stackoverflow.com/users/12349", "pm_score": 6, "selected": true, "text": "Controller.RedirectToAction" } ]
2009/01/03
[ "https://Stackoverflow.com/questions/409049", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46616/" ]
409,060
<p>(<em>Almost exact duplicate of <a href="https://stackoverflow.com/questions/408469/keeping-original-format-post-passing-through-awk">Keeping original format POST passing through AWK</a> submitted by same person.</em>)</p> <p>I have a simple question pertaining to <b>g</b>awk, illustrated below:</p> <pre><code> 1 int blah (void) 2 { 3 if (foo) { 4 printf ("blah\n"); 5 } 6 return 0; 7 } </code></pre> <p>Using the following gawk code - using gensub() to maintain original formatting:</p> <pre><code> gawk '{ print gensub($1, "\t", 1) }' ./sample_code.out int blah (void) { if (foo) { printf ("blah\n"); } return 0; } </code></pre> <p>How can I use <b>g</b>awk or awk (maybe with regular expressions) to remove previous whitespace before field $1 <b>(^ )</b></p> <p>Illustrated below:</p> <pre><code> int blah (void) { if (foo) { printf ("blah\n"); } return 0; } </code></pre> <p>Kind regards in advance</p>
[ { "answer_id": 409090, "author": "Zsolt Botykai", "author_id": 11621, "author_profile": "https://Stackoverflow.com/users/11621", "pm_score": 2, "selected": false, "text": "awk '{sub(/^[ \\t]+/, \"\"); print}'\n" }, { "answer_id": 409317, "author": "Jonathan Leffler", "aut...
2009/01/03
[ "https://Stackoverflow.com/questions/409060", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51078/" ]
409,069
<p>How do I get the size (free, total) of any drive on a Windows Mobile phone using C#?</p> <p>I need to do this with code running on the device (not on a connected PC).</p>
[ { "answer_id": 409143, "author": "ctacke", "author_id": 13154, "author_profile": "https://Stackoverflow.com/users/13154", "pm_score": 4, "selected": true, "text": "public class MyClass\n{\n [DllImport(\"coredll.dll\", SetLastError=true, CharSet=CharSet.Auto)]\n [return: MarshalAs(Unman...
2009/01/03
[ "https://Stackoverflow.com/questions/409069", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42782/" ]
409,076
<p>I'm trying to create nested Organizational Units in Active Directory and I'm close to having this working. I have a problem line below that I need help with. I'm checking if an OU exists and if not I need to create it, strOUArray contains OU=Test OU=Test2 and OU=Test3. I need the code to create OU=Test first and then use this as the parent OU on the //PROBLEM LINE below allowing the next OU OU=Test2 to be created inside OU=Test. Currently in the code below all OU's would be created in the root as I don't know how to use the first created OU in //PROBLEM LINE. I've tried using:</p> <pre><code>parent = new DirectoryEntry("LDAP://" + strOUArray[x-1] + "," + dcSubString); //note x-1 </code></pre> <p>This fails as the parent doesn't exist for the first OU to be created in. Any help really appreciated, I've a tight deadline and just need to move away from this so thank you for any help.</p> <pre><code>String strOUs = container.Substring(0, container.IndexOf(@",DC=")); int dcIndex = container.IndexOf("DC="); string dcSubString = container.Substring(dcIndex); //dcSubString = DC=Internal,DC=Net string[] strOUArray = strOUs.Split(new Char[] { ',' }); for (int x = 0; x &lt; strOUArray.Length; x++) { if (DirectoryEntry.Exists("LDAP://" + strOUArray[x] + "," + dcSubString)) { } else { DirectoryEntry objOU; DirectoryEntry parent = new DirectoryEntry("LDAP://" + dcSubString); //PROBLEM LINE objOU = parent.Children.Add(strOUArray[x], "OrganizationalUnit"); objOU.CommitChanges(); } } </code></pre>
[ { "answer_id": 409278, "author": "ecoffey", "author_id": 37838, "author_profile": "https://Stackoverflow.com/users/37838", "pm_score": 1, "selected": false, "text": "//PROBLEM LINE strOUArray[x] DirectoryEntry parent = new DirectoryEntry();\nparent = new DirectoryEntry(\"...\");\n Direct...
2009/01/03
[ "https://Stackoverflow.com/questions/409076", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
409,151
<p>I have a page where when some operation goes wrong i want to start the timer, wait 30 second, stop the timer and retry the operation. Every time the timer starts I need to inform the user about it by changing some label's text. </p> <p>How can I do it?</p>
[ { "answer_id": 409235, "author": "M4N", "author_id": 19635, "author_profile": "https://Stackoverflow.com/users/19635", "pm_score": 3, "selected": true, "text": " <script>\n function StartTimer()\n {\n setTimeout('DoPostBack()', 30000); // call DoPostBack in 30 seconds\n }\...
2009/01/03
[ "https://Stackoverflow.com/questions/409151", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40872/" ]
409,153
<p>What is the best function to use in php when grabbing the contents of a file. Currently Im using fopen but when I try to get the headers it uses roughly 2-3 seconds to get the headers. Would HTTPRequest be a better option?</p>
[ { "answer_id": 409180, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 3, "selected": true, "text": "curl_setopt($myCurlResource, CURLOPT_HEADER, true)" }, { "answer_id": 409990, "author": "Community", "author_i...
2009/01/03
[ "https://Stackoverflow.com/questions/409153", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4985/" ]
409,162
<p>When doing a simple performance measurement, I was astonished to see that calling <code>String.IndexOf(char)</code> was actually slower than doing it manually! Is this really true?! Here is my test code:</p> <pre><code>const string str = @"91023m lkajsdfl;jkasdf;piou-09324\\adf \asdf\45\ 65u\ 86\ 8\\\;"; static int testIndexOf() { return str.IndexOf('\\'); } static int testManualIndexOf() { string s = str; for (int i = 0; i &lt; s.Length; ++i) if (s[i] == '\\') return i; return -1; } </code></pre> <p>I ran each method 25 million times, and measured the time using a <code>Stopwatch</code>. The manual version was consistently 25% faster than the other one.</p> <p>Any thoughts?!</p> <hr> <p><strong>Edit 2:</strong> Running the tests on a different machine with .NET 4.0 yields results very similar to those in Marc Gravell's answer. <strong><code>String.IndexOf(char)</code></strong> <em>is faster</em> than manual searching.</p> <hr> <p><strong>Edit:</strong> Today (Jan 4 '09) I wanted to check this issue in a more comprehensive way, so I created a new project, and wrote the code you'll find below. I got the following results when running release mode from cmd for 100 million iterations:</p> <pre><code> - String. IndexOf : 00:00:07.6490042 - MyString.PublicIndexOf : 00:00:05.6676471 - MyString.InternIndexOf : 00:00:06.1191796 - MyString.PublicIndexOf2: 00:00:09.1363687 - MyString.InternIndexOf2: 00:00:09.1182569 </code></pre> <p>I ran these tests at least 20 times, getting almost the same results every time. My machine is XP SP3, VS 2008 SP1, P4 3.0 GHz with no hyper-threading and 1 GB RAM. I find the results really strange. As you can see, <code>String.IndexOf</code> was about 33% slower than my <code>PublicIndexOf</code>. Even stranger, I wrote the same method as <code>internal</code>, and it was about 8% slower than the <code>public</code> one! I do not understand what's happening, and I hope you could help me understand!</p> <p>The testing code is below. (Sorry for the repeated code, but I found that using a delegate showed different timings, with the <code>public</code> and <code>internal</code> methods taking the same time.)</p> <pre><code>public static class MyString { public static int PublicIndexOf(string str, char value) { for (int i = 0; i &lt; str.Length; ++i) if (str[i] == value) return i; return -1; } internal static int InternIndexOf(string str, char value) { for (int i = 0; i &lt; str.Length; ++i) if (str[i] == value) return i; return -1; } public static int PublicIndexOf2(string str, char value, int startIndex) { if (startIndex &lt; 0 || startIndex &gt;= str.Length) throw new ArgumentOutOfRangeException("startIndex"); for (; startIndex &lt; str.Length; ++startIndex) if (str[startIndex] == value) return startIndex; return -1; } internal static int InternIndexOf2(string str, char value, int startIndex) { if (startIndex &lt; 0 || startIndex &gt;= str.Length) throw new ArgumentOutOfRangeException("startIndex"); for (; startIndex &lt; str.Length; ++startIndex) if (str[startIndex] == value) return startIndex; return -1; } } class Program { static void Main(string[] args) { int iterations = 100 * 1000 * 1000; // 100 millions char separator = '\\'; string str = @"91023m lkajsdfl;jkasdf;piou-09324\\adf \asdf\45\ 65u\ 86\ 8\\\;"; Stopwatch watch = new Stopwatch(); // test String.IndexOf int sum = 0; watch.Start(); for (int i = 0; i &lt; iterations; ++i) sum += str.IndexOf(separator); watch.Stop(); Console.WriteLine(" String. IndexOf : ({0}, {1})", watch.Elapsed, sum); // test MyString.PublicIndexOf sum = 0; watch.Reset(); watch.Start(); for (int i = 0; i &lt; iterations; ++i) sum += MyString.PublicIndexOf(str, separator); watch.Stop(); Console.WriteLine("MyString.PublicIndexOf : ({0}, {1})", watch.Elapsed, sum); // test MyString.InternIndexOf sum = 0; watch.Reset(); watch.Start(); for (int i = 0; i &lt; iterations; ++i) sum += MyString.InternIndexOf(str, separator); watch.Stop(); Console.WriteLine("MyString.InternIndexOf : ({0}, {1})", watch.Elapsed, sum); // test MyString.PublicIndexOf2 sum = 0; watch.Reset(); watch.Start(); for (int i = 0; i &lt; iterations; ++i) sum += MyString.PublicIndexOf2(str, separator,0); watch.Stop(); Console.WriteLine("MyString.PublicIndexOf2: ({0}, {1})", watch.Elapsed, sum); // test MyString.InternIndexOf2 sum = 0; watch.Reset(); watch.Start(); for (int i = 0; i &lt; iterations; ++i) sum += MyString.InternIndexOf2(str, separator,0); watch.Stop(); Console.WriteLine("MyString.InternIndexOf2: ({0}, {1})", watch.Elapsed, sum); } } </code></pre>
[ { "answer_id": 409206, "author": "Greg Beech", "author_id": 13552, "author_profile": "https://Stackoverflow.com/users/13552", "pm_score": 3, "selected": false, "text": "IndexOf IndexOf" }, { "answer_id": 409228, "author": "Bartek Szabat", "author_id": 23774, "author_p...
2009/01/03
[ "https://Stackoverflow.com/questions/409162", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41283/" ]
409,173
<p>How do I import a CSV file using OpenOffice.org APIs? I want to do this using the same functionality that is also provided when I open the same file using "CVS text" filter.</p>
[ { "answer_id": 409206, "author": "Greg Beech", "author_id": 13552, "author_profile": "https://Stackoverflow.com/users/13552", "pm_score": 3, "selected": false, "text": "IndexOf IndexOf" }, { "answer_id": 409228, "author": "Bartek Szabat", "author_id": 23774, "author_p...
2009/01/03
[ "https://Stackoverflow.com/questions/409173", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51162/" ]
409,198
<p>I remember someone saying if you create a class through a lib you should destroy it through the library. So, does this mean I shouldn't call delete? I should call <code>myclass.deleteMe()</code> instead? Would overloading delete solve the problem?</p>
[ { "answer_id": 409205, "author": "ChrisW", "author_id": 49942, "author_profile": "https://Stackoverflow.com/users/49942", "pm_score": 3, "selected": true, "text": "delete this; operator delete" }, { "answer_id": 409215, "author": "Johannes Schaub - litb", "author_id": 345...
2009/01/03
[ "https://Stackoverflow.com/questions/409198", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
409,213
<p>I want to create a view that has different displays according to the role the user is in. </p> <p>Should I create a different view for different roles or should I check the roles on the Veiw page itself rather than in the actions?</p> <p>How would I check the role on the view page?</p>
[ { "answer_id": 409249, "author": "Wayne Molina", "author_id": 40667, "author_profile": "https://Stackoverflow.com/users/40667", "pm_score": 0, "selected": false, "text": "<% if @user.admin? # is the user an admin %>\n <h3>Admin Tools</h3>\n<% end %>\n<p>Regular site content</p>\n" }, ...
2009/01/03
[ "https://Stackoverflow.com/questions/409213", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43838/" ]