qid
int64
4
19.1M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
410,485
<p>What is the <code>7n5lu</code> in the reddit URL </p> <blockquote> <p><a href="http://www.reddit.com/r/reddit.com/comments/7n5lu/man_can_fly_if_you_watch_one_video_in_2" rel="nofollow noreferrer">http://www.reddit.com/r/reddit.com/comments/7n5lu/man_can_fly_if_you_watch_one_video_in_2</a></p> </blockquote> <p>...and how is it generated?</p> <p>Update: @Gerald, I initially thought this is some obfuscation of the id. It is just doing the conversion from integer to a more compact representation. I am thinking, why is this being done? why not use the original integer itself!!</p> <pre><code>&gt;&gt;&gt; to36(4000) '334' &gt;&gt;&gt; to36(4001) '335' </code></pre>
[ { "answer_id": 410504, "author": "gak", "author_id": 11125, "author_profile": "https://Stackoverflow.com/users/11125", "pm_score": 5, "selected": false, "text": "def to_base(q, alphabet):\n if q < 0: raise ValueError, \"must supply a positive integer\"\n l = len(alphabet)\n conv...
2009/01/04
[ "https://Stackoverflow.com/questions/410485", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48557/" ]
410,502
<p>Does anyone know what culture settings Win32 uses when dealing with case-insensitive files names?</p> <p>Is this something that varies based on the user's culture, or are the casing rules that Win32 uses culture invariant?</p>
[ { "answer_id": 410562, "author": "Doug", "author_id": 51305, "author_profile": "https://Stackoverflow.com/users/51305", "pm_score": 4, "selected": true, "text": "CharUpper CharUpperBuff LCMapString" }, { "answer_id": 410598, "author": "Steve Steiner", "author_id": 3892, ...
2009/01/04
[ "https://Stackoverflow.com/questions/410502", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1737192/" ]
410,516
<p>I have the following doubts on header files usage.</p> <p><strong>1 - Include guards placing after comments</strong></p> <pre><code>/* Copyright Note and licence information (multiple lines) */ #ifndef FOO_H #define FOO_H // Header file contents #endif </code></pre> <p>Herb Sutter says in his "C++ coding standards" book that code like the above is problematic. He is saying the "#ifndef" statements should appear in the first line of the header file. I haven't felt this as convincing. Is this followed by you guys/gals in header files?</p> <p><strong>2 - Using namespaces in header files</strong></p> <pre><code>#ifndef FOO_H #define FOO_H namespace FooNameSpace{ // Header file contents } #endif </code></pre> <p>Is the above code using correct practice? I mean, do you use namespaces in header files? I know why importing a namespace in header file is pointless but what about a declaration like the above?</p> <p>If the above one is the correct method, how do you do "<em>forward declaration</em>" of a class which is in another namespace? Is it like</p> <pre><code>#ifndef FOO_H #define FOO_H namespace AnotherNameSpace{ class AnotherFoo; // forward declaration } namespace FooNameSpace{ // Use AnotherFoo here } #endif </code></pre> <p>The "<em>forward declaration</em>" is the only method to avoid "<em>cyclic dependency</em>", correct?</p>
[ { "answer_id": 410523, "author": "Adam Rosenfield", "author_id": 9530, "author_profile": "https://Stackoverflow.com/users/9530", "pm_score": 4, "selected": false, "text": "using // WRONG!\nusing namespace std;\nclass MyClass\n{\n string stringVar;\n};\n\n// RIGHT\nclass MyClass\n{\n ...
2009/01/04
[ "https://Stackoverflow.com/questions/410516", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50419/" ]
410,532
<p>I have inherited a project that has some huge switch statement blocks, with some containing up to 20 cases. What is a good way to rewrite these?</p>
[ { "answer_id": 410858, "author": "Breton", "author_id": 51101, "author_profile": "https://Stackoverflow.com/users/51101", "pm_score": 3, "selected": false, "text": "switch(x){\n case 1:\n makeitso(\"foo\");\n globalLog += \"foo\";\n case 2:\n makeitso(\"bar\");\n glob...
2009/01/04
[ "https://Stackoverflow.com/questions/410532", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51325/" ]
410,558
<p>I understand that "Exceptions are for exceptional cases" [a], but besides just being repeated <a href="https://stackoverflow.com/questions/88541/business-objects-validation-and-exceptions#88917">over</a> and <a href="https://stackoverflow.com/questions/77127/when-to-throw-an-exception#77227">over</a> again, I've never found an actual reason for this fact.</p> <p>Being that they halt execution, it makes sense that you wouldn't want them for plain conditional logic, but why not input validation?</p> <p>Say you were to loop through a group of inputs and catch each exception to group them together for user notification... I continually see that this is somehow "wrong" because users enter incorrect input all the time, but that point seems to be <a href="https://stackoverflow.com/questions/77127/when-to-throw-an-exception#77164">based on semantics</a>. </p> <p>The input is Not what was expected and hence is exceptional. Throwing an exception allows me to define exactly what was wrong like StringValueTooLong or or IntegerValueTooLow or InvalidDateValue or whatever. Why is this considered wrong?</p> <p>Alternatives to throwing an exception would be to either return (and eventually collect) an error code or far worse an error string. Then I would either show those error strings directly, or parse the error codes and then show corresponding error messages to the user. Wouldn't a exception be considered a malleable error code? Why create a separate table of error codes and messages, when these could be generalized with the exception functionality already built into my language?</p> <p>Also, I <a href="http://www.martinfowler.com/eaaDev/Notification.html" rel="noreferrer">found this article by Martin Fowler</a> as to how to handle such things - the Notification pattern. I'm not sure how I see this as being anything other than Exceptions that don't halt execution. </p> <p>a: Everywhere I've read anything about Exceptions.</p> <p>--- Edit ---</p> <p>Many great points have been made. I've commented on most and +'d the good points, but I'm not yet completely convinced.</p> <p>I don't mean to advocate Exceptions as the proper means to resolve Input Validation, but I would like to find good reasons why the practice is considered so evil when it seems most alternate solutions are just Exceptions in disguise.</p>
[ { "answer_id": 484445, "author": "ScottKoon", "author_id": 1538, "author_profile": "https://Stackoverflow.com/users/1538", "pm_score": 1, "selected": false, "text": "public bool isValidDate(string date)\n{\n bool retVal = true;\n //check for 4 digit year\n throw new FourDigitYea...
2009/01/04
[ "https://Stackoverflow.com/questions/410558", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14651/" ]
410,576
<p>It's the weirdest thing. When I ran the Rails WEBrick debugger yesterday I could do things like</p> <pre><code>cookies[uid] = s.session_id </code></pre> <p>where 'uid' is a passed argument that has a user id in it, and then expect</p> <pre><code>cookies[uid] </code></pre> <p>to give me back, say: </p> <pre><code>29b93443d9ec18168a26e1ab12957b0dd0b799ff </code></pre> <p>Today, I always get back 'nil'. I can read existing values just fine. Any of the keys listed in </p> <pre><code>cookies.keys </code></pre> <p>work just fine.</p> <p>Does anyone have a possible explanation for this behavior. It is very maddening, and a Google search hasn't yielded an answer.</p>
[ { "answer_id": 410727, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "cookies[:key]\n @future_value = cookies[:key] = {\n :value => 'new value',\n ...
2009/01/04
[ "https://Stackoverflow.com/questions/410576", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
410,579
<p>I'm trying to create a custom control - a button - which will have multiple styles applied to it depending on the value of a property within the data context.</p> <p>What I was thinking is using something similar to:</p> <pre><code>&lt;Button Style="{Binding Path=ButtonStyleProperty, Converter={StaticResource styleConverter}}" Text="{Binding Path=TextProp}" /&gt; </code></pre> <p>And in code... Implement an IValueConverter which does something similar to the code below in the <code>ConvertTo</code> method:</p> <pre><code>switch(value as ValueEnums) { case ValueEnums.Enum1: FindResource("Enum1ButtonStyle") as Style; break; ... and so on. } </code></pre> <p>However I'm not entirely sure about how to pull out the style object and even if this is possible at all...</p> <p>What I am doing in the mean time is handling the <code>DataContextChanged</code> event, then attaching a handler to the <code>PropertyChanged</code> event of the object being bound to the button - then running the switch statement in there.</p> <p>Its not quite perfect but until I can find a better solution it seems like that is what I'll have to use.</p>
[ { "answer_id": 410599, "author": "aku", "author_id": 1196, "author_profile": "https://Stackoverflow.com/users/1196", "pm_score": 4, "selected": false, "text": "<Style x:Key=\"ButtonStyle\" TargetType=\"{x:Type Button}\">\n <Style.Triggers>\n <DataTrigger Binding=\"{Binding Path...
2009/01/04
[ "https://Stackoverflow.com/questions/410579", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18434/" ]
410,583
<p>Is there any way to automatically launch an application on USB attach or CD insert on Mac OS X? it's easy on Windows, but I found that <code>AutoRun.Inf</code> does not work on the Mac at all.</p>
[ { "answer_id": 410590, "author": "Sophie Alpert", "author_id": 49485, "author_profile": "https://Stackoverflow.com/users/49485", "pm_score": 6, "selected": true, "text": ".dmg" } ]
2009/01/04
[ "https://Stackoverflow.com/questions/410583", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51306/" ]
410,593
<p>I would like to clarify the differences between by value and by reference.</p> <p>I drew a picture:</p> <p><img src="https://i.stack.imgur.com/fNEsL.jpg" alt="Enter image description here" /></p> <p>So, for passing by value, a copy of an identical object is created with a different reference, and the local variable is assigned the new reference, so to point to the new copy</p> <p>How should I understand the following?</p> <blockquote> <p>If the function modifies that value, the modifications appear also within the scope of the calling function for both passing by value and by reference</p> </blockquote>
[ { "answer_id": 410604, "author": "Flame", "author_id": 5387, "author_profile": "https://Stackoverflow.com/users/5387", "pm_score": 3, "selected": false, "text": "void func(Object o);\n func(a);\n Object func o a o a o a a void func2(Object& o);\n func2(a);\n a a o o func2 a" }, { ...
2009/01/04
[ "https://Stackoverflow.com/questions/410593", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36064/" ]
410,611
<p>I have a type which I consider use it as struct.</p> <ul> <li>It represents single value</li> <li>It is immutable</li> </ul> <p>But the problem is, it has 6 fields of int.</p> <p>So which solution I should use for this type?</p> <ol> <li>keep using struct?</li> <li>change to class?</li> <li>or pack 6 integers into an array of int, so it has only one field</li> </ol> <p><strong>EDIT</strong></p> <p>Size of struct with 6 integer fields is 24 bytes, which is huge to pass around. Recommend size for struct is not more than 16 bytes</p>
[ { "answer_id": 410627, "author": "Dmitri Nesteruk", "author_id": 9476, "author_profile": "https://Stackoverflow.com/users/9476", "pm_score": 0, "selected": false, "text": "WriteOnce<int[]>" } ]
2009/01/04
[ "https://Stackoverflow.com/questions/410611", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2398110/" ]
410,614
<p>I have a Application A(by some company X). This application allows me to extend the functionality by allowing me to write my own functions.</p> <p>I tell the Application A to call my user functions in the Applications A's configuration file (this is how it knows that Appl A must call user written Functions). The appl A uses Function pointers which I must register with Application A prior to calling my user written functions.</p> <p>If there is a bug or fault in my user written functions in production, the Appl A will stop functioning. For example, if I have a segmentation fault in my User written functions.</p> <p>So Application A will load my user written function from a shared DLL file. This means that my user written functions will be running in Application A' Process address space.</p> <p>I wish to handle certain signals like Segmentation fault, divide by zero and stack overflow, but applications A has its own signal handlers written for this, </p> <p>How can I write my own signal handlers to catch the exceptions in my user written functions, so that I can clean up gracefully w/o affecting much of Application A? Since my user functions will be called in Applications A's process, the OS will call signal handlers written in Application A and not my user functions.</p> <p>How can I change this? I want OS to call signal handlers written in my functions but only for signal raised by my functions, which is asynchronous in nature.</p> <p>Note: I do not have the source code of Application A and I cannot make any changes to it, because it's controlled by a different company.</p> <p>I will be using C , and only C on a Linux, solaris and probably windows platforms.</p>
[ { "answer_id": 410635, "author": "Stefan", "author_id": 48003, "author_profile": "https://Stackoverflow.com/users/48003", "pm_score": -1, "selected": false, "text": "try\n{\n // here goes your code\n}\ncatch ( ... )\n{\n // handle segfaults\n}\n" } ]
2009/01/04
[ "https://Stackoverflow.com/questions/410614", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50706/" ]
410,616
<p>I am programming a server and it seems like my number of connections is being limited since my bandwidth isn't being saturated even when I've set the number of connections to "unlimited".</p> <p>How can I increase or eliminate a maximum number of connections that my Ubuntu Linux box can open at a time? Does the OS limit this, or is it the router or the ISP? Or is it something else? </p>
[ { "answer_id": 410643, "author": "derobert", "author_id": 27727, "author_profile": "https://Stackoverflow.com/users/27727", "pm_score": 6, "selected": false, "text": "ulimit -n /proc ping -s 1472 tc iperf netstat lsof ulimit -n iostat -x" }, { "answer_id": 3923785, "author": ...
2009/01/04
[ "https://Stackoverflow.com/questions/410616", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
410,623
<p>I have an array, and I want to make a hash so I can quickly ask "is X in the array?".</p> <p>In perl, there is an easy (and fast) way to do this:</p> <pre><code>my @array = qw( 1 2 3 ); my %hash; @hash{@array} = undef; </code></pre> <p>This generates a hash that looks like:</p> <pre><code>{ 1 =&gt; undef, 2 =&gt; undef, 3 =&gt; undef, } </code></pre> <p>The best I've come up with in Ruby is:</p> <pre><code>array = [1, 2, 3] hash = Hash[array.map {|x| [x, nil]}] </code></pre> <p>which gives:</p> <pre><code>{1=&gt;nil, 2=&gt;nil, 3=&gt;nil} </code></pre> <p>Is there a better Ruby way? </p> <h2>EDIT 1</h2> <p>No, Array.include? is not a good idea. Its <strong>slow</strong>. It does a query in O(n) instead of O(1). My example array had three elements for brevity; assume the actual one has a million elements. Let's do a little benchmarking:</p> <pre><code>#!/usr/bin/ruby -w require 'benchmark' array = (1..1_000_000).to_a hash = Hash[array.map {|x| [x, nil]}] Benchmark.bm(15) do |x| x.report("Array.include?") { 1000.times { array.include?(500_000) } } x.report("Hash.include?") { 1000.times { hash.include?(500_000) } } end </code></pre> <p>Produces:</p> <pre><code> user system total real Array.include? 46.190000 0.160000 46.350000 ( 46.593477) Hash.include? 0.000000 0.000000 0.000000 ( 0.000523) </code></pre>
[ { "answer_id": 410648, "author": "Zach Langley", "author_id": 45230, "author_profile": "https://Stackoverflow.com/users/45230", "pm_score": 3, "selected": false, "text": "Array#include? nil Array#to_set require 'benchmark'\nrequire 'set'\n\narray = (1..1_000_000).to_a\nset = array.to_set...
2009/01/04
[ "https://Stackoverflow.com/questions/410623", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27727/" ]
410,628
<p>I need your help to define a special case in XML schema: A sequence that contains two elements: 'x' and 'y' whereas:</p> <ul> <li><p><code>&lt;x&gt;</code> element can appear 0 to unbound times in the sequence</p></li> <li><p><code>&lt;y&gt;</code> element can appear 0 to 1 time in the sequence</p></li> <li><p><code>&lt;x&gt;</code> and <code>&lt;y&gt;</code> locations can be anywhere - that is, it is possible to have unbound times the <code>&lt;x&gt;</code> element and then a single <code>&lt;y&gt;</code> element, and then unbound times the <code>&lt;x&gt;</code> element.</p></li> </ul> <p>XML examples of this problem:</p> <h2>Example #1</h2> <pre><code>&lt;x&gt;stuff&lt;/x&gt; &lt;y&gt;stuff&lt;/y&gt; &lt;x&gt;stuff&lt;/x&gt; </code></pre> <h2>Example #2</h2> <pre><code>&lt;y&gt;stuff&lt;/y&gt; &lt;x&gt;stuff&lt;/x&gt; &lt;x&gt;stuff&lt;/x&gt; </code></pre> <h2>Example #3</h2> <pre><code>&lt;x&gt;stuff&lt;/x&gt; &lt;x&gt;stuff&lt;/x&gt; &lt;y&gt;stuff&lt;/y&gt; &lt;x&gt;stuff&lt;/x&gt; </code></pre> <p>Thanks!</p>
[ { "answer_id": 410656, "author": "Yuval Adam", "author_id": 24545, "author_profile": "https://Stackoverflow.com/users/24545", "pm_score": 0, "selected": false, "text": "<xs:element name=\"x\" type=\"xs:string\" minOccurs=\"0\" maxOccurs=\"unbounded\"/>\n<xs:element name=\"y\" type=\"xs:s...
2009/01/04
[ "https://Stackoverflow.com/questions/410628", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51338/" ]
410,630
<p>I have the following Hibernate Mapping, which has to be mapped using the Table per Concrete Class Hierarchy:</p> <pre><code>&lt;hibernate-mapping package='dao'&gt; &lt;meta attribute='class-description'&gt;&lt;/meta&gt; &lt;class name='PropertyDAO'&gt; &lt;id name='id' column='id_property'&gt; &lt;generator class='assigned'/&gt; &lt;/id&gt; &lt;property name='address' column='address' type='string'/&gt; &lt;union-subclass name='HouseDAO' table='house'&gt; &lt;property name='noOfRooms' column='noOfRooms'/&gt; &lt;property name='totalArea' column='totalArea'/&gt; &lt;property name='price' column='price'/&gt; &lt;/union-subclass&gt; &lt;union-subclass name='LandDAO' table='land'&gt; &lt;property name='area' column='area'/&gt; &lt;property name='unitPrice' column='unitPrice'/&gt; &lt;/union-subclass&gt; &lt;/class&gt; &lt;/hibernate-mapping&gt; </code></pre> <p>Which means in the database i have only 2 tables : </p> <ul> <li>house (id_property(PK), address, noOfRooms, totalArea, price)</li> <li>land (id_property(PK), address, area, unitPrice)</li> </ul> <p>As far as I understood, in this case the ids need to be generated explicitly before calling .save(), so my question is: How can I create a strategy for the automatically generation of the ids, so that the ids from the concrete class form a continuous domain when joined.</p>
[ { "answer_id": 410642, "author": "Arthur Thomas", "author_id": 14009, "author_profile": "https://Stackoverflow.com/users/14009", "pm_score": 1, "selected": false, "text": "<key column=\"id\"/>\n" } ]
2009/01/04
[ "https://Stackoverflow.com/questions/410630", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51336/" ]
410,692
<p>I am trying to do the following in a way or another:</p> <pre><code>const char EscapeChar = '\\'; const string EscapeString = EscapeChar.ToString(); // or ("" + EscapeChar) </code></pre> <p>This does't compile. Is there another way to make it work?</p>
[ { "answer_id": 410695, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 3, "selected": false, "text": "const static readonly" }, { "answer_id": 410698, "author": "Steven Robbins", "author_id": 26507, "au...
2009/01/04
[ "https://Stackoverflow.com/questions/410692", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41283/" ]
410,704
<p>I'm trying to encode Cyrillic UTF-8 array to JSON string using php's function json_encode. The sample code looks like this:</p> <pre><code>&lt;?php $arr = array( 'едно' =&gt; 'първи', 'две' =&gt; 'втори' ); $str = json_encode($arr); echo $str; ?&gt; </code></pre> <p>It works fine but the result of the script is represented as:</p> <pre><code>{"\u0435\u0434\u043d\u043e":"\u043f\u044a\u0440\u0432\u0438","\u0434\u0432\u0435":"\u0432\u0442\u043e\u0440\u0438"} </code></pre> <p>which makes 6 characters for each Cyrillic character. Is there a way to get the original characters for key/value pairs instead of encoded ones?</p>
[ { "answer_id": 410712, "author": "Beau Simensen", "author_id": 50453, "author_profile": "https://Stackoverflow.com/users/50453", "pm_score": 2, "selected": false, "text": "json_encode UTF-8" }, { "answer_id": 410772, "author": "AquilaX", "author_id": 17734, "author_pr...
2009/01/04
[ "https://Stackoverflow.com/questions/410704", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17734/" ]
410,705
<p>In the upcoming Java7, there is a <a href="http://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html#isSameFile(java.nio.file.Path,%20java.nio.file.Path)" rel="noreferrer">new API</a> to check if two file object are same file reference.</p> <p>Are there similar API provided in the .NET framework?</p> <p>I've search it over MSDN but nothing enlighten me.</p> <p>I want it simple but I don't want to compare by filename which will cause problems with hard/symbolic links and different style of path. (e.g. <code>\\?\C:\</code>, <code>C:\</code>). </p> <p>What I going to do is just prevent duplicated file being drag and dropped to my linklist.</p>
[ { "answer_id": 410746, "author": "tuinstoel", "author_id": 43901, "author_profile": "https://Stackoverflow.com/users/43901", "pm_score": 1, "selected": false, "text": " string fileName1 = @\"c:\\vobp.log\";\n string fileName2 = @\"c:\\vobp.log\".ToUpper();\n FileInfo fileInfo1 = new F...
2009/01/04
[ "https://Stackoverflow.com/questions/410705", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40214/" ]
410,717
<p>F# has a bunch of standard sequence operators I have come to know and love from my experience with Mathematica. F# is getting lots of my attention now, and when it is in general release, I intend to use it frequently.</p> <p>Right now, since F# isn't yet in general release, I can't really use it in production code. LINQ implements some of these operators using SQL-like names (e.g. 'select' is 'map', and 'where' is 'filter'), but I can find no implementation of 'fold', 'iter' or 'partition'. </p> <p>Has anyone seen any C# implementation of standard sequence operators? Is this something someone should write?</p>
[ { "answer_id": 410759, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 3, "selected": false, "text": "Aggregate iter partition SelectMany Skip Take using System;\nusing System.Collections.Generic;\nstatic class Program ...
2009/01/04
[ "https://Stackoverflow.com/questions/410717", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51345/" ]
410,719
<p>This really, really urks me, so I hope that someone can give me a reasonable justification for why things are as they are.</p> <p><strong>NotImplementedException.</strong> You are pulling my leg, right?</p> <p>No, I'm not going to take the cheap stab at this by saying, "hang on, the method is implemented - it throws a NotImplementedException." Yes, that's right, you have to implement the method to throw a NotImplementedException (unlike a pure virtual function call in C++ - now that makes sense!). While that's pretty damn funny, there is a more serious problem in my mind.</p> <p>I just wonder, in the presence of the NotImplementedException, how can anyone do anything with .Net? Are you expected to wrap every abstract method call with a try catch block to guard against methods that might not be implemented? If you catch such an exception, what the heck are you supposed to do with it??</p> <p>I see no way to test if a method is actually implemented without calling it. Since calling it may have side effects, I can't do all my checks up-front and then run my algorithm. I have to run my algorithm, catch NotImplementedExceptions and the some how roll back my application to some sane state.</p> <p>It's crazy. Mad. Insane. So the question is: <strong>Why does the NotImplementedException exist</strong>?</p> <p>As a preemptive strike, I do not want anyone to respond with, "because designers need to put this in the auto-generated code." This is horrid. I would rather the auto-generated code not compile until you supply an implementation. For example, the auto generated implementation could be "throw NotImplementedException;" where the NotImplementedException is not defined!</p> <p>Has anyone ever caught and handled a NotImplementedException? Have you ever left a NotImplementedException in your code? If so, did this represent a time bomb (ie, you accidentally left it there), or a design flaw (the method should not be implemented and will never be called)?</p> <p>I'm very suspicious of the NotSupportedException also... Not supported? What the? If it's not supported, why is it part of your interface? Can anyone at Microsoft spell improper inheritance? But I might start another question for that if I don't get too abuse for this one. </p> <p>Additional info:</p> <p><a href="http://www.lostechies.com/blogs/jimmy_bogard/archive/2008/10/12/notimplementedexception-and-the-interface-segregation-principle.aspx" rel="noreferrer">This</a> is an interesting read on the subject.</p> <p>There seems to be a strong agreement with <a href="http://blogs.msdn.com/brada/archive/2004/07/29/201354.aspx" rel="noreferrer">Brad Abrams</a> that "NotImplementedException is for functionality that is just not yet implemented, but really should (and will be). Something like what you might <em>start</em> with when you are building a class, get all the methods there throwing NotImplementedException, then flush them out with real code…"</p> <p>Comments from <a href="http://blogs.msdn.com/jaredpar/archive/2008/12/12/notimplementedexception-vs-notsupportedexception.aspx" rel="noreferrer">Jared Parsons</a> are very weak and should probably be ignored: NotImplementedException: Throw this exception when a type does not implement a method for any other reason.</p> <p>The <a href="http://msdn.microsoft.com/en-us/library/system.notimplementedexception.aspx" rel="noreferrer">MSDN</a> is even weaker on the subject, merely stating that, "The exception that is thrown when a requested method or operation is not implemented."</p>
[ { "answer_id": 410737, "author": "Scott Weinstein", "author_id": 25201, "author_profile": "https://Stackoverflow.com/users/25201", "pm_score": 5, "selected": false, "text": "WashDishes() DryDishes() PutAwayDishes() DryDishes() NotSupportedException NotSupportedException" }, { "an...
2009/01/04
[ "https://Stackoverflow.com/questions/410719", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43066/" ]
410,723
<p>Is there a difference between having a <code>private const</code> variable or a <code>private static readonly</code> variable in C# (other than having to assign the <code>const</code> a compile-time expression)?</p> <p>Since they are both private, there is no linking with other libraries. So would it make any difference? Can it make a performance difference for example? Interned strings? Anything similar?</p>
[ { "answer_id": 410748, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 6, "selected": true, "text": ".cctor someField = \"abc\";\n \"abc\" ldstr" }, { "answer_id": 410782, "author": "melculetz", "author_...
2009/01/04
[ "https://Stackoverflow.com/questions/410723", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41283/" ]
410,749
<p>I use svn for a project im working on with a couple of other developers. Svn works fine for source control however we are all ways getting conflicts when we commit the dlls.</p> <p>When i do i resolve the conflict (which deletes my dlls as the diff program cant handle binary files) then have to rebuild to commit. How are you meant to resolve conflicts like this?</p> <p>Edit:</p> <p>The dlls are in a separate svn folder as the project is a game mod and non programmers need access to the latest builds.</p>
[ { "answer_id": 410757, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 2, "selected": false, "text": ".tar.gz Makefile" }, { "answer_id": 410767, "author": "Stefan", "author_id": 48003, "author_profile":...
2009/01/04
[ "https://Stackoverflow.com/questions/410749", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23339/" ]
410,756
<p>Is it possible to browse the source code of OpenJDK online, just like I can do with SourceForge's projects? I never used Mercury before, so I felt confused.</p> <p>(Note: I don't want to download the source. I just want to browse it online, to see how some methods are implemented.)</p>
[ { "answer_id": 410780, "author": "Rasmus Faber", "author_id": 5542, "author_profile": "https://Stackoverflow.com/users/5542", "pm_score": 8, "selected": true, "text": "java.util.List java.util.List jdk6 jdk src/share/classes/java/util/List.java" }, { "answer_id": 36079260, "a...
2009/01/04
[ "https://Stackoverflow.com/questions/410756", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41283/" ]
410,787
<p>According to [MSDN: Array usage guidelines](<a href="http://msdn.microsoft.com/en-us/library/k2604h5s(VS.71).aspx)" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/k2604h5s(VS.71).aspx)</a>: </p> <p>Array Valued Properties</p> <blockquote> <p>You should use collections to avoid code inefficiencies. In the following code example, each call to the myObj property creates a copy of the array. As a result, 2n+1 copies of the array will be created in the following loop.</p> </blockquote> <pre><code>[Visual Basic] Dim i As Integer For i = 0 To obj.myObj.Count - 1 DoSomething(obj.myObj(i)) Next i [C#] for (int i = 0; i &lt; obj.myObj.Count; i++) DoSomething(obj.myObj[i]); </code></pre> <p>Other than the change from myObj[] to ICollection myObj, what else would you recommend? Just realized that my current app is leaking memory :(</p> <p>Thanks;</p> <p>EDIT: Would forcing C# to pass references w/ ref (safety aside) improve performance and/or memory usage?</p>
[ { "answer_id": 410790, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 4, "selected": true, "text": "var arr = obj.myObj; // var since I don't know the type!\nfor (int i = 0; i < arr.Length; i++) {\n DoSomething(arr[i]...
2009/01/04
[ "https://Stackoverflow.com/questions/410787", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40164/" ]
410,811
<p>I need to set up some RewriteRules to redirect a URL which has a space in it. I've tried this:</p> <pre><code>RewriteRule ^article/with%20spaces.html$ /article/without_spaces.html [R=301,L] </code></pre> <p>... but it doesn't work. Putting in a space instead of %20 causes a 500 Internal Server Error. How do I add a space?</p>
[ { "answer_id": 410815, "author": "nickf", "author_id": 9021, "author_profile": "https://Stackoverflow.com/users/9021", "pm_score": 1, "selected": false, "text": "RewriteRule ^article/with\\sspaces.html$ ...\n" }, { "answer_id": 410816, "author": "Beau Simensen", "author_i...
2009/01/04
[ "https://Stackoverflow.com/questions/410811", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9021/" ]
410,819
<p>Even better would be if <code>autoResize</code> in latest branch would work as intended, but till then the question is simple: <strong>how to resize a dialog once it is created?</strong></p>
[ { "answer_id": 410871, "author": "Soviut", "author_id": 46914, "author_profile": "https://Stackoverflow.com/users/46914", "pm_score": 2, "selected": false, "text": "$(document).ready(function(){\n var d = $(\"#example\").dialog();\n d.data(\"width.dialog\", 700);\n});\n" }, { ...
2009/01/04
[ "https://Stackoverflow.com/questions/410819", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51357/" ]
410,820
<p>I've got a blogging site hosted on Windows Sever, ASP.Net 3.5, ASP.Net AJAX, SQL Server in background.</p> <p>I want to give bloggers a button like 'digg-it' which they can put on their blogs for the readers to click to thumb-up the post if they like it.</p> <p>I know I'll be using Javascript to do that. What can I do to: -</p> <ol> <li>Retrieve code from my website which will display the current count of the thumb-up.</li> <li>Increase the count on my website if the user thumbs up something.</li> </ol> <p>Since most of these blogs are on blogger.com/wordpress.com, the plugin code will be embedded in the blog theme. I guess I will be using the URL of the blog post as the unique id. My problem is how to get my site and javascript that's on blogger.com talking.</p> <p>Your help will be appreciated.</p> <p>Thanks</p>
[ { "answer_id": 410828, "author": "Beau Simensen", "author_id": 50453, "author_profile": "https://Stackoverflow.com/users/50453", "pm_score": 3, "selected": true, "text": "function dynScript(url){\n var script=document.createElement('script');\n script.src=url;\n script.type=\"te...
2009/01/04
[ "https://Stackoverflow.com/questions/410820", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33052/" ]
410,823
<p>I have the following code for "factory" design pattern implementation.</p> <pre><code>class Pen{ public: virtual void Draw() = 0; }; class RedPen : public Pen{ public: virtual void Draw(){ cout &lt;&lt; "Drawing with red pen" &lt;&lt; endl; } }; class BluePen : public Pen{ public: virtual void Draw(){ cout &lt;&lt; "Drawing with blue pen" &lt;&lt; endl; } }; auto_ptr&lt;Pen&gt; createPen(const std::string color){ if(color == "red") return auto_ptr&lt;Pen&gt;(new RedPen); else if(color == "blue") return auto_ptr&lt;Pen&gt;(new BluePen); } </code></pre> <p>But I heard that it can be done in a better way using "C++ templates". Can anyone help how it is done and how template approach is better than this?</p> <p>Any thoughts</p>
[ { "answer_id": 410856, "author": "gnud", "author_id": 27204, "author_profile": "https://Stackoverflow.com/users/27204", "pm_score": 3, "selected": true, "text": "class Pen {\npublic:\n Pen() : m_color(0,0,0,0) /* the default colour is black */\n { \n }\n\n Pen(cons...
2009/01/04
[ "https://Stackoverflow.com/questions/410823", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50419/" ]
410,841
<p>This is a bit of a crazy idea, but would there be a way to bootstrap all the functions that php have without using a helper function to call the functions.</p> <p>What I mean is actually calling some code or function before and after every basic function call.</p> <p>Example:</p> <pre><code>&lt;?php echo "Hello"; ?&gt; </code></pre> <p>But these functions would be called before echo and after echo:</p> <pre><code>&lt;?php function pre_echo() { do_something(); } function post_echo() { do_something_else(); } ?&gt; </code></pre>
[ { "answer_id": 418389, "author": "Gabriel Sosa", "author_id": 31039, "author_profile": "https://Stackoverflow.com/users/31039", "pm_score": 0, "selected": false, "text": "auto_prepend_file\nauto_append_file\n auto_prepend_file=/home/php/run_before.php\nauto_prepend_file=/home/php/run_aft...
2009/01/04
[ "https://Stackoverflow.com/questions/410841", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4985/" ]
410,842
<p>How do I hide a child in a accordion? Using visible doesn't seem to work and enabled isn't what I'm after.</p> <pre><code>&lt;mx:Accordion&gt; &lt;mx:VBox width="100%" height="100%" label="Foo" id="viewOverview" visible="false"&gt; ... &lt;/mx:VBox&gt; ... &lt;/mx:Accordion&gt; </code></pre>
[ { "answer_id": 410863, "author": "PEZ", "author_id": 44639, "author_profile": "https://Stackoverflow.com/users/44639", "pm_score": 4, "selected": true, "text": "function hideFoo():void {\n this.theAccordion.removeChild(this.vboxFoo);\n}\n" }, { "answer_id": 1859540, "autho...
2009/01/04
[ "https://Stackoverflow.com/questions/410842", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40939/" ]
410,844
<p>I've created a SubVersion server on one of the machines in my workgroup. From my development box I'm able to access the repository and check in/out files without any problem.</p> <p>I've just installed TortoiseSVN and no matter what I do it won't connect to the repository on the server. I get the infamous error "No connection could be made because the target machine actively refused it".</p> <p>Does anyone have any ideas why this might be..? As far as I know, the tortoise shell extension is running under my user credentials. It seems strange that the SVN command line tools work correctly, but not Tortoise.</p> <p>Both machines are running Vista</p> <p><em>NOTE: In both cases I'm using the svn protocol to connect</em></p> <p><em>Finally, I've fixed it...! The problem seems to be with the Subversion package I downloaded. I downloaded the latest version of SlikSVN (1.5.5) and installed it on my client and server. It seems TortoiseSVN doesn't like this build/version. I just uninstalled SlickSVN on both machines and grabbed the latest version from CollabNet and now everything works as expected!</em></p>
[ { "answer_id": 410848, "author": "Mihai Limbășan", "author_id": 14444, "author_profile": "https://Stackoverflow.com/users/14444", "pm_score": 0, "selected": false, "text": "file:// telnet target.machine.ip.address target_port target.machine.ip.address target_port" }, { "answer_id...
2009/01/04
[ "https://Stackoverflow.com/questions/410844", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26095/" ]
410,853
<p>In my programs infinity usually arises when a value is divided by zero. I get indeterminate when I divide zero by zero. How do you check for infinite and indeterminate values in C++?</p> <p>In C++, infinity is represented by 1.#INF. Indeterminate is represented by -1.#IND. The problem is how to test if a variable is infinite or indeterminate. Checking infinity is relatively straightforward: You find the infinity definition in your particular C++. For my case (VS2003), it is std::numeric_limits::infinity(). You have to include "limits" in order to use it. You can assign this infinite value to a variable and you can compare it to some value in order to check if that value is infinite.</p> <p>Indeterminate is a little tricky, because you cannot compare an indeterminate value to some other value. Any comparison returns false. You can use this property to detect an indeterminate value by comparing it to itself. Let's say you have a double variable called aVal. Under normal conditions, aVal != aVal returns false. But if the value is indeterminate, aIndVal != aIndVal returns true. This weird situation is not present for infinite values, i.e. aInfVal != aInfVal always returns false.</p> <p>Here are two functions that can be used to check for indeterminate and infinite values:</p> <pre><code>#include "limits.h" #include "math.h" bool isIndeterminate(const double pV) { return (pV != pV); } bool isInfinite(const double pV) { return (fabs(pV) == std::numeric_limits::infinity()) } </code></pre> <p>Are there better ways for these checks, am I missing anything?</p>
[ { "answer_id": 410864, "author": "CB Bailey", "author_id": 19563, "author_profile": "https://Stackoverflow.com/users/19563", "pm_score": 2, "selected": false, "text": "isfinite isinf isnan" }, { "answer_id": 410867, "author": "dalle", "author_id": 19100, "author_profi...
2009/01/04
[ "https://Stackoverflow.com/questions/410853", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51358/" ]
410,865
<p>I read about the <code>Conditional</code> attribute today. According to MSDN:</p> <blockquote> <p>Applying <code>ConditionalAttribute</code> to a method indicates to compilers that a call to the method should not be compiled into Microsoft intermediate language (MSIL) unless the conditional compilation symbol that is associated with <code>ConditionalAttribute</code> is defined.</p> </blockquote> <p>OK. That's clear. So the <em>call to the method</em> will not be compiled. But what about side effects?</p> <pre><code>[Conditional("UndefinedCondition")] static void f1(int x) { Console.WriteLine(x); } static int a = 0; static void f2() { f1(++a); } </code></pre> <p>So when <code>f2</code> is called, the call to <code>f1</code> should be removed. But why is <code>++a</code> removed as well? This does't make any sense to me!</p>
[ { "answer_id": 410873, "author": "R. Martinho Fernandes", "author_id": 46642, "author_profile": "https://Stackoverflow.com/users/46642", "pm_score": 1, "selected": false, "text": "++a;\nf1(a);\n" }, { "answer_id": 410929, "author": "Marc Gravell", "author_id": 23354, ...
2009/01/04
[ "https://Stackoverflow.com/questions/410865", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41283/" ]
410,889
<p>I'm not very good at C, and I always get stuck on simple string manipulation tasks (that's why I love Perl!).</p> <p>I have a string that contains a file path like "/Volumes/Media/Music/Arcade Fire/Black Mirror.aac". I need to extract the drive name ("Media" or preferably "/Volumes/Media") from that path.</p> <p>Any help would be greatly appreciated, just as I try to return the favor on the Perl questions!</p> <ul> <li>Jim</li> </ul>
[ { "answer_id": 410896, "author": "CB Bailey", "author_id": 19563, "author_profile": "https://Stackoverflow.com/users/19563", "pm_score": 1, "selected": false, "text": "strchr strstr p q *q = 0 p q - p + 1 +1 q - p char *buffer = malloc(q - p + 1); memcpy memcpy(buffer, p, q - p + 1)" }...
2009/01/04
[ "https://Stackoverflow.com/questions/410889", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13563/" ]
410,890
<p>If I get a NullPointerException in a call like this:</p> <pre><code>someObject.getSomething().getSomethingElse(). getAnotherThing().getYetAnotherObject().getValue(); </code></pre> <p>I get a rather useless exception text like:</p> <pre><code>Exception in thread &quot;main&quot; java.lang.NullPointerException at package.SomeClass.someMethod(SomeClass.java:12) </code></pre> <p>I find it rather hard to find out which call actually returned null, often finding myself refactoring the code to something like this:</p> <pre><code>Foo ret1 = someObject.getSomething(); Bar ret2 = ret1.getSomethingElse(); Baz ret3 = ret2.getAnotherThing(); Bam ret4 = ret3.getYetAnotherOject(); int ret5 = ret4.getValue(); </code></pre> <p>and then waiting for a more descriptive NullPointerException that tells me which line to look for.</p> <p>Some of you might argue that concatenating getters is bad style and should be avoided anyway, but my Question is: Can I find the bug without changing the code?</p> <p>Hint: I'm using eclipse and I know what a debugger is, but I can't figuer out how to apply it to the problem.</p> <p><strong>My conclusion on the answers:</strong><br /> Some answers told me that I should not chain getters one after another, some answers showed my how to debug my code if I disobeyed that advice.</p> <p>I've accepted an answer that taught me exactly when to chain getters:</p> <ul> <li>If they cannot return null, chain them as long as you like. No need for checking != null, no need to worry about NullPointerExceptions (<em>be warned that chaining still violates the Law of Demeter, but I can live with that</em>)</li> <li>If they may return null, don't ever, never ever chain them, and perform a check for null values on each one that may return null</li> </ul> <p>This makes any good advice on actual debugging useless.</p>
[ { "answer_id": 410923, "author": "Ronald Blaschke", "author_id": 49604, "author_profile": "https://Stackoverflow.com/users/49604", "pm_score": 4, "selected": true, "text": "null null IllegalStateException null" }, { "answer_id": 410926, "author": "ewalshe", "author_id": 4...
2009/01/04
[ "https://Stackoverflow.com/questions/410890", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39946/" ]
410,898
<p>I have some markup like this:</p> <pre><code>&lt;p&gt;&lt;a id="1" href="#"&gt;Link 1&lt;/a&gt;&lt;/p&gt; &lt;p id="1show" class="starthidden"&gt;Hi! I get shown when link 1 is clicked&lt;/p&gt; &lt;p&gt;&lt;a id="2" href="#"&gt;Link 2&lt;/a&gt;&lt;/p&gt; &lt;p id="2show" class="starthidden"&gt;Hi! I get shown when link 2 is clicked&lt;/p&gt; &lt;p&gt;&lt;a id="3" href="#"&gt;Link 3&lt;/a&gt;&lt;/p&gt; &lt;p id="3show" class="starthidden"&gt;Hi! I get shown when link 3 is clicked&lt;/p&gt; </code></pre> <p>And some javascript like this:</p> <pre><code>$(document).ready(function(){ $("#maincontent a").click(function () { var id = '#' + $(this).attr("id"); var show = id + 'show'; $("id").click(function () { $("show").slideToggle("slow"); return false; }); return false; }); }); </code></pre> <p>Now, id and show are both what I'd expect at runtime, but the next line doesn't work. I guess that it's the $("id") bit - though changing this to $(id) doesn't work either.</p> <p>How do I fix this?</p>
[ { "answer_id": 410910, "author": "clawr", "author_id": 46201, "author_profile": "https://Stackoverflow.com/users/46201", "pm_score": 2, "selected": false, "text": "$(show) click() slideToggle() $(document).ready(function(){\n\n $(\"#maincontent a\").click(function () {\n var id...
2009/01/04
[ "https://Stackoverflow.com/questions/410898", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16511/" ]
410,924
<p>I'm trying to create an overridden operator function using both const parameters, but I can't figure out how to do it. Here is a simple example:</p> <pre><code>class Number { Number() { value = 1; }; inline Number operator + (const Number&amp; n) { Number result; result.value = value + n.value; return result; } int value; } </code></pre> <p>What I am trying to do here is pass in two arguments into the addition function that are both const and return the result without changing anything in the class:</p> <pre><code>const Number a = Number(); const Number b = Number(); Number c = a + b; </code></pre> <p>Is this possible and how would I go about doing this?</p> <p>Thanks,</p> <p>Dan</p>
[ { "answer_id": 410928, "author": "cletus", "author_id": 18393, "author_profile": "https://Stackoverflow.com/users/18393", "pm_score": 1, "selected": false, "text": "class Number\n{\n Number()\n {\n value = 1;\n };\n\n inline Number operator + (const Number& n) const\n ...
2009/01/04
[ "https://Stackoverflow.com/questions/410924", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18909/" ]
410,943
<p>What would be the most efficient method of reading a text file into a dynamic one-dimensional array? reallocing after every read char seems silly, reallocing after every read line doesn't seem much better. I would like to read the entire file into the array. How would you do it?</p>
[ { "answer_id": 410952, "author": "Johannes Schaub - litb", "author_id": 34509, "author_profile": "https://Stackoverflow.com/users/34509", "pm_score": 6, "selected": true, "text": "FILE *f = fopen(\"text.txt\", \"rb\");\nfseek(f, 0, SEEK_END);\nlong pos = ftell(f);\nfseek(f, 0, SEEK_SET);...
2009/01/04
[ "https://Stackoverflow.com/questions/410943", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41839/" ]
410,951
<p>I needed to change the SID of an Oracle XE database (not the Service Name) to match a production database.</p> <p>When I tried searching online, most of the pages were describing changing or adding a service name through tnsnames.ora; that's not what I needed to do.</p>
[ { "answer_id": 3424544, "author": "Johannes Brodwall", "author_id": 27658, "author_profile": "https://Stackoverflow.com/users/27658", "pm_score": 5, "selected": true, "text": "C:\\oraclexe\\app\\oracle\\product\\10.2.0\\server copy [XE_HOME]\\dbs\\spfileXE.ora [XE_HOME]\\dbs\\spfileNEW_S...
2009/01/04
[ "https://Stackoverflow.com/questions/410951", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25544/" ]
410,954
<p>How do I parse XML from a Google App Engine app? Any examples?</p>
[ { "answer_id": 410971, "author": "jfs", "author_id": 4279, "author_profile": "https://Stackoverflow.com/users/4279", "pm_score": 3, "selected": false, "text": "from cStringIO import StringIO\nfrom xml.etree import cElementTree as etree\n\nxml = \"<a>aaa<b>bbb</b></a>\"\n\nfor event, ...
2009/01/04
[ "https://Stackoverflow.com/questions/410954", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
410,966
<p>When an object has various formats (XML,CSV) it can be represented in, where should one store knowledge of those formats.</p> <p>Should the object have knowledge of how it's represented in XML (i.e. letting the object convert itself through some method on the object such as <code>GetXML()</code>). Is this too much knowledge for the object and should this be stored externally in a repository/service/other layer?</p> <p>If it is stored in a repository, what happens in the use case where the XML representation of the object must be persisted to a database along with other information, e.g.:-</p> <p><code>insert into order values(1, '2004', &lt;order&gt;&lt;amount&gt;2&lt;/amount&gt;&lt;price&gt;19.99&lt;/price&gt;&lt;/order&gt;)</code>;</p> <p>...the knowledge of the object's XML structure would be in the XML repository, however the SQL repository would also need this knowledge, and this seems like duplication.</p> <p>I am unsure as to whether the service layer should be holding object representations either, as it does not seem like this is business logic.</p> <p>What is the recommended implementation for this use case?</p>
[ { "answer_id": 411104, "author": "Aaron Maenpaa", "author_id": 2603, "author_profile": "https://Stackoverflow.com/users/2603", "pm_score": 4, "selected": true, "text": "public String GetShortXml(){ ... }\npublic String GetFullXml(){ ... }\npublic String GetCsv(){ ... }\npublic String Get...
2009/01/04
[ "https://Stackoverflow.com/questions/410966", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34991/" ]
410,967
<p>I'm searching for a possibility to get a list of installed printers. I'm using JDK 1.6 with a Windows operating system. Does anyone know a solution? </p> <p>Thank you in advance.</p>
[ { "answer_id": 410972, "author": "Ronald Blaschke", "author_id": 49604, "author_profile": "https://Stackoverflow.com/users/49604", "pm_score": 2, "selected": false, "text": "javax.print.PrintServiceLookup" }, { "answer_id": 410991, "author": "Pedro Henriques", "author_id"...
2009/01/04
[ "https://Stackoverflow.com/questions/410967", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42659/" ]
410,980
<p>Is there a way to include an entire text file as a string in a C program at compile-time?</p> <p>something like:</p> <ul> <li><p>file.txt:</p> <pre><code>This is a little text file </code></pre></li> <li><p>main.c:</p> <pre><code>#include &lt;stdio.h&gt; int main(void) { #blackmagicinclude("file.txt", content) /* equiv: char[] content = "This is\na little\ntext file"; */ printf("%s", content); } </code></pre></li> </ul> <p>obtaining a little program that prints on stdout "This is a little text file"</p> <p>At the moment I used an hackish python script, but it's butt-ugly and limited to only one variable name, can you tell me another way to do it?</p>
[ { "answer_id": 410988, "author": "Dominik Grabiec", "author_id": 3719, "author_profile": "https://Stackoverflow.com/users/3719", "pm_score": 0, "selected": false, "text": "int main()\n{\n const char* text = \"\n#include \"file.txt\"\n\";\n printf(\"%s\", text);\n return 0;\n}\n ...
2009/01/04
[ "https://Stackoverflow.com/questions/410980", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
410,982
<p>Or to reformulate the question: is there a performance penalty in using unsigned values?</p> <p>And in general: what is the most performant type (16bit signed?, 32bit signed? etc.) on the IPhone ARM processor?</p>
[ { "answer_id": 411015, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": false, "text": "stdint.h #include <stdio.h>\n#include <stdint.h>\n\nint main (int argc, char **argv)\n{\n uint_fast8_t i;\n printf(\"Wid...
2009/01/04
[ "https://Stackoverflow.com/questions/410982", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50335/" ]
410,986
<p>Microsoft's live service has an amazing contact details form in their "Account" > "Registered information" page. You are first asked for your country and the rest of the contact form changes accordingly. For example, if you select "United States", the form fields will change to: Address 1, Address 2, City, State (drop down of US states), ZIP code, Time zone (drop down of US time zones in a user-friendly form, e.g., "Eastern Time (EST)").</p> <p>If you select "United Kingdom", the form fields will change to: Address 1, Address 2, Address 3, Second City, City, Country, Postal Code, Constituent Country (drop down) and Time zone (drop down).</p> <p>This contact form provides the best user experience I have ever encountered in a contact form (I may be over sensitive here but enhanced user experiences excites me and I want to provide the same experience to my users).</p> <p>Is there a way of creating such a form using VS 2008/.NET 3.5? Is there a legal way of getting hold of their information database?</p>
[ { "answer_id": 411015, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": false, "text": "stdint.h #include <stdio.h>\n#include <stdint.h>\n\nint main (int argc, char **argv)\n{\n uint_fast8_t i;\n printf(\"Wid...
2009/01/04
[ "https://Stackoverflow.com/questions/410986", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45735/" ]
410,995
<p>I am currently working at a client were they have locked down the network, except for ports 80 and 443. I need to connect to our server using SSH, but the same server also runs our website. We do not want to invest in a new server or place a second network card.</p> <p>I have been searching the internet for away to setup our linux server (running CentOS 5), so that there is a daemon listening on port 443 that depending on the client protocol forwards the request to the correct internal port (SSH 22 or HTTPS moved to a differentport_.</p> <p>There are a lot of people on internet looking for this kind solution, but no clear instructions how to do this.</p> <p>Anyone have ideas/clear instructions how to do this?</p> <p>Regards, nidkil</p>
[ { "answer_id": 411185, "author": "gbjbaanb", "author_id": 13744, "author_profile": "https://Stackoverflow.com/users/13744", "pm_score": 0, "selected": false, "text": "ServerName webmin.myserver.co.uk\nSSLProxyEngine On\n\nProxyRequests Off\nProxyPass / https://myserver.co.uk:10000/\nProx...
2009/01/04
[ "https://Stackoverflow.com/questions/410995", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
411,012
<p>I just finished reading <a href="https://stackoverflow.com/questions/410558/why-are-exceptions-said-to-be-so-bad-for-input-validation">this article</a> on the advantages and disadvantages of exceptions and I agree with the sentiment that Try-Catch blocks should not be used for "normal" control-flow management (don't use them like a goto). However, one author made (good) points about Maintainability and especially Performance that made me wonder about the same thing in Try-Finally blocks.</p> <p>I surround <em>every</em> Connection open event in my ASP.NET application with a Try so that I can be sure to close the Connection in a Finally. Leaking connections is obviously NOT a good thing in a web app and I doubt I'd change this practice but what are your thoughts?</p> <p>Note: I do have connections wrapped in a DAL and could close connections when the object destructor is called but this seems sketchy to me. As far as I know, you cannot count on a destructor being called in the event of an exception. Am I wrong?</p>
[ { "answer_id": 411047, "author": "jalf", "author_id": 33213, "author_profile": "https://Stackoverflow.com/users/33213", "pm_score": 1, "selected": false, "text": "using" } ]
2009/01/04
[ "https://Stackoverflow.com/questions/411012", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15592/" ]
411,048
<p>What is the difference between using Private Properties instead of Private Fields</p> <pre><code>private String MyValue { get; set; } // instead of private String _myValue; public void DoSomething() { MyValue = "Test"; // Instead of _myValue = "Test"; } </code></pre> <p>Is there any performance issue ? or just a naming convention ?</p>
[ { "answer_id": 411082, "author": "JoshBerke", "author_id": 26160, "author_profile": "https://Stackoverflow.com/users/26160", "pm_score": 3, "selected": false, "text": "public class Item\n{\n private Item _parent;\n private List<Item> _children;\n\n public void Add(Item child)\n ...
2009/01/04
[ "https://Stackoverflow.com/questions/411048", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50974/" ]
411,054
<p>I'm try to figure out how to handle the following scenario. In general, i have a bunch of records in a table. All of these have ID and ParentID fields to form a tree. </p> <pre><code>Page1 - Page2 - Page3 Page4 - Page5 -- Page6 </code></pre> <p>Now, i want my routes for Page3 and Page6 to be like <code>/Page1/Page6</code> and <code>/Page3/Page5/Page6</code> respectivelly. That is, i want to include all parents in the URL.</p> <p>How to set my controller action/routing to achieve the above result?</p> <p>Edit: Forgot to mention that the above structure will be dynamic - nodes can be added/deleted/change parent, etc.</p>
[ { "answer_id": 411062, "author": "Yoann. B", "author_id": 50974, "author_profile": "https://Stackoverflow.com/users/50974", "pm_score": -1, "selected": false, "text": "routes.MapRoute(\"Page6\", \"Page3/Page5/Page6\", new { controller = \"Page6\", action = \"Index\" });\n" }, { "...
2009/01/04
[ "https://Stackoverflow.com/questions/411054", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19610/" ]
411,057
<p>Is there a way to generate a class constraint with CodeDom.</p> <p>Because when I use something like</p> <pre><code>var method = new CodeMemberMethod(); var genericParam = new CodeTypeParameter("InterfaceType"); genericParam.Constraints.Add("class"); method.TypeParameters.Add(genericParam); </code></pre> <p>the generated code is like</p> <pre><code>private InterfaceType GetImpl&lt;InterfaceType&gt;() where InterfaceType : @class { } </code></pre> <p>The best workaround i found is to use a leading whitespace before the class</p> <pre><code>genericParam.Constraints.Add(" class"); </code></pre> <p>But this seems to be at best a workaround.</p>
[ { "answer_id": 976071, "author": "Max Galkin", "author_id": 2351099, "author_profile": "https://Stackoverflow.com/users/2351099", "pm_score": 4, "selected": true, "text": "HasConstructorConstraint" }, { "answer_id": 10865747, "author": "IS4", "author_id": 1424244, "au...
2009/01/04
[ "https://Stackoverflow.com/questions/411057", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21566/" ]
411,058
<p>I'm experiencing something really strange!</p> <p>I have a div that I'm hiding with JS (jQuery). Like this:</p> <pre><code>$('#myDiv').hide(); </code></pre> <p>Then when I make a fadeIn like this:</p> <pre><code>$("#myDiv").fadeIn('slow'); </code></pre> <p>then the text loses ClearType in IE but not in FF. If I go with toggle insted of fadeIn, then it's all fine.</p> <p>What is IE up to and is there any solutions for it because it looks horrible. <em>(I have ClearType on as you maybe understand at this point)</em></p>
[ { "answer_id": 411067, "author": "Aron Rotteveel", "author_id": 11568, "author_profile": "https://Stackoverflow.com/users/11568", "pm_score": 6, "selected": true, "text": "$('#myDiv').fadeIn('slow', function() {\n this.style.removeAttribute('filter');\n});\n $('#node').customFadeOut('s...
2009/01/04
[ "https://Stackoverflow.com/questions/411058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50896/" ]
411,092
<p>I have this bash script running my backup to an external hard drive... only if that drive is mounted (OS X):</p> <pre><code>DIR=/Volumes/External; if [ -e $DIR ]; then rsync -av ~/dir_to_backup $DIR; else echo "$DIR does not exist"; fi </code></pre> <p>This works, but I sense I am misreading the rsync man page. Is there a builtin rsync option to abort the run if the top level destination directory does not exist? Without testing for the existence of /Volumes/External, a directory will be created by that name if it isn't already mounted.</p>
[ { "answer_id": 411097, "author": "Ray Booysen", "author_id": 42124, "author_profile": "https://Stackoverflow.com/users/42124", "pm_score": 2, "selected": false, "text": "--existing, --ignore-non-existing\n" }, { "answer_id": 411101, "author": "mjy", "author_id": 2128202, ...
2009/01/04
[ "https://Stackoverflow.com/questions/411092", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26848/" ]
411,103
<p>I have a function with the same name, but with different signature in a base and derived classes. When I am trying to use the base class's function in another class that inherits from the derived, I receive an error. See the following code:</p> <pre><code>class A { public: void foo(string s){}; }; class B : public A { public: int foo(int i){}; }; class C : public B { public: void bar() { string s; foo(s); } }; </code></pre> <p>I receive the following error from the gcc compiler:</p> <pre><code>In member function `void C::bar()': no matching function for call to `C::foo(std::string&amp;)' candidates are: int B::foo(int) </code></pre> <p>If I remove <code>int foo(int i){};</code> from class <code>B</code>, or if I rename it from <code>foo1</code>, everything works fine. </p> <p>What's the problem with this?</p>
[ { "answer_id": 411112, "author": "Johannes Schaub - litb", "author_id": 34509, "author_profile": "https://Stackoverflow.com/users/34509", "pm_score": 7, "selected": false, "text": "class A\n{\n public:\n void foo(string s){};\n};\n\nclass B : public A\n{\n public:\n int foo(i...
2009/01/04
[ "https://Stackoverflow.com/questions/411103", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44673/" ]
411,114
<p>I'm used to thinking of member functions as just being a special case of normal functions, where member functions have an extra parameter at the beginning of their parameter list for the 'this' pointer, that is, the object on which the member function is supposed to act. I've used boost::function this way in the past and never encountered any problems:</p> <pre><code>boost::function f&lt;(void)(MyObject*, int, int)&gt; = &amp;MyObject::method_that_takes_two_ints; </code></pre> <p>But I've seen this syntax for member-function pointers:</p> <pre><code>void (MyObject::*f)( int, int ) = &amp;MyObject::method_that_takes_two_ints; </code></pre> <p>In this syntax, the 'this' parameter is not visible. Which got me wondering if under the hood pointer-to-member-functions are really a separate beast, and that boost was taking care of details for me. </p> <p>What does the standard dictate about the placement of the 'this' parameter? Perhaps just on my compiler the extra 'this' argument comes first, and maybe on other compilers it could be on the end? Am I just lucky that my way of thinking is consistent with how my compilers (GCC4, VS2005) handle it? Are pointer-to-member-functions always just a special case of pointer-to-functions with an extra parameter or can the compiler implement them differently?</p>
[ { "answer_id": 411125, "author": "jalf", "author_id": 33213, "author_profile": "https://Stackoverflow.com/users/33213", "pm_score": 4, "selected": true, "text": "this thiscall stdcall thiscall this ECX stdcall" }, { "answer_id": 411128, "author": "CB Bailey", "author_id":...
2009/01/04
[ "https://Stackoverflow.com/questions/411114", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50385/" ]
411,118
<p>I have drawn an icon in <a href="http://inkscape.org/" rel="nofollow noreferrer">Inkscape</a>, but would now like to programmatically alter it (change the colours slightly for different icon states) and convert it to a tiled PNG format file containing multiple icons with different colours. I know about Inkscape's <em>--export-png</em> options, but can't see a way to make it change the image and/or export multiple times to different parts of the combined image.</p> <p><strong>Are there any good <em>user-oriented</em> tools for programmatically fiddling with images, or do I have to delve into GD or even manually modifying the SVG XML?</strong></p>
[ { "answer_id": 1295008, "author": "Bruce Alderson", "author_id": 99003, "author_profile": "https://Stackoverflow.com/users/99003", "pm_score": 0, "selected": false, "text": "find -name \"*svg\" -exec inkscape -z --file={} \\ \n --export-png=$OUTPUT{}.png --export-width=640 --vacuum-de...
2009/01/04
[ "https://Stackoverflow.com/questions/411118", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42974/" ]
411,121
<p>There are plenty of script/tools for counting line of code, and some to count functions size in terms of line of code. But here I'm looking to a way to measure function size in terms of bytes of generated code.</p> <p>Does anyone know a way/tools to extract this information from a .lib or a .dll? </p> <p>For example, I know how to list function name from a .lib or .dll, and their start address, but I haven't found a way yet to get their memory footprint.</p> <p>PS : I'm look for a solution on windows platform, but any answer on an alternative system is welcome.</p>
[ { "answer_id": 1295008, "author": "Bruce Alderson", "author_id": 99003, "author_profile": "https://Stackoverflow.com/users/99003", "pm_score": 0, "selected": false, "text": "find -name \"*svg\" -exec inkscape -z --file={} \\ \n --export-png=$OUTPUT{}.png --export-width=640 --vacuum-de...
2009/01/04
[ "https://Stackoverflow.com/questions/411121", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51386/" ]
411,134
<p>Rails gurus: I've just discovered <code>named_scope</code> thanks to another SO user. :)</p> <p>I'd like to get the count of a set of rows - i.e. a <code>SELECT COUNT(*)</code>. Additionally, I want to still be able to chain named scopes in the call. </p> <p>Is this a legitimate (albeit weird) usage of named scope?</p> <pre><code>named_scope :count, :select =&gt; "COUNT(*) as count_all" </code></pre> <p>So then I can do (for example):</p> <pre><code>@foobar = Foobar.count.scope.scope.scope </code></pre> <p>The count is accessed via <code>@foobar.first.count_all</code>.</p> <blockquote> <p><strong>(Edited to address Allan's comments)</strong></p> </blockquote> <p>You could do:</p> <pre><code>@foobar = Foobar.scope.scope.scope.size </code></pre> <p>But this would cause a result query and not the faster <code>SELECT COUNT(*)</code> query. I have a large amount of rows in the database I am querying.</p> <p>Is there a better way to do this? </p>
[ { "answer_id": 411252, "author": "Allan L.", "author_id": 19527, "author_profile": "https://Stackoverflow.com/users/19527", "pm_score": 2, "selected": false, "text": "@foobar_size = Foobar.all.size #returns integer equal to total rows of Foobar\n @banned_foobars = Foobar.scope_to_find_ba...
2009/01/04
[ "https://Stackoverflow.com/questions/411134", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42914/" ]
411,142
<p>In Visual Studio (C++), is there a way to easily find duplicate headers that are defined in .cpp files?</p> <p>I'm also trying to find ways to detect this situation:</p> <ul> <li>A includes B includes C</li> <li>A includes C</li> <li>=> A doesn't need to include C</li> </ul>
[ { "answer_id": 411156, "author": "JaredPar", "author_id": 23283, "author_profile": "https://Stackoverflow.com/users/23283", "pm_score": 4, "selected": true, "text": "#if A_H\n#error \"Duplicate include\"\n#else\n#define A_H\n#endif\n" } ]
2009/01/04
[ "https://Stackoverflow.com/questions/411142", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3153/" ]
411,143
<p>Is it possible to make the text in a TextBox unselectable without disabling the TextBox? It's a RichTextBox and I need it's formatting and selection features. I can't disable it because I want to handle MouseMove and MouseDown events.</p> <p>So far I've thought about disabling the Text box and putting a panel on top of it which will delegate it's events to the textbox handlers, but I can't make the panel transparent so it hides the textbox.</p> <p>Thanks.</p>
[ { "answer_id": 411198, "author": "lc.", "author_id": 44853, "author_profile": "https://Stackoverflow.com/users/44853", "pm_score": 0, "selected": false, "text": "ReadOnly" }, { "answer_id": 3333311, "author": "Human", "author_id": 283411, "author_profile": "https://St...
2009/01/04
[ "https://Stackoverflow.com/questions/411143", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19956/" ]
411,145
<p>Could anyone explain me why:</p> <pre><code>function doAjax() { var xmlHttpReq = false; try { // Firefox, Opera 8.0+ and Safari xmlHttpReq = new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttpReq = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("Your browser does not support AJAX. Please use an AJAX compatible browser."); return false; } } } xmlHttpReq.open('GET', 'handler.php', true); xmlHttpReq.onreadystatechange = function() { if (xmlHttpReq.readyState == 4) { var response = xmlHttpReq.responseText; handleAjaxResponse(response); } }; xmlHttpReq.send(null); return true; } </code></pre> <p>is causing the following validation errors:</p> <pre><code>Error: Implied global: ActiveXObject 8, XMLHttpRequest 4, alert 15, handleAjaxResponse 24 Problem at line 10 character 16: 'e' is already defined. catch (e) { Problem at line 14 character 20: 'e' is already defined. catch (e) { </code></pre> <p>by the JSlint.com javascript validator</p>
[ { "answer_id": 411158, "author": "Aron Rotteveel", "author_id": 11568, "author_profile": "https://Stackoverflow.com/users/11568", "pm_score": 3, "selected": false, "text": "/*global getElementByAttribute, breakCycles, hanoi */\n /*global /*global e" }, { "answer_id": 411224, ...
2009/01/04
[ "https://Stackoverflow.com/questions/411145", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45974/" ]
411,167
<p>I'm using URL rewrite on my site to get URLs like:<br> <em><a href="http://mysite.com/users/john" rel="nofollow noreferrer">http://mysite.com/users/john</a></em><br> instead of<br> <em><a href="http://mysite.com/index.aspx?user=john" rel="nofollow noreferrer">http://mysite.com/index.aspx?user=john</a></em></p> <p>To achive this extensionless rewrite with IIS6 and no access to the hosting-server I use the "404-approach". When a request that the server can't find, the mapped 404-page is executed, since this is a aspx-page the rewrite can be performed (I can setup the 404-mapping using the controlpanel on the hosting-service).</p> <p>This is the code in Global.asax:</p> <pre><code>protected void Application_BeginRequest(object sender, EventArgs e) { string url = HttpContext.Current.Request.Url.AbsolutePath; if (url.Contains("404.aspx")) { string[] urlInfo404 = Request.Url.Query.ToString().Split(';'); if (urlInfo404.Length &gt; 1) { string requestURL = urlInfo404[1]; if (requestURL.Contains("/users/")) { HttpContext.Current.RewritePath("~/index.aspx?user=" + GetPageID(requestURL)); StoreRequestURL(requestURL); } else if (requestURL.Contains("/picture/")) { HttpContext.Current.RewritePath("~/showPicture.aspx?pictureID=" + GetPageID(requestURL)); StoreRequestURL(requestURL); } } } } private void StoreRequestURL(string url) { url = url.Replace("http://", ""); url = url.Substring(url.IndexOf("/")); HttpContext.Current.Items["VirtualUrl"] = url; } private string GetPageID(string requestURL) { int idx = requestURL.LastIndexOf("/"); string id = requestURL.Substring(idx + 1); id = id.Replace(".aspx", ""); //Only needed when testing without the 404-approach return id; } </code></pre> <p>And in Page_Load on my masterpage I set the correct URL in the action-attribute on the form-tag.</p> <pre><code>protected void Page_Load(object sender, EventArgs e) { string virtualURL = (string)HttpContext.Current.Items["VirtualUrl"]; if (!String.IsNullOrEmpty(virtualURL)) { form1.Action = virtualURL; } } </code></pre> <p>The rewrite works fine but when I perform a postback on the page the postback isn't executed, can this be solved somehow?</p> <p>The problem seems to be with the 404-approach because when I try without it (and loses the extensionless-feature) the postback works. That is when I request:<br> <em><a href="http://mysite.com/users/john.aspx" rel="nofollow noreferrer">http://mysite.com/users/john.aspx</a></em> </p> <p>Can this be solved or is there any other solution that fulfil my requirements (IIS6, no serveraccess/ISAPI-filter and extensionless).</p>
[ { "answer_id": 411183, "author": "Shawn", "author_id": 26, "author_profile": "https://Stackoverflow.com/users/26", "pm_score": 1, "selected": false, "text": "<form runat=\"server\"> <form> <form> <form>" }, { "answer_id": 2666727, "author": "Toma", "author_id": 320233, ...
2009/01/04
[ "https://Stackoverflow.com/questions/411167", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39636/" ]
411,218
<p>Has anyone used <a href="http://hudson.dev.java.net/" rel="noreferrer">Hudson</a> as a Continuous-Integration server for a C++ project using <a href="http://unittest-cpp.sourceforge.net/" rel="noreferrer">UnitTest++</a> as a testing library?</p> <p>How exactly did you set it up?</p> <p>I know there have been several questions on Continuous Integration before, but I hope this one has a narrower scope.</p> <p>EDIT: I'll clarify a bit on what I'm looking for. I already have the build set to fail when the Unit-Tests fail. I'm looking for something like Hudson's JUnit support. UnitTest++ can create XML reports (See <a href="http://www.alittlemadness.com/2007/01/10/unittest-reports/" rel="noreferrer">here</a>). So, perhaps if someone knows how to translate these reports to be JUnit compatible, Hudson will know how to eat it up?</p>
[ { "answer_id": 413316, "author": "Patrick Johnmeyer", "author_id": 363, "author_profile": "https://Stackoverflow.com/users/363", "pm_score": 5, "selected": true, "text": "main()" }, { "answer_id": 701194, "author": "Community", "author_id": -1, "author_profile": "http...
2009/01/04
[ "https://Stackoverflow.com/questions/411218", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11515/" ]
411,221
<p>Can someone please explain why <code>int (0.4 * 10.0)</code> is <code>4</code> yet <code>int ((2.4 - 2.0) * 10.0)</code> is <code>3</code>?</p> <p>And then also please explain how to get <code>4</code>. i.e. Do I really have to do <code>int (System.Math.Round((2.4 - 2.0) * 10.0))</code>?</p> <p>It's just so ugly for something that should be so simple.</p>
[ { "answer_id": 413212, "author": "Alexey Romanov", "author_id": 9204, "author_profile": "https://Stackoverflow.com/users/9204", "pm_score": 3, "selected": false, "text": "let round x = int System.Math.Round(x)\n" }, { "answer_id": 413229, "author": "Alexey Romanov", "auth...
2009/01/04
[ "https://Stackoverflow.com/questions/411221", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40783/" ]
411,222
<p>I am looking to make a website and in the future desktop apps as well and i know nothing about db design so what tutorials or books (online preferably) are there? thanks </p>
[ { "answer_id": 413212, "author": "Alexey Romanov", "author_id": 9204, "author_profile": "https://Stackoverflow.com/users/9204", "pm_score": 3, "selected": false, "text": "let round x = int System.Math.Round(x)\n" }, { "answer_id": 413229, "author": "Alexey Romanov", "auth...
2009/01/04
[ "https://Stackoverflow.com/questions/411222", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44411/" ]
411,228
<p><em>I removed the footer for the time being, site had to go online. So the link is gone as well.</em></p> <p>As you can see (in FF2 as well as in IE7) the footer is at the bottom of the SCREEN, but not at the bottom of the page (content).</p> <p>I have this in my code:</p> <pre><code>&lt;div id="wrap"&gt; &lt;div id="top"&gt;&lt;/div&gt; &lt;div id="content"&gt;&lt;/div&gt; &lt;div id="footer"&gt;&lt;/div&gt; &lt;/div&gt; </code></pre> <p>and this in the css:</p> <pre><code>html { height: 100%; margin: 0; padding: 0; } body { height: 100%; margin: 0; padding: 0; padding-bottom: 30px; /* height of the footer */ } #wrap { margin-left: auto; margin-right: auto; width: 960px; min-height: 100%; position: relative; } *#wrap { /* IE hack */ height:100%; } #footer { position: absolute; bottom: 0; width: 100%; height: 30px; padding: 0; margin: 0; } </code></pre> <p>Or, making a long story short: I followed the instructions given <a href="http://matthewjamestaylor.com/blog/keeping-footers-at-the-bottom-of-the-page" rel="nofollow noreferrer">here</a>.</p>
[ { "answer_id": 411265, "author": "James Anderson", "author_id": 27632, "author_profile": "https://Stackoverflow.com/users/27632", "pm_score": 0, "selected": false, "text": " <style type=\"text/css\">\nhtml {\n height: 100%;\n margin: 0;\n padding: 0;\n}\nbody {\n height: 1...
2009/01/04
[ "https://Stackoverflow.com/questions/411228", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42389/" ]
411,232
<p>If i have a complex object, what is the best practice pattern to write code to compare 2 instances to see if they are the same</p>
[ { "answer_id": 411260, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 2, "selected": false, "text": "if their references are equal (includes both null)\n return true\nelse if one object is null\n return false\nelse\n...
2009/01/04
[ "https://Stackoverflow.com/questions/411232", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4653/" ]
411,237
<p>I have a problem.</p> <p>I have wrote an upload form on my html page. Then created an upload php file. I added both to my webserver 1 and 1. when clicking on the script on the live webpage - it starts uploading, however the domain name/upload.php file sits there with nothing there (blank) when i check the destination folder nothing is there.</p> <p>any gurus willing to help with this - i'm baffled - its my first time dabbling with php?</p>
[ { "answer_id": 411370, "author": "ceejayoz", "author_id": 1902010, "author_profile": "https://Stackoverflow.com/users/1902010", "pm_score": 2, "selected": false, "text": "<form> enctype=\"multipart/form-data\" print_r($_FILES);" } ]
2009/01/04
[ "https://Stackoverflow.com/questions/411237", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
411,247
<p>How can I run a CMD or .bat file in silent mode? I'm looking to prevent the CMD interface from being shown to the user.</p>
[ { "answer_id": 411269, "author": "Frederick The Fool", "author_id": 32688, "author_profile": "https://Stackoverflow.com/users/32688", "pm_score": 6, "selected": false, "text": "@echo off\n" }, { "answer_id": 411270, "author": "VonC", "author_id": 6309, "author_profile...
2009/01/04
[ "https://Stackoverflow.com/questions/411247", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2140183/" ]
411,249
<p>I'm working for a company that has strict coding style guidelines but no automatic tool to validate them. I've looked around and the only tools I could find were lint like tools that seem to be aimed at verifying what the code does, and preventing bugs and not at making sure the coding style is correct.</p> <p>What tool should we use, if at all?</p> <p>NOTE: I'm looking for something for C code, although something that works for C++ would be good as well.</p>
[ { "answer_id": 411293, "author": "Jonathan Leffler", "author_id": 15168, "author_profile": "https://Stackoverflow.com/users/15168", "pm_score": 2, "selected": false, "text": "cb CB ( 1 ) UNIX Programmer’s Manual CB ( 1 )\n\nNAME\n cb – C program beautifier\nSYNOPSIS\n cb\nDESCRIPTI...
2009/01/04
[ "https://Stackoverflow.com/questions/411249", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15109/" ]
411,254
<p>What are the main differences between PHP and Java that someone proficient in PHP but learning Java should know about?</p> <p><strong>Edit:</strong> I mean differences in the syntax of the languages, i.e their data types, how they handle arrays &amp; reference variables, and so forth :)</p>
[ { "answer_id": 411650, "author": "Alan Storm", "author_id": 4668, "author_profile": "https://Stackoverflow.com/users/4668", "pm_score": 7, "selected": true, "text": "int foo = 36;\nchar bar = 'b';\ndouble baz = 3.14;\nString speech = \"We hold these truths ...\";\nMyWidget widget...
2009/01/04
[ "https://Stackoverflow.com/questions/411254", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49153/" ]
411,295
<p>i'm using this example implementation found at <a href="http://tangentsoft.net/wskfaq/examples/basics/select-server.html" rel="nofollow noreferrer">http://tangentsoft.net/wskfaq/examples/basics/select-server.html</a></p> <p>This is doing most of what I need, handles connections without blocking and does all work in its thread (not creating a new thread for each connection as some examples do), but i'm worried since i've been told winsock will only support max 64 client connectios :S</p> <p>Is this 64 connections true?</p> <p>What other choices do I have? It would be cool to have a c++ example for a similar implementation.</p> <p>Thanks</p>
[ { "answer_id": 411321, "author": "Daniel Sloof", "author_id": 51133, "author_profile": "https://Stackoverflow.com/users/51133", "pm_score": 2, "selected": false, "text": " if ((gConnections.size() + 1) > 64) {\n // For the background on this check, see\n...
2009/01/04
[ "https://Stackoverflow.com/questions/411295", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49710/" ]
411,296
<p>I have a List (Foo) and I want to see if it's equal to another List (foo). What is the fastest way ?</p>
[ { "answer_id": 411313, "author": "M4N", "author_id": 19635, "author_profile": "https://Stackoverflow.com/users/19635", "pm_score": 1, "selected": false, "text": "public static bool CompareLists(List<int> l1, List<int> l2)\n{\n if (l1 == l2) return true;\n if (l1.Count != l2.Count) ...
2009/01/04
[ "https://Stackoverflow.com/questions/411296", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4653/" ]
411,302
<p>does anyone know why this is a bad request?</p> <pre><code>http://chart.apis.google.com/chart?cht=lxy&amp; chd=t:0,0.7,1.4,2.2,2.9,3.6,4.3,5,5.8,6.5,7.2,7.9,8.6,9.4,10.1,10.8,11.5,12.2,12.9,13.7,14.4,15.1,15.8,16.5,17.3,18,18.7,19.4,20.1,20.9,21.6,22.3,23,23.7,24.5,25.2,25.9,26.6,27.3,28.1,28.8,29.5,30.2,30.9,31.7,32.4,33.1,33.8,34.5,35.3,36,36.7,37.4,38.1,38.8,39.6,40.3,41,41.7,42.4,43.2,43.9,44.6,45.3,46,46.8,47.5,48.2,48.9,49.6,50.4,51.1,51.8,52.5,53.2,54,54.7,55.4,56.1,56.8,57.6,58.3,59,59.7,60.4,61.2,61.9,62.6,63.3,64,64.7,65.5,66.2,66.9,67.6,68.3,69.1,69.8,70.5,71.2,71.9,72.7,73.4,74.1,74.8,75.5,76.3,77,77.7,78.4,79.1,79.9,80.6,81.3,82,82.7,83.5,84.2,84.9,85.6,86.3,87.1,87.8,88.5,89.2,89.9,90.6,91.4,92.1,92.8,93.5,94.2,95,95.7,96.4,97.1,97.8,98.6,99.3|30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30|0,0.7,1.4,2.2,2.9,3.6,4.3,5,5.8,6.5,7.2,7.9,8.6,9.4,10.1,10.8,11.5,12.2,12.9,13.7,14.4,15.1,15.8,16.5,17.3,18,18.7,19.4,20.1,20.9,21.6,22.3,23,23.7,24.5,25.2,25.9,26.6,27.3,28.1,28.8,29.5,30.2,30.9,31.7,32.4,33.1,33.8,34.5,35.3,36,36.7,37.4,38.1,38.8,39.6,40.3,41,41.7,42.4,43.2,43.9,44.6,45.3,46,46.8,47.5,48.2,48.9,49.6,50.4,51.1,51.8,52.5,53.2,54,54.7,55.4,56.1,56.8,57.6,58.3,59,59.7,60.4,61.2,61.9,62.6,63.3,64,64.7,65.5,66.2,66.9,67.6,68.3,69.1,69.8,70.5,71.2,71.9,72.7,73.4,74.1,74.8,75.5,76.3,77,77.7,78.4,79.1,79.9,80.6,81.3,82,82.7,83.5,84.2,84.9,85.6,86.3,87.1,87.8,88.5,89.2,89.9,90.6,91.4,92.1,92.8,93.5,94.2,95,95.7,96.4,97.1,97.8,98.6,99.3|28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28|0,0.7,1.4,2.2,2.9,3.6,4.3,5,5.8,6.5,7.2,7.9,8.6,9.4,10.1,10.8,11.5,12.2,12.9,13.7,14.4,15.1,15.8,16.5,17.3,18,18.7,19.4,20.1,20.9,21.6,22.3,23,23.7,24.5,25.2,25.9,26.6,27.3,28.1,28.8,29.5,30.2,30.9,31.7,32.4,33.1,33.8,34.5,35.3,36,36.7,37.4,38.1,38.8,39.6,40.3,41,41.7,42.4,43.2,43.9,44.6,45.3,46,46.8,47.5,48.2,48.9,49.6,50.4,51.1,51.8,52.5,53.2,54,54.7,55.4,56.1,56.8,57.6,58.3,59,59.7,60.4,61.2,61.9,62.6,63.3,64,64.7,65.5,66.2,66.9,67.6,68.3,69.1,69.8,70.5,71.2,71.9,72.7,73.4,74.1,74.8,75.5,76.3,77,77.7,78.4,79.1,79.9,80.6,81.3,82,82.7,83.5,84.2,84.9,85.6,86.3,87.1,87.8,88.5,89.2,89.9,90.6,91.4,92.1,92.8,93.5,94.2,95,95.7,96.4,97.1,97.8,98.6,99.3|0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0|0,0.7,1.4,2.2,2.9,3.6,4.3,5,5.8,6.5,7.2,7.9,8.6,9.4,10.1,10.8,11.5,12.2,12.9,13.7,14.4,15.1,15.8,16.5,17.3,18,18.7,19.4,20.1,20.9,21.6,22.3,23,23.7,24.5,25.2,25.9,26.6,27.3,28.1,28.8,29.5,30.2,30.9,31.7,32.4,33.1,33.8,34.5,35.3,36,36.7,37.4,38.1,38.8,39.6,40.3,41,41.7,42.4,43.2,43.9,44.6,45.3,46,46.8,47.5,48.2,48.9,49.6,50.4,51.1,51.8,52.5,53.2,54,54.7,55.4,56.1,56.8,57.6,58.3,59,59.7,60.4,61.2,61.9,62.6,63.3,64,64.7,65.5,66.2,66.9,67.6,68.3,69.1,69.8,70.5,71.2,71.9,72.7,73.4,74.1,74.8,75.5,76.3,77,77.7,78.4,79.1,79.9,80.6,81.3,82,82.7,83.5,84.2,84.9,85.6,86.3,87.1,87.8,88.5,89.2,89.9,90.6,91.4,92.1,92.8,93.5,94.2,95,95.7,96.4,97.1,97.8,98.6,99.3|100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100&amp; chco=3072F3,ff0000,00aaaa,541269&amp;chs=1000x200&amp;chxt=x,y&amp; chxl=0:|18|18|18|18|18|19|19|19|19|19|19|20|20|20|20|20|20|21|21|21|21|21|21|22|22|22|22|22|22|23|23|23|23|23|23|0|0|0|0|0|0|1|1|1|1|1|1|2|2|2|2|2|2|3|3|3|3|3|3|4|4|4|4|4|4|5|5|5|5|5|5|6|6|6|6|6|6|7|7|7|7|7|7|8|8|8|8|8|8|9|9|9|9|9|9|10|10|10|10|10|10|11|11|11|11|11|11|12|12|12|12|12|12|13|13|13|13|13|13|14|14|14|14|14|14|15|15|15|15|15|15|16|16|16|16|16|16|17|17|1:||3.5|7|10.5|14 </code></pre> <p>trying to plot four lines on a graph</p> <p>thanks</p>
[ { "answer_id": 10834547, "author": "DespairTyre", "author_id": 585243, "author_profile": "https://Stackoverflow.com/users/585243", "pm_score": 0, "selected": false, "text": "<form id='graphform' name='graphform' action='https://chart.googleapis.com/chart' method='POST' target='graph_targ...
2009/01/04
[ "https://Stackoverflow.com/questions/411302", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
411,304
<p>Hi i'v look through the WMI class... but none can help me in getting the partition table information... now i'm having a project which is to display the USB thumbdrive's .MBR how should i go about it? really puzzle... Any help and guide will be very much appreciated!</p> <p>p.s. the code can only be written in C#</p> <p><strong>Edit</strong></p> <p>Thank you! I've browse through the CreateFile documentation... Still wondering how should I use P/Invoke to call CreateFile and to read the boot sector( display out the .MBR )? Do you have any reference code for this portion? Thank you once again!!</p>
[ { "answer_id": 411446, "author": "Roger Lipscombe", "author_id": 8446, "author_profile": "https://Stackoverflow.com/users/8446", "pm_score": 3, "selected": true, "text": "\"\\\\.\\PHYSICALDRIVE0\"" }, { "answer_id": 5936389, "author": "Mert Gülsoy", "author_id": 745049, ...
2009/01/04
[ "https://Stackoverflow.com/questions/411304", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
411,306
<p>I have some XML code that looks like this</p> <pre><code>&lt;SEARCHRESULTS&gt; &lt;FUNCTION name="BarGraph"&gt; &lt;PARAMETER name="numList"&gt;&lt;/PARAMETER&gt; &lt;PARAMETER name="maxValue"&gt;&lt;/PARAMETER&gt; &lt;CODE&gt;Some code&lt;/CODE&gt; &lt;/FUNCTION&gt; &lt;/SEARCHRESULTS&gt; </code></pre> <p>And I want to extract a list of parameter names for each function, so far I've got the following xsl code</p> <pre><code>&lt;xsl:for-each select="SEARCHRESULTS/FUNCTION"&gt; &lt;ROW&gt; &lt;COL&gt;&lt;DATA&gt;&lt;xsl:value-of select="@name" /&gt;&lt;/DATA&gt;&lt;/COL&gt; &lt;COL&gt;&lt;DATA&gt;&lt;xsl:value-of select="PARAMETER/@name" /&gt;&lt;/DATA&gt;&lt;/COL&gt; &lt;COL&gt;&lt;DATA&gt;&lt;xsl:value-of select="CODE" /&gt;&lt;/DATA&gt;&lt;/COL&gt; &lt;/ROW&gt; &lt;/xsl:for-each&gt; </code></pre> <p>which of course returns the name of the first parameter along with the function name and code.</p> <p>I want a list of all the parameters for the function in a text string. Return separated is best, but as long as all the names are in the string I can parse it later on.</p> <p>I could normalise the parameter records out in the target database - but I'm not going to, I just need them for display purposes really so I don't want to put too much effort in. This is why I'm looking for a simple text string.</p> <p>I thought there might be some way of just putting an asterisk in or something. If not I'll create a variable and add another for-each to build a string - but it just seems like there should be a simpler way</p> <p>The resulting XML should look like</p> <pre><code>&lt;ROW&gt; &lt;COL&gt;&lt;DATA&gt;BarGraph&lt;/DATA&gt;&lt;/COL&gt; &lt;COL&gt;&lt;DATA&gt;numList;maxValue&lt;/DATA&gt;&lt;/COL&gt; &lt;COL&gt;&lt;DATA&gt;Some code&lt;/DATA&gt;&lt;/COL&gt; &lt;/ROW&gt; </code></pre> <p>Where the ';' in the second column could be a carriage return or another character that I can specify</p>
[ { "answer_id": 411323, "author": "Dirk Vollmar", "author_id": 40347, "author_profile": "https://Stackoverflow.com/users/40347", "pm_score": 3, "selected": true, "text": "<xsl:template match=\"/\">\n<xsl:for-each select=\"SEARCHRESULTS/FUNCTION\">\n <ROW>\n <COL>\n <DATA>\n ...
2009/01/04
[ "https://Stackoverflow.com/questions/411306", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6106/" ]
411,312
<p>At the company I work for, I have created a Error Logging class to handle errors in my ASP.net application. It is a custom class because we are not allowed to install additional software on our servers (nLog, log4net, etc).</p> <p>I currently use it in two of my projects and have seen some good results from it. Right now I am trapping the errors that cause page and application errors. It sends and stores the error message and all inner exceptions. </p> <p>The problem I am having now is, I am receiving errors that I am not quite sure how to reproduce. I have not heard any error reports from any of my users. I am not sure what they are doing, or even if they are seeing these as errors.</p> <p>I am thinking about creating an Event Log on each page, or the ones I want additional information on. Keeping it as a Session variable on the page, and writing events to it (start/end of functions, variable changes, etc). Then only if an error is called to have that send along with the error message to see if it gives a better picture of what is going on. I am hoping that doing it this way will not give me tons of event logs when all users access the application, just want was going on right before the error happen with the one user.</p> <p>Do you know of any pitfalls I should watchout with method?</p> <p>Do you have any advise for things to look for? </p> <p>Update:</p> <p>@Saret: I understnad where you are coming from with that response and I agree. I am fairly new to this company and still need to learn how they do things. In the past I have had conversations with my coworkers how it would be great to have this product, or use this open source project. The problem comes down to is, we work on secure systems and getting approval to get these things takes a lot of time, top cover, and dealing with all the red tape. I will look into the situation further because I believe having a good error logging system in place is important, currently nothing is being used.</p> <p>@Jim Blizard: I wanted to try to get away from logging/storing everything someplace to come back and find out what is important to the situation that caused the error. I didn't want to fall into overload of information that is talked about in artical that Roberto Barros linked. My current method of thinking is, keeping a string in memory on each page, and if an error is rasied, on the pages Page_Error event, grab that string and attach it to the exception that is getting logged. That way I am only logging the error/exceptions that occured and storing the event log with that error. If nothing happens, that log that was being created is dropped into the bit bucket never to be seen again.</p> <p>@Roberto Barros: Thanks for that link, I remember reading it somewhere but forgot to save it.</p>
[ { "answer_id": 412076, "author": "Cohen", "author_id": 34474, "author_profile": "https://Stackoverflow.com/users/34474", "pm_score": 2, "selected": false, "text": "\nprotected void Application_Error(object sender, EventArgs e)\n{\n Server.Transfer(\"~/Support/ServerErrorSupport.aspx\"...
2009/01/04
[ "https://Stackoverflow.com/questions/411312", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31474/" ]
411,316
<p>I've made a C# usercontrol with one textbox and one richtextbox.</p> <p>How can I access the properties of the richtextbox from outside the usercontrol.</p> <p>For example.. if i put it in a form, how can i use the Text propertie of the richtextbox???</p> <p>thanks</p>
[ { "answer_id": 411332, "author": "M4N", "author_id": 19635, "author_profile": "https://Stackoverflow.com/users/19635", "pm_score": 6, "selected": true, "text": "class MyUserControl\n{\n // expose the Text of the richtext control (read-only)\n public string TextOfRichTextBox\n {\n g...
2009/01/04
[ "https://Stackoverflow.com/questions/411316", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50069/" ]
411,330
<p>Which one of the following do you do:</p> <pre><code>var = true; if (...) var = false; </code></pre> <p>Or</p> <pre><code>if (...) var = false; else var = true; </code></pre> <p>Is there a reason you pick on or the other?</p> <p>I'm working on the premise that nothing else is happening to var. The next line of code might be something like:</p> <pre><code>if (var) { ... } </code></pre>
[ { "answer_id": 411350, "author": "krosenvold", "author_id": 23691, "author_profile": "https://Stackoverflow.com/users/23691", "pm_score": 4, "selected": true, "text": "var = { ... } boolean" }, { "answer_id": 411357, "author": "ForYourOwnGood", "author_id": 48728, "au...
2009/01/04
[ "https://Stackoverflow.com/questions/411330", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5441/" ]
411,331
<p>I found several other questions on SO regarding the JavaMail API and sending mail through an SMTP server, but none of them discussed using TLS security. I'm trying to use JavaMail to send status updates to myself through my work SMTP mail server, but it requires TLS, and I can't find any examples online of how to use JavaMail to access an SMTP server that requires TLS encryption. Can anyone help with this?</p>
[ { "answer_id": 411362, "author": "Sarat", "author_id": 18937, "author_profile": "https://Stackoverflow.com/users/18937", "pm_score": 7, "selected": true, "text": "Properties props = new Properties();\nprops.put(\"mail.smtp.starttls.enable\",\"true\");\nprops.put(\"mail.smtp.auth\", \"tru...
2009/01/04
[ "https://Stackoverflow.com/questions/411331", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42891/" ]
411,352
<p>I have now seen 2 methods for determining if an argument has been passed to a JavaScript function. I'm wondering if one method is better than the other or if one is just bad to use?</p> <pre><code> function Test(argument1, argument2) { if (Test.arguments.length == 1) argument2 = 'blah'; alert(argument2); } Test('test'); </code></pre> <p>Or</p> <pre><code> function Test(argument1, argument2) { argument2 = argument2 || 'blah'; alert(argument2); } Test('test'); </code></pre> <p>As far as I can tell, they both result in the same thing, but I've only used the first one before in production.</p> <p>Another Option as mentioned by <a href="https://stackoverflow.com/questions/411352/how-best-to-determine-if-an-argument-is-not-sent-to-the-javascript-function#411368">Tom</a>:</p> <pre><code>function Test(argument1, argument2) { if(argument2 === null) { argument2 = 'blah'; } alert(argument2); } </code></pre> <p>As per Juan's comment, it would be better to change Tom's suggestion to:</p> <pre><code>function Test(argument1, argument2) { if(argument2 === undefined) { argument2 = 'blah'; } alert(argument2); } </code></pre>
[ { "answer_id": 411372, "author": "Christoph", "author_id": 48015, "author_profile": "https://Stackoverflow.com/users/48015", "pm_score": 9, "selected": true, "text": "arguments.length || undefined argument2 === undefined typeof argument2 === 'undefined' || false undefined null false 0 ''...
2009/01/04
[ "https://Stackoverflow.com/questions/411352", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5441/" ]
411,396
<p>Hi I've got a DIV section that has only its title visible initially. What I would like to achieve is that when the visitor clicks anywhere on the area of <code>toggle_section</code> the <code>toggle_stuff</code> div toggles between visible/hidden.</p> <pre><code>&lt;div id="toggle_section" onclick="javascript: new Effect.toggle('toggle_stuff', 'slide');"&gt; &lt;div id="toggle_title"&gt;Some title&lt;/div&gt; &lt;div id="toggle_stuff"&gt; some content stuff &lt;a href="/foo.php"&gt;Some link&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>However, the way it is set-up right now, if I have any <code>&lt;a&gt;</code> link within the <code>toggle_section</code>, clicking that link will also execute the onclick event.</p> <p>Then my question is what would be the best way to set this type of behavior?</p>
[ { "answer_id": 411458, "author": "andyk", "author_id": 26721, "author_profile": "https://Stackoverflow.com/users/26721", "pm_score": 0, "selected": false, "text": "z-index #toggle_section a { z-index: 10; }\n" }, { "answer_id": 411488, "author": "Aron Rotteveel", "author_...
2009/01/04
[ "https://Stackoverflow.com/questions/411396", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47193/" ]
411,407
<p>Well, my question is simple. </p> <p>Does the ID affect the position of a webpage on Google ? I have links like this <code>http://example.com/news/title-slug/15/</code> and people say to me that I should remove the ID from the URL. </p> <p>And I belive that is not true. By my logic, you can't depend on the title's slug. I know it should work perfectly fine if there aren't two pages that have the same title, but why should I remove the ID if there is no harm when it's there. </p>
[ { "answer_id": 411423, "author": "Gareth", "author_id": 31582, "author_profile": "https://Stackoverflow.com/users/31582", "pm_score": 4, "selected": false, "text": "http://example.com/news/wrong-title-slug/15/ http://example.com/news/title-slug/15/" }, { "answer_id": 411480, ...
2009/01/04
[ "https://Stackoverflow.com/questions/411407", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51414/" ]
411,410
<p>What's the best practice for setting up a subversion repository on a linux development machine. External users need to be able to access a specific repository, but nothing else on the machine. I know one answer is to set up a dedicated repository, but I'm looking for a single machine solution: location of repositories, accounts, backup procedures.</p>
[ { "answer_id": 411433, "author": "Eugene Yokota", "author_id": 3827, "author_profile": "https://Stackoverflow.com/users/3827", "pm_score": 3, "selected": false, "text": "mod_auth_sspi" }, { "answer_id": 412521, "author": "jtimberman", "author_id": 7672, "author_profil...
2009/01/04
[ "https://Stackoverflow.com/questions/411410", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14167/" ]
411,422
<p>I'm reading some code in the <a href="http://www.ogre3d.org" rel="nofollow noreferrer">Ogre3D</a> implementation and I can't understand what a <code>void *</code> type variable means. What does a pointer to <code>void</code> mean in C++?</p>
[ { "answer_id": 411429, "author": "Johannes Schaub - litb", "author_id": 34509, "author_profile": "https://Stackoverflow.com/users/34509", "pm_score": 6, "selected": true, "text": "void* int a = 5;\nvoid *p = &a;\n\ndouble b = 3.14;\np = &b;\n void* memcpy" }, { "answer_id": 41168...
2009/01/04
[ "https://Stackoverflow.com/questions/411422", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25418/" ]
411,436
<p>My app uses NSTimer and it appears that NSTimer doesn't fire when the iPhone goes into the stand-by mode (either by pressing the hardware button or by the idle timer).</p> <p>When I activate the iPhone again, my app is still in the foreground. What happens to third party apps when the iPhone is the stand-by mode?</p>
[ { "answer_id": 411542, "author": "zoul", "author_id": 17279, "author_profile": "https://Stackoverflow.com/users/17279", "pm_score": 4, "selected": false, "text": "applicationWillResignActive applicationDidBecomeActive" }, { "answer_id": 846333, "author": "Amber Star", "au...
2009/01/04
[ "https://Stackoverflow.com/questions/411436", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44091/" ]
411,447
<p>After posting <a href="https://stackoverflow.com/questions/410890/how-to-trace-a-nullpointerexception-in-a-chain-of-getters" title="How to trace a NullPointerException in a chain of getters?">this question</a> and reading <a href="https://stackoverflow.com/questions/271526/How-to-avoid-null-statements-in-java" title="how to avoid null statements in java?">that one</a> I realized that it is very important to know if a method is supposed to return null, or if this is considered an error condition and an exceptions should be thrown. There also is a nice discussion when to <a href="https://stackoverflow.com/questions/175532/return-null-or-throw-exception">return ‘null’ or throw exception </a>.</p> <p><strong>I'm writing a method and I already know if I want to return null or throw an exception, what is the best way to express my decision, in other words, to document my contract?</strong></p> <p>Some ways I can think of:</p> <ul> <li>Write it down in the specs / the documentation (will anyone read it?)</li> <li>Make it part of the method name (as I suggested <a href="https://stackoverflow.com/questions/175532/return-null-or-throw-exception#411400" title="answer on &#39;Return null or throw exception&#39;">here</a>)</li> <li>assume that every method that <em>throws</em> an exception will <em>not</em> return null, and every one that does 'not' throw <em>might</em> return null.</li> </ul> <p>I'm mainly talking about java, but it might apply to other languages, too: Why is there a formal way to express if exceptions will be thrown (the <code>throws</code> keywords) but no formal way to express if null might be returned? </p> <p>Why isn't there something like that:</p> <pre><code>public notnull Object methodWhichCannotReturnNull(int i) throws Exception { return null; // this would lead to a compiler error! } </code></pre> <h2>Summary and Conclusion</h2> <p>There are many ways to express the contract:</p> <ul> <li>If your IDE supports it (as IntelliJ), it's best to use an annotation like <code>@NotNull</code> because it is visible to the programmer and can be used for automated compile time checking. There's a <a href="http://groups.csail.mit.edu/pag/jsr308/eclipse/" rel="noreferrer">plugin for Eclipse</a> to add support for these, but it didn't work for me.</li> <li>If these are not an option, use custom Types like <code>Option&lt;T&gt;</code> or <code>NotNull&lt;T&gt;</code>, which add clarity and at least runtime checking.</li> <li>In any way, documenting the contract in the JavaDoc never hurts and sometimes even helps.</li> <li>Using method names to document the <em>nullability</em> of the return value was not proposed by anyone but me, and though it might be very verbose und not always useful, I still believe sometimes it has its advantages, too.</li> </ul>
[ { "answer_id": 411467, "author": "Apocalisp", "author_id": 3434, "author_profile": "https://Stackoverflow.com/users/3434", "pm_score": 3, "selected": false, "text": "Option Option<Object> Object None public Option<Integer> parseInt(String s) {\n try {\n return Option.some(Integer....
2009/01/04
[ "https://Stackoverflow.com/questions/411447", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39946/" ]
411,457
<p>I'm binding a domain objects property to the Text property of a System.Windows.Forms.Label using the <code>DataBindings</code>:</p> <pre><code>Label l = new Label(); l.DataBindings.Add(new Binding("Text",myDomainObject,"MyProperty")); </code></pre> <p>However, when I change the domain object, the Label does not reflect the change. I know that for complex Controls like the DataGridView, binding can be done with a BindingSource on which I can call ResetBindings, but I couldn't find any method to update the binding in the simple case of a Label.</p>
[ { "answer_id": 5096143, "author": "John Alexiou", "author_id": 380384, "author_profile": "https://Stackoverflow.com/users/380384", "pm_score": 3, "selected": false, "text": "INotifyPropertyChanged protected void OnPropertyChanged<T>(Expression<Func<T>> property)\n{\n if (this.Property...
2009/01/04
[ "https://Stackoverflow.com/questions/411457", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50697/" ]
411,462
<p>I am working on a small client server program to collect orders. I want to do this in a "REST(ful) way".</p> <p>What I want to do is:</p> <p>Collect all orderlines (product and quantity) and send the complete order to the server</p> <p>At the moment I see two options to do this:</p> <ol> <li>Send each orderline to the server: POST qty and product_id</li> </ol> <p>I actually don't want to do this because I want to limit the number of requests to the server so option 2:</p> <ol start="2"> <li>Collect all the orderlines and send them to the server at once.</li> </ol> <p>How should I implement option 2? a couple of ideas I have is: Wrap all orderlines in a JSON object and send this to the server or use an array to post the orderlines.</p> <p>Is it a good idea or good practice to implement option 2, and if so how should I do it.</p> <p>What is good practice? </p>
[ { "answer_id": 411622, "author": "Milan Novota", "author_id": 26123, "author_profile": "https://Stackoverflow.com/users/26123", "pm_score": 3, "selected": false, "text": "POST /orders\n" }, { "answer_id": 33768160, "author": "miguelcobain", "author_id": 1137735, "auth...
2009/01/04
[ "https://Stackoverflow.com/questions/411462", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
411,464
<p>I see many, many sites that have URLs for individual pages such as </p> <p><a href="http://www.mysite.com/articles/this-is-article-1" rel="nofollow noreferrer">http://www.mysite.com/articles/this-is-article-1</a> <a href="http://www.mysite.com/galleries/575" rel="nofollow noreferrer">http://www.mysite.com/galleries/575</a></p> <p>And they don't redirect, they don't run slowly...</p> <p>I know how to parse URL's, that's easy enough. But in my mind, that seems slow and cumbersome on a dynamic site. As well, if the pages are all staticly built (hende the custom URL) then that means all components of the page are static as well... (which would be bad)</p> <p>I'd love to hear some ideas about how this is typically accomplished.</p>
[ { "answer_id": 411581, "author": "Chris Nava", "author_id": 45163, "author_profile": "https://Stackoverflow.com/users/45163", "pm_score": 0, "selected": false, "text": "http://www.example.com/articles/12345 (where \"articles\" is a CGI script)\n ^CGI^ ^^^^^^PATH_I...
2009/01/04
[ "https://Stackoverflow.com/questions/411464", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42979/" ]
411,476
<p>I have a controller with two actions:</p> <pre><code>[AcceptVerbs("GET")] public ActionResult Add() { PrepareViewDataForAddAction(); return View(); } [AcceptVerbs("POST")] public ActionResult Add([GigBinderAttribute]Gig gig, FormCollection formCollection) { if (ViewData.ModelState.IsValid) { GigManager.Save(gig); return RedirectToAction("Index", gig.ID); } PrepareViewDataForAddAction(); return View(gig); } </code></pre> <p>As you can see, when the form posts its data, the Add action uses a GigBinder (An implemenation of IModelBinder)</p> <p>In this binder I have:</p> <pre><code> if (int.TryParse(bindingContext.HttpContext.Request.Form["StartDate.Hour"], out hour)) { gig.StartDate.Hour = hour; } else { bindingContext.ModelState.AddModelError("Doors", "You need to tell us when the doors open"); } </code></pre> <p>The form contains a text box with id "StartDate.Hour".</p> <p>As you can see above, the GigBinder tests to see that the user has typed in an integer into the textbox with id "StartDate.Hour". If not, a model error is added to the modelstate using AddModelError. </p> <p>Since the gigs property gigs.StartDate.Hour is strongly typed, I cannot set its value to, for example, "TEST" if the user has typed this into the forms textbox. </p> <p>Hence, I cant set the value of gigs.StartDate.Hour since the user has entered a string rather than an integer.</p> <p>Since the Add Action returns the view and passes the model (return View(gig);) if the modelstate is invalid, when the form is re-displayed with validation mssages, the value "TEST" is not displayed in the textbox. Instead, it will be the default value of gig.StartDate.Hour.</p> <p>How do I get round this problem? I really stuck!</p>
[ { "answer_id": 416654, "author": "Dominic Betts", "author_id": 50911, "author_profile": "https://Stackoverflow.com/users/50911", "pm_score": 1, "selected": false, "text": "if (!ViewData.ModelState.IsValid)\n {\n ViewData[\"StartDate.Hour\"] = \"Error\";\n }\n" } ]
2009/01/04
[ "https://Stackoverflow.com/questions/411476", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46616/" ]
411,478
<p>This method returns some strange results, and was wondering if someone could explain why this is happening, and possibly a solution to get my desired results.</p> <p>Results:</p> <p>FileName = what I'd expect</p> <p>FileSize = what I'd expect</p> <p>Buffer = all bytes = 0</p> <p>BytesRead = 0</p> <p>BlobString = string of binary data</p> <p>FieldType = BLOB (what I'd expect)</p> <p>ColumnType = System.String</p> <p>Furthermore, if the file is greater than a few KB, the reader throws an exception stating the StringBuilder capacity argument must be greater than zero (presummably because the size is greater than Int32.MaxValue).</p> <p>I guess my question is how does one properly read large BLOBs from an OdbcDataReader?</p> <pre><code> public static String SaveBinaryFile(String Key) { try { Connect(); OdbcCommand Command = new OdbcCommand("SELECT [_filename_],[_filesize_],[_content_] FROM [_sys_content] WHERE [_key_] = '" + Key + "';", Connection); OdbcDataReader Reader = Command.ExecuteReader(CommandBehavior.SequentialAccess); if (Reader.HasRows == false) return null; String FileName = Reader.GetString(0); int FileSize = int.Parse(Reader.GetString(1)); byte[] Buffer = new byte[FileSize]; long BytesRead = Reader.GetBytes(2, 0, Buffer, 0, FileSize); String BlobString = (String)Reader["_content_"]; String FieldType = Reader.GetDataTypeName(2); Type ColumnType = Reader.GetFieldType(2); return null; } catch (Exception ex) { Tools.ErrorHandler.Catch(ex); return null; } } </code></pre>
[ { "answer_id": 411490, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 0, "selected": false, "text": "Reader.GetFieldType(2) Reader.GetInt32(1) int.MaxValue" } ]
2009/01/04
[ "https://Stackoverflow.com/questions/411478", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
411,495
<p>In bash one can escape arguments that contain whitespace.</p> <pre><code>foo "a string" </code></pre> <p>This also works for arguments to a command or function:</p> <pre><code>bar() { foo "$@" } bar "a string" </code></pre> <p>So far so good, but what if I want to manipulate the arguments before calling <code>foo</code>?</p> <p>This does not work:</p> <pre><code>bar() { for arg in "$@" do args="$args \"prefix $arg\"" done # Everything looks good ... echo $args # ... but it isn't. foo $args # foo "$args" would just be silly } bar a b c </code></pre> <p>So how do you build argument lists when the arguments contain whitespace?</p>
[ { "answer_id": 411999, "author": "tarsius", "author_id": 51019, "author_profile": "https://Stackoverflow.com/users/51019", "pm_score": 6, "selected": true, "text": "\"${array[@]}\" bar() {\n local i=0 args=()\n for arg in \"$@\"\n do\n args[$i]=\"prefix $arg\"\n ((...
2009/01/04
[ "https://Stackoverflow.com/questions/411495", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51019/" ]
411,499
<p>Please take a look on the following pseudo-code:</p> <pre><code>boolean blocked[2]; int turn; void P(int id) { while(true) { blocked[id] = true; while(turn != id) { while(blocked[1-id]) /* do nothing */; turn = id; } /* critical section */ blocked[id] = false; /* remainder */ } } void main() { blocked[0] = false; blocked[1] = false; turn = 0; parbegin(P(0), P(1)); //RUN P0 and P1 parallel } </code></pre> <p>I thought that a could implement a simple Mutual - Exclution solution using the code above. But it's not working. Has anyone got an idea why?</p> <p>Any help would really be appreciated!</p>
[ { "answer_id": 411587, "author": "derobert", "author_id": 27727, "author_profile": "https://Stackoverflow.com/users/27727", "pm_score": -1, "selected": false, "text": "get blocked[0] -> false // cpu 0\nset blocked[0] = true // cpu 1 (stored in CPU 1's L1 cache)\nget blocked[0] -> f...
2009/01/04
[ "https://Stackoverflow.com/questions/411499", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43960/" ]
411,500
<p>When I implement objects that I want to compare using the <a href="https://learn.microsoft.com/en-us/dotnet/api/system.iequatable-1?view=netstandard-2.0" rel="nofollow noreferrer"><code>IEquatable&lt;T&gt;</code> interface</a>:</p> <ol> <li>Why do I have to override <code>Equals(object)</code> method if I already implemented <code>Equals(T)</code>?</li> <li>Can I use <code>==</code> and <code>!=</code> operators once I implement <code>IEquatable&lt;T&gt;</code>?</li> </ol>
[ { "answer_id": 411508, "author": "Ray Booysen", "author_id": 42124, "author_profile": "https://Stackoverflow.com/users/42124", "pm_score": 7, "selected": true, "text": "IEquatable<T> IEquatable<T> Equals(Object) GetHashCode() Equals(T) Equals(Object) Equals(Object, Object) op_Equality op...
2009/01/04
[ "https://Stackoverflow.com/questions/411500", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4653/" ]
411,515
<p>Is there an automatic way to add base classes to Linq2Sql entities?</p> <p>I know I can define a partial and implement that but there has to be an automated way, right?</p>
[ { "answer_id": 411903, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 4, "selected": true, "text": "Base Class <Database EntityBase=\"Some.NameSpace.Foo\" ... > \n <Database BaseType=\"Some.NameSpace.Bar\" ... >\n Last...
2009/01/04
[ "https://Stackoverflow.com/questions/411515", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25300/" ]
411,517
<p>I'm working on a java SE 1.5+ swing application, in conjunction with others. I'm wondering what the best way of managing string resources is. I understand the principles behind resource bundles etc. I'd like to avoid having one property file for every class that needs a string, as this seems a bit of overkill. Especially when you have a lot of classes that may only make a single reference to a string (say in an error handler). On the other hand it makes it easier when collaborating with others as you reduce the risk of merge conflicts.</p> <p>It seems particularly cumbersome to have to load resource bundles, every time you need to display simple user feedback, likewise in error handlers, when many classes are involved.</p> <p>What is the most effective way to manage strings in a fairly large application with hundreds of classes, many of which aren't GUI related, but need to pass informative messages back up to the GUI when exceptions occur.</p> <p>I'm using NetBeans which generally creates a property file for each GUI class, for all text relating to buttons, labels etc.</p>
[ { "answer_id": 411523, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 5, "selected": true, "text": "ResourceBundle.getBundle()" } ]
2009/01/04
[ "https://Stackoverflow.com/questions/411517", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3898/" ]
411,533
<p>How do I add adsense or other ads in a asp.net ajax/ajax based application ? (ex. <a href="http://ra-ajax.org/samples/Viewport-Calendar-Starter-Kit.aspx" rel="noreferrer">ra-ajax samples page</a>) or <a href="http://gwt-ext.com/demo/" rel="noreferrer">GWT</a></p> <p>Is creating an iframe a viable solution?</p> <p>As stated below, placing adsense script is easy. But the google bot wont be able to scan my ajax based page, as all of the content is javascript. There wont be contextual ads. So wont be able to monetize. It would be great for static ads. Any idea/inputs?</p>
[ { "answer_id": 2785732, "author": "noah", "author_id": 12034, "author_profile": "https://Stackoverflow.com/users/12034", "pm_score": 0, "selected": false, "text": "document.write $('#ads').writeCapture().html('<script src=\"whatever-your-adsense-code-is\"> </script>');\n" } ]
2009/01/04
[ "https://Stackoverflow.com/questions/411533", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46795/" ]
411,544
<p>I am attempting to port one of my hobby project to linux. Preferrably to Mono since it is written in C#. But I am looking into Python as well.</p> <p>One of the feature of the application is that it needs to associate with a custom protocol so the application is invoked when the user clicks links like this on the app's website:</p> <pre><code>myapp://module/action </code></pre> <p>A custom protocol like <a href="http://msdn.microsoft.com/en-us/library/aa767914.aspx" rel="nofollow noreferrer">this</a>, <a href="https://stackoverflow.com/questions/389204/how-do-i-create-my-own-url-protocol-eg-so">this</a> and <a href="https://stackoverflow.com/questions/309690/communicating-from-website-to-desktop-application-not-vice-versa">this</a>.</p> <p>How can that be done in linux/unix systems? Can I associate a system-wide handler like in Windows? or does it need to be browser-dependent?</p> <p>Can't find anything on Google. And I am utterly clueless at linux programming.</p> <p>I need some pointers. Thanks!</p>
[ { "answer_id": 411568, "author": "Cheery", "author_id": 21711, "author_profile": "https://Stackoverflow.com/users/21711", "pm_score": 2, "selected": false, "text": "open firefox\ntype in about:config to location bar\nadd new string\nname: network.protocol-handler.app.myapp\nvalue: /path...
2009/01/04
[ "https://Stackoverflow.com/questions/411544", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3055/" ]
411,553
<p>What are the various parts to an email message?</p> <p>I'm working with these 3rd party components, and so far from what I understand are:</p> <ol> <li><p>emails have unique messageID's (per server I would presume)</p></li> <li><p>emails have headers</p></li> <li><p>emails have body text that can be either html or plain text.</p></li> <li><p>attachments have to be parsed using mime, and each mime part can have different types like: multipart/ applicatoin/octet-stream and filenames.</p></li> </ol> <p>side question, where exactly is the documentation that these 3rd party components have to adhere to?</p>
[ { "answer_id": 411569, "author": "shoosh", "author_id": 9611, "author_profile": "https://Stackoverflow.com/users/9611", "pm_score": 0, "selected": false, "text": "winmail.dat" } ]
2009/01/04
[ "https://Stackoverflow.com/questions/411553", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50700/" ]
411,571
<p>I've created </p> <pre><code> DataTable dt = new DataTable(); dt.Columns.Add("Type"); dt.Columns.Add("Address1"); dt.Columns.Add("Address2"); dt.Columns.Add("PostalCode"); dt.Columns.Add("Country"); DataRow drow = dt.NewRow(); drow["Type"] = ddlAddressType.SelectedItem.ToString(); drow["Address1"] = txtAddress1.Text; drow["Address2"] = txtAddress2.Text; drow["PostalCode"] = txtPostalCode.Text; drow["Country"] = ddlCountry.SelectedItem.ToString(); dt.Rows.Add(drow); Session["Address"] = dt; </code></pre> <p>tried to add the value into a gridview using the following code:</p> <pre><code>public void populateAddressGridView() { if (Session["Address"] != null) { DataTable dt = (DataTable)Session["Address"]; if ((dt != null) &amp;&amp; (dt.Rows.Count &gt; 0)) { AddressGridView.Visible = true; AddressGridView.DataSource = dt; AddressGridView.DataBind(); } else { AddressGridView.Visible = false; } } </code></pre> <p>but the fields are empty without any value after adding a new data row. if i enable autogeneration of fields, i am able to view the generated data.</p> <p>how do i go about solving this problem?</p>
[ { "answer_id": 449254, "author": "CRice", "author_id": 55693, "author_profile": "https://Stackoverflow.com/users/55693", "pm_score": 1, "selected": false, "text": "<asp:GridView ID=\"AddressGridView\" runat=\"server\" AutoGenerateColumns=\"false\">\n<Columns>\n <asp:BoundField HeaderT...
2009/01/04
[ "https://Stackoverflow.com/questions/411571", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]