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
296,003
<p>Does any one know the best way to deploy a resource file to the App_GlobalResource folder of the web application when a feature is activated?</p>
[ { "answer_id": 296488, "author": "Lars Fastrup", "author_id": 27393, "author_profile": "https://Stackoverflow.com/users/27393", "pm_score": 2, "selected": false, "text": "<p>Application resource files cannot be deployed via a feature unless you execute some code and start a SharePoint ti...
2008/11/17
[ "https://Stackoverflow.com/questions/296003", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13135/" ]
Does any one know the best way to deploy a resource file to the App\_GlobalResource folder of the web application when a feature is activated?
So, as a final followup to this question here is what we finally did to completely automate this process. We did, as was suggested, use the ApplicationResourceFile element in the manifest file. ``` <?xml version="1.0" encoding="utf-8"?> <Solution SolutionId="{185E973C-3A10-4e2a-9E0F-DC14414551F9}" xmlns="ht...
296,015
<p>Please consider the following example. Note that in the real-word, the binding source will likely be a data object. I'm using a <code>TextBlock</code> for simplicity.</p> <pre><code>&lt;Window x:Class="Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microso...
[ { "answer_id": 296092, "author": "Sam Meldrum", "author_id": 16005, "author_profile": "https://Stackoverflow.com/users/16005", "pm_score": 2, "selected": false, "text": "<p>You can do this manually just before the save using:</p>\n\n<pre><code>txt_Name.GetBindingExpression(TextBox.TextPr...
2008/11/17
[ "https://Stackoverflow.com/questions/296015", "https://Stackoverflow.com", "https://Stackoverflow.com/users/132931/" ]
Please consider the following example. Note that in the real-word, the binding source will likely be a data object. I'm using a `TextBlock` for simplicity. ``` <Window x:Class="Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" ...
You can do this manually just before the save using: ``` txt_Name.GetBindingExpression(TextBox.TextProperty).UpdateTarget(); ``` A bit ugly, but it works.
296,017
<p>My simplified and contrived example is the following:-</p> <p>Lets say that I want to measure and store the temperature (and other values) of all the worlds' towns on a daily basis. I am looking for an optimal way of storing the data so that it is just as easy to get the current temperature in all the towns, as it ...
[ { "answer_id": 296033, "author": "Gordon Bell", "author_id": 16473, "author_profile": "https://Stackoverflow.com/users/16473", "pm_score": 1, "selected": false, "text": "<p>I suggest keep in the same table since historical data is queried just as often. Unless you will be adding many mo...
2008/11/17
[ "https://Stackoverflow.com/questions/296017", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1982/" ]
My simplified and contrived example is the following:- Lets say that I want to measure and store the temperature (and other values) of all the worlds' towns on a daily basis. I am looking for an optimal way of storing the data so that it is just as easy to get the current temperature in all the towns, as it is to get ...
it DEPENDS on the applications usage patterns... If usage patterns indicate that the historical data will be queried more often than the current values, then put them all in one table... But if Historical queries are the exception, (or less than 10% of the queries), and the performance of the more common current value ...
296,020
<p>How can I create a table that has its first row and first column both locked, as in Excel, when you activate 'freeze panes'? I need the table to both scroll horizontally and vertically (a lot of solutions for this exist, but only allow vertical scrolling).</p> <p>So, when you scroll down in the table, the first ro...
[ { "answer_id": 296030, "author": "matt b", "author_id": 4249, "author_profile": "https://Stackoverflow.com/users/4249", "pm_score": 0, "selected": false, "text": "<p>How about a solution where you put the actual \"data\" of the table inside its own div, with <code>overflow: scroll;</code...
2008/11/17
[ "https://Stackoverflow.com/questions/296020", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4257/" ]
How can I create a table that has its first row and first column both locked, as in Excel, when you activate 'freeze panes'? I need the table to both scroll horizontally and vertically (a lot of solutions for this exist, but only allow vertical scrolling). So, when you scroll down in the table, the first row will stay...
Oh well, I looked up for scrollable table with fixed column to understand the need of this specific requirement and your question was one of it with no close answers.. I answered this question [Large dynamically sized html table with a fixed scroll row and fixed scroll column](https://stackoverflow.com/questions/1083...
296,036
<p>If a large module is loaded by some submodule of your code, is there any benefit to referencing the module from that namespace instead of importing it again?</p> <p>For example: I have a module MyLib, which makes extensive use of ReallyBigLib. If I have code that imports MyLib, should I dig the module out like so</...
[ { "answer_id": 296046, "author": "Marko", "author_id": 31141, "author_profile": "https://Stackoverflow.com/users/31141", "pm_score": 2, "selected": false, "text": "<p>It is the same performancewise. There is no JIT compiler in Python yet.</p>\n" }, { "answer_id": 296062, "aut...
2008/11/17
[ "https://Stackoverflow.com/questions/296036", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32880/" ]
If a large module is loaded by some submodule of your code, is there any benefit to referencing the module from that namespace instead of importing it again? For example: I have a module MyLib, which makes extensive use of ReallyBigLib. If I have code that imports MyLib, should I dig the module out like so ``` import...
Python modules could be considered as singletons... no matter how many times you import them they get initialized only once, so it's better to do: ``` import MyLib import ReallyBigLib ``` Relevant documentation on the import statement: <https://docs.python.org/2/reference/simple_stmts.html#the-import-statement> > ...
296,055
<p>Let's say I want to create the alias %xed for %edit -x. How would I do it?</p>
[ { "answer_id": 296334, "author": "Igal Serban", "author_id": 25737, "author_profile": "https://Stackoverflow.com/users/25737", "pm_score": 3, "selected": true, "text": "<p><strong>Update:</strong> The first response( below) does not accept parameters. So put this snippet at the end of th...
2008/11/17
[ "https://Stackoverflow.com/questions/296055", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1512/" ]
Let's say I want to create the alias %xed for %edit -x. How would I do it?
**Update:** The first response( below) does not accept parameters. So put this snippet at the end of the ipy\_user\_conf.py file ( it is in your home directory ). ``` def ed_xed(self,arg): ip = self.api return ip.magic.im_class.magic_edit(ip.IP," -x %s "%arg) ip.expose_magic('xed',ed_xed) ``` **Before updat...
296,090
<p>I am using C# and DSL Tools for VS2005. </p> <p>I need to create Transactions to change some data but i want them to be hidden from the user, that means, to not show in the UNDO list in VS2005.</p> <p>I tried by disabling the UndoManager</p> <pre><code>store.UndoManager.UndoState = UndoState.Disabled; </code></pr...
[ { "answer_id": 315750, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>I'm afraid I don't have an exact answer for your question but... are you sure you really need that? Most of the times when ...
2008/11/17
[ "https://Stackoverflow.com/questions/296090", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20335/" ]
I am using C# and DSL Tools for VS2005. I need to create Transactions to change some data but i want them to be hidden from the user, that means, to not show in the UNDO list in VS2005. I tried by disabling the UndoManager ``` store.UndoManager.UndoState = UndoState.Disabled; ``` But by disabling it all existing ...
`store.UndoManager.UndoState = UndoState.Disabled`; is almost right for what u want, `store.UndoManager.UndoState = UndoState.DisabledNoFlush;` this will not clear the rest of the undo list :) cyas at lunch Luis.
296,096
<p>I'm writing code in Java, using the NetBeans IDE. I keep getting a couple of "Incompatible Type" errors. I declare a variable as String and then assign to it the value from a method that returns a String too. The error says that there was expected a type of "String" but instead found "..." where "..." the name of th...
[ { "answer_id": 296106, "author": "toolkit", "author_id": 3295, "author_profile": "https://Stackoverflow.com/users/3295", "pm_score": 0, "selected": false, "text": "<p>Perhaps you could post a more complete code snippet? </p>\n\n<p>It looks like your method argument <code>string</code> is...
2008/11/17
[ "https://Stackoverflow.com/questions/296096", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm writing code in Java, using the NetBeans IDE. I keep getting a couple of "Incompatible Type" errors. I declare a variable as String and then assign to it the value from a method that returns a String too. The error says that there was expected a type of "String" but instead found "..." where "..." the name of the m...
Make sure that the other method is returning also a "java.lang.String", not a user defined object "string".
296,097
<p>we're dealing with a very slow update statement in an Oracle project.</p> <p>Here's a little script to replciate the issue:</p> <pre><code>drop table j_test; CREATE TABLE J_TEST ( ID NUMBER(10) PRIMARY KEY, C1 VARCHAR2(50 BYTE), C2 VARCHAR2(250 BYTE), C3 NUMBER(5), C4 NUMBER(10) ); -- just ins...
[ { "answer_id": 296123, "author": "Gordon Bell", "author_id": 16473, "author_profile": "https://Stackoverflow.com/users/16473", "pm_score": 2, "selected": false, "text": "<p>Try this:</p>\n\n<pre><code>insert into j_test (id, C3, C4)\nselect rownum, 1, 'NEU'\nfrom &lt;dummy_table&gt;\nwhe...
2008/11/17
[ "https://Stackoverflow.com/questions/296097", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25320/" ]
we're dealing with a very slow update statement in an Oracle project. Here's a little script to replciate the issue: ``` drop table j_test; CREATE TABLE J_TEST ( ID NUMBER(10) PRIMARY KEY, C1 VARCHAR2(50 BYTE), C2 VARCHAR2(250 BYTE), C3 NUMBER(5), C4 NUMBER(10) ); -- just insert a bunch of rows i...
One possible cause of poor performance is row chaining. All your rows initially have columns C3 and C4 null, and then you update them all to have a value. The new data won't fit into the existing blocks, so Oracle has to chain the rows to new blocks. If you know in advance that you will be doing this you can pre-alloc...
296,116
<p>I am implementing web services for a PHP application and am trying to understand what both standard web services and RESTful web services have to offer. My intent is to write wrapper code to abstract away the web service details so that developers can just "instantiate remote objects" and use them. Here are my thou...
[ { "answer_id": 296170, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 4, "selected": true, "text": "<p>They are different models... REST is <strong>data-centric</strong>, where-as SOAP is <strong>operation-centric</str...
2008/11/17
[ "https://Stackoverflow.com/questions/296116", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4639/" ]
I am implementing web services for a PHP application and am trying to understand what both standard web services and RESTful web services have to offer. My intent is to write wrapper code to abstract away the web service details so that developers can just "instantiate remote objects" and use them. Here are my thought...
They are different models... REST is **data-centric**, where-as SOAP is **operation-centric**. i.e. with SOAP you tend to have discrete operations "SubmitOrder", etc; but with REST you are typically a lot more fluid about how you are querying the data. SOAP also tends to be associated with a lot more complexity (which...
296,146
<p>I am sure making a silly mistake but I can't figure what:</p> <p>In SQL Server 2005 I am trying select all customers except those who have made a reservation before 2 AM.</p> <p>When I run this query:</p> <pre><code>SELECT idCustomer FROM reservations WHERE idCustomer NOT IN (SELECT distinct idCustomer FROM r...
[ { "answer_id": 296158, "author": "Amy B", "author_id": 8155, "author_profile": "https://Stackoverflow.com/users/8155", "pm_score": 7, "selected": true, "text": "<pre><code>SELECT distinct idCustomer FROM reservations\nWHERE DATEPART ( hour, insertDate) &lt; 2\n and idCustomer is not nul...
2008/11/17
[ "https://Stackoverflow.com/questions/296146", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4264/" ]
I am sure making a silly mistake but I can't figure what: In SQL Server 2005 I am trying select all customers except those who have made a reservation before 2 AM. When I run this query: ``` SELECT idCustomer FROM reservations WHERE idCustomer NOT IN (SELECT distinct idCustomer FROM reservations WHERE DATEPA...
``` SELECT distinct idCustomer FROM reservations WHERE DATEPART ( hour, insertDate) < 2 and idCustomer is not null ``` Make sure your list parameter does not contain null values. Here's an explanation: ``` WHERE field1 NOT IN (1, 2, 3, null) ``` is the same as: ``` WHERE NOT (field1 = 1 OR field1 = 2 OR field1...
296,147
<p>I have a web service class that the rest of the framework depends on to grab its data, but the web service class needs to have different method attributes depending on what environment it's in. For instance...</p> <pre><code>[SoapDocumentMethodAttribute("https://example",...)] public string Test() { //doSomethi...
[ { "answer_id": 296185, "author": "Cristian Libardo", "author_id": 16526, "author_profile": "https://Stackoverflow.com/users/16526", "pm_score": 3, "selected": true, "text": "<p>Could you use conditional comments?</p>\n\n<pre><code>#if TESTING\n [SoapDocumentMethodAttribute(somethi...
2008/11/17
[ "https://Stackoverflow.com/questions/296147", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1212/" ]
I have a web service class that the rest of the framework depends on to grab its data, but the web service class needs to have different method attributes depending on what environment it's in. For instance... ``` [SoapDocumentMethodAttribute("https://example",...)] public string Test() { //doSomething } ``` See...
Could you use conditional comments? ``` #if TESTING [SoapDocumentMethodAttribute(something)] #else [SoapDocumentMethodAttribute(someotherthing)] #endif ``` For your test configuration you would define the constant: ``` <DefineConstants>TESTING</DefineConstants> ```
296,148
<p>I have the following div layout:</p> <img src="https://i.stack.imgur.com/bZSnA.jpg"> <p>Everything is fine when I put normal txt elements in both the blue and the orange div. However, when I place an image in the orange div (which is 31px), the elements in the blue div get pushed down by about half the height of...
[ { "answer_id": 296166, "author": "Pim Jager", "author_id": 35197, "author_profile": "https://Stackoverflow.com/users/35197", "pm_score": 0, "selected": false, "text": "<p>I'm not so good with CSS boxes, but could adding: display:inline; to the image style fix the porblem? And/Or adding m...
2008/11/17
[ "https://Stackoverflow.com/questions/296148", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28871/" ]
I have the following div layout: ![](https://i.stack.imgur.com/bZSnA.jpg) Everything is fine when I put normal txt elements in both the blue and the orange div. However, when I place an image in the orange div (which is 31px), the elements in the blue div get pushed down by about half the height of the blue div. (add...
You might want to try floating the image to the left of the text. This way the text will sit next to the image without the need for positioning. For example: ``` <style> div { position: absolute; border: 1px solid blue; } div img { height: 31px; width: 50px; float: left; } </style> <div> <img src="myImage.gif"> ...
296,150
<p>Many times I saw logging of errors like these:</p> <pre><code>System.out.println("Method aMethod with parameters a:"+a+" b: "+b); print("Error in line 88"); </code></pre> <p>so.. What are the best practices to log an error?</p> <p><strong>EDIT:</strong></p> <p>This is java but could be C/C++, basic, etc.</p>
[ { "answer_id": 296165, "author": "MunkiPhD", "author_id": 30816, "author_profile": "https://Stackoverflow.com/users/30816", "pm_score": -1, "selected": false, "text": "<p>There really is no best practice for logging an error. It basically just needs to follow a consistent pattern (withi...
2008/11/17
[ "https://Stackoverflow.com/questions/296150", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24639/" ]
Many times I saw logging of errors like these: ``` System.out.println("Method aMethod with parameters a:"+a+" b: "+b); print("Error in line 88"); ``` so.. What are the best practices to log an error? **EDIT:** This is java but could be C/C++, basic, etc.
Apache Commons Logging is not intended for *applications* general logging. It's intended to be used by libraries or APIs that don't want to force a logging implementation on the API's user. There are also classloading issues with Commons Logging. Pick one of the [many] logging api's, the most widely used probably bei...
296,173
<p>I'd like to copy the files that have a specific file extension to a new folder. I have an idea how to use <code>os.walk</code> but specifically how would I go about using that? I'm searching for the files with a specific file extension in only one folder (this folder has 2 subdirectories but the files I'm looking fo...
[ { "answer_id": 296184, "author": "Federico A. Ramponi", "author_id": 18770, "author_profile": "https://Stackoverflow.com/users/18770", "pm_score": 6, "selected": true, "text": "<pre><code>import glob, os, shutil\n\nfiles = glob.iglob(os.path.join(source_dir, \"*.ext\"))\nfor file in file...
2008/11/17
[ "https://Stackoverflow.com/questions/296173", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37804/" ]
I'd like to copy the files that have a specific file extension to a new folder. I have an idea how to use `os.walk` but specifically how would I go about using that? I'm searching for the files with a specific file extension in only one folder (this folder has 2 subdirectories but the files I'm looking for will never b...
``` import glob, os, shutil files = glob.iglob(os.path.join(source_dir, "*.ext")) for file in files: if os.path.isfile(file): shutil.copy2(file, dest_dir) ``` Read the [documentation](http://www.python.org/doc/2.5.2/lib/module-shutil.html) of the shutil module to choose the function that fits your needs ...
296,182
<p>In the standard PrintDialog there are four values associated with a selected printer: Status, Type, Where, and Comment.</p> <p>If I know a printer's name, how can I get these values in C# 2.0?</p>
[ { "answer_id": 296232, "author": "dowski", "author_id": 21712, "author_profile": "https://Stackoverflow.com/users/21712", "pm_score": 2, "selected": false, "text": "<p>It's been a long time since I've worked in a Windows environment, but I would suggest that you look at <a href=\"http://...
2008/11/17
[ "https://Stackoverflow.com/questions/296182", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38258/" ]
In the standard PrintDialog there are four values associated with a selected printer: Status, Type, Where, and Comment. If I know a printer's name, how can I get these values in C# 2.0?
As [dowski suggested](https://stackoverflow.com/questions/296182/how-to-get-printer-info-in-cnet#296232), you could use WMI to get printer properties. The following code displays all properties for a given printer name. Among them you will find: PrinterStatus, Comment, Location, DriverName, PortName, etc. ``` using Sy...
296,193
<p>I have a .NET application distributed through <code>ClickOnce</code>. Security within the application is implemented through the <code>WindowsPrincipal.IsInRole(GroupName)</code> method using a set of groups as resources. This structure works well for us for users within the same domain as the groups. Unfortunately ...
[ { "answer_id": 296213, "author": "Mauro", "author_id": 2208, "author_profile": "https://Stackoverflow.com/users/2208", "pm_score": 0, "selected": false, "text": "<p>shouldnt it be a universal group to allow users from multiple trusted domains?</p>\n\n<p>The user account you are checking ...
2008/11/17
[ "https://Stackoverflow.com/questions/296193", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38292/" ]
I have a .NET application distributed through `ClickOnce`. Security within the application is implemented through the `WindowsPrincipal.IsInRole(GroupName)` method using a set of groups as resources. This structure works well for us for users within the same domain as the groups. Unfortunately we now have users that ne...
you might try using LDAP instead, but you'll have to know which LDAP server to query; see [this answer](https://stackoverflow.com/questions/290548/c-validate-a-username-and-password-against-active-directory#290599) for sample code
296,230
<p>In javascript, I've got a block of HTML like this:</p> <pre><code>&lt;h2&gt;{title}&lt;/h2&gt; &lt;p&gt;&lt;a href="{url}"&gt;{content}&lt;/a&gt;&lt;/p&gt; </code></pre> <p>And I'm trying use regex "match" to spit out an array of all the {item}'s. So my output should look like:</p> <pre><code>['title', 'url', 'co...
[ { "answer_id": 296235, "author": "grieve", "author_id": 34329, "author_profile": "https://Stackoverflow.com/users/34329", "pm_score": 2, "selected": false, "text": "<p>I think you want:</p>\n\n<pre><code>var pattern = new RegExp(\"\\{[a-zA-Z]+\\}+\", \"g\");\n</code></pre>\n\n<p>The seco...
2008/11/17
[ "https://Stackoverflow.com/questions/296230", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38241/" ]
In javascript, I've got a block of HTML like this: ``` <h2>{title}</h2> <p><a href="{url}">{content}</a></p> ``` And I'm trying use regex "match" to spit out an array of all the {item}'s. So my output should look like: ``` ['title', 'url', 'content'] ``` I've gotten as far as: ``` var pattern = new RegExp("\{[a-...
You need to create a pattern with the global flag: ``` var pattern = new RegExp("\{[a-zA-Z]+\}", "g"); ``` or: ``` var pattern = /\{[a-zA-Z]+\}/g; ``` Then you can call the match() method on your string to get a list of matches: ``` var matches = "{Sample} bob {text}".match(pattern); ```
296,251
<p>I have a set of classes, each one is a different <a href="http://en.wikipedia.org/wiki/Strategy_pattern" rel="noreferrer">strategy</a> to do the same work. </p> <pre><code>namespace BigCorp.SuperApp { public class BaseClass { } public class ClassA : BaseClass { } public class ClassB : BaseClass { } } </...
[ { "answer_id": 296260, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 4, "selected": false, "text": "<p>Either use the assembly-qualified-name, or get hold of the Assembly and use <code>Assembly.GetType(name)</code>. I...
2008/11/17
[ "https://Stackoverflow.com/questions/296251", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3619/" ]
I have a set of classes, each one is a different [strategy](http://en.wikipedia.org/wiki/Strategy_pattern) to do the same work. ``` namespace BigCorp.SuperApp { public class BaseClass { } public class ClassA : BaseClass { } public class ClassB : BaseClass { } } ``` The choice of which strategy to use is...
Since you know all classes will be coming from the same namespace, configure it once and use that: ``` <appConfig> <SuperAppConfig handlerNamespace="BigCorp.SuperApp"> <Handler class="ClassB" /> </SuperAppConfig> </appConfig> ``` **Edit:** I changed *name* to *class* to better denote the meaning of that ...
296,261
<p>When I try using a <code>Name="id"</code> and\or <code>x:name="id"</code> I get a compiler error:</p> <pre><code>The Type 'MyName' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built. </code></pre> <p>When I don't have this specified my control ru...
[ { "answer_id": 296296, "author": "Kent Boogaart", "author_id": 5380, "author_profile": "https://Stackoverflow.com/users/5380", "pm_score": 0, "selected": false, "text": "<p>I've run into this before and believe it's a compiler bug. I ended up just sticking a named <code>ContentControl</c...
2008/11/17
[ "https://Stackoverflow.com/questions/296261", "https://Stackoverflow.com", "https://Stackoverflow.com/users/805/" ]
When I try using a `Name="id"` and\or `x:name="id"` I get a compiler error: ``` The Type 'MyName' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built. ``` When I don't have this specified my control runs just fine. Any suggestions?
Well, first of all the right syntax is `x:Name`, although `Name` by itself usually (but not always) works too. Does the `x:Class` on your root-level element match the name (and namespace!) of your code-behind file? I know that some versions of Blend and VS didn't insert the default namespace correctly, and of course i...
296,263
<p>What is the <code>@</code> symbol mean in <a href="/questions/tagged/oracle" class="post-tag" title="show questions tagged &#39;oracle&#39;" rel="tag">oracle</a>? </p> <p>For example:</p> <pre><code>select * from question_answer@abcd where id = '45' </code></pre>
[ { "answer_id": 296331, "author": "a2800276", "author_id": 27408, "author_profile": "https://Stackoverflow.com/users/27408", "pm_score": 6, "selected": true, "text": "<p>It refers to a non-local table, the bit behind the @ is the db descriptor.</p>\n<pre><code>select * from question_answe...
2008/11/17
[ "https://Stackoverflow.com/questions/296263", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
What is the `@` symbol mean in [oracle](/questions/tagged/oracle "show questions tagged 'oracle'")? For example: ``` select * from question_answer@abcd where id = '45' ```
It refers to a non-local table, the bit behind the @ is the db descriptor. ``` select * from question_answer@abcd where id = '45' ``` Means select not from the local `question_answer` table, but from the table on the db designated as `abcd`. The keyword to google for is `dblink`
296,264
<p>In EL expressions, used in a jsp page, strings are taken literally. For example, in the following code snippet</p> <pre><code>&lt;c:when test="${myvar == 'prefix.*'}"&gt; </code></pre> <p>test does not evaluate to true if the value of myvar is 'prefixxxxx.' Does anyone know if there is a way to have the string ...
[ { "answer_id": 296324, "author": "lucas", "author_id": 31172, "author_profile": "https://Stackoverflow.com/users/31172", "pm_score": 3, "selected": false, "text": "<p>You can use JSTL functions like so - </p>\n\n<pre><code>&lt;c:when test=\"${fn:startsWith(myVar, 'prefix')}\"&gt;\n</code...
2008/11/17
[ "https://Stackoverflow.com/questions/296264", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1094969/" ]
In EL expressions, used in a jsp page, strings are taken literally. For example, in the following code snippet ``` <c:when test="${myvar == 'prefix.*'}"> ``` test does not evaluate to true if the value of myvar is 'prefixxxxx.' Does anyone know if there is a way to have the string interpreted as a regex instead? Doe...
While this special case can be handled with the JSTL `fn:startsWith` function, regular expressions in general seem like very likely tests. It's unfortunate that JSTL doesn't include a function for these. On the bright side, it's pretty easy to write an EL function that does what you want. You need the function impleme...
296,270
<p>I apologize in advance if this question seems remedial.</p> <p>Which would be considered more efficient in Python:</p> <p><strong>Standard import</strong></p> <pre><code>import logging try: ...some code... exception Exception, e: logging.error(e) </code></pre> <p>...or...</p> <p><strong>Contextual import</...
[ { "answer_id": 296292, "author": "mipadi", "author_id": 28804, "author_profile": "https://Stackoverflow.com/users/28804", "pm_score": 2, "selected": false, "text": "<p>They're essentially the same. The Python interpreter will only load a used module <em>once</em>, no matter how many time...
2008/11/17
[ "https://Stackoverflow.com/questions/296270", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10040/" ]
I apologize in advance if this question seems remedial. Which would be considered more efficient in Python: **Standard import** ``` import logging try: ...some code... exception Exception, e: logging.error(e) ``` ...or... **Contextual import** ``` try: ...some code... exception Exception, e: import logg...
Contextual imports are technically more efficient, but I think they can create other problems. Later, if you want to add a similar except clause, you now have two places to maintain the same block of code. You also now have the problem of testing the exception, to make sure that the first import doesn't cause any unfo...
296,283
<p>The "ATL simple object" wizard doesn't provide a way to specify that a new class is derived from an existing coclass and its interface. In Visual Studio 2008, how do I make a new ATL COM class derived from an existing one (i.e. <code>Base</code> implements <code>IBase</code>, and I want to make a new <code>Derived</...
[ { "answer_id": 297377, "author": "John Dibling", "author_id": 241536, "author_profile": "https://Stackoverflow.com/users/241536", "pm_score": 0, "selected": false, "text": "<p>Edit the code that the wizards generate. If you want an object to derive from additional interfaces, add these ...
2008/11/17
[ "https://Stackoverflow.com/questions/296283", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22820/" ]
The "ATL simple object" wizard doesn't provide a way to specify that a new class is derived from an existing coclass and its interface. In Visual Studio 2008, how do I make a new ATL COM class derived from an existing one (i.e. `Base` implements `IBase`, and I want to make a new `Derived` class derived from `Base` that...
Just a suggestion - if your COM object does not need to do anything special with COM related stuff then you can implement code such that the real logic that your base COM class does is encapsulated in another plain old C++ class say CBaseLogic. ``` CBaseLogic : IBase class ATL_NO_VTABLE CBase : public CComObject...
296,284
<p>I would like to create dynamic urls that route to controller actions with an Id value. I've created the following route using a catch-all parameter</p> <pre><code>routes.MapRoute( "RouteName", "{id}/{*Url}", new { controller = "Con...
[ { "answer_id": 300635, "author": "Doug Wilson", "author_id": 32588, "author_profile": "https://Stackoverflow.com/users/32588", "pm_score": 1, "selected": false, "text": "<p>That's a really difficult one, for me anyway.</p>\n\n<p>Given the following route:</p>\n\n<pre><code>routes.MapRout...
2008/11/17
[ "https://Stackoverflow.com/questions/296284", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I would like to create dynamic urls that route to controller actions with an Id value. I've created the following route using a catch-all parameter ``` routes.MapRoute( "RouteName", "{id}/{*Url}", new { controller = "Controller", acti...
That's a really difficult one, for me anyway. Given the following route: ``` routes.MapRoute("Default", "{*token}", new { controller = "Home", action = "Index", token = 0 }); ``` Your controller and supporting classes would be something like this: ``` [HandleError] public class HomeController : Controller { ...
296,294
<p>How do I install a specific package, like derbytools, with Maven without specifying it as a dependency of project?</p>
[ { "answer_id": 296315, "author": "rich", "author_id": 25502, "author_profile": "https://Stackoverflow.com/users/25502", "pm_score": 2, "selected": false, "text": "<p>Here is a sample using the <code>mvn install</code> goal. I used windows style env vars in place of parameters you will n...
2008/11/17
[ "https://Stackoverflow.com/questions/296294", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6068/" ]
How do I install a specific package, like derbytools, with Maven without specifying it as a dependency of project?
Here is a sample using the `mvn install` goal. I used windows style env vars in place of parameters you will need to provide. ``` mvn install:install-file -DgroupId=%DERBYTOOLS_GROUP_ID% \ -DartifactId=%DERBYTOOLS_ARTIFACT_ID% \ -Dversion=%DERBYTOOLS_VERSION% \ -Dpackaging=jar \ -Dfile=%DERBYTOOLS_FIL...
296,309
<p>The following code is just a simplified example to demonstrate my problem:</p> <pre><code>using System; using System.IO; using System.Diagnostics; using System.Threading; namespace ConsoleApplication5 { class Program { static string LogFile = @"C:\test.log"; static void Main(string[] args)...
[ { "answer_id": 296363, "author": "bruno conde", "author_id": 31136, "author_profile": "https://Stackoverflow.com/users/31136", "pm_score": 4, "selected": true, "text": "<p>There is nothing strange going on here. Imagine that you have a file \"a.txt\" and you open it in notepad 10 times. ...
2008/11/17
[ "https://Stackoverflow.com/questions/296309", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3043/" ]
The following code is just a simplified example to demonstrate my problem: ``` using System; using System.IO; using System.Diagnostics; using System.Threading; namespace ConsoleApplication5 { class Program { static string LogFile = @"C:\test.log"; static void Main(string[] args) { ...
There is nothing strange going on here. Imagine that you have a file "a.txt" and you open it in notepad 10 times. After that, you change the contents of the file and save it in every instance of notepad. Naturally, the last save you make is the one that is persisted to the file because it rewrites the previous 9 saves....
296,312
<p>I'm using Spring's dependency injection but I'm running into difficulty loading a resource in my Spring config file. </p> <p>The resource is an XML file and is in a JAR file on my classpath. I try to access it as follows:</p> <pre><code>&lt;import resource="classpath:com/config/resources.xml" /&gt; </code></pre> ...
[ { "answer_id": 296357, "author": "toolkit", "author_id": 3295, "author_profile": "https://Stackoverflow.com/users/3295", "pm_score": 4, "selected": true, "text": "<p>If it needs to be in the classpath of your webapp, then you should stick the JAR containing the config file into your WEB-...
2008/11/17
[ "https://Stackoverflow.com/questions/296312", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24481/" ]
I'm using Spring's dependency injection but I'm running into difficulty loading a resource in my Spring config file. The resource is an XML file and is in a JAR file on my classpath. I try to access it as follows: ``` <import resource="classpath:com/config/resources.xml" /> ``` however I keep getting encountering ...
If it needs to be in the classpath of your webapp, then you should stick the JAR containing the config file into your WEB-INF/lib directory. If you're using a webapp, then the common convention is use a ContextLoaderListener to ensure a WebApplicationContext is inserted into a standard place in the ServletContext: ``...
296,325
<p>I'm teaching Java EE at the university, and this was a question a student asked. I said "no", but I wasn't really sure, so I thought I might ask you mighty developers. :)</p> <p>Basically, what I'd like to do is to use entities if they were in my context: cat getters, setters, etc, so like normal POJOs. if I use an...
[ { "answer_id": 296436, "author": "rich", "author_id": 25502, "author_profile": "https://Stackoverflow.com/users/25502", "pm_score": -1, "selected": false, "text": "<p>One alternative is <a href=\"http://www.springframework.org/\" rel=\"nofollow noreferrer\">the Spring Framework</a>. Spr...
2008/11/17
[ "https://Stackoverflow.com/questions/296325", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm teaching Java EE at the university, and this was a question a student asked. I said "no", but I wasn't really sure, so I thought I might ask you mighty developers. :) Basically, what I'd like to do is to use entities if they were in my context: cat getters, setters, etc, so like normal POJOs. if I use an EJB using...
In a basic modern world Java EE application, it is broken into various layers, where you have 4 basic layers ``` +--------------------+ | Presentation | +--------------------+ | Controller/Actions | +--------------------+ | Business Delegate | | (Service) | +--------------------+ | Data Access Layer ...
296,366
<p>I have a directory full of files and I need to pull the headers and footers off of them. They are all variable length so using head or tail isn't going to work. Each file does have a line I can search for, but I don't want to include the line in the results.</p> <p>It's usually </p> <pre><code>*** Start (more text...
[ { "answer_id": 296385, "author": "Jonathan Lonowski", "author_id": 15031, "author_profile": "https://Stackoverflow.com/users/15031", "pm_score": 0, "selected": false, "text": "<p>Maybe? Start to Finish with not-delete.</p>\n\n<pre><code>$ sed -i '/^\\*\\*\\* Start/,/^\\*\\*\\* Finish/d!'...
2008/11/17
[ "https://Stackoverflow.com/questions/296366", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13704/" ]
I have a directory full of files and I need to pull the headers and footers off of them. They are all variable length so using head or tail isn't going to work. Each file does have a line I can search for, but I don't want to include the line in the results. It's usually ``` *** Start (more text here) ``` And ends...
Try the [flip flop!](http://perldoc.perl.org/perlop.html#Range-Operators) ".." operator. ``` # flip-flop.pl use strict; use warnings; my $start = qr/^\*\*\* Start/; my $finish = qr/^\*\*\* Finish/; while ( <> ) { if ( /$start/ .. /$finish/ ) { next if /$start/ or /$finish/; print $_; } } `...
296,398
<p>I have a List of beans, each of which has a property which itself is a List of email addresses.</p> <pre><code>&lt;c:forEach items="${upcomingSchedule}" var="conf"&gt; &lt;div class='scheduled' title="${conf.subject}" id="scheduled&lt;c:out value="${conf.id}"/&gt;"&gt; ... &lt;/div&gt; &lt;/c:forEach&gt...
[ { "answer_id": 296430, "author": "matt b", "author_id": 4249, "author_profile": "https://Stackoverflow.com/users/4249", "pm_score": 4, "selected": true, "text": "<p>Figured out a somewhat dirty way to do this:</p>\n\n<pre><code>&lt;c:forEach items=\"${upcomingSchedule}\" var=\"conf\"&gt;...
2008/11/17
[ "https://Stackoverflow.com/questions/296398", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4249/" ]
I have a List of beans, each of which has a property which itself is a List of email addresses. ``` <c:forEach items="${upcomingSchedule}" var="conf"> <div class='scheduled' title="${conf.subject}" id="scheduled<c:out value="${conf.id}"/>"> ... </div> </c:forEach> ``` This renders one `<div>` per bean in...
Figured out a somewhat dirty way to do this: ``` <c:forEach items="${upcomingSchedule}" var="conf"> <c:set var="title" value="${conf.subject}: "/> <c:forEach items="${conf.invitees}" var="invitee"> <c:set var="title" value="${title} ${invitee}, "/> </c:forEach> <div class='scheduled' title="${t...
296,418
<p>I have a datagridview where the users can select which subset of columns to view. The problem I am having is that when I change the columns being displayed, the column widths are only being determined by the width of the Header Cells, not the data in it. I do have each column set to AutoSizeMode = AllCells.</p> <p...
[ { "answer_id": 296425, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 3, "selected": true, "text": "<p>Hmm... can't say I've seen that myself, but (as a workaround) you could try toggling the resize mode after you chan...
2008/11/17
[ "https://Stackoverflow.com/questions/296418", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4779/" ]
I have a datagridview where the users can select which subset of columns to view. The problem I am having is that when I change the columns being displayed, the column widths are only being determined by the width of the Header Cells, not the data in it. I do have each column set to AutoSizeMode = AllCells. If a new ...
Hmm... can't say I've seen that myself, but (as a workaround) you could try toggling the resize mode after you change the columns: ``` dgv.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.None; dgv.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; ``` Worth a try...
296,490
<p>I would like to remove two files from a folder at the conclusion of my script. Do I need to create a function responsible for removing these two specific files? I would like to know in some detail how to use os.remove (if that is what I should use) properly. These two files will always be discarded at the conclusion...
[ { "answer_id": 296495, "author": "mipadi", "author_id": 28804, "author_profile": "https://Stackoverflow.com/users/28804", "pm_score": -1, "selected": true, "text": "<p>Just call <code>os.remove(\"path/to/file\")</code>. For example, to remove the file <code>.emacs</code>, call</p>\n\n<pr...
2008/11/17
[ "https://Stackoverflow.com/questions/296490", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37804/" ]
I would like to remove two files from a folder at the conclusion of my script. Do I need to create a function responsible for removing these two specific files? I would like to know in some detail how to use os.remove (if that is what I should use) properly. These two files will always be discarded at the conclusion of...
Just call `os.remove("path/to/file")`. For example, to remove the file `.emacs`, call ``` os.remove(".emacs") ``` The path should be a `str` that's the pathname of the file. It may be relative or absolute.
296,499
<p>Once I have all the files I require in a particular folder, I would like my python script to zip the folder contents. </p> <p>Is this possible? </p> <p>And how could I go about doing it?</p>
[ { "answer_id": 296565, "author": "Kozyarchuk", "author_id": 52490, "author_profile": "https://Stackoverflow.com/users/52490", "pm_score": 3, "selected": false, "text": "<p>Here is a recursive version</p>\n\n<pre><code>def zipfolder(path, relname, archive):\n paths = os.listdir(path)\n...
2008/11/17
[ "https://Stackoverflow.com/questions/296499", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37804/" ]
Once I have all the files I require in a particular folder, I would like my python script to zip the folder contents. Is this possible? And how could I go about doing it?
Adapted version of [the script](http://mail.python.org/pipermail/python-list/2006-May/384142.html) is: ``` #!/usr/bin/env python from __future__ import with_statement from contextlib import closing from zipfile import ZipFile, ZIP_DEFLATED import os def zipdir(basedir, archivename): assert os.path.isdir(basedir) ...
296,501
<p>I am overriding a Grid, adding some customer features. One of the features is a drop-down to adjust page size. I am extending the grid using a customer server control, which works great for what I've done so far. Now, however I am having a bit of trouble getting the dynamically added control to do a postback. Th...
[ { "answer_id": 296508, "author": "FlySwat", "author_id": 1965, "author_profile": "https://Stackoverflow.com/users/1965", "pm_score": 1, "selected": false, "text": "<p>You need to set \"AutoPostBack\" to true for a dropdown list to postback. Otherwise, another control will have to post th...
2008/11/17
[ "https://Stackoverflow.com/questions/296501", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2017/" ]
I am overriding a Grid, adding some customer features. One of the features is a drop-down to adjust page size. I am extending the grid using a customer server control, which works great for what I've done so far. Now, however I am having a bit of trouble getting the dynamically added control to do a postback. The javas...
The first thing I noticed was you'd be missing this: ``` pageSizeDropdown.AutoPostBack = true ``` but I'm not sure if that's all you need for it to work
296,503
<p>I have a user control where the XAML of the control can bind to the appropriate properties from the parent's data context like normal (the data context propagates in xaml). </p> <p>For example, I have a window whose DataContext I am setting to ObjectA for example. My user control within the window is then try to ac...
[ { "answer_id": 296614, "author": "Jobi Joy", "author_id": 8091, "author_profile": "https://Stackoverflow.com/users/8091", "pm_score": 4, "selected": false, "text": "<p>I think you are checking the 'DataContext' in the constructor of the UserControl. It will be null at the Constructor sin...
2008/11/17
[ "https://Stackoverflow.com/questions/296503", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9401/" ]
I have a user control where the XAML of the control can bind to the appropriate properties from the parent's data context like normal (the data context propagates in xaml). For example, I have a window whose DataContext I am setting to ObjectA for example. My user control within the window is then try to access the p...
failing that if you need to check whether the DataContext is being set you can use the DataContextChanged ``` public partial class UserControl1 : UserControl { public UserControl1() { InitializeComponent(); DataContextChanged += new DependencyPropertyChangedEventHandler(UserControl1_DataContex...
296,517
<p>I need to pass an array from JavaScript to a page method in C#. I have tried using a parameter in the C# method of IList and also a string[] array. Both ways throw an exception "cannot convert an object of type system.string to xxx", where xxx is the parameter type in the C# method. I am passing the object from jQue...
[ { "answer_id": 296564, "author": "Powerlord", "author_id": 15880, "author_profile": "https://Stackoverflow.com/users/15880", "pm_score": 4, "selected": true, "text": "<p>Hmm, two things:</p>\n\n<ol>\n<li>JSON arrays have square brackets around them</li>\n<li>JSON numbers aren't quoted.</...
2008/11/17
[ "https://Stackoverflow.com/questions/296517", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1284/" ]
I need to pass an array from JavaScript to a page method in C#. I have tried using a parameter in the C# method of IList and also a string[] array. Both ways throw an exception "cannot convert an object of type system.string to xxx", where xxx is the parameter type in the C# method. I am passing the object from jQuery ...
Hmm, two things: 1. JSON arrays have square brackets around them 2. JSON numbers aren't quoted. Try this instead: ``` {"testNumbers": [5555555555,3333333333,4444444444]} ```
296,519
<p>I have shell script which starts with:</p> <pre><code>sdir=`dirname $0` sdir=`(cd "$sdir/"; pwd)` </code></pre> <p>And this usually gets expanded (with 'sh -h') into </p> <pre><code>++ dirname /opt/foo/bin/bar + sdir=/opt/foo/bin ++ cd /opt/foo/bin/ ++ pwd + sdir=/opt/foo/bin </code></pre> <p>but for single user...
[ { "answer_id": 296566, "author": "David M. Karr", "author_id": 10508, "author_profile": "https://Stackoverflow.com/users/10508", "pm_score": 0, "selected": false, "text": "<p>It's possible that user has some funky alias for \"cd\". Perhaps you could try making it do \"/usr/bin/cd\" (or ...
2008/11/17
[ "https://Stackoverflow.com/questions/296519", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have shell script which starts with: ``` sdir=`dirname $0` sdir=`(cd "$sdir/"; pwd)` ``` And this usually gets expanded (with 'sh -h') into ``` ++ dirname /opt/foo/bin/bar + sdir=/opt/foo/bin ++ cd /opt/foo/bin/ ++ pwd + sdir=/opt/foo/bin ``` but for single user for single combination of parameters in expands ...
The culprit is cd, try this instead ``` sdir=`dirname $0` sdir=`(cd "$sdir/" >/dev/null; pwd)` ``` This happens because when you specify a non absolute path and the directory is found in the environment variable CDPATH, cd prints to stdout the value of the absolute path to the directory it changed to. Relevant man ...
296,520
<p>I have a Win32 console application which is doing some computations, compiled in Compaq Visual Fortran (which probably doesn't matter). </p> <p>I need to run a lot of them simultaneously.</p> <p>In XP, they take around 90-100% CPU together, work very fast. In Vista, no matter how many of them I run, they take no m...
[ { "answer_id": 296547, "author": "Patrick Desjardins", "author_id": 13913, "author_profile": "https://Stackoverflow.com/users/13913", "pm_score": 0, "selected": false, "text": "<p>Is it the same machine hardware on your Vista and XP? It might use just 10% of the Vista because it doesn't ...
2008/11/17
[ "https://Stackoverflow.com/questions/296520", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38325/" ]
I have a Win32 console application which is doing some computations, compiled in Compaq Visual Fortran (which probably doesn't matter). I need to run a lot of them simultaneously. In XP, they take around 90-100% CPU together, work very fast. In Vista, no matter how many of them I run, they take no more than 10% of C...
Have you tried redirecting the console output to a file? If your applications are being held up writing to the console (this happens sometimes unfortunately) then redirecting the output should help, as it's much quicker to write to a simple file than write to the console. You do this like so ``` c:\temp> dir > output...
296,525
<h1>Example</h1> <p>There is an application that measures temperature in each town of the world. Each measurement is taken every 5 minutes and written in to the Measurement table.</p> <pre><code>CREATE TABLE [dbo].[Measurement]( [MeasurementID] [int] IDENTITY(1,1) NOT NULL, [Town] [varchar](50) NOT NULL, [D...
[ { "answer_id": 296531, "author": "Andrew Rimmer", "author_id": 1982, "author_profile": "https://Stackoverflow.com/users/1982", "pm_score": 0, "selected": false, "text": "<pre><code>select s.*\nfrom Measurement s\nwhere exists ( \n select 1\n from Measurement s1\n where s.Town = s1....
2008/11/17
[ "https://Stackoverflow.com/questions/296525", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1982/" ]
Example ======= There is an application that measures temperature in each town of the world. Each measurement is taken every 5 minutes and written in to the Measurement table. ``` CREATE TABLE [dbo].[Measurement]( [MeasurementID] [int] IDENTITY(1,1) NOT NULL, [Town] [varchar](50) NOT NULL, [Date] [datetim...
Here are a couple that should work: SELECT m1.Town, m1.Temp FROM Measurement AS m1 LEFT JOIN Measurement AS m2 ON m1.Town = m2.Town AND m1.Date < m2.Date WHERE m2.MeasurementID IS NULL ORDER BY m1.Town --- You'll need an index on Town and Date. This technique is especially us...
296,533
<p>I have a Windows Forms app, that has a single ElementHost containing a WPF UserControl... in my WPF, I have a VERY simple ListView:</p> <pre><code>&lt;ListView Margin="4" ItemsSource="{Binding Notifications}"&gt; &lt;ListView.View&gt; &lt;GridView&gt; &lt;GridViewColumn Header="FirstName" Di...
[ { "answer_id": 296606, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 6, "selected": true, "text": "<p>Use virtualization</p>\n\n<pre><code>&lt;ListView ItemsSource=\"{BindingNames}\"Name=\"lv\"&gt;\n &lt;ListView.It...
2008/11/17
[ "https://Stackoverflow.com/questions/296533", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11917/" ]
I have a Windows Forms app, that has a single ElementHost containing a WPF UserControl... in my WPF, I have a VERY simple ListView: ``` <ListView Margin="4" ItemsSource="{Binding Notifications}"> <ListView.View> <GridView> <GridViewColumn Header="FirstName" DisplayMemberBinding="{Binding FirstN...
Use virtualization ``` <ListView ItemsSource="{BindingNames}"Name="lv"> <ListView.ItemsPanel> <ItemsPanelTemplate> <!--<StackPanel/> If StackPanel was used, the memory consumed was over 2GB and dead slow. --> <Vir...
296,536
<p>I am trying to write a bash script for testing that takes a parameter and sends it through curl to web site. I need to url encode the value to make sure that special characters are processed properly. What is the best way to do this? </p> <p>Here is my basic script so far:</p> <pre><code>#!/bin/bash host=${1:?'...
[ { "answer_id": 296630, "author": "Jay", "author_id": 20840, "author_profile": "https://Stackoverflow.com/users/20840", "pm_score": 3, "selected": false, "text": "<p>If you don't want to depend on Perl you can also use sed. It's a bit messy, as each character has to be escaped individuall...
2008/11/17
[ "https://Stackoverflow.com/questions/296536", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19130/" ]
I am trying to write a bash script for testing that takes a parameter and sends it through curl to web site. I need to url encode the value to make sure that special characters are processed properly. What is the best way to do this? Here is my basic script so far: ``` #!/bin/bash host=${1:?'bad host'} value=$2 shif...
Use `curl --data-urlencode`; from `man curl`: > > This posts data, similar to the other `--data` options with the exception that this performs URL-encoding. To be CGI-compliant, the `<data>` part should begin with a name followed by a separator and a content specification. > > > Example usage: ``` curl \ --d...
296,538
<p>I'm working for the first time with Forms Authentication, I'm using an example from the web to learn, I included in my web.config</p> <pre><code> &lt;authentication mode="Forms"&gt; &lt;forms name="MYWEBAPP.ASPXAUTH" loginUrl="Login.aspx" protection="All" path="/"/&gt; &lt;/authentication&gt; &lt...
[ { "answer_id": 296546, "author": "Jonas Kongslund", "author_id": 37548, "author_profile": "https://Stackoverflow.com/users/37548", "pm_score": 3, "selected": true, "text": "<p>Drop the spaces in</p>\n\n<pre><code>\"accountants, seekers, copiers, typers\"\n</code></pre>\n" }, { "a...
2008/11/17
[ "https://Stackoverflow.com/questions/296538", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1130097/" ]
I'm working for the first time with Forms Authentication, I'm using an example from the web to learn, I included in my web.config ``` <authentication mode="Forms"> <forms name="MYWEBAPP.ASPXAUTH" loginUrl="Login.aspx" protection="All" path="/"/> </authentication> <authorization> <deny users...
Drop the spaces in ``` "accountants, seekers, copiers, typers" ```
296,550
<p>I understand how Lucene.net can work for text indexing. Will I be able to efficiently search for documents based on a given date range? Or will Lucene.net just use text matching to match the dates?</p>
[ { "answer_id": 304964, "author": "Stefan Schultze", "author_id": 6358, "author_profile": "https://Stackoverflow.com/users/6358", "pm_score": 4, "selected": true, "text": "<p>Lucene.Net will just use text matching, so you'd need to format the dates correctly before adding to the index:</p...
2008/11/17
[ "https://Stackoverflow.com/questions/296550", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1363/" ]
I understand how Lucene.net can work for text indexing. Will I be able to efficiently search for documents based on a given date range? Or will Lucene.net just use text matching to match the dates?
Lucene.Net will just use text matching, so you'd need to format the dates correctly before adding to the index: ``` public static string Serialize(DateTime dateTime) { return dateTime.ToString("yyyyMMddHHmmss", CultureInfo.InvariantCulture); } public static DateTime Deserialize(string str) ...
296,560
<p>I am looking for a way to mount\unmount a USB flash drive using VBScript. This is the closest I was able to get.</p> <pre><code>Sub EjectDrive(strDrive) On Error Resume Next CONST SSF_DRIVES = 17 Set objShell = CreateObject("Shell.Application") Set objDrive = objShell.Namespace(SSF_DRIVES).ParseName(strDrive) objD...
[ { "answer_id": 297352, "author": "aphoria", "author_id": 2441, "author_profile": "https://Stackoverflow.com/users/2441", "pm_score": 2, "selected": false, "text": "<p>This will work on Windows Server 2003, but not NT/2000/XP/Vista unfortunately.</p>\n\n<pre><code>strComputer = \".\"\nSet...
2008/11/17
[ "https://Stackoverflow.com/questions/296560", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am looking for a way to mount\unmount a USB flash drive using VBScript. This is the closest I was able to get. ``` Sub EjectDrive(strDrive) On Error Resume Next CONST SSF_DRIVES = 17 Set objShell = CreateObject("Shell.Application") Set objDrive = objShell.Namespace(SSF_DRIVES).ParseName(strDrive) objDrive.InvokeVerb...
This will work on Windows Server 2003, but not NT/2000/XP/Vista unfortunately. ``` strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery _ ("Select * From Win32_Volume Where Name = 'E:\\'") F...
296,609
<p>I'm trying to avoid a composite control or using and ASCX by extending an existing control. However, I'm having trouble with getting the controls added to the inherited control and keep their view-state/post-back integrity. Whenever I add the controls during pre-render, the controls show up, but the post-back throws...
[ { "answer_id": 296622, "author": "user38123", "author_id": 38123, "author_profile": "https://Stackoverflow.com/users/38123", "pm_score": 2, "selected": false, "text": "<p>You should add them in OnInit or in CreateChildControls. Anyway, to avoid having troubles with ViewState, read <a hre...
2008/11/17
[ "https://Stackoverflow.com/questions/296609", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2017/" ]
I'm trying to avoid a composite control or using and ASCX by extending an existing control. However, I'm having trouble with getting the controls added to the inherited control and keep their view-state/post-back integrity. Whenever I add the controls during pre-render, the controls show up, but the post-back throws a ...
Actually, microsoft says you should override the [CreateChildControls](http://msdn.microsoft.com/en-us/library/system.web.ui.control.createchildcontrols.aspx) method. You can call the base class method before or after you add the controls, I'm not sure if there is a convention there. ``` protected override void Creat...
296,615
<p>Greetings!</p> <p>I'm scratching my head, wondering why when I do the following:</p> <pre><code>Response.Redirect(@"http://www.example.com/file.exe?id=12345"); </code></pre> <p>Both IE6 and IE7 will download the file as "file" (with no extension), but Firefox, Opera, Google Chrome and Safari have no problems at a...
[ { "answer_id": 296631, "author": "Falco Foxburr", "author_id": 37266, "author_profile": "https://Stackoverflow.com/users/37266", "pm_score": 2, "selected": false, "text": "<p>Have You tried to set correct content-type in Your response headers? For example:</p>\n\n<pre><code>Content-Type:...
2008/11/17
[ "https://Stackoverflow.com/questions/296615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27870/" ]
Greetings! I'm scratching my head, wondering why when I do the following: ``` Response.Redirect(@"http://www.example.com/file.exe?id=12345"); ``` Both IE6 and IE7 will download the file as "file" (with no extension), but Firefox, Opera, Google Chrome and Safari have no problems at all downloading the file as "file....
Have You tried to set correct content-type in Your response headers? For example: ``` Content-Type: application/octet-stream Content-Disposition: attachment; filename="file.exe" ```
296,619
<p>FreeMarker templates support an if-statement with the following syntax</p> <pre><code>&lt;#if hot&gt; It's hot. &lt;/#if&gt; </code></pre> <p>I've looked in the documentation and can't find any support for an if-else statement. Of course, I could achieve the same result with:</p> <pre><code>&lt;#if hot&gt; ...
[ { "answer_id": 296627, "author": "Ulf Lindback", "author_id": 30354, "author_profile": "https://Stackoverflow.com/users/30354", "pm_score": 6, "selected": true, "text": "<p>Yes, you can write:</p>\n\n<pre><code>&lt;#if hot&gt;\nit's hot\n&lt;#else&gt;\nit's not\n&lt;/#if&gt;\n</code></pr...
2008/11/17
[ "https://Stackoverflow.com/questions/296619", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2648/" ]
FreeMarker templates support an if-statement with the following syntax ``` <#if hot> It's hot. </#if> ``` I've looked in the documentation and can't find any support for an if-else statement. Of course, I could achieve the same result with: ``` <#if hot> It's hot. </#if> <#if !hot> It's not hot. </#if>...
Yes, you can write: ``` <#if hot> it's hot <#else> it's not </#if> ``` And if you're doing lots of freemarker, I really can recommend IntelliJ IDEA 8, its freemarker support really helps...
296,632
<p>I'm trying to configure Apache to allow read only access and ask for user to write to a SVN repository when you are coming from the local network (10.*) but not allow any access unless logged in when coming from external network.</p> <p>I sort of understand how the Order, Deny, Allow, and Limit directives work but ...
[ { "answer_id": 296627, "author": "Ulf Lindback", "author_id": 30354, "author_profile": "https://Stackoverflow.com/users/30354", "pm_score": 6, "selected": true, "text": "<p>Yes, you can write:</p>\n\n<pre><code>&lt;#if hot&gt;\nit's hot\n&lt;#else&gt;\nit's not\n&lt;/#if&gt;\n</code></pr...
2008/11/17
[ "https://Stackoverflow.com/questions/296632", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32465/" ]
I'm trying to configure Apache to allow read only access and ask for user to write to a SVN repository when you are coming from the local network (10.\*) but not allow any access unless logged in when coming from external network. I sort of understand how the Order, Deny, Allow, and Limit directives work but I do not ...
Yes, you can write: ``` <#if hot> it's hot <#else> it's not </#if> ``` And if you're doing lots of freemarker, I really can recommend IntelliJ IDEA 8, its freemarker support really helps...
296,643
<p>I'm getting ready to implement a source control system (subversion) but I'm facing some doubts on how to structure my folders.</p> <p>I use Delphi for all my development and compile the projects from within the IDE.</p> <p>My current projects folder structure is as follows:</p> <pre> -E:\Work\1. Shared --Forms (s...
[ { "answer_id": 296651, "author": "Tim", "author_id": 10755, "author_profile": "https://Stackoverflow.com/users/10755", "pm_score": 2, "selected": false, "text": "<p>why the 5.x? (under projectA)</p>\n\n<p>I don't think it is useful to introduce the versions in the tree - that is what sub...
2008/11/17
[ "https://Stackoverflow.com/questions/296643", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36544/" ]
I'm getting ready to implement a source control system (subversion) but I'm facing some doubts on how to structure my folders. I use Delphi for all my development and compile the projects from within the IDE. My current projects folder structure is as follows: ``` -E:\Work\1. Shared --Forms (shared forms across all...
Having setup literally hundreds of projects over the years, and having specialized in software configuration management and release engineering, I would recommend that you first focus on how you want to build/release your project(s). If you only use an IDE to build (compile and package) your project(s), then you might...
296,667
<p>I have a function, <code>a()</code>, that I want to override, but also have the original <code>a()</code> be performed in an order depending on the context. For example, sometimes when I'm generating a page I'll want to override like this:</p> <pre><code>function a() { new_code(); original_a(); } </code></p...
[ { "answer_id": 296706, "author": "Matthew Crumley", "author_id": 2214, "author_profile": "https://Stackoverflow.com/users/2214", "pm_score": 9, "selected": true, "text": "<p>You could do something like this:</p>\n\n<pre><code>var a = (function() {\n var original_a = a;\n\n if (cond...
2008/11/17
[ "https://Stackoverflow.com/questions/296667", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16777/" ]
I have a function, `a()`, that I want to override, but also have the original `a()` be performed in an order depending on the context. For example, sometimes when I'm generating a page I'll want to override like this: ``` function a() { new_code(); original_a(); } ``` and sometimes like this: ``` function a...
You could do something like this: ``` var a = (function() { var original_a = a; if (condition) { return function() { new_code(); original_a(); } } else { return function() { original_a(); other_new_code(); } } })(); ``` ...
296,674
<p>One thing that bugs me about IE is that when it goes to load a page with an iframe it will wait until the iframe has finished loading before it will render the page. Firefox by contrast will render all the other page elements while the iframe is loading which is really nice if the iframe takes a long time to load b...
[ { "answer_id": 296731, "author": "Mark Cidade", "author_id": 1659, "author_profile": "https://Stackoverflow.com/users/1659", "pm_score": 3, "selected": true, "text": "<p>What if you were to load the page with an XmlHttpRequest and then replace the contents of the document as/when it load...
2008/11/17
[ "https://Stackoverflow.com/questions/296674", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5234/" ]
One thing that bugs me about IE is that when it goes to load a page with an iframe it will wait until the iframe has finished loading before it will render the page. Firefox by contrast will render all the other page elements while the iframe is loading which is really nice if the iframe takes a long time to load becau...
What if you were to load the page with an XmlHttpRequest and then replace the contents of the document as/when it loads? ``` <!-- jQuery example: --> <div id='content'>Loading...</div> <script type='text/javascript'> $("#content").load(url); </script> ```
296,685
<p>I am trying to autoreload my page after every 20 seconds. I am using JavaScript for this instead of the &lt;meta>.</p> <p>I have &lt;body onload="SetTimer()"> and here is my JavaScript function</p> <pre><code> function SetTimer(){ setTimeout('window.location.replace(window.location.pathname)', 20000) ...
[ { "answer_id": 296727, "author": "ng.mangine", "author_id": 37784, "author_profile": "https://Stackoverflow.com/users/37784", "pm_score": 1, "selected": false, "text": "<p>window.location will include the GET parameters that were that was passed.</p>\n\n<pre><code>function SetTimer(){ \n...
2008/11/17
[ "https://Stackoverflow.com/questions/296685", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34219/" ]
I am trying to autoreload my page after every 20 seconds. I am using JavaScript for this instead of the <meta>. I have <body onload="SetTimer()"> and here is my JavaScript function ``` function SetTimer(){ setTimeout('window.location.replace(window.location.pathname)', 20000) } ``` Now my problem is...
``` setTimeout('window.location.replace(window.location.href)', 2000); ``` did the trick
296,696
<p>In Excel VBA (2003), I've noticed that any <strong>Public</strong> or <strong>Friend</strong> <strong>Sub</strong> method in either a module or <em>ThisWorkbook</em> that doesn't have any arguments will show up as a Macro that can be run by the user. I.e. when the user goes to Tools --> Macro --> Macros... (or Alt+...
[ { "answer_id": 296765, "author": "e.James", "author_id": 33686, "author_profile": "https://Stackoverflow.com/users/33686", "pm_score": 3, "selected": false, "text": "<p>One solution is to give the method an <code>Optional</code> argument.</p>\n\n<pre><code>Public Sub myPublicSub(Optional...
2008/11/17
[ "https://Stackoverflow.com/questions/296696", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1354/" ]
In Excel VBA (2003), I've noticed that any **Public** or **Friend** **Sub** method in either a module or *ThisWorkbook* that doesn't have any arguments will show up as a Macro that can be run by the user. I.e. when the user goes to Tools --> Macro --> Macros... (or Alt+F8) the method will show up in the list that can b...
Add the following to the top of your module: ``` Option Private Module ``` From [MSDN](http://msdn.microsoft.com/en-us/library/aa266185(VS.60).aspx): > > When a module contains Option Private > Module, the public parts, for example, > variables, objects, and user-defined > types declared at module level, are > ...
296,717
<p>I need to unzip a compressed file on the fly in my program. It works when I try it on my own linux computer, but for some reason the school computers fail whenever I tell them to do it. To unzip I'm using the following command:</p> <pre><code> zcat /file/address/file.tar.gz </code></pre> <p>and get the error:</p> ...
[ { "answer_id": 296725, "author": "Alnitak", "author_id": 6782, "author_profile": "https://Stackoverflow.com/users/6782", "pm_score": 7, "selected": true, "text": "<p>Your school's system still has the old \"compress\" style utilities rather than the newer GNU \"gzip\" based ones.</p>\n\n...
2008/11/17
[ "https://Stackoverflow.com/questions/296717", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21539/" ]
I need to unzip a compressed file on the fly in my program. It works when I try it on my own linux computer, but for some reason the school computers fail whenever I tell them to do it. To unzip I'm using the following command: ``` zcat /file/address/file.tar.gz ``` and get the error: ``` /file/address/file.tar.g...
Your school's system still has the old "compress" style utilities rather than the newer GNU "gzip" based ones. You need to use `gzcat` rather than `zcat`, assuming that it's available.
296,719
<p>What's a good rule of thumb for naming methods that return properties/attributes/members of an object? If an object has some immutable quality "blarg", should a method that returns that quality be called "blarg()" or "getBlarg()"? The Java API, for example, is inconsistent: most properties are accessed through "ge...
[ { "answer_id": 296734, "author": "Khb", "author_id": 37817, "author_profile": "https://Stackoverflow.com/users/37817", "pm_score": 2, "selected": false, "text": "<p>I believe the most often used conventions are:</p>\n\n<pre><code>GetBlarg() or getBlarg()\n</code></pre>\n\n<p>It could be ...
2008/11/17
[ "https://Stackoverflow.com/questions/296719", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38343/" ]
What's a good rule of thumb for naming methods that return properties/attributes/members of an object? If an object has some immutable quality "blarg", should a method that returns that quality be called "blarg()" or "getBlarg()"? The Java API, for example, is inconsistent: most properties are accessed through "get" me...
I believe the most often used conventions are: ``` GetBlarg() or getBlarg() ``` It could be argued that the name `GetHashCode()` is incorrect, since the object doesn't have a field called `hashcode` and that it's calculated. These are of course all conventions, not rules, and most of them have evolved over a long t...
296,721
<p>When is it appropriate to use &lt;cflock scope="application"&gt; or it's ilk as opposed to &lt;cflock name="foo"&gt;? </p> <p>Specifically, I'm interested in using CFLock to protect shared objects in the application, session, or server scopes, but I'm also interested in finding out about different uses of locking ...
[ { "answer_id": 296758, "author": "Anne Porosoff", "author_id": 28701, "author_profile": "https://Stackoverflow.com/users/28701", "pm_score": 0, "selected": false, "text": "<p>Typically you should always use cflock for session, application and server vars any time you're reading or changi...
2008/11/17
[ "https://Stackoverflow.com/questions/296721", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21973/" ]
When is it appropriate to use <cflock scope="application"> or it's ilk as opposed to <cflock name="foo">? Specifically, I'm interested in using CFLock to protect shared objects in the application, session, or server scopes, but I'm also interested in finding out about different uses of locking in ColdFusion.
You should use when reading and writing from things that can change in the application scope. For example: ``` <cfquery name="application.myData"> select * from myTable </cfquery> ``` You are going to want to lock that with type="exclusive". Wherever application.myData is used, you need a type="readonly" lock. T...
296,730
<p>I am creating a new table inside mysql and I am trying to add a foreign key constraint to one of the fields.</p> <pre> CREATE TABLE `onlineorder` ( `receiptid` varchar(10) NOT NULL default '', `delivereddate` date default NULL, `cid` int(10) NOT NULL, `card#` int(10) default NULL, `expire` date default NU...
[ { "answer_id": 296754, "author": "activout.se", "author_id": 20444, "author_profile": "https://Stackoverflow.com/users/20444", "pm_score": 3, "selected": false, "text": "<p>You need to use the InnoDB engine to have foreign keys.</p>\n\n<p>Ref: <a href=\"http://dev.mysql.com/doc/refman/5....
2008/11/17
[ "https://Stackoverflow.com/questions/296730", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28462/" ]
I am creating a new table inside mysql and I am trying to add a foreign key constraint to one of the fields. ``` CREATE TABLE `onlineorder` ( `receiptid` varchar(10) NOT NULL default '', `delivereddate` date default NULL, `cid` int(10) NOT NULL, `card#` int(10) default NULL, `expire` date default NULL, PR...
You need to use the InnoDB engine to have foreign keys. Ref: <http://dev.mysql.com/doc/refman/5.0/en/innodb-foreign-key-constraints.html>
296,732
<p>I've been wondering if it's possible to have Fluent-NHibernate communicate with stored procedures that already exist and assign mapping from the result set to my own domain objects.</p> <p>Also is Fluent-NHibernate able to directly execute procedures with no result set returned?</p> <p>Basically I've been consider...
[ { "answer_id": 420491, "author": "Chris Marisic", "author_id": 37055, "author_profile": "https://Stackoverflow.com/users/37055", "pm_score": 4, "selected": false, "text": "<p>Just to answer my own question, the answer is no other than you can write xml mapppings for NHibernate and combin...
2008/11/17
[ "https://Stackoverflow.com/questions/296732", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37055/" ]
I've been wondering if it's possible to have Fluent-NHibernate communicate with stored procedures that already exist and assign mapping from the result set to my own domain objects. Also is Fluent-NHibernate able to directly execute procedures with no result set returned? Basically I've been considering the implicati...
The trunk version of Fluent NHibernate (on GitHub) supports insert, update and delete stored procedures. In your mapping class constructor, call: ``` SqlInsert("StoredProcName"); ``` Disclaimer: I haven't tested this myself yet, but it certainly will come in handy soon. For more info see [this thread](http://group...
296,738
<p>I'd love to know if there is a module to parse "human formatted" dates in Perl. I mean things like "tomorrow", "Tuesday", "next week", "1 hour ago".</p> <p>My research with CPAN suggest that there is no such module, so how would you go about creating one? NLP is way over the top for this.</p>
[ { "answer_id": 296739, "author": "Robert Gamble", "author_id": 25222, "author_profile": "https://Stackoverflow.com/users/25222", "pm_score": 6, "selected": true, "text": "<p><a href=\"http://search.cpan.org/perldoc?Date::Manip\" rel=\"noreferrer\">Date::Manip</a> does exactly this.</p>\n...
2008/11/17
[ "https://Stackoverflow.com/questions/296738", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38346/" ]
I'd love to know if there is a module to parse "human formatted" dates in Perl. I mean things like "tomorrow", "Tuesday", "next week", "1 hour ago". My research with CPAN suggest that there is no such module, so how would you go about creating one? NLP is way over the top for this.
[Date::Manip](http://search.cpan.org/perldoc?Date::Manip) does exactly this. Here is an example program: ``` #!/usr/bin/perl use strict; use Date::Manip; while (<DATA>) { chomp; print UnixDate($_, "%Y-%m-%d %H:%M:%S"), " ($_)\n"; } __DATA__ today yesterday tomorrow last Tuesday next Tuesday 1 hour ago next we...
296,740
<p>I need to populate a context menu from a database at run time. I do not know the number of items that will be in the list, so I would like to handle the click event in a single place. How do I declare the handler so I can tell which menu item actually triggered the click.</p> <pre><code>Public Function GetBookmar...
[ { "answer_id": 296757, "author": "Jon B", "author_id": 27414, "author_profile": "https://Stackoverflow.com/users/27414", "pm_score": 1, "selected": true, "text": "<p>Your ForwardToList_Click() should include parameters for the sender and event args:</p>\n\n<pre><code>Public Sub ForwardTo...
2008/11/17
[ "https://Stackoverflow.com/questions/296740", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38349/" ]
I need to populate a context menu from a database at run time. I do not know the number of items that will be in the list, so I would like to handle the click event in a single place. How do I declare the handler so I can tell which menu item actually triggered the click. ``` Public Function GetBookmarkContextMenu(ByV...
Your ForwardToList\_Click() should include parameters for the sender and event args: ``` Public Sub ForwardToList_Click(sender As Object, e As EventArgs) '... End Sub ``` "sender" is the control that caused the event, which is what I believe you're looking for.
296,747
<p>When I generate a default scaffold, the display tags on show.html.erb have</p> <pre><code>&lt;%=h @broker.name %&gt; </code></pre> <p>I know the difference between <code>&lt;%</code> and <code>&lt;%=</code>. What's the "h" do?</p>
[ { "answer_id": 296751, "author": "JasonTrue", "author_id": 13433, "author_profile": "https://Stackoverflow.com/users/13433", "pm_score": 8, "selected": true, "text": "<p>html escape. It's a method that converts things like &lt; and > into numerical character references so that rendering ...
2008/11/17
[ "https://Stackoverflow.com/questions/296747", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32154/" ]
When I generate a default scaffold, the display tags on show.html.erb have ``` <%=h @broker.name %> ``` I know the difference between `<%` and `<%=`. What's the "h" do?
html escape. It's a method that converts things like < and > into numerical character references so that rendering won't break your html.
296,750
<p>I have a class that has some properties. And I want something that calculates a Score out of these properties. Since this is a trivial task (some additions and divisions, but nothing spectacular).</p> <p>So naturally, the question is: "When to use a Property with some code in the getter, and when to use a function?...
[ { "answer_id": 296761, "author": "jcollum", "author_id": 30946, "author_profile": "https://Stackoverflow.com/users/30946", "pm_score": 2, "selected": false, "text": "<p>Pull up reflector, you'll see that your properties already are methods :)</p>\n" }, { "answer_id": 296777, ...
2008/11/17
[ "https://Stackoverflow.com/questions/296750", "https://Stackoverflow.com", "https://Stackoverflow.com/users/91/" ]
I have a class that has some properties. And I want something that calculates a Score out of these properties. Since this is a trivial task (some additions and divisions, but nothing spectacular). So naturally, the question is: "When to use a Property with some code in the getter, and when to use a function?", and [th...
No. There are no side affects to this at all. > > Pull up reflector, you'll see that > your properties already are methods > > > Under the hood the `get` and `set` accessors in a property are simply converted to `get_MyPropertyName()` and `set_MyPropertyName()` methods. This is also why you can (but typically s...
296,755
<p>The following code fails to compile stating "A local variable named 'st' cannot be declared in this scope because it would give a different meaning to 'st', which is already used in a 'child' scope to denote something else": </p> <pre><code> var l = new List&lt;string&gt;(); l.Find(st =&gt; st.EndsW...
[ { "answer_id": 296780, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 5, "selected": true, "text": "<p>Yes, the compiler is enforcing scope. Note that the scope of a variable is the lexical block it's part of - not just f...
2008/11/17
[ "https://Stackoverflow.com/questions/296755", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26160/" ]
The following code fails to compile stating "A local variable named 'st' cannot be declared in this scope because it would give a different meaning to 'st', which is already used in a 'child' scope to denote something else": ``` var l = new List<string>(); l.Find(st => st.EndsWith("12")); stri...
Yes, the compiler is enforcing scope. Note that the scope of a variable is the lexical block it's part of - not just from the point of declaration onwards, but the whole scope. The compiler is complaining because the assignment to `postParent` is outside its scope (which is only the nested braces). If you tried to de...
296,781
<p>I'm running an SQL query against a mainframe DB2 database using the OdbcDataReader class and ExecuteReader() method. This code is in production and has been running fine for months.</p> <p>The query normally takes 1-2 minutes to execute. This past Friday, the query encountered a ThreadAbortException. Below is the ...
[ { "answer_id": 296847, "author": "Greg D", "author_id": 6932, "author_profile": "https://Stackoverflow.com/users/6932", "pm_score": 0, "selected": false, "text": "<p>It might be possible that your thread was chosen as the victim in a deadlock situation resulting from optimistic locking, ...
2008/11/17
[ "https://Stackoverflow.com/questions/296781", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3106/" ]
I'm running an SQL query against a mainframe DB2 database using the OdbcDataReader class and ExecuteReader() method. This code is in production and has been running fine for months. The query normally takes 1-2 minutes to execute. This past Friday, the query encountered a ThreadAbortException. Below is the formatted s...
Here is the answer to my own question. When hosting a web service, there is some process monitoring how long a web service call is taking. If a call is taking too long, then it is killed and a ThreadAbortException will occur. The timeout can be increased. For a WSE3 web service running outside of ASP.NET, e.g. hosted...
296,792
<p>When I open a file for reading in Haskell, I've found that I can't use the contents of the file after closing it. For example, this program will print the contents of a file:</p> <pre><code>main = do inFile &lt;- openFile "foo" ReadMode contents &lt;- hGetContents inFile putStr contents ...
[ { "answer_id": 296877, "author": "ADEpt", "author_id": 10105, "author_profile": "https://Stackoverflow.com/users/10105", "pm_score": 0, "selected": false, "text": "<p>The explanation is rather long to be included here. Forgive me for dispensing a short tip only: you need to read about \"...
2008/11/17
[ "https://Stackoverflow.com/questions/296792", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1891/" ]
When I open a file for reading in Haskell, I've found that I can't use the contents of the file after closing it. For example, this program will print the contents of a file: ``` main = do inFile <- openFile "foo" ReadMode contents <- hGetContents inFile putStr contents hClose inFile ```...
As others have stated, it is because of lazy evaluation. The handle is half-closed after this operation, and will be closed automatically when all data is read. Both hGetContents and readFile are lazy in this way. In cases where you're having issues with handles being kept open, typically you just force the read. Here'...
296,795
<p>I've got a Subversion repository, and there are a number of users checking things in and out. However, I also need to frequently check in work for other people. I need to track the original author of the work.</p> <p>I was considering creating a property in SVN, like "originalauthor", which could track this. In ...
[ { "answer_id": 296812, "author": "Tim", "author_id": 10755, "author_profile": "https://Stackoverflow.com/users/10755", "pm_score": 0, "selected": false, "text": "<p>Why not have a separate branch for all the other users (who need proxies) and then when you review them (I assume you check...
2008/11/17
[ "https://Stackoverflow.com/questions/296795", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9161/" ]
I've got a Subversion repository, and there are a number of users checking things in and out. However, I also need to frequently check in work for other people. I need to track the original author of the work. I was considering creating a property in SVN, like "originalauthor", which could track this. In cases where i...
Subversion has two kinds of properties * Properties on a file or directory. These properties are versioned * Revision properties. These are specific to the reversion on which they apply. The first type is only usefull if you want all versions of the file to be marked. To mark a specific path the Subversion project i...
296,797
<p>Since you guys are having lots of questions or not enough info to work with, below is proprietary information and as such be careful as you can. The question – (please refer to if [$7 -eq "AAA"]...then statement - in bold ) has a problem with an output, where I can only output/print count of 'AAA' regardless the v...
[ { "answer_id": 296905, "author": "ADEpt", "author_id": 10105, "author_profile": "https://Stackoverflow.com/users/10105", "pm_score": 2, "selected": false, "text": "<p>Anything between \"sqlplus -s $1 &lt;&lt; EOF\" and \"EOF\" is called \"here-doc\" and intended for consumption by sqlplu...
2008/11/17
[ "https://Stackoverflow.com/questions/296797", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Since you guys are having lots of questions or not enough info to work with, below is proprietary information and as such be careful as you can. The question – (please refer to if [$7 -eq "AAA"]...then statement - in bold ) has a problem with an output, where I can only output/print count of 'AAA' regardless the variab...
Anything between "sqlplus -s $1 << EOF" and "EOF" is called "here-doc" and intended for consumption by sqlplus. You can't really expect sqlplus to understand shell scripting in the form of "if [ "$7" -eq ....] ". You should make all "ifs" outside of the here-doc and use results in it. Like this: ``` if [ "$7" -eq "AA...
296,799
<p>How can I get the name of a file in in PHP? What I want to do is have a function take a string of a filename and then do some stuff if it's actually on the page.</p> <pre><code>function onThisPageFunction(fileNameFromFunction) { if(onThisPage == fileNameFromFunction) { do stuff } } </code></...
[ { "answer_id": 296813, "author": "activout.se", "author_id": 20444, "author_profile": "https://Stackoverflow.com/users/20444", "pm_score": 2, "selected": false, "text": "<p>If I understand correctly you want <code>__FILE__</code>.</p>\n\n<p>Ref: <a href=\"http://php.net/manual/en/languag...
2008/11/17
[ "https://Stackoverflow.com/questions/296799", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28672/" ]
How can I get the name of a file in in PHP? What I want to do is have a function take a string of a filename and then do some stuff if it's actually on the page. ``` function onThisPageFunction(fileNameFromFunction) { if(onThisPage == fileNameFromFunction) { do stuff } } ```
There are two variables that will give you file names. eg: you call /test/test1.php as the url and test1.php includes test2.php. [`__FILE__`](http://pl.php.net/manual/en/language.constants.predefined.php) will give you the current file of the executing code, in this case it will return "test2.php" [`$_SERVER['PHP_SE...
296,834
<p>Suppose I have three classes. It is valid to instantiate A, but there are also special cases B and D which subclass A, adding additional information.</p> <p>How would I do the mapping files for this in (fluent) NHibernate?</p> <pre><code>public class A { public int ID { get; set;} public string CommonProp...
[ { "answer_id": 298329, "author": "Erik Öjebo", "author_id": 276, "author_profile": "https://Stackoverflow.com/users/276", "pm_score": 4, "selected": true, "text": "<p>I'm not sure I understand what you mean by \"map a subclass one-to-one\", but if you want to map inheritance where the su...
2008/11/17
[ "https://Stackoverflow.com/questions/296834", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24954/" ]
Suppose I have three classes. It is valid to instantiate A, but there are also special cases B and D which subclass A, adding additional information. How would I do the mapping files for this in (fluent) NHibernate? ``` public class A { public int ID { get; set;} public string CommonProperty1 { get; set; } ...
I'm not sure I understand what you mean by "map a subclass one-to-one", but if you want to map inheritance where the subclasses have properties that are not nullable, you can do like this in Fluent-NHibernate: ``` // Domain classes public class Animal { public virtual int Id { get; set; } public virtual string...
296,842
<p>Given an amount of days, say 25, convert it into a duration text such as "3 Weeks, 4 Days"</p> <p>C# and F# solutions would both be great if the F# variation offers any improvement over C#.</p> <p>Edit: The solution should expand past weeks to include months and years. Bonus points for including centuries and so o...
[ { "answer_id": 296852, "author": "Gavin Miller", "author_id": 33226, "author_profile": "https://Stackoverflow.com/users/33226", "pm_score": 3, "selected": false, "text": "<pre><code>String.Format(\"{0} Weeks, {1} days\", days / 7, days % 7);\n</code></pre>\n" }, { "answer_id": 29...
2008/11/17
[ "https://Stackoverflow.com/questions/296842", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45/" ]
Given an amount of days, say 25, convert it into a duration text such as "3 Weeks, 4 Days" C# and F# solutions would both be great if the F# variation offers any improvement over C#. Edit: The solution should expand past weeks to include months and years. Bonus points for including centuries and so on. Extra bonus if...
This is a recursive solution. Note that a duration only really makes sense measured against a particular point in time on a given calendar because month and year lengths vary. But here is a simple solution assuming fixed lengths: ``` let divmod n m = n / m, n % m let units = [ ("Centuries", TimeSpan.TicksPerD...
296,861
<p>In ActionScript, how can you test if an object is defined, that is, not null?</p>
[ { "answer_id": 296870, "author": "Herms", "author_id": 1409, "author_profile": "https://Stackoverflow.com/users/1409", "pm_score": 2, "selected": false, "text": "<p>Just test it against null.</p>\n\n<pre><code>var someObj:Object = getSomeObjectOrMaybeNull();\nif(someObj == null) {\n tra...
2008/11/17
[ "https://Stackoverflow.com/questions/296861", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3858/" ]
In ActionScript, how can you test if an object is defined, that is, not null?
> > **test if an object is defined** > > > This works in AS2 and AS3, and is the most reliable way to test if an object has a value. ``` if (obj != null) { doSomethingWith(obj); } ``` Its also the most reliable way to test an object's property and read it in the same expression: ``` if (arr[0] != null && a...
296,873
<p>Lets say I am currently at: <code>http://example.com/folder/page.html</code></p> <p>Is it possible to create a relative link on this page that points to <code>http://example.com/folder/</code> without specifying <code>folder</code> anywhere? (And using only HTML.)</p> <p><strong>UPDATE:</strong> <strong>As it turn...
[ { "answer_id": 296875, "author": "bdukes", "author_id": 2688, "author_profile": "https://Stackoverflow.com/users/2688", "pm_score": 2, "selected": false, "text": "<p>Both of the below seem to work</p>\n\n<p>./</p>\n\n<p>.</p>\n" }, { "answer_id": 296881, "author": "Bullines",...
2008/11/17
[ "https://Stackoverflow.com/questions/296873", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20128/" ]
Lets say I am currently at: `http://example.com/folder/page.html` Is it possible to create a relative link on this page that points to `http://example.com/folder/` without specifying `folder` anywhere? (And using only HTML.) **UPDATE:** **As it turned out `./` works only in non-strict doctype mode, while `.` works in...
Just dot is working. The doctype makes a difference however as sometimes the ./ is fine as well. ``` <a href=".">Link to this folder</a> ```
296,904
<p>My data is such that I want to display values for the Employee and the Supervisor for a particular record. Instead of describing it, I'll show you a rough example:</p> <pre><code>&lt;table&gt;&lt;tr&gt; &lt;th colspan="3"&gt;Employee&lt;/th&gt; &lt;th colspan="3"&gt;Supervisor&lt;/th&gt; &lt;/tr&gt;&lt;tr&gt; &lt;t...
[ { "answer_id": 403722, "author": "Glen Solsberry", "author_id": 16645, "author_profile": "https://Stackoverflow.com/users/16645", "pm_score": 3, "selected": false, "text": "<p>This is probably happening because you're trying to index too many items at once. Make sure you're using <a hre...
2008/11/17
[ "https://Stackoverflow.com/questions/296904", "https://Stackoverflow.com", "https://Stackoverflow.com/users/337/" ]
My data is such that I want to display values for the Employee and the Supervisor for a particular record. Instead of describing it, I'll show you a rough example: ``` <table><tr> <th colspan="3">Employee</th> <th colspan="3">Supervisor</th> </tr><tr> <th>Name</th> <th>Last Activity</th> <th>Count</th> <th>Name</th> <...
This is probably happening because you're trying to index too many items at once. Make sure you're using [ranged queries](http://www.sphinxsearch.com/docs/current.html#conf-sql-query-range). If you're already using ranged queries, increasing the `mem_limit`, as it suggests, may help. The `merge_block_size` is based on ...
296,910
<p>I want to have an executable file that will call some other programs. The way I would do this in Linux is with a simple bash script that looks like this:</p> <pre><code>#!/bin/bash echo "running some-program" /home/murat/some-program arg1 arg2 </code></pre> <p>What's the best way to do this kind of thing under Win...
[ { "answer_id": 296915, "author": "Tim", "author_id": 10755, "author_profile": "https://Stackoverflow.com/users/10755", "pm_score": 2, "selected": false, "text": "<p>batch files work for me. Just remove the first line in your example and it should work the same in win32 cmd line.</p>\n\n...
2008/11/17
[ "https://Stackoverflow.com/questions/296910", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25910/" ]
I want to have an executable file that will call some other programs. The way I would do this in Linux is with a simple bash script that looks like this: ``` #!/bin/bash echo "running some-program" /home/murat/some-program arg1 arg2 ``` What's the best way to do this kind of thing under Windows?
Take a look at [PowerShell](http://www.microsoft.com/downloads/details.aspx?familyid=C6EF4735-C7DE-46A2-997A-EA58FDFCBA63&displaylang=en), which is the closest you will get to a true scripting language like you have in Unix. Other than that, for simple things such as simply runnning an application, take a look at Windo...
296,913
<p>I am looking to write a function like </p> <pre><code>ref String TestIt( int index ) { return this.TestArray[index]; }; </code></pre> <p>so that I could write code like:</p> <pre><code>MyClass.TestIt(0) = "Hello World"; </code></pre> <p>My goal is to mimic this c++ declaration</p> <pre><code>CString&amp; MyClas...
[ { "answer_id": 296936, "author": "Jeff Kotula", "author_id": 1382162, "author_profile": "https://Stackoverflow.com/users/1382162", "pm_score": 0, "selected": false, "text": "<p>You don't need to return a reference to achieve your goal. String types are reference types but has special han...
2008/11/17
[ "https://Stackoverflow.com/questions/296913", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5618/" ]
I am looking to write a function like ``` ref String TestIt( int index ) { return this.TestArray[index]; }; ``` so that I could write code like: ``` MyClass.TestIt(0) = "Hello World"; ``` My goal is to mimic this c++ declaration ``` CString& MyClass::Data( UINT index); ``` By Reference I am referring to the c...
To do this you need to write a setter property. Unfortunately, setters can’t take further arguments in C# so you won't be able to write this code 1:1 in C#. The closest you can get is a nested class with a default property: ``` class YourClass { public class Nested { public Nested(YourClass outer) { m_RefT...
296,952
<p>How can I prevent the image tag that calls the associated image from displaying if no image is associated with the record?</p> <pre><code>&lt;%= image_tag @agent.avatar.url %&gt; </code></pre> <p>...gives me the text "Missing" if there is no image associated with that agent. I want to test to see there is an imag...
[ { "answer_id": 296990, "author": "neezer", "author_id": 32154, "author_profile": "https://Stackoverflow.com/users/32154", "pm_score": 5, "selected": false, "text": "<p>Okay, so I got one part of it.</p>\n\n<p>Specifying a default image happens in the model</p>\n\n<pre><code>has_attached_...
2008/11/17
[ "https://Stackoverflow.com/questions/296952", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32154/" ]
How can I prevent the image tag that calls the associated image from displaying if no image is associated with the record? ``` <%= image_tag @agent.avatar.url %> ``` ...gives me the text "Missing" if there is no image associated with that agent. I want to test to see there is an image available first, then render th...
I use the following to find wether a model has an associated attachment: ``` <% if @agent.avatar.file? %> <%= image_tag @agent.avatar.url(:normal) %> <% else %> No attachment available! <% end %> ```
296,964
<p>What could the following line possibly mean?</p> <pre><code>my $x = shift; </code></pre>
[ { "answer_id": 296969, "author": "David Nehme", "author_id": 14167, "author_profile": "https://Stackoverflow.com/users/14167", "pm_score": 2, "selected": false, "text": "<p>This is usually an idiom for: $x is a local variable assigned to the first parameter passed to the subroutine, alth...
2008/11/17
[ "https://Stackoverflow.com/questions/296964", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
What could the following line possibly mean? ``` my $x = shift; ```
`shift()` is a built in Perl subroutine that takes an array as an argument, then returns and deletes the first item in that array. It is common practice to obtain all parameters passed into a subroutine with `shift` calls. For example, say you have a subroutine `foo` that takes three arguments. One way to get these par...
296,967
<p>I'm wondering where the callbacks are (or if there are anything) for animations in a CALayer. Specifically, for implied animations like altering the frame, position, etc. In a UIView, you could do something like this:</p> <pre><code>[UIView beginAnimations:@"SlideOut" context:nil]; [UIView setAnimationDuration:.3];...
[ { "answer_id": 297045, "author": "Jeffrey Forbes", "author_id": 28019, "author_profile": "https://Stackoverflow.com/users/28019", "pm_score": 7, "selected": true, "text": "<p>I answered my own question. You have to add an animation using <code>CABasicAnimation</code> like so:</p>\n\n<pre...
2008/11/17
[ "https://Stackoverflow.com/questions/296967", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28019/" ]
I'm wondering where the callbacks are (or if there are anything) for animations in a CALayer. Specifically, for implied animations like altering the frame, position, etc. In a UIView, you could do something like this: ``` [UIView beginAnimations:@"SlideOut" context:nil]; [UIView setAnimationDuration:.3]; [UIView setAn...
I answered my own question. You have to add an animation using `CABasicAnimation` like so: ``` CABasicAnimation* anim = [CABasicAnimation animationWithKeyPath:@"frame"]; anim.fromValue = [NSValue valueWithCGRect:layer.frame]; anim.toValue = [NSValue valueWithCGRect:frame]; anim.delegate = self; [layer addAnimation:ani...
296,971
<p>The section <strong>Last links in the chain: Stashing and the reflog</strong> in <a href="http://ftp.newartisans.com/pub/git.from.bottom.up.pdf" rel="noreferrer">http://ftp.newartisans.com/pub/git.from.bottom.up.pdf</a> recommends stashing often to take snapshots of your work in progress. The author goes as far as...
[ { "answer_id": 297036, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 5, "selected": true, "text": "<p>I certainly wouldn't set up automatic stashing as described in that (otherwise excellent) article, for exactly the reas...
2008/11/17
[ "https://Stackoverflow.com/questions/296971", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4883/" ]
The section **Last links in the chain: Stashing and the reflog** in <http://ftp.newartisans.com/pub/git.from.bottom.up.pdf> recommends stashing often to take snapshots of your work in progress. The author goes as far as recommending that you can use a cron job to stash your work regularly, without having to do a stash ...
I certainly wouldn't set up automatic stashing as described in that (otherwise excellent) article, for exactly the reasons you cite. I prefer to use the stash as it is intended to be used, where I deliberately stash and apply changes as I'm working. For periodic backups, I use a proper backup solution. In my opinion, ...
296,975
<p>I'm using <code>git-svn</code> to work against my company's central Subversion repository. We've recently created a new feature branch in the central repo. </p> <p>How do I tell Git about it? When I run <code>git branch -r</code> I can only see the branches that existed when I ran <code>fetch</code> against the Sub...
[ { "answer_id": 297000, "author": "Hank Gay", "author_id": 4203, "author_profile": "https://Stackoverflow.com/users/4203", "pm_score": 6, "selected": false, "text": "<p>It appears I just needed to <code>git svn fetch</code>; somehow I had convinced myself that would fetch the entire repo ...
2008/11/17
[ "https://Stackoverflow.com/questions/296975", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4203/" ]
I'm using `git-svn` to work against my company's central Subversion repository. We've recently created a new feature branch in the central repo. How do I tell Git about it? When I run `git branch -r` I can only see the branches that existed when I ran `fetch` against the Subversion repo to initialize my Git repo?
You can manually add the remote branch, ``` git config --add svn-remote.newbranch.url https://svn/path_to_newbranch/ git config --add svn-remote.newbranch.fetch :refs/remotes/newbranch git svn fetch newbranch [-r<rev>] git checkout -b local-newbranch -t newbranch git svn rebase newbranch ```
296,978
<p>I've got a small piece of code that is parsing an index value to determine a cell input into Excel. It's got me thinking...</p> <p>What's the difference between </p> <pre><code>xlsSheet.Write("C" + rowIndex.ToString(), null, title); </code></pre> <p>and</p> <pre><code>xlsSheet.Write(string.Format("C{0}", rowInd...
[ { "answer_id": 296985, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 8, "selected": true, "text": "<p><strong>Before C# 6</strong></p>\n\n<p>To be honest, I think the first version is simpler - although I'd simplify it t...
2008/11/17
[ "https://Stackoverflow.com/questions/296978", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33226/" ]
I've got a small piece of code that is parsing an index value to determine a cell input into Excel. It's got me thinking... What's the difference between ``` xlsSheet.Write("C" + rowIndex.ToString(), null, title); ``` and ``` xlsSheet.Write(string.Format("C{0}", rowIndex), null, title); ``` Is one "better" than...
**Before C# 6** To be honest, I think the first version is simpler - although I'd simplify it to: ``` xlsSheet.Write("C" + rowIndex, null, title); ``` I suspect other answers *may* talk about the performance hit, but to be honest it'll be minimal *if present at all* - and this concatenation version doesn't need to ...
296,981
<p>Could someone show me a regular expression that would look through this document and select the href value of every href that has <code>RELATION_ID</code> on the end of it? Then if it does, I have to get the Id that is before the question mark (example <code>href="dctm://ISDOFSDdev/</code>37004e1f800021f3<code>?DMS_...
[ { "answer_id": 296997, "author": "sblundy", "author_id": 4893, "author_profile": "https://Stackoverflow.com/users/4893", "pm_score": 1, "selected": false, "text": "<p>Something like: <code>href=\".*/([^\"?/]*)?[^\"]*RELATION_ID[^\"]*\"</code>. This assumes you're being consistent in usin...
2008/11/17
[ "https://Stackoverflow.com/questions/296981", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5653/" ]
Could someone show me a regular expression that would look through this document and select the href value of every href that has `RELATION_ID` on the end of it? Then if it does, I have to get the Id that is before the question mark (example `href="dctm://ISDOFSDdev/`37004e1f800021f3`?DMS_OBJECT_SPEC=RELATION_ID`") Th...
You can use this regex expression: ``` [a-fA-F0-9]+(?=\?DMS_OBJECT_SPEC=RELATION_ID) ``` which matches the the hex number immediately before the query string. I'd also suggest using XPath to do this over regex.
297,010
<p>Current, I've got a stored procedure that has a main goal of doing a full text search through a database table of films and tv shows. In order to get it to do partial-keyword searching, I added some code in SQL to split up the search query by spaces, and output a statement like the following:</p> <p><code>"batman*...
[ { "answer_id": 298966, "author": "Carl", "author_id": 38375, "author_profile": "https://Stackoverflow.com/users/38375", "pm_score": 2, "selected": true, "text": "<p>After some more researching, I'm going to try and use Lucene.Net for my movie-title search engine, and not rely on Full-Tex...
2008/11/17
[ "https://Stackoverflow.com/questions/297010", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38375/" ]
Current, I've got a stored procedure that has a main goal of doing a full text search through a database table of films and tv shows. In order to get it to do partial-keyword searching, I added some code in SQL to split up the search query by spaces, and output a statement like the following: `"batman*" ~ "be*"` The ...
After some more researching, I'm going to try and use Lucene.Net for my movie-title search engine, and not rely on Full-Text Searching in SQL Server 2005. Early testing shows that the results have been better and more relevant with Lucene. A search for "batman" returns the following partial result-set: * Batman * Batm...
297,029
<p>How to get file name and revision number as a list starting from a designated folder?</p>
[ { "answer_id": 298196, "author": "Oliver Giesen", "author_id": 9784, "author_profile": "https://Stackoverflow.com/users/9784", "pm_score": 0, "selected": false, "text": "<p><code>cvs status</code> will give you that information in the following form per file:</p>\n\n<pre><code>==========...
2008/11/17
[ "https://Stackoverflow.com/questions/297029", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How to get file name and revision number as a list starting from a designated folder?
You can use `cvs status` at the base folder of your project and grep for the appropriate line: ``` > cvs status | grep Repository\ revision\: Repository revision: 1.16 /cvsroot/module/.cvsignore,v Repository revision: 1.1.1.1 /cvsroot/module/build.sh,v Repository revision: 1.251 /cvsroot/module/build.xml,v Reposi...
297,034
<p>In <a href="https://stackoverflow.com/questions/204467/is-there-a-perl-function-to-turn-a-string-into-a-regexp-to-use-that-string-as-p">another Stack&nbsp;Overflow question</a> <a href="https://stackoverflow.com/users/4727/leon-timmermans">Leon Timmermans</a> asserted:</p> <blockquote> <p>I would advice you not t...
[ { "answer_id": 297095, "author": "cjm", "author_id": 8355, "author_profile": "https://Stackoverflow.com/users/8355", "pm_score": 6, "selected": false, "text": "<p>The problem is that Perl's function prototypes don't do what people think they do. Their purpose is to allow you to write fu...
2008/11/17
[ "https://Stackoverflow.com/questions/297034", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6782/" ]
In [another Stack Overflow question](https://stackoverflow.com/questions/204467/is-there-a-perl-function-to-turn-a-string-into-a-regexp-to-use-that-string-as-p) [Leon Timmermans](https://stackoverflow.com/users/4727/leon-timmermans) asserted: > > I would advice you not to use prototypes. They have their uses, but not...
Prototypes aren't bad if used correctly. The difficulty is that Perl's prototypes don't work the way people often expect them to. People with a background in other programming languages tend to expect prototypes to provide a mechanism for checking that function calls are correct: that is, that they have the right numbe...
297,035
<p>I am currently faced with a difficult sorting problem. I have a collection of events that need to be sorted against each other (a <a href="http://en.wikipedia.org/wiki/Comparison_sort" rel="nofollow noreferrer">comparison sort</a>) and against their relative position in the list.</p> <p>In the simplest terms I have...
[ { "answer_id": 297053, "author": "jakber", "author_id": 29812, "author_profile": "https://Stackoverflow.com/users/29812", "pm_score": 0, "selected": false, "text": "<p>I think you should sort the list twice: first by priority and then by earliest time, using any <strong>stable</strong> s...
2008/11/17
[ "https://Stackoverflow.com/questions/297035", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11889/" ]
I am currently faced with a difficult sorting problem. I have a collection of events that need to be sorted against each other (a [comparison sort](http://en.wikipedia.org/wiki/Comparison_sort)) and against their relative position in the list. In the simplest terms I have list of events that each have a priority (inte...
This is actually more than a sorting problem. It's a single-machine scheduling problem with release dates. Depending on what you are trying to do, the problem might be NP-Hard. For example, if you are trying to mimimize the weighted-sum of the completion times (the weight being inversely proportional to the priority), ...
297,063
<p>I'm still trying to get my head around using Java's generics. I have no problems at all with using typed collections, but much of the rest of it just seems to escape me.</p> <p>Right now I'm trying to use the JUnit "PrivateAccessor", which requires a Class[] argument with a list of all the argument types for the p...
[ { "answer_id": 297138, "author": "erickson", "author_id": 3474, "author_profile": "https://Stackoverflow.com/users/3474", "pm_score": 2, "selected": false, "text": "<p>This is the correct syntax:</p>\n\n<pre><code>Class&lt;?&gt;[] paramTypes = new Class[]{ Collection.class, ArrayList.cla...
2008/11/17
[ "https://Stackoverflow.com/questions/297063", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3333/" ]
I'm still trying to get my head around using Java's generics. I have no problems at all with using typed collections, but much of the rest of it just seems to escape me. Right now I'm trying to use the JUnit "PrivateAccessor", which requires a Class[] argument with a list of all the argument types for the private meth...
The first problem you have is that you should be using ``` Class<?>[] args = new Class[] ``` instead of ``` Class<? extends Object>[] args = new Class<? extends Object>[] ``` [This](http://www.angelikalanger.com/GenericsFAQ/FAQSections/ParameterizedTypes.html#FAQ104) explains why. Your second problem is that you...
297,064
<p>This one has me beat;</p> <p>I have a WPF window with two (important for this case) controls, both from the WPF toolkit available at CodePlex; A DatePicker and a DataGrid.</p> <p>The DataContext of this window is set to a CLR object that has all the information it needs. This CLR object has a large list of data, a...
[ { "answer_id": 297186, "author": "Sacha Bruttin", "author_id": 20761, "author_profile": "https://Stackoverflow.com/users/20761", "pm_score": 1, "selected": false, "text": "<p>You could set up a OneWayToSource binding on the DatePicker.SelectedDate property which pushes the text value int...
2008/11/17
[ "https://Stackoverflow.com/questions/297064", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2122/" ]
This one has me beat; I have a WPF window with two (important for this case) controls, both from the WPF toolkit available at CodePlex; A DatePicker and a DataGrid. The DataContext of this window is set to a CLR object that has all the information it needs. This CLR object has a large list of data, and a method calle...
Here is my complete code. I hope this will help. The xaml code: ``` <Window x:Class="DataGridSort.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:dg="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit" xm...
297,068
<p>Normally, the method of passing workflow parameters to the workflow happens in the call to RunWorkflow. However, with the WorkflowServiceHost, there is no such method call involved. You simply call the Open() method on the instance. Any ideas?</p> <p>Of course, the implication is that I add more parameters to th...
[ { "answer_id": 297186, "author": "Sacha Bruttin", "author_id": 20761, "author_profile": "https://Stackoverflow.com/users/20761", "pm_score": 1, "selected": false, "text": "<p>You could set up a OneWayToSource binding on the DatePicker.SelectedDate property which pushes the text value int...
2008/11/17
[ "https://Stackoverflow.com/questions/297068", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5573/" ]
Normally, the method of passing workflow parameters to the workflow happens in the call to RunWorkflow. However, with the WorkflowServiceHost, there is no such method call involved. You simply call the Open() method on the instance. Any ideas? Of course, the implication is that I add more parameters to the service con...
Here is my complete code. I hope this will help. The xaml code: ``` <Window x:Class="DataGridSort.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:dg="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit" xm...
297,070
<p>I'm looking for Java code that can be used to generate sound at runtime - NOT playback of existing sound files.</p> <p>For example, what's the best code for generating a sawtooth waveform at 440 Hz for a duration of 2 milliseconds? <b>Source code appreciated!</b></p> <p>I remember my Commodore 128 had a simple Sou...
[ { "answer_id": 297163, "author": "Stein G. Strindhaug", "author_id": 26115, "author_profile": "https://Stackoverflow.com/users/26115", "pm_score": 0, "selected": false, "text": "<p>What you want is probably not a sound API but some kind of synthesizer code, I'm pretty sure you need more ...
2008/11/17
[ "https://Stackoverflow.com/questions/297070", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2197/" ]
I'm looking for Java code that can be used to generate sound at runtime - NOT playback of existing sound files. For example, what's the best code for generating a sawtooth waveform at 440 Hz for a duration of 2 milliseconds? **Source code appreciated!** I remember my Commodore 128 had a simple Sound command that took...
You can easily generate sampled sound data in Java and play it back without using native code. If you're talking MIDI things may get tricky, but I've not dabbled in that area. To generate sampled sound data, you have to thing of the process backwards. We're going to act like the A-to-D and sample a continuous sound fu...
297,081
<p>I am trying to RegisterClientScriptBlock in a method that is only called via an AJAX call. It doesn't appear to actually register the script on the page and I'm guessing this is because it's not actually reloading the entire page. Is there any way to register javascript on a page from within an ajax method call?</...
[ { "answer_id": 297210, "author": "Mitchel Sellers", "author_id": 13279, "author_profile": "https://Stackoverflow.com/users/13279", "pm_score": 0, "selected": false, "text": "<p>As far as I know for this you would be forced to be calling this method via a PostBack and not an ajax call. T...
2008/11/17
[ "https://Stackoverflow.com/questions/297081", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24908/" ]
I am trying to RegisterClientScriptBlock in a method that is only called via an AJAX call. It doesn't appear to actually register the script on the page and I'm guessing this is because it's not actually reloading the entire page. Is there any way to register javascript on a page from within an ajax method call? ``` ...
With AJAX enabled pages, you should use the ScriptManager to register scripts: ``` ScriptManager.RegisterClientScriptBlock(Page, typeof(MyPage), "MyScript", "GoStuff()", true) ``` You can use this to register all your scripts (Original load, postback, AJAX postback).
297,111
<p>Can anyone point me to an example of how to use ServletUnit to test JSP's? Do I need I need to call registerServlet()? If so, what class name do I pass?</p>
[ { "answer_id": 1798413, "author": "user142435", "author_id": 142435, "author_profile": "https://Stackoverflow.com/users/142435", "pm_score": 3, "selected": true, "text": "<p>You do not need to registerServlet if you are going use the default Jasper compiler. However, I needed Jasper jars...
2008/11/17
[ "https://Stackoverflow.com/questions/297111", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38226/" ]
Can anyone point me to an example of how to use ServletUnit to test JSP's? Do I need I need to call registerServlet()? If so, what class name do I pass?
You do not need to registerServlet if you are going use the default Jasper compiler. However, I needed Jasper jars and their dependencies on the CLASSPATH. The Maven dependencies I needed to get a basic JSP to compile and render were: ``` <dependency> <groupId>tomcat</groupId> <artifactId>jasper</artifactId> <ve...
297,119
<p>I've struggled for the last couple of months to come up with some clean code to report progress to a user. Everything always seems to boil down to:</p> <pre><code>ReportProgress("Starting Task 1"); doTask1(); ReportProgress("Task 1 is done"); ReportProgress("Starting Task 2"); doTask2(); ReportProgress("Task 2 is...
[ { "answer_id": 297143, "author": "toolkit", "author_id": 3295, "author_profile": "https://Stackoverflow.com/users/3295", "pm_score": 2, "selected": false, "text": "<p>Could you perhaps use <a href=\"http://en.wikipedia.org/wiki/Aspect-oriented_programming\" rel=\"nofollow noreferrer\">As...
2008/11/17
[ "https://Stackoverflow.com/questions/297119", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33226/" ]
I've struggled for the last couple of months to come up with some clean code to report progress to a user. Everything always seems to boil down to: ``` ReportProgress("Starting Task 1"); doTask1(); ReportProgress("Task 1 is done"); ReportProgress("Starting Task 2"); doTask2(); ReportProgress("Task 2 is done"); //etc...
set up your tasks as an event stream, and have the event-processing 'engine' report progress. Each event instance can have its own name, progress-reporting blurb/template, etc. if you want to go that far if this is a pattern that occurs often, it is worth the effort for the infrastructure. When you're done, the usable...
297,121
<p>I have a section on my ASP.net web.config for the Enterprise library logging block. Is it possible to separate the logging configuration into another configuration file? How do I do that?</p>
[ { "answer_id": 297143, "author": "toolkit", "author_id": 3295, "author_profile": "https://Stackoverflow.com/users/3295", "pm_score": 2, "selected": false, "text": "<p>Could you perhaps use <a href=\"http://en.wikipedia.org/wiki/Aspect-oriented_programming\" rel=\"nofollow noreferrer\">As...
2008/11/17
[ "https://Stackoverflow.com/questions/297121", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28647/" ]
I have a section on my ASP.net web.config for the Enterprise library logging block. Is it possible to separate the logging configuration into another configuration file? How do I do that?
set up your tasks as an event stream, and have the event-processing 'engine' report progress. Each event instance can have its own name, progress-reporting blurb/template, etc. if you want to go that far if this is a pattern that occurs often, it is worth the effort for the infrastructure. When you're done, the usable...
297,134
<p>I have a folder "FolderA" which contains three sub-folders: foldera1 foldera2 and foldera3</p> <p>I need to write a batch file which resides inside "FolderA". It should delete all the folders under "FolderA" as a cleanup activity. I don't know the folder names. <code>rmdir</code> does not support wild cards.</p> <...
[ { "answer_id": 297152, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 4, "selected": true, "text": "<p>something like :</p>\n\n<pre><code>for /f %%a in ('dir /ad /b') do (rmdir /S /Q \"%%a\")\nfor /d %%a in (*) do (rmdir /S /Q \...
2008/11/17
[ "https://Stackoverflow.com/questions/297134", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32670/" ]
I have a folder "FolderA" which contains three sub-folders: foldera1 foldera2 and foldera3 I need to write a batch file which resides inside "FolderA". It should delete all the folders under "FolderA" as a cleanup activity. I don't know the folder names. `rmdir` does not support wild cards. Could someone provide a so...
something like : ``` for /f %%a in ('dir /ad /b') do (rmdir /S /Q "%%a") for /d %%a in (*) do (rmdir /S /Q "%%a") ``` should do the trick. The second form allow some wildcard selection for directories. To test it outside a script, in a plain DOS session: ``` for /f %a in ('dir /ad /b') do (rmdir /S /Q "%a") for /d...
297,136
<p>Is there a way to prompt the user for input during a NAnt build? I want to execute a command that takes a password, but I don't want to put the password into the build script.</p>
[ { "answer_id": 297177, "author": "Jonas Kongslund", "author_id": 37548, "author_profile": "https://Stackoverflow.com/users/37548", "pm_score": 3, "selected": false, "text": "<p>A solution I have used many times is to have a <em>local</em> config file containing such things as passwords, ...
2008/11/17
[ "https://Stackoverflow.com/questions/297136", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4794/" ]
Is there a way to prompt the user for input during a NAnt build? I want to execute a command that takes a password, but I don't want to put the password into the build script.
I'm using a script for now, but I'd love to hear if there's a prebuilt method already available. Many thanks to sundar for the ForegroundColor trick. I'm not sure if it matters whether you use Project.Log or go direct to Console.WriteLine(), any NAnt ninjas want to educate me? Here's the script and a sample target th...
297,162
<p>I have a project consisting of two files, main.c and logoff.c. When I try to compile them I get this error:</p> <pre><code>gcc -c -g -Wall main.c gcc -c -g -Wall logoff.c gcc -o main -g -Wall main.o logoff.o ld: duplicate symbol _logoff in logoff.o and main.o</code></pre> <p>I have a function named logoff in logo...
[ { "answer_id": 297197, "author": "Joel Martinez", "author_id": 5416, "author_profile": "https://Stackoverflow.com/users/5416", "pm_score": 2, "selected": false, "text": "<p>Make the different panels all be client side ... all in the same form ... and when the final submit button is press...
2008/11/17
[ "https://Stackoverflow.com/questions/297162", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18091/" ]
I have a project consisting of two files, main.c and logoff.c. When I try to compile them I get this error: ``` gcc -c -g -Wall main.c gcc -c -g -Wall logoff.c gcc -o main -g -Wall main.o logoff.o ld: duplicate symbol _logoff in logoff.o and main.o ``` I have a function named logoff in logoff.c, but I have searched m...
I don't believe there is a best/correct way, but the way I'd do it is... Each wizard gets its own page. Each step gets its own div. All steps are in the same form. The previous/next buttons would essentially hide/show the div in each step of the process. The last step's submit button submits the entire form. It would...
297,205
<p>I have a field (say, foo) in a table in a SQL Server database that was originally defined as nullable, but new requirements indicate that this field must be non-null.</p> <p>What's the best way of updating this field to non-null via an update script without deleting the contents of the table? I tried generating a ...
[ { "answer_id": 297221, "author": "Rockcoder", "author_id": 5290, "author_profile": "https://Stackoverflow.com/users/5290", "pm_score": 0, "selected": false, "text": "<p>You can set a default value to the not-nullable field. If you want to change it from nullable to not-nullable you must ...
2008/11/17
[ "https://Stackoverflow.com/questions/297205", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5563/" ]
I have a field (say, foo) in a table in a SQL Server database that was originally defined as nullable, but new requirements indicate that this field must be non-null. What's the best way of updating this field to non-null via an update script without deleting the contents of the table? I tried generating a script from...
You've got to set a value to any rows with `NULL` in the `NULL`able column before you change it to `NOT NULL`. ``` -- Clean up the data which won't comply with the schema changes UPDATE t SET foo = 0 WHERE foo IS NULL -- Apply the NOT NULL ALTER TABLE t ALTER COLUMN foo int NOT NULL -- Add a default for the future i...
297,206
<p>I have a simple page that displays a user's email addresses in a table. I also have a textbox underneath the table and an "add" button. Currently, I am using a simple form post that is handled by a controller that will add the e-mail address to the database and reload the page. This works fine, but I'm looking to...
[ { "answer_id": 297259, "author": "EndangeredMassa", "author_id": 106, "author_profile": "https://Stackoverflow.com/users/106", "pm_score": 2, "selected": false, "text": "<p>You should use XML or JSON. I prefer JSON because it's easy to parse back on the javascript side.</p>\n\n<p>In the ...
2008/11/17
[ "https://Stackoverflow.com/questions/297206", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1574/" ]
I have a simple page that displays a user's email addresses in a table. I also have a textbox underneath the table and an "add" button. Currently, I am using a simple form post that is handled by a controller that will add the e-mail address to the database and reload the page. This works fine, but I'm looking to strea...
You should use XML or JSON. I prefer JSON because it's easy to parse back on the javascript side. In the click handler for the add button, make an AJAX call to some MVC path specifies what email has been added. Make the code for that path insert the email specified. Then, just return a result: ``` { result: 'SUCC...