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 |
|---|---|---|---|---|---|---|
344,797 | <p>What is the best solution to build several CDT C++ projects from the command line? The projects have references and so it is not possible to just build single projects.</p>
| [
{
"answer_id": 414044,
"author": "Paulo Lopes",
"author_id": 51560,
"author_profile": "https://Stackoverflow.com/users/51560",
"pm_score": 0,
"selected": false,
"text": "<p>If you created a Make project under CDT you can just use your favorite shell and execute make in all the projects d... | 2008/12/05 | [
"https://Stackoverflow.com/questions/344797",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | What is the best solution to build several CDT C++ projects from the command line? The projects have references and so it is not possible to just build single projects. | This feature has been added in CDT 6 (Final build due June 15th 2009). You can download the final release candidate from builds page: download.eclipse.org/tools/cdt/builds/6.0.0/.
Using a release of Eclipse 3.5 + CDT 6, you can import, build and clean-build projects and the workspace using the following options sent t... |
344,801 | <p>Deletion operations seems to be the slowest in a YUI datatable. I have a datatable with > 300 rows. I need to delete selected rows. I tried removing the selected records from the <code>recordset</code> and then calling <code>table.render()</code> .. While this is okay, can it be made better?</p>
| [
{
"answer_id": 346747,
"author": "Evan Anderson",
"author_id": 40764,
"author_profile": "https://Stackoverflow.com/users/40764",
"pm_score": 2,
"selected": false,
"text": "<p>Have a look at the API docs on the \"deleteRow\" method for the datatable widget (at <a href=\"http://developer.y... | 2008/12/05 | [
"https://Stackoverflow.com/questions/344801",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Deletion operations seems to be the slowest in a YUI datatable. I have a datatable with > 300 rows. I need to delete selected rows. I tried removing the selected records from the `recordset` and then calling `table.render()` .. While this is okay, can it be made better? | Have a look at the API docs on the "deleteRow" method for the datatable widget (at <http://developer.yahoo.com/yui/docs/YAHOO.widget.DataTable.html#method_deleteRow>). This looks to me like this is what you'd want. Perhaps something like:
```
var selected = theDataTable.getSelectedRows();
var rset = theDataTable.getRe... |
344,823 | <p>On various pages throughout my PHP web site and in various nested directories I want to include a specific file at a path relative to the root.</p>
<p>What single command can I put on both of these pages...</p>
<pre>http://www.example.com/pageone.php</pre>
<pre>http://www.example.com/somedirectory/pagetwo.php</pr... | [
{
"answer_id": 344831,
"author": "Stefan Mai",
"author_id": 13257,
"author_profile": "https://Stackoverflow.com/users/13257",
"pm_score": 1,
"selected": false,
"text": "<p>Use .. to go up a directory. So in pageone.php</p>\n\n<pre><code>include 'includes/analytics.php';\n</code></pre>\n... | 2008/12/05 | [
"https://Stackoverflow.com/questions/344823",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/83/"
] | On various pages throughout my PHP web site and in various nested directories I want to include a specific file at a path relative to the root.
What single command can I put on both of these pages...
```
http://www.example.com/pageone.php
```
```
http://www.example.com/somedirectory/pagetwo.php
```
...to include th... | If you give include() or require() (or the \*\_once versions) an absolute pathname, that file will be included. An absolute pathname starts with a "/" on unix, and with a drive letter and colon on Windows.
If you give a relative path (any other path), PHP will search the directories in the configuration value "include... |
344,826 | <p>Today I'm starting a little project to create a Django based school administration program. I'm currently designing the models and their corresponding relationships. Being rather new to Django and relational databases in general, I would like some input.</p>
<p>Before I show you the current model layout, you need t... | [
{
"answer_id": 344919,
"author": "Mr Shark",
"author_id": 6093,
"author_profile": "https://Stackoverflow.com/users/6093",
"pm_score": 1,
"selected": false,
"text": "<p>From a quick look I think that its fairly comprehensive. Perhaps you should allow multiple teachers on a course, and all... | 2008/12/05 | [
"https://Stackoverflow.com/questions/344826",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33383/"
] | Today I'm starting a little project to create a Django based school administration program. I'm currently designing the models and their corresponding relationships. Being rather new to Django and relational databases in general, I would like some input.
Before I show you the current model layout, you need to have an ... | From a quick look I think that its fairly comprehensive. Perhaps you should allow multiple teachers on a course, and allow reuse of addresses/locations between parents and students.
As a general rule I would say that you should start implementing and then you will find where you need improvement. |
344,829 | <p>I got a core that looks very different from the ones I usually get - most of the threads are in __kernel_vsyscall() :</p>
<pre><code> 9 process 11334 0xffffe410 in __kernel_vsyscall ()
8 process 11453 0xffffe410 in __kernel_vsyscall ()
7 process 11454 0xffffe410 in __kernel_vsyscall ()
6 process 11455 0x... | [
{
"answer_id": 344840,
"author": "Stefan Mai",
"author_id": 13257,
"author_profile": "https://Stackoverflow.com/users/13257",
"pm_score": 3,
"selected": false,
"text": "<p>When you make a system call (like reading from a file, talking to hardware, writing to sockets) you're actually crea... | 2008/12/05 | [
"https://Stackoverflow.com/questions/344829",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/779/"
] | I got a core that looks very different from the ones I usually get - most of the threads are in \_\_kernel\_vsyscall() :
```
9 process 11334 0xffffe410 in __kernel_vsyscall ()
8 process 11453 0xffffe410 in __kernel_vsyscall ()
7 process 11454 0xffffe410 in __kernel_vsyscall ()
6 process 11455 0xffffe410 in... | `__kernel_vsyscal` is the method used by linux-gate.so (a part of the Linux kernel) to make a system call using the fastest available method, preferably the `sysenter` instruction. The thing is properly explained by [Johan Petersson](http://www.trilithium.com/johan/2005/08/linux-gate). |
344,845 | <p>I am regularly required to compare data sent to me in Excel spreadsheets with data that lives in SQL Server. I know that you can connect SQL Server to spreadsheets but it always seemed clunky</p>
<p>This is really a post to show off my solution but I would love to hear other peoples ideas.</p>
| [
{
"answer_id": 344846,
"author": "wcm",
"author_id": 2173,
"author_profile": "https://Stackoverflow.com/users/2173",
"pm_score": 3,
"selected": true,
"text": "<p>For best results, paste the below code into a module in your personal.xls file. You will need to add a reference to the Micro... | 2008/12/05 | [
"https://Stackoverflow.com/questions/344845",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2173/"
] | I am regularly required to compare data sent to me in Excel spreadsheets with data that lives in SQL Server. I know that you can connect SQL Server to spreadsheets but it always seemed clunky
This is really a post to show off my solution but I would love to hear other peoples ideas. | For best results, paste the below code into a module in your personal.xls file. You will need to add a reference to the Microsoft Forms 2.0 Object Library.
When you run this routine, it takes the currently highlighted region and creates an XML string. It also creates the TSQL to convert that XML into a temporary table... |
344,851 | <p>I added a <code>get_absolute_url</code> function to one of my models.</p>
<pre><code>def get_absolute_url(self):
return '/foo/bar'
</code></pre>
<p>The admin site picks it up and adds a "view on site" link to the detail page for that object (when I put a real URL there instead of "/foo/bar").</p>
<p>The prob... | [
{
"answer_id": 344909,
"author": "Alex Koshelev",
"author_id": 19772,
"author_profile": "https://Stackoverflow.com/users/19772",
"pm_score": 6,
"selected": true,
"text": "<p>You have to change <a href=\"http://docs.djangoproject.com/en/dev/ref/contrib/sites/#ref-contrib-sites\" rel=\"nor... | 2008/12/05 | [
"https://Stackoverflow.com/questions/344851",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/437/"
] | I added a `get_absolute_url` function to one of my models.
```
def get_absolute_url(self):
return '/foo/bar'
```
The admin site picks it up and adds a "view on site" link to the detail page for that object (when I put a real URL there instead of "/foo/bar").
The problem is instead of going to `http://localhost... | You have to change [default site](http://docs.djangoproject.com/en/dev/ref/contrib/sites/#ref-contrib-sites) domain value. |
344,856 | <p>I have a form action that needs to have its value set from a variable. I need to set the variable once and it will be reflected many times throughout the DOM.</p>
<p>So:</p>
<p>variable = "somthing.html";
...
</p>
| [
{
"answer_id": 344869,
"author": "Mitchel Sellers",
"author_id": 13279,
"author_profile": "https://Stackoverflow.com/users/13279",
"pm_score": 2,
"selected": false,
"text": "<p>You can then change the form action to be equal to the variable name. Something like the following.</p>\n\n<pr... | 2008/12/05 | [
"https://Stackoverflow.com/questions/344856",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4444/"
] | I have a form action that needs to have its value set from a variable. I need to set the variable once and it will be reflected many times throughout the DOM.
So:
variable = "somthing.html";
... | This will cause all FORMs to get the variable action:
```
<script src="jquery-1.2.6.pack.js"></script>
<script>
$(document).ready(function() {
var variable = "something.html";
$('form').attr("action", variable);
});
</script>
``` |
344,881 | <p>I'm doing some straight up asynchronous calls from javascript using the XMLHTTPRequest object. On success, with certain return values, I would like to do an asynchonous post back on an update panel and run some server side methods. This is about how I'm implementing it now:</p>
<pre><code><script language="java... | [
{
"answer_id": 344903,
"author": "Aaron Powell",
"author_id": 11388,
"author_profile": "https://Stackoverflow.com/users/11388",
"pm_score": 3,
"selected": true,
"text": "<p>Be very careful with UpdatePanels, they can be very heavy if not used properly as I explain <a href=\"http://www.aa... | 2008/12/05 | [
"https://Stackoverflow.com/questions/344881",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18893/"
] | I'm doing some straight up asynchronous calls from javascript using the XMLHTTPRequest object. On success, with certain return values, I would like to do an asynchonous post back on an update panel and run some server side methods. This is about how I'm implementing it now:
```
<script language="javascript">
fun... | Be very careful with UpdatePanels, they can be very heavy if not used properly as I explain [here](http://www.aaron-powell.com/blog.aspx?id=1195).
But the JavaScript for submitting a form is:
```
__doPostBack('eventTarget','eventArguments');
```
So in your example you'd have something like:
```
__doPostBack('<%= b... |
344,906 | <p>I thought it is a very simple task to export data in a view from SQL Server 2005 to a fixed width text file. But the wizard is a pain. The format is not correct. Does anybody know how to deal with it? or any better way to do that?</p>
| [
{
"answer_id": 344985,
"author": "HLGEM",
"author_id": 9034,
"author_profile": "https://Stackoverflow.com/users/9034",
"pm_score": 0,
"selected": false,
"text": "<p>If the format from the wizard doesn't suit your needs, you will need to develop your own SSIS package. Are you sure you rea... | 2008/12/05 | [
"https://Stackoverflow.com/questions/344906",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31689/"
] | I thought it is a very simple task to export data in a view from SQL Server 2005 to a fixed width text file. But the wizard is a pain. The format is not correct. Does anybody know how to deal with it? or any better way to do that? | Use bcp with queryout option
<http://msdn.microsoft.com/en-us/library/ms162802(SQL.90).aspx>
```
bcp "SELECT * FROM AdventureWorks.Person.Contact" queryout Contacts.txt -c -T
```
Use a format file if you want fixed-width output
<http://weblogs.sqlteam.com/brettk/archive/2006/07/06/10504.aspx>
I just tried exportin... |
344,924 | <p>I did this in the past, and can't remember the correct command (I think I was using instring or soemthign?)</p>
<p>I want to list all the windows services running that have the word 'sql' in them.</p>
<p>Listing all the windows services is:</p>
<pre><code>Get-Service
</code></pre>
<p>Is there a instring function... | [
{
"answer_id": 344933,
"author": "Steven Murawski",
"author_id": 1233,
"author_profile": "https://Stackoverflow.com/users/1233",
"pm_score": 6,
"selected": true,
"text": "<pre><code>Get-Service -Name *sql*\n</code></pre>\n\n<p>A longer alternative would be:</p>\n\n<pre><code>Get-Service ... | 2008/12/05 | [
"https://Stackoverflow.com/questions/344924",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39677/"
] | I did this in the past, and can't remember the correct command (I think I was using instring or soemthign?)
I want to list all the windows services running that have the word 'sql' in them.
Listing all the windows services is:
```
Get-Service
```
Is there a instring function that does this? | ```
Get-Service -Name *sql*
```
A longer alternative would be:
```
Get-Service | where-object {$_.name -like '*sql*'}
```
Many cmdlets offer built in filtering and support wildcards. If you check the help files (Get-Help Get-Service -full), you will see
```
-name <string[]>
Specifies the service names of se... |
344,934 | <p>I'd like one of my table rows to be a button that takes up an entire row of my UITableView. I figured the best way to go about this is to instantiate a UIButton, and give it the same frame size as an instance of UITableViewCell, and add that as a subview to the cell. I'm almost there, but quite a few pixels off to n... | [
{
"answer_id": 345062,
"author": "Ryan Townshend",
"author_id": 24707,
"author_profile": "https://Stackoverflow.com/users/24707",
"pm_score": 4,
"selected": false,
"text": "<p>You can fake it in your didSelectRowAtIndexPath: method.\nHave the tableView cell act as the button.</p>\n\n<pre... | 2008/12/05 | [
"https://Stackoverflow.com/questions/344934",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40882/"
] | I'd like one of my table rows to be a button that takes up an entire row of my UITableView. I figured the best way to go about this is to instantiate a UIButton, and give it the same frame size as an instance of UITableViewCell, and add that as a subview to the cell. I'm almost there, but quite a few pixels off to not ... | You can fake it in your didSelectRowAtIndexPath: method.
Have the tableView cell act as the button.
```
[[[self tableView] cellForRowAtIndexPath:indexPath] setSelected:YES animated:YES];
[self doStuff];
[[[self tableView] cellForRowAtIndexPath:indexPath] setSelected:NO animated:YES];
```
Use `setSelected: animated:`... |
344,961 | <p>I'm trying to remember how the math is worked out to compute the remainder of an XOR algorithm in Cyclical Redundancy Checks to verify the remainder bits of a network message.</p>
<p>I shouldn't have tossed that text book.</p>
<p>This is easily done in code, but how is it worked out by hand?</p>
<p>I know it look... | [
{
"answer_id": 344982,
"author": "Rasmus Faber",
"author_id": 5542,
"author_profile": "https://Stackoverflow.com/users/5542",
"pm_score": 2,
"selected": true,
"text": "<p>It is long division by binary 11. There is an example on <a href=\"http://en.wikipedia.org/wiki/Computation_of_CRC\" ... | 2008/12/05 | [
"https://Stackoverflow.com/questions/344961",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34183/"
] | I'm trying to remember how the math is worked out to compute the remainder of an XOR algorithm in Cyclical Redundancy Checks to verify the remainder bits of a network message.
I shouldn't have tossed that text book.
This is easily done in code, but how is it worked out by hand?
I know it looks something like a stand... | It is long division by binary 11. There is an example on [Wikipedia](http://en.wikipedia.org/wiki/Computation_of_CRC). |
344,963 | <p>I'm trying to use the freeware <a href="http://www.nontube.com/products/multiple-find-and-replace/" rel="nofollow noreferrer">Multiple Find And Replace 1.00</a> suggested in <a href="https://stackoverflow.com/questions/268045/multi-line-search-and-replace-tool#272325">this question</a>.</p>
<p><a href="http://www.n... | [
{
"answer_id": 344974,
"author": "Cory Foy",
"author_id": 4083,
"author_profile": "https://Stackoverflow.com/users/4083",
"pm_score": 2,
"selected": false,
"text": "<p><code>dir /S /B *.php</code></p>\n"
},
{
"answer_id": 344980,
"author": "Brett",
"author_id": 43778,
... | 2008/12/05 | [
"https://Stackoverflow.com/questions/344963",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/83/"
] | I'm trying to use the freeware [Multiple Find And Replace 1.00](http://www.nontube.com/products/multiple-find-and-replace/) suggested in [this question](https://stackoverflow.com/questions/268045/multi-line-search-and-replace-tool#272325).
[Multiple Find And Replace 1.00 http://www.nontube.com/images/screenshot-mfar.p... | You can use built-in DOS commands like so:
```
cd /d "[base-directory]" && dir /s /b *.php > [list file]
```
e.g.
```
cd /d "c:\my files" && dir /s /b *.php > c:\list.txt
``` |
344,964 | <p>I have a binary field in my database that is hard to describe in a UI using a single "Is XXXX?"-type checkbox. I'd rather use a pair of radio buttons (e.g. "Do it the Foo way" and "Do it the Bar way"), but right now all the other fields on my form are data-bound to a business object. I'd like to data-bind the pair... | [
{
"answer_id": 345353,
"author": "Excel Kobayashi",
"author_id": 42911,
"author_profile": "https://Stackoverflow.com/users/42911",
"pm_score": -1,
"selected": false,
"text": "<p>You should only have to bind one of the controls as long as you make sure they are in the same group.</p>\n\n<... | 2008/12/05 | [
"https://Stackoverflow.com/questions/344964",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26286/"
] | I have a binary field in my database that is hard to describe in a UI using a single "Is XXXX?"-type checkbox. I'd rather use a pair of radio buttons (e.g. "Do it the Foo way" and "Do it the Bar way"), but right now all the other fields on my form are data-bound to a business object. I'd like to data-bind the pair of r... | I have found a way of doing this using DataSet/DataTable.
I make a calculated column in the DataTable with the expression `IIF(Foo=true, false, true)`. Let's call that column `Bar`.
`Bar` is of type Boolean. Now you can bind one `RadioButton.Checked` to `Foo` and one to `Bar`.
To get `Bar` checking/unchecking to pro... |
344,965 | <p>I need to have a <code>staticText</code> to float below another element with variable height. I'm taking a sample from the book <code>JasperReports for Java Programmers</code>. It says that it's possible to do it. The difference with my sample is that I use a hard coded string in <code>textFieldExpression</code>, th... | [
{
"answer_id": 359114,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": false,
"text": "<p><a href=\"https://stackoverflow.com/questions/353928/jasperreports-subreports-not-working-with-positiontypefloat#359092\">T... | 2008/12/05 | [
"https://Stackoverflow.com/questions/344965",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I need to have a `staticText` to float below another element with variable height. I'm taking a sample from the book `JasperReports for Java Programmers`. It says that it's possible to do it. The difference with my sample is that I use a hard coded string in `textFieldExpression`, they use a $F{} field.
```xml
<textFi... | [This answer](https://stackoverflow.com/questions/353928/jasperreports-subreports-not-working-with-positiontypefloat#359092) applies (different elements, same situation).
One thing I didn't take right from the book's sample is that the textField's declared height (24) is less than the actual height when the element is... |
344,966 | <p>I want to override the bad default tabbing scheme in emacs so that it will work like most other editors (eclipse, notepad++). I want to set it so that regardless of mode, tab will insert a tab, and pressing enter will keep me at my current tab depth.</p>
<p>I tried this, but it does nothing:</p>
<pre><code>(global... | [
{
"answer_id": 344970,
"author": "J Cooper",
"author_id": 38803,
"author_profile": "https://Stackoverflow.com/users/38803",
"pm_score": 1,
"selected": false,
"text": "<p><code>C-j</code> does the newline + indent functionality that you want out of pressing Enter.</p>\n"
},
{
"ans... | 2008/12/05 | [
"https://Stackoverflow.com/questions/344966",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40397/"
] | I want to override the bad default tabbing scheme in emacs so that it will work like most other editors (eclipse, notepad++). I want to set it so that regardless of mode, tab will insert a tab, and pressing enter will keep me at my current tab depth.
I tried this, but it does nothing:
```
(global-set-key (kbd "TAB") ... | To make the Enter key take you to the next line and indent it automatically, you can put
```
(global-set-key (kbd "RET") 'newline-and-indent)
```
in your `.emacs`. [Or you can hit `C-j` instead of Enter.] Once you have that, you'll never need to insert tabs manually, because Emacs automatically indents a new line to... |
344,998 | <p>Can we access div tags of user control in Master page? I am trying to change the background color for each one of the div tags on some event.</p>
| [
{
"answer_id": 345000,
"author": "Mitchel Sellers",
"author_id": 13279,
"author_profile": "https://Stackoverflow.com/users/13279",
"pm_score": 0,
"selected": false,
"text": "<p>The best way is to make a public property in the user control that you can then set directly from the masterpag... | 2008/12/05 | [
"https://Stackoverflow.com/questions/344998",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21918/"
] | Can we access div tags of user control in Master page? I am trying to change the background color for each one of the div tags on some event. | Something like this should work (in C#):
```
Control myControl = this.Page.Master.FindControl("[Your name here]");
```
Then you can do whatever you would like to the control. If it's a Panel control (for the div) you can cast it that way, or if you are using an HTML server side control, you can cast it that way. |
345,009 | <p>I'm building a demo app in WPF, which is new to me. I'm currently displaying text in a FlowDocument, and need to print it.</p>
<p>The code I'm using looks like this:</p>
<pre><code> PrintDialog pd = new PrintDialog();
fd.PageHeight = pd.PrintableAreaHeight;
fd.PageWidth = pd.PrintableAreaWi... | [
{
"answer_id": 353194,
"author": "Nir",
"author_id": 3509,
"author_profile": "https://Stackoverflow.com/users/3509",
"pm_score": 3,
"selected": false,
"text": "<p>You can use the code from the URL below, it wraps the flow document in a fixed document and prints that, the big advantage is... | 2008/12/05 | [
"https://Stackoverflow.com/questions/345009",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1338/"
] | I'm building a demo app in WPF, which is new to me. I'm currently displaying text in a FlowDocument, and need to print it.
The code I'm using looks like this:
```
PrintDialog pd = new PrintDialog();
fd.PageHeight = pd.PrintableAreaHeight;
fd.PageWidth = pd.PrintableAreaWidth;
fd.PagePa... | yes, make a copy of the FlowDocument before printing it. This is because the pagination and margins will be different. This works for me.
```
private void DoThePrint(System.Windows.Documents.FlowDocument document)
{
// Clone the source document's content into a new FlowDocument.
// This is beca... |
345,010 | <p>Does combining an Enterprise Messaging solution with Web Services result in a real performance gain over simple HTTP requests over sockets?</p>
<p>(if implementation details will help, interested in JMS with a SOAP webservice)</p>
| [
{
"answer_id": 353194,
"author": "Nir",
"author_id": 3509,
"author_profile": "https://Stackoverflow.com/users/3509",
"pm_score": 3,
"selected": false,
"text": "<p>You can use the code from the URL below, it wraps the flow document in a fixed document and prints that, the big advantage is... | 2008/12/05 | [
"https://Stackoverflow.com/questions/345010",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2362/"
] | Does combining an Enterprise Messaging solution with Web Services result in a real performance gain over simple HTTP requests over sockets?
(if implementation details will help, interested in JMS with a SOAP webservice) | yes, make a copy of the FlowDocument before printing it. This is because the pagination and margins will be different. This works for me.
```
private void DoThePrint(System.Windows.Documents.FlowDocument document)
{
// Clone the source document's content into a new FlowDocument.
// This is beca... |
345,025 | <p>I have an XML document looking similar to this:</p>
<pre><code><items>
<item cat="1" owner="14">bla</item>
<item cat="1" owner="9">bla</item>
<item cat="1" owner="14">bla</item>
<item cat="2" owner="12">bla</item>
<item cat="2" owner="12">bla</item... | [
{
"answer_id": 345109,
"author": "Jennifer",
"author_id": 22360,
"author_profile": "https://Stackoverflow.com/users/22360",
"pm_score": 5,
"selected": true,
"text": "<p>Presuming the fragment is in itemsElement:</p>\n\n<pre><code>var distinctOwners = (from item in itemsElement.Element(\"... | 2008/12/05 | [
"https://Stackoverflow.com/questions/345025",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16440/"
] | I have an XML document looking similar to this:
```
<items>
<item cat="1" owner="14">bla</item>
<item cat="1" owner="9">bla</item>
<item cat="1" owner="14">bla</item>
<item cat="2" owner="12">bla</item>
<item cat="2" owner="12">bla</item>
</items>
```
Now I'd like to get all unique owners (I actually only need ... | Presuming the fragment is in itemsElement:
```
var distinctOwners = (from item in itemsElement.Element("item")
where itemElements.Attribute("cat") == 1
select item.Attribute("owner")).Distinct();
```
Apologies for formatting and indentation! |
345,041 | <p>say p.products_price equals 1</p>
<p>why does:</p>
<blockquote>
<pre><code>UPDATE products p
SET p.products_price = (1 + p.products_price)
WHERE p.products_id = 8
</code></pre>
</blockquote>
<p>make p.products_price equals 3?</p>
<p>It is adding 1 to the price and then doing it all over again? I am trying to do ... | [
{
"answer_id": 345055,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 0,
"selected": false,
"text": "<p>That should definitely set products_price to 2. There must be something else going on.</p>\n\n<p>This is similar to <a hr... | 2008/12/05 | [
"https://Stackoverflow.com/questions/345041",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15000/"
] | say p.products\_price equals 1
why does:
>
>
> ```
> UPDATE products p
> SET p.products_price = (1 + p.products_price)
> WHERE p.products_id = 8
>
> ```
>
>
make p.products\_price equals 3?
It is adding 1 to the price and then doing it all over again? I am trying to do something a little more complicated but w... | ```
UPDATE products
SET products_price = (1 + products_price)
WHERE products_id = 8
```
works like it should (removed table alias 'p') |
345,042 | <p>I would like to shorten very long descriptions to the available table column width. I have the column width information in pixels. Now I would like to convert this measure to the number of characters, so I can shorten the text to the specified number.</p>
<p>I doesn't have to be 100% correct, a near assumption will... | [
{
"answer_id": 345060,
"author": "Chris Van Opstal",
"author_id": 7264,
"author_profile": "https://Stackoverflow.com/users/7264",
"pm_score": 0,
"selected": false,
"text": "<p>This is for the web? If so, why not use a simpler method like using css to hide the overflow?</p>\n"
},
{
... | 2008/12/05 | [
"https://Stackoverflow.com/questions/345042",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6482/"
] | I would like to shorten very long descriptions to the available table column width. I have the column width information in pixels. Now I would like to convert this measure to the number of characters, so I can shorten the text to the specified number.
I doesn't have to be 100% correct, a near assumption will also work... | Wrap your text in the cell in a DIV. This will tell you whether the text inside the DIV is larger than the cell:
```
<div id='test' style='width:200px;height:100px;overflow:hidden'>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Suspendisse at felis. Etiam ullamcorper. Aenean fringilla, eros eu dapibus t... |
345,045 | <p>I have a C++ DLL including bitmap resources created by Visual Studio.</p>
<p>Though I can load the DLL in VB6 using LoadLibrary, I cannot load the image resources either by using LoadImage or by using LoadBitmap. When I try to get the error using GetLastError(), it doesnot return any errors.</p>
<p>I have tried us... | [
{
"answer_id": 345110,
"author": "Joel Lucsy",
"author_id": 645,
"author_profile": "https://Stackoverflow.com/users/645",
"pm_score": 0,
"selected": false,
"text": "<p>You've got the right idea. You probably have the call wrong. Perhaps you could show a bit of code as I can't guess as to... | 2008/12/05 | [
"https://Stackoverflow.com/questions/345045",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a C++ DLL including bitmap resources created by Visual Studio.
Though I can load the DLL in VB6 using LoadLibrary, I cannot load the image resources either by using LoadImage or by using LoadBitmap. When I try to get the error using GetLastError(), it doesnot return any errors.
I have tried using LoadImage and... | Since you are using the numeric ID of the bitmap as a string, you have to add a "#" in front of it:
```
DLLHandle = LoadLibrary("Mydll.dll")
myimage = LoadBitmap(DLLHandle, "#101") ' note the "#"
```
In C++ you could also use the MAKEINTRESOURCE macro, which is simply a cast to LPCTSTR:
```
imagehandle = LoadBitma... |
345,047 | <p>A weird bug was occurring in production which I was asked to look into.<br/> The issue was tracked down to a couple of variables being declared within a For loop and not being initialized on each iteration. An assumption had been made that due to the scope of their declaration they would be "reset" on each... | [
{
"answer_id": 345150,
"author": "Victor",
"author_id": 42518,
"author_profile": "https://Stackoverflow.com/users/42518",
"pm_score": 0,
"selected": false,
"text": "<p>Were you getting a NullReferenceException error?</p>\n\n<p>From the code above you would get that error on every odd num... | 2008/12/05 | [
"https://Stackoverflow.com/questions/345047",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12875/"
] | A weird bug was occurring in production which I was asked to look into.
The issue was tracked down to a couple of variables being declared within a For loop and not being initialized on each iteration. An assumption had been made that due to the scope of their declaration they would be "reset" on each iteration.
... | **Most** of the time, it does not matter whether you declare a variable inside or outside the loop; the rules of definite assignment ensure that it doesn't matter. In the debugger you might occasionally see old values (i.e. if you look at a variable in a breakpoint before it is assigned), but static-analysis proves tha... |
345,091 | <p>I'm reviewing some code for a friend and say that he was using a return statement inside of a try-finally block. Does the code in the Finally section still fire even though the rest of the try block doesn't?</p>
<p>Example:</p>
<pre><code>public bool someMethod()
{
try
{
return true;
throw new Excepti... | [
{
"answer_id": 345095,
"author": "Andrew Rollings",
"author_id": 40410,
"author_profile": "https://Stackoverflow.com/users/40410",
"pm_score": 9,
"selected": true,
"text": "<p>Simple answer: Yes.</p>\n"
},
{
"answer_id": 345103,
"author": "mmx",
"author_id": 33708,
"a... | 2008/12/05 | [
"https://Stackoverflow.com/questions/345091",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28540/"
] | I'm reviewing some code for a friend and say that he was using a return statement inside of a try-finally block. Does the code in the Finally section still fire even though the rest of the try block doesn't?
Example:
```
public bool someMethod()
{
try
{
return true;
throw new Exception("test"); // doesn't... | Simple answer: Yes. |
345,133 | <p>Applications I am using:
Visual Studio 2008 (C#/ASP.NET)
Visual Source Safe 8.0
IIS 5.1</p>
<p>I have two Web Apps both named the same but one is used for major releases and the other is for minor (trunk and branch). I am wondering if there is an option in Visual Studio that prevents it from creating an ASP.NET app... | [
{
"answer_id": 345155,
"author": "Ricardo Villamil",
"author_id": 19314,
"author_profile": "https://Stackoverflow.com/users/19314",
"pm_score": 2,
"selected": true,
"text": "<p>Instead of having HTTP based projects in your visual studio solution, add them as file projects, where the webs... | 2008/12/05 | [
"https://Stackoverflow.com/questions/345133",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43792/"
] | Applications I am using:
Visual Studio 2008 (C#/ASP.NET)
Visual Source Safe 8.0
IIS 5.1
I have two Web Apps both named the same but one is used for major releases and the other is for minor (trunk and branch). I am wondering if there is an option in Visual Studio that prevents it from creating an ASP.NET app in IIS us... | Instead of having HTTP based projects in your visual studio solution, add them as file projects, where the website will be accessed as c:\inetput\wwwroot\major\_version (for example) in visual studio (and not <http://localhost>). That way you can have any kind of setup you want in IIS and your projects won't conflict w... |
345,147 | <p>i'm trying to send fake keyboard input to an application that's running in a Remote Desktop session. i'm using:</p>
<pre><code>Byte key = Ord("A");
keybd_event(key, 0, 0, 0); // key goes down
keybd_event(key, 0, KEYEVENTF_KEYUP, 0); // key goes up
</code></pre>
<p>Now this code does send the character "a" to any ... | [
{
"answer_id": 345167,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 2,
"selected": false,
"text": "<p>May be you can execute an <a href=\"http://www.autoitscript.com/autoit3/\" rel=\"nofollow noreferrer\">autoit</a> script wit... | 2008/12/05 | [
"https://Stackoverflow.com/questions/345147",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12597/"
] | i'm trying to send fake keyboard input to an application that's running in a Remote Desktop session. i'm using:
```
Byte key = Ord("A");
keybd_event(key, 0, 0, 0); // key goes down
keybd_event(key, 0, KEYEVENTF_KEYUP, 0); // key goes up
```
Now this code does send the character "a" to any local window, but it will ... | Answer
------
Although Microsft says you don't need to, [and you should not](http://msdn.microsoft.com/en-us/library/aa453245.aspx), send the OEM code, you need to send the OEM scan codes. In this example i need to send the OEM scan codes for
* key A goes down
* key A goes up
There is a [picture of a chart on CodePr... |
345,157 | <p>I redirect the user to the login page when user click log out however I don't think it clears any application or session because all the data persisted when the user logs back in.</p>
<p>Currently the login page has a login control and the code behind on the page is only wired up the login Authenticate.</p>
<p>Can... | [
{
"answer_id": 345161,
"author": "BobbyShaftoe",
"author_id": 38426,
"author_profile": "https://Stackoverflow.com/users/38426",
"pm_score": 0,
"selected": false,
"text": "<p>Session.Clear();</p>\n"
},
{
"answer_id": 345164,
"author": "Ryan Cook",
"author_id": 43029,
"... | 2008/12/05 | [
"https://Stackoverflow.com/questions/345157",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28647/"
] | I redirect the user to the login page when user click log out however I don't think it clears any application or session because all the data persisted when the user logs back in.
Currently the login page has a login control and the code behind on the page is only wired up the login Authenticate.
Can someone direct m... | ```
Session.Abandon()
```
<http://msdn.microsoft.com/en-us/library/ms524310.aspx>
Here is a little more detail on the `HttpSessionState` object:
<http://msdn.microsoft.com/en-us/library/system.web.sessionstate.httpsessionstate_members.aspx> |
345,174 | <p>I need to be able to determine when <code>ContainsFocus</code> changes on a <code>Control</code> (specifically a windows form). Overriding <code>OnGotFocus</code> is not the answer. When I bring the form to the foreground, <code>ContainsFocus</code> is true and <code>Focused</code> is false. So is there an <code>OnG... | [
{
"answer_id": 345177,
"author": "Mike Hall",
"author_id": 18202,
"author_profile": "https://Stackoverflow.com/users/18202",
"pm_score": 1,
"selected": false,
"text": "<p>One way to solve this is to use a Timer. It's definitely brute force, but it gets the job done:</p>\n\n<pre><code>pri... | 2008/12/05 | [
"https://Stackoverflow.com/questions/345174",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18202/"
] | I need to be able to determine when `ContainsFocus` changes on a `Control` (specifically a windows form). Overriding `OnGotFocus` is not the answer. When I bring the form to the foreground, `ContainsFocus` is true and `Focused` is false. So is there an `OnGotFocus` equivalent for `ContainsFocus`? Or any other way? | Note: GotFocus events of the child controls are fired if you have a child control. Otherwise OnGotFocus of the form is called.
If I understood the question correctly, then this should work:
```
bool lastNotificationWasGotFocus = false;
protected override void OnControlAdded(ControlEventArgs e)
{
... |
345,178 | <p>I can do this:</p>
<pre><code>Dim fso As New FileSystemObject
</code></pre>
<p>or I can do this:</p>
<pre><code>Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
</code></pre>
<p>How do I know what string to use for CreateObject? For example, how would I know to use the "Scripting." part of ... | [
{
"answer_id": 345184,
"author": "huseyint",
"author_id": 39,
"author_profile": "https://Stackoverflow.com/users/39",
"pm_score": 6,
"selected": true,
"text": "<p>It is the <a href=\"http://www.vbaccelerator.com/progid.htm\" rel=\"noreferrer\">ProgID</a> of the component which is registe... | 2008/12/05 | [
"https://Stackoverflow.com/questions/345178",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16415/"
] | I can do this:
```
Dim fso As New FileSystemObject
```
or I can do this:
```
Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
```
How do I know what string to use for CreateObject? For example, how would I know to use the "Scripting." part of "Scripting.FileSystemObject"? Where do you go to ... | It is the [ProgID](http://www.vbaccelerator.com/progid.htm) of the component which is registered in Windows registry under HKCR key:
```none
HKEY_CLASSES_ROOT\Scripting.FileSystemObject
```
ProgID's are human readable identifiers for COM objects. They point to the actual CLSIDs, which in this case is:
```none
HKEY_... |
345,179 | <p>I am writing a deployment script using MSBuild. I want to clean my web directories prior to copying all the new files in. My current "Clean" target looks like this:</p>
<pre><code> <Target Name="Clean">
<Exec Command="del %(DeploymentSet.LocalWebRoot)\* /Q /F /S" IgnoreExitCode="true" />
</Targ... | [
{
"answer_id": 345202,
"author": "Patrick Cuff",
"author_id": 7903,
"author_profile": "https://Stackoverflow.com/users/7903",
"pm_score": 2,
"selected": true,
"text": "<p>You can <code>rmdir /s /q</code> each sub-directory individually, then <code>del %(DeploymentSet.LocalWebRoot)\\* /Q ... | 2008/12/05 | [
"https://Stackoverflow.com/questions/345179",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/303/"
] | I am writing a deployment script using MSBuild. I want to clean my web directories prior to copying all the new files in. My current "Clean" target looks like this:
```
<Target Name="Clean">
<Exec Command="del %(DeploymentSet.LocalWebRoot)\* /Q /F /S" IgnoreExitCode="true" />
</Target>
```
This takes an consi... | You can `rmdir /s /q` each sub-directory individually, then `del %(DeploymentSet.LocalWebRoot)\* /Q /F` your clean target. For example:
```
<Target Name="Clean">
<Exec Command="rmdir %(DeploymentSet.LocalWebRoot)\subdir1 /Q /S" IgnoreExitCode="true" />
<Exec Command="rmdir %(DeploymentSet.LocalWebRoot)\subdir... |
345,180 | <p>I wrote a DLL in .NET and I want to access it in VBScript. I don't want to add it to the assembly directory. </p>
<p>Is there a way to point too the DLL and create an instance of it?</p>
| [
{
"answer_id": 345196,
"author": "mmx",
"author_id": 33708,
"author_profile": "https://Stackoverflow.com/users/33708",
"pm_score": 1,
"selected": false,
"text": "<p>Not directly. You'll need a COM Callable Wrapper to any .NET library you'll calling from COM (and hence, VBScript). Therefo... | 2008/12/05 | [
"https://Stackoverflow.com/questions/345180",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1231/"
] | I wrote a DLL in .NET and I want to access it in VBScript. I don't want to add it to the assembly directory.
Is there a way to point too the DLL and create an instance of it? | You can register that .NET dll with [regasm utility](http://msdn.microsoft.com/en-us/library/tzat5yw6.aspx) by specifying `/codebase` parameter. This parameter is not encouraged to use with unsigned assemblies but it works when you can not put your assembly into GAC.
```
regasm your.dll /codebase
```
Please note tha... |
345,185 | <p>Check out this test:</p>
<pre><code>[TestFixture]
public class Quick_test
{
[Test]
public void Test()
{
Assert.AreEqual(0, GetByYield().Count());
Assert.AreEqual(0, GetByEnumerable().Count());
}
private IEnumerable<string> GetByYield()
{
yield break;
}
private IEnum... | [
{
"answer_id": 345200,
"author": "leppie",
"author_id": 15541,
"author_profile": "https://Stackoverflow.com/users/15541",
"pm_score": 1,
"selected": false,
"text": "<p>Even faster might be:</p>\n\n<pre><code>T[] e = {};\nreturn e;\n</code></pre>\n"
},
{
"answer_id": 345265,
"... | 2008/12/05 | [
"https://Stackoverflow.com/questions/345185",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2595/"
] | Check out this test:
```
[TestFixture]
public class Quick_test
{
[Test]
public void Test()
{
Assert.AreEqual(0, GetByYield().Count());
Assert.AreEqual(0, GetByEnumerable().Count());
}
private IEnumerable<string> GetByYield()
{
yield break;
}
private IEnumerable<string> GetBy... | I would prefer any method that delivers the clearest meaning to the developer. Personally, I don't even know what the ***yield break;*** line is does, so returning 'Enumerable.Empty();` would be preferred in any of my code bases. |
345,187 | <p>How do I map numbers, linearly, between a and b to go between c and d.</p>
<p>That is, I want numbers between 2 and 6 to map to numbers between 10 and 20... but I need the generalized case.</p>
<p>My brain is fried.</p>
| [
{
"answer_id": 345203,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 5,
"selected": false,
"text": "<p>Divide to get the ratio between the sizes of the two ranges, then subtract the starting value of your inital range... | 2008/12/05 | [
"https://Stackoverflow.com/questions/345187",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43005/"
] | How do I map numbers, linearly, between a and b to go between c and d.
That is, I want numbers between 2 and 6 to map to numbers between 10 and 20... but I need the generalized case.
My brain is fried. | If your number X falls between A and B, and you would like Y to fall between C and D, you can apply the following linear transform:
```
Y = (X-A)/(B-A) * (D-C) + C
```
That should give you what you want, although your question is a little ambiguous, since you could also map the interval in the reverse direction. Jus... |
345,198 | <p>I want to set the backgroun color for a GridViewColumn that is databound inside of a listview in WPF. I'm not sure how to ask this question being fairly new to WPF, otherwise I wouldn't have bothered all of you.</p>
<p>I want to change the background color of the whole row, based on a bool flag in my databound obje... | [
{
"answer_id": 345260,
"author": "Bryan Anderson",
"author_id": 21186,
"author_profile": "https://Stackoverflow.com/users/21186",
"pm_score": 2,
"selected": false,
"text": "<p>I haven't tested this yet so it might need some tweaks but you're going to want to trigger off the value to set ... | 2008/12/05 | [
"https://Stackoverflow.com/questions/345198",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32772/"
] | I want to set the backgroun color for a GridViewColumn that is databound inside of a listview in WPF. I'm not sure how to ask this question being fairly new to WPF, otherwise I wouldn't have bothered all of you.
I want to change the background color of the whole row, based on a bool flag in my databound object.
In th... | I ran into a few troubles trying to do this, ended up like so
```
<ListBox ...>
<ListBox.ItemTemplate>
<DataTemplate>
<Border x:Name="BGBorder">
<!-- -->
</Border>
<DataTemplate.Triggers>
<DataTrigger
Binding="{Binding Path=DataContext.IsAborted, RelativeSource={Rel... |
345,199 | <p>I need to watch when certain processes are started or stopped on a Windows machine. I'm currently tapped into the WMI system and querying it every 5 seconds, but this causes a CPU spike every 5 seconds because WMI is WMI. Is there a better way of doing this? I could just make a list of running processes and attach a... | [
{
"answer_id": 345836,
"author": "denis phillips",
"author_id": 748,
"author_profile": "https://Stackoverflow.com/users/748",
"pm_score": 2,
"selected": true,
"text": "<p>This is not exactly how you'd do it in the real world but should help. This seems not to drive my CPU much at all.</p... | 2008/12/05 | [
"https://Stackoverflow.com/questions/345199",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I need to watch when certain processes are started or stopped on a Windows machine. I'm currently tapped into the WMI system and querying it every 5 seconds, but this causes a CPU spike every 5 seconds because WMI is WMI. Is there a better way of doing this? I could just make a list of running processes and attach an E... | This is not exactly how you'd do it in the real world but should help. This seems not to drive my CPU much at all.
```
static void Main(string[] args)
{
// Getting all instances of notepad
// (this is only done once here so start up some notepad instances first)
// you may want use GetP... |
345,225 | <p>I have a (varchar) field Foo which can only be specified if (bit) Bar is <em>not</em> true. I would like the textbox in which Foo is displayed to be <em>disabled</em> when Bar is true -- essentially, <code>FooBox.Enabled = !isBar</code>. I'm trying to do something like</p>
<pre><code>FooBox.DataBindings.Add(new B... | [
{
"answer_id": 345237,
"author": "FlySwat",
"author_id": 1965,
"author_profile": "https://Stackoverflow.com/users/1965",
"pm_score": 2,
"selected": false,
"text": "<p>As far as I can tell, Databind uses reflection to find the member passed as the 3rd string argument. You cannot pass an e... | 2008/12/05 | [
"https://Stackoverflow.com/questions/345225",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26286/"
] | I have a (varchar) field Foo which can only be specified if (bit) Bar is *not* true. I would like the textbox in which Foo is displayed to be *disabled* when Bar is true -- essentially, `FooBox.Enabled = !isBar`. I'm trying to do something like
```
FooBox.DataBindings.Add(new Binding("Enabled", source, "!isBar"));
``... | I tried doing something like this a while ago and the best I could come up with was either
a) Changing the source class to also have a NotBar property and bind to that
b) Make a dumb wrapper class around source that has a NotBar property and bind to that. |
345,281 | <p>Is there a command-line argument that would force firefox.exe to launch a new process for a particular URL regardless of whether another instance of firefox is already running?</p>
| [
{
"answer_id": 345300,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 1,
"selected": false,
"text": "<p>Yes, as detailed in <a href=\"http://kb.mozillazine.org/Command_line_arguments\" rel=\"nofollow noreferrer\">Firefox Comma... | 2008/12/05 | [
"https://Stackoverflow.com/questions/345281",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10026/"
] | Is there a command-line argument that would force firefox.exe to launch a new process for a particular URL regardless of whether another instance of firefox is already running? | If you have a second profile (like 'sidekick'), the following will launch a new Firefox process:
```
firefox.exe -no-remote -p sidekick
```
However, if that profile is already used by a current Firefox session, that will not work.
To create a new profile launch Firefox from the command line with the -P flag and cre... |
345,315 | <p>A listbox is passed, the data placed in an array, the array is sort and then the data is placed back in the listbox. The part that does work is putting the data back in the listbox. Its like the listbox is being passed by value instead of by ref.</p>
<p>Here's the sub that does the sort and the line of code that c... | [
{
"answer_id": 345476,
"author": "GSerg",
"author_id": 11683,
"author_profile": "https://Stackoverflow.com/users/11683",
"pm_score": 0,
"selected": false,
"text": "<p>You can't pass objects by value. Since you're not going to return another instance of listbox to the caller, you should d... | 2008/12/05 | [
"https://Stackoverflow.com/questions/345315",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | A listbox is passed, the data placed in an array, the array is sort and then the data is placed back in the listbox. The part that does work is putting the data back in the listbox. Its like the listbox is being passed by value instead of by ref.
Here's the sub that does the sort and the line of code that calls the so... | This works for me on Excel 2003 on a very basic UserForm with a single ListBox called ListBox1:
```
Private Sub UserForm_Initialize()
ListBox1.AddItem "john"
ListBox1.AddItem "paul"
ListBox1.AddItem "george"
ListBox1.AddItem "ringo"
SortListBox ListBox1
End Sub
```
and then your SortListBox as written apart from ... |
345,318 | <p>What is the best design decision for a 'top-level' class to attach to an event to a class that may be '5+ layers down in the callstack?</p>
<p>For example, perhaps the MainForm has spawned an object, and that object has spawned a callstack of several other object calls. The most obvious way would be to chain the e... | [
{
"answer_id": 345349,
"author": "eulerfx",
"author_id": 13855,
"author_profile": "https://Stackoverflow.com/users/13855",
"pm_score": 0,
"selected": false,
"text": "<p>My initial intention would be to try and avoid that, so that an object's scope has obvious boundaries. In the particula... | 2008/12/05 | [
"https://Stackoverflow.com/questions/345318",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43823/"
] | What is the best design decision for a 'top-level' class to attach to an event to a class that may be '5+ layers down in the callstack?
For example, perhaps the MainForm has spawned an object, and that object has spawned a callstack of several other object calls. The most obvious way would be to chain the event up the... | If your application isn't based on Composite UI Application Blocks, the easiest solution is to put a "listener" class between Main form and your other components which both classes can easily access. Conceptually, the classes are laid out as follows:
```
---------- ----------------
| MainForm | ... |
345,324 | <p>I have an application that has multiple states, with each state responding to input differently.</p>
<p>The initial implementation was done with a big switch statement, which I refactored using the state pattern (at least, I think it's the state pattern. I'm kind of new to using design patterns, so I tend to get t... | [
{
"answer_id": 345342,
"author": "Bill K",
"author_id": 12943,
"author_profile": "https://Stackoverflow.com/users/12943",
"pm_score": 0,
"selected": false,
"text": "<p>I wrote a library where I refactored a lot of the state stuff. It's clean and quite OO, and doesn't really add a lot of... | 2008/12/05 | [
"https://Stackoverflow.com/questions/345324",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27088/"
] | I have an application that has multiple states, with each state responding to input differently.
The initial implementation was done with a big switch statement, which I refactored using the state pattern (at least, I think it's the state pattern. I'm kind of new to using design patterns, so I tend to get them confuse... | Given your refactoring, it looks like the question now is how to reduce the amount of keycode parsing code that will be duplicated across your various concrete AppState implementations. As you mention, this leads to multiple switch statements which select which code to call to handle the keystroke input.
Depending on ... |
345,352 | <p>I want to build a LineChart component where the color of the line is indicative on how high the value is. I should be able to do this buy just using a gradient stroke (see below) but for some reason the gradient only goes from left to right and the "angle" property is being ignored. How could i do this?</p>
<pre><c... | [
{
"answer_id": 460600,
"author": "James Hay",
"author_id": 47339,
"author_profile": "https://Stackoverflow.com/users/47339",
"pm_score": 1,
"selected": false,
"text": "<p>I would expect that you would need to create a custom lineSegmentRenderer for the line series chart. The current line... | 2008/12/05 | [
"https://Stackoverflow.com/questions/345352",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I want to build a LineChart component where the color of the line is indicative on how high the value is. I should be able to do this buy just using a gradient stroke (see below) but for some reason the gradient only goes from left to right and the "angle" property is being ignored. How could i do this?
```
<mx:Pl... | After encountering the same problem and using James Hay's explanation/example above, I constructed my own LineSegmentRenderer.
Basically I wanted to have a top-to bottom gradient stroke in my lineChart. I too found out that the angle or more accurately the rotation property of the LinearGradientStroke wasn't effective... |
345,354 | <p>I have a control that is created like so:</p>
<pre><code>public partial class MYControl : MyControlBase
{
public string InnerText {
get { return textBox1.Text; }
set { textBox1.Text = value; }
}
public MYControl()
{
InitializeComponent();
}
}
partial class MYControl
{
... | [
{
"answer_id": 345398,
"author": "rfgamaral",
"author_id": 40480,
"author_profile": "https://Stackoverflow.com/users/40480",
"pm_score": 2,
"selected": true,
"text": "<p>I think you'll have to use <strong>base.listBox1</strong> and <strong>base.textBox1</strong>. They are defined in MyCo... | 2008/12/05 | [
"https://Stackoverflow.com/questions/345354",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26166/"
] | I have a control that is created like so:
```
public partial class MYControl : MyControlBase
{
public string InnerText {
get { return textBox1.Text; }
set { textBox1.Text = value; }
}
public MYControl()
{
InitializeComponent();
}
}
partial class MYControl
{
/// <summar... | I think you'll have to use **base.listBox1** and **base.textBox1**. They are defined in MyControlBase which is the base class, not the child class where you need to use the *this* keyword. |
345,380 | <p>I have a table with a clustered primary key index on a uniqueidentifier column. I have a procedure that runs the following psuedo functions:</p>
<pre><code>begin transaction
read from table 1
insert into table 2
update table 1 with pointer to table 2 record
commit transaction
</code></pre>
<p>This all works fine u... | [
{
"answer_id": 345393,
"author": "eulerfx",
"author_id": 13855,
"author_profile": "https://Stackoverflow.com/users/13855",
"pm_score": 2,
"selected": true,
"text": "<p>Look here:</p>\n\n<p><a href=\"http://msdn.microsoft.com/en-us/library/aa213026(SQL.80).aspx\" rel=\"nofollow noreferrer... | 2008/12/05 | [
"https://Stackoverflow.com/questions/345380",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34942/"
] | I have a table with a clustered primary key index on a uniqueidentifier column. I have a procedure that runs the following psuedo functions:
```
begin transaction
read from table 1
insert into table 2
update table 1 with pointer to table 2 record
commit transaction
```
This all works fine until the same procedure is... | Look here:
<http://msdn.microsoft.com/en-us/library/aa213026(SQL.80).aspx>
and here:
<http://msdn.microsoft.com/en-us/library/aa213039(SQL.80).aspx> |
345,385 | <p>does anyone know if there is a simple way to bind a textblock to a List.
What I've done so far is create a listview and bind it to the List and then I have a template within the listview that uses a single textblock.</p>
<p>what I'd really like to do is just bind the List to a textblock and have it display all the ... | [
{
"answer_id": 345515,
"author": "Jobi Joy",
"author_id": 8091,
"author_profile": "https://Stackoverflow.com/users/8091",
"pm_score": 6,
"selected": true,
"text": "<p>Convert your List to a single string with \"\\r\\n\" as the delimiter in between. and bind that to the TextBlock. Make su... | 2008/12/05 | [
"https://Stackoverflow.com/questions/345385",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29849/"
] | does anyone know if there is a simple way to bind a textblock to a List.
What I've done so far is create a listview and bind it to the List and then I have a template within the listview that uses a single textblock.
what I'd really like to do is just bind the List to a textblock and have it display all the lines.
In... | Convert your List to a single string with "\r\n" as the delimiter in between. and bind that to the TextBlock. Make sure that the TextBlock is not restricted with its height , so that it can grow based on the number of lines.
I would implement this as a Value Converter to XAML Binding which converts a List of strings to... |
345,396 | <p>I tried doing this but this only display the radiobutton without text beside it..</p>
<pre><code><% foreach (string s in Html.RadioButtonList("rbl")) {%>
<% =s %>
<% } %>
</code></pre>
| [
{
"answer_id": 353737,
"author": "brady gaster",
"author_id": 28686,
"author_profile": "https://Stackoverflow.com/users/28686",
"pm_score": 3,
"selected": false,
"text": "<p>If it were me I would just use a series of static HTML elements. I know some consider doing such a throwback to th... | 2008/12/05 | [
"https://Stackoverflow.com/questions/345396",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43838/"
] | I tried doing this but this only display the radiobutton without text beside it..
```
<% foreach (string s in Html.RadioButtonList("rbl")) {%>
<% =s %>
<% } %>
``` | [Elijah Manor](https://stackoverflow.com/users/4481/elijah-manor) wrote about the same trouble in ASP.NET MVC 1.0:
[ASP.NET MVC Html.RadioButtonList Blues](http://www.elijahmanor.com/asp-net-mvc-html-radiobuttonlist-blues/)
He decided to loop through his DataSource and create individual Html.RadioButton and Label co... |
345,401 | <p>I've got a couple django models that look like this:</p>
<pre><code>from django.contrib.sites.models import Site
class Photo(models.Model):
title = models.CharField(max_length=100)
site = models.ForeignKey(Site)
file = models.ImageField(upload_to=get_site_profile_path)
def __unicode__(self):
... | [
{
"answer_id": 345419,
"author": "Tom",
"author_id": 3715,
"author_profile": "https://Stackoverflow.com/users/3715",
"pm_score": -1,
"selected": false,
"text": "<p>According to the <a href=\"http://docs.djangoproject.com/en/dev/ref/models/fields/#manytomanyfield\" rel=\"nofollow noreferr... | 2008/12/05 | [
"https://Stackoverflow.com/questions/345401",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3912/"
] | I've got a couple django models that look like this:
```
from django.contrib.sites.models import Site
class Photo(models.Model):
title = models.CharField(max_length=100)
site = models.ForeignKey(Site)
file = models.ImageField(upload_to=get_site_profile_path)
def __unicode__(self):
return sel... | I would delete `site` field on my `Photo` model and add a `ForeignKey` to `Gallery`. I would remove `limit_choices_to` from `photos` fields on `Gallery` model.
Because you are using `ForeignKey`s to `Site`s, that means sites don't share galleries and photos. Therefore having those I mentioned above is already useless.... |
345,406 | <p>I am trying to convert this test code to C# and having a problem with the Trim command. Has anyone done anything similiar like this in C# going to use this with a text box for searching the aspx page. </p>
<pre><code>Dim q = From b In db.Blogs _
Where b.BlogContents.Contains(txtSearch.Text.Trim()) ... | [
{
"answer_id": 345416,
"author": "Victor",
"author_id": 42518,
"author_profile": "https://Stackoverflow.com/users/42518",
"pm_score": 0,
"selected": false,
"text": "<p>not sure what you are asking but the Trim function in c# is the same.</p>\n\n<p><a href=\"http://msdn.microsoft.com/en-u... | 2008/12/05 | [
"https://Stackoverflow.com/questions/345406",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37126/"
] | I am trying to convert this test code to C# and having a problem with the Trim command. Has anyone done anything similiar like this in C# going to use this with a text box for searching the aspx page.
```
Dim q = From b In db.Blogs _
Where b.BlogContents.Contains(txtSearch.Text.Trim()) Or _
b.Bl... | What is the issue you are having? And what LINQ provider is this? An in-memory set (LINQ-to-Objects)? Or LINQ-to-SQL? Or LINQ-to-Entities?
I *suspect* you are getting something about the db LINQ provider not knowing about Trim() - in which case, try doing the trim first:
```
string s = txtSearch.Text.Trim();
var q = ... |
345,411 | <p>I'm using Fedex's web services and getting an annoying error right up front before I can actually get anywhere.</p>
<p>There was an error in serializing body of message addressValidationRequest1: 'Unable to generate a temporary class (result=1).
error CS0030: Cannot convert type 'FedEx.InterOp.AddressValidationServ... | [
{
"answer_id": 345456,
"author": "Simon_Weaver",
"author_id": 16940,
"author_profile": "https://Stackoverflow.com/users/16940",
"pm_score": 3,
"selected": false,
"text": "<p>Turns out Fedex's own documentation covers this specifically!</p>\n\n<p><strong>I am using wsdl.exe from Microsoft... | 2008/12/05 | [
"https://Stackoverflow.com/questions/345411",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16940/"
] | I'm using Fedex's web services and getting an annoying error right up front before I can actually get anywhere.
There was an error in serializing body of message addressValidationRequest1: 'Unable to generate a temporary class (result=1).
error CS0030: Cannot convert type 'FedEx.InterOp.AddressValidationServiceReferen... | You only need change the [][], not the single [].
In Reference.cs change
```
private ParsedElement[][] parsedStreetLineField;
to
private ParsedElement[] parsedStreetLineField;
and
public ParsedElement[][] ParsedStreetLine {
to
public ParsedElement[] ParsedStreetLine {
``` |
345,413 | <p>I am working on a plugin system that loads .dll's contained in a specified folder. I am then using reflection to load the assemblies, iterate through the types they contain and identify any that implement my <code>IPlugin</code> interface. </p>
<p>I am checking this with code similar to the following: </p>
<pre><c... | [
{
"answer_id": 345445,
"author": "Lawrence Dol",
"author_id": 8946,
"author_profile": "https://Stackoverflow.com/users/8946",
"pm_score": 0,
"selected": false,
"text": "<p>I work in Java which has the same API method and I just can't get my mind to grok it when reading the code (for some... | 2008/12/05 | [
"https://Stackoverflow.com/questions/345413",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20489/"
] | I am working on a plugin system that loads .dll's contained in a specified folder. I am then using reflection to load the assemblies, iterate through the types they contain and identify any that implement my `IPlugin` interface.
I am checking this with code similar to the following:
```
foreach(Type t in myTypes )
... | That typically happens when there's a mismatch between the assembly which contains the type IPlugin that the current assembly references, and the assembly which is referenced by the assembly containg the types you're iterating over.
I suggest you print:
```
typeof (IPlugin).Module.FullyQualifiedName
```
and
```
fo... |
345,414 | <p>Let's say that I'm considering designing a WCF service whose primary purpose is to provide broad services that can be used by three disparate applications: a public-facing Web site, an internal Windows Forms application, and a wireless mobile device. The purpose of the service is twofold: (1) to consolidate code rel... | [
{
"answer_id": 351560,
"author": "Nicholas Piasecki",
"author_id": 32187,
"author_profile": "https://Stackoverflow.com/users/32187",
"pm_score": 5,
"selected": true,
"text": "<p>Well, I reckon that I'll take a stab at my own question now that I've spent a few hours playing with various a... | 2008/12/05 | [
"https://Stackoverflow.com/questions/345414",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32187/"
] | Let's say that I'm considering designing a WCF service whose primary purpose is to provide broad services that can be used by three disparate applications: a public-facing Web site, an internal Windows Forms application, and a wireless mobile device. The purpose of the service is twofold: (1) to consolidate code relate... | Well, I reckon that I'll take a stab at my own question now that I've spent a few hours playing with various approaches.
My first approach was to set up certificate-based authentication between the WCF service and the public-facing Web site (the Web site is a consumer/client of the service). A few test certs generated... |
345,427 | <p>How do I inner join multiple columns from the same tables via Linq? </p>
<p>For example:
I already have this...</p>
<pre><code>join c in db.table2 on table2.ID equals table1.ID
</code></pre>
<p>I need to add this...</p>
<pre><code>join d in db.table2 on table2.Country equals table1.Country
</code></pre>
| [
{
"answer_id": 345459,
"author": "TGnat",
"author_id": 25121,
"author_profile": "https://Stackoverflow.com/users/25121",
"pm_score": 1,
"selected": false,
"text": "<p>In VB:</p>\n\n<pre><code> dim qry = FROM t1 in table1 _\n JOIN t2 in table2 on t2.ID equals t1.ID _\n ... | 2008/12/05 | [
"https://Stackoverflow.com/questions/345427",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43841/"
] | How do I inner join multiple columns from the same tables via Linq?
For example:
I already have this...
```
join c in db.table2 on table2.ID equals table1.ID
```
I need to add this...
```
join d in db.table2 on table2.Country equals table1.Country
``` | You can put your query inside a Where clause instead of using the join operator.
The join operator supports multiple clauses in VB.NET, but not C#.
Alternatively, you can use the ANSI-82 style of 'SQL' syntax, e.g.:
```
from t1 in table1
from t2 in table1
where t1.x == t2.x
&& t1.y == t2.y
``` |
345,428 | <p>I want to use libgadu (library of instant messaging protocol) under Visual Studio 2008.
I have downloaded libgadu <a href="http://toxygen.net/libgadu/files/libgadu-1.8.2.tar.gz" rel="nofollow noreferrer">http://toxygen.net/libgadu/files/libgadu-1.8.2.tar.gz</a> and under cygwin I've compiled it - ./configure , make ... | [
{
"answer_id": 345437,
"author": "Frank Krueger",
"author_id": 338,
"author_profile": "https://Stackoverflow.com/users/338",
"pm_score": 3,
"selected": true,
"text": "<p>You need to locate the compiled DLL and LIB file, or just LIB file if it was compiled into a static library. The files... | 2008/12/05 | [
"https://Stackoverflow.com/questions/345428",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43842/"
] | I want to use libgadu (library of instant messaging protocol) under Visual Studio 2008.
I have downloaded libgadu <http://toxygen.net/libgadu/files/libgadu-1.8.2.tar.gz> and under cygwin I've compiled it - ./configure , make , make install.
File libgadu.h which appeard in include folder I copied to another folder which... | You need to locate the compiled DLL and LIB file, or just LIB file if it was compiled into a static library. The files will probably be named libgadu.dll and libgadu.lib.
Once you have those, you can instruct Visual Studio to link with the LIB file by selecting Project Properties and locating the Additional Dependenci... |
345,432 | <p>I have a simple app loading a site optimized for the iPhone in a <code>UIWebView</code>.</p>
<p>Problem is, caching does not seem to work:</p>
<pre><code>[webView loadRequest: [NSURLRequest requestWithURL: [NSURL URLWithString: url]
cachePolicy: NSURLRequestUseProtocolCachePo... | [
{
"answer_id": 345499,
"author": "seanb",
"author_id": 3354,
"author_profile": "https://Stackoverflow.com/users/3354",
"pm_score": 1,
"selected": false,
"text": "<p>The ihone has limited caching capacity compared to a normal computer. It limits <em>uncompressed</em> cache items to 25k. ... | 2008/12/05 | [
"https://Stackoverflow.com/questions/345432",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43843/"
] | I have a simple app loading a site optimized for the iPhone in a `UIWebView`.
Problem is, caching does not seem to work:
```
[webView loadRequest: [NSURLRequest requestWithURL: [NSURL URLWithString: url]
cachePolicy: NSURLRequestUseProtocolCachePolicy
... | One workaround of this problem as I see is to
1) download HTML code
2) store it in the string
3) find all external links in it like
```
<img src="img.gif" width="..." height="..." />
```
4) download them all
5) replace them with embedded Base64-encoded version
```
<img src="data:image/gif;base64,R0lGODlhUAAPA.... |
345,454 | <p>How can I programmatically generate keypress events from Javascript code running in Safari? It looks like WebKit is using the DOM level 3 model for creating keyboard events from Javascript, and the DOM level 3 keyboard event model does not support the keypress event. Is there another way that I can use?</p>
<p>I'... | [
{
"answer_id": 345460,
"author": "Matt",
"author_id": 32881,
"author_profile": "https://Stackoverflow.com/users/32881",
"pm_score": -1,
"selected": false,
"text": "<p><a href=\"http://docs.jquery.com/Events/keypress#fn\" rel=\"nofollow noreferrer\">http://docs.jquery.com/Events/keypress#... | 2008/12/05 | [
"https://Stackoverflow.com/questions/345454",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42484/"
] | How can I programmatically generate keypress events from Javascript code running in Safari? It looks like WebKit is using the DOM level 3 model for creating keyboard events from Javascript, and the DOM level 3 keyboard event model does not support the keypress event. Is there another way that I can use?
I'm looking fo... | Use the TextEvent (introduced by DOM3). Since you're looking to generate keypress events, I'm guessing you're working with characters. In the code below, textToInsert is a string, and textarea the element I'm dispatching the event to.
```
var eventObject = document.createEvent('TextEvent');
eventObject.initTextEvent('... |
345,479 | <p>Strangest thing happened today with my ASP.NET MVC project. I built the installer project this afternoon, and all of a sudden, there were all these new dependencies! Yuck.</p>
<pre><code>Microsoft.SqlServer.BatchParser.dll
Microsoft.SqlServer.ConnectionInfo.dll
Microsoft.SqlServer.Dmf.dll
Microsoft.SqlServer.Mana... | [
{
"answer_id": 345965,
"author": "shahkalpesh",
"author_id": 23574,
"author_profile": "https://Stackoverflow.com/users/23574",
"pm_score": 0,
"selected": false,
"text": "<p>To be honest, I do not have any idea of setup projects.</p>\n\n<p>But looks like your solution has some kind of dat... | 2008/12/05 | [
"https://Stackoverflow.com/questions/345479",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40097/"
] | Strangest thing happened today with my ASP.NET MVC project. I built the installer project this afternoon, and all of a sudden, there were all these new dependencies! Yuck.
```
Microsoft.SqlServer.BatchParser.dll
Microsoft.SqlServer.ConnectionInfo.dll
Microsoft.SqlServer.Dmf.dll
Microsoft.SqlServer.Management.Sdk.Sfc.d... | Well here we go:
*Microsoft.Web.Mvc.dll* is for experimental features of the MVC framework that probably won't make it into the final release
*Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll, Microsoft.VisualStudio.TeamSystem.Data.dll,
Microsoft.VisualStudio.TeamSystem.Data.UnitTesting.dll* are probably th... |
345,489 | <p>I read somewhere that one should never use error conditions as normal program flow. Makes excellent sense to me... But</p>
<p>C# application sitting on top of a MySQL db. I need to parse a string value into two parts, an ID, and a value. (The original data come from a Devonian database), then validate the value aga... | [
{
"answer_id": 345493,
"author": "Rob Prouse",
"author_id": 30827,
"author_profile": "https://Stackoverflow.com/users/30827",
"pm_score": 3,
"selected": true,
"text": "<p>You shouldn't be calling ToString() at that point, first you should check if the value returned is null;</p>\n\n<pre>... | 2008/12/05 | [
"https://Stackoverflow.com/questions/345489",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16851/"
] | I read somewhere that one should never use error conditions as normal program flow. Makes excellent sense to me... But
C# application sitting on top of a MySQL db. I need to parse a string value into two parts, an ID, and a value. (The original data come from a Devonian database), then validate the value against a loo... | You shouldn't be calling ToString() at that point, first you should check if the value returned is null;
```
object productName = productAdapter.GetProductName(product_id);
if ( productName != null )
{
s_product = productName.ToString();
}
else
{
s_product = String.Empty;
}
``` |
345,505 | <p>How can you <a href="http://en.wikipedia.org/wiki/Diff" rel="noreferrer">diff</a> two pipelines without using temporary files in Bash? Say you have two command pipelines:</p>
<pre><code>foo | bar
baz | quux
</code></pre>
<p>And you want to find the <code>diff</code> in their outputs. One solution would obviously... | [
{
"answer_id": 345526,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 8,
"selected": true,
"text": "<p>A one-line with 2 tmp files (not what you want) would be:</p>\n\n<pre><code> foo | bar > file1.txt && baz | quux &... | 2008/12/05 | [
"https://Stackoverflow.com/questions/345505",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9530/"
] | How can you [diff](http://en.wikipedia.org/wiki/Diff) two pipelines without using temporary files in Bash? Say you have two command pipelines:
```
foo | bar
baz | quux
```
And you want to find the `diff` in their outputs. One solution would obviously be to:
```
foo | bar > /tmp/a
baz | quux > /tmp/b
diff /tmp/a /tm... | A one-line with 2 tmp files (not what you want) would be:
```
foo | bar > file1.txt && baz | quux > file2.txt && diff file1.txt file2.txt
```
With **bash**, you might try though:
```
diff <(foo | bar) <(baz | quux)
foo | bar | diff - <(baz | quux) # or only use process substitution once
```
The 2nd version w... |
345,506 | <p>suppose I have an enum</p>
<pre><code>[Flags]
public enum E {
zero = 0,
one = 1
}
</code></pre>
<p>then I can write</p>
<pre><code>E e;
object o = 1;
e = (E) o;
</code></pre>
<p>and it will work.</p>
<p>BUT if I try to do that at runtime, like</p>
<pre><code>(o as IConvertible).ToType(typeof(E), null)... | [
{
"answer_id": 345509,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 0,
"selected": false,
"text": "<p>How does the variable look like that you save the result of that conversion in? I.e. with which type do you declar... | 2008/12/05 | [
"https://Stackoverflow.com/questions/345506",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43848/"
] | suppose I have an enum
```
[Flags]
public enum E {
zero = 0,
one = 1
}
```
then I can write
```
E e;
object o = 1;
e = (E) o;
```
and it will work.
BUT if I try to do that at runtime, like
```
(o as IConvertible).ToType(typeof(E), null)
```
it will throw InvalidCastException.
So, is there something ... | ```
object o = 1;
object z = Enum.ToObject(typeof(E), o);
``` |
345,513 | <p>Can someone give some hints of how to delete the last n lines from a file in Perl? I have a very large file of around 400 MB, and I want to delete some 125,000 last lines from it.</p>
| [
{
"answer_id": 345521,
"author": "Svante",
"author_id": 31615,
"author_profile": "https://Stackoverflow.com/users/31615",
"pm_score": 5,
"selected": true,
"text": "<p>You can use <a href=\"http://search.cpan.org/dist/Tie-File\" rel=\"nofollow noreferrer\">Tie::File</a> to handle the file... | 2008/12/05 | [
"https://Stackoverflow.com/questions/345513",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33411/"
] | Can someone give some hints of how to delete the last n lines from a file in Perl? I have a very large file of around 400 MB, and I want to delete some 125,000 last lines from it. | You can use [Tie::File](http://search.cpan.org/dist/Tie-File) to handle the file as an array.
```
use Tie::File;
tie (@File, 'Tie::File', $Filename);
splice (@File, -125000, 125000);
untie @File;
```
An alternative is to use `head` and `wc -l` in the shell.
*edit:* grepsedawk reminds us of the `-n` option to `head`... |
345,518 | <p>I have a file that has one entry per line. Each line has the following format:</p>
<pre><code> "group:permissions:users"
</code></pre>
<p>Permissions and users could have more than one value separated by comas like this:</p>
<pre><code> "grp1:create,delete:yo,el,ella"
</code></pre>
<p>I want is to return the f... | [
{
"answer_id": 345528,
"author": "Jay",
"author_id": 20840,
"author_profile": "https://Stackoverflow.com/users/20840",
"pm_score": 5,
"selected": true,
"text": "<p>You can use awk, with the -F option to use : as the field separator: </p>\n\n<pre><code>[user@host]$ echo \"grp1:create,dele... | 2008/12/05 | [
"https://Stackoverflow.com/questions/345518",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16316/"
] | I have a file that has one entry per line. Each line has the following format:
```
"group:permissions:users"
```
Permissions and users could have more than one value separated by comas like this:
```
"grp1:create,delete:yo,el,ella"
```
I want is to return the following:
```
yo
el
ella
```
This is what I ha... | You can use awk, with the -F option to use : as the field separator:
```
[user@host]$ echo "grp1:create,delete:yo,el,ella" | awk -F ':' '{print $3}'
yo,el,ella
```
That will get you just the users string, separated by commas. Then you can do whatever you want with that string. If you want to literally print each us... |
345,540 | <p>I can't seem to be able to disable a select box when the select tag is not nested inside a form tag. Some things I tried are (using Firefox 3):
(via Jquery)</p>
<pre><code>$("#mySelect").attr("disabled", true);
$("#mySelect").attr("disabled", "disabled");
</code></pre>
<p>(also)</p>
<pre><code>document.getElemen... | [
{
"answer_id": 345554,
"author": "Tom",
"author_id": 20,
"author_profile": "https://Stackoverflow.com/users/20",
"pm_score": 3,
"selected": true,
"text": "<p>Short answer: No, you don't need to have the select box within a form. </p>\n\n<p>Where is your JavaScript currently included with... | 2008/12/05 | [
"https://Stackoverflow.com/questions/345540",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4352/"
] | I can't seem to be able to disable a select box when the select tag is not nested inside a form tag. Some things I tried are (using Firefox 3):
(via Jquery)
```
$("#mySelect").attr("disabled", true);
$("#mySelect").attr("disabled", "disabled");
```
(also)
```
document.getElementById('mySelect').disabled = true;
doc... | Short answer: No, you don't need to have the select box within a form.
Where is your JavaScript currently included with respect to the `body` tag in your HTML? Remember that if you have inline JavaScript included in the head if your page, then it will fire as the page is loaded. At this point, the select box will not... |
345,547 | <p>I want to use a Simulink mdl to generate C files in an automated fashion. I am currently trying to use an m-script and a dos command shell, but I am having issues with a "do you want to save" dialog hanging the m-script. By experimentation I know that the mdl is being modified when the "set_param" line is run (i.e... | [
{
"answer_id": 345613,
"author": "Jeffrey Fredrick",
"author_id": 35894,
"author_profile": "https://Stackoverflow.com/users/35894",
"pm_score": 0,
"selected": false,
"text": "<p>can you do something like:</p>\n\n<blockquote>\n <p>matlab -r samplebuild -nosplash\n -nodesktop < yes</p... | 2008/12/05 | [
"https://Stackoverflow.com/questions/345547",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34605/"
] | I want to use a Simulink mdl to generate C files in an automated fashion. I am currently trying to use an m-script and a dos command shell, but I am having issues with a "do you want to save" dialog hanging the m-script. By experimentation I know that the mdl is being modified when the "set\_param" line is run (i.e. no... | Use the following command to force the model to be closed without saving:
```
close_system(gcs, false);
```
E.g.
```
rtwdemo_counter
set_param(gcs,'SystemTargetFile','ert.tlc')
rtwbuild(gcs)
close_system(gcs, false);
exit
``` |
345,559 | <p>When starting a new project that required the use of membership providers I found that I could not connect to a remote database that contained the membership database.</p>
<p>I ran aspnet_regsql and was able to create the membership database on the remote server but when I go to ASPNET Configuration (cassini develo... | [
{
"answer_id": 345570,
"author": "jdiaz",
"author_id": 831,
"author_profile": "https://Stackoverflow.com/users/831",
"pm_score": 5,
"selected": true,
"text": "<p>After much searching I found that the default Membership Provider specified in machine.config (c:\\windows\\Microsoft.NET\\Fra... | 2008/12/05 | [
"https://Stackoverflow.com/questions/345559",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/831/"
] | When starting a new project that required the use of membership providers I found that I could not connect to a remote database that contained the membership database.
I ran aspnet\_regsql and was able to create the membership database on the remote server but when I go to ASPNET Configuration (cassini development ser... | After much searching I found that the default Membership Provider specified in machine.config (c:\windows\Microsoft.NET\Framework\v2.0.50727\CONFIG) was always pointing to a SQL Server running on the localhost.
Instead of modifying machine.config there is a way to set it up in the projects web.config:
1) Setup the co... |
345,610 | <p>Our logging class, when initialised, truncates the log file to 500,000 bytes. From then on, log statements are appended to the file.</p>
<p>We do this to keep disk usage low, we're a commodity end-user product.</p>
<p>Obviously keeping the first 500,000 bytes is not useful, so we keep the last 500,000 bytes.</p>
... | [
{
"answer_id": 345622,
"author": "gbjbaanb",
"author_id": 13744,
"author_profile": "https://Stackoverflow.com/users/13744",
"pm_score": 0,
"selected": false,
"text": "<p>I don't think it is anything computer related, but how you guys have written your logging class. It sounds strange to ... | 2008/12/06 | [
"https://Stackoverflow.com/questions/345610",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6444/"
] | Our logging class, when initialised, truncates the log file to 500,000 bytes. From then on, log statements are appended to the file.
We do this to keep disk usage low, we're a commodity end-user product.
Obviously keeping the first 500,000 bytes is not useful, so we keep the last 500,000 bytes.
Our solution has some... | >
> "I would probably create a new file, seek in the old file, do a buffered read/write from old file to new file, rename the new file over the old one."
>
>
>
I think you'd be better off simply:
```
#include <fstream>
std::ifstream ifs("logfile"); //One call to start it all. . .
ifs.seekg(-512000, std::ios_base... |
345,617 | <p>I am running Ubuntu8.041. Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.3 with Suhosin-Patch configured </p>
<p>Can't get file uploading to work at all. Have tested locally on the Ubuntu box... and from my Vista Box. Ubuntu is running inside VMWare on the Vista box.</p>
<p>Here is uploadTestBrowse.php</p>
<pre><code... | [
{
"answer_id": 345622,
"author": "gbjbaanb",
"author_id": 13744,
"author_profile": "https://Stackoverflow.com/users/13744",
"pm_score": 0,
"selected": false,
"text": "<p>I don't think it is anything computer related, but how you guys have written your logging class. It sounds strange to ... | 2008/12/06 | [
"https://Stackoverflow.com/questions/345617",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26086/"
] | I am running Ubuntu8.041. Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.3 with Suhosin-Patch configured
Can't get file uploading to work at all. Have tested locally on the Ubuntu box... and from my Vista Box. Ubuntu is running inside VMWare on the Vista box.
Here is uploadTestBrowse.php
```
<?php
?>
<form enctype="multi... | >
> "I would probably create a new file, seek in the old file, do a buffered read/write from old file to new file, rename the new file over the old one."
>
>
>
I think you'd be better off simply:
```
#include <fstream>
std::ifstream ifs("logfile"); //One call to start it all. . .
ifs.seekg(-512000, std::ios_base... |
345,626 | <p>I have been assigned a project to develop a set of classes that act as an interface to a storage system. A requirement is that the class support a get method with the following signature:</p>
<pre><code>public CustomObject get(String key, Date ifModifiedSince)
</code></pre>
<p>Basically the method is supposed to ... | [
{
"answer_id": 345631,
"author": "Lawrence Dol",
"author_id": 8946,
"author_profile": "https://Stackoverflow.com/users/8946",
"pm_score": 2,
"selected": false,
"text": "<p>You can create a special final CustomObject as a \"marker\" to indicate unchanged:</p>\n\n<pre><code>static public f... | 2008/12/06 | [
"https://Stackoverflow.com/questions/345626",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28408/"
] | I have been assigned a project to develop a set of classes that act as an interface to a storage system. A requirement is that the class support a get method with the following signature:
```
public CustomObject get(String key, Date ifModifiedSince)
```
Basically the method is supposed to return the `CustomObject` a... | It sounds like you actually want to return two items: the response code and the object found. You might consider creating a lightweight wrapper that holds both and return them together.
```
public class Pair<K,V>{
public K first;
public V second;
}
```
Then you can create a new Pair that holds your response code... |
345,632 | <p>I have redirected some valuable information into a text file. How can I execute each line of that text file in a loop?</p>
<p>What im thinking is to double space my text file, then to use a loop to execute each line invidually. I'm hoping that when i double space the text file every string of commands will have th... | [
{
"answer_id": 345639,
"author": "Lawrence Dol",
"author_id": 8946,
"author_profile": "https://Stackoverflow.com/users/8946",
"pm_score": 1,
"selected": false,
"text": "<p>Why not just have the line separator delimit the commands? You don't need a blank line to delimit them unless your c... | 2008/12/06 | [
"https://Stackoverflow.com/questions/345632",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40120/"
] | I have redirected some valuable information into a text file. How can I execute each line of that text file in a loop?
What im thinking is to double space my text file, then to use a loop to execute each line invidually. I'm hoping that when i double space the text file every string of commands will have their own lin... | Why not just have the line separator delimit the commands? You don't need a blank line to delimit them unless your command must be able to contain line separators - and then what if it needed to contain 2 in a row? |
345,637 | <p>So I have an SQL dump file that needs to be loaded using mysql_query(). Unfortunately, it's not possible to execute multiple queries with it.</p>
<p>-> It cannot be assumed that the <strong>mysql command-line client</strong> (mysql --help) is installed -- for loading the SQL file directly</p>
<p>-> It cannot be as... | [
{
"answer_id": 345712,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "https://Stackoverflow.com/users/20860",
"pm_score": 5,
"selected": true,
"text": "<p>You have more problem cases than just semicolons within strings. </p>\n\n<ul>\n<li>Script <a href=\"http://dev.mysq... | 2008/12/06 | [
"https://Stackoverflow.com/questions/345637",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32881/"
] | So I have an SQL dump file that needs to be loaded using mysql\_query(). Unfortunately, it's not possible to execute multiple queries with it.
-> It cannot be assumed that the **mysql command-line client** (mysql --help) is installed -- for loading the SQL file directly
-> It cannot be assumed that the **mysqli** ext... | You have more problem cases than just semicolons within strings.
* Script [builtin](http://dev.mysql.com/doc/refman/5.1/en/mysql-commands.html) commands that cannot be executed by `mysql_query()`, like `USE`.
* Statements that are not terminated with a semicolon, like [`DELIMITER`](http://dev.mysql.com/doc/refman/5.1... |
345,656 | <p>I am creating a Windows service. When an exception occurrs, I handle it appropriately and create a log. I am using the <a href="http://en.wikipedia.org/wiki/Decorator_pattern" rel="nofollow noreferrer">decorator pattern</a>, as there are many different ways people will be looking at these logs. I have an email logge... | [
{
"answer_id": 345662,
"author": "BobbyShaftoe",
"author_id": 38426,
"author_profile": "https://Stackoverflow.com/users/38426",
"pm_score": 3,
"selected": false,
"text": "<p>Why don't put it in the actual Windows Event log if logger fails?</p>\n"
},
{
"answer_id": 345716,
"au... | 2008/12/06 | [
"https://Stackoverflow.com/questions/345656",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37064/"
] | I am creating a Windows service. When an exception occurrs, I handle it appropriately and create a log. I am using the [decorator pattern](http://en.wikipedia.org/wiki/Decorator_pattern), as there are many different ways people will be looking at these logs. I have an email logger, a file logger, and a windows event lo... | Its not an answer, but curious why did you choose to not utilize the existing System.Diagnostics.Trace methods. You could implement some type of categorization of log types on top it it perhaps? |
345,680 | <p>I have a ticker which items are updated using polling. I have written a simple jQuery plugin for the ticker which is invoked like so:</p>
<pre><code>$("#cont ul").ticker();
</code></pre>
<p>Which turns a ul into a ticker, scrolling through the li. To add new items I have to add lis to the ul, which works fine. How... | [
{
"answer_id": 345778,
"author": "nickf",
"author_id": 9021,
"author_profile": "https://Stackoverflow.com/users/9021",
"pm_score": 2,
"selected": true,
"text": "<p>jQuery isn't really an OO solution, so you're correct in saying that it's not really the \"jQuery way\". I've heard Prototyp... | 2008/12/06 | [
"https://Stackoverflow.com/questions/345680",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/214/"
] | I have a ticker which items are updated using polling. I have written a simple jQuery plugin for the ticker which is invoked like so:
```
$("#cont ul").ticker();
```
Which turns a ul into a ticker, scrolling through the li. To add new items I have to add lis to the ul, which works fine. However, the OO in me wishes ... | jQuery isn't really an OO solution, so you're correct in saying that it's not really the "jQuery way". I've heard Prototype is all about OO, so you might want to look into that one day.
There's no reason you couldn't add another function to the jQuery object though:
```
$.fn.addTickerItem = function(contents) {
t... |
345,683 | <p>I am working a project that does not have a trunk / branches / tags directory structure - ie. everything is in the root of the svn repo.</p>
<p>I would like to create a trunk directory and in the root directory, and move everything in the root directory into the new trunk directory.</p>
<p>What is the best way to ... | [
{
"answer_id": 345692,
"author": "saffsd",
"author_id": 37984,
"author_profile": "https://Stackoverflow.com/users/37984",
"pm_score": 0,
"selected": false,
"text": "<p>You may want to look into the svnadmin tool.</p>\n\n<ul>\n<li><a href=\"http://svnbook.red-bean.com/en/1.0/ch09s02.html\... | 2008/12/06 | [
"https://Stackoverflow.com/questions/345683",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31092/"
] | I am working a project that does not have a trunk / branches / tags directory structure - ie. everything is in the root of the svn repo.
I would like to create a trunk directory and in the root directory, and move everything in the root directory into the new trunk directory.
What is the best way to do this?
The fir... | This is similar to the way I've done it in the past. Your solution actually *copies* each file, then deletes the original. Because of the way Subversion implements copies, the history for every file is preserved.
After doing this, you can point existing checkouts at the new location using `svn switch`. |
345,704 | <p>You guys were very helpful yesterday. I am still a bit confused here though. </p>
<p>I want to make it so that the numbers on the rightmost column are rounded off to the nearest dollar:</p>
<p><a href="http://www.nextadvisor.com/voip_services/voip_calculator.php?monthlybill=50&Submit=Submit" rel="nofollow no... | [
{
"answer_id": 345725,
"author": "grepsedawk",
"author_id": 14388,
"author_profile": "https://Stackoverflow.com/users/14388",
"pm_score": 4,
"selected": true,
"text": "<p>Do you want rounded up/down/truncated to the nearest dollar?</p>\n\n<p>Here are some suggested functions you can use:... | 2008/12/06 | [
"https://Stackoverflow.com/questions/345704",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43035/"
] | You guys were very helpful yesterday. I am still a bit confused here though.
I want to make it so that the numbers on the rightmost column are rounded off to the nearest dollar:
<http://www.nextadvisor.com/voip_services/voip_calculator.php?monthlybill=50&Submit=Submit>
the code for the table looks like this:
I wan... | Do you want rounded up/down/truncated to the nearest dollar?
Here are some suggested functions you can use:
**Rounding**
[round](http://us.php.net/manual/en/function.round.php)
[floor](http://us.php.net/manual/en/function.floor.php)
[ceil](http://us.php.net/manual/en/function.ceil.php)
**Formatting/Truncating**
... |
345,705 | <p>Here's one that has me perplexed. I'm trying to implement a basic Hibernate DAO structure, but am having a problem.</p>
<p>Here's the essential code:</p>
<pre><code>int startingCount = sfdao.count();
sfdao.create( sf );
SecurityFiling sf2 = sfdao.read( sf.getId() );
sfdao.delete( sf );
int endingCount = sfdao.coun... | [
{
"answer_id": 346338,
"author": "digitalsanctum",
"author_id": 22436,
"author_profile": "https://Stackoverflow.com/users/22436",
"pm_score": 4,
"selected": false,
"text": "<p>This generally means that the owning Hibernate session has already closed. You can do one of the following to fi... | 2008/12/06 | [
"https://Stackoverflow.com/questions/345705",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17304/"
] | Here's one that has me perplexed. I'm trying to implement a basic Hibernate DAO structure, but am having a problem.
Here's the essential code:
```
int startingCount = sfdao.count();
sfdao.create( sf );
SecurityFiling sf2 = sfdao.read( sf.getId() );
sfdao.delete( sf );
int endingCount = sfdao.count();
assertTrue( sta... | The problem is that you are trying to access a collection in an object that is [detached](http://docs.jboss.org/hibernate/core/3.3/reference/en/html/objectstate.html). You need to re-attach the object before accessing the collection to the current session. You can do that through
```
session.update(object);
```
Usin... |
345,707 | <p>I am working on a rails application (I have some experience with rails). But, this time I am using RESTful to build it. I am wondering how do I validate my models in a RESTful fashion? What I mean by that is when a user enters data into a form, but the model validations prevent the model from being created what i... | [
{
"answer_id": 345747,
"author": "Hates_",
"author_id": 3410,
"author_profile": "https://Stackoverflow.com/users/3410",
"pm_score": 0,
"selected": false,
"text": "<p>Whether developing in a RESTful or regular fashion, the backend implementation remains generally the same. Just as in a no... | 2008/12/06 | [
"https://Stackoverflow.com/questions/345707",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5004/"
] | I am working on a rails application (I have some experience with rails). But, this time I am using RESTful to build it. I am wondering how do I validate my models in a RESTful fashion? What I mean by that is when a user enters data into a form, but the model validations prevent the model from being created what is a RE... | Josh - you mention wanting to know how to redirect the user back to create if it errored out. If you are use to earlier versions of Rails just make sure you are using the form\_for helper rather then the start\_form\_tag from early. Your controller code will look pretty similar to how you might be used to... for exampl... |
345,745 | <p>I just came across this idiom in some open-source Python, and I choked on my drink.</p>
<p>Rather than:</p>
<pre><code>if isUp:
return "Up"
else:
return "Down"
</code></pre>
<p>or even:</p>
<pre><code>return "Up" if isUp else "Down"
</code></pre>
<p>the code read:</p>
<pre><code>return isUp and "Up" or... | [
{
"answer_id": 345752,
"author": "Jason Baker",
"author_id": 2147,
"author_profile": "https://Stackoverflow.com/users/2147",
"pm_score": 0,
"selected": false,
"text": "<p>That code is a big fugly and clever for my tastes, but I suppose there's not anything wrong with it per se. I think ... | 2008/12/06 | [
"https://Stackoverflow.com/questions/345745",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8014/"
] | I just came across this idiom in some open-source Python, and I choked on my drink.
Rather than:
```
if isUp:
return "Up"
else:
return "Down"
```
or even:
```
return "Up" if isUp else "Down"
```
the code read:
```
return isUp and "Up" or "Down"
```
I can see this is the same result, but is this a typi... | The "a and b or c" idiom was the canonical way to express the ternary arithmetic if in Python, before [PEP 308](http://www.python.org/dev/peps/pep-0308/) was written and implemented. This idiom fails the "b" answer is false itself; to support the general case, you could write
```
return (a and [b] or [c])[0]
```
An... |
345,746 | <p>This is related to a <a href="https://stackoverflow.com/questions/343517/how-do-i-work-with-multiple-git-branches-of-a-python-module">previous question</a> of mine.</p>
<p>I understand how to store and read configuration files. There are choices such as <a href="http://www.python.org/doc/2.5.2/lib/module-ConfigParse... | [
{
"answer_id": 345790,
"author": "Kozyarchuk",
"author_id": 52490,
"author_profile": "https://Stackoverflow.com/users/52490",
"pm_score": 0,
"selected": false,
"text": "<p>require statement from <a href=\"http://peak.telecommunity.com/DevCenter/PkgResources#basic-workingset-methods\" rel... | 2008/12/06 | [
"https://Stackoverflow.com/questions/345746",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37984/"
] | This is related to a [previous question](https://stackoverflow.com/questions/343517/how-do-i-work-with-multiple-git-branches-of-a-python-module) of mine.
I understand how to store and read configuration files. There are choices such as [ConfigParser](http://www.python.org/doc/2.5.2/lib/module-ConfigParser.html) and [C... | "imports ... require your module to be on your PYTHONPATH"
Right.
So, what's wrong with setting `PYTHONPATH`? |
345,760 | <p>We were having a debate if enums should have uninitialized values. For example. We have </p>
<pre><code>public enum TimeOfDayType
{
Morning
Afternoon
Evening
}
</code></pre>
<p>or </p>
<pre><code>public enum TimeOfDayType
{
None
Morning
Afternoon
Evening
}
</code></pre>
<p>I think that t... | [
{
"answer_id": 345771,
"author": "Steve Jessop",
"author_id": 13005,
"author_profile": "https://Stackoverflow.com/users/13005",
"pm_score": 1,
"selected": false,
"text": "<p>Depends how the type is used. It's often easier for users of the type not to have an \"undefined\" value, because ... | 2008/12/06 | [
"https://Stackoverflow.com/questions/345760",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4653/"
] | We were having a debate if enums should have uninitialized values. For example. We have
```
public enum TimeOfDayType
{
Morning
Afternoon
Evening
}
```
or
```
public enum TimeOfDayType
{
None
Morning
Afternoon
Evening
}
```
I think that there shouldn't be any none but then you have to defau... | Speaking of nullable types - I think they can be used to solve the problem of forcing/not forcing the initialization of an enum. Say we have
```
enum Color { Red, Blue }
```
And let's say you have a function:
```
void Draw(Color c);
```
That function says that it **requires** a valid `Color`. However, we could al... |
345,766 | <p>Has anyone managed to do this? I tried making a managed wrapper class for IPropertyStore but am getting AccessViolationExceptions on the methods (i.e. IPropertyStore::GetValue) that take a pointer to PROPVARIANT (rendered as a MarshalAs(UnmanagedType.Struct) out parameter in my managed version) Probably my underst... | [
{
"answer_id": 345771,
"author": "Steve Jessop",
"author_id": 13005,
"author_profile": "https://Stackoverflow.com/users/13005",
"pm_score": 1,
"selected": false,
"text": "<p>Depends how the type is used. It's often easier for users of the type not to have an \"undefined\" value, because ... | 2008/12/06 | [
"https://Stackoverflow.com/questions/345766",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19393/"
] | Has anyone managed to do this? I tried making a managed wrapper class for IPropertyStore but am getting AccessViolationExceptions on the methods (i.e. IPropertyStore::GetValue) that take a pointer to PROPVARIANT (rendered as a MarshalAs(UnmanagedType.Struct) out parameter in my managed version) Probably my understandin... | Speaking of nullable types - I think they can be used to solve the problem of forcing/not forcing the initialization of an enum. Say we have
```
enum Color { Red, Blue }
```
And let's say you have a function:
```
void Draw(Color c);
```
That function says that it **requires** a valid `Color`. However, we could al... |
345,788 | <p>I want my client code to look somewhat like this:</p>
<pre><code> val config:Config = new MyConfig("c:/etc/myConfig.txt")
println(config.param1)
println(config.param2)
println(config.param3)
</code></pre>
<p>Which means that:</p>
<ul>
<li>The Config interface defines the config fields</li>
... | [
{
"answer_id": 345869,
"author": "sblundy",
"author_id": 4893,
"author_profile": "https://Stackoverflow.com/users/4893",
"pm_score": 0,
"selected": false,
"text": "<p>If you just want to simplify it, the \"param\" fields could be methods...</p>\n\n<pre><code>trait Config {\n def param1:... | 2008/12/06 | [
"https://Stackoverflow.com/questions/345788",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17138/"
] | I want my client code to look somewhat like this:
```
val config:Config = new MyConfig("c:/etc/myConfig.txt")
println(config.param1)
println(config.param2)
println(config.param3)
```
Which means that:
* The Config interface defines the config fields
* MyConfig is a Config implementation -- a... | There's nothing preventing you from just making the values abstract. You cannot enforce laziness in the super-trait, but that's ok since lazy-loading is really an implementation detail anyway:
```
trait Config {
val param1: String
val param2: String
val param3: Int
}
class MyConfig extends Config {
lazy val p... |
345,794 | <p>Below is the command I tried executing, without success:</p>
<pre><code>exec('ln -s ' . PLUGIN_DIR . '/.htaccess ' . ABSPATH . '/.htaccess');
</code></pre>
<p>When you add a die() at the end, it catches that there's an error:</p>
<pre><code>exec('ln -s ' . PLUGIN_DIR . '/.htaccess ' . ABSPATH . '/.htaccess') or d... | [
{
"answer_id": 345802,
"author": "Eran Galperin",
"author_id": 10585,
"author_profile": "https://Stackoverflow.com/users/10585",
"pm_score": 5,
"selected": true,
"text": "<p>You can receive the output result of the <a href=\"http://www.php.net/function.exec\" rel=\"nofollow noreferrer\">... | 2008/12/06 | [
"https://Stackoverflow.com/questions/345794",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32881/"
] | Below is the command I tried executing, without success:
```
exec('ln -s ' . PLUGIN_DIR . '/.htaccess ' . ABSPATH . '/.htaccess');
```
When you add a die() at the end, it catches that there's an error:
```
exec('ln -s ' . PLUGIN_DIR . '/.htaccess ' . ABSPATH . '/.htaccess') or die('what?!');
```
For the above exe... | You can receive the output result of the [exec function](http://www.php.net/function.exec) by passing an optional second parameter:
```
exec('ln -s ' . PLUGIN_DIR . '/.htaccess ' . ABSPATH . '/.htaccess',$output);
var_dump($output);
``` |
345,795 | <p>I recently started Erlang, and I notice I constantly get "Warning: variable X is unused" while compiling. For example, take the following function, which finds the maximum element in a list:</p>
<pre><code> max([Head|Tail]) ->
max(Head,Tail).
max(Element,[Head | Tail]) when Element < Head ->... | [
{
"answer_id": 345803,
"author": "Dustin",
"author_id": 39975,
"author_profile": "https://Stackoverflow.com/users/39975",
"pm_score": 4,
"selected": true,
"text": "<p>This should suppress the warning without being confusing:</p>\n\n<pre><code>max(Element,[_Head | Tail]) ->\n max(Ele... | 2008/12/06 | [
"https://Stackoverflow.com/questions/345795",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43791/"
] | I recently started Erlang, and I notice I constantly get "Warning: variable X is unused" while compiling. For example, take the following function, which finds the maximum element in a list:
```
max([Head|Tail]) ->
max(Head,Tail).
max(Element,[Head | Tail]) when Element < Head ->
max(Head,Tail);... | This should suppress the warning without being confusing:
```
max(Element,[_Head | Tail]) ->
max(Element, Tail);
``` |
345,823 | <p>My question pertains to multi-threading in Java. I'm translating an app I wrote in Visual Basic 2008 into Java. There is a class in VB called <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker_members.aspx" rel="nofollow noreferrer">BackgroundWorker</a>, which allows the coder to... | [
{
"answer_id": 345830,
"author": "OscarRyz",
"author_id": 20654,
"author_profile": "https://Stackoverflow.com/users/20654",
"pm_score": 1,
"selected": false,
"text": "<p>What was the mainline again?</p>\n\n<p>Let me see if I get this right.</p>\n\n<p>The background thread fires an event ... | 2008/12/06 | [
"https://Stackoverflow.com/questions/345823",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43874/"
] | My question pertains to multi-threading in Java. I'm translating an app I wrote in Visual Basic 2008 into Java. There is a class in VB called [BackgroundWorker](http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker_members.aspx), which allows the coder to perform a task on another thread, a lot... | The solely intention of the following code is to show how does it looks like when the SwingUtilities.invokeLater method is used.
The effect is the task is executed in the AWT-Event thread ( the one responsible for component painting ) .
The rest ( creating a new thread , creating a gui etc. ) is just scaffold code.
... |
345,838 | <p>With the help of the Stack Overflow community I've written a pretty basic-but fun physics simulator.</p>
<p><img src="https://i.stack.imgur.com/EeqSP.png" alt="alt text" /></p>
<p>You click and drag the mouse to launch a ball. It will bounce around and eventually stop on the "floor".</p>
<p>My next big fe... | [
{
"answer_id": 345857,
"author": "Ryan Fox",
"author_id": 55,
"author_profile": "https://Stackoverflow.com/users/55",
"pm_score": 3,
"selected": false,
"text": "<p>A good way of reducing the number of collision checks is to split the screen into different sections. You then only compare ... | 2008/12/06 | [
"https://Stackoverflow.com/questions/345838",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2635/"
] | With the help of the Stack Overflow community I've written a pretty basic-but fun physics simulator.

You click and drag the mouse to launch a ball. It will bounce around and eventually stop on the "floor".
My next big feature I want to add in is ball to ball collision... | To detect whether two balls collide, just check whether the distance between their centers is less than two times the radius. To do a perfectly elastic collision between the balls, you only need to worry about the component of the velocity that is in the direction of the collision. The other component (tangent to the c... |
345,865 | <p>I'm adding a record like this:</p>
<pre><code> Dim pathString As String = HttpContext.Current.Request.MapPath("Banking.mdb")
Dim odbconBanking As New OleDbConnection _
("Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" + pathString)
Dim sql As String
sql = "INSERT I... | [
{
"answer_id": 345870,
"author": "Christian C. Salvadó",
"author_id": 5445,
"author_profile": "https://Stackoverflow.com/users/5445",
"pm_score": 2,
"selected": false,
"text": "<p><code>\"SELECT @@IDENTITY\"</code> just after the insertion should work with Microsoft.Jet Provider.</p>\n"
... | 2008/12/06 | [
"https://Stackoverflow.com/questions/345865",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32495/"
] | I'm adding a record like this:
```
Dim pathString As String = HttpContext.Current.Request.MapPath("Banking.mdb")
Dim odbconBanking As New OleDbConnection _
("Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" + pathString)
Dim sql As String
sql = "INSERT INTO tblUsers ( Fir... | I believe a parameterized query would look something like this:
```
Dim pathString As String = HttpContext.Current.Request.MapPath("Banking.mdb")
Dim odbconBanking As New OleDbConnection _
("Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" + pathString)
Dim sql As String
sql = "INSERT INTO tblUsers ( Fi... |
345,874 | <p>Using Awk I want to match the <em>entire</em> record using a regular expression. By default the regular expression matching is for parts of a record.</p>
<p>The ideal solution would:</p>
<ul>
<li>Be general for all fields, regardless of the field separator used.</li>
<li>Not treat the entire input as a single fiel... | [
{
"answer_id": 345900,
"author": "Paul Tomblin",
"author_id": 3333,
"author_profile": "https://Stackoverflow.com/users/3333",
"pm_score": 3,
"selected": true,
"text": "<p>You just need to add a beginning and end anchor to your regex:</p>\n\n<pre><code>/^[01]*_[01]*$/ { print $0 }\n</code... | 2008/12/06 | [
"https://Stackoverflow.com/questions/345874",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Using Awk I want to match the *entire* record using a regular expression. By default the regular expression matching is for parts of a record.
The ideal solution would:
* Be general for all fields, regardless of the field separator used.
* Not treat the entire input as a single field and parse it manually using strin... | You just need to add a beginning and end anchor to your regex:
```
/^[01]*_[01]*$/ { print $0 }
``` |
345,883 | <p>Since String implements <code>IEnumerable<char></code>, I was expecting to see the Enumerable extension methods in Intellisense, for example, when typing the period in</p>
<pre><code>String s = "asdf";
s.
</code></pre>
<p>I was expecting to see <code>.Select<char>(...)</code>, <code>.ToList<char>... | [
{
"answer_id": 345889,
"author": "JaredPar",
"author_id": 23283,
"author_profile": "https://Stackoverflow.com/users/23283",
"pm_score": 5,
"selected": true,
"text": "<p>It's by explicit design. The problem is that while String most definitely implements <code>IEnumerable<T></code>... | 2008/12/06 | [
"https://Stackoverflow.com/questions/345883",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22539/"
] | Since String implements `IEnumerable<char>`, I was expecting to see the Enumerable extension methods in Intellisense, for example, when typing the period in
```
String s = "asdf";
s.
```
I was expecting to see `.Select<char>(...)`, `.ToList<char>()`, etc.
I was then suprised to see that the extension methods **do** ... | It's by explicit design. The problem is that while String most definitely implements `IEnumerable<T>`, most people don't think of it, or more importantly use it, in that way.
String has a fairly small number of methods. Initially we did not filter extension methods off of String and the result was a lot of negative f... |
345,920 | <p>I need to invoke a VBA macro within an Excel workbook from a python script. Someone else has provided the Excel workbook with the macro. The macro grabs updated values from an external database, and performs some fairly complex massaging of the data. I need the results from this massaging, and I don't really want... | [
{
"answer_id": 345995,
"author": "shahkalpesh",
"author_id": 23574,
"author_profile": "https://Stackoverflow.com/users/23574",
"pm_score": 2,
"selected": true,
"text": "<p>I am sorry, I dont know python enough.\nHowever, the following should help.</p>\n\n<p>Excel's Application object has... | 2008/12/06 | [
"https://Stackoverflow.com/questions/345920",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40514/"
] | I need to invoke a VBA macro within an Excel workbook from a python script. Someone else has provided the Excel workbook with the macro. The macro grabs updated values from an external database, and performs some fairly complex massaging of the data. I need the results from this massaging, and I don't really want to du... | I am sorry, I dont know python enough.
However, the following should help.
Excel's Application object has a Run method - which takes the name of the macro alongwith arguments to it.
Lets assume that the workbook has a macro named test.
```
Sub test(ByVal i As Integer)
MsgBox "hello world " & i
End Sub
```
You can... |
345,929 | <p>I have a automated (Visual Build) build process that runs: </p>
<p>A set of automated smoke tests (AutoIT) that enters data into a .Net WinForm app that writes to a cleanly seeded MS SQL 2005 DB. </p>
<p>A SQL query that returns the data I want. </p>
<pre><code>SELECT i.ID, i.firstname, i.lastname, i.ModDate
FROM... | [
{
"answer_id": 574847,
"author": "Maksym Gontar",
"author_id": 67407,
"author_profile": "https://Stackoverflow.com/users/67407",
"pm_score": 0,
"selected": false,
"text": "<p>So, why don't you use NUnit tests project to be with build right after main project testing?\nYou can easily test... | 2008/12/06 | [
"https://Stackoverflow.com/questions/345929",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8900/"
] | I have a automated (Visual Build) build process that runs:
A set of automated smoke tests (AutoIT) that enters data into a .Net WinForm app that writes to a cleanly seeded MS SQL 2005 DB.
A SQL query that returns the data I want.
```
SELECT i.ID, i.firstname, i.lastname, i.ModDate
FROM app.Individual i
Where last... | The automation tool TestComplete does this well: <http://www.automatedqa.com/products/testcomplete/> |
345,991 | <p>Okay, what is it, and why does it occur on Win2003 server, but not on WinXP.</p>
<p>It doesn't seem to affect my application at all, but I get this error message when I close the application. And it's annoying (as errors messages should be).</p>
<p>I am using pyOpenGl and wxPython to do the graphics stuff. Unfor... | [
{
"answer_id": 346501,
"author": "Kozyarchuk",
"author_id": 52490,
"author_profile": "https://Stackoverflow.com/users/52490",
"pm_score": 9,
"selected": true,
"text": "<p>Looks like OpenGL is trying to report some error on Win2003, however you've not configured your system where to outpu... | 2008/12/06 | [
"https://Stackoverflow.com/questions/345991",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30862/"
] | Okay, what is it, and why does it occur on Win2003 server, but not on WinXP.
It doesn't seem to affect my application at all, but I get this error message when I close the application. And it's annoying (as errors messages should be).
I am using pyOpenGl and wxPython to do the graphics stuff. Unfortunately, I'm a C# ... | Looks like OpenGL is trying to report some error on Win2003, however you've not configured your system where to output logging info.
You can add the following to the beginning of your program and you'll see details of the error in stderr.
```
import logging
logging.basicConfig()
```
Checkout documentation on [loggi... |
345,997 | <p>I accidentally committed too many files to an SVN repository and changed some things I didn't mean to. (Sigh.) In order to revert them to their prior state, the best I could come up with was </p>
<pre><code>svn rm l3toks.dtx
svn copy -r 854 svn+ssh://<repository URL>/l3toks.dtx ./l3toks.dtx
</code></pre>
<p>... | [
{
"answer_id": 346017,
"author": "luapyad",
"author_id": 39578,
"author_profile": "https://Stackoverflow.com/users/39578",
"pm_score": 5,
"selected": false,
"text": "<p>Check out \"<a href=\"http://svnbook.red-bean.com/en/1.5/svn.branchmerge.basicmerging.html#svn.branchmerge.basicmerging... | 2008/12/06 | [
"https://Stackoverflow.com/questions/345997",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4161/"
] | I accidentally committed too many files to an SVN repository and changed some things I didn't mean to. (Sigh.) In order to revert them to their prior state, the best I could come up with was
```
svn rm l3toks.dtx
svn copy -r 854 svn+ssh://<repository URL>/l3toks.dtx ./l3toks.dtx
```
Jeez! Is there no better way? Wh... | ```
svn merge -r 854:853 l3toks.dtx
```
or
```
svn merge -c -854 l3toks.dtx
```
The two commands [are equivalent](http://svnbook.red-bean.com/en/1.7/svn.ref.svn.c.merge.html). |
346,015 | <p>I have a problem with an object I have created that looks something like this:</p>
<pre><code>var myObject = {
AddChildRowEvents: function(row, p2) {
if(document.attachEvent) {
row.attachEvent('onclick', function(){this.DoSomething();});
} else {
row.addEventListener('cl... | [
{
"answer_id": 346044,
"author": "Mike Kantor",
"author_id": 14607,
"author_profile": "https://Stackoverflow.com/users/14607",
"pm_score": 5,
"selected": false,
"text": "<p>WHen the function is called, \"this\" refers to row. If you want to have the object, you can do it something like ... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346015",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a problem with an object I have created that looks something like this:
```
var myObject = {
AddChildRowEvents: function(row, p2) {
if(document.attachEvent) {
row.attachEvent('onclick', function(){this.DoSomething();});
} else {
row.addEventListener('click', function... | WHen the function is called, "this" refers to row. If you want to have the object, you can do it something like this:
]
```
AddChildRowEvents: function(row, p2) {
var theObj = this;
if(document.attachEvent) {
row.attachEvent('onclick', function(){theObj.DoSomething();});
} else {
row.addE... |
346,021 | <p>Suppose I have this code:</p>
<pre><code>var myArray = new Object();
myArray["firstname"] = "Bob";
myArray["lastname"] = "Smith";
myArray["age"] = 25;
</code></pre>
<p>Now if I wanted to remove "lastname"?....is there some equivalent of
<code>myArray["... | [
{
"answer_id": 346022,
"author": "Dennis C",
"author_id": 40214,
"author_profile": "https://Stackoverflow.com/users/40214",
"pm_score": 11,
"selected": true,
"text": "<p>Objects in JavaScript can be thought of as associative arrays, mapping keys (properties) to values.</p>\n\n<p>To remov... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346021",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Suppose I have this code:
```
var myArray = new Object();
myArray["firstname"] = "Bob";
myArray["lastname"] = "Smith";
myArray["age"] = 25;
```
Now if I wanted to remove "lastname"?....is there some equivalent of
`myArray["lastname"].remove()`?
(I need the element gone because the number of elements is important an... | Objects in JavaScript can be thought of as associative arrays, mapping keys (properties) to values.
To remove a property from an object in JavaScript you use the [`delete`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/delete) operator:
```
const o = { lastName: 'foo' }
o.hasOwnProperty(... |
346,045 | <p>I'm trying to figure out how to fix the selection box size under JCrop. The documentation mentions how to set an initial selection area but not how to make it fixed size. Does anybody knows how could I make it fixed. Thanks in advance.</p>
<p><a href="http://deepliquid.com/content/Jcrop_Manual.html" rel="noreferrer... | [
{
"answer_id": 346302,
"author": "muhuk",
"author_id": 42188,
"author_profile": "https://Stackoverflow.com/users/42188",
"pm_score": 3,
"selected": false,
"text": "<p>Using <a href=\"http://deepliquid.com/projects/Jcrop/demos.php?demo=handler\" rel=\"noreferrer\">this example</a> you sho... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346045",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43092/"
] | I'm trying to figure out how to fix the selection box size under JCrop. The documentation mentions how to set an initial selection area but not how to make it fixed size. Does anybody knows how could I make it fixed. Thanks in advance.
<http://deepliquid.com/content/Jcrop_Manual.html> | You are basically looking for the API section. Having extensively used this plugin myself, I know exactly what you're looking for:
```
var api;
var cropWidth = 100;
var cropHeight = 100;
$(window).load(function() {
// set default options
var opt = {};
// if height and width must be exact, dont allow res... |
346,048 | <p>I have this code:</p>
<pre><code> Dim pathString As String = HttpContext.Current.Request.MapPath("Banking.mdb")
Dim odbconBanking As New OleDbConnection _
("Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" + pathString)
Dim sql As String
sql = "UPDATE tblAccounts ba... | [
{
"answer_id": 346051,
"author": "shahkalpesh",
"author_id": 23574,
"author_profile": "https://Stackoverflow.com/users/23574",
"pm_score": 0,
"selected": false,
"text": "<p>You are missing SET as part of UPDATE.</p>\n\n<p>It should be UPDATE tablename SET fieldname = ... WHERE [criteria]... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346048",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32495/"
] | I have this code:
```
Dim pathString As String = HttpContext.Current.Request.MapPath("Banking.mdb")
Dim odbconBanking As New OleDbConnection _
("Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" + pathString)
Dim sql As String
sql = "UPDATE tblAccounts balance = " & CDbl(b... | I think the missing is SET.
Try: UPDATE table SET field = newvalue WHERE criteria;
Just modify:
```
sql = "UPDATE tblAccounts SET balance = " & CDbl(balance + value) & " WHERE(accountID = " & accountID & ")"
```
<http://office.microsoft.com/en-us/access/HA100765271033.aspx> |
346,057 | <p>I have a Delphi 7 app using <code>ADO/MSDASQL.1</code> provider and I wonder if it is possible to "log" the SQL queries sent to the DB in a easy way? Just like the SQL profiler in SQL Server?</p>
| [
{
"answer_id": 346221,
"author": "Cesar Romero",
"author_id": 36875,
"author_profile": "https://Stackoverflow.com/users/36875",
"pm_score": 3,
"selected": false,
"text": "<p>Inside your application you can log the commands in TADOConnection.OnWillExecute event, you only have to save the ... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346057",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38165/"
] | I have a Delphi 7 app using `ADO/MSDASQL.1` provider and I wonder if it is possible to "log" the SQL queries sent to the DB in a easy way? Just like the SQL profiler in SQL Server? | Inside your application you can log the commands in TADOConnection.OnWillExecute event, you only have to save the CommandText, but you can also log a lot of other options.
```
procedure TForm23.ADOConnection1WillExecute(Connection: TADOConnection; var
CommandText: WideString; var CursorType: TCursorType; var LockTyp... |
346,092 | <p>I have a staging Rails site up that's running on MySQL 5.0.32-Debian.</p>
<p>On this particular site, all of my tables are using <code>utf8 / utf8_general_ci</code> encoding.</p>
<p>Inside that database, I have some data that looks like so:</p>
<pre><code>mysql> select * from currency_types limit 1,10;
+------... | [
{
"answer_id": 346109,
"author": "Subimage",
"author_id": 10596,
"author_profile": "https://Stackoverflow.com/users/10596",
"pm_score": 6,
"selected": true,
"text": "<p>AHA! Seems I had some table information encoded in latin1 before, and stupidly changed the databases to utf8 without co... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346092",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10596/"
] | I have a staging Rails site up that's running on MySQL 5.0.32-Debian.
On this particular site, all of my tables are using `utf8 / utf8_general_ci` encoding.
Inside that database, I have some data that looks like so:
```
mysql> select * from currency_types limit 1,10;
+------+-----------------+---------+
| code | nam... | AHA! Seems I had some table information encoded in latin1 before, and stupidly changed the databases to utf8 without converting.
Running the following fixed that currency\_types table:
```
mysqldump -u root -p --opt --default-character-set=latin1 --skip-set-charset DBNAME > DBNAME.sql
mysql -u root -p --default-cha... |
346,107 | <p>how to create a shortcut for a exe from a batch file.</p>
<p>i tried </p>
<pre><code>call link.bat "c:\program Files\App1\program1.exe" "C:\Documents and Settings\%USERNAME%\Desktop" "C:\Documents and Settings\%USERNAME%\Start Menu\Programs" "Program1 shortcut"
</code></pre>
<p>but it did not worked.</p>
<p>link... | [
{
"answer_id": 346118,
"author": "Martin",
"author_id": 770,
"author_profile": "https://Stackoverflow.com/users/770",
"pm_score": 1,
"selected": false,
"text": "<p>Alternative method, using a third party utility:</p>\n\n<p><a href=\"http://www.xxcopy.com/xxcopy38.htm\" rel=\"nofollow nor... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346107",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32670/"
] | how to create a shortcut for a exe from a batch file.
i tried
```
call link.bat "c:\program Files\App1\program1.exe" "C:\Documents and Settings\%USERNAME%\Desktop" "C:\Documents and Settings\%USERNAME%\Start Menu\Programs" "Program1 shortcut"
```
but it did not worked.
link.bat can be found at
<http://www.robvan... | Your link points to a Windows 95/98 version and I guess you have at least Windows 2000 or XP. You should try the NT version [here](http://www.robvanderwoude.com/amb_shortcutsnt.html).
Alternatively use a little VBScript that you can call from the command line:
```
set objWSHShell = CreateObject("WScript.Shell")
set o... |
346,111 | <p>I'm using C# with <a href="http://en.wikipedia.org/wiki/.NET_Framework" rel="noreferrer">.NET</a> 3.5. Is it possible to serialize a block of code, transmit it somewhere, deserialize it, and then execute it?</p>
<p>An example usage of this would be:</p>
<pre><code>Action<object> pauxPublish = delegate(object... | [
{
"answer_id": 346122,
"author": "Daniel Earwicker",
"author_id": 27423,
"author_profile": "https://Stackoverflow.com/users/27423",
"pm_score": 1,
"selected": false,
"text": "<p>Compile it into a separate assembly, send the assembly, have the other process load it.</p>\n\n<p>You might wa... | 2008/12/06 | [
"https://Stackoverflow.com/questions/346111",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38438/"
] | I'm using C# with [.NET](http://en.wikipedia.org/wiki/.NET_Framework) 3.5. Is it possible to serialize a block of code, transmit it somewhere, deserialize it, and then execute it?
An example usage of this would be:
```
Action<object> pauxPublish = delegate(object o)
{
if (!(o is string))
{
return;
... | **YES!!!**
We have done this for a very real case of performance. Doing this at runtime or using a DSL was not an option due to performance.
We compile the code into an assembly, and rip the IL out of the method. We then get all the metadata associated with this method and serialize the whole mess via XML, compress ... |