qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
194,077
<p>I've just recently setup a custom replication for my subscriber database, as described in <a href="https://stackoverflow.com/questions/161890/how-do-you-track-the-time-of-replicated-rows-for-subscribers-in-sql-server-2005">another post here</a>. Basically, when the publisher pushes a new record to the subscribers, the stored procedure will also insert a replicated time into an extra column in the table, and insert a new record to a log table.</p> <p>My problem occurs when trying to replicate the log table back to the main publication database. This is what I did:</p> <ol> <li>In the database where the log table is located, I setup a new transactional replication, and set it to create a snapshot.</li> <li>Once the publication is created, I create a new push subscription, and set it to initialize immediately.</li> <li>Once the subscription is created, I checked the synchronization status and confirm that the snapshot is applied successfully.</li> </ol> <p>Now here's the weird part: if I manually add a record to the log table using the SQL Server Management Studio, the record will be replicated fine. If the record is added by the custom replication stored procedure, it will not. The status will always display "No replicated transactions are available".</p> <p>I have no clue why the publication is behaving this way: I really don't see how it is treating the data inserted by the custom replication stored procedure differently.</p> <p>Can someone explain what may I've done wrong?</p> <p><strong>UPDATE:</strong> I finally have an answer for this problem a few months ago, just that I never got around to update this question. We have to log a support call to Microsoft, but we got a working solution.</p> <p><hr> <strong>ANSWER:</strong> To resolve the problem, when adding a subscription, you need to run the script like below:</p> <pre><code>sp_addsubscription @publication = 'TEST', ..., @loopback_detection = 'false' </code></pre> <p>The key to the solution is the last parameter shown above. By default, the generated subscription script will not have this parameter. </p>
[ { "answer_id": 649814, "author": "alextansc", "author_id": 19582, "author_profile": "https://Stackoverflow.com/users/19582", "pm_score": 2, "selected": true, "text": "sp_addsubscription @publication = 'TEST', ..., @loopback_detection = 'false'\n" } ]
2008/10/11
[ "https://Stackoverflow.com/questions/194077", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19582/" ]
194,089
<p>Say I've got a string which contains a number. I want to check if this number is an integer.</p> <h3>Examples</h3> <pre><code>IsInteger(&quot;sss&quot;) =&gt; false IsInteger(&quot;123&quot;) =&gt; true IsInterger(&quot;123.45&quot;) =&gt;false </code></pre>
[ { "answer_id": 194091, "author": "mattlant", "author_id": 14642, "author_profile": "https://Stackoverflow.com/users/14642", "pm_score": 4, "selected": false, "text": " int val;\nif(int.TryParse(inputString, out val))\n{\n //dosomething\n}\n" }, { "answer_id": 194097, "auth...
2008/10/11
[ "https://Stackoverflow.com/questions/194089", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
194,101
<p>I'd like to track changes in inputs in a form via javascript. My intent is (but not limited) to</p> <ul> <li>enable "save" button only when something has changed</li> <li>alert if the user wants to close the page and something is not saved</li> </ul> <p>Ideas?</p>
[ { "answer_id": 194110, "author": "nickf", "author_id": 9021, "author_profile": "https://Stackoverflow.com/users/9021", "pm_score": 6, "selected": true, "text": "onchange" }, { "answer_id": 194112, "author": "Dylan Beattie", "author_id": 5017, "author_profile": "https:...
2008/10/11
[ "https://Stackoverflow.com/questions/194101", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19224/" ]
194,102
<p>We have a web service that is deployed on 2 separate machines in different locations. Is it possible to monitor the url that a person used to call our webservice using java code? We have a 3DNS url set up and we want all clients to use this url as oppossed hitting the boxes directly with the correct port numbers in the url.</p> <p>Thanks Damien</p>
[ { "answer_id": 1861830, "author": "monksy", "author_id": 80701, "author_profile": "https://Stackoverflow.com/users/80701", "pm_score": 3, "selected": true, "text": "@Resource\nWebServiceContext wsContext;\n" } ]
2008/10/11
[ "https://Stackoverflow.com/questions/194102", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11612/" ]
194,104
<p>I am writing a script that powers on a system via network. And then i need to run a few commands on the other host. How do I know whether the system has powered on?</p> <p>My programming language is Perl and the target host is RHEL5.</p> <p>Is there any kernel interrupt or network boot information that indicates the system has powered on and the os has loaded?</p> <p>[In a different scenario] I was also wondering just in case if i just switch on my Machine manually. when is it exactly said to have powered on. and when is the OS is supposed to have booted completely for a network related operation such as executing a network command there. What if the system is on DHCP how would a remote system then search for this machine [i guess it is possible via mac address. but if i am wrong ].</p> <p>If I have missed out any info please feel free to ask me. If you have any suggestions to make the task easier please surface them :) </p> <p>thanx imkin</p>
[ { "answer_id": 194139, "author": "moritz", "author_id": 14132, "author_profile": "https://Stackoverflow.com/users/14132", "pm_score": 3, "selected": false, "text": "@reboot" } ]
2008/10/11
[ "https://Stackoverflow.com/questions/194104", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2577336/" ]
194,121
<p>At the team with which I work, we have an old codebase using PHP's ibase_* functions all over the code to communicate with database. We created a wrapper to it that would do something else beside just calling the original function and I did a mass search-replace in the entire code to make sure that wrapper is used instead.</p> <p>Now, how do we prevent usage of ibase_* functions in the future?</p> <p>Preferably, I'd like to still have them available, but make it throw a NOTICE or WARNING when it is used.</p> <p>A solution in pure PHP (not needing to compile a custom version of PHP) is preferred.</p>
[ { "answer_id": 194129, "author": "unexist", "author_id": 18179, "author_profile": "https://Stackoverflow.com/users/18179", "pm_score": 3, "selected": false, "text": "<?php\nclass Foo\n{ \n public function __construct()\n {\n trigger_error('Use Bar instead', E_USER_NOTICE);...
2008/10/11
[ "https://Stackoverflow.com/questions/194121", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14690/" ]
194,133
<p>I'm working on a Win32 control. There could be hundreds of "items" on this control. Those are not windows, but internal objects (eg: rectangles). Depending on the mouse position I want to change the mouse cursor. That is fine, I can use WM_SETCURSOR.</p> <p>At the same time based on mouse move I want to display a status bar which shows details about the object currently under the mouse. For that I can use WM_MOUSEMOVE.</p> <p>Because there could be hundreds of items, traveling all of them to find one under the mouse, well it's not efficient, especially two times (one for set cursor, one for mouse move).</p> <p>To make it short, do you know if WM_SETCURSOR and WM_MOUSEMOVE are <strong>ALWAYS</strong> in pair? In that case I can calculate what I want during WM_SETCURSOR. The other option would be to set the mouse cursor during WM_MOUSEMOVE, but as far as I know that it's not a good solution (will flicker).</p> <p>Thanks</p>
[ { "answer_id": 5579715, "author": "T800", "author_id": 696612, "author_profile": "https://Stackoverflow.com/users/696612", "pm_score": 2, "selected": false, "text": "GetMessagePos()" } ]
2008/10/11
[ "https://Stackoverflow.com/questions/194133", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
194,150
<p>How to check reliably if a SoundChannel is still playing a sound? </p> <p>For example,</p> <pre><code>[Embed(source="song.mp3")] var Song: Class; var s: Song = new Song(); var ch: SoundChannel = s.play(); // how to check if ch is playing? </code></pre>
[ { "answer_id": 194653, "author": "James Fassett", "author_id": 27081, "author_profile": "https://Stackoverflow.com/users/27081", "pm_score": 5, "selected": true, "text": "\npackage\n{\n import flash.events.Event;\n import flash.media.Sound;\n import flash.media.SoundChannel;\n\n...
2008/10/11
[ "https://Stackoverflow.com/questions/194150", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11238/" ]
194,157
<p>I'm using:</p> <pre><code>FileInfo( System.Environment.GetFolderPath( System.Environment.SpecialFolder.ProgramFiles) + @"\MyInstalledApp" </code></pre> <p>In order to determine if a program is detected on a users machine (it's not ideal, but the program I'm looking for is a right old kludge of a MS-DOS application, and I couldn't think of another method).</p> <p>On Windows XP and 32-bit versions of Windows Vista this works fine. However, on x64 Windows Vista the code returns the x64 Program Files folder, whereas the application is installed in Program Files x86. Is there a way to programatically return the path to Program Files x86 without hard wiring "C:\Program Files (x86)"?</p>
[ { "answer_id": 194163, "author": "tomasr", "author_id": 10292, "author_profile": "https://Stackoverflow.com/users/10292", "pm_score": 3, "selected": false, "text": "String x86folder = Environment.GetEnvironmentVariable(\"ProgramFiles(x86)\");\n" }, { "answer_id": 194191, "aut...
2008/10/11
[ "https://Stackoverflow.com/questions/194157", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1293123/" ]
194,165
<p>I'm using the standard <code>ConsoleHandler</code> from <code>java.util.logging</code> and by default the console output is directed to the error stream (i.e. <code>System.err</code>).</p> <p>How do I change the console output to the output stream (i.e. <code>System.out</code>)?</p>
[ { "answer_id": 194202, "author": "Uri", "author_id": 23072, "author_profile": "https://Stackoverflow.com/users/23072", "pm_score": 2, "selected": false, "text": "Handler fh = new FileHandler(FILENAME);\nLogger.getLogger(LOGGER_NAME).addHandler(fh);\n" }, { "answer_id": 194851, ...
2008/10/11
[ "https://Stackoverflow.com/questions/194165", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23120/" ]
194,168
<p>I asked before about pixel-pushing, and have now managed to get far enough to get noise to show up on the screen. Here's how I init:</p> <pre><code>CGDataProviderRef provider; bitmap = malloc(320*480*4); provider = CGDataProviderCreateWithData(NULL, bitmap, 320*480*4, NULL); CGColorSpaceRef colorSpaceRef; colorSpaceRef = CGColorSpaceCreateDeviceRGB(); ir = CGImageCreate( 320, 480, 8, 32, 4 * 320, colorSpaceRef, kCGImageAlphaNoneSkipLast, provider, NULL, NO, kCGRenderingIntentDefault ); </code></pre> <p>Here's how I render each frame:</p> <pre><code>for (int i=0; i&lt;320*480*4; i++) { bitmap[i] = rand()%256; } CGRect rect = CGRectMake(0, 0, 320, 480); CGContextDrawImage(context, rect, ir); </code></pre> <p>Problem is this is awfully awfully slow, around 5fps. I think my path to publish the buffer must be wrong. Is it even possible to do full-screen pixel-based graphics that I could update at 30fps, without using the 3D chip?</p>
[ { "answer_id": 194216, "author": "freespace", "author_id": 8297, "author_profile": "https://Stackoverflow.com/users/8297", "pm_score": 1, "selected": false, "text": "320*480*4" }, { "answer_id": 1948932, "author": "rpetrich", "author_id": 4007, "author_profile": "http...
2008/10/11
[ "https://Stackoverflow.com/questions/194168", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8005/" ]
194,192
<p>I need to know when the user finishes editing a cell in an NSTableView. The table contains all of the user's calendars (obtained from the CalCalendarStore), so in order for the user's changes to be saved I need to inform the CalCalendarStore of the changes. However, I can't find anything that gets called after the user finishes their editing - I would guess that there would be a method in the table's delegate, but I only saw one that gets called when editing starts, not when editing ends.</p>
[ { "answer_id": 12132442, "author": "Milly", "author_id": 1608447, "author_profile": "https://Stackoverflow.com/users/1608447", "pm_score": 4, "selected": false, "text": "NSTableView" }, { "answer_id": 46102084, "author": "J.beenie", "author_id": 7289621, "author_profi...
2008/10/11
[ "https://Stackoverflow.com/questions/194192", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3857/" ]
194,194
<p>I have a large collection of data in an excel file (and csv files). The data needs to be placed into a database (mysql). However, before it goes into the database it needs to be processed..for example if columns 1 is less than column 3 add 4 to column 2. There are quite a few rules that must be followed before the information is persisted.</p> <p>What would be a good design to follow to accomplish this task? (using java)</p> <p><strong>Additional notes</strong></p> <p>The process needs to be automated. In the sense that I don't have to manually go in and alter the data. We're talking about thousands of lines of data with 15 columns of information per line.</p> <p>Currently, I have a sort of chain of responsibility design set up. One class(Java) for each rule. When one rule is done, it calls the following rule.</p> <p><strong>More Info</strong></p> <p>Typically there are about 5000 rows per data sheet. Speed isn't a huge concern because this large input doesn't happen often.</p> <p>I've considered drools, however I wasn't sure the task was complicated enough for drols. </p> <p>Example rules:</p> <ol> <li><p>All currency (data in specific columns) must not contain currency symbols.</p></li> <li><p>Category names must be uniform (e.g. book case = bookcase)</p></li> <li><p>Entry dates can not be future dates</p></li> <li><p>Text input can only contain [A-Z 0-9 \s]</p></li> </ol> <p>etc..<br> Additionally if any column of information is invalid it needs to be reported when processing is complete (or maybe stop processing).</p> <p>My current solution works. However I think there is room for improvement so I'm looking for ideals as to how it can be improved and or how other people have handled similar situations.</p> <p>I've considered (very briefly) using drools but I wasn't sure the work was complicated enough to take advantage of drools.</p>
[ { "answer_id": 194205, "author": "Oli", "author_id": 12870, "author_profile": "https://Stackoverflow.com/users/12870", "pm_score": 0, "selected": false, "text": "public class ALine {\n private int col1;\n private int col2;\n private int coln;\n // ...\n\n public ALine(stri...
2008/10/11
[ "https://Stackoverflow.com/questions/194194", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17337/" ]
194,208
<p>I'm using the following code within the JCProperty class to retrieve data from a DAL: </p> <pre><code>Dim x As JCProperty x = JCPropertyDB.GetProperty(PropertyID) If Not x Is Nothing Then Me.PropertyID = x.PropertyID Me.AddressLine1 = x.AddressLine1 Me.AddressLine2 = x.AddressLine2 Me.AddressLine3 = x.AddressLine3 Me.AddressCity = x.AddressCity Me.AddressCounty = x.AddressCounty Me.AddressPostcode = x.AddressPostcode Me.TelNo = x.TelNo Me.UpdatedOn = x.UpdatedOn Me.CreatedOn = x.CreatedOn Me.Description = x.Description Me.GUID = x.GUID End If </code></pre> <p>This works fine but requires that the DAL object (JCPropertyDB) is aware of the business object (JCProperty) and I effectively create and populate the same object twice (once in the DAL to return to the BL and then again within the BL object to populate itself). </p> <p>I'm missing something here, I know there must be a better way! </p> <p>Effectively I need to assign 'Me = x' which is not allowed. Can someone put me straight?</p>
[ { "answer_id": 194270, "author": "Ron Savage", "author_id": 12476, "author_profile": "https://Stackoverflow.com/users/12476", "pm_score": 2, "selected": true, "text": "class JCProperty : inherits JCPropertyDB\n {\n\n New()\n {\n MyBase.New()\n\n GetProperty(PropertyID)...
2008/10/11
[ "https://Stackoverflow.com/questions/194208", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20048/" ]
194,241
<p>In Visual Studio if I define a class to implement an interface e.g.</p> <pre><code>class MyObject : ISerializable {} </code></pre> <p>I am able to right click on ISerializable, select "<em>Implement Interface</em>" from the context menu and see the appropriate methods appear in my class definition.</p> <pre><code>class MyObject : ISerializable { #region ISerializable Members public void GetObjectData(SerializationInfo info, StreamingContext context) { throw new NotImplementedException(); } #endregion } </code></pre> <p>Is there anything anything like this functionality available in Xcode on the Mac? I would like to be able to automatically implement Protocols in this way. Maybe with the optional methods generated but commented out.</p>
[ { "answer_id": 3952028, "author": "bithavoc", "author_id": 146032, "author_profile": "https://Stackoverflow.com/users/146032", "pm_score": 1, "selected": false, "text": "@protocol PosterousWebsitesDelegate <NSObject>\n- (void)PosterousWebsitesLoadSuccess:(PosterousWebsites*)websites;\n@e...
2008/10/11
[ "https://Stackoverflow.com/questions/194241", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1403/" ]
194,247
<p>I have a 2 dimensional array, like so:</p> <pre><code>char[,] str = new char[2,50]; </code></pre> <p>Now, after I've stored contents in both str[0] and str[1], how do I store it in a </p> <pre><code>string[] s = new string[2]; </code></pre> <p>?</p> <p>I tried </p> <pre><code>s[0] = str[0].ToString(); </code></pre> <p>but that seems to be an error: VC# expects 'two' indices within the braces, which means I can convert only a character from the array. Is there a way to convert the entire str[0] to a string? Or is changing it to a jagged array the only solution?</p>
[ { "answer_id": 194252, "author": "Drew Noakes", "author_id": 24874, "author_profile": "https://Stackoverflow.com/users/24874", "pm_score": 2, "selected": false, "text": "char[,] str = new char[2,50];\n\n// populate str somehow\n\n// chose which of the strings we want (the 'row' index)\ni...
2008/10/11
[ "https://Stackoverflow.com/questions/194247", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8127/" ]
194,261
<p>I just played with Java file system API, and came down with the following function, used to copy binary files. The original source came from the Web, but I added try/catch/finally clauses to be sure that, should something wrong happen, the Buffer Streams would be closed (and thus, my OS ressources freed) before quiting the function.</p> <p>I trimmed down the function to show the pattern:</p> <pre><code>public static void copyFile(FileOutputStream oDStream, FileInputStream oSStream) throw etc... { BufferedInputStream oSBuffer = new BufferedInputStream(oSStream, 4096); BufferedOutputStream oDBuffer = new BufferedOutputStream(oDStream, 4096); try { try { int c; while((c = oSBuffer.read()) != -1) // could throw a IOException { oDBuffer.write(c); // could throw a IOException } } finally { oDBuffer.close(); // could throw a IOException } } finally { oSBuffer.close(); // could throw a IOException } } </code></pre> <p>As far as I understand it, I cannot put the two <code>close()</code> in the finally clause because the first <code>close()</code> could well throw, and then, the second would not be executed.</p> <p>I know C# has the <em>Dispose</em> pattern that would have handled this with the <code>using</code> keyword.</p> <p>I even know better a C++ code would have been something like (using a Java-like API):</p> <pre><code>void copyFile(FileOutputStream &amp; oDStream, FileInputStream &amp; oSStream) { BufferedInputStream oSBuffer(oSStream, 4096); BufferedOutputStream oDBuffer(oDStream, 4096); int c; while((c = oSBuffer.read()) != -1) // could throw a IOException { oDBuffer.write(c); // could throw a IOException } // I don't care about resources, as RAII handle them for me } </code></pre> <p>I am missing something, or do I really have to produce ugly and bloated code in Java just to handle exceptions in the <code>close()</code> method of a Buffered Stream?</p> <p>(Please, tell me I'm wrong somewhere...)</p> <p><strong>EDIT: Is it me, or when updating this page, I saw both the question and all the answers decreased by one point in a couple of minutes? Is someone enjoying himself too much while remaning anonymous?</strong></p> <p>EDIT 2: <strong>McDowell</strong> offered a very interesting link I felt I had to mention here: <a href="http://illegalargumentexception.blogspot.com/2008/10/java-how-not-to-make-mess-of-stream.html" rel="noreferrer">http://illegalargumentexception.blogspot.com/2008/10/java-how-not-to-make-mess-of-stream.html</a></p> <p>EDIT 3: Following McDowell's link, I tumbled upon a proposal for Java 7 of a pattern similar to the C# using pattern: <a href="http://tech.puredanger.com/java7/#resourceblock" rel="noreferrer">http://tech.puredanger.com/java7/#resourceblock</a> . My problem is explicitly described. Apparently, even with the Java 7 <code>do</code>, the problems remain.</p>
[ { "answer_id": 194288, "author": "McDowell", "author_id": 304, "author_profile": "https://Stackoverflow.com/users/304", "pm_score": 5, "selected": true, "text": "/** transcodes text file from one encoding to another */\npublic static void transcode(File source, Charset srcEncoding,\n ...
2008/10/11
[ "https://Stackoverflow.com/questions/194261", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14089/" ]
194,278
<p>In a <a href="https://stackoverflow.com/questions/194272">related question</a>, my team is about to (hopefully) start using LINQ, and I'd like to take advantage of anonymous types. What is the best way to mix VB.NET's Option Strict (which we've been using through the life of the project) and the new Option Infer directives?</p>
[ { "answer_id": 54266943, "author": "jmoreno", "author_id": 234954, "author_profile": "https://Stackoverflow.com/users/234954", "pm_score": 0, "selected": false, "text": "txtBox.Text = If(str=\"\", Nothing, CDate(str))\n" } ]
2008/10/11
[ "https://Stackoverflow.com/questions/194278", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6897/" ]
194,304
<p>I'm trying to think of clever, clear, and simple ways to write code that describes the sequence of integers in a given range. </p> <p>Here's an example:</p> <pre><code>IEnumerable&lt;int&gt; EnumerateIntegerRange(int from, int to) { for (int i = from; i &lt;= to; i++) { yield return i; } } </code></pre>
[ { "answer_id": 195920, "author": "Jay Bazuzi", "author_id": 5314, "author_profile": "https://Stackoverflow.com/users/5314", "pm_score": 0, "selected": false, "text": "class Range<T> where T: IComparable<T>\n{\n public T From { get; set; }\n public T To { get; set; }\n\n public R...
2008/10/11
[ "https://Stackoverflow.com/questions/194304", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5314/" ]
194,328
<p>I know we can use tools like JProfiler etc. Is there any tutorial on how to configure it to display the memory usage just by remote monitoring?</p> <p>Any idea?</p>
[ { "answer_id": 194351, "author": "MatthieuGD", "author_id": 3109, "author_profile": "https://Stackoverflow.com/users/3109", "pm_score": 3, "selected": false, "text": "JAVA_HOME/bin/jstatd -J-Djava.security.policy=jstatd.all.policy\n" }, { "answer_id": 229091, "author": "Peter...
2008/10/11
[ "https://Stackoverflow.com/questions/194328", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25368/" ]
194,331
<p>I have a domain class containing a couple of fields. I can access them from my .gsps. I want to add a method to the domain class, which I can call from the .gsps (this method is a kind of virtual field; it's data is not coming directly from the database).</p> <p>How do I add the method and how can I then call it from the .gsps?</p>
[ { "answer_id": 194348, "author": "Hates_", "author_id": 3410, "author_profile": "https://Stackoverflow.com/users/3410", "pm_score": 5, "selected": true, "text": "def someMethod() {\n return \"Hello.\"\n}\n" }, { "answer_id": 18535117, "author": "Ramesh", "author_id": 272...
2008/10/11
[ "https://Stackoverflow.com/questions/194331", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3506/" ]
194,339
<p>I have several python projects that share common modules. Until now, I've been ... ahem ... keeping multiple copies of the common code and synchronizing by hand. But I'd clearly prefer to do something else.</p> <p>It looks to me now, as if zc.Buildout maybe what I need. I guess that what I should be doing is putting each reusable component of my system into a separate egg, and then using buildout to assemble them into projects.</p> <p>I'm also thinking that for any particular module, I should put the unit-tests into a separate package or egg, so that I'm not also installing copies of the component's unit-tests in every project. I only want to unit-test in a place where my library is developed, not where it's just being used.</p> <p>So maybe I want something like this</p> <pre><code>projects lib1 tests code lib2 tests code app1 tests appcode app2 tests appcode </code></pre> <p>etc.</p> <p>Where both app1 and app2 are independent applications with their own code and tests, but are also including and using both lib1 and lib2. And lib1/test, lib1/code, lib2/test, lib2code, app1, app2 are separate eggs. Does this sound right?</p> <p>However, I now get confused. I assume that when I develop app1, I want buildout to pull copies of lib1, lib2 and app1 into a separate working directory rather than put copies of these libraries under app1 directly. But how does this work with my SVN source-control? If the working directory is dynamically constructed with buildout, it can't be a live SVN directory from which I can check the changes back into the repository?</p> <p>Have I misunderstood how buildout is meant to be used? Would I be better going for a completely different approach? How do you mix source-control with module-reuse between projects?</p> <p>Update : thanks to the two people who've currently answered this question. I'm experimenting more with this.</p>
[ { "answer_id": 194472, "author": "S.Lott", "author_id": 10661, "author_profile": "https://Stackoverflow.com/users/10661", "pm_score": 2, "selected": false, "text": "sys.path" }, { "answer_id": 195102, "author": "Kozyarchuk", "author_id": 52490, "author_profile": "http...
2008/10/11
[ "https://Stackoverflow.com/questions/194339", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8482/" ]
194,346
<p>I have an HTML page (say welcome.html) which contains an iframe to a page I have no control over (say app.html). The user performs some actions using the app within the iframe and clicks submit. Once they do this, they are taken to a new page (say thanks.jsp), which loads within the iframe. Is there a way in which I can force thanks.jsp to load in the full frame and not the iframe once submit is clicked? Remember, I have no control over the logic behind that Submit button or app.html. I do however have control over welcome.html and thanks.jsp. If possible, I would like to stick with HTML and/or JavaScript. Thank you in advance.</p>
[ { "answer_id": 194363, "author": "Quentin", "author_id": 19068, "author_profile": "https://Stackoverflow.com/users/19068", "pm_score": 4, "selected": true, "text": "thanks.jsp" }, { "answer_id": 194365, "author": "ConroyP", "author_id": 2287, "author_profile": "https:...
2008/10/11
[ "https://Stackoverflow.com/questions/194346", "https://Stackoverflow.com", "https://Stackoverflow.com/users/78/" ]
194,349
<p>Where do you store <em>user-specific</em> and <em>machine-specific</em> <strong>runtime</strong> configuration data for J2SE application?</p> <p>(For example, <em>C:\Users\USERNAME\AppData\Roaming&lt;/em&gt; on Windows and /home/username</em> on Unix)</p> <p>How do you get these locations in the filesystem in platform-independent way?</p>
[ { "answer_id": 194371, "author": "Powerlord", "author_id": 15880, "author_profile": "https://Stackoverflow.com/users/15880", "pm_score": 3, "selected": false, "text": "Preferences userPrefs = Preferences.getUserNodeForPackage(MyClass.class); // Gets user preferences node for MyClass\nPre...
2008/10/11
[ "https://Stackoverflow.com/questions/194349", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1764/" ]
194,358
<p>I have an unmanaged C dll I call from a C# class library that encrypts a string value into an encrypted string that contains non-ascii characters. I need to take the data and write its binary values to a file, but C# treats text as <code>string</code> rather than a <code>byte[]</code>. </p> <p>The encrypted value commonly contains special characters (<code>\r</code>, <code>\O</code>, etc). When I do this converting the returned string to C# using some type of codeset (ascii, utf-7, utf-16) it writes the special character values as the Windows interpreted values instead their actual binary representation. </p> <p>My question is how can I pull the data from the unmanaged dll into a <code>byte[]</code> rather than a string so I can write that to file using the <code>BinaryWriter</code>?</p> <p>Thanks.</p>
[ { "answer_id": 194425, "author": "Stephen Edmonds", "author_id": 17349, "author_profile": "https://Stackoverflow.com/users/17349", "pm_score": 2, "selected": false, "text": "ASCIIEncoding ascii = new ASCIIEncoding();\nByte[] encodedBytes = ascii.GetBytes(unicodeString);\n" } ]
2008/10/11
[ "https://Stackoverflow.com/questions/194358", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
194,382
<p>What is the difference between applying the visitor design pattern to your code and the following approach:</p> <pre><code>interface Dointerface { public void perform(Object o); } public class T { private Dointerface d; private String s; public String getS() { return s; } public T(String s) { this.s = s; } public void setInterface(Dointerface d) { this.d = d; } public void perform() { d.perform(this); } public static void main(String[] args) { T t = new T("Geonline"); t.setInterface(new Dointerface() { public void perform(Object o) { T a = (T)o; System.out.println(a.getS()); } }); t.perform(); } } </code></pre> <p>I assume that by using interfaces, we're not really separating the algorithm.</p>
[ { "answer_id": 194452, "author": "Benno Richters", "author_id": 3565, "author_profile": "https://Stackoverflow.com/users/3565", "pm_score": 3, "selected": true, "text": "perfom" }, { "answer_id": 217105, "author": "Martin Brown", "author_id": 20553, "author_profile": ...
2008/10/11
[ "https://Stackoverflow.com/questions/194382", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11234/" ]
194,384
<p>(sorry for my English) For example, in my DAL,I have an AuthorDB object, that has a Name and a BookDB object, that has a Title and an IdAuthor. </p> <p>Now, if I want to show all the books with their corresponding author's name, I have to get a collection of all the Books, and for each of them, with the IdAuthor attribute, find the Author's name. This makes a lot of queries to the database, and obviously, a simple JOIN could be used. </p> <p>What are my options? Creating a 'custom' object that contains the author's name and the title of the book? If so, the maintenance could become awful.</p> <p>So, what are the options? Thank you!</p>
[ { "answer_id": 194588, "author": "Thomas Eyde", "author_id": 3282, "author_profile": "https://Stackoverflow.com/users/3282", "pm_score": 0, "selected": false, "text": "public IEnumerable<Book> AllBooks()\n{\n return from book in db.Books\n join author in db.Authors on book...
2008/10/11
[ "https://Stackoverflow.com/questions/194384", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
194,388
<p>The existing application is in C#. During startup the application calls a virtual method to make changes to the database (for example a new revision may need to calculate a new field or something). An open OleDb connection is passed into the method. </p> <p>I need to change a field width. The ALTER TABLE statement is working fine. But I would like to avoid executing the ALTER TABLE statement if the field is already the appropriate size. Is there a way to determine the size of an MS Access field using the same OleDb connection?</p>
[ { "answer_id": 195048, "author": "Andy", "author_id": 27096, "author_profile": "https://Stackoverflow.com/users/27096", "pm_score": 1, "selected": false, "text": "var command = new OleDbCommand(\"SELECT FIELD FROM TABLE\", connection); \nvar reader = command.ExecuteReader(CommandBehavior...
2008/10/11
[ "https://Stackoverflow.com/questions/194388", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27096/" ]
194,395
<p>Given a heapdump or a running VM, how do I discover what the contents of the permanent generation is ? I know about 'jmap -permstat' but that's not available on Windows.</p>
[ { "answer_id": 8600342, "author": "David Tinker", "author_id": 159434, "author_profile": "https://Stackoverflow.com/users/159434", "pm_score": 1, "selected": false, "text": " MemoryUsage usage = ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage();\n long nonHeapFree = usage...
2008/10/11
[ "https://Stackoverflow.com/questions/194395", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22850/" ]
194,397
<p>I want to make a JavaScript application that's not open source, and thus I wish to learn how to can obfuscate my JS code? Is this possible?</p>
[ { "answer_id": 194399, "author": "keparo", "author_id": 19468, "author_profile": "https://Stackoverflow.com/users/19468", "pm_score": 10, "selected": true, "text": "UPDATE: This question was originally asked on 2008, and The mentioned technologies are deprecated. you can use:" }, { ...
2008/10/11
[ "https://Stackoverflow.com/questions/194397", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1384652/" ]
194,418
<p>I'm looking for some help and it goes like this: I'm a fairly green software developer, and focus mainly on the web (python/PHP) but am pretty well experienced with Java applications and as an electrical engineering student, looking forward to dive into some c/c++. I've pretty much grown up on Windows machine, but hate .net with a passion and dont really have a need to develop on Windows - besides the fact that i'm used to it.</p> <p>I'm looking to switch to Ubuntu as my development machine entirely (without having WinXP on another partition) as I'm quite fedup with Windows, but am tempted to go back to it everytime i'm stuck with countless driver issues (be it headphone drivers, or dual monitor setup, etc). I'm looking for a comprehensive resource that will help this transition and doesn't assume you know alien linux shell keywords.</p> <p>Cheers.</p>
[ { "answer_id": 194636, "author": "SCdF", "author_id": 1666, "author_profile": "https://Stackoverflow.com/users/1666", "pm_score": 2, "selected": false, "text": ".gnome" } ]
2008/10/11
[ "https://Stackoverflow.com/questions/194418", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11110/" ]
194,428
<p>How can i release the memory that I used for a variable (e.g. a long string) in C?</p>
[ { "answer_id": 194432, "author": "Michael Carman", "author_id": 8233, "author_profile": "https://Stackoverflow.com/users/8233", "pm_score": 5, "selected": true, "text": "malloc" }, { "answer_id": 194444, "author": "Svet", "author_id": 8934, "author_profile": "https://...
2008/10/11
[ "https://Stackoverflow.com/questions/194428", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25017/" ]
194,430
<p>I'm experimenting with internationalization by making a Hello World program that uses properties files + ResourceBundle to get different strings.</p> <p>Specifically, I have a file "messages_en_US.properties" that stores "hello.world=Hello World!", which works fine of course.</p> <p>I then have a file "messages_ja_JP.properties" which I've tried all sorts of things with, but it always appears as some type of garbled string when printed to the console or in Swing. The problem is obviously with the reading of the content into a Java string, as a Java string in Japanese typed directly into the source can print fine.</p> <p>Things I've tried:</p> <ul> <li>The .properties file in UTF-8 encoding with the Japanese string as-is for the value. Something I read indicates that Java expects a properties file to be in the native encoding of the system...? It didn't work either way.</li> <li>The file in default encoding (ISO-8859-1) and the value stored as escaped Unicode created by the native2ascii program included with Java. Tried with a source file in various Japanese encodings... SHIFT-JIS, EUC-JP, ISO-2022-JP.</li> </ul> <p><strong>Edit:</strong></p> <p>I actually figured this out while I was typing this, but I figured I'd post it anyway and answer it in case it helps anyone.</p>
[ { "answer_id": 194794, "author": "Alan Moore", "author_id": 20938, "author_profile": "https://Stackoverflow.com/users/20938", "pm_score": 2, "selected": false, "text": "String realProp = new String(prop.getBytes(\"ISO-8859-1\"), \"UTF-8\");\n" } ]
2008/10/11
[ "https://Stackoverflow.com/questions/194430", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13792/" ]
194,443
<p>I want to post an xml document to an <strong>asp</strong> page from an <strong>asp.net</strong> page. If I use WebRequest with content/type text/xml the document never gets to the asp page. How can I do this ?</p>
[ { "answer_id": 197728, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<data id='10'>value</data>" }, { "answer_id": 315438, "author": "Sunny Milenov", "author_id": 8220, "autho...
2008/10/11
[ "https://Stackoverflow.com/questions/194443", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
194,445
<p>the question I am having is: when running my app with a launch code other than sysAppLaunchCmdNormalLaunch, I can not use code outside the default code segment - but could I use a shared library that is multi-segmented, thus circumventing this problem?</p> <p>A bit of background information: I am evaluating the possibility of porting an existing mobile application to PalmOS. A core part of this app is that it is doing some network communication in the background every 10 minutes or so, or when it receives incoming data (via a network/socket callback). During this time, I do not have access to globals and hence not to any code segments in my application other than the default one.</p> <p>The problem now is that the actions involved in the communication (protocol, data handling, etc) require a lot of code that just does not fit into one segment. Apart from the question whether it makes sense to have that much code run in the 'background', the obvious problem is: how would I run it in the first place? Hence the question, whether putting the code in a shared (multi-segment) library would help.</p> <p>Looking forward to your insights.</p>
[ { "answer_id": 912886, "author": "PhrkOnLsh", "author_id": 112613, "author_profile": "https://Stackoverflow.com/users/112613", "pm_score": 1, "selected": false, "text": "__STANDALONE_CODE_RESOURCE__" } ]
2008/10/11
[ "https://Stackoverflow.com/questions/194445", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27101/" ]
194,450
<p>I'm looking for an easiest way how to implement the "suggest" feature for a text entry field in a Rails application. The idea is to complete names stored in a database column, giving the user a drop-down menu of possible matches as he types.</p> <p>Thanks for any suggestions!</p>
[ { "answer_id": 199771, "author": "JasonOng", "author_id": 6048, "author_profile": "https://Stackoverflow.com/users/6048", "pm_score": 1, "selected": false, "text": "# your_view.rhtml\n\n<%= text_field 'contact', 'name', :id => 'suggest' %>\n<div id='dropdown' style='display:none; z-index...
2008/10/11
[ "https://Stackoverflow.com/questions/194450", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
194,464
<p>Everyone (at least everyone who uses a compiled language) has faced compilation errors but how many times do you get to actually crash the compiler? </p> <p>I've had my fair share of <strong>"internal compiler errors"</strong> but most went away just by re-compiling. Do you have a (minimal) piece of code that crashes the compiler?</p>
[ { "answer_id": 194599, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "switch(on_some_variable)\n{\n}\n" }, { "answer_id": 194630, "author": "ejgottl", "author_id": 9808, "autho...
2008/10/11
[ "https://Stackoverflow.com/questions/194464", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3848/" ]
194,465
<p>What's the C++ way of parsing a string (given as char *) into an int? Robust and clear error handling is a plus (instead of <a href="http://en.cppreference.com/w/cpp/string/byte/atoi" rel="noreferrer">returning zero</a>).</p>
[ { "answer_id": 194478, "author": "Christian C. Salvadó", "author_id": 5445, "author_profile": "https://Stackoverflow.com/users/5445", "pm_score": 3, "selected": false, "text": "int str2int (const string &str) {\n stringstream ss(str);\n int num;\n ss >> num;\n return num;\n}\n" }, ...
2008/10/11
[ "https://Stackoverflow.com/questions/194465", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3827/" ]
194,468
<p>I'm trying to write a faster user switching app for Windows. Win+L and selecting users is very cumbersome. If I start Task Manager as administrator, it shows active users and I can select one and "Connect" (if I enter their password).</p> <p>How do I get the list of all users (or all active users)? </p> <p>I'm using C# (Visual Studio Express).</p>
[ { "answer_id": 732654, "author": "Dan Ports", "author_id": 88885, "author_profile": "https://Stackoverflow.com/users/88885", "pm_score": 2, "selected": false, "text": "using Cassia;\n\nforeach (ITerminalServicesSession session in new TerminalServicesManager().GetSessions())\n{\n if (!...
2008/10/11
[ "https://Stackoverflow.com/questions/194468", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21352/" ]
194,484
<p>I collect a few corner cases and <a href="http://www.yoda.arachsys.com/csharp/teasers.html" rel="nofollow noreferrer">brain teasers</a> and would always like to hear more. The page only really covers C# language bits and bobs, but I also find core .NET things interesting too. For example, here's one which isn't on the page, but which I find incredible:</p> <pre><code>string x = new string(new char[0]); string y = new string(new char[0]); Console.WriteLine(object.ReferenceEquals(x, y)); </code></pre> <p>I'd expect that to print False - after all, "new" (with a reference type) <em>always</em> creates a new object, doesn't it? The specs for both C# and the CLI indicate that it should. Well, not in this particular case. It prints True, and has done on every version of the framework I've tested it with. (I haven't tried it on Mono, admittedly...)</p> <p>Just to be clear, this is only an example of the kind of thing I'm looking for - I wasn't particularly looking for discussion/explanation of this oddity. (It's not the same as normal string interning; in particular, string interning doesn't normally happen when a constructor is called.) I was really asking for similar odd behaviour.</p> <p>Any other gems lurking out there?</p>
[ { "answer_id": 194671, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 10, "selected": true, "text": " static void Foo<T>() where T : new()\n {\n T t = new T();\n Console.WriteLine(t.ToString()); // ...
2008/10/11
[ "https://Stackoverflow.com/questions/194484", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22656/" ]
194,485
<p>I'm building few command-line utilities in Xcode (plain C, no Cocoa). I want all of them to use my customized version of libpng, and I want to save space by sharing one copy of the library among all executables (I don't mind re-distributing <code>.dylib</code> with them).</p> <p>Do I need to do some magic to get libpng export symbols?</p> <p>Does <em>"Link Binary With Libraries"</em> build phase link statically? </p> <p>Apple's docs mention loading of libraries at run time with <code>dlopen</code>, but how I can make Xcode create executable without complaining about missing symbols?</p> <hr> <p>I think I've figured it out:</p> <ul> <li><p>libpng wasn't linking properly, because I've built 32/64-bit executables and 32-bit library. Build settings of the library and executables must match.</p></li> <li><p>libpng's config.h needs to have tons of defines like <code>#define FEATURE_XXX_SUPPORTED</code></p></li> <li><p><em>"Link Binary With Libraries"</em> build phase handles dynamic libraries just fine, and <code>DYLD_FALLBACK_LIBRARY_PATH</code> environmental variable is neccessary for loading <code>.dylib</code>s from application bundle.</p></li> </ul>
[ { "answer_id": 195030, "author": "Chris Hanson", "author_id": 714, "author_profile": "https://Stackoverflow.com/users/714", "pm_score": 4, "selected": true, "text": "DYLD_FALLBACK_LIBRARY_PATH" }, { "answer_id": 515966, "author": "denis", "author_id": 86643, "author_p...
2008/10/11
[ "https://Stackoverflow.com/questions/194485", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27009/" ]
194,492
<p>In visual C++, I can do things like this:</p> <pre><code>template &lt;class T&gt; class A{ protected: T i; }; template &lt;class T&gt; class B : public A&lt;T&gt;{ T geti() {return i;} }; </code></pre> <p>If I try to compile this in g++, I get an error. I have to do this:</p> <pre><code>template &lt;class T&gt; class B : public A&lt;T&gt;{ T geti() {return A&lt;T&gt;::i;} }; </code></pre> <p>Am I not supposed to do the former in standard C++? Or is something misconfigured with gcc that's giving me errors?</p>
[ { "answer_id": 194640, "author": "Brian R. Bondy", "author_id": 3153, "author_profile": "https://Stackoverflow.com/users/3153", "pm_score": 4, "selected": true, "text": " template <typename T> struct B {\n int m;\n int n;\n int f ();\n int g ();\n };\n int n;...
2008/10/11
[ "https://Stackoverflow.com/questions/194492", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2147/" ]
194,496
<p>In a language where both are available, would you prefer to see an instance constructor or a static method that returns an instance?</p> <p>For example, if you're creating a <code>String</code> from a <code>char[]</code>:</p> <ol> <li><p><code>String.FromCharacters(chars);</code></p></li> <li><p><code>new String(chars);</code></p></li> </ol>
[ { "answer_id": 194540, "author": "Robert Rossney", "author_id": 19403, "author_profile": "https://Stackoverflow.com/users/19403", "pm_score": 5, "selected": false, "text": "public class Foo\n{\n private Foo() { }\n\n private static List<Foo> FooList = new List<Foo>();\n public stat...
2008/10/11
[ "https://Stackoverflow.com/questions/194496", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23427/" ]
194,520
<p>Is there an easy way to create standalone .exe files from Lua scripts? Basically this would involve linking the Lua interpreter and the scripts.</p> <p>I believe it is possible (PLT Scheme allows the creation of standalone executables in the same way), but how, exactly?</p>
[ { "answer_id": 194605, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "copy interpreter.exe+script.lua script.exe\n" }, { "answer_id": 1150047, "author": "Community", "author_id": -...
2008/10/11
[ "https://Stackoverflow.com/questions/194520", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21048/" ]
194,528
<p>I have a ASP.Net page using ADO to query MS access database and as a learning exercise i would like to incorporate LINQ. I have one simple table called Quotes.</p> <p>The fields are: QuoteID, QuoteDescription, QuoteAuthor, QuoteDate. I would like to run simple queries like, "Give me all quotes after 1995". </p> <p>How would i incorporate LINQ into this ASP.Net site (C#)</p> <p>Basically, my question is does LINQ work for MS Access ??</p>
[ { "answer_id": 194651, "author": "Ryan Lundy", "author_id": 5486, "author_profile": "https://Stackoverflow.com/users/5486", "pm_score": 5, "selected": true, "text": "var year = 1995; // you can pass the year into a method so you can filter on any year\nvar results = from row in dsQuotes...
2008/10/11
[ "https://Stackoverflow.com/questions/194528", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4653/" ]
194,534
<p>I have been looking at various dependency injection frameworks for .NET as I feel the project I am working on would greatly benefit from it. While I think I have a good grasp of the <em>capabilities</em> of these frameworks, I am still a little unclear on how best to introduce them into a large system. Most demos (understandably) tend to be of quite simple classes that have one or two dependencies. </p> <p>I have three questions...</p> <p><strong>First</strong>, how do you deal with those common but uninteresting dependencies, e.g. ILog, IApplicationSettings, IPermissions, IAudit. It seems overkill for every class to have these as parameters in their constructor. Would it be better to use a static instance of the DI container to get these when they are needed?</p> <pre><code>MyClass(ILog log, IAudit audit, IPermissions permissions, IApplicationSettings settings) // ... versus ... ILog log = DIContainer.Get&lt;ILog&gt;(); </code></pre> <p><strong>Second</strong>, how do you approach dependencies that <em>might</em> be used, but may be expensive to create. Example - a class might have a dependency on an ICDBurner interface but not want the concrete implementation to be created unless the CD Burning feature was actually used. Do you pass in interfaces to factories (e.g. ICDBurnerFactory) in the constructor, or do you again go with some static way of getting directly to the DI Container and ask for it at the point it is needed?</p> <p><strong>Third</strong>, suppose you have a large Windows Forms application, in which the top level GUI component (e.g. MainForm) is the parent of potentially hundreds of sub-panels or modal forms, each of which may have several dependencies. Does this mean that MainForm should be set up to have as dependencies the superset of all the dependencies of its children? And if you did so, wouldn't this end up creating a huge self-inflating monster that constructs every single class it could ever need the moment you create MainForm, wasting time and memory in the process?</p>
[ { "answer_id": 198911, "author": "Maurice", "author_id": 19676, "author_profile": "https://Stackoverflow.com/users/19676", "pm_score": 4, "selected": true, "text": "IUnityContainer container = new UnityContainer();\ncontainer.RegisterInstance<IUnityContainer>(container);\n" }, { ...
2008/10/11
[ "https://Stackoverflow.com/questions/194534", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7532/" ]
194,565
<p>I have to implement the VinPower application. They offer a Java version, a C dll and an ActiveX dll, if anyone has an idea on where I could begin, I'd appreciate it.</p>
[ { "answer_id": 194911, "author": "Peter Boughton", "author_id": 9360, "author_profile": "https://Stackoverflow.com/users/9360", "pm_score": 2, "selected": true, "text": "<cfset vp = createObject(\"java\",\"com.pki.vp4j.VinPower\") />\n\n<cfset rc = vp.decodeVIN(\"JTEDP21A650046919\") />\...
2008/10/11
[ "https://Stackoverflow.com/questions/194565", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26121/" ]
194,574
<p>I was trying to insert new data into an existing XML file, but it's not working. Here's my xml file:</p> <pre><code>&lt;list&gt; &lt;activity&gt;swimming&lt;/activity&gt; &lt;activity&gt;running&lt;/activity&gt; &lt;list&gt; </code></pre> <p>Now, my idea was making two files: an index page, where it displays what's on the file and provides a field for inserting new elements, and a php page which will insert the data into the XML file. Here's the code for index.php:</p> <pre><code>&lt;html&gt; &lt;head&gt;&lt;title&gt;test&lt;/title&gt;&lt;/head&gt; &lt;/head&gt; &lt;?php $xmldoc = new DOMDocument(); $xmldoc-&gt;load('sample.xml', LIBXML_NOBLANKS); $activities = = $xmldoc-&gt;firstChild-&gt;firstChild; if($activities!=null){ while(activities!=null){ echo $activities-&gt;textContent.'&lt;br/&gt;'; activities = activities-&gt;nextSibling. } } ?&gt; &lt;form name='input' action='insert.php' method='post'&gt; insert activity: &lt;input type='text' name='activity'/&gt; &lt;input type='submit' value='send'/&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html </code></pre> <p>and here's the code for insert.php:</p> <pre><code>&lt;?php header('Location:index.php'); $xmldoc = new DOMDocument(); $xmldoc-&gt;load('sample.xml'); $newAct = $_POST['activity']; $root = $xmldoc-&gt;firstChild; $newElement = $xmldoc-&gt;createElement('activity'); $root-&gt;appendChild($newElement); $newText = $xmldoc-&gt;createTextNode($newAct); $newElement-&gt;appendChild($newText); $xmldoc-&gt;save('sample.xml'); ?&gt; </code></pre> <p>The user is to access index.php, where he would see a list of the current activities present in the XML file, and a text field below where he can insert new activities. Upon clicking the send button, the page would call insert.php, which contains a code that opens the XML file in a DOM tree, inserts a new node under the root node and calls back the index.php page, where the user should be able to see the list of activities, his new activity there under the others. It is not working. When i click on the button to submit a new entry, the pages refreshes and apparently nothing happens, the XML is the same as before. What did i do wrong? Also, i'd like to know if there's a better way of doing it.</p>
[ { "answer_id": 194637, "author": "Owen", "author_id": 4853, "author_profile": "https://Stackoverflow.com/users/4853", "pm_score": 4, "selected": true, "text": "<form name='input' action'insert.php' method='post'> // should be:\n<form name=\"input\" action=\"insert.php\" method=\"post\">\...
2008/10/11
[ "https://Stackoverflow.com/questions/194574", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27090/" ]
194,579
<p>I've got a php page which handles requets for file downloads. I need to be able to detect when a file has been downloaded successfully. How can this be done? Perhaps there's some means of detecting this client-side then sending a confirmation down to the server.</p> <p>Thanks.</p> <p>Edit: By handle, I mean that the page is doing something like this:</p> <pre><code>$file = '/var/www/html/file-to-download.xyz'; header('Content-Type: application/octet-stream'); header('Content-Length: ' . filesize($file)); header('Content-Disposition: attachment; filename=' . basename($file)); readfile($file); </code></pre>
[ { "answer_id": 194618, "author": "Treb", "author_id": 22114, "author_profile": "https://Stackoverflow.com/users/22114", "pm_score": 5, "selected": true, "text": "readfile($file);" }, { "answer_id": 196246, "author": "Willem", "author_id": 15447, "author_profile": "htt...
2008/10/11
[ "https://Stackoverflow.com/questions/194579", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19467/" ]
194,584
<p>Other than standard OO concepts, what are some other strategies that allow for producing good, clean PHP code when a framework is not being used?</p>
[ { "answer_id": 195378, "author": "Javier", "author_id": 11649, "author_profile": "https://Stackoverflow.com/users/11649", "pm_score": 6, "selected": true, "text": "?>" } ]
2008/10/11
[ "https://Stackoverflow.com/questions/194584", "https://Stackoverflow.com", "https://Stackoverflow.com/users/572/" ]
194,616
<p>I have an application installed on my computer. How do I find out if it was compiled in DEBUG mode or not?</p> <p>I've tried to use <a href="http://en.wikipedia.org/wiki/.NET_Reflector" rel="noreferrer">.NET Reflector</a>, but it does not show anything specific. Here is what I see:</p> <pre><code>// Assembly APPLICATION_NAME, Version 8.0.0.15072 Location: C:\APPLICATION_FOLDER\APPLICATION_NAME.exe Name: APPLICATION_NAME, Version=8.0.0.15072, Culture=neutral, PublicKeyToken=null Type: Windows Application </code></pre>
[ { "answer_id": 194625, "author": "ZombieSheep", "author_id": 377, "author_profile": "https://Stackoverflow.com/users/377", "pm_score": 5, "selected": false, "text": "private void testfile(string file)\n{\n if(isAssemblyDebugBuild(file))\n {\n MessageBox.Show(String.Format(\"...
2008/10/11
[ "https://Stackoverflow.com/questions/194616", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
194,621
<p>I know there are a few different <a href="http://en.wikipedia.org/wiki/Traveling_salesman_problem" rel="nofollow noreferrer">Traveling Salesman</a> projects out there and I've played with <a href="http://www.akira.ruc.dk/~keld/research/LKH/" rel="nofollow noreferrer">LKH</a> a bit, but I was wondering if anyone had any recommendations on any other ones?</p> <p>My project is GPL'ed so I would need something that is compatible with that license.</p> <p><img src="https://i.stack.imgur.com/6WnwE.gif" alt="Input"> <img src="https://i.stack.imgur.com/lAUwq.gif" alt="Output"></p>
[ { "answer_id": 197110, "author": "dsm", "author_id": 7780, "author_profile": "https://Stackoverflow.com/users/7780", "pm_score": 2, "selected": false, "text": "(defvar *grid-width* 100000)\n(defvar *grid-heigth* 100000)\n(defvar *max-number-of-points* 1000)\n(defvar *search-area-width* (...
2008/10/11
[ "https://Stackoverflow.com/questions/194621", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13676/" ]
194,628
<p>IOKit and the DiskArbitration framework can tell me a lot of things about mounted volumes on a mac, but they don't seem to be able to differentiate between HFS+ and HFS Standard volumes. </p> <p>The IOKit/DA keys <code>Content</code>, <code>DAVolumeKind</code> and <code>DAMediaContent</code> are always Apple_HFS and hfs for both HFS Standard and HFS+ volumes.</p> <p>diskutil and DiskUtility.app <em>can</em> tell the difference, but I they don't seem to have been open sourced by Apple. </p> <p>p.s. statfs (2) does not differentiate</p>
[ { "answer_id": 194722, "author": "Brian Webster", "author_id": 23324, "author_profile": "https://Stackoverflow.com/users/23324", "pm_score": 4, "selected": true, "text": "getattrlist()" }, { "answer_id": 550570, "author": "mouviciel", "author_id": 45249, "author_profi...
2008/10/11
[ "https://Stackoverflow.com/questions/194628", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22147/" ]
194,634
<p>I have read several places that the difference between <code>c_str()</code> and <code>data()</code> (in STL and other implementations) is that <code>c_str()</code> is always null terminated while <code>data()</code> is not. As far as I have seen in actual implementations, they either do the same or <code>data()</code> calls <code>c_str()</code>.</p> <p>What am I missing here? Which one is more correct to use in which scenarios?</p>
[ { "answer_id": 194638, "author": "Scott Langham", "author_id": 11898, "author_profile": "https://Stackoverflow.com/users/11898", "pm_score": 7, "selected": false, "text": "c_str()" }, { "answer_id": 194654, "author": "Brian R. Bondy", "author_id": 3153, "author_profil...
2008/10/11
[ "https://Stackoverflow.com/questions/194634", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
194,650
<p>Simply put, is there a way to create a 2D javascript array using similar syntax to this?</p> <pre><code>var newArray = [ [0, 1, 2], [3, 4, 5], [6, 7, 8] ] </code></pre>
[ { "answer_id": 194660, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "<script>\nvar newArray = [\n [0, 1, 2],\n [3, 4, 5],\n [6, 7, 8]\n]\nalert(newArray[0][2]);\n</script>\n" }, { ...
2008/10/11
[ "https://Stackoverflow.com/questions/194650", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1384652/" ]
194,652
<p>Is there any regular expression library written in T-SQL (no CLR, no extended <code>SP</code>, pure T-SQL) for SQL Server, and that should work with shared hosting?</p> <p>Edit:</p> <ul> <li>Thanks, I know about <code>PATINDEX</code>, <code>LIKE</code>, <code>xp_</code> <code>sps</code> and CLR solutions</li> <li>I also know it is not the best place for regex, the question is theoretical :)</li> <li>Reduced functionality is also accepted</li> </ul>
[ { "answer_id": 198986, "author": "Eric Z Beard", "author_id": 1219, "author_profile": "https://Stackoverflow.com/users/1219", "pm_score": 6, "selected": false, "text": "Wildcard Meaning \n% Any string of zero or more characters.\n\n_ Any single character.\n\n[ ] Any single character wi...
2008/10/11
[ "https://Stackoverflow.com/questions/194652", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2622295/" ]
194,663
<p>I'm new to Flex SDK and trying to implement a simple project using <a href="http://dougmccune.com/blog/2007/11/19/flex-coverflow-performance-improvement-flex-carousel-component-and-vertical-coverflow/" rel="nofollow noreferrer">Doug Mccune's CoverFlow</a> widget. Most of the documentation out there on how to do this assumes that one is using Adobe's FlexBuilder product, which is a $250 Eclipse plug-in that I'd rather avoid buying. The problem I'm having is simply getting Doug's swc file, which is the binary version of his component lib, to be recognized by mxmlc, the Flex SDK project compiler. I keep getting error messages such as</p> <blockquote> <p>Error: Could not resolve to a component installation</p> </blockquote> <p>and</p> <blockquote> <p>Error: Type was not found or was not a compile-time constant: CoverFlow.</p> </blockquote> <p>I have also tried the type "VideoCoverFlow" as I am pretty sure that these types are defined in Doug's lib. Alas, I am stuck on figuring out where I've gone wrong.</p> <p>The following is the full text for my mxml project file, called coverflow.mxml.</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:local="*" height="100%" width="100%" layout="absolute"&gt; &lt;local:CoverFlow id="CoverFlow" horizontalCenter="0" verticalCenter="0" borderThickness="10" borderColor="#FFFFFF" width="100%"/&gt; &lt;/mx:Application&gt; </code></pre> <p>I am trying to compile it with the following command:</p> <pre><code>c:\flex_sdk_3\bin\mxmlc.exe -compiler.source-path=lib coverflow.mxml </code></pre> <p>I have also tried moving the CoverFlow_lib.swc file into the same dir as the mxml file instead of using the source-path argument, but that does not seem to make a difference.</p> <p>I would gladly go RTFM if somebody could be so kind as to point me in the direction of the proper docs. There are related Stack Overflow questions <a href="https://stackoverflow.com/questions/78230/compiling-mxml-files-with-ant-and-flex-sdk">here</a> and <a href="https://stackoverflow.com/questions/119947/using-flash-component-swc-file-in-flex">here</a>.</p> <p>Thank you!</p> <hr> <p><strong>Update</strong>: I have changed my build command to the following:</p> <pre><code>mxmlc -library-path+=lib coverflow.mxml </code></pre> <p>And I also tried the following:</p> <pre><code>mxmlc -library-path+=CoverFlow_lib.swc coverflow.mxml </code></pre> <p>With the swc file in the same dir as the mxml file. However, I'm still getting the same errors.</p> <p>There's also a <a href="http://www.adobe.com/products/flex/media/flexapp/" rel="nofollow noreferrer">video here</a> showing the same library that I'm trying to use, but in Flex Builder. Unfortunately, it doesn't show how to use mxmlc.</p> <p>I've also tried stripping down my mxml to simply,</p> <pre><code>&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:local="*" &gt; &lt;local:VideoCoverFlow /&gt; &lt;/mx:Application&gt; </code></pre>
[ { "answer_id": 194682, "author": "James Fassett", "author_id": 27081, "author_profile": "https://Stackoverflow.com/users/27081", "pm_score": 4, "selected": true, "text": "mxmlc -help list" }, { "answer_id": 194716, "author": "Parappa", "author_id": 9974, "author_profi...
2008/10/11
[ "https://Stackoverflow.com/questions/194663", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9974/" ]
194,666
<p>Is there a way to suppress warnings in Xcode?</p> <p>For example I am calling an undocumented method and since the method is not in the header I get a warning on compile. I know I can add it to my header to stop the warning, but I am wondering if there is a way other than adding it to the header (so I can keep the headers clean and standard) to suppress the warning? A pragma or something?</p>
[ { "answer_id": 196781, "author": "robottobor", "author_id": 10184, "author_profile": "https://Stackoverflow.com/users/10184", "pm_score": 7, "selected": false, "text": "#pragma GCC diagnostic ignored \"-Wwarning-flag\"\n" }, { "answer_id": 1480048, "author": "Mark Pauley", ...
2008/10/11
[ "https://Stackoverflow.com/questions/194666", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26728/" ]
194,698
<p>I was asked to build a java system that will have the ability to load new code (expansions) while running. How do I re-load a jar file while my code is running? or how do I load a new jar?</p> <p>Obviously, since constant up-time is important, I'd like to add the ability to re-load existing classes while at it (if it does not complicate things too much).</p> <p>What are the things I should look out for? (think of it as two different questions - one regarding reloading classes at runtime, the other regarding adding new classes).</p>
[ { "answer_id": 194708, "author": "Amir Arad", "author_id": 11813, "author_profile": "https://Stackoverflow.com/users/11813", "pm_score": 2, "selected": false, "text": "File file = getJarFileToLoadFrom(); \nString lcStr = getNameOfClassToLoad(); \nURL jarfile = new URL(\"jar\", \"\",\...
2008/10/11
[ "https://Stackoverflow.com/questions/194698", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11813/" ]
194,725
<p>I am a heavy command line user and use the <code>find</code> command extensively in my build system scripts. However on Mac OS X when I am not concentrating I often get output like this:</p> <pre><code>$ find -name \*.plist find: illegal option -- n find: illegal option -- a find: illegal option -- m find: illegal option -- e find: *.plist: No such file or directory </code></pre> <p>Basically, I forgot to add the little dot:</p> <pre><code>$ find . -name \*.plist </code></pre> <p>Because BSD <code>find</code> requires the path and GNU <code>find</code> doesn't (it assumes the current directory if you don't specify one). I use Linux, Mac OS X and Cygwin often all at the same time, so it's of great benefit to me to have all my tools behave the same. I tried writing a bash <code>find</code> function that added "./" if I forgot, but I failed. Thanks for your help. :)</p>
[ { "answer_id": 194732, "author": "Owen", "author_id": 4853, "author_profile": "https://Stackoverflow.com/users/4853", "pm_score": 2, "selected": false, "text": "find ./ -name \"*.plist\"\n" }, { "answer_id": 194737, "author": "James Fassett", "author_id": 27081, "auth...
2008/10/11
[ "https://Stackoverflow.com/questions/194725", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6444/" ]
194,733
<p>If I have a method such as:</p> <pre><code>private function testMethod(param:string):void { // Get the object that called this function } </code></pre> <p>Inside the testMethod, can I work out what object called us? e.g.</p> <pre><code>class A { doSomething() { var b:B = new B(); b.fooBar(); } } class B { fooBar() { // Can I tell that the calling object is type of class A? } } </code></pre>
[ { "answer_id": 194745, "author": "James Fassett", "author_id": 27081, "author_profile": "https://Stackoverflow.com/users/27081", "pm_score": 4, "selected": true, "text": "arguments" }, { "answer_id": 958720, "author": "Community", "author_id": -1, "author_profile": "h...
2008/10/11
[ "https://Stackoverflow.com/questions/194733", "https://Stackoverflow.com", "https://Stackoverflow.com/users/986/" ]
194,742
<p>What is the best way to determine whether there is an available Internet connection for a WinForms app. (Programatically of course) I want to disable/hide certain functions if the user is not connected to the Internet.</p>
[ { "answer_id": 194747, "author": "QAZ", "author_id": 14260, "author_profile": "https://Stackoverflow.com/users/14260", "pm_score": 3, "selected": false, "text": "bool IsInternetConnected( void )\n{\n DWORD dwConnectionFlags = 0;\n\n if( !InternetGetConnectedState( &dwConnectionFlag...
2008/10/11
[ "https://Stackoverflow.com/questions/194742", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5019/" ]
194,754
<p>Is there any good tool or tool-chain that allows UML images in the .svg format to be created from a textual source file? The reason for this question is that I want to automate the generation of these images to avoid having to manually create and update this set of images.</p>
[ { "answer_id": 17568112, "author": "Pranav 웃", "author_id": 993915, "author_profile": "https://Stackoverflow.com/users/993915", "pm_score": 2, "selected": false, "text": "underscore.js" }, { "answer_id": 21622594, "author": "Jonathan Hartley", "author_id": 10176, "aut...
2008/10/11
[ "https://Stackoverflow.com/questions/194754", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27134/" ]
194,759
<p>I've got a client that, during testing, is giving me conflicting information. I don't think they are lying but more confused. So, I would like to setup some simple auditing in my ASP.Net application. Specifically, right when any page is called, I want to immediately insert the Querystring and/or form POST data into a log table. Just the raw values.</p> <p>Querystring is easy. But there doesn't seem to be a way to get the raw form POST'ed data without using BinaryRead, and if I do that, then I screw myself out of using the Request.Form collection later on.</p> <p>Does anyone know a way around this?</p> <p>EDIT: tvanfosson suggested Request.Params. I was looking for something that was easier to use (like Request.Querystring, only for POST), but I guess I could just as easily loop through all params and build a string of name=value&amp;, etc).</p>
[ { "answer_id": 194910, "author": "Eduardo Campañó", "author_id": 12091, "author_profile": "https://Stackoverflow.com/users/12091", "pm_score": 2, "selected": false, "text": "public class CustomModule : IHttpModule \n{\n public void Init(HttpApplication context)\n {\n context...
2008/10/11
[ "https://Stackoverflow.com/questions/194759", "https://Stackoverflow.com", "https://Stackoverflow.com/users/232/" ]
194,765
<p>At the moment a default entry looks something like this:</p> <pre><code>Oct 12, 2008 9:45:18 AM myClassInfoHere INFO: MyLogMessageHere </code></pre> <p>How do I get it to do this?</p> <pre><code>Oct 12, 2008 9:45:18 AM myClassInfoHere - INFO: MyLogMessageHere </code></pre> <p>Clarification I'm using java.util.logging</p>
[ { "answer_id": 195147, "author": "Obediah Stane", "author_id": 23120, "author_profile": "https://Stackoverflow.com/users/23120", "pm_score": 3, "selected": false, "text": " public String format(LogRecord record) {\n return new java.util.Date() + \" \" + record.getLevel() + \" \...
2008/10/11
[ "https://Stackoverflow.com/questions/194765", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23120/" ]
194,803
<p>I'm currently developing a website and my client wants the text of various articles to overflow into two columns. Kind of like in a newspaper? So it would look like:</p> <pre class="lang-none prettyprint-override"><code>Today in Wales, someone actually Nobody was harmed in did something interesting. the incident, although one Authorities are baffled by this elderly victim is receiving development and have arrested the counselling. perpetrator. </code></pre> <p>Is there a way I can do this with just CSS alone? I'd prefer not to have to use multiple divs. I'm open to using JavaScript too, but I'm <em>really</em> bad at that, so help would be appreciated. I was thinking maybe JavaScript could count how many &lt;p&gt;'s there are in the content div, and then move the second half of them to be floated right based on that?</p>
[ { "answer_id": 194818, "author": "Matthew Scharley", "author_id": 15537, "author_profile": "https://Stackoverflow.com/users/15537", "pm_score": 3, "selected": false, "text": "$content = \"Today in Wales, someone actually did something...\";\n// Find the literal halfway point, should be c...
2008/10/11
[ "https://Stackoverflow.com/questions/194803", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12765/" ]
194,821
<p>What is the most efficient way to go through and update every single node in a drupal site, to, for instance mechanically add tags? Drupal 6 has a shiny new batch API, but what to do in Drupal 5?</p> <p>I started writing a script that keeps a pointer and then goes around all nodes on a cron, loads them and then saves them, but I wonder what else could be done.</p>
[ { "answer_id": 194838, "author": "Owen", "author_id": 4853, "author_profile": "https://Stackoverflow.com/users/4853", "pm_score": 0, "selected": false, "text": "term_node" } ]
2008/10/11
[ "https://Stackoverflow.com/questions/194821", "https://Stackoverflow.com", "https://Stackoverflow.com/users/556/" ]
194,828
<p>Is it possible to initialize an array of pointers to structs? Something like:</p> <pre><code>struct country_t *countries[] = { {"United States of America", "America"}, {"England", "Europe"}, {"Ethiopia", "Africa"} } </code></pre> <p>I want to do that in order to get the entities in not-contiguous memory, and the pointers to them in contiguous memory... But I can't use dynamic memory, so I wonder if it is possible without it.</p>
[ { "answer_id": 194840, "author": "Jonathan Leffler", "author_id": 15168, "author_profile": "https://Stackoverflow.com/users/15168", "pm_score": 5, "selected": false, "text": "static struct country_t us = { \"United States of America\", \"America\" };\nstatic struct country_t uk = { \"Eng...
2008/10/11
[ "https://Stackoverflow.com/questions/194828", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
194,842
<p>Is it possible to make such buttons (<a href="http://img225.imageshack.us/img225/6452/buttonslw9.jpg" rel="nofollow noreferrer">http://img225.imageshack.us/img225/6452/buttonslw9.jpg</a>) using CSS? It should be Menu, and PHP would just feed the text to html/css and css should take care of the design. </p> <p>Maybe I want too much out of CSS - especially with that red outline of the text.. ? Any ideas how i can achieve such results without doing those buttons manually in Graphical Editor?</p>
[ { "answer_id": 194880, "author": "Kornel", "author_id": 27009, "author_profile": "https://Stackoverflow.com/users/27009", "pm_score": 2, "selected": true, "text": "text-shadow" } ]
2008/10/11
[ "https://Stackoverflow.com/questions/194842", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21209/" ]
194,846
<p>Basically, I'm trying to create an object of unique objects, a set. I had the brilliant idea of just using a JavaScript object with objects for the property names. Such as,</p> <pre><code>set[obj] = true; </code></pre> <p>This works, up to a point. It works great with string and numbers, but with other objects, they all seem to "hash" to the same value and access the same property. Is there some kind of way I can generate a unique hash value for an object? How do strings and numbers do it, can I override the same behavior?</p>
[ { "answer_id": 194906, "author": "eyelidlessness", "author_id": 17964, "author_profile": "https://Stackoverflow.com/users/17964", "pm_score": 6, "selected": true, "text": "var ObjectReference = [];\nObjectReference.push(obj);\n\nset['ObjectReference.' + ObjectReference.indexOf(obj)] = tr...
2008/10/11
[ "https://Stackoverflow.com/questions/194846", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16492/" ]
194,852
<p>Consider a database table holding names, with three rows:</p> <pre><code>Peter Paul Mary </code></pre> <p>Is there an easy way to turn this into a single string of <code>Peter, Paul, Mary</code>?</p>
[ { "answer_id": 194875, "author": "Darryl Hein", "author_id": 5441, "author_profile": "https://Stackoverflow.com/users/5441", "pm_score": 7, "selected": false, "text": "SELECT 1 AS a, GROUP_CONCAT(name ORDER BY name ASC SEPARATOR ', ') AS people \nFROM users \nWHERE id IN (1,2,3) \nGROUP ...
2008/10/11
[ "https://Stackoverflow.com/questions/194852", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27109/" ]
194,863
<p>I'm looking for some succinct, modern C# code to generate a random date between Jan 1 1995 and the current date.</p> <p>I'm thinking some solution that utilizes Enumerable.Range somehow may make this more succinct.</p>
[ { "answer_id": 194870, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 9, "selected": true, "text": "private Random gen = new Random();\nDateTime RandomDay()\n{\n DateTime start = new DateTime(1995, 1, 1);\n int ra...
2008/10/12
[ "https://Stackoverflow.com/questions/194863", "https://Stackoverflow.com", "https://Stackoverflow.com/users/536/" ]
194,869
<p>I am working on a project that does a large amount of hashing, signing, and both asymmetric and symmetric encryption. Since these steps have a significant effect on our performance and available load, I was wondering if there is a hardware based solution to offloading the work. </p> <p>I have done some surfing to find out, and the only items I can find are dedicated to SSL based communications. I need a more generic solution that will allow me to speed up signing and encryption regardless of where it occurs. </p> <p>Is it possible to adapt these SSL based solutions (maybe it's just marketing and it would be easy to re-use elsewhere)? Is there a good generic co-processor that can help out? </p> <p>I need this on a Windows Server 2008 based box, but I would be interested in solutions on any platform.</p>
[ { "answer_id": 194870, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 9, "selected": true, "text": "private Random gen = new Random();\nDateTime RandomDay()\n{\n DateTime start = new DateTime(1995, 1, 1);\n int ra...
2008/10/12
[ "https://Stackoverflow.com/questions/194869", "https://Stackoverflow.com", "https://Stackoverflow.com/users/71994/" ]
194,890
<p>I have a large project that I want to start using visual studio 2005 to edit. I want to tell it "Here are all the files I want you to track, now get on with it" and have them displayed as a directory tree, for example:</p> <pre><code>Folder 1 - File A - File B - File C Folder 2 - Folder 3 - File X - File Y - File D - File E </code></pre> <p>Right now it's just showing all the header files in one big list, and all the source files in one big list, which I find unhelpful. I also don't want to spend ages creating a folder in the project for each folder on the disk.</p> <p>Is there any way I can get VS to show me a source tree of everything in the solution, organised by where it is on the actual disk?</p> <p>Thanks.</p>
[ { "answer_id": 3599629, "author": "crayor", "author_id": 434800, "author_profile": "https://Stackoverflow.com/users/434800", "pm_score": 0, "selected": false, "text": "Datei >> Neu >> Projekt aus vorhandenem Code" } ]
2008/10/12
[ "https://Stackoverflow.com/questions/194890", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13500/" ]
194,914
<p>What's the best way of adding spaces between strings</p> <pre><code>myString = string.Concat("a"," ","b") </code></pre> <p>or</p> <pre><code>myString = string.Concat("a",Chr(9),"b") </code></pre> <p>I am using stringbuilder to build an XML file and looking for something efficient.</p> <p>Thanks</p> <p>Edit ~ Language VB.NET</p>
[ { "answer_id": 194918, "author": "defeated", "author_id": 16997, "author_profile": "https://Stackoverflow.com/users/16997", "pm_score": 3, "selected": false, "text": "string sentence = String.Join(\" \", new string[] { \"The\", \"quick\", \"brown\", \"fox\" });\n" }, { "answer_id...
2008/10/12
[ "https://Stackoverflow.com/questions/194914", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23667/" ]
194,930
<p>I got one big question.</p> <p>I got a linq query to put it simply looks like this:</p> <pre><code>from xx in table where xx.uid.ToString().Contains(string[]) select xx </code></pre> <p>The values of the <code>string[]</code> array would be numbers like (1,45,20,10,etc...)</p> <p>the Default for <code>.Contains</code> is <code>.Contains(string)</code>.</p> <p>I need it to do this instead: <code>.Contains(string[])</code>...</p> <p><strong>EDIT :</strong> One user suggested writing an extension class for <code>string[]</code>. I would like to learn how, but any one willing to point me in the right direction?</p> <p><strong>EDIT :</strong> The uid would also be a number. That's why it is converted to a string.</p> <p>Help anyone?</p>
[ { "answer_id": 194939, "author": "spoulson", "author_id": 3347, "author_profile": "https://Stackoverflow.com/users/3347", "pm_score": 2, "selected": false, "text": "from xx in table\nwhere stringarray.Contains(xx.uid.ToString())\nselect xx\n" }, { "answer_id": 194970, "author...
2008/10/12
[ "https://Stackoverflow.com/questions/194930", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7644/" ]
194,944
<p>I am creating a lightweight editor in C# and would like to know the best method for converting a string into a nicely formatted XML string. I would hope that there's a public method in the C# library like "public bool FormatAsXml(string text, out string formattedXmlText)", but it couldn't be that easy, could it?</p> <p>Very specifically, what would the method "SomeMethod" have to be that would produce the output below?</p> <pre><code>string unformattedXml; string formattedXml; unformattedXml = "&lt;?xml version=\"1.0\"?&gt;&lt;book&gt;&lt;author&gt;Lewis, C.S.&lt;/author&gt;&lt;title&gt;The Four Loves&lt;/title&gt;&lt;/book&gt;" formattedXml = SomeMethod(unformattedXml); Console.WriteLine(formattedXml); </code></pre> <p>Output:</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;book id="123"&gt; &lt;author&gt;Lewis, C.S.&lt;/author&gt; &lt;title&gt;The Four Loves&lt;/title&gt; &lt;/book&gt; </code></pre>
[ { "answer_id": 194951, "author": "rp.", "author_id": 2536, "author_profile": "https://Stackoverflow.com/users/2536", "pm_score": 0, "selected": false, "text": "XmlDocument xml = new XmlDocument();\n\nxml.LoadXml( YourString );\n" }, { "answer_id": 194956, "author": "defeated"...
2008/10/12
[ "https://Stackoverflow.com/questions/194944", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27109/" ]
194,976
<p>I thought the web page designer screen in 2005 was mediocre until I used the one in 2008 which I think is bad. There is an interesting white paper here:</p> <p><a href="http://www.west-wind.com/weblog/posts/484172.aspx" rel="nofollow noreferrer">http://www.west-wind.com/weblog/posts/484172.aspx</a></p> <p>I've gotten very used to these WYSIWYG designers over the years, but I am looking now for a new way. </p> <p>I make business web apps which call for data entry forms. I don't need anything particularly artistic, but I do need to be able to line up text boxes etc on input forms so that they lkook orderly and are convenient for the user. I use Telerik controls, and my skills with CSS are approaching passable.</p> <p>People often mention that they don't use the designer, but they rarely state what approach they DO use.</p> <p>What are some of the alternatives to using the VS designer? </p>
[ { "answer_id": 194951, "author": "rp.", "author_id": 2536, "author_profile": "https://Stackoverflow.com/users/2536", "pm_score": 0, "selected": false, "text": "XmlDocument xml = new XmlDocument();\n\nxml.LoadXml( YourString );\n" }, { "answer_id": 194956, "author": "defeated"...
2008/10/12
[ "https://Stackoverflow.com/questions/194976", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
194,999
<p>On an ASP.NET website, are static classes unique to each web request, or are they instantiated whenever needed and GCed whenever the GC decides to disposed of them?</p> <p>The reason I ask is because I've written some static classes before in C# and the behavior is different than I would have expected. I would have expected static classes to be unique to each request, but it doesn't seem like that is the case.</p> <p>If they are not unique to each request, is there a way to allow them to be?</p> <p><strong>UPDATE:</strong><br> The answer driis gave me was exactly what I needed. I was already using a singleton class, however it was using a static instance and therefore was being shared between requests even if the users were different which in this case was a bad thing. Using <code>HttpContext.Current.Items</code> solves my problem perfectly. For anyone who stumbles upon this question in the future, here is my implementation, simplified and shortened so that it easy to understand the pattern:</p> <pre><code>using System.Collections; using System.Web; public class GloballyAccessibleClass { private GloballyAccessibleClass() { } public static GloballyAccessibleClass Instance { get { IDictionary items = HttpContext.Current.Items; if(!items.Contains("TheInstance")) { items["TheInstance"] = new GloballyAccessibleClass(); } return items["TheInstance"] as GloballyAccessibleClass; } } } </code></pre>
[ { "answer_id": 195290, "author": "driis", "author_id": 13627, "author_profile": "https://Stackoverflow.com/users/13627", "pm_score": 8, "selected": true, "text": "HttpContext.Current.Items" }, { "answer_id": 195297, "author": "Sklivvz", "author_id": 7028, "author_prof...
2008/10/12
[ "https://Stackoverflow.com/questions/194999", "https://Stackoverflow.com", "https://Stackoverflow.com/users/392/" ]
195,008
<p>What is code coverage and how do YOU measure it?</p> <p>I was asked this question regarding our automating testing code coverage. It seems to be that, outside of automated tools, it is more art than science. Are there any real-world examples of how to use code coverage?</p>
[ { "answer_id": 195044, "author": "azamsharp", "author_id": 3797, "author_profile": "https://Stackoverflow.com/users/3797", "pm_score": 8, "selected": false, "text": "if(customer.IsOldCustomer()) \n{\n}\nelse \n{\n}\n" }, { "answer_id": 195392, "author": "moritz", "author_...
2008/10/12
[ "https://Stackoverflow.com/questions/195008", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3208/" ]
195,010
<p>I have an array of 1000 or so entries, with examples below:</p> <pre><code>wickedweather liquidweather driveourtrucks gocompact slimprojector </code></pre> <p>I would like to be able to split these into their respective words, as:</p> <pre><code>wicked weather liquid weather drive our trucks go compact slim projector </code></pre> <p>I was hoping a regular expression my do the trick. But, since there is no boundary to stop on, nor is there any sort of capitalization that I could possibly key on, I am thinking, that some sort of reference to a dictionary might be necessary? </p> <p>I suppose it could be done by hand, but why - when it can be done with code! =) But this has stumped me. Any ideas? </p>
[ { "answer_id": 195024, "author": "SquareCog", "author_id": 15962, "author_profile": "https://Stackoverflow.com/users/15962", "pm_score": 6, "selected": true, "text": "#!/usr/bin/env perl\n\nuse strict;\nuse warnings;\n\nsub find_matches($);\nsub find_matches_rec($\\@\\@);\nsub find_word_...
2008/10/12
[ "https://Stackoverflow.com/questions/195010", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14728/" ]
195,020
<p>I've just started using Java's enums in my own projects (I have to use JDK 1.4 at work) and I am confused as to the best practice of using JavaDoc for an enum.</p> <p>I have found that this method works, but the resultant code is a little unrefined:</p> <pre><code>/** * Doc for enum */ public enum Something { /** * First thing */ FIRST_THING, /** * Second thing */ SECOND_THING; //could continue with more } </code></pre> <p>Is there any way I could break up the enum declarations on their own lines without chaining them by commas, or is this the best approach for using JavaDoc for an enum?</p>
[ { "answer_id": 195105, "author": "Dov Wasserman", "author_id": 26010, "author_profile": "https://Stackoverflow.com/users/26010", "pm_score": 4, "selected": false, "text": "Something values are used to indicate which mode of operation a client wishes..." } ]
2008/10/12
[ "https://Stackoverflow.com/questions/195020", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8026/" ]
195,036
<p>I've been researching PHP frameworks as of late for some personal projects, and it looks like most of them use a front controller to mimic a response. The controller gets the params from the request, and re-routes by sending the appropriate headers depending on the logic. This is the "response". Is this the best way to do this in PHP, or are there other theories about how to handle re-routing and responses?</p>
[ { "answer_id": 195047, "author": "Owen", "author_id": 4853, "author_profile": "https://Stackoverflow.com/users/4853", "pm_score": 3, "selected": true, "text": "switch($_GET['page']) {\n case \"one\";\n print \"page one!\";\n break;\n default:\n print \"default page\";\n ...
2008/10/12
[ "https://Stackoverflow.com/questions/195036", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
195,058
<p>Below is my $.ajax call, how do I put a selects (multiple) selected values in the data section?</p> <pre><code>$.ajax({ type: "post", url: "http://myServer" , dataType: "text", data: { 'service' : 'myService', 'program' : 'myProgram', 'start' : start, 'end' : end , }, success: function(request) { result.innerHTML = request ; } // End success }); // End ajax method </code></pre> <p><strong>EDIT</strong> I should have included that I understand how to loop through the selects selected options with this code:</p> <pre><code>$('#userid option').each(function(i) { if (this.selected == true) { </code></pre> <p>but how do I fit that into my data: section?</p>
[ { "answer_id": 195064, "author": "Owen", "author_id": 4853, "author_profile": "https://Stackoverflow.com/users/4853", "pm_score": 4, "selected": true, "text": "data: {\n ...\n 'select' : ['value1', 'value2', 'value3'],\n ...\n},\n" }, { "answer_id": 196274, "author":...
2008/10/12
[ "https://Stackoverflow.com/questions/195058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2755/" ]
195,061
<p>I have some assembly that references NUnit and creates a single test class with a single test method. I am able to get the file system path to this assembly (e.g. "C:...\test.dll"). I would like to programmatically use NUnit to run against this assembly.</p> <p>So far I have:</p> <pre><code>var runner = new SimpleTestRunner(); runner.Load(path); var result = runner.Run(NullListener.NULL); </code></pre> <p>However, calling runner.Load(path) throws a FileNotFound exception. I can see through the stack trace that the problem is with NUnit calling Assembly.Load(path) down the stack. If I change path to be something like "Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" then I still get the same error.</p> <p>I have added an event handler to AppDomain.Current.AssemblyResolve to see if I could manually resolve this type but my handler never gets called.</p> <p>What is the secret to getting Assembly.Load(...) to work??</p>
[ { "answer_id": 195066, "author": "Ash", "author_id": 5023, "author_profile": "https://Stackoverflow.com/users/5023", "pm_score": 2, "selected": false, "text": "Assembly a = System.Reflection.Assembly.LoadFrom(pathToFileOnDisk);\n" }, { "answer_id": 450076, "author": "Ricibald...
2008/10/12
[ "https://Stackoverflow.com/questions/195061", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12958/" ]
195,070
<p>I would like the fastest and most accurate function <code>boolean isReachable(String host, int port)</code> that passes the following JUnit tests under the conditions below. Timeout values are specified by the JUnit test itself, and may be considered "unreachable."</p> <p><strong>Please note:</strong> All answers must be platform-independent. This means that <code>InetAddress.isReachable(int timeout)</code> is not going to work, since it relies on port <code>7</code> to do a ping on Windows (ICMP ping being an undocumented function on Windows), and this port is blocked in this setup.</p> <p>LAN Setup:</p> <ul> <li><code>thisMachine</code> (<code>192.168.0.100</code>)</li> <li><code>otherMachine</code> (<code>192.168.0.200</code>)</li> <li><strong>no</strong> machine is called <code>noMachine</code> or has the IP <code>192.168.0.222</code> (always unreachable)</li> <li>both machines are running Apache Tomcat on port <code>8080</code>; all other ports are unreachable (including port <code>7</code>)</li> <li><code>example.com</code> (<code>208.77.188.166</code>) is running a webserver on port <code>80</code> and is only reachable when the LAN is connected to the Internet</li> </ul> <p>Occasionally, the LAN is disconnected from the Internet in which case only local machines called by IP address are reachable (all others are unreachable; there's no DNS).</p> <p><strong>All tests are run on <code>thisMachine</code>.</strong></p> <pre><code>@Test(timeout=1600) // ~320ms per call (should be possible to do better) public void testLocalhost() { // We can always reach ourselves. assertTrue(isReachable("localhost", 8080)); assertTrue(isReachable("127.0.0.1", 8080)); assertTrue(isReachable("thisMachine", 8080)); // Even if there's no DNS! assertTrue(isReachable("192.168.0.100", 8080)); assertFalse(isReachable("localhost", 80)); // Nothing on that port. } @Test(timeout=5500) // ~1867ms per call (should be able to do better) public void testLAN() { assertTrue(isReachable("192.168.0.200", 8080)); // Always connected to the LAN. assertFalse(isReachable("192.168.0.222", 8080)); // No such a machine. assertFalse(isReachable("noMachine", 8080)); // No such machine. } </code></pre> <p>The following test is only run when the LAN is <strong>disconnected</strong> from the Internet.</p> <pre><code>@Test(timeout=5600) // ~1867ms per call (reasonable?) public void testNoDNS() { assertFalse(isReachable("otherMachine", 8080)); // No DNS. assertFalse(isReachable("example.com", 80)); // No DNS &amp; no Internet. assertFalse(isReachable("208.77.188.166", 80)); // No Internet. } </code></pre> <p>The following test is only run when the LAN is <strong>connected</strong> to the Internet.</p> <pre><code>@Test(timeout=5600) // ~1867ms per call (reasonable?) public void testHaveDNS() { assertTrue(isReachable("otherMachine", 8080)); // DNS resolves local names. assertTrue(isReachable("example.com", 80)); // DNS available. assertTrue(isReachable("208.77.188.166", 80)); // Internet available. } </code></pre>
[ { "answer_id": 195071, "author": "grammar31", "author_id": 12815, "author_profile": "https://Stackoverflow.com/users/12815", "pm_score": 0, "selected": false, "text": "TimedSocket" } ]
2008/10/12
[ "https://Stackoverflow.com/questions/195070", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12815/" ]
195,072
<p>I'm experiencing what I believe is a circular dependency issue with my PHP application. Please let me know if this is incorrect. Here is the situation:</p> <p>Two classes, LogManager and DBSession.</p> <p>DBSession is used to interact with the database, and LogManager is used to log to files. Both are widely used in my application. When you create an instance of DBSession, you must give it an instance of LogManager via a constructor parameter. This because DBSession will sometimes log information to a file, and will use the LogManager instance to do this. </p> <p>Now, I wanted to extend LogManager so that it could also log to a database table, rather than a text file. Naturally, my preference is to re-use existing classes, but I soon realized this brought about an interesting situation.</p> <p>DBSession already requires an instance of LogManager for construction. If I want to re-use the DBSession class in LogManager, it will now require an instance of DBSession. How can I satisfy both demands? Clearly, something must be wrong with my approach.</p> <p>How would you suggest I fix this?</p> <p>Thanks in advance, guys.</p>
[ { "answer_id": 195083, "author": "Federico A. Ramponi", "author_id": 18770, "author_profile": "https://Stackoverflow.com/users/18770", "pm_score": 4, "selected": true, "text": "$logManager = new LogManager();\n$dbSession = new DbSession($logManager);\n$logManager->add(new FileLog($filena...
2008/10/12
[ "https://Stackoverflow.com/questions/195072", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21263/" ]
195,078
<p>I need to hide (make private) the <code>-init</code> method of my class in Objective-C.</p> <p>How can I do that?</p>
[ { "answer_id": 195107, "author": "Matt Dillard", "author_id": 863, "author_profile": "https://Stackoverflow.com/users/863", "pm_score": 2, "selected": false, "text": "init" }, { "answer_id": 195223, "author": "Chris Hanson", "author_id": 714, "author_profile": "https:...
2008/10/12
[ "https://Stackoverflow.com/questions/195078", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3740/" ]
195,109
<p>Is it possible to programaticly run compiled Python (comiled via py2exe) as administrator in Vista?</p> <p>Some more clarification:<br /> I have written a program that modifies the windows hosts file (c:\Windows\system32\drivers\etc\hosts) in Vista the program will not run and will fail with an exception unless you right-click and run as administrator even when the user has administrator privileges, unlike in XP where it will run if the user has administration rights, so I need a way to elevate it to the correct privileges programaticly.</p>
[ { "answer_id": 196208, "author": "John Fouhy", "author_id": 15154, "author_profile": "https://Stackoverflow.com/users/15154", "pm_score": 2, "selected": false, "text": "# in setup.py\n# manifest copied from http://blogs.msdn.com/shawnfa/archive/2006/04/06/568563.aspx\nmanifest = '''\n<as...
2008/10/12
[ "https://Stackoverflow.com/questions/195109", "https://Stackoverflow.com", "https://Stackoverflow.com/users/115/" ]
195,114
<p>I'm trying to do a custom button to my form (which has FormBorderStyle = none) using Visual Studio 2005. I have my 3 states button images in an ImageList linked to the button.</p> <pre><code>this.btnClose.AutoSize = false; this.btnClose.BackColor = System.Drawing.Color.Transparent; this.btnClose.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; this.btnClose.FlatAppearance.BorderSize = 0; this.btnClose.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btnClose.ForeColor = System.Drawing.Color.Transparent; this.btnClose.ImageKey = "Disabled"; this.btnClose.ImageList = this.imageList1; this.btnClose.Location = new System.Drawing.Point(368, -5); this.btnClose.Margin = new System.Windows.Forms.Padding(0); this.btnClose.Name = "btnClose"; this.btnClose.Size = new System.Drawing.Size(31, 31); this.btnClose.TabIndex = 0; this.btnClose.UseVisualStyleBackColor = false; this.btnClose.MouseLeave += new System.EventHandler(this.btnClose_MouseLeave); this.btnClose.Click += new System.EventHandler(this.btnClose_Click); this.btnClose.MouseDown += new System.Windows.Forms.MouseEventHandler(this.btnClose_MouseDown); this.btnClose.MouseHover += new System.EventHandler(this.btnClose_MouseHover); private void btnClose_MouseHover(object sender, EventArgs e) { btnClose.ImageKey = "enabled"; } private void btnClose_MouseDown(object sender, MouseEventArgs e) { btnClose.ImageKey = "down"; } private void btnClose_MouseLeave(object sender, EventArgs e) { btnClose.ImageKey = "disabled"; } </code></pre> <p>All is working, but there's one catch. Whenever I move the mouse hover the button I get a really annoying grey background.</p> <p>How can I remove that?</p>
[ { "answer_id": 196202, "author": "Tute", "author_id": 4386, "author_profile": "https://Stackoverflow.com/users/4386", "pm_score": 2, "selected": false, "text": "// \n// imageListButtons\n// \nthis.imageListButtons.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObjec...
2008/10/12
[ "https://Stackoverflow.com/questions/195114", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4386/" ]
195,116
<p>Does anyone know of a faster decimal implementation in python?</p> <p>As the example below demonstrates, the standard library's decimal module is ~100 times slower than <code>float</code>.</p> <pre class="lang-py prettyprint-override"><code>from timeit import Timer def run(val, the_class): test = the_class(1) for c in xrange(10000): d = the_class(val) d + test d - test d * test d / test d ** test str(d) abs(d) if __name__ == "__main__": a = Timer("run(123.345, float)", "from decimal_benchmark import run") print "FLOAT", a.timeit(1) a = Timer("run('123.345', Decimal)", "from decimal_benchmark import run; from decimal import Decimal") print "DECIMAL", a.timeit(1) </code></pre> <p><em>Outputs:</em></p> <pre><code>FLOAT 0.040635041427 DECIMAL 3.39666790146 </code></pre>
[ { "answer_id": 8192918, "author": "Andrew G", "author_id": 995672, "author_profile": "https://Stackoverflow.com/users/995672", "pm_score": 5, "selected": false, "text": "from cdecimal import Decimal\n" }, { "answer_id": 24408798, "author": "Joel Santirso", "author_id": 56...
2008/10/12
[ "https://Stackoverflow.com/questions/195116", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52490/" ]
195,149
<p>I'm wondering if it's possible to sandbox JavaScript running in the browser to prevent access to features that are normally available to JavaScript code running in an HTML page.</p> <p>For example, let's say I want to provide a JavaScript API for end users to let them define event handlers to be run when &quot;interesting events&quot; happen, but I don't want those users to access the properties and functions of the <code>window</code> object. Am I able to do this?</p> <p>In the simplest case, let's say I want to prevent users calling <code>alert</code>. A couple of approaches I can think of are:</p> <ul> <li>Redefine <code>window.alert</code> globally. I don't think this would be a valid approach because other code running in the page (i.e., stuff not authored by users in their event handlers) might want to use <code>alert</code>.</li> <li>Send the event handler code to the server to process. I'm not sure that sending the code to the server to process is the right approach, because the event handlers need to run in the context of the page.</li> </ul> <p>Perhaps a solution where the server processes the user defined function and then generates a callback to be executed on the client would work? Even if that approach works, are there better ways to solve this problem?</p>
[ { "answer_id": 195153, "author": "John Millikin", "author_id": 3560, "author_profile": "https://Stackoverflow.com/users/3560", "pm_score": -1, "selected": false, "text": "undefined" }, { "answer_id": 195156, "author": "Dimitry", "author_id": 27073, "author_profile": "...
2008/10/12
[ "https://Stackoverflow.com/questions/195149", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1654/" ]
195,150
<p>How can I raise an event from a SWF file loaded into a Flex application (using SWFLoader)?</p> <p>I want to be able to detect</p> <pre><code>a) when a button is pressed b) when the animation ends </code></pre>
[ { "answer_id": 195160, "author": "Christophe Herreman", "author_id": 17255, "author_profile": "https://Stackoverflow.com/users/17255", "pm_score": 2, "selected": false, "text": "mySWFLoader.content.addEventListener(\"myEvent\", myEventHandler);\n" }, { "answer_id": 195249, "a...
2008/10/12
[ "https://Stackoverflow.com/questions/195150", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24727/" ]
195,151
<p>I have a ListView in WPF that is databound to a basic table that I pull from the database. The code for the ListView is as follows:</p> <pre><code>&lt;ListView Canvas.Left="402" Canvas.Top="480" Height="78" ItemsSource="{Binding}" Name="lsvViewEditCardPrint" Width="419"&gt; &lt;ListView.View&gt; &lt;GridView&gt; &lt;GridViewColumn DisplayMemberBinding="{Binding Path=IdCst}"&gt;Set&lt;/GridViewColumn&gt; &lt;GridViewColumn DisplayMemberBinding="{Binding Path=Language}"&gt;Language&lt;/GridViewColumn&gt; &lt;GridViewColumn DisplayMemberBinding="{Binding Path=Number}"&gt;Number&lt;/GridViewColumn&gt; &lt;GridViewColumn DisplayMemberBinding="{Binding Path=IdArt}"&gt;Artwork&lt;/GridViewColumn&gt; &lt;/GridView&gt; &lt;/ListView.View&gt; &lt;/ListView&gt; </code></pre> <p>The IdCst column is a foreign key to a separate table, and I'd like to display the actual name field from that table instead of just the Id. Does anybody know how to set a databinding, or is there an event, such as OnItemDataBound, that I could intercept to modify the display?</p>
[ { "answer_id": 198015, "author": "Bob King", "author_id": 6897, "author_profile": "https://Stackoverflow.com/users/6897", "pm_score": 1, "selected": false, "text": "Public ReadOnly Property NameCst() as String\n Get\n Return Names.LookupName(Me.IdCst)\n End Get\nEnd Property...
2008/10/12
[ "https://Stackoverflow.com/questions/195151", "https://Stackoverflow.com", "https://Stackoverflow.com/users/71/" ]
195,173
<p>When you run something similar to:</p> <pre><code>UPDATE table SET datetime = NOW(); </code></pre> <p>on a table with 1 000 000 000 records and the query takes 10 seconds to run, will all the rows have the exact same time (minutes and seconds) or will they have different times? In other words, will the time be when the query started or when each row is updated?</p> <p>I'm running MySQL, but I'm thinking this applies to all dbs.</p>
[ { "answer_id": 11587803, "author": "My Name Goes Here", "author_id": 1541909, "author_profile": "https://Stackoverflow.com/users/1541909", "pm_score": 0, "selected": false, "text": "update TABLE set mydatetime = datetime('now');\n" }, { "answer_id": 38186380, "author": "MRRaj...
2008/10/12
[ "https://Stackoverflow.com/questions/195173", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5441/" ]
195,175
<p>I am new to this community, but I am working on a site that requires implementation of a user/password/register check upon entry, which would check against a database, or write to the database, in the case of registration. I have experience with XHTML and CSS, and just discovered RoR. I honestly have very little insight into how to achieve my goal using just XHTML, so I decided to learn Ruby, taking a shot in the dark. I'm wondering if there's an easier language, or more direct fix that I should be implementing instead. Any thoughts?</p>
[ { "answer_id": 195178, "author": "John Millikin", "author_id": 3560, "author_profile": "https://Stackoverflow.com/users/3560", "pm_score": 0, "selected": false, "text": "acts_as_authenticated" } ]
2008/10/12
[ "https://Stackoverflow.com/questions/195175", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27171/" ]
195,177
<p>I have a Zimbra installation and I need to programmaticaly update contacts in it. It seems that its REST interface is only working to add new contacts, but I need to update existing ones. Is there a way, tool or something, open-source, to do that ?</p>
[ { "answer_id": 195708, "author": "edomaur", "author_id": 14262, "author_profile": "https://Stackoverflow.com/users/14262", "pm_score": 3, "selected": true, "text": "box$ zmmailbox help contact\n\n autoComplete(ac) [opts] {query}\n -v/--verbose verbose outp...
2008/10/12
[ "https://Stackoverflow.com/questions/195177", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14262/" ]
195,207
<p>Very simply put:</p> <p>I have a class that consists mostly of static public members, so I can group similar functions together that still have to be called from other classes/functions.</p> <p>Anyway, I have defined two static unsigned char variables in my class public scope, when I try to modify these values in the same class' constructor, I am getting an "unresolved external symbol" error at compilation.</p> <pre><code>class test { public: static unsigned char X; static unsigned char Y; ... test(); }; test::test() { X = 1; Y = 2; } </code></pre> <p>I'm new to C++ so go easy on me. Why can't I do this?</p>
[ { "answer_id": 195209, "author": "Colin Jensen", "author_id": 9884, "author_profile": "https://Stackoverflow.com/users/9884", "pm_score": 8, "selected": true, "text": "inline" }, { "answer_id": 195233, "author": "sergtk", "author_id": 13441, "author_profile": "https:/...
2008/10/12
[ "https://Stackoverflow.com/questions/195207", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
195,208
<p>I'm attempting to use File.Move to move a file from one UNC location to another. This blows up if the UNC path for the destination happens to be the local machine (error: Access to the path is denied). Example <code>File.Move(@"\\someServer\path\file.txt", @"\\blah2\somewhere\file.txt")</code>. This assumes there's a network share out there somewhere named \\someServer and my local machine name is blah2. Change \\blah2 to C:\ and all is good.</p>
[ { "answer_id": 195232, "author": "Juanma", "author_id": 3730, "author_profile": "https://Stackoverflow.com/users/3730", "pm_score": 2, "selected": false, "text": "@\"\\\\blah2\\somewhere\\file.txt\"" } ]
2008/10/12
[ "https://Stackoverflow.com/questions/195208", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16439/" ]
195,240
<p>I have the following template</p> <pre><code>&lt;h2&gt;one&lt;/h2&gt; &lt;xsl:apply-templates select="one"/&gt; &lt;h2&gt;two&lt;/h2&gt; &lt;xsl:apply-templates select="two"/&gt; &lt;h2&gt;three&lt;/h2&gt; &lt;xsl:apply-templates select="three"/&gt; </code></pre> <p>I would like to only display the headers (one,two,three) if there is at least one member of the corresponding template. How do I check for this?</p>
[ { "answer_id": 195248, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 5, "selected": true, "text": "<xsl:if test=\"one\">\n <h2>one</h2>\n <xsl:apply-templates select=\"one\"/>\n</xsl:if>\n<!-- etc -->\n" }, { ...
2008/10/12
[ "https://Stackoverflow.com/questions/195240", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2133/" ]