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 |
|---|---|---|---|---|---|---|
478,573 | <p>I have the following code:</p>
<pre><code>public class Test
{
public static void Main()
{
List<Person> list = new List<Person>();
Person person = new Person() { Name="Chris" };
list.Add(person);
person = new Person(){ Name="Wilson the cat" };
list.Add(per... | [
{
"answer_id": 478585,
"author": "Mitch Wheat",
"author_id": 16076,
"author_profile": "https://Stackoverflow.com/users/16076",
"pm_score": 2,
"selected": false,
"text": "<p>1) It goes on the heap (or large object heap if > 84K)</p>\n\n<p>2) Yes, a new instance is created. It can be refer... | 2009/01/26 | [
"https://Stackoverflow.com/questions/478573",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21574/"
] | I have the following code:
```
public class Test
{
public static void Main()
{
List<Person> list = new List<Person>();
Person person = new Person() { Name="Chris" };
list.Add(person);
person = new Person(){ Name="Wilson the cat" };
list.Add(person);
Console.Wri... | ```
List<Person> list = new List<Person>();
Person person = new Person() { Name="Chris" };
// your person object lives on the heap. The person variable is just
// a pointer of that object on the heap. Note that the pointer lives
// on the stack, and the object it points to lives on the heap.
l... |
478,594 | <p>i'm trying to port some Java stuff to C#. I'm just wondering if the following C# code is the equivalent to the original Java source.</p>
<h2>Source: Java Code</h2>
<pre><code>private static final Pattern SIMPLE_IDENTIFIER_NAME_PATTERN =
Pattern.compile("^[a-zA-Z_][a-zA-Z0-9_]*$");
private static boolean ... | [
{
"answer_id": 478596,
"author": "Aaron Maenpaa",
"author_id": 2603,
"author_profile": "https://Stackoverflow.com/users/2603",
"pm_score": 2,
"selected": true,
"text": "<p>Looks good, but why don't you start by porting your unit tests?</p>\n"
},
{
"answer_id": 478598,
"author... | 2009/01/26 | [
"https://Stackoverflow.com/questions/478594",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30674/"
] | i'm trying to port some Java stuff to C#. I'm just wondering if the following C# code is the equivalent to the original Java source.
Source: Java Code
-----------------
```
private static final Pattern SIMPLE_IDENTIFIER_NAME_PATTERN =
Pattern.compile("^[a-zA-Z_][a-zA-Z0-9_]*$");
private static boolean isVal... | Looks good, but why don't you start by porting your unit tests? |
478,616 | <p>I am completely perplexed with how my Queue is function. I am attempting (and failing) to write
a small multi-threaded application to collect and display data in C#.<br>
After reading through <a href="http://www.albahari.com/threading/" rel="nofollow noreferrer">Albahari's book</a> and using the Consumer/Producer ... | [
{
"answer_id": 478621,
"author": "Mitch Wheat",
"author_id": 16076,
"author_profile": "https://Stackoverflow.com/users/16076",
"pm_score": 3,
"selected": false,
"text": "<p>The problem is due to no synchronisation on the StreamWriter you are writing to. The order is not sequential.</p>\n... | 2009/01/26 | [
"https://Stackoverflow.com/questions/478616",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4612/"
] | I am completely perplexed with how my Queue is function. I am attempting (and failing) to write
a small multi-threaded application to collect and display data in C#.
After reading through [Albahari's book](http://www.albahari.com/threading/) and using the Consumer/Producer
pattern he describes I got most of it to ... | Is it because you are writing to the same array `UInt16[] intDist` over and over again? Shouldn't you be using separate arrays for each `sensorData` object? (Btw, is `sensorData.intData` suppose to be `sensorData.data` in your sample code?)
**CLARIFICATION:**
Only one `intDist` array is created in `calculateAndEnqueu... |
478,632 | <p>My javascript gets included multiple times with the script tag, like so:</p>
<pre><code><script src="code.js></script>
<script src="code.js></script>
<script src="code.js></script>
</code></pre>
<p>Right now I have this code inside <strong>code.js</strong> to make my code run on... | [
{
"answer_id": 478638,
"author": "geowa4",
"author_id": 50214,
"author_profile": "https://Stackoverflow.com/users/50214",
"pm_score": 2,
"selected": false,
"text": "<pre><code>var _ow = _ow || { Auth: ... };\n</code></pre>\n\n<p>if its already defined then it wont be defined again.</p>\n... | 2009/01/26 | [
"https://Stackoverflow.com/questions/478632",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50394/"
] | My javascript gets included multiple times with the script tag, like so:
```
<script src="code.js></script>
<script src="code.js></script>
<script src="code.js></script>
```
Right now I have this code inside **code.js** to make my code run only once without overwriting my namespaces:
```
if(typeof _ow == "undefined... | Are you familiar with Crockford's [Javascript Module Pattern](http://ajaxian.com/archives/a-javascript-module-pattern)?
A slight variation on how to prevent overwriting the namespace:
```
var _ow;
if(!_ow) _ow = {};
``` |
478,637 | <p>Is it appropriate to send TEARDOWN when user clicks on the stop-button in a video (RTSP )streaming session?
If not then why??</p>
| [
{
"answer_id": 494980,
"author": "shodanex",
"author_id": 11589,
"author_profile": "https://Stackoverflow.com/users/11589",
"pm_score": 1,
"selected": false,
"text": "<p>I think it is, there is no other \"guaranteed\" way to tell the server to stop.\nBoth Quicktime and VLC do it that way... | 2009/01/26 | [
"https://Stackoverflow.com/questions/478637",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/55412/"
] | Is it appropriate to send TEARDOWN when user clicks on the stop-button in a video (RTSP )streaming session?
If not then why?? | I think it is, there is no other "guaranteed" way to tell the server to stop.
Both Quicktime and VLC do it that way, I don't know for the other client.
As you can see from this page of [RFC 2326](http://www.ietf.org/rfc/rfc2326.txt), the PAUSE directive is recommended but not required. Plus it is for pausing, and not s... |
478,639 | <p>I have the following code:</p>
<pre><code><script type="text/javascript">
$(document).ready(function() {
$("#Save").click(function() {
$.post("url", {
"data": "data"
}, function(data) {
alert(data);
});
});
});
<... | [
{
"answer_id": 478640,
"author": "cletus",
"author_id": 18393,
"author_profile": "https://Stackoverflow.com/users/18393",
"pm_score": 5,
"selected": true,
"text": "<p>Use the <a href=\"http://docs.jquery.com/Ajax/jQuery.ajax\" rel=\"noreferrer\"><code>$.ajax()</code></a> method instead. ... | 2009/01/26 | [
"https://Stackoverflow.com/questions/478639",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17648/"
] | I have the following code:
```
<script type="text/javascript">
$(document).ready(function() {
$("#Save").click(function() {
$.post("url", {
"data": "data"
}, function(data) {
alert(data);
});
});
});
</script>
```
I'm tes... | Use the [`$.ajax()`](http://docs.jquery.com/Ajax/jQuery.ajax) method instead. It has a hook for errors.
[For example](http://www.ibm.com/developerworks/library/x-ajaxjquery.html):
```
$.ajax({
url: 'document.xml',
type: 'GET',
dataType: 'xml',
timeout: 1000,
error: function(){
alert('Error... |
478,655 | <p>The problem is a need to take the arguments into account before choosing the responder. Here is my attempt so far.</p>
<pre><code>from responders import A, B, C
class RandomResponder(object)
def init(self, *args, *kwargs):
self.args = args
self.kwargs = kwargs
def __getattr__(self, name):
... | [
{
"answer_id": 478673,
"author": "Nikhil",
"author_id": 853,
"author_profile": "https://Stackoverflow.com/users/853",
"pm_score": 0,
"selected": false,
"text": "<p>If you specify <code>args</code> (without the asterisk), it's just a List of values (strings). Similarly, <code>kwargs</cod... | 2009/01/26 | [
"https://Stackoverflow.com/questions/478655",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40149/"
] | The problem is a need to take the arguments into account before choosing the responder. Here is my attempt so far.
```
from responders import A, B, C
class RandomResponder(object)
def init(self, *args, *kwargs):
self.args = args
self.kwargs = kwargs
def __getattr__(self, name):
# pick... | Try this:
```
class RandomResponder(object):
choices = [A, B, C]
@classmethod
def which(cls):
return random.choice(cls.choices)
def __getattr__(self, attr):
return getattr(self.which(), attr)
```
which() randomly selects an option from the choices, and which **getattr** uses to get ... |
478,659 | <p>I'm looking for something equivalent to the code below but for any value type without having to encode a switch statement for each data type.
The code below does not compile because XmlConvert.ToString() does not have an overload that accepts and object.</p>
<pre><code> int intValue = 10;
object boxe... | [
{
"answer_id": 478661,
"author": "Spence",
"author_id": 53771,
"author_profile": "https://Stackoverflow.com/users/53771",
"pm_score": 0,
"selected": false,
"text": "<p>Just to throw this out there, are you attempting to convert a business object into XML?</p>\n\n<p>Perhaps you might want... | 2009/01/26 | [
"https://Stackoverflow.com/questions/478659",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6819/"
] | I'm looking for something equivalent to the code below but for any value type without having to encode a switch statement for each data type.
The code below does not compile because XmlConvert.ToString() does not have an overload that accepts and object.
```
int intValue = 10;
object boxedValue = (obje... | All value types are inherently serializable. So you just need to use an XMLSerializer.
Something like this would do it (based on your method):
```
public static string ToXmlString(Type type, object value)
{
StringBuilder sb = new StringBuilder();
System.Xml.XmlWriter writer = System.Xml.XmlWriter.Create(sb);
... |
478,660 | <p>if you create html layout like so</p>
<pre><code><ul>
<li class='a'></li>
<li class='b'></li>
<li class='a'></li>
<li class='b'></li>
<li class='a'></li>
<li class='b'></li>
<li class='a'></li&g... | [
{
"answer_id": 478669,
"author": "willoller",
"author_id": 33822,
"author_profile": "https://Stackoverflow.com/users/33822",
"pm_score": 0,
"selected": false,
"text": "<p>If you are trying to get the 1st and third, you just need $$('.a'). </p>\n\n<p>Are you trying to get the 1st and 5th ... | 2009/01/26 | [
"https://Stackoverflow.com/questions/478660",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20955/"
] | if you create html layout like so
```
<ul>
<li class='a'></li>
<li class='b'></li>
<li class='a'></li>
<li class='b'></li>
<li class='a'></li>
<li class='b'></li>
<li class='a'></li>
<li class='b'></li>
</ul>
```
and try to select odd elements with 'a' class like so $$('.a:odd... | The problem is that :odd and :even (and their CSS cousins :nth-child(odd) and :nth-child(even)) refer to the order in which the elements appear as children of their parent, not as children with that particular selector.
This worked for me (Prototype, but it looks like MooTools has similar syntax):
```
var odd = $$('.... |
478,665 | <p>I have a webview in my iPhone application, and I also have some html files inside my Resources folder. When my app loads, I load in a page from my resources into my webview. But , I need to make links inside my webview that point to some other resources (For example, images, or other html files). Just doing a relati... | [
{
"answer_id": 478683,
"author": "August",
"author_id": 30966,
"author_profile": "https://Stackoverflow.com/users/30966",
"pm_score": 5,
"selected": true,
"text": "<p>When you load those resources, you need to set the base URL. You can do this using the method:</p>\n\n<pre><code>- (void)... | 2009/01/26 | [
"https://Stackoverflow.com/questions/478665",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/764272/"
] | I have a webview in my iPhone application, and I also have some html files inside my Resources folder. When my app loads, I load in a page from my resources into my webview. But , I need to make links inside my webview that point to some other resources (For example, images, or other html files). Just doing a relative ... | When you load those resources, you need to set the base URL. You can do this using the method:
```
- (void)loadHTMLString:(NSString *)string baseURL:(NSURL *)baseURL
```
...where baseURL would be the file URL of your resources folder. |
478,668 | <p>I am working on a client-server application that uses boost::serialization library for it's serialization needs. </p>
<p>I need to serialize and deserialize polymorphic objects that does not seem to work. The documentation does say that it is supported but none of the related examples demonstrate what I'm trying t... | [
{
"answer_id": 479127,
"author": "Sameer",
"author_id": 45216,
"author_profile": "https://Stackoverflow.com/users/45216",
"pm_score": 4,
"selected": true,
"text": "<p>Found a resolution. I had to export the derived class with the statement:</p>\n\n<pre><code>BOOST_CLASS_EXPORT(derived);\... | 2009/01/26 | [
"https://Stackoverflow.com/questions/478668",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45216/"
] | I am working on a client-server application that uses boost::serialization library for it's serialization needs.
I need to serialize and deserialize polymorphic objects that does not seem to work. The documentation does say that it is supported but none of the related examples demonstrate what I'm trying to do here. ... | Found a resolution. I had to export the derived class with the statement:
```
BOOST_CLASS_EXPORT(derived);
```
Posting something that works with some corrections.
```
using namespace std;
class base {
public:
int data1;
friend class boost::serialization::access;
template<typename Archive>... |
478,671 | <p>I can't seem to find a relevant example out there.</p>
<p>I'm trying to return a sub-set of a table, and for each row in that table, I want to check how many children it has, and return that number as part of the result set.</p>
<p>Parent Table Columns:
PK_ID, Column1, Column2, FK1</p>
<p>For each FK1 in result s... | [
{
"answer_id": 478676,
"author": "cletus",
"author_id": 18393,
"author_profile": "https://Stackoverflow.com/users/18393",
"pm_score": 4,
"selected": false,
"text": "<p>Ok, apparently, based on the upvotes for the other answer, this needs further explanation. Example (done with MySQL bec... | 2009/01/26 | [
"https://Stackoverflow.com/questions/478671",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I can't seem to find a relevant example out there.
I'm trying to return a sub-set of a table, and for each row in that table, I want to check how many children it has, and return that number as part of the result set.
Parent Table Columns:
PK\_ID, Column1, Column2, FK1
For each FK1 in result set, select count(\*) fr... | Ok, apparently, based on the upvotes for the other answer, this needs further explanation. Example (done with MySQL because I have it handy but the principle is universal to any SQL dialect):
```
CREATE TABLE Blah (
ID INT PRIMARY KEY,
SomeText VARCHAR(30),
ParentID INT
)
INSERT INTO Blah VALUES (1, 'One', 0);
... |
478,684 | <p>Given the following interfaces:</p>
<pre><code>interface IFoo
{
void Foo();
}
interface IBar : IFoo
{
void Bar();
}
</code></pre>
<p>what is the best way to indicate that a given class implements <code>IBar</code>?</p>
<h3>Approach A:</h3>
<pre><code>class Implementation : IBar { ... }
</code></pre>
<p>This... | [
{
"answer_id": 478689,
"author": "Simon P",
"author_id": 31387,
"author_profile": "https://Stackoverflow.com/users/31387",
"pm_score": 1,
"selected": false,
"text": "<p>I'd go with A. You get to see which methods you need to implement in the class itself, and the navigation tools in the ... | 2009/01/26 | [
"https://Stackoverflow.com/questions/478684",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34211/"
] | Given the following interfaces:
```
interface IFoo
{
void Foo();
}
interface IBar : IFoo
{
void Bar();
}
```
what is the best way to indicate that a given class implements `IBar`?
### Approach A:
```
class Implementation : IBar { ... }
```
This seems simpler and cleaner but it does not indicate that `Im... | Personally I'd go with the former. With the latter, say you're in this situation where you have a bunch of derived classes:
```
class DerivedA : Implementation, IBar, IFoo { ... }
class DerivedB : Implementation, IBar, IFoo { ... }
class DerivedC : Implementation, IBar, IFoo { ... }
class DerivedD : Implementation, IB... |
478,721 | <p>I have a class which represents a shape. The Shape class has a property called Angle. I want the setter for this property to automatically wrap the value into the range [0,359].</p>
<p>Unfortunately, a simple <code>_Angle = value % 360;</code> only works for positive numbers. In C#, <code>-40 % 360 == -40</code>. G... | [
{
"answer_id": 478740,
"author": "ja.",
"author_id": 15467,
"author_profile": "https://Stackoverflow.com/users/15467",
"pm_score": 1,
"selected": false,
"text": "<p><code>\n// go 'round once</p>\n\n<p>set { _Angle = (value + 360) % 360 }\n</code></p>\n"
},
{
"answer_id": 478744,
... | 2009/01/26 | [
"https://Stackoverflow.com/questions/478721",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/369/"
] | I have a class which represents a shape. The Shape class has a property called Angle. I want the setter for this property to automatically wrap the value into the range [0,359].
Unfortunately, a simple `_Angle = value % 360;` only works for positive numbers. In C#, `-40 % 360 == -40`. Google calc does it [the way I wa... | Although this is for Java, Java also has the same behavior for modulus. (i.e. `-40 % 360 == -40`).
The below code should return an answer from [0. 360), regardless of the given angle, positive or negative.
```
public class Mod
{
public static int mod(int a, int b)
{
if (a < 0)
return b + (... |
478,724 | <p>I've never really had the need to use any drag functions until now, so let me fill you in on what I've discovered so far:</p>
<ul>
<li>Drag events are events that take place when the user is dragging an object. This is "proper" OS dragging, eg: hiliting some text and dragging it, or even dragging in something fro... | [
{
"answer_id": 479002,
"author": "sam",
"author_id": 58249,
"author_profile": "https://Stackoverflow.com/users/58249",
"pm_score": 4,
"selected": true,
"text": "<p>I've found a way to handle onDragLeave via event delegation.</p>\n\n<p>Simply add an event to monitor \"dragover\" on the en... | 2009/01/26 | [
"https://Stackoverflow.com/questions/478724",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/58249/"
] | I've never really had the need to use any drag functions until now, so let me fill you in on what I've discovered so far:
* Drag events are events that take place when the user is dragging an object. This is "proper" OS dragging, eg: hiliting some text and dragging it, or even dragging in something from outside of the... | I've found a way to handle onDragLeave via event delegation.
Simply add an event to monitor "dragover" on the entire document. When the event source becomes your element in question, set a flag, and once the event source is no longer that element, fire the "dragleave" event.
Note:
* Will need to be modified so that ... |
478,764 | <p>My code that can get tablename in linq query is:</p>
<pre><code> Dim TY As Type = (From T In DB.Mapping.GetTables()
Where T.TableName = tableN
Select T.RowType.Type).SingleOrDefault
Dim Table As ITable = DB.GetTable(TY)
Dim mq = From t In Table Select t
</... | [
{
"answer_id": 478823,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 1,
"selected": false,
"text": "<p>Try using extension methods instead:</p>\n\n<pre><code>Dim mq = Table.Select( Function(t) t.Code );\n</code></pre>\n... | 2009/01/26 | [
"https://Stackoverflow.com/questions/478764",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | My code that can get tablename in linq query is:
```
Dim TY As Type = (From T In DB.Mapping.GetTables()
Where T.TableName = tableN
Select T.RowType.Type).SingleOrDefault
Dim Table As ITable = DB.GetTable(TY)
Dim mq = From t In Table Select t
```
tableN get... | Try using extension methods instead:
```
Dim mq = Table.Select( Function(t) t.Code );
``` |
478,798 | <p>I have been using dean edwards <a href="http://code.google.com/p/ie7-js/" rel="nofollow noreferrer">ie7/8 script</a>. Not sure if it's my implementation or not but sometimes I would experience ie6 issues that weren't quite fixed or <a href="http://code.google.com/p/ie7-js/issues/detail?id=114" rel="nofollow noreferr... | [
{
"answer_id": 478816,
"author": "Joe Soul-bringer",
"author_id": 56279,
"author_profile": "https://Stackoverflow.com/users/56279",
"pm_score": 0,
"selected": false,
"text": "<p>I don't think there is ever a standard as to what browser you can or can't ignore. It depends on the organizat... | 2009/01/26 | [
"https://Stackoverflow.com/questions/478798",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43465/"
] | I have been using dean edwards [ie7/8 script](http://code.google.com/p/ie7-js/). Not sure if it's my implementation or not but sometimes I would experience ie6 issues that weren't quite fixed or [required special handling](http://code.google.com/p/ie7-js/issues/detail?id=114) which meant I would be back where I started... | **Update**: I expanded my answer here with a tutorial on my site, which will probably be more helpful than my answer here. [Ultimate IE6 Cheatsheet: How To Fix 25+ Internet Explorer 6 Bugs](http://www.virtuosimedia.com/tutorials/ultimate-ie6-cheatsheet-how-to-fix-25-internet-explorer-6-bugs)
Here's how I tackle IE6:
... |
478,806 | <p>I am reading a text file with this format:</p>
<blockquote>
<p>grrr,some text,45.4321,54.22134</p>
</blockquote>
<p>I just have my double valued stored in a string variable.</p>
<p>Why is it only giving me the first digit of the string?</p>
<p>If I start over with just one while loop and a text file of this ne... | [
{
"answer_id": 478851,
"author": "1800 INFORMATION",
"author_id": 3146,
"author_profile": "https://Stackoverflow.com/users/3146",
"pm_score": 2,
"selected": false,
"text": "<p>Your code is a little tough to read. You probably want to think some point about encapsulation and breaking it u... | 2009/01/26 | [
"https://Stackoverflow.com/questions/478806",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40120/"
] | I am reading a text file with this format:
>
> grrr,some text,45.4321,54.22134
>
>
>
I just have my double valued stored in a string variable.
Why is it only giving me the first digit of the string?
If I start over with just one while loop and a text file of this new format:
>
> 21.34564
>
>
>
it works as... | Using ***instream>>dvalue*** is certainly the **right** way to do things. But sometimes what's right isn't always easiest or necessarily best.
We could do something like this:
```
int
main()
{
string s = "grrr,some text,45.4321,54.22134";
double a,b;
ASSERT_IS( 2, sscanf( s.c_str(), "%*[^,],%*[^,],%lf,%lf", & ... |
478,815 | <p>I have an associative array (object) of the following construction</p>
<pre><code>var menu = new Object('Submenu A','Submenu B','Submenu C','Submenu D');
menu['Submenu A']=new Object();
menu['Submenu A']['Option A']= 'foo blah text';
menu['Submenu A']['Option B']= 'blah more text';
menu['Submenu B']['Option A']= 'b... | [
{
"answer_id": 478834,
"author": "Abie",
"author_id": 53166,
"author_profile": "https://Stackoverflow.com/users/53166",
"pm_score": 1,
"selected": false,
"text": "<p>You want Prototype's <a href=\"http://www.prototypejs.org/api/hash\" rel=\"nofollow noreferrer\">Hash</a>.</p>\n"
},
{... | 2009/01/26 | [
"https://Stackoverflow.com/questions/478815",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/58917/"
] | I have an associative array (object) of the following construction
```
var menu = new Object('Submenu A','Submenu B','Submenu C','Submenu D');
menu['Submenu A']=new Object();
menu['Submenu A']['Option A']= 'foo blah text';
menu['Submenu A']['Option B']= 'blah more text';
menu['Submenu B']['Option A']= 'blah blah';
men... | To create a new object with no properties, use:
```
var menu = new Object();
```
The Object constructor actually takes one optional argument. Now let's look at what you have:
```
var menu = new Object('Submenu A','Submenu B','Submenu C','Submenu D');
```
Only the first argument (`'Submenu A'`) is being used while... |
478,826 | <p>I'm trying to write a static member function in C# or find one in the .NET Framework that will re-case a file path to what the filesystem specifies.</p>
<p>Example:</p>
<pre><code>string filepath = @"C:\temp.txt";
filepath = FileUtility.RecaseFilepath(filepath);
// filepath = C:\Temp.TXT
// Where the real fully q... | [
{
"answer_id": 478871,
"author": "Jay Riggs",
"author_id": 52249,
"author_profile": "https://Stackoverflow.com/users/52249",
"pm_score": 1,
"selected": false,
"text": "<p>You can search for the file you want to get the case on and return the results of your search (you want to check the ... | 2009/01/26 | [
"https://Stackoverflow.com/questions/478826",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42005/"
] | I'm trying to write a static member function in C# or find one in the .NET Framework that will re-case a file path to what the filesystem specifies.
Example:
```
string filepath = @"C:\temp.txt";
filepath = FileUtility.RecaseFilepath(filepath);
// filepath = C:\Temp.TXT
// Where the real fully qualified filepath in ... | This is a pretty simple implementation that assumes that the file and directories all exist and are accessible:
```
static string GetProperDirectoryCapitalization(DirectoryInfo dirInfo)
{
DirectoryInfo parentDirInfo = dirInfo.Parent;
if (null == parentDirInfo)
return dirInfo.Name;
return Path.Combi... |
478,827 | <p>I can't get my update to work. The test fails and I do not see any update statements being sent to the database. Can someone tell me what I'm doing wrong?</p>
<p>This is my repository update procedure:</p>
<pre><code>public void UpdateProject(Project proj)
{
Session.Update(proj);
}
</code></pre>
<p>This is th... | [
{
"answer_id": 479421,
"author": "MrTelly",
"author_id": 56092,
"author_profile": "https://Stackoverflow.com/users/56092",
"pm_score": 4,
"selected": false,
"text": "<p>There are a couple of things that may be happening.</p>\n\n<p>1) The update is failing and NHibernate is raising an exc... | 2009/01/26 | [
"https://Stackoverflow.com/questions/478827",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I can't get my update to work. The test fails and I do not see any update statements being sent to the database. Can someone tell me what I'm doing wrong?
This is my repository update procedure:
```
public void UpdateProject(Project proj)
{
Session.Update(proj);
}
```
This is the unit test I am trying:
```
[Te... | There are a couple of things that may be happening.
1) The update is failing and NHibernate is raising an exception that is being swallowed somewhere - that can happen depending on how you've configured things. So in VS make sure all exceptions will cause a break.
2) The update is being cached and not written directl... |
478,832 | <p>In <a href="https://stackoverflow.com/questions/478616/why-in-c-is-queue-scrambling-the-data-in-its-elements">this question</a>, I asked about using queue's and threads in C#. I found that locking around the code that writes data to file resolved my issue. One of the <a href="https://stackoverflow.com/users/20029/... | [
{
"answer_id": 478866,
"author": "Spence",
"author_id": 53771,
"author_profile": "https://Stackoverflow.com/users/53771",
"pm_score": 2,
"selected": true,
"text": "<p>b[1] no longer exists, and will be garbage collected.</p>\n\n<p>You create array a.</p>\n\n<p>You create array b.</p>\n\n... | 2009/01/26 | [
"https://Stackoverflow.com/questions/478832",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4612/"
] | In [this question](https://stackoverflow.com/questions/478616/why-in-c-is-queue-scrambling-the-data-in-its-elements), I asked about using queue's and threads in C#. I found that locking around the code that writes data to file resolved my issue. One of the [ansewerers](https://stackoverflow.com/users/20029/zach-scriven... | b[1] no longer exists, and will be garbage collected.
You create array a.
You create array b.
when you say b=a you throw away the reference to array b.
b[1] and a[1] are now pointing at the same array. |
478,835 | <p>I am trying to use GetThemeFont to read the font data from a visual style, but I can't seem to get it to return anything. Here is how I'm using it:</p>
<pre><code>IntPtr h = OpenThemeData(this.Handle, "Button");
LOGFONT font = new LOGFONT();
int r = GetThemeFont(h, IntPtr.Zero, 1, 1, 210, out font);
CloseThemeData(... | [
{
"answer_id": 478866,
"author": "Spence",
"author_id": 53771,
"author_profile": "https://Stackoverflow.com/users/53771",
"pm_score": 2,
"selected": true,
"text": "<p>b[1] no longer exists, and will be garbage collected.</p>\n\n<p>You create array a.</p>\n\n<p>You create array b.</p>\n\n... | 2009/01/26 | [
"https://Stackoverflow.com/questions/478835",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/343/"
] | I am trying to use GetThemeFont to read the font data from a visual style, but I can't seem to get it to return anything. Here is how I'm using it:
```
IntPtr h = OpenThemeData(this.Handle, "Button");
LOGFONT font = new LOGFONT();
int r = GetThemeFont(h, IntPtr.Zero, 1, 1, 210, out font);
CloseThemeData(h);
```
The ... | b[1] no longer exists, and will be garbage collected.
You create array a.
You create array b.
when you say b=a you throw away the reference to array b.
b[1] and a[1] are now pointing at the same array. |
478,844 | <p>It's got to be somewhere in the phpinfo() dump, but I just don't know where. Is it supposed to be under the "Additional Modules" section? Somewhere else? I'm trying to figure out why some extensions don't appear to be loaded, but I don't even know where I should be looking.</p>
| [
{
"answer_id": 478922,
"author": "Abdullah Jibaly",
"author_id": 47110,
"author_profile": "https://Stackoverflow.com/users/47110",
"pm_score": 8,
"selected": false,
"text": "<p>Running <pre>php -m</pre> will give you all the modules, and <pre>php -i</pre> will give you a lot more detaile... | 2009/01/26 | [
"https://Stackoverflow.com/questions/478844",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2484/"
] | It's got to be somewhere in the phpinfo() dump, but I just don't know where. Is it supposed to be under the "Additional Modules" section? Somewhere else? I'm trying to figure out why some extensions don't appear to be loaded, but I don't even know where I should be looking. | Running
```
php -m
```
will give you all the modules, and
```
php -i
```
will give you a lot more detailed information on what the current configuration. |
478,857 | <p>I need to implement something similar to <a href="http://en.wikipedia.org/wiki/Help:Link#Wikilinks" rel="nofollow noreferrer">wikilinks</a> on my site. The user is entering plain text and will enter [[asdf]] wherever there is an internal link. Only the first five examples are really applicable in the implementation ... | [
{
"answer_id": 478963,
"author": "David Z",
"author_id": 56541,
"author_profile": "https://Stackoverflow.com/users/56541",
"pm_score": 1,
"selected": false,
"text": "<p>I don't know if there are existing libraries to do this, but if it were me I'd probably just use regexes:</p>\n\n<ul>\n... | 2009/01/26 | [
"https://Stackoverflow.com/questions/478857",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40161/"
] | I need to implement something similar to [wikilinks](http://en.wikipedia.org/wiki/Help:Link#Wikilinks) on my site. The user is entering plain text and will enter [[asdf]] wherever there is an internal link. Only the first five examples are really applicable in the implementation I need.
Would you use regex, what expre... | On the pure regexp side, the expression would rather be:
```
\[\[([^\]\|\r\n]+?)\|([^\]\|\r\n]+?)\]\]([^\] ]\S*)
\[\[([^\]\|\r\n]+?)\]\]([^\] ]\S*)
```
By replacing the `(.+?)` [suggested by David](https://stackoverflow.com/questions/478857#478963) with `([^\]\|\r\n]+?)`, you ensure to only capture legitimate wiki l... |
478,860 | <p>I have a collection of legacy C code which I'm refactoring to split the C computational code from the GUI. This is complicated by the heavily recursive mathematical core code being K&R style declarations. I've already abandoned an attempt to convert these to ANSI declarations due to nested use of function parame... | [
{
"answer_id": 1285121,
"author": "Ira Baxter",
"author_id": 120163,
"author_profile": "https://Stackoverflow.com/users/120163",
"pm_score": 0,
"selected": false,
"text": "<p>You could use Scientific Toolworks to see your system-wide call graph.</p>\n\n<p>If you want to automate the anal... | 2009/01/26 | [
"https://Stackoverflow.com/questions/478860",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53870/"
] | I have a collection of legacy C code which I'm refactoring to split the C computational code from the GUI. This is complicated by the heavily recursive mathematical core code being K&R style declarations. I've already abandoned an attempt to convert these to ANSI declarations due to nested use of function parameters (j... | In your Doxyfile, set
```
GENERATE_XML = YES
```
and then you can find your call graph in the XML files. For each function marked with the callergraph, you'll find `<referencedby>` elements in the output that you can use. Here's a sample from one of my C files:
```
<memberdef kind="function" id="spfs_8c_1a3"
... |
478,898 | <p>I am looking for a way to get the output of a command when it is run from within a C++ program. I have looked at using the <code>system()</code> function, but that will just execute a command. Here's an example of what I'm looking for:</p>
<pre><code>std::string result = system("./some_command");
</code></pre>
<p... | [
{
"answer_id": 478949,
"author": "paxdiablo",
"author_id": 14860,
"author_profile": "https://Stackoverflow.com/users/14860",
"pm_score": 4,
"selected": false,
"text": "<p>Two possible approaches:</p>\n\n<ol>\n<li><p>I don't think <code>popen()</code> is part of the C++ standard (it's par... | 2009/01/26 | [
"https://Stackoverflow.com/questions/478898",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3467/"
] | I am looking for a way to get the output of a command when it is run from within a C++ program. I have looked at using the `system()` function, but that will just execute a command. Here's an example of what I'm looking for:
```
std::string result = system("./some_command");
```
I need to run an arbitrary command an... | ```
#include <cstdio>
#include <iostream>
#include <memory>
#include <stdexcept>
#include <string>
#include <array>
std::string exec(const char* cmd) {
std::array<char, 128> buffer;
std::string result;
std::unique_ptr<FILE, decltype(&pclose)> pipe(popen(cmd, "r"), pclose);
if (!pipe) {
throw st... |
478,910 | <p>In .NET 3.5 winforms, I've created an MVC. I'd like to take the controller part and put it into a separate assembly, so that it has no knowledge of the view. My app uses five forms in its view. The controller takes care of initializing the forms at different times, which means the controller has a reference to th... | [
{
"answer_id": 478920,
"author": "Vinay",
"author_id": 28641,
"author_profile": "https://Stackoverflow.com/users/28641",
"pm_score": 0,
"selected": false,
"text": "<p>You can use Subject-Observer pattern between view and model to decouple the interaction between view and model.\nFurther ... | 2009/01/26 | [
"https://Stackoverflow.com/questions/478910",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40106/"
] | In .NET 3.5 winforms, I've created an MVC. I'd like to take the controller part and put it into a separate assembly, so that it has no knowledge of the view. My app uses five forms in its view. The controller takes care of initializing the forms at different times, which means the controller has a reference to the view... | I use an IOC Container to resolve the view and inject the controller instance via the form constructor, like so.
```
public class MainWindowController : WindowController<IMainWindowView>
{
}
public class WindowController<TView> where TView : IView
{
public WindowController( IViewFactory factory ) {}
public v... |
478,918 | <p>I'm stuck on a portion of the Java tutorial, specifically <a href="http://java.sun.com/docs/books/tutorial/java/javaOO/QandE/creating-questions.html" rel="nofollow noreferrer">this exercise</a>. The exercise asks you to:</p>
<blockquote>
<p>1- Write a class whose instances
represent a single playing card from a... | [
{
"answer_id": 478942,
"author": "Cory Foy",
"author_id": 4083,
"author_profile": "https://Stackoverflow.com/users/4083",
"pm_score": 1,
"selected": false,
"text": "<p>The exercise is simple enough if you know some basics:</p>\n\n<ul>\n<li>A deck of cards has 52 cards (54 if counting Jok... | 2009/01/26 | [
"https://Stackoverflow.com/questions/478918",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49153/"
] | I'm stuck on a portion of the Java tutorial, specifically [this exercise](http://java.sun.com/docs/books/tutorial/java/javaOO/QandE/creating-questions.html). The exercise asks you to:
>
> 1- Write a class whose instances
> represent a single playing card from a
> deck of cards. Playing cards have two
> distinguish... | I think it's worth the time to be familiar with the example, since it's frequently used to describe programming concepts. Let me try to distill the description of playing cards for you:
First, keep [this picture](http://en.wikipedia.org/wiki/File:Set_of_playing_cards_52.JPG) of the **deck** (the whole collection of ca... |
478,927 | <p><strong>Has anyone written any <a href="http://blog.wekeroad.com/blog/aspnet-mvc-preview-using-the-mvc-ui-helpers/" rel="nofollow noreferrer">HTMLHelper classes</a> for MVC that help with <a href="http://developer.yahoo.com/yui/" rel="nofollow noreferrer">Yahoo's User Interface Library</a>?</strong></p>
<p>For inst... | [
{
"answer_id": 478977,
"author": "Eric Miraglia",
"author_id": 41261,
"author_profile": "https://Stackoverflow.com/users/41261",
"pm_score": 2,
"selected": false,
"text": "<p>Simon,</p>\n\n<p>I'm not sure this is helpful with respect to the MVC question, but there is a good open-source p... | 2009/01/26 | [
"https://Stackoverflow.com/questions/478927",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16940/"
] | **Has anyone written any [HTMLHelper classes](http://blog.wekeroad.com/blog/aspnet-mvc-preview-using-the-mvc-ui-helpers/) for MVC that help with [Yahoo's User Interface Library](http://developer.yahoo.com/yui/)?**
For instance I have written a helper method to convert a 'menu model' into the HTML markup needed to supp... | Simon,
I'm not sure this is helpful with respect to the MVC question, but there is a good open-source project that aims to simplify working with YUI within .NET:
<http://www.yuiasp.net/>
Menu is one of the controls that they include.
At the very least, this may be a project you can contribute back to if your work a... |
478,931 | <p>I have a grouped table view with textfields in the tableview. For the keyboard to not hide the textfields, in the textFieldShouldBeginEditing, I am calling the scrollToRowAtIndexPath method and setting the scroll position of the row being edited to the top of the tableview.</p>
<p>The scrolling does happen, but as ... | [
{
"answer_id": 494028,
"author": "Louis Gerbarg",
"author_id": 30506,
"author_profile": "https://Stackoverflow.com/users/30506",
"pm_score": 4,
"selected": true,
"text": "<p>I suspect what is going on is that the table view is rubber banding back, just like a webview in Safari does when ... | 2009/01/26 | [
"https://Stackoverflow.com/questions/478931",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46297/"
] | I have a grouped table view with textfields in the tableview. For the keyboard to not hide the textfields, in the textFieldShouldBeginEditing, I am calling the scrollToRowAtIndexPath method and setting the scroll position of the row being edited to the top of the tableview.
The scrolling does happen, but as soon as th... | I suspect what is going on is that the table view is rubber banding back, just like a webview in Safari does when you run pass its bounds. The most likely reason for this is that when you pop up the keyboard it is on top of the table view, but the table view has not physically contracted, thus all the UITableViewCells ... |
478,952 | <p><strong>I wish to write a windows app which does something when I become disconnected from the internet</strong>. I was thinking of writing a very simple C#/Delphi app which simply polls every 20 seconds to see if I'm still connected.</p>
<p>If I have to poll I'd really like a solution other than trying to download... | [
{
"answer_id": 478961,
"author": "John Boker",
"author_id": 2847,
"author_profile": "https://Stackoverflow.com/users/2847",
"pm_score": 2,
"selected": false,
"text": "<p>It looks like it can be done by using the method described here: <a href=\"http://www.csharphelp.com/archives3/archive... | 2009/01/26 | [
"https://Stackoverflow.com/questions/478952",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26335/"
] | **I wish to write a windows app which does something when I become disconnected from the internet**. I was thinking of writing a very simple C#/Delphi app which simply polls every 20 seconds to see if I'm still connected.
If I have to poll I'd really like a solution other than trying to download a web page from the ne... | Beware that connected to the Internet does not really mean anything: what if you are connected to your ISP, but the backbone is down, or all the sites you want to access are in a country that went off the grid like recently? Having a connection does not mean you can do what you want.
Anyway, as stated before you can... |
478,953 | <p>I'm using NHibernate and Fluent NHibernate to create a mapping file for a domain object (though I don't care if an answer uses fluent NHibernate or xml hbm syntax). And I'm having trouble with figuring out how I specify that a set of columns representing a component within the domain object is unique.</p>
<p>Here'... | [
{
"answer_id": 480172,
"author": "Mark Rogers",
"author_id": 25847,
"author_profile": "https://Stackoverflow.com/users/25847",
"pm_score": 0,
"selected": false,
"text": "<p>I believe the answer is something like this:</p>\n\n<pre><code><class name=\"SpaceLocation\" table=\"SpaceLocati... | 2009/01/26 | [
"https://Stackoverflow.com/questions/478953",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25847/"
] | I'm using NHibernate and Fluent NHibernate to create a mapping file for a domain object (though I don't care if an answer uses fluent NHibernate or xml hbm syntax). And I'm having trouble with figuring out how I specify that a set of columns representing a component within the domain object is unique.
Here's the domai... | m4bwav was correct with the hbm mapping; however, Fluent NHibernate didn't have support for this at the time you wrote your question. I've just committed a fix that adds a `Unique` method to the component mapping.
```
Component<SpaceCoordinate>(x => x.Coordinates, m =>
{
m.Map(x => x.x);
m.Map(x => x.y);
m.Map(... |
478,967 | <p>I have a class that contains an array. I want this array to be set at the length of a constant:</p>
<pre><code>// Entities.h
class Entities
{
private:
const int maxLimit;
int objects[maxLimit];
int currentUsage;
public:
Entities();
... | [
{
"answer_id": 478982,
"author": "John Boker",
"author_id": 2847,
"author_profile": "https://Stackoverflow.com/users/2847",
"pm_score": 1,
"selected": false,
"text": "<p>to dynamically allocate the memory you may need to use the 'new' keyword like</p>\n\n<p>objects would be defined like:... | 2009/01/26 | [
"https://Stackoverflow.com/questions/478967",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/58934/"
] | I have a class that contains an array. I want this array to be set at the length of a constant:
```
// Entities.h
class Entities
{
private:
const int maxLimit;
int objects[maxLimit];
int currentUsage;
public:
Entities();
bool addObje... | The array must have a constant length. I mean a length that is the same for all objects of that class. That is because the compiler has to know the size of each object, and it must be the same for all objects of that particular class. So, the following would do it:
```
class Entities
{
private:
static ... |
478,968 | <p>What's the fastest and easiest to read implementation of calculating the sum of digits?</p>
<p>I.e. Given the number: 17463 = 1 + 7 + 4 + 6 + 3 = 21</p>
| [
{
"answer_id": 478974,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 8,
"selected": true,
"text": "<p>You could do it arithmetically, without using a string:</p>\n\n<pre><code>sum = 0;\nwhile (n != 0) {\n sum += n % 10... | 2009/01/26 | [
"https://Stackoverflow.com/questions/478968",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42475/"
] | What's the fastest and easiest to read implementation of calculating the sum of digits?
I.e. Given the number: 17463 = 1 + 7 + 4 + 6 + 3 = 21 | You could do it arithmetically, without using a string:
```
sum = 0;
while (n != 0) {
sum += n % 10;
n /= 10;
}
``` |
478,985 | <p>The files residing in .settings in a <strong>Dynamic Web Project</strong> are:</p>
<pre><code>.settings/
|-- org.eclipse.jdt.core.prefs
|-- org.eclipse.jst.common.project.facet.core.prefs
|-- org.eclipse.jst.j2ee.ejb.annotations.xdoclet.prefs
|-- org.eclipse.wst.common.component
|-- org.eclipse.wst.common.project.f... | [
{
"answer_id": 479055,
"author": "Markus Lausberg",
"author_id": 39062,
"author_profile": "https://Stackoverflow.com/users/39062",
"pm_score": 0,
"selected": false,
"text": "<p>You should use and trust the \"Dependencies\" tab in the MANIFEST.MF. After working about a year with Eclipse p... | 2009/01/26 | [
"https://Stackoverflow.com/questions/478985",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | The files residing in .settings in a **Dynamic Web Project** are:
```
.settings/
|-- org.eclipse.jdt.core.prefs
|-- org.eclipse.jst.common.project.facet.core.prefs
|-- org.eclipse.jst.j2ee.ejb.annotations.xdoclet.prefs
|-- org.eclipse.wst.common.component
|-- org.eclipse.wst.common.project.facet.core.xml
|-- org.eclip... | Let's see:
* `org.eclipse.jdt.core.prefs` is really important and control how you compile your java project.
* `org.eclipse.jst.common.project.facet.core.prefs` adds a **[Facet](http://org.eclipse.wst.common.project.facet.core.xml)**, basically a way to introduce functionality to projects in Eclipse, therefore a proje... |
479,005 | <p>How do i dynamically assign a name to a php object?</p>
<p>for example how would i assign a object to a var that is the id of the db row that i am using to create objects.</p>
<p>for example </p>
<pre><code>$<idnum>= new object();
</code></pre>
<p>where idnum is the id from my database.</p>
| [
{
"answer_id": 479010,
"author": "John Boker",
"author_id": 2847,
"author_profile": "https://Stackoverflow.com/users/2847",
"pm_score": 4,
"selected": true,
"text": "<p>this little snippet works for me</p>\n\n<pre><code>$num=500;\n${\"id$num\"} = 1234;\necho $id500;\n</code></pre>\n\n<p>... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479005",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How do i dynamically assign a name to a php object?
for example how would i assign a object to a var that is the id of the db row that i am using to create objects.
for example
```
$<idnum>= new object();
```
where idnum is the id from my database. | this little snippet works for me
```
$num=500;
${"id$num"} = 1234;
echo $id500;
```
basically just use the curly brackets to surround your variable name and prepend a $; |
479,033 | <p>My BindingSource is bound to a collection of objects (not using ADO.NET) and I would like to filter it and exclude some values but not sure if I'm using this exactly since the result set I am expecting is not coming back. I was thinking something like this, but its not working:</p>
<pre><code>MyBindingSource.Filte... | [
{
"answer_id": 479045,
"author": "Martin Moser",
"author_id": 58275,
"author_profile": "https://Stackoverflow.com/users/58275",
"pm_score": 0,
"selected": false,
"text": "<p>I never tried it outside of the WPF world, but you could take a look at the ListCollectionView (for IList)/Binding... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479033",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/58943/"
] | My BindingSource is bound to a collection of objects (not using ADO.NET) and I would like to filter it and exclude some values but not sure if I'm using this exactly since the result set I am expecting is not coming back. I was thinking something like this, but its not working:
```
MyBindingSource.Filter = "State = 'N... | You've used AND.
If you want your filter to work you want this:
```
MyBindingSource.Filter = "State = 'NY' OR State = 'MA' OR State = 'CO'";
```
There is no way that something in boolean can be in two states at the same time. (At least in logic realms I work in anyway...) |
479,043 | <p>This is good:</p>
<pre class="lang-py prettyprint-override"><code>import string
string.capwords("proper name")
Out: 'Proper Name'
</code></pre>
<p>This is not so good:</p>
<pre class="lang-py prettyprint-override"><code>string.capwords("I.R.S")
Out: 'I.r.s'
</code></pre>
<p>Is there no string m... | [
{
"answer_id": 479044,
"author": "Martin v. Löwis",
"author_id": 33006,
"author_profile": "https://Stackoverflow.com/users/33006",
"pm_score": 2,
"selected": false,
"text": "<p>No, there is no such method in the standard library.</p>\n"
},
{
"answer_id": 479047,
"author": "Gr... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479043",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9106/"
] | This is good:
```py
import string
string.capwords("proper name")
Out: 'Proper Name'
```
This is not so good:
```py
string.capwords("I.R.S")
Out: 'I.r.s'
```
Is there no string method to do capwords so that it accomodates acronyms? | This might work:
```
import re
def _callback(match):
""" This is a simple callback function for the regular expression which is
in charge of doing the actual capitalization. It is designed to only
capitalize words which aren't fully uppercased (like acronyms).
"""
word = match.group(0)
... |
479,049 | <p>The following GUI code is working in 99.99% of OS environments used by our customers:</p>
<pre><code>jStatusDescription = new JTextArea();
jStatusDescription.setFont(new Font("Verdana", Font.PLAIN, 12));
jStatusDescription.setText("test"); <-- crashes
</code></pre>
<p>However, there are now 2 different cus... | [
{
"answer_id": 479909,
"author": "Tom Hawtin - tackline",
"author_id": 4725,
"author_profile": "https://Stackoverflow.com/users/4725",
"pm_score": 3,
"selected": true,
"text": "<p>There has been a problem reading physical fonts reported for all current releases of Java SE 6 when running ... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479049",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20979/"
] | The following GUI code is working in 99.99% of OS environments used by our customers:
```
jStatusDescription = new JTextArea();
jStatusDescription.setFont(new Font("Verdana", Font.PLAIN, 12));
jStatusDescription.setText("test"); <-- crashes
```
However, there are now 2 different customers both using Terminal se... | There has been a problem reading physical fonts reported for all current releases of Java SE 6 when running on certain configurations of thin clients. I've not tried, but I guess you can copy the font files into the fonts directory of the JRE (assuming these are checked before the system/Windows directory). You might b... |
479,057 | <p>I was using <code>Application.AddMessageFilter()</code> in my <code>WinForms</code> applications (when working with unmanaged code). </p>
<p>Now I'm switching to <code>WPF</code> and can't find this functionality.</p>
<p>Please advice where it can be found or implemented.</p>
| [
{
"answer_id": 39012598,
"author": "LordWilmore",
"author_id": 1983197,
"author_profile": "https://Stackoverflow.com/users/1983197",
"pm_score": 1,
"selected": false,
"text": "<p>If you want to monitor a window message, you can use HwndSource.AddHook method. The following example shows h... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479057",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/430254/"
] | I was using `Application.AddMessageFilter()` in my `WinForms` applications (when working with unmanaged code).
Now I'm switching to `WPF` and can't find this functionality.
Please advice where it can be found or implemented. | In WPF, you can use `ComponentDispatcher.ThreadFilterMessage` event.
```
ComponentDispatcher.ThreadFilterMessage += ComponentDispatcher_ThreadFilterMessage;
private void ComponentDispatcher_ThreadFilterMessage(ref MSG msg, ref bool handled)
{
if (msg.message == 513)//MOUSE_LEFTBUTTON_DOWN
{
//todo
... |
479,058 | <p>I'm trying to write some Javascript that shows data based on an HTTP GET request to a server on a different domain. From what I've read, this is made tricky due to the SOP (Same Origin Policy).</p>
<p>I'm curious how snap.com "Snap Shots" (webpage previews) work. Here is an example page: <a href="http://premshree... | [
{
"answer_id": 39012598,
"author": "LordWilmore",
"author_id": 1983197,
"author_profile": "https://Stackoverflow.com/users/1983197",
"pm_score": 1,
"selected": false,
"text": "<p>If you want to monitor a window message, you can use HwndSource.AddHook method. The following example shows h... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479058",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3439/"
] | I'm trying to write some Javascript that shows data based on an HTTP GET request to a server on a different domain. From what I've read, this is made tricky due to the SOP (Same Origin Policy).
I'm curious how snap.com "Snap Shots" (webpage previews) work. Here is an example page: <http://premshree.livejournal.com/661... | In WPF, you can use `ComponentDispatcher.ThreadFilterMessage` event.
```
ComponentDispatcher.ThreadFilterMessage += ComponentDispatcher_ThreadFilterMessage;
private void ComponentDispatcher_ThreadFilterMessage(ref MSG msg, ref bool handled)
{
if (msg.message == 513)//MOUSE_LEFTBUTTON_DOWN
{
//todo
... |
479,080 | <p>Is it me or are there no standard trim functions in the c or c++ library? is there any single function that acts as a trim? If not can anyone tell me Why trim is not part of the standard library? (i know trim is in boost)</p>
<p>My trim code is</p>
<pre><code>std::string trim(const std::string &str)
{
size... | [
{
"answer_id": 479091,
"author": "BobbyShaftoe",
"author_id": 38426,
"author_profile": "https://Stackoverflow.com/users/38426",
"pm_score": 5,
"selected": false,
"text": "<p>No, you have to write it yourself or use some other library like Boost and so forth.</p>\n\n<p>In C++, you could d... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479080",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Is it me or are there no standard trim functions in the c or c++ library? is there any single function that acts as a trim? If not can anyone tell me Why trim is not part of the standard library? (i know trim is in boost)
My trim code is
```
std::string trim(const std::string &str)
{
size_t s = str.find_first_not... | The reason trim() isn't in the standard library is that when the last standard was made, they had to strike a balance between formalizing current behavior (adding nothing new, just stabilizing what already existed), and adding new functionality. In general, they preferred not to add a feature unless it either 1) would ... |
479,099 | <p>i have to make a user input num/percentage pairs. the code looks like:</p>
<pre><code>while(choice != 0)
{
printf("enter number");
fgets(line, sizeof(line), stdin);//sizeof(line) is 6
sscanf(line, "%d\n", choice);
if(choice > 0)
{
printf("enter percentage\n");
fgets(percent_line, sizeof(percent... | [
{
"answer_id": 479133,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 2,
"selected": false,
"text": "<p>This isn't necessarily the best solution, but another approach might be to use <code>fscanf()</code>:</p>\n\n<pre><cod... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479099",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/58948/"
] | i have to make a user input num/percentage pairs. the code looks like:
```
while(choice != 0)
{
printf("enter number");
fgets(line, sizeof(line), stdin);//sizeof(line) is 6
sscanf(line, "%d\n", choice);
if(choice > 0)
{
printf("enter percentage\n");
fgets(percent_line, sizeof(percent_line), stdin);//... | This isn't necessarily the best solution, but another approach might be to use `fscanf()`:
```
while(choice != 0)
{
printf("enter number");
fscanf(stdin, "%d", &choice);
if(choice > 0)
{
printf("enter percentage\n");
fscanf(stdin, "%f", &percentage);
//add to an array holding numbers vs percentages... |
479,105 | <p>i have a class whose equality is based on 2 fields such that if either one is equal then the objects of this type are considered equal. how can i write a hashCode() function for such an equals() so that the general contract of hashCode being equal when equals returns true is preserved?</p>
<pre><code>public class M... | [
{
"answer_id": 479107,
"author": "Brian",
"author_id": 18192,
"author_profile": "https://Stackoverflow.com/users/18192",
"pm_score": -1,
"selected": false,
"text": "<p>The simplest route is to XOR the hashcodes of each individual field. This has minor ugliness in some situations (e.g. i... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479105",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | i have a class whose equality is based on 2 fields such that if either one is equal then the objects of this type are considered equal. how can i write a hashCode() function for such an equals() so that the general contract of hashCode being equal when equals returns true is preserved?
```
public class MyClass {
int... | I don't think a nontrivial hashcode exists. Also, your `equals()` violates the general contract as [stated in the API](http://java.sun.com/javase/6/docs/api/java/lang/Object.html#equals(java.lang.Object)) --- it is **not transitive**:
`(1,2)` equals `(1,3)`
`(4,3)` equals `(1,3)`
But `(4,3)` is **not equal** to `(1,... |
479,114 | <p>I am looking for a way to determine when a particular file has changed, through .NET. (What I ultimately want is functionality that makes a copy of the file as soon as it has changed.) How can this be done?</p>
| [
{
"answer_id": 479116,
"author": "cjk",
"author_id": 52201,
"author_profile": "https://Stackoverflow.com/users/52201",
"pm_score": 4,
"selected": false,
"text": "<p>You can use a FileSystemWatcher object. This raises events on changes to files within the specified watched folder.</p>\n"... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479114",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2166173/"
] | I am looking for a way to determine when a particular file has changed, through .NET. (What I ultimately want is functionality that makes a copy of the file as soon as it has changed.) How can this be done? | ```
class Program
{
static void Main(string[] args)
{
FileSystemWatcher fsw = new FileSystemWatcher(@"c:\temp");
fsw.Changed += new FileSystemEventHandler(fsw_Changed);
fsw.Deleted += new FileSystemEventHandler(fsw_Deleted);
fsw.Renamed += new RenamedE... |
479,125 | <p>Slightly strange question, but hopefully someone can help.</p>
<p>In essence, if the time was 12pm the the elapsed percentage would be 50%, 6am would be 25% and 16pm would be 75%.</p>
<p>Given the current time, how could you work out the amount of day that already passed? </p>
| [
{
"answer_id": 479134,
"author": "Sebastian",
"author_id": 56440,
"author_profile": "https://Stackoverflow.com/users/56440",
"pm_score": 2,
"selected": false,
"text": "<p>24hours are 100%\nso 24/currentTime = result\n100 / result = % ;)</p>\n"
},
{
"answer_id": 479136,
"autho... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479125",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45350/"
] | Slightly strange question, but hopefully someone can help.
In essence, if the time was 12pm the the elapsed percentage would be 50%, 6am would be 25% and 16pm would be 75%.
Given the current time, how could you work out the amount of day that already passed? | Assuming you can get the current time of day, it'd be pretty easy to calculate the percentage of the day elapsed.
```
percentage = (hours / 24 + minutes / (60 * 24)) * 100
``` |
479,135 | <p>How do you handle slow operations in the Model-View-Presenter (or MVC or M-V-VM or whatever variant you are using)?</p>
<p>When you have a slow operation in WinForms or SWT/JFace or whatever desktop framework you are using, you have to run it on a background thread to avoid completely locking up the application. Wh... | [
{
"answer_id": 479134,
"author": "Sebastian",
"author_id": 56440,
"author_profile": "https://Stackoverflow.com/users/56440",
"pm_score": 2,
"selected": false,
"text": "<p>24hours are 100%\nso 24/currentTime = result\n100 / result = % ;)</p>\n"
},
{
"answer_id": 479136,
"autho... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479135",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5542/"
] | How do you handle slow operations in the Model-View-Presenter (or MVC or M-V-VM or whatever variant you are using)?
When you have a slow operation in WinForms or SWT/JFace or whatever desktop framework you are using, you have to run it on a background thread to avoid completely locking up the application. Where do you... | Assuming you can get the current time of day, it'd be pretty easy to calculate the percentage of the day elapsed.
```
percentage = (hours / 24 + minutes / (60 * 24)) * 100
``` |
479,173 | <pre><code>$ apropos mkfifo
mkfifo (1) - make FIFOs (named pipes)
mkfifo (1posix) - make FIFO special files
mkfifo (3) - make a FIFO special file (a named pipe)
mkfifo (3posix) - make a FIFO special file
mkfifoat (3) - make a FIFO (named pipe) relative to a directory file ...
</cod... | [
{
"answer_id": 479184,
"author": "jpalecek",
"author_id": 51831,
"author_profile": "https://Stackoverflow.com/users/51831",
"pm_score": 5,
"selected": true,
"text": "<p>Basically, the linux manuals are documentation of the commands/APIs from their writers; The POSIX manuals are from the ... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479173",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48461/"
] | ```
$ apropos mkfifo
mkfifo (1) - make FIFOs (named pipes)
mkfifo (1posix) - make FIFO special files
mkfifo (3) - make a FIFO special file (a named pipe)
mkfifo (3posix) - make a FIFO special file
mkfifoat (3) - make a FIFO (named pipe) relative to a directory file ...
```
So I h... | Basically, the linux manuals are documentation of the commands/APIs from their writers; The POSIX manuals are from the POSIX standard. Usually, the "normal" ones are shorter and terser, but deal with the specific implementation; the POSIX ones are longer and more detailed (see `man 3p read`), but only tell what is in t... |
479,182 | <p>I am using JTextArea in JScrollPane</p>
<p>I want to limit the maximum number of lines possible and the maximum chars in each line.</p>
<p>I need that the string will be exactly like on the screen, each line will end with '\n' (if there another line after it) and the user will be able to insert only X lines and Y ... | [
{
"answer_id": 479194,
"author": "kgiannakakis",
"author_id": 24054,
"author_profile": "https://Stackoverflow.com/users/24054",
"pm_score": 4,
"selected": true,
"text": "<p>The <a href=\"http://java.sun.com/docs/books/tutorial/collections/TOC.html\" rel=\"noreferrer\">Collections Tutoria... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479182",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/57809/"
] | I am using JTextArea in JScrollPane
I want to limit the maximum number of lines possible and the maximum chars in each line.
I need that the string will be exactly like on the screen, each line will end with '\n' (if there another line after it) and the user will be able to insert only X lines and Y chars in each lin... | The [Collections Tutorial](http://java.sun.com/docs/books/tutorial/collections/TOC.html) is a good resource. |
479,207 | <p>Is there any way to achieve function overloading in C? I am looking at simple functions to be overloaded like </p>
<pre><code>foo (int a)
foo (char b)
foo (float c , int d)
</code></pre>
<p>I think there is no straight forward way; I'm looking for workarounds if any exist. </p>
| [
{
"answer_id": 479212,
"author": "Jacek Ławrynowicz",
"author_id": 43399,
"author_profile": "https://Stackoverflow.com/users/43399",
"pm_score": 8,
"selected": true,
"text": "<p>There are few possibilities:</p>\n\n<ol>\n<li>printf style functions (type as an argument)</li>\n<li>opengl st... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479207",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34590/"
] | Is there any way to achieve function overloading in C? I am looking at simple functions to be overloaded like
```
foo (int a)
foo (char b)
foo (float c , int d)
```
I think there is no straight forward way; I'm looking for workarounds if any exist. | There are few possibilities:
1. printf style functions (type as an argument)
2. opengl style functions (type in function name)
3. c subset of c++ (if You can use a c++ compiler) |
479,208 | <p>I have a MDI application written in Delphi 2007.</p>
<p>If the user exits a form within it whilst code is executing it causes an exception, because the code is trying to update a component or use an object that has been freed with the form.</p>
<p>Is there anyway I can tell if code is executing in the exit event o... | [
{
"answer_id": 479221,
"author": "Toon Krijthe",
"author_id": 18061,
"author_profile": "https://Stackoverflow.com/users/18061",
"pm_score": 0,
"selected": false,
"text": "<p>Each form has a OnCloseQuery event. </p>\n\n<pre><code>procedure TForm1.FormCloseQuery(Sender: TObject; var CanClo... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479208",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2098/"
] | I have a MDI application written in Delphi 2007.
If the user exits a form within it whilst code is executing it causes an exception, because the code is trying to update a component or use an object that has been freed with the form.
Is there anyway I can tell if code is executing in the exit event or is there a stan... | You provide not enough information, but the easiest solution that comes to mind is to test in the OnCloseQuery handler whether code is executing, and if so set CanClose to False.
Alternatively you can decouple the code from the MDI form, by creating an intermediate object that both the form and the background code kno... |
479,226 | <p>Suppose do you want test if /mnt/disk is a mount point in a shell script.
How do you do this?</p>
| [
{
"answer_id": 479240,
"author": "Bombe",
"author_id": 43582,
"author_profile": "https://Stackoverflow.com/users/43582",
"pm_score": 2,
"selected": false,
"text": "<pre><code>for mountedPath in `mount | cut -d ' ' -f 3`; do\n if [ \"${mountedPath}\" == \"${wantedPath}\" ]; then\n ... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479226",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36131/"
] | Suppose do you want test if /mnt/disk is a mount point in a shell script.
How do you do this? | I discover that on my Fedora 7 there is a mountpoint command.
From man mountpoint:
```
NAME
mountpoint - see if a directory is a mountpoint
SYNOPSIS
/bin/mountpoint [-q] [-d] /path/to/directory
/bin/mountpoint -x /dev/device
```
Apparently it come with the sysvinit package, I don't know if thi... |
479,236 | <p>I want to simulate N-sided biased die? </p>
<pre><code>def roll(N,bias):
'''this function rolls N dimensional die with biasing provided'''
# do something
return result
>> N=6
>> bias=( 0.20,0.20,0.15,0.15,0.14,0.16,)
>> roll(N,bias)
2
</code></pre>
| [
{
"answer_id": 479263,
"author": "Toon Krijthe",
"author_id": 18061,
"author_profile": "https://Stackoverflow.com/users/18061",
"pm_score": 4,
"selected": false,
"text": "<p>More language agnostic, but you could use a lookup table.</p>\n\n<p>Use a random number in the range 0-1 and looku... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479236",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/58737/"
] | I want to simulate N-sided biased die?
```
def roll(N,bias):
'''this function rolls N dimensional die with biasing provided'''
# do something
return result
>> N=6
>> bias=( 0.20,0.20,0.15,0.15,0.14,0.16,)
>> roll(N,bias)
2
``` | A little bit of math here.
A regular die will give each number 1-6 with equal probability, namely `1/6`. This is referred to as [uniform distribution](https://en.wikipedia.org/wiki/Uniform_distribution_(continuous)) (the discrete version of it, as opposed to the continuous version). Meaning that if `X` is a random var... |
479,244 | <p>I will be using LLBLGen to generate a model, however I don't want to solve my design issues by just using whatever built-in inheritance tools it has. I want the model to make sense regardless of the OR/M tool.</p>
<p>So, I have several different kinds of entities that can have addresses and each entity can have mul... | [
{
"answer_id": 479263,
"author": "Toon Krijthe",
"author_id": 18061,
"author_profile": "https://Stackoverflow.com/users/18061",
"pm_score": 4,
"selected": false,
"text": "<p>More language agnostic, but you could use a lookup table.</p>\n\n<p>Use a random number in the range 0-1 and looku... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479244",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/58959/"
] | I will be using LLBLGen to generate a model, however I don't want to solve my design issues by just using whatever built-in inheritance tools it has. I want the model to make sense regardless of the OR/M tool.
So, I have several different kinds of entities that can have addresses and each entity can have multiple addr... | A little bit of math here.
A regular die will give each number 1-6 with equal probability, namely `1/6`. This is referred to as [uniform distribution](https://en.wikipedia.org/wiki/Uniform_distribution_(continuous)) (the discrete version of it, as opposed to the continuous version). Meaning that if `X` is a random var... |
479,269 | <p>Is there any reason why XML such as this :</p>
<pre><code><person>
<firstname>Joe</firstname>
<lastname>Plumber</lastname>
</person>
</code></pre>
<p>couldn't be compressed like this for client/server transfer. </p>
<pre><code><person>
<firstnam... | [
{
"answer_id": 479272,
"author": "cletus",
"author_id": 18393,
"author_profile": "https://Stackoverflow.com/users/18393",
"pm_score": 4,
"selected": true,
"text": "<p>That's not valid XML. Closing tags must be named. It's potentially error prone otherwise and frankly I think it'd be le... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479269",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16940/"
] | Is there any reason why XML such as this :
```
<person>
<firstname>Joe</firstname>
<lastname>Plumber</lastname>
</person>
```
couldn't be compressed like this for client/server transfer.
```
<person>
<firstname>Joe</>
<lastname>Plumber</>
</>
```
It would be smaller - and slightly... | That's not valid XML. Closing tags must be named. It's potentially error prone otherwise and frankly I think it'd be less readable your way.
In reference to your clarification about this being a nonstandard violation of the XML standard to save a few bytes, it is an incredibly bad idea for several reasons:
1. It's no... |
479,284 | <p>I can't get the Mouse Wheel event in the main form.</p>
<p>As a demo I came up with a simple example:</p>
<pre><code>public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.panel1.MouseWheel += new MouseEventHandler(panel1_MouseWheel);
this.panel1.MouseMove... | [
{
"answer_id": 479310,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>Maybe this will work for you?</p>\n<pre><code>public partial class Form1 : Form {\n public Form1() {\n Initialize... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479284",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I can't get the Mouse Wheel event in the main form.
As a demo I came up with a simple example:
```
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.panel1.MouseWheel += new MouseEventHandler(panel1_MouseWheel);
this.panel1.MouseMove += new MouseEventHan... | I suspect the OP wants to get scroll events when just the mouse is hovering over the panel even though the panel does not have the focus.
A way to accomplish this behaviour is explained here:
<http://social.msdn.microsoft.com/forums/en-US/winforms/thread/eb922ed2-1036-41ca-bd15-49daed7b637c/>
and here:
<http://soci... |
479,328 | <p>Suppose my stored procedure is:</p>
<pre><code>IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'sp_QB_descriptionwise_select')
BEGIN
DROP Procedure sp_QB_descriptionwise_select
END
GO
CREATE Procedure sp_QB_descriptionwise_select
(
@description nvarchar(max)
)
AS
d... | [
{
"answer_id": 479412,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 2,
"selected": false,
"text": "<p>Using <code>IDataReader</code> / <code>ExecuteReader</code>, you should be able to use:</p>\n\n<pre><code> usin... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479328",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Suppose my stored procedure is:
```
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'sp_QB_descriptionwise_select')
BEGIN
DROP Procedure sp_QB_descriptionwise_select
END
GO
CREATE Procedure sp_QB_descriptionwise_select
(
@description nvarchar(max)
)
AS
declare @type i... | Using `IDataReader` / `ExecuteReader`, you should be able to use:
```
using (IDataReader reader = cmd.ExecuteReader())
{
do
{
while (reader.Read())
{
/* row */
}
} while (reader.NextResult()); /* grid */
}
``` |
479,329 | <p>I have a simple <code>List<string></code> and I'd like it to be displayed in a <code>DataGridView</code> column.<br>
If the list would contain more complex objects, simply would establish the list as the value of its <code>DataSource</code> property.</p>
<p>But when doing this:</p>
<pre><code>myDataGridView.... | [
{
"answer_id": 479419,
"author": "sinm",
"author_id": 58981,
"author_profile": "https://Stackoverflow.com/users/58981",
"pm_score": 7,
"selected": true,
"text": "<p>Thats because DataGridView looks for properties of containing objects. For string there is just one property - length. So, ... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479329",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40872/"
] | I have a simple `List<string>` and I'd like it to be displayed in a `DataGridView` column.
If the list would contain more complex objects, simply would establish the list as the value of its `DataSource` property.
But when doing this:
```
myDataGridView.DataSource = myStringList;
```
I get a column called `Lengt... | Thats because DataGridView looks for properties of containing objects. For string there is just one property - length. So, you need a wrapper for a string like this
```
public class StringValue
{
public StringValue(string s)
{
_value = s;
}
public string Value { get { return _value; } set { _va... |
479,341 | <p>I have a question related to gridviews in ASP.NET</p>
<p>I have a gridview that I pull information from a SQL db and it displays the username and current status IE;</p>
<ul>
<li>Username | Status</li>
<li>user1 | Logged Out</li>
<li>user2 | Logged in</li>
<li>user3 | On Leave</li>
</ul>
<p>So thi... | [
{
"answer_id": 479365,
"author": "Christoph",
"author_id": 34464,
"author_profile": "https://Stackoverflow.com/users/34464",
"pm_score": 1,
"selected": false,
"text": "<p>Try to set the corresponding CSS Class, and then set the CSS to use the fitting Background Image. I Think you cannot ... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479341",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a question related to gridviews in ASP.NET
I have a gridview that I pull information from a SQL db and it displays the username and current status IE;
* Username | Status
* user1 | Logged Out
* user2 | Logged in
* user3 | On Leave
So this is working all handy dandy, however what I'd like to do is rather that ... | Try to set the corresponding CSS Class, and then set the CSS to use the fitting Background Image. I Think you cannot use a BoundField, but you have to use a TemplateField like this:
```
<asp:TemplateField>
<ItemTemplate>
<div class="StateBar State<%#eval("State") %>"> </div>
</ItemTemplate>
</asp:... |
479,343 | <p>How can I build a recursive function in python?</p>
| [
{
"answer_id": 479352,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 6,
"selected": false,
"text": "<p>I'm wondering whether you meant \"recursive\". Here is a simple example of a recursive function to compute the <a href... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479343",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How can I build a recursive function in python? | I'm wondering whether you meant "recursive". Here is a simple example of a recursive function to compute the [factorial function](http://en.wikipedia.org/wiki/Factorial):
```
def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n - 1)
```
The two key elements of a recursive algori... |
479,351 | <p>I have an important Object which have loads of properties. Now few of the properties could have multiple values for example consider, A Channel Object having one or mulitple producers (Now our client think that there could be only few producers like mostly 1 or 2 ). The same issue exist with almost 7 properties. </p... | [
{
"answer_id": 479387,
"author": "MrTelly",
"author_id": 56092,
"author_profile": "https://Stackoverflow.com/users/56092",
"pm_score": 2,
"selected": true,
"text": "<p>I think you can combine both approaches to give a good overall result. Create seperate tables for Producer etc, and then... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479351",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17519/"
] | I have an important Object which have loads of properties. Now few of the properties could have multiple values for example consider, A Channel Object having one or mulitple producers (Now our client think that there could be only few producers like mostly 1 or 2 ). The same issue exist with almost 7 properties.
Now ... | I think you can combine both approaches to give a good overall result. Create seperate tables for Producer etc, and then use domain objects to read the values from those tables once only and cache the results. In that way you can
1) maintain ref integrity in the DB, take advantage of DB backups etc,
2) remove the pe... |
479,355 | <p>HI,
I am developing a iphone app by using cocos2d. Its shown this msg.</p>
<pre><code>2009-01-26 16:17:40.603 Find The Nuts[449:20b] *** -[NSCFArray onTimer:]: unrecognized selector sent to instance 0x59be030
2009-01-26 16:17:40.605 Find The Nuts[449:20b] *** Terminating app due to uncaught exception 'NSInvalidArg... | [
{
"answer_id": 479402,
"author": "AnthonyLambert",
"author_id": 31762,
"author_profile": "https://Stackoverflow.com/users/31762",
"pm_score": 0,
"selected": false,
"text": "<p>sounds like you are not providing a valid method to the timer to call on completion of the count down. You need ... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479355",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51108/"
] | HI,
I am developing a iphone app by using cocos2d. Its shown this msg.
```
2009-01-26 16:17:40.603 Find The Nuts[449:20b] *** -[NSCFArray onTimer:]: unrecognized selector sent to instance 0x59be030
2009-01-26 16:17:40.605 Find The Nuts[449:20b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException... | Your onTimer method is being sent to an instance of NSArray for some reason. It is likely that you are either accidentally sending it to a real instance of NSArray, or that the object you are really trying to send it to has been released (aka, is no longer accessible) by the time the timer actually fires.
I would try ... |
479,361 | <p>Currently I have a root-level repository set up for each project, like so:</p>
<pre><code>Project1
Project2
Project3
Project5
Project5
</code></pre>
<p>I'd like to reorganise this so that rather than a repository for each individual project, I just have one for each logical grouping, and then the projects would ju... | [
{
"answer_id": 479378,
"author": "Steven Robbins",
"author_id": 26507,
"author_profile": "https://Stackoverflow.com/users/26507",
"pm_score": 6,
"selected": true,
"text": "<p>You should be able to dump it, then reload it to a subdirectory of a new repository:</p>\n\n<blockquote>\n <p>sv... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479361",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43140/"
] | Currently I have a root-level repository set up for each project, like so:
```
Project1
Project2
Project3
Project5
Project5
```
I'd like to reorganise this so that rather than a repository for each individual project, I just have one for each logical grouping, and then the projects would just be folders within those... | You should be able to dump it, then reload it to a subdirectory of a new repository:
>
> svnadmin dump <http://oldrepo/> > mydump
>
>
> svnadmin load --parent-dir my/new/folder
> <http://newrepo/> < mydump
>
>
> |
479,368 | <p>I've some pocket pc app and i'm having a serious problem with it described here: <a href="https://stackoverflow.com/questions/472598">https://stackoverflow.com/questions/472598</a> . While looking for a solution i tried some actually quite stupid code in Main(): </p>
<pre><code>[MTAThread]
static void Main... | [
{
"answer_id": 479380,
"author": "Vojislav Stojkovic",
"author_id": 58099,
"author_profile": "https://Stackoverflow.com/users/58099",
"pm_score": 0,
"selected": false,
"text": "<p>This line seems to be the problem:</p>\n\n<pre><code>Tasks tasksWindow = new Tasks();\n</code></pre>\n\n<p>I... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479368",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40872/"
] | I've some pocket pc app and i'm having a serious problem with it described here: <https://stackoverflow.com/questions/472598> . While looking for a solution i tried some actually quite stupid code in Main():
```
[MTAThread]
static void Main()
{
Application.Run(new Tasks());
App... | `new Tasks()` in `Main()` is not the same object with `Tasks tasksWindow = new Tasks();`
You got 2 objects of Tasks, so closing second, first is still present and never dies. You need to pass to `QuestionnairesWindow` the reference of current `Tasks`.
You can do that with additional `QuestionnairesWindow` constructor... |
479,373 | <p>I want to do:</p>
<pre><code>int a = 255;
cout << a;
</code></pre>
<p>and have it show FF in the output, how would I do this?</p>
| [
{
"answer_id": 479377,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 8,
"selected": false,
"text": "<p>Use:</p>\n\n<pre><code>#include <iostream>\n\n...\n\nstd::cout << std::hex << a;\n</code></pre>\n\n<... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479373",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I want to do:
```
int a = 255;
cout << a;
```
and have it show FF in the output, how would I do this? | Use:
```
#include <iostream>
...
std::cout << std::hex << a;
```
There are [many other options to control the exact formatting of the output number](http://en.cppreference.com/w/cpp/io/manip), such as leading zeros and upper/lower case. |
479,398 | <p>I have a web page which have 3 controls:</p>
<ol>
<li>form using the post command.</li>
<li>in the form i have an input file control named "myFile".</li>
<li>a button</li>
</ol>
<p>the upload process works just fine, until I'm trying to post the form and handle the upload in another form.</p>
<p><strong>Request["... | [
{
"answer_id": 479432,
"author": "Mark Bell",
"author_id": 43140,
"author_profile": "https://Stackoverflow.com/users/43140",
"pm_score": 1,
"selected": false,
"text": "<p>It's the Request.Files collection you need - look it up in the .NET Framework docs:</p>\n\n<pre><code>Request.Files[\... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479398",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a web page which have 3 controls:
1. form using the post command.
2. in the form i have an input file control named "myFile".
3. a button
the upload process works just fine, until I'm trying to post the form and handle the upload in another form.
**Request["myFile"]** and **request.Params["myFile"]** gave me ... | It's the Request.Files collection you need - look it up in the .NET Framework docs:
```
Request.Files["myFile"]
```
Also make sure that the enctype attribute of your upload form is set correctly - it should be "multipart/form-data" if the form contains file inputs. |
479,400 | <p>i have two applications - one is an asp.net website and the other is a windows service.</p>
<p>both applications are referencing my business layer (library project), which itself is referencing my data access layer (library project) that itself uses the enterprise library data application block to receive the data ... | [
{
"answer_id": 479711,
"author": "Jochen",
"author_id": 13278,
"author_profile": "https://Stackoverflow.com/users/13278",
"pm_score": 2,
"selected": false,
"text": "<p>I think what you need is a distributed cache system like memcached. But there are more, just do a quick Google and you w... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479400",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/57737/"
] | i have two applications - one is an asp.net website and the other is a windows service.
both applications are referencing my business layer (library project), which itself is referencing my data access layer (library project) that itself uses the enterprise library data application block to receive the data form a sql... | You should take a significant look at Microsoft's new free distributed cache "Velocity."
Here's a podcast I did on the subject:
<http://www.hanselman.com/blog/HanselminutesPodcast116DistributedCachingWithMicrosoftsVelocity.aspx>
Here's details on MSDN: <http://msdn.microsoft.com/en-us/data/cc655792.aspx>
Here's down... |
479,408 | <p>While entering a SQL statement in Oracle SQL Developer, I noticed that I have two choices. I can either "Run Statement" or "Run Script". A similar choice seems to be available in SQL Maestro as well, although named "Execute query" and "Execute as script".</p>
<p>What exactly is the difference between the two?</p>
| [
{
"answer_id": 479437,
"author": "waney",
"author_id": 58123,
"author_profile": "https://Stackoverflow.com/users/58123",
"pm_score": 0,
"selected": false,
"text": "<p>I think \n\"Execute Statement\" - mean if you want to get results (resultset)\n\"Run Script\" - is something you... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479408",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/57898/"
] | While entering a SQL statement in Oracle SQL Developer, I noticed that I have two choices. I can either "Run Statement" or "Run Script". A similar choice seems to be available in SQL Maestro as well, although named "Execute query" and "Execute as script".
What exactly is the difference between the two? | `Run Statement` will give you a list of all the results in a sortable table. It will also only run the statement under the cursor (or highlighted). You will be prompted for bind variables when you run the statement (any place holder with : in front of it).
E.g.
```
select * from customers where customer_id = :id
``... |
479,410 | <p>My enum consists of the following values:</p>
<pre><code>private enum PublishStatusses{
NotCompleted,
Completed,
Error
};
</code></pre>
<p>I want to be able to output these values in a user friendly way though.<br>
I don't need to be able to go from string to value again. </p>
| [
{
"answer_id": 479417,
"author": "Ray Booysen",
"author_id": 42124,
"author_profile": "https://Stackoverflow.com/users/42124",
"pm_score": 10,
"selected": true,
"text": "<p>I use the <a href=\"http://msdn.microsoft.com/en-us/library/system.componentmodel.descriptionattribute.aspx\" rel=\... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479410",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11333/"
] | My enum consists of the following values:
```
private enum PublishStatusses{
NotCompleted,
Completed,
Error
};
```
I want to be able to output these values in a user friendly way though.
I don't need to be able to go from string to value again. | I use the [`Description`](http://msdn.microsoft.com/en-us/library/system.componentmodel.descriptionattribute.aspx) attribute from the System.ComponentModel namespace. Simply decorate the enum:
```
private enum PublishStatusValue
{
[Description("Not Completed")]
NotCompleted,
Completed,
Error
};
```
T... |
479,425 | <p>For two of my VS 2005 C++ projects, VS wants to write to the .sln file when I build the projects. I have got a number of other VS 2005 C++ projects where this is not the case. It is a problem as due to the fact that we have ClearCase source control integrated with our VS 2005 installations and when we try and run ... | [
{
"answer_id": 479444,
"author": "Sergio",
"author_id": 32037,
"author_profile": "https://Stackoverflow.com/users/32037",
"pm_score": 1,
"selected": false,
"text": "<p>I am guessing here, but it looks like some changes have been made to the InterCommClientB project(project, not the files... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479425",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12735/"
] | For two of my VS 2005 C++ projects, VS wants to write to the .sln file when I build the projects. I have got a number of other VS 2005 C++ projects where this is not the case. It is a problem as due to the fact that we have ClearCase source control integrated with our VS 2005 installations and when we try and run an ov... | I had similar problem. It seems that when converting projects from old versions of VS (like 6 or 2003) VS 2010 is not adding Project GUID to the .vcxproj file. Because of that when you open solution including such project VS will recreate GUID for such project, and will change .sln file but will not change .vcxproj fil... |
479,431 | <p>I'm new to Boost.Spirit and Boost.Test and I would like to know how you verify the correctness of your grammars. Below is a simplified version of how I do it at the moment and I'm pretty sure that there's a better way:</p>
<p>Each test case hase a pair of two strings containing the text to parse and the expected re... | [
{
"answer_id": 479444,
"author": "Sergio",
"author_id": 32037,
"author_profile": "https://Stackoverflow.com/users/32037",
"pm_score": 1,
"selected": false,
"text": "<p>I am guessing here, but it looks like some changes have been made to the InterCommClientB project(project, not the files... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479431",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/58978/"
] | I'm new to Boost.Spirit and Boost.Test and I would like to know how you verify the correctness of your grammars. Below is a simplified version of how I do it at the moment and I'm pretty sure that there's a better way:
Each test case hase a pair of two strings containing the text to parse and the expected result delim... | I had similar problem. It seems that when converting projects from old versions of VS (like 6 or 2003) VS 2010 is not adding Project GUID to the .vcxproj file. Because of that when you open solution including such project VS will recreate GUID for such project, and will change .sln file but will not change .vcxproj fil... |
479,435 | <p>I'm looking to retrieve a machine's windows experience rating in C#. If possible I would also like to retrieve the numbers for each component (Graphics, RAM etc.)</p>
<p>Is this possible?</p>
| [
{
"answer_id": 479442,
"author": "Noldorin",
"author_id": 44389,
"author_profile": "https://Stackoverflow.com/users/44389",
"pm_score": 1,
"selected": false,
"text": "<p><a href=\"http://www.dreamincode.net/code/snippet1456.htm\" rel=\"nofollow noreferrer\">Here</a> is a snippet for VB.N... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479435",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42124/"
] | I'm looking to retrieve a machine's windows experience rating in C#. If possible I would also like to retrieve the numbers for each component (Graphics, RAM etc.)
Is this possible? | Every time the user goes through control panel to calculate the Windows Experience Rating, the system creates a new file in `%Windows%\Performance\WinSAT\DataStore\`
You need to find the most recent file (they are named with the most significant date first, so finding the latest file is trivial).
These files are xml ... |
479,455 | <p>What is the best way to populate records in two tables that each need a reference to the primary key of the other?</p>
<p>My thoughts are either having a "link" table between them which is populated once both have been written to the db or by the following complex series of commands</p>
<pre><code>Insert1
get ide... | [
{
"answer_id": 479482,
"author": "Jack Ryan",
"author_id": 28882,
"author_profile": "https://Stackoverflow.com/users/28882",
"pm_score": 2,
"selected": false,
"text": "<p>Can I ask why the tables need to reference each other. If it is a straight 1:1 then I would suggest just putting the ... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479455",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20400/"
] | What is the best way to populate records in two tables that each need a reference to the primary key of the other?
My thoughts are either having a "link" table between them which is populated once both have been written to the db or by the following complex series of commands
```
Insert1
get identity1
Insert2
get id... | Can I ask why the tables need to reference each other. If it is a straight 1:1 then I would suggest just putting the foreign key in one of the tables. the lookup is just as easy. And your foreign key can be properly enforced. otherwise you run into a chicken/egg scenario where the tables both need to reference each oth... |
479,466 | <p>I've got data in ten minutes intervals in my table:</p>
<pre><code>2009-01-26 00:00:00 12
2009-01-26 00:10:00 1.1
2009-01-26 00:20:00 11
2009-01-26 00:30:00 0
2009-01-26 00:40:00 5
2009-01-26 00:50:00 3.4
2009-01-26 01:00:00 7
2009-01-26 01:10:00 7
2009-01-26 01:20:00 7.... | [
{
"answer_id": 479480,
"author": "MattBelanger",
"author_id": 655,
"author_profile": "https://Stackoverflow.com/users/655",
"pm_score": 2,
"selected": false,
"text": "<p>This should work:</p>\n\n<pre><code>SELECT AVG( value ) , thetime\nFROM hourly_averages\nGROUP BY HOUR( thetime )\n</c... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479466",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6260/"
] | I've got data in ten minutes intervals in my table:
```
2009-01-26 00:00:00 12
2009-01-26 00:10:00 1.1
2009-01-26 00:20:00 11
2009-01-26 00:30:00 0
2009-01-26 00:40:00 5
2009-01-26 00:50:00 3.4
2009-01-26 01:00:00 7
2009-01-26 01:10:00 7
2009-01-26 01:20:00 7.2
2009-01-26 0... | It's unclear whether you want the average to be aggregated over days or not.
If you want a different average for midnight on the 26th vs midnight on the 27th, then modify Mabwi's query thus:
```
SELECT AVG( value ) , thetime
FROM hourly_averages
GROUP BY DATE( thetime ), HOUR( thetime )
```
Note the additional `DAT... |
479,475 | <p>OK, as is often the case, I have a controller action in my app that is protected from unauthorized access by a before_filter. The only thing is that I need to redirect this action if another condition is true:</p>
<pre><code>class Payment < ApplicationController
before_filter login_required
def new
redi... | [
{
"answer_id": 479528,
"author": "August Lilleaas",
"author_id": 26051,
"author_profile": "https://Stackoverflow.com/users/26051",
"pm_score": 0,
"selected": false,
"text": "<p>I don't think your before filter is what causes the double render error. Take a look at this example:</p>\n\n<p... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479475",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12037/"
] | OK, as is often the case, I have a controller action in my app that is protected from unauthorized access by a before\_filter. The only thing is that I need to redirect this action if another condition is true:
```
class Payment < ApplicationController
before_filter login_required
def new
redirect_to some_oth... | I am assuming that the login\_required method performs a redirect if the user is not logged in. In which case:
Your before filter should return false after calling redirect. This will prevent the new action from ever being called. Later versions of rails automatically do this if you call render or redirect in a before... |
479,481 | <p>I have order - items tables.
so I want to display on some grid all the orders info including a col like total_items</p>
<p>There is a premetive working way. like this:</p>
<pre><code>TotalQuantity =
(from i in _db.ProposaItems
where i.ProposaID == p.ProposaID select i)
.Sum(q => q.Quantity)
</code></pr... | [
{
"answer_id": 479741,
"author": "yfeldblum",
"author_id": 12349,
"author_profile": "https://Stackoverflow.com/users/12349",
"pm_score": 1,
"selected": false,
"text": "<p>I don't think you can call unmapped functions (such as <code>GetItems</code>) in a LINQ to SQL query.</p>\n"
},
{... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479481",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54801/"
] | I have order - items tables.
so I want to display on some grid all the orders info including a col like total\_items
There is a premetive working way. like this:
```
TotalQuantity =
(from i in _db.ProposaItems
where i.ProposaID == p.ProposaID select i)
.Sum(q => q.Quantity)
```
But this is not the way I wa... | I don't think you can call unmapped functions (such as `GetItems`) in a LINQ to SQL query. |
479,487 | <p>I am looking for some information about Advertisement servers.</p>
<ol>
<li>Implementation details
<ul>
<li>tracking code generation</li>
<li>user data collection</li>
<li>serving the ad in response to a click-through</li>
</ul></li>
<li>Applicable standards</li>
<li>Reference material (Please provide links or sea... | [
{
"answer_id": 479526,
"author": "annakata",
"author_id": 13018,
"author_profile": "https://Stackoverflow.com/users/13018",
"pm_score": 2,
"selected": false,
"text": "<p>I work for such a company, and I'm afraid this kind of proprietary information is considered extremely sensitive. AFAI... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479487",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37571/"
] | I am looking for some information about Advertisement servers.
1. Implementation details
* tracking code generation
* user data collection
* serving the ad in response to a click-through
2. Applicable standards
3. Reference material (Please provide links or search teams to search)
* books
* white papers
4. Implem... | Check out the [IAB (Interactive Advertising Bureau)](http://www.iab.net/about_the_iab)
They have specs on some commonly agreed-upon things like ad-banner formats. They seem to deal mostly in business issues and less on the technical/implementation specifics.
The simplest implementation is simply pointing to an image ... |
479,492 | <p>I mean, like php'h include...</p>
<p>something like</p>
<pre>
my_file_to_be_included = "include_me.asp"
-- >
</pre>
<p>for what I've seen so far, there are a couple of alternatives, but every one of them has some sort of shortcoming...</p>
<p>what I'm trying to figure out is how to make a flexible template syst... | [
{
"answer_id": 479546,
"author": "AnthonyWJones",
"author_id": 17516,
"author_profile": "https://Stackoverflow.com/users/17516",
"pm_score": 3,
"selected": false,
"text": "<p>No you can't do a dyanmic include, period.</p>\n\n<p>Your best shot at this is a server.execute and passing whate... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479492",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47633/"
] | I mean, like php'h include...
something like
```
my_file_to_be_included = "include_me.asp"
-- >
```
for what I've seen so far, there are a couple of alternatives, but every one of them has some sort of shortcoming...
what I'm trying to figure out is how to make a flexible template system... without having to sta... | No you can't do a dyanmic include, period.
Your best shot at this is a server.execute and passing whatever state it needs via a Session variable:-
```vb
Session("callParams") = BuildMyParams() 'Creates some sort of string
Server.Execute(my_file_to_be_included)
Session.Contents.Remove("callParams")
``` |
479,523 | <p>I'm putting together a quick and dirty animation using swing. I would like the window to be maximized. How can I do that?</p>
| [
{
"answer_id": 479540,
"author": "user54579",
"author_id": 54579,
"author_profile": "https://Stackoverflow.com/users/54579",
"pm_score": 4,
"selected": false,
"text": "<p>If you're using a JFrame, try this</p>\n\n<pre><code>JFrame frame = new JFrame();\n//...\nframe.setExtendedState(JFra... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479523",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41718/"
] | I'm putting together a quick and dirty animation using swing. I would like the window to be maximized. How can I do that? | Provided that you are extending JFrame:
```
public void run() {
MyFrame myFrame = new MyFrame();
myFrame.setVisible(true);
myFrame.setExtendedState(myFrame.getExtendedState() | JFrame.MAXIMIZED_BOTH);
}
``` |
479,531 | <p>In C# I can use the following code to have code which only executes during debug build, how can I do the same in Xcode?</p>
<pre><code>#if DEBUG
{
// etc etc
}
#endif
</code></pre>
| [
{
"answer_id": 479562,
"author": "Alnitak",
"author_id": 6782,
"author_profile": "https://Stackoverflow.com/users/6782",
"pm_score": 6,
"selected": false,
"text": "<p>You can use</p>\n\n<pre><code>#ifdef DEBUG\n ....\n#endif\n</code></pre>\n\n<p>You'll need to add <code>DEBUG=1</code>... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479531",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/258/"
] | In C# I can use the following code to have code which only executes during debug build, how can I do the same in Xcode?
```
#if DEBUG
{
// etc etc
}
#endif
``` | The NDEBUG symbol should be defined for you already in release mode builds
```
#ifndef NDEBUG
/* Debug only code */
#endif
```
By using NDEBUG you just avoid having to specify a -D DEBUG argument to the compiler yourself for the debug builds |
479,548 | <p>I'm creating a small utility in C#, that will add some text to an active textbox when a global hotkey is pressed, it's a type of auto complete function. I have my global hotkey working, but now I don't know how to get the current text in the active textbox (if the active window is a textbox that is.) What I've tried... | [
{
"answer_id": 479550,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "<p><a href=\"http://openidenabled.com/php-openid/\" rel=\"nofollow noreferrer\">http://openidenabled.com/php-openid/</a></p>\n... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479548",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35716/"
] | I'm creating a small utility in C#, that will add some text to an active textbox when a global hotkey is pressed, it's a type of auto complete function. I have my global hotkey working, but now I don't know how to get the current text in the active textbox (if the active window is a textbox that is.) What I've tried so... | See here: [Google Login PHP Class](http://www.andrewpeace.com/php-google-login-class.html).
Also be sure to refer to the [Google Federated Login site](https://developers.google.com/accounts/docs/OpenID) for more info. |
479,554 | <p>I want to have four colored areas which are clickable.
I can user TextBlock in a Border to get the color areas, but then neither of them have a Click event.
So I can make the whole thing a button, but then it doesn't have rounded corners and I can't seem to change the background.</p>
<p>What is the recommended way ... | [
{
"answer_id": 479600,
"author": "Mark Pim",
"author_id": 38883,
"author_profile": "https://Stackoverflow.com/users/38883",
"pm_score": 3,
"selected": true,
"text": "<p>You have to define a custom template for your button</p>\n\n<p>For example:</p>\n\n<pre><code><UniformGrid>\n &l... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479554",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4639/"
] | I want to have four colored areas which are clickable.
I can user TextBlock in a Border to get the color areas, but then neither of them have a Click event.
So I can make the whole thing a button, but then it doesn't have rounded corners and I can't seem to change the background.
What is the recommended way to go abou... | You have to define a custom template for your button
For example:
```
<UniformGrid>
<UniformGrid.Resources>
<ControlTemplate x:Key="buttonTemp">
<Border Margin="10" CornerRadius="10" Background="Yellow">
<TextBlock Text="{TemplateBinding Button.Content}"/>
</Border>
</ControlTemplate>
... |
479,558 | <p><a href="http://www.eclipse.org" rel="noreferrer">Eclipse</a> the IDE is one of the best examples of a huge desktop application written in Java.</p>
<p>Most Java applications I've seen usually rely on a batch or shell script to build a string with the class path of the application, and launch the JVM with the class... | [
{
"answer_id": 479590,
"author": "ShuggyCoUk",
"author_id": 12748,
"author_profile": "https://Stackoverflow.com/users/12748",
"pm_score": 3,
"selected": false,
"text": "<p>Some of these are windows specific some are general.</p>\n\n<ol>\n<li><p>Your shell integration is much improved com... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479558",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15649/"
] | [Eclipse](http://www.eclipse.org) the IDE is one of the best examples of a huge desktop application written in Java.
Most Java applications I've seen usually rely on a batch or shell script to build a string with the class path of the application, and launch the JVM with the class path as an env variable.
Eclipse, on... | The [Equinox launcher](http://wiki.eclipse.org/index.php/Equinox_Launcher) uses JNI to start the Java VM in the same process as the launcher. Using JNI also allows us to use SWT widgets in the splash screen.
---
Actually, you can still have a script, since the launcher executable, eclipse.exe, has been broken into 2 ... |
479,565 | <p>Suppose you need to define a class which all it does is hold constants.</p>
<pre><code>public static final String SOME_CONST = "SOME_VALUE";
</code></pre>
<p>What is the preferred way of doing this?</p>
<ol>
<li>Interface</li>
<li>Abstract Class</li>
<li>Final Class</li>
</ol>
<p>Which one should I use and why?<... | [
{
"answer_id": 479572,
"author": "Megacan",
"author_id": 54947,
"author_profile": "https://Stackoverflow.com/users/54947",
"pm_score": 2,
"selected": false,
"text": "<p>Just use final class.</p>\n\n<p>If you want to be able to add other values use an abstract class.</p>\n\n<p>It doesn't ... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479565",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24545/"
] | Suppose you need to define a class which all it does is hold constants.
```
public static final String SOME_CONST = "SOME_VALUE";
```
What is the preferred way of doing this?
1. Interface
2. Abstract Class
3. Final Class
Which one should I use and why?
---
*Clarifications to some answers:*
**Enums** - I'm not g... | Use a final class, and define a private constructor to hide the public one.
For simplicity you may then use a static import to reuse your values in another class
```
public final class MyValues {
private MyValues() {
// No need to instantiate the class, we can hide its constructor
}
public static final ... |
479,587 | <p>I've created a control derived from ComboBox, and wish to unit test its behaviour.</p>
<p>However, it appears to be behaving differently in my unit test to how it behaves in the real application.</p>
<p>In the real application, the Combobox.DataSource property and the .Items sync up - in other words when I change ... | [
{
"answer_id": 479593,
"author": "abatishchev",
"author_id": 41956,
"author_profile": "https://Stackoverflow.com/users/41956",
"pm_score": 0,
"selected": false,
"text": "<p>I'm sure that <code>Application.Run</code> absence cannot affects any control's behavior</p>\n"
},
{
"answe... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479587",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23461/"
] | I've created a control derived from ComboBox, and wish to unit test its behaviour.
However, it appears to be behaving differently in my unit test to how it behaves in the real application.
In the real application, the Combobox.DataSource property and the .Items sync up - in other words when I change the Combobox.Data... | Since you're simply calling the constructor, a lot of functionality of the combobox will not work. For example, the items will be filled when the ComboBox is drawn on screen, on a form. This does not happen when constructing it in a unit test.
Why do you want to write a unit test on that combobox?
Can't you seperate ... |
479,591 | <p>I'm having a play with SVG and am having a few problems with positioning. I have a series of shapes which are contained in the <code>g</code> group tag. I was hoping to use it like a container, so I could set its x position and then all the elements in that group would also move. But that doesn't seem to be possible... | [
{
"answer_id": 479643,
"author": "Aaron Digulla",
"author_id": 34088,
"author_profile": "https://Stackoverflow.com/users/34088",
"pm_score": 8,
"selected": false,
"text": "<p>Everything in the g element is positioned relative to the current transform matrix.</p>\n\n<p>To move the content... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479591",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37196/"
] | I'm having a play with SVG and am having a few problems with positioning. I have a series of shapes which are contained in the `g` group tag. I was hoping to use it like a container, so I could set its x position and then all the elements in that group would also move. But that doesn't seem to be possible.
1. How do m... | Everything in the g element is positioned relative to the current transform matrix.
To move the content, just put the transformation in the g element:
```
<g transform="translate(20,2.5) rotate(10)">
<rect x="0" y="0" width="60" height="10"/>
</g>
```
Links: [Example](http://www.w3.org/TR/SVG11/images/struct/Us... |
479,592 | <p>I have this Struts tag:</p>
<pre class="lang-html prettyprint-override"><code><s:select name="country.id"
list="countries"
listValue="name"
listKey="id"
headerValue="Select Country"
headerKey=""
label="Country" />
</code></pre>
<p>which output... | [
{
"answer_id": 479646,
"author": "Boris Pavlović",
"author_id": 32090,
"author_profile": "https://Stackoverflow.com/users/32090",
"pm_score": 0,
"selected": false,
"text": "<p>Try this:</p>\n\n<pre><code>headerKey=\"3\"\n</code></pre>\n"
},
{
"answer_id": 481918,
"author": "P... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479592",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21613/"
] | I have this Struts tag:
```html
<s:select name="country.id"
list="countries"
listValue="name"
listKey="id"
headerValue="Select Country"
headerKey=""
label="Country" />
```
which outputs the following HTML code:
```html
<select name="country.id" tabinde... | Use the `value` attribute in the `s:select` tag:
```
<s:select name="country.id"
list="countries"
listValue="name"
listKey="id"
headerValue="Select Country"
headerKey=""
label="Country"
value="3" />
``` |
479,595 | <p>In Java, how would you set up a socket listener that listened to a socket for a series of bytes that represented a command and on recieving called a method which parsed the incoming data and invoked the appropriate command?</p>
<p><strong>Clarification:</strong></p>
<p>My issue is not with handling the commands (W... | [
{
"answer_id": 479615,
"author": "Alnitak",
"author_id": 6782,
"author_profile": "https://Stackoverflow.com/users/6782",
"pm_score": 0,
"selected": false,
"text": "<p>I would</p>\n\n<ol>\n<li><p>put each command into a <code>class</code> of its own, where each class implements a specific... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479595",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20400/"
] | In Java, how would you set up a socket listener that listened to a socket for a series of bytes that represented a command and on recieving called a method which parsed the incoming data and invoked the appropriate command?
**Clarification:**
My issue is not with handling the commands (Which might also be error codes... | [Starting from my other answer](https://stackoverflow.com/questions/479595/forwarding-incoming-tcp-commands-to-a-function#479898): The specific part you request is the one that goes into the section: "Magic goes here". It can be done in ohh so many ways, but one is:
```
final InputStream in = socket.getInputStream();
... |
479,607 | <p>Is there a way to write an XSL 1.0 template which is matching in all modes? </p>
<p>Or do I have to write a separate template for every existing mode (including additional templates for modes being added in the future)?</p>
<p>Here is what I have:</p>
<pre><code><xsl:apply-templates mode="mode1" />
...
... | [
{
"answer_id": 479627,
"author": "annakata",
"author_id": 13018,
"author_profile": "https://Stackoverflow.com/users/13018",
"pm_score": 4,
"selected": true,
"text": "<p>The predefined mode: <a href=\"http://www.zvon.org/xxl/XSL-Ref/Tutorials/Modes/m4.html\" rel=\"noreferrer\"><code>#all<... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479607",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40347/"
] | Is there a way to write an XSL 1.0 template which is matching in all modes?
Or do I have to write a separate template for every existing mode (including additional templates for modes being added in the future)?
Here is what I have:
```
<xsl:apply-templates mode="mode1" />
...
<xsl:apply-templates mode="mode2" ... | The predefined mode: [`#all`](http://www.zvon.org/xxl/XSL-Ref/Tutorials/Modes/m4.html) (only available in XSLT 2.0 however).
edit: replicating shared mode behaviour with 1.0
```
<xsl:template match="/">
<xsl:variable name="choice" select="'a'"/><!-- input seed here -->
<xsl:choose>
<xsl:when test="$ch... |
479,654 | <p>I need to match up two almost-the-same long freetext strings; i.e., to find index-to-index correspondences wherever possible.</p>
<p>Because this is freetext, the comparison should not be line-based as in code diffing.</p>
<p>Any suggestions for Java libraries?</p>
<p>A simple example (In real life , of course,... | [
{
"answer_id": 479712,
"author": "Joshua Fox",
"author_id": 39242,
"author_profile": "https://Stackoverflow.com/users/39242",
"pm_score": 5,
"selected": true,
"text": "<p>This one might be good <a href=\"https://github.com/google/diff-match-patch\" rel=\"nofollow noreferrer\">Diff Match ... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479654",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39242/"
] | I need to match up two almost-the-same long freetext strings; i.e., to find index-to-index correspondences wherever possible.
Because this is freetext, the comparison should not be line-based as in code diffing.
Any suggestions for Java libraries?
A simple example (In real life , of course, there would not be extra ... | This one might be good [Diff Match Patch](https://github.com/google/diff-match-patch). |
479,658 | <p>I figured the easiest thing to do was to just change the port number that Apache listens to, but I still can't get it to start back up after installing IIS. My IIS currently serves up pages correctly at <a href="http://localhost:80" rel="nofollow noreferrer">http://localhost:80</a>. I have several PHP projects, and ... | [
{
"answer_id": 479691,
"author": "Igal Serban",
"author_id": 25737,
"author_profile": "https://Stackoverflow.com/users/25737",
"pm_score": 0,
"selected": false,
"text": "<ul>\n<li>Stop the iis server and see if apache starts.</li>\n<li><p>In command line, run:</p>\n\n<p>netstat -ano</p><... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479658",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I figured the easiest thing to do was to just change the port number that Apache listens to, but I still can't get it to start back up after installing IIS. My IIS currently serves up pages correctly at <http://localhost:80>. I have several PHP projects, and here are the basics of how ports are configured in my httpd.c... | I did what Haarsma suggested, and it turns out that I had removed a virtual directory, and so Apache couldn't find it (thus not starting). Apparently it had nothing to do with the ports at all, and was my dumb mistake. I reinstalled IIS, changed my config for Apache to listen on port 81, and it works! |
479,678 | <p>I'm using <em>iReport</em> and I need to create a sub-report using a <em>XML DataSource</em>.</p>
<p>I will have only one XML for the hole report. Something like this:</p>
<pre class="lang-xml prettyprint-override"><code><question>
<text>What do you think about SO?</text>
<options>
... | [
{
"answer_id": 479694,
"author": "Peter Severin",
"author_id": 22716,
"author_profile": "https://Stackoverflow.com/users/22716",
"pm_score": 3,
"selected": true,
"text": "<p>Take a look at the <a href=\"http://jasperreports.sourceforge.net/api/net/sf/jasperreports/engine/data/JRXmlDataSo... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479678",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19224/"
] | I'm using *iReport* and I need to create a sub-report using a *XML DataSource*.
I will have only one XML for the hole report. Something like this:
```xml
<question>
<text>What do you think about SO?</text>
<options>
<option>Like it</option>
<option>Really like it</option>
<option>Love it</option>
</... | Take a look at the [JRXmlDataSource JavaDoc](http://jasperreports.sourceforge.net/api/net/sf/jasperreports/engine/data/JRXmlDataSource.html). There are example that show how it's done. |
479,692 | <p>Ok here's a little problem I would love to get some help on.</p>
<p>I have a view and the viewport size will vary based on user screen resolution. The viewport needs to contain N boxes which are lined up next to each other from right to left and take up all of the horizontal space in the viewport. Now if all the bo... | [
{
"answer_id": 479708,
"author": "cletus",
"author_id": 18393,
"author_profile": "https://Stackoverflow.com/users/18393",
"pm_score": 2,
"selected": false,
"text": "<p>This is really a mathematical problem. With two boxes given:</p>\n\n<p>x = size of the first box\nn = number of boxes\n... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479692",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37196/"
] | Ok here's a little problem I would love to get some help on.
I have a view and the viewport size will vary based on user screen resolution. The viewport needs to contain N boxes which are lined up next to each other from right to left and take up all of the horizontal space in the viewport. Now if all the boxes could ... | Using a simple geometric progression, in Python,
```
def box_sizes(width, num_boxes) :
first_box = width / (10 * (1 - 0.9**n))
return [first_box * 0.9**i for i in range(n)]
>>> box_sizes(100, 5)
[24.419428096993972, 21.977485287294574, 19.779736758565118, 17.801763082708607, 16.021586774437747]
>>> sum(_)
100... |
479,697 | <p>I'm working on a SQL Reporting Services report (in VS.Net 2005) which displays a count of different data in a matrix. The columns have a count on the amount of customers in a certain set. So I have several columns like these: "1 employer", "2-9 employers", "10-19 employers" and so on.</p>
<p>The problem I have is t... | [
{
"answer_id": 479828,
"author": "Gambrinus",
"author_id": 42386,
"author_profile": "https://Stackoverflow.com/users/42386",
"pm_score": 1,
"selected": false,
"text": "<p>I had a similar problem but did not find a solution using a matrix in time - so I used a table - and put the needed l... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479697",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/57036/"
] | I'm working on a SQL Reporting Services report (in VS.Net 2005) which displays a count of different data in a matrix. The columns have a count on the amount of customers in a certain set. So I have several columns like these: "1 employer", "2-9 employers", "10-19 employers" and so on.
The problem I have is that SQL Re... | We do a lot of SSRS Reports and this was always an issue with mdx. Here is one way we do it:
Set *Sorting* in the *Grouping and Sorting Properties* to sort by this expression:
```
=iif(Fields!DataSetField.Value = "ColumnName", "zzz", Fields!DataSetField.Value)
```
Where "zzz" could be a number or whatever you need ... |
479,699 | <p>I know there is a way to upload images to the database as image type or varbinary type, however, I searched around the entire week, I am unable to find anything that can help me, so this is really my last resort, if anybody know how to upload images to the database, I am using SQL Server 2005 Express.</p>
<p>Thanks... | [
{
"answer_id": 479745,
"author": "Portman",
"author_id": 1690,
"author_profile": "https://Stackoverflow.com/users/1690",
"pm_score": 0,
"selected": false,
"text": "<p>If you're okay storing the image as a VARCHAR, here is some code to do so. </p>\n\n<pre><code> String b64;\n using ... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479699",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52590/"
] | I know there is a way to upload images to the database as image type or varbinary type, however, I searched around the entire week, I am unable to find anything that can help me, so this is really my last resort, if anybody know how to upload images to the database, I am using SQL Server 2005 Express.
Thanks | You should be able to access the Request's File collection and obtain an HttpPostedFile instance for each uploaded file. Grab the InputStream from the file and read it into the byte array for the column property. I'm assuming this is how your DAL maps the varbinary to your business class -- if not, say it's a native Im... |
479,705 | <p>I'm looking for a way to reinterpret an array of type byte[] as a different type, say short[]. In C++ this would be achieved by a simple cast but in C# I haven't found a way to achieve this without resorting to duplicating the entire buffer.</p>
<p>Any ideas?</p>
| [
{
"answer_id": 479726,
"author": "Hans Passant",
"author_id": 17034,
"author_profile": "https://Stackoverflow.com/users/17034",
"pm_score": 0,
"selected": false,
"text": "<p>Casting like this is fundamentally unsafe and not permitted in a managed language. That's also why C# doesn't sup... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479705",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5776/"
] | I'm looking for a way to reinterpret an array of type byte[] as a different type, say short[]. In C++ this would be achieved by a simple cast but in C# I haven't found a way to achieve this without resorting to duplicating the entire buffer.
Any ideas? | You can achieve this but this is a relatively bad idea. Raw memory access like this is not type-safe and can only be done under a full trust security environment. You should never do this in a properly designed managed application. If your data is masquerading under two different forms, perhaps you actually have two se... |
479,706 | <p>What is the best way to return the whole number part of a decimal (in c#)? (This has to work for very large numbers that may not fit into an int). </p>
<pre><code>GetIntPart(343564564.4342) >> 343564564
GetIntPart(-323489.32) >> -323489
GetIntPart(324) >> 324
</code></pre>
<p>The purpose of this ... | [
{
"answer_id": 479717,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 9,
"selected": true,
"text": "<p>By the way guys, (int)Decimal.MaxValue will overflow. You can't get the \"int\" part of a decimal because the decimal is to... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479706",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51/"
] | What is the best way to return the whole number part of a decimal (in c#)? (This has to work for very large numbers that may not fit into an int).
```
GetIntPart(343564564.4342) >> 343564564
GetIntPart(-323489.32) >> -323489
GetIntPart(324) >> 324
```
The purpose of this is: I am inserting into a decimal (30,4) fie... | By the way guys, (int)Decimal.MaxValue will overflow. You can't get the "int" part of a decimal because the decimal is too friggen big to put in the int box. Just checked... its even too big for a long (Int64).
If you want the bit of a Decimal value to the LEFT of the dot, you need to do this:
```
Math.Truncate(numb... |
479,716 | <p>Basically, I want to do "zipzam&&&?&&&?&&&" -> "zipzam%26%26%26?&&&?&&&". I can do that without regex many different ways, but it'd cleanup things a tad bit if I could do it with regex.</p>
<p>Thanks</p>
<p>Edit: "zip=zam&&&=?&&&... | [
{
"answer_id": 479759,
"author": "Michael Borgwardt",
"author_id": 16883,
"author_profile": "https://Stackoverflow.com/users/16883",
"pm_score": 1,
"selected": false,
"text": "<p>This should do it:</p>\n\n<pre><code>^[^?]*&[^?]*\\?\n</code></pre>\n"
},
{
"answer_id": 479764,
... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479716",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1697/"
] | Basically, I want to do "zipzam&&&?&&&?&&&" -> "zipzam%26%26%26?&&&?&&&". I can do that without regex many different ways, but it'd cleanup things a tad bit if I could do it with regex.
Thanks
Edit: "zip=zam&&&=?&&&?&&&" -> "zip=zam%26%26%26=?&&&?&&&" should make things a little clearer.
Edit: "zip=zam=&=&=&=?&&&?&&... | This should do it:
```
"zip=zam=&=&=&=?&&&?&&&".replace(/^[^?]+/, function(match) { return match.replace(/&/g, "%26"); });
``` |
479,718 | <p>I am using CodeIgniter to pass some parameters to my PHP page through <code>$_POST</code> request, and in the PHP page I am reading. </p>
<pre><code>$foo = $this->input->post('myParam');
</code></pre>
<p>If the <code>myParam</code> parameter is present in the <code>$_POST</code> request, then <code>$foo</cod... | [
{
"answer_id": 479735,
"author": "mozboz",
"author_id": 53691,
"author_profile": "https://Stackoverflow.com/users/53691",
"pm_score": 3,
"selected": true,
"text": "<p>I Googled 'codeigniter input post'.</p>\n\n<p>First result is <a href=\"http://codeigniter.com/user_guide/libraries/input... | 2009/01/26 | [
"https://Stackoverflow.com/questions/479718",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42372/"
] | I am using CodeIgniter to pass some parameters to my PHP page through `$_POST` request, and in the PHP page I am reading.
```
$foo = $this->input->post('myParam');
```
If the `myParam` parameter is present in the `$_POST` request, then `$foo` will be assigned the `myParam` value. How do I check if `myParam` is **no... | I Googled 'codeigniter input post'.
First result is [this](http://codeigniter.com/user_guide/libraries/input.html).
From that document:
>
>
> ```
> $this->input->post('some_data');
>
> ```
>
> The function returns FALSE (boolean) if the item you are attempting to
> retrieve does not exist.
>
>
>
So you need... |