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 |
|---|---|---|---|---|---|---|
260,236 | <p>I know that php has md5(), sha1(), and the hash() functions, but I want to create a hash using the MySQL PASSWORD() function. So far, the only way I can think of is to just query the server, but I want a function (preferably in php or Perl) that will do the same thing without querying MySQL at all.</p>
<p>For exam... | [
{
"answer_id": 260280,
"author": "Davide Gualano",
"author_id": 28582,
"author_profile": "https://Stackoverflow.com/users/28582",
"pm_score": 2,
"selected": false,
"text": "<p>Why do you want to use mysql password() function?\nEven the Mysql documentation advises against this:</p>\n\n<p>... | 2008/11/03 | [
"https://Stackoverflow.com/questions/260236",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I know that php has md5(), sha1(), and the hash() functions, but I want to create a hash using the MySQL PASSWORD() function. So far, the only way I can think of is to just query the server, but I want a function (preferably in php or Perl) that will do the same thing without querying MySQL at all.
For example:
MySQL... | I originally stumbled across this question in my own search for a PHP implementation of the two MySQL password hashing functions. I was unable to find any implementations, so I adapted my own from the MySQL source code (sql/password.c). The following are tested and working in PHP 5.2:
```
// The following is free for ... |
260,252 | <p>I have a web-app that I would like to extend to support multiple languages with new URLs. For example, www.example.com/home.do stays English, but www.example.com/es/home.do is Spanish. My first thought was to create a Filter which rewrites incoming urls like /es/home.do to /home.do (and sets the Locale in the Requ... | [
{
"answer_id": 260293,
"author": "David M. Karr",
"author_id": 10508,
"author_profile": "https://Stackoverflow.com/users/10508",
"pm_score": 0,
"selected": false,
"text": "<p>As far as I know, the conventional way to do this is with the accept-language HTTP header. The presentation lang... | 2008/11/03 | [
"https://Stackoverflow.com/questions/260252",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7867/"
] | I have a web-app that I would like to extend to support multiple languages with new URLs. For example, www.example.com/home.do stays English, but www.example.com/es/home.do is Spanish. My first thought was to create a Filter which rewrites incoming urls like /es/home.do to /home.do (and sets the Locale in the Request);... | I'm not sure that overriding `getContextPath()` is enough to solve your problem. What if Struts is calling `ServletContext.getContextPath()` under the covers, or uses `getRequestURI()`, etc? |
260,253 | <p>A little example</p>
<pre><code>TTest<T> = class
private
f : T;
public
function ToString : string;
end;
</code></pre>
<p>If is an object then this should work</p>
<pre><code>TTest<T>.ToString;
begin
Result := f.ToString;
end;
</code></pre>
<p>But what happens when is say an integer? This woul... | [
{
"answer_id": 260266,
"author": "Toon Krijthe",
"author_id": 18061,
"author_profile": "https://Stackoverflow.com/users/18061",
"pm_score": 2,
"selected": false,
"text": "<p>The last example will not work. You need to add a constraint in order to use methods. In this case TObject will be... | 2008/11/03 | [
"https://Stackoverflow.com/questions/260253",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22712/"
] | A little example
```
TTest<T> = class
private
f : T;
public
function ToString : string;
end;
```
If is an object then this should work
```
TTest<T>.ToString;
begin
Result := f.ToString;
end;
```
But what happens when is say an integer? This would be ok in .net. of course.
I know it won't work, but how do I... | There are three reasons why Delphi doesn't let you do what you are trying to do in your second example - call the ToString method on a value of an unconstrained type parameter type (or at least that's what I think you were trying to show, since TObject.ToString is an instance method, not a class method, so T.ToString w... |
260,254 | <p>I'm writing a simple C++ class in which I would like cache picture thumbnails versions of images downloaded from the web. As such, I would like to use a hash function which takes in URL strings and outputs a unique string suitable as a filename.</p>
<p>Is there a simple way to do this without re-writing the functi... | [
{
"answer_id": 260262,
"author": "JesperE",
"author_id": 13051,
"author_profile": "https://Stackoverflow.com/users/13051",
"pm_score": 2,
"selected": true,
"text": "<p>A simpler approach is to replace everything which is not a character or a number with an underscore.</p>\n\n<p>EDIT: Her... | 2008/11/03 | [
"https://Stackoverflow.com/questions/260254",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33791/"
] | I'm writing a simple C++ class in which I would like cache picture thumbnails versions of images downloaded from the web. As such, I would like to use a hash function which takes in URL strings and outputs a unique string suitable as a filename.
Is there a simple way to do this without re-writing the function myself? ... | A simpler approach is to replace everything which is not a character or a number with an underscore.
EDIT: Here's a naive implementation in C:
```
#include <cctype>
char *safe_url(const char *str) {
char *safe = strdup(str);
for (int i = 0; i < strlen(str); i++) {
if (isalpha(str[i]))
saf... |
260,273 | <p>I have a file and I don't know how big it's going to be (it could be quite large, but the size will vary greatly). I want to search the last 10 lines or so to see if any of them match a string. I need to do this as quickly and efficiently as possible and was wondering if there's anything better than:</p>
<pre><co... | [
{
"answer_id": 260282,
"author": "Javier",
"author_id": 11649,
"author_profile": "https://Stackoverflow.com/users/11649",
"pm_score": 0,
"selected": false,
"text": "<p>read the last few Ks of the file, and split that into lines to return only the last 10.</p>\n\n<p>it's quite unlikely th... | 2008/11/03 | [
"https://Stackoverflow.com/questions/260273",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1057/"
] | I have a file and I don't know how big it's going to be (it could be quite large, but the size will vary greatly). I want to search the last 10 lines or so to see if any of them match a string. I need to do this as quickly and efficiently as possible and was wondering if there's anything better than:
```
s = "foo"
las... | ```
# Tail
from __future__ import with_statement
find_str = "FIREFOX" # String to find
fname = "g:/autoIt/ActiveWin.log_2" # File to check
with open(fname, "r") as f:
f.seek (0, 2) # Seek @ EOF
fsize = f.tell() # Get Size
f.seek (max (fsize-1024, 0), 0) # Set pos @ ... |
260,285 | <p>I've got a canvas that's 800x600 inside a window that's 300x300. When I press a certain key, I want it the canvas to move in that direction.<br>
I've done this inside the window's code behind:</p>
<pre>
protected override void OnKeyDown(KeyEventArgs e)
{
base.OnKeyDown(e);
Key keyPressed = e.Key;
if (k... | [
{
"answer_id": 260295,
"author": "Tigraine",
"author_id": 21699,
"author_profile": "https://Stackoverflow.com/users/21699",
"pm_score": 1,
"selected": false,
"text": "<p>Yes, you could incorporate the time into your calculation. Currently you add/substract 5 whenever the event fires, and... | 2008/11/03 | [
"https://Stackoverflow.com/questions/260285",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33324/"
] | I've got a canvas that's 800x600 inside a window that's 300x300. When I press a certain key, I want it the canvas to move in that direction.
I've done this inside the window's code behind:
```
protected override void OnKeyDown(KeyEventArgs e)
{
base.OnKeyDown(e);
Key keyPressed = e.Key;
if (keyPressed... | Currently, your setup is accepting spammed keyinput (holding down a key). The way I've seen it done in most games with event based input is to use a boolean array, `keydown[256]`, mapping the keyboard (the index being the key value); all values initialized to `false`.
When the key is pressed, you set the the appropria... |
260,307 | <p>I need to take production data with real customer info (names, address, phone numbers, etc) and move it into a dev environment, but I'd like to remove any semblance of <em>real</em> customer info.</p>
<p>Some of the answers to <a href="https://stackoverflow.com/questions/157600/data-generators-for-sql-server">this ... | [
{
"answer_id": 260318,
"author": "John Lemp",
"author_id": 12915,
"author_profile": "https://Stackoverflow.com/users/12915",
"pm_score": 5,
"selected": true,
"text": "<p>Anonymizing data can be tricky and if not done correctly can lead you to trouble, like what happened to <a href=\"http... | 2008/11/03 | [
"https://Stackoverflow.com/questions/260307",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21398/"
] | I need to take production data with real customer info (names, address, phone numbers, etc) and move it into a dev environment, but I'd like to remove any semblance of *real* customer info.
Some of the answers to [this question](https://stackoverflow.com/questions/157600/data-generators-for-sql-server) can help me gen... | Anonymizing data can be tricky and if not done correctly can lead you to trouble, like what happened to [AOL when they released search data a while back](http://en.wikipedia.org/wiki/AOL_search_data_scandal). I would attempt to create test data from scratch at all costs before I tried to convert existing customer data.... |
260,337 | <p>Why does this test program result in a <code>java.lang.IllegalMonitorStateException</code>?</p>
<pre><code>public class test {
static Integer foo = new Integer(1);
public static void main(String[] args) {
synchronized(foo) {
foo++;
foo.notifyAll();
}
System.er... | [
{
"answer_id": 260343,
"author": "erickson",
"author_id": 3474,
"author_profile": "https://Stackoverflow.com/users/3474",
"pm_score": 7,
"selected": true,
"text": "<p>You have noted correctly that <code>notifyAll</code> must be called from a synchronized block.</p>\n\n<p>However, in your... | 2008/11/03 | [
"https://Stackoverflow.com/questions/260337",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29264/"
] | Why does this test program result in a `java.lang.IllegalMonitorStateException`?
```
public class test {
static Integer foo = new Integer(1);
public static void main(String[] args) {
synchronized(foo) {
foo++;
foo.notifyAll();
}
System.err.println("Success");
... | You have noted correctly that `notifyAll` must be called from a synchronized block.
However, in your case, because of auto-boxing, the object you synchronized on is not the same instance that you invoked `notifyAll` on. In fact, the new, incremented `foo` instance is still confined to the stack, and no other threads c... |
260,356 | <p>I am experimenting for the first time with css layouts and my experience with CSS is very basic. What I want to achieve is a 2 column layout: left panel and content.<br>
I have found this:</p>
<pre><code>#leftcontent
{
position: absolute;
left: 10px;
top: 10px;
width: 170px;
border: 1px solid #C... | [
{
"answer_id": 260361,
"author": "David Arno",
"author_id": 7122,
"author_profile": "https://Stackoverflow.com/users/7122",
"pm_score": -1,
"selected": false,
"text": "<p>Use a table. It is more suited to the task, way easier to implement and far more reliable across different browsers.<... | 2008/11/03 | [
"https://Stackoverflow.com/questions/260356",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16989/"
] | I am experimenting for the first time with css layouts and my experience with CSS is very basic. What I want to achieve is a 2 column layout: left panel and content.
I have found this:
```
#leftcontent
{
position: absolute;
left: 10px;
top: 10px;
width: 170px;
border: 1px solid #C0C0C0;
padd... | I'd advise floating the #leftcontent element to the left, and then setting the margin of the #centercontent element to compensate:
```
#leftcontent {
float: left;
width:170px;
border:1px solid #C0C0C0;
padding: 2px;
}
#centercontent {
margin-left: 181px;
border:1px soli... |
260,372 | <p>I occasionally work on an old project that uses classic asp as a front end and an access database as a backend.</p>
<p>I'd like to create a new column in one of the tables that contains logic to calculate its value from the other columns in the row.</p>
<p>I know how to do this in a more modern DBMS, but I don't t... | [
{
"answer_id": 260631,
"author": "pro3carp3",
"author_id": 7899,
"author_profile": "https://Stackoverflow.com/users/7899",
"pm_score": 2,
"selected": false,
"text": "<p>Can you just make a calculated column?</p>\n\n<pre><code>SELECT Table1.Col_1, Table1.Col_2, [Col_1]*[Col_2] AS Col_3\nF... | 2008/11/03 | [
"https://Stackoverflow.com/questions/260372",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965/"
] | I occasionally work on an old project that uses classic asp as a front end and an access database as a backend.
I'd like to create a new column in one of the tables that contains logic to calculate its value from the other columns in the row.
I know how to do this in a more modern DBMS, but I don't think that access ... | Can you just make a calculated column?
```
SELECT Table1.Col_1, Table1.Col_2, [Col_1]*[Col_2] AS Col_3
FROM Table1;
``` |
260,380 | <p>I have a base class with an optional virtual function</p>
<pre><code>class Base {
virtual void OnlyImplementThisSometimes(int x) {}
};
</code></pre>
<p>When I compile this I get a warning about the unused param x. Is there some other way I should have implemented the virtual function? I have re-written it li... | [
{
"answer_id": 260393,
"author": "Chris Thompson",
"author_id": 5982,
"author_profile": "https://Stackoverflow.com/users/5982",
"pm_score": 3,
"selected": false,
"text": "<p>Why define it in the base class? If the base class isn't going to use the method, then just define it as a virtua... | 2008/11/03 | [
"https://Stackoverflow.com/questions/260380",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20889/"
] | I have a base class with an optional virtual function
```
class Base {
virtual void OnlyImplementThisSometimes(int x) {}
};
```
When I compile this I get a warning about the unused param x. Is there some other way I should have implemented the virtual function? I have re-written it like this:
```
class Base {
... | Ignoring the design issues you can get around the compiler warning about an unused variable by omitting the variable name, for example:
```
virtual void OnlyImplementThisSometimes(int ) { }
```
Mistakenly implementing the wrong method signature when trying to override the virtual function is just something you need ... |
260,387 | <p>I am using the code below to display all the files from a directory in a drop down menu. Does anyone know how to make this alphabetical? I presume it has something to do with the sort function, I just can't figure out how!</p>
<pre><code><?php
$dirname = "images/";
$images = scandir($dirname);
$dh = opendir($dir... | [
{
"answer_id": 260400,
"author": "Paige Ruten",
"author_id": 813,
"author_profile": "https://Stackoverflow.com/users/813",
"pm_score": 3,
"selected": false,
"text": "<p>Why are you reading all the filenames using scandir() and then looping through them with the readdir() method? You coul... | 2008/11/04 | [
"https://Stackoverflow.com/questions/260387",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32972/"
] | I am using the code below to display all the files from a directory in a drop down menu. Does anyone know how to make this alphabetical? I presume it has something to do with the sort function, I just can't figure out how!
```
<?php
$dirname = "images/";
$images = scandir($dirname);
$dh = opendir($dirname);
while ($f... | Why are you reading all the filenames using scandir() and then looping through them with the readdir() method? You could just do this:
```
<?php
$dirname = "images/";
$images = scandir($dirname);
// This is how you sort an array, see http://php.net/sort
sort($images);
// There's no need to use a directory handler, ... |
260,391 | <p>I have an iphone app where I call these three functions in appDidFinishLaunching:</p>
<pre><code>glMatrixMode(GL_PROJECTION);
glOrthof(0, rect.size.width, 0, rect.size.height, -1, 1);
glMatrixMode(GL_MODELVIEW);
</code></pre>
<p>When stepping through with the debugger I get EXC BAD ACCESS when I execute the first ... | [
{
"answer_id": 262253,
"author": "Brian",
"author_id": 15901,
"author_profile": "https://Stackoverflow.com/users/15901",
"pm_score": 2,
"selected": false,
"text": "<p>I've seen this error in many different situations but never specifically in yours. It usually comes up as a result of the... | 2008/11/04 | [
"https://Stackoverflow.com/questions/260391",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22471/"
] | I have an iphone app where I call these three functions in appDidFinishLaunching:
```
glMatrixMode(GL_PROJECTION);
glOrthof(0, rect.size.width, 0, rect.size.height, -1, 1);
glMatrixMode(GL_MODELVIEW);
```
When stepping through with the debugger I get EXC BAD ACCESS when I execute the first line. Any ideas why this i... | I've run into this with OpenGL calls if two threads are attempting to draw to the OpenGL scene at once. However, that doesn't sound like what you're doing.
Have you properly initialized your display context and framebuffer before this call? For example, in my UIView subclass that does OpenGL drawing, I call the follow... |
260,398 | <p>I have a list of stores, departments within the stores, and sales for each department, like so (created using max(sales) in a subquery, but that's not terribly important here I don't think):</p>
<pre><code>toronto baskets 500
vancouver baskets 350
halifax baskets 100
toronto noodles 275
vancouver noodles... | [
{
"answer_id": 260419,
"author": "Noah Yetter",
"author_id": 30080,
"author_profile": "https://Stackoverflow.com/users/30080",
"pm_score": 2,
"selected": false,
"text": "<p>This works in Oracle, other implementations may have different syntax for analytic functions (or lack them entirely... | 2008/11/04 | [
"https://Stackoverflow.com/questions/260398",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a list of stores, departments within the stores, and sales for each department, like so (created using max(sales) in a subquery, but that's not terribly important here I don't think):
```
toronto baskets 500
vancouver baskets 350
halifax baskets 100
toronto noodles 275
vancouver noodles 390
halifax ... | This works in Oracle, other implementations may have different syntax for analytic functions (or lack them entirely):
```
select store
, max(department) keep(dense_rank last order by sales)
, max(sales)
from (
...query that generates your results...
)
group by store
``` |
260,399 | <p>I know you cannot use a alias column in the where clause for T-SQL; however, has Microsoft provided some kind of workaround for this?</p>
<blockquote>
<p><strong>Related Questions:</strong> </p>
<ul>
<li><a href="https://stackoverflow.com/questions/200200/can-you-use-an-alias-in-the-where-clause-in-mysql"... | [
{
"answer_id": 260437,
"author": "Jim V.",
"author_id": 33819,
"author_profile": "https://Stackoverflow.com/users/33819",
"pm_score": 6,
"selected": true,
"text": "<p>One workaround would be to use a derived table.</p>\n\n<p>For example:</p>\n\n<pre><code>select *\nfrom \n (\n select... | 2008/11/04 | [
"https://Stackoverflow.com/questions/260399",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1632/"
] | I know you cannot use a alias column in the where clause for T-SQL; however, has Microsoft provided some kind of workaround for this?
>
> **Related Questions:**
>
>
> * [Unknown Column In Where Clause](https://stackoverflow.com/questions/200200/can-you-use-an-alias-in-the-where-clause-in-mysql)
> * [Can you use an... | One workaround would be to use a derived table.
For example:
```
select *
from
(
select a + b as aliased_column
from table
) dt
where dt.aliased_column = something.
```
I hope this helps. |
260,432 | <p>I have the following method in my unit test project:</p>
<pre><code> [TestMethod]
[HostType("ASP.NET")]
[UrlToTest("http://localhost:3418/Web/SysCoord/ChooseEPA.aspx")]
[AspNetDevelopmentServerHost("%PathToWebRoot%")]
public void TestMethod1()
{
Page page = TestContext.RequestedPage;
... | [
{
"answer_id": 269052,
"author": "cfeduke",
"author_id": 5645,
"author_profile": "https://Stackoverflow.com/users/5645",
"pm_score": 1,
"selected": false,
"text": "<p>Based on your evidence I would guess that a reference to whichever assembly contains <code>MyApplicationFramework.Profile... | 2008/11/04 | [
"https://Stackoverflow.com/questions/260432",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12260/"
] | I have the following method in my unit test project:
```
[TestMethod]
[HostType("ASP.NET")]
[UrlToTest("http://localhost:3418/Web/SysCoord/ChooseEPA.aspx")]
[AspNetDevelopmentServerHost("%PathToWebRoot%")]
public void TestMethod1()
{
Page page = TestContext.RequestedPage;
Assert... | I've had this problem before and at that point gave up after reading all I could google about it (including this thread).
The solution turned out to be simple in my case. All I had to do was not use ASP.NET test attributes and simply test the MVC project as a DLL.
### Step 1
Remove the extra attributes from the test... |
260,436 | <p>Disclaimer: the following is a sin against XML. That's why I'm trying to change it with XSLT :)</p>
<p>My XML currently looks like this:</p>
<pre><code><root>
<object name="blarg" property1="shablarg" property2="werg".../>
<object name="yetanotherobject" .../>
</root>
</code></pre>... | [
{
"answer_id": 260457,
"author": "James Sulak",
"author_id": 207,
"author_profile": "https://Stackoverflow.com/users/207",
"pm_score": 2,
"selected": false,
"text": "<p>According to the <a href=\"http://www.xml.com/axml/testaxml.htm\" rel=\"nofollow noreferrer\">Annotated XML Spec</a>, w... | 2008/11/04 | [
"https://Stackoverflow.com/questions/260436",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2555346/"
] | Disclaimer: the following is a sin against XML. That's why I'm trying to change it with XSLT :)
My XML currently looks like this:
```
<root>
<object name="blarg" property1="shablarg" property2="werg".../>
<object name="yetanotherobject" .../>
</root>
```
Yes, I'm putting all the textual data in attributes. ... | This is actually a raw XML parsing problem, not something XSLT can help you with. An XML parse must convert the newlines in that attribute value to spaces, as per ‘3.3.3 Attribute-Value Normalization’ in the XML standard. So anything currently reading your description attributes and keeping the newlines in is doing it ... |
260,439 | <p>I currently have two text boxes which accept any number. I have a text block that takes the two numbers entered and calculates the average. </p>
<p>I was wondering if there was a way I could bind this text block to both text boxes and utilize a custom converter to calculate the average? I currently am catching the ... | [
{
"answer_id": 260445,
"author": "Jacob Carpenter",
"author_id": 26627,
"author_profile": "https://Stackoverflow.com/users/26627",
"pm_score": 7,
"selected": true,
"text": "<p>You're looking for <a href=\"http://msdn.microsoft.com/en-us/library/system.windows.data.multibinding.aspx\" rel... | 2008/11/04 | [
"https://Stackoverflow.com/questions/260439",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23939/"
] | I currently have two text boxes which accept any number. I have a text block that takes the two numbers entered and calculates the average.
I was wondering if there was a way I could bind this text block to both text boxes and utilize a custom converter to calculate the average? I currently am catching the text chang... | You're looking for [`MultiBinding`](http://msdn.microsoft.com/en-us/library/system.windows.data.multibinding.aspx).
Your `XAML` will look something like this:
```
<TextBlock>
<TextBlock.Text>
<MultiBinding Converter="{StaticResource myConverter}">
<Binding Path="myFirst.Value" />
<Binding Path="mySe... |
260,441 | <p>In class, we are all 'studying' databases, and everyone is using Access. Bored with this, I am trying to do what the rest of the class is doing, but with raw SQL commands with MySQL instead of using Access.</p>
<p>I have managed to create databases and tables, but now how do I make a relationship between two tables... | [
{
"answer_id": 260453,
"author": "Eric Hogue",
"author_id": 4137,
"author_profile": "https://Stackoverflow.com/users/4137",
"pm_score": 8,
"selected": true,
"text": "<p>If the tables are innodb you can create it like this: </p>\n\n<pre><code>CREATE TABLE accounts(\n account_id INT NOT... | 2008/11/04 | [
"https://Stackoverflow.com/questions/260441",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2592/"
] | In class, we are all 'studying' databases, and everyone is using Access. Bored with this, I am trying to do what the rest of the class is doing, but with raw SQL commands with MySQL instead of using Access.
I have managed to create databases and tables, but now how do I make a relationship between two tables?
If I ha... | If the tables are innodb you can create it like this:
```
CREATE TABLE accounts(
account_id INT NOT NULL AUTO_INCREMENT,
customer_id INT( 4 ) NOT NULL ,
account_type ENUM( 'savings', 'credit' ) NOT NULL,
balance FLOAT( 9 ) NOT NULL,
PRIMARY KEY ( account_id ),
FOREIGN KEY (customer_id) REFERE... |
260,464 | <p>I'm running my C++ program in gdb. I'm not real experienced with gdb, but I'm getting messages like:</p>
<pre><code>warning: HEAP[test.exe]:
warning: Heap block at 064EA560 modified at 064EA569 past requested size of 1
</code></pre>
<p>How can I track down where this is happening at? Viewing the memory doesn't giv... | [
{
"answer_id": 260496,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": true,
"text": "<p>So you're busting your heap. Here's a nice <a href=\"http://www.cs.princeton.edu/courses/archive/spring99/cs126/help/gdbtut.... | 2008/11/04 | [
"https://Stackoverflow.com/questions/260464",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3175/"
] | I'm running my C++ program in gdb. I'm not real experienced with gdb, but I'm getting messages like:
```
warning: HEAP[test.exe]:
warning: Heap block at 064EA560 modified at 064EA569 past requested size of 1
```
How can I track down where this is happening at? Viewing the memory doesn't give me any clues.
Thanks! | So you're busting your heap. Here's a nice [GDB tutorial](http://www.cs.princeton.edu/courses/archive/spring99/cs126/help/gdbtut.html) to keep in mind.
My normal practice is to set a break in known good part of the code. Once it gets there step through until you error out. Normally you can determine the problem that w... |
260,484 | <p>How do I query the iPhone's current IP address?</p>
| [
{
"answer_id": 2913196,
"author": "arifwidi",
"author_id": 212915,
"author_profile": "https://Stackoverflow.com/users/212915",
"pm_score": 2,
"selected": false,
"text": "<p>You can try to use similar to this service:\n<a href=\"http://automation.whatismyip.com/n09230945.asp\" rel=\"nofol... | 2008/11/04 | [
"https://Stackoverflow.com/questions/260484",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How do I query the iPhone's current IP address? | If you want the **external** IP address (the one used to connect from outside the local network), you need to query a server on the external network. A quick search yielded the following: <http://checkip.dyndns.org>, <http://www.whatismyip.com>. It is quite simple to load the page using e.g.
```
[NSData dataWithConten... |
260,491 | <p>I'm developing a library for use in other apps and this library has lots of debugging and logging statements thanks to NLog.</p>
<p>Is it possible to exclude the reference to NLog.dll when I switch to release mode?</p>
<p>Cheers,</p>
| [
{
"answer_id": 260522,
"author": "wonderchook",
"author_id": 32113,
"author_profile": "https://Stackoverflow.com/users/32113",
"pm_score": 0,
"selected": false,
"text": "<p>I can't think of a good way to do this. Unless maybe you wrote a stub reference for NLog.dll. Since you are using... | 2008/11/04 | [
"https://Stackoverflow.com/questions/260491",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17211/"
] | I'm developing a library for use in other apps and this library has lots of debugging and logging statements thanks to NLog.
Is it possible to exclude the reference to NLog.dll when I switch to release mode?
Cheers, | You can manually edit the csproj file, and do something like this:
```
<Reference Include="NLog" Condition="'$(Configuration)' == 'Debug'" />
```
This only makes it reference that assembly in Debug. I wouldn't recommend doing this often though, because this behavior isn't reflected in the references list in Visual S... |
260,511 | <p>Here is my short implementation of <a href="http://en.wikipedia.org/wiki/Ancient_Egyptian_multiplication" rel="noreferrer">Russian Peasant Multiplication</a>. How can it be improved?</p>
<p><em>Restrictions</em> : only works when a>0,b>0</p>
<pre><code>for(p=0;p+=(a&1)*b,a!=1;a>>=1,b<<=1);
</code><... | [
{
"answer_id": 260529,
"author": "Mark Bessey",
"author_id": 17826,
"author_profile": "https://Stackoverflow.com/users/17826",
"pm_score": 2,
"selected": false,
"text": "<p>I think it's incomplete, and very hard to read. What specific sort of feedback were you looking for?</p>\n"
},
... | 2008/11/04 | [
"https://Stackoverflow.com/questions/260511",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34051/"
] | Here is my short implementation of [Russian Peasant Multiplication](http://en.wikipedia.org/wiki/Ancient_Egyptian_multiplication). How can it be improved?
*Restrictions* : only works when a>0,b>0
```
for(p=0;p+=(a&1)*b,a!=1;a>>=1,b<<=1);
``` | It can be improved by adding whitespace, proper indentation, and a proper function body:
```
int peasant_mult (int a, int b) {
for (p = 0;
p += (a & 1) * b, a != 1;
a /= 2, b *= 2);
return p;}
```
See? Now it's clear how the three parts of the `for` declaration are used. Remember, programs are writ... |
260,523 | <p>I am developing an iPhone application, in my table view I wanted custom color for Cell Selection Style, I read the <em>UITableViewCell Class Reference</em> but there are only three constants defined for Selection style (Blue, Gray, None). I saw one application that used a different color than those defined in the re... | [
{
"answer_id": 260697,
"author": "Jeffrey Forbes",
"author_id": 28019,
"author_profile": "https://Stackoverflow.com/users/28019",
"pm_score": 2,
"selected": false,
"text": "<p>Override didSelectRowAtIndexPath: and draw a UIView of a color of your choosing and insert it behind the UILabel... | 2008/11/04 | [
"https://Stackoverflow.com/questions/260523",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/451867/"
] | I am developing an iPhone application, in my table view I wanted custom color for Cell Selection Style, I read the *UITableViewCell Class Reference* but there are only three constants defined for Selection style (Blue, Gray, None). I saw one application that used a different color than those defined in the reference.
... | The best way to set the selection is to set the `selectedBackgroundView` on the cell when you construct it.
i.e.
```
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueRe... |
260,531 | <p>How have you explained nested arrays to a programmer. I'm thinking someone that has an entry level understanding of programming, but is trying to do more complicated coding.</p>
<p>The array with array works, but they can't quite get their mind around the idea.</p>
<p><strong>Edit:</strong> example of a nested arr... | [
{
"answer_id": 260537,
"author": "Tim Howland",
"author_id": 4276,
"author_profile": "https://Stackoverflow.com/users/4276",
"pm_score": 4,
"selected": true,
"text": "<p>Tell them to think of an array as a list- it helps to give them something less abstract, like a grocery list. Then, a ... | 2008/11/04 | [
"https://Stackoverflow.com/questions/260531",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5441/"
] | How have you explained nested arrays to a programmer. I'm thinking someone that has an entry level understanding of programming, but is trying to do more complicated coding.
The array with array works, but they can't quite get their mind around the idea.
**Edit:** example of a nested array:
```
array(
'array1' =... | Tell them to think of an array as a list- it helps to give them something less abstract, like a grocery list. Then, a nested array is simply a list of lists.
Maybe I have a todo list, a grocery list, and a wishlist at amazon.com . Now I have a list of all of my lists, and I can look at all of those elements in each li... |
260,540 | <p>Please advise how to scrape AJAX pages.</p>
| [
{
"answer_id": 260557,
"author": "wonderchook",
"author_id": 32113,
"author_profile": "https://Stackoverflow.com/users/32113",
"pm_score": 2,
"selected": false,
"text": "<p>Depends on the ajax page. The first part of screen scraping is determining how the page works. Is there some sort... | 2008/11/04 | [
"https://Stackoverflow.com/questions/260540",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34051/"
] | Please advise how to scrape AJAX pages. | **Overview:**
All screen scraping first requires manual review of the page you want to extract resources from. When dealing with AJAX you usually just need to analyze a bit more than just simply the HTML.
When dealing with AJAX this just means that the value you want is not in the initial HTML document that you requ... |
260,594 | <p>My question is how do I configure an EJB 3.0 style message driven bean to use a configured JMS datasource in jboss. </p>
<p>For example, my MDB looks something like:</p>
<pre><code>@MessageDriven(mappedName = "ExampleMDB", activationConfig = {
@ActivationConfigProperty(propertyName = "destinationType", pr... | [
{
"answer_id": 260796,
"author": "brian d foy",
"author_id": 2766176,
"author_profile": "https://Stackoverflow.com/users/2766176",
"pm_score": 6,
"selected": true,
"text": "<p>Make your own CPAN mirror with exactly what you want. <a href=\"http://www.stratopan.com\" rel=\"noreferrer\">St... | 2008/11/04 | [
"https://Stackoverflow.com/questions/260594",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33864/"
] | My question is how do I configure an EJB 3.0 style message driven bean to use a configured JMS datasource in jboss.
For example, my MDB looks something like:
```
@MessageDriven(mappedName = "ExampleMDB", activationConfig = {
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.... | Make your own CPAN mirror with exactly what you want. [Stratopan.com](http://www.stratopan.com), a service, and [Pinto](http://www.metacpan.org/module/Pinto), tools that's built on top of, can help you do that.
The CPAN tools only install the latest version of any distribution because PAUSE only indexes the latest ver... |
260,597 | <p>I'd like to receive error logs via email. For example, if a <code>Warning-level</code> error message should occur, I'd like to get an email about it.</p>
<p>How can I get that working in CodeIgniter?</p>
| [
{
"answer_id": 260655,
"author": "Adam",
"author_id": 13320,
"author_profile": "https://Stackoverflow.com/users/13320",
"pm_score": 5,
"selected": true,
"text": "<p>You could extend the Exception core class to do it.</p>\n\n<p>Might have to adjust the reference to CI's email class, not s... | 2008/11/04 | [
"https://Stackoverflow.com/questions/260597",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'd like to receive error logs via email. For example, if a `Warning-level` error message should occur, I'd like to get an email about it.
How can I get that working in CodeIgniter? | You could extend the Exception core class to do it.
Might have to adjust the reference to CI's email class, not sure if you can instantiate it from a library like this. I don't use CI's email class myself, I've been using the Swift Mailer library. But this should get you on the right path.
Make a file MY\_Exceptions.... |
260,615 | <p>I am trying this in my Form Load Event</p>
<p><pre><code>
cmdCancel.Attributes.Add("onClick", "document.forms[0].reset();return false;")
</pre></code></p>
<p>but it doesn't clear my form. My form is a "ContentPage", part of a masterpage.</p>
<p>Am I missing something?</p>
| [
{
"answer_id": 260629,
"author": "pearcewg",
"author_id": 24126,
"author_profile": "https://Stackoverflow.com/users/24126",
"pm_score": 0,
"selected": false,
"text": "<p>Shouldn't cancel take you away from the form entry page?\nIt sounds like you are trying to code \"reset\", but you are... | 2008/11/04 | [
"https://Stackoverflow.com/questions/260615",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23667/"
] | I am trying this in my Form Load Event
```
cmdCancel.Attributes.Add("onClick", "document.forms[0].reset();return false;")
```
but it doesn't clear my form. My form is a "ContentPage", part of a masterpage.
Am I missing something? | Try this:
```
cmdCancel.Attributes.Add("onClick","document.getElementById('" + this.Page.ClientId + "').reset(); return false;");
``` |
260,626 | <p>What does "type-safe" mean?</p>
| [
{
"answer_id": 260640,
"author": "FlySwat",
"author_id": 1965,
"author_profile": "https://Stackoverflow.com/users/1965",
"pm_score": 8,
"selected": false,
"text": "<p>Type safety means that the compiler will validate types while compiling, and throw an error if you try to assign the wron... | 2008/11/04 | [
"https://Stackoverflow.com/questions/260626",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | What does "type-safe" mean? | Type safety means that the compiler will validate types while compiling, and throw an error if you try to assign the wrong type to a variable.
Some simple examples:
```
// Fails, Trying to put an integer in a string
String one = 1;
// Also fails.
int foo = "bar";
```
This also applies to method arguments, since you... |
260,627 | <p>This drop down list, displaying all the files from a folder, one of which will be selected for use. Is there a way to show which file is selected when you load the page? At the moment it says "select a file" every time.</p>
<pre><code><select name="image" type="text" class="box" id="image" value="<?=$image;?&... | [
{
"answer_id": 260640,
"author": "FlySwat",
"author_id": 1965,
"author_profile": "https://Stackoverflow.com/users/1965",
"pm_score": 8,
"selected": false,
"text": "<p>Type safety means that the compiler will validate types while compiling, and throw an error if you try to assign the wron... | 2008/11/04 | [
"https://Stackoverflow.com/questions/260627",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32972/"
] | This drop down list, displaying all the files from a folder, one of which will be selected for use. Is there a way to show which file is selected when you load the page? At the moment it says "select a file" every time.
```
<select name="image" type="text" class="box" id="image" value="<?=$image;?>">
<option value='em... | Type safety means that the compiler will validate types while compiling, and throw an error if you try to assign the wrong type to a variable.
Some simple examples:
```
// Fails, Trying to put an integer in a string
String one = 1;
// Also fails.
int foo = "bar";
```
This also applies to method arguments, since you... |
260,658 | <p>Via command line, I usually do this:</p>
<pre><code>cp -rRp /path/to/a\_folder/. /path/to/another\_folder
</code></pre>
<p>This copies just the contents underneath <strong>a_folder</strong> to <strong>another_folder</strong>. In SVN I need to do the same thing, but can't figure it out. I always end up with this:</... | [
{
"answer_id": 260706,
"author": "Jerub",
"author_id": 14648,
"author_profile": "https://Stackoverflow.com/users/14648",
"pm_score": 4,
"selected": true,
"text": "<p>Have you considered using svn merge?</p>\n\n<p>Given a repo like this:</p>\n\n<pre><code>trunk/a_folder/foo\ntrunk/a_folde... | 2008/11/04 | [
"https://Stackoverflow.com/questions/260658",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Via command line, I usually do this:
```
cp -rRp /path/to/a\_folder/. /path/to/another\_folder
```
This copies just the contents underneath **a\_folder** to **another\_folder**. In SVN I need to do the same thing, but can't figure it out. I always end up with this:
```
/path/to/another\_folder/a\_folder
```
SVN t... | Have you considered using svn merge?
Given a repo like this:
```
trunk/a_folder/foo
trunk/a_folder/bar
trunk/new_folder/baz
```
use these commands to merge the foo and bar directories:
```
cd trunk/new_folder
svn merge -r1:HEAD http://svn/repo/trunk/a_folder .
``` |
260,663 | <p>I started web programming with raw PHP, gradually moving on to its various frameworks, then to Django and Rails. In every framework I've used, pretty much everything I need to do with a database (even involving relatively complex things like many-to-many relationships) could be taken care of by the automatically gen... | [
{
"answer_id": 260673,
"author": "Noah Goodrich",
"author_id": 20178,
"author_profile": "https://Stackoverflow.com/users/20178",
"pm_score": 1,
"selected": false,
"text": "<p>I would suggest that you look at the <a href=\"http://www.springframework.org/\" rel=\"nofollow noreferrer\">Spri... | 2008/11/04 | [
"https://Stackoverflow.com/questions/260663",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I started web programming with raw PHP, gradually moving on to its various frameworks, then to Django and Rails. In every framework I've used, pretty much everything I need to do with a database (even involving relatively complex things like many-to-many relationships) could be taken care of by the automatically genera... | [Grails](http://grails.org) for the win. Groovy is very similar to Java but with a lot of nice dynamic language additions/simplifications. Grails has GORM, which is exactly what you're looking for. |
260,666 | <p>Can an abstract class have a constructor?</p>
<p>If so, how can it be used and for what purposes?</p>
| [
{
"answer_id": 260686,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 1,
"selected": false,
"text": "<p>Consider this:</p>\n\n<pre><code>abstract class Product { \n int value;\n public Product( int val ) {\n val... | 2008/11/04 | [
"https://Stackoverflow.com/questions/260666",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33885/"
] | Can an abstract class have a constructor?
If so, how can it be used and for what purposes? | Yes, an abstract class can have a constructor. Consider this:
```
abstract class Product {
int multiplyBy;
public Product( int multiplyBy ) {
this.multiplyBy = multiplyBy;
}
public int mutiply(int val) {
return multiplyBy * val;
}
}
class TimesTwo extends Product {
public Time... |
260,668 | <p>I'm curious about people's experiences using AR's to_xml() to build non-entity fields (as in, not an attribute of the model you are serializing, but perhaps, utilizing the attributes in the process) from a controller. </p>
<p>to_xml seems to supply a few options for doing this. </p>
<p>One is by passing in refer... | [
{
"answer_id": 260686,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 1,
"selected": false,
"text": "<p>Consider this:</p>\n\n<pre><code>abstract class Product { \n int value;\n public Product( int val ) {\n val... | 2008/11/04 | [
"https://Stackoverflow.com/questions/260668",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33866/"
] | I'm curious about people's experiences using AR's to\_xml() to build non-entity fields (as in, not an attribute of the model you are serializing, but perhaps, utilizing the attributes in the process) from a controller.
to\_xml seems to supply a few options for doing this.
One is by passing in references to methods ... | Yes, an abstract class can have a constructor. Consider this:
```
abstract class Product {
int multiplyBy;
public Product( int multiplyBy ) {
this.multiplyBy = multiplyBy;
}
public int mutiply(int val) {
return multiplyBy * val;
}
}
class TimesTwo extends Product {
public Time... |
260,679 | <p>If I have a table like:</p>
<pre><code>CREATE TABLE FRED
(
recordId number(18) primary key,
firstName varchar2(50)
);
</code></pre>
<p>Is there an easy way to clone it's structure (not it's data) into another table of a given name. Basically I want to create table with exactly the same structure, but a different n... | [
{
"answer_id": 260689,
"author": "BQ.",
"author_id": 4632,
"author_profile": "https://Stackoverflow.com/users/4632",
"pm_score": 3,
"selected": false,
"text": "<p>CREATE TABLE tablename AS SELECT * FROM orginaltable WHERE 1=2;</p>\n\n<p>Edit: The WHERE clause prohibits any rows from qual... | 2008/11/04 | [
"https://Stackoverflow.com/questions/260679",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6044/"
] | If I have a table like:
```
CREATE TABLE FRED
(
recordId number(18) primary key,
firstName varchar2(50)
);
```
Is there an easy way to clone it's structure (not it's data) into another table of a given name. Basically I want to create table with exactly the same structure, but a different name, so that I can perform... | If you're looking a way to find the exact DDL to recreate the table, including the storage clause, you can use
```
select dbms_metadata.get_ddl('TABLE', 'TABLE_NAME', 'SCHEMA_NAME') from dual
```
as described [here](http://www.troygeek.com/articles/ExtractingOracleDDLCommandLine/). |
260,701 | <p>I'm looking for one line code examples in various languages for getting a valid MD5 result (as a string, not a bytehash or what have you). For instance:</p>
<p>PHP:
$token = md5($var1 . $var2);</p>
<p>I found VB especially troublesome to do in one line.</p>
| [
{
"answer_id": 260715,
"author": "Markus Jarderot",
"author_id": 22364,
"author_profile": "https://Stackoverflow.com/users/22364",
"pm_score": 2,
"selected": false,
"text": "<p><strong>Python</strong></p>\n\n<pre><code>token = __import__('md5').new(var1 + var2).hexdigest()\n</code></pre>... | 2008/11/04 | [
"https://Stackoverflow.com/questions/260701",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33886/"
] | I'm looking for one line code examples in various languages for getting a valid MD5 result (as a string, not a bytehash or what have you). For instance:
PHP:
$token = md5($var1 . $var2);
I found VB especially troublesome to do in one line. | C#:
```
string hash = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(input, "md5");
```
VB is virtually the same.
Here it is not using the System.Web namespace:
```
string hash = Convert.ToBase64String(new System.Security.Cryptography.MD5CryptoServiceProvider().ComputeHash(System.Text.E... |
260,703 | <p>Here is some simple Perl to count the number of times a value occurs in an array. This runs without any warnings.</p>
<pre><code>use warnings;
use strict;
my @data = qw(1 1 2 3 4 5 5 5 9);
my %histogram;
foreach (@data)
{
$histogram{$_}++;
}
</code></pre>
<p>When the loop body is changed to</p>
<pre><code>$h... | [
{
"answer_id": 260724,
"author": "Svante",
"author_id": 31615,
"author_profile": "https://Stackoverflow.com/users/31615",
"pm_score": 5,
"selected": true,
"text": "<p>The + operator evaluates both the form to the left and the form to the right of it, then returns the sum of both. The ha... | 2008/11/04 | [
"https://Stackoverflow.com/questions/260703",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25164/"
] | Here is some simple Perl to count the number of times a value occurs in an array. This runs without any warnings.
```
use warnings;
use strict;
my @data = qw(1 1 2 3 4 5 5 5 9);
my %histogram;
foreach (@data)
{
$histogram{$_}++;
}
```
When the loop body is changed to
```
$histogram{$_} = $histogram{$_} + 1;
`... | The + operator evaluates both the form to the left and the form to the right of it, then returns the sum of both. The hash call evaluation does not see any special context.
The ++ operator has some special magic built in. Quoting from the perlop manpage, regarding the ++ operator:
>
> "undef" is always treated as n... |
260,716 | <p>I'm using a <code>RichTextBox</code> (.NET WinForms 3.5) and would like to override some of the standard ShortCut keys....
For example, I don't want <kbd>Ctrl</kbd>+<kbd>I</kbd> to make the text italic via the RichText method, but to instead run my own method for processing the text.</p>
<p>Any ideas?</p>
| [
{
"answer_id": 260821,
"author": "Jim Burger",
"author_id": 20164,
"author_profile": "https://Stackoverflow.com/users/20164",
"pm_score": 2,
"selected": false,
"text": "<p>Set the RichtTextBox.ShortcutsEnabled property to true and then handle the shortcuts yourself, using the KeyUp event... | 2008/11/04 | [
"https://Stackoverflow.com/questions/260716",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/194/"
] | I'm using a `RichTextBox` (.NET WinForms 3.5) and would like to override some of the standard ShortCut keys....
For example, I don't want `Ctrl`+`I` to make the text italic via the RichText method, but to instead run my own method for processing the text.
Any ideas? | `Ctrl`+`I` isn't one of the default shortcuts affected by the ShortcutsEnabled property.
The following code intercepts the `Ctrl`+`I` in the KeyDown event so you can do anything you want inside the if block, just make sure to suppress the key press like I've shown.
```
private void YourRichTextBox_KeyDown(object send... |
260,744 | <p>An abstract class can only be used as a base class which is extended by some other class, right? The constructor(s) of an abstract class can have the usual access modifiers (public, protected, and private (for internal use)). Which of <code>protected</code> and <code>public</code> is the correct access modifier to ... | [
{
"answer_id": 260751,
"author": "IAmCodeMonkey",
"author_id": 27613,
"author_profile": "https://Stackoverflow.com/users/27613",
"pm_score": 3,
"selected": false,
"text": "<p>If this behavior is true, and I'm not sure it is, you should always use the most restricted scope available for y... | 2008/11/04 | [
"https://Stackoverflow.com/questions/260744",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15075/"
] | An abstract class can only be used as a base class which is extended by some other class, right? The constructor(s) of an abstract class can have the usual access modifiers (public, protected, and private (for internal use)). Which of `protected` and `public` is the correct access modifier to use, since the abstract ty... | >
>
> >
> > since the abstract type seems to indicate that technically a public constructor will act very much protected
> >
> >
> >
>
>
> This is not correct. An abstract class cannot be directly instatiated by calling its constructor, however, any concrete implementation *will inherit the abstract class' meth... |
260,745 | <p>I have a menu with an animation going on, but I want to disable the click while the animation is happening.</p>
<pre><code><div></div>
<div></div>
<div></div>
$("div").click(function() {
$(this).animate({height: "200px"}, 2000);
return false;
});
</code></pre>
<p>However,... | [
{
"answer_id": 260789,
"author": "Markus Jarderot",
"author_id": 22364,
"author_profile": "https://Stackoverflow.com/users/22364",
"pm_score": 5,
"selected": true,
"text": "<pre><code>$(\"div\").click(function() {\n if (!$(this).parent().children().is(':animated')) {\n $(this).... | 2008/11/04 | [
"https://Stackoverflow.com/questions/260745",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16124/"
] | I have a menu with an animation going on, but I want to disable the click while the animation is happening.
```
<div></div>
<div></div>
<div></div>
$("div").click(function() {
$(this).animate({height: "200px"}, 2000);
return false;
});
```
However, I want to disable all the buttons while the event is happenin... | ```
$("div").click(function() {
if (!$(this).parent().children().is(':animated')) {
$(this).animate({height: "200px"}, 2000);
}
return false;
});
``` |
260,749 | <p>I want to increment a cookie value every time a page is referenced even if the page is loaded from cache. What is the "best" or most concise way to implement this?</p>
| [
{
"answer_id": 260866,
"author": "Christian C. Salvadó",
"author_id": 5445,
"author_profile": "https://Stackoverflow.com/users/5445",
"pm_score": 3,
"selected": false,
"text": "<p>Most of the old cookie handling functions I've seen use simple string manipulations for storing an retrievin... | 2008/11/04 | [
"https://Stackoverflow.com/questions/260749",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30099/"
] | I want to increment a cookie value every time a page is referenced even if the page is loaded from cache. What is the "best" or most concise way to implement this? | Stolen from <http://www.quirksmode.org/js/cookies.html#script>
```
function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toUTCString();
}
else var expires = "";
document.cook... |
260,817 | <p>I wanted to try a little design by contract in my latest C# application and wanted to have syntax akin to:</p>
<pre><code>public string Foo()
{
set {
Assert.IsNotNull(value);
Assert.IsTrue(value.Contains("bar"));
_foo = value;
}
}
</code></pre>
<p>I know I can get static methods lik... | [
{
"answer_id": 260833,
"author": "FlySwat",
"author_id": 1965,
"author_profile": "https://Stackoverflow.com/users/1965",
"pm_score": 4,
"selected": false,
"text": "<p>Aside from using an external library, you have a simple assert in System.Diagnostics:</p>\n\n<pre><code>using System.Diag... | 2008/11/04 | [
"https://Stackoverflow.com/questions/260817",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27613/"
] | I wanted to try a little design by contract in my latest C# application and wanted to have syntax akin to:
```
public string Foo()
{
set {
Assert.IsNotNull(value);
Assert.IsTrue(value.Contains("bar"));
_foo = value;
}
}
```
I know I can get static methods like this from a unit test fr... | >
> C# 4.0 Code Contracts
> ---------------------
>
>
>
Microsoft has released a library for design by contract in version 4.0 of the .net framework. One of the coolest features of that library is that it also comes with a static analysis tools (similar to FxCop I guess) that leverages the details of the contracts... |
260,825 | <p>We have been having serious trouble getting an application we devlop running with UAC enabled for long.</p>
<p>Once installed (the installer fails almost immediately with UAC) it appears that UAC can be turned on and have the application work. However, after a while, it will stop working with strange errors about c... | [
{
"answer_id": 260841,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "<p>Where is the application trying to write the file? If it is trying to write to it's install location under Program Files yo... | 2008/11/04 | [
"https://Stackoverflow.com/questions/260825",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14768/"
] | We have been having serious trouble getting an application we devlop running with UAC enabled for long.
Once installed (the installer fails almost immediately with UAC) it appears that UAC can be turned on and have the application work. However, after a while, it will stop working with strange errors about cannot find... | After all this time I found a solution that works.
1. Install somewhere else besides Program Files. This neatly sidesteps the filesystem virtualization that seems to be causing all the problems.
2. Disable virtualization on the application's HLKM registry key. this fixes the one remaining glitch involving system updat... |
260,847 | <p>I have written a few MSBuild custom tasks that work well and are use in our CruiseControl.NET build process.</p>
<p>I am modifying one, and wish to unit test it by calling the Task's Execute() method. </p>
<p>However, if it encounters a line containing </p>
<pre><code>Log.LogMessage("some message here");
</code><... | [
{
"answer_id": 274660,
"author": "evilhomer",
"author_id": 2806,
"author_profile": "https://Stackoverflow.com/users/2806",
"pm_score": 3,
"selected": false,
"text": "<p>If you have implemented the interface ITask you will have to initialise the Log class yourself.</p>\n\n<p>Otherwise you... | 2008/11/04 | [
"https://Stackoverflow.com/questions/260847",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30183/"
] | I have written a few MSBuild custom tasks that work well and are use in our CruiseControl.NET build process.
I am modifying one, and wish to unit test it by calling the Task's Execute() method.
However, if it encounters a line containing
```
Log.LogMessage("some message here");
```
it throws an InvalidOperationE... | You need to set the .BuildEngine property of the custom task you are calling.
You can set it to the same BuildEngine your current task is using to include the output seamlessly.
```
Task myCustomTask = new CustomTask();
myCustomTask.BuildEngine = this.BuildEngine;
myCustomTask.Execute();
``` |
260,857 | <p>I have a web application that's branded according to the user that's currently logged in. I'd like to change the favicon of the page to be the logo of the private label, but I'm unable to find any code or any examples of how to do this. Has anybody successfully done this before?</p>
<p>I'm picturing having a dozen ... | [
{
"answer_id": 260873,
"author": "Jeff Sheldon",
"author_id": 33910,
"author_profile": "https://Stackoverflow.com/users/33910",
"pm_score": 4,
"selected": false,
"text": "<p>The favicon is declared in the head tag with something like:</p>\n\n<pre><code><link rel=\"shortcut icon\" type... | 2008/11/04 | [
"https://Stackoverflow.com/questions/260857",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8114/"
] | I have a web application that's branded according to the user that's currently logged in. I'd like to change the favicon of the page to be the logo of the private label, but I'm unable to find any code or any examples of how to do this. Has anybody successfully done this before?
I'm picturing having a dozen icons in a... | Why not?
```
var link = document.querySelector("link[rel~='icon']");
if (!link) {
link = document.createElement('link');
link.rel = 'icon';
document.getElementsByTagName('head')[0].appendChild(link);
}
link.href = 'https://stackoverflow.com/favicon.ico';
``` |
260,915 | <p>I know how to create an array of structs but with a predefined size. However is there a way to create a dynamic array of structs such that the array could get bigger?</p>
<p>For example:</p>
<pre><code> typedef struct
{
char *str;
} words;
main()
{
words x[100]; // I do not want... | [
{
"answer_id": 260932,
"author": "coobird",
"author_id": 17172,
"author_profile": "https://Stackoverflow.com/users/17172",
"pm_score": 4,
"selected": false,
"text": "<p>If you want to dynamically allocate arrays, you can use <a href=\"http://en.wikipedia.org/wiki/Malloc\" rel=\"noreferre... | 2008/11/04 | [
"https://Stackoverflow.com/questions/260915",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31274/"
] | I know how to create an array of structs but with a predefined size. However is there a way to create a dynamic array of structs such that the array could get bigger?
For example:
```
typedef struct
{
char *str;
} words;
main()
{
words x[100]; // I do not want to use this, I want ... | You've tagged this as C++ as well as C.
If you're using C++ things are a lot easier. The standard template library has a template called vector which allows you to dynamically build up a list of objects.
```
#include <stdio.h>
#include <vector>
typedef std::vector<char*> words;
int main(int argc, char** argv) {
... |
260,945 | <p>This should be easy, but I'm having a hard time finding the easiest solution.</p>
<p>I need an <code>NSString</code> that is equal to another string concatenated with itself a given number of times.</p>
<p>For a better explanation, consider the following python example:</p>
<pre><code>>> original = "abc"
"a... | [
{
"answer_id": 260969,
"author": "Mike McMaster",
"author_id": 544,
"author_profile": "https://Stackoverflow.com/users/544",
"pm_score": 3,
"selected": false,
"text": "<pre><code>NSString *original = @\"abc\";\nint times = 2;\n\n// Capacity does not limit the length, it's just an initial... | 2008/11/04 | [
"https://Stackoverflow.com/questions/260945",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2954/"
] | This should be easy, but I'm having a hard time finding the easiest solution.
I need an `NSString` that is equal to another string concatenated with itself a given number of times.
For a better explanation, consider the following python example:
```
>> original = "abc"
"abc"
>> times = 2
2
>> result = original * tim... | There is a method called `stringByPaddingToLength:withString:startingAtIndex:`:
```
[@"" stringByPaddingToLength:100 withString: @"abc" startingAtIndex:0]
```
Note that if you want 3 abc's, than use 9 (`3 * [@"abc" length]`) or create category like this:
```
@interface NSString (Repeat)
- (NSString *)repeatTimes:(... |
260,962 | <p>To trim the leading spaces we are using strmove. But we were advised to use strlmove instead of strmove. I have read and used strlcpy and strlcat. Whether strlmove does the similar functionality and what all are its advantages?</p>
<p>Edit 1: Thank you Mike B and Chris Young. This is how we use strlcpy.</p>
<pre><... | [
{
"answer_id": 260972,
"author": "Chris Young",
"author_id": 9417,
"author_profile": "https://Stackoverflow.com/users/9417",
"pm_score": 2,
"selected": false,
"text": "<p>strmove, strlmove, strlcpy, strlcat are all <strong>not</strong> standard C functions, so I can't comment on what the... | 2008/11/04 | [
"https://Stackoverflow.com/questions/260962",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18657/"
] | To trim the leading spaces we are using strmove. But we were advised to use strlmove instead of strmove. I have read and used strlcpy and strlcat. Whether strlmove does the similar functionality and what all are its advantages?
Edit 1: Thank you Mike B and Chris Young. This is how we use strlcpy.
```
size_t strlcpy(c... | As [Chris Young mentions](https://stackoverflow.com/questions/260962/what-is-the-advantage-of-strlmove-vs-strmove-in-c#260972), these routines are not standard (or as far as I known in wide, common use) so I can't be 100% certain with more specifics, but:
Typically the `strl()` variations of `str()` routines take an a... |
260,986 | <p>I have a text file which contains some data. I am trying to search for EA in <strong>ID column only</strong> and prints the whole row. But the code recognize all EA and prints all rows. What code I should add to satisfy the condition? Thanks Again:-)!</p>
<p>DATA: <br>
Name Age ID <br>
---------------------<br>
... | [
{
"answer_id": 260995,
"author": "Paige Ruten",
"author_id": 813,
"author_profile": "https://Stackoverflow.com/users/813",
"pm_score": 2,
"selected": false,
"text": "<p>You almost had it, I think this should work:</p>\n\n<pre><code>file='save.txt';\nopen(F,$file)||die(\"Could not open $f... | 2008/11/04 | [
"https://Stackoverflow.com/questions/260986",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28607/"
] | I have a text file which contains some data. I am trying to search for EA in **ID column only** and prints the whole row. But the code recognize all EA and prints all rows. What code I should add to satisfy the condition? Thanks Again:-)!
DATA:
Name Age ID
---------------------
KRISTE,22,**EA**2008
J**EA... | You should post the actual sample program you are using to illustrate the problem. Here's your cleansed program:
```
use strict;
use warnings;
use CGI;
my $EA = param('keyword');
my $file = 'save.txt';
open my $fh, "<", $file or die "Could not open $file: $!";
while( $line=<$fh> ) {
if( $line=~ m/$EA/i ) {
... |
261,004 | <p>I've got an old classic ASP site that connects to a local sql server 2000 instance. We're moving the db to a new box, and the port is non standard for sql (out of my control). .NET connection strings handle the port number fine by adding it with ,1999 after the server name/IP. The classic ASP connection string isn't... | [
{
"answer_id": 261026,
"author": "jwalkerjr",
"author_id": 689,
"author_profile": "https://Stackoverflow.com/users/689",
"pm_score": 0,
"selected": false,
"text": "<p>I think we need more information. What are you using to connect to the database? ODBC? OLE DB? Are you connecting through... | 2008/11/04 | [
"https://Stackoverflow.com/questions/261004",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1786/"
] | I've got an old classic ASP site that connects to a local sql server 2000 instance. We're moving the db to a new box, and the port is non standard for sql (out of my control). .NET connection strings handle the port number fine by adding it with ,1999 after the server name/IP. The classic ASP connection string isn't wo... | The solution was installing the SQL Native Driver from MS, then updating the connection string to the following:
```
Driver={SQL Native Client};Server=xxx.xxx.xxx.xxx,port;Database=dbname;Uid=dbuser;Pwd=dbpassword
```
I originally couldn't get it working with the SQL Native Client because of a firewall issue that wa... |
261,045 | <p>I just upgraded to Eclipse 3.4 for the second time and I think its for good now. The first time (right when it was released) was too buggy for me to stomach (mainly the PDT 2.0 plug-in); but now it seems to be all worked out.</p>
<p>My problem is the Javascript validator. If I define a class in one JS file in my pr... | [
{
"answer_id": 261760,
"author": "Jonny Buchanan",
"author_id": 6760,
"author_profile": "https://Stackoverflow.com/users/6760",
"pm_score": 3,
"selected": false,
"text": "<p>Unfortunately, you might just have to scrap the JavaScript validation.</p>\n\n<p>In my experience, the JavaScript ... | 2008/11/04 | [
"https://Stackoverflow.com/questions/261045",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I just upgraded to Eclipse 3.4 for the second time and I think its for good now. The first time (right when it was released) was too buggy for me to stomach (mainly the PDT 2.0 plug-in); but now it seems to be all worked out.
My problem is the Javascript validator. If I define a class in one JS file in my project, the... | Looks like this problem is due to the default browser for Eclipse not having the required libraries.
Try below steps to add the required library:
Project -> Properties -> JavaScript -> JavaScript Libraries -> Libraries(tab) -> Add Runtime Library -> select 'Internet Explorer Library'
This should resolve the issue. It... |
261,046 | <p>I am maintaining a website with currently about 800 concurrent users. The business plan says that this number will be 10x higher in one year.</p>
<p>This is my current configuration:</p>
<pre><code><Connector port="8080" address="${jboss.bind.address}"
maxThreads="500" maxHttpHeaderSize="8192"
emptySessionP... | [
{
"answer_id": 261109,
"author": "Yuval F",
"author_id": 1702,
"author_profile": "https://Stackoverflow.com/users/1702",
"pm_score": 1,
"selected": false,
"text": "<p>You can tune this using <a href=\"http://jakarta.apache.org/jmeter/\" rel=\"nofollow noreferrer\">JMeter</a>. I think muc... | 2008/11/04 | [
"https://Stackoverflow.com/questions/261046",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2554/"
] | I am maintaining a website with currently about 800 concurrent users. The business plan says that this number will be 10x higher in one year.
This is my current configuration:
```
<Connector port="8080" address="${jboss.bind.address}"
maxThreads="500" maxHttpHeaderSize="8192"
emptySessionPath="true" protocol="HTT... | I think that putting tomcat in Apache Http server is much more robust and faster approach. here are the pros & cons taken from <http://wiki.apache.org/tomcat/FAQ/Connectors>
Why should I integrate Apache with Tomcat? (or not)
There are many reasons to integrate Tomcat with Apache. And there are reasons why it should ... |
261,050 | <p>I'm having an issue with a standard ASP.NET page that has a TextBox and a RequiredFieldValidator. The steps to reproduce are quite simple:</p>
<ol>
<li>Place a TextBox on a page</li>
<li>Place a RequiredFieldValidator on the page</li>
<li>Point the RequiredFieldValidator at the TextBox</li>
<li>Run the app</li>
<l... | [
{
"answer_id": 261082,
"author": "Jake",
"author_id": 24730,
"author_profile": "https://Stackoverflow.com/users/24730",
"pm_score": 2,
"selected": false,
"text": "<p>did you set the EnableClientScript attribute/property to true?\ndo you have a default value for the text box? if so you ne... | 2008/11/04 | [
"https://Stackoverflow.com/questions/261050",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1462735/"
] | I'm having an issue with a standard ASP.NET page that has a TextBox and a RequiredFieldValidator. The steps to reproduce are quite simple:
1. Place a TextBox on a page
2. Place a RequiredFieldValidator on the page
3. Point the RequiredFieldValidator at the TextBox
4. Run the app
5. Tab away from the TextBox the Requir... | Is it possible this behavior is by design to suppress the appearance of validation controls until user input?
Generally speaking, Validate() gets called whenever a control is clicked that has CausesValidation set to true, like a submit button.
In any case, a poor mans work around, you *could* call the page Validate(... |
261,062 | <p>Although I grasp the concept of Bitwise Operators, I can't say that I have come across many use cases during the webdevelopment process at which I had to resort to using Bitwise Operators.</p>
<ul>
<li>Do you use Bitwise Operators?</li>
<li>Why do you use them?</li>
<li>What are some example use cases?</li>
</ul>
... | [
{
"answer_id": 261073,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 7,
"selected": true,
"text": "<p>My main use for bitwise operators could be relevant anywhere - representing a set of flags. For instance, you might ha... | 2008/11/04 | [
"https://Stackoverflow.com/questions/261062",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11568/"
] | Although I grasp the concept of Bitwise Operators, I can't say that I have come across many use cases during the webdevelopment process at which I had to resort to using Bitwise Operators.
* Do you use Bitwise Operators?
* Why do you use them?
* What are some example use cases?
Please remember that this question is s... | My main use for bitwise operators could be relevant anywhere - representing a set of flags. For instance, you might have an integer in the database representing a set of security permissions for a user, and in your web app you would have to check those before continuing.
Those tend to only require `&` and `|` - e.g.
... |
261,086 | <p>I am using a fictional example for this. Say, I have a Widget class like:</p>
<pre><code>abstract class Widget
{
Widget parent;
}
</code></pre>
<p>Now, my other classes would be derived from this Widget class, but suppose I want to put some constraint in the class while defining the derived types such that only a ... | [
{
"answer_id": 261104,
"author": "chakrit",
"author_id": 3055,
"author_profile": "https://Stackoverflow.com/users/3055",
"pm_score": 0,
"selected": false,
"text": "<p>I don't think there is a language mechanism that would allow you to do that.</p>\n\n<p>However, you might want to use a <... | 2008/11/04 | [
"https://Stackoverflow.com/questions/261086",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6621/"
] | I am using a fictional example for this. Say, I have a Widget class like:
```
abstract class Widget
{
Widget parent;
}
```
Now, my other classes would be derived from this Widget class, but suppose I want to put some constraint in the class while defining the derived types such that only a particular "type" of widge... | You should be able to use the code you've got by still having the non-generic class `Widget` and making `Widget<T>` derive from it:
```
public abstract class Widget
{
}
public abstract class Widget<T> : Widget where T : Widget
{
}
```
You then need to work out what belongs in the generic class and what belongs in t... |
261,089 | <p>how is it advisable to control the cpu utilization during run time ?</p>
<p>poll the cpu load and insert sleeps ?</p>
| [
{
"answer_id": 261123,
"author": "artur02",
"author_id": 13937,
"author_profile": "https://Stackoverflow.com/users/13937",
"pm_score": 2,
"selected": false,
"text": "<p>I'd recommend OS functionality. There are performance counters and WinAPI functions for this on Windows.</p>\n\n<p>Here... | 2008/11/04 | [
"https://Stackoverflow.com/questions/261089",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/195/"
] | how is it advisable to control the cpu utilization during run time ?
poll the cpu load and insert sleeps ? | I'd recommend OS functionality. There are performance counters and WinAPI functions for this on Windows.
Here is an example using **performance counters** from [BCL Team Blog](http://blogs.msdn.com/bclteam/archive/2006/06/06/619284.aspx):
```
foreach (Process proc in Process.GetProcesses()) {
using (PerformanceCo... |
261,092 | <p>What are all <a href="http://en.wikipedia.org/wiki/Hayes_command_set" rel="nofollow noreferrer">AT</a> commands required for <a href="http://en.wikipedia.org/wiki/General_Packet_Radio_Service" rel="nofollow noreferrer">GPRS</a> communication?</p>
| [
{
"answer_id": 261115,
"author": "Adam Davis",
"author_id": 2915,
"author_profile": "https://Stackoverflow.com/users/2915",
"pm_score": 1,
"selected": false,
"text": "<p>It depends quite a bit on:</p>\n\n<ul>\n<li>The modem</li>\n<li>How much of the modem's stack you plan on using</li>\n... | 2008/11/04 | [
"https://Stackoverflow.com/questions/261092",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | What are all [AT](http://en.wikipedia.org/wiki/Hayes_command_set) commands required for [GPRS](http://en.wikipedia.org/wiki/General_Packet_Radio_Service) communication? | A more specific answer, if you're using a MultiTech Multimodem GPRS (or similar) and Tmobile's internet service (one of the higher tiers usually used with laptops). The uppercase names starting with "M" were the names of the states in the modem control state machine I was using. The data I was collecting was simple GPS... |
261,125 | <p>I launch a child process in Java as follows:</p>
<pre><code>final String[] cmd = {"<childProcessName>"};
Process process = Runtime.getRuntime().exec(cmd);
</code></pre>
<p>It now runs in the background. All good and fine. </p>
<p>If my program now crashes (it <em>is</em> still in dev :-)) the child process ... | [
{
"answer_id": 261133,
"author": "Steve McLeod",
"author_id": 2959,
"author_profile": "https://Stackoverflow.com/users/2959",
"pm_score": 3,
"selected": false,
"text": "<p>I worked it out myself already. I add a shutdown hook, as follows:</p>\n\n<pre><code>final String[] cmd = {\"<chi... | 2008/11/04 | [
"https://Stackoverflow.com/questions/261125",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2959/"
] | I launch a child process in Java as follows:
```
final String[] cmd = {"<childProcessName>"};
Process process = Runtime.getRuntime().exec(cmd);
```
It now runs in the background. All good and fine.
If my program now crashes (it *is* still in dev :-)) the child process still seems to hang around. How can I make it ... | As you said, [addShutdownHook](https://web.archive.org/web/20080310051714/http://www.onjava.com/pub/a/onjava/2003/03/26/shutdownhook.html?page=2) is the way to go.
BUT:
* There's no real guarantee that your shutdown hooks are executed if the program terminates. Someone could kill the Java process and in that case you... |
261,190 | <p>I am rendering a rails partial and I want to alternate the background color when it renders the partial. I know that is not super clear so here is an example of what I want to do:</p>
Row One grey Background
Row Two yellow background
Row Three grey Background
Row Four yellow background
<ul>
<li>sorry st... | [
{
"answer_id": 261204,
"author": "Kristian",
"author_id": 23246,
"author_profile": "https://Stackoverflow.com/users/23246",
"pm_score": 5,
"selected": true,
"text": "<p>You could use the Cycle helper. Something like this:</p>\n\n<pre><code><tr class=\"<%= cycle(\"even\", \"odd\") %... | 2008/11/04 | [
"https://Stackoverflow.com/questions/261190",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5004/"
] | I am rendering a rails partial and I want to alternate the background color when it renders the partial. I know that is not super clear so here is an example of what I want to do:
Row One grey Background
Row Two yellow background
Row Three grey Background
Row Four yellow background
* sorry stackoverflow seams to p... | You could use the Cycle helper. Something like this:
```
<tr class="<%= cycle("even", "odd") %>">
<td><%= row.name %></td>
</tr>
```
Or in your case use bgcolor instead, although i would recomend using css classes.
You can cycle through more than two values: cycle(‘first’, ‘second’, ‘third’, ‘and\_more’).
There... |
261,202 | <p>I've written a little web site in my effort to learn vb.net and asp.net, fairly happy with it so rented some space and uploaded it, it was written using asp.net express edition 2008 and sql server express .... I've uploaded it and I've found that it was written in .NET 3.5 and my host only deals with 2.01 ... I've s... | [
{
"answer_id": 261208,
"author": "Yooakim",
"author_id": 6536,
"author_profile": "https://Stackoverflow.com/users/6536",
"pm_score": 1,
"selected": false,
"text": "<p>If the probllem is that you can not access your SQL Server it may be that you are using a trusted connection to it?</p>\n... | 2008/11/04 | [
"https://Stackoverflow.com/questions/261202",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32336/"
] | I've written a little web site in my effort to learn vb.net and asp.net, fairly happy with it so rented some space and uploaded it, it was written using asp.net express edition 2008 and sql server express .... I've uploaded it and I've found that it was written in .NET 3.5 and my host only deals with 2.01 ... I've sort... | Are you using the SqlMembershipProvider to store your users in your database? Check your config file's section and make sure the connectionStringName refers to the name of your connection string. |
261,215 | <p>I need to write the content of a map (key is ID of int, value is of self-defined struct) into a file, and load it from the file later on. Can I do it in MFC with CArchive?</p>
<p>Thank you!</p>
| [
{
"answer_id": 261239,
"author": "Pieter",
"author_id": 5822,
"author_profile": "https://Stackoverflow.com/users/5822",
"pm_score": 1,
"selected": false,
"text": "<p>I don't know much about MFC, but your problem is rather trivially solved using <a href=\"http://www.boost.org/doc/libs/1_3... | 2008/11/04 | [
"https://Stackoverflow.com/questions/261215",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26404/"
] | I need to write the content of a map (key is ID of int, value is of self-defined struct) into a file, and load it from the file later on. Can I do it in MFC with CArchive?
Thank you! | In MFC, I believe it's easiest to first serialize the size of the map, and then simply iterate through all the elements.
You didn't specify if you use `std::map` or MFC's `CMap`, but a version based on `std::map` could look like this:
```
void MyClass::Serialize(CArchive& archive)
{
CObject::Serialize(archive);
i... |
261,219 | <p>I'm having a bit of trouble trying to get class variables to work in javascript. </p>
<p>I thought that I understood the prototype inheritance model, but obviously not. I assumed that since prototypes will be shared between objects then so will their variables.</p>
<p>This is why this bit of code confuses me.</... | [
{
"answer_id": 261241,
"author": "Chei",
"author_id": 11411,
"author_profile": "https://Stackoverflow.com/users/11411",
"pm_score": 1,
"selected": false,
"text": "<p>If you instantiate that class (<code>a = new classA</code>), then modifying that instance <code>a</code> won't change the ... | 2008/11/04 | [
"https://Stackoverflow.com/questions/261219",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28486/"
] | I'm having a bit of trouble trying to get class variables to work in javascript.
I thought that I understood the prototype inheritance model, but obviously not. I assumed that since prototypes will be shared between objects then so will their variables.
This is why this bit of code confuses me.
What is the correct ... | ```
I assumed that since prototypes will be shared between objects then so will their variables.
```
They are, but this:
```
a.shared++
```
is not doing what you think it's doing. It's in fact (approximately) sugar syntax for:
```
(a.shared= a.shared+1)-1
```
(the -1 being to return the pre-increment value, not... |
261,234 | <p>Let's say I have an array of lots of values (C++ syntax, sorry):</p>
<pre><code>vector<double> x(100000);
</code></pre>
<p>This array is sorted such that <code>x[n] > x[n-1]</code>.</p>
<p>I would like a function to retrieve an array of all values in the range [a, b] (that's inclusive). Some interface li... | [
{
"answer_id": 261245,
"author": "Alnitak",
"author_id": 6782,
"author_profile": "https://Stackoverflow.com/users/6782",
"pm_score": 0,
"selected": false,
"text": "<p>You already appear to know that a binary search can be used to find the range, and implementations of those are easily fo... | 2008/11/04 | [
"https://Stackoverflow.com/questions/261234",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/338/"
] | Let's say I have an array of lots of values (C++ syntax, sorry):
```
vector<double> x(100000);
```
This array is sorted such that `x[n] > x[n-1]`.
I would like a function to retrieve an array of all values in the range [a, b] (that's inclusive). Some interface like:
```
void subarray(const double a, const double b... | What you're asking is a bit confusing regarding the the exact range properties and the types. However, you can tweak the following C++ code to suit your needs. The basic intuition is to use lower\_bound and upper\_bound to find the positions in the array that delineate the range you're looking for.
```
void subarray(c... |
261,237 | <p>How do I create an Application Pool on IIS 6.0 using a PowerShell script?</p>
<p>This is what I have come up with so far ...</p>
<pre><code>$appPool = [wmiclass] "root\MicrosoftIISv2:IIsApplicationPool"
</code></pre>
<p>Thanks</p>
| [
{
"answer_id": 263843,
"author": "Steven Murawski",
"author_id": 1233,
"author_profile": "https://Stackoverflow.com/users/1233",
"pm_score": 4,
"selected": true,
"text": "<p>It isn't the most obvious process, but here is what worked for me..</p>\n\n<pre><code>$AppPoolSettings = [wmiclass... | 2008/11/04 | [
"https://Stackoverflow.com/questions/261237",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10784/"
] | How do I create an Application Pool on IIS 6.0 using a PowerShell script?
This is what I have come up with so far ...
```
$appPool = [wmiclass] "root\MicrosoftIISv2:IIsApplicationPool"
```
Thanks | It isn't the most obvious process, but here is what worked for me..
```
$AppPoolSettings = [wmiclass]'root\MicrosoftIISv2:IISApplicationPoolSetting'
$NewPool = $AppPoolSettings.CreateInstance()
$NewPool.Name = 'W3SVC/AppPools/MyAppPool'
$Result = $NewPool.Put()
```
You might get an error with the call to Put(), but ... |
261,271 | <p>I'd like to compare two consecutive elements in a std::list while iterating through the list. What is the proper way to access element i+1 while my iterator is at element i?
Thanks
Cobe</p>
| [
{
"answer_id": 261277,
"author": "C. K. Young",
"author_id": 13,
"author_profile": "https://Stackoverflow.com/users/13",
"pm_score": 3,
"selected": false,
"text": "<p>Boost has a utility called <a href=\"http://www.boost.org/libs/utility/utility.htm\" rel=\"nofollow noreferrer\"><code>ne... | 2008/11/04 | [
"https://Stackoverflow.com/questions/261271",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'd like to compare two consecutive elements in a std::list while iterating through the list. What is the proper way to access element i+1 while my iterator is at element i?
Thanks
Cobe | STL provide the adjacent\_find() algorithm that can be used to find two consecutive equal elements. There is also a version with a custom predicate.
These are the prototypes:
```
template <class ForwardIterator>
ForwardIterator adjacent_find ( ForwardIterator first, ForwardIterator last );
template <class Forward... |
261,296 | <p>I have a batch file (in windows XP, with command extension activated) with the following line:</p>
<pre><code>for /f %%s in ('type version.txt') do set VERSION=%%s
</code></pre>
<p>On some computer, it works just fine (as illustrated by <a href="https://stackoverflow.com/questions/130116/dos-batch-commands-to-read... | [
{
"answer_id": 261299,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 4,
"selected": true,
"text": "<p>I got a first empiric answer:</p>\n\n<pre><code>for /f %%s in (version.txt) do ...\n</code></pre>\n\n<p>works just fine, on e... | 2008/11/04 | [
"https://Stackoverflow.com/questions/261296",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6309/"
] | I have a batch file (in windows XP, with command extension activated) with the following line:
```
for /f %%s in ('type version.txt') do set VERSION=%%s
```
On some computer, it works just fine (as illustrated by [this SO question](https://stackoverflow.com/questions/130116/dos-batch-commands-to-read-first-line-from... | I got a first empiric answer:
```
for /f %%s in (version.txt) do ...
```
works just fine, on every computer.
It seems `for /f` works with a filename, not with any dos command like 'type filename'.
However, it is not true for all my client's computer (on some, the 'type filename' works fine)
If you want 15 (easy ?... |
261,316 | <p>I have created a report in MS Access report and write some VBA code to retrive data and show the report in MS-Word format.
But while generate the report on runtime, the report first show or flash the report design view for few seconds and the report will get generated. </p>
<p>I would like to find a solution to av... | [
{
"answer_id": 261489,
"author": "Fionnuala",
"author_id": 2548,
"author_profile": "https://Stackoverflow.com/users/2548",
"pm_score": 1,
"selected": false,
"text": "<p>It seems you are opening the report in design view in order to change some property. It may be possible to avoid this, ... | 2008/11/04 | [
"https://Stackoverflow.com/questions/261316",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18792/"
] | I have created a report in MS Access report and write some VBA code to retrive data and show the report in MS-Word format.
But while generate the report on runtime, the report first show or flash the report design view for few seconds and the report will get generated.
I would like to find a solution to avoid this f... | What happens if you try this code:
```
Dim strReport As Report
strReport = rst!Argument
If SysCmd(acSysCmdGetObjectState, acReport, strReport) Then
DoCmd.Close acReport, strReport
End If
DoCmd.OpenReport strReport, acPreview
```
What that code does is check to see if the report is already open... |
261,336 | <p>If I declare a temporary auto deleted character buffer using</p>
<pre><code>std::auto_ptr<char> buffer(new char[n]);
</code></pre>
<p>then the buffer is automatically deleted when the buffer goes out of scope. I would assume that the buffer is deleted using delete.</p>
<p>However the buffer was created usin... | [
{
"answer_id": 261352,
"author": "Stephen Veiss",
"author_id": 28097,
"author_profile": "https://Stackoverflow.com/users/28097",
"pm_score": 5,
"selected": true,
"text": "<p>The behaviour of calling delete on a pointer allocated with new[] is <a href=\"https://isocpp.org/wiki/faq/freesto... | 2008/11/04 | [
"https://Stackoverflow.com/questions/261336",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/259/"
] | If I declare a temporary auto deleted character buffer using
```
std::auto_ptr<char> buffer(new char[n]);
```
then the buffer is automatically deleted when the buffer goes out of scope. I would assume that the buffer is deleted using delete.
However the buffer was created using new[], and so strictly speaking the b... | The behaviour of calling delete on a pointer allocated with new[] is [undefined](https://isocpp.org/wiki/faq/freestore-mgmt#delete-array). As you assumed, auto\_ptr [does call delete](http://www.gotw.ca/conv/001.htm) when the smart pointer goes out of scope. It's not just memory leaks you have to worry about -- crashes... |
261,338 | <p>Talking from a 'best practice' point of view, what do you think is the best way to insert HTML using PHP. For the moment I use one of the following methods (mostly the latter), but I'm curious to know which you think is best.</p>
<pre><code><?php
if($a){
?>
[SOME MARKUP]
<?php
}
else{
?>
[SOME OTH... | [
{
"answer_id": 261341,
"author": "Ken",
"author_id": 20074,
"author_profile": "https://Stackoverflow.com/users/20074",
"pm_score": 3,
"selected": false,
"text": "<p>The most important consideration is keeping the logic separate from the presentation - less coupling will make future chang... | 2008/11/04 | [
"https://Stackoverflow.com/questions/261338",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20603/"
] | Talking from a 'best practice' point of view, what do you think is the best way to insert HTML using PHP. For the moment I use one of the following methods (mostly the latter), but I'm curious to know which you think is best.
```
<?php
if($a){
?>
[SOME MARKUP]
<?php
}
else{
?>
[SOME OTHER MARKUP]
<?php
}
?>
`... | If you are going to do things that way, you want to separate your logic and design, true.
But you don't need to use Smarty to do this.
Priority is about mindset. I have seen people do shocking things in Smarty, and it eventually turns into people developing sites **in** Smarty, and then some bright spark will decid... |
261,345 | <p>How do I get the complete request URL (including query string) in my controller? Is it a matter of concatenating my URL and form parameters or is there a better way.</p>
<p>I checked <a href="https://stackoverflow.com/questions/40680/how-do-i-get-the-full-url-of-the-page-i-am-on-in-c">this</a> question, but it seem... | [
{
"answer_id": 261411,
"author": "Roger Lipscombe",
"author_id": 8446,
"author_profile": "https://Stackoverflow.com/users/8446",
"pm_score": 2,
"selected": false,
"text": "<p>You can get at the current Request object by using:</p>\n\n<pre><code>HttpContext.Current.Request\n</code></pre>\... | 2008/11/04 | [
"https://Stackoverflow.com/questions/261345",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11333/"
] | How do I get the complete request URL (including query string) in my controller? Is it a matter of concatenating my URL and form parameters or is there a better way.
I checked [this](https://stackoverflow.com/questions/40680/how-do-i-get-the-full-url-of-the-page-i-am-on-in-c) question, but it seems not to be applicabl... | You can use [`Request.Url.PathAndQuery`](https://msdn.microsoft.com/en-us/library/system.uri.pathandquery(v=vs.110).aspx).
MVC5: use **Request.RequestUri.PathAndQuery** |
261,348 | <p>I want to share an object between my servlets and my webservice (JAX-WS) by storing it as a servlet context attribute. But how can I retrieve the servlet context from a web service?</p>
| [
{
"answer_id": 261349,
"author": "Jens Bannmann",
"author_id": 7641,
"author_profile": "https://Stackoverflow.com/users/7641",
"pm_score": 7,
"selected": true,
"text": "<p>The servlet context is made available by JAX-WS via the message context, which can be retrieved using the web servic... | 2008/11/04 | [
"https://Stackoverflow.com/questions/261348",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7641/"
] | I want to share an object between my servlets and my webservice (JAX-WS) by storing it as a servlet context attribute. But how can I retrieve the servlet context from a web service? | The servlet context is made available by JAX-WS via the message context, which can be retrieved using the web service context. Inserting the following member will cause JAX-WS to inject a reference to the web service context into your web service:
```
import javax.annotation.Resource;
import javax.servlet.ServletConte... |
261,351 | <p>I have a web page <code>x.php</code> (in a password protected area of my web site) which has a form and a button which uses the <code>POST</code> method to send the form data and opens <code>x.php#abc</code>. This works pretty well.</p>
<p>However, if the users decides to navigate back in Internet Explorer 7, all t... | [
{
"answer_id": 261403,
"author": "mkoeller",
"author_id": 33433,
"author_profile": "https://Stackoverflow.com/users/33433",
"pm_score": 2,
"selected": false,
"text": "<p>Firefox does this kind of caching. As I understand your question, you want IE7 to behave the way Firefox does. I think... | 2008/11/04 | [
"https://Stackoverflow.com/questions/261351",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4597/"
] | I have a web page `x.php` (in a password protected area of my web site) which has a form and a button which uses the `POST` method to send the form data and opens `x.php#abc`. This works pretty well.
However, if the users decides to navigate back in Internet Explorer 7, all the fields in the original `x.php` get clear... | IE *will* retain form contents on a back button click automatically, as long as:
* you haven't broken cacheing with a no-cache pragma or similar
* the form fields in question weren't dynamically created by script
You seem to have the cacheing in hand, so I'm guessing the latter may apply. (As mkoeller says, Firefox a... |
261,362 | <p>I've got an HTML "select" element which I'm updating dynamically with code something like this:</p>
<pre><code>var selector = document.getElementById('selectorId');
for (var i = 0; i < data.length; ++i)
{
var opt = document.createElement('option');
opt.value = data[i].id;
opt.text = data[i].name;
sel... | [
{
"answer_id": 261390,
"author": "Joeri Sebrechts",
"author_id": 20980,
"author_profile": "https://Stackoverflow.com/users/20980",
"pm_score": -1,
"selected": false,
"text": "<p>You could try replacing the entire select element from generated html code, or as a hack removing the element ... | 2008/11/04 | [
"https://Stackoverflow.com/questions/261362",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3974/"
] | I've got an HTML "select" element which I'm updating dynamically with code something like this:
```
var selector = document.getElementById('selectorId');
for (var i = 0; i < data.length; ++i)
{
var opt = document.createElement('option');
opt.value = data[i].id;
opt.text = data[i].name;
selector.appendChild... | Set the `innerHTML` property of the option objects, instead of their `text`.
```
var selector = document.getElementById('selectorId');
for (var i = 0; i < data.length; ++i)
{
var opt = document.createElement('option');
opt.value = data[i].id;
opt.innerHTML = data[i].name;
selector.appendChild(opt... |
261,368 | <p>How do you calculate the number of <code><td></code> elements in a particular <code><tr></code>?</p>
<p>I didn't specify id or name to access directly, we have to use the <code>document.getElementsByTagName</code> concept.</p>
| [
{
"answer_id": 261383,
"author": "Aron Rotteveel",
"author_id": 11568,
"author_profile": "https://Stackoverflow.com/users/11568",
"pm_score": 4,
"selected": true,
"text": "<p>You can use something like the following:</p>\n\n<pre><code>var rowIndex = 0; // rowindex, in this case the first... | 2008/11/04 | [
"https://Stackoverflow.com/questions/261368",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How do you calculate the number of `<td>` elements in a particular `<tr>`?
I didn't specify id or name to access directly, we have to use the `document.getElementsByTagName` concept. | You can use something like the following:
```
var rowIndex = 0; // rowindex, in this case the first row of your table
var table = document.getElementById('mytable'); // table to perform search on
var row = table.getElementsByTagName('tr')[rowIndex];
var cells = row.getElementsByTagName('td');
var cellCount = cells.len... |
261,374 | <p>What is the most efficient way to enumerate every cell in every sheet in a workbook?</p>
<p>The method below seems to work reasonably for a workbook with ~130,000 cells. On my machine it took ~26 seconds to open the file and ~5 seconds to enumerate the cells . However I'm no Excel expert and wanted to validate this... | [
{
"answer_id": 261412,
"author": "Tamas Czinege",
"author_id": 8954,
"author_profile": "https://Stackoverflow.com/users/8954",
"pm_score": 3,
"selected": true,
"text": "<p>Excel PIA Interop is really slow when you are doing things cell by cell.</p>\n\n<p>You should select the range you w... | 2008/11/04 | [
"https://Stackoverflow.com/questions/261374",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5182/"
] | What is the most efficient way to enumerate every cell in every sheet in a workbook?
The method below seems to work reasonably for a workbook with ~130,000 cells. On my machine it took ~26 seconds to open the file and ~5 seconds to enumerate the cells . However I'm no Excel expert and wanted to validate this code snip... | Excel PIA Interop is really slow when you are doing things cell by cell.
You should select the range you want to extract, like you did with the `Worksheet.UsedRange` property and then read the value of the whole range in one step, by invoking `get_Value()` (or just simply by reading the `Value` or `Value2` property, I... |
261,375 | <p>No doubt I'm missing something really simple here but I just can't see the problem with this query which is producing the following error:</p>
<pre><code>SQL query:
INSERT INTO ads(
ad_id, author, ad_date, category, title,
description, condition, price, fullname,
telephone, email, status, photo, photot... | [
{
"answer_id": 261380,
"author": "Alexander Kojevnikov",
"author_id": 712,
"author_profile": "https://Stackoverflow.com/users/712",
"pm_score": 3,
"selected": true,
"text": "<p>Shouldn't you use back ticks instead of single quotes in column names?</p>\n\n<pre><code>INSERT INTO ads( `ad_i... | 2008/11/04 | [
"https://Stackoverflow.com/questions/261375",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34019/"
] | No doubt I'm missing something really simple here but I just can't see the problem with this query which is producing the following error:
```
SQL query:
INSERT INTO ads(
ad_id, author, ad_date, category, title,
description, condition, price, fullname,
telephone, email, status, photo, photothumb
)
VALUES ... | Shouldn't you use back ticks instead of single quotes in column names?
```
INSERT INTO ads( `ad_id`, `author`, `ad_date`, `category`, `title`, `description`, `condition`, `price`, `fullname`, `telephone`, `email`, `status`, `photo`, `photothumb` )
VALUES (
NULL , 'justal', '1225790938', 'Windsurf Boards', 'test', 'tes... |
261,377 | <p>I apologize in advance for the long post...</p>
<p>I used to be able to build our VC++ solutions (we're on VS 2008) when we listed the STLPort include and library directories under VS Menu > Tools > Options > VC++ Directories > Directories for Include and Library files. However, we wanted to transition to a build ... | [
{
"answer_id": 261951,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>This is a link error. It doesn't have to do with your include paths.</p>\n\n<p>You either forgot to add MyClass.cpp to your... | 2008/11/04 | [
"https://Stackoverflow.com/questions/261377",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15515/"
] | I apologize in advance for the long post...
I used to be able to build our VC++ solutions (we're on VS 2008) when we listed the STLPort include and library directories under VS Menu > Tools > Options > VC++ Directories > Directories for Include and Library files. However, we wanted to transition to a build process tha... | Raymond Chen recently talked about this at [The Old New Thing](http://blogs.msdn.com/oldnewthing/archive/2008/12/29/9255240.aspx)-- one cause of these problems is that the library was compiled with one set of switches, but your app is using a different set. What you have to do is:
Get the exact symbol that the linker ... |
261,386 | <p>I'm new to Flex, and I'm trying to write a simple application. I have a file with an image and I want to display this image on a Graphics. How do I do this? I tried [Embed]-ding it and adding as a child to the component owning the Graphics', but I'm getting a "Type Coercion failed: cannot convert ... to mx.core.IUIC... | [
{
"answer_id": 261768,
"author": "hasseg",
"author_id": 4111,
"author_profile": "https://Stackoverflow.com/users/4111",
"pm_score": 4,
"selected": true,
"text": "<p>Off the top of my head I can think of two things that might help you (depending on what it is exactly that you're trying to... | 2008/11/04 | [
"https://Stackoverflow.com/questions/261386",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6533/"
] | I'm new to Flex, and I'm trying to write a simple application. I have a file with an image and I want to display this image on a Graphics. How do I do this? I tried [Embed]-ding it and adding as a child to the component owning the Graphics', but I'm getting a "Type Coercion failed: cannot convert ... to mx.core.IUIComp... | Off the top of my head I can think of two things that might help you (depending on what it is exactly that you're trying to achieve):
If you just want to display an image you've embedded, you can add an [Image](http://livedocs.adobe.com/flex/3/langref/mx/controls/Image.html) component to the stage and set the value of... |
261,387 | <p>I've noticed in many places in Java (C# included), that many "getter" methods are prefixed with "get" while many other aren't. I never noticed any kind of pattern Sun seems to be following. What are some guidelines or rules for using "get" in getter method names?</p>
| [
{
"answer_id": 261396,
"author": "Marko",
"author_id": 31141,
"author_profile": "https://Stackoverflow.com/users/31141",
"pm_score": 2,
"selected": false,
"text": "<p>\"get\" and \"set\" prefix pair in Java is used originally as a convention to denote java bean. Later, it become just an ... | 2008/11/04 | [
"https://Stackoverflow.com/questions/261387",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30323/"
] | I've noticed in many places in Java (C# included), that many "getter" methods are prefixed with "get" while many other aren't. I never noticed any kind of pattern Sun seems to be following. What are some guidelines or rules for using "get" in getter method names? | It comes down to semantics. Yes, C# has "properties" which give you a get/set 'method' stub... but functions (..."methods"...) in the .NET Framework that start with "Get" is supposed to clue the developer into the fact that some operation is happening for the sole purpose of getting some results.
You may think that's ... |
261,407 | <p>Currently I have a structure like this:</p>
<pre><code>A
|
+--B
|
+--C
</code></pre>
<p>It's mapped with one table per subclass using joined tables. For historic reasons I also use a discriminator, so the current situation is as described in <a href="http://www.hibernate.org/hib_docs/v3/reference/en-US/html/inheri... | [
{
"answer_id": 262654,
"author": "shyam",
"author_id": 7616,
"author_profile": "https://Stackoverflow.com/users/7616",
"pm_score": 4,
"selected": true,
"text": "<p><strong><em>not tested</em></strong> but, according to the link you posted if you are using hibernate3</p>\n\n<pre><code><... | 2008/11/04 | [
"https://Stackoverflow.com/questions/261407",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29549/"
] | Currently I have a structure like this:
```
A
|
+--B
|
+--C
```
It's mapped with one table per subclass using joined tables. For historic reasons I also use a discriminator, so the current situation is as described in [Section 9.1.3 of the Hibernate manual](http://www.hibernate.org/hib_docs/v3/reference/en-US/html/i... | ***not tested*** but, according to the link you posted if you are using hibernate3
```
<hibernate-mapping>
<class name="A" table="A">
<id name="id" type="long" column="a_id">
<generator class="native"/>
</id>
<discriminator column="discriminator_col" type="string"/>
<property name="" type=""/>
... |
261,431 | <p>I have a variable </p>
<pre><code>unsigned char* data = MyFunction();
</code></pre>
<p>how to find the length of data?</p>
| [
{
"answer_id": 261437,
"author": "kenny",
"author_id": 3225,
"author_profile": "https://Stackoverflow.com/users/3225",
"pm_score": 3,
"selected": false,
"text": "<p>Assuming its a <code>string</code></p>\n\n<pre><code>length = strlen( char* );\n</code></pre>\n\n<p>but it doesn't seem to ... | 2008/11/04 | [
"https://Stackoverflow.com/questions/261431",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a variable
```
unsigned char* data = MyFunction();
```
how to find the length of data? | Assuming its a `string`
```
length = strlen( char* );
```
but it doesn't seem to be...so there isn't a way *without* having the function return the length. |
261,449 | <p>I'm trying to do the classic Insert/Update scenario where I need to update existing rows in a database or insert them if they are not there.</p>
<p>I've found a <a href="https://stackoverflow.com/questions/13540/insert-update-stored-proc-on-sql-server">previous question on the subject</a>, but it deals with stored ... | [
{
"answer_id": 261466,
"author": "Sören Kuklau",
"author_id": 1600,
"author_profile": "https://Stackoverflow.com/users/1600",
"pm_score": 4,
"selected": true,
"text": "<p>The most efficient way is to do the <code>UPDATE</code>, then do an <code>INSERT</code> if <code>@@rowcount</code> is... | 2008/11/04 | [
"https://Stackoverflow.com/questions/261449",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30023/"
] | I'm trying to do the classic Insert/Update scenario where I need to update existing rows in a database or insert them if they are not there.
I've found a [previous question on the subject](https://stackoverflow.com/questions/13540/insert-update-stored-proc-on-sql-server), but it deals with stored procedures, which I'm... | The most efficient way is to do the `UPDATE`, then do an `INSERT` if `@@rowcount` is zero, [as explained in this previous answer](https://stackoverflow.com/questions/108403/solutions-for-insert-or-update-on-sql-server#108416). |
261,455 | <p>After reading a couple of answers and comments on some SQL questions here, and also hearing that a friend of mine works at a place which has a policy which bans them, I'm wondering if there's anything wrong with using backticks around field names in MySQL.</p>
<p>That is:</p>
<pre><code>SELECT `id`, `name`, `anoth... | [
{
"answer_id": 261467,
"author": "C. K. Young",
"author_id": 13,
"author_profile": "https://Stackoverflow.com/users/13",
"pm_score": 2,
"selected": false,
"text": "<p>Well, as far as I know, the whole purpose of using backticks is so you can use names that coincide with reserved keywords... | 2008/11/04 | [
"https://Stackoverflow.com/questions/261455",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9021/"
] | After reading a couple of answers and comments on some SQL questions here, and also hearing that a friend of mine works at a place which has a policy which bans them, I'm wondering if there's anything wrong with using backticks around field names in MySQL.
That is:
```
SELECT `id`, `name`, `anotherfield` ...
-- vs --... | Using backticks permits you to use alternative characters. In query writing it's not such a problem, but if one assumes you can just use backticks, I would assume it lets you get away with ridiculous stuff like
```
SELECT `id`, `my name`, `another field` , `field,with,comma`
```
Which does of course generate badly ... |
261,463 | <p>We have a couple of web servers using load balancer. Machines are running IIS6 on port 81. Externally, site is accessable using port 80. External name and name of the machine are different.</p>
<p>We're getting </p>
<pre><code>System.ServiceModel.EndpointNotFoundException: The message with To '<url>' cannot ... | [
{
"answer_id": 261498,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 1,
"selected": false,
"text": "<p>What is the specific load balancer? Using an F5 BIG-IP we got it working fairly easily, but we were using the same... | 2008/11/04 | [
"https://Stackoverflow.com/questions/261463",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28912/"
] | We have a couple of web servers using load balancer. Machines are running IIS6 on port 81. Externally, site is accessable using port 80. External name and name of the machine are different.
We're getting
```
System.ServiceModel.EndpointNotFoundException: The message with To '<url>' cannot be processed at the receive... | ```
[ServiceBehavior(AddressFilterMode=AddressFilterMode.Any)]
```
Putting this attribute on service solves the problem. |
261,512 | <p>I'm currently working with Db2 Enterprise Server V 8.2 with FixPak 10</p>
<p>And I want to retrieve list of all the open active connections with an instance.</p>
<p>In Oracle there is a utility program called "Top Session" which does the similar task. Is there any equivalent in DB2?</p>
| [
{
"answer_id": 261578,
"author": "Tamas Czinege",
"author_id": 8954,
"author_profile": "https://Stackoverflow.com/users/8954",
"pm_score": 2,
"selected": false,
"text": "<p>The command you seek is:</p>\n\n<pre><code>LIST APPLICATIONS\n</code></pre>\n\n<p>In the DB2 Command Center there i... | 2008/11/04 | [
"https://Stackoverflow.com/questions/261512",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34058/"
] | I'm currently working with Db2 Enterprise Server V 8.2 with FixPak 10
And I want to retrieve list of all the open active connections with an instance.
In Oracle there is a utility program called "Top Session" which does the similar task. Is there any equivalent in DB2? | CLP:
```
db2 list applications
```
QUERY:
```
SELECT * FROM SYSIBM.APPLICATIONS
SELECT * FROM SYSIBM.SESSION
``` |
261,515 | <p>I have a large set of files, some of which contain special characters in the filename (e.g. ä,ö,%, and others). I'd like a script file to iterate over these files and rename them removing the special characters. I don't really mind what it does, but it could replace them with underscores for example e.g.</p>
<p>Stö... | [
{
"answer_id": 261552,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 3,
"selected": false,
"text": "<p>Have you tried setting cmd.exe into another codepage before you feed the file names to gnupg? Issue <code>chcp 65001</c... | 2008/11/04 | [
"https://Stackoverflow.com/questions/261515",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9625/"
] | I have a large set of files, some of which contain special characters in the filename (e.g. ä,ö,%, and others). I'd like a script file to iterate over these files and rename them removing the special characters. I don't really mind what it does, but it could replace them with underscores for example e.g.
Störung%20.do... | Thanks to Tomalak who actually pointed me in the right direction. Thought I'd post here for completeness.
The problem seems to be that the codepage used by GPG is fixed (Latin I) independent of the codepage configured in the console. But once he pointed this out, I figured out how to workaraound this.
The trick is to... |
261,518 | <p>Here's the situation:</p>
<p>I have one VS2005 solution with two projects: MyDll (DLL), MyDllUnitTest (console EXE).</p>
<p>In MyDll I have a class called MyClass which is internal to the DLL and should not be exported. I want to test it in MyDllUnitTest, so I added a test suite class called MyClassTest, where I c... | [
{
"answer_id": 261579,
"author": "Ferruccio",
"author_id": 4086,
"author_profile": "https://Stackoverflow.com/users/4086",
"pm_score": 3,
"selected": true,
"text": "<p>I don't understand why you don't want to build it in your dll project. As long as both projects are using the same sourc... | 2008/11/04 | [
"https://Stackoverflow.com/questions/261518",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33982/"
] | Here's the situation:
I have one VS2005 solution with two projects: MyDll (DLL), MyDllUnitTest (console EXE).
In MyDll I have a class called MyClass which is internal to the DLL and should not be exported. I want to test it in MyDllUnitTest, so I added a test suite class called MyClassTest, where I create instances o... | I don't understand why you don't want to build it in your dll project. As long as both projects are using the same source file, they will both generate the same object file (assuming compiler options are set the same way).
If you want to test the dll without exporting the class itself (I presume this is because export... |
261,525 | <p>We're using Perforce and Visual Studio. Whenever we create a branch, some projects will not be bound to source control unless we use "Open from Source Control", but other projects work regardless. From my investigations, I know some of the things involved:</p>
<p>In our .csproj files, there are these settings:</p>
... | [
{
"answer_id": 268578,
"author": "Thomas L Holaday",
"author_id": 29403,
"author_profile": "https://Stackoverflow.com/users/29403",
"pm_score": 1,
"selected": false,
"text": "<p>I can answer the last one.</p>\n\n<p>In order to get source control bindings to work even when you create a ne... | 2008/11/04 | [
"https://Stackoverflow.com/questions/261525",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2283/"
] | We're using Perforce and Visual Studio. Whenever we create a branch, some projects will not be bound to source control unless we use "Open from Source Control", but other projects work regardless. From my investigations, I know some of the things involved:
In our .csproj files, there are these settings:
* <SccProject... | Introduction
============
I would disagree with the claim that Perforce integration in Visual Studio is "terrible". Rather, I'd define it as "out of the box experience is less than optimal" :-). The following sections discuss my understanding of the integration and recommendations for project/solution setup.
If you'r... |
261,536 | <p>I'm getting the following error when my win32 (c#) app is calling web services.</p>
<pre><code>The request failed with HTTP status 504: Gateway timeout server response timeout.
</code></pre>
<p>I understand 'I think' that this is because the upstream request does not get a response in a timely fashion.</p>
<p>But my... | [
{
"answer_id": 261562,
"author": "Toon Krijthe",
"author_id": 18061,
"author_profile": "https://Stackoverflow.com/users/18061",
"pm_score": 5,
"selected": false,
"text": "<p>CheckUpDown has <a href=\"http://www.checkupdown.com/status/E504.html\" rel=\"noreferrer\">a nice explanation of t... | 2008/11/04 | [
"https://Stackoverflow.com/questions/261536",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26098/"
] | I'm getting the following error when my win32 (c#) app is calling web services.
```
The request failed with HTTP status 504: Gateway timeout server response timeout.
```
I understand 'I think' that this is because the upstream request does not get a response in a timely fashion.
But my question is this? How do I ch... | You can't. The problem is not that your app is impatient and timing out; the problem is that an intermediate proxy is impatient and timing out. "The server, while acting as a gateway or proxy, did not receive a timely response from the upstream server specified by the URI." (<http://www.w3.org/Protocols/rfc2616/rfc2616... |
261,539 | <p>I've got a WCF service that uses a LinqToSql DataContext to fetch some information out of a database. The return type of the operation is IEnumerable<code><DomainObject</code>>, and I have a helper method that converts from the Table-derived LINQ object to a WCF data contract like so:</p>
<pre><code>[OperationCo... | [
{
"answer_id": 261555,
"author": "Timothy Khouri",
"author_id": 11917,
"author_profile": "https://Stackoverflow.com/users/11917",
"pm_score": 0,
"selected": false,
"text": "<p>Did you configure your \"<a href=\"http://msdn.microsoft.com/en-us/library/system.servicemodel.description.servi... | 2008/11/04 | [
"https://Stackoverflow.com/questions/261539",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32539/"
] | I've got a WCF service that uses a LinqToSql DataContext to fetch some information out of a database. The return type of the operation is IEnumerable`<DomainObject`>, and I have a helper method that converts from the Table-derived LINQ object to a WCF data contract like so:
```
[OperationContract]
public IEnumerable<D... | WCF does seem, at least in my experience, to do some magic with exceptions. I'm really not sure what it does with exceptions but I've found that if the FaultContract attribute is used to specify exceptions that the contract could throw, it'll at least give a bit more information to the client about the why the error oc... |
261,543 | <p>Is there a way to drop a validation that was set in Rails plugin (or included module)?
Let's say I have some model with module included in it:</p>
<pre><code>class User < ActiveRecord::Base
include SomeModuleWithValidations
# How to cancel validates_presence_of :something here?
end
module SomeModuleWithVali... | [
{
"answer_id": 261713,
"author": "Kristian",
"author_id": 23246,
"author_profile": "https://Stackoverflow.com/users/23246",
"pm_score": 1,
"selected": false,
"text": "<p>You could overload the validates_precense_of in the class. Something like:</p>\n\n<pre><code>def self.validates_presen... | 2008/11/04 | [
"https://Stackoverflow.com/questions/261543",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26123/"
] | Is there a way to drop a validation that was set in Rails plugin (or included module)?
Let's say I have some model with module included in it:
```
class User < ActiveRecord::Base
include SomeModuleWithValidations
# How to cancel validates_presence_of :something here?
end
module SomeModuleWithValidations
def sel... | See <http://casperfabricius.com/site/2008/12/06/removing-rails-validations-with-metaprogramming/> |
261,547 | <p>This query is related to <a href="https://stackoverflow.com/questions/259850/javascript-multiple-client-side-validations-on-same-event">this</a> one I asked yesterday.
I have a radio button list on my asp.net page defined as follows: </p>
<pre><code><asp:RadioButtonList ID="rdlSortBy" runat="server" RepeatDir... | [
{
"answer_id": 261632,
"author": "Adrian Clark",
"author_id": 148,
"author_profile": "https://Stackoverflow.com/users/148",
"pm_score": 1,
"selected": false,
"text": "<p>The <code>OnClick</code> code you are using to \"validate\" is being run and then the code which posts the form back w... | 2008/11/04 | [
"https://Stackoverflow.com/questions/261547",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13370/"
] | This query is related to [this](https://stackoverflow.com/questions/259850/javascript-multiple-client-side-validations-on-same-event) one I asked yesterday.
I have a radio button list on my asp.net page defined as follows:
```
<asp:RadioButtonList ID="rdlSortBy" runat="server" RepeatDirection="Horizontal" RepeatLayou... | I fixed this, the problem was that I was attaching the "onclick" of the RadioButtonList instead on the individual radio buttons.
This is the fix:
```
rdlSortBy.Items(0).Attributes("onclick") = "javascript:return isDirtied() && prepareSearch();"
rdlSortBy.Items(1).Attributes("onclick") = "javascript:return isDirti... |
261,559 | <p>I was wondering how to make a toolbar in MFC that used 24bit or 256 colour bitmaps rather than the horrible 16 colour ones.</p>
<p>Can anyone point me in the direction of some simple code?</p>
<p>Thanks</p>
| [
{
"answer_id": 261589,
"author": "Stu Mackellar",
"author_id": 28591,
"author_profile": "https://Stackoverflow.com/users/28591",
"pm_score": 5,
"selected": true,
"text": "<p>The reason this happens is that the MFC CToolbar class uses an image list internally that is initialised to use 16... | 2008/11/04 | [
"https://Stackoverflow.com/questions/261559",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18664/"
] | I was wondering how to make a toolbar in MFC that used 24bit or 256 colour bitmaps rather than the horrible 16 colour ones.
Can anyone point me in the direction of some simple code?
Thanks | The reason this happens is that the MFC CToolbar class uses an image list internally that is initialised to use 16 colours only. The solution is to create our own image list and tell the toolbar to use that instead. I know this will work for 256-colours, but I haven't tested it with higher bit-depths:
First, load a 25... |
261,572 | <p>I am building a FAQ module for my site and I want to be able to control single elements on the page even though they all have the same class. I believe this comes under siblings which I am not yet familiar with.</p>
<p>Basically I want the user to be able to click the question div and then when they click it the an... | [
{
"answer_id": 261596,
"author": "Pat",
"author_id": 238,
"author_profile": "https://Stackoverflow.com/users/238",
"pm_score": 3,
"selected": true,
"text": "<p>If I understand your question correctly, you should \nStart by setting all answers as hidden in the css:\n.answer {display:none;... | 2008/11/04 | [
"https://Stackoverflow.com/questions/261572",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26823/"
] | I am building a FAQ module for my site and I want to be able to control single elements on the page even though they all have the same class. I believe this comes under siblings which I am not yet familiar with.
Basically I want the user to be able to click the question div and then when they click it the answer div w... | If I understand your question correctly, you should
Start by setting all answers as hidden in the css:
.answer {display:none;}
Then you can use jquery to show the correct answer to the clicked questions :
```
$(document).ready ( function () {
$('.question').click(function() {
$(this).next('.answer').sho... |
261,580 | <p>This declaration causes an overflow in VBA:</p>
<pre><code>Const OVERFLOWS As Long = 10 * 60 * 60
</code></pre>
<p>whereas setting the value directly is fine:</p>
<pre><code>Const COMPILES_OK As Long = 36000
</code></pre>
<p>How do you persuade VBA to treat literal integers as longs?</p>
<p>Thanks</p>
| [
{
"answer_id": 261615,
"author": "xsl",
"author_id": 11387,
"author_profile": "https://Stackoverflow.com/users/11387",
"pm_score": 5,
"selected": true,
"text": "<p>Add the <code>long</code> suffix <code>&</code> to at least one number:</p>\n\n<pre><code>Const OVERFLOWS As Long = 10&a... | 2008/11/04 | [
"https://Stackoverflow.com/questions/261580",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1518/"
] | This declaration causes an overflow in VBA:
```
Const OVERFLOWS As Long = 10 * 60 * 60
```
whereas setting the value directly is fine:
```
Const COMPILES_OK As Long = 36000
```
How do you persuade VBA to treat literal integers as longs?
Thanks | Add the `long` suffix `&` to at least one number:
```
Const OVERFLOWS As Long = 10& * 60 * 60
```
Note that using the `CLNG` function to convert the values to `long` will not work, because VBA does not allow assigning the return value of a function to a constant. |
261,599 | <p>This code always works, even in different browsers:</p>
<pre><code>function fooCheck() {
alert(internalFoo()); // We are using internalFoo() here...
return internalFoo(); // And here, even though it has not been defined...
function internalFoo() { return true; } //...until here!
}
fooCheck();
</code></pre>... | [
{
"answer_id": 261605,
"author": "RailsSon",
"author_id": 30786,
"author_profile": "https://Stackoverflow.com/users/30786",
"pm_score": 2,
"selected": false,
"text": "<p>I have only used JavaScript a little. I am not sure if this will help, but it looks very similar to what you are talki... | 2008/11/04 | [
"https://Stackoverflow.com/questions/261599",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21648/"
] | This code always works, even in different browsers:
```
function fooCheck() {
alert(internalFoo()); // We are using internalFoo() here...
return internalFoo(); // And here, even though it has not been defined...
function internalFoo() { return true; } //...until here!
}
fooCheck();
```
I could not find a si... | The `function` declaration is magic and causes its identifier to be bound before anything in its code-block\* is executed.
This differs from an assignment with a `function` expression, which is evaluated in normal top-down order.
If you changed the example to say:
```
var internalFoo = function() { return true; };
... |
261,622 | <p>Is it possible to replace the standard broken image via CSS or using another technique? All my images are the same size and my have transparency.</p>
<p>I've tried to wrap all images with a div's background:</p>
<pre><code><div class="no_broken">
<img src="http://www.web.com/found.gif"/>
</div>... | [
{
"answer_id": 261635,
"author": "Ned Batchelder",
"author_id": 14343,
"author_profile": "https://Stackoverflow.com/users/14343",
"pm_score": 0,
"selected": false,
"text": "<p>As far as I know, there is no CSS property that controls the display of broken images. Maybe there are browser-... | 2008/11/04 | [
"https://Stackoverflow.com/questions/261622",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28150/"
] | Is it possible to replace the standard broken image via CSS or using another technique? All my images are the same size and my have transparency.
I've tried to wrap all images with a div's background:
```
<div class="no_broken">
<img src="http://www.web.com/found.gif"/>
</div>
<div class="no_broken">
<img src="h... | This works without CSS:
```
<img src="some.jpg" onerror="this.src='alternative.jpg';">
```
It seems to even work when Javascript is disabled. |
261,655 | <p>I have a list of tuples like this:</p>
<pre><code>[
('a', 1),
('a', 2),
('a', 3),
('b', 1),
('b', 2),
('c', 1),
]
</code></pre>
<p>I want to iterate through this keying by the first item, so, for example, I could print something like this:</p>
<pre><code>a 1 2 3
b 1 2
c 1
</code></pre>
<p>How would I go about do... | [
{
"answer_id": 261665,
"author": "Ned Batchelder",
"author_id": 14343,
"author_profile": "https://Stackoverflow.com/users/14343",
"pm_score": 7,
"selected": true,
"text": "<pre><code>l = [\n('a', 1),\n('a', 2),\n('a', 3),\n('b', 1),\n('b', 2),\n('c', 1),\n]\n\nd = {}\nfor x, y in l:\n ... | 2008/11/04 | [
"https://Stackoverflow.com/questions/261655",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18909/"
] | I have a list of tuples like this:
```
[
('a', 1),
('a', 2),
('a', 3),
('b', 1),
('b', 2),
('c', 1),
]
```
I want to iterate through this keying by the first item, so, for example, I could print something like this:
```
a 1 2 3
b 1 2
c 1
```
How would I go about doing this without keeping an item to track whether... | ```
l = [
('a', 1),
('a', 2),
('a', 3),
('b', 1),
('b', 2),
('c', 1),
]
d = {}
for x, y in l:
d.setdefault(x, []).append(y)
print d
```
produces:
```
{'a': [1, 2, 3], 'c': [1], 'b': [1, 2]}
``` |
261,660 | <p>I have a <code>TreeView</code> windows forms control with an <code>ImageList</code>, and I want some of the nodes to display images, but the others to not have images.</p>
<p>I <em>don't</em> want a blank space where the image should be. I <em>don't</em> want an image that looks like the lines that the TreeView wo... | [
{
"answer_id": 262396,
"author": "Martin Brown",
"author_id": 20553,
"author_profile": "https://Stackoverflow.com/users/20553",
"pm_score": 4,
"selected": true,
"text": "<p>I tried this once and I don't think it is possible.</p>\n\n<p>If you try to set both <code>ImageKey</code> and <cod... | 2008/11/04 | [
"https://Stackoverflow.com/questions/261660",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15371/"
] | I have a `TreeView` windows forms control with an `ImageList`, and I want some of the nodes to display images, but the others to not have images.
I *don't* want a blank space where the image should be. I *don't* want an image that looks like the lines that the TreeView would draw if it didn't have an ImageList. How do... | I tried this once and I don't think it is possible.
If you try to set both `ImageKey` and `ImageIndex` to "not set" values the control just defaults `ImageIndex` to 0. The following code:
```
treeView.ImageKey = "Value";
Debug.WriteLine(treeView.ImageIndex);
treeView.ImageKey = null;
Debug.WriteLine(treeView.ImageInd... |