qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
6,110
<p>I've been handed a table with about 18000 rows. Each record describes the location of one customer. The issue is, that when the person created the table, they did not add a field for "Company Name", only "Location Name," and one company can have many locations.</p> <p>For example, here are some records that describe the same customer:</p> <p><strong>Location Table</strong></p> <pre><code> ID Location_Name 1 TownShop#1 2 Town Shop - Loc 2 3 The Town Shop 4 TTS - Someplace 5 Town Shop,the 3 6 Toen Shop4 </code></pre> <p>My goal is to make it look like:</p> <p><strong>Location Table</strong></p> <pre><code> ID Company_ID Location_Name 1 1 Town Shop#1 2 1 Town Shop - Loc 2 3 1 The Town Shop 4 1 TTS - Someplace 5 1 Town Shop,the 3 6 1 Toen Shop4 </code></pre> <p><strong>Company Table</strong></p> <pre><code> Company_ID Company_Name 1 The Town Shop </code></pre> <p>There is no "Company" table, I will have to generate the Company Name list from the most descriptive or best Location Name that represents the multiple locations.</p> <p>Currently I am thinking I need to generate a list of Location Names that are similar, and then and go through that list by hand.</p> <p>Any suggestions on how I can approach this is appreciated.</p> <p><strong>@Neall, Thank you for your statement, but unfortunately, each location name is distinct, there are no duplicate location names, only similar. So in the results from your statement "repcount" is 1 in each row.</strong></p> <p><strong>@yukondude, Your step 4 is the heart of my question.</strong></p>
[ { "answer_id": 6119, "author": "Neall", "author_id": 619, "author_profile": "https://Stackoverflow.com/users/619", "pm_score": 1, "selected": false, "text": "SELECT count(*) AS repcount, \"Location Name\" FROM mytable\n WHERE \"Company Name\" IS NULL\n GROUP BY \"Location Name\"\n ORDER ...
2008/08/08
[ "https://Stackoverflow.com/questions/6110", "https://Stackoverflow.com", "https://Stackoverflow.com/users/754/" ]
6,113
<p>The application my team is currently developing has a DLL that is used to perform all database access. The application can not use a trusted connection because the database is behind a firewall and the domain server is not. So it appears that the connection string needs to have a DB username and password. The DLL currently has the database connection string hard coded, but I don't want to do this when we launch as the assembly can be disassembled and the username and password would be right there in the open.</p> <p>One of the requirements is that the password needs to be changed once every few months, so we would need to roll that out to our internal user base.</p> <p>Is there a way to store the password encrypted in such a way we can easily distribute to the entire user base without storing it in the assembly?</p> <p>UPDATE: Thanks to everyone who's answered. I'll try to answer some of the questions back to me... The data DLL is used by both ASP.NET WebForms and VB.NET WinForms. I understand that Applications can have their own config files, but I haven't seen anything on config files for DLLs. Unfortunately, I can't get to the Jon Galloway post at work so I can't judge if that will work. From a development standpoint, we don't want to use web services inhouse, but may be providing them to third parties sometime next year. I don't think impersonation will work because we can't authenticate the user through the firewall. As a user (or former user) can be an attacker, we're keeping it from everyone!</p>
[ { "answer_id": 6123, "author": "Kev", "author_id": 419, "author_profile": "https://Stackoverflow.com/users/419", "pm_score": 0, "selected": false, "text": "web.config" }, { "answer_id": 6176, "author": "Brian Childress", "author_id": 721, "author_profile": "https://St...
2008/08/08
[ "https://Stackoverflow.com/questions/6113", "https://Stackoverflow.com", "https://Stackoverflow.com/users/702/" ]
6,126
<p>It's something that's bugged me in every language I've used, I have an if statement but the conditional part has so many checks that I have to split it over multiple lines, use a nested if statement or just accept that it's ugly and move on with my life.</p> <p>Are there any other methods that you've found that might be of use to me and anybody else that's hit the same problem?</p> <p>Example, all on one line:</p> <pre><code>if (var1 = true &amp;&amp; var2 = true &amp;&amp; var2 = true &amp;&amp; var3 = true &amp;&amp; var4 = true &amp;&amp; var5 = true &amp;&amp; var6 = true) { </code></pre> <p>Example, multi-line:</p> <pre><code>if (var1 = true &amp;&amp; var2 = true &amp;&amp; var2 = true &amp;&amp; var3 = true &amp;&amp; var4 = true &amp;&amp; var5 = true &amp;&amp; var6 = true) { </code></pre> <p>Example-nested:</p> <pre><code>if (var1 = true &amp;&amp; var2 = true &amp;&amp; var2 = true &amp;&amp; var3 = true) { if (var4 = true &amp;&amp; var5 = true &amp;&amp; var6 = true) { </code></pre>
[ { "answer_id": 6131, "author": "abyx", "author_id": 573, "author_profile": "https://Stackoverflow.com/users/573", "pm_score": 3, "selected": false, "text": "== true" }, { "answer_id": 6132, "author": "TimM", "author_id": 32, "author_profile": "https://Stackoverflow.co...
2008/08/08
[ "https://Stackoverflow.com/questions/6126", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1384652/" ]
6,130
<p>I'm using subclipse in Flex Builder 3, and recently received this error when trying to commit:</p> <p><code>svn: Checksum mismatch for '/Users/redacted/Documents/Flex Builder 3/path/to/my/file.mxml'; expected: 'f8cb275de72776657406154dd3c10348', actual: 'null'</code></p> <p>I worked around it by:</p> <ol> <li>Committing all the other changed files, omitting the troublesome one.</li> <li>Copying the contents of the trouble file to a TextMate window</li> <li>Deleting my project in FlexBuilder/Eclipse</li> <li>Checking my project out fresh from SVN</li> <li>Copying the text of the trouble file back in from the TextMate Window</li> <li>Committing the changes.</li> </ol> <p>It worked, but I can't help but think there's a better way. What's actaully happening to cause the svn:checksum error, and what's the best fix.</p> <p>Maybe more important -- is this a symptom of a greater problem?</p>
[ { "answer_id": 6509, "author": "Polsonby", "author_id": 137, "author_profile": "https://Stackoverflow.com/users/137", "pm_score": 3, "selected": false, "text": "svn update\n" }, { "answer_id": 1771570, "author": "jsh", "author_id": 132408, "author_profile": "https://S...
2008/08/08
[ "https://Stackoverflow.com/questions/6130", "https://Stackoverflow.com", "https://Stackoverflow.com/users/763/" ]
6,134
<p>I have a problem with some zombie-like processes on a certain server that need to be killed every now and then. How can I best identify the ones that have run for longer than an hour or so?</p>
[ { "answer_id": 6145, "author": "Mark Harrison", "author_id": 116, "author_profile": "https://Stackoverflow.com/users/116", "pm_score": 5, "selected": false, "text": "ps aux\n" }, { "answer_id": 6150, "author": "yukondude", "author_id": 726, "author_profile": "https://...
2008/08/08
[ "https://Stackoverflow.com/questions/6134", "https://Stackoverflow.com", "https://Stackoverflow.com/users/726/" ]
6,155
<p>What kinds of hook scripts are people using for Subversion? Just general ideas but code would be great too!</p>
[ { "answer_id": 68850, "author": "Philibert Perusse", "author_id": 7984, "author_profile": "https://Stackoverflow.com/users/7984", "pm_score": 6, "selected": false, "text": "pre-revprop-change" }, { "answer_id": 3630318, "author": "Philibert Perusse", "author_id": 7984, ...
2008/08/08
[ "https://Stackoverflow.com/questions/6155", "https://Stackoverflow.com", "https://Stackoverflow.com/users/204/" ]
6,173
<p>I'm looking for a .NET regular expression extract all the URLs from a webpage but haven't found one to be comprehensive enough to cover all the different ways you can specify a link. </p> <p>And a side question:</p> <p>Is there <strong>one regex to rule them all</strong>? Or am I better off using a series of less complicated regular expressions and just using mutliple passes against the raw HTML? (Speed vs. Maintainability)</p>
[ { "answer_id": 6179, "author": "Kevin", "author_id": 40, "author_profile": "https://Stackoverflow.com/users/40", "pm_score": 0, "selected": false, "text": "%href=\"(.[\"]*)\"%" }, { "answer_id": 6181, "author": "Neall", "author_id": 619, "author_profile": "https://Sta...
2008/08/08
[ "https://Stackoverflow.com/questions/6173", "https://Stackoverflow.com", "https://Stackoverflow.com/users/322/" ]
6,184
<p>When you subscribe to an event on an object from within a form, you are essentially handing over control of your callback method to the event source. You have no idea whether that event source will choose to trigger the event on a different thread.</p> <p>The problem is that when the callback is invoked, you cannot assume that you can make update controls on your form because sometimes those controls will throw an exception if the event callback was called on a thread different than the thread the form was run on.</p>
[ { "answer_id": 6189, "author": "Simon Gillbee", "author_id": 756, "author_profile": "https://Stackoverflow.com/users/756", "pm_score": 4, "selected": false, "text": "private delegate void EventArgsDelegate(object sender, EventArgs ea);\n\nvoid SomethingHappened(object sender, EventArgs e...
2008/08/08
[ "https://Stackoverflow.com/questions/6184", "https://Stackoverflow.com", "https://Stackoverflow.com/users/756/" ]
6,209
<p>Given a string like this:</p> <blockquote> <p>a,"string, with",various,"values, and some",quoted</p> </blockquote> <p>What is a good algorithm to split this based on commas while ignoring the commas inside the quoted sections?</p> <p>The output should be an array:</p> <blockquote> <p>[ "a", "string, with", "various", "values, and some", "quoted" ]</p> </blockquote>
[ { "answer_id": 6215, "author": "Pat", "author_id": 238, "author_profile": "https://Stackoverflow.com/users/238", "pm_score": 2, "selected": false, "text": "Loop on the string letter by letter.\n If current_letter == quote : \n toggle inside_quote variable.\n Else if (current...
2008/08/08
[ "https://Stackoverflow.com/questions/6209", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
6,301
<p>Why is <code>Array.Length</code> an int, and not a <code>uint</code>. This bothers me (just a bit) because a length value can never be negative. </p> <p>This also forced me to use an int for a length-property on my own class, because when you specify an int-value, this needs to be cast explicitly...</p> <p>So the ultimate question is: is there any use for an unsigned int (<code>uint</code>)? Even Microsoft seems not to use them.</p>
[ { "answer_id": 6320, "author": "Kev", "author_id": 419, "author_profile": "https://Stackoverflow.com/users/419", "pm_score": 7, "selected": true, "text": "UInt" } ]
2008/08/08
[ "https://Stackoverflow.com/questions/6301", "https://Stackoverflow.com", "https://Stackoverflow.com/users/56/" ]
6,326
<p>I have the following html.erb code that I'm looking to move to Haml:</p> <pre><code>&lt;span class="&lt;%= item.dashboardstatus.cssclass %&gt;" &gt;&lt;%= item.dashboardstatus.status %&gt;&lt;/span&gt; </code></pre> <p>What it does is associate the CSS class of the currently assigned status to the span.</p> <p>How is this done in Haml? I'm sure I'm missing something really simple.</p>
[ { "answer_id": 6355, "author": "Christian Lescuyer", "author_id": 341, "author_profile": "https://Stackoverflow.com/users/341", "pm_score": 5, "selected": true, "text": "%span{:class => item.dashboardstatus.cssclass }= item.dashboardstatus.status\n" }, { "answer_id": 46319782, ...
2008/08/08
[ "https://Stackoverflow.com/questions/6326", "https://Stackoverflow.com", "https://Stackoverflow.com/users/722/" ]
6,340
<p>I've got a table that is supposed to track days and costs for shipping product from one vendor to another. We (brilliantly :p) stored both the shipping vendors (FedEx, UPS) with the product handling vendors (Think... Dunder Mifflin) in a "VENDOR" table. So, I have three columns in my SHIPPING_DETAILS table that all reference VENDOR.no. For some reason MySQL isn't letting me define all three as foreign keys. Any ideas?</p> <pre><code>CREATE TABLE SHIPPING_GRID( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY COMMENT 'Unique ID for each row', shipping_vendor_no INT(6) NOT NULL COMMENT 'Foreign key to VENDOR.no for the shipping vendor (vendors_type must be 3)', start_vendor_no INT(6) NOT NULL COMMENT 'Foreign key to VENDOR.no for the vendor being shipped from', end_vendor_no INT(6) NOT NULL COMMENT 'Foreign key to the VENDOR.no for the vendor being shipped to', shipment_duration INT(1) DEFAULT 1 COMMENT 'Duration in whole days shipment will take', price FLOAT(5,5) NOT NULL COMMENT 'Price in US dollars per shipment lbs (down to 5 decimal places)', is_flat_rate TINYINT(1) DEFAULT 0 COMMENT '1 if is flat rate regardless of weight, 0 if price is by lbs', INDEX (shipping_vendor_no), INDEX (start_vendor_no), INDEX (end_vendor_no), FOREIGN KEY (shipping_vendor_no) REFERENCES VENDOR (no), FOREIGN KEY (start_vendor_no) REFERENCES VENDOR (no), FOREIGN KEY (end_vendor_no) REFERENCES VENDOR (no) ) TYPE = INNODB; </code></pre> <p><em>Edited to remove double primary key definition...</em></p> <hr> <p>Yeah, unfortunately that didn't fix it though. Now I'm getting:</p> <blockquote> <p>Can't create table './<em>REMOVED MY DB NAME</em>/SHIPPING_GRID.frm' (errno: 150)</p> </blockquote> <p>Doing a phpinfo() tells me this for mysql:</p> <blockquote> <p>Client API version 5.0.45</p> </blockquote> <p>Yes, the VENDOR.no is type int(6).</p>
[ { "answer_id": 6349, "author": "Christian Lescuyer", "author_id": 341, "author_profile": "https://Stackoverflow.com/users/341", "pm_score": 5, "selected": true, "text": "CREATE TABLE SHIPPING_GRID( \n id INT NOT NULL AUTO_INCREMENT PRIMARY KEY COMMENT 'Unique ID for each row', \n ...
2008/08/08
[ "https://Stackoverflow.com/questions/6340", "https://Stackoverflow.com", "https://Stackoverflow.com/users/58/" ]
6,369
<p>So I have a Sybase stored proc that takes 1 parameter that's a comma separated list of strings and runs a query with in in an IN() clause:</p> <pre><code>CREATE PROCEDURE getSomething @keyList varchar(4096) AS SELECT * FROM mytbl WHERE name IN (@keyList) </code></pre> <p>How do I call my stored proc with more than 1 value in the list? So far I've tried </p> <pre><code>exec getSomething 'John' -- works but only 1 value exec getSomething 'John','Tom' -- doesn't work - expects two variables exec getSomething "'John','Tom'" -- doesn't work - doesn't find anything exec getSomething '"John","Tom"' -- doesn't work - doesn't find anything exec getSomething '\'John\',\'Tom\'' -- doesn't work - syntax error </code></pre> <p><strong>EDIT:</strong> I actually found this <a href="http://vyaskn.tripod.com/passing_arrays_to_stored_procedures.htm" rel="noreferrer">page</a> that has a great reference of the various ways to pas an array to a sproc</p>
[ { "answer_id": 6377, "author": "Brian Childress", "author_id": 721, "author_profile": "https://Stackoverflow.com/users/721", "pm_score": 0, "selected": false, "text": "DECLARE @idoc int\nDECLARE @doc varchar(1000)\nSET @doc ='\n<ROOT>\n<Customer CustomerID=\"VINET\" ContactName=\"Paul He...
2008/08/08
[ "https://Stackoverflow.com/questions/6369", "https://Stackoverflow.com", "https://Stackoverflow.com/users/779/" ]
6,371
<p>I've had a hard time trying to find good examples of how to manage database schemas and data between development, test, and production servers.</p> <p>Here's our setup. Each developer has a virtual machine running our app and the MySQL database. It is their personal sandbox to do whatever they want. Currently, developers will make a change to the SQL schema and do a dump of the database to a text file that they commit into SVN.</p> <p>We're wanting to deploy a continuous integration development server that will always be running the latest committed code. If we do that now, it will reload the database from SVN for each build.</p> <p>We have a test (virtual) server that runs "release candidates." Deploying to the test server is currently a very manual process, and usually involves me loading the latest SQL from SVN and tweaking it. Also, the data on the test server is inconsistent. You end up with whatever test data the last developer to commit had on his sandbox server.</p> <p>Where everything breaks down is the deployment to production. Since we can't overwrite the live data with test data, this involves manually re-creating all the schema changes. If there were a large number of schema changes or conversion scripts to manipulate the data, this can get really hairy.</p> <p>If the problem was just the schema, It'd be an easier problem, but there is "base" data in the database that is updated during development as well, such as meta-data in security and permissions tables.</p> <p>This is the biggest barrier I see in moving toward continuous integration and one-step-builds. How do <strong><em>you</em></strong> solve it?</p> <hr> <p>A follow-up question: how do you track database versions so you know which scripts to run to upgrade a given database instance? Is a version table like Lance mentions below the standard procedure?</p> <hr> <p>Thanks for the reference to Tarantino. I'm not in a .NET environment, but I found their <a href="http://code.google.com/p/tarantino/wiki/DatabaseChangeManagement" rel="noreferrer">DataBaseChangeMangement wiki page</a> to be very helpful. Especially this <a href="http://tarantino.googlecode.com/svn/docs/Database-Change-Management.ppt" rel="noreferrer">Powerpoint Presentation (.ppt)</a></p> <p>I'm going to write a Python script that checks the names of <code>*.sql</code> scripts in a given directory against a table in the database and runs the ones that aren't there in order based on a integer that forms the first part of the filename. If it is a pretty simple solution, as I suspect it will be, then I'll post it here.</p> <hr> <p>I've got a working script for this. It handles initializing the DB if it doesn't exist and running upgrade scripts as necessary. There are also switches for wiping an existing database and importing test data from a file. It's about 200 lines, so I won't post it (though I might put it on pastebin if there's interest).</p>
[ { "answer_id": 775948, "author": "Yordan Georgiev", "author_id": 65706, "author_profile": "https://Stackoverflow.com/users/65706", "pm_score": 3, "selected": false, "text": "dev_<<db>> , tst_<<db>> , stg_<<db>> , prd_<<db>>" } ]
2008/08/08
[ "https://Stackoverflow.com/questions/6371", "https://Stackoverflow.com", "https://Stackoverflow.com/users/763/" ]
6,373
<p>There are two popular closure styles in javascript. The first I call <em>anonymous constructor</em>:</p> <pre><code>new function() { var code... } </code></pre> <p>and the <em>inline executed function</em>:</p> <pre><code>(function() { var code... })(); </code></pre> <p>are there differences in behaviour between those two? Is one "better" over the other?</p>
[ { "answer_id": 6387, "author": "doekman", "author_id": 56, "author_profile": "https://Stackoverflow.com/users/56", "pm_score": 3, "selected": false, "text": "function Blah() {\n alert('blah');\n}\nnew Bla();\n" }, { "answer_id": 6424, "author": "olliej", "author_id": 7...
2008/08/08
[ "https://Stackoverflow.com/questions/6373", "https://Stackoverflow.com", "https://Stackoverflow.com/users/56/" ]
6,392
<p>I am running a Tomcat application, and I need to display some time values. Unfortunately, the time is coming up an hour off. I looked into it and discovered that my default TimeZone is being set to:</p> <pre><code>sun.util.calendar.ZoneInfo[id="GMT-08:00", offset=-28800000, dstSavings=0, useDaylight=false, transitions=0, lastRule=null] </code></pre> <p>Rather than the Pacific time zone. This is further indicated when I try to print the default time zone's <a href="http://docs.oracle.com/javase/7/docs/api/java/util/TimeZone.html#getDisplayName()" rel="noreferrer">display name</a>, and it comes up "GMT-08:00", which seems to indicate to me that it is not correctly set to the US Pacific time zone. I am running on Ubuntu Hardy Heron, upgraded from Gutsy Gibbon.</p> <p>Is there a configuration file I can update to tell the JRE to use Pacific with all the associated daylight savings time information? The time on my machine shows correctly, so it doesn't seem to be an OS-wide misconfiguration.</p> <hr> <p>Ok, here's an update. A coworker suggested I update JAVA_OPTS in my /etc/profile to include "-Duser.timezone=US/Pacific", which worked (I also saw CATALINA_OPTS, which I updated as well). Actually, I just exported the change into the variables rather than use the new /etc/profile (a reboot later will pick up the changes and I will be golden).</p> <p>However, I still think there is a better solution... there should be a configuration for Java somewhere that says what timezone it is using, or how it is grabbing the timezone. If someone knows such a setting, that would be awesome, but for now this is a decent workaround.</p> <hr> <p>I am using 1.5, and it is most definitely a DST problem. As you can see, the time zone is set to not use daylight savings. My belief is it is generically set to -8 offset rather than the specific Pacific timezone. Since the generic -8 offset has no daylight savings info, it's of course not using it, but the question is, where do I tell Java to use Pacific time zone when it starts up? I'm NOT looking for a programmatic solution, it should be a configuration solution.</p>
[ { "answer_id": 6496, "author": "Jason Day", "author_id": 737, "author_profile": "https://Stackoverflow.com/users/737", "pm_score": 6, "selected": true, "text": "# sudo cp /etc/localtime /etc/localtime.dist\n# sudo ln -fs /usr/share/zoneinfo/America/Los_Angeles /etc/localtime\n" }, { ...
2008/08/08
[ "https://Stackoverflow.com/questions/6392", "https://Stackoverflow.com", "https://Stackoverflow.com/users/122/" ]
6,406
<p>Is it possible to access an element on a Master page from the page loaded within the <code>ContentPlaceHolder</code> for the master?</p> <p>I have a ListView that lists people's names in a navigation area on the Master page. I would like to update the ListView after a person has been added to the table that the ListView is data bound to. The <code>ListView</code> currently does not update it's values until the cache is reloaded. We have found that just re-running the <code>ListView.DataBind()</code> will update a listview's contents. We have not been able to run the <code>ListView.DataBind()</code> on a page that uses the Master page. </p> <p>Below is a sample of what I wanted to do but a compiler error says </p> <blockquote> <p>"PeopleListView does not exist in the current context"</p> </blockquote> <p>GIS.master - Where ListView resides</p> <pre><code>...&lt;asp:ListView ID="PeopleListView"... </code></pre> <p>GISInput_People.aspx - Uses GIS.master as it's master page</p> <p>GISInput_People.aspx.cs</p> <pre><code>AddNewPerson() { // Add person to table .... // Update Person List PeopleListView.DataBind(); ... } </code></pre> <p>What would be the best way to resolve an issue like this in C# .Net?</p>
[ { "answer_id": 6411, "author": "Brandon Wood", "author_id": 423, "author_profile": "https://Stackoverflow.com/users/423", "pm_score": -1, "selected": false, "text": "(Master as MyMaster).PeopleListView.DataBind();\n" }, { "answer_id": 6413, "author": "Kev", "author_id": 4...
2008/08/08
[ "https://Stackoverflow.com/questions/6406", "https://Stackoverflow.com", "https://Stackoverflow.com/users/576/" ]
6,414
<p>In a C# (feel free to answer for other languages) loop, what's the difference between <code>break</code> and <code>continue</code> as a means to leave the structure of the loop, and go to the next iteration?</p> <p>Example:</p> <pre><code>foreach (DataRow row in myTable.Rows) { if (someConditionEvalsToTrue) { break; //what's the difference between this and continue ? //continue; } } </code></pre>
[ { "answer_id": 6415, "author": "palmsey", "author_id": 521, "author_profile": "https://Stackoverflow.com/users/521", "pm_score": 5, "selected": false, "text": "break" }, { "answer_id": 6417, "author": "Michael Stum", "author_id": 91, "author_profile": "https://Stackov...
2008/08/08
[ "https://Stackoverflow.com/questions/6414", "https://Stackoverflow.com", "https://Stackoverflow.com/users/357/" ]
6,430
<p>I'm suddenly back to WinForms, after years of web development, and am having trouble with something that should be simple. I have an <code>ArrayList</code> of business objects bound to a Windows Forms <code>DataGrid</code>. I'd like the user to be able to edit the cells, and when finished, press a Save button. At that point I'd like to iterate the all the rows and columns in the <code>DataGrid</code> to find any changes, and save them to the database. But I can't find a way to access the <code>DataGrid</code> rows. </p> <p>I'll also want to validate individual cells real time, as they are edited, but I'm pretty sure that can be done. (Maybe not with an <code>ArrayList</code> as the <code>DataSource</code>?) But as for iterating the <code>DataGrid</code>, I'm quite surprised it doesn't seem possible.</p> <p>Must I really stuff my business objects data into datatables in order to use the datagrid? </p>
[ { "answer_id": 6435, "author": "NotMyself", "author_id": 303, "author_profile": "https://Stackoverflow.com/users/303", "pm_score": 4, "selected": true, "text": "foreach(var row in DataGrid1.Rows)\n{\n DoStuff(row);\n}\n//Or --------------------------------------------- \nforeach(DataG...
2008/08/08
[ "https://Stackoverflow.com/questions/6430", "https://Stackoverflow.com", "https://Stackoverflow.com/users/785/" ]
6,441
<p>The following code works great in IE, but not in FF or Safari. I can't for the life of me work out why. The code is <em>supposed</em> to disable radio buttons if you select the &quot;Disable 2 radio buttons&quot; option. It should enable the radio buttons if you select the &quot;Enable both radio buttons&quot; option. These both work...</p> <p>However, if you don't use your mouse to move between the 2 options (&quot;Enable...&quot; and &quot;Disable...&quot;) then the radio buttons do not appear to be disabled or enabled correctly, until you click anywhere else on the page (not on the radio buttons themselves).</p> <p>If anyone has time/is curious/feeling helpful, please paste the code below into an html page and load it up in a browser. It works great in IE, but the problem manifests itself in FF (3 in my case) and Safari, all on Windows XP.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>function SetLocationOptions() { var frmTemp = document.frm; var selTemp = frmTemp.user; if (selTemp.selectedIndex &gt;= 0) { var myOpt = selTemp.options[selTemp.selectedIndex]; if (myOpt.attributes[0].nodeValue == '1') { frmTemp.transfer_to[0].disabled = true; frmTemp.transfer_to[1].disabled = true; frmTemp.transfer_to[2].checked = true; } else { frmTemp.transfer_to[0].disabled = false; frmTemp.transfer_to[1].disabled = false; } } }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;form name="frm" action="coopfunds_transfer_request.asp" method="post"&gt; &lt;select name="user" onchange="javascript: SetLocationOptions()"&gt; &lt;option value="" /&gt;Choose One &lt;option value="58" user_is_tsm="0" /&gt;Enable both radio buttons &lt;option value="157" user_is_tsm="1" /&gt;Disable 2 radio buttons &lt;/select&gt; &lt;br /&gt;&lt;br /&gt; &lt;input type="radio" name="transfer_to" value="fund_amount1" /&gt;Premium&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;input type="radio" name="transfer_to" value="fund_amount2" /&gt;Other&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;input type="radio" name="transfer_to" value="both" CHECKED /&gt;Both &lt;br /&gt;&lt;br /&gt; &lt;input type="button" class="buttonStyle" value="Submit Request" /&gt; &lt;/form&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 6456, "author": "Polsonby", "author_id": 137, "author_profile": "https://Stackoverflow.com/users/137", "pm_score": 2, "selected": false, "text": "document.getElementById('whatever')" }, { "answer_id": 6868, "author": "Ricky", "author_id": 653, "author_p...
2008/08/08
[ "https://Stackoverflow.com/questions/6441", "https://Stackoverflow.com", "https://Stackoverflow.com/users/232/" ]
6,467
<p>I need to do date arithmetic in Unix shell scripts that I use to control the execution of third party programs. </p> <p>I'm using a function to increment a day and another to decrement: </p> <pre><code>IncrementaDia(){ echo $1 | awk ' BEGIN { diasDelMes[1] = 31 diasDelMes[2] = 28 diasDelMes[3] = 31 diasDelMes[4] = 30 diasDelMes[5] = 31 diasDelMes[6] = 30 diasDelMes[7] = 31 diasDelMes[8] = 31 diasDelMes[9] = 30 diasDelMes[10] = 31 diasDelMes[11] = 30 diasDelMes[12] = 31 } { anio=substr($1,1,4) mes=substr($1,5,2) dia=substr($1,7,2) if((anio % 4 == 0 &amp;&amp; anio % 100 != 0) || anio % 400 == 0) { diasDelMes[2] = 29; } if( dia == diasDelMes[int(mes)] ) { if( int(mes) == 12 ) { anio = anio + 1 mes = 1 dia = 1 } else { mes = mes + 1 dia = 1 } } else { dia = dia + 1 } } END { printf("%04d%02d%02d", anio, mes, dia) } ' } if [ $# -eq 1 ]; then tomorrow=$1 else today=$(date +"%Y%m%d") tomorrow=$(IncrementaDia $hoy) fi </code></pre> <p>but now I need to do more complex arithmetic. </p> <p>What it's the best and more compatible way to do this?</p>
[ { "answer_id": 6468, "author": "abyx", "author_id": 573, "author_profile": "https://Stackoverflow.com/users/573", "pm_score": 6, "selected": false, "text": "date --date='1 days ago' '+%a'\n" }, { "answer_id": 6471, "author": "ggasp", "author_id": 527, "author_profile"...
2008/08/08
[ "https://Stackoverflow.com/questions/6467", "https://Stackoverflow.com", "https://Stackoverflow.com/users/527/" ]
6,475
<p>In a machine with AIX without <code>PERL</code> I need to filter records that will be considered duplicated if they have the same id and if they were registered between a period of four hours. </p> <p>I implemented this filter using <code>AWK</code> and work pretty well but I need a solution much faster: </p> <pre> # Generar lista de Duplicados awk 'BEGIN { FS="," } /OK/ { old[$8] = f[$8]; f[$8] = mktime($4, $3, $2, $5, $6, $7); x[$8]++; } /OK/ && x[$8]>1 && f[$8]-old[$8] <p>Any suggestions? Are there ways to improve the environment (preloading the file or someting like that)? </p> <p>The input file is already sorted.</p> <p>With the corrections suggested by <a href="https://stackoverflow.com/questions/6475/faster-way-to-find-duplicates-conditioned-by-time#6869">jj33</a> I made a new version with better treatment of dates, still maintaining a low profile for incorporating more operations: </p> awk 'BEGIN { FS=","; SECSPERMINUTE=60; SECSPERHOUR=3600; SECSPERDAY=86400; split("0 31 59 90 120 151 181 212 243 273 304 334", DAYSTOMONTH, " "); split("0 366 731 1096 1461 1827 2192 2557 2922 3288 3653 4018 4383 4749 5114 5479 5844 6210 6575 6940 7305", DAYSTOYEAR, " "); } /OK/ { old[$8] = f[$8]; f[$8] = mktime($4, $3, $2, $5, $6, $7); x[$8]++; } /OK/ && x[$8]>1 && f[$8]-old[$8] 2 ) && ( ((y % 4 == 0) && (y % 100 != 0)) || (y % 400 == 0) ) ) { d2m = d2m + 1; } d2y = DAYSTOYEAR[ y - 1999 ]; return ss + (mm*SECSPERMINUTE) + (hh*SECSPEROUR) + (d*SECSPERDAY) + (d2m*SECSPERDAY) + (d2y*SECSPERDAY); } ' </pre>
[ { "answer_id": 7210, "author": "AnotherHowie", "author_id": 923, "author_profile": "https://Stackoverflow.com/users/923", "pm_score": 1, "selected": false, "text": "sort -k 8 < input.txt > output.txt\n" }, { "answer_id": 7756, "author": "jj33", "author_id": 430, "auth...
2008/08/08
[ "https://Stackoverflow.com/questions/6475", "https://Stackoverflow.com", "https://Stackoverflow.com/users/527/" ]
6,484
<p><a href="http://www.google.com/search?q=how%20to%20mock%20sealed%20class" rel="noreferrer">Mocking sealed classes</a> can be quite a pain. I currently favor an <a href="http://en.wikipedia.org/wiki/Adapter_pattern" rel="noreferrer">Adapter pattern</a> to handle this, but something about just keeps feels weird. </p> <p><strong>So, What is the best way you mock sealed classes?</strong></p> <p><em>Java answers are more than welcome</em>. In fact, I would anticipate that the Java community has been dealing with this longer and has a great deal to offer.</p> <p>But here are some of the .NET opinions:</p> <ul> <li><a href="http://haacked.com/archive/2007/08/19/why-duck-typing-matters-to-c-developers.aspx" rel="noreferrer">Why Duck Typing Matters for C# Develoepers</a> </li> <li><a href="http://cs.rthand.com/blogs/blog_with_righthand/archive/2008/07/22/Creating-wrappers-for-sealed-and-other-types-for-mocking.aspx" rel="noreferrer">Creating wrappers for sealed and other types for mocking</a></li> <li><a href="http://weblogs.asp.net/cibrax/archive/2008/05/16/unit-tests-for-wcf.aspx" rel="noreferrer">Unit tests for WCF (and Moq)</a></li> </ul>
[ { "answer_id": 2587888, "author": "Adam Lenda", "author_id": 104846, "author_profile": "https://Stackoverflow.com/users/104846", "pm_score": 1, "selected": false, "text": " [TestMethod]\n public void Test()\n {\n Queue<Message> messages = new Queue<Message>();\n Ac...
2008/08/09
[ "https://Stackoverflow.com/questions/6484", "https://Stackoverflow.com", "https://Stackoverflow.com/users/307/" ]
6,499
<p>There are a few ways to get class-like behavior in javascript, the most common seem to be prototype based like this:</p> <pre><code>function Vector(x, y, x) { this.x = x; this.y = y; this.z = z; return this; } Vector.prototype.length = function () { return Math.sqrt(this.x * this.x ... ); } </code></pre> <p>and closure based approaches similar to</p> <pre><code>function Vector(x, y, z) { this.length = function() { return Math.sqrt(x * x + ...); } } </code></pre> <p>For various reasons the latter is faster, but I've seen (and I frequently do write) the prototype version and was curious as to what other people do.</p>
[ { "answer_id": 6516, "author": "Patrick", "author_id": 429, "author_profile": "https://Stackoverflow.com/users/429", "pm_score": 2, "selected": false, "text": "function Vector(x, y, z) {\n function length() {\n return Math.sqrt(x * x + ...);\n }\n}\n" }, { "answer_id": 6533,...
2008/08/09
[ "https://Stackoverflow.com/questions/6499", "https://Stackoverflow.com", "https://Stackoverflow.com/users/784/" ]
6,512
<p>I'm working on a Scheme interpreter written in C. Currently it uses the C runtime stack as its own stack, which is presenting a minor problem with implementing continuations. My current solution is manual copying of the C stack to the heap then copying it back when needed. Aside from not being standard C, this solution is hardly ideal.</p> <p>What is the simplest way to implement continuations for Scheme in C?</p>
[ { "answer_id": 31951, "author": "Thomas Vander Stichele", "author_id": 2900, "author_profile": "https://Stackoverflow.com/users/2900", "pm_score": 3, "selected": false, "text": "setjmp" }, { "answer_id": 46927339, "author": "alinsoar", "author_id": 1419272, "author_pr...
2008/08/09
[ "https://Stackoverflow.com/questions/6512", "https://Stackoverflow.com", "https://Stackoverflow.com/users/658/" ]
6,547
<p>One of those classic programming interview questions...</p> <p>You are given two marbles, and told that they will break when dropped from some certain height (and presumably suffer no damage if dropped from below that height). You’re then taken to a 100 story building (presumably higher than the certain height), and asked to find the highest floor your can drop a marble from without breaking it as efficiently as possible.</p> <p>Extra info</p> <ul> <li>You must find the correct floor (not a possible range)</li> <li>The marbles are both guaranteed to break at the same floor</li> <li>Assume it takes zero time for you to change floors - only the number of marble drops counts</li> <li>Assume the correct floor is randomly distributed in the building</li> </ul>
[ { "answer_id": 21133595, "author": "herohuyongtao", "author_id": 2589776, "author_profile": "https://Stackoverflow.com/users/2589776", "pm_score": 4, "selected": false, "text": "N" } ]
2008/08/09
[ "https://Stackoverflow.com/questions/6547", "https://Stackoverflow.com", "https://Stackoverflow.com/users/797/" ]
6,557
<p>It seems that a List object cannot be stored in a List variable in C#, and can't even be explicitly cast that way.</p> <pre><code>List&lt;string&gt; sl = new List&lt;string&gt;(); List&lt;object&gt; ol; ol = sl; </code></pre> <p>results in Cannot implicitly convert type <code>System.Collections.Generic.List&lt;string&gt;</code> to <code>System.Collections.Generic.List&lt;object&gt;</code></p> <p>And then...</p> <pre><code>List&lt;string&gt; sl = new List&lt;string&gt;(); List&lt;object&gt; ol; ol = (List&lt;object&gt;)sl; </code></pre> <p>results in Cannot convert type <code>System.Collections.Generic.List&lt;string&gt;</code> to <code>System.Collections.Generic.List&lt;object&gt;</code></p> <p>Of course, you can do it by pulling everything out of the string list and putting it back in one at a time, but it is a rather convoluted solution.</p>
[ { "answer_id": 6559, "author": "Rex M", "author_id": 67, "author_profile": "https://Stackoverflow.com/users/67", "pm_score": 4, "selected": false, "text": "List<>" }, { "answer_id": 6567, "author": "Mike Stone", "author_id": 122, "author_profile": "https://Stackoverfl...
2008/08/09
[ "https://Stackoverflow.com/questions/6557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/797/" ]
6,578
<p>I'm just beginning to have a look at Objective-C and Cocoa with a view to playing with the iPhone SDK. I'm reasonably comfortable with C's <code>malloc</code> and <code>free</code> concept, but Cocoa's references counting scheme has me rather confused. I'm told it's very elegant once you understand it, but I'm just not over the hump yet.</p> <p>How do <code>release</code>, <code>retain</code> and <code>autorelease</code> work and what are the conventions about their use?</p> <p>(Or failing that, what did you read which helped you get it?)</p>
[ { "answer_id": 6592, "author": "Ecton", "author_id": 457, "author_profile": "https://Stackoverflow.com/users/457", "pm_score": 3, "selected": false, "text": "id myVar = [someObject someMessage];\n.... do something ....;\n[myVar release];\nreturn someValue;\n" }, { "answer_id": 66...
2008/08/09
[ "https://Stackoverflow.com/questions/6578", "https://Stackoverflow.com", "https://Stackoverflow.com/users/797/" ]
6,594
<p>What are some good steps to follow for a smooth migration from PHP4 to PHP5. What are some types of code that are likely to break?</p>
[ { "answer_id": 6625, "author": "Akira", "author_id": 795, "author_profile": "https://Stackoverflow.com/users/795", "pm_score": 2, "selected": false, "text": "error_reporting( E_ALL );\n" } ]
2008/08/09
[ "https://Stackoverflow.com/questions/6594", "https://Stackoverflow.com", "https://Stackoverflow.com/users/796/" ]
6,607
<p>I'm a new Windows programmer and I'm not sure where I should store user configurable application settings. I understand the need to provide a user friendly means for the user to change application settings, like an Edit | Settings form or similar. But where should I store the values after the user hits the Apply button on that form? </p> <p>What are the pros and cons of storing settings in the Windows registry vs. storing them in a local INI file or config file or similar?</p>
[ { "answer_id": 6622, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 2, "selected": false, "text": "GetPrivateProfileString" }, { "answer_id": 6757, "author": "deadtime", "author_id": 614, "author_profile":...
2008/08/09
[ "https://Stackoverflow.com/questions/6607", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27687/" ]
6,612
<p>On a recent Java project, we needed a free Java based real-time data plotting utility. After much searching, we found this tool called the <a href="http://www.epic.noaa.gov/java/sgt/" rel="noreferrer">Scientific Graphics Toolkit or SGT</a> from NOAA. It seemed pretty robust, but we found out that it wasn't terribly configurable. Or at least not configurable enough to meet our needs. We ended up digging very deeply into the Java code and reverse engineering the code and changing it all around to make the plot tool look and act the way we wanted it to look and act. Of course, this killed any chance for future upgrades from NOAA. </p> <p>So what free or cheap Java based data plotting tools or libraries do you use?</p> <p><em>Followup: Thanks for the <a href="http://www.jfree.org/jfreechart/" rel="noreferrer">JFreeChart</a> suggestions. I checked out their website and it looks like a very nice data charting and plotting utility. I should have made it clear in my original question that I was looking specifically to plot real-time data. I corrected my question above to make that point clear. It appears that <a href="http://www.jfree.org/jfreechart/faq.html#FAQ5" rel="noreferrer">JFreeChart support for live data is marginal at best, though</a>. Any other suggestions out there?</em></p>
[ { "answer_id": 11265300, "author": "Bob Weigel", "author_id": 1491619, "author_profile": "https://Stackoverflow.com/users/1491619", "pm_score": 1, "selected": false, "text": "&filePollUpdates=1&tail=100" } ]
2008/08/09
[ "https://Stackoverflow.com/questions/6612", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27687/" ]
6,623
<p>After changing the output directory of a visual studio project it started to fail to build with an error very much like: </p> <pre><code>C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\bin\sgen.exe /assembly:C:\p4root\Zantaz\trunk\EASDiscovery\EASDiscoveryCaseManagement\obj\Release\EASDiscoveryCaseManagement.dll /proxytypes /reference:C:\p4root\Zantaz\trunk\EASDiscovery\EasDiscovery.Common\target\win_x32\release\results\EASDiscovery.Common.dll /reference:C:\p4root\Zantaz\trunk\EASDiscovery\EasDiscovery.Export\target\win_x32\release\results\EASDiscovery.Export.dll /reference:c:\p4root\Zantaz\trunk\EASDiscovery\ItemCache\target\win_x32\release\results\EasDiscovery.ItemCache.dll /reference:c:\p4root\Zantaz\trunk\EASDiscovery\RetrievalEngine\target\win_x32\release\results\EasDiscovery.RetrievalEngine.dll /reference:C:\p4root\Zantaz\trunk\EASDiscovery\EASDiscoveryJobs\target\win_x32\release\results\EASDiscoveryJobs.dll /reference:"C:\Program Files\Infragistics\NetAdvantage for .NET 2008 Vol. 1 CLR 2.0\Windows Forms\Bin\Infragistics2.Shared.v8.1.dll" /reference:"C:\Program Files\Infragistics\NetAdvantage for .NET 2008 Vol. 1 CLR 2.0\Windows Forms\Bin\Infragistics2.Win.Misc.v8.1.dll" /reference:"C:\Program Files\Infragistics\NetAdvantage for .NET 2008 Vol. 1 CLR 2.0\Windows Forms\Bin\Infragistics2.Win.UltraWinChart.v8.1.dll" /reference:"C:\Program Files\Infragistics\NetAdvantage for .NET 2008 Vol. 1 CLR 2.0\Windows Forms\Bin\Infragistics2.Win.UltraWinDataSource.v8.1.dll" /reference:"C:\Program Files\Infragistics\NetAdvantage for .NET 2008 Vol. 1 CLR 2.0\Windows Forms\Bin\Infragistics2.Win.UltraWinDock.v8.1.dll" /reference:"C:\Program Files\Infragistics\NetAdvantage for .NET 2008 Vol. 1 CLR 2.0\Windows Forms\Bin\Infragistics2.Win.UltraWinEditors.v8.1.dll" /reference:"C:\Program Files\Infragistics\NetAdvantage for .NET 2008 Vol. 1 CLR 2.0\Windows Forms\Bin\Infragistics2.Win.UltraWinGrid.v8.1.dll" /reference:"C:\Program Files\Infragistics\NetAdvantage for .NET 2008 Vol. 1 CLR 2.0\Windows Forms\Bin\Infragistics2.Win.UltraWinListView.v8.1.dll" /reference:"C:\Program Files\Infragistics\NetAdvantage for .NET 2008 Vol. 1 CLR 2.0\Windows Forms\Bin\Infragistics2.Win.UltraWinMaskedEdit.v8.1.dll" /reference:"C:\Program Files\Infragistics\NetAdvantage for .NET 2008 Vol. 1 CLR 2.0\Windows Forms\Bin\Infragistics2.Win.UltraWinStatusBar.v8.1.dll" /reference:"C:\Program Files\Infragistics\NetAdvantage for .NET 2008 Vol. 1 CLR 2.0\Windows Forms\Bin\Infragistics2.Win.UltraWinTabControl.v8.1.dll" /reference:"C:\Program Files\Infragistics\NetAdvantage for .NET 2008 Vol. 1 CLR 2.0\Windows Forms\Bin\Infragistics2.Win.UltraWinToolbars.v8.1.dll" /reference:"C:\Program Files\Infragistics\NetAdvantage for .NET 2008 Vol. 1 CLR 2.0\Windows Forms\Bin\Infragistics2.Win.UltraWinTree.v8.1.dll" /reference:"C:\Program Files\Infragistics\NetAdvantage for .NET 2008 Vol. 1 CLR 2.0\Windows Forms\Bin\Infragistics2.Win.v8.1.dll" /reference:"C:\Program Files\Microsoft Visual Studio 8\ReportViewer\Microsoft.ReportViewer.Common.dll" /reference:"C:\Program Files\Microsoft Visual Studio 8\ReportViewer\Microsoft.ReportViewer.WinForms.dll" /reference:C:\p4root\Zantaz\trunk\EASDiscovery\PreviewControl\target\win_x32\release\results\PreviewControl.dll /reference:C:\p4root\Zantaz\trunk\EASDiscovery\Quartz\src\Quartz\target\win_x32\release\results\Scheduler.dll /reference:c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.configuration.dll /reference:c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.dll /reference:c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Design.dll /reference:c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.DirectoryServices.dll /reference:c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll /reference:c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Drawing.dll /reference:c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Web.dll /reference:c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Web.Services.dll /reference:c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Windows.Forms.dll /reference:c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll /compiler:/delaysign- Error: The specified module could not be found. (Exception from HRESULT: 0x8007007E) C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Microsoft.Common.targets(1902,9): error MSB6006: "sgen.exe" exited with code 1. </code></pre> <p>I changed the output directory to target/win_x32/release/results but the path in sgen doesn't seem to have been updated. There seems to be no reference in the project to what path is passed into sgen so I'm unsure how to fix it. As a workaround I have disabled the serialization generation but it would be nice to fix the underlying problem. Has anybody else seen this?</p>
[ { "answer_id": 27317, "author": "sphereinabox", "author_id": 2775, "author_profile": "https://Stackoverflow.com/users/2775", "pm_score": 4, "selected": true, "text": "<Target Name=\"GenerateSerializationAssembliesForAllTypes\"\n DependsOnTargets=\"AssignTargetPaths;Compile;ResolveKeySou...
2008/08/09
[ "https://Stackoverflow.com/questions/6623", "https://Stackoverflow.com", "https://Stackoverflow.com/users/361/" ]
6,628
<p>What is the difference, if any, between these methods of indexing into a PHP array:</p> <pre><code>$array[$index] $array[&quot;$index&quot;] $array[&quot;{$index}&quot;] </code></pre> <p>I'm interested in both the performance and functional differences.</p> <h3>Update:</h3> <p>(In response to @Jeremy) I'm not sure that's right. I ran this code:</p> <pre><code> $array = array(100, 200, 300); print_r($array); $idx = 0; $array[$idx] = 123; print_r($array); $array[&quot;$idx&quot;] = 456; print_r($array); $array[&quot;{$idx}&quot;] = 789; print_r($array); </code></pre> <p>And got this output:</p> <pre><code>Array ( [0] =&gt; 100 [1] =&gt; 200 [2] =&gt; 300 ) Array ( [0] =&gt; 123 [1] =&gt; 200 [2] =&gt; 300 ) Array ( [0] =&gt; 456 [1] =&gt; 200 [2] =&gt; 300 ) Array ( [0] =&gt; 789 [1] =&gt; 200 [2] =&gt; 300 ) </code></pre>
[ { "answer_id": 6637, "author": "ejunker", "author_id": 796, "author_profile": "https://Stackoverflow.com/users/796", "pm_score": -1, "selected": false, "text": "$str = \"this is my string {$array[\"$index\"]}\";\n" }, { "answer_id": 6646, "author": "Paige Ruten", "author_...
2008/08/09
[ "https://Stackoverflow.com/questions/6628", "https://Stackoverflow.com", "https://Stackoverflow.com/users/103/" ]
6,633
<p>I have inherited some legacy PHP code what was written back when it was standard practice to use <a href="http://php.net/register_globals" rel="nofollow noreferrer"><code>register_globals</code></a> (As of PHP 4.2.0, this directive defaults to off, released 22. Apr 2002).</p> <p>We know now that it is bad for security to have it enabled. The problem is how do I find all the places in the code where I need to use <code>$_GET</code> or <code>$_POST</code>? My only thought was to set the error reporting to warn about uninitialized variables and then test each part of the site. Is there an easier way? Will I have to test each code path in the site or will PHP give a warning on a file basis?</p>
[ { "answer_id": 13758, "author": "Eric Goodwin", "author_id": 1430, "author_profile": "https://Stackoverflow.com/users/1430", "pm_score": 2, "selected": false, "text": "// Detect bad global variables\n$bad_global_list = array('GLOBALS', '_SESSION', 'HTTP_SESSION_VARS', '_GET', 'HTTP_GET_...
2008/08/09
[ "https://Stackoverflow.com/questions/6633", "https://Stackoverflow.com", "https://Stackoverflow.com/users/796/" ]
6,639
<p>How should I load files into my Java application?</p>
[ { "answer_id": 6640, "author": "Will", "author_id": 816, "author_profile": "https://Stackoverflow.com/users/816", "pm_score": 6, "selected": false, "text": "Class.getResource(String)" }, { "answer_id": 30854, "author": "Vinnie", "author_id": 2890, "author_profile": "h...
2008/08/09
[ "https://Stackoverflow.com/questions/6639", "https://Stackoverflow.com", "https://Stackoverflow.com/users/816/" ]
6,642
<p>I was trying to add a favicon to a website earlier and looked for a better way to implement this than to dump a <code>favicon.ico</code> file in the root of the website.</p> <p>I found this nice little guide: <a href="http://www.w3.org/2005/10/howto-favicon" rel="noreferrer">How to Add a Favicon</a>. However, the preferred method did not work in IE (7) and the second method is the old fashioned way (which I resigned myself to use).</p> <p>Is there a third method that works across all the most popular browsers?</p>
[ { "answer_id": 6643, "author": "Brandon Wood", "author_id": 423, "author_profile": "https://Stackoverflow.com/users/423", "pm_score": 0, "selected": false, "text": "<link rel=\"shortcut icon\" href=\"/favicon.ico\" />\n" }, { "answer_id": 6644, "author": "mbillard", "auth...
2008/08/09
[ "https://Stackoverflow.com/questions/6642", "https://Stackoverflow.com", "https://Stackoverflow.com/users/810/" ]
6,658
<p>At work we are currently still using JUnit 3 to run our tests. We have been considering switching over to JUnit 4 for <strong>new</strong> tests being written but I have been keeping an eye on TestNG for a while now. What experiences have you all had with either JUnit 4 or TestNG, and which seems to work better for very large numbers of tests? Having flexibility in writing tests is also important to us since our functional tests cover a wide aspect and need to be written in a variety of ways to get results.</p> <p>Old tests will not be re-written as they do their job just fine. What I would like to see in new tests though is flexibility in the way the test can be written, natural assertions, grouping, and easily distributed test executions.</p>
[ { "answer_id": 430893, "author": "Denis Bazhenov", "author_id": 53658, "author_profile": "https://Stackoverflow.com/users/53658", "pm_score": 3, "selected": false, "text": "assertEquals(operation.getStatus(), Operation.Status.Active);\n" }, { "answer_id": 3522444, "author": "...
2008/08/09
[ "https://Stackoverflow.com/questions/6658", "https://Stackoverflow.com", "https://Stackoverflow.com/users/782/" ]
6,661
<p>I'm aware of things like <code>onchange</code>, <code>onmousedown</code> and <code>onmouseup</code> but is there a good reference somewhere that lists all of them complete with possibly a list of the elements that they cover?</p>
[ { "answer_id": 6686, "author": "GateKiller", "author_id": 383, "author_profile": "https://Stackoverflow.com/users/383", "pm_score": 2, "selected": false, "text": "$(\"#navigation a\").addEvent(\"click\", myFunc);\n" } ]
2008/08/09
[ "https://Stackoverflow.com/questions/6661", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1384652/" ]
6,719
<p>I've just been learning about master pages in ASP.NET 2.0. </p> <p>They sound great, but how well do they work in practice? </p> <p>Does anybody have experience of using them for a large web site?</p>
[ { "answer_id": 6744, "author": "mbillard", "author_id": 810, "author_profile": "https://Stackoverflow.com/users/810", "pm_score": 3, "selected": false, "text": "<%@ Master ... %>\n\n<%-- HTML code --%>\n<asp:ContentPlaceHolder id=\"plhMainContent\" runat=\"server\" />\n<%-- HTML code --%...
2008/08/09
[ "https://Stackoverflow.com/questions/6719", "https://Stackoverflow.com", "https://Stackoverflow.com/users/133/" ]
6,765
<p>I'm going to start a new project - rewriting an existing system (PHP + SQL Server) from scratch because of some very serious limitations by design.</p> <p>We have some quite good knowledge of SQL Server (currently we're using SQL Server 2000 in existing system) and we would like to employ its newer version (2008 I guess) in our new project.</p> <p>I am really fond of technologies that Java offers - particularly Spring Framework and Wicket and I am quite familiar with Java from others projects and assignments before. Therefore, we consider using Java and Microsoft SQL Server.</p> <p>There are two JDBC drivers for SQL Server - jTDS and Microsoft's one - <a href="http://msdn.microsoft.com/en-us/data/aa937724.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/data/aa937724.aspx</a>. I think we should test both of them.<br/></p> <p>Are there any limitations in such solution I should know of? Has someone experience with such a technology combination?</p>
[ { "answer_id": 38664293, "author": "Jay", "author_id": 5641640, "author_profile": "https://Stackoverflow.com/users/5641640", "pm_score": 0, "selected": false, "text": "import java.sql.Connection;\nimport java.sql.DriverManager;\nimport java.sql.ResultSet;\nimport java.sql.SQLException;\n...
2008/08/09
[ "https://Stackoverflow.com/questions/6765", "https://Stackoverflow.com", "https://Stackoverflow.com/users/837/" ]
6,778
<p>This page from Adobe says to add a "wmode" parameter and set its value to "transparent": <a href="http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_14201" rel="nofollow noreferrer">http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_1420</a></p> <p>This works flawlessly in IE. The background renders correctly in Firefox and Safari, however as soon as you use the browser's scroll bar then mouse over the Flash control you must click once to activate the control. You can see this behavior if you try to hit the play button in Adobe's example.</p> <p>Anyone know a way around this?</p>
[ { "answer_id": 16830, "author": "Shawn Miller", "author_id": 247, "author_profile": "https://Stackoverflow.com/users/247", "pm_score": 0, "selected": false, "text": "var parameters:Object = LoaderInfo(this.root.loaderInfo).parameters;\nopaqueBackground = parameters[\"background-color\"];...
2008/08/09
[ "https://Stackoverflow.com/questions/6778", "https://Stackoverflow.com", "https://Stackoverflow.com/users/247/" ]
6,785
<p>Suppose I have a stringbuilder in C# that does this:</p> <pre><code>StringBuilder sb = new StringBuilder(); string cat = "cat"; sb.Append("the ").Append(cat).(" in the hat"); string s = sb.ToString(); </code></pre> <p>would that be as efficient or any more efficient as having:</p> <pre><code>string cat = "cat"; string s = String.Format("The {0} in the hat", cat); </code></pre> <p>If so, why?</p> <p><strong>EDIT</strong> </p> <p>After some interesting answers, I realised I probably should have been a little clearer in what I was asking. I wasn't so much asking for which was quicker at concatenating a string, but which is quicker at <strong><em>injecting</em></strong> one string into another.</p> <p>In both cases above I want to inject one or more strings into the middle of a predefined template string.</p> <p>Sorry for the confusion</p>
[ { "answer_id": 6786, "author": "GateKiller", "author_id": 383, "author_profile": "https://Stackoverflow.com/users/383", "pm_score": -1, "selected": false, "text": "String s = String.Format(\"Today is {0:dd-MMM-yyyy}.\", DateTime.Today);\n" }, { "answer_id": 6788, "author": "J...
2008/08/09
[ "https://Stackoverflow.com/questions/6785", "https://Stackoverflow.com", "https://Stackoverflow.com/users/493/" ]
6,811
<p>Before reading anything else, please take time to read the <a href="https://stackoverflow.com/questions/1615/how-can-i-modify-xfdl-files-update-1">original thread</a>.</p> <p>Overview: a .xfdl file is a gzipped .xml file which has then been encoded in base64. I wish to de-encode the .xfdl into xml which I can then modify and then re-encode back into a .xfdl file.</p> <blockquote> <p>xfdl > xml.gz > xml > xml.gz > xfdl</p> </blockquote> <p>I have been able to take a .xfdl file and de-encode it from base64 using uudeview:</p> <pre><code>uudeview -i yourform.xfdl </code></pre> <p>Then decommpressed it using gunzip</p> <pre><code>gunzip -S "" &lt; UNKNOWN.001 &gt; yourform-unpacked.xml </code></pre> <p>The xml produced is 100% readable and looks wonderful. Without modifying the xml then, i should be able to re-compress it using gzip:</p> <pre><code>gzip yourform-unpacked.xml </code></pre> <p>Then re-encoded in base-64:</p> <pre><code>base64 -e yourform-unpacked.xml.gz yourform_reencoded.xfdl </code></pre> <p>If my thinking is correct, the original file and the re-encoded file should be equal. If I put yourform.xfdl and yourform_reencoded.xfdl into beyond compare, however, they do not match up. Also, the original file can be viewed in an http://www.grants.gov/help/download_software.jsp#pureedge">.xfdl viewer. The viewer says that the re-encoded xfdl is unreadable. </p> <p>I have also tried uuenview to re-encode in base64, it also produces the same results. Any help would be appreciated.</p>
[ { "answer_id": 6852, "author": "CodingWithoutComments", "author_id": 25, "author_profile": "https://Stackoverflow.com/users/25", "pm_score": 0, "selected": false, "text": "H4sIAAAAAAAAC+19eZOiyNb3/34K3r4RT/WEU40ssvTtrhuIuKK44Bo3YoJdFAFZ3D79C6hVVhUq\ndsnUVN/qmIkSOLlwlt/JPCfJ/PGf9dwAlorj6p...
2008/08/09
[ "https://Stackoverflow.com/questions/6811", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25/" ]
6,816
<p>I was hoping someone could help me out with a problem I'm having using the java search function in Eclipse on a particular project.</p> <p>When using the java search on one particular project, I get an error message saying <code>Class file name must end with .class</code> (see stack trace below). This does not seem to be happening on all projects, just one particular one, so perhaps there's something I should try to get rebuilt?</p> <p>I have already tried <code>Project -&gt; Clean</code>... and Closing Eclipse, deleting all the built class files and restarting Eclipse to no avail.</p> <p>The only reference I've been able to find on Google for the problem is at <a href="http://www.crazysquirrel.com/computing/java/eclipse/error-during-java-search.jspx" rel="noreferrer">http://www.crazysquirrel.com/computing/java/eclipse/error-during-java-search.jspx</a>, but unfortunately his solution (closing, deleting class files, restarting) did not work for me.</p> <p>If anyone can suggest something to try, or there's any more info I can gather which might help track it's down, I'd greatly appreciate the pointers.</p> <pre><code>Version: 3.4.0 Build id: I20080617-2000 </code></pre> <p>Also just found this thread - <a href="http://www.myeclipseide.com/PNphpBB2-viewtopic-t-20067.html" rel="noreferrer">http://www.myeclipseide.com/PNphpBB2-viewtopic-t-20067.html</a> - which indicates the same problem may occur when the project name contains a period. Unfortunately, that's not the case in my setup, so I'm still stuck.</p> <pre><code>Caused by: java.lang.IllegalArgumentException: Class file name must end with .class at org.eclipse.jdt.internal.core.PackageFragment.getClassFile(PackageFragment.java:182) at org.eclipse.jdt.internal.core.util.HandleFactory.createOpenable(HandleFactory.java:109) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:1177) at org.eclipse.jdt.internal.core.search.JavaSearchParticipant.locateMatches(JavaSearchParticipant.java:94) at org.eclipse.jdt.internal.core.search.BasicSearchEngine.findMatches(BasicSearchEngine.java:223) at org.eclipse.jdt.internal.core.search.BasicSearchEngine.search(BasicSearchEngine.java:506) at org.eclipse.jdt.core.search.SearchEngine.search(SearchEngine.java:551) at org.eclipse.jdt.internal.corext.refactoring.RefactoringSearchEngine.internalSearch(RefactoringSearchEngine.java:142) at org.eclipse.jdt.internal.corext.refactoring.RefactoringSearchEngine.search(RefactoringSearchEngine.java:129) at org.eclipse.jdt.internal.corext.refactoring.rename.RenameTypeProcessor.initializeReferences(RenameTypeProcessor.java:594) at org.eclipse.jdt.internal.corext.refactoring.rename.RenameTypeProcessor.doCheckFinalConditions(RenameTypeProcessor.java:522) at org.eclipse.jdt.internal.corext.refactoring.rename.JavaRenameProcessor.checkFinalConditions(JavaRenameProcessor.java:45) at org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring.checkFinalConditions(ProcessorBasedRefactoring.java:225) at org.eclipse.ltk.core.refactoring.Refactoring.checkAllConditions(Refactoring.java:160) at org.eclipse.jdt.internal.ui.refactoring.RefactoringExecutionHelper$Operation.run(RefactoringExecutionHelper.java:77) at org.eclipse.jdt.internal.core.BatchOperation.executeOperation(BatchOperation.java:39) at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:709) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1800) at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:4650) at org.eclipse.jdt.internal.ui.actions.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:92) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121) </code></pre> <p>Thanks McDowell, closing and opening the project seems to have fixed it (at least for now).</p>
[ { "answer_id": 1220707, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": false, "text": "<workspace>/.metadata/.plugins/org.eclipse.jdt.core/*.index" } ]
2008/08/09
[ "https://Stackoverflow.com/questions/6816", "https://Stackoverflow.com", "https://Stackoverflow.com/users/797/" ]
6,847
<p>When writing code do you consciously program defensively to ensure high program quality and to avoid the possibility of your code being exploited maliciously, e.g. through buffer overflow exploits or code injection ?</p> <p>What's the "minimum" level of quality you'll always apply to your code ?</p>
[ { "answer_id": 10150, "author": "Andrew Grant", "author_id": 1043, "author_profile": "https://Stackoverflow.com/users/1043", "pm_score": 1, "selected": false, "text": "inline const Vector3 Normalize( Vector3arg vec )\n{\n const float len = Length(vec);\n ASSERTMSG(len > 0.0f \"Inva...
2008/08/09
[ "https://Stackoverflow.com/questions/6847", "https://Stackoverflow.com", "https://Stackoverflow.com/users/381/" ]
6,890
<p>I have some code for starting a thread on the .NET CF 2.0:</p> <pre><code>ThreadStart tStart = new ThreadStart(MyMethod); Thread t = new Thread(tStart); t.Start(); </code></pre> <p>If I call this inside a loop the items completely out of order. How do introduce a wait after <code>t.Start()</code>, so that the work on the thread completes before the code continues? Will BeginInvoke/EndInvoke be a better option for this than manually creating threads?</p>
[ { "answer_id": 6935, "author": "Kev", "author_id": 419, "author_profile": "https://Stackoverflow.com/users/419", "pm_score": 2, "selected": false, "text": "t.Join();\n" }, { "answer_id": 7101, "author": "Dominic Cooney", "author_id": 878, "author_profile": "https://St...
2008/08/09
[ "https://Stackoverflow.com/questions/6890", "https://Stackoverflow.com", "https://Stackoverflow.com/users/636/" ]
6,891
<p>I have come across the following type of code many a times, and I wonder if this is a good practice (from Performance perspective) or not:</p> <pre><code>try { ... // some code } catch (Exception ex) { ... // Do something throw new CustomException(ex); } </code></pre> <p>Basically, what the coder is doing is that they are encompassing the exception in a custom exception and throwing that again.</p> <p>How does this differ in Performance from the following two:</p> <pre><code>try { ... // some code } catch (Exception ex) { .. // Do something throw ex; } </code></pre> <p>or </p> <pre><code>try { ... // some code } catch (Exception ex) { .. // Do something throw; } </code></pre> <p>Putting aside any functional or coding best practice arguments, is there any performance difference between the 3 approaches?</p>
[ { "answer_id": 6912, "author": "ggasp", "author_id": 527, "author_profile": "https://Stackoverflow.com/users/527", "pm_score": 2, "selected": false, "text": "try {\n // something that will raise an exception almost half the time\n} catch( InsufficientFunds e) {\n // Inform ...
2008/08/09
[ "https://Stackoverflow.com/questions/6891", "https://Stackoverflow.com", "https://Stackoverflow.com/users/380/" ]
6,899
<p>To illustrate, assume that I have two tables as follows:</p> <pre><code>VehicleID Name 1 Chuck 2 Larry LocationID VehicleID City 1 1 New York 2 1 Seattle 3 1 Vancouver 4 2 Los Angeles 5 2 Houston </code></pre> <p>I want to write a query to return the following results:</p> <pre><code>VehicleID Name Locations 1 Chuck New York, Seattle, Vancouver 2 Larry Los Angeles, Houston </code></pre> <p>I know that this can be done using server side cursors, ie:</p> <pre><code>DECLARE @VehicleID int DECLARE @VehicleName varchar(100) DECLARE @LocationCity varchar(100) DECLARE @Locations varchar(4000) DECLARE @Results TABLE ( VehicleID int Name varchar(100) Locations varchar(4000) ) DECLARE VehiclesCursor CURSOR FOR SELECT [VehicleID] , [Name] FROM [Vehicles] OPEN VehiclesCursor FETCH NEXT FROM VehiclesCursor INTO @VehicleID , @VehicleName WHILE @@FETCH_STATUS = 0 BEGIN SET @Locations = '' DECLARE LocationsCursor CURSOR FOR SELECT [City] FROM [Locations] WHERE [VehicleID] = @VehicleID OPEN LocationsCursor FETCH NEXT FROM LocationsCursor INTO @LocationCity WHILE @@FETCH_STATUS = 0 BEGIN SET @Locations = @Locations + @LocationCity FETCH NEXT FROM LocationsCursor INTO @LocationCity END CLOSE LocationsCursor DEALLOCATE LocationsCursor INSERT INTO @Results (VehicleID, Name, Locations) SELECT @VehicleID, @Name, @Locations END CLOSE VehiclesCursor DEALLOCATE VehiclesCursor SELECT * FROM @Results </code></pre> <p>However, as you can see, this requires a great deal of code. What I would like is a generic function that would allow me to do something like this:</p> <pre><code>SELECT VehicleID , Name , JOIN(SELECT City FROM Locations WHERE VehicleID = Vehicles.VehicleID, ', ') AS Locations FROM Vehicles </code></pre> <p>Is this possible? Or something similar?</p>
[ { "answer_id": 6961, "author": "Matt Hamilton", "author_id": 615, "author_profile": "https://Stackoverflow.com/users/615", "pm_score": 6, "selected": false, "text": "declare @s varchar(max)\nset @s = ''\nselect @s = @s + City + ',' from Locations\n\nselect @s\n" }, { "answer_id":...
2008/08/09
[ "https://Stackoverflow.com/questions/6899", "https://Stackoverflow.com", "https://Stackoverflow.com/users/799/" ]
6,904
<p>I'm trying to use the CoreCon API in Visual Studio 2008 to programmatically launch device emulators. When I call <code>device.Connect()</code>, I inexplicably get a DirectoryNotFoundException. I get it if I try it in PowerShell or in C# Console Application. Here's the code I'm using:</p> <pre><code>static void Main(string[] args) { DatastoreManager dm = new DatastoreManager(1033); Collection&lt;Platform&gt; platforms = dm.GetPlatforms(); foreach (var p in platforms) { Console.WriteLine("{0} {1}", p.Name, p.Id); } Platform platform = platforms[3]; Console.WriteLine("Selected {0}", platform.Name); Device device = platform.GetDevices()[0]; device.Connect(); Console.WriteLine("Device Connected"); SystemInfo info = device.GetSystemInfo(); Console.WriteLine("System OS Version:{0}.{1}.{2}",info.OSMajor, info.OSMinor, info.OSBuildNo); Console.ReadLine(); } </code></pre> <p>Does anyone know why I'm getting this error? I'm running this on WinXP 32-bit, plain jane Visual Studio 2008 Pro. I imagine it's some config issue since I can't do it from a Console app or PowerShell.</p> <p>Here's the stack trace:</p> <pre><code>System.IO.DirectoryNotFoundException was unhandled Message="The system cannot find the path specified.\r\n" Source="Device Connection Manager" StackTrace: at Microsoft.VisualStudio.DeviceConnectivity.Interop.ConManServerClass.ConnectDevice() at Microsoft.SmartDevice.Connectivity.Device.Connect() at ConsoleApplication1.Program.Main(String[] args) in C:\Documents and Settings\Thomas\Local Settings\Application Data\Temporary Projects\ConsoleApplication1\Program.cs:line 23 at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() </code></pre>
[ { "answer_id": 2401184, "author": "PrateekSaluja", "author_id": 307989, "author_profile": "https://Stackoverflow.com/users/307989", "pm_score": 2, "selected": true, "text": "<systemdrive>:\\Program files\\Common Files\\Microsoft Shared\\CoreCon\\1.0\\Bin" } ]
2008/08/09
[ "https://Stackoverflow.com/questions/6904", "https://Stackoverflow.com", "https://Stackoverflow.com/users/631/" ]
6,915
<p>Is there a way to implement a singleton object in C++ that is:</p> <ol> <li>Lazily constructed in a thread safe manner (two threads might simultaneously be the first user of the singleton - it should still only be constructed once).</li> <li>Doesn't rely on static variables being constructed beforehand (so the singleton object is itself safe to use during the construction of static variables).</li> </ol> <p>(I don't know my C++ well enough, but is it the case that integral and constant static variables are initialized before any code is executed (ie, even before static constructors are executed - their values may already be "initialized" in the program image)? If so - perhaps this can be exploited to implement a singleton mutex - which can in turn be used to guard the creation of the real singleton..)</p> <hr> <p>Excellent, it seems that I have a couple of good answers now (shame I can't mark 2 or 3 as being <strong>the answer</strong>). There appears to be two broad solutions:</p> <ol> <li>Use static initialisation (as opposed to dynamic initialisation) of a POD static variable, and implementing my own mutex with that using the builtin atomic instructions. This was the type of solution I was hinting at in my question, and I believe I knew already.</li> <li>Use some other library function like <a href="http://opengroup.org/onlinepubs/007908799/xsh/pthread_once.html" rel="noreferrer">pthread_once</a> or <a href="http://www.boost.org/doc/libs/1_33_1/doc/html/call_once.html" rel="noreferrer">boost::call_once</a>. These I certainly didn't know about - and am very grateful for the answers posted.</li> </ol>
[ { "answer_id": 6943, "author": "Chris Hanson", "author_id": 714, "author_profile": "https://Stackoverflow.com/users/714", "pm_score": 4, "selected": false, "text": "pObj == NULL" }, { "answer_id": 7036, "author": "C. K. Young", "author_id": 13, "author_profile": "http...
2008/08/09
[ "https://Stackoverflow.com/questions/6915", "https://Stackoverflow.com", "https://Stackoverflow.com/users/755/" ]
6,932
<p>What is the best way to transcode audio and video to show on the web? </p> <p>I need to do it programmatically. I'd like to do something like YouTube or Google Video where users can upload whatever format they want, and I encode it to flv, mp3, and/or mp4. I could do it on our server, but I would rather use an EC2 instance or even a web service. We have a Windows 2008 server.</p>
[ { "answer_id": 7186, "author": "masc", "author_id": 919, "author_profile": "https://Stackoverflow.com/users/919", "pm_score": 2, "selected": false, "text": "ffmpeg -hq -y -i $directory/$file -r 20 -s 300x200 -deinterlace -ar 22050 $directory/$file.flv 1>/dev/null 2>/dev/null\n" }, { ...
2008/08/09
[ "https://Stackoverflow.com/questions/6932", "https://Stackoverflow.com", "https://Stackoverflow.com/users/571/" ]
7,015
<p>I have a quad core machine and would like to write some code to parse a text file that takes advantage of all four cores. The text file basically contains one record per line.</p> <p>Multithreading isn't my forte so I'm wondering if anyone could give me some patterns that I might be able to use to parse the file in an optimal manner.</p> <p>My first thoughts are to read all the lines into some sort of queue and then spin up threads to pull the lines off the queue and process them, but that means the queue would have to exist in memory and these are fairly large files so I'm not so keen on that idea.</p> <p>My next thoughts are to have some sort of controller that will read in a line and assign it a thread to parse, but I'm not sure if the controller will end up being a bottleneck if the threads are processing the lines faster than it can read and assign them.</p> <p>I know there's probably another simpler solution than both of these but at the moment I'm just not seeing it.</p>
[ { "answer_id": 7023, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 1, "selected": false, "text": "Executors" }, { "answer_id": 7045, "author": "Mark Harrison", "author_id": 116, "author_profile": "https:/...
2008/08/10
[ "https://Stackoverflow.com/questions/7015", "https://Stackoverflow.com", "https://Stackoverflow.com/users/493/" ]
7,031
<p>I have been using PHP and JavaScript for building my dad's website. He wants to incorporate a login system into his website, and I have the design for the system using PHP. My problem is how do I show buttons if the person is logged in?­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­</p> <p><strong>For Example -</strong> You have <em>Home</em>, <em>Products</em>, <em>About Us</em>, and <em>Contact</em>. I want to have buttons for <em>Dealer</em>, <em>Distributor</em>, and maybe other information if the user is logged in. So I will have <em>Home</em>, <em>Products</em>, <em>About Us</em>, <em>Contacts</em>, Dealer (if dealer login), <em>Distributor</em> (if distributor login), and so forth. </p> <p>Would JavaScript be a good way to do this or would PHP, or maybe even both? Using JavaScript to show and hide buttons, and PHP to check to see which buttons to show. ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­</p>
[ { "answer_id": 7466, "author": "grom", "author_id": 486, "author_profile": "https://Stackoverflow.com/users/486", "pm_score": 1, "selected": false, "text": "<?php\nrequire_once 'Auth.php';\n// output some html\nif (isLoggedIn()) {\n echo 'html for logged in user';\n}\n// rest of html\...
2008/08/10
[ "https://Stackoverflow.com/questions/7031", "https://Stackoverflow.com", "https://Stackoverflow.com/users/876/" ]
7,034
<p>I have a data structure that represents a directed graph, and I want to render that dynamically on an HTML page. These graphs will usually be just a few nodes, maybe ten at the very upper end, so my guess is that performance isn't going to be a big deal. Ideally, I'd like to be able to hook it in with jQuery so that users can tweak the layout manually by dragging the nodes around.</p> <p>Note: I'm not looking for a charting library.</p>
[ { "answer_id": 2366237, "author": "Johann Philipp Strathausen", "author_id": 284708, "author_profile": "https://Stackoverflow.com/users/284708", "pm_score": 11, "selected": true, "text": "var g = new Graph();\ng.addEdge(\"strawberry\", \"cherry\");\ng.addEdge(\"cherry\", \"apple\");\ng.a...
2008/08/10
[ "https://Stackoverflow.com/questions/7034", "https://Stackoverflow.com", "https://Stackoverflow.com/users/404/" ]
7,035
<p>I'm writing a few little bash scripts under Ubuntu linux. I want to be able to run them from the GUI without needing a terminal window to enter any input or view any output.</p> <p>So far the only input required is a password for sudo - and gksudo handles that fine. But I haven't found an easy way to show a message box yet. Is there some kind of 'gkmessage' command available? I'd prefer something present in a default Ubuntu install, but I don't mind installing a new package if necessary.</p>
[ { "answer_id": 7043, "author": "Mark Harrison", "author_id": 116, "author_profile": "https://Stackoverflow.com/users/116", "pm_score": 3, "selected": false, "text": "#!/usr/bin/wish\npack [label .msg -text [lindex $argv 0]]\npack [entry .ent]\nbind .ent <KeyPress-Return> { puts [.ent get...
2008/08/10
[ "https://Stackoverflow.com/questions/7035", "https://Stackoverflow.com", "https://Stackoverflow.com/users/369/" ]
7,074
<p>What are the differences between these two and which one should I use?</p> <pre><code>string s = &quot;Hello world!&quot;; String s = &quot;Hello world!&quot;; </code></pre>
[ { "answer_id": 7077, "author": "Derek Park", "author_id": 872, "author_profile": "https://Stackoverflow.com/users/872", "pm_score": 14, "selected": true, "text": "string" }, { "answer_id": 7079, "author": "Ronnie", "author_id": 193, "author_profile": "https://Stackove...
2008/08/10
[ "https://Stackoverflow.com/questions/7074", "https://Stackoverflow.com", "https://Stackoverflow.com/users/571/" ]
7,084
<p>I've worked on a number of different embedded systems. They have all used <code>typedef</code>s (or <code>#defines</code>) for types such as <code>UINT32</code>.</p> <p>This is a good technique as it drives home the size of the type to the programmer and makes you more conscious of chances for overflow etc.</p> <p>But on some systems you know that the compiler and processor won't change for the life of the project.</p> <p>So what should influence your decision to create and enforce project-specific types?</p> <p>EDIT I think I managed to lose the gist of my question, and maybe it's really two.</p> <p>With embedded programming you may need types of specific size for interfaces and also to cope with restricted resources such as RAM. This can't be avoided, but you can choose to use the basic types from the compiler.</p> <p>For everything else the types have less importance.<br> You need to be careful not to cause overflow and may need to watch out for register and stack usage. Which may lead you to <code>UINT16</code>, <code>UCHAR</code>. Using types such as <code>UCHAR</code> can add compiler 'fluff' however. Because registers are typically larger, some compilers may add code to force the result into the type.<br> <PRE>i++;</PRE> can become <PRE>ADD REG,1 AND REG, 0xFF</PRE> which is unecessary.</p> <p>So I think my question should have been :-</p> <p>given the constraints of embedded software what is the best policy to set for a project which will have many people working on it - not all of whom will be of the same level of experience.</p>
[ { "answer_id": 7117, "author": "Chris Hanson", "author_id": 714, "author_profile": "https://Stackoverflow.com/users/714", "pm_score": 3, "selected": false, "text": "<stdint.h>" }, { "answer_id": 7515, "author": "Bernard", "author_id": 61, "author_profile": "https://St...
2008/08/10
[ "https://Stackoverflow.com/questions/7084", "https://Stackoverflow.com", "https://Stackoverflow.com/users/888/" ]
7,089
<p>How can I create rounded corners using CSS?</p>
[ { "answer_id": 7098, "author": "Yaakov Ellis", "author_id": 51, "author_profile": "https://Stackoverflow.com/users/51", "pm_score": 8, "selected": true, "text": "border-radius" }, { "answer_id": 7099, "author": "Jeff Atwood", "author_id": 1, "author_profile": "https:/...
2008/08/10
[ "https://Stackoverflow.com/questions/7089", "https://Stackoverflow.com", "https://Stackoverflow.com/users/889/" ]
7,095
<p>In other words, is this Singleton implementation thread safe:</p> <pre><code>public class Singleton { private static Singleton instance; private Singleton() { } static Singleton() { instance = new Singleton(); } public static Singleton Instance { get { return instance; } } } </code></pre>
[ { "answer_id": 7105, "author": "Zooba", "author_id": 891, "author_profile": "https://Stackoverflow.com/users/891", "pm_score": 9, "selected": true, "text": "public class Singleton\n{\n private static Singleton instance;\n // Added a static mutex for synchronising use of instance.\n...
2008/08/10
[ "https://Stackoverflow.com/questions/7095", "https://Stackoverflow.com", "https://Stackoverflow.com/users/373/" ]
7,118
<p>Currently, I don't really have a good method of debugging JavaScript in Internet&nbsp;Explorer and <a href="http://en.wikipedia.org/wiki/Safari_%28web_browser%29" rel="noreferrer">Safari</a>. In Firefox, you can use <a href="http://en.wikipedia.org/wiki/Firebug" rel="noreferrer">Firebug's</a> <a href="http://getfirebug.com/logging.html" rel="noreferrer">logging feature</a> and <a href="http://getfirebug.com/commandline.html" rel="noreferrer">command Line functions</a>. However, this doesn't help me when I move to other browsers.</p>
[ { "answer_id": 7129, "author": "Dominic Cooney", "author_id": 878, "author_profile": "https://Stackoverflow.com/users/878", "pm_score": 5, "selected": true, "text": "$ defaults write com.apple.Safari IncludeDebugMenu 1\n" } ]
2008/08/10
[ "https://Stackoverflow.com/questions/7118", "https://Stackoverflow.com", "https://Stackoverflow.com/users/889/" ]
7,209
<p>I'm trying to alpha blend sprites and backgrounds with <a href="http://www.devkitpro.org/" rel="noreferrer">devkitPro</a> (including libnds, libarm, etc).</p> <p>Does anyone know how to do this?</p>
[ { "answer_id": 10527, "author": "Cristián Romo", "author_id": 1256, "author_profile": "https://Stackoverflow.com/users/1256", "pm_score": 2, "selected": false, "text": "REG_BLDMOD" }, { "answer_id": 119880, "author": "PypeBros", "author_id": 15304, "author_profile": "...
2008/08/10
[ "https://Stackoverflow.com/questions/7209", "https://Stackoverflow.com", "https://Stackoverflow.com/users/209/" ]
7,211
<p>I currently have a relatively small (4 or 5 tables, 5000 rows) MySQL database that I would like to convert to an sqlite database. As I'd potentially have to do this more than once, I'd be grateful if anyone could recommend any useful tools, or at least any easily-replicated method.</p> <p>(I have complete admin access to the database/machines involved.)</p>
[ { "answer_id": 7218, "author": "Terry G Lorber", "author_id": 809, "author_profile": "https://Stackoverflow.com/users/809", "pm_score": 2, "selected": false, "text": " tgl@moto~$ mysqldump old-database > old-database-dump.sql\n tgl@moto~$ sqlite3 -init old-database-dump.sql new-database\...
2008/08/10
[ "https://Stackoverflow.com/questions/7211", "https://Stackoverflow.com", "https://Stackoverflow.com/users/916/" ]
7,212
<p>What I'd like to do is something like the following:</p> <pre><code>FooClass.prototype.method = function():String { return "Something"; } var foo:FooClass = new FooClass(); foo.method(); </code></pre> <p>Which is to say, I'd like to extend a generated class with a single method, not via inheritance but via the prototype.</p> <p>The class is generated from a WSDL, it's not a dynamic class, and I don't want to touch the generated code because it will be overwritten anyway.</p> <p>Long story short, I'd like to have the moral equivalent of C# 3:s Extension Methods for AS3.</p> <p>Edit: I accepted aib's answer, because it fits what I was asking best -- although upon further reflection it doesn't really solve my problem, but that's my fault for asking the wrong question. :) Also, upmods for the good suggestions.</p>
[ { "answer_id": 8886, "author": "aib", "author_id": 1088, "author_profile": "https://Stackoverflow.com/users/1088", "pm_score": 3, "selected": true, "text": "foo[\"method\"]();\n" }, { "answer_id": 9958, "author": "Theo", "author_id": 1109, "author_profile": "https://S...
2008/08/10
[ "https://Stackoverflow.com/questions/7212", "https://Stackoverflow.com", "https://Stackoverflow.com/users/266/" ]
7,231
<p>Can anyone recommend software or a .NET library that will check for bounced emails and the reason for the bounce? I get bounced emails into a pop3 account that I can read then.</p> <p>I need it to keep my user database clean from invalid email addresses and want to automate this (mark user as invalid email).</p>
[ { "answer_id": 7249, "author": "Robert Ellison", "author_id": 2521991, "author_profile": "https://Stackoverflow.com/users/2521991", "pm_score": 2, "selected": false, "text": "TcpClient tcpClient = new TcpClient();\ntcpClient.Connect(POP3Server, POP3Port);\nNetworkStream stream = tcpClien...
2008/08/10
[ "https://Stackoverflow.com/questions/7231", "https://Stackoverflow.com", "https://Stackoverflow.com/users/925/" ]
7,237
<p>Our software must be able to run on SQL Server 2000 and 2005. To simplify development, we're running our SQL Server 2005 databases in compatibility level 80. However, database performance seems slower on SQL 2005 than on SQL 2000 in some cases (we have not confirmed this using benchmarks yet). Would upgrading the compatibility level to 90 improve performance on the SQL 2005 servers?</p>
[ { "answer_id": 7242, "author": "SQLMenace", "author_id": 740, "author_profile": "https://Stackoverflow.com/users/740", "pm_score": 1, "selected": false, "text": "(*= and =*)" } ]
2008/08/10
[ "https://Stackoverflow.com/questions/7237", "https://Stackoverflow.com", "https://Stackoverflow.com/users/799/" ]
7,244
<p>What I want to do is something like this: I have enums with combined flagged values.</p> <pre><code>public static class EnumExtension { public static bool IsSet&lt;T&gt;( this T input, T matchTo ) where T:enum //the constraint I want that doesn't exist in C#3 { return (input &amp; matchTo) != 0; } } </code></pre> <p>So then I could do:</p> <pre><code>MyEnum tester = MyEnum.FlagA | MyEnum.FlagB if( tester.IsSet( MyEnum.FlagA ) ) //act on flag a </code></pre> <p>Unfortunately, C#'s generic where constraints have no enum restriction, only class and struct. C# doesn't see enums as structs (even though they are value types) so I can't add extension types like this.</p> <p>Does anyone know a workaround?</p>
[ { "answer_id": 7385, "author": "Ronnie", "author_id": 193, "author_profile": "https://Stackoverflow.com/users/193", "pm_score": 4, "selected": false, "text": "public static bool IsSet( this Enum input, Enum matchTo )\n{\n return ( Convert.ToUInt32( input ) & Convert.ToUInt32( matchTo ...
2008/08/10
[ "https://Stackoverflow.com/questions/7244", "https://Stackoverflow.com", "https://Stackoverflow.com/users/905/" ]
7,245
<p>What's the most efficient algorithm to find the rectangle with the largest area which will fit in the empty space?</p> <p>Let's say the screen looks like this ('#' represents filled area):</p> <pre><code>.................... ..............###### ##.................. .................### .................### #####............... #####............... #####............... </code></pre> <p>A probable solution is:</p> <pre><code>.................... ..............###### ##...++++++++++++... .....++++++++++++### .....++++++++++++### #####++++++++++++... #####++++++++++++... #####++++++++++++... </code></pre> <p>Normally I'd enjoy figuring out a solution. Although this time I'd like to avoid wasting time fumbling around on my own since this has a practical use for a project I'm working on. Is there a well-known solution?</p> <p><strong>Shog9</strong> wrote:</p> <blockquote> <p>Is your input an array (as implied by the other responses), or a list of occlusions in the form of arbitrarily sized, positioned rectangles (as might be the case in a windowing system when dealing with window positions)?</p> </blockquote> <p>Yes, I have a structure which keeps track of a set of windows placed on the screen. I also have a grid which keeps track of all the areas between each edge, whether they are empty or filled, and the pixel position of their left or top edge. I think there is some modified form which would take advantage of this property. Do you know of any?</p>
[ { "answer_id": 7250, "author": "Mark Renouf", "author_id": 758, "author_profile": "https://Stackoverflow.com/users/758", "pm_score": 2, "selected": false, "text": " // 4. Outer double-for-loop to consider all possible positions \n // for topleft corner. \n for (int i=0; i < M...
2008/08/10
[ "https://Stackoverflow.com/questions/7245", "https://Stackoverflow.com", "https://Stackoverflow.com/users/758/" ]
7,260
<p>How do I setup Public-Key Authentication for SSH?</p>
[ { "answer_id": 9095, "author": "dbr", "author_id": 745, "author_profile": "https://Stackoverflow.com/users/745", "pm_score": 8, "selected": true, "text": "ssh-keygen\n" } ]
2008/08/10
[ "https://Stackoverflow.com/questions/7260", "https://Stackoverflow.com", "https://Stackoverflow.com/users/889/" ]
7,272
<p>Alright, so maybe I shouldn't have shrunk this question sooo much... I have seen the post on <a href="https://stackoverflow.com/questions/622/most-efficient-code-for-the-first-10000-prime-numbers">the most efficient way to find the first 10000 primes</a>. I'm looking for <strong>all possible ways</strong>. The goal is to have a one stop shop for primality tests. Any and all tests people know for finding prime numbers are welcome.</p> <p>And so:</p> <ul> <li><strong>What are all the different ways of finding primes?</strong></li> </ul>
[ { "answer_id": 7476, "author": "goric", "author_id": 940, "author_profile": "https://Stackoverflow.com/users/940", "pm_score": 2, "selected": false, "text": "//Assuming theInteger is the number to be tested for primality.\n// Check if theInteger is divisible by 2. If not, run this loop....
2008/08/10
[ "https://Stackoverflow.com/questions/7272", "https://Stackoverflow.com", "https://Stackoverflow.com/users/145/" ]
7,277
<p>I'm generating some XML documents and when it comes to the address part I have fragments that look like this:</p> <pre><code>&lt;Address&gt;15 Sample St Example Bay Some Country&lt;/Address&gt; </code></pre> <p>The XSLT that I have for converting this to XHTML has some funky recursive template to convert newline characters within strings to &lt;br/&gt; tags.</p> <p>This is all working fine; but is it considered "bad practice" to rely on linebreaks within XML documents? If so, is it recommended that I do this instead?</p> <pre><code>&lt;Address&gt;&lt;Line&gt;15 Sample St&lt;/Line&gt; &lt;Line&gt;Example Bay&lt;/Line&gt; &lt;Line&gt;Some Country&lt;/Line&gt;&lt;/Address&gt; </code></pre> <p>Seems like it'd be really awkward to wrap every place where my text may be multiple lines with tags like that..</p>
[ { "answer_id": 7282, "author": "Derek Park", "author_id": 872, "author_profile": "https://Stackoverflow.com/users/872", "pm_score": 2, "selected": false, "text": "<Something>\n <Contains>\n <An>\n <Address>15 Sample St\nExample Bay\nSome Country</Address>\n </...
2008/08/10
[ "https://Stackoverflow.com/questions/7277", "https://Stackoverflow.com", "https://Stackoverflow.com/users/755/" ]
7,284
<p>What does the expression "Turing Complete" mean? </p> <p>Can you give a simple explanation, without going into too many theoretical details?</p>
[ { "answer_id": 1610655, "author": "Gordon Gustafson", "author_id": 89989, "author_profile": "https://Stackoverflow.com/users/89989", "pm_score": 7, "selected": false, "text": "+" } ]
2008/08/10
[ "https://Stackoverflow.com/questions/7284", "https://Stackoverflow.com", "https://Stackoverflow.com/users/198/" ]
7,287
<p>Lately I had to change some code on older systems where not all of the code has unit tests.<br> Before making the changes I want to write tests, but each class created a lot of dependencies and other anti-patterns which made testing quite hard.<br> Obviously, I wanted to refactor the code to make it easier to test, write the tests and then change it.<br> Is this the way you'd do it? Or would you spend a lot of time writing the hard-to-write tests that would be mostly removed after the refactoring will be completed?</p>
[ { "answer_id": 7296, "author": "Mike Stone", "author_id": 122, "author_profile": "https://Stackoverflow.com/users/122", "pm_score": 4, "selected": true, "text": "public class MyClass {\n public MyClass() {\n // undesirable DB logic\n }\n}\n" } ]
2008/08/10
[ "https://Stackoverflow.com/questions/7287", "https://Stackoverflow.com", "https://Stackoverflow.com/users/573/" ]
7,348
<p>My requirements:</p> <ul> <li>Support .NET Compact Framework 2.0 and Windows Mobile 6.0 devices.</li> <li>Only need to unzip the contents to a directory on a storage card. Creation of zip files is not required.</li> <li>Must be able to use in corporate/commercial software.</li> <li>Can be open source, but not have GPL or other viral license.</li> </ul> <p>I've seen the <a href="http://xceed.com/Zip_NET_CF_Intro.html" rel="noreferrer">Xceed Zip for CF</a> library. What other options are there?</p>
[ { "answer_id": 388253, "author": "Cheeso", "author_id": 48082, "author_profile": "https://Stackoverflow.com/users/48082", "pm_score": 3, "selected": false, "text": " try\n {\n using (var zip1 = Ionic.Zip.ZipFile.Read(zipToUnpack))\n {\n foreach (var entry in zip1)\n ...
2008/08/10
[ "https://Stackoverflow.com/questions/7348", "https://Stackoverflow.com", "https://Stackoverflow.com/users/636/" ]
7,364
<p>Does anyone know of a good method for editing PDFs in PHP? Preferably open-source/zero-license cost methods. :)</p> <p>I am thinking along the lines of opening a PDF file, replacing text in the PDF and then writing out the modified version of the PDF?</p> <p>On the front-end</p>
[ { "answer_id": 7455, "author": "grom", "author_id": 486, "author_profile": "https://Stackoverflow.com/users/486", "pm_score": 7, "selected": true, "text": "<?php\nrequire_once 'Zend/Pdf.php';\n\n$pdf = Zend_Pdf::load('blank.pdf');\n$page = $pdf->pages[0];\n$font = Zend_Pdf_Font::fontWith...
2008/08/10
[ "https://Stackoverflow.com/questions/7364", "https://Stackoverflow.com", "https://Stackoverflow.com/users/277/" ]
7,398
<p>I haven't seen any questions relating to GNU autoconf/automake builds, but I'm hoping at least some of you out there are familiar with it. Here goes:</p> <p>I have a project (I'll call it myproject) that includes another project (vendor). The vendor project is a standalone project maintained by someone else. Including a project like this is fairly <a href="http://www.gnu.org/software/autoconf/manual/autoconf.html#Subdirectories" rel="nofollow noreferrer">straightforward</a>, but in this case there is a tiny snag: each project generates its own <code>config.h</code> file, each of which defines standard macros such as PACKAGE, VERSION, etc. This means that, during the build, when vendor is being built, I get lots of errors like this:</p> <pre><code>... warning: "VERSION" redefined ... warning: this is the location of the previous definition ... warning: "PACKAGE" redefined ... warning: this is the location of the previous definition </code></pre> <p>These are just warnings, for the time being at least, but I would like to get rid of them. The only relevant information I've been able to turn up with a Google search is <a href="http://sourceware.org/ml/automake/2004-03/msg00130.html" rel="nofollow noreferrer">this</a> thread on the automake mailing list, which isn't a whole lot of help. Does anybody else have any better ideas?</p>
[ { "answer_id": 9214, "author": "David Joyner", "author_id": 1146, "author_profile": "https://Stackoverflow.com/users/1146", "pm_score": 2, "selected": false, "text": "config.h" }, { "answer_id": 11269, "author": "Jason Day", "author_id": 737, "author_profile": "https:...
2008/08/10
[ "https://Stackoverflow.com/questions/7398", "https://Stackoverflow.com", "https://Stackoverflow.com/users/737/" ]
7,470
<p>After a couple of hours fighting with the <a href="http://gallery.menalto.com/" rel="nofollow noreferrer">Gallery2</a> <a href="http://codex.gallery2.org/Gallery2:Modules:rss" rel="nofollow noreferrer">RSS module</a> and getting only the message, "no feeds have yet been defined", I gave up. Based on <a href="http://www.google.com/search?q=%22no+feeds+have+yet+been+defined%22" rel="nofollow noreferrer">a Google search for "no feeds have yet been defined"</a>, this is a pretty common problem. Do you have any tips and/or tricks for getting the Gallery2 RSS module to work? Or any tips for a relatively-PHP-ignorant developer trying to debug problems with this PHP application?</p>
[ { "answer_id": 7471, "author": "ESV", "author_id": 150, "author_profile": "https://Stackoverflow.com/users/150", "pm_score": 1, "selected": false, "text": "#!/usr/bin/python\n\"\"\"A CGI script to produce an RSS feed of top-level Gallery2 albums.\"\"\"\n\n#import cgi\n#import cgitb; cgit...
2008/08/11
[ "https://Stackoverflow.com/questions/7470", "https://Stackoverflow.com", "https://Stackoverflow.com/users/150/" ]
7,472
<p>Can anyone point me to a good resource (or throw me a clue) to show me how to do DataBinding to controls (ComboBox, ListBox, etc.) in WPF? I'm at a bit of a loss when all my WinForms niceities are taken away from me, and I'm not all that bright to start with...</p>
[ { "answer_id": 7475, "author": "Leon Bambrick", "author_id": 49, "author_profile": "https://Stackoverflow.com/users/49", "pm_score": 2, "selected": false, "text": "private void OnInit(object sender, EventArgs e)\n{\n //myDataSet is some IEnumerable \n\n // myListBox is a ListBox contro...
2008/08/11
[ "https://Stackoverflow.com/questions/7472", "https://Stackoverflow.com", "https://Stackoverflow.com/users/856/" ]
7,477
<p>I'm currently working on an internal sales application for the company I work for, and I've got a form that allows the user to change the delivery address.</p> <p>Now I think it would look much nicer, if the textarea I'm using for the main address details would just take up the area of the text in it, and automatically resize if the text was changed.</p> <p>Here's a screenshot of it currently.</p> <p><img src="https://i.stack.imgur.com/XK48E.png" alt="ISO Address"></p> <p>Any ideas?</p> <hr> <p>@Chris</p> <p>A good point, but there are reasons I want it to resize. I want the area it takes up to be the area of the information contained in it. As you can see in the screen shot, if I have a fixed textarea, it takes up a fair wack of vertical space.</p> <p>I can reduce the font, but I need address to be large and readable. Now I can reduce the size of the text area, but then I have problems with people who have an address line that takes 3 or 4 (one takes 5) lines. Needing to have the user use a scrollbar is a major no-no.</p> <p>I guess I should be a bit more specific. I'm after vertical resizing, and the width doesn't matter as much. The only problem that happens with that, is the ISO number (the large "1") gets pushed under the address when the window width is too small (as you can see on the screenshot).</p> <p>It's not about having a gimick; it's about having a text field the user can edit that won't take up unnecessary space, but will show all the text in it.</p> <p>Though if someone comes up with another way to approach the problem I'm open to that too.</p> <hr> <p>I've modified the code a little because it was acting a little odd. I changed it to activate on keyup, because it wouldn't take into consideration the character that was just typed.</p> <pre><code>resizeIt = function() { var str = $('iso_address').value; var cols = $('iso_address').cols; var linecount = 0; $A(str.split("\n")).each(function(l) { linecount += 1 + Math.floor(l.length / cols); // Take into account long lines }) $('iso_address').rows = linecount; }; </code></pre>
[ { "answer_id": 7523, "author": "Orion Edwards", "author_id": 234, "author_profile": "https://Stackoverflow.com/users/234", "pm_score": 7, "selected": true, "text": "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"\n \"http://www.w3.org/TR/html4/loose.dtd\">\n<html>\n ...
2008/08/11
[ "https://Stackoverflow.com/questions/7477", "https://Stackoverflow.com", "https://Stackoverflow.com/users/841/" ]
7,489
<p>I've made many different seperate parts of a GUI system for the Nintendo DS, like buttons and textboxes and select boxes, but I need a way of containing these classes in one Gui class, so that I can draw everything to the screen all at once, and check all the buttons at once to check if any are being pressed. My question is what is the best way organize all the classes (such as buttons and textboxes) into one GUI class?</p> <p>Here's one way I thought of but it doesn't seem right:</p> <p><strong>Edit:</strong> I'm using C++.</p> <pre><code>class Gui { public: void update_all(); void draw_all() const; int add_button(Button *button); // Returns button id void remove_button(int button_id); private: Button *buttons[10]; int num_buttons; } </code></pre> <p>This code has a few problems, but I just wanted to give you an idea of what I want.</p>
[ { "answer_id": 13384, "author": "thing2k", "author_id": 3180, "author_profile": "https://Stackoverflow.com/users/3180", "pm_score": 3, "selected": true, "text": "class uiElement()\n{\n ...\n virtual void Update() = 0;\n virtual void Draw() = 0;\n ...\n}\n\nclass uiButton() pu...
2008/08/11
[ "https://Stackoverflow.com/questions/7489", "https://Stackoverflow.com", "https://Stackoverflow.com/users/813/" ]
7,492
<p>In the past, I used Microsoft Web Application Stress Tool and Pylot to stress test web applications. I'd written a simple home page, login script, and site walkthrough (in an ecommerce site adding a few items to a cart and checkout).</p> <p>Just hitting the homepage hard with a handful of developers would almost always locate a major problem. More scalability problems would surface at the second stage, and even more - after the launch.</p> <p>The URL of the tools I used were Microsoft Homer (aka <a href="http://www.microsoft.com/downloads/details.aspx?familyid=e2c0585a-062a-439e-a67d-75a89aa36495&amp;displaylang=en" rel="noreferrer">Microsoft Web Application Stress Tool</a>) and <a href="https://code.google.com/archive/p/pylt/" rel="noreferrer">Pylot</a>.</p> <p>The reports generated by these tools never made much sense to me, and I would spend many hours trying to figure out what kind of concurrent load the site would be able to support. It was always worth it because the stupidest bugs and bottlenecks would always come up (for instance, web server misconfigurations).</p> <p>What have you done, what tools have you used, and what success have you had with your approach? The part that is most interesting to me is coming up with some kind of a meaningful formula for calculating the number of concurrent users an app can support from the numbers reported by the stress test application.</p>
[ { "answer_id": 3546467, "author": "Ben Li", "author_id": 423840, "author_profile": "https://Stackoverflow.com/users/423840", "pm_score": 3, "selected": false, "text": "ab -c n -t 30 url\n\nsiege -b -c n -t 30s url\n" }, { "answer_id": 33876200, "author": "Sunil Kapil", "a...
2008/08/11
[ "https://Stackoverflow.com/questions/7492", "https://Stackoverflow.com", "https://Stackoverflow.com/users/556/" ]
7,503
<p>I know almost nothing about linq.</p> <p>I'm doing this:</p> <pre><code>var apps = from app in Process.GetProcesses() where app.ProcessName.Contains( "MyAppName" ) &amp;&amp; app.MainWindowHandle != IntPtr.Zero select app; </code></pre> <p>Which gets me all the running processes which match that criteria.</p> <p>But I don't know how to get the first one. The examples I can find on the net seem to imply I have to do this</p> <pre><code>var matchedApp = (from app in Process.GetProcesses() where app.ProcessName.Contains( "MyAppName" ) &amp;&amp; app.MainWindowHandle != IntPtr.Zero select app).First(); </code></pre> <p>which strikes me as somewhat ugly, and also throws an exception if there are no matching processes. Is there a better way?</p> <p><strong>UPDATE</strong></p> <p>I'm actually trying to find the first matching item, and call <code>SetForegroundWindow</code> on it</p> <p>I've come up with this solution, which also strikes me as ugly and awful, but better than above. Any ideas?</p> <pre><code>var unused = from app in Process.GetProcesses() where app.ProcessName.Contains( "MyAppName" ) &amp;&amp; app.MainWindowHandle != IntPtr.Zero select SetForegroundWindow( app.MainWindowHandle ); // side-effects in linq-query is technically bad I guess </code></pre>
[ { "answer_id": 7509, "author": "FryHard", "author_id": 231, "author_profile": "https://Stackoverflow.com/users/231", "pm_score": 0, "selected": false, "text": "var apps = from app in Process.GetProcesses()\nwhere app.ProcessName.Contains( \"MyAppName\" ) && app.MainWindowHandle != IntPtr...
2008/08/11
[ "https://Stackoverflow.com/questions/7503", "https://Stackoverflow.com", "https://Stackoverflow.com/users/234/" ]
7,517
<p>Is there a simple way to drop a group of interrelated tables in SQL Server? Ideally I'd like to avoid having to worry about what order they're being dropped in since I know the entire group will be gone by the end of the process.</p>
[ { "answer_id": 7537, "author": "Derek Park", "author_id": 872, "author_profile": "https://Stackoverflow.com/users/872", "pm_score": 0, "selected": false, "text": "DROP TABLE IF EXISTS table1, table2, table3 CASCADE;\n" }, { "answer_id": 25719, "author": "Matt Sheppard", "...
2008/08/11
[ "https://Stackoverflow.com/questions/7517", "https://Stackoverflow.com", "https://Stackoverflow.com/users/797/" ]
7,525
<p>So, I need some help. I am working on a project in C++. However, I think I have somehow managed to corrupt my heap. This is based on the fact that I added an <code>std::string</code> to a class and assigning it a value from another <code>std::string</code>:</p> <pre><code>std::string hello = "Hello, world.\n"; /* exampleString = "Hello, world.\n" would work fine. */ exampleString = hello; </code></pre> <p>crashes on my system with a stack dump. So basically I need to <strong>stop</strong> and go through all my code and memory management stuff and find out where I've screwed up. The codebase is still small (about 1000 lines), so this is easily do-able. </p> <p>Still, I'm over my head with this kind of stuff, so I thought I'd throw it out there. I'm on a Linux system and have poked around with <code>valgrind</code>, and while not knowing completely what I'm doing, it did report that the <code>std::string</code>'s destructor was an invalid free. I have to admit to getting the term 'Heap Corruption' from a Google search; any general purpose articles on this sort of stuff would be appreciated as well.</p> <p>(In before <code>rm -rf ProjectDir</code>, do again in C# :D)</p> <p>EDIT: I haven't made it clear, but what I'm asking for are ways an advice of diagnosing these sort of memory problems. I know the std::string stuff is right, so it's something I've done (or a bug, but there's Not A Problem With Select). I'm sure I could check the code I've written up and you very smart folks would see the problem in no time, but I want to add this kind of code analysis to my 'toolbox', as it were.</p>
[ { "answer_id": 7559, "author": "Bernard", "author_id": 61, "author_profile": "https://Stackoverflow.com/users/61", "pm_score": 1, "selected": false, "text": " this->map = new Area*[largestY + 1];\n for (int i = 0; i < largestY + 1; i++) {\n this->map[i] = new Area[largestX + 1];\n }\...
2008/08/11
[ "https://Stackoverflow.com/questions/7525", "https://Stackoverflow.com", "https://Stackoverflow.com/users/61/" ]
7,535
<p>What is the best way to use SQL Server 2008 as a development database, but ensure that the database is compatible with SQL Server 2005?</p>
[ { "answer_id": 7547, "author": "vzczc", "author_id": 224, "author_profile": "https://Stackoverflow.com/users/224", "pm_score": 5, "selected": true, "text": "ALTER DATABASE <database> \nSET COMPATIBILITY_LEVEL = { 80 | 90 | 100 }\n" } ]
2008/08/11
[ "https://Stackoverflow.com/questions/7535", "https://Stackoverflow.com", "https://Stackoverflow.com/users/708/" ]
7,539
<p>Recently I tried understanding the use of <strong>java.math.MathContext</strong> but failed to understand properly. Is it used for rounding in <code>java.math.BigDecimal</code>. If yes why does not it round the decimal digits but even mantissa part.</p> <p>From API docs, I came to know that it follows the standard specified in <code>ANSI X3.274-1996</code> and <code>ANSI X3.274-1996/AM 1-2000</code> specifications but I did not get them to read online.</p> <p>Please let me know if you have any idea on this.</p>
[ { "answer_id": 7550, "author": "Derek Park", "author_id": 872, "author_profile": "https://Stackoverflow.com/users/872", "pm_score": 3, "selected": false, "text": "System.out.println(new BigDecimal(\"1234567890.123456789\",\n new MathContext(20)));\n\nSystem.out.println(...
2008/08/11
[ "https://Stackoverflow.com/questions/7539", "https://Stackoverflow.com", "https://Stackoverflow.com/users/959/" ]
7,551
<p>When designing a REST API or service are there any established best practices for dealing with security (Authentication, Authorization, Identity Management) ?</p> <p>When building a SOAP API you have WS-Security as a guide and much literature exists on the topic. I have found less information about securing REST endpoints.</p> <p>While I understand REST intentionally does not have specifications analogous to WS-* I am hoping best practices or recommended patterns have emerged.</p> <p>Any discussion or links to relevant documents would be very much appreciated. If it matters, we would be using WCF with POX/JSON serialized messages for our REST API's/Services built using v3.5 of the .NET Framework.</p>
[ { "answer_id": 24807288, "author": "Archimedes Trajano", "author_id": 242042, "author_profile": "https://Stackoverflow.com/users/242042", "pm_score": 2, "selected": false, "text": "userPrincipal" }, { "answer_id": 47189047, "author": "Andrejs", "author_id": 2786733, "...
2008/08/11
[ "https://Stackoverflow.com/questions/7551", "https://Stackoverflow.com", "https://Stackoverflow.com/users/541/" ]
7,558
<p>I am displaying a list of items using a SAP ABAP column tree model, basically a tree of folder and files, with columns.</p> <p>I want to load the sub-nodes of folders dynamically, so I'm using the EXPAND_NO_CHILDREN event which is firing correctly.</p> <p>Unfortunately, after I add the new nodes and items to the tree, the folder is automatically collapsing again, requiring a second click to view the sub-nodes. Do I need to call a method when handling the event so that the folder stays open, or am I doing something else wrong?</p> <pre><code>* Set up event handling. LS_EVENT-EVENTID = CL_ITEM_TREE_CONTROL=&gt;EVENTID_EXPAND_NO_CHILDREN. LS_EVENT-APPL_EVENT = GC_X. APPEND LS_EVENT TO LT_EVENTS. CALL METHOD GO_MODEL-&gt;SET_REGISTERED_EVENTS EXPORTING EVENTS = LT_EVENTS EXCEPTIONS ILLEGAL_EVENT_COMBINATION = 1 UNKNOWN_EVENT = 2. SET HANDLER GO_APPLICATION-&gt;HANDLE_EXPAND_NO_CHILDREN FOR GO_MODEL. ... * Add new data to tree. CALL METHOD GO_MODEL-&gt;ADD_NODES EXPORTING NODE_TABLE = PTI_NODES[] EXCEPTIONS ERROR_IN_NODE_TABLE = 1. CALL METHOD GO_MODEL-&gt;ADD_ITEMS EXPORTING ITEM_TABLE = PTI_ITEMS[] EXCEPTIONS NODE_NOT_FOUND = 1 ERROR_IN_ITEM_TABLE = 2. </code></pre>
[ { "answer_id": 63251, "author": "tomdemuyt", "author_id": 7602, "author_profile": "https://Stackoverflow.com/users/7602", "pm_score": 0, "selected": false, "text": "ADD_NODES_AND_ITEMS" } ]
2008/08/11
[ "https://Stackoverflow.com/questions/7558", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
7,579
<p>In the SSW rules to better SQL Server Database there is an example of a full database maintenance plan: <a href="http://www.ssw.com.au/ssw/Standards/Rules/RulesToBetterSQLServerDatabases.aspx#MaintenancePlan" rel="noreferrer">SSW</a>. In the example they run both a Reorganize Index and then a Rebuild Index and then Update Statistics. Is there any point to this? I thought Reorganize Index was a fast but less effective version of Rebuild Index? and that an index rebuild would also update the statistics automatically (on the clustered index at least).</p>
[ { "answer_id": 7635, "author": "GateKiller", "author_id": 383, "author_profile": "https://Stackoverflow.com/users/383", "pm_score": 3, "selected": false, "text": "EXEC [sp_MSforeachtable] @command1=\"RAISERROR('DBCC DBREINDEX(''?'') ...',10,1) WITH NOWAIT DBCC DBREINDEX('?')\"\n" }, ...
2008/08/11
[ "https://Stackoverflow.com/questions/7579", "https://Stackoverflow.com", "https://Stackoverflow.com/users/961/" ]
7,586
<p>I was trying to get my head around XAML and thought that I would try writing some code. </p> <p>Trying to add a grid with 6 by 6 column definitions then add a text block into one of the grid cells. I don't seem to be able to reference the cell that I want. There is no method on the grid that I can add the text block too. There is only grid.children.add(object), no Cell definition.</p> <p>XAML:</p> <pre><code>&lt;Page x:Class="WPF_Tester.Page1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Page1" Loaded="Page_Loaded"&gt; &lt;/Page&gt; </code></pre> <p>C#:</p> <pre><code>private void Page_Loaded(object sender, RoutedEventArgs e) { //create the structure Grid g = new Grid(); g.ShowGridLines = true; g.Visibility = Visibility.Visible; //add columns for (int i = 0; i &lt; 6; ++i) { ColumnDefinition cd = new ColumnDefinition(); cd.Name = "Column" + i.ToString(); g.ColumnDefinitions.Add(cd); } //add rows for (int i = 0; i &lt; 6; ++i) { RowDefinition rd = new RowDefinition(); rd.Name = "Row" + i.ToString(); g.RowDefinitions.Add(rd); } TextBlock tb = new TextBlock(); tb.Text = "Hello World"; g.Children.Add(tb); } </code></pre> <p><strong>Update</strong></p> <p>Here is the spooky bit:</p> <ul> <li><p>Using VS2008 Pro on XP</p></li> <li><p>WPFbrowser Project Template (3.5 verified)</p></li> </ul> <p>I don't get the methods in autocomplete.</p>
[ { "answer_id": 7590, "author": "Matt Hamilton", "author_id": 615, "author_profile": "https://Stackoverflow.com/users/615", "pm_score": 4, "selected": true, "text": "<TextBlock Grid.Row=\"0\" Grid.Column=\"0\" />\n" }, { "answer_id": 7591, "author": "Zooba", "author_id": 8...
2008/08/11
[ "https://Stackoverflow.com/questions/7586", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
7,592
<p>I want to create a client side mail creator web page. I know the problems of using the mailto action in an html form (not standard, no default mail appication set on the client). But the web page isn't very important, and they don't care very much.</p> <p>The mail created by the mailto action has the syntax:</p> <blockquote> <p>subject: undefined subject<br> body:</p> <p>param1=value1<br> param2=value2<br> .<br> .<br> .<br> paramn=valuen </p> </blockquote> <p>Can I use JavaScript to format the mail like this?</p> <blockquote> <p>Subject:XXXXX</p> <p>Body: Value1;Value2;Value3...ValueN</p> </blockquote>
[ { "answer_id": 7643, "author": "Vincent Robert", "author_id": 268, "author_profile": "https://Stackoverflow.com/users/268", "pm_score": 5, "selected": true, "text": "var addresses = \"\";//between the speech mark goes the receptient. Seperate addresses with a ;\nvar body = \"\"//write th...
2008/08/11
[ "https://Stackoverflow.com/questions/7592", "https://Stackoverflow.com", "https://Stackoverflow.com/users/518/" ]
7,596
<p>First of all, I know how to build a Java application. But I have always been puzzled about where to put my classes. There are proponents for organizing the packages in a strictly domain oriented fashion, others separate by tier.</p> <p>I myself have always had problems with </p> <ul> <li>naming, </li> <li>placing</li> </ul> <p>So,</p> <ol> <li>Where do you put your domain specific constants (and what is the best name for such a class)?</li> <li>Where do you put classes for stuff which is both infrastructural and domain specific (for instance I have a FileStorageStrategy class, which stores the files either in the database, or alternatively in database)?</li> <li>Where to put Exceptions?</li> <li>Are there any standards to which I can refer?</li> </ol>
[ { "answer_id": 7610, "author": "Kieron", "author_id": 588, "author_profile": "https://Stackoverflow.com/users/588", "pm_score": 2, "selected": false, "text": "com.domain.subdomain" }, { "answer_id": 8594, "author": "cringe", "author_id": 834, "author_profile": "https:...
2008/08/11
[ "https://Stackoverflow.com/questions/7596", "https://Stackoverflow.com", "https://Stackoverflow.com/users/917/" ]
7,614
<p>What is the best way of testing a function that throws on failure? Or testing a function that is fairly immune to failure?</p> <p>For instance; I have a <code>I/O Completion Port</code> class that throws in the constructor if it can't initialise the port correctly. This uses the <code>Win32</code> function of <code>CreateIoCompletionPort</code> in the initialiser list. If the handle isn't set correctly - a non-null value - then the constructor will throw an exception. I have never seen this function fail.</p> <p>I am pretty certain that this (and other functions like it in my code) if they fail will behave correctly, the code is 50 lines long including white-space, so my questions are</p> <p>a) is it worth testing that it will throw<br> b) and if it is worth testing, how to?<br> c) should simple wrapper classes as these be unit-tested? </p> <p>For b) I thought about overriding <code>CreateIoCompletionPort</code> and passing the values through. In the unit test override it and cause it to return 0 when a certain value is passed in. However since this is used in the constructor then this needs to be static. Does this seem valid or not?</p>
[ { "answer_id": 7624, "author": "Mike Stone", "author_id": 122, "author_profile": "https://Stackoverflow.com/users/122", "pm_score": 2, "selected": false, "text": "public class MyClass {\n public MyClass() throws MyClassException {\n // Whatever, including a call to invokeCreate...
2008/08/11
[ "https://Stackoverflow.com/questions/7614", "https://Stackoverflow.com", "https://Stackoverflow.com/users/342/" ]
7,622
<p>In C, are the shift operators (<code>&lt;&lt;</code>, <code>&gt;&gt;</code>) arithmetic or logical?</p>
[ { "answer_id": 7632, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 7, "selected": false, "text": "signed int x1 = 5;\nassert((x1 >> 1) == 2);\nsigned int x2 = -5;\nassert((x2 >> 1) == -3);\nunsigned int x3 = (unsigned int...
2008/08/11
[ "https://Stackoverflow.com/questions/7622", "https://Stackoverflow.com", "https://Stackoverflow.com/users/973/" ]
7,642
<p>Is there an official convention for naming private fields in VB.NET? For example, if I have a property called 'Foo', I normally call the private field '_Foo'. This seems to be frowned upon in the <a href="http://msdn.microsoft.com/en-us/library/ms229012.aspx" rel="noreferrer">Offical Guidelines</a>:</p> <p>"Do not use a prefix for field names. For example, do not use g_ or s_ to distinguish static versus non-static fields."</p> <p>In C#, you could call the private field 'foo', the property 'Foo', and refer to the private field as 'this.foo' in the constructor. As VB.NET is case insensitive you can't do this - any suggestions?</p>
[ { "answer_id": 8092, "author": "Lance Fisher", "author_id": 571, "author_profile": "https://Stackoverflow.com/users/571", "pm_score": 0, "selected": false, "text": "Public Class Class1\n\n Private _foo As String\n Public Property Foo() As String\n Get\n Return _fo...
2008/08/11
[ "https://Stackoverflow.com/questions/7642", "https://Stackoverflow.com", "https://Stackoverflow.com/users/133/" ]
7,651
<p>I have an array in Perl:</p> <pre><code>my @my_array = ("one","two","three","two","three"); </code></pre> <p>How do I remove the duplicates from the array?</p>
[ { "answer_id": 7657, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 8, "selected": true, "text": "sub uniq {\n my %seen;\n grep !$seen{$_}++, @_;\n}\n\nmy @array = qw(one two three two three);\nmy @filtered = uniq(@a...
2008/08/11
[ "https://Stackoverflow.com/questions/7651", "https://Stackoverflow.com", "https://Stackoverflow.com/users/381/" ]
7,661
<p>Searching for some sample code for converting a point in WGS84 coordinate system to a map position in Google Maps (pixel position), also supporting zoom levels. </p> <p>If the codes is well commented, then it can also be in some other language.</p> <p>You can also point me to a open source Java project :)</p> <p>Some resources found:</p> <p><a href="http://trac.openlayers.org/browser/trunk/openlayers/lib/OpenLayers/Layer" rel="nofollow noreferrer">OpenLayer</a> implementation. </p> <p><a href="http://josm.openstreetmap.de/browser/trunk/src/org/openstreetmap/josm/data/projection" rel="nofollow noreferrer">JOSM</a> project</p> <p>Excellent <a href="https://github.com/OSUCartography/JMapProjLib" rel="nofollow noreferrer">Java Map Projection Library </a> from JH LABS. This is a pure java PROJ.4 port. Does projection from WGS84 to meters. From there it's quite straightforward to convert meters to tile pixels.</p>
[ { "answer_id": 2373697, "author": "Ro.", "author_id": 103446, "author_profile": "https://Stackoverflow.com/users/103446", "pm_score": 2, "selected": false, "text": "function toMercator (lon, lat) {\n var x = lon * 20037508.34 / 180;\n var y = Math.log(Math.tan((90 + lat) * Math.PI / 36...
2008/08/11
[ "https://Stackoverflow.com/questions/7661", "https://Stackoverflow.com", "https://Stackoverflow.com/users/706/" ]
7,662
<p>Whenever I design a database, I always wonder if there is a best way of naming an item in my database. Quite often I ask myself the following questions:</p> <ol> <li>Should table names be plural?</li> <li>Should column names be singular?</li> <li>Should I prefix tables or columns?</li> <li>Should I use any case in naming items?</li> </ol> <p>Are there any recommended guidelines out there for naming items in a database?</p>
[ { "answer_id": 7667, "author": "Matt Hamilton", "author_id": 615, "author_profile": "https://Stackoverflow.com/users/615", "pm_score": 7, "selected": false, "text": "SELECT person.Name\nFROM People person\n" }, { "answer_id": 7678, "author": "Keith", "author_id": 905, ...
2008/08/11
[ "https://Stackoverflow.com/questions/7662", "https://Stackoverflow.com", "https://Stackoverflow.com/users/383/" ]
7,664
<p>I am wrapping existing C++ code from a <strong>BSD</strong> project in our own custom wrapper and I want to integrate it to our code with as few changes as possible. This code uses <code>fprintf</code> to print to <strong>stderr</strong> in order to log / report errors.</p> <p>I want to redirect this to an alternative place within the same process. On <strong>Unix</strong> I have done this with a <code>socketpair</code> and a <code>thread</code>: one end of the socket is where I send <strong>stderr</strong> (via a call to <code>dup2</code>) and the other end is monitored in a thread, where I can then process the output.</p> <p>This does not work on <strong>Windows</strong> though because a socket is not the same as a file handle.</p> <p>All documents I have found on the web show how to redirect output from a child process, which is not what I want. How can I redirect <strong>stderr</strong> within the same process getting a callback of some sort when output is written? (and before you say so, I've tried <code>SetStdHandle</code> but cannot find any way to make this work)...</p>
[ { "answer_id": 7669, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 4, "selected": true, "text": "DWORD CALLBACK DoDebugThread(void *)\n{\n AllocConsole();\n SetConsoleTitle(\"Copilot Debugger\");\n // The followi...
2008/08/11
[ "https://Stackoverflow.com/questions/7664", "https://Stackoverflow.com", "https://Stackoverflow.com/users/912/" ]
7,665
<p>Given an absolute or relative path (in a Unix-like system), I would like to determine the full path of the target after resolving any intermediate symlinks. Bonus points for also resolving ~username notation at the same time.</p> <p>If the target is a directory, it might be possible to chdir() into the directory and then call getcwd(), but I really want to do this from a shell script rather than writing a C helper. Unfortunately, shells have a tendency to try to hide the existence of symlinks from the user (this is bash on OS X):</p> <pre><code>$ ls -ld foo bar drwxr-xr-x 2 greg greg 68 Aug 11 22:36 bar lrwxr-xr-x 1 greg greg 3 Aug 11 22:36 foo -&gt; bar $ cd foo $ pwd /Users/greg/tmp/foo $ </code></pre> <p>What I want is a function resolve() such that when executed from the tmp directory in the above example, resolve("foo") == "/Users/greg/tmp/bar".</p>
[ { "answer_id": 7666, "author": "kauppi", "author_id": 964, "author_profile": "https://Stackoverflow.com/users/964", "pm_score": 8, "selected": true, "text": "pwd -P" }, { "answer_id": 7673, "author": "Hugo", "author_id": 972, "author_profile": "https://Stackoverflow.c...
2008/08/11
[ "https://Stackoverflow.com/questions/7665", "https://Stackoverflow.com", "https://Stackoverflow.com/users/893/" ]
7,685
<p>I was recently brushing up on some fundamentals and found merge sorting a linked list to be a pretty good challenge. If you have a good implementation then show it off here.</p>
[ { "answer_id": 3032462, "author": "Dave Gamble", "author_id": 133758, "author_profile": "https://Stackoverflow.com/users/133758", "pm_score": 3, "selected": false, "text": "\ntypedef struct _aList {\n struct _aList* next;\n struct _aList* prev; // Optional.\n // some data\n} ...
2008/08/11
[ "https://Stackoverflow.com/questions/7685", "https://Stackoverflow.com", "https://Stackoverflow.com/users/608/" ]