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 |
|---|---|---|---|---|---|---|
301,793 | <p>I am trying to accomplish the following in MySQL (see <code>pseudo</code> code)</p>
<pre><code>SELECT DISTINCT gid
FROM `gd`
WHERE COUNT(*) > 10
ORDER BY lastupdated DESC
</code></pre>
<p>Is there a way to do this without using a (SELECT...) in the WHERE clause because that would seem like a waste of resources.... | [
{
"answer_id": 301804,
"author": "Winston Smith",
"author_id": 35086,
"author_profile": "https://Stackoverflow.com/users/35086",
"pm_score": 5,
"selected": false,
"text": "<pre><code>SELECT COUNT(*)\nFROM `gd`\nGROUP BY gid\nHAVING COUNT(gid) > 10\nORDER BY lastupdated DESC;\n</code><... | 2008/11/19 | [
"https://Stackoverflow.com/questions/301793",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am trying to accomplish the following in MySQL (see `pseudo` code)
```
SELECT DISTINCT gid
FROM `gd`
WHERE COUNT(*) > 10
ORDER BY lastupdated DESC
```
Is there a way to do this without using a (SELECT...) in the WHERE clause because that would seem like a waste of resources. | try this;
```
select gid
from `gd`
group by gid
having count(*) > 10
order by lastupdated desc
``` |
301,809 | <p>There has been a lot of sentiment to include a <code>nameof</code> operator in C#. As an example of how this operator would work, <code>nameof(Customer.Name)</code> would return the string <code>"Name"</code>.</p>
<p>I have a domain object. And I have to bind it. And I need names of properties as strings then. And ... | [
{
"answer_id": 301812,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 2,
"selected": false,
"text": "<p>The workaround is to use an expression tree, and to take that expression tree apart to find the relevant <code>Member... | 2008/11/19 | [
"https://Stackoverflow.com/questions/301809",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38325/"
] | There has been a lot of sentiment to include a `nameof` operator in C#. As an example of how this operator would work, `nameof(Customer.Name)` would return the string `"Name"`.
I have a domain object. And I have to bind it. And I need names of properties as strings then. And I want them to be type-safe.
I remember co... | This code basically does that:
```
class Program
{
static void Main()
{
var propName = Nameof<SampleClass>.Property(e => e.Name);
Console.WriteLine(propName);
}
}
public class Nameof<T>
{
public static string Property<TProp>(Expression<Func<T, TProp>> expression)
{
var bod... |
301,817 | <p>I have some data of the form</p>
<pre><code>Key ID Link
1 MASTER 123
2 AA 123
3 AA 123
4 BB 123
5 MASTER 456
6 CC 456
</code></pre>
<p>I would like to be able to select in the same select all linked items matching the selection criteria, plus the l... | [
{
"answer_id": 301835,
"author": "Gilles",
"author_id": 36141,
"author_profile": "https://Stackoverflow.com/users/36141",
"pm_score": 0,
"selected": false,
"text": "<p>SELECT * FROM table_name WHERE ID=your_id UNION ALL SELECT * FROM table_name WHERE ID='MASTER' AND link = (SELECT link F... | 2008/11/19 | [
"https://Stackoverflow.com/questions/301817",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8163/"
] | I have some data of the form
```
Key ID Link
1 MASTER 123
2 AA 123
3 AA 123
4 BB 123
5 MASTER 456
6 CC 456
```
I would like to be able to select in the same select all linked items matching the selection criteria, plus the linked master. For example,... | Here's one method.
```
SELECT DISTINCT key, id, link
FROM the_table
START WITH id = 'AA'
CONNECT BY id = 'MASTER' and link = PRIOR link and 'AA' = PRIOR ID
``` |
301,844 | <p>I'm currently writing some methods that do some basic operations on form controls eg Textbox, Groupbox, these operations are generic and can be used in any application. </p>
<p>I started to write some unit tests and was just wondering should I use the real form controls found in System.Windows.Forms or should I jus... | [
{
"answer_id": 301883,
"author": "Cristian Diaconescu",
"author_id": 11545,
"author_profile": "https://Stackoverflow.com/users/11545",
"pm_score": 4,
"selected": true,
"text": "<p>If you're trying to unit test the application logic by simulating interaction with the UI controls, you shou... | 2008/11/19 | [
"https://Stackoverflow.com/questions/301844",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6335/"
] | I'm currently writing some methods that do some basic operations on form controls eg Textbox, Groupbox, these operations are generic and can be used in any application.
I started to write some unit tests and was just wondering should I use the real form controls found in System.Windows.Forms or should I just mock up ... | If you're trying to unit test the application logic by simulating interaction with the UI controls, you should do some abstraction using the [MVC pattern](http://en.wikipedia.org/wiki/Model-view-controller). Then you can just have a stub view and call the controller methods from your unit tests.
If it's the actual con... |
301,854 | <p>Am I right to think that there is no way to set the selected value in the C# class SelectList after it is created?
Isn't that a bit silly?</p>
| [
{
"answer_id": 301923,
"author": "Tor Haugen",
"author_id": 32050,
"author_profile": "https://Stackoverflow.com/users/32050",
"pm_score": 0,
"selected": false,
"text": "<p>You mean client-side, in the browser?</p>\n\n<pre><code>var select = document.getElementById('mySelect');\nselect.op... | 2008/11/19 | [
"https://Stackoverflow.com/questions/301854",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11333/"
] | Am I right to think that there is no way to set the selected value in the C# class SelectList after it is created?
Isn't that a bit silly? | I think you are fighting the framework. The data going into your views should be created at the Last Possible Minute (LPM).
Thinking this way, a `SelectList` is a type to feed the `DropDownList` HTML helper. It is NOT a place to store data while you decide how to process it.
A better solution would be to retrieve you... |
301,860 | <p>I need to check whether the user executing the script has administrative privileges on the machine.</p>
<p>I have specified the user executing the script because the script could have been executed with a user other than the logged on using something similar to "Runas".</p>
<p>@Javier: Both solutions work in a PC ... | [
{
"answer_id": 301920,
"author": "Tim C",
"author_id": 7585,
"author_profile": "https://Stackoverflow.com/users/7585",
"pm_score": 3,
"selected": true,
"text": "<p>You can use script if you want to see if the logged on user is an administrator</p>\n\n<pre><code>Set objNetwork = CreateObj... | 2008/11/19 | [
"https://Stackoverflow.com/questions/301860",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14053/"
] | I need to check whether the user executing the script has administrative privileges on the machine.
I have specified the user executing the script because the script could have been executed with a user other than the logged on using something similar to "Runas".
@Javier: Both solutions work in a PC with an English v... | You can use script if you want to see if the logged on user is an administrator
```
Set objNetwork = CreateObject("Wscript.Network")
strComputer = objNetwork.ComputerName
strUser = objNetwork.UserName
isAdministrator = false
Set objGroup = GetObject("WinNT://" & strComputer & "/Administrators")
For Each objUser in o... |
301,865 | <p>So our scenario is this: We have multiple Sharepoint sites that are created dynamically on a "as requested" basis. Basically there's a new site for each new project. Now, for every site we want to add a search clause that says that only contents with a metadata tag value equal to the sitename should be found. Quick ... | [
{
"answer_id": 301920,
"author": "Tim C",
"author_id": 7585,
"author_profile": "https://Stackoverflow.com/users/7585",
"pm_score": 3,
"selected": true,
"text": "<p>You can use script if you want to see if the logged on user is an administrator</p>\n\n<pre><code>Set objNetwork = CreateObj... | 2008/11/19 | [
"https://Stackoverflow.com/questions/301865",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11220/"
] | So our scenario is this: We have multiple Sharepoint sites that are created dynamically on a "as requested" basis. Basically there's a new site for each new project. Now, for every site we want to add a search clause that says that only contents with a metadata tag value equal to the sitename should be found. Quick exa... | You can use script if you want to see if the logged on user is an administrator
```
Set objNetwork = CreateObject("Wscript.Network")
strComputer = objNetwork.ComputerName
strUser = objNetwork.UserName
isAdministrator = false
Set objGroup = GetObject("WinNT://" & strComputer & "/Administrators")
For Each objUser in o... |
301,869 | <p>There seem to be so many color wheel, color picker, and color matcher web apps out there, where you give one color and the they'll find a couple of other colors that will create a harmonic layout when being used in combination. However most of them focus on background colors only and any text printed on each backgro... | [
{
"answer_id": 301902,
"author": "MusiGenesis",
"author_id": 14606,
"author_profile": "https://Stackoverflow.com/users/14606",
"pm_score": 2,
"selected": false,
"text": "<p>This is an interesting question, but I don't think this is actually possible. Whether or not two colors \"fit\" as... | 2008/11/19 | [
"https://Stackoverflow.com/questions/301869",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15809/"
] | There seem to be so many color wheel, color picker, and color matcher web apps out there, where you give one color and the they'll find a couple of other colors that will create a harmonic layout when being used in combination. However most of them focus on background colors only and any text printed on each background... | If you need an algorithm, try this: Convert the color from RGB space to HSV space (Hue, Saturation, Value). If your UI framework can't do it, check this article: <http://en.wikipedia.org/wiki/HSL_and_HSV#Conversion_from_RGB_to_HSL_or_HSV>
Hue is in [0,360). To find the "opposite" color (think colorwheel), just add 180... |
301,882 | <p>Thats what I am using to read e-mail using C#:</p>
<pre><code>outLookApp.NewMailEx += new ApplicationEvents_11_NewMailExEventHandler(outLookApp_NewMailEx);
Outlook.NameSpace olNameSpace = outLookApp.GetNamespace("mapi");
olNameSpace.Logon("xxxx", "xxxxx", false, true);
Outlook.MAPIFolder oInbox = olNa... | [
{
"answer_id": 301904,
"author": "Mat Nadrofsky",
"author_id": 26853,
"author_profile": "https://Stackoverflow.com/users/26853",
"pm_score": 2,
"selected": false,
"text": "<p>You'll likely run into <a href=\"https://stackoverflow.com/questions/235231/how-to-avoid-outlook-security-alert-w... | 2008/11/19 | [
"https://Stackoverflow.com/questions/301882",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Thats what I am using to read e-mail using C#:
```
outLookApp.NewMailEx += new ApplicationEvents_11_NewMailExEventHandler(outLookApp_NewMailEx);
Outlook.NameSpace olNameSpace = outLookApp.GetNamespace("mapi");
olNameSpace.Logon("xxxx", "xxxxx", false, true);
Outlook.MAPIFolder oInbox = olNameSpace.GetDef... | You'll likely run into [this](https://stackoverflow.com/questions/235231/how-to-avoid-outlook-security-alert-when-reading-outlook-message-from-c-program) when Outlook is closed.
Also following [this tutorial](http://www.programminghelp.com/programming/dotnet/access-your-email-within-outlook-pt-1-of-3-c/) will ensure y... |
301,918 | <p>As you can see <a href="https://stackoverflow.com/questions/301854/set-selected-value-in-selectlist-after-instantiation">here</a> and <a href="https://stackoverflow.com/questions/295313/modelbinding-with-selectlist">here</a> I'm not a good friend of asp.net MVC's SelectList.<br>
This time I'm wondering how to count ... | [
{
"answer_id": 301947,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": true,
"text": "<p>Linq has an extension method for <a href=\"http://www.hookedonlinq.com/CountOperator.ashx\" rel=\"nofollow noreferrer\">IEnu... | 2008/11/19 | [
"https://Stackoverflow.com/questions/301918",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11333/"
] | As you can see [here](https://stackoverflow.com/questions/301854/set-selected-value-in-selectlist-after-instantiation) and [here](https://stackoverflow.com/questions/295313/modelbinding-with-selectlist) I'm not a good friend of asp.net MVC's SelectList.
This time I'm wondering how to count the items in it. I want to... | Linq has an extension method for [IEnumerable called Count().](http://www.hookedonlinq.com/CountOperator.ashx) |
301,922 | <p>"Fatal error: Allowed memory size of 31457280 bytes exhausted (tried to allocate 9828 bytes)".</p>
<p>This is the error i get but I am only trying to upload a 1mb image. I have increased the memory limit in php.ini and the execution time. I am trying this on a local MAMP server, on a Mac using firefox. This going t... | [
{
"answer_id": 301929,
"author": "Michael Madsen",
"author_id": 27528,
"author_profile": "https://Stackoverflow.com/users/27528",
"pm_score": 3,
"selected": true,
"text": "<p>You're likely loading the image to do some manipulation of it. That causes the image data to be decompressed, whi... | 2008/11/19 | [
"https://Stackoverflow.com/questions/301922",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31677/"
] | "Fatal error: Allowed memory size of 31457280 bytes exhausted (tried to allocate 9828 bytes)".
This is the error i get but I am only trying to upload a 1mb image. I have increased the memory limit in php.ini and the execution time. I am trying this on a local MAMP server, on a Mac using firefox. This going to be for a... | You're likely loading the image to do some manipulation of it. That causes the image data to be decompressed, which requires a lot of memory for big images (I think it's about 4 bytes per pixel).
You can choose to either not process the image, or do your processing outside of PHP - for example by invoking ImageMagick ... |
301,924 | <p>I'm trying to test the functionality of a web app by scripting a login sequence in Python, but I'm having some troubles.</p>
<p>Here's what I need to do:</p>
<ol>
<li>Do a POST with a few parameters and headers.</li>
<li>Follow a redirect</li>
<li>Retrieve the HTML body.</li>
</ol>
<p>Now, I'm relatively new to p... | [
{
"answer_id": 301953,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>Besides the fact that you may be missing a cookie, there might be some field(s) in the form that you are not POSTing to the... | 2008/11/19 | [
"https://Stackoverflow.com/questions/301924",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18673/"
] | I'm trying to test the functionality of a web app by scripting a login sequence in Python, but I'm having some troubles.
Here's what I need to do:
1. Do a POST with a few parameters and headers.
2. Follow a redirect
3. Retrieve the HTML body.
Now, I'm relatively new to python, but the two things I've tested so far h... | Focus on `urllib2` for this, it works quite well. Don't mess with `httplib`, it's not the top-level API.
What you're noting is that `urllib2` doesn't follow the redirect.
You need to fold in an instance of `HTTPRedirectHandler` that will catch and follow the redirects.
Further, you may want to subclass the default `... |
301,934 | <p>I need to store an array in a custom content type in MOSS. This will always be hidden, only used programmatically. Throughout the lifecycle of the list item, I will be adding values to the array. My array may look like this after a while:</p>
<pre>
value1,1 | value1,2 | value1,3 | value1,4
value2,1 | value2,2 | ... | [
{
"answer_id": 302732,
"author": "Nico",
"author_id": 22970,
"author_profile": "https://Stackoverflow.com/users/22970",
"pm_score": 3,
"selected": true,
"text": "<p>There is no out of the box field in which you can store a 2-dimensional array.<br>\nUsually, you either store each row in a... | 2008/11/19 | [
"https://Stackoverflow.com/questions/301934",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1753/"
] | I need to store an array in a custom content type in MOSS. This will always be hidden, only used programmatically. Throughout the lifecycle of the list item, I will be adding values to the array. My array may look like this after a while:
```
value1,1 | value1,2 | value1,3 | value1,4
value2,1 | value2,2 | value2,3 |
... | There is no out of the box field in which you can store a 2-dimensional array.
Usually, you either store each row in a different item, or you serialize your value in a simpler field (like multiline text). |
301,937 | <p>I have the following table in MySQL (version 5):</p>
<pre><code>id int(10) UNSIGNED No auto_increment
year varchar(4) latin1_swedish_ci No
title varchar(250) latin1_swedish_ci Yes NULL
body text latin1_swedish_ci Yes NULL
</... | [
{
"answer_id": 301944,
"author": "Noah Goodrich",
"author_id": 20178,
"author_profile": "https://Stackoverflow.com/users/20178",
"pm_score": 3,
"selected": false,
"text": "<p>The following should work:</p>\n\n<pre><code>ALTER TABLE tips MODIFY COLUMN year YEAR(4) NOT NULL DEFAULT CURRENT... | 2008/11/19 | [
"https://Stackoverflow.com/questions/301937",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have the following table in MySQL (version 5):
```
id int(10) UNSIGNED No auto_increment
year varchar(4) latin1_swedish_ci No
title varchar(250) latin1_swedish_ci Yes NULL
body text latin1_swedish_ci Yes NULL
```
And I want... | >
> The DEFAULT value clause in a data
> type specification indicates a default
> value for a column. With one
> exception, the default value must be a
> constant; it cannot be a function or
> an expression. This means, for
> example, that you cannot set the
> default for a date column to be the
> value of a f... |
301,959 | <p>I have an abstract base class called Shape from which both Circle and Rectangle are derived, but when I execute the following code in VS 2005 I get the error Debug assertion failed. At the same time I have not overloaded == operator in any class</p>
<p>Expression:Vector iterator not dereferencable, what is the reas... | [
{
"answer_id": 301990,
"author": "David Pierre",
"author_id": 18296,
"author_profile": "https://Stackoverflow.com/users/18296",
"pm_score": 5,
"selected": true,
"text": "<p>Simple :</p>\n\n<ul>\n<li>find fails since your newly created Circle can't be found in the vector with comparing Sh... | 2008/11/19 | [
"https://Stackoverflow.com/questions/301959",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7965/"
] | I have an abstract base class called Shape from which both Circle and Rectangle are derived, but when I execute the following code in VS 2005 I get the error Debug assertion failed. At the same time I have not overloaded == operator in any class
Expression:Vector iterator not dereferencable, what is the reason for thi... | Simple :
* find fails since your newly created Circle can't be found in the vector with comparing Shape \*
* a failed find returns the end iterator which is not deferencable as caught by a Debug assertion
For it to work like you want, you do need to compare Shape, not Shape\*
As pointed out in other answers, [boost:... |
301,965 | <p>This is my first crack at a method that is run periodically during the lifetime of my ASP.NET application to clean up expired sessions stored in my database. It seems to work pretty well, but the software engineer in me doesn't feel "right" about this code. I've been working with LINQ to SQL for a few months now, bu... | [
{
"answer_id": 302014,
"author": "GalacticCowboy",
"author_id": 29638,
"author_profile": "https://Stackoverflow.com/users/29638",
"pm_score": 1,
"selected": false,
"text": "<p>You can have a stored proc as a method on your database context. Why not write one that does what you want and ... | 2008/11/19 | [
"https://Stackoverflow.com/questions/301965",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18505/"
] | This is my first crack at a method that is run periodically during the lifetime of my ASP.NET application to clean up expired sessions stored in my database. It seems to work pretty well, but the software engineer in me doesn't feel "right" about this code. I've been working with LINQ to SQL for a few months now, but I... | This sounds like something you could easily do in a sproc. SQLServer gives you a GETDATE() method that returns the current time... I don't see why you can't just
```
DELETE * FROM tblSignIns
WHERE LastActivityTime < DATEADD("minute", -10, GETDATE());
```
Wouldn't that do the same thing? |
301,983 | <p>I am working on a project that I want to implement AJAX, and I have decided on jQuery as a JavaScript Library. Here is the HTML:</p>
<pre><code><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtm... | [
{
"answer_id": 302000,
"author": "kgiannakakis",
"author_id": 24054,
"author_profile": "https://Stackoverflow.com/users/24054",
"pm_score": 0,
"selected": false,
"text": "<p>Why are you using \"json\" as dataType, while you are returning html? Use \"html\" as dataType and replace msg.d w... | 2008/11/19 | [
"https://Stackoverflow.com/questions/301983",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25515/"
] | I am working on a project that I want to implement AJAX, and I have decided on jQuery as a JavaScript Library. Here is the HTML:
```
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server"... | Use:
```
$("#result").html(msg.d)
``` |
301,989 | <p>I'm writing an MFC App to automatically configure Postgresql with ODBC for use by another app. The idea being that the user runs the app and it automatically creates the database and the tables within it. My problem is that when I set up the File DSN it seems to require the name of the database it will access. This ... | [
{
"answer_id": 301997,
"author": "sgwill",
"author_id": 1204,
"author_profile": "https://Stackoverflow.com/users/1204",
"pm_score": 5,
"selected": true,
"text": "<p>One simple option would be to create a view to render an XML-version of an Excel File. You could either use the new Office ... | 2008/11/19 | [
"https://Stackoverflow.com/questions/301989",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3875/"
] | I'm writing an MFC App to automatically configure Postgresql with ODBC for use by another app. The idea being that the user runs the app and it automatically creates the database and the tables within it. My problem is that when I set up the File DSN it seems to require the name of the database it will access. This app... | One simple option would be to create a view to render an XML-version of an Excel File. You could either use the new Office 2007 version, or the older 2003 version. We chose the 2003 version so that more people could use it, but that's up to you, of course.
[XML 2003 ref on MSDN](http://msdn.microsoft.com/en-us/library... |
301,991 | <p>Inspired by the question <a href="https://stackoverflow.com/questions/301546/whats-the-simplest-way-to-call-http-get-url-using-delphi">What’s the simplest way to call Http GET url using Delphi?</a>
I really would like to see a sample of how to use POST. Preferably to receive XML from the call.</p>
<p>Added: What ab... | [
{
"answer_id": 302061,
"author": "Bruce McGee",
"author_id": 19183,
"author_profile": "https://Stackoverflow.com/users/19183",
"pm_score": 7,
"selected": true,
"text": "<p>Using Indy. Put your parameters in a StringList (name=value) and simply call Post with the URL and StringList.</p>\... | 2008/11/19 | [
"https://Stackoverflow.com/questions/301991",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13219/"
] | Inspired by the question [What’s the simplest way to call Http GET url using Delphi?](https://stackoverflow.com/questions/301546/whats-the-simplest-way-to-call-http-get-url-using-delphi)
I really would like to see a sample of how to use POST. Preferably to receive XML from the call.
Added: What about including an imag... | Using Indy. Put your parameters in a StringList (name=value) and simply call Post with the URL and StringList.
```
function PostExample: string;
var
lHTTP: TIdHTTP;
lParamList: TStringList;
begin
lParamList := TStringList.Create;
lParamList.Add('id=1');
lHTTP := TIdHTTP.Create;
try
Result := lHTTP.Pos... |
301,999 | <p>What's the best way to move a document from one doc library to another? I don't care about version history or preserving CreatedBy and ModifiedBy metadata...</p>
<pre><code>SPList lib1 = (SPDocumentLibrary) web.Lists["lib1"];
SPList lib2 = (SPDocumentLibrary) web.Lists["lib2"];
SPItem item1 = lib1.Items[0];
//inser... | [
{
"answer_id": 302117,
"author": "vitule",
"author_id": 1287,
"author_profile": "https://Stackoverflow.com/users/1287",
"pm_score": 4,
"selected": true,
"text": "<p>Got it:</p>\n\n<pre><code>SPList lib1 = (SPDocumentLibrary) web.Lists[\"lib1\"];\nSPList lib2 = (SPDocumentLibrary) web.Lis... | 2008/11/19 | [
"https://Stackoverflow.com/questions/301999",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1287/"
] | What's the best way to move a document from one doc library to another? I don't care about version history or preserving CreatedBy and ModifiedBy metadata...
```
SPList lib1 = (SPDocumentLibrary) web.Lists["lib1"];
SPList lib2 = (SPDocumentLibrary) web.Lists["lib2"];
SPItem item1 = lib1.Items[0];
//insert code to move... | Got it:
```
SPList lib1 = (SPDocumentLibrary) web.Lists["lib1"];
SPList lib2 = (SPDocumentLibrary) web.Lists["lib2"];
SPListItem item1 = lib1.Items[0];
byte[] fileBytes = item1.File.OpenBinary();
string destUrl = lib2.RootFolder.Url + "/" + item1.File.Name;
SPFile destFile = lib2.RootFolder.Files.Add(destUrl, fileByte... |
302,026 | <p><strong>For a particular segment of Java code, I'd like to measure:</strong></p>
<ul>
<li><strong>Execution time (most likely <em>thread execution time</em>)</strong></li>
<li><strong>Memory usage</strong></li>
<li><strong>CPU load (specifically attributable to the code segment)</strong></li>
</ul>
<p>I'm a relati... | [
{
"answer_id": 302077,
"author": "basszero",
"author_id": 287,
"author_profile": "https://Stackoverflow.com/users/287",
"pm_score": 5,
"selected": true,
"text": "<p>Profiling may be an easier option since you don't require in-production stats. Profiling also doesn't require code modifica... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302026",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5343/"
] | **For a particular segment of Java code, I'd like to measure:**
* **Execution time (most likely *thread execution time*)**
* **Memory usage**
* **CPU load (specifically attributable to the code segment)**
I'm a relative Java novice and am not familiar with how this might be achieved. I've been referred to [JMX](http:... | Profiling may be an easier option since you don't require in-production stats. Profiling also doesn't require code modification. VisualVM (which ships w/ the JDK 1.6.06+) is a simple tool. If you want something more in-depth I'd go with Eclipse TPTP, Netbeans profiler, or JProfiler(pay).
If you want to write you own, ... |
302,037 | <p>I have created a Registry class in .NET which is a singleton. Apparently this singleton behaves as if it were kept in the Cache (the singleton object is available to each session). Is this a good practice of should I add this Singleton to the Cache?
+ do I need to wacth out for concurrency problems with the GetInsta... | [
{
"answer_id": 302053,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 3,
"selected": false,
"text": "<p>Well, your GetInstance method certainly isn't thread-safe - if two threads call it at the same time, they may well en... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302037",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26521/"
] | I have created a Registry class in .NET which is a singleton. Apparently this singleton behaves as if it were kept in the Cache (the singleton object is available to each session). Is this a good practice of should I add this Singleton to the Cache?
+ do I need to wacth out for concurrency problems with the GetInstance... | i would make it like:
private static READONLY ExamDTORegistry instance;
then you dont need to check for NULL and its thread safe. |
302,047 | <p>In VB.NET, what is the difference between <code>And</code> and <code>AndAlso</code>? Which should I use?</p>
| [
{
"answer_id": 302067,
"author": "Nico",
"author_id": 22970,
"author_profile": "https://Stackoverflow.com/users/22970",
"pm_score": 10,
"selected": true,
"text": "<p>The <code>And</code> operator evaluates both sides, where <code>AndAlso</code> evaluates the right side if and only if the... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302047",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34588/"
] | In VB.NET, what is the difference between `And` and `AndAlso`? Which should I use? | The `And` operator evaluates both sides, where `AndAlso` evaluates the right side if and only if the left side is true.
**An example:**
```
If mystring IsNot Nothing And mystring.Contains("Foo") Then
' bla bla
End If
```
**The above throws an exception if `mystring = Nothing`**
```
If mystring IsNot Nothing AndA... |
302,064 | <p>I want to allow only users with a 3G phone to use a particular GPS function. How do I run a check on the device before allowing that feature to be used?</p>
| [
{
"answer_id": 303606,
"author": "wisequark",
"author_id": 33159,
"author_profile": "https://Stackoverflow.com/users/33159",
"pm_score": 2,
"selected": false,
"text": "<p>The following code with allow you to determine the exact device that is in use but I would first consider the fact th... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302064",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38953/"
] | I want to allow only users with a 3G phone to use a particular GPS function. How do I run a check on the device before allowing that feature to be used? | The following code with allow you to determine the exact device that is in use but I would first consider the fact that a 3G device may not actually be able to obtain a GPS lock as the process of doing so is quite slow and requires a more or less clear view of the sky.
For an iPhone 3G the result of this method will b... |
302,082 | <p>I'm using a SqlDataSource to populate my GridView, because the two seem to be so tightly coupled together. Since this grid shows results of a search, I have a dynamic sql string being written in my codebehind that references parameters I pass in, such as below:</p>
<pre><code>sdsResults.SelectParameters.Add("CodeID... | [
{
"answer_id": 302295,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "<p>BTW, my workaround right now lets SqlDataSource pass in the param as an nvarchar. My first line in my SQL then converts tha... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302082",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm using a SqlDataSource to populate my GridView, because the two seem to be so tightly coupled together. Since this grid shows results of a search, I have a dynamic sql string being written in my codebehind that references parameters I pass in, such as below:
```
sdsResults.SelectParameters.Add("CodeID", TypeCode.St... | BTW, my workaround right now lets SqlDataSource pass in the param as an nvarchar. My first line in my SQL then converts that nvarchar param explicitly to a varchar variable, and use that new varchar variable through my script instead.
But that seems silly. |
302,086 | <p>I have a lengthy user-interface operation on my form which is triggered whenever an event is fired. Rather than have the UI block while the operation takes place, I'd like to perform the operation in another thread, and abort that thread and start again if the event fires again.</p>
<p>However, to safely alter con... | [
{
"answer_id": 302106,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 2,
"selected": false,
"text": "<p>First - don't disable the cross-thread checks... forms have thread affinity...</p>\n\n<p>Second - try to avoid abo... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302086",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15371/"
] | I have a lengthy user-interface operation on my form which is triggered whenever an event is fired. Rather than have the UI block while the operation takes place, I'd like to perform the operation in another thread, and abort that thread and start again if the event fires again.
However, to safely alter controls on my... | First - don't disable the cross-thread checks... forms have thread affinity...
Second - try to avoid aborting threads; it isn't nice - you should prefer clean shutdown (such as the cancellation that BackgroundWorker supports)
One option might be to write a wrapper method that:
* accepts a typed delegate (so you can ... |
302,096 | <p>I have a generic method with this (dummy) code (yes I'm aware IList has predicates, but my code is not using IList but some other collection, anyway this is irrelevant for the question...)</p>
<pre class="lang-cs prettyprint-override"><code> static T FindThing<T>(IList collection, int id) where T : IThing, ... | [
{
"answer_id": 302111,
"author": "Ricardo Villamil",
"author_id": 19314,
"author_profile": "https://Stackoverflow.com/users/19314",
"pm_score": 7,
"selected": false,
"text": "<pre><code>return default(T);\n</code></pre>\n"
},
{
"answer_id": 302112,
"author": "Mitchel Sellers"... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302096",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6399/"
] | I have a generic method with this (dummy) code (yes I'm aware IList has predicates, but my code is not using IList but some other collection, anyway this is irrelevant for the question...)
```cs
static T FindThing<T>(IList collection, int id) where T : IThing, new()
{
foreach (T thing in collection)
... | Three options:
* Return `default` (or `default(T)` for older versions of C#) which means you'll return `null` if `T` is a reference type (or a nullable value type), `0` for `int`, `'\0'` for `char`, etc. ([Default values table (C# Reference)](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/... |
302,122 | <p>With jQuery, how do I find out which key was pressed when I bind to the keypress event?</p>
<pre><code>$('#searchbox input').bind('keypress', function(e) {});
</code></pre>
<p>I want to trigger a submit when <kbd>ENTER</kbd> is pressed.</p>
<p><strong>[Update]</strong></p>
<p>Even though I found the (or better: ... | [
{
"answer_id": 302140,
"author": "BlaM",
"author_id": 999,
"author_profile": "https://Stackoverflow.com/users/999",
"pm_score": 3,
"selected": false,
"text": "<p>Okay, I was blind:</p>\n<pre><code>e.which\n</code></pre>\n<p>will contain the ASCII code of the key.</p>\n<p>See <a href=\"ht... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302122",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/999/"
] | With jQuery, how do I find out which key was pressed when I bind to the keypress event?
```
$('#searchbox input').bind('keypress', function(e) {});
```
I want to trigger a submit when `ENTER` is pressed.
**[Update]**
Even though I found the (or better: one) answer myself, there seems to be some room for variation ... | Actually this is better:
```
var code = e.keyCode || e.which;
if(code == 13) { //Enter keycode
//Do something
}
``` |
302,131 | <p>I'm writing a CLR stored procedure to take XML data in the form of a string, then use the data to execute certain commands etc. </p>
<p>The problem that I'm running into is that whenever I try to send XML that is longer than 4000 characters, I get an error, as the XmlDocument object can't load the XML as a lot of t... | [
{
"answer_id": 518476,
"author": "Chris Woodruff",
"author_id": 7001,
"author_profile": "https://Stackoverflow.com/users/7001",
"pm_score": 0,
"selected": false,
"text": "<p>For CLR stored procedures, char, varchar, text, ntext, image, cursor,\nuser-define table types and table cannot be... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302131",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm writing a CLR stored procedure to take XML data in the form of a string, then use the data to execute certain commands etc.
The problem that I'm running into is that whenever I try to send XML that is longer than 4000 characters, I get an error, as the XmlDocument object can't load the XML as a lot of the closing... | I think you want the `System.Data.SqlTypes.SqlXml` type.
For example:
```
using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Xml;
using Microsoft.SqlServer.Server;
public partial class StoredProcedures
{
[SqlProcedure]
public static void StoredProcedure1(Sq... |
302,136 | <p>I'm currently designing a database schema that's used to store recipes. In this database there are different types of entities that I want to be able to tag (ingredients, recipe issuers, recipes, etc). So a tag has multiple n:m relations. If I use the "three table design", this would result in tables (cross table) ... | [
{
"answer_id": 302226,
"author": "Tjofras",
"author_id": 37486,
"author_profile": "https://Stackoverflow.com/users/37486",
"pm_score": 1,
"selected": false,
"text": "<p>I think you're on the right track. You have described it really good, you have a couple of different entities. You coul... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302136",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33110/"
] | I'm currently designing a database schema that's used to store recipes. In this database there are different types of entities that I want to be able to tag (ingredients, recipe issuers, recipes, etc). So a tag has multiple n:m relations. If I use the "three table design", this would result in tables (cross table) for ... | I don't see anything wrong with having a single table for all tag assignments (as opposed to multiple tables - one for each taggable entity).
However, one important detail in your design remains ambiguous to me: if you are going to have something along these lines
```
- - - - - - - - - -
Tag
ID // PK
... |
302,157 | <p>I have a base class vehicle and some children classes like car, motorbike etc.. inheriting from vehicle.
In each children class there is a function Go();
now I want to log information on every vehicle when the function Go() fires, and on that log I want to know which kind of vehicle did it.</p>
<p>Example:</p>
<pr... | [
{
"answer_id": 302172,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 5,
"selected": true,
"text": "<p>Calling <a href=\"http://msdn.microsoft.com/en-us/library/system.object.gettype.aspx\" rel=\"noreferrer\"><code>GetTyp... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302157",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38963/"
] | I have a base class vehicle and some children classes like car, motorbike etc.. inheriting from vehicle.
In each children class there is a function Go();
now I want to log information on every vehicle when the function Go() fires, and on that log I want to know which kind of vehicle did it.
Example:
```
public class ... | Calling [`GetType()`](http://msdn.microsoft.com/en-us/library/system.object.gettype.aspx) from Vehicle.Go() would work - but only if Go() was actually called.
One way of enforcing this is to use the [template method pattern](http://en.wikipedia.org/wiki/Template_method_pattern):
```
public abstract class Vehicle
{
... |
302,166 | <p>I've recently been exposed to the fluent interface in nUnit and I love it; however, I am using msTest. </p>
<p>Does anyone know if there is a fluent interface that is either testing framework agnostic or for msTest? </p>
| [
{
"answer_id": 348640,
"author": "JoshBerke",
"author_id": 26160,
"author_profile": "https://Stackoverflow.com/users/26160",
"pm_score": 1,
"selected": false,
"text": "<p>Based on my research there isn't one, but if your willing to sacrifice the better reportability as far as why an asse... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302166",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26160/"
] | I've recently been exposed to the fluent interface in nUnit and I love it; however, I am using msTest.
Does anyone know if there is a fluent interface that is either testing framework agnostic or for msTest? | See [Fluent Assertions](http://www.fluentassertions.com/). You can do stuff like
```
"ABCDEFGHI".Should().StartWith("AB").And.EndWith("HI").And.Contain("EF").And.HaveLength(9);
new[] { 1, 2, 3 }.Should().HaveCount(4, "because we thought we put three items in the
collection"))
dtoCollection.Should().Contain(dto => d... |
302,171 | <p>I'm compiling library for a private project, which depends on a number of libraries. Specifically one of the dependencies is compiled with Fortran. On some instances, I've seen the dependency compiled with <code>g77</code>, on others I've seen it compiled with <code>gfortran</code>. My project then is <code>./config... | [
{
"answer_id": 302334,
"author": "Andru Luvisi",
"author_id": 5922,
"author_profile": "https://Stackoverflow.com/users/5922",
"pm_score": 1,
"selected": false,
"text": "<p>You might be able to figure it out by using nm, and seeing if the compiled code uses functions from one or the other... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302171",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36145/"
] | I'm compiling library for a private project, which depends on a number of libraries. Specifically one of the dependencies is compiled with Fortran. On some instances, I've seen the dependency compiled with `g77`, on others I've seen it compiled with `gfortran`. My project then is `./configure`'d to link with either `-l... | ```
nm filename | fgrep ' __g77'
```
will give results if g77 was used, meanwhile
```
nm filename | fgrep '@@GFORTRAN'
```
will give results if gfortran is used. |
302,195 | <p>Im trying to extract a line from wget's result but having trouble with it.
This is my wget call:</p>
<pre><code>$ wget -SO- -T 1 -t 1 http://myurl.com:15000/myhtml.html
</code></pre>
<p>Output:</p>
<pre>
--18:24:12-- http://xxx.xxxx.xxxx:15000/myhtml.html
=> `-'
Resolving xxx.xxxx.xxxx... xxx.xxxx.xxx... | [
{
"answer_id": 302213,
"author": "Piotr Lesnicki",
"author_id": 38796,
"author_profile": "https://Stackoverflow.com/users/38796",
"pm_score": 5,
"selected": true,
"text": "<p>The output of wget you are looking for is written on stderr. You must redirect it:</p>\n\n<pre><code>$ wget -SO- ... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302195",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38961/"
] | Im trying to extract a line from wget's result but having trouble with it.
This is my wget call:
```
$ wget -SO- -T 1 -t 1 http://myurl.com:15000/myhtml.html
```
Output:
```
--18:24:12-- http://xxx.xxxx.xxxx:15000/myhtml.html
=> `-'
Resolving xxx.xxxx.xxxx... xxx.xxxx.xxxx
Connecting to xxx.xxxx.xxxx|x... | The output of wget you are looking for is written on stderr. You must redirect it:
```
$ wget -SO- -T 1 -t 1 http://myurl.com:15000/myhtml.html 2>&1 | egrep -i "302"
``` |
302,208 | <p>I've built the x86 Boost libraries many times, but I can't seem to build x64 libraries. I start the "Visual Studio 2005 x64 Cross Tools Command Prompt" and run my usual build:</p>
<pre><code>bjam --toolset=msvc --build-type=complete --build-dir=c:\build install
</code></pre>
<p>But it still produces x86 .lib files... | [
{
"answer_id": 302257,
"author": "macbirdie",
"author_id": 5049,
"author_profile": "https://Stackoverflow.com/users/5049",
"pm_score": 7,
"selected": true,
"text": "<p>You need to add the <code>address-model=64</code> parameter.</p>\n\n<p>Look e.g. <a href=\"http://devsql.blogspot.com/20... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302208",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4086/"
] | I've built the x86 Boost libraries many times, but I can't seem to build x64 libraries. I start the "Visual Studio 2005 x64 Cross Tools Command Prompt" and run my usual build:
```
bjam --toolset=msvc --build-type=complete --build-dir=c:\build install
```
But it still produces x86 .lib files (I verified this with dum... | You need to add the `address-model=64` parameter.
Look e.g. [here](http://devsql.blogspot.com/2007/05/building-boost-134-for-x86-x64-and-ia64.html). |
302,219 | <p>I'm using the following logon trigger on an Oracle 10.2 database:</p>
<pre><code>CREATE OR REPLACE TRIGGER AlterSession_trg
AFTER LOGON ON DATABASE
BEGIN
EXECUTE IMMEDIATE 'ALTER SESSION SET NLS_COMP=LINGUISTIC';
EXECUTE IMMEDIATE 'ALTER SESSION SET NLS_SORT=BINARY_AI';
END AlterSession_trg;
</code></pre>
<p>T... | [
{
"answer_id": 302283,
"author": "Brian Schmitt",
"author_id": 30492,
"author_profile": "https://Stackoverflow.com/users/30492",
"pm_score": 1,
"selected": false,
"text": "<p>I think you should have your DBA make those changes rather than relying on a trigger.\nYou could run into issues ... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302219",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29740/"
] | I'm using the following logon trigger on an Oracle 10.2 database:
```
CREATE OR REPLACE TRIGGER AlterSession_trg
AFTER LOGON ON DATABASE
BEGIN
EXECUTE IMMEDIATE 'ALTER SESSION SET NLS_COMP=LINGUISTIC';
EXECUTE IMMEDIATE 'ALTER SESSION SET NLS_SORT=BINARY_AI';
END AlterSession_trg;
```
This is intended to make ca... | Oracle SQL Developer is changing the NLS parameters based on the preferences. (Tools -> Preferences... -> Database -> NLS Parameters)
Probably your .NET application is also changing the NLS parameters, overwriting your trigger settings.
Have you tried setting `NLS_COMP` and `NLS_SORT` as [environment variables](http:... |
302,234 | <p>In my asp.net mvc page I create a link that renders as followed:</p>
<p><code>http://localhost:3035/Formula/OverView?colorId=349405&paintCode=744&name=BRILLANT%20SILVER&formulaId=570230</code></p>
<p>According to the W3C validator, this is not correct and it errors after the first ampersand. It complai... | [
{
"answer_id": 302253,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 2,
"selected": false,
"text": "<p>Entities which are part of the attributes should be encoded, generally. Thus you need &amp; instead of just &... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302234",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11333/"
] | In my asp.net mvc page I create a link that renders as followed:
`http://localhost:3035/Formula/OverView?colorId=349405&paintCode=744&name=BRILLANT%20SILVER&formulaId=570230`
According to the W3C validator, this is not correct and it errors after the first ampersand. It complains about the & not being encoded and the... | All HTML attributes need to use character entities. You only don't need to change & into & within script blocks.
```
<a href="http://localhost:3035/Formula/OverView?colorId=349405&paintCode=744&name=BRILLANT%20SILVER&formulaId=570230">Whatever</a>
```
Anywhere in an HTML document that you want an & t... |
302,239 | <p>I'm trying to add a publisher policy file to the gac as per this <a href="https://stackoverflow.com/questions/283419/how-to-just-load-the-latest-version-of-dll-from-gac">thread</a> but I'm having problems when I try and add the file on my test server. </p>
<p>I get "A module specified in the manifest of assembly '... | [
{
"answer_id": 302417,
"author": "Kev",
"author_id": 419,
"author_profile": "https://Stackoverflow.com/users/419",
"pm_score": 1,
"selected": false,
"text": "<p>Ok...just want to check some basics....</p>\n\n<p>You definitely have got both versions of the dependent assembly installed to ... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302239",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36852/"
] | I'm trying to add a publisher policy file to the gac as per this [thread](https://stackoverflow.com/questions/283419/how-to-just-load-the-latest-version-of-dll-from-gac) but I'm having problems when I try and add the file on my test server.
I get "A module specified in the manifest of assembly 'policy.3.0.assemblynam... | Wow - ok got it.
I should have paid more attention to exactly what this meant
[(MSDN) How to: Create a Publisher Policy](http://msdn.microsoft.com/en-us/library/dz32563a.aspx)
>
> Important Note: The publisher policy
> assembly cannot be added to the global
> assembly cache unless the original
> publisher polic... |
302,244 | <p>I'm working on a .NET web application and I'm using a CalendarExtender control within it to have the user specify a date. For some reason, when I click the icon to display the calendar, the background seems to be transparent.</p>
<p>I'm using the extender on other pages and do not run into this issue.</p>
<p>I'm n... | [
{
"answer_id": 302265,
"author": "kͩeͣmͮpͥ ͩ",
"author_id": 26479,
"author_profile": "https://Stackoverflow.com/users/26479",
"pm_score": 0,
"selected": false,
"text": "<p>That doesn't look transparent to me, it looks like it's rendering \"behind\" the other elements.\nDo you have a \"z-... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302244",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/71/"
] | I'm working on a .NET web application and I'm using a CalendarExtender control within it to have the user specify a date. For some reason, when I click the icon to display the calendar, the background seems to be transparent.
I'm using the extender on other pages and do not run into this issue.
I'm not sure if it is ... | So some more poking around and I figured out the issue. Part of the problem arises from the fact that the div layout I setup to create two separate columns is using the position:relative and float:right/left attributes.
From what I've read, as soon as you start augmenting the position attribute of a div tag, it affec... |
302,252 | <p>I have a class that looks like this:</p>
<pre><code>public class TextField : TextBox
{
public bool Required { get; set; }
RequiredFieldValidator _validator;
protected override void CreateChildControls()
{
base.CreateChildControls();
_validator = new RequiredFieldValidator();
_valida... | [
{
"answer_id": 302272,
"author": "kͩeͣmͮpͥ ͩ",
"author_id": 26479,
"author_profile": "https://Stackoverflow.com/users/26479",
"pm_score": 0,
"selected": false,
"text": "<p>Validators have to inherit from BaseValidator.</p>\n"
},
{
"answer_id": 302468,
"author": "azamsharp",
... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302252",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3381/"
] | I have a class that looks like this:
```
public class TextField : TextBox
{
public bool Required { get; set; }
RequiredFieldValidator _validator;
protected override void CreateChildControls()
{
base.CreateChildControls();
_validator = new RequiredFieldValidator();
_validator.ControlToVa... | The CreateChildControls is basically for the controls that have childs. RequiredFieldValidator is like a sibling to TextBox.
Here is the code that works for me:
```
public class RequiredTextBox : TextBox
{
private RequiredFieldValidator _req;
private string _errorMessage;
public string ... |
302,271 | <p>I am trying to use the <code>System.Net.Mail.MailMessage</code> class in C# to create an email that is sent to a list of email addresses all via <code>BCC</code>. I do not want to include a <code>TO</code> address, but it seems that I must because I get an exception if I use an empty string for the <code>TO</code> a... | [
{
"answer_id": 302281,
"author": "kͩeͣmͮpͥ ͩ",
"author_id": 26479,
"author_profile": "https://Stackoverflow.com/users/26479",
"pm_score": 2,
"selected": false,
"text": "<p>You have to include a TO address. Just send it to a \"junk\" email address that you don't mind getting mail on.</p>\... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302271",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12081/"
] | I am trying to use the `System.Net.Mail.MailMessage` class in C# to create an email that is sent to a list of email addresses all via `BCC`. I do not want to include a `TO` address, but it seems that I must because I get an exception if I use an empty string for the `TO` address in the `MailMessage` constructor. The er... | I think if you comment out the whole `emailMessage.To.Add(sendTo);` line , it will send the email with `To` field empty. |
302,277 | <p>I was wondering whether the object to test should be a field and thus set up during a <code>SetUp</code> method (ie. JUnit, nUnit, MS Test, …).</p>
<p>Consider the following examples (this is C♯ with MsTest, but the idea should be similar for any other language and testing framework):</p>
<pre><code>public class S... | [
{
"answer_id": 302297,
"author": "kͩeͣmͮpͥ ͩ",
"author_id": 26479,
"author_profile": "https://Stackoverflow.com/users/26479",
"pm_score": 1,
"selected": false,
"text": "<p>The second approach is much more readable, and much easier to visually trace.</p>\n\n<p>However, the first approach ... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302277",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11963/"
] | I was wondering whether the object to test should be a field and thus set up during a `SetUp` method (ie. JUnit, nUnit, MS Test, …).
Consider the following examples (this is C♯ with MsTest, but the idea should be similar for any other language and testing framework):
```
public class SomeStuff
{
public string Val... | It's a slippery slope once you start initializing fields & generally setting up the context of your test *within* the test method itself. This leads to large test methods and really really unmanageable fixtures that don't explain themselves very well.
Instead, you should look at the BDD style naming & test organizatio... |
302,279 | <p>I want to know if I'm missing something.
Here's how I would do it:
For SPFolder I would change the associtaed item's permissions (SPFolder.Item).
So I suppose managing SPFolder permissions boils down to managing SPListItem permissions.
For SPListItem I would frist break role inheritance with <code>SPListItem.BreakRo... | [
{
"answer_id": 302297,
"author": "kͩeͣmͮpͥ ͩ",
"author_id": 26479,
"author_profile": "https://Stackoverflow.com/users/26479",
"pm_score": 1,
"selected": false,
"text": "<p>The second approach is much more readable, and much easier to visually trace.</p>\n\n<p>However, the first approach ... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302279",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/578/"
] | I want to know if I'm missing something.
Here's how I would do it:
For SPFolder I would change the associtaed item's permissions (SPFolder.Item).
So I suppose managing SPFolder permissions boils down to managing SPListItem permissions.
For SPListItem I would frist break role inheritance with `SPListItem.BreakRoleInheri... | It's a slippery slope once you start initializing fields & generally setting up the context of your test *within* the test method itself. This leads to large test methods and really really unmanageable fixtures that don't explain themselves very well.
Instead, you should look at the BDD style naming & test organizatio... |
302,294 | <p>Where does Firefox store cookies and in what format are they stored</p>
| [
{
"answer_id": 302306,
"author": "Thomas Owens",
"author_id": 572,
"author_profile": "https://Stackoverflow.com/users/572",
"pm_score": 0,
"selected": false,
"text": "<p>The directory depends on your OS, but they appear to be stored in a SQLite database.</p>\n"
},
{
"answer_id": ... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302294",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1443363/"
] | Where does Firefox store cookies and in what format are they stored | For Windows
===========
Your cookies are stored in:
* In Firefox 2.x: plain text file (`cookies.txt`) in a unix-format text file (eg LF instead of CRLF for newlines).
* In Firefox 3.0 and up: a binary file representing [**SQLite database** on which you can make queries](http://www.webdevbros.net/2008/07/31/query-your... |
302,310 | <p>What does it mean that a Transaction Log is Full? I have it the file set to grow 20% when needed. I have 4GBs left on the drive. How do I solve this issue permanently?
Running these commands solves the issue temporarily:</p>
<pre>
DBCC SHRINKFILE('MyDatabase_log', 1)
BACKUP LOG MyDatabase WITH TRUNCATE_ONLY
DBCC SH... | [
{
"answer_id": 302337,
"author": "Sean Carpenter",
"author_id": 729,
"author_profile": "https://Stackoverflow.com/users/729",
"pm_score": 2,
"selected": false,
"text": "<p>You should look at <a href=\"http://msdn.microsoft.com/en-us/library/ms366344.aspx\" rel=\"nofollow noreferrer\">SQL... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302310",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36590/"
] | What does it mean that a Transaction Log is Full? I have it the file set to grow 20% when needed. I have 4GBs left on the drive. How do I solve this issue permanently?
Running these commands solves the issue temporarily:
```
DBCC SHRINKFILE('MyDatabase_log', 1)
BACKUP LOG MyDatabase WITH TRUNCATE_ONLY
DBCC SHRINKFILE... | The Transaction Log is where SQL server 'Records' every change it makes so that if something goes wrong, (From software crash to Power failure, to an asteroid strike... well maybe not an an asteroid strike), it can "recover" by "undoing" all the changes it has made, since the last consistent "CheckPoint" - back to what... |
302,312 | <p>I have a tab page that should be hidden if a property (BlahType) is set to 1 and shown if set to 0. This is what I <em>WANT</em> to do:</p>
<pre><code><TabItem Header="Blah">
<TabItem.Triggers>
<DataTrigger Binding="{Binding BlahType}" Value="0">
<Setter Property="TabIte... | [
{
"answer_id": 302350,
"author": "Nir",
"author_id": 3509,
"author_profile": "https://Stackoverflow.com/users/3509",
"pm_score": 0,
"selected": false,
"text": "<p>Well, you can't do that using triggers (not unless you are inside a DataTemplate, ControlTemplate or a Style).</p>\n\n<p>You ... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302312",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11917/"
] | I have a tab page that should be hidden if a property (BlahType) is set to 1 and shown if set to 0. This is what I *WANT* to do:
```
<TabItem Header="Blah">
<TabItem.Triggers>
<DataTrigger Binding="{Binding BlahType}" Value="0">
<Setter Property="TabItem.Visibility" Value="Hidden" />
</... | I believe that the Triggers collection of a control only currently supports EventTriggers. If you would like to use a DataTrigger simply place it inside a style, for your example:
```
<TabItem Header="Blah">
<TabItem.Style>
<Style>
<Style.Triggers>
<DataTrigger Binding="{Binding... |
302,365 | <p>A class has a property (and instance var) of type NSMutableArray with synthesized accessors (via <code>@property</code>). If you observe this array using:</p>
<pre><code>[myObj addObserver:self forKeyPath:@"theArray" options:0 context:NULL];
</code></pre>
<p>And then insert an object in the array like this:</p>
<... | [
{
"answer_id": 302763,
"author": "Ben Gottlieb",
"author_id": 6694,
"author_profile": "https://Stackoverflow.com/users/6694",
"pm_score": 0,
"selected": false,
"text": "<p>You need to wrap your <code>addObject:</code> call in <code>willChangeValueForKey:</code> and <code>didChangeValueFo... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302365",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/79/"
] | A class has a property (and instance var) of type NSMutableArray with synthesized accessors (via `@property`). If you observe this array using:
```
[myObj addObserver:self forKeyPath:@"theArray" options:0 context:NULL];
```
And then insert an object in the array like this:
```
[myObj.theArray addObject:NSString.str... | >
> But shouldn't the synthesized accessors automatically return such a proxy object?
>
>
>
No.
>
> What's the proper way to work around this--should I write a custom accessor that just invokes `[super mutableArrayValueForKey...]`?
>
>
>
No. Implement the [array accessors](https://developer.apple.com/library... |
302,369 | <p>The hover "joke" in #505 <a href="http://en.wikipedia.org/wiki/Xkcd" rel="noreferrer">xkcd</a> touts "I call rule 34 on Wolfram's Rule 34".</p>
<p>I know <a href="http://www.urbandictionary.com/define.php?term=Rule%2034" rel="noreferrer">what rule 34 is in Internet terms</a> and I've googled up <a href="http://en.w... | [
{
"answer_id": 302389,
"author": "Jason Slocomb",
"author_id": 34895,
"author_profile": "https://Stackoverflow.com/users/34895",
"pm_score": 0,
"selected": false,
"text": "<p>Rule 34</p>\n\n<p><a href=\"http://xkcd.com/305/\" rel=\"nofollow noreferrer\">http://xkcd.com/305/</a></p>\n"
... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8724/"
] | The hover "joke" in #505 [xkcd](http://en.wikipedia.org/wiki/Xkcd) touts "I call rule 34 on Wolfram's Rule 34".
I know [what rule 34 is in Internet terms](http://www.urbandictionary.com/define.php?term=Rule%2034) and I've googled up [who Wolfram is](http://en.wikipedia.org/wiki/Stephen_Wolfram) but I'm having a hard t... | Wolfram has organized the 256 possible 1-D cellular automata based on nearest neighbors in this way:
```
RULES:
0: 0 0 0
1: 0 0 1
2: 0 1 0
3: 0 1 1
4: 1 0 0
5: 1 0 1
6: 1 1 ... |
302,371 | <p><strong>Description |</strong> A Java program to read a text file and print each of the unique words in alphabetical order together with the number of times the word occurs in the text. </p>
<p>The program should declare a variable of type <code>Map<String, Integer></code> to store the words and corresponding... | [
{
"answer_id": 302378,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 7,
"selected": true,
"text": "<p><a href=\"http://java.sun.com/javase/6/docs/api/java/util/TreeMap.html\" rel=\"nofollow noreferrer\"><code>TreeMap</co... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302371",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38696/"
] | **Description |** A Java program to read a text file and print each of the unique words in alphabetical order together with the number of times the word occurs in the text.
The program should declare a variable of type `Map<String, Integer>` to store the words and corresponding frequency of occurrence. Which concrete... | [`TreeMap`](http://java.sun.com/javase/6/docs/api/java/util/TreeMap.html) seems a no-brainer to me - simply because of the "in alphabetical order" requirement. `HashMap` has no ordering when you iterate through it; `TreeMap` iterates in the natural key order.
EDIT: I think Konrad's comment may have been suggesting "us... |
302,379 | <p>Okay, this bugged me for several years, now. If you sucked in statistics and higher math at school, turn away, <em>now</em>. Too late.</p>
<p>Okay. Take a deep breath. Here are the rules. Take <em>two</em> thirty sided dice (yes, <a href="http://paizo.com/store/byCompany/k/koplow/dice/d30" rel="nofollow noreferrer"... | [
{
"answer_id": 302455,
"author": "James Curran",
"author_id": 12725,
"author_profile": "https://Stackoverflow.com/users/12725",
"pm_score": 0,
"selected": false,
"text": "<p>Well, let's see. The <em>second</em> throw (which will sometimes be added or subtracted to the first roll) has a ... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302379",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34088/"
] | Okay, this bugged me for several years, now. If you sucked in statistics and higher math at school, turn away, *now*. Too late.
Okay. Take a deep breath. Here are the rules. Take *two* thirty sided dice (yes, [they do exist](http://paizo.com/store/byCompany/k/koplow/dice/d30)) and roll them simultaneously.
* Add the ... | I had to first rewrite your code before I could understand it:
```
def OW60(sign=1):
r1 = random.randint (1, 30)
r2 = random.randint (1, 30)
val = sign * (r1 + r2)
islow = (r1<=5) + (r2<=5)
ishigh = (r1>=26) + (r2>=26)
if islow == 2 or ishigh == 2:
return val + OW60(1)
elif islo... |
302,381 | <p>There's an in-house program we use and it's stored on a UNC share so that updates are transparent. I'd like to supply it some command line parameters like so:</p>
<pre><code>\\server\share\in_house_thingy.exe myusername mypassword
</code></pre>
<p>But I can't seem to get it to work in either CMD or PowerShell or ... | [
{
"answer_id": 302385,
"author": "Josh Kodroff",
"author_id": 549,
"author_profile": "https://Stackoverflow.com/users/549",
"pm_score": 0,
"selected": false,
"text": "<p>I just noticed that there's a .CMD file that's copying the file from the share to the temp directory and running it lo... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302381",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/549/"
] | There's an in-house program we use and it's stored on a UNC share so that updates are transparent. I'd like to supply it some command line parameters like so:
```
\\server\share\in_house_thingy.exe myusername mypassword
```
But I can't seem to get it to work in either CMD or PowerShell or via a shortcut.
Anyone got... | For a shortcut, change the target to be like:
```
"\\server\share\in_house_thingy.exe" myusername mypassword
```
unless you really do want to have to use powershell to make this work. |
302,398 | <p>I'm using Drupal 5 and have a multitude of views that I want to alter the output of. Using the views wizard, I can create a different template for each instance, but I'm wanting to do the same changes across all my views and having 30 files in the themes directory seams like a hell of a lot of maintenance and code.... | [
{
"answer_id": 302678,
"author": "acrosman",
"author_id": 24215,
"author_profile": "https://Stackoverflow.com/users/24215",
"pm_score": 0,
"selected": false,
"text": "<p>I believe that each template will have to be updated independently, if you're talking about something that goes on ins... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302398",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16124/"
] | I'm using Drupal 5 and have a multitude of views that I want to alter the output of. Using the views wizard, I can create a different template for each instance, but I'm wanting to do the same changes across all my views and having 30 files in the themes directory seams like a hell of a lot of maintenance and code. Doe... | I *think* just creating a file named "views-list.tpl.php" will apply to all List-style views (unless a more specific .tpl.php file is present).
Otherwise, there may be a way to get what you want using theme functions. |
302,409 | <p>Delphi strings use single quotes, for example '<code>a valid string</code>'. How does one specify the <code>'</code> character within a literal string? How would one refer to the null byte (Unicode code point <code>U+0000</code>)? </p>
| [
{
"answer_id": 302431,
"author": "Jamie",
"author_id": 922,
"author_profile": "https://Stackoverflow.com/users/922",
"pm_score": 7,
"selected": true,
"text": "<p>To add a single quote to a string, you include two <code>'</code> marks e.g. </p>\n\n<pre><code>str := '''test string''';\nWri... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302409",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2892/"
] | Delphi strings use single quotes, for example '`a valid string`'. How does one specify the `'` character within a literal string? How would one refer to the null byte (Unicode code point `U+0000`)? | To add a single quote to a string, you include two `'` marks e.g.
```
str := '''test string''';
Writeln(str)
```
In the string above, you have the normal single quotation to start a string and then two for the single quote. Same goes for the end of the string.
You can also use `#` followed by a number for other e... |
302,423 | <p>Whenever I write a stored procedure for selecting data based on string variable (varchar, nvarchar, char) I would have something like:</p>
<pre><code>procedure dbo.p_get_user_by_username(
@username nvarchar(256)
as
begin
select
u.username
,u.email
--,etc
from
sampleU... | [
{
"answer_id": 302441,
"author": "bruno conde",
"author_id": 31136,
"author_profile": "https://Stackoverflow.com/users/31136",
"pm_score": 2,
"selected": false,
"text": "<p>With the <a href=\"http://msdn.microsoft.com/en-us/library/ms179859.aspx\" rel=\"nofollow noreferrer\">LIKE</a> key... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302423",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3241/"
] | Whenever I write a stored procedure for selecting data based on string variable (varchar, nvarchar, char) I would have something like:
```
procedure dbo.p_get_user_by_username(
@username nvarchar(256)
as
begin
select
u.username
,u.email
--,etc
from
sampleUserTable u
... | You are correct. There is no benefit in using LIKE unless you are doing wild card matching. In addition, using it without wildcard could lead to the use of an inefficient queryplan. |
302,435 | <p>I'm trying to programmatically set the constructor sting of a COM+ component from a C# application. I found the following sample code online, but it throws an exception:</p>
<pre><code> COMAdminCatalogCollection Components;
COMAdminCatalogClass Catalog = new COMAdminCatalogClass();
string st... | [
{
"answer_id": 302824,
"author": "Brian Sullivan",
"author_id": 767,
"author_profile": "https://Stackoverflow.com/users/767",
"pm_score": 3,
"selected": true,
"text": "<p>I found a way to avoid the exception. Rather than doing this in C#, I can take advantage of VB.NET's optional weak t... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302435",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/767/"
] | I'm trying to programmatically set the constructor sting of a COM+ component from a C# application. I found the following sample code online, but it throws an exception:
```
COMAdminCatalogCollection Components;
COMAdminCatalogClass Catalog = new COMAdminCatalogClass();
string strConstr;
... | I found a way to avoid the exception. Rather than doing this in C#, I can take advantage of VB.NET's optional weak typing to remove all of the casts and a couple of the variable declaration types. The resulting code looks like this:
```
Dim Components As COMAdminCatalogCollection
Dim Catalog As New COMAdminCat... |
302,446 | <p>Suppose one had inherited a complex codebase (in Visual C++, assume 2003 or perhaps later) with a large and complex inheritance graph. Suppose it's deep, and there's lots of virtual functions and possibly even multiple inheritance as well. (Yes, a bit of a maintenance nightmare). Any attempt to refactor this class h... | [
{
"answer_id": 302607,
"author": "kervin",
"author_id": 16549,
"author_profile": "https://Stackoverflow.com/users/16549",
"pm_score": 4,
"selected": false,
"text": "<p>With Visual Studio 2005 there are two undocumented flags that does exactly what you need. They are the <strong>reportAl... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302446",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36978/"
] | Suppose one had inherited a complex codebase (in Visual C++, assume 2003 or perhaps later) with a large and complex inheritance graph. Suppose it's deep, and there's lots of virtual functions and possibly even multiple inheritance as well. (Yes, a bit of a maintenance nightmare). Any attempt to refactor this class hier... | With Visual Studio 2005 there are two undocumented flags that does exactly what you need. They are the **reportAllClassLayout** and **reportSingleClassLayout** flags. For example try "/d1 reportAllClassLayout" on the cl.exe commandline. It will show you the full class layout including virtual tables, here's an [Example... |
302,452 | <p>What's the most efficient way to calculate the last day of the prior quarter?</p>
<p>Example: given the date 11/19/2008, I want to return 9/30/2008.</p>
<p>Platform is SQL Server </p>
| [
{
"answer_id": 302525,
"author": "Bob Probst",
"author_id": 12424,
"author_profile": "https://Stackoverflow.com/users/12424",
"pm_score": 2,
"selected": false,
"text": "<p>I came up with this (tested for all months):</p>\n\n<pre><code>select dateadd(dd,-1,dateadd(qq,datediff(qq,0,'11/19/... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302452",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12424/"
] | What's the most efficient way to calculate the last day of the prior quarter?
Example: given the date 11/19/2008, I want to return 9/30/2008.
Platform is SQL Server | If @Date has the date in question
```
Select DateAdd(day, -1, dateadd(qq, DateDiff(qq, 0, @Date), 0))
```
EDIT: Thanks to @strEagle below, simpler still is:
```
Select dateadd(qq, DateDiff(qq, 0, @Date), -1)
``` |
302,459 | <p>I see the phrase "programming idiom" thrown around as if it is commonly understood. Yet, in search results and stackoverflow I see everything...</p>
<p>From micro:</p>
<ul>
<li>Incrementing a variable</li>
<li>Representing an infinite loop</li>
<li>Swapping variable values</li>
</ul>
<p>To medium:</p>
<ul>
<li><... | [
{
"answer_id": 302471,
"author": "Sam Hasler",
"author_id": 2541,
"author_profile": "https://Stackoverflow.com/users/2541",
"pm_score": 4,
"selected": false,
"text": "<p>See <a href=\"http://en.wikipedia.org/wiki/Programming_idiom\" rel=\"noreferrer\">http://en.wikipedia.org/wiki/Program... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302459",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7625/"
] | I see the phrase "programming idiom" thrown around as if it is commonly understood. Yet, in search results and stackoverflow I see everything...
From micro:
* Incrementing a variable
* Representing an infinite loop
* Swapping variable values
To medium:
* [PIMPL](http://aszt.inf.elte.hu/~gsd/halado_cpp/ch09s03.html)... | A programming idiom is the usual way to code a task in a specific language. For example a loop is often written like this in C:
```
for (i=0; i<10; i++)
```
PHP will understand a similar construct:
```
for ($i = 1; $i <= 10; $i++)
```
But it is discouraged in PHP for looping over an array. In this case you would ... |
302,476 | <p>C#, .NET 3.5</p>
<p>I am trying to get all of the properties of an object that have BOTH a getter and a setter for the instance. The code I <em>thought</em> should work is </p>
<pre><code>PropertyInfo[] infos = source.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.SetProperty |... | [
{
"answer_id": 302492,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 7,
"selected": true,
"text": "<p>Call <a href=\"http://msdn.microsoft.com/en-us/library/system.reflection.propertyinfo.getgetmethod.aspx\" rel=\"norefe... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302476",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17803/"
] | C#, .NET 3.5
I am trying to get all of the properties of an object that have BOTH a getter and a setter for the instance. The code I *thought* should work is
```
PropertyInfo[] infos = source.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.SetProperty | BindingFlags.GetProperty);
... | Call [`GetGetMethod`](http://msdn.microsoft.com/en-us/library/system.reflection.propertyinfo.getgetmethod.aspx) and [`GetSetMethod`](http://msdn.microsoft.com/en-us/library/system.reflection.propertyinfo.getsetmethod.aspx) on the property - if both results are non-null, you're there :)
(The parameterless versions only... |
302,482 | <p>I need to display a string which has a white space on a asp.net page.</p>
<p>****Here is what I am doing:****</p>
<pre><code>cell = New TableCell
cell.Text = value (lets assume value is <" test with whitespace ">
row.Cells.Add(cell)
</code></pre>
<p><strong>and it gets rendered as</strong> </p>
<pre... | [
{
"answer_id": 302490,
"author": "rp.",
"author_id": 2536,
"author_profile": "https://Stackoverflow.com/users/2536",
"pm_score": 3,
"selected": true,
"text": "<p>HTML strips out all but one space character. You need to use the &NBSP; entity to ensure white space is presented with HTML. U... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302482",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38997/"
] | I need to display a string which has a white space on a asp.net page.
\*\*\*\*Here is what I am doing:\*\*\*\*
```
cell = New TableCell
cell.Text = value (lets assume value is <" test with whitespace ">
row.Cells.Add(cell)
```
**and it gets rendered as**
```
<tr>
<td>" test with whitespace "</td>
</tr>... | HTML strips out all but one space character. You need to use the &NBSP entity to ensure white space is presented with HTML. Use the String class's Replace method (or RegEx) to swap out each space for &NBSP;
<http://en.wikipedia.org/wiki/Non-breaking_space> |
302,486 | <p>I see this from time to time and want to know what it is. I did try google, but its filtering out the characters from the search. I have a few books that don't reference it either. </p>
<p>FWIW, I remember in pascal that is was the assignment operator. </p>
<p>Can anybody point me to the MSDN or similar page?</p>
| [
{
"answer_id": 302506,
"author": "rp.",
"author_id": 2536,
"author_profile": "https://Stackoverflow.com/users/2536",
"pm_score": 2,
"selected": false,
"text": "<p>VB uses that operator for attribute value assignments:</p>\n\n<p><a href=\"http://www.ondotnet.com/pub/a/dotnet/excerpt/vbnut... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302486",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16391/"
] | I see this from time to time and want to know what it is. I did try google, but its filtering out the characters from the search. I have a few books that don't reference it either.
FWIW, I remember in pascal that is was the assignment operator.
Can anybody point me to the MSDN or similar page? | You can use the := syntax to assign the parameters to a Sub or Function by name, rather than strictly by position. For example:
```
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TestRoutine(Y:="TestString", X:=12)
End Sub
... |
302,488 | <p>In my WCF service, I have methods that are currently public, but I want to hide them from the outside world but be able to use them in my WCF service.</p>
<p>Is internal what I'm looking at?</p>
| [
{
"answer_id": 302506,
"author": "rp.",
"author_id": 2536,
"author_profile": "https://Stackoverflow.com/users/2536",
"pm_score": 2,
"selected": false,
"text": "<p>VB uses that operator for attribute value assignments:</p>\n\n<p><a href=\"http://www.ondotnet.com/pub/a/dotnet/excerpt/vbnut... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302488",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39677/"
] | In my WCF service, I have methods that are currently public, but I want to hide them from the outside world but be able to use them in my WCF service.
Is internal what I'm looking at? | You can use the := syntax to assign the parameters to a Sub or Function by name, rather than strictly by position. For example:
```
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TestRoutine(Y:="TestString", X:=12)
End Sub
... |
302,496 | <p>This is a followup to <a href="https://stackoverflow.com/questions/284428/avoiding-property-itis-ie-overuse-of-properties-when-are-they-appropriate">Avoiding @property-itis</a>.</p>
<p>UIWebView has the following property declarations:</p>
<pre><code>@property(nonatomic,readonly,getter=canGoBack) BOOL canGoBack;
@... | [
{
"answer_id": 302556,
"author": "Marc Charbonneau",
"author_id": 35136,
"author_profile": "https://Stackoverflow.com/users/35136",
"pm_score": 1,
"selected": false,
"text": "<p>My best guess is that UIResponder is meant to match NSResponder, which of course was designed before Objective... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302496",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | This is a followup to [Avoiding @property-itis](https://stackoverflow.com/questions/284428/avoiding-property-itis-ie-overuse-of-properties-when-are-they-appropriate).
UIWebView has the following property declarations:
```
@property(nonatomic,readonly,getter=canGoBack) BOOL canGoBack;
@property(nonatomic,readonly,gett... | My best guess is that UIResponder is meant to match NSResponder, which of course was designed before Objective-C 2.0 introduced properties. Why UIWebView doesn't do the same with regard to WebView, I don't know. I'd expect properties in Cocoa to be a little schizophrenic in this way for some time, and I wouldn't think ... |
302,507 | <p>I'm using ActiveState Perl on Windows Server 2003. </p>
<p>I want to create a directory on a Windows NTFS partition and then grant a Windows NT security group read access to the folder. Is this possible in Perl? Would I have to use Windows NT commands or is there a Perl module to do it?</p>
<p>A small example woul... | [
{
"answer_id": 302565,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 3,
"selected": false,
"text": "<p><a href=\"http://www.roth.net/perl/perms/\" rel=\"noreferrer\">Here</a>'s a generic permissions package for Activ... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302507",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38211/"
] | I'm using ActiveState Perl on Windows Server 2003.
I want to create a directory on a Windows NTFS partition and then grant a Windows NT security group read access to the folder. Is this possible in Perl? Would I have to use Windows NT commands or is there a Perl module to do it?
A small example would be much appreci... | The standard way is to use the [Win32::FileSecurity](http://search.cpan.org/perldoc?Win32::FileSecurity) module:
```
use Win32::FileSecurity qw(Set MakeMask);
my $dir = 'c:/newdir';
mkdir $dir or die $!;
Set($dir, { 'Power Users'
=> MakeMask( qw( READ GENERIC_READ GENERIC_EXECUTE ) ) });
```
Note that ... |
302,515 | <p>I was previously getting the next available autonumber used in Access by doing a simple query like so:</p>
<pre><code>SELECT RecordNumber, Info
FROM myTABLE
WHERE 0 = 1
</code></pre>
<p>This way I could create a variable to hold the currentRecord and it will use the same autonumber that Access was going to use w... | [
{
"answer_id": 302534,
"author": "Andrew Bullock",
"author_id": 28543,
"author_profile": "https://Stackoverflow.com/users/28543",
"pm_score": 1,
"selected": false,
"text": "<p>SELECT CAST(Scope_Identity() AS INT)</p>\n"
},
{
"answer_id": 302573,
"author": "P Daddy",
"auth... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302515",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38678/"
] | I was previously getting the next available autonumber used in Access by doing a simple query like so:
```
SELECT RecordNumber, Info
FROM myTABLE
WHERE 0 = 1
```
This way I could create a variable to hold the currentRecord and it will use the same autonumber that Access was going to use when I was updating the row... | `IDENT_CURRENT('tableName')` (include the single quotes) returns the current value of the identity for the given table. This value should be the last-assigned identity value used in the table. In other words, you will have a row with this identity value already in the table, unless that row has been deleted. The identi... |
302,533 | <p>Would it be benefical to add a generic way to add info to a Throwable without creating a new Throwable?</p>
<p>I often see code like this:</p>
<pre><code>try {
foo();
} catch (Exception e) {
throw new Exception(e.getMessage() + " extra info=" + blah, e);
}
</code></pre>
<p>Would it be better to instead ad... | [
{
"answer_id": 302555,
"author": "Avi",
"author_id": 1605,
"author_profile": "https://Stackoverflow.com/users/1605",
"pm_score": 0,
"selected": false,
"text": "<p>In general, I think that it is better to use the standard idioms in cases like this. In this case, the standard idiom is to w... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302533",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6770/"
] | Would it be benefical to add a generic way to add info to a Throwable without creating a new Throwable?
I often see code like this:
```
try {
foo();
} catch (Exception e) {
throw new Exception(e.getMessage() + " extra info=" + blah, e);
}
```
Would it be better to instead add `Throwable.setProperty(String k... | Chained exceptions already take care of removing redundant stack frames. That is, you'll only see a given stack frame listed once. It's a matter of opinion, but I'd consider lack of a chained exception a drawback.
Discouraging extension of `RuntimeException` would be good. This might help in that regard.
Intervening ... |
302,544 | <p>I would like to use <code>ON DUPLICATE KEY UPDATE</code> in Zend Framework 1.5, is this possible?</p>
<p>Example</p>
<pre><code>INSERT INTO sometable (...)
VALUES (...)
ON DUPLICATE KEY UPDATE ...
</code></pre>
| [
{
"answer_id": 302757,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "https://Stackoverflow.com/users/20860",
"pm_score": 7,
"selected": true,
"text": "<p>I worked for Zend and specifically worked on Zend_Db quite a bit.</p>\n\n<p>No, there is no API support for the <cod... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302544",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37019/"
] | I would like to use `ON DUPLICATE KEY UPDATE` in Zend Framework 1.5, is this possible?
Example
```
INSERT INTO sometable (...)
VALUES (...)
ON DUPLICATE KEY UPDATE ...
``` | I worked for Zend and specifically worked on Zend\_Db quite a bit.
No, there is no API support for the `ON DUPLICATE KEY UPDATE` syntax. For this case, you must simply use `query()` and form the complete SQL statement yourself.
I do not recommend interpolating values into the SQL as harvejs shows. Use query parameter... |
302,559 | <p>Given the following sample array, how can I find all permutations of times available such that the amountNeeded is satisfied? In others words the follow array should produce the following:</p>
<blockquote>
<p>Available on 2008-05-14 from 08:00 to 08:10 using resource 10 and 13</p>
<p>Available on 2008-05-14... | [
{
"answer_id": 303281,
"author": "matt_dev",
"author_id": 39086,
"author_profile": "https://Stackoverflow.com/users/39086",
"pm_score": 0,
"selected": false,
"text": "<p>Not completely sure about this...</p>\n\n<p>But I think when you use conditional breakpoints in Visual Studio, you can... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302559",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/68043/"
] | Given the following sample array, how can I find all permutations of times available such that the amountNeeded is satisfied? In others words the follow array should produce the following:
>
> Available on 2008-05-14 from 08:00 to 08:10 using resource 10 and 13
>
>
> Available on 2008-05-14 from 08:10 to 08:20 usin... | `System.Diagnostics.Debugger.Break()`
"If no debugger is attached, users are asked if they want to attach a debugger. If yes, the debugger is started. If a debugger is attached, the debugger is signaled with a user breakpoint event, and the debugger suspends execution of the process just as if a debugger breakpoint ha... |
302,569 | <p>The monthRegex regular expression always returns true, even if dateInput is something like "December 1, 2008" by my thoughts it should match a regular expression by whichever key I pass into it. But that isn't what happens, it just returns true, and detects "JAN" as the month.</p>
<pre><code> function dateForma... | [
{
"answer_id": 302735,
"author": "PhiLho",
"author_id": 15459,
"author_profile": "https://Stackoverflow.com/users/15459",
"pm_score": 2,
"selected": false,
"text": "<p>First remark: don't use Array as associative array! Use Object instead. Or use the Array in the reverse way.</p>\n\n<p>S... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302569",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18149/"
] | The monthRegex regular expression always returns true, even if dateInput is something like "December 1, 2008" by my thoughts it should match a regular expression by whichever key I pass into it. But that isn't what happens, it just returns true, and detects "JAN" as the month.
```
function dateFormat(dateInput) {
... | Remove the "monthRegex.compile();" line and it works.
This is because monthRegex.compile(); complies "" as a regex and therefore everything matches it. |
302,577 | <p>If it's harder to explain using words, let's look at an example
I have a generic function like this</p>
<pre><code>void FunctionA<T>() where T : Form, new()
{
}
</code></pre>
<p>If I have a reflected type, how do I use it with the above function? I'm looking forward to do this</p>
<pre><code>Type a = Type.G... | [
{
"answer_id": 302598,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 5,
"selected": true,
"text": "<p><s>You can't. Generics in .NET must be resolved at compile time. You're trying to do something that would resolve them at ... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302577",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20007/"
] | If it's harder to explain using words, let's look at an example
I have a generic function like this
```
void FunctionA<T>() where T : Form, new()
{
}
```
If I have a reflected type, how do I use it with the above function? I'm looking forward to do this
```
Type a = Type.GetType("System.Windows.Forms.Form");
Functi... | ~~You can't. Generics in .NET must be resolved at compile time. You're trying to do something that would resolve them at runtime.~~
The only thing you can do is to provide an overload for FunctionA that takes a type object.
---
Hmmm... the commenter is right.
```
class Program
{
static void Main(string[] args)... |
302,597 | <p>How do I calculate the last business day of month in VBScript? It is for a Reporting Services report.</p>
<p>Thanks</p>
| [
{
"answer_id": 302642,
"author": "P Daddy",
"author_id": 36388,
"author_profile": "https://Stackoverflow.com/users/36388",
"pm_score": 0,
"selected": false,
"text": "<p>If you mean the last <strong>week</strong> day of the month (M-F), then try:</p>\n\n<pre><code>Dim d\n\nd = DateAdd(\"m... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302597",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How do I calculate the last business day of month in VBScript? It is for a Reporting Services report.
Thanks | How about:
```
intMonth=11
'Use zero to return last day of previous month '
LastDayOfMonth= dateserial(2008,intMonth+1,0)
'Saturday '
If WeekDay(LastDayOfMonth,1)=7 Then LastDayOfMonth=LastDayOfMonth-1
'Sunday '
If WeekDay(LastDayOfMonth,1)=1 Then LastDayOfMonth=LastDayOfMonth-2
Msgbox LastDayOfMonth & " " & Weekda... |
302,606 | <p>I have a "fat" GUI that it getting fairly complex, and I would like to add links from a place to an other, and add back/forward buttons to ease navigation. It seems to me that this would be easier if my application was addressable: each composite could have its URI, and links would use that URI.</p>
<p>Are there de... | [
{
"answer_id": 302634,
"author": "AdamC",
"author_id": 16476,
"author_profile": "https://Stackoverflow.com/users/16476",
"pm_score": 1,
"selected": false,
"text": "<p>My solution for doing things like this usually involves the <a href=\"http://en.wikipedia.org/wiki/Observer_pattern\" rel... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302606",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9843/"
] | I have a "fat" GUI that it getting fairly complex, and I would like to add links from a place to an other, and add back/forward buttons to ease navigation. It seems to me that this would be easier if my application was addressable: each composite could have its URI, and links would use that URI.
Are there design patte... | In Swing, you might use a [CardLayout](http://java.sun.com/javase/6/docs/api/java/awt/CardLayout.html). You can have each "page" be a card, and the name of the card (chosen when adding cards to the layout) would be equivalent to the URI you want.
Example:
```
String PAGE_1_KEY = "page 1";
String PAGE_2_KEY = "page 2"... |
302,609 | <p>I'd like to write a batch file that checks to see if a process is running, and takes one action if it is, and another action if it isn't.</p>
<p>I know I can use tasklist to list all running processes, but is there a simpler way to directly check on a specific process?</p>
<p>It seems like this should work, but it... | [
{
"answer_id": 302624,
"author": "Lou Franco",
"author_id": 3937,
"author_profile": "https://Stackoverflow.com/users/3937",
"pm_score": 2,
"selected": false,
"text": "<p>Some options:</p>\n\n<ul>\n<li>PsList from Microsoft</li>\n</ul>\n\n<p><a href=\"http://www.windowsdevcenter.com/pub/a... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302609",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/672/"
] | I'd like to write a batch file that checks to see if a process is running, and takes one action if it is, and another action if it isn't.
I know I can use tasklist to list all running processes, but is there a simpler way to directly check on a specific process?
It seems like this should work, but it doesn't:
```
ta... | You can use "for /f" construct to analyze program output.
```
set running=0
for /f "usebackq" %%T in (`tasklist /nh /fi "imagename eq firefox.exe"`) do set running=1
```
Also, it's a good idea to stick a
```
setlocal EnableExtensions
```
at the begginning of your script, just in case if the user has it disabled b... |
302,614 | <p>I've seen the following code to enable double buffering on a winform:</p>
<pre><code>// Activates double buffering
this.SetStyle(ControlStyles.DoubleBuffer |
ControlStyles.OptimizedDoubleBuffer |
ControlStyles.UserPaint |
ControlStyles.AllPaintingInWmPaint, true);
this.UpdateStyles();
</code></pre>
<p>Is... | [
{
"answer_id": 302640,
"author": "Judah Gabriel Himango",
"author_id": 536,
"author_profile": "https://Stackoverflow.com/users/536",
"pm_score": 2,
"selected": false,
"text": "<p>Setting a form's DoubleBuffering will set double buffering for that form. It's the same as calling</p>\n\n<pr... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302614",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9382/"
] | I've seen the following code to enable double buffering on a winform:
```
// Activates double buffering
this.SetStyle(ControlStyles.DoubleBuffer |
ControlStyles.OptimizedDoubleBuffer |
ControlStyles.UserPaint |
ControlStyles.AllPaintingInWmPaint, true);
this.UpdateStyles();
```
Is this different in any way... | `Control.DoubleBuffering` performs
```
SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, value);
```
so your code sets `ControlStyles.UserPaint` as well (which probably has no effect at this point). |
302,637 | <p>Working in an AIX environment, I'm issuing the following tar command and receive errors on sockets. </p>
<p>Question 1. How can I avoid the socket errors?</p>
<p>Question 2. Can I rely on the tar file to contain all files excluding the ones in error?</p>
<pre><code> $ tar -cvf /post_patches.tar /xyz
tar: /x... | [
{
"answer_id": 302747,
"author": "ayaz",
"author_id": 23191,
"author_profile": "https://Stackoverflow.com/users/23191",
"pm_score": 0,
"selected": false,
"text": "<p>I don't have AIX at hand to take a look, but the 'tar' on Mac OSX supports the '<strong>--ignore-failed-read</strong>' swi... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302637",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Working in an AIX environment, I'm issuing the following tar command and receive errors on sockets.
Question 1. How can I avoid the socket errors?
Question 2. Can I rely on the tar file to contain all files excluding the ones in error?
```
$ tar -cvf /post_patches.tar /xyz
tar: /xyz/runtime/splSock6511 could ... | 1. You should probably avoid including the absolute path - GNU `tar` does that automatically. It makes it hard to restore onto other machines where the `/xyz` may already exist and perhaps should not be tampered with.
2. You probably should not be writing in the root directory - it is a bad practice to get into.
3. AIX... |
302,650 | <p>in the out of the project template solution (Dynamic Data Web Application), I have the model created and all is good. - Get the list of the tables, and the select edit etc.</p>
<p>But my database has linking tables that just contain forgien keys - so the list template just displays the fk value</p>
<p><img src="h... | [
{
"answer_id": 304931,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": true,
"text": "<p>you can reference the metaModel via the dataContext</p>\n\n<pre><code>MetaModel refMetaModel = MetaModel.GetModel(typeof(you... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302650",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | in the out of the project template solution (Dynamic Data Web Application), I have the model created and all is good. - Get the list of the tables, and the select edit etc.
But my database has linking tables that just contain forgien keys - so the list template just displays the fk value
);
MetaTable refMetaModel;
refMetaModel = refMetaModel.GetTable("yourTableName");
```
PS looked at your code and this works in your sceanrio. You can get the tables from the model then insp... |
302,651 | <p>I like Django, but for a particular application I would like to use only parts of it, but I'm not familiar enough with how Django works on the inside, so maybe someone can point me into the right direction as to what I have to check out.</p>
<p>Specifically, I <i>want to use</i>:</p>
<ul>
<li>The models and databa... | [
{
"answer_id": 302686,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "<p>There are of course other projects out there that specifically implement single parts of django. <a href=\"http://turbogear... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302651",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2077/"
] | I like Django, but for a particular application I would like to use only parts of it, but I'm not familiar enough with how Django works on the inside, so maybe someone can point me into the right direction as to what I have to check out.
Specifically, I *want to use*:
* The models and database abstraction
* The [cach... | I myself use Django for its object/db mapping without using its urlconfigs. Simply create a file called `djangosettings.py` and insert the necessary configuration, for example:
```
DATABASE_ENGINE = 'oracle'
DATABASE_HOST = 'localhost'
DATABASE_NAME = 'ORCL'
DATABASE_USER = 'scott'
DATABASE_PASSWORD = '... |
302,658 | <p>Given a java.util.Date object how do I go about finding what Quarter it's in?</p>
<p>Assuming Q1 = Jan Feb Mar, Q2 = Apr, May, Jun, etc.</p>
| [
{
"answer_id": 302669,
"author": "Bill the Lizard",
"author_id": 1288,
"author_profile": "https://Stackoverflow.com/users/1288",
"pm_score": 7,
"selected": true,
"text": "<p>Since Java 8, the quarter is accessible as a field using classes in the <a href=\"https://docs.oracle.com/javase/8... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302658",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2443/"
] | Given a java.util.Date object how do I go about finding what Quarter it's in?
Assuming Q1 = Jan Feb Mar, Q2 = Apr, May, Jun, etc. | Since Java 8, the quarter is accessible as a field using classes in the [java.time](https://docs.oracle.com/javase/8/docs/api/java/time/package-summary.html) package.
```
import java.time.LocalDate;
import java.time.temporal.IsoFields;
LocalDate myLocal = LocalDate.now();
quarter = myLocal.get(IsoFields.QUARTER_OF_YE... |
302,663 | <p>Is there a difference between <code>Cursor.Current</code> and <code>this.Cursor</code> (where <code>this</code> is a WinForm) in .Net? I've always used <code>this.Cursor</code> and have had very good luck with it but I've recently started using CodeRush and just embedded some code in a "Wait Cursor" block and CodeRu... | [
{
"answer_id": 302672,
"author": "James Curran",
"author_id": 12725,
"author_profile": "https://Stackoverflow.com/users/12725",
"pm_score": 4,
"selected": false,
"text": "<p>I believe that Cursor.Current is the mouse cursor currently being used (regardless of where it is on the screen), ... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302663",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16419/"
] | Is there a difference between `Cursor.Current` and `this.Cursor` (where `this` is a WinForm) in .Net? I've always used `this.Cursor` and have had very good luck with it but I've recently started using CodeRush and just embedded some code in a "Wait Cursor" block and CodeRush used the `Cursor.Current` property. I've see... | Windows sends the window that contains the mouse cursor the WM\_SETCURSOR message, giving it an opportunity to change the cursor shape. A control like TextBox takes advantage of that, changing the cursor into a I-bar. The Control.Cursor property determines what shape will be used.
The Cursor.Current property changes t... |
302,664 | <p>I have a sqlite3 table that I'm trying to map to an object in objective-C. One attribute of the table is 'completed_at' which is stored as a DATETIME.</p>
<p>I want to create a property on my objective-C class (which inherits from NSObject) that will map well to the 'completed_at' attribute.</p>
<p>Objective-C has... | [
{
"answer_id": 302804,
"author": "converter42",
"author_id": 28974,
"author_profile": "https://Stackoverflow.com/users/28974",
"pm_score": 2,
"selected": false,
"text": "<p>I have zero experience with Objective-C, but I found Apple's <a href=\"http://developer.apple.com/documentation/Coc... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302664",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2476/"
] | I have a sqlite3 table that I'm trying to map to an object in objective-C. One attribute of the table is 'completed\_at' which is stored as a DATETIME.
I want to create a property on my objective-C class (which inherits from NSObject) that will map well to the 'completed\_at' attribute.
Objective-C has an NSDate type... | I am sharing here just the core things regarding date formatting for saving and retrieving the data for presentation. If you have any problem with this code snippet then I will share the full code that I used for my project.
When you save your data, bind your date value in the sql statement like this way:
```
NS... |
302,679 | <p>I am trying to run my Django sites with mod_wsgi instead of mod_python (RHEL 5). I tried this with all my sites, but get the same problem. I configured it the standard way everyone recommends, but requests to the site simply time out.</p>
<p>Apache conf:</p>
<pre><code><VirtualHost 74.54.144.34>
Document... | [
{
"answer_id": 302858,
"author": "Vladimir Prudnikov",
"author_id": 29364,
"author_profile": "https://Stackoverflow.com/users/29364",
"pm_score": 1,
"selected": false,
"text": "<p><a href=\"http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango\" rel=\"nofollow noreferrer\">Here</a>... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302679",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10751/"
] | I am trying to run my Django sites with mod\_wsgi instead of mod\_python (RHEL 5). I tried this with all my sites, but get the same problem. I configured it the standard way everyone recommends, but requests to the site simply time out.
Apache conf:
```
<VirtualHost 74.54.144.34>
DocumentRoot /wwwclients/thymeand... | The problem is that mod\_python doesn't go well together with mod\_wsgi. I got into similar issue few weeks ago and everything started working for me shortly after I commented out mod\_python inclusion.
Try to search [modwsgi.org](http://modwsgi.org) wiki for "mod\_python", I believe there was someone talking about th... |
302,680 | <p>I'm looking to have a simple custom dialog box, like a message box, that has a label and a TextBox. If there's a simple way to do this, sorry! I'm really not well versed in the dialog stuff. </p>
<p>Thanks for any help, guys!</p>
| [
{
"answer_id": 302828,
"author": "MusiGenesis",
"author_id": 14606,
"author_profile": "https://Stackoverflow.com/users/14606",
"pm_score": 0,
"selected": false,
"text": "<p>I'm assuming you basically want a custom dialog box that returns a string entered by the user. One way is to add a... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302680",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39024/"
] | I'm looking to have a simple custom dialog box, like a message box, that has a label and a TextBox. If there's a simple way to do this, sorry! I'm really not well versed in the dialog stuff.
Thanks for any help, guys! | Here is how to make a small custom dialog box in Windows Mobile that looks like this:
[alt text http://www.freeimagehosting.net/uploads/b8fb5421d6.jpg](http://www.freeimagehosting.net/uploads/b8fb5421d6.jpg)
Add a form to your project, and set its FormBorderStyle property to None. This allows the form to be resized a... |
302,692 | <p>I'm having a weird problem, where tagging <strong>works fine on my development machine</strong>, but when I deploy to the production server, I get this error in the log:</p>
<pre><code>ActionView::TemplateError (undefined method `tags' for #<Person:0x98bb9d4>) on line...
</code></pre>
<p>There is an entry ... | [
{
"answer_id": 302702,
"author": "Cade Roux",
"author_id": 18255,
"author_profile": "https://Stackoverflow.com/users/18255",
"pm_score": 3,
"selected": true,
"text": "<p><a href=\"http://msdn.microsoft.com/en-us/library/ms179877.aspx\" rel=\"nofollow noreferrer\"><code>sp_attach_db</code... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302692",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/722/"
] | I'm having a weird problem, where tagging **works fine on my development machine**, but when I deploy to the production server, I get this error in the log:
```
ActionView::TemplateError (undefined method `tags' for #<Person:0x98bb9d4>) on line...
```
There is an entry in the production.log file that states that h... | [`sp_attach_db`](http://msdn.microsoft.com/en-us/library/ms179877.aspx) (or CREATE DATABASE FOR ATTACH) - don't forget to bring the LDF (log) files, too. |
302,700 | <p>So, up until today, when I tried to edit a read only file in VS2008, a dialog popped up giving me three options:</p>
<ul>
<li>Edit in memory</li>
<li>Make writable</li>
<li>Save a copy</li>
</ul>
<p>There was also a checkbox which read "Never allow in memory edits".</p>
<p>Suddenly, it has stopped offering these ... | [
{
"answer_id": 303349,
"author": "Kent Fredric",
"author_id": 15614,
"author_profile": "https://Stackoverflow.com/users/15614",
"pm_score": -1,
"selected": false,
"text": "<p>Actually, the most logical thing to do is this: </p>\n\n<ol>\n<li>If A file is not intended to be edited, mark it... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302700",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35086/"
] | So, up until today, when I tried to edit a read only file in VS2008, a dialog popped up giving me three options:
* Edit in memory
* Make writable
* Save a copy
There was also a checkbox which read "Never allow in memory edits".
Suddenly, it has stopped offering these options and simply will not accept any input in t... | In case anyone is interested, resetting the following registry entry to 0 will restore the previous behaviour:
```
HKCU\Sofware\Microsoft\Visual Studio\9.0\Source Control\UncontrolledInMemoryEditDialogSuppressed
``` |
302,701 | <p>What is the difference between </p>
<pre><code>if(null==object)
</code></pre>
<p>and </p>
<pre><code>if(object==null)
</code></pre>
<p>Please give the advantage for using the above.</p>
| [
{
"answer_id": 302707,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 4,
"selected": false,
"text": "<p>The difference comes if you accidentally type <code>=</code> instead of <code>==</code>:</p>\n\n<p><code>if (null = object... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302701",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | What is the difference between
```
if(null==object)
```
and
```
if(object==null)
```
Please give the advantage for using the above. | The difference comes if you accidentally type `=` instead of `==`:
`if (null = object)` - Compiler error
`if (object = null)` - Bug! |
302,718 | <p>I have the following string in the smarty (php templating system) variable $test:</p>
<pre><code><img height="113" width="150" alt="Sunset" src="/test.jpg"/>
</code></pre>
<p>I want to add "em" to the height and width like this:</p>
<pre><code>{$test|replace:'" w':'em" w'|replace:'" a':'em" a'}
</code></pre... | [
{
"answer_id": 302798,
"author": "Adam",
"author_id": 13320,
"author_profile": "https://Stackoverflow.com/users/13320",
"pm_score": 3,
"selected": true,
"text": "<p>my regex isn't the greatest, or i'd give you a better matcher, but maybe using what you have through the regex replace woul... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302718",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13262/"
] | I have the following string in the smarty (php templating system) variable $test:
```
<img height="113" width="150" alt="Sunset" src="/test.jpg"/>
```
I want to add "em" to the height and width like this:
```
{$test|replace:'" w':'em" w'|replace:'" a':'em" a'}
```
But this doesn't work... What's the problem and t... | my regex isn't the greatest, or i'd give you a better matcher, but maybe using what you have through the regex replace would work.
```
{$test|regex_replace:'/".w/':'em" w'|regex_replace:'/".a/':'em" a'}
```
other matchers to try
```
'/\".w/'
'/".*w/'
'/\".*w/'
```
i can't play with my smarty sites at the moment, ... |
302,720 | <p>I have a parent object which has a one to many relationship with an IList of child objects. What is the best way to delete the child objects? I am not deleting the parent. My parent object contains an IList of child objects. Here is the mapping for the one to many relationship:</p>
<pre><code><bag name="Tiers" c... | [
{
"answer_id": 302746,
"author": "Kyle West",
"author_id": 34133,
"author_profile": "https://Stackoverflow.com/users/34133",
"pm_score": -1,
"selected": false,
"text": "<p>set Not-Null = true in your mapping on the column causing the issue. I'm not sure of the exact syntax though (sorry)... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302720",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1284/"
] | I have a parent object which has a one to many relationship with an IList of child objects. What is the best way to delete the child objects? I am not deleting the parent. My parent object contains an IList of child objects. Here is the mapping for the one to many relationship:
```
<bag name="Tiers" cascade="all">
<... | You are getting the first error because, when you remove the items from the collection, NHibernate's default mode of operation is to simply break the association. In the database, NHibernate tries to set the foreign key column on the child row to null. Since you do not allow nulls in that column, SQL Server raises the ... |
302,736 | <p>What are some guidelines for when it is <strong>not</strong> necessary to check for a null?</p>
<p>A lot of the inherited code I've been working on as of late has null-checks ad nauseam. Null checks on trivial functions, null checks on API calls that state non-null returns, etc. In some cases, the null-checks are r... | [
{
"answer_id": 302762,
"author": "MetroidFan2002",
"author_id": 8026,
"author_profile": "https://Stackoverflow.com/users/8026",
"pm_score": 3,
"selected": false,
"text": "<p>If you write the code and its contract, you are responsible for using it in terms of its contract and ensuring the... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302736",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17871/"
] | What are some guidelines for when it is **not** necessary to check for a null?
A lot of the inherited code I've been working on as of late has null-checks ad nauseam. Null checks on trivial functions, null checks on API calls that state non-null returns, etc. In some cases, the null-checks are reasonable, but in many ... | First note that this a special case of contract-checking: you're writing code that does nothing other than validate at runtime that a documented contract is met. Failure means that some code somewhere is faulty.
I'm always slightly dubious about implementing special cases of a more generally useful concept. Contract c... |
302,742 | <p>I need to use C++ to read in text with spaces, followed by a numeric value.</p>
<p>For example, data that looks like:</p>
<pre><code>text1
1.0
text two
2.1
text2 again
3.1
</code></pre>
<p>can't be read in with 2 <code>"infile >>"</code> statements. I'm not having any luck with <code>getline</code>
either... | [
{
"answer_id": 302848,
"author": "atzz",
"author_id": 23252,
"author_profile": "https://Stackoverflow.com/users/23252",
"pm_score": 0,
"selected": false,
"text": "<p>If you can be sure that your input is well-formed, you can try something like this sample:</p>\n\n<pre><code>#include <... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302742",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39035/"
] | I need to use C++ to read in text with spaces, followed by a numeric value.
For example, data that looks like:
```
text1
1.0
text two
2.1
text2 again
3.1
```
can't be read in with 2 `"infile >>"` statements. I'm not having any luck with `getline`
either. I ultimately want to populate a `struct` with these 2 data ... | The standard IO library isn't going to do this for you alone, you need some sort of simple parsing of the data to determine where the text ends and the numeric value begins. If you can make some simplifying assumptions (like saying there is exactly one text/number pair per line, and minimal error recovery) it wouldn't ... |
302,749 | <p>I'm having a couple of problems with the JQuery <a href="http://tablesorter.com/docs/" rel="noreferrer">tablesorter</a> plugin. If you click on a column header, it should sort the data by this column, but there are a couple of problems:</p>
<ol>
<li>The rows are not properly sorted (1, 1, 2183, 236)</li>
<li>The to... | [
{
"answer_id": 302795,
"author": "Eric Wendelin",
"author_id": 25066,
"author_profile": "https://Stackoverflow.com/users/25066",
"pm_score": 2,
"selected": false,
"text": "<p>I <em>think</em> the answer to #1 is that you have blank fields for some numerical columns causing the tablesorte... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302749",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2648/"
] | I'm having a couple of problems with the JQuery [tablesorter](http://tablesorter.com/docs/) plugin. If you click on a column header, it should sort the data by this column, but there are a couple of problems:
1. The rows are not properly sorted (1, 1, 2183, 236)
2. The total row is included in the sort
Regarding (2),... | The first problem is due to the fact that the table sorter auto detects the column to a 'text'-column (probably because the empty cells). To solve this use this code to initialize the tablesorter and set all the field to either digit or currency depending on the data:
```
<script type="text/javascript" >
jQuery(docume... |
302,768 | <p>I have the following:</p>
<pre><code>classA::FuncA()
{
... code
FuncB();
... code
}
classA::FuncB(const char *pText)
{
SelectObject(m_hDC, GetStockObject ( SYSTEM_FONT));
wglUseFontBitmaps(m_hDC, 0, 255, 1000);
glListBase(1000);
glCallLists(static_cast<GLsizei>(strlen(pText)), GL_UNS... | [
{
"answer_id": 302801,
"author": "Valentin Galea",
"author_id": 5760,
"author_profile": "https://Stackoverflow.com/users/5760",
"pm_score": 0,
"selected": false,
"text": "<p>If everything fails try updating to VS2005 SP1 if you don't already have it...</p>\n\n<p>Sounds strange indeed!</p... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302768",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18882/"
] | I have the following:
```
classA::FuncA()
{
... code
FuncB();
... code
}
classA::FuncB(const char *pText)
{
SelectObject(m_hDC, GetStockObject ( SYSTEM_FONT));
wglUseFontBitmaps(m_hDC, 0, 255, 1000);
glListBase(1000);
glCallLists(static_cast<GLsizei>(strlen(pText)), GL_UNSIGNED_BYTE, pText); ... | Make sure all compiler optimizations are disabled (/Od). Compiler optimization can cause problems with debugger breakpoints. |
302,775 | <p>I need a way of calling a web page from inside my .net appliction. </p>
<p>But i just want to send a request to the page and not worry about the response. </p>
<p>As there are times when the response can take a while so i dont want it to hang the appliction. </p>
<p>I have been trying in side the page_load event<... | [
{
"answer_id": 302787,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 3,
"selected": false,
"text": "<p>Look at <a href=\"http://msdn.microsoft.com/en-us/library/system.net.webclient.aspx\" rel=\"noreferrer\"><code>Syst... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302775",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27922/"
] | I need a way of calling a web page from inside my .net appliction.
But i just want to send a request to the page and not worry about the response.
As there are times when the response can take a while so i dont want it to hang the appliction.
I have been trying in side the page\_load event
```
WebClient webC = n... | Doak, Was almost there, but each time I put any of the request in a sepreate thread the page still wouldn't render until all the thread had finished running.
The best way I found was adjusting Doak's method, and just sticking a timeout in there and swallowing the error.
I know its a hack but it does work :P
```
Web... |
302,781 | <p>I have transferred a Classic asp site running on windows server 2003 to windows server 2008 but suddenly the below code has stopped working.</p>
<pre><code>Const connStr_FC08 = "Provider=SQLNCLI10;Server=DS-47500;Database=TestDB;Uid=TestLogin;Pwd=test;Network=dbmssocn;"
Function connDB(OpenDB)
DIM conn
SET... | [
{
"answer_id": 302810,
"author": "StingyJack",
"author_id": 16391,
"author_profile": "https://Stackoverflow.com/users/16391",
"pm_score": 0,
"selected": false,
"text": "<p>You have that SQL Provider installed right?</p>\n\n<p>You can put that function into a simple VBScript script to tes... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302781",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have transferred a Classic asp site running on windows server 2003 to windows server 2008 but suddenly the below code has stopped working.
```
Const connStr_FC08 = "Provider=SQLNCLI10;Server=DS-47500;Database=TestDB;Uid=TestLogin;Pwd=test;Network=dbmssocn;"
Function connDB(OpenDB)
DIM conn
SET conn = Server... | I see a few possible syntax issues with the code you posted:
```
...
conn.open = connStr_FC08
...
connDB = conn
...
cn = connDB("Y")
```
Should it be updated to the following?
```
...
conn.ConnectionString = connStr_FC08
...
Set connDB = conn
...
Set cn = connDB("Y")
``` |
302,782 | <p>How can I accomplish this?</p>
<pre><code><% for agent in @broker.agents %>
...
<% if agent.cell %><span class="cell-number">Cell: <%= agent.cell %></span><% end %>
...
<% end %>
</code></pre>
<p>I want to test to see if the agent has a cell number, and if so, displa... | [
{
"answer_id": 302827,
"author": "neezer",
"author_id": 32154,
"author_profile": "https://Stackoverflow.com/users/32154",
"pm_score": 3,
"selected": false,
"text": "<pre><code>if !agent.cell.blank?\n</code></pre>\n\n<p>It works.</p>\n"
},
{
"answer_id": 302868,
"author": "Adr... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302782",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32154/"
] | How can I accomplish this?
```
<% for agent in @broker.agents %>
...
<% if agent.cell %><span class="cell-number">Cell: <%= agent.cell %></span><% end %>
...
<% end %>
```
I want to test to see if the agent has a cell number, and if so, display what's inside the conditional. What I have currently doesn't seem ... | This is what you asked for:
```
<% for agent in @broker.agents %>
<% unless agent.cell.blank? %>
<span class="cell-number">Cell: <%= agent.cell %></span>
<% end %>
<% end %>
```
The cell? method works whether cell is nil or an empty string. Rails adds similar functions for all ActiveRecord attributes. This w... |
302,789 | <p>My rails model has code that is attempting to <code>define_method(method_name)</code> inside the model.</p>
<p>I keep getting:</p>
<pre><code>NoMethodError: undefined method `define_method'
</code></pre>
<p>What am I doing wrong? Am I doing this in the wrong place. I need this method attached to this model. Where... | [
{
"answer_id": 302950,
"author": "Tim Harding",
"author_id": 38021,
"author_profile": "https://Stackoverflow.com/users/38021",
"pm_score": 2,
"selected": false,
"text": "<p>was able to cobble this together. Very little understanding of what's actually going on though.</p>\n\n<p>My instan... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302789",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/757/"
] | My rails model has code that is attempting to `define_method(method_name)` inside the model.
I keep getting:
```
NoMethodError: undefined method `define_method'
```
What am I doing wrong? Am I doing this in the wrong place. I need this method attached to this model. Where else can I define this method?
EDIT:
For t... | There's nothing magical or about a rails model, it's just a normal class with a bunch of pre-existing methods,
So, the question is "can I define\_method in a class"?
### Part 1: Yes you can.
The important distinction is than you can define method *in a class* not *in an instance* method
For example:
```
class Cow
... |
302,794 | <p>I'm being asked to look into a problem that occurs intermittently on a WebServer running my team's application.</p>
<p>Essentially, we have a webservice that does a lookup between codes. If you have Code Type A, you can use it to look up the corresponding Code Type B. Periodically, when memory is running low, whe... | [
{
"answer_id": 302950,
"author": "Tim Harding",
"author_id": 38021,
"author_profile": "https://Stackoverflow.com/users/38021",
"pm_score": 2,
"selected": false,
"text": "<p>was able to cobble this together. Very little understanding of what's actually going on though.</p>\n\n<p>My instan... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302794",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26516/"
] | I'm being asked to look into a problem that occurs intermittently on a WebServer running my team's application.
Essentially, we have a webservice that does a lookup between codes. If you have Code Type A, you can use it to look up the corresponding Code Type B. Periodically, when memory is running low, when this webse... | There's nothing magical or about a rails model, it's just a normal class with a bunch of pre-existing methods,
So, the question is "can I define\_method in a class"?
### Part 1: Yes you can.
The important distinction is than you can define method *in a class* not *in an instance* method
For example:
```
class Cow
... |
302,820 | <p>Anyone getting this error when using the new free chart controls MS bought from Dundas?</p>
<p>"Error executing child request for ChartImg.axd"</p>
<p>On the MSDN forum they suggested it was my web.config:
<a href="http://social.msdn.microsoft.com/Forums/en-US/MSWinWebChart/thread/1dc4b352-c9a5-49dc-8f35-9b176509... | [
{
"answer_id": 308090,
"author": "Scott Anderson",
"author_id": 5115,
"author_profile": "https://Stackoverflow.com/users/5115",
"pm_score": 2,
"selected": false,
"text": "<p>I posted a way I fixed this problem on the MSDN forum:</p>\n\n<p>Well I still don't know why I was getting the exc... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302820",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5115/"
] | Anyone getting this error when using the new free chart controls MS bought from Dundas?
"Error executing child request for ChartImg.axd"
On the MSDN forum they suggested it was my web.config:
[MSDN forum post](http://social.msdn.microsoft.com/Forums/en-US/MSWinWebChart/thread/1dc4b352-c9a5-49dc-8f35-9b176509faa1/)
... | I encountered the same problem: the chart would work on one page but not on the next. Turns out if the chart is initialized for the first time in a POST (i.e. a postback) the error is thrown because the handler is configured incorrectly. To fix the issue modify the httpHandler configuration that user LaptopHeaven refer... |
302,821 | <p>I have a simple 2D array of strings and I would like to stuff it into an SPFieldMultiLineText in MOSS. This maps to an ntext database field.</p>
<p>I know I can serialize to XML and store to the file system, but I would like to serialize without touching the filesystem.</p>
<pre><code>public override void ItemAdd... | [
{
"answer_id": 302891,
"author": "Sunny Milenov",
"author_id": 8220,
"author_profile": "https://Stackoverflow.com/users/8220",
"pm_score": 6,
"selected": true,
"text": "<pre><code>StringWriter outStream = new StringWriter();\nXmlSerializer s = new XmlSerializer(typeof(List<List<str... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302821",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1753/"
] | I have a simple 2D array of strings and I would like to stuff it into an SPFieldMultiLineText in MOSS. This maps to an ntext database field.
I know I can serialize to XML and store to the file system, but I would like to serialize without touching the filesystem.
```
public override void ItemAdding(SPItemEventPropert... | ```
StringWriter outStream = new StringWriter();
XmlSerializer s = new XmlSerializer(typeof(List<List<string>>));
s.Serialize(outStream, myObj);
properties.AfterProperties["myNoteField"] = outStream.ToString();
``` |
302,829 | <p>I was trying to access swf from javascript, so this example in livedocs is what I'm trying to modify. <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/external/ExternalInterface.html#includeExamplesSummary" rel="nofollow noreferrer">http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/fl... | [
{
"answer_id": 309138,
"author": "jcoder",
"author_id": 417292,
"author_profile": "https://Stackoverflow.com/users/417292",
"pm_score": 4,
"selected": true,
"text": "<p>The problem is that the SWF file isn't fully loaded by the time you try to call it. The flash player is probably loaded... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302829",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34797/"
] | I was trying to access swf from javascript, so this example in livedocs is what I'm trying to modify. <http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/external/ExternalInterface.html#includeExamplesSummary>
However,it is not working correctly for some reason. The problem I'm encountering
is that it doe... | The problem is that the SWF file isn't fully loaded by the time you try to call it. The flash player is probably loaded but it takes a while to load and initialise the swf file.
What you need to do is make a call from the SWF file to a javascript function when it's loaded and put your javascript there rather than in t... |
302,833 | <p>I want to use a case statement in my user-defined functions because I need to match on a number of terms. I could use a table for the matches but then I wouldn't be able to put it inside the Computed Column definition. </p>
<p>This works with IF statements:</p>
<pre><code>CREATE FUNCTION MaraSizeNumber
(
@ms v... | [
{
"answer_id": 302841,
"author": "ConcernedOfTunbridgeWells",
"author_id": 15401,
"author_profile": "https://Stackoverflow.com/users/15401",
"pm_score": 3,
"selected": true,
"text": "<p>The case statement should look like:</p>\n\n<pre><code>RETURN CASE @ms\n WHEN '16-18' THEN '1'\n... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302833",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26140/"
] | I want to use a case statement in my user-defined functions because I need to match on a number of terms. I could use a table for the matches but then I wouldn't be able to put it inside the Computed Column definition.
This works with IF statements:
```
CREATE FUNCTION MaraSizeNumber
(
@ms varchar
)
RETURNS varc... | The case statement should look like:
```
RETURN CASE @ms
WHEN '16-18' THEN '1'
WHEN '18-20' THEN '2'
WHEN '20-22' THEN '3'
WHEN '22+' THEN '4'
WHEN '24+' THEN '5'
WHEN '14-16' THEN '7'
ELSE 'BAD'
END
``` |