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
18,685
<p>Can anyone tell me how I can display a status message like "12 seconds ago" or "5 minutes ago" etc in a web page?</p>
[ { "answer_id": 18693, "author": "Niyaz", "author_id": 184, "author_profile": "https://Stackoverflow.com/users/184", "pm_score": 7, "selected": true, "text": "<p>Here is the php code for the same:</p>\n\n<pre><code>function time_since($since) {\n $chunks = array(\n array(60 * 60...
2008/08/20
[ "https://Stackoverflow.com/questions/18685", "https://Stackoverflow.com", "https://Stackoverflow.com/users/184/" ]
Can anyone tell me how I can display a status message like "12 seconds ago" or "5 minutes ago" etc in a web page?
Here is the php code for the same: ``` function time_since($since) { $chunks = array( array(60 * 60 * 24 * 365 , 'year'), array(60 * 60 * 24 * 30 , 'month'), array(60 * 60 * 24 * 7, 'week'), array(60 * 60 * 24 , 'day'), array(60 * 60 , 'hour'), array(60 , 'minute'), ...
18,754
<p>I'm writing some documentation in Markdown, and creating a separate file for each section of the doc. I would like to be able to convert all the files to HTML in one go, but I can't find anyone else who has tried the same thing. I'm on a Mac, so I would think a simple bash script should be able to handle it, but I...
[ { "answer_id": 18775, "author": "Julio César", "author_id": 2148, "author_profile": "https://Stackoverflow.com/users/2148", "pm_score": -1, "selected": false, "text": "<p>I use this in a .bat file:</p>\n\n<pre><code>@echo off\nfor %i in (*.txt) python markdown.py \"%i\"\n</code></pre>\n"...
2008/08/20
[ "https://Stackoverflow.com/questions/18754", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2185/" ]
I'm writing some documentation in Markdown, and creating a separate file for each section of the doc. I would like to be able to convert all the files to HTML in one go, but I can't find anyone else who has tried the same thing. I'm on a Mac, so I would think a simple bash script should be able to handle it, but I've n...
This is how you would do it in Bash. ``` for i in ./*.markdown; do perl markdown.pl --html4tags $i > $i.html; done; ``` Of course, you need the [Markdown script](http://daringfireball.net/projects/markdown/).
18,757
<p>The Add view and the Edit view are often incredibly similar that it is unwarranted to write 2 views. As the app evolves you would be making the same changes to both.</p> <p>However, there are usually subtle differences. For instance, a field might be read-only once it's been added, and if that field is a DropDownLi...
[ { "answer_id": 18876, "author": "Andrew Rimmer", "author_id": 1982, "author_profile": "https://Stackoverflow.com/users/1982", "pm_score": 2, "selected": false, "text": "<p>I don't like the Views to become too complex, and so far I have tended to have separate views for Edit and Add. I us...
2008/08/20
[ "https://Stackoverflow.com/questions/18757", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1851/" ]
The Add view and the Edit view are often incredibly similar that it is unwarranted to write 2 views. As the app evolves you would be making the same changes to both. However, there are usually subtle differences. For instance, a field might be read-only once it's been added, and if that field is a DropDownList you no ...
It's pretty easy really. Let's assume you're editing a blog post. Here's your 2 actions for new/edit: ``` public class BlogController : Controller { public ActionResult New() { var post = new Post(); return View("Edit", post); } public ActionResult Edit(int id) { var post = _reposito...
18,764
<p>Since both a <code>Table Scan</code> and a <code>Clustered Index Scan</code> essentially scan all records in the table, why is a Clustered Index Scan supposedly better?</p> <p>As an example - what's the performance difference between the following when there are many records?:</p> <pre><code>declare @temp table( ...
[ { "answer_id": 18782, "author": "DrPizza", "author_id": 2131, "author_profile": "https://Stackoverflow.com/users/2131", "pm_score": -1, "selected": false, "text": "<p>A table scan has to examine every single row of the table. The clustered index scan only needs to scan the index. It do...
2008/08/20
[ "https://Stackoverflow.com/questions/18764", "https://Stackoverflow.com", "https://Stackoverflow.com/users/357/" ]
Since both a `Table Scan` and a `Clustered Index Scan` essentially scan all records in the table, why is a Clustered Index Scan supposedly better? As an example - what's the performance difference between the following when there are many records?: ``` declare @temp table( SomeColumn varchar(50) ) insert into @t...
In a table without a clustered index (a heap table), data pages are not linked together - so traversing pages requires a [lookup into the Index Allocation Map](http://msdn.microsoft.com/en-us/library/ms188270.aspx). A clustered table, however, has it's [data pages linked in a doubly linked list](http://msdn.microsoft....
18,765
<p>I'm currently working on creating a new C# project that needs to interact with an older C++ application. There is an error enumeration that already exists in the C++ app that I need to use in the C# app.</p> <p><em>I don't want to just re declare the enumeration in C# because that could cause sync issues down the l...
[ { "answer_id": 18774, "author": "Adam Haile", "author_id": 194, "author_profile": "https://Stackoverflow.com/users/194", "pm_score": 2, "selected": false, "text": "<p>Simple answer is going to be no. Sorry, you are going to have to re-declare.</p>\n\n<p>I have, in the past however, writ...
2008/08/20
[ "https://Stackoverflow.com/questions/18765", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2191/" ]
I'm currently working on creating a new C# project that needs to interact with an older C++ application. There is an error enumeration that already exists in the C++ app that I need to use in the C# app. *I don't want to just re declare the enumeration in C# because that could cause sync issues down the line if the fi...
Check out the PInvoke Interop Assistant tool <http://www.codeplex.com/clrinterop/Release/ProjectReleases.aspx?ReleaseId=14120>. Its a useful tool for generating PInvoke signatures for native methods. If I feed it your enum it generates this code. There is a command line version of the tool included so you could poten...
18,787
<p>When a controller renders a view based on a model you can get the properties from the ViewData collection using the indexer (ie. ViewData["Property"]). However, I have a shared user control that I tried to call using the following:</p> <pre><code>return View("Message", new { DisplayMessage = "This is a test" }); <...
[ { "answer_id": 18830, "author": "Ryan Eastabrook", "author_id": 105, "author_profile": "https://Stackoverflow.com/users/105", "pm_score": 2, "selected": false, "text": "<p>Of course after I create this question I immediately find the answer after a few more searches on Google</p>\n\n<p><...
2008/08/20
[ "https://Stackoverflow.com/questions/18787", "https://Stackoverflow.com", "https://Stackoverflow.com/users/105/" ]
When a controller renders a view based on a model you can get the properties from the ViewData collection using the indexer (ie. ViewData["Property"]). However, I have a shared user control that I tried to call using the following: ``` return View("Message", new { DisplayMessage = "This is a test" }); ``` and on my ...
The method ``` ViewData.Eval("DisplayMessage") ``` should work for you.
18,836
<p>I'm looking for shell scripts files installed on my system, but <strong>find</strong> doesn't work:</p> <pre><code>$ find /usr -name *.sh </code></pre> <p>But I know there are a ton of scripts out there. For instance:</p> <pre><code>$ ls /usr/local/lib/*.sh /usr/local/lib/tclConfig.sh /usr/local/lib/tkConfig.s...
[ { "answer_id": 18837, "author": "Jon Ericson", "author_id": 1438, "author_profile": "https://Stackoverflow.com/users/1438", "pm_score": 7, "selected": true, "text": "<p>Try quoting the wildcard:</p>\n\n<pre><code>$ find /usr -name \\*.sh\n</code></pre>\n\n<p>or:</p>\n\n<pre><code>$ find ...
2008/08/20
[ "https://Stackoverflow.com/questions/18836", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1438/" ]
I'm looking for shell scripts files installed on my system, but **find** doesn't work: ``` $ find /usr -name *.sh ``` But I know there are a ton of scripts out there. For instance: ``` $ ls /usr/local/lib/*.sh /usr/local/lib/tclConfig.sh /usr/local/lib/tkConfig.sh ``` Why doesn't **find** work?
Try quoting the wildcard: ``` $ find /usr -name \*.sh ``` or: ``` $ find /usr -name '*.sh' ``` If you happen to have a file that matches **\*.sh** in the current working directory, the wildcard will be expanded before find sees it. If you happen to have a file named tkConfig.sh in your working directory, the **fi...
18,858
<p>Does anyone here know of good batch file code indenters or beautifiers?</p> <p>Specifically for PHP, JS and SGML-languages.</p> <p>Preferably with options as to style.</p>
[ { "answer_id": 18837, "author": "Jon Ericson", "author_id": 1438, "author_profile": "https://Stackoverflow.com/users/1438", "pm_score": 7, "selected": true, "text": "<p>Try quoting the wildcard:</p>\n\n<pre><code>$ find /usr -name \\*.sh\n</code></pre>\n\n<p>or:</p>\n\n<pre><code>$ find ...
2008/08/20
[ "https://Stackoverflow.com/questions/18858", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2118/" ]
Does anyone here know of good batch file code indenters or beautifiers? Specifically for PHP, JS and SGML-languages. Preferably with options as to style.
Try quoting the wildcard: ``` $ find /usr -name \*.sh ``` or: ``` $ find /usr -name '*.sh' ``` If you happen to have a file that matches **\*.sh** in the current working directory, the wildcard will be expanded before find sees it. If you happen to have a file named tkConfig.sh in your working directory, the **fi...
18,861
<p>So I am writing a registration form and I need the display name to be only numbers, letters and underscores. </p> <p>Have a look at my code and tell me what I'm doing wrong.</p> <pre><code>&lt;form method="post" action="/" onsubmit="return check_form()"&gt; &lt;input type="text" id="display-name" name="display...
[ { "answer_id": 18874, "author": "AnnanFay", "author_id": 2118, "author_profile": "https://Stackoverflow.com/users/2118", "pm_score": 3, "selected": false, "text": "<p>My regexp would go along the lines of: <code>/^[a-zA-Z0-9_]+$/</code></p>\n\n<p>edit: I think it's the lack of a line end...
2008/08/20
[ "https://Stackoverflow.com/questions/18861", "https://Stackoverflow.com", "https://Stackoverflow.com/users/428190/" ]
So I am writing a registration form and I need the display name to be only numbers, letters and underscores. Have a look at my code and tell me what I'm doing wrong. ``` <form method="post" action="/" onsubmit="return check_form()"> <input type="text" id="display-name" name="display-name" maxlength="255" /> ...
Your regex ``` /^([a-zA-Z0-9_])+/ ``` Looks for 1. Start of string(check), followed by 2. 1 or more letters, numbers, or underscore (check) And then whatever comes after it doesn't matter. This regex will match anything at all so long as it begins with a letter, number, or underscore If you put a `$` at the end,...
18,912
<p>I know in JavaScript, <em>objects</em> double as hashes, but I have been unable to find a built-in function to get the keys:</p> <pre><code>var h = {a:'b', c:'d'}; </code></pre> <p>I want something like</p> <pre><code>var k = h.keys() ; // k = ['a', 'c']; </code></pre> <p>It is simple to write a function myself to i...
[ { "answer_id": 18929, "author": "danb", "author_id": 2031, "author_profile": "https://Stackoverflow.com/users/2031", "pm_score": 4, "selected": false, "text": "<p>This is the best you can do, as far as I know...</p>\n\n<pre><code>var keys = [];\nfor (var k in h)keys.push(k);\n</code></pr...
2008/08/20
[ "https://Stackoverflow.com/questions/18912", "https://Stackoverflow.com", "https://Stackoverflow.com/users/238/" ]
I know in JavaScript, *objects* double as hashes, but I have been unable to find a built-in function to get the keys: ``` var h = {a:'b', c:'d'}; ``` I want something like ``` var k = h.keys() ; // k = ['a', 'c']; ``` It is simple to write a function myself to iterate over the items and add the keys to an array t...
There is function in modern JavaScript (ECMAScript 5) called [`Object.keys`](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object/keys) performing this operation: ``` var obj = { "a" : 1, "b" : 2, "c" : 3}; alert(Object.keys(obj)); // will output ["a", "b", "c"] ``` Compatibility details can b...
18,918
<p>Im testing an ASP.NEt site. When I execute it, it starts the ASP.NET Development Server and opens up a page.</p> <p>Now I want to test it in the intranet I have. </p> <ol> <li><p>Can I use this server or I need to configure IIS in this machine? </p></li> <li><p>Do I need to configure something for it to work?</p>...
[ { "answer_id": 18919, "author": "Jason", "author_id": 1338, "author_profile": "https://Stackoverflow.com/users/1338", "pm_score": 1, "selected": false, "text": "<p>I believe the built in ASP.NET server only works on localhost. You'll have to use IIS.</p>\n" }, { "answer_id": 189...
2008/08/20
[ "https://Stackoverflow.com/questions/18918", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1013/" ]
Im testing an ASP.NEt site. When I execute it, it starts the ASP.NET Development Server and opens up a page. Now I want to test it in the intranet I have. 1. Can I use this server or I need to configure IIS in this machine? 2. Do I need to configure something for it to work? I've changed the localhost to the correc...
**Yes you can! And you don't need IIS** Just use a simple Java TCP tunnel. Download this Java app & just tunnel the traffic back. <http://jcbserver.uwaterloo.ca/cs436/software/tgui/tcpTunnelGUI.shtml> In command prompt, you'd then run the java app like this... Let's assume you want external access on port 80 and your...
18,920
<p>When opening a file from your hard drive into your browser, where is the document root? To illustrate, given the following HTML code, if the page is opened from the local machine <code>(file:///)</code> then where should the <code>css</code> file be for the browser to find it?</p> <pre><code>&lt;link href="/temp/t...
[ { "answer_id": 18924, "author": "Andy", "author_id": 1993, "author_profile": "https://Stackoverflow.com/users/1993", "pm_score": 3, "selected": true, "text": "<p>It depends on what browser you use, but Internet Explorer, for example, would take you to the root directory of your harddrive...
2008/08/20
[ "https://Stackoverflow.com/questions/18920", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1858/" ]
When opening a file from your hard drive into your browser, where is the document root? To illustrate, given the following HTML code, if the page is opened from the local machine `(file:///)` then where should the `css` file be for the browser to find it? ``` <link href="/temp/test.css" rel="stylesheet" type="text/css...
It depends on what browser you use, but Internet Explorer, for example, would take you to the root directory of your harddrive (eg. `C:/`), while browsers such as Firefox does nothing.
18,932
<p>I need to remove duplicate rows from a fairly large SQL Server table (i.e. 300,000+ rows).</p> <p>The rows, of course, will not be perfect duplicates because of the existence of the <code>RowID</code> identity field.</p> <p><strong>MyTable</strong></p> <pre><code>RowID int not null identity(1,1) primary key, Col1 va...
[ { "answer_id": 18934, "author": "Jon Galloway", "author_id": 5, "author_profile": "https://Stackoverflow.com/users/5", "pm_score": 7, "selected": false, "text": "<p>There's a good article on <a href=\"http://support.microsoft.com/kb/139444\" rel=\"noreferrer\">removing duplicates</a> on ...
2008/08/20
[ "https://Stackoverflow.com/questions/18932", "https://Stackoverflow.com", "https://Stackoverflow.com/users/357/" ]
I need to remove duplicate rows from a fairly large SQL Server table (i.e. 300,000+ rows). The rows, of course, will not be perfect duplicates because of the existence of the `RowID` identity field. **MyTable** ``` RowID int not null identity(1,1) primary key, Col1 varchar(20) not null, Col2 varchar(2048) not null, ...
Assuming no nulls, you `GROUP BY` the unique columns, and `SELECT` the `MIN (or MAX)` RowId as the row to keep. Then, just delete everything that didn't have a row id: ``` DELETE FROM MyTable LEFT OUTER JOIN ( SELECT MIN(RowId) as RowId, Col1, Col2, Col3 FROM MyTable GROUP BY Col1, Col2, Col3 ) as KeepRows ...
18,955
<p>Is there a way to disable entering multi-line entries in a Text Box (i.e., I'd like to stop my users from doing ctrl-enter to get a newline)?</p>
[ { "answer_id": 18972, "author": "Mauro", "author_id": 2208, "author_profile": "https://Stackoverflow.com/users/2208", "pm_score": 0, "selected": false, "text": "<p>not entirely sure about that one, you should be able to remove the line breaks when you render the content though, or even r...
2008/08/20
[ "https://Stackoverflow.com/questions/18955", "https://Stackoverflow.com", "https://Stackoverflow.com/users/685/" ]
Is there a way to disable entering multi-line entries in a Text Box (i.e., I'd like to stop my users from doing ctrl-enter to get a newline)?
I was able to do it on using KeyPress event. Here's the code example: ``` Private Sub SingleLineTextBox_ KeyPress(ByRef KeyAscii As Integer) If KeyAscii = 10 _ or KeyAscii = 13 Then '10 -> Ctrl-Enter. AKA ^J or ctrl-j '13 -> Enter. AKA ^M or ctrl-m KeyAscii = 0 'clear ...
18,984
<p>What are your opinions on developing for the command line first, then adding a GUI on after the fact by simply calling the command line methods?</p> <p>eg.</p> <blockquote> <p>W:\ todo AddTask "meeting with John, re: login peer review" "John's office" "2008-08-22" "14:00" </p> </blockquote> <p>loads <code>tod...
[ { "answer_id": 18990, "author": "Stu", "author_id": 414, "author_profile": "https://Stackoverflow.com/users/414", "pm_score": 3, "selected": false, "text": "<p>Put the shared functionality in a library, then write a command-line and a GUI front-end for it. That way your layer transition ...
2008/08/20
[ "https://Stackoverflow.com/questions/18984", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1588/" ]
What are your opinions on developing for the command line first, then adding a GUI on after the fact by simply calling the command line methods? eg. > > W:\ todo AddTask "meeting with John, re: login peer review" "John's office" "2008-08-22" "14:00" > > > loads `todo.exe` and calls a function called `AddTask` t...
I would go with building a library with a command line application that links to it. Afterwards, you can create a GUI that links to the same library. Calling a command line from a GUI spawns external processes for each command and is more disruptive to the OS. Also, with a library you can easily do unit tests for the ...
18,985
<p>I am writing a batch script in order to beautify JavaScript code. It needs to work on both <strong>Windows</strong> and <strong>Linux</strong>. </p> <p>How can I beautify JavaScript code using the command line tools? </p>
[ { "answer_id": 27343, "author": "Alan Storm", "author_id": 2838, "author_profile": "https://Stackoverflow.com/users/2838", "pm_score": 7, "selected": true, "text": "<p>First, pick your favorite Javascript based Pretty Print/Beautifier. I prefer the one at <a href=\"http://jsbeautifier.o...
2008/08/20
[ "https://Stackoverflow.com/questions/18985", "https://Stackoverflow.com", "https://Stackoverflow.com/users/486/" ]
I am writing a batch script in order to beautify JavaScript code. It needs to work on both **Windows** and **Linux**. How can I beautify JavaScript code using the command line tools?
First, pick your favorite Javascript based Pretty Print/Beautifier. I prefer the one at [<http://jsbeautifier.org/>](http://jsbeautifier.org/), because it's what I found first. Downloads its file <https://github.com/beautify-web/js-beautify/blob/master/js/lib/beautify.js> Second, download and install The Mozilla group...
19,014
<p>I want to use Lucene (in particular, Lucene.NET) to search for email address domains.</p> <p>E.g. I want to search for "@gmail.com" to find all emails sent to a gmail address.</p> <p>Running a Lucene query for "*@gmail.com" results in an error, asterisks cannot be at the start of queries. Running a query for "@gma...
[ { "answer_id": 20468, "author": "Judah Gabriel Himango", "author_id": 536, "author_profile": "https://Stackoverflow.com/users/536", "pm_score": 5, "selected": true, "text": "<p>No one gave a satisfactory answer, so we started poking around Lucene documentation and discovered we can accom...
2008/08/20
[ "https://Stackoverflow.com/questions/19014", "https://Stackoverflow.com", "https://Stackoverflow.com/users/536/" ]
I want to use Lucene (in particular, Lucene.NET) to search for email address domains. E.g. I want to search for "@gmail.com" to find all emails sent to a gmail address. Running a Lucene query for "\*@gmail.com" results in an error, asterisks cannot be at the start of queries. Running a query for "@gmail.com" doesn't ...
No one gave a satisfactory answer, so we started poking around Lucene documentation and discovered we can accomplish this using custom Analyzers and Tokenizers. The answer is this: create a WhitespaceAndAtSymbolTokenizer and a WhitespaceAndAtSymbolAnalyzer, then recreate your index using this analyzer. Once you do thi...
19,030
<p>I have a bunch of files (TV episodes, although that is fairly arbitrary) that I want to check match a specific naming/organisation scheme..</p> <p>Currently: I have three arrays of regex, one for valid filenames, one for files missing an episode name, and one for valid paths.</p> <p>Then, I loop though each valid-...
[ { "answer_id": 19389, "author": "sven", "author_id": 46, "author_profile": "https://Stackoverflow.com/users/46", "pm_score": 0, "selected": false, "text": "<p>maybe you should take the approach of defaulting to: \"the filename is correct\" and work from there to disprove that statement:<...
2008/08/20
[ "https://Stackoverflow.com/questions/19030", "https://Stackoverflow.com", "https://Stackoverflow.com/users/745/" ]
I have a bunch of files (TV episodes, although that is fairly arbitrary) that I want to check match a specific naming/organisation scheme.. Currently: I have three arrays of regex, one for valid filenames, one for files missing an episode name, and one for valid paths. Then, I loop though each valid-filename regex, i...
> > I want to add a rule that checks for > the presence of a folder.jpg file in > each directory, but to add this would > make the code substantially more messy > in it's current state.. > > > This doesn't look bad. In fact your current code does it very nicely, and Sven mentioned a good way to do it as well: ...
19,035
<p>I am working with both <a href="http://activemq.apache.org/ajax.html" rel="nofollow noreferrer">amq.js</a> (ActiveMQ) and <a href="http://code.google.com/apis/maps/documentation/reference.html" rel="nofollow noreferrer">Google Maps</a>. I load my scripts in this order</p> <pre><code>&lt;head&gt; &lt;meta http-e...
[ { "answer_id": 19067, "author": "maxsilver", "author_id": 1477, "author_profile": "https://Stackoverflow.com/users/1477", "pm_score": 2, "selected": false, "text": "<blockquote>\n <p><strong>Is there a way to make sure both scripts load before I use them?</strong></p>\n</blockquote>\n\n...
2008/08/20
[ "https://Stackoverflow.com/questions/19035", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1992/" ]
I am working with both [amq.js](http://activemq.apache.org/ajax.html) (ActiveMQ) and [Google Maps](http://code.google.com/apis/maps/documentation/reference.html). I load my scripts in this order ``` <head> <meta http-equiv="content-type" content="text/html;charset=UTF-8" /> <title>AMQ & Maps Demo</title> ...
> > **Is there a way to make sure both scripts load before I use them in my application.js?** > > > JavaScript files should load sequentially *and block* so unless the scripts you are depending on are doing something unusual all you should need to do is load application.js after the other files. [Non-blocking Jav...
19,047
<p>After upgrading to the latest version of TortoiseSVN (1.5.2.13595), it's context menu is no longer available.</p> <p>When attempting to run it manually, I get this error:</p> <pre><code>The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log for...
[ { "answer_id": 19053, "author": "Orion Edwards", "author_id": 234, "author_profile": "https://Stackoverflow.com/users/234", "pm_score": 4, "selected": true, "text": "<p>I remembered I'd seen this thing before just after posting to SO</p>\n\n<p>It seems that later versions of TortoiseSVN ...
2008/08/20
[ "https://Stackoverflow.com/questions/19047", "https://Stackoverflow.com", "https://Stackoverflow.com/users/234/" ]
After upgrading to the latest version of TortoiseSVN (1.5.2.13595), it's context menu is no longer available. When attempting to run it manually, I get this error: ``` The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log for more detail ``` Th...
I remembered I'd seen this thing before just after posting to SO It seems that later versions of TortoiseSVN are built with Visual Studio 2008 SP1 (hence the 9.0.30411.0 build number) Installing the [VC2008 SP1 Redistributable](http://www.microsoft.com/downloads/details.aspx?familyid=A5C84275-3B97-4AB7-A40D-3802B2AF5...
19,058
<p>Example:</p> <pre><code>select ename from emp where hiredate = todate('01/05/81','dd/mm/yy') </code></pre> <p>and </p> <pre><code>select ename from emp where hiredate = todate('01/05/81','dd/mm/rr') </code></pre> <p>return different results</p>
[ { "answer_id": 19061, "author": "Michael Stum", "author_id": 91, "author_profile": "https://Stackoverflow.com/users/91", "pm_score": 7, "selected": true, "text": "<p><a href=\"http://oracle.ittoolbox.com/groups/technical-functional/oracle-dev-l/difference-between-yyyy-and-rrrr-format-519...
2008/08/20
[ "https://Stackoverflow.com/questions/19058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1782/" ]
Example: ``` select ename from emp where hiredate = todate('01/05/81','dd/mm/yy') ``` and ``` select ename from emp where hiredate = todate('01/05/81','dd/mm/rr') ``` return different results
<http://oracle.ittoolbox.com/groups/technical-functional/oracle-dev-l/difference-between-yyyy-and-rrrr-format-519525> > > YY allows you to retrieve just two digits of a year, for example, the 99 in > 1999. The other digits (19) are automatically assigned to the current > century. RR converts two-digit years into fo...
19,089
<p>I have a view that has a list of jobs in it, with data like who they're assigned to and the stage they are in. I need to write a stored procedure that returns how many jobs each person has at each stage.</p> <p>So far I have this (simplified):</p> <pre><code>DECLARE @ResultTable table ( StaffName nvarchar(100),...
[ { "answer_id": 19097, "author": "AlexCuse", "author_id": 794, "author_profile": "https://Stackoverflow.com/users/794", "pm_score": 1, "selected": false, "text": "<p>To get a real \"upsert\" type of query you need to use an if exists... type of thing, and this unfortunately means using a ...
2008/08/20
[ "https://Stackoverflow.com/questions/19089", "https://Stackoverflow.com", "https://Stackoverflow.com/users/233/" ]
I have a view that has a list of jobs in it, with data like who they're assigned to and the stage they are in. I need to write a stored procedure that returns how many jobs each person has at each stage. So far I have this (simplified): ``` DECLARE @ResultTable table ( StaffName nvarchar(100), Stage1Count int, ...
IIRC there is some sort of "On Duplicate" (name might be wrong) syntax that lets you update if a row exists (MySQL) Alternately some form of: ``` INSERT INTO @ResultTable (StaffName, Stage1Count, Stage2Count) SELECT StaffName,0,0 FROM ViewJob GROUP BY StaffName UPDATE @ResultTable Stage1Count= ( SELECT COUNT(*...
19,122
<p>Does anyone know how bash handles sending data through pipes?</p> <pre><code>cat file.txt | tail -20 </code></pre> <p>Does this command print all the contents of file.txt into a buffer, which is then read by tail? Or does this command, say, print the contents of file.txt line by line, and then pause at each line f...
[ { "answer_id": 19134, "author": "Mike Stone", "author_id": 122, "author_profile": "https://Stackoverflow.com/users/122", "pm_score": 0, "selected": false, "text": "<p>cat will just print the data to standard out, which happens to be redirected to the standard in of tail. This can be see...
2008/08/21
[ "https://Stackoverflow.com/questions/19122", "https://Stackoverflow.com", "https://Stackoverflow.com/users/306/" ]
Does anyone know how bash handles sending data through pipes? ``` cat file.txt | tail -20 ``` Does this command print all the contents of file.txt into a buffer, which is then read by tail? Or does this command, say, print the contents of file.txt line by line, and then pause at each line for tail to process, and th...
I decided to write a slightly more detailed explanation. The "magic" here lies in the operating system. Both programs do start up at roughly the same time, and run at the same time (the operating system assigns them slices of time on the processor to run) as every other simultaneously running process on your computer ...
19,132
<p>I'm asking with regards to c#, but I assume its the same in most other languages.</p> <p>Does anyone have a good definition of <em>expressions</em> and <em>statements</em> and what the differences are?</p>
[ { "answer_id": 19138, "author": "Mark Cidade", "author_id": 1659, "author_profile": "https://Stackoverflow.com/users/1659", "pm_score": 3, "selected": false, "text": "<p>Expressions can be evaluated to get a value, whereas statements don't return a value (they're of type <em>void</em>).<...
2008/08/21
[ "https://Stackoverflow.com/questions/19132", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm asking with regards to c#, but I assume its the same in most other languages. Does anyone have a good definition of *expressions* and *statements* and what the differences are?
**Expression:** Something which evaluates to a value. Example: *1+2/x* **Statement:** A line of code which does something. Example: *GOTO 100* In the earliest general-purpose programming languages, like FORTRAN, the distinction was crystal-clear. In FORTRAN, a statement was one unit of execution, a thing that you d...
19,147
<p>Using C# and WPF under .NET (rather than <a href="http://en.wikipedia.org/wiki/Windows_Forms" rel="noreferrer">Windows Forms</a> or console), what is the correct way to create an application that can only be run as a single instance?</p> <p>I know it has something to do with some mythical thing called a mutex, rare...
[ { "answer_id": 19165, "author": "jason saldo", "author_id": 1293, "author_profile": "https://Stackoverflow.com/users/1293", "pm_score": 7, "selected": false, "text": "<p>From <a href=\"http://www.albahari.com/threading/part2.html#_MutexSingleAppInstance\" rel=\"noreferrer\">here</a>.</p>...
2008/08/21
[ "https://Stackoverflow.com/questions/19147", "https://Stackoverflow.com", "https://Stackoverflow.com/users/483/" ]
Using C# and WPF under .NET (rather than [Windows Forms](http://en.wikipedia.org/wiki/Windows_Forms) or console), what is the correct way to create an application that can only be run as a single instance? I know it has something to do with some mythical thing called a mutex, rarely can I find someone that bothers to ...
Here is a very good [article](http://sanity-free.org/143/csharp_dotnet_single_instance_application.html) regarding the Mutex solution. The approach described by the article is advantageous for two reasons. First, it does not require a dependency on the Microsoft.VisualBasic assembly. If my project already had a depend...
19,151
<p>How would one create an iterative function (or iterator object) in python?</p>
[ { "answer_id": 19152, "author": "akdom", "author_id": 145, "author_profile": "https://Stackoverflow.com/users/145", "pm_score": 7, "selected": false, "text": "<p>First of all the <a href=\"https://docs.python.org/3/library/itertools.html\" rel=\"noreferrer\">itertools module</a> is incre...
2008/08/21
[ "https://Stackoverflow.com/questions/19151", "https://Stackoverflow.com", "https://Stackoverflow.com/users/145/" ]
How would one create an iterative function (or iterator object) in python?
Iterator objects in python conform to the iterator protocol, which basically means they provide two methods: `__iter__()` and `__next__()`. * The `__iter__` returns the iterator object and is implicitly called at the start of loops. * The `__next__()` method returns the next value and is implicitly called at each loo...
19,185
<p>There is some documentation on the internet that shows that Windows changes the behavior of the NotifyIcon.BalloonTipShown command if the user is currently idle and this is <a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=343411&amp;SiteID=1" rel="nofollow noreferrer">detected by checking for keyboard ...
[ { "answer_id": 19187, "author": "lubos hasko", "author_id": 275, "author_profile": "https://Stackoverflow.com/users/275", "pm_score": 1, "selected": false, "text": "<p><strong>Managed code</strong></p>\n\n<p>Check position of the mouse every second. If there are new messages for user, ho...
2008/08/21
[ "https://Stackoverflow.com/questions/19185", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1185/" ]
There is some documentation on the internet that shows that Windows changes the behavior of the NotifyIcon.BalloonTipShown command if the user is currently idle and this is [detected by checking for keyboard and mouse events](http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=343411&SiteID=1). I am currently working...
How about the Win32 [LASTINPUTINFO](http://www.codeproject.com/KB/cs/GetIdleTimeWithCS.aspx) function? ``` using System.Runtime.InteropServices; [DllImport("User32.dll")] static extern bool GetLastInputInfo(ref LASTINPUTINFO plii); struct LASTINPUTINFO { public uint cbSize; public uint dwTime; } ```
19,193
<p>How do I make a tree data structure in C++ that uses iterators instead of pointers? I couldn't find anything in the STL that can do this. What I would like to do is to be able to create and manipulate trees like this:</p> <pre><code>#include &lt;iostream&gt; #include &lt;tree&gt; using namespace std; int main() ...
[ { "answer_id": 19204, "author": "wilhelmtell", "author_id": 456, "author_profile": "https://Stackoverflow.com/users/456", "pm_score": 2, "selected": false, "text": "<p>Why would you want to do that? If this is for learning purposes then you can write your own tree data structure. If th...
2008/08/21
[ "https://Stackoverflow.com/questions/19193", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2222/" ]
How do I make a tree data structure in C++ that uses iterators instead of pointers? I couldn't find anything in the STL that can do this. What I would like to do is to be able to create and manipulate trees like this: ``` #include <iostream> #include <tree> using namespace std; int main() { tree<int> myTree; ...
Here is [tree.hh](http://www.aei.mpg.de/~peekas/tree/) which is a bit close to what you want to do, though a bit different. Here is a piece of code extracted from its website. ``` int main(int, char **) { tree<string> tr; tree<string>::iterator top, one, two, loc, banana; top=tr.begin(); one=tr.insert...
19,236
<p>I'm working on a internal web based tool for my company. Part of this tool is another application (The Cruise Control Dashboard) that runs in its own Virtual Directory under my root application.</p> <p>I wanted to limit access to this internal application by setting up Forms Authentication on it, and having a login...
[ { "answer_id": 19239, "author": "Darren Kopp", "author_id": 77, "author_profile": "https://Stackoverflow.com/users/77", "pm_score": 0, "selected": false, "text": "<p>you are allowing all unauthenticated. You might be looking for something like this</p>\n\n<pre><code>&lt;deny users=\"?\"/...
2008/08/21
[ "https://Stackoverflow.com/questions/19236", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1965/" ]
I'm working on a internal web based tool for my company. Part of this tool is another application (The Cruise Control Dashboard) that runs in its own Virtual Directory under my root application. I wanted to limit access to this internal application by setting up Forms Authentication on it, and having a login form in t...
You might also need to put path="/" in the <forms tag(s) I think. Sorry, its been a while since i've done this
19,294
<p>In my code behind I wire up my events like so:</p> <pre><code>protected override void OnInit(EventArgs e) { base.OnInit(e); btnUpdateUser.Click += btnUpateUserClick; } </code></pre> <p>I've done it this way because that's what I've seen in examples. </p> <ul> <li>Does the base.OnInit() method need to be c...
[ { "answer_id": 19296, "author": "David Wengier", "author_id": 489, "author_profile": "https://Stackoverflow.com/users/489", "pm_score": 0, "selected": false, "text": "<p>In this case, if you don't call the base OnInit, then the Init even will not fire.</p>\n\n<p>In general, it is best pr...
2008/08/21
[ "https://Stackoverflow.com/questions/19294", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1894/" ]
In my code behind I wire up my events like so: ``` protected override void OnInit(EventArgs e) { base.OnInit(e); btnUpdateUser.Click += btnUpateUserClick; } ``` I've done it this way because that's what I've seen in examples. * Does the base.OnInit() method need to be called? * Will it be implicitly be cal...
I should clarify: The guidelines recommend that firing an event should involve calling a virtual "On*EventName*" method, but they also say that if a derived class overrides that method and forgets to call the base method, the event should still fire. See the "Important Note" about halfway down [this page](http://msdn...
19,295
<p>I'd like to use a database to store i18n key/value pairs so we can modify / reload the i18n data at runtime. Has anyone done this? Or does anyone have an idea of how to implement this? I've read several threads on this, but I haven't seen a workable solution.</p> <p>I'm specifically refering to something that would...
[ { "answer_id": 19308, "author": "danb", "author_id": 2031, "author_profile": "https://Stackoverflow.com/users/2031", "pm_score": 3, "selected": true, "text": "<p>Are you just asking how to store UTF-8/16 characters in a DB? in mysql it's just a matter of making sure you build with UTF8 s...
2008/08/21
[ "https://Stackoverflow.com/questions/19295", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1310/" ]
I'd like to use a database to store i18n key/value pairs so we can modify / reload the i18n data at runtime. Has anyone done this? Or does anyone have an idea of how to implement this? I've read several threads on this, but I haven't seen a workable solution. I'm specifically refering to something that would work with...
Are you just asking how to store UTF-8/16 characters in a DB? in mysql it's just a matter of making sure you build with UTF8 support and setting that as the default, or specifying it at the column or table level. I've done this in oracle and mysql before. Create a table and cut and paste some i18n data into it and see ...
19,318
<p>I have an ASP.NET webservice with along the lines of:</p> <pre><code>[WebService(Namespace = "http://internalservice.net/messageprocessing")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [ToolboxItem(false)] public class ProvisioningService : WebService { [WebMethod] public XmlDocument Proc...
[ { "answer_id": 19324, "author": "FlySwat", "author_id": 1965, "author_profile": "https://Stackoverflow.com/users/1965", "pm_score": 0, "selected": false, "text": "<p>I take it you have access to the Services code, not just the consuming client right?</p>\n\n<p>Just pull the namespace out...
2008/08/21
[ "https://Stackoverflow.com/questions/19318", "https://Stackoverflow.com", "https://Stackoverflow.com/users/419/" ]
I have an ASP.NET webservice with along the lines of: ``` [WebService(Namespace = "http://internalservice.net/messageprocessing")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [ToolboxItem(false)] public class ProvisioningService : WebService { [WebMethod] public XmlDocument ProcessMessage(Xml...
I solved this: The SOAP client *request* node was picking up the default namespace from: ``` <ProcessMessage xmlns="http://internalservice.net/messageprocessing"> ``` Adding an empty default namespace to the XML sent by the ASP client overrides this behaviour: ``` xmlMessage = "<request xmlns=''><task>....various ...
19,339
<p>I have a list of 2-item tuples and I'd like to convert them to 2 lists where the first contains the first item in each tuple and the second list holds the second item.</p> <p><strong>For example:</strong></p> <pre><code>original = [('a', 1), ('b', 2), ('c', 3), ('d', 4)] # and I want to become... result = (['a', '...
[ { "answer_id": 19343, "author": "Patrick", "author_id": 429, "author_profile": "https://Stackoverflow.com/users/429", "pm_score": 11, "selected": true, "text": "<p><a href=\"http://docs.python.org/library/functions.html#zip\" rel=\"noreferrer\"><code>zip</code></a> is its own inverse! Pr...
2008/08/21
[ "https://Stackoverflow.com/questions/19339", "https://Stackoverflow.com", "https://Stackoverflow.com/users/680/" ]
I have a list of 2-item tuples and I'd like to convert them to 2 lists where the first contains the first item in each tuple and the second list holds the second item. **For example:** ``` original = [('a', 1), ('b', 2), ('c', 3), ('d', 4)] # and I want to become... result = (['a', 'b', 'c', 'd'], [1, 2, 3, 4]) ``` ...
[`zip`](http://docs.python.org/library/functions.html#zip) is its own inverse! Provided you use the special \* operator. ``` >>> zip(*[('a', 1), ('b', 2), ('c', 3), ('d', 4)]) [('a', 'b', 'c', 'd'), (1, 2, 3, 4)] ``` The way this works is by calling `zip` with the arguments: ``` zip(('a', 1), ('b', 2), ('c', 3), ('...
19,355
<p>In a .NET project, say you have a configuration setting - like a connection string - stored in a app.config file, which is different for each developer on your team (they may be using a local SQL Server, or a specific server instance, or using a remote server, etc). </p> <p>How can you structure your solution so th...
[ { "answer_id": 19359, "author": "Scott Muc", "author_id": 1894, "author_profile": "https://Stackoverflow.com/users/1894", "pm_score": 0, "selected": false, "text": "<p>I always make templates for my config files. </p>\n\n<p>As an example I use NAnt for the building of my projects. I have...
2008/08/21
[ "https://Stackoverflow.com/questions/19355", "https://Stackoverflow.com", "https://Stackoverflow.com/users/708/" ]
In a .NET project, say you have a configuration setting - like a connection string - stored in a app.config file, which is different for each developer on your team (they may be using a local SQL Server, or a specific server instance, or using a remote server, etc). How can you structure your solution so that each de...
AppSettings can be overridden with a local file: ``` <appSettings file="localoveride.config"/> ``` This allows for each developer to keep their own local settings. As far as the connection string, in a perfect world all developers should connect to a test DB, not run SQL Server each. However, I've found it best to...
19,388
<p>I've heard rumors that PHP is planning on introducing a "goto" command. What is it supposed to be doing?</p> <p>I've tried searching a bit, but haven't found anything awfully descriptive. I understand that it won't be a "<code>GOTO 10</code>"-like command...</p>
[ { "answer_id": 19398, "author": "postfuturist", "author_id": 1892, "author_profile": "https://Stackoverflow.com/users/1892", "pm_score": 2, "selected": false, "text": "<p>Granted, I am not a PHP programmer, and I don't know what PHP's exact implementation of GOTO will look like, but here...
2008/08/21
[ "https://Stackoverflow.com/questions/19388", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2238/" ]
I've heard rumors that PHP is planning on introducing a "goto" command. What is it supposed to be doing? I've tried searching a bit, but haven't found anything awfully descriptive. I understand that it won't be a "`GOTO 10`"-like command...
They are not adding a real GOTO, but extending the BREAK keyword to use static labels. Basically, it will be enhancing the ability to break out of ~~switch~~ nested if statements. Here's the concept example I found: ``` <?php for ($i = 0; $i < 9; $i++) { if (true) { break blah; } echo "not shown"; ...
19,409
<p>This is kinda oddball, but I was poking around with the GNU assembler today (I want to be able to at least read the syntax), and was trying to get this little contrived example of mine to work. Namely I just want to go from 0 to 100, printing out numbers all the while. So a few minutes later I come up with this:</p>...
[ { "answer_id": 19411, "author": "Nathan Fellman", "author_id": 1084, "author_profile": "https://Stackoverflow.com/users/1084", "pm_score": 3, "selected": false, "text": "<p>I'm not too familiar with _printf, but could it be that it modifies eax? Printf should return the number of chars ...
2008/08/21
[ "https://Stackoverflow.com/questions/19409", "https://Stackoverflow.com", "https://Stackoverflow.com/users/61/" ]
This is kinda oddball, but I was poking around with the GNU assembler today (I want to be able to at least read the syntax), and was trying to get this little contrived example of mine to work. Namely I just want to go from 0 to 100, printing out numbers all the while. So a few minutes later I come up with this: ``` #...
You can't trust what any called procedure does to any of the registers. Either push the registers onto the stack and pop them back off after calling printf or have the increment and end point values held in memory and read/written into registers as you need them. I hope the following works. I'm assuming that pushl h...
19,412
<p>How can I request a random row (or as close to truly random as is possible) in pure SQL?</p>
[ { "answer_id": 19414, "author": "Matt Hamilton", "author_id": 615, "author_profile": "https://Stackoverflow.com/users/615", "pm_score": 6, "selected": false, "text": "<p>I don't know how efficient this is, but I've used it before:</p>\n\n<pre><code>SELECT TOP 1 * FROM MyTable ORDER BY ne...
2008/08/21
[ "https://Stackoverflow.com/questions/19412", "https://Stackoverflow.com", "https://Stackoverflow.com/users/473/" ]
How can I request a random row (or as close to truly random as is possible) in pure SQL?
See this post: [SQL to Select a random row from a database table](http://www.petefreitag.com/item/466.cfm). It goes through methods for doing this in MySQL, PostgreSQL, Microsoft SQL Server, IBM DB2 and Oracle (the following is copied from that link): Select a random row with MySQL: ``` SELECT column FROM table ORDER...
19,436
<p>I have a datalist with a OnDeleteCommand="Delete_Command".</p> <p>I want the delete a record with multiple primary Keys but I do not know how to access it from the Delete_Command event.</p> <p>If I use DataKeyField I'm limited to only one key. Any workarounds for this?</p>
[ { "answer_id": 19447, "author": "Biri", "author_id": 968, "author_profile": "https://Stackoverflow.com/users/968", "pm_score": 2, "selected": true, "text": "<p>You can access all of the keys:</p>\n\n<pre><code>gridView.DataKeys[rowNum][dataKeyName]\n</code></pre>\n\n<p>where rowNum is e....
2008/08/21
[ "https://Stackoverflow.com/questions/19436", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1013/" ]
I have a datalist with a OnDeleteCommand="Delete\_Command". I want the delete a record with multiple primary Keys but I do not know how to access it from the Delete\_Command event. If I use DataKeyField I'm limited to only one key. Any workarounds for this?
You can access all of the keys: ``` gridView.DataKeys[rowNum][dataKeyName] ``` where rowNum is e.RowIndex from the gridView\_RowDeleting event handler, and dataKeyName is the key you want to get: ``` <asp:GridView ID="gridView" runat="server" DataKeyNames="userid, id1, id2, id3" OnRowDeleting="gridView_RowDeleting"...
19,442
<p>How can I create this file in a directory in windows 2003 SP2:</p> <pre><code>.hgignore </code></pre> <p>I get error: You must type a file name.</p>
[ { "answer_id": 19443, "author": "Ishmaeel", "author_id": 227, "author_profile": "https://Stackoverflow.com/users/227", "pm_score": 6, "selected": true, "text": "<p>That's a \"feature\" of Windows Explorer. Try to create your files from a command line (or from a batch/program you wrote) a...
2008/08/21
[ "https://Stackoverflow.com/questions/19442", "https://Stackoverflow.com", "https://Stackoverflow.com/users/479/" ]
How can I create this file in a directory in windows 2003 SP2: ``` .hgignore ``` I get error: You must type a file name.
That's a "feature" of Windows Explorer. Try to create your files from a command line (or from a batch/program you wrote) and it should work fine. Try this from a dos prompt: ``` echo Hello there! > .hgignore ```
19,454
<p>Following on from my recent question on <a href="https://stackoverflow.com/questions/17725/large-complex-objects-as-a-web-service-result">Large, Complex Objects as a Web Service Result</a>. I have been thinking about how I can ensure all future child classes are serializable to XML.</p> <p>Now, obviously I could imp...
[ { "answer_id": 19455, "author": "Fredrik Kalseth", "author_id": 1710, "author_profile": "https://Stackoverflow.com/users/1710", "pm_score": 5, "selected": true, "text": "<p>I'd write a unit/integration test that verifies that any class matching some given criteria (ie subclassing X) is d...
2008/08/21
[ "https://Stackoverflow.com/questions/19454", "https://Stackoverflow.com", "https://Stackoverflow.com/users/832/" ]
Following on from my recent question on [Large, Complex Objects as a Web Service Result](https://stackoverflow.com/questions/17725/large-complex-objects-as-a-web-service-result). I have been thinking about how I can ensure all future child classes are serializable to XML. Now, obviously I could implement the [IXmlSeri...
I'd write a unit/integration test that verifies that any class matching some given criteria (ie subclassing X) is decorated appropriately. If you set up your build to run with tests, you can have the build fail when this test fails. UPDATE: You said, "Looks like I will just have to roll my sleeves up and make sure tha...
19,461
<p>I have a standard HTML image tag with an image in it, 100 by 100 pixels in size. I want people to be able to click the image and for that to pass the X and Y that they click into a function.</p> <p>The coordinates need to be relative to the image top and left.</p>
[ { "answer_id": 19464, "author": "Jon Galloway", "author_id": 5, "author_profile": "https://Stackoverflow.com/users/5", "pm_score": 3, "selected": false, "text": "<p>I think you're talking about:</p>\n\n<pre><code>&lt;input id=\"info\" type=\"image\"&gt;\n</code></pre>\n\n<p>When submitte...
2008/08/21
[ "https://Stackoverflow.com/questions/19461", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1384652/" ]
I have a standard HTML image tag with an image in it, 100 by 100 pixels in size. I want people to be able to click the image and for that to pass the X and Y that they click into a function. The coordinates need to be relative to the image top and left.
I think you're talking about: ``` <input id="info" type="image"> ``` When submitted, there are form values for the x and y coordinate based on the input element id (`info.x` and `info.y` in this case). <http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.4.1>
19,466
<p>How can I check <code>file permissions</code>, without having to run operating system specific command via <code>passthru()</code> or <code>exec()</code>?</p>
[ { "answer_id": 19469, "author": "Chris Hanson", "author_id": 714, "author_profile": "https://Stackoverflow.com/users/714", "pm_score": 0, "selected": false, "text": "<p>What do you want to do by checking file permissions?</p>\n\n<p>When writing secure code, it's almost always incorrect t...
2008/08/21
[ "https://Stackoverflow.com/questions/19466", "https://Stackoverflow.com", "https://Stackoverflow.com/users/115/" ]
How can I check `file permissions`, without having to run operating system specific command via `passthru()` or `exec()`?
Use [fileperms()](http://php.net/fileperms) function ``` clearstatcache(); echo substr(sprintf('%o', fileperms('/etc/passwd')), -4); ```
19,516
<p>Here is a simplification of my database:</p> <pre>Table: Property Fields: ID, Address Table: Quote Fields: ID, PropertyID, BespokeQuoteFields... Table: Job Fields: ID, PropertyID, BespokeJobFields...</pre> <p>Then we have other tables that relate to the <strong>Quote</strong> and <strong>Job</strong> tables indi...
[ { "answer_id": 19521, "author": "Ian Nelson", "author_id": 2084, "author_profile": "https://Stackoverflow.com/users/2084", "pm_score": 3, "selected": true, "text": "<p>Create one Message table, containing a unique MessageId and the various properties you need to store for a message.</p>\...
2008/08/21
[ "https://Stackoverflow.com/questions/19516", "https://Stackoverflow.com", "https://Stackoverflow.com/users/366/" ]
Here is a simplification of my database: ``` Table: Property Fields: ID, Address Table: Quote Fields: ID, PropertyID, BespokeQuoteFields... Table: Job Fields: ID, PropertyID, BespokeJobFields... ``` Then we have other tables that relate to the **Quote** and **Job** tables individually. I now need to add a **Messag...
Create one Message table, containing a unique MessageId and the various properties you need to store for a message. ``` Table: Message Fields: Id, TimeReceived, MessageDetails, WhateverElse... ``` Create two link tables - QuoteMessage and JobMessage. These will just contain two fields each, foreign keys to the Quote...
19,517
<p>I was reading the example chapter from <a href="http://www.manning.com/rahien/" rel="nofollow noreferrer">the book by Ayende</a> and on the website of <a href="http://boo.codehaus.org/" rel="nofollow noreferrer">the Boo language</a> I saw a reference to the <a href="http://specter.sourceforge.net/" rel="nofollow nor...
[ { "answer_id": 19521, "author": "Ian Nelson", "author_id": 2084, "author_profile": "https://Stackoverflow.com/users/2084", "pm_score": 3, "selected": true, "text": "<p>Create one Message table, containing a unique MessageId and the various properties you need to store for a message.</p>\...
2008/08/21
[ "https://Stackoverflow.com/questions/19517", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4367/" ]
I was reading the example chapter from [the book by Ayende](http://www.manning.com/rahien/) and on the website of [the Boo language](http://boo.codehaus.org/) I saw a reference to the [Specter BDD Framework](http://specter.sourceforge.net/). I am wondering if anybody is using it in their project, how that works out an...
Create one Message table, containing a unique MessageId and the various properties you need to store for a message. ``` Table: Message Fields: Id, TimeReceived, MessageDetails, WhateverElse... ``` Create two link tables - QuoteMessage and JobMessage. These will just contain two fields each, foreign keys to the Quote...
19,553
<p>I have a "Status" class in C#, used like this:</p> <pre><code>Status MyFunction() { if(...) // something bad return new Status(false, "Something went wrong") else return new Status(true, "OK"); } </code></pre> <p>You get the idea. All callers of MyFunction <em>should</em> check the returned Status:...
[ { "answer_id": 19560, "author": "Ian Nelson", "author_id": 2084, "author_profile": "https://Stackoverflow.com/users/2084", "pm_score": 3, "selected": false, "text": "<p>I know this doesn't answer your question directly, but if \"something went wrong\" within your function (unexpected cir...
2008/08/21
[ "https://Stackoverflow.com/questions/19553", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1163/" ]
I have a "Status" class in C#, used like this: ``` Status MyFunction() { if(...) // something bad return new Status(false, "Something went wrong") else return new Status(true, "OK"); } ``` You get the idea. All callers of MyFunction *should* check the returned Status: ``` Status myStatus = MyFunctio...
I am fairly certain you can't get the effect you want as a return value from a method. C# just can't do some of the things C++ can. However, a somewhat ugly way to get a similar effect is the following: ``` using System; public class Example { public class Toy { private bool inCupboard = false; ...
19,589
<p>Using C# .NET 3.5 and WCF, I'm trying to write out some of the WCF configuration in a client application (the name of the server the client is connecting to).</p> <p>The obvious way is to use <code>ConfigurationManager</code> to load the configuration section and write out the data I need.</p> <pre><code>var servi...
[ { "answer_id": 19594, "author": "DavidWhitney", "author_id": 1297, "author_profile": "https://Stackoverflow.com/users/1297", "pm_score": 6, "selected": false, "text": "<p><a href=\"http://mostlytech.blogspot.com/2007/11/programmatically-enumerate-wcf.html\" rel=\"noreferrer\">http://most...
2008/08/21
[ "https://Stackoverflow.com/questions/19589", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1297/" ]
Using C# .NET 3.5 and WCF, I'm trying to write out some of the WCF configuration in a client application (the name of the server the client is connecting to). The obvious way is to use `ConfigurationManager` to load the configuration section and write out the data I need. ``` var serviceModelSection = ConfigurationMa...
The [`<system.serviceModel>`](http://msdn.microsoft.com/en-us/library/ms731354%28v=vs.90%29.aspx) element is for a configuration section **group**, not a section. You'll need to use [`System.ServiceModel.Configuration.ServiceModelSectionGroup.GetSectionGroup()`](http://msdn.microsoft.com/en-us/library/system.servicemod...
19,656
<p>I have an Interface called <code>IStep</code> that can do some computation (See "<a href="http://steve-yegge.blogspot.com/2006/03/execution-in-kingdom-of-nouns.html" rel="nofollow noreferrer">Execution in the Kingdom of Nouns</a>"). At runtime, I want to select the appropriate implementation by class name.</p> <pre...
[ { "answer_id": 19658, "author": "Ian Nelson", "author_id": 2084, "author_profile": "https://Stackoverflow.com/users/2084", "pm_score": 2, "selected": false, "text": "<p>If the implementation has a parameterless constructor, you can do this using the System.Activator class. You will need ...
2008/08/21
[ "https://Stackoverflow.com/questions/19656", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2260/" ]
I have an Interface called `IStep` that can do some computation (See "[Execution in the Kingdom of Nouns](http://steve-yegge.blogspot.com/2006/03/execution-in-kingdom-of-nouns.html)"). At runtime, I want to select the appropriate implementation by class name. ``` // use like this: IStep step = GetStep(sName); ```
Your question is very confusing... If you want to find types that implement IStep, then do this: ``` foreach (Type t in Assembly.GetCallingAssembly().GetTypes()) { if (!typeof(IStep).IsAssignableFrom(t)) continue; Console.WriteLine(t.FullName + " implements " + typeof(IStep).FullName); } ``` If you know already...
19,708
<p>To grab the inode of a file in PHP, you can use this:</p> <pre><code>$fs = stat($file); echo $fs['ino']; </code></pre> <p>The problem with this is EVERYWHERE says it's slow and you should avoid it. So the question becomes what's the fast(er) way to do it?</p>
[ { "answer_id": 19716, "author": "mercutio", "author_id": 1951, "author_profile": "https://Stackoverflow.com/users/1951", "pm_score": 2, "selected": true, "text": "<p>You could use <a href=\"http://php.net/fileinode\" rel=\"nofollow noreferrer\"><code>fileinode()</code></a> but you should...
2008/08/21
[ "https://Stackoverflow.com/questions/19708", "https://Stackoverflow.com", "https://Stackoverflow.com/users/497/" ]
To grab the inode of a file in PHP, you can use this: ``` $fs = stat($file); echo $fs['ino']; ``` The problem with this is EVERYWHERE says it's slow and you should avoid it. So the question becomes what's the fast(er) way to do it?
You could use [`fileinode()`](http://php.net/fileinode) but you should run benchmarks if you think it is slow.
19,725
<p>Right, initially ran:</p> <pre><code>c:\regsvr32 Amazing.dll </code></pre> <p>then, (accidentally - I might add) I must have run it again, and (indeed) again when new versions of 'Amazing.dll' were released. Yes - I know <em>now</em> I should've run:</p> <pre><code>c:\regsvr32 /u Amazing.dll </code></pre> <p>bef...
[ { "answer_id": 19730, "author": "Johnno Nolan", "author_id": 1116, "author_profile": "https://Stackoverflow.com/users/1116", "pm_score": 0, "selected": false, "text": "<p>I've got myself into a horrible mess with COM before. I had to pick my way though the registry deleting each referenc...
2008/08/21
[ "https://Stackoverflow.com/questions/19725", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2266/" ]
Right, initially ran: ``` c:\regsvr32 Amazing.dll ``` then, (accidentally - I might add) I must have run it again, and (indeed) again when new versions of 'Amazing.dll' were released. Yes - I know *now* I should've run: ``` c:\regsvr32 /u Amazing.dll ``` beforehand - but hey! I forgot. To cut to the chase, when ...
Your object's GUID's should not be changing. In other words, once you register the COM object, re-registering shouldn't be adding anything additional to the registry. Unless you added additional COM interfaces or objects to the project. In any case, if this is a one time deal (and it sounds like it is), open regedit ...
19,786
<p>I am maintaining an app for a client that is used in two locations. One in England and one in Poland.</p> <p>The database is stored in England and uses the format £1000.00 for currency, but the information is being gathered locally in Poland where 1000,00 is the format.</p> <p>My question is, in VB6 is there a fun...
[ { "answer_id": 19810, "author": "Espo", "author_id": 2257, "author_profile": "https://Stackoverflow.com/users/2257", "pm_score": 0, "selected": false, "text": "<p>What database are you using? And what data type is the amount stored in?</p>\n\n<p>As long as you are always converting from ...
2008/08/21
[ "https://Stackoverflow.com/questions/19786", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1075/" ]
I am maintaining an app for a client that is used in two locations. One in England and one in Poland. The database is stored in England and uses the format £1000.00 for currency, but the information is being gathered locally in Poland where 1000,00 is the format. My question is, in VB6 is there a function that takes ...
The data is not actually stored as the string `"£1000.00"`; it's stored in some numeric format. > > **Sidebar:** Usually databases are set up to store money amounts using either the **decimal** data type (also called **money** in some DBs), or as a floating point number (also called **double**). > > > The differenc...
19,787
<p>Is it possible to look back through the history of a Subversion repository for files of a certain name (even better would be for them to have a wildcard search)?</p> <p>I want to see if a <code>.bat</code> file has been committed to the repository at some point in the past but has since been removed in later update...
[ { "answer_id": 19798, "author": "Ishmaeel", "author_id": 227, "author_profile": "https://Stackoverflow.com/users/227", "pm_score": 2, "selected": false, "text": "<p>I assume you are using the SVN command line client. Give TortoiseSVN a try. Its \"Show Log\" dialog allows searching for co...
2008/08/21
[ "https://Stackoverflow.com/questions/19787", "https://Stackoverflow.com", "https://Stackoverflow.com/users/277/" ]
Is it possible to look back through the history of a Subversion repository for files of a certain name (even better would be for them to have a wildcard search)? I want to see if a `.bat` file has been committed to the repository at some point in the past but has since been removed in later updates. Even a dump of the...
TortoiseSVN can search the logs very easily, and on my system I can enter ".plg" in the search box and find all adds, modifies, and deletes for those files. Without Tortoise, the only way I can think of doing that would be to grep the full logs or parse the logs and do your own searching for 'A' and 'D' indicators on ...
19,838
<p>I've been trying to understand how Ruby blocks work, and to do that I've been trying to implement them in C.</p> <p>One easy way to implement closures is to pass a <code>void*</code> to the enclosing stack to the closure/function but Ruby blocks also seem to handle returns and break statements from the scope that u...
[ { "answer_id": 20154, "author": "wvdschel", "author_id": 2018, "author_profile": "https://Stackoverflow.com/users/2018", "pm_score": 4, "selected": true, "text": "<p>The concept of closures requires the concept of contexts. C's context is based on the stack and the registers of the CPU, ...
2008/08/21
[ "https://Stackoverflow.com/questions/19838", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2148/" ]
I've been trying to understand how Ruby blocks work, and to do that I've been trying to implement them in C. One easy way to implement closures is to pass a `void*` to the enclosing stack to the closure/function but Ruby blocks also seem to handle returns and break statements from the scope that uses the block. ``` l...
The concept of closures requires the concept of contexts. C's context is based on the stack and the registers of the CPU, so to create a block/closure, you need to be able to manipulate the stack pointer in a correct (and reentrant) way, and store/restore registers as needed. The way this is done by interpreters or vi...
19,843
<p>My question concerns c# and how to access Static members ... Well I don't really know how to explain it (which kind of is bad for a question isn't it?) I will just give you some sample code:</p> <pre><code>Class test&lt;T&gt;{ int method1(Obj Parameter1){ //in here I want to do something which I would ...
[ { "answer_id": 19862, "author": "Greg Hurlman", "author_id": 35, "author_profile": "https://Stackoverflow.com/users/35", "pm_score": 3, "selected": false, "text": "<p>The problem is that TryParse isn't defined on an interface or base class anywhere, so you can't make an assumption that t...
2008/08/21
[ "https://Stackoverflow.com/questions/19843", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2275/" ]
My question concerns c# and how to access Static members ... Well I don't really know how to explain it (which kind of is bad for a question isn't it?) I will just give you some sample code: ``` Class test<T>{ int method1(Obj Parameter1){ //in here I want to do something which I would explain as ...
One more way to do it, this time some reflection in the mix: ``` static class Parser { public static bool TryParse<TType>( string str, out TType x ) { // Get the type on that TryParse shall be called Type objType = typeof( TType ); // Enumerate the methods of TType foreach( Met...
19,852
<p>I'm just designing the schema for a database table which will hold details of email attachments - their size in bytes, filename and content-type (i.e. "image/jpg", "audio/mp3", etc).</p> <p>Does anybody know the maximum length that I can expect a content-type to be?</p>
[ { "answer_id": 136592, "author": "Walden Leverich", "author_id": 2673770, "author_profile": "https://Stackoverflow.com/users/2673770", "pm_score": 1, "selected": false, "text": "<p>We run an SaaS system that allows users to upload files. We'd originally designed it to store MIME Types up...
2008/08/21
[ "https://Stackoverflow.com/questions/19852", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2084/" ]
I'm just designing the schema for a database table which will hold details of email attachments - their size in bytes, filename and content-type (i.e. "image/jpg", "audio/mp3", etc). Does anybody know the maximum length that I can expect a content-type to be?
I hope I havn't misread, but it looks like the length is max 127/127 or **255 total**. [RFC 4288](http://www.ietf.org/rfc/rfc4288.txt?number=4288) has a reference in 4.2 (page 6): ``` Type and subtype names MUST conform to the following ABNF: type-name = reg-name subtype-name = reg-name reg-name = 1*127reg...
19,952
<p>The RFC for a Java class is set of all methods that can be invoked in response to a message to an object of the class or by some method in the class. RFC = M + R where M = Number of methods in the class. R = Total number of other methods directly invoked from the M.</p> <p>Thinking C is the .class and J is the .j...
[ { "answer_id": 19967, "author": "Nicolas", "author_id": 1730, "author_profile": "https://Stackoverflow.com/users/1730", "pm_score": 0, "selected": false, "text": "<p>You should find your answer in the <a href=\"http://java.sun.com/docs/books/jls/third_edition/html/j3TOC.html\" rel=\"nofo...
2008/08/21
[ "https://Stackoverflow.com/questions/19952", "https://Stackoverflow.com", "https://Stackoverflow.com/users/482/" ]
The RFC for a Java class is set of all methods that can be invoked in response to a message to an object of the class or by some method in the class. RFC = M + R where M = Number of methods in the class. R = Total number of other methods directly invoked from the M. Thinking C is the .class and J is the .java file o...
You could use the [Byte Code Engineering Library](http://jakarta.apache.org/bcel/index.html) with binaries. You can use a [DescendingVisitor](http://jakarta.apache.org/bcel/apidocs/org/apache/bcel/classfile/DescendingVisitor.html) to visit a class' members and references. I've used it to [find class dependencies](http:...
20,047
<p>We're seeing some pernicious, but rare, deadlock conditions in the Stack Overflow SQL Server 2005 database.</p> <p>I attached the profiler, set up a trace profile using <a href="http://www.simple-talk.com/sql/learn-sql-server/how-to-track-down-deadlocks-using-sql-server-2005-profiler/" rel="noreferrer">this excelle...
[ { "answer_id": 20056, "author": "Greg Hurlman", "author_id": 35, "author_profile": "https://Stackoverflow.com/users/35", "pm_score": 3, "selected": false, "text": "<blockquote>\n <p>Will you care if your user profile is a few seconds out of date?</p>\n</blockquote>\n\n<p>Nope - that's p...
2008/08/21
[ "https://Stackoverflow.com/questions/20047", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1/" ]
We're seeing some pernicious, but rare, deadlock conditions in the Stack Overflow SQL Server 2005 database. I attached the profiler, set up a trace profile using [this excellent article on troubleshooting deadlocks](http://www.simple-talk.com/sql/learn-sql-server/how-to-track-down-deadlocks-using-sql-server-2005-profi...
According to MSDN: <http://msdn.microsoft.com/en-us/library/ms191242.aspx> > > When either the > READ COMMITTED SNAPSHOT or > ALLOW SNAPSHOT ISOLATION database > options are ON, logical copies > (versions) are maintained for all data > modifications performed in the > database. Every time a row is modified > ...
20,061
<p>I've recently taken up learning some C# and wrote a Yahtzee clone. My next step (now that the game logic is in place and functioning correctly) is to integrate some method of keeping stats across all the games played.</p> <p>My question is this, how should I go about storing this information? My first thought wou...
[ { "answer_id": 20086, "author": "palmsey", "author_id": 521, "author_profile": "https://Stackoverflow.com/users/521", "pm_score": 3, "selected": false, "text": "<p>A database may be overkill - have you thought about just storing the scores in a file?</p>\n\n<p>If you decide to go with a ...
2008/08/21
[ "https://Stackoverflow.com/questions/20061", "https://Stackoverflow.com", "https://Stackoverflow.com/users/271/" ]
I've recently taken up learning some C# and wrote a Yahtzee clone. My next step (now that the game logic is in place and functioning correctly) is to integrate some method of keeping stats across all the games played. My question is this, how should I go about storing this information? My first thought would be to use...
Here is one idea: use Xml Serialization. Design your GameStats data structure and optionally use Xml attributes to influence the schema as you like. I like to use this method for small data sets because its quick and easy and all I need to do is design and manipulate the data structure. ``` using (FileStream fs = new...
20,063
<p>What's the <strong>easiest</strong>, <strong>tersest</strong>, and most <strong>flexible</strong> method or library for parsing Python command line arguments?</p>
[ { "answer_id": 20065, "author": "Corey", "author_id": 1595, "author_profile": "https://Stackoverflow.com/users/1595", "pm_score": 4, "selected": false, "text": "<p>Use <code>optparse</code> which comes with the standard library. For example:</p>\n\n<pre><code>#!/usr/bin/env python\nimpor...
2008/08/21
[ "https://Stackoverflow.com/questions/20063", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1335/" ]
What's the **easiest**, **tersest**, and most **flexible** method or library for parsing Python command line arguments?
**This answer suggests `optparse` which is appropriate for older Python versions. For Python 2.7 and above, `argparse` replaces `optparse`. See [this answer](https://stackoverflow.com/questions/3217673/why-use-argparse-rather-than-optparse) for more information.** As other people pointed out, you are better off going ...
20,081
<p>I've written PL/SQL code to denormalize a table into a much-easer-to-query form. The code uses a temporary table to do some of its work, merging some rows from the original table together.</p> <p>The logic is written as a <a href="http://www.oreillynet.com/lpt/a/3136" rel="nofollow noreferrer">pipelined table funct...
[ { "answer_id": 22033, "author": "hollystyles", "author_id": 2083160, "author_profile": "https://Stackoverflow.com/users/2083160", "pm_score": 1, "selected": false, "text": "<p>Rather than having the input parameter as a cursor, I would have a table variable (don't know if Oracle has such...
2008/08/21
[ "https://Stackoverflow.com/questions/20081", "https://Stackoverflow.com", "https://Stackoverflow.com/users/726/" ]
I've written PL/SQL code to denormalize a table into a much-easer-to-query form. The code uses a temporary table to do some of its work, merging some rows from the original table together. The logic is written as a [pipelined table function](http://www.oreillynet.com/lpt/a/3136), following the pattern from the linked ...
I think a way to approach this is to use analytic functions... I set up your test case using: ``` create table employee_job ( emp_id integer, job_id integer, status varchar2(1 char), eff_date date ); insert into employee_job values (1,10,'A',to_date('10-JAN-2008','DD-MON-YYYY')); insert into em...
20,084
<p>Following on from my <a href="https://stackoverflow.com/questions/19454/enforce-attribute-decoration-of-classesmethods">previous question</a> I have been working on getting my object model to serialize to XML. But I have now run into a problem (quelle surprise!).</p> <p>The problem I have is that I have a collectio...
[ { "answer_id": 20097, "author": "TheSmurf", "author_id": 1975282, "author_profile": "https://Stackoverflow.com/users/1975282", "pm_score": 1, "selected": false, "text": "<p>I've done things similar to this. What I normally do is make sure all the XML serialization attributes are on the c...
2008/08/21
[ "https://Stackoverflow.com/questions/20084", "https://Stackoverflow.com", "https://Stackoverflow.com/users/832/" ]
Following on from my [previous question](https://stackoverflow.com/questions/19454/enforce-attribute-decoration-of-classesmethods) I have been working on getting my object model to serialize to XML. But I have now run into a problem (quelle surprise!). The problem I have is that I have a collection, which is of a abst...
Problem Solved! --------------- OK, so I finally got there (admittedly with a **lot** of help from [here](http://www.codeproject.com/KB/XML/xmlserializerforunknown.aspx)!). So summarise: ### Goals: * I didn't want to go down the *XmlInclude* route due to the maintenence headache. * Once a solution was found, I want...
20,107
<p>This line in YUI's <a href="http://developer.yahoo.com/yui/reset/" rel="nofollow noreferrer">Reset CSS</a> is causing trouble for me:</p> <pre class="lang-css prettyprint-override"><code>address,caption,cite,code,dfn,em,strong,th,var { font-style: normal; font-weight: normal; } </code></pre> <p>It makes my...
[ { "answer_id": 20118, "author": "palmsey", "author_id": 521, "author_profile": "https://Stackoverflow.com/users/521", "pm_score": 5, "selected": true, "text": "<p>If your strong declaration comes after YUI's yours should override it. You can force it like this:</p>\n\n<pre><code>strong, ...
2008/08/21
[ "https://Stackoverflow.com/questions/20107", "https://Stackoverflow.com", "https://Stackoverflow.com/users/437/" ]
This line in YUI's [Reset CSS](http://developer.yahoo.com/yui/reset/) is causing trouble for me: ```css address,caption,cite,code,dfn,em,strong,th,var { font-style: normal; font-weight: normal; } ``` It makes my `em` not italic and my `strong` not bold. Which is okay. I know how to override that in my own st...
If your strong declaration comes after YUI's yours should override it. You can force it like this: ``` strong, b, strong *, b * { font-weight: bold; } em, i, em *, i * { font-style: italic; } ``` If you still support IE7 you'll need to add `!important`. ``` strong, b, strong *, b * { font-weight: bold !important; }...
20,146
<p>I'm looking for something like the <code>tempfile</code> module in Python: A (preferably) secure way to open a file for writing to. This should be easy to delete when I'm done too...</p> <p>It seems, .NET does not have the &quot;batteries included&quot; features of the <code>tempfile</code> module, which not only cr...
[ { "answer_id": 20150, "author": "Rob Cooper", "author_id": 832, "author_profile": "https://Stackoverflow.com/users/832", "pm_score": 0, "selected": false, "text": "<p>I don't know of any built in (within the framework) classes to do this, but I imagine it wouldn't be too much of an issue...
2008/08/21
[ "https://Stackoverflow.com/questions/20146", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2260/" ]
I'm looking for something like the `tempfile` module in Python: A (preferably) secure way to open a file for writing to. This should be easy to delete when I'm done too... It seems, .NET does not have the "batteries included" features of the `tempfile` module, which not only creates the file, but returns the file desc...
I've also had the same requirement before, and I've created a small class to solve it: ``` public sealed class TemporaryFile : IDisposable { public TemporaryFile() : this(Path.GetTempPath()) { } public TemporaryFile(string directory) { Create(Path.Combine(directory, Path.GetRandomFileName())); } ~Te...
20,148
<p>I'm working on a projects which involves a lot of database writes, I'd say (<em>70% inserts and 30% reads</em>). This ratio would also include updates which I consider to be one read and one write. The reads can be dirty (e.g. I don't need 100% accurate information at the time of read).<br> The task in question wi...
[ { "answer_id": 22733, "author": "rix0rrr", "author_id": 2474, "author_profile": "https://Stackoverflow.com/users/2474", "pm_score": 8, "selected": false, "text": "<p>I'm not a database expert, and I do not speak from experience. However:</p>\n\n<p><a href=\"http://dev.mysql.com/doc/refma...
2008/08/21
[ "https://Stackoverflow.com/questions/20148", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2013/" ]
I'm working on a projects which involves a lot of database writes, I'd say (*70% inserts and 30% reads*). This ratio would also include updates which I consider to be one read and one write. The reads can be dirty (e.g. I don't need 100% accurate information at the time of read). The task in question will be doing o...
I have briefly [discussed](http://developer99.blogspot.com/2011/07/mysql-innodb-vs-myisam.html) this question in a table so you can conclude whether to go with **InnoDB** or **MyISAM**. Here is a small overview of which db storage engine you should use in which situation: ``` ...
20,156
<p>Is there an easy way in C# to create <a href="http://en.wikipedia.org/wiki/Ordinal_numbers_%28linguistics%29" rel="noreferrer">Ordinals</a> for a number? For example:</p> <ul> <li>1 returns 1st</li> <li>2 returns 2nd</li> <li>3 returns 3rd</li> <li>...etc</li> </ul> <p>Can this be done through <code>String.Format(...
[ { "answer_id": 20166, "author": "Stu", "author_id": 414, "author_profile": "https://Stackoverflow.com/users/414", "pm_score": 4, "selected": false, "text": "<p>You'll have to roll your own. From the top of my head:</p>\n\n<pre><code>public static string Ordinal(this int number)\n{\n var...
2008/08/21
[ "https://Stackoverflow.com/questions/20156", "https://Stackoverflow.com", "https://Stackoverflow.com/users/383/" ]
Is there an easy way in C# to create [Ordinals](http://en.wikipedia.org/wiki/Ordinal_numbers_%28linguistics%29) for a number? For example: * 1 returns 1st * 2 returns 2nd * 3 returns 3rd * ...etc Can this be done through `String.Format()` or are there any functions available to do this?
This page gives you a complete listing of all custom numerical formatting rules: [Custom numeric format strings](https://learn.microsoft.com/en-us/dotnet/standard/base-types/custom-numeric-format-strings) As you can see, there is nothing in there about ordinals, so it can't be done using `String.Format`. However its ...
20,185
<p>I have a collection of classes that inherit from an abstract class I created. I'd like to use the abstract class as a factory for creating instances of concrete implementations of my abstract class. </p> <p>Is there any way to hide a constructor from all code except a parent class.</p> <p>I'd like to do this basic...
[ { "answer_id": 20199, "author": "Vaibhav", "author_id": 380, "author_profile": "https://Stackoverflow.com/users/380", "pm_score": 1, "selected": false, "text": "<p>No, I don't think we can do that.</p>\n" }, { "answer_id": 20200, "author": "samjudson", "author_id": 1908, ...
2008/08/21
[ "https://Stackoverflow.com/questions/20185", "https://Stackoverflow.com", "https://Stackoverflow.com/users/392/" ]
I have a collection of classes that inherit from an abstract class I created. I'd like to use the abstract class as a factory for creating instances of concrete implementations of my abstract class. Is there any way to hide a constructor from all code except a parent class. I'd like to do this basically ``` public ...
You can make the sub classes child classes, something like this: ``` public abstract class AbstractClass { public static AbstractClass MakeAbstractClass(string args) { if (args == "a") return new ConcreteClassA(); if (args == "b") return new ConcreteClassB(); } ...
20,227
<p>Every method I write to encode a string in Java using 3DES can't be decrypted back to the original string. Does anyone have a simple code snippet that can just encode and then decode the string back to the original string?</p> <p>I know I'm making a very silly mistake somewhere in this code. Here's what I've been ...
[ { "answer_id": 20670, "author": "Boris Terzic", "author_id": 1996, "author_profile": "https://Stackoverflow.com/users/1996", "pm_score": 7, "selected": true, "text": "<p>Your code was fine except for the Base 64 encoding bit (which you mentioned was a test), the reason the output may not...
2008/08/21
[ "https://Stackoverflow.com/questions/20227", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1486/" ]
Every method I write to encode a string in Java using 3DES can't be decrypted back to the original string. Does anyone have a simple code snippet that can just encode and then decode the string back to the original string? I know I'm making a very silly mistake somewhere in this code. Here's what I've been working wit...
Your code was fine except for the Base 64 encoding bit (which you mentioned was a test), the reason the output may not have made sense is that you were displaying a raw byte array (doing toString() on a byte array returns its internal Java reference, not the String representation of the **contents**). Here's a version ...
20,245
<p>I am doing an e-commerce solution in ASP.NET which uses <a href="https://www.paypal.com/IntegrationCenter/ic_standard_home.html" rel="noreferrer">PayPal's Website Payments Standard</a> service. Together with that I use a service they offer (<a href="https://www.paypal.com/IntegrationCenter/ic_pdt.html" rel="noreferr...
[ { "answer_id": 20256, "author": "Greg Hurlman", "author_id": 35, "author_profile": "https://Stackoverflow.com/users/35", "pm_score": 0, "selected": false, "text": "<p>If I'm reading your question right, I think you're looking for the <a href=\"http://msdn.microsoft.com/en-us/library/syst...
2008/08/21
[ "https://Stackoverflow.com/questions/20245", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1801/" ]
I am doing an e-commerce solution in ASP.NET which uses [PayPal's Website Payments Standard](https://www.paypal.com/IntegrationCenter/ic_standard_home.html) service. Together with that I use a service they offer ([Payment Data Transfer](https://www.paypal.com/IntegrationCenter/ic_pdt.html)) that sends you back order in...
Something like this placed in your onload event. ``` if (Request.RequestType == "POST") { using (StreamReader sr = new StreamReader(Request.InputStream)) { if (sr.ReadLine() == "SUCCESS") { /* Do your parsing here */ } } } ``` Mind you that they might want some special...
20,249
<p>We're attemtping to merge our DLL's into one for deployment, thus ILMerge. Almost everything seems to work great. We have a couple web controls that use <code>ClientScript.RegisterClientScriptResource</code> and these are 404-ing after the merge (These worked before the merge).</p> <p>For example one of our contr...
[ { "answer_id": 20380, "author": "John Hoven", "author_id": 1907, "author_profile": "https://Stackoverflow.com/users/1907", "pm_score": 3, "selected": true, "text": "<p>OK - I got this working. It looks like the primary assembly was the only one whose assembly attributes were being copie...
2008/08/21
[ "https://Stackoverflow.com/questions/20249", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1907/" ]
We're attemtping to merge our DLL's into one for deployment, thus ILMerge. Almost everything seems to work great. We have a couple web controls that use `ClientScript.RegisterClientScriptResource` and these are 404-ing after the merge (These worked before the merge). For example one of our controls would look like ``...
OK - I got this working. It looks like the primary assembly was the only one whose assembly attributes were being copied. With copyattrs set, the last one in would win, not a merge (as far as I can tell). I created a dummy project to reference the other DLL's and included all the web resources from those projects in th...
20,272
<p>In a macro for Visual Studio 6, I wanted to run an external program, so I typed:</p> <pre><code>shell("p4 open " + ActiveDocument.FullName) </code></pre> <p>Which gave me a type mismatch runtime error. What I ended up having to type was this:</p> <pre><code>Dim wshShell Set wshShell = CreateObject("WScript.Shell"...
[ { "answer_id": 20304, "author": "Lasse V. Karlsen", "author_id": 267, "author_profile": "https://Stackoverflow.com/users/267", "pm_score": 1, "selected": false, "text": "<p>VBScript isn't Visual Basic.</p>\n" }, { "answer_id": 20353, "author": "Bryan Roth", "author_id": 2...
2008/08/21
[ "https://Stackoverflow.com/questions/20272", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1105/" ]
In a macro for Visual Studio 6, I wanted to run an external program, so I typed: ``` shell("p4 open " + ActiveDocument.FullName) ``` Which gave me a type mismatch runtime error. What I ended up having to type was this: ``` Dim wshShell Set wshShell = CreateObject("WScript.Shell") strResult = wshShell.Run("p4 open "...
As [lassevk](https://stackoverflow.com/questions/20272/why-doesnt-shell-work-in-vbscript-in-vs6#20304) pointed out, VBScript is not Visual Basic. I believe the only built in object in VBScript is the WScript object. ``` WScript.Echo "Hello, World!" ``` From the docs > > The WScript object is the root object of th...
20,298
<p>I have something like this:</p> <pre> barProgress.BeginAnimation(RangeBase.ValueProperty, new DoubleAnimation( barProgress.Value, dNextProgressValue, new Duration(TimeSpan.FromSeconds(dDuration))); </pre> <p>Now, how would you stop that animation (the <code>DoubleAnimation</code>)? The reason I want to do ...
[ { "answer_id": 20306, "author": "TheSmurf", "author_id": 1975282, "author_profile": "https://Stackoverflow.com/users/1975282", "pm_score": 8, "selected": true, "text": "<p>To stop it, call <code>BeginAnimation</code> again with the second argument set to <code>null</code>.</p>\n" }, ...
2008/08/21
[ "https://Stackoverflow.com/questions/20298", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2260/" ]
I have something like this: ``` barProgress.BeginAnimation(RangeBase.ValueProperty, new DoubleAnimation( barProgress.Value, dNextProgressValue, new Duration(TimeSpan.FromSeconds(dDuration))); ``` Now, how would you stop that animation (the `DoubleAnimation`)? The reason I want to do this, is because I would...
To stop it, call `BeginAnimation` again with the second argument set to `null`.
20,326
<p>I have a ASP.NET 1.1 application, and I'm trying to find out why when I change a ComboBox which value is used to fill another one (parent-child relation), two postbacks are produced.</p> <p>I have checked and checked the code, and I can't find the cause.</p> <p>Here are both call stacks which end in a page_load</p...
[ { "answer_id": 20348, "author": "TheSmurf", "author_id": 1975282, "author_profile": "https://Stackoverflow.com/users/1975282", "pm_score": 0, "selected": false, "text": "<p>First thing I would look for is that you don't have the second ComboBox's AutoPostBack property set to true. If you...
2008/08/21
[ "https://Stackoverflow.com/questions/20326", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1782/" ]
I have a ASP.NET 1.1 application, and I'm trying to find out why when I change a ComboBox which value is used to fill another one (parent-child relation), two postbacks are produced. I have checked and checked the code, and I can't find the cause. Here are both call stacks which end in a page\_load First postback (g...
It's a very specific problem with this code, I doubt it will be useful for someone else, but here it goes: A check was added to the combo's `onchange` with an if, if the condition was met, an explicit call to the postback function was made. If the combo was set to `AutoPostback`, asp.net added the postback call again,...
20,346
<p>What are attributes in .NET, what are they good for, and how do I create my own attributes?</p>
[ { "answer_id": 20351, "author": "TheSmurf", "author_id": 1975282, "author_profile": "https://Stackoverflow.com/users/1975282", "pm_score": 3, "selected": false, "text": "<p>An attribute is a class that contains some bit of functionality that you can apply to objects in your code. To crea...
2008/08/21
[ "https://Stackoverflow.com/questions/20346", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1595/" ]
What are attributes in .NET, what are they good for, and how do I create my own attributes?
Metadata. Data about your objects/methods/properties. For example I might declare an Attribute called: DisplayOrder so I can easily control in what order properties should appear in the UI. I could then append it to a class and write some GUI components that extract the attributes and order the UI elements appropriat...
20,386
<p>What are all the possible ways in which we can get memory leaks in .NET?</p> <p>I know of two:</p> <ol> <li>Not properly un-registering <a href="http://diditwith.net/PermaLink,guid,fcf59145-3973-468a-ae66-aaa8df9161c7.aspx" rel="nofollow noreferrer">Event Handlers/Delegates</a>.</li> <li>Not disposing dynamic chil...
[ { "answer_id": 20393, "author": "Greg Hurlman", "author_id": 35, "author_profile": "https://Stackoverflow.com/users/35", "pm_score": 4, "selected": false, "text": "<p>There's no way to provide a comprehensive list... this is very much like asking \"How can you get wet?\"</p>\n\n<p>That s...
2008/08/21
[ "https://Stackoverflow.com/questions/20386", "https://Stackoverflow.com", "https://Stackoverflow.com/users/380/" ]
What are all the possible ways in which we can get memory leaks in .NET? I know of two: 1. Not properly un-registering [Event Handlers/Delegates](http://diditwith.net/PermaLink,guid,fcf59145-3973-468a-ae66-aaa8df9161c7.aspx). 2. Not disposing dynamic child controls in Windows Forms: Example: ``` // Causes Leaks L...
Block the finalizer thread. No other objects will be garbage collected until the finalizer thread is unblocked. Thus the amount of memory used will grow and grow. Further reading: <http://dotnetdebug.net/2005/06/22/blocked-finalizer-thread/>
20,391
<p>I have a svn repo on my machine (Windows). Anyone have a script to back it up to a network share?</p> <p>I'm using the repo locally since I'm disconnected a lot. The network share is on a server with a backup strategy. I'm a perfect candidate for git/hg but I don't want to give up my VS integration just yet.</p>
[ { "answer_id": 20408, "author": "Jedi Master Spooky", "author_id": 1154, "author_profile": "https://Stackoverflow.com/users/1154", "pm_score": 2, "selected": false, "text": "<p>svnadmin dump C:\\SVNRepositorio\\Repositorio > \\\\Backups\\BkTmpSubversion\\subversiontemp.dump</p>\n\n<p>Try...
2008/08/21
[ "https://Stackoverflow.com/questions/20391", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1946/" ]
I have a svn repo on my machine (Windows). Anyone have a script to back it up to a network share? I'm using the repo locally since I'm disconnected a lot. The network share is on a server with a backup strategy. I'm a perfect candidate for git/hg but I don't want to give up my VS integration just yet.
I wrote a batch file to do this for a bunch of repos, you could just hook that batch file up to windows scheduler and run it on a schedule. ``` svnadmin hotcopy m:\Source\Q4Press\Repo m:\SvnOut\Q4Press ``` I use the hotcopy but the svn dump would work just as well.
20,426
<p>I have a tree encoded in a MySQL database as edges:</p> <pre><code>CREATE TABLE items ( num INT, tot INT, PRIMARY KEY (num) ); CREATE TABLE tree ( orig INT, term INT FOREIGN KEY (orig,term) REFERENCES items (num,num) ) </code></pre> <p>For each leaf in the tree, <code>items.tot</cod...
[ { "answer_id": 21019, "author": "Chris Hanson", "author_id": 714, "author_profile": "https://Stackoverflow.com/users/714", "pm_score": 3, "selected": false, "text": "<p>Xcode has refactoring for C and Objective-C built in. Just select what you'd like to refactor, choose \"Refactor...\" ...
2008/08/21
[ "https://Stackoverflow.com/questions/20426", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1343/" ]
I have a tree encoded in a MySQL database as edges: ``` CREATE TABLE items ( num INT, tot INT, PRIMARY KEY (num) ); CREATE TABLE tree ( orig INT, term INT FOREIGN KEY (orig,term) REFERENCES items (num,num) ) ``` For each leaf in the tree, `items.tot` is set by someone. For interior no...
You sound as if you're looking for three major things: code templates, refactoring tools, and auto-completion. The good news is that Xcode 3 and later come with superb auto-completion and template support. By default, you have to explicitly request completion by hitting the escape key. (This actually works in all `NST...
20,450
<p>I'd like to take some RTF input and clean it to remove all RTF formatting except \ul \b \i to paste it into Word with minor format information.</p> <p>The command used to paste into Word will be something like: oWord.ActiveDocument.ActiveWindow.Selection.PasteAndFormat(0) (with some RTF text already in the Clipboar...
[ { "answer_id": 20498, "author": "Chris Miller", "author_id": 206, "author_profile": "https://Stackoverflow.com/users/206", "pm_score": 2, "selected": false, "text": "<p>You can strip out the tags with regular expressions. Just make sure that your expressions will not filter tags that we...
2008/08/21
[ "https://Stackoverflow.com/questions/20450", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1508/" ]
I'd like to take some RTF input and clean it to remove all RTF formatting except \ul \b \i to paste it into Word with minor format information. The command used to paste into Word will be something like: oWord.ActiveDocument.ActiveWindow.Selection.PasteAndFormat(0) (with some RTF text already in the Clipboard) ``` {\...
I would use a hidden RichTextBox, set the Rtf member, then retrieve the Text member to sanitize the RTF in a well-supported way. Then I would use manually inject the desired formatting afterwards.
20,465
<p>I'm developing an Excel 2007 add-in using Visual Studio Tools for Office (2008). I have one sheet with several ListObjects on it, which are being bound to datatables on startup. When they are bound, they autosize correctly.</p> <p>The problem comes when they are re-bound. I have a custom button on the ribbon bar...
[ { "answer_id": 23735, "author": "Guy", "author_id": 1463, "author_profile": "https://Stackoverflow.com/users/1463", "pm_score": 0, "selected": false, "text": "<p>Just an idea of something to try to see if it gives you more info: Try resizes the list object before the exception line and s...
2008/08/21
[ "https://Stackoverflow.com/questions/20465", "https://Stackoverflow.com", "https://Stackoverflow.com/users/940/" ]
I'm developing an Excel 2007 add-in using Visual Studio Tools for Office (2008). I have one sheet with several ListObjects on it, which are being bound to datatables on startup. When they are bound, they autosize correctly. The problem comes when they are re-bound. I have a custom button on the ribbon bar which goes b...
If anyone else is having this problem, I have found the cause of this exception. ListObjects will automatically re-size on binding, as long as they do not affect any other objects on the sheet. Keep in mind that ListObjects can only affect the Ranges which they wrap around. In my case, the list object which was above ...
20,467
<p>Are there any automatic methods for trimming a path string in .NET?</p> <p>For example:</p> <pre><code>C:\Documents and Settings\nick\My Documents\Tests\demo data\demo data.emx </code></pre> <p>becomes</p> <pre><code>C:\Documents...\demo data.emx </code></pre> <p>It would be particularly cool if this were built...
[ { "answer_id": 20492, "author": "Darren Kopp", "author_id": 77, "author_profile": "https://Stackoverflow.com/users/77", "pm_score": 0, "selected": false, "text": "<p>What you are thinking on the label is that it will put ... if it is longer than the width (not set to auto size), but that...
2008/08/21
[ "https://Stackoverflow.com/questions/20467", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1490/" ]
Are there any automatic methods for trimming a path string in .NET? For example: ``` C:\Documents and Settings\nick\My Documents\Tests\demo data\demo data.emx ``` becomes ``` C:\Documents...\demo data.emx ``` It would be particularly cool if this were built into the Label class, and I seem to recall it is--can't...
Use **TextRenderer.DrawText** with **TextFormatFlags.PathEllipsis** flag ``` void label_Paint(object sender, PaintEventArgs e) { Label label = (Label)sender; TextRenderer.DrawText(e.Graphics, label.Text, label.Font, label.ClientRectangle, label.ForeColor, TextFormatFlags.PathEllipsis); } ``` > > Your code is 95...
20,484
<p>Can/Should I use a LIKE criteria as part of an INNER JOIN when building a stored procedure/query? I'm not sure I'm asking the right thing, so let me explain.</p> <p>I'm creating a procedure that is going to take a list of keywords to be searched for in a column that contains text. If I was sitting at the console, I...
[ { "answer_id": 20513, "author": "Nick Berardi", "author_id": 17, "author_profile": "https://Stackoverflow.com/users/17", "pm_score": 1, "selected": false, "text": "<p>It seems like you are looking for full-text search. Because you want to query a set of keywords against the card descrip...
2008/08/21
[ "https://Stackoverflow.com/questions/20484", "https://Stackoverflow.com", "https://Stackoverflow.com/users/71/" ]
Can/Should I use a LIKE criteria as part of an INNER JOIN when building a stored procedure/query? I'm not sure I'm asking the right thing, so let me explain. I'm creating a procedure that is going to take a list of keywords to be searched for in a column that contains text. If I was sitting at the console, I'd execute...
Your first query will work but will require a full table scan because any index on that column will be ignored. You will also have to do some dynamic SQL to generate all your LIKE clauses. Try a full text search if your using SQL Server or check out one of the [Lucene](http://lucene.apache.org/java/docs/index.html) im...
20,510
<p>I have a flex application that needs the ability to generate and execute JavaScript. When I say this, I mean I need to execute raw JavaScript that I create in my Flex application (not just an existing JavaScript method)</p> <p>I am currently doing this by exposing the following JavaScript method:</p> <pre><code>fu...
[ { "answer_id": 20532, "author": "Darren Kopp", "author_id": 77, "author_profile": "https://Stackoverflow.com/users/77", "pm_score": 0, "selected": false, "text": "<p>As far as I know, and I'm definately not a hacker, you are completely fine. Really, if someone wanted to, they could explo...
2008/08/21
[ "https://Stackoverflow.com/questions/20510", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1638/" ]
I have a flex application that needs the ability to generate and execute JavaScript. When I say this, I mean I need to execute raw JavaScript that I create in my Flex application (not just an existing JavaScript method) I am currently doing this by exposing the following JavaScript method: ``` function doScript(js){ ...
There's no need for the JavaScript function, the first argument to `ExternalInterface` can be any JavaScript code, it doesn't have to be a function name (the documentation says so, but it is wrong). Try this: ``` ExternalInterface.call("alert('hello')"); ```
20,586
<p>I'm trying to bind a list of custom objects to a WPF Image like this:</p> <pre><code>&lt;Image&gt; &lt;Image.Source&gt; &lt;BitmapImage UriSource="{Binding Path=ImagePath}" /&gt; &lt;/Image.Source&gt; &lt;/Image&gt; </code></pre> <p>But it doesn't work. This is the error I'm getting:</p> <p><em>"P...
[ { "answer_id": 20617, "author": "Dale Ragan", "author_id": 1117, "author_profile": "https://Stackoverflow.com/users/1117", "pm_score": 3, "selected": false, "text": "<p>You need to have an implementation of <a href=\"http://msdn.microsoft.com/en-us/library/system.windows.data.ivalueconve...
2008/08/21
[ "https://Stackoverflow.com/questions/20586", "https://Stackoverflow.com", "https://Stackoverflow.com/users/373/" ]
I'm trying to bind a list of custom objects to a WPF Image like this: ``` <Image> <Image.Source> <BitmapImage UriSource="{Binding Path=ImagePath}" /> </Image.Source> </Image> ``` But it doesn't work. This is the error I'm getting: *"Property 'UriSource' or property 'StreamSource' must be set."* Wha...
WPF has built-in converters for certain types. If you bind the Image's `Source` property to a `string` or `Uri` value, under the hood WPF will use an [ImageSourceConverter](https://msdn.microsoft.com/en-us/library/system.windows.media.imagesourceconverter(v=vs.110).aspx) to convert the value to an `ImageSource`. So `...
20,587
<p>I want to get the results of a stored procedure and place them into a CSV file onto an FTP location.</p> <p>The catch though is that I cannot create a local/temporary file that I can then FTP over.</p> <p>The approach I was taking was to use an SSIS package to create a temporary file and then have a FTP Task withi...
[ { "answer_id": 20593, "author": "Eric Z Beard", "author_id": 1219, "author_profile": "https://Stackoverflow.com/users/1219", "pm_score": 0, "selected": false, "text": "<p>Try using a CLR stored procedure. You might be able to come up with something, but without first creating a temporar...
2008/08/21
[ "https://Stackoverflow.com/questions/20587", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1950/" ]
I want to get the results of a stored procedure and place them into a CSV file onto an FTP location. The catch though is that I cannot create a local/temporary file that I can then FTP over. The approach I was taking was to use an SSIS package to create a temporary file and then have a FTP Task within the pack to FTP...
This step-by-step example is for others who might stumble upon this question. This example uses *Windows Server 2008 R2 server* and *SSIS 2008 R2*. Even though, the example uses *SSIS 2008 R2*, the logic used is applicable to *SSIS 2005* as well. Thanks to `@Kev` for the *FTPWebRequest* code. Create an SSIS package ([...
20,598
<p>I'm interested in doing comparisons between the date string and the MySQL timestamp. However, I'm not seeing an easy conversion. Am I overlooking something obvious?</p>
[ { "answer_id": 20605, "author": "Ross", "author_id": 2025, "author_profile": "https://Stackoverflow.com/users/2025", "pm_score": 5, "selected": true, "text": "<p>Converting from timestamp to format:</p>\n\n<pre><code>date('Y-m-d', $timestamp);\n</code></pre>\n\n<p>Converting from formatt...
2008/08/21
[ "https://Stackoverflow.com/questions/20598", "https://Stackoverflow.com", "https://Stackoverflow.com/users/572/" ]
I'm interested in doing comparisons between the date string and the MySQL timestamp. However, I'm not seeing an easy conversion. Am I overlooking something obvious?
Converting from timestamp to format: ``` date('Y-m-d', $timestamp); ``` Converting from formatted to timestamp: ``` mktime(0, 0, 0, $month, $day, $year, $is_dst); ``` See [date](http://www.php.net/manual/en/function.date.php) and [mktime](http://www.php.net/manual/en/function.mktime.php) for further documentation...
20,611
<p>The following code should find the appropriate project tag and remove it from the XmlDocument, however when I test it, it says:</p> <p><strong>The node to be removed is not a child of this node.</strong></p> <p>Does anyone know the proper way to do this?</p> <pre><code>public void DeleteProject (string projectNam...
[ { "answer_id": 20614, "author": "Greg Hurlman", "author_id": 35, "author_profile": "https://Stackoverflow.com/users/35", "pm_score": 1, "selected": false, "text": "<p>Is it possible that the project nodes aren't child nodes, but grandchildren or lower? GetElementsByTagName will give you...
2008/08/21
[ "https://Stackoverflow.com/questions/20611", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1965/" ]
The following code should find the appropriate project tag and remove it from the XmlDocument, however when I test it, it says: **The node to be removed is not a child of this node.** Does anyone know the proper way to do this? ``` public void DeleteProject (string projectName) { string ccConfigPath = Configurat...
Instead of ``` configDoc.RemoveChild(projectNodes[i]); ``` try ``` projectNodes[i].parentNode.RemoveChild(projectNodes[i]); ```
20,674
<p>Other than <code>self.class.send :method, args...</code>, of course. I'd like to make a rather complex method available at both the class and instance level without duplicating the code.</p> <hr> <p><strong>UPDATE:</strong> </p> <p>@Jonathan Branam: that was my assumption, but I wanted to make sure nobody else ...
[ { "answer_id": 20690, "author": "John", "author_id": 2168, "author_profile": "https://Stackoverflow.com/users/2168", "pm_score": -1, "selected": false, "text": "<p>Unless I'm misunderstanding, don't you just need something like this:</p>\n\n<pre><code>class Foo\n private\n def Foo....
2008/08/21
[ "https://Stackoverflow.com/questions/20674", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1190/" ]
Other than `self.class.send :method, args...`, of course. I'd like to make a rather complex method available at both the class and instance level without duplicating the code. --- **UPDATE:** @Jonathan Branam: that was my assumption, but I wanted to make sure nobody else had found a way around. Visibility in Ruby i...
Here is a code snippet to go along with the question. Using "private" in a class definition does not apply to class methods. You need to use "private\_class\_method" as in the following example. ``` class Foo def self.private_bar # Complex logic goes here puts "hi" end private_class_method :private_bar ...
20,696
<p>In E (specman) I want to declare variables that are lists, and I want to fix their lengths.</p> <p>It's easy to do for a member of a struct:</p> <pre><code>thread[2] : list of thread_t; </code></pre> <p>while for a "regular" variable in a function the above doesn't work, and I have to do something like:</p> <pre...
[ { "answer_id": 28801, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": -1, "selected": false, "text": "<p>I know nothing of specman, but a fixed sized list is an array, so that might point you somewhere.</p>\n" }, { ...
2008/08/21
[ "https://Stackoverflow.com/questions/20696", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1084/" ]
In E (specman) I want to declare variables that are lists, and I want to fix their lengths. It's easy to do for a member of a struct: ``` thread[2] : list of thread_t; ``` while for a "regular" variable in a function the above doesn't work, and I have to do something like: ``` var warned : list of bool; gen warned...
A hard keep like you have is only going to fix the size at initialization but elements could still be added or dropped later, are you trying to guard against this condition? The only way I can think of to guarantee that elements aren't added or dropped later is emitting an event synced on the size != the predetermined ...
20,722
<p>How can I efficiently and effectively detect the version and, for that matter, any available information about the instance of <a href="http://silverlight.net/" rel="nofollow noreferrer">Silverlight</a> currently running on the browser?</p>
[ { "answer_id": 20729, "author": "Stu", "author_id": 414, "author_profile": "https://Stackoverflow.com/users/414", "pm_score": 0, "selected": false, "text": "<p>Look in silverlight.js:</p>\n\n<p><a href=\"http://forums.asp.net/p/1135746/1997617.aspx#1997617\" rel=\"nofollow noreferrer\">h...
2008/08/21
[ "https://Stackoverflow.com/questions/20722", "https://Stackoverflow.com", "https://Stackoverflow.com/users/375/" ]
How can I efficiently and effectively detect the version and, for that matter, any available information about the instance of [Silverlight](http://silverlight.net/) currently running on the browser?
The Silverlight control only has an [IsVersionSupported function](http://msdn.microsoft.com/en-us/library/system.windows.interop.silverlighthost.isversionsupported(VS.95).aspx), which returns true / false when you give it a version number, e.g.: ``` if(slPlugin.isVersionSupported("2.0")) { alert("I haz some flavour ...
20,731
<p>I've tried several things already,</p> <pre><code>std::stringstream m; m.empty(); m.clear(); </code></pre> <p>both of which don't work.</p>
[ { "answer_id": 20732, "author": "CodingWithoutComments", "author_id": 25, "author_profile": "https://Stackoverflow.com/users/25", "pm_score": 5, "selected": false, "text": "<pre><code>m.str(\"\");\n</code></pre>\n\n<p>seems to work.</p>\n" }, { "answer_id": 20792, "author": "...
2008/08/21
[ "https://Stackoverflow.com/questions/20731", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25/" ]
I've tried several things already, ``` std::stringstream m; m.empty(); m.clear(); ``` both of which don't work.
For all the standard library types the member function `empty()` is a query, not a command, i.e. it means "are you empty?" not "please throw away your contents". The `clear()` member function is inherited from `ios` and is used to clear the error state of the stream, e.g. if a file stream has the error state set to `e...
20,744
<p>Using the viewer control for display of SQL Reporting Services reports on web page (Microsoft.ReportViewer.WebForms), can you move the View Report button? It defaults to the very right side of the report, which means you have to scroll all the way across before the button is visible. Not a problem for reports that f...
[ { "answer_id": 20781, "author": "Bryan Roth", "author_id": 299, "author_profile": "https://Stackoverflow.com/users/299", "pm_score": 2, "selected": false, "text": "<p>No, you cannot reposition the view report button in the ReportViewer control.</p>\n\n<p>However, you could create your ow...
2008/08/21
[ "https://Stackoverflow.com/questions/20744", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1215/" ]
Using the viewer control for display of SQL Reporting Services reports on web page (Microsoft.ReportViewer.WebForms), can you move the View Report button? It defaults to the very right side of the report, which means you have to scroll all the way across before the button is visible. Not a problem for reports that fit ...
It's kind of a hack, but you can move it in JavaScript. Just see what HTML the ReportViewer generates, and write the appropriate JavaScript code to move the button. I used JavaScript to hide the button (because we wanted our own View Report button). Any JavaScript code that manipulates the generated ReportViewer's HTML...
20,762
<p>Is there any easy/general way to clean an XML based data source prior to using it in an XmlReader so that I can gracefully consume XML data that is non-conformant to the hexadecimal character restrictions placed on XML?</p> <p>Note: </p> <ul> <li>The solution needs to handle XML data sources that use character enc...
[ { "answer_id": 20777, "author": "Eugene Katz", "author_id": 1533, "author_profile": "https://Stackoverflow.com/users/1533", "pm_score": 7, "selected": true, "text": "<p>It <strong>may not be perfect</strong> (emphasis added since people missing this disclaimer), but what I've done in tha...
2008/08/21
[ "https://Stackoverflow.com/questions/20762", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2029/" ]
Is there any easy/general way to clean an XML based data source prior to using it in an XmlReader so that I can gracefully consume XML data that is non-conformant to the hexadecimal character restrictions placed on XML? Note: * The solution needs to handle XML data sources that use character encodings other than UTF...
It **may not be perfect** (emphasis added since people missing this disclaimer), but what I've done in that case is below. You can adjust to use with a stream. ``` /// <summary> /// Removes control characters and other non-UTF-8 characters /// </summary> /// <param name="inString">The string to process</param> /// <re...
20,778
<p>I have binary data in a file that I can read into a byte array and process with no problem. Now I need to send parts of the data over a network connection as elements in an XML document. My problem is that when I convert the data from an array of bytes to a String and back to an array of bytes, the data is getting...
[ { "answer_id": 20779, "author": "Sam", "author_id": 428, "author_profile": "https://Stackoverflow.com/users/428", "pm_score": 5, "selected": true, "text": "<p>If you encode it in base64, this will turn any data into ascii safe text, but base64 encoded data is larger than the orignal data...
2008/08/21
[ "https://Stackoverflow.com/questions/20778", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1288/" ]
I have binary data in a file that I can read into a byte array and process with no problem. Now I need to send parts of the data over a network connection as elements in an XML document. My problem is that when I convert the data from an array of bytes to a String and back to an array of bytes, the data is getting corr...
If you encode it in base64, this will turn any data into ascii safe text, but base64 encoded data is larger than the orignal data
20,794
<p>If I call <code>os.stat()</code> on a broken <code>symlink</code>, python throws an <code>OSError</code> exception. This makes it useful for finding them. However, there are a few other reasons that <code>os.stat()</code> might throw a similar exception. Is there a more precise way of detecting broken <code>symlinks...
[ { "answer_id": 20843, "author": "dlamblin", "author_id": 459, "author_profile": "https://Stackoverflow.com/users/459", "pm_score": 2, "selected": false, "text": "<p>Can I mention testing for hardlinks without python? /bin/test has the FILE1 -ef FILE2 condition that is true when files sha...
2008/08/21
[ "https://Stackoverflow.com/questions/20794", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1892/" ]
If I call `os.stat()` on a broken `symlink`, python throws an `OSError` exception. This makes it useful for finding them. However, there are a few other reasons that `os.stat()` might throw a similar exception. Is there a more precise way of detecting broken `symlinks` with Python under Linux?
A common Python saying is that it's easier to ask forgiveness than permission. While I'm not a fan of this statement in real life, it does apply in a lot of cases. Usually you want to avoid code that chains two system calls on the same file, because you never know what will happen to the file in between your two calls ...
20,797
<p>I have a byte array in memory, read from a file. I would like to split the byte array at a certain point (index) without having to just create a new byte array and copy each byte at a time, increasing the in memory foot print of the operation. What I would like is something like this:</p> <pre><code>byte[] largeBy...
[ { "answer_id": 20826, "author": "Stu", "author_id": 414, "author_profile": "https://Stackoverflow.com/users/414", "pm_score": 0, "selected": false, "text": "<p>You can't. What you might want is keep a starting point and number of items; in essence, build iterators. If this is C++, you ca...
2008/08/21
[ "https://Stackoverflow.com/questions/20797", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1048/" ]
I have a byte array in memory, read from a file. I would like to split the byte array at a certain point (index) without having to just create a new byte array and copy each byte at a time, increasing the in memory foot print of the operation. What I would like is something like this: ``` byte[] largeBytes = [1,2,3,4,...
This is how I would do that: ``` using System; using System.Collections; using System.Collections.Generic; class ArrayView<T> : IEnumerable<T> { private readonly T[] array; private readonly int offset, count; public ArrayView(T[] array, int offset, int count) { this.array = array; thi...
20,840
<p>Why should I or shouldn't I use dirty reads:</p> <pre><code>set transaction isolation level read uncommitted </code></pre> <p>in SQL Server?</p>
[ { "answer_id": 20879, "author": "Tokabi", "author_id": 315, "author_profile": "https://Stackoverflow.com/users/315", "pm_score": 3, "selected": false, "text": "<p>Generally when you need to do a sizeable (or frequent) queries to busy tables, where read committed would possibly be blocked...
2008/08/21
[ "https://Stackoverflow.com/questions/20840", "https://Stackoverflow.com", "https://Stackoverflow.com/users/357/" ]
Why should I or shouldn't I use dirty reads: ``` set transaction isolation level read uncommitted ``` in SQL Server?
From [MSDN](http://msdn.microsoft.com/en-us/library/aa259216(SQL.80).aspx): > > When this option is set, it is possible to read uncommitted or dirty data; values in the data can be changed and rows can appear or disappear in the data set before the end of the transaction. > > > Simply put, when you are using thi...
20,850
<p>I'm a bit newbieish when it comes to the deeper parts of OSX configuration and am having to put up with a fairly irritating niggle which while I can put up with it, I know under Windows I could have sorted in minutes.</p> <p>Basically, I have an external disk with two volumes: </p> <p>One is an HFS+ volume which I...
[ { "answer_id": 21101, "author": "Orion Edwards", "author_id": 234, "author_profile": "https://Stackoverflow.com/users/234", "pm_score": 1, "selected": false, "text": "<p>This is not directly an answer, but</p>\n\n<blockquote>\n <p>The thing is that to remove the disk you have to eject t...
2008/08/21
[ "https://Stackoverflow.com/questions/20850", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1120/" ]
I'm a bit newbieish when it comes to the deeper parts of OSX configuration and am having to put up with a fairly irritating niggle which while I can put up with it, I know under Windows I could have sorted in minutes. Basically, I have an external disk with two volumes: One is an HFS+ volume which I use for TimeMach...
The following entry in `/etc/fstab` will do what you want, even on 10.5 (Leopard): ``` LABEL=VolumeName none ntfs noauto ``` If the file is not already there, just create it. Do not use `/etc/fstab.hd`! No reloading of `diskarbitrationd` needed. If this still doesn't work for you, maybe you can find a hint i...
20,856
<p>I've heard of a few ways to implement tagging; using a mapping table between TagID and ItemID (makes sense to me, but does it scale?), adding a fixed number of possible TagID columns to ItemID (seems like a bad idea), Keeping tags in a text column that's comma separated (sounds crazy but could work). I've even heard...
[ { "answer_id": 20871, "author": "Yaakov Ellis", "author_id": 51, "author_profile": "https://Stackoverflow.com/users/51", "pm_score": 10, "selected": true, "text": "<p>Three tables (one for storing all items, one for all tags, and one for the relation between the two), properly indexed, w...
2008/08/21
[ "https://Stackoverflow.com/questions/20856", "https://Stackoverflow.com", "https://Stackoverflow.com/users/459/" ]
I've heard of a few ways to implement tagging; using a mapping table between TagID and ItemID (makes sense to me, but does it scale?), adding a fixed number of possible TagID columns to ItemID (seems like a bad idea), Keeping tags in a text column that's comma separated (sounds crazy but could work). I've even heard so...
Three tables (one for storing all items, one for all tags, and one for the relation between the two), properly indexed, with foreign keys set running on a proper database, should work well and scale properly. ``` Table: Item Columns: ItemID, Title, Content Table: Tag Columns: TagID, Title Table: ItemTag Columns: It...
20,876
<p>I'm new to SQL Server Reporting Services, and was wondering the best way to do the following:</p> <blockquote> <ul> <li>Query to get a list of popular IDs</li> <li>Subquery on each item to get properties from another table</li> </ul> </blockquote> <p>Ideally, the final report columns would look like this:<...
[ { "answer_id": 20895, "author": "Bryan Roth", "author_id": 299, "author_profile": "https://Stackoverflow.com/users/299", "pm_score": 3, "selected": true, "text": "<p>I would recommend using a <a href=\"http://msdn.microsoft.com/en-us/library/ms160348.aspx\" rel=\"nofollow noreferrer\">Su...
2008/08/21
[ "https://Stackoverflow.com/questions/20876", "https://Stackoverflow.com", "https://Stackoverflow.com/users/109/" ]
I'm new to SQL Server Reporting Services, and was wondering the best way to do the following: > > * Query to get a list of popular IDs > * Subquery on each item to get properties from another table > > > Ideally, the final report columns would look like this: ``` [ID] [property1] [property2] [SELECT COUNT(*) ...
I would recommend using a [SubReport](http://msdn.microsoft.com/en-us/library/ms160348.aspx). You would place the SubReport in a table cell.
20,923
<p>I need to script the creation of app pools and websites on IIS 6.0. I have been able to create these using adsutil.vbs and iisweb.vbs, but don't know how to set the version of ASP.NET for the sites I have just created to 2.0.50727.0.</p> <p>Ideally I would like to adsutil.vbs to update the metabase. How do I do thi...
[ { "answer_id": 20953, "author": "Chris Miller", "author_id": 206, "author_profile": "https://Stackoverflow.com/users/206", "pm_score": 2, "selected": false, "text": "<p>I found the following script <a href=\"http://www.diablopup.net/post/Set-an-IIS-Object%27s-ASPNET-Version-Using-VBScrip...
2008/08/21
[ "https://Stackoverflow.com/questions/20923", "https://Stackoverflow.com", "https://Stackoverflow.com/users/636/" ]
I need to script the creation of app pools and websites on IIS 6.0. I have been able to create these using adsutil.vbs and iisweb.vbs, but don't know how to set the version of ASP.NET for the sites I have just created to 2.0.50727.0. Ideally I would like to adsutil.vbs to update the metabase. How do I do this?
@[Chris](https://stackoverflow.com/questions/20923/vbscriptiis-how-do-i-automatically-set-aspnet-version-for-a-particular-website#20953) beat me to the punch on the ADSI way You can do this using the aspnet\_regiis.exe tool. There is one of these tools per version of ASP.NET installed on the machine. You could shell o...
20,926
<p>Today I was working on a tab navigation for a webpage. I tried the <a href="http://www.alistapart.com/articles/slidingdoors2/" rel="noreferrer">Sliding Doors</a> approach which worked fine. Then I realized that I must include an option to delete a tab (usually a small X in the right corner of each tab). </p> <p>I w...
[ { "answer_id": 20944, "author": "Yaakov Ellis", "author_id": 51, "author_profile": "https://Stackoverflow.com/users/51", "pm_score": 4, "selected": true, "text": "<p>They must be doing some really crazy stuff with JavaScript to get it to work (notice how neither the parent nor the nested...
2008/08/21
[ "https://Stackoverflow.com/questions/20926", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2078/" ]
Today I was working on a tab navigation for a webpage. I tried the [Sliding Doors](http://www.alistapart.com/articles/slidingdoors2/) approach which worked fine. Then I realized that I must include an option to delete a tab (usually a small X in the right corner of each tab). I wanted to use a nested anchor, which di...
They must be doing some really crazy stuff with JavaScript to get it to work (notice how neither the parent nor the nested anchor tags have a name or href attribute - all functionality is done through the class name and JS). Here is what the html looks like: ``` <a class="page_tab page_tab"> <div class="page_title"...
20,927
<p>I've got two models: Message and Attachment. Each attachment is attached to a specific message, using a ForeignKey on the Attachment model. Both models have an auto_now DateTimeField called updated. I'm trying to make it so that when any attachment is saved, it also sets the updated field on the associated message t...
[ { "answer_id": 20983, "author": "John", "author_id": 2168, "author_profile": "https://Stackoverflow.com/users/2168", "pm_score": 5, "selected": true, "text": "<p>You would also need to then save the message. Then it that should work.</p>\n" }, { "answer_id": 72359, "author":...
2008/08/21
[ "https://Stackoverflow.com/questions/20927", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1914/" ]
I've got two models: Message and Attachment. Each attachment is attached to a specific message, using a ForeignKey on the Attachment model. Both models have an auto\_now DateTimeField called updated. I'm trying to make it so that when any attachment is saved, it also sets the updated field on the associated message to ...
You would also need to then save the message. Then it that should work.