qid int64 4 8.14M | question stringlengths 20 48.3k | answers list | date stringlengths 10 10 | metadata list | input stringlengths 12 45k | output stringlengths 2 31.8k |
|---|---|---|---|---|---|---|
496,987 | <p>I'm trying to add a strongly-typed view to the sample app that's created when you create a new MVC project, but I'm not getting something. I added a "Warehouse.dbml" LINQ to SQL file in the Models folder, which contains one table. When I go to the Views folder and right-click and select Add | View, all I see under "... | [
{
"answer_id": 497568,
"author": "Morph",
"author_id": 31489,
"author_profile": "https://Stackoverflow.com/users/31489",
"pm_score": 0,
"selected": false,
"text": "<p>Ran into the same thing today, and my own classes didn't show up in the dropdown box. Weird enough later on they did. May... | 2009/01/30 | [
"https://Stackoverflow.com/questions/496987",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23935/"
] | I'm trying to add a strongly-typed view to the sample app that's created when you create a new MVC project, but I'm not getting something. I added a "Warehouse.dbml" LINQ to SQL file in the Models folder, which contains one table. When I go to the Views folder and right-click and select Add | View, all I see under "Cre... | Have you tried looking in your web.config and including those namespaces?
```
<namespaces>
<add namespace="System.Web.Mvc"/>
<add namespace="System.Web.Mvc.Ajax"/>
```
You would add another element with something like
```
<add namespace="MyProject.Data" />
```
That should fix it. |
497,018 | <p>Is there a function to round a float in C or do I need to write my own? </p>
<blockquote>
<p>float conver = 45.<strong>59</strong>2346543;</p>
</blockquote>
<p>I would like to round the actual value to one decimal place, conver = 45.<strong>6</strong>.</p>
| [
{
"answer_id": 497034,
"author": "Joao da Silva",
"author_id": 46329,
"author_profile": "https://Stackoverflow.com/users/46329",
"pm_score": 2,
"selected": false,
"text": "<pre><code>#include <math.h>\n\ndouble round(double x);\nfloat roundf(float x);\n</code></pre>\n\n<p>Don't for... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497018",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52256/"
] | Is there a function to round a float in C or do I need to write my own?
>
> float conver = 45.**59**2346543;
>
>
>
I would like to round the actual value to one decimal place, conver = 45.**6**. | As Rob mentioned, you probably just want to *print* the float to 1 decimal place. In this case, you can do something like the following:
```
#include <stdio.h>
#include <stdlib.h>
int main()
{
float conver = 45.592346543;
printf("conver is %0.1f\n",conver);
return 0;
}
```
If you want to actually round the st... |
497,020 | <p>I am wanting to have a series of dates (mainly Month, Day, Year) displayed within a vertical arrangement of table cells on a web page. The first date needs to be the current date minus one day, with the next date in the sequence be the current date, The remaining dates need to incrementally be one day in future out... | [
{
"answer_id": 497039,
"author": "Cyril Gupta",
"author_id": 33052,
"author_profile": "https://Stackoverflow.com/users/33052",
"pm_score": 0,
"selected": false,
"text": "<p>Did you try myDate.toString() or myDate.toDateString()?</p>\n\n<p>What you need to do is have some variables holdin... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497020",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am wanting to have a series of dates (mainly Month, Day, Year) displayed within a vertical arrangement of table cells on a web page. The first date needs to be the current date minus one day, with the next date in the sequence be the current date, The remaining dates need to incrementally be one day in future out to ... | Try this:
HTML
```
<table id="myTable"></table>
```
JavaScript
```
var table = document.getElementById('myTable')
var myDate = new Date();
myDate.setDate(myDate.getDate() - 1)
for(var i = 0; i < 16; i++)
{
var row = document.createElement('TR');
var cell = document.createElement('TD');
cell.innerT... |
497,024 | <p>I have a directory I’m archiving:</p>
<pre><code>$ du -sh oldcode
1400848
$ tar cf oldcode.tar oldcode
</code></pre>
<p>So the directory is 1.4gb. The file is significantly smaller, though:</p>
<pre><code>$ ls -l oldcode.tar
-rw-r--r-- 1 ieure ieure 940339200 2002-01-30 10:33 oldcode.tar
</code></pre>
<p>Only 897mb.... | [
{
"answer_id": 497058,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>du counts disk blocks, not file size duder.</p>\n"
},
{
"answer_id": 497060,
"author": "Nils Pipenbrinck",
... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497024",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45224/"
] | I have a directory I’m archiving:
```
$ du -sh oldcode
1400848
$ tar cf oldcode.tar oldcode
```
So the directory is 1.4gb. The file is significantly smaller, though:
```
$ ls -l oldcode.tar
-rw-r--r-- 1 ieure ieure 940339200 2002-01-30 10:33 oldcode.tar
```
Only 897mb. It’s not compressed in any way:
```
$ file ... | You get a difference because of the way the filesystem works.
In a nutshell your disk is made out of clusters. Each cluster has a fixed size of - let's say - 4 kilobytes. If you store a 1kb file in such a cluster 3kb will be unused. The exact details vary with the kind of file-system that you use, but most file-syste... |
497,025 | <p>I'm looking to make a recursive method iterative.</p>
<p>I have a list of Objects I want to iterate over, and then check their subobjects.</p>
<p>Recursive:</p>
<pre><code>doFunction(Object)
while(iterator.hasNext())
{
//doStuff
doFunction(Object.subObjects);
}
</code></pre>
<p>I want to change it to somet... | [
{
"answer_id": 497068,
"author": "Dan Lew",
"author_id": 60261,
"author_profile": "https://Stackoverflow.com/users/60261",
"pm_score": 1,
"selected": false,
"text": "<p>I think your problem is inherently a problem that needs to be solved via a List. If you think about it, your Set versi... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497025",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60789/"
] | I'm looking to make a recursive method iterative.
I have a list of Objects I want to iterate over, and then check their subobjects.
Recursive:
```
doFunction(Object)
while(iterator.hasNext())
{
//doStuff
doFunction(Object.subObjects);
}
```
I want to change it to something like this
```
doFunction(Object)
i... | I would use two data structures --- a **queue** (e.g. [`ArrayDeque`](http://java.sun.com/javase/6/docs/api/java/util/ArrayDeque.html)) for storing objects whose subobjects are to be visited, and a **set** (e.g. [`HashSet`](http://java.sun.com/javase/6/docs/api/java/util/HashSet.html)) for storing all visited objects wi... |
497,030 | <p><a href="http://www.codeplex.com/IIRF/Thread/List.aspx" rel="nofollow noreferrer">http://www.codeplex.com/IIRF/Thread/List.aspx</a></p>
<p>My webhost installed IIRF for me and I am convinced that they did not do it correctly. I've tried numerous examples including one that I know works with apache's mod_rewrite but... | [
{
"answer_id": 497874,
"author": "Sean Bright",
"author_id": 21926,
"author_profile": "https://Stackoverflow.com/users/21926",
"pm_score": 3,
"selected": true,
"text": "<p>This is tested and working with IIRF:</p>\n\n<pre><code>RedirectRule ^.*$ http://www.google.com/ [I,R=301]\n</code><... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497030",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/438/"
] | <http://www.codeplex.com/IIRF/Thread/List.aspx>
My webhost installed IIRF for me and I am convinced that they did not do it correctly. I've tried numerous examples including one that I know works with apache's mod\_rewrite but I can't get anything to work with IIRF. Is there rule or configuration option that you guys ... | This is tested and working with IIRF:
```
RedirectRule ^.*$ http://www.google.com/ [I,R=301]
```
It will match **any** URL and redirect to Google. |
497,038 | <p>I have to write an ASP.NET application that connects to our legacy IBM Universe Database and we are using a product called mv.net which allows us to connect, read, write, select, run server side programs, etc. </p>
<p>I want as little code repetition as possible but I also want as little data transfer as possible ... | [
{
"answer_id": 497074,
"author": "airportyh",
"author_id": 5304,
"author_profile": "https://Stackoverflow.com/users/5304",
"pm_score": 1,
"selected": false,
"text": "<p>I would use closures, I think for C# you have Delegates. So something like:</p>\n\n<pre>\nMyAccount.loginAndDo(serverna... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497038",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9938/"
] | I have to write an ASP.NET application that connects to our legacy IBM Universe Database and we are using a product called mv.net which allows us to connect, read, write, select, run server side programs, etc.
I want as little code repetition as possible but I also want as little data transfer as possible as well.
... | I would use closures, I think for C# you have Delegates. So something like:
```
MyAccount.loginAndDo(servername, login, delegate(account){
invoice = account.read("INVOICE");
.
.
.
});
```
In loginAndDo, you would login, call the delegate, and then close the account. |
497,049 | <p>I want to implement an atomic transaction like the following:</p>
<pre><code>BEGIN TRAN A
SELECT id
FROM Inventory
WITH (???)
WHERE material_id = 25 AND quantity > 10
/*
Process some things using the inventory record and
eventually write some updates that are dependent on the fact that
that specific inventory ... | [
{
"answer_id": 497059,
"author": "ILKirk",
"author_id": 59606,
"author_profile": "https://Stackoverflow.com/users/59606",
"pm_score": 0,
"selected": false,
"text": "<p>I believe this would be UPDLOCK.</p>\n\n<p><a href=\"http://www.devx.com/tips/Tip/13134\" rel=\"nofollow noreferrer\">ht... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497049",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8784/"
] | I want to implement an atomic transaction like the following:
```
BEGIN TRAN A
SELECT id
FROM Inventory
WITH (???)
WHERE material_id = 25 AND quantity > 10
/*
Process some things using the inventory record and
eventually write some updates that are dependent on the fact that
that specific inventory record had suffic... | You may actually be better off setting the transaction isolation level rather than using a query hint.
The following reference from Books Online provides details of each of the different Isolation levels.
<http://msdn.microsoft.com/en-us/library/ms173763.aspx>
Here is good article that explains the various types of ... |
497,081 | <p>Is there a difference between concatenating strings with '' and ""?</p>
<p>For example, what is the difference between:</p>
<pre><code>String s = "hello" + "/" + "world";
</code></pre>
<p>and</p>
<pre><code>String s = "hello" + '/' + "world";
</code></pre>
| [
{
"answer_id": 497095,
"author": "Otávio Décio",
"author_id": 48684,
"author_profile": "https://Stackoverflow.com/users/48684",
"pm_score": 3,
"selected": false,
"text": "<p><code>"."</code> is a String, <code>'.'</code> is a char.</p>\n"
},
{
"answer_id": 497102,
"... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497081",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34768/"
] | Is there a difference between concatenating strings with '' and ""?
For example, what is the difference between:
```
String s = "hello" + "/" + "world";
```
and
```
String s = "hello" + '/' + "world";
``` | Literals enclosed in double quotes, e.g. `"foo"`, are **strings**, whereas single-quoted literals, e.g. `'c'`, are **chars**. In terms of concatenation behaviour, there'll be no discernible difference.
Nevertheless, it's worth remembering that strings and chars aren't interchangeable in all scenarios, and you can't ha... |
497,101 | <p>I was using .Net Reflector on an Internal App to try and understand what the previous Dev was doing and also to learn. I have never had <em>actual</em> instruction on how to develop Apps so I take from where I can (Hooray Stack Overflow). That being said I found something that has me confused. A class Library cal... | [
{
"answer_id": 497110,
"author": "Bramha Ghosh",
"author_id": 3268,
"author_profile": "https://Stackoverflow.com/users/3268",
"pm_score": 0,
"selected": false,
"text": "<p>The only explanation I can think of is as some sort of message library - but that doesn't hold for 90% of the entrie... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497101",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46724/"
] | I was using .Net Reflector on an Internal App to try and understand what the previous Dev was doing and also to learn. I have never had *actual* instruction on how to develop Apps so I take from where I can (Hooray Stack Overflow). That being said I found something that has me confused. A class Library called WinConsta... | Back in the days of coding windows applications in c, there were similar files #included in windows which consisted of **long** lists of #defines creating constants. Various c applications emulated this approach in their own files. The "class" seems to be a "transliteration" of this "c-ism". The fundamental principle o... |
497,109 | <p>I'm creating an AIR application which connects to a SQLite database. The database balks at this insert statement, and I simply cannot figure out why. There is no error, it simply does not move on.</p>
<pre><code>INSERT INTO Attendee (AttendeeId,ShowCode,LastName,FirstName,Company,Address,Address2,City,State,ZipCod... | [
{
"answer_id": 497120,
"author": "Grant",
"author_id": 30,
"author_profile": "https://Stackoverflow.com/users/30",
"pm_score": 2,
"selected": true,
"text": "<pre><code>insert into Attendee (\"AttendeeId\", \"ShowCode\", \"LastName\", \"FirstName\", \"Company\", \"Address\", \"Address2\",... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497109",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54331/"
] | I'm creating an AIR application which connects to a SQLite database. The database balks at this insert statement, and I simply cannot figure out why. There is no error, it simply does not move on.
```
INSERT INTO Attendee (AttendeeId,ShowCode,LastName,FirstName,Company,Address,Address2,City,State,ZipCode,Country,Phone... | ```
insert into Attendee ("AttendeeId", "ShowCode", "LastName", "FirstName", "Company", "Address", "Address2", "City", "State", "ZipCode", "Country", "Phone", "Fax", "Email", "BuyNum", "PrimaryBusiness", "Business", "Employees", "Job", "Value", "Volume", "SpouseBusiness", "DateAdded", "ConstructionWorkType", "UserPurch... |
497,114 | <p>In Perl, I can replicate strings with the 'x' operator:</p>
<pre><code>$str = "x" x 5;
</code></pre>
<p>Can I do something similar in Python?</p>
| [
{
"answer_id": 497119,
"author": "Dustin",
"author_id": 39975,
"author_profile": "https://Stackoverflow.com/users/39975",
"pm_score": 6,
"selected": true,
"text": "<pre><code>>>> \"blah\" * 5\n'blahblahblahblahblah'\n</code></pre>\n"
},
{
"answer_id": 30409778,
"auth... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497114",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42974/"
] | In Perl, I can replicate strings with the 'x' operator:
```
$str = "x" x 5;
```
Can I do something similar in Python? | ```
>>> "blah" * 5
'blahblahblahblahblah'
``` |
497,116 | <p>I'd like to populate the homepage of my user-submitted-illustrations site with the "hottest" illustrations uploaded.</p>
<p>Here are the measures I have available:</p>
<ul>
<li>How many people have favourited that illustration
<ul>
<li><code>votes</code> table includes date voted</li>
</ul></li>
<li>When the ill... | [
{
"answer_id": 497131,
"author": "Rob",
"author_id": 3542,
"author_profile": "https://Stackoverflow.com/users/3542",
"pm_score": 0,
"selected": false,
"text": "<p>I've no useful ideas as far as the actual agorithm is concerned, but in terms of implementation, I'd suggest caching the resu... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497116",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31399/"
] | I'd like to populate the homepage of my user-submitted-illustrations site with the "hottest" illustrations uploaded.
Here are the measures I have available:
* How many people have favourited that illustration
+ `votes` table includes date voted
* When the illustration was uploaded
+ `illustration` table has date cr... | Many sites that use some type of popularity ranking do so by using a standard algorithm to determine a score and then decaying eternally over time. What I've found works better for sites with less traffic is a multiplier that gives a bonus to new content/activity - it's essentially the same, but the score stops changin... |
497,118 | <p>I know Visual Studio offers some Unit Testing goodies. How do I use them, how do you use them? What should I know about unit testing (assume I know nothing).</p>
<p><a href="https://stackoverflow.com/questions/16860/getting-started-with-unit-testing">This question</a> is similar but it does not address what Visual ... | [
{
"answer_id": 497184,
"author": "Eric",
"author_id": 42461,
"author_profile": "https://Stackoverflow.com/users/42461",
"pm_score": 2,
"selected": false,
"text": "<p>The unit testing structure in VS is similar to NUnit in it's usage. One interesting (and useful) feature of it does diffe... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497118",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12243/"
] | I know Visual Studio offers some Unit Testing goodies. How do I use them, how do you use them? What should I know about unit testing (assume I know nothing).
[This question](https://stackoverflow.com/questions/16860/getting-started-with-unit-testing) is similar but it does not address what Visual Studio can do, please... | Easily the most significant difference is that the MSTest support is built in to Visual Studio and provides unit testing, code coverage and mocking support directly. In order to do the same types of things in the external (third-party) unit test frameworks generally requires multiple frameworks (a unit testing framewor... |
497,121 | <p>I have a combo box in Silverlight. It has a collection of values built out of the properties of one of my LINQ-to-SQL objects (ie Name, Address, Age, etc...). I would like to filter my results based off the value selected in a combo box. </p>
<p>Example: Say I want everyone with a last name "Smith". I'd select 'L... | [
{
"answer_id": 497224,
"author": "Kev",
"author_id": 419,
"author_profile": "https://Stackoverflow.com/users/419",
"pm_score": 1,
"selected": false,
"text": "<p>Scott Guthrie has a short series on dyamically built LINQ to SQL queries:</p>\n\n<p><a href=\"http://weblogs.asp.net/scottgu/ar... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497121",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13367/"
] | I have a combo box in Silverlight. It has a collection of values built out of the properties of one of my LINQ-to-SQL objects (ie Name, Address, Age, etc...). I would like to filter my results based off the value selected in a combo box.
Example: Say I want everyone with a last name "Smith". I'd select 'Last Name' fr... | Assuming:
```
public class Person
{
public string LastName { get; set; }
}
IQueryable<Person> collection;
```
your query:
```
var query =
from p in collection
where p.LastName == textBox.Text
select p;
```
means the same as:
```
var query = collection.Where(p => p.LastName == textBox.Text);
```... |
497,128 | <p>I'm attempting to load a dll into MSSQL with:</p>
<pre><code>USE dbname
GO
CREATE ASSEMBLY foo
FROM 'C:\foo\foo.dll'
WITH PERMISSION_SET = UNSAFE
GO
</code></pre>
<p>And I'm getting an error that states:</p>
<pre>
Msg 33009, Level 16, State 2, Line 2
The database owner SID recorded in the master database differ... | [
{
"answer_id": 514481,
"author": "Chris KL",
"author_id": 58110,
"author_profile": "https://Stackoverflow.com/users/58110",
"pm_score": 3,
"selected": true,
"text": "<p>I have had exactly the same problem and only solution for me was to change the owner, then change it back again.</p>\n\... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497128",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8607/"
] | I'm attempting to load a dll into MSSQL with:
```
USE dbname
GO
CREATE ASSEMBLY foo
FROM 'C:\foo\foo.dll'
WITH PERMISSION_SET = UNSAFE
GO
```
And I'm getting an error that states:
```
Msg 33009, Level 16, State 2, Line 2
The database owner SID recorded in the master database differs from the database owner
SID ... | I have had exactly the same problem and only solution for me was to change the owner, then change it back again.
The problem is that users are both per-database and per-server. What's happened is that the per-database user has a username that is the same as a per-server user, however they SIDs don't match, so it think... |
497,133 | <p>I have this C++ code:</p>
<pre><code>extern "C" __declspec(dllexport) VOID AllocateFoo(MY_DATA_STRUCTURE** foo)
{
*foo = new MY_DATA_STRUCTURE;
//do stuff to foo
}
</code></pre>
<p>Then in C# I call the function thus:</p>
<pre><code>[DllImport("MyDll.dll")]
static extern void AllocateFoo(out IntPtr pMyDa... | [
{
"answer_id": 497203,
"author": "Erik Forbes",
"author_id": 16942,
"author_profile": "https://Stackoverflow.com/users/16942",
"pm_score": 3,
"selected": false,
"text": "<p>Yes, in this case, Marshall means copy; thus, you need to deallocate your memory in unmanaged code. All the call to... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497133",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47693/"
] | I have this C++ code:
```
extern "C" __declspec(dllexport) VOID AllocateFoo(MY_DATA_STRUCTURE** foo)
{
*foo = new MY_DATA_STRUCTURE;
//do stuff to foo
}
```
Then in C# I call the function thus:
```
[DllImport("MyDll.dll")]
static extern void AllocateFoo(out IntPtr pMyDataStruct);
...
MyDataStructure GetM... | As Erik said, the Marshal does mean copy, but I don't think he answered the main point of your question.
Do you need to hold onto the pData native pointer until the MyDataStructure is GCed? No.
Once marshaled, your MyDataStructure instance, foo, contains a copy of the structure pointed to by pData. You need not hold ... |
497,139 | <p>I'm sure that almost everyone programming in .net has ran into similar issues with the dynamic creation of buttons.. </p>
<p>Example scenario.. </p>
<p>I have a gridview and in one of the gridview fields I have a button. Normally in .net using visual studio you can easily grab the click event of the button, howeve... | [
{
"answer_id": 497160,
"author": "Tom Ritter",
"author_id": 8435,
"author_profile": "https://Stackoverflow.com/users/8435",
"pm_score": 2,
"selected": false,
"text": "<p>In the gridview, there is an event called <a href=\"http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497139",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60629/"
] | I'm sure that almost everyone programming in .net has ran into similar issues with the dynamic creation of buttons..
Example scenario..
I have a gridview and in one of the gridview fields I have a button. Normally in .net using visual studio you can easily grab the click event of the button, however since these but... | Sadly, the answer was much simpler than I ever thought..
I didn't realize that the ItemCommand event was usable for buttons created in a TemplateField.
All I really had to do was..
```
Private Sub GridView1_ItemCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewCommandEventArgs) Handle... |
497,156 | <p>I'm modifying existing security code. The specifications are pretty clear, there is example code, but I'm no cryptographic expert. In fact, the example code has a disclaimer saying, in effect, "Don't use this code verbatim."</p>
<p>While auditing the code I'm to modify (which is supposedly feature complete) I ran... | [
{
"answer_id": 497199,
"author": "Darron",
"author_id": 22704,
"author_profile": "https://Stackoverflow.com/users/22704",
"pm_score": 3,
"selected": false,
"text": "<p>Your question shows one of the more common ones: poor sources of randomness. It doesn't matter if you use a 256 bit key... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497156",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2915/"
] | I'm modifying existing security code. The specifications are pretty clear, there is example code, but I'm no cryptographic expert. In fact, the example code has a disclaimer saying, in effect, "Don't use this code verbatim."
While auditing the code I'm to modify (which is supposedly feature complete) I ran across this... | [Applied Cryptography](http://www.schneier.com/book-applied.html) is an excellent book to help you understand crypto and code. It goes over a lot of fundamentals, like how block ciphers work, and why choosing a poor cipher mode will make your code useless even if you're using a perfectly implemented version of AES.
So... |
497,163 | <p>I'm trying a little concept test to change one of the features of the logitech MS3200 keyboard (the zoom feature). I've got the keys that are sent from the zoom control. So, I have a main app, and a dll that contains a hook procedure. </p>
<p>Here's the main app:</p>
<pre><code>#include <stdio.h>
#include &l... | [
{
"answer_id": 497172,
"author": "Graeme Perrow",
"author_id": 1821,
"author_profile": "https://Stackoverflow.com/users/1821",
"pm_score": 0,
"selected": false,
"text": "<p>Code in a DLL can't directly access variables in the calling app, because there's no guarantee that the app that lo... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497163",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53007/"
] | I'm trying a little concept test to change one of the features of the logitech MS3200 keyboard (the zoom feature). I've got the keys that are sent from the zoom control. So, I have a main app, and a dll that contains a hook procedure.
Here's the main app:
```
#include <stdio.h>
#include <windows.h>
HANDLE hHook;
i... | It's probably possible, but it's not worth your time to investigate.
Instead, move the hook setting code to the DLL.
Oh, and I think you need to pass the DLL module handle to the hook setting function, not a NULL |
497,176 | <p>I'm trying to implement a simple class like this:</p>
<pre><code>public static void main(String args[])
{
try
{
myClass test = new Thread(new myClass(stuff));
test.start();
test.join();
}
catch (Throwable t) { }
}
</code></pre>
<p>When I try to include a print() method in my... | [
{
"answer_id": 497185,
"author": "Fortyrunner",
"author_id": 16828,
"author_profile": "https://Stackoverflow.com/users/16828",
"pm_score": 1,
"selected": false,
"text": "<p>You can have additional methods.</p>\n\n<p>Your problem seems to be the naming of your variables!!</p>\n"
},
{
... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497176",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm trying to implement a simple class like this:
```
public static void main(String args[])
{
try
{
myClass test = new Thread(new myClass(stuff));
test.start();
test.join();
}
catch (Throwable t) { }
}
```
When I try to include a print() method in myClass and use it, I get a ... | You can implement whatever methods you want. However, you need to make sure the reference uses your class name, and not Runnable:
```
public class MyRunner implements Runnable
{
@Override public void run();
public void somethingElse();
}
Runnable r = new MyRunner();
r.somethingElse(); // won't work, this meth... |
497,192 | <p>I've been trying to build some huge projects in BCB5 for some time now. I want to use the command line tools because it would cut build time by more than 50% (it already takes 4 hours in the IDE). Often, projects will build just fine in the IDE but fail miserably in the command line. I did some digging and discov... | [
{
"answer_id": 499375,
"author": "stukelly",
"author_id": 5891,
"author_profile": "https://Stackoverflow.com/users/5891",
"pm_score": 0,
"selected": false,
"text": "<p>Have you tried installing the <a href=\"http://andy.jgknet.de/blog/?page_id=12\" rel=\"nofollow noreferrer\">C++ Compile... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497192",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54790/"
] | I've been trying to build some huge projects in BCB5 for some time now. I want to use the command line tools because it would cut build time by more than 50% (it already takes 4 hours in the IDE). Often, projects will build just fine in the IDE but fail miserably in the command line. I did some digging and discovered t... | I've more or less given up on the BCB5 command line tools. It appears that they are fundamentally broken.
I did, however, manage to find a nice open source tool, ProjectMaker, that uses the command line tools effectively. You can find it here: [http://projectmaker.jomitech.com](http://projectmaker.jomitech.com/).
Pro... |
497,194 | <p>Hi basicly I am trying to create a simple IF statement that shows a default picture if one hasn't been entered in to my database. I am using server to store my picture and a database to store the file name, so I can get the image to display if it has a file name in the db but I want the If statement to say if the re... | [
{
"answer_id": 497213,
"author": "Christian C. Salvadó",
"author_id": 5445,
"author_profile": "https://Stackoverflow.com/users/5445",
"pm_score": 2,
"selected": false,
"text": "<p>What about a simple <a href=\"http://php.net/language.operators.comparison\" rel=\"nofollow noreferrer\">ter... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497194",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60163/"
] | Hi basicly I am trying to create a simple IF statement that shows a default picture if one hasn't been entered in to my database. I am using server to store my picture and a database to store the file name, so I can get the image to display if it has a file name in the db but I want the If statement to say if the recor... | What about a simple [ternary](http://php.net/language.operators.comparison):
```
$photo = ($info['photo'] == null) ? "default.jpg" : $info['photo'];
echo "<img class=\"memberImage\" src=images/". $photo .">";
``` |
497,210 | <p><strong>Important: This question isn't actually really an ASP.NET question.</strong> Anyone who knows anything about URLS can answer it. I just happen to be using ASP.NET routing so included that detail.</p>
<p>In a nutshell my question is : </p>
<p>"What URL format should I design that i can give to external part... | [
{
"answer_id": 499082,
"author": "David Brown",
"author_id": 31516,
"author_profile": "https://Stackoverflow.com/users/31516",
"pm_score": 1,
"selected": false,
"text": "<p>It looks like you've covered all of your bases. The only suggestion I have is to change</p>\n\n<pre><code>{custom}\... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497210",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16940/"
] | **Important: This question isn't actually really an ASP.NET question.** Anyone who knows anything about URLS can answer it. I just happen to be using ASP.NET routing so included that detail.
In a nutshell my question is :
"What URL format should I design that i can give to external parties to get to a specific place... | This URL:
```
"campaign/{destination}/{partnerid}/{campaignid}/{custom}",
```
...doesn't look like a resource to me, it looks like a remote method call. There is a lot of business logic here which is likely to change in the future. Also, it's complicated. My gut instinct when designing URLs is that simpler is genera... |
497,220 | <p>Any idea where the setting is hiding for turning gridlines off while using excel 2003 from interop? </p>
| [
{
"answer_id": 497299,
"author": "Jon Fournier",
"author_id": 5106,
"author_profile": "https://Stackoverflow.com/users/5106",
"pm_score": 5,
"selected": true,
"text": "<p>DisplayGridlines is a method on an Excel Window object. \nFor example:</p>\n\n<pre><code>ActiveWindow.DisplayGridline... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497220",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/361/"
] | Any idea where the setting is hiding for turning gridlines off while using excel 2003 from interop? | DisplayGridlines is a method on an Excel Window object.
For example:
```
ActiveWindow.DisplayGridlines = true
``` |
497,233 | <p>I'm writing a script that has to move some file around, but unfortunately it doesn't seem <code>os.path</code> plays with internationalization very well. When I have files named in Hebrew, there are problems. Here's a screenshot of the contents of a directory:</p>
<p><a href="https://i.stack.imgur.com/ypP2Z.png" re... | [
{
"answer_id": 497309,
"author": "Kiv",
"author_id": 49559,
"author_profile": "https://Stackoverflow.com/users/49559",
"pm_score": 2,
"selected": false,
"text": "<p>It looks like a Unicode vs ASCII issue - <code>os.listdir</code> is returning a list of ASCII strings. </p>\n\n<p>Edit: I t... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497233",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8206/"
] | I'm writing a script that has to move some file around, but unfortunately it doesn't seem `os.path` plays with internationalization very well. When I have files named in Hebrew, there are problems. Here's a screenshot of the contents of a directory:
[](https://i.stack.im... | Hmm, after [some digging](http://www.amk.ca/python/howto/unicode) it appears that when supplying os.listdir a unicode string, this kinda works:
```
files = os.listdir(u'test_source')
for f in files:
pf = os.path.join(u'test_source', f)
print pf.encode('ascii', 'replace'), os.path.exists(pf)
```
===>
```
t... |
497,241 | <p>I'm trying to perform a <em>group by</em> action on an aliased column (example below) but can't determine the proper syntax.</p>
<pre><code>SELECT LastName + ', ' + FirstName AS 'FullName'
FROM customers
GROUP BY 'FullName'
</code></pre>
<p>What is the correct syntax?</p>
<p>Extending the question ... | [
{
"answer_id": 497251,
"author": "cmsjr",
"author_id": 23114,
"author_profile": "https://Stackoverflow.com/users/23114",
"pm_score": 8,
"selected": true,
"text": "<p>You pass the expression you want to group by rather than the alias </p>\n\n<pre><code>SELECT LastName + ', ' + First... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497241",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33226/"
] | I'm trying to perform a *group by* action on an aliased column (example below) but can't determine the proper syntax.
```
SELECT LastName + ', ' + FirstName AS 'FullName'
FROM customers
GROUP BY 'FullName'
```
What is the correct syntax?
Extending the question further (I had not expected the answe... | You pass the expression you want to group by rather than the alias
```
SELECT LastName + ', ' + FirstName AS 'FullName'
FROM customers
GROUP BY LastName + ', ' + FirstName
``` |
497,243 | <p>How do you traverse a directory tree in your favorite language?</p>
<p>What do you need to know to traverse a directory tree in different operating systems? On different filesystems?</p>
<p>What's your favorite library/module for aiding in traversing a directory tree?</p>
| [
{
"answer_id": 497301,
"author": "Sean Bright",
"author_id": 21926,
"author_profile": "https://Stackoverflow.com/users/21926",
"pm_score": 2,
"selected": false,
"text": "<p>In <strong>C#</strong>:</p>\n\n<pre><code>Stack<DirectoryInfo> dirs = new Stack<DirectoryInfo>();\n\ndi... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497243",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18103/"
] | How do you traverse a directory tree in your favorite language?
What do you need to know to traverse a directory tree in different operating systems? On different filesystems?
What's your favorite library/module for aiding in traversing a directory tree? | In **Java**:
Recursion is useful here. Following is a Java code snippet that's been all over the Internet for ages. Not sure who deserves the credit for it.
```
// Process all files and directories under dir
public static void visitAllDirsAndFiles(File dir) {
process(dir); //do something useful with th... |
497,261 | <p>I often want to grab the first element of an <code>IEnumerable<T></code> in .net, and I haven't found a nice way to do it. The best I've come up with is:</p>
<pre><code>foreach(Elem e in enumerable) {
// do something with e
break;
}
</code></pre>
<p>Yuck! So, is there a nice way to do this?</p>
| [
{
"answer_id": 497275,
"author": "Erik Forbes",
"author_id": 16942,
"author_profile": "https://Stackoverflow.com/users/16942",
"pm_score": 9,
"selected": true,
"text": "<p>If you can use LINQ you can use:</p>\n\n<pre><code>var e = enumerable.First();\n</code></pre>\n\n<p>This will throw ... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497261",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2348/"
] | I often want to grab the first element of an `IEnumerable<T>` in .net, and I haven't found a nice way to do it. The best I've come up with is:
```
foreach(Elem e in enumerable) {
// do something with e
break;
}
```
Yuck! So, is there a nice way to do this? | If you can use LINQ you can use:
```
var e = enumerable.First();
```
This will throw an exception though if enumerable is empty: in which case you can use:
```
var e = enumerable.FirstOrDefault();
```
`FirstOrDefault()` will return `default(T)` if the enumerable is empty, which will be `null` for reference types ... |
497,294 | <p>When I enter <em>9:00</em> into the Start control, and <em>16:00</em> into Finish; the code below fails validation.</p>
<p>Does anybody know a way I can use the ASP.NET validator for times without the dates?</p>
<pre><code>Start <asp:TextBox ID="txtStart" runat="server" /> (hh:mm)
<br />
Finish <asp... | [
{
"answer_id": 497340,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>try to change the Type property to String, it should work.</p>\n"
},
{
"answer_id": 497342,
"author": "Tom",
... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497294",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29043/"
] | When I enter *9:00* into the Start control, and *16:00* into Finish; the code below fails validation.
Does anybody know a way I can use the ASP.NET validator for times without the dates?
```
Start <asp:TextBox ID="txtStart" runat="server" /> (hh:mm)
<br />
Finish <asp:TextBox ID="txtFinish" runat="server" /> (hh:mm)
... | This appearently cannot be done.
For the record; I used a custom validator.
EDIT: Here's my custom validator code in case anyone (i.e. alhambraeidos) needs it. Please note, this code replaces my sample control names (txtStart & txtFinish) with actual names from my app (txtReady & txtClose).
```
try
{
// parse &... |
497,311 | <p>I have a program that generates text fiels that can be up to 20 mets in size. Sometimes I only care about the last line in the file, is there a way to read just that line with out wasting memory reading the rest of the file?</p>
| [
{
"answer_id": 497750,
"author": "Ignacio",
"author_id": 44740,
"author_profile": "https://Stackoverflow.com/users/44740",
"pm_score": 3,
"selected": true,
"text": "<p>I could be mistaken but without resorting to some trickery, it seems that you can't.\nHowever, if you have a rough estim... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497311",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14744/"
] | I have a program that generates text fiels that can be up to 20 mets in size. Sometimes I only care about the last line in the file, is there a way to read just that line with out wasting memory reading the rest of the file? | I could be mistaken but without resorting to some trickery, it seems that you can't.
However, if you have a rough estimate of the length of the lines, you can open a file and then seek from the end, say, 1Kb.
```
local f = io.open([[c:\test_file.txt]], "r")
local len = f:seek("end")
f:seek("set", len - 1024)
local te... |
497,314 | <p>Right now, I am in prototyping phase. So I am just getting started.</p>
<p>Situation:
Server - Will be run tests and publish progress to Client, must be low impact, no webserver, possibly running xp embedded or xp home.</p>
<p>Client - Initiate tests and receive progress report. running xp pro.</p>
<p>The two ... | [
{
"answer_id": 497392,
"author": "StingyJack",
"author_id": 16391,
"author_profile": "https://Stackoverflow.com/users/16391",
"pm_score": 0,
"selected": false,
"text": "<p>By the Server connecting to the client, you are actually inverting the model and causing the server to become the cl... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497314",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Right now, I am in prototyping phase. So I am just getting started.
Situation:
Server - Will be run tests and publish progress to Client, must be low impact, no webserver, possibly running xp embedded or xp home.
Client - Initiate tests and receive progress report. running xp pro.
The two machines are connected via... | I once deployed a system wich used remoting, and where the server launched some events to which the client could subscribe to.
In order to make it possible, you have to set the typeFilterLevel to full, and, you also have to create an 'intermediate' object that is known on the client and on the server in order to be ab... |
497,317 | <p>I am using SQL Server 2005, I want to find out what all the grants are on a specific database for all tables. It would also help to find out all tables where the delete grant has been given for a specific user.</p>
<p>Note: this may be similar to <a href="https://stackoverflow.com/questions/212681/how-do-i-generate... | [
{
"answer_id": 497362,
"author": "Adam",
"author_id": 59117,
"author_profile": "https://Stackoverflow.com/users/59117",
"pm_score": 3,
"selected": false,
"text": "<p>To view all grants on a specific database use this:</p>\n\n<pre><code>Select * from INFORMATION_SCHEMA.TABLE_PRIVILEGES\n<... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497317",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43472/"
] | I am using SQL Server 2005, I want to find out what all the grants are on a specific database for all tables. It would also help to find out all tables where the delete grant has been given for a specific user.
Note: this may be similar to [this question](https://stackoverflow.com/questions/212681/how-do-i-generate-a-... | The given solution does not cover where the permission is granted against the schema or the database itself, which do grant permissions against the tables as well. This will give you those situations, too. You can use a WHERE clause against permission\_name to restrict to just DELETE.
```
SELECT
class_desc
, C... |
497,320 | <p>I'm building a PHP application using the data mapper pattern to separate my DB from the domain objects. I have a mapper class that returns Site objects based on data from the DB and accepts existing Site objects to be saved back to the DB.</p>
<p>My problem is that in the system one (and only one) of all the sites ... | [
{
"answer_id": 497362,
"author": "Adam",
"author_id": 59117,
"author_profile": "https://Stackoverflow.com/users/59117",
"pm_score": 3,
"selected": false,
"text": "<p>To view all grants on a specific database use this:</p>\n\n<pre><code>Select * from INFORMATION_SCHEMA.TABLE_PRIVILEGES\n<... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497320",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39428/"
] | I'm building a PHP application using the data mapper pattern to separate my DB from the domain objects. I have a mapper class that returns Site objects based on data from the DB and accepts existing Site objects to be saved back to the DB.
My problem is that in the system one (and only one) of all the sites has to be ... | The given solution does not cover where the permission is granted against the schema or the database itself, which do grant permissions against the tables as well. This will give you those situations, too. You can use a WHERE clause against permission\_name to restrict to just DELETE.
```
SELECT
class_desc
, C... |
497,331 | <p>My PHPEd suddenly stopped showing arguments and arg order in the hints, and now just shows a basic description of the function.</p>
<p>Before I go digging around in the config files, has anyone else had this problem?</p>
<p>Thanks!</p>
<p><strong>Edit:</strong></p>
<p>Sorry, I may not have been entirely clear on... | [
{
"answer_id": 497362,
"author": "Adam",
"author_id": 59117,
"author_profile": "https://Stackoverflow.com/users/59117",
"pm_score": 3,
"selected": false,
"text": "<p>To view all grants on a specific database use this:</p>\n\n<pre><code>Select * from INFORMATION_SCHEMA.TABLE_PRIVILEGES\n<... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497331",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27580/"
] | My PHPEd suddenly stopped showing arguments and arg order in the hints, and now just shows a basic description of the function.
Before I go digging around in the config files, has anyone else had this problem?
Thanks!
**Edit:**
Sorry, I may not have been entirely clear on this. There is no problem with my own class... | The given solution does not cover where the permission is granted against the schema or the database itself, which do grant permissions against the tables as well. This will give you those situations, too. You can use a WHERE clause against permission\_name to restrict to just DELETE.
```
SELECT
class_desc
, C... |
497,343 | <p>In Java, I'm trying to log into an FTP server and find all the files newer than x for retrieval. </p>
<p>Currently I have an input stream that's reading in the directory contents and printing them out, line by line, which is all well and good, but the output is fairly vague... it looks like this...</p>
<pre><code>... | [
{
"answer_id": 497373,
"author": "Mark Davidson",
"author_id": 50866,
"author_profile": "https://Stackoverflow.com/users/50866",
"pm_score": 3,
"selected": true,
"text": "<p>Maybe worth having a look at the <a href=\"http://commons.apache.org/net/\" rel=\"nofollow noreferrer\">Jakarta Co... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497343",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/59947/"
] | In Java, I'm trying to log into an FTP server and find all the files newer than x for retrieval.
Currently I have an input stream that's reading in the directory contents and printing them out, line by line, which is all well and good, but the output is fairly vague... it looks like this...
```
-rw------- 1 vuse... | Maybe worth having a look at the [Jakarta Commons Net](http://commons.apache.org/net/) API which has FTP functionality.
I think with it you can use [list files](http://commons.apache.org/net/api/org/apache/commons/net/ftp/FTPClient.html#listFiles()) which will give you file objects that you can do [getTimeStamp](http:... |
497,347 | <p>So I have a ResourceManager that points to a resource file with a bunch of strings in it. When I call <code>GetString()</code> with a key that doesn't exist in the file, I get a <code>System.Resources.MissingManifestResourceException</code>. I need to find out whether the Resource contains the specified key without ... | [
{
"answer_id": 497520,
"author": "Brian",
"author_id": 2831,
"author_profile": "https://Stackoverflow.com/users/2831",
"pm_score": 0,
"selected": false,
"text": "<p>Not sure what the problem was, but I got frustrated and deleted/recreated the resx files and this worked.</p>\n"
},
{
... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497347",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2831/"
] | So I have a ResourceManager that points to a resource file with a bunch of strings in it. When I call `GetString()` with a key that doesn't exist in the file, I get a `System.Resources.MissingManifestResourceException`. I need to find out whether the Resource contains the specified key without using exception handling ... | Note that by default, it appears that a new .net project's Resources.resx is going to be in the Properties folder, so you'll need to create the ResourceManager like this:
```
rm = new ResourceManager("MyNamespace.Properties.MyResource", assembly);
```
Alternatively, by getting frustrated and deleting/recreating Reso... |
497,353 | <p>What I'm trying to do is create a PowerShell script which gets a list of folders in a directory which is filtered by a regular expression screening out folder names with nnnnnnx31 or nnnnnnddd where n = alpha chars for the first 6 characters and the last 3 is either numbers of the static string x31. Next it screens... | [
{
"answer_id": 497396,
"author": "Scott Weinstein",
"author_id": 25201,
"author_profile": "https://Stackoverflow.com/users/25201",
"pm_score": 4,
"selected": true,
"text": "<p>you need to do <code>(get-date).AddDays(-90)</code></p>\n"
},
{
"answer_id": 497397,
"author": "audi... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497353",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18853/"
] | What I'm trying to do is create a PowerShell script which gets a list of folders in a directory which is filtered by a regular expression screening out folder names with nnnnnnx31 or nnnnnnddd where n = alpha chars for the first 6 characters and the last 3 is either numbers of the static string x31. Next it screens if ... | you need to do `(get-date).AddDays(-90)` |
497,359 | <p>I'm creating a new Flex component (Flex 3). I'd like it to have a default style. Is there a naming convention or something for my .cs file to make it the default style? Am I missing something?</p>
| [
{
"answer_id": 497695,
"author": "Christian Nunciato",
"author_id": 32129,
"author_profile": "https://Stackoverflow.com/users/32129",
"pm_score": 4,
"selected": true,
"text": "<p>Two ways, generally. One's just by referencing the class name directly -- so for example, if you'd created a... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497359",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39827/"
] | I'm creating a new Flex component (Flex 3). I'd like it to have a default style. Is there a naming convention or something for my .cs file to make it the default style? Am I missing something? | Two ways, generally. One's just by referencing the class name directly -- so for example, if you'd created a new component class `MyComponent` in ActionScript, or indirectly by making an MXML component extending another UIComponent called `MyComponent`, in both cases, the component would pick up the styles declared in ... |
497,389 | <p>The situation is as follows:</p>
<p>I have a database with many RSS Categories, that in turn have many RSS Feeds. I want to display them in the following fashion:</p>
<pre><code>RSS Category 1
[ ] Rss Feed 1
[ ] Rss Feed 2
[ ] Rss Feed 3
RSS Category 2
[ ] Rss Feed 1
[ ] Rss Feed 2
[ ] Rss Feed 3
</code></p... | [
{
"answer_id": 497430,
"author": "tsilb",
"author_id": 11112,
"author_profile": "https://Stackoverflow.com/users/11112",
"pm_score": 0,
"selected": false,
"text": "<p>If you can't use a CheckBoxList, you'll have to handle the values manually. </p>\n\n<p>You can manually .Controls.Add(ne... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497389",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | The situation is as follows:
I have a database with many RSS Categories, that in turn have many RSS Feeds. I want to display them in the following fashion:
```
RSS Category 1
[ ] Rss Feed 1
[ ] Rss Feed 2
[ ] Rss Feed 3
RSS Category 2
[ ] Rss Feed 1
[ ] Rss Feed 2
[ ] Rss Feed 3
```
Where [ ] represents a ch... | I think you might be looking for something like this:
ASPX:
```
<asp:Repeater ID="rptOuter" runat="server" OnItemDataBound="rptOuter_ItemDataBound">
<HeaderTemplate>
<ul style="list-style-type: none">
</HeaderTemplate>
<ItemTemplate>
<li id='<%# Eval("Id") %>'>
... |
497,390 | <p>I was working for a telecom company some years ago and I had to generate a formula which calculates duration of a call according to the following algorithm:</p>
<ul>
<li>t1 is the first period </li>
<li>t2 is the recurring period</li>
<li>RCT is the actual call time (in seconds)</li>
<li>CD is the effective call d... | [
{
"answer_id": 497458,
"author": "Godeke",
"author_id": 28006,
"author_profile": "https://Stackoverflow.com/users/28006",
"pm_score": 2,
"selected": false,
"text": "<p>EDIT: simplified further, and fixed < vs <= error. </p>\n\n<p>No floating point and worked on every database I hav... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497390",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I was working for a telecom company some years ago and I had to generate a formula which calculates duration of a call according to the following algorithm:
* t1 is the first period
* t2 is the recurring period
* RCT is the actual call time (in seconds)
* CD is the effective call duration (for billing purposes)
if RC... | EDIT: simplified further, and fixed < vs <= error.
No floating point and worked on every database I have access to:
```
create table calls (t1 int, t2 int, rct int, cd int)
insert into calls (t1, t2, rct, cd)
values (60, 10, 48, 60)
insert into calls (t1, t2, rct, cd)
values (60, 10, 65, 70)
insert into calls ... |
497,395 | <p>Does anyone have a process or approach to use for determining how to resove a many-to-many relationship in a relational database? Here is my scenario. I have a group of contacts and a group of phone numbers. Each contact can be associated with multiple phone numbers and each phone number can be associated with mu... | [
{
"answer_id": 497410,
"author": "MarlonRibunal",
"author_id": 10385,
"author_profile": "https://Stackoverflow.com/users/10385",
"pm_score": 1,
"selected": false,
"text": "<ol>\n<li>Normalize</li>\n<li>Best Practices on Referential Integrity</li>\n<li>Check this - <a href=\"http://stati... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497395",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60231/"
] | Does anyone have a process or approach to use for determining how to resove a many-to-many relationship in a relational database? Here is my scenario. I have a group of contacts and a group of phone numbers. Each contact can be associated with multiple phone numbers and each phone number can be associated with multiple... | Employees:
```
eID, eName
1, e1
2, e2
```
PhoneNumbers:
```
pID, pNumber
1, v1
2, v2
```
EmployeePhones:
```
eID, pID
1, 1
1, 2
2, 2
```
then you inner join. if you need to find out what number(s) e1 can be reached at (t-sql):
```
SELECT E.eName, P.pNumber
FROM dbo.Employees E
INNER JOIN dbo.EmployeePhone... |
497,408 | <p>Can anyone explain why this code gives the error:</p>
<pre><code>error C2039: 'RT' : is not a member of 'ConcreteTable'
</code></pre>
<p>(at least when compiled with VS2008 SP1)</p>
<pre><code>class Record
{
};
template <class T>
class Table
{
public:
typedef typename T::RT Zot; // << error occu... | [
{
"answer_id": 497435,
"author": "Raz",
"author_id": 5661,
"author_profile": "https://Stackoverflow.com/users/5661",
"pm_score": 1,
"selected": false,
"text": "<p>you are trying to use class CponcreateTable as a template parameter before the class is fully defined. </p>\n\n<p>The followi... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497408",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3631/"
] | Can anyone explain why this code gives the error:
```
error C2039: 'RT' : is not a member of 'ConcreteTable'
```
(at least when compiled with VS2008 SP1)
```
class Record
{
};
template <class T>
class Table
{
public:
typedef typename T::RT Zot; // << error occurs here
};
class ConcreteTable : public Table<Co... | That's because the class ConcreteTable is not yet instantiated when instantiating Table, so the compiler doesn't see T::RT yet. I'm not really sure how exactly C++ standard handles this kind of recursion (I suspect it's undefined), but it doesn't work how you'd expect (and this is probably good, otherwise things would ... |
497,418 | <p>I've been pondering this for a while but cannot come up with a working solution. I can't even psuedo code it...</p>
<p>Say, for example, you have a page with a heading structure like this:</p>
<pre><code><h1>Heading level 1</h1>
<h2>Sub heading #1</h2>
<h2>Sub heading #2<... | [
{
"answer_id": 497468,
"author": "strager",
"author_id": 39992,
"author_profile": "https://Stackoverflow.com/users/39992",
"pm_score": 3,
"selected": true,
"text": "<p>First, build a tree. Pseudocode (because I'm not fluent in Javascript):</p>\n\n<pre><code>var headings = array(...);\nv... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497418",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21677/"
] | I've been pondering this for a while but cannot come up with a working solution. I can't even psuedo code it...
Say, for example, you have a page with a heading structure like this:
```
<h1>Heading level 1</h1>
<h2>Sub heading #1</h2>
<h2>Sub heading #2</h2>
<h3>Sub Sub heading</h3>
<h2>Sub he... | First, build a tree. Pseudocode (because I'm not fluent in Javascript):
```
var headings = array(...);
var treeLevels = array();
var treeRoots = array();
foreach(headings as heading) {
if(heading.level == treeLevels.length) {
/* Adjacent siblings. */
if(heading.level == 1) {
treeRoots... |
497,420 | <p>I'm seeing something very very strange happening in a Flex app I'm maintaining.</p>
<p>I've been going through it removing all calls to trace() and replacing it with calls into the logging framework (using the built in mx.logging stuff). After doing so some XML parsing code suddenly broke, and I can't for the life... | [
{
"answer_id": 498611,
"author": "David Hanak",
"author_id": 42136,
"author_profile": "https://Stackoverflow.com/users/42136",
"pm_score": 1,
"selected": false,
"text": "<p>That's a tough one. I never used the logging classes, so I'm unsure of that part of the question, but converting an... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497420",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1409/"
] | I'm seeing something very very strange happening in a Flex app I'm maintaining.
I've been going through it removing all calls to trace() and replacing it with calls into the logging framework (using the built in mx.logging stuff). After doing so some XML parsing code suddenly broke, and I can't for the life of me figu... | Posting this as an answer instead of an edit as it includes some workarounds.
I did a few more tests. Here's the relevant code from the first:
```
LOG.debug("Got response:");
var cityXML:XML = xml..city[0];
var stateXML:XML = xml..stateProv[0];
```
Stepping through with the debugger, cityXML is assigned to null, wh... |
497,426 | <p>Is it possible to delete multiple elements from a list at the same time? If I want to delete elements at index 0 and 2, and try something like <code>del somelist[0]</code>, followed by <code>del somelist[2]</code>, the second statement will actually delete <code>somelist[3]</code>.</p>
<p>I suppose I could always d... | [
{
"answer_id": 497434,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 7,
"selected": false,
"text": "<p>If you're deleting multiple non-adjacent items, then what you describe is the best way (and yes, be sure to start from... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497426",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Is it possible to delete multiple elements from a list at the same time? If I want to delete elements at index 0 and 2, and try something like `del somelist[0]`, followed by `del somelist[2]`, the second statement will actually delete `somelist[3]`.
I suppose I could always delete the higher numbered elements first bu... | You can use `enumerate` and remove the values whose index matches the indices you want to remove:
```
indices = 0, 2
somelist = [i for j, i in enumerate(somelist) if j not in indices]
``` |
497,427 | <p>Is it possible to define anonymous subroutines in a hash constructor in Perl?</p>
<p>I'm trying to do something like this:</p>
<pre><code>my %array = { one => sub { print "first $_[0]" },
two => sub { print "next $_[0]" },
three => sub { print "last $_[0]" }};
$array{$fo... | [
{
"answer_id": 497440,
"author": "codelogic",
"author_id": 43427,
"author_profile": "https://Stackoverflow.com/users/43427",
"pm_score": 3,
"selected": false,
"text": "<p>That's because in the first case, you're creating a hashref not a hash, what you want is:</p>\n\n<pre><code>my $array... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497427",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2192597/"
] | Is it possible to define anonymous subroutines in a hash constructor in Perl?
I'm trying to do something like this:
```
my %array = { one => sub { print "first $_[0]" },
two => sub { print "next $_[0]" },
three => sub { print "last $_[0]" }};
$array{$foo}->('thing');
```
But it is... | It looks like you're assigning into the hash incorrectly. Using `{}` constructs an anonymous hash reference, which you assign to a scalar. But you're assigning to a named hash (`%array`).
You need to assign into a scalar:
```
my $array = { one => sub { print "first $_[0]" },
two => sub { print "next... |
497,428 | <p>I have a .NET program and a Borland Win32 program that need to pass some cryptographically secure information. The plan right now is to have the .NET app create a public/private key pair, store the public key on disk and keep the private key in memory for as long as the .NET program is running. </p>
<p>The Borland ... | [
{
"answer_id": 504907,
"author": "Mykroft",
"author_id": 2191,
"author_profile": "https://Stackoverflow.com/users/2191",
"pm_score": 4,
"selected": true,
"text": "<p>In the .NET program create a new <code>RSACryptoServiceProvider</code>. Export the public key as <code>RSAParameters</code... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497428",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2191/"
] | I have a .NET program and a Borland Win32 program that need to pass some cryptographically secure information. The plan right now is to have the .NET app create a public/private key pair, store the public key on disk and keep the private key in memory for as long as the .NET program is running.
The Borland app will t... | In the .NET program create a new `RSACryptoServiceProvider`. Export the public key as `RSAParameters` and write the `Modulus` and `Exponent` values to disk. Like this:
```
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(4096); //4096 bit key
RSAParameters par = rsa.ExportParameters(false); // export the pu... |
497,452 | <p>I have ant code that kicks off a release build in all subdirectories:</p>
<pre><code><target name="all-release" >
<subant target="sub-release" failonerror="true">
<fileset dir="." includes="*/build.xml" />
</subant>
</target>
</code></pre>
<p>As written, if any individ... | [
{
"answer_id": 1604019,
"author": "martin clayton",
"author_id": 183172,
"author_profile": "https://Stackoverflow.com/users/183172",
"pm_score": 2,
"selected": false,
"text": "<p>Suggest you look at the extensions available in the <a href=\"http://ant-contrib.sourceforge.net/\" rel=\"nof... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497452",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25915/"
] | I have ant code that kicks off a release build in all subdirectories:
```
<target name="all-release" >
<subant target="sub-release" failonerror="true">
<fileset dir="." includes="*/build.xml" />
</subant>
</target>
```
As written, if any individual build fails, all-release will fail fast (none of the... | Suggest you look at the extensions available in the [ant-contrib](http://ant-contrib.sourceforge.net/) tasks.
The 'for' task can probably be adapted to meet your requirements.
Your 'all-release' target, with the ant-contrib taskdef might look like this:
```
<taskdef resource="net/sf/antcontrib/antlib.xml">
<clas... |
497,461 | <p>I'm trying to find an employee in Active Directory using the following c# code:</p>
<pre><code>"Select userPrincipalName, ADsPath, Department, Mail,
HomeMDB, cn, ssn FROM
'LDAP://" + DomainName + "'
WHERE objectCategory = 'person' and
sAMAccountName = '" + UserName.Replace("'", "''") + "'";
</code></pre>
<p>Whe... | [
{
"answer_id": 497490,
"author": "Adam Bellaire",
"author_id": 21632,
"author_profile": "https://Stackoverflow.com/users/21632",
"pm_score": 0,
"selected": false,
"text": "<p>You tried:</p>\n\n<pre><code>Replace(\"'\", \"\\''\")\n</code></pre>\n\n<p>And not:</p>\n\n<pre><code>Replace(\"'... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497461",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm trying to find an employee in Active Directory using the following c# code:
```
"Select userPrincipalName, ADsPath, Department, Mail,
HomeMDB, cn, ssn FROM
'LDAP://" + DomainName + "'
WHERE objectCategory = 'person' and
sAMAccountName = '" + UserName.Replace("'", "''") + "'";
```
When I run this for an employ... | Do the replace on it's own line.
```
Username.Replace("'", "\'");
"Select userPrincipalName, ADsPath, Department, Mail, HomeMDB, cn, ssn FROM
'LDAP://" + DomainName + "' WHERE objectCategory = 'person' and
sAMAccountName = '" + UserName + "'";
``` |
497,464 | <p>I'd like to update a set of rows based on a simple criteria and get the list of PKs that were changed. I thought I could just do something like this but am worried about possible concurrency problems:</p>
<pre><code>SELECT Id FROM Table1 WHERE AlertDate IS NULL;
UPDATE Table1 SET AlertDate = getutcdate() WHERE Aler... | [
{
"answer_id": 497474,
"author": "Kevin Fairchild",
"author_id": 3743,
"author_profile": "https://Stackoverflow.com/users/3743",
"pm_score": 3,
"selected": false,
"text": "<p>It'd be easier to do your UPDATE first and then run 'SELECT ID FROM INSERTED'.</p>\n\n<p>Take a look at <a href=\... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497464",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40161/"
] | I'd like to update a set of rows based on a simple criteria and get the list of PKs that were changed. I thought I could just do something like this but am worried about possible concurrency problems:
```
SELECT Id FROM Table1 WHERE AlertDate IS NULL;
UPDATE Table1 SET AlertDate = getutcdate() WHERE AlertDate IS NULL;... | Consider looking at the [OUTPUT clause](http://msdn.microsoft.com/en-us/library/ms177564.aspx):
```
USE AdventureWorks2012;
GO
DECLARE @MyTableVar table(
EmpID int NOT NULL,
OldVacationHours int,
NewVacationHours int,
ModifiedDate datetime);
UPDATE TOP (10) HumanResources.Employee
SET... |
497,472 | <p>What I'm trying to do is to convert a double to hex string and then back to double.</p>
<p>The following code does conversion double-to-hex string.</p>
<pre><code>char * double2HexString(double a)
{
char *buf = new char[17]; // double is 8-byte long, so we have 2*8 + terminating \0
char *d2c;
d2c = (char ... | [
{
"answer_id": 497511,
"author": "Daniel C. Sobral",
"author_id": 53013,
"author_profile": "https://Stackoverflow.com/users/53013",
"pm_score": 0,
"selected": false,
"text": "<p>Using sprintf is slow, to be honest, but you can revert it with sscanf, doing almost exactly the same thing.</... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497472",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | What I'm trying to do is to convert a double to hex string and then back to double.
The following code does conversion double-to-hex string.
```
char * double2HexString(double a)
{
char *buf = new char[17]; // double is 8-byte long, so we have 2*8 + terminating \0
char *d2c;
d2c = (char *) &a;
char *n = b... | I am surprised to see nobody has come up with the standard solution, which is the `%a` format specifier in the ISO C99 Standard.
```
#include <iostream>
#include <string>
#include <stdio.h>
std::string double2hexastr(double d) {
char buffer[25] = { 0 };
::snprintf(buffer, 25, "%A", d); // TODO Check for errors
... |
497,485 | <p>Did anybody get <a href="http://www.vim.org/scripts/script.php?script_id=1697" rel="noreferrer">surround.vim</a> to work with <a href="http://www.vim.org/scripts/script.php?script_id=2136" rel="noreferrer">repeat.vim</a>?</p>
<p>This should enable you to repeat any command provided by the surround plugin with the "... | [
{
"answer_id": 498614,
"author": "f3lix",
"author_id": 60617,
"author_profile": "https://Stackoverflow.com/users/60617",
"pm_score": 5,
"selected": true,
"text": "<p>I just put surround.vim and repeat.vim in my .vim/plugins folder and tried it out. For me, it works like described.</p>\n\... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497485",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Did anybody get [surround.vim](http://www.vim.org/scripts/script.php?script_id=1697) to work with [repeat.vim](http://www.vim.org/scripts/script.php?script_id=2136)?
This should enable you to repeat any command provided by the surround plugin with the "." command.
I think surround.vim should already have builtin supp... | I just put surround.vim and repeat.vim in my .vim/plugins folder and tried it out. For me, it works like described.
May you try the repeat command on a function that is *not* supported. In the docs of surround.vim it says
```
The "." command will work with ds, cs, and yss if you install repeat.vim
```
It does not ... |
497,504 | <p>Can u give me a simple function in vb.net which can take number of days and date as parameters and subtract these number of days from given date.
Forexample</p>
<pre><code>Private function Calculate(Byval p_number_days,p_date) as date
Dim calculated_date as Date= (p_date) - (p_number_days)
return calculated
E... | [
{
"answer_id": 497525,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 3,
"selected": true,
"text": "<pre><code>Private Function Calculate(ByVal p_Number_Days As Integer, ByVal p_Date As DateTime) As DateTime\n Return... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497504",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Can u give me a simple function in vb.net which can take number of days and date as parameters and subtract these number of days from given date.
Forexample
```
Private function Calculate(Byval p_number_days,p_date) as date
Dim calculated_date as Date= (p_date) - (p_number_days)
return calculated
End Function
``... | ```
Private Function Calculate(ByVal p_Number_Days As Integer, ByVal p_Date As DateTime) As DateTime
Return p_Date.AddDays(p_Number_Days * -1)
End Function
``` |
497,519 | <p>I have a custom control that shows a value obtained from the database (the price of the product). This value is stored in the cache for performance reasons and it works fine. However, in design mode in Visual Studio 2008, I get an error that says, "Error Rendering Control. An unhandled exception has occurred. Cache ... | [
{
"answer_id": 497558,
"author": "Nick Berardi",
"author_id": 17,
"author_profile": "https://Stackoverflow.com/users/17",
"pm_score": 0,
"selected": false,
"text": "<p>Are you directly referencing the Cache object in your ASPX file?</p>\n"
},
{
"answer_id": 499353,
"author": ... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497519",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28260/"
] | I have a custom control that shows a value obtained from the database (the price of the product). This value is stored in the cache for performance reasons and it works fine. However, in design mode in Visual Studio 2008, I get an error that says, "Error Rendering Control. An unhandled exception has occurred. Cache is ... | You need to add a wrapper to your Cache access for custom controls, otherwise they will fail in design mode when HttpContext.Current is null. You want to do something like this:
```
public object GetFromCache(string key)
{
var myContext = HttpContext.Current;
if(myContext != null)
{
return myCo... |
497,522 | <p>I want to create a SQL Select to do a unit test in MS SQL Server 2005. The basic idea is this:</p>
<pre class="lang-sql prettyprint-override"><code>select 'Test Name', foo = 'Result'
from bar
where baz = (some criteria)
</code></pre>
<p>The idea being that, if the value of the "foo" column is "Result", then I'd ge... | [
{
"answer_id": 497530,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 5,
"selected": false,
"text": "<pre><code>SELECT 'TestName', \n CASE WHEN Foo = 'Result' THEN 1 ELSE 0 END AS TestResult\nFROM bar \nWHERE baz = @... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497522",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3488/"
] | I want to create a SQL Select to do a unit test in MS SQL Server 2005. The basic idea is this:
```sql
select 'Test Name', foo = 'Result'
from bar
where baz = (some criteria)
```
The idea being that, if the value of the "foo" column is "Result", then I'd get a value of true/1; if it isn't, I'd get false/0.
Unfortuna... | Use the case construct:
```
select 'Test Name',
case when foo = 'Result' then 1 else 0 end
from bar where baz = (some criteria)
```
Also see [the MSDN Transact-SQL CASE documentation](http://msdn.microsoft.com/en-us/library/ms181765.aspx). |
497,535 | <p>I have data that looks like this:</p>
<pre><code>entities
id name
1 Apple
2 Orange
3 Banana
</code></pre>
<p>Periodically, a process will run and give a score to each entity. The process generates the data and adds it to a scores table like so:</p>
<pre><code>scores
id entity_... | [
{
"answer_id": 497551,
"author": "Otávio Décio",
"author_id": 48684,
"author_profile": "https://Stackoverflow.com/users/48684",
"pm_score": 1,
"selected": false,
"text": "<pre><code>SELECT entities.*, \n scores.score, \n scores.date_added \nFROM entities\n\nINNER JOIN scores... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497535",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3238/"
] | I have data that looks like this:
```
entities
id name
1 Apple
2 Orange
3 Banana
```
Periodically, a process will run and give a score to each entity. The process generates the data and adds it to a scores table like so:
```
scores
id entity_id score date_added
1 1 ... | I do it this way:
```
SELECT e.*, s1.score, s1.date_added
FROM entities e
INNER JOIN scores s1
ON (e.id = s1.entity_id)
LEFT OUTER JOIN scores s2
ON (e.id = s2.entity_id AND s1.id < s2.id)
WHERE s2.id IS NULL;
``` |
497,543 | <p>I have a Silverlight application which has on it a Canvas.
On that Canvas, I dynamically "paint" a bunch of stuff, but adding controls to the canvas.</p>
<p>I have a button outside the Canvas area which clears the content.
The objects are removed (successfully). However, the Canvas area does not refresh itself im... | [
{
"answer_id": 501551,
"author": "George Sealy",
"author_id": 10086,
"author_profile": "https://Stackoverflow.com/users/10086",
"pm_score": 3,
"selected": true,
"text": "<p>It's a bit grubby, but you could try changing the visibility to 'Visible' (even though it already is) of the Canvas... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497543",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24126/"
] | I have a Silverlight application which has on it a Canvas.
On that Canvas, I dynamically "paint" a bunch of stuff, but adding controls to the canvas.
I have a button outside the Canvas area which clears the content.
The objects are removed (successfully). However, the Canvas area does not refresh itself immediately; i... | It's a bit grubby, but you could try changing the visibility to 'Visible' (even though it already is) of the Canvas, so:
```
myCanvas.Visibility = Visibility.Visible;
```
We've found that this forces as redraw, even if the actual value of myCanvas.Visible hasn't changed...
Give it a go, it's only a one liner that ... |
497,552 | <p>I'm trying to create a cache in a webservice. For this I've created a new Stateless Bean to provide this cache to other Stateless beans. This cache is simply a static ConcurrentMap where MyObject is a POJO.
The problem is that it seems as there are different cache objects. One for the client beans, and another local... | [
{
"answer_id": 497595,
"author": "svrist",
"author_id": 86,
"author_profile": "https://Stackoverflow.com/users/86",
"pm_score": 3,
"selected": true,
"text": "<p>As far as I remember you cant be certain that the stateless bean is global enough for you to keep data in static fields. There ... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497552",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48869/"
] | I'm trying to create a cache in a webservice. For this I've created a new Stateless Bean to provide this cache to other Stateless beans. This cache is simply a static ConcurrentMap where MyObject is a POJO.
The problem is that it seems as there are different cache objects. One for the client beans, and another locally.... | As far as I remember you cant be certain that the stateless bean is global enough for you to keep data in static fields. There exist several caching frameworks that would help you with this. Maybe [memcache](http://www.whalin.com/memcached/)?
EDIT:
<http://java.sun.com/blueprints/qanda/ejb_tier/restrictions.html#stat... |
497,575 | <p>Is there a way to do this in C#? </p>
<pre><code>private void Caller()
{
MyControl c = new MyControl();
Callee(ref c); //Here I want to cast c as Control and pass by ref
}
private void Callee(ref Control c)
{
}
</code></pre>
<hr>
<p>In the generics example, how does it infer T = MyCont... | [
{
"answer_id": 497579,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 2,
"selected": false,
"text": "<p>First, I'd question whether you <em>need</em> <code>ref</code> - it seems unusual; that would mean you intend to r... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497575",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/58348/"
] | Is there a way to do this in C#?
```
private void Caller()
{
MyControl c = new MyControl();
Callee(ref c); //Here I want to cast c as Control and pass by ref
}
private void Callee(ref Control c)
{
}
```
---
In the generics example, how does it infer T = MyControl? Can you please explain... | First, I'd question whether you *need* `ref` - it seems unusual; that would mean you intend to re-assign the variable inside the method? (different to changing properties of the passed instance).
For `ref`, it must be an exact match; you could use:
```
Control tmp = c;
Callee(ref tmp);
c = (MyControl) tmp;
```
Alte... |
497,578 | <p>I'm trying to display one form relative to a Button on a control below it.</p>
<p>But Button.top is relative to the <strong>titlebar</strong> of the bottom form, and the top form will be relative to the screen.</p>
<p>So, to compensate for that I need to now how tall the titlebar is.</p>
<p>I've used Form.height-... | [
{
"answer_id": 497600,
"author": "ahockley",
"author_id": 8209,
"author_profile": "https://Stackoverflow.com/users/8209",
"pm_score": 1,
"selected": false,
"text": "<p>You'll probably need to make a Win32 API call to <a href=\"http://msdn.microsoft.com/en-us/library/ms724385.aspx\" rel=\... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497578",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4906/"
] | I'm trying to display one form relative to a Button on a control below it.
But Button.top is relative to the **titlebar** of the bottom form, and the top form will be relative to the screen.
So, to compensate for that I need to now how tall the titlebar is.
I've used Form.height-Form.ScalehHeight but ScaleHeight doe... | Subtract it back out:
```
(Form.height-Form.ScaleHeight) - (Form.Width-Form.ScaleWidth) / 2
``` |
497,585 | <p>As you probably know if you write text in multiple languages and use Emacs, Emacs has its own input method system independent of Windows (or other operating systems). Input methods can be toggled with <code>toggle-input-method</code> command. When Windows language changes, Emacs receives a <code><language-change&... | [
{
"answer_id": 497997,
"author": "jrockway",
"author_id": 8457,
"author_profile": "https://Stackoverflow.com/users/8457",
"pm_score": 1,
"selected": false,
"text": "<p>Just to make sure, you want this to happen: You change the language in the OS. Emacs gets this event, sends a keypress... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497585",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9204/"
] | As you probably know if you write text in multiple languages and use Emacs, Emacs has its own input method system independent of Windows (or other operating systems). Input methods can be toggled with `toggle-input-method` command. When Windows language changes, Emacs receives a `<language-change>` keypress. I would li... | Just to make sure, you want this to happen: You change the language in the OS. Emacs gets this event, sends a keypress back to the OS, and then un-changes the language.
You may be able to call an external utility to do this.
I'm not sure why you want to do this, though.
If you've changed the OS's language, then let... |
497,609 | <p>I'm using the following code to execute a query in Lucene.Net</p>
<pre><code>var collector = new GroupingHitCollector(searcher.GetIndexReader());
searcher.Search(myQuery, collector);
resultsCount = collector.Hits.Count;
</code></pre>
<p>How do I sort these search results based on a field?</p>
<hr>
<h2>Update</h2... | [
{
"answer_id": 497621,
"author": "James Brady",
"author_id": 29903,
"author_profile": "https://Stackoverflow.com/users/29903",
"pm_score": 6,
"selected": true,
"text": "<p>The <a href=\"http://lucene.apache.org/core/3_0_3/api/core/org/apache/lucene/search/IndexSearcher.html#search%28org.... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497609",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/55717/"
] | I'm using the following code to execute a query in Lucene.Net
```
var collector = new GroupingHitCollector(searcher.GetIndexReader());
searcher.Search(myQuery, collector);
resultsCount = collector.Hits.Count;
```
How do I sort these search results based on a field?
---
Update
------
Thanks for [your answer](https... | The [`search.Searcher.search`](http://lucene.apache.org/core/3_0_3/api/core/org/apache/lucene/search/IndexSearcher.html#search%28org.apache.lucene.search.Weight,%20org.apache.lucene.search.Filter,%20int,%20org.apache.lucene.search.Sort%29) method will accept a [`search.Sort`](http://lucene.apache.org/core/3_0_3/api/cor... |
497,629 | <p>The problem is with the convert of the txt box value, but why?</p>
<pre><code>string strChar = strTest.Substring(0, Convert.ToInt16(txtBoxValue.Text));
</code></pre>
<p>Error is: Input string was not in a correct format.</p>
<p>Thanks all.</p>
| [
{
"answer_id": 497638,
"author": "Otávio Décio",
"author_id": 48684,
"author_profile": "https://Stackoverflow.com/users/48684",
"pm_score": 3,
"selected": false,
"text": "<p>txtBoxValue.Text probably does not contain a valid int16.</p>\n"
},
{
"answer_id": 497648,
"author": "... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497629",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | The problem is with the convert of the txt box value, but why?
```
string strChar = strTest.Substring(0, Convert.ToInt16(txtBoxValue.Text));
```
Error is: Input string was not in a correct format.
Thanks all. | txtBoxValue.Text probably does not contain a valid int16. |
497,630 | <p>I have a base class with a virtual function and I want to override that function in a derived class. Is there some way to make the compiler check if the function I declared in the derived class actually overrides a function in the base class? I would like to add some macro or something that ensures that I didn't acc... | [
{
"answer_id": 497642,
"author": "JMD",
"author_id": 56793,
"author_profile": "https://Stackoverflow.com/users/56793",
"pm_score": 2,
"selected": false,
"text": "<p>I would suggest a slight change in your logic. It may or may not work, depending on what you need to accomplish.</p>\n\n<p... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497630",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/56338/"
] | I have a base class with a virtual function and I want to override that function in a derived class. Is there some way to make the compiler check if the function I declared in the derived class actually overrides a function in the base class? I would like to add some macro or something that ensures that I didn't accide... | Since g++ 4.7 it does understand the new C++11 `override` keyword:
```
class child : public parent {
public:
// force handle_event to override a existing function in parent
// error out if the function with the correct signature does not exist
void handle_event(int something) override;
};
``` |
497,654 | <p>as I usually don't do the up front design of my models in Django projects I end up modifying the models a lot and thus deleting my test database every time (because "syncdb" won't ever alter the tables automatically for you). Below lies my workflow and I'd like to hear about yours. Any thoughts welcome.. </p>
<ol>
... | [
{
"answer_id": 497687,
"author": "Harper Shelby",
"author_id": 21196,
"author_profile": "https://Stackoverflow.com/users/21196",
"pm_score": 6,
"selected": true,
"text": "<p>Steps 2 & 3 can be done in one step:</p>\n\n<pre><code>manage.py reset appname\n</code></pre>\n\n<p>Step 4 is ... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497654",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14716/"
] | as I usually don't do the up front design of my models in Django projects I end up modifying the models a lot and thus deleting my test database every time (because "syncdb" won't ever alter the tables automatically for you). Below lies my workflow and I'd like to hear about yours. Any thoughts welcome..
1. Modify th... | Steps 2 & 3 can be done in one step:
```
manage.py reset appname
```
Step 4 is most easily managed, from my understanding, by using [fixtures](http://www.djangoproject.com/documentation/models/fixtures/) |
497,656 | <p>I have a project for a client that will consist of managing jobs on a MS Compute Cluster. I will be developing the application outside of their network, and would like a way to develop/debug my app without the need to be on their network.</p>
<p>I am developing the app in C#, and all I have so far is the Microsoft... | [
{
"answer_id": 497687,
"author": "Harper Shelby",
"author_id": 21196,
"author_profile": "https://Stackoverflow.com/users/21196",
"pm_score": 6,
"selected": true,
"text": "<p>Steps 2 & 3 can be done in one step:</p>\n\n<pre><code>manage.py reset appname\n</code></pre>\n\n<p>Step 4 is ... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497656",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45153/"
] | I have a project for a client that will consist of managing jobs on a MS Compute Cluster. I will be developing the application outside of their network, and would like a way to develop/debug my app without the need to be on their network.
I am developing the app in C#, and all I have so far is the Microsoft Compute Cl... | Steps 2 & 3 can be done in one step:
```
manage.py reset appname
```
Step 4 is most easily managed, from my understanding, by using [fixtures](http://www.djangoproject.com/documentation/models/fixtures/) |
497,657 | <p>I'm calling a function with call_user_func_array :</p>
<pre><code>call_user_func_array(array($this, 'myFunction'), array('param1', 'param2', 'param3'));
</code></pre>
<p>Everything is ok unless I don't know how many parameters the function needs.
If the function needs 4 parameters it sends me an error, I'd like to... | [
{
"answer_id": 497689,
"author": "Henrik Paul",
"author_id": 2238,
"author_profile": "https://Stackoverflow.com/users/2238",
"pm_score": 1,
"selected": false,
"text": "<p>One way getting around this is to call the function always with a <em>lot</em> of arguments. PHP is designed in such ... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497657",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43364/"
] | I'm calling a function with call\_user\_func\_array :
```
call_user_func_array(array($this, 'myFunction'), array('param1', 'param2', 'param3'));
```
Everything is ok unless I don't know how many parameters the function needs.
If the function needs 4 parameters it sends me an error, I'd like to test if I can call the... | You could use reflection to get the number of parameters:
```
$refl = new ReflectionMethod(get_class($this), 'myFunction');
$numParams = $refl->getNumberOfParameters();
```
or
```
$numParams = $refl->getNumberOfRequiredParameters();
```
See [here](http://uk.php.net/manual/en/language.oop5.reflection.php#language.... |
497,669 | <p>Has anyone tried installing powershell on a Windows 2000 server? I realize its not supposed to be installed on windows 2000 server and therefore not supported; however the vbscript that runs on it takes 3.5 days to complete which powershell could probably finish in lesser time. Nevertheless, I noticed it just requ... | [
{
"answer_id": 498887,
"author": "Steven Murawski",
"author_id": 1233,
"author_profile": "https://Stackoverflow.com/users/1233",
"pm_score": 1,
"selected": false,
"text": "<p>If you have administrator access to the Windows 2000 server in question, you could run PowerShell on a supported ... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497669",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18853/"
] | Has anyone tried installing powershell on a Windows 2000 server? I realize its not supposed to be installed on windows 2000 server and therefore not supported; however the vbscript that runs on it takes 3.5 days to complete which powershell could probably finish in lesser time. Nevertheless, I noticed it just requires ... | If you have administrator access to the Windows 2000 server in question, you could run PowerShell on a supported machine in the same domain and use set-location to change your working directory to the remote server
```
cd \\remoteserver\<drive>$\path\to\folder\you\want\to\start\in
```
You could then run whatever Pow... |
497,670 | <p>These instructions are a little intimidating and confusing: <a href="http://svnbook.red-bean.com/en/1.0/ch04s04.html#svn-ch-4-sect-4.3" rel="noreferrer">http://svnbook.red-bean.com/en/1.0/ch04s04.html#svn-ch-4-sect-4.3</a> .
And also they don't seem to mention that it's much simpler if you haven't yet checked in aft... | [
{
"answer_id": 497671,
"author": "dreeves",
"author_id": 4234,
"author_profile": "https://Stackoverflow.com/users/4234",
"pm_score": 8,
"selected": true,
"text": "<p>If you just did</p>\n\n<pre><code>svn rm foo.txt\n</code></pre>\n\n<p>then you can undo that with simply</p>\n\n<pre><code... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497670",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4234/"
] | These instructions are a little intimidating and confusing: <http://svnbook.red-bean.com/en/1.0/ch04s04.html#svn-ch-4-sect-4.3> .
And also they don't seem to mention that it's much simpler if you haven't yet checked in after doing the "`svn rm`" [1].
So I thought this would be a good place to record a simpler answer ... | If you just did
```
svn rm foo.txt
```
then you can undo that with simply
```
svn revert foo.txt
```
If you already checked in after doing the "`svn rm`" then you can look at the log (`svn log`), find the last revision where the file existed, and grab it from that version.
One way to do that is to merge in the o... |
497,679 | <p>I'm working on a framework in PHP, part of this frameworks job is to write SQL code to generate new MySQL columns.</p>
<p>What is the most elegant way to pass in a bunch of parameters for a column and then turn that into SQL code? As an example here is some YAML I have, that specifies parameters for creating a varc... | [
{
"answer_id": 498114,
"author": "chaos",
"author_id": 47529,
"author_profile": "https://Stackoverflow.com/users/47529",
"pm_score": 2,
"selected": true,
"text": "<p>I recommend you make a class Column that takes, as a constructor argument, an array that can define the various configurat... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497679",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46540/"
] | I'm working on a framework in PHP, part of this frameworks job is to write SQL code to generate new MySQL columns.
What is the most elegant way to pass in a bunch of parameters for a column and then turn that into SQL code? As an example here is some YAML I have, that specifies parameters for creating a varchar column... | I recommend you make a class Column that takes, as a constructor argument, an array that can define the various configuration points you want. The ones that don't matter in each particular case you just don't define. |
497,681 | <p>The following works very nicely to determine the length of various audio/video files:</p>
<pre><code>mplayer -identify file.ogg 2>/dev/null | grep ID_LENGTH
</code></pre>
<p>However, I want to kill mplayer's output so I can determine the length of many files more efficiently. How do I do that?</p>
| [
{
"answer_id": 497859,
"author": "codelogic",
"author_id": 43427,
"author_profile": "https://Stackoverflow.com/users/43427",
"pm_score": 3,
"selected": false,
"text": "<p>FFMPEG can give you the same information in a different format (and doesn't attempt playing the file):</p>\n\n<pre><c... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497681",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | The following works very nicely to determine the length of various audio/video files:
```
mplayer -identify file.ogg 2>/dev/null | grep ID_LENGTH
```
However, I want to kill mplayer's output so I can determine the length of many files more efficiently. How do I do that? | The `MPlayer` source ships with a sample script called `midentify`, which looks like this:
```
#!/bin/sh
#
# This is a wrapper around the -identify functionality.
# It is supposed to escape the output properly, so it can be easily
# used in shellscripts by 'eval'ing the output of this script.
#
# Written by Tobias Die... |
497,699 | <p>I have been creating Unit tests like crazy and find that I'm often having to set up something in one test that I just tore down in a previous test. Is it ever reasonable to create something (e.g. a database record) in one test (e.g. an Insertion test) and then use it for a later test (e.g. a Deletion test)? Or sho... | [
{
"answer_id": 497710,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 2,
"selected": false,
"text": "<p>I really wouldn't rely on ordering of tests. Instead, I'd pull the common setup code into a separate method and call ... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497699",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15592/"
] | I have been creating Unit tests like crazy and find that I'm often having to set up something in one test that I just tore down in a previous test. Is it ever reasonable to create something (e.g. a database record) in one test (e.g. an Insertion test) and then use it for a later test (e.g. a Deletion test)? Or should e... | Relying on the order of your tests indicates that you are persisting state across tests. This is *[smelly](http://en.wikipedia.org/wiki/Code_smell)*
A cleaner way of testing is where you only depend on the single piece of functionality you want to check the behaviour of. Commonly you [mock](http://en.wikipedia.org/wik... |
497,720 | <p>I am trying to change the keys my keyboard sends to applications. I've already created a global hook and can prevent the keys I want, but I want to now send a new key in place. Here's my hook proc:</p>
<pre><code>LRESULT __declspec (dllexport) HookProc(int nCode, WPARAM wParam, LPARAM lParam)
{
int ret;
if... | [
{
"answer_id": 497758,
"author": "Tadmas",
"author_id": 3750,
"author_profile": "https://Stackoverflow.com/users/3750",
"pm_score": 3,
"selected": true,
"text": "<p>Calling keybd_event is correct. If all you're doing is a key up, maybe the window processes the key down message instead. ... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497720",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53007/"
] | I am trying to change the keys my keyboard sends to applications. I've already created a global hook and can prevent the keys I want, but I want to now send a new key in place. Here's my hook proc:
```
LRESULT __declspec (dllexport) HookProc(int nCode, WPARAM wParam, LPARAM lParam)
{
int ret;
if(nCode < 0)
... | Calling keybd\_event is correct. If all you're doing is a key up, maybe the window processes the key down message instead. You really need to send a key down followed by a key up:
```
keybd_event(VK_UP, 75, 0, NULL);
keybd_event(VK_UP, 75, KEYEVENTF_KEYUP, NULL);
```
Or, better yet, send the key down when the OEM ke... |
497,735 | <p>I have custom errors configured in my web.config, but IIS 6.0 is returning the custom error specified in the Custom Errors tab of the website configuration.</p>
<pre><code> <system.web>
<customErrors>
<error statusCode="404" redirect="UrlRedirect.aspx" />
</custom... | [
{
"answer_id": 497760,
"author": "Phaedrus",
"author_id": 46072,
"author_profile": "https://Stackoverflow.com/users/46072",
"pm_score": 2,
"selected": false,
"text": "<p>You might be missing mode=\"On\":</p>\n\n<pre><code><system.web>\n <customErrors mode=\"On\">\n ... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497735",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16794/"
] | I have custom errors configured in my web.config, but IIS 6.0 is returning the custom error specified in the Custom Errors tab of the website configuration.
```
<system.web>
<customErrors>
<error statusCode="404" redirect="UrlRedirect.aspx" />
</customErrors>
</system.web>
```
What ... | Bear in mind that the 404 handler specified in the web.config only kicks in for files handled by the ASP.NET runtime - .htm, images, css, javascript will all be handled by the 404 page specified in your hosts IIS settings.
If you want these file types to be handled by your custom error, you'll need to set IIS to direc... |
497,747 | <p>I currently use Python for most of my programming projects (mainly rapid development of small programs and prototypes). I'd like to invest time in learning a language that gives me the flexibility to use various Microsoft tools and APIs whenever the opportunity arises. I'm trying to decide between IronPython and C#.... | [
{
"answer_id": 497938,
"author": "user54650",
"author_id": 54650,
"author_profile": "https://Stackoverflow.com/users/54650",
"pm_score": 5,
"selected": true,
"text": "<p>I've built a large-scale application in IronPython bound with C#.</p>\n\n<p>It's almost completely seamless. The only... | 2009/01/30 | [
"https://Stackoverflow.com/questions/497747",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38146/"
] | I currently use Python for most of my programming projects (mainly rapid development of small programs and prototypes). I'd like to invest time in learning a language that gives me the flexibility to use various Microsoft tools and APIs whenever the opportunity arises. I'm trying to decide between IronPython and C#. Si... | I've built a large-scale application in IronPython bound with C#.
It's almost completely seamless. The only things missing in IronPython from the true "python" feel are the C-based libraries (gotta use .NET for those) and IDLE.
The language interacts with other .NET languages like a dream... Specifically if you embed... |
497,765 | <p>In Python, I can do:</p>
<pre><code>>>> list = ['a', 'b', 'c']
>>> ', '.join(list)
'a, b, c'
</code></pre>
<p>Is there any easy way to do the same when I have a list of objects?</p>
<pre><code>>>> class Obj:
... def __str__(self):
... return 'name'
...
>>> list = [O... | [
{
"answer_id": 497773,
"author": "Adam Rosenfield",
"author_id": 9530,
"author_profile": "https://Stackoverflow.com/users/9530",
"pm_score": 10,
"selected": true,
"text": "<p>You could use a list comprehension or a generator expression instead:</p>\n\n<pre><code>', '.join([str(x) for x i... | 2009/01/31 | [
"https://Stackoverflow.com/questions/497765",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42974/"
] | In Python, I can do:
```
>>> list = ['a', 'b', 'c']
>>> ', '.join(list)
'a, b, c'
```
Is there any easy way to do the same when I have a list of objects?
```
>>> class Obj:
... def __str__(self):
... return 'name'
...
>>> list = [Obj(), Obj(), Obj()]
>>> ', '.join(list)
Traceback (most recent call last)... | You could use a list comprehension or a generator expression instead:
```
', '.join([str(x) for x in list]) # list comprehension
', '.join(str(x) for x in list) # generator expression
``` |
497,772 | <p>I have something unclear concerning casting reference variable in Java.</p>
<p>I have two classes A and B. A is the super class of B.
If I have the two objects, and then the print statement:</p>
<pre><code>A a = new A(); //superclass
B b = new B(); //subclass
System.out.println ((A)b);
</code></pre>
<p>then wh... | [
{
"answer_id": 497833,
"author": "yawmark",
"author_id": 45204,
"author_profile": "https://Stackoverflow.com/users/45204",
"pm_score": 1,
"selected": false,
"text": "<blockquote>\n <p>Is this correct?</p>\n</blockquote>\n\n<p>Sort of. The result of the casting expression would be of the... | 2009/01/31 | [
"https://Stackoverflow.com/questions/497772",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42155/"
] | I have something unclear concerning casting reference variable in Java.
I have two classes A and B. A is the super class of B.
If I have the two objects, and then the print statement:
```
A a = new A(); //superclass
B b = new B(); //subclass
System.out.println ((A)b);
```
then what exactly is happening when the ... | The cast has no impact in this case.
The System.out.println(XXX) takes parameters of different types (multiple overloaded versions) but in this case you would get the version that takes Object. Since every object in Java supports toString(), toString is invoked on the actual argument, no matter what it is.
Now, since... |
497,777 | <p>What is the most efficient to fill a ComboBox with all the registered file types in Windows?</p>
<p>I want the full file type, not just the extension. I'm using VB 9 (VS2008).</p>
| [
{
"answer_id": 497785,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 0,
"selected": false,
"text": "<p>I know this doesn't answer your question, but it's worth considering: on many systems, that's <em>LOT</em> of item... | 2009/01/31 | [
"https://Stackoverflow.com/questions/497777",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/57175/"
] | What is the most efficient to fill a ComboBox with all the registered file types in Windows?
I want the full file type, not just the extension. I'm using VB 9 (VS2008). | All the file types are stored in the registry under the HKEY\_CLASS\_ROOT, which you could obtain using the Framework's [Registry class](http://msdn.microsoft.com/en-us/library/microsoft.win32.registry.aspx).
Here's c# code to perform the task:
```
using Microsoft.Win32;
public class FileAssoc
{
public string Ex... |
497,780 | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/231893/what-does-yield-break-do-in-c">What does “yield break;” do in C#?</a> </p>
</blockquote>
<p>Can anyone see a use for the "yield break" statement that could not have been otherwise achieved by using "brea... | [
{
"answer_id": 497827,
"author": "Bob",
"author_id": 45,
"author_profile": "https://Stackoverflow.com/users/45",
"pm_score": 3,
"selected": false,
"text": "<p>yield break specifies that the method should stop returning results. \"return\" by itself would not be good enough, or could even... | 2009/01/31 | [
"https://Stackoverflow.com/questions/497780",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | >
> **Possible Duplicate:**
>
> [What does “yield break;” do in C#?](https://stackoverflow.com/questions/231893/what-does-yield-break-do-in-c)
>
>
>
Can anyone see a use for the "yield break" statement that could not have been otherwise achieved by using "break" or "return".
This statement seems to be utterly... | To give a code example, say you want to write an iterator that returns nothing if the source is null or empty.
```
public IEnumerable<T> EnumerateThroughNull<T>(IEnumerable<T> source)
{
if (source == null)
yield break;
foreach (T item in source)
yield return item;
}
```
Without the yield bre... |
497,782 | <p>I have a string object </p>
<p>"with multiple characters and even special characters"</p>
<p>I am trying to use </p>
<pre><code>UTF8Encoding utf8 = new UTF8Encoding();
ASCIIEncoding ascii = new ASCIIEncoding();
</code></pre>
<p>objects in order to convert that string to ascii. May I ask someone to bring some lig... | [
{
"answer_id": 497813,
"author": "Geo",
"author_id": 47222,
"author_profile": "https://Stackoverflow.com/users/47222",
"pm_score": 4,
"selected": false,
"text": "<p>I was able to figure it out. In case someone wants to know below the code that worked for me:</p>\n\n<pre><code>ASCIIEncod... | 2009/01/31 | [
"https://Stackoverflow.com/questions/497782",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47222/"
] | I have a string object
"with multiple characters and even special characters"
I am trying to use
```
UTF8Encoding utf8 = new UTF8Encoding();
ASCIIEncoding ascii = new ASCIIEncoding();
```
objects in order to convert that string to ascii. May I ask someone to bring some light to this simple task, that is hunting ... | This was in response to your other question, that looks like it's been deleted....the point still stands.
Looks like a [classic Unicode to ASCII issue](http://www.joelonsoftware.com/articles/Unicode.html). The trick would be to find *where* it's happening.
.NET works fine with Unicode, assuming [it's told it's Unicod... |
497,794 | <p>I was working on implementing a quicksort yesterday, and then I ran it, expecting a faster runtime than the Mergesort (which I had also implemented). I ran the two, and while the quicksort was faster for smaller data sets <100 elements (and I <i>did</i> verify that it works), the mergesort became the quicker algo... | [
{
"answer_id": 497819,
"author": "yawmark",
"author_id": 45204,
"author_profile": "https://Stackoverflow.com/users/45204",
"pm_score": 2,
"selected": false,
"text": "<p>Previously discussed on SO: \"<a href=\"https://stackoverflow.com/questions/70402/why-is-quicksort-better-than-mergesor... | 2009/01/31 | [
"https://Stackoverflow.com/questions/497794",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60881/"
] | I was working on implementing a quicksort yesterday, and then I ran it, expecting a faster runtime than the Mergesort (which I had also implemented). I ran the two, and while the quicksort was faster for smaller data sets <100 elements (and I *did* verify that it works), the mergesort became the quicker algorithm fairl... | I actually just wrote a "linked-list comparative sort demo program" in C and arrived at a similar conclusion (that mergesort will beat quicksort for most uses), altho I have been told that quicksort is generally not used for linked lists anyway. I would note that **the choice of pivot values** is a monster factor -- my... |
497,802 | <p>I have this label control in my web page</p>
<pre><code><asp:Label ID="Label1" runat="server" Text="test"></asp:Label>
</code></pre>
<p>And when the page rendered the id of the control changes to something like this</p>
<pre><code> <span id="ctl00_ContentPlaceHolder1_Label3">test</span>
<... | [
{
"answer_id": 497815,
"author": "devio",
"author_id": 21336,
"author_profile": "https://Stackoverflow.com/users/21336",
"pm_score": 2,
"selected": false,
"text": "<p>You have to pass the control's ClientID to the javascript code (I doubt though that Label1 gets renamed to Label3)</p>\n\... | 2009/01/31 | [
"https://Stackoverflow.com/questions/497802",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/459737/"
] | I have this label control in my web page
```
<asp:Label ID="Label1" runat="server" Text="test"></asp:Label>
```
And when the page rendered the id of the control changes to something like this
```
<span id="ctl00_ContentPlaceHolder1_Label3">test</span>
```
How can I stop asp.net from changing IDs in order to per... | instead of using this selector
```
$('#Label1')
```
use this one, basically you are using the classic asp inline server side code.
```
$('#<%= Label1.ClientID %>')
```
this will insert whatever ID that is generated to be placed as a literal.
If you wish to use external files then I would suggest you create an ob... |
497,809 | <p>I would like to implement the method <code>User.calculate_hashed_password</code>. I'm trying to use the Shoulda testing library which works with Rails's built-in testing tools, so an answer related to Test::Unit would be just as good as one related to Shoulda (I think).</p>
<p>I'm trying to figure out <strong>what<... | [
{
"answer_id": 497840,
"author": "dylanfm",
"author_id": 38795,
"author_profile": "https://Stackoverflow.com/users/38795",
"pm_score": 2,
"selected": false,
"text": "<p>Maybe use <code>respond_to?</code></p>\n"
},
{
"answer_id": 497864,
"author": "Otto",
"author_id": 9594... | 2009/01/31 | [
"https://Stackoverflow.com/questions/497809",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42595/"
] | I would like to implement the method `User.calculate_hashed_password`. I'm trying to use the Shoulda testing library which works with Rails's built-in testing tools, so an answer related to Test::Unit would be just as good as one related to Shoulda (I think).
I'm trying to figure out **what** I need to test and **how*... | You don't need to test that the method exists, just that the method behaves correctly. Say something like this:
```
class UserTest < ActiveSupport::TestCase
setup do
@user = User.new
end
should 'Calculate the hashed password correctly'
@user.password = "password"
@user.hashed_password = "xxxxx" # Ma... |
497,830 | <p>We're using both Apache Tomcat 6.0 and Jetty 6 where I work. We mostly use Jetty for testing (it's great for running embedded in JUnit tests) and Tomcat for production.</p>
<p>By default, Tomcat compiles JSPs on-the-fly as users request them. But this results in degraded performance for the first hit. It also hi... | [
{
"answer_id": 810138,
"author": "ariso",
"author_id": 97775,
"author_profile": "https://Stackoverflow.com/users/97775",
"pm_score": 3,
"selected": false,
"text": "<p><a href=\"http://www.devshed.com/c/a/BrainDump/Tomcat-Capacity-Planning/\" rel=\"noreferrer\">http://www.devshed.com/c/a/... | 2009/01/31 | [
"https://Stackoverflow.com/questions/497830",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54829/"
] | We're using both Apache Tomcat 6.0 and Jetty 6 where I work. We mostly use Jetty for testing (it's great for running embedded in JUnit tests) and Tomcat for production.
By default, Tomcat compiles JSPs on-the-fly as users request them. But this results in degraded performance for the first hit. It also highlights [biz... | <http://www.devshed.com/c/a/BrainDump/Tomcat-Capacity-Planning/>
---
```
project name="pre-compile-jsps" default="compile-jsp-servlets">
<!-- Private properties. -- >
<property name="webapp.dir" value="${basedir}/webapp-dir"/>
<property name="tomcat.home" value="/opt/tomcat"/>
<property name="jspc.pkg.pr... |
497,837 | <p>Can I assign more than one "CssClass" to a control in asp.net?How to do this?</p>
| [
{
"answer_id": 497844,
"author": "Larsenal",
"author_id": 337,
"author_profile": "https://Stackoverflow.com/users/337",
"pm_score": 6,
"selected": true,
"text": "<p>To assign class \"myClass1\" and \"myClass2\" you simply say:</p>\n\n<pre><code><asp:Label runat=\"server\" CssClass=\"m... | 2009/01/31 | [
"https://Stackoverflow.com/questions/497837",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/459737/"
] | Can I assign more than one "CssClass" to a control in asp.net?How to do this? | To assign class "myClass1" and "myClass2" you simply say:
```
<asp:Label runat="server" CssClass="myClass1 myClass2" />
```
This is the same approach you'd use in normal HTML as in:
```
<div class="myClass1 myClass2"></div>
``` |
497,850 | <p>I have a build script that does a number of things (minimize javascript, upload to amazon s3 etc). The minimize ANT task only operates on the javascript that I have modified and ignores the rest (I didn't write this script). I would like to do something similar for the amazon s3 task where only the updated content i... | [
{
"answer_id": 497868,
"author": "Peter Hilton",
"author_id": 2670,
"author_profile": "https://Stackoverflow.com/users/2670",
"pm_score": 0,
"selected": false,
"text": "<p>In general you can do this for tasks that have source and destination files using <a href=\"http://ant.apache.org/ma... | 2009/01/31 | [
"https://Stackoverflow.com/questions/497850",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35505/"
] | I have a build script that does a number of things (minimize javascript, upload to amazon s3 etc). The minimize ANT task only operates on the javascript that I have modified and ignores the rest (I didn't write this script). I would like to do something similar for the amazon s3 task where only the updated content is u... | You can select a fileset with a modified date tag. The modified tag is insanely powerful, so check it out: [Ant Selectors - Modified](http://ant.apache.org/manual/Types/selectors.html#modified).
In order for it to tell what has changed, it can keep a cache in a property file, which updates after each successful build,... |
497,885 | <p>Is there anyway to get tuple operations in Python to work like this:</p>
<pre><code>>>> a = (1,2,3)
>>> b = (3,2,1)
>>> a + b
(4,4,4)
</code></pre>
<p>instead of:</p>
<pre><code>>>> a = (1,2,3)
>>> b = (3,2,1)
>>> a + b
(1,2,3,3,2,1)
</code></pre>
<p>I know i... | [
{
"answer_id": 497894,
"author": "ironfroggy",
"author_id": 19687,
"author_profile": "https://Stackoverflow.com/users/19687",
"pm_score": 8,
"selected": true,
"text": "<pre><code>import operator\ntuple(map(operator.add, a, b))\n</code></pre>\n"
},
{
"answer_id": 497896,
"auth... | 2009/01/31 | [
"https://Stackoverflow.com/questions/497885",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14006/"
] | Is there anyway to get tuple operations in Python to work like this:
```
>>> a = (1,2,3)
>>> b = (3,2,1)
>>> a + b
(4,4,4)
```
instead of:
```
>>> a = (1,2,3)
>>> b = (3,2,1)
>>> a + b
(1,2,3,3,2,1)
```
I know it works like that because the `__add__` and `__mul__` methods are defined to work like that. So the onl... | ```
import operator
tuple(map(operator.add, a, b))
``` |
497,886 | <p>I got the following code fom the web and was trying to compile and run it. Its an ajax application. I couldn't get it to compile/build this application, because it gives the following error: </p>
<blockquote>
<p>Are you missing a using directive or assembly reference</p>
</blockquote>
<p>Can somebody advise what... | [
{
"answer_id": 497910,
"author": "Serguei",
"author_id": 47693,
"author_profile": "https://Stackoverflow.com/users/47693",
"pm_score": 1,
"selected": false,
"text": "<p>Check that the project has a reference to the System.Web.Extensions assembly.</p>\n"
},
{
"answer_id": 497956,
... | 2009/01/31 | [
"https://Stackoverflow.com/questions/497886",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I got the following code fom the web and was trying to compile and run it. Its an ajax application. I couldn't get it to compile/build this application, because it gives the following error:
>
> Are you missing a using directive or assembly reference
>
>
>
Can somebody advise what/where should I check?
Here is ... | Check that the project has a reference to the System.Web.Extensions assembly. |
497,890 | <p>Ok, so I'm psyched about another list. I got myself a copy of the beta Clojure programming book...</p>
<p>And the one thing I'm noticing most is that it's assumed I know... like all the major java classes.</p>
<p>Except, generally, I don't really care about Java. I just want enough knowledge of it for Clojure to... | [
{
"answer_id": 497906,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": -1,
"selected": false,
"text": "<p>If you're not interested in all the Java aspects of Clojure, perhaps you'd be better off learning another dialect of ... | 2009/01/31 | [
"https://Stackoverflow.com/questions/497890",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54650/"
] | Ok, so I'm psyched about another list. I got myself a copy of the beta Clojure programming book...
And the one thing I'm noticing most is that it's assumed I know... like all the major java classes.
Except, generally, I don't really care about Java. I just want enough knowledge of it for Clojure to be an option for m... | My main recommendation for you, you've already accomplished by buying Programming Clojure. I've avoided and loathed Java for years and years, and (Programming) Clojure rehabilitated it enough that the language now excites me. Who'd've thought that a famously onerous system would let you interactively `(map #(.getName %... |
497,943 | <p>What is the best way to convert from a generic <code>IEnumerable<T></code> implementation to an array of T? The current solution I have looks like the following:</p>
<pre><code>IEnumerable<string> foo = getFoo();
string[] bar = new List<string>(foo).ToArray();
</code></pre>
<p>The transfer throu... | [
{
"answer_id": 497958,
"author": "Ray Hidayat",
"author_id": 49643,
"author_profile": "https://Stackoverflow.com/users/49643",
"pm_score": 0,
"selected": false,
"text": "<p>If there's no way to determine the length of the array, then that's the best way. </p>\n\n<p>There's nothing in IEn... | 2009/01/31 | [
"https://Stackoverflow.com/questions/497943",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16002/"
] | What is the best way to convert from a generic `IEnumerable<T>` implementation to an array of T? The current solution I have looks like the following:
```
IEnumerable<string> foo = getFoo();
string[] bar = new List<string>(foo).ToArray();
```
The transfer through a `List<T>` seems unneccesary, but I haven't been abl... | .NET 3.0 and after:
-------------------
Call the [`ToArray` extension method](https://msdn.microsoft.com/en-us/library/bb298736(v=vs.110).aspx) on `IEnumerable<T>`, it does nearly the same as below, performing type sniffing and some other optimizations.
.NET 2.0 and before:
--------------------
Generally speaking, u... |
497,945 | <p>The option exists in the UI, but not in the help displayed in the command line.</p>
| [
{
"answer_id": 506362,
"author": "NicJ",
"author_id": 43815,
"author_profile": "https://Stackoverflow.com/users/43815",
"pm_score": 4,
"selected": false,
"text": "<p>Are you creating a new task via the <code>schtasks.exe</code> command line, or updating an existing task?</p>\n\n<p>On Vis... | 2009/01/31 | [
"https://Stackoverflow.com/questions/497945",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8694/"
] | The option exists in the UI, but not in the help displayed in the command line. | Are you creating a new task via the `schtasks.exe` command line, or updating an existing task?
On Vista, `schtasks.exe` has an `/xml` option for both `/create` and `/query`. With this XML encoding of the task, you can see the `WakeToRun` node can be set for waking the computer from sleep to run the task:
```
<?xml ve... |
497,952 | <p>I was just wondering how do you make python fail in a user defined way in all possible errors. </p>
<p>For example, I'm writing a program that processes a (large) list of items, and some of the items may not be in the format I defined. If python detects an error, it currently just spits out an ugly error message an... | [
{
"answer_id": 497960,
"author": "dF.",
"author_id": 3002,
"author_profile": "https://Stackoverflow.com/users/3002",
"pm_score": 3,
"selected": false,
"text": "<p>The ugly error message means that an exception is raised. You need to catch the exception.</p>\n\n<p>A good place to start is... | 2009/01/31 | [
"https://Stackoverflow.com/questions/497952",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60893/"
] | I was just wondering how do you make python fail in a user defined way in all possible errors.
For example, I'm writing a program that processes a (large) list of items, and some of the items may not be in the format I defined. If python detects an error, it currently just spits out an ugly error message and stop the... | The following are a few basic strategies I regularly use in my more-than-trivial scripts and medium-size applications.
Tip 1: Trap the error at every level where it makes sense to continue processing. In your case it may be in the inside the loop. You don't have to protect every single line or every single function ca... |
497,974 | <p>I have a navigationController-based app. I want to change the title of the back button for the root view controller. I have tried the following code in the rootViewController's viewDidLoad method, but no success:</p>
<pre><code>self.navigationItem.backBarButtonItem.title = @"Back";
</code></pre>
<p>Any ideas?</p>
| [
{
"answer_id": 498089,
"author": "Chris Lundie",
"author_id": 20685,
"author_profile": "https://Stackoverflow.com/users/20685",
"pm_score": 6,
"selected": false,
"text": "<p>I've had success by creating my own UIBarButtonItem instead of setting the title of the existing one:</p>\n\n<pre>... | 2009/01/31 | [
"https://Stackoverflow.com/questions/497974",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53527/"
] | I have a navigationController-based app. I want to change the title of the back button for the root view controller. I have tried the following code in the rootViewController's viewDidLoad method, but no success:
```
self.navigationItem.backBarButtonItem.title = @"Back";
```
Any ideas? | The title of the back button is either:
1. The title of the previous view controller
2. The name of the previous view controller's navigation item back button
If you are setting the back button for the current view controller's navigation item you are not setting the button that get's displayed in the current view. Y... |
497,978 | <p>I wonder if there is an easy way to check if two strings match by excluding certain characters in the strings. See example below.</p>
<p>I can easily write such a method by writing a regular expression to find the "wild card" characters, and replace them with a common character. Then compare the two strings str1 an... | [
{
"answer_id": 497981,
"author": "Sean Bright",
"author_id": 21926,
"author_profile": "https://Stackoverflow.com/users/21926",
"pm_score": 0,
"selected": false,
"text": "<p>No, there is nothing in the framework itself that can do this.</p>\n"
},
{
"answer_id": 497988,
"author... | 2009/01/31 | [
"https://Stackoverflow.com/questions/497978",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60892/"
] | I wonder if there is an easy way to check if two strings match by excluding certain characters in the strings. See example below.
I can easily write such a method by writing a regular expression to find the "wild card" characters, and replace them with a common character. Then compare the two strings str1 and str2. I ... | Sorry but I think either regex, or replacing the "wildcard" characters with a common character are going to be your best solution. Basically, the answers that you stated you didn't want to receive. |
498,002 | <p>I have the following situation:</p>
<pre><code>// A public interface of some kind
public interface IMyInterface {
int Something { get; set; }
}
// An internal class that implements the public interface.
// Despite the internal/public mismatch, this works.
internal class MyInternalConcrete : I... | [
{
"answer_id": 498037,
"author": "Rob Walker",
"author_id": 3631,
"author_profile": "https://Stackoverflow.com/users/3631",
"pm_score": 3,
"selected": false,
"text": "<p>According to this article on <a href=\"http://www.codeguru.com/csharp/sample_chapter/article.php/c11637__2/\" rel=\"no... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498002",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27667/"
] | I have the following situation:
```
// A public interface of some kind
public interface IMyInterface {
int Something { get; set; }
}
// An internal class that implements the public interface.
// Despite the internal/public mismatch, this works.
internal class MyInternalConcrete : IMyInterface { ... | This constraint you are facing makes sense for the following reason.
C# is strongly typed so...
To be able to reference the MySpecificClass outside the scope of the assembly it is defined in you must know its parameter types in order to generate a strong type reference to its instance; but an separate assembly than t... |
498,009 | <p>Is there an implementation of a Unix shell and commands as a .Net assembly. This could be a wrapper around cygwin, or a standalone built from public domain source. The kind of commands I'd really like to be able to use are wc, tar, cpio, ps, kill, cat, at ...</p>
<p>how cool would it be to do this (Pseudo code)</p>... | [
{
"answer_id": 498028,
"author": "Mitch Wheat",
"author_id": 16076,
"author_profile": "https://Stackoverflow.com/users/16076",
"pm_score": 2,
"selected": false,
"text": "<p>Have you looked at PowerShell? Many tasks using Unix commands can be <a href=\"http://blogs.msdn.com/powershell/arc... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498009",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/56092/"
] | Is there an implementation of a Unix shell and commands as a .Net assembly. This could be a wrapper around cygwin, or a standalone built from public domain source. The kind of commands I'd really like to be able to use are wc, tar, cpio, ps, kill, cat, at ...
how cool would it be to do this (Pseudo code)
usng cygwin
... | Have you looked at PowerShell? Many tasks using Unix commands can be [translated into PowerShell](http://blogs.msdn.com/powershell/archive/2006/04/25/comparative-examples-in-msh-and-ksh.aspx). |
498,069 | <p>My understanding is that there are 3 types of stylesheet:</p>
<ul>
<li>Defined by the page author</li>
<li>Defined by the user (i.e. a set of default styles defined by the user and installed into their browser)</li>
<li>Default stylesheet defined by the browser</li>
</ul>
<p>According to <a href="http://www.amazon... | [
{
"answer_id": 498128,
"author": "geowa4",
"author_id": 50214,
"author_profile": "https://Stackoverflow.com/users/50214",
"pm_score": 2,
"selected": false,
"text": "<p>You're right. There are three sources of stylesheets. First come browser styles, then user (reader) styles, and finall... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498069",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2648/"
] | My understanding is that there are 3 types of stylesheet:
* Defined by the page author
* Defined by the user (i.e. a set of default styles defined by the user and installed into their browser)
* Default stylesheet defined by the browser
According to [this book](http://www.amazon.co.uk/Head-First-HTML-CSS-XHTML/dp/059... | The browser doesn't define a style for **all** elements, just certain ones. A simplified internal browser stylesheet might look like this:
```
a { color: blue; border-bottom: 1px solid blue }
p { margin-bottom: 1em; }
blockquote { margin: 0 5em 1em 5em; }
```
Take the following snippet of HTML as an example:
```
<u... |
498,106 | <p>I'm scripting the checkout, build, distribution, test, and commit cycle for a large C++ solution that is using <a href="http://en.wikipedia.org/wiki/Monotone_%28software%29" rel="noreferrer">Monotone</a>, <a href="http://en.wikipedia.org/wiki/CMake" rel="noreferrer">CMake</a>, Visual Studio Express 2008, and custom ... | [
{
"answer_id": 498108,
"author": "Adam Davis",
"author_id": 2915,
"author_profile": "https://Stackoverflow.com/users/2915",
"pm_score": 3,
"selected": false,
"text": "<p><a href=\"http://msdn.microsoft.com/en-us/library/ms171452.aspx\" rel=\"nofollow noreferrer\">MSBuild is your friend.<... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498106",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2242/"
] | I'm scripting the checkout, build, distribution, test, and commit cycle for a large C++ solution that is using [Monotone](http://en.wikipedia.org/wiki/Monotone_%28software%29), [CMake](http://en.wikipedia.org/wiki/CMake), Visual Studio Express 2008, and custom tests.
All of the other parts seem pretty straight-forwar... | I know of two ways to do it.
**Method 1**
The first method (which I prefer) is to use [msbuild](http://msdn.microsoft.com/en-us/library/0k6kkbsd.aspx):
```
msbuild project.sln /Flags...
```
**Method 2**
You can also run:
```
vcexpress project.sln /build /Flags...
```
The vcexpress option returns immediate... |
498,134 | <p>I am creating some html from code running on a WinForm. I want to create the following html:</p>
<pre><code><html>
<body>
<div>
<p>foo</p>
</div>
</body>
</html>
</code></pre>
<p>I'm using the System.Web.UI.HtmlTextWriter class to do this like so:</p>... | [
{
"answer_id": 498158,
"author": "David Brown",
"author_id": 31516,
"author_profile": "https://Stackoverflow.com/users/31516",
"pm_score": 3,
"selected": true,
"text": "<p>I'm not a System.Web.UI guy, but from the <a href=\"http://msdn.microsoft.com/en-us/library/y8y8wst5(VS.80).aspx\" r... | 2009/01/31 | [
"https://Stackoverflow.com/questions/498134",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52561/"
] | I am creating some html from code running on a WinForm. I want to create the following html:
```
<html>
<body>
<div>
<p>foo</p>
</div>
</body>
</html>
```
I'm using the System.Web.UI.HtmlTextWriter class to do this like so:
```
System.Web.UI.HtmlTextWriter htmlWriter = new System.Web.UI.HtmlTextWrit... | I'm not a System.Web.UI guy, but from the [MSDN documentation](http://msdn.microsoft.com/en-us/library/y8y8wst5(VS.80).aspx), it looks like you can supply the character to use for indentation as the second argument to the HtmlTextWriter constructor. Thus, to get 4 spaces instead of a tab:
```
System.Web.UI.HtmlTextWri... |