qid int64 4 22.2M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
294,355 | <p>Does anyone know of a good YAML Parser for PHP? If so, what are the pros and cons of this library?</p>
| [
{
"answer_id": 854262,
"author": "drowe",
"author_id": 105563,
"author_profile": "https://Stackoverflow.com/users/105563",
"pm_score": 6,
"selected": false,
"text": "require_once \"spyc.php\";\n$data = Spyc::YAMLLoad($myfile);\n"
},
{
"answer_id": 2446512,
"author": "takeshin... | 2008/11/16 | [
"https://Stackoverflow.com/questions/294355",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2327/"
] |
294,382 | <p>Is there any reason to prefer a <code>CharBuffer</code> to a <code>char[]</code> in the following:</p>
<pre><code>CharBuffer buf = CharBuffer.allocate(DEFAULT_BUFFER_SIZE);
while( in.read(buf) >= 0 ) {
out.append( buf.flip() );
buf.clear();
}
</code></pre>
<p>vs.</p>
<pre><code>char[] buf = new char[DEFAULT_BUFFER_SIZE];
int n;
while( (n = in.read(buf)) >= 0 ) {
out.write( buf, 0, n );
}
</code></pre>
<p>(where <code>in</code> is a <code>Reader</code> and <code>out</code> in a <code>Writer</code>)?</p>
| [
{
"answer_id": 294469,
"author": "erickson",
"author_id": 3474,
"author_profile": "https://Stackoverflow.com/users/3474",
"pm_score": 5,
"selected": true,
"text": "CharBuffer"
},
{
"answer_id": 295190,
"author": "Ron Tuffin",
"author_id": 939,
"author_profile": "https... | 2008/11/16 | [
"https://Stackoverflow.com/questions/294382",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1412/"
] |
294,443 | <p>I'm looking for a consistent way to structure my use of formatting strings throughout a large web application, and I'm looking for recommendations or best practices on which way to go.</p>
<p>Up until now I've had a static class that does some common formatting e.g.</p>
<p>Formatting.FormatCurrency</p>
<p>Formatting.FormatBookingReference</p>
<p>I'm not convinced that this is the way to go though, I'd prefer to use the standard way of formatting strings within .NET directly and use:</p>
<p>amount.ToString("c")</p>
<p>reference.ToString("000000")</p>
<p>Id use IFormattable and ICustomFormatter for some of our more complicated data structures, but I'm struggling what to do about the more simple existing objects that we need to format (in this case Int32 but also DateTime). </p>
<p>Do I simply define constants for "c" and "000000" and use them consistently around the whole web app or is there a more standard way to do it?</p>
| [
{
"answer_id": 294448,
"author": "GeekyMonkey",
"author_id": 29900,
"author_profile": "https://Stackoverflow.com/users/29900",
"pm_score": 5,
"selected": true,
"text": "public static class MyWebAppExtensions\n{\n public static string FormatCurrency(this decimal d)\n {\n retu... | 2008/11/16 | [
"https://Stackoverflow.com/questions/294443",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5777/"
] |
294,444 | <p>I have long tables generated by datagrid control that go beyond the page width. I would like to convert that into separate table for each row or definition list where each field name is followed by field value.</p>
<p>How would I do that. </p>
| [
{
"answer_id": 294575,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 3,
"selected": true,
"text": "$(document).ready(\n function() {\n\n var headers = $('tr:first').children();\n\n $('tr:not(:first)').e... | 2008/11/16 | [
"https://Stackoverflow.com/questions/294444",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35513/"
] |
294,465 | <p>DBD, and Oracle Masters:</p>
<p>I have a Perl web application that is behaving oddly. I am using it to read some stuff from an Oracle DB and report. I have version 11.1.0.6.0 of Oracle's Instant Client installed. I'm running on WinXP and have the PATH environment variable set to the instant client location. I have Apache2 for my webserver.</p>
<p>Here's the issue: when I run the app from a command line, it works without a hitch. However, when I run from <a href="http://127.0.0.1/cgi-bin/a.cgi" rel="nofollow noreferrer">http://127.0.0.1/cgi-bin/a.cgi</a>, I get the following DB access error:</p>
<blockquote>
<p><code>install_driver(Oracle) failed: Can't load 'C:/usr/lib/auto/DBD/Oracle/Oracle.dll' for module DBD::Oracle: load_file:The specified module could not be found at C:/usr/lib/DynaLoader.pm line 202. at (eval 9) line 3</code></p>
</blockquote>
<p>Intuition tells me it's a permission issue, but I'm not sure where to look further. Can anyone shed some light on this? I would much appreciate any help.</p>
<p>Thanks,
Saker Ghani</p>
| [
{
"answer_id": 294476,
"author": "Alnitak",
"author_id": 6782,
"author_profile": "https://Stackoverflow.com/users/6782",
"pm_score": 2,
"selected": false,
"text": "open"
}
] | 2008/11/16 | [
"https://Stackoverflow.com/questions/294465",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
294,468 | <p>I am developing a system as an aid to musicians performing transcription. The aim is to perform automatic music transcription (it does not have to be perfect, as the user will correct glitches / mistakes later) on a single instrument monophonic recording. Does anyone here have experience in automatic music transcription? Or digital signal processing in general? Help from anyone is greatly appreciated no matter what your background.</p>
<p>So far I have investigated the use of the Fast Fourier Transform for pitch detection, and a number of tests in both MATLAB and my own Java test programs have shown it to be fast and accurate enough for my needs. Another element of the task that will need to be tackled is the display of the produced MIDI data in sheet music form, but this is something I am not concerned with right now.</p>
<p>In brief, what I am looking for is a good method for note onset detection, i.e. the position in the signal where a new note begins. As slow onsets can be quite difficult to detect properly, I will initially be using the system with piano recordings. This is also partially due to the fact I play piano and should be in a better position to obtain suitable recordings for testing. As stated above, early versions of this system will be used for simple monophonic recordings, possibly progressing later to more complex input depending on progress made in the coming weeks.</p>
| [
{
"answer_id": 294724,
"author": "MusiGenesis",
"author_id": 14606,
"author_profile": "https://Stackoverflow.com/users/14606",
"pm_score": 7,
"selected": true,
"text": "short threshold = 10000;\nfor (int i = 0; i < samples.Length; i++)\n{\n if ((short)Math.Abs(samples[i]) > threshold)... | 2008/11/16 | [
"https://Stackoverflow.com/questions/294468",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11650/"
] |
294,470 | <p>I need to set my process to run under 'nobody', I've found os.setuid(), but how do I find <code>uid</code> if I have <code>login</code>?</p>
<p>I've found out that uids are in /etc/passwd, but maybe there is a more pythonic way than scanning /etc/passwd. Anybody?</p>
| [
{
"answer_id": 294480,
"author": "TFKyle",
"author_id": 19208,
"author_profile": "https://Stackoverflow.com/users/19208",
"pm_score": 5,
"selected": true,
"text": "import pwd\npw = pwd.getpwnam(\"nobody\")\nuid = pw.pw_uid\n"
},
{
"answer_id": 294535,
"author": "CesarB",
... | 2008/11/16 | [
"https://Stackoverflow.com/questions/294470",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37141/"
] |
294,485 | <p>When I run my asp.net app I get the error</p>
<blockquote>
<p>The type ‘System.Web.UI.ScriptManager’ is ambiguous:</p>
</blockquote>
<p>I am having the same problem this person is having <a href="http://forums.asp.net/t/1313257.aspx" rel="nofollow noreferrer">http://forums.asp.net/t/1313257.aspx</a> , when I change the 1.0.61025.0 to 3.5 and re-compile It resets it to 1.0.61025.0</p>
<p>what I can I do to resolve this. I've been trying to get my app running for hours now.</p>
<p>Thanks</p>
<p>Edit ~ HELPPpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp</p>
<p>I see 2 system.web.extensions in the GAC. I tried to remove with gacutil.exe /u system.web.ext
ensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
Microsoft (R) .NET Global Assembly Cache Utility. Version 2.0.50727.42
Copyright (c) Microsoft Corporation. All rights reserved.</p>
<p>Unknown option: Version=1.0.61025.0
what am I doing wrong.</p>
<p>Edit ~ MY SOLUTION</p>
<blockquote>
<p>I went to "Add Remove Programs" and un-installed the Ajax Web Extensions 2.0 version 1.0.61025.0 </p>
</blockquote>
| [
{
"answer_id": 8276727,
"author": "Tom",
"author_id": 1066632,
"author_profile": "https://Stackoverflow.com/users/1066632",
"pm_score": 1,
"selected": false,
"text": " <!-- <add assembly=\"System.Web.Extensions.Design, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364... | 2008/11/16 | [
"https://Stackoverflow.com/questions/294485",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23667/"
] |
294,495 | <p>I'm trying to make semantic urls for search pages, but if someone use a search finished in dot, the .net engine return a 404. </p>
<p>The request don't even get to the routing engine, so i think its something related to security or something like that. </p>
<p>For example, the stackoverflow routes also don't work in these case:
<a href="https://stackoverflow.com/questions/tagged/etc."><a href="https://stackoverflow.com/questions/tagged/etc">https://stackoverflow.com/questions/tagged/etc</a>.</a></p>
| [
{
"answer_id": 2541677,
"author": "Aaron Maenpaa",
"author_id": 2603,
"author_profile": "https://Stackoverflow.com/users/2603",
"pm_score": 1,
"selected": false,
"text": "^(.*[^.])(\\.+)$"
},
{
"answer_id": 3542522,
"author": "bkaid",
"author_id": 265570,
"author_prof... | 2008/11/16 | [
"https://Stackoverflow.com/questions/294495",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27369/"
] |
294,502 | <p>I'm trying to convert Matt Berseth's '<a href="http://mattberseth.com/blog/2007/10/yui_style_yesno_confirm_dialog.html" rel="nofollow noreferrer">YUI Style Yes/No Confirm Dialog</a>' so I can use it with the jQuery blockUI plugin.</p>
<p>I have to admit I'm no CSS guru but I thought this would pretty easy even for me....except 10hrs later I'm at a loss as to why I can't get the blasted thing to work. </p>
<p>The problem is that I can't seem to get the 'confirmDialogue' DIV to centre on the page without some artifacts showing above it. Alternatively if I reset blockUI's CSS settings by doing....:</p>
<pre><code>$.blockUI.defaults.css = {};
</code></pre>
<p>.....I find that the DIV aligns left.</p>
<p>I've tried all sorts of stuff but CSS isn't my strong point being a server side app kinda guy :(</p>
<p>So if anyone out there who's a jQuery/blockUI/CSS wizard reading this...please can you have a go and let me know what I'm getting wrong?</p>
<p>Basically I followed the design template on Matt's blog and the HTML looks like the stuff below (the CSS is unchanged from Matt's sample). You can grab the png 'sprite' file from the complete sample project download at <a href="http://mattberseth2.com/downloads/yui_simpledialog.zip" rel="nofollow noreferrer">http://mattberseth2.com/downloads/yui_simpledialog.zip</a> - it's a .net project but I'm just trying to get this to work in a simple html file, so no .NET knowledge required.</p>
<p>Anyway any advice and guidance would be really really really useful. I'll even incentivise things buy promising to buy you lashings of beer if we ever meet :)</p>
<pre><code><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title></title>
<script type="text/javascript" src="script/jquery-1.2.6.js"></script>
<script type="text/javascript" src="script/jquery.blockUI.js"></script>
<style>
.modalpopup
{
font-family: arial,helvetica,clean,sans-serif;
font-size: small;
padding: 2px 3px;
display: block;
position: absolute;
}
.container
{
width: 300px;
border: solid 1px #808080;
border-width: 1px 0px;
}
.header
{
background: url(img/sprite.png) repeat-x 0px -200px;
color: #000;
border-color: #808080 #808080 #ccc;
border-style: solid;
border-width: 0px 1px 1px;
padding: 3px 10px;
}
.header .msg
{
font-weight: bold;
}
.body
{
background-color: #f2f2f2;
border-color: #808080;
border-style: solid;
border-width: 0px 1px;
padding-top: 10px;
padding-left: 10px;
padding-bottom: 30px;
}
.body .msg
{
background: url(img/sprite.png) no-repeat 0px -1150px;
float: left;
padding-left: 22px;
}
.footer
{
background-color: #f2f2f2;
border-color: #808080;
border-style: none solid;
border-width: 0px 1px;
text-align:right;
padding-bottom: 8px;
padding-right: 8px;
}
.close
{
right: 7px;
background: url(img/sprite.png) no-repeat 0px -300px;
width: 25px;
cursor: pointer;
position: absolute;
top: 7px;
height: 15px;
}
.modalBackground
{
background-color:Gray;
filter:alpha(opacity=50);
opacity:0.5;
}
</style>
</head>
<body>
<input id="triggerDialogue" name="triggerDialogue" type="button" value="Go" />
<div id="confirmDialogue"
class="modalpopup" style="display:none; text-align: center">
<div class="container">
<div class="header">
<span class="msg">Are you sure?</span>
<a onclick="return false;" class="close"
href="javascript: return false;"></a>
</div>
<div class="body">
<span class="msg">Do you want to continue?</span>
</div>
<div class="footer">
<input type="button" id="Button1" value="Yes" style="width:40px" />
<input type="button" id="Button2" value="No" style="width:40px" />
</div>
</div>
</div>
<script type="text/javascript">
$(document).ready(function() {
$('#triggerDialogue').click(function() {
$.blockUI({ message: $('#confirmDialogue') });
});
});
</script>
</body>
</html>
</code></pre>
<p>@Owen - many thanks for that. I had to make a wee change in the .modalPopup CSS class in Matt's stylesheet to:</p>
<pre><code>position: fixed;
</code></pre>
<p>....and it works. Much appreciated. I really gotta sit down with my <a href="http://oreilly.com/catalog/9780596527334/" rel="nofollow noreferrer">O'Reilly CSS book</a> which I never get a chance to read some night....:)</p>
| [
{
"answer_id": 294534,
"author": "Owen",
"author_id": 4853,
"author_profile": "https://Stackoverflow.com/users/4853",
"pm_score": 4,
"selected": true,
"text": "#confirmDialogue"
},
{
"answer_id": 5579772,
"author": "ben",
"author_id": 170768,
"author_profile": "https:... | 2008/11/16 | [
"https://Stackoverflow.com/questions/294502",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/419/"
] |
294,504 | <p>I am searching for an open-source implementation of an <a href="http://elinux.org/UPnP" rel="nofollow noreferrer">UPnP</a> client in Python, and more specifically of its <a href="http://en.wikipedia.org/wiki/Internet_Gateway_Device_Protocol" rel="nofollow noreferrer">Internet Gateway Device</a> (IGD) part.</p>
<p>For now, I have only been able to find UPnP Media Server implementations, in projects such as <a href="http://pymediaserver.sourceforge.net/" rel="nofollow noreferrer">PyMediaServer</a>, <a href="http://resnet.uoregon.edu/~gurney_j/jmpc/pymeds.html" rel="nofollow noreferrer">PyMedS</a>, <a href="http://brisa.garage.maemo.org/" rel="nofollow noreferrer">BRisa</a> or <a href="https://coherence.beebits.net/" rel="nofollow noreferrer">Coherence</a>.</p>
<p>I am sure I could use those code bases as a start, but the Media Server part will introduce unneeded complexity.</p>
<p>So can you recommend a client UPnP (and hopefully IGD) Python library? An alternative would be to dispatch calls to a C library such as <a href="http://miniupnp.free.fr/" rel="nofollow noreferrer">MiniUPnP</a>, but I would much prefer a pure Python implementation.</p>
<p>Update: an interesting, kind of related discussion of SSDP and UPnP is available on <a href="https://stackoverflow.com/questions/22321/remoting-server-auto-discovery-broadcast-or-not">StackOverflow</a>.</p>
| [
{
"answer_id": 298052,
"author": "oparisy",
"author_id": 38096,
"author_profile": "https://Stackoverflow.com/users/38096",
"pm_score": 4,
"selected": true,
"text": "testupnpigd.py"
}
] | 2008/11/16 | [
"https://Stackoverflow.com/questions/294504",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38096/"
] |
294,517 | <p>I'm writing a script that pulls XML data from wowarmory.com, using PHP 5 and cURL:</p>
<pre><code>$url = "http://www.wowarmory.com";
$userAgent = 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12';
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
curl_setopt($ch, CURLOPT_URL,$url);
$str = "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n";
$str .= "Accept-Language: en-us,en;q=0.5\r\n";
$str .= "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n";
$str .= "Keep-Alive: 300\r\n";
$str .= "Connection: keep-alive\r\n";
curl_setopt($ch, CURLOPT_HTTPHEADER, array($str));
curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_TIMEOUT, 3000);
$xml = curl_exec($ch);
</code></pre>
<p>When I run this from my hosted web server, I get the XML response as expected. But when running from my localhost web server, I get nothing.</p>
<p>I can get any other website via cURL from localhost ( yahoo.com, even worldofwarcraft.com ), but not wowarmory.com. So I know cURL is functioning properly.</p>
<p>I'm using the following versions of PHP and cURL:</p>
<p>Hosted Server:</p>
<ul>
<li>php 5.2.6</li>
<li>cURL libcurl/7.16.1 OpenSSL/0.9.7e zlib/1.2.3 </li>
</ul>
<p>Localhost:</p>
<ul>
<li>php 5.2.6</li>
<li>cURL libcurl/7.16.0 OpenSSL/0.9.8i zlib/1.2.3 </li>
</ul>
<p>Any ideas?</p>
<p>EDIT: Localhost is running Windows XP SP3. I can access wowarmory.com through a web browser. Tracert starts timing out at hop 13 ( from my location, obviously ):</p>
<pre><code>13 458 ms 529 ms 549 ms 0.so-6-0-0.BR1.LAX15.ALTER.NET [152.63.116.21]
14 476 ms 510 ms 488 ms 192.205.34.29
15 257 ms 279 ms 261 ms cr1.la2ca.ip.att.net [12.122.128.14]
16 242 ms 259 ms 249 ms gar5.la2ca.ip.att.net [12.122.128.25]
17 252 ms * 1691 ms 12.122.255.74
18 * 2361 ms 634 ms mdf001c7613r0003-gig-10-1.lax1.attens.net [12.129.193.242]
19 * * * Request timed out.
</code></pre>
<p>I'm not familiar with tcptraceroute, unfortunately. </p>
<p>The windows binary version of curl doesn't return anything for <a href="http://www.wowarmory.com/" rel="nofollow noreferrer">http://www.wowarmory.com/</a> but does for <a href="http://www.yahoo.com/" rel="nofollow noreferrer">http://www.yahoo.com/</a></p>
<p>I don't have wget available.</p>
<p>EDIT 2: I can access my localhosted website just fine. It's just the response from curl I don't receive. I'm running a pretty much default XAMPP install ( apache 2 on windows xp ). All of this works fine. </p>
| [
{
"answer_id": 294555,
"author": "CesarB",
"author_id": 28258,
"author_profile": "https://Stackoverflow.com/users/28258",
"pm_score": 2,
"selected": false,
"text": "curl"
}
] | 2008/11/16 | [
"https://Stackoverflow.com/questions/294517",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
294,520 | <p>I'm generating C++ code, and it seems like it's going to get very messy, even my simple generating classes already have tons of special cases. Here is the code as it stands now: <a href="http://github.com/alex/alex-s-language/tree/local%2Fcpp-generation/alexs_lang/cpp" rel="nofollow noreferrer">http://github.com/alex/alex-s-language/tree/local%2Fcpp-generation/alexs_lang/cpp</a> .</p>
| [
{
"answer_id": 294542,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 3,
"selected": false,
"text": "indent"
},
{
"answer_id": 294550,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://... | 2008/11/16 | [
"https://Stackoverflow.com/questions/294520",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37181/"
] |
294,543 | <p>I have a main table that I must get data from. I have a left outer join where the fields will match 40% of the time. And then I have another join where I need to match the data from table A with.</p>
<p>This is the SQL in pseudo code. This query won't work.</p>
<p>-- This is the part I want to do but doesn't work.
AND H.COL3 = A.STATE????</p>
<p>I am working with IBM DB2.</p>
<pre><code>SELECT DISTINCT
APP_NO as app_no,
A.STATE as state
...
... Fields
...
FROM
TABLE_A A
LEFT OUTER JOIN
TABLE_B HIST
ON
HIST.COL1 = A.COL1
, TABLE_C B
LEFT OUTER JOIN
TABLE_D H
ON
H.COL2 = B.COL2
-- This is the part I want to do but doesn't work.
AND
H.COL3 = A.STATE????
WHERE
A.BRANCH = 'Data'
</code></pre>
| [
{
"answer_id": 294588,
"author": "Mark",
"author_id": 26310,
"author_profile": "https://Stackoverflow.com/users/26310",
"pm_score": 5,
"selected": true,
"text": "FROM \n TABLE_A A LEFT OUTER JOIN TABLE_B HIST ON\n HIST.COL1 = A.COL1\n LEFT OUTER JOIN TABLE_D H ON \n H.COL3 = ... | 2008/11/16 | [
"https://Stackoverflow.com/questions/294543",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10522/"
] |
294,545 | <p>I have a winforms projects and we use the command pattern. We are trying to clean up our directory structure and make it consistent.</p>
<p>We are trying to decide if we should have a root commands folder or not. What do you think is better for a directory structure?</p>
<p>Project<br>
--Commands<br>
----AddCommand<br>
----SubtractCommand<br>
----InsertCommand<br>
----DeleteCommand </p>
<p>or</p>
<p>Project<br>
--Calculation<br>
----AddCommand<br>
----SubtractCommand<br>
--Database<br>
----InsertCommand<br>
----DeleteCommand </p>
| [
{
"answer_id": 294561,
"author": "Nathan W",
"author_id": 6335,
"author_profile": "https://Stackoverflow.com/users/6335",
"pm_score": 0,
"selected": false,
"text": "Project\n-Commands\n--Calculation\n----AddCommand\n----SubtractCommand\n--Database\n----InsertCommand\n----DeleteCommand\n"... | 2008/11/16 | [
"https://Stackoverflow.com/questions/294545",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4653/"
] |
294,553 | <p>I was just wondering if there is any difference between the two different new object initializers or is it just syntactic sugar. </p>
<p>So is:</p>
<pre><code>Dim _StreamReader as New Streamreader(mystream)
</code></pre>
<p>and different to:</p>
<pre><code>Dim _StreamReader as Streamreader = new streamreader(mystream)
</code></pre>
<p>Is there any difference under the hood? or are they both the same? Which one do you prefer to use?</p>
| [
{
"answer_id": 294568,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 5,
"selected": true,
"text": "As New"
}
] | 2008/11/16 | [
"https://Stackoverflow.com/questions/294553",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6335/"
] |
294,558 | <p>I have an enumeration: <code>ENUM( 'alpha', 'beta', 'gamma', 'delta', 'omega' )</code></p>
<p>If I sort my table by this column I get them in the correct order defined above.</p>
<p>However, I can't find a way to select a subset of these, e.g. everything before delta. Using <code>WHERE status < 'delta'</code> only returns alpha and beta, not gamma. It seems MySQL uses a string comparison, not enum index comparison.</p>
<p>I could use the index numbers - i.e. <code>WHERE status < 4</code> - but it's a bit of a code smell (magic numbers) and may break if I insert new values into the enumeration.</p>
| [
{
"answer_id": 294603,
"author": "Kendrick Erickson",
"author_id": 37882,
"author_profile": "https://Stackoverflow.com/users/37882",
"pm_score": 2,
"selected": false,
"text": "FIELD(column, \"string1\", \"string2\", ...)"
},
{
"answer_id": 296439,
"author": "Bill Karwin",
... | 2008/11/16 | [
"https://Stackoverflow.com/questions/294558",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37947/"
] |
294,582 | <p>I'm currently considering the use of Reflection classes (ReflectionClass and ReflectionMethod mainly) in my own MVC web framework, because I need to automatically instanciate controller classes and invoke their methods without any required configuration ("convention over configuration" approach).</p>
<p>I'm concerned about performance, even though I think that database requests are likely to be bigger bottlenecks than the actual PHP code.</p>
<p>So, I'm wondering if anyone has any good or bad experience with PHP 5 Reflection from a performance point of view.</p>
<p>Besides, I'd be curious to know if any one of the popular PHP frameworks (CI, Cake, Symfony, etc.) actually use Reflection.</p>
| [
{
"answer_id": 409299,
"author": "codeassembly",
"author_id": 47537,
"author_profile": "https://Stackoverflow.com/users/47537",
"pm_score": 2,
"selected": false,
"text": "<?php\nrequire_once('sanitize.inc');\n\n/**\n * MVC Controller\n *\n * This Class implements MVC Controller part\n *... | 2008/11/16 | [
"https://Stackoverflow.com/questions/294582",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38072/"
] |
294,585 | <p>Sorry for the newb question. I'm still learning programming. So I'm using C++, and I need to do something like this:</p>
<pre><code>int n;
do {
n = get_data();
if(n != -1)
send(n);
} while(n != -1);
</code></pre>
<p>This is just a sketch. Anyway it doesn't feel real elegant. I have to have my test twice. I could just test once and set a flag, but that doesn't feel real elegant either since I have to check the flag twice. It just seems like there should be a way to do this more easily, since it's so easy what I want to do.</p>
| [
{
"answer_id": 294589,
"author": "Charlie",
"author_id": 18529,
"author_profile": "https://Stackoverflow.com/users/18529",
"pm_score": 4,
"selected": false,
"text": "int n;\nwhile(1) {\n n = get_data();\n if(n == -1)\n break;\n send(n);\n}\n"
},
{
"answer_id": 294... | 2008/11/16 | [
"https://Stackoverflow.com/questions/294585",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
294,607 | <p>I'm using django and when users go to www.website.com/ I want to point them to the index view.</p>
<p>Right now I'm doing this:</p>
<pre><code>(r'^$', 'ideas.idea.views.index'),
</code></pre>
<p>However, it's not working. I'm assuming my regular expression is wrong. Can anyone help me out? I've looked at python regular expressions but they didn't help me. </p>
| [
{
"answer_id": 294612,
"author": "Harley Holcombe",
"author_id": 1057,
"author_profile": "https://Stackoverflow.com/users/1057",
"pm_score": 3,
"selected": true,
"text": "urls.py"
},
{
"answer_id": 294656,
"author": "Community",
"author_id": -1,
"author_profile": "htt... | 2008/11/17 | [
"https://Stackoverflow.com/questions/294607",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23695/"
] |
294,609 | <p>I'm interested in measuring and improving (where necessary) my team's SQL-92 skills. Can anyone recommend an appropriate on-line course and/or examination?</p>
<p>Ideally it would be vendor-neutral, but it could also be MSSQL/Oracle specific, as long as the proprietary bits were flagged as such.</p>
| [
{
"answer_id": 294612,
"author": "Harley Holcombe",
"author_id": 1057,
"author_profile": "https://Stackoverflow.com/users/1057",
"pm_score": 3,
"selected": true,
"text": "urls.py"
},
{
"answer_id": 294656,
"author": "Community",
"author_id": -1,
"author_profile": "htt... | 2008/11/17 | [
"https://Stackoverflow.com/questions/294609",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10433/"
] |
294,611 | <p>What is the best way to block certain input keys from being used in a TextBox with out blocking special keystrokes such as <kbd>Ctrl</kbd>-<kbd>V</kbd>/<kbd>Ctrl</kbd>-<kbd>C</kbd>?</p>
<p>For example, only allowing the user to enter a subset of characters or numerics such as A or B or C and nothing else.</p>
| [
{
"answer_id": 294624,
"author": "Nathan Koop",
"author_id": 18821,
"author_profile": "https://Stackoverflow.com/users/18821",
"pm_score": 0,
"selected": false,
"text": " private void txtInput_TextChanged(object sender, EventArgs e)\n {\n if (txtInput.Text.ToUpper() == \"A\"... | 2008/11/17 | [
"https://Stackoverflow.com/questions/294611",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4490/"
] |
294,616 | <p>I am trying to resolve Euler Problem 18 -> <a href="http://projecteuler.net/index.php?section=problems&id=18" rel="nofollow noreferrer">http://projecteuler.net/index.php?section=problems&id=18</a></p>
<p>I am trying to do this with c++ (I am relearning it and euler problems make for good learning/searching material)</p>
<pre><code>#include <iostream>
using namespace std;
long long unsigned countNums(short,short,short array[][15],short,bool,bool);
int main(int argc,char **argv) {
long long unsigned max = 0;
long long unsigned sum;
short piramide[][15] = {{75,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{95,64,0,0,0,0,0,0,0,0,0,0,0,0,0},
{17,47,82,0,0,0,0,0,0,0,0,0,0,0,0},
{18,35,87,10,0,0,0,0,0,0,0,0,0,0,0},
{20,4,82,47,65,0,0,0,0,0,0,0,0,0,0},
{19,1,23,75,3,34,0,0,0,0,0,0,0,0,0},
{88,2,77,73,7,63,67,0,0,0,0,0,0,0,0},
{99,65,4 ,28,6,16,70,92,0,0,0,0,0,0,0},
{41,41,26,56,83,40,80,70,33,0,0,0,0,0,0},
{41,48,72,33,47,32,37,16,94,29,0,0,0,0,0},
{53,71,44,65,25,43,91,52,97,51,14,0,0,0,0},
{70,11,33,28,77,73,17,78,39,68,17,57,0,0,0},
{91,71,52,38,17,14,91,43,58,50,27,29,48,0,0},
{63,66,4,68,89,53,67,30,73,16,69,87,40,31,0},
{4,62,98,27,23,9,70,98,73,93,38,53,60,4,23}};
for (short i = 0;i<15;i++) {
for (short m=0;m<15;m++) {
if (piramide[i][m] == 0)
break;
sum = countNums(i,m,piramide,15,true,true);
if (sum > max)
max = sum;
sum = countNums(i,m,piramide,15,true,false);
if (sum > max)
max = sum;
sum = countNums(i,m,piramide,15,false,true);
if (sum > max)
max = sum;
sum = countNums(i,m,piramide,15,false,false);
if (sum > max)
max = sum;
}
}
cout << max;
return 0;
}
long long unsigned countNums(short start_x,short start_y,short array[][15],short size, bool goright,bool goright2) {
long long unsigned currentSum;
currentSum = array[start_x][start_y];
if (goright) { //go right
if ((start_x + 1) < size)
start_x++;
if ((start_y + 1) < size)
start_y++;
}
else //go down
if ((start_x + 1) < size)
start_x++;
if (goright2) { //still going right
for (short i = start_x, m = start_y;i< size && m < size;i++,m++) {
currentSum += array[i][m];
}
}
else { //still going down
for (short i = start_x;i<size;i++) {
currentSum += array[i][start_y];
}
}
return currentSum;
}
</code></pre>
<p>The countNums function is used to go either down or diagonally.
I have tested this function like so:</p>
<pre><code>short a = 0;
short b = 0;
cout << countNums(a,b,piramide,15,true,true) << endl;
cout << countNums(a,b,piramide,15,true,false) << endl;
cout << countNums(a,b,piramide,15,false,true) << endl;
cout << countNums(a,b,piramide,15,false,false) << endl;
return 0;
</code></pre>
<p>And it does work (I also changed the function a little so it would print every number it was going through) </p>
<p>But I still don't get the right result. This goes down and to the right and still goes right (adjacent numbers to the right), goes down and keeps going down (adjacent number to the left).
What am I doing wrong here, anyone?</p>
<hr>
<p>Alastair: It's simple</p>
<p>long long unsigned countNums(short start_x,short start_y,short array[][15],short size, bool goright,bool goright2);</p>
<p>start_x and start_y are the coords of the array
array is the reference to the array
size is just the size of the array (it's always 15)
goright is to know if I am going to go down and right or just down
goright2 is to know if I am going to continue to go down or going left</p>
| [
{
"answer_id": 294641,
"author": "Alastair",
"author_id": 31038,
"author_profile": "https://Stackoverflow.com/users/31038",
"pm_score": 3,
"selected": true,
"text": "countNums"
},
{
"answer_id": 294687,
"author": "baash05",
"author_id": 31325,
"author_profile": "https... | 2008/11/17 | [
"https://Stackoverflow.com/questions/294616",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8715/"
] |
294,622 | <p>I'm getting an exception which says "Access Denied" when the users permissions are sufficient, how do I catch an exception and check for "Access Denied" so that I can show the user a friendlier "Sorry Access Denied" message?</p>
<p>Thanks
Beginner :-)</p>
| [
{
"answer_id": 294630,
"author": "Ed S.",
"author_id": 1053,
"author_profile": "https://Stackoverflow.com/users/1053",
"pm_score": 3,
"selected": false,
"text": "try\n{\n //error occurs\n}\ncatch (Exception ex)\n{\n MessageBox.show(ex.Message);\n}\n"
},
{
"answer_id": 29463... | 2008/11/17 | [
"https://Stackoverflow.com/questions/294622",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
294,659 | <p>I made a couple of changes to my working application and started getting the following error at this line of code.</p>
<pre><code>Dim Deserializer As New Serialization.XmlSerializer(GetType(Groups))
</code></pre>
<p>And here is the error.</p>
<pre><code> BindingFailure was detected
Message: The assembly with display name 'FUSE.XmlSerializers' failed to load in the 'LoadFrom' binding context of the AppDomain with ID 1. The cause of the failure was: System.IO.FileNotFoundException: Could not load file or assembly 'FUSE.XmlSerializers, Version=8.11.16.1, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
File name: 'FUSE.XmlSerializers, Version=8.11.16.1, Culture=neutral, PublicKeyToken=null'
Message: The assembly with display name 'FUSE.XmlSerializers' failed to load in the 'LoadFrom' binding context of the AppDomain with ID 1. The cause of the failure was: System.IO.FileNotFoundException: Could not load file or assembly 'FUSE.XmlSerializers, Version=8.11.16.1, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
File name: 'FUSE.XmlSerializers, Version=8.11.16.1, Culture=neutral, PublicKeyToken=null'
=== Pre-bind state information ===
LOG: User = DOUG-VM\Doug
LOG: DisplayName = FUSE.XmlSerializers, Version=8.11.16.1, Culture=neutral, PublicKeyToken=null, processorArchitecture=MSIL
(Fully-specified)
LOG: Appbase = file:///E:/Laptop/Core Data/Data/Programming/Windows/DotNet/Work Projects/NOP/Official Apps/FUSE WPF/Fuse/bin/Debug/
LOG: Initial PrivatePath = NULL
Calling assembly : System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: E:\Laptop\Core Data\Data\Programming\Windows\DotNet\Work Projects\NOP\Official Apps\FUSE WPF\Fuse\bin\Debug\FUSE.vshost.exe.config
LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///E:/Laptop/Core Data/Data/Programming/Windows/DotNet/Work Projects/NOP/Official Apps/FUSE WPF/Fuse/bin/Debug/FUSE.XmlSerializers.DLL.
LOG: Attempting download of new URL file:///E:/Laptop/Core Data/Data/Programming/Windows/DotNet/Work Projects/NOP/Official Apps/FUSE WPF/Fuse/bin/Debug/FUSE.XmlSerializers/FUSE.XmlSerializers.DLL.
LOG: Attempting download of new URL file:///E:/Laptop/Core Data/Data/Programming/Windows/DotNet/Work Projects/NOP/Official Apps/FUSE WPF/Fuse/bin/Debug/FUSE.XmlSerializers.EXE.
LOG: Attempting download of new URL file:///E:/Laptop/Core Data/Data/Programming/Windows/DotNet/Work Projects/NOP/Official Apps/FUSE WPF/Fuse/bin/Debug/FUSE.XmlSerializers/FUSE.XmlSerializers.EXE.
</code></pre>
<p>What's going on?</p>
| [
{
"answer_id": 295239,
"author": "Kent Boogaart",
"author_id": 5380,
"author_profile": "https://Stackoverflow.com/users/5380",
"pm_score": 0,
"selected": false,
"text": "Groups"
}
] | 2008/11/17 | [
"https://Stackoverflow.com/questions/294659",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6514/"
] |
294,660 | <p>What's a good algorithm to solve this problem?</p>
<p>I have three groups of people - group A, group B, and group C. There are the same number of people in each group. They each have a list of people in the other groups that they're willing to work with. I want to group all these people together in groups of 3 (one from A, one from B, and one from C) such that everyone in a group wants to work with the other people in their group. </p>
<p>How can I find these groups in a fast way? If there's no way to make everyone happy, then the algorithm should first make as many groups have three people who want to work with each other, and then make as many people in the other groups happy.</p>
<p>One final point: people agree on who they want to work with (if person x wants to work with person y, then y also wants to work with x). If you could also give a big-O of the running time of your algorithm, that'd be great!</p>
| [
{
"answer_id": 294970,
"author": "RexE",
"author_id": 38146,
"author_profile": "https://Stackoverflow.com/users/38146",
"pm_score": 3,
"selected": false,
"text": "M1 = |A| x |B|"
},
{
"answer_id": 67391545,
"author": "Eduardo Cuomo",
"author_id": 717267,
"author_profi... | 2008/11/17 | [
"https://Stackoverflow.com/questions/294660",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15055/"
] |
294,661 | <p>I have a MySQL table that will only have one row. What should my statement be for the first time I insert to this row, and for subsequent updates? I tried an insert where the primary key equals 1, but this doesn't account for the first time around when no row exists yet.</p>
| [
{
"answer_id": 294671,
"author": "SoapBox",
"author_id": 36384,
"author_profile": "https://Stackoverflow.com/users/36384",
"pm_score": 4,
"selected": true,
"text": "INSERT INTO table(col1,col2,col3) VALUES(val1,val2,val3) ON DUPLICATE KEY UPDATE col1 = val1, col2 = val2, col3 = val3;\n"
... | 2008/11/17 | [
"https://Stackoverflow.com/questions/294661",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
294,664 | <p>I also want to save the font size in my <code>.emacs</code> file.</p>
| [
{
"answer_id": 294685,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 5,
"selected": false,
"text": "default"
},
{
"answer_id": 294733,
"author": "Chris Conway",
"author_id": 1412,
"author... | 2008/11/17 | [
"https://Stackoverflow.com/questions/294664",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8661/"
] |
294,680 | <p>The application de-serializes a stream into dynamically allocated objects and then keeps base type pointers in a linked list (i.e. abstract factory). It's too slow. Profiling says all the time is spent in <code>operator new</code>.</p>
<p>Notes: The application already uses a custom memory allocator that does pooling. The compiler is VC++ 6.0 and the code uses the old RogueWave collections rather than the STL.</p>
<p>The only idea I have right now is to introduce Object Pooling. I'd maintain large collections of pre-allocated objects for each type and re-use them. But this will be a lot of work in this old code, and I'm not yet sure there's enough re-use that it would even help. I was hoping someone smarter than me has an idea.</p>
| [
{
"answer_id": 294735,
"author": "Steve Jessop",
"author_id": 13005,
"author_profile": "https://Stackoverflow.com/users/13005",
"pm_score": 0,
"selected": false,
"text": "char *alloc(POOL *pool, size_t size) {\n // if size is a parameter, and may be a non-multiple the max alignment \n... | 2008/11/17 | [
"https://Stackoverflow.com/questions/294680",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16161/"
] |
294,688 | <p>I have a specific scenario in mind, but I will ask this generally:</p>
<p><strong>Is there a way to make my mobile phone trigger an action on my computer?</strong> I am thinking that with a smart phone it must be possible to link the phone and the personal computer with bluetooth, and have some sort of small program running on my computer that will listen for incoming phone calls on the phone. When someone calls me, I want my mobile to simply submit the callers phone number to the personal computer, and then the personal computer will do its stuff from there. Then, I want to handle the call on the mobile phone as usual.</p>
<p><strong>Edit</strong>:<br></p>
<p>Updated this question! I am currently using the HTC Hero, and hopefully the Android SDK will make this more easy to accomplish.</p>
<p><strong>My specific scenario was:</strong><br></p>
<p>When my phone (Nokia N82) calls, i want to submit the callers <code>phonenumber</code> to a search <em>applet/application</em>, that will query <em>Microsoft Dynamics CRM</em> and see if a contact person or a company has that <code>phonenumber</code>, and if so, show the corresponding person or companys info on my screen. My preferred development platform is .NET Framework.</p>
| [
{
"answer_id": 565788,
"author": "funkybro",
"author_id": 64505,
"author_profile": "https://Stackoverflow.com/users/64505",
"pm_score": 3,
"selected": false,
"text": "+CLCC: 1,1,4,0,0,\"07xxxxxxxxx\",129\n"
}
] | 2008/11/17 | [
"https://Stackoverflow.com/questions/294688",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29397/"
] |
294,699 | <p>I am using the following servlet-mapping in my <code>web.xml</code> file:</p>
<pre><code><servlet>
<servlet-name>PostController</servlet-name>
<servlet-class>com.webcodei.controller.PostController</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>PostController</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</code></pre>
<p>To do some kind of a search. ex: <pre><code> <a href="http://www.myweb.com/The" rel="nofollow noreferrer">http://www.myweb.com/The</a> search string here </code></pre></p>
<p>But the problem is that CSS, JS and Images are treated like a search request. </p>
<p><b>There are any patterns that strip out *.css, *.js, *.gif and etc, so the requests don't need to pass through my controller?</b></p>
<p>Thank you so much, bye bye!</p>
| [
{
"answer_id": 294708,
"author": "sblundy",
"author_id": 4893,
"author_profile": "https://Stackoverflow.com/users/4893",
"pm_score": 2,
"selected": false,
"text": "/actions/*"
},
{
"answer_id": 294725,
"author": "Peter Bratton",
"author_id": 37856,
"author_profile": "... | 2008/11/17 | [
"https://Stackoverflow.com/questions/294699",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37190/"
] |
294,700 | <p>How does the data go from the MVC to the browser and back again? Does it use Microsoft's own technology like ASMX or WCF or something completely different? </p>
<p>This sounds like MVC is using a ASMX Web Service they are using but I can't seem to find any documentation which gives the real answer. </p>
| [
{
"answer_id": 294792,
"author": "CVertex",
"author_id": 209,
"author_profile": "https://Stackoverflow.com/users/209",
"pm_score": 1,
"selected": false,
"text": "ActionResult MyAction() {\n return Json(new { success=false, for_lunch=\"mmm, chicken\"});\n}\n"
}
] | 2008/11/17 | [
"https://Stackoverflow.com/questions/294700",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10352/"
] |
294,705 | <p>I have two tables: articles and articletags</p>
<pre><code>articles: id, author, date_time, article_text
articletags: id, tag
(article.id == articletags.id in a many-to-many relationship)
</code></pre>
<p>I am after the last time that something was published under each tag. To put it another way, for every tag, look through all the articles it is related to and find the most recent and return that.</p>
<p>eg
articles:</p>
<pre><code>1, me, 12 Nov, Sometext
2, me, 13 Nov, Sometext
3, me, 14 Nov, Sometext
</code></pre>
<p>article tags</p>
<pre><code>1, foo
1, bar
2, foo
3, bar
</code></pre>
<p>I want to get back:</p>
<pre><code>foo, 13 Nov
bar, 14 Nov
</code></pre>
<p>I can get as far as an inner join and then am stumped. I dont think a DISTINCT clause is what I am after and I am not familiar enough for subqueries to know if that would help.</p>
<pre><code>SELECT date_time, tag
FROM articles, articletags
WHERE articles.id = articletags.id
</code></pre>
<p>Is this even possible?</p>
| [
{
"answer_id": 294713,
"author": "SoapBox",
"author_id": 36384,
"author_profile": "https://Stackoverflow.com/users/36384",
"pm_score": 0,
"selected": false,
"text": "SELECT date_time, tag \nFROM articles, articletags\nWHERE articles.id = articletags.id\nORDER BY date_time DESC\nGROUP BY ... | 2008/11/17 | [
"https://Stackoverflow.com/questions/294705",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3431280/"
] |
294,712 | <p>I have a few model classes with basic one-to-many relationships. For example, a book has many recipes, and each recipe has many ingredients:</p>
<pre><code>class Book(models.Model):
name = models.CharField(max_length=64)
class Recipe(models.Model):
book = models.ForeignKey(Book)
name = models.CharField(max_length=64)
class Ingredient(models.Model):
text = models.CharField(max_length=128)
recipe = models.ForeignKey(Recipe)
</code></pre>
<p>I'd like a flat list of all ingredients in all recipes from a particular book. What's the best way to express this in Python?</p>
<p>If I was using LINQ, I might write something like this:</p>
<pre><code>var allIngredients = from recipe in book.Recipes
from ingredient in recipe.Ingredients
select ingredient;
</code></pre>
| [
{
"answer_id": 294717,
"author": "Harley Holcombe",
"author_id": 1057,
"author_profile": "https://Stackoverflow.com/users/1057",
"pm_score": 1,
"selected": false,
"text": "mybook = Book.objects.get(name=\"Jason's Cookbook\")\nfor recipe in mybook.recipe_set.all():\n print recipe.name\... | 2008/11/17 | [
"https://Stackoverflow.com/questions/294712",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5142/"
] |
294,738 | <p>When I debug my ASP.NET web site code using the Microsoft debug symbol's for .NET .. I keep getting this silly 'result' for most of the variables when I'm debugging .NET framework code (which of course is provided by the Microsoft Symbol Server, which I told VS2008 to grab the info, from)</p>
<pre><code>Cannot obtain value of local or argument 'cookie' as
it is not available at this instruction pointer, possibly because
it has been optimized away.
</code></pre>
<p>It's like the code I'm using is using optimized, compiled code. If that's the case, can I tell it NOT to optimize? I'm in DEBUG configuration. It's very frustrating because I cannot debug .. cause I can't see/retrieve the values of local variables as I step through the code.</p>
<p>Any clues/thoughts?</p>
| [
{
"answer_id": 1518810,
"author": "Cameron MacFarland",
"author_id": 3820,
"author_profile": "https://Stackoverflow.com/users/3820",
"pm_score": 5,
"selected": true,
"text": "set COMPLUS_ZapDisable=1\ncd /d \"%ProgramFiles%\\Microsoft Visual Studio 9.0\\Common7\\ide\\\"\nstart devenv.exe... | 2008/11/17 | [
"https://Stackoverflow.com/questions/294738",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30674/"
] |
294,741 | <p>I have read some PL SQL programming books, and they recommend me to group procedures, functions, cursors, and so on in a package. Packages provide modularity and information hiding, which is the OO design. However, I'm just familiar with stand alone procedures. Would anyone kindly provide some examples in code and how to call package from the client? I'm currently using ODP.NET as a data access in client application. Thank you.</p>
| [
{
"answer_id": 295974,
"author": "Jim Hudson",
"author_id": 8051,
"author_profile": "https://Stackoverflow.com/users/8051",
"pm_score": 1,
"selected": false,
"text": "create or replace procedure foo (i_something in varchar2) as\nbegin\n -- do some stuff;\nend foo;\n"
},
{
"answ... | 2008/11/17 | [
"https://Stackoverflow.com/questions/294741",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1602746/"
] |
294,748 | <p>I've got a TDbGrid in my project, and I'm trying to have an event go off every time I change the selected row. Any change in row already updates all the data-aware controls linked to the same DataSource, but there are other changes to be made too, that I need an event handler for.</p>
<p>I thought OnColEnter would work. According to the helpfile, it fires when:</p>
<ul>
<li><p>The user navigates to the cell using
the keyboard. For example, when the
user uses the Tab key, or the Home
key. </p></li>
<li><p>The user clicks the mouse button
down in the cell. </p></li>
<li><p>The SelectedField or SelectedIndex
property is set.</p></li>
</ul>
<p>Unfortunately, it does <em>not</em> fire when the user navigates using the keyboard while the dgRowSelect option is enabled, and there's no OnRowEnter. And the OnKeyDown event fires before the selection change has been made. I'm trying to simulate a data-aware version of a TListBox here, and I need something to replace the List Box's OnClick handler, which despite the name actually goes off anytime the selection is changed, whether through the mouse or the keyboard. Is there any way I can do that with a TDbGrid? If not, there's got to be some other grid control that will do it. Does anyone know what it is? (Preferably open source?)</p>
| [
{
"answer_id": 295727,
"author": "skamradt",
"author_id": 9217,
"author_profile": "https://Stackoverflow.com/users/9217",
"pm_score": 2,
"selected": false,
"text": "procedure TForm1.DataSource1DataChange(Sender: TObject; Field: TField);\nbegin\n if fbLoading then exit;\n // rest of you... | 2008/11/17 | [
"https://Stackoverflow.com/questions/294748",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32914/"
] |
294,766 | <p>I've explored python for several years, but now I'm slowly learning how to work with c. Using the <a href="http://www.python.org/doc/2.5.2/ext/intro.html" rel="nofollow noreferrer">python documentation</a>, I learned how to extend my python programs with some c, since this seemed like the logical way to start playing with it. My question now is how to distribute a program like this.</p>
<p>I suppose the heart of my question is how to compile things. I can do this easily on my own machine (gentoo), but a binary distribution like Ubuntu probably doesn't have a compiler available by default. Plus, I have a few friends who are mac users. My instinct says that I can't just compile with my own machine and then run it on another. Anyone know what I can do, or some online resources for learning things like this?</p>
| [
{
"answer_id": 294785,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 3,
"selected": false,
"text": "setup.py"
}
] | 2008/11/17 | [
"https://Stackoverflow.com/questions/294766",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36312/"
] |
294,771 | <p>Please excuse my lack of knowledge... I know there is a lot of documentation on the internet related to this but I still don't understand.</p>
<p>My situation is this:</p>
<p>I have an XML file that I need import and eventually replace daily with.</p>
<pre><code> <item>
<model>AA311-Pink</model>
<title>1122</title>
<price>19.43</price>
<category>cat</category>
<loc>/AA311.html</loc>
<image>/aa311.jpg</image>
<description>Item Info</description>
<weight>0.45</weight>
<option_type>Color-Color</option_type>
<option_value>Pink-Pink</option_value>
<suggested_retail>51.50</suggested_retail>
<special_handling/>
<manufacturer>Tantus</manufacturer>
<manufacturer_code>VB5074 and VB5067</manufacturer_code>
<packaging>Retail Packaging</packaging>
<in_stock>Yes</in_stock>
<lastupdated>2008-11-05 16:35:56</lastupdated>
</code></pre>
<p>I need to change a handful of the column names automatically and import them into multiple tables in my database.</p>
<p>For instance,</p>
<pre><code> <item>
<products_model>AA315</products_model>
<products_name>name</products_name>
<price>19.43</price>
<category>cat</category>
<loc>/AA315.html</loc>
<products_image>aa315.jpg</products_image>
<products_description>info</products_description>
<products_weight>0.44</products_weight>
<option_type/>
<option_value/>
<products_price>51.50</products_price>
<special_handling/>
<manufactures_name>Tantus</manufactures_name>
<manufacturer_code>VA5104</manufacturer_code>
<packaging>Retail Packaging</packaging>
<products_status>Yes</products_status>
<products_last_modified>2008-11-05 16:35:27</products_last_modified>
</code></pre>
<p>And then import into MySQL DB</p>
<p>Columns:
products_weight, products_model, products_image, products_price, products_last_modified </p>
<p>import into table 'products'</p>
<p>Columns:
products_description, products_name</p>
<p>import into table 'product_description</p>
<p>Also what about the product_id that is automatically created? I can send SQL output of table structure.</p>
<p>I really apprecaite the help... I am willing to pay some if they are willing to create a fully automated procedure to import this file into my database; I am using Zen Cart to host my shopping cart.</p>
| [
{
"answer_id": 8916800,
"author": "Mário Rodrigues",
"author_id": 581256,
"author_profile": "https://Stackoverflow.com/users/581256",
"pm_score": 1,
"selected": false,
"text": "mysql> LOAD XML LOCAL INFILE 'items.xml'\n -> INTO TABLE item\n -> ROWS IDENTIFIED BY '<item>';\n"
... | 2008/11/17 | [
"https://Stackoverflow.com/questions/294771",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
294,773 | <p>First of all, I'm kinda new to the barcode formats and what I do know, I've learned from Wikipedia.</p>
<p>We have some barcodes generated by an existing app that uses the Barcode.4NET library. The barcode is in Code 128A format. The code to generate them is pretty simple, looking something like this:</p>
<pre><code>// Create the barcode
Code128ABarcode c128A = new Code128ABarcode("045746201627080857");
</code></pre>
<p>No other parameters are set for it - after setting the data, we just get a GIF version of the barcode back from the library.</p>
<p>I'm working on a new app that is using iTextSharp for PDF generation and I figured that instead of using two libraries, I would use iTextSharp's barcode generation library since it supports Code128 barcodes. It has a few different variations of Code 128, but none of them are "Code 128A".</p>
<p>Here is what the code looks like for it:</p>
<pre><code>Barcode128 code128 = new Barcode128();
code128.CodeType = Barcode.CODE128;
code128.ChecksumText = true;
code128.GenerateChecksum = true;
code128.StartStopText = true;
code128.Code = "045746201627080857";
</code></pre>
<p>The image below shows the best I've accomplished so far.</p>
<p><img src="https://farm4.static.flickr.com/3187/3037044282_c6396bc09a.jpg" alt="alt text"></p>
<p>The image on top is generated by iTextSharp and the one on the bottom is generated by Barcode4Net. Obviously, they aren't the same (and not just in the size and the font - the barcoded data is pretty different).</p>
<p>Is anyone out there familiar enough with iTextSharp's (or iText itself) barcode components or with Code 128A barcodes to tell me how to make the iTextSharp one look exactly like the Barcode.4NET one?</p>
| [
{
"answer_id": 294790,
"author": "balexandre",
"author_id": 28004,
"author_profile": "https://Stackoverflow.com/users/28004",
"pm_score": 2,
"selected": false,
"text": "*045746201627080857*\n"
}
] | 2008/11/17 | [
"https://Stackoverflow.com/questions/294773",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14894/"
] |
294,775 | <p>When working with window handles, is it <em>good</em> enough to use the plain <strong>IntPtr</strong> or should I subclass <strong>SafeHandle</strong>?</p>
<p>Are there any significant pros/cons?</p>
<p>Thanks.</p>
| [
{
"answer_id": 294866,
"author": "P Daddy",
"author_id": 36388,
"author_profile": "https://Stackoverflow.com/users/36388",
"pm_score": 2,
"selected": true,
"text": "SafeHandle"
}
] | 2008/11/17 | [
"https://Stackoverflow.com/questions/294775",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15409/"
] |
294,779 | <p>I have a big list of global variables that each have their own setup function. My goal is to go through this list, call each item's setup function, and generate some stats on the data loaded in the matching variable. However, what I'm trying now isn't working and I need help to make my program call the setup functions. </p>
<p>The global variables and their setup functions are case-sensitive since this came from XML and is necessary for uniqueness.</p>
<p>The data looks something like this:</p>
<pre><code>'(ABCD ABC\d AB\c\d ...)
</code></pre>
<p>and the setup functions look like this:</p>
<pre><code>(defun setup_ABCD...
(defun setup_ABC\d...
</code></pre>
<p>I've tried concatenating them together and turning the resulting string into a function,
but this interferes with the namespace of the previously loaded setup function. Here's how I tried to implement that:</p>
<pre><code>(make-symbol (concatenate 'string "setup_" (symbol-name(first '(abc\d)))))
</code></pre>
<p>But using <code>funcall</code> on this doesn't work. How can I get a callable function from this?</p>
| [
{
"answer_id": 6791761,
"author": "Intrinsic",
"author_id": 260256,
"author_profile": "https://Stackoverflow.com/users/260256",
"pm_score": 0,
"selected": false,
"text": "(funcall (read-from-string (concatenate 'string \"setup_\" (symbol-name(first '(abc\\d)))))) \n"
}
] | 2008/11/17 | [
"https://Stackoverflow.com/questions/294779",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38132/"
] |
294,795 | <p>Wwhen I click the button on the popup to insert data to database, it does nothing, WHYYYYY?</p>
<pre><code><cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server" BehaviorID="popup" TargetControlID="cmdTrigger"
PopupControlID="pnlPopup" BackgroundCssClass="modalBackground"
OkControlID="btnOk" >
</cc1:ModalPopupExtender>
<asp:Panel ID="pnlPopup" runat="server" CssClass="modalpopup" Style="display: none">
<div class="container">
<div class="header">
<asp:Label ID="Label1" runat="server" CssClass="msg" Text="Add a new Entry" />
<asp:LinkButton ID="LinkButton1" runat="server" CssClass="close" OnClientClick="$find('popup').hide(); return false;" />
</div>
<div class="body">
<asp:Label ID="Label2" runat="server" CssClass="msg" Text="Name" />
<asp:TextBox ID="txtName" runat="server" Width="346px"></asp:TextBox>
</div>
<div class="footer">
<asp:Button ID="btnOk" runat="server" Text="Save" Width="48px" />
<asp:Button ID="btnCancel" runat="server" Text="Cancel" Width="50px" OnClientClick="$find('popup').hide(); return false;" />
</div>
</div>
</asp:Panel>
</code></pre>
<p>The code on the btnOK is</p>
<p>a simple textbox1.text = txtName</p>
<p>I even tries setting a breakpoint, the button click event is not being executed. Any ideas?</p>
<p>Edit ~ Solution</p>
<blockquote>
<p>Follow <a href="http://forums.asp.net/t/1070213.aspx" rel="nofollow noreferrer">http://forums.asp.net/t/1070213.aspx</a></p>
</blockquote>
| [
{
"answer_id": 877703,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "CausesValidation=\"false\""
}
] | 2008/11/17 | [
"https://Stackoverflow.com/questions/294795",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23667/"
] |
294,802 | <p>What methods to use a database from Clojure are there?</p>
<p>I know from Clojure you can do anything you can with Java, but that means that I may end up using something overly complicated (like Hibernate) which clashes with Clojure simplicity. Any recommendations or comments?</p>
| [
{
"answer_id": 8007765,
"author": "mikera",
"author_id": 214010,
"author_profile": "https://Stackoverflow.com/users/214010",
"pm_score": 4,
"selected": false,
"text": "(select users\n (aggregate (count :*) :cnt)\n (where (or (> :visits 20)\n (< :last_login a-year-ago))))\n"... | 2008/11/17 | [
"https://Stackoverflow.com/questions/294802",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6068/"
] |
294,822 | <p>I have a ComboBox bound to an ObservableCollection of decimals. What is the correct way to apply our currency converter to the items?</p>
<p>Edit:</p>
<p>a) I have an existing currency converter that I must use
b) .NET 3.0</p>
<p>Do I need to template the items?</p>
| [
{
"answer_id": 294830,
"author": "Jobi Joy",
"author_id": 8091,
"author_profile": "https://Stackoverflow.com/users/8091",
"pm_score": 0,
"selected": false,
"text": "<TextBox Text=\"{Binding Path=Value, StringFormat=Amount: {0:C}}\"/>\n"
},
{
"answer_id": 294838,
"author": "Ma... | 2008/11/17 | [
"https://Stackoverflow.com/questions/294822",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28074/"
] |
294,852 | <p>I find myself attached to a project to integerate an interpreter into an existing application. The language to be interpreted is a derivative of Lisp, with application-specific builtins. Individual 'programs' will be run batch-style in the application.</p>
<p>I'm surprised that over the years I've written a couple of compilers, and several data-language translators/parsers, but I've never actually written an interpreter before. The prototype is pretty far along, implemented as a syntax tree walker, in C++. I can probably influence the architecture beyond the prototype, but not the implementation language (C++). So, constraints:</p>
<ul>
<li>implementation will be in C++</li>
<li>parsing will probably be handled with a yacc/bison grammar (it is now)</li>
<li>suggestions of full VM/Interpreter ecologies like NekoVM and LLVM are probably not practical for this project. Self-contained is better, even if this sounds like NIH.</li>
</ul>
<p>What I'm really looking for is reading material on the fundamentals of implementing interpreters. I did some browsing of SO, and another site known as <a href="http://www.lambda-the-ultimate.org" rel="nofollow noreferrer">Lambda the Ultimate</a>, though they are more oriented toward programming language theory.</p>
<p>Some of the tidbits I've gathered so far:</p>
<ul>
<li><p><a href="https://rads.stackoverflow.com/amzn/click/com/0521545668" rel="nofollow noreferrer" rel="nofollow noreferrer">Lisp in Small Pieces</a>, by Christian Queinnec. The person recommending it said it "goes from the trivial interpreter to more advanced techniques and finishes presenting bytecode and 'Scheme to C' compilers."</p></li>
<li><p><a href="http://nekovm.org/" rel="nofollow noreferrer">NekoVM</a>. As I've mentioned above, I doubt that we'd be allowed to incorporate an entire VM framework to support this project.</p></li>
<li><p><a href="http://mitpress.mit.edu/sicp/full-text/book/book.html" rel="nofollow noreferrer">Structure and Interpretation of Computer Programs</a>. Originally I suggested that this might be overkill, but having worked through a healthy chunk, I agree with @JBF. Very informative, and mind-expanding.</p></li>
<li><p><a href="http://paulgraham.com/rootsoflisp.html" rel="nofollow noreferrer">On Lisp</a> by Paul Graham. I've read this, and while it is an informative introduction to Lisp principles, is not enough to jump-start constructing an interpreter.</p></li>
<li><p><a href="http://www.sidhe.org/~dan/presentations/Parrot_Implementation.pdf" rel="nofollow noreferrer">Parrot Implementation</a>. This seems like a fun read. Not sure it will provide me with the fundamentals.</p></li>
<li><p><a href="http://peter.michaux.ca/articles/scheme-from-scratch-introduction" rel="nofollow noreferrer">Scheme from Scratch</a>. Peter Michaux is attacking various implementations of Scheme, from a quick-and-dirty Scheme interpreter written in C (for use as a bootstrap in later projects) to compiled Scheme code. Very interesting so far.</p></li>
<li><p><a href="http://pragprog.com/book/tpdsl/language-implementation-patterns" rel="nofollow noreferrer">Language Implementation Patterns: Create Your Own Domain-Specific and General Programming Languages</a>, recommended in the comment thread for <a href="https://stackoverflow.com/questions/2853412/books-on-creating-interpreted-languages">Books On Creating Interpreted Languages</a>. The book contains two chapters devoted to the practice of building interpreters, so I'm adding it to my reading queue.</p></li>
<li><em>New</em> (and yet <em>Old</em>, i.e. 1979): <a href="http://books.google.com/books?id=d6cpAQAAIAAJ&q=writing+interactive+compilers+and+interpreters&dq=writing+interactive+compilers+and+interpreters&hl=en&ei=FzorTsDzFIj0swOb_4XMCg&sa=X&oi=book_result&ct=result&resnum=1&ved=0CCkQ6AEwAA" rel="nofollow noreferrer">Writing Interactive Compilers and Interpreters</a> by P. J. Brown. This is long out of print, but is interesting in providing an outline of the various tasks associated with the implementation of a Basic interpreter. I've seen mixed reviews for this one but as it is cheap (I have it on order used for around $3.50) I'll give it a spin.</li>
</ul>
<p>So how about it? Is there a good book that takes the neophyte by the hand and shows how to build an interpreter in C/C++ for a Lisp-like language? Do you have a preference for syntax-tree walkers or bytecode interpreters?</p>
<p>To answer @JBF:</p>
<ul>
<li><p>the current prototype is an interpreter, and it makes sense to me as we're accepting a path to an arbitrary code file and executing it in our application environment. The builtins are used to affect our in-memory data representation.</p></li>
<li><p>it should not be hideously slow. The current tree walker seems acceptable.</p></li>
<li><p>The language is <em>based</em> on Lisp, but is not Lisp, so no standards compliance required.</p></li>
<li>As mentioned above, it's unlikely that we'll be allowed to add a full external VM/interpreter project to solve this problem.</li>
</ul>
<p>To the other posters, I'll be checking out your citations as well. Thanks, all!</p>
| [
{
"answer_id": 296157,
"author": "plinth",
"author_id": 20481,
"author_profile": "https://Stackoverflow.com/users/20481",
"pm_score": 3,
"selected": false,
"text": "ConsBoxFactory &GetConsBoxFactory() { return mConsFactory; }\nAtomFactory &GetAtomFactory() { return mAtomFactory; }\nEnvir... | 2008/11/17 | [
"https://Stackoverflow.com/questions/294852",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3778/"
] |
294,865 | <p>How do you convert a number to a string showing dollars and cents?</p>
<pre><code>eg:
123.45 => '$123.45'
123.456 => '$123.46'
123 => '$123.00'
.13 => '$0.13'
.1 => '$0.10'
0 => '$0.00'
</code></pre>
| [
{
"answer_id": 294868,
"author": "nickf",
"author_id": 9021,
"author_profile": "https://Stackoverflow.com/users/9021",
"pm_score": 3,
"selected": false,
"text": "printf(\"$%01.2f\", $money);\n"
},
{
"answer_id": 294871,
"author": "Paige Ruten",
"author_id": 813,
"auth... | 2008/11/17 | [
"https://Stackoverflow.com/questions/294865",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9021/"
] |
294,875 | <p>What are some of the ways you have implemented models in the Zend Framework?</p>
<p>I have seen the basic <code>class User extends Zend_Db_Table_Abstract</code> and then putting calls to that in your controllers: </p>
<p><code>$foo = new User;</code></p>
<p><code>$foo->fetchAll()</code></p>
<p>but what about more sophisticated uses? The Quickstart section of the documentation offers such an example but I still feel like I'm not getting a "best use" example for models in Zend Framework. Any interesting implementations out there?</p>
<hr>
<p><strong>EDIT:</strong> I should clarify (in response to CMS's comment)... I know about doing more complicated selects. I was interested in overall approaches to the Model concept and concrete examples of how others have implemented them (basically, the stuff the manual leaves out and the stuff that basic how-to's gloss over) </p>
| [
{
"answer_id": 294896,
"author": "Christian C. Salvadó",
"author_id": 5445,
"author_profile": "https://Stackoverflow.com/users/5445",
"pm_score": 1,
"selected": false,
"text": "Zend_Db_Table"
},
{
"answer_id": 294914,
"author": "farzad",
"author_id": 9394,
"author_pro... | 2008/11/17 | [
"https://Stackoverflow.com/questions/294875",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11252/"
] |
294,885 | <p>I have a table like this:</p>
<pre><code><table>
<tfoot>
<tr><td>footer</td></tr>
</tfoot>
<tbody>
<tr><td>Body 1</td></tr>
<tr><td>Body 1</td></tr>
<tr><td>Body 1</td></tr>
</tbody>
<tbody>
<tr><td>Body 2</td></tr>
<tr><td>Body 2</td></tr>
<tr><td>Body 2</td></tr>
</tbody>
<tbody>
<tr><td>Body 3</td></tr>
<tr><td>Body 3</td></tr>
<tr><td>Body 3</td></tr>
</tbody>
</table>
</code></pre>
<p>I'd like to put some spacing between each tbody element, but padding and margin have no effect. Any ideas?</p>
| [
{
"answer_id": 294886,
"author": "Dave Jensen",
"author_id": 35341,
"author_profile": "https://Stackoverflow.com/users/35341",
"pm_score": 7,
"selected": true,
"text": "<style>\ntable {\n border-collapse: collapse;\n}\n\ntable tbody {\n border-top: 15px solid white;\n}\n</style>\n\n<ta... | 2008/11/17 | [
"https://Stackoverflow.com/questions/294885",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9021/"
] |
294,890 | <p>This might be too opinionated a question, but looking for help!</p>
<p>I have been trying to refine my ASP.NET MVC program structure. I just started using it at preview 5 and it is my first foray into business application development -- so everyting is new!</p>
<p>At the controller level, I have a service object responsible for talking to the repository and taking care of all business logic. At the action level, I have an object that holds all view data -- user input and generated output -- that I'll call view object (is there a general term for this?). Unlike most examples I see, this object is not a database object, but an object specific to the view.</p>
<p>So now I want to add user validation. The problem is, I'm not sure where to put it. It makes the most sense to me to do it in the Service layer. The Service layer is responsible for all the business logic and validation is business logic. On the other hand, most validation frameworks that I see are for validating an object, which makes me think the view object should be validation aware. Finally, there are some validation methods that would require a database connection (checking if a user input field has a corresponding database record for example), and the view object has no concept of a database, only the Service.</p>
<p>So some options I see are:</p>
<ul>
<li>Do validation in the Service.Method on the parameters passed to the method.</li>
<li>Do validation in the view object before calling Service.Method.</li>
<li>Do validation in the view object but make the Service.Method require a view object reference so it is initiating the validation on the object.</li>
</ul>
<p>I'm sure there are more. I'm curious of how other people handle user input validation in the MVC sense. I've previously used the Enterprise Validation Block and liked being able to use stock validators for everything, but I'm not sure how to make it fit into a seperate view object and service layer. It would be easy if they (view object / service) were the same object, which is maybe what people do? Like I said, its all new to me and I'm looking for best practice / patterns.</p>
| [
{
"answer_id": 296084,
"author": "anonymous",
"author_id": 36602,
"author_profile": "https://Stackoverflow.com/users/36602",
"pm_score": 1,
"selected": false,
"text": "public static void SavePerson(Person person)\n{\n // make sure it meets some format requirement\n // in this case ... | 2008/11/17 | [
"https://Stackoverflow.com/questions/294890",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36602/"
] |
294,905 | <p>Why does a System.Boolean take 4 bytes? It just stores one state, either <em>true</em> or <em>false</em>, which could be stored in less space than 4 bytes.</p>
| [
{
"answer_id": 294911,
"author": "arul",
"author_id": 15409,
"author_profile": "https://Stackoverflow.com/users/15409",
"pm_score": 2,
"selected": false,
"text": "Console.WriteLine( sizeof( System.Boolean ).ToString() );\n"
},
{
"answer_id": 294942,
"author": "P Daddy",
"... | 2008/11/17 | [
"https://Stackoverflow.com/questions/294905",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19917/"
] |
294,917 | <p>I'm trying to create a newsletter standard for our org and having problems with Outlook rendering the text too large.</p>
<p>Here is the css section of the page</p>
<pre><code>body {
margin: 0;
padding: 0;
font-family: Arial, Helvetica, sans-serif;
font-size: 75%;
background: url(http://www.blah.com/stuff.gif);
}
a {
color: #f24c22 !important;
}
a:visited {
color: #f24c22 !important;
}
a:hover {
color: #3d7ac5 !important;
}
table {
background: #ffffff;
}
h1 {
font-size: 1.3em;
}
h2 {
font-size: 1.2em;
color: #494949;
padding-top: 0 !important;
margin-top: 0 !important;
}
h3 {
font-size: 1.1em;
color: #12377c;
}
p {
padding-top: 0 !important;
margin-top: 0 !important;
color:#333333;
}
.style1 {color: #333333}
.style2 {color: #12377c}
.style3 {
font-size: smaller;
color: #666666;
}
</code></pre>
<p>Any suggestions why this might be caused?</p>
| [
{
"answer_id": 575878,
"author": "Esteban Küber",
"author_id": 34813,
"author_profile": "https://Stackoverflow.com/users/34813",
"pm_score": 3,
"selected": true,
"text": "main *{font-size: 12pt;}"
},
{
"answer_id": 1679306,
"author": "Dave Stewart",
"author_id": 203298,
... | 2008/11/17 | [
"https://Stackoverflow.com/questions/294917",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38149/"
] |
294,922 | <p>I have a winforms app and i want to keep track of every time a user clicks certain buttons, etc as well as other actions. What is the best way for me to keep track of this information and then put it together so i can run metrics on most used features, etc.</p>
<p>This is a winforms app and I have users around the world.</p>
| [
{
"answer_id": 294943,
"author": "arul",
"author_id": 15409,
"author_profile": "https://Stackoverflow.com/users/15409",
"pm_score": 0,
"selected": false,
"text": " // execute this method once all forms have been created\n public static void HookButtons()\n {\n foreach( F... | 2008/11/17 | [
"https://Stackoverflow.com/questions/294922",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4653/"
] |
294,927 | <p>Do you have to pass delete the same pointer that was returned by new, or can you pass it a pointer to one of the classes base types? For example:</p>
<pre><code>class Base
{
public:
virtual ~Base();
...
};
class IFoo
{
public:
virtual ~IFoo() {}
virtual void DoSomething() = 0;
};
class Bar : public Base, public IFoo
{
public:
virtual ~Bar();
void DoSomething();
...
};
Bar * pBar = new Bar;
IFoo * pFoo = pBar;
delete pFoo;
</code></pre>
<p>Of course this is greatly simplified. What I really want to do is create a container full of boost::shared_ptr and pass it to some code that will remove it from the container when it is finished. This code will know nothing of the implementation of Bar or Base, and will rely on the implied delete operator in the shared_ptr destructor to do the right thing.</p>
<p>Can this possibly work? My intuition says no, since the pointers will not have the same address. On the other hand, a dynamic_cast<Bar*> should work, so somewhere the compiler is storing enough information to figure it out.
<hr>
Thanks for the help, everybody who answered and commented. I already knew the importance of virtual destructors, as shown in my example; after seeing the answer I gave it a little thought, and realized the <i>whole reason</i> for a virtual destructor is this exact scenario. Thus it had to work. I was thrown by the absence of a visible means of converting the pointer back to the original. A little more thinking led me to believe there was an invisible means, and I theorized that the destructor was returning the true pointer for delete to release. Investigating the compiled code from Microsoft VC++ confirmed my suspicion when I saw this line in ~Base:</p>
<pre><code>mov eax, DWORD PTR _this$[ebp]
</code></pre>
<p>Tracing the assembler revealed that this was the pointer being passed to the delete function. Mystery solved.</p>
<p>I've fixed the example to add the virtual destructor to IFoo, it was a simple oversight. Thanks again to everyone who pointed it out.</p>
| [
{
"answer_id": 294932,
"author": "Adam Rosenfield",
"author_id": 9530,
"author_profile": "https://Stackoverflow.com/users/9530",
"pm_score": 7,
"selected": true,
"text": "Base"
},
{
"answer_id": 295048,
"author": "Michael Burr",
"author_id": 12711,
"author_profile": "... | 2008/11/17 | [
"https://Stackoverflow.com/questions/294927",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5987/"
] |
294,933 | <p>I have a couple of tables in a SQL 2008 server that I need to generate unique ID's for. I have looked at the "identity" column but the ID's really need to be unique and shared between all the tables. </p>
<p>So if I have say (5) five tables of the flavour "asset infrastructure" and I want to run with a unique ID between them as a combined group, I need some sort of generator that looks at all (5) five tables and issues the next ID which is not duplicated in any of those (5) five tales. </p>
<p>I know this could be done with some sort of stored procedure but I'm not sure how to go about it. Any ideas?</p>
| [
{
"answer_id": 294982,
"author": "Ian Varley",
"author_id": 37539,
"author_profile": "https://Stackoverflow.com/users/37539",
"pm_score": 2,
"selected": false,
"text": "CREATE PROCEDURE InsertAsset_Table1 (\n BEGIN TRANSACTION\n -- SELECT MIN INTEGER NOT ALREADY USED IN ANY OF THE FIVE... | 2008/11/17 | [
"https://Stackoverflow.com/questions/294933",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6335/"
] |
294,949 | <p>I need to create an empty .mdb file, so that I can then run ADO commands on it (<em>not</em> ADO.NET). Is there a way to create an empty mdb using ADO?</p>
| [
{
"answer_id": 294959,
"author": "Corey Trager",
"author_id": 9328,
"author_profile": "https://Stackoverflow.com/users/9328",
"pm_score": 3,
"selected": true,
"text": " string sADOProvider = \"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\";\n\n ADOX.CatalogClass cat = new ... | 2008/11/17 | [
"https://Stackoverflow.com/questions/294949",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14902/"
] |
294,969 | <p>I am working on an application that will be used as an extensible framework for other applications.</p>
<p>One of the fundamental classes is called Node, and Nodes have Content. The SQL tables look like this:</p>
<p>TABLE Node ( NodeId int, .... etc )</p>
<p>TABLE NodeContentRelationship ( NodeId int, ContentType string, ContentId int)</p>
<p>It will be up to the developers extending the application to create their own content types.</p>
<p>Clearly this is bad from a relationship-database point of view as it is not possible to add a foreign key relationship to NodeContentRelationship.ContentId, even though it <em>is</em> a foreign key column.</p>
<p>However, the solution is quite simple and powerful so I am reluctant to change it.</p>
<p>What do you think - am I in for a world of pain down the track?</p>
| [
{
"answer_id": 294994,
"author": "yfeldblum",
"author_id": 12349,
"author_profile": "https://Stackoverflow.com/users/12349",
"pm_score": 3,
"selected": true,
"text": "NoteContentRelationship.ContentId"
}
] | 2008/11/17 | [
"https://Stackoverflow.com/questions/294969",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21966/"
] |
294,976 | <p>As prescribed by Yahoo!, gzip'ng files would make your websites load faster. The problem? I don't know how :p</p>
| [
{
"answer_id": 295053,
"author": "amitkaz",
"author_id": 38100,
"author_profile": "https://Stackoverflow.com/users/38100",
"pm_score": 2,
"selected": false,
"text": "LoadModule deflate_module modules/mod_deflate.so\n"
},
{
"answer_id": 13054409,
"author": "Anthony Hatzopoulos... | 2008/11/17 | [
"https://Stackoverflow.com/questions/294976",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37532/"
] |
294,989 | <p>Can somebody tell me how to use the <em><code>printWhenExpression</code></em> of JasperReports?</p>
| [
{
"answer_id": 294999,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 4,
"selected": false,
"text": "$F{mesure} != \"PH\"\n($F{userfd4}).equals(\"1\") ? true : false \n"
},
{
"answer_id": 302142,
"author": "Dónal",
... | 2008/11/17 | [
"https://Stackoverflow.com/questions/294989",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
295,013 | <p>In the application that I am working on, the logging facility makes use of <code>sprintf</code> to format the text that gets written to file. So, something like:</p>
<pre><code>char buffer[512];
sprintf(buffer, ... );
</code></pre>
<p>This sometimes causes problems when the message that gets sent in becomes too big for the manually allocated buffer.</p>
<p>Is there a way to get <code>sprintf</code> behaviour without having to manually allocate memory like this? </p>
<p>EDIT: while <code>sprintf</code> is a C operation, I'm looking for C++ type solutions (if there are any!) for me to get this sort of behaviour...</p>
| [
{
"answer_id": 295018,
"author": "Artelius",
"author_id": 31945,
"author_profile": "https://Stackoverflow.com/users/31945",
"pm_score": 2,
"selected": false,
"text": "fprintf()"
},
{
"answer_id": 295023,
"author": "philant",
"author_id": 18804,
"author_profile": "http... | 2008/11/17 | [
"https://Stackoverflow.com/questions/295013",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4368/"
] |
295,016 | <p>When using <code>call_user_func_array()</code> I want to pass a parameter by reference. How would I do this. For example</p>
<pre><code>function toBeCalled( &$parameter ) {
//...Do Something...
}
$changingVar = 'passThis';
$parameters = array( $changingVar );
call_user_func_array( 'toBeCalled', $parameters );
</code></pre>
| [
{
"answer_id": 295020,
"author": "Steven Oxley",
"author_id": 3831,
"author_profile": "https://Stackoverflow.com/users/3831",
"pm_score": 7,
"selected": true,
"text": "call_user_func_array()"
},
{
"answer_id": 31972652,
"author": "Sophia_ES",
"author_id": 3080003,
"au... | 2008/11/17 | [
"https://Stackoverflow.com/questions/295016",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3831/"
] |
295,027 | <p>I am working on refactoring some old code and have found few structs containing zero length arrays (below). Warnings depressed by pragma, of course, but I've failed to create by "new" structures containing such structures (error 2233). Array 'byData' used as pointer, but why not to use pointer instead? or array of length 1? And of course, no comments were added to make me enjoy the process...
Any causes to use such thing? Any advice in refactoring those?</p>
<pre><code>struct someData
{
int nData;
BYTE byData[0];
}
</code></pre>
<p>NB It's C++, Windows XP, VS 2003</p>
| [
{
"answer_id": 296143,
"author": "Martin York",
"author_id": 14065,
"author_profile": "https://Stackoverflow.com/users/14065",
"pm_score": 6,
"selected": true,
"text": "struct someData* mallocSomeData(int size)\n{\n struct someData* result = (struct someData*)malloc(sizeof(struct som... | 2008/11/17 | [
"https://Stackoverflow.com/questions/295027",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7003/"
] |
295,028 | <p>I have a very tricky situation (for my standards) in hand. I have a script that needs to read a script variable name from <a href="https://docs.python.org/2/library/configparser.html" rel="nofollow noreferrer">ConfigParser</a>. For example, I need to read</p>
<pre><code>self.post.id
</code></pre>
<p>from a .cfg file and use it as a variable in the script. How do I achieve this?</p>
<p>I suppose I was unclear in my query. The .cfg file looks something like:</p>
<pre><code>[head]
test: me
some variable : self.post.id
</code></pre>
<p>This self.post.id is to be replaced at the run time, taking values from the script.</p>
| [
{
"answer_id": 295038,
"author": "Owen",
"author_id": 4853,
"author_profile": "https://Stackoverflow.com/users/4853",
"pm_score": 4,
"selected": true,
"text": "[head]\nvar: self.post.id\n"
},
{
"answer_id": 295745,
"author": "S.Lott",
"author_id": 10661,
"author_profi... | 2008/11/17 | [
"https://Stackoverflow.com/questions/295028",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2220518/"
] |
295,035 | <p>I have a sharepoint event handler which I want to activate for a single list, not all the lists in the site. How do I go about this?</p>
| [
{
"answer_id": 295090,
"author": "ashwnacharya",
"author_id": 1909,
"author_profile": "https://Stackoverflow.com/users/1909",
"pm_score": 3,
"selected": true,
"text": "string siteUrl = Console.ReadLine();\nSPSite site = new SPSite(siteUrl);\nSPWeb web = site.OpenWeb();\nstring listName =... | 2008/11/17 | [
"https://Stackoverflow.com/questions/295035",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1909/"
] |
295,042 | <p>Is there an issue with databinding in WPF when you bind to the current source (Path=".") and using a converter? The two way binding doesn't seem to work in this situation.</p>
<p>I know I could change the path, but I want to be able to pass the "Name" value to the converter.</p>
<p>I can't get the following example to work:</p>
<pre><code><Window x:Class="WpfTest.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:l="clr-namespace:WpfTest"
Title="Window1" Height="600" Width="600">
<Window.Resources>
<l:Person x:Key="myDataSource" Name="Cam"/>
<l:TestConverter x:Key="converter" />
</Window.Resources>
<StackPanel>
<StackPanel.DataContext>
<Binding Source="{StaticResource myDataSource}"/>
</StackPanel.DataContext>
<TextBox>
<TextBox.Text>
<Binding
Path="."
UpdateSourceTrigger="PropertyChanged"
Converter="{StaticResource converter}"
ConverterParameter="Name"
/>
</TextBox.Text>
</TextBox>
<TextBlock Text="{Binding Path=Name}"/>
</StackPanel>
</Window>
class TestConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return Reverse(value, parameter);
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return Reverse(value, parameter);
}
private static object Reverse(object value, object parameter)
{
if (value == null)
throw new ArgumentNullException("value", "value is null.");
if (parameter == null)
throw new ArgumentNullException("parameter", "parameter is null.");
Person p = (Person)value;
if (parameter.ToString() == "Name")
{
StringBuilder sb = new StringBuilder();
for (int i = p.Name.Length - 1; i >= 0; i--)
{
sb.Append(p.Name[i]);
}
return sb.ToString();
}
throw new NotImplementedException();
}
}
public class Person:INotifyPropertyChanged
{
private string name;
public string Name
{
get
{
return name;
}
set
{
name = value;
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs("Name"));
}
}
public event PropertyChangedEventHandler PropertyChanged;
}
</code></pre>
| [
{
"answer_id": 295090,
"author": "ashwnacharya",
"author_id": 1909,
"author_profile": "https://Stackoverflow.com/users/1909",
"pm_score": 3,
"selected": true,
"text": "string siteUrl = Console.ReadLine();\nSPSite site = new SPSite(siteUrl);\nSPWeb web = site.OpenWeb();\nstring listName =... | 2008/11/17 | [
"https://Stackoverflow.com/questions/295042",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3820/"
] |
295,052 | <p>Ok I need to determine the system's OS from a Lua script, but Lua as such has no API for this, so I use os.getenv() and query enviromental variables. On Windows checking the enviromental variable "OS" gives me the name of the system's OS, but is there some variable that exists on both Windows and most flavors of Unix that can be checked?</p>
| [
{
"answer_id": 14425862,
"author": "mnicky",
"author_id": 626431,
"author_profile": "https://Stackoverflow.com/users/626431",
"pm_score": 5,
"selected": false,
"text": "package.config:sub(1,1)"
},
{
"answer_id": 30960054,
"author": "Matías Hermosilla",
"author_id": 503227... | 2008/11/17 | [
"https://Stackoverflow.com/questions/295052",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15124/"
] |
295,055 | <p>I'm learning xForms, but apparently not well enough because I can't figure out why <a href="http://www.logomachist.info/temp/fix_me.xhtml.xml" rel="nofollow noreferrer">this code</a> doesn't work. </p>
<p>It parses in FF2 w/ the xForms extension but does not render the form controls. IE7 and X-Smiles give me different problems, but I'm not sure if those problems are becaause of my xForms or because of something else- until I get it working in FF2 I can't really tell.</p>
| [
{
"answer_id": 874224,
"author": "Phil Booth",
"author_id": 47348,
"author_profile": "https://Stackoverflow.com/users/47348",
"pm_score": 3,
"selected": true,
"text": "model"
}
] | 2008/11/17 | [
"https://Stackoverflow.com/questions/295055",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22885/"
] |
295,058 | <p>How do I convert a string to the variable name in <a href="http://en.wikipedia.org/wiki/Python_%28programming_language%29" rel="noreferrer">Python</a>?</p>
<p>For example, if the program contains a object named <code>self.post</code> that contains a variable named, I want to do something like:</p>
<pre><code>somefunction("self.post.id") = |Value of self.post.id|
</code></pre>
| [
{
"answer_id": 295064,
"author": "Owen",
"author_id": 4853,
"author_profile": "https://Stackoverflow.com/users/4853",
"pm_score": 6,
"selected": true,
"text": "eval()"
},
{
"answer_id": 295113,
"author": "Geo",
"author_id": 31610,
"author_profile": "https://Stackoverf... | 2008/11/17 | [
"https://Stackoverflow.com/questions/295058",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2220518/"
] |
295,059 | <p>Is it possible to get the value from the first page to the second page, BUT without <code>FORM</code>?</p>
<p>Shall we use</p>
<pre><code>window.parent.document.getElementById("").value..
</code></pre>
<p>But this is working in <code>popup</code> window, but I need this for between two pages which redirecting from the first page to the second page.</p>
| [
{
"answer_id": 295541,
"author": "Tom",
"author_id": 26155,
"author_profile": "https://Stackoverflow.com/users/26155",
"pm_score": 0,
"selected": false,
"text": "site.com/index.php?info=value"
}
] | 2008/11/17 | [
"https://Stackoverflow.com/questions/295059",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38172/"
] |
295,067 | <p>I am a COM object written in ATL that is used from a C++ application, and I want to pass an array of BYTEs between the two. My experience of COM/IDL so far is limited to passing simple types (BSTRs, LONGs, etc.).</p>
<p>Is there a relatively easy way to have the COM object pass an array to the caller? For example, I want to pass a raw image (TIFF) instead of messing with temporary files.</p>
| [
{
"answer_id": 295070,
"author": "jpoh",
"author_id": 4368,
"author_profile": "https://Stackoverflow.com/users/4368",
"pm_score": 0,
"selected": false,
"text": "[id(1), helpstring(\"LogCache\")] HRESULT LogCache([out,retval] VARIANT* logCache);\n"
},
{
"answer_id": 295080,
"a... | 2008/11/17 | [
"https://Stackoverflow.com/questions/295067",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9236/"
] |
295,071 | <p>When we write in a Javascript expression : </p>
<pre><code>expression < <%=variableJsp%>
</code></pre>
<p>the double "<" seems to be a problem and the JSP is not interpreted ?</p>
<p>Is it a fault of the other servers that should not accept this type of expression ? Or WebSphere that bugs ?</p>
| [
{
"answer_id": 295074,
"author": "krosenvold",
"author_id": 23691,
"author_profile": "https://Stackoverflow.com/users/23691",
"pm_score": 0,
"selected": false,
"text": "expression < <%=variableJsp%>\n"
}
] | 2008/11/17 | [
"https://Stackoverflow.com/questions/295071",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19281/"
] |
295,085 | <p>Is there a way to specify the font size for a class to be, say, 70% of the inherited font size?</p>
<p>I have a general "button" class that sets up my buttons with the appropriate borders, background, etc. I use it in multiple places, including one where the font size is fairly small and another where the font size is quite large.</p>
<pre><code><div style="font-size: 26px;">
Push this: <input class="button" type="submit" value="Go">
</div>
<div style="font-size: 10px;">
Push this too: <input class="button" type="submit" value="Go">
</div>
</code></pre>
<p>In both instances I'd like the button font-size to be about 70% of the font size of the span or div the button is in. </p>
<p>Can I do this with pure CSS?</p>
| [
{
"answer_id": 295087,
"author": "Jason Anderson",
"author_id": 5142,
"author_profile": "https://Stackoverflow.com/users/5142",
"pm_score": 2,
"selected": false,
"text": "font-size: 0.7em;\n"
},
{
"answer_id": 295093,
"author": "Will Kemp",
"author_id": 38177,
"author... | 2008/11/17 | [
"https://Stackoverflow.com/questions/295085",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13055/"
] |
295,091 | <p>The ListChanged event for an IBindingList fires a type ListChangedType.ItemDeleted when items are deleted, perhaps by a user deleting a row in a datagrid control bound to the list. The problem is that the NewIndex into the list is invalid in this event, it's been deleted, and the item that was deleted is not available. There should be an ItemDeleting event, but I doubt they will ever fix this.</p>
| [
{
"answer_id": 295468,
"author": "Sunlight",
"author_id": 33650,
"author_profile": "https://Stackoverflow.com/users/33650",
"pm_score": 2,
"selected": false,
"text": "NewIndex"
},
{
"answer_id": 2127342,
"author": "Adam Valpied",
"author_id": 257246,
"author_profile":... | 2008/11/17 | [
"https://Stackoverflow.com/questions/295091",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28343/"
] |
295,094 | <p>is there any known pattern/algorithm on how to perform sorting or filtering a list of records (from database) in the correct way? My current attempt involves usage of a form that provides some filtering and sorting options, and then append these criteria and sorting algorithm to my existing SQL. However, I find it can be easily abused that users may get results that they are not suppose to see. </p>
<p>The application that I am building is a scheduler where I store all the events in a database table. Then depending on user's level/role/privilege a different subset of data will be displayed. Therefore my query can be as complicated as </p>
<pre><code>SELECT *
FROM app_event._event_view
WHERE ((class_id = (SELECT class_id FROM app_event._ical_class WHERE name = 'PUBLIC') AND class_id != (SELECT class_id FROM app_event._ical_class WHERE name = 'PRIVATE') AND class_id != (SELECT class_id FROM app_event._ical_class WHERE name = 'CONFIDENTIAL')) OR user_id = '1')
AND calendar_id IN (SELECT calendar_id FROM app_event.calendar WHERE is_personal = 't')
AND calendar_id = (SELECT calendar_id FROM app_event.calendar WHERE name = 'personal')
AND state_id IN (1,2,3,4,5,6) AND EXTRACT(year FROM dtstart) = '2008'
AND EXTRACT(month FROM dtstart) = '11'
</code></pre>
<p>As I am more concern about serving the correct subset of information, performance is not a major concern at the moment (as the sql mentioned was generated by the script, clause by clause). I am thinking of turning all these complicated SQL statements to views, so there will be less chances that the SQL generated is inappropriate.</p>
| [
{
"answer_id": 295115,
"author": "Stein G. Strindhaug",
"author_id": 26115,
"author_profile": "https://Stackoverflow.com/users/26115",
"pm_score": 0,
"selected": false,
"text": "select from event where conditions AND event.privilegue <= user.privilegue\n"
},
{
"answer_id": 295129... | 2008/11/17 | [
"https://Stackoverflow.com/questions/295094",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5742/"
] |
295,095 | <p>I have a textbox whose value I want to set based on the inner text of an anchor tag. In other words, when someone clicks on this anchor:</p>
<pre><code><a href="javascript:void();" class="clickable">Blah</a>
</code></pre>
<p>I want my textbox to populate with the text "Blah". Here is the code I am currently using:</p>
<pre><code><script type="text/javascript">
$(document).ready(function(){
$("a.clickable").click(function(event){
$("input#textbox").val($(this).html());
});
});
</script>
</code></pre>
<p>And in my html there is a list of anchor tags with the class "clickable" and one textbox with the id "textbox".</p>
<p>I've substituted the code above with code to just show a javascript alert with $(this).html() and it seems to show the correct value. I have also changed the $(this).html() to be a hardcoded string and it setes the textbox value correctly. But when I combine them the textbox simply clears out. What am I doing wrong?</p>
| [
{
"answer_id": 295099,
"author": "Falco Foxburr",
"author_id": 37266,
"author_profile": "https://Stackoverflow.com/users/37266",
"pm_score": 7,
"selected": true,
"text": "<a href=\"#\" class=\"clickable\">Blah</a>\n<input id=\"textbox\">\n<script type=\"text/javascript\">\n $(document... | 2008/11/17 | [
"https://Stackoverflow.com/questions/295095",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1574/"
] |
295,100 | <p>I am having a similar issue to <a href="https://stackoverflow.com/questions/28387/sql-server-2k5-memory-consumption">this person</a>. The primary difference being the application is NOT meant for a developer environment, and therefore I need to know how to optimize the space used by Sql Server (possibly per machine based on specs).</p>
<p>I was intrigued by <a href="https://stackoverflow.com/users/10795/ricardo-c">Ricardo C's</a> answer, particularly the following:</p>
<blockquote>
<p>Extracted fromt he SQL Server
documentation:</p>
<p>Maximum server memory (in MB)</p>
<p>Specifies the maximum amount of memory SQL Server can allocate when it
starts and while it runs. This
configuration option can be set to a
specific value if you know there are
multiple applications running at the
same time as SQL Server and you want
to guarantee that these applications
have sufficient memory to run. If
these other applications, such as Web
or e-mail servers, request memory only
as needed, then do not set the option,
because SQL Server will release memory
to them as needed. <strong>However,
applications often use whatever memory
is available when they start and do
not request more if needed</strong>. If an
application that behaves in this
manner runs on the same computer at
the same time as SQL Server, set the
option to a value that guarantees that
the memory required by the application
is not allocated by SQL Server.</p>
</blockquote>
<p>My question is: how does an application request memory from the OS when it needs it? Is this something built into compilation or something managed by the developer? The two primary apps running on this machine are Sql Server and the (fairly heavyweight) C# application I'm developing, and I'm almost certain we didn't specifically do anything in the realm of asking the OS for memory. Is there a correct/necessary way to do this?</p>
| [
{
"answer_id": 295367,
"author": "Matthew Schinckel",
"author_id": 188,
"author_profile": "https://Stackoverflow.com/users/188",
"pm_score": 0,
"selected": false,
"text": "[object alloc]; \n"
}
] | 2008/11/17 | [
"https://Stackoverflow.com/questions/295100",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8207/"
] |
295,101 | <p>I have a movie which is made up of a series of SWF files that read XML. Is there any way to burn it to a CD/DVD or at least convert it to a 'burnable' format such as AVI, MPEG, or ISO? Currently in order to burn it I have to so some funky screen capture stuff and recorded it to a DVD that way.</p>
| [
{
"answer_id": 3975666,
"author": "fish2000",
"author_id": 298171,
"author_profile": "https://Stackoverflow.com/users/298171",
"pm_score": 0,
"selected": false,
"text": "package ost.panda.map.core {\n\n/// ...\n\npublic dynamic class Signatories extends EventDispatcher {\n\n [Embed(so... | 2008/11/17 | [
"https://Stackoverflow.com/questions/295101",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
295,104 | <p>In C#, what makes a field different from a property, and when should a field be used instead of a property?</p>
| [
{
"answer_id": 295109,
"author": "Cory",
"author_id": 8207,
"author_profile": "https://Stackoverflow.com/users/8207",
"pm_score": 11,
"selected": true,
"text": "public class MyClass\n{\n // this is a field. It is private to your class and stores the actual data.\n private string _... | 2008/11/17 | [
"https://Stackoverflow.com/questions/295104",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
295,110 | <p>I'm looking to use: </p>
<pre><code>#define
</code></pre>
<p>and</p>
<pre><code>#if
</code></pre>
<p>to allow me to simulate potentially absent hardware during unit tests. What are the rules for using the <code>#define</code> statements? </p>
<p>i.e. what is its default scope? can I change the scope of the directive?</p>
| [
{
"answer_id": 295162,
"author": "Ali Ersöz",
"author_id": 4215,
"author_profile": "https://Stackoverflow.com/users/4215",
"pm_score": 1,
"selected": false,
"text": "#define something\n... some code ...\n"
}
] | 2008/11/17 | [
"https://Stackoverflow.com/questions/295110",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1816/"
] |
295,112 | <p>How would I get the last item (or any specific item for that matter) in a simplexml object? Assume you don't know how many nodes there will be.</p>
<p>ex.</p>
<pre><code><?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="/xsl.xml"?>
<obj
href="http://xml.foo.com/"
display="com.foo.bar"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://obix.org/ns/schema/1.0"
>
<list name="data" of="HistoryRecord">
<obj>
<abstime name="timestamp" val="1876-11-10T00:00:00-08:00"></abstime>
<int name="energy_in_kwh" val="1234"></int>
<int name="energy_out_kwh" val="123456"></int>
</obj>
<obj>
<abstime name="timestamp" val="1876-11-10T00:15:00-08:00"></abstime>
<int name="energy_in_kwh" val="1335"></int>
<int name="energy_out_kwh" val="443321"></int>
</obj>
</list>
<int name="count" val="2"></int>
</obj>
</code></pre>
<p>And I want to grab the last <code><obj></obj></code> chunk (or even just part of it).</p>
| [
{
"answer_id": 295127,
"author": "Stein G. Strindhaug",
"author_id": 26115,
"author_profile": "https://Stackoverflow.com/users/26115",
"pm_score": 0,
"selected": false,
"text": "last()"
},
{
"answer_id": 295177,
"author": "DreamWerx",
"author_id": 15487,
"author_profi... | 2008/11/17 | [
"https://Stackoverflow.com/questions/295112",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11252/"
] |
295,114 | <p>Ok, I'm getting my version control processes in order for my web team.</p>
<p>I know ideally each user would have a full working copy of their code on their local machine.</p>
<p>Unfortunately for a lot of our web apps they have additional server specific DB or other system integration requirements that cannot be replicated on a user's workstation (i.e. some servers just wont install on XP, vista etc.)</p>
<p>I'm looking at setting up an area on one of my servers that acts as a working copy for each user but still resides on the network.</p>
<p>i.e.</p>
<pre><code>/SVRROOT/
- Dev1 Working Copy
- Dev2 Working Copy
- Dev3 Working Copy
</code></pre>
<p>This means that each user will have their own working space (as per SVN best practices) but it will reside on the network. </p>
<p>Does anyone see a problem with this model?</p>
| [
{
"answer_id": 55263128,
"author": "Cornelius Sicker",
"author_id": 2471067,
"author_profile": "https://Stackoverflow.com/users/2471067",
"pm_score": 0,
"selected": false,
"text": "TortoiseSVN"
}
] | 2008/11/17 | [
"https://Stackoverflow.com/questions/295114",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22837/"
] |
295,120 | <p>I have a method in an interface that I want to deprecate with portable C++.
When I Googled for this all I got was a Microsoft specific solution; <a href="https://learn.microsoft.com/en-us/cpp/preprocessor/deprecated-c-cpp?view=vs-2017" rel="noreferrer"><code>#pragma deprecated</code></a> and <a href="https://learn.microsoft.com/en-us/cpp/cpp/deprecated-cpp?view=vs-2017" rel="noreferrer"><code>__declspec(deprecated)</code></a>.</p>
<p>A second prize solution would be to <code>ifdef</code> a MSVC and a GCC solution.</p>
| [
{
"answer_id": 295149,
"author": "Terje Mikal",
"author_id": 37570,
"author_profile": "https://Stackoverflow.com/users/37570",
"pm_score": 5,
"selected": false,
"text": "void myfunc() __attribute__ ((deprecated));\n"
},
{
"answer_id": 295229,
"author": "Michael Platings",
... | 2008/11/17 | [
"https://Stackoverflow.com/questions/295120",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8524/"
] |
295,123 | <p>I need to write a temporary Web-based graphical front-end for a custom server system. In this case performance and scalability aren't issues, since at most 10 people may check the system simultaneously. Also it should be PHP or Python (server) & JavaScript (client) (can't use Flex or Silverlight for very specific non-programming related issues).</p>
<p>So I know I could use YUI or jQuery, but was wondering if there is something even more high-level that would say allow me to write such a little project within a few hours of work, and get done with it. Basically I want to be as lazy as possible (this is throw-away code anyways) and get the job done in as little time as possible.</p>
<p>Any suggestions?</p>
| [
{
"answer_id": 41054529,
"author": "AxleWack",
"author_id": 2298585,
"author_profile": "https://Stackoverflow.com/users/2298585",
"pm_score": 0,
"selected": false,
"text": "<!DOCTYPE html>\n<html>\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, in... | 2008/11/17 | [
"https://Stackoverflow.com/questions/295123",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15124/"
] |
295,128 | <p>I have an app which consists of several different assemblies, one of which holds the various interfaces which the classes obey, and by which the classes communicate across assembly boundaries. There are several classes firing events, and several which are interested in these events. </p>
<p>My question is as follows: is it good practice to implement a central EventConsolidator of some kind? This would be highly coupled, as it would need to know every class (or at least interface) throwing an event, and every consumer of an event would need to have a reference to EventConsolidator in order to subscribe. </p>
<p>Currently I have the situation where class A knows class B (but not C), class B knows class C, etc. Then if C fires an event B needs to pick it up and fire its own event in order for A to respond. These kinds of chains can get quite long, and it may be that B is only interested in the event in order to pass it along. I don't want A to know about C though, as that would break encapsulation. </p>
<p>What is good practice in this situation? Centralise the events, or grin and bear it and define events in each intermediate class? Or what are the criteria by which to make the decision? Thanks!</p>
<p>Edit: <a href="https://stackoverflow.com/questions/217233/bubbling-up-events">Here</a> is another question asking essentially the same thing.</p>
| [
{
"answer_id": 295145,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 4,
"selected": true,
"text": "public event FooHandler Foo\n{\n add\n {\n c.Foo += value;\n }\n remove\n {\n c.Foo -= value... | 2008/11/17 | [
"https://Stackoverflow.com/questions/295128",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6091/"
] |
295,135 | <p>I have a string that I want to use as a filename, so I want to remove all characters that wouldn't be allowed in filenames, using Python.</p>
<p>I'd rather be strict than otherwise, so let's say I want to retain only letters, digits, and a small set of other characters like <code>"_-.() "</code>. What's the most elegant solution?</p>
<p>The filename needs to be valid on multiple operating systems (Windows, Linux and Mac OS) - it's an MP3 file in my library with the song title as the filename, and is shared and backed up between 3 machines.</p>
| [
{
"answer_id": 295146,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 7,
"selected": false,
"text": ">>> import string\n>>> valid_chars = \"-_.() %s%s\" % (string.ascii_letters, string.digits)\n>>> valid_chars\n'-_.()... | 2008/11/17 | [
"https://Stackoverflow.com/questions/295135",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37134/"
] |
295,141 | <p>I have a List of custom object, which consist of a custom list.</p>
<pre><code>class person{
string name;
int age;
List<friend> allMyFriends;
}
class friend{
string name;
string address;
}
</code></pre>
<p>I'trying to bind a list of these objects to a GridView and the Grid should create for each friend a column and write the name in it. If some people have the same frined the grid shouldn't create a seperate column, but use the existing one. You know what I mean.
(The classes are just some sample classes to simplify my case)</p>
<p>Is there a way to dynamically customize the binding?</p>
<p>I can change the class definitions and so on, if they need to inherit from some interfaces or so on.</p>
<p>I googled a lot, but no example really seemed to cover this case.</p>
<p>Could the use of a objectSourceControl solve my problem in some way?</p>
<h3>Update:</h3>
<p>To give some more information:
In the end I have a list of persons, while each person in the list has a list of friends.</p>
<pre><code>List<person> allPerson = new List<person>();
// fill the list
Grid.DataSource = allPerson;
Grid.DataBind()
</code></pre>
<p>The table should have columns for each friend and the rows are the person. Where a person has a friend a cross (or whatever) needs to be placed in the grid.</p>
<pre><code>friend1 friend2
x peter
x x adam
</code></pre>
<p>At the moment a intercept the RowDataBound event and since the binding only creates the rows with the names and not the columns, because the only property on my person object is the name. Is there a way to force the binding to look through the List Property in the person objects and create a column for each of them.</p>
| [
{
"answer_id": 2059565,
"author": "Chris Porter",
"author_id": 13495,
"author_profile": "https://Stackoverflow.com/users/13495",
"pm_score": 3,
"selected": true,
"text": "public partial class _Default : System.Web.UI.Page\n{\n protected void Page_Load(object sender, EventArgs e)\n ... | 2008/11/17 | [
"https://Stackoverflow.com/questions/295141",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36475/"
] |
295,161 | <p>If you try to launch a .NET 3.5 application on a Windows computer which does not have this version of the .NET framework installed, you get a <code>FileNotFoundException</code> for some system assemblies (for example System.Core 3.5.0.0).</p>
<p>Is it possible to catch this exception and tell the user to upgrade their .NET framework or is it thrown too early to handle it?</p>
| [
{
"answer_id": 295168,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 2,
"selected": false,
"text": "System.Core.dll"
},
{
"answer_id": 295173,
"author": "David Wengier",
"author_id": 489,
"author_prof... | 2008/11/17 | [
"https://Stackoverflow.com/questions/295161",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11963/"
] |
295,163 | <p>I have a program that is running a basic RMISecurityManager in all its threads. But I would like to do more control to several threads and set another SecurityManager specially for these threads.</p>
<p>How can I do that ? ...if this is possible !?</p>
<p>thank you by advance.</p>
<p>Edit : I have found my solution. <a href="https://stackoverflow.com/questions/290545/how-to-automatically-copy-data-to-new-rmi-threads#298148">See here</a> for more details.</p>
| [
{
"answer_id": 295396,
"author": "Tom Hawtin - tackline",
"author_id": 4725,
"author_profile": "https://Stackoverflow.com/users/4725",
"pm_score": 3,
"selected": true,
"text": "java.security.AccessController.getContext"
}
] | 2008/11/17 | [
"https://Stackoverflow.com/questions/295163",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26465/"
] |
295,165 | <p>I have some special cells in my Excel workbooks which are managed by my Excel Add-in. I want to prevent users from changing content of those cells, but I also want to know, what value users wanted to enter to those cells. On the SheetChange event I can check what users entered to my special cells, but how do I determine the PREVIOUS value in those cells and REVERT user changes?</p>
<hr>
<p>It is not a solution for me. If I lock cell in Excel, it becomes read-only - user can not even try to enter anything to this cell - Excel popups warning dialog in this case. My problem is that I want to catch what user entered to my cell, do something with this value, and then revert cell content to original value.</p>
| [
{
"answer_id": 295212,
"author": "Mike Woodhouse",
"author_id": 1060,
"author_profile": "https://Stackoverflow.com/users/1060",
"pm_score": 3,
"selected": true,
"text": "Option Explicit\n\n' We are monitoring cell B2...\n\nPrivate initialB2Value As Variant ' holds the value for reinstat... | 2008/11/17 | [
"https://Stackoverflow.com/questions/295165",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37266/"
] |
295,169 | <p>A program written in Visual C/C++ 2005/2008 might not compile with another compiler such as GNU C/C++ or vice-versa. For example when trying to reuse code, which uses windows.h, written for a particular compiler with another, what are the differences to be aware of?</p>
<p>Is there any information about how to produce code which is compatible with either one compiler or another e.g. with either GC/C++ or MSVC/C++? What problems will attempting to do this cause?</p>
<p>What about other compilers, such as LCC and Digital Mars?</p>
| [
{
"answer_id": 296552,
"author": "Max Lybbert",
"author_id": 10593,
"author_profile": "https://Stackoverflow.com/users/10593",
"pm_score": 1,
"selected": false,
"text": "typename"
},
{
"answer_id": 298041,
"author": "MattyT",
"author_id": 7405,
"author_profile": "http... | 2008/11/17 | [
"https://Stackoverflow.com/questions/295169",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25093/"
] |
295,182 | <p>I have a producer-consumer pattern working for one product. What is the best implementation when the producer produce many products? For example a DataBaseEvent, GuiEvent and ControlEvent that the consumer shall consume. The code below shows the pattern for one product (a DataBaseEvent). Should each event type be enqueued on an own queue or should the events inherit a base class that can be enqueued. Maybe there exist a better pattern when working with many event types?</p>
<pre><code>class DataBaseEventArgs : EventArgs
{
public string textToDB = "";
}
class Consumer
{
private Producer mProducer = new Producer();
private Queue<DataBaseEventArgs> mDataBaseEventQueue = new Queue<DataBaseEventArgs>();
private static EventWaitHandle mDataBaseEventWaitHandle = new EventWaitHandle(false, EventResetMode.ManualReset);
private Thread mDataBaseEventDequeueThread = null;
public Consumer()
{
mDataBaseEventDequeueThread = new Thread(DataBaseDequeueEvent);
mDataBaseEventDequeueThread.Start();
mProducer.mDataBaseEventHandler += WhenDataBaseEvent;
}
protected void DataBaseDequeueEvent()
{
while (true)
{
DataBaseEventArgs e;
lock (((ICollection)mDataBaseEventQueue).SyncRoot)
{
if (mDataBaseEventQueue.Count > 0)
{
e = mDataBaseEventQueue.Dequeue();
}
}
// WriteToDatabase(e.textToDB);
if (mDataBaseEventQueue.Count == 0)
{
mDataBaseEventWaitHandle.WaitOne(1000);
mDataBaseEventWaitHandle.Reset();
}
}
}
internal void WhenDataBaseEvent(object sender, DataBaseEventArgs e)
{
lock (((ICollection)mDataBaseEventQueue).SyncRoot)
{
mDataBaseEventQueue.Enqueue(e);
mDataBaseEventWaitHandle.Set();
}
}
}
class Producer
{
public event EventHandler<DataBaseEventArgs> mDataBaseEventHandler = null;
public void SendDataBaseEvent()
{
if (mDataBaseEventHandler != null)
{
DataBaseEventArgs e = new DataBaseEventArgs();
e.textToDB = "This text will be written to DB";
mDataBaseEventHandler(this, e);
}
}
}
</code></pre>
| [
{
"answer_id": 295189,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 2,
"selected": false,
"text": "while(true) {\n T item;\n lock(lockObj) {\n if(queue.Count == 0) { // empty\n Monitor.Wait(lo... | 2008/11/17 | [
"https://Stackoverflow.com/questions/295182",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36922/"
] |
295,195 | <p>The problem is simple:</p>
<p>Using bash, I want to add a directory to my PYTHONPATH for ease of script execution. Unfortunately, the directory I want to use has a : in it. So I try each of the following</p>
<pre><code>export PYTHONPATH=${PYTHONPATH}:/home/shane/mywebsite.com:3344/
export PYTHONPATH=${PYTHONPATH}:/home/shane/mywebsite.com\:3344/
export PYTHONPATH=${PYTHONPATH}:"/home/shane/mywebsite.com:3344/"
</code></pre>
<p>None of these work. Every time, the path is created as two separate directories on the path in python.
My question is, is it possible to do this for bash?
If so, what's the syntax required?</p>
| [
{
"answer_id": 295226,
"author": "Kent Fredric",
"author_id": 15614,
"author_profile": "https://Stackoverflow.com/users/15614",
"pm_score": 2,
"selected": false,
"text": "export PYTHONPATH=${PYTHONPATH}:\"/home/shane/mywebsite.com\\:3344/\"\n"
},
{
"answer_id": 295233,
"autho... | 2008/11/17 | [
"https://Stackoverflow.com/questions/295195",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10264/"
] |
295,200 | <p><em>Short:</em> how does modelbinding pass objects from view to controller?</p>
<p><em>Long:</em><br>
First, based on the parameters given by the user through a search form, some objects are retrieved from the database.
These objects are given meta data that are visible(but not defining) to the customer (e.g: naming and pricing of the objects differ from region to region).<br>
Later on in the site, the user can click links that should show details of these objects.
Because these meta data are important for displaying, but not defining, I need to get the previously altered object back in the controller.
When I use the default asp.net mvc modelbinding, the .ToString() method is used. This off course doesn't return a relevant string for recreating the complete object.<br>
I would have figured the ISerializable interface would be involved, but this is not so.
How should I go about to get the desired effect? I can't imagine I'm the first one to be faced with this question, so I guess I'm missing something somewhere...</p>
| [
{
"answer_id": 295489,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 3,
"selected": true,
"text": "<%= Html.ActionLink( ViewData[\"CustomObject1\",\n \"Select\",\n new { TempDataK... | 2008/11/17 | [
"https://Stackoverflow.com/questions/295200",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11333/"
] |
295,224 | <p>I just want to clarify one thing. This is not a question on which one is better, that part I leave to someone else to discuss. I don't care about it.
I've been asked this question on my job interview and I thought it might be useful to learn a bit more.</p>
<p>These are the ones I could come up with:</p>
<ul>
<li>Java is "platform independent". Well nowadays you could say there is the <a href="http://en.wikipedia.org/wiki/Mono_%28software%29" rel="noreferrer">Mono</a> project so C# could be considered too but
I believe it is a bit exaggerating. Why? Well, when a new release of Java is done it is simultaneously available on all platforms it supports, on the other hand how many features of C# 3.0 are still missing in the Mono implementation? Or is it really <a href="http://en.wikipedia.org/wiki/Common_Language_Runtime" rel="noreferrer">CLR</a> vs. <a href="http://en.wikipedia.org/wiki/JRE" rel="noreferrer">JRE</a> that we should compare here?</li>
<li>Java doesn't support events and delegates. As far as I know.</li>
<li>In Java all methods are virtual</li>
<li>Development tools: I believe there isn't such a tool yet as Visual Studio. Especially if you've worked with team editions you'll know what I mean.</li>
</ul>
<p>Please add others you think are relevant.</p>
<p>Update:
Just popped up my mind, Java doesn't have something like custom attributes on classes, methods etc. Or does it?</p>
| [
{
"answer_id": 295241,
"author": "bruno conde",
"author_id": 31136,
"author_profile": "https://Stackoverflow.com/users/31136",
"pm_score": 3,
"selected": false,
"text": "Foo<T>"
},
{
"answer_id": 295248,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "ht... | 2008/11/17 | [
"https://Stackoverflow.com/questions/295224",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2921654/"
] |
295,234 | <p>I'm currently maintaining some flex code and noticed very many functions which are declared like:</p>
<pre><code>private function exampleFunc():void {
....
}
</code></pre>
<p>These functions are in the <em>global scope</em>, and aren't part of any specific class, so it's a bit unclear to me what effect declaring them as private would have. What restrictions does the "private" qualifier have for functions like this?</p>
| [
{
"answer_id": 295573,
"author": "mmattax",
"author_id": 1638,
"author_profile": "https://Stackoverflow.com/users/1638",
"pm_score": 3,
"selected": true,
"text": "\n<!-- FooBox.mxml -->\n<mx:Box xmlns:mx=\"http://www.macromedia.com/2003/mxml\">\n <mx:Script><![CDATA[\n private ... | 2008/11/17 | [
"https://Stackoverflow.com/questions/295234",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14302/"
] |
295,235 | <p>Recently I was trying to make a calendar application that will display the current year-month-date to the user. The problem is, if the user is gonna keep my application running even for the next day, how do I get notified ?? How shall I change the date displayed ? I don't wanna poll the current date to update it. Is this possible in c#. </p>
<p>Note: I tried out the <strong>SystemEvent.TimeChanged</strong> event, but it works only if the user manually changes the time / date from the control panel.</p>
| [
{
"answer_id": 4097497,
"author": "Case",
"author_id": 497238,
"author_profile": "https://Stackoverflow.com/users/497238",
"pm_score": 3,
"selected": false,
"text": "public void Main()\n{\n\n var T = new System.Timers.Timer();\n\n T.Elapsed += CallBackFunction;\n\n var D = (Date... | 2008/11/17 | [
"https://Stackoverflow.com/questions/295235",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
295,251 | <p>I have tried, 'PreviousPage', 'PreviousPage.IsCrossPagePostBack' 'Page.previousPage', page.title</p>
<p>It causes the client to stop rendering the page after this line.</p>
<p>simple example</p>
<pre><code>protected void Page_Load(object sender, EventArgs e)
{
response.write("I can see this");
string test = PreviousPage.IsCrossPagePostBack.toString(); //Any page call Causes client rendering to freeze
response.write("But i cant see this");
System.Windows.Forms.MessageBox.Show("However i can see this,proving that the server is still running the code");
}
</code></pre>
<p>Anybody Please, any ideas? </p>
| [
{
"answer_id": 295253,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 0,
"selected": false,
"text": "MessageBox"
}
] | 2008/11/17 | [
"https://Stackoverflow.com/questions/295251",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
295,257 | <p>How can I search for specific value in the registry keys?</p>
<p>For example I want to search for XXX in </p>
<pre><code>HKEY_CLASSES_ROOT\Installer\Products
</code></pre>
<p>any code sample in C# will be appreciated,</p>
<p>thanks</p>
| [
{
"answer_id": 295265,
"author": "Galwegian",
"author_id": 3201,
"author_profile": "https://Stackoverflow.com/users/3201",
"pm_score": 4,
"selected": false,
"text": "tlbimp \"C:\\Program Files\\Log Parser 2.2\\LogParser.dll\"\n/out:Interop.MSUtil.dll\n"
},
{
"answer_id": 295762,
... | 2008/11/17 | [
"https://Stackoverflow.com/questions/295257",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
295,266 | <p>I'm trying to wrap my head around how to search for something that appears in the middle of a word / expression - something like searching for "LIKE %book% " - but in SQL Server (2005) full text catalog.</p>
<p>How can I do that? It almost appears as if both <code>CONTAINS</code> and <code>FREETEXT</code> really don't support wildcard at the <strong>beginning</strong> of a search expression - can that really be?</p>
<p>I would have imagined that <code>FREETEXT(*, "book")</code> would find anything with "book" inside, including "rebooked" or something like that. </p>
| [
{
"answer_id": 295289,
"author": "Mitch Wheat",
"author_id": 16076,
"author_profile": "https://Stackoverflow.com/users/16076",
"pm_score": 4,
"selected": false,
"text": "CONTAINS(*, '\"book*\"')\n"
},
{
"answer_id": 295297,
"author": "Tomalak",
"author_id": 18771,
"au... | 2008/11/17 | [
"https://Stackoverflow.com/questions/295266",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
295,279 | <p>I'm talking about this:</p>
<p>If we have the letter 'A' which is 77 in decimal and 4D in Hex.
I am looking for the fastest way to get D.</p>
<p>I thought about two ways:</p>
<p>Given x is a byte.</p>
<ol>
<li><p><code>x << 4; x >> 4</code></p></li>
<li><p><code>x %= 16</code></p></li>
</ol>
<p>Any other ways? Which one is faster?</p>
| [
{
"answer_id": 295286,
"author": "arul",
"author_id": 15409,
"author_profile": "https://Stackoverflow.com/users/15409",
"pm_score": 2,
"selected": false,
"text": "x = (x & 0x0F);\n"
},
{
"answer_id": 295288,
"author": "Terje Mikal",
"author_id": 37570,
"author_profile... | 2008/11/17 | [
"https://Stackoverflow.com/questions/295279",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.