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 |
|---|---|---|---|---|---|---|
319,923 | <p>I'm looking for a way to upload a file to s3. I am using django. I am currently using amazon's python library for uploading along with the following code: </p>
<p>View:</p>
<pre><code>def submitpicture(request):
fuser = request.session["login"]
copied_data = request.POST.copy()
copied_data.update(requ... | [
{
"answer_id": 319943,
"author": "ayaz",
"author_id": 23191,
"author_profile": "https://Stackoverflow.com/users/23191",
"pm_score": 5,
"selected": true,
"text": "<p>You will have to provide the enctype attribute to the FORM element (I've been bitten by this before). For example, your FOR... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319923",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23695/"
] | I'm looking for a way to upload a file to s3. I am using django. I am currently using amazon's python library for uploading along with the following code:
View:
```
def submitpicture(request):
fuser = request.session["login"]
copied_data = request.POST.copy()
copied_data.update(request.FILES)
conten... | You will have to provide the enctype attribute to the FORM element (I've been bitten by this before). For example, your FORM tag should look like:
```
<form action="/submitpicture/" method="POST" enctype="multipart/form-data" >
```
Without the enctype, you will find yourself with an empty request.FILES. |
319,936 | <p>How do I connect to the database(MYSQL) in connection bean using JSF to retrieve its contents. Also please let me know how do I configure the web.xml file?</p>
| [
{
"answer_id": 319980,
"author": "Chris Kimpton",
"author_id": 48310,
"author_profile": "https://Stackoverflow.com/users/48310",
"pm_score": 0,
"selected": false,
"text": "<p>Here is an <a href=\"http://blog.exadel.com/?p=8\" rel=\"nofollow noreferrer\">example using Hibernate and HSQL</... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319936",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40933/"
] | How do I connect to the database(MYSQL) in connection bean using JSF to retrieve its contents. Also please let me know how do I configure the web.xml file? | To get connected to mysql:
```
public void open() {
try {
String databaseName = "custom";
String userName = "root";
String password = "welcome";
//
String url = "jdbc:mysql://localhost/" + databaseName;
Class.forName("com.mysql.jdbc.Dr... |
319,950 | <p>i want to create a number of databases in ms-access using a code or any option of ms-access, but i want delete databases also.
Please help me</p>
| [
{
"answer_id": 320351,
"author": "Berzerk",
"author_id": 37599,
"author_profile": "https://Stackoverflow.com/users/37599",
"pm_score": 2,
"selected": false,
"text": "<p>You could have an empty database named \"db1.mdb\", and then add this code inside a module <strong>in another</strong> ... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319950",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | i want to create a number of databases in ms-access using a code or any option of ms-access, but i want delete databases also.
Please help me | You could have an empty database named "db1.mdb", and then add this code inside a module **in another** Access database:
```
Set fso = CreateObject("scripting.filesystemobject")
fso.CopyFile "c:\db.mdb", "c:\db_copy1.mdb", True
fso.CopyFile "c:\db.mdb", "c:\db_copy2.mdb", True
fso.CopyFile "c:\db.mdb", "c:\db_... |
319,958 | <p>This is to all the C# gurus. I have been banging my head on this for some time already, tried all kinds of advice on the net with no avail. The action is happening in Windows Mobile 5.0.</p>
<p>I have a DLL named MyDll.dll. In the MyDll.h I have:</p>
<pre><code>extern "C" __declspec(dllexport) int MyDllFunction(in... | [
{
"answer_id": 320012,
"author": "JaredPar",
"author_id": 23283,
"author_profile": "https://Stackoverflow.com/users/23283",
"pm_score": 0,
"selected": false,
"text": "<p>The exception you listed and the pinvoke signature you put in the question have different names: MyDll.dll and ThreadB... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319958",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2877/"
] | This is to all the C# gurus. I have been banging my head on this for some time already, tried all kinds of advice on the net with no avail. The action is happening in Windows Mobile 5.0.
I have a DLL named MyDll.dll. In the MyDll.h I have:
```
extern "C" __declspec(dllexport) int MyDllFunction(int one, int two);
```... | Maybe this seems like an obvious thing to check, but are you compiling the native DLL for the correct CPU architecture? IIRC, Windows Mobile runs on multiple CPU architectures. |
319,973 | <p>I would like to use Linq to query a bus schedule in my project, so that at any time I can get the next 5 bus arrival times. How can I limit my query to the first 5 results?</p>
<p>More generally, how can I take a slice of a list in C#? (In Python I would use <code>mylist[:5]</code> to get the first 5 elements.)</p>... | [
{
"answer_id": 319976,
"author": "Matt Hamilton",
"author_id": 615,
"author_profile": "https://Stackoverflow.com/users/615",
"pm_score": 11,
"selected": true,
"text": "<pre><code>var firstFiveItems = myList.Take(5);\n</code></pre>\n\n<p>Or to slice:</p>\n\n<pre><code>var secondFiveItems ... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319973",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38146/"
] | I would like to use Linq to query a bus schedule in my project, so that at any time I can get the next 5 bus arrival times. How can I limit my query to the first 5 results?
More generally, how can I take a slice of a list in C#? (In Python I would use `mylist[:5]` to get the first 5 elements.) | ```
var firstFiveItems = myList.Take(5);
```
Or to slice:
```
var secondFiveItems = myList.Skip(5).Take(5);
```
And of course often it's convenient to get the first five items according to some kind of order:
```
var firstFiveArrivals = myList.OrderBy(i => i.ArrivalTime).Take(5);
``` |
319,993 | <p>This is a <a href="https://stackoverflow.com/questions/319199/why-is-java-able-to-store-0xff000000-as-an-int">follow up question</a>. So, Java store's integers in <a href="http://en.wikipedia.org/wiki/Two%27s_complement" rel="nofollow noreferrer">two's-complements</a> and you can do the following:</p>
<pre><code>in... | [
{
"answer_id": 320000,
"author": "Martin v. Löwis",
"author_id": 33006,
"author_profile": "https://Stackoverflow.com/users/33006",
"pm_score": 6,
"selected": true,
"text": "<p>C# (rather, .NET) also uses the two's complement, but it supports both signed and unsigned types (which Java doe... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319993",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13466/"
] | This is a [follow up question](https://stackoverflow.com/questions/319199/why-is-java-able-to-store-0xff000000-as-an-int). So, Java store's integers in [two's-complements](http://en.wikipedia.org/wiki/Two%27s_complement) and you can do the following:
```
int ALPHA_MASK = 0xff000000;
```
In C# this requires the use o... | C# (rather, .NET) also uses the two's complement, but it supports both signed and unsigned types (which Java doesn't). A bit mask is more naturally an unsigned thing - why should one bit be different than all the other bits?
In this specific case, it is safe to use an unchecked cast:
```
int ALPHA_MASK = unchecked((i... |
320,004 | <p>Given a couple of simple tables like so:</p>
<pre><code>create table R(foo text);
create table S(bar text);
</code></pre>
<p>If I were to union them together in a query, what do I call the column?</p>
<pre><code>select T.????
from (
select foo
from R
union
select bar
from S) as T;
</code></pre... | [
{
"answer_id": 320018,
"author": "Ali Ersöz",
"author_id": 4215,
"author_profile": "https://Stackoverflow.com/users/4215",
"pm_score": 4,
"selected": false,
"text": "<p>Try to give an alias to columns;</p>\n\n<pre><code>select T.Col1\nfrom (\n select foo as Col1\n from R\n union... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320004",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22897/"
] | Given a couple of simple tables like so:
```
create table R(foo text);
create table S(bar text);
```
If I were to union them together in a query, what do I call the column?
```
select T.????
from (
select foo
from R
union
select bar
from S) as T;
```
Now, in mysql, I can apparently refer to th... | Although there is no spelled rule, we can use the column names from the first subquery in the union query to fetch the union results. |
320,009 | <p>In C++, I code this way:</p>
<pre><code>//foo.h
class cBar
{
void foobar();
}
</code></pre>
<hr>
<pre><code>//foo.cpp
void cBar::foobar()
{
//Code
}
</code></pre>
<p>I tried to do this on PHP but the parser would complain. PHP's documentation also doesn't help. Can this be done in PHP?</p>
| [
{
"answer_id": 320024,
"author": "Aron Rotteveel",
"author_id": 11568,
"author_profile": "https://Stackoverflow.com/users/11568",
"pm_score": 1,
"selected": false,
"text": "<p>You can't really do this in the same manner.</p>\n\n<p>You can use <a href=\"http://nl2.php.net/manual/en/langua... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320009",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1599/"
] | In C++, I code this way:
```
//foo.h
class cBar
{
void foobar();
}
```
---
```
//foo.cpp
void cBar::foobar()
{
//Code
}
```
I tried to do this on PHP but the parser would complain. PHP's documentation also doesn't help. Can this be done in PHP? | No. You need to including all your function definitions inside the class block. If defining your functions in a separate structure makes you feel better you could use an interface.
```
interface iBar
{
function foobar();
}
class cBar implements iBar
{
function foobar()
{
//Code
}
}
```
I'd s... |
320,028 | <p>I cannot get a two-way bind in WPF to work. </p>
<p>I have a string property in my app's main window that is bound to a TextBox (I set the mode to "TwoWay"). </p>
<p>The only time that the value of the TextBox will update is when the window initializes. </p>
<p>When I type into the TextBox, the underlying string ... | [
{
"answer_id": 320033,
"author": "Matt Hamilton",
"author_id": 615,
"author_profile": "https://Stackoverflow.com/users/615",
"pm_score": 2,
"selected": false,
"text": "<p>We might need to see the code. Does your string property raise a PropertyChanged event? Or (even better) is it implem... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320028",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29119/"
] | I cannot get a two-way bind in WPF to work.
I have a string property in my app's main window that is bound to a TextBox (I set the mode to "TwoWay").
The only time that the value of the TextBox will update is when the window initializes.
When I type into the TextBox, the underlying string properties value does no... | Most probably you're trying to bind to a .net CLR property instead of a WPF dependencyProperty (which provides Change Notification in addition to some other things).
For normal CLR property, you'd need to implement INotifyPropertyChanged and force update on the textbox in the event handler for PropertyChanged.
* S... |
320,046 | <p>This is intended to be a more concrete, easily expressable form of my earlier question.</p>
<p>Take a list of words from a dictionary with common letter length.<br>
How to reorder this list tto keep as many letters as possible common between adjacent words? </p>
<p>Example 1:</p>
<pre><code>AGNI, CIVA, DEVA, DEW... | [
{
"answer_id": 320063,
"author": "schnaader",
"author_id": 34065,
"author_profile": "https://Stackoverflow.com/users/34065",
"pm_score": 0,
"selected": false,
"text": "<p>This can be done with a recursive approach. Pseudo-code:</p>\n\n<pre><code>Start with one of the words, call it w\nFi... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320046",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | This is intended to be a more concrete, easily expressable form of my earlier question.
Take a list of words from a dictionary with common letter length.
How to reorder this list tto keep as many letters as possible common between adjacent words?
Example 1:
```
AGNI, CIVA, DEVA, DEWA, KAMA, RAMA, SIVA, VAYU
reor... | What you're trying to do, is calculate the shortest hamiltonian path in a complete weighted graph, where each word is a vertex, and the weight of each edge is the number of letters that are differenct between those two words.
For your example, the graph would have edges weighted as so:
```
DEVI KALI SHRI VACH
D... |
320,052 | <p>What is your preferred method of traversing a tree data structure, since recursive method calls can be pretty inefficient in some circumstances. I am simply using a generator like the one above. Do you have any hints to make it faster?</p>
<pre><code>def children(self):
stack = [self.entities]
while stack: ... | [
{
"answer_id": 320060,
"author": "rebra",
"author_id": 2282296,
"author_profile": "https://Stackoverflow.com/users/2282296",
"pm_score": 3,
"selected": false,
"text": "<p>Unless your tree is really large or you have really high (real) requirements for speed, I would choose the recursive ... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320052",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40948/"
] | What is your preferred method of traversing a tree data structure, since recursive method calls can be pretty inefficient in some circumstances. I am simply using a generator like the one above. Do you have any hints to make it faster?
```
def children(self):
stack = [self.entities]
while stack:
for e... | I can't think of any big algorithmic improvements, but a simple microoptimisation you can make is to bind frequently called methods (such as stack.append / stack.pop) to locals (this saves a dictionary lookup)
```
def children(self):
stack = [self.entities]
push = stack.append
pop = stack.pop
while sta... |
320,078 | <p>How do you add that little "X" button on the right side of a UITextField that clears the text? I can't find an attribute for adding this sub-control in Interface Builder in the iPhone OS 2.2 SDK.</p>
<p><strong>Note:</strong> In Xcode 4.x and later (iPhone 3.0 SDK and later), you can do this in Interface Builder.<... | [
{
"answer_id": 320079,
"author": "Kristopher Johnson",
"author_id": 1175,
"author_profile": "https://Stackoverflow.com/users/1175",
"pm_score": 10,
"selected": true,
"text": "<p>This button is a built-in overlay that is provided by the <code>UITextField</code> class, but as of the iOS 2.... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320078",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1175/"
] | How do you add that little "X" button on the right side of a UITextField that clears the text? I can't find an attribute for adding this sub-control in Interface Builder in the iPhone OS 2.2 SDK.
**Note:** In Xcode 4.x and later (iPhone 3.0 SDK and later), you can do this in Interface Builder. | This button is a built-in overlay that is provided by the `UITextField` class, but as of the iOS 2.2 SDK, there isn't any way to set it via Interface Builder. You have to enable it programmatically.
Add this line of code somewhere (`viewDidLoad`, for example):
**Objective-C**
```
myUITextField.clearButtonMode = UITe... |
320,089 | <p>My WPF application generates sets of data which may have a different number of columns each time. Included in the output is a description of each column that will be used to apply formatting. A simplified version of the output might be something like:</p>
<pre><code>class Data
{
IList<ColumnDescription>... | [
{
"answer_id": 321124,
"author": "Bryan Anderson",
"author_id": 21186,
"author_profile": "https://Stackoverflow.com/users/21186",
"pm_score": 1,
"selected": false,
"text": "<p>You might be able to do this with AutoGenerateColumns and a DataTemplate. I'm not positive if it would work with... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320089",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40944/"
] | My WPF application generates sets of data which may have a different number of columns each time. Included in the output is a description of each column that will be used to apply formatting. A simplified version of the output might be something like:
```
class Data
{
IList<ColumnDescription> ColumnDescriptions { ... | Here's a workaround for Binding Columns in the DataGrid. Since the Columns property is ReadOnly, like everyone noticed, I made an Attached Property called BindableColumns which updates the Columns in the DataGrid everytime the collection changes through the CollectionChanged event.
If we have this Collection of DataG... |
320,096 | <p>If there a way to protect against concurrent modifications of the same data base entry by two or more users?</p>
<p>It would be acceptable to show an error message to the user performing the second commit/save operation, but data should not be silently overwritten.</p>
<p>I think locking the entry is not an option... | [
{
"answer_id": 320134,
"author": "Stein G. Strindhaug",
"author_id": 26115,
"author_profile": "https://Stackoverflow.com/users/26115",
"pm_score": -1,
"selected": false,
"text": "<p>To be safe the database needs to support <a href=\"http://en.wikipedia.org/wiki/Database_transaction\" rel... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320096",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11527/"
] | If there a way to protect against concurrent modifications of the same data base entry by two or more users?
It would be acceptable to show an error message to the user performing the second commit/save operation, but data should not be silently overwritten.
I think locking the entry is not an option, as a user might... | This is how I do optimistic locking in Django:
```
updated = Entry.objects.filter(Q(id=e.id) && Q(version=e.version))\
.update(updated_field=new_value, version=e.version+1)
if not updated:
raise ConcurrentModificationException()
```
The code listed above can be implemented as a method in [Custom Manage... |
320,103 | <p>Using the Facebook API, is there a way of getting a friend's phone/cell number? I'm sure I saw an app a while ago that could sync Facebook with your Mac Address Book, but I haven't found anything in the API documentation that allows you to get a friend's number. Is this possible?</p>
<p>Thanks in advance.</p>
| [
{
"answer_id": 320134,
"author": "Stein G. Strindhaug",
"author_id": 26115,
"author_profile": "https://Stackoverflow.com/users/26115",
"pm_score": -1,
"selected": false,
"text": "<p>To be safe the database needs to support <a href=\"http://en.wikipedia.org/wiki/Database_transaction\" rel... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320103",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21709/"
] | Using the Facebook API, is there a way of getting a friend's phone/cell number? I'm sure I saw an app a while ago that could sync Facebook with your Mac Address Book, but I haven't found anything in the API documentation that allows you to get a friend's number. Is this possible?
Thanks in advance. | This is how I do optimistic locking in Django:
```
updated = Entry.objects.filter(Q(id=e.id) && Q(version=e.version))\
.update(updated_field=new_value, version=e.version+1)
if not updated:
raise ConcurrentModificationException()
```
The code listed above can be implemented as a method in [Custom Manage... |
320,124 | <p>I want to debug an application in Linux.
The application is created in C++. The GUI is created using QT.
The GUI is linked with a static library that can be treated as the back end of the application.</p>
<p>I want to debug the static library but am not sure how to do that.</p>
<p>I tried using gdb</p>
<pre><code... | [
{
"answer_id": 320136,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 4,
"selected": true,
"text": "<p>gdb will automatically debug functions in the library when they are called. just call it like</p>\n\n<pre... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320124",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33411/"
] | I want to debug an application in Linux.
The application is created in C++. The GUI is created using QT.
The GUI is linked with a static library that can be treated as the back end of the application.
I want to debug the static library but am not sure how to do that.
I tried using gdb
```
gdb GUI
```
But how can I... | gdb will automatically debug functions in the library when they are called. just call it like
```
gdb ./foo
run
```
:) . Be sure you build foo with debugging flags (`-g3` will enable all debugging stuffs for gcc :). You should not optimize when debugging (pass at most `-O1` to gcc, do not optimize further). It can c... |
320,135 | <p>I need to ensure that an application I am developing is accessable and also works with JavaScript turned off. I just need a pointer to assist with the following.</p>
<p>I had 3 'chained' select boxes and I wanted JavaScript enabled clients to have a nice Ajax experience. I can easily write the required functionalit... | [
{
"answer_id": 321473,
"author": "rodbv",
"author_id": 79101,
"author_profile": "https://Stackoverflow.com/users/79101",
"pm_score": 2,
"selected": false,
"text": "<p>You can check the IsMvcAjaxRequest property and use it inside your controller and then return a partial view (user contro... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320135",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6440/"
] | I need to ensure that an application I am developing is accessable and also works with JavaScript turned off. I just need a pointer to assist with the following.
I had 3 'chained' select boxes and I wanted JavaScript enabled clients to have a nice Ajax experience. I can easily write the required functionality to popul... | You can check the IsMvcAjaxRequest property and use it inside your controller and then return a partial view (user control) or JSON result if true, or the full View if it's false.
Something like this:
```
public ActionResult List()
{
if (!Request.IsMvcAjaxRequest())
{
// Non AJAX requests see the entire ... |
320,148 | <p>I have a xml file like this:</p>
<pre><code><customer>
<field1 />
<field2 />
<field3>
<item1 />
</field3>
<field3>
<item1 />
</field3>
</customer>
</code></pre>
<p>field* can appear in any order and only field3 can appear more than onc... | [
{
"answer_id": 320363,
"author": "AJ.",
"author_id": 7211,
"author_profile": "https://Stackoverflow.com/users/7211",
"pm_score": 2,
"selected": false,
"text": "<h2>Try this</h2>\n\n<p>I'm not a guru, but this appears to work. </p>\n\n<pre><code><?xml version=\"1.0\" encoding=\"UTF-8\... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320148",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26079/"
] | I have a xml file like this:
```
<customer>
<field1 />
<field2 />
<field3>
<item1 />
</field3>
<field3>
<item1 />
</field3>
</customer>
```
field\* can appear in any order and only field3 can appear more than once.
How can I create a XSD file to validate this?
Thank you! | Try this
--------
I'm not a guru, but this appears to work.
```
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="customer" type="customerType"/>
<xs:complexType name="customerType">
<xs:sequence>
<xs:element name="field1" minOccurs="1" max... |
320,158 | <p>I've created a workflow/flowchart style designer for something. At the moment it is using relatively simple Bezier curve lines to connect up the various end points of the "blocks" on the workflow.</p>
<p>However I would like something a bit more intuitive for the user. I want the lines to avoid obstacles like other... | [
{
"answer_id": 320363,
"author": "AJ.",
"author_id": 7211,
"author_profile": "https://Stackoverflow.com/users/7211",
"pm_score": 2,
"selected": false,
"text": "<h2>Try this</h2>\n\n<p>I'm not a guru, but this appears to work. </p>\n\n<pre><code><?xml version=\"1.0\" encoding=\"UTF-8\... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320158",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40963/"
] | I've created a workflow/flowchart style designer for something. At the moment it is using relatively simple Bezier curve lines to connect up the various end points of the "blocks" on the workflow.
However I would like something a bit more intuitive for the user. I want the lines to avoid obstacles like other blocks (r... | Try this
--------
I'm not a guru, but this appears to work.
```
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="customer" type="customerType"/>
<xs:complexType name="customerType">
<xs:sequence>
<xs:element name="field1" minOccurs="1" max... |
320,166 | <pre><code> self.logger.info(msg)
popinstance=poplib.POP3(self.account[0])
self.logger.info(popinstance.getwelcome())
popinstance.user(self.account[1])
popinstance.pass_(self.account[2])
try:
(numMsgs, totalSize)=popinstance.stat()
self.logger.info("POP contains " + str(numMsgs) +... | [
{
"answer_id": 320192,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 4,
"selected": true,
"text": "<p>It is probably a Space character encoded in <a href=\"http://en.wikipedia.org/wiki/Quoted-printable\" rel=\"noreferrer\">quo... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320166",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21537/"
] | ```
self.logger.info(msg)
popinstance=poplib.POP3(self.account[0])
self.logger.info(popinstance.getwelcome())
popinstance.user(self.account[1])
popinstance.pass_(self.account[2])
try:
(numMsgs, totalSize)=popinstance.stat()
self.logger.info("POP contains " + str(numMsgs) + " emai... | It is probably a Space character encoded in [quoted-printable](http://en.wikipedia.org/wiki/Quoted-printable) |
320,170 | <p>Does anyone have a good algorithm for taking an ordered list of integers, i.e.:<br>
[1, 3, 6, 7, 8, 10, 11, 13, 14, 17, 19, 23, 25, 27, 28]</p>
<p>into a given number of evenly sized ordered sublists, i.e. for 4 it will be:<br>
[1, 3, 6] [7, 8, 10, 11] [13, 14, 17, 19] [23, 25, 27, 28]</p>
<p>The requirement being... | [
{
"answer_id": 320180,
"author": "Nicolai",
"author_id": 20962,
"author_profile": "https://Stackoverflow.com/users/20962",
"pm_score": 1,
"selected": false,
"text": "<p>Here is my own recursive solution, inspired by merge sort and breadth first tree traversal:</p>\n\n<pre><code>private s... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320170",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20962/"
] | Does anyone have a good algorithm for taking an ordered list of integers, i.e.:
[1, 3, 6, 7, 8, 10, 11, 13, 14, 17, 19, 23, 25, 27, 28]
into a given number of evenly sized ordered sublists, i.e. for 4 it will be:
[1, 3, 6] [7, 8, 10, 11] [13, 14, 17, 19] [23, 25, 27, 28]
The requirement being that each of the s... | Splitting the lists evenly means you will have two sizes of lists - size S and S+1.
With N sublists, and X elements in the original, you would get:
floor(X/N) number of elements in the smaller sublists (S), and X % N is the number of larger sublists (S+1).
Then iterate over the original array, and (looking at your e... |
320,178 | <p>I want to build an Axis2 client (I'm only accessing a remote web service, I'm <em>not</em> implementing one!) with Maven2 and I don't want to add 21MB of JARs to my project. What do I have to put in my pom.xml to compile the code when I've converted the WSDL with ADB?</p>
| [
{
"answer_id": 321599,
"author": "Alex",
"author_id": 30859,
"author_profile": "https://Stackoverflow.com/users/30859",
"pm_score": 5,
"selected": true,
"text": "<p>(<strong>Note:</strong> This response was provided by Aaron Digulla himself. What follows is the exact text of his own answ... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320178",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34088/"
] | I want to build an Axis2 client (I'm only accessing a remote web service, I'm *not* implementing one!) with Maven2 and I don't want to add 21MB of JARs to my project. What do I have to put in my pom.xml to compile the code when I've converted the WSDL with ADB? | (**Note:** This response was provided by Aaron Digulla himself. What follows is the exact text of his own answer.)
In maven2, the minimum dependency set to make an ADB client work ("ADB" as in the way you created the Java classes from the WSDL) is this:
```
<dependency>
<groupId>org.apache.axis2</grou... |
320,184 | <p>Ever since switching from TABLE-layout to DIV-layout, one common problem remains:</p>
<p><strong>PROBLEM</strong>: you fill your DIV with dynamic text and inevitably there is a super-long word that extends over the edge of your div column and makes your site look unprofessional.</p>
<p><strong>RETRO-WHINING</stron... | [
{
"answer_id": 320196,
"author": "Oli",
"author_id": 12870,
"author_profile": "https://Stackoverflow.com/users/12870",
"pm_score": 5,
"selected": false,
"text": "<p>Two fixes:</p>\n\n<ol>\n<li><code>overflow:scroll</code> -- this makes sure your content can be seen at the cost of design ... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320184",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4639/"
] | Ever since switching from TABLE-layout to DIV-layout, one common problem remains:
**PROBLEM**: you fill your DIV with dynamic text and inevitably there is a super-long word that extends over the edge of your div column and makes your site look unprofessional.
**RETRO-WHINING**: This *never* happened with table layout... | Soft hyphen
-----------
You can tell browsers where to split long words by inserting soft hyphen (`­`):
```
averyvery­longword
```
may be rendered as
>
> averyverylongword
>
>
>
or
>
> averyvery-
>
> longword
>
>
>
A nice regular expression can ensure you won't be inserting them unless necces... |
320,194 | <p>In Ruby on Rails, how to add foreign key constraint in migration?</p>
| [
{
"answer_id": 320457,
"author": "Jeroen Heijmans",
"author_id": 30748,
"author_profile": "https://Stackoverflow.com/users/30748",
"pm_score": 3,
"selected": true,
"text": "<p>AFAIK, there isn't any built-in support for that, but there are <a href=\"http://agilewebdevelopment.com/plugins... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320194",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40236/"
] | In Ruby on Rails, how to add foreign key constraint in migration? | AFAIK, there isn't any built-in support for that, but there are [several plugins](http://agilewebdevelopment.com/plugins/search?q=foreign+keys) that help you with that. You can also add them manually to your migration files, just use the execute method for that, e.g. (sample from Rails API):
```
class MakeJoinUnique... |
320,204 | <p>I have a <code>JFrame</code> that contains a "display" <code>JPanel</code> with <code>JTextField</code> and a "control" <code>JPanel</code> with buttons that should access the contents of the display <code>JPanel</code>. I think my problem is related on how to use the observer pattern, which in principle I understan... | [
{
"answer_id": 320384,
"author": "Tom Hawtin - tackline",
"author_id": 4725,
"author_profile": "https://Stackoverflow.com/users/4725",
"pm_score": 1,
"selected": false,
"text": "<p>It does make the code cleaner if you create the models in one layer and add a layer or two above to create ... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320204",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39444/"
] | I have a `JFrame` that contains a "display" `JPanel` with `JTextField` and a "control" `JPanel` with buttons that should access the contents of the display `JPanel`. I think my problem is related on how to use the observer pattern, which in principle I understand. You need to place listeners and update messages, but I ... | You need to reduce the coupling between these objects.
You can have a master object, that owns all the text fields and the button ( the panels are irrelevant )
Then a separete actionlistener within that master object ( I call it mediator see mediator pattern )
That action listener performs a method on the mediator... |
320,222 | <p>as a follow up on my <a href="https://stackoverflow.com/questions/318208/cast-to-combined-generic">previous question</a>
Having a function with combined generic bounds such as:</p>
<pre><code><T extends Foo & Bar> void doStuff(T argument) {
//do stuff wich should only be done if arguments is both foo an... | [
{
"answer_id": 320262,
"author": "Frank Grimm",
"author_id": 903,
"author_profile": "https://Stackoverflow.com/users/903",
"pm_score": 2,
"selected": false,
"text": "<p>I wouldn't consider combined generic bounds an anti-pattern. At least I've got some uses for them in my code. For insta... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320222",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15355/"
] | as a follow up on my [previous question](https://stackoverflow.com/questions/318208/cast-to-combined-generic)
Having a function with combined generic bounds such as:
```
<T extends Foo & Bar> void doStuff(T argument) {
//do stuff wich should only be done if arguments is both foo and bar
}
```
Because this is not c... | I wouldn't consider combined generic bounds an anti-pattern. At least I've got some uses for them in my code. For instance, the following sample code finds the biggest Number instance in a collection using compareTo from the Comparable interface:
```
<T extends Number & Comparable<T>> T max(Collection<T> numbers)
``` |
320,232 | <p>Is there a way to ensure all created subprocess are dead at exit time of a Python program? By subprocess I mean those created with subprocess.Popen().</p>
<p>If not, should I iterate over all of the issuing kills and then kills -9? anything cleaner?</p>
| [
{
"answer_id": 320251,
"author": "Igal Serban",
"author_id": 25737,
"author_profile": "https://Stackoverflow.com/users/25737",
"pm_score": 2,
"selected": false,
"text": "<blockquote>\n <p>poll( ) </p>\n \n <p>Check if child process has terminated.\n Returns returncode attribute.</p>\... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320232",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6068/"
] | Is there a way to ensure all created subprocess are dead at exit time of a Python program? By subprocess I mean those created with subprocess.Popen().
If not, should I iterate over all of the issuing kills and then kills -9? anything cleaner? | You can use [**atexit**](http://docs.python.org/library/atexit.html) for this, and register any clean up tasks to be run when your program exits.
**atexit.register(func[, \*args[, \*\*kargs]])**
In your cleanup process, you can also implement your own wait, and kill it when a your desired timeout occurs.
```
>>> im... |
320,250 | <p>I am trying to return the minimum and maximum prices for a villa booking system. I have a look up table that stores the price for each week for each villa. </p>
<p>I am using the min and max functions to do this within the select but I'm having lots of problems. Can anyone explain where i'm going wrong? Heres the s... | [
{
"answer_id": 320256,
"author": "Tony Andrews",
"author_id": 18747,
"author_profile": "https://Stackoverflow.com/users/18747",
"pm_score": 2,
"selected": false,
"text": "<p>You don't elaborate on <em>what</em> problems you are getting, but this is probably one: you need to specify <stro... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320250",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40623/"
] | I am trying to return the minimum and maximum prices for a villa booking system. I have a look up table that stores the price for each week for each villa.
I am using the min and max functions to do this within the select but I'm having lots of problems. Can anyone explain where i'm going wrong? Heres the sp
```
ALT... | You don't elaborate on *what* problems you are getting, but this is probably one: you need to specify **all** the non-aggregate columns in the GROUP BY clause i.e.:
```
GROUP BY tblVillas.name,
tblVillas.introduction,
tblVillas.italian_introduction,
tblVillas.uk_content,
tblVillas.italian_... |
320,281 | <p>I need to determine the number of pages in a specified PDF file using C# code (.NET 2.0). The PDF file will be read from the file system, and not from an URL. Does anyone have any idea on how this could be done? Note: Adobe Acrobat Reader is installed on the PC where this check will be carried out.</p>
| [
{
"answer_id": 320325,
"author": "darkdog",
"author_id": 1094,
"author_profile": "https://Stackoverflow.com/users/1094",
"pm_score": 7,
"selected": true,
"text": "<p>You'll need a PDF API for C#. iTextSharp is one possible API, though better ones might exist.</p>\n\n<p><strong>iTextSharp... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320281",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35483/"
] | I need to determine the number of pages in a specified PDF file using C# code (.NET 2.0). The PDF file will be read from the file system, and not from an URL. Does anyone have any idea on how this could be done? Note: Adobe Acrobat Reader is installed on the PC where this check will be carried out. | You'll need a PDF API for C#. iTextSharp is one possible API, though better ones might exist.
**iTextSharp Example**
You must install iTextSharp.dll as a reference. Download iTextsharp from SourceForge.net This is a complete working program using a console application.
```
using System;
using System.Collections.Gene... |
320,289 | <p>What is the C# equivalent of Delphi's <code>FillChar</code>?</p>
| [
{
"answer_id": 320320,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 3,
"selected": true,
"text": "<p>If I understand FillChar correctly, it sets all elements of an array to the same value, yes?</p>\n\n<p>In which cas... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320289",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38940/"
] | What is the C# equivalent of Delphi's `FillChar`? | If I understand FillChar correctly, it sets all elements of an array to the same value, yes?
In which case, unless the value is 0, you probably have to loop:
```
for(int i = 0 ; i < arr.Length ; i++) {
arr[i] = value;
}
```
For setting the values to the type's 0, there is `Array.Clear`
Obviously, with the loop... |
320,291 | <p>My current code looks like the following. How can I pass my array to the controller and what kind of parameters must my controller action accept?</p>
<pre><code>function getplaceholders() {
var placeholders = $('.ui-sortable');
var result = new Array();
placeholders.each(function() {
var ph = $(... | [
{
"answer_id": 320644,
"author": "anonymous",
"author_id": 36602,
"author_profile": "https://Stackoverflow.com/users/36602",
"pm_score": 3,
"selected": false,
"text": "<p>Towards the second half of <em><a href=\"http://weblogs.asp.net/omarzabir/archive/2008/10/03/create-rest-api-using-as... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320291",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37311/"
] | My current code looks like the following. How can I pass my array to the controller and what kind of parameters must my controller action accept?
```
function getplaceholders() {
var placeholders = $('.ui-sortable');
var result = new Array();
placeholders.each(function() {
var ph = $(this).attr('id... | I've found an solution. I use an solution of Steve Gentile, *[jQuery and ASP.NET MVC – sending JSON to an Action – Revisited](http://blogger.forgottenskies.com/?p=252)*.
My ASP.NET MVC view code looks like:
```
function getplaceholders() {
var placeholders = $('.ui-sortable');
var results = new Array(... |
320,313 | <p>I'm using GNU bash, version 3.00.15(1)-release (x86_64-redhat-linux-gnu). And this command:</p>
<pre><code>echo "-e"
</code></pre>
<p>doesn't print anything. I guess this is because "-e" is one of a valid options of echo command because echo "-n" and echo "-E" (the other two options) also produce empty strings.</... | [
{
"answer_id": 320321,
"author": "Joachim Sauer",
"author_id": 40342,
"author_profile": "https://Stackoverflow.com/users/40342",
"pm_score": 2,
"selected": false,
"text": "<p>You could cheat by doing</p>\n\n<pre><code>echo \"-e \"\n</code></pre>\n\n<p>That would be dash, e, space.</p>\n\... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320313",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15647/"
] | I'm using GNU bash, version 3.00.15(1)-release (x86\_64-redhat-linux-gnu). And this command:
```
echo "-e"
```
doesn't print anything. I guess this is because "-e" is one of a valid options of echo command because echo "-n" and echo "-E" (the other two options) also produce empty strings.
The question is how to es... | This is a tough one ;)
Usually you would use double dashes to tell the command that it should stop interpreting options, but echo will only output those:
```
$ echo -- -e
-- -e
```
You can use -e itself to get around the problem:
```
$ echo -e '\055e'
-e
```
Also, as others have pointed out, if you don't insist ... |
320,330 | <p>When using <a href="http://log4perl.sourceforge.net/" rel="nofollow noreferrer">log4perl</a>, the debug log layout that I'm using is :</p>
<pre><code>log4perl.appender.D10.layout=PatternLayout
log4perl.appender.D10.layout.ConversionPattern=%d [pid=%P] %p %F{1} (%L) %M %m%n
log4perl.appender.D10.Filter = DebugAndUp
... | [
{
"answer_id": 320472,
"author": "innaM",
"author_id": 7498,
"author_profile": "https://Stackoverflow.com/users/7498",
"pm_score": 4,
"selected": true,
"text": "<p>You can pad the single fields that make up your entries. For example [pid=%5P] will always give you at least 5 characters fo... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320330",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13523/"
] | When using [log4perl](http://log4perl.sourceforge.net/), the debug log layout that I'm using is :
```
log4perl.appender.D10.layout=PatternLayout
log4perl.appender.D10.layout.ConversionPattern=%d [pid=%P] %p %F{1} (%L) %M %m%n
log4perl.appender.D10.Filter = DebugAndUp
```
This produces very verbose debug logs, for ex... | You can pad the single fields that make up your entries. For example [pid=%5P] will always give you at least 5 characters for the PID.
The ["Quantify Placeholders" section](http://search.cpan.org/~mschilli/Log-Log4perl-1.19/lib/Log/Log4perl/Layout/PatternLayout.pm#Quantify_placeholders) in the docs for Log::Log4perl:... |
320,333 | <p>I'd like to have some of the ScriptManager features in the new Asp.net MVC model:</p>
<p>1- Script combining<br>
2- Resolving different paths for external Javascript files<br>
3- Minify and Gzip Compression </p>
<p><a href="http://www.codeproject.com/KB/aspnet/HttpCombine.aspx" rel="nofollow noreferrer">Here</a> i... | [
{
"answer_id": 320397,
"author": "Franck",
"author_id": 38072,
"author_profile": "https://Stackoverflow.com/users/38072",
"pm_score": 5,
"selected": true,
"text": "<p>Maybe you could just create a new 'Scripts' controller with different actions serving different combinations of compresse... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320333",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1929/"
] | I'd like to have some of the ScriptManager features in the new Asp.net MVC model:
1- Script combining
2- Resolving different paths for external Javascript files
3- Minify and Gzip Compression
[Here](http://www.codeproject.com/KB/aspnet/HttpCombine.aspx) is what I found, but I'm not sure is the best way for MVC... | Maybe you could just create a new 'Scripts' controller with different actions serving different combinations of compressed JS files. Since MVC is designed with a resource oriented approach, i.e. URLs are now at the center of your programming model, why not define simple URIs for your Javascripts too ?
In your views, f... |
320,355 | <p>I would like to create a WLST script to create my Weblogic domain. However I'm having problems adding the LDAP config.</p>
<pre><code>cd("/SecurityConfiguration/myDomain")
cmo.createRealm("myrealm")
cd("/SecurityConfiguration/myDomain/Realms/myrealm")
cmo.createAuthenticationProvider("myLDAP", "weblogic.security.p... | [
{
"answer_id": 325454,
"author": "Mark Sailes",
"author_id": 33167,
"author_profile": "https://Stackoverflow.com/users/33167",
"pm_score": 2,
"selected": true,
"text": "<p>From what I've found, this configuration has to be done using WLST Online.</p>\n\n<p>The script I have created looks... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320355",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33167/"
] | I would like to create a WLST script to create my Weblogic domain. However I'm having problems adding the LDAP config.
```
cd("/SecurityConfiguration/myDomain")
cmo.createRealm("myrealm")
cd("/SecurityConfiguration/myDomain/Realms/myrealm")
cmo.createAuthenticationProvider("myLDAP", "weblogic.security.providers.authe... | From what I've found, this configuration has to be done using WLST Online.
The script I have created looks something like this
```
connect("username", "password", "t3://ip:port");
edit()
startEdit()
create_AuthenticationProvider_54("/SecurityConfiguration/myDomain/Realms/myrealm", "value")
cd("/SecurityConfiguratio... |
320,387 | <p>I am wondering if it is possible to have a sort of thumbnail image gallery, in which clicking on a thumbnail would show the full image in a layer. I was wondering if it was possible to load all layers and respective images and use javascript to change the z index or something similar to avoid having to reload or lea... | [
{
"answer_id": 320401,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 0,
"selected": false,
"text": "<p><a href=\"http://jquery.com/\" rel=\"nofollow noreferrer\">JQuery</a> should be able to make what you want.</p>\n\n<p>You ha... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320387",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1246613/"
] | I am wondering if it is possible to have a sort of thumbnail image gallery, in which clicking on a thumbnail would show the full image in a layer. I was wondering if it was possible to load all layers and respective images and use javascript to change the z index or something similar to avoid having to reload or leave ... | Yes, you can do it without a framework:
```
<div id='big' style='width:500px;height:500px'></div>
<a href="javascript://load big image" onclick="document.getElementById('big').style.backgroundImage='url(Big.gif)'"><img border="0" src="images/Thumb.gif" /></a>
```
Here is a simple example using the [Prototype](http:/... |
320,436 | <p>In a C# application I am working on I have a very long identifier as follows:-</p>
<pre><code>foo.bar.bwah.blah.whatever.very.very.huge
</code></pre>
<p>Whenever I to reference this object it's an absolute nightmare, and unfortunately I do need to reference it a lot:-</p>
<pre><code>var something = foo.bar.bwah.b... | [
{
"answer_id": 320451,
"author": "Barry Kelly",
"author_id": 3712,
"author_profile": "https://Stackoverflow.com/users/3712",
"pm_score": 4,
"selected": true,
"text": "<p>One way out is to use one or a pair of lambdas.</p>\n\n<p>For example:</p>\n\n<pre><code>Func<string> getter = (... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320436",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3394/"
] | In a C# application I am working on I have a very long identifier as follows:-
```
foo.bar.bwah.blah.whatever.very.very.huge
```
Whenever I to reference this object it's an absolute nightmare, and unfortunately I do need to reference it a lot:-
```
var something = foo.bar.bwah.blah.whatever.very.very.huge.a;
var so... | One way out is to use one or a pair of lambdas.
For example:
```
Func<string> getter = () => blah_de_blah;
Action<string> setter = x => blah_de_blah = x;
```
Now, you can use getter and setter to read and write the long identifier.
However, since your dots are member accessors, the easiest way of going about it is... |
320,443 | <p>I wrote code to set permission of the folder. Function I developed was</p>
<pre><code>public void SetPermission(string user,FileSystemRights rights)
{
DirectoryInfo dInfo = new DirectoryInfo(folderPath);
DirectorySecurity oDirectorySecurity = new DirectorySecurity();
oDirectorySecurity.AddAccessRule(ne... | [
{
"answer_id": 339830,
"author": "Excel Kobayashi",
"author_id": 42911,
"author_profile": "https://Stackoverflow.com/users/42911",
"pm_score": 0,
"selected": false,
"text": "<p>It might help to use dInfo.GetAccessControl to initialize oDirectorySecurity.\nYou could also try calling oDire... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320443",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40987/"
] | I wrote code to set permission of the folder. Function I developed was
```
public void SetPermission(string user,FileSystemRights rights)
{
DirectoryInfo dInfo = new DirectoryInfo(folderPath);
DirectorySecurity oDirectorySecurity = new DirectorySecurity();
oDirectorySecurity.AddAccessRule(new FileSystemAc... | I ran into this as well. It seems to be a Service Patch thing.
You can read how I fixed it at <http://jspot.jerryhanel.com/2009/01/08/c-filedirectory-permissions/>
The short version: You have to set a flag for all of the ACLs for all users. Yes... it's ugly. And when you add Service Pack 3, the checkmarks go away aga... |
320,448 | <p>I can't seem to find an answer to this problem, and I'm wondering if one exists. Simplified example:</p>
<p>Consider a string "nnnn", where I want to find all matches of "nn" - but also those that overlap with each other. So the regex would provide the following 3 matches:</p>
<ol>
<li><b>nn</b>nn</li>
<li>n<b>nn<... | [
{
"answer_id": 320470,
"author": "PhiLho",
"author_id": 15459,
"author_profile": "https://Stackoverflow.com/users/15459",
"pm_score": 2,
"selected": false,
"text": "<p>AFAIK, there is no pure regex way to do that at once (ie. returning the three captures you request without loop).</p>\n\... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320448",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4333/"
] | I can't seem to find an answer to this problem, and I'm wondering if one exists. Simplified example:
Consider a string "nnnn", where I want to find all matches of "nn" - but also those that overlap with each other. So the regex would provide the following 3 matches:
1. **nn**nn
2. n**nn**n
3. nn**nn**
I realize this... | Update 2016:
To get `nn`, `nn`, `nn`, [SDJMcHattie](https://stackoverflow.com/users/772095/sdjmchattie) proposes in [the comments](https://stackoverflow.com/questions/320448/overlapping-matches-in-regex/320478?noredirect=1#comment57488084_320478) [`(?=(nn))` (see regex101)](https://regex101.com/r/ET6Rvs/1/).
```
(?=(... |
320,452 | <p>I have a SQL table which has a number of fields</p>
<p>ID | Value | Type</p>
<p>A typical record may be :-
1000,10,[int]</p>
<p>a second row may be:-</p>
<p>1001,foo,[string]</p>
<p>a third row may be:-</p>
<p>1002,10/12/2008,[DateTime]</p>
<p>I have been asked to look at this as at the moment, each time we w... | [
{
"answer_id": 320650,
"author": "Tony Andrews",
"author_id": 18747,
"author_profile": "https://Stackoverflow.com/users/18747",
"pm_score": 3,
"selected": true,
"text": "<p>Horrors! This is the dreaded <a href=\"http://tonyandrews.blogspot.com/2004/10/otlt-and-eav-two-big-design-mistake... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320452",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35441/"
] | I have a SQL table which has a number of fields
ID | Value | Type
A typical record may be :-
1000,10,[int]
a second row may be:-
1001,foo,[string]
a third row may be:-
1002,10/12/2008,[DateTime]
I have been asked to look at this as at the moment, each time we wish to select from this table we have to cast the va... | Horrors! This is the dreaded [Entity-Attribute-Value (EAV)](http://tonyandrews.blogspot.com/2004/10/otlt-and-eav-two-big-design-mistakes.html) model! Run away!
But seriously, assuming there is some reason for needing this kind of model, maybe create a properly typed column for each data type?
```
ID Type S... |
320,461 | <p>Why main must be declared as if it has external linkage?
<p>Why it should not be static?
<p>what is meant by external linkage??</p>
| [
{
"answer_id": 320463,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 6,
"selected": true,
"text": "<p>Because you link the startup files to your program, which contains (usually) assembler code that calls yo... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320461",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31116/"
] | Why main must be declared as if it has external linkage?
Why it should not be static?
what is meant by external linkage?? | Because you link the startup files to your program, which contains (usually) assembler code that calls your main. If main were static, that code wouldn't be able to call main.
`external linkage` means that other so-called `translation-units` can see your symbol declared extern in its own translation-unit. So, your mai... |
320,466 | <p>I'm using MVC to validate some html text boxes on a page, for example in my controller there is</p>
<pre><code> if (String.IsNullOrEmpty(name))
{
ModelState.AddModelError("name", "You must specify a name.");
}
if (ViewData.ModelState.IsValid)
{
return... | [
{
"answer_id": 320620,
"author": "anonymous",
"author_id": 36602,
"author_profile": "https://Stackoverflow.com/users/36602",
"pm_score": 0,
"selected": false,
"text": "<p>I must admit, I have some confusion following exactly what you mean, so this is sort of a generic answer that might n... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320466",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29445/"
] | I'm using MVC to validate some html text boxes on a page, for example in my controller there is
```
if (String.IsNullOrEmpty(name))
{
ModelState.AddModelError("name", "You must specify a name.");
}
if (ViewData.ModelState.IsValid)
{
return RedirectToActi... | Take the code you have for initializing the ViewData in the (GET) Add action, and refactor it (extract method) into a standalone, private method. Call that method from your (GET) Add action. Now in the POST action (which is, I presume, what you're showing above; it isn't clear) you can call the same, private method to ... |
320,480 | <p>Nested If or single if with And operator, which is better approach?<br>
<strong>Single If with And</strong> </p>
<pre><code>if (txtPackage.Text != string.Empty && txtPackage.Text == "abc")
{
//
}
</code></pre>
<p><strong>Nested If</strong> </p>
<pre><code>if (txtPackage.Text != string.Empty)
{
... | [
{
"answer_id": 320488,
"author": "itsmatt",
"author_id": 7862,
"author_profile": "https://Stackoverflow.com/users/7862",
"pm_score": 4,
"selected": true,
"text": "<p>Are you going to do something different in the 'nested if' example if, in fact, txtPackage.Text isn't empty but contains s... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320480",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34588/"
] | Nested If or single if with And operator, which is better approach?
**Single If with And**
```
if (txtPackage.Text != string.Empty && txtPackage.Text == "abc")
{
//
}
```
**Nested If**
```
if (txtPackage.Text != string.Empty)
{
if (txtPackage.Text == "abc")
{
//
}
}
``` | Are you going to do something different in the 'nested if' example if, in fact, txtPackage.Text isn't empty but contains something other than "abc"?
If you aren't, I'd ask why are you checking for string.empty at all?
You could just write:
```
if (txtPackage.Text == "abc")
{
//
}
```
and be done with it.
Total... |
320,481 | <p>Is it possible to access the following formatted menu item like any other standard menu item (using the underscore-method, e.g. "_File" would be accessible by pressing "f")? I would like to use "O" as "access key" here.</p>
<p>Unfortunately, <code><AccessText></code> does not seem to be usable directly (I ima... | [
{
"answer_id": 320617,
"author": "Andy",
"author_id": 3857,
"author_profile": "https://Stackoverflow.com/users/3857",
"pm_score": 0,
"selected": false,
"text": "<p>Do you even need to use an AccessKey at all? Assuming that you didn't need/want the custom styling of the MenuItem header te... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320481",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Is it possible to access the following formatted menu item like any other standard menu item (using the underscore-method, e.g. "\_File" would be accessible by pressing "f")? I would like to use "O" as "access key" here.
Unfortunately, `<AccessText>` does not seem to be usable directly (I imaginged something like
``... | As I need the subscript, I cannot avoid the custom formatting. What I found out to be an ugly, but obviously possible solution is the following:
```
<MenuItem>
<MenuItem.Header>
<StackPanel Orientation="Horizontal">
<AccessText>_O</AccessText>
<TextBlock>
<Span BaselineAlignment="Subscript" F... |
320,482 | <p>There is a groupwall of which I want to download and store all messages in a db.
In the documentation I cannot find a good way to do it. Did I miss something? What's the good way to do this?</p>
| [
{
"answer_id": 320617,
"author": "Andy",
"author_id": 3857,
"author_profile": "https://Stackoverflow.com/users/3857",
"pm_score": 0,
"selected": false,
"text": "<p>Do you even need to use an AccessKey at all? Assuming that you didn't need/want the custom styling of the MenuItem header te... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320482",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/553923/"
] | There is a groupwall of which I want to download and store all messages in a db.
In the documentation I cannot find a good way to do it. Did I miss something? What's the good way to do this? | As I need the subscript, I cannot avoid the custom formatting. What I found out to be an ugly, but obviously possible solution is the following:
```
<MenuItem>
<MenuItem.Header>
<StackPanel Orientation="Horizontal">
<AccessText>_O</AccessText>
<TextBlock>
<Span BaselineAlignment="Subscript" F... |
320,484 | <p>Marked a javascript file as "Embedded resource"<br />
Added WebResource attribute to my AssemblyInfo class<br /><br />
Now i'm trying to output the embedded javascript to my master page. All I'm getting is a "Web Resource not found" from the web resource url.</p>
<p><br />Project Assembly Name:<br /></p>
<pre><cod... | [
{
"answer_id": 320711,
"author": "Chris Shaffer",
"author_id": 6744,
"author_profile": "https://Stackoverflow.com/users/6744",
"pm_score": 2,
"selected": false,
"text": "<p>I think you want the full paths to be based on the namespace, not the assembly; So anywhere you have \"CompanyProdu... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320484",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40986/"
] | Marked a javascript file as "Embedded resource"
Added WebResource attribute to my AssemblyInfo class
Now i'm trying to output the embedded javascript to my master page. All I'm getting is a "Web Resource not found" from the web resource url.
Project Assembly Name:
```
CompanyProduct
```
Project Default Name... | Instead of `this.GetType()`, get a type from the assembly that contains the resource.. ie:
```
typeof(Company.Product.Web.Library.Class1)
```
Does that work? |
320,500 | <p>I'm generating compiled getter methods at runtime for a given member. Right now, my code just assumes that the result of the getter method is a string (worked good for testing). However, I'd like to make this work with a custom converter class I've written, see below, "ConverterBase" reference that I've added.</p>... | [
{
"answer_id": 320507,
"author": "Barry Kelly",
"author_id": 3712,
"author_profile": "https://Stackoverflow.com/users/3712",
"pm_score": 2,
"selected": false,
"text": "<p>You need to wrap the object in an ExpressionConstant, e.g. by using Expression.Constant. Here's an example:</p>\n\n<p... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320500",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18941/"
] | I'm generating compiled getter methods at runtime for a given member. Right now, my code just assumes that the result of the getter method is a string (worked good for testing). However, I'd like to make this work with a custom converter class I've written, see below, "ConverterBase" reference that I've added.
I can't... | Can you illustrate what (if it was regular C#) you want the expression to evaluate? I can write the expression easily enough - I just don't fully understand the question...
(edit re comment) - in that case, it'll be something like:
```
ConverterBase typeConverter = new ConverterBase();
var target = Expression... |
320,506 | <p>Consider the following piece of Java code.</p>
<pre><code>int N = 10;
Object obj[] = new Object[N];
for (int i = 0; i < N; i++) {
int capacity = 1000 * i;
obj[i] = new ArrayList(capacity);
}
</code></pre>
<p>Because in Java, all objects live on the Heap, the array does not
contain the objects themselves... | [
{
"answer_id": 320512,
"author": "Joris Timmermans",
"author_id": 33987,
"author_profile": "https://Stackoverflow.com/users/33987",
"pm_score": 3,
"selected": false,
"text": "<p>Simply declaring</p>\n\n<pre><code>Object array_of_objects[10];\n</code></pre>\n\n<p>in C++ creates 10 default... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320506",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15649/"
] | Consider the following piece of Java code.
```
int N = 10;
Object obj[] = new Object[N];
for (int i = 0; i < N; i++) {
int capacity = 1000 * i;
obj[i] = new ArrayList(capacity);
}
```
Because in Java, all objects live on the Heap, the array does not
contain the objects themselves, but references to the objec... | For an array of ArrayList objects:
```
ArrayList obj[10];
```
The objects will be default initialised, which is fine for user-defined types, but may not be what you want for builtin-types.
Consider also:
```
std::vector<ArrayList> obj(10, ArrayList());
```
This initialises the objects by copying whatever you pas... |
320,509 | <p>I'm sure this must be possible, but I can't find out how to do it.</p>
<p>Any clues?</p>
| [
{
"answer_id": 320539,
"author": "Alex",
"author_id": 26564,
"author_profile": "https://Stackoverflow.com/users/26564",
"pm_score": 4,
"selected": false,
"text": "<pre><code>$startinfo = new-object System.Diagnostics.ProcessStartInfo \n$startinfo.FileName = \"explorer.exe\"\n$startinfo.W... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320509",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1088682/"
] | I'm sure this must be possible, but I can't find out how to do it.
Any clues? | Use:
```
ii .
```
which is short for
```
Invoke-Item .
```
It is one of the most common things I type at the PowerShell command line. |
320,523 | <p>I have a loop on page to update an access database that takes 15-20 seconds to complete. I only run it once a month at most but I noticed that every time I run it the web site (IIS 6) simply stops serving pages.</p>
<p>After the loop ends, pages begin opening again.</p>
<p>Here's my code:</p>
<pre><code>For each ... | [
{
"answer_id": 320569,
"author": "GalacticCowboy",
"author_id": 29638,
"author_profile": "https://Stackoverflow.com/users/29638",
"pm_score": 0,
"selected": false,
"text": "<p>What is the source for the \"Emails\" collection? If it is from your database, you'd get much better performanc... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320523",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36544/"
] | I have a loop on page to update an access database that takes 15-20 seconds to complete. I only run it once a month at most but I noticed that every time I run it the web site (IIS 6) simply stops serving pages.
After the loop ends, pages begin opening again.
Here's my code:
```
For each Email in Emails
if Trim(... | You are probably using up all the available connections in the connection pool. Try this instead:
```
Set MM_editCmd = Server.CreateObject("ADODB.Command")
MM_editCmd.ActiveConnection = MM_Customers_STRING
For each Email in Emails
if Trim(Email) <> "" then
' execute the update
MM_editCmd.CommandTex... |
320,532 | <p>How can I simplify a basic arithmetic expression?</p>
<p>e.g.</p>
<pre><code>module ExprOps where
simplify :: Expr -> Expr
simplify (Plus(Var"x") (Const 0)) = Var "x"
</code></pre>
<p>What do I have to do?</p>
<hr>
<pre><code>module Expr where
-- Variables are named by strings, assumed to be identifiers.
... | [
{
"answer_id": 320576,
"author": "bugmagnet",
"author_id": 426,
"author_profile": "https://Stackoverflow.com/users/426",
"pm_score": 0,
"selected": false,
"text": "<p>Are we talking rationals here, like GMP's rationals? If so, then one could simplify a division by making the second argum... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320532",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41000/"
] | How can I simplify a basic arithmetic expression?
e.g.
```
module ExprOps where
simplify :: Expr -> Expr
simplify (Plus(Var"x") (Const 0)) = Var "x"
```
What do I have to do?
---
```
module Expr where
-- Variables are named by strings, assumed to be identifiers.
type Variable = String
-- Representation of exp... | Well, you have the right general model. You just need more rules and to recursively apply the simplification process.
```
simplify :: Expr -> Expr
simplify (Mult (Const 0) x) = Const 0
simplify (Mult x (Const 0)) = Const 0
simplify (Plus (Const 0) x) = simplify x
simplify (Plus x (Const 0)) = simplify x
simplify (M... |
320,535 | <p>Edit: Closing this because i've found the reason why it's erroring, but instead of removing this post .. i generate a newer post with a more refined question.</p>
<hr>
<p>Hi folks,</p>
<p>i have some binary data i've read in. i wish to convert it to an <code>System.Drawing.Image</code>, so i create an instance of... | [
{
"answer_id": 320561,
"author": "Ovidiu Pacurar",
"author_id": 28419,
"author_profile": "https://Stackoverflow.com/users/28419",
"pm_score": 2,
"selected": false,
"text": "<p>Just tested your code, it worked, the code is fine. There must be a problem with the image file or path.\nThis i... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320535",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30674/"
] | Edit: Closing this because i've found the reason why it's erroring, but instead of removing this post .. i generate a newer post with a more refined question.
---
Hi folks,
i have some binary data i've read in. i wish to convert it to an `System.Drawing.Image`, so i create an instance of an `Image object`, using a `... | Just tested your code, it worked, the code is fine. There must be a problem with the image file or path.
This is my test:
```
private void Form1_Load(object sender, EventArgs e)
{
byte[] data = File.ReadAllBytes("c:\\t.jpg");
using (Stream originalBinaryDataStream = new MemoryStrea... |
320,542 | <p>My code runs inside a JAR file, say <strong>foo.jar</strong>, and I need to know, in the code, in which folder the running <strong>foo.jar</strong> is.</p>
<p>So, if <strong>foo.jar</strong> is in <code>C:\FOO\</code>, I want to get that path no matter what my current working directory is.</p>
| [
{
"answer_id": 320554,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 5,
"selected": false,
"text": "<p>Use ClassLoader.getResource() to find the URL for your current class.</p>\n\n<p>For example:</p>\n\n<pre><code>packag... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320542",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16873/"
] | My code runs inside a JAR file, say **foo.jar**, and I need to know, in the code, in which folder the running **foo.jar** is.
So, if **foo.jar** is in `C:\FOO\`, I want to get that path no matter what my current working directory is. | ```
return new File(MyClass.class.getProtectionDomain().getCodeSource().getLocation()
.toURI()).getPath();
```
Replace "MyClass" with the name of your class.
Obviously, this will do odd things if your class was loaded from a non-file location. |
320,567 | <p>How can I simplify an expression using basic arithmetic?</p>
| [
{
"answer_id": 320589,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 1,
"selected": false,
"text": "<p>You can use the technique described here: <a href=\"http://augustss.blogspot.com/2007/04/overloading-has... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320567",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41000/"
] | How can I simplify an expression using basic arithmetic? | I'm not sure what you mean, but if you have an expression datatype you can define a recursive eval-function. In this case eval means simplify.
For example,
```
data Exp = Lit Int
| Plus Exp Exp
| Times Exp Exp
eval :: Exp -> Int
eval (Lit x) = x
eval (Plus x y) = eval x + eval y
eval (Times x ... |
320,588 | <p>I'm looking at some open source Java projects to get into Java and notice a lot of them have some sort of 'constants' interface.</p>
<p>For instance, <a href="http://www.processing.org" rel="noreferrer">processing.org</a> has an interface called <a href="http://dev.processing.org/source/index.cgi/tags/processing-1.... | [
{
"answer_id": 320601,
"author": "gizmo",
"author_id": 9396,
"author_profile": "https://Stackoverflow.com/users/9396",
"pm_score": -1,
"selected": false,
"text": "<p>This came from a time before Java 1.5 exists and bring enums to us. Prior to that, there was no good way to define a set o... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320588",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13466/"
] | I'm looking at some open source Java projects to get into Java and notice a lot of them have some sort of 'constants' interface.
For instance, [processing.org](http://www.processing.org) has an interface called [PConstants.java](http://dev.processing.org/source/index.cgi/tags/processing-1.0/core/src/processing/core/PC... | It's generally considered bad practice. The problem is that the constants are part of the public "interface" (for want of a better word) of the implementing class. This means that the implementing class is publishing all of these values to external classes even when they are only required internally. The constants prol... |
320,590 | <p>I'm trying to add a special markup to Python documentation strings in emacs (python-mode).</p>
<p>Currently I'm able to extract a single line with:</p>
<pre><code>(font-lock-add-keywords
'python-mode
'(("\\(\"\\{3\\}\\.+\"\\{3\\}\\)"
1 font-lock-doc-face prepend)))
</code></pre>
<p>This works now:</p>
<pre... | [
{
"answer_id": 320755,
"author": "huaiyuan",
"author_id": 16240,
"author_profile": "https://Stackoverflow.com/users/16240",
"pm_score": 2,
"selected": false,
"text": "<pre><code>\"\\\\(\\\"\\\\{3\\\\}\\\\(.*\\n?\\\\)*?\\\"\\\\{3\\\\}\\\\)\"\n</code></pre>\n\n<p>The \"*?\" construct is th... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320590",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34020/"
] | I'm trying to add a special markup to Python documentation strings in emacs (python-mode).
Currently I'm able to extract a single line with:
```
(font-lock-add-keywords
'python-mode
'(("\\(\"\\{3\\}\\.+\"\\{3\\}\\)"
1 font-lock-doc-face prepend)))
```
This works now:
```
"""Foo"""
```
But as soon there is ... | ```
"\\(\"\\{3\\}\\(.*\n?\\)*?\"\\{3\\}\\)"
```
The "\*?" construct is the non-greedy version of "\*". |
320,600 | <p>I have a library consisting of approx 100 source files. I want one of the sources to be always rebuilt if any of the other files have been compiled but I don't want it built every time I run the make/build.</p>
<p>Basically I want this file to have the last build date/time built into it so any application linking t... | [
{
"answer_id": 320623,
"author": "JesperE",
"author_id": 13051,
"author_profile": "https://Stackoverflow.com/users/13051",
"pm_score": 3,
"selected": false,
"text": "<p>Let the object file containing the build timestamp depend on all the other object files:</p>\n\n<pre><code>version.o: $... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320600",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3685/"
] | I have a library consisting of approx 100 source files. I want one of the sources to be always rebuilt if any of the other files have been compiled but I don't want it built every time I run the make/build.
Basically I want this file to have the last build date/time built into it so any application linking to the libr... | To expand slightly on JesperE's solution.
Let the object file depend on all targets which the executable depends on, (excluding itself).
So if all the executable depends on is objects, then JesperE is completely correct.
Otherwise, you could rebuild the executable without updating the timestamp, in the case where on... |
320,618 | <p>I am currently doing some socket programming using C/C++. To be able to use a somewhat cleaner interface, and a more OO structure, I decided to write a few simple wrapper classes around parts of the C socket API, but while doing so I stumbled upon a problem:</p>
<p>Given the following code:</p>
<pre><code>// Globa... | [
{
"answer_id": 320626,
"author": "jab",
"author_id": 20367,
"author_profile": "https://Stackoverflow.com/users/20367",
"pm_score": 2,
"selected": false,
"text": "<p>You must use the scope resolution try:</p>\n\n<p>::foo(1);</p>\n"
},
{
"answer_id": 320627,
"author": "Johannes... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320618",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/276/"
] | I am currently doing some socket programming using C/C++. To be able to use a somewhat cleaner interface, and a more OO structure, I decided to write a few simple wrapper classes around parts of the C socket API, but while doing so I stumbled upon a problem:
Given the following code:
```
// Global method
int foo(int ... | The problem is that it first looks in the scope of your class, and finds a foo function. The lookup will stop then, and the compiler tries to match arguments. Since it only has the one foo function in that scope in your class, calling the function fails.
You need to explicitly state that you want to call the free func... |
320,629 | <p>if i have :</p>
<pre><code><div class="carBig"></div>
</code></pre>
<p>and</p>
<pre><code><div class="car"></div>
</code></pre>
<p>and $(".car").size();</p>
<p>i get 2 items ..</p>
| [
{
"answer_id": 320666,
"author": "BrianH",
"author_id": 40619,
"author_profile": "https://Stackoverflow.com/users/40619",
"pm_score": 2,
"selected": false,
"text": "<p>What version of jquery are you using?</p>\n\n<p>Using this code:</p>\n\n<pre><code><html><head><title>... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320629",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1409636/"
] | if i have :
```
<div class="carBig"></div>
```
and
```
<div class="car"></div>
```
and $(".car").size();
i get 2 items .. | I think you may have something funky somewhere that's throwing it off. If I run this very simple example, it works just as expected.
```
<html>
<head>
</head>
<script type="text/javascript" src="jquery-1.2.6.pack.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$(".car").hide();... |
320,636 | <p>I have a class 'Database' that works as a wrapper for ADO.net. For instance, when I need to execute a procedure, I call Database.ExecuteProcedure(procedureName, parametersAndItsValues).</p>
<p>We are experiencing serious problems with Deadlock situations in SQL Server 2000. Part of our team is working on the sql co... | [
{
"answer_id": 320661,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 2,
"selected": false,
"text": "<p>If you are getting problems with deadlocks, it would be better to look at what the SQL code is doing. For example,... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320636",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21668/"
] | I have a class 'Database' that works as a wrapper for ADO.net. For instance, when I need to execute a procedure, I call Database.ExecuteProcedure(procedureName, parametersAndItsValues).
We are experiencing serious problems with Deadlock situations in SQL Server 2000. Part of our team is working on the sql code and tra... | First, I would review my SQL 2000 code and get to the bottom of why this deadlock is happening. Fixing this may be hiding a bigger problem (Eg. missing index or bad query).
Second I would review my architecture to confirm the deadlocking statement really needs to be called that frequently (Does `select count(*) from ... |
320,645 | <p>I want to programmatically verify the status of an application to see if it has crashed or stopped. I know how to see if the process exists in C# but can I also see if it is "Not responding"?</p>
| [
{
"answer_id": 320658,
"author": "bugmagnet",
"author_id": 426,
"author_profile": "https://Stackoverflow.com/users/426",
"pm_score": 0,
"selected": false,
"text": "<p>See <a href=\"http://discuss.fogcreek.com/dotnetquestions/default.asp?cmd=show&ixPost=6167\" rel=\"nofollow noreferre... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320645",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9077/"
] | I want to programmatically verify the status of an application to see if it has crashed or stopped. I know how to see if the process exists in C# but can I also see if it is "Not responding"? | Everything you need is in System.Diagnostics, for example: to check if a process is responding.
```
using System;
using System.Diagnostics;
namespace ProcessStatus
{
class Program
{
static void Main(string[] args)
{
Process[] processes = Process.GetProcesses();
foreach... |
320,659 | <p>I was using an mxml class but since i need to pass some properties at construction time, to make it easier i will convert it to as3 code.</p>
<p>The class is RectangleShape and it just draws a rectangle.</p>
<p><strong>Original mxml working</strong></p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<... | [
{
"answer_id": 320792,
"author": "coulix",
"author_id": 32032,
"author_profile": "https://Stackoverflow.com/users/32032",
"pm_score": 0,
"selected": false,
"text": "<p>I think i pinpointed the problem.\nBefore in the mxml version we had</p>\n\n<p>width=\"{width}\"\nheight=\"{height}\"</p... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320659",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32032/"
] | I was using an mxml class but since i need to pass some properties at construction time, to make it easier i will convert it to as3 code.
The class is RectangleShape and it just draws a rectangle.
**Original mxml working**
```
<?xml version="1.0" encoding="utf-8"?>
<BaseShape name="rectangle"
xmlns="org.edorado.... | Try setting up the bindings with the BindingUtils class.
For example:
```
BindingUtils.bindProperty(component, "height", this, "height");
``` |
320,692 | <p>Is it possible to create an XML Schema which imposes a co-occurrence constraint to an attribute/element pair?</p>
<pre><code><primitive-list>
<primitive name="P1">
<definition><!-- primitive specification --></definition>
</primitive>
<primitive name="P2"&g... | [
{
"answer_id": 320744,
"author": "Mitchel Sellers",
"author_id": 13279,
"author_profile": "https://Stackoverflow.com/users/13279",
"pm_score": 0,
"selected": false,
"text": "<p>Yes, this is possible. When creating your XML Schema, you will be creating a complex type for each scenario, b... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320692",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31993/"
] | Is it possible to create an XML Schema which imposes a co-occurrence constraint to an attribute/element pair?
```
<primitive-list>
<primitive name="P1">
<definition><!-- primitive specification --></definition>
</primitive>
<primitive name="P2">
<definition><!-- primitive specification --><... | After searching on the Internet and digging in some books I figured out how to implement that.
First of all we need to define a generic type which accommodates all attributes and elements from both kinds of the **primitive** element. It is assumed that the **definition** element is defined somewhere else.
```
<xs:com... |
320,693 | <p>Is it possible to checkout only those files from a SVN repository that were modified in a revision or range of revisions, without checking out any files that were not modified? </p>
| [
{
"answer_id": 320706,
"author": "Drejc",
"author_id": 6482,
"author_profile": "https://Stackoverflow.com/users/6482",
"pm_score": 0,
"selected": false,
"text": "<p>I'm not completly sure if this is possible but you can also do something like this:</p>\n\n<pre><code>svn checkout --revisi... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320693",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8952/"
] | Is it possible to checkout only those files from a SVN repository that were modified in a revision or range of revisions, without checking out any files that were not modified? | My suggestion is in the same lines as flolo suggests. But, takes a range.
You could the following shell function.
```
function checkout_files_in_revrange()
{
svn_url=$1;
start_rev=$2;
end_rev=$3;
for theCheckoutCanditate in `svn log -r $start_rev:$end_rev --verbose --incremental | grep " M " | cut -f5 -d' ' ... |
320,759 | <p>A bit of background first:</p>
<ul>
<li><p>I am using "base" code from a remote SVN repository, not under my control. The code is not tagged (yet), so I always need to keep up with the trunk. </p></li>
<li><p>For a number of reasons (the most important being that our local extensions to the code are of a "niche" na... | [
{
"answer_id": 320771,
"author": "boutta",
"author_id": 15108,
"author_profile": "https://Stackoverflow.com/users/15108",
"pm_score": 2,
"selected": false,
"text": "<p>You can have your local repository where you commit your changes, as you already have done. Further you would do a perio... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320759",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30859/"
] | A bit of background first:
* I am using "base" code from a remote SVN repository, not under my control. The code is not tagged (yet), so I always need to keep up with the trunk.
* For a number of reasons (the most important being that our local extensions to the code are of a "niche" nature, and intended to solve a sp... | I did this using git svn, with my development done in a git repository. The remote development is done in subversion. I made a git svn clone of the subversion repository, which I push to a real git repository. A cronjob runs "git svn rebase && git push" every now and again to create a git mirror of the subversion repo.... |
320,761 | <p>Environment: </p>
<blockquote>
<p>win2003 running IIS6 serving asp pages that call delphi code.</p>
</blockquote>
<p>Delphi code contacts a <strong>c# webservice</strong> for which it needs to login (<code>login.asmx</code>). Webservice logs show login is successful. Debug results show that <code>Context.User.Id... | [
{
"answer_id": 320771,
"author": "boutta",
"author_id": 15108,
"author_profile": "https://Stackoverflow.com/users/15108",
"pm_score": 2,
"selected": false,
"text": "<p>You can have your local repository where you commit your changes, as you already have done. Further you would do a perio... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320761",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Environment:
>
> win2003 running IIS6 serving asp pages that call delphi code.
>
>
>
Delphi code contacts a **c# webservice** for which it needs to login (`login.asmx`). Webservice logs show login is successful. Debug results show that `Context.User.Identity.IsAuthenticated returns true`.
After login, delphi co... | I did this using git svn, with my development done in a git repository. The remote development is done in subversion. I made a git svn clone of the subversion repository, which I push to a real git repository. A cronjob runs "git svn rebase && git push" every now and again to create a git mirror of the subversion repo.... |
320,782 | <p>I find that in my daily Flex/Flash work, I do this number a lot:</p>
<pre><code>//Calling a function...
MyCustomObject(container.getChildAt(i)).mySpecialFunction();
</code></pre>
<p>The question is - is this the best way to do this? Should I do this:</p>
<pre><code>//Calling a function
var tempItem:MyCustomObjec... | [
{
"answer_id": 321232,
"author": "RickDT",
"author_id": 5421,
"author_profile": "https://Stackoverflow.com/users/5421",
"pm_score": 3,
"selected": true,
"text": "<p>It generally doesn't matter. Creating a var just creates a pointer to the object, so it's not using more memory or anythin... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320782",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3435/"
] | I find that in my daily Flex/Flash work, I do this number a lot:
```
//Calling a function...
MyCustomObject(container.getChildAt(i)).mySpecialFunction();
```
The question is - is this the best way to do this? Should I do this:
```
//Calling a function
var tempItem:MyCustomObject = container.getChildAt(i) as MyCusto... | It generally doesn't matter. Creating a var just creates a pointer to the object, so it's not using more memory or anything like that.
The second example is definitely more readable and debuggable and should thus be preferred.
The risk you run from creating temp vars is that you might delay or prevent garbage collect... |
320,797 | <p>Using a macro I have consolidated info from several workbooks into one sheet in new workbook.</p>
<p>In one column I have created a named range called ColRange. That column has numbers ranging from -350 to 500.</p>
<p>How do I change the color of the cells based on the value of the text in the cell.<br>
red(0-50... | [
{
"answer_id": 320851,
"author": "Vincent Ramdhanie",
"author_id": 27439,
"author_profile": "https://Stackoverflow.com/users/27439",
"pm_score": 0,
"selected": false,
"text": "<p>Assume that value is the number stored in the column then:</p>\n\n<pre><code>If value >= 0 AND value <=... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320797",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Using a macro I have consolidated info from several workbooks into one sheet in new workbook.
In one column I have created a named range called ColRange. That column has numbers ranging from -350 to 500.
How do I change the color of the cells based on the value of the text in the cell.
red(0-500)
yellow(-5-0)
gre... | Have a look at [conditional formatting](http://www.wikihow.com/Apply-Conditional-Formatting-in-Excel). You may not even need VBA to do this.
That being said, the VBA code would look something like this:
```
Public Sub colorit()
Dim colRange As Range
Dim rowNum As Integer
Dim rnum As Integer
rnum = 20... |
320,798 | <p>Is it acceptable to add types to the <code>std</code> namespace. For example, I want a TCHAR-friendly string, so is the following acceptable?</p>
<pre><code>#include <string>
namespace std
{
typedef basic_string<TCHAR> tstring;
}
</code></pre>
<p>Or should I use my own namespace?</p>
| [
{
"answer_id": 320804,
"author": "Klaim",
"author_id": 2368,
"author_profile": "https://Stackoverflow.com/users/2368",
"pm_score": 2,
"selected": false,
"text": "<p>You should use your own namespace as adding code to the standard library will only confuse the users that will look online ... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320798",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9236/"
] | Is it acceptable to add types to the `std` namespace. For example, I want a TCHAR-friendly string, so is the following acceptable?
```
#include <string>
namespace std
{
typedef basic_string<TCHAR> tstring;
}
```
Or should I use my own namespace? | No ... part of the point of a namespace is to prevent name collisions on upgrade.
If you add things to the std namespace, then your code might break with the next release of the library if they decide to add something with the same name. |
320,801 | <p>I'm developing a new ASP .NET website which is effectively a subset of the pages in another site we've just released. Two or three of the pages will need minor tweaks but nothing significant.</p>
<p>The obvious answer is to simply copy all of the code and markup files into the new project, make the aforementioned t... | [
{
"answer_id": 320809,
"author": "Winston Smith",
"author_id": 35086,
"author_profile": "https://Stackoverflow.com/users/35086",
"pm_score": 0,
"selected": false,
"text": "<p>Why not create user controls (or custom controls) from the pages which you wish to share? You can then re-use the... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320801",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12277/"
] | I'm developing a new ASP .NET website which is effectively a subset of the pages in another site we've just released. Two or three of the pages will need minor tweaks but nothing significant.
The obvious answer is to simply copy all of the code and markup files into the new project, make the aforementioned tweaks, and... | You might want to take a look at the MVP pattern. Since you are probably using WebForms it would be hard to migrate to ASP.Net MVC, but you could implement MVP pretty easily into existing apps.
On a basic level you would move all the business logic into a Presenter class that has a View that represents some sort of in... |
320,841 | <p>I have a question about css selectors.</p>
<p>Say I have the following html </p>
<pre><code><div class="message">
<div class="messageheader">
<div class='name'>A news story</div>
</div>
</div>
</code></pre>
<p>In the css I could refer to the <code>class</code> called <c... | [
{
"answer_id": 320858,
"author": "Jeremy B.",
"author_id": 28567,
"author_profile": "https://Stackoverflow.com/users/28567",
"pm_score": 2,
"selected": false,
"text": "<p>If you are only interested in the initial scenario using .name is just fine. In fact, best practice with CSS is to a... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320841",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31765/"
] | I have a question about css selectors.
Say I have the following html
```
<div class="message">
<div class="messageheader">
<div class='name'>A news story</div>
</div>
</div>
```
In the css I could refer to the `class` called `name` either like this
```
div.message div.messageheader div.name {}
```
or
`... | If you are only interested in the initial scenario using .name is just fine. In fact, best practice with CSS is to always start more generic and focus as you go.
also, doing things like div.\* are unnecessary unless you have the same class on a different element and want to make them different. If you are nesting cla... |
320,861 | <p>I have a class <code>Application</code> that my global.asax inherits from. The class has this method:</p>
<pre><code>protected void Application_Start(object sender, EventArgs e)
{
// ...
}
</code></pre>
<p>In my understanding this is basically an event handler that is automatically added to an event (based on ... | [
{
"answer_id": 320926,
"author": "Rune Grimstad",
"author_id": 30366,
"author_profile": "https://Stackoverflow.com/users/30366",
"pm_score": 4,
"selected": true,
"text": "<p>HttpApplicationFactory is an internal class defined in System.Web.dll. \nYou can check it out in .NET Reflector if... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320861",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4830/"
] | I have a class `Application` that my global.asax inherits from. The class has this method:
```
protected void Application_Start(object sender, EventArgs e)
{
// ...
}
```
In my understanding this is basically an event handler that is automatically added to an event (based on the method name [\*]). I tried to fin... | HttpApplicationFactory is an internal class defined in System.Web.dll.
You can check it out in .NET Reflector if you are interested.
Internal means that it is not normally visible outside the dll where it is defined, so you can't use it in your own code. |
320,894 | <p>I have an Access 2002 application which links an Oracle table via ODBC with this code:</p>
<pre><code>Set HRSWsp = CreateWorkspace("CONNODBC", "", "", dbUseODBC)
Set HRSConn = HRSWsp.OpenConnection("HRSCONN", dbDriverPrompt, , "ODBC;")
DoCmd.TransferDatabase acLink, "Database ODBC", HRSConn.Connect, acTable, "SCHEM... | [
{
"answer_id": 322809,
"author": "Patrick Cuff",
"author_id": 7903,
"author_profile": "https://Stackoverflow.com/users/7903",
"pm_score": -1,
"selected": false,
"text": "<p>Try this:</p>\n\n<pre><code>Dim tbl As New ADOX.Table\nDim cat As New ADOX.Catalog\n\ncat.ActiveConnection = _\n ... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320894",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1005/"
] | I have an Access 2002 application which links an Oracle table via ODBC with this code:
```
Set HRSWsp = CreateWorkspace("CONNODBC", "", "", dbUseODBC)
Set HRSConn = HRSWsp.OpenConnection("HRSCONN", dbDriverPrompt, , "ODBC;")
DoCmd.TransferDatabase acLink, "Database ODBC", HRSConn.Connect, acTable, "SCHEMA.TABLE", "TAB... | I found that I could solve my problem in a very simple way, by deleting the first two statements and modifying the third this way:
```
DoCmd.TransferDatabase acLink, "ODBC Database", "ODBC;DRIVER=Microsoft ODBC for Oracle;SERVER=myserver;UID=myuser;PWD=mypassword", acTable, "SCHEMA.TABLE", "TABLE", False, True
```
T... |
320,895 | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/167304/is-it-possible-to-pivot-data-using-linq">Is it possible to Pivot data using LINQ?</a> </p>
</blockquote>
<p>I'm wondering if its at all possible to create crosstab style results with Linq.
I have some da... | [
{
"answer_id": 320984,
"author": "David",
"author_id": 39552,
"author_profile": "https://Stackoverflow.com/users/39552",
"pm_score": 1,
"selected": false,
"text": "<p>After doing a quick search you might want to look at the ModuleBuilder, TypeBuilder, and FieldBuilder classes in System.R... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320895",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | >
> **Possible Duplicate:**
>
> [Is it possible to Pivot data using LINQ?](https://stackoverflow.com/questions/167304/is-it-possible-to-pivot-data-using-linq)
>
>
>
I'm wondering if its at all possible to create crosstab style results with Linq.
I have some data that looks like the following:
```
var list... | You need a runtimy class to hold these runtimy results. How about xml?
```
XElement result = new XElement("result",
list.GroupBy(i => i.GroupId)
.Select(g =>
new XElement("Group", new XAttribute("GroupID", g.Key),
g.Select(i => new XAttribute(i.Country, i.Value))
)
)
);
```
Are you expecting mult... |
320,906 | <p>I am using a piece of html something like the following:-</p>
<pre><code><a class="somePseudoClass" title="Blablabla">Something</a>
</code></pre>
<p>and I have the following css in an imported file.</p>
<pre><code>a.somePseudoClass:hover {color: #000000; text-decoration: underline;}
</code></pre>
... | [
{
"answer_id": 320916,
"author": "scunliffe",
"author_id": 6144,
"author_profile": "https://Stackoverflow.com/users/6144",
"pm_score": 0,
"selected": false,
"text": "<p>this should work, but it depends on what other CSS declarations you have (before and after it)</p>\n"
},
{
"ans... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320906",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am using a piece of html something like the following:-
```
<a class="somePseudoClass" title="Blablabla">Something</a>
```
and I have the following css in an imported file.
```
a.somePseudoClass:hover {color: #000000; text-decoration: underline;}
```
This works perfectly in Firefox 2.0 but in IE6 the underl... | Looks like you need a href attribute to make it work...
```
a.somePseudoClass {text-decoration: none;}
a.somePseudoClass:hover {color: #000000; text-decoration: underline;}
<a class="somePseudoClass" title="Blablabla" href="#" onclick="return false;">Something</a>
``` |
320,921 | <p>I would like to modify an MSI installer (created through <a href="http://en.wikipedia.org/wiki/WiX" rel="noreferrer">WiX</a>) to delete an entire directory on uninstall.</p>
<p>I understand the <code>RemoveFile</code> and <code>RemoveFolder</code> options in WiX, but these are not robust enough to recursively delet... | [
{
"answer_id": 321721,
"author": "csexton",
"author_id": 19839,
"author_profile": "https://Stackoverflow.com/users/19839",
"pm_score": 6,
"selected": false,
"text": "<p>You can do this with a custom action. You can add a refrence to your custom action under <code><InstallExecuteSeque... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320921",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I would like to modify an MSI installer (created through [WiX](http://en.wikipedia.org/wiki/WiX)) to delete an entire directory on uninstall.
I understand the `RemoveFile` and `RemoveFolder` options in WiX, but these are not robust enough to recursively delete an entire folder that has content created after the instal... | **EDIT**: Perhaps look at the answer [currently immediately below](https://stackoverflow.com/a/17608049/286021).
---
This topic has been a headache for long time. I finally figured it out.
There are some solutions online, but none of them really works. And of course there is no documentation.
So in the chart below th... |
320,929 | <p>I am looking to format a number like 188518982.18 to £188,518,982.18 using Python.</p>
<p>How can I do this?</p>
| [
{
"answer_id": 320951,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 9,
"selected": true,
"text": "<p>See the <a href=\"https://docs.python.org/3/library/locale.html\" rel=\"noreferrer\">locale</a> module.</p>\n<p>This does... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320929",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30786/"
] | I am looking to format a number like 188518982.18 to £188,518,982.18 using Python.
How can I do this? | See the [locale](https://docs.python.org/3/library/locale.html) module.
This does currency (and date) formatting.
```
>>> import locale
>>> locale.setlocale( locale.LC_ALL, '' )
'English_United States.1252'
>>> locale.currency( 188518982.18 )
'$188518982.18'
>>> locale.currency( 188518982.18, grouping=True )
'$188,51... |
320,946 | <p>The Replace Temp with Query refactoring method is recommended quite widely now but
seems to be very inefficient for very little gain. </p>
<p>The method from the Martin Fowler's site gives the following example:</p>
<p>Extract the expression into a method. Replace all references to the temp with the expression. T... | [
{
"answer_id": 320983,
"author": "MikeJ",
"author_id": 10676,
"author_profile": "https://Stackoverflow.com/users/10676",
"pm_score": 2,
"selected": false,
"text": "<p>It's intended to be more revealing of the intention of the code. In some cases it can be abused but not likely. for examp... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320946",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | The Replace Temp with Query refactoring method is recommended quite widely now but
seems to be very inefficient for very little gain.
The method from the Martin Fowler's site gives the following example:
Extract the expression into a method. Replace all references to the temp with the expression. The new method can... | It's a refactoring that is important as it is a refactoring towards single responsibility, it's a resolution of DRY fail!
The main problem with temps (esp. in naive code using long methods, hundreds of lines long!) is that they are mutable, local state. The obvious risk (as discussed by Fowler?) is that someone might... |
320,948 | <pre><code>Type.GetType("System.String")
</code></pre>
<p>Is there a lookup for the aliases available somewhere?</p>
<pre><code>Type.GetType("string")
</code></pre>
<p>returns <code>null</code>.</p>
| [
{
"answer_id": 320954,
"author": "Barry Kelly",
"author_id": 3712,
"author_profile": "https://Stackoverflow.com/users/3712",
"pm_score": 2,
"selected": false,
"text": "<p>The \"aliases\" are part of the language definition. You need to look them up in the <a href=\"http://msdn.microsoft.... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320948",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21909/"
] | ```
Type.GetType("System.String")
```
Is there a lookup for the aliases available somewhere?
```
Type.GetType("string")
```
returns `null`. | This is not possible programmatically, since the 'aliases' are in fact keywords introduced in C#, and `Type.GetType` (like every other framework method) is part of the language-independent framework.
You could create a dictionary with the following values:
```
bool System.Boolean
byte System.Byte
... |
320,950 | <p>I have seen the error "The ';' character, hexadecimal value 0x3B, cannot be included in a name." in my log files for an ASP.NET Web App. The url that's logged looks something like this:</p>
<pre><code>mypage.aspx?paramone=one+two&amp;paramtwo=zero+1
</code></pre>
<p>So my first question is what type of system/... | [
{
"answer_id": 321149,
"author": "Alnitak",
"author_id": 6782,
"author_profile": "https://Stackoverflow.com/users/6782",
"pm_score": 1,
"selected": false,
"text": "<ol>\n<li><p>Your web server should be able to log the \"user agent\" field from the HTTP Request, which should enable you t... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320950",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1463/"
] | I have seen the error "The ';' character, hexadecimal value 0x3B, cannot be included in a name." in my log files for an ASP.NET Web App. The url that's logged looks something like this:
```
mypage.aspx?paramone=one+two&paramtwo=zero+1
```
So my first question is what type of system/browser is encoding the origin... | 1. Your web server should be able to log the "user agent" field from the HTTP Request, which should enable you to identify the culprit.
2. Don't fix it - there's a very well defined set of legal syntaxes for URI parameters, and this ain't one of them. |
320,959 | <p>I need to <strong>disable PUT, DELETE & TRACE HTTP requests</strong> on my Application Server, Apache Tomcat 6.0.</p>
<p>All other sources, i have searched till now, have directed me towards the limit parameter in <em>httpd.conf</em>, Hence I'd put it before-hand that I am not using Apache Web Server, and reque... | [
{
"answer_id": 321069,
"author": "James Schek",
"author_id": 17871,
"author_profile": "https://Stackoverflow.com/users/17871",
"pm_score": 5,
"selected": true,
"text": "<p>Inside your WEBINF, add you can add a security constraint:</p>\n\n<pre class=\"lang-xml prettyprint-override\"><code... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320959",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18615/"
] | I need to **disable PUT, DELETE & TRACE HTTP requests** on my Application Server, Apache Tomcat 6.0.
All other sources, i have searched till now, have directed me towards the limit parameter in *httpd.conf*, Hence I'd put it before-hand that I am not using Apache Web Server, and requests are directly being handled by ... | Inside your WEBINF, add you can add a security constraint:
```xml
<security-constraint>
<web-resource-collection>
<web-resource-name>Forbidden</web-resource-name>
<url-pattern>/blah/*</url-pattern>
<http-method>PUT</http-method>
<http-method>DELETE</http-method>
<... |
320,979 | <p>I need to have the output of a PHP snippet in a Plone site. It was delivered to be a small library that has a display() function, in PHP, that outputs a line of text. But I need to put it in a Plone site. Do you have any recommendations?</p>
<p>I was thinking a long the lines of having a display.php that just runs ... | [
{
"answer_id": 321123,
"author": "Reinout van Rees",
"author_id": 27401,
"author_profile": "https://Stackoverflow.com/users/27401",
"pm_score": 0,
"selected": false,
"text": "<p>Probably the easiest way: install <a href=\"http://plone.org/products/windowz\" rel=\"nofollow noreferrer\" ti... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320979",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6068/"
] | I need to have the output of a PHP snippet in a Plone site. It was delivered to be a small library that has a display() function, in PHP, that outputs a line of text. But I need to put it in a Plone site. Do you have any recommendations?
I was thinking a long the lines of having a display.php that just runs display() ... | Another option is to run the PHP script on the server using os.popen, then just printing the output. Quick and dirty example:
```
import os
print os.popen('php YourScript.php').read()
``` |
320,980 | <p><strong>What happens in the memory when a class instantiates the following object?</strong> </p>
<pre><code>public class SomeObject{
private String strSomeProperty;
public SomeObject(String strSomeProperty){
this.strSomeProperty = strSomeProperty;
}
public void setSomeProperty(String strSo... | [
{
"answer_id": 321060,
"author": "slim",
"author_id": 7512,
"author_profile": "https://Stackoverflow.com/users/7512",
"pm_score": 5,
"selected": true,
"text": "<p>Let's step through it:</p>\n\n<pre><code>SomeObject so1 = new SomeObject(\"some property value\");\n</code></pre>\n\n<p>... i... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320980",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37740/"
] | **What happens in the memory when a class instantiates the following object?**
```
public class SomeObject{
private String strSomeProperty;
public SomeObject(String strSomeProperty){
this.strSomeProperty = strSomeProperty;
}
public void setSomeProperty(String strSomeProperty){
this.s... | Let's step through it:
```
SomeObject so1 = new SomeObject("some property value");
```
... is actually more complicated than it looks, because you're creating a new String. It might be easier to think of as:
```
String tmp = new String("some property value");
SomeObject so1 = new SomeObject(tmp);
// Not that you wo... |
320,986 | <p>I am trying to set up a simple transaction for my Linq-to-Sql actions against my Sql 2000 database. Using TransactionScope it looks like this:</p>
<pre><code>using (TransactionScope transaction = new TransactionScope())
{
try
{
Store.DBDataContext dc = new Store.DBDataContext();
Store.P... | [
{
"answer_id": 321090,
"author": "Keith Sirmons",
"author_id": 1048,
"author_profile": "https://Stackoverflow.com/users/1048",
"pm_score": 4,
"selected": true,
"text": "<p>Take a look here: </p>\n\n<p>Fast transactions with System.Transactions and Microsoft SQL Server 2000\n<a href=\"ht... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320986",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3268/"
] | I am trying to set up a simple transaction for my Linq-to-Sql actions against my Sql 2000 database. Using TransactionScope it looks like this:
```
using (TransactionScope transaction = new TransactionScope())
{
try
{
Store.DBDataContext dc = new Store.DBDataContext();
Store.Product product ... | Take a look here:
Fast transactions with System.Transactions and Microsoft SQL Server 2000
<http://blogs.msdn.com/florinlazar/archive/2005/09/29/475546.aspx>
And here:
<http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=230390&SiteID=1>
>
> First verify the "Distribute Transaction Coordinator" Service is
> ... |
320,999 | <p>I wish to execute a javascript function after asp.net postback with out using ajax.</p>
<p>I've tried the following in my even method with no luck:</p>
<pre><code>Page.ClientScript.RegisterStartupScript(GetType(), "ShowPopup", "showCheckOutPopIn('Livraison',556);");
</code></pre>
| [
{
"answer_id": 321027,
"author": "Joel Martinez",
"author_id": 5416,
"author_profile": "https://Stackoverflow.com/users/5416",
"pm_score": 0,
"selected": false,
"text": "<p>I don't remember offhand what is the exact syntax/usage for the Page.ClientScript stuff ... that looks like it shou... | 2008/11/26 | [
"https://Stackoverflow.com/questions/320999",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18619/"
] | I wish to execute a javascript function after asp.net postback with out using ajax.
I've tried the following in my even method with no luck:
```
Page.ClientScript.RegisterStartupScript(GetType(), "ShowPopup", "showCheckOutPopIn('Livraison',556);");
``` | You should rather use the ScriptManager class, since the Page.ClientScript property is deprecated...
>
> The ClientScriptManager class is new in ASP.NET 2.0 and replaces Page class methods for managing scripts that are now deprecated.
>
> [Reference: MSDN - Page.ClientScript Property](http://msdn.microsoft.com/en-... |
321,000 | <p>I've learned that <a href="http://en.wikipedia.org/wiki/Static_scoping#Static_scoping_.28also_known_as_lexical_scoping.29" rel="noreferrer">static scoping</a> is the only sane way to do things, and that <a href="http://en.wikipedia.org/wiki/Static_scoping#Dynamic_scoping" rel="noreferrer">dynamic scoping</a> is the ... | [
{
"answer_id": 321056,
"author": "ddaa",
"author_id": 11549,
"author_profile": "https://Stackoverflow.com/users/11549",
"pm_score": 3,
"selected": false,
"text": "<p>Dynamic scoping is useful in some domain-specific languages. In particular, it can be handly in stylesheet languages. My e... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321000",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15055/"
] | I've learned that [static scoping](http://en.wikipedia.org/wiki/Static_scoping#Static_scoping_.28also_known_as_lexical_scoping.29) is the only sane way to do things, and that [dynamic scoping](http://en.wikipedia.org/wiki/Static_scoping#Dynamic_scoping) is the tool of the devil, and results only from poor implementatio... | Like everything else, Dynamic Scoping is merely a tool. Used well it can make certain tasks easier. Used poorly it can introduce bugs and headaches.
I can certainly see some uses for it. One can eliminate the need to pass variables to some functions.
For instance, I might set the display up at the beginning of the pr... |
321,024 | <p>I know python functions are virtual by default. Let's say I have this:</p>
<pre><code>class Foo:
def __init__(self, args):
do some stuff
def goo():
print "You can overload me"
def roo():
print "You cannot overload me"
</code></pre>
<p>I don't want them to be able to do this:</p>... | [
{
"answer_id": 321119,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 4,
"selected": false,
"text": "<p>Since Python has monkey patching, not only can you not make anything \"private\". Even if you could, someone could stil... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321024",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34395/"
] | I know python functions are virtual by default. Let's say I have this:
```
class Foo:
def __init__(self, args):
do some stuff
def goo():
print "You can overload me"
def roo():
print "You cannot overload me"
```
I don't want them to be able to do this:
```
class Aoo(Foo):
def ... | You can use a metaclass:
```
class NonOverridable(type):
def __new__(self, name, bases, dct):
if bases and "roo" in dct:
raise SyntaxError, "Overriding roo is not allowed"
return type.__new__(self, name, bases, dct)
class foo:
__metaclass__=NonOverridable
...
```
The metatype... |
321,034 | <p>My company currently evaluates the development of a Java FAT client. It should support a dynamic GUI and has as much logic as possible on the server side. Hence the idea came up to send the screen as XML to the FAT client, show it to the user and send the entered data similar to "html form" back in a structure like:... | [
{
"answer_id": 321049,
"author": "Draemon",
"author_id": 26334,
"author_profile": "https://Stackoverflow.com/users/26334",
"pm_score": 2,
"selected": false,
"text": "<p>\"It should support a dynamic GUI and has as much logic as possible on the server side.\"</p>\n\n<p>What you're describ... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321034",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33429/"
] | My company currently evaluates the development of a Java FAT client. It should support a dynamic GUI and has as much logic as possible on the server side. Hence the idea came up to send the screen as XML to the FAT client, show it to the user and send the entered data similar to "html form" back in a structure like:
`... | When I last looked for such a thing, two options were [Thinlet](http://www.thinlet.com/index.html) and [Apache Jelly](http://commons.apache.org/jelly/libs/swing/index.html).
The plus points were that you could separate the wiring and construction of your application from the behaviour. I'm not sure of the viability of... |
321,036 | <p>I have some funny deadlock caused by a stupid simple SQL UPDATE query, on a flat plain table, under default "READ COMMITED" transaction.</p>
<pre><code>UPDATE table SET column=@P1 WHERE PK=@P2
</code></pre>
<p>Column <code>PK</code> is <code>varchar(11)</code>, has a clustered index on it.
no trigger or table rela... | [
{
"answer_id": 321062,
"author": "Mitch Wheat",
"author_id": 16076,
"author_profile": "https://Stackoverflow.com/users/16076",
"pm_score": 3,
"selected": false,
"text": "<p>You have 2 options to reduce the lock escalation:</p>\n\n<p>1) add the WITH (ROWLOCK) hint to ask sql server to tak... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321036",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40214/"
] | I have some funny deadlock caused by a stupid simple SQL UPDATE query, on a flat plain table, under default "READ COMMITED" transaction.
```
UPDATE table SET column=@P1 WHERE PK=@P2
```
Column `PK` is `varchar(11)`, has a clustered index on it.
no trigger or table relation..etc on the table.
I did some check and fi... | I finally have to do a workaround by using cusror in a stored procedure.
But it is still interesting that how the PAGE lock happen and how to resolve.
---
After some more search on Google, there are some other people have the same problem and they(from MSDN forum) suggest to turn off the parallelism in SQL Server 20... |
321,055 | <p>I'm using a preformatted text file as a template for emails. The file has line breaks where I want them. I'd like to use this template to send a plain text email, but when I do I'm losing all formatting. Line breaks are stripped.</p>
<p>How do I parse this file and retain line breaks? I don't want to use a <code>&l... | [
{
"answer_id": 321132,
"author": "Russ",
"author_id": 32772,
"author_profile": "https://Stackoverflow.com/users/32772",
"pm_score": 2,
"selected": false,
"text": "<p>this is what I have done...</p>\n\n<p>I take a text, or HTML file, ( I'll show text, since its smaller, but the exact same... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321055",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26180/"
] | I'm using a preformatted text file as a template for emails. The file has line breaks where I want them. I'd like to use this template to send a plain text email, but when I do I'm losing all formatting. Line breaks are stripped.
How do I parse this file and retain line breaks? I don't want to use a `<pre>` tag becaus... | The code you show shouldn't strip any line breaks. The problem is probably on the email generation part. Could you show that part?
Is the mail's Content-Type: text/plain? |
321,061 | <p>The situation I'm trying to solve: in my Cocoa app, I need to encrypt a string with a symmetric cipher, POST it to PHP, and have that script decode the data. The process needs to work in reverse for returning an answer (PHP encodes, Cocoa decodes).</p>
<p>I'm missing something because even though I can get both th... | [
{
"answer_id": 321587,
"author": "Boaz Stuller",
"author_id": 1464654,
"author_profile": "https://Stackoverflow.com/users/1464654",
"pm_score": 3,
"selected": true,
"text": "<p>I think your problem is that the method of deriving the raw encryption key from the key string is different on ... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321061",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4233/"
] | The situation I'm trying to solve: in my Cocoa app, I need to encrypt a string with a symmetric cipher, POST it to PHP, and have that script decode the data. The process needs to work in reverse for returning an answer (PHP encodes, Cocoa decodes).
I'm missing something because even though I can get both the key and i... | I think your problem is that the method of deriving the raw encryption key from the key string is different on the two sides. The php md5() function returns a hexadecimal string, i.e 'a476c3...' which you are chopping down to the key size, while EVP\_BytesToKey() is a fairly complicated hash routine that return a raw b... |
321,067 | <p>This is in the context of <a href="http://en.wikipedia.org/wiki/Automatic_differentiation" rel="noreferrer">Automatic Differentiation</a> - what would such a system do with a function like <code>map</code>, or <code>filter</code> - or even one of the <a href="http://en.wikipedia.org/wiki/SKI_combinator_calculus" rel... | [
{
"answer_id": 321099,
"author": "Barry Kelly",
"author_id": 3712,
"author_profile": "https://Stackoverflow.com/users/3712",
"pm_score": 2,
"selected": true,
"text": "<p>Higher-order functions are discrete. They don't have the Cartesian quality of having arguments that have well-defined ... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321067",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15055/"
] | This is in the context of [Automatic Differentiation](http://en.wikipedia.org/wiki/Automatic_differentiation) - what would such a system do with a function like `map`, or `filter` - or even one of the [SKI Combinators](http://en.wikipedia.org/wiki/SKI_combinator_calculus)?
Example: I have the following function:
```
... | Higher-order functions are discrete. They don't have the Cartesian quality of having arguments that have well-defined mappings to points in some n-dimensional space.
However, with your clarification on the answer, there are several things that can be said. Symbolically differentiating some higher-order functions would... |
321,068 | <p>Is there a preferred way to return multiple values from a C++ function? For example, imagine a function that divides two integers and returns both the quotient and the remainder. One way I commonly see is to use reference parameters:</p>
<pre><code>void divide(int dividend, int divisor, int& quotient, int&... | [
{
"answer_id": 321075,
"author": "Mark",
"author_id": 37923,
"author_profile": "https://Stackoverflow.com/users/37923",
"pm_score": 2,
"selected": false,
"text": "<p>Alternatives include arrays, <a href=\"http://en.wikipedia.org/wiki/Generator_(computer_science)\" rel=\"nofollow noreferr... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321068",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10077/"
] | Is there a preferred way to return multiple values from a C++ function? For example, imagine a function that divides two integers and returns both the quotient and the remainder. One way I commonly see is to use reference parameters:
```
void divide(int dividend, int divisor, int& quotient, int& remainder);
```
A va... | For returning two values I use a `std::pair` (usually typedef'd). You should look at `boost::tuple` (in C++11 and newer, there's `std::tuple`) for more than two return results.
With introduction of structured binding in C++ 17, returning `std::tuple` should probably become accepted standard. |
321,077 | <p>I have an ASP.NET program where i am downloading a file from web using DownloadFile method of webClient Class and the do some modifications on it. then i am Saving it to another folder with a unique name.When I am getting this error</p>
<blockquote>
<p>The process cannot access the file 'D:\RD\dotnet\abc\abcimage... | [
{
"answer_id": 321088,
"author": "EBGreen",
"author_id": 1358,
"author_profile": "https://Stackoverflow.com/users/1358",
"pm_score": 0,
"selected": false,
"text": "<p>Are you explicitly closing the file stream after you make your changes?</p>\n"
},
{
"answer_id": 321163,
"aut... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321077",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40521/"
] | I have an ASP.NET program where i am downloading a file from web using DownloadFile method of webClient Class and the do some modifications on it. then i am Saving it to another folder with a unique name.When I am getting this error
>
> The process cannot access the file 'D:\RD\dotnet\abc\abcimageupload\images\TempSt... | Generally, I think your code should looking something like this.
```
WebClient wc = new WebClient();
wc.DownloadFile("http://stackoverflow.com/Content/Img/stackoverflow-logo-250.png", "Foo.png");
FileStream fooStream;
using (fooStream = new FileStream("foo.png", FileMode.Open))
{
// do stuff
}
File.Move("foo.png",... |
321,081 | <p>I have an xml file ('videofaq.xml') that defines a DTD using the following DOCTYPE</p>
<pre><code><!DOCTYPE video-faq SYSTEM "videofaq.dtd">
</code></pre>
<p>I am loading the file from the classpath (from a JAR actually) at Servlet initialization time using:</p>
<pre><code>getClass().getResourceAsStream("vi... | [
{
"answer_id": 321224,
"author": "Loki",
"author_id": 39057,
"author_profile": "https://Stackoverflow.com/users/39057",
"pm_score": 1,
"selected": false,
"text": "<p>When you do</p>\n\n<pre><code>getClass().getResourceAsStream(\"videofaq.xml\")\n</code></pre>\n\n<p>It's not xerces you ar... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321081",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41060/"
] | I have an xml file ('videofaq.xml') that defines a DTD using the following DOCTYPE
```
<!DOCTYPE video-faq SYSTEM "videofaq.dtd">
```
I am loading the file from the classpath (from a JAR actually) at Servlet initialization time using:
```
getClass().getResourceAsStream("videofaq.xml")
```
The XML is found correct... | A custom EntityResolver will work, but you might be able to avoid having to create a custom class by setting a SystemID to allow the processor to "find" relative paths.
<http://www.onjava.com/pub/a/onjava/excerpt/java_xslt_ch5/index.html?page=5>
>
> By providing a system identifier as a
> parameter to the StreamSou... |
321,096 | <p>If I'm using an ArrayList in C#.NET, is the order guaranteed to stay the same as the order I add items to it?</p>
| [
{
"answer_id": 321103,
"author": "Barry Kelly",
"author_id": 3712,
"author_profile": "https://Stackoverflow.com/users/3712",
"pm_score": 3,
"selected": false,
"text": "<p>Yes, it is, unless some piece of your code changes the order by e.g. swapping.</p>\n"
},
{
"answer_id": 32110... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321096",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2462/"
] | If I'm using an ArrayList in C#.NET, is the order guaranteed to stay the same as the order I add items to it? | Yes, elements are always added to the end (unless you specify otherwise, e.g. with a call to [Insert](http://msdn.microsoft.com/en-us/library/system.collections.arraylist.insert.aspx)). In other words, if you do:
```
int size = list.Count;
int index = list.Add(element);
Assert.AreEqual(size, index); // Element is alwa... |
321,109 | <p>I have my own linq to sql database with a nice login method which gives me back a user.</p>
<p>I have followed the 101 examples there on the web as to how to add the cookie to the client.</p>
<pre><code> FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
1,
... | [
{
"answer_id": 321440,
"author": "Chris James",
"author_id": 3193,
"author_profile": "https://Stackoverflow.com/users/3193",
"pm_score": 2,
"selected": false,
"text": "<p>This particular error was caused because I had the browser set to erase cookies when it was closed.</p>\n"
},
{
... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321109",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3193/"
] | I have my own linq to sql database with a nice login method which gives me back a user.
I have followed the 101 examples there on the web as to how to add the cookie to the client.
```
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
1,
_u.id.ToString(),
... | This particular error was caused because I had the browser set to erase cookies when it was closed. |
321,112 | <p>How would you run the Selenium process (thread) from a Java process so I don't have to start Selenium by hand?</p>
| [
{
"answer_id": 321243,
"author": "BraveSirFoobar",
"author_id": 39263,
"author_profile": "https://Stackoverflow.com/users/39263",
"pm_score": 4,
"selected": true,
"text": "<p>The server:</p>\n\n<pre><code>import org.openqa.selenium.server.SeleniumServer;\npublic class SeleniumServerContr... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321112",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6068/"
] | How would you run the Selenium process (thread) from a Java process so I don't have to start Selenium by hand? | The server:
```
import org.openqa.selenium.server.SeleniumServer;
public class SeleniumServerControl {
private static final SeleniumServerControl instance = new SeleniumServerControl();
public static SeleniumServerControl getInstance() {
return instance;
}
private SeleniumServer server = null;
protected ... |
321,113 | <p>I am trying to write a JavaScript function that will return its first argument(function) with all the rest of its arguments as preset parameters to that function.</p>
<p>So:</p>
<pre>function out(a, b) {
document.write(a + " " + b);
}
function setter(...) {...}
setter(out, "hello")("world");
setter(out, "hel... | [
{
"answer_id": 321133,
"author": "Peter Bailey",
"author_id": 8815,
"author_profile": "https://Stackoverflow.com/users/8815",
"pm_score": 2,
"selected": false,
"text": "<p>Is <a href=\"http://www.crockford.com/javascript/www_svendtofte_com/code/curried_javascript/index.html\" rel=\"nofol... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321113",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40397/"
] | I am trying to write a JavaScript function that will return its first argument(function) with all the rest of its arguments as preset parameters to that function.
So:
```
function out(a, b) {
document.write(a + " " + b);
}
function setter(...) {...}
setter(out, "hello")("world");
setter(out, "hello", "world")()... | First of all, you need a partial - [**there is a difference between a partial and a curry**](https://stackoverflow.com/questions/218025/what-is-the-difference-between-currying-and-partial-application) - and here is all you need, *without a framework*:
```
function partial(func /*, 0..n args */) {
var args = Array.pr... |
321,127 | <p>I have two simple tables in my database. A "card" table that contains Id, Name, and text of a card, and a "rulings" table which contains the Id of the card, and text detailing the rulings for the card.</p>
<p>Often enough in the ruling text, there is a reference to another card in the database. It is easy enough to... | [
{
"answer_id": 321194,
"author": "George Mastros",
"author_id": 1408129,
"author_profile": "https://Stackoverflow.com/users/1408129",
"pm_score": 1,
"selected": false,
"text": "<p>I would recommend that you create another table that stores your references. Then, create an insert and upd... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321127",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/71/"
] | I have two simple tables in my database. A "card" table that contains Id, Name, and text of a card, and a "rulings" table which contains the Id of the card, and text detailing the rulings for the card.
Often enough in the ruling text, there is a reference to another card in the database. It is easy enough to find this... | This seems like a fairly simple and common relational problem that is solved by a cross-reference table. For example:
```
CREATE TABLE dbo.Cards (
id INT NOT NULL,
name VARCHAR(50) NOT NULL,
card_text VARCHAR(4000) NOT NULL,
CONSTRAINT PK_Cards PRIMARY KEY CLUSTERED (id)
)
GO... |