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
239,275
<p>Let's say I have the following table:</p> <pre><code>CustomerID ParentID Name ========== ======== ==== 1 null John 2 1 James 3 2 Jenna 4 3 Jennifer 5 3 Peter 6 5 Alice 7 5 Steve 8 1 Larry </...
[ { "answer_id": 239283, "author": "Jasper Bekkers", "author_id": 31486, "author_profile": "https://Stackoverflow.com/users/31486", "pm_score": 0, "selected": false, "text": "<p>You can't do recursion in SQL without stored procedures. The way to solve this is using Nested Sets, they basica...
2008/10/27
[ "https://Stackoverflow.com/questions/239275", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30729/" ]
Let's say I have the following table: ``` CustomerID ParentID Name ========== ======== ==== 1 null John 2 1 James 3 2 Jenna 4 3 Jennifer 5 3 Peter 6 5 Alice 7 5 Steve 8 1 Larry ``` I want to ...
On SQL Server 2005 you can use [CTEs (Common Table Expressions)](https://web.archive.org/web/20210927200924/http://www.4guysfromrolla.com/webtech/071906-1.shtml) : ``` with Hierachy(CustomerID, ParentID, Name, Level) as ( select CustomerID, ParentID, Name, 0 as Level from Customers c where c.CustomerID = 2 -- ...
239,278
<p>I have database with many tables. In the first table, I have a field called <code>status</code>.</p> <pre><code>table 1 idno name status 111 hjghf yes 225 hjgjj no 345 hgj yes </code></pre> <p>Other tables could have same <code>idno</code> with different fields.</p> <p>I want to check the s...
[ { "answer_id": 241191, "author": "Fionnuala", "author_id": 2548, "author_profile": "https://Stackoverflow.com/users/2548", "pm_score": -1, "selected": true, "text": "<p>Here is some largely untested code. Hopefully it will give you a start.</p>\n\n<pre><code>Sub UpdateNulls()\nDim strSQL...
2008/10/27
[ "https://Stackoverflow.com/questions/239278", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31132/" ]
I have database with many tables. In the first table, I have a field called `status`. ``` table 1 idno name status 111 hjghf yes 225 hjgjj no 345 hgj yes ``` Other tables could have same `idno` with different fields. I want to check the status for each id no and if it is yes then for that id n...
Here is some largely untested code. Hopefully it will give you a start. ``` Sub UpdateNulls() Dim strSQL As String Dim rs As DAO.Recordset For Each tdf In CurrentDb.TableDefs If Left(tdf.Name, 4) <> "Msys" And tdf.Name <> "Table1" Then strSQL = "Select * From [" & tdf.Name & "] a Inner Join " _ & "...
239,301
<p>Is there in Ruby some functionality/syntax to compare two floats with delta? Something similar to <em>assert_in_delta(expected_float, actual_float, delta)</em> from <em>test/unit</em> but returning Boolean?</p>
[ { "answer_id": 239314, "author": "ysth", "author_id": 17389, "author_profile": "https://Stackoverflow.com/users/17389", "pm_score": 6, "selected": true, "text": "<pre><code>(expected_float - actual_float).abs &lt;= delta\n</code></pre>\n" }, { "answer_id": 240708, "author": "...
2008/10/27
[ "https://Stackoverflow.com/questions/239301", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31726/" ]
Is there in Ruby some functionality/syntax to compare two floats with delta? Something similar to *assert\_in\_delta(expected\_float, actual\_float, delta)* from *test/unit* but returning Boolean?
``` (expected_float - actual_float).abs <= delta ```
239,302
<p>I usually never see test for new in C++ and I was wondering why.</p> <p><code>Foo *f = new Foo;</code></p> <p><code>// f is assumed as allocated, why usually, nobody test the return of new?</code></p>
[ { "answer_id": 239307, "author": "David Holm", "author_id": 22247, "author_profile": "https://Stackoverflow.com/users/22247", "pm_score": 7, "selected": true, "text": "<p>As per the current standard, <em>new</em> never returns <em>NULL</em>, it throws a std::bad_alloc instead. If you don...
2008/10/27
[ "https://Stackoverflow.com/questions/239302", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25888/" ]
I usually never see test for new in C++ and I was wondering why. `Foo *f = new Foo;` `// f is assumed as allocated, why usually, nobody test the return of new?`
As per the current standard, *new* never returns *NULL*, it throws a std::bad\_alloc instead. If you don't want new to throw(as per the old standard) but rather return NULL you should call it by postfixing it with "*(std::nothrow)*". i.e. ``` Foo* foo = new (std::nothrow) Foo; ``` Of course, if you have a very old o...
239,340
<p>Does anybody know a way to recursively remove all files in a working copy that are not under version control? (I need this to get more reliable results in my automatic build VMware.)</p>
[ { "answer_id": 239342, "author": "leppie", "author_id": 15541, "author_profile": "https://Stackoverflow.com/users/15541", "pm_score": 2, "selected": false, "text": "<p>Can you not just do an export to a new location and build from there?</p>\n" }, { "answer_id": 239351, "auth...
2008/10/27
[ "https://Stackoverflow.com/questions/239340", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6358/" ]
Does anybody know a way to recursively remove all files in a working copy that are not under version control? (I need this to get more reliable results in my automatic build VMware.)
Edit: Subversion 1.9.0 introduced an option to do this: ``` svn cleanup --remove-unversioned ``` Before that, I use this python script to do that: ```py import os import re def removeall(path): if not os.path.isdir(path): os.remove(path) return files=os.listdir(path) for x in files: ...
239,344
<p>I want your suggestion on the following pseudo-code. Please suggest how could I improve it, whether or not I could use some design patterns.</p> <pre><code> // i'm receiving a string containing : id operation arguments data = read(socket); tokens = tokenize(data," "); // tokenize the string based on spaces if(t...
[ { "answer_id": 239348, "author": "Epaga", "author_id": 6583, "author_profile": "https://Stackoverflow.com/users/6583", "pm_score": 5, "selected": true, "text": "<p>Have a class for each ID which implements a common interface. Basically the <a href=\"http://en.wikipedia.org/wiki/Strategy_...
2008/10/27
[ "https://Stackoverflow.com/questions/239344", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31610/" ]
I want your suggestion on the following pseudo-code. Please suggest how could I improve it, whether or not I could use some design patterns. ``` // i'm receiving a string containing : id operation arguments data = read(socket); tokens = tokenize(data," "); // tokenize the string based on spaces if(tokens[0] == "A...
Have a class for each ID which implements a common interface. Basically the [Strategy pattern](http://en.wikipedia.org/wiki/Strategy_pattern) IIRC. So you'd call (pseudo)code like: `StrategyFactory.GetStrategy(tokens[0]).parse(tokens[1..n])`
239,350
<p>For some odd reason the Elapsed event is firing twice, where it should definitely be firing once. And immediately after, the timer ceases to work... The code structure is somewhat like this: A certain object is defined to fire a certain event when a value it contains, which is constantly updated in 500-1500ms interv...
[ { "answer_id": 239354, "author": "Calanus", "author_id": 445, "author_profile": "https://Stackoverflow.com/users/445", "pm_score": 0, "selected": false, "text": "<p>Well my most basic instinct would be that somehow you actually have two event wireups to the Elapsed event - resulting in t...
2008/10/27
[ "https://Stackoverflow.com/questions/239350", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
For some odd reason the Elapsed event is firing twice, where it should definitely be firing once. And immediately after, the timer ceases to work... The code structure is somewhat like this: A certain object is defined to fire a certain event when a value it contains, which is constantly updated in 500-1500ms intervals...
From [MSDN](http://msdn.microsoft.com/en-us/library/system.timers.timer(VS.80).aspx): > > The Elapsed event is raised on a > ThreadPool thread. If processing of > the Elapsed event lasts longer than > Interval, the event might be raised > again on another ThreadPool thread. > Thus, the event handler should be > ...
239,408
<p>I have a class with some abstract methods, but I want to be able to edit a subclass of that class in the designer. However, the designer can't edit the subclass unless it can create an instance of the parent class. So my plan is to replace the abstract methods with stubs and mark them as virtual - but then if I ma...
[ { "answer_id": 239423, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 4, "selected": true, "text": "<p>Well you could do some really messy code involving <code>#if</code> - i.e. in <code>DEBUG</code> it is virtual (for...
2008/10/27
[ "https://Stackoverflow.com/questions/239408", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15371/" ]
I have a class with some abstract methods, but I want to be able to edit a subclass of that class in the designer. However, the designer can't edit the subclass unless it can create an instance of the parent class. So my plan is to replace the abstract methods with stubs and mark them as virtual - but then if I make an...
Well you could do some really messy code involving `#if` - i.e. in `DEBUG` it is virtual (for the designer), but in `RELEASE` it is abstract. A real pain to maintain, though. But other than that: basically, no. If you want designer support it can't be abstract, so you are left with "virtual" (presumably with the base ...
239,414
<p>How do I insert a current_timestamp into an SQL Server 2005 database datable with a timestamp column?</p> <p>It should be simple but I cannot get it to work. Examples would be much appreciated.</p>
[ { "answer_id": 239426, "author": "robsoft", "author_id": 3897, "author_profile": "https://Stackoverflow.com/users/3897", "pm_score": 3, "selected": false, "text": "<p>if you can execute a query from PHP then it should just be a matter of using 'getdate()' ;</p>\n\n<pre><code>update MyTab...
2008/10/27
[ "https://Stackoverflow.com/questions/239414", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How do I insert a current\_timestamp into an SQL Server 2005 database datable with a timestamp column? It should be simple but I cannot get it to work. Examples would be much appreciated.
if you can execute a query from PHP then it should just be a matter of using 'getdate()' ; ``` update MyTable set MyColumn=getdate(); ``` or ``` insert into MyTable (MyColumn) values (getdate()); ```
239,425
<p>I have a WinForms C# application using a MS SQL Server Express database. The application is deployed on the PCs of our customers and they don't have computer related knowledge. </p> <p>The application updates the database regularly and I see a lot of fragmentation on the index files. How do I keep the database heal...
[ { "answer_id": 239479, "author": "baldy", "author_id": 2012, "author_profile": "https://Stackoverflow.com/users/2012", "pm_score": 1, "selected": false, "text": "<p>Use the DBCC REINDEX option if you can afford to take the table offline for a short while, alternatively DBCC INDEXDEFRAG. ...
2008/10/27
[ "https://Stackoverflow.com/questions/239425", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1997188/" ]
I have a WinForms C# application using a MS SQL Server Express database. The application is deployed on the PCs of our customers and they don't have computer related knowledge. The application updates the database regularly and I see a lot of fragmentation on the index files. How do I keep the database healthy/respon...
I now use 2 sql scripts. ``` SELECT st.object_id AS objectid, st.index_id AS indexid, partition_number AS partitionnum, avg_fragmentation_in_percent AS frag, o.name, i.name FROM sys.dm_db_index_physical_stats (DB_ID(), NULL, NULL , NULL, 'LIMITED') st join sys.objects o on o.object_i...
239,435
<p>I'm kinda stuck with this one so I hoped someone could help me.</p> <p>I am doing a Winforms application and I need to show a Modal Dialog (form.ShowDialog) that returns a value (prompts the User some values and wraps them in a Object). </p> <p>I just can't see how to do this rather than give a reference into the ...
[ { "answer_id": 239449, "author": "Matt Hamilton", "author_id": 615, "author_profile": "https://Stackoverflow.com/users/615", "pm_score": 5, "selected": true, "text": "<p>Add a static method to your form, like this:</p>\n\n<pre><code>public class MyDialog : Form\n{\n // todo: think of ...
2008/10/27
[ "https://Stackoverflow.com/questions/239435", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21699/" ]
I'm kinda stuck with this one so I hoped someone could help me. I am doing a Winforms application and I need to show a Modal Dialog (form.ShowDialog) that returns a value (prompts the User some values and wraps them in a Object). I just can't see how to do this rather than give a reference into the object or dependi...
Add a static method to your form, like this: ``` public class MyDialog : Form { // todo: think of a better method name :) public static MyObject ShowAndReturnObject() { var dlg = new MyDialog(); if (new dlg.ShowDialog() == DialogResult.OK) { var obj = // construct an i...
239,443
<p>I have these two <code>CREATE TABLE</code> statements: </p> <pre><code>CREATE TABLE GUEST ( id int(15) not null auto_increment PRIMARY KEY, GuestName char(25) not null ); CREATE TABLE PAYMENT ( id int(15) not null auto_increment Foreign Key(id) references GUEST(id), BillNr int(15) not null ); </code></pr...
[ { "answer_id": 239582, "author": "mattoc", "author_id": 10901, "author_profile": "https://Stackoverflow.com/users/10901", "pm_score": 0, "selected": false, "text": "<p>Make sure you're using the InnoDB engine for either the database, or for both tables. From the MySQL Reference:</p>\n\n<...
2008/10/27
[ "https://Stackoverflow.com/questions/239443", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17451/" ]
I have these two `CREATE TABLE` statements: ``` CREATE TABLE GUEST ( id int(15) not null auto_increment PRIMARY KEY, GuestName char(25) not null ); CREATE TABLE PAYMENT ( id int(15) not null auto_increment Foreign Key(id) references GUEST(id), BillNr int(15) not null ); ``` What is the problem in the sec...
The answer to your question is almost the same as the answer to [this one](https://stackoverflow.com/questions/236668/foreign-keys-in-mysql#236677) . You need to specify in the table containing the foreign key the name of the table containing the primary key, and the name of the primary key field (using "references")...
239,450
<p>I want to compare two ms-access .mdb files to check that the data they contain is same in both.</p> <p>How can I do this?</p>
[ { "answer_id": 239484, "author": "rwired", "author_id": 17492, "author_profile": "https://Stackoverflow.com/users/17492", "pm_score": -1, "selected": false, "text": "<p>If you want to know if the files are identical then</p>\n\n<pre><code>fc file1.mdb file2.mdb \n</code></pre>\n\n<p>on a...
2008/10/27
[ "https://Stackoverflow.com/questions/239450", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6613/" ]
I want to compare two ms-access .mdb files to check that the data they contain is same in both. How can I do this?
I've done this kind of thing in code many, many times, mostly in cases where a local MDB needed to have updates applied to it drawn from data entered on a website. In one case the website was driven by an MDB, in others, it was a MySQL database. For the MDB, we just downloaded it, for MySQL, we ran scripts on the websi...
239,453
<p>I have a bunch of questions to post regarding the issue of separating the view from logic when creating a GUI.<br> The following is a minimal example of what I would do for a simple dialog that has a label and a button using the "Humble Dialog" approach. Pressing the button should show some text on the label. I have...
[ { "answer_id": 239541, "author": "Mendelt", "author_id": 3320, "author_profile": "https://Stackoverflow.com/users/3320", "pm_score": 1, "selected": false, "text": "<p>I usually use the same pattern for my UI in C# Winforms stuff.</p>\n\n<p>You're actually not really doing multiple inheri...
2008/10/27
[ "https://Stackoverflow.com/questions/239453", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6403/" ]
I have a bunch of questions to post regarding the issue of separating the view from logic when creating a GUI. The following is a minimal example of what I would do for a simple dialog that has a label and a button using the "Humble Dialog" approach. Pressing the button should show some text on the label. I have use...
When you do multiple inheritance with QObjects, the first class in the inheritance list needs to be the QObject-derived class. This is only strictly required if you plan to add signals and slots to your class, but is good practice anyway. So your class declaration: class MyView : public IView , public QDialog { needs...
239,463
<p>I have an application that behaves oddly, and just to verify, I'd like to see which security zone it is currently running under.</p> <p>I've found the System.Security.SecurityZone enum, but can't seem to find anything that will return which of these I'm running under.</p> <p>Does anyone have any tips?</p> <p>Basi...
[ { "answer_id": 239471, "author": "blowdart", "author_id": 2525, "author_profile": "https://Stackoverflow.com/users/2525", "pm_score": 4, "selected": true, "text": "<p>You need to look at the CAS evidence for the current assembly;</p>\n\n<p>this.GetType().Assembly.Evidence</p>\n\n<p><a hr...
2008/10/27
[ "https://Stackoverflow.com/questions/239463", "https://Stackoverflow.com", "https://Stackoverflow.com/users/267/" ]
I have an application that behaves oddly, and just to verify, I'd like to see which security zone it is currently running under. I've found the System.Security.SecurityZone enum, but can't seem to find anything that will return which of these I'm running under. Does anyone have any tips? Basically I want to find out...
You need to look at the CAS evidence for the current assembly; this.GetType().Assembly.Evidence [Assembly.Evidence](http://msdn.microsoft.com/en-us/library/system.reflection.assembly.evidence.aspx) is a property [Evidence](http://msdn.microsoft.com/en-us/library/system.security.policy.evidence.aspx) object. From this...
239,465
<p>I have a setup project for a .NET Service Application which uses a .NET component which exposes a COM interface (COM callable wrapper / CCW). To get the component working on a target machine, it has to be registered with</p> <blockquote> <p>regasm.exe /tlb /codebase component.dll</p> </blockquote> <p>The /tlb switch...
[ { "answer_id": 239641, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "<p>Your service should have an Installer class.\nRegister to the OnAfterInstall event and call RegAsm: the path should be comp...
2008/10/27
[ "https://Stackoverflow.com/questions/239465", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25727/" ]
I have a setup project for a .NET Service Application which uses a .NET component which exposes a COM interface (COM callable wrapper / CCW). To get the component working on a target machine, it has to be registered with > > regasm.exe /tlb /codebase component.dll > > > The /tlb switch to generate the typelib is ...
You can lose the manual call to regasm.exe by using System.Runtime.InteropServices.RegistrationServices instead: ``` [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand)] public override void Install(IDictionary stateSaver) { base.Install(stateSaver); RegistrationServices...
239,486
<p>I want to convert an XML document containing many elements within a node (around 150) into another XML document with a slightly different schema but mostly with the same element names. Now do I have to manually map each element/node between the 2 documents. For that I will have to hardcode 150 lines of mapping and e...
[ { "answer_id": 239515, "author": "OJ.", "author_id": 611, "author_profile": "https://Stackoverflow.com/users/611", "pm_score": 5, "selected": true, "text": "<p>Use an <a href=\"http://www.w3schools.com/xsl/xsl_transformation.asp\" rel=\"noreferrer\">XSLT transform</a> instead. You can us...
2008/10/27
[ "https://Stackoverflow.com/questions/239486", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1688440/" ]
I want to convert an XML document containing many elements within a node (around 150) into another XML document with a slightly different schema but mostly with the same element names. Now do I have to manually map each element/node between the 2 documents. For that I will have to hardcode 150 lines of mapping and elem...
Use an [XSLT transform](http://www.w3schools.com/xsl/xsl_transformation.asp) instead. You can use the built-in .NET [XslCompiledTransform](http://msdn.microsoft.com/en-us/library/system.xml.xsl.xslcompiledtransform.aspx) to do the transformation. Saves you from having to type out stacks of code. If you don't already kn...
239,526
<p>How do I truncate output in BASH? </p> <p>For example, if I "du file.name" how do I just get the numeric value and nothing more?</p> <p>later addition:<br> all solutions work perfectly. I chose to accept the most enlightning "cut" answer because I prefer the simplest approach in bash files others are supposed to b...
[ { "answer_id": 239530, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 3, "selected": false, "text": "<pre><code>du | cut -f 1\n</code></pre>\n" }, { "answer_id": 239532, "author": "Ken", "author_id": 20074, ...
2008/10/27
[ "https://Stackoverflow.com/questions/239526", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11813/" ]
How do I truncate output in BASH? For example, if I "du file.name" how do I just get the numeric value and nothing more? later addition: all solutions work perfectly. I chose to accept the most enlightning "cut" answer because I prefer the simplest approach in bash files others are supposed to be able to read.
If you know what the delimiters are then cut is your friend ``` du | cut -f1 ``` Cut defaults to tab delimiters so in this case you are selecting the first field. You can change delimiters: cut -d ' ' would use a space as a delimiter. (from [Tomalak](https://stackoverflow.com/users/18771/tomalak)) You can also se...
239,537
<p>My Program overrides <code>public void paint(Graphics g, int x, int y);</code> in order to draw some stings using <code>g.drawString(someString, x+10, y+30);</code></p> <p>Now someString can be quite long and thus, it may not fit on one line.<br></p> <p>What is the best way to write the text on multiple line.<br> ...
[ { "answer_id": 239539, "author": "Epaga", "author_id": 6583, "author_profile": "https://Stackoverflow.com/users/6583", "pm_score": 2, "selected": false, "text": "<p><a href=\"http://java.sun.com/j2se/1.4.2/docs/api/java/awt/font/TextLayout.html\" rel=\"nofollow noreferrer\">java.awt.font...
2008/10/27
[ "https://Stackoverflow.com/questions/239537", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12860/" ]
My Program overrides `public void paint(Graphics g, int x, int y);` in order to draw some stings using `g.drawString(someString, x+10, y+30);` Now someString can be quite long and thus, it may not fit on one line. What is the best way to write the text on multiple line. For instance, in a rectangle (x1, y1, x2, ...
Thanks to Epaga's hint and a couple of examples on the Net (not so obvious to find! I used mainly [Break a Line for text layout](http://www.roseindia.net/java/example/java/swing/graphics2D/line-break-text-layout.shtml "Break a Line for text layout")), I could make a component to display wrapped text. It is incomplete, ...
239,545
<p>I have a table that has a <code>processed_timestamp</code> column -- if a record has been processed then that field contains the datetime it was processed, otherwise it is null.</p> <p>I want to write a query that returns two rows:</p> <pre><code>NULL xx -- count of records with null timestamps NOT NULL ...
[ { "answer_id": 239548, "author": "Stefan Gehrig", "author_id": 11354, "author_profile": "https://Stackoverflow.com/users/11354", "pm_score": 6, "selected": false, "text": "<p>In MySQL you could do something like</p>\n\n<pre><code>SELECT \n IF(ISNULL(processed_timestamp), 'NULL', 'NOT ...
2008/10/27
[ "https://Stackoverflow.com/questions/239545", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6408/" ]
I have a table that has a `processed_timestamp` column -- if a record has been processed then that field contains the datetime it was processed, otherwise it is null. I want to write a query that returns two rows: ``` NULL xx -- count of records with null timestamps NOT NULL yy -- count of records with non-...
Oracle: group by nvl2(field, 'NOT NULL', 'NULL')
239,546
<pre><code>$sql = "INSERT INTO images (path, useremail, approved, flagged,caption,date) VALUES ('$target','$email',0,0, '$caption','$b')"; $sql1 = "INSERT INTO users (name, email, phone) VALUES ('$peoplename','$email','$phone')" $conn-&gt;execute($sql, $sql1); </code></pre> <p>Above is the code Ι am using to try and w...
[ { "answer_id": 239554, "author": "Sani Singh Huttunen", "author_id": 26742, "author_profile": "https://Stackoverflow.com/users/26742", "pm_score": 0, "selected": false, "text": "<p>You have a missing semicolon on the second line.</p>\n" }, { "answer_id": 239563, "author": "To...
2008/10/27
[ "https://Stackoverflow.com/questions/239546", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
``` $sql = "INSERT INTO images (path, useremail, approved, flagged,caption,date) VALUES ('$target','$email',0,0, '$caption','$b')"; $sql1 = "INSERT INTO users (name, email, phone) VALUES ('$peoplename','$email','$phone')" $conn->execute($sql, $sql1); ``` Above is the code Ι am using to try and write to 2 tables. Befo...
I thought that the second parameter was for passing parameters to be bound to the query. If the server lets you execute two sql statements in one go maybe this would work. (added a terminating semi-colon at the end of each query and concatenated both queries together as one string.) ``` $sql = "INSERT INTO images (pa...
239,556
<p>We are replacing the exception handling system in our app in order to conform to Vista certification, but the problem is how to force certain exceptions to be thrown, so that we can check the response.</p> <p>Unfortunately the whole app was written without taking into consideration proper layering, abstraction or i...
[ { "answer_id": 239559, "author": "Ben Collins", "author_id": 3279, "author_profile": "https://Stackoverflow.com/users/3279", "pm_score": 1, "selected": false, "text": "<p>Introduce this code:</p>\n\n<pre><code>throw new Exception(\"test\");\n</code></pre>\n\n<p>If you need the exception ...
2008/10/27
[ "https://Stackoverflow.com/questions/239556", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7140/" ]
We are replacing the exception handling system in our app in order to conform to Vista certification, but the problem is how to force certain exceptions to be thrown, so that we can check the response. Unfortunately the whole app was written without taking into consideration proper layering, abstraction or isolation p...
Introduce this code: ``` throw new Exception("test"); ``` If you need the exception to always be there (i.e., not just test code), then hide it behind a command-line parameter. ``` C:\Users\Dude> myapp.exe /x ```
239,601
<p>How would you model booked hotel room to guests relationship (in PostgreSQL, if it matters)? A room can have several guests, but at least one.</p> <p>Sure, one can relate guests to bookings with a foreign key <code>booking_id</code>. But how do you enforce on the DBMS level that a room must have at least one guest?...
[ { "answer_id": 239616, "author": "Ovid", "author_id": 8003, "author_profile": "https://Stackoverflow.com/users/8003", "pm_score": 0, "selected": false, "text": "<p>What about a room which has not been rented out? What you're looking for are reservations and a reservation presumably need...
2008/10/27
[ "https://Stackoverflow.com/questions/239601", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6430/" ]
How would you model booked hotel room to guests relationship (in PostgreSQL, if it matters)? A room can have several guests, but at least one. Sure, one can relate guests to bookings with a foreign key `booking_id`. But how do you enforce on the DBMS level that a room must have at least one guest? May be it's just im...
Actually, if you read the question, it states booked hotel rooms. This is quite easy to do as follows: ``` Rooms: room_id primary key not null blah blah Guests: guest_id primary key not null yada yada BookedRooms: room_id primary key foreign key (Rooms:room_id) primary_guest_id foreig...
239,622
<p>We have an x-files problem with our .NET application. Or, rather, hybrid Win32 and .NET application.</p> <p>When it attempts to communicate with Oracle, it just dies. Vanishes. Goes to the big black void in the sky. No event log message, no exception, no nothing.</p> <p>If we simply ask the application to talk to...
[ { "answer_id": 239659, "author": "Dave Markle", "author_id": 24995, "author_profile": "https://Stackoverflow.com/users/24995", "pm_score": 3, "selected": true, "text": "<p>Here's what I would do. First, TRIPLE-check that you're seeing the behavior you think you're seeing. I can see thi...
2008/10/27
[ "https://Stackoverflow.com/questions/239622", "https://Stackoverflow.com", "https://Stackoverflow.com/users/267/" ]
We have an x-files problem with our .NET application. Or, rather, hybrid Win32 and .NET application. When it attempts to communicate with Oracle, it just dies. Vanishes. Goes to the big black void in the sky. No event log message, no exception, no nothing. If we simply ask the application to talk to a MS SQL Server i...
Here's what I would do. First, TRIPLE-check that you're seeing the behavior you think you're seeing. I can see this happening the other way around by not using System.IO.Path to concatenate paths, but not like you're seeing it. Triple-check that the file permissions make sense. Next, download [Filemon](http://technet....
239,628
<p>HI,</p> <p>I am trying to write a query in vba and to save its result in a report. I am a beginner. this is what i have tried can somebody correct me</p> <pre><code>Dim cn As New ADODB.Connection, rs As New ADODB.Recordset Dim sql As String Set cn = CurrentProject.Connection sql = "Select * from table1 where emp...
[ { "answer_id": 239699, "author": "Rune Grimstad", "author_id": 30366, "author_profile": "https://Stackoverflow.com/users/30366", "pm_score": 0, "selected": false, "text": "<p>Normally you would design the report based on a data source. Then after your report is done and working properly ...
2008/10/27
[ "https://Stackoverflow.com/questions/239628", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
HI, I am trying to write a query in vba and to save its result in a report. I am a beginner. this is what i have tried can somebody correct me ``` Dim cn As New ADODB.Connection, rs As New ADODB.Recordset Dim sql As String Set cn = CurrentProject.Connection sql = "Select * from table1 where empno is 0" rs.Open sql...
**IF you are wanting to create a report using MS Access's report generator**, you will have to use a Query Object (there might be a way to trick MS Access into running it off of your record set, but it's probably not worth your effort). You can create the Query Object on the "Database" window. Click the Query button ...
239,645
<p>I have an abstract Class <strong>Monitor.java</strong> which is subclassed by a Class <strong>EmailMonitor.java</strong>. </p> <p>The method:</p> <pre><code>public abstract List&lt;? extends MonitorAccount&gt; performMonitor(List&lt;? extends MonitorAccount&gt; accounts) </code></pre> <p>is defined in <strong>Mon...
[ { "answer_id": 239663, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 6, "selected": true, "text": "<p>No, it's not overriding it properly. Overriding means you should be able to cope with any valid input to the base clas...
2008/10/27
[ "https://Stackoverflow.com/questions/239645", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31749/" ]
I have an abstract Class **Monitor.java** which is subclassed by a Class **EmailMonitor.java**. The method: ``` public abstract List<? extends MonitorAccount> performMonitor(List<? extends MonitorAccount> accounts) ``` is defined in **Monitor.java** and must be overridden in **EmailMonitor.java**. I currently hav...
No, it's not overriding it properly. Overriding means you should be able to cope with any valid input to the base class. Consider what would happen if a client did this: ``` Monitor x = new EmailMonitor(); List<NonEmailAccount> nonEmailAccounts = ...; x.performMonitor(nonEmailAccounts); ``` There's nothing in there ...
239,669
<p>I'm occasionaly getting the following popup from an AJAX.NET application</p> <pre>Sys.WebForms.PageRequestManagerServerErrorException: An Unknown error occurred while processing the request on the server. The status code returned from the server was: 12031</pre> <p>From the <a href="http://support.microsoft.com/kb...
[ { "answer_id": 239674, "author": "Zachary Yates", "author_id": 8360, "author_profile": "https://Stackoverflow.com/users/8360", "pm_score": 4, "selected": false, "text": "<p>If you're getting that from an updatePanel, set EnablePartialRendering to false in the ScriptManager for the page, ...
2008/10/27
[ "https://Stackoverflow.com/questions/239669", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12772/" ]
I'm occasionaly getting the following popup from an AJAX.NET application ``` Sys.WebForms.PageRequestManagerServerErrorException: An Unknown error occurred while processing the request on the server. The status code returned from the server was: 12031 ``` From the [Microsoft kb](http://support.microsoft.com/kb/193625...
It's a viewstate problem, but not related with time but with size. Try playing with maxRequestLength in your web.config.
239,682
<p>When reading the registry for file names I get 3 entries loading into my combo box for every 1 registry entry. If I have 1 file listed in the registry I would see :</p> <p>Combo box values:</p> <p>c:\file1.txt</p> <p>&lt;-----Blank here</p> <p>c:\file1.txt</p> <p>I have found the problem lies in this code, it h...
[ { "answer_id": 239684, "author": "Joachim Kerschbaumer", "author_id": 20227, "author_profile": "https://Stackoverflow.com/users/20227", "pm_score": 0, "selected": false, "text": "<p>just add a \"break;\" after the first comboBox1.Items.Add().\nit will leave the loop after the insert (if ...
2008/10/27
[ "https://Stackoverflow.com/questions/239682", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
When reading the registry for file names I get 3 entries loading into my combo box for every 1 registry entry. If I have 1 file listed in the registry I would see : Combo box values: c:\file1.txt <-----Blank here c:\file1.txt I have found the problem lies in this code, it hits 'if (previousFiles != null)' 3 times....
Well, it should hit the if() statement 6 times, the comboBox1.Items.Add() statement 3 times. The logical explanation is that the real problem is located in the code that writes the registry keys. Run Regedit.exe to find out what is really stored in these registry key values.
239,725
<p>When I try to add a HTTP header key/value pair on a <code>WebRequest</code> object, I get the following exception:</p> <blockquote> <p>This header must be modified using the appropriate property</p> </blockquote> <p>I've tried adding new values to the <code>Headers</code> collection by using the Add() method but...
[ { "answer_id": 239736, "author": "FOR", "author_id": 27826, "author_profile": "https://Stackoverflow.com/users/27826", "pm_score": 3, "selected": false, "text": "<p><a href=\"http://msdn.microsoft.com/en-us/library/system.net.webrequest(VS.71).aspx\" rel=\"nofollow noreferrer\">WebReques...
2008/10/27
[ "https://Stackoverflow.com/questions/239725", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17211/" ]
When I try to add a HTTP header key/value pair on a `WebRequest` object, I get the following exception: > > This header must be modified using the appropriate property > > > I've tried adding new values to the `Headers` collection by using the Add() method but I still get the same exception. ``` webRequest.Heade...
If you need the short and technical answer go right to the last section of the answer. If you want to know better, read it all, and i hope you'll enjoy... --- I countered this problem too today, and what i discovered today is that: 1. the above answers are true, as: 1.1 it's telling you that the header you are try...
239,732
<p>I have heard from people who have switched either way and who swear by the one or the other.</p> <p>Being a huge Eclipse fan but having not had the time to try out IntelliJ, I am interested in hearing from IntelliJ users who are "ex-Eclipsians" some specific things that you can do with IntelliJ that you can not do ...
[ { "answer_id": 239754, "author": "krosenvold", "author_id": 23691, "author_profile": "https://Stackoverflow.com/users/23691", "pm_score": 3, "selected": false, "text": "<p>IntelliJ has intellisense and refactoring support from code into jspx documents.</p>\n" }, { "answer_id": 23...
2008/10/27
[ "https://Stackoverflow.com/questions/239732", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6583/" ]
I have heard from people who have switched either way and who swear by the one or the other. Being a huge Eclipse fan but having not had the time to try out IntelliJ, I am interested in hearing from IntelliJ users who are "ex-Eclipsians" some specific things that you can do with IntelliJ that you can not do with Eclip...
CTRL-click works anywhere ------------------------- CTRL-click that brings you to where clicked object is defined works everywhere - not only in Java classes and variables in Java code, but in Spring configuration (you can click on class name, or property, or bean name), in Hibernate (you can click on property name or...
239,744
<p>I'm developing a SWT/JFace application using the libraries from Eclipse 3.4.1. I encounter the following problem on Windows (Vista 32bit) and Ubuntu 8.10 32bit:</p> <p>I create a menu bar in the createMenuManager method of the JFace ApplicationWindow. I add MenuManagers for file, edit and help.</p> <p>I then add a...
[ { "answer_id": 247334, "author": "the.duckman", "author_id": 21368, "author_profile": "https://Stackoverflow.com/users/21368", "pm_score": 0, "selected": false, "text": "<p>AFAIK <code>setAccelerator(.)</code> does nothing else than adding the appropriate text to your <code>MenuItem</cod...
2008/10/27
[ "https://Stackoverflow.com/questions/239744", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7143/" ]
I'm developing a SWT/JFace application using the libraries from Eclipse 3.4.1. I encounter the following problem on Windows (Vista 32bit) and Ubuntu 8.10 32bit: I create a menu bar in the createMenuManager method of the JFace ApplicationWindow. I add MenuManagers for file, edit and help. I then add an ExitAction to t...
Update: There is a duplicate bug of mine which also contains a workaround. The bug url is: <https://bugs.eclipse.org/bugs/show_bug.cgi?id=243758> Basically the workaround is to call `create()` on the `ApplicationWindow` and then `getMenuBarManager().updateAll(true);` which will force all menu items to get initialized....
239,746
<p>What is the correct way to check if a value is a date/number in Delphi?</p> <p>I know other languages have functions like isDate and isNaN, but what is the Delphi equivalent? at the minute I have this</p> <pre><code>function isNumeric(s1:string):boolean; begin // will throw exception if its not a number /...
[ { "answer_id": 239751, "author": "Alan", "author_id": 31223, "author_profile": "https://Stackoverflow.com/users/31223", "pm_score": 5, "selected": true, "text": "<p>For integers, you could use TryStrToInt to check and convert without throwing exceptions:</p>\n\n<pre><code>function TryStr...
2008/10/27
[ "https://Stackoverflow.com/questions/239746", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2098/" ]
What is the correct way to check if a value is a date/number in Delphi? I know other languages have functions like isDate and isNaN, but what is the Delphi equivalent? at the minute I have this ``` function isNumeric(s1:string):boolean; begin // will throw exception if its not a number // there must be a bett...
For integers, you could use TryStrToInt to check and convert without throwing exceptions: ``` function TryStrToInt(const s: string; out i : integer): boolean; ``` I'm not absolutely sure there is a full equivalent for floats, though, so you might need to use StrToFloat() and accept the possibility of a TFormatExcept...
239,786
<p>I have put together the following mootools script</p> <pre><code> window.addEvent('domready', function() { var shouts = "timed.php"; var log = $('log_res'); function updateData (url,target) { new Ajax(url,{ method: 'get', update: $(target), onComplete: function() { ...
[ { "answer_id": 239869, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 3, "selected": true, "text": "<p>With MooTools 1.2, this works as requested:</p>\n\n<pre><code>function updateData (url, target)\n{\n var target = $(tar...
2008/10/27
[ "https://Stackoverflow.com/questions/239786", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28241/" ]
I have put together the following mootools script ``` window.addEvent('domready', function() { var shouts = "timed.php"; var log = $('log_res'); function updateData (url,target) { new Ajax(url,{ method: 'get', update: $(target), onComplete: function() { log.re...
With MooTools 1.2, this works as requested: ``` function updateData (url, target) { var target = $(target); target.empty().addClass('ajax-loading'); target.innerHTML = "Loading..."; new Request({ url: url, method: 'get', onComplete: function(responseText) { target.removeClass('ajax-loading')...
239,802
<p>I'm writing an app where 3rd party vendors can write plugin DLLs and drop them into the web app's bin directory. I want the ability for these plugins to be able to register their own HttpModules if necessary. </p> <p>Is there anyway that I can add or remove HttpModules from and to the pipeline at runtime without ha...
[ { "answer_id": 240110, "author": "Aaron Fischer", "author_id": 5618, "author_profile": "https://Stackoverflow.com/users/5618", "pm_score": 7, "selected": true, "text": "<blockquote>\n <p>It has to be done at just the right\n time in the HttpApplication life cycle\n which is when the H...
2008/10/27
[ "https://Stackoverflow.com/questions/239802", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2285/" ]
I'm writing an app where 3rd party vendors can write plugin DLLs and drop them into the web app's bin directory. I want the ability for these plugins to be able to register their own HttpModules if necessary. Is there anyway that I can add or remove HttpModules from and to the pipeline at runtime without having a cor...
> > It has to be done at just the right > time in the HttpApplication life cycle > which is when the HttpApplication > object initializes (multiple times, > once for each instance of > HttpApplication). The only method > where this works correct is > HttpApplication Init(). > > > To hook up a module via code ...
239,823
<p>According <a href="http://msdn.microsoft.com/en-us/library/y3bwdsh3.aspx" rel="noreferrer">this MSDN article</a> <em>HttpApplication</em>.EndRequest can be used to close or dispose of resources. However this event is not fired/called in my application.</p> <p>We are attaching the handler in Page_Load the following ...
[ { "answer_id": 239848, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "<p>The page is probably being disposed before the event fires. You might want to try to do your work in the Page_Unload handl...
2008/10/27
[ "https://Stackoverflow.com/questions/239823", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18859/" ]
According [this MSDN article](http://msdn.microsoft.com/en-us/library/y3bwdsh3.aspx) *HttpApplication*.EndRequest can be used to close or dispose of resources. However this event is not fired/called in my application. We are attaching the handler in Page\_Load the following way: ``` HttpContext.Current.ApplicationIns...
You can use your own HttpModule to capture the EndRequest if you don't want to use the global.asax. ``` public class CustomModule : IHttpModule { public void Init(HttpApplication context) { context.EndRequest += new EventHandler(context_EndRequest); } private void context_EndRequest(object se...
239,865
<p>All numbers that divide evenly into x.</p> <p>I put in 4 it returns: 4, 2, 1</p> <p>edit: I know it sounds homeworky. I'm writing a little app to populate some product tables with semi random test data. Two of the properties are ItemMaximum and Item Multiplier. I need to make sure that the multiplier does not c...
[ { "answer_id": 239877, "author": "Chris Marasti-Georg", "author_id": 96, "author_profile": "https://Stackoverflow.com/users/96", "pm_score": 6, "selected": true, "text": "<p>pseudocode:</p>\n<ul>\n<li>Loop from 1 to the square root of the number, call the index &quot;i&quot;.</li>\n<li>i...
2008/10/27
[ "https://Stackoverflow.com/questions/239865", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12862/" ]
All numbers that divide evenly into x. I put in 4 it returns: 4, 2, 1 edit: I know it sounds homeworky. I'm writing a little app to populate some product tables with semi random test data. Two of the properties are ItemMaximum and Item Multiplier. I need to make sure that the multiplier does not create an illogical s...
pseudocode: * Loop from 1 to the square root of the number, call the index "i". * if number mod i is 0, add i and number / i to the list of factors. realocode: ``` public List<int> Factor(int number) { var factors = new List<int>(); int max = (int)Math.Sqrt(number); // Round down for (int factor = 1; ...
239,866
<p>I'm writing a license agreement dialog box with Win32 and I'm stumped. As usual with these things I want the "accept/don't accept" buttons to become enabled when the slider of the scroll bar of the richedit control hits bottom, but I can't find a way to get notified of that event. The earliest I've been able to le...
[ { "answer_id": 239928, "author": "Skizz", "author_id": 1898, "author_profile": "https://Stackoverflow.com/users/1898", "pm_score": 1, "selected": false, "text": "<p>You need to sub-class the edit box and intercept the messages to the edit box itself. <a href=\"http://msdn.microsoft.com/e...
2008/10/27
[ "https://Stackoverflow.com/questions/239866", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31790/" ]
I'm writing a license agreement dialog box with Win32 and I'm stumped. As usual with these things I want the "accept/don't accept" buttons to become enabled when the slider of the scroll bar of the richedit control hits bottom, but I can't find a way to get notified of that event. The earliest I've been able to learn a...
You need to sub-class the edit box and intercept the messages to the edit box itself. [Here's an artical on MSDN about subclassing controls](http://msdn.microsoft.com/en-us/library/ms997565.aspx). EDIT: Some code to demonstrate the scroll bar enabling a button: ``` #include <windows.h> #include <richedit.h> LRESULT...
239,872
<p>VS2008 Code Analysis will flag a spelling mistake in an identifier using the <code>IdentifiersShouldBeSpelledCorrectly</code> warning type.</p> <p>This process is using an American dictionary by default because words are being flagged that are correctly spelt using the British spelling. For example, words like "Org...
[ { "answer_id": 239908, "author": "dove", "author_id": 30913, "author_profile": "https://Stackoverflow.com/users/30913", "pm_score": 2, "selected": false, "text": "<p>This should do it for you <a href=\"http://blogs.msdn.com/fxcop/archive/2007/08/12/new-for-visual-studio-2008-spelling-rul...
2008/10/27
[ "https://Stackoverflow.com/questions/239872", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3362/" ]
VS2008 Code Analysis will flag a spelling mistake in an identifier using the `IdentifiersShouldBeSpelledCorrectly` warning type. This process is using an American dictionary by default because words are being flagged that are correctly spelt using the British spelling. For example, words like "Organisation" and "Custo...
Excellent, thanks. A summary of the solution is... Add the `CodeAnalysisCulture` line to the Project file. Unfortunately I think this has to be done for every project being analysed... ``` <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> ... <RunCodeAnalysis>true</RunCodeAnalys...
239,876
<p>What is the best way of storing data out to a file on a network, which will be later read in again programmatically. Target platform for the program is Linux (Fedora), but it will need to write out a file to a Windows (XP) machine</p> <p>This needs to be in C++, there will be a high number of write / read events so...
[ { "answer_id": 239906, "author": "Yuval F", "author_id": 1702, "author_profile": "https://Stackoverflow.com/users/1702", "pm_score": 3, "selected": false, "text": "<p>Your question is too general. I would first define my needs, then a record structure for the file, and then use a textual...
2008/10/27
[ "https://Stackoverflow.com/questions/239876", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15533/" ]
What is the best way of storing data out to a file on a network, which will be later read in again programmatically. Target platform for the program is Linux (Fedora), but it will need to write out a file to a Windows (XP) machine This needs to be in C++, there will be a high number of write / read events so it needs ...
Your question is too general. I would first define my needs, then a record structure for the file, and then use a textual representation to save it. Take a look at [Eric Stone Raymond's data metaformat](http://www.faqs.org/docs/artu/ch05s02.html), at [JSON](http://www.json.org/), and maybe [CSV](http://en.wikipedia.org...
239,905
<p>Lets say on MySQL database (if it matters).</p>
[ { "answer_id": 239916, "author": "Ilya Komakhin", "author_id": 21603, "author_profile": "https://Stackoverflow.com/users/21603", "pm_score": 2, "selected": false, "text": "<p>No, as you could still use D-SQL in your stored procedures... and validating and restricting your input is a good...
2008/10/27
[ "https://Stackoverflow.com/questions/239905", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28098/" ]
Lets say on MySQL database (if it matters).
No, you will not be completely safe. As others have mentioned, parameterized queries are always the way to go -- no matter how you're accessing the database. It's a bit of an urban legend that with procs you're safe. I think the reason people are under this delusion is because most people assume that you'll call the p...
239,909
<p>I have a property called "IsSecureConnection" that is part of my object's interface. This makes sense for most implementations of the interface, however, in some implementations I would like to make the property ReadOnly. </p> <p>Should I omit this property from the object's interface even though it is required b...
[ { "answer_id": 239911, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": false, "text": "<p>Just add the getter in the interface.</p>\n\n<pre><code>public interface Foo{\n bool MyMinimallyReadOnlyPropertyThatCanAls...
2008/10/27
[ "https://Stackoverflow.com/questions/239909", "https://Stackoverflow.com", "https://Stackoverflow.com/users/132931/" ]
I have a property called "IsSecureConnection" that is part of my object's interface. This makes sense for most implementations of the interface, however, in some implementations I would like to make the property ReadOnly. Should I omit this property from the object's interface even though it is required by all of the...
It really depends on what's most readable for your clients. I can think of a couple of options: 1) The inherited interface, though I'm not a fan of hiding, and I think it makes it a bit ugly for any VB.NET or explicit clients to implement: ``` interface IObject { bool IsSecureConnection { get; } // ... other i...
239,912
<p>Is there a Python class that wraps the <code>file</code> interface (read, write etc.) around a string? I mean something like the <code>stringstream</code> classes in C++.</p> <p>I was thinking of using it to redirect the output of <code>print</code> into a string, like this</p> <pre><code>sys.stdout = string_wrapp...
[ { "answer_id": 239929, "author": "Peter Hoffmann", "author_id": 720, "author_profile": "https://Stackoverflow.com/users/720", "pm_score": 5, "selected": true, "text": "<p>Yes, there is StringIO:</p>\n\n<pre><code>import StringIO\nimport sys\n\n\nsys.stdout = StringIO.StringIO()\nprint \"...
2008/10/27
[ "https://Stackoverflow.com/questions/239912", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30579/" ]
Is there a Python class that wraps the `file` interface (read, write etc.) around a string? I mean something like the `stringstream` classes in C++. I was thinking of using it to redirect the output of `print` into a string, like this ``` sys.stdout = string_wrapper() print "foo", "bar", "baz" s = sys.stdout.to_strin...
Yes, there is StringIO: ``` import StringIO import sys sys.stdout = StringIO.StringIO() print "foo", "bar", "baz" s = sys.stdout.getvalue() ```
239,934
<p>I am using Oracle 10g R2. Recently, after rebooting the server, I started having a problem where I couldn't connect to the instance. I am only connecting locally on the server itself. </p> <p>Oddly enough, the issue corrects itself if I start the Database Administration Assistant, and select my instance to suppose...
[ { "answer_id": 240005, "author": "Colin Pickard", "author_id": 12744, "author_profile": "https://Stackoverflow.com/users/12744", "pm_score": 2, "selected": false, "text": "<p>EDIT: I don't think I read your question properly: The listener should not affect connections on the local machi...
2008/10/27
[ "https://Stackoverflow.com/questions/239934", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3751/" ]
I am using Oracle 10g R2. Recently, after rebooting the server, I started having a problem where I couldn't connect to the instance. I am only connecting locally on the server itself. Oddly enough, the issue corrects itself if I start the Database Administration Assistant, and select my instance to supposedly change...
EDIT: I don't think I read your question properly: The listener should not affect connections on the local machine, so you can probably ignore the rest of the answer, unless it gives you a hint! How were you testing your connection? Was ORA-12514 the only error? --- (I'm assuming you're on Windows here) I guess the l...
239,938
<p>i'm trying to change the number of rows in a <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.tablelayoutpanel.aspx" rel="nofollow noreferrer">TableLayoutPanel</a> programatically (sometimes it needs to be four, sometimes five, and rarely six).</p> <p>Unfortunatly changing the number of rows do...
[ { "answer_id": 240004, "author": "Mark Heath", "author_id": 7532, "author_profile": "https://Stackoverflow.com/users/7532", "pm_score": 0, "selected": false, "text": "<p>Have you tried creating a new <code>RowStyle</code> and then adding it using the <code>tableLayoutPanel1.RowStyles.Add...
2008/10/27
[ "https://Stackoverflow.com/questions/239938", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12597/" ]
i'm trying to change the number of rows in a [TableLayoutPanel](http://msdn.microsoft.com/en-us/library/system.windows.forms.tablelayoutpanel.aspx) programatically (sometimes it needs to be four, sometimes five, and rarely six). Unfortunatly changing the number of rows does not keep the [`RowStyles`](http://msdn.micro...
This issue was reported to Microsoft in 2005, and they acknowledge it's a bug, but they were "*still evaluating our options here*" Microsoft has decided not to fix it ("Closed"). **[TableLayoutPanel Rows and RowStyles do not correspond.](http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=1...
239,945
<p>I'm creating a really complex dynamic sql, it's got to return one row per user, but now I have to join against a one to many table. I do an outer join to make sure I get at least one row back (and can check for null to see if there's data in that table) but I have to make sure I only get one row back from this outer...
[ { "answer_id": 239956, "author": "Ady", "author_id": 31395, "author_profile": "https://Stackoverflow.com/users/31395", "pm_score": 0, "selected": false, "text": "<p>Maybe your example is too simplified, but I'd use a group by:</p>\n\n<pre>\nSELECT\n a.user_id \nFROM \n table1 a\n LE...
2008/10/27
[ "https://Stackoverflow.com/questions/239945", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12386/" ]
I'm creating a really complex dynamic sql, it's got to return one row per user, but now I have to join against a one to many table. I do an outer join to make sure I get at least one row back (and can check for null to see if there's data in that table) but I have to make sure I only get one row back from this outer jo...
In MySql you can ensure that any query returns at most X rows using ``` select * from foo where bar = 1 limit X; ``` Unfortunately, I'm fairly sure this is a MySQL-specific extension to SQL. However, a Google search for something like "mysql sybase limit" might turn up an equivalent for Sybase.
239,951
<p>For example for the following XML</p> <pre><code> &lt;Order&gt; &lt;Phone&gt;1254&lt;/Phone&gt; &lt;City&gt;City1&lt;/City&gt; &lt;State&gt;State&lt;/State&gt; &lt;/Order&gt; </code></pre> <p>I might want to find out whether the XElement contains "City" Node or not. </p>
[ { "answer_id": 239963, "author": "Amy B", "author_id": 8155, "author_profile": "https://Stackoverflow.com/users/8155", "pm_score": 7, "selected": true, "text": "<p>Just use the other overload for <a href=\"http://msdn.microsoft.com/en-us/library/bb348975.aspx\" rel=\"noreferrer\">Element...
2008/10/27
[ "https://Stackoverflow.com/questions/239951", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1688440/" ]
For example for the following XML ``` <Order> <Phone>1254</Phone> <City>City1</City> <State>State</State> </Order> ``` I might want to find out whether the XElement contains "City" Node or not.
Just use the other overload for [Elements](http://msdn.microsoft.com/en-us/library/bb348975.aspx). ``` bool hasCity = OrderXml.Elements("City").Any(); ```
240,012
<p>This is a follow-up to a previous question I had about interfaces. I received an answer that I like, but I'm not sure how to implement it in VB.NET.</p> <p>Previous question:</p> <p><a href="https://stackoverflow.com/questions/239909/should-this-property-be-part-of-my-objects-interface">Should this property be pa...
[ { "answer_id": 240036, "author": "Chris Marasti-Georg", "author_id": 96, "author_profile": "https://Stackoverflow.com/users/96", "pm_score": 3, "selected": true, "text": "<p>Simply define the getter in one interface, and create a second interface that has both the getter and the setter. ...
2008/10/27
[ "https://Stackoverflow.com/questions/240012", "https://Stackoverflow.com", "https://Stackoverflow.com/users/132931/" ]
This is a follow-up to a previous question I had about interfaces. I received an answer that I like, but I'm not sure how to implement it in VB.NET. Previous question: [Should this property be part of my object's interface?](https://stackoverflow.com/questions/239909/should-this-property-be-part-of-my-objects-interfa...
Simply define the getter in one interface, and create a second interface that has both the getter and the setter. If your concrete class is mutable, have it implement the second interface. In your code that deals with the class, check to see that it is an instance of the second interface, cast if so, then call the sett...
240,016
<p>I have created a class for a dashboard item which will hold information such as placement on the dashboard, description, etc. I am currently using a pair of Collections to hold those dashboard items contained in the "library" and those items showing on the dashboard itself. I have been asked to make this dashboard...
[ { "answer_id": 240027, "author": "Charles Graham", "author_id": 7705, "author_profile": "https://Stackoverflow.com/users/7705", "pm_score": 1, "selected": false, "text": "<p>Why not create a class that contains your second collection and any of the previous information, and just have a c...
2008/10/27
[ "https://Stackoverflow.com/questions/240016", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30838/" ]
I have created a class for a dashboard item which will hold information such as placement on the dashboard, description, etc. I am currently using a pair of Collections to hold those dashboard items contained in the "library" and those items showing on the dashboard itself. I have been asked to make this dashboard mult...
``` List< List<Placement>> ListofListOfPlacements = new List< List<Placement>> (); List<Placement> dashboard1 = new List<Placement>(); List<Placement> dashboard2 = new List<Placement>(); List<Placement> dashboard3 = new List<Placement>(); List<Placement> dashboard4 = new List<Placement>(); ListofListOfPlacements.Add(...
240,031
<p>I'm working on a program to do some image wrangling in Python for work. I'm using FreeImagePy because PIL doesn't support multi-page TIFFs. Whenever I try to save a file with it from my program I get this error message (or something similar depending on which way I try to save):</p> <pre><code>Error returned. TI...
[ { "answer_id": 242366, "author": "monkut", "author_id": 24718, "author_profile": "https://Stackoverflow.com/users/24718", "pm_score": 1, "selected": false, "text": "<p>Looks like a permission issues, make sure you don't have the file open in another application, and that you have write p...
2008/10/27
[ "https://Stackoverflow.com/questions/240031", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31801/" ]
I'm working on a program to do some image wrangling in Python for work. I'm using FreeImagePy because PIL doesn't support multi-page TIFFs. Whenever I try to save a file with it from my program I get this error message (or something similar depending on which way I try to save): ``` Error returned. TIFF FreeImage_Sav...
Looks like a permission issues, make sure you don't have the file open in another application, and that you have write permissions to the file location your trying to write to.
240,046
<p>I'd like to use Oracle's utl_match.edit_distance function. It supposed to compare two strings and return the <a href="http://en.wikipedia.org/wiki/Levenshtein_Distance" rel="nofollow noreferrer">Levenshtein distance</a>.</p> <pre><code>select utl_match.edit_distance('a','b') from dual </code></pre> <p>returns 1 as...
[ { "answer_id": 240121, "author": "Tony Andrews", "author_id": 18747, "author_profile": "https://Stackoverflow.com/users/18747", "pm_score": 1, "selected": false, "text": "<p>I agree, it appears to be wrong. However, this package is undocumented by Oracle, so is perhaps unsupported at pr...
2008/10/27
[ "https://Stackoverflow.com/questions/240046", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21348/" ]
I'd like to use Oracle's utl\_match.edit\_distance function. It supposed to compare two strings and return the [Levenshtein distance](http://en.wikipedia.org/wiki/Levenshtein_Distance). ``` select utl_match.edit_distance('a','b') from dual ``` returns 1 as expected, but ``` select utl_match.edit_distance('á','b') f...
This seems to be related to the character set. If I run the same test in a 10.2.0.3 and 11.1.0.7 database using ISO8859P15 as the character set, I get a distance of 1 as well. I'm guessing that Oracle is computing the distance in terms of bytes rather than characters in variable-width character sets. You can work arou...
240,047
<p>In SQL Server, why is this:</p> <pre><code>[dbo].[table_name] </code></pre> <p>preferable to this:</p> <pre><code>dbo.table_name </code></pre> <p>And along those lines, why even list the dbo at all if there's only one schema?</p>
[ { "answer_id": 240052, "author": "Iain Holder", "author_id": 1122, "author_profile": "https://Stackoverflow.com/users/1122", "pm_score": 3, "selected": true, "text": "<p>It's just in case you have a keyword as a tablename like [user]</p>\n" }, { "answer_id": 240056, "author":...
2008/10/27
[ "https://Stackoverflow.com/questions/240047", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2147/" ]
In SQL Server, why is this: ``` [dbo].[table_name] ``` preferable to this: ``` dbo.table_name ``` And along those lines, why even list the dbo at all if there's only one schema?
It's just in case you have a keyword as a tablename like [user]
240,090
<p>We have a ASP.Net 2.0 web application up and running with the server in the Midwest (Eastern Standard Time). At this moment all of our customers are in the same time zone as the server. We are bringing another server online in Arizona (Mountain Standard Time).</p> <p>We are storing all our times in a SQL 2005 datab...
[ { "answer_id": 240105, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 1, "selected": false, "text": "<p>If you're using .NET 3.5 <em>and</em> you know the timezone that the user is in, <a href=\"http://msdn.microsoft.com/...
2008/10/27
[ "https://Stackoverflow.com/questions/240090", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4096/" ]
We have a ASP.Net 2.0 web application up and running with the server in the Midwest (Eastern Standard Time). At this moment all of our customers are in the same time zone as the server. We are bringing another server online in Arizona (Mountain Standard Time). We are storing all our times in a SQL 2005 database via C#...
I had the same issue. We sold our application to a user that was in a different time zone than the web server. We did not store any time information in UTC, but it was actually working correctly. Time displayed in the server's time zone was displaying exactly 3 hours behind. All we had to do was add a time zone drop do...
240,098
<p>I'm using an HTML sanitizing whitelist code found here:<br> <a href="http://refactormycode.com/codes/333-sanitize-html" rel="nofollow noreferrer">http://refactormycode.com/codes/333-sanitize-html</a></p> <p>I needed to add the "font" tag as an additional tag to match, so I tried adding this condition after the <cod...
[ { "answer_id": 240129, "author": "Robert Gamble", "author_id": 25222, "author_profile": "https://Stackoverflow.com/users/25222", "pm_score": 2, "selected": false, "text": "<p>I don't see anything obviously wrong with the regex. I would try isolating the problem by removing pieces of the...
2008/10/27
[ "https://Stackoverflow.com/questions/240098", "https://Stackoverflow.com", "https://Stackoverflow.com/users/392/" ]
I'm using an HTML sanitizing whitelist code found here: <http://refactormycode.com/codes/333-sanitize-html> I needed to add the "font" tag as an additional tag to match, so I tried adding this condition after the `<img` tag check ``` if (tagname.StartsWith("<font")) { // detailed <font> tag checking // No...
Your IsMatch Method is using the option `RegexOptions.IgnorePatternWhitespace`, that allows you to put comments inside the regular expressions, so you have to scape the # chatacter, otherwise it will be interpreted as a comment. ``` if (!IsMatch(tagname,@"<font(\s*size=""\d{1}"")? (\s*color=""((\#[0-9a-f]{6})|(\#[...
240,122
<p>Given the following java enum:</p> <pre><code>public enum AgeRange { A18TO23 { public String toString() { return "18 - 23"; } }, A24TO29 { public String toString() { return "24 - 29"; } }, A30TO35 { public String toStr...
[ { "answer_id": 240132, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 3, "selected": false, "text": "<p>You could always create a map from string to value - do so statically so you only need to map it once, assuming that ...
2008/10/27
[ "https://Stackoverflow.com/questions/240122", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27163/" ]
Given the following java enum: ``` public enum AgeRange { A18TO23 { public String toString() { return "18 - 23"; } }, A24TO29 { public String toString() { return "24 - 29"; } }, A30TO35 { public String toString() { ...
The best and simplest way to do it is like this: ``` public enum AgeRange { A18TO23 ("18-23"), A24TO29 ("24-29"), A30TO35("30-35"); private String value; AgeRange(String value){ this.value = value; } public String toString(){ return value; } public static AgeRang...
240,125
<p>I have a form a user can enter their name, then it will add it to $message to be sent in an email.</p> <p>Is it better to use <code>$_POST</code> or <code>$_REQUEST</code>?</p> <p>Here is a snippet of using <code>$_REQUEST</code></p> <pre><code>$message.= "Name: ".$_REQUEST["fname"]." ".$_REQUEST["mname"]." ".$_R...
[ { "answer_id": 240141, "author": "DylanJ", "author_id": 87, "author_profile": "https://Stackoverflow.com/users/87", "pm_score": 1, "selected": false, "text": "<p>doesn't matter which one you use. just make sure you use some form of security with forms.</p>\n" }, { "answer_id": 24...
2008/10/27
[ "https://Stackoverflow.com/questions/240125", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26130/" ]
I have a form a user can enter their name, then it will add it to $message to be sent in an email. Is it better to use `$_POST` or `$_REQUEST`? Here is a snippet of using `$_REQUEST` ``` $message.= "Name: ".$_REQUEST["fname"]." ".$_REQUEST["mname"]." ".$_REQUEST["lname"]."\n"; ```
The answer is: It depends on how you want it to be used. If you're using `$_POST`, that means it can only come in via POST. If you're using `$_REQUEST`, that means you accept POST, GET (and COOKIE, but it's mainly the first two we're interested in). For something like this, `$_POST` would probably be neater, but if y...
240,163
<p>I am trying to upload files using the FileReference class. Files >2MB all work correctly but files &lt;2MB cause this error:</p> <blockquote> <p>"java.io.IOException: Corrupt form data: premature ending"</p> </blockquote> <p>On the server I am using the com.oreilly.servlet package to handle the request.</p> <p>...
[ { "answer_id": 240213, "author": "asterite", "author_id": 20459, "author_profile": "https://Stackoverflow.com/users/20459", "pm_score": 3, "selected": true, "text": "<p>In WPF you have <a href=\"http://msdn.microsoft.com/en-us/library/system.componentmodel.dependencypropertydescriptor.ad...
2008/10/27
[ "https://Stackoverflow.com/questions/240163", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22/" ]
I am trying to upload files using the FileReference class. Files >2MB all work correctly but files <2MB cause this error: > > "java.io.IOException: Corrupt form data: premature ending" > > > On the server I am using the com.oreilly.servlet package to handle the request. I have used this package many times to suc...
In WPF you have [DependencyPropertyDescriptor.AddValueChanged](http://msdn.microsoft.com/en-us/library/system.componentmodel.dependencypropertydescriptor.addvaluechanged.aspx), but unfortunately in Silverlight there's no such thing. So the answer is no. Maybe if you explain what are you trying to do you can workaround...
240,166
<p>I'm using the javax.mail system, and having problems with "Invalid Address" exceptions. Here's the basics of the code:</p> <pre><code> // Get system properties Properties props = System.getProperties(); // Setup mail server props.put("mail.smtp.host", m_sending_host); // Get session Sessio...
[ { "answer_id": 240208, "author": "Agusti-N", "author_id": 24639, "author_profile": "https://Stackoverflow.com/users/24639", "pm_score": 0, "selected": false, "text": "<p>Try this:</p>\n\n<pre><code>String to=\"stackoverflow@so.com\";\nString cc=\"one@mail.com,two@mail.com\"; //The separa...
2008/10/27
[ "https://Stackoverflow.com/questions/240166", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24193/" ]
I'm using the javax.mail system, and having problems with "Invalid Address" exceptions. Here's the basics of the code: ``` // Get system properties Properties props = System.getProperties(); // Setup mail server props.put("mail.smtp.host", m_sending_host); // Get session Session session = Ses...
--Update: problem with authentication. Ok, here's what I've discovered was going on. When receiving e-mail, the code above correctly sets up authentication and the Authenticator.getPasswordAuthentication() callback is actually invoked. Not so when sending e-mail. You have to do a bit more. Add this: ``` // Setup mai...
240,171
<p>How can I launch an application using C#?</p> <p>Requirements: Must work on <a href="http://en.wikipedia.org/wiki/Windows_XP" rel="noreferrer">Windows&nbsp;XP</a> and <a href="http://en.wikipedia.org/wiki/Windows_Vista" rel="noreferrer">Windows&nbsp;Vista</a>.</p> <p>I have seen a sample from DinnerNow.net sampler...
[ { "answer_id": 240189, "author": "Mark S. Rasmussen", "author_id": 12469, "author_profile": "https://Stackoverflow.com/users/12469", "pm_score": 6, "selected": false, "text": "<pre><code>System.Diagnostics.Process.Start(\"PathToExe.exe\");\n</code></pre>\n" }, { "answer_id": 2401...
2008/10/27
[ "https://Stackoverflow.com/questions/240171", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5147/" ]
How can I launch an application using C#? Requirements: Must work on [Windows XP](http://en.wikipedia.org/wiki/Windows_XP) and [Windows Vista](http://en.wikipedia.org/wiki/Windows_Vista). I have seen a sample from DinnerNow.net sampler that only works in Windows Vista.
Use [`System.Diagnostics.Process.Start()`](http://msdn.microsoft.com/en-us/library/system.diagnostics.process.start.aspx) method. Check out [this article](http://www.codeproject.com/KB/cs/start_an_external_app.aspx) on how to use it. ``` Process.Start("notepad", "readme.txt"); string winpath = Environment.GetEnviron...
240,178
<p>I created a list of lists:</p> <pre><code>xs = [[1] * 4] * 3 # xs == [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]] </code></pre> <p>Then, I changed one of the innermost values:</p> <pre><code>xs[0][0] = 5 # xs == [[5, 1, 1, 1], [5, 1, 1, 1], [5, 1, 1, 1]] </code></pre> <p>Why did every first element of each subli...
[ { "answer_id": 240202, "author": "Blair Conrad", "author_id": 1199, "author_profile": "https://Stackoverflow.com/users/1199", "pm_score": 6, "selected": false, "text": "<pre><code>[[1] * 4] * 3\n</code></pre>\n\n<p>or even:</p>\n\n<pre><code>[[1, 1, 1, 1]] * 3\n</code></pre>\n\n<p>Create...
2008/10/27
[ "https://Stackoverflow.com/questions/240178", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11677/" ]
I created a list of lists: ``` xs = [[1] * 4] * 3 # xs == [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]] ``` Then, I changed one of the innermost values: ``` xs[0][0] = 5 # xs == [[5, 1, 1, 1], [5, 1, 1, 1], [5, 1, 1, 1]] ``` Why did every first element of each sublist change to `5`?
When you write `[x]*3` you get, essentially, the list `[x, x, x]`. That is, a list with 3 references to the same `x`. When you then modify this single `x` it is visible via all three references to it: ``` x = [1] * 4 xs = [x] * 3 print(f"id(x): {id(x)}") # id(x): 140560897920048 print( f"id(xs[0]): {id(xs[0])}\n" ...
240,182
<p>Why is Oracle's <code>to_char()</code> function adding spaces?</p> <pre><code>select length('012'), length(to_char('012')), length(to_char('12', '000')) from dual; </code></pre> <p><code>3, 3, 4</code></p>
[ { "answer_id": 240196, "author": "stjohnroe", "author_id": 2985, "author_profile": "https://Stackoverflow.com/users/2985", "pm_score": 6, "selected": true, "text": "<p>The format mask that you are using is fixed width and allows for a minus sign</p>\n" }, { "answer_id": 240206, ...
2008/10/27
[ "https://Stackoverflow.com/questions/240182", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4235/" ]
Why is Oracle's `to_char()` function adding spaces? ``` select length('012'), length(to_char('012')), length(to_char('12', '000')) from dual; ``` `3, 3, 4`
The format mask that you are using is fixed width and allows for a minus sign
240,184
<p>I'm writing a CESetup.dll for a Windows Mobile app. It must be unmanaged, which I have little experience with. So I'm unsure of whether I should free the memory I allocate and how I do it.</p> <p>Here's the function I've written:</p> <pre><code> Uninstall_Init( HWND hwndParent, LPCTSTR pszIns...
[ { "answer_id": 240197, "author": "Treb", "author_id": 22114, "author_profile": "https://Stackoverflow.com/users/22114", "pm_score": 1, "selected": false, "text": "<p>Yes, you should. By calling </p>\n\n<pre><code> delete[] folderPath;\n</code></pre>\n\n<p>at the end of your function. All...
2008/10/27
[ "https://Stackoverflow.com/questions/240184", "https://Stackoverflow.com", "https://Stackoverflow.com/users/631/" ]
I'm writing a CESetup.dll for a Windows Mobile app. It must be unmanaged, which I have little experience with. So I'm unsure of whether I should free the memory I allocate and how I do it. Here's the function I've written: ``` Uninstall_Init( HWND hwndParent, LPCTSTR pszInstallDir ) { LPTST...
I think you want to use this: ``` delete [] folderPath; ``` It looks like you're allocating an array of TCHARs, which makes sense since it's a string. When you allocate an array, you must delete using the array delete operator (which you get by including the brackets in the delete statement). I'm pretty sure you'll ...
240,219
<p>I have an ASP .Net (3.5) website. I have the following code that uploads a file as a binary to a SQL Database:</p> <pre><code>Print(" protected void UploadButton_Click(object sender, EventArgs e) { //Get the posted file Stream fileDataStream = FileUpload.Post...
[ { "answer_id": 240243, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 1, "selected": false, "text": "<p>So are you really just after how to serve a byte array in ASP.NET? It sounds like the database part is irrelevant, gi...
2008/10/27
[ "https://Stackoverflow.com/questions/240219", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have an ASP .Net (3.5) website. I have the following code that uploads a file as a binary to a SQL Database: ``` Print(" protected void UploadButton_Click(object sender, EventArgs e) { //Get the posted file Stream fileDataStream = FileUpload.PostedFile.InputSt...
So are you really just after how to serve a byte array in ASP.NET? It sounds like the database part is irrelevant, given that you've said you are able to get the binary file with a LINQ query. If so, look at [HttpResponse.BinaryWrite](http://msdn.microsoft.com/en-us/library/system.web.httpresponse.binarywrite.aspx). Y...
240,224
<p>In my web app, my parameters can contain all sorts of crazy characters (russian chars, slashes, spaces etc) and can therefor not always be represented as-is in a URL.<br> Sending them on their merry way will work in about 50% of the cases. Some things like spaces are already encoded somewhere (I'm guessing in the Ht...
[ { "answer_id": 240245, "author": "Mitchel Sellers", "author_id": 13279, "author_profile": "https://Stackoverflow.com/users/13279", "pm_score": 0, "selected": false, "text": "<p>Have you tried using the <code>Server.UrlEncode()</code> method to do the encoding, and the <code>Server.UrlDec...
2008/10/27
[ "https://Stackoverflow.com/questions/240224", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11333/" ]
In my web app, my parameters can contain all sorts of crazy characters (russian chars, slashes, spaces etc) and can therefor not always be represented as-is in a URL. Sending them on their merry way will work in about 50% of the cases. Some things like spaces are already encoded somewhere (I'm guessing in the Html.B...
Parameters should be escaped using `Uri.EscapeDataString`: ``` string url = string.Format("http://www.foo.bar/page?name={0}&address={1}", Uri.EscapeDataString("adlknad /?? lkm#"), Uri.EscapeDataString(" qeio103 8182")); Console.WriteLine(url); Uri ur...
240,242
<p>I have a main window (#1) on my webpage from which I open a new browser window (#2) from which I open a new window (#3).</p> <p>Now if my user closes window#2 before window#3, I have the problem that window#3 no longer can call function in its window.opener since it has gone away.</p> <p>What I would like to do is...
[ { "answer_id": 240266, "author": "Chris Marasti-Georg", "author_id": 96, "author_profile": "https://Stackoverflow.com/users/96", "pm_score": 0, "selected": false, "text": "<p>This may be tangential, but why do you need to open 3 separate windows? Can you use a jQuery dialog instead? I ...
2008/10/27
[ "https://Stackoverflow.com/questions/240242", "https://Stackoverflow.com", "https://Stackoverflow.com/users/441556/" ]
I have a main window (#1) on my webpage from which I open a new browser window (#2) from which I open a new window (#3). Now if my user closes window#2 before window#3, I have the problem that window#3 no longer can call function in its window.opener since it has gone away. What I would like to do is to set window#3....
In the third wndow you put in: ``` <script type="text/javascript"> var grandMother = null; window.onload = function(){ grandMother = window.opener.opener; } </script> ``` Thus you have the handle to the grandmother-window, and you can then use it for anything directly: ``` if(grandMother) grandMothe...
240,244
<p>I want to read line n1->n2 from file foo.c into the current buffer.</p> <p>I tried: <code>147,227r /path/to/foo/foo.c</code></p> <p>But I get: "E16: Invalid range", though I am certain that foo.c contains more than 1000 lines.</p>
[ { "answer_id": 240262, "author": "Stewart Johnson", "author_id": 6408, "author_profile": "https://Stackoverflow.com/users/6408", "pm_score": 5, "selected": false, "text": "<p>The {range} refers to the destination in the current file, not the range of lines in the source file.</p>\n\n<p>A...
2008/10/27
[ "https://Stackoverflow.com/questions/240244", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29405/" ]
I want to read line n1->n2 from file foo.c into the current buffer. I tried: `147,227r /path/to/foo/foo.c` But I get: "E16: Invalid range", though I am certain that foo.c contains more than 1000 lines.
``` :r! sed -n 147,227p /path/to/foo/foo.c ```
240,263
<p>I am putting together some ideas for our automated testing platform and have been looking at Selenium for the test runner.</p> <p>I am wrapping the recorded Selenium C# scripts in an MbUnit test, which is being triggered via the MbUnit NAnt task. The Selenium test client is created as follows:</p> <pre><code>selen...
[ { "answer_id": 240295, "author": "Scott Saad", "author_id": 4916, "author_profile": "https://Stackoverflow.com/users/4916", "pm_score": 0, "selected": false, "text": "<p>Anytime I need to integrate with an external entity using NAnt I either end up using the <strong>exec task</strong> or...
2008/10/27
[ "https://Stackoverflow.com/questions/240263", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31412/" ]
I am putting together some ideas for our automated testing platform and have been looking at Selenium for the test runner. I am wrapping the recorded Selenium C# scripts in an MbUnit test, which is being triggered via the MbUnit NAnt task. The Selenium test client is created as follows: ``` selenium = new DefaultSele...
Thanks for the responses so far. Environment variables could work, however, we could be running parallel tests via a single test assembly so I wouldn't want settings to be overwritten during execution, which could break another test. Interesting line of thought though, thanks, I reckon I could use that in other areas....
240,269
<p>I'm hitting this error and I'm not really sure why. I have a minified version of excanvas.js and something is breaking in IE, specifically on:</p> <p><code> var b=a.createStyleSheet(); </code></p> <p>I'm not sure why. Does anyone have any insight? I can provide more information, I'm just not sure what informati...
[ { "answer_id": 267947, "author": "Justin Love", "author_id": 30203, "author_profile": "https://Stackoverflow.com/users/30203", "pm_score": 0, "selected": false, "text": "<p>First thing I'd do is use the un-minified version. Looks like this coming from an init function called from onread...
2008/10/27
[ "https://Stackoverflow.com/questions/240269", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2484/" ]
I'm hitting this error and I'm not really sure why. I have a minified version of excanvas.js and something is breaking in IE, specifically on: `var b=a.createStyleSheet();` I'm not sure why. Does anyone have any insight? I can provide more information, I'm just not sure what information will help.
This is a slightly old thread, but I thought it would be useful to post. There seems to be a limitation on how much style information a page can contain, which causes this error in IE6. I am able to produce an invalid argument error using this simple test page: ``` <html> <head> <title></title> <script> for(var i=0;i<...
240,283
<p>I'm working on a REST service that has a few requirements:</p> <ol> <li>It has to be secure.</li> <li>Users should not be able to forge requests.</li> </ol> <p>My current proposed solution is to have a custom Authorization header that look like this (this is the same way that the amazon web services work):</p> <p...
[ { "answer_id": 240305, "author": "Steven Huwig", "author_id": 28604, "author_profile": "https://Stackoverflow.com/users/28604", "pm_score": 2, "selected": true, "text": "<p>I think the simplest way to do this right would be to use HTTPS client authentication. Apple's site has a <a href=\...
2008/10/27
[ "https://Stackoverflow.com/questions/240283", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4590/" ]
I'm working on a REST service that has a few requirements: 1. It has to be secure. 2. Users should not be able to forge requests. My current proposed solution is to have a custom Authorization header that look like this (this is the same way that the amazon web services work): ``` Authorization: MYAPI username:signa...
I think the simplest way to do this right would be to use HTTPS client authentication. Apple's site has a [thread](http://discussions.apple.com/thread.jspa?threadID=1643618) on this very subject. Edit: to handle authorization, I would create a separate resource (URI) on the server for each user, and only permit that (...
240,293
<p>How would I achieve the pseudo-code below in JavaScript? I want to include the date check in the second code excerpt, where txtDate is for the BilledDate.</p> <pre><code>If ABS(billeddate – getdate) &gt; 31 then yesno “The date you have entered is more than a month from today, Are you sure the date is correct,”....
[ { "answer_id": 240318, "author": "yeradis", "author_id": 30715, "author_profile": "https://Stackoverflow.com/users/30715", "pm_score": -1, "selected": false, "text": "<p>Hello and good day for everyone</p>\n\n<p>You can try Refular Expressions to parse and validate a date format</p>\n\n<...
2008/10/27
[ "https://Stackoverflow.com/questions/240293", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8741/" ]
How would I achieve the pseudo-code below in JavaScript? I want to include the date check in the second code excerpt, where txtDate is for the BilledDate. ``` If ABS(billeddate – getdate) > 31 then yesno “The date you have entered is more than a month from today, Are you sure the date is correct,”. if (txtDate && t...
Generally speaking you work with Date-objects in javascript, and these should be constructed with the following syntax: ``` var myDate = new Date(yearno, monthno-1, dayno); //you could put hour, minute, second and milliseconds in this too ``` Beware, the month-part is an index, so january is 0, february is 1...
240,314
<p>I use Struts v1.3 and have following input form:</p> <p>In struts-config.xml:</p> <pre><code> &lt;form-bean name="testForm" type="org.apache.struts.validator.DynaValidatorForm"&gt; &lt;form-property name="displayName" type="java.lang.String" /&gt; &lt;/form-bean&gt; </code></pre> <p...
[ { "answer_id": 263444, "author": "mana", "author_id": 12016, "author_profile": "https://Stackoverflow.com/users/12016", "pm_score": 2, "selected": false, "text": "<p>You may have a chance to trim the string right at the moment, the request processor updates the data from the input fields...
2008/10/27
[ "https://Stackoverflow.com/questions/240314", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11662/" ]
I use Struts v1.3 and have following input form: In struts-config.xml: ``` <form-bean name="testForm" type="org.apache.struts.validator.DynaValidatorForm"> <form-property name="displayName" type="java.lang.String" /> </form-bean> ``` In validation.xml: ``` <form name="testForm">...
You may have a chance to trim the string right at the moment, the request processor updates the data from the input fields to the form. This was not tested, but what happens when you modify the setter setDisplayName(String displayName) to something like ``` public void setDisplayName(String displayName) { this.di...
240,320
<p>I have a method that I would like to call. However, I'm looking for a clean, simple way to kill it or force it to return if it is taking too long to execute.</p> <p>I'm using Java.</p> <p>to illustrate:</p> <pre><code>logger.info("sequentially executing all batches..."); for (TestExecutor executor : builder.getE...
[ { "answer_id": 240343, "author": "Tim Stewart", "author_id": 26002, "author_profile": "https://Stackoverflow.com/users/26002", "pm_score": 3, "selected": false, "text": "<p>I'm assuming the use of multiple threads in the following statements.</p>\n\n<p>I've done some reading in this area...
2008/10/27
[ "https://Stackoverflow.com/questions/240320", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20498/" ]
I have a method that I would like to call. However, I'm looking for a clean, simple way to kill it or force it to return if it is taking too long to execute. I'm using Java. to illustrate: ``` logger.info("sequentially executing all batches..."); for (TestExecutor executor : builder.getExecutors()) { logger.info("ex...
You should take a look at these classes : [FutureTask](http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/FutureTask.html), [Callable](http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/Callable.html), [Executors](http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/Executors.html) Here is...
240,341
<p>I need a date formula in Oracle SQL or T-SQL that will return a date of the previous week (eg Last Monday's date).</p> <p>I have reports with parameters that are run each week usually with parameter dates mon-friday or sunday-saturday of the previous week. I'd like to not have to type in the dates when i run the r...
[ { "answer_id": 240368, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 2, "selected": false, "text": "<p>T-SQL:</p>\n\n<pre><code>SELECT \n DateColumn,\n DateColumn - CASE DATEPART(dw, DateColumn) \n WHEN 1 ...
2008/10/27
[ "https://Stackoverflow.com/questions/240341", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I need a date formula in Oracle SQL or T-SQL that will return a date of the previous week (eg Last Monday's date). I have reports with parameters that are run each week usually with parameter dates mon-friday or sunday-saturday of the previous week. I'd like to not have to type in the dates when i run the reports each...
T-SQL: ``` SELECT DateColumn, DateColumn - CASE DATEPART(dw, DateColumn) WHEN 1 THEN 6 ELSE DATEPART(dw, DateColumn) - 2 END MondayOfDateColumn FROM TheTable ``` Do you need the time part to be "00:00:00", too? If so, add this expression to the calculation: ``...
240,345
<p>I have a ClickOnce deployed application I want to launch from VBScript, similar to launching Microsoft Word in the following example:</p> <pre><code>Dim word Set word = CreateObject("Word.Application") word.Visible = True </code></pre> <p>The problem is I don't know what parameter to pass into the <code>CreateObje...
[ { "answer_id": 240366, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 3, "selected": true, "text": "<p>ClickOnce simply isn't installed that way. They don't typically have COM hooks (for CreateObject), and are installe...
2008/10/27
[ "https://Stackoverflow.com/questions/240345", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13338/" ]
I have a ClickOnce deployed application I want to launch from VBScript, similar to launching Microsoft Word in the following example: ``` Dim word Set word = CreateObject("Word.Application") word.Visible = True ``` The problem is I don't know what parameter to pass into the `CreateObject` function to launch my appli...
ClickOnce simply isn't installed that way. They don't typically have COM hooks (for CreateObject), and are installed in an isolated part of the user's profile (not that machine's profile). And don't forget you can also get multiple copies/versions of the same app at once via ClickOnce (from different locations). One o...
240,353
<p>I'm looking for a way to convert a preprocessor token to a string.</p> <p>Specifically, I've somewhere got:</p> <pre><code>#define MAX_LEN 16 </code></pre> <p>and I want to use it to prevent buffer overrun:</p> <pre><code>char val[MAX_LEN+1]; // room for \0 sscanf(buf, "%"MAX_LEN"s", val); </code></pre> <p>I'm ...
[ { "answer_id": 240361, "author": "davenpcj", "author_id": 4777, "author_profile": "https://Stackoverflow.com/users/4777", "pm_score": 5, "selected": false, "text": "<p>I found an answer online.</p>\n\n<blockquote>\n <blockquote>\n<pre><code>#define VERSION_MAJOR 4\n#define VERSION_MINOR...
2008/10/27
[ "https://Stackoverflow.com/questions/240353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4777/" ]
I'm looking for a way to convert a preprocessor token to a string. Specifically, I've somewhere got: ``` #define MAX_LEN 16 ``` and I want to use it to prevent buffer overrun: ``` char val[MAX_LEN+1]; // room for \0 sscanf(buf, "%"MAX_LEN"s", val); ``` I'm open to other ways to accomplish the same thing, but sta...
see <http://www.decompile.com/cpp/faq/file_and_line_error_string.htm> specifically: ``` #define STRINGIFY(x) #x #define TOSTRING(x) STRINGIFY(x) #define AT __FILE__ ":" TOSTRING(__LINE__) ``` so your problem can be solved by doing `sscanf(buf, "%" TOSTRING(MAX_LEN) "s", val);`
240,354
<p>We have a POST to a PL/SQL database procedure that (a) does some database operations based on the POST parameters and (b) redirects the user to a page showing the results.</p> <p>The problem is, when the user does a browser "refresh" of the results page, that still has the original request, so it calls the database...
[ { "answer_id": 240361, "author": "davenpcj", "author_id": 4777, "author_profile": "https://Stackoverflow.com/users/4777", "pm_score": 5, "selected": false, "text": "<p>I found an answer online.</p>\n\n<blockquote>\n <blockquote>\n<pre><code>#define VERSION_MAJOR 4\n#define VERSION_MINOR...
2008/10/27
[ "https://Stackoverflow.com/questions/240354", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8051/" ]
We have a POST to a PL/SQL database procedure that (a) does some database operations based on the POST parameters and (b) redirects the user to a page showing the results. The problem is, when the user does a browser "refresh" of the results page, that still has the original request, so it calls the database procedure...
see <http://www.decompile.com/cpp/faq/file_and_line_error_string.htm> specifically: ``` #define STRINGIFY(x) #x #define TOSTRING(x) STRINGIFY(x) #define AT __FILE__ ":" TOSTRING(__LINE__) ``` so your problem can be solved by doing `sscanf(buf, "%" TOSTRING(MAX_LEN) "s", val);`
240,382
<p>I need my .net application to use the .html extension instead of .aspx </p> <p>I'm converting a php app and there are external applications which depend on that extension to function.</p> <p>What is the best way to do this?</p> <p>Thanks</p>
[ { "answer_id": 240385, "author": "dove", "author_id": 30913, "author_profile": "https://Stackoverflow.com/users/30913", "pm_score": 1, "selected": false, "text": "<p>You want to use <a href=\"http://msdn.microsoft.com/en-us/library/ms972953.aspx\" rel=\"nofollow noreferrer\">httpHandlers...
2008/10/27
[ "https://Stackoverflow.com/questions/240382", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2424/" ]
I need my .net application to use the .html extension instead of .aspx I'm converting a php app and there are external applications which depend on that extension to function. What is the best way to do this? Thanks
In IIS, when you create the application for the virtual directory, click on "Configuration" for the application, and edit "App mappings", i.e. add a new mapping for html. Or, in your web.config, in add this sections: ``` <httpHandlers> <remove verb="*" path="*.html" /> <add verb="*" path="*.html" type="System.W...
240,393
<p>I have the following SQL-statement:</p> <pre><code>SELECT DISTINCT name FROM log WHERE NOT name = '' AND name LIKE '%.EDIT%'; </code></pre> <p>It works fine on Postgres (returns all different names from log, which aren't empty and contain the string '.EDIT'). But on Oracle this statement doesn't work. Any idea why...
[ { "answer_id": 240417, "author": "Erick B", "author_id": 1373, "author_profile": "https://Stackoverflow.com/users/1373", "pm_score": 2, "selected": false, "text": "<p>The empty string in Oracle is equivalent to NULL, causing the comparison to fail.\nChange that part of the query to NAME ...
2008/10/27
[ "https://Stackoverflow.com/questions/240393", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21005/" ]
I have the following SQL-statement: ``` SELECT DISTINCT name FROM log WHERE NOT name = '' AND name LIKE '%.EDIT%'; ``` It works fine on Postgres (returns all different names from log, which aren't empty and contain the string '.EDIT'). But on Oracle this statement doesn't work. Any idea why?
``` SELECT DISTINCT name FROM log WHERE NOT name = '' AND name LIKE '%.EDIT%'; ``` 1) Oracle treats '' as NULL, which means the comparison "NOT name = ''" is never true or false; use "IS NOT NULL" instead. But... 2) The second condition "name LIKE '%.EDIT%' will not match an empty string anyway, making the first con...
240,394
<p>In normal WebForms scenario, any root-relative URLs (e.g. ~/folder/file.txt) <strong>inside</strong> CSS files such as:</p> <pre><code>.form { background-image: url(~/Content/Images/form_bg.gif); } </code></pre> <p>will automatically get resolved during runtime if I specify</p> <pre><code>&lt;head runat="server"&...
[ { "answer_id": 240637, "author": "David Alpert", "author_id": 8997, "author_profile": "https://Stackoverflow.com/users/8997", "pm_score": 2, "selected": false, "text": "<p><a href=\"http://msdn.microsoft.com/en-us/library/aa719858(VS.71).aspx\" rel=\"nofollow noreferrer\">Here</a> <a hre...
2008/10/27
[ "https://Stackoverflow.com/questions/240394", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3055/" ]
In normal WebForms scenario, any root-relative URLs (e.g. ~/folder/file.txt) **inside** CSS files such as: ``` .form { background-image: url(~/Content/Images/form_bg.gif); } ``` will automatically get resolved during runtime if I specify ``` <head runat="server"> ``` In the referencing page. However, that is no ...
I would not bother with the auto-root-finding `~` character. I understand that you want the same solution to work where the root directory differs between deployments, but within the CSS document you shouldn't have any problems using relative paths. The paths in the CSS document (to the image URL in your example) will ...
240,419
<p>I've got a VB.NET class that is invoked with a context menu extension in Internet Explorer. </p> <p>The code has access to the object model of the page, and reading data is not a problem. This is the code of a test function...it changes the status bar text (OK), prints the page HTML (OK), changes the HTML by adding...
[ { "answer_id": 240435, "author": "S.Lott", "author_id": 10661, "author_profile": "https://Stackoverflow.com/users/10661", "pm_score": 1, "selected": false, "text": "<p>For this kind of thing you have separate Diagrams showing the internal structure or processing of a class.</p>\n\n<p>usu...
2008/10/27
[ "https://Stackoverflow.com/questions/240419", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22108/" ]
I've got a VB.NET class that is invoked with a context menu extension in Internet Explorer. The code has access to the object model of the page, and reading data is not a problem. This is the code of a test function...it changes the status bar text (OK), prints the page HTML (OK), changes the HTML by adding a text an...
Consider using a nesting relationship (a line with a '+' in a circle at the parent end).
240,425
<p>When I merge the trunk into a feature-branch, a delete that occurred on the trunk will not be replicated to my working copy.</p> <p>Why will a delete on trunk not delete the same file on a branch when merging? I'm using subversion 1.5 client and server.</p> <p>I'm assuming that changes to the file in the branch w...
[ { "answer_id": 242636, "author": "JXG", "author_id": 15456, "author_profile": "https://Stackoverflow.com/users/15456", "pm_score": 1, "selected": false, "text": "<p>To the best of my understanding, what you've done is create a local conflict in file1. In your branch, it was modified. I...
2008/10/27
[ "https://Stackoverflow.com/questions/240425", "https://Stackoverflow.com", "https://Stackoverflow.com/users/972/" ]
When I merge the trunk into a feature-branch, a delete that occurred on the trunk will not be replicated to my working copy. Why will a delete on trunk not delete the same file on a branch when merging? I'm using subversion 1.5 client and server. I'm assuming that changes to the file in the branch will be skipped wh...
To the best of my understanding, what you've done is create a local conflict in file1. In your branch, it was modified. In your trunk, it was deleted. When you merge, it will be in conflict. So the file will still be around. I suggest 2 tests: 1. After running the code above, include the results of `svn status`. 2. T...
240,467
<p>Of course, there are a whole range of possible errors relating to document validity, but my immediate stumbling block occurs when changing a paragraph (<code>p</code>) into an <code>address</code> element. My current method is (more-or-less):</p> <pre><code>var p = $('p#test'); p.replaceWith('&lt;address&gt;' + p.h...
[ { "answer_id": 240480, "author": "Ady", "author_id": 31395, "author_profile": "https://Stackoverflow.com/users/31395", "pm_score": 0, "selected": false, "text": "<p>You'll could use a placeholder around the title:</p>\n\n<pre>\n&lt;span id=\"demo\">&lt;h1>Title&lt;/h1>&lt;/span>\n</pre>\...
2008/10/27
[ "https://Stackoverflow.com/questions/240467", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5058/" ]
Of course, there are a whole range of possible errors relating to document validity, but my immediate stumbling block occurs when changing a paragraph (`p`) into an `address` element. My current method is (more-or-less): ``` var p = $('p#test'); p.replaceWith('<address>' + p.html() + '</address>'); ``` but that fail...
``` var p = $('p#test'); var a = $('<address>'). append(p.contents()); p.replaceWith(a); ``` Your solution is subject to all sorts of horrible HTML escaping issues and possibly injection attacks.
240,470
<p>I want to get user input in one page, store that in a php variable and use it in another php page. I have tried using 'sessions' but it doesn't seem to be working. Is there another safe alternative? This information is likely to be usernames and passwords.</p>
[ { "answer_id": 240489, "author": "ZombieSheep", "author_id": 377, "author_profile": "https://Stackoverflow.com/users/377", "pm_score": 3, "selected": false, "text": "<p>I Agree with carson, sessions should work for this. Make sure you are calling <a href=\"http://uk3.php.net/session_sta...
2008/10/27
[ "https://Stackoverflow.com/questions/240470", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24391/" ]
I want to get user input in one page, store that in a php variable and use it in another php page. I have tried using 'sessions' but it doesn't seem to be working. Is there another safe alternative? This information is likely to be usernames and passwords.
Try changing your session code as this is the best way to do this. For example: index.php --------- ``` <?php session_start(); if (isset($_POST['username'], $_POST['password']) { $_SESSION['username'] = $_POST['username']; $_SESSION['password'] = $_POST['password']; echo '<a href="nextpage.php">Click to...
240,510
<p>I have a string from an email header, like <code>Date: Mon, 27 Oct 2008 08:33:29 -0700</code>. What I need is an instance of GregorianCalendar, that will represent the same moment. As easy as that -- how do I do it?</p> <p>And for the fastest ones -- this is <strong>not</strong> going to work properly:</p> <pre><c...
[ { "answer_id": 240565, "author": "Jack Leow", "author_id": 31506, "author_profile": "https://Stackoverflow.com/users/31506", "pm_score": 5, "selected": true, "text": "<p>I'd recommend looking into the Joda Time library, if that's an option. I'm normally against using a third-party librar...
2008/10/27
[ "https://Stackoverflow.com/questions/240510", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3105/" ]
I have a string from an email header, like `Date: Mon, 27 Oct 2008 08:33:29 -0700`. What I need is an instance of GregorianCalendar, that will represent the same moment. As easy as that -- how do I do it? And for the fastest ones -- this is **not** going to work properly: ``` SimpleDateFormat format = ... // whatever...
I'd recommend looking into the Joda Time library, if that's an option. I'm normally against using a third-party library when the core platform provides similar functionality, but I made this an exception because the author of Joda Time is also behind JSR310, and Joda Time is basically going to be rolled into Java 7 eve...
240,531
<p>I have a weird date rounding problem that hopefully someone can solve. My client uses a work week that runs from Monday through Sunday. Sunday's date is considered the end of the week, and is used to identify all records entered in a particular week (so anything entered last week would have a WEEKDATE value of '10...
[ { "answer_id": 240560, "author": "James Curran", "author_id": 12725, "author_profile": "https://Stackoverflow.com/users/12725", "pm_score": 3, "selected": true, "text": "<pre><code>public DateTime WeekNum(DateTime now)\n{\n DateTime NewNow = now.AddHours(-11).AddDays(6);\n\n return...
2008/10/27
[ "https://Stackoverflow.com/questions/240531", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14606/" ]
I have a weird date rounding problem that hopefully someone can solve. My client uses a work week that runs from Monday through Sunday. Sunday's date is considered the end of the week, and is used to identify all records entered in a particular week (so anything entered last week would have a WEEKDATE value of '10/26/2...
``` public DateTime WeekNum(DateTime now) { DateTime NewNow = now.AddHours(-11).AddDays(6); return (NewNow.AddDays(- (int) NewNow.DayOfWeek).Date); } public void Code(params string[] args) { Console.WriteLine(WeekNum(DateTime.Now)); Console.WriteLine(WeekNum(new DateTime(2008,10,27, 10, 00, 00)));...
240,544
<p>I have the following rails migration:</p> <pre><code>create_table :articles do |t| t.integer :user_id, :allow_null =&gt; false t.integer :genre_id, :allow_null =&gt; false t.string :url, :limit =&gt; 255, :allow_null =&gt; false t.string :title, :limit =&gt; 60, :allow_null =&gt; false t.text :summary, :l...
[ { "answer_id": 240556, "author": "Daniel Spiewak", "author_id": 9815, "author_profile": "https://Stackoverflow.com/users/9815", "pm_score": 5, "selected": true, "text": "<p>Not much if you mean in terms of performance or storage efficiency. However, it's just good practice to push as ma...
2008/10/27
[ "https://Stackoverflow.com/questions/240544", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31810/" ]
I have the following rails migration: ``` create_table :articles do |t| t.integer :user_id, :allow_null => false t.integer :genre_id, :allow_null => false t.string :url, :limit => 255, :allow_null => false t.string :title, :limit => 60, :allow_null => false t.text :summary, :limit => 350, :allow_null => fals...
Not much if you mean in terms of performance or storage efficiency. However, it's just good practice to push as many of your low-level constraints into the database layer. For one thing, it guarantees that a subtle bug in Rails isn't going to lead to some randomly `NULL` data in a not-null field. Likewise, if you ever ...
240,546
<p>Is there a good way to remove HTML from a Java string? A simple regex like</p> <pre class="lang-js prettyprint-override"><code>replaceAll(&quot;\\&lt;.*?&gt;&quot;, &quot;&quot;) </code></pre> <p>will work, but some things like <code>&amp;amp;</code> won't be converted correctly and non-HTML between the two angle b...
[ { "answer_id": 240630, "author": "Chris Marasti-Georg", "author_id": 96, "author_profile": "https://Stackoverflow.com/users/96", "pm_score": 7, "selected": false, "text": "<p>If the user enters <code>&lt;b&gt;hey!&lt;/b&gt;</code>, do you want to display <code>&lt;b&gt;hey!&lt;/b&gt;</co...
2008/10/27
[ "https://Stackoverflow.com/questions/240546", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8973/" ]
Is there a good way to remove HTML from a Java string? A simple regex like ```js replaceAll("\\<.*?>", "") ``` will work, but some things like `&amp;` won't be converted correctly and non-HTML between the two angle brackets will be removed (i.e. the `.*?` in the regex will disappear).
Use a HTML parser instead of regex. This is dead simple with [Jsoup](http://jsoup.org). ``` public static String html2text(String html) { return Jsoup.parse(html).text(); } ``` Jsoup also [supports](https://jsoup.org/cookbook/cleaning-html/whitelist-sanitizer) removing HTML tags against a customizable whitelist,...
240,582
<p>I have tried the following two statements:</p> <ul> <li><code>SELECT col FROM db.tbl WHERE col (LIKE 'str1' OR LIKE 'str2') AND col2 = num</code> results in a syntax error</li> <li><code>SELECT col FROM db.tbl WHERE page LIKE ('str1' OR 'str2') AND col2 = num</code> results in "Truncated incorrect DOUBLE value: str...
[ { "answer_id": 240585, "author": "Tom Ritter", "author_id": 8435, "author_profile": "https://Stackoverflow.com/users/8435", "pm_score": 7, "selected": true, "text": "<blockquote>\n<pre><code>SELECT col FROM db.tbl WHERE (col LIKE 'str1' OR col LIKE 'str2') AND col2 = num\n</code></pre>\n...
2008/10/27
[ "https://Stackoverflow.com/questions/240582", "https://Stackoverflow.com", "https://Stackoverflow.com/users/572/" ]
I have tried the following two statements: * `SELECT col FROM db.tbl WHERE col (LIKE 'str1' OR LIKE 'str2') AND col2 = num` results in a syntax error * `SELECT col FROM db.tbl WHERE page LIKE ('str1' OR 'str2') AND col2 = num` results in "Truncated incorrect DOUBLE value: str1" and "Truncated incorrect DOUBLE value: s...
> > > ``` > SELECT col FROM db.tbl WHERE (col LIKE 'str1' OR col LIKE 'str2') AND col2 = num > > ``` > >
240,592
<p>I'm working on a fiddly web interface which is mostly built with JavaScript. Its basically one (very) large form with many sections. Each section is built based on options from other parts of the form. Whenever those options change the new values are noted in a "registry" type object and the other sections re-popula...
[ { "answer_id": 240663, "author": "Ken", "author_id": 20074, "author_profile": "https://Stackoverflow.com/users/20074", "pm_score": 2, "selected": false, "text": "<p>You could attach a listener to a container (the body or the form) and then use the event parameter to react to the change. ...
2008/10/27
[ "https://Stackoverflow.com/questions/240592", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30478/" ]
I'm working on a fiddly web interface which is mostly built with JavaScript. Its basically one (very) large form with many sections. Each section is built based on options from other parts of the form. Whenever those options change the new values are noted in a "registry" type object and the other sections re-populate ...
Thanks for the comments guys. I've gone with the following: ``` var EntriesRegistry = (function(){ var instance = null; function __constructor() { var self = this, observations = {}; this.set = function(n,v) { self[n] = v; if( observa...
240,648
<p>I am trying to do a search in my Eclipse (Java) workspace to find all instances of static variables that are not final.</p> <p>I tried various regexes but they do not result in any matches. Can someone suggest a regex that will match all lines containing <code>static</code> and not containing <code>final</code>, an...
[ { "answer_id": 240687, "author": "a2800276", "author_id": 27408, "author_profile": "https://Stackoverflow.com/users/27408", "pm_score": 2, "selected": false, "text": "<p>Eclipse should have some sort of Java search built-in where you could specify that... Else, instead of writing one lar...
2008/10/27
[ "https://Stackoverflow.com/questions/240648", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31837/" ]
I am trying to do a search in my Eclipse (Java) workspace to find all instances of static variables that are not final. I tried various regexes but they do not result in any matches. Can someone suggest a regex that will match all lines containing `static` and not containing `final`, and not ending in a `{`? The last...
This pattern works: ``` [^(final)] static [^(final)][^(\})]*$ ``` Here is a test: ``` $ cat test.txt private int x = "3"; private static x = "3"; private final static String x = "3"; private static final String x = "3"; private static String x = "3"; public static void main(String args[]) { blah; } $ grep ...
240,659
<p>I have a pretty generic Article model, with m2m relation to Tag model. I want to keep count of each tag usage, i think the best way would be to denormalise count field on Tag model and update it each time Article being saved. How can i accomplish this, or maybe there's a better way?</p>
[ { "answer_id": 241430, "author": "Jonny Buchanan", "author_id": 6760, "author_profile": "https://Stackoverflow.com/users/6760", "pm_score": 3, "selected": true, "text": "<p>You can do this by creating an <a href=\"http://docs.djangoproject.com/en/dev/topics/db/models/#extra-fields-on-man...
2008/10/27
[ "https://Stackoverflow.com/questions/240659", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7437/" ]
I have a pretty generic Article model, with m2m relation to Tag model. I want to keep count of each tag usage, i think the best way would be to denormalise count field on Tag model and update it each time Article being saved. How can i accomplish this, or maybe there's a better way?
You can do this by creating an [intermediate model](http://docs.djangoproject.com/en/dev/topics/db/models/#extra-fields-on-many-to-many-relationships) for the M2M relationship and use it as your hook for the `post_save` and `post_delete` signals to update the denormalised column in the `Article` table. For example, I ...
240,660
<p>I have an associative array in the form <code>key =&gt; value</code> where key is a numerical value, however it is not a sequential numerical value. The key is actually an ID number and the value is a count. This is fine for most instances, however I want a function that gets the human-readable name of the array and...
[ { "answer_id": 240673, "author": "Tom Ritter", "author_id": 8435, "author_profile": "https://Stackoverflow.com/users/8435", "pm_score": 4, "selected": false, "text": "<p>You could use a second associative array that maps human readable names to the id's. That would also provide a Many t...
2008/10/27
[ "https://Stackoverflow.com/questions/240660", "https://Stackoverflow.com", "https://Stackoverflow.com/users/572/" ]
I have an associative array in the form `key => value` where key is a numerical value, however it is not a sequential numerical value. The key is actually an ID number and the value is a count. This is fine for most instances, however I want a function that gets the human-readable name of the array and uses that for th...
``` $arr[$newkey] = $arr[$oldkey]; unset($arr[$oldkey]); ```
240,661
<p>Do you think changing directories inside bash or Perl scripts is acceptable? Or should one avoid doing this at all costs?</p> <p>What is the best practice for this issue?</p>
[ { "answer_id": 240675, "author": "Ovid", "author_id": 8003, "author_profile": "https://Stackoverflow.com/users/8003", "pm_score": 2, "selected": false, "text": "<p>I don't do this often, but sometimes it can save quite a bit of headache. Just be sure that if you change directories, you ...
2008/10/27
[ "https://Stackoverflow.com/questions/240661", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13523/" ]
Do you think changing directories inside bash or Perl scripts is acceptable? Or should one avoid doing this at all costs? What is the best practice for this issue?
The current working directory is local to the executing shell, so you can't affect the user unless he is "dotting" (running it in the current shell, as opposed to running it normally creating a new shell process) your script. A very good way of doing this is to use subshells, which i often do in aliases. ``` alias bu...
240,692
<p>I am trying to download an xml.gz file from a remote server with HttpsURLConnection in java, but I am getting an empty response. Here is a sample of my code:</p> <pre><code>URL server = new URL("https://www.myurl.com/path/sample_file.xml.gz"); HttpsURLConnection connection = (HttpsURLConnection)server.openConnecti...
[ { "answer_id": 240760, "author": "matt b", "author_id": 4249, "author_profile": "https://Stackoverflow.com/users/4249", "pm_score": 2, "selected": false, "text": "<p>Is any exception being logged? Is the website presenting a self-signed SSL certificate, or one that is not signed by a CA?...
2008/10/27
[ "https://Stackoverflow.com/questions/240692", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29752/" ]
I am trying to download an xml.gz file from a remote server with HttpsURLConnection in java, but I am getting an empty response. Here is a sample of my code: ``` URL server = new URL("https://www.myurl.com/path/sample_file.xml.gz"); HttpsURLConnection connection = (HttpsURLConnection)server.openConnection(); connectio...
Is any exception being logged? Is the website presenting a self-signed SSL certificate, or one that is not signed by a CA? There are several reasons why it might work fine in your browser (the browser might have been told to accept self-signed certs from that domain) and not in your code. What are the results of using...
240,704
<p>Does anyone have any suggestions for a good approach to finding all the CPAN dependencies that might have arisen in a bespoke development project. As tends to be the case your local development environment rarely matches your live one and as you build more and more projects you tend to build up a local library of in...
[ { "answer_id": 240723, "author": "Vagnerr", "author_id": 3720, "author_profile": "https://Stackoverflow.com/users/3720", "pm_score": 3, "selected": false, "text": "<p>In the past I have used <a href=\"http://search.cpan.org/dist/Devel-Modlist/\" rel=\"noreferrer\">Devel::Modlist</a> whic...
2008/10/27
[ "https://Stackoverflow.com/questions/240704", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3720/" ]
Does anyone have any suggestions for a good approach to finding all the CPAN dependencies that might have arisen in a bespoke development project. As tends to be the case your local development environment rarely matches your live one and as you build more and more projects you tend to build up a local library of insta...
I've had this problem myself. [Devel::Modlist](http://search.cpan.org/perldoc?Devel::Modlist) (as suggested by [this answer](https://stackoverflow.com/questions/240704/how-can-i-determine-cpan-dependencies-before-i-deploy-a-perl-project#240723)) takes a dynamic approach. It reports the modules that were actually loaded...
240,713
<p>I need to encrypt and decrypt a querystring in ASP.NET. </p> <p>The querystring might look something like this:</p> <blockquote> <p><a href="http://www.mysite.com/report.aspx?id=12345&amp;year=2008" rel="noreferrer">http://www.mysite.com/report.aspx?id=12345&amp;year=2008</a></p> </blockquote> <p>How do I go ab...
[ { "answer_id": 240730, "author": "swilliams", "author_id": 736, "author_profile": "https://Stackoverflow.com/users/736", "pm_score": 0, "selected": false, "text": "<p>I can't give you a turn key solution off the top of my head, but you should avoid TripleDES since it is <a href=\"http://...
2008/10/27
[ "https://Stackoverflow.com/questions/240713", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7072/" ]
I need to encrypt and decrypt a querystring in ASP.NET. The querystring might look something like this: > > <http://www.mysite.com/report.aspx?id=12345&year=2008> > > > How do I go about encrypting the entire querystring so that it looks something like the following? > > <http://www.mysite.com/report.aspx?cry...
Here is a way to do it in VB From: <http://www.devcity.net/Articles/47/1/encrypt_querystring.aspx> **Wrapper for the encryption code:** Pass your querystring parameters into this, and change the key!!! ``` Private _key as string = "!#$a54?3" Public Function encryptQueryString(ByVal strQueryString As String) As String...
240,719
<p>I'm running SQL Server 2000 and I need to export the SQL Statement from all the DTS objects so that they can be parsed and put into a wiki documentation if needed. </p> <p>Is there a way to do that?</p> <p>maybe dumping each DTS object out into a text file with the object name as the file name with the name of th...
[ { "answer_id": 240797, "author": "ConcernedOfTunbridgeWells", "author_id": 15401, "author_profile": "https://Stackoverflow.com/users/15401", "pm_score": 2, "selected": false, "text": "<p>There is an API with an object model for the DTS packages. You can get the SQL text through this. T...
2008/10/27
[ "https://Stackoverflow.com/questions/240719", "https://Stackoverflow.com", "https://Stackoverflow.com/users/730/" ]
I'm running SQL Server 2000 and I need to export the SQL Statement from all the DTS objects so that they can be parsed and put into a wiki documentation if needed. Is there a way to do that? maybe dumping each DTS object out into a text file with the object name as the file name with the name of the process and the ...
I have a [Python 2.6](http://www.python.org/) script (easily portable to Python 2.5) that dumps the SQL from the tasks in a DTS package that has been saved as Visual Basic code. Refer to ConcernedOfTunbridgeWells' post to find out how to save the DTS package to a VB file. After you save a VB file, run this function on...
240,721
<p>Has anyone used jQuery to populate an autocomplete list on a textbox using ASP.NET webforms? If so, can anyone recommend a good method? From my reading so far, it seems like most people are using delimited lists rather than JSON to bring the items back. I'm open to any ideas that will get me up and running rather qu...
[ { "answer_id": 240882, "author": "Pablo", "author_id": 22696, "author_profile": "https://Stackoverflow.com/users/22696", "pm_score": 2, "selected": true, "text": "<p>There are many, many examples on the web. I've used this one before, and if I recall you only need to create an aspx that ...
2008/10/27
[ "https://Stackoverflow.com/questions/240721", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1284/" ]
Has anyone used jQuery to populate an autocomplete list on a textbox using ASP.NET webforms? If so, can anyone recommend a good method? From my reading so far, it seems like most people are using delimited lists rather than JSON to bring the items back. I'm open to any ideas that will get me up and running rather quick...
There are many, many examples on the web. I've used this one before, and if I recall you only need to create an aspx that will return matching terms as a `<BR/>` separated list: <http://www.dyve.net/jquery/?autocomplete> The documentation shows php in the example, but there's no difference in the way the plugin itsel...
240,725
<p>I have OS X 10.5 set up with the precompiled versions of PHP 5 and Apache 2. I'm trying to set up the Zend Debugger, but with no luck. Here's what I did:</p> <ul> <li>I downloaded <code>ZendDebugger-5.2.14-darwin8.6-uni.tar</code></li> <li>I created the directory <code>/Developer/Extras/PHP</code> and set the per...
[ { "answer_id": 240830, "author": "Barrett Conrad", "author_id": 1227, "author_profile": "https://Stackoverflow.com/users/1227", "pm_score": 3, "selected": true, "text": "<p>If I remember correctly, this problem is do to the fact that the Zend Debugger is compiled for 32-bit Apache while ...
2008/10/27
[ "https://Stackoverflow.com/questions/240725", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12549/" ]
I have OS X 10.5 set up with the precompiled versions of PHP 5 and Apache 2. I'm trying to set up the Zend Debugger, but with no luck. Here's what I did: * I downloaded `ZendDebugger-5.2.14-darwin8.6-uni.tar` * I created the directory `/Developer/Extras/PHP` and set the permissions to: + Permissions: `drwxrwxr-x` + ...
If I remember correctly, this problem is do to the fact that the Zend Debugger is compiled for 32-bit Apache while the Apache that comes with Max OS 10.5 is compiled as 64-bit application. Until Zend comes out with a 64-bit version, you have two options: 1) [Restart Apache manually into 32-bit](http://www.entropy.ch/...
240,755
<p>I have to create the sin function from scratch in my Comp Sci class, and I am getting close to a solution. However, I am still having a few problems. If I put in a value of .5PI or less it works, but otherwise I get the incorrect result. Here is the code I have so far:</p> <pre><code>double i=1; double sinSoFar = 0...
[ { "answer_id": 240831, "author": "Federico A. Ramponi", "author_id": 18770, "author_profile": "https://Stackoverflow.com/users/18770", "pm_score": 2, "selected": false, "text": "<p>Some advices:</p>\n\n<ul>\n<li>Start with term = 0. The canonical MacLaurin expansion also does</li>\n<li>c...
2008/10/27
[ "https://Stackoverflow.com/questions/240755", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31665/" ]
I have to create the sin function from scratch in my Comp Sci class, and I am getting close to a solution. However, I am still having a few problems. If I put in a value of .5PI or less it works, but otherwise I get the incorrect result. Here is the code I have so far: ``` double i=1; double sinSoFar = 0; int term = 1...
Like Federico pointed, the problem probably is in your factorial() or pow(). I ran a test that worked fine replacing your functions with the pow() function provided in the Math class, and this factorial(): ``` public static long factorial(long n) { if (n < 0) throw new RuntimeException("Underflow error i...
240,764
<p>I have seen some websites use the following tag:</p> <pre><code>&lt;meta type="title" content="Title of the page" /&gt; </code></pre> <p>Is it needed when you have a <code>&lt;title&gt;</code>?</p> <p>Also, what's the best formatting for a page title? Some ideas:</p> <ul> <li>Page Description :: Company Name</li...
[ { "answer_id": 240867, "author": "Leandro López", "author_id": 22695, "author_profile": "https://Stackoverflow.com/users/22695", "pm_score": 2, "selected": false, "text": "<p>Search engines often ignore meta tags as in the past they where used for spamming purposes. The best tag for titl...
2008/10/27
[ "https://Stackoverflow.com/questions/240764", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5441/" ]
I have seen some websites use the following tag: ``` <meta type="title" content="Title of the page" /> ``` Is it needed when you have a `<title>`? Also, what's the best formatting for a page title? Some ideas: * Page Description :: Company Name * Page Description - Company Name * Page Description <> Company Name *...
The `<meta type="title">` tag has little rank or relevance to search engine crawlers. The good old `<title>` tag is far and away the [most important element of a good web page](http://www.w3.org/QA/Tips/good-titles). As for the format of the title, I think there is good advice in [this article at Standards Schmandards...