qid
int64
4
19.1M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
371,808
<p>I'm on a project doing an iPhone application. We had a Cocoa consultant come in for a few weeks. He showed me an interesting idiom of Cocoa, dealing with interfaces, but there was a difficult language barrier between us, and he wasn't really able to explain <em>why</em> this was done or where it was documented so I could learn more on my own. I went into monkey see mode, and just used the style he prefers. But it's been bugging the hell out of me that I don't know more about the history of this style. It's certainly NOT an informal protocol. Sure enough, looking at <em>some</em> of the Cocoa API headers, I sometimes see the style he asserted was the 'Cocoa' way. Here's an example (note accessors, mutators, etc., each have their own interface declaration without the funny braces):</p> <pre><code>@interface AViewController : UIViewController &lt;UITextViewDelegate&gt; { @public UITableView *tableView; @private NSUInteger someIndex; } @property (nonatomic, retain) ... @end @interface AViewController (AViewControllerCreation) - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil withController:(id)controller; @end @interface AViewController (AViewControllerMutator) - (void) doSomeSettingStuff; @end @interface AViewController (AViewControllerAccessor) - (NSString *)doSomeAccessorStuff; @end @interface AViewController (AViewControllerAction) - (IBAction)cancel:(id)sender; @end @interface AViewController (AViewControllerTableViewDelegate) &lt;UITableViewDelegate, UITableViewDataSource&gt; @end </code></pre> <p>You can see this style of setting up the interface in NSButton, NSControl, etc. Interestingly, corresponding classes like UIButton, UIControl DON'T use this idiom. Hmm, these probably came after as I assume UIKit was done after AppKit. So is this idiom 'old hat'? Also, is there any reason for it other then style? Is it good style? Bad? Any docs that go over this? Thanks all.</p>
[ { "answer_id": 372021, "author": "Marc Charbonneau", "author_id": 35136, "author_profile": "https://Stackoverflow.com/users/35136", "pm_score": 2, "selected": false, "text": "#pragma mark <label> #pragma mark API #pragma mark NSWindowController Overrides #pragma mark NSObject Overrides #...
2008/12/16
[ "https://Stackoverflow.com/questions/371808", "https://Stackoverflow.com", "https://Stackoverflow.com/users/386102/" ]
371,816
<p>Does anyone know how to clear the filter drop down (combo) contents in Wireshark? Are the contents stored in a file somewhere?</p> <p>For the life of me, I can't figure this out. And, the Wireshark help file only tells me "The entries in the pull down list will remain available even after a program restart."</p>
[ { "answer_id": 371826, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "~/.wireshark/recent" } ]
2008/12/16
[ "https://Stackoverflow.com/questions/371816", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
371,839
<p>What is the most efficient way to convert data from nested lists to an object array (which can be used i.e. as data for JTable)?</p> <pre><code>List&lt;List&gt; table = new ArrayList&lt;List&gt;(); for (DATAROW rowData : entries) { List&lt;String&gt; row = new ArrayList&lt;String&gt;(); for (String col : rowData.getDataColumn()) row.add(col); table.add(row); } // I'm doing the conversion manually now, but // I hope that there are better ways to achieve the same Object[][] finalData = new String[table.size()][max]; for (int i = 0; i &lt; table.size(); i++) { List&lt;String&gt; row = table.get(i); for (int j = 0; j &lt; row.size(); j++) finalData[i][j] = row.get(j); } </code></pre> <p>Many thanks!</p>
[ { "answer_id": 371873, "author": "Michael Myers", "author_id": 13531, "author_profile": "https://Stackoverflow.com/users/13531", "pm_score": 3, "selected": false, "text": "JTable AbstractTableModel class MyTableModel extends AbstractTableModel {\n private List<List<String>> data;\n ...
2008/12/16
[ "https://Stackoverflow.com/questions/371839", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33429/" ]
371,875
<p>Is there local file manipulation that's been done with JavaScript? I'm looking for a solution that can be accomplished with no install footprint like requiring <a href="http://en.wikipedia.org/wiki/Adobe_Integrated_Runtime" rel="noreferrer">Adobe AIR</a>.</p> <p>Specifically, I'd like to read the contents from a file and write those contents to another file. At this point I'm not worried about gaining permissions and am just assuming I already have full permissions to these files.</p>
[ { "answer_id": 371902, "author": "Jason S", "author_id": 44330, "author_profile": "https://Stackoverflow.com/users/44330", "pm_score": 5, "selected": false, "text": "netscape.security.PrivilegeManager.enablePrivilege(\"UniversalBrowserRead\");\nnetscape.security.PrivilegeManager.enablePr...
2008/12/16
[ "https://Stackoverflow.com/questions/371875", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24841/" ]
371,878
<p>I'm just starting out with F# and I can't find the syntax to do object initialization like in C# 3. </p> <p>I.e. given this:</p> <pre><code>public class Person { public DateTime BirthDate { get; set; } public string Name { get; set; } } </code></pre> <p>how do I write the following in F#:</p> <pre><code>var p = new Person { Name = "John", BirthDate = DateTime.Now }; </code></pre>
[ { "answer_id": 371910, "author": "Christian C. Salvadó", "author_id": 5445, "author_profile": "https://Stackoverflow.com/users/5445", "pm_score": 8, "selected": true, "text": "let p = new Person (Name = \"John\", BirthDate = DateTime.Now)\n" }, { "answer_id": 372187, "author"...
2008/12/16
[ "https://Stackoverflow.com/questions/371878", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21239/" ]
371,898
<p>I've seen a few mentions of this on Stack Overflow, but staring at Wikipedia (the relevant page has since been deleted) and at an <a href="http://sourceforge.net/projects/dyndlgdemo/" rel="noreferrer">MFC dynamic dialog demo</a> did nothing to enlighten me. Can someone please explain this? Learning a fundamentally different concept sounds nice.</p> <hr/> <p>Based on the answers: I think I'm getting a better feel for it. I guess I just didn't look at the source code carefully enough the first time. I have mixed feelings about differential execution at this point. On the one hand, it can make certain tasks considerably easier. On the other hand, getting it up and running (that is, setting it up in your language of choice) is not easy (I'm sure it would be if I understood it better)...though I guess the toolbox for it need only be made once, then expanded as necessary. I think in order to really understand it, I'll probably need to try implementing it in another language.</p>
[ { "answer_id": 381861, "author": "Alex", "author_id": 45581, "author_profile": "https://Stackoverflow.com/users/45581", "pm_score": 4, "selected": false, "text": "Start loop:\nfor each element in the datastructure: \n if element has changed from oldDatastructure:\n copy element...
2008/12/16
[ "https://Stackoverflow.com/questions/371898", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18192/" ]
371,930
<p>Environment is VS2008, .Net 3.5</p> <p>The following C# code (note the specified encoding of UTF8)</p> <pre><code>XmlWriterSettings settings = new XmlWriterSettings (); StringBuilder sb = new StringBuilder(); settings.Encoding = System.Text.Encoding.UTF8; settings.Indent = false; settings.NewLineChars = "\n"; settings.ConformanceLevel = System.Xml.ConformanceLevel.Document; XmlWriter writer = XmlWriter.Create (sb, settings); { // Write XML data. writer.WriteStartElement ("CCHEADER"); writer.WriteAttributeString ("ProtocolVersion", "1.0.0"); writer.WriteAttributeString ("ServerCapabilities", "0x0000000F"); writer.WriteEndElement (); writer.Flush (); } </code></pre> <p>Actually generates the XML (>&lt; omitted because SO barfs on them):</p> <p>?xml version="1.0" encoding="utf-16"?<br> CCHEADER ProtocolVersion="1.0.0" ServerCapabilities="0x0000000F" /</p> <p>Why do I get the wrong encoding generated here ? What am I doing wrong ?</p>
[ { "answer_id": 371946, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 5, "selected": true, "text": "public sealed class StringWriterWithEncoding : StringWriter\n{\n private readonly Encoding encoding;\n\n public Str...
2008/12/16
[ "https://Stackoverflow.com/questions/371930", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9368/" ]
371,938
<p>I have two routes I want mapped in my ASP.NET MVC application</p> <ol> <li>/User/Login</li> <li>/User/{userid}/{username}/{action} (e.g. /User/1/blah/profile)</li> </ol> <p>Here are the routes I've defined: </p> <pre><code> routes.MapRoute( "Profile", "Users/{userID}/{username}/{action}", new { controller = "Users", action = "Profile" } ); routes.MapRoute( "Default", "{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = "" } ); </code></pre> <p>This works great so far in most instances. The following URLs work from my home page:</p> <pre><code>&lt;%= Html.ActionLink((UsersController x) =&gt; x.Login(), "Login") %&gt; &lt;%= Html.ActionLink((UsersController x) =&gt; x.Profile(1, "blah") %&gt; </code></pre> <p>These map to (respectfully):</p> <p>/Users/Login /Users/1/blah</p> <p>However, once I've navigated to /Users/1/blah, the login url immediately turns to /Users/1/blah/login. Any idea how to fix this?</p>
[ { "answer_id": 375059, "author": "Chris James", "author_id": 3193, "author_profile": "https://Stackoverflow.com/users/3193", "pm_score": 2, "selected": true, "text": "<%=Html.RouteLink%>" } ]
2008/12/16
[ "https://Stackoverflow.com/questions/371938", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1574/" ]
371,961
<p>How are you supposed to unit test a web service in C# with Visual Studio 2008? When I generate a unit test it adds an actual reference to the web service class instead of a web reference. It sets the attributes specified in:</p> <p><a href="http://msdn.microsoft.com/en-us/library/ms243399(VS.80).aspx#TestingWebServiceLocally" rel="noreferrer">http://msdn.microsoft.com/en-us/library/ms243399(VS.80).aspx#TestingWebServiceLocally</a></p> <p>Yet, it will complete without executing the test. I attempted to add the call to <code>WebServiceHelper.TryUrlRedirection(...)</code> but the call does not like the target since it inherits from <code>WebService</code>, not <code>WebClientProtocol</code>.</p>
[ { "answer_id": 372455, "author": "Chris Brandsma", "author_id": 9443, "author_profile": "https://Stackoverflow.com/users/9443", "pm_score": 3, "selected": false, "text": "[WebMethod]\npublic void DoSomething()\n{ \n hander.DoSomething();\n}\n" }, { "answer_id": 1049680, "au...
2008/12/16
[ "https://Stackoverflow.com/questions/371961", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42588/" ]
371,974
<p>I'm writing my own Modal Popup as a template control in ASP.NET. I got two template containers - one for the heading of the window and one for the actual control i want to display in the modal window (let's call it the form control). The form controls can contain server controls like buttons, textbox'es etc.</p> <p>It works well, except when i want to access the form control in my web page. My codebehind won't recognize the content in the template control - just like it won't in, say a Repeater. So i figured a Panel control works just like what i need, except the Panel control only has "one container" and i'd really like to be able to set both a header and the content (form control).</p> <p>I figured i could overwrite the Panel control to add my own html but that would limit my header to be something encodeable in an attribute. So is my best bet really to expose the Heading as just a property, instead of a template and thus being limited in what i can write for heading?</p>
[ { "answer_id": 372455, "author": "Chris Brandsma", "author_id": 9443, "author_profile": "https://Stackoverflow.com/users/9443", "pm_score": 3, "selected": false, "text": "[WebMethod]\npublic void DoSomething()\n{ \n hander.DoSomething();\n}\n" }, { "answer_id": 1049680, "au...
2008/12/16
[ "https://Stackoverflow.com/questions/371974", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11619/" ]
371,987
<p>I doubt I am the only one who has come up with this solution, but if you have a better one please post it here. I simply want to leave this question here so I and others can search it later. </p> <p>I needed to tell whether a valid date had been entered into a text box and this is the code that I came up with. I fire this when focus leaves the text box.</p> <pre><code>try { DateTime.Parse(startDateTextBox.Text); } catch { startDateTextBox.Text = DateTime.Today.ToShortDateString(); } </code></pre>
[ { "answer_id": 371993, "author": "Chris James", "author_id": 3193, "author_profile": "https://Stackoverflow.com/users/3193", "pm_score": 9, "selected": true, "text": "DateTime.TryParse\n DateTime temp;\nif(DateTime.TryParse(startDateTextBox.Text, out temp))\n{\n // Yay :)\n}\nelse\n{\n ...
2008/12/16
[ "https://Stackoverflow.com/questions/371987", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19802/" ]
372,003
<p>I am looking for any kind of information (prefer Moq) on how to unit test the Application_Start method in Global.asax. I am using ASP.NET MVC and trying to get to that elusive 100% code coverage!</p> <p>The fact that I'm using MVC is not the point. And saying that not testing Start is not necessary isn't really the answer either. What if I had other code in there? I need to know how to test it.</p>
[ { "answer_id": 373681, "author": "CubanX", "author_id": 27555, "author_profile": "https://Stackoverflow.com/users/27555", "pm_score": 0, "selected": false, "text": "public static void CheckSession(HttpSessionStateBase session)\n{\n...\n}\n protected void Application_Start(object sender, ...
2008/12/16
[ "https://Stackoverflow.com/questions/372003", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
372,009
<p><a href="https://medifacd.relayhealth.com/Pharmacies/MediFacD_Pharmacies_PayerSheet_E1December2006.htm#Examples" rel="nofollow noreferrer" title="Medicare Eligibility EDI Example Responses">Medicare Eligibility EDI Example Responses</a> is what I'm trying to match.</p> <p>I have a string that looks like this:</p> <pre>LN:SMITHbbbbbbbbFN:SAMANTHAbbBD:19400515PD:1BN:123456PN:9876543210GP:ABCDEFGHIJKLMNOID:123456789012345bbbbbPC:123PH:8005551212CD:123456PB:123ED:20060101TD:2070101LC:NFI:12345678FE:20070101FT:20080101</pre> <p>I need a set of matches that look like this:</p> <pre> Key | Value ------------------- LN | SMITHbbbbbbbb FN | SAMANTHAbb BD | 19400515 ... etc </pre> <p>I've been dealing with this all day, and I can't seem to get an acceptable matching scenario. I'm about to program it procedurally with a for loop and finding indexes of colons if I can't figure something out.</p> <p>I've tried using <a href="http://yacsharpblog.blogspot.com/2008/09/regular-expressions-in-c-negative-look.html" rel="nofollow noreferrer" title="C# Negative Lookahead">negative lookahead</a> and I'm not getting anywhere. This is C#, and I'm using <a href="http://regexlib.com/RETester.aspx" rel="nofollow noreferrer" title=".Net Online Regular Expression Tester">this tester</a> (.Net) while I'm testing, along with <a href="http://www.weitz.de/regex-coach/" rel="nofollow noreferrer" title="The Regex Coach">The Regex Coach</a> (non .Net).</p> <p>I've tried using this:</p> <pre><code>([\w]{2})\:(?![\w]{2}\:) </code></pre> <p>But that only matches the keys and their colons, like "LN:", "FN:", etc.</p> <p>If I use:</p> <pre><code>([\w]{2})\:(.+?)([\w]{2})\: </code></pre> <p>It consumes the next matching two character key and colon as well, leading to me only matching every other key/value pair.</p> <p>Is there a way for me to match these using RegEx in .Net correctly, or am I stuck with a more procedural solution? Keep in mind, I can't assume that the keys will always be upper case letters. They could possibly include numbers, but they will always be two characters and then a colon.</p> <p>Thanks in advance for any help I can get.</p>
[ { "answer_id": 372036, "author": "Adam Bellaire", "author_id": 21632, "author_profile": "https://Stackoverflow.com/users/21632", "pm_score": 4, "selected": true, "text": "([\\w]{2})\\:(.+?)(?=[\\w]{2}\\:|$)\n" }, { "answer_id": 372054, "author": "Ates Goral", "author_id":...
2008/12/16
[ "https://Stackoverflow.com/questions/372009", "https://Stackoverflow.com", "https://Stackoverflow.com/users/448/" ]
372,011
<p>I have a listview working in virtual mode, in the LargeIcons view. Retrieves are expensive, so I want to ask for the data for all the visible items. How do I get the start index and total number of the visible items?</p> <p>Update: I am aware of the CacheVirtualItems event. The third-party database we're using takes ~3s to retrieve a single record, but ~4s to retrieve a thousand records, so I have to do them in large blocks. I need to make sure the visible records are among those we retrieve, so I need to know the start index and total number of the visible items. If that's not feasible, I'll have to find a workaround (which will probably involve using a DataGridView with a load of image cells to imitate the LargeIcons view) but I would like to do this properly if possible.</p>
[ { "answer_id": 372020, "author": "Jeff Yates", "author_id": 23234, "author_profile": "https://Stackoverflow.com/users/23234", "pm_score": 1, "selected": false, "text": " for (int index = 0; index < list.Items.Count; index++)\n {\n if (list.ClientRectangle.Interse...
2008/12/16
[ "https://Stackoverflow.com/questions/372011", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15371/" ]
372,018
<p>I'm trying to make a Card class that duplicates the behavior of Dashboard widgets in that you can put controls or images or whatever on two sides of the card and flip between them. </p> <p>Layer backed views have a transform property, but altering that doesn't do what I would expect it to do (rotating the layer around the y axis folds it off to the left side).</p> <p>I was pointed to some undocumented features and an .h file named cgsprivate.h, but I'm wondering if there is an official way to do this? This software would have to be shipped and I'd hate to see it fail later because the Apple guys pull it in 10.6.</p> <p>Anyone have any idea how to do this? It's so weird to me that a simple widget thing would be so hard to do in Core Animation.</p> <p>Thanks in advance!</p> <p>EDIT: I can accomplish this behavior with images that are on layers, but I don't know how to get more advanced controls/views/whatever on the layers. The card example uses images.</p>
[ { "answer_id": 372294, "author": "e.James", "author_id": 33686, "author_profile": "https://Stackoverflow.com/users/33686", "pm_score": 2, "selected": false, "text": "NSView NSView cacheDisplayInRect:toBitmapImageRep: NSView NSView" }, { "answer_id": 5082979, "author": "Arvin"...
2008/12/16
[ "https://Stackoverflow.com/questions/372018", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
372,023
<p>I want to build a DLL Class Library use COM Interop, with C#, target ANY CPU, and register it as 32-bit and 64-bit interfaces. </p> <p>I want to be able to, at runtime, display what interface was used - if I am using the 32-bit version, or 64-bit version.</p> <p>Any ideas?</p>
[ { "answer_id": 372065, "author": "Daniel Earwicker", "author_id": 27423, "author_profile": "https://Stackoverflow.com/users/27423", "pm_score": 4, "selected": true, "text": "if (System.IntPtr.Size == 8)\n{\n // 64-bit\n}\nelse\n{\n // 32-bit\n}\n" }, { "answer_id": 20379314...
2008/12/16
[ "https://Stackoverflow.com/questions/372023", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16794/" ]
372,033
<p>As the topic suggests I wish to be able to pass table names as parameters using .NET (doesn't matter which language really) and SQL Server.</p> <p>I know how to do this for values, e.g. <code>command.Parameters.AddWithValue("whatever", whatever)</code> using <code>@whatever</code> in the query to denote the parameter. The thing is I am in a situation where I wish to be able to do this with other parts of the query such as column and table names.</p> <p>This is not an ideal situation but it's one I have to use, it's not really prone to SQL injection as only someone using the code can set these table names and not the end-user. It is messy however.</p> <p>So, is what I am asking possible? </p> <p>EDIT: To make the point about SQL injection clear, the table names are only passed in by source code, depending on the situation. It is the developer who specifies this. The developer will have access to the database layer anyway, so the reason I am asking is not so much for security but just to make the code cleaner.</p>
[ { "answer_id": 372053, "author": "JoshBerke", "author_id": 26160, "author_profile": "https://Stackoverflow.com/users/26160", "pm_score": 2, "selected": false, "text": "create procedure myProc\n\n@tableName nvarchar(50)\n\nas\n\nsp_executesql N'select * from ' + @tablename\n" }, { ...
2008/12/16
[ "https://Stackoverflow.com/questions/372033", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35454/" ]
372,034
<p>The ListView doesn't seem to support the Scroll event. I need to call a function whenever the list is scrolled; how would I go about that?</p>
[ { "answer_id": 375808, "author": "Brian Rudolph", "author_id": 33114, "author_profile": "https://Stackoverflow.com/users/33114", "pm_score": 4, "selected": true, "text": "public class TestListView : System.Windows.Forms.ListView\n{\n private const int WM_HSCROLL = 0x114;\n private ...
2008/12/16
[ "https://Stackoverflow.com/questions/372034", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15371/" ]
372,040
<p>I have three tables like that:</p> <p><strong>Articles</strong> IdArticle Title Content</p> <p><strong>Tags</strong> IdTag TagName</p> <p><strong>ContentTag</strong> IdContentTag Idtag IdContent</p> <p>When user in my site write an article with adding tags and submit, I want to save it to tables above. </p> <p>In traditional ways, I used to use transaction and I could do it. But How can I do it by using linq to sql?</p>
[ { "answer_id": 375808, "author": "Brian Rudolph", "author_id": 33114, "author_profile": "https://Stackoverflow.com/users/33114", "pm_score": 4, "selected": true, "text": "public class TestListView : System.Windows.Forms.ListView\n{\n private const int WM_HSCROLL = 0x114;\n private ...
2008/12/16
[ "https://Stackoverflow.com/questions/372040", "https://Stackoverflow.com", "https://Stackoverflow.com/users/439507/" ]
372,041
<p>I want to register a specific instance of an object for a type in structuremap, how can I do that?</p> <p>For example,</p> <p>When I do:</p> <pre><code>var myObj = ObjectFactory.GetInstance(typeof(MyAbstractClass)); </code></pre> <p>i would like it to return a previously constructed concrete class, which i created like this:</p> <pre><code>var myClass = new MyConcreteClass("bla"); // MyConcreteClass : MyAbstractClass </code></pre> <p>so </p> <pre><code>myObj == myClass </code></pre> <p>How do i register myClass with structuremap to facilitate this?</p> <p>Thanks</p> <p>Andrew</p>
[ { "answer_id": 372168, "author": "Jab", "author_id": 29676, "author_profile": "https://Stackoverflow.com/users/29676", "pm_score": 4, "selected": true, "text": " ObjectFactory.Initialize(x =>\n {\n x.ForRequestedType<MyAbstractClass>().TheDefault.IsThis(myClass);...
2008/12/16
[ "https://Stackoverflow.com/questions/372041", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28543/" ]
372,042
<p>What is the difference between abstract class and interface in Python?</p>
[ { "answer_id": 372121, "author": "S.Lott", "author_id": 10661, "author_profile": "https://Stackoverflow.com/users/10661", "pm_score": 10, "selected": true, "text": "class Abstract1:\n \"\"\"Some description that tells you it's abstract,\n often listing the methods you're expected t...
2008/12/16
[ "https://Stackoverflow.com/questions/372042", "https://Stackoverflow.com", "https://Stackoverflow.com/users/461736/" ]
372,043
<p>I want to do something sort of like this:</p> <pre><code>let x = 5 let y = 10 let expr = Console.ReadLine() expr </code></pre> <p>Where one might type <code>"x+y"</code> in the console to store in expr.</p> <p>How does one evaluate a statement like this in F#?</p> <p>Ultimately, I want a user to be able to enter expressions, or a set of rules for a system, on a webpage and have them saved in a database to be applied at appropriate times in an F# library. I just don't know how to convert the entered string in to a function value in F#.</p> <p>Thanks for any help you may provide!</p> <p>Adam</p>
[ { "answer_id": 372100, "author": "nlucaroni", "author_id": 157, "author_profile": "https://Stackoverflow.com/users/157", "pm_score": 3, "selected": true, "text": "ocamlmktop" }, { "answer_id": 409388, "author": "Community", "author_id": -1, "author_profile": "https://...
2008/12/16
[ "https://Stackoverflow.com/questions/372043", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42140/" ]
372,075
<p>I am trying to understand difference between those two and really need a explanatory simple example for them.</p> <p>Thanks in advance..</p>
[ { "answer_id": 372084, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 3, "selected": true, "text": "InsertOnSubmit InsertAllOnSubmit IEnumerable<T>" }, { "answer_id": 711148, "author": "Jim Ierley", "au...
2008/12/16
[ "https://Stackoverflow.com/questions/372075", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44852/" ]
372,086
<p>I asked <a href="https://stackoverflow.com/questions/370024/sql-server-2005-public-database-role-doesnt-seem-to-apply">another question</a> about roles and permissions, which mostly served to reveal my ignorance. One of the other outcomes was the advice that one should generally stay away from mucking with permissions for the "public" role.</p> <p>OK, fine, but if I've already done so and want to re-assign the same permissions to a custom/"flexible" role, what's the best way to do that? What I've done so far is to run the Scripting wizard, and tell it to script object permissions without CREATE or DROP, then run a find-replace so that I wind up with a lot of <code>"GRANT DELETE on [dbo.tablename] TO [newRole]"</code>. It gets the job done, but I feel like it could be prettier/easier. Any "best practice" suggestions?</p>
[ { "answer_id": 375782, "author": "gbn", "author_id": 27535, "author_profile": "https://Stackoverflow.com/users/27535", "pm_score": 4, "selected": true, "text": "sys.database_permissions SET NOCOUNT ON;\nDECLARE @NewRole varchar(100), @SourceRole varchar(100);\n\n-- Change as needed\nSELE...
2008/12/16
[ "https://Stackoverflow.com/questions/372086", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26286/" ]
372,087
<p>Here is the single line from one of my functions to test if any objects in my array have a given property with a matching value</p> <pre><code>Return ((From tag In DataCache.Tags Where (tag.FldTag = strtagname) Select tag).Count = 1) </code></pre> <p>WHERE....</p> <p><code>DataCache.Tags</code> is an array of custom objects</p> <p><code>strtagname = "brazil"</code></p> <p>and brazil is definitely a tag name stored within one of the custom objects in the array.</p> <p>However the function continually returns false.</p> <p>Can someone confirm to me that the above should or should not work.</p> <p>and if it wont work can someone tell me the best way to test if any of the objects in the array contain a property with a specific value.</p> <p>I suppose in summary I am looking for the equivalent of a SQL EXISTS statement.</p> <p>Many thanks in hope.</p>
[ { "answer_id": 372098, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 3, "selected": false, "text": "Return DataCache.Tags.Any(Function(tag) tag.FldTag = strtagname)\n" } ]
2008/12/16
[ "https://Stackoverflow.com/questions/372087", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
372,102
<p>I'm aware that Python 3 fixes a lot of UTF issues, I am not however able to use Python 3, I am using 2.5.1</p> <p>I'm trying to regex a document but the document has UTF hyphens in it – rather than -. Python can't match these and if I put them in the regex it throws a wobbly.</p> <p>How can I force Python to use a UTF string or in some way match a character such as that?</p> <p>Thanks for your help</p>
[ { "answer_id": 372128, "author": "Patrick McElhaney", "author_id": 437, "author_profile": "https://Stackoverflow.com/users/437", "pm_score": 3, "selected": false, "text": "re.compile(\"–\") \n re.compile(u\"\\u2013\")\n" }, { "answer_id": 372193, "author": "Patrick McElhaney"...
2008/12/16
[ "https://Stackoverflow.com/questions/372102", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1384652/" ]
372,105
<p>At work today we were trying to come up with any reason you would use <a href="http://www.php.net/strspn" rel="noreferrer">strspn</a>.</p> <p>I searched google code to see if it's ever been implemented in a useful way and came up blank. I just can't imagine a situation in which I would really need to know the length of the first segment of a string that contains only characters from another string. Any ideas?</p>
[ { "answer_id": 372130, "author": "Adam Rosenfield", "author_id": 9530, "author_profile": "https://Stackoverflow.com/users/9530", "pm_score": 1, "selected": false, "text": "strspn()" }, { "answer_id": 372144, "author": "Loki", "author_id": 39057, "author_profile": "htt...
2008/12/16
[ "https://Stackoverflow.com/questions/372105", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29683/" ]
372,114
<p>I have a HashMap that I am serializing and deserializing to an Oracle db, in a BLOB data type field. I want to perform a query, using this field. Example, the application will make a new HashMap, and have some key-value pairs. I want to query the db to see if a HashMap with this data already exists in the db. I do not know how to do this, it seems strange if i have to go to every record in the db, deserialize it, then compare, Does SQL handle comparing BLOBs, so i could have...select * from PROCESSES where foo = ?....and foo is a BLOB type, and the ? is an instance of the new HashMap? Thanks</p>
[ { "answer_id": 372131, "author": "BQ.", "author_id": 4632, "author_profile": "https://Stackoverflow.com/users/4632", "pm_score": 0, "selected": false, "text": "dbms_lob dbms_lob.compare()" }, { "answer_id": 372215, "author": "Juliet", "author_id": 40516, "author_profi...
2008/12/16
[ "https://Stackoverflow.com/questions/372114", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13143/" ]
372,116
<p>I currently use this function to wrap executing commands and logging their execution, and return code, and exiting in case of a non-zero return code.</p> <p>However this is problematic as apparently, it does double interpolation, making commands with single or double quotes in them break the script.</p> <p>Can you recommend a better way?</p> <p>Here's the function:</p> <pre><code>do_cmd() { eval $* if [[ $? -eq 0 ]] then echo "Successfully ran [ $1 ]" else echo "Error: Command [ $1 ] returned $?" exit $? fi } </code></pre>
[ { "answer_id": 372120, "author": "Douglas Leeder", "author_id": 3978, "author_profile": "https://Stackoverflow.com/users/3978", "pm_score": 6, "selected": true, "text": "\"$@\"\n do_cmd()\n{\n \"$@\"\n ret=$?\n if [[ $ret -eq 0 ]]\n then\n echo \"Successfully ran [ $@ ...
2008/12/16
[ "https://Stackoverflow.com/questions/372116", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13523/" ]
372,126
<p>If <code>UNION ALL</code> is an <em>addition</em> in T-SQL. What is the equivalent of subtraction?</p> <p>For example, if I have a table <code>PEOPLE</code> and a table <code>EMPLOYEES</code>. And I know if I remove <code>EMPLOYEES</code> records from <code>PEOPLE</code> I will be left with my companies <code>CONTRACTORS</code>. </p> <p>Is there a way of doing this that is similar to <code>UNION ALL</code>? One where I don't have to specify any field names? The reason I ask is this is just one hypothetical example. I need to do this several times to many different tables. Assume that the schema of <code>EMPLOYEES</code> and <code>PEOPLE</code> are the same.</p>
[ { "answer_id": 372146, "author": "Greg Dean", "author_id": 1200558, "author_profile": "https://Stackoverflow.com/users/1200558", "pm_score": 2, "selected": false, "text": "SELECT * FROM Table1\nWHERE Table1.Key NOT IN (SELECT Table2.Key FROM Table2 WHERE Table2.Key IS NOT NULL)\n" }, ...
2008/12/16
[ "https://Stackoverflow.com/questions/372126", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36590/" ]
372,140
<p>I am building a C# ActiveX DLL... do I use REGASM or REGSVR32 to register it?</p> <p>How do I register the 64-bit interface vs the 32-bit interface?</p>
[ { "answer_id": 372197, "author": "Kev", "author_id": 419, "author_profile": "https://Stackoverflow.com/users/419", "pm_score": 6, "selected": true, "text": "regasm.exe regasm.exe C:\\Windows\\Microsoft.NET\\Framework\\v2.0.50727\n C:\\Windows\\Microsoft.NET\\Framework64\\v2.0.50727\n reg...
2008/12/16
[ "https://Stackoverflow.com/questions/372140", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16794/" ]
372,148
<p>I'd like to use regex with Java.</p> <p>What I want to do is find the first integer in a string.</p> <p>Example:</p> <pre><code>String = "the 14 dogs ate 12 bones" </code></pre> <p>Would return 14.</p> <pre><code>String = "djakld;asjl14ajdka;sdj" </code></pre> <p>Would also return 14.</p> <p>This is what I have so far.</p> <pre><code>Pattern intsOnly = Pattern.compile("\\d*"); Matcher makeMatch = intsOnly.matcher("dadsad14 dssaf jfdkasl;fj"); makeMatch.find(); String inputInt = makeMatch.group(); System.out.println(inputInt); </code></pre> <p>What am I doing wrong?</p>
[ { "answer_id": 372154, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 7, "selected": true, "text": "\"\\\\d+\"\n" }, { "answer_id": 1609659, "author": "Chris Smith", "author_id": 194872, "author_profile": "h...
2008/12/16
[ "https://Stackoverflow.com/questions/372148", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2510/" ]
372,149
<p>Any thoughts on why I might be getting tons of "hangs" when trying to download a file via HTTP, based on the following?</p> <ul> <li>Server is IIS 6</li> <li>File being downloaded is a binary file, rather than a web page</li> <li>Several clients hang, including TrueUpdate and FlexNet web updating packages, as well as custom .NET app that just does basic HttpWebRequest/HttpWebResponse logic and downloads using a response stream</li> <li>IIS log file signature when success is 200 0 0 (sc-status sc-substatus sc-win32-status)</li> <li>For failure, error signature is 200 0 64 </li> <li>sc-win32-status of 64 is "the specified network name is no longer available"</li> <li>I can point firefox at the URL and download successfully every time (perhaps some retry logic is happening under the hood)</li> </ul> <p>At this point, it seems like either there's something funky with my server that it's throwing these errors, or that this is just normal network behavior and I need to use (or write) a client that is more resilient to the failures.</p> <p>Any thoughts?</p>
[ { "answer_id": 20632109, "author": "Emiel", "author_id": 3110830, "author_profile": "https://Stackoverflow.com/users/3110830", "pm_score": 1, "selected": false, "text": "//curl_setopt($ch, CURLOPT_TIMEOUT, 4); // times out after 4s\ncurl_setopt($ch, CURLOPT_TIMEOUT, 60); // times out aft...
2008/12/16
[ "https://Stackoverflow.com/questions/372149", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22357/" ]
372,159
<p>AFAIK, you never need to specify the protocol in an onclick:</p> <p><code>onclick="javascript:myFunction()"</code> <strong>Bad</strong></p> <p><code>onclick="myFunction()"</code> <strong>Good</strong></p> <p>Today I noticed in <a href="http://web.archive.org/web/20080428095515/http://www.google.com/support/analytics/bin/answer.py?answer=55527" rel="noreferrer">this article</a> on Google Anallytics that <em>they</em> are using it:</p> <pre><code>&lt;a href="http://www.example.com" onClick="javascript: pageTracker._trackPageview('/outgoing/example.com');"&gt; </code></pre> <p>Is this example just plain wrong, or is there ever a reason to specify <code>javascript:</code> in anything other than a <code>href</code>?</p>
[ { "answer_id": 372253, "author": "jishi", "author_id": 33663, "author_profile": "https://Stackoverflow.com/users/33663", "pm_score": 3, "selected": false, "text": "javascript: <a href=\"javascript:void(alert('really bad usage!'))\">\n" }, { "answer_id": 372279, "author": "Ate...
2008/12/16
[ "https://Stackoverflow.com/questions/372159", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12579/" ]
372,162
<p>I am trying to reduce the load on my webservers by adding an "Image server" (a dedicated server for handling image requests), and redirecting all requests for .gif,.jpg,.png etc., to it.</p> <p>My question is, what is the best way to handle the redirection?</p> <ul> <li>At the firewall level? (can I do this using iptables?) </li> <li>At the load balancer level? (can ldirectord handle this?) </li> <li>At the apache level - using rewrite rules?</li> </ul> <p>Thanks for any suggestions on the best way to do this.</p> <p>--Update--</p> <p>One thing I would add is that these are domains that are hosted for 3rd parties, so I can't expect all the developers to modify their code and point their images to another server.</p>
[ { "answer_id": 372238, "author": "Ian Boyd", "author_id": 12597, "author_profile": "https://Stackoverflow.com/users/12597", "pm_score": 1, "selected": false, "text": "<IMG src=\"images/Brett.jpg\">\n <IMG src=\"http://brettnesbitt.akamia-technologies.com/images/Brett.jpg\">\n GET images/...
2008/12/16
[ "https://Stackoverflow.com/questions/372162", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3764/" ]
372,186
<p>Can you show sample code for reading a drive label or volume name in .NET? I get the sense this requires WMI, but I am loathe to "drop-down" into WMI because it is like dropping down into a string-based SQL query in the sense that certain objects may not exist on certain versions of OSes or the user may not have the right to query certain data. I will be happy to be convinced that I'm wrong about WMI ...</p>
[ { "answer_id": 372201, "author": "Kent Boogaart", "author_id": 5380, "author_profile": "https://Stackoverflow.com/users/5380", "pm_score": 5, "selected": true, "text": "var labels = from drive in DriveInfo.GetDrives()\n select drive.VolumeLabel\n" }, { "answer_id": 37...
2008/12/16
[ "https://Stackoverflow.com/questions/372186", "https://Stackoverflow.com", "https://Stackoverflow.com/users/470/" ]
372,202
<p>I have been doing a lot of research on this lately, but have yet to get a really good solid answer. I read somewhere that a new Function() object is created when the JavaScript engine comes across a function statement, which would lead me to believe it could be a child of an object (thus becoming one). So I emailed Douglas Crockford, and his answer was:</p> <blockquote> <p>Not exactly, because a function statement does not call the compiler.</p> <p>But it produces a similar result.</p> </blockquote> <p>Also, to my knowledge, you can't call members on a function constructor unless it has been instantiated as a new object. So this will not work:</p> <pre><code>function myFunction(){ this.myProperty = "Am I an object!"; } myFunction.myProperty; // myFunction is not a function myFunction().myProperty; // myFunction has no properties </code></pre> <p>However, this will work:</p> <pre><code>function myFunction(){ this.myProperty = "Am I an object!"; } var myFunctionVar = new myFunction(); myFunctionVar.myProperty; </code></pre> <p>Is this just a matter of semantics... in the whole of the programming world, when does an object really become an object, and how does that map to JavaScript?</p>
[ { "answer_id": 372228, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 2, "selected": false, "text": "window this.myProperty = \"foo\" myFunction() window.myProperty = \"foo\" myFunction().myProperty myFunction() function myFun...
2008/12/16
[ "https://Stackoverflow.com/questions/372202", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
372,218
<p>I would like to insert the current Subversion revision number (as reported by <code>svnversion</code>) into my Xcode project. I managed to insert the revision number into the <code>Info.plist</code> in the <code>$PROJECT_DIR</code>, but this is not a good solution, since the file is versioned. I tried to insert the revision into the <code>Info.plist</code> in the build directory, but then I get an error during the code signing phase (this is an iPhone application).</p> <p>Is there a simple way to get the revision number into the application using some build files, so that the changing revision does not change versioned files? I thought maybe I could create a temporary source file that would link with the others and provide a function to get the revision number. But I don’t know how to do that.</p> <p>I am not much interested in other solutions, ie. the <code>agvtool</code>. All I want is the revision number available to the application, without too much magic.</p>
[ { "answer_id": 414792, "author": "Brad Larson", "author_id": 19679, "author_profile": "https://Stackoverflow.com/users/19679", "pm_score": 3, "selected": false, "text": "REV=`/usr/bin/svnversion -nc ${PROJECT_DIR} | /usr/bin/sed -e 's/^[^:]*://;s/[A-Za-z]//'`\necho \"#define kRevisionNum...
2008/12/16
[ "https://Stackoverflow.com/questions/372218", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17279/" ]
372,220
<p>I have an executable that runs instantly from a command prompt, but does not appear to ever return when spawned using System.Diagnostics.Process:</p> <p>Basicly, I'm writing a .NET library wrapper around the Accurev CLI interface, so each method call spawns the CLI process to execute a command.</p> <p>This works great for all but one command:</p> <pre><code> accurev.exe show depots </code></pre> <p>However, when running this from a console, it runs fine, when I call it using a .net process, it hangs...The process spawning code I use is:</p> <pre><code> public static string ExecuteCommand(string command) { Process p = createProcess(command); p.Start(); p.WaitForExit(); // Accurev writes to the error stream if ExitCode is non zero. if (p.ExitCode != 0) { string error = p.StandardError.ReadToEnd(); Log.Write(command + " failed..." + error); throw new AccurevException(error); } else { return p.StandardOutput.ReadToEnd(); } } /// Creates Accurev Process /// &lt;/summary&gt; /// &lt;param name="command"&gt;&lt;/param&gt; /// &lt;returns&gt;&lt;/returns&gt; private static Process createProcess(string command) { Log.Write("Executing Command: " + command); ProcessStartInfo startInfo = new ProcessStartInfo(); Process p = new Process(); startInfo.CreateNoWindow = false; startInfo.RedirectStandardOutput = true; startInfo.RedirectStandardInput = true; startInfo.RedirectStandardError = true; startInfo.UseShellExecute = false; startInfo.Arguments = command; startInfo.FileName = _accurev; p.StartInfo = startInfo; return p; } </code></pre> <p>It hangs at p.WaitForExit().</p> <p>Any advice?</p> <p><strong>EDIT</strong>: Solved!</p> <p>.NET Process's hang if the output buffer overflows, I switched to using an asynchronous read method and everything works:</p> <pre><code> public static string ExecuteCommand(string command) { StringBuilder outputData = new StringBuilder(); Process p = createProcess(command); p.OutputDataReceived += delegate(object sender, DataReceivedEventArgs e) { outputData.AppendLine(e.Data); }; p.Start(); p.BeginOutputReadLine(); p.WaitForExit(); // Accurev writes to the error stream if ExitCode is non zero. if (p.ExitCode != 0) { string error = p.StandardError.ReadToEnd(); Log.Write(command + " failed..." + error); throw new AccurevException(error); } else { return outputData.ToString(); } } </code></pre>
[ { "answer_id": 372304, "author": "FryGuy", "author_id": 28776, "author_profile": "https://Stackoverflow.com/users/28776", "pm_score": -1, "selected": false, "text": "while (!p.WaitForExit(100))\n Console.Write(\".\");\n" } ]
2008/12/16
[ "https://Stackoverflow.com/questions/372220", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1965/" ]
372,224
<p>I'm having some trouble with this code:</p> <p>CSS: </p> <pre><code>div#header { width: 100%; background-color: #252525; padding: 10px 0px 10px 15px; position: relative; } div#login { float: right; position: absolute; right: 10px; top: 5px; } </code></pre> <p>HTML:</p> <pre><code>&lt;div id="header"&gt; &lt;img src="./img/logo.jpg" /&gt; &lt;div id="login"&gt; &lt;form id="header-login" action="#"&gt; &lt;input type="text" /&gt; &lt;input type="text" /&gt; &lt;input type="submit" value="LOGIN" /&gt; &lt;/form&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>The div id=header tag has a left padding of 15px. Because of this, the div itself stretches the width of the page, plus an extra 15px to the right, causing me to have a horizontal scrollbar. I've tried putting the header div inside a container div, with relative positioning, but the padding caused the header div to just overflow 15px over the container, still leaving me with the sidebar. Can someone help me with a better understanding? Thanks.</p>
[ { "answer_id": 372272, "author": "fasih.rana", "author_id": 46024, "author_profile": "https://Stackoverflow.com/users/46024", "pm_score": 1, "selected": false, "text": "div#header { width: 100%; height:15px; background-color: #252525; padding: 10px 0px 10px; position: relative; }\n" } ...
2008/12/16
[ "https://Stackoverflow.com/questions/372224", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32432/" ]
372,230
<p>I have a read-only database that has cached information which is used to display pages on the site. There are processes that run to generate the database, and those run on a different server. When I need to update the live database, I restore this database to the live server, to a new name and file. Then I drop the live database and rename this one to the original name. Currently I do this with a stored procedure, that kills all connections via 'sp_who' and 'kill', then the drop database command, then 'sp_renamedb'. Now when I kill all connections it will throw an error on the site for people and crawlers currently accessing those pages, is there a better methodology for performing this procedure?</p>
[ { "answer_id": 372322, "author": "Michael Sharek", "author_id": 1958, "author_profile": "https://Stackoverflow.com/users/1958", "pm_score": 2, "selected": true, "text": "ALTER DATABASE name SET OFFLINE\n" } ]
2008/12/16
[ "https://Stackoverflow.com/questions/372230", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13855/" ]
372,246
<p>How can I get a query which uses an OR in the WHERE clause to split itself into two queries with a UNION during compilation? If I manually rewrite it, the query using the UNION is 100x faster than the single query, because it can effectively use different indices in each query of the union. Is there any way I can make the optimizer use this approach?</p> <p>I have a query that looks something like this:</p> <pre><code>select columnlist from table1 join table2 on joincond2 join table3 on joincond3 where conditions1 and ((@param1 is null and cond3a) or (cond3b)) </code></pre> <p>Where columnlist, joincond2, joincond3, and conditions1 are all longer expressions. The kicker is that only one of the conditions in the OR is ever true.</p> <p>I first thought I could just rewrite it to do the union, but then I am repeating columnlist, joincond2, joincond3, and conditions1, which is 20 or so lines of SQL that might need a lot of maintenance in the future. Is there a hint I can supply or some better way to write the WHERE clause? Thanks in advance.</p>
[ { "answer_id": 372352, "author": "Chaowlert Chaisrichalermpol", "author_id": 2398110, "author_profile": "https://Stackoverflow.com/users/2398110", "pm_score": 3, "selected": true, "text": "select columnlist\nfrom table1\njoin table2 on joincond2\njoin table3 on joincond3\n with cte ( col...
2008/12/16
[ "https://Stackoverflow.com/questions/372246", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7453/" ]
372,250
<p>I think there must be something subtle going on here that I don't know about. Consider the following:</p> <pre><code>public class Foo&lt;T&gt; { private T[] a = (T[]) new Object[5]; public Foo() { // Add some elements to a } public T[] getA() { return a; } } </code></pre> <p>Suppose that your main method contains the following:</p> <pre><code>Foo&lt;Double&gt; f = new Foo&lt;Double&gt;(); Double[] d = f.getA(); </code></pre> <p>You will get a <code>CastClassException</code> with the message <code>java.lang.Object</code> cannot be cast to <code>java.lang.Double</code>.</p> <p>Can anyone tell me why? My understanding of <code>ClassCastException</code> is that it is thrown when you try to cast an object to a type that cannot be casted. That is, to a subclass of which it is not an instance (to quote the documentation). e.g.:</p> <pre><code>Object o = new Double(3.); Double d = (Double) o; // Working cast String s = (String) o; // ClassCastException </code></pre> <p>And it seems I can do this. If <code>a</code> was just a <code>T</code> instead of an array <code>T[]</code>, we can get <code>a</code> and cast it without a problem. Why do arrays break this?</p> <p>Thanks.</p>
[ { "answer_id": 372258, "author": "matt b", "author_id": 4249, "author_profile": "https://Stackoverflow.com/users/4249", "pm_score": 5, "selected": true, "text": "Foo<Double> f = new Foo<Double>();\n a private T[] a = (T[]) new Object[5];\n T Double private Double[] a = (Double[]) new Obj...
2008/12/16
[ "https://Stackoverflow.com/questions/372250", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2200391/" ]
372,268
<p>I'm trying to learn how to do passphrase-based encryption with Java. I'm finding several examples online, but none (yet) on Stack Overflow. The examples are a little light on explanation for me, particularly regarding algorithm selection. There seems to be a lot of passing strings around to say what algorithms to use, but little documentation as to where the strings came from and what they mean. And it also seems like the different algorithms may require different implementations of the KeySpec class, so I'm not sure what algorithms can use the PBEKeySpec class I'm looking at. Furthermore, the examples all seem a little out of date, many requiring you to get an older cryptography package that used to not be part of the JDK, or even a third-party implementation.</p> <p>Can someone provide a straightforward introduction to what I need to do to implement encrypt(String data, String passphrase) and decrypt(byte[] data, String passphrase)?</p>
[ { "answer_id": 372690, "author": "Jim Barrows", "author_id": 45108, "author_profile": "https://Stackoverflow.com/users/45108", "pm_score": 2, "selected": false, "text": "Security.addProvider(new BouncyCastleProvider());\n keyGen = KeyGenerator.getInstance(\"DES\", \"BC\");\n" }, { ...
2008/12/16
[ "https://Stackoverflow.com/questions/372268", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18103/" ]
372,282
<p>Is it good practice to have more than one <code>try{} catch{}</code> statement per method?</p>
[ { "answer_id": 372290, "author": "Bullines", "author_id": 27870, "author_profile": "https://Stackoverflow.com/users/27870", "pm_score": 3, "selected": false, "text": "try\n{\n // a bunch of risky code\n}\ncatch (SpecificException1 ex1)\n{\n // handle Specific Exception 1\n}\ncatch...
2008/12/16
[ "https://Stackoverflow.com/questions/372282", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46780/" ]
372,309
<p>Is there a way to get notification of date change in c#?</p> <p>I have a requirement where I have to do something when the system date is changed.</p> <p>I found that SystemsEvent.TimeChanged is an event you can hook into, however it is only fired only when user has changed the time.</p>
[ { "answer_id": 376356, "author": "Brian Rudolph", "author_id": 33114, "author_profile": "https://Stackoverflow.com/users/33114", "pm_score": 1, "selected": false, "text": " static System.Diagnostics.EventLog log = new EventLog(\"System\");\n\n public Form1()\n {\n log.Ent...
2008/12/16
[ "https://Stackoverflow.com/questions/372309", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45648/" ]
372,316
<p>I am working with PHP and I am wondering how bad practise it is to combine lots of functions into a class. I am aware of it's not the purpose of classes, but the reason why I would do this is to provide a namespace. How big impact does it make to initiate let's say 10 classes at the execution of a PHP script instead of let's say 2 or 3?</p>
[ { "answer_id": 372359, "author": "Hrvoje Prgeša", "author_id": 45875, "author_profile": "https://Stackoverflow.com/users/45875", "pm_score": 3, "selected": false, "text": "<?php\nclass Foo {\n public static function aStaticMethod() {\n // ...\n }\n}\n\nFoo::aStaticMethod();\n?>...
2008/12/16
[ "https://Stackoverflow.com/questions/372316", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
372,317
<p>I have a dataprovider and a filterfunction for my array that's assigned to my dataprovider.</p> <p>How can I get a list of the properties that are in each row of the dataprovider (item.data) as it gets passed to the filterfunction?</p> <p>For instance, if my object contained:</p> <ul> <li>Object <ul> <li>name</li> <li>email</li> <li>address</li> </ul></li> </ul> <p>Then I would want, in my filterfunction to be able to look at name, email and address. Unfortunately, I don't know what these properties will be before hand.</p> <p>Any ideas?</p>
[ { "answer_id": 372427, "author": "Herms", "author_id": 1409, "author_profile": "https://Stackoverflow.com/users/1409", "pm_score": 7, "selected": true, "text": "var obj:Object; // I'm assuming this is your object\n\nfor(var id:String in obj) {\n var value:Object = obj[id];\n\n trace(id...
2008/12/16
[ "https://Stackoverflow.com/questions/372317", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46782/" ]
372,321
<p>Should I use them as separate releases? Do I check them back into trunk or branches? Is this all in the red book and I've just wasted your time?</p>
[ { "answer_id": 372429, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 4, "selected": false, "text": "svn copy" }, { "answer_id": 8826704, "author": "altern", "author_id": 50962, "author_profile": "https://Sta...
2008/12/16
[ "https://Stackoverflow.com/questions/372321", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7853/" ]
372,325
<p>I have this line of code for page load:</p> <pre><code>if ($("input").is(':checked')) { </code></pre> <p>and it works fine when the radio button input is checked. However, I want the opposite. Something along the lines of </p> <pre><code>if ($("input").not(.is(':checked'))) { </code></pre> <p>so that my if statement runs when none of the radiobuttons are selected. What is the best way to go about this?</p>
[ { "answer_id": 372364, "author": "singpolyma", "author_id": 8611, "author_profile": "https://Stackoverflow.com/users/8611", "pm_score": 7, "selected": true, "text": "if ( ! $(\"input\").is(':checked') )\n var iz_checked = true;\n$('input').each(function(){\n iz_checked = iz_checked && ...
2008/12/16
[ "https://Stackoverflow.com/questions/372325", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16508/" ]
372,327
<p>I'm trying to consume Sharepoint webservices with ruby. I've basically given up trying to authenticate with NTLM and temporarily changed the Sharepoint server to use basic authentication. I've been successful getting a WSDL using soap4r but still cannot authenticate when attempting to use an actual web service call.</p> <p>Has anyone had any experience getting ruby and Sharepoint to talk?</p>
[ { "answer_id": 1032955, "author": "Arthur", "author_id": 127608, "author_profile": "https://Stackoverflow.com/users/127608", "pm_score": 1, "selected": false, "text": "cscript adsutil.vbs set w3svc/1/NTAuthenticationProviders \"Negotiate,NTLM\"\n" }, { "answer_id": 5344338, "...
2008/12/16
[ "https://Stackoverflow.com/questions/372327", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1766771/" ]
372,334
<p>Is there a pure .net way to do this reliably? The solutions I keep finding either require guessing or they have a solution that is specific to a database provider. Usually querying some internal system table to get this information.</p>
[ { "answer_id": 372349, "author": "Igor Zelaya", "author_id": 22769, "author_profile": "https://Stackoverflow.com/users/22769", "pm_score": 4, "selected": true, "text": "string[] GetPrimaryKeys(SqlConnection connection, string tableName)\n{\n using(SqlDataAdapter adapter = new SqlDataA...
2008/12/16
[ "https://Stackoverflow.com/questions/372334", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7176/" ]
372,354
<p>Does string immutability work by statement, or by strings within a statement? </p> <p>For example, I understand that the following code will allocate two strings on the heap.</p> <pre><code>string s = "hello "; s += "world!"; </code></pre> <p>"hello" will remain on the heap until garbage collected; and s now references "hello world!" on the heap. However, how many strings does the following line allocate on the heap...1 or 2? Also, is there a tool/way to verify the results?</p> <pre><code>string s = "goodbye " + "cruel world!"; </code></pre>
[ { "answer_id": 372363, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 5, "selected": true, "text": ".method private hidebysig static void Main() cil managed\n{\n .entrypoint\n .maxstack 1\n .locals init (\n ...
2008/12/16
[ "https://Stackoverflow.com/questions/372354", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37064/" ]
372,365
<p>I am using xmlrpclib.ServerProxy to make RPC calls to a remote server. If there is not a network connection to the server it takes the default 10 seconds to return a socket.gaierror to my program. </p> <p>This is annoying when doing development without a network connection, or if the remote server is down. Is there a way to update the timeout on my ServerProxy object?</p> <p>I can't see a clear way to get access to the socket to update it.</p>
[ { "answer_id": 375000, "author": "monkut", "author_id": 24718, "author_profile": "https://Stackoverflow.com/users/24718", "pm_score": 1, "selected": false, "text": "def timeout(func, args=(), kwargs={}, timeout_duration=1, default=None):\n import threading\n class InterruptableThre...
2008/12/16
[ "https://Stackoverflow.com/questions/372365", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22306/" ]
372,370
<p>How do I take a string in Perl and split it up into an array with entries two characters long each?</p> <p>I attempted this:</p> <pre><code>@array = split(/../, $string); </code></pre> <p>but did not get the expected results.</p> <p>Ultimately I want to turn something like this</p> <pre><code>F53CBBA476 </code></pre> <p>in to an array containing</p> <pre><code>F5 3C BB A4 76 </code></pre>
[ { "answer_id": 372397, "author": "Bill Karwin", "author_id": 20860, "author_profile": "https://Stackoverflow.com/users/20860", "pm_score": 7, "selected": true, "text": "@array = ( $string =~ m/../g );\n" }, { "answer_id": 372762, "author": "mat", "author_id": 42083, "...
2008/12/16
[ "https://Stackoverflow.com/questions/372370", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23/" ]
372,382
<p>I have a simple extension method on the int type so I can do the following:</p> <pre><code>string timeLength = 61.ToTime() // timeLength will be "1:01" </code></pre> <p>This works great in code, but I want to use this extension method in a Repeater Template. When databinding I want to do the following:</p> <pre><code>&lt;%# Eval("LengthInSeconds").ToTime() %&gt; </code></pre> <p>That didn't work so I tried:</p> <pre><code>&lt;%# ((int) Eval("LengthInSeconds")).ToTime() %&gt; </code></pre> <p>and it still didn't work. The JIT compiler is not seeing my extension method and I do have the proper import statement in the page.</p> <p>My only idea for solving this is to replace the Eval with a Literal control and call the extension method in the code-behind, but either way, I would still like to know why this isn't working.</p> <p>Thanks</p>
[ { "answer_id": 372461, "author": "Scott Muc", "author_id": 1894, "author_profile": "https://Stackoverflow.com/users/1894", "pm_score": 4, "selected": true, "text": " <system.codedom>\n <compilers>\n <compiler language=\"c#;cs;csharp\" extension=\".cs\" type=\"Microsoft.CSharp.CS...
2008/12/16
[ "https://Stackoverflow.com/questions/372382", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1894/" ]
372,383
<p>I have a web service (WCF or ASMX doesn't matter)... I have made a Console application, right-clicked, added service referrence. So far, so good.</p> <p>However, I cannot for the life of me pass "security" credentials across to my service. This is my client code:</p> <pre><code>var client = new MyClient(); client.ClientCredentials.UserName.UserName = "bob"; client.ClientCredentials.UserName.Password = "123!!"; client.HelloWorld(); client.Close(); </code></pre> <p>But on the server, no matter what I do (aspnetcompant mode on and off, wcf service, asmx service, custom http handlers, etc)... I can't find 'bob:123!!' anywhere. Not in headers, not in HttpContext.Current.User.Identiy.Name, not in Thread.CurrentPrincipal... nothing.</p> <p>What am I missing here?</p>
[ { "answer_id": 404710, "author": "Yossi Dahan", "author_id": 43541, "author_profile": "https://Stackoverflow.com/users/43541", "pm_score": 0, "selected": false, "text": "ServiceSecurityContext.Current.PrimaryIdentity" }, { "answer_id": 897399, "author": "Community", "auth...
2008/12/16
[ "https://Stackoverflow.com/questions/372383", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11917/" ]
372,399
<p>I have 3 tables, foo, foo2bar, and bar. foo2bar is a many to many map between foo and bar. Here are the contents.</p> <pre><code>select * from foo +------+ | fid | +------+ | 1 | | 2 | | 3 | | 4 | +------+ select * from foo2bar +------+------+ | fid | bid | +------+------+ | 1 | 1 | | 1 | 2 | | 2 | 1 | | 2 | 3 | | 4 | 4 | +------+------+ select * from bar +------+-------+------+ | bid | value | zid | +------+-------+------+ | 1 | 2 | 10 | | 2 | 4 | 20 | | 3 | 8 | 30 | | 4 | 42 | 30 | +------+-------+------+ </code></pre> <p>What I want to request is, "Give me a list of all the fid and values with zid of 30"</p> <p>I expect an answer for all the fids, so the result would look like:</p> <pre><code>+------+--------+ | fid | value | +------+--------+ | 1 | null | | 2 | 8 | | 3 | null | | 4 | 42 | +------+--------+ </code></pre>
[ { "answer_id": 372415, "author": "BCS", "author_id": 1343, "author_profile": "https://Stackoverflow.com/users/1343", "pm_score": 3, "selected": false, "text": "SELECT * FROM\n foo LEFT JOIN\n (\n Foo2bar JOIN bar\n ON foo2bar.bid = bar.bid AND zid = 30\n ...
2008/12/16
[ "https://Stackoverflow.com/questions/372399", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21838/" ]
372,428
<p>I'm working on a very simple game (essentially an ice sliding puzzle), for now the whole things in one file and the only level is completely blank of any form of obstacle. It throws up a few errors. My current annoyance is an expected primary expression error, can anyone tell me how to fix it (it throws up at line 99)?</p> <p>Here's the whole thing,</p> <pre><code>#include &lt;allegro.h&gt; BITMAP* buffer; int x = 15; int y = 11; int tempX = 15; int tempY = 11; //This will be our background, 1 = clouds, 2 = brick, 3 = floor int map[24][32] = {{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1,1,1,2,3,3,3,3,3,3,3,3,3,2,1,1,1,1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1,1,1,2,3,3,3,3,3,3,3,3,3,2,1,1,1,1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1,1,1,2,3,3,3,3,3,3,3,3,3,2,1,1,1,1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1,1,1,2,3,3,3,3,3,3,3,3,3,2,1,1,1,1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1,1,1,2,3,3,3,3,3,3,3,3,3,2,1,1,1,1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1,1,1,2,3,3,3,3,3,3,3,3,3,2,1,1,1,1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1,1,1,2,3,3,3,3,3,3,3,3,3,2,1,1,1,1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1,1,1,2,3,3,3,3,3,3,3,3,3,2,1,1,1,1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1,1,1,2,3,3,3,3,3,3,3,3,3,2,1,1,1,1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}}; //This will contain all the objects, 100 = player int objMap[24][32] = {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}}; void setupGame(){ buffer = create_bitmap( 640, 480); for (int i = 0; i &lt;= 24; i++){ for( int t = 0; t &lt;= 32; t++){ if( map[i][t] == 1) rectfill( buffer, t * 20, i * 20, (t + 1) * 20, (i + 1) * 20, makecol( 128, 255, 255)); else if( map[i][t] == 2) rectfill( buffer, t * 20, i * 20, (t + 1) * 20, (i + 1) * 20, makecol( 255, 128, 0)); else if( map[i][t] == 3) rectfill( buffer, t * 20, i * 20, (t + 1) * 20, (i + 1) * 20, makecol( 0, 0, 255)); } } for (int i = 0; i &lt;= 24; i++){ for( int t = 0; t &lt;= 32; t++){ if( objMap[i][t] == 100) circlefill( buffer, (t * 20) + 10, (i * 20) + 10, 10, makecol( 255, 255, 0)); } } draw_sprite( screen, buffer, 0, 0); } void movePlayer(){ tempX = x; tempY = y; if ( key[KEY_UP] &amp;&amp; map[y - 1][x] == 3){ for ([y - 1][x] == 3; --y){ // these lines are the ones } } else if( key[KEY_DOWN] &amp;&amp; map[y + 1][x] == 3){ for ([y + 1][x] == 3; ++y){ } } else if( key[KEY_RIGHT] &amp;&amp; map[y][x + 1] == 3){ for ([y][x + 1] == 3; ++x){ } } else if( key[KEY_LEFT] &amp;&amp; map[y][x - 1] == 3){ for ([y][x - 1] == 3; --x){ } } acquire_screen(); rectfill( buffer, tempX * 20, tempY * 20, (tempX + 1) * 20, (tempY + 1) * 20, makecol( 255, 0, 0)); circlefill( buffer, (x * 20) + 10, (y * 20) + 10, 10, makecol( 255, 255, 0)); draw_sprite( screen, buffer, 0, 0); release_screen(); rest(20); } int main(){ allegro_init(); install_keyboard(); set_color_depth(16); set_gfx_mode( GFX_AUTODETECT, 640, 480, 0, 0); setupGame(); while( !key[KEY_ESC]){ modePlayer(); } return 0; } END_OF_MAIN(); </code></pre> <p>and here's the section that breaks;</p> <pre><code>void movePlayer(){ tempX = x; tempY = y; if ( key[KEY_UP] &amp;&amp; map[y - 1][x] == 3){ for ([y - 1][x] == 3; --y){ } } else if( key[KEY_DOWN] &amp;&amp; map[y + 1][x] == 3){ for ([y + 1][x] == 3; ++y){ } } else if( key[KEY_RIGHT] &amp;&amp; map[y][x + 1] == 3){ for ([y][x + 1] == 3; ++x){ } } else if( key[KEY_LEFT] &amp;&amp; map[y][x - 1] == 3){ for ([y][x - 1] == 3; --x){ } } </code></pre> <p>it's the for lines it doesn't like.</p> <p>thanks if you can help.</p>
[ { "answer_id": 372457, "author": "Martin York", "author_id": 14065, "author_profile": "https://Stackoverflow.com/users/14065", "pm_score": 2, "selected": false, "text": "for(<init>;<test>;<post>)\n{\n}\n for(; map[BLA][BLA] == <VALUE>;<INC>)\n" }, { "answer_id": 372459, "auth...
2008/12/16
[ "https://Stackoverflow.com/questions/372428", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33061/" ]
372,434
<p>I'm struggling with the following problem. I use the <a href="http://docs.jquery.com/Plugins/Autocomplete/autocomplete" rel="noreferrer">jQuery autocomplete plugin</a> to get a list of suggested values from the server. The list would look like this:</p> <pre> Username1|UserId1 Username2|UserId2 </pre> <p>So if I start typing "U", a list of <code>"Username1"</code> and <code>"Username2"</code> pops up, as expected. I could chose the first item and the <code>&lt;input&gt;</code>'s value would become <code>"Username1"</code>, but what I <em>really</em> want to send to the server is the user ID.</p> <p>Can I somehow get a hold of the ID that is following the user name? I intend to do the form post on change of the text box. Maybe I'm just too blind to see it in the docs or to find it on Google?</p>
[ { "answer_id": 372858, "author": "davidavr", "author_id": 8247, "author_profile": "https://Stackoverflow.com/users/8247", "pm_score": 4, "selected": true, "text": "result autocomplete data[1] $(\"#my_field\").autocomplete(...).result(function(event, data, formatted) {\n if (data) {\n ...
2008/12/16
[ "https://Stackoverflow.com/questions/372434", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18771/" ]
372,446
<p>I'm overthinking this. I have colors stored in a database table, and I want to set the background of specific cells in a table to those colors. In other words:</p> <pre><code>&lt;table&gt; &lt;tr&gt; &lt;td ???set color here???&gt; ...content... &lt;/td&gt; &lt;td ???next color here???&gt; ...next content... &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>Originally I had Panels surrounding each piece of content and I set their background color in the code-behind, which worked fine until I had varying size panels, which threw off the layout. What's the easiest way to feed the color values from the database to the <code>&lt;td&gt;</code> element? Note that the colors are user-configurable, so I can't have them pre-defined in a CSS file.</p>
[ { "answer_id": 372479, "author": "Diodeus - James MacFarlane", "author_id": 12579, "author_profile": "https://Stackoverflow.com/users/12579", "pm_score": 0, "selected": false, "text": ".dark {\n background-color:[database field]\n}\n\n<td class='dark'></td>\n" }, { "answer_id":...
2008/12/16
[ "https://Stackoverflow.com/questions/372446", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23935/" ]
372,462
<p>I've setup a reverse ssh tunnel, using PuTTY, to allow me to VNC into a home computer without having to enable NAT port forwarding. Works great, no problem.</p> <p>I would like to set the tunnel up as a "persistent service" that will connect on boot up and reconnect when dropped. PS. this is on Windows.</p> <p>Exhaustive googling found a few products but many seem to have been abandoned and none appear to have major "street cred." </p> <ul> <li><a href="http://llemarie.wordpress.com/2007/11/25/programming-eztunnel-ssh-port-forwarding-made-easy/" rel="noreferrer">eztunnel ssh</a> </li> <li><a href="http://www.easyvbapps.com/2008/07/03/easytunnel-21-out-now/comment-page-1" rel="noreferrer">Easy Tunnel</a></li> <li><a href="http://www.softpedia.com/get/Others/Miscellaneous/SSH-Tunnel.shtml" rel="noreferrer">SSH Tunnel</a></li> <li><a href="http://jclement.ca/software/ptunnel/" rel="noreferrer">Persistent Tunnel</a></li> <li><a href="http://nemesis2.qx.net/software-myentunnel.php" rel="noreferrer">MyEnTunnel</a></li> <li><a href="http://callinghome.sourceforge.net/files.html" rel="noreferrer">Calling Home</a></li> </ul> <p>Does anyone have experience with this type of thing or with any of these products? I don't need all the bells and whistles, just reliability.</p>
[ { "answer_id": 13023780, "author": "Simon B.", "author_id": 296639, "author_profile": "https://Stackoverflow.com/users/296639", "pm_score": 1, "selected": false, "text": " :: This is a batch file. Save with file name: plink_forever.bat\n :restart\n plink saved_session_name\n goto res...
2008/12/16
[ "https://Stackoverflow.com/questions/372462", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34888/" ]
372,465
<p>How would I only allow users authenticated via Python code to access certain files on the server?</p> <p>For instance, say I have <code>/static/book.txt</code> which I want to protect. When a user accesses <code>/some/path/that/validates/him</code>, a Python script deems him worthy of accessing <code>/static/book.txt</code> and redirects him to that path.</p> <p>How would I stop users who bypass the script and directly access <code>/static/book.txt</code>?</p>
[ { "answer_id": 13023780, "author": "Simon B.", "author_id": 296639, "author_profile": "https://Stackoverflow.com/users/296639", "pm_score": 1, "selected": false, "text": " :: This is a batch file. Save with file name: plink_forever.bat\n :restart\n plink saved_session_name\n goto res...
2008/12/16
[ "https://Stackoverflow.com/questions/372465", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
372,474
<p>Using Visual Studio 2005 with default install of Crystal Reports.</p> <p>When I create a report, Crystal asks for the database, and I give it my development db. In the app, I create a DataTable and pass it to the report, which is then handed to the CR Viewer. At runtime, neither the report object, nor the viewer need to see the db since I have already retrieved the table.</p> <p>When the app is handed to the users, everything works fine. They cannot see the development db.</p> <p>Once, in the production office, I created a report at the production site, and instead of creating the Crystal Report by specifying the development db, I gave it the production db. Back in my own office, running in VS, the report tries to connect to the development db, and fails. (It's not visible.)</p> <p>So, it's not a problem that they can't see my development database, but it is a problem that I can't see the production database. </p> <p>Questions are: Does this arise because running in VS is different from running the installed app? Why does the report try to connect to the DB anyway? How do I control it?</p>
[ { "answer_id": 23648885, "author": "E R", "author_id": 3493685, "author_profile": "https://Stackoverflow.com/users/3493685", "pm_score": 0, "selected": false, "text": "'Build a SQL statement to query for the authors table \n\nDim sqlString As String = \"SELECT * FROM authors\"\n\n'Retrie...
2008/12/16
[ "https://Stackoverflow.com/questions/372474", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19267/" ]
372,475
<p>My requirement is to develop a page with 4 sections, which cannot have a postback. Section 1. Content which can be changed on user click Section 2. List of users viewing the page online (Auto update when user leaves or visits the page ) Section 3. Chat for the users online Section 4. Rating the content and other functionality for Section 1</p> <p>Please advise me how to go about it ? Also let me know if there are other easy options in this scenario. One of the options considered was GWT, dropped due to the fact that entire application is being developed in .nET</p> <p>Any help regarding this will be highly appreciated. Freelancers willing to work on this will be highly rewarded. </p>
[ { "answer_id": 23648885, "author": "E R", "author_id": 3493685, "author_profile": "https://Stackoverflow.com/users/3493685", "pm_score": 0, "selected": false, "text": "'Build a SQL statement to query for the authors table \n\nDim sqlString As String = \"SELECT * FROM authors\"\n\n'Retrie...
2008/12/16
[ "https://Stackoverflow.com/questions/372475", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46795/" ]
372,484
<p>I'm writing cross platform C++ code (Windows, Mac). Is there a way to check how much memory is in use by the current process? A very contrived snippet to illustrate:</p> <pre><code>unsigned long m0 = GetMemoryInUse(); char *p = new char[ random_number ]; unsigned long m1 = GetMemoryInUse(); printf( "%d bytes used\n", (m1-m0) ); </code></pre> <p>Of course (m1-m0) should equal random_number, but I'm trying to do this on a more complicated level, including possible library calls that could allocate memory.</p> <p>The following are not preferable:</p> <ol> <li>Use Valgrind (or its ilk) </li> <li>Use a custom memory allocator to track allocated memory.</li> </ol>
[ { "answer_id": 372525, "author": "Larry Gritz", "author_id": 3832, "author_profile": "https://Stackoverflow.com/users/3832", "pm_score": 4, "selected": false, "text": "#ifdef __linux__\n# include <sys/sysinfo.h>\n#endif\n\n#ifdef __APPLE__\n# include <mach/task.h>\n# include <mach/mach_i...
2008/12/16
[ "https://Stackoverflow.com/questions/372484", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4065/" ]
372,506
<p>In Git, how could I search for a file or directory by path across a number of branches?</p> <p>I've written something in a branch, but I don't remember which one. Now I need to find it.</p> <p><strong>Clarification</strong>: I'm looking for a file which I created on one of my branches. I'd like to find it by path, and not by its contents, as I don't remember what the contents are.</p>
[ { "answer_id": 372654, "author": "ididak", "author_id": 28888, "author_profile": "https://Stackoverflow.com/users/28888", "pm_score": 6, "selected": false, "text": "for branch in `git for-each-ref --format=\"%(refname)\" refs/heads`; do\n echo $branch :; git ls-tree -r --name-only $bran...
2008/12/16
[ "https://Stackoverflow.com/questions/372506", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4937/" ]
372,547
<p>A recent <a href="https://stackoverflow.com/questions/372354/string-immutability">question about string literals</a> in .NET caught my eye. I know that string literals are <a href="http://en.wikipedia.org/wiki/String_intern_pool" rel="noreferrer">interned</a> so that different strings with the same value refer to the same object. I also know that a string can be interned at runtime:</p> <pre><code>string now = DateTime.Now.ToString().Intern(); </code></pre> <p>Obviously a string that is interned at runtime resides on the heap but I had assumed that a literal is placed in the program's data segment (and said so in my <a href="https://stackoverflow.com/questions/372354/string-immutability#372380">answer</a> to said question). However I don't remember seeing this anywhere. I assume this is the case since it's how I would do it and the fact that the <code>ldstr</code> IL instruction is used to get literals and no allocation seems to take place seems to back me up.</p> <p>To cut a long story short, where do string literals reside? Is it on the heap, the data segment or some-place I haven't thought of?</p> <hr> <p><strong>Edit:</strong> If string literals <em>do</em> reside on the heap, when are they allocated? </p>
[ { "answer_id": 372559, "author": "Brian Rasmussen", "author_id": 38206, "author_profile": "https://Stackoverflow.com/users/38206", "pm_score": 8, "selected": true, "text": " class SomeType {\n public void Foo() {\n string s = \"hello world\";\n Console.WriteLine(s)...
2008/12/16
[ "https://Stackoverflow.com/questions/372547", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3848/" ]
372,557
<p>Please bear with me: this isn't a language debate or a flame. It's a real request for opinions.</p> <p>Occasionally, I have to help educate a traditional text coder in how to think in LabVIEW (LV). Often during this process, I get to hear about how LV sucks. Rarely is this insight accompanied by rational observations other than "Language X is just so much better!". While this statement is satisfying to them, it doesn't help me understand what is frustrating them.</p> <p>So, for those of you with LabVIEW <em>and</em> text language experience, what <strong>specific</strong> things about LV drive you nuts?</p> <p>------ Summaries -------</p> <p>Thanks for all the answers! Some of the issues are answered in the comments below, some exist on other sites, and some are just genuine problems with LV. In the spirit of the original question, I'm not going to try to answer all of these here: check <a href="http://www.lavag.org" rel="noreferrer">LAVA</a> or <a href="http://www.ni.com/labview" rel="noreferrer">NI</a>'s website, and you'll be pleasantly surprised at how many of these things can be overcome.</p> <ul> <li>Unintentional concurrency</li> <li>No access to tradition text manipulation tools</li> <li>Binary-only source code control</li> <li>Difficult to branch and merge</li> <li>Too many open windows</li> <li>Text has cleaner/clearer/more expressive syntax</li> <li>Clean coding requires a lot of time and manipulation</li> <li>Large, difficult to access API/palette system</li> <li>Mouse required</li> <li>File namespacing: no duplicate files with the same name in memory</li> <li>LV objects are natively by-value only</li> <li>Requires dev environment to view code</li> <li>Lack of zoom</li> <li>Slow startup</li> <li>Memory pig</li> <li>"Giant" code is difficult to work with</li> <li>UI lockup is easy to do</li> <li>Trackpads and LV don't mix well</li> <li>String manipulation is graphically bloated</li> <li>Limited UI customization</li> <li>"Hidden" primitives (yes, these exist)</li> <li>Lack of official metaprogramming capability (not for much longer, though)</li> <li>Lack of unicode support</li> </ul>
[ { "answer_id": 433449, "author": "CharlesB", "author_id": 11343, "author_profile": "https://Stackoverflow.com/users/11343", "pm_score": 4, "selected": false, "text": "if error return; else do stuff" } ]
2008/12/16
[ "https://Stackoverflow.com/questions/372557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3696/" ]
372,561
<p>I have an app that is a combination of asp/asp.net, and both sides depend on the same cookies (they are in the same domain). There are some values in the cookies that I don't want going to the client anymore due to security concerns. What I was hoping to accomplish is to take out these values so they no longer go to the client, and then on every server request, somehow "inject" the values back into the cookie so the app will still function properly.</p> <p>Is this even possible? I thought it might be through ISAPI, but I don't know c++ to well.</p>
[ { "answer_id": 433449, "author": "CharlesB", "author_id": 11343, "author_profile": "https://Stackoverflow.com/users/11343", "pm_score": 4, "selected": false, "text": "if error return; else do stuff" } ]
2008/12/16
[ "https://Stackoverflow.com/questions/372561", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30488/" ]
372,569
<p>I'm just getting started/familar with Subversion and was wondering which protocol gives the best performance file:// or svn://, when accessing a Subversion repository over the network? If we don't use the svn:// protocol, will be missing out on any features that we couldn't mitgate using the file:// protocol? We're all on the same NT domain &amp; plan on using Windows Auth and use NTFS/UNC security.</p> <p>TIA!</p>
[ { "answer_id": 390069, "author": "Mike Miller", "author_id": 16138, "author_profile": "https://Stackoverflow.com/users/16138", "pm_score": 1, "selected": false, "text": "svn relocate" } ]
2008/12/16
[ "https://Stackoverflow.com/questions/372569", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46809/" ]
372,572
<p>A requirement for my application is if it looses database connectivity then it must pop up a big modal "No Connection. Try again later" dialog blocking all user interaction until such time that connectivity is regained.</p> <p>I achieve this by at the start of the application starting an instance of a DeviceMonitor class. This class creates a System.Threading.Timer and every Tick (usually 1 second) along with a few other things it tries to draw data from the database. If the draw fails and the cause is determined to be due to a lack of connectivity, the exception is handled by popping up the aforementioned dialog. Likewise, if the data fetch succeeds and the dialog is currently up hen it is forced closed.</p> <p>The problem is that although this all works fine, the ConnectionLost dialog does not block the user from interacting with the UI. This makes sense, since the Timer.Elapsed event is raised within its own thread and noConnectionDialog.ShowDialog() is called from within the callback it blocks the thread it is on but not the UI Thread.</p> <p>To my understanding I need to either force the noConnectionDialog.ShowDialog() to run within the UI thread or to block the UI thread until noConnectionDialog.Hide() is called but I don't know how to do either. </p> <p>Perhaps there is some other remedy or I am missing something here. Any advice is appreciated.</p> <p><strong>EDIT:</strong> Further information - this is a stylized dialog, not just a messagebox. It is being created when my application starts by Castle Windsor and injected into a DialogFactory class which gets passed around. The dialog is therefore accessed by </p> <pre><code>var d = _dialogFactory.GetNoConnectionDialog(); d.ShowDialog(); </code></pre> <p>I have experimented with putting this code outside of the timer elapsed callback - when a button on UI interface is clicked for example - and it blocks the UI just fine from there so this is not a matter of where the form is created.</p>
[ { "answer_id": 372574, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 1, "selected": false, "text": "someControl.Invoke((Action)delegate {\n MessageBox.Show(someControl, \"Foo\");\n // could also show a form here...
2008/12/16
[ "https://Stackoverflow.com/questions/372572", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5056/" ]
372,580
<p>Visual Studio syntax highlighting colors this word blue as if it were a keyword or reserved word. I tried searching online for it but the word "array" throws the search off, I get mostly pages explaining what an array is. What is it used for?</p>
[ { "answer_id": 25519643, "author": "phuclv", "author_id": 995714, "author_profile": "https://Stackoverflow.com/users/995714", "pm_score": 0, "selected": false, "text": "__int64 __int128" } ]
2008/12/16
[ "https://Stackoverflow.com/questions/372580", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46811/" ]
372,581
<p>When I try to programmatically access a Word object model, I get an error saying no document is active. This appears to be because I am loading the document as not visible using Word automation, and I have to keep it invisible.</p> <p>How would I code the open macro so that it does nothing in this case? </p> <p><code>If Not ActiveDocument is Nothing Then</code></p> <p>didn't work.</p> <pre><code>Private Sub Document_Open() If (ActiveDocument.SaveFormat = wdFormatRTF) Then 'Do some stuff End If End Sub </code></pre>
[ { "answer_id": 372677, "author": "Dirk Vollmar", "author_id": 40347, "author_profile": "https://Stackoverflow.com/users/40347", "pm_score": 1, "selected": false, "text": "dim word as new Word.Application\ndim doc as Word.Document\n\ndoc = word.Documents.Open(fileName)\nMsgBox doc.FullNam...
2008/12/16
[ "https://Stackoverflow.com/questions/372581", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4066/" ]
372,589
<p>I was wondering if something exists (in Java world) able to take an snapshot of the JVM current state with the following features:</p> <ul> <li>Do it while an exception is being thrown.</li> <li>Capture local variables, method's arguments, etc.</li> <li>Put it in a handy file which can be used to extract or reproduce in a IDE the situation in your source code.</li> </ul> <p>The two first features are required (third would be awesome). And it must be suitable for production use (so, there is no way about debuggers).</p> <p>Before asking this I've searched through the WWW (as long as possible) and I found some pointers:</p> <ul> <li><a href="http://www.cajoon.com" rel="nofollow noreferrer">Cajoon Interceptor</a>: As said in <a href="http://www.dzone.com/links/java_production_errors_rapid_resolution.html" rel="nofollow noreferrer">Dzone post</a>, it's a passive JVM agent which fulfill the three requirements! But, it has two downsides: you must pay for it and the site is down (maybe there is no chance to pay anything).</li> <li><a href="http://www.avicode.com/" rel="nofollow noreferrer">AviCode Intercept Studio</a>: Cajoon's .NET equivalent. Just to give some insight about.</li> <li><a href="http://twitter.com/thobe/status/1012650896" rel="nofollow noreferrer">JavaFrame</a>: Ok, it's a tweet, but it points to a available SVN repo which have the source code (under MIT license) of a JVM agent which looks fine (I'm going to give a try to it).</li> </ul> <p>So, maybe I'm looking for a non existent solution? It's not urgent, but I had this idea for a project and it would be great to explore this "unknown" (?) path and get something real.</p> <p>It seems to be clear that it would be a JVM agent (exception event from JVMTI, for <a href="http://java.sun.com/developer/technicalArticles/Programming/jvmti/" rel="nofollow noreferrer">example</a>).</p> <p>At last, I would highlight the followin paragraph from <a href="http://en.wikipedia.org/wiki/Exception_handling" rel="nofollow noreferrer">Wikipedia's Exception Handling article</a>:</p> <blockquote> <p>In runtime engine environments such as Java or .NET, there exist tools that attach to the runtime engine and every time that an exception of interest occurs, they record debugging information that existed in memory at the time the exception was thrown (call stack and heap values). These tools are called Automated Exception Handling or Error Interception tools and provide 'root-cause' information for exceptions.</p> </blockquote> <p>That's the idea. I hope somebody can give me some insight or maybe, in the future, somebody get inspired by this humble post :)</p> <p>Thanks!</p>
[ { "answer_id": 378902, "author": "Dario", "author_id": 11583, "author_profile": "https://Stackoverflow.com/users/11583", "pm_score": 3, "selected": true, "text": "ant LD_LIBRARY_PATH=../build/native/ java -agentlib:frameintrospect -classpath ../build/classes/:. org.thobe.frame.Test\n" ...
2008/12/16
[ "https://Stackoverflow.com/questions/372589", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11583/" ]
372,601
<p>I'm using a <code>DateTime</code> in C# to display times. What date portion does everyone use when constructing a time?</p> <p>E.g. the following is not valid because there is no zero-th month or zero-th day:</p> <pre><code>// 4:37:58 PM DateTime time = new DateTime(0, 0, 0, 16, 47, 58); </code></pre> <p>Do I use COM's zero date?</p> <pre><code>// 4:37:58 PM DateTime time = new DateTime(1899, 12, 30, 16, 47, 58); </code></pre> <p>Or perhaps SQL Server's?</p> <pre><code>//4:37:58 PM DateTime time = new DateTime(1900, 1, 1, 16, 47, 58); </code></pre> <p>I realize it's arbitrary, since I'll be ignoring the date portions in code, but it would still be nice to be able to use:</p> <pre><code>DateTime duration = time2 - time1; </code></pre> <hr> <h1>Answer</h1> <p>I think I like <strong>MinValue</strong></p> <pre><code> DateTime time = DateTime.MinValue.Date.Add(new TimeSpan(16, 47, 58)); </code></pre> <hr> <p><strong>Note:</strong> I can't use a <code>TimeSpan</code>, because that doesn't store times of the day. And the reason I know that is because there's no way to display its contents as a time.</p> <p>Which is to say that <code>TimeSpan</code> records a <em>span of time</em>, not a <em>time of day</em>, e.g.:</p> <pre><code>TimeSpan t = new TimeSpan(16, 47, 58); t.ToString(); </code></pre> <p>returns a span of time in the format <em>hours</em>:<em>minutes</em>:<em>seconds</em>, e.g.:</p> <pre><code>16:47:58 </code></pre> <p>rather than a time:</p> <pre><code>4:47:58 PM (United States) 04:47:58 nm (South Africa) 4:47:58.MD (Albania) 16:47:58 (Algeria) 04:47:58 م (Bahrain) PM 4:47:58 (Singapore) 下午 04:47:58 (Taiwan) 04:47:58 PM (Belize) 4:47:58 p.m. (New Zealand) 4:47:58 μμ (Greece) 16.47.58 (Italy) 오후 4:47:58 (Korea) 04:47:58 ب.ظ (Iran) ਸ਼ਾਮ 04:47:58 (India) 04:47:58 p.m. (Argentina) etc </code></pre> <p>In other words, there is a difference between a timespan, and a time. And also realize that <code>TimeSpan</code> doesn't provide a mechanism to convert a span of time into a time of day - and there is a reason for that.</p>
[ { "answer_id": 372617, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 2, "selected": false, "text": "DateTime.Now.TimeOfDay TimeSpan TimeSpan TimeSpan" }, { "answer_id": 372629, "author": "Joel Coehoorn", ...
2008/12/16
[ "https://Stackoverflow.com/questions/372601", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12597/" ]
372,604
<p>what is the code to disable an INPUT text box for HTML?</p> <p>Thanks</p>
[ { "answer_id": 372615, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 7, "selected": true, "text": "<input type=\"text\" disabled=\"disabled\" />\n" }, { "answer_id": 372616, "author": "fasih.rana", "author_id"...
2008/12/16
[ "https://Stackoverflow.com/questions/372604", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44973/" ]
372,631
<p>I'm looking for suggestions on how to inject runtime dependencies into JPA entities retrieved from Hibernate. My problem is essentially this:</p> <p>I have a number of different subclasses of a Transaction object. Each Transaction subclass has different behavior when it is executed, and requires a different set of dependencies from the environment. These Transaction objects are managed as JPA entities by Hibernate, so I can't effectively use Guice for dependency injection to populate the instances with their environmental dependencies as I do in the rest of my application.</p> <p>To get around this problem, I've taken an approach that's somewhat akin to the Visitor pattern, as follows:</p> <pre><code>public abstract class Transaction { // ...snip... public abstract void apply(Transactor transactor); } public class TransactionA extends Transaction { public void apply(Transactor transactor) { transactor.execute(this); } } public class TransactionB extends Transaction { public void apply(Transactor transactor) { transactor.execute(this); } } // other Transaction subclasses with the same boilerplate public interface Transactor { public void execute(TransactionA trans); public void execute(TransactionB trans); // corresponding methods for other transaction types. } public class BeginTransactor { @Inject private Foo execAdep; public void execute(TransactionA trans) { execAdep.doSomething(...) } @Inject private Bar execBdep; public void execute(TransactionB trans) { execBdep.doOther(...) } } </code></pre> <p>I have various implementations of Transactor for different parts of the transaction lifecycle. These can be dependency-injected using Guice into the context in which I want to process the transactions, where I simply call:</p> <pre><code> Transactor transactor = injector.getInstance(BeginTransactor.class); //Guice injection Transaction t = ... //get a transaction instance t.apply(transactor); </code></pre> <p>What I don't like about this approach is (1) Not every type of transaction should be executable in each lifecycle phase, but every Transactor must implement an execute() method for every transaction subclass and (2) Essentially none of the injected dependencies are used for processing more than one transaction type.</p> <p>Essentially, my Transactor interface &amp; implementations have a lot of unrelated crud glopped together. Ideally I'd just have the execute() method on the transaction object itself, but I don't want the calling code to have to know about the type of the Transaction or the dependencies that it requires. Also, this could make testing harder because I couldn't easily mock out the execute() method if it were a concrete method on the Transaction object. Using the Transactor interface means that I can easily mock it out as needed.</p> <p>Can anyone suggest how to address this problem in a typesafe manner that doesn't result in a bunch of mostly-unrelated behavior being glommed together in the Transactor, but keeps the testability and allows for dependency injection?</p>
[ { "answer_id": 373381, "author": "SamBeran", "author_id": 43379, "author_profile": "https://Stackoverflow.com/users/43379", "pm_score": 4, "selected": true, "text": "class BusinessLogic {\n @Inject public EntityManager em;\n\n @Transactional\n publc void doSomething() {\n ...
2008/12/16
[ "https://Stackoverflow.com/questions/372631", "https://Stackoverflow.com", "https://Stackoverflow.com/users/390636/" ]
372,652
<p>I have recently learned the Ruby programming language, and all in all it is a good language. But I was quite surprised to see that it was not as simple as I had expected. More precisely, the "rule of least-surprise" did not seem very respected to me (of course this is quite subjective). For example:</p> <pre><code>x = true and false puts x # displays true! </code></pre> <p>and the famous:</p> <pre><code>puts "zero is true!" if 0 # zero is true! </code></pre> <p>What are the other "Gotchas" you would warn a Ruby newbie about?</p>
[ { "answer_id": 372669, "author": "John Topley", "author_id": 1450, "author_profile": "https://Stackoverflow.com/users/1450", "pm_score": 2, "selected": false, "text": "\\n" }, { "answer_id": 372727, "author": "Dan Vinton", "author_id": 21849, "author_profile": "https:...
2008/12/16
[ "https://Stackoverflow.com/questions/372652", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38626/" ]
372,655
<p>Is it possible to use 2 CSS classes that have the same name for the selectors, etc. in the same HTML file? If so, how do you differentiate between the two when styling elements?</p>
[ { "answer_id": 372662, "author": "scunliffe", "author_id": 6144, "author_profile": "https://Stackoverflow.com/users/6144", "pm_score": 0, "selected": false, "text": "<style>\n .foo{\n border:1px solid blue;\n color:red;\n }\n .foo{\n border:4px solid orange;\n }\n</style>\n<...
2008/12/16
[ "https://Stackoverflow.com/questions/372655", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33690/" ]
372,660
<p>Considering you have an MVVM Architecture in WPF like <a href="http://joshsmithonwpf.wordpress.com/2008/11/14/using-a-viewmodel-to-provide-meaningful-validation-error-messages/" rel="nofollow noreferrer">Josh Smith's examples</a></p> <p>How would you implement two properties 'synced' that update eachother? I have a Price property, and a PriceVatInclusive property in my model. </p> <p>-When the Price changes, I want to see the Vat inclusive price to automatically be 'Price * 1.21'. </p> <p>-Vice versa, when the PriceVatInclusive changes, I want the Price to be 'PriceVatInclusive / 1.21'</p> <p>Any ideas on that?</p> <p>And what if your model is a Entity framework entiry? You can't use the approach above then... no? Should you put calculating code in the ViewMOdel or ... ?</p>
[ { "answer_id": 372682, "author": "Szymon Rozga", "author_id": 7583, "author_profile": "https://Stackoverflow.com/users/7583", "pm_score": 3, "selected": true, "text": " public class Sample : INotifyPropertyChanged\n {\n private const double Multiplier = 1.21;\n #regio...
2008/12/16
[ "https://Stackoverflow.com/questions/372660", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26579/" ]
372,664
<p>I have an html table which i bind data dynamically on the server side in C#.. The problem is that I have a search button that calls a search on the DB(in a search method on the server side) based on the information from the client page. this search method loads the info from the DB and updates the html table(this is where the information is binded dynamically) </p> <pre><code>for (int i = 0; i &lt; data.Count; i++) { FirstCell.Controls.Add(lbl1); SecondCell.Controls.Add(lbl2); ThirdCell.Controls.Add(lbl3); row.Cells.Add(FirstCell); row.Cells.Add(SecondCell); row.Cells.Add(ThirdCell); Table.Rows.Add(row); } </code></pre> <p>... and after this is done I store the loaded objects from the DB in a session variable like: Session{"data"]=data;</p> <p>my question is how do I display the html table with a certain number of records per page with the page's indexes at the bottom of the view page below the table? And as I iterate through the pages keep the data viewable and not lost? I am not trying to use ASP.net data controls!!!</p>
[ { "answer_id": 372682, "author": "Szymon Rozga", "author_id": 7583, "author_profile": "https://Stackoverflow.com/users/7583", "pm_score": 3, "selected": true, "text": " public class Sample : INotifyPropertyChanged\n {\n private const double Multiplier = 1.21;\n #regio...
2008/12/16
[ "https://Stackoverflow.com/questions/372664", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39809/" ]
372,665
<p>Given a class like this:</p> <pre><code>class Foo { public: Foo(int); Foo(const Foo&amp;); Foo&amp; operator=(int); private: // ... }; </code></pre> <p>Are these two lines exactly equivalent, or is there a subtle difference between them?</p> <pre><code>Foo f(42); Foo f = 42; </code></pre> <hr> <p>Edit: I confused matters by making the Foo constructor "explicit" in the original question. I've removed that, but appreciate the answers.</p> <p>I've also added declaration of a copy constructor, to make it clear that copying may not be a trivial operation.</p> <p>What I really want to know is, according to the C++ standard, will "Foo f = 42" directly call the Foo(int) constructor, or is the copy constructor going to be called?</p> <p>It looks like fasih.ahmed has the answer I was looking for (unless it's wrong).</p>
[ { "answer_id": 372673, "author": "fasih.rana", "author_id": 46024, "author_profile": "https://Stackoverflow.com/users/46024", "pm_score": 4, "selected": true, "text": "Foo f = 42;\n Foo f(42);\n" }, { "answer_id": 372723, "author": "Johannes Schaub - litb", "author_id": 3...
2008/12/16
[ "https://Stackoverflow.com/questions/372665", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1175/" ]
372,686
<p>I understand that I can specify system properties to Tomcat by passing arguments with the -D parameter, for example "<strong>-Dmy.prop=value</strong>".</p> <p>I am wondering if there is a cleaner way of doing this by specifying the property values in the context.xml file or some other tomcat configuration file. I would like to do this because, first, it is easier to keep track of my properties, and second, I have multiple contexts running and I don't know how I would specify context-specific properties through the -D parameter.</p> <p>I am using Tomcat version 5.5.</p>
[ { "answer_id": 376827, "author": "cliff.meyers", "author_id": 41754, "author_profile": "https://Stackoverflow.com/users/41754", "pm_score": 5, "selected": true, "text": "<env-entry>\n <env-entry-name>SMTP_PASSWORD</env-entry-name>\n <env-entry-type>java.lang.String</env-entry-type>...
2008/12/16
[ "https://Stackoverflow.com/questions/372686", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45856/" ]
372,693
<p>I have a configuration file where a developer can specify a text color by passing in a string:</p> <pre><code> &lt;text value="Hello, World" color="Red"/&gt; </code></pre> <p>Rather than have a gigantic switch statement look for all of the possible colors, it'd be nice to just use the properties in the class System.Drawing.Brushes instead so internally I can say something like:</p> <pre><code> Brush color = Brushes.Black; // Default // later on... this.color = (Brush)Enum.Parse(typeof(Brush), prasedValue("color")); </code></pre> <p>Except that the values in Brush/Brushes aren't enums. So Enum.Parse gives me no joy. Suggestions?</p>
[ { "answer_id": 372704, "author": "leppie", "author_id": 15541, "author_profile": "https://Stackoverflow.com/users/15541", "pm_score": -1, "selected": false, "text": "TypeConverter var tc = TypeDescriptor.GetConverter(typeof(Brush));\n SystemBrushes" }, { "answer_id": 372707, ...
2008/12/16
[ "https://Stackoverflow.com/questions/372693", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8173/" ]
372,695
<p>Does anyone know if there's a de-facto standard (i.e., TR1 or Boost) C++ function object for accessing the elements of a std::pair? Twice in the past 24 hours I've wished I had something like the <code>keys</code> function for Perl hashes. For example, it would be nice to run std::transform on a std::map object and dump all the keys (or values) to another container. I could certainly write such a function object but I'd prefer to reuse something that's had a lot of eyeballs on it.</p>
[ { "answer_id": 372720, "author": "Head Geek", "author_id": 12193, "author_profile": "https://Stackoverflow.com/users/12193", "pm_score": 2, "selected": false, "text": "boost::tie std::pair" }, { "answer_id": 372922, "author": "Johannes Schaub - litb", "author_id": 34509, ...
2008/12/16
[ "https://Stackoverflow.com/questions/372695", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46821/" ]
372,696
<p>When I inserted text from one SQL Server VARCHAR(MAX) field in one database to another, I get question mark symbols - "?" - in the target database (in addition to line feeds) whenever there are line feeds in the source database.</p> <p>Text in the target database looks like this:</p> <p>Line one.?<br> ?<br> Line two.?<br> ?</p> <p>Any ideas about what could cause this, and how to fix it? </p>
[ { "answer_id": 372720, "author": "Head Geek", "author_id": 12193, "author_profile": "https://Stackoverflow.com/users/12193", "pm_score": 2, "selected": false, "text": "boost::tie std::pair" }, { "answer_id": 372922, "author": "Johannes Schaub - litb", "author_id": 34509, ...
2008/12/16
[ "https://Stackoverflow.com/questions/372696", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
372,700
<p>I notice that get/set is not the c++ way as far as I can tell by looking at boost/stl, and even reading the writings of some of the top c++ experts.</p> <p>Does anyone use get/set in their c++ class design, and can someone suggest a rule of thumb on where if at all this paradigm belongs in the c++ world?</p> <p>It is obviously very popular in Java, and imitated by c# using Property syntactic sugar.</p> <p>EDIT:</p> <p>Well after reading more about this in one of the links provided in an answer below, I came across at least one argument for keeping the accessors of a member field the same name as the member field. Namely that you could simply expose the member field as public, and instead make it an instance of a class, and then overload the () operator. By using set/get, you'd force clients to not only recompile, but to actually change their code. </p> <p>Not sure I love the idea, seems a bit too fine grained to me, but more details are here:</p> <p><a href="http://www.kirit.com/C%2B%2B%20killed%20the%20get%20%26%20set%20accessors" rel="noreferrer">C++ Killed the Getter/Setter</a></p>
[ { "answer_id": 372740, "author": "Evan Teran", "author_id": 13430, "author_profile": "https://Stackoverflow.com/users/13430", "pm_score": 1, "selected": false, "text": "int x = o->x() // getter\no->setX(5); // setter\n" }, { "answer_id": 372800, "author": "pyon", "author_...
2008/12/16
[ "https://Stackoverflow.com/questions/372700", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44996/" ]
372,703
<p>I would like to store log4net config data in my application.config file. Based on my understanding of the documentation, I did the following:</p> <ol> <li><p>Add a reference to log4net.dll</p></li> <li><p>Add the following line in AssemblyInfo.cs: </p> <pre><code>[assembly: log4net.Config.XmlConfigurator(Watch = true)] </code></pre></li> <li><p>Initialize the logger as follows:</p> <pre><code>private static readonly ILog log = LogManager.GetLogger(typeof(frmWizard)); </code></pre></li> <li><p>I have the following code in my app.config:</p></li> </ol> <pre class="lang-xml prettyprint-override"><code> &lt;configSections&gt; &lt;section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" /&gt; &lt;/configSections&gt; &lt;log4net&gt; &lt;appender name="EventLogAppender" type="log4net.Appender.EventLogAppender" &gt; &lt;layout type="log4net.Layout.PatternLayout"&gt; &lt;conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" /&gt; &lt;/layout&gt; &lt;/appender&gt; &lt;root&gt; &lt;level value="INFO" /&gt; &lt;appender-ref ref="ConsoleAppender" /&gt; &lt;/root&gt; &lt;/log4net&gt; </code></pre> <p>However, when I run the application, I get the following error on the console: </p> <blockquote> <p>No appender named [Consoleappender] could be found.</p> </blockquote> <p>How can I get log4net to read settings from the config file?</p> <p>Thanks!</p>
[ { "answer_id": 372725, "author": "Joachim Kerschbaumer", "author_id": 20227, "author_profile": "https://Stackoverflow.com/users/20227", "pm_score": 2, "selected": false, "text": "configsection <section name=\"log4net\" type=\"log4net.Config.Log4NetConfigurationSectionHandler, log4net\"/>...
2008/12/16
[ "https://Stackoverflow.com/questions/372703", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29726/" ]
372,714
<p>So I have this code for these Constructors of the Weapon class:</p> <pre><code>Weapon(const WeaponsDB * wepDB); Weapon(const WeaponsDB * wepDB_, int * weaponlist); ~Weapon(void); </code></pre> <p>And I keep getting an error:</p> <pre><code>1&gt;c:\users\owner\desktop\bosconian\code\bosconian\weapon.h(20) : error C2062: type 'int' unexpected </code></pre> <p>and ensuing errors (more than listed):</p> <pre><code>1&gt;c:\users\owner\desktop\bosconian\code\bosconian\weapon.h(21) : error C2059: syntax error : '(' 1&gt;c:\users\owner\desktop\bosconian\code\bosconian\weapon.h(21) : error C2238: unexpected token(s) preceding ';' 1&gt;c:\users\owner\desktop\bosconian\code\bosconian\weapon.h(33) : error C2327: '&lt;unnamed-tag&gt;::maxWeapons' : is not a type name, static, or enumerator 1&gt;c:\users\owner\desktop\bosconian\code\bosconian\weapon.h(33) : error C2065: 'maxWeapons' : undeclared identifier 1&gt;c:\users\owner\desktop\bosconian\code\bosconian\weapon.h(38) : warning C4094: untagged 'class' declared no symbols </code></pre> <p>I'm a semi-newbie and I haven't been able to figure it out.</p> <p>Line 21 is the second constructor, the first one doesn't cause an error. Also, if I comment out this constructor I still get all the errors listed after that constructors. Any idea what the problem might be?</p> <p>Here is the preceding code for reference:</p> <pre><code>#ifndef Weapon #define Weapon #include &lt;allegro.h&gt; #include &lt;stdio.h&gt; #include &lt;iostream&gt; using namespace std; class WeaponsDB; class MenuDriver; class Ammo; class Weapon { public: ..... </code></pre>
[ { "answer_id": 372756, "author": "Ana Betts", "author_id": 5728, "author_profile": "https://Stackoverflow.com/users/5728", "pm_score": 5, "selected": true, "text": "#ifndef Weapon\n#define Weapon\n" }, { "answer_id": 372788, "author": "Stephen C. Steel", "author_id": 1913...
2008/12/16
[ "https://Stackoverflow.com/questions/372714", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39189/" ]
372,715
<p>Ok, this is not a CSS issue, I removed all styling from the page. This is a calendar extender that has a target id of a textbox and the popupbutton is the same text box. </p> <p>The month name is displaying lower than the days, so it's not usable. </p> <p>it's fine in IE. </p> <p>I am using Safari in Windows Vista. </p> <p>Does anyone know what is causing this?</p> <p>Thank you. </p> <p>I don't know why this was voted down, is there some information I'm missing? This isn't a duplicate question. </p> <p>UPDATE:</p> <p>here is the c0dez:</p> <pre><code> &lt;label&gt;date&lt;/label&gt; &lt;asp:TextBox ID="txtDate" CssClass="field" runat="server" /&gt; &lt;asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtDate" Text="*" /&gt; &lt;ajaxtoolkit:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="txtDate" Format="MMMM d, yyyy" PopupButtonID="txtDate" PopupPosition="BottomLeft" /&gt; </code></pre>
[ { "answer_id": 511465, "author": "JC.", "author_id": 54604, "author_profile": "https://Stackoverflow.com/users/54604", "pm_score": 1, "selected": false, "text": "<browsers>\n <browser refID=\"safari1plus\">\n <controlAdapters>\n <adapter controlType=\"System.Web.UI.W...
2008/12/16
[ "https://Stackoverflow.com/questions/372715", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4140/" ]
372,718
<p>I want to prevent the user from maximizing the Windows Form to full screen so I have disabled the Maximize button. However, I want to be able to have the user 'restore' the Form. When they click the Restore button I want it to show a different, smaller, minified, form, which will show them a maximize button which will return the use to the original form.</p> <p>Is there a way to do this?</p> <p>Thanks.</p> <p>edit: You don't understand, I'm not preventing the user from resizing the form. Whats happening is when the click the restore button, it will hide the form and open a new one with less controls on it. When they click maximize on the smaller form, it will return to the original form.</p>
[ { "answer_id": 24372822, "author": "Victor Stoddard", "author_id": 1090802, "author_profile": "https://Stackoverflow.com/users/1090802", "pm_score": 0, "selected": false, "text": "Resize FormWindowState.Maximized FormWindowState.Maximized Resize" } ]
2008/12/16
[ "https://Stackoverflow.com/questions/372718", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12243/" ]
372,721
<p>the homework: <a href="http://www.cs.rit.edu/~waw/networks/prob1.082.html" rel="nofollow noreferrer">http://www.cs.rit.edu/~waw/networks/prob1.082.html</a></p> <p>Ok, I am still confused why this question was asked for my data communications and networks class, but here is the question from my homework:</p> <blockquote> <ol start="8"> <li><p>Write a computer program that reads the header on an e-mail message and deletes all lines except those that begin with</p> <p>From:, To:, Subject: and Cc:.</p></li> </ol> <p>CONTEST -- Who can write the shortest program that does this.</p> </blockquote> <p>So after thinking for a bit I decided that the following Perl code was as small as I could do this.</p> <pre><code>#!/usr/bin/perl while (&lt;&gt;) { print "$_" if ($_ =~ m/^(To:|From:|Subject:|Cc:)/); } </code></pre> <p>All this does is act like a filter for which the only output is lines that start with From:, To:, Subject: and Cc: as specified in the question. Since there aren't any specific details I think that the above code works to at least correctly answer the question.</p> <p>Now, I wonder how small a program could possibly written for this? I can understand if no one wants to post code because they think I will use it for the assignment, but I am more or less looking for suggestions and techniques that could help me write the shortest program possible.</p> <p>Also, I am quite sure by shortest he is referring to actual code length. He did mention that scripting languages were the way to go so I doubt he is considering something like the overhead involved with an interpreter. This also means that he does not care which language is used.</p> <p>Thanks for looking!</p> <p>EDIT: Thanks for the suggestions! I had been reading questions here for quite a while, hopefully in the future I can contribute more. Also, some of the suggestions I trimmed my Perl code down to 55 bytes. I don't think we will need to deal with something like a multi-line header.</p> <p>BONUS: Who can identify a good reason why this was asked in a class where we are discussing things like packet switching and client/server architectures?</p> <p>EDIT2: For the record, my professor said that someone did this with something like 55 bytes. The only way I see that as being possible is if he was only asking for a simple implementation like the one above.</p>
[ { "answer_id": 372763, "author": "Leon Timmermans", "author_id": 4727, "author_profile": "https://Stackoverflow.com/users/4727", "pm_score": 3, "selected": false, "text": "print \"$_\" print #! : #!/usr/bin/perl -n\nprint if /^(To|From|Subject|Cc):/;\n" }, { "answer_id": 372998, ...
2008/12/16
[ "https://Stackoverflow.com/questions/372721", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
372,731
<p>How can I set a custom background color of a button? </p> <p>Interface Builder doesn't seem to have an interface to do this. </p> <p>Is it only available programmatically? If so, can you provide an example, please?</p>
[ { "answer_id": 373572, "author": "Brad Larson", "author_id": 19679, "author_profile": "https://Stackoverflow.com/users/19679", "pm_score": 4, "selected": false, "text": "downloadButton = [[UIButton alloc] initWithFrame:CGRectMake(36, 212, 247, 37)];\n\ndownloadButton.contentVerticalAlign...
2008/12/16
[ "https://Stackoverflow.com/questions/372731", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
372,742
<p>This is related to a question I asked the other day on <a href="https://stackoverflow.com/questions/366629/how-do-i-send-an-email-message-from-my-c-application">how to send email</a>. </p> <p>My new, related question is this... what if the user of my application is behind a firewall or some other reason why the line client.Send(mail) won't work...</p> <p>After the lines:</p> <pre><code>SmtpClient client = new SmtpClient("mysmtpserver.com", myportID); client.Credentials = new System.Net.NetworkCredential("myusername.com", "mypassword"); </code></pre> <p>is there something I can do to test client before I try sending? </p> <p>I thought about putting this in a try/catch loop, but I'd rather do a test and then pop up a dialog saying: can't access smtp or something like that. </p> <p>(I'm presuming that neither I, nor potentially my application user, has the ability to adjust their firewall settings. For example... they install the app at work and don't have control over their internet at work)</p> <p>-Adeena</p>
[ { "answer_id": 2860887, "author": "Four", "author_id": 103887, "author_profile": "https://Stackoverflow.com/users/103887", "pm_score": 6, "selected": false, "text": "public static class SmtpHelper\n{\n /// <summary>\n /// test the smtp connection by sending a HELO command\n /// ...
2008/12/16
[ "https://Stackoverflow.com/questions/372742", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44004/" ]
372,747
<p>Does anybody know if there is a color theme like the TextMate Dawn theme, for Emacs ? I simply don't like the way the fonts look on my dark emacs theme and I am not sure if it's emacs's fault or just the theme.</p> <p>Here's a comparison:</p> <p><a href="http://mixandgo.com/emacs_textmate.png" rel="nofollow noreferrer">http://mixandgo.com/emacs_textmate.png</a></p> <p>Thanks, Cezar</p>
[ { "answer_id": 372891, "author": "ShreevatsaR", "author_id": 4958, "author_profile": "https://Stackoverflow.com/users/4958", "pm_score": 3, "selected": false, "text": "M-x color-theme-select color-theme sudo apt-get install emacs-goodies-el" } ]
2008/12/16
[ "https://Stackoverflow.com/questions/372747", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
372,750
<p>I was trying to use the slime-connect function to get access to a remote server with sbcl. I followed all the steps from the slime.mov movie from <a href="http://www.guba.com/watch/30000548671" rel="noreferrer">Marco Baringer,</a> but I got stuck when creating the ssh connection for slime. This is after already starting the swank server on the remote machine. I did it like this:</p> <p><code>ssh -L 4005:127.0.0.1:4005 user@server.com</code></p> <p>And I got this errors, on local SLIME: </p> <p>Lisp connection closed unexpectedly: connection broken by remote peer </p> <p>...and on the remote server: </p> <p>channel 3: open failed: connect failed: Connection refused</p> <p>What could possibly be wrong?</p>
[ { "answer_id": 384650, "author": "Anton Nazarov", "author_id": 38204, "author_profile": "https://Stackoverflow.com/users/38204", "pm_score": 2, "selected": false, "text": "ssh user@server.com\ntelnet 127.0.0.1:4005\n" }, { "answer_id": 54387736, "author": "hsrv", "author_...
2008/12/16
[ "https://Stackoverflow.com/questions/372750", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9082/" ]
372,773
<pre><code>enum MyEnum { A( 1, 2, 3, 4), B(1, 2), C(4, 5, 8, 8, 9); private MyEnum( int firstInt, int... otherInts ) { // do something with arguments, perhaps initialize a List } } </code></pre> <p>Are there any problems with this? Any reasons not to do it?</p>
[ { "answer_id": 373063, "author": "Milhous", "author_id": 17712, "author_profile": "https://Stackoverflow.com/users/17712", "pm_score": 0, "selected": false, "text": "private MyEnum(int... Ints )\n MyEnum bob = MyEnum.A;\n" } ]
2008/12/16
[ "https://Stackoverflow.com/questions/372773", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39489/" ]
372,778
<p>I have written some CSS which targets elements using the parent > child selector. Specifically for tables so I can apply certain styles to the headers and footers like this</p> <pre><code>table &gt; thead &gt; tr &gt; th ... table &gt; tbody &gt; tr &gt; td ... //there are other uses in the css as well </code></pre> <p>This works great, except in IE6. What is my best approach for unfactoring this css to support IE6? </p>
[ { "answer_id": 372847, "author": "davethegr8", "author_id": 12930, "author_profile": "https://Stackoverflow.com/users/12930", "pm_score": 3, "selected": false, "text": "E F {\n set-some-style: value;\n}\n\nE * F {\n unset-some-style: 0;\n}\n" }, { "answer_id": 7645106, ...
2008/12/16
[ "https://Stackoverflow.com/questions/372778", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45/" ]
372,780
<p>I am adding dynamically controls to page by using LoadControl and Controls.Add. I need somehow to wrap Init and Load event handlers of this loaded controls into my code. So it should be such order of events <em>SomeMyCode() -> Control.Init() -> AnotherMyCode()</em> and the same for Load <em>SomeMyCode() -> Control.Load() -> AnotherMyCode()</em>.<br/> My idea was to Get List of Control's event handlers for Init and Load events and add first and last event handers with code I should to run. But I cannot figure out how to do this.</p>
[ { "answer_id": 372847, "author": "davethegr8", "author_id": 12930, "author_profile": "https://Stackoverflow.com/users/12930", "pm_score": 3, "selected": false, "text": "E F {\n set-some-style: value;\n}\n\nE * F {\n unset-some-style: 0;\n}\n" }, { "answer_id": 7645106, ...
2008/12/16
[ "https://Stackoverflow.com/questions/372780", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39292/" ]