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
329,051
<p>I am trying to execute a stored procedured from a linked database in MS SQL 2005. The linked database is a db2 database on a iseries server. I am using the iSeries IBMDASQL service provider. I am able to query the stored procedure without problems using a simple vbscript and ado. When I try to execute the same s...
[ { "answer_id": 329083, "author": "ConcernedOfTunbridgeWells", "author_id": 15401, "author_profile": "https://Stackoverflow.com/users/15401", "pm_score": 0, "selected": false, "text": "<p>Try using <a href=\"http://msdn.microsoft.com/en-us/library/ms188427(SQL.90).aspx\" rel=\"nofollow no...
2008/11/30
[ "https://Stackoverflow.com/questions/329051", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41951/" ]
I am trying to execute a stored procedured from a linked database in MS SQL 2005. The linked database is a db2 database on a iseries server. I am using the iSeries IBMDASQL service provider. I am able to query the stored procedure without problems using a simple vbscript and ado. When I try to execute the same stored p...
Turns out that there are a number of issues with the IBMDASQL provider that I was using. Believe it or not it is faster and more reliable to use the Microsoft OLE DB Provider for ODBC Drivers. After creating a new linked server with this provider, all of my earlier sql attempts worked properly. Cheers!
329,058
<p>Why do you think Microsoft wants us to go through IEnumerable to get to IEnumerator? Isn't the presence or absence of a valid cast to IEnumerator for a given type enough to determine if the type is enumerable or not?</p> <p>For example whats wrong with the following?</p> <pre><code>class MyClass : IEnumerator { ...
[ { "answer_id": 329064, "author": "Joe", "author_id": 13087, "author_profile": "https://Stackoverflow.com/users/13087", "pm_score": 4, "selected": true, "text": "<p>You might have two threads enumerating - each needs its own enumerator.</p>\n\n<p>IEnumerable.GetEnumerator returns an enume...
2008/11/30
[ "https://Stackoverflow.com/questions/329058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39648/" ]
Why do you think Microsoft wants us to go through IEnumerable to get to IEnumerator? Isn't the presence or absence of a valid cast to IEnumerator for a given type enough to determine if the type is enumerable or not? For example whats wrong with the following? ``` class MyClass : IEnumerator { ... } MyClass myOb...
You might have two threads enumerating - each needs its own enumerator. IEnumerable.GetEnumerator returns an enumerator that is initially positioned before the first element of the collection. If you only had IEnumerator, you'd have to remember to reset yourself before using it, even in a single-threaded scenario.
329,059
<p>This is a second-hand question from an OS development site, but it made me curious since I couldn't find a decent explanation anywhere.</p> <p>When compiling and linking a free-standing C++ program using gcc, sometimes a linker error like this occurs:</p> <pre><code>out/kernel.o:(.eh_frame+0x11): undefined referen...
[ { "answer_id": 329092, "author": "Martin v. Löwis", "author_id": 33006, "author_profile": "https://Stackoverflow.com/users/33006", "pm_score": 4, "selected": false, "text": "<p>It's part of the exception handling. The gcc EH mechanism allows to mix various EH models, and a personality ro...
2008/11/30
[ "https://Stackoverflow.com/questions/329059", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3121/" ]
This is a second-hand question from an OS development site, but it made me curious since I couldn't find a decent explanation anywhere. When compiling and linking a free-standing C++ program using gcc, sometimes a linker error like this occurs: ``` out/kernel.o:(.eh_frame+0x11): undefined reference to `__gxx_personal...
It is used in the stack unwiding tables, which you can see for instance in the assembly output of [my answer to another question](https://stackoverflow.com/questions/307610/how-do-exceptions-work-behind-the-scenes-in-c#307716). As mentioned on that answer, its use is defined by the [Itanium C++ ABI](https://itanium-cxx...
329,061
<p>What are the tensions between multithreading and exception-safety in C++? Are there good guidelines to follow? Does a thread terminate because of an uncaught exception?</p>
[ { "answer_id": 329084, "author": "Adam Rosenfield", "author_id": 9530, "author_profile": "https://Stackoverflow.com/users/9530", "pm_score": 4, "selected": true, "text": "<p>I believe the C++ standard does not make any mention of multithreading - multithreading is a platform-specific fea...
2008/11/30
[ "https://Stackoverflow.com/questions/329061", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19630/" ]
What are the tensions between multithreading and exception-safety in C++? Are there good guidelines to follow? Does a thread terminate because of an uncaught exception?
I believe the C++ standard does not make any mention of multithreading - multithreading is a platform-specific feature. I'm not exactly sure what the C++ standard says about uncaught exceptions in general, but according to [this page](http://www.devx.com/tips/Tip/14240), what happens is platform-defined, and you shoul...
329,063
<p>For example so that it works like this toString (Var x)= "x"</p>
[ { "answer_id": 329070, "author": "mipadi", "author_id": 28804, "author_profile": "https://Stackoverflow.com/users/28804", "pm_score": 1, "selected": false, "text": "<p>Use the <code>show</code> function:</p>\n\n<pre><code>putStrLn (show x)\n</code></pre>\n\n<p>will print out the \"x\" va...
2008/11/30
[ "https://Stackoverflow.com/questions/329063", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41000/" ]
For example so that it works like this toString (Var x)= "x"
Use the `show` function: ``` putStrLn (show x) ``` will print out the "x" variable. (Naturally, you don't need to use it with `putStrLn`, either -- `show` returns a string that can be used anywhere like a string.)
329,065
<p>I have a stored procedure that returns values from a temp table. In my DBML, it displays (None) for the return type. What is the trick to get it to recognize the columns from my temp table?</p> <pre><code>CREATE PROCEDURE [dbo].[GetCategoryPriceRanges] @CategoryId int AS BEGIN DECLARE @MinPrice money, @MaxPric...
[ { "answer_id": 329191, "author": "Bravax", "author_id": 13911, "author_profile": "https://Stackoverflow.com/users/13911", "pm_score": 3, "selected": true, "text": "<p>If you have a table which returns the same set of columns you can assign the stored procedure to return that type in the ...
2008/11/30
[ "https://Stackoverflow.com/questions/329065", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3047/" ]
I have a stored procedure that returns values from a temp table. In my DBML, it displays (None) for the return type. What is the trick to get it to recognize the columns from my temp table? ``` CREATE PROCEDURE [dbo].[GetCategoryPriceRanges] @CategoryId int AS BEGIN DECLARE @MinPrice money, @MaxPrice money SELE...
If you have a table which returns the same set of columns you can assign the stored procedure to return that type in the data model diagram. (Either by dragging the stored prcoedure onto it, or by setting it in the properties of the stored procedure.) Alternatively you can create a view with this set of columns, and a...
329,102
<p>I defined a Controller to force authentication by using the [Authorize] attribute. When a session times out, the request is still passed down and executed instead of forcing a redirect.</p> <p>I do use FormsAuthentication to login and logoff users.</p> <p>Any ideas on how to control that?</p> <p>Example: </p> <p...
[ { "answer_id": 329135, "author": "Darin Dimitrov", "author_id": 29407, "author_profile": "https://Stackoverflow.com/users/29407", "pm_score": 1, "selected": false, "text": "<p>To track user sessions ASP.NET uses the <em>ASP.NET_SessionId</em> cookie. To track authenticated users ASP.NET ...
2008/11/30
[ "https://Stackoverflow.com/questions/329102", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34819/" ]
I defined a Controller to force authentication by using the [Authorize] attribute. When a session times out, the request is still passed down and executed instead of forcing a redirect. I do use FormsAuthentication to login and logoff users. Any ideas on how to control that? Example: ``` [Authorize] public class P...
Again, ASP.NET MVC builds on top of traditional ASP.NET. Yes, there is an "built authentication shizzle"... it's the *exact* same Membership API that traditional ASP.NET uses. Meaning... something else is the problem here. Maybe you have sliding sessions turned on... or maybe the timeout is higher than you thought, et...
329,118
<p>I need to activate a JButton ActionListener within a JDialog so I can do some unit testing using JUnit.</p> <p>Basically I have this:</p> <pre><code> public class MyDialog extends JDialog { public static int APPLY_OPTION= 1; protected int buttonpressed; protected JButton okButton; public MyDial...
[ { "answer_id": 329153, "author": "Tom Hawtin - tackline", "author_id": 4725, "author_profile": "https://Stackoverflow.com/users/4725", "pm_score": 4, "selected": true, "text": "<p><code>AbstractButton.doClick</code></p>\n\n<p>Your tests might run faster if you use the form that takes an ...
2008/11/30
[ "https://Stackoverflow.com/questions/329118", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3485/" ]
I need to activate a JButton ActionListener within a JDialog so I can do some unit testing using JUnit. Basically I have this: ``` public class MyDialog extends JDialog { public static int APPLY_OPTION= 1; protected int buttonpressed; protected JButton okButton; public MyDialog(Frame f) { ...
`AbstractButton.doClick` Your tests might run faster if you use the form that takes an argument and give it a shorter delay. The call blocks for the delay.
329,144
<p>This is a question brought up in a local user group mailing list at dot.net.nz ...</p> <blockquote> <p>I when I create an XHTML page old-fashioned way, I used to use the following syntax for my CSS declarations:</p> </blockquote> <pre><code>&lt;link rel=”stylesheet” type=”text/css” media=”screen” href=”css...
[ { "answer_id": 329179, "author": "technophile", "author_id": 23029, "author_profile": "https://Stackoverflow.com/users/23029", "pm_score": 1, "selected": false, "text": "<p>You can declare the media type inside the stylesheets. For example, printer.css:</p>\n\n<pre><code>@media print\n{\...
2008/11/30
[ "https://Stackoverflow.com/questions/329144", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19377/" ]
This is a question brought up in a local user group mailing list at dot.net.nz ... > > I when I create an XHTML page > old-fashioned way, I used to use the > following syntax for my CSS > declarations: > > > ``` <link rel=”stylesheet” type=”text/css” media=”screen” href=”css/screen.css” /> <link rel=”styleshe...
You should define media in the CSS file: ``` @media print { p { ... } ...put styles here. } ```
329,145
<p>Assuming the following directory structure,</p> <pre><code>htdocs/ images/ css/ .htaccess system/ index.php ... </code></pre> <p>I would like to route all incoming requests through that php script. I have been trying some rewrite rules within the htaccess, but I can't seem to be able to route to files th...
[ { "answer_id": 329173, "author": "Robert K", "author_id": 24950, "author_profile": "https://Stackoverflow.com/users/24950", "pm_score": 2, "selected": false, "text": "<p>No, you cannot route outside the docroot without potentially enormous risk.</p>\n\n<p>You should place the <code>index...
2008/11/30
[ "https://Stackoverflow.com/questions/329145", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1951/" ]
Assuming the following directory structure, ``` htdocs/ images/ css/ .htaccess system/ index.php ... ``` I would like to route all incoming requests through that php script. I have been trying some rewrite rules within the htaccess, but I can't seem to be able to route to files that are outside the documen...
What a lot of frameworks do is use rewrite to route all requests to one file where you can do more complex routing of your own. An example .htaccess file might be: ``` # ignore anything that's an actual file (eg CSS, js, images) RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f # redirect all other traffic to the index ...
329,151
<p>jQuery selectors are wonderful, but I sometimes I find myself typing them over and over, and it gets a little annoying.</p> <pre><code> $('#mybutton').click(function() { $('#message-box').doSomething(); $('#message-box').doSomethingElse(); $('#message-box').attr('something', 'something'); }); </code></...
[ { "answer_id": 329155, "author": "Pim Jager", "author_id": 35197, "author_profile": "https://Stackoverflow.com/users/35197", "pm_score": 5, "selected": true, "text": "<p>You should chain them:</p>\n\n<pre><code>$('#mybutton').click(function() {\n $('#message-box').doSomething().doSometh...
2008/11/30
[ "https://Stackoverflow.com/questions/329151", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4636/" ]
jQuery selectors are wonderful, but I sometimes I find myself typing them over and over, and it gets a little annoying. ``` $('#mybutton').click(function() { $('#message-box').doSomething(); $('#message-box').doSomethingElse(); $('#message-box').attr('something', 'something'); }); ``` So often I like t...
You should chain them: ``` $('#mybutton').click(function() { $('#message-box').doSomething().doSomethingElse().attr('something', 'something'); }); ``` If you need to do something over and over again and the functions don't return the jQuery object saving them in a var is faster.
329,197
<p>In <code>SQL Server</code>, I can do something like this:</p> <pre><code>UPDATE tbl1 SET col2 = tbl2.col2 FROM table1 tbl1 INNER JOIN table2 tbl2 ON tbl1.col1 = tbl2.col1 </code></pre> <p>I haven't bothered to look whether this is part of any SQL standard or not, and I'm sure there are other ways to do...
[ { "answer_id": 329208, "author": "Gregory Higley", "author_id": 27779, "author_profile": "https://Stackoverflow.com/users/27779", "pm_score": 1, "selected": false, "text": "<p>I've discovered this can be done with <code>INSERT OR REPLACE INTO</code>. A little more verbose than T-SQL's eq...
2008/11/30
[ "https://Stackoverflow.com/questions/329197", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27779/" ]
In `SQL Server`, I can do something like this: ``` UPDATE tbl1 SET col2 = tbl2.col2 FROM table1 tbl1 INNER JOIN table2 tbl2 ON tbl1.col1 = tbl2.col1 ``` I haven't bothered to look whether this is part of any SQL standard or not, and I'm sure there are other ways to do it, but it is *astoundingly* usefu...
This works for sqlite: ``` UPDATE tbl1 SET col2 = (SELECT col2 FROM tbl2 WHERE tbl2.col1 = tbl1.col1) ```
329,216
<p>First off, I apologize if this doesn't make sense. I'm new to XHTML, CSS and JavaScript.</p> <p>I gather that in XHTML, the correct way to have a nested page is as follows (instead of an iframe):</p> <pre><code>&lt;object name="nestedPage" data="http://abc.com/page.html" type="text/html" width="500" height="400" ...
[ { "answer_id": 329218, "author": "Javache", "author_id": 1074, "author_profile": "https://Stackoverflow.com/users/1074", "pm_score": 0, "selected": false, "text": "<p>If the nested page is outside your domain, cross-domain restrictions will prevent you from fiddling with its stylesheet/h...
2008/11/30
[ "https://Stackoverflow.com/questions/329216", "https://Stackoverflow.com", "https://Stackoverflow.com/users/82/" ]
First off, I apologize if this doesn't make sense. I'm new to XHTML, CSS and JavaScript. I gather that in XHTML, the correct way to have a nested page is as follows (instead of an iframe): ``` <object name="nestedPage" data="http://abc.com/page.html" type="text/html" width="500" height="400" /> ``` If I have a nes...
``` d = document.getElementsByTagName('object').namedItem('nestedPage').getContentDocument(); d.styleSheets[d.styleSheets.length].href = 'whereever'; ``` WARNING: hasn't been tested in all browsers.
329,256
<p>What's the best way to consume REST web services from .NET?</p>
[ { "answer_id": 329268, "author": "Brian", "author_id": 19299, "author_profile": "https://Stackoverflow.com/users/19299", "pm_score": 2, "selected": false, "text": "<p>Probably WCF; check out</p>\n\n<p><a href=\"http://hyperthink.net/blog/announcing-the-wcf-rest-starter-kit/\" rel=\"nofol...
2008/11/30
[ "https://Stackoverflow.com/questions/329256", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
What's the best way to consume REST web services from .NET?
A straight forward and easy approach would be to use WebClient which is in the System.Net namespace. Pretty much all you need to do is pass in the Uri required with any parameters needed in the form of a query string and you should get back the response in the form of a string, be it json or xml. For example. ``` us...
329,307
<p>I'm revisiting som old code of mine and have stumbled upon a method for getting the title of a website based on its url. It's not really what you would call a stable method as it often fails to produce a result and sometimes even produces incorrect results. Also, sometimes it fails to show some of the characters fro...
[ { "answer_id": 329317, "author": "Nick Berardi", "author_id": 17, "author_profile": "https://Stackoverflow.com/users/17", "pm_score": -1, "selected": false, "text": "<p>Inorder to accomplish this you are going to need to do a couple of things.</p>\n\n<ul>\n<li>Make your app threaded, so ...
2008/11/30
[ "https://Stackoverflow.com/questions/329307", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4055/" ]
I'm revisiting som old code of mine and have stumbled upon a method for getting the title of a website based on its url. It's not really what you would call a stable method as it often fails to produce a result and sometimes even produces incorrect results. Also, sometimes it fails to show some of the characters from t...
A simpler way to get the content: ``` WebClient x = new WebClient(); string source = x.DownloadString("http://www.singingeels.com/"); ``` A simpler, more reliable way to get the title: ``` string title = Regex.Match(source, @"\<title\b[^>]*\>\s*(?<Title>[\s\S]*?)\</title\>", RegexOptions.IgnoreCase).Groups["Tit...
329,355
<p>I'm using .NET 3.5, trying to recursively delete a directory using:</p> <pre><code>Directory.Delete(myPath, true); </code></pre> <p>My understanding is that this should throw if files are in use or there is a permissions problem, but otherwise it should delete the directory and all of its contents.</p> <p>However...
[ { "answer_id": 329364, "author": "Drejc", "author_id": 6482, "author_profile": "https://Stackoverflow.com/users/6482", "pm_score": 4, "selected": false, "text": "<p>I had the very same problem under Delphi. And the end result was that my own application was locking the directory I wanted...
2008/11/30
[ "https://Stackoverflow.com/questions/329355", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5142/" ]
I'm using .NET 3.5, trying to recursively delete a directory using: ``` Directory.Delete(myPath, true); ``` My understanding is that this should throw if files are in use or there is a permissions problem, but otherwise it should delete the directory and all of its contents. However, I occasionally get this: ``` S...
**Editor's note:** Although this answer contains some useful information, it is factually incorrect about the workings of `Directory.Delete`. Please read the comments for this answer, and other answers to this question. --- I ran into this problem before. The root of the problem is that this function does not delete...
329,359
<p>I faced a little trouble - I do not know if I can define my own operators for my classes. For example:<br></p> <pre><code>type TMinMatrix = class(TMatrix) private RowAmount: Byte; ColAmount: Byte; Data: DataMatrix; DemVector, SupVector: SupplyDemand; public constructor Create...
[ { "answer_id": 329385, "author": "Drejc", "author_id": 6482, "author_profile": "https://Stackoverflow.com/users/6482", "pm_score": 3, "selected": true, "text": "<p>Operator overloading is possible in Delphi .NET versions, older versions of Delphi don't support it.</p>\n" }, { "an...
2008/11/30
[ "https://Stackoverflow.com/questions/329359", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28298/" ]
I faced a little trouble - I do not know if I can define my own operators for my classes. For example: ``` type TMinMatrix = class(TMatrix) private RowAmount: Byte; ColAmount: Byte; Data: DataMatrix; DemVector, SupVector: SupplyDemand; public constructor Create(Rows, Cols: Byt...
Operator overloading is possible in Delphi .NET versions, older versions of Delphi don't support it.
329,390
<p>The singleton is explained here: <a href="http://en.wikipedia.org/wiki/Singleton_pattern#PHP_5" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Singleton_pattern#PHP_5</a>. I want to use the singleton class as a superclass, and extend it in other classes that are supposed to be singletons. The problem is, the...
[ { "answer_id": 329404, "author": "Vilx-", "author_id": 41360, "author_profile": "https://Stackoverflow.com/users/41360", "pm_score": 1, "selected": false, "text": "<p>A static method is tied to its defining type, not an instance. Child classes do not inherit static methods (that would ma...
2008/11/30
[ "https://Stackoverflow.com/questions/329390", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
The singleton is explained here: <http://en.wikipedia.org/wiki/Singleton_pattern#PHP_5>. I want to use the singleton class as a superclass, and extend it in other classes that are supposed to be singletons. The problem is, the superclass makes an instance of itself, not the subclass. Any idea how I can make the Supercl...
This is a limitation of PHP - a parent class cannot determine the name of a subclass on which its methods are statically called. PHP 5.3 now has support for late static bindings, which will let you do what you need to, but it will be a while before that is widely available. See some information [here](http://php.net/o...
329,399
<p>In C++, on the stack, a simple variable is assigned a memory address so that we can use a pointer to contain this memory to point to it; then is a pointer also assigned a memory address?</p> <p>If yes, can we have a pointer of pointers?</p>
[ { "answer_id": 329403, "author": "Johannes Schaub - litb", "author_id": 34509, "author_profile": "https://Stackoverflow.com/users/34509", "pm_score": 4, "selected": false, "text": "<p>Yes, you are right. We can have pointers to pointers:</p>\n\n<pre><code>int a;\nint b;\nint * pa = &amp;...
2008/11/30
[ "https://Stackoverflow.com/questions/329399", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36064/" ]
In C++, on the stack, a simple variable is assigned a memory address so that we can use a pointer to contain this memory to point to it; then is a pointer also assigned a memory address? If yes, can we have a pointer of pointers?
Yes, you are right. We can have pointers to pointers: ``` int a; int b; int * pa = &a; int ** ppa = &pa; // set a to 10 **ppa = 10; // set pa so it points to b. and then set b to 11. *ppa = &b; **ppa = 11; ``` Read it from right to left: *ppa is a pointer to a pointer to an int* . It's not limited to `**` . You ca...
329,411
<p>config file :</p> <pre><code>&lt;system.net&gt; &lt;mailSettings&gt; &lt;smtp from="YYYYY@xxxxxx.com"&gt; &lt;network host="mail.xxxxxx.com" port="25" password="password" userName="user@xxxxxx.com" defaultCredentials="false" /&gt; &lt;/smtp&gt; &lt;/mailSettings&gt; &lt;/system.net&gt; </code></pre> <p>I've alread...
[ { "answer_id": 329417, "author": "John Sheehan", "author_id": 1786, "author_profile": "https://Stackoverflow.com/users/1786", "pm_score": 2, "selected": false, "text": "<p>Set the deliveryMethod property on the smtp element to 'network'. </p>\n" }, { "answer_id": 329432, "aut...
2008/11/30
[ "https://Stackoverflow.com/questions/329411", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
config file : ``` <system.net> <mailSettings> <smtp from="YYYYY@xxxxxx.com"> <network host="mail.xxxxxx.com" port="25" password="password" userName="user@xxxxxx.com" defaultCredentials="false" /> </smtp> </mailSettings> </system.net> ``` I've already tried defaultCredentials="true" but i recieved following message: ...
Set the deliveryMethod property on the smtp element to 'network'.
329,414
<p>I have an abstract class:</p> <pre><code>type TInterfaceMethod = class abstract public destructor Destroy; virtual; abstract; function GetBasePlan: Word; virtual; abstract; procedure CountBasePlan; virtual; abstract; procedure Calculate; virtual; abstract; procedure Prepare...
[ { "answer_id": 329416, "author": "Toon Krijthe", "author_id": 18061, "author_profile": "https://Stackoverflow.com/users/18061", "pm_score": 4, "selected": true, "text": "<p>Yes you can. Abstract classes are classes and they can have implementations.</p>\n\n<p>By adding the abstract keywo...
2008/11/30
[ "https://Stackoverflow.com/questions/329414", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28298/" ]
I have an abstract class: ``` type TInterfaceMethod = class abstract public destructor Destroy; virtual; abstract; function GetBasePlan: Word; virtual; abstract; procedure CountBasePlan; virtual; abstract; procedure Calculate; virtual; abstract; procedure PrepareForWork; vir...
Yes you can. Abstract classes are classes and they can have implementations. By adding the abstract keyword to a class, you prohibit the class to be instantiated. It does not require to have any abstract methods. A class with absract methods can be instantiated, but this result in a warning at compile time and an exc...
329,423
<p>I understand how Map is easily parallelizable - each computer/CPU can just operate on a small portion of the array.</p> <p>Is Reduce/foldl parallelizable? It seems like each computation depends on the previous one. Is it just parallelizable for certain types of functions?</p>
[ { "answer_id": 329461, "author": "strager", "author_id": 39992, "author_profile": "https://Stackoverflow.com/users/39992", "pm_score": 1, "selected": false, "text": "<p>Not sure what platform/language you're thinking of, but you can parallelize reduce operators like this:</p>\n\n<pre><co...
2008/11/30
[ "https://Stackoverflow.com/questions/329423", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15055/" ]
I understand how Map is easily parallelizable - each computer/CPU can just operate on a small portion of the array. Is Reduce/foldl parallelizable? It seems like each computation depends on the previous one. Is it just parallelizable for certain types of functions?
If your reduction underlying operation is associative\*, you can play with the order of operations and locality. Therefore you often have a tree-like structure in the 'gather' phase, so you can do it in several passes in logarithmic time: ``` a + b + c + d \ / \ / (a+b) (c+d) \ / ...
329,447
<p>I've got a form inside an <code>&lt;asp:Content&gt;</code> block that is being submitted to a controller. For one of the controls, I need to get some information from it directly that won't happen automatically by calling <code>UpdateModel()</code>.</p> <p>However, in the <code>Request.Form</code> dictionary, the ...
[ { "answer_id": 329473, "author": "Todd Smith", "author_id": 31624, "author_profile": "https://Stackoverflow.com/users/31624", "pm_score": -1, "selected": false, "text": "<p>Are you using a WebForm control? To my knowledge, the default ASP.NET MVC view engine does not mangle control ID's....
2008/11/30
[ "https://Stackoverflow.com/questions/329447", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9913/" ]
I've got a form inside an `<asp:Content>` block that is being submitted to a controller. For one of the controls, I need to get some information from it directly that won't happen automatically by calling `UpdateModel()`. However, in the `Request.Form` dictionary, the control's id is of the mangled form `ctl00$Content...
FCKEditor is a standard javascript library that also comes wrapped in an ASP.NET control for Webforms. So it would be easier to use the FCKEditor javascript without the ASP.NET control. It will be easier to integrate into MVC that way. If you must use the ASP.NET control version then you will have these kinds of issue...
329,448
<p>I know how to use the DrawImage() method of the Graphics object to copy from a rectangular source region to a rectangular destination region, and how to copy to a paralellogram region defined by a three-element Point[] array.</p> <p>Is there any way in .NET to copy from a rectangular source region to a 4-sided non-...
[ { "answer_id": 330029, "author": "Joel Meador", "author_id": 1976, "author_profile": "https://Stackoverflow.com/users/1976", "pm_score": 1, "selected": false, "text": "<p>As far as I can tell, there isn't a straightforward (built-in) way to do this kind of image transform in .NET.</p>\n\...
2008/11/30
[ "https://Stackoverflow.com/questions/329448", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14606/" ]
I know how to use the DrawImage() method of the Graphics object to copy from a rectangular source region to a rectangular destination region, and how to copy to a paralellogram region defined by a three-element Point[] array. Is there any way in .NET to copy from a rectangular source region to a 4-sided non-rectangula...
It *is* possible to do this entirely in .NET: [alt text http://www.freeimagehosting.net/uploads/a770d1e97f.jpg](http://www.freeimagehosting.net/uploads/a770d1e97f.jpg) but you have to do it yourself, pixel-by-pixel. Graphics courtesy of [Jonbert](https://stackoverflow.com/questions/305223/jon-skeet-facts#309319).
329,477
<p>I have an SQL 2005 table, let's call it Orders, in the format:</p> <pre><code>OrderID, OrderDate, OrderAmount 1, 25/11/2008, 10 2, 25/11/2008, 2 3, 30/1002008, 5 </code></pre> <p>Then I need to produce a report table showing the ordered amount on each day in the last 7 days:</p> <pre><code>Day,...
[ { "answer_id": 329501, "author": "Jonathan Leffler", "author_id": 15168, "author_profile": "https://Stackoverflow.com/users/15168", "pm_score": 1, "selected": false, "text": "<p>Depending on how SQL Server handles temporary tables, you can more or less easily arrange to create a temporar...
2008/11/30
[ "https://Stackoverflow.com/questions/329477", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3263/" ]
I have an SQL 2005 table, let's call it Orders, in the format: ``` OrderID, OrderDate, OrderAmount 1, 25/11/2008, 10 2, 25/11/2008, 2 3, 30/1002008, 5 ``` Then I need to produce a report table showing the ordered amount on each day in the last 7 days: ``` Day, OrderCount, OrderAmount 25/11...
SQL isn't "skipping" dates... because queries run against *data* that is actually in the table. So, if you don't have a DATE in the table for January 14th, then why would SQL show you a result :) What you need to do is make a temp table, and JOIN to it. ``` CREATE TABLE #MyDates ( TargetDate DATETIME ) INSERT INTO #M...
329,490
<p>in Microsoft Access, is there a way which I can programatically set the Confirm Action Queries flag on the options screen to False? Ideally when the database is started up I would like to check if it's true, and if so, mark it as false for the currently logged in user.</p> <p>The application is locked down reasonab...
[ { "answer_id": 329524, "author": "Harry Steinhilber", "author_id": 6118, "author_profile": "https://Stackoverflow.com/users/6118", "pm_score": 2, "selected": true, "text": "<p>Place the following in a method when the database starts:</p>\n\n<pre><code>If Application.GetOption(\"Confirm A...
2008/11/30
[ "https://Stackoverflow.com/questions/329490", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30140/" ]
in Microsoft Access, is there a way which I can programatically set the Confirm Action Queries flag on the options screen to False? Ideally when the database is started up I would like to check if it's true, and if so, mark it as false for the currently logged in user. The application is locked down reasonably tightly...
Place the following in a method when the database starts: ``` If Application.GetOption("Confirm Action Queries") Then Application.SetOption "Confirm Action Queries", False End If ```
329,497
<p>i have code like, sorry i dont have the exact code now. but its valid.</p> <pre><code>&lt;iframe src="..." borderframe="0" scrolling="no" width=728px" height="90px"&gt;&lt;/iframe&gt; </code></pre> <p>the target is a html file that contains code for a banner. everything displays well. but when i resize browser or...
[ { "answer_id": 329558, "author": "Karl", "author_id": 36093, "author_profile": "https://Stackoverflow.com/users/36093", "pm_score": 3, "selected": false, "text": "<p>I have an idea, but you haven't given us the whole picture, so I might be way off. </p>\n\n<p>I would guess that the ifra...
2008/11/30
[ "https://Stackoverflow.com/questions/329497", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
i have code like, sorry i dont have the exact code now. but its valid. ``` <iframe src="..." borderframe="0" scrolling="no" width=728px" height="90px"></iframe> ``` the target is a html file that contains code for a banner. everything displays well. but when i resize browser or go to maximize. the content is shifte...
I have an idea, but you haven't given us the whole picture, so I might be way off. I would guess that the iframe is positioned with a percentage or some sort of division calculation like 40% left of parent. Then at certain browser widths this number doesn divide evenly and gets truncated. Say it is at 100px in from t...
329,498
<p>I've recently started with Python, and am enjoying the "batteries included" design. I'e already found out I can import time, math, re, urllib, but don't know how to know that something is builtin rather than writing it from scratch.</p> <p>What's included, and where can I get other good quality libraries from?</p>
[ { "answer_id": 329509, "author": "Patrick Harrington", "author_id": 41165, "author_profile": "https://Stackoverflow.com/users/41165", "pm_score": 2, "selected": false, "text": "<p>The Python Global Module Index (<a href=\"http://docs.python.org/modindex.html\" rel=\"nofollow noreferrer\"...
2008/11/30
[ "https://Stackoverflow.com/questions/329498", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16511/" ]
I've recently started with Python, and am enjoying the "batteries included" design. I'e already found out I can import time, math, re, urllib, but don't know how to know that something is builtin rather than writing it from scratch. What's included, and where can I get other good quality libraries from?
Firstly, the [python libary reference](https://docs.python.org/2/library/index.html) gives a blow by blow of what's actually included. And the [global module index](http://docs.python.org/modindex.html) contains a neat, alphabetized summary of those same modules. If you have dependencies on a library, you can trivially...
329,500
<p>I would like to use <code>[Authorize]</code> for every action in my admin controller except the <code>Login</code> action. </p> <pre><code>[Authorize (Roles = "Administrator")] public class AdminController : Controller { // what can I place here to disable authorize? public ActionResult Login() { ...
[ { "answer_id": 329562, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 5, "selected": true, "text": "<p>I don't think you can do this with the standard Authorize attribute, but you could derive your own attribute from Aut...
2008/11/30
[ "https://Stackoverflow.com/questions/329500", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31624/" ]
I would like to use `[Authorize]` for every action in my admin controller except the `Login` action. ``` [Authorize (Roles = "Administrator")] public class AdminController : Controller { // what can I place here to disable authorize? public ActionResult Login() { return View(); } } ```
I don't think you can do this with the standard Authorize attribute, but you could derive your own attribute from AuthorizeAttribute that takes a list of actions to allow and allows access to just those actions. You can look at the source for the AuthorizeAttribute at [www.codeplex.com](http://www.codeplex.com/aspnet) ...
329,516
<p>I'm using the following code to have a non-JS navigation:</p> <pre><code>&lt;ol id="navigation"&gt; &lt;li id="home"&gt;&lt;a href="#"&gt;&lt;img src="./images/nav/home-hover.png" alt="Home" /&gt;&lt;/li&gt; ... &lt;/ol&gt; </code></pre> <p>And the CSS:</p> <pre><code>#navigation a { display: block; ...
[ { "answer_id": 329550, "author": "Kornel", "author_id": 27009, "author_profile": "https://Stackoverflow.com/users/27009", "pm_score": 3, "selected": true, "text": "<p>IE doesn't repaint anchors unless any rule on <code>&lt;a&gt;</code> itself changes. Add anything for <code>a:hover</code...
2008/11/30
[ "https://Stackoverflow.com/questions/329516", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2025/" ]
I'm using the following code to have a non-JS navigation: ``` <ol id="navigation"> <li id="home"><a href="#"><img src="./images/nav/home-hover.png" alt="Home" /></li> ... </ol> ``` And the CSS: ``` #navigation a { display: block; height: 25px; } #navigation a img { display: none; } #navigation...
IE doesn't repaint anchors unless any rule on `<a>` itself changes. Add anything for `a:hover`, e.g.: ``` #navigation a:hover {border:0} /* no-op */ ``` BTW: unfortunately popular screen readers don't read things with `display:none`, so your menu ends up being inaccessible. I suggest having `<img>` visible by defa...
329,517
<p>There is a simple C++ method to use pattern matching on strings? The code should sound like this:</p> <pre><code>if (regexpcmp("l?nole*[0-9]", "linoleum1")) { //we have a match! } else { //no match } </code></pre>
[ { "answer_id": 329522, "author": "Reunanen", "author_id": 19254, "author_profile": "https://Stackoverflow.com/users/19254", "pm_score": 4, "selected": false, "text": "<p>Did you already look at <a href=\"http://www.boost.org/doc/libs/release/libs/regex/\" rel=\"nofollow noreferrer\">Boos...
2008/11/30
[ "https://Stackoverflow.com/questions/329517", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39796/" ]
There is a simple C++ method to use pattern matching on strings? The code should sound like this: ``` if (regexpcmp("l?nole*[0-9]", "linoleum1")) { //we have a match! } else { //no match } ```
Not in the core language. Use Boost.Regex or an external library like `pcre`. In a unix environment you almost certainly have access to the BSD regular expression tools (`regcomp`, `regerror`, `regexec`, `regfree`) which are c-like rather than c++-like but do work.
329,547
<p>I have some code that I am putting in the code-behind of a master page. This master page is my main layout and the purpose of the code is to check whether the user is logged in and take the appropriate action depending on whether they are or not. I would be interested in hearing alternate methods on how to approach ...
[ { "answer_id": 329603, "author": "MrJavaGuy", "author_id": 7138, "author_profile": "https://Stackoverflow.com/users/7138", "pm_score": 3, "selected": true, "text": "<p>Take a look at the Authorization attribute for controllers and controllers actions. It should save you from doing anythi...
2008/11/30
[ "https://Stackoverflow.com/questions/329547", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39430/" ]
I have some code that I am putting in the code-behind of a master page. This master page is my main layout and the purpose of the code is to check whether the user is logged in and take the appropriate action depending on whether they are or not. I would be interested in hearing alternate methods on how to approach thi...
Take a look at the Authorization attribute for controllers and controllers actions. It should save you from doing anything in the code behind of the master page.
329,556
<p>I have <code>DataTemplate</code> containing a <code>TextBox</code>. I'm setting this template to a listbox item on a selection.</p> <p>I'm unable to set focus to textbox in the template. I tried to call MyTemplate.FindName, but it ends up with an Invalid Operation Exception: This operation is valid only on elements...
[ { "answer_id": 329571, "author": "Matt Hamilton", "author_id": 615, "author_profile": "https://Stackoverflow.com/users/615", "pm_score": 4, "selected": true, "text": "<p>Since you know the name of the <code>TextBox</code> you want to focus, this becomes relatively easy. The idea is to ge...
2008/11/30
[ "https://Stackoverflow.com/questions/329556", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19146/" ]
I have `DataTemplate` containing a `TextBox`. I'm setting this template to a listbox item on a selection. I'm unable to set focus to textbox in the template. I tried to call MyTemplate.FindName, but it ends up with an Invalid Operation Exception: This operation is valid only on elements that have this template applied...
Since you know the name of the `TextBox` you want to focus, this becomes relatively easy. The idea is to get hold of the template as it's applied to the `ListBoxItem` itself. First thing you want to do is get the selected item: ``` var item = listBox1.ItemContainerGenerator.ContainerFromItem(listBox1.SelectedItem) as...
329,570
<p>Is it possble to have something like this in ASP.NET MVC...</p> <pre><code>[Authorize] [AcceptVerbs(HttpVerbs.Get)] public string AddData(string Issues, string LabelGUID) { return "Authorized"; } [AcceptVerbs(HttpVerbs.Get)] public string AddData() { return "Not Authorized"; } </code></pre> <p>So if the u...
[ { "answer_id": 329594, "author": "Todd Smith", "author_id": 31624, "author_profile": "https://Stackoverflow.com/users/31624", "pm_score": 1, "selected": false, "text": "<p>I don't believe so. The controller action with the best parameter match will get selected and then the attributes wi...
2008/11/30
[ "https://Stackoverflow.com/questions/329570", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1231/" ]
Is it possble to have something like this in ASP.NET MVC... ``` [Authorize] [AcceptVerbs(HttpVerbs.Get)] public string AddData(string Issues, string LabelGUID) { return "Authorized"; } [AcceptVerbs(HttpVerbs.Get)] public string AddData() { return "Not Authorized"; } ``` So if the user is not logged in, it d...
Yes, its possible. You would need to create your own `ControllerActionInvoker` and override the `FindActionMethod` member. I'd let the base class do it's work and then check to see if the method it returns satisfies your criteria and if not, return a better match. I'm doing something like this to allow my Controllers ...
329,622
<p>Well basically I have this script that takes a long time to execute and occasionally times out and leaves semi-complete data floating around my database. (Yes I know in a perfect world I would fix THAT instead of implementing commits and rollbacks but I am forced to not do that)</p> <p>Here is my basic code (dumbed...
[ { "answer_id": 329629, "author": "Brian C. Lane", "author_id": 27461, "author_profile": "https://Stackoverflow.com/users/27461", "pm_score": 4, "selected": true, "text": "<p>Take a look at <a href=\"http://www.phpro.org/tutorials/Introduction-to-PHP-PDO.html#11\" rel=\"noreferrer\">this ...
2008/11/30
[ "https://Stackoverflow.com/questions/329622", "https://Stackoverflow.com", "https://Stackoverflow.com/users/428190/" ]
Well basically I have this script that takes a long time to execute and occasionally times out and leaves semi-complete data floating around my database. (Yes I know in a perfect world I would fix THAT instead of implementing commits and rollbacks but I am forced to not do that) Here is my basic code (dumbed down for ...
Take a look at [this tutorial](http://www.phpro.org/tutorials/Introduction-to-PHP-PDO.html#11) on transactions with PDO. Basically wrap the long running code in: ``` $dbh->beginTransaction(); ... $dbh->commit(); ``` And [according to this PDO document page](http://usphp.com/manual/en/ref.pdo.php): "When the script...
329,658
<p>How do I achieve authorization with MVC asp.net?</p>
[ { "answer_id": 329669, "author": "MrJavaGuy", "author_id": 7138, "author_profile": "https://Stackoverflow.com/users/7138", "pm_score": 2, "selected": false, "text": "<p>There is an Authorization feature with MVC, using ASP.NET MVC beta and creating the MVC project from Visual Studio, aut...
2008/12/01
[ "https://Stackoverflow.com/questions/329658", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29445/" ]
How do I achieve authorization with MVC asp.net?
Use the Authorize attribute ``` [Authorize] public ActionResult MyAction() { //stuff } ``` You can also use this on the controller. Can pass in users or roles too. If you want something with a little more control, you could try something like [this](http://schotime.net/blog/index.php/2009/02/17/custom-authorizat...
329,676
<p>In a WPF UserControl, I have to make to call to a WebService. I am making this call on a separate thread but I want to inform the user that the call may take some time. </p> <p>The WebMethod returns me a collection of objects and I bind it to a ListBox in my UC. So far, so good... This part works really well. Howev...
[ { "answer_id": 329714, "author": "Rob", "author_id": 18505, "author_profile": "https://Stackoverflow.com/users/18505", "pm_score": 4, "selected": true, "text": "<p>Don't go with the adorner - what I do is have two separate container controls (usually grids) that occupy the same area of t...
2008/12/01
[ "https://Stackoverflow.com/questions/329676", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42024/" ]
In a WPF UserControl, I have to make to call to a WebService. I am making this call on a separate thread but I want to inform the user that the call may take some time. The WebMethod returns me a collection of objects and I bind it to a ListBox in my UC. So far, so good... This part works really well. However, **I wa...
Don't go with the adorner - what I do is have two separate container controls (usually grids) that occupy the same area of the screen. One is my "progress" control, and the other is my "content" control. I set the visibility of the progress control to Collapsed and the visibility of the content control to Visible by de...
329,682
<p>One of the nice feature of the Image control is that we can specified an Uri as the ImageSource and the image is automatically downloaded for us. This is great! <strong>However, the control doesn't seem to have a property indicating if the image loading is in progress or not.</strong></p> <p>Is there a property tel...
[ { "answer_id": 329762, "author": "Rob", "author_id": 18505, "author_profile": "https://Stackoverflow.com/users/18505", "pm_score": 0, "selected": false, "text": "<p>Hmm - that's a good question. I looked at the ImageSource class's documentation on MSDN, and it doesn't look like there is ...
2008/12/01
[ "https://Stackoverflow.com/questions/329682", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42024/" ]
One of the nice feature of the Image control is that we can specified an Uri as the ImageSource and the image is automatically downloaded for us. This is great! **However, the control doesn't seem to have a property indicating if the image loading is in progress or not.** Is there a property telling us the status (Dow...
As long as your ImageSource is a BitmapImage you could use the BitmapImage.DownloadCompleted event. The only problem I have found so far is that it only works from C#, so you would lose some flexibility. I'm guessing you could access that event from XAML, but I'm not sure how. The following sample starts loading the im...
329,724
<p>I have this marked as PHP but only because I'll be using PHP code to show my problem.</p> <p>So I have some code like this for the controller:</p> <pre><code>switch ($page) { case "home": require "views/home.php"; break; case "search": require "views/search.php"; break; } </...
[ { "answer_id": 329740, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 3, "selected": false, "text": "<p>The controller should just set up the data for the view and choose which view to display. The view should be respon...
2008/12/01
[ "https://Stackoverflow.com/questions/329724", "https://Stackoverflow.com", "https://Stackoverflow.com/users/428190/" ]
I have this marked as PHP but only because I'll be using PHP code to show my problem. So I have some code like this for the controller: ``` switch ($page) { case "home": require "views/home.php"; break; case "search": require "views/search.php"; break; } ``` Obviously there's...
The controller should just set up the data for the view and choose which view to display. The view should be responsible for the layout of the page, including shared pages. I like your first sample over the second.
329,775
<p>I'm having trouble with a web application that will deadlock occasionally</p> <p>There are 3 queries involved. 2 are trying to update a table</p> <pre><code>UPDATE AttendanceRoll SET ErrorFlag = 0 WHERE ContractID = @ContractID AND DATEPART(month,AttendanceDate) = DATEPART(month,@Month_Beginning) AND DATEPART(year...
[ { "answer_id": 329794, "author": "cbp", "author_id": 21966, "author_profile": "https://Stackoverflow.com/users/21966", "pm_score": 1, "selected": false, "text": "<p>Is the Update query taking a significant time to execute (say, more than second)? If so, try optimizing the query (i.e. by ...
2008/12/01
[ "https://Stackoverflow.com/questions/329775", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm having trouble with a web application that will deadlock occasionally There are 3 queries involved. 2 are trying to update a table ``` UPDATE AttendanceRoll SET ErrorFlag = 0 WHERE ContractID = @ContractID AND DATEPART(month,AttendanceDate) = DATEPART(month,@Month_Beginning) AND DATEPART(year,AttendanceDate) = DA...
Is the Update query taking a significant time to execute (say, more than second)? If so, try optimizing the query (i.e. by putting indexes on the contractid column etc) The first thing I always like to do when fixing deadlocks is tune the queries involved. If you can get a good performance improvement then you get the...
329,805
<p>In jQuery, if I assign <code>class=auto_submit_form</code> to a form, it will be submitted whenever any element is changed, with the following code:</p> <pre><code>/* automatically submit if any element in the form changes */ $(function() { $(".auto_submit_form").change(function() { this.submit(); }); }); <...
[ { "answer_id": 329810, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 6, "selected": true, "text": "<pre><code> /* submit if elements of class=auto_submit_item in the form changes */\n$(function() {\n $(\".auto_submit_...
2008/12/01
[ "https://Stackoverflow.com/questions/329805", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41759/" ]
In jQuery, if I assign `class=auto_submit_form` to a form, it will be submitted whenever any element is changed, with the following code: ``` /* automatically submit if any element in the form changes */ $(function() { $(".auto_submit_form").change(function() { this.submit(); }); }); ``` However, if I want t...
``` /* submit if elements of class=auto_submit_item in the form changes */ $(function() { $(".auto_submit_item").change(function() { $("form").submit(); }); }); ``` Assumes you only have one form on the page. If not, you'll need to do select the form that is an ancestor of the current element using `$(th...
329,816
<p>I have a WPF TabControl with two TabItems. Each TabItem contains a ListBox with a separate ObservableCollection as its ItemsSource. Each ListBox has a different ItemTemplate. </p> <p>No matter which TabItem I set to be selected at startup, that tab will be displayed fine, but when I click on the other tab the ap...
[ { "answer_id": 329852, "author": "Geoff Cox", "author_id": 30505, "author_profile": "https://Stackoverflow.com/users/30505", "pm_score": 0, "selected": false, "text": "<p>I think the problem is that both ListBox's ItemSource=\"{Binding}\". I think this says to bind to the Window's DataC...
2008/12/01
[ "https://Stackoverflow.com/questions/329816", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25044/" ]
I have a WPF TabControl with two TabItems. Each TabItem contains a ListBox with a separate ObservableCollection as its ItemsSource. Each ListBox has a different ItemTemplate. No matter which TabItem I set to be selected at startup, that tab will be displayed fine, but when I click on the other tab the application cra...
> > No matter which TabItem I set to be selected at startup, that tab will be displayed fine, but when I click on the other tab the application crashes with an 'Exception has been thrown by the target of an invocation' error pointing toward the DataTemplate for the tab I'm switching to. > > > Enable first-chance e...
329,822
<p>I have three tables in the many-to-many format. I.e, table A, B, and AB set up as you'd expect. </p> <p>Given some set of A ids, I need to select only the rows in AB that match all of the ids. </p> <p>Something like the following won't work:</p> <p>"SELECT * FROM AB WHERE A_id = 1 AND A_id = 2 AND A_id = 3 AND .....
[ { "answer_id": 329841, "author": "paxdiablo", "author_id": 14860, "author_profile": "https://Stackoverflow.com/users/14860", "pm_score": 1, "selected": false, "text": "<p>Your database doesn't appear to be normalized correctly. Your <code>AB</code> table should have a single <code>A_id<...
2008/12/01
[ "https://Stackoverflow.com/questions/329822", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42033/" ]
I have three tables in the many-to-many format. I.e, table A, B, and AB set up as you'd expect. Given some set of A ids, I need to select only the rows in AB that match all of the ids. Something like the following won't work: "SELECT \* FROM AB WHERE A\_id = 1 AND A\_id = 2 AND A\_id = 3 AND ... " As no single row...
A bit of a hacky solution is to use IN with a group by and having filter. Like so: ``` SELECT B_id FROM AB WHERE A_id IN (1,2,3) GROUP BY B_id HAVING COUNT(DISTINCT A_id) = 3; ``` That way, you only get the B\_id values that have exactly 3 A\_id values, and they have to be from your list. I used DISTINCT in the COUN...
329,837
<p>I need to create simple reusable javascript object publishing several methods and parameterized constructor. After reading through several "OOP in JavaScript" guides I'm sitting here with an empty head. How on the Earth can I do this?</p> <p>Here my last non-working code:</p> <pre><code>SomeClass = function(id) { ...
[ { "answer_id": 329846, "author": "JW.", "author_id": 4321, "author_profile": "https://Stackoverflow.com/users/4321", "pm_score": 3, "selected": false, "text": "<p>This is my usual approach:</p>\n\n<pre><code>MyClass = function(x, y, z) {\n // This is the constructor. When you use it wi...
2008/12/01
[ "https://Stackoverflow.com/questions/329837", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2313/" ]
I need to create simple reusable javascript object publishing several methods and parameterized constructor. After reading through several "OOP in JavaScript" guides I'm sitting here with an empty head. How on the Earth can I do this? Here my last non-working code: ``` SomeClass = function(id) { this._id = id; } ...
All **vars** are private: ``` SomeClass = function (id) { var THIS = this; // unambiguous reference THIS._id = id; var intFun = function () { // private return THIS._id; } this.extFun = function () { // public return intFun(); } } ``` Use **`THIS`** within private methods si...
329,838
<p>I have, for my game, a Packet class, which represents network packet and consists basically of an array of data, and some pure virtual functions</p> <p>I would then like to have classes deriving from Packet, for example: StatePacket, PauseRequestPacket, etc. Each one of these sub-classes would implement the virtual...
[ { "answer_id": 329844, "author": "Martin York", "author_id": 14065, "author_profile": "https://Stackoverflow.com/users/14065", "pm_score": 0, "selected": false, "text": "<p>You need to look up the Factory Pattern.</p>\n\n<p>The factory looks at the incomming data and created an object of...
2008/12/01
[ "https://Stackoverflow.com/questions/329838", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42029/" ]
I have, for my game, a Packet class, which represents network packet and consists basically of an array of data, and some pure virtual functions I would then like to have classes deriving from Packet, for example: StatePacket, PauseRequestPacket, etc. Each one of these sub-classes would implement the virtual functions...
For copying you need to write a clone function, since a constructor cannot be virtual: ``` virtual Packet * clone() const = 0; ``` Which each Packet implementation implement like this: ``` virtual Packet * clone() const { return new StatePacket(*this); } ``` for example for StatePacket. Packet classes should ...
329,865
<p>I am trying to create a serial port in VB.net using code only. Because I am creating a class library I cannot use the built-in component. I have tried instantiating a new SeialPort() object, but that does not seem to be enough. I'm sure there is something simple I am missing and any help would be greatly appreciated...
[ { "answer_id": 329877, "author": "Hapkido", "author_id": 27646, "author_profile": "https://Stackoverflow.com/users/27646", "pm_score": 0, "selected": false, "text": "<p>I have used the SerialPort .Net class in a past project and I worked fine. You really don't need anything else. Check...
2008/12/01
[ "https://Stackoverflow.com/questions/329865", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21958/" ]
I am trying to create a serial port in VB.net using code only. Because I am creating a class library I cannot use the built-in component. I have tried instantiating a new SeialPort() object, but that does not seem to be enough. I'm sure there is something simple I am missing and any help would be greatly appreciated! T...
If you want to use the events make sure you declare your serialPort object using the 'withevents'. The below example will allow you to connect to a serial port, and will raise an event with the received string. ``` Imports System.Threading Imports System.IO Imports System.Text Imports System.IO.Ports Public Class...
329,866
<p>I can successfully connect to MySQL from a DOS prompt, but when I try to connect from cygwin, it just hangs.</p> <pre><code>$/cygdrive/c/Program\ Files/MySQL/MySQL\ Server\ 5.1/bin/mysql -u root -p </code></pre> <p>What's wrong?</p>
[ { "answer_id": 329941, "author": "Ken Gentle", "author_id": 8709, "author_profile": "https://Stackoverflow.com/users/8709", "pm_score": 5, "selected": true, "text": "<p>Assuming that you have a native Windows build of MySQL, there is a terminal emulation incompatibility between <code>DOS...
2008/12/01
[ "https://Stackoverflow.com/questions/329866", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1094969/" ]
I can successfully connect to MySQL from a DOS prompt, but when I try to connect from cygwin, it just hangs. ``` $/cygdrive/c/Program\ Files/MySQL/MySQL\ Server\ 5.1/bin/mysql -u root -p ``` What's wrong?
Assuming that you have a native Windows build of MySQL, there is a terminal emulation incompatibility between `DOS` (command prompt) windows and `bash`. The prompt for `mysql` isn't showing up. To confirm this, type a command and return - it will probably work, but the prompt and the echo of the command (what you're t...
329,876
<p>i have a few classes that i am trying to move to using generics</p> <p>Class1: Curve</p> <p>this class has the following code:</p> <pre><code>public class Curve : IEnumerable IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); // Calls non-interface method } public RTRatePointE...
[ { "answer_id": 329888, "author": "C. Broadbent", "author_id": 28859, "author_profile": "https://Stackoverflow.com/users/28859", "pm_score": 0, "selected": false, "text": "<p><code>IEnumerable&lt;T&gt; and IEnumerator&lt;T&gt;</code></p>\n\n<p>gah, it swallowed my code</p>\n" }, { ...
2008/12/01
[ "https://Stackoverflow.com/questions/329876", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4653/" ]
i have a few classes that i am trying to move to using generics Class1: Curve this class has the following code: ``` public class Curve : IEnumerable IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); // Calls non-interface method } public RTRatePointEnumerator GetEnumerator() ...
You didn't specify the type being returned from the enumerator. but I'm going to guess based on the names it's RTRatePoint and CurvePoint. I would change the code to be the following ``` class Curve: IEnumerable<RTRatePoint> { IEnumerator<RTRatePoint> IEnumerable<RTRatePoint>.GetEnumerator() { return GetEnumer...
329,886
<p>Basically, I would like to build a list comprehension over the "cartesian product" of two iterators. Think about the following <a href="http://www.haskell.org/haskellwiki/List_comprehension" rel="noreferrer">Haskell code</a>:</p> <pre><code>[(i,j) | i &lt;- [1,2], j &lt;- [1..4]] </code></pre> <p>which yields</p> ...
[ { "answer_id": 329904, "author": "S.Lott", "author_id": 10661, "author_profile": "https://Stackoverflow.com/users/10661", "pm_score": 5, "selected": true, "text": "<p>Are you asking about this?</p>\n\n<pre><code>[ (i,j) for i in range(1,3) for j in range(1,5) ]\n</code></pre>\n" }, {...
2008/12/01
[ "https://Stackoverflow.com/questions/329886", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18770/" ]
Basically, I would like to build a list comprehension over the "cartesian product" of two iterators. Think about the following [Haskell code](http://www.haskell.org/haskellwiki/List_comprehension): ``` [(i,j) | i <- [1,2], j <- [1..4]] ``` which yields ``` [(1,1),(1,2),(1,3),(1,4),(2,1),(2,2),(2,3),(2,4)] ``` Can...
Are you asking about this? ``` [ (i,j) for i in range(1,3) for j in range(1,5) ] ```
329,900
<p>My question revolves around CSS Fixed Layout vs a Float Layout that extends to fill the width of the browser.</p> <p>Right now the issue I'm running into is to have the masthead resize depending on the width of the page (something that I understand isn't possible given current browser implementation of <a href="htt...
[ { "answer_id": 329975, "author": "Logan Serman", "author_id": 29595, "author_profile": "https://Stackoverflow.com/users/29595", "pm_score": 1, "selected": false, "text": "<p>If you are trying to expand your background-image to the width of your page, it is better to use a fixed-sized lay...
2008/12/01
[ "https://Stackoverflow.com/questions/329900", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16587/" ]
My question revolves around CSS Fixed Layout vs a Float Layout that extends to fill the width of the browser. Right now the issue I'm running into is to have the masthead resize depending on the width of the page (something that I understand isn't possible given current browser implementation of [CSS3's `background-im...
What about revealing more or less of the image as the browser is resized, rather than scaling the image? It's not quite the same effect, but it's an easy way to fill an entire space with an image. Let's assume, for the sake of the example, that your masthead's background image contains a logo of some sort on top of, s...
329,911
<p>I've just installed Ocaml on Mac OS X, and when I run the ocaml program I get a "Bus Error" with no other clues to what might be going on. Can anyone offer suggestions on where to go from here?</p> <p>EDIT:</p> <p>I installed via the package: </p> <p><a href="http://caml.inria.fr/pub/distrib/ocaml-3.10/ocaml-3....
[ { "answer_id": 329916, "author": "Dustin", "author_id": 39975, "author_profile": "https://Stackoverflow.com/users/39975", "pm_score": 1, "selected": false, "text": "<p>Did you install it from macports? It's working fine for me. Can you describe some more details about your installation...
2008/12/01
[ "https://Stackoverflow.com/questions/329911", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30529/" ]
I've just installed Ocaml on Mac OS X, and when I run the ocaml program I get a "Bus Error" with no other clues to what might be going on. Can anyone offer suggestions on where to go from here? EDIT: I installed via the package: <http://caml.inria.fr/pub/distrib/ocaml-3.10/ocaml-3.10.2-ppc.dmg> (I have an iBook G...
Turns out I was installing a version of OCaml built for Mac OS X 10.5.x (Leopard) on my machine running 10.4.x (Tiger). One would think it would be easy for the installer to catch this, but alas...
329,918
<h2>What I'm trying to accomplish</h2> <ul> <li>My app generates some tabular data</li> <li>I want the user to be able to launch Excel and click "paste" to place the data as cells in Excel</li> <li>Windows accepts a format called "CommaSeparatedValue" that is used with it's APIs so this seems possible</li> <li>Putting...
[ { "answer_id": 329967, "author": "BFree", "author_id": 15861, "author_profile": "https://Stackoverflow.com/users/15861", "pm_score": 3, "selected": false, "text": "<p>Use tabs instead of commas. ie:</p>\n\n<pre><code>Clipboard.SetText(\"1\\t2\\t3\\t4\\t3\\t2\\t3\\t4\", TextDataFormat.Tex...
2008/12/01
[ "https://Stackoverflow.com/questions/329918", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13477/" ]
What I'm trying to accomplish ----------------------------- * My app generates some tabular data * I want the user to be able to launch Excel and click "paste" to place the data as cells in Excel * Windows accepts a format called "CommaSeparatedValue" that is used with it's APIs so this seems possible * Putting raw te...
The .NET Framework places `DataFormats.CommaSeparatedValue` on the clipboard as Unicode text. But as mentioned at <http://www.syncfusion.com/faq/windowsforms/faq_c98c.aspx#q899q>, Excel expects CSV data to be a UTF-8 memory stream (it is difficult to say whether .NET or Excel is at fault for the incompatibility). The ...
329,931
<p>I'm wondering if this is possible in SQL. Say you have two tables A and B, and you do a select on table A and join on table B:</p> <pre><code>SELECT a.*, b.* FROM TABLE_A a JOIN TABLE_B b USING (some_id); </code></pre> <p>If table A has columns 'a_id', 'name', and 'some_id', and table B has 'b_id', 'name', and 'some...
[ { "answer_id": 329939, "author": "dkretz", "author_id": 31641, "author_profile": "https://Stackoverflow.com/users/31641", "pm_score": 2, "selected": false, "text": "<p>DIfferent database products will give you different answers; but you're setting yourself up for hurt if you carry this v...
2008/12/01
[ "https://Stackoverflow.com/questions/329931", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26353/" ]
I'm wondering if this is possible in SQL. Say you have two tables A and B, and you do a select on table A and join on table B: ``` SELECT a.*, b.* FROM TABLE_A a JOIN TABLE_B b USING (some_id); ``` If table A has columns 'a\_id', 'name', and 'some\_id', and table B has 'b\_id', 'name', and 'some\_id', the query will...
I see two possible situations here. First, you want to know if there is a SQL standard for this, that you can use in general regardless of the database. No, there is not. Second, you want to know with regard to a specific dbms product. Then you need to identify it. But I imagine the most likely answer is that you'll ge...
329,956
<p>First, context: I'm trying to create a command-line-based tool (Linux) that requires login. Accounts on this tool have nothing to do with system-level accounts -- none of this looks at /etc/passwd.</p> <p>I am planning to store user accounts in a text file using the same format (roughly) as /etc/passwd.</p> <p>Des...
[ { "answer_id": 329995, "author": "genehack", "author_id": 39933, "author_profile": "https://Stackoverflow.com/users/39933", "pm_score": 2, "selected": false, "text": "<p>You're misunderstanding the documentation; it says that since the length of the salt may vary depending on the underly...
2008/12/01
[ "https://Stackoverflow.com/questions/329956", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19207/" ]
First, context: I'm trying to create a command-line-based tool (Linux) that requires login. Accounts on this tool have nothing to do with system-level accounts -- none of this looks at /etc/passwd. I am planning to store user accounts in a text file using the same format (roughly) as /etc/passwd. Despite not using th...
For the use of the crypt module: When GENERATING the crypted password, you provide the salt. It might as well be random to increase resistance to brute-forcing, as long as it meets the listed conditions. When CHECKING a password, you should provide the value from getpwname, in case you are on a system that supports la...
329,957
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/164926/c-sharp-how-do-i-round-a-decimal-value-to-2-decimal-places-for-output-on-a-pa">c# - How do I round a decimal value to 2 decimal places (for output on a page)</a> </p> </blockquote> <p>I want to truncate ...
[ { "answer_id": 329982, "author": "Christian C. Salvadó", "author_id": 5445, "author_profile": "https://Stackoverflow.com/users/5445", "pm_score": 6, "selected": false, "text": "<p>You can use <a href=\"http://msdn.microsoft.com/en-us/library/zy06z30k.aspx\" rel=\"noreferrer\">Math.Round<...
2008/12/01
[ "https://Stackoverflow.com/questions/329957", "https://Stackoverflow.com", "https://Stackoverflow.com/users/709/" ]
> > **Possible Duplicate:** > > [c# - How do I round a decimal value to 2 decimal places (for output on a page)](https://stackoverflow.com/questions/164926/c-sharp-how-do-i-round-a-decimal-value-to-2-decimal-places-for-output-on-a-pa) > > > I want to truncate the decimals like below i.e. * 2.22939393 -> 2.22...
``` double d = 2.22977777; d = ( (double) ( (int) (d * 1000.0) ) ) / 1000.0 ; ``` Of course, this won't work if you're trying to truncate rounding error, but it should work fine with the values you give in your examples. See the first two answers to [this question](https://stackoverflow.com/questions/304011/truncate-...
329,962
<p>I wrote a program out, which was all in one file, and the methods were forward declared in a header. The program initially worked perfectly when it was in one file. But when I separated the program, I kept getting random occurrences for the destructor of one of the classes which was declared in the header file. <...
[ { "answer_id": 329974, "author": "Uri", "author_id": 23072, "author_profile": "https://Stackoverflow.com/users/23072", "pm_score": 0, "selected": false, "text": "<p>Can you elaborate what you mean by the \"value seems to be off\"? Do you get too many constructions? Not enough destruction...
2008/12/01
[ "https://Stackoverflow.com/questions/329962", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33481/" ]
I wrote a program out, which was all in one file, and the methods were forward declared in a header. The program initially worked perfectly when it was in one file. But when I separated the program, I kept getting random occurrences for the destructor of one of the classes which was declared in the header file. I hav...
``` class A { public: virtual ~A() { count --; if (count == 0) { // this is the last one, do something } } protected: static int count; }; class B : public A{ public: B(); }; ``` And then, in one and only one of your source files you need to put the following. It should go in the source f...
329,977
<p>When creating a string using the following notation:</p> <pre><code>NSString *foo = @"Bar"; </code></pre> <p>Does one need to release <code>foo</code>? Or is <code>foo</code> autoreleased in this case?</p>
[ { "answer_id": 329985, "author": "Ben Gottlieb", "author_id": 6694, "author_profile": "https://Stackoverflow.com/users/6694", "pm_score": 5, "selected": true, "text": "<p>Compiler allocated strings (of the format @\"STRING\") are constant, and so -retain, -release, and -autorelease messa...
2008/12/01
[ "https://Stackoverflow.com/questions/329977", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40882/" ]
When creating a string using the following notation: ``` NSString *foo = @"Bar"; ``` Does one need to release `foo`? Or is `foo` autoreleased in this case?
Compiler allocated strings (of the format @"STRING") are constant, and so -retain, -release, and -autorelease messages to them are ignored. You don't have to release or autorelease foo in this case (but it won't hurt).
330,010
<p>I'm trying to display a caret (<code>^</code>) in math mode in LaTeX to represent the exclusive or operation implemented in the "C languages". By default, <code>^</code> is for creating a superscript in math mode. The closest I can seem to get is by using <code>\wedge</code>, which isn't the same.</p>
[ { "answer_id": 330019, "author": "genehack", "author_id": 39933, "author_profile": "https://Stackoverflow.com/users/39933", "pm_score": 3, "selected": false, "text": "<p>How about </p>\n\n<pre><code>\\^{}\n</code></pre>\n\n<p>or </p>\n\n<pre><code>\\verb|^|\n</code></pre>\n\n<p>?</p>\n" ...
2008/12/01
[ "https://Stackoverflow.com/questions/330010", "https://Stackoverflow.com", "https://Stackoverflow.com/users/488/" ]
I'm trying to display a caret (`^`) in math mode in LaTeX to represent the exclusive or operation implemented in the "C languages". By default, `^` is for creating a superscript in math mode. The closest I can seem to get is by using `\wedge`, which isn't the same.
You might want to use the common symbol for exclusive or instead, \oplus (but give it a proper name with something like `\newcommand\XOR{\oplus}`). The caret is a bit too small to be noticeable as a binary operator. However, if you do insist using a caret instead, use this: ``` \newcommand\XOR{\mathbin{\char`\^}} $x...
330,030
<p>I have an object, and I want to list all the selectors to which it responds. It feels like this should be perfectly possible, but I'm having trouble finding the APIs.</p>
[ { "answer_id": 330084, "author": "Rob", "author_id": 386102, "author_profile": "https://Stackoverflow.com/users/386102", "pm_score": 0, "selected": false, "text": "<p>Something like this should work (just put it in the object you're curious about). For example if you have an object that'...
2008/12/01
[ "https://Stackoverflow.com/questions/330030", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18017/" ]
I have an object, and I want to list all the selectors to which it responds. It feels like this should be perfectly possible, but I'm having trouble finding the APIs.
This is a solution based on the runtime C functions: class\_copyMethodList returns a list of class methods given a Class object obtainable from an object. ``` #import <objc/runtime.h> ``` [..] ``` SomeClass * t = [[SomeClass alloc] init]; int i=0; unsigned int mc = 0; Method * mlist = class_copyMethodList(object_...
330,034
<p>When I pass a list of objects out of my silverlight app using WCF everything works fine until the List grows too big. It seems that when I exceed 80 items I get the error: The remote server returned an unexpected response: (404) Not Found</p> <p>I'm presuming that it's because the List has grown too big as when the...
[ { "answer_id": 330818, "author": "Shawn Wildermuth", "author_id": 40125, "author_profile": "https://Stackoverflow.com/users/40125", "pm_score": 2, "selected": false, "text": "<p>There are two config files. The silverlight clientconfig will let you send the larger message, but if you'r e...
2008/12/01
[ "https://Stackoverflow.com/questions/330034", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
When I pass a list of objects out of my silverlight app using WCF everything works fine until the List grows too big. It seems that when I exceed 80 items I get the error: The remote server returned an unexpected response: (404) Not Found I'm presuming that it's because the List has grown too big as when the List had ...
There are two config files. The silverlight clientconfig will let you send the larger message, but if you'r eusing WCF, there is a server web.config that limits the size of the received message (to prevent DDOS attacks).
330,043
<p>I have a structure that represents a wire format packet. In this structure is an array of other structures. I have generic code that handles this very nicely for most cases but this array of structures case is throwing the marshaller for a loop.</p> <p>Unsafe code is a no go since I can't get a pointer to a struc...
[ { "answer_id": 330090, "author": "grieve", "author_id": 34329, "author_profile": "https://Stackoverflow.com/users/34329", "pm_score": 2, "selected": false, "text": "<p>Using memcpy to copy an array of bytes to a structure is extremely dangerous if you are not controlling the byte packing...
2008/12/01
[ "https://Stackoverflow.com/questions/330043", "https://Stackoverflow.com", "https://Stackoverflow.com/users/109736/" ]
I have a structure that represents a wire format packet. In this structure is an array of other structures. I have generic code that handles this very nicely for most cases but this array of structures case is throwing the marshaller for a loop. Unsafe code is a no go since I can't get a pointer to a struct with an ar...
Using memcpy to copy an array of bytes to a structure is extremely dangerous if you are not controlling the byte packing of the structure. It is safer to marshall and unmarshall a structure one field at a time. Of course you will lose the generic feature of the sample code you have given. To answer your real question ...
330,053
<p>I have a simple row that I edit using LINQ. It has about 30 columns, including a primary key numeric sequence.</p> <p>When an UPDATE is performed through LINQ, the UPDATE statement includes all the columns of the table (for concurrency checking). </p> <p>I'm wondering how inefficient this is - if not negligibiel. ...
[ { "answer_id": 330073, "author": "Jeff Atwood", "author_id": 1, "author_profile": "https://Stackoverflow.com/users/1", "pm_score": 5, "selected": false, "text": "<p>We ran into this early on Stack Overflow. Every LINQ to SQL update verifies that the underlying fields haven't changed befo...
2008/12/01
[ "https://Stackoverflow.com/questions/330053", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16940/" ]
I have a simple row that I edit using LINQ. It has about 30 columns, including a primary key numeric sequence. When an UPDATE is performed through LINQ, the UPDATE statement includes all the columns of the table (for concurrency checking). I'm wondering how inefficient this is - if not negligibiel. Since there is an...
Your assertion that the overhead for the update check is negligible is correct. If there is an index (or primary key) that is satisfied by any part of the where clause, then that will be used. The cost for checking the other columns is negligible. You can confirm this by enabling the execution plan display in SQL manag...
330,060
<p>I create an <code>NSURLRequest</code> to post my data in the iPhone application to a server to proceed the PHP script. My PHP script is look like this.</p> <pre><code>&lt;?php $name = $_POST['name']; $email = $_POST['email']; $link = mysql_connect("localhost", "fffasfdas","Nfdsafafs") or die ("Unable t...
[ { "answer_id": 330064, "author": "superfell", "author_id": 41455, "author_profile": "https://Stackoverflow.com/users/41455", "pm_score": 6, "selected": false, "text": "<p>You should remove the leading <code>&amp;</code> in <code>myRequestString</code> and the problem is likely that the c...
2008/12/01
[ "https://Stackoverflow.com/questions/330060", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I create an `NSURLRequest` to post my data in the iPhone application to a server to proceed the PHP script. My PHP script is look like this. ``` <?php $name = $_POST['name']; $email = $_POST['email']; $link = mysql_connect("localhost", "fffasfdas","Nfdsafafs") or die ("Unable to connect to database."); ...
You should remove the leading `&` in `myRequestString` and the problem is likely that the correct `content-type` header is not being sent. Try adding a call to ``` [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"content-type"]; ``` You should also not pass `nil` for error, so you can see ...
330,074
<p>I've one plist file and I want to parse it and copy it's content into NSArray,and code that I am using for that is. </p> <pre><code>NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES); NSString *documentsPath = [paths objectAtIndex:0]; NSString *fooPath = [documentsP...
[ { "answer_id": 330083, "author": "superfell", "author_id": 41455, "author_profile": "https://Stackoverflow.com/users/41455", "pm_score": 0, "selected": false, "text": "<p>Are you generating the file with <a href=\"http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classe...
2008/12/01
[ "https://Stackoverflow.com/questions/330074", "https://Stackoverflow.com", "https://Stackoverflow.com/users/451867/" ]
I've one plist file and I want to parse it and copy it's content into NSArray,and code that I am using for that is. ``` NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES); NSString *documentsPath = [paths objectAtIndex:0]; NSString *fooPath = [documentsPath stringByAppen...
Depending on how you generated the .plist initially, you may run into problems if you try and read it back in as an array. The safest way to read a plist is using the NSPropertyListSerialization class: [Apple Doc.](https://developer.apple.com/iphone/library/documentation/Cocoa/Reference/Foundation/Classes/NSPropertyLis...
330,085
<p>My aim is to convert a stream of byte code sent from an Alesis synthesizer to a human readable format. I need to be able to take a "Program Dump" and read the 10 character string that makes up the patch name.</p> <p>In order to receive the "Program Dump" from the synth, I sent the synth the following command via M...
[ { "answer_id": 331329, "author": "PhiLho", "author_id": 15459, "author_profile": "https://Stackoverflow.com/users/15459", "pm_score": 2, "selected": false, "text": "<p>You are lucky, because some years ago I played a bit with Midi (with my Atari ST 520) so I had enough interest in the to...
2008/12/01
[ "https://Stackoverflow.com/questions/330085", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42054/" ]
My aim is to convert a stream of byte code sent from an Alesis synthesizer to a human readable format. I need to be able to take a "Program Dump" and read the 10 character string that makes up the patch name. In order to receive the "Program Dump" from the synth, I sent the synth the following command via MIDI-OX: ``...
You are lucky, because some years ago I played a bit with Midi (with my Atari ST 520) so I had enough interest in the topic to investigate a bit... For the record, I found the [MIDI System Exclusive Message](http://crystal.apana.org.au/ghansper/midi_introduction/midi_system_exclusive.html "MIDI System Exclusive Messag...
330,092
<p>I'm not familiar with shell scripting, so I'm not sure how to do it or if it is possible. If you can give me links or advice, that would be great.</p> <p>What I want to do is:</p> <ul> <li><p>Create a file, simple text file EX:</p> <p>param1 (RANDOMVALUE)</p> <p>Where randomvalue is a random number generated.</p> ...
[ { "answer_id": 330105, "author": "Federico A. Ramponi", "author_id": 18770, "author_profile": "https://Stackoverflow.com/users/18770", "pm_score": 2, "selected": false, "text": "<p>You have almost written the script already. The only missing thing is the random number; I'll do it with Pe...
2008/12/01
[ "https://Stackoverflow.com/questions/330092", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm not familiar with shell scripting, so I'm not sure how to do it or if it is possible. If you can give me links or advice, that would be great. What I want to do is: * Create a file, simple text file EX: param1 (RANDOMVALUE) Where randomvalue is a random number generated. * run a program with that file we just c...
You have almost written the script already. The only missing thing is the random number; I'll do it with Perl. Here is a quick & dirty solution in sh (or bash; I'm presuming you're on a Linux/Unix system): ``` #!/bin/sh perl -e 'print "TheWord (", int(rand(1000)), ")\n"' > tempfile ./program tempfile > A ./Anotherprog...
330,115
<p>In C#, it is possible to retrieve assembly related information like product name, version etc using reflection:</p> <pre><code>string productName = Assembly.GetCallingAssembly().GetName().Name; string versionString = Assembly.GetCallingAssembly().GetName().Version.ToString(); </code></pre> <p>How do I do the equiv...
[ { "answer_id": 330314, "author": "Dirk Vollmar", "author_id": 40347, "author_profile": "https://Stackoverflow.com/users/40347", "pm_score": 0, "selected": false, "text": "<p>you could use the following code in VB.Net to retrieve extended document properties:</p>\n\n<pre><code>Sub Main()\...
2008/12/01
[ "https://Stackoverflow.com/questions/330115", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4368/" ]
In C#, it is possible to retrieve assembly related information like product name, version etc using reflection: ``` string productName = Assembly.GetCallingAssembly().GetName().Name; string versionString = Assembly.GetCallingAssembly().GetName().Version.ToString(); ``` How do I do the equivalent if the executing ass...
Walking the stack is not necessary to find out what process you are in. You simply make a single Win32 API call: ``` HMODULE hEXE = GetModuleHandle(NULL); ``` According to the [documentation for this call](http://msdn.microsoft.com/en-us/library/ms683199(VS.85).aspx): > > If this parameter is NULL, GetModuleHandle...
330,138
<p>I have got these two classes interacting and I am trying to call four different classes from class one for use in class two.</p> <p>The methods are public and they do return values but for some reason there is not a connection being made. The error I get when I try is: <code>"An object reference is required for the...
[ { "answer_id": 330140, "author": "Jeffrey L Whitledge", "author_id": 10174, "author_profile": "https://Stackoverflow.com/users/10174", "pm_score": 2, "selected": false, "text": "<p>You have to create a variable of the type of the class, and set it equal to a new instance of the object fi...
2008/12/01
[ "https://Stackoverflow.com/questions/330138", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29756/" ]
I have got these two classes interacting and I am trying to call four different classes from class one for use in class two. The methods are public and they do return values but for some reason there is not a connection being made. The error I get when I try is: `"An object reference is required for the nonstatic fiel...
You're trying to call an instance method on the class. To call an instance method on a class you must create an instance on which to call the method. If you want to call the method on non-instances add the static keyword. For example ``` class Example { public static string NonInstanceMethod() { return "static";...
330,151
<p>I'm not sure if this has been asked or not yet, but how much logic should you put in your UI classes?</p> <p>When I started programming I used to put all my code behind events on the form which as everyone would know makes it an absolute pain in the butt to test and maintain. Overtime I have come to release how ba...
[ { "answer_id": 330157, "author": "yesraaj", "author_id": 22076, "author_profile": "https://Stackoverflow.com/users/22076", "pm_score": 0, "selected": false, "text": "<p>Input validations attached to control.\nLike emails,age,date validators with text boxes</p>\n" }, { "answer_id"...
2008/12/01
[ "https://Stackoverflow.com/questions/330151", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6335/" ]
I'm not sure if this has been asked or not yet, but how much logic should you put in your UI classes? When I started programming I used to put all my code behind events on the form which as everyone would know makes it an absolute pain in the butt to test and maintain. Overtime I have come to release how bad this prac...
Just logic dealing with the UI. Sometimes people try to put even that into the Business layer. For example, one might have in their BL: ``` if (totalAmount < 0) color = "RED"; else color = "BLACK"; ``` And in the UI display totalAmount using color -- which is completely wrong. It should be: ``` if (tota...
330,155
<p>Can someone tell me how to change directories using FtpWebRequest? This seems like it should be an easy thing to do, but I'm not seeing it.</p> <p><strong>EDIT</strong></p> <p>I just want to add...I don't have my heart set on FtpWebRequest. If there's a better (easier) way to do FTP in .NET please let me know.</...
[ { "answer_id": 330177, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 5, "selected": true, "text": "<p>There's a <a href=\"http://blogs.msdn.com/mariya/archive/2006/03/06/544523.aspx\" rel=\"noreferrer\">blog post</a> fro...
2008/12/01
[ "https://Stackoverflow.com/questions/330155", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4050/" ]
Can someone tell me how to change directories using FtpWebRequest? This seems like it should be an easy thing to do, but I'm not seeing it. **EDIT** I just want to add...I don't have my heart set on FtpWebRequest. If there's a better (easier) way to do FTP in .NET please let me know. --- Apparently there's no way t...
There's a [blog post](http://blogs.msdn.com/mariya/archive/2006/03/06/544523.aspx) from Mariya Atanasova which shows how you can fake it - basically you have to put the directory on the URL. I suspect you may be better off with a dedicated FTP library though - one that doesn't try to force everything into the WebReque...
330,169
<p>It's been quite a while since I last used <a href="http://digitalmars.com/d" rel="nofollow noreferrer">D Programming Language</a>, and now I'm using it for some project that involves scientific calculations.</p> <p>I have a bunch of floating point data, but when I print them using <code>writefln</code>, I get resul...
[ { "answer_id": 330192, "author": "Federico A. Ramponi", "author_id": 18770, "author_profile": "https://Stackoverflow.com/users/18770", "pm_score": 2, "selected": false, "text": "<p>Try something like</p>\n\n<pre><code>writefln(\"%.3f\", a);\n</code></pre>\n" }, { "answer_id": 330...
2008/12/01
[ "https://Stackoverflow.com/questions/330169", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35364/" ]
It's been quite a while since I last used [D Programming Language](http://digitalmars.com/d), and now I'm using it for some project that involves scientific calculations. I have a bunch of floating point data, but when I print them using `writefln`, I get results like: `4.62593E-172` which is a zero! How do I use stri...
Short answer: This can't be done with printf format specifiers. Since D uses the same formatting as C99's `vsprintf()`, you find your answer in this thread: [Avoid trailing zeroes in printf()](https://stackoverflow.com/questions/277772)
330,178
<p>Checkstyle reports this code as "The double-checked locking idiom is broken", but I don't think that my code actually is affected by the problems with double-checked locking.</p> <p>The code is supposed to create a row in a database if a row with that id doesn't exist. It runs in a multi-threaded environment and I ...
[ { "answer_id": 330184, "author": "Dustin", "author_id": 39975, "author_profile": "https://Stackoverflow.com/users/39975", "pm_score": 3, "selected": true, "text": "<p>Assuming you want that innermost line to read:</p>\n\n<pre><code>row = dao().create(id);\n</code></pre>\n\n<p>It's not a ...
2008/12/01
[ "https://Stackoverflow.com/questions/330178", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40136/" ]
Checkstyle reports this code as "The double-checked locking idiom is broken", but I don't think that my code actually is affected by the problems with double-checked locking. The code is supposed to create a row in a database if a row with that id doesn't exist. It runs in a multi-threaded environment and I want to av...
Assuming you want that innermost line to read: ``` row = dao().create(id); ``` It's not a classic double-checked lock problem assuming `dao().fetch` is properly mutexed from the create method. **Edit**: (code was updated) The classic problem of a double-checked lock is having a value assigned before initialization...
330,186
<p>I'm currently working on a DNA database class and I currently associate each row in the database with both a match score (based on edit distance) and the actual DNA sequence itself, is it safe to modify first this way within an iteration loop?</p> <pre><code>typedef std::pair&lt;int, DnaDatabaseRow&gt; DnaPairT; ty...
[ { "answer_id": 330196, "author": "e.James", "author_id": 33686, "author_profile": "https://Stackoverflow.com/users/33686", "pm_score": 4, "selected": true, "text": "<p>To answer your first question, yes. It is perfectly safe to modify the members of your pair, since the actual data in th...
2008/12/01
[ "https://Stackoverflow.com/questions/330186", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2594/" ]
I'm currently working on a DNA database class and I currently associate each row in the database with both a match score (based on edit distance) and the actual DNA sequence itself, is it safe to modify first this way within an iteration loop? ``` typedef std::pair<int, DnaDatabaseRow> DnaPairT; typedef std::vector<Dn...
To answer your first question, yes. It is perfectly safe to modify the members of your pair, since the actual data in the pair does not affect the vector itself. **edit:** I have a feeling that you were getting an error when using a map because you tried to modify the `first` value of the map's internal pair. That wou...
330,206
<p>In PHP, depending on your error reporting level, if you don't define a constant and then call it like so:</p> <pre><code>&lt;?= MESSAGE ?&gt; </code></pre> <p>It may print the name of the constant instead of the value!</p> <p>So, I wrote the following function to get around this problem, but I wanted to know if y...
[ { "answer_id": 330212, "author": "Ray", "author_id": 40866, "author_profile": "https://Stackoverflow.com/users/40866", "pm_score": -1, "selected": false, "text": "<p>try </p>\n\n<pre>if (isset(constant($constant)) ...</pre>\n\n<p>This shouldn't trigger any E_NOTICE messages, so you don't...
2008/12/01
[ "https://Stackoverflow.com/questions/330206", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
In PHP, depending on your error reporting level, if you don't define a constant and then call it like so: ``` <?= MESSAGE ?> ``` It may print the name of the constant instead of the value! So, I wrote the following function to get around this problem, but I wanted to know if you know a way to do it in faster code? ...
As long as you don't mind using quotes on your constants, you can do this: ``` function C($constant) { return defined($constant) ? constant($constant) : 'Undefined'; } echo C('MESSAGE') . '<br />'; define('MESSAGE', 'test'); echo C('MESSAGE') . '<br />'; ``` Output: > > Undefined > > > test > > > Othe...
330,207
<p>One concept I've always wondered about is the use of cryptographic hash functions and values. I understand that these functions can generate a hash value that is unique and virtually impossible to reverse, but here's what I've always wondered:</p> <p>If on my server, in PHP I produce:</p> <pre><code>md5("stackover...
[ { "answer_id": 330210, "author": "Serafina Brocious", "author_id": 4977, "author_profile": "https://Stackoverflow.com/users/4977", "pm_score": 9, "selected": true, "text": "<p>The input material can be an infinite length, where the output is always 128 bits long. This means that an infi...
2008/12/01
[ "https://Stackoverflow.com/questions/330207", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1390354/" ]
One concept I've always wondered about is the use of cryptographic hash functions and values. I understand that these functions can generate a hash value that is unique and virtually impossible to reverse, but here's what I've always wondered: If on my server, in PHP I produce: ``` md5("stackoverflow.com") = "d0cc85b...
The input material can be an infinite length, where the output is always 128 bits long. This means that an infinite number of input strings will generate the same output. If you pick a random number and divide it by 2 but only write down the remainder, you'll get either a 0 or 1 -- even or odd, respectively. Is it pos...
330,229
<p>When presenting preformatted text on the web (e.g. code samples), line wrapping can be a problem. You want to wrap for readability without scrolling, but also need it to be unambiguous to the user that it is all one line with no line break.</p> <p>For example, you may have a really long command line to display, lik...
[ { "answer_id": 330297, "author": "eyelidlessness", "author_id": 17964, "author_profile": "https://Stackoverflow.com/users/17964", "pm_score": 1, "selected": false, "text": "<p>This cannot be done with CSS. Sorry. :(</p>\n" }, { "answer_id": 330352, "author": "Jack Ryan", ...
2008/12/01
[ "https://Stackoverflow.com/questions/330229", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6329/" ]
When presenting preformatted text on the web (e.g. code samples), line wrapping can be a problem. You want to wrap for readability without scrolling, but also need it to be unambiguous to the user that it is all one line with no line break. For example, you may have a really long command line to display, like this: `...
Here is one (unpleasant) way of doing this. It requires a number of bad practices. But SO is about solutions to real problems so here we go... First each line needs to be wrapped in some sort of containing block. Span or p are probably the most appropriate. Then the style of the containing block needs to have line he...
330,240
<p>This is a puzzle for me, I am able to get three DropDownLists to behave like a cascade (it fetches the correct data) but where I run into problem is where I try to set the value for the dropdownlist based on the value of the querystring. </p> <p>Only the first dropdownlist seems to take it's value from the queryst...
[ { "answer_id": 330251, "author": "leppie", "author_id": 15541, "author_profile": "https://Stackoverflow.com/users/15541", "pm_score": 3, "selected": true, "text": "<p>You can only set the SelectItem/Value/Text after databinding has happened.</p>\n" }, { "answer_id": 330948, "...
2008/12/01
[ "https://Stackoverflow.com/questions/330240", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40559/" ]
This is a puzzle for me, I am able to get three DropDownLists to behave like a cascade (it fetches the correct data) but where I run into problem is where I try to set the value for the dropdownlist based on the value of the querystring. Only the first dropdownlist seems to take it's value from the querystring. The o...
You can only set the SelectItem/Value/Text after databinding has happened.
330,241
<p>From my code (Java) I want to ensure that a row exists in the database (DB2) after my code is executed.</p> <p>My code now does a <code>select</code> and if no result is returned it does an <code>insert</code>. I really don't like this code since it exposes me to concurrency issues when running in a multi-threaded...
[ { "answer_id": 330364, "author": "Winston Smith", "author_id": 35086, "author_profile": "https://Stackoverflow.com/users/35086", "pm_score": 5, "selected": false, "text": "<p>Yes, DB2 has the MERGE statement, which will do an UPSERT (update or insert).</p>\n\n<pre><code>MERGE INTO target...
2008/12/01
[ "https://Stackoverflow.com/questions/330241", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40136/" ]
From my code (Java) I want to ensure that a row exists in the database (DB2) after my code is executed. My code now does a `select` and if no result is returned it does an `insert`. I really don't like this code since it exposes me to concurrency issues when running in a multi-threaded environment. What I would like ...
Yes, DB2 has the MERGE statement, which will do an UPSERT (update or insert). ``` MERGE INTO target_table USING source_table ON match-condition {WHEN [NOT] MATCHED THEN [UPDATE SET ...|DELETE|INSERT VALUES ....|SIGNAL ...]} [ELSE IGNORE] ``` See: ~~<http://publib.boulder.ibm.com/infocenter/db2luw/v9/inde...
330,268
<p>I have an array full of random content item ids. I need to run a mysql query (id in the array goes in the WHERE clause), using each ID that's in the array, in the order that they appear in the said array. How would I do this? </p> <p>This will be an UPDATE query, for each individual ID in the array.</p>
[ { "answer_id": 330274, "author": "Dean Rather", "author_id": 14966, "author_profile": "https://Stackoverflow.com/users/14966", "pm_score": 2, "selected": false, "text": "<h1>Using the \"IN\" Clause</h1>\n\n<p>Might be what you're after</p>\n\n<pre><code>$ids = array(2,4,6,8);\n$ids = imp...
2008/12/01
[ "https://Stackoverflow.com/questions/330268", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have an array full of random content item ids. I need to run a mysql query (id in the array goes in the WHERE clause), using each ID that's in the array, in the order that they appear in the said array. How would I do this? This will be an UPDATE query, for each individual ID in the array.
As with nearly all "How do I do SQL from within PHP" questions - You *really* should use prepared statements. It's not that hard: ``` $ids = array(2, 4, 6, 8); // prepare an SQL statement with a single parameter placeholder $sql = "UPDATE MyTable SET LastUpdated = GETDATE() WHERE id = ?"; $stmt = $mysqli->prepare($...
330,303
<p>Is it possible to create a stored procedure as</p> <pre><code>CREATE PROCEDURE Dummy @ID INT NOT NULL AS BEGIN END </code></pre> <p>Why is it not possible to do something like this?</p>
[ { "answer_id": 330324, "author": "dkretz", "author_id": 31641, "author_profile": "https://Stackoverflow.com/users/31641", "pm_score": 1, "selected": true, "text": "<p>Parameter validation is not currently a feature of procedural logic in SQL Server, and NOT NULL is only one possible type...
2008/12/01
[ "https://Stackoverflow.com/questions/330303", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21586/" ]
Is it possible to create a stored procedure as ``` CREATE PROCEDURE Dummy @ID INT NOT NULL AS BEGIN END ``` Why is it not possible to do something like this?
Parameter validation is not currently a feature of procedural logic in SQL Server, and NOT NULL is only one possible type of data validation. The CHAR datatype in a table has a length specification. Should that be implemented as well? And how do you handle exceptions? There is an extensive, highly developed and somewha...
330,320
<p>In an aspx page I get the Windows username with the function <code>Request.LogonUserIdentity.Name</code>. This function returns a string in the format "domain\user".</p> <p>Is there some function to only get the username, without resorting to the <code>IndexOf</code> and <code>Substring</code>, like this?</p> <pre...
[ { "answer_id": 330408, "author": "Russ Cam", "author_id": 1831, "author_profile": "https://Stackoverflow.com/users/1831", "pm_score": 7, "selected": true, "text": "<p>I don't believe so. I have got the username using these methods before-</p>\n\n<pre><code>var user = System.Web.HttpConte...
2008/12/01
[ "https://Stackoverflow.com/questions/330320", "https://Stackoverflow.com", "https://Stackoverflow.com/users/56/" ]
In an aspx page I get the Windows username with the function `Request.LogonUserIdentity.Name`. This function returns a string in the format "domain\user". Is there some function to only get the username, without resorting to the `IndexOf` and `Substring`, like this? ``` public static string StripDomain(string usernam...
I don't believe so. I have got the username using these methods before- ``` var user = System.Web.HttpContext.Current.User; var name = user.Identity.Name; var slashIndex = name.IndexOf("\\"); return slashIndex > -1 ? name.Substring(slashIndex + 1) : name.Substring(0, name.IndexOf("@")); ``` or ``` var...
330,331
<p>I just recently installed <a href="http://www.oddsock.org/tools/gen_songrequester/" rel="nofollow noreferrer">Winamp Song Requester</a> wich is a Winamp web song requester plugin with a built in minimal HTTP CGI Server.</p> <p>What the plugin does is that it runs a web server, serves a html page with some special v...
[ { "answer_id": 330398, "author": "Owen", "author_id": 4853, "author_profile": "https://Stackoverflow.com/users/4853", "pm_score": 6, "selected": true, "text": "<p><strong>edit</strong>: ok i think this works (at least it worked in my test environment, see revisions for previous attempt)<...
2008/12/01
[ "https://Stackoverflow.com/questions/330331", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32728/" ]
I just recently installed [Winamp Song Requester](http://www.oddsock.org/tools/gen_songrequester/) wich is a Winamp web song requester plugin with a built in minimal HTTP CGI Server. What the plugin does is that it runs a web server, serves a html page with some special variables wich it replaces with actual data on r...
**edit**: ok i think this works (at least it worked in my test environment, see revisions for previous attempt) ``` $.ajaxSetup({ 'beforeSend' : function(xhr) { xhr.overrideMimeType('text/html; charset=UTF-8'); }, }); $('#stuff').load('/yourresource.file'); // your ajax load ``` what i had was the ma...
330,334
<p>What would be the best way to do this.</p> <p>The input string is </p> <pre><code>&lt;133_3&gt;&lt;135_3&gt;&lt;116_2&gt;The other system worked for about 1 month&lt;/116_2&gt; got some good images &lt;137_3&gt;on it then it started doing the same thing as the first one&lt;/137_3&gt; so then I quit using either ca...
[ { "answer_id": 330356, "author": "Gonzalo Quero", "author_id": 40996, "author_profile": "https://Stackoverflow.com/users/40996", "pm_score": 1, "selected": false, "text": "<p>I think a grammar would be the best option here. I found a link with some information:\n<a href=\"http://www.onla...
2008/12/01
[ "https://Stackoverflow.com/questions/330334", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33612/" ]
What would be the best way to do this. The input string is ``` <133_3><135_3><116_2>The other system worked for about 1 month</116_2> got some good images <137_3>on it then it started doing the same thing as the first one</137_3> so then I quit using either camera now they are just sitting and collecting dust.</135_...
Use expat or another XML parser; it's more explicit than anything else, considering you're dealing with XML data anyway. However, note that XML element names can't start with a number as your example has them. Here's a parser that will do what you need, although you'll need to tweak it to combine duplicate elements i...
330,337
<p>I have a greasemonkey user script with this single line of code...</p> <pre><code>window.close(); </code></pre> <p>but firefox does not allow a user script to close a window (as reported by an error message in the error console)</p> <p>Is there a work around to this problem?</p>
[ { "answer_id": 330372, "author": "M.N", "author_id": 18615, "author_profile": "https://Stackoverflow.com/users/18615", "pm_score": 6, "selected": true, "text": "<p><strong>You need to change configuration settings of Firefox (about:config) to allow this.</strong></p>\n\n<h2>Steps:</h2>\n...
2008/12/01
[ "https://Stackoverflow.com/questions/330337", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39648/" ]
I have a greasemonkey user script with this single line of code... ``` window.close(); ``` but firefox does not allow a user script to close a window (as reported by an error message in the error console) Is there a work around to this problem?
**You need to change configuration settings of Firefox (about:config) to allow this.** Steps: ------ 1. Go to address bar and type **about:config** 2. Go to parameter **dom.allow\_scripts\_to\_close\_windows** 3. Set its value as **true** Now your script can close the TAB with 'window.close()' ***eg.*** ``` functi...
330,339
<p>Is there any way to re-generate views from newly updated model?</p>
[ { "answer_id": 331668, "author": "Stein G. Strindhaug", "author_id": 26115, "author_profile": "https://Stackoverflow.com/users/26115", "pm_score": 1, "selected": false, "text": "<p>The scaffold is not intended to <em>create</em> the interface, only to make a starting point for further de...
2008/12/01
[ "https://Stackoverflow.com/questions/330339", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27257/" ]
Is there any way to re-generate views from newly updated model?
Unless you've made a lot of changes to the scaffold, it's probably easier just to overwrite the current scaffold: ``` ./script/generate -f scaffold Model ```
330,383
<p>Given a string as below, I need to convert:</p> <p>1 Dec 2008 06:43:00 +0100</p> <p>to</p> <p>MM/DD/YYYY HH:MM:SSAM</p> <p>using jython what is the best way to do this?</p>
[ { "answer_id": 330466, "author": "Dustin", "author_id": 39975, "author_profile": "https://Stackoverflow.com/users/39975", "pm_score": 3, "selected": true, "text": "<p>I don't have jython handy, but I'd expect something like this to work:</p>\n\n<pre><code>import java\nsdf = java.text.Sim...
2008/12/01
[ "https://Stackoverflow.com/questions/330383", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21537/" ]
Given a string as below, I need to convert: 1 Dec 2008 06:43:00 +0100 to MM/DD/YYYY HH:MM:SSAM using jython what is the best way to do this?
I don't have jython handy, but I'd expect something like this to work: ``` import java sdf = java.text.SimpleDateFormat fmt_in = sdf('d MMM yyyy HH:mm:ss Z') fmt_out = sdf('MM/dd/yyyy HH:mm:ssaa') fmt_out.format(fmt_in.parse(time_str)) ```
330,387
<p>While checking out the generic collection in .net i found about KeyedByTypeCollection. Although I worked with it and got to know how to use it, I did not get in which scenario it will be useful.</p> <p>I read through <a href="https://stackoverflow.com/questions/178255/serviceprovider-cache-etc-done-with-generics-wi...
[ { "answer_id": 349304, "author": "Prensen", "author_id": 43633, "author_profile": "https://Stackoverflow.com/users/43633", "pm_score": 5, "selected": true, "text": "<p>AFAIK, this generic collection serves just as a simple wrapper for <code>KeyedCollection&lt;KEY,VALUE&gt;</code> when <c...
2008/12/01
[ "https://Stackoverflow.com/questions/330387", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41968/" ]
While checking out the generic collection in .net i found about KeyedByTypeCollection. Although I worked with it and got to know how to use it, I did not get in which scenario it will be useful. I read through [ServiceProvider, cache etc. done with generics without cast](https://stackoverflow.com/questions/178255/serv...
AFAIK, this generic collection serves just as a simple wrapper for `KeyedCollection<KEY,VALUE>` when `KEY` is the Type of the `VALUE` to store. For example, it is very convinient to use this collection if you want to implement a factory returning singletons: ``` public class Factory<T> { private readonly KeyedByT...
330,395
<p>I am setting up a development server in my flat. I have set up an Ubuntu DNS server on it and have added the zone weddinglist (just weddinglist - no <a href="http://en.wikipedia.org/wiki/Top-level_domain" rel="noreferrer">TLD</a>. It's just an internal domain.)</p> <p>This works fine on my Ubuntu laptop.</p> <p>On...
[ { "answer_id": 330409, "author": "Alnitak", "author_id": 6782, "author_profile": "https://Stackoverflow.com/users/6782", "pm_score": 6, "selected": false, "text": "<p>It's possible that the Windows internal resolver is adding '.local' to the domain name because there's no dots in it. <c...
2008/12/01
[ "https://Stackoverflow.com/questions/330395", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42088/" ]
I am setting up a development server in my flat. I have set up an Ubuntu DNS server on it and have added the zone weddinglist (just weddinglist - no [TLD](http://en.wikipedia.org/wiki/Top-level_domain). It's just an internal domain.) This works fine on my Ubuntu laptop. On all my Windows PCs (Vista and XP) I get the ...
It's possible that the Windows internal resolver is adding '.local' to the domain name because there's no dots in it. `nslookup` wouldn't do that. To verify this possiblity, install 'Wireshark' (previously aka Ethereal) on your client machine and observe any DNS request packets leaving it when you run the `ping` comma...
330,405
<p>If I have a table where <strong>the cells in a column should not have the same values</strong>, how do I check this and update? (I know I can set constraints in the settings, but I don't want to do that.)</p> <p>Say the column name is called <em>unique hash name</em> and contains </p> <pre> Peter Peter Peter Dave ...
[ { "answer_id": 330695, "author": "Timothy Khouri", "author_id": 11917, "author_profile": "https://Stackoverflow.com/users/11917", "pm_score": 4, "selected": true, "text": "<p>EDIT: I've changed the query to use your field names and added a \"select-only\" query for you to preview.</p>\n\...
2008/12/01
[ "https://Stackoverflow.com/questions/330405", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2429/" ]
If I have a table where **the cells in a column should not have the same values**, how do I check this and update? (I know I can set constraints in the settings, but I don't want to do that.) Say the column name is called *unique hash name* and contains ``` Peter Peter Peter Dave Dave ``` and so on. I want that t...
EDIT: I've changed the query to use your field names and added a "select-only" query for you to preview. This is actually pretty easy to do... just use ROW\_NUMBER() with a PARTITION clause: ``` UPDATE Persons SET UniqueName = temp.DeDupded FROM (SELECT ID, CASE WHEN ROW_NUMBER() OVER (PARTITI...
330,427
<p>I want to develop JavaScript on my Windows machine. Do you know a browser where I can turn off <em>Same Origin Policy</em> so I can develop locally? Firefox would be optimal.</p> <p>Or if you know a proxy I could use for a SOAP/WSDL site it would be great too.</p> <p>I am trying to work with the <a href="http://ww...
[ { "answer_id": 330442, "author": "The Archetypal Paul", "author_id": 21755, "author_profile": "https://Stackoverflow.com/users/21755", "pm_score": 0, "selected": false, "text": "<blockquote>\n <p>Firefox would be optimal.</p>\n</blockquote>\n\n<p>If you can live with Internet Explorer, ...
2008/12/01
[ "https://Stackoverflow.com/questions/330427", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19929/" ]
I want to develop JavaScript on my Windows machine. Do you know a browser where I can turn off *Same Origin Policy* so I can develop locally? Firefox would be optimal. Or if you know a proxy I could use for a SOAP/WSDL site it would be great too. I am trying to work with the [JavaSCript SOAP Client](http://www.codepl...
**UPDATE 6/2012: This used to work at the time of the writing, but obviously no more. Sorry.** In Firefox (might apply to other Gecko-based browsers as well) you can use the following JavaScript snippet to allow cross-domain calls: ``` if (navigator.userAgent.indexOf("Firefox") != -1) { try { netscape.sec...
330,444
<p>I've got a MenuItem whos ItemsSource is databound to a simple list of strings, its showing correctly, but I'm struggling to see how I can handle click events for them!</p> <p>Here's a simple app that demonstrates it:</p> <pre><code>&lt;Window x:Class="WPFDataBoundMenu.Window1" xmlns="http://schemas.microsoft.com/w...
[ { "answer_id": 330566, "author": "Kent Boogaart", "author_id": 5380, "author_profile": "https://Stackoverflow.com/users/5380", "pm_score": 3, "selected": false, "text": "<p>You could have each menu item execute the same command, thus handling the execution centrally. If you need to disti...
2008/12/01
[ "https://Stackoverflow.com/questions/330444", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26759/" ]
I've got a MenuItem whos ItemsSource is databound to a simple list of strings, its showing correctly, but I'm struggling to see how I can handle click events for them! Here's a simple app that demonstrates it: ``` <Window x:Class="WPFDataBoundMenu.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentat...
``` <MenuItem Header="My Items" ItemsSource="{Binding Path=MyMenuItems}" Click="DataBoundMenuItem_Click" /> ``` Code behind.. ``` private void DataBoundMenuItem_Click(object sender, RoutedEventArgs e) { MenuItem obMenuItem = e.OriginalSource as MenuItem; MessageBox.Show( String.Format("{0} just said Hi!", obMe...
330,447
<p>How can I compile a .cs file into a DLL?</p> <p>My project name is WA. In my <code>bin</code> folder after the compilation, I found:</p> <ul> <li><code>WA.exe</code></li> <li><code>WA.vshost.exe</code></li> <li><code>WA.pdb</code></li> </ul>
[ { "answer_id": 330449, "author": "mannu", "author_id": 15858, "author_profile": "https://Stackoverflow.com/users/15858", "pm_score": 2, "selected": false, "text": "<p>You use a compiler. Csc.exe comes with the .NET Framework.</p>\n\n<p>Check this link: <a href=\"http://msdn.microsoft.com...
2008/12/01
[ "https://Stackoverflow.com/questions/330447", "https://Stackoverflow.com", "https://Stackoverflow.com/users/201406/" ]
How can I compile a .cs file into a DLL? My project name is WA. In my `bin` folder after the compilation, I found: * `WA.exe` * `WA.vshost.exe` * `WA.pdb`
You have to compile it: ``` csc /t:library source.cs -> source.dll ```
330,458
<p>Is there a clean and OS independent way to determine the local machine's IP addresses from Perl?</p> <p>So far I have found the following solutions:</p> <ul> <li><p>parse the output of ifconfig and ipconfig (hard, different windows versions have different ipconfig outputs)</p></li> <li><p>establish a network conne...
[ { "answer_id": 330487, "author": "The Archetypal Paul", "author_id": 21755, "author_profile": "https://Stackoverflow.com/users/21755", "pm_score": 0, "selected": false, "text": "<p>use WMI?</p>\n\n<p><a href=\"http://www.computerperformance.co.uk/ezine/ezine141.htm\" rel=\"nofollow noref...
2008/12/01
[ "https://Stackoverflow.com/questions/330458", "https://Stackoverflow.com", "https://Stackoverflow.com/users/686/" ]
Is there a clean and OS independent way to determine the local machine's IP addresses from Perl? So far I have found the following solutions: * parse the output of ifconfig and ipconfig (hard, different windows versions have different ipconfig outputs) * establish a network connection to a well-known IP and examine t...
[Net::Address::IP::Local](http://search.cpan.org/perldoc?Net::Address::IP::Local) looks promising. ``` use Net::Address::IP::Local; # Get the local system's IP address that is "en route" to "the internet": my $address = Net::Address::IP::Local->public; ```
330,461
<p>How do I get the battery status on an iPhone?</p>
[ { "answer_id": 705071, "author": "Raviprakash", "author_id": 42078, "author_profile": "https://Stackoverflow.com/users/42078", "pm_score": 2, "selected": false, "text": "<p>Iphone SDK 3.0 beta supports this.</p>\n" }, { "answer_id": 1418694, "author": "Grzegorz Adam Hankiewic...
2008/12/01
[ "https://Stackoverflow.com/questions/330461", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42078/" ]
How do I get the battery status on an iPhone?
``` UIDevice *myDevice = [UIDevice currentDevice]; [myDevice setBatteryMonitoringEnabled:YES]; float batLeft = [myDevice batteryLevel]; int i=[myDevice batteryState]; int batinfo=(batLeft*100); NSLog(@"Battry Level is :%d and Battery Status is :%d",batinfo,i); switch (i) { case UIDeviceBatteryStateUnplugged: ...
330,471
<p>Explain why a nullable int can't be assigned the value of null e.g</p> <pre><code>int? accom = (accomStr == "noval" ? null : Convert.ToInt32(accomStr)); </code></pre> <p>What's wrong with that code?</p>
[ { "answer_id": 330484, "author": "Harry Steinhilber", "author_id": 6118, "author_profile": "https://Stackoverflow.com/users/6118", "pm_score": 9, "selected": true, "text": "<p>The problem isn't that null cannot be assigned to an int?. The problem is that both values returned by the terna...
2008/12/01
[ "https://Stackoverflow.com/questions/330471", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40623/" ]
Explain why a nullable int can't be assigned the value of null e.g ``` int? accom = (accomStr == "noval" ? null : Convert.ToInt32(accomStr)); ``` What's wrong with that code?
The problem isn't that null cannot be assigned to an int?. The problem is that both values returned by the ternary operator must be the same type, or one must be implicitly convertible to the other. In this case, null cannot be implicitly converted to int nor vice-versus, so an explict cast is necessary. Try this inste...
330,493
<p>In many places in our code we have collections of objects, from which we need to create a comma-separated list. The type of collection varies: it may be a DataTable from which we need a certain column, or a List&lt;Customer&gt;, etc.</p> <p>Now we loop through the collection and use string concatenation, for exampl...
[ { "answer_id": 330508, "author": "Galwegian", "author_id": 3201, "author_profile": "https://Stackoverflow.com/users/3201", "pm_score": 2, "selected": false, "text": "<p>As an aside: The first modification I would make is to use the <a href=\"http://msdn.microsoft.com/en-us/library/2839d5...
2008/12/01
[ "https://Stackoverflow.com/questions/330493", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9449/" ]
In many places in our code we have collections of objects, from which we need to create a comma-separated list. The type of collection varies: it may be a DataTable from which we need a certain column, or a List<Customer>, etc. Now we loop through the collection and use string concatenation, for example: ``` string t...
``` // using System.Collections; // using System.Collections.Generic; // using System.Linq public delegate string Indexer<T>(T obj); public static string concatenate<T>(IEnumerable<T> collection, Indexer<T> indexer, char separator) { StringBuilder sb = new StringBuilder(); foreach (T t in collection) sb.Appen...
330,497
<p>I just stumbled across this bug in some legacy code:</p> <pre><code>class MyAPIHandler { private: int handle; public: void MyApiHandler() // default constructor { handle = 42; }; }; </code></pre> <p>It compiles fine, with no warnings - but the behaviour wasn't what I intended, bec...
[ { "answer_id": 330506, "author": "Brian", "author_id": 19299, "author_profile": "https://Stackoverflow.com/users/19299", "pm_score": 2, "selected": false, "text": "<p>Code review? Unit test, as you mention is good too. Code coverage. Many of the usual tools for finding bugs could find...
2008/12/01
[ "https://Stackoverflow.com/questions/330497", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1737/" ]
I just stumbled across this bug in some legacy code: ``` class MyAPIHandler { private: int handle; public: void MyApiHandler() // default constructor { handle = 42; }; }; ``` It compiles fine, with no warnings - but the behaviour wasn't what I intended, because the constructor name ...
If you always use initialiser lists in your constructors: ``` MyApiHandler() // default constructor : handle(42) { } ``` the misnamed constructor bug would be even more unlikely, and it's better [style](http://www.parashift.com/c++-faq-lite/ctors.html#faq-10 "style") anyway. **Edit**: thanks to commenter for the l...
330,500
<p>This is a Windows Console application (actually a service) that a previous guy built 4 years ago and is installed and running. I now need to make some changes but can't even build the current version! Here is the build output:</p> <pre><code>--------------------Configuration: MyApp - Win32 Debug--------------------...
[ { "answer_id": 330521, "author": "Joris Timmermans", "author_id": 33987, "author_profile": "https://Stackoverflow.com/users/33987", "pm_score": 1, "selected": false, "text": "<p>You can use <a href=\"http://www.dependencywalker.com/\" rel=\"nofollow noreferrer\">\"Dependency Walker\"</a>...
2008/12/01
[ "https://Stackoverflow.com/questions/330500", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41013/" ]
This is a Windows Console application (actually a service) that a previous guy built 4 years ago and is installed and running. I now need to make some changes but can't even build the current version! Here is the build output: ``` --------------------Configuration: MyApp - Win32 Debug-------------------- Compiling res...
Sorry, this turns out to be an internal problem. A combination of a maverick coder 4 years ago and a rusty no-nothing (me!) now. The code does not use `_socket_noblock` but it **does** use `socket_noblock` and I just need to link to one of our own libraries.
330,526
<p>In my code i create a HyperLinkField object. Depending on a database field value, i want to set the NavigateUrl property. This is my problem, i don't know how.</p> <p>With:</p> <pre><code>objHF.DataNavigateUrlFields = new[] { "id", "Stype" }; </code></pre> <p>i get my database field. Now i want to check the Stype...
[ { "answer_id": 330517, "author": "Kent Fredric", "author_id": 15614, "author_profile": "https://Stackoverflow.com/users/15614", "pm_score": 2, "selected": false, "text": "<p>Not in New Zealand at least. </p>\n\n<p>Here, Fax-Numbers do not differ from normal numbers in terms of namespacin...
2008/12/01
[ "https://Stackoverflow.com/questions/330526", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40676/" ]
In my code i create a HyperLinkField object. Depending on a database field value, i want to set the NavigateUrl property. This is my problem, i don't know how. With: ``` objHF.DataNavigateUrlFields = new[] { "id", "Stype" }; ``` i get my database field. Now i want to check the Stype value. Depeding on this value i ...
If you can make a phone call, many faxes create a "[Fax Identification tone](http://telecom.tbi.net/fax-call.htm)". > > This signal may be sent by the Terminating FAX machine anywhere between 1.8 to 2.5 seconds AFTER answering the call. The CED signal consists of a 2100 Hz tone that is from 2.6 to 4 seconds in durati...
330,529
<p>What is the difference between the selectitem and selectitems tags in jsf?</p>
[ { "answer_id": 330552, "author": "paxdiablo", "author_id": 14860, "author_profile": "https://Stackoverflow.com/users/14860", "pm_score": 5, "selected": true, "text": "<p>The difference is exactly what you would expect. The <code>selectitem</code> tag adds a single item to the HTML list w...
2008/12/01
[ "https://Stackoverflow.com/questions/330529", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40933/" ]
What is the difference between the selectitem and selectitems tags in jsf?
The difference is exactly what you would expect. The `selectitem` tag adds a single item to the HTML list while `selectitems` adds multiple items. From [JSF Core Tag Reference](http://www.jsftoolbox.com/documentation/help/12-TagReference/core/f_selectItem.html): ### SelectItem: The `SelectItem` tag adds a child `UIS...