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 |
|---|---|---|---|---|---|---|
371,716 | <p>When we serialize an enum from C# to SQL Server we use a NCHAR(3) datatype with mnemonic values for each value of the enum.
That way we can easily read a SELECT qry.</p>
<p>How do you save enum to your database?</p>
<p>What datatype do you use?</p>
| [
{
"answer_id": 371729,
"author": "Martin Brown",
"author_id": 20553,
"author_profile": "https://Stackoverflow.com/users/20553",
"pm_score": 2,
"selected": false,
"text": "<p>I use a separate reference data table with ID & Description for each enum. You can group them all into one tab... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371716",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28207/"
] | When we serialize an enum from C# to SQL Server we use a NCHAR(3) datatype with mnemonic values for each value of the enum.
That way we can easily read a SELECT qry.
How do you save enum to your database?
What datatype do you use? | A better way would be to store as an int. That way you can deserialise/cast from the DB right back to the correct enum value.
If the enum is likely to be changed in the future then use explicit values e.g.
```
public enum ActionType
{
Insert = 1,
Update = 2,
Delete = 3
}
```
The practicalities of storing as a... |
371,725 | <p>In Pseudo code</p>
<pre><code>If Domain inList(GB,US,ES,FR Then
Print This Html
Else
Print This HTML
EndIf
</code></pre>
| [
{
"answer_id": 371880,
"author": "mtruesdell",
"author_id": 6479,
"author_profile": "https://Stackoverflow.com/users/6479",
"pm_score": 1,
"selected": false,
"text": "<p>Try using the <a href=\"http://www.w3schools.com/Xsl/el_choose.asp\" rel=\"nofollow noreferrer\">xsl:choose.</a> (Also... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371725",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/87783/"
] | In Pseudo code
```
If Domain inList(GB,US,ES,FR Then
Print This Html
Else
Print This HTML
EndIf
``` | This is a*very* general form, but where you don't know the list at design-time, so long as you can get a reference to a nodeset which represents the list you can do a simple test like:
```
<xsl:when test="$listset/item[@property=$variable]">
```
where say $variable = /foo/bar/@property and $listset = /foo/list for X... |
371,753 | <p>I want to override access to one variable in a class, but return all others normally. How do I accomplish this with <code>__getattribute__</code>?</p>
<p>I tried the following (which should also illustrate what I'm trying to do) but I get a recursion error:</p>
<pre><code>class D(object):
def __init__(self):
... | [
{
"answer_id": 371833,
"author": "Egil",
"author_id": 44606,
"author_profile": "https://Stackoverflow.com/users/44606",
"pm_score": 8,
"selected": true,
"text": "<p>You get a recursion error because your attempt to access the <code>self.__dict__</code> attribute inside <code>__getattribu... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371753",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13009/"
] | I want to override access to one variable in a class, but return all others normally. How do I accomplish this with `__getattribute__`?
I tried the following (which should also illustrate what I'm trying to do) but I get a recursion error:
```
class D(object):
def __init__(self):
self.test=20
self... | You get a recursion error because your attempt to access the `self.__dict__` attribute inside `__getattribute__` invokes your `__getattribute__` again. If you use `object`'s `__getattribute__` instead, it works:
```
class D(object):
def __init__(self):
self.test=20
self.test2=21
def __getattrib... |
371,808 | <p>I'm on a project doing an iPhone application. We had a Cocoa consultant come in for a few weeks. He showed me an interesting idiom of Cocoa, dealing with interfaces, but there was a difficult language barrier between us, and he wasn't really able to explain <em>why</em> this was done or where it was documented so I ... | [
{
"answer_id": 371911,
"author": "Tom Harrington",
"author_id": 43832,
"author_profile": "https://Stackoverflow.com/users/43832",
"pm_score": 5,
"selected": true,
"text": "<p>These are what's known in Objective-C as \"categories\". Categories make it possible to have multiple @interface... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371808",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/386102/"
] | I'm on a project doing an iPhone application. We had a Cocoa consultant come in for a few weeks. He showed me an interesting idiom of Cocoa, dealing with interfaces, but there was a difficult language barrier between us, and he wasn't really able to explain *why* this was done or where it was documented so I could lear... | These are what's known in Objective-C as "categories". Categories make it possible to have multiple @interface and @implementation blocks for the same class. This works even to the extent that you can add methods on classes in the standard Apple frameworks, e.g. adding a category on NSString to add new methods to it. C... |
371,839 | <p>What is the most efficient way to convert data from nested lists to an object array (which can be used i.e. as data for JTable)?</p>
<pre><code>List<List> table = new ArrayList<List>();
for (DATAROW rowData : entries) {
List<String> row = new ArrayList<String>();
for (String col : ... | [
{
"answer_id": 371873,
"author": "Michael Myers",
"author_id": 13531,
"author_profile": "https://Stackoverflow.com/users/13531",
"pm_score": 3,
"selected": false,
"text": "<p>For <code>JTable</code> in particular, I'd suggest subclassing <code>AbstractTableModel</code> like so:</p>\n\n<p... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371839",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33429/"
] | What is the most efficient way to convert data from nested lists to an object array (which can be used i.e. as data for JTable)?
```
List<List> table = new ArrayList<List>();
for (DATAROW rowData : entries) {
List<String> row = new ArrayList<String>();
for (String col : rowData.getDataColumn())
row.a... | ```
//defined somewhere
List<List<String>> lists = ....
String[][] array = new String[lists.size()][];
String[] blankArray = new String[0];
for(int i=0; i < lists.size(); i++) {
array[i] = lists.get(i).toArray(blankArray);
}
```
I don't know anything about JTable, but converting a list of lists to array can be d... |
371,878 | <p>I'm just starting out with F# and I can't find the syntax to do object initialization like in C# 3. </p>
<p>I.e. given this:</p>
<pre><code>public class Person {
public DateTime BirthDate { get; set; }
public string Name { get; set; }
}
</code></pre>
<p>how do I write the following in F#:</p>
<pre><code>var ... | [
{
"answer_id": 371910,
"author": "Christian C. Salvadó",
"author_id": 5445,
"author_profile": "https://Stackoverflow.com/users/5445",
"pm_score": 8,
"selected": true,
"text": "<p>You can do it like this:</p>\n\n<pre><code>let p = new Person (Name = \"John\", BirthDate = DateTime.Now)\n</... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371878",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21239/"
] | I'm just starting out with F# and I can't find the syntax to do object initialization like in C# 3.
I.e. given this:
```
public class Person {
public DateTime BirthDate { get; set; }
public string Name { get; set; }
}
```
how do I write the following in F#:
```
var p = new Person { Name = "John", BirthDate = ... | You can do it like this:
```
let p = new Person (Name = "John", BirthDate = DateTime.Now)
``` |
371,898 | <p>I've seen a few mentions of this on Stack Overflow, but staring at Wikipedia (the relevant page has since been deleted) and at an <a href="http://sourceforge.net/projects/dyndlgdemo/" rel="noreferrer">MFC dynamic dialog demo</a> did nothing to enlighten me. Can someone please explain this? Learning a fundamentally d... | [
{
"answer_id": 381861,
"author": "Alex",
"author_id": 45581,
"author_profile": "https://Stackoverflow.com/users/45581",
"pm_score": 4,
"selected": false,
"text": "<p>Differential execution is a strategy for changing the flow of your code based on external events. This is usually done by... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371898",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18192/"
] | I've seen a few mentions of this on Stack Overflow, but staring at Wikipedia (the relevant page has since been deleted) and at an [MFC dynamic dialog demo](http://sourceforge.net/projects/dyndlgdemo/) did nothing to enlighten me. Can someone please explain this? Learning a fundamentally different concept sounds nice.
... | Gee, Brian, I wish I had seen your question sooner. Since it's pretty much my
"invention" (for better or worse), I might be able to help.
>
> Inserted: The shortest possible
> explanation I can make is that if
> normal execution is like throwing a
> ball in the air and catching it, then
> differential execution i... |
371,923 | <p>I have a series of messages that are defined by independent structs. These structs share a common header are sent between applications. I am creating a decoder that will take the raw data captures in the messages that were built using these structs and decode/parse them to some plain text.</p>
<p>I have over 1000 d... | [
{
"answer_id": 371936,
"author": "Jon Tackabury",
"author_id": 343,
"author_profile": "https://Stackoverflow.com/users/343",
"pm_score": 4,
"selected": false,
"text": "<p>I disable the elements instead of hiding them. That way the user knows the option would normally be available, and I ... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371923",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a series of messages that are defined by independent structs. These structs share a common header are sent between applications. I am creating a decoder that will take the raw data captures in the messages that were built using these structs and decode/parse them to some plain text.
I have over 1000 different m... | As with nearly all UI questions, the answer is "it depends".
You need to weigh discoverability with user satisfaction, among other things. For example, allowing an invalid action gives you an opportunity to explain why something is invalid. This is particularly useful if the answer to "why is this disabled" isn't obv... |
371,930 | <p>Environment is VS2008, .Net 3.5</p>
<p>The following C# code (note the specified encoding of UTF8)</p>
<pre><code>XmlWriterSettings settings = new XmlWriterSettings ();
StringBuilder sb = new StringBuilder();
settings.Encoding = System.Text.Encoding.UTF8;
settings.Indent = false;
settings.NewLineChars = "\n";
s... | [
{
"answer_id": 371946,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 5,
"selected": true,
"text": "<p>I suspect it's because it's writing to a StringBuilder, which is inherently UTF-16. An alternative to get round this i... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371930",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9368/"
] | Environment is VS2008, .Net 3.5
The following C# code (note the specified encoding of UTF8)
```
XmlWriterSettings settings = new XmlWriterSettings ();
StringBuilder sb = new StringBuilder();
settings.Encoding = System.Text.Encoding.UTF8;
settings.Indent = false;
settings.NewLineChars = "\n";
settings.ConformanceLe... | I suspect it's because it's writing to a StringBuilder, which is inherently UTF-16. An alternative to get round this is to create a class derived from StringWriter, but which overrides the Encoding property.
I believe I've got one in [MiscUtil](http://pobox.com/~skeet/csharp/miscutil) - but it's pretty trivial to writ... |
371,938 | <p>I have two routes I want mapped in my ASP.NET MVC application</p>
<ol>
<li>/User/Login</li>
<li>/User/{userid}/{username}/{action} (e.g. /User/1/blah/profile)</li>
</ol>
<p>Here are the routes I've defined: </p>
<pre><code> routes.MapRoute(
"Profile",
"Users/{userID}/{username}/{action}",... | [
{
"answer_id": 372758,
"author": "E Rolnicki",
"author_id": 46449,
"author_profile": "https://Stackoverflow.com/users/46449",
"pm_score": 0,
"selected": false,
"text": "<p>is your route hitting an Authorize filter? Is there a requirement to be logged in to view the /Users/1/blah page? (... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371938",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1574/"
] | I have two routes I want mapped in my ASP.NET MVC application
1. /User/Login
2. /User/{userid}/{username}/{action} (e.g. /User/1/blah/profile)
Here are the routes I've defined:
```
routes.MapRoute(
"Profile",
"Users/{userID}/{username}/{action}",
new { controller = "Users", action = "Pro... | You want to use `<%=Html.RouteLink%>`
This is very similar to the [problem I had which you can view here](https://stackoverflow.com/questions/323572/asp-mvc-routing-with-1-parameter) |
371,987 | <p>I doubt I am the only one who has come up with this solution, but if you have a better one please post it here. I simply want to leave this question here so I and others can search it later. </p>
<p>I needed to tell whether a valid date had been entered into a text box and this is the code that I came up with. I fi... | [
{
"answer_id": 371993,
"author": "Chris James",
"author_id": 3193,
"author_profile": "https://Stackoverflow.com/users/3193",
"pm_score": 9,
"selected": true,
"text": "<pre><code>DateTime.TryParse\n</code></pre>\n\n<p>This I believe is faster and it means you dont have to use ugly try/cat... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371987",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19802/"
] | I doubt I am the only one who has come up with this solution, but if you have a better one please post it here. I simply want to leave this question here so I and others can search it later.
I needed to tell whether a valid date had been entered into a text box and this is the code that I came up with. I fire this wh... | ```
DateTime.TryParse
```
This I believe is faster and it means you dont have to use ugly try/catches :)
e.g
```
DateTime temp;
if(DateTime.TryParse(startDateTextBox.Text, out temp))
{
// Yay :)
}
else
{
// Aww.. :(
}
``` |
372,003 | <p>I am looking for any kind of information (prefer Moq) on how to unit test the Application_Start method in Global.asax. I am using ASP.NET MVC and trying to get to that elusive 100% code coverage!</p>
<p>The fact that I'm using MVC is not the point. And saying that not testing Start is not necessary isn't really t... | [
{
"answer_id": 372167,
"author": "Steven A. Lowe",
"author_id": 9345,
"author_profile": "https://Stackoverflow.com/users/9345",
"pm_score": 0,
"selected": false,
"text": "<p>this function is called the first time your site is visited.\nrecycling the app pool will cause it to be triggered... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372003",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am looking for any kind of information (prefer Moq) on how to unit test the Application\_Start method in Global.asax. I am using ASP.NET MVC and trying to get to that elusive 100% code coverage!
The fact that I'm using MVC is not the point. And saying that not testing Start is not necessary isn't really the answer e... | Some organizations do require those meaningless numbers, and have issues beyond cost. For companies dealing with $ensitive information "Good enough" is not good enough. I had exactly the same issue and like Klas Mellbourn, need to get to 100% (if not higher!)
The following worked for me. Although, I'd have preferred to... |
372,007 | <p>When is white space not important in Python?</p>
<p>It seems to be ignored inside a list, for example:</p>
<pre><code>for x in range(5):
list += [x, 1
,2,3,
4,5]
</code></pre>
| [
{
"answer_id": 372025,
"author": "Robert Gamble",
"author_id": 25222,
"author_profile": "https://Stackoverflow.com/users/25222",
"pm_score": 5,
"selected": true,
"text": "<p>White space is only important for indentation of statements. You have a single statement across several lines, and... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372007",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4435/"
] | When is white space not important in Python?
It seems to be ignored inside a list, for example:
```
for x in range(5):
list += [x, 1
,2,3,
4,5]
``` | White space is only important for indentation of statements. You have a single statement across several lines, and only the indentation of the beginning of the statement on the first line is significant. See *[Python: Myths about Indentation](http://www.secnetix.de/~olli/Python/block_indentation.hawk)* for more informa... |
372,009 | <p><a href="https://medifacd.relayhealth.com/Pharmacies/MediFacD_Pharmacies_PayerSheet_E1December2006.htm#Examples" rel="nofollow noreferrer" title="Medicare Eligibility EDI Example Responses">Medicare Eligibility EDI Example Responses</a> is what I'm trying to match.</p>
<p>I have a string that looks like this:</p>
... | [
{
"answer_id": 372036,
"author": "Adam Bellaire",
"author_id": 21632,
"author_profile": "https://Stackoverflow.com/users/21632",
"pm_score": 4,
"selected": true,
"text": "<p>I think what you want is positive lookahead, not negative, so that you find the key-colon combo ahead of the curre... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372009",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/448/"
] | [Medicare Eligibility EDI Example Responses](https://medifacd.relayhealth.com/Pharmacies/MediFacD_Pharmacies_PayerSheet_E1December2006.htm#Examples "Medicare Eligibility EDI Example Responses") is what I'm trying to match.
I have a string that looks like this:
```
LN:SMITHbbbbbbbbFN:SAMANTHAbbBD:19400515PD:1BN:123456... | I think what you want is positive lookahead, not negative, so that you find the key-colon combo ahead of the current position, but you don't consume it. This appears to work for your test example:
```
([\w]{2})\:(.+?)(?=[\w]{2}\:|$)
```
Yielding:
```
LN: SMITHbbbbbbbb
FN: SAMANTHAbb
BD: 19400515
PD: 1
BN: 123456
P... |
372,011 | <p>I have a listview working in virtual mode, in the LargeIcons view. Retrieves are expensive, so I want to ask for the data for all the visible items. How do I get the start index and total number of the visible items?</p>
<p>Update: I am aware of the CacheVirtualItems event. The third-party database we're using t... | [
{
"answer_id": 372020,
"author": "Jeff Yates",
"author_id": 23234,
"author_profile": "https://Stackoverflow.com/users/23234",
"pm_score": 1,
"selected": false,
"text": "<p>You could iterate through subsequent items, checking their visibility until you reach the one that isn't visible. Th... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372011",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15371/"
] | I have a listview working in virtual mode, in the LargeIcons view. Retrieves are expensive, so I want to ask for the data for all the visible items. How do I get the start index and total number of the visible items?
Update: I am aware of the CacheVirtualItems event. The third-party database we're using takes ~3s to r... | THE REAL Answer is :
\* get the ScrollViewer of the ListView.
\* ScrollViewer.VerticalOffset is the index of first shown item.
\* ScrollViewer.ViewportHeight is the number of items shown.
To get the ScrollViewer, you will need a function,
FindDescendant(FrameworkElement, Type) that will search
within the c... |
372,023 | <p>I want to build a DLL Class Library use COM Interop, with C#, target ANY CPU, and register it as 32-bit and 64-bit interfaces. </p>
<p>I want to be able to, at runtime, display what interface was used - if I am using the 32-bit version, or 64-bit version.</p>
<p>Any ideas?</p>
| [
{
"answer_id": 372065,
"author": "Daniel Earwicker",
"author_id": 27423,
"author_profile": "https://Stackoverflow.com/users/27423",
"pm_score": 4,
"selected": true,
"text": "<p>In order for a process to load a 32-bit DLL, the process has to be 32-bit. And same for 64-bit. So to find out ... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372023",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16794/"
] | I want to build a DLL Class Library use COM Interop, with C#, target ANY CPU, and register it as 32-bit and 64-bit interfaces.
I want to be able to, at runtime, display what interface was used - if I am using the 32-bit version, or 64-bit version.
Any ideas? | In order for a process to load a 32-bit DLL, the process has to be 32-bit. And same for 64-bit. So to find out what has been loaded, assuming it has already worked, you just need to find out the bit-ness of the CLR:
```
if (System.IntPtr.Size == 8)
{
// 64-bit
}
else
{
// 32-bit
}
```
PS. for discussion of w... |
372,034 | <p>The ListView doesn't seem to support the Scroll event. I need to call a function whenever the list is scrolled; how would I go about that?</p>
| [
{
"answer_id": 375808,
"author": "Brian Rudolph",
"author_id": 33114,
"author_profile": "https://Stackoverflow.com/users/33114",
"pm_score": 4,
"selected": true,
"text": "<p>Why do you need to call a function when the list is scrolled? </p>\n\n<p>If you are changing the items as it's sc... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372034",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15371/"
] | The ListView doesn't seem to support the Scroll event. I need to call a function whenever the list is scrolled; how would I go about that? | Why do you need to call a function when the list is scrolled?
If you are changing the items as it's scrolled i would recommend setting the listview to virtual.
Or you could override the listview and do this:
```
public class TestListView : System.Windows.Forms.ListView
{
private const int WM_HSCROLL = 0x114;
... |
372,040 | <p>I have three tables like that:</p>
<p><strong>Articles</strong>
IdArticle
Title
Content</p>
<p><strong>Tags</strong>
IdTag
TagName</p>
<p><strong>ContentTag</strong>
IdContentTag
Idtag
IdContent</p>
<p>When user in my site write an article with adding tags and submit, I want to save it to tables above. </p>
<p>... | [
{
"answer_id": 375808,
"author": "Brian Rudolph",
"author_id": 33114,
"author_profile": "https://Stackoverflow.com/users/33114",
"pm_score": 4,
"selected": true,
"text": "<p>Why do you need to call a function when the list is scrolled? </p>\n\n<p>If you are changing the items as it's sc... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372040",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/439507/"
] | I have three tables like that:
**Articles**
IdArticle
Title
Content
**Tags**
IdTag
TagName
**ContentTag**
IdContentTag
Idtag
IdContent
When user in my site write an article with adding tags and submit, I want to save it to tables above.
In traditional ways, I used to use transaction and I could do it. But How can... | Why do you need to call a function when the list is scrolled?
If you are changing the items as it's scrolled i would recommend setting the listview to virtual.
Or you could override the listview and do this:
```
public class TestListView : System.Windows.Forms.ListView
{
private const int WM_HSCROLL = 0x114;
... |
372,041 | <p>I want to register a specific instance of an object for a type in structuremap, how can I do that?</p>
<p>For example,</p>
<p>When I do:</p>
<pre><code>var myObj = ObjectFactory.GetInstance(typeof(MyAbstractClass));
</code></pre>
<p>i would like it to return a previously constructed concrete class, which i creat... | [
{
"answer_id": 372168,
"author": "Jab",
"author_id": 29676,
"author_profile": "https://Stackoverflow.com/users/29676",
"pm_score": 4,
"selected": true,
"text": "<p>I believe you would do this in you initialization</p>\n\n<pre><code> ObjectFactory.Initialize(x =>\n {\n ... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372041",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28543/"
] | I want to register a specific instance of an object for a type in structuremap, how can I do that?
For example,
When I do:
```
var myObj = ObjectFactory.GetInstance(typeof(MyAbstractClass));
```
i would like it to return a previously constructed concrete class, which i created like this:
```
var myClass = new MyC... | I believe you would do this in you initialization
```
ObjectFactory.Initialize(x =>
{
x.ForRequestedType<MyAbstractClass>().TheDefault.IsThis(myClass);
});
```
Where myClass is the instance of the object you want to return. |
372,042 | <p>What is the difference between abstract class and interface in Python?</p>
| [
{
"answer_id": 372066,
"author": "Douglas Leeder",
"author_id": 3978,
"author_profile": "https://Stackoverflow.com/users/3978",
"pm_score": 5,
"selected": false,
"text": "<p>Python doesn't really have either concept.</p>\n<p>It uses <a href=\"https://stackoverflow.com/q/4205130\">duck ty... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372042",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/461736/"
] | What is the difference between abstract class and interface in Python? | What you'll see sometimes is the following:
```py
class Abstract1:
"""Some description that tells you it's abstract,
often listing the methods you're expected to supply."""
def aMethod(self):
raise NotImplementedError("Should have implemented this")
```
Because Python doesn't have (and doesn't n... |
372,043 | <p>I want to do something sort of like this:</p>
<pre><code>let x = 5
let y = 10
let expr = Console.ReadLine()
expr
</code></pre>
<p>Where one might type <code>"x+y"</code> in the console to store in expr.</p>
<p>How does one evaluate a statement like this in F#?</p>
<p>Ultimately, I want a user to be able to ent... | [
{
"answer_id": 372060,
"author": "Alex Fort",
"author_id": 12624,
"author_profile": "https://Stackoverflow.com/users/12624",
"pm_score": 0,
"selected": false,
"text": "<p>F# doesn't have an eval function like Lisp's (AFAIK), if that's what you're wondering. You could build up an expressi... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372043",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42140/"
] | I want to do something sort of like this:
```
let x = 5
let y = 10
let expr = Console.ReadLine()
expr
```
Where one might type `"x+y"` in the console to store in expr.
How does one evaluate a statement like this in F#?
Ultimately, I want a user to be able to enter expressions, or a set of rules for a system, on ... | F# doesn't have eval, as mentioned, but if you can define the grammar, you can utilize the Lex and Yacc implementations in F# (fslex and and fsyacc).
*EDIT:*
As a quick follow up, I know in ocaml you can exploit the interactive console to your users with `ocamlmktop`. I am unsure of an equivalent in F#. This, althoug... |
372,086 | <p>I asked <a href="https://stackoverflow.com/questions/370024/sql-server-2005-public-database-role-doesnt-seem-to-apply">another question</a> about roles and permissions, which mostly served to reveal my ignorance. One of the other outcomes was the advice that one should generally stay away from mucking with permissi... | [
{
"answer_id": 372692,
"author": "Nick Kavadias",
"author_id": 40067,
"author_profile": "https://Stackoverflow.com/users/40067",
"pm_score": 1,
"selected": false,
"text": "<p>The idea of having a role is that you only need to setup the permissions once. You can then assign users, or grou... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372086",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26286/"
] | I asked [another question](https://stackoverflow.com/questions/370024/sql-server-2005-public-database-role-doesnt-seem-to-apply) about roles and permissions, which mostly served to reveal my ignorance. One of the other outcomes was the advice that one should generally stay away from mucking with permissions for the "pu... | Working from memory (no SQL on my gaming 'pooter), you can use [`sys.database_permissions`](http://msdn.microsoft.com/en-us/library/ms188367(SQL.90).aspx)
Run this and paste the results into a new query.
Edit, Jan 2012. Added OBJECT\_SCHEMA\_NAME.
You may need to pimp it to support schemas (dbo.) by joining onto ... |
372,087 | <p>Here is the single line from one of my functions to test if any objects in my array have a given property with a matching value</p>
<pre><code>Return ((From tag In DataCache.Tags Where (tag.FldTag = strtagname) Select tag).Count = 1)
</code></pre>
<p>WHERE....</p>
<p><code>DataCache.Tags</code> is an array of cu... | [
{
"answer_id": 372098,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 3,
"selected": false,
"text": "<p>Your code is currently checking whether the count is <em>exactly</em> one.</p>\n\n<p>The equivalent of EXISTS in LINQ... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372087",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Here is the single line from one of my functions to test if any objects in my array have a given property with a matching value
```
Return ((From tag In DataCache.Tags Where (tag.FldTag = strtagname) Select tag).Count = 1)
```
WHERE....
`DataCache.Tags` is an array of custom objects
`strtagname = "brazil"`
and br... | Your code is currently checking whether the count is *exactly* one.
The equivalent of EXISTS in LINQ is [Any](http://msdn.microsoft.com/en-us/library/system.linq.queryable.any.aspx). You want something like:
```
Return DataCache.Tags.Any(Function(tag) tag.FldTag = strtagname)
```
(Miraculously it looks like that sy... |
372,102 | <p>I'm aware that Python 3 fixes a lot of UTF issues, I am not however able to use Python 3, I am using 2.5.1</p>
<p>I'm trying to regex a document but the document has UTF hyphens in it – rather than -. Python can't match these and if I put them in the regex it throws a wobbly.</p>
<p>How can I force Python to use a... | [
{
"answer_id": 372128,
"author": "Patrick McElhaney",
"author_id": 437,
"author_profile": "https://Stackoverflow.com/users/437",
"pm_score": 3,
"selected": false,
"text": "<p>You have to escape the character in question (–) and put a u in front of the string literal to make it a unicode ... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372102",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1384652/"
] | I'm aware that Python 3 fixes a lot of UTF issues, I am not however able to use Python 3, I am using 2.5.1
I'm trying to regex a document but the document has UTF hyphens in it – rather than -. Python can't match these and if I put them in the regex it throws a wobbly.
How can I force Python to use a UTF string or in... | After a quick test and visit to [PEP 0264: Defining Python Source Code Encodings](http://www.python.org/dev/peps/pep-0263/), I see you may need to tell Python the whole file is UTF-8 encoded by adding adding a comment like this to the first line.
```
# encoding: utf-8
```
Here's the test file I created and ran on Py... |
372,105 | <p>At work today we were trying to come up with any reason you would use <a href="http://www.php.net/strspn" rel="noreferrer">strspn</a>.</p>
<p>I searched google code to see if it's ever been implemented in a useful way and came up blank. I just can't imagine a situation in which I would really need to know the lengt... | [
{
"answer_id": 372130,
"author": "Adam Rosenfield",
"author_id": 9530,
"author_profile": "https://Stackoverflow.com/users/9530",
"pm_score": 1,
"selected": false,
"text": "<p>It's based on the the ANSI C function <code>strspn()</code>. It can be useful in low-level C parsing code, where... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372105",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29683/"
] | At work today we were trying to come up with any reason you would use [strspn](http://www.php.net/strspn).
I searched google code to see if it's ever been implemented in a useful way and came up blank. I just can't imagine a situation in which I would really need to know the length of the first segment of a string tha... | Although you link to the PHP manual, the `strspn()` function comes from C libraries, along with `strlen()`, `strcpy()`, `strcmp()`, etc.
`strspn()` is a convenient alternative to picking through a string character by character, testing if the characters match one of a set of values. It's useful when writing tokenizers... |
372,114 | <p>I have a HashMap that I am serializing and deserializing to an Oracle db, in a BLOB data type field.
I want to perform a query, using this field.
Example, the application will make a new HashMap, and have some key-value pairs.
I want to query the db to see if a HashMap with this data already exists in the db.
I do ... | [
{
"answer_id": 372131,
"author": "BQ.",
"author_id": 4632,
"author_profile": "https://Stackoverflow.com/users/4632",
"pm_score": 0,
"selected": false,
"text": "<p>I haven't had the need to compare BLOBs, but it appears that it's supported through the <code>dbms_lob</code> package. </p>\n... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372114",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13143/"
] | I have a HashMap that I am serializing and deserializing to an Oracle db, in a BLOB data type field.
I want to perform a query, using this field.
Example, the application will make a new HashMap, and have some key-value pairs.
I want to query the db to see if a HashMap with this data already exists in the db.
I do not... | Here's an article for you to read: [Pounding a Nail: Old Shoe or Glass Bottle](http://weblogs.asp.net/alex_papadimoulis/archive/2005/05/25/408925.aspx)
I haven't heard much about your application's underlying architecture, but I can tell you immediately that there is *never* a reason why you should need to use a HashM... |
372,116 | <p>I currently use this function to wrap executing commands and logging their execution, and return code, and exiting in case of a non-zero return code.</p>
<p>However this is problematic as apparently, it does double interpolation, making commands with single or double quotes in them break the script.</p>
<p>Can you... | [
{
"answer_id": 372120,
"author": "Douglas Leeder",
"author_id": 3978,
"author_profile": "https://Stackoverflow.com/users/3978",
"pm_score": 6,
"selected": true,
"text": "<pre><code>\"$@\"\n</code></pre>\n\n<p>From <a href=\"http://www.gnu.org/software/bash/manual/bashref.html#Special-Par... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372116",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13523/"
] | I currently use this function to wrap executing commands and logging their execution, and return code, and exiting in case of a non-zero return code.
However this is problematic as apparently, it does double interpolation, making commands with single or double quotes in them break the script.
Can you recommend a bett... | ```
"$@"
```
From <http://www.gnu.org/software/bash/manual/bashref.html#Special-Parameters>:
>
> @
>
>
> Expands to the positional parameters, starting from one. When the
> expansion occurs within double quotes, each parameter expands to a
> separate word. That is, "$@" is equivalent to "$1" "$2" .... If the
> ... |
372,140 | <p>I am building a C# ActiveX DLL... do I use REGASM or REGSVR32 to register it?</p>
<p>How do I register the 64-bit interface vs the 32-bit interface?</p>
| [
{
"answer_id": 372197,
"author": "Kev",
"author_id": 419,
"author_profile": "https://Stackoverflow.com/users/419",
"pm_score": 6,
"selected": true,
"text": "<p>You need to use <a href=\"http://msdn.microsoft.com/en-us/library/tzat5yw6%28v=vs.80%29.aspx\" rel=\"noreferrer\"><code>regasm.e... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372140",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16794/"
] | I am building a C# ActiveX DLL... do I use REGASM or REGSVR32 to register it?
How do I register the 64-bit interface vs the 32-bit interface? | You need to use [`regasm.exe`](http://msdn.microsoft.com/en-us/library/tzat5yw6%28v=vs.80%29.aspx) to register both the 32 bit and 64 bit interfaces I believe you need to run each of the `regasm.exe`'s in:
```
C:\Windows\Microsoft.NET\Framework\v2.0.50727
```
and
```
C:\Windows\Microsoft.NET\Framework64\v2.0.50727
... |
372,148 | <p>I'd like to use regex with Java.</p>
<p>What I want to do is find the first integer in a string.</p>
<p>Example:</p>
<pre><code>String = "the 14 dogs ate 12 bones"
</code></pre>
<p>Would return 14.</p>
<pre><code>String = "djakld;asjl14ajdka;sdj"
</code></pre>
<p>Would also return 14.</p>
<p>This is what I h... | [
{
"answer_id": 372154,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 7,
"selected": true,
"text": "<p>You're asking for 0 or more digits. You need to ask for 1 or more:</p>\n\n<pre><code>\"\\\\d+\"\n</code></pre>\n"
},
{
... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372148",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2510/"
] | I'd like to use regex with Java.
What I want to do is find the first integer in a string.
Example:
```
String = "the 14 dogs ate 12 bones"
```
Would return 14.
```
String = "djakld;asjl14ajdka;sdj"
```
Would also return 14.
This is what I have so far.
```
Pattern intsOnly = Pattern.compile("\\d*");
Matcher ma... | You're asking for 0 or more digits. You need to ask for 1 or more:
```
"\\d+"
``` |
372,159 | <p>AFAIK, you never need to specify the protocol in an onclick:</p>
<p><code>onclick="javascript:myFunction()"</code> <strong>Bad</strong></p>
<p><code>onclick="myFunction()"</code> <strong>Good</strong></p>
<p>Today I noticed in <a href="http://web.archive.org/web/20080428095515/http://www.google.com/support/analyt... | [
{
"answer_id": 372179,
"author": "George Stocker",
"author_id": 16587,
"author_profile": "https://Stackoverflow.com/users/16587",
"pm_score": 0,
"selected": false,
"text": "<p>It's good practice for your maintenance programmer. The compiler knows the difference, but that young, just-out... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372159",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12579/"
] | AFAIK, you never need to specify the protocol in an onclick:
`onclick="javascript:myFunction()"` **Bad**
`onclick="myFunction()"` **Good**
Today I noticed in [this article](http://web.archive.org/web/20080428095515/http://www.google.com/support/analytics/bin/answer.py?answer=55527) on Google Anallytics that *they* a... | Some of the responses here claim that the "javascript:" prefix is a "leftover from the old days", implying that it's intentionally, specially handled by the browsers for backwards compatibility. Is there solid evidence that this is the case (has anyone checked source code)?
```
<span onclick="javascript:alert(42)">Tes... |
372,186 | <p>Can you show sample code for reading a drive label or volume name in .NET? I get the sense this requires WMI, but I am loathe to "drop-down" into WMI because it is like dropping down into a string-based SQL query in the sense that certain objects may not exist on certain versions of OSes or the user may not have the... | [
{
"answer_id": 372201,
"author": "Kent Boogaart",
"author_id": 5380,
"author_profile": "https://Stackoverflow.com/users/5380",
"pm_score": 5,
"selected": true,
"text": "<p>No WMI required. The following will get all volume labels:</p>\n\n<pre><code>var labels = from drive in DriveInfo.Ge... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372186",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/470/"
] | Can you show sample code for reading a drive label or volume name in .NET? I get the sense this requires WMI, but I am loathe to "drop-down" into WMI because it is like dropping down into a string-based SQL query in the sense that certain objects may not exist on certain versions of OSes or the user may not have the ri... | No WMI required. The following will get all volume labels:
```
var labels = from drive in DriveInfo.GetDrives()
select drive.VolumeLabel
``` |
372,202 | <p>I have been doing a lot of research on this lately, but have yet to get a really good solid answer. I read somewhere that a new Function() object is created when the JavaScript engine comes across a function statement, which would lead me to believe it could be a child of an object (thus becoming one). So I emailed ... | [
{
"answer_id": 372228,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 2,
"selected": false,
"text": "<p>The \"global\" scope of Javascript (at least in a browser) is the <code>window</code> object.</p>\n\n<p>This means that wh... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372202",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have been doing a lot of research on this lately, but have yet to get a really good solid answer. I read somewhere that a new Function() object is created when the JavaScript engine comes across a function statement, which would lead me to believe it could be a child of an object (thus becoming one). So I emailed Dou... | Your understanding is wrong:
```
myFunction().myProperty; // myFunction has no properties
```
The reason it does not work is because ".myProperty" is applied to the returned value of "myFunction()", not to the object "myFunction". To wit:
```
$ js
js> function a() { this.b=1;return {b: 2};}
js> a().b
2
js>
```
R... |
372,218 | <p>I would like to insert the current Subversion revision number (as reported by <code>svnversion</code>) into my Xcode project. I managed to insert the revision number into the <code>Info.plist</code> in the <code>$PROJECT_DIR</code>, but this is not a good solution, since the file is versioned. I tried to insert the ... | [
{
"answer_id": 414792,
"author": "Brad Larson",
"author_id": 19679,
"author_profile": "https://Stackoverflow.com/users/19679",
"pm_score": 3,
"selected": false,
"text": "<p>For posterity, I did something similar to zoul for iPhone applications, by adding a revision.h to my project, then ... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372218",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17279/"
] | I would like to insert the current Subversion revision number (as reported by `svnversion`) into my Xcode project. I managed to insert the revision number into the `Info.plist` in the `$PROJECT_DIR`, but this is not a good solution, since the file is versioned. I tried to insert the revision into the `Info.plist` in th... | There's a much simpler solution: using [**PlistBuddy**](http://developer.apple.com/documentation/Darwin/Reference/ManPages/man8/PlistBuddy.8.html), included at `/usr/libexec/PlistBuddy` in Leopard. See [my answer to a related SO question](https://stackoverflow.com/questions/877128/#1061864) for details.
PlistBuddy ca... |
372,220 | <p>I have an executable that runs instantly from a command prompt, but does not appear to ever return when spawned using System.Diagnostics.Process:</p>
<p>Basicly, I'm writing a .NET library wrapper around the Accurev CLI interface, so each method call spawns the CLI process to execute a command.</p>
<p>This works g... | [
{
"answer_id": 372255,
"author": "David Norman",
"author_id": 34502,
"author_profile": "https://Stackoverflow.com/users/34502",
"pm_score": 1,
"selected": false,
"text": "<p>Is the spawned process still alive while WaitForExit() is executing? Can you attach a debugger to it?</p>\n"
},... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372220",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965/"
] | I have an executable that runs instantly from a command prompt, but does not appear to ever return when spawned using System.Diagnostics.Process:
Basicly, I'm writing a .NET library wrapper around the Accurev CLI interface, so each method call spawns the CLI process to execute a command.
This works great for all but ... | It is seeking for input? In particular, I notice that you are redirecting stdin, but not closing it - so if it is reading from stdin it will hang. |
372,224 | <p>I'm having some trouble with this code:</p>
<p>CSS: </p>
<pre><code>div#header
{
width: 100%;
background-color: #252525;
padding: 10px 0px 10px 15px;
position: relative;
}
div#login
{
float: right;
position: absolute;
right: 10px;
top: 5px;
}
</code></pre>
<p>HTML:</p>
<pre><code... | [
{
"answer_id": 372251,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>Would 'overflow:hidden' on a properly sized container div work?</p>\n"
},
{
"answer_id": 372260,
"author": "Mg.... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372224",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32432/"
] | I'm having some trouble with this code:
CSS:
```
div#header
{
width: 100%;
background-color: #252525;
padding: 10px 0px 10px 15px;
position: relative;
}
div#login
{
float: right;
position: absolute;
right: 10px;
top: 5px;
}
```
HTML:
```
<div id="header">
<img src="./img/logo.... | Try removing the 100% width of the header. Since divs are line elements, thats not needed. |
372,230 | <p>I have a read-only database that has cached information which is used to display pages on the site. There are processes that run to generate the database, and those run on a different server. When I need to update the live database, I restore this database to the live server, to a new name and file. Then I drop the ... | [
{
"answer_id": 372322,
"author": "Michael Sharek",
"author_id": 1958,
"author_profile": "https://Stackoverflow.com/users/1958",
"pm_score": 2,
"selected": true,
"text": "<p>Probably what you want to do is take the live database offline with the command:</p>\n\n<pre><code>ALTER DATABASE n... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372230",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13855/"
] | I have a read-only database that has cached information which is used to display pages on the site. There are processes that run to generate the database, and those run on a different server. When I need to update the live database, I restore this database to the live server, to a new name and file. Then I drop the liv... | Probably what you want to do is take the live database offline with the command:
```
ALTER DATABASE name SET OFFLINE
```
You can read more [here](http://www.blackwasp.co.uk/SQLOffline.aspx), but it says:
>
> The above command attempts to take the named database off-line immediately. If a user or a background proce... |
372,246 | <p>How can I get a query which uses an OR in the WHERE clause to split itself into two queries with a UNION during compilation? If I manually rewrite it, the query using the UNION is 100x faster than the single query, because it can effectively use different indices in each query of the union. Is there any way I can ... | [
{
"answer_id": 372352,
"author": "Chaowlert Chaisrichalermpol",
"author_id": 2398110,
"author_profile": "https://Stackoverflow.com/users/2398110",
"pm_score": 3,
"selected": true,
"text": "<p>You can group</p>\n\n<pre><code>select columnlist\nfrom table1\njoin table2 on joincond2\njoin t... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372246",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7453/"
] | How can I get a query which uses an OR in the WHERE clause to split itself into two queries with a UNION during compilation? If I manually rewrite it, the query using the UNION is 100x faster than the single query, because it can effectively use different indices in each query of the union. Is there any way I can make ... | You can group
```
select columnlist
from table1
join table2 on joincond2
join table3 on joincond3
```
into a view, and then use union.
but if you can migrate to sql2005/8,
you can use common table expression.
```
with cte ( columnlist )
as (
select columnlist
from table1
join table2 on joincond2
jo... |
372,250 | <p>I think there must be something subtle going on here that I don't know about. Consider the following:</p>
<pre><code>public class Foo<T> {
private T[] a = (T[]) new Object[5];
public Foo() {
// Add some elements to a
}
public T[] getA() {
return a;
}
}
</code></pre>
<p>Suppose that your m... | [
{
"answer_id": 372258,
"author": "matt b",
"author_id": 4249,
"author_profile": "https://Stackoverflow.com/users/4249",
"pm_score": 5,
"selected": true,
"text": "<pre><code>Foo<Double> f = new Foo<Double>();\n</code></pre>\n\n<p>When you use this version of the generic class ... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372250",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2200391/"
] | I think there must be something subtle going on here that I don't know about. Consider the following:
```
public class Foo<T> {
private T[] a = (T[]) new Object[5];
public Foo() {
// Add some elements to a
}
public T[] getA() {
return a;
}
}
```
Suppose that your main method contains the followin... | ```
Foo<Double> f = new Foo<Double>();
```
When you use this version of the generic class Foo, then for the member variable `a`, the compiler is essentially taking this line:
```
private T[] a = (T[]) new Object[5];
```
and replacing `T` with `Double` to get this:
```
private Double[] a = (Double[]) new Object[5]... |
372,316 | <p>I am working with PHP and I am wondering how bad practise it is to combine lots of functions into a class. I am aware of it's not the purpose of classes, but the reason why I would do this is to provide a namespace. How big impact does it make to initiate let's say 10 classes at the execution of a PHP script instead... | [
{
"answer_id": 372323,
"author": "Adam Wright",
"author_id": 1200,
"author_profile": "https://Stackoverflow.com/users/1200",
"pm_score": 0,
"selected": false,
"text": "<p>You may not be aware that PHP, as of recently, has first class namespace support: <a href=\"http://php.net/language.n... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372316",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am working with PHP and I am wondering how bad practise it is to combine lots of functions into a class. I am aware of it's not the purpose of classes, but the reason why I would do this is to provide a namespace. How big impact does it make to initiate let's say 10 classes at the execution of a PHP script instead of... | If you're using a php version < 5.3 (and you are probably, so you can't use namespaces) than you could use something like:
```
<?php
class Foo {
public static function aStaticMethod() {
// ...
}
}
Foo::aStaticMethod();
?>
```
(copied from [the php manual](http://theserverpages.com/php/manual/en/langua... |
372,317 | <p>I have a dataprovider and a filterfunction for my array that's assigned to my dataprovider.</p>
<p>How can I get a list of the properties that are in each row of the dataprovider (item.data) as it gets passed to the filterfunction?</p>
<p>For instance, if my object contained:</p>
<ul>
<li>Object
<ul>
<li>name</l... | [
{
"answer_id": 372427,
"author": "Herms",
"author_id": 1409,
"author_profile": "https://Stackoverflow.com/users/1409",
"pm_score": 7,
"selected": true,
"text": "<p>If it's a dynamic object I believe you can just do something like this:</p>\n\n<pre><code>var obj:Object; // I'm assuming th... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372317",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46782/"
] | I have a dataprovider and a filterfunction for my array that's assigned to my dataprovider.
How can I get a list of the properties that are in each row of the dataprovider (item.data) as it gets passed to the filterfunction?
For instance, if my object contained:
* Object
+ name
+ email
+ address
Then I would wan... | If it's a dynamic object I believe you can just do something like this:
```
var obj:Object; // I'm assuming this is your object
for(var id:String in obj) {
var value:Object = obj[id];
trace(id + " = " + value);
}
```
That's how it's done in AS2, and I believe that still works for dynamic objects in AS3. I thin... |
372,325 | <p>I have this line of code for page load:</p>
<pre><code>if ($("input").is(':checked')) {
</code></pre>
<p>and it works fine when the radio button input is checked. However, I want the opposite. Something along the lines of </p>
<pre><code>if ($("input").not(.is(':checked'))) {
</code></pre>
<p>so that my if sta... | [
{
"answer_id": 372364,
"author": "singpolyma",
"author_id": 8611,
"author_profile": "https://Stackoverflow.com/users/8611",
"pm_score": 7,
"selected": true,
"text": "<pre><code>if ( ! $(\"input\").is(':checked') )\n</code></pre>\n\n<p>Doesn't work?</p>\n\n<p>You might also try iterating ... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372325",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16508/"
] | I have this line of code for page load:
```
if ($("input").is(':checked')) {
```
and it works fine when the radio button input is checked. However, I want the opposite. Something along the lines of
```
if ($("input").not(.is(':checked'))) {
```
so that my if statement runs when none of the radiobuttons are selec... | ```
if ( ! $("input").is(':checked') )
```
Doesn't work?
You might also try iterating over the elements like so:
```
var iz_checked = true;
$('input').each(function(){
iz_checked = iz_checked && $(this).is(':checked');
});
if ( ! iz_checked )
``` |
372,326 | <p>I've written a new application in a network I haven't worked in before, and am running into a problem.</p>
<p>If I have the following C# code:</p>
<pre><code>FileStream fs = File.Create(@"\\MyServer\MyShare\testing.txt");
fs.Close();
</code></pre>
<p>In a console application, this code executes correctly.</p>
<p... | [
{
"answer_id": 372339,
"author": "Mitchel Sellers",
"author_id": 13279,
"author_profile": "https://Stackoverflow.com/users/13279",
"pm_score": 0,
"selected": false,
"text": "<p>The issue is that with identity impersonate set to false the ASP.NET worker process account is trying to write ... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372326",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30006/"
] | I've written a new application in a network I haven't worked in before, and am running into a problem.
If I have the following C# code:
```
FileStream fs = File.Create(@"\\MyServer\MyShare\testing.txt");
fs.Close();
```
In a console application, this code executes correctly.
In an ASP.Net application, I receive th... | **Update:**
So I think I posted this too soon... The reason it was failing on my localhost was due to the directory being set as allow anonymous access (so the page wasn't impersonating; the user was '').
It also started working on the server as well; however, nothing was changed there... I don't know if something wa... |
372,327 | <p>I'm trying to consume Sharepoint webservices with ruby. I've basically given up trying to authenticate with NTLM and temporarily changed the Sharepoint server to use basic authentication. I've been successful getting a WSDL using soap4r but still cannot authenticate when attempting to use an actual web service cal... | [
{
"answer_id": 372505,
"author": "Greg Hurlman",
"author_id": 35,
"author_profile": "https://Stackoverflow.com/users/35",
"pm_score": 1,
"selected": false,
"text": "<p>How did you change the SP server to use Basic Auth? Did you just configure the site via IIS, or did you do it through S... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372327",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1766771/"
] | I'm trying to consume Sharepoint webservices with ruby. I've basically given up trying to authenticate with NTLM and temporarily changed the Sharepoint server to use basic authentication. I've been successful getting a WSDL using soap4r but still cannot authenticate when attempting to use an actual web service call.
H... | I'm a total newb. But after a lot of time and with some help from more experience coders, I was able to get ruby working with Sharepoint 2010. The code below requires the 'ntlm/mechanize' gem.
I've been able to download the sharepoint xml from lists specified (below) using the List GUID and the List View GUID.
Edit (... |
372,334 | <p>Is there a pure .net way to do this reliably? The solutions I keep finding either require guessing or they have a solution that is specific to a database provider. Usually querying some internal system table to get this information.</p>
| [
{
"answer_id": 372349,
"author": "Igor Zelaya",
"author_id": 22769,
"author_profile": "https://Stackoverflow.com/users/22769",
"pm_score": 4,
"selected": true,
"text": "<p>Each DataTable object has a PrimaryKey property wich is an array of DataColumns that represent the table's primary k... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372334",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7176/"
] | Is there a pure .net way to do this reliably? The solutions I keep finding either require guessing or they have a solution that is specific to a database provider. Usually querying some internal system table to get this information. | Each DataTable object has a PrimaryKey property wich is an array of DataColumns that represent the table's primary key.
For example:
```
string[] GetPrimaryKeys(SqlConnection connection, string tableName)
{
using(SqlDataAdapter adapter = new SqlDataAdapter("select * from " + tableName, connection))
using(Data... |
372,354 | <p>Does string immutability work by statement, or by strings within a statement? </p>
<p>For example, I understand that the following code will allocate two strings on the heap.</p>
<pre><code>string s = "hello ";
s += "world!";
</code></pre>
<p>"hello" will remain on the heap until garbage collected; and s now refe... | [
{
"answer_id": 372363,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 5,
"selected": true,
"text": "<p>The compiler has special treatment for string concatenation, which is why the second example is only ever <strong>o... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372354",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37064/"
] | Does string immutability work by statement, or by strings within a statement?
For example, I understand that the following code will allocate two strings on the heap.
```
string s = "hello ";
s += "world!";
```
"hello" will remain on the heap until garbage collected; and s now references "hello world!" on the heap... | The compiler has special treatment for string concatenation, which is why the second example is only ever **one** string. And "interning" means that even if you run this line 20000 times there is still only 1 string.
Re testing the results... the easiest way (in this case) is probably to look in reflector:
```
.meth... |
372,365 | <p>I am using xmlrpclib.ServerProxy to make RPC calls to a remote server. If there is not a network connection to the server it takes the default 10 seconds to return a socket.gaierror to my program. </p>
<p>This is annoying when doing development without a network connection, or if the remote server is down. Is there... | [
{
"answer_id": 375000,
"author": "monkut",
"author_id": 24718,
"author_profile": "https://Stackoverflow.com/users/24718",
"pm_score": 1,
"selected": false,
"text": "<p>Here is a verbatim copy from <a href=\"http://code.activestate.com/recipes/473878/\" rel=\"nofollow noreferrer\">http://... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372365",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22306/"
] | I am using xmlrpclib.ServerProxy to make RPC calls to a remote server. If there is not a network connection to the server it takes the default 10 seconds to return a socket.gaierror to my program.
This is annoying when doing development without a network connection, or if the remote server is down. Is there a way to ... | An more straightforward solution is at:
<http://www.devpicayune.com/entry/200609191448>
```
import xmlrpclib
import socket
x = xmlrpclib.ServerProxy('http:1.2.3.4')
socket.setdefaulttimeout(10) #set the timeout to 10 seconds
x.func_name(args) #times out after 10 seconds
socket.setdefaultt... |
372,370 | <p>How do I take a string in Perl and split it up into an array with entries two characters long each?</p>
<p>I attempted this:</p>
<pre><code>@array = split(/../, $string);
</code></pre>
<p>but did not get the expected results.</p>
<p>Ultimately I want to turn something like this</p>
<pre><code>F53CBBA476
</code>... | [
{
"answer_id": 372397,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "https://Stackoverflow.com/users/20860",
"pm_score": 7,
"selected": true,
"text": "<pre><code>@array = ( $string =~ m/../g );\n</code></pre>\n\n<p>The pattern-matching operator behaves in a special way ... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372370",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23/"
] | How do I take a string in Perl and split it up into an array with entries two characters long each?
I attempted this:
```
@array = split(/../, $string);
```
but did not get the expected results.
Ultimately I want to turn something like this
```
F53CBBA476
```
in to an array containing
```
F5 3C BB A4 76
``` | ```
@array = ( $string =~ m/../g );
```
The pattern-matching operator behaves in a special way in a list context in Perl. It processes the operation iteratively, matching the pattern against the remainder of the text after the previous match. Then the list is formed from all the text that matched during each applicat... |
372,382 | <p>I have a simple extension method on the int type so I can do the following:</p>
<pre><code>string timeLength = 61.ToTime() // timeLength will be "1:01"
</code></pre>
<p>This works great in code, but I want to use this extension method in a Repeater Template. When databinding I want to do the following:</p>
<pre><... | [
{
"answer_id": 372458,
"author": "shahkalpesh",
"author_id": 23574,
"author_profile": "https://Stackoverflow.com/users/23574",
"pm_score": 0,
"selected": false,
"text": "<p>Does Eval(\"LengthInSeconds\") work by itself?</p>\n"
},
{
"answer_id": 372461,
"author": "Scott Muc",
... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372382",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1894/"
] | I have a simple extension method on the int type so I can do the following:
```
string timeLength = 61.ToTime() // timeLength will be "1:01"
```
This works great in code, but I want to use this extension method in a Repeater Template. When databinding I want to do the following:
```
<%# Eval("LengthInSeconds").ToTi... | Looks like I get to answer my own question! Asp.Net was compiling the .aspx,.ascx templates using the .Net 2.0 compiler. I needed to add the following to my web.config to make it work
```
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvide... |
372,383 | <p>I have a web service (WCF or ASMX doesn't matter)... I have made a Console application, right-clicked, added service referrence. So far, so good.</p>
<p>However, I cannot for the life of me pass "security" credentials across to my service. This is my client code:</p>
<pre><code>var client = new MyClient();
client... | [
{
"answer_id": 380778,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>Have you configured the UserName (message security) or Basic (transport security) client credential type on the endpoint bi... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372383",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11917/"
] | I have a web service (WCF or ASMX doesn't matter)... I have made a Console application, right-clicked, added service referrence. So far, so good.
However, I cannot for the life of me pass "security" credentials across to my service. This is my client code:
```
var client = new MyClient();
client.ClientCredentials.Us... | Yes I have, and apparently if you don't use SSL, .Net throws an exception. So apparently you **can't** do what I want without SSL. |
372,399 | <p>I have 3 tables, foo, foo2bar, and bar. foo2bar is a many to many map between foo and bar. Here are the contents.</p>
<pre><code>select * from foo
+------+
| fid |
+------+
| 1 |
| 2 |
| 3 |
| 4 |
+------+
select * from foo2bar
+------+------+
| fid | bid |
+------+------+
| 1 | 1 |
| 1 |... | [
{
"answer_id": 372415,
"author": "BCS",
"author_id": 1343,
"author_profile": "https://Stackoverflow.com/users/1343",
"pm_score": 3,
"selected": false,
"text": "<pre><code>SELECT * FROM\n foo LEFT JOIN\n (\n Foo2bar JOIN bar\n ON foo2bar.bid = bar.bid AND ... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372399",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21838/"
] | I have 3 tables, foo, foo2bar, and bar. foo2bar is a many to many map between foo and bar. Here are the contents.
```
select * from foo
+------+
| fid |
+------+
| 1 |
| 2 |
| 3 |
| 4 |
+------+
select * from foo2bar
+------+------+
| fid | bid |
+------+------+
| 1 | 1 |
| 1 | 2 |
| 2 |... | ```
SELECT * FROM foo
LEFT OUTER JOIN (foo2bar JOIN bar ON (foo2bar.bid = bar.bid AND zid = 30))
USING (fid);
```
Tested on MySQL 5.0.51.
This is not a subquery, it just uses parentheses to specify the precedence of joins. |
372,412 | <p>I'm trying to write a simple WCF Wrapper to load a SyndicationFeed as a client.</p>
<p>Contract</p>
<pre><code>[ServiceContract]
public interface IFeedService
{
[OperationContract]
[WebGet(UriTemplate="")]
SyndicationFeed GetFeed();
}
</code></pre>
<p>Usage</p>
<pre><code>using (var cf = new WebChann... | [
{
"answer_id": 372413,
"author": "ConcernedOfTunbridgeWells",
"author_id": 15401,
"author_profile": "https://Stackoverflow.com/users/15401",
"pm_score": 4,
"selected": true,
"text": "<p>Oracle also has a cached execution facility. The Query is hashed and matched to a plan if it hits on ... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372412",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37881/"
] | I'm trying to write a simple WCF Wrapper to load a SyndicationFeed as a client.
Contract
```
[ServiceContract]
public interface IFeedService
{
[OperationContract]
[WebGet(UriTemplate="")]
SyndicationFeed GetFeed();
}
```
Usage
```
using (var cf = new WebChannelFactory<IFeedService>(new Uri("http://chan... | Oracle also has a cached execution facility. The Query is hashed and matched to a plan if it hits on the hash table. You can also use this mechanism to force a plan for a particular query. As with SQL Server, you need to use a parameterised query to do this, rather than substituting the values into the string - as the ... |
372,428 | <p>I'm working on a very simple game (essentially an ice sliding puzzle), for now the whole things in one file and the only level is completely blank of any form of obstacle. It throws up a few errors. My current annoyance is an expected primary expression error, can anyone tell me how to fix it (it throws up at line 9... | [
{
"answer_id": 372457,
"author": "Martin York",
"author_id": 14065,
"author_profile": "https://Stackoverflow.com/users/14065",
"pm_score": 2,
"selected": false,
"text": "<p>The for() statment takes three parts separated by ';'</p>\n\n<pre><code>for(<init>;<test>;<post>)... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372428",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33061/"
] | I'm working on a very simple game (essentially an ice sliding puzzle), for now the whole things in one file and the only level is completely blank of any form of obstacle. It throws up a few errors. My current annoyance is an expected primary expression error, can anyone tell me how to fix it (it throws up at line 99)?... | This might help:
```
void movePlayer(){
tempX = x;
tempY = y;
if (key[KEY_UP] && map[y - 1][x] == 3)
for ( ; map[y - 1][x] == 3; --y){
}
else if(key[KEY_DOWN] && map[y + 1][x] == 3)
for ( ; map[y + 1][x] == 3; ++y){
}
else if(key[KEY_RIGHT] && map[y... |
372,434 | <p>I'm struggling with the following problem. I use the <a href="http://docs.jquery.com/Plugins/Autocomplete/autocomplete" rel="noreferrer">jQuery autocomplete plugin</a> to get a list of suggested values from the server. The list would look like this:</p>
<pre>
Username1|UserId1
Username2|UserId2
</pre>
<p>So if I s... | [
{
"answer_id": 372483,
"author": "Oli",
"author_id": 12870,
"author_profile": "https://Stackoverflow.com/users/12870",
"pm_score": 0,
"selected": false,
"text": "<p>I was going to list a few methods here but all but one is junk. Do the string->user conversion on the server as you've been... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372434",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18771/"
] | I'm struggling with the following problem. I use the [jQuery autocomplete plugin](http://docs.jquery.com/Plugins/Autocomplete/autocomplete) to get a list of suggested values from the server. The list would look like this:
```
Username1|UserId1
Username2|UserId2
```
So if I start typing "U", a list of `"Username1"` ... | Use the `result` method of the `autocomplete` plugin to handle this. The data is passed as an array to the callback and you just need to save `data[1]` somewhere. Something like this:
```
$("#my_field").autocomplete(...).result(function(event, data, formatted) {
if (data) {
$("#the_id").attr("value", data[... |
372,446 | <p>I'm overthinking this. I have colors stored in a database table, and I want to set the background of specific cells in a table to those colors. In other words:</p>
<pre><code><table>
<tr>
<td ???set color here???>
...content...
</td>
<td ???next col... | [
{
"answer_id": 372479,
"author": "Diodeus - James MacFarlane",
"author_id": 12579,
"author_profile": "https://Stackoverflow.com/users/12579",
"pm_score": 0,
"selected": false,
"text": "<p>Why not have the DB populate the CSS?</p>\n\n<pre><code>.dark {\n background-color:[database field... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372446",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23935/"
] | I'm overthinking this. I have colors stored in a database table, and I want to set the background of specific cells in a table to those colors. In other words:
```
<table>
<tr>
<td ???set color here???>
...content...
</td>
<td ???next color here???>
...next content..... | You can make a custom CSS file with database data by creating a custom HttpHandler.
But the simple way woud be:
```
<td style="background-color:#000000">
...
</td>
```
with
```
<td style='background-color:<%= GetCellColor() %>'>
...
</td>
``` |
372,484 | <p>I'm writing cross platform C++ code (Windows, Mac). Is there a way to check how much memory is in use by the current process? A very contrived snippet to illustrate:</p>
<pre><code>unsigned long m0 = GetMemoryInUse();
char *p = new char[ random_number ];
unsigned long m1 = GetMemoryInUse();
printf( "%d bytes used\n... | [
{
"answer_id": 372491,
"author": "James Curran",
"author_id": 12725,
"author_profile": "https://Stackoverflow.com/users/12725",
"pm_score": 3,
"selected": true,
"text": "<ul>\n<li>There is no portable way to do that.</li>\n<li>For most Operating systems, there isn't even a reliable way t... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372484",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4065/"
] | I'm writing cross platform C++ code (Windows, Mac). Is there a way to check how much memory is in use by the current process? A very contrived snippet to illustrate:
```
unsigned long m0 = GetMemoryInUse();
char *p = new char[ random_number ];
unsigned long m1 = GetMemoryInUse();
printf( "%d bytes used\n", (m1-m0) );
... | * There is no portable way to do that.
* For most Operating systems, there isn't even a reliable way to do it specific to that OS. |
372,506 | <p>In Git, how could I search for a file or directory by path across a number of branches?</p>
<p>I've written something in a branch, but I don't remember which one. Now I need to find it.</p>
<p><strong>Clarification</strong>: I'm looking for a file which I created on one of my branches. I'd like to find it by pa... | [
{
"answer_id": 372654,
"author": "ididak",
"author_id": 28888,
"author_profile": "https://Stackoverflow.com/users/28888",
"pm_score": 6,
"selected": false,
"text": "<p>git ls-tree might help. To search across all existing branches:</p>\n\n<pre><code>for branch in `git for-each-ref --form... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372506",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4937/"
] | In Git, how could I search for a file or directory by path across a number of branches?
I've written something in a branch, but I don't remember which one. Now I need to find it.
**Clarification**: I'm looking for a file which I created on one of my branches. I'd like to find it by path, and not by its contents, as I... | `git log` + `git branch` will find it for you:
```
% git log --all -- somefile
commit 55d2069a092e07c56a6b4d321509ba7620664c63
Author: Dustin Sallings <dustin@spy.net>
Date: Tue Dec 16 14:16:22 2008 -0800
added somefile
% git branch -a --contains 55d2069
otherbranch
```
Supports globbing, too:
```
% git ... |
372,537 | <p>For the life of me I can't figure out how I'm supposed to set the <code>UITextField</code> to display the text vertically (landscape mode) instead of horizontally (portrait mode). The keyboard shows up properly, but when the keys are pressed the text is entered in the wrong orientation.</p>
<p>Here is the screensho... | [
{
"answer_id": 372570,
"author": "Kristopher Johnson",
"author_id": 1175,
"author_profile": "https://Stackoverflow.com/users/1175",
"pm_score": 1,
"selected": false,
"text": "<p>iPhone OS handles the orientation changes by applying a transform to the view. Are you applying your own tran... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372537",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | For the life of me I can't figure out how I'm supposed to set the `UITextField` to display the text vertically (landscape mode) instead of horizontally (portrait mode). The keyboard shows up properly, but when the keys are pressed the text is entered in the wrong orientation.
Here is the screenshot for the [window](ht... | iPhone OS handles the orientation changes by applying a transform to the view. Are you applying your own transforms that might interfere? |
372,547 | <p>A recent <a href="https://stackoverflow.com/questions/372354/string-immutability">question about string literals</a> in .NET caught my eye. I know that string literals are <a href="http://en.wikipedia.org/wiki/String_intern_pool" rel="noreferrer">interned</a> so that different strings with the same value refer to th... | [
{
"answer_id": 372555,
"author": "matt b",
"author_id": 4249,
"author_profile": "https://Stackoverflow.com/users/4249",
"pm_score": 2,
"selected": false,
"text": "<p>Correct me if I am wrong but don't all objects reside on the heap, in both Java and .NET? </p>\n"
},
{
"answer_id"... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372547",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3848/"
] | A recent [question about string literals](https://stackoverflow.com/questions/372354/string-immutability) in .NET caught my eye. I know that string literals are [interned](http://en.wikipedia.org/wiki/String_intern_pool) so that different strings with the same value refer to the same object. I also know that a string c... | Strings in .NET are reference types, so they are always on the heap (even when they are interned). You can verify this using a debugger such as WinDbg.
If you have the class below
```
class SomeType {
public void Foo() {
string s = "hello world";
Console.WriteLine(s);
Console.Writ... |
372,572 | <p>A requirement for my application is if it looses database connectivity then it must pop up a big modal "No Connection. Try again later" dialog blocking all user interaction until such time that connectivity is regained.</p>
<p>I achieve this by at the start of the application starting an instance of a DeviceMonito... | [
{
"answer_id": 372574,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 1,
"selected": false,
"text": "<p>If you have access to a UI element, you can push to the UI thread by using things like:</p>\n\n<pre><code>someCont... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372572",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5056/"
] | A requirement for my application is if it looses database connectivity then it must pop up a big modal "No Connection. Try again later" dialog blocking all user interaction until such time that connectivity is regained.
I achieve this by at the start of the application starting an instance of a DeviceMonitor class. Th... | I'm pretty sure what Marc suggested should work. This is how I would write it to use your dialog instead of `MessageBox`:
```
someControl.Invoke((Action)delegate {
var d = _dialogFactory.GetNoConnectionDialog();
d.ShowDialog();
}, null);
```
If that really isn't working I've had success in the past using a T... |
372,580 | <p>Visual Studio syntax highlighting colors this word blue as if it were a keyword or reserved word. I tried searching online for it but the word "array" throws the search off, I get mostly pages explaining what an array is. What is it used for?</p>
| [
{
"answer_id": 372584,
"author": "Paul Tomblin",
"author_id": 3333,
"author_profile": "https://Stackoverflow.com/users/3333",
"pm_score": 3,
"selected": false,
"text": "<p>It isn't. At least not in standard C/C++.</p>\n\n<p>Now you might well <a href=\"https://stackoverflow.com/question... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372580",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46811/"
] | Visual Studio syntax highlighting colors this word blue as if it were a keyword or reserved word. I tried searching online for it but the word "array" throws the search off, I get mostly pages explaining what an array is. What is it used for? | It's not a reserved word under ISO standards. Microsoft's [C++/CLI](http://en.wikipedia.org/wiki/C%2B%2B/CLI) defines [array](http://msdn.microsoft.com/en-us/library/ts4c4dw6(VS.85).aspx) in the [cli namespace](http://msdn.microsoft.com/en-us/library/d87eee3k(VS.85).aspx), and Visual Studio's syntax highlighting will t... |
372,581 | <p>When I try to programmatically access a Word object model, I get an error saying no document is active. This appears to be because I am loading the document as not visible using Word automation, and I have to keep it invisible.</p>
<p>How would I code the open macro so that it does nothing in this case? </p>
<p>... | [
{
"answer_id": 372677,
"author": "Dirk Vollmar",
"author_id": 40347,
"author_profile": "https://Stackoverflow.com/users/40347",
"pm_score": 1,
"selected": false,
"text": "<p>Instead of using ActiveDocument you could remember the document that you open (some schematic code):</p>\n\n<pre><... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372581",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4066/"
] | When I try to programmatically access a Word object model, I get an error saying no document is active. This appears to be because I am loading the document as not visible using Word automation, and I have to keep it invisible.
How would I code the open macro so that it does nothing in this case?
`If Not ActiveDocum... | Instead of using ActiveDocument you could remember the document that you open (some schematic code):
```
dim word as new Word.Application
dim doc as Word.Document
doc = word.Documents.Open(fileName)
MsgBox doc.FullName
``` |
372,589 | <p>I was wondering if something exists (in Java world) able to take an snapshot of the JVM current state with the following features:</p>
<ul>
<li>Do it while an exception is being thrown.</li>
<li>Capture local variables, method's arguments, etc.</li>
<li>Put it in a handy file which can be used to extract or reprodu... | [
{
"answer_id": 372649,
"author": "bajafresh4life",
"author_id": 21339,
"author_profile": "https://Stackoverflow.com/users/21339",
"pm_score": 0,
"selected": false,
"text": "<p>Not sure if this is viable in a production environment, but there's the Omniscient debugger:</p>\n\n<blockquote>... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372589",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11583/"
] | I was wondering if something exists (in Java world) able to take an snapshot of the JVM current state with the following features:
* Do it while an exception is being thrown.
* Capture local variables, method's arguments, etc.
* Put it in a handy file which can be used to extract or reproduce in a IDE the situation in... | I give a look to [JavaFrame](http://kenai.com/projects/jvm-frame-introspect) and it seems a good starting point. Just install Apache Ant, do `ant` in the javaframe directory and launch the test suite (inside test directory) with:
```
LD_LIBRARY_PATH=../build/native/ java -agentlib:frameintrospect -classpath ../build/c... |
372,601 | <p>I'm using a <code>DateTime</code> in C# to display times. What date portion does everyone use when constructing a time?</p>
<p>E.g. the following is not valid because there is no zero-th month or zero-th day:</p>
<pre><code>// 4:37:58 PM
DateTime time = new DateTime(0, 0, 0, 16, 47, 58);
</code></pre>
<p>Do I use... | [
{
"answer_id": 372617,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 2,
"selected": false,
"text": "<p>How about <code>DateTime.Now.TimeOfDay</code>, and use the <code>TimeSpan</code>?</p>\n\n<p>Re \"because that does... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372601",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12597/"
] | I'm using a `DateTime` in C# to display times. What date portion does everyone use when constructing a time?
E.g. the following is not valid because there is no zero-th month or zero-th day:
```
// 4:37:58 PM
DateTime time = new DateTime(0, 0, 0, 16, 47, 58);
```
Do I use COM's zero date?
```
// 4:37:58 PM
DateTim... | what about DateTime.MinValue? |
372,604 | <p>what is the code to disable an INPUT text box for HTML?</p>
<p>Thanks</p>
| [
{
"answer_id": 372615,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 7,
"selected": true,
"text": "<pre><code><input type=\"text\" disabled=\"disabled\" />\n</code></pre>\n\n<p>See the <a href=\"http://www.w3.org/TR/htm... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372604",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44973/"
] | what is the code to disable an INPUT text box for HTML?
Thanks | ```
<input type="text" disabled="disabled" />
```
See the [W3C HTML Specification on the input tag](http://www.w3.org/TR/html-markup/input.text.html) for more information. |
372,631 | <p>I'm looking for suggestions on how to inject runtime dependencies into JPA entities retrieved from Hibernate. My problem is essentially this:</p>
<p>I have a number of different subclasses of a Transaction object. Each Transaction subclass has different behavior when it is executed, and requires a different set of ... | [
{
"answer_id": 373381,
"author": "SamBeran",
"author_id": 43379,
"author_profile": "https://Stackoverflow.com/users/43379",
"pm_score": 4,
"selected": true,
"text": "<p>I use guice for transactions, but I use the AOP to carry them out. I have almost no boilerplate, at the expense of a li... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372631",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/390636/"
] | I'm looking for suggestions on how to inject runtime dependencies into JPA entities retrieved from Hibernate. My problem is essentially this:
I have a number of different subclasses of a Transaction object. Each Transaction subclass has different behavior when it is executed, and requires a different set of dependenci... | I use guice for transactions, but I use the AOP to carry them out. I have almost no boilerplate, at the expense of a little "magic". As long as your intercepted class is "in the club," it works really well.
```
class BusinessLogic {
@Inject public EntityManager em;
@Transactional
publc void doSomething() ... |
372,652 | <p>I have recently learned the Ruby programming language, and all in all it is a good language. But I was quite surprised to see that it was not as simple as I had expected. More precisely, the "rule of least-surprise" did not seem very respected to me (of course this is quite subjective). For example:</p>
<pre><co... | [
{
"answer_id": 372669,
"author": "John Topley",
"author_id": 1450,
"author_profile": "https://Stackoverflow.com/users/1450",
"pm_score": 2,
"selected": false,
"text": "<p>One that's caught me out in the past is that the newline character (<code>\\n</code>) escape sequence—amongst o... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372652",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38626/"
] | I have recently learned the Ruby programming language, and all in all it is a good language. But I was quite surprised to see that it was not as simple as I had expected. More precisely, the "rule of least-surprise" did not seem very respected to me (of course this is quite subjective). For example:
```
x = true and f... | [Wikipedia Ruby gotchas](http://en.wikipedia.org/wiki/Ruby_(programming_language)#.22Gotchas.22)
From the article:
* Names which begin with a capital letter are treated as constants, so local variables should begin with a lowercase letter.
* The characters `$` and `@` do not indicate variable data type as in Perl, bu... |
372,655 | <p>Is it possible to use 2 CSS classes that have the same name for the selectors, etc. in the same HTML file? If so, how do you differentiate between the two when styling elements?</p>
| [
{
"answer_id": 372661,
"author": "fasih.rana",
"author_id": 46024,
"author_profile": "https://Stackoverflow.com/users/46024",
"pm_score": 2,
"selected": false,
"text": "<p>Yes it is possible.\nThe definitions in second file will overwrite the definitions of the first file. There is no wa... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372655",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33690/"
] | Is it possible to use 2 CSS classes that have the same name for the selectors, etc. in the same HTML file? If so, how do you differentiate between the two when styling elements? | Yes this is possible, simply include two css files in the HEAD section of the document. Any styles set in the first will be overwritten in the second, so say you have this:
First file:
```css
#something{
background-color: #F00;
color: #FFF;
}
```
And then in the second file:
```css
#something{
backgroun... |
372,660 | <p>Considering you have an MVVM Architecture in WPF like <a href="http://joshsmithonwpf.wordpress.com/2008/11/14/using-a-viewmodel-to-provide-meaningful-validation-error-messages/" rel="nofollow noreferrer">Josh Smith's examples</a></p>
<p>How would you implement two properties 'synced' that update eachother? I have a... | [
{
"answer_id": 372682,
"author": "Szymon Rozga",
"author_id": 7583,
"author_profile": "https://Stackoverflow.com/users/7583",
"pm_score": 3,
"selected": true,
"text": "<p>One way:</p>\n\n<pre><code> public class Sample : INotifyPropertyChanged\n {\n private const double Mult... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372660",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26579/"
] | Considering you have an MVVM Architecture in WPF like [Josh Smith's examples](http://joshsmithonwpf.wordpress.com/2008/11/14/using-a-viewmodel-to-provide-meaningful-validation-error-messages/)
How would you implement two properties 'synced' that update eachother? I have a Price property, and a PriceVatInclusive proper... | One way:
```
public class Sample : INotifyPropertyChanged
{
private const double Multiplier = 1.21;
#region Fields
private double price;
private double vat;
#endregion
#region Properties
public double Price
{
get { return price; }
... |
372,664 | <p>I have an html table which i bind data dynamically on the server side in C#.. The problem is that I have a search button that calls a search on the DB(in a search method on the server side) based on the information from the client page. this search method loads the info from the DB and updates the html table(this is... | [
{
"answer_id": 372682,
"author": "Szymon Rozga",
"author_id": 7583,
"author_profile": "https://Stackoverflow.com/users/7583",
"pm_score": 3,
"selected": true,
"text": "<p>One way:</p>\n\n<pre><code> public class Sample : INotifyPropertyChanged\n {\n private const double Mult... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372664",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39809/"
] | I have an html table which i bind data dynamically on the server side in C#.. The problem is that I have a search button that calls a search on the DB(in a search method on the server side) based on the information from the client page. this search method loads the info from the DB and updates the html table(this is wh... | One way:
```
public class Sample : INotifyPropertyChanged
{
private const double Multiplier = 1.21;
#region Fields
private double price;
private double vat;
#endregion
#region Properties
public double Price
{
get { return price; }
... |
372,665 | <p>Given a class like this:</p>
<pre><code>class Foo {
public:
Foo(int);
Foo(const Foo&);
Foo& operator=(int);
private:
// ...
};
</code></pre>
<p>Are these two lines exactly equivalent, or is there a subtle difference between them?</p>
<pre><code>Foo f(42);
Foo f = 42;
</code></pre>
<hr... | [
{
"answer_id": 372673,
"author": "fasih.rana",
"author_id": 46024,
"author_profile": "https://Stackoverflow.com/users/46024",
"pm_score": 4,
"selected": true,
"text": "<pre><code>Foo f = 42;\n</code></pre>\n\n<p>This statement will make a temporary object for the value '42'.</p>\n\n<pre... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372665",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1175/"
] | Given a class like this:
```
class Foo {
public:
Foo(int);
Foo(const Foo&);
Foo& operator=(int);
private:
// ...
};
```
Are these two lines exactly equivalent, or is there a subtle difference between them?
```
Foo f(42);
Foo f = 42;
```
---
Edit: I confused matters by making the Foo construct... | ```
Foo f = 42;
```
This statement will make a temporary object for the value '42'.
```
Foo f(42);
```
This statement will directly assign the value so one less function call. |
372,686 | <p>I understand that I can specify system properties to Tomcat by passing arguments with the -D parameter, for example "<strong>-Dmy.prop=value</strong>".</p>
<p>I am wondering if there is a cleaner way of doing this by specifying the property values in the context.xml file or some other tomcat configuration file. I w... | [
{
"answer_id": 376827,
"author": "cliff.meyers",
"author_id": 41754,
"author_profile": "https://Stackoverflow.com/users/41754",
"pm_score": 5,
"selected": true,
"text": "<p>(Update: If I could delete this answer I would, although since it's accepted, I can't. I'm updating the description... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372686",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45856/"
] | I understand that I can specify system properties to Tomcat by passing arguments with the -D parameter, for example "**-Dmy.prop=value**".
I am wondering if there is a cleaner way of doing this by specifying the property values in the context.xml file or some other tomcat configuration file. I would like to do this be... | (Update: If I could delete this answer I would, although since it's accepted, I can't. I'm updating the description to provide better guidance and discourage folks from using the poor practice I outlined in the original answer).
You can specify these parameters via context or environment parameters, such as in context... |
372,693 | <p>I have a configuration file where a developer can specify a text color by passing in a string:</p>
<pre><code> <text value="Hello, World" color="Red"/>
</code></pre>
<p>Rather than have a gigantic switch statement look for all of the possible colors, it'd be nice to just use the properties in the class Syste... | [
{
"answer_id": 372704,
"author": "leppie",
"author_id": 15541,
"author_profile": "https://Stackoverflow.com/users/15541",
"pm_score": -1,
"selected": false,
"text": "<p>Try using a <code>TypeConverter</code>. Example:</p>\n\n<pre><code>var tc = TypeDescriptor.GetConverter(typeof(Brush))... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372693",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8173/"
] | I have a configuration file where a developer can specify a text color by passing in a string:
```
<text value="Hello, World" color="Red"/>
```
Rather than have a gigantic switch statement look for all of the possible colors, it'd be nice to just use the properties in the class System.Drawing.Brushes instead so int... | Recap of all previous answers, different ways to convert a string to a Color or Brush:
```
// best, using Color's static method
Color red1 = Color.FromName("Red");
// using a ColorConverter
TypeConverter tc1 = TypeDescriptor.GetConverter(typeof(Color)); // ..or..
TypeConverter tc2 = new ColorConverter();
Color red2 =... |
372,695 | <p>Does anyone know if there's a de-facto standard (i.e., TR1 or Boost) C++ function object for accessing the elements of a std::pair? Twice in the past 24 hours I've wished I had something like the <code>keys</code> function for Perl hashes. For example, it would be nice to run std::transform on a std::map object an... | [
{
"answer_id": 372720,
"author": "Head Geek",
"author_id": 12193,
"author_profile": "https://Stackoverflow.com/users/12193",
"pm_score": 2,
"selected": false,
"text": "<p>From the way you worded your question, I'm not sure this is a proper response, but try <code>boost::tie</code> (part ... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372695",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46821/"
] | Does anyone know if there's a de-facto standard (i.e., TR1 or Boost) C++ function object for accessing the elements of a std::pair? Twice in the past 24 hours I've wished I had something like the `keys` function for Perl hashes. For example, it would be nice to run std::transform on a std::map object and dump all the k... | `boost::bind` is what you look for.
```
boost::bind(&std::pair::second, _1); // returns the value of a pair
```
Example:
```
typedef std::map<std::string, int> map_type;
std::vector<int> values; // will contain all values
map_type map;
std::transform(map.begin(),
map.end(),
std::bac... |
372,696 | <p>When I inserted text from one SQL Server VARCHAR(MAX) field in one database to another, I get question mark symbols - "?" - in the target database (in addition to line feeds) whenever there are line feeds in the source database.</p>
<p>Text in the target database looks like this:</p>
<p>Line one.?<br>
?<br>
Line t... | [
{
"answer_id": 372720,
"author": "Head Geek",
"author_id": 12193,
"author_profile": "https://Stackoverflow.com/users/12193",
"pm_score": 2,
"selected": false,
"text": "<p>From the way you worded your question, I'm not sure this is a proper response, but try <code>boost::tie</code> (part ... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372696",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | When I inserted text from one SQL Server VARCHAR(MAX) field in one database to another, I get question mark symbols - "?" - in the target database (in addition to line feeds) whenever there are line feeds in the source database.
Text in the target database looks like this:
Line one.?
?
Line two.?
?
Any idea... | `boost::bind` is what you look for.
```
boost::bind(&std::pair::second, _1); // returns the value of a pair
```
Example:
```
typedef std::map<std::string, int> map_type;
std::vector<int> values; // will contain all values
map_type map;
std::transform(map.begin(),
map.end(),
std::bac... |
372,703 | <p>I would like to store log4net config data in my application.config file. Based on my understanding of the documentation, I did the following:</p>
<ol>
<li><p>Add a reference to log4net.dll</p></li>
<li><p>Add the following line in AssemblyInfo.cs: </p>
<pre><code>[assembly: log4net.Config.XmlConfigurator(Watch = ... | [
{
"answer_id": 372725,
"author": "Joachim Kerschbaumer",
"author_id": 20227,
"author_profile": "https://Stackoverflow.com/users/20227",
"pm_score": 2,
"selected": false,
"text": "<p>Have you tried adding a <code>configsection</code> handler to your app.config? e.g.</p>\n\n<pre class=\"la... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372703",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29726/"
] | I would like to store log4net config data in my application.config file. Based on my understanding of the documentation, I did the following:
1. Add a reference to log4net.dll
2. Add the following line in AssemblyInfo.cs:
```
[assembly: log4net.Config.XmlConfigurator(Watch = true)]
```
3. Initialize the logger as f... | Add a line to your app.config in the configSections element
```xml
<configSections>
<section name="log4net"
type="log4net.Config.Log4NetConfigurationSectionHandler, log4net, Version=1.2.10.0,
Culture=neutral, PublicKeyToken=1b44e1d426115821" />
</configSections>
```
Then later add the log4Net section,... |
372,714 | <p>So I have this code for these Constructors of the Weapon class:</p>
<pre><code>Weapon(const WeaponsDB * wepDB);
Weapon(const WeaponsDB * wepDB_, int * weaponlist);
~Weapon(void);
</code></pre>
<p>And I keep getting an error:</p>
<pre><code>1>c:\users\owner\desktop\bosconian\code\bosconian\weapon.h(20) : erro... | [
{
"answer_id": 372746,
"author": "Tim",
"author_id": 10755,
"author_profile": "https://Stackoverflow.com/users/10755",
"pm_score": 3,
"selected": false,
"text": "<p>So you named your class the same as a preprocessor directive? That is something I would avoid.</p>\n\n<p>Try changing your ... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372714",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39189/"
] | So I have this code for these Constructors of the Weapon class:
```
Weapon(const WeaponsDB * wepDB);
Weapon(const WeaponsDB * wepDB_, int * weaponlist);
~Weapon(void);
```
And I keep getting an error:
```
1>c:\users\owner\desktop\bosconian\code\bosconian\weapon.h(20) : error C2062: type 'int' unexpected
```
and... | ```
#ifndef Weapon
#define Weapon
```
This is almost certainly going to cause weirdness; call the constant WEAPON\_H instead. |
372,715 | <p>Ok, this is not a CSS issue, I removed all styling from the page. This is a calendar extender that has a target id of a textbox and the popupbutton is the same text box. </p>
<p>The month name is displaying lower than the
days, so it's not usable. </p>
<p>it's fine in IE. </p>
<p>I am using Safari in Windows Vis... | [
{
"answer_id": 372776,
"author": "Diones",
"author_id": 2605,
"author_profile": "https://Stackoverflow.com/users/2605",
"pm_score": 2,
"selected": false,
"text": "<p>I think it was voted down because you didn't entered any code in your question, so it looks like you are asking support to... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372715",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4140/"
] | Ok, this is not a CSS issue, I removed all styling from the page. This is a calendar extender that has a target id of a textbox and the popupbutton is the same text box.
The month name is displaying lower than the
days, so it's not usable.
it's fine in IE.
I am using Safari in Windows Vista.
Does anyone know w... | I think it was voted down because you didn't entered any code in your question, so it looks like you are asking support to your Safari browser instead of asking for help on a particularity of how safari treats AJAX.
In other words you need to be more specific and clear. |
372,721 | <p>the homework: <a href="http://www.cs.rit.edu/~waw/networks/prob1.082.html" rel="nofollow noreferrer">http://www.cs.rit.edu/~waw/networks/prob1.082.html</a></p>
<p>Ok, I am still confused why this question was asked for my data communications and networks class, but here is the question from my homework:</p>
<block... | [
{
"answer_id": 372763,
"author": "Leon Timmermans",
"author_id": 4727,
"author_profile": "https://Stackoverflow.com/users/4727",
"pm_score": 3,
"selected": false,
"text": "<p>A few tips:</p>\n\n<ul>\n<li><code>print \"$_\"</code> is equal to <code>print</code></li>\n<li>while(<>) {...... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372721",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | the homework: <http://www.cs.rit.edu/~waw/networks/prob1.082.html>
Ok, I am still confused why this question was asked for my data communications and networks class, but here is the question from my homework:
>
> 8. Write a computer program that reads the header on an e-mail message and
> deletes all lines except t... | A few tips:
* `print "$_"` is equal to `print`
* while(<>) {...} can be replaced by adding -n to the options on the `#!` line/
* $\_ =~ m// is equal to //
* You're typing four `:`'s where one is good enough.
Something like
```
#!/usr/bin/perl -n
print if /^(To|From|Subject|Cc):/;
``` |
372,731 | <p>How can I set a custom background color of a button? </p>
<p>Interface Builder doesn't seem to have an interface to do this. </p>
<p>Is it only available programmatically?
If so, can you provide an example, please?</p>
| [
{
"answer_id": 372817,
"author": "keremk",
"author_id": 29475,
"author_profile": "https://Stackoverflow.com/users/29475",
"pm_score": -1,
"selected": false,
"text": "<p>May be I misunderstood your question, but does below not work for you?</p>\n\n<p><img src=\"https://i.stack.imgur.com/I... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372731",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How can I set a custom background color of a button?
Interface Builder doesn't seem to have an interface to do this.
Is it only available programmatically?
If so, can you provide an example, please? | I found that I needed to use a stretchable image to accomplish this. Apple's UICatalog example has one or more colored buttons that are drawn in this fashion. You could use their template image and recolor it to suit your button needs.
I'm not sure about doing this in Interface Builder, but I was able to create a butt... |
372,742 | <p>This is related to a question I asked the other day on <a href="https://stackoverflow.com/questions/366629/how-do-i-send-an-email-message-from-my-c-application">how to send email</a>. </p>
<p>My new, related question is this... what if the user of my application is behind a firewall or some other reason why the l... | [
{
"answer_id": 372753,
"author": "Jon B",
"author_id": 27414,
"author_profile": "https://Stackoverflow.com/users/27414",
"pm_score": 4,
"selected": true,
"text": "<p>I think this is a case where exception handling would be the preferred solution. You really don't know that it will work u... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372742",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44004/"
] | This is related to a question I asked the other day on [how to send email](https://stackoverflow.com/questions/366629/how-do-i-send-an-email-message-from-my-c-application).
My new, related question is this... what if the user of my application is behind a firewall or some other reason why the line client.Send(mail) w... | I think this is a case where exception handling would be the preferred solution. You really don't know that it will work until you try, and failure is an exception.
Edit:
You'll want to handle SmtpException. This has a StatusCode property, which is an enum that will tell you why the Send() failed. |
372,750 | <p>I was trying to use the slime-connect function to get access to a remote server with sbcl. I followed all the steps from the slime.mov movie from <a href="http://www.guba.com/watch/30000548671" rel="noreferrer">Marco Baringer,</a> but I got stuck when creating the ssh connection for slime. This is after already star... | [
{
"answer_id": 384650,
"author": "Anton Nazarov",
"author_id": 38204,
"author_profile": "https://Stackoverflow.com/users/38204",
"pm_score": 2,
"selected": false,
"text": "<p>I don't know, but you can try to connect to swank on remote machine locally. </p>\n\n<pre><code>ssh user@server.c... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372750",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9082/"
] | I was trying to use the slime-connect function to get access to a remote server with sbcl. I followed all the steps from the slime.mov movie from [Marco Baringer,](http://www.guba.com/watch/30000548671) but I got stuck when creating the ssh connection for slime. This is after already starting the swank server on the re... | I don't know, but you can try to connect to swank on remote machine locally.
```
ssh user@server.com
telnet 127.0.0.1:4005
```
May be there you will find errors. Also you can try localhost:4005 instead of 127.0.0.1 and check if localhost interface is properly configured. |
372,771 | <pre><code>[hannel,192.168.0.46:40014] 15:08:03,642 - ERROR - org.jgroups.protocols.UDP - failed sending message to null (61 bytes)
java.lang.Exception: dest=/225.1.2.46:30446 (64 bytes)
at org.jgroups.protocols.UDP._send(UDP.java:333)
at org.jgroups.protocols.UDP.sendToAllMembers(UDP.java:283)
at org.jgrou... | [
{
"answer_id": 372802,
"author": "matt b",
"author_id": 4249,
"author_profile": "https://Stackoverflow.com/users/4249",
"pm_score": 0,
"selected": false,
"text": "<p>Is it possible you are getting an error because you are sending a message to \"null\"?</p>\n\n<blockquote>\n <p>ERROR - o... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372771",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13267/"
] | ```
[hannel,192.168.0.46:40014] 15:08:03,642 - ERROR - org.jgroups.protocols.UDP - failed sending message to null (61 bytes)
java.lang.Exception: dest=/225.1.2.46:30446 (64 bytes)
at org.jgroups.protocols.UDP._send(UDP.java:333)
at org.jgroups.protocols.UDP.sendToAllMembers(UDP.java:283)
at org.jgroups.prot... | In response to matt b, the "failed sending message to null" message is misleading. The true problem is the InterruptedIOException. This means that someone called interrupt() on the Thread that was sending UDP. Most likely, the interrupt is generated within JGroups. (Unless you started, and then stopped the JGroups chan... |
372,773 | <pre><code>enum MyEnum {
A( 1, 2, 3, 4),
B(1, 2),
C(4, 5, 8, 8, 9);
private MyEnum( int firstInt, int... otherInts ) {
// do something with arguments, perhaps initialize a List
}
}
</code></pre>
<p>Are there any problems with this? Any reasons not to do it?</p>
| [
{
"answer_id": 372777,
"author": "Jorn",
"author_id": 8681,
"author_profile": "https://Stackoverflow.com/users/8681",
"pm_score": 4,
"selected": true,
"text": "<p>Sure, this is perfectly legal. No reason not to do it if your program requires it.</p>\n"
},
{
"answer_id": 373063,
... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372773",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39489/"
] | ```
enum MyEnum {
A( 1, 2, 3, 4),
B(1, 2),
C(4, 5, 8, 8, 9);
private MyEnum( int firstInt, int... otherInts ) {
// do something with arguments, perhaps initialize a List
}
}
```
Are there any problems with this? Any reasons not to do it? | Sure, this is perfectly legal. No reason not to do it if your program requires it. |
372,778 | <p>I have written some CSS which targets elements using the parent > child selector. Specifically for tables so I can apply certain styles to the headers and footers like this</p>
<pre><code>table > thead > tr > th ...
table > tbody > tr > td ...
//there are other uses in the css as well
</code></pre... | [
{
"answer_id": 372805,
"author": "Pim Jager",
"author_id": 35197,
"author_profile": "https://Stackoverflow.com/users/35197",
"pm_score": 0,
"selected": false,
"text": "<p>You could target them using JavaScript, but that hardly is a real solution since it would require javaScript for some... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372778",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45/"
] | I have written some CSS which targets elements using the parent > child selector. Specifically for tables so I can apply certain styles to the headers and footers like this
```
table > thead > tr > th ...
table > tbody > tr > td ...
//there are other uses in the css as well
```
This works great, except in IE6. What ... | Usually you can just remove the '>' and it will work. It's a matter of how your CSS and HTML is written. I'd give it a shot. |
372,807 | <p>I have a problem with a bash script. I have to use the operator * to multiplicate. Instead the script bugs me with expansion and using as operator the name of the script itself. I tried with single quotes but it doesn't work :( Here's the code</p>
<pre><code>#!/bin/bash -x
# Bash script that calculates an arithmet... | [
{
"answer_id": 372841,
"author": "Paul Tomblin",
"author_id": 3333,
"author_profile": "https://Stackoverflow.com/users/3333",
"pm_score": 4,
"selected": true,
"text": "<p>If \"op\" is \"*\", it will be expanded by the shell before your script even sees it. You need to choose something e... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372807",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41977/"
] | I have a problem with a bash script. I have to use the operator \* to multiplicate. Instead the script bugs me with expansion and using as operator the name of the script itself. I tried with single quotes but it doesn't work :( Here's the code
```
#!/bin/bash -x
# Bash script that calculates an arithmetic expression... | If "op" is "\*", it will be expanded by the shell before your script even sees it. You need to choose something else for your multiplication operator, like "x", or force your users to escape it by putting it in single quotes or preceeding it with a backslash.
If the terms of the exercise allow it, maybe you should try... |
372,808 | <p>I have uploaded some files to a directory under public and I try to access them using Dir.glob. But I get no results back. </p>
<p>The Dir.glob works fine on dev server (mongrel) and also works fine when using script/console on the site installed on site5</p>
<p>is there a way to get this working or a different wa... | [
{
"answer_id": 372851,
"author": "Keltia",
"author_id": 16143,
"author_profile": "https://Stackoverflow.com/users/16143",
"pm_score": 2,
"selected": true,
"text": "<p>My guess is that executing a shell is prohibited by site5 or that you don't have access to /bin/sh. Globbing is generall... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372808",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36465/"
] | I have uploaded some files to a directory under public and I try to access them using Dir.glob. But I get no results back.
The Dir.glob works fine on dev server (mongrel) and also works fine when using script/console on the site installed on site5
is there a way to get this working or a different way to get the list... | My guess is that executing a shell is prohibited by site5 or that you don't have access to /bin/sh. Globbing is generally implemented by running a shell... Try
```
Dir.entries("public").each do |f|
puts(f)
end
``` |
372,812 | <p>I am running C# framework 2.0 and I would like to get some of the data from a list? The list is a List<>. How can I do that without looping and doing comparaison manually on each element of the List<>?</p>
| [
{
"answer_id": 372822,
"author": "Patrick Desjardins",
"author_id": 13913,
"author_profile": "https://Stackoverflow.com/users/13913",
"pm_score": 3,
"selected": true,
"text": "<p>You can try Predicate. Here is a code I wrote to illustrate the point. Of course, as you can see in this exam... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372812",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46829/"
] | I am running C# framework 2.0 and I would like to get some of the data from a list? The list is a List<>. How can I do that without looping and doing comparaison manually on each element of the List<>? | You can try Predicate. Here is a code I wrote to illustrate the point. Of course, as you can see in this example, you can move the Predicate outside the calling class and have a control on it. This is useful if you need to have more option with it. Inside the predicate you can do many comparison with all property/funct... |
372,815 | <pre><code> for m := 0 to 300 do
if Pos(certain_String, string(arrayitem(m)) <> 0 then
begin
randomize;
x := random(100);
begin
case x of
0..69 : function(m); // 70 percent
70..79 : function(m+1); // 10 percent
80..84 : ... | [
{
"answer_id": 372840,
"author": "pyon",
"author_id": 46571,
"author_profile": "https://Stackoverflow.com/users/46571",
"pm_score": 0,
"selected": false,
"text": "<p>There must be an equivalent to C's <code>break</code> in Object Pascal. That's a cleaner way to get out of the loop.</p>\n... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372815",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | ```
for m := 0 to 300 do
if Pos(certain_String, string(arrayitem(m)) <> 0 then
begin
randomize;
x := random(100);
begin
case x of
0..69 : function(m); // 70 percent
70..79 : function(m+1); // 10 percent
80..84 : function(m+2)... | Changed the code a bit:
```
randomize;
for m := 0 to 300 do begin
if Pos(certain_String, string(arrayitem(m)) <> 0 then begin
x := random(100);
case x of
0..69 : function(m); // 70 percent
70..79 : function(m+1); // 10 percent
80..84 : function(m+2); // 5 percent
85..88 : function(m... |
372,828 | <p>I wrote below code to remove checked item from radio group in my form by double click.</p>
<pre><code>$("input[type='radio']").each(function(){
$(this).dblclick(function(){
$(this).removeAttr("checked");
});
});
</code></pre>
<p>but this code doesn't work in FireFox ... | [
{
"answer_id": 372856,
"author": "Ata",
"author_id": 46110,
"author_profile": "https://Stackoverflow.com/users/46110",
"pm_score": 1,
"selected": false,
"text": "<p>I am so sorry, It works. I think cache makes this issue.</p>\n"
},
{
"answer_id": 1298571,
"author": "Andy Gask... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372828",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46110/"
] | I wrote below code to remove checked item from radio group in my form by double click.
```
$("input[type='radio']").each(function(){
$(this).dblclick(function(){
$(this).removeAttr("checked");
});
});
```
but this code doesn't work in FireFox but work in IE.
anybody kn... | Either way, you probably want to wire it up a little differently.
```
$("input[type='radio']").dblclick(function(){
$(this).removeAttr("checked");
});
```
One thing that can help when learning jQuery is to think set-based, like SQL. Selectors can select one or a group of elements. Any function or event you call on... |
372,862 | <p>I'm an old (but not too old) Java programmer, that decided to learn C++. But I have seen that much of C++ programming style, is... well, just damn ugly!</p>
<p>All that stuff of putting the class definition in a header file, and the methods in a different source file- Calling functions out of nowhere, instead of us... | [
{
"answer_id": 372879,
"author": "Julienne Walker",
"author_id": 13259,
"author_profile": "https://Stackoverflow.com/users/13259",
"pm_score": 3,
"selected": false,
"text": "<p>Find a style that works for you, just like everyone else did. Nobody is forcing you to use one of the \"ugly\" ... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372862",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2605/"
] | I'm an old (but not too old) Java programmer, that decided to learn C++. But I have seen that much of C++ programming style, is... well, just damn ugly!
All that stuff of putting the class definition in a header file, and the methods in a different source file- Calling functions out of nowhere, instead of using method... | In addition to what others have said here, there are even more important problems:
1) Large translation units lead to longer compile times and larger
object file sizes.
2) Circular dependencies! And this is the big one. And it can almost
always be fixed by splitting up headers and source:
```
// Vehicle.h
class Wh... |
372,865 | <p><a href="https://msdn.microsoft.com/en-us/library/system.io.path.combine%28v=vs.110%29.aspx" rel="noreferrer">Path.Combine</a> is handy, but is there a similar function in the .NET framework for <a href="http://en.wikipedia.org/wiki/Uniform_resource_locator" rel="noreferrer">URLs</a>?</p>
<p>I'm looking for syntax ... | [
{
"answer_id": 372888,
"author": "Ryan Cook",
"author_id": 43029,
"author_profile": "https://Stackoverflow.com/users/43029",
"pm_score": 7,
"selected": false,
"text": "<p>You use <code>Uri.TryCreate( ... )</code> :</p>\n\n<pre><code>Uri result = null;\n\nif (Uri.TryCreate(new Uri(\"http:... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372865",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16082/"
] | [Path.Combine](https://msdn.microsoft.com/en-us/library/system.io.path.combine%28v=vs.110%29.aspx) is handy, but is there a similar function in the .NET framework for [URLs](http://en.wikipedia.org/wiki/Uniform_resource_locator)?
I'm looking for syntax like this:
```
Url.Combine("http://MyUrl.com/", "/Images/Image.jp... | There [is a Todd Menier's comment above](https://stackoverflow.com/questions/372865/path-combine-for-urls/43582421#comment33212350_372865) that [Flurl](https://flurl.dev/) includes a `Url.Combine`.
More details:
>
> Url.Combine is basically a Path.Combine for URLs, ensuring one
> and only one separator character bet... |
372,869 | <p>I get the name of a variable from the script user as the first argument and I echo the value of said variable back to the console:</p>
<pre><code>#!/bin/bash
variablename=$1
echo "The value of $variablename is: " ${!variablename}
</code></pre>
<p>This works great!</p>
<p>What I can't get to work is if I want to c... | [
{
"answer_id": 372876,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 4,
"selected": true,
"text": "<p>I had a flash all of a sudden, minutes after asking for help, and I think I have a solution:</p>\n\n<pre><code>#!/bin/bash\n... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372869",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I get the name of a variable from the script user as the first argument and I echo the value of said variable back to the console:
```
#!/bin/bash
variablename=$1
echo "The value of $variablename is: " ${!variablename}
```
This works great!
What I can't get to work is if I want to change that variable into the valu... | I had a flash all of a sudden, minutes after asking for help, and I think I have a solution:
```
#!/bin/bash
variablename=$1
echo "The value of $variablename is: " ${!variablename}
echo "I will now try to change the value into $2."
eval "$variablename=$2"
echo "Success! $variablename now has the value ${!variablename}... |
372,872 | <p>When converting from PNG to JPG using the MagickWand API, how do I set the background to white for transparent pixels?</p>
| [
{
"answer_id": 373398,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "<p>Use MagickMergeImageLayers </p>\n"
},
{
"answer_id": 4318947,
"author": "Oldes",
"author_id": 494472,
"... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372872",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | When converting from PNG to JPG using the MagickWand API, how do I set the background to white for transparent pixels? | ```
if(current_wand && IsMagickWand(current_wand)){
status=MagickReadImage(current_wand, "test.png");
if (status == MagickFalse) {
ThrowWandException(current_wand);
}
PixelWand *color = NewPixelWand();
PixelSetColor(color, "white");
MagickSetImageBackgroundColor(current_wand, color);
... |
372,877 | <p>I have Default.aspx page, which inherits from BasePage.cs, which inherits from System.Web.UI.Page. BasePage is where I do some common things every page must do upon loading.</p>
<p>In BasePage, lets say I'm checking for X. If X=1, then I will redirect to my "Discontinued.aspx" page immediately and stop execution ... | [
{
"answer_id": 372930,
"author": "Steven A. Lowe",
"author_id": 9345,
"author_profile": "https://Stackoverflow.com/users/9345",
"pm_score": 5,
"selected": true,
"text": "<p>are you exiting from the function that calls redirect, e.g.</p>\n\n<pre><code>...redirect(stopit,true);\nreturn;\n<... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372877",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44698/"
] | I have Default.aspx page, which inherits from BasePage.cs, which inherits from System.Web.UI.Page. BasePage is where I do some common things every page must do upon loading.
In BasePage, lets say I'm checking for X. If X=1, then I will redirect to my "Discontinued.aspx" page immediately and stop execution of BasePage.... | are you exiting from the function that calls redirect, e.g.
```
...redirect(stopit,true);
return;
```
? |
372,885 | <p>How do I connect to a MySQL database using a python program?</p>
| [
{
"answer_id": 372896,
"author": "George Stocker",
"author_id": 16587,
"author_profile": "https://Stackoverflow.com/users/16587",
"pm_score": 8,
"selected": false,
"text": "<p>Here's one way to do it, using <a href=\"https://pypi.org/project/MySQL-python/\" rel=\"noreferrer\">MySQLdb</a>... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372885",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How do I connect to a MySQL database using a python program? | Connecting to MYSQL with Python 2 in three steps
------------------------------------------------
**1 - Setting**
You must install a MySQL driver before doing anything. Unlike PHP, Only the SQLite driver is installed by default with Python. The most used package to do so is [MySQLdb](http://pypi.python.org/pypi/MySQL... |
372,893 | <p>I want to create a file that only resides in memory... In looking through some documentation I saw a recommendation to use a shell extension as a virtual file. Im not sure that is a workable solution but I would like to know</p>
<ol>
<li>Is it a good approach (or should I be using a ramdisk instead)</li>
<li>Wher... | [
{
"answer_id": 372896,
"author": "George Stocker",
"author_id": 16587,
"author_profile": "https://Stackoverflow.com/users/16587",
"pm_score": 8,
"selected": false,
"text": "<p>Here's one way to do it, using <a href=\"https://pypi.org/project/MySQL-python/\" rel=\"noreferrer\">MySQLdb</a>... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372893",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38734/"
] | I want to create a file that only resides in memory... In looking through some documentation I saw a recommendation to use a shell extension as a virtual file. Im not sure that is a workable solution but I would like to know
1. Is it a good approach (or should I be using a ramdisk instead)
2. Where is a good place to ... | Connecting to MYSQL with Python 2 in three steps
------------------------------------------------
**1 - Setting**
You must install a MySQL driver before doing anything. Unlike PHP, Only the SQLite driver is installed by default with Python. The most used package to do so is [MySQLdb](http://pypi.python.org/pypi/MySQL... |
372,907 | <p>How do I maintain the scroll position of the parent page when I open new window using window.open()? The parent page returns to the top of the page.</p>
<p>Here is my current code:</p>
<pre><code><a href="#" onclick="javascript: window.open('myPage.aspx');">
Open New Window
</a>
</code></pre>
| [
{
"answer_id": 372924,
"author": "Grant Wagner",
"author_id": 9254,
"author_profile": "https://Stackoverflow.com/users/9254",
"pm_score": 4,
"selected": true,
"text": "<pre><code><a href=\"#\" onclick=\"window.open('myPage.aspx');return false;\">Open New Window</a>\n</code></... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372907",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26327/"
] | How do I maintain the scroll position of the parent page when I open new window using window.open()? The parent page returns to the top of the page.
Here is my current code:
```
<a href="#" onclick="javascript: window.open('myPage.aspx');">
Open New Window
</a>
``` | ```
<a href="#" onclick="window.open('myPage.aspx');return false;">Open New Window</a>
```
* `javascript:` is not required in event attributes.
* You were not returning false from the event handler, so the link was being following, it was equivilent to `<a href="#">Scroll to top</a>`. |
372,914 | <p>I have the following code to zip all the files and then save it to the harddisk. I want zip all the files (this is done) and then attach the zip file to the Response stream so that the user have the option to save it! </p>
<pre><code>protected void DownloadSelectedFiles_Click(object sender, EventArgs e)
{
... | [
{
"answer_id": 373238,
"author": "Stefan",
"author_id": 19307,
"author_profile": "https://Stackoverflow.com/users/19307",
"pm_score": 1,
"selected": false,
"text": "<p>If you are using IE, check that its not the old \"cache is full\"-bug that is showing its ugly face.</p>\n\n<p>And if y... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372914",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3797/"
] | I have the following code to zip all the files and then save it to the harddisk. I want zip all the files (this is done) and then attach the zip file to the Response stream so that the user have the option to save it!
```
protected void DownloadSelectedFiles_Click(object sender, EventArgs e)
{
str... | I blogged about sending files like this a while ago. You might find something usefull in there.
<http://absolutecobblers.blogspot.com/2008/02/downloading-and-deleting-temporary.html> |
372,915 | <p>I'm dealing with game dialogue files (conversation between player and non-playable-characters) where dialogue choices and their outcome depend on certain conditions and result in certain actions. Now, I could write a simple parser to handle some sort of language for specifying the pre and post-conditions, but a frie... | [
{
"answer_id": 373030,
"author": "Andrew Cowenhoven",
"author_id": 12281,
"author_profile": "https://Stackoverflow.com/users/12281",
"pm_score": 1,
"selected": false,
"text": "<p>A DSL would be a Mercedes-Benz implementation for this and would be fun to write in Ruby. You are right, it w... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372915",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23153/"
] | I'm dealing with game dialogue files (conversation between player and non-playable-characters) where dialogue choices and their outcome depend on certain conditions and result in certain actions. Now, I could write a simple parser to handle some sort of language for specifying the pre and post-conditions, but a friend ... | Unless your game will have less than half a dozen unique dialogs, you should definitely put this information in some kind of data file. XML is a strong contender for the format. I don't speak Ruby, so it may not work in this case, but another option would be to define the dialog as data directly in Ruby code. (I know t... |
372,933 | <p>I am taking in a string from user input, and splitting it on whitespace (using \w) into an array of strings. I then loop through the array, and append a part of the where clause like this:</p>
<pre><code> query += " AND ( "
+ "field1 LIKE '%" + searchStrings[i] +"%' "
... | [
{
"answer_id": 372953,
"author": "Joachim Sauer",
"author_id": 40342,
"author_profile": "https://Stackoverflow.com/users/40342",
"pm_score": 3,
"selected": false,
"text": "<p>There are just too many ways to get this wrong, that I wouldn't rely if anyone told me \"no, this will be safe, b... | 2008/12/16 | [
"https://Stackoverflow.com/questions/372933",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4257/"
] | I am taking in a string from user input, and splitting it on whitespace (using \w) into an array of strings. I then loop through the array, and append a part of the where clause like this:
```
query += " AND ( "
+ "field1 LIKE '%" + searchStrings[i] +"%' "
+ " OR field2 L... | Any time you allow a user to enter data into a query string like this you are vulnerable to SQL injection and it should be avoided like the plague!
You should be very careful how you allow your searchStrings[] array to be populated. You should always append variable data to your query using parameter objects:
```
+ f... |