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
280,834
<p>I would like to know if it is possible, to select certain columns from one table, and another column from a second table, which would relate to a non imported column in the first table. I have to obtain this data from access, and do not know if this is possible with Access, or SQL in general.</p>
[ { "answer_id": 280844, "author": "okoman", "author_id": 35903, "author_profile": "https://Stackoverflow.com/users/35903", "pm_score": 2, "selected": false, "text": "<p>What you are looking for are JOINs:</p>\n\n<p><a href=\"http://en.wikipedia.org/wiki/Join_(SQL)\" rel=\"nofollow norefer...
2008/11/11
[ "https://Stackoverflow.com/questions/280834", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1246613/" ]
I would like to know if it is possible, to select certain columns from one table, and another column from a second table, which would relate to a non imported column in the first table. I have to obtain this data from access, and do not know if this is possible with Access, or SQL in general.
Assuming the following table structure: ``` CREATE TABLE tbl_1 ( pk_1 int, field_1 varchar(25), field_2 varchar(25) ); CREATE TABLE tbl_2 ( pk_2 int, fk_1 int, field_3 varchar(25), field_4 varchar(25) ); ``` You could use the following: ``` SELECT t1.field_1, t2.field_3 FROM tbl_1 t1 IN...
280,846
<p><strong>Mark Up</strong></p> <pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test.aspx.cs" Inherits="Zuhaib.test" %&gt; &lt;!-- Put IE into quirks mode --&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; &lt;html xmln...
[ { "answer_id": 280933, "author": "postback", "author_id": 32849, "author_profile": "https://Stackoverflow.com/users/32849", "pm_score": 2, "selected": false, "text": "<p>Remove the comment on top of the page\nThe \"Put IE into quirks mode\" thing</p>\n\n<p>You are using a lot of 'hacks'....
2008/11/11
[ "https://Stackoverflow.com/questions/280846", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25138/" ]
**Mark Up** ``` <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test.aspx.cs" Inherits="Zuhaib.test" %> <!-- Put IE into quirks mode --> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> ...
As already said, your code is full of hacks. Please remove especially the unnecessary definitions. If a browser does not support *cascading* style sheets, it will not support CSS anyway. That being said, why not use position: absolute; for #right? As in ``` #right{ position: absolute; left: 100px; padding-left...
280,864
<p>Does anyone know of an open source web service/wcf service that can stream media content to clients? In particular I am looking for something that could access my music collection and stream it to a client (could be a client browser, win mobile app or even iphone application).</p> <p>I guess it would have to be WCF...
[ { "answer_id": 280933, "author": "postback", "author_id": 32849, "author_profile": "https://Stackoverflow.com/users/32849", "pm_score": 2, "selected": false, "text": "<p>Remove the comment on top of the page\nThe \"Put IE into quirks mode\" thing</p>\n\n<p>You are using a lot of 'hacks'....
2008/11/11
[ "https://Stackoverflow.com/questions/280864", "https://Stackoverflow.com", "https://Stackoverflow.com/users/445/" ]
Does anyone know of an open source web service/wcf service that can stream media content to clients? In particular I am looking for something that could access my music collection and stream it to a client (could be a client browser, win mobile app or even iphone application). I guess it would have to be WCF based as ...
As already said, your code is full of hacks. Please remove especially the unnecessary definitions. If a browser does not support *cascading* style sheets, it will not support CSS anyway. That being said, why not use position: absolute; for #right? As in ``` #right{ position: absolute; left: 100px; padding-left...
280,872
<p>I'm trying to write a <a href="/questions/tagged/vba" class="post-tag" title="show questions tagged &#39;vba&#39;" rel="tag">vba</a> macro for a group tha</p> <ul> <li>has one workbook where they daily create new worksheets, and also have</li> <li><em>Sheet 1</em>, <em>Sheet 2</em> and <em>Sheet 3</em> at the end o...
[ { "answer_id": 280979, "author": "dbb", "author_id": 25675, "author_profile": "https://Stackoverflow.com/users/25675", "pm_score": 4, "selected": true, "text": "<p>This function works through the sheets from right to left until it finds a non-blank sheet, and returns its name</p>\n\n<pre...
2008/11/11
[ "https://Stackoverflow.com/questions/280872", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26140/" ]
I'm trying to write a [vba](/questions/tagged/vba "show questions tagged 'vba'") macro for a group tha * has one workbook where they daily create new worksheets, and also have * *Sheet 1*, *Sheet 2* and *Sheet 3* at the end of their long list of sheets. I need to create a external cell reference in a new column in a ...
This function works through the sheets from right to left until it finds a non-blank sheet, and returns its name ``` Function GetLastNonEmptySheetName() As String Dim i As Long For i = Worksheets.Count To 1 Step -1 If Sheets(i).UsedRange.Cells.Count > 1 Then GetLastNonEmptySheetName = Sheets(i).Name Exit Fun...
280,879
<p>In some existing code there is a test to see if the user is running IE, by checking if the object Browser.Engine.trident is defined and returns true.</p> <p>But how can I determine if the user is running IE6 (or earlier) or IE7 (or later)?</p> <p>The test is needed inside a JavaScript function so a conditional com...
[ { "answer_id": 280886, "author": "Nick Berardi", "author_id": 17, "author_profile": "https://Stackoverflow.com/users/17", "pm_score": 2, "selected": false, "text": "<p>If you are already using jQuery in a pre-1.9 version AND you don't need to detect IE 11, you can do this:</p>\n\n<pre><c...
2008/11/11
[ "https://Stackoverflow.com/questions/280879", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
In some existing code there is a test to see if the user is running IE, by checking if the object Browser.Engine.trident is defined and returns true. But how can I determine if the user is running IE6 (or earlier) or IE7 (or later)? The test is needed inside a JavaScript function so a conditional comment doesn't seem...
From [detecting Internet Explorer More Effectively](http://msdn.microsoft.com/en-us/library/ms537509.aspx) at msdn: ``` function getInternetExplorerVersion() // Returns the version of Internet Explorer or a -1 // (indicating the use of another browser). { var rv = -1; // Return value assumes failure. if (navigator...
280,891
<p>I've decided to reimplement the datetime picker, as a standard datetime picker isn't nullable. The user wants to start with a blank field and type (not select) the date.</p> <p>I've created a user control to do just that, but if the user control is near the edge of the form, it will be cut off on the form boundry. ...
[ { "answer_id": 280905, "author": "Tigraine", "author_id": 21699, "author_profile": "https://Stackoverflow.com/users/21699", "pm_score": 2, "selected": false, "text": "<p>The screenshots looks like a Windows Forms applications, so my answer is for winforms.</p>\n\n<p>I guess the best solu...
2008/11/11
[ "https://Stackoverflow.com/questions/280891", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29830/" ]
I've decided to reimplement the datetime picker, as a standard datetime picker isn't nullable. The user wants to start with a blank field and type (not select) the date. I've created a user control to do just that, but if the user control is near the edge of the form, it will be cut off on the form boundry. The standa...
The ToolStripDropDown control has this functionallity so by inheriting from it we can make a simple PopupWindow. ``` /// <summary> /// A simple popup window that can host any System.Windows.Forms.Control /// </summary> public class PopupWindow : System.Windows.Forms.ToolStripDropDown { private System.Windows.Forms...
280,892
<p>I'm looking to write a small proxy server for kicks and giggles.</p> <p>Apart from the options in libWWW, can anyone recommend any opensource options for the HTTP server and client code? Thinking of a library of some kind similar to libWWW.</p> <p>Chosen language is C/C++ but open to Java, C#, Python... etc. :-)</...
[ { "answer_id": 280905, "author": "Tigraine", "author_id": 21699, "author_profile": "https://Stackoverflow.com/users/21699", "pm_score": 2, "selected": false, "text": "<p>The screenshots looks like a Windows Forms applications, so my answer is for winforms.</p>\n\n<p>I guess the best solu...
2008/11/11
[ "https://Stackoverflow.com/questions/280892", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm looking to write a small proxy server for kicks and giggles. Apart from the options in libWWW, can anyone recommend any opensource options for the HTTP server and client code? Thinking of a library of some kind similar to libWWW. Chosen language is C/C++ but open to Java, C#, Python... etc. :-)
The ToolStripDropDown control has this functionallity so by inheriting from it we can make a simple PopupWindow. ``` /// <summary> /// A simple popup window that can host any System.Windows.Forms.Control /// </summary> public class PopupWindow : System.Windows.Forms.ToolStripDropDown { private System.Windows.Forms...
280,894
<p>I have an access database, with a query made. I need to automate it so that each night this query can run and export to a tab delimited csv file. It is not possible to export a query to a csv file from within access. My question is, are there any tools that can select certain tables, or perform an sql query on an md...
[ { "answer_id": 280900, "author": "Fionnuala", "author_id": 2548, "author_profile": "https://Stackoverflow.com/users/2548", "pm_score": 2, "selected": false, "text": "<p>VBScript works quite well with the Jet engine. However, I do not see why you say \" It is not possible to export a quer...
2008/11/11
[ "https://Stackoverflow.com/questions/280894", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1246613/" ]
I have an access database, with a query made. I need to automate it so that each night this query can run and export to a tab delimited csv file. It is not possible to export a query to a csv file from within access. My question is, are there any tools that can select certain tables, or perform an sql query on an mdb f...
Actually, you can export a query to a csv file from within Access. You can do this with a Macro using the TransferText method. Macro: ``` Name = ExportQuery Action = TransferText Transfer Type = Export Delimited Table Name = [name of your Access query] File Name = [path of output file] Has Field Na...
280,904
<p>I hope this is a simple enough question for any SQL people out there...</p> <p>We have a table which hold system configuration data, and this is tied to a history table via triggers so we can track who changed what, and when. </p> <p>I have a requirement to add another value in to this table, but it is one that w...
[ { "answer_id": 280956, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 7, "selected": true, "text": "<p>Given that a WHERE clause did not work, maybe this will:</p>\n\n<pre><code>CREATE TRIGGER \n [dbo].[SystemParamet...
2008/11/11
[ "https://Stackoverflow.com/questions/280904", "https://Stackoverflow.com", "https://Stackoverflow.com/users/377/" ]
I hope this is a simple enough question for any SQL people out there... We have a table which hold system configuration data, and this is tied to a history table via triggers so we can track who changed what, and when. I have a requirement to add another value in to this table, but it is one that will change frequen...
Given that a WHERE clause did not work, maybe this will: ``` CREATE TRIGGER [dbo].[SystemParameterInsertUpdate] ON [dbo].[SystemParameter] FOR INSERT, UPDATE AS BEGIN SET NOCOUNT ON If (SELECT Attribute FROM INSERTED) LIKE 'NoHist_%' Begin Return End INSERT INTO Sys...
280,909
<p>Is there a programmatic method to set CPU affinity for a process in c/c++ for the Linux operating system?</p>
[ { "answer_id": 280924, "author": "Alnitak", "author_id": 6782, "author_profile": "https://Stackoverflow.com/users/6782", "pm_score": 7, "selected": true, "text": "<p>You need to use <a href=\"http://linux.die.net/man/2/sched_setaffinity\" rel=\"noreferrer\"><code>sched_setaffinity(2)</co...
2008/11/11
[ "https://Stackoverflow.com/questions/280909", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7362/" ]
Is there a programmatic method to set CPU affinity for a process in c/c++ for the Linux operating system?
You need to use [`sched_setaffinity(2)`](http://linux.die.net/man/2/sched_setaffinity). For example, to run on CPUs 0 and 2 only: ``` #define _GNU_SOURCE #include <sched.h> cpu_set_t mask; CPU_ZERO(&mask); CPU_SET(0, &mask); CPU_SET(2, &mask); int result = sched_setaffinity(0, sizeof(mask), &mask); ``` (`0` for t...
280,940
<p>I am programming in C against a third party library (in HP/Mercury Loadrunner) that allows a varargs-style variable size argument list for one of it's functions. I want to call this function but I do not know up front how many arguments I will have. </p> <p>There is a function made by one of my predecessors that se...
[ { "answer_id": 280993, "author": "Robert Gamble", "author_id": 25222, "author_profile": "https://Stackoverflow.com/users/25222", "pm_score": 2, "selected": false, "text": "<p>There is no portable way to build up an argument list for a variable argument function in C at run time. There a...
2008/11/11
[ "https://Stackoverflow.com/questions/280940", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36574/" ]
I am programming in C against a third party library (in HP/Mercury Loadrunner) that allows a varargs-style variable size argument list for one of it's functions. I want to call this function but I do not know up front how many arguments I will have. There is a function made by one of my predecessors that serves somew...
In CamelBones I use [libffi](http://sourceware.org/libffi/) to call objc\_msgSend(), which is a varargs function. Works a treat.
280,948
<p>I am setting-up my DataGridView like this:</p> <pre><code> jobs = new List&lt;DisplayJob&gt;(); uxJobList.AutoGenerateColumns = false; jobListBindingSource.DataSource = jobs; uxJobList.DataSource = jobListBindingSource; int newColumn; newColumn = uxJobList.Columns.Ad...
[ { "answer_id": 280958, "author": "Bruno Shine", "author_id": 28294, "author_profile": "https://Stackoverflow.com/users/28294", "pm_score": 1, "selected": false, "text": "<p>I believe that your class must implement the <code>IComparable</code> interface.</p>\n\n<p>Hope it helps,</p>\n\n<p...
2008/11/11
[ "https://Stackoverflow.com/questions/280948", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18349/" ]
I am setting-up my DataGridView like this: ``` jobs = new List<DisplayJob>(); uxJobList.AutoGenerateColumns = false; jobListBindingSource.DataSource = jobs; uxJobList.DataSource = jobListBindingSource; int newColumn; newColumn = uxJobList.Columns.Add("Id", "Job No."); ...
If you want to support sorting and searching on the collection, all **it takes it to derive a class from your BindingList parameterized type**, and override a few base class methods and properties. The best way is to extend the BindingList and do those following things: ``` protected override bool SupportsSearchingCo...
280,953
<p>Could anyboby help me with the alternative solution in C# regarding <strong>AddressOf operator in VB6</strong>? AddressOf returns a long value. What way can I get the output in C#?</p>
[ { "answer_id": 280959, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 3, "selected": false, "text": "<p>C# has special syntax for assigning functions to delegates/events. Just use <code>&lt;delegate&gt; += &lt;function...
2008/11/11
[ "https://Stackoverflow.com/questions/280953", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Could anyboby help me with the alternative solution in C# regarding **AddressOf operator in VB6**? AddressOf returns a long value. What way can I get the output in C#?
Expanding on Harper Shelby's answer, yes it can be done, but it's generally a code smell to do so in .NET. To get the address of a variable in C#, you can use C-style pointer (\*) /address (&) / dereference (->) syntax. In order to do this, you will have to compile the app with the /unsafe compiler switch, as you're b...
280,969
<p>I need to grab the folder name of a currently executing batch file. I have been trying to loop over the current directory using the following syntax (which is wrong at present):</p> <pre><code>set mydir = %~p0 for /F "delims=\" %i IN (%mydir%) DO @echo %i </code></pre> <p>Couple of issues in that I cannot seem to ...
[ { "answer_id": 281001, "author": "kenny", "author_id": 3225, "author_profile": "https://Stackoverflow.com/users/3225", "pm_score": 0, "selected": false, "text": "<p>In batch files in the FOR command you'll need to prepend %whatever with an extra % (e.g. %%whatever).\n<br><br>\n'echo %~p0...
2008/11/11
[ "https://Stackoverflow.com/questions/280969", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31412/" ]
I need to grab the folder name of a currently executing batch file. I have been trying to loop over the current directory using the following syntax (which is wrong at present): ``` set mydir = %~p0 for /F "delims=\" %i IN (%mydir%) DO @echo %i ``` Couple of issues in that I cannot seem to pass the 'mydir' variable ...
You were pretty close to it :) This should work: ``` @echo OFF set mydir="%~p0" SET mydir=%mydir:\=;% for /F "tokens=* delims=;" %%i IN (%mydir%) DO call :LAST_FOLDER %%i goto :EOF :LAST_FOLDER if "%1"=="" ( @echo %LAST% goto :EOF ) set LAST=%1 SHIFT goto :LAST_FOLDER ``` For some reason the for command ...
280,971
<p>Within my InfoPath form (which has to be loaded within a SharePoint Portal by the browser)I have a repeating table containing multiple fields. Now I would like to make the first textfield autoincrement starting by 1. How exactly can I do this?</p> <p>I have already heard of a way by using the "count" function but t...
[ { "answer_id": 281227, "author": "Alex", "author_id": 35999, "author_profile": "https://Stackoverflow.com/users/35999", "pm_score": 2, "selected": true, "text": "<p>Let's say your repeating group is called \"item\" and your autoincrement field is called \"index\". The default value of th...
2008/11/11
[ "https://Stackoverflow.com/questions/280971", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25428/" ]
Within my InfoPath form (which has to be loaded within a SharePoint Portal by the browser)I have a repeating table containing multiple fields. Now I would like to make the first textfield autoincrement starting by 1. How exactly can I do this? I have already heard of a way by using the "count" function but this produc...
Let's say your repeating group is called "item" and your autoincrement field is called "index". The default value of the index field should be ``` count(/my:myFields/my:item) ``` This should count correctly for you.
280,990
<p>I have a snippet looking something like the below.</p> <pre><code>string bodyTypeAssemblyQualifiedName = "XXX.XX.XI.CustomerPayment.Schemas.r1.CustomerPayments_v01, XXX.XX.XI.CustomerPaym" + "ent.Schemas.r1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ac564f277cd4488" + "e"; </c...
[ { "answer_id": 281014, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 0, "selected": false, "text": "<p>You can try</p>\n\n<pre><code>bodyTypeAssemblyQualifiedName\\s=\\s(?&lt;location&gt;[.\\n]*?);\n</code></pre>\n\n<p>Or ...
2008/11/11
[ "https://Stackoverflow.com/questions/280990", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a snippet looking something like the below. ``` string bodyTypeAssemblyQualifiedName = "XXX.XX.XI.CustomerPayment.Schemas.r1.CustomerPayments_v01, XXX.XX.XI.CustomerPaym" + "ent.Schemas.r1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ac564f277cd4488" + "e"; ``` I'd like us...
This works: > > (?<=string\sbodyTypeAssemblyQualifiedName\s=\s)(?s:[^;]\*)(?=;) > > > Which is the equivalent of: 1. After the string "string bodyTypeAssemblyQualifiedName = " 2. Turn on single line (treat \r\n as any other character) ( this is what (?s: ) does) 3. match every character that is not a semicolon 4...
281,015
<p>Hi would like to send an email alert after checking the result of a query which will return the numbers of rows in a table. Does anyone have any ideas how I could do this in SQL Server 2000 in 2005 I would use a maintenence plan but not sure how in 2000?</p>
[ { "answer_id": 281026, "author": "Cade Roux", "author_id": 18255, "author_profile": "https://Stackoverflow.com/users/18255", "pm_score": 0, "selected": false, "text": "<p>Because SQLMail is so useless for real world usage (MAPI, etc), we ended up using <a href=\"http://www.sqlanswers.com...
2008/11/11
[ "https://Stackoverflow.com/questions/281015", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Hi would like to send an email alert after checking the result of a query which will return the numbers of rows in a table. Does anyone have any ideas how I could do this in SQL Server 2000 in 2005 I would use a maintenence plan but not sure how in 2000?
I did this a few years ago - hastily adapted from a MS Knowledgebase article. I changed the params to be hardcoded variables. I've removed the identifying servernames/email addresses etc etc from here but you should be able to figure it out! CREATE PROCEDURE [dbo].[usp\_SendSuccessMail] --Adapted from a Microsoft Know...
281,017
<p>(Warning - asp newbie) I have an aspx file with the tag</p> <pre><code> &lt;%@ Page Language=VB ... %&gt; </code></pre> <p>right at the beginning of the file.</p> <p>When calling this from my IIS server (<a href="http://localhost/myservice/default.aspx" rel="noreferrer">http://localhost/myservice/default.aspx...
[ { "answer_id": 281039, "author": "Daan", "author_id": 7922, "author_profile": "https://Stackoverflow.com/users/7922", "pm_score": 4, "selected": true, "text": "<p>It appears as if the browser tries to display what it thinks is an XML file, since it gives an error on the second character ...
2008/11/11
[ "https://Stackoverflow.com/questions/281017", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6583/" ]
(Warning - asp newbie) I have an aspx file with the tag ``` <%@ Page Language=VB ... %> ``` right at the beginning of the file. When calling this from my IIS server (<http://localhost/myservice/default.aspx>), this gives me the error > > This page contains the following > errors: > > > error on line 1 a...
It appears as if the browser tries to display what it thinks is an XML file, since it gives an error on the second character of the first line. So I think the file is not parsed, but simply returned as is immediately. Check if your IIS server is configured correctly and that it actually parses your ASP tags before retu...
281,020
<p>I want to call some RESTful web services from a J2ME client running on a MIDP enabled mobile device. I read the MIDP api for HTTPConnections and thought this is just crying out for a simple wrapper to hide all those unpleasant byte arrays and such like. Before I write my own I wondered whether there was a good open ...
[ { "answer_id": 284676, "author": "rupello", "author_id": 635, "author_profile": "https://Stackoverflow.com/users/635", "pm_score": 0, "selected": false, "text": "<p>I don't know of any such library, but found some <a href=\"http://mobile-j2me.blogspot.com/\" rel=\"nofollow noreferrer\">s...
2008/11/11
[ "https://Stackoverflow.com/questions/281020", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32747/" ]
I want to call some RESTful web services from a J2ME client running on a MIDP enabled mobile device. I read the MIDP api for HTTPConnections and thought this is just crying out for a simple wrapper to hide all those unpleasant byte arrays and such like. Before I write my own I wondered whether there was a good open sou...
You might want to check out this little gem, Mobile Ajax for Java ME: <https://meapplicationdevelopers.java.net/mobileajax.html> One part is (from the site): > > Asynchronous I/O for Java ME > > > This library provides the equivalent > of XmlHttpRequest for Java ME with > some additional functionality useful > ...
281,041
<p>I am not that hot at regular expressions and it has made my little mind melt some what.</p> <p>I am trying to find all the tables names in a query. So say I have the query:</p> <pre><code>SELECT one, two, three FROM table1, table2 WHERE X=Y </code></pre> <p>I would like to pull out "table1, table2" or "table1" a...
[ { "answer_id": 281053, "author": "LeppyR64", "author_id": 16592, "author_profile": "https://Stackoverflow.com/users/16592", "pm_score": 1, "selected": false, "text": "<p>It's definitely not easy.</p>\n\n<p>Consider subqueries.</p>\n\n<pre><code>select\n *\nfrom\n A\n join (\n selec...
2008/11/11
[ "https://Stackoverflow.com/questions/281041", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6486/" ]
I am not that hot at regular expressions and it has made my little mind melt some what. I am trying to find all the tables names in a query. So say I have the query: ``` SELECT one, two, three FROM table1, table2 WHERE X=Y ``` I would like to pull out "table1, table2" or "table1" and "table2" But what if there is ...
RegEx isn't very good at this, as it's a lot more complicated than it appears: * What if they use LEFT/RIGHT INNER/OUTER/CROSS/MERGE/NATURAL joins instead of the a,b syntax? The a,b syntax should be avoided anyway. * What about nested queries? * What if there is no table (selecting a constant) * What about line breaks...
281,045
<p>This is a question that was sparked by <a href="https://stackoverflow.com/users/3631/rob-walker">Rob Walker</a>'s answer <a href="https://stackoverflow.com/questions/36455/alignment-restrictions-for-mallocfree#36466">here</a>.</p> <p>Suppose I declare a class/struct like so:</p> <pre><code>struct { char A; ...
[ { "answer_id": 281064, "author": "Chris Young", "author_id": 9417, "author_profile": "https://Stackoverflow.com/users/9417", "pm_score": 2, "selected": false, "text": "<p>I cannot speak for C++, but in C the order is guaranteed to be the same order in memory as declared in the struct.</p...
2008/11/11
[ "https://Stackoverflow.com/questions/281045", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2147/" ]
This is a question that was sparked by [Rob Walker](https://stackoverflow.com/users/3631/rob-walker)'s answer [here](https://stackoverflow.com/questions/36455/alignment-restrictions-for-mallocfree#36466). Suppose I declare a class/struct like so: ``` struct { char A; int B; char C; int D; }; ``` Is...
C99 §6.7.2.1 clause 13 states: > > Within a structure object, the > non-bit-field members and the units in > which bit-fields reside have addresses > that increase in the order in which > they are declared. > > > and goes on to say a bit more about padding and addresses. The C89 equivalent section is §6.5.2.1. ...
281,060
<p>I'm trying to read the data in a Win32 ListView owned by another process. Unfortunately, my WriteProcessMemory() call fails with the error "This function is not supported on this system." when I specify "NULL" for the base address in my VirtualAlloc() call. If, however, I offset that VirtualAlloc() address by some "...
[ { "answer_id": 281141, "author": "Rob Walker", "author_id": 3631, "author_profile": "https://Stackoverflow.com/users/3631", "pm_score": 2, "selected": false, "text": "<p>VirtualAlloc allocates memory in <strong>YOUR</strong> address space. It is absolutely not valid to use that address ...
2008/11/11
[ "https://Stackoverflow.com/questions/281060", "https://Stackoverflow.com", "https://Stackoverflow.com/users/57185/" ]
I'm trying to read the data in a Win32 ListView owned by another process. Unfortunately, my WriteProcessMemory() call fails with the error "This function is not supported on this system." when I specify "NULL" for the base address in my VirtualAlloc() call. If, however, I offset that VirtualAlloc() address by some "mag...
Instead of trying to allocate memory in another process, why not use named shared memory instead. This article will take you through the basic setup of [shared memory](http://msdn.microsoft.com/en-us/library/aa366551(VS.85).aspx), and I did a quick check to make sure these functions are supported by [Windows Mobile 5](...
281,108
<p>I have a compiled AppleScript application which I have moved to my windows server. I'd like to then insert a text file into the application (which looks like a zip file on windows):</p> <pre><code>myapplescript.app/Contents/Resources/MyNewDir/MyTxtFile.txt </code></pre> <p>So, I've precompiled the AppleScript to t...
[ { "answer_id": 284311, "author": "Mike Blandford", "author_id": 28643, "author_profile": "https://Stackoverflow.com/users/28643", "pm_score": 3, "selected": true, "text": "<p>Ok, I figured it out, I changed the second line to this:</p>\n\n<pre><code>set theFile to (POSIX file (theFolder ...
2008/11/11
[ "https://Stackoverflow.com/questions/281108", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28643/" ]
I have a compiled AppleScript application which I have moved to my windows server. I'd like to then insert a text file into the application (which looks like a zip file on windows): ``` myapplescript.app/Contents/Resources/MyNewDir/MyTxtFile.txt ``` So, I've precompiled the AppleScript to try to read from this text ...
Ok, I figured it out, I changed the second line to this: ``` set theFile to (POSIX file (theFolder & "Contents/Resources/MyNewDir/MyTxtFile.txt")) ```
281,111
<p>How do I replace text from one file with text from another file using vbscript?</p> <p>The text being replaced is somewhere in the middle of the file. </p>
[ { "answer_id": 281138, "author": "Svante Svenson", "author_id": 19707, "author_profile": "https://Stackoverflow.com/users/19707", "pm_score": 2, "selected": false, "text": "<p>filea.txt:\nhello cruel world</p>\n\n<p>fileb.txt:\ncruel</p>\n\n<p>filec.txt:\nhappy</p>\n\n<p>will make sResul...
2008/11/11
[ "https://Stackoverflow.com/questions/281111", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How do I replace text from one file with text from another file using vbscript? The text being replaced is somewhere in the middle of the file.
filea.txt: hello cruel world fileb.txt: cruel filec.txt: happy will make sResult = "hello happy world" after the following has executed. ``` Dim oFSO Dim sFileAContents Dim sFileBContents Dim sFileCContents Dim sResult Set oFSO = CreateObject("Scripting.FileSystemObject") sFileAContents = oFSO.OpenTextFile("c:\file...
281,119
<p>Has anyone written a version of .Net's generic Queue that implements INotifyCollectionChanged, or is there one hidden deep in the .Net framework somewhere already?</p>
[ { "answer_id": 281148, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": true, "text": "<p>A quick search didn't show any results. But the interface is simple and it would be almost trivial to extend the Queue clas...
2008/11/11
[ "https://Stackoverflow.com/questions/281119", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5548/" ]
Has anyone written a version of .Net's generic Queue that implements INotifyCollectionChanged, or is there one hidden deep in the .Net framework somewhere already?
A quick search didn't show any results. But the interface is simple and it would be almost trivial to extend the Queue class and add support for the interface. Just override all methods thusly: ``` // this isn't the best code ever; refactor as desired protected void OnCollectionChanged( NotifyCollectionChangedEventArg...
281,123
<p>I have a loop (for item in @dataset) and I want, in each iteration, to get different data from another table and make some operations that will be printed in the view. I cant't get this data from the dataset used in the loop.</p> <p>How can I do this according to MVC? I can put the code into the loop, in the view, ...
[ { "answer_id": 281216, "author": "IDBD", "author_id": 7403, "author_profile": "https://Stackoverflow.com/users/7403", "pm_score": 1, "selected": false, "text": "<p>It is quite hard to tell about best solution for your problem without details about data and relations between your models(t...
2008/11/11
[ "https://Stackoverflow.com/questions/281123", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36599/" ]
I have a loop (for item in @dataset) and I want, in each iteration, to get different data from another table and make some operations that will be printed in the view. I cant't get this data from the dataset used in the loop. How can I do this according to MVC? I can put the code into the loop, in the view, but I thin...
If you have one table, and want to get data from another table, usually this is in the situation of a `has_many` relation. For example, we have `@people` (`Person` model), and each person `has_many` addresses (`Address` model). In those cases the best thing to do is this ``` # Controller @people = Person.find(:all, :i...
281,133
<p>What would be the easiest way to move the mouse around (and possibly click) using Python on OS X? </p> <p>This is just for rapid prototyping, it doesn't have to be elegant.</p>
[ { "answer_id": 281330, "author": "Ben", "author_id": 36522, "author_profile": "https://Stackoverflow.com/users/36522", "pm_score": 4, "selected": true, "text": "<p>I dug through the source code of Synergy to find the call that generates mouse events:</p>\n\n<pre><code>#include &lt;Applic...
2008/11/11
[ "https://Stackoverflow.com/questions/281133", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36522/" ]
What would be the easiest way to move the mouse around (and possibly click) using Python on OS X? This is just for rapid prototyping, it doesn't have to be elegant.
I dug through the source code of Synergy to find the call that generates mouse events: ``` #include <ApplicationServices/ApplicationServices.h> int to(int x, int y) { CGPoint newloc; CGEventRef eventRef; newloc.x = x; newloc.y = y; eventRef = CGEventCreateMouseEvent(NULL, kCGEventMouseMoved, newl...
281,135
<p>My code:</p> <pre><code> string input1; input1 = Console.ReadLine(); Console.WriteLine("byte output"); byte[] bInput1 = Encoding.Unicode.GetBytes(input1); for (int x = 0; x &lt; bInput1.Length; x++) Console.WriteLine("{0} = {1}", x, bInput1[x]); </code></pre> ...
[ { "answer_id": 281152, "author": "Nir", "author_id": 3509, "author_profile": "https://Stackoverflow.com/users/3509", "pm_score": 3, "selected": false, "text": "<p>You should read \"The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character ...
2008/11/11
[ "https://Stackoverflow.com/questions/281135", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
My code: ``` string input1; input1 = Console.ReadLine(); Console.WriteLine("byte output"); byte[] bInput1 = Encoding.Unicode.GetBytes(input1); for (int x = 0; x < bInput1.Length; x++) Console.WriteLine("{0} = {1}", x, bInput1[x]); ``` outputs: 104 0 101 0 108...
You should read "The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)" at <http://www.joelonsoftware.com/articles/Unicode.html> You can find a list of all Unicode characters at <http://www.unicode.org> but don't expect to be able to read the file...
281,136
<p>Is it possible to share a single 'god' instance among everyone that links to this code, to be placed in a shared object?</p> <pre><code>god* _god = NULL; extern "C" { int set_log_level(int level) { if(_god == NULL) return -1; _stb-&gt;log_level(level); return 0; } int god_init(){ if(_god == NULL)...
[ { "answer_id": 281168, "author": "Will Hartung", "author_id": 13663, "author_profile": "https://Stackoverflow.com/users/13663", "pm_score": 1, "selected": false, "text": "<p>This isn't the correct approach at all. By doing what you suggest, the variable, yes, is global to the library, an...
2008/11/11
[ "https://Stackoverflow.com/questions/281136", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21648/" ]
Is it possible to share a single 'god' instance among everyone that links to this code, to be placed in a shared object? ``` god* _god = NULL; extern "C" { int set_log_level(int level) { if(_god == NULL) return -1; _stb->log_level(level); return 0; } int god_init(){ if(_god == NULL){ _god = ...
[Boost Interprocess](http://www.boost.org/doc/libs/1_37_0/doc/html/interprocess.html) library has high(er) level, portable shared memory objects.
281,167
<p>I've got a particular SQL statement which takes about 30 seconds to perform, and I'm wondering if anyone can see a problem with it, or where I need additional indexing.</p> <p>The code is on a subform in Access, which shows results dependent on the content of five fields in the master form. There are nearly 5000 re...
[ { "answer_id": 281214, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 1, "selected": false, "text": "<p>At first, try compacting and repairing the .mdb file.</p>\n\n<p>Then, simplify your WHERE clause:</p>\n\n<pre><code>WHE...
2008/11/11
[ "https://Stackoverflow.com/questions/281167", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30140/" ]
I've got a particular SQL statement which takes about 30 seconds to perform, and I'm wondering if anyone can see a problem with it, or where I need additional indexing. The code is on a subform in Access, which shows results dependent on the content of five fields in the master form. There are nearly 5000 records in t...
Two things. Since this is an Access database with a SQL Server backend, you may find a considerable speed improvement by converting this to a stored proc. Second, do you really need to return all those fields, especially in the tabCustomers table? Never return more fields than you actually intend to use and you will i...
281,177
<p>Is it a good practice to comment code that is removed? For example:</p> <pre><code>// Code to do {task} was removed by Ajahn on 10/10/08 because {reason}. </code></pre> <p>Someone in my developer group during a peer review made a note that we should comment the lines of code to be removed. I thought this was a ter...
[ { "answer_id": 281185, "author": "David Koelle", "author_id": 2197, "author_profile": "https://Stackoverflow.com/users/2197", "pm_score": 8, "selected": true, "text": "<p>Generally, code that is removed should not be commented, precisely because it clutters the codebase (and, why would o...
2008/11/11
[ "https://Stackoverflow.com/questions/281177", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5831/" ]
Is it a good practice to comment code that is removed? For example: ``` // Code to do {task} was removed by Ajahn on 10/10/08 because {reason}. ``` Someone in my developer group during a peer review made a note that we should comment the lines of code to be removed. I thought this was a terrible suggestion, since it...
Generally, code that is removed should not be commented, precisely because it clutters the codebase (and, why would one comment on something that doesn't exist?). Your defect tracking system or source control management tools are where such comments belong.
281,210
<p>We have scalar functions in our database for returning things like "number of tasks for a customer" or "total invoice amount for a customer". </p> <p>We are experimenting and looking to try to do this w/o stored procedures ... normally we would just call this function in our stored procedure and return it as a sin...
[ { "answer_id": 281222, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 1, "selected": false, "text": "<p>I believe <a href=\"http://msdn.microsoft.com/en-us/library/bb386973.aspx\" rel=\"nofollow noreferrer\">this MSDN doc...
2008/11/11
[ "https://Stackoverflow.com/questions/281210", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1768/" ]
We have scalar functions in our database for returning things like "number of tasks for a customer" or "total invoice amount for a customer". We are experimenting and looking to try to do this w/o stored procedures ... normally we would just call this function in our stored procedure and return it as a single value. ...
LINQ-to-SQL supports use with UDFs, if that is what you mean. Just drag the UDF onto the designer surface and you're done. This creates a matching method on the data-context, marked [`[Function(..., IsComposable=true)]`](http://msdn.microsoft.com/en-us/library/system.data.linq.mapping.functionattribute.aspx) or similar...
281,246
<p>I have to add either an embed tag for Firefox or an object tag for Internet Explorer with JavaScript to address the appropriate ActiveX / Plugin depending on the browser. The plugin could be missing and needs to get downloaded in this case. The dynamically added embed tag for Firefox works as expected. The dynamical...
[ { "answer_id": 281280, "author": "Jason Bunting", "author_id": 1790, "author_profile": "https://Stackoverflow.com/users/1790", "pm_score": 5, "selected": true, "text": "<p>I needed to do this same thing and simply place all of the HTML needed for the OBJECT tag in a string in JavaScript ...
2008/11/11
[ "https://Stackoverflow.com/questions/281246", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1890/" ]
I have to add either an embed tag for Firefox or an object tag for Internet Explorer with JavaScript to address the appropriate ActiveX / Plugin depending on the browser. The plugin could be missing and needs to get downloaded in this case. The dynamically added embed tag for Firefox works as expected. The dynamically ...
I needed to do this same thing and simply place all of the HTML needed for the OBJECT tag in a string in JavaScript and simply replace the innerHTML of a div tag with the OBJECT HTML and it works in IE just fine. ``` // something akin to this: document.getElementById(myDivId).innerHTML = "<OBJECT id='foo' classid='CLS...
281,257
<p>In an earlier question about <a href="https://stackoverflow.com/questions/280579/c-beginner-help-how-do-i-pass-a-value-from-a-child-back-to-the-parent-form">how to return a string from a dialog window</a>, <strong>yapiskan</strong> suggested <a href="https://stackoverflow.com/questions/280579/c-beginner-help-how-do-...
[ { "answer_id": 281262, "author": "Patrick Desjardins", "author_id": 13913, "author_profile": "https://Stackoverflow.com/users/13913", "pm_score": 4, "selected": true, "text": "<p>Better to have a Public property/method and get the information. </p>\n\n<p>What would you do if you would ne...
2008/11/11
[ "https://Stackoverflow.com/questions/281257", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14606/" ]
In an earlier question about [how to return a string from a dialog window](https://stackoverflow.com/questions/280579/c-beginner-help-how-do-i-pass-a-value-from-a-child-back-to-the-parent-form), **yapiskan** suggested [overloading the child form's ShowDialog() method](https://stackoverflow.com/questions/280579/c-beginn...
Better to have a Public property/method and get the information. What would you do if you would need 3..4..5 informations, having 5 parameters out? More clean to have accessors to get your information from the Dialog.
281,264
<p>How do I remove empty elements from an array in JavaScript? </p> <p>Is there a straightforward way, or do I need to loop through it and remove them manually?</p>
[ { "answer_id": 281288, "author": "Matty", "author_id": 26241, "author_profile": "https://Stackoverflow.com/users/26241", "pm_score": -1, "selected": false, "text": "<p>Try this. Pass it your array and it will return with empty elements removed. *Updated to address the bug pointed out b...
2008/11/11
[ "https://Stackoverflow.com/questions/281264", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8954/" ]
How do I remove empty elements from an array in JavaScript? Is there a straightforward way, or do I need to loop through it and remove them manually?
**EDIT:** This question was answered almost nine years ago when there were not many useful built-in methods in the `Array.prototype`. Now, certainly, I would recommend you to use the `filter` method. Take in mind that this method will return you *a new array* with the elements that pass the criteria of the callback f...
281,275
<p>I have two STL containers that I want to merge, removing any elements that appear more than once. For example:</p> <pre><code>typedef std::list&lt;int&gt; container; container c1; container c2; c1.push_back(1); c1.push_back(2); c1.push_back(3); c2.push_back(2); c2.push_back(3); c2.push_back(4); container c3 = u...
[ { "answer_id": 281296, "author": "Eclipse", "author_id": 8701, "author_profile": "https://Stackoverflow.com/users/8701", "pm_score": 4, "selected": true, "text": "<p>For an unordered lists, your set trick is probably one of the best. It each insert should be O(log n), with N inserts req...
2008/11/11
[ "https://Stackoverflow.com/questions/281275", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9236/" ]
I have two STL containers that I want to merge, removing any elements that appear more than once. For example: ``` typedef std::list<int> container; container c1; container c2; c1.push_back(1); c1.push_back(2); c1.push_back(3); c2.push_back(2); c2.push_back(3); c2.push_back(4); container c3 = unique_merge(c1, c2); ...
For an unordered lists, your set trick is probably one of the best. It each insert should be O(log n), with N inserts required, and traversing will be O(n), giving you O(N\*log n). The other option is to run std::sort on each list individually and then walk through them in parallel using [std::set\_union](http://msdn.m...
281,323
<p>I am attempting to insert a copy of a row from one table into another table with the same schema, with the addition of one column (a timestamp) to provide a "history" of the first table in MS Sql Server 2005.</p> <p>So, my query, without the additional column would be:</p> <pre><code>"SELECT INTO [WebsiteHistory] ...
[ { "answer_id": 281336, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 5, "selected": true, "text": "<p>Be warned. This works, but it is neither <em>nice</em> nor recommendable:</p>\n\n<pre><code>INSERT\n WebsiteHistory\nSE...
2008/11/11
[ "https://Stackoverflow.com/questions/281323", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2327/" ]
I am attempting to insert a copy of a row from one table into another table with the same schema, with the addition of one column (a timestamp) to provide a "history" of the first table in MS Sql Server 2005. So, my query, without the additional column would be: ``` "SELECT INTO [WebsiteHistory] FROM [Website]" ``` ...
Be warned. This works, but it is neither *nice* nor recommendable: ``` INSERT WebsiteHistory SELECT *, GETDATE() FROM Website WHERE Id = @WebsiteId ``` This assumes `WebsiteHistory` has the same structure as `Website` (you said it has), plus there is one additional `DATETIME` field. Better is this, becaus...
281,334
<p>I have a UL that looks like this:</p> <pre><code>&lt;ul class="popular-pages"&gt; &lt;li&gt;&lt;a href="region/us/california/"&gt;California&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="region/us/michigan/"&gt;Michigan&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="region/us/missouri/"&gt;Missouri&lt;/a&gt;&l...
[ { "answer_id": 281351, "author": "Greg", "author_id": 28002, "author_profile": "https://Stackoverflow.com/users/28002", "pm_score": 0, "selected": false, "text": "<p>What DOCTYPE are you using? DOCTYPE has an impact on how browsers render.</p>\n" }, { "answer_id": 281360, "a...
2008/11/11
[ "https://Stackoverflow.com/questions/281334", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a UL that looks like this: ``` <ul class="popular-pages"> <li><a href="region/us/california/">California</a></li> <li><a href="region/us/michigan/">Michigan</a></li> <li><a href="region/us/missouri/">Missouri</a></li> <li><a href="region/us/new-york/">New York</a></li> <li><a href="region/us...
The reason for your layout is probably because you have the float on the anchor, move it to the list-item instead. ``` ul.popular-pages li { float: left; } ``` Since you're not setting any width in your LI's, I suggest skipping the float and set display: inline on your LI's instead, if you want them on a row. Ad...
281,355
<p>I have seen this in a lot of XML comments for classes in the .NET Framework BCL but have never been able to find documentation that explains what it does.</p> <p>As an example, looking at System.Object reveals the following comments:</p> <pre><code>namespace System { /// &lt;summary&gt;Supports all classes ...
[ { "answer_id": 281457, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 5, "selected": true, "text": "<p>Just a guess: the All vs Common tabs in intellisense?</p>\n" }, { "answer_id": 409009, "author": "Øyvin...
2008/11/11
[ "https://Stackoverflow.com/questions/281355", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1559/" ]
I have seen this in a lot of XML comments for classes in the .NET Framework BCL but have never been able to find documentation that explains what it does. As an example, looking at System.Object reveals the following comments: ``` namespace System { /// <summary>Supports all classes in the .NET Framework class...
Just a guess: the All vs Common tabs in intellisense?
281,359
<p>I am binding a TreeView to an XMLDataSource, the databindings are being generated automatically and the XML looks like this:-</p> <pre><code>&lt;Passengers&gt; &lt;Passenger&gt; &lt;PassengerName&gt;Name1&lt;/PassengerName&gt; &lt;/Passenger&gt; &lt;Passenger&gt; &lt;PassengerName&gt;Name2&lt;/Passeng...
[ { "answer_id": 281457, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 5, "selected": true, "text": "<p>Just a guess: the All vs Common tabs in intellisense?</p>\n" }, { "answer_id": 409009, "author": "Øyvin...
2008/11/11
[ "https://Stackoverflow.com/questions/281359", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am binding a TreeView to an XMLDataSource, the databindings are being generated automatically and the XML looks like this:- ``` <Passengers> <Passenger> <PassengerName>Name1</PassengerName> </Passenger> <Passenger> <PassengerName>Name2</PassengerName> </Passenger> <Passenger> <PassengerName>Nam...
Just a guess: the All vs Common tabs in intellisense?
281,362
<p>I'm building a class that automatically loads a DB record, looks at each DB column name, and fills the associated textbox/label/literal/etc, if it has the same name. I got this idea from Rails, in case that helps clarify what I'm trying to do.</p> <pre><code>public string presentData(Page thisForm) { // .. for eac...
[ { "answer_id": 281376, "author": "Erik Hesselink", "author_id": 8071, "author_profile": "https://Stackoverflow.com/users/8071", "pm_score": 3, "selected": true, "text": "<p>FindControl is not recursive, so it only finds top level controls, not controls that are nested within other contro...
2008/11/11
[ "https://Stackoverflow.com/questions/281362", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25538/" ]
I'm building a class that automatically loads a DB record, looks at each DB column name, and fills the associated textbox/label/literal/etc, if it has the same name. I got this idea from Rails, in case that helps clarify what I'm trying to do. ``` public string presentData(Page thisForm) { // .. for each column name /...
FindControl is not recursive, so it only finds top level controls, not controls that are nested within other controls. See [this article](https://blog.codinghorror.com/recursive-pagefindcontrol/) for an example of a recursive version of FindControl.
281,365
<p>If I have the following code,</p> <pre><code>Foo *f = new Foo(); vector&lt;Foo*&gt; vect; vect.push_back(f); // do stuff vect.erase(f); </code></pre> <p>Did I create a memory leak? I guess so, but the word <em>erase</em> gives the feeling that it is deleting it. </p> <p>Writing this, I am wondering if it is not ...
[ { "answer_id": 281385, "author": "Johannes Schaub - litb", "author_id": 34509, "author_profile": "https://Stackoverflow.com/users/34509", "pm_score": 4, "selected": true, "text": "<p>Yes, you created a memory leak by that. std::vector and other containers will just remove the pointer, th...
2008/11/11
[ "https://Stackoverflow.com/questions/281365", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20986/" ]
If I have the following code, ``` Foo *f = new Foo(); vector<Foo*> vect; vect.push_back(f); // do stuff vect.erase(f); ``` Did I create a memory leak? I guess so, but the word *erase* gives the feeling that it is deleting it. Writing this, I am wondering if it is not a mistake to put a pointer in a STL vector. Wh...
Yes, you created a memory leak by that. std::vector and other containers will just remove the pointer, they won't free the memory the pointer points to. It's not unusual to put a pointer into a standard library container. The problem, however, is that you have to keep track of deleting it when removing it from the con...
281,373
<p>I am looking for a query that will work on Sharepoint 2003 to show me all the documents created/touched by a given userID.</p> <p>I have found tables with the documents (Docs) and tables for users (UserInfo, UserData) but the relationship between seems a bit odd - there are 99,000 records in our userdata table, and...
[ { "answer_id": 283290, "author": "Bjørn Stærk", "author_id": 36164, "author_profile": "https://Stackoverflow.com/users/36164", "pm_score": 2, "selected": true, "text": "<p>I've never looked at the database in SharePoint 2003, but in 2007 UserInfo is connected to Sites, which means that e...
2008/11/11
[ "https://Stackoverflow.com/questions/281373", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33186/" ]
I am looking for a query that will work on Sharepoint 2003 to show me all the documents created/touched by a given userID. I have found tables with the documents (Docs) and tables for users (UserInfo, UserData) but the relationship between seems a bit odd - there are 99,000 records in our userdata table, and 12,000 re...
I've never looked at the database in SharePoint 2003, but in 2007 UserInfo is connected to Sites, which means that every user has a row in UserInfo for each site collection (or the equivalent 2003 concept). So to identify what a user does you need both the site id and the user's id within that site. In 2007, I would be...
281,380
<p>I am trying to format a date with: </p> <pre><code>&lt;fmt:formatDate value="${newsletter.createdOn}" pattern="MM/dd/yyyy"/&gt; </code></pre> <p>newsletter is an object with a <code>createdOn</code> property which is <code>java.util.Date</code>.</p> <p>When I invoke the previous sentence I get: </p> <p>According...
[ { "answer_id": 281406, "author": "sblundy", "author_id": 4893, "author_profile": "https://Stackoverflow.com/users/4893", "pm_score": 1, "selected": false, "text": "<p>Are you sure you're not using the runtime versions of the tag lib? May we see the library import statement?</p>\n\n<p>I t...
2008/11/11
[ "https://Stackoverflow.com/questions/281380", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2138/" ]
I am trying to format a date with: ``` <fmt:formatDate value="${newsletter.createdOn}" pattern="MM/dd/yyyy"/> ``` newsletter is an object with a `createdOn` property which is `java.util.Date`. When I invoke the previous sentence I get: According to the TLD, the attribute value does not accept expressions. I am...
Try ``` <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> ```
281,383
<p>As the title suggests, I am having trouble maintaining my code on postback. I have a bunch of jQuery code in the Head section and this works fine until a postback occurs after which it ceases to function! </p> <p>How can I fix this? Does the head not get read on postback, and is there a way in which I can force thi...
[ { "answer_id": 281419, "author": "Justin Bozonier", "author_id": 9401, "author_profile": "https://Stackoverflow.com/users/9401", "pm_score": 4, "selected": true, "text": "<p>If you just have that code hard coded into your page's head then a post back won't affect it. I would check the fo...
2008/11/11
[ "https://Stackoverflow.com/questions/281383", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35454/" ]
As the title suggests, I am having trouble maintaining my code on postback. I have a bunch of jQuery code in the Head section and this works fine until a postback occurs after which it ceases to function! How can I fix this? Does the head not get read on postback, and is there a way in which I can force this to happe...
If you just have that code hard coded into your page's head then a post back won't affect it. I would check the following by debugging (FireBug in FireFox is a good debugger): * Verify the script is still in the head on postback. * verify that the css classes are in fact attached to some element in the page. * verify ...
281,398
<p>I have an existing web app that allows users to "rate" items based on their difficulty. (0 through 15). Currently, I'm simply taking the average of each user's opinion and presenting the average straight from MySQL. However, it's becoming clear to me (and my users) that weighting the numbers would be more appropr...
[ { "answer_id": 281433, "author": "Vinko Vrsalovic", "author_id": 5190, "author_profile": "https://Stackoverflow.com/users/5190", "pm_score": 4, "selected": true, "text": "<p>This is a simple example about how to do it in MySQL directly. You of course would need to add a condition on the ...
2008/11/11
[ "https://Stackoverflow.com/questions/281398", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24708/" ]
I have an existing web app that allows users to "rate" items based on their difficulty. (0 through 15). Currently, I'm simply taking the average of each user's opinion and presenting the average straight from MySQL. However, it's becoming clear to me (and my users) that weighting the numbers would be more appropriate. ...
This is a simple example about how to do it in MySQL directly. You of course would need to add a condition on the subquery to get only the votes for the relevant item instead of all the votes. ``` mysql> create table votes( vote int); Query OK, 0 rows affected (0.01 sec) mysql> insert into votes values (5),(5),(4); ...
281,440
<pre> create table person ( name varchar(15), attr1 varchar(15), attr2 varchar(1), attr3 char(1), attr4 int ) </pre> <p>How I can use basic ORM in Perl by taking a simple table like the one above and mapping it to Perl objects? Next I'd like to perform basic operations like select results using so...
[ { "answer_id": 281459, "author": "Dave Rolsky", "author_id": 9832, "author_profile": "https://Stackoverflow.com/users/9832", "pm_score": 6, "selected": true, "text": "<p>Rule #1, don't write your own.</p>\n\n<p>There are quite a number of ORMs on CPAN, including ...</p>\n\n<ul>\n<li><a h...
2008/11/11
[ "https://Stackoverflow.com/questions/281440", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
``` create table person ( name varchar(15), attr1 varchar(15), attr2 varchar(1), attr3 char(1), attr4 int ) ``` How I can use basic ORM in Perl by taking a simple table like the one above and mapping it to Perl objects? Next I'd like to perform basic operations like select results using some crit...
Rule #1, don't write your own. There are quite a number of ORMs on CPAN, including ... * [DBIx::Class](http://search.cpan.org/dist/DBIx-Class) - probably #1 in popularity at the moment * [Rose::DB::Object](http://search.cpan.org/dist/Rose-DB-Object) * [Fey::ORM](http://search.cpan.org/dist/Fey-ORM) - my own contribut...
281,443
<p>The following source code alerts the following results:</p> <p><strong>Internet Explorer 7</strong>: 29<br> <strong>Firefox 3.0.3</strong>: 37 (correct)<br> <strong>Safari 3.0.4 (523.12.9)</strong>: 38<br> <strong>Google Chrome 0.3.154.9</strong>: 38 </p> <p>Please ignore the following facts: </p> <ul> <li>Webk...
[ { "answer_id": 281493, "author": "okoman", "author_id": 35903, "author_profile": "https://Stackoverflow.com/users/35903", "pm_score": 0, "selected": false, "text": "<p>Well... I'd say the reason it that it is IE. I don't think the programers had a specific intention to do it that way.</p...
2008/11/11
[ "https://Stackoverflow.com/questions/281443", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16711/" ]
The following source code alerts the following results: **Internet Explorer 7**: 29 **Firefox 3.0.3**: 37 (correct) **Safari 3.0.4 (523.12.9)**: 38 **Google Chrome 0.3.154.9**: 38 Please ignore the following facts: * Webkit (Safari/Chrome) browsers insert an extra text node at the end of the body tag * In...
IE tries to be helpful and hides text nodes that contain only whitespace. In the following: ``` <p> <input> </p> ``` W3C DOM spec says that `<p>` has 3 child nodes ("\n", `<input>` and "\n"), IE will pretend there's only one. The solution is to skip [text nodes](https://developer.mozilla.org/en/DOM/element.nodeTyp...
281,456
<p>I need to convert several Java classes to C#, but I have faced few problems.</p> <p>In Java I have following class hierarchy:</p> <pre><code>public abstract class AbstractObject { public String getId() { return id; } } public class ConcreteObject extends AbstractObject { public void setId(Str...
[ { "answer_id": 281469, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 2, "selected": false, "text": "<p>When you supply only the <code>get</code> portion of a property in .Net, you are explicitly telling the compiler th...
2008/11/11
[ "https://Stackoverflow.com/questions/281456", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22062/" ]
I need to convert several Java classes to C#, but I have faced few problems. In Java I have following class hierarchy: ``` public abstract class AbstractObject { public String getId() { return id; } } public class ConcreteObject extends AbstractObject { public void setId(String id) { thi...
I would suggest using method calls as you've already outlined to make sure that the usage of the class is clear to the caller. If you're set on implementing it using properties, then you could do the following (some documentation for the new keyword can be found [here](http://msdn.microsoft.com/en-us/library/6fawty39.a...
281,500
<p>I'm trying to connect to an MDF. I've even gone to the lengths of re-installing sql server express entirely (it is now the only flavor of SQL installed on my box, where previously I had 05 dev and express). I've verified that the paths are all correct, and thus far my google-fu hasn't helped.</p> <p>The Full exce...
[ { "answer_id": 281530, "author": "Jimoc", "author_id": 24079, "author_profile": "https://Stackoverflow.com/users/24079", "pm_score": -1, "selected": false, "text": "<p>Have you tried to connect to the SQL Server instance by using SQL Management Studio?</p>\n\n<p>If this also doesn't allo...
2008/11/11
[ "https://Stackoverflow.com/questions/281500", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5416/" ]
I'm trying to connect to an MDF. I've even gone to the lengths of re-installing sql server express entirely (it is now the only flavor of SQL installed on my box, where previously I had 05 dev and express). I've verified that the paths are all correct, and thus far my google-fu hasn't helped. The Full exception messag...
ok, it works now! guess it was a compound problem ... the steps I took to resolve it are as such: 1. Changed the following property in the connection string (note the subtle difference): `AttachDbFilename=|DataDirectory|CustomerDb.mdf;` 2. Deleted the contents of the following directory: `c:\Users\<user name>\AppData\...
281,503
<p>I am having trouble creating a mapping when the List type is an interface. It looks like I need to create an abstract class and use the discriminator column is this the case? I would rather not have to as the abstract class will just contain an abstract method and I would rather just keep the interface.</p> <p>I ha...
[ { "answer_id": 281900, "author": "Andrea Francia", "author_id": 36131, "author_profile": "https://Stackoverflow.com/users/36131", "pm_score": 1, "selected": false, "text": "<p>You can also introduce an abstract class without removing the interface.</p>\n\n<pre><code>// not an entity\npub...
2008/11/11
[ "https://Stackoverflow.com/questions/281503", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3050/" ]
I am having trouble creating a mapping when the List type is an interface. It looks like I need to create an abstract class and use the discriminator column is this the case? I would rather not have to as the abstract class will just contain an abstract method and I would rather just keep the interface. I have an inte...
I think that it is possible to to make an interface the supertype of a mapping. You may not be able to use annotations though. Annotations play well with xml config files so you might have to add a hibernate config file to your project with the mappings that you need. But you will be able to keep the annotations for th...
281,512
<p>I am having issues converting a png to tiff. The conversion goes fine, but the image is huge. I think the issue is that I am not doing the compression correctly? Anyone have any suggestions??</p> <p>Here is the code sample</p> <pre><code>public static void test() throws IOException { // String fileName = "...
[ { "answer_id": 281612, "author": "Lou Franco", "author_id": 3937, "author_profile": "https://Stackoverflow.com/users/3937", "pm_score": 2, "selected": false, "text": "<p>I don't know Java IO, but generally you want to look at a few things</p>\n\n<ol>\n<li>Can you use JPEG compression ins...
2008/11/11
[ "https://Stackoverflow.com/questions/281512", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36641/" ]
I am having issues converting a png to tiff. The conversion goes fine, but the image is huge. I think the issue is that I am not doing the compression correctly? Anyone have any suggestions?? Here is the code sample ``` public static void test() throws IOException { // String fileName = "4958813_1"; String f...
`Writer.getDefaultWriteParam()` only creates an `ImageWriteParam` object, it doesn't link it back to anything else. I don't see any mechanism in your code for your modified `param` object to be subsequently used in the `ImageWriter`. I believe that instead of: ``` writer.write(bi); ``` you need to use: ``` writer...
281,526
<p>I have a delete statement that's going against one of my core application tables. The delete statement is using the table's primary key but is still taking around 30 seconds. As far as I can tell the execution plan needs to do about 12 checks in other tables where this table is a FK prior to doing the delete. I n...
[ { "answer_id": 281566, "author": "Charles Bretana", "author_id": 32632, "author_profile": "https://Stackoverflow.com/users/32632", "pm_score": 0, "selected": false, "text": "<p>In the execution plan, which step is taking the majority pf the time? Also can you reRun the delete with \"Set...
2008/11/11
[ "https://Stackoverflow.com/questions/281526", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1989/" ]
I have a delete statement that's going against one of my core application tables. The delete statement is using the table's primary key but is still taking around 30 seconds. As far as I can tell the execution plan needs to do about 12 checks in other tables where this table is a FK prior to doing the delete. I need he...
Make sure you have indexes on the FKs in the other tables.
281,531
<p>Most of my PHP apps have an ob_start at the beginning, runs through all the code, and then outputs the content, sometimes with some modifications, after everything is done.</p> <pre><code>ob_start() //Business Logic, etc header-&gt;output(); echo apply_post_filter(ob_get_clean()); footer-&gt;output(); </code></pre>...
[ { "answer_id": 281615, "author": "troelskn", "author_id": 18180, "author_profile": "https://Stackoverflow.com/users/18180", "pm_score": 4, "selected": true, "text": "<p>Can't you raise the memory limit? Sounds like the best solution to me.</p>\n\n<p>Edit: Obviously, raising the memory li...
2008/11/11
[ "https://Stackoverflow.com/questions/281531", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6681/" ]
Most of my PHP apps have an ob\_start at the beginning, runs through all the code, and then outputs the content, sometimes with some modifications, after everything is done. ``` ob_start() //Business Logic, etc header->output(); echo apply_post_filter(ob_get_clean()); footer->output(); ``` This ensures that PHP erro...
Can't you raise the memory limit? Sounds like the best solution to me. Edit: Obviously, raising the memory limit just because a script tops out should raise some red flags, but it sounds to me like this is a legitimate case - eg. the script is actually producing rather large chunks of output. As such, you have to stor...
281,534
<p>Grasping at straws here... I work with a VB6 desktop system using several 2003-style Access databases (.MDB). Recently, I changed the first function from VB6 to VB.NET, still using an Access database. This is more than a conversion, but a rewrite with additional functionality. It is still fairly simple functional...
[ { "answer_id": 281539, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 0, "selected": false, "text": "<p>No, VB.Net works great with Access. SHARED environments will trash access.</p>\n\n<p>Since rebooting solves the pr...
2008/11/11
[ "https://Stackoverflow.com/questions/281534", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12897/" ]
Grasping at straws here... I work with a VB6 desktop system using several 2003-style Access databases (.MDB). Recently, I changed the first function from VB6 to VB.NET, still using an Access database. This is more than a conversion, but a rewrite with additional functionality. It is still fairly simple functionality, w...
Rebooting while updating an access database can trash it. You need some more info so that you have a better understanding of what is going on. They need to collect some information for you on a workstation that is having the problem. Using task manager you can have them get the following info: * CPU utilization * Wha...
281,538
<p>Are there major advantages to <a href="https://web.archive.org/web/20090207080811/http://www.innodb.com:80/hot-backup/features/" rel="nofollow noreferrer">InnoDB hot backup</a> vs ZRM <a href="https://www.zmanda.com/zrm-enterprise/" rel="nofollow noreferrer">snapshots</a> in terms of disruption to the running site, ...
[ { "answer_id": 281539, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 0, "selected": false, "text": "<p>No, VB.Net works great with Access. SHARED environments will trash access.</p>\n\n<p>Since rebooting solves the pr...
2008/11/11
[ "https://Stackoverflow.com/questions/281538", "https://Stackoverflow.com", "https://Stackoverflow.com/users/556/" ]
Are there major advantages to [InnoDB hot backup](https://web.archive.org/web/20090207080811/http://www.innodb.com:80/hot-backup/features/) vs ZRM [snapshots](https://www.zmanda.com/zrm-enterprise/) in terms of disruption to the running site, the size of compressed backup files, and speed of backup/restore on a medium-...
Rebooting while updating an access database can trash it. You need some more info so that you have a better understanding of what is going on. They need to collect some information for you on a workstation that is having the problem. Using task manager you can have them get the following info: * CPU utilization * Wha...
281,548
<p>I have the very same delphi version, bpls, components, everything. And yet in three machines the resulting executables are different in size. What else can influence in the size of the exe?</p> <p>In my machine I get this size (Vista 6.0.6001):</p> <pre><code>4.547.584 bytes </code></pre> <p>In my colleague's mac...
[ { "answer_id": 281577, "author": "QAZ", "author_id": 14260, "author_profile": "https://Stackoverflow.com/users/14260", "pm_score": 2, "selected": false, "text": "<p>With Delphi/BCB these are a few factors that can influence size:</p>\n\n<p><strong>Your Build Configuration</strong>: Relea...
2008/11/11
[ "https://Stackoverflow.com/questions/281548", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19224/" ]
I have the very same delphi version, bpls, components, everything. And yet in three machines the resulting executables are different in size. What else can influence in the size of the exe? In my machine I get this size (Vista 6.0.6001): ``` 4.547.584 bytes ``` In my colleague's machine, he gets (XP 5.1.2600 SP3): ...
It would seem that it is configuration differences, or if maybe you have different versions of components installed between the three machines. I would suggest creating a blank form and trying it on all 3 after you verify that the build settings are the same. If that is the same then add some 3rd party components until...
281,563
<p>I'm currently using AntLR to parse some files with a proprietary language. I have a need of highlighting sections of it on an editor (think of highlighting a method in a Java class, for instance).</p> <p>Does anyone has a hint on how to get them? Say I have this code:</p> <pre><code>function test(param1, param2) {...
[ { "answer_id": 281571, "author": "Josh", "author_id": 2204759, "author_profile": "https://Stackoverflow.com/users/2204759", "pm_score": 0, "selected": false, "text": "<p>Not quite following why the first position you are getting is the position of test. You should easily be able to get t...
2008/11/11
[ "https://Stackoverflow.com/questions/281563", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7277/" ]
I'm currently using AntLR to parse some files with a proprietary language. I have a need of highlighting sections of it on an editor (think of highlighting a method in a Java class, for instance). Does anyone has a hint on how to get them? Say I have this code: ``` function test(param1, param2) { } ``` as function ...
If I understand your question, I think you can use attribute 'pos' on each token ``` func: FUNCTION ID '(' ID (',' ID)* ')' { System.out.println("Position = " + $FUNCTION.pos); } ``` which refers to the character position within the line counting from zero.
281,579
<p>I'm trying to do Ruby password input with the <a href="http://highline.rubyforge.org/" rel="noreferrer">Highline gem</a> and since I have the user input the password twice, I'd like to eliminate the duplication on the blocks I'm passing in. For example, a simple version of what I'm doing right now is:</p> <pre><cod...
[ { "answer_id": 281620, "author": "Lucas Oman", "author_id": 6726, "author_profile": "https://Stackoverflow.com/users/6726", "pm_score": -1, "selected": false, "text": "<p>I don't think the language supports a construct like this. The only way I can see to generalize this in any way is:</...
2008/11/11
[ "https://Stackoverflow.com/questions/281579", "https://Stackoverflow.com", "https://Stackoverflow.com/users/422/" ]
I'm trying to do Ruby password input with the [Highline gem](http://highline.rubyforge.org/) and since I have the user input the password twice, I'd like to eliminate the duplication on the blocks I'm passing in. For example, a simple version of what I'm doing right now is: ``` new_pass = ask("Enter your new password:...
The code by David will work fine, but this is an easier and shorter solution: ``` foo = Proc.new { |prompt| prompt.echo = false } new_pass = ask("Enter your new password: ", &foo) verify_pass = ask("Enter again to verify: ", &foo) ``` You can also use an ampersand to assign a block to a variable when defining a meth...
281,584
<p>Using an ORM approach in applications can often lead to the scenario where you have a collection of objects you've retrieved and would like to display them in a tabular view using a DataGridView.</p> <p>In my (limited) experience, binding collections of objects using a custom BindingList to a DataGridView results i...
[ { "answer_id": 281620, "author": "Lucas Oman", "author_id": 6726, "author_profile": "https://Stackoverflow.com/users/6726", "pm_score": -1, "selected": false, "text": "<p>I don't think the language supports a construct like this. The only way I can see to generalize this in any way is:</...
2008/11/11
[ "https://Stackoverflow.com/questions/281584", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3406/" ]
Using an ORM approach in applications can often lead to the scenario where you have a collection of objects you've retrieved and would like to display them in a tabular view using a DataGridView. In my (limited) experience, binding collections of objects using a custom BindingList to a DataGridView results in poor per...
The code by David will work fine, but this is an easier and shorter solution: ``` foo = Proc.new { |prompt| prompt.echo = false } new_pass = ask("Enter your new password: ", &foo) verify_pass = ask("Enter again to verify: ", &foo) ``` You can also use an ampersand to assign a block to a variable when defining a meth...
281,605
<p>I am developing a touch screen application that has to display a possibly large amount of text. The problem I am having is that the default scroll bar attached to text boxes is just too small to be practically used in a touch screen application. I have tried adding a separate scroll bar control and using it to contr...
[ { "answer_id": 281656, "author": "TcKs", "author_id": 20382, "author_profile": "https://Stackoverflow.com/users/20382", "pm_score": 1, "selected": false, "text": "<p>I think, there is way how to change size of scrollbar wint Win32API.\nLook at:\n<a href=\"http://pinvoke.net/search.aspx?s...
2008/11/11
[ "https://Stackoverflow.com/questions/281605", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25511/" ]
I am developing a touch screen application that has to display a possibly large amount of text. The problem I am having is that the default scroll bar attached to text boxes is just too small to be practically used in a touch screen application. I have tried adding a separate scroll bar control and using it to control ...
I think, there is way how to change size of scrollbar wint Win32API. Look at: <http://pinvoke.net/search.aspx?search=scrollbar&namespace=[All]> <http://pinvoke.net/default.aspx/user32/FindWindowEx.html> <http://pinvoke.net/default.aspx/user32/GetScrollBarInfo.html> <http://pinvoke.net/default.aspx/user32/ShowScrollBar....
281,640
<p>How do I get a human-readable file size in bytes abbreviation using .NET?</p> <p><strong>Example</strong>: Take input 7,326,629 and display 6.98 MB</p>
[ { "answer_id": 281665, "author": "TcKs", "author_id": 20382, "author_profile": "https://Stackoverflow.com/users/20382", "pm_score": 4, "selected": false, "text": "<pre><code>int size = new FileInfo( filePath ).Length / 1024;\nstring humanKBSize = string.Format( \"{0} KB\", size );\nstrin...
2008/11/11
[ "https://Stackoverflow.com/questions/281640", "https://Stackoverflow.com", "https://Stackoverflow.com/users/337/" ]
How do I get a human-readable file size in bytes abbreviation using .NET? **Example**: Take input 7,326,629 and display 6.98 MB
This may not the most efficient or optimized way to do it, but it's easier to read if you are not familiar with log maths, and should be fast enough for most scenarios. ``` string[] sizes = { "B", "KB", "MB", "GB", "TB" }; double len = new FileInfo(filename).Length; int order = 0; while (len >= 1024 && order < sizes.L...
281,664
<p>Imagine the following scenario - we have Page1 which contains controls Control A and Control B.</p> <p>Say Control A has a button, and on the click of this button we want Control B to react. But we want to do this in an abstract fashion, i.e. we can't have Control B knowing anything about Control A, and vice versa....
[ { "answer_id": 281678, "author": "Steven A. Lowe", "author_id": 9345, "author_profile": "https://Stackoverflow.com/users/9345", "pm_score": 2, "selected": false, "text": "<p>an interesting abuse of the session...</p>\n\n<p>you could also have the message queue belong to the hosting page ...
2008/11/11
[ "https://Stackoverflow.com/questions/281664", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7140/" ]
Imagine the following scenario - we have Page1 which contains controls Control A and Control B. Say Control A has a button, and on the click of this button we want Control B to react. But we want to do this in an abstract fashion, i.e. we can't have Control B knowing anything about Control A, and vice versa. That way...
What you have is pretty much an [EventBroker](http://msforge.net/blogs/paki/archive/2007/11/20/EventBroker-implementation-in-C_2300_-full-source-code.aspx). I don't think Session is the appropiate place for this, as it's not necessary to live across requests. [HttpContext](http://msdn.microsoft.com/en-us/library/system...
281,682
<p>I am trying to set the innerxml of a xmldoc but get the exception: Reference to undeclared entity</p> <pre><code>XmlDocument xmldoc = new XmlDocument(); string text = "Hello, I am text &amp;alpha; &amp;nbsp; &amp;ndash; &amp;mdash;" xmldoc.InnerXml = "&lt;p&gt;" + text + "&lt;/p&gt;"; </code></pre> <p>This throws ...
[ { "answer_id": 281686, "author": "FlySwat", "author_id": 1965, "author_profile": "https://Stackoverflow.com/users/1965", "pm_score": 3, "selected": false, "text": "<p>Try replacing &amp;Alpha with </p>\n\n<pre><code> &amp;#913;\n</code></pre>\n" }, { "answer_id": 281703, "au...
2008/11/11
[ "https://Stackoverflow.com/questions/281682", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6201/" ]
I am trying to set the innerxml of a xmldoc but get the exception: Reference to undeclared entity ``` XmlDocument xmldoc = new XmlDocument(); string text = "Hello, I am text &alpha; &nbsp; &ndash; &mdash;" xmldoc.InnerXml = "<p>" + text + "</p>"; ``` This throws the exception: > > Reference to undeclared entity '...
XML, unlike HTML does not define entities (ie named references to UNICODE characters) so &alpha; &mdash; etc. are not translated to their corresponding character. You must use the numerical value instead. You can only use &lt; and &amp; in XML If you want to create HTML, use an HtmlDocument instead.
281,694
<p>I want to set up an ASP.NET custom control such that it has a custom name, specifically, with a hyphen within it, so it might look like this in markup:</p> <pre><code>&lt;rp:do-something runat="server" id="doSomething1" /&gt;</code></pre> <p>I don't mind if this syntax requires setting up a tag mapping in web.conf...
[ { "answer_id": 281686, "author": "FlySwat", "author_id": 1965, "author_profile": "https://Stackoverflow.com/users/1965", "pm_score": 3, "selected": false, "text": "<p>Try replacing &amp;Alpha with </p>\n\n<pre><code> &amp;#913;\n</code></pre>\n" }, { "answer_id": 281703, "au...
2008/11/11
[ "https://Stackoverflow.com/questions/281694", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34224/" ]
I want to set up an ASP.NET custom control such that it has a custom name, specifically, with a hyphen within it, so it might look like this in markup: ``` <rp:do-something runat="server" id="doSomething1" /> ``` I don't mind if this syntax requires setting up a tag mapping in web.config or something to that effect, ...
XML, unlike HTML does not define entities (ie named references to UNICODE characters) so &alpha; &mdash; etc. are not translated to their corresponding character. You must use the numerical value instead. You can only use &lt; and &amp; in XML If you want to create HTML, use an HtmlDocument instead.
281,697
<p>I used code like this to find the remote user name:</p> <pre><code>banner_label.Text = "Welcome, &lt;B&gt;" + User.Identity.Name + "&lt;/B&gt;!" </code></pre> <p>I'd also like to find the remote host name. My production environment will be a corporate intranet with active directory.</p>
[ { "answer_id": 281732, "author": "John Boker", "author_id": 2847, "author_profile": "https://Stackoverflow.com/users/2847", "pm_score": 0, "selected": false, "text": "<p>maybe this would work for you</p>\n\n<pre><code>Request.UserHostName\n</code></pre>\n\n<p>edit:</p>\n\n<p>i think what...
2008/11/11
[ "https://Stackoverflow.com/questions/281697", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I used code like this to find the remote user name: ``` banner_label.Text = "Welcome, <B>" + User.Identity.Name + "</B>!" ``` I'd also like to find the remote host name. My production environment will be a corporate intranet with active directory.
You're on an Intranet, so Request.UserHostName should work well for you. If you have a complex network, some of the routers may not let that info through, but... Here's something similar I did in an app at a previous job, to record the IP and host name: ``` // NAT'ed addresses are sometimes still shown in HTTP_X_FORW...
281,698
<p>I just don't get it. Tried on VC++ 2008 and G++ 4.3.2</p> <pre><code>#include &lt;map&gt; class A : public std::multimap&lt;int, bool&gt; { public: size_type erase(int k, bool v) { return erase(k); // &lt;- this fails; had to change to __super::erase(k) } }; int main() { A a; a.erase(...
[ { "answer_id": 281707, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 6, "selected": true, "text": "<p>When you declare a function in a class with the same name but different signature from a superclass, then the name reso...
2008/11/11
[ "https://Stackoverflow.com/questions/281698", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21704/" ]
I just don't get it. Tried on VC++ 2008 and G++ 4.3.2 ``` #include <map> class A : public std::multimap<int, bool> { public: size_type erase(int k, bool v) { return erase(k); // <- this fails; had to change to __super::erase(k) } }; int main() { A a; a.erase(0, false); a.erase(0); // ...
When you declare a function in a class with the same name but different signature from a superclass, then the name resolution rules state that the compiler should *stop looking* for the function you are trying to call once it finds the first match. After finding the function by name, *then* it applies the overload reso...
281,706
<p>I'm having an issue dragging a file from Windows Explorer on to a Windows Forms application. </p> <p>It works fine when I drag text, but for some reason it is not recognizing the file. Here is my test code:</p> <pre><code>namespace WindowsFormsApplication1 { public partial class Form1 : Form { pub...
[ { "answer_id": 281770, "author": "arul", "author_id": 15409, "author_profile": "https://Stackoverflow.com/users/15409", "pm_score": 0, "selected": false, "text": "<p>The code you posted <em>should</em> work.</p>\n\n<p>Try putting this at the beginning of the DragEnter method</p>\n\n<pre>...
2008/11/11
[ "https://Stackoverflow.com/questions/281706", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1768/" ]
I'm having an issue dragging a file from Windows Explorer on to a Windows Forms application. It works fine when I drag text, but for some reason it is not recognizing the file. Here is my test code: ``` namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { ...
The problem comes from Vista's [UAC](http://en.wikipedia.org/wiki/User_Account_Control). DevStudio is running as administrator, but explorer is running as a regular user. When you drag a file from explorer and drop it on your DevStudio hosted application, that is the same as a non-privileged user trying to communicate ...
281,719
<p>I am quantitatively studying various metrics associated with automated tests. Chrome seems to have a reasonable set, so I wanted to add it to my data set. I downloaded the Chrome source code and tried to build it with VisualStudio but got several hundred errors--types not defined, identifiers not defined, etc. Has a...
[ { "answer_id": 281736, "author": "FlySwat", "author_id": 1965, "author_profile": "https://Stackoverflow.com/users/1965", "pm_score": 3, "selected": true, "text": "<p>From the Chromium dev page:</p>\n<h1>Compilation failures</h1>\n<p>Some common things to think about when you have weird c...
2008/11/11
[ "https://Stackoverflow.com/questions/281719", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13842/" ]
I am quantitatively studying various metrics associated with automated tests. Chrome seems to have a reasonable set, so I wanted to add it to my data set. I downloaded the Chrome source code and tried to build it with VisualStudio but got several hundred errors--types not defined, identifiers not defined, etc. Has anyo...
From the Chromium dev page: Compilation failures ==================== Some common things to think about when you have weird compilation failures: * Make sure you have SP1 for Visual Studio 2005. It's required. Really. * Sometimes Visual Studio does the wrong thing when building Chromium and gets stuck on a bogus err...
281,725
<p>I want to make this specialized w/o changing main. Is it possible to specialize something based on its base class? I hope so.</p> <p>-edit-</p> <p>I'll have several classes that inherit from SomeTag. I don't want to write the same specialization for each of them.</p> <pre><code>class SomeTag {}; class InheritSome...
[ { "answer_id": 281795, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 2, "selected": false, "text": "<p>In your case, the only way that I see would be to explicitly specialize <code>MyClass</code> for <code>InheritSome...
2008/11/11
[ "https://Stackoverflow.com/questions/281725", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I want to make this specialized w/o changing main. Is it possible to specialize something based on its base class? I hope so. -edit- I'll have several classes that inherit from SomeTag. I don't want to write the same specialization for each of them. ``` class SomeTag {}; class InheritSomeTag : public SomeTag {}; te...
This article describes a neat trick: <http://www.gotw.ca/publications/mxc++-item-4.htm> Here's the basic idea. You first need an IsDerivedFrom class (this provides runtime and compile-time checking): ``` template<typename D, typename B> class IsDerivedFrom { class No { }; class Yes { No no[3]; }; static Yes T...
281,743
<p>I have a client which is shipping via UPS, and therefore cannot deliver to Post Office boxes. I would like to be able to validate customer address fields in order to prevent them from entering addresses which include a PO box. It would be best if this were implemented as a regex so that I could use a client-side reg...
[ { "answer_id": 281753, "author": "Bill the Lizard", "author_id": 1288, "author_profile": "https://Stackoverflow.com/users/1288", "pm_score": 3, "selected": true, "text": "<p>This should get you started. Test to see if the Address field matches this regex.</p>\n\n<pre><code>\"^P\\.?\\s?O...
2008/11/11
[ "https://Stackoverflow.com/questions/281743", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13583/" ]
I have a client which is shipping via UPS, and therefore cannot deliver to Post Office boxes. I would like to be able to validate customer address fields in order to prevent them from entering addresses which include a PO box. It would be best if this were implemented as a regex so that I could use a client-side regex ...
This should get you started. Test to see if the Address field matches this regex. ``` "^P\.?\s?O\.?\sB[Oo][Xx]." ``` Translation to English: That's a P at the beginning of the line, followed by an optional period and space, followed by an O, followed by an optional period, followed by a space, followed by "Box", fol...
281,744
<p>Can someone explain how exactly prepared connection pooling using dbcp can be used? (with some example code if possible). I've figured out how to turn it on - passing a KeyedObjectPoolFactory to the PoolableConnectionFactory. But how should the specific prepared statements be defined after that? Right now I'm only ...
[ { "answer_id": 282135, "author": "Georgy Bolyuba", "author_id": 4052, "author_profile": "https://Stackoverflow.com/users/4052", "pm_score": 4, "selected": true, "text": "<p>Well talking about getting connection from the pool vs getting \"not-pooled\" connection, do you have any change in...
2008/11/11
[ "https://Stackoverflow.com/questions/281744", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12649/" ]
Can someone explain how exactly prepared connection pooling using dbcp can be used? (with some example code if possible). I've figured out how to turn it on - passing a KeyedObjectPoolFactory to the PoolableConnectionFactory. But how should the specific prepared statements be defined after that? Right now I'm only usi...
Well talking about getting connection from the pool vs getting "not-pooled" connection, do you have any change in your code :)? I bet you do not. Same way with prepared statements. Your code should not change. So, there is no useful code example to this. You should read docs for your JDBC Datasource implementation and...
281,758
<p>I'm working on a Spring MVC project, and I have unit tests for all of the various components in the source tree.</p> <p>For example, if I have a controller <code>HomeController</code>, which needs to have a <code>LoginService</code> injected into it, then in my unit test <code>HomeControllerTest</code> I simply ins...
[ { "answer_id": 281841, "author": "Ken Gentle", "author_id": 8709, "author_profile": "https://Stackoverflow.com/users/8709", "pm_score": 6, "selected": true, "text": "<p>I can't speak to being a best practice, but here's what I've done in the past.</p>\n\n<p><strong>Unit tests:</strong></...
2008/11/11
[ "https://Stackoverflow.com/questions/281758", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4249/" ]
I'm working on a Spring MVC project, and I have unit tests for all of the various components in the source tree. For example, if I have a controller `HomeController`, which needs to have a `LoginService` injected into it, then in my unit test `HomeControllerTest` I simply instantiate the object as normal (outside of S...
I can't speak to being a best practice, but here's what I've done in the past. **Unit tests:** * Create unit tests for non-trivial beans (ie, most of your Spring related beans) * Use Mocks for injected services where practical (ie, most if not all the time). * Use a standard naming convention for these tests in the p...
281,787
<p>What's the best way to output the public contents of an object to a human-readable file? I'm looking for a way to do this that would not require me to know of all the members of the class, but rather use the compiler to tell me what members exist, and what their names are. There have to be macros or something like t...
[ { "answer_id": 281807, "author": "arul", "author_id": 15409, "author_profile": "https://Stackoverflow.com/users/15409", "pm_score": 2, "selected": true, "text": "<p>Take a look at <a href=\"http://s11n.net\" rel=\"nofollow noreferrer\">this library</a> .</p>\n" }, { "answer_id": ...
2008/11/11
[ "https://Stackoverflow.com/questions/281787", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22724/" ]
What's the best way to output the public contents of an object to a human-readable file? I'm looking for a way to do this that would not require me to know of all the members of the class, but rather use the compiler to tell me what members exist, and what their names are. There have to be macros or something like that...
Take a look at [this library](http://s11n.net) .
281,811
<p>How do I test if two dates are within a certain tolerance in NUnit?</p>
[ { "answer_id": 281853, "author": "Rob Prouse", "author_id": 30827, "author_profile": "https://Stackoverflow.com/users/30827", "pm_score": 1, "selected": false, "text": "<p>Convert your tolerance to Ticks and then use an And constraint. Something like;</p>\n\n<pre><code>long ticks = mydat...
2008/11/11
[ "https://Stackoverflow.com/questions/281811", "https://Stackoverflow.com", "https://Stackoverflow.com/users/549/" ]
How do I test if two dates are within a certain tolerance in NUnit?
You may want to look at the "Within" method that lives off of the Constraint object. For example: ``` Assert.That(DateTime.Now, Is.EqualTo(DateTime.Now.AddMilliseconds(1000)).Within(101)); ``` It's usually used to give a tolerance to doubles and floats, but since in the end a DateTime is a double, it might suit you...
281,818
<p>I'm currently working on some logging code that supposed to - among other things - print information about the calling function. This should be relatively easy, standard C++ has a <code>type_info</code> class. This contains the name of the typeid'd class/function/etc. but it's mangled. It's not very useful. I.e. <co...
[ { "answer_id": 281834, "author": "Eclipse", "author_id": 8701, "author_profile": "https://Stackoverflow.com/users/8701", "pm_score": 3, "selected": false, "text": "<p>It's implementation defined, so it's not something that's going to be portable. In MSVC++, name() is the undecorated nam...
2008/11/11
[ "https://Stackoverflow.com/questions/281818", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9232/" ]
I'm currently working on some logging code that supposed to - among other things - print information about the calling function. This should be relatively easy, standard C++ has a `type_info` class. This contains the name of the typeid'd class/function/etc. but it's mangled. It's not very useful. I.e. `typeid(std::vect...
Given the attention this question / answer receives, and the valuable feedback from [GManNickG](https://stackoverflow.com/questions/281818/unmangling-the-result-of-stdtype-infoname/4541470#comment26629807_4541470), I have cleaned up the code a little bit. Two versions are given: one with C++11 features and another one ...
281,831
<p>I am porting an MFC application to .NET WinForms. In the MFC application, you can right click on a menu or on a context menu item and we show another context menu with diagnostic and configuration items. I am trying to port this functionality to .NET, but I am having trouble.</p> <p>I have been able to capture the ...
[ { "answer_id": 281883, "author": "Jason Diller", "author_id": 2187, "author_profile": "https://Stackoverflow.com/users/2187", "pm_score": 2, "selected": false, "text": "<p>You'll probably have to p/invoke the method. </p>\n\n<pre><code>[DllImport(\"user32.dll\")]\nstatic extern bool Trac...
2008/11/11
[ "https://Stackoverflow.com/questions/281831", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30827/" ]
I am porting an MFC application to .NET WinForms. In the MFC application, you can right click on a menu or on a context menu item and we show another context menu with diagnostic and configuration items. I am trying to port this functionality to .NET, but I am having trouble. I have been able to capture the right clic...
Edit, due to a comment: In: ``` protected override void OnClick(EventArgs e) { if (SecondaryContextMenu == null || MouseButtons != MouseButtons.Right) { base.OnClick(e); } } ``` this part ``` MouseButtons != MouseButtons.Right ``` should and does compile as it is a call to Control.MouseButt...
281,837
<p>I would like to parse HTML document and replace action attribute of all the forms and add some hidden fields with XSL. Can someone show some examples of XSL that can do this?</p>
[ { "answer_id": 281848, "author": "andy.gurin", "author_id": 22388, "author_profile": "https://Stackoverflow.com/users/22388", "pm_score": 0, "selected": false, "text": "<p>You can start from <a href=\"http://www.w3schools.com/xsl/\" rel=\"nofollow noreferrer\">this tutorial</a></p>\n\n<p...
2008/11/11
[ "https://Stackoverflow.com/questions/281837", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I would like to parse HTML document and replace action attribute of all the forms and add some hidden fields with XSL. Can someone show some examples of XSL that can do this?
What you need first is well formed HTML (at least transitional), although best recommended XHTML. Some XSLT processors could accept malformed HTML but it is not the rule. To try the example below you can download [this small Microsoft command line app](http://www.microsoft.com/downloads/details.aspx?FamilyId=2FB55371-...
281,843
<p>I realize you can't get the target entity in the Attribute itself, but what about in an associated Permission object when using a CodeAccessSecurityAttribute? The Permission object gets called at runtime so it seems there should be a way but I'm at a loss.</p> <pre><code>public sealed class MySecurityAttribute : C...
[ { "answer_id": 343463, "author": "Miral", "author_id": 43534, "author_profile": "https://Stackoverflow.com/users/43534", "pm_score": 0, "selected": false, "text": "<p>Well, I guess you could use reflection to scan through all the loaded assemblies, looking for any class/member that has <...
2008/11/11
[ "https://Stackoverflow.com/questions/281843", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36668/" ]
I realize you can't get the target entity in the Attribute itself, but what about in an associated Permission object when using a CodeAccessSecurityAttribute? The Permission object gets called at runtime so it seems there should be a way but I'm at a loss. ``` public sealed class MySecurityAttribute : CodeAccessSecuri...
What about walking the call stack? At least that would narrow down what you need to reflect over. Grab [System.Diagnostics.StackTrace](http://msdn.microsoft.com/en-us/library/system.diagnostics.stacktrace.aspx) and use [GetFrame](http://msdn.microsoft.com/en-us/library/system.diagnostics.stackframe.getmethod.aspx) to g...
281,847
<p>I understand that there's no universal answer to the attribute vs. element debate (and I read through the other questions I saw on this), but any insight into this particular circumstance would be greatly appreciated. </p> <p>In our case we're going to be receiving very large amounts of master and transactional da...
[ { "answer_id": 281861, "author": "David Norman", "author_id": 34502, "author_profile": "https://Stackoverflow.com/users/34502", "pm_score": 2, "selected": true, "text": "<p>If performance is the only requirement, I think you have to go with the attributes, just because it takes up less s...
2008/11/11
[ "https://Stackoverflow.com/questions/281847", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3613/" ]
I understand that there's no universal answer to the attribute vs. element debate (and I read through the other questions I saw on this), but any insight into this particular circumstance would be greatly appreciated. In our case we're going to be receiving very large amounts of master and transactional data from a s...
If performance is the only requirement, I think you have to go with the attributes, just because it takes up less space. I don't see any advantage to the elements.
281,864
<p>I have a function that checks if a cookie (by name) exists or not:</p> <pre><code>Private Function cookieExists(ByVal cName As String) As Boolean For Each c As HttpCookie In Response.Cookies If c.Name = cName Then Return True Next Return False End Function </code></pre> <p>I have a class that h...
[ { "answer_id": 281872, "author": "Gordon Bell", "author_id": 16473, "author_profile": "https://Stackoverflow.com/users/16473", "pm_score": 5, "selected": true, "text": "<pre><code>HttpContext.Current.Response\nHttpContext.Current.Request\n</code></pre>\n" }, { "answer_id": 281879...
2008/11/11
[ "https://Stackoverflow.com/questions/281864", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25515/" ]
I have a function that checks if a cookie (by name) exists or not: ``` Private Function cookieExists(ByVal cName As String) As Boolean For Each c As HttpCookie In Response.Cookies If c.Name = cName Then Return True Next Return False End Function ``` I have a class that handles cookies in an appli...
``` HttpContext.Current.Response HttpContext.Current.Request ```
281,866
<p>Often you need to show a list of database items and certain aggregate numbers about each item. For instance, when you type the title text on Stack Overflow, the Related Questions list appears. The list shows the titles of related entries and the single aggregated number of quantity of responses for each title.</p> ...
[ { "answer_id": 281894, "author": "Bill Karwin", "author_id": 20860, "author_profile": "https://Stackoverflow.com/users/20860", "pm_score": 4, "selected": true, "text": "<p>Here's a trick: calculating a <code>SUM()</code> of values that are known to be either 1 or 0 is equivalent to a <c...
2008/11/11
[ "https://Stackoverflow.com/questions/281866", "https://Stackoverflow.com", "https://Stackoverflow.com/users/356/" ]
Often you need to show a list of database items and certain aggregate numbers about each item. For instance, when you type the title text on Stack Overflow, the Related Questions list appears. The list shows the titles of related entries and the single aggregated number of quantity of responses for each title. I have ...
Here's a trick: calculating a `SUM()` of values that are known to be either 1 or 0 is equivalent to a `COUNT()` of the rows where the value is 1. And you know that a boolean comparison returns 1 or 0 (or NULL). ``` SELECT c.catname, COUNT(m.catid) AS item_count, SUM(i.ownerid = @ownerid) AS owner_item_count FROM cat...
281,881
<p>I am trying to keep track of something and using the SessionID as they key to that object</p> <p>However the SessionID every 2-3 reqiests changes shouldn't it remain the same?</p> <pre><code>HttpContext.Session.SessionID </code></pre> <p>Is the code I am using.</p>
[ { "answer_id": 281917, "author": "MrJavaGuy", "author_id": 7138, "author_profile": "https://Stackoverflow.com/users/7138", "pm_score": 2, "selected": false, "text": "<p>I would look into using TempData to keep track of something.</p>\n" }, { "answer_id": 283321, "author": "Hr...
2008/11/11
[ "https://Stackoverflow.com/questions/281881", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22093/" ]
I am trying to keep track of something and using the SessionID as they key to that object However the SessionID every 2-3 reqiests changes shouldn't it remain the same? ``` HttpContext.Session.SessionID ``` Is the code I am using.
I've seen that happen even without MVC. If I remember correctly, ASP.NET keeps assigning new session ids until you place something into the Session variable.
281,888
<p>In Python, how do I jump to a file in the Windows Explorer? I found a solution for jumping to folders:</p> <pre><code>import subprocess subprocess.Popen('explorer "C:\path\of\folder"') </code></pre> <p>but I have no solution for files.</p>
[ { "answer_id": 281911, "author": "Blair Conrad", "author_id": 1199, "author_profile": "https://Stackoverflow.com/users/1199", "pm_score": 8, "selected": true, "text": "<p>From <a href=\"http://www.geoffchappell.com/studies/windows/shell/explorer/cmdline.htm\" rel=\"noreferrer\">Geoff Cha...
2008/11/11
[ "https://Stackoverflow.com/questions/281888", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25705/" ]
In Python, how do I jump to a file in the Windows Explorer? I found a solution for jumping to folders: ``` import subprocess subprocess.Popen('explorer "C:\path\of\folder"') ``` but I have no solution for files.
From [Geoff Chappell's *The Windows Explorer Command Line*](http://www.geoffchappell.com/studies/windows/shell/explorer/cmdline.htm) ``` import subprocess subprocess.Popen(r'explorer /select,"C:\path\of\folder\file"') ```
281,890
<p>There are Hibernate tools for mapping files to ddl generation; ddl to mapping files and so on, but I can't find any command line tools for simple DDL generation from JPA annotated classes.</p> <p>Does anyone know an easy way to do this? (Not using Ant or Maven workarounds)</p>
[ { "answer_id": 497798, "author": "Kariem", "author_id": 12039, "author_profile": "https://Stackoverflow.com/users/12039", "pm_score": 3, "selected": false, "text": "<p>I'm not sure, whether this is considered a workaround, because you already referred to it in your question. You can use ...
2008/11/11
[ "https://Stackoverflow.com/questions/281890", "https://Stackoverflow.com", "https://Stackoverflow.com/users/450527/" ]
There are Hibernate tools for mapping files to ddl generation; ddl to mapping files and so on, but I can't find any command line tools for simple DDL generation from JPA annotated classes. Does anyone know an easy way to do this? (Not using Ant or Maven workarounds)
I'm not sure, whether this is considered a workaround, because you already referred to it in your question. You can use [Hibernate Tools](http://tools.hibernate.org/) to generate DDL from JPA annotated classes. You just need hibernate tools and its dependencies on the classpath and should be fine with something like th...
281,891
<p>I'm using ASP.NET Membership and noticed there isn't a method in the <a href="http://msdn.microsoft.com/en-us/library/system.web.security.roles_members.aspx" rel="nofollow noreferrer">Roles class</a> to <em>modify</em> a role (its name for instance), only to create and delete them.</p> <p>Is it possible or it's not...
[ { "answer_id": 281907, "author": "Harper Shelby", "author_id": 21196, "author_profile": "https://Stackoverflow.com/users/21196", "pm_score": 3, "selected": false, "text": "<p>Renaming a Role in the ASP.NET Membership model programatically would be a Bad Thing&trade;, because the Role nam...
2008/11/11
[ "https://Stackoverflow.com/questions/281891", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1782/" ]
I'm using ASP.NET Membership and noticed there isn't a method in the [Roles class](http://msdn.microsoft.com/en-us/library/system.web.security.roles_members.aspx) to *modify* a role (its name for instance), only to create and delete them. Is it possible or it's not supported? EDIT: @CheGueVerra: Yes, nice workaround....
There is no direct way to change a role name in the Membership provider. I would get the list of users that are in the role you want to rename, then remove them from the list, delete the role, create the role with the new name and then Add the users found earlier to the role with the new name. ``` public void RenameR...
281,909
<p>let's say I have a excel spread sheet like below:</p> <pre> col1 col2 ------------ dog1 dog dog2 dog dog3 dog dog4 dog cat1 cat cat2 cat cat3 cat </pre> <p>I want to return a range of cells (dog1,dog2,dog3,dog4) or (cat1,cat2,cat3) based on either "dog" or "cat"</p> <p>I know I can do a loop to ch...
[ { "answer_id": 281971, "author": "DJ.", "author_id": 10492, "author_profile": "https://Stackoverflow.com/users/10492", "pm_score": 1, "selected": false, "text": "<p>This guy has a nice FindAll function:</p>\n\n<p><a href=\"http://www.cpearson.com/excel/findall.aspx\" rel=\"nofollow noref...
2008/11/11
[ "https://Stackoverflow.com/questions/281909", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36674/" ]
let's say I have a excel spread sheet like below: ``` col1 col2 ------------ dog1 dog dog2 dog dog3 dog dog4 dog cat1 cat cat2 cat cat3 cat ``` I want to return a range of cells (dog1,dog2,dog3,dog4) or (cat1,cat2,cat3) based on either "dog" or "cat" I know I can do a loop to check one by one, but ...
Here are some notes on using a recordset to return the range. ``` Sub GetRange() Dim cn As Object Dim rs As Object Dim strcn, strFile, strPos1, strPos2 Set cn = CreateObject("ADODB.Connection") Set rs = CreateObject("ADODB.Recordset") strFile = ActiveWorkbook.FullName strcn = "Provider=Microsoft.Jet...
281,914
<p>This is as much a code maintenance issue as a code issue, but I have a WebForm that no longer checks it CustomValidator. It worked when I last touched the code over a year ago, but it no longer works now that the user has requested some changes ...</p> <p>The WebForm contains a data-bound drop down with a default "...
[ { "answer_id": 281919, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 0, "selected": false, "text": "<p>Some troubleshooting steps:</p>\n\n<ul>\n<li>Is this the only validator on the form? </li>\n<li>Is validation enab...
2008/11/11
[ "https://Stackoverflow.com/questions/281914", "https://Stackoverflow.com", "https://Stackoverflow.com/users/470/" ]
This is as much a code maintenance issue as a code issue, but I have a WebForm that no longer checks it CustomValidator. It worked when I last touched the code over a year ago, but it no longer works now that the user has requested some changes ... The WebForm contains a data-bound drop down with a default " - All -" ...
I notice a couple of issues * I don't think you need a CausesValidation=true if AutoPostBack is set to false * You do not use validation groups, so that cannot be the cause * Why not use a RequiredFieldValidator? * If you want to fire validation on empty fields, set the ValidateEmptyText property to true
281,922
<p>I'm building a program that has a class used locally, but I want the same class to be used the same way over the network. This means I need to be able to make synchronous calls to any of its public methods. The class reads and writes files, so I think XML-RPC is too much overhead. I created a basic rpc client/server...
[ { "answer_id": 281991, "author": "eswald", "author_id": 21229, "author_profile": "https://Stackoverflow.com/users/21229", "pm_score": 2, "selected": false, "text": "<p>For a synchronous client, Twisted probably isn't the right option. Instead, you might want to use the socket module dir...
2008/11/11
[ "https://Stackoverflow.com/questions/281922", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35247/" ]
I'm building a program that has a class used locally, but I want the same class to be used the same way over the network. This means I need to be able to make synchronous calls to any of its public methods. The class reads and writes files, so I think XML-RPC is too much overhead. I created a basic rpc client/server us...
If you're even considering Pyro, check out [RPyC](http://rpyc.wikidot.com/) first, and re-consider XML-RPC. Regarding Twisted: try leaving the reactor up instead of stopping it, and just `ClientCreator(...).connectTCP(...)` each time. If you `self.transport.loseConnection()` in your Protocol you won't be leaving open...
281,928
<p>I often find myself writing simple for loops to perform an operation to many files, for example:</p> <pre><code>for i in `find . | grep ".xml$"`; do bzip2 $i; done </code></pre> <p>It seems a bit depressing that on my 4-core machine only one core is getting used.. is there an easy way I can add parallelism to my s...
[ { "answer_id": 281952, "author": "Tom Ritter", "author_id": 8435, "author_profile": "https://Stackoverflow.com/users/8435", "pm_score": 1, "selected": false, "text": "<p>I think you could to the following</p>\n\n<blockquote>\n<pre><code>for i in `find . | grep \".xml$\"`; do bzip2 $i&amp...
2008/11/11
[ "https://Stackoverflow.com/questions/281928", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27074/" ]
I often find myself writing simple for loops to perform an operation to many files, for example: ``` for i in `find . | grep ".xml$"`; do bzip2 $i; done ``` It seems a bit depressing that on my 4-core machine only one core is getting used.. is there an easy way I can add parallelism to my shell scripting? EDIT: To ...
If you had to solve the problem today you would probably use a tool like GNU Parallel (unless there is a specialized parallelized tool for your task like `pbzip2`): ``` find . | grep ".xml$" | parallel bzip2 ``` To learn more: * Watch the intro video for a quick introduction: <https://www.youtube.com/playlist?list...
281,933
<p>Given a word, I've to replace some specific alphabets with some specific letters such as 1 for a, 5 for b etc. I'm using regex for this. I understand that StringBuilder is the best way to deal with this problem as I'm doing a lot of string manipulations. Here is what I'm doing:</p> <pre><code>String word = "foobooa...
[ { "answer_id": 281949, "author": "auramo", "author_id": 4110, "author_profile": "https://Stackoverflow.com/users/4110", "pm_score": 1, "selected": false, "text": "<p>I don't know if StringBuilder is the tool for you here. I'd consider looking at <a href=\"http://java.sun.com/j2se/1.4.2/d...
2008/11/11
[ "https://Stackoverflow.com/questions/281933", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33203/" ]
Given a word, I've to replace some specific alphabets with some specific letters such as 1 for a, 5 for b etc. I'm using regex for this. I understand that StringBuilder is the best way to deal with this problem as I'm doing a lot of string manipulations. Here is what I'm doing: ``` String word = "foobooandfoo"; String...
I think this is a case where clarity and performance happily coincide. I would use a lookup table to do the "translation". ``` public static void translate(StringBuilder str, char[] table) { for (int idx = 0; idx < str.length(); ++idx) { char ch = str.charAt(idx); if (ch < table.length) { c...
281,945
<p>Does anyone know of a way to store values as NVARCHAR in a manually created query in ColdFusion using the querynew() function? I have multiple parts of a largish program relying on using a query as an input point to construct an excel worksheet (using Ben's POI) so it's somewhat important I can continue to use it a...
[ { "answer_id": 282260, "author": "Adam Tuttle", "author_id": 751, "author_profile": "https://Stackoverflow.com/users/751", "pm_score": 1, "selected": false, "text": "<p>The only thing I've been able to come up with so far is this:</p>\n\n<pre><code>&lt;cfset x = QueryNew(\"foobar\")/&gt;...
2008/11/11
[ "https://Stackoverflow.com/questions/281945", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16631/" ]
Does anyone know of a way to store values as NVARCHAR in a manually created query in ColdFusion using the querynew() function? I have multiple parts of a largish program relying on using a query as an input point to construct an excel worksheet (using Ben's POI) so it's somewhat important I can continue to use it as a ...
When creating a ColdFusion query with queryNew(), you can pass a list of datatypes as a second argument. For example: ``` <cfset x = queryNew("foo,bar","integer,varchar") /> ``` Alternatively, you can use cf\_sql\_varchar (which you would use in queryparam tags). According to the livedocs, nvarchar is accepted for t...
281,951
<p>We're using the following command line from within a Windows Service developed with C# .Net Framework 1.1:</p> <pre><code>net use z: \\myComputer\c$ </code></pre> <p>The service is running under a domain account that is a local administrator on "myComputer". After debugging the code we can see that it does not ret...
[ { "answer_id": 281959, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 0, "selected": false, "text": "<p>You probably need to specify the account used for the login. Type <code>net use /?</code> on a command prompt to g...
2008/11/11
[ "https://Stackoverflow.com/questions/281951", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
We're using the following command line from within a Windows Service developed with C# .Net Framework 1.1: ``` net use z: \\myComputer\c$ ``` The service is running under a domain account that is a local administrator on "myComputer". After debugging the code we can see that it does not return any errors but the "z:...
From <http://msdn.microsoft.com/en-us/library/ms685143.aspx>: > > A service (or any process running in a > different security context) that must > access a remote resource should use > the Universal Naming Convention (UNC) > name to access the resource. The > service must have appropriate > privileges to access...
281,960
<p>I would like the value of the input text box to be highlighted when it gains focus, either by clicking it or tabbing to it.</p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;script&gt; function focusTest(el) { el.select(); } &lt;/script&gt; &lt;input type="text" value="one" OnFocus="focusTest(this); return false;" ...
[ { "answer_id": 281965, "author": "Kon", "author_id": 22303, "author_profile": "https://Stackoverflow.com/users/22303", "pm_score": 0, "selected": false, "text": "<p>Not sure about a Safari-specific solution here, but an alternative would be to wrap the input element in a div and set the ...
2008/11/11
[ "https://Stackoverflow.com/questions/281960", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2749/" ]
I would like the value of the input text box to be highlighted when it gains focus, either by clicking it or tabbing to it. ``` <html> <body> <script> function focusTest(el) { el.select(); } </script> <input type="text" value="one" OnFocus="focusTest(this); return false;" /> <br/> <input type="text" value="two" O...
I noticed Safari is actually selecting the text then removing the selection quickly. So I tried this quick workaround that works in all browsers: ``` function focusTest(el) { setTimeout (function () {el.select();} , 50 ); } ``` Edit : Upon further testing it turns out the OnMouseUp event is clearing the select...
282,014
<p>I have an object that starts a thread, opens a file, and waits for input from other classes. As it receives input, it writes it to disk. Basically, it's a thread safe data logging class...</p> <p>Here's the weird part. When I open a form in the designer (Visual&nbsp;Studio&nbsp;2008) that uses the object the file ...
[ { "answer_id": 282031, "author": "Tigraine", "author_id": 21699, "author_profile": "https://Stackoverflow.com/users/21699", "pm_score": 0, "selected": false, "text": "<p>There are some things you shouldn't do with the designer. I don't have any hard evidence, but I found that the Windows...
2008/11/11
[ "https://Stackoverflow.com/questions/282014", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36693/" ]
I have an object that starts a thread, opens a file, and waits for input from other classes. As it receives input, it writes it to disk. Basically, it's a thread safe data logging class... Here's the weird part. When I open a form in the designer (Visual Studio 2008) that uses the object the file gets created. It's ob...
You can check the UsageMode of the LicenseManager, to check if the code is in design time or not. System.ComponentModel.LicenseManager.UsageMode == System.ComponentModel.LicenseUsageMode.Designtime Here is a quick example: ``` using System; using System.ComponentModel; using System.Windows.Forms; namespace Test { ...
282,016
<p>I need to make a piece of C# code interact through COM with all kinds of implementations.</p> <p>To make it easeier for users of that integration, I included the interacted interfaces in IDL (as part of a relevant existing DLL, but without coclass or implementation), then got that into my C# code by running Tlbimp ...
[ { "answer_id": 282325, "author": "Juan Zamudio", "author_id": 15058, "author_profile": "https://Stackoverflow.com/users/15058", "pm_score": 0, "selected": false, "text": "<p>I think you need this on the interface</p>\n\n<pre><code>[InterfaceType(ComInterfaceType.InterfaceIsDual)]\n</code...
2008/11/11
[ "https://Stackoverflow.com/questions/282016", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36694/" ]
I need to make a piece of C# code interact through COM with all kinds of implementations. To make it easeier for users of that integration, I included the interacted interfaces in IDL (as part of a relevant existing DLL, but without coclass or implementation), then got that into my C# code by running Tlbimp to create ...
Again - thanks for the suggestions. I was able to finally resolve the issue on my own. I tried the above suggestions and didn't made any progress. Then I changed the namespace of the interop in the 'testing' code - it varied from the one in the main code because of different argument use when using Tlbimp. This solved...
282,018
<p>I'm doing some maintenance on a private svn server. Authentication is handled through Apache basic HTTP+mod_authz_svn. I need to have it so every user has read/write access, except for a single read-only user. The read-only user still needs to be authenticated, though. I setup my authz config file like this:</p> <p...
[ { "answer_id": 282052, "author": "Martin v. Löwis", "author_id": 33006, "author_profile": "https://Stackoverflow.com/users/33006", "pm_score": 3, "selected": false, "text": "<p>In this case, the read-only user has still write access as it also matches the * group.</p>\n\n<p>A safe way to...
2008/11/11
[ "https://Stackoverflow.com/questions/282018", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36683/" ]
I'm doing some maintenance on a private svn server. Authentication is handled through Apache basic HTTP+mod\_authz\_svn. I need to have it so every user has read/write access, except for a single read-only user. The read-only user still needs to be authenticated, though. I setup my authz config file like this: ``` [/]...
In this case, the read-only user has still write access as it also matches the \* group. A safe way to achieve what you want is to create a group of all users except read-only, e.g. ``` [groups] all-but-ro = harry, sally, ... [/] @all-but-ro = rw read-only = r ``` (alternatively, you might just generate many =rw l...
282,019
<p>I would like to declare a record in Delphi that contains the same layout as it has in C.</p> <p>For those interested : This record is part of a union in the Windows OS's LDT_ENTRY record. (I need to use this record in Delphi because I'm working on an Xbox emulator in Delphi - see project Dxbx on sourceforge).</p> ...
[ { "answer_id": 282048, "author": "Lasse V. Karlsen", "author_id": 267, "author_profile": "https://Stackoverflow.com/users/267", "pm_score": 0, "selected": false, "text": "<p>Well, you basically need to get down to the dirty with bit-manipulation.</p>\n\n<p>Why, specifically, do you need ...
2008/11/11
[ "https://Stackoverflow.com/questions/282019", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12170/" ]
I would like to declare a record in Delphi that contains the same layout as it has in C. For those interested : This record is part of a union in the Windows OS's LDT\_ENTRY record. (I need to use this record in Delphi because I'm working on an Xbox emulator in Delphi - see project Dxbx on sourceforge). Anyway, the r...
Thanks everyone! Based on this information, I reduced this to : ``` RBits = record public BaseMid: BYTE; private Flags: WORD; function GetBits(const aIndex: Integer): Integer; procedure SetBits(const aIndex: Integer; const aValue: Integer); public BaseHi: BYTE; property _Type: Integer index $0005 read Get...
282,023
<p>I am trying to audit the action that the user performed that resulted in changes to corresponding tables. For example if a user were to transfer money between 2 accounts this would generate the following sequence of events:</p> <ol> <li>Insert transfer amount into Transfer table</li> <li>Subtract transfer amount fr...
[ { "answer_id": 282071, "author": "zmf", "author_id": 13285, "author_profile": "https://Stackoverflow.com/users/13285", "pm_score": 1, "selected": false, "text": "<p>Seems like the relationship between parentAuditRecord and transferauditrecord and balance auditrecord shouldn't be one to m...
2008/11/11
[ "https://Stackoverflow.com/questions/282023", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36670/" ]
I am trying to audit the action that the user performed that resulted in changes to corresponding tables. For example if a user were to transfer money between 2 accounts this would generate the following sequence of events: 1. Insert transfer amount into Transfer table 2. Subtract transfer amount from balance in Balan...
Seems like the relationship between parentAuditRecord and transferauditrecord and balance auditrecord shouldn't be one to many. When I read what you typed I'm seeing it as a table per subclass usage of that audit hierarchy which is a one-to-one relationship. <http://www.hibernate.org/hib_docs/reference/en/html/inherit...
282,024
<p>So I'm generating a random number using Rnd and Randomize to set a seed that looks like this:</p> <pre><code>Randomize lSeed Response.Write Rnd </code></pre> <p>I'm noticing that it's returning the same result for two values in a row for lSeed (e.g. 123, 124) but then on say 125 it will return a new value but 126 ...
[ { "answer_id": 282027, "author": "FlySwat", "author_id": 1965, "author_profile": "https://Stackoverflow.com/users/1965", "pm_score": 0, "selected": false, "text": "<p>You should reseed before getting a random value each time. I'd recommend seeding to a timer.</p>\n" }, { "answer_...
2008/11/11
[ "https://Stackoverflow.com/questions/282024", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12261/" ]
So I'm generating a random number using Rnd and Randomize to set a seed that looks like this: ``` Randomize lSeed Response.Write Rnd ``` I'm noticing that it's returning the same result for two values in a row for lSeed (e.g. 123, 124) but then on say 125 it will return a new value but 126 will be the same as the on...
The issue was that the value for the seed was too large in the other environment (an incrementing database value). I ended up doing value Mod 100 to get something semi-random and that was going to be low to always work.