qid
int64
4
8.14M
question
stringlengths
20
48.3k
answers
list
date
stringlengths
10
10
metadata
list
input
stringlengths
12
45k
output
stringlengths
2
31.8k
333,181
<p>I have 3 tables in database shown below. And I want to make a report just like shown link below. How can I do it with datagrid or datalist? Which one is the best chois? I have tried to do it for a week. </p> <p><img src="https://i.stack.imgur.com/uZtmk.jpg" alt="http://img123.imageshack.us/my.php?image=61519307xx5....
[ { "answer_id": 333203, "author": "BenAlabaster", "author_id": 40650, "author_profile": "https://Stackoverflow.com/users/40650", "pm_score": 2, "selected": false, "text": "<p>What version of SQL are you running? Using PIVOT might be a quick way to get the data into the form you want, and...
2008/12/02
[ "https://Stackoverflow.com/questions/333181", "https://Stackoverflow.com", "https://Stackoverflow.com/users/439507/" ]
I have 3 tables in database shown below. And I want to make a report just like shown link below. How can I do it with datagrid or datalist? Which one is the best chois? I have tried to do it for a week. ![http://img123.imageshack.us/my.php?image=61519307xx5.jpg](https://i.stack.imgur.com/uZtmk.jpg) > > **COMPANY**:...
Use a standard sql query (pivots are expensive in terms of performance) and create a custom pivot function in your server side code. Here are a couple of examples. ``` ''' <summary> ''' Pivots columnX as new columns for the X axis (must be unique values) and the remaining columns as ''' the Y axis. Optionally can inc...
333,185
<p>I'm trying to figure out if Haskell uses dynamic or static scoping. I realize that, for example, if you define:</p> <pre><code>let x = 10 </code></pre> <p>then define the function</p> <pre><code>let square x = x*x </code></pre> <p>You have 2 different "x's", and does that mean it is dynamically scoped? If not, ...
[ { "answer_id": 333189, "author": "olliej", "author_id": 784, "author_profile": "https://Stackoverflow.com/users/784", "pm_score": 4, "selected": false, "text": "<p>Haskell use (broadly speaking) exactly the same lexical scoping as most other languages.</p>\n\n<p>eg.</p>\n\n<pre><code>x =...
2008/12/02
[ "https://Stackoverflow.com/questions/333185", "https://Stackoverflow.com", "https://Stackoverflow.com/users/83819/" ]
I'm trying to figure out if Haskell uses dynamic or static scoping. I realize that, for example, if you define: ``` let x = 10 ``` then define the function ``` let square x = x*x ``` You have 2 different "x's", and does that mean it is dynamically scoped? If not, what scoping does it use, and why? Also, can Hask...
There are some things wrong in your statements... * There are no mutable variables in Haskell just definitions (or immutable variables) * A variable memory location is a concept that do not exist in Haskell In your example, *x* is **not** 10 in the function is just a argument to square, that can take any value (you ...
333,216
<p>I'm new to this JSF world, please bear with me if I'm asking some silly thing</p> <p>i'm using UI tags for my application and I have a scenario that I need to generate a calendar control to make the user to select the date I followed the ui tags documentation and wrote the code like this:</p> <pre><code> &lt;tabl...
[ { "answer_id": 333327, "author": "Romain Linsolas", "author_id": 26457, "author_profile": "https://Stackoverflow.com/users/26457", "pm_score": 0, "selected": false, "text": "<p>The component is coming from which JSF library?\nIn others words, what do you have at the beginning of your XH...
2008/12/02
[ "https://Stackoverflow.com/questions/333216", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm new to this JSF world, please bear with me if I'm asking some silly thing i'm using UI tags for my application and I have a scenario that I need to generate a calendar control to make the user to select the date I followed the ui tags documentation and wrote the code like this: ``` <table width="100%"> <tr>...
I got the solution by myself - the issue is with the javascript code. it reads the javascript from themes.jar, which i placed in web-inf/lib folder still it was unable to access that. so I extracted the same and placed it in web-inf and it's working fine
333,249
<p>What is the XPath expression that I would use to get the string following 'HarryPotter:' for each book.</p> <p>ie. Given this XML:</p> <pre><code>&lt;bookstore&gt; &lt;book&gt; HarryPotter:Chamber of Secrets &lt;/book&gt; &lt;book&gt; HarryPotter:Prisoners in Azkabahn &lt;/book&gt; &lt;/bookstore&gt; </code>...
[ { "answer_id": 333265, "author": "BenAlabaster", "author_id": 40650, "author_profile": "https://Stackoverflow.com/users/40650", "pm_score": 3, "selected": false, "text": "<p>In your XML you've got no space between Harry Potter but in your XQuery you've got a space. Just make it match an...
2008/12/02
[ "https://Stackoverflow.com/questions/333249", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
What is the XPath expression that I would use to get the string following 'HarryPotter:' for each book. ie. Given this XML: ``` <bookstore> <book> HarryPotter:Chamber of Secrets </book> <book> HarryPotter:Prisoners in Azkabahn </book> </bookstore> ``` I would get back: ``` Chamber of Secrets Prisoners in Azk...
In XPath 2.0 this can be produced by a single XPath expression:       **`/*/*/substring-after(., 'HarryPotter:')`** Here we are using the very powerful feature of XPath 2.0 that at the end of a path of location steps we can put a function and this function will be applied on all nodes in the current result set. **In...
333,260
<p>We have a PageRoles xml file which contains the page path and the user role that can access that page.</p> <p>We are maintaining a Dictionary in a static class, which gets loaded int static constructor for the class. The class has a method CheckIfRoleAllowed that takes in a page path and returns a bool.</p> <p>Eac...
[ { "answer_id": 333263, "author": "Serge Wautier", "author_id": 12379, "author_profile": "https://Stackoverflow.com/users/12379", "pm_score": 3, "selected": true, "text": "<p>You do use a singleton. Simply, there are 2 usual implementations for singletons, the other being instantiating th...
2008/12/02
[ "https://Stackoverflow.com/questions/333260", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21586/" ]
We have a PageRoles xml file which contains the page path and the user role that can access that page. We are maintaining a Dictionary in a static class, which gets loaded int static constructor for the class. The class has a method CheckIfRoleAllowed that takes in a page path and returns a bool. Each page call the C...
You do use a singleton. Simply, there are 2 usual implementations for singletons, the other being instantiating the class and having a static member referencing this instance. Your implementation makes calls simpler IMO : ``` PageAccessChecker.CheckIfRoleAllowed(path); ``` instead of: ``` PageAccessChecker._defaul...
333,264
<p>i want to get an ending html tag like <code>&lt;/EM&gt;</code> only if somewhere before it i.e. before any previous tags or text there is no starting <code>&lt;EM&gt;</code> tag my sample string is </p> <pre><code>ddd d&lt;STRONG&gt;dfdsdsd dsdsddd&lt;EM&gt;ss&lt;/EM&gt;r and&lt;/EM&gt;and strong&lt;/STRONG&gt; </c...
[ { "answer_id": 333276, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 3, "selected": true, "text": "<p>I am not sure regex is best suited for this kind of task, since tags can always be nested.</p>\n\n<p>Anyhow, a C# regex like:...
2008/12/02
[ "https://Stackoverflow.com/questions/333264", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40570/" ]
i want to get an ending html tag like `</EM>` only if somewhere before it i.e. before any previous tags or text there is no starting `<EM>` tag my sample string is ``` ddd d<STRONG>dfdsdsd dsdsddd<EM>ss</EM>r and</EM>and strong</STRONG> ``` in this string the output should be `</EM>` and this also the second `</EM>...
I am not sure regex is best suited for this kind of task, since tags can always be nested. Anyhow, a C# regex like: ``` (?<!<EM>[^<]+)</EM> ``` would only bring the second `</EM>` tag Note that: * `?!` is a negative look*ahead* which explains why both `</EM>` are found. So... `(?!=<EM>.*)`xxx actually means ca...
333,287
<p>Tried something like this:</p> <pre><code>HttpApplication app = s as HttpApplication; //s is sender of the OnBeginRequest event System.Web.UI.Page p = (System.Web.UI.Page)app.Context.Handler; System.Web.UI.WebControls.Label lbl = new System.Web.UI.WebControls.Label(); lbl.Text = "TEST TEST TEST"; p.Controls.Add(lbl...
[ { "answer_id": 333360, "author": "user39603", "author_id": 39603, "author_profile": "https://Stackoverflow.com/users/39603", "pm_score": 3, "selected": true, "text": "<p>I'm not sure, but I don't think you can use an HttpModule to alter the Page's control tree (please correct me if I'm w...
2008/12/02
[ "https://Stackoverflow.com/questions/333287", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42108/" ]
Tried something like this: ``` HttpApplication app = s as HttpApplication; //s is sender of the OnBeginRequest event System.Web.UI.Page p = (System.Web.UI.Page)app.Context.Handler; System.Web.UI.WebControls.Label lbl = new System.Web.UI.WebControls.Label(); lbl.Text = "TEST TEST TEST"; p.Controls.Add(lbl); ``` w...
I'm not sure, but I don't think you can use an HttpModule to alter the Page's control tree (please correct me if I'm wrong). You CAN modify the HTML markup however, you'll have to write a "response filter" for this. For an example, see <http://aspnetresources.com/articles/HttpFilters.aspx>, or google for "httpmodule re...
333,315
<p>Looking for a column formatting script, I have a feeling this could be a one line awk. Ideally, a small shell script is all I am after.</p> <p>The data is tab separated, each cell in each row is of variable length, and of course, may have spaces in it.</p> <p>So we have something like this</p> <pre> dasj dhsa...
[ { "answer_id": 333345, "author": "Alnitak", "author_id": 6782, "author_profile": "https://Stackoverflow.com/users/6782", "pm_score": 1, "selected": false, "text": "<p>In un-obsfucated Perl:</p>\n\n<pre><code>#!/usr/bin/perl -w\n\nuse strict;\n\nmy (@data, @length);\nwhile (&lt;&gt;) {\n ...
2008/12/02
[ "https://Stackoverflow.com/questions/333315", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Looking for a column formatting script, I have a feeling this could be a one line awk. Ideally, a small shell script is all I am after. The data is tab separated, each cell in each row is of variable length, and of course, may have spaces in it. So we have something like this ``` dasj dhsahdwe dhasdhajks ewq...
If you're on a BSD-derived OS (including Mac OS X), column(1) and its -t option might do what you want: ``` % column -t coltest dasj dhsahdwe dhasdhajks ewqhehwq dsajkdhas e dward das dsaw das daswf fjdk ewf jken ...
333,328
<p>I'm using caml query to select all documents which were modified or added by user. Query runs recursively on all subsites of specified site collection.</p> <p>Now problem is I can't get rid of folders which are also part of result set. For now I'm filtering them from result datatable. But I'm wondering: Is it possi...
[ { "answer_id": 333586, "author": "Marian Polacek", "author_id": 41545, "author_profile": "https://Stackoverflow.com/users/41545", "pm_score": 4, "selected": false, "text": "<p>So, i figured it out :)\nYou can use FieldRef='ContentType' in your caml query and specify typr of content type ...
2008/12/02
[ "https://Stackoverflow.com/questions/333328", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41545/" ]
I'm using caml query to select all documents which were modified or added by user. Query runs recursively on all subsites of specified site collection. Now problem is I can't get rid of folders which are also part of result set. For now I'm filtering them from result datatable. But I'm wondering: Is it possible to fil...
This CAML actually does the trick: ``` <Where> <Eq> <FieldRef Name='FSObjType' /> <Value Type='Integer'>0</Value> </Eq> </Where> ``` that will not give you any folders.
333,329
<p>I'm trying to make a pull down menu post a form when the user selects (releases the mouse) on one of the options from the menu. This code works fine in FF but Safari, for some reason, doesn't submit the form. I re-wrote the code using jquery to see if jquery's .submit() implementation handled the browser quirks be...
[ { "answer_id": 333337, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 2, "selected": false, "text": "<p>You should probably use the <code>onchange</code> event of the <code>&lt;select&gt;</code> instead (or as well).</p>\n" ...
2008/12/02
[ "https://Stackoverflow.com/questions/333329", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27462/" ]
I'm trying to make a pull down menu post a form when the user selects (releases the mouse) on one of the options from the menu. This code works fine in FF but Safari, for some reason, doesn't submit the form. I re-wrote the code using jquery to see if jquery's .submit() implementation handled the browser quirks better....
The code would be: ``` <form id="setlang_form" method="post" action="{% url django.views.i18n.set_language %}"> <fieldset> <select name="language" onchange="formSubmit(this)"> {% for lang in interface_languages %} <option value="{{ lang.code }}" {% ifequal lang.code LANGUAGE_CODE %}selected="select...
333,346
<p>I have this code inside a class that is used by an application and by an applet.</p> <pre><code>static { if (System.getProperty("os.name").startsWith("Windows")) { System.loadLibrary("extmapi"); } } </code></pre> <p>Unfortunately, when the applet loads this code I get an error, because it can't...
[ { "answer_id": 333356, "author": "Franck", "author_id": 38072, "author_profile": "https://Stackoverflow.com/users/38072", "pm_score": 2, "selected": false, "text": "<p>You need to understand that MVC doesn't directly reference .aspx pages like WebForms in its URLs. Its main purpose is to...
2008/12/02
[ "https://Stackoverflow.com/questions/333346", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15173/" ]
I have this code inside a class that is used by an application and by an applet. ``` static { if (System.getProperty("os.name").startsWith("Windows")) { System.loadLibrary("extmapi"); } } ``` Unfortunately, when the applet loads this code I get an error, because it can't load the "extmapi" librar...
You need to understand that MVC doesn't directly reference .aspx pages like WebForms in its URLs. Its main purpose is to separate concerns, that is model (data), controller (logic), and view (presentation). First, you'd have to create a route matching your URLs, which would now look like this for example : /home/searc...
333,363
<p>I need to read a properties files that's buried in my package structure in <code>com.al.common.email.templates</code>.</p> <p>I've tried everything and I can't figure it out.</p> <p>In the end, my code will be running in a servlet container, but I don't want to depend on the container for anything. I write JUnit t...
[ { "answer_id": 333385, "author": "Joachim Sauer", "author_id": 40342, "author_profile": "https://Stackoverflow.com/users/40342", "pm_score": 9, "selected": true, "text": "<p>When loading the Properties from a Class in the package <code>com.al.common.email.templates</code> you can use</p>...
2008/12/02
[ "https://Stackoverflow.com/questions/333363", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42375/" ]
I need to read a properties files that's buried in my package structure in `com.al.common.email.templates`. I've tried everything and I can't figure it out. In the end, my code will be running in a servlet container, but I don't want to depend on the container for anything. I write JUnit test cases and it needs to wo...
When loading the Properties from a Class in the package `com.al.common.email.templates` you can use ``` Properties prop = new Properties(); InputStream in = getClass().getResourceAsStream("foo.properties"); prop.load(in); in.close(); ``` (Add all the necessary exception handling). If your class is not in that packa...
333,364
<p>I have an interface method</p> <pre><code> public void Execute(ICommand command); </code></pre> <p>which needs to pass known subtypes of <code>ICommand</code> to an apropriate <code>Handle(SpecificCommand command)</code> method implementation and do some generic handling of unknown types. I am looking for a unive...
[ { "answer_id": 333373, "author": "OJ.", "author_id": 611, "author_profile": "https://Stackoverflow.com/users/611", "pm_score": 2, "selected": false, "text": "<p>You can't, and why would you want to?</p>\n\n<p>That's the whole reason we have polymorphism. If you want to have custom behavi...
2008/12/02
[ "https://Stackoverflow.com/questions/333364", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3205/" ]
I have an interface method ``` public void Execute(ICommand command); ``` which needs to pass known subtypes of `ICommand` to an apropriate `Handle(SpecificCommand command)` method implementation and do some generic handling of unknown types. I am looking for a universal (i.e. not requiring a giant switch) method ...
The cast is emitted at compile-time, so you need to know the type at compile-time. The overloading is also determined at compile-time - so by the time you actually know the concrete type to use, it's too late. I don't see that you'd actually be duplicating any *logic* by using delegates. Alternatively, if you do it wi...
333,391
<p>I need to know how I can detect the current application pool I am running under, so I can do a Recycle on it programmatically.</p> <p>Does anyone know how to do this for IIS6?</p> <p>My current code for recycling the app-pool is:</p> <pre><code> /// &lt;summary&gt; /// Recycle an application pool /// &...
[ { "answer_id": 333475, "author": "Wolf5", "author_id": 37643, "author_profile": "https://Stackoverflow.com/users/37643", "pm_score": 4, "selected": true, "text": "<p>And after searching I found the answer myself:</p>\n\n<pre><code> public string GetAppPoolName() {\n\n string App...
2008/12/02
[ "https://Stackoverflow.com/questions/333391", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37643/" ]
I need to know how I can detect the current application pool I am running under, so I can do a Recycle on it programmatically. Does anyone know how to do this for IIS6? My current code for recycling the app-pool is: ``` /// <summary> /// Recycle an application pool /// </summary> /// <param name="IIs...
And after searching I found the answer myself: ``` public string GetAppPoolName() { string AppPath = Context.Request.ServerVariables["APPL_MD_PATH"]; AppPath = AppPath.Replace("/LM/", "IIS://localhost/"); DirectoryEntry root = new DirectoryEntry(AppPath); if ((root == null)) { ...
333,400
<p>In my application, there are 10-20 classes that are instantiated once[*]. Here's an example:</p> <pre><code>class SomeOtherManager; class SomeManagerClass { public: SomeManagerClass(SomeOtherManager*); virtual void someMethod1(); virtual void someMethod2(); }; </code></pre> <p>Instances of the classes...
[ { "answer_id": 333442, "author": "boutta", "author_id": 15108, "author_profile": "https://Stackoverflow.com/users/15108", "pm_score": 1, "selected": false, "text": "<p>You could implement an object factory with static methods that return an instance of a Manager-Class. In the factory you...
2008/12/02
[ "https://Stackoverflow.com/questions/333400", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33982/" ]
In my application, there are 10-20 classes that are instantiated once[\*]. Here's an example: ``` class SomeOtherManager; class SomeManagerClass { public: SomeManagerClass(SomeOtherManager*); virtual void someMethod1(); virtual void someMethod2(); }; ``` Instances of the classes are contained in one obj...
I think there are two separate problems here. One problem is: how does TheManager *name* the class that it has to create? It must keep some kind of pointer to "a way to create the class". Possible solutions are: * keeping a separate pointer for each kind of class, with a way to set it, but you already said that you d...
333,435
<p>I have an application where I open a log file for writing. At some point in time (while the application is running), I opened the file with Excel 2003, which said the file should be opened as read-only. That's OK with me.</p> <p>But then my application threw this exception:</p> <blockquote> <p>System.IO.IOExcept...
[ { "answer_id": 333497, "author": "FerranB", "author_id": 40441, "author_profile": "https://Stackoverflow.com/users/40441", "pm_score": 0, "selected": false, "text": "<p>How do you write the log? Have your own open/close or use some thirty party product?</p>\n\n<p>I thing that the log is ...
2008/12/02
[ "https://Stackoverflow.com/questions/333435", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41283/" ]
I have an application where I open a log file for writing. At some point in time (while the application is running), I opened the file with Excel 2003, which said the file should be opened as read-only. That's OK with me. But then my application threw this exception: > > System.IO.IOException: The process cannot acc...
Here is a logger which will take care of sync locks. (You can modify it to fit to your requirements) ``` using System; using System.Collections.Generic; using System.Text; using System.IO; namespace Owf.Logger { public class Logger { private static object syncContoller = string.Empty; private ...
333,441
<p>I'm trying to add a label to my toolbar. Button works great, however when I add the label object, it crashes. Any ideas?</p> <pre><code>UIBarButtonItem *setDateRangeButton = [[UIBarButtonItem alloc] initWithTitle:@"Set date range" style:UIBarBut...
[ { "answer_id": 333509, "author": "adam", "author_id": 33604, "author_profile": "https://Stackoverflow.com/users/33604", "pm_score": 8, "selected": true, "text": "<p>Have a look into this</p>\n\n<pre><code>[[UIBarButtonItem alloc] initWithCustomView:yourCustomView];\n</code></pre>\n\n<p>E...
2008/12/02
[ "https://Stackoverflow.com/questions/333441", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm trying to add a label to my toolbar. Button works great, however when I add the label object, it crashes. Any ideas? ``` UIBarButtonItem *setDateRangeButton = [[UIBarButtonItem alloc] initWithTitle:@"Set date range" style:UIBarButtonItemStyleBo...
Have a look into this ``` [[UIBarButtonItem alloc] initWithCustomView:yourCustomView]; ``` Essentially every item must be a "button" but they can be instantiated with any view you require. Here is some example code. Note, since other buttons are typically on the toolbar, spacers are placed on each side of the title ...
333,443
<p>I'm a C programmer trying to understand C++. Many tutorials demonstrate object instantiation using a snippet such as:</p> <pre><code>Dog* sparky = new Dog(); </code></pre> <p>which implies that later on you'll do:</p> <pre><code>delete sparky; </code></pre> <p>which makes sense. Now, in the case when dynamic m...
[ { "answer_id": 333448, "author": "PierreBdR", "author_id": 7136, "author_profile": "https://Stackoverflow.com/users/7136", "pm_score": 4, "selected": false, "text": "<p>Well, the reason to use the pointer would be exactly the same that the reason to use pointers in C allocated with mallo...
2008/12/02
[ "https://Stackoverflow.com/questions/333443", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42387/" ]
I'm a C programmer trying to understand C++. Many tutorials demonstrate object instantiation using a snippet such as: ``` Dog* sparky = new Dog(); ``` which implies that later on you'll do: ``` delete sparky; ``` which makes sense. Now, in the case when dynamic memory allocation is unnecessary, is there any reaso...
On the contrary, you should always prefer stack allocations, to the extent that as a rule of thumb, you should never have new/delete in your user code. As you say, when the variable is declared on the stack, its destructor is automatically called when it goes out of scope, which is your main tool for tracking resource...
333,454
<p>I am using an api which interacts with a db. This api has methods for querying, loading and saving elements to the db. I have written integration tests which do things like create a new instance, then check that when I do a query for that instance, the correct instance is found. This is all fine. </p> <p>I woul...
[ { "answer_id": 333488, "author": "John Stauffer", "author_id": 5874, "author_profile": "https://Stackoverflow.com/users/5874", "pm_score": 2, "selected": false, "text": "<p>It is a good idea to mock out m_api in my code for the following reasons (not all of which apply to your psuedo-cod...
2008/12/02
[ "https://Stackoverflow.com/questions/333454", "https://Stackoverflow.com", "https://Stackoverflow.com/users/97614/" ]
I am using an api which interacts with a db. This api has methods for querying, loading and saving elements to the db. I have written integration tests which do things like create a new instance, then check that when I do a query for that instance, the correct instance is found. This is all fine. I would like to have...
Look at what the tests are like. If you're only testing if stuff that comes in ends up in the database etc. Your probably doing the right thing by only doing automated integration tests. If there's logic you want to test then you might want to look if you can factor out your logic into separate classes that you can uni...
333,462
<p>I'm struggling here with a problem: I have a controller <em>questions</em> which has action <em>new</em>. Whenever I need to create new question, I'm typing </p> <pre><code>/questions/new </code></pre> <p>What changes to routes.rb should I make to change the URI to </p> <pre><code>/questions/ask </code></pre> <h...
[ { "answer_id": 333491, "author": "Jason Watkins", "author_id": 39405, "author_profile": "https://Stackoverflow.com/users/39405", "pm_score": 0, "selected": false, "text": "<p>Which version of rails?</p>\n\n<p>Generally the default route should catch anything like /:controller/:action, so...
2008/12/02
[ "https://Stackoverflow.com/questions/333462", "https://Stackoverflow.com", "https://Stackoverflow.com/users/430254/" ]
I'm struggling here with a problem: I have a controller *questions* which has action *new*. Whenever I need to create new question, I'm typing ``` /questions/new ``` What changes to routes.rb should I make to change the URI to ``` /questions/ask ``` --- Thank you. Valve.
Try this: ``` map.ask_question '/questions/ask', :controller => 'questions', :action => 'new' ``` Then you'll have a named route and you can: ``` link_to "Ask a question", ask_question_path ```
333,463
<p>I know that XSLT does not work in procedural terms, but unfortunately I have been doing procedural languages for too long. Can anyone help me out by explaining in simple terms how things like apply-templates works and help a thicko like me to understand it.</p>
[ { "answer_id": 333480, "author": "Greg Beech", "author_id": 13552, "author_profile": "https://Stackoverflow.com/users/13552", "pm_score": 3, "selected": false, "text": "<p>I wrote <a href=\"http://gregbee.ch/blog/using-xsl-for-each-is-almost-always-wrong\" rel=\"nofollow noreferrer\">a b...
2008/12/02
[ "https://Stackoverflow.com/questions/333463", "https://Stackoverflow.com", "https://Stackoverflow.com/users/274/" ]
I know that XSLT does not work in procedural terms, but unfortunately I have been doing procedural languages for too long. Can anyone help me out by explaining in simple terms how things like apply-templates works and help a thicko like me to understand it.
What makes you think that procedural terms do not apply here? It's just that the calling convention is somewhat more implicit than you would traditionally expect it, because there is an invisible context involved. Everything `apply-templates` does could be expressed in procedural terms. Basically, `apply-templates` is...
333,484
<p>I have a GridView control on my page that I have defined a number of BoundFields for. Each row of the databound GridView has a CommandField (Select), for which I want to send the PostBack to a new page.</p> <p>Of course I could easily send the NewSelectedIndex in a QueryString, but I'd rather keep that information...
[ { "answer_id": 333862, "author": "Sergiu Damian", "author_id": 41345, "author_profile": "https://Stackoverflow.com/users/41345", "pm_score": 0, "selected": false, "text": "<p>Use a HyperLinkField column in your GridView:</p>\n\n<pre><code>&lt;asp:HyperLinkField AccessibleHeaderText=\"Edi...
2008/12/02
[ "https://Stackoverflow.com/questions/333484", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15609/" ]
I have a GridView control on my page that I have defined a number of BoundFields for. Each row of the databound GridView has a CommandField (Select), for which I want to send the PostBack to a new page. Of course I could easily send the NewSelectedIndex in a QueryString, but I'd rather keep that information hidden fro...
Leppie is right. The GridView has no PostbackUrl property. However, you can do what you want by using a standard control, which has a PostbackUrl property. ``` <asp:TemplateField AccessibleHeaderText="Edit"> <ItemTemplate> <asp:Button runat="server" ID="btnEdit" PostBackUrl="~/Default.aspx" OnClientClick='...
333,487
<p>I've made this decorator, which results in an infinite redirect loop.</p> <p>The problem is this: </p> <pre><code>args[0].redirect(users.create_login_url(args[0].request.path)) </code></pre> <p>It appears to be a perfectly valid URL. So why wouldn't it properly redirect?</p> <pre><code>def admin_only(handler, *a...
[ { "answer_id": 333599, "author": "M. Utku ALTINKAYA", "author_id": 40948, "author_profile": "https://Stackoverflow.com/users/40948", "pm_score": 0, "selected": false, "text": "<p>Are you sure proper status code is being sent, you can use live http headers add-on for firefox to check whet...
2008/12/02
[ "https://Stackoverflow.com/questions/333487", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9106/" ]
I've made this decorator, which results in an infinite redirect loop. The problem is this: ``` args[0].redirect(users.create_login_url(args[0].request.path)) ``` It appears to be a perfectly valid URL. So why wouldn't it properly redirect? ``` def admin_only(handler, *args): def redirect_to_login(*args, **kw...
It seems that you aren't defining your decorator properly. A decorator is called only **once** every time you wrap a function with it; from then on the function that the decorator **returned** will be called. It seems that you (mistakenly) believe that the decorator function **itself** will be called every time. Try ...
333,508
<p>By default, when you <code>sudo gem install thegemname</code> it will install executables into <code>/usr/bin/</code></p> <p>Is there a way to change this? For example, to install them into <code>/usr/local/rubygems/bin</code> (or any other path)?</p> <p>The path doesn't seem to be hard-coded into the gemspec file...
[ { "answer_id": 333519, "author": "csl", "author_id": 21028, "author_profile": "https://Stackoverflow.com/users/21028", "pm_score": 5, "selected": true, "text": "<p>See <a href=\"http://www.rubygems.org/read/chapter/11\" rel=\"nofollow noreferrer\">http://www.rubygems.org/read/chapter/11<...
2008/12/02
[ "https://Stackoverflow.com/questions/333508", "https://Stackoverflow.com", "https://Stackoverflow.com/users/745/" ]
By default, when you `sudo gem install thegemname` it will install executables into `/usr/bin/` Is there a way to change this? For example, to install them into `/usr/local/rubygems/bin` (or any other path)? The path doesn't seem to be hard-coded into the gemspec file, so I don't see why this shouldn't be possible (a...
See <http://www.rubygems.org/read/chapter/11> and specify a `~/.gemrc` which defines a gemhome variable. For example: ``` gemhome: /usr/local/rubygems ``` You can also place this file in `/etc/gemrc` Alternatively you can set the [`GEM_HOME` env-variable](http://docs.rubygems.org/read/chapter/12): ``` $ export GE...
333,517
<p>I want to implement an application (scholar exercise) over the AdventureWorks database. I have downloaded the diagram. Is there a less formal description of the database?</p> <p>Thanks, Lucian</p>
[ { "answer_id": 333519, "author": "csl", "author_id": 21028, "author_profile": "https://Stackoverflow.com/users/21028", "pm_score": 5, "selected": true, "text": "<p>See <a href=\"http://www.rubygems.org/read/chapter/11\" rel=\"nofollow noreferrer\">http://www.rubygems.org/read/chapter/11<...
2008/12/02
[ "https://Stackoverflow.com/questions/333517", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11464/" ]
I want to implement an application (scholar exercise) over the AdventureWorks database. I have downloaded the diagram. Is there a less formal description of the database? Thanks, Lucian
See <http://www.rubygems.org/read/chapter/11> and specify a `~/.gemrc` which defines a gemhome variable. For example: ``` gemhome: /usr/local/rubygems ``` You can also place this file in `/etc/gemrc` Alternatively you can set the [`GEM_HOME` env-variable](http://docs.rubygems.org/read/chapter/12): ``` $ export GE...
333,518
<p>In (Visual Basic, .NET):</p> <pre><code> Dim result As Match = Regex.Match(aStr, aMatchStr) If result.Success Then Dim result0 As String = result.Groups(0).Value Dim result1 As String = result.Groups(1).Value End If </code></pre> <p>With: aStr equal to (whitespace is normal space and there are sev...
[ { "answer_id": 333535, "author": "Brian", "author_id": 19299, "author_profile": "https://Stackoverflow.com/users/19299", "pm_score": 1, "selected": false, "text": "<p>\". * ?\" in this example will always match zero characters, since \"* ?\" does shortest possible match. As a result, sin...
2008/12/02
[ "https://Stackoverflow.com/questions/333518", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
In (Visual Basic, .NET): ``` Dim result As Match = Regex.Match(aStr, aMatchStr) If result.Success Then Dim result0 As String = result.Groups(0).Value Dim result1 As String = result.Groups(1).Value End If ``` With: aStr equal to (whitespace is normal space and there are seven spaces between `n` and ...
I think it's because the matching starts at the first character and moves on from there... For your first regular expression: ``` Does "AMEVDIEERPK + 7 Oxidation (M)" match "\s*(\d*).*?Oxidation\s+(M)"? Yes.. stop matching. ``` For your second regular expression: ``` Does "AMEVDIEERPK + 7 Oxidation (M)" match "\...
333,529
<p>I would like to migrate from Oracle to MySQL, and one of the important steps is to replace the actual job built on an Oracle environment.</p> <p>Basically, every day I receive some 'oracle' dump files from another Oracle environment (mainly CTL or Oracle table exports). Today my Oracle jobs loaded the received data...
[ { "answer_id": 333535, "author": "Brian", "author_id": 19299, "author_profile": "https://Stackoverflow.com/users/19299", "pm_score": 1, "selected": false, "text": "<p>\". * ?\" in this example will always match zero characters, since \"* ?\" does shortest possible match. As a result, sin...
2008/12/02
[ "https://Stackoverflow.com/questions/333529", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I would like to migrate from Oracle to MySQL, and one of the important steps is to replace the actual job built on an Oracle environment. Basically, every day I receive some 'oracle' dump files from another Oracle environment (mainly CTL or Oracle table exports). Today my Oracle jobs loaded the received data (CTL...) ...
I think it's because the matching starts at the first character and moves on from there... For your first regular expression: ``` Does "AMEVDIEERPK + 7 Oxidation (M)" match "\s*(\d*).*?Oxidation\s+(M)"? Yes.. stop matching. ``` For your second regular expression: ``` Does "AMEVDIEERPK + 7 Oxidation (M)" match "\...
333,532
<p>I need to make an AJAX request from a website to a REST web service hosted in another domain.</p> <p>Although this is works just fine in Internet Explorer, other browsers such as Mozilla and Google Chrome impose far stricter security restrictions, which prohibit cross-site AJAX requests.</p> <p>The problem is that...
[ { "answer_id": 333543, "author": "redsquare", "author_id": 6440, "author_profile": "https://Stackoverflow.com/users/6440", "pm_score": 5, "selected": true, "text": "<p>maybe <a href=\"http://en.wikipedia.org/wiki/JSONP\" rel=\"noreferrer\">JSONP</a> can help.</p>\n\n<p>NB youll have to c...
2008/12/02
[ "https://Stackoverflow.com/questions/333532", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26396/" ]
I need to make an AJAX request from a website to a REST web service hosted in another domain. Although this is works just fine in Internet Explorer, other browsers such as Mozilla and Google Chrome impose far stricter security restrictions, which prohibit cross-site AJAX requests. The problem is that I have no contro...
maybe [JSONP](http://en.wikipedia.org/wiki/JSONP) can help. NB youll have to change your messages to use json instead of xml Edit Major sites such as flickr and [twitter](http://apiwiki.twitter.com/Search+API+Documentation) support jsonp with callbacks etc
333,571
<p>I have an ASP.NET web application which does the following:</p> <ol> <li>Reads an Excel file.</li> <li>The excel file will have an image URL located in it that points to somewhere on the internet.</li> <li>The program reads each image URL and store it into a temporary folder in the web server.</li> <li>The applicat...
[ { "answer_id": 333588, "author": "Samiksha", "author_id": 29515, "author_profile": "https://Stackoverflow.com/users/29515", "pm_score": 4, "selected": true, "text": "<p>Try setting the access permissions to \"Full control\" for the .Net user from where you are reading/saving the files.</...
2008/12/02
[ "https://Stackoverflow.com/questions/333571", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40521/" ]
I have an ASP.NET web application which does the following: 1. Reads an Excel file. 2. The excel file will have an image URL located in it that points to somewhere on the internet. 3. The program reads each image URL and store it into a temporary folder in the web server. 4. The application then resizes (changes the w...
Try setting the access permissions to "Full control" for the .Net user from where you are reading/saving the files.
333,589
<p>I've got some C# code that resizes images that I think is pretty typical:</p> <pre><code>Bitmap bmp = new Bitmap(image, new Size(width, height)); Graphics graphics = Graphics.FromImage(bmp); graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; graphics.CompositingQuality = CompositingQuality.HighQuali...
[ { "answer_id": 333604, "author": "Firas Assaad", "author_id": 23153, "author_profile": "https://Stackoverflow.com/users/23153", "pm_score": 2, "selected": false, "text": "<p>Try graphics.DrawImage(bmp, 0, 0, width, height);\nAlso check this <a href=\"http://msdn.microsoft.com/en-us/libra...
2008/12/02
[ "https://Stackoverflow.com/questions/333589", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3187/" ]
I've got some C# code that resizes images that I think is pretty typical: ``` Bitmap bmp = new Bitmap(image, new Size(width, height)); Graphics graphics = Graphics.FromImage(bmp); graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; graphics.CompositingQuality = CompositingQuality.HighQuality; graphics.S...
It turns the code was just wrong. It was actually resizing the image without interpolation in the Bitmap constructor, and then attempting to smoothly resize that version to the size it was already at. Here is the amended code: ``` Bitmap bmp = new Bitmap(width, height); Graphics graph = Graphics.FromImage(bmp); graph....
333,593
<p>If I would write:</p> <pre> int selectedChannels = selector.select(); Set selectedKeys = selector.selectedKeys(); if ( selectedChannels != selectedKeys.size() ) { // Selector.select() returned because of a call to Selector.wakeup() // so do synchronization. } // Continue with handling selected channels. </p...
[ { "answer_id": 333752, "author": "Tom Hawtin - tackline", "author_id": 4725, "author_profile": "https://Stackoverflow.com/users/4725", "pm_score": 0, "selected": false, "text": "<p>I don't understand why your code would work in general.</p>\n\n<p>Why not just check a <code>volatile</code...
2008/12/02
[ "https://Stackoverflow.com/questions/333593", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
If I would write: ``` int selectedChannels = selector.select(); Set selectedKeys = selector.selectedKeys(); if ( selectedChannels != selectedKeys.size() ) { // Selector.select() returned because of a call to Selector.wakeup() // so do synchronization. } // Continue with handling selected channels. ``` would...
I would guess that the proposed snippet would not work at all in principle, per the contracts of `Selector#select()` and `Selector#selectedKeys()`. From [Selector](http://java.sun.com/javase/6/docs/api/java/nio/channels/Selector.html): > > * The selected-key set is the set of keys such that each key's channel was det...
333,596
<p>When create a new ASP.NET MVC project in Visual Studio 2008, there is a Default.aspx page by default. It has one line</p> <blockquote> </blockquote> <p>In its Page_Load function, it just redirects to "/" to go through the routing procedure.</p> <pre><code> public void Page_Load(object sender, System.EventAr...
[ { "answer_id": 333609, "author": "mapache", "author_id": 41422, "author_profile": "https://Stackoverflow.com/users/41422", "pm_score": 3, "selected": false, "text": "<p>What's happening here, is that the Url requested (which was Default.aspx) is being re-written to the application root \...
2008/12/02
[ "https://Stackoverflow.com/questions/333596", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26349/" ]
When create a new ASP.NET MVC project in Visual Studio 2008, there is a Default.aspx page by default. It has one line > > In its Page\_Load function, it just redirects to "/" to go through the routing procedure. ``` public void Page_Load(object sender, System.EventArgs e) { HttpContext.Current.Rewr...
Older versions of IIS need a startup document and it also gives you something to right-click on to get the "View in Browser" option.
333,630
<p>I have a single line CEikLabel in my application that needs to scroll text.</p> <p>The simple solution that comes to mind (but possibly naive) would be something like..</p> <pre><code>[begin pseduo code] on timer.fire { set slightly shifted text in label redraw label } start timer [end pseudo code] </code...
[ { "answer_id": 333640, "author": "M. Utku ALTINKAYA", "author_id": 40948, "author_profile": "https://Stackoverflow.com/users/40948", "pm_score": 4, "selected": true, "text": "<p>You can never receive an error, or notice for a UDP packet that did not reach destination.</p>\n" }, { ...
2008/12/02
[ "https://Stackoverflow.com/questions/333630", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33604/" ]
I have a single line CEikLabel in my application that needs to scroll text. The simple solution that comes to mind (but possibly naive) would be something like.. ``` [begin pseduo code] on timer.fire { set slightly shifted text in label redraw label } start timer [end pseudo code] ``` Using a CPeriodic cla...
You can never receive an error, or notice for a UDP packet that did not reach destination.
333,634
<p>Is it possible to do a HTTP Head request solely using an XMLHTTPRequest in JavaScript?</p> <p>My motivation is to conserve bandwidth.</p> <p>If not, is it possible to fake it?</p>
[ { "answer_id": 333657, "author": "doekman", "author_id": 56, "author_profile": "https://Stackoverflow.com/users/56", "pm_score": 8, "selected": true, "text": "<p>Easy, just use the HEAD method, instead of GET or POST:</p>\n\n<pre><code>function UrlExists(url, callback)\n{\n var http =...
2008/12/02
[ "https://Stackoverflow.com/questions/333634", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6691/" ]
Is it possible to do a HTTP Head request solely using an XMLHTTPRequest in JavaScript? My motivation is to conserve bandwidth. If not, is it possible to fake it?
Easy, just use the HEAD method, instead of GET or POST: ``` function UrlExists(url, callback) { var http = new XMLHttpRequest(); http.open('HEAD', url); http.onreadystatechange = function() { if (this.readyState == this.DONE) { callback(this.status != 404); } }; http.sen...
333,664
<p>I can find lots of information on how Long Polling works (For example, <a href="http://jfarcand.wordpress.com/2007/05/15/new-adventures-in-comet-polling-long-polling-or-http-streaming-with-ajax-which-one-to-choose/" rel="noreferrer">this</a>, and <a href="http://en.wikipedia.org/wiki/Comet_(programming)#Ajax_with_lo...
[ { "answer_id": 333677, "author": "adam", "author_id": 33604, "author_profile": "https://Stackoverflow.com/users/33604", "pm_score": 4, "selected": false, "text": "<p>I used <a href=\"http://ajaxian.com/archives/comet-with-php\" rel=\"noreferrer\">this</a> to get to grips with Comet, I ha...
2008/12/02
[ "https://Stackoverflow.com/questions/333664", "https://Stackoverflow.com", "https://Stackoverflow.com/users/745/" ]
I can find lots of information on how Long Polling works (For example, [this](http://jfarcand.wordpress.com/2007/05/15/new-adventures-in-comet-polling-long-polling-or-http-streaming-with-ajax-which-one-to-choose/), and [this](http://en.wikipedia.org/wiki/Comet_(programming)#Ajax_with_long_polling)), but no *simple* exa...
It's simpler than I initially thought.. Basically you have a page that does nothing, until the data you want to send is available (say, a new message arrives). Here is a really basic example, which sends a simple string after 2-10 seconds. 1 in 3 chance of returning an error 404 (to show error handling in the coming J...
333,665
<p>I tried the following code to get an alert upon closing a browser window:</p> <pre><code>window.onbeforeunload = confirmExit; function confirmExit() { return "You have attempted to leave this page. If you have made any changes to the fields without clicking the Save button, your changes will be lost. Are you su...
[ { "answer_id": 333672, "author": "M. Utku ALTINKAYA", "author_id": 40948, "author_profile": "https://Stackoverflow.com/users/40948", "pm_score": 6, "selected": true, "text": "<p>Keep your code as is and use jQuery to handle links:</p>\n\n<pre><code>$(function () {\n $(\"a\").click(funct...
2008/12/02
[ "https://Stackoverflow.com/questions/333665", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42348/" ]
I tried the following code to get an alert upon closing a browser window: ``` window.onbeforeunload = confirmExit; function confirmExit() { return "You have attempted to leave this page. If you have made any changes to the fields without clicking the Save button, your changes will be lost. Are you sure you want to...
Keep your code as is and use jQuery to handle links: ``` $(function () { $("a").click(function { window.onbeforeunload = null; }); }); ```
333,669
<p>Getting this <strong>error</strong>:</p> <pre><code>NativeError = 258 Error = [Microsoft][SQL Native Client]Shared Memory Provider: Timeout error [258]. SQLState = HYT00, NativeError = 0 Error = [Microsoft][SQL Native Client]Login timeout expired SQLState = 08001, NativeError = 258 Error = [Microsoft][SQL Native C...
[ { "answer_id": 333675, "author": "Samiksha", "author_id": 29515, "author_profile": "https://Stackoverflow.com/users/29515", "pm_score": -1, "selected": false, "text": "<p>Restart your SQL server or try increasing the pool size in your connection string.</p>\n" }, { "answer_id": 3...
2008/12/02
[ "https://Stackoverflow.com/questions/333669", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Getting this **error**: ``` NativeError = 258 Error = [Microsoft][SQL Native Client]Shared Memory Provider: Timeout error [258]. SQLState = HYT00, NativeError = 0 Error = [Microsoft][SQL Native Client]Login timeout expired SQLState = 08001, NativeError = 258 Error = [Microsoft][SQL Native Client]Unable to complete lo...
Try setting the SqlCommand.CommandTimeout property to 0. For more info, there is a MSDN article [here](http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.commandtimeout.aspx).
333,687
<p>My function iterates through every node of an instance of an <code>XMLDocument</code>. It checks to see if the current node's name is in a lookup list. If it is, it applies appropriate validation to the value of the current node.</p> <p>When the validation method indicates that the value has been changed, I want ...
[ { "answer_id": 333718, "author": "xan", "author_id": 15667, "author_profile": "https://Stackoverflow.com/users/15667", "pm_score": 3, "selected": true, "text": "<p>Can you not modify the existing nodes (which ate already in the correct structure and in an XMLDocument, then re-serialise t...
2008/12/02
[ "https://Stackoverflow.com/questions/333687", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7703/" ]
My function iterates through every node of an instance of an `XMLDocument`. It checks to see if the current node's name is in a lookup list. If it is, it applies appropriate validation to the value of the current node. When the validation method indicates that the value has been changed, I want to replace the value in...
Can you not modify the existing nodes (which ate already in the correct structure and in an XMLDocument, then re-serialise the XMLDocument? If the nodes are simple text containters then the ``` .InnerText ``` property is the one you want.
333,690
<p>Every tutorial or explanation of REST just goes too complicated too quickly - the learning curve rises so fast after the initial explanation of CRUD and the supposed simplicity over SOAP. Why can't people write decent tutorials anymore!</p> <p>I'm looking at Restlet - and its not the best, there are things missing...
[ { "answer_id": 333716, "author": "gregnostic", "author_id": 41891, "author_profile": "https://Stackoverflow.com/users/41891", "pm_score": 4, "selected": true, "text": "<p>It sounds like you could use a solid understanding of the fundamentals of REST, and for that I <em>highly</em> recomm...
2008/12/02
[ "https://Stackoverflow.com/questions/333690", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5175/" ]
Every tutorial or explanation of REST just goes too complicated too quickly - the learning curve rises so fast after the initial explanation of CRUD and the supposed simplicity over SOAP. Why can't people write decent tutorials anymore! I'm looking at Restlet - and its not the best, there are things missing in the tut...
It sounds like you could use a solid understanding of the fundamentals of REST, and for that I *highly* recommend [RESTful Web Services](https://rads.stackoverflow.com/amzn/click/com/0596529260) by Leonard Richardson and Sam Ruby. I provides a great introduction to REST: what it is and how to implement a (practical) RE...
333,706
<p>There is one thing that I do not understand... </p> <p>Imagine you have a <strong>text</strong> = "hello world" and you want to split it.</p> <p>In some places I see people that want to split the <strong>text</strong> doing:</p> <pre><code>string.split(text) </code></pre> <p>In other places I see people just do...
[ { "answer_id": 333715, "author": "S.Lott", "author_id": 10661, "author_profile": "https://Stackoverflow.com/users/10661", "pm_score": 4, "selected": false, "text": "<p>The <code>string.split(stringobj)</code> is a feature of the <code>string</code> module, which must be imported separate...
2008/12/02
[ "https://Stackoverflow.com/questions/333706", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41795/" ]
There is one thing that I do not understand... Imagine you have a **text** = "hello world" and you want to split it. In some places I see people that want to split the **text** doing: ``` string.split(text) ``` In other places I see people just doing: ``` text.split() ``` What’s the difference? Why you do in o...
Interestingly, the docstrings for the two are not completely the same in Python 2.5.1: ``` >>> import string >>> help(string.split) Help on function split in module string: split(s, sep=None, maxsplit=-1) split(s [,sep [,maxsplit]]) -> list of strings Return a list of the words in the string s, using sep as ...
333,729
<p>I want to include a js file depending on the value of the current Locale. I have tried to access it from JSP as follows: </p> <pre><code>&lt;%@ page import="java.util.Locale" %&gt; &lt;% if( ((Locale) pageContext.getAttribute("org.apache.struts.action.LOCALE",PageContext.REQUEST_SCOPE)).getLanguage().equals("de")...
[ { "answer_id": 333915, "author": "Ken Gentle", "author_id": 8709, "author_profile": "https://Stackoverflow.com/users/8709", "pm_score": 2, "selected": false, "text": "<p>I can't find a constant <code>org.apache.struts.action.LOCALE</code> in the Struts 1.x documentation - should it be <...
2008/12/02
[ "https://Stackoverflow.com/questions/333729", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2138/" ]
I want to include a js file depending on the value of the current Locale. I have tried to access it from JSP as follows: ``` <%@ page import="java.util.Locale" %> <% if( ((Locale) pageContext.getAttribute("org.apache.struts.action.LOCALE",PageContext.REQUEST_SCOPE)).getLanguage().equals("de")) { %> <script src=...
At the moment I am using this : ``` <c:set var="localeCode" value="${pageContext.response.locale}" /> ``` This can later be access by using `${localeCode}` 1. **Scriplet mode**, discouraged! See [Why not use Scriptlets](http://www.coderanch.com/how-to/java/WhyNotUseScriptlets) for reason not to use a scriptlet. T...
333,735
<p>What's the best way to:</p> <ol> <li>Get the data from the db using a single query</li> <li>Loop through the results building e.g. a nested unordered list</li> </ol> <p>My table has <code>id</code>, <code>name</code> and <code>parent_id</code> columns.</p> <hr> <p>Here's an update to my last answer, with a count...
[ { "answer_id": 333754, "author": "ThoKra", "author_id": 38254, "author_profile": "https://Stackoverflow.com/users/38254", "pm_score": 2, "selected": false, "text": "<p>MySQL have created a good article on this subject: <a href=\"http://mikehillyer.com/articles/managing-hierarchical-data-...
2008/12/02
[ "https://Stackoverflow.com/questions/333735", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4196/" ]
What's the best way to: 1. Get the data from the db using a single query 2. Loop through the results building e.g. a nested unordered list My table has `id`, `name` and `parent_id` columns. --- Here's an update to my last answer, with a counter that gives each ul a nesting 'level' class, and some comments. Could a...
MySQL have created a good article on this subject: [Managing Hierarchical Data in MySQL](http://mikehillyer.com/articles/managing-hierarchical-data-in-mysql/)
333,737
<p>Is there a function the .NET framework that can evaluate a numeric expression contained in a string and return the result? F.e.:</p> <pre><code>string mystring = "3*(2+4)"; int result = EvaluateExpression(mystring); Console.Writeln(result); // Outputs 18 </code></pre> <p>Is there a standard framework function that...
[ { "answer_id": 333746, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 2, "selected": false, "text": "<p>You could fairly easily run this through the CSharpCodeProvider with suitable fluff wrapping it (a type and a method,...
2008/12/02
[ "https://Stackoverflow.com/questions/333737", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37119/" ]
Is there a function the .NET framework that can evaluate a numeric expression contained in a string and return the result? F.e.: ``` string mystring = "3*(2+4)"; int result = EvaluateExpression(mystring); Console.Writeln(result); // Outputs 18 ``` Is there a standard framework function that you can replace my `Evalu...
If you want to evaluate a string expression use the below code snippet. ``` using System.Data; DataTable dt = new DataTable(); var v = dt.Compute("3 * (2+4)",""); ```
333,750
<p>I have the following five tables:</p> <ul> <li>ISP</li> <li>Product</li> <li>Connection</li> <li>AddOn</li> <li>AddOn/Product (pivot table for many-to-many relationship).</li> </ul> <p>Each Product is linked to an ISP, each Connection is listed to a Product. Each product can have a number of add-ons, through the u...
[ { "answer_id": 333816, "author": "Tony Andrews", "author_id": 18747, "author_profile": "https://Stackoverflow.com/users/18747", "pm_score": 0, "selected": false, "text": "<p>You could add to the WHERE clause:</p>\n\n<pre><code>AND NOT EXISTS (SELECT NULL FROM addon a2\n WH...
2008/12/02
[ "https://Stackoverflow.com/questions/333750", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9479/" ]
I have the following five tables: * ISP * Product * Connection * AddOn * AddOn/Product (pivot table for many-to-many relationship). Each Product is linked to an ISP, each Connection is listed to a Product. Each product can have a number of add-ons, through the use of the pivot table (which simply has 2 fields, one fo...
``` GROUP BY set-of-column HAVING SUM(CASE WHEN ISNULL(pa.addon_id, 0) IN (1,14,237) THEN 1 ELSE 0 END) = 3 ```
333,767
<p>Is there some smart way to retreive the installation path when working within a dll (C#) which will be called from an application in a different folder?</p> <p>I'm developing an add-in for an application. My add-in is written in C#. The application that will use is written in C and needs to compile some stuff durin...
[ { "answer_id": 333786, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 5, "selected": true, "text": "<p>I think what you want is <code>Assembly.GetExecutingAssembly().Location</code>.</p>\n" }, { "answer_id": 3337...
2008/12/02
[ "https://Stackoverflow.com/questions/333767", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15763/" ]
Is there some smart way to retreive the installation path when working within a dll (C#) which will be called from an application in a different folder? I'm developing an add-in for an application. My add-in is written in C#. The application that will use is written in C and needs to compile some stuff during evaluati...
I think what you want is `Assembly.GetExecutingAssembly().Location`.
333,776
<p>I want to link to a page which contains multiple support topics. When the user clicks on the link while being on an external site, the topic should be expanded as soon as the user arrives on the support page.</p> <p>Example:</p> <p>I link to this page</p> <pre><code>http://www.nintendo.de/NOE/de_DE/support/ninten...
[ { "answer_id": 333795, "author": "PhiLho", "author_id": 15459, "author_profile": "https://Stackoverflow.com/users/15459", "pm_score": 1, "selected": true, "text": "<p>Good idea, but I don't see the question... :-)</p>\n\n<p>The way I saw on some sites, like deviantART, is to use the shar...
2008/12/02
[ "https://Stackoverflow.com/questions/333776", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42415/" ]
I want to link to a page which contains multiple support topics. When the user clicks on the link while being on an external site, the topic should be expanded as soon as the user arrives on the support page. Example: I link to this page ``` http://www.nintendo.de/NOE/de_DE/support/nintendo_ds_lite_159_142.html ```...
Good idea, but I don't see the question... :-) The way I saw on some sites, like deviantART, is to use the sharp anchor notation: myURL.com/foo/page.html#TopicToExpand JS can analyze the current URL and get the anchor part, then do whatever you need to do to highlight/jump to the right place.
333,812
<p>How can I list all the local users configured on a windows machine (Win2000+) using java.<br> I would prefer doing this with ought using any java 2 com bridges, or any other third party library if possible.<br> Preferable some native method to Java. </p>
[ { "answer_id": 333848, "author": "gimel", "author_id": 6491, "author_profile": "https://Stackoverflow.com/users/6491", "pm_score": 3, "selected": true, "text": "<p>Using a Java-COM Bridge , like <a href=\"http://danadler.com/jacob/\" rel=\"nofollow noreferrer\">Jacob</a>. You then select...
2008/12/02
[ "https://Stackoverflow.com/questions/333812", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26042/" ]
How can I list all the local users configured on a windows machine (Win2000+) using java. I would prefer doing this with ought using any java 2 com bridges, or any other third party library if possible. Preferable some native method to Java.
Using a Java-COM Bridge , like [Jacob](http://danadler.com/jacob/). You then select an appropriate COM library, e.g. [COM API for WMI](http://msdn.microsoft.com/en-us/library/aa389276(VS.85).aspx) to list local users, or any other Windows management information. The [Win32\_SystemUsers](http://msdn.microsoft.com/en-us...
333,819
<p>I am currently in the process of replacing the IBM WebService framework with Axis2. When generating the code from the WSDL file, I use the Maven plugin WSDL2Code. However, the code created is always wrong. Or rather, the packagenames are always wrong, which in turn makes every method called uncallable (creating even...
[ { "answer_id": 333836, "author": "leppie", "author_id": 15541, "author_profile": "https://Stackoverflow.com/users/15541", "pm_score": 0, "selected": false, "text": "<p>Maybe 'src' is part of ${basedir} ?</p>\n" }, { "answer_id": 333914, "author": "Community", "author_id":...
2008/12/02
[ "https://Stackoverflow.com/questions/333819", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am currently in the process of replacing the IBM WebService framework with Axis2. When generating the code from the WSDL file, I use the Maven plugin WSDL2Code. However, the code created is always wrong. Or rather, the packagenames are always wrong, which in turn makes every method called uncallable (creating even mo...
Version 1.4.1 has a few more configuration options that are not really documented (have a look at the the source of org.apache.axis2.maven2.wsdl2code.WSDL2CodeMojo)... Just use <flattenFiles>true</flattenFiles> - that should solve your problem :-)
333,828
<p>I've built a small application which has User Management, a frontend console to enter data and a backend console to control parts of the frontend. The frontend adds rows to a MySQL database which are timestamped. The backend needs to be able to select rows from the database between X and Y dates.</p> <p>Everything ...
[ { "answer_id": 333844, "author": "Tim", "author_id": 33914, "author_profile": "https://Stackoverflow.com/users/33914", "pm_score": 4, "selected": true, "text": "<p>MySQL datetime should be formatted with dashes:</p>\n\n<p>YYYY-MM-DD HH:MM:SS</p>\n\n<p><a href=\"http://dev.mysql.com/doc/r...
2008/12/02
[ "https://Stackoverflow.com/questions/333828", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42428/" ]
I've built a small application which has User Management, a frontend console to enter data and a backend console to control parts of the frontend. The frontend adds rows to a MySQL database which are timestamped. The backend needs to be able to select rows from the database between X and Y dates. Everything works so f...
MySQL datetime should be formatted with dashes: YYYY-MM-DD HH:MM:SS <http://dev.mysql.com/doc/refman/5.0/en/datetime.html> Then you can query for date ranges a couple of ways: ``` select * from table where date >= '[start date]' and date <= '[end date]'; ``` or ``` select * from table where date between '[star...
333,829
<p>In .NET, a value type (C# <code>struct</code>) can't have a constructor with no parameters. According to <a href="https://stackoverflow.com/questions/203695/structure-vs-class-in-c#204009">this post</a> this is mandated by the CLI specification. What happens is that for every value-type a default constructor is crea...
[ { "answer_id": 333840, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 9, "selected": true, "text": "<p><strike> <strong>Note:</strong> the answer below was written a long time prior to C# 6, which is planning to introduce...
2008/12/02
[ "https://Stackoverflow.com/questions/333829", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3848/" ]
In .NET, a value type (C# `struct`) can't have a constructor with no parameters. According to [this post](https://stackoverflow.com/questions/203695/structure-vs-class-in-c#204009) this is mandated by the CLI specification. What happens is that for every value-type a default constructor is created (by the compiler?) wh...
**Note:** the answer below was written a long time prior to C# 6, which is planning to introduce the ability to declare parameterless constructors in structs - but they still won't be called in all situations (e.g. for array creation) (in the end this feature [was not added to C# 6](https://stackoverflow.com/questions/...
333,839
<p>I have a MySQL query that I use to retrieve random rows from a table. The query is:</p> <pre><code>SELECT * FROM QUESTION WHERE TESTID=1 ORDER BY RAND() LIMIT 10; </code></pre> <p>Now I need to change this query to <strong><em>Hibernate</em></strong>. Did a bit of googling but couldn't find the answer. Can someone...
[ { "answer_id": 333846, "author": "Romain Linsolas", "author_id": 26457, "author_profile": "https://Stackoverflow.com/users/26457", "pm_score": 2, "selected": true, "text": "<p>According to this <a href=\"http://cephas.net/blog/2004/05/21/hibernate-returning-n-records-in-a-random-order/\"...
2008/12/02
[ "https://Stackoverflow.com/questions/333839", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40945/" ]
I have a MySQL query that I use to retrieve random rows from a table. The query is: ``` SELECT * FROM QUESTION WHERE TESTID=1 ORDER BY RAND() LIMIT 10; ``` Now I need to change this query to ***Hibernate***. Did a bit of googling but couldn't find the answer. Can someone provide help on this?
According to this [post](http://cephas.net/blog/2004/05/21/hibernate-returning-n-records-in-a-random-order/), you can do that : ``` String query = "from QUESTION order by newid()"; Query q = session.createQuery(query); q.setMaxResults(10); ``` Not sure if it will work (especially for the random part), but you can tr...
333,841
<p>Is there any way to have a look at signatures of anonymous functions in ActionScript 3 during runtime?</p> <p>I would like to validate <code>Function</code> objects passed in as arguments to other functions and make sure that they accept the correct number of arguments (with the correct types) and return a value of...
[ { "answer_id": 334491, "author": "Luca Tettamanti", "author_id": 42448, "author_profile": "https://Stackoverflow.com/users/42448", "pm_score": 1, "selected": false, "text": "<p>As a rough approximation you can check the number of parameters using length property, e.g.:</p>\n\n<pre><code>...
2008/12/02
[ "https://Stackoverflow.com/questions/333841", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4111/" ]
Is there any way to have a look at signatures of anonymous functions in ActionScript 3 during runtime? I would like to validate `Function` objects passed in as arguments to other functions and make sure that they accept the correct number of arguments (with the correct types) and return a value of the correct type. `...
It doesn't look like the runtime allows you to reflect on anonymous functions, which is a shame. Anonymous functions are (perhaps by definition) marked as `dynamic`. If you pass an incompatible type into an anonymous function, *no error is thrown*. Any type mismatches will be silently cast as best they can. Passing so...
333,850
<p>I'm trying to work out a way of passing the web current http context to a service class (or initialising the class with a reference to it). I am doing this to abstract the rest of the app away from needing to know anything about the http context. </p> <p>I also want the service to be testable using TDD, probably us...
[ { "answer_id": 333866, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 3, "selected": true, "text": "<p>This is why HttpContextBase and HttpContextWrapper were introduced. You probably want to use HttpContextBase and whe...
2008/12/02
[ "https://Stackoverflow.com/questions/333850", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31128/" ]
I'm trying to work out a way of passing the web current http context to a service class (or initialising the class with a reference to it). I am doing this to abstract the rest of the app away from needing to know anything about the http context. I also want the service to be testable using TDD, probably using one of...
This is why HttpContextBase and HttpContextWrapper were introduced. You probably want to use HttpContextBase and when passing the real context in, use `new HttpContextWrapper( httpContext )`, although, I think that what is available to you in the controller is already of type HttpContextBase. I would create one of thes...
333,856
<p>Is it possible to get a report of the records that are updated using a update query, without using a recordset?</p> <p>Ex:</p> <p><code>sqltext = update table employees set bonus = 0 where salary &gt; 50000<br> DoCmd.RunSQL sqltext</code></p> <p>After this query runs, is it possible to get the name of the employe...
[ { "answer_id": 333892, "author": "JFV", "author_id": 1391, "author_profile": "https://Stackoverflow.com/users/1391", "pm_score": 1, "selected": false, "text": "<p>I don't see any way at this time to get the information after the update query has run unless you have another distinguishing...
2008/12/02
[ "https://Stackoverflow.com/questions/333856", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31132/" ]
Is it possible to get a report of the records that are updated using a update query, without using a recordset? Ex: `sqltext = update table employees set bonus = 0 where salary > 50000 DoCmd.RunSQL sqltext` After this query runs, is it possible to get the name of the employees for whom this update query was perfo...
It's never a good idea to use `DoCmd.RunSQL` as it generates a prompt (which you have to turn off if you don't want it), and it completes the updates even if errors occur, and doesn't report the errors. Much better is to replace it with a function that executes the same SQL: ``` Public Function SQLRun(strSQL As String...
333,875
<p>I have a SelectList that I first check for a selected value != null and then want to use this selectedvalue in a where clause for a filter. Like so:</p> <pre><code>if(searchBag.Qualities.SelectedValue != null){ ListItem selected = (ListItem)searchBag.Qualities.SelectedValue; } </code></pre> <p>I made the cast ...
[ { "answer_id": 333892, "author": "JFV", "author_id": 1391, "author_profile": "https://Stackoverflow.com/users/1391", "pm_score": 1, "selected": false, "text": "<p>I don't see any way at this time to get the information after the update query has run unless you have another distinguishing...
2008/12/02
[ "https://Stackoverflow.com/questions/333875", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11333/" ]
I have a SelectList that I first check for a selected value != null and then want to use this selectedvalue in a where clause for a filter. Like so: ``` if(searchBag.Qualities.SelectedValue != null){ ListItem selected = (ListItem)searchBag.Qualities.SelectedValue; } ``` I made the cast in a seperate useless line...
It's never a good idea to use `DoCmd.RunSQL` as it generates a prompt (which you have to turn off if you don't want it), and it completes the updates even if errors occur, and doesn't report the errors. Much better is to replace it with a function that executes the same SQL: ``` Public Function SQLRun(strSQL As String...
333,876
<p>Is there some way to determine what file currently is being rendered by Rails (2.2) in a helper method. An example result would be "/sessions/new.html.erb" or something similar.</p> <p>I am trying to write a helper function that does something based on the file name that is being rendered, so I need a reliable way ...
[ { "answer_id": 333892, "author": "JFV", "author_id": 1391, "author_profile": "https://Stackoverflow.com/users/1391", "pm_score": 1, "selected": false, "text": "<p>I don't see any way at this time to get the information after the update query has run unless you have another distinguishing...
2008/12/02
[ "https://Stackoverflow.com/questions/333876", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42431/" ]
Is there some way to determine what file currently is being rendered by Rails (2.2) in a helper method. An example result would be "/sessions/new.html.erb" or something similar. I am trying to write a helper function that does something based on the file name that is being rendered, so I need a reliable way to obtain ...
It's never a good idea to use `DoCmd.RunSQL` as it generates a prompt (which you have to turn off if you don't want it), and it completes the updates even if errors occur, and doesn't report the errors. Much better is to replace it with a function that executes the same SQL: ``` Public Function SQLRun(strSQL As String...
333,911
<p>I'm getting crazy with this IE 7...</p> <p>==> hhttp://neu.emergent-innovation.com/</p> <p>Why does following function not work in IE 7, but perfectly with Firefox? Is there a bug in the animate-function?</p> <pre><code>function accordion_starting_page(){ // hide all elements except the first one $('#FCE-...
[ { "answer_id": 333975, "author": "nickf", "author_id": 9021, "author_profile": "https://Stackoverflow.com/users/9021", "pm_score": 0, "selected": false, "text": "<p>I'm not sure what the problem is exactly... perhaps you can't animate to \"<code>display: none</code>\" ? Try this:</p>\n\n...
2008/12/02
[ "https://Stackoverflow.com/questions/333911", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27404/" ]
I'm getting crazy with this IE 7... ==> hhttp://neu.emergent-innovation.com/ Why does following function not work in IE 7, but perfectly with Firefox? Is there a bug in the animate-function? ``` function accordion_starting_page(){ // hide all elements except the first one $('#FCE-Inhalt02-ContentWrapper .FCE...
As stated by Paul, when using the method. Animate () jQuery IE7 browser does not recognize internally the property 'position'. eg CSS rule: ``` li p (bottom:-178px; color: white; background-color: # 4d4d4d; height: 100%; padding: 30px 10px 0 10px;) ``` Implementation of animation in jQuery: ``` $('li').hover(funct...
333,923
<p>I'm building a traditional ASP.NET Web Service -- the style built using asmx. It's a pretty simple service. I started using the new Ado.NET Entity Framework for my persistence layer, and I'm running into some problems:</p> <p>1) I don't like the WSDL that gets automatically generated -- the complex types were ge...
[ { "answer_id": 334081, "author": "RobS", "author_id": 18471, "author_profile": "https://Stackoverflow.com/users/18471", "pm_score": 2, "selected": true, "text": "<p>You're facing the kind of wall many of us have faced when trying to use the Entity Framework in an SOA style architecture. ...
2008/12/02
[ "https://Stackoverflow.com/questions/333923", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8531/" ]
I'm building a traditional ASP.NET Web Service -- the style built using asmx. It's a pretty simple service. I started using the new Ado.NET Entity Framework for my persistence layer, and I'm running into some problems: 1) I don't like the WSDL that gets automatically generated -- the complex types were getting defined...
You're facing the kind of wall many of us have faced when trying to use the Entity Framework in an SOA style architecture. Version 1.0 of the Entity Framework doesn't work very well in the scenario you've described, as you end up in a world of hurt trying to manage object contexts (and likely having to cache them). ...
333,946
<p>How would you write ToUpper() if it didn't exist? Bonus points for i18n and L10n</p> <p>Curiosity sparked by this: <a href="http://thedailywtf.com/Articles/The-Long-Way-toUpper.aspx" rel="nofollow noreferrer">http://thedailywtf.com/Articles/The-Long-Way-toUpper.aspx</a></p>
[ { "answer_id": 333971, "author": "leppie", "author_id": 15541, "author_profile": "https://Stackoverflow.com/users/15541", "pm_score": 3, "selected": false, "text": "<p>I dont think SO can handle the size of the unicode tables in a single posting :)</p>\n\n<p>Unfortunately, it is not so ...
2008/12/02
[ "https://Stackoverflow.com/questions/333946", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12744/" ]
How would you write ToUpper() if it didn't exist? Bonus points for i18n and L10n Curiosity sparked by this: <http://thedailywtf.com/Articles/The-Long-Way-toUpper.aspx>
1. I download the Unicode tables 2. I import the tables into a database 3. I write a method upper(). Here is a sample implementation ;) ``` public static String upper(String s) { if (s == null) { return null; } final int N = s.length(); // Mind the optimization! PreparedStatement stmtName = n...
333,953
<p>Is there a C# equivalent method to Java's <code>Exception.printStackTrace()</code> or do I have to write something myself, working my way through the InnerExceptions?</p>
[ { "answer_id": 333959, "author": "JeeBee", "author_id": 17832, "author_profile": "https://Stackoverflow.com/users/17832", "pm_score": 0, "selected": false, "text": "<p>Is there no C# Logging API that can take an Exception as an argument and handle everything for you, like Java's Log4J do...
2008/12/02
[ "https://Stackoverflow.com/questions/333953", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6583/" ]
Is there a C# equivalent method to Java's `Exception.printStackTrace()` or do I have to write something myself, working my way through the InnerExceptions?
Try this: ``` Console.WriteLine(ex.ToString()); ``` From <http://msdn.microsoft.com/en-us/library/system.exception.tostring.aspx>: > > The default implementation of ToString obtains the name of the class that threw the current exception, the message, the result of calling ToString on the inner exception, and the r...
333,954
<p>I'm working on a client-server solution that uses .NET 2.0 Remoting (server activation, binary formatting over TCP channel, Vista Ultimate) for communication purposes. Currently I'm profiling the application and run everything on the same machine. I noticed that if I start the application, everything works just fine...
[ { "answer_id": 333967, "author": "Dave Markle", "author_id": 24995, "author_profile": "https://Stackoverflow.com/users/24995", "pm_score": 0, "selected": false, "text": "<p>Never. Are you doing something that's causing extra instances of your remoting layer to be registered/instantiated...
2008/12/02
[ "https://Stackoverflow.com/questions/333954", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21952/" ]
I'm working on a client-server solution that uses .NET 2.0 Remoting (server activation, binary formatting over TCP channel, Vista Ultimate) for communication purposes. Currently I'm profiling the application and run everything on the same machine. I noticed that if I start the application, everything works just fine fo...
Use some network monitoring tool like [Wireshark](http://www.wireshark.org/) to see if your problem is network related or server sync related. If it proves that it is not a network issue, then try to attach a simple custom sync in the chain (just before the channel) to log and get the timing between the hooks.
333,965
<p>I'm trying to write a query for an advanced search page on my document archiving system. I'm attempting to search by multiple optional parameters. I have about 5 parameters that could be empty strings or search strings. I know I shouldn't have to check for each as a string or empty and create a separate stored pr...
[ { "answer_id": 333974, "author": "Dave Markle", "author_id": 24995, "author_profile": "https://Stackoverflow.com/users/24995", "pm_score": 1, "selected": false, "text": "<p>You can put OR's in your WHERE clause like so:</p>\n\n<pre><code>WHERE \n (@var1 = '' OR col1 = @var1) AND\n (@...
2008/12/02
[ "https://Stackoverflow.com/questions/333965", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1491425/" ]
I'm trying to write a query for an advanced search page on my document archiving system. I'm attempting to search by multiple optional parameters. I have about 5 parameters that could be empty strings or search strings. I know I shouldn't have to check for each as a string or empty and create a separate stored procedur...
You could use COALESCE (or ISNULL) like so: ``` WHERE COALESCE(@var1, col1) = col1 AND COALESCE(@var2, col2) = col2 AND COALESCE(@var3, col3) = col3 ```
333,995
<p>Is there a simple way to detect, within Python code, that this code is being executed through the Python debugger?</p> <p>I have a small Python application that uses Java code (thanks to JPype). When I'm debugging the Python part, I'd like the embedded JVM to be passed debug options too.</p>
[ { "answer_id": 334073, "author": "dowski", "author_id": 21712, "author_profile": "https://Stackoverflow.com/users/21712", "pm_score": 1, "selected": false, "text": "<p>From taking a quick look at the pdb docs and source code, it doesn't look like there is a built in way to do this. I su...
2008/12/02
[ "https://Stackoverflow.com/questions/333995", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11618/" ]
Is there a simple way to detect, within Python code, that this code is being executed through the Python debugger? I have a small Python application that uses Java code (thanks to JPype). When I'm debugging the Python part, I'd like the embedded JVM to be passed debug options too.
A solution working with Python 2.4 (it should work with any version superior to 2.1) and Pydev: ``` import inspect def isdebugging(): for frame in inspect.stack(): if frame[1].endswith("pydevd.py"): return True return False ``` The same should work with pdb by simply replacing `pydevd.py` with `pdb.py...
334,038
<p>In a Swing app a method should continue only after user enters a correct answer. The correct answer is stored in a <code>String</code> with user answer being set by a listener to another <code>String</code>. So, the code is</p> <pre><code>while (!correctAnswer.equals(currentAnswer)) { // wait for user to click...
[ { "answer_id": 334056, "author": "unwind", "author_id": 28169, "author_profile": "https://Stackoverflow.com/users/28169", "pm_score": 0, "selected": false, "text": "<p>If your strings are coming from a human user at GUI rates, there's very little point in optimizing for performance. The ...
2008/12/02
[ "https://Stackoverflow.com/questions/334038", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15187/" ]
In a Swing app a method should continue only after user enters a correct answer. The correct answer is stored in a `String` with user answer being set by a listener to another `String`. So, the code is ``` while (!correctAnswer.equals(currentAnswer)) { // wait for user to click the button with the correct answer ...
Are you new to UI programming? The reason I ask is that your answer is predicated on a procedural style of coding, which isn't what UIs are about. It tends to be event-driven. In this case the solution is pretty easy: add an event listener (`ActionListener`) to the submit button and check the result there. If its OK, ...
334,057
<p>I have a very simple html page here:</p> <p><a href="http://www.nomorepasting.com/getpaste.php?pasteid=22407" rel="nofollow noreferrer">http://www.nomorepasting.com/getpaste.php?pasteid=22407</a></p> <p>And I have 4 layers on the page. The reason for this is it is the framework oif a much more complicated site, I ...
[ { "answer_id": 334106, "author": "TravisO", "author_id": 35116, "author_profile": "https://Stackoverflow.com/users/35116", "pm_score": 1, "selected": false, "text": "<p>Tables are for tabular data (think Excel). If you have a grid of data to display use a table. When it comes to page l...
2008/12/02
[ "https://Stackoverflow.com/questions/334057", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1246613/" ]
I have a very simple html page here: <http://www.nomorepasting.com/getpaste.php?pasteid=22407> And I have 4 layers on the page. The reason for this is it is the framework oif a much more complicated site, I have simplified it to ask my question. Basically, I want to be able to click on different links in layer 2 and ...
(In response to Joshxtothe4's comment... I needed more space to respond) Changing the class back to class1 will not show the text again, unfortunately. The code I gave will hide the text, always, if it's found in a span. You could do something like below, and add another CSS statement that will hide the span if class4...
334,095
<p>I have been trying to get more in to TDD. Currently keeping it simple with lots of <code>Debug.Asserts</code> in a console application.</p> <p>Part of the tests I wanted to complete was ensuring that events were raised from the object, the correct number of times, since client code will depend on these events.</p> ...
[ { "answer_id": 334105, "author": "Steven A. Lowe", "author_id": 9345, "author_profile": "https://Stackoverflow.com/users/9345", "pm_score": 0, "selected": false, "text": "<p>looks fine to me - since it works ;-)</p>\n" }, { "answer_id": 334118, "author": "Mendelt", "autho...
2008/12/02
[ "https://Stackoverflow.com/questions/334095", "https://Stackoverflow.com", "https://Stackoverflow.com/users/832/" ]
I have been trying to get more in to TDD. Currently keeping it simple with lots of `Debug.Asserts` in a console application. Part of the tests I wanted to complete was ensuring that events were raised from the object, the correct number of times, since client code will depend on these events. So, I began thinking abo...
The easiest thing you can do is subscribe an anonymous method or a lambda to the event and increment a counter that's local to your test in it. No need to use an extra class at all. I found this won't make your code very readable so I've done about the same thing. I've written monitor objects in several projects. Usua...
334,108
<p>I want to check for data, but ignore it if it's null or empty. Currently the query is as follows...</p> <pre><code>Select Coalesce(listing.OfferText, company.OfferText, '') As Offer_Text, from tbl_directorylisting listing Inner Join tbl_companymaster company On listing.compan...
[ { "answer_id": 334115, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 6, "selected": false, "text": "<pre><code>SELECT\n CASE WHEN LEN(listing.OfferText) &gt; 0 THEN listing.OfferText \n ELSE COALESCE(Company.O...
2008/12/02
[ "https://Stackoverflow.com/questions/334108", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5055/" ]
I want to check for data, but ignore it if it's null or empty. Currently the query is as follows... ``` Select Coalesce(listing.OfferText, company.OfferText, '') As Offer_Text, from tbl_directorylisting listing Inner Join tbl_companymaster company On listing.company_id= company....
I think this: ``` SELECT ISNULL(NULLIF(listing.Offer_Text, ''), company.Offer_Text) AS Offer_Text FROM ... ``` is the most elegant solution. And to break it down a bit in pseudo code: ``` // a) NULLIF: if (listing.Offer_Text == '') temp := null; else temp := listing.Offer_Text; // may now be null or non-nu...
334,111
<p>I have a directory outside the webroot that is used for storing images uploaded from a separate admin system. Images are stored in this format:</p> <pre><code>filepath/writable/images/00/00/23/65/filename-236581.jpg </code></pre> <p>(where the webroot is filepath/html)</p> <p>...for example. Here, 236 is the ID o...
[ { "answer_id": 334140, "author": "adam", "author_id": 33604, "author_profile": "https://Stackoverflow.com/users/33604", "pm_score": 1, "selected": false, "text": "<p>That [L] you have after the RewriteRule means \"Last\"</p>\n\n<p>To be honest, I believed this only meant further RewriteR...
2008/12/02
[ "https://Stackoverflow.com/questions/334111", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42456/" ]
I have a directory outside the webroot that is used for storing images uploaded from a separate admin system. Images are stored in this format: ``` filepath/writable/images/00/00/23/65/filename-236581.jpg ``` (where the webroot is filepath/html) ...for example. Here, 236 is the ID of the image in the database, and ...
The [L] means last. What you really need to use as well is the [PT] flag to indicate that the resultant path from your rewrite rule should be passed through to next handler which in your case is the alias directive. As the [PT] tag also implies the [L] tag you no longer require [L] aswell.
334,123
<p>I need a regex for the following pattern:</p> <ul> <li><p>Total of 5 characters (alpha and numeric, nothing else).</p></li> <li><p>first character must be a letter (<code>A</code>, <code>B</code>, or <code>C</code> only)</p></li> <li><p>the remaining 4 characters can be number or letter.</p></li> </ul> <p>Clarifca...
[ { "answer_id": 334134, "author": "Timothy Khouri", "author_id": 11917, "author_profile": "https://Stackoverflow.com/users/11917", "pm_score": 7, "selected": true, "text": "<p>EDIT: Grrr... edited regex due to new \"clarification\" :)</p>\n\n<pre><code>^[A-C][a-zA-Z0-9]{4}$\n</code></pre>...
2008/12/02
[ "https://Stackoverflow.com/questions/334123", "https://Stackoverflow.com", "https://Stackoverflow.com/users/750/" ]
I need a regex for the following pattern: * Total of 5 characters (alpha and numeric, nothing else). * first character must be a letter (`A`, `B`, or `C` only) * the remaining 4 characters can be number or letter. Clarifcation: the first letter can only be `A`, `B`, or `C`. Examples: * `A1234` is valid * `D1234` is...
EDIT: Grrr... edited regex due to new "clarification" :) ``` ^[A-C][a-zA-Z0-9]{4}$ ``` EDIT: To explain the above Regex in English... `^` and `$` mean "From start to finish" (this ensures that the whole string must perfectly match) `[A-C]` means "Match either `A`, `B`, or `C`" `[a-zA-Z0-9]{4}` means "Match 4 lowe...
334,149
<p>What's the quickest/neatest way to calculate the next anniversary of someone's birthday.</p> <p>For example, if I knew a person was born on 31st January, 1990, and today is the 10th February 2000, their next anniversary will be 31st January, 2001.</p> <p>February 29th should roll onto March 1st (e.g. if they were ...
[ { "answer_id": 334168, "author": "biozinc", "author_id": 30698, "author_profile": "https://Stackoverflow.com/users/30698", "pm_score": 3, "selected": true, "text": "<p>I haven't worked in VB.Net, but I think the C# code will make enough sense:</p>\n\n<pre><code>private DateTime nextDate(...
2008/12/02
[ "https://Stackoverflow.com/questions/334149", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15393/" ]
What's the quickest/neatest way to calculate the next anniversary of someone's birthday. For example, if I knew a person was born on 31st January, 1990, and today is the 10th February 2000, their next anniversary will be 31st January, 2001. February 29th should roll onto March 1st (e.g. if they were born on February ...
I haven't worked in VB.Net, but I think the C# code will make enough sense: ``` private DateTime nextDate(DateTime currentDate, DateTime anniversaryDate) { DateTime nextDate; try{ nextDate = new DateTime(currentDate.Year, anniversaryDate.Month, anniversaryDate.Day); } catch (ArgumentOutOfRangeExcep...
334,163
<p>I created a vbscript custom action which checks for some registry keys and alters them if neccessary. In case a key could not be written or something like that, the setup should be aborted.</p> <p>In order to achieve this, I set a property which I tried to use as a condition for the next step within the execute seq...
[ { "answer_id": 334343, "author": "Web", "author_id": 2889, "author_profile": "https://Stackoverflow.com/users/2889", "pm_score": 0, "selected": false, "text": "<p>You should need return 3 from your function for a fail and 0 or 1 for success. </p>\n\n<p>Here is a msdn article on the topi...
2008/12/02
[ "https://Stackoverflow.com/questions/334163", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25428/" ]
I created a vbscript custom action which checks for some registry keys and alters them if neccessary. In case a key could not be written or something like that, the setup should be aborted. In order to achieve this, I set a property which I tried to use as a condition for the next step within the execute sequence but ...
If you search on <http://community.installshield.com> you'll find an article by Robert Dickau entitled "Exiting an MSI Installation from a Custom Action". It's at the following link: <http://community.installshield.com/showthread.php?p=418197> Here's the snippet of code he uses as his example: ``` Function ExitSetup...
334,183
<p>I am implementing a tagging system on my website similar to one stackoverflow uses, my question is - what is the most effective way to store tags so that they may be searched and filtered?</p> <p>My idea is this:</p> <pre><code>Table: Items Columns: Item_ID, Title, Content Table: Tags Columns: Title, Item_ID </co...
[ { "answer_id": 334209, "author": "Rockcoder", "author_id": 5290, "author_profile": "https://Stackoverflow.com/users/5290", "pm_score": 2, "selected": false, "text": "<p>You can't really talk about slowness based on the data you provided in a question. And I don't think you should even wo...
2008/12/02
[ "https://Stackoverflow.com/questions/334183", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29595/" ]
I am implementing a tagging system on my website similar to one stackoverflow uses, my question is - what is the most effective way to store tags so that they may be searched and filtered? My idea is this: ``` Table: Items Columns: Item_ID, Title, Content Table: Tags Columns: Title, Item_ID ``` Is this too slow? I...
One item is going to have many tags. And one tag will belong to many items. This implies to me that you'll quite possibly need an intermediary table to overcome the many-to-many obstacle. Something like: > > Table: Items > > Columns: Item\_ID, Item\_Title, Content > > > > > Table: Tags > > Columns: Tag\_I...
334,201
<p>At every company I have worked at, I have found that people are still writing their SQL queries in the ANSI-89 standard:</p> <pre><code>select a.id, b.id, b.address_1 from person a, address b where a.id = b.id </code></pre> <p>rather than the ANSI-92 standard:</p> <pre><code>select a.id, b.id, b.address_1 from pe...
[ { "answer_id": 334245, "author": "Bill Karwin", "author_id": 20860, "author_profile": "https://Stackoverflow.com/users/20860", "pm_score": 7, "selected": true, "text": "<p>According to \"SQL Performance Tuning\" by Peter Gulutzan and Trudy Pelzer, of the six or eight RDBMS brands they te...
2008/12/02
[ "https://Stackoverflow.com/questions/334201", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41165/" ]
At every company I have worked at, I have found that people are still writing their SQL queries in the ANSI-89 standard: ``` select a.id, b.id, b.address_1 from person a, address b where a.id = b.id ``` rather than the ANSI-92 standard: ``` select a.id, b.id, b.address_1 from person a inner join address b on a.id =...
According to "SQL Performance Tuning" by Peter Gulutzan and Trudy Pelzer, of the six or eight RDBMS brands they tested, there was no difference in optimization or performance of SQL-89 versus SQL-92 style joins. One can assume that most RDBMS engines transform the syntax into an internal representation before optimizin...
334,207
<p>I would like to document the file format of regedit utility, so data can be merged into the registry. </p> <p>From the command-line you can (silently) merge data from a batch file like this:</p> <pre><code>regedit /s file.reg </code></pre> <p>Exporting from a subkey goes like this:</p> <pre><code>regedit /e file...
[ { "answer_id": 334208, "author": "doekman", "author_id": 56, "author_profile": "https://Stackoverflow.com/users/56", "pm_score": 6, "selected": true, "text": "<p>Remove keys and values by using the minus sign (-).</p>\n\n<pre><code>REGEDIT4\n[-HKEY_CURRENT_USER\\RemoveThisTree]\n[HKEY_CU...
2008/12/02
[ "https://Stackoverflow.com/questions/334207", "https://Stackoverflow.com", "https://Stackoverflow.com/users/56/" ]
I would like to document the file format of regedit utility, so data can be merged into the registry. From the command-line you can (silently) merge data from a batch file like this: ``` regedit /s file.reg ``` Exporting from a subkey goes like this: ``` regedit /e file.reg "HKEY_XX\key" ```
Remove keys and values by using the minus sign (-). ``` REGEDIT4 [-HKEY_CURRENT_USER\RemoveThisTree] [HKEY_CURRENT_USER\RemoveValue] "valueName"=- ``` ### References * Minus sign to delete mentioned here: [MSKB310516: *How to add, modify, or delete registry subkeys and values by using a .reg file*](https://support....
334,214
<p>I have been asked to find training resources to bring engineers up to speed on VBA programming.</p> <p>The target trainee will have some systems engineering experience but little to no non-systems programming experience. </p> <p>I'm hoping for a computer-based training course or DVD that we can purchase and give t...
[ { "answer_id": 334208, "author": "doekman", "author_id": 56, "author_profile": "https://Stackoverflow.com/users/56", "pm_score": 6, "selected": true, "text": "<p>Remove keys and values by using the minus sign (-).</p>\n\n<pre><code>REGEDIT4\n[-HKEY_CURRENT_USER\\RemoveThisTree]\n[HKEY_CU...
2008/12/02
[ "https://Stackoverflow.com/questions/334214", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29/" ]
I have been asked to find training resources to bring engineers up to speed on VBA programming. The target trainee will have some systems engineering experience but little to no non-systems programming experience. I'm hoping for a computer-based training course or DVD that we can purchase and give to the engineers f...
Remove keys and values by using the minus sign (-). ``` REGEDIT4 [-HKEY_CURRENT_USER\RemoveThisTree] [HKEY_CURRENT_USER\RemoveValue] "valueName"=- ``` ### References * Minus sign to delete mentioned here: [MSKB310516: *How to add, modify, or delete registry subkeys and values by using a .reg file*](https://support....
334,256
<p>I would like to create a custom XmlDeclaration while using the XmlDocument/XmlDeclaration classes in c# .net 2 or 3. </p> <p>This is my desired output (it is an expected output by a 3rd party app):</p> <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1" ?&gt; &lt;?MyCustomNameHere attribute1="val1" attribute2=...
[ { "answer_id": 334291, "author": "Bradley Grainger", "author_id": 23633, "author_profile": "https://Stackoverflow.com/users/23633", "pm_score": 5, "selected": true, "text": "<p>What you are wanting to create is not an XML declaration, but a \"processing instruction\". You should use the ...
2008/12/02
[ "https://Stackoverflow.com/questions/334256", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9664/" ]
I would like to create a custom XmlDeclaration while using the XmlDocument/XmlDeclaration classes in c# .net 2 or 3. This is my desired output (it is an expected output by a 3rd party app): ``` <?xml version="1.0" encoding="ISO-8859-1" ?> <?MyCustomNameHere attribute1="val1" attribute2="val2" ?> [ ...more xml... ] ...
What you are wanting to create is not an XML declaration, but a "processing instruction". You should use the [XmlProcessingInstruction](http://msdn.microsoft.com/en-us/library/system.xml.xmlprocessinginstruction.aspx) class, not the [XmlDeclaration](http://msdn.microsoft.com/en-us/library/system.xml.xmldeclaration.aspx...
334,259
<p>I'm working on an useragent that logs into teamcity and I'm trying to move the password encryption from js to c#.</p> <p><a href="http://teamcity.jetbrains.com/res/-4045289697674020822.js" rel="nofollow noreferrer">this is the javascript</a> </p> <p>the section called rsa.js and encrypt.js are important. They make...
[ { "answer_id": 334291, "author": "Bradley Grainger", "author_id": 23633, "author_profile": "https://Stackoverflow.com/users/23633", "pm_score": 5, "selected": true, "text": "<p>What you are wanting to create is not an XML declaration, but a \"processing instruction\". You should use the ...
2008/12/02
[ "https://Stackoverflow.com/questions/334259", "https://Stackoverflow.com", "https://Stackoverflow.com/users/253/" ]
I'm working on an useragent that logs into teamcity and I'm trying to move the password encryption from js to c#. [this is the javascript](http://teamcity.jetbrains.com/res/-4045289697674020822.js) the section called rsa.js and encrypt.js are important. They make a function call with ``` rsa.setPublic(publicKey,"1...
What you are wanting to create is not an XML declaration, but a "processing instruction". You should use the [XmlProcessingInstruction](http://msdn.microsoft.com/en-us/library/system.xml.xmlprocessinginstruction.aspx) class, not the [XmlDeclaration](http://msdn.microsoft.com/en-us/library/system.xml.xmldeclaration.aspx...
334,279
<p>Can anyone tell me how can I get the xpath of the name attribute from this file:</p> <pre><code>&lt;asmv1:assembly xmlns:asmv1="urn:schemas-microsoft-com:asm.v1"&gt; &lt;assemblyIdentity name="MyName"/&gt; &lt;/asmv1:assembly&gt; </code></pre> <p>I'm trying to get it for nant xmlpoke task without success.</p> <...
[ { "answer_id": 334310, "author": "joegtp", "author_id": 39431, "author_profile": "https://Stackoverflow.com/users/39431", "pm_score": 1, "selected": false, "text": "<p>Try this XPath</p>\n\n<pre><code>/*[local-name()='assembly']/assemblyIdentity/@name\n</code></pre>\n" }, { "answ...
2008/12/02
[ "https://Stackoverflow.com/questions/334279", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19956/" ]
Can anyone tell me how can I get the xpath of the name attribute from this file: ``` <asmv1:assembly xmlns:asmv1="urn:schemas-microsoft-com:asm.v1"> <assemblyIdentity name="MyName"/> </asmv1:assembly> ``` I'm trying to get it for nant xmlpoke task without success. Thanks.
This should do the trick: ``` //asmv1:assembly/asmv1:assemblyIdentity/@name ```
334,292
<p>What is the preferred/easiest way to manipulate TDesC strings, for example to obtain a substring.</p> <p>I will give you an example of my scenario.</p> <pre><code>RBuf16 buf; ... CEikLabel label; ... label-&gt;SetTextL(buf); // (SetTextL takes a const TDesC&amp;) </code></pre> <p>I want to get a substring from bu...
[ { "answer_id": 334372, "author": "Dynite", "author_id": 16177, "author_profile": "https://Stackoverflow.com/users/16177", "pm_score": 3, "selected": true, "text": "<p>Read descriptors.blogspot.com (scroll down once loaded).</p>\n\n<p>You can use TDes::LeftTPtr, TDes::RightTPtr or TDes::M...
2008/12/02
[ "https://Stackoverflow.com/questions/334292", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33604/" ]
What is the preferred/easiest way to manipulate TDesC strings, for example to obtain a substring. I will give you an example of my scenario. ``` RBuf16 buf; ... CEikLabel label; ... label->SetTextL(buf); // (SetTextL takes a const TDesC&) ``` I want to get a substring from buf. So do I want to manipulate the RBuf16...
Read descriptors.blogspot.com (scroll down once loaded). You can use TDes::LeftTPtr, TDes::RightTPtr or TDes::MidTPtr which will give you a substring as a TPtr (i.e. a descriptor which manipulates the original data). You can use the TDes::Copy function if you want to create a copy of your substring.
334,317
<p>I'm working on an ASP.NET page, using VB.NET and I have this hierarchy:</p> <p>Page A <br /> &nbsp;&nbsp;- Web User Control 1 <br /> &nbsp;&nbsp;&nbsp;&nbsp;- Web User Control A <br /> &nbsp;&nbsp;&nbsp;&nbsp;- Web User Control B <br /> &nbsp;&nbsp;&nbsp;&nbsp;- Web User Control C <br /></p> <p>I need to raise an ...
[ { "answer_id": 334441, "author": "Mitchel Sellers", "author_id": 13279, "author_profile": "https://Stackoverflow.com/users/13279", "pm_score": 1, "selected": false, "text": "<p>The real question here is is the actual action in Web UserControl B something that should notify both, OR, is W...
2008/12/02
[ "https://Stackoverflow.com/questions/334317", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1530166/" ]
I'm working on an ASP.NET page, using VB.NET and I have this hierarchy: Page A   - Web User Control 1     - Web User Control A     - Web User Control B     - Web User Control C I need to raise an event from Web User Control B that Page A will receive (the event flow will be Web User Control B -> We...
You can use the [BubbleEvent](http://msdn.microsoft.com/en-us/library/system.web.ui.control.raisebubbleevent.aspx) [concept](http://msdn.microsoft.com/en-us/library/system.web.ui.control.onbubbleevent.aspx) to do this. A BubbleEvent goes up the control hierarchy until someone handles it. The GridView and Repeater contr...
334,334
<p>I have a need to allow for a user to download an event that has multiple meeting dates. To do this I have created a memorystream to be downloaded which produces a .ics file. For example:</p> <pre> BEGIN:VCALENDAR PRODID:-//Company//Product//EN VERSION:2.0 METHOD:PUBLISH BEGIN:VEVENT SUMMARY:Subject of Event LOCAT...
[ { "answer_id": 335117, "author": "jwmiller5", "author_id": 7824, "author_profile": "https://Stackoverflow.com/users/7824", "pm_score": 3, "selected": true, "text": "<p>I don't think this will work. Outlook is limited in importing those \"open\" specs. I had a similar problem trying to im...
2008/12/02
[ "https://Stackoverflow.com/questions/334334", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19251/" ]
I have a need to allow for a user to download an event that has multiple meeting dates. To do this I have created a memorystream to be downloaded which produces a .ics file. For example: ``` BEGIN:VCALENDAR PRODID:-//Company//Product//EN VERSION:2.0 METHOD:PUBLISH BEGIN:VEVENT SUMMARY:Subject of Event LOCATION:Locati...
I don't think this will work. Outlook is limited in importing those "open" specs. I had a similar problem trying to import a vCard file with multiple contacts. I ended up splitting the file and writing a script in Outlook to import all the files in a directory.
334,341
<p>Component Services -> Computers -> My Computer -> COM+ Applications</p> <p>Open a COM+ Application object.</p> <p>Open Components.</p> <p>Right-click on a class and select Properties.</p> <p>Under "Advanced" there is a check box for "Allow IIS intrinsic properties".</p> <p>How do I check this check box programm...
[ { "answer_id": 334409, "author": "Arnout", "author_id": 3496, "author_profile": "https://Stackoverflow.com/users/3496", "pm_score": 0, "selected": false, "text": "<p>I have no experience with this particular property, but it seems to be documented in <a href=\"http://msdn.microsoft.com/e...
2008/12/02
[ "https://Stackoverflow.com/questions/334341", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4886/" ]
Component Services -> Computers -> My Computer -> COM+ Applications Open a COM+ Application object. Open Components. Right-click on a class and select Properties. Under "Advanced" there is a check box for "Allow IIS intrinsic properties". How do I check this check box programmatically? I can create and delete COM...
I found out how to do it. Apparently I have to get a collection of COM+ applications, find the one I want (by name), then get a collection of components in the application, then go through the collection and set the attribute: ``` //get collection of applications COMAdminCatalog catalog = new COMA...
334,345
<p>I have a table with a view_name field (varchar(256)) and I would like to use that field in an sql query.</p> <p>Example :</p> <p>TABLE university_members</p> <p><strong>id | type | view_name | count</strong></p> <p>1 | professors | view_professors | 0</p> <p>2 | students | view_students2 | 0</p> <p>3 | staff |...
[ { "answer_id": 334364, "author": "Mitchel Sellers", "author_id": 13279, "author_profile": "https://Stackoverflow.com/users/13279", "pm_score": 2, "selected": false, "text": "<p>To do this you would have to do it as a bit of dynamic SQL, something like this might work, obviously you would...
2008/12/02
[ "https://Stackoverflow.com/questions/334345", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5788/" ]
I have a table with a view\_name field (varchar(256)) and I would like to use that field in an sql query. Example : TABLE university\_members **id | type | view\_name | count** 1 | professors | view\_professors | 0 2 | students | view\_students2 | 0 3 | staff | view\_staff4 | 0 And I would like to update all row...
To do this you would have to do it as a bit of dynamic SQL, something like this might work, obviously you would need to edit to actually match what you are trying to do. ``` DECLARE @ViewName VARCHAR(500) SELECT @ViewName = view_name FROM University_Members WHERE Id = 1 DECLARE @SQL VARCHAR(MAX) SET @SQL = ' UPDATE...
334,354
<p>With the XML below, I would like to know how to get the value of text in the case_id node as an attribute for the hidden input tag in the xsl sheet below. Is this possible?</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;?xml-stylesheet type="text/xsl" href="data.xsl"?&gt; &lt;NewDataSet&gt; &lt;Cas...
[ { "answer_id": 334395, "author": "Jeff Yates", "author_id": 23234, "author_profile": "https://Stackoverflow.com/users/23234", "pm_score": 2, "selected": false, "text": "<p>You need to expand your XSLT with some more specific matches.</p>\n\n<p>The following should output <code>input</cod...
2008/12/02
[ "https://Stackoverflow.com/questions/334354", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
With the XML below, I would like to know how to get the value of text in the case\_id node as an attribute for the hidden input tag in the xsl sheet below. Is this possible? ``` <?xml version="1.0" encoding="utf-8"?> <?xml-stylesheet type="text/xsl" href="data.xsl"?> <NewDataSet> <Cases> <Case> <case_id>30</case_id> ....
Just change your XSLT to this, this assumes that you do only have 1 case\_id, otherwise, you will need to go with a more specific template match, and remove some of the path in the XPATH value I used as an example. ``` <input type="hidden" name="case-num"> <xsl:attribute name="value"> <xsl:value-of select=...
334,360
<p>Whilst debugging my program in VS 2008 I have come across the following error:</p> <p>The CLR has been unable to transition from COM context 0x34fc1a0 to COM context 0x34fc258 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very l...
[ { "answer_id": 334605, "author": "Jorge Villuendas Zapatero", "author_id": 27097, "author_profile": "https://Stackoverflow.com/users/27097", "pm_score": 1, "selected": false, "text": "<p>It seems that you are adding a new event handler each time you call InitialiseTimer. That way m_Timer...
2008/12/02
[ "https://Stackoverflow.com/questions/334360", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Whilst debugging my program in VS 2008 I have come across the following error: The CLR has been unable to transition from COM context 0x34fc1a0 to COM context 0x34fc258 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long runnin...
You can turn this off if you think you've definitely *not* got a deadlock situation: Debug->Exceptions->Managed Debug Assistants menu in Visual Studio and uncheck the ContextSwitchDeadlock
334,367
<p>Playing with log4net, I have seen the possibility to use a per-thread stack of context labels called the NDC. </p> <p>The labels pushed on this stack are displayed in a PatternLayout by specifying the <code>%x</code> or the <code>%ndc</code> format parameter.</p> <p>The usage is something like: </p> <pre><code>IL...
[ { "answer_id": 334463, "author": "Eugene Yokota", "author_id": 3827, "author_profile": "https://Stackoverflow.com/users/3827", "pm_score": 4, "selected": false, "text": "<p>These feature come in handy when you have lots of logs to go through. When would you have lots of logs? Diagnosing ...
2008/12/02
[ "https://Stackoverflow.com/questions/334367", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11545/" ]
Playing with log4net, I have seen the possibility to use a per-thread stack of context labels called the NDC. The labels pushed on this stack are displayed in a PatternLayout by specifying the `%x` or the `%ndc` format parameter. The usage is something like: ``` ILog log = log4net.LogManager.GetLogger(...) ; //pa...
In a server application such as ASP.NET. For example, you can push information about the current request on to the NDC.
334,370
<p>I've seen (and used) code to have a link spawn a javascript action many times in my life, but I've never come to a firm conclusion on if the href attribute should be blank or #. Do you have any preference one way or the other, and if so, why?</p> <pre><code>&lt;a href="" onclick="javascript: DoSomething();"&gt;lin...
[ { "answer_id": 334394, "author": "sblundy", "author_id": 4893, "author_profile": "https://Stackoverflow.com/users/4893", "pm_score": 3, "selected": false, "text": "<p>Checkout the discussion over at <a href=\"https://stackoverflow.com/questions/134845/href-for-javascript-links-or-javascr...
2008/12/02
[ "https://Stackoverflow.com/questions/334370", "https://Stackoverflow.com", "https://Stackoverflow.com/users/232/" ]
I've seen (and used) code to have a link spawn a javascript action many times in my life, but I've never come to a firm conclusion on if the href attribute should be blank or #. Do you have any preference one way or the other, and if so, why? ``` <a href="" onclick="javascript: DoSomething();">linky</a> ``` or ``` ...
You **must** have *something* for the `href` attribute, otherwise the browser will not treat it as a link (for example, making it focusable or giving it an underline) - that's why the use of "#" has become prevalent. Also, the contents of the event attributes (`onclick`, `onmouseover`, `on...`) are already treated as ...
334,371
<p>What would the purpose of this construct in a c file be?: </p> <pre><code>#define _TIMERC #include "timer.h" #undef _TIMERC </code></pre> <p>I am aware of the guard for preventing multiple inclusion of a header file. This doesn't appear to be whats happening though.</p> <p>thanks!</p>
[ { "answer_id": 334380, "author": "JeffV", "author_id": 445087, "author_profile": "https://Stackoverflow.com/users/445087", "pm_score": 2, "selected": false, "text": "<p>I was wondering if it could be this:</p>\n\n<p>The header file in this case is intended to allow multiple inclusions w...
2008/12/02
[ "https://Stackoverflow.com/questions/334371", "https://Stackoverflow.com", "https://Stackoverflow.com/users/445087/" ]
What would the purpose of this construct in a c file be?: ``` #define _TIMERC #include "timer.h" #undef _TIMERC ``` I am aware of the guard for preventing multiple inclusion of a header file. This doesn't appear to be whats happening though. thanks!
Often times a library header file will have multiple options, that are enabled and disabled by macro defines. This will enable such an option. More typically these are set at a global scope by configuring your build system to add (for eg with gcc) **-D\_TIMERC** to the compilers command line.
334,373
<p>When debugging I need to start an external program from the target directory of a build and am wondering if it can be accomplished using relative paths.</p> <p>As a post-build event I have the following:</p> <pre> IF NOT "$(ConfigurationName)"=="Debug" GOTO End :CopyExecutable copy "$(SolutionDir)\Source\Lib\MyExe...
[ { "answer_id": 397017, "author": "alexandroid", "author_id": 49678, "author_profile": "https://Stackoverflow.com/users/49678", "pm_score": -1, "selected": false, "text": "<p>Did you try something like $(TargetDir)\\..\\Lib ?</p>\n" }, { "answer_id": 404927, "author": "Alex Ly...
2008/12/02
[ "https://Stackoverflow.com/questions/334373", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32313/" ]
When debugging I need to start an external program from the target directory of a build and am wondering if it can be accomplished using relative paths. As a post-build event I have the following: ``` IF NOT "$(ConfigurationName)"=="Debug" GOTO End :CopyExecutable copy "$(SolutionDir)\Source\Lib\MyExecutable.exe" "$...
The 'Start External Program' path is relative to your solution directory (in VS2005 anyway). So you could just put: ``` Source\Lib\MyExecutable.exe ``` I see you asked this a while ago, but I just ran into the same problem, and this is how I solved it.
334,382
<p>I asked <a href="https://stackoverflow.com/questions/288409/how-do-i-get-the-html-output-of-a-usercontrol-in-net-c">how to render a UserControl's HTML</a> and got the code working for a dynamically generated UserControl.</p> <p>Now I'm trying to use LoadControl to load a previously generated Control and spit out it...
[ { "answer_id": 334405, "author": "Bob", "author_id": 45, "author_profile": "https://Stackoverflow.com/users/45", "pm_score": 0, "selected": false, "text": "<p>You can either add a form to your user control, or use a regular html input box</p>\n\n<pre><code> &lt;input type=\"text\" /&gt;\...
2008/12/02
[ "https://Stackoverflow.com/questions/334382", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25538/" ]
I asked [how to render a UserControl's HTML](https://stackoverflow.com/questions/288409/how-do-i-get-the-html-output-of-a-usercontrol-in-net-c) and got the code working for a dynamically generated UserControl. Now I'm trying to use LoadControl to load a previously generated Control and spit out its HTML, but it's givi...
Alternatively you could disable the ServerForm/Event-validation on the page that is rendering the control to a string. The following example illustrates how to do this. ``` public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { string rawHtml = Rend...
334,404
<p>When I run <code>get-user|get-member</code> in powershell with the exchange add-in I noticed there is no description property.</p> <p>Does anyone know if it has been renamed to something else or another way of accessing it? </p>
[ { "answer_id": 334468, "author": "x0n", "author_id": 6920, "author_profile": "https://Stackoverflow.com/users/6920", "pm_score": 0, "selected": false, "text": "<p>get-user? do you mean get-qaduser from the quest cmdlet suite?</p>\n\n<p>if so, I believe not all properties are retrieved by...
2008/12/02
[ "https://Stackoverflow.com/questions/334404", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18853/" ]
When I run `get-user|get-member` in powershell with the exchange add-in I noticed there is no description property. Does anyone know if it has been renamed to something else or another way of accessing it?
If you aren't looking to change the description this should work: ``` [PS] C:\>$ANR = "testuser@example.com" [PS] C:\>$foo = [adsi]("LDAP://" + (get-user $ANR).DistinguishedName) [PS] C:\>$foo.description My Description ``` If you are wanting to edit, you will need to get further into System.DirectoryServices & look...
334,431
<p>I've recently started upgrading some applications to use Spring Webflow 2, and I want to make use of the new Ajax functionality that comes with Webflow 2. Can somebody please direct me to a tutorial for integrating Tiles 2 with Spring Webflow (since that's apparently what they recommend). I've found the documentat...
[ { "answer_id": 838242, "author": "TM.", "author_id": 12983, "author_profile": "https://Stackoverflow.com/users/12983", "pm_score": 2, "selected": false, "text": "<p>This isn't exactly referring to the ajax features, but it helped me get apache tiles 2 set up for regular flows:</p>\n\n<p>...
2008/12/02
[ "https://Stackoverflow.com/questions/334431", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32232/" ]
I've recently started upgrading some applications to use Spring Webflow 2, and I want to make use of the new Ajax functionality that comes with Webflow 2. Can somebody please direct me to a tutorial for integrating Tiles 2 with Spring Webflow (since that's apparently what they recommend). I've found the documentation t...
This is what I did to get it working with webflow 2 and tiles 2.0 ``` <bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer"> <property name="definitions"> <list> <value>/WEB-INF/tiles-defs/templates.xml</value> </list> </property> </bean>...
334,439
<p>We have recently been faced with the problem of porting our C++ framework to an ARM platform running uClinux where the only vendor supported compiler is GCC 2.95.3. The problem we have run into is that exceptions are extremely unreliable causing everything from not being caught at all to being caught by an unrelated...
[ { "answer_id": 334461, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 0, "selected": false, "text": "<p>Regarding the Google reference (you couldn't find how they handled errors in the constructor):</p>\n\n<p>The answer...
2008/12/02
[ "https://Stackoverflow.com/questions/334439", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22247/" ]
We have recently been faced with the problem of porting our C++ framework to an ARM platform running uClinux where the only vendor supported compiler is GCC 2.95.3. The problem we have run into is that exceptions are extremely unreliable causing everything from not being caught at all to being caught by an unrelated th...
Generally you end up with code like this for objects on the stack: ``` MyClassWithNoThrowConstructor foo; if (foo.init(bar, baz, etc) != 0) { // error-handling code } else { // phew, we got away with it. Now for the next object... } ``` And this for objects on the heap. I assume you override global operator ...
334,471
<p>Here is the situation:</p> <p>I have been called upon to work with InstallAnywhere 8, a Java-based installer IDE, of sorts, that allows starting and stopping of windows services, but has no built-in method to query their states. Fortunately, it allows you to create custom actions in Java which can be called at any...
[ { "answer_id": 334564, "author": "Aaron Digulla", "author_id": 34088, "author_profile": "https://Stackoverflow.com/users/34088", "pm_score": 0, "selected": false, "text": "<p>During startup, create a file with <a href=\"http://java.sun.com/j2se/1.5.0/docs/api/java/io/File.html#deleteOnEx...
2008/12/02
[ "https://Stackoverflow.com/questions/334471", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42489/" ]
Here is the situation: I have been called upon to work with InstallAnywhere 8, a Java-based installer IDE, of sorts, that allows starting and stopping of windows services, but has no built-in method to query their states. Fortunately, it allows you to create custom actions in Java which can be called at any time durin...
here's what I had to do. It's ugly, but it works beautifully. ``` String STATE_PREFIX = "STATE : "; String s = runProcess("sc query \""+serviceName+"\""); // check that the temp string contains the status prefix int ix = s.indexOf(STATE_PREFIX); if (ix >= 0) { // compare status number to one of the sta...
334,472
<p>Running a ServiceHost with a single contract is working fine like this:</p> <pre><code>servicehost = new ServiceHost(typeof(MyService1)); servicehost.AddServiceEndpoint(typeof(IMyService1), new NetTcpBinding(), "net.tcp://127.0.0.1:800/MyApp/MyService1"); servicehost.Open(); </code></pre> <p>Now I'd like to add a ...
[ { "answer_id": 334554, "author": "chilltemp", "author_id": 28736, "author_profile": "https://Stackoverflow.com/users/28736", "pm_score": 7, "selected": true, "text": "<p>You need to implement both services (interfaces) in the same class.</p>\n\n<pre><code>servicehost = new ServiceHost(ty...
2008/12/02
[ "https://Stackoverflow.com/questions/334472", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7021/" ]
Running a ServiceHost with a single contract is working fine like this: ``` servicehost = new ServiceHost(typeof(MyService1)); servicehost.AddServiceEndpoint(typeof(IMyService1), new NetTcpBinding(), "net.tcp://127.0.0.1:800/MyApp/MyService1"); servicehost.Open(); ``` Now I'd like to add a second (3rd, 4th, ...) con...
You need to implement both services (interfaces) in the same class. ``` servicehost = new ServiceHost(typeof(WcfEntryPoint)); servicehost.Open(); public class WcfEntryPoint : IMyService1, IMyService2 { #region IMyService1 #endregion #region IMyService2 #endregion } ``` --- FYI: I frequently use p...
334,489
<p>Let’s say I have this markup:</p> <pre><code>&lt;div id="content"&gt; &lt;div id="firstP"&gt;&lt;p&gt;First paragraph&lt;/p&gt;&lt;/div&gt; &lt;div id="secondP"&gt;&lt;p&gt;Second paragraph&lt;/p&gt;&lt;/div&gt; &lt;div id="thirdP"&gt;&lt;p&gt;Third paragraph&lt;/p&gt;&lt;/div&gt; &lt;div id="fourthP"&gt;&l...
[ { "answer_id": 334494, "author": "nickf", "author_id": 9021, "author_profile": "https://Stackoverflow.com/users/9021", "pm_score": 4, "selected": false, "text": "<p>There's no problem with your code, it's just that <strong>a paragraph or div tag can't receive focus</strong>. Focus can on...
2008/12/02
[ "https://Stackoverflow.com/questions/334489", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2138/" ]
Let’s say I have this markup: ``` <div id="content"> <div id="firstP"><p>First paragraph</p></div> <div id="secondP"><p>Second paragraph</p></div> <div id="thirdP"><p>Third paragraph</p></div> <div id="fourthP"><p>Fourth paragraph</p></div> </div> ``` I want to add a new `<div>` with jQuery and focus on this...
I think the main answer is incorrect. DIV and P tags can receive focus providing you specify a tabindex property for them. i.e. ``` <div class="someclass" tabindex="100"> ``` Once the tabindex is specified you can either tab to these elements or shift focus with *.focus()* . Using a scrollTo plugin seems like a bi...
334,496
<p>I have a couple of nagging compiler warnings for an app that I ported from VB6 a while back regarding CLS-Compliance including:</p> <pre><code>Name '_AnIdentifier' is not CLS-Compliant. Type of parameter 'myType' is not CLS-Compliant. </code></pre> <p>Despite this, my app seems to perform just fine from COM and Ma...
[ { "answer_id": 334536, "author": "James Curran", "author_id": 12725, "author_profile": "https://Stackoverflow.com/users/12725", "pm_score": 4, "selected": true, "text": "<p>Basically, your class may not be accessible (or may act oddly, such as large positive numbers being treated as nega...
2008/12/02
[ "https://Stackoverflow.com/questions/334496", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30018/" ]
I have a couple of nagging compiler warnings for an app that I ported from VB6 a while back regarding CLS-Compliance including: ``` Name '_AnIdentifier' is not CLS-Compliant. Type of parameter 'myType' is not CLS-Compliant. ``` Despite this, my app seems to perform just fine from COM and Managed clients. I have seen...
Basically, your class may not be accessible (or may act oddly, such as large positive numbers being treated as negative), when used with some .NET languages. I cannot say what languages they might be. For example, I don't believe a language is required to recognize an identifer that begins with an underscore. C# allow...
334,515
<p>This question regards unit testing in Visual Studio using MSTest (this is important, because of MSTest's <a href="http://blogs.msdn.com/nnaderi/archive/2007/02/17/explaining-execution-order.aspx" rel="noreferrer">execution order</a>). Both the method marked [TestInitialize] and the test class constructor will run be...
[ { "answer_id": 334528, "author": "Patrick Desjardins", "author_id": 13913, "author_profile": "https://Stackoverflow.com/users/13913", "pm_score": 2, "selected": false, "text": "<p>The object you test doesn't need to be instantiated in the [TestInitialize] method. You can test the constru...
2008/12/02
[ "https://Stackoverflow.com/questions/334515", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3619/" ]
This question regards unit testing in Visual Studio using MSTest (this is important, because of MSTest's [execution order](http://blogs.msdn.com/nnaderi/archive/2007/02/17/explaining-execution-order.aspx)). Both the method marked [TestInitialize] and the test class constructor will run before each test method. So, the...
The constructor is just a structure provided by the language. Every test framework seems has its own controlled lifecycle "initialize". You'll probably only get into trouble using the constructor to mutate your locals. **MSTest:** You get an entire new instance of the test class for every `TestMethod`. This might be t...
334,518
<p>I'm a C++ guy learning Java. I'm reading Effective Java and something confused me. It says never to write code like this:</p> <pre><code>String s = new String("silly"); </code></pre> <p>Because it creates unnecessary <code>String</code> objects. But instead it should be written like this:</p> <pre><code>String s ...
[ { "answer_id": 334538, "author": "Alnitak", "author_id": 6782, "author_profile": "https://Stackoverflow.com/users/6782", "pm_score": 4, "selected": false, "text": "<p><code>String</code>s are special in Java - they're immutable, and string constants are automatically turned into <code>St...
2008/12/02
[ "https://Stackoverflow.com/questions/334518", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42496/" ]
I'm a C++ guy learning Java. I'm reading Effective Java and something confused me. It says never to write code like this: ``` String s = new String("silly"); ``` Because it creates unnecessary `String` objects. But instead it should be written like this: ``` String s = "No longer silly"; ``` Ok fine so far...Howe...
`String` is a special built-in class of the language. It is for the `String` class **only** in which you should avoid saying ``` String s = new String("Polish"); ``` Because the literal `"Polish"` is already of type `String`, and you're creating an extra unnecessary object. For any other class, saying ``` CaseInsen...
334,519
<p>I've been attempting to hook a Rails application up to ActiveDirectory. I'll be synchronizing data about users between AD and a database, currently MySQL (but may turn into SQL Server or PostgreSQL).</p> <p>I've checked out activedirectory-ruby, and it looks really buggy (for a 1.0 release!?). It wraps Net::LDAP, s...
[ { "answer_id": 335495, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "<p>Have you checked out thoughtbot's ldap-activerecord-gateway? It might be something for you to consider...</p>\n\n<p><a href...
2008/12/02
[ "https://Stackoverflow.com/questions/334519", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42486/" ]
I've been attempting to hook a Rails application up to ActiveDirectory. I'll be synchronizing data about users between AD and a database, currently MySQL (but may turn into SQL Server or PostgreSQL). I've checked out activedirectory-ruby, and it looks really buggy (for a 1.0 release!?). It wraps Net::LDAP, so I tried ...
Here is sample code I use with the [net-ldap](http://net-ldap.rubyforge.org/) gem to verify user logins from the ActiveDirectory server at my work: ``` require 'net/ldap' # gem install net-ldap def name_for_login( email, password ) email = email[/\A\w+/].downcase # Throw out the domain, if it was there email << ...