qid int64 4 22.2M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
348,320 | <p>Here's the deal. I have a big class hierarchy and I have this one method that is extended all the way through. The method always has to look at one or two more variable at each new level and these variable depend on the actual class in the hierarchy. What I want to do is check those two extra variables then call the superclass's version of that same function. I want to be able to define this function as all it's immediate children will use it, but I want to force any children of that class to have to redefine that method (because they will have to look at their new data members)</p>
<p>So how would I write this? I usually use =0; in the .h file, but I assume I can't use that and define it...</p>
| [
{
"answer_id": 348452,
"author": "jmucchiello",
"author_id": 44065,
"author_profile": "https://Stackoverflow.com/users/44065",
"pm_score": 0,
"selected": false,
"text": "// this could be loaded from a file potentially\n// notice that the keys have been sorted.\nconst char* keys[] = { \"1... | 2008/12/07 | [
"https://Stackoverflow.com/questions/348320",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39189/"
] |
348,321 | <p>I'm going to make a space/trading/combat game that is completely procedurally generated. But, I know that storing all of the details of the whole galaxy in memory is unfeasable. As a result, I've been think that I can use a seed to generate a solar system, and from that solar system, you can use jumpgates to travel to other solar systems. The problem is that if I jump to another solar system from the starting one, I need to be able to get back to the exact same starting solar system with the exact the same features (planets, asteroids, etc.).</p>
<p>Essentially, I need to be able to generate a whole galaxy from one number. And from that one number, which generates one solar system, I need to be able to generate all of the other solar systems that link from the first one and all of the solar systems that link from those, and so on. And each solar system has to stay exactly the same feature-wise, if I return to them. Also, the number of links from each solar system can be either random, or fixed, your choice. Random would be better though.</p>
| [
{
"answer_id": 348486,
"author": "Darius Bacon",
"author_id": 27024,
"author_profile": "https://Stackoverflow.com/users/27024",
"pm_score": 3,
"selected": false,
"text": "nplanets"
},
{
"answer_id": 5488469,
"author": "Tom Gullen",
"author_id": 356635,
"author_profile... | 2008/12/07 | [
"https://Stackoverflow.com/questions/348321",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27677/"
] |
348,328 | <p>I recently upgraded to Eclipse Ganymede from Europa and now I'm finding that when I'm editing JSP files the IDE crawls when editing HTML attributes (but not JSP attributes).</p>
<p>Has anyone experienced this, or have any suggestions?</p>
<p>Also if you can point me to a better place to ask Eclipse related questions, do tell.</p>
<p>Thanks!</p>
| [
{
"answer_id": 6994301,
"author": "Ben Barkay",
"author_id": 885681,
"author_profile": "https://Stackoverflow.com/users/885681",
"pm_score": 3,
"selected": false,
"text": "attribute_name=\"\""
},
{
"answer_id": 38842103,
"author": "Flavio",
"author_id": 6693818,
"auth... | 2008/12/07 | [
"https://Stackoverflow.com/questions/348328",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34859/"
] |
348,342 | <p>I'm currently trying to read text from a file and append it to a element in my html page using the DOM and Javascript. I can't get the text to format though. I've tried using innerHtml but isn't formating at all( no line breaks ).</p>
<p>Here is the javascript:</p>
<pre><code>http = new XMLHttpRequest();
http.open("GET",FILE,false);
http.send();
document.getElementById("tbody").innerHTML = http.responseText
</code></pre>
<p>Like I said the text gets added to the tbody element but isn't formatted what so ever.</p>
<hr>
<p>I got it working with this code( with the pre tag ), but like I said it works on my pc but not on the server which doesn't help.</p>
<pre><code> http.open("GET",FILE ,false);
http.send();
var newtext = document.createTextNode(http.responseText);
var para = document.getElementById("tbody");
para.appendChild(newtext);
</code></pre>
<hr>
<p>Here is all my javascript code:</p>
<p>function getHTTPObject()
{
var http = false;</p>
<pre><code>/*@cc_on
@if (@_jscript_version >= 5)
try
{
http = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
http = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (E)
{
http = false;
}
}
@else
{
http = false;
}
@end @*/
if (!http && typeof XMLHttpRequest != 'undefined')
{
try
{
http = new XMLHttpRequest();
}
catch (e)
{
http = false;
}
}
return http
</code></pre>
<p>}</p>
<pre><code> function loadData()
{
http = getHTTPObject();
if (http)
{
http.open("GET","my file name",false);
http.send();
var newtext = document.createTextNode(http.responseText);
var para = document.getElementById("tbody");
para.appendChild(newtext);
}
}
</code></pre>
| [
{
"answer_id": 348343,
"author": "sblundy",
"author_id": 4893,
"author_profile": "https://Stackoverflow.com/users/4893",
"pm_score": 1,
"selected": false,
"text": "<pre>"
},
{
"answer_id": 348349,
"author": "olliej",
"author_id": 784,
"author_profile": "https://Stacko... | 2008/12/07 | [
"https://Stackoverflow.com/questions/348342",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44160/"
] |
348,363 | <p>I'm writing an application that allows users to upload images onto the server. I expect about 20 images per day all jpeg and probably not edited/resized. (This is another question, how to resize the images on the server side before storing. Maybe someone can please drop a .NET resource for that in the comment or so).
I wonder now what the best place for storing uploaded images is.</p>
<ul>
<li><p>Store the images as a file in the file system and create a record in a table with the exact path to that image.</p></li>
<li><p>Or, store the image itself in a table using an "image" or "binary data" data type of the database server.</p></li>
</ul>
<p>I see advantages and disadvantages in both.
I like a) because I can easily relocate the files and just have to change the table entry. On the other hand I don't like storing business data on the web server and I don't really want to connect the web server to any other datasource that holds business data (for security reasons)
I like b) because all the information is in one place and easily accessible by a query. On the other hand the database will get very big very soon. Outsourcing that data could be more difficult.</p>
| [
{
"answer_id": 38105092,
"author": "Uday Hiwarale",
"author_id": 2790983,
"author_profile": "https://Stackoverflow.com/users/2790983",
"pm_score": 3,
"selected": false,
"text": "id"
}
] | 2008/12/07 | [
"https://Stackoverflow.com/questions/348363",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14027/"
] |
348,371 | <p>I've got MS Access database with linked tables, whenever each table is linked to a table in the same SQL Server database. I have a query inside Access that joins two tables (in particular I'm updating a table based on another using a join).</p>
<p>The question is does Access "download" all the table data before doing a join? Or is smart and joining it on the SQL Server?</p>
<p>The query is:</p>
<pre><code>UPDATE TBL_INVOICE_CHARGES INNER JOIN TBL_ANI
ON (TBL_INVOICE_CHARGES.CH_CUST_ID = TBL_ANI.ANI_CUST_ID)
AND (TBL_INVOICE_CHARGES.CH_ANI = TBL_ANI.ANI_NZ_ANI)
SET TBL_INVOICE_CHARGES.ANI_NOTES = TBL_ANI.ANI_NOTES;
</code></pre>
| [
{
"answer_id": 348439,
"author": "David-W-Fenton",
"author_id": 9787,
"author_profile": "https://Stackoverflow.com/users/9787",
"pm_score": 2,
"selected": false,
"text": " WHERE Format(MyDate,\"YYYY\") = 2008\n"
}
] | 2008/12/08 | [
"https://Stackoverflow.com/questions/348371",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10793/"
] |
348,392 | <p>How can I receive and send email in python? A 'mail server' of sorts.</p>
<p>I am looking into making an app that listens to see if it receives an email addressed to foo@bar.domain.com, and sends an email to the sender.</p>
<p>Now, am I able to do this all in python, would it be best to use 3rd party libraries? </p>
| [
{
"answer_id": 348551,
"author": "Manuel Ceron",
"author_id": 23657,
"author_profile": "https://Stackoverflow.com/users/23657",
"pm_score": 6,
"selected": true,
"text": "import smtplib\n\nserver = 'mail.server.com'\nuser = ''\npassword = ''\n\nrecipients = ['user@mail.com', 'other@mail.c... | 2008/12/08 | [
"https://Stackoverflow.com/questions/348392",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2592/"
] |
348,408 | <p>I'm a little new to the Java 5 annotations and I'm curious if either of these are possible:</p>
<p>This annotation would generate a simple getter and setter for you.</p>
<pre><code>@attribute
private String var = "";
</code></pre>
<p>The <code>@NotNull</code> annotation indicates that a variable connot be null so you don't have to write that boilerplate code every time.</p>
<pre><code>/*
* @param s @NotNull
*/
public void setString(String s){
...
}
</code></pre>
<p>Will either of these work? They seem like the first things I would write annotations for if I could. Since I don't see much about these when I read the docs I'm assuming that it's not really what annotations are about. Any direction here would be appreciated.</p>
| [
{
"answer_id": 349104,
"author": "jamesh",
"author_id": 4737,
"author_profile": "https://Stackoverflow.com/users/4737",
"pm_score": 5,
"selected": true,
"text": "@NonNull"
},
{
"answer_id": 681825,
"author": "Scott Stanchfield",
"author_id": 12541,
"author_profile": "... | 2008/12/08 | [
"https://Stackoverflow.com/questions/348408",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42994/"
] |
348,410 | <p>Is it possible in PHP to do something like this? How would you go about writing a function? Here is an example. The order is the most important thing.</p>
<pre><code>$customer['address'] = '123 fake st';
$customer['name'] = 'Tim';
$customer['dob'] = '12/08/1986';
$customer['dontSortMe'] = 'this value doesnt need to be sorted';
</code></pre>
<p>And I'd like to do something like </p>
<pre><code>$properOrderedArray = sortArrayByArray($customer, array('name', 'dob', 'address'));
</code></pre>
<p>Because at the end I use a foreach() and they're not in the right order (because I append the values to a string which needs to be in the correct order and I don't know in advance all of the array keys/values).</p>
<p>I've looked through PHP's internal array functions but it seems you can only sort alphabetically or numerically. </p>
| [
{
"answer_id": 348418,
"author": "Eran Galperin",
"author_id": 10585,
"author_profile": "https://Stackoverflow.com/users/10585",
"pm_score": 7,
"selected": false,
"text": "function sortArrayByArray(array $array, array $orderArray) {\n $ordered = array();\n foreach ($orderArray as $... | 2008/12/08 | [
"https://Stackoverflow.com/questions/348410",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31671/"
] |
348,417 | <p>Some time ago I wrote a piece of code to update multiple rows in a database table. The code was like this</p>
<pre><code>var db = new MyDataContext();
db.Execute("UPDATE Details SET IsActive = 0 WHERE MasterId = 1");
</code></pre>
<p>Then the other day when I got the latest version of the file I saw that somebody changed the code to something like this</p>
<pre><code>var details = from d in db.details where d.MasterId == 1 select d;
foreach (var detail in details)
detail.IsActive = false;
db.SubmitChanges();
</code></pre>
<p>So my question is: What is the better way to update multiple rows? Using Linq or SQL?</p>
| [
{
"answer_id": 1718317,
"author": "Shannon Davidson",
"author_id": 103596,
"author_profile": "https://Stackoverflow.com/users/103596",
"pm_score": 2,
"selected": false,
"text": "context.Task.Update(t => t.Id == 1, t2 => new Task {StatusId = 2});\n"
},
{
"answer_id": 3355796,
... | 2008/12/08 | [
"https://Stackoverflow.com/questions/348417",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24293/"
] |
348,419 | <p>I have a sorted list that contains the column headers, how do I rearrange my datagridview so it is in the same order as my sorted list?</p>
<p>I've tried the code below but this doesn't always work, some columns are not sorted correctly. Thanks for any help with this.</p>
<pre><code>sortedColumnNames.Sort();
foreach (DataGridViewColumn col in dataGridView1.Columns)
{
col.DisplayIndex = sortedColumnNames.IndexOf(col.HeaderText);
}
</code></pre>
<p>sortedColumnNames:
athens
crete
corfu
kefalonia
mykonos
rhodes
santorini
skiathos
zante</p>
| [
{
"answer_id": 348474,
"author": "Robert Rossney",
"author_id": 19403,
"author_profile": "https://Stackoverflow.com/users/19403",
"pm_score": 3,
"selected": false,
"text": "SortedColumnNames"
}
] | 2008/12/08 | [
"https://Stackoverflow.com/questions/348419",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
348,421 | <p>I am having problems running my Junit tests via Ant. I can't seem to get Ant to see the properties file it needs to load a dll my project needs. All my tests work using the Junit GUI in Elcipse, so I'm pretty sure it's not a problem with the tests themselves. I think my problem is something classpath-related, but I can't seem to find the problem.</p>
<p>jar strucure:
/root/folder/../Foo.properties</p>
<h2>This is how the properties file is loaded in the library:</h2>
<pre><code>// load class properties
props = PropertyLoader.loadProperties(Foo.class);
public static Properties loadProperties(Class className) {
return loadProperties(className.getName());
}
public static Properties loadProperties(final String propsName) {
Properties props = null;
InputStream in = null;
try {
ClassLoader cl = ClassLoader.getSystemClassLoader();
String name = propsName.replace('.', '/').concat(".properties");
in = cl.getResourceAsStream(name);
if (in != null) {
props = new Properties();
props.load(in);
}
}
catch (Exception e) {
props = null;
}
finally {
if (props == null) {
System.err.print("Property file " + propsName + " doesn't exist. System terminated.");
System.exit(0);
}
}
return props;
}
</code></pre>
<h2>Except from build file in question:</h2>
<pre><code><!-- Pattern of source files to copy into classpath-->
<property name="source.files.tocopy"
value="**/*.properties,**/*.dtd,**/*.xml,**/*.jpg" />
<path id="compile.classpath">
<fileset dir="lib">
<include name="*.jar" />
</fileset>
</path>
<!-- Generate Class-Path entry for the JAR's Manifest -->
<pathconvert property="manifest.classpath"
pathsep=" " dirsep="\">
<map from="${basedir}/" to="" />
<fileset dir="lib">
<include name="*.jar" />
</fileset>
</pathconvert>
<!-- Run tests against the JAR -->
<path id="test.compile.classpath">
<path refid="compile.classpath" />
<pathelement location="${target.jar}" />
</path>
<path id="test.classpath">
<path refid="test.compile.classpath" />
<pathelement location="${test.classes.dir}" />
</path>
<!-- - - - - - - - - - - - - - - - - -
target: test-compile
- - - - - - - - - - - - - - - - - -->
<target name="test-compile" depends="compile, test-init"
description="Compiles our testing code">
<javac destdir="${test.classes.dir}"
debug="true"
includeAntRuntime="true"
srcdir="test">
<classpath refid="test.compile.classpath" />
</javac>
<copy todir="${test.classes.dir}">
<fileset dir="test" includes="${source.files.tocopy}"/>
<fileset dir="resources" includes="${source.files.tocopy}"/>
</copy>
</target>
<!-- =================================
target: test
================================= -->
<target name="test" depends="test-compile, optional-tests">
<description>
Runs our tests, generates reports, and stops
the build on failure. Optionally runs one test.
</description>
<junit printsummary="false"
errorProperty="test.failed"
failureProperty="test.failed">
<classpath>
<path refid="test.classpath" />
</classpath>
<sysproperty key="test.properties" value="${test.properties.file}"/>
<formatter type="brief" usefile="false" />
<formatter type="xml" />
<test name="${testcase}" todir="${test.data.dir}" if="testcase" />
<batchtest todir="${test.data.dir}" unless="testcase">
<fileset dir="${test.classes.dir}">
<patternset>
<include name="**/test/*Test.class" />
<exclude name="**/test/*Printer*.class" unless="test.properties.file" />
</patternset>
</fileset>
</batchtest>
</junit>
</code></pre>
<p>I could really use a second set of eyes, so any help is appreciated. Thanks in advance!</p>
<p>--Charly</p>
| [
{
"answer_id": 349029,
"author": "Staale",
"author_id": 3355,
"author_profile": "https://Stackoverflow.com/users/3355",
"pm_score": 2,
"selected": false,
"text": "clazz.getResource(clazz.getName()+\".class\")\n"
},
{
"answer_id": 349825,
"author": "Ken Gentle",
"author_id... | 2008/12/08 | [
"https://Stackoverflow.com/questions/348421",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
348,428 | <p>I've been trying with limited success to export a crosstab query result set to Excel using Access 2003. Occasionally, the export works correctly, and Excel shows with no errors. Other times, using the exact same query parameters, I get a 3190 error - too many fields. I am using the TransferSpreadsheet option in a macro that is called from VB code.</p>
<p>The macro has the following parameters:
Transfer type: Export
Spreadsheet type: Microsoft Excel 8-10
Table Name: (this is my query name)
File Name: (Excel output file, which exists in the directory)
Has Field Names: Yes</p>
<p>The query should not produce any more than 14 columns worth of information, so the Excel 255 col limit should not be a problem. Also,the data in the database is not changing during the time I am querying, so the same query will produce the same result set.</p>
<p>One of the only solutions I have read on the net thus far is to close the recordset before running the macro, but this is hit or miss.</p>
<p>Your thoughts/help are greatly appreciated!</p>
| [
{
"answer_id": 356492,
"author": "Jon Wilson",
"author_id": 27876,
"author_profile": "https://Stackoverflow.com/users/27876",
"pm_score": 0,
"selected": false,
"text": "DoCmd.SetWarnings False\n DoCmd.OpenQuery \"TempTable-Make\" \n DoCmd.RunSQL \"DROP TABLE TempTable\" \n ExportToExcel(... | 2008/12/08 | [
"https://Stackoverflow.com/questions/348428",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
348,440 | <p>Is there an easy way to move around controls on a form exactly the same way as the tab key? This includes moving around cells on a datagridview etc.</p>
| [
{
"answer_id": 348492,
"author": "Marioh",
"author_id": 24293,
"author_profile": "https://Stackoverflow.com/users/24293",
"pm_score": 3,
"selected": true,
"text": "private void Form1_KeyPress(object sender, KeyPressEventArgs e)\n{\n if (e.KeyChar == 13)\n GetNextControl(ActiveCo... | 2008/12/08 | [
"https://Stackoverflow.com/questions/348440",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29823/"
] |
348,465 | <p>I have the following code that I need to run over a matrix with over 20000 rows. It takes several minutes to run and the datenum and str2double functions appear to be the bottlenecks. Since no calculation depends on previous ones is there a way to break the loop into multiple parts and have them execute in parallel? Any advice on optimising this code would be appreciated.</p>
<pre>
for i=1:length(DJI)
DJI2(i,1)=datenum(char(DJI(i,2)),'yyyy-mm-dd');
for j=3:7
DJI2(i,j-1)=str2double(char(DJI(i,j)));
end
end
</pre>
| [
{
"answer_id": 471420,
"author": "Jason S",
"author_id": 44330,
"author_profile": "https://Stackoverflow.com/users/44330",
"pm_score": 2,
"selected": true,
"text": "octave-3.0.3.exe:15> s=sprintf('1 2\\n3 4');\noctave-3.0.3.exe:16> m=str2double(s)\nm =\n\n 1 2\n 3 4\n\n\noctave-3... | 2008/12/08 | [
"https://Stackoverflow.com/questions/348465",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14744/"
] |
348,469 | <p>While the J2EE module reference feature allows your to create common Java library projects, I can't find a neat way to do this for web content.</p>
<p>I have common JSPs, CSS files, JavaScript libraries and even descriptor fragments that I would like to use across a number of Dynamic Web Projects, so that these artefacts are edited i only one place, but will be exported into each of the Dynamic WebProject WAR files.</p>
<p>I am surprised that I can't find a way to promote reusability in the web space without writing my own scripts and hooking into the export process.</p>
<p>Is there a way to do this?
Thanks.
Matt.</p>
| [
{
"answer_id": 366802,
"author": "Paul Fisher",
"author_id": 39808,
"author_profile": "https://Stackoverflow.com/users/39808",
"pm_score": 2,
"selected": false,
"text": "svn up"
},
{
"answer_id": 15404702,
"author": "JZ.Hunt",
"author_id": 1273270,
"author_profile": "... | 2008/12/08 | [
"https://Stackoverflow.com/questions/348469",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
348,491 | <p>I have a code igniter project, and I wanted to try debugging it using Zend Studio. WHen I start debugging, I immediately run ino</p>
<p>"The URI you submitted has disallowed characters."</p>
<p>Does anyone have any idea?</p>
| [
{
"answer_id": 348548,
"author": "Cody Caughlan",
"author_id": 25398,
"author_profile": "https://Stackoverflow.com/users/25398",
"pm_score": 5,
"selected": false,
"text": "$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\\-';\n"
},
{
"answer_id": 17566966,
"author": "Stelian",
... | 2008/12/08 | [
"https://Stackoverflow.com/questions/348491",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
348,502 | <p>I have created an application that writes some data to the root folder of the directory in which it was installed (in Program Files). But under Windows Vista, the program is unable to write to the directory because the UAC restricts administrative privileges.</p>
<p>I need to be able to do the following</p>
<ol>
<li>Write a file in the folder where the program was installed in program files.</li>
</ol>
<p>That's possible if the software is run with administrative privileges. But I don't know how to modify my setup to always run it with administrative privileges.</p>
<p>Are there any ways or suggestions I can accomplish this?</p>
| [
{
"answer_id": 348549,
"author": "flipdoubt",
"author_id": 470,
"author_profile": "https://Stackoverflow.com/users/470",
"pm_score": 2,
"selected": true,
"text": "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestversion=\"1.0\">\n<assemblyidentity version=\"1.0.0.0\" processo... | 2008/12/08 | [
"https://Stackoverflow.com/questions/348502",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33052/"
] |
348,530 | <p>I have an asp:DropDownList on a page that, due to the 1024x768 development standard can truncate some of the text values in the dropdown (not enough of them, apparently, to redesign the layout ), so I need to display a tooltip of the selected value <em>when</em> a dropdown item is being selected (i.e. when the dropdown is shown and an item is being hovered over), preferably only when the text for that item is being truncated.</p>
<p>Is this possible by default, javascript hacking or only my imagination?</p>
| [
{
"answer_id": 348668,
"author": "BenAlabaster",
"author_id": 40650,
"author_profile": "https://Stackoverflow.com/users/40650",
"pm_score": 0,
"selected": false,
"text": "<asp:DropDownList id=\"ddl1\" runat=\"server\">\n <asp:ListItem Text=\"Display text\" Value=\"1\" Title=\"This is my... | 2008/12/08 | [
"https://Stackoverflow.com/questions/348530",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5302/"
] |
348,533 | <p>I am trying to make a graph in java that would have different nodes. some nodes would be connected to others and some wont. If they are connected then some boolean value for that node will be true and another variable will hold the value of the node it is connected to. </p>
<p>...any suggestions on what you guys think is the best way to approach this?</p>
| [
{
"answer_id": 348543,
"author": "Tom",
"author_id": 20,
"author_profile": "https://Stackoverflow.com/users/20",
"pm_score": 1,
"selected": false,
"text": "Node"
}
] | 2008/12/08 | [
"https://Stackoverflow.com/questions/348533",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41685/"
] |
348,562 | <p>I have a messy function that needs refactoring, it has too many nested IF's and it makes me nervous just to look at it!</p>
<p><b>Please ignore what the functions are doing, I'm more concerned with the structure/flow and how it can be refactored so it has less nested IF statements</b></p>
<p>The basic flow is as follows:</p>
<pre><code>public static void HandleUploadedFile(string filename)
{
try
{
if(IsValidFileFormat(filename)
{
int folderID = GetFolderIDFromFilename(filename);
if(folderID > 0)
{
if(HasNoViruses(filename)
{
if(VerifyFileSize(filename)
{
// file is OK
MoveToSafeFolder(filename);
}
else
{
DeleteFile(filename);
}
}
else
{
DeleteFile(filename);
}
}
else
{
DeleteFile(filename);
}
}
else
{
DeleteFile(filename);
}
}
catch (Exception ex)
{
}
finally
{
// do some things
}
}
</code></pre>
| [
{
"answer_id": 348575,
"author": "Andrew Kennan",
"author_id": 22506,
"author_profile": "https://Stackoverflow.com/users/22506",
"pm_score": 3,
"selected": false,
"text": " private static bool CanMoveToSafeFolder(string filename)\n {\n return IsValidFileFormat(filename)\n ... | 2008/12/08 | [
"https://Stackoverflow.com/questions/348562",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
348,573 | <p>I was wondering what people thought about the decision to support Entity Framework over LINQ-to-SQL? I have an application I'm developing originally in LINQ-to-SQL. I found it the perfect solution for our application. </p>
<p>While attempting to port to Entity Framework I was surprised how rough it was. IMHO, not even close to being ready for prime time. No lazy loading, no POCOs, horrible dependency on inheritance. I found it largely unusable in my case and instead decided to stick with LINQ-to-SQL until somehow this Entity Framework can get more polished.</p>
<p>Anyone else have similar experience with it?</p>
| [
{
"answer_id": 348694,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 3,
"selected": true,
"text": "Expression.Invoke"
}
] | 2008/12/08 | [
"https://Stackoverflow.com/questions/348573",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37591/"
] |
348,576 | <p>I'm using QUnit to test some JQuery, and I've got Watin to load up the test page and parse out the test results, but I'm wondering if there's a way to dynamically generate the tests from the page using the MS Test suite rather than having to write a Test function for each test?</p>
<p>I'm just trying to reduce the amount of code having to be written</p>
| [
{
"answer_id": 348694,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 3,
"selected": true,
"text": "Expression.Invoke"
}
] | 2008/12/08 | [
"https://Stackoverflow.com/questions/348576",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2975/"
] |
348,582 | <p>We use Log4j (and Commons Logging) to log our error messages. Now we want to set up an additional log appender that outputs fatal errors to syslog, but without the exceptionally long Java stacktraces (those will still be available in the full log file).</p>
<p>How would one configure this (using log4j.xml)? Is there a filter available to ignore the stack traces?</p>
| [
{
"answer_id": 1788778,
"author": "Totach",
"author_id": 209622,
"author_profile": "https://Stackoverflow.com/users/209622",
"pm_score": 4,
"selected": false,
"text": "import org.apache.log4j.PatternLayout;\n\npublic class NoStackTracePatterLayout extends PatternLayout {\n\n @Override\n ... | 2008/12/08 | [
"https://Stackoverflow.com/questions/348582",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14955/"
] |
348,586 | <p>After installing the F# September CTP (1.9.6.2), Visual Studio 2008 frequently gives an error "Microsoft Visual C# IntelliSense has stopped working" which promptly crashes all of Visual Studio. I tried the tips mentioned in a <a href="https://stackoverflow.com/questions/178846/visual-studio-intellisense-stopped-working">similar SO article</a> such as "devenv.exe /ResetSettings", deleting the ncb file (which actually didn't exist), and installing the latest service pack (SP1) but no luck. Also tried reinstalling F#, nothing. This specifically happens in a C# unit test project that references my F# project and when I start to type things like [TestMethod] or "= new Tuple<List<int>,int,int> { Item1 = ". That's why I'm guessing it's related to F#. Incidentally I have ReSharper installed but disabled. Anyway, wondering if anyone else has had this problem and/or solved it. Otherwise any thoughts/ideas would be much appreciated.</p>
| [
{
"answer_id": 1788778,
"author": "Totach",
"author_id": 209622,
"author_profile": "https://Stackoverflow.com/users/209622",
"pm_score": 4,
"selected": false,
"text": "import org.apache.log4j.PatternLayout;\n\npublic class NoStackTracePatterLayout extends PatternLayout {\n\n @Override\n ... | 2008/12/08 | [
"https://Stackoverflow.com/questions/348586",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40783/"
] |
348,589 | <p>I need to make some code to talk to a SOAP web service. Unfortunately I'm unable to get a connection to the service as it requires a SSL connection encrypted with a special certificate. I've been given a pk12 certificate which when installed into my keychain allows me to access the SOAP service manually via Safari, but I'm unable to get a connection from the Cocoa web services stuff :(
Does anybody have any ideas on what I might have to do to get this to work?</p>
| [
{
"answer_id": 367254,
"author": "Nick R.",
"author_id": 373524,
"author_profile": "https://Stackoverflow.com/users/373524",
"pm_score": 0,
"selected": false,
"text": "using System.Security.Cryptography.X509Certificates;\n\npublic partial class _Default : System.Web.UI.Page \n{\n prot... | 2008/12/08 | [
"https://Stackoverflow.com/questions/348589",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6852/"
] |
348,606 | <p>As you can see below, in the constructor I'm instantiating a validation object so I can validate a user's email in a set method. Is this architecture best practice or flawed? Can I avoid making my User class directly dependent on my Validation class?</p>
<pre><code>Class User {
Private Email
//constructor
User() {
Validation = new Validation
}
SetEmail(NewValue) {
if (Validation.isEmail(NewValue)) {
Email = NewValue
}
}
</code></pre>
<p>And a related question: When a set method receives an invalid value, what is the proper response? I see 2 options</p>
<ol>
<li>Don't set the value and return false</li>
<li>Set the value anyway, but set an error property for the object. (so if User.Error is set I know something went wrong)</li>
</ol>
<p>I suspect #1 is best practice because you can then assure the value of any object property is always valid. Correct?</p>
| [
{
"answer_id": 348746,
"author": "Rob Williams",
"author_id": 26682,
"author_profile": "https://Stackoverflow.com/users/26682",
"pm_score": 4,
"selected": true,
"text": "User"
}
] | 2008/12/08 | [
"https://Stackoverflow.com/questions/348606",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26180/"
] |
348,630 | <p>How do I connect to Gmail and determine which messages have attachments? I then want to download each attachment, printing out the Subject: and From: for each message as I process it.</p>
| [
{
"answer_id": 641843,
"author": "jfs",
"author_id": 4279,
"author_profile": "https://Stackoverflow.com/users/4279",
"pm_score": 3,
"selected": false,
"text": "#!/usr/bin/env python\n\"\"\"Save all attachments for given gmail account.\"\"\"\nimport os, sys\nfrom libgmail import GmailAcco... | 2008/12/08 | [
"https://Stackoverflow.com/questions/348630",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
348,657 | <p>I have a string from which I wish to extract a single word, but with a numerical appended to it, which might be different in each line:</p>
<pre><code>This is string1 this is string
This is string11
This is string6 and it is in this line
</code></pre>
<p>I want to parse this file and get the values of "stringXXX", starting from 0 to 100</p>
<pre><code># suppose ABC.txt contains the above lines
FH1 = open "Abc.txt";
@abcFile = <FH1>;
foreach $line(@abcFile) {
if ($pattern =~ s/string.(d{0}d{100});
print $pattern;
</code></pre>
<p>The above prints the whole line, I wish to get only stringXXX</p>
| [
{
"answer_id": 348670,
"author": "Nathan Fellman",
"author_id": 1084,
"author_profile": "https://Stackoverflow.com/users/1084",
"pm_score": 5,
"selected": true,
"text": "while ($pattern =~/(string(100|\\d{1,2}))/g) {\n print $1;\n}\n"
},
{
"answer_id": 348735,
"author": "j... | 2008/12/08 | [
"https://Stackoverflow.com/questions/348657",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35416/"
] |
348,680 | <p>I am working with a wrapper class for <code>CFHTTPMessage</code>, which contains a <code>CFHTTPMessageRef</code> object to which is added the method (GET), the URL of the web application server, and a few custom headers containing the date and an authentication nonce.</p>
<p>I'm having some problems getting the method and URL to return certain data. I think I've worked out the authentication nonce. </p>
<p>I'd like to troubleshoot this by looking at the raw request going to the web application, and making sure everything is formatted properly. </p>
<p>My question is: If I have a <code>CFHTTPMessageRef</code> object (e.g. <code>messageRef</code>), is there a way to log the raw HTTP request that comes out of this message?</p>
<p>I've tried the following but I get a <code>EXC_BAD_ACCESS</code> signal when I try to access its bytes:</p>
<pre><code>CFDataRef messageData = CFHTTPMessageCopyBody(messageRef);
</code></pre>
<p>Thanks for any advice.</p>
<p>As an alternative, is it possible to use a packet sniffer on a switched network? I can run <code>ettercap</code> on a laptop device, but don't know how to sniff what my iPhone is doing on the local wireless network.</p>
| [
{
"answer_id": 351335,
"author": "Alex Reynolds",
"author_id": 19410,
"author_profile": "https://Stackoverflow.com/users/19410",
"pm_score": 4,
"selected": true,
"text": "NSData *d = (NSData *)CFHTTPMessageCopySerializedMessage(messageRef);\nNSLog(@\"%@\",[[[NSString alloc] initWithBytes... | 2008/12/08 | [
"https://Stackoverflow.com/questions/348680",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19410/"
] |
348,684 | <p>I've got an NSBrowser hooked up to an NSTreeController bound to an array of NSTreeNode objects. It's easy enough to get the text portion working by setting the Content and Content Value bindings to properly reference the tree controller, but how do I set the image for each cell using bindings?</p>
| [
{
"answer_id": 351335,
"author": "Alex Reynolds",
"author_id": 19410,
"author_profile": "https://Stackoverflow.com/users/19410",
"pm_score": 4,
"selected": true,
"text": "NSData *d = (NSData *)CFHTTPMessageCopySerializedMessage(messageRef);\nNSLog(@\"%@\",[[[NSString alloc] initWithBytes... | 2008/12/08 | [
"https://Stackoverflow.com/questions/348684",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1512/"
] |
348,688 | <p>I'm using a hosting service which allows me to backup my SQL 2008 database and download the BAK file via a web interface only--and I have access to the database via Management Studio. I can execute the backup command from Management Studio,but I don't have rights to the path where the backups are located. Is there any way via SQL or script to pull down a full copy of the database--can I generate the script required to recreate the database using code? It's only a few thousand records.</p>
<p>Thanks.</p>
| [
{
"answer_id": 5413233,
"author": "anthonyvscode",
"author_id": 79254,
"author_profile": "https://Stackoverflow.com/users/79254",
"pm_score": 2,
"selected": false,
"text": "::Run dbbackup.bat and append all output to log.txt\n\nmd C:\\[directory]\\%date:~-4,4%%date:~-7,2%%date:~-10,2%\n\... | 2008/12/08 | [
"https://Stackoverflow.com/questions/348688",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5592/"
] |
348,689 | <p>I'm doing some simple tests (in preparation for a larger project) to call an ASP.NET WebMethod using JQuery AJAX. In my example, my WebMethod returns a simple string. However, when I attempt to call it using JQuery, I get the entire HTML page content returned instead of just my string. What am I missing?</p>
<p>Client Side :</p>
<pre><code>$(document).ready(function ready() {
$("#MyButton").click(function clicked(e) {
$.post("Default.aspx/TestMethod",
{name:"Bob"},
function(msg) {
alert("Data Recieved: " + msg);
},
"html"
);
});
});
</code></pre>
<p>Server Side:</p>
<pre><code>using System;
using System.Web.Services;
namespace JqueryAjaxText
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
[WebMethod]
public static string TestMethod(string name)
{
return "The value submitted was " + name;
}
}
}
</code></pre>
| [
{
"answer_id": 348770,
"author": "JoshBerke",
"author_id": 26160,
"author_profile": "https://Stackoverflow.com/users/26160",
"pm_score": 6,
"selected": true,
"text": " $(\"#Result\").click(function() {\n $.ajax({\n type: \"POST\",\n url: \"Default.aspx/GetDate\",\n dat... | 2008/12/08 | [
"https://Stackoverflow.com/questions/348689",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44197/"
] |
348,690 | <p>How do I compare two dates in Lingo? To be specific, I want to know if today's date is after some fixed date. I know I can create the fixed date by using:</p>
<pre><code>date("20090101")
</code></pre>
<p>and I can get the current date using:</p>
<pre><code>_system.date()
</code></pre>
<p>but I can't seem to directly compare the two. Do I have to parse the _system.date() to determine if it's after my fixed date? I tried:</p>
<pre><code>if(_system.date() > date("20090101") then
--do something
end if
</code></pre>
<p>but that doesn't seem to work. Any ideas?</p>
| [
{
"answer_id": 348712,
"author": "Elie",
"author_id": 23249,
"author_profile": "https://Stackoverflow.com/users/23249",
"pm_score": 0,
"selected": false,
"text": " if (_system.date().char[1..2] >= 01 and _system.date().char[4..5] >= 01 and _system.date().char[7..10] >= 2010) then\n a... | 2008/12/08 | [
"https://Stackoverflow.com/questions/348690",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23249/"
] |
348,708 | <p>Ok, what I'm trying to do is build a web app that allows students to visually organize their class calendar using drag and drop. but They have to be able to drag and drop to specific locations (when those classes are available), not just anywhere.</p>
<p>This would be a 'fixed week' calendar. I was considering using a table, but was wondering if anyone thought this might be an issue for the drag and drop and if you had suggestions for a better implementation. Would love to hear your thoughts. I'm a very visual thinker and know this sort of app would help me.</p>
<p>Alternatively, if you know of something like this already implemented which I can use, Let me know!</p>
| [
{
"answer_id": 348874,
"author": "Tuminoid",
"author_id": 40657,
"author_profile": "https://Stackoverflow.com/users/40657",
"pm_score": 3,
"selected": true,
"text": "<body style=\"font-size: 12px;\">\n<h1>A Simple Example</h1>\n<table><tbody><tr>\n<td>\n<!-- Create a source with two node... | 2008/12/08 | [
"https://Stackoverflow.com/questions/348708",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43510/"
] |
348,724 | <p>I have a situation where I'm populating a gridview with a bound data source, and want two additional rows at the very bottom; one to show the sum of values in the columns and one to show the average of values in the columns. I can quite easily calculate these values by aggregating information taken from the rowDataBound event, but don't know how to go about manually adding the additional two rows to the gridview. Any help much appreciated.</p>
| [
{
"answer_id": 348762,
"author": "Samiksha",
"author_id": 29515,
"author_profile": "https://Stackoverflow.com/users/29515",
"pm_score": 2,
"selected": false,
"text": "UNION\n"
},
{
"answer_id": 348778,
"author": "Eugene Yokota",
"author_id": 3827,
"author_profile": "h... | 2008/12/08 | [
"https://Stackoverflow.com/questions/348724",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
348,730 | <p>What does the "class" part of a template statement do?</p>
<p>Example:</p>
<pre><code>template <class T>
class Something
{
public:
Something(const T &something);
}
</code></pre>
<p>And what else can go there? I usually only see "class".</p>
| [
{
"answer_id": 348740,
"author": "AlfaZulu",
"author_id": 44060,
"author_profile": "https://Stackoverflow.com/users/44060",
"pm_score": 4,
"selected": true,
"text": "class"
},
{
"answer_id": 348774,
"author": "e.James",
"author_id": 33686,
"author_profile": "https://S... | 2008/12/08 | [
"https://Stackoverflow.com/questions/348730",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43496/"
] |
348,736 | <p>I have noticed jQuery (or is it Firefox) will turn some of my <code><span class="presentational"></span> into <span class="presentational" /></code></p>
<p>Now my question is, is this okay to write my markup like this? Will any browsers choke on it?</p>
<p>Personally, I think it looks cleaner to do <code><span class="presentational" /></code> if it's going to be empty.</p>
| [
{
"answer_id": 348767,
"author": "mmx",
"author_id": 33708,
"author_profile": "https://Stackoverflow.com/users/33708",
"pm_score": 3,
"selected": false,
"text": "<script type='text/javascript' src='script.js' />\n"
},
{
"answer_id": 348781,
"author": "Elle H",
"author_id"... | 2008/12/08 | [
"https://Stackoverflow.com/questions/348736",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31671/"
] |
348,756 | <p>Modifying the HTTP Response Using Filters</p>
| [
{
"answer_id": 348766,
"author": "Samiksha",
"author_id": 29515,
"author_profile": "https://Stackoverflow.com/users/29515",
"pm_score": 0,
"selected": false,
"text": "HttpServletResponse"
}
] | 2008/12/08 | [
"https://Stackoverflow.com/questions/348756",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42791/"
] |
348,760 | <p>What is the simplest way to get the machine's time zone as a positive or negative UTC offset, preferably using some time of shell command?</p>
| [
{
"answer_id": 348824,
"author": "Mihai Limbășan",
"author_id": 14444,
"author_profile": "https://Stackoverflow.com/users/14444",
"pm_score": 3,
"selected": false,
"text": "date +%z"
},
{
"answer_id": 348848,
"author": "ysth",
"author_id": 17389,
"author_profile": "ht... | 2008/12/08 | [
"https://Stackoverflow.com/questions/348760",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
348,763 | <p>I have a template class like below.</p>
<pre><code>template<int S> class A
{
private:
char string[S];
public:
A()
{
for(int i =0; i<S; i++)
{
.
.
}
}
int MaxLength()
{
return S;
}
};
</code></pre>
<p>If i instantiate the above class with different values of S, will the compiler create different instances of A() and MaxLenth() function? Or will it create one instance and pass the S as some sort of argument?</p>
<p>How will it behave if i move the definition of A and Maxlength to a different cpp file.</p>
| [
{
"answer_id": 348772,
"author": "Frank Krueger",
"author_id": 338,
"author_profile": "https://Stackoverflow.com/users/338",
"pm_score": 0,
"selected": false,
"text": "A()"
},
{
"answer_id": 348780,
"author": "Alastair",
"author_id": 31038,
"author_profile": "https://... | 2008/12/08 | [
"https://Stackoverflow.com/questions/348763",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39615/"
] |
348,777 | <p>I have to read a COM port and the data should be displayed inside the TextArea dynamically (data will come every minute), which I have created inside JPanel.</p>
<p>Advance Thanks for reply.</p>
| [
{
"answer_id": 349797,
"author": "Ken Gentle",
"author_id": 8709,
"author_profile": "https://Stackoverflow.com/users/8709",
"pm_score": 0,
"selected": false,
"text": "javax.comm"
}
] | 2008/12/08 | [
"https://Stackoverflow.com/questions/348777",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
348,785 | <p>I know the use of server-side controls is a no-no in ASP.NET MVC, however we have a long list of crystal reports that the company has already produced for a previous application that I would like to utilize for our new ASP.NET MVC application.</p>
<p>Is there an appropriate way to use crystal reports in ASP.NET MVC? If so, how?</p>
| [
{
"answer_id": 2747571,
"author": "coderguy123",
"author_id": 73496,
"author_profile": "https://Stackoverflow.com/users/73496",
"pm_score": 6,
"selected": false,
"text": "using CrystalDecisions.CrystalReports.Engine;\n\npublic ActionResult Report()\n {\n ReportClass rptH = new ... | 2008/12/08 | [
"https://Stackoverflow.com/questions/348785",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11908/"
] |
348,792 | <p>How do you tell if caps lock is on using JavaScript?</p>
<p>One caveat though: I did google it and the best solution I could find was to attach an <code>onkeypress</code> event to every input, then check each time if the letter pressed was uppercase, and if it was, then check if shift was also held down. If it wasn't, therefore caps lock must be on. This feels really dirty and just... <em>wasteful</em> - surely there's a better way than this?</p>
| [
{
"answer_id": 348802,
"author": "rajesh pillai",
"author_id": 34644,
"author_profile": "https://Stackoverflow.com/users/34644",
"pm_score": 8,
"selected": true,
"text": "function isCapslock(e) {\n const IS_MAC = /Mac/.test(navigator.platform);\n\n const charCode = e.charCode;\n const... | 2008/12/08 | [
"https://Stackoverflow.com/questions/348792",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9021/"
] |
348,807 | <p>I have defined a new dialog and its controls in an already existing resource file. I have also created a new file which will handle the events being generated from this dialog. But I am not sure how to connect these two. </p>
<p>Is the statement <code>enum { IDD=IDD_NEW_DIALOG };</code> all that is required to connect the two? Or should we add some other statement?</p>
| [
{
"answer_id": 348810,
"author": "peterchen",
"author_id": 31317,
"author_profile": "https://Stackoverflow.com/users/31317",
"pm_score": 1,
"selected": false,
"text": "DoModal()"
},
{
"answer_id": 349093,
"author": "DavidK",
"author_id": 31394,
"author_profile": "http... | 2008/12/08 | [
"https://Stackoverflow.com/questions/348807",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41518/"
] |
348,821 | <p>This question is coded in pseudo-PHP, but I really don't mind what language I get answers in (except for Ruby :-P), as this is purely hypothetical. In fact, PHP is quite possibly the worst language to be doing this type of logic in. Unfortunately, I have never done this before, so I can't provide a real-world example. Therefore, hypothetical answers are completely acceptable.</p>
<p>Basically, I have lots of objects performing a task. For this example, let's say each object is a class that downloads a file from the Internet. Each object will be downloading a different file, and the downloads are run in parallel. Obviously, some objects may finish downloading before others. The actual grabbing of data may run in threads, but that is not relevant to this question.</p>
<p>So we can define the object as such:</p>
<pre><code>class DownloaderObject() {
var $url = '';
var $downloading = false;
function DownloaderObject($v){ // constructor
$this->url = $v;
start_downloading_in_the_background(url=$this->$url, callback=$this->finished);
$this->downloading = true;
}
function finished() {
save_the_data_somewhere();
$this->downloading = false;
$this->destroy(); // actually destroys the object
}
}
</code></pre>
<p>Okay, so we have lots of these objects running:</p>
<pre><code>$download1 = new DownloaderObject('http://somesite.com/latest_windows.iso');
$download2 = new DownloaderObject('http://somesite.com/kitchen_sink.iso');
$download3 = new DownloaderObject('http://somesite.com/heroes_part_1.rar');
</code></pre>
<p>And we can store them in an array:</p>
<pre><code>$downloads = array($download1, $download2, $download3);
</code></pre>
<p>So we have an array full of the downloads:</p>
<pre><code>array(
1 => $download1,
2 => $download2,
3 => $download3
)
</code></pre>
<p>And we can iterate through them like this:</p>
<pre><code>print('Here are the downloads that are running:');
foreach ($downloads as $d) {
print($d->url . "\n");
}
</code></pre>
<p>Okay, now suppose download 2 finishes, and the object is destroyed. Now we should have two objects in the array:</p>
<pre><code>array(
1 => $download1,
3 => $download3
)
</code></pre>
<p>But there is a hole in the array! Key #2 is being unused. Also, if I wanted to start a new download, it is unclear where to insert the download into the array. The following could work:</p>
<pre><code>$i = 0;
while ($i < count($downloads) - 1) {
if (!is_object($downloads[$i])) {
$downloads[$i] = new DownloaderObject('http://somesite.com/doctorwho.iso');
break;
}
$i++;
}
</code></pre>
<p>However, that is terribly inefficient (and <code>while $i++</code> loops are nooby). So, another approach is to keep a counter.</p>
<pre><code>function add_download($url) {
global $downloads;
static $download_counter;
$download_counter++;
$downloads[$download_counter] = new DownloaderObject($url);
}
</code></pre>
<p>That would work, but we still get holes in the array:</p>
<pre><code>array(
1 => DownloaderObject,
3 => DownloaderObject,
7 => DownloaderObject,
13 => DownloaderObject
)
</code></pre>
<p>That's ugly. However, is that acceptable? Should the array be "defragmented", i.e. the keys rearranged to eliminate blank spaces?</p>
<p>Or is there another programmatic structure I should be aware of? I want a structure that I can add stuff to, remove stuff from, refer to keys in a variable, iterate through, etc., that is not an array. Does such a thing exist?</p>
<p>I have been coding for years, but this question has bugged me for very many of those years, and I am still not aware of an answer. This may be obvious to some programmers, but is extremely non-trivial to me.</p>
| [
{
"answer_id": 348830,
"author": "Stefan Mai",
"author_id": 13257,
"author_profile": "https://Stackoverflow.com/users/13257",
"pm_score": 1,
"selected": false,
"text": "$i = 0;\nwhile ($i < count($downloads) - 1) {\n if (!is_object($downloads[$i])) {\n $downloads[$i] = new Downl... | 2008/12/08 | [
"https://Stackoverflow.com/questions/348821",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10839/"
] |
348,833 | <p>If I generate an exception on my own, I can include any info into the exception: a number of code line and name of source file. Something like this:</p>
<pre><code>throw std::exception("myFile.cpp:255");
</code></pre>
<p>But what's with unhandled exceptions or with exceptions that were not generated by me?</p>
| [
{
"answer_id": 348843,
"author": "Frank Krueger",
"author_id": 338,
"author_profile": "https://Stackoverflow.com/users/338",
"pm_score": 2,
"selected": false,
"text": "#define throw_line(msg) \\\n throw std::exception(msg \" \" __FILE__ \":\" __LINE__)\n\nvoid f() {\n throw_line(\"... | 2008/12/08 | [
"https://Stackoverflow.com/questions/348833",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44217/"
] |
348,849 | <p>I am writing a batch file, in which I call an EXE to execute. Now, statements after the call to the EXE should not execute till the EXE completes its execution. How can I do it in the batch file (on Windows)?</p>
| [
{
"answer_id": 348851,
"author": "Dean Rather",
"author_id": 14966,
"author_profile": "https://Stackoverflow.com/users/14966",
"pm_score": 0,
"selected": false,
"text": "PAUSE\n"
},
{
"answer_id": 348857,
"author": "Toon Krijthe",
"author_id": 18061,
"author_profile":... | 2008/12/08 | [
"https://Stackoverflow.com/questions/348849",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
348,853 | <p>Inspired by <a href="https://stackoverflow.com/questions/40845/how-do-f-units-of-measurement-work">Units of Measure in F#</a>, and despite asserting (<a href="https://stackoverflow.com/questions/39492/where-can-f-actually-save-time-and-money#71112">here</a>) that you couldn't do it in C#, I had an idea the other day which I've been playing around with.</p>
<pre><code>namespace UnitsOfMeasure
{
public interface IUnit { }
public static class Length
{
public interface ILength : IUnit { }
public class m : ILength { }
public class mm : ILength { }
public class ft : ILength { }
}
public class Mass
{
public interface IMass : IUnit { }
public class kg : IMass { }
public class g : IMass { }
public class lb : IMass { }
}
public class UnitDouble<T> where T : IUnit
{
public readonly double Value;
public UnitDouble(double value)
{
Value = value;
}
public static UnitDouble<T> operator +(UnitDouble<T> first, UnitDouble<T> second)
{
return new UnitDouble<T>(first.Value + second.Value);
}
//TODO: minus operator/equality
}
}
</code></pre>
<p>Example usage:</p>
<pre><code>var a = new UnitDouble<Length.m>(3.1);
var b = new UnitDouble<Length.m>(4.9);
var d = new UnitDouble<Mass.kg>(3.4);
Console.WriteLine((a + b).Value);
//Console.WriteLine((a + c).Value); <-- Compiler says no
</code></pre>
<p>The next step is trying to implement conversions (snippet):</p>
<pre><code>public interface IUnit { double toBase { get; } }
public static class Length
{
public interface ILength : IUnit { }
public class m : ILength { public double toBase { get { return 1.0;} } }
public class mm : ILength { public double toBase { get { return 1000.0; } } }
public class ft : ILength { public double toBase { get { return 0.3048; } } }
public static UnitDouble<R> Convert<T, R>(UnitDouble<T> input) where T : ILength, new() where R : ILength, new()
{
double mult = (new T() as IUnit).toBase;
double div = (new R() as IUnit).toBase;
return new UnitDouble<R>(input.Value * mult / div);
}
}
</code></pre>
<p>(I would have liked to avoid instantiating objects by using static, but as we all know you <a href="https://stackoverflow.com/questions/259026/why-doesnt-c-allow-static-methods-to-implement-an-interface">can't declare a static method in an interface</a>)
You can then do this:</p>
<pre><code>var e = Length.Convert<Length.mm, Length.m>(c);
var f = Length.Convert<Length.mm, Mass.kg>(d); <-- but not this
</code></pre>
<p>Obviously, there is a gaping hole in this, compared to F# Units of measure (I'll let you work it out).</p>
<p>Oh, the question is: what do you think of this? Is it worth using? Has someone else already done better?</p>
<p><strong>UPDATE</strong> for people interested in this subject area, <a href="http://www.cs.utexas.edu/users/novak/units95.pdf" rel="noreferrer">here</a> is a link to a paper from 1997 discussing a different kind of solution (not specifically for C#)</p>
| [
{
"answer_id": 348868,
"author": "Mark Cidade",
"author_id": 1659,
"author_profile": "https://Stackoverflow.com/users/1659",
"pm_score": 4,
"selected": false,
"text": "Length length = Length.FromMillimeters(n1);\ndecimal lengthInFeet = length.Feet;\nLength length2 = length.A... | 2008/12/08 | [
"https://Stackoverflow.com/questions/348853",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11410/"
] |
348,864 | <p>F
Is there a way to monitor the FTP port so that I can know what commands my FTP application is sending to a FTP server?</p>
<p>I am using a closed-source FTP client application, which is not working with a closed-source FTP application server. The client and the server are not communicating well with each other, and I would like to find out why. I wish to reverse-engineer the client to see what commends the client are sending to the sever. I used a web test tool before that allowed me to monitor the content transferring through HTTP, but I can't seem to find such tool for FTP. I appreciate it if you can help me out, thanks. </p>
| [
{
"answer_id": 1012046,
"author": "cjs",
"author_id": 107294,
"author_profile": "https://Stackoverflow.com/users/107294",
"pm_score": 0,
"selected": false,
"text": "ktrace"
}
] | 2008/12/08 | [
"https://Stackoverflow.com/questions/348864",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23637/"
] |
348,867 | <p>can anyone think of a better way to do this?</p>
<pre><code> [AcceptVerbs(HttpVerbs.Post)]
public ActionResult SaveAction()
{
NameValueDeserializer value = new NameValueDeserializer();
// selected messages
MemberMessageSaveAction[] messages = (MemberMessageSaveAction[])value.Deserialize(Request.Form, "value", typeof(MemberMessageSaveAction[]));
// selected action
MemberMessageAction action = (MemberMessageAction)Enum.Parse(typeof(MemberMessageAction), Request.Form["action"]);
// determine action
if (action != MemberMessageAction.MarkRead &&
action != MemberMessageAction.MarkUnRead &&
action != MemberMessageAction.Delete)
{
// selected action requires special processing
IList<MemberMessage> items = new List<MemberMessage>();
// add selected messages to list
for (int i = 0; i < messages.Length; i++)
{
foreach (int id in messages[i].Selected)
{
items.Add(MessageRepository.FetchByID(id));
}
}
// determine action further
if (action == MemberMessageAction.MoveToFolder)
{
// folders
IList<MemberMessageFolder> folders = FolderRepository.FetchAll(new MemberMessageFolderCriteria
{
MemberID = Identity.ID,
ExcludedFolder = Request.Form["folder"]
});
if (folders.Total > 0)
{
ViewData["messages"] = items;
ViewData["folders"] = folders;
return View("move");
}
return Url<MessageController>(c => c.Index("inbox", 1)).Redirect();
}
else if (action == MemberMessageAction.ExportXml)
{
return new MemberMessageDownload(Identity.ID, items, MemberMessageDownloadType.Xml);
}
else if (action == MemberMessageAction.ExportCsv)
{
return new MemberMessageDownload(Identity.ID, items, MemberMessageDownloadType.Csv);
}
else
{
return new MemberMessageDownload(Identity.ID, items, MemberMessageDownloadType.Text);
}
}
else if (action == MemberMessageAction.Delete)
{
for (int i = 0; i < messages.Length; i++)
{
foreach (int id in messages[i].Selected)
{
MemberMessage message = MessageRepository.FetchByID(id);
if (message.Sender.ID == Identity.ID || message.Receiver.ID == Identity.ID)
{
if (message.Sender.ID == Identity.ID)
{
message.SenderActive = false;
}
else
{
message.ReceiverActive = false;
}
message.Updated = DateTime.Now;
MessageRepository.Update(message);
if (message.SenderActive == false && message.ReceiverActive == false)
{
MessageRepository.Delete(message);
}
}
}
}
}
else
{
for (int i = 0; i < messages.Length; i++)
{
foreach (int id in messages[i].Selected)
{
MemberMessage message = MessageRepository.FetchByID(id);
if (message.Receiver.ID == Identity.ID)
{
if (action == MemberMessageAction.MarkRead)
{
message.ReceiverRead = true;
}
else
{
message.ReceiverRead = false;
}
message.Updated = DateTime.Now;
MessageRepository.Update(message);
}
}
}
}
return Url<MessageController>(c => c.Index("inbox", 1)).Redirect();
}
</code></pre>
| [
{
"answer_id": 348870,
"author": "Toon Krijthe",
"author_id": 18061,
"author_profile": "https://Stackoverflow.com/users/18061",
"pm_score": 2,
"selected": false,
"text": "[AcceptVerbs(HttpVerbs.Post)]\npublic ActionResult SaveAction() {\n // SNIP \n if (action == MemberMessageAction.... | 2008/12/08 | [
"https://Stackoverflow.com/questions/348867",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43380/"
] |
348,880 | <p>Is it possible to create an sql statement that selects the week number (NOT the day of week - or the day number in a week). I'm creating a view to select this extra information along with a couple of other fields and thus can not use a stored procedure. I'm aware that it's possible to create a UDF to do the trick, but if at all possible i'd rather only have to add a view to this database, than both a view and a function.</p>
<p>Any ideas? Also where i come from, the week starts monday and week 1 is the first week of the year with atleast 4 days.</p>
<h3>Related:</h3>
<blockquote>
<p><a href="https://stackoverflow.com/questions/274861/how-do-i-calculate-the-week-number-given-a-date">How do I calculate the week number given a date?</a></p>
</blockquote>
| [
{
"answer_id": 348894,
"author": "Gishu",
"author_id": 1695,
"author_profile": "https://Stackoverflow.com/users/1695",
"pm_score": 2,
"selected": false,
"text": "DATEPART(wk, ‘Jan 1, xxxx’) = 1\n"
},
{
"answer_id": 348896,
"author": "Samiksha",
"author_id": 29515,
"au... | 2008/12/08 | [
"https://Stackoverflow.com/questions/348880",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11619/"
] |
348,892 | <p>I normally in my projects use such these code:</p>
<pre><code>If user.IsInRole("Admin") Then
deleteButton.Visible = True
else
deleteButton.Visible = False
</code></pre>
<p>But I want to control roles, which can see this button in database.</p>
<p>For this purpose how should database design be?</p>
<p>Thanks.</p>
| [
{
"answer_id": 348901,
"author": "Vilx-",
"author_id": 41360,
"author_profile": "https://Stackoverflow.com/users/41360",
"pm_score": 1,
"selected": false,
"text": "user.isInRole(\"Admin\")"
},
{
"answer_id": 348927,
"author": "BobbyShaftoe",
"author_id": 38426,
"autho... | 2008/12/08 | [
"https://Stackoverflow.com/questions/348892",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/439507/"
] |
348,900 | <p>There are a few questions on SO already regarding LINQ pivots and while a couple of them outline my exact problem, I can't successfully translate them to a working solution. I feel that this is mostly due to a join in my tables.</p>
<p>So for the benefit of all the LINQ junkies out there who love a problem, here's another puzzle for you to work out. Please help me out (and earn some reputation points and much respect from me) by converting the following SQL stored proc script to LINQ:</p>
<pre><code>ALTER PROCEDURE [dbo].[GetTimesheetForWeekById]
@timesheetid int,
@begindate VarChar(20),
@enddate VarChar(20)
AS
BEGIN
SELECT T.TaskName,
SUM(
case DATEPART(weekday, TE.StartTime)
WHEN 1 THEN DATEDIFF(minute, TE.StartTime, TE.EndTime) ELSE 0 END
) AS Sunday,
SUM(
case DATEPART(weekday, TE.StartTime)
when 2 THEN DATEDIFF(minute, TE.StartTime, TE.EndTime) ELSE 0 END
) AS Monday,
SUM(
case DATEPART(weekday, TE.StartTime)
when 3 THEN DATEDIFF(minute, TE.StartTime, TE.EndTime) ELSE 0 END
) AS Tuesday,
SUM(
case DATEPART(weekday, TE.StartTime)
when 4 THEN DATEDIFF(minute, TE.StartTime, TE.EndTime) ELSE 0 END
) AS Wednesday,
SUM(
case DATEPART(weekday, TE.StartTime)
when 5 THEN DATEDIFF(minute, TE.StartTime, TE.EndTime) ELSE 0 END
) AS Thursday,
SUM(
case DATEPART(weekday, TE.StartTime)
when 6 THEN DATEDIFF(minute, TE.StartTime, TE.EndTime) ELSE 0 END
) AS Friday,
SUM(
case DATEPART(weekday, TE.StartTime)
when 6 THEN DATEDIFF(minute, TE.StartTime, TE.EndTime) ELSE 0 END
) AS Saturday
FROM Tasks T
INNER JOIN TimeEntries TE on T.TaskID = TE.TaskID
WHERE TE.StartTime BETWEEN
(CONVERT(datetime, @begindate, 103)) AND (CONVERT(datetime, @enddate, 103))
AND TE.TimesheetID = @timesheetid
GROUP BY T.TaskName
END
</code></pre>
| [
{
"answer_id": 348901,
"author": "Vilx-",
"author_id": 41360,
"author_profile": "https://Stackoverflow.com/users/41360",
"pm_score": 1,
"selected": false,
"text": "user.isInRole(\"Admin\")"
},
{
"answer_id": 348927,
"author": "BobbyShaftoe",
"author_id": 38426,
"autho... | 2008/12/08 | [
"https://Stackoverflow.com/questions/348900",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15609/"
] |
348,919 | <p>I'd like to be able to send a Ruby app to some colleagues without requiring them to install a Ruby interpreter. A single exe would be preferable.</p>
<p>I googled and found "RubyScript2Exe".</p>
<p>What are your experiences with that? Are there other such tools or are there better approaches altogether than building an exe?</p>
| [
{
"answer_id": 682780,
"author": "JasonSmith",
"author_id": 2938,
"author_profile": "https://Stackoverflow.com/users/2938",
"pm_score": 0,
"selected": false,
"text": "exerb"
}
] | 2008/12/08 | [
"https://Stackoverflow.com/questions/348919",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15323/"
] |
348,920 | <p>I am new to php.
I made a member registration on login page and adm too. So inside admin I wanted to get the list of the members and delete the members I dont want. So I took the a code from a sample code for phone book from <a href="http://localhost/xamp" rel="nofollow noreferrer">http://localhost/xamp</a> and editted it to my requirement I am able to retrieve the members but unable to delete the members. See the code below:</p>
<pre><code><?php
require_once('auth.php');
require_once('../config.php');
//Array to store validation errors
$errmsg_arr = array();
//Validation error flag
$errflag = false;
//Connect to mysql server
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$link) {
die('Failed to connect to server: ' . mysql_error());
}
//Select database
$db = mysql_select_db(DB_DATABASE);
if(!$db) {
die("Unable to select database");
}
?>
<html>
<head>
<meta name="author" content="Kai Oswald Seidler">
<link href="../loginmodule.css" rel="stylesheet" type="text/css">
<title></title>
</head>
<body>
&nbsp;<p>
<h2><?php echo "User list"; ?></h2>
<table border="0" cellpadding="0" cellspacing="0">
<tr bgcolor="#f87820">
<td><img src="img/blank.gif" alt="" width="10" height="25"></td>
<td class="tabhead"><img src="img/blank.gif" alt="" width="150" height="6"><br><b><?php echo $TEXT['phonebook-attrib1']; ?></b></td>
<td class="tabhead"><img src="img/blank.gif" alt="" width="150" height="6"><br><b><?php echo $TEXT['phonebook-attrib2']; ?></b></td>
<td class="tabhead"><img src="img/blank.gif" alt="" width="150" height="6"><br><b><?php echo $TEXT['phonebook-attrib3']; ?></b></td>
<td class="tabhead"><img src="img/blank.gif" alt="" width="50" height="6"><br><b><?php echo $TEXT['phonebook-attrib4']; ?></b></td>
<td><img src="img/blank.gif" alt="" width="10" height="25"></td>
</tr>
<?php
$firstname=$_REQUEST['firstname'];
$lastname=$_REQUEST['lastname'];
$phone=$_REQUEST['phone'];
if($_REQUEST['action']=="del")
{
$result=mysql_query("DELETE FROM members WHERE member_id={$_REQUEST['member_id']}");
}
$result=mysql_query("SELECT member_id,firstname,lastname,login FROM members ORDER BY lastname");
$i = 0;
while($row = mysql_fetch_array($result)) {
if ($i > 0) {
echo "<tr valign='bottom'>";
echo "<td bgcolor='#ffffff' height='1' style='background-image:url(img/strichel.gif)' colspan='6'></td>";
echo "</tr>";
}
echo "<tr valign='middle'>";
echo "<td class='tabval'><img src='img/blank.gif' alt='' width='10' height='20'></td>";
echo "<td class='tabval'><b>".$row['lastname']."</b></td>";
echo "<td class='tabval'>".$row['firstname']."&nbsp;</td>";
echo "<td class='tabval'>".$row['member_id']."&nbsp;</td>";
echo "<td class='tabval'><a onclick=\"return confirm('".$TEXT['userlist-sure']."');\" href='userlist.php?action=del&amp;member_1d=".$row['member_id']."'><span class='red'>[".$TEXT['userlist-button1']."]</span></a></td>";
echo "<td class='tabval'></td>";
echo "</tr>";
$i++;
}
echo "<tr valign='bottom'>";
echo "<td bgcolor='#fb7922' colspan='6'><img src='img/blank.gif' alt='' width='1' height='8'></td>";
echo "</tr>";
?>
</table>
</body>
</html>
</code></pre>
<p>I haven't editted it that properly and the looks in all.</p>
<p>Please help me in making it able to delete the members also.</p>
<p>I didn't understand what .$TEXT['userlist-button1'].,'".$TEXT['userlist-sure']. variables are?
I also want to include an approved and disapproved radio button in table for each members.</p>
<p>How can I do that?</p>
<p>Please if you can help me.</p>
| [
{
"answer_id": 348941,
"author": "OIS",
"author_id": 36175,
"author_profile": "https://Stackoverflow.com/users/36175",
"pm_score": 1,
"selected": false,
"text": "&member_1d"
},
{
"answer_id": 348942,
"author": "markus",
"author_id": 11995,
"author_profile": "https... | 2008/12/08 | [
"https://Stackoverflow.com/questions/348920",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40975/"
] |
348,928 | <p>Parser Error Message: The entry 'SiteSqlServer' has already been added.</p>
<p>Source Error:</p>
<blockquote>
<pre><code>Line 23: providerName="System.Data.SqlClient"/> -->
Line 24: < ! -- Connection String for SQL Server 2000/2005 -->
Line 25: <add name="SiteSqlServer" connectionString="Server=(local);
</code></pre>
<p>abase=DotNetNuke2; uid=nukeuser;pwd=dotnetnuke;" providerName="System.Data.SqlClient" / ></p>
<pre><code>Line 26: </connectionStrings>
Line 27: <appSettings>
</code></pre>
</blockquote>
<p>Does anyone know the work around???</p>
| [
{
"answer_id": 351961,
"author": "Samiksha",
"author_id": 29515,
"author_profile": "https://Stackoverflow.com/users/29515",
"pm_score": 2,
"selected": true,
"text": "<connectionStrings>\n\n<remove name=\"SiteSqlServer\" />\n\n<add name=\"SiteSqlServer\" connectionString=\"server=(local);... | 2008/12/08 | [
"https://Stackoverflow.com/questions/348928",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29515/"
] |
348,953 | <p>I am extending a template class using C++ in Visual Studio 2005.
It is giving me an error when I try to extend the template base class with:</p>
<pre><code>template <class K, class D>
class RedBlackTreeOGL : public RedBlackTree<K, D>::RedBlackTree // Error 1
{
public:
RedBlackTreeOGL();
~RedBlackTreeOGL();
</code></pre>
<p>and a second error when I try to instantiate the object:</p>
<pre><code>RedBlackTreeOGL<double, std::string> *tree = new RedBlackTreeOGL<double, std::string>; // error 2
</code></pre>
<p><strong>Error 1:</strong></p>
<p>**redblacktreeopengl.hpp(27) : error C2039: '{ctor}' : is not a member of 'RedBlackTree'
with
[
K=double,
D=std::string
]
**</p>
<p><strong>Error 2:</strong></p>
<p>main.cpp(50) : see reference to class template instantiation 'RedBlackTreeOGL' being compiled</p>
| [
{
"answer_id": 348955,
"author": "Sandeep Datta",
"author_id": 39648,
"author_profile": "https://Stackoverflow.com/users/39648",
"pm_score": 1,
"selected": false,
"text": "RedBlackTree<K, D>::RedBlackTree"
},
{
"answer_id": 348968,
"author": "Brock Woolf",
"author_id": 40... | 2008/12/08 | [
"https://Stackoverflow.com/questions/348953",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40002/"
] |
348,964 | <p>Can someone share a simple example of using the <code>foreach</code> keyword with custom objects?</p>
| [
{
"answer_id": 348977,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 7,
"selected": true,
"text": "foreach"
},
{
"answer_id": 348983,
"author": "Mats Fredriksson",
"author_id": 2973,
"author_profile":... | 2008/12/08 | [
"https://Stackoverflow.com/questions/348964",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42070/"
] |
348,966 | <p>I'm working with asp.net (I'm a designer) and at some point during debugging it'll throw me and I'll get to an Exception objErr in the code - and when I hover it says "file not found". I assume it's an image but I've been searching and can't find anyway to pinpoint which file is missing. I hope this is enough information - if anyone could give me a direction I'll really appreciate it!</p>
<p>AB</p>
| [
{
"answer_id": 349054,
"author": "Germstorm",
"author_id": 18631,
"author_profile": "https://Stackoverflow.com/users/18631",
"pm_score": 0,
"selected": false,
"text": "<asp:HyperLink ID=\"lnkExample\" runat=\"server\" NavigateUrl=\"~/Pages/Example.aspx\"> Example</asp:HyperLink>\n"
}
] | 2008/12/08 | [
"https://Stackoverflow.com/questions/348966",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
348,985 | <p>I user sun jdk 1.5 ThreadPoolExecutor( 24, 24,60,TimeUnit.SECONDS, new LinkedBlockingQueue()). soemtime I use jdb tool to find the status of all threads in thread pool are " waiting in a monitor", the code is : </p>
<pre><code> String key = getKey(dt.getPrefix(), id);
synchronized (key.intern()) { ----->
</code></pre>
<p>Is there a problem in "synchronized (key.intern()) " ?</p>
<hr>
<p>I get following informatnio using jdb tool, the status of 24 threads is "waiting in a monitor", it means 24 threads are deadlock at "key.intern()".</p>
<p>(java.lang.Thread)0x28 pool-3-thread-2 waiting in a monitor</p>
<p>(java.lang.Thread)0x27 pool-3-thread-3 waiting in a monitor</p>
<p>(java.lang.Thread)0x1b pool-3-thread-4 waiting in a monitor</p>
<p>(java.lang.Thread)0x1a pool-3-thread-5 waiting in a monitor</p>
<p>(java.lang.Thread)0x19 pool-3-thread-6 waiting in a monitor</p>
<p>(java.lang.Thread)0x18 pool-3-thread-7 waiting in a monitor</p>
<p>(java.lang.Thread)0x17 pool-3-thread-8 waiting in a monitor
...</p>
<p>so the result is : in multi-threads environment, Sting intern() method may be deadlock, ok ?</p>
| [
{
"answer_id": 348994,
"author": "Bombe",
"author_id": 43582,
"author_profile": "https://Stackoverflow.com/users/43582",
"pm_score": 2,
"selected": false,
"text": "key"
},
{
"answer_id": 358513,
"author": "erickson",
"author_id": 3474,
"author_profile": "https://Stack... | 2008/12/08 | [
"https://Stackoverflow.com/questions/348985",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44230/"
] |
348,991 | <p>I have a string, lets say "123|ABC|test|12345|FF" and I want to xor the ascii value of each character and print the result in hex.</p>
<p>What is the simplest way?</p>
| [
{
"answer_id": 348994,
"author": "Bombe",
"author_id": 43582,
"author_profile": "https://Stackoverflow.com/users/43582",
"pm_score": 2,
"selected": false,
"text": "key"
},
{
"answer_id": 358513,
"author": "erickson",
"author_id": 3474,
"author_profile": "https://Stack... | 2008/12/08 | [
"https://Stackoverflow.com/questions/348991",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
348,999 | <p>On my Centos server Python's mimetypes.guess_type("mobile.3gp") returns (None, None), instead of ('video/3gpp', None).</p>
<p>Where does Python get the list of mimetypes from, and is it possible to add a missing type to the list?</p>
| [
{
"answer_id": 349020,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 4,
"selected": true,
"text": "knownfiles"
},
{
"answer_id": 43311856,
"author": "JinSnow",
"author_id": 1486850,
"author_profile": "https... | 2008/12/08 | [
"https://Stackoverflow.com/questions/348999",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21716/"
] |
349,004 | <p>I have written a game that uses GLUT, OpenGL and FMOD. The problem is that the binary won't run, unless Visual Studio 2008 is installed on the computer.</p>
<p>Why is this?</p>
| [
{
"answer_id": 349017,
"author": "Eugene Yokota",
"author_id": 3827,
"author_profile": "https://Stackoverflow.com/users/3827",
"pm_score": 3,
"selected": false,
"text": "cout << \"Hello, World\" << endl;\n"
}
] | 2008/12/08 | [
"https://Stackoverflow.com/questions/349004",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40002/"
] |
349,022 | <p>I have an app that run on many computers and connect to sql server
I want to log the machine names of that computers in a table every time they connect how can I do that</p>
<p>I want to know if there is a command like that</p>
<p>"Select @@MachineName"</p>
| [
{
"answer_id": 349028,
"author": "Samiksha",
"author_id": 29515,
"author_profile": "https://Stackoverflow.com/users/29515",
"pm_score": 0,
"selected": false,
"text": " [ , [ @datasrc= ] 'data_source' ] \n [ , [ @location= ] 'location' ] \n [ , [ @provstr= ] 'provider_string' ] \n [ , [ @... | 2008/12/08 | [
"https://Stackoverflow.com/questions/349022",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
349,023 | <p>The code below is the code i am using. It works fine in thunderbird but not in mac mail client (and i assume anything made by microsoft. I currently do not have access to this to test it in). Much as i am aware of the idiosyncrasies of the various mail clients, I am flummoxed by this! It's fairly self explanatory but i am trying to send plain text and html emails to increase the readership. Any help would be much appreciated.</p>
<p>EDIT</p>
<p>I should have clarified that the contents get sent regardless but in thunderbird it displays the message correctly, but in mac mail client you get the entire thing from the first PHP-alt to the last PHP</p>
<pre><code><?php
//define the receiver of the email
$to = 'youraddress@example.com';
//define the subject of the email
$subject = 'Test HTML email';
//create a boundary string. It must be unique
//so we use the MD5 algorithm to generate a random hash
$random_hash = md5(date('r', time()));
//define the headers we want passed. Note that they are separated with \r\n
$headers = "From: webmaster@example.com\r\nReply-To: webmaster@example.com";
//add boundary string and mime type specification
$headers .= "\r\nContent-Type: multipart/alternative; boundary=\"PHP-alt-".$random_hash."\"";
//define the body of the message.
ob_start(); //Turn on output buffering
?>
--PHP-alt-<?php echo $random_hash; ?>
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Hello World!!!
This is simple text email message.
--PHP-alt-<?php echo $random_hash; ?>
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
<h2>Hello World!</h2>
<p>This is something with <b>HTML</b> formatting.</p>
--PHP-alt-<?php echo $random_hash; ?>--
<?
//copy current buffer contents into $message variable and delete current output buffer
$message = ob_get_clean();
//send the email
$mail_sent = @mail( $to, $subject, $message, $headers );
//if the message is sent successfully print "Mail sent". Otherwise print "Mail failed"
echo $mail_sent ? "Mail sent" : "Mail failed";
?>
</code></pre>
| [
{
"answer_id": 349039,
"author": "Paul Dixon",
"author_id": 6521,
"author_profile": "https://Stackoverflow.com/users/6521",
"pm_score": 0,
"selected": false,
"text": "$message =ob_get_contents();\nob_end_clean();\n"
}
] | 2008/12/08 | [
"https://Stackoverflow.com/questions/349023",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31677/"
] |
349,025 | <p>Is a string literal in C++ created in static memory and destroyed only when the program exits?</p>
| [
{
"answer_id": 349030,
"author": "paxdiablo",
"author_id": 14860,
"author_profile": "https://Stackoverflow.com/users/14860",
"pm_score": 7,
"selected": true,
"text": "char *x = \"hello\";"
}
] | 2008/12/08 | [
"https://Stackoverflow.com/questions/349025",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22076/"
] |
349,040 | <p>I don't want a "close window" menu item in the task bar context menu for my WPF window. My intention is to annoy the user.</p>
<p>Thank you!</p>
| [
{
"answer_id": 349966,
"author": "Micah",
"author_id": 17744,
"author_profile": "https://Stackoverflow.com/users/17744",
"pm_score": 3,
"selected": false,
"text": "<Window ShowInTaskbar=\"False\" ... />\n"
}
] | 2008/12/08 | [
"https://Stackoverflow.com/questions/349040",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22038/"
] |
349,050 | <p>I'm in the midst of writing a 3d engine and I've come across the LookAt algorithm described in the DirectX documentation:</p>
<pre><code>zaxis = normal(At - Eye)
xaxis = normal(cross(Up, zaxis))
yaxis = cross(zaxis, xaxis)
xaxis.x yaxis.x zaxis.x 0
xaxis.y yaxis.y zaxis.y 0
xaxis.z yaxis.z zaxis.z 0
-dot(xaxis, eye) -dot(yaxis, eye) -dot(zaxis, eye) 1
</code></pre>
<p>Now I get how it works on the rotation side, but what I don't quite get is why it puts the translation component of the matrix to be those dot products. Examining it a bit it seems that it's adjusting the camera position by a small amount based on a projection of the new basis vectors onto the position of the eye/camera.</p>
<p>The question is why does it need to do this? What does it accomplish?</p>
| [
{
"answer_id": 353612,
"author": "TM.",
"author_id": 12983,
"author_profile": "https://Stackoverflow.com/users/12983",
"pm_score": 2,
"selected": false,
"text": "gluLookAt"
}
] | 2008/12/08 | [
"https://Stackoverflow.com/questions/349050",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3719/"
] |
349,055 | <p>T have used checkbox column in gridview. On click of a linkbutton, it should be checked that checkboxes in gridview are checked or not. If none check box is checked then it should display alert("Check at leat one check box"). </p>
| [
{
"answer_id": 349168,
"author": "Andreas Grech",
"author_id": 44084,
"author_profile": "https://Stackoverflow.com/users/44084",
"pm_score": 0,
"selected": false,
"text": "var grid = document.getElementById(\"gridId\"); //Retrieve the grid \n var inputs = grid.getElementsByTagName... | 2008/12/08 | [
"https://Stackoverflow.com/questions/349055",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43886/"
] |
349,060 | <p>Now I know about the "normal" CSS list styles (roman, latin, etc) and certainly in years past they were somewhat inflexible in not allowing things like:</p>
<p>(a)</p>
<p>or </p>
<p>a)</p>
<p>only</p>
<p>a.</p>
<p>Now I believe that you can get an effect like the above with the :before and :after pseudo-elements. Is that correct? And whats the browser compatibility like if you can?</p>
<p>My main question however is that I want to have report style numbering:</p>
<ol>
<li>Introduction
1.1 Objectives
1.2 Assumptions
1.3 Limitations
1.3.1 ...</li>
<li>New Section
...</li>
</ol>
<p>and so on.</p>
<p>Can CSS do this and, if so, whats the browser compatibility like?</p>
| [
{
"answer_id": 349089,
"author": "Eugene Yokota",
"author_id": 3827,
"author_profile": "https://Stackoverflow.com/users/3827",
"pm_score": 4,
"selected": true,
"text": "H1:before {\n content: \"Chapter \" counter(chapter) \". \";\n counter-increment: chapter; /* Add 1 to chapter *... | 2008/12/08 | [
"https://Stackoverflow.com/questions/349060",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18393/"
] |
349,062 | <p>Is it possible to overload the null-coalescing operator for a class in C#? </p>
<p>Say for example I want to return a default value if an instance is null and return the instance if it's not. The code would look like something like this:</p>
<pre><code> return instance ?? new MyClass("Default");
</code></pre>
<p>But what if I would like to use the null-coalescing operator to also check if the MyClass.MyValue is set?</p>
| [
{
"answer_id": 349096,
"author": "Simon",
"author_id": 15371,
"author_profile": "https://Stackoverflow.com/users/15371",
"pm_score": 6,
"selected": true,
"text": "public class TestClass\n{\n public static TestClass operator ??(TestClass test1, TestClass test2)\n {\n return ... | 2008/12/08 | [
"https://Stackoverflow.com/questions/349062",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/936/"
] |
349,067 | <p>There's this Excel file I want users to be able to download from my server. There must be an easy way to initiate the download of the file after a click on the "Download" button... but I have no clue how to make that happen.</p>
<p>I have this so far: (VBscript and ASP)</p>
<pre><code><head>
<script type="text/javascript" src="overzicht.js"></script>
</head>
Set fs=Server.CreateObject("Scripting.FileSystemObject")
if (fs.FileExists("c:\file.xls"))=true then 'fake filename D:
response.write("<input type='button' value='Download Masterfile' class='button' onclick='exportmasterfile();' /><br />")
else
response.write("Masterfile not found. <br />")
end if
set fs=nothing
</code></pre>
<p>The javascript function is empty.</p>
| [
{
"answer_id": 349077,
"author": "Kablam",
"author_id": 42389,
"author_profile": "https://Stackoverflow.com/users/42389",
"pm_score": 5,
"selected": true,
"text": "function exportmasterfile()\n{ var url='../documenten/Master-File.xls'; \n window.open(url,'Download'); \n}\n"
},... | 2008/12/08 | [
"https://Stackoverflow.com/questions/349067",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42389/"
] |
349,075 | <p>Hey. I have a problem with the highlighter in ComboBox. Recently I had to gray out certain items in a ComboBox and I did that by manually (programitically) drawing strings in the <strong>ComboBox</strong>. In a .NET combobox under the <strong>DrawMode.NORMAL</strong>, the lighlighter will automatically come when you click the arrow and the backcolor of the highlighter will be kinna blue by default. The problem is when we move the mouse over a item the forecolor of the hovered item changes to white, but when we draw the items manually (<strong>DrawMode.OwnerDrawVariable</strong>) it dosen't work. Can you help me with this ??</p>
<p>This is how I grayed out items,</p>
<pre><code>private void comboBox1_DrawItem(object sender, DrawItemEventArgs e)
{
e.DrawBackground();
int index = e.Index;
CombinationEntry aFunction = comboBox1.Items[index] as CombinationEntry; //CombinationEntry is a custom object to hold the gray info. Gray if not available and black if available
if (aFunction.myIsAvailable)
{
e.Graphics.DrawString(aFunction.ToString(), new Font("Arial", 10, FontStyle.Regular, GraphicsUnit.Pixel), Brushes.Black, new Point(e.Bounds.X, e.Bounds.Y));
}
else
{
e.Graphics.DrawString(aFunction.ToString(), new Font("Arial", 10, FontStyle.Regular, GraphicsUnit.Pixel), Brushes.Gray, new Point(e.Bounds.X, e.Bounds.Y));
}
}
</code></pre>
| [
{
"answer_id": 350006,
"author": "Eric Rosenberger",
"author_id": 41624,
"author_profile": "https://Stackoverflow.com/users/41624",
"pm_score": 3,
"selected": false,
"text": "SystemColors.WindowText\n"
},
{
"answer_id": 351681,
"author": "Community",
"author_id": -1,
... | 2008/12/08 | [
"https://Stackoverflow.com/questions/349075",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
349,087 | <p>I have used checkbox column in gridview. I want to check status of that checkboxes. On click of a button it should be checked that if any checkbox is checked or not. If none checkbox is checked then it should display alert message that check checkbox first.</p>
| [
{
"answer_id": 349100,
"author": "I.devries",
"author_id": 6388,
"author_profile": "https://Stackoverflow.com/users/6388",
"pm_score": 2,
"selected": false,
"text": "if(document.getElementById('checkBoxId').checked) {\n //checked\n} else {\n //not checked\n}\n"
},
{
"answer... | 2008/12/08 | [
"https://Stackoverflow.com/questions/349087",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43886/"
] |
349,092 | <p>I need to have one column as the primary key and another to auto increment an order number field. Is this possible?</p>
<p>EDIT: I think I'll just use a composite number as the order number. Thanks anyways.</p>
| [
{
"answer_id": 349137,
"author": "Eugene Yokota",
"author_id": 3827,
"author_profile": "https://Stackoverflow.com/users/3827",
"pm_score": 6,
"selected": true,
"text": "CREATE TABLE [dbo].[Foo](\n [FooId] [int] IDENTITY(1,1) NOT NULL,\n [BarId] [int] IDENTITY(1,1) NOT NULL\n)\n"
... | 2008/12/08 | [
"https://Stackoverflow.com/questions/349092",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23230/"
] |
349,094 | <p>I've been having an agruement with a friend that Mason (Perl) is not a framework, but a templating language. I feel Mason for Perl does what JSP does for Java (as an analogy, not pure technical comparison). From what I know, JSP is not a framework and I feel neither is Mason. When I looked up wikipedia <a href="http://en.wikipedia.org/wiki/Mason_%28Perl%29" rel="noreferrer">Mason (Perl)</a>, I see that the main site says it is a web application framework written in Perl while the discussion page contests it.</p>
<p>Any pointers on why it is/ it is not a framework?</p>
<p>Update based on comments from ysth:
For a framework, I feel it should at least make db access easy, manage sessions, basic security that a webapp would need, templating and code reuse (or libraries that make basic tasks easy).</p>
| [
{
"answer_id": 349124,
"author": "mat",
"author_id": 42083,
"author_profile": "https://Stackoverflow.com/users/42083",
"pm_score": 2,
"selected": false,
"text": "HTML::Template"
}
] | 2008/12/08 | [
"https://Stackoverflow.com/questions/349094",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11541/"
] |
349,108 | <p>What is the correct way of retrieving maximum values of all columns in a table with a single query? Thanks.</p>
<p>Clarification: the same query should work on any table, i.e. the column names are not to be hard-coded into it.</p>
| [
{
"answer_id": 349115,
"author": "gnud",
"author_id": 27204,
"author_profile": "https://Stackoverflow.com/users/27204",
"pm_score": 3,
"selected": false,
"text": "SELECT max(col1) as max_col1, max(col2) as max_col2 FROM `table`;\n"
},
{
"answer_id": 349163,
"author": "ysth",
... | 2008/12/08 | [
"https://Stackoverflow.com/questions/349108",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27122/"
] |
349,119 | <p>I have implemented tracing based on System.Diagnostics. </p>
<p>I am also using a System.Diagnostics.TextWriterTraceListener, and hooked the whole trace up to a MOSS 2007 Web Application. </p>
<p>The trace for some reason is trying to (a) create the log file, and/or (b) write to the log file using <strong>the user that is currently browsing the SharePoint site</strong> , is there any way to configure the logging to use a particular user account instead?</p>
| [
{
"answer_id": 349801,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": true,
"text": "var wic = WindowsIdentity.Impersonate(IntPtr.Zero); // \"revert to self\"\n/* LOG GOES HERE K */\nwic.Undo(); // return to impe... | 2008/12/08 | [
"https://Stackoverflow.com/questions/349119",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41291/"
] |
349,126 | <p>I'm running an upgrade script against a database hosted in Microsoft SQL Server. It's taking a while. Some of the queries are not worth optimising any further, for various reasons.</p>
<p>I'm the only person using this database: Is there a way that I can tell SQL Server to not bother with transactions/locking?</p>
<p>For instance, on a DELETE ... WHERE, does SQL need to get exclusive locks on the rows it's about to delete? If so, can I tell it not to bother, since this is the only running query?</p>
| [
{
"answer_id": 349193,
"author": "Eugene Yokota",
"author_id": 3827,
"author_profile": "https://Stackoverflow.com/users/3827",
"pm_score": 2,
"selected": true,
"text": "WITH (TABLOCKX)"
}
] | 2008/12/08 | [
"https://Stackoverflow.com/questions/349126",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8446/"
] |
349,127 | <p>My university refused to allow us to access out mail via POP or IMAP etc so I want to write a GTK based C app that sits in my notifcation area and does the job of a mail client notifier. Because I can't use anything like POP or IMAP, what would be a good way to do it? I guess I could scrape the HTML and look for a tag that is only present in unread mail or something?</p>
<p>Any Ideas?</p>
| [
{
"answer_id": 349177,
"author": "mat",
"author_id": 42083,
"author_profile": "https://Stackoverflow.com/users/42083",
"pm_score": 0,
"selected": false,
"text": "WWW::Mechanize"
}
] | 2008/12/08 | [
"https://Stackoverflow.com/questions/349127",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
349,142 | <p>I am developing a multi-threaded application in Cocoa. The main thread takes values from the user, and when a button is clicked I invoke a secondary thread in which a long calculation takes place. Now from this thread I have to return the output of every step of the calculation to the main thread. I want to periodically send data from one thread to the other. I can't find any simple example that does this. Any ideas?</p>
| [
{
"answer_id": 350196,
"author": "Marc Charbonneau",
"author_id": 35136,
"author_profile": "https://Stackoverflow.com/users/35136",
"pm_score": 1,
"selected": false,
"text": "performSelectorOnMainThread:withObject:waitUntilDone:"
}
] | 2008/12/08 | [
"https://Stackoverflow.com/questions/349142",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
349,155 | <p>For example, if you type something in upper-right google/yahoo search box in firefox there will be some kind 'suggested auto complete' sort of thing. </p>
<p>Another example is in youtube search box and Stackoverflow tags edit box just below this question preview. How do they work? What technology behind 'em?</p>
| [
{
"answer_id": 71302803,
"author": "Grogu",
"author_id": 12687061,
"author_profile": "https://Stackoverflow.com/users/12687061",
"pm_score": 0,
"selected": false,
"text": "$(function () {\nvar availableTags = [\n\"ActionScript\",\n\"AppleScript\",\n\"Asp\",\n\"BASIC\",\n\"C\",\n\"C++\",\... | 2008/12/08 | [
"https://Stackoverflow.com/questions/349155",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38515/"
] |
349,156 | <p>What's the regex to match a square bracket? I'm using <code>\\]</code> in a pattern in <code>eregi_replace</code>, but it doesn't seem to be able to find a <code>]</code>...</p>
| [
{
"answer_id": 349178,
"author": "Bombe",
"author_id": 43582,
"author_profile": "https://Stackoverflow.com/users/43582",
"pm_score": 3,
"selected": false,
"text": "<?php\n $hay = \"ab]cd\";\n echo eregi_replace(\"\\]\", \"e\", $hay);\n?>\n"
},
{
"answer_id": 349180,
"au... | 2008/12/08 | [
"https://Stackoverflow.com/questions/349156",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44257/"
] |
349,172 | <p>I'm thinking about SEDA. We design at the moment an application (which is running on a server as a service) which must be multithreaded and message / event based.</p>
<p>The SEDA idea is very intresting and should match. But I cannot find articles etc. writing about experiences made with it. </p>
<p>My question(s) now is(are): </p>
<ul>
<li><p>Do you use ActiveMQ, MSMQ to implement the queues or do you have a self written class which acts as queue? We have written once a thread-safe FIFO Queue class which is very helpful in a multithreaded environment.</p></li>
<li><p>Fit's the threadpool class of .NET for this or did you implement an own Threadpool / sheduler ?</p></li>
</ul>
<p>Are there any traps / good practices?</p>
| [
{
"answer_id": 349178,
"author": "Bombe",
"author_id": 43582,
"author_profile": "https://Stackoverflow.com/users/43582",
"pm_score": 3,
"selected": false,
"text": "<?php\n $hay = \"ab]cd\";\n echo eregi_replace(\"\\]\", \"e\", $hay);\n?>\n"
},
{
"answer_id": 349180,
"au... | 2008/12/08 | [
"https://Stackoverflow.com/questions/349172",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43532/"
] |
349,175 | <p>I need to convert a list (or a dict) into a comma-separated list for passing to another language.</p>
<p>Is there a nicer way of doing this than:</p>
<pre><code> result = ''
args = ['a', 'b', 'c', 'd']
i = 0
for arg in args:
if i != 0: result += arg
else: result += arg + ', '
i += 1
result = 'function (' + result + ')
</code></pre>
<p>Thanks,
Dan</p>
| [
{
"answer_id": 349182,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 4,
"selected": false,
"text": "', '.join(args)"
},
{
"answer_id": 349197,
"author": "James Hopkin",
"author_id": 11828,
"author_profile":... | 2008/12/08 | [
"https://Stackoverflow.com/questions/349175",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18909/"
] |
349,192 | <p>In a multi-threaded program running on a multi-cpu machine do I need to access shared state ( _data in the example code below) using volatile read/writes to ensure correctness.</p>
<p>In other words, can heap objects be cached on the cpu?</p>
<p>Using the example below and assuming multi-threads will access the GetValue and Add methods, I need ThreadA to be able to add data (using the Add Method) and ThreadB to be able to see/get that added data immediately (using the GetValue method). So do I need to add volatile reads/writes to _data to ensure this? Basically I don’t want to added data to be cached on ThreadA’s cpu.</p>
<p>/ I am not Locking (enforcing exclusive thread access) as the code needs to be ultra-fast and I am not removing any data from _data so I don’t need to lock _data.</p>
<p>Thanks.</p>
<p>**** Update ****************************</p>
<p>Obviously you guys think going lock-free using this example is bad idea. But what side effects or exceptions could I face here?</p>
<p>Could the Dictionary type throw an exception if 1 thread is iterating the values for read and another thread is iterating the values for update? Or would I just experience “dirty reads” (which would be fine in my case)?</p>
<p>**** End Update ****************************</p>
<pre><code>public sealed class Data
{
private volatile readonly Dictionary<string, double> _data = new Dictionary<string, double>();
public double GetVaule(string key)
{
double value;
if (!_data.TryGetValue(key, out value))
{
throw new ArgumentException(string.Format("Key {0} does not exist.", key));
}
return value;
}
public void Add(string key, double value)
{
_data.Add(key, value);
}
public void Clear()
{
_data.Clear();
}
}
</code></pre>
<hr>
<p>Thanks for the replies. Regarding the locks, the methods are pretty much constantly called by mulitple threads so my problem is with contested locks not the actual lock operation.</p>
<p>So my question is about cpu caching, can heap objects (the _data instance field) be cached on a cpu? Do i need the access the _data field using volatile reads/writes?</p>
<p>/Also, I am stuck with .Net 2.0.</p>
<p>Thanks for your help.</p>
| [
{
"answer_id": 349239,
"author": "Eugene Yokota",
"author_id": 3827,
"author_profile": "https://Stackoverflow.com/users/3827",
"pm_score": 2,
"selected": false,
"text": "ReaderWriterLockSlim"
},
{
"answer_id": 349245,
"author": "Jon Skeet",
"author_id": 22656,
"author... | 2008/12/08 | [
"https://Stackoverflow.com/questions/349192",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
349,204 | <p>I've written a simple control which basically displays a few words with an image next to it.</p>
<p>I want the containing items to strech when the parent form is resized and as you can see from my commented out code, I don't want to use a loop as it flickers.</p>
<p>Any idea on how to get the items to grow and shrink with the form in a nice way?</p>
<pre><code> public class IconListBox : FlowLayoutPanel {
private const int ITEM_PADDING = 2;
private const int MAX_IMAGE_SIZE = 64;
List<FlowLayoutPanel> _listItems;
public IconListBox() {
this.SizeChanged += new EventHandler(IconListBox_SizeChanged);
this.AutoScroll = true;
this.HorizontalScroll.Enabled = false;
this.HorizontalScroll.Visible = false;
this.VerticalScroll.Enabled = true;
this.VerticalScroll.Visible = true;
_listItems = new List<FlowLayoutPanel>();
}
void IconListBox_SizeChanged(object sender, EventArgs e) {
//foreach (FlowLayoutPanel item in _listItems) {
// item.Width = this.Width - 10;
//}
}
public void AddItem(string itemText) {
PictureBox pic = new PictureBox();
pic.Image = MyWave.Properties.Resources.mywave_icon;
pic.Width = pic.Height = MAX_IMAGE_SIZE;
pic.SizeMode = PictureBoxSizeMode.Normal;
pic.Enabled = false;
FlowLayoutPanel p = new FlowLayoutPanel();
p.Width = this.Width;
p.Height = pic.Image.Height + (ITEM_PADDING * 4);
p.BackColor = Color.White;
p.Padding = new Padding(ITEM_PADDING);
p.Margin = new Padding(0);
Label l = new Label();
l.Margin = new Padding(10, 5, 0, 0);
l.Width = this.Width - ITEM_PADDING - MAX_IMAGE_SIZE;
l.Height = p.Height - (ITEM_PADDING * 2);
l.Text = itemText;
l.Enabled = false;
//l.BorderStyle = BorderStyle.FixedSingle;
p.Controls.Add(pic);
p.Controls.Add(l);
p.MouseEnter += new EventHandler(p_MouseEnter);
p.MouseLeave += new EventHandler(p_MouseLeave);
p.MouseClick += new MouseEventHandler(p_MouseClick);
this.Controls.Add(p);
_listItems.Add(p);
p.Anchor = AnchorStyles.Right;
}
void p_MouseClick(object sender, MouseEventArgs e) {
//throw new NotImplementedException();
}
void p_MouseLeave(object sender, EventArgs e) {
((Panel)sender).BackColor = Color.White;
}
void p_MouseEnter(object sender, EventArgs e) {
((Panel)sender).BackColor = Color.LightBlue;
}
public void AddItem(string itemText, Image icon) {
}
}
</code></pre>
| [
{
"answer_id": 349244,
"author": "Treb",
"author_id": 22114,
"author_profile": "https://Stackoverflow.com/users/22114",
"pm_score": 3,
"selected": true,
"text": "foreach"
}
] | 2008/12/08 | [
"https://Stackoverflow.com/questions/349204",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17211/"
] |
349,206 | <p>I'm trying to find the actual class of a django-model object, when using model-inheritance.</p>
<p>Some code to describe the problem:</p>
<pre><code>class Base(models.model):
def basemethod(self):
...
class Child_1(Base):
pass
class Child_2(Base):
pass
</code></pre>
<p>If I create various objects of the two Child classes and the create a queryset containing them all:</p>
<pre><code>Child_1().save()
Child_2().save()
(o1, o2) = Base.objects.all()
</code></pre>
<p>I want to determine if the object is of type Child_1 or Child_2 in basemethod, I can get to the child object via o1.child_1 and o2.child_2 but that reconquers knowledge about the childclasses in the baseclass.</p>
<p>I have come up with the following code:</p>
<pre><code>def concrete_instance(self):
instance = None
for subclass in self._meta.get_all_related_objects():
acc_name = subclass.get_accessor_name()
try:
instance = self.__getattribute__(acc_name)
return instance
except Exception, e:
pass
</code></pre>
<p>But it feels brittle and I'm not sure of what happens when if I inherit in more levels.</p>
| [
{
"answer_id": 349235,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": -1,
"selected": false,
"text": "aMethod()"
},
{
"answer_id": 349494,
"author": "Daniel Naab",
"author_id": 32638,
"author_profile": "h... | 2008/12/08 | [
"https://Stackoverflow.com/questions/349206",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6093/"
] |
349,238 | <p>I had a realtivley simple ajax application, which I have broken up to be more modular. The code is at the link below, and what I have mainly done is add the GetRecordSet function and allowed fetchcompelte to take a variable for which layer to put data in. It should work fine in thery. When I put alert()s in, the code seems to execute, except for inside either of the if clauses in fetchcomplete.</p>
<p><a href="http://www.nomorepasting.com/getpaste.php?pasteid=22558" rel="nofollow noreferrer">http://www.nomorepasting.com/getpaste.php?pasteid=22558</a></p>
<p>This is the code for get_records.php, which again seems like it should be fine</p>
<p><a href="http://www.nomorepasting.com/getpaste.php?pasteid=22559" rel="nofollow noreferrer">http://www.nomorepasting.com/getpaste.php?pasteid=22559</a></p>
<p>and this is the original index php file</p>
<p><a href="http://www.nomorepasting.com/getpaste.php?pasteid=22560" rel="nofollow noreferrer">http://www.nomorepasting.com/getpaste.php?pasteid=22560</a></p>
| [
{
"answer_id": 349235,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": -1,
"selected": false,
"text": "aMethod()"
},
{
"answer_id": 349494,
"author": "Daniel Naab",
"author_id": 32638,
"author_profile": "h... | 2008/12/08 | [
"https://Stackoverflow.com/questions/349238",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1246613/"
] |
349,248 | <p>I am using <code>cvs -tag -b "abcdefg"</code> command to tag-branch in my CVS. My CSV repo has an empty directory "obj" in every folder. </p>
<p>Whenever I use the command <code>cvs co -r "abcdefg" REPO</code>, I get a complete repo minus the empty folders. I tried using <code>-f</code> option too but it did not work. What is the way to get out of this?</p>
| [
{
"answer_id": 349275,
"author": "Ulf Lindback",
"author_id": 30354,
"author_profile": "https://Stackoverflow.com/users/30354",
"pm_score": 0,
"selected": false,
"text": "co -P\n"
}
] | 2008/12/08 | [
"https://Stackoverflow.com/questions/349248",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20958/"
] |
349,250 | <p>As the question says, it just escaped my memory how to display xml in javascript, I want to display some source xml within an div on a page, that sits next to the processed result of the xml in another div.</p>
<p>Can't remember if there was an equivalent to javascript's escape to convert entities on the client </p>
<p><strong>Note</strong>: the xml files are served as is from the server, so I need a client side solution</p>
<p><strong>Note</strong>: the main problem is XML doesn't render correctly in most browsers, all the brackets and attributes disappear, leaving you with text that doesn't look like xml</p>
| [
{
"answer_id": 349264,
"author": "J c",
"author_id": 25837,
"author_profile": "https://Stackoverflow.com/users/25837",
"pm_score": 2,
"selected": false,
"text": "<iframe src=\"/myapp/Document1.xml\"><iframe src=\"/myapp/Document2.xml\">\n"
},
{
"answer_id": 349295,
"author": ... | 2008/12/08 | [
"https://Stackoverflow.com/questions/349250",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15124/"
] |
349,251 | <p>I need to get a count of the number of files in a directory. I could get the names of all the files in the directory using <code>System.IO.Directory.GetFiles()</code> and take the length of that array but that takes too long on large directories. Is there a way to get just the count without having to get the names?</p>
| [
{
"answer_id": 349412,
"author": "abatishchev",
"author_id": 41956,
"author_profile": "https://Stackoverflow.com/users/41956",
"pm_score": 3,
"selected": false,
"text": "LARGE_INTEGER i1, i2; \n\nQueryPerformanceCounter(&i1); \n\nint count = IO::Directory::GetFiles(L\"c:\\\\w... | 2008/12/08 | [
"https://Stackoverflow.com/questions/349251",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15371/"
] |
349,256 | <p>When is a good idea to save information in a XML file and when in a own-format file?</p>
<p>For XML (or other standard) I see:</p>
<ul>
<li>(+) Standard format.</li>
<li>(-) It's tedious to hand modify.</li>
</ul>
<p>For own-format files I see:</p>
<ul>
<li>(-) We need to build a own-parser (non-standard).</li>
<li>(+) It can be easy to hand modify the files.</li>
</ul>
| [
{
"answer_id": 350555,
"author": "Rich",
"author_id": 28442,
"author_profile": "https://Stackoverflow.com/users/28442",
"pm_score": 0,
"selected": false,
"text": "<?xml-stylesheet type=\"text/xsl\" href=\"config-documentation.xsl\"?>\n"
},
{
"answer_id": 350700,
"author": "Ad... | 2008/12/08 | [
"https://Stackoverflow.com/questions/349256",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40441/"
] |
349,257 | <p>Is there a way to detect the true border, padding and margin of elements from Javascript code? If you look at the following code:</p>
<pre><code><html>
<head>
<style>
<!--
.some_class {
padding-left: 2px;
border: 2px solid green;
}
-->
</style>
<script>
<!--
function showDetails()
{
var elem = document.getElementById("my_div");
alert("elem.className=" + elem.className);
alert("elem.style.padding=" + elem.style.padding);
alert("elem.style.paddingLeft=" + elem.style.paddingLeft);
alert("elem.style.margin=" + elem.style.margin);
alert("elem.style.marginLeft=" + elem.style.marginLeft);
alert("elem.style.border=" + elem.style.border);
alert("elem.style.borderLeft=" + elem.style.borderLeft);
}
-->
</script>
</head>
<body>
<div id="my_div" class="some_class" style="width: 300px; height: 300px; margin-left: 4px;">
some text here
</div>
<button onclick="showDetails();">show details</button>
</body>
</html>
</code></pre>
<p>you can see, if you click the button, that the padding is not reported right. Only the properties defined directly through "style" are reported back, those defined through a CSS class are not reported.</p>
<p>Is there a way to get back the final values of these properties? I mean the values obtained after all CSS settings are computed and applied by the browser.</p>
| [
{
"answer_id": 1280733,
"author": "vsync",
"author_id": 104380,
"author_profile": "https://Stackoverflow.com/users/104380",
"pm_score": 3,
"selected": false,
"text": "var $elm = $('.box');\nvar hPadding = $elm.outerWidth() - $elm.width();\nvar vPadding = $elm.outerHeight() - $elm.height(... | 2008/12/08 | [
"https://Stackoverflow.com/questions/349257",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11384/"
] |
349,260 | <p>I used a query a few weeks ago in MySQL that described a table and suggested possible improvements to its structure. For example, if I have an int field but only the numbers 1-3 in that field, it will suggest set(1,2,3) as the type.</p>
<p>I think I was using phpMyAdmin but I've been through all the functions I can find - Analyze, Describe, Explain, Optimize, etc - to no avail. I can't for the life of me remember what the query was!</p>
| [
{
"answer_id": 349273,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 6,
"selected": true,
"text": "SELECT *\nFROM `table_name`\nPROCEDURE ANALYSE ( ) \n"
}
] | 2008/12/08 | [
"https://Stackoverflow.com/questions/349260",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37947/"
] |
349,286 | <p>I am using ASP.NET membership for the authentication of my web app. This worked great for me. I now have to implement password expiration.</p>
<p>If the password has expired the user should be redirected to <code>ChangePassword</code> screen and should not be allowed access to any other part of the application without changing the password.</p>
<p>There are many aspx pages. One solution could be to redirect to the <code>ChangePassword</code> screen <code>OnInit</code> of every aspx if the password has expired. Is there any other solutions or recommendations.</p>
<p>Thanks,
Jai</p>
| [
{
"answer_id": 1177869,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": false,
"text": "LoggingIn"
},
{
"answer_id": 6705094,
"author": "Andrew",
"author_id": 5662,
"author_profile": "https://S... | 2008/12/08 | [
"https://Stackoverflow.com/questions/349286",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44272/"
] |
349,291 | <p>How do I convert a datetime field in Grails to just date, with out capturing the time? I need to do this for comparison with system date. </p>
<pre><code>class Trip
{
String name
String city
Date startDate
Date endDate
String purpose
String notes
static constraints = {
name(maxLength: 50, blank: false)
startDate(validator: {return (it >= new Date())}) // This won't work as it compares the time as well
city(maxLength: 30, blank: false)
}
}
</code></pre>
| [
{
"answer_id": 349421,
"author": "Samiksha",
"author_id": 29515,
"author_profile": "https://Stackoverflow.com/users/29515",
"pm_score": 1,
"selected": false,
"text": "* format (required) - The format to use for the date\n* date (required) - The date object to format\n"
},
{
"answ... | 2008/12/08 | [
"https://Stackoverflow.com/questions/349291",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11193/"
] |
349,322 | <p>I've been handing a design for a webpage which I'm trying to implement correctly. This design contains navigation elements which are partially or entirely duplicated all over the page - in particular, links to the main 3 categories for navigation are present on the page no less than 4 times.</p>
<p>I'm no web design expert, but I don't like the idea of having the same content duplicated in the html. Can I use CSS so that my html contains a single list of navigation links in a sane format, but the standard browser view contains multiple partial duplicates?</p>
<p>(Also, assuming this is possible, is it a good idea? or would I be better just getting used to the idea that my html is going to contain the same links 4 times?)</p>
<p>EDIT: Actually generating the nav links is not an issue; I was looking to clean up the output html</p>
| [
{
"answer_id": 15838669,
"author": "ScottS",
"author_id": 369707,
"author_profile": "https://Stackoverflow.com/users/369707",
"pm_score": 5,
"selected": true,
"text": "<a></a>"
},
{
"answer_id": 15870759,
"author": "nexus_07",
"author_id": 1787585,
"author_profile": "... | 2008/12/08 | [
"https://Stackoverflow.com/questions/349322",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12744/"
] |
349,348 | <p>I have the following JavaScript code:
<a href="http://www.nomorepasting.com/getpaste.php?pasteid=22561" rel="nofollow noreferrer">Link</a></p>
<p>In which the function makewindows does not seem to be working.</p>
<p>It does actual create a window, however the html either contains what is quotes, or if I change it to</p>
<pre><code>child1.document.write(json_encode($row2["ARTICLE_DESC"]));
</code></pre>
<p>to create a blank html page.</p>
<p>I moved this function to my main JavaScript file to include because I was getting errors before, but now no HTML is presented in the popupwindow. Is this because I am not retrieving article_Desc in thest3.php?</p>
<p>The other 2 files used are here:
<a href="http://www.nomorepasting.com/getpaste.php?pasteid=22562" rel="nofollow noreferrer">link</a>
and <a href="http://www.nomorepasting.com/getpaste.php?pasteid=22563" rel="nofollow noreferrer">test3.php</a></p>
| [
{
"answer_id": 349363,
"author": "Irmantas",
"author_id": 43182,
"author_profile": "https://Stackoverflow.com/users/43182",
"pm_score": 2,
"selected": false,
"text": "child1.document.write(<?php echo json_encode($row2[\"ARTICLE_DESC\"]); ?>);\n"
},
{
"answer_id": 349448,
"aut... | 2008/12/08 | [
"https://Stackoverflow.com/questions/349348",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1246613/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.