qid int64 4 22.2M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
176,411 | <p>A question about different methods of outputting html from PHP; what are the performance differences between these:</p>
<p>Method 1 - variable concatenation</p>
<pre><code>$html = '';
$html .= '<ul>';
for ($k = 1; $k < = 1000; $k++){
$html .= '<li> This is list item #'.$k.'</li>';
}
$html .= '</ul>';
echo $html;
</code></pre>
<p>Method 2 - output buffering</p>
<pre><code>ob_start();
echo '<ul>';
for ($k = 1; $k < = 1000; $k++){
echo '<li> This is list item #',$k,'</li>';
}
echo '</ul>';
</code></pre>
<p>I suspect you get some performance hit from continually modifying and enlarging a variable; is that correct?</p>
<p>Cheers!</p>
<p>Thanks GaryF, but I don't want an answer about architecture - this question is about performance. There seem to be some different opinions / testing about which one is faster, which is why there is not an accepted answer as yet.</p>
| [
{
"answer_id": 176434,
"author": "Darryl Hein",
"author_id": 5441,
"author_profile": "https://Stackoverflow.com/users/5441",
"pm_score": 2,
"selected": false,
"text": "<?php"
},
{
"answer_id": 176458,
"author": "Erik van Brakel",
"author_id": 909,
"author_profile": "h... | 2008/10/06 | [
"https://Stackoverflow.com/questions/176411",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2027/"
] |
176,440 | <p>I have a filter in a combobox with a number of entries. Instead of filtering the datagrid with an exact match, I would like to take the selected value and only display records where the selected value is contained in the datafield.
For example: the user selects a value of "New" and the datagrid displays records where the contents of the record could be "New User", "New Person", "This one is New" etc.
I think that I need to use RegExp, but I cant work out how to get it to work.
Thanks in advance,
S... </p>
| [
{
"answer_id": 176606,
"author": "JustLogic",
"author_id": 21664,
"author_profile": "https://Stackoverflow.com/users/21664",
"pm_score": 2,
"selected": false,
"text": " public function filter(item:Object):Boolean{\n var result:Boolean=false;\n if (item.name.toUpperCase().in... | 2008/10/06 | [
"https://Stackoverflow.com/questions/176440",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25463/"
] |
176,446 | <p>Why do I get compiler errors with this Java code?</p>
<pre><code>1 public List<? extends Foo> getFoos()
2 {
3 List<? extends Foo> foos = new ArrayList<? extends Foo>();
4 foos.add(new SubFoo());
5 return foos;
6 }</code></pre>
<p>Where 'SubFoo' is a concrete class that implements Foo, and Foo is an interface.</p>
<p>Errors I get with this code:</p>
<ul>
<li>On Line 3: "Cannot instantiate ArrayList<? extends Foo>"</li>
<li>On Line 4: "The method add(capture#1-of ? extends Foo) in the type List<capture#1-of ? extends Foo> is not applicable for the arguments (SubFoo)"</li>
</ul>
<p><b>Update:</b> Thanks to Jeff C, I can change Line 3 to say "new ArrayList<Foo>();". But I'm still having the issue with Line 4.</p>
| [
{
"answer_id": 176478,
"author": "erickson",
"author_id": 3474,
"author_profile": "https://Stackoverflow.com/users/3474",
"pm_score": 6,
"selected": true,
"text": "1 public List<? extends Foo> getFoos()\n2 {\n3 List<Foo> foos = new ArrayList<Foo>(); /* Or List<SubFoo> */\n4 foos.... | 2008/10/06 | [
"https://Stackoverflow.com/questions/176446",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2197/"
] |
176,459 | <p>Here are the declarations of the variables:</p>
<pre><code>string strFirstName;
string strLastName;
string strAddress;
string strCity;
string strState;
double dblSalary;
string strGender;
int intAge;
</code></pre>
<p>...Do some "cin" statements to get data...</p>
<pre><code>retcode = SQLPrepare(StatementHandle, (SQLCHAR *)"INSERT INTO EMPLOYEE ([FirstName], [LastName], [Address], [City], [State], [Salary], [Gender],[Age]) VALUES (?,?,?,?,?,?,?,?)", SQL_NTS);
retcode = SQLBindParameter(StatementHandle, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, 50, 0 &strFirstName,0, NULL);
retcode = SQLBindParameter(StatementHandle, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, 50, 0, &strLastName,0, NULL);
retcode = SQLBindParameter(StatementHandle, 3, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, 30, 0, &strAddress,0, NULL);
retcode = SQLBindParameter(StatementHandle, 4, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, 30, 0, &strCity,0, NULL);
retcode = SQLBindParameter(StatementHandle, 5, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, 3, 0, &strState,0, NULL);
retcode = SQLBindParameter(StatementHandle, 6, SQL_PARAM_INPUT, SQL_C_DOUBLE, SQL_DOUBLE, 0, 0, &dblSalary,0, NULL);
retcode = SQLBindParameter(StatementHandle, 7, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, 2, 0, &strGender,0, NULL);
retcode = SQLBindParameter(StatementHandle, 8, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, &intAge,0, NULL);
retcode = SQLExecute(StatementHandle);
</code></pre>
<p>The int and double work fine and get stored in the table...but I can't figure out how to get the strings to store...</p>
| [
{
"answer_id": 176509,
"author": "1800 INFORMATION",
"author_id": 3146,
"author_profile": "https://Stackoverflow.com/users/3146",
"pm_score": 4,
"selected": true,
"text": "ParameterValuePtr"
}
] | 2008/10/06 | [
"https://Stackoverflow.com/questions/176459",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25642/"
] |
176,476 | <p>I've been using htmldoc for a while, but I've run into some fairly serious limitations. I need the end solution to work on a Linux box. I'll be calling this library/utility/application from a Perl app, so any Perl interfaces would be a bonus.</p>
| [
{
"answer_id": 29335384,
"author": "MrTux",
"author_id": 3906760,
"author_profile": "https://Stackoverflow.com/users/3906760",
"pm_score": 1,
"selected": false,
"text": "phantomjs rasterize.js 'http://en.wikipedia.org/w/index.php?title=Jakarta&printable=yes' jakarta.pdf\n"
},
{
"... | 2008/10/06 | [
"https://Stackoverflow.com/questions/176476",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2901/"
] |
176,479 | <p>I have a image upload form that should take image types (PNG, JPEG, GIF), resize it and then save it to a path. </p>
<p>For some reason I can't get the PNG file types to work, it works fine with JPEG/GIF and the file is copied so it looks like it's something to do with how I'm creating the PNG. </p>
<p>Does PNG creation in PHP require different parameters or options? Some sample code of lines that do image creation:</p>
<pre><code>$src = imagecreatefrompng($uploadedfile);
imagecreatetruecolor($newWidth,$newHeight)
imagecopyresampled($tmp,$src,0,0,0,0,$newWidth,$newHeight,$width,$height);
imagepng($tmp,$destinationPath."/".$destinationFile,100);
</code></pre>
<p>The same commands work for JPG and GIF.</p>
| [
{
"answer_id": 176513,
"author": "DreamWerx",
"author_id": 15487,
"author_profile": "https://Stackoverflow.com/users/15487",
"pm_score": 2,
"selected": false,
"text": "GD Support enabled\nGD Version bundled (2.0.28 compatible) \nPNG Support enabled \n"
},
{
"answer_id": 176... | 2008/10/06 | [
"https://Stackoverflow.com/questions/176479",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
176,504 | <p>New to visual studio and programing in general.</p>
<p>I am starting to work on a asp.net project. At home I have a computer running Windows 2008 Server with SQL 2008 and Visual 2008 running.</p>
<p>I want to install the same thing on my laptop win2008/sql2008/vs2008 so I can take it with me on the go.</p>
<p>What I want to know is how would I synchronized the two, where projects would syncrhonized to my laptop and I can take it on the go, then when i return and connect it to my network, it synchronizes back to my main workstation so the two are always the same?</p>
| [
{
"answer_id": 176894,
"author": "Pablo Venturino",
"author_id": 16732,
"author_profile": "https://Stackoverflow.com/users/16732",
"pm_score": 0,
"selected": false,
"text": "\\\\my_workstation\\path\\to\\project"
}
] | 2008/10/06 | [
"https://Stackoverflow.com/questions/176504",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25631/"
] |
176,512 | <p>In short, how do you unit test an error condition such as EINTR on a system call.</p>
<p>One particular example I'm working on, which could be a case all by itself, is whether it's necessary to call fclose again when it returns EOF with (errno==EINTR). The behavior depends on the implementation of fclose:</p>
<pre><code>// Given an open FILE *fp
while (fclose(fp)==EOF && errno==EINTR) {
errno = 0;
}
</code></pre>
<p>This call can be unsafe if fp freed when EINTR occurs. How can I test the error handling for when (errno==EINTR)?</p>
| [
{
"answer_id": 176821,
"author": "bmdhacks",
"author_id": 14032,
"author_profile": "https://Stackoverflow.com/users/14032",
"pm_score": 2,
"selected": false,
"text": "int scull_release(struct inode *inode, struct file *filp)\n{\n return -EINTR;\n}\n"
},
{
"answer_id": 177001,
... | 2008/10/06 | [
"https://Stackoverflow.com/questions/176512",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24310/"
] |
176,514 | <p>What is meant by <code>nvarchar</code>?</p>
<p>What is the difference between <code>char</code>, <code>nchar</code>, <code>varchar</code>, and <code>nvarchar</code> in SQL Server?</p>
| [
{
"answer_id": 176565,
"author": "Brian Kim",
"author_id": 5704,
"author_profile": "https://Stackoverflow.com/users/5704",
"pm_score": 11,
"selected": true,
"text": "nchar"
},
{
"answer_id": 1660254,
"author": "ss.",
"author_id": 200846,
"author_profile": "https://Sta... | 2008/10/06 | [
"https://Stackoverflow.com/questions/176514",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22471/"
] |
176,527 | <p>I need to enumerate all classes in a package and add them to a List. The non-dynamic version for a single class goes like this:</p>
<pre><code>List allClasses = new ArrayList();
allClasses.add(String.class);
</code></pre>
<p>How can I do this dynamically to add all classes in a package and all its subpackages?</p>
<hr>
<p><strong><em>Update:</em></strong> Having read the early answers, it's absolutely true that I'm trying to solve another secondary problem, so let me state it. And I know this is possible since other tools do it. See new question <a href="https://stackoverflow.com/questions/176913/how-can-i-run-all-unit-tests-except-those-ending-in-integrationtest-in-my-intel">here</a>. </p>
<p><strong><em>Update:</em></strong> Reading this again, I can see how it's being misread. I'm looking to enumerate all of MY PROJECT'S classes from the file system after compilation. </p>
| [
{
"answer_id": 3527428,
"author": "Dave Dopson",
"author_id": 407731,
"author_profile": "https://Stackoverflow.com/users/407731",
"pm_score": 6,
"selected": true,
"text": "private static ArrayList<Class<?>> getClassesForPackage(Package pkg) {\n String pkgname = pkg.getName();\n Arr... | 2008/10/06 | [
"https://Stackoverflow.com/questions/176527",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13041/"
] |
176,545 | <p>I am going to be starting a javascript reporting engine for my website, and have started some prototyping using MooTools. I really like being able to do things like this:</p>
<pre><code>function showLeagues(leagues) {
var leagueList = $("leagues");
leagueList.empty();
for(var i = 0; i<leagues.length; ++i) {
var listItem = getLeagueListElement(leagues[i]);
leagueList.adopt(listItem);
}
}
function getLeagueListElement(league) {
var listItem = new Element('li');
var newElement = new Element('a', {
'html': league.name,
'href': '?league='+league.key,
'events': {
'click': function() { showLeague(league); return false; }
}
});
listItem.adopt(newElement);
return listItem;
}
</code></pre>
<p>From what I've seen, jQuery's "adopt" type methods only take html strings or DOM Elements. Is there any jQuery equivalent to MooTools' <a href="http://mootools.net/docs/Element/Element#Element:constructor" rel="nofollow noreferrer">Element</a>?
<hr/>
EDIT: The big thing I'm looking for here is the programmatic attachment of my click event to the link.</p>
| [
{
"answer_id": 176567,
"author": "nickf",
"author_id": 9021,
"author_profile": "https://Stackoverflow.com/users/9021",
"pm_score": 2,
"selected": false,
"text": "function showLeagues(leagues) {\n var $leagueList = $(\"#leagues\");\n $leagueList.empty();\n $.each(leagues, functio... | 2008/10/06 | [
"https://Stackoverflow.com/questions/176545",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/96/"
] |
176,559 | <p>In the Google C++ Style Guide, there's a section on <a href="http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Operator_Overloading" rel="noreferrer">Operator Overloading</a> that has a curious statement:</p>
<blockquote>
<p>Overloading also has surprising
ramifications. For instance, you can't
forward declare classes that overload
<code>operator&</code>.</p>
</blockquote>
<p>This seems incorrect, and I haven't been able to find any code that causes GCC to have a problem with it. Does anyone know what that statement is referring to?</p>
| [
{
"answer_id": 176581,
"author": "Lou Franco",
"author_id": 3937,
"author_profile": "https://Stackoverflow.com/users/3937",
"pm_score": 0,
"selected": false,
"text": "class A;\n\nvoid f(A& x) {\n A* xPointer = &x;\n}\n"
},
{
"answer_id": 176640,
"author": "Pete Kirkham",
... | 2008/10/06 | [
"https://Stackoverflow.com/questions/176559",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12193/"
] |
176,572 | <p>I have a UI widget that needs to be put in an IFRAME both for performance reasons and so we can syndicate it out to affiliate sites easily. The UI for the widget includes tool-tips that display over the top of other page content. See screenshot below or <strong><a href="http://www.bookabach.co.nz/" rel="noreferrer">go to the site</a></strong> to see it in action. Is there any way to make content from within the IFRAME overlap the parent frame's content?</p>
<p><img src="https://i.stack.imgur.com/8rAnj.png" alt="Tool-tip content needs to overlap parent frame content"></p>
| [
{
"answer_id": 176670,
"author": "Luke Bennett",
"author_id": 17602,
"author_profile": "https://Stackoverflow.com/users/17602",
"pm_score": 1,
"selected": false,
"text": "<script>"
}
] | 2008/10/06 | [
"https://Stackoverflow.com/questions/176572",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11577/"
] |
176,625 | <p>I have the following query in iSeries SQL which I output to a file.</p>
<pre><code>SELECT SSLOTMAK, SSLOTMDL, SSLOTYER, sum(SSCOUNT)
FROM prqhdrss
GROUP BY SSLOTMAK, SSLOTMDL, SSLotyer
HAVING sum(SSCOUNT) > 4
ORDER BY SSLOTMAK, SSLOTMDL, SSLOTYER
</code></pre>
<p>When I run it, the field created be the sum(SSCOUNT) is a 31 Packed field. This does not allow me to send it to my PC. How can I force SQL to create the field as a non-packed field.</p>
| [
{
"answer_id": 177635,
"author": "pmg",
"author_id": 25324,
"author_profile": "https://Stackoverflow.com/users/25324",
"pm_score": 3,
"selected": true,
"text": "SELECT SSLOTMAK, SSLOTMDL, SSLOTYER, cast(sum(SSCOUNT) as integer)\nFROM prqhdrss\nGROUP BY SSLOTMAK, SSLOTMDL, SSLotyer\nHAVIN... | 2008/10/06 | [
"https://Stackoverflow.com/questions/176625",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11270/"
] |
176,627 | <p>I run into this quite often where a new page is supposedly "tested" and ready to go. But as soon as I change the page from http to https (secure) mode I get the "This page contains both secure and nonsecure items." error.</p>
<p>Usually I can find the problem and fix it pretty quick. Today is different. I've checked every image reference and every javascript reference and their source and haven't found anything that should be causing this error.</p>
<p>Are there any developer tools or techniques that can point out specifically what is causing this error?</p>
| [
{
"answer_id": 176651,
"author": "John Millikin",
"author_id": 3560,
"author_profile": "https://Stackoverflow.com/users/3560",
"pm_score": 1,
"selected": false,
"text": "<script>"
}
] | 2008/10/06 | [
"https://Stackoverflow.com/questions/176627",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3747/"
] |
176,673 | <p>If I have a datetime field, how do I get just records created later than a certain time, ignoring the date altogether?</p>
<p>It's a logging table, it tells when people are connecting and doing something in our application. I want to find out how often people are on later than 5pm. </p>
<p>(Sorry - it is SQL Server. But this could be useful for other people for other databases)</p>
| [
{
"answer_id": 176684,
"author": "Thilo",
"author_id": 14955,
"author_profile": "https://Stackoverflow.com/users/14955",
"pm_score": 3,
"selected": false,
"text": "SELECT * FROM TABLE \n WHERE TO_CHAR(THE_DATE, 'HH24:MI:SS') BETWEEN '17:00:00' AND '23:59:59';\n"
},
{
"answer_id"... | 2008/10/06 | [
"https://Stackoverflow.com/questions/176673",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22523/"
] |
176,695 | <p>The attached screenshot is from OS X/Firefox 3. Note that the center tab (an image) has a dotted line around it, apparently because it was the most-recently selected tab. Is there a way I can eliminate this dotted line in CSS or JavaScript? (Hmmm...the free image hosting service has reduced the size of the image. But if you could see it, you'd notice a dotted-line select area around the block.)</p>
<p><a href="http://www.freeimagehosting.net/uploads/th.fadf78173b.png" rel="nofollow noreferrer">Screen Shot http://www.freeimagehosting.net/uploads/th.fadf78173b.png</a></p>
| [
{
"answer_id": 176719,
"author": "Dave Rutledge",
"author_id": 2486915,
"author_profile": "https://Stackoverflow.com/users/2486915",
"pm_score": 5,
"selected": true,
"text": "a:active, a:focus { outline-style: none; -moz-outline-style:none; }\n"
},
{
"answer_id": 176725,
"aut... | 2008/10/06 | [
"https://Stackoverflow.com/questions/176695",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17307/"
] |
176,709 | <p>I have a set of configuration items I need to persist to a "human readable" file. These items are in a hierarchy:</p>
<pre>
Device 1
Name
Channel 1
Name
Size
...
Channel N
Name
...
Device M
Name
Channel 1
</pre>
<p>Each of these item could be stored in a Dictionary with a string Key and a value. They could also be in a structure/DTO.</p>
<p>I don't care about the format of the file as long as it's human readable. It could be XML or it could have something more like INI format</p>
<pre>
[Header]
Key=value
Key2=value
...
</pre>
<p>Is there a way to minimize the amount of boiler plate code I would need to write to manage storing/reading configuration items?</p>
<p>Should I just create Data Transfer Objects (DTO)/structures and mark them serializable (Does that generate bloated XML still human readable?)</p>
<p>Is there other suggestions?</p>
<p>Edit: Not that the software has to <strong>write</strong> as well as <strong>read</strong> the config. That leaves app.config out.</p>
| [
{
"answer_id": 176776,
"author": "Ron Savage",
"author_id": 12476,
"author_profile": "https://Stackoverflow.com/users/12476",
"pm_score": 0,
"selected": false,
"text": "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n<configuration>\n<!--*****************************************************... | 2008/10/06 | [
"https://Stackoverflow.com/questions/176709",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10703/"
] |
176,712 | <p>I'd like to find the base url of my application, so I can automatically reference other files in my application tree...</p>
<p>So given a file config.php in the base of my application, if a file in a subdirectory includes it, knows what to prefix a url with. </p>
<pre><code>application/config.php
application/admin/something.php
application/css/style.css
</code></pre>
<p>So given that <code>http://www.example.com/application/admin/something.php</code> is accessed, I want it to be able to know that the css file is in <code>$approot/css/style.css</code>. In this case, <code>$approot</code> is "<code>/application</code>" but I'd like it to know if the application is installed elsewhere.</p>
<p>I'm not sure if it's possible, many applications (phpMyAdmin, Squirrelmail I think) have to set a config variable to begin with. It would be more user friendly if it just knew.</p>
| [
{
"answer_id": 176730,
"author": "Jay",
"author_id": 20840,
"author_profile": "https://Stackoverflow.com/users/20840",
"pm_score": 2,
"selected": false,
"text": "<?php\n echo dirname($_SERVER[\"REQUEST_URI\"]);\n?>\n"
},
{
"answer_id": 176736,
"author": "Lucas Oman",
"a... | 2008/10/06 | [
"https://Stackoverflow.com/questions/176712",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14253/"
] |
176,720 | <p>What is the easiest way to do this? Is it possible with managed code?</p>
| [
{
"answer_id": 176734,
"author": "Geoff",
"author_id": 10427,
"author_profile": "https://Stackoverflow.com/users/10427",
"pm_score": 6,
"selected": true,
"text": "this.BackgroundImage = //Image\nthis.FormBorderStyle = FormBorderStyle.None;\nthis.Width = this.BackgroundImage.Width;\nthis.... | 2008/10/06 | [
"https://Stackoverflow.com/questions/176720",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4386/"
] |
176,743 | <p>I'm writing a .NET forms control to edit HTML using MSHTML. I am creating some custom elements and want to make them effectively read-only. I thought I could go about this by focusing on the entire element any time focus entered anywhere in that element but the HtmlElement.Focus() doesn't select the entire element and I don't seem to be able to capture entry of the cursor.</p>
<p>Another option would be to raise an event whenever the text of the element is changed (on KeyDown I expect) but I can't get that event to fire, either. Any ideas about why my expectations about event behavior is wrong or alternate suggestions for implementation?</p>
| [
{
"answer_id": 179506,
"author": "dmo",
"author_id": 1807,
"author_profile": "https://Stackoverflow.com/users/1807",
"pm_score": 2,
"selected": true,
"text": "contentEditable=false\n"
}
] | 2008/10/06 | [
"https://Stackoverflow.com/questions/176743",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1807/"
] |
176,745 | <p>Given an aggregation of class instances which refer to each other in a complex, circular, fashion: is it possible that the garbage collector may not be able to free these objects?</p>
<p>I vaguely recall this being an issue in the JVM in the past, but I <em>thought</em> this was resolved years ago. yet, some investigation in jhat has revealed a circular reference being the reason for a memory leak that I am now faced with.</p>
<p><em>Note: I have always been under the impression that the JVM was capable of resolving circular references and freeing such "islands of garbage" from memory. However, I am posing this question just to see if anyone has found any exceptions.</em> </p>
| [
{
"answer_id": 15748185,
"author": "Rupesh",
"author_id": 1270989,
"author_profile": "https://Stackoverflow.com/users/1270989",
"pm_score": 2,
"selected": false,
"text": "class A {\nprivate B b;\n\npublic void setB(B b) {\n this.b = b;\n}\n}\n\nclass B {\nprivate A a;\n\npublic void s... | 2008/10/06 | [
"https://Stackoverflow.com/questions/176745",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9931/"
] |
176,749 | <p>I have a web service that uses Python's SimpleJSON to serialize JSON, and a javascript/ client that uses Google's Visualization <a href="http://code.google.com/apis/visualization/documentation/reference.html" rel="nofollow noreferrer">API</a>. When I try to read in the JSON response using Google Data Table's Query method, I am getting a "invalid label" error. </p>
<p>I noticed that Google spreadsheet outputs JSON without quotes around the object keys. I tried reading in JSON without the quotes and that works. I was wondering what was the best way to get SimpleJSON output to be read into Google datable using </p>
<p><code>query = new google.visualization.Query("http://www.myuri.com/api/")</code>. </p>
<p>I could use a regex to remove the quotes, but that seems sloppy. The javascript JSON parsing libraries I've tried won't read in JSON syntax without quotes around the object keys.</p>
<p>Here's some good background reading re: quotes around object keys: </p>
<p><a href="http://simonwillison.net/2006/Oct/11/json/" rel="nofollow noreferrer">http://simonwillison.net/2006/Oct/11/json/</a>.</p>
| [
{
"answer_id": 176780,
"author": "John Millikin",
"author_id": 3560,
"author_profile": "https://Stackoverflow.com/users/3560",
"pm_score": 3,
"selected": true,
"text": "google.visualization.Query.setResponse(\n{requestId:'0',status:'ok',signature:'1464883469881501252',\ntable:{cols: [{id... | 2008/10/07 | [
"https://Stackoverflow.com/questions/176749",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1227001/"
] |
176,774 | <p>I have 2 tables. Table1 has fields A, B, C, D and Table2 has fields A, B. Field A and B of both tables have same record type. I would like to grab the records from both tables of fields A and B as single result.</p>
<p>Is there any Query or Function in PHP+MySql?</p>
<p>Thanks...</p>
| [
{
"answer_id": 176794,
"author": "paxdiablo",
"author_id": 14860,
"author_profile": "https://Stackoverflow.com/users/14860",
"pm_score": 3,
"selected": false,
"text": "select a,b from table1\n where <where-clause>\nunion all select a,b from table2\n where <where-clause>\n"
},
{... | 2008/10/07 | [
"https://Stackoverflow.com/questions/176774",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22962/"
] |
176,775 | <p>Currently I am <a href="http://msdn.microsoft.com/en-us/magazine/cc163696.aspx" rel="noreferrer">borrowing <code>java.math.BigInteger</code> from the J# libraries as described here</a>. Having never used a library for working with large integers before, this seems slow, on the order of 10 times slower, even for <code>ulong</code> length numbers. Does anyone have any better (preferably free) libraries, or is this level of performance normal?</p>
| [
{
"answer_id": 498820,
"author": "Steve Severance",
"author_id": 41717,
"author_profile": "https://Stackoverflow.com/users/41717",
"pm_score": 3,
"selected": false,
"text": "F#"
},
{
"answer_id": 1019202,
"author": "Rasmus Faber",
"author_id": 5542,
"author_profile": ... | 2008/10/07 | [
"https://Stackoverflow.com/questions/176775",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15537/"
] |
176,777 | <p>I'm trying to build a proxy module for .NET, but I'm having trouble copying the Headers from the current request to the new request. I am setting the headers of the new request, because I want the proxy to support SOAP requests. Here is a portion of my code. I can post everything if need, but this is the only part that seems related to the issue I am having:</p>
<pre>
<code>
HttpApplication app = (HttpApplication)sender; // sender from context.BeginRequest event
HttpRequest crntReq = app.Request; // set a reference to request object for easier access
HttpWebRequest proxyReq = (HttpWebRequest)HttpWebRequest.Create(crntReq.Url.AbsoluteUri);
// parse headers from current httpcontext.request.headers and add each name->value to the
// new request object
foreach (string header in crntReq.Headers)
{
proxyReq.Headers.Add(header, crntReq.Headers[header]); // throws exception :(
}
</code>
</pre>
<p><br /></p>
<p>When my code hits the foreach loop, it throws an exception for the Headers.Add function. I'm assuming the collection has access restrictions, for security purposes. It appears that some of the header values are accessible with properties for the HttpWebRequest object itself. However in this case I'd rather get rid of the abstraction and set the properties manually. The exception that I'm receiving is:<br /><i>{"This header must be modified using the appropriate property.\r\nParameter name: name"}</i></p>
<p><hr>
Thanks in advance for your help,</p>
<p>CJAM</p>
| [
{
"answer_id": 11146923,
"author": "Jimmy Schementi",
"author_id": 5721,
"author_profile": "https://Stackoverflow.com/users/5721",
"pm_score": 0,
"selected": false,
"text": "static void CopyHeaders (HttpRequest sourceRequest, HttpWebRequest targetRequest) {\n foreach (string key in so... | 2008/10/07 | [
"https://Stackoverflow.com/questions/176777",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23869/"
] |
176,782 | <p>So, I have an autocomplete dropdown with a list of townships. Initially I just had the 20 or so that we had in the database... but recently, we have noticed that some of our data lies in other counties... even other states. So, the answer to that was buy one of those databases with all towns in the US (yes, I know, geocoding is the answer but due to time constraints we are doing this until we have time for that feature). </p>
<p>So, when we had 20-25 towns the autocomplete worked stellarly... now that there are 80,000 it's not as easy. </p>
<p>As I type I am thinking that the best way to do this is default to this state, then there will be much less. I will add a state selector to the page that defaults to NJ then you can pick another state if need be, this will narrow down the list to < 1000. Though, I may have the same issue? Does anyone know of a work around for an autocomplete with a lot of data? </p>
<p>should I post teh codez of my webservice?</p>
| [
{
"answer_id": 177195,
"author": "James Curran",
"author_id": 12725,
"author_profile": "https://Stackoverflow.com/users/12725",
"pm_score": 0,
"selected": false,
"text": "select top 10 name from cities where @partialname < name order by name;\n"
}
] | 2008/10/07 | [
"https://Stackoverflow.com/questions/176782",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4140/"
] |
176,791 | <p>I have a legacy application that I needed to implement a configuration page for to change text colors, fonts, etc.</p>
<p>This applications output is also replicated with a PHP web application, where the fonts, colors, etc. are configured in a style sheet.</p>
<p>I've not worked with CSS previously.</p>
<p>Is there a programatic way to modify the CSS and save it without resorting to string parsing or regex?</p>
<p>The application is VB6, but I could write a .net tool that would do the css manipulation if that was the only way.</p>
| [
{
"answer_id": 207161,
"author": "Alexey Shatygin",
"author_id": 10915,
"author_profile": "https://Stackoverflow.com/users/10915",
"pm_score": 0,
"selected": false,
"text": "border-color: #008a77;\n"
}
] | 2008/10/07 | [
"https://Stackoverflow.com/questions/176791",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10119/"
] |
176,827 | <p>I have an ASP.NET linkbutton control on my form. I would like to use it for javascript on the client side and prevent it from posting back to the server. (I'd like to use the linkbutton control so I can skin it and disable it in some cases, so a straight up tag is not preferred).</p>
<p>How do I prevent it from posting back to the server?</p>
| [
{
"answer_id": 176829,
"author": "BoltBait",
"author_id": 20848,
"author_profile": "https://Stackoverflow.com/users/20848",
"pm_score": 2,
"selected": false,
"text": "MyButton.Attributes.Add(\"onclick\", \"put your javascript here including... return false;\");\n"
},
{
"answer_id... | 2008/10/07 | [
"https://Stackoverflow.com/questions/176827",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/417/"
] |
176,831 | <p>I have a modal popup that initially shows some content but expands a div if a checkbox is selected. The modal expands correctly but doesn't recenter unless you scroll up or down. Is there a javascript event I can tack on to my javascript function to recenter the entire modal?</p>
| [
{
"answer_id": 481797,
"author": "Luke",
"author_id": 14275,
"author_profile": "https://Stackoverflow.com/users/14275",
"pm_score": 4,
"selected": true,
"text": "$find('ModalPopupExtenderClientID')._layout();\n"
}
] | 2008/10/07 | [
"https://Stackoverflow.com/questions/176831",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14275/"
] |
176,840 | <p>It's the first <a href="http://oreilly.com/catalog/opensources/book/larry.html" rel="nofollow noreferrer">great virtue</a> of programmers. All of us have, at one time or another automated a task with a bit of throw-away code. Sometimes it takes a couple seconds tapping out a one-liner, sometimes we spend an exorbitant amount of time automating away a two-second task and then never use it again.</p>
<p>What tiny hack have you found useful enough to <b>reuse</b>? To make go so far as to make an alias for?</p>
<p>Note: before answering, please check to make sure it's not already on <a href="https://stackoverflow.com/questions/68372/what-is-your-single-most-favorite-command-line-trick-using-bash">favourite command-line tricks using BASH</a> or perl/ruby one-liner questions. </p>
| [
{
"answer_id": 176930,
"author": "Frew Schmidt",
"author_id": 12448,
"author_profile": "https://Stackoverflow.com/users/12448",
"pm_score": 1,
"selected": false,
"text": "#!/usr/bin/ruby -w\n\nDay = 60 * 60 * 24\n\nFromat = \"hjlsdahjsd/comics/st%Y%m%d.gif\"\n\nt = Time.local(2005, 2, 5)... | 2008/10/07 | [
"https://Stackoverflow.com/questions/176840",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1582786/"
] |
176,850 | <p>I've used NUnit before, but not in a while, and never on this machine. I unzipped version 2.4.8 under <code>Program Files</code>, and I keep getting this error when trying to load my tests.</p>
<blockquote>
<p>Could not load file or assembly 'nunit.framework, Version=2.4.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77' or one of its dependencies. The system cannot find the file specified**</p>
</blockquote>
<p>In order to simplify the problem, I've compiled the most basic possible test file.</p>
<pre><code>using NUnit.Framework;
namespace test
{
[TestFixture]
public class Tester
{
[Test]
public void ATest()
{
Assert.IsTrue(false, "At least the test ran!");
}
}
}
</code></pre>
<p>I've added "C:\Program Files\NUnit-2.4.8-net-2.0\bin" to my PATH (and rebooted). Note that if I copy the test assembly into that folder, then</p>
<pre>
C:\Program Files\NUnit-2.4.8-net-2.0\bin>nunit-console test.dll
</pre>
<p>works, but</p>
<pre>
C:\Program Files\NUnit-2.4.8-net-2.0\bin>nunit-console c:\dev\nunit_test\test.dll
</pre>
<p>and</p>
<pre>
C:\dev\nunit_test>nunit_console test.dll
</pre>
<p>fail with the above error.</p>
<p>Presumably I could get around this by copying the NUnit.Framework DLL file into my project's <code>bin</code> folder, but I don't remember having to do this in the past. Moreover, I get the same error in the GUI. Shouldn't the GUI know where the framework is located (that is, in the same folder)?</p>
<p>I'm not using Visual Studio. I use the following line to compile the test project.</p>
<pre>
%windir%\Microsoft.NET\Framework\v2.0.50727\csc.exe /r:"C:\Program Files\NUnit-2.4.8-net-2.0\bin\nunit.framework.dll" /t:library /out:test.dll test.cs
</pre>
<p>I tried both the .msi and the .zip file with the same result.</p>
| [
{
"answer_id": 688174,
"author": "Jeffrey Knight",
"author_id": 83418,
"author_profile": "https://Stackoverflow.com/users/83418",
"pm_score": 4,
"selected": false,
"text": "gacutil /l | find /i \"nunit\" > temp.bat && notepad temp.bat\n"
},
{
"answer_id": 7812614,
"author": "... | 2008/10/07 | [
"https://Stackoverflow.com/questions/176850",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4525/"
] |
176,851 | <p>I have taken a copy of a database home with me so I can do some testing. However when I try to run a stored procedure I get Cannot open user default database. Login failed.. </p>
<p>I have checked and checked and checked I can open tables in the databases login to sql management studio and access the default as well as other databases any ideas?</p>
<p>Possibly a corrupt user it was from sql 2000 at work to 2005 at home</p>
| [
{
"answer_id": 176939,
"author": "flatline",
"author_id": 20846,
"author_profile": "https://Stackoverflow.com/users/20846",
"pm_score": 0,
"selected": false,
"text": "exec sp_change_users_login update_one, 'user', 'login'\n"
},
{
"answer_id": 177048,
"author": "Hector Sosa Jr... | 2008/10/07 | [
"https://Stackoverflow.com/questions/176851",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16989/"
] |
176,856 | <p>What's the best way for constructing headers, and footers? Should you call it all from the controller, or include it from the view file? I'm using CodeIgniter, and I'm wanting to know what's the best practice for this. Loading all the included view files from the controller, like this?</p>
<pre><code>class Page extends Controller {
function index()
{
$data['page_title'] = 'Your title';
$this->load->view('header');
$this->load->view('menu');
$this->load->view('content', $data);
$this->load->view('footer');
}
}
</code></pre>
<p>or calling the single view file, and calling the header and footer views from there:</p>
<pre><code>//controller file
class Page extends Controller {
function index()
{
$data['page_title'] = 'Your title';
$this->load->view('content', $data);
}
}
//view file
<?php $this->load->view('header'); ?>
<p>The data from the controller</p>
<?php $this->load->view('footer'); ?>
</code></pre>
<p>I've seen it done both ways, but want to choose now before I go too far down a path.</p>
| [
{
"answer_id": 176988,
"author": "gradbot",
"author_id": 17919,
"author_profile": "https://Stackoverflow.com/users/17919",
"pm_score": 2,
"selected": false,
"text": "class Page extends Controller {\n function index() {\n $data['page_title'] = 'Your title';\n \n $this->lo... | 2008/10/07 | [
"https://Stackoverflow.com/questions/176856",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24708/"
] |
176,857 | <p>I should probably take this for a forum but figured someone here might know the answer. I'm trying to install sql server 2008 on a home vista machine but it keeps telling 'Restart computer failed' everytime it does a check to make sure pre-reqs are met. I've restarted my computer and even uinstalled/installed .net 3.5 sp1.<br>
only thread i found about this was: <a href="http://forums.microsoft.com/msdn/showpost.aspx?postid=3656807&siteid=1&sb=0&d=1&at=7&ft=11&tf=0&pageid=1" rel="noreferrer">http://forums.microsoft.com/msdn/showpost.aspx?postid=3656807&siteid=1&sb=0&d=1&at=7&ft=11&tf=0&pageid=1</a></p>
<p>the last post on that forum states that there is a way to 'forcefully' (using command prompt) there is a way to bypass the reboot check. </p>
<p>does anyone know what commands can be used to bypass the rebook check??</p>
| [
{
"answer_id": 15720206,
"author": "Paldom",
"author_id": 1208812,
"author_profile": "https://Stackoverflow.com/users/1208812",
"pm_score": 0,
"selected": false,
"text": "INSTANCENAME=SQL2008\n/SQLSYSADMINACCOUNTS=”yourPcName\\yourUserName”\n/SAPWD=”yourSqlPassword” \n/SQLTEMPDBDIR=”C:\\... | 2008/10/07 | [
"https://Stackoverflow.com/questions/176857",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
176,858 | <p>In a static view, how can I view an old version of a file?</p>
<p>Given an empty file (called <code>empty</code> in this example) I can subvert <code>diff</code> to show me the old version:</p>
<pre>
% cleartool diff -ser empty File@@/main/28
</pre>
<p>This feels like a pretty ugly hack. Have I missed a more basic command? Is there a neater way to do this?</p>
<p>(I don't want to edit the config spec - that's pretty tedious, and I'm trying to look at a bunch of old versions.)</p>
<p><strong>Clarification</strong>: I want to send the version of the file to stdout, so I can use it with the rest of Unix (grep, sed, and so on.) If you found this question because you're looking for a way to save a version of an element to a file, see <a href="https://stackoverflow.com/questions/176858/in-clearcase-how-can-i-view-old-version-of-a-file-in-a-static-view-from-the-com/4962643#4962643">Brian's answer</a>.</p>
| [
{
"answer_id": 177273,
"author": "Chris Arguin",
"author_id": 25704,
"author_profile": "https://Stackoverflow.com/users/25704",
"pm_score": 2,
"selected": false,
"text": " cat File@@/main/28\n"
},
{
"answer_id": 177350,
"author": "VonC",
"author_id": 6309,
"author_p... | 2008/10/07 | [
"https://Stackoverflow.com/questions/176858",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17221/"
] |
176,877 | <p>I want to call <code>ShowDialog()</code> when a keyboard hook event is triggered, but I'm having some difficulties:</p>
<ul>
<li>ShowDialog() blocks, so I can't call it from the hook triggered event, because it will block the OS.</li>
<li>I can start a new thread and call <code>ShowDialog()</code> from there, but I get some nasty exception. I guess I can't call <code>ShowDialog()</code> in any other thread.</li>
<li>I can start a timer: in the next 50 milliseconds call <code>ShowDialog()</code> (which is a nasty hack BTW, and I rather not do this). But then the timer fires in a new thread, and then I run into the same problem explained in the previous bullet.</li>
</ul>
<p>Is there a way?</p>
| [
{
"answer_id": 176906,
"author": "Brody",
"author_id": 17131,
"author_profile": "https://Stackoverflow.com/users/17131",
"pm_score": 3,
"selected": true,
"text": "ShowDialog()"
},
{
"answer_id": 176920,
"author": "Ed S.",
"author_id": 1053,
"author_profile": "https://... | 2008/10/07 | [
"https://Stackoverflow.com/questions/176877",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44972/"
] |
176,902 | <p>How do I run a .jar executable java file from outside NetBeans IDE? (Windows Vista). My project has a .jar file created by Netbeans. We'd like to run it. Either: how do we run the file or how do we create a 'proper' executable file in NetBeans 6.1?</p>
| [
{
"answer_id": 176905,
"author": "Laplie Anderson",
"author_id": 14204,
"author_profile": "https://Stackoverflow.com/users/14204",
"pm_score": 4,
"selected": false,
"text": "java -jar filename.jar\n"
},
{
"answer_id": 176911,
"author": "Josh Moore",
"author_id": 5004,
... | 2008/10/07 | [
"https://Stackoverflow.com/questions/176902",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
176,910 | <p>When I want an array of flags it has typically pained me to use an entire byte (or word) to store each one, as would be the result if I made an array of <code>bool</code>s or some other numeric type that could be set to 0 or 1. But now I wonder whether using a structure that is more space-efficient is worth it given the (albeit hopefully very slight) additional overhead of shifting and bit testing.</p>
<p>In my company we use Rogue Wave tools (though hopefully not for much longer) and it's their <code>RWBitVec</code> that I've used for this purpose up until now.</p>
| [
{
"answer_id": 176946,
"author": "Andrew Edgecombe",
"author_id": 11694,
"author_profile": "https://Stackoverflow.com/users/11694",
"pm_score": 0,
"selected": false,
"text": "bool"
}
] | 2008/10/07 | [
"https://Stackoverflow.com/questions/176910",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4790/"
] |
176,913 | <p>I basically want to run all JUnit <strong><em>unit</em></strong> tests in my IntelliJ IDEA project (excluding JUnit integration tests), using the static suite() method of JUnit. Why use the static suite() method? Because I can then use IntelliJ IDEA's JUnit test runner to run all unit tests in my application (and easily exclude all integration tests by naming convention). The code so far looks like this:</p>
<pre><code>package com.acme;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class AllUnitTests extends TestCase {
public static Test suite() {
List classes = getUnitTestClasses();
return createTestSuite(classes);
}
private static List getUnitTestClasses() {
List classes = new ArrayList();
classes.add(CalculatorTest.class);
return classes;
}
private static TestSuite createTestSuite(List allClasses) {
TestSuite suite = new TestSuite("All Unit Tests");
for (Iterator i = allClasses.iterator(); i.hasNext();) {
suite.addTestSuite((Class<? extends TestCase>) i.next());
}
return suite;
}
}
</code></pre>
<p>The method getUnitTestClasses() should be rewritten to add all project classes extending TestCase, except if the class name ends in "IntegrationTest".</p>
<p>I know I can do this easily in Maven for example, but I need to do it in IntelliJ IDEA so I can use the integrated test runner - I like the green bar :)</p>
| [
{
"answer_id": 178030,
"author": "Roel Spilker",
"author_id": 12634,
"author_profile": "https://Stackoverflow.com/users/12634",
"pm_score": 4,
"selected": true,
"text": "public class ClassEnumerator {\n public static void main(String[] args) throws ClassNotFoundException {\n Li... | 2008/10/07 | [
"https://Stackoverflow.com/questions/176913",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13041/"
] |
176,918 | <p>Given a list <code>["foo", "bar", "baz"]</code> and an item in the list <code>"bar"</code>, how do I get its index <code>1</code>?</p>
| [
{
"answer_id": 176921,
"author": "Alex Coventry",
"author_id": 1941213,
"author_profile": "https://Stackoverflow.com/users/1941213",
"pm_score": 13,
"selected": true,
"text": ">>> [\"foo\", \"bar\", \"baz\"].index(\"bar\")\n1\n"
},
{
"answer_id": 178399,
"author": "davidavr",... | 2008/10/07 | [
"https://Stackoverflow.com/questions/176918",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25680/"
] |
176,922 | <p>For decades, in the field of computing (except disk manufacturers), a KB (kilobyte) was understood to mean 1024 bytes. In the past few years, there has been a movement to use KiB ("kibibyte") to mean 1024 bytes, and <i>change the meaning of kilobyte to be 1000 bytes</i>, dooming us to many more years of confusion. On the other hand, the movement seems to be confined to Gnome, and some <a href="http://en.wikipedia.org/wiki/Talk:Kilobyte#Kibibyte.3F" rel="noreferrer">overzealous wikipedia editing</a>.</p>
<p><i>Will you be converting your programs to use KiB?</i> If you have ever displayed a filesize in KB, did you divide by 1000 or 1024?</p>
| [
{
"answer_id": 1402810,
"author": "Noon Silk",
"author_id": 154152,
"author_profile": "https://Stackoverflow.com/users/154152",
"pm_score": 0,
"selected": false,
"text": "1,000"
}
] | 2008/10/07 | [
"https://Stackoverflow.com/questions/176922",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15947/"
] |
176,931 | <p>How can I get MSBuild to evaluate and print in a <code><Message /></code> task an absolute path given a relative path?</p>
<p><strong>Property Group</strong></p>
<pre><code><Source_Dir>..\..\..\Public\Server\</Source_Dir>
<Program_Dir>c:\Program Files (x86)\Program\</Program_Dir>
</code></pre>
<p><strong>Task</strong></p>
<pre><code><Message Importance="low" Text="Copying '$(Source_Dir.FullPath)' to '$(Program_Dir)'" />
</code></pre>
<p><strong>Output</strong></p>
<blockquote>
<p>Copying '' to 'c:\Program Files (x86)\Program\'</p>
</blockquote>
| [
{
"answer_id": 177136,
"author": "brock.holum",
"author_id": 15860,
"author_profile": "https://Stackoverflow.com/users/15860",
"pm_score": 3,
"selected": false,
"text": "public class ResolveRelativePath : Task\n{\n [Required]\n public string RelativePath { get; set; }\n\n [Outpu... | 2008/10/07 | [
"https://Stackoverflow.com/questions/176931",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3957/"
] |
176,964 | <p>I want to return top 10 records from each section in one query. Can anyone help with how to do it? Section is one of the columns in the table.</p>
<p>Database is SQL Server 2005. I want to return the top 10 by date entered. Sections are business, local, and feature. For one particular date I want only the top (10) business rows (most recent entry), the top (10) local rows, and the top (10) features.</p>
| [
{
"answer_id": 176977,
"author": "Matt Hamilton",
"author_id": 615,
"author_profile": "https://Stackoverflow.com/users/615",
"pm_score": 5,
"selected": false,
"text": "select *\nfrom Things t\nwhere t.ThingID in (\n select top 10 ThingID\n from Things tt\n where tt.Section = t.S... | 2008/10/07 | [
"https://Stackoverflow.com/questions/176964",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14752/"
] |
176,966 | <p>I've been looking for the answer for how to use BSWAP for lower 32-bit sub-register of 64-bit register. For example, <code>0x0123456789abcdef</code> is inside RAX register, and I want to change it to <code>0x01234567efcdab89</code> with a single instruction (because of performance).</p>
<p>So I tried following inline function:</p>
<pre class="lang-c prettyprint-override"><code>#define BSWAP(T) { \
__asm__ __volatile__ ( \
"bswap %k0" \
: "=q" (T) \
: "q" (T)); \
}
</code></pre>
<p>And the result was <code>0x00000000efcdab89</code>. I don't understand why the compiler acts like this. Does anybody know the efficient solution?</p>
| [
{
"answer_id": 176981,
"author": "Dan Lenski",
"author_id": 20789,
"author_profile": "https://Stackoverflow.com/users/20789",
"pm_score": -1,
"selected": false,
"text": "gcc -s"
},
{
"answer_id": 178474,
"author": "Dan Lenski",
"author_id": 20789,
"author_profile": "h... | 2008/10/07 | [
"https://Stackoverflow.com/questions/176966",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25683/"
] |
176,973 | <p>I am a new to the prefuse visualization toolkit and have a couple of general questions. For my purpose, I would like to perform an initial visualization using prefuse (graphview / graphml). Once rendered, upon a user click of a node, I would like to completely reload a new xml file for a new visualization. I want to do this in order to allow me to "pre-package" graphs for display. </p>
<p>For example. If I search for Ted. I would like to have an xml file relating to Ted load and render a display. Now in the display I see that Ted has nodes associated called Bill and Joe. When I click Joe, I would like to clear the display and load an xml file associated with Joe. And so on. </p>
<p>I have looked into loading one very large xml file containing all node and node relationship info and allowing prefuse to handle this using the hops from one level to another. However, eventually I am sure that system performance issues will arise due to the size of data.</p>
<p>Thanks in advance for any help,
John </p>
| [
{
"answer_id": 13370364,
"author": "alemangui",
"author_id": 1046444,
"author_profile": "https://Stackoverflow.com/users/1046444",
"pm_score": 0,
"selected": false,
"text": "public void refresh(clickedNode){\n visualization.removeGroup(GRAPH);\n visualization.removeGroup(AGGR);\n ... | 2008/10/07 | [
"https://Stackoverflow.com/questions/176973",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
176,983 | <p>I am trying to learn CodeIgniter to use for a shopping site, but I am not having luck with the official doc. Does anyone know of anything that will help?</p>
| [
{
"answer_id": 177117,
"author": "jmccartie",
"author_id": 24708,
"author_profile": "https://Stackoverflow.com/users/24708",
"pm_score": 3,
"selected": true,
"text": "<link href=\"<?=base_url();?>content/css/main.css\" rel=\"stylesheet\" type=\"text/css\" />\n"
}
] | 2008/10/07 | [
"https://Stackoverflow.com/questions/176983",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25695/"
] |
176,989 | <p>In the early days of C++ when it was bolted on top of C, you could not use NULL as it was defined as <code>(void*)0</code>. You could not assign NULL to any pointer other than <code>void*</code>, which made it kind of useless. Back in those days, it was accepted that you used <code>0</code> (zero) for null pointers.</p>
<p>To this day, I have continued to use zero as a null pointer but those around me insist on using <code>NULL</code>. I personally do not see any benefit to giving a name (<code>NULL</code>) to an existing value - and since I also like to test pointers as truth values:</p>
<pre><code>if (p && !q)
do_something();
</code></pre>
<p>then using zero makes more sense (as in if you use <code>NULL</code>, you cannot logically use <code>p && !q</code> - you need to explicitly compare against <code>NULL</code>, unless you assume <code>NULL</code> is zero, in which case why use <code>NULL</code>).</p>
<p>Is there any objective reason to prefer zero over NULL (or vice versa), or is all just personal preference?</p>
<p>Edit: I should add (and meant to originally say) that with RAII and exceptions, I rarely use zero/NULL pointers, but sometimes you do need them still.</p>
| [
{
"answer_id": 177007,
"author": "Martin Cote",
"author_id": 9936,
"author_profile": "https://Stackoverflow.com/users/9936",
"pm_score": 9,
"selected": true,
"text": "NULL"
},
{
"answer_id": 177009,
"author": "mxg",
"author_id": 11157,
"author_profile": "https://Stack... | 2008/10/07 | [
"https://Stackoverflow.com/questions/176989",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23744/"
] |
177,011 | <p>OK I have an array of tserversocket and am using the tag property to keep track of its index. When an event is fired off such as _clientconnect i am using Index := (Sender as TServerSocket).Tag; but i get an error that highlights that line and tells me its an invalid typecast. What am I doing wrong if all I want to do is get the tag property field? It works with other objects.</p>
| [
{
"answer_id": 177270,
"author": "Chris Latta",
"author_id": 20977,
"author_profile": "https://Stackoverflow.com/users/20977",
"pm_score": 2,
"selected": false,
"text": "procedure TfrmServer.sskServerClientConnect(Sender: TObject; Socket: TCustomWinSocket);\n"
},
{
"answer_id": 1... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177011",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
177,039 | <p>First, two examples:</p>
<pre><code>// This works
int foo = 43;
long lFoo = foo;
// This doesn't
object foo = (int)43;
long? nullFoo = foo as long?; // returns null
long lFoo = (long)foo; // throws InvalidCastException
if (foo.GetType() == typeof(int))
Console.WriteLine("But foo is an int..."); // This gets written out
</code></pre>
<p>Now, my guess as to why the second doesn't work is because of boxing. The purpose behind this code is to implement <code>IComparable</code>. I need some way to coerce an object into either a long or a ulong as appropriate, or if it's neither, than to throw an error. I don't want to have to implement checks for each basic numeric type (byte, int, long, ubyte, ...) I'd rather just catch them in the largest numeric type and deal with it that way. Thoughts from all the smart people here? How can I unbox the object, preferably avoiding reflection, but I suppose if that's the only way... Or should I just not implement the non-generics version of <code>IComparable</code>?</p>
<p><strong>Edit:</strong></p>
<p>This seems to work, but seems like a horrible hack around the problem. Is it just me?</p>
<pre><code>long lFoo = long.Parse(foo.ToString());
</code></pre>
| [
{
"answer_id": 177081,
"author": "Nat",
"author_id": 13813,
"author_profile": "https://Stackoverflow.com/users/13813",
"pm_score": 0,
"selected": false,
"text": "object foo = (int)43;\nlong outVal;\nif(long.TryParse(foo.ToString(),out outVal))\n{\n//take action with correct value of long... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177039",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15537/"
] |
177,042 | <p>I am having an issue setting up cURL with IIS 6.0, Windows Server 2003, PHP 5.2.6</p>
<p>I have installed to <code>C:\PHP</code></p>
<pre><code>set PHPRC = C:\PHP\php.ini
</code></pre>
<p>copied <code>ssleay32.dll</code> and <code>libeay32.dll</code> to <code>C:\PHP</code></p>
<p>in php.ini, uncommented the line</p>
<pre><code>extension=php_curl.dll
extension_dir="C:\PHP\ext"
</code></pre>
<p><code>c:\php\ext</code> has the dll <code>php_curl.dll</code></p>
<p><code>C:\PHP</code> is in <code>PATH</code></p>
<p>still getting </p>
<blockquote>
<p>Fatal error: Call to undefined function curl_init()</p>
</blockquote>
| [
{
"answer_id": 177112,
"author": "Randy",
"author_id": 9361,
"author_profile": "https://Stackoverflow.com/users/9361",
"pm_score": 2,
"selected": false,
"text": "php -c . -i | find /i \"curl\"\n"
}
] | 2008/10/07 | [
"https://Stackoverflow.com/questions/177042",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20641/"
] |
177,052 | <p>I am working on integrating geolocation services into a website and the best source of data I've found so far is MaxMind's GeoIP API with GeoLite City data. Even this data seems to often be questionable though. For example, I am located in downtown Palo Alto, but it locates my IP as being in Portola Valley, which is about 7 miles away. Palo Alto has a population of 60k+, whereas Portola Valley has a population of less than 5k. I would think if you see an IP originating somewhere around there it would make more sense to assume it was coming from the highly populated city, not the tiny one. I've also had it locate Palo Alto IPs completely across the country in Kentucky, etc.</p>
<p>Does anyone know of any better sources of data, or any tools/technologies/efforts to improve the accuracy of geolocation efforts? Commercial solutions are fine.</p>
| [
{
"answer_id": 205585,
"author": "stevemegson",
"author_id": 25028,
"author_profile": "https://Stackoverflow.com/users/25028",
"pm_score": 2,
"selected": false,
"text": "ORDER BY ( Distance / LOG( Population ) )\n"
}
] | 2008/10/07 | [
"https://Stackoverflow.com/questions/177052",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2168/"
] |
177,054 | <p>There's a common way to store multiple values in one variable, by using a bitmask. For example, if a user has read, write and execute privileges on an item, that can be converted to a single number by saying <code>read = 4 (2^2), write = 2 (2^1), execute = 1 (2^0)</code> and then add them together to get 7.</p>
<p>I use this technique in several web applications, where I'd usually store the variable into a field and give it a type of MEDIUMINT or whatever, depending on the number of different values.</p>
<p>What I'm interested in, is whether or not there is a practical limit to the number of values you can store like this? For example, if the number was over 64, you couldn't use (64 bit) integers any more. If this was the case, what would you use? How would it affect your program logic (ie: could you still use bitwise comparisons)?</p>
<p><em>I know that once you start getting really large sets of values, a different method would be the optimal solution, but I'm interested in the boundaries of <strong>this</strong> method.</em></p>
| [
{
"answer_id": 177092,
"author": "Mike Spross",
"author_id": 17862,
"author_profile": "https://Stackoverflow.com/users/17862",
"pm_score": 3,
"selected": true,
"text": "set_bit"
}
] | 2008/10/07 | [
"https://Stackoverflow.com/questions/177054",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9021/"
] |
177,062 | <p>I know that to change the index page for rails I need to do three things: delete the index.html, do something with routes.rb, and probably make an action that the route will point to. It's the details that I am a little fuzzy on :-)</p>
| [
{
"answer_id": 177913,
"author": "allesklar",
"author_id": 19893,
"author_profile": "https://Stackoverflow.com/users/19893",
"pm_score": 3,
"selected": false,
"text": "<h1>My New Index Page</h1>\n<p>Some text here.</p>\n"
}
] | 2008/10/07 | [
"https://Stackoverflow.com/questions/177062",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12448/"
] |
177,080 | <p>Method signature in Java:</p>
<pre><code>public List<String> getFilesIn(List<File> directories)
</code></pre>
<p>similar one in ruby</p>
<pre><code>def get_files_in(directories)
</code></pre>
<p>In the case of Java, the type system gives me information about what the method expects and delivers. In Ruby's case, I have <strong>no</strong> clue what I'm supposed to pass in, or what I'll expect to receive.</p>
<p>In Java, the object must formally implement the interface. In Ruby, the object being passed in must respond to whatever methods are called in the method defined here. </p>
<p>This seems highly problematic:</p>
<ol>
<li>Even with 100% accurate, up-to-date documentation, the Ruby code has to essentially expose its implementation, breaking encapsulation. "OO purity" aside, this would seem to be a maintenance nightmare.</li>
<li>The Ruby code gives me <strong>no</strong> clue what's being returned; I would have to essentially experiment, or read the code to find out what methods the returned object would respond to.</li>
</ol>
<p>Not looking to debate static typing vs duck typing, but looking to understand how you maintain a production system where you have almost no ability to design by contract.</p>
<h3>Update</h3>
<p>No one has really addressed the exposure of a method's internal implementation via documentation that this approach requires. Since there are no interfaces, if I'm not expecting a particular type, don't I have to itemize every method I might call so that the caller knows what can be passed in? Or is this just an edge case that doesn't really come up?</p>
| [
{
"answer_id": 177110,
"author": "Kent Fredric",
"author_id": 15614,
"author_profile": "https://Stackoverflow.com/users/15614",
"pm_score": 3,
"selected": false,
"text": "i = {}\n=> {}\ni.methods.sort\n=> [\"==\", \"===\", \"=~\", \"[]\", \"[]=\", \"__id__\", \"__send__\", \"all?\", \"an... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177080",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3029/"
] |
177,113 | <p>I have a std::string with UTF-8 characters in it.<br>
I want to convert the string to its closest equivalent with ASCII characters.</p>
<p>For example:</p>
<p>Łódź => Lodz<br>
Assunção => Assuncao<br>
Schloß => Schloss</p>
<p>Unfortunatly ICU library is realy unintuitive and I haven't found good documentation on its usage, so it would take me too much time to learn to use it. Time I dont have.</p>
<p>Could someone give a little example about how can this be done??<br>
thanks.</p>
| [
{
"answer_id": 177224,
"author": "shoosh",
"author_id": 9611,
"author_profile": "https://Stackoverflow.com/users/9611",
"pm_score": 2,
"selected": false,
"text": "ICONV_SET_TRANSLITERATE"
},
{
"answer_id": 1533156,
"author": "Steven R. Loomis",
"author_id": 185799,
"a... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177113",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25700/"
] |
177,118 | <p>I saw this question on Reddit, and there were no positive solutions presented, and I thought it would be a perfect question to ask here. This was in a thread about interview questions:</p>
<blockquote>
<p>Write a method that takes an int array of size m, and returns (True/False) if the array consists of the numbers n...n+m-1, all numbers in that range and only numbers in that range. The array is not guaranteed to be sorted. (For instance, {2,3,4} would return true. {1,3,1} would return false, {1,2,4} would return false.</p>
<p>The problem I had with this one is that my interviewer kept asking me to optimize (faster O(n), less memory, etc), to the point where he claimed you could do it in one pass of the array using a constant amount of memory. Never figured that one out.</p>
</blockquote>
<p>Along with your solutions please indicate if they assume that the array contains unique items. Also indicate if your solution assumes the sequence starts at 1. (I've modified the question slightly to allow cases where it goes 2, 3, 4...)</p>
<p><strong>edit:</strong> I am now of the opinion that there does not exist a linear in time and constant in space algorithm that handles duplicates. Can anyone verify this?</p>
<p>The duplicate problem boils down to testing to see if the array contains duplicates in O(n) time, O(1) space. If this can be done you can simply test first and if there are no duplicates run the algorithms posted. So can you test for dupes in O(n) time O(1) space?</p>
| [
{
"answer_id": 177126,
"author": "hazzen",
"author_id": 5066,
"author_profile": "https://Stackoverflow.com/users/5066",
"pm_score": 4,
"selected": false,
"text": "1"
},
{
"answer_id": 177128,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stack... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177118",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/658/"
] |
177,121 | <p>In particular, I am interested in:
1) Getting up a <em>free</em> environment setup to do workflows.
2) How to use existing workflow items/states and what is involved in that.</p>
<p>Thanks!</p>
| [
{
"answer_id": 5694752,
"author": "krisragh MSFT",
"author_id": 528570,
"author_profile": "https://Stackoverflow.com/users/528570",
"pm_score": 3,
"selected": false,
"text": "public void HandleLoanRequest (string customerID, Application app)\n{\n if (CheckCredit(customerId, app.Amount... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177121",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13990/"
] |
177,122 | <p>This is really two questions, but they are so similar, and to keep it simple, I figured I'd just roll them together:</p>
<ul>
<li><p><strong>Firstly</strong>: Given an established Perl project, what are some decent ways to speed it up beyond just plain in-code optimization?</p></li>
<li><p><strong>Secondly</strong>: When writing a program from scratch in Perl, what are some good ways to greatly improve performance?</p></li>
</ul>
<p>For the first question, imagine you are handed a decently written project and you need to improve performance, but you can't seem to get much of a gain through refactoring/optimization. What would you do to speed it up in this case short of rewriting it in something like C?</p>
<p><strong>Please stay away from general optimization techniques unless they are <em>Perl specific</em>.</strong></p>
<p>I asked this about <a href="https://stackoverflow.com/questions/172720/speeding-up-python">Python</a> earlier, and I figured it might be good to do it for other languages (I'm especially curious if there are corollaries to <a href="http://psyco.sourceforge.net/" rel="nofollow noreferrer">psycho</a> and <a href="http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/" rel="nofollow noreferrer">pyrex</a> for Perl).</p>
| [
{
"answer_id": 177252,
"author": "pjf",
"author_id": 19422,
"author_profile": "https://Stackoverflow.com/users/19422",
"pm_score": 5,
"selected": false,
"text": "Devel::NYTProf"
},
{
"answer_id": 177643,
"author": "brian d foy",
"author_id": 2766176,
"author_profile":... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177122",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/145/"
] |
177,133 | <p>I am trying to override the DataGridViewTextBoxCell's paint method in a derived class so that I can indent the foreground text by some variable amount of pixels. I would like it if the width of the column adjusts so that its total width is the length of my cells text plus the "buffer" indent. Does anyone know of a way to accomplish this? My lame implementation is listed below:</p>
<pre><code>public class MyTextBoxCell : DataGridViewTextBoxCell{ ....
protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts) {
clipBounds.Inflate(100, 0);
DataGridViewPaintParts pp = DataGridViewPaintParts.Background | DataGridViewPaintParts.Border | DataGridViewPaintParts.ContentBackground
| DataGridViewPaintParts.ErrorIcon;
base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, pp);
string text = formattedValue as string;
//My lame attempt to indent 20 pixels??
TextRenderer.DrawText(graphics, text, cellStyle.Font, new Point(cellBounds.Location.X + 20, cellBounds.Location.Y), cellStyle.SelectionForeColor ,TextFormatFlags.EndEllipsis);
}
</code></pre>
<p>}</p>
| [
{
"answer_id": 177184,
"author": "BFree",
"author_id": 15861,
"author_profile": "https://Stackoverflow.com/users/15861",
"pm_score": 2,
"selected": false,
"text": " if (e.ColumnIndex == 1)\n {\n string val = (string)e.Value;\n e.Value =... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177133",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10446/"
] |
177,146 | <p>How do I get the list of open file handles by process id in C#? </p>
<p>I'm interested in digging down and getting the file names as well. </p>
<p>Looking for the programmatic equivalent of what process explorer does. </p>
<p>Most likely this will require interop. </p>
<p>Considering adding a bounty on this, the implementation is nasty complicated.</p>
| [
{
"answer_id": 177351,
"author": "Mark Cidade",
"author_id": 1659,
"author_profile": "https://Stackoverflow.com/users/1659",
"pm_score": 4,
"selected": false,
"text": "NtQuerySystemInformation"
},
{
"answer_id": 5372541,
"author": "manuc66",
"author_id": 77135,
"autho... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177146",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17174/"
] |
177,154 | <p>I'm trying to create an instance of a class at run time. The classes I'm trying to create all inherit from a base class, ConfigMgrObj, and are named <code>ConfigMgr_xxxxxx</code> e.g. <code>ConfigMgr_Collection</code>. They all take a special object that I'm calling oController and a string as arguments.</p>
<p>This is the line I'm using to do it, where ClassToGet is a string that contains the name of the class e.g. <code>ConfigMgr_Collection</code>.</p>
<pre><code>object oNewObject = System.Activator.CreateInstance(null, "StackOverflowNamespace." + ClassToGet, new object[] { oController, ClassToGet });
</code></pre>
<p>This throws a TypeLoadException exception. What's up with it?</p>
| [
{
"answer_id": 177164,
"author": "jop",
"author_id": 11830,
"author_profile": "https://Stackoverflow.com/users/11830",
"pm_score": 0,
"selected": false,
"text": "\"StackOverflowNamespace.\"+ClassToGet"
}
] | 2008/10/07 | [
"https://Stackoverflow.com/questions/177154",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5133/"
] |
177,160 | <p>Is it possible to set an iPhone Xcode project to skip the 'CompressResources' build step?</p>
<p>Specifically, I want to skip the stage where it runs pngcrush on all of my .png files, many of which don't survive the experience in a form which my app can read.</p>
<p><strong>Edit:</strong> the version of pngcrush used creates png files which contain a non-standard 'mandatory, private' chunk which explicitly prevents decoding. I've modified my png reader to handle these files, but I'd still like a per-project method of skipping this step. One of the other side effects of pngcrush is that it doesn't save the colour value of transparent pixels, so alpha-ed textures show fringing at smaller mip levels.</p>
<p>The iphone png format is described here: <a href="https://web.archive.org/web/20110519164905/http://modmyi.com/wiki/index.php/Iphone_PNG_images" rel="nofollow noreferrer">https://web.archive.org/web/20110519164905/http://modmyi.com/wiki/index.php/Iphone_PNG_images</a>. In short,</p>
<ul>
<li>Skip the CgBI chunk</li>
<li>Skip the zlib headers</li>
<li>Swap BGR to RGB channel order</li>
</ul>
<p><strong>Edit:</strong> It appears it also premultiplies the alpha, so:</p>
<ul>
<li>Divide by alpha</li>
</ul>
| [
{
"answer_id": 178599,
"author": "jblocksom",
"author_id": 20626,
"author_profile": "https://Stackoverflow.com/users/20626",
"pm_score": 2,
"selected": false,
"text": "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/iphoneos-optimize"
}
] | 2008/10/07 | [
"https://Stackoverflow.com/questions/177160",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25352/"
] |
177,161 | <p>I need to get just the first item (actually, just the first key) off a rather large associative array in JavaScript. Here's how I'm doing it currently (using jQuery):</p>
<pre><code>getKey = function (data) {
var firstKey;
$.each(data, function (key, val) {
firstKey = key;
return false;
});
return firstKey;
};
</code></pre>
<p>Just guessing, but I'd say there's got to be a better (read: more efficient) way of doing this. Any suggestions?</p>
<p>UPDATE: Thanks for the insightful answers and comments! I had forgotten my JavaScript 101, wherein the spec says you're not guaranteed a particular order in an associative array. It's interesting, though, that most browsers do implement it that way. I'd prefer not to sort the array before getting that first key, but it may be unavoidable given my use case.</p>
| [
{
"answer_id": 177191,
"author": "Jonathan Lonowski",
"author_id": 15031,
"author_profile": "https://Stackoverflow.com/users/15031",
"pm_score": 7,
"selected": true,
"text": "function getKey(data) {\n for (var prop in data)\n return prop;\n}\n"
},
{
"answer_id": 13179330,
... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177161",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11577/"
] |
177,188 | <p>I'm not talking about a post build event for a project. Rather, I want to run an executable automatically after the entire solution is built. Is there a way to do a post build event for the solution?</p>
| [
{
"answer_id": 177243,
"author": "Ryan Lundy",
"author_id": 5486,
"author_profile": "https://Stackoverflow.com/users/5486",
"pm_score": 6,
"selected": true,
"text": "Public Sub AfterBuild(scope As vsBuildScope, action As vsBuildAction) _\n Handles BuildEvents.OnBuildDone\n If s... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177188",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5469/"
] |
177,189 | <p>Sometime I see many application such as msn, windows media player etc that are single instance applications (when user executes while application is running a new application instance will not created).</p>
<p>In C#, I use <code>Mutex</code> class for this but I don't know how to do this in Java.</p>
| [
{
"answer_id": 177201,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 7,
"selected": true,
"text": "InetAddress.getLocalHost()"
},
{
"answer_id": 2002948,
"author": "Robert",
"author_id": 240453,
"author_prof... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177189",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24550/"
] |
177,197 | <p>Please anybody can tell me the questions, that can be asked in an interview for below topics</p>
<ul>
<li>Socket Programming</li>
<li>Multi-Threading</li>
</ul>
<p>An advance thanks goes to everybody who provide their time</p>
| [
{
"answer_id": 11804526,
"author": "jxh",
"author_id": 315052,
"author_profile": "https://Stackoverflow.com/users/315052",
"pm_score": 1,
"selected": false,
"text": "accept"
}
] | 2008/10/07 | [
"https://Stackoverflow.com/questions/177197",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21599/"
] |
177,205 | <p>What is the data that Process and Thread will not share ? </p>
<p>An advance thanks goes to everybody who provide their time</p>
| [
{
"answer_id": 177336,
"author": "bk1e",
"author_id": 8090,
"author_profile": "https://Stackoverflow.com/users/8090",
"pm_score": 0,
"selected": false,
"text": "FD_CLOEXEC"
}
] | 2008/10/07 | [
"https://Stackoverflow.com/questions/177205",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21599/"
] |
177,228 | <p>What is the easiest way of finding out what version of the iPhone SDK is installed on my OS X?</p>
<p>When you log into the Apple's iPhone Developer Center, you can see the build number of the current available version of the SDK, but you have to remember if you have already downloaded that version or not. </p>
<p>What is the easiest way of staying current?</p>
| [
{
"answer_id": 46978885,
"author": "greymouser",
"author_id": 404640,
"author_profile": "https://Stackoverflow.com/users/404640",
"pm_score": 0,
"selected": false,
"text": "$ xcrun --sdk iphoneos --show-sdk-path\n/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Deve... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177228",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2954/"
] |
177,240 | <p>Lets just say you have a table in Oracle:</p>
<pre><code>CREATE TABLE person (
id NUMBER PRIMARY KEY,
given_names VARCHAR2(50),
surname VARCHAR2(50)
);
</code></pre>
<p>with these function-based indices:</p>
<pre><code>CREATE INDEX idx_person_upper_given_names ON person (UPPER(given_names));
CREATE INDEX idx_person_upper_last_name ON person (UPPER(last_name));
</code></pre>
<p>Now, given_names has no NULL values but for argument's sake last_name does. If I do this:</p>
<pre><code>SELECT * FROM person WHERE UPPER(given_names) LIKE 'P%'
</code></pre>
<p>the explain plan tells me its using the index but change it to:</p>
<pre><code>SELECT * FROM person WHERE UPPER(last_name) LIKE 'P%'
</code></pre>
<p>it doesn't. The Oracle docs say that to use the function-based index will only be used when several conditions are met, one of which is ensuring there are no NULL values since they aren't indexed.</p>
<p>I've tried these queries:</p>
<pre><code>SELECT * FROM person WHERE UPPER(last_name) LIKE 'P%' AND UPPER(last_name) IS NOT NULL
</code></pre>
<p>and</p>
<pre><code>SELECT * FROM person WHERE UPPER(last_name) LIKE 'P%' AND last_name IS NOT NULL
</code></pre>
<p>In the latter case I even added an index on last_name but no matter what I try it uses a full table scan. Assuming I can't get rid of the NULL values, how do I get this query to use the index on UPPER(last_name)?</p>
| [
{
"answer_id": 177304,
"author": "CaptainPicard",
"author_id": 15203,
"author_profile": "https://Stackoverflow.com/users/15203",
"pm_score": 2,
"selected": false,
"text": "CREATE INDEX idx_person_upper_surname ON person (UPPER(surname));\n\nSELECT * FROM person WHERE UPPER(surname) LIKE ... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177240",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18393/"
] |
177,241 | <p>I know how to load themes dynamically when they are stored locally. Is it possible to store theses themes in the database yet still apply them programmatically as described in referenced MSDN article?</p>
<p>Also - If you do store them in the filesystem, is it possible to change the path of the App_Themes directory to a different location? Like Amazon S3?</p>
<p><a href="http://msdn.microsoft.com/en-us/library/tx35bd89.aspx" rel="nofollow noreferrer">Apply Themes Programattically</a></p>
| [
{
"answer_id": 177304,
"author": "CaptainPicard",
"author_id": 15203,
"author_profile": "https://Stackoverflow.com/users/15203",
"pm_score": 2,
"selected": false,
"text": "CREATE INDEX idx_person_upper_surname ON person (UPPER(surname));\n\nSELECT * FROM person WHERE UPPER(surname) LIKE ... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177241",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12442/"
] |
177,242 | <p>Whenever I start our Apache Felix (OSGi) based application under SUN Java ( build 1.6.0_10-rc2-b32 and other 1.6.x builds) I see the following message output on the console (usually under Ubuntu 8.4):</p>
<blockquote>
<p>Warning: The encoding 'UTF-8' is not supported by the Java runtime.</p>
</blockquote>
<p>I've seen this message display occasionally when running both Tomcat and Resin as well. If java supports unicode and UTF-8, what causes this message? I've yet to find any reference, or answer to this anywhere else.</p>
| [
{
"answer_id": 177934,
"author": "tgdavies",
"author_id": 11002,
"author_profile": "https://Stackoverflow.com/users/11002",
"pm_score": 3,
"selected": false,
"text": "import java.nio.charset.Charset;\n\npublic class TestCharset {\n public static void main(String[] args) {\n Sys... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177242",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1720/"
] |
177,251 | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/65820/unit-testing-c-code">Unit Testing C Code</a> </p>
</blockquote>
<p>I've seen a few questions specific to C++, but I'm really curious about C. I'm trying to add a standard unit test framework into our build environment. My primary goals are to encourage our developers to write unit tests, and to standardize those test so others can run them. Ideally I'd like to run the unit tests as part of our nightly build.</p>
<p>We started some work with CUnit, which worked except that everything ran in one thread and any memory faults caused the unit tests to stop running, which was rather annoying. I also found it incredibly difficult to write the tests, but that might just be unit testing for you.</p>
<p>Does anybody know of good alternatives? Has anybody had any experience with the C++ Unit Testers with C-only code?</p>
| [
{
"answer_id": 177440,
"author": "philant",
"author_id": 18804,
"author_profile": "https://Stackoverflow.com/users/18804",
"pm_score": 0,
"selected": false,
"text": "void test_function_returning_a_pointer(void)\n{\n struct_t *theStruct = function_returning_a_pointer();\n MU_ASSERT(... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177251",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25704/"
] |
177,258 | <p>Please can someone help me make sense of the Batch madness?</p>
<p>I'm trying to debug an Axapta 3.0 implementation that has about 50 Batch Jobs. Most of the batched classes do not implement the <strong><code>description()</code></strong> method, so when you look at the <em>Batch List</em> form (Basic>>Inquiries>>Batch list) the description field is blank. You can see the <strong>Batch Group</strong> and the <strong>Start Time</strong>, etc. but you can't tell which class is actually being called.</p>
<p>The <em>Batch</em> table contains a hidden field called <em>ClassNum</em> which identifies the <em>ID</em> property of the class. Can anyone tell me how I can find the corresponding class from the ID? Once I've identified the culprits I can add descriptions.</p>
<p>I tried using the standard <em>Find</em> function on the AOT but it doesn't pick them up. </p>
<p>Any suggestions would be most welcome!</p>
<p>Many thanks,
Mike</p>
| [
{
"answer_id": 177357,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": false,
"text": "display str Classname()\n{\n return ClassId2Name(this.ClassNum); \n}\n"
},
{
"answer_id": 179362,
"author": "... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177258",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
177,259 | <p>Always was interested why are <a href="http://msdn.microsoft.com/en-us/library/system.array.sort.aspx" rel="nofollow noreferrer">Array.Sort()</a> and <a href="http://msdn.microsoft.com/en-us/library/system.array.indexof.aspx" rel="nofollow noreferrer">Array.IndexOf()</a> methods made static and similar <a href="http://msdn.microsoft.com/en-us/library/system.collections.arraylist.sort.aspx" rel="nofollow noreferrer">ArrayList.Sort()</a> and <a href="http://msdn.microsoft.com/en-us/library/system.collections.arraylist.indexof.aspx" rel="nofollow noreferrer">ArrayList.IndexOf()</a> are designed as member methods. Thank you for any ideas.</p>
| [
{
"answer_id": 414084,
"author": "JacquesB",
"author_id": 7488,
"author_profile": "https://Stackoverflow.com/users/7488",
"pm_score": 2,
"selected": false,
"text": "ArrayList"
}
] | 2008/10/07 | [
"https://Stackoverflow.com/questions/177259",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11256/"
] |
177,271 | <p>Can anyone provide some pseudo code for a roulette selection function? How would I implement this:</p>
<p><img src="https://upload.wikimedia.org/math/0/d/2/0d24a82d8e813380f670bf80ae74486b.png" alt="alt text"></p>
<p>I don't really understand how to read this math notation. I never took any probability or statistics.</p>
| [
{
"answer_id": 391712,
"author": "Wartin",
"author_id": 48778,
"author_profile": "https://Stackoverflow.com/users/48778",
"pm_score": 3,
"selected": false,
"text": "// Find the sum of fitnesses. The function fitness(i) should \n//return the fitness value for member i**\n\nfloat sumFitn... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177271",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/577/"
] |
177,277 | <p>I have a TreeView control in my WinForms .NET application that has multiple levels of childnodes that have childnodes with more childnodes, with no defined depth. When a user selects any parent node (not necessarily at the root level), how can I get a list of all the nodes beneith that parent node?</p>
<p>For example, I started off with this:</p>
<pre><code>Dim nodes As List(Of String)
For Each childNodeLevel1 As TreeNode In parentNode.Nodes
For Each childNodeLevel2 As TreeNode In childNodeLevel1.Nodes
For Each childNodeLevel3 As TreeNode In childNodeLevel2.Nodes
nodes.Add(childNodeLevel3.Text)
Next
Next
Next
</code></pre>
<p>The problem is that this loop depth is defined and I'm only getting nodes burried down three levels. What if next time the user selects a parent node, there are seven levels?</p>
| [
{
"answer_id": 177282,
"author": "Steven A. Lowe",
"author_id": 9345,
"author_profile": "https://Stackoverflow.com/users/9345",
"pm_score": 4,
"selected": false,
"text": "function outputNodes(Node root)\n writeln(root.Text)\n foreach(Node n in root.ChildNodes)\n outputNodes(... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177277",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5473/"
] |
177,284 | <p>I have a table that looks something like this:</p>
<pre>
word big expensive smart fast
dog 9 -10 -20 4
professor 2 4 40 -7
ferrari 7 50 0 48
alaska 10 0 1 0
gnat -3 0 0 0
</pre>
<p>The + and - values are associated with the word, so professor is smart and dog is not smart. Alaska is big, as a proportion of the total value associated with its entries, and the opposite is true of gnat.</p>
<p>Is there a good way to get the absolute value of the number farthest from zero, and some token whether absolute value =/= value? Relatedly, how might I calculate whether the results for a given value are proportionately large with respect to the other values? I would write something to format the output to the effect of: "dog: not smart, probably not expensive; professor smart; ferrari: fast, expensive; alaska: big; gnat: probably small." (The formatting is not a question, just an illustration, I am stuck on the underlying queries.) </p>
<p>Also, the rest of the program is python, so if there is any python solution with normal dbapi modules or a more abstract module, any help appreciated.</p>
| [
{
"answer_id": 177308,
"author": "James Curran",
"author_id": 12725,
"author_profile": "https://Stackoverflow.com/users/12725",
"pm_score": 2,
"selected": false,
"text": "select word, big from myTable order by abs(big)\n"
},
{
"answer_id": 177311,
"author": "Mark Harrison",
... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177284",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11596/"
] |
177,287 | <p>Is it possible to produce an alert similar to JavaScript's alert("message") in python, with an application running as a daemon.</p>
<p>This will be run in Windows, Most likely XP but 2000 and Vista are also very real possibilities.</p>
<p>Update:<br />
This is intended to run in the background and alert the user when certain conditions are met, I figure that the easiest way to alert the user would be to produce a pop-up, as it needs to be handled immediately, and other options such as just logging, or sending an email are not efficient enough.</p>
| [
{
"answer_id": 177312,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 7,
"selected": true,
"text": "import win32api\n\nwin32api.MessageBox(0, 'hello', 'title')\n"
},
{
"answer_id": 177316,
"author": "Mikael Jansson"... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177287",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/115/"
] |
177,323 | <p>What is the most efficient way to read the last row with SQL Server?</p>
<p>The table is indexed on a unique key -- the "bottom" key values represent the last row.</p>
| [
{
"answer_id": 177325,
"author": "willurd",
"author_id": 1943957,
"author_profile": "https://Stackoverflow.com/users/1943957",
"pm_score": 4,
"selected": false,
"text": "SELECT * FROM table_name ORDER BY unique_column DESC LIMIT 1"
},
{
"answer_id": 177327,
"author": "Adam Pi... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177323",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2536/"
] |
177,331 | <p>what sql query will i need to show the activated server roles in a specific user?</p>
| [
{
"answer_id": 177403,
"author": "sef",
"author_id": 21963,
"author_profile": "https://Stackoverflow.com/users/21963",
"pm_score": 1,
"selected": false,
"text": "select 'ServerRole' = spv.name, 'MemberName' = lgn.name, 'MemberSID' = lgn.sid\nfrom master.dbo.spt_values spv, master.dbo.sys... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177331",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21963/"
] |
177,338 | <p>When you unload a project in Visual Studio, any referencing projects get warning triangles on their reference to the unloaded project. I've written myself a macro to do clever stuff (detect add/remove of project and transform any references from-to file/project dependency), but I can't believe that I'm not missing something much simpler. How can the unload function be any use if I have to go around manually changing references (and it breaks the 'personal solutions/shared projects' team development paradigm).</p>
<p>(This question is related to answers to <a href="https://stackoverflow.com/questions/152053/structuring-projects-dependencies-of-large-winforms-applications-in-c">this question</a> about structuring large solutions in Visual Studio - some answers mentioned having solutions with lots of projects, but 'unloading' unused projects to improve performance.)</p>
| [
{
"answer_id": 177403,
"author": "sef",
"author_id": 21963,
"author_profile": "https://Stackoverflow.com/users/21963",
"pm_score": 1,
"selected": false,
"text": "select 'ServerRole' = spv.name, 'MemberName' = lgn.name, 'MemberSID' = lgn.sid\nfrom master.dbo.spt_values spv, master.dbo.sys... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177338",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11410/"
] |
177,353 | <p>I am using VB.NET. In Visual Studio, if I right-click a property name and click "Find All References", it searches for all instances of the property being used.</p>
<p>However, a property is always used either for assignment (Set method) or retrieval (Get method). Is there any way of searching for only one of these uses? e.g. search for all uses of the property in code where it is being assigned a value, not when the value is being retrieved.</p>
| [
{
"answer_id": 177426,
"author": "Dandikas",
"author_id": 23436,
"author_profile": "https://Stackoverflow.com/users/23436",
"pm_score": 1,
"selected": false,
"text": "ReSharper.FindUsages"
}
] | 2008/10/07 | [
"https://Stackoverflow.com/questions/177353",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10786/"
] |
177,363 | <p>Is there a way to generate a hash of a string so that the hash itself would be of specific length? I've got a function that generates 41-byte hashes (SHA-1), but I need it to be 33-bytes max (because of certain hardware limitations). If I truncate the 41-byte hash to 33, I'd probably (certainly!) lost the uniqueness.</p>
<p>Or actually I suppose an MD5 algorithm would fit nicely, if I could find some C code for one with your help.</p>
<p>EDIT: Thank you all for the quick and knowledgeable responses. I've chosen to go with an MD5 hash and it fits fine for my purpose. The uniqueness is an important issue, but I don't expect the number of those hashes to be very large at any given time - these hashes represent software servers on a home LAN, so at max there would be 5, maybe 10 running.</p>
| [
{
"answer_id": 177369,
"author": "Robert Gould",
"author_id": 15124,
"author_profile": "https://Stackoverflow.com/users/15124",
"pm_score": 2,
"selected": false,
"text": "/*****Please include following header files*****/\n// string\n/***********************************************/\n\n/*... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177363",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20208/"
] |
177,373 | <p>I have a generic list...</p>
<p>public List<ApprovalEventDto> ApprovalEvents</p>
<p>The ApprovalEventDto has </p>
<pre><code>public class ApprovalEventDto
{
public string Event { get; set; }
public DateTime EventDate { get; set; }
}
</code></pre>
<p>How do I sort the list by the event date?</p>
| [
{
"answer_id": 177380,
"author": "Mark Cidade",
"author_id": 1659,
"author_profile": "https://Stackoverflow.com/users/1659",
"pm_score": 3,
"selected": false,
"text": "using System.Linq;\n\nvoid List<ApprovalEventDto> sort(List<ApprovalEventDto> list)\n { return list.OrderBy(x => x.Event... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177373",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6268/"
] |
177,389 | <p>This question will expand on: <a href="https://stackoverflow.com/questions/68774/best-way-to-open-a-socket-in-python">Best way to open a socket in Python</a><br />
When opening a socket how can I test to see if it has been established, and that it did not timeout, or generally fail.
<br /><br />
Edit:
I tried this:</p>
<pre><code>try:
s.connect((address, '80'))
except:
alert('failed' + address, 'down')
</code></pre>
<p>but the alert function is called even when that connection should have worked.</p>
| [
{
"answer_id": 177411,
"author": "kender",
"author_id": 4172,
"author_profile": "https://Stackoverflow.com/users/4172",
"pm_score": 7,
"selected": true,
"text": "s"
},
{
"answer_id": 177652,
"author": "bortzmeyer",
"author_id": 15625,
"author_profile": "https://Stacko... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177389",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/115/"
] |
177,393 | <p>In our code we used to have something like this:</p>
<pre><code> *(controller->bigstruct) = ( struct bigstruct ){ 0 };
</code></pre>
<p>This used to work great, and then we upgraded versions of GCC and suddenly started seeing stack overflows. Looking at the assembly, the old GCC code (2.x) was basically doing this:</p>
<pre><code>memset(controller->bigstruct, 0, sizeof(struct bigstruct));
</code></pre>
<p>The new GCC (3.4.x) was doing this</p>
<pre><code> struct bigstruct temp = { 0 };
controller->bigstruct = temp;
</code></pre>
<p>After reviewing the C99 spec, I could see why; C99 basically requires that anonymous structures exist on the stack. It's a good concept, but this structure was 4 Megabytes large, and only ever intended to exist on heap!</p>
<p>We've resorted to making our own 'initialize' function that explicitly sets the members, but that's ugly and a maintenance headache. I don't consider memset a proper solution, because I can't know that a bit-value of 0 is an appropriate zero value for the type ( nit-picking, I know, but there you are; I don't mind that the compiler does it, because it <em>can</em> know )</p>
<p>What is the "correct", or at least best, way to initialize a large structure like this? </p>
<p>To furthur clarify why I think memset isn't a solution: The rules of initialization of members not explicitly initialized are the same as static initialization, and are as follows:
- If it has pointer type, it is initialized to a null pointer;
- If it has arithmetic type, it is initialized to ( positive or unsigned ) zero;
...</p>
<p>'memset' will set the memory to bit-pattern zero, which isn't necessarily the same thing. Imagine a system that doesn't use IEEE floating point numbers. Unusual, but supported by C. The representation of 0.0 doesn't have to mean "all-bits zero", it could be anything convenient to the processor.</p>
| [
{
"answer_id": 177402,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 5,
"selected": true,
"text": "#define InitStruct(var, type) type var; memset(&var, 0, sizeof(type))\n"
},
{
"answer_id": 177460,
"author": "Ilya"... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177393",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25704/"
] |
177,414 | <p>How can i go about programaticaly getting the IP address of my network as seen from the Internet? Its obviously a property that my router has access to when it connects to the ISP. Is there any way to get this info from a router using a standard protocol. My only other option is to either find a WS which returns my IP address (suprisingly difficult to do), or just go to something like <a href="http://www.whatismyip.com" rel="nofollow noreferrer">whatismyip.com</a> and strip out all the HTML (very dirty and susceptable to change). Is there any other way??? </p>
| [
{
"answer_id": 177418,
"author": "UnkwnTech",
"author_id": 115,
"author_profile": "https://Stackoverflow.com/users/115",
"pm_score": 1,
"selected": false,
"text": "<?php\necho $_SERVER['REMOTE_ADDR'];\n?>\n"
}
] | 2008/10/07 | [
"https://Stackoverflow.com/questions/177414",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
177,437 | <pre><code>const static int foo = 42;
</code></pre>
<p>I saw this in some code here on StackOverflow and I couldn't figure out what it does. Then I saw some confused answers on other forums. My best guess is that it's used in C to hide the constant <code>foo</code> from other modules. Is this correct? If so, why would anyone use it in a C++ context where you can just make it <code>private</code>?</p>
| [
{
"answer_id": 177443,
"author": "Kevin",
"author_id": 6386,
"author_profile": "https://Stackoverflow.com/users/6386",
"pm_score": 3,
"selected": false,
"text": "const static int foo = 42;\n"
},
{
"answer_id": 177451,
"author": "Chris Arguin",
"author_id": 25704,
"aut... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177437",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2079/"
] |
177,459 | <p>I have a sort of tree structure that represent a hierarchy of layers in a map, divided by types of layers and categories. Each node can be a different class for different types of layers (but all nodes implement a common interface).</p>
<p>I need to convert that class to an ASP.NET TreeView control. Each node in the input tree is a node in the output tree, with properties set that are dependant on the type of the node. I don't want the input tree classes to know the UI classes, so I can't write a "ToTreeViewNode()" method in them. There are currently 4 types of concrete node classes, 2 of them are composite (contain child-nodes) and 2 of them are leaves. This might change in the future.</p>
<p>It feels like there is a design pattern here itching to be used, can you help me find what it is?</p>
| [
{
"answer_id": 193922,
"author": "rabashani",
"author_id": 10977,
"author_profile": "https://Stackoverflow.com/users/10977",
"pm_score": 1,
"selected": false,
"text": "public class Node\n{\n public IDraw genericDrawing;\n public Node[] Childs;\n public Node() { //init you genericDr... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177459",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3389/"
] |
177,475 | <p>I am building a desktop application. Our analysis says it would be better built with a RCP. Should I use the eclipse or netbeans platform to build my application . Some of the factors to consider are</p>
<ul>
<li>Performance</li>
<li>Look and Feel</li>
<li>Popularity among target users (developers/testers)</li>
<li>License (has to be some FOSS)</li>
</ul>
<p>The application will be having things like text editor, grid views, block diagrams and graph visualizations.</p>
<p>I already have experience with netbeans development, but learning eclipse won't hurt. any other options would be welcome too.</p>
| [
{
"answer_id": 228470,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": false,
"text": "http://www.netbeans.org/kb/trails/platform.html\n"
}
] | 2008/10/07 | [
"https://Stackoverflow.com/questions/177475",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9425/"
] |
177,492 | <p>What I would like to achive is: </p>
<ul>
<li>I go to admin site, apply some filters to the list of objects</li>
<li>I click and object edit, edit, edit, hit 'Save'</li>
<li>Site takes me to the list of objects... unfiltered. I'd like to have the filter from step 1 remembered and applied.</li>
</ul>
<p>Is there an easy way to do it?</p>
| [
{
"answer_id": 2645126,
"author": "Ben James",
"author_id": 189179,
"author_profile": "https://Stackoverflow.com/users/189179",
"pm_score": 1,
"selected": false,
"text": "ModelAdmin"
},
{
"answer_id": 9112369,
"author": "Krzysztof",
"author_id": 994350,
"author_profil... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177492",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9622/"
] |
177,496 | <p>I have a simple HTML. I am using the JQuery for AJAX purpose. Now, I want to put my javascript function in a separate javascript file. What is the syntax for this? For example, currently my script section in the HTML is something like this:</p>
<pre><code><script>
<script type="text/javascript" src="scripts/scripts.js"></script>
<script type="text/javascript" src="scripts/jquery.js"></script>
<script type = "text/javascript" language="javascript">
$(document).ready(function() {
$("#SubmitForm").click(Submit());
});
</script>
</code></pre>
<p>But I want to put the function </p>
<pre><code>function() {
$("#SubmitForm").click(Submit());
})
</code></pre>
<p>in the file scripts.js. Can I use assign a name to that function and refer to it? </p>
<p>EDit: I still have a bit of problem here: I changed the code to </p>
<pre><code><script type = "text/javascript" language="javascript">
$(document).ready(function() {
$("#SubmitForm").click(submitMe);
});
</script>
</code></pre>
<p>and in a separate js file, I have the following code:</p>
<pre><code>var submitMe = function(){
alert('clicked23!');
//$('#Testing').html('news');
};
</code></pre>
<p>Here's the body section:</p>
<pre><code><body>
welcome
<form id="SubmitForm" action="/showcontent" method="POST">
<input type="file" name="vsprojFiles" />
<br/>
<input type="submit" id="SubmitButton"/>
</form>
<div id="Testing">
hi
</div>
</body>
</code></pre>
<p>Yet, it is still not working, anything I miss?</p>
| [
{
"answer_id": 177499,
"author": "Mote",
"author_id": 24789,
"author_profile": "https://Stackoverflow.com/users/24789",
"pm_score": -1,
"selected": false,
"text": "$('head').append('<script type=\"text/javascript\" src=\"scripts/scripts.js\"/>')\n"
},
{
"answer_id": 177517,... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177496",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3834/"
] |
177,506 | <pre class="lang-cpp prettyprint-override"><code>double r = 11.631;
double theta = 21.4;
</code></pre>
<p>In the debugger, these are shown as <code>11.631000000000000</code> and <code>21.399999618530273</code>.</p>
<p>How can I avoid this?</p>
| [
{
"answer_id": 177525,
"author": "Mark Ingram",
"author_id": 986,
"author_profile": "https://Stackoverflow.com/users/986",
"pm_score": 4,
"selected": false,
"text": "double theta = 21.4;\n"
},
{
"answer_id": 177749,
"author": "Peter Wone",
"author_id": 1715673,
"autho... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177506",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22076/"
] |
177,514 | <p>I was hoping to implement a simple XMPP server in Java. </p>
<p>What I need is a library which can parse and understand xmpp requests from a client. I have looked at Smack (mentioned below) and JSO. Smack appears to be client only so while it might help parsing packets it doesn't know how to respond to clients. Is JSO maintained it looks very old. The only promising avenue is to pull apart Openfire which is an entire commercial (OSS) XMPP server.</p>
<p>I was just hoping for a few lines of code on top of Netty or Mina, so I could get started processing some messages off the wire.</p>
<hr>
<p>Joe - </p>
<p>Well the answer to what I am trying to do is somewhat long - I'll try to keep it short. </p>
<p>There are two things, that are only loosely related:</p>
<p>1) I wanted to write an XMPP server because I imagine writing a custom protocol for two clients to communicate. Basically I am thinking of a networked iPhone app - but I didn't want to rely on low-level binary protocols because using something like XMPP means the app can "grow up" very quickly from a local wifi based app to an internet based one...</p>
<p>The msgs exchanged should be relatively low latency, so strictly speaking a binary protocol would be best, but I felt that it might be worth exploring if XMPP didn't introduce too much overhead such that I could use it and then reap benefits of it's extensability and flexability later.</p>
<p>2) I work for Terracotta - so I have this crazy bent to cluster everything. As soon as I started thinking about writing some custom server code, I figured I wanted to cluster it. Terracotta makes scaling out Java POJOs trivial, so my thought was to build a super simple XMPP server as a demonstration app for Terracotta. Basically each user would connect to the server over a TCP connection, which would register the user into a hashmap. Each user would have a LinkedBlockingQueue with a listener thread taking message from the queue. Then any connected user that wants to send a message to any other user (e.g. any old chat application) simply issues an XMPP message (as usual) to that user over the connection. The server picks it up, looks up the corresponding user object in a map and places the message onto the queue. Since the queue is clustered, regardless of wether the destination user is connected to the same physical server, or a different physical server, the message is delivered and the thread that is listening picks it up and sends it back down the destination user's tcp connection.</p>
<p>So - not too short of a summary I'm afraid. But that's what I want to do. I suppose I could just write a plugin for Openfire to accomplish #1 but I think it takes care of a lot of plumbing so it's harder to do #2 (especially since I was hoping for a very small amount of code that could fit into a simple 10-20kb Maven project).</p>
| [
{
"answer_id": 2427358,
"author": "Bill Barnhill",
"author_id": 204343,
"author_profile": "https://Stackoverflow.com/users/204343",
"pm_score": 3,
"selected": false,
"text": "object Main {\n\n/**\n* @param args the command line arguments\n*/\n def main(args: Array[String]) :Unit = {\n ... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177514",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19013/"
] |
177,519 | <p>Im trying to squeeze some extra performance from searching through a table with many rows.
My current reasoning is that if I can throw away some of the seldom used member from the searched table thereby reducing rowsize the amount of pagesplits and hence IO should drop giving a benefit when data start to spill from memory. </p>
<p>Any good resource detailing such effects?
Any experiences?</p>
<p>Thanks.</p>
| [
{
"answer_id": 178204,
"author": "Mitch Wheat",
"author_id": 16076,
"author_profile": "https://Stackoverflow.com/users/16076",
"pm_score": 1,
"selected": false,
"text": "SET STATISTICS IO ON\nGO\n\n\n-- Execute your query here\n\n\nSET STATISTICS IO OFF\nGO\n"
}
] | 2008/10/07 | [
"https://Stackoverflow.com/questions/177519",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21182/"
] |
177,520 | <p>I am wondering if there are any alternatives to using the Expand key word when performing an LINQ to ADO.net Data Services query. The expand method does get me the data I am interested in, but it requires me to know all of the sub-objects that I am going to be working with in advance. My absolute preference would be that those sub-objects would be lazy loaded for me when I access them, but this doesn't look to be an option (I could add this lazy loading to the get on that sub-object property, but it gets wiped out when I do an update of the data service reference).</p>
<p>Does anyone have any suggestions/best practices/alternatives for this situation? Thanks.</p>
<p>===== Example Code using Member that has a MailingAddress =====</p>
<p>Works: </p>
<pre><code>var me = (from m in ctx.Member.Expand("MailingAddress")
where m.MemberID == 10000
select m).First();
MessageBox.Show(me.MailingAddress.Street);
</code></pre>
<p>Would Prefer (would really like if this then went and loaded the MailingAddress)</p>
<pre><code>var me = (from m in ctx.Member
where m.MemberID == 10000
select m).First();
MessageBox.Show(me.MailingAddress.Street);
</code></pre>
<p>Or at least (note: something similar to this, with MailingAddressReference, works on the server side if I do so as LINQ to Entities in a Service Operation)</p>
<pre><code>var me = (from m in ctx.Member
where m.MemberID == 10000
select m).First();
if (!(me.MailingAddress.IsLoaded())) me.MailingAddress.Load()
MessageBox.Show(me.MailingAddress.Street);
</code></pre>
| [
{
"answer_id": 178391,
"author": "Craig Stuntz",
"author_id": 7714,
"author_profile": "https://Stackoverflow.com/users/7714",
"pm_score": 2,
"selected": false,
"text": "me = me.Include(\"MailingAddress\");\n"
},
{
"answer_id": 190016,
"author": "ChrisHDog",
"author_id": 2... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177520",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25719/"
] |
177,536 | <p>Is there a simple way to prevent browser from downloading and displaying images, best would be via some magic style tag or javasctipe.</p>
<p>The thing is, I'd like to tweak the company's website a bit to be more usable via mobile devices. The company is a gaming one, there's like 5MBs of images on it's main page (and those can't be touched). They alredy display deadly slow on my dsl, and they can be killers to someone who's paying for his GPRS per MB ;)</p>
<p>The code of the page is not mine and shouldn't be touched too (in fact, it should be written from scratch, but it's not in my gesture to do it now) :)</p>
<p>I was thinking about two solutions:</p>
<p>1) If there was some kind of style-tag (or maybe a javascript? the one that would work on mobile browsers tho) that would prevent browser from downloading images and force to display alt-parameter instead I could simply attach this style if I discovered a user-agent to be some known mobile thing.
or 2) I could tweak the webserver a bit to check the User-agent header and if client requests an image (.png, .gif and .jpg) send 404 instead. That has a downside tho - I'd like to allow the user to view images if he actually wants to.</p>
<p>It seems that first solution would be best - what you guys think? And is there a javascript way to do it? </p>
<p>I could try building document DOM, then get all <code><img></code> elements, and replace their <code>src</code> with some placeholder even but will that work on most mobile browsers (Opera Mini I suppose, the Windows Mobile thingy, the basic Symbian browser from Nokia)? And would playing with document DOM be a good solution on a mobile device (I'm not sure about it's memory-and-cpu requirements to be honest).</p>
| [
{
"answer_id": 177654,
"author": "Treb",
"author_id": 22114,
"author_profile": "https://Stackoverflow.com/users/22114",
"pm_score": 0,
"selected": false,
"text": "<link rel=\"stylesheet\" media=\"screen,projection,tv\" href=\"main.css\" type=\"text/css\">\n<link rel=\"stylesheet\" media=... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177536",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4172/"
] |
177,538 | <p>Every time I need to do something <em>N</em> times inside an algorithm using C# I write this code</p>
<pre><code>for (int i = 0; i < N; i++)
{
...
}
</code></pre>
<p>Studying Ruby I have learned about method <em>times()</em> which can be used with the same semantics like this</p>
<pre><code>N.times do
...
end
</code></pre>
<p>Code fragment in C# looks more complex and we should declare useless variable <em>i</em>.</p>
<p>I tried to write extension method which returns <em>IEnumerable</em>, but I am not satisfied with the result because again I have to declare a cycle variable <em>i</em>.</p>
<pre><code>public static class IntExtender
{
public static IEnumerable Times(this int times)
{
for (int i = 0; i < times; i++)
yield return true;
}
}
...
foreach (var i in 5.Times())
{
...
}
</code></pre>
<p>Is it possible using some new C# 3.0 language features to make <em>N</em> times cycle more elegant?</p>
| [
{
"answer_id": 177551,
"author": "cvk",
"author_id": 25397,
"author_profile": "https://Stackoverflow.com/users/25397",
"pm_score": 4,
"selected": false,
"text": "public interface ILoopIterator\n{\n void Do(Action action);\n void Do(Action<int> action);\n}\n\nprivate class LoopItera... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177538",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11256/"
] |
177,550 | <p>While estimating straight row and table sizes are fairly simple math, we find it challenging to guess just how much space each index will occupy (for a given table size). What areas can we learn to calculate a better estimate and growth rate for indexes?</p>
| [
{
"answer_id": 23830119,
"author": "Marcello Miorelli",
"author_id": 1501497,
"author_profile": "https://Stackoverflow.com/users/1501497",
"pm_score": 1,
"selected": false,
"text": "--Find out the disk size of an index:\n--USE [DB NAME HERE]\ngo\nSELECT\nOBJECT_NAME(I.OBJECT_ID) AS Table... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177550",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2663/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.