qid int64 4 22.2M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
339,910 | <p>in context of SQL Server 2005, I have a table for which the primary key is a uniqueidentifier (GUID), with a default value generated by the newid() function. I want to write a stored procedure that inserts a new record into the table. How do I get the record's PK value? for an identity-declared field, this is easy - I call scope_identity(). How should I proceed with guids?</p>
<p>Thanks,
Lucian</p>
| [
{
"answer_id": 339918,
"author": "Paul Nearney",
"author_id": 24071,
"author_profile": "https://Stackoverflow.com/users/24071",
"pm_score": 3,
"selected": true,
"text": "DECLARE @newGuid uniqueidentifier\nSET @newGuid = newid()\n\nINSERT INTO myTable(id, stringval)\nVALUES (@newGuid, \"H... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339910",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11464/"
] |
339,912 | <p>I have class with internal property:</p>
<pre><code>internal virtual StateEnum EnrolmentState
{
get { ..getter logic }
set { ..setter logic }
}
</code></pre>
<p>However I want to be able to access to this property outside of the assembly so I created method that simply returns this property:</p>
<pre><code>public StateEnum GetCurrentState()
{
return EnrolmentState;
}
</code></pre>
<p>But when I call this method from class outside of this assembly I get an exception</p>
<p><code>(System.TypeLoadException: Method 'get_EnrolmentState' on type 'EnrolmentAopProxy' from assembly '44fe776f-458e-4c5d-aa35-08c55501dd43, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is overriding a method that is not visible from that assembly.)</code></p>
<p>So it is possible to access to internal member outside of the assembly in any way, or I should consider a different approach.</p>
<p>Just to mention that this class is used as an O/R mapper entity (NPersist) and it is overrided from the O/R mapper to inject persistence code.</p>
| [
{
"answer_id": 339937,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 3,
"selected": true,
"text": "InternalsVisibleTo"
},
{
"answer_id": 340195,
"author": "Aleksandar",
"author_id": 29511,
"author_pro... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339912",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29511/"
] |
339,923 | <p>In an HTML table, the <code>cellpadding</code> and <code>cellspacing</code> can be set like this:</p>
<pre class="lang-html prettyprint-override"><code><table cellspacing="1" cellpadding="1">
</code></pre>
<p>How can the same be accomplished using CSS?</p>
| [
{
"answer_id": 339964,
"author": "mat",
"author_id": 42083,
"author_profile": "https://Stackoverflow.com/users/42083",
"pm_score": 6,
"selected": false,
"text": "cellspacing=\"0\""
},
{
"answer_id": 339997,
"author": "Will Prescott",
"author_id": 13780,
"author_profil... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339923",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1065/"
] |
339,931 | <p>Javascript client side application.</p>
<p>Trying to eliminate memory leaks leads to ugly (to say the least) code.</p>
<p>I am trying to clean up in window.unload instead on messing up all the code trying to avoid them.</p>
<p>We use mostly <code>element.onevent=function(){..};</code> pattern, that results in closure (mostly wanted) and memory leak.</p>
<p>We do not use javascript frameworks.</p>
<p>Are there any ideas on how to clean up properly on exit?</p>
<p>Has anyone do the same or are you trying to avoid them?</p>
| [
{
"answer_id": 1889571,
"author": "Ruan Mendes",
"author_id": 227299,
"author_profile": "https://Stackoverflow.com/users/227299",
"pm_score": 3,
"selected": true,
"text": "var EvtMgr = (function(){\n var listenerMap = {};\n\n // Public interface\n return {\n addListener: function (... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339931",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28207/"
] |
339,935 | <p>For example:</p>
<p>script.js:</p>
<pre><code>function functionFromScriptJS() {
alert('inside functionFromScriptJS');
}
</code></pre>
<p>iframe.html:</p>
<pre><code><html>
<head>
<script language="Javascript" src="script.js"></script>
</head>
<body>
<iframe>
<body>
<script language="JavaScript">
functionFromScriptJS();
</script>
</body>
</iframe>
</body>
<html>
</code></pre>
<p>The above call to functionFromScriptJS() is not working.</p>
<p>The first guess parent.functionFromScriptJS() is not working too.</p>
<p>Is it possible to access such an external function from an iframe when the include is not in the iframe itself but in the parent document?</p>
<p><strong>@Edit:</strong> So my mistake was that I put the document inside the iframe tag, and I sould have put it in a separate file and specified through the src attrubute of the tag. In this case <em>parent.functionFromScriptJS()</em> works.</p>
| [
{
"answer_id": 339965,
"author": "Ryan Cook",
"author_id": 43029,
"author_profile": "https://Stackoverflow.com/users/43029",
"pm_score": 3,
"selected": true,
"text": "<iframe>"
},
{
"answer_id": 339990,
"author": "adam",
"author_id": 33604,
"author_profile": "https://... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339935",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/578/"
] |
339,939 | <h2>My Situation</h2>
<ul>
<li>I have a N rectangles</li>
<li>The rectangles all have the same shape (for example 2 inches wide x 1 inch tall) - Let's refer to this size as Sw and Sh for the width and height</li>
<li>I want to position these rectangles in a grid such that the rects completely on top and next to each other - like what you would see in a spreadsheet </li>
<li>What I need is this: <strong>Given N, Sw, and Sh what are the number of rows (R) and columns (C) that would stack these rects into the most square-like arrangement possible</strong></li>
<li>It is understood that R & C may provide more cells than in needed (for example if N=15,Sw=1,Sh=1 then R=4,C=4 yielding 16 "slots" for 15 rectangles - that is OK.</li>
<li>If Sw=Sh then my humble math skills are enough - when they rectangles have differing widths and heights - well frankly that's beyond me.</li>
</ul>
<h2>Some Notes</h2>
<ul>
<li>Yes I have read this question: <a href="https://stackoverflow.com/questions/251488/stacking-rectangles-to-take-as-little-space-as-possible">Stacking rectangles to take as little space as possible</a> and no it did not help. Also it isnt the same question. That question is about rectangles that could be of different sizes, in this question the rectangles have the same size</li>
<li>Yes I have searched on wolfram.com, etc and no luck there</li>
<li>I don't have a strong math background so I the way I phrasing this problem may itself be preventing me from finding the answer - I've tried related searches relating to tiling, dissecting, decomposing, and not had any success there either</li>
</ul>
<h2>Some examples</h2>
<pre><code>the * indicates the edges of the rects
the | indicates that a cell is "filled-in"
Notice that not all R*C cells are filled in, but only and exactly N cells
IF N=1, Sw=2, Sh=1 THEN R=1, C=1
********
*||||||*
********
IF N=2, Sw=2, Sh=1 THEN R=2, C=1
********
*||||||*
********
*||||||*
********
IF N=3, Sw=2, Sh=1 THEN R=2, C=2
***************
*||||||* *
***************
*||||||*||||||*
***************
IF N=4, Sw=2, Sh=1 THEN R=2, C=2
***************
*||||||*||||||*
***************
*||||||*||||||*
***************
IF N=5, Sw=2, Sh=1 THEN R=3, C=2
***************
*||||||* *
***************
*||||||*||||||*
***************
*||||||*||||||*
***************
</code></pre>
<h2>Implementation of AaronofTomorrow's answer</h2>
<pre><code># Implementation of AaronofTomorrow's answer
# implemented in python 2.6
# reasonable output
# works in constant time
import math
def f( N, Sw, Sh ) :
cols = math.sqrt( float(N) * float(Sh) / float(Sw) )
cols = round(cols)
rows = float(N) / float(cols)
rows = math.ceil(rows)
return (int(cols),int(rows))
</code></pre>
<h2>Another implementation inspired by Will's answer (Updated on 2008-12-08) - this is the one I finally used</h2>
<pre><code># Another implementation inspired by Will's answer
# implemented in python 2.6
# reasonable output - a bit better in yielding more squarelike grids
# works in time proportional to number of rects
#
# strategy used it to try incrementaly adding a rect.
# if the resulting rect requires more space then two
# possibilities are checked - adding a new row or adding a new col
# the one with the best aspect ratio (1:1) will be chosen
def g( N, Sw, Sh ) :
slope = float(Sh)/float(Sw)
cols = 1
rows = 1
for i in xrange( N ) :
num_to_fit =i+1
allocated_cells= cols* rows
if ( num_to_fit <= allocated_cells ) :
pass # do nothing
else :
hc,wc = float(Sh * rows), float(Sw * (cols+1))
hr,wr = float(Sh * (rows+1)), float(Sw * cols)
thetac = math.atan( hc/wc)
thetar = math.atan( hr/wr)
alpha = math.pi/4.0
difr = abs(alpha-thetar)
difc = abs(alpha-thetac)
if ( difr < difc ) :
rows = rows +1
else:
cols = cols + 1
return (cols,rows)
</code></pre>
| [
{
"answer_id": 339982,
"author": "Will Dean",
"author_id": 987,
"author_profile": "https://Stackoverflow.com/users/987",
"pm_score": 1,
"selected": false,
"text": "N/nCols*Sh + nCols*Sw\n"
}
] | 2008/12/04 | [
"https://Stackoverflow.com/questions/339939",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13477/"
] |
339,952 | <p>We are in the process of upgrading our projects from C# 2.0 / VS2005 to C# 3.0 / VS2008. As part of the upgrade, we are adding some items to our coding standards document.</p>
<p>How would (or did) you change your coding standards document when upgrading from C# 2.0 / VS2005 to C# 3.0 / VS2008?</p>
| [
{
"answer_id": 340028,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 4,
"selected": true,
"text": "var"
},
{
"answer_id": 341485,
"author": "David Schmitt",
"author_id": 4918,
"author_profile": "https... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339952",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2822/"
] |
339,956 | <p>What is the best method for date of birth selector?</p>
<ul>
<li>3 text inputs (month / day / year) or one mask input. User MUST use keyboard</li>
<li>3 select boxes. User can use keyboard or mouse. </li>
<li>One nice <a href="http://jqueryui.com/demos/datepicker/" rel="noreferrer">datepicker</a>.</li>
</ul>
<p>I want to know what is the most usable and problem free solution, so user wont be confused at all.</p>
| [
{
"answer_id": 3261876,
"author": "Bennett McElwee",
"author_id": 61754,
"author_profile": "https://Stackoverflow.com/users/61754",
"pm_score": 4,
"selected": false,
"text": " _______\n|_______| (example: 31/3/1970)\n"
},
{
"answer_id": 24788502,
"author": "user3845825",
... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339956",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23810/"
] |
339,961 | <p>I need the perfect algorithm or C# function to calculate the difference (distance) between 2 decimal numbers.</p>
<p>For example the difference between:<br />
<strong>100</strong> and <strong>25</strong> is <strong>75</strong><br />
<strong>100</strong> and <strong>-25</strong> is <strong>125</strong><br />
<strong>-100</strong> and <strong>-115</strong> is <strong>15</strong><br />
<strong>-500</strong> and <strong>100</strong> is <strong>600</strong></p>
<p>Is there a C# function or a very elegant algorithm to calculate this or I have to go and handle every case separately with <em>if</em>s.</p>
<p>If there is such a function or algorithm, which one is it?</p>
| [
{
"answer_id": 339979,
"author": "terjetyl",
"author_id": 29519,
"author_profile": "https://Stackoverflow.com/users/29519",
"pm_score": 8,
"selected": true,
"text": "public decimal FindDifference(decimal nr1, decimal nr2)\n{\n return Math.Abs(nr1 - nr2);\n}\n"
},
{
"answer_id": ... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339961",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18631/"
] |
339,962 | <p>What I am trying to do when the user is in a textbox (in silverlight 2.0):</p>
<ul>
<li>When user presses the decimal point
(.) <strong>on the numeric pad</strong>, I want to
have it replaced by the correct
decimal separator (which is comma
(,) in a lot of countries)</li>
</ul>
<p>I can track that the user typed a decimal point by checking in the keydown event </p>
<pre><code>void Cell_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Decimal)
</code></pre>
<p>But how do I replace that key with an other in Silverlight. The <code>e.Key</code> is read only. Is there a way to 'send an other key' to the control? Or any other suggestions?</p>
| [
{
"answer_id": 340162,
"author": "Tjipke",
"author_id": 17709,
"author_profile": "https://Stackoverflow.com/users/17709",
"pm_score": 1,
"selected": true,
"text": " void CellText_KeyUp(object sender, KeyEventArgs e)\n {\n var DecSep = System.Threading.Thread.CurrentThread.Cu... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339962",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17709/"
] |
339,963 | <p>I'm trying to use System.Transaction.TransactionScope to create a transaction to call a few stored procedures but it doesn't seem to clean up after itself. Once the transaction is finished (commited or not and the transaction scope object is disposed) subsequent connections to the database open up with the read commit level of serializable instead of read commited like they normally would. </p>
<p>I'm opening and closing a connection for each call (well closing and returning to a pool of connections like normal in .NET), am I missing some way to explicitly reset the connection when I'm done using it for a transaction? I thought the idea behind System.Transaction.TransactionScope was to hide all the complexity.</p>
<p>So the code I have looks like this:</p>
<pre><code> using (var scope = new TransactionScope())
{
... make my 3 stored procedure calls ...
scope.Complete();
return returnCode;
}
</code></pre>
<p>which I guess is the normal way to do it. But then if I look in sqlserver profiler I can see connections being opened with </p>
<pre><code>set transaction isolation level serializable
</code></pre>
<p>which is messing with subsequent non-transaction related database activity and also is apparently not as fast. I can get around this by setting a transaction option to explicity do the transaction with ReadCommited but this is not the ideal behaviour for this operation in my opinion. </p>
<p>I've also tried explicitly creating a Commitabletransaction object, creating explict new transactions instead of using the ambient one and still no luck. </p>
<p>Any ideas on how to fix this would be much appreciated as any calls that use the serializable connection will throw an error if they try to use a readpast locking hint.</p>
| [
{
"answer_id": 340045,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 0,
"selected": false,
"text": "sp_reset_connection"
},
{
"answer_id": 341841,
"author": "gbn",
"author_id": 27535,
"author_profi... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339963",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6084/"
] |
339,969 | <p>I have two models one is Employee and other is Asset, with Many to one relation between Asset and Employee. And Asset is added as StackedInline field to Employee Admin interface, Is there anyway I can make Asset as read only field in the Employee Admin. </p>
<p>My intention was to show all the assets the employee is currently holding in the Admin, so that he will not delete it accidentally.</p>
| [
{
"answer_id": 1078084,
"author": "ha22109",
"author_id": 104824,
"author_profile": "https://Stackoverflow.com/users/104824",
"pm_score": 2,
"selected": false,
"text": "from django import forms\nfrom django.utils.safestring import mark_safe\nfrom datetime import datetime\n\nclass ReadOnl... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339969",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7965/"
] |
339,971 | <p>I have to include many header files, which are in different sub-directories. Is there a way in Visual Studio (I am using 2005 edition) to set one include path that Visual Studio will search also the sub-directories for header files?</p>
| [
{
"answer_id": 339988,
"author": "Joris Timmermans",
"author_id": 33987,
"author_profile": "https://Stackoverflow.com/users/33987",
"pm_score": 6,
"selected": true,
"text": "#include \"subdirectory/somefile.h\""
},
{
"answer_id": 26518113,
"author": "riderBill",
"author_i... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339971",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9035/"
] |
339,995 | <p>Is there a better way to develop Java Swing applications?</p>
<p>SWIXML? JavaFX? Anything else that developers out here have liked and recommend?</p>
| [
{
"answer_id": 340088,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 3,
"selected": false,
"text": "JPanel panel = new JPanel(new MigLayout());\n\npanel.add(firstNameLabel);\npanel.add(firstNameTextField);\npanel.add(lastNameLa... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339995",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29860/"
] |
340,003 | <p>What is the C++ equivalent to <code>GetObject</code> in <a href="http://en.wikipedia.org/wiki/JavaScript" rel="nofollow noreferrer">JavaScript</a> and <a href="http://en.wikipedia.org/wiki/VBScript" rel="nofollow noreferrer">VBScript</a>?</p>
<p>The closest match I found to my question is:</p>
<p><a href="http://codewiz51.blogspot.com/2008/06/vb-script-getobject-c-api-cogetobject.html" rel="nofollow noreferrer">http://codewiz51.blogspot.com/2008/06/vb-script-getobject-c-api-cogetobject.html</a></p>
<p>However the sample use an unexisting interface and asking for the <code>IUnknown</code> returns null. Did someone have an example that works?</p>
| [
{
"answer_id": 340032,
"author": "1800 INFORMATION",
"author_id": 3146,
"author_profile": "https://Stackoverflow.com/users/3146",
"pm_score": 1,
"selected": false,
"text": "CoGetObject"
},
{
"answer_id": 340117,
"author": "Emmanuel Caradec",
"author_id": 4508,
"author... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340003",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4508/"
] |
340,007 | <p>I've recently have a reason to include into our build script the creation of an XML configuration file. The most straightforward way I can think of to do this is to hard-code the XML content as a string into the script and then to simply create a file and write that XML string to the file (named appropriately etc). Is there a more elegant or efficient way of doing this? </p>
<p>The build script that I am looking to modify is written in VBScript.</p>
| [
{
"answer_id": 352035,
"author": "jpoh",
"author_id": 4368,
"author_profile": "https://Stackoverflow.com/users/4368",
"pm_score": 0,
"selected": false,
"text": "Function XMLToString(Nodes)\n dim retStr\n retStr = \"<?xml version=\"\"1.0\"\" encoding=\"\"utf-8\"\" ?>\"\n XMLToString = ... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340007",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4368/"
] |
340,010 | <p>I was reading up about NTVDM.exe as I build a quick test console app and it crashed on a friends machine complaining about this EXE.</p>
<p>As I understand it all DOS cmd windows (C# console apps included) run as 16bit not 32bit.</p>
<p>Is this true? Does this mean all my works console app back office apps are running as 16bit rather than making the most of the 32bit available?</p>
<p>What about Windows services? As I believe we wrote it as a console app then made it run as a windows service?</p>
<p>Thanks</p>
| [
{
"answer_id": 588720,
"author": "RBerteig",
"author_id": 68204,
"author_profile": "https://Stackoverflow.com/users/68204",
"pm_score": 0,
"selected": false,
"text": ".COM"
}
] | 2008/12/04 | [
"https://Stackoverflow.com/questions/340010",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6486/"
] |
340,020 | <p>I'm using this query to get all employees of {clients with name starting with lowercase "a"}:</p>
<pre><code>SELECT * FROM employees
WHERE client_id IN (SELECT id FROM clients WHERE name LIKE 'a%')
</code></pre>
<p>Column <code>employees.client_id</code> is an int, with <code>INDEX client_id (index_id)</code>. The subquery should IMHO return a list of id-s, which is then used in the WHERE clause.</p>
<p>When I <code>EXPLAIN</code> the query, the primary query uses no indexes (<code>type:ALL</code>). But when I <code>EXPLAIN</code>
a list taken from the subquery (e.g. <code>SELECT ... WHERE client_id IN (121,184,501)</code>), the <code>EXPLAIN</code> switches to <code>type:range</code>, and this query gets faster by 50%.</p>
<p>How can I make the query use the index for the data returned by subquery - or, is there a more efficient way of retrieving this data? (Retrieving the id-list to application server, joining it and sending a second query is even more expensive here).</p>
<p>Thanks in advance.</p>
| [
{
"answer_id": 340029,
"author": "cagcowboy",
"author_id": 19629,
"author_profile": "https://Stackoverflow.com/users/19629",
"pm_score": 5,
"selected": true,
"text": "SELECT employees.*\nFROM employees, clients\nWHERE employees.client_id = clients.id\nAND clients.name LIKE 'a%';\n"... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340020",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19746/"
] |
340,030 | <p>Is there a Firefox plugin for manipulating and deleting saved form data?
In the browser there is only the option to delete all data.</p>
| [
{
"answer_id": 340050,
"author": "stesch",
"author_id": 41860,
"author_profile": "https://Stackoverflow.com/users/41860",
"pm_score": 2,
"selected": false,
"text": "formhistory.sqlite"
}
] | 2008/12/04 | [
"https://Stackoverflow.com/questions/340030",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43144/"
] |
340,043 | <p>I have a problem and i would like to learn the correct way to solve this. </p>
<p>I have a Data Objeckt</p>
<pre><code>class LinkHolder {
public string Text;
public string Link;
}
</code></pre>
<p>I would like to present to the user a RadioButton list that uses the LinkHolder.Text value as descriptive text.
Then on the postback, i would like to do a </p>
<pre><code>Server.Transfer( LinkHolder.Link )
</code></pre>
<p>on the corresponding Link.</p>
<p>I am unsure what is the best/most correct way to do this. Any hints would be appreciated.</p>
| [
{
"answer_id": 340087,
"author": "terjetyl",
"author_id": 29519,
"author_profile": "https://Stackoverflow.com/users/29519",
"pm_score": 0,
"selected": false,
"text": "class LinkHolder {\n public string Text { get; set;}\n public string Link { get; set;}\n}\n"
},
{
"answer_i... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340043",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40274/"
] |
340,046 | <p>We have enableviewstate property for all the server controls in ASP.net.
We know that its going to have the member datas and values in viewstate across postbacks</p>
<p>What is the actual example for this?</p>
| [
{
"answer_id": 340370,
"author": "HTTP 410",
"author_id": 13118,
"author_profile": "https://Stackoverflow.com/users/13118",
"pm_score": 2,
"selected": false,
"text": "<asp:Label runat=\"server\" Font-Name=\"Verdana\" Text=\"Hello, World!\"></asp:Label>\n"
}
] | 2008/12/04 | [
"https://Stackoverflow.com/questions/340046",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22162/"
] |
340,049 | <p>When I call GetForegroundWindow from c# I am getting the explorer parent process ID (I see this from process explorer) and not the process ID of the app that is in the foreground.</p>
<p>Why is this and how do get the right process ID?</p>
<p>Malcolm</p>
| [
{
"answer_id": 340207,
"author": "Wolf5",
"author_id": 37643,
"author_profile": "https://Stackoverflow.com/users/37643",
"pm_score": 3,
"selected": false,
"text": " [DllImport(\"user32\", SetLastError = true)]\n public static extern int GetForegroundWindow();\n"
}
] | 2008/12/04 | [
"https://Stackoverflow.com/questions/340049",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40568/"
] |
340,090 | <p>I have a C# method that projects the value of a number from an interval to a target interval.<br>
<strong>For example:</strong> we have an interval of -1000 and 9000 and a value of 5000; if we want to project this value to an interval of 0..100 we get 60.</p>
<p>Here is the method: </p>
<pre><code>/// <summary>
/// Projects a value to an interval
/// </summary>
/// <param name="val">The value that needs to be projected</param>
/// <param name="min">The minimum of the interval the value comes from</param>
/// <param name="max">The maximum of the interval the value comes from</param>
/// <param name="intervalTop">The minimum of the interval the value will
/// be projected to</param>
/// <param name="intervalBottom">The maximum of the interval the value will
/// be projected to</param>
/// <returns>Projected value</returns>
public decimal ProjectValueToInterval(decimal val,
decimal min,
decimal max,
decimal intervalBottom,
decimal intervalTop)
{
decimal newMin = Math.Min(0, min);
decimal valueIntervalSize = Math.Abs(max - newMin);
decimal targetIntervalSize = Math.Abs(intervalTop - intervalBottom);
decimal projectionUnit = targetIntervalSize / valueIntervalSize;
return (val * projectionUnit) + Math.Abs((newMin * projectionUnit));
}
</code></pre>
<p>This method needs to be called for thousands of values.<br>
I was wondering if there is a more efficient way to do this in C#? If yes, what changes do you suggest?</p>
| [
{
"answer_id": 340141,
"author": "Skizz",
"author_id": 1898,
"author_profile": "https://Stackoverflow.com/users/1898",
"pm_score": 1,
"selected": false,
"text": "intervalTop + (intervalBottom - intervalTop) * (val - min) / (max - min);\n"
},
{
"answer_id": 340150,
"author": "... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340090",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18631/"
] |
340,093 | <p>I'm trying to make a proxy object in IronPython, which should dynamically present underlying structure. The proxy itself shouldn't have any functions and properties, I'm trying to catch all the calls in the runtime. Catching the function calls is easy, I just need to define <strong>getattr</strong>() function for my object, and check does appropriate function exists in the underlying layer, and return some function-like object.</p>
<p>I have problems with properties - I don't know how to distinguish the calling context, is my property called as a lvalue or rvalue:</p>
<p>o = myproxy.myproperty # <em>I need to call underlying.myproperty_get()</em></p>
<p>or</p>
<p>myproxy.myproperty = o # <em>I need to call underlying.myproperty_set(o)</em></p>
<p>I looked at the list of special functions in Python, but I didn't found anything appropriate.</p>
<p>I also tried to make property in the object on the fly, with combination of exec() and builtin property() function, but I found that IronPython 1.1.2 lacks of entire 'new' module (which is present in IronPython 2.x beta, but I'll rather use IP 1.x, because of .NET 2.0 framework).</p>
<p>Any ideas?</p>
| [
{
"answer_id": 340141,
"author": "Skizz",
"author_id": 1898,
"author_profile": "https://Stackoverflow.com/users/1898",
"pm_score": 1,
"selected": false,
"text": "intervalTop + (intervalBottom - intervalTop) * (val - min) / (max - min);\n"
},
{
"answer_id": 340150,
"author": "... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340093",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43152/"
] |
340,095 | <p>I am looking for a .net templating engine - something simple, lightweight, stable with not too many dependencies. All I need it for at the moment is creating templated plain text and html emails. Can anyone give me a good recommendation?</p>
<p>If it helps at all - something like Java's <a href="http://freemarker.sourceforge.net/" rel="noreferrer">Freemarker</a> or <a href="http://velocity.apache.org/" rel="noreferrer">Velocity</a> libraries.</p>
<p>[UPDATE]
Thanks for the answers so far - much appreciated. I am really intested in recommendations or war stories from when you have used these libraries. Seems to be the best way to make a decision without trying each in turn.</p>
| [
{
"answer_id": 33546901,
"author": "Nigrimmist",
"author_id": 1151741,
"author_profile": "https://Stackoverflow.com/users/1151741",
"pm_score": 2,
"selected": false,
"text": "namespace ConsoleApplication4\n{\nclass Program\n{\n static void Main(string[] args)\n {\n\n Stopwat... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340095",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1853/"
] |
340,104 | <p>So I've got some scripts I've written which set up a Google map on my page. These scripts are in included in the <code><head></code> of my page, and use jQuery to build the map with markers generated from a list of addresses on the page.</p>
<p>However, I have some exact co-ordinate data for each address which the javascript requires to place the markers correctly. This isn't information I want to be visible on the screen to the user, so what's the "best practice" way to put that data into my document?</p>
| [
{
"answer_id": 340126,
"author": "Rob Stevenson-Leggett",
"author_id": 4950,
"author_profile": "https://Stackoverflow.com/users/4950",
"pm_score": 1,
"selected": false,
"text": " <input id=\"coordinates\" type=\"hidden\" value=\"123.2123.123:123,123,321;.....\" />\n"
},
{
"answer... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340104",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31582/"
] |
340,111 | <pre><code><document.write("<SCR"+"IPT TYPE='text/javascript' SRC='"+"http"+(window.location.protocol.indexOf('https:')==0?'s':'')+"://"+gDomain+"/"+gDcsId+"/wtid.js"+"'><\/SCR"+"IPT>");
</code></pre>
<p>I need to escape the string above in order to add the whole thing to a StringBuilder but so far I must be missing something because string termination is not correct...</p>
| [
{
"answer_id": 340130,
"author": "Ian G",
"author_id": 31765,
"author_profile": "https://Stackoverflow.com/users/31765",
"pm_score": 0,
"selected": false,
"text": "JavaScript"
},
{
"answer_id": 340159,
"author": "Stephane",
"author_id": 32891,
"author_profile": "https... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340111",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42108/"
] |
340,128 | <p>We know that Python provides a lot of productivity over any compiled languages. We have programming in C# & need to write the unit test cases in C# itself. If we see the amount of code we write for unit test is approximately ten times more than the original code. </p>
<p>Is it ideal choice to write unit test cases in IronPython instead of C#? Any body has done like that? I wrote few test cases, they seems to be good. But hairy pointy managers won't accept.</p>
| [
{
"answer_id": 2994724,
"author": "Andy Dent",
"author_id": 53870,
"author_profile": "https://Stackoverflow.com/users/53870",
"pm_score": 1,
"selected": false,
"text": "[TestCase(12, 3, 4)]\n[TestCase(12, 2, 6)]\n[TestCase(12, 4, 3)]\n[TestCase(12, 0, 0, ExpectedException = typeof(System... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340128",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43056/"
] |
340,138 | <p>I have the odd problem that I am not able to open the properties of my .NET projects in Visual Studio. If I try to open it by clicking on the Properties tree node in the Solution Explorer I get the following message:</p>
<blockquote>
<p>There is no editor available for '....csproj'. Make sure the application for the file type (.csproj) is installed.</p>
</blockquote>
<p>If I try to open the project properties by the main menu nothing happens at all.</p>
<p>I already tried to reset the Visual Studio settings by command line and a repair installation but nothing helped so far.</p>
<p>I use the Visual Studio 2008 in version 9.0.30729.1 SP including the XNA Game Studio 3.0, ReSharper 4.1 and Visual SVN 1.5.1.</p>
<p>It is occurring on all my projects and seems to be a local issue because my co-workers do not have this kind of problem.</p>
<p>Help is much appreciated!</p>
<p>Thanks,
Michael</p>
| [
{
"answer_id": 413430,
"author": "Mil",
"author_id": 9470,
"author_profile": "https://Stackoverflow.com/users/9470",
"pm_score": 6,
"selected": true,
"text": "devenv /ResetSkipPkgs\n"
},
{
"answer_id": 43673571,
"author": "Anoop",
"author_id": 2123370,
"author_profile... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340138",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9470/"
] |
340,139 | <p>I have a set of conditions in my where clause like</p>
<pre><code>WHERE
d.attribute3 = 'abcd*'
AND x.STATUS != 'P'
AND x.STATUS != 'J'
AND x.STATUS != 'X'
AND x.STATUS != 'S'
AND x.STATUS != 'D'
AND CURRENT_TIMESTAMP - 1 < x.CREATION_TIMESTAMP
</code></pre>
<p>Which of these conditions will be executed first? I am using oracle.</p>
<p>Will I get these details in my execution plan?
(I do not have the authority to do that in the db here, else I would have tried)</p>
| [
{
"answer_id": 340293,
"author": "Tony Andrews",
"author_id": 18747,
"author_profile": "https://Stackoverflow.com/users/18747",
"pm_score": 6,
"selected": true,
"text": "SQL> set autotrace on\nSQL> select * from emp\n 2 join dept on dept.deptno = emp.deptno\n 3 where emp.ename like '... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340139",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16488/"
] |
340,145 | <p>How can I add the reboot action to a vdproj?</p>
<p>I need an <a href="http://en.wikipedia.org/wiki/Windows_Installer" rel="nofollow noreferrer">MSI</a> file which restart the PC at the end of the installation.</p>
| [
{
"answer_id": 342926,
"author": "saschabeaumont",
"author_id": 592,
"author_profile": "https://Stackoverflow.com/users/592",
"pm_score": 2,
"selected": false,
"text": "ForceReboot"
},
{
"answer_id": 6664104,
"author": "angularsen",
"author_id": 134761,
"author_profil... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340145",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15485/"
] |
340,183 | <p>I've been spending some time looking at Phil Haack's article on <a href="http://haacked.com/archive/2008/11/04/areas-in-aspnetmvc.aspx" rel="noreferrer">Grouping Controllers</a> very interesting stuff.</p>
<p>At the moment I'm trying to figure out if it would be possible to use the same ideas to create a plug-in/modular architecture for a project I'm working on.</p>
<p>So my question is: Is it possible to have the Areas in Phil's article split across multiple projects?</p>
<p>I can see that the name spaces will work themselves out, but I'm concerned about the views ending up in the right place. Is it something that can be sorted out with build rules?</p>
<p>Assuming that the above is possible with multiple projects in a single solution, does anyone have any ideas about the best way to make it possible with a separate solution and coding to a predefined set of interfaces? Moving from an Area to a plug-in.</p>
<p>I have some experiences with plug-in architecture but not masses so any guidance in this area would be useful.</p>
| [
{
"answer_id": 340322,
"author": "gius",
"author_id": 19712,
"author_profile": "https://Stackoverflow.com/users/19712",
"pm_score": 2,
"selected": false,
"text": "public IView GetView(string viewName)\n{\n switch (viewName)\n {\n case \"Namespace.View1\":\n return... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340183",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35047/"
] |
340,185 | <p>I am working on an application that involves some gis stuff. There would be some .shp files to be read and plotted onto an opengl screen. The current opengl screen is using the orthographic projection as set from <code>glOrtho()</code> and is already displaying a map using coordinates from a simple text file..</p>
<p>Now the map to be plotted is to be read from a shapefile.</p>
<p>I have the following doubts:</p>
<ol>
<li><p>How to use the WGS84 projection of the .shp file(as read from the .prj file of the shapefile,WKT format) into my existing glOrtho projection..is there any conversion that needs to be done? and how is it different from what the glOrtho() sets up?basically how to use this information?</p></li>
<li><p>My application needs to be setup in such a way that i can know the exact lat/long of a point on the map.for eg. if i am hovering on X city,its correct lat/long could be fetched.I know that this can be done by using opensource utils/apis like GDAL/OGR but i am messed up as the documentation of these apis are not getting into my head.
I tried to find some sample c++ progs but couldnt find one.</p></li>
<li><p>I have already written my own logic to read the coordinates from a shapefile containing either points/polyline/polygon(using C-shapelib) and plotted over my opengl screen.I found a OGR sample code in doc to read a POINTS shapefile but none for POLYGON shapefile.And the problem is that this application has to be so dynamic that upon loading the shapefile,it should correctly setup the projection of the opengl screen depending upon the projection of the .shp file being read..eg WGS84,LCC,EVEREST MODIFIED...etc. how to achieve this from OGR api?</p></li>
</ol>
<p>Kindly give your inputs on this problem.. I am really keen to make this work but im not getting the right start..</p>
| [
{
"answer_id": 24601460,
"author": "msmith81886",
"author_id": 2142228,
"author_profile": "https://Stackoverflow.com/users/2142228",
"pm_score": 0,
"selected": false,
"text": "Guide Books"
}
] | 2008/12/04 | [
"https://Stackoverflow.com/questions/340185",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30868/"
] |
340,192 | <p>I have a problem with a oneway web method that open a moss site (probably because in a oneway webmethod the context is null)</p>
<p>Is possible to rewrite this code to remove the null reference exception? (without the oneway attribute i don't have the exception)</p>
<pre><code>[SoapDocumentMethod(OneWay = true)]
[WebMethod(Description = "TestOneWay")]
public voidTestOneWay(string webUrl)
{
using (SPSite site = new SPSite(webUrl))
{
....
}
}
</code></pre>
<p>the exception is:</p>
<pre><code>[2304] Error:Object reference not set to an instance of an object.
[2304] w3wp.exe Error: 0 :
[2304StackTrace: at System.Web.Hosting.ISAPIWorkerRequestInProc.GetAdditionalServerVar(Int32 index)
[2304] at System.Web.Hosting.ISAPIWorkerRequestInProc.GetServerVariable(String name)
[2304] at System.Web.HttpRequest.AddServerVariableToCollection(String name)
[2304] at System.Web.HttpRequest.FillInServerVariablesCollection()
[2304] at System.Web.HttpServerVarsCollection.Populate()
[2304] at System.Web.HttpServerVarsCollection.Get(String name)
[2304] at System.Collections.Specialized.NameValueCollection.get_Item(String name)
[2304] at Microsoft.SharePoint.SPGlobal.CreateSPRequestAndSetIdentity(Boolean bNotGlobalAdminCode, String strUrl, Boolean bNotAddToContext, Byte[] UserToken, String userName, Boolean bIgnoreTokenTimeout, Boolean bAsAnonymous)
[2304] at Microsoft.SharePoint.SPRequestManager.GetContextRequest(SPRequestAuthenticationMode authenticationMode)
[2304] at Microsoft.SharePoint.Administration.SPFarm.get_RequestNoAuth()
[2304] at Microsoft.SharePoint.SPSite.CopyUserToken(SPUserToken userToken)
[2304] at Microsoft.SharePoint.SPSite.SPSiteConstructor(SPFarm farm, Guid applicationId, Guid contentDatabaseId, Guid siteId, SPUrlZone zone, Uri requestUri, String serverRelativeUrl, Boolean hostHeaderIsSiteName, Uri redirectUri, Pairing pairing, SPUserToken userToken)
[2304] at Microsoft.SharePoint.SPSite..ctor(SPFarm farm, Uri requestUri, Boolean contextSite, SPUserToken userToken)
[2304] at Microsoft.SharePoint.SPSite..ctor(String requestUrl)
[2304] at Reply.Moss2EAI.SPHandler.GetAllFlowConfiguration(String webUrl, String flowConList)
[2304] at Reply.Moss2EAI.EaiMossIntegration.GetMessagesFromEai(String webUrl, String listName, String applicationName)
</code></pre>
| [
{
"answer_id": 355627,
"author": "tartafe",
"author_id": 43162,
"author_profile": "https://Stackoverflow.com/users/43162",
"pm_score": 2,
"selected": true,
"text": "//Call this before call new SPSite()\n private static void ChangeContext(string webUrl)\n {\n Trace.Trace... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340192",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43162/"
] |
340,194 | <p>how to validate letters and whitespaces using Zend Framework ?</p>
| [
{
"answer_id": 341114,
"author": "dcousineau",
"author_id": 20265,
"author_profile": "https://Stackoverflow.com/users/20265",
"pm_score": 2,
"selected": false,
"text": "true"
}
] | 2008/12/04 | [
"https://Stackoverflow.com/questions/340194",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
340,204 | <p>Can a macro be written in Scheme (with <code>define-syntax</code>, for example) which will take expressions like this:</p>
<pre><code>(op a b c d e f g h i j)
</code></pre>
<p>And yield expressions like this as output?</p>
<pre><code>(op (op (op (op (op (op (op (op (op a b) c) d) e) f) g) h) i) j)
</code></pre>
<p>Of course, for arbitrary lengths. I can't think of a way to do it, given some template like this:</p>
<pre><code>(define-syntax op
(syntax-rules ()
[(_) 'base-case]
[(v1 v2 ...) 'nested-case??]))
</code></pre>
| [
{
"answer_id": 340294,
"author": "namin",
"author_id": 34596,
"author_profile": "https://Stackoverflow.com/users/34596",
"pm_score": 4,
"selected": true,
"text": "(define bop list)\n\n(define-syntax op\n (syntax-rules ()\n ((op a b) (bop a b))\n ((op a b c ...) (op (bop a b) c ...... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340204",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15055/"
] |
340,209 | <p>I'm writing a Java game and I want to implement a power meter for how hard you are going to shoot something. </p>
<p>I need to write a function that takes a int between 0 - 100, and based on how high that number is, it will return a color between Green (0 on the power scale) and Red (100 on the power scale).</p>
<p>Similar to how volume controls work:<br>
<img src="https://i.stack.imgur.com/uErDJ.png" alt="volume control"></p>
<p>What operation do I need to do on the Red, Green, and Blue components of a color to generate the colors between Green and Red?</p>
<p>So, I could run say, <code>getColor(80)</code> and it will return an orangish color (its values in R, G, B) or <code>getColor(10)</code> which will return a more Green/Yellow RGB value.</p>
<p>I know I need to increase components of the R, G, B values for a new color, but I don't know specifically what goes up or down as the colors shift from Green-Red.</p>
<hr>
<p>Progress:</p>
<p>I ended up using HSV/HSB color space because I liked the gradiant better (no dark browns in the middle).</p>
<p>The function I used was:</p>
<pre class="lang-java prettyprint-override"><code>public Color getColor(double power)
{
double H = power * 0.4; // Hue (note 0.4 = Green, see huge chart below)
double S = 0.9; // Saturation
double B = 0.9; // Brightness
return Color.getHSBColor((float)H, (float)S, (float)B);
}
</code></pre>
<p>Where "power" is a number between 0.0 and 1.0. 0.0 will return a bright red, 1.0 will return a bright green.</p>
<p>Java Hue Chart:<br>
<img src="https://i.stack.imgur.com/QphuU.png" alt="Java Hue Chart"></p>
| [
{
"answer_id": 340214,
"author": "Paul Dixon",
"author_id": 6521,
"author_profile": "https://Stackoverflow.com/users/6521",
"pm_score": 9,
"selected": true,
"text": "255"
},
{
"answer_id": 340234,
"author": "efotinis",
"author_id": 12320,
"author_profile": "https://St... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340209",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2635/"
] |
340,213 | <p>I work on a program in Delphi that holds a lot of data, and I wonder which method is the best to save it to file. Now we use records and "file of" to save it but I think it should be better methods. I would prefer a system that makes it easy to migrate from the system we use now.</p>
<p>EDIT: The application is a sort of a database application. The user use it to manage data.</p>
| [
{
"answer_id": 340304,
"author": "Miel",
"author_id": 17336,
"author_profile": "https://Stackoverflow.com/users/17336",
"pm_score": 2,
"selected": false,
"text": "procedure TmyThing.PutData(AFile: String);\nvar\n writer: TWriter;\n stream: TFileStream;\nbegin\n stream := TFileStream.C... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340213",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36966/"
] |
340,217 | <p>I have two tables with the following columns:</p>
<p>table1:</p>
<pre><code>id, agent_name, ticket_id, category, date_logged
</code></pre>
<p>table2:</p>
<pre><code>id, agent_name, department, admin_status
</code></pre>
<p>What I'm trying to achieve is to Select all rows from table1 where an agents department is equal to that of table2.</p>
<p>I've tried a few different join statements but I'm either getting the syntax wrong or it just won't work with this table setup. I'm a beginner when it comes to MySQL and from what I've read JOIN's are at the complex end of the spectrum!</p>
<p>One other option I've considered is duplicating the column "department" into table1 but that will require a little bit more coding on the frontend and I'm trying to see if I can achieve the desired result without doing that.</p>
<p>Any assistance greatly appreciated. </p>
| [
{
"answer_id": 340231,
"author": "Arvo",
"author_id": 35777,
"author_profile": "https://Stackoverflow.com/users/35777",
"pm_score": 0,
"selected": false,
"text": "select \n a.id, a.agent_name, a.ticket_id, \n a.category, a.date_logged, b.department\nfrom \n table1 a inner join t... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340217",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42428/"
] |
340,223 | <p>I have checked the whole site and googled on the net but was unable to find a simple solution to this problem.</p>
<p>I have a datatable which has about 20 columns and 10K rows. I need to remove the duplicate rows in this datatable based on 4 key columns. Doesn't .Net have a function which does this? The function closest to what I am looking for was datatable.DefaultView.ToTable(true, array of columns to display), But this function does a distinct on <strong>all</strong> the columns.</p>
<p>It would be great if someone could help me with this.</p>
<p>EDIT: I am sorry for not being clear on this. This datatable is being created by reading a CSV file and not from a DB. So using an SQL query is not an option.</p>
| [
{
"answer_id": 340235,
"author": "Samiksha",
"author_id": 29515,
"author_profile": "https://Stackoverflow.com/users/29515",
"pm_score": 0,
"selected": false,
"text": "DELETE FROM table1 AS tb1 INNER JOIN \n(SELECT id, COUNT(id) AS cntr FROM table1 GROUP BY id) AS tb2\nON tb1.id = tb2.id ... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340223",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24105/"
] |
340,232 | <p>With my jquery I'm trying to make the transition from a message to a loading function easy on the eyes by animate the opasity of the message out, inserting the loading.gif and animating the opacity back in. It fails.</p>
<pre><code>$('#powerSearchSubmitButton').click(function(ev) {
startLoad();
return false;
});
function startLoad() {
$('.message').each(function(i) {
$(this).animate({opacity: 0}, 500, function() {
$(this).html("<img src=\"/content/pics/loadingBig.gif\" alt=\"loading\" style=\"opacity:0\"/>");
$(this).animate({opacity: 1},500);
});
};
return true;
};
</code></pre>
<p>When I leave out the <code>.html()</code> call, it works fine (except off course the image is not there; So I think that it is beacuse the html isn't inserted with <code>opacity:0;</code> But when I inserted it with <code>style="opacity:0"</code> it cannot fade back in...</p>
<p>What am I doing wrong?</p>
| [
{
"answer_id": 341339,
"author": "Nathan Long",
"author_id": 4376,
"author_profile": "https://Stackoverflow.com/users/4376",
"pm_score": 2,
"selected": false,
"text": "$(this).fadeOut(500, function() {\n $(this).html(\"<img src='content/pics/loadingBig.gif' alt='loading'/>\");\n }... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340232",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11333/"
] |
340,237 | <p>I've cached a value using the ASP.NET Cache, with the following code:</p>
<pre><code>Cache.Insert("TEST_VALUE", 150, null, Cache.NoAbsoluteExpiration, TimeSpan.FromSeconds(120));
</code></pre>
<p>As I understand it, this should mean that if nothing accesses that object for 120 seconds, it will expire and return null.</p>
<p>However, if after 10 minutes I run a page which writes out that value from the cache, it's still there (and indeed still after a whole hour). I know there's nothing else accessing it, because this is all on a local server on my machine.</p>
<p>Can anyone tell me why these values aren't getting purged from the cache?</p>
<hr>
<p>Thanks, I see what you mean, but my HttpModule is checking the type of request before inserting anything into the cache, so it will only occur on form uploads.</p>
<p>I've tried what you suggested anyway, and the breakpoint never gets hit when I am refreshing the page that displays the cached value. </p>
<p>I am assuming that even reading from the cache should extend the lifespan of the object, so I am leaving it 5-10 minutes before refreshing the 'debugging' page, but the value is still there!</p>
| [
{
"answer_id": 341331,
"author": "Mark Bell",
"author_id": 43140,
"author_profile": "https://Stackoverflow.com/users/43140",
"pm_score": 1,
"selected": true,
"text": "Cache[\"TEST_VALUE\"] = counter;\n"
},
{
"answer_id": 343273,
"author": "Ben Aston",
"author_id": 38522,
... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340237",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43140/"
] |
340,250 | <p>Hi I'm using <code>System.Net.Mail</code> to send some HTML formatted emails.</p>
<p>What is the correct method for inserting css into the email message?</p>
<p>I know I can apply formatting to each item, but I'ld rather use style sheets..</p>
<p><strong>EDIT</strong>
I should have mentioned that this is for an internal application, and I expect 99% of users to be using Outlook or other client, but never hotmail or gmail etc.</p>
| [
{
"answer_id": 343618,
"author": "Alexander Prokofyev",
"author_id": 11256,
"author_profile": "https://Stackoverflow.com/users/11256",
"pm_score": 2,
"selected": false,
"text": "string letter = File.ReadAllText(Request.PhysicalApplicationPath + \"letter.html\");\nstring style = File.Read... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340250",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31765/"
] |
340,270 | <p>I'm doing some really simple math and saving the result to a MS SQL2008 DB.</p>
<p>I'm <em>averaging</em> out the some numbers, which are byte values between 1<->5. I wish to record probably 2 decimal places only. I don't care about rounding for the 2nd decimal place (eg. a 1.155 == 1.5 or 1.6 .. i'm not too phased).</p>
<p>So .. should i store the average result as a float, decimal or double?</p>
<p>When i check what LINQ returns, it can return all three values!</p>
<p>Lastly, what would be the relevant SQL datatype field, also.</p>
<p>cheers!</p>
| [
{
"answer_id": 340301,
"author": "Stein G. Strindhaug",
"author_id": 26115,
"author_profile": "https://Stackoverflow.com/users/26115",
"pm_score": 0,
"selected": false,
"text": "integer = ( sum(all_values) / all_values.count().float ) * 100;\n"
},
{
"answer_id": 341100,
"auth... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340270",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30674/"
] |
340,271 | <p>The bugzilla (perl-based) system has a feature to login automatically by using a http server environment variable. If you fill in the right ID or username, you are automatically logged in.</p>
<p>My server runs Joomla (PHP-based) and has all the information about who is logged in. It runs bugzilla within a sub-frame.</p>
<p>So, how can I set this enviroment value from a PHP script?</p>
<p>To put it in another way, how does the following script return my own-set variable elsewhere in a session from PHP:</p>
<pre><code>#!/usr/bin/perl -wT
print "Content-type: text/html\n\n";
while (($key, $val) = each %ENV) {
print "$key = $val&lt;BR&gt;\n";
}
</code></pre>
| [
{
"answer_id": 340301,
"author": "Stein G. Strindhaug",
"author_id": 26115,
"author_profile": "https://Stackoverflow.com/users/26115",
"pm_score": 0,
"selected": false,
"text": "integer = ( sum(all_values) / all_values.count().float ) * 100;\n"
},
{
"answer_id": 341100,
"auth... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340271",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26387/"
] |
340,274 | <p>I'm creating a zip file using the class FastZip from SharpZipLib and once I after I close the program, I cannot delete the file because:</p>
<p>"Cannot delete zip.zip: It is being used by another person or program. Close any programs that might be using the file and try again."</p>
<p>The code that is generating the file is simply this:</p>
<pre><code>fZip.CreateEmptyDirectories = true;
fZip.CreateZip(filesPath + "\\" + this.zipName, filesPath, false, this.zipFilter);
</code></pre>
<p>I tried using:</p>
<pre><code> using (FastZip fZip = new FastZip())
{
try
{
fZip.CreateEmptyDirectories = true;
fZip.CreateZip(filesPath + "\\" + this.zipName, filesPath, false, this.zipFilter);
}
catch (Exception)
{
}
}
</code></pre>
<p>But it doesn't convert to iDisposable</p>
| [
{
"answer_id": 340406,
"author": "Thomas Hansen",
"author_id": 29746,
"author_profile": "https://Stackoverflow.com/users/29746",
"pm_score": 0,
"selected": false,
"text": "using(Stream s = new SharpZipLibStream())\n{\n /*...do stuff, zip stuff.../\n}\n"
},
{
"answer_id": 342470... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340274",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36532/"
] |
340,277 | <p>I would like to use the JTable row sorter new in Java 6. But also I need it to be compatible in Mac OSX with Java 5. </p>
<p>Is it possible to find out the JVM version during runtime and use different code for the JTable with and without row sorter?</p>
| [
{
"answer_id": 340401,
"author": "Aaron Digulla",
"author_id": 34088,
"author_profile": "https://Stackoverflow.com/users/34088",
"pm_score": 0,
"selected": false,
"text": "sorterClass"
}
] | 2008/12/04 | [
"https://Stackoverflow.com/questions/340277",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9774/"
] |
340,282 | <p>Can someone explain to me why this code prints 14? I was just asked by another student and couldn't figure it out.</p>
<pre><code>int i = 5;
i = ++i + ++i;
cout<<i;
</code></pre>
| [
{
"answer_id": 340299,
"author": "Gonzalo Quero",
"author_id": 40996,
"author_profile": "https://Stackoverflow.com/users/40996",
"pm_score": -1,
"selected": false,
"text": "int i = 5;\ni = i+1; // First ++i, i is now 6\ni = i+1; // Second ++i, i is now 7\ni = i + i // i = 7 + 7\ncout << ... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340282",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2450/"
] |
340,283 | <p>Please consider the following <code>fork()</code>/<code>SIGCHLD</code> pseudo-code.</p>
<pre><code> // main program excerpt
for (;;) {
if ( is_time_to_make_babies ) {
pid = fork();
if (pid == -1) {
/* fail */
} else if (pid == 0) {
/* child stuff */
print "child started"
exit
} else {
/* parent stuff */
print "parent forked new child ", pid
children.add(pid);
}
}
}
// SIGCHLD handler
sigchld_handler(signo) {
while ( (pid = wait(status, WNOHANG)) > 0 ) {
print "parent caught SIGCHLD from ", pid
children.remove(pid);
}
}
</code></pre>
<p>In the above example there's a race-condition. It's possible for "<code>/* child stuff */</code>" to finish before "<code>/* parent stuff */</code>" starts which can result in a child's pid being added to the list of children after it's exited, and never being removed. When the time comes for the app to close down, the parent will wait endlessly for the already-finished child to finish.</p>
<p>One solution I can think of to counter this is to have two lists: <code>started_children</code> and <code>finished_children</code>. I'd add to <code>started_children</code> in the same place I'm adding to <code>children</code> now. But in the signal handler, instead of removing from <code>children</code> I'd <em>add</em> to <code>finished_children</code>. When the app closes down, the parent can simply wait until the difference between <code>started_children</code> and <code>finished_children</code> is zero.</p>
<p>Another possible solution I can think of is using shared-memory, e.g. share the parent's list of children and let the children <code>.add</code> and <code>.remove</code> themselves? But I don't know too much about this.</p>
<p>EDIT: Another possible solution, which was the first thing that came to mind, is to simply add a <code>sleep(1)</code> at the start of <code>/* child stuff */</code> but that smells funny to me, which is why I left it out. I'm also not even sure it's a 100% fix.</p>
<p>So, how would you correct this race-condition? And if there's a well-established recommended pattern for this, please let me know!</p>
<p>Thanks.</p>
| [
{
"answer_id": 340312,
"author": "Darron",
"author_id": 22704,
"author_profile": "https://Stackoverflow.com/users/22704",
"pm_score": -1,
"selected": false,
"text": " // main program excerpt\n for (;;) {\n if ( is_time_to_make_babies ) {\n\n pid = fork();\n if (pid... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340283",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
340,286 | <p>I keep getting this NPE in my application and I can't seem to get rid of it because it is not showing up in any of my source code. As you can see from the stacktrace it is not happening in my code but in the Swing plaf. Has any of you had this problem and maybe figured out what is happening here?</p>
<pre><code> 11:28:23,273 [AWT-EventQueue-0] ERROR [is.althingi.styran.utlit.styran.StyranImpl]
- uncaughtException
java.lang.NullPointerException
at javax.swing.plaf.basic.BasicTableUI$Handler.setValueIsAdjusting(Unknown Source)
at javax.swing.plaf.basic.BasicTableUI$Handler.mouseReleased(Unknown Source)
at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
</code></pre>
| [
{
"answer_id": 340340,
"author": "bruno conde",
"author_id": 31136,
"author_profile": "https://Stackoverflow.com/users/31136",
"pm_score": 2,
"selected": false,
"text": "private void setValueIsAdjusting(boolean flag) {\n table.getSelectionModel().setValueIsAdjusting(flag);\n table.... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340286",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3379/"
] |
340,341 | <p>When I call the connect function of the Paramiko <code>SSHClient</code> class, it outputs some log data about establishing the connection, which I would like to suppress.</p>
<p>Is there a way to do this either through Paramiko itself, or Python in general?</p>
| [
{
"answer_id": 340815,
"author": "M. Utku ALTINKAYA",
"author_id": 40948,
"author_profile": "https://Stackoverflow.com/users/40948",
"pm_score": 0,
"selected": false,
"text": "import sys\ndev_null = sys.stdout = sys.stderr = open('/dev/null', 'w')\ntry:\n.\n. connect()\n.\nfinally:\n de... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340341",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42820/"
] |
340,344 | <p>I Have created an SSRS Report for retrieving 55000 records using a Stored Procedure. When
executing from the Stored Proc it is taking just 3 seconds but when executing from SSRS report it is taking more than one minute. How can I solve this problem?</p>
| [
{
"answer_id": 21031438,
"author": "Zain",
"author_id": 3179416,
"author_profile": "https://Stackoverflow.com/users/3179416",
"pm_score": 0,
"selected": false,
"text": "declare @reportParamLocal int\nset @reportParamLocal = @reportParam\n\nselect * from Table A where A.field = @reportPar... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340344",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
340,345 | <p>I've got a C++ service which provides a named pipe to clients with a NULL SECURITY_ATTRIBUTES as follows:</p>
<p><code>
hPipe = CreateNamedPipe( lpszPipename, PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED, PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT,
PIPE_UNLIMITED_INSTANCES, BUFSIZE, BUFSIZE, 0, NULL);
</code></p>
<p>There is a dll which uses this pipe to get services.</p>
<p>There is a c# GUI which uses the dll and works fine.</p>
<p>There is a .net web site which also uses this dll (the exact same one on the same PC) but always gets permission denied when it tries to open the pipe.</p>
<p>Any one know why this might happen and how to fix it?</p>
<p>Also does anyone know of a good tutorial on SECURITY_ATTRIBUTES because I haven't understood the msdn info yet.</p>
<p>Thanks,
Patrick</p>
| [
{
"answer_id": 21031438,
"author": "Zain",
"author_id": 3179416,
"author_profile": "https://Stackoverflow.com/users/3179416",
"pm_score": 0,
"selected": false,
"text": "declare @reportParamLocal int\nset @reportParamLocal = @reportParam\n\nselect * from Table A where A.field = @reportPar... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340345",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38892/"
] |
340,353 | <p>I have a post-compilation step that manipulates the Java bytecode of generated classes. I'd like to make life as painless as possible for library consumers, so I'm looking at ways I can make this process automatic and (if possible) compiler agnostic.</p>
<p>The <a href="http://java.sun.com/javase/6/docs/api/javax/annotation/processing/package-summary.html" rel="nofollow noreferrer">Annotation Processing API</a> provides many of the desired features (automatic service discovery; supported by Eclipse). Unfortunately, this is aimed at code generators and <a href="http://java.sun.com/javase/6/docs/api/javax/annotation/processing/Filer.html" rel="nofollow noreferrer">doesn't support manipulation of existing artefacts</a>:</p>
<blockquote>
<p>The initial inputs to the tool are
considered to be created by the zeroth
round; therefore, attempting to create
a source or class file corresponding
to one of those inputs will result in
a FilerException.</p>
</blockquote>
<p>The Decorator pattern recommended by the API is not an option.</p>
<p>I can see how to perform the step with a runtime agent/instrumentation, but this is a worse option than a manual build step as it would require anyone even peripherally touched by the API to configure their JVMs in a non-obvious manner.</p>
<p>Is there a way to plug into or wrap the <a href="http://java.sun.com/javase/6/docs/api/javax/tools/JavaCompiler.html" rel="nofollow noreferrer">compiler tool</a> as invoked by <a href="http://java.sun.com/javase/6/docs/technotes/tools/" rel="nofollow noreferrer">javac</a>? Has anyone successfully subverted the annotation processors to manipulate bytecode, no matter what the doc says?</p>
| [
{
"answer_id": 340455,
"author": "Aaron Digulla",
"author_id": 34088,
"author_profile": "https://Stackoverflow.com/users/34088",
"pm_score": 3,
"selected": true,
"text": "Example"
}
] | 2008/12/04 | [
"https://Stackoverflow.com/questions/340353",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/304/"
] |
340,354 | <p>I had two domains for ex. domain1 and domain2, I am opening domain2/index.aspx page as popup from domain1/default.aspx page. While closing domain2 page i need to reload the domain1 page, i had given the javascript code as "Opener.Location.Reload();". I am getting <strong>Permission denied</strong> javascript error. Any ideas about this issue.</p>
| [
{
"answer_id": 340417,
"author": "Timothy Khouri",
"author_id": 11917,
"author_profile": "https://Stackoverflow.com/users/11917",
"pm_score": 2,
"selected": false,
"text": "// On the parent...\nfunction DoTheRefresh()\n{\n location.reload();\n}\n"
},
{
"answer_id": 1355689,
... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340354",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
340,356 | <p>When I call CreateProcess in Windows, the new process doesn't seem to inherit the console of the calling process. I made a test program that runs "ruby xtest", xtest being a script that writes "hello" to standard output. I ran this test program from Emacs, and get no output. I also tried the following code calling GetStdHandle, but again, no output. Then I tried passing CREATE_NEW_CONSOLE in dwCreationFlags to CreateProcess, which made a whole new window with the Ruby output. Finally, I made a simple fork/exec
test program and compiled it using Cygwin's GCC. This program worked: the Ruby output showed up in Emacs as expected. I tried to decipher the Cygwin source code in <a href="http://cygwin.com/cgi-bin/cvsweb.cgi/src/winsup/cygwin/spawn.cc?rev=1.268&content-type=text/x-cvsweb-markup&cvsroot=src" rel="noreferrer">http://cygwin.com/cgi-bin/cvsweb.cgi/src/winsup/cygwin/spawn.cc?rev=1.268&content-type=text/x-cvsweb-markup&cvsroot=src</a> but failed. So, how do you make the new process inherit the console of the parent process such that the output from the child shows up as expected?</p>
<pre><code>STARTUPINFO si;
PROCESS_INFORMATION pi;
memset(&si, 0, sizeof(si));
memset(&pi, 0, sizeof(pi));
si.dwFlags |= STARTF_USESTDHANDLES;
si.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
si.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
si.hStdError = GetStdHandle(STD_ERROR_HANDLE);
if(!CreateProcess(0, "ruby xtest", 0, 0, 1, 0, 0, 0, &si, &pi)) die("CreateProcess");
</code></pre>
| [
{
"answer_id": 552413,
"author": "MSN",
"author_id": 6210,
"author_profile": "https://Stackoverflow.com/users/6210",
"pm_score": 1,
"selected": false,
"text": "hStdInput"
},
{
"answer_id": 640473,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stac... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340356",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
340,359 | <p>like whether it is pentium or AMD etc. </p>
| [
{
"answer_id": 340434,
"author": "gimel",
"author_id": 6491,
"author_profile": "https://Stackoverflow.com/users/6491",
"pm_score": 2,
"selected": false,
"text": "Processor family type"
},
{
"answer_id": 340611,
"author": "WACM161",
"author_id": 12255,
"author_profile"... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340359",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38807/"
] |
340,366 | <p>I need to update a record in a database with the following fields </p>
<pre><code>[ID] int (AutoIncr. PK)
[ScorerID] int
[Score] int
[DateCreated] smalldatetime
</code></pre>
<p>If a record exists for todays date (only the date portion should be checked, not the time) and a given scorer, I'd like to update the score value for this guy and this day. If the scorer doesn't have a record for today, I'd like to create a new one.</p>
<p>I'm getting grey hair trying to figure how to put this into a single (is this possible?) sql statement. By the way I'm using an MSSQl database and the <code>ExecuteNonQuery()</code> method to issue the query.</p>
| [
{
"answer_id": 340384,
"author": "Timothy Khouri",
"author_id": 11917,
"author_profile": "https://Stackoverflow.com/users/11917",
"pm_score": 5,
"selected": true,
"text": "IF EXISTS (SELECT NULL FROM MyTable WHERE ScorerID = @Blah AND CONVERT(VARCHAR, DateCreated, 101) = CONVERT(VARCHAR,... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340366",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16440/"
] |
340,368 | <p>In Visual Studio 2005, is there an easy way to automatically increment the assembly/file build numbers after a successful build?</p>
<p>Emphasis on <strong><em>easy</em></strong>. I would like to track my build version, without having to set up CruiseControl or some similar tool.</p>
| [
{
"answer_id": 340404,
"author": "Dean",
"author_id": 11802,
"author_profile": "https://Stackoverflow.com/users/11802",
"pm_score": 3,
"selected": true,
"text": "<?xml version=\"1.0\" encoding=\"utf-8\"?> <Project DefaultTargets=\"Build\" \n xmlns=\"http://schemas.microsoft.com/... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340368",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22114/"
] |
340,376 | <p>I was wondering if it's possible to calculate the average of some numbers if I have this:</p>
<pre><code>int currentCount = 12;
float currentScore = 6.1123 (this is a range of 1 <-> 10).
</code></pre>
<p>Now, if I receive another score (let's say 4.5), can I recalculate the average so it would be something like:</p>
<pre><code>int currentCount now equals 13
float currentScore now equals ?????
</code></pre>
<p>or is this impossible and I still need to remember the list of scores?</p>
| [
{
"answer_id": 340387,
"author": "John with waffle",
"author_id": 279,
"author_profile": "https://Stackoverflow.com/users/279",
"pm_score": 4,
"selected": false,
"text": "current_sum += input;\ncurrent_count++;\ncurrent_average = current_sum/current_count;\n"
},
{
"answer_id": 34... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340376",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30674/"
] |
340,383 | <pre><code>function a () {
return "foo";
}
a.b = function () {
return "bar";
}
function c () { };
c.prototype = a;
var d = new c();
d.b(); // returns "bar"
d(); // throws exception, d is not a function
</code></pre>
<p>Is there some way for <code>d</code> to be a function, and yet still inherit properties from <code>a</code>?</p>
| [
{
"answer_id": 340838,
"author": "Eugene Lazutkin",
"author_id": 26394,
"author_profile": "https://Stackoverflow.com/users/26394",
"pm_score": 3,
"selected": false,
"text": "var d = new c();\n"
},
{
"answer_id": 341050,
"author": "Russell Leggett",
"author_id": 2828,
... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340383",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31662/"
] |
340,413 | <p>How do type casting happen without loss of data inside the compiler?</p>
<p>For example:</p>
<pre><code> int i = 10;
UINT k = (UINT) k;
float fl = 10.123;
UINT ufl = (UINT) fl; // data loss here?
char *p = "Stackoverflow Rocks";
unsigned char *up = (unsigned char *) p;
</code></pre>
<p>How does the compiler handle this type of typecasting? A low-level example showing the bits would be highly appreciated.</p>
| [
{
"answer_id": 340439,
"author": "MSalters",
"author_id": 15416,
"author_profile": "https://Stackoverflow.com/users/15416",
"pm_score": 3,
"selected": false,
"text": "& __stack[4] = float_to_int_bits(& __stack[0])"
},
{
"answer_id": 340466,
"author": "James Hopkin",
"auth... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340413",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38038/"
] |
340,415 | <p>I have a <code>JSP</code> page which contains an <code>HTML</code> <code><select></code> populated with all countries loaded from a database. Say for example, on "create user" all the country values are loaded in the select menu and I select 5 countries. Those 5 values are loaded into database for that particular user.</p>
<p>Now when I click on "modify user" for that userid again there will be a select menu and all the countries will be loaded in the select menu but those 5 countries should be highlighted/selected. </p>
<p>How do I accomplish this using <code>javascript</code>?</p>
| [
{
"answer_id": 340502,
"author": "kgiannakakis",
"author_id": 24054,
"author_profile": "https://Stackoverflow.com/users/24054",
"pm_score": 2,
"selected": false,
"text": "<select multiple=\"multiple\">\n <option value =\"UK\">UK</option>\n <option value =\"France\" selected=\"selected\... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340415",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
340,428 | <p>Is it possible to save a form in VBA as .exe file and then run it.</p>
| [
{
"answer_id": 340490,
"author": "Patrick Cuff",
"author_id": 7903,
"author_profile": "https://Stackoverflow.com/users/7903",
"pm_score": 4,
"selected": true,
"text": "/m"
}
] | 2008/12/04 | [
"https://Stackoverflow.com/questions/340428",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31132/"
] |
340,431 | <p>I want to create a linked server in one sql server to another using the sp_addlinkedserver procedure. When i access the remote server I would like it to logon as me (i.e. using my windows account). How do I do this?</p>
| [
{
"answer_id": 340450,
"author": "Ed Harper",
"author_id": 27825,
"author_profile": "https://Stackoverflow.com/users/27825",
"pm_score": 2,
"selected": false,
"text": "EXEC master.dbo.sp_addlinkedsrvlogin \n @rmtsrvname=N'<your linked server name>',\n @useself=N'True',\n @... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340431",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36189/"
] |
340,437 | <p>Whilst trawling through some old code I came across something similar to the following:</p>
<pre><code>class Base
{
public:
virtual int Func();
...
};
class Derived : public Base
{
public:
int Func(); // Missing 'virtual' qualifier
...
};
</code></pre>
<p>The code compiles fine (MS VS2008) with no warnings (level 4) and it works as expected - <code>Func</code> is virtual even though the virtual qualifier is missing in the derived class. Now, other than causing some confusion, are there any dangers with this code or should I change it all, adding the <code>virtual</code> qualifier?</p>
| [
{
"answer_id": 340446,
"author": "Blair Conrad",
"author_id": 1199,
"author_profile": "https://Stackoverflow.com/users/1199",
"pm_score": 4,
"selected": true,
"text": "virtual"
},
{
"answer_id": 340472,
"author": "James Hopkin",
"author_id": 11828,
"author_profile": "... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340437",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9236/"
] |
340,461 | <p>I am wondering how to tell NHibernate to resolve dependencies on my POCO domain objects.</p>
<p>I figured out that methods like CalculateOrderTax should be in the Domain object because they encode domain specific business rules. But once I have two of those I am violating SRP. </p>
<p>It would be no problem to extract those methods to Strategy classes, but I wonder how to make NHibernate load those. </p>
<p>It doesn't seem like a good solution to loop through a list of objects in the repository to do get/set based Dependecy injection before handing the object off to the higher layers.</p>
<p>I am also using Castle Windsor for my Depency injection right now.</p>
| [
{
"answer_id": 341009,
"author": "Cristian Libardo",
"author_id": 16526,
"author_profile": "https://Stackoverflow.com/users/16526",
"pm_score": 4,
"selected": true,
"text": "public class MyInterceptor : EmptyInterceptor\n{\n public override bool OnLoad(object entity, object id, object... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340461",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21699/"
] |
340,471 | <p>Our development process is highly automated via a raft of bash and php scripts (including subversion hook scripts.) These scripts do a number of things to integrate with our Bugzilla 3.0 installation.</p>
<p>But the current integration approach is a bunch of SQL calls which update the bugzilla database directly - which obviously has a number of downsides - including making me nervous about upgrading to 3.2 in case the database schema has changed!</p>
<p>For example, to add a comment to a bug, I'm doing an INSERT into the longdescs table.</p>
<p>So my (slightly long-winded) question is:</p>
<ul>
<li>should I be using Bugzilla WebServices (and if so, is there any good documentation other than the Bugzilla API docs which aren't getting me up to speed quickly)</li>
<li>or, should I be using some other Bugzilla API (direct perl calls?) - and, again, is there any decent doco on this?</li>
<li>or, should I just keep doing what I'm doing (direct SQL calls) because the db doesn't change that much and it "does the job"</li>
</ul>
| [
{
"answer_id": 363507,
"author": "Larry Silverman",
"author_id": 7752,
"author_profile": "https://Stackoverflow.com/users/7752",
"pm_score": 2,
"selected": false,
"text": "contrib/bz_webservice_demo.pl"
}
] | 2008/12/04 | [
"https://Stackoverflow.com/questions/340471",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24106/"
] |
340,507 | <p>I have a Customer class.</p>
<pre><code>public class Customer
{
private string _id;
private string _name;
// some more properties follow
</code></pre>
<p>I am inheriting the EqualityComparer form MyEqualityComparer(of Customer).<br>
This I am intending to use in LINQ queries.<br>
MyEqualityComparer is intended for partial check between two objects.<br>
If the customer.id and customer.name matches I treat the objects the equal. </p>
<pre><code>public class MyComparer : System.Collections.Generic.EqualityComparer<Customer>
{
public override bool Equals(Customer x, Customer y)
{
if (x.Id == y.Id && x.Name == y.Name)
return true;
else
return false;
}
public override int GetHashCode(Customer obj)
{
return string.Concat(obj.Id,obj.Name).GetHashCode();
}
}
</code></pre>
<p>I referred to <a href="https://stackoverflow.com/questions/16340/how-do-i-generate-a-hashcode-from-a-byte-array-in-c">generating hashcode</a>.<br>
I am little unsure about concatenating strings and using that as a hashcode.<br>
Is this safe and sound what I am trying to do ? </p>
| [
{
"answer_id": 340523,
"author": "liggett78",
"author_id": 19762,
"author_profile": "https://Stackoverflow.com/users/19762",
"pm_score": 2,
"selected": false,
"text": "return obj.Id.GetHashCode() ^ obj.Name.GetHashCode();\n"
},
{
"answer_id": 340526,
"author": "Jon Skeet",
... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340507",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41968/"
] |
340,520 | <p>A few months ago, I have programmed an ASP.NET GridView with a custom "Delete" LinkButton and Client-Side JavaScript Confirmation according to this msdn article:</p>
<p><a href="http://msdn.microsoft.com/en-us/library/bb428868.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/bb428868.aspx</a> (published in April 2007)</p>
<p>or e.g. <a href="https://stackoverflow.com/questions/218733/javascript-before-aspbuttonfield-click">Javascript before asp:ButtonField click</a></p>
<p>The code looks like this:</p>
<pre><code><ItemTemplate>
<asp:LinkButton ID="deleteLinkButton" runat="server"
Text="Delete"
OnCommand="deleteLinkButtonButton_Command"
CommandName='<%# Eval("id") %>'
OnClientClick='<%# Eval("id", "return confirm(\"Delete Id {0}?\")") %>'
/>
</ItemTemplate>
</code></pre>
<p>Surprisingly, "Cancel" doesn't work no more with my ie (Version: <code>6.0.2900.2180.xpsp_sp2_qfe.080814-1242</code>) - it always deletes the row. With Opera (Version 9.62) it still works as expeced and described in the msdn article. More surprisingly,
on a fellow worker's machine with the same ie version, it still works ("Cancel" will not delete the row).</p>
<p>The generated code looks like </p>
<pre><code><a onclick="return confirm(...);" href="javascript:__doPostBack('...')">
</code></pre>
<p>As confirm(...) returns false on "Cancel", I expect the __doPostBack event in the href not to be fired. Are there any strange ie settings I accidentally might have changed? What else could be the cause of this weird behaviour? Or is this a "please reinstall WinXP" issue?</p>
| [
{
"answer_id": 340747,
"author": "Samiksha",
"author_id": 29515,
"author_profile": "https://Stackoverflow.com/users/29515",
"pm_score": 1,
"selected": false,
"text": "<asp:LinkButton ID=\"DeleteButton\" runat=\"server\" CausesValidation=\"False\"\n CommandName=\"Delete\" Text=\"Delete... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340520",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
340,521 | <p>I'm writing a service that will only get calls from the local host. Performance is important so I thought I'd try the <a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.netnamedpipebinding.aspx" rel="noreferrer">NetNamedPipeBinding</a> instead of <a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.nettcpbinding.aspx" rel="noreferrer">NetTcpBinding</a> and see If I could see any noticeable performance gains.</p>
<p>If a client, after having performed one or more requests to the server, is idle for a longer period of time the next request will fail seemingly due to some idle timeout in the binding. The same thing also happens when the service gets restarted.</p>
<p>I need my clients to be able to keep a connection open for as long as it's allowed in order to avoid the overhead associated with setting up a new connection. I also need to be able to restart the service from time to time and have the clients to automatically retry if they notice that the connection has been terminated.</p>
<p>I know that this is suppported by the reliability stuff in NetTcpBinding but how would one go about getting the same level of re-connect reliability in the NetNamedPipeBinding? Is it even possible?</p>
<p>The question is somewhat academic as it isn't a requirement to use NetNamedPipes, I could just as easily adopt it to use the tcp-binding but It's an itch and I'd really like to scratch it.</p>
| [
{
"answer_id": 340869,
"author": "Chris Porter",
"author_id": 13495,
"author_profile": "https://Stackoverflow.com/users/13495",
"pm_score": 4,
"selected": false,
"text": "<binding name=\"MyBindingName\" sendTimeout=\"00:00:30\" receiveTimeout=\"infinite\">\n <reliableSession enabled=\... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340521",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2114/"
] |
340,525 | <p>I'm trying to learn about Expression trees, and I've created a method that takes an</p>
<pre><code>Expression<Func<bool>>
</code></pre>
<p>and executes it if it satisfies some conditions - see the code below.</p>
<pre><code> private static void TryCommand(Expression<Func<bool>> expression)
{
var methodCallExpression = expression.Body as MethodCallExpression;
if (methodCallExpression == null)
{
throw new ArgumentException("expression must be a MethodCallExpression.");
}
if (methodCallExpression.Object.Type != typeof (MyClass))
{
throw new ArgumentException("expression must be operating on an instanceof MyClass.");
}
var func = expression.Compile();
var success = func.Invoke();
if(!success)
{
Console.WriteLine(methodCallExpression.Method.Name + "() failed with error code " + (func.Target as MyClass).GetError());
}
}
</code></pre>
<p>The problem that</p>
<pre><code>(func.Target as MyClass)
</code></pre>
<p>is null. Clearly I'm doing something wrong! How do I access the instance that the method is operating on?</p>
| [
{
"answer_id": 340566,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 2,
"selected": true,
"text": "Func<int>"
},
{
"answer_id": 1422704,
"author": "Ricardo Lacerda Castelo Branco",
"author_id": 173246,
... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340525",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32413/"
] |
340,528 | <p>If both get and set are compulsory in C# automatic properties, why do I have to bother specifying "get; set;" at all?</p>
| [
{
"answer_id": 340531,
"author": "Brian Genisio",
"author_id": 36687,
"author_profile": "https://Stackoverflow.com/users/36687",
"pm_score": 6,
"selected": false,
"text": "public int Foo { get; private set; }\n"
},
{
"answer_id": 340535,
"author": "Cristian Libardo",
"aut... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340528",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38522/"
] |
340,543 | <p>I have a problem creating a regular expression for the following task:</p>
<p>Suppose we have HTML-like text of the kind:</p>
<pre><code><x>...<y>a</y>...<y>b</y>...</x>
</code></pre>
<p>I want to get a collection of values inside <code><y></y></code> tags located inside a given <code><x></code> tag, so the result of the above example would be a collection of two elements ["a","b"].</p>
<p>Additionally, we know that:</p>
<ul>
<li><code><y></code> tags cannot be enclosed in other <code><y></code> tags </li>
<li><code>...</code> can include any text or other tags.</li>
</ul>
<p>How can I achieve this with RegExp?</p>
| [
{
"answer_id": 340603,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 2,
"selected": false,
"text": "\"y\" tags cannot be enclosed in other \"y\" tags\n\ninput looks like: <x>...<y>a</y>...<y>b</y>...</x>\n"
},
{
"a... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340543",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
340,546 | <p>It is advised to use override instead of new key word in C#. Why that rule?</p>
| [
{
"answer_id": 340554,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 5,
"selected": true,
"text": "Base b = new Derived();\nDerived d = new Derived();\nb.MyMethod(); // Calls Base.MyMethod\nd.MyMethod(); // Calls Derived... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340546",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38807/"
] |
340,548 | <p>I'm writing some tests in Perl which have a fair amount of set up. This setup all lives in a module that the test scripts <code>use</code>. I want to be able to print some diagnostics from the module, and intended to use the <code>diag</code> function from <code>Test::More</code>. Problem is, when you <code>use Test::More</code>, it writes the plan so I get </p>
<blockquote>
<p>You tried to plan twice at lib/MyTest.pm line 15.</p>
</blockquote>
<p>Is there any way I can use <code>diag</code> (or is there an equivalent), or am I stuck with <code>print STDERR</code>?</p>
| [
{
"answer_id": 340554,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 5,
"selected": true,
"text": "Base b = new Derived();\nDerived d = new Derived();\nb.MyMethod(); // Calls Base.MyMethod\nd.MyMethod(); // Calls Derived... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340548",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6402/"
] |
340,553 | <p>What is the best way to send HTTP requests from Windows Powershell?</p>
| [
{
"answer_id": 340570,
"author": "Thomas Bratt",
"author_id": 15985,
"author_profile": "https://Stackoverflow.com/users/15985",
"pm_score": 6,
"selected": true,
"text": "$page = (New-Object System.Net.WebClient).DownloadString(\"http://localhost/\")\n"
},
{
"answer_id": 21857868,... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340553",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15985/"
] |
340,562 | <p>In Java (And in general) is there a way to make a class so public that it's methods etc... are accessible from little classes all around that don't even instantiate it? Ha, what I mean is... If I have a daddy class that has a method <code>draw()</code> and it instantiates a baby class called Hand and one called Deck, and then deck instantiates a babier class called Card that has a method <code>play()</code>, is there a way for <code>Play()</code> to then call <code>Draw()</code> from the daddy class?</p>
<p>The idea here is that... the daddy class says "Deck! play(card)!" and then deck says "Card! play()!" and then play turns around and says "Hey daddy! Draw()!"</p>
<p>PS the idea is that... in a CCG every card has a "play()" method that is different but they are all essentially called in the same way. The opportunity to play the card comes around, and you call play on it. But the card doesn't do anything internal to itself: no no, it calls a number of methods from the rules of the game, which is has visibility to. So, like, a card in MTG that says "draw one card. Deal one damage to target player." is calling draw(player, 1) and dealDamage(player, 1) which are presumably not in the card itself... since they effect variables presumably instantiated by the players when they started the game and agreed on life totals and rules such as what "draw" means?</p>
<p>(meta-question: as usual, could someone please rename this question so that it reflects what I am asking... being a beginner is so frustrating!)</p>
| [
{
"answer_id": 340590,
"author": "Bill the Lizard",
"author_id": 1288,
"author_profile": "https://Stackoverflow.com/users/1288",
"pm_score": 3,
"selected": true,
"text": "class Daddy {\n public foo(){...}\n public createBaby(){\n Baby baby = new Baby(this);\n // baby ... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340562",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29182/"
] |
340,568 | <p>I'm trying to find an zip compression and encryption component with <a href="http://www.networkworld.com/careers/2004/0315manonline.html" rel="noreferrer">encryption suitable for use by the US Federal Government</a>, so I can't use Zip 2.0 encryption, it has to be AES or the like. I've already found <a href="http://www.icsharpcode.net/OpenSource/SharpZipLib/" rel="noreferrer">SharpZipLib</a> (can't do AES encyrption), and <a href="http://www.chilkatsoft.com/downloads.asp" rel="noreferrer">Chilkat</a> (can do AES encryption, but costs money). Am I missing any other options?</p>
| [
{
"answer_id": 410446,
"author": "Cheeso",
"author_id": 48082,
"author_profile": "https://Stackoverflow.com/users/48082",
"pm_score": 5,
"selected": true,
"text": " using (ZipFile zip = new ZipFile())\n {\n zip.AddFile(\"ReadMe.txt\"); // no password for this entry\n\n // use a p... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340568",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33264/"
] |
340,608 | <p>So I was thinking about creating a dynamic sql question, meaning that i want the amount of parameters to be dynamic.</p>
<p>Having looked at this: <a href="https://stackoverflow.com/questions/337704/parameterizing-a-sql-in-clause#337725">Parameterize an SQL IN clause</a> i was thinking that using like '%x%' is SLOW and not good.</p>
<p>What i actually would like to do is using the IN keyword and have it somewhat like this:</p>
<p>select UserId from NameTable where Name IN (@List_of_names)</p>
<p>Where the @List_of_names could contain i.e. </p>
<ul>
<li>Filip Ekberg</li>
<li>Filip</li>
<li>Ekberg Filip</li>
<li>Ekberg</li>
<li>Johan Ekberg</li>
<li>Johan</li>
</ul>
<p>( my second name is johan, thats why it's in there ,) )</p>
<p>So all these should match up with Johan Filip Ekberg.</p>
<p>I want to be using either LINQ to SQL or LINQ to SQL ( Stored Procedure ) using C#.</p>
<p>Suggestions and thoughts please!</p>
<p>----------------- Clearification of scenario and tables -------------------------</p>
<p>Imagine i have the following: A table with Users, A table with Names and a Table that connects the Names to a certain user.</p>
<p>So by having</p>
<pre><code>[User Table]
User ID Full Name
1 Johan Filip Ekberg
2 Anders Ekberg
[Names]
Name ID Name
1 Filip
2 Ekberg
3 Johan
4 Anders
[Connect Names]
Name ID User ID
1 1
2 1
3 1
2 4
2 2
</code></pre>
<p>So if i want to look for: Ekberg</p>
<p>The return should be:</p>
<ul>
<li>Johan Filip Ekberg</li>
<li>Anders Ekberg</li>
</ul>
<p>If i want to search for Johan Ekberg</p>
<ul>
<li>Johan Filip Ekberg</li>
</ul>
<p>If i want to search for Anders</p>
<ul>
<li>Anders Ekberg</li>
</ul>
<p>The amount of "search names" can be infinite, if i have the name: Johan Anders Carl Filip Ekberg ( This is just 1 person with many names ) and i just pass "Carl Filip" in, i want to find that User.</p>
<p>Does this make everything clearer?</p>
| [
{
"answer_id": 340630,
"author": "Sergiu Damian",
"author_id": 41345,
"author_profile": "https://Stackoverflow.com/users/41345",
"pm_score": 1,
"selected": false,
"text": "SELECT UserId FROM NameTable WHERE CHARINDEX( '|' + Name + '|', '|Filip Ekberg|Filip|Ekberg Filip|') > 0\n"
},
{... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340608",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39106/"
] |
340,610 | <p>It is not possible to fire an event in C# that has no handlers attached to it. So before each call it is necessary to check if the event is null.</p>
<pre><code>if ( MyEvent != null ) {
MyEvent( param1, param2 );
}
</code></pre>
<p>I would like to keep my code as clean as possible and get rid of those null checks. I don't think it will affect performance very much, at least not in my case.</p>
<pre><code>MyEvent( param1, param2 );
</code></pre>
<p>Right now I solve this by adding an empty inline handler to each event manually. This is error prone, since I need to remember to do that etc.</p>
<pre><code>void Initialize() {
MyEvent += new MyEvent( (p1,p2) => { } );
}
</code></pre>
<p>Is there a way to generate empty handlers for all events of a given class automatically using reflection and some CLR magic?</p>
| [
{
"answer_id": 340618,
"author": "Dinah",
"author_id": 356,
"author_profile": "https://Stackoverflow.com/users/356",
"pm_score": 8,
"selected": true,
"text": "public delegate void MyClickHandler(object sender, string myValue);\npublic event MyClickHandler Click = delegate {}; // add empt... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340610",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35440/"
] |
340,622 | <p>Is there a shortcut key to bring up the call hierarchy of a method inline with the code, in the quick menu format, rather than bringing up the call hierarchy panel?</p>
| [
{
"answer_id": 49383362,
"author": "mani_drinks_coffee",
"author_id": 1315254,
"author_profile": "https://Stackoverflow.com/users/1315254",
"pm_score": 2,
"selected": false,
"text": "alt"
}
] | 2008/12/04 | [
"https://Stackoverflow.com/questions/340622",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42491/"
] |
340,623 | <p>I understand that programming to interfaces helps with loose coupling. However, is there a guideline that explains when its most effective?</p>
<p>For example, I have a simple web application that collects data on employees, their training plans, expenses and computes their expense for the year etc. This is a fairly simple application and I can of course use an interface but wonder if there would be any use. I will be using it for the sake of using it.</p>
<p>It can always be argued that as the application grows in complexity and I pass around objects it would make more sense to pass the type (interface) than an implementation. So, should I wait for the application to become complex or use it right away? I'm wondering the best practice might turn out to be "this guy is over doing things".</p>
| [
{
"answer_id": 340665,
"author": "terjetyl",
"author_id": 29519,
"author_profile": "https://Stackoverflow.com/users/29519",
"pm_score": 2,
"selected": false,
"text": "class SimpleClass\n{\n public int A { get; set; }\n public int B { get; set; }\n public int C { get; set; }\n}\n\nList... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340623",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40070/"
] |
340,627 | <p>I need to parse Visual Studio automatically generated XML documentation to create a report. I decided to use XSLT but I'm very new to it and need help.
Common template is:</p>
<pre><code><doc>
<members>
<member name="F:MyNamespace">
<summary>Some text</summary>
</member>
</members>
</doc>
</code></pre>
<p>I want to isolate members with name which begins on some word, for example, P:Interfaces.Core. I decided to use RegExp in select statement.</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fn="http://www.w3.org/TR/xpath-functions/">
<xsl:template match="/" >
<html xmlns="http://www.w3.org/1999/xhtml">
<body style="font-family:Tahoma">
<p>Interfaces list:</p>
<table>
<xsl:for-each select="doc/members/member">
<xsl:sort order="ascending" />
<xsl:value-of select="fn:matches(., 'P\..+')" />
<br />
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
</code></pre>
<p>Why does I'm getting error:</p>
<blockquote>
<p>Namespace <a href="http://www.w3.org/TR/xpath-functions" rel="nofollow noreferrer">http://www.w3.org/TR/xpath-functions</a> does not contain any functions ></p>
</blockquote>
<p>Where am I wrong? I found such code in examples, including w3c.org!</p>
| [
{
"answer_id": 340865,
"author": "Dimitre Novatchev",
"author_id": 36305,
"author_profile": "https://Stackoverflow.com/users/36305",
"pm_score": 4,
"selected": true,
"text": "XslCompiledTransform"
}
] | 2008/12/04 | [
"https://Stackoverflow.com/questions/340627",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41956/"
] |
340,645 | <p>Let's say I have a simple chunck of XML:-</p>
<pre><code><root>
<item forename="Fred" surname="Flintstone" />
<item forename="Barney" surname="Rubble" />
</root>
</code></pre>
<p>Having fetched this XML in Silverlight I would like to bind it with <a href="http://en.wikipedia.org/wiki/Extensible_Application_Markup_Language" rel="nofollow noreferrer">XAML</a> of this ilke:-</p>
<pre><code><ListBox x:Name="ItemList" Style="{StaticResource Items}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBox Text="{Binding Forename}" />
<TextBox Text="{Binding Surname}" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</code></pre>
<p>Now I can bind simply enough with LINQ to XML and a nominal class:-</p>
<pre><code>public class Person {
public string Forename {get; set;}
public string Surname {get; set;}
}
</code></pre>
<p>Can it be done without this class?</p>
<p>In other words, coupling between the Silverlight code and the input XML is limited to the XAML only, other source code is agnostic to the set of attributes on the item element.</p>
<p><strong>Edit</strong>: The use of XSD is suggested but ultimately it amounts the same thing. XSD->Generated class.</p>
<p><strong>Edit</strong>: An anonymous class doesn't work, Silverlight can't bind them.</p>
<p><strong>Edit</strong>: This needs to be two way, the user needs to be able to edit the values and these values end up in the XML. (Changed original TextBlock to TextBox in sample above.)</p>
| [
{
"answer_id": 341358,
"author": "Bryant",
"author_id": 10893,
"author_profile": "https://Stackoverflow.com/users/10893",
"pm_score": 2,
"selected": false,
"text": "public class XAttributeConverter : IValueConverter\n{\n public object Convert(object value, Type targetType, object para... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340645",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17516/"
] |
340,657 | <p>Is there a way to just tell the compiler, that I want my objects to be serializable by default?</p>
| [
{
"answer_id": 342178,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 3,
"selected": true,
"text": "[Serializable]"
}
] | 2008/12/04 | [
"https://Stackoverflow.com/questions/340657",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1220/"
] |
340,696 | <p>Does cygwin allow a statically compiled binary? This would prevent the need for cygwin1.dll being on the PATH of target machines.</p>
| [
{
"answer_id": 27370738,
"author": "chenwj",
"author_id": 577251,
"author_profile": "https://Stackoverflow.com/users/577251",
"pm_score": 4,
"selected": false,
"text": "-mno-cygwin"
},
{
"answer_id": 44076504,
"author": "Peter Schultz",
"author_id": 2480447,
"author_p... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340696",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5823/"
] |
340,708 | <p>I want to use jQuery with a GridView which contains textboxes, but I'm stuck on how to get event listeners registered for every textbox on the selected row. I was thinking I could do something with a StingBuilder in the Unload event of the GridView but I can't get it working.</p>
| [
{
"answer_id": 340795,
"author": "BigJump",
"author_id": 8542,
"author_profile": "https://Stackoverflow.com/users/8542",
"pm_score": 2,
"selected": true,
"text": "<asp:GridView runat=\"server\">\n <Columns>\n <asp:BoundField ControlStyle-CssClass=\"someclass\" DataField=\"xxx\" />\n ... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340708",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30512/"
] |
340,717 | <p>Seeing this: <a href="http://www.suckless.org/wiki.html" rel="nofollow noreferrer">http://www.suckless.org/wiki.html</a>. A wiki based on Mercurial. Are there any other non-code related use to version control? Is there any other projects that uses version control tools inside instead of programming their own specific solution?</p>
| [
{
"answer_id": 340731,
"author": "Joachim Sauer",
"author_id": 40342,
"author_profile": "https://Stackoverflow.com/users/40342",
"pm_score": 3,
"selected": false,
"text": "/etc"
},
{
"answer_id": 7585122,
"author": "Félix Saparelli",
"author_id": 231788,
"author_profi... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340717",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39057/"
] |
340,748 | <p>I was writing some code, and I notice a pattern in the exception handling that got me thinking:</p>
<pre><code>try{
// do stuff... throws JMS, Create and NamingException
} catch (NamingException e) {
log1(e);
rollback();
doSomething(e)
} catch (CreateException e) {
log1(e);
rollback();
doSomething(e)
}
</code></pre>
<p>Where JMSException would be handle some where up in the stack.</p>
<p>Would it be to just write:</p>
<pre><code>try{
// do stuff... throws JMS, Create and NamingException
} catch Exception[NamingException, CreateException] e) {
log1(e);
rollback();
doSomething(e)
}
</code></pre>
<p>instead of putting it in tu a helper method:</p>
<pre><code>try{
// do stuff... throws JMS, Create and NamingException
} catch (NamingException e) {
helper_handleError1(e)
} catch (CreateException e) {
helper_handleError1(e)
}
</code></pre>
<p>Notice that I want to propagate stacktrace of the original JMSException, and I don't "feel like" creating an new JMSException with a third catch clause :)</p>
<p>Any toughs? Is this an extreme situation that would only pollute the syntax of Java, or just a cool thing to add?</p>
| [
{
"answer_id": 340785,
"author": "defnull",
"author_id": 407880,
"author_profile": "https://Stackoverflow.com/users/407880",
"pm_score": 0,
"selected": false,
"text": "try {\n ...\n} catch ( Exception e) {\n if typeof(e) not in ('MyException', 'SpecialException') {\n throw e\n }\n ... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340748",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35323/"
] |
340,787 | <p>I have a XML with a structure similar to this:</p>
<pre><code><category>
<subCategoryList>
<category>
</category>
<category>
<!--and so on -->
</category>
</subCategoryList>
</category>
</code></pre>
<p>I have a Category class that has a <code>subcategory</code> list (<code>List<Category></code>). I'm trying to parse this XML file with XPath, but I can't get the child categories of a category. </p>
<p>How can I do this with XPath? Is there a better way to do this?</p>
| [
{
"answer_id": 340831,
"author": "sblundy",
"author_id": 4893,
"author_profile": "https://Stackoverflow.com/users/4893",
"pm_score": 2,
"selected": false,
"text": "//category/subCategoryList/category"
},
{
"answer_id": 340832,
"author": "kgiannakakis",
"author_id": 24054,... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340787",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/314728/"
] |
340,790 | <p>I have the following problem: Multithreaded WPF application, Model View Presenter Implementation. Presenters and Views that belong together are created on a separate thread and get a separate Dispatcher. Now someone calls from another thread a method on the Presenter. I am intercepting the call, and now begins the problem: if the call comes from the same thread as the presenter, i want to proceed with the call, else invoke the call on the Dispatcherthread, so that i don't need to care about UI calls.
I have already read about the use of SynchronizationContext, but that doesnt seem to work for me because if the calling thread is no UI thread i can't compare the 2 contexts. Whats a possible, working and elegant solution ?</p>
| [
{
"answer_id": 340968,
"author": "jyoung",
"author_id": 14841,
"author_profile": "https://Stackoverflow.com/users/14841",
"pm_score": 2,
"selected": false,
"text": "if( presenterDispatcherObject.CheckAccess() )\n Doit();\nelse\n presenterDispatcherObject.BeginInvoke( DispatcherPriorit... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340790",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
340,816 | <p>How can I send keyboard input messages to either the currently selected window or the previously selected window? </p>
<p>I have a program which I use to type some characters which are not present on my keyboard and I would like it if I could just send the input directly rather than me having to copy and paste all the time.</p>
<p>EDIT:</p>
<p>The application of this is typing the German Umlauts. I'm an American and I work in Germany. I'm working on an American keyboard and from time to time I have to type in the umlauts / the euro symbol / the sharp S. Currently I have a simple WinForms application with a textfield and some buttons with the extra characters on it. I type into the textfield and I can press the buttons to append text to the textfield. I then copy the text and paste it where ever. What would be nice though if I could just just hit one of the buttons and it would send the text where ever I'm typing / was typing. The current program works fairly well but I could make it better.</p>
| [
{
"answer_id": 340883,
"author": "Patrick Desjardins",
"author_id": 13913,
"author_profile": "https://Stackoverflow.com/users/13913",
"pm_score": 0,
"selected": false,
"text": "myField.Text += \"®\"; //This is a char that I do not have on my keyboard\n"
}
] | 2008/12/04 | [
"https://Stackoverflow.com/questions/340816",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26566/"
] |
340,827 | <p>I am attempting to mock a call to an indexed property. I.e. I would like to moq the following:</p>
<pre><code>object result = myDictionaryCollection["SomeKeyValue"];
</code></pre>
<p>and also the setter value</p>
<pre><code>myDictionaryCollection["SomeKeyValue"] = myNewValue;
</code></pre>
<p>I am doing this because I need to mock the functionality of a class my app uses. </p>
<p>Does anyone know how to do this with MOQ? I've tried variations on the following:</p>
<pre><code>Dictionary<string, object> MyContainer = new Dictionary<string, object>();
mock.ExpectGet<object>( p => p[It.IsAny<string>()]).Returns(MyContainer[(string s)]);
</code></pre>
<p>But that doesn't compile.</p>
<p>Is what I am trying to achieve possible with MOQ, does anyone have any examples of how I can do this?</p>
| [
{
"answer_id": 359123,
"author": "Mike Scott",
"author_id": 43649,
"author_profile": "https://Stackoverflow.com/users/43649",
"pm_score": 7,
"selected": false,
"text": "MyContainer[(string s)]"
},
{
"answer_id": 861282,
"author": "wasker",
"author_id": 21952,
"author_... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340827",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31128/"
] |
340,842 | <p>This works:</p>
<pre><code>constructor TMyObj.Create;
begin
inherited;
end;
</code></pre>
<p>Why this is not working also?</p>
<pre><code>function TMyObjEx.Import(CONST FileName: string; CONST x, y, z: Integer): string;
begin
result:= inherited; // Import(FileName, x, y, z); <--- Compiler says: "incompatible types"
//do other stuff here
end;
</code></pre>
<p>Declaration of TMyObjEx is like this:</p>
<pre><code>TYPE
TMyObj = class(TChObj)
private
protected
public
function Import (CONST FileName: string; CONST x, y, z: Integer): string; virtual;
end;
TMyObjEx= class(TMyObj)
private
protected
public
function Import(CONST FileName: string; CONST x, y, z: Integer): string; override;
end;
</code></pre>
| [
{
"answer_id": 340893,
"author": "Rob Kennedy",
"author_id": 33732,
"author_profile": "https://Stackoverflow.com/users/33732",
"pm_score": 1,
"selected": false,
"text": "inherited"
},
{
"answer_id": 342063,
"author": "Nick Hodges",
"author_id": 2044,
"author_profile":... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340842",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
340,850 | <blockquote>
<p><code>dict</code> methods <code>dict.keys()</code>, <code>dict.items()</code> and <code>dict.values()</code>
return “views” instead of lists.</p>
</blockquote>
<p><a href="https://docs.python.org/3/whatsnew/3.0.html#views-and-iterators-instead-of-lists" rel="nofollow noreferrer">Source</a></p>
<p>First of all, how is a view different from an iterator? Secondly, what is the benefit of this change? Is it just for performance reasons?</p>
<p>It doesn't seem intuitive to me, i.e., I'm asking for a list of things (give me all your keys) and I'm getting something else back. Will this confuse people?</p>
| [
{
"answer_id": 9023627,
"author": "max",
"author_id": 336527,
"author_profile": "https://Stackoverflow.com/users/336527",
"pm_score": 3,
"selected": false,
"text": "list"
},
{
"answer_id": 26553373,
"author": "Antony Hatchkins",
"author_id": 237105,
"author_profile": ... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340850",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13009/"
] |
340,878 | <p>I'm having trouble setting up a scheduled task (now called Task Scheduler) under the actions tab to run on windows 2007 server. It also has exchange server 2007. </p>
<p>I've tried setting </p>
<p>Program/script : C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Add arguments (optional): -psconsolefile exshell.psc1 -command "& {c:\mes-detail\emsbilling08.ps1}"
Start in (optional): "C:\Program Files\Microsoft\Exchange Server\Bin\</p>
<p>I realize the exshell.psc1 probably also needs an explicit path so I've also tried:</p>
<p>-psconsolefile C:\Program Files\Microsoft\Exchange Server\Bin\exshell.psc1 -command "& {c:\mes-detail\mailall3.ps1}" as well but that doesn't work either</p>
<p>Any ideas? </p>
| [
{
"answer_id": 33798161,
"author": "uz-it",
"author_id": 3382897,
"author_profile": "https://Stackoverflow.com/users/3382897",
"pm_score": 0,
"selected": false,
"text": "Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin\nAdd-PSSnapin Microsoft.Exchange.Management.PowerShell.Sup... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340878",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18853/"
] |
340,888 | <p>I've just done my first little webapp in django and I love it. I'm about to start on converting an old production PHP site into django and as part its template, there is a navigation bar.</p>
<p>In PHP, I check each nav option's URL against the current URL, in the template code and apply a CSS class if they line up. It's horrendously messy.</p>
<p>Is there something better for django or a good way of handling the code in the template?</p>
<p>To start, how would I go about getting the current URL?</p>
| [
{
"answer_id": 341713,
"author": "Michael Warkentin",
"author_id": 422277,
"author_profile": "https://Stackoverflow.com/users/422277",
"pm_score": 3,
"selected": false,
"text": "<body class=\"{{ nav_class }}\">\n"
},
{
"answer_id": 341748,
"author": "jpwatts",
"author_id"... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340888",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12870/"
] |
340,911 | <p>Are there any VS.NET plugins that will format a selection of code for printing or emailing and is also free?</p>
| [
{
"answer_id": 341079,
"author": "Stein G. Strindhaug",
"author_id": 26115,
"author_profile": "https://Stackoverflow.com/users/26115",
"pm_score": 0,
"selected": false,
"text": "monospaced"
},
{
"answer_id": 341576,
"author": "configurator",
"author_id": 9536,
"author... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340911",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40106/"
] |
340,915 | <p>I have form that displays several keywords (standard set of choice lists that changes rarely). There are about 4 such fields and each have about 20 choices or so.</p>
<p>I'm thinking if caching the keywords will be helpful for performance / best practice? Is there a strategy for determining when to cache?</p>
| [
{
"answer_id": 341125,
"author": "user35559",
"author_id": 35559,
"author_profile": "https://Stackoverflow.com/users/35559",
"pm_score": 0,
"selected": false,
"text": "\"IDictionary<string, IList<string>\"\n"
},
{
"answer_id": 341151,
"author": "Shawn",
"author_id": 26,
... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340915",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40070/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.