qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
203,383
<p>I get obsessed with the best names for arrays and variables that I use, I'll look up words in the thesaurus, dictionary, etc..</p> <p>So I'm trying to name this array / structure:</p> <pre><code>$nameMe = array( '392' =&gt; TRUE, '234' =&gt; TRUE, '754' =&gt; TRUE, '464' =&gt; TRUE, ); </code></pre> <p>and it's used to check if that id has a certain property, like so</p> <pre><code>if(isset($name[$id])) { doSomething(); } </code></pre> <p>Problem being I'm getting really long variable names like</p> <pre><code>$propertyNameArrayIdIndexed </code></pre> <p>Any ideas for how I can better name this particular function of array? or better names in general</p>
[ { "answer_id": 203414, "author": "Claudiu", "author_id": 15055, "author_profile": "https://Stackoverflow.com/users/15055", "pm_score": 3, "selected": true, "text": "$hasProperty[$id]\n" }, { "answer_id": 203424, "author": "nickf", "author_id": 9021, "author_profile": ...
2008/10/15
[ "https://Stackoverflow.com/questions/203383", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5261/" ]
203,384
<p>Various programs can do stuff only when you haven't used the computer for a while (eg screensaver, Google Desktop indexing, etc).</p> <p>How do they know when it has been inactive? Is there some function in Windows that tells you how long it has been inactive, or do you have to use some kind of keyboard/mouse hook to track activity yourself?</p> <p>I'm using C#, but I'm interested in any method of determining the inactivity.</p>
[ { "answer_id": 203410, "author": "Bill", "author_id": 14547, "author_profile": "https://Stackoverflow.com/users/14547", "pm_score": 0, "selected": false, "text": "using System;\nusing System.Runtime.InteropServices;\nusing System.Threading;\nusing System.Windows.Forms;\n\nnamespace Examp...
2008/10/15
[ "https://Stackoverflow.com/questions/203384", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4495/" ]
203,397
<p>Is there a way to change the context sensitive help in Visual Studio so that it will only search against the text under the caret instead of a compilation error in your code?</p> <p>More info: After you compile and receive a compilation error(underlined), placing the caret within the underlined text and pressing <kbd>F1</kbd> will take you to the Compilation error page instead of the help for the function under the caret. Can this behavior be changed to always go to the method/keyword help?</p> <p>Language: C#</p>
[ { "answer_id": 211389, "author": "Robin Bennett", "author_id": 27794, "author_profile": "https://Stackoverflow.com/users/27794", "pm_score": 3, "selected": true, "text": "int myInt = new int(3);\n" } ]
2008/10/15
[ "https://Stackoverflow.com/questions/203397", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4490/" ]
203,399
<p>I'm running a MySQL database locally for development, but deploying to Heroku which uses Postgres. Heroku handles almost everything, but my case-insensitive Like statements become case sensitive. I could use iLike statements, but my local MySQL database can't handle that.</p> <p>What is the best way to write a case insensitive query that is compatible with both MySQL and Postgres? Or do I need to write separate Like and iLike statements depending on the DB my app is talking to?</p>
[ { "answer_id": 203419, "author": "Paul Tomblin", "author_id": 3333, "author_profile": "https://Stackoverflow.com/users/3333", "pm_score": 7, "selected": true, "text": "select * from foo where upper(bar) = upper(?);\n" }, { "answer_id": 203428, "author": "Adam Pierce", "au...
2008/10/15
[ "https://Stackoverflow.com/questions/203399", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23885/" ]
203,425
<p>What's the ASP equivalent to PHP's <code>.=</code> when concatenating strings? I'm referring to asp NOT asp.net.</p> <p>I meant to specify that I'm in a for-loop. So I want to know the equivalent for <code>.=</code> (in php) not standard concatenation.</p> <p><em>Example:</em></p> <pre><code>For Each Item In Request.Form If (Item = "service") then For x=1 To Request.Form(item).Count service = "&amp;service="&amp;Request.Form(Item)(x) Next End If Next </code></pre>
[ { "answer_id": 203429, "author": "cfeduke", "author_id": 5645, "author_profile": "https://Stackoverflow.com/users/5645", "pm_score": 3, "selected": false, "text": "Variable = Variable & \"something more\"\n" } ]
2008/10/15
[ "https://Stackoverflow.com/questions/203425", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
203,446
<p>Does anyone know the format of the MAPI property <code>PR_SEARCH_KEY</code>?</p> <p>The <a href="http://msdn.microsoft.com/en-us/library/ms529414(EXCHG.10).aspx" rel="nofollow noreferrer">online documentation</a> has this to say about it:</p> <blockquote> <p>The search key is formed by concatenating the address type (in uppercase characters), the colon character ':', the e-mail address in canonical form, and the terminating null character.</p> </blockquote> <p>And the exchange document <a href="http://msdn.microsoft.com/en-us/library/cc433489(EXCHG.80).aspx" rel="nofollow noreferrer">MS-OXOABK</a> says this:</p> <blockquote> <p>The PidTagSearchKey property of type PtypBinary is a binary value formed by concatenating the ASCII string "EX: " followed by the DN for the object converted to all upper case, followed by a zero byte value.</p> </blockquote> <p>However all the MAPI messages I've seen with this property have it as some sort of binary 16 byte sequence that looks like a GUID. Does anyone else have any more information about it? Is it always 16 bytes?</p> <p>Thanks!</p>
[ { "answer_id": 206432, "author": "Henk", "author_id": 4613, "author_profile": "https://Stackoverflow.com/users/4613", "pm_score": 3, "selected": true, "text": "PR_SEARCH_KEY" } ]
2008/10/15
[ "https://Stackoverflow.com/questions/203446", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18437/" ]
203,456
<p>I can get the executable location from the process, how do I get the icon from file?</p> <p>Maybe use windows api LoadIcon(). I wonder if there is .NET way...</p>
[ { "answer_id": 203490, "author": "TheSoftwareJedi", "author_id": 18941, "author_profile": "https://Stackoverflow.com/users/18941", "pm_score": 6, "selected": true, "text": "Icon ico = Icon.ExtractAssociatedIcon(theProcess.MainModule.FileName);\n" }, { "answer_id": 203517, "au...
2008/10/15
[ "https://Stackoverflow.com/questions/203456", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44972/" ]
203,468
<p>Ok, so I'm looking for a bit of architecture guidance, my team is getting a chance to re-cast certain decisions with a new feature that we're building, and I wanted to see what SO thought :-) There are of course certain things that we're not changing, so the solution would have to fit in this model. Namely, that we've got an ASP.NET application, which uses web services to allow users to perform actions on the system.</p> <p>The problem comes in because, as with many systems, different users need access to different functions. Some roles have access to Y button, and others have access to Y and B button, while another still only has access to B. Most of the time that I see this, developers just put in a mish-mosh of if statements to deal with the UI state. My fear is that left unchecked, this will become an unmaintainable mess, because in addition to putting authorization logic in the GUI, it needs to be put in the web services (which are called via ajax) to ensure that only authorized users call certain methods.</p> <p>so my question to you is, how can a system be designed to decrease the random ad-hoc if statements here and there that check for specific roles, which could be re-used in both GUI/webform code, and web service code.</p> <p>Just for clarity, this is an ASP.NET web application, using webforms, and <a href="http://projects.nikhilk.net/ScriptSharp/" rel="nofollow noreferrer">Script#</a> for the AJAX functionality. Don't let the script# throw you off of answering, it's not fundamentally different than asp.net ajax :-)</p>
[ { "answer_id": 203490, "author": "TheSoftwareJedi", "author_id": 18941, "author_profile": "https://Stackoverflow.com/users/18941", "pm_score": 6, "selected": true, "text": "Icon ico = Icon.ExtractAssociatedIcon(theProcess.MainModule.FileName);\n" }, { "answer_id": 203517, "au...
2008/10/15
[ "https://Stackoverflow.com/questions/203468", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5416/" ]
203,469
<p>How do you use enums in Oracle using SQL only? (No PSQL)</p> <p>In MySQL you can do:</p> <pre><code>CREATE TABLE sizes ( name ENUM('small', 'medium', 'large') ); </code></pre> <p>What would be a similar way to do this in Oracle?</p>
[ { "answer_id": 203547, "author": "Justin Cave", "author_id": 10397, "author_profile": "https://Stackoverflow.com/users/10397", "pm_score": 7, "selected": true, "text": "CREATE TABLE sizes (\n name VARCHAR2(10) CHECK( name IN ('small','medium','large') )\n);\n" }, { "answer_id": ...
2008/10/15
[ "https://Stackoverflow.com/questions/203469", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15124/" ]
203,473
<p>I have a Crystal Report that looks like:</p> <p><em>Date | Person | Ticket | Summary <br> Date | Person | Ticket | Summary <br> Date | Person | Ticket | Summary</em> </p> <p>I would like it to look like: </p> <p><em>Date <br> Person | Ticket | Summary <br> Person | Ticket | Summary <br><br> Date <br> Person | Ticket | Summary</em></p> <p>All values are pulled from a MS SQL 2000 database, the application that will ultimately use the report is a VB 6 app that I unfortunately have to support. </p>
[ { "answer_id": 203547, "author": "Justin Cave", "author_id": 10397, "author_profile": "https://Stackoverflow.com/users/10397", "pm_score": 7, "selected": true, "text": "CREATE TABLE sizes (\n name VARCHAR2(10) CHECK( name IN ('small','medium','large') )\n);\n" }, { "answer_id": ...
2008/10/15
[ "https://Stackoverflow.com/questions/203473", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8900/" ]
203,475
<p>In my code, I am creating a collection of objects which will be accessed by various threads in a fashion that is only safe if the objects are immutable. When an attempt is made to insert a new object into my collection, I want to test to see if it is immutable (if not, I'll throw an exception).</p> <p>One thing I can do is to check a few well-known immutable types:</p> <pre><code>private static final Set&lt;Class&gt; knownImmutables = new HashSet&lt;Class&gt;(Arrays.asList( String.class, Byte.class, Short.class, Integer.class, Long.class, Float.class, Double.class, Boolean.class, BigInteger.class, BigDecimal.class )); ... public static boolean isImmutable(Object o) { return knownImmutables.contains(o.getClass()); } </code></pre> <p>This actually gets me 90% of the way, but sometimes my users will want to create simple immutable types of their own:</p> <pre><code>public class ImmutableRectangle { private final int width; private final int height; public ImmutableRectangle(int width, int height) { this.width = width; this.height = height; } public int getWidth() { return width; } public int getHeight() { return height; } } </code></pre> <p>Is there some way (perhaps using reflection) that I could reliably detect whether a class is immutable? False positives (thinking it's immutable when it isn't) are not acceptable but false negatives (thinking it's mutable when it isn't) are.</p> <p><strong>Edited to add:</strong> Thanks for the insightful and helpful answers. As some of the answers pointed out, I neglected to define my security objectives. The threat here is clueless developers -- this is a piece of framework code that will be used by large numbers of people who know next-to-nothing about threading and won't be reading the documentation. I do NOT need to defend against malicious developers -- anyone clever enough to <a href="http://directwebremoting.org/blog/joe/2005/05/26/1117108773674.html" rel="noreferrer">mutate a String</a> or perform other shenanigans will also be smart enough to know it's not safe in this case. Static analysis of the codebase IS an option, so long as it is automated, but code reviews cannot be counted on because there is no guarantee every review will have threading-savvy reviewers.</p>
[ { "answer_id": 203504, "author": "Jason Cohen", "author_id": 4926, "author_profile": "https://Stackoverflow.com/users/4926", "pm_score": 3, "selected": false, "text": "@Immutable" }, { "answer_id": 203506, "author": "Pablo Fernandez", "author_id": 7595, "author_profil...
2008/10/15
[ "https://Stackoverflow.com/questions/203475", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14570/" ]
203,477
<p>I'm using KML and the GGeoXml object to overlay some shapes on an embedded Google map. The placemarks in the KML file have some custom descriptive information that shows up in the balloons.</p> <pre><code>&lt;Placemark&gt; &lt;name /&gt; &lt;description&gt; &lt;![CDATA[ &lt;div class=&quot;MapPopup&quot;&gt; &lt;h6&gt;Concession&lt;/h6&gt; &lt;h4&gt;~Name~&lt;/h4&gt; &lt;p&gt;Description goes here&lt;/p&gt; &lt;a class=&quot;Button GoRight FloatRight&quot; href=&quot;#&quot;&gt;&lt;span&gt;&lt;/span&gt;View details&lt;/a&gt; &lt;/div&gt; ]]&gt; &lt;/description&gt; &lt;styleUrl&gt;#masterPolyStyle&lt;/styleUrl&gt; ...Placemarks go here ... &lt;/Placemark&gt; </code></pre> <p>So far so good - the popups show up and have the correct text in them. Here's the weird thing: I'm trying to use CSS to format what goes in the popups, and it halfway works.</p> <p>Specifically:</p> <ul> <li><p>The <code>&lt;h6&gt;</code> and <code>&lt;h4&gt;</code> elements are rendered using the colors and background images I've specified in my stylesheet.</p> </li> <li><p>Everything shows up in Arial, not in the font I've specified in my CSS.</p> </li> <li><p>The class names seem to be ignored (e.g. none of the <code>a.Button</code> formatting is applied; if I define a style like the one below, it's ignored.)</p> <pre><code> div.MapPopup { background:pink; } </code></pre> </li> </ul> <p>Any ideas? I wouldn't have been surprised for the CSS not to work at all, but it's weird that it only partly works.</p> <h3>Update</h3> <p>Here's a screenshot to better illustrate this. I've reproduced the <code>&lt;div class=&quot;MapPopup&quot;&gt;</code> markup further down on the page (in yellow), to show how it should be rendered according to my CSS.</p> <p><img src="https://farm4.static.flickr.com/3072/2942636927_2f8119a72a.jpg?v=0" alt="alt text" /></p>
[ { "answer_id": 208902, "author": "Herb Caudill", "author_id": 239663, "author_profile": "https://Stackoverflow.com/users/239663", "pm_score": 4, "selected": true, "text": "<div style=\"font-family: Arial,sans-serif; font-size: small;\">\n <div id=\"iw_kml\">\n <div>\n ...
2008/10/15
[ "https://Stackoverflow.com/questions/203477", "https://Stackoverflow.com", "https://Stackoverflow.com/users/239663/" ]
203,493
<p>I know that it <em>does</em> consider ' ' as <code>NULL</code>, but that doesn't do much to tell me <em>why</em> this is the case. As I understand the SQL specifications, ' ' is not the same as <code>NULL</code> -- one is a valid datum, and the other is indicating the absence of that same information.</p> <p>Feel free to speculate, but please indicate if that's the case. If there's anyone from Oracle who can comment on it, that'd be fantastic!</p>
[ { "answer_id": 203536, "author": "Justin Cave", "author_id": 10397, "author_profile": "https://Stackoverflow.com/users/10397", "pm_score": 9, "selected": true, "text": "VARCHAR" }, { "answer_id": 29209211, "author": "Sorter", "author_id": 1097600, "author_profile": "h...
2008/10/15
[ "https://Stackoverflow.com/questions/203493", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23309/" ]
203,495
<p>My organization is working on building RESTful webservices on JBoss appserver. The QA team is used to testing SOAP webservices so far using SoapUI. SoapUI has a new version that has REST capabilities. We're considering using that.</p> <ol> <li>Are there any publicly available RESTful services available on the net for free that someone could test ? <br> </li> <li>What tools are available(and used) for testing RESTful web services ?</li> </ol>
[ { "answer_id": 203601, "author": "S.Lott", "author_id": 10661, "author_profile": "https://Stackoverflow.com/users/10661", "pm_score": 4, "selected": false, "text": "urllib" }, { "answer_id": 12298362, "author": "Heiko Rupp", "author_id": 100957, "author_profile": "htt...
2008/10/15
[ "https://Stackoverflow.com/questions/203495", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11142/" ]
203,520
<p>I have what must be a typical catch-22 problem. I have a .NET WinForm control that contains a textbox and a checkbox. Both controls are data bound to properties on a data class instance. The textbox is for price, the check box to indicate that the price is a price override. Also on the data class is a property that holds the item's original price.</p> <p>I would like the controls to respect the following rules:</p> <ul> <li>When the user enters a value into the price textbox, the checkbox is automatically checked to indicate they are overriding the price value</li> <li>When the check box is un-checked, the item's price is restored to the original price.</li> </ul> <p>When the user unchecks the checkbox, the event handler tests the checked state, and sets the item's price property to the original price value. However, the price value being databound, a bind event is fired, which updates the textbox value, which fires the text changed event handler which re-checks the checkbox. </p> <p>I've attempted to trap the conditions where I'm explicitly updating something that would trigger a control change event. This only works for part of it though. The textbox change event fires other times that are outside my control, such as when databinding fires when the form is initially shown.</p> <p>I've been searching around and I guess I'm just not coming up with the right search terms to find what I'm looking for. It seems that databinding is all wonderful and nifty until you need to do something pratical with it, like having two bound controls interact with each other. There just doesn't seem to be a way to discriminate between what triggered the control events.</p> <p>I've also looked at the events available on the binding source component but there doesn't seem to be anything there that is any more useful. I can handle the event that fires after binding is complete, but that's after the problems occur.</p> <p>Anyone have any suggestions?</p>
[ { "answer_id": 203920, "author": "Tom Juergens", "author_id": 2899, "author_profile": "https://Stackoverflow.com/users/2899", "pm_score": 2, "selected": false, "text": "Private _dc As DataClass\n\nPrivate Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load...
2008/10/15
[ "https://Stackoverflow.com/questions/203520", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5496/" ]
203,528
<p>When I build XML up from scratch with <code>XmlDocument</code>, the <code>OuterXml</code> property already has everything nicely indented with line breaks. However, if I call <code>LoadXml</code> on some very "compressed" XML (no line breaks or indention) then the output of <code>OuterXml</code> stays that way. So ...</p> <p>What is the simplest way to get beautified XML output from an instance of <code>XmlDocument</code>?</p>
[ { "answer_id": 203533, "author": "DocMax", "author_id": 6234, "author_profile": "https://Stackoverflow.com/users/6234", "pm_score": 6, "selected": false, "text": "XmlDocument doc = new XmlDocument();\ndoc.LoadXml(\"<item><name>wrench</name></item>\");\n// Save the document to a file and ...
2008/10/15
[ "https://Stackoverflow.com/questions/203528", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9642/" ]
203,543
<p>I recently had to work on a project where the previous developer modified the wp-admin directory. It seems like a bad idea to me, since Wordpress is constantly updated. Am I just not at that level of expertise with modifying Wordpress?</p>
[ { "answer_id": 203662, "author": "joelhardi", "author_id": 11438, "author_profile": "https://Stackoverflow.com/users/11438", "pm_score": 3, "selected": false, "text": "siteurl" } ]
2008/10/15
[ "https://Stackoverflow.com/questions/203543", "https://Stackoverflow.com", "https://Stackoverflow.com/users/65465/" ]
203,548
<p>I've been getting this undefined symbol building with this command line:</p> <pre><code>$ gcc test.cpp Undefined symbols: "___gxx_personality_v0", referenced from: etc... </code></pre> <p>test.cpp is simple and should build fine. What is the deal?</p>
[ { "answer_id": 203550, "author": "ryan_s", "author_id": 13728, "author_profile": "https://Stackoverflow.com/users/13728", "pm_score": 7, "selected": true, "text": "g++ test.cpp\n" }, { "answer_id": 1626030, "author": "pseudosudo", "author_id": 196678, "author_profile"...
2008/10/15
[ "https://Stackoverflow.com/questions/203548", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13728/" ]
203,589
<p>I have an iPhone app that compiles and runs fine in the Simulator on my laptop. Now, I try to build and run the same code in the Simulator on an iMac, and it starts up and lets me click a button, but then I get an assertion failure.</p> <p>Here is what is in the console:</p> <pre><code>*** Assertion failure in -[UILabel setFont:], /SourceCache/UIKit/UIKit-738/UILabel.m:438 *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: font != nil' Stack: ( 2493366603, 2432871995, 2493366059, 2459146836, 817183141, 817926218, 837317240, 837317032, 837315376, 837314643, 2492860866, 2492867620, 2492869880, 85304, 85501, 816175835, 816221412, 9096, 8930 ) </code></pre> <p>Here's the stack trace:</p> <pre><code>#0 0x949dbff4 in ___TERMINATING_DUE_TO_UNCAUGHT_EXCEPTION___ #1 0x9102ae3b in objc_exception_throw #2 0x94962ad3 in CFRunLoopRunSpecific #3 0x94962cf8 in CFRunLoopRunInMode #4 0x00014d38 in GSEventRunModal #5 0x00014dfd in GSEventRun #6 0x30a5dadb in -[UIApplication _run] #7 0x30a68ce4 in UIApplicationMain #8 0x00002388 in main at main.m:16 </code></pre> <p>My code does not make any direct calls to setFont:. However, this would be the point in the program's execution where some buttons are made visible for the first time.</p> <p>I've Googled. A few people with similar problems say that this gets magically fixed when they edit the NIB, or change their time zone, or other weirdness.</p> <p>Any ideas what the real cause is?</p> <p>(Please no whining about NDA's.)</p> <hr> <p><strong>Update:</strong> If I change the font of some of my buttons from "TimesNewRomanPS-BoldMT" to "Times", then the assertion failure no longer occurs. But why can't I use the desired font, which exists on the iPhone, is installed on the new machine, and is selectable in Interface Builder?</p>
[ { "answer_id": 10255142, "author": "user102008", "author_id": 102008, "author_profile": "https://Stackoverflow.com/users/102008", "pm_score": 0, "selected": false, "text": "[UIFont fontWithName:fontSize:]" } ]
2008/10/15
[ "https://Stackoverflow.com/questions/203589", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1175/" ]
203,605
<p>I'm looking for a way to match only fully composed characters in a Unicode string.</p> <p>Is <code>[:print:]</code> dependent upon locale in any regular expression implementation that incorporates this character class? For example, will it match Japanese character 'あ', since it is not a control character, or is <code>[:print:]</code> always going to be ASCII codes 0x20 to 0x7E?</p> <p>Is there any character class, including Perl REs, that can be used to match anything other than a control character? If <code>[:print:]</code> includes only characters in ASCII range I would assume <code>[:cntrl:]</code> does too.</p>
[ { "answer_id": 203623, "author": "Adam Rosenfield", "author_id": 9530, "author_profile": "https://Stackoverflow.com/users/9530", "pm_score": 1, "selected": false, "text": "[^[:cntrl:]]" }, { "answer_id": 203801, "author": "Tanktalus", "author_id": 23512, "author_profi...
2008/10/15
[ "https://Stackoverflow.com/questions/203605", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10320/" ]
203,616
<p>The <a href="http://www.cplusplus.com/doc/tutorial/inheritance/" rel="noreferrer">C++ friend keyword</a> allows a <code>class A</code> to designate <code>class B</code> as its friend. This allows <code>Class B</code> to access the <code>private</code>/<code>protected</code> members of <code>class A</code>.</p> <p>I've never read anything as to why this was left out of C# (and VB.NET). Most answers to this <a href="https://stackoverflow.com/questions/17434/when-should-you-use-friend-in-c">earlier StackOverflow question</a> seem to be saying it is a useful part of C++ and there are good reasons to use it. In my experience I'd have to agree.</p> <p>Another <a href="https://stackoverflow.com/questions/200079/inheritance-trees-and-protected-constructors-in-c#200117">question</a> seems to me to be really asking how to do something similar to <code>friend</code> in a C# application. While the answers generally revolve around nested classes, it doesn't seem quite as elegant as using the <code>friend</code> keyword.</p> <p>The original <a href="https://rads.stackoverflow.com/amzn/click/com/0201633612" rel="noreferrer" rel="nofollow noreferrer">Design Patterns book</a> uses it regularly throughout its examples.</p> <p>So in summary, why is <code>friend</code> missing from C#, and what is the "best practice" way (or ways) of simulating it in C#?</p> <p>(By the way, the <code>internal</code> keyword is <em>not</em> the same thing, it allows <em>all</em> classes within the entire assembly to access <code>internal</code> members, while <code>friend</code> allows you to give a certain class <em>complete access</em> to <em>exactly one</em> other class)</p>
[ { "answer_id": 203813, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 6, "selected": false, "text": "[InternalsVisibleTo]" }, { "answer_id": 4577298, "author": "Nick Alexeev", "author_id": 279844, "...
2008/10/15
[ "https://Stackoverflow.com/questions/203616", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5023/" ]
203,618
<ul> <li>What rules do you use to name your variables?</li> <li>Where are single letter vars allowed?</li> <li>How much info do you put in the name?</li> <li>How about for example code?</li> <li>What are your preferred meaningless variable names? (after foo &amp; bar)</li> <li>Why are they spelled <a href="http://en.wikipedia.org/wiki/Foobar" rel="nofollow noreferrer">"foo" and "bar"</a> rather than <a href="http://en.wikipedia.org/wiki/FUBAR" rel="nofollow noreferrer">FUBAR</a></li> </ul>
[ { "answer_id": 203648, "author": "Tony BenBrahim", "author_id": 80075, "author_profile": "https://Stackoverflow.com/users/80075", "pm_score": 6, "selected": false, "text": "function startEditing(){\n if (user.canEdit(currentDocument)){\n editorControl.setEditMode(true);\n set...
2008/10/15
[ "https://Stackoverflow.com/questions/203618", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1343/" ]
203,620
<p>I need ideas on how to go about table layout problem. I want to set different width of the columns dependent on the picked language.</p>
[ { "answer_id": 203647, "author": "cdeszaq", "author_id": 20770, "author_profile": "https://Stackoverflow.com/users/20770", "pm_score": 2, "selected": true, "text": "<%\ndim columnWidth\nif session(\"lang\") = \"eng\" then\n columnWidth = 50\nelse\n columnWidth = 100\nend if\n%>\n\n...
2008/10/15
[ "https://Stackoverflow.com/questions/203620", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28098/" ]
203,629
<p>Has anyone used OSGi and JSF together?</p> <p>I ask because JSF uses class-loader magic to find custom components. From a tutorial (emphasis mine):</p> <blockquote> <p>This configuration file will end up being META-INF/faces-config.xml in the .jar file that represents this component. <strong>JSF will look for such a file name in each of the .jar files that are loaded at runtime</strong> (in the WEB-INF/lib directory for .war files) and use each of them in its configuration. In this way, multiple component .jar files can be combined into one web application, and all of the components described in each .jar will be available to the application.</p> </blockquote> <p>I would like to be able to have JSF custom components as OSGi bundles (i.e. custom components are in different OSGi bundles than the JSF runtime) and for JSF to be able to find these at runtime.</p> <p>Has anyone done anything similar?</p>
[ { "answer_id": 203647, "author": "cdeszaq", "author_id": 20770, "author_profile": "https://Stackoverflow.com/users/20770", "pm_score": 2, "selected": true, "text": "<%\ndim columnWidth\nif session(\"lang\") = \"eng\" then\n columnWidth = 50\nelse\n columnWidth = 100\nend if\n%>\n\n...
2008/10/15
[ "https://Stackoverflow.com/questions/203629", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1666/" ]
203,677
<p>Just got a question about generics, why doesn't this compile when using a generic List? If its not possible, anyway around it? Much appreciate any answer.</p> <pre><code>// Interface used in the ServiceAsync inteface. public interface BaseObject { public String getId(); } // Class that implements the interface public class _ModelDto implements BaseObject, IsSerializable { protected String id; public void setId(String id) { this.id = id; } public String getId() { return id; } } // Interface used in the ServiceAsync inteface. public interface MyAsync&lt;T&gt; { // Nothing here. } // Service interface use both interfaces above. public interface ServiceAsync { public void getList(MyAsync&lt;List&lt;? extends BaseObject&gt;&gt; callback); } public class MyClass { ServiceAsync service = (some implementation); MyAsync&lt;List&lt;_ModelDto&gt;&gt; callBack = new MyAsync&lt;List&lt;_ModelDto&gt;&gt;() { }; service.getList(callBack); // This does not compile, says arguments are not applicable???? } </code></pre>
[ { "answer_id": 203741, "author": "Aaron", "author_id": 3752, "author_profile": "https://Stackoverflow.com/users/3752", "pm_score": 2, "selected": false, "text": " ServiceAsync service = (some implementation);\n MyAsync<List<? extends BaseObject>> callBack = new MyAsync<List<? extends...
2008/10/15
[ "https://Stackoverflow.com/questions/203677", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28108/" ]
203,684
<p>I need to parse recipe ingredients into amount, measurement, item, and description as applicable to the line, such as 1 cup flour, the peel of 2 lemons and 1 cup packed brown sugar etc. What would be the best way of doing this? I am interested in using python for the project so I am assuming using the nltk is the best bet but I am open to other languages.</p>
[ { "answer_id": 204013, "author": "Claudiu", "author_id": 15055, "author_profile": "https://Stackoverflow.com/users/15055", "pm_score": -1, "selected": false, "text": "1 cup flour\n2 lemon peels\n1 cup packed brown sugar\n" } ]
2008/10/15
[ "https://Stackoverflow.com/questions/203684", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18926/" ]
203,695
<p>When you create an instance of a class with the <code>new</code> operator, memory gets allocated on the heap. When you create an instance of a struct with the <code>new</code> operator where does the memory get allocated, on the heap or on the stack ?</p>
[ { "answer_id": 204009, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 9, "selected": true, "text": "new" }, { "answer_id": 12329123, "author": "Sujit", "author_id": 792713, "author_profile": "https://S...
2008/10/15
[ "https://Stackoverflow.com/questions/203695", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18709/" ]
203,707
<p>The following two forms of jQuery selectors seem to do the same thing:</p> <ul> <li>$("div > ul.posts") </li> <li>$("div ul.posts")</li> </ul> <p>which is to select all the "ul" elements of class "posts" under "div" elements.</p> <p>Is there any difference?</p>
[ { "answer_id": 203710, "author": "eyelidlessness", "author_id": 17964, "author_profile": "https://Stackoverflow.com/users/17964", "pm_score": 3, "selected": false, "text": "<div>\n <blockquote>\n <ul class=\"posts\"></ul>\n </blockquote>\n</div>\n" }, { "answer_id": ...
2008/10/15
[ "https://Stackoverflow.com/questions/203707", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6225/" ]
203,739
<pre><code>&quot;foo&quot; instanceof String //=&gt; false &quot;foo&quot; instanceof Object //=&gt; false true instanceof Boolean //=&gt; false true instanceof Object //=&gt; false false instanceof Boolean //=&gt; false false instanceof Object //=&gt; false 12.21 instanceof Number //=&gt; false /foo/ instanceof RegExp //=&gt; true // the tests against Object really don't make sense </code></pre> <p>Array literals and Object literals match...</p> <pre><code>[0,1] instanceof Array //=&gt; true {0:1} instanceof Object //=&gt; true </code></pre> <p>Why don't all of them? Or, why don't they all <em>not</em>?<br /> And, what are they an instance of, then?</p> <p>It's the same in FF3, IE7, Opera, and Chrome. So, at least it's consistent.</p>
[ { "answer_id": 203757, "author": "John Millikin", "author_id": 3560, "author_profile": "https://Stackoverflow.com/users/3560", "pm_score": 10, "selected": true, "text": "var color1 = new String(\"green\");\ncolor1 instanceof String; // returns true\nvar color2 = \"coral\";\ncolor2 instan...
2008/10/15
[ "https://Stackoverflow.com/questions/203739", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15031/" ]
203,754
<p>I have a thread running in the background that is reading events from an input device in a blocking fashion, now when I exit the application I want to clean up the thread properly, but I can't just run a pthread_join() because the thread would never exit due to the blocking IO.</p> <p>How do I properly solve that situation? Should I send a pthread_kill(theard, SIGIO) or a pthread_kill(theard, SIGALRM) to break the block? Is either of that even the right signal? Or is there another way to solve this situation and let that child thread exit the blocking read?</p> <p>Currently a bit puzzled since none of my googling turned up a solution.</p> <p>This is on Linux and using pthreads.</p> <p>Edit: I played around a bit with SIGIO and SIGALRM, when I don't install a signal handler they break the blocking IO up, but give a message on the console ("I/O possible") but when I install a signal handler, to avoid that message, they no longer break the blocking IO, so the thread doesn't terminate. So I am kind of back to step one.</p>
[ { "answer_id": 203902, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": false, "text": "select()" }, { "answer_id": 204027, "author": "bog", "author_id": 20909, "author_profile": "https://Stacko...
2008/10/15
[ "https://Stackoverflow.com/questions/203754", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28113/" ]
203,771
<p>I have been using CPPUnit as a unit testing framework and am now trying to use it in an automated build and package system. However a problem holding me back is that if a crash occurs during the running of the unit tests, e.g. a null pointer dereferencing, it halts the remainder of the automation.</p> <p>Is there any way for CPPUnit to recover from the exception, record the test failure and then exist gracefully rather than terminating the unit test process? Even an approach specific to null pointer dereferencing would be useful as that makes up about 90% of the issues I have had.</p> <p>To be technology-specific, I am using makefiles on a Windows system.</p>
[ { "answer_id": 203889, "author": "philant", "author_id": 18804, "author_profile": "https://Stackoverflow.com/users/18804", "pm_score": 3, "selected": true, "text": "class TestObject : public CPPUNIT_NS::TestCase\n{\n CPPUNIT_TEST_SUITE(Test);\n CPPUNIT_TEST(testObjectIsReady);\n CPPUN...
2008/10/15
[ "https://Stackoverflow.com/questions/203771", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10247/" ]
203,787
<p>I have an object, that is facing a particular direction with (for instance) a 45 degree field of view, and a limit view range. I have done all the initial checks (Quadtree node, and distance), but now I need to check if a particular object is within that view cone, (In this case to decide only to follow that object if we can see it). </p> <p>Apart from casting a ray for each degree from <code>Direction - (FieldOfView / 2)</code> to <code>Direction + (FieldOfView / 2)</code> (I am doing that at the moment and it is horrible), what is the best way to do this visibility check?</p>
[ { "answer_id": 203802, "author": "Federico A. Ramponi", "author_id": 18770, "author_profile": "https://Stackoverflow.com/users/18770", "pm_score": 4, "selected": true, "text": "arccos(scalarProduct(viewDirection, (object - you)) / (norm(viewDirection)*norm(object - you))).\n" }, { ...
2008/10/15
[ "https://Stackoverflow.com/questions/203787", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24793/" ]
203,807
<p>I have a VB application which extracts data and creates 3 CSV files (a.csv, b.csv, c.csv). Then I use another Excel spreadsheet (import.xls) to import all the data from the above CSV files into this sheet.</p> <p>import.xls file has a macro which opens the CSV files one by one and copies the data. The problem I am facing is the dates in the CSV files are stored as mm/dd/yyyy and this is copied as is to the Excel sheet. But I want the date in dd/mm/yyy format.</p> <p>When I open any of the CSV files manually the dates are displayed in the correct format (mm/dd/yyyy). Any idea how I can solve this issue?</p>
[ { "answer_id": 203814, "author": "Mark", "author_id": 26310, "author_profile": "https://Stackoverflow.com/users/26310", "pm_score": 4, "selected": true, "text": "Format(DateText, \"dd/mm/yyyy\")\n" }, { "answer_id": 264992, "author": "Community", "author_id": -1, "aut...
2008/10/15
[ "https://Stackoverflow.com/questions/203807", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12178/" ]
203,809
<p>This might be a little hard to explain, but I will try.</p> <p>I want to display a list of categories (stored in 1 table), and number of domains associated with each category (stored in another table). </p> <p>The monkey wrench in this case is that each domain has a set of records associated with it (which are stored in a 3rd table). I only want to show the categories that have domains associated with them, and the count of domains should reflect only the domains that have records associated with them (from the 3rd table).</p> <p>My current query</p> <pre><code>SELECT r.rev_id, c.cat_id, c.cat_name, count(d.dom_id) As rev_id_count FROM reviews r INNER JOIN domains d ON r.rev_domain_from=d.dom_id INNER JOIN categories c ON d.dom_catid=c.cat_id WHERE rev_status = 1 GROUP BY cat_name ORDER BY cat_name </code></pre> <p>This selects the correct category names, but shows a false count (rev_id_count). If the category has 2 domains in it, and each domain has 2 records, it will show count of 4, when it should be 2.</p>
[ { "answer_id": 203815, "author": "AquilaX", "author_id": 17734, "author_profile": "https://Stackoverflow.com/users/17734", "pm_score": 0, "selected": false, "text": "SELECT c.name, count(d.id)\nFROM categories c\nJOIN domains d ON c.id = d.cid\nJOIN records r ON r.did = d.id\nGROUP BY c....
2008/10/15
[ "https://Stackoverflow.com/questions/203809", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
203,823
<p>One of classes in my program uses some third-party library. Library object is a private member of my class:</p> <pre><code>// My.h #include &lt;3pheader.h&gt; class My { ... private: 3pObject m_object; } </code></pre> <p>The problem with this - any other unit in my program that uses My class should be configured to include 3p headers. Moving to another kind of 3p will jeopardize the whole build... I see two ways to fix this - one is to is to make 3pObject extern and turn m_Object into a pointer, being initialized in constructor; second is to create an "interface" and "factory" classes and export them...</p> <p>Could you suggest another ways to solve that ?</p>
[ { "answer_id": 203830, "author": "1800 INFORMATION", "author_id": 3146, "author_profile": "https://Stackoverflow.com/users/3146", "pm_score": 4, "selected": true, "text": "// header\nclass My\n{\n class impl;\n std::auto_ptr<impl> _impl;\n};\n\n// cpp\n#include <3pheader.h>\nclass My::...
2008/10/15
[ "https://Stackoverflow.com/questions/203823", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18174/" ]
203,837
<p>I am trying to use a StreamReader to read a file, but it is always in use by another process so I get this error:</p> <blockquote> <p>The process cannot access the file '\arfjwknasgmed17\C$\FLAG CONDITION\CP-ARFJN-FLAG.XLS' because it is being used by another process.</p> </blockquote> <p>Is there a way I can read this without copying it? Or is that my only option?</p>
[ { "answer_id": 9123879, "author": "JST", "author_id": 1076973, "author_profile": "https://Stackoverflow.com/users/1076973", "pm_score": 2, "selected": false, "text": "FileStream fileStr = File.Open(<full file name>, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);\nfileStream = new ...
2008/10/15
[ "https://Stackoverflow.com/questions/203837", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14777/" ]
203,844
<p>I have a form with multiple fields that I'm validating (some with methods added for custom validation) with Jörn Zaeffere's excellent jQuery Validation plugin. How do you circumvent validation with specified submit controls (in other words, fire validation with some submit inputs, but do not fire validation with others)? This would be similar to ValidationGroups with standard ASP.NET validator controls.</p> <p>My situation:</p> <p>It's with ASP.NET WebForms, but you can ignore that if you wish. However, I am using the validation more as a "recommendation": in other words, when the form is submitted, validation fires but instead of a "required" message displaying, a "recommendation" shows that says something along the line of "you missed the following fields.... do you wish to proceed anyways?" At that point in the error container there's another submit button now visible that can be pressed which would ignore the validation and submit anyways. How to circumvent the forms .validate() for this button control and still post?</p> <p>The Buy and Sell a House sample at <a href="http://jquery.bassistance.de/validate/demo/multipart/" rel="noreferrer">http://jquery.bassistance.de/validate/demo/multipart/</a> allows for this in order to hit the previous links, but it does so through creating custom methods and adding it to the validator. I would prefer to not have to create custom methods duplicating functionality already in the validation plugin.</p> <p>The following is a shortened version of the immediately applicable script that I've got right now:</p> <pre><code>var container = $("#&lt;%= Form.ClientID %&gt; div.validationSuggestion"); $('#&lt;%= Form.ClientID %&gt;').validate({ errorContainer: container, errorLabelContainer: $("ul",container), rules: { &lt;%= YesNo.UniqueID %&gt;: { required: true }, &lt;%= ShortText.UniqueID %&gt;: { required: true } // etc. }, messages: { &lt;%= YesNo.UniqueID %&gt;: 'A message.', &lt;%= ShortText.UniqueID %&gt;: 'Another message.' // etc. }, highlight: function(element, errorClass) { $(element).addClass(errorClass); $(element.form).find("label[for=" + element.id + "]").addClass(errorClass); $(element.form).find("label[for=" + element.id + "]").removeClass("valid"); }, unhighlight: function(element, errorClass) { $(element).removeClass(errorClass); $(element.form).find("label[for=" + element.id + "]").removeClass(errorClass); $(element.form).find("label[for=" + element.id + "]").addClass("valid"); }, wrapper: 'li' }); </code></pre>
[ { "answer_id": 203989, "author": "redsquare", "author_id": 6440, "author_profile": "https://Stackoverflow.com/users/6440", "pm_score": 9, "selected": true, "text": "cancel" }, { "answer_id": 2879499, "author": "lepe", "author_id": 196507, "author_profile": "https://St...
2008/10/15
[ "https://Stackoverflow.com/questions/203844", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9344/" ]
203,854
<p>Example. 123456, and we want the third from the right ('4') out.</p> <p>The idea in practise is to access each digit seperately (ie. 6 5 4 3 2 1).</p> <p>C/C++/C# preferred.</p>
[ { "answer_id": 203864, "author": "SmacL", "author_id": 22564, "author_profile": "https://Stackoverflow.com/users/22564", "pm_score": -1, "selected": false, "text": "char nthDigitFromRight(int x,int n)\n{\n char str[20];\n sprintf(str,\"%020d\",x);\n return(str[19 - x]);\n}\n" ...
2008/10/15
[ "https://Stackoverflow.com/questions/203854", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24661/" ]
203,859
<p>Markdown is a great tool for formatting plain text into pretty html, but it doesn't turn plain-text links into URLs automatically. Like this one:</p> <p><a href="http://www.google.com/" rel="noreferrer">http://www.google.com/</a></p> <p>How do I get markdown to add tags to URLs when I format a block of text?</p>
[ { "answer_id": 203870, "author": "John Millikin", "author_id": 3560, "author_profile": "https://Stackoverflow.com/users/3560", "pm_score": 2, "selected": false, "text": "AutoLink" }, { "answer_id": 206486, "author": "andrewrk", "author_id": 432, "author_profile": "htt...
2008/10/15
[ "https://Stackoverflow.com/questions/203859", "https://Stackoverflow.com", "https://Stackoverflow.com/users/432/" ]
203,863
<p>I am getting this warning: "Missing XML comment for publicly visible type or member".</p> <p>How to solve this?</p>
[ { "answer_id": 203871, "author": "Matthias Meid", "author_id": 17713, "author_profile": "https://Stackoverflow.com/users/17713", "pm_score": 5, "selected": false, "text": "/// <summary>\n/// Describe your member here.\n/// </summary>\npublic string Something\n{\n get;\n set;\n}\n" ...
2008/10/15
[ "https://Stackoverflow.com/questions/203863", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
203,890
<p>How do I generate an audio sine or square wave of a given frequency?</p> <p>I am hoping to do this to calibrate equipment, so how precise would these waves be?</p>
[ { "answer_id": 203917, "author": "Mark Heath", "author_id": 7532, "author_profile": "https://Stackoverflow.com/users/7532", "pm_score": 6, "selected": true, "text": "int sampleRate = 8000;\nshort[] buffer = new short[8000];\ndouble amplitude = 0.25 * short.MaxValue;\ndouble frequency = 1...
2008/10/15
[ "https://Stackoverflow.com/questions/203890", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5302/" ]
203,911
<p>I am using Java API and XPath to parse my XML. I have XML like this:</p> <pre><code>&lt;animals&gt; &lt;dog&gt; &lt;looks&gt;dangerous &lt;/looks&gt; &lt;bites&gt; hard &lt;/bites&gt; &lt;growls&gt; yes &lt;/growls&gt; &lt;/dog&gt; &lt;cat&gt;nothing special&lt;/cat&gt; &lt;/animals&gt; </code></pre> <p>I would like an XPath condition to print </p> <pre><code>&lt;dog&gt; &lt;looks&gt;dangerous &lt;/looks&gt; &lt;bites&gt; hard &lt;/bites&gt; &lt;growls&gt; yes &lt;/growls&gt; &lt;/dog&gt; </code></pre> <p>But I am not able to now. If I use <code>/animal/dog/text()</code> it gives <code>dangerous</code>. But I guess it is used print text alone. Is there a way using XPath condition to fetch a block of XML?</p> <p><strong>EDIT</strong>:</p> <p>Thanks a lot for your responses. Appreciate your time spent on this. Is there way to do it in Java without printing the inner text? </p> <p>Here is where my XPath condition goes:</p> <pre><code>public static final String XPATH_INPUT_DATA="//text()"; </code></pre>
[ { "answer_id": 204526, "author": "bortzmeyer", "author_id": 15625, "author_profile": "https://Stackoverflow.com/users/15625", "pm_score": 1, "selected": false, "text": "% xpath -e /animals/dog animals.xml \nFound 1 nodes in animals.xml:\n-- NODE --\n<dog>\n <looks>dangerous </looks> \n...
2008/10/15
[ "https://Stackoverflow.com/questions/203911", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25458/" ]
203,912
<p>What is the difference between multiprocessor programming and multicore programming?</p> <p>Preferably show examples in python how to write a small program for multiprocessor programming &amp; multicore programming</p>
[ { "answer_id": 204150, "author": "Glyph", "author_id": 13564, "author_profile": "https://Stackoverflow.com/users/13564", "pm_score": 7, "selected": false, "text": "threading" } ]
2008/10/15
[ "https://Stackoverflow.com/questions/203912", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20211/" ]
203,918
<p>Been creating a simple program using VBA that I can use to review vocabulary in Chinese.</p> <p>I've gotten a fair bit working so far, but have run into a huge problem with inputting a macron-character such as "ā" (unicode 257). The specific application I am working on right now involves changing the contents of the text-box form so that an "a" can automatically be replaced as I type into the text box. Such a procedure itself is easy--I can get it to work with the pinyin characters "á" and "à".</p> <pre><code>Select Case testchar Case "a" Mid(strclip, markloc, 1) = "ā" End Select </code></pre> <p>The previous is an attempt at using the Mid function to replace one character in the textbox string with a pinyin character at the appropriate cue from the user.</p> <p>The hangup is I can't enter the "ā" into VBA! I've been looking around the internet but this doesn't seem like a problem to anyone else. When I am in the VBA editor and I type alt + 0257, nothing happens. I can't copy-paste from notepad either.. I'm about ready to scrap VBA and redo this application in some other language..</p> <p>Cheers</p>
[ { "answer_id": 203946, "author": "Ozgur Ozcitak", "author_id": 976, "author_profile": "https://Stackoverflow.com/users/976", "pm_score": 2, "selected": false, "text": "Mid(strclip, markloc, 1) = ChrW(257)\n" } ]
2008/10/15
[ "https://Stackoverflow.com/questions/203918", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
203,930
<p>Kinda long title, but anyways...</p> <p>I've been looking at these examples, specifically on the parts on writing and reading the size of the message to the byte streams<br> <a href="http://doc.trolltech.com/4.4/network-fortuneclient-client-cpp.html" rel="nofollow noreferrer">http://doc.trolltech.com/4.4/network-fortuneclient-client-cpp.html</a><br> <a href="http://doc.trolltech.com/4.4/network-fortuneserver-server-cpp.html" rel="nofollow noreferrer">http://doc.trolltech.com/4.4/network-fortuneserver-server-cpp.html</a></p> <p>But I can't seem to figure it out in C#.</p> <pre><code>StreamWriter writer = new StreamWriter(tcpClient.GetStream()); writer.Write(data.Length + data); </code></pre> <p>This doesn't work very well at all. Could someone give me a nudge in the right direction?</p>
[ { "answer_id": 203934, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 1, "selected": false, "text": "data.Length" }, { "answer_id": 203962, "author": "Marc Gravell", "author_id": 23354, "author_profile"...
2008/10/15
[ "https://Stackoverflow.com/questions/203930", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15067/" ]
203,969
<p>How do you get an instance of the actionscript class <code>Class</code> from an instance of that class?</p> <p>In Python, this would be <code>x.__class__</code>; in Java, <code>x.getClass();</code>.</p> <p>I'm aware that <a href="http://actionscript.org/forums/showthread.php3?t=120135#td_post_545693" rel="noreferrer">certain terrible hacks</a> exist to do this, but I'm looking for a built-in language facility, or at least a library routine built on something reliable.</p>
[ { "answer_id": 204003, "author": "fenomas", "author_id": 10651, "author_profile": "https://Stackoverflow.com/users/10651", "pm_score": 4, "selected": false, "text": "var s:Sprite = new flash.display.Sprite();\n\nvar className:String = flash.utils.getQualifiedClassName( s );\nvar myClass:...
2008/10/15
[ "https://Stackoverflow.com/questions/203969", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13564/" ]
203,984
<p>I have an <code>ArrayList&lt;String&gt;</code>, and I want to remove repeated strings from it. How can I do this?</p>
[ { "answer_id": 203992, "author": "jonathan-stafford", "author_id": 27587, "author_profile": "https://Stackoverflow.com/users/27587", "pm_score": 11, "selected": true, "text": "Collection" }, { "answer_id": 203997, "author": "Benno Richters", "author_id": 3565, "author...
2008/10/15
[ "https://Stackoverflow.com/questions/203984", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25778/" ]
203,990
<p>I'm writing a C++ client which is using libcurl for communicating with a PHP script.</p> <p>The communication should be session based, and thus the first task is to login and make the PHP script set up a session.</p> <p>I'm not used to working with sessions either from C++ or PHP. I basically know that it has to do with cookies and communicating session id.</p> <p>I can't find any example on the curl homepage which demonstrates a simple session management use case.</p> <p>I'm assuming it has something to do with one or many of the following options in curl:</p> <pre><code>CURLOPT_COOKIE CURLOPT_COOKIEFILE CURLOPT_COOKIEJAR CURLOPT_COOKIESESSION CURLOPT_COOKIELIST </code></pre> <p>But I can't really see the big picture just from the documentation of CURLOPT_COOKIESESSION for instance.</p> <p>Anybody who has done this, please share a simple piece of code which shows the concept.</p> <p>Regards</p> <p>Robert</p>
[ { "answer_id": 204357, "author": "Tometzky", "author_id": 15862, "author_profile": "https://Stackoverflow.com/users/15862", "pm_score": 1, "selected": false, "text": "#!/bin/bash\n\nPHPMYADMINURL=\"http://www.example.com/phpmyadmin/\"\n\n# Username and password, has to be URL-encoded\nMY...
2008/10/15
[ "https://Stackoverflow.com/questions/203990", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7891/" ]
204,007
<p>I get this error:-</p> <p>You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' at line 1</p> <p>whenever I tried something like this:-</p> <pre><code>mysql&gt; source /home/user1/sql/ddl.sql mysql&gt; source /home/user1/sql/insert.sql mysql&gt; source /home/user1/sql/cleanup.sql </code></pre> <p>The intresting thing is, this happen to each and every one of the sql scripts but only the first statement is corrupted. The rest of the statements in the script will run fine. I have worked around this by putting a dummy statement in every script.</p> <p>Anyone had this problem before? I am completely stumped and checking Google hadn't helped yet. Thanks in advance.</p>
[ { "answer_id": 204022, "author": "Vinko Vrsalovic", "author_id": 5190, "author_profile": "https://Stackoverflow.com/users/5190", "pm_score": 4, "selected": true, "text": ":set nobomb\n" } ]
2008/10/15
[ "https://Stackoverflow.com/questions/204007", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18500/" ]
204,010
<p>how can i figure out the last modified date of a html file im importing into my web app?</p> <p>The html file is on another server and different users can make updates, when i retrieve the page i want to be able see when it was last updated so i can label the updated date on my homepage. I</p>
[ { "answer_id": 204021, "author": "michaeljoseph", "author_id": 5549, "author_profile": "https://Stackoverflow.com/users/5549", "pm_score": 3, "selected": false, "text": "document.lastModified" }, { "answer_id": 204028, "author": "Node", "author_id": 7190, "author_prof...
2008/10/15
[ "https://Stackoverflow.com/questions/204010", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24481/" ]
204,017
<p>I have a Python script that needs to execute an external program, but for some reason fails.</p> <p>If I have the following script:</p> <pre><code>import os; os.system("C:\\Temp\\a b c\\Notepad.exe"); raw_input(); </code></pre> <p>Then it fails with the following error:</p> <blockquote> <p>'C:\Temp\a' is not recognized as an internal or external command, operable program or batch file.</p> </blockquote> <p>If I escape the program with quotes:</p> <pre><code>import os; os.system('"C:\\Temp\\a b c\\Notepad.exe"'); raw_input(); </code></pre> <p>Then it works. However, if I add a parameter, it stops working again:</p> <pre><code>import os; os.system('"C:\\Temp\\a b c\\Notepad.exe" "C:\\test.txt"'); raw_input(); </code></pre> <p>What is the right way to execute a program and wait for it to complete? I do not need to read output from it, as it is a visual program that does a job and then just exits, but I need to wait for it to complete.</p> <p>Also note, moving the program to a non-spaced path is not an option either.</p> <hr> <p>This does not work either:</p> <pre><code>import os; os.system("'C:\\Temp\\a b c\\Notepad.exe'"); raw_input(); </code></pre> <p>Note the swapped single/double quotes.</p> <p>With or without a parameter to Notepad here, it fails with the error message</p> <blockquote> <p>The filename, directory name, or volume label syntax is incorrect.</p> </blockquote>
[ { "answer_id": 204024, "author": "Matthew Scharley", "author_id": 15537, "author_profile": "https://Stackoverflow.com/users/15537", "pm_score": 2, "selected": false, "text": "import os;\nos.system(\"\\\"C:\\\\Temp\\\\a b c\\\\Notepad.exe\\\" C:\\\\test.txt\");\n" }, { "answer_id"...
2008/10/15
[ "https://Stackoverflow.com/questions/204017", "https://Stackoverflow.com", "https://Stackoverflow.com/users/267/" ]
204,025
<p>What do I have to consider <strong>in database design</strong> for a new application which should be able to support the most common relational database systems (SQL Server, MySQL, Oracle, PostgreSQL ...)?</p> <p>Is it even worth the effort? What are the pitfalls?</p>
[ { "answer_id": 68858389, "author": "Lukas Eder", "author_id": 521799, "author_profile": "https://Stackoverflow.com/users/521799", "pm_score": 1, "selected": false, "text": "FROM" } ]
2008/10/15
[ "https://Stackoverflow.com/questions/204025", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6461/" ]
204,032
<p>I've run into a problem trying to return an object that holds a collection of childobjects that again can hold a collection of grandchild objects. I get an error, 'connection forcibly closed by host'.</p> <p>Is there any way to make this work? I currently have a structure resembling this:</p> <p>pseudo code:</p> <pre><code>Person: IEnumerable&lt;Order&gt; Order: IEnumerable&lt;OrderLine&gt; </code></pre> <p>All three objects have the DataContract attribute and all public properties i want exposed (including the IEnumerable's) have the DataMember attribute.</p> <p>I have multiple OperationContract's on my service and all the methods returning a single object OR an IEnumerable of an object works perfectly. It's only when i try to nest IEnumerable that it turns bad. Also in my client service reference i picked the generic list as my collection type. I just want to emphasize, <strong>only one of my operations/methods fail with this error - the rest of them work perfectly</strong>.</p> <p>EDIT (more detailed error description):</p> <pre><code>[SocketException (0x2746): An existing connection was forcibly closed by the remote host] [IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.] [WebException: The underlying connection was closed: An unexpected error occurred on a receive.] [CommunicationException: An error occurred while receiving the HTTP response to http://myservice.mydomain.dk/MyService.svc. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details.] </code></pre> <p>I tried looking for logs but i can't find any... also i'm using a WSHttpBinding and an http endpoint.</p>
[ { "answer_id": 204126, "author": "Per Hornshøj-Schierbeck", "author_id": 11619, "author_profile": "https://Stackoverflow.com/users/11619", "pm_score": 0, "selected": false, "text": "Server Error in '/' Application.\n------------------------------------------------------------------------...
2008/10/15
[ "https://Stackoverflow.com/questions/204032", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11619/" ]
204,040
<p>REBOL has no built-in way to perform list comprehensions. However, REBOL has a powerful facility (known as <code>parse</code>) that can be used to create domain-specific languages (DSLs). I've used <code>parse</code> to create such a mini-DSL for list comprehensions. In order to interpret the expression, the block containing the comprehension is passed to a function, which for lack of a better term I've called <code>comprehend</code>.</p> <p><strong>Example:</strong></p> <pre><code>comprehend [(a * b) for a in 1x100 for b in 4x10 where (all [odd? a odd? b])] </code></pre> <p>For some reason, <code>comprehend</code> doesn't sound right to me, but something like <code>eval</code> is too general.</p> <p>I haven't found any other language that requires a keyword or function for list comprehensions. They are pure syntactic sugar wherever they exist. Unfortunately I don't have that option. So, seeing that I must have a function, what's a good, succinct, logical name for it?</p>
[ { "answer_id": 501642, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": true, "text": "select" }, { "answer_id": 501651, "author": "Logan Capaldo", "author_id": 61289, "author_profile": "https:/...
2008/10/15
[ "https://Stackoverflow.com/questions/204040", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27779/" ]
204,041
<p>In my asp.net mvc app I want to check if a certain url returns a valid response. Therefor I send the url to a method that tests the HttpWebRequest.GetResponse()</p> <p>On my dev server (vs2008) it works just fine. When deployed on production server however, it returns a Bad Request. The method is never hit and my asp.net custom error pages are not used.</p> <p>any ideas?</p>
[ { "answer_id": 204136, "author": "J c", "author_id": 25837, "author_profile": "https://Stackoverflow.com/users/25837", "pm_score": 0, "selected": false, "text": "<%@ Page Language=\"C#\" CodeFile=\"Default.aspx.cs\" Inherits=\"_Default\" ValidateRequest=\"false\" %>\n" } ]
2008/10/15
[ "https://Stackoverflow.com/questions/204041", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11333/" ]
204,050
<p>I know a role name and want to find all users in this role. How do I acheive this in SQL Server 2000 (in the SQL script, not in Management Studio or other tool)?</p>
[ { "answer_id": 204105, "author": "Tim", "author_id": 10363, "author_profile": "https://Stackoverflow.com/users/10363", "pm_score": 3, "selected": true, "text": "exec sp_helpsrvrolemember 'role'\n" }, { "answer_id": 204106, "author": "Ilya Kochetov", "author_id": 15329, ...
2008/10/15
[ "https://Stackoverflow.com/questions/204050", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23714/" ]
204,075
<p>I know many people who use computers every day, who do not know how to select multiple items in a HTML select box/list. I don't want to use this control in my pages any more:</p> <pre><code>Please pick 3 options: &lt;select name="categories" size="10" multiple="yes"&gt; </code></pre> <p>So what user-friendly alternatives do you suggest? Perhaps have 10 tickboxes...or maybe just have each option in a coloured block which changes colour when they click to choose it? This gets messier when I consider my current list of 20 options might grow to 50 eventually.</p> <p>Whatever way I pick it's gonna be a pain to validate it (using Javascript), to make sure the person picks at least 1 item and not more than 3. It's not about detecting how many options they have picked, the problem is more about how to convey this to the user in a friendly way!</p> <p><b>Edit:</b> I suppose I could use tags, like right here on stackoverflow, but I feel these are less appropriate if the users are non-technical (and half of them will be).</p>
[ { "answer_id": 204104, "author": "Aleris", "author_id": 20417, "author_profile": "https://Stackoverflow.com/users/20417", "pm_score": 4, "selected": false, "text": "<div style=\"overflow: scroll\" />\n" }, { "answer_id": 204109, "author": "Vlad Gudim", "author_id": 22088,...
2008/10/15
[ "https://Stackoverflow.com/questions/204075", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11461/" ]
204,087
<blockquote> <p>"To help protect your security, Explorer has restricted this webpage from running scripts or ActiveX controls that could access your computer"</p> </blockquote> <p>Whenever I add Flash movies or javascript code this message will show. It also shows for somebody else, so how do I get rid of this message? If I load or access some other website which cotains these features it doesn't show this message. Please tell me how to write a script so that it does not show this error.</p>
[ { "answer_id": 280326, "author": "Javier Suero Santos", "author_id": 34432, "author_profile": "https://Stackoverflow.com/users/34432", "pm_score": 0, "selected": false, "text": "<head>\n<!-- saved from url=(0021)http://www.myurl.com/ -->\n</head>\n" } ]
2008/10/15
[ "https://Stackoverflow.com/questions/204087", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
204,115
<p>So there seems to be this problem with GNU Make's $(wildcard) function keeping a directory open on Windows. See (unasnwered) post "<a href="http://www.cygwin.com/ml/cygwin/2003-06/msg01182.html" rel="nofollow noreferrer">make is holding a directory open</a>". Google does not provide much information on the topic.</p> <p>In short: the Makefile uses the $(wildcard) function at some point, and keeps a directory open, which typically prevents the "make clean" rule to do its work correctly. Re-running "make clean" a second time usually solves it.</p> <p>I'm using GNU Make version 3.81 under a standard DOS-Box. The author of the post linked to above is using Cygwin.</p> <p>Has anyone found a fix for this?</p>
[ { "answer_id": 220331, "author": "Charles Duffy", "author_id": 14122, "author_profile": "https://Stackoverflow.com/users/14122", "pm_score": 2, "selected": false, "text": "/proc/self/fd" }, { "answer_id": 388248, "author": "Carl Seleborg", "author_id": 2095, "author_p...
2008/10/15
[ "https://Stackoverflow.com/questions/204115", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2095/" ]
204,123
<p>I am cloning a hidden table row then populating it and after validation I want to show the row using a jquery effect ... say .show("slow")</p> <pre><code>var baseRow = $("#tasks tr#baseTaskLine"); var newRow = baseRow.clone(); var lastRow = $("#tasks tr[id^='TaskLine_']" + dayClass + ":last"); var newRowId; if (lastRow.length == 0) { newRowId = "TaskLine_new0"; } else { newRowId = "TaskLine_new" + lastRow[0].rowIndex; } newRow.attr("id", newRowId); : [populate new row] : if (lastRow.length == 0) { baseRow.after(newRow); } else { lastRow.after(newRow); } newRow.hide(); : : [validate via webservice call] : newRow.show("slow"); </code></pre> <p>This does show the row but it appears instantly. I have tried hiding all the <code>&lt;td&gt;</code> elements of the row then showing those and that does seem to work but some strange styles get added to each <code>&lt;td&gt;</code> which interfere with the formatting i.e. <code>style="display: block;"</code></p>
[ { "answer_id": 204142, "author": "Tamas Czinege", "author_id": 8954, "author_profile": "https://Stackoverflow.com/users/8954", "pm_score": 4, "selected": true, "text": "<table>\n<tr id=\"row1\"><td><div>Cell1:1</div></td><td><div>Cell2:1</div></td></tr>\n<tr id=\"row2\"><td><div>Cell1:2<...
2008/10/15
[ "https://Stackoverflow.com/questions/204123", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18349/" ]
204,140
<p>How can I move items from one list box control to another listbox control using JavaScript in ASP.NET?</p>
[ { "answer_id": 204161, "author": "Remy Sharp", "author_id": 22617, "author_profile": "https://Stackoverflow.com/users/22617", "pm_score": 5, "selected": false, "text": "$('#firstSelect option:selected').appendTo('#secondSelect');\n" }, { "answer_id": 204429, "author": "Tom", ...
2008/10/15
[ "https://Stackoverflow.com/questions/204140", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22162/" ]
204,169
<p>I have a very simple question. I want to test whether a particular port is currently under use or not. For this, I want to bind a TCP socket to the port, if the connection is refused means the port is in use and if not that mean the port is free.</p> <p>Can someone please tell me how can I write the TCP socket code in C? I am on a solaris platform.</p> <p>I know its very basic. But I appreciate your help. Thanks in advance.</p>
[ { "answer_id": 204236, "author": "Joel Cunningham", "author_id": 5360, "author_profile": "https://Stackoverflow.com/users/5360", "pm_score": 5, "selected": true, "text": "#include <stdio.h>\n#include <sys/socket.h>\n#include <netinet/in.h>\n\n#define PORT 12345\n\nint main()\n{\n struct...
2008/10/15
[ "https://Stackoverflow.com/questions/204169", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27778/" ]
204,170
<p>So I need to update a text field. Neither the UPDATE statement or the WRITETEXT statement work when used below</p> <pre><code>CREATE TABLE MyTable (IDField int, MyField text) INSERT INTO MyTable (IDField) SELECT 1 DECLARE @Data1 varchar(8000), @Data2 varchar(8000), @ptrval binary(16) SELECT @Data1 = REPLICATE('1',8000) SELECT @Data2 = REPLICATE('2',8000) -- this sets MyField to string of only 8000 characters UPDATE MyTable SET MyField = @Data1 + @Data2 WHERE IDField = 1 SELECT @ptrval = TEXTPTR(MyField ) FROM MyTable WHERE IDField = 1 -- this causes an error: Incorrect syntax near '+'. --WRITETEXT MyTable.MyField @ptrval @Data1 + @Data2 </code></pre> <p>How am I supposed to do this when local variables cannot be of type TEXT? (If I had SSQL Server 2005 I would use varchar(max) - but I don't)</p>
[ { "answer_id": 204255, "author": "Jim Birchall", "author_id": 989, "author_profile": "https://Stackoverflow.com/users/989", "pm_score": 4, "selected": true, "text": "WRITETEXT MyTable.MyField @ptrval @Data1 \nUPDATETEXT MyTable.MyField @ptrval 8000 NULL @Data2\n" }, { "answer_id"...
2008/10/15
[ "https://Stackoverflow.com/questions/204170", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10422/" ]
204,172
<p>How can I turn off certificate revocation for a WCF service's client? The client proxy was generated by wsdl.exe and inherits SoapHttpClientProtocol.</p>
[ { "answer_id": 204209, "author": "Kev", "author_id": 419, "author_profile": "https://Stackoverflow.com/users/419", "pm_score": 4, "selected": true, "text": "ServicePointManager.ServerCertificateValidationCallback" } ]
2008/10/15
[ "https://Stackoverflow.com/questions/204172", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19956/" ]
204,181
<p>I've got two applications I'm developing using Qt on windows. I want the user to be able to press a button in one application which makes the other application come to the foreground. (The programs communicate using QLocalSocket and named pipes.)</p> <p>Currently I'm using Qt's QWidget::activateWindow() which occasionally brings the application to the foreground, but most of the time it just highlights the program on the taskbar.</p> <p>Can someone please tell me how to do this, preferably using Qt although failing that using the WIN32 API would be fine.</p> <hr> <p>Unfortunately, I couldn't find a way to do this only with Qt. I solved it using Chris Becke's suggestion of calling SetForegroundWindow from the currently active application.</p>
[ { "answer_id": 204228, "author": "PierreBdR", "author_id": 7136, "author_profile": "https://Stackoverflow.com/users/7136", "pm_score": 2, "selected": false, "text": "QWidget::activateWindow" }, { "answer_id": 1017667, "author": "nurxb01", "author_id": 132736, "author_...
2008/10/15
[ "https://Stackoverflow.com/questions/204181", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22648/" ]
204,186
<p>In writing some test code I have found that Selector.select() can return without Selector.selectedKeys() containing any keys to process. This is happening in a tight loop when I register an accept()ed channel with</p> <pre>SelectionKey.OP_READ | SelectionKey.OP_CONNECT</pre> <p>as the operations of interest.</p> <p>According to the docs, select() should return when:</p> <p>1) There are channels that can be acted upon.</p> <p>2) You explicitly call Selector.wakeup() - no keys are selected.</p> <p>3) You explicitly Thread.interrupt() the thread doing the select() - no keys are selected.</p> <p>If I get no keys after the select() I must be in cases (2) and (3). However, my code is not calling wakeup() or interrupt() to initiate these returns.</p> <p>Any ideas as to what is causing this behaviour?</p>
[ { "answer_id": 205354, "author": "Alexander", "author_id": 16724, "author_profile": "https://Stackoverflow.com/users/16724", "pm_score": 4, "selected": true, "text": "OP_CONNECT" }, { "answer_id": 6646131, "author": "user207421", "author_id": 207421, "author_profile":...
2008/10/15
[ "https://Stackoverflow.com/questions/204186", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28164/" ]
204,194
<p>I have a JSP accessed through JBoss. It renders a list (a search result). If the response gets big, approximately larger than 200k the response is truncated. I can see how the page just ends in the middle of a tag in Firefox. IE totally freaks out an so does Fiddler. Responses smaller than 200k are no problem.</p> <p>Anyone has experienced this? I don't know where to look for the problem... any suggestions are welcome.</p>
[ { "answer_id": 204246, "author": "Victor", "author_id": 14514, "author_profile": "https://Stackoverflow.com/users/14514", "pm_score": 1, "selected": false, "text": "<%@page buffer=\"500kb\" autoFlush=\"true\" %>\n" }, { "answer_id": 20885515, "author": "Ujjwal Singh", "au...
2008/10/15
[ "https://Stackoverflow.com/questions/204194", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28180/" ]
204,208
<p>I want to detect and replace malformed UTF-8 characters with blank space using a Perl script while loading the data using SQL*Loader. How can I do this? </p>
[ { "answer_id": 205713, "author": "Constantin", "author_id": 20310, "author_profile": "https://Stackoverflow.com/users/20310", "pm_score": 2, "selected": false, "text": "import codecs\ncodecs.register_error('spacer', lambda ex: (u' ', ex.start + 1))\ns = 'spam\\xb0\\xc0eggs\\xd0bacon'.dec...
2008/10/15
[ "https://Stackoverflow.com/questions/204208", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
204,241
<p>Using <code>WritePrivateProfileString</code> and <code>GetPrivateProfileString</code> results in <code>???</code> instead of the real characters.</p>
[ { "answer_id": 204254, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 1, "selected": false, "text": "WritePrivateProfileString" }, { "answer_id": 8821555, "author": "Roger Bamforth", "author_id": 1143459, ...
2008/10/15
[ "https://Stackoverflow.com/questions/204241", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
204,256
<p>Why does a Boolean consume 4 bytes and a char 2 bytes in the .NET framework? A Boolean should take up 1bit or at least be smaller than a char.</p>
[ { "answer_id": 434182, "author": "Blaisorblade", "author_id": 53974, "author_profile": "https://Stackoverflow.com/users/53974", "pm_score": 4, "selected": false, "text": "boolean" } ]
2008/10/15
[ "https://Stackoverflow.com/questions/204256", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17211/" ]
204,282
<p>My problem is that I set some breakpoints in my code and some of them aren't working. In some places it complains about "Unresolved Breakpoint". </p> <p>Does anyone have any clue why this is happening? I am using gdb, by the way.</p> <p>EDIT: Yes, of course is compiled with debug information. It only happens at some classes or points in the code. And I am pretty sure that that part of the code is reached because I can reach it stepping</p> <p>EDIT: The solution from Richard doesn't work; thanks anyway. I am compiling in Debug, without any optimization.</p>
[ { "answer_id": 19493016, "author": "Arks", "author_id": 1582090, "author_profile": "https://Stackoverflow.com/users/1582090", "pm_score": 0, "selected": false, "text": "template <typename T>\nint doit(T a) {\n return a.do(); // <-- breakpoint here\n}\n...\nA a;\ncout << doit(a);\n" }, ...
2008/10/15
[ "https://Stackoverflow.com/questions/204282", "https://Stackoverflow.com", "https://Stackoverflow.com/users/366094/" ]
204,289
<p>Been trying to find a working implementation of a WPF listview (or listbox) where you can order items by dragging them up or down.</p> <p>I have found a few, but none really works, for example this one <a href="http://www.codeproject.com/KB/WPF/ListViewDragDropManager.aspx?msg=2765618#xx2765618xx" rel="nofollow noreferrer">http://www.codeproject.com/KB/WPF/ListViewDragDropManager.aspx?msg=2765618#xx2765618xx</a> stops working once you have list where you need to scroll down to get to the last items.</p> <p>Why is Drag&amp;Drop so hard in WPF? Does anybody know a working control?</p>
[ { "answer_id": 204462, "author": "rudigrobler", "author_id": 5147, "author_profile": "https://Stackoverflow.com/users/5147", "pm_score": 1, "selected": false, "text": "<ListBox src:DragAndDrop.DragEnabled=\"true\"/> \n" } ]
2008/10/15
[ "https://Stackoverflow.com/questions/204289", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28149/" ]
204,303
<p>I'm starting to investigate T4 for Code Generation.</p> <p>I get that you have a basic template in which you can embed little chunks of c#/vb which can perform clever stuff...</p> <pre><code>&lt;#@ template language="VB" debug="True" hostspecific="True" #&gt; &lt;#@ output extension=".vb" debug="True" hostspecific="True" #&gt; Imports System &lt;#For Each Table as String in New String(0 {"Table1","Table2"}#&gt; Public Class &lt;#=Table#&gt;DA Public Sub New &lt;#= WriteConstructorBody() #&gt; End Sub End Class &lt;#Next#&gt; &lt;#+ Public Function WriteConstructorBody() as String return "' Some comment" End function #&gt; </code></pre> <p>This is great.. However I would like to be able to write my main block thus...</p> <pre><code>&lt;#@ template language="VB" debug="True" hostspecific="True" #&gt; &lt;#@ output extension=".vb" debug="True" hostspecific="True" #&gt; Imports System &lt;# For Each BaseTableName as String in New String(){"Table1","Table2"} WriteRecDataInterface(BaseTableName) WriteRecDataClass(BaseTableName) WriteDAInterface(BaseTableName) WriteDAClass(BaseTableName) Next #&gt; </code></pre> <p>Then I would like to be able to have the WriteX methods exist in a Class Block but themselves be writable using code by example ie escaped Code blocks.</p> <p>How can I achieve this?</p>
[ { "answer_id": 204367, "author": "Enrico Campidoglio", "author_id": 26396, "author_profile": "https://Stackoverflow.com/users/26396", "pm_score": 2, "selected": true, "text": "<#@ template language=\"C#\" #>\n<# HelloWorld(); #>\n<#+\n private string _field = \"classy\";\n private ...
2008/10/15
[ "https://Stackoverflow.com/questions/204303", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11356/" ]
204,305
<p>I have an asp.net server control (with the asp: in its definition). The button has been set to do post back.</p> <p>On the server side, I have the on click event handler e.g btnSave_click()</p> <p>On the client side, I have a javascript function to be invoked on the click event e.g btnSave.Attributes.Add("onclick","javascript: return CheckIsDirty();")</p> <p>Am not sure which order these two will be executed. Because I want first on the client side to warn of any data entry fields that are not yet filled-out before actually saving any data.</p> <p>Any help?</p>
[ { "answer_id": 204325, "author": "Biri", "author_id": 968, "author_profile": "https://Stackoverflow.com/users/968", "pm_score": 3, "selected": true, "text": "close.Attributes[\"OnClick\"] = \"return confirm('Are you sure?')\";\n" }, { "answer_id": 204454, "author": "Jason Whi...
2008/10/15
[ "https://Stackoverflow.com/questions/204305", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13370/" ]
204,308
<p>I regularly want to check if an object has a member or not. An example is the creation of a singleton in a function. For that purpose, you can use <code>hasattr</code> like this:</p> <pre><code>class Foo(object): @classmethod def singleton(self): if not hasattr(self, 'instance'): self.instance = Foo() return self.instance </code></pre> <p>But you can also do this:</p> <pre><code>class Foo(object): @classmethod def singleton(self): try: return self.instance except AttributeError: self.instance = Foo() return self.instance </code></pre> <p>Is one method better of the other?</p> <p><strong>Edit:</strong> Added the <code>@classmethod</code> ... But note that the question is <em>not</em> about how to make a singleton but how to check the presence of a member in an object.</p> <p><strong>Edit:</strong> For that example, a typical usage would be:</p> <pre><code>s = Foo.singleton() </code></pre> <p>Then <code>s</code> is an object of type <code>Foo</code>, the same each time. And, typically, the method is called many times.</p>
[ { "answer_id": 204318, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 3, "selected": false, "text": "instance" }, { "answer_id": 204481, "author": "Andrea Ambu", "author_id": 21384, "author_profile": "http...
2008/10/15
[ "https://Stackoverflow.com/questions/204308", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7136/" ]
204,316
<p>According to this</p> <p><a href="http://perldoc.perl.org/UNIVERSAL.html" rel="noreferrer">http://perldoc.perl.org/UNIVERSAL.html</a></p> <p>I shouldn't use UNIVERSAL::isa() and should instead use $obj->isa() or CLASS->isa().</p> <p>This means that to find out if something is a reference in the first place and then is reference to this class I have to do</p> <pre><code>eval { $poss-&gt;isa("Class") } </code></pre> <p>and check $@ and all that gumph, or else</p> <pre><code>use Scalar::Util 'blessed'; blessed $ref &amp;&amp; $ref-&gt;isa($class); </code></pre> <p>My question is why? What's wrong with UNIVERSAL::isa called like that? It's much cleaner for things like:</p> <pre><code>my $self = shift if UNIVERSAL::isa($_[0], __PACKAGE__) </code></pre> <p>To see whether this function is being called on the object or not. And is there a nice clean alternative that doesn't get cumbersome with ampersands and potentially long lines?</p>
[ { "answer_id": 204352, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 3, "selected": false, "text": "isa" }, { "answer_id": 204355, "author": "Penfold", "author_id": 11952, "author_profile": "https://Stack...
2008/10/15
[ "https://Stackoverflow.com/questions/204316", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2386199/" ]
204,320
<p>Is there a way to declare a variable as Nullable in c#?</p> <pre><code>struct MyStruct { int _yer, _ner; public MyStruct() { _yer = Nullable&lt;int&gt;; //This does not work. _ner = 0; } } </code></pre>
[ { "answer_id": 204326, "author": "Joel Cunningham", "author_id": 5360, "author_profile": "https://Stackoverflow.com/users/5360", "pm_score": 1, "selected": false, "text": "int? yer;\n" }, { "answer_id": 204327, "author": "Kev", "author_id": 419, "author_profile": "htt...
2008/10/15
[ "https://Stackoverflow.com/questions/204320", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17211/" ]
204,334
<p><strong>What?</strong></p> <p>I have a DLGTEMPLATE loaded from a resource DLL, how can I change the strings assigned to the controls at runtime programmatically?</p> <p>I want to be able to do this before the dialog is created, such that I can tell that the strings on display came from the resource DLL, and not from calls to SetWindowText when the dialog is initialized.</p> <p>Google has found examples of creating DLGTEMPLATE in code, or twiddling simple style bits but nothing on editing the strings in memory.</p> <p><strong>How?</strong></p> <p>I am doing this by hooking the Dialog/Property Sheet creation API's. Which gives me access to the DLGTEMPLATE before the actual dialog is created and before it has a HWND. </p> <p><strong>Why?</strong></p> <p>I want to be able to do runtime localization, and localization testing. I already have this implemented for loading string (including the MFC 7.0 wrapper), menus and accelerator tables, but I am struggling to handle dialog/property sheet creation.</p> <p>Code examples would be the perfect answer, ideally a class to wrap around the DLGTEMPLATE, if I work out my own solution I will post it.</p>
[ { "answer_id": 205935, "author": "Aidan Ryan", "author_id": 1042, "author_profile": "https://Stackoverflow.com/users/1042", "pm_score": 1, "selected": false, "text": "CMyDialog::OnInitDialog()\n{\n ::EnumChildWindows(\n this->GetSafeHwnd(),\n CMyDialog::UpdateControlText...
2008/10/15
[ "https://Stackoverflow.com/questions/204334", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2387/" ]
204,343
<p>In .net, is there a way using reflection to determine if a parameter on a method is marked with the "params" keyword?</p>
[ { "answer_id": 204377, "author": "Nathan Baulch", "author_id": 8799, "author_profile": "https://Stackoverflow.com/users/8799", "pm_score": 5, "selected": false, "text": "ParamArrayAttribute" } ]
2008/10/15
[ "https://Stackoverflow.com/questions/204343", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13943/" ]
204,360
<p>What's the term for this design?</p> <pre><code>object.method1().method2().method3() </code></pre> <p>..when all methods return *this?</p> <p>I found the term for this a while ago, but lost it meanwhile. I have no clue how to search for this on google :) Also if anyone can think of a better title for the question, feel free to change it.</p> <p>Thanks</p> <p><strong>Update-Gishu</strong>: After reading about it, I feel that your question is misleading w.r.t. code snippet provided.. (Feel free to rollback)</p> <p><em>Method Chaining</em></p> <pre><code>object.method1().method2().method3() </code></pre> <p><em>Fluent Interfaces</em></p> <pre><code>private void makeFluent(Customer customer) { customer.newOrder() .with(6, "TAL") .with(5, "HPK").skippable() .with(3, "LGV") .priorityRush(); } </code></pre>
[ { "answer_id": 28081241, "author": "Barry", "author_id": 2069064, "author_profile": "https://Stackoverflow.com/users/2069064", "pm_score": 2, "selected": false, "text": "vector<int> v; \nv += 1,2,3,4,5,6,7,8,9;\n\ntypedef pair< string,string > str_pair;\ndeque<str_pair> deq;\npush_front(...
2008/10/15
[ "https://Stackoverflow.com/questions/204360", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21240/" ]
204,363
<p>Is it possible to create a simple 3D model (for example in 3DS MAX) and then import it to Android?</p>
[ { "answer_id": 741926, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 4, "selected": false, "text": "gl.glFrontFace(GL10.GL_CCW);\n" }, { "answer_id": 742087, "author": "Maciej Gryka", "author_id": 3037, "au...
2008/10/15
[ "https://Stackoverflow.com/questions/204363", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3037/" ]
204,369
<p>Recently our company has started measuring the cyclomatic complexity (CC) of the functions in our code on a weekly basis, and reporting which functions have improved or worsened. So we have started paying a lot more attention to the CC of functions.</p> <p>I've read that CC could be informally calculated as 1 + the number of decision points in a function (e.g. if statement, for loop, select etc), or also the number of paths through a function...</p> <p>I understand that the easiest way of reducing CC is to use the Extract Method refactoring repeatedly...</p> <p>There are somethings I am unsure about, e.g. what is the CC of the following code fragments?</p> <p>1)</p> <pre><code>for (int i = 0; i &lt; 3; i++) Console.WriteLine("Hello"); </code></pre> <p>And</p> <pre><code>Console.WriteLine("Hello"); Console.WriteLine("Hello"); Console.WriteLine("Hello"); </code></pre> <p>They both do the same thing, but does the first version have a higher CC because of the for statement?</p> <p>2)</p> <pre><code>if (condition1) if (condition2) if (condition 3) Console.WriteLine("wibble"); </code></pre> <p>And</p> <pre><code>if (condition1 &amp;&amp; condition2 &amp;&amp; condition3) Console.WriteLine("wibble"); </code></pre> <p>Assuming the language does short-circuit evaluation, such as C#, then these two code fragments have the same effect... but is the CC of the first fragment higher because it has 3 decision points/if statements?</p> <p>3)</p> <pre><code>if (condition1) { Console.WriteLine("one"); if (condition2) Console.WriteLine("one and two"); } </code></pre> <p>And</p> <pre><code>if (condition3) Console.WriteLine("fizz"); if (condition4) Console.WriteLine("buzz"); </code></pre> <p>These two code fragments do different things, but do they have the same CC? Or does the nested if statement in the first fragment have a higher CC? i.e. nested if statements are mentally more complex to understand, but is that reflected in the CC?</p>
[ { "answer_id": 204415, "author": "PW.", "author_id": 927, "author_profile": "https://Stackoverflow.com/users/927", "pm_score": 0, "selected": false, "text": "if (condition1 && condition2 && condition3)\n Console.WriteLine(\"wibble\");\n" } ]
2008/10/15
[ "https://Stackoverflow.com/questions/204369", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7261/" ]
204,396
<p>When returning objects from a class, when is the right time to release the memory?</p> <p>Example,</p> <pre><code>class AnimalLister { public: Animal* getNewAnimal() { Animal* animal1 = new Animal(); return animal1; } } </code></pre> <p>If i create an instance of Animal Lister and get Animal reference from it, then where am i supposed to delete it?</p> <pre><code>int main() { AnimalLister al; Animal *a1, *a2; a1 = al.getNewAnimal(); a2 = al.getNewAnimal(); } </code></pre> <p>The problem here is AnimalLister doesnot have a way to track the list of Animals Created, so how do i change the logic of such code to have a way to delete the objects created.</p>
[ { "answer_id": 204408, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 5, "selected": false, "text": "std::tr1::shared_ptr" }, { "answer_id": 204410, "author": "Igor Semenov", "author_id": 11401, "author_pr...
2008/10/15
[ "https://Stackoverflow.com/questions/204396", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28202/" ]
204,398
<p>Let's have the following class hierarchy:</p> <pre><code>public class ParentClass implements SomeInterface { } public class ChildClass extends ParentClass { } </code></pre> <p>Then let's have these two instances:</p> <pre><code>ParentClass parent; ChildClass child; </code></pre> <p>Then we have the following TRUE statements</p> <pre><code>(parent instanceof SomeInterface) == true (child instanceof SomeInterface) == true </code></pre> <p>Is it possible to unimplement the SomeInterface in the ChildClass, so when we check with the instanceof operator it returns false?</p> <p>If not possible, is there a workaround?</p>
[ { "answer_id": 204418, "author": "user28205", "author_id": 28205, "author_profile": "https://Stackoverflow.com/users/28205", "pm_score": 5, "selected": true, "text": "interface SomeInterface {}\nabstract class AbstractParentClass {}\nclass ParentClass extends AbstractParentClass implemen...
2008/10/15
[ "https://Stackoverflow.com/questions/204398", "https://Stackoverflow.com", "https://Stackoverflow.com/users/446104/" ]
204,406
<p>I am trying to convert all DateTime values in a DataTable to strings. Here is the method I use:</p> <pre><code>private static void ConvertDateTimesToStrings(DataTable dataTable) { if (dataTable == null) { return; } for (int rowIndex = 0; rowIndex &lt; dataTable.Rows.Count; rowIndex++ ) { for (int i = 0; i &lt; dataTable.Columns.Count; i++) { DateTime dateTime; try { dateTime = (DateTime)dataTable.Rows[rowIndex][i]; } catch (InvalidCastException) { continue; } dataTable.Rows[rowIndex][i] = dateTime.ToString("dd.MM.yyyy hh:mm:ss"); } } } </code></pre> <p>After this line works:</p> <pre><code>dataTable.Rows[rowIndex][i] = dateTime.ToString("dd.MM.yyyy hh:mm:ss"); </code></pre> <p>I check the value of dataTable.Rows[rowIndex][i] and see it is still a DateTime, not a string. Why does this happen and how can I solve this?</p> <p>Edit: I am trying to do this because I am fighting an api and unfortunately I do not have the choice of which component to use.</p>
[ { "answer_id": 204419, "author": "Biri", "author_id": 968, "author_profile": "https://Stackoverflow.com/users/968", "pm_score": 4, "selected": false, "text": "if (dataTable.Columns[0].DataType == typeof(DateTime))\n{\n}\n" }, { "answer_id": 204507, "author": "Eduardo Campañó"...
2008/10/15
[ "https://Stackoverflow.com/questions/204406", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31505/" ]
204,444
<p>As can be seen in the Mozilla changlog for JavaScript 1.7 they have added destructuring assignment. Sadly I'm not very fond of the syntax (why write a and b twice?):</p> <pre><code>var a, b; [a, b] = f(); </code></pre> <p>Something like this would have been a lot better:</p> <pre><code>var [a, b] = f(); </code></pre> <p>That would still be backwards compatible. Python-like destructuring would not be backwards compatible.</p> <p>Anyway the best solution for JavaScript 1.5 that I have been able to come up with is:</p> <pre><code>function assign(array, map) { var o = Object(); var i = 0; $.each(map, function(e, _) { o[e] = array[i++]; }); return o; } </code></pre> <p>Which works like:</p> <pre><code>var array = [1,2]; var _ = assign[array, { var1: null, var2: null }); _.var1; // prints 1 _.var2; // prints 2 </code></pre> <p>But this really sucks because _ has no meaning. It's just an empty shell to store the names. But sadly it's needed because JavaScript doesn't have pointers. On the plus side you can assign default values in the case the values are not matched. Also note that this solution doesn't try to slice the array. So you can't do something like <code>{first: 0, rest: 0}</code>. But that could easily be done, if one wanted that behavior.</p> <p>What is a better solution?</p>
[ { "answer_id": 205254, "author": "Ates Goral", "author_id": 23501, "author_profile": "https://Stackoverflow.com/users/23501", "pm_score": 2, "selected": false, "text": "window[\"foo\"] = \"bar\";\nalert(foo); // Gives \"bar\"\n" }, { "answer_id": 206566, "author": "Shog9", ...
2008/10/15
[ "https://Stackoverflow.com/questions/204444", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13995/" ]
204,461
<p>Suppose you have:</p> <pre><code>A-B-C </code></pre> <p>Now your build/test fails. The fix should be merged in A. My current work-flow is like this:</p> <pre><code>$ git commit -m "fixA" A-B-C-fixA $ git rebase -i A~1 </code></pre> <p>And squash fixA in A, result in: </p> <pre><code>A'-B-C </code></pre> <p>Is there a command to do something like:</p> <pre><code>A-B-C + (index with fix for A) $ git commit -supperdupper A </code></pre> <p>Result:</p> <pre><code>A'-B-C </code></pre>
[ { "answer_id": 4607280, "author": "Jo Liss", "author_id": 525872, "author_profile": "https://Stackoverflow.com/users/525872", "pm_score": 5, "selected": true, "text": "--autosquash" }, { "answer_id": 5538884, "author": "lanoxx", "author_id": 474034, "author_profile": ...
2008/10/15
[ "https://Stackoverflow.com/questions/204461", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1277510/" ]
204,465
<p>I'm planning to develop an app for the iPhone and that app would have to access a couple of SOAP services. While doing some basic checking in the iPhone SDK I was not able to find any support for accessing SOAP services, a bit of Googling lead to the conclusion that there is no support for SOAP in the iPhone SDK. </p> <p>So if I do want to build that app I'll need to come up with a approach to access SOAP services from the iPhone. What would be the best approach? Any best practices? Did someone already write a library using the functionality that is present in the iPhone SDK to access SOAP services?</p> <p>(Since the service I need to access is exposed by another party and they only expose it as SOAP, it's unfortunately not an option to switch to another type of interface (e.g. REST based API).</p> <p>Gero</p>
[ { "answer_id": 14586865, "author": "Bennya", "author_id": 1569335, "author_profile": "https://Stackoverflow.com/users/1569335", "pm_score": 2, "selected": false, "text": "SampleServiceProxy *proxy = [[SampleServiceProxy alloc]initWithUrl:@\"YOUR\n URL\" AndDelegate:self];\n\n[prox...
2008/10/15
[ "https://Stackoverflow.com/questions/204465", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25277/" ]
204,467
<p>I have trouble using Perl grep() with a string that <em>may</em> contain chars that are interpreted as regular expressions quantifiers. </p> <p>I got the following error when the grep pattern is "g++" because the '+' symbols are interpreted as quantifiers. Here is the output of for program that follows:</p> <pre><code>1..3 ok 1 - grep, pattern not found ok 2 - grep, pattern found Nested quantifiers in regex; marked by &lt;-- HERE in m/g++ &lt;-- HERE / at escape_regexp_quantifier.pl line 8. </code></pre> <p>Is there a modifier I could use to indicate to grep that the quantifiers shall be ignored, or is there a function that would escape the quantifiers ?</p> <pre><code>#! /usr/bin/perl sub test_grep($) { my $filter = shift; my @output = ("-r-xr-xr-x 3 root bin 122260 Jan 23 2005 gcc", "-r-xr-xr-x 4 root bin 124844 Jan 23 2005 g++"); return grep (!/$filter/, @output); } use Test::Simple tests =&gt; 2; ok(test_grep("foo"), "grep, pattern not found"); ok(test_grep("gcc"), "grep, pattern found"); ok(test_grep("g++"), "grep, pattern found"); </code></pre> <p>PS: in addition to the answer question above, I welcome any feedback on Perl usage in the above as I'm still learning. Thanks</p>
[ { "answer_id": 204474, "author": "Adam Bellaire", "author_id": 21632, "author_profile": "https://Stackoverflow.com/users/21632", "pm_score": 6, "selected": true, "text": "\\Q" }, { "answer_id": 204943, "author": "pjf", "author_id": 19422, "author_profile": "https://St...
2008/10/15
[ "https://Stackoverflow.com/questions/204467", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18804/" ]
204,468
<p>So I have the following:</p> <pre><code>public class Singleton { private Singleton(){} public static readonly Singleton instance = new Singleton(); public string DoSomething(){ ... } public string DoSomethingElse(){ ... } } </code></pre> <p>Using reflection how can I invoke the DoSomething Method? </p> <p>Reason I ask is because I store the method names in XML and dynamically create the UI. For example I'm dynamically creating a button and telling it what method to call via reflection when the button is clicked. In some cases it would be DoSomething or in others it would be DoSomethingElse.</p>
[ { "answer_id": 204508, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 5, "selected": true, "text": "string methodName = \"DoSomething\"; // e.g. read from XML\nMethodInfo method = typeof(Singleton).GetMethod(methodName);\...
2008/10/15
[ "https://Stackoverflow.com/questions/204468", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6204/" ]
204,476
<p>What is the correct (most efficient) way to define the <code>main()</code> function in C and C++ — <code>int main()</code> or <code>void main()</code> — and why? And how about the arguments? If <code>int main()</code> then <code>return 1</code> or <code>return 0</code>?</p> <hr> <p><em>There are numerous duplicates of this question, including:</em></p> <ul> <li><a href="https://stackoverflow.com/questions/2108192/what-are-the-valid-signatures-for-cs-main-function/">What are the valid signatures for C's <code>main()</code> function?</a></li> <li><a href="https://stackoverflow.com/questions/17715008/the-return-type-of-main-function/">The return type of <code>main()</code> function</a></li> <li><a href="https://stackoverflow.com/questions/636829/difference-between-void-main-and-int-main">Difference between <code>void main()</code> and <code>int main()</code>?</a></li> <li><a href="https://stackoverflow.com/questions/1621574/mains-signature-in-c"><code>main()</code>'s signature in C++</a></li> <li><a href="https://stackoverflow.com/questions/4207134/what-is-the-proper-declaration-of-main">What is the proper declaration of <code>main()</code>?</a> — For C++, with a very good answer indeed.</li> <li><a href="https://stackoverflow.com/questions/8692120/styles-of-main-functions-in-c">Styles of <code>main()</code> functions in C</a></li> <li><a href="https://stackoverflow.com/questions/10915713/return-type-of-main-method-in-c">Return type of <code>main()</code> method in C</a></li> <li><a href="https://stackoverflow.com/questions/9356510/int-main-vs-void-main-in-c"><code>int main()</code> vs <code>void main()</code> in C</a></li> </ul> <p>Related:</p> <ul> <li><a href="https://stackoverflow.com/questions/5191965/c-int-mainint-argc-char-argv">C++ — <code>int main(int argc, char **argv)</code></a></li> <li><a href="https://stackoverflow.com/questions/5217395/c-int-mainint-argc-char-argv">C++ — <code>int main(int argc, char *argv[])</code></a></li> <li><a href="https://stackoverflow.com/questions/10321435/is-char-envp-as-a-third-argument-to-main-portable">Is <code>char *envp[]</code> as a third argument to <code>main()</code> portable?</a></li> <li><a href="https://stackoverflow.com/questions/18402853/must-the-int-main-function-return-a-value-in-all-compilers">Must the <code>int main()</code> function return a value in all compilers?</a></li> <li><a href="https://stackoverflow.com/questions/5296163/why-is-the-type-of-the-main-function-in-c-and-c-left-to-the-user-to-define">Why is the type of the <code>main()</code> function in C and C++ left to the user to define?</a></li> <li><a href="https://stackoverflow.com/questions/22239/why-does-int-main-compile">Why does <code>int main(){}</code> compile?</a></li> <li><a href="https://stackoverflow.com/questions/26470912/legal-definitions-of-main-in-c14">Legal definitions of <code>main()</code> in C++14?</a></li> </ul>
[ { "answer_id": 204483, "author": "workmad3", "author_id": 16035, "author_profile": "https://Stackoverflow.com/users/16035", "pm_score": 10, "selected": true, "text": "main" }, { "answer_id": 204530, "author": "dmityugov", "author_id": 3232, "author_profile": "https://...
2008/10/15
[ "https://Stackoverflow.com/questions/204476", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25632/" ]
204,488
<p>I am trying to create a new contact using Dynamic Entity. The sample i found in CRM SDK had this code.</p> <pre><code>// Set the properties of the contact using property objects. StringProperty firstname = new StringProperty(); firstname.Name = "firstname"; firstname.Value = "Jesper"; StringProperty lastname = new StringProperty(); lastname.Name = "lastname"; lastname.Value = "Aaberg"; // Create the DynamicEntity object. DynamicEntity contactEntity = new DynamicEntity(); // Set the name of the entity type. contactEntity.Name = EntityName.contact.ToString(); // Set the properties of the contact. contactEntity.Properties = new Property[] {firstname, lastname}; </code></pre> <p>In my code i have the following implementation.</p> <pre><code> StringProperty sp_Field1 = new StringProperty("Field1","Value1"); StringProperty sp_Field2 = new StringProperty("Field2","Value1"); CrmService service = new CrmService(); service.Credentials = System.Net.CredentialCache.DefaultCredentials; // Create the DynamicEntity object. DynamicEntity contactEntity = new DynamicEntity(); // Set the name of the entity type. contactEntity.Name = EntityName.contact.ToString(); // Set the properties of the contact. contactEntity.Properties = new Property[] {sp_Field1,sp_Field2}; </code></pre> <p>I don't see much differences in the code. In the examples i found in the internet i have the same implementation as i found in SDK. But if i run the same i get the following error</p> <blockquote> <p>CS0029: Cannot implicitly convert type 'Microsoft.Crm.Sdk.StringProperty' to 'Microsoft.Crm.Sdk.PropertyCollection'</p> </blockquote> <p>I tried created a new variable of type PropertyCollection(one that belongs in mscrm namespace) and added the stringpropertys into that and passed it to the entity. </p> <pre><code>Microsoft.Crm.Sdk.PropertyCollection propTest = new Microsoft.Crm.Sdk.PropertyCollection(); propTest.Add(sp_SSNNo); propTest.Add(sp_FirstName); contactEntity.Properties = new Property[] {propTest}; </code></pre> <p>This gave me the following error</p> <blockquote> <p>CS0029: Cannot implicitly convert type 'Microsoft.Crm.Sdk.PropertyCollection' to 'Microsoft.Crm.Sdk.Property'</p> </blockquote> <p>I am sure its a minor typecasting error but i am not able to figure out where the error is. And moreover, even if it was a typecasting error why is it working for all the samples given in the internet and not for me. I tried getting the code sample to run but i am encountering the same conversion error. Please let me know if you need more info on this, any help on this would be appreciated.</p>
[ { "answer_id": 204985, "author": "SaaS Developer", "author_id": 7215, "author_profile": "https://Stackoverflow.com/users/7215", "pm_score": 3, "selected": true, "text": " StringProperty sp_Field1 = new StringProperty(\"Field1\",\"Value1\");\n StringProperty sp_Field2 = new StringPr...
2008/10/15
[ "https://Stackoverflow.com/questions/204488", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2245/" ]
204,505
<p>I use LINQ to Objects instructions on an ordered array. Which operations shouldn't I do to be sure the order of the array is not changed?</p>
[ { "answer_id": 204516, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 3, "selected": false, "text": "Dictionary<,>" }, { "answer_id": 204777, "author": "Amy B", "author_id": 8155, "author_profile": ...
2008/10/15
[ "https://Stackoverflow.com/questions/204505", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28216/" ]
204,519
<p>I've got nutch and lucene setup to crawl and index some sites and I'd like to use a .net website instead of the JSP site that comes with nutch.</p> <p>Can anyone recommend some solutions?</p> <p>I've seen solutions where there was an app running on the index server which the .Net site used remoting to connect to.</p> <p>Speed is a consideration obviously so can this still perform well?</p> <p><strong>Edit:</strong> could NHibernate.Search work for this?</p> <p><strong>Edit:</strong> We ended up going with Solr index servers being used by our ASP.net site with the <a href="http://code.google.com/p/solrnet/" rel="nofollow noreferrer">solrnet</a> library.</p>
[ { "answer_id": 582489, "author": "Sam", "author_id": 37379, "author_profile": "https://Stackoverflow.com/users/37379", "pm_score": 1, "selected": false, "text": "private void Form1_Load(object sender, EventArgs e)\n {\n searchurl.Text = \"http://localhost:8080/opensearc...
2008/10/15
[ "https://Stackoverflow.com/questions/204519", "https://Stackoverflow.com", "https://Stackoverflow.com/users/253/" ]
204,538
<p>I am having a listbox in ASP.net. I am populating the listbox values from another listbox in a page dynamically. During postbacks the values of output listbox are not persisted. (while going to another page and come back to this page).</p> <p>Please suggest some good answer. EnableViewstate = "true" is not working.</p>
[ { "answer_id": 204551, "author": "Lou Franco", "author_id": 3937, "author_profile": "https://Stackoverflow.com/users/3937", "pm_score": 3, "selected": true, "text": "if(!IsPostBack) {}\n" }, { "answer_id": 204577, "author": "thmsn", "author_id": 28145, "author_profile...
2008/10/15
[ "https://Stackoverflow.com/questions/204538", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22162/" ]
204,548
<p>How to change overview rule <strong>background</strong> color in Eclipse 3.4.0.I20080617-2000 (vertical bar on right of editing window with some annotations) ? </p> <p>General > Editors > Text Editors > Annotations allows only to change colors of marks itself not background of whole bar.</p> <p>It looks like my web searching skills are getting weaker since I cannot find it anywhere ... </p>
[ { "answer_id": 6994150, "author": "Rachel K. Westmacott", "author_id": 846145, "author_profile": "https://Stackoverflow.com/users/846145", "pm_score": 1, "selected": false, "text": "(Window -> Preferences -> General -> Editors -> Text Editors -> Background color => BLACK" }, { "a...
2008/10/15
[ "https://Stackoverflow.com/questions/204548", "https://Stackoverflow.com", "https://Stackoverflow.com/users/501/" ]
204,549
<p>I need to insert some data into a table in Oracle. </p> <p>The only problem is one of the fields is a timestamp(6) type and it is required data. I don't care about what actually goes in here I just need to get the right syntax for an entry so that the database will accept it.</p> <p>I'm using the gui web client to enter data however I don't mind using raw SQL if I have to.</p> <p>Thanks.</p>
[ { "answer_id": 204620, "author": "Mike Woodhouse", "author_id": 1060, "author_profile": "https://Stackoverflow.com/users/1060", "pm_score": 4, "selected": false, "text": "create table x ( a timestamp(6));\ninsert into x values ( current_timestamp );\nselect * from x;\n" }, { "ans...
2008/10/15
[ "https://Stackoverflow.com/questions/204549", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22061/" ]
204,553
<p>im using httpclient and last-modified header in order to retrieve the last updated date of an html file however when i try this on a linux box it returns yesterdays date but when i use a windows machine it returns todays date. is anyone aware of issues using this header field in linux?</p>
[ { "answer_id": 205456, "author": "Mihai Limbășan", "author_id": 14444, "author_profile": "https://Stackoverflow.com/users/14444", "pm_score": 0, "selected": false, "text": "date" } ]
2008/10/15
[ "https://Stackoverflow.com/questions/204553", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24481/" ]
204,557
<p>I'm working on scripts that apply database schema updates. I've setup all my SQL update scripts using start transaction/commit. I pass these scripts to psql on the command line.</p> <p>I now need to apply multiple scripts at the same time, and in one transaction. So far the only solution I've come up with is to remove the start transaction/commit from the original set of scripts, then jam them together inside a new start transaction/commit block. I'm writing perl scripts to do this on the fly.</p> <p>Effectively I want nested transactions, which I can't figure out how to do in postgresql. </p> <p>Is there any way to do or simulate nested transactions for this purpose? I have things setup to automatically bail out on any error, so I don't need to continue in the top level transaction if any of the lower ones fail.</p>
[ { "answer_id": 204592, "author": "MysticSlayer", "author_id": 28139, "author_profile": "https://Stackoverflow.com/users/28139", "pm_score": 4, "selected": true, "text": "CREATE TABLE t1 (a integer PRIMARY KEY);\n\nCREATE FUNCTION test_exception() RETURNS boolean LANGUAGE plpgsql AS\n$$BE...
2008/10/15
[ "https://Stackoverflow.com/questions/204557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5801/" ]
204,564
<p>Is there any way to get the custom attributes of a specific object I am receiving in a method?</p> <p>I do not want nor can to iterate over Type.GetMembers() and search for my member. I have the object, which is also a member, that has the attribute.</p> <p>How do I get the attribute?</p> <pre><code>class Custom { [Availability] private object MyObject = "Hello"; private void Do(object o) { //does object 'o' has any custom attributes of type 'Availability'? } //somewhere I make the call: Do(MyObject) } </code></pre>
[ { "answer_id": 204573, "author": "leppie", "author_id": 15541, "author_profile": "https://Stackoverflow.com/users/15541", "pm_score": 1, "selected": false, "text": "abstract MyBase\n{\n public string Name;\n protected MyBase()\n {\n //look up value of Name attribute and assign to N...
2008/10/15
[ "https://Stackoverflow.com/questions/204564", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2130892/" ]