instruction stringlengths 14 27.6k | completion stringlengths 3 38.3k | __original_row_idx int64 0 50k | conversations listlengths 2 2 |
|---|---|---|---|
It seems that everybody knows you're supposed to have a clear distinction between the GUI, the business logic, and the data access. I recently talked to a programmer who bragged about always having a clean data access layer. I looked at this code, and it turns out his data access layer is just a small class wrapping ... | A Data Access Layer (DAL) is a structured and organized approach to managing data interactions within an application. The purpose of a DAL is to abstract and encapsulate the logic required to access data sources, thereby promoting separation of concerns, maintainability, testability, and reusability. Here's how I would... | 38,025 | [
{
"from": "human",
"value": "It seems that everybody knows you're supposed to have a clear distinction between the GUI, the business logic, and the data access. I recently talked to a programmer who bragged about always having a clean data access layer. I looked at this code, and it turns out his data acc... |
I'm completely new at C# and NUnit.
In Boost.Test there is a family of BOOST_*_THROW macros. In Python's test module there is TestCase.assertRaises method.
As far as I understand it, in C# with NUnit (2.4.8) the only method of doing exception test is to use ExpectedExceptionAttribute.
Why should I prefer ExpectedExcept... | NUnit, as you noted, provides a way to test for exceptions using the `ExpectedExceptionAttribute` in older versions like 2.4.8. However, in more recent versions of NUnit (3.x and above), the preferred approach is to use the `Assert.Throws` method, which provides more flexibility and allows you to assert additional cond... | 42,135 | [
{
"from": "human",
"value": "I'm completely new at C# and NUnit.\nIn Boost.Test there is a family of BOOST_*_THROW macros. In Python's test module there is TestCase.assertRaises method.\nAs far as I understand it, in C# with NUnit (2.4.8) the only method of doing exception test is to use ExpectedExceptionAt... |
What is the point of an action returning ActionResult?
| In ASP.NET (especially in ASP.NET MVC and ASP.NET Core), an action method in a controller typically returns an `ActionResult`. The `ActionResult` class serves as a base class for different types of responses that an action method can produce. Here are some key reasons why actions return `ActionResult`:
1. **Flexibilit... | 38,973 | [
{
"from": "human",
"value": "What is the point of an action returning ActionResult?\n"
},
{
"from": "gpt",
"value": "In ASP.NET (especially in ASP.NET MVC and ASP.NET Core), an action method in a controller typically returns an `ActionResult`. The `ActionResult` class serves as a base class for ... |
So I started with a web services project (just a dynamic web project) that builds and debugs correctly from eclipse. We've pulled a chunk of common code out that we want to put into a shared library so now those classes are going into a separate jar project that the web project references.
On the web project, I did Pr... | In Eclipse, when you have a separate Java project (like your shared library) that needs to be included in the runtime classpath of a dynamic web project (like your web service project), you need to ensure that the dependency is properly configured for runtime as well. Here are a few steps to ensure that your jar projec... | 41,525 | [
{
"from": "human",
"value": "So I started with a web services project (just a dynamic web project) that builds and debugs correctly from eclipse. We've pulled a chunk of common code out that we want to put into a shared library so now those classes are going into a separate jar project that the web project... |
What is the preferred/easiest way to manipulate TDesC strings, for example to obtain a substring.
I will give you an example of my scenario.
RBuf16 buf;
...
CEikLabel label;
...
label->SetTextL(buf); // (SetTextL takes a const TDesC&)
I want to get a substring from buf. So do I want to manipulate the RBuf16 directly a... | When working with `RBuf16` in Symbian OS, you have a couple of options for manipulating the strings, including obtaining a substring. Let's walk through how to get a substring from your `RBuf16` and set the text for the `CEikLabel`.
### Working with `RBuf16` and TDesC
You do not need to convert the `RBuf16` to a `con... | 41,358 | [
{
"from": "human",
"value": "What is the preferred/easiest way to manipulate TDesC strings, for example to obtain a substring.\nI will give you an example of my scenario.\nRBuf16 buf;\n...\nCEikLabel label;\n...\nlabel->SetTextL(buf); // (SetTextL takes a const TDesC&)\n\nI want to get a substring from buf.... |
Does anybody know if it is possible to migrate separate projects from a TFS 2005 server to a TFS 2008 Server?
| Yes, it is possible to migrate separate projects from a TFS 2005 server to a TFS 2008 server, but the process can be complex and requires careful planning. Here are the general steps you should follow:
1. **Backup**: Before starting the migration process, make sure to back up your TFS 2005 server, including both the S... | 43,268 | [
{
"from": "human",
"value": "Does anybody know if it is possible to migrate separate projects from a TFS 2005 server to a TFS 2008 Server?\n"
},
{
"from": "gpt",
"value": "Yes, it is possible to migrate separate projects from a TFS 2005 server to a TFS 2008 server, but the process can be complex... |
I'm developing a web tool using JSP, where there are many users of multiple kind (i.e. administrators, guest, write-enabled users, ...). Since this will be a subscription based system (i.e. user pay for a 3/6/12 month subscription), I need to enforce at most 1 login per user at the same time.
For example, say Mr. John ... | To enforce a single session per user in your web application using JSP, you can implement a mechanism that tracks active sessions for each user and restricts additional logins when an existing session is active. Here’s a general approach to achieve this:
### Steps to Enforce Single Login Per User
1. **Session Trackin... | 39,822 | [
{
"from": "human",
"value": "I'm developing a web tool using JSP, where there are many users of multiple kind (i.e. administrators, guest, write-enabled users, ...). Since this will be a subscription based system (i.e. user pay for a 3/6/12 month subscription), I need to enforce at most 1 login per user at ... |
I have a project built and packaged with a specific version of jsp-apiand servlet-api jar files. Now I want these jars to be loaded when deploying the web project on any application server for example tomcat, WAS, Weblogic etc.
The behaviour I have seen on tomcat is that it gives messages that the packaged version of t... | When deploying a web application, especially when it involves different Java EE or Jakarta EE application servers (like Tomcat, WebSphere Application Server, WebLogic, etc.), it's crucial to manage dependencies properly to ensure consistent behavior across environments.
### Java EE / Jakarta EE Specification
1. **Con... | 41,927 | [
{
"from": "human",
"value": "I have a project built and packaged with a specific version of jsp-apiand servlet-api jar files. Now I want these jars to be loaded when deploying the web project on any application server for example tomcat, WAS, Weblogic etc.\nThe behaviour I have seen on tomcat is that it giv... |
I know this sounds very basic but I just started with visual studio and I am looking for instructions on the basic control functions. In general, what the different options do. I am just trying to get familiar with some of the functions and I am not completely understanding how to manipulate the data. For example, h... | It's perfectly normal to feel overwhelmed when starting with a new development environment like Visual Studio, especially if you're new to programming. Here are some basic concepts and examples to help you get started:
### Basic Control Functions in Visual Studio (Windows Forms)
1. **Controls**: These are UI elements... | 39,802 | [
{
"from": "human",
"value": "I know this sounds very basic but I just started with visual studio and I am looking for instructions on the basic control functions. In general, what the different options do. I am just trying to get familiar with some of the functions and I am not completely understanding ho... |
I am currently looking at the "unload" event of a window to try to determine how the "unload" event was triggered, but am having little success. Is there a way to determine how the javascript event was triggered?
Page Refresh
Back Button (or navigate away from the page)
Closing the Browser
Essentially I need to execu... | Detecting the specific action that triggered the `unload` event in JavaScript is inherently challenging, as the browser does not provide a built-in mechanism to distinguish between different types of navigations (like refresh, back navigation, or closing the browser). However, you can implement some workarounds to achi... | 40,899 | [
{
"from": "human",
"value": "I am currently looking at the \"unload\" event of a window to try to determine how the \"unload\" event was triggered, but am having little success. Is there a way to determine how the javascript event was triggered?\n\nPage Refresh\nBack Button (or navigate away from the page)\... |
How can I bring my WPF application to the front of the desktop? So far I've tried:
SwitchToThisWindow(new WindowInteropHelper(Application.Current.MainWindow).Handle, true);
SetWindowPos(new WindowInteropHelper(Application.Current.MainWindow).Handle, IntPtr.Zero, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
SetForegroundWind... | When dealing with bringing a WPF application to the front of the desktop, particularly when invoked via a global hotkey, there are some additional considerations to take into account. The main issue arises from the focus behavior of Windows and how applications are allowed to steal focus from other applications.
Here ... | 42,326 | [
{
"from": "human",
"value": "How can I bring my WPF application to the front of the desktop? So far I've tried:\nSwitchToThisWindow(new WindowInteropHelper(Application.Current.MainWindow).Handle, true);\n\nSetWindowPos(new WindowInteropHelper(Application.Current.MainWindow).Handle, IntPtr.Zero, 0, 0, 0, 0, ... |
I need to write a little tool for a customer to be run on Windows 98. Since this is a very small project I'd hope that I could avoid having to go native C++ and use C#.
The .net Framework 2.0 download claims to support Windows 98. Are there any caveats or hitches to be aware of when installing or coding?
| Developing a tool for Windows 98 using C# and .NET Framework 2.0 is indeed possible, but there are several important caveats and considerations to keep in mind:
1. **Installation Requirements**: While .NET Framework 2.0 claims to support Windows 98, the installation may require certain prerequisites, such as Windows I... | 40,313 | [
{
"from": "human",
"value": "I need to write a little tool for a customer to be run on Windows 98. Since this is a very small project I'd hope that I could avoid having to go native C++ and use C#.\nThe .net Framework 2.0 download claims to support Windows 98. Are there any caveats or hitches to be aware of... |
I've seen many website designs with frequent inclusions of 'back to top' links and am just wondering when, if ever, they can really be justified? What use cases demand a 'back top top' link, and what are their effects on usability?
| 'Back to top' links can enhance usability in various scenarios, particularly on long web pages or content-heavy sites. Here are some use cases where these links are justified, along with their effects on usability:
### Use Cases for 'Back to Top' Links
1. **Long Content Pages:**
- **Examples:** Blog posts, article... | 43,208 | [
{
"from": "human",
"value": "I've seen many website designs with frequent inclusions of 'back to top' links and am just wondering when, if ever, they can really be justified? What use cases demand a 'back top top' link, and what are their effects on usability?\n"
},
{
"from": "gpt",
"value": "'B... |
Writing a ton of web applications leveraging JSON/AJAX, I find myself returning tons literal javascript objects (JSON). For example, I may be request all the Cats from GetCats.asp. It would return:
[
{ 'id': 0, 'name': 'Persian' },
{ 'id': 1, 'name': 'Calico' },
{ 'id': 2, 'name': 'Tabby' }
]
Now, these are a... | Yes, you can efficiently convert your literal JSON objects into instances of a user-defined object with behaviors using a combination of JavaScript’s `map` function and the `Object.assign` method (or even using the spread operator). This allows you to create new instances of your `Cat` function while copying properties... | 41,578 | [
{
"from": "human",
"value": "Writing a ton of web applications leveraging JSON/AJAX, I find myself returning tons literal javascript objects (JSON). For example, I may be request all the Cats from GetCats.asp. It would return:\n\n[\n { 'id': 0, 'name': 'Persian' },\n { 'id': 1, 'name': 'Calico' },\n { ... |
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
| To perform an inner join on multiple columns from the same tables using LINQ, you can use the `join` clause multiple times. However, it's important to structure your query correctly to reflect the conditions accurately.
In your case, you want to join `table1` with `table2` based on two conditions: one for the `ID` and... | 42,289 | [
{
"from": "human",
"value": "How do I inner join multiple columns from the same tables via Linq? \nFor example:\nI already have this...\njoin c in db.table2 on table2.ID equals table1.ID\n\nI need to add this...\njoin d in db.table2 on table2.Country equals table1.Country \n\n"
},
{
"from": "gpt",
... |
I'm writing an application that outputs xml and I'm using a jsp to do it (in eclipse). It works fine, but the jsp editor complains about the xml tags. Is there a way to convince the jsp editor to validate xml instead of html?
| In Eclipse, the JSP editor may default to validating the content as HTML rather than XML, which can lead to warnings or errors when you’re using XML tags. Here are a few steps you can take to change the behavior of the editor and improve your experience while working with XML output in JSP:
### 1. Set Content Type
Yo... | 40,965 | [
{
"from": "human",
"value": "I'm writing an application that outputs xml and I'm using a jsp to do it (in eclipse). It works fine, but the jsp editor complains about the xml tags. Is there a way to convince the jsp editor to validate xml instead of html?\n"
},
{
"from": "gpt",
"value": "In Eclip... |
Following on from this question, I now want to know how to stop an ANT script from executing if the preceding build failed. I can't see a way in the Build setup in Eclipse of chaining builds together based on their success.
I think I am lookikng for either a way to pass the previous build status into my ANT script s... | In Eclipse, there isn't a built-in way to chain builds in a direct manner based on their success or failure. However, there are several approaches you can take to achieve the desired behavior of stopping an ANT script from executing if a preceding build fails.
### Option 1: Use Ant's Conditional Execution
If you can ... | 41,690 | [
{
"from": "human",
"value": "Following on from this question, I now want to know how to stop an ANT script from executing if the preceding build failed. I can't see a way in the Build setup in Eclipse of chaining builds together based on their success. \nI think I am lookikng for either a way to pass the ... |
I am trying to merge several XML files in a single XDocument object.
Merge does not exist in XDocument object. I miss this.
Has anyone already implemented a Merge extension method for XDocument, or something similar ?
| Merging multiple XML files into a single `XDocument` can be accomplished using LINQ to XML in C#. While there isn't a built-in `Merge` method for `XDocument`, you can easily create an extension method to achieve this functionality.
Here’s an example of how to implement a `Merge` extension method for `XDocument` that c... | 42,827 | [
{
"from": "human",
"value": "I am trying to merge several XML files in a single XDocument object.\nMerge does not exist in XDocument object. I miss this.\nHas anyone already implemented a Merge extension method for XDocument, or something similar ?\n"
},
{
"from": "gpt",
"value": "Merging multip... |
We have a Hibernate/Spring application that have the following Spring beans:
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager" />
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean" />
When wiring the applicatio... | In Hibernate, when you're using JPA annotations (like `@Entity`), it requires a visible constructor for the entity class to create instances when retrieving data from the database. This is because Hibernate uses reflection to instantiate entities. If you define a private constructor, Hibernate will not be able to acces... | 41,661 | [
{
"from": "human",
"value": "We have a Hibernate/Spring application that have the following Spring beans:\n<bean id=\"transactionManager\" class=\"org.springframework.orm.hibernate3.HibernateTransactionManager\" />\n<bean id=\"sessionFactory\" class=\"org.springframework.orm.hibernate3.annotation.Annotation... |
This one has us all baffled at work. We have two services running on .net 3.5 SP1 that hits up sharepoint, and return Lists of model objects that are pretty similar. One of them works fine, the other throws an EngineExecutionException on the return.
I know that is sort of vague, but everything executes fine right up un... | The `EngineExecutionException` in a .NET application, particularly when interacting with SharePoint, can occur for a variety of reasons. Here are some steps and considerations to help you diagnose and potentially resolve the issue:
1. **Check Inner Exception**: The `EngineExecutionException` can wrap another exception... | 42,269 | [
{
"from": "human",
"value": "This one has us all baffled at work. We have two services running on .net 3.5 SP1 that hits up sharepoint, and return Lists of model objects that are pretty similar. One of them works fine, the other throws an EngineExecutionException on the return.\nI know that is sort of vague... |
I am hearing a lot of rumours that Linq2Sql is not going to be supported any more in the next version of .net. I like Linq2Sql a lot and find it very easy / lightweight to work with. I can understand some of the problems people have had with it (ppl used to nhibernate...) but used correctly I think most problems can be... | LINQ to SQL is a lightweight Object-Relational Mapping (ORM) framework that allows developers to work with databases using .NET languages. While it is user-friendly and well-integrated with the .NET ecosystem, there are several disadvantages associated with it:
1. **Limited Database Support**: LINQ to SQL is primarily... | 41,051 | [
{
"from": "human",
"value": "I am hearing a lot of rumours that Linq2Sql is not going to be supported any more in the next version of .net. I like Linq2Sql a lot and find it very easy / lightweight to work with. I can understand some of the problems people have had with it (ppl used to nhibernate...) but us... |
Is there any way to use the VS2008 built-in Refactoring functionality on VB.NET projects?
| Yes, Visual Studio 2008 does include built-in refactoring capabilities for VB.NET projects, though they are somewhat limited compared to later versions of Visual Studio. Here’s how you can use the refactoring features that are available:
### Using Built-in Refactoring Features in VS2008
1. **Rename**:
- To rename ... | 42,388 | [
{
"from": "human",
"value": "Is there any way to use the VS2008 built-in Refactoring functionality on VB.NET projects? \n"
},
{
"from": "gpt",
"value": "Yes, Visual Studio 2008 does include built-in refactoring capabilities for VB.NET projects, though they are somewhat limited compared to later ... |
Working with dates in ruby and rails on windows, I'm having problems with pre-epoch dates (before 1970) throwing out of range exceptions. I tried using both Time and DateTime objects, but still have the same problems.
| Working with dates before the Unix epoch (January 1, 1970) can indeed lead to issues in Ruby and Rails, particularly on Windows, where the handling of time and date objects can behave differently than on UNIX-like systems.
### Common Issues with Pre-Epoch Dates
1. **Time Class Limitations**: The `Time` class in Ruby ... | 1,588 | [
{
"from": "human",
"value": "Working with dates in ruby and rails on windows, I'm having problems with pre-epoch dates (before 1970) throwing out of range exceptions. I tried using both Time and DateTime objects, but still have the same problems.\n"
},
{
"from": "gpt",
"value": "Working with dat... |
For example, I issued an ALTER TABLE statement to create an index on a MEDIUMTEXT field in an InnoDB table that has 134k rows where the size of the index was 255 bytes and the average size of the data in the field is 30k. This command has been running for the last 15 minutes or so (and is the only thing running on the... | When dealing with long-running `ALTER TABLE` statements in MySQL, particularly with indexes on large text fields like `MEDIUMTEXT`, it can be challenging to predict completion time. However, you can use a few strategies and tools to monitor the progress and performance of the operation:
1. **Check Process List**: Use ... | 1,351 | [
{
"from": "human",
"value": "For example, I issued an ALTER TABLE statement to create an index on a MEDIUMTEXT field in an InnoDB table that has 134k rows where the size of the index was 255 bytes and the average size of the data in the field is 30k. This command has been running for the last 15 minutes or... |
The default behavior of NHibernate is the write all changes to objects to the database when Session.Flush() is called. It does this whether you want it to or not.
How do we prevent writing bad data to the database when we need to do things like validate business rules or input?
For instance ..
Customer Name is not nu... | In NHibernate, as you've pointed out, calling `Session.Flush()` will write all changes made to your entities to the database. To prevent unwanted data changes, especially when performing business rule validation, there are several strategies you can use:
### 1. **Manual Control of `Session.Flush()`**
One of the simple... | 36,713 | [
{
"from": "human",
"value": "The default behavior of NHibernate is the write all changes to objects to the database when Session.Flush() is called. It does this whether you want it to or not.\nHow do we prevent writing bad data to the database when we need to do things like validate business rules or input?... |
I have a 5 ASPX page wizard.
Each one contains a SaveAndExit button that executes a C# function on a common static class. After saving, the C# code redirects to another page.
Is there a way for running javascript: alert('Data Saved'); after the saving, and before new page is Loaded.
| Yes, you can achieve this by using a combination of server-side C# and client-side JavaScript. When you want to display a JavaScript alert after your C# function executes and before the page redirects, you can use the `ClientScript` or `ScriptManager` to register a script that will run on the client side.
Here’s how y... | 42,382 | [
{
"from": "human",
"value": "I have a 5 ASPX page wizard.\nEach one contains a SaveAndExit button that executes a C# function on a common static class. After saving, the C# code redirects to another page.\nIs there a way for running javascript: alert('Data Saved'); after the saving, and before new page is ... |
Should be simple and quick: I want a C# equivalent to the following Java code:
orig: for(String a : foo) {
for (String b : bar) {
if (b.equals("buzz")) {
continue orig;
}
}
// other code comes here...
}
Edit:
OK it seems there is no such equivalent (hey - Jon Skeet himself said there isn't, that s... | You're correct that there isn't a direct equivalent in C# for the labeled `continue` statement from Java. However, your approach to using a boolean flag to achieve similar logic is a good solution.
Here’s how you can implement the equivalent logic in C# using your proposed method with a boolean flag:
```csharp
foreac... | 44,129 | [
{
"from": "human",
"value": "Should be simple and quick: I want a C# equivalent to the following Java code:\norig: for(String a : foo) {\n for (String b : bar) {\n if (b.equals(\"buzz\")) {\n continue orig;\n }\n }\n // other code comes here...\n}\n\n\nEdit:\nOK it seems there is no such equiv... |
I have multiple iframes which are displaying same collection of data (help in asp.net Cache).
After the modifies the data on one of the frames, I would like all of the others to reflect the update without the need for explicit postback on each one of them.
So the question is: What is the easiest and most elegant way t... | To keep multiple iframes synchronized after data modifications without requiring explicit postbacks for each one, you can use several approaches, including AJAX polling, WebSockets, or using the `postMessage` API for communication between the main page and iframes. Below is a common and elegant way to achieve synchroni... | 36,758 | [
{
"from": "human",
"value": "I have multiple iframes which are displaying same collection of data (help in asp.net Cache).\nAfter the modifies the data on one of the frames, I would like all of the others to reflect the update without the need for explicit postback on each one of them. \nSo the question is:... |
I want to make custom control which has couple of <input type='checkbox' /> controls which I render in Render method.
Is it possible to retain ViewState (e.g. checked or not) on these Controls?
There is a way of doing this by using ASP.NET server CheckBox control,
adding them in OnLoad event with this.Controls.Add(),... | Yes, it is possible to retain the state of custom checkbox controls in ASP.NET without using ASP.NET server controls like `CheckBox`. You can achieve this by handling the ViewState and PostBack mechanism manually in your custom control.
To create a custom control that includes several `<input type='checkbox'>` element... | 39,459 | [
{
"from": "human",
"value": "I want to make custom control which has couple of <input type='checkbox' /> controls which I render in Render method.\nIs it possible to retain ViewState (e.g. checked or not) on these Controls? \nThere is a way of doing this by using ASP.NET server CheckBox control, \nadding th... |
I'm developing front-end code for a web application, and ran into an odd piece of trouble with a custom object. When I request the object and use print_r() I get this (the object is a lot bigger; just cut it to the relevant code):
MemberInfo Object
(
[meta_data] => Array
(
[email_recommendations] => tr... | It looks like you're encountering an issue where the `meta_data` property of your `MemberInfo` object is being converted to a JSON string instead of remaining an associative array. This typically happens when the code responsible for handling the `MemberInfo` object is unintentionally serializing or converting the `met... | 41,663 | [
{
"from": "human",
"value": "I'm developing front-end code for a web application, and ran into an odd piece of trouble with a custom object. When I request the object and use print_r() I get this (the object is a lot bigger; just cut it to the relevant code):\nMemberInfo Object\n(\n [meta_data] => Array... |
For example:
script.js:
function functionFromScriptJS() {
alert('inside functionFromScriptJS');
}
iframe.html:
<html>
<head>
<script language="Javascript" src="script.js"></script>
</head>
<body>
<iframe>
<body>
<script language="JavaScript">
functionFromScriptJS();
</script>
</body>
</ifra... | Your observation is correct! When dealing with iframes, there are a few important considerations regarding scope and how scripts are loaded.
In the code you originally provided, the issue arises because the `<iframe>` tag itself does not create a valid document structure when you place the `<body>` tag directly inside... | 43,624 | [
{
"from": "human",
"value": "For example:\nscript.js:\nfunction functionFromScriptJS() {\n alert('inside functionFromScriptJS');\n}\n\niframe.html:\n<html>\n<head>\n<script language=\"Javascript\" src=\"script.js\"></script>\n</head>\n<body>\n\n<iframe>\n <body>\n <script language=\"JavaScript\">\n ... |
I've got a WebBrowser control on my page. To fire some javascript on a page displayed in the browser control, I call this.myBrowser.Document.InvokeScript("Test");
This works on my dev box with IE7, but on a seperate test machine I get the following error:
Exception Type: System.InvalidCastException
Message: Specified c... | Yes, your suspicion about the difference in Internet Explorer versions is likely correct. The `WebBrowser` control in .NET wraps the IE rendering engine, which is tied to the version of Internet Explorer installed on the machine. If your application works on a machine with IE7 but not on one with IE6, it's possible tha... | 41,705 | [
{
"from": "human",
"value": "I've got a WebBrowser control on my page. To fire some javascript on a page displayed in the browser control, I call this.myBrowser.Document.InvokeScript(\"Test\");\nThis works on my dev box with IE7, but on a seperate test machine I get the following error:\nException Type: Sys... |
I am first doing a search on the table tags which results in all the rows returned together with their additional data from the table links (on which i do a join). The table tags works such that for an auto _id there can be multiple rows (1 tag per row so multiple tags is multiple rows).
What I want to do is that inst... | It looks like you're trying to achieve a SQL query that retrieves each `auto_id` with a concatenated list of tags associated with it. The SQL you provided has a few issues, such as the placement of the `GROUP_CONCAT` function and the incorrect use of the `SELECT` statement within it. Here's how you can structure your S... | 42,407 | [
{
"from": "human",
"value": "I am first doing a search on the table tags which results in all the rows returned together with their additional data from the table links (on which i do a join). The table tags works such that for an auto _id there can be multiple rows (1 tag per row so multiple tags is multip... |
I have an input file that I want to sort based on timestamp which is a substring of each record. I want to store multiple attributes of the
The list is currently about 1000 records. But, I want it to be able to scale up a bit just in case.
When I did it with a Linked List by searching the entire list for insertion i... | It looks like you're on the right track with your C++ code, but let's tackle the sorting part with a more structured approach. You can easily implement sorting algorithms such as Merge Sort for your custom object (`CFileInfo`). I'll provide a step-by-step example using Merge Sort, which is efficient and stable.
First... | 39,071 | [
{
"from": "human",
"value": "I have an input file that I want to sort based on timestamp which is a substring of each record. I want to store multiple attributes of the \nThe list is currently about 1000 records. But, I want it to be able to scale up a bit just in case.\nWhen I did it with a Linked List b... |
Is there a command in oracle 9i that displays the foreign keys of a table and also the table that those foreign keys reference?
I was searching, did not find anything but i found an equivalent command that works with MySql which is SHOW CREATE TABLE
Is there an equivalent command for this within oracle's SQL?
I apprec... | In Oracle 9i, there isn't a single command equivalent to MySQL's `SHOW CREATE TABLE` that directly displays foreign keys and their referenced tables in one go. However, you can retrieve this information using the data dictionary views.
You can query the `USER_CONSTRAINTS` and `USER_CONS_COLUMNS` views to get informati... | 43,612 | [
{
"from": "human",
"value": "Is there a command in oracle 9i that displays the foreign keys of a table and also the table that those foreign keys reference?\nI was searching, did not find anything but i found an equivalent command that works with MySql which is SHOW CREATE TABLE \nIs there an equivalent com... |
I need to validate an integer to know if is a valid enum value.
What is the best way to do this in C#?
| In C#, if you want to validate an integer to check if it corresponds to a valid value of an enum, you can use the `Enum.IsDefined` method. This method checks whether a specific value (in this case, your integer) is defined in the specified enum type.
Here’s how you can do this:
1. Define your enum.
2. Use `Enum.IsDef... | 864 | [
{
"from": "human",
"value": "I need to validate an integer to know if is a valid enum value.\nWhat is the best way to do this in C#?\n"
},
{
"from": "gpt",
"value": "In C#, if you want to validate an integer to check if it corresponds to a valid value of an enum, you can use the `Enum.IsDefined`... |
I have a set of EJBs and other Java classes which need to be configured differently based on the system environment in which they are deployed: production, test, or lab. The configuration information includes stuff like URLs and database connection information.
We'd like to deploy the same exact product (EAR file) in e... | Configuring Java EE applications, especially EJBs within an EAR file, to behave differently based on the environment can be accomplished in several ways. The goal is to achieve a centralized, reliable, and maintainable configuration setup without needing to change the code for different deployments. Here are some best ... | 36,860 | [
{
"from": "human",
"value": "I have a set of EJBs and other Java classes which need to be configured differently based on the system environment in which they are deployed: production, test, or lab. The configuration information includes stuff like URLs and database connection information.\nWe'd like to dep... |
Is it possible to run a batch file as a menu item in studio 2008?
| Yes, you can run a batch file from a menu item in a Visual Studio 2008 project, but you'll need to use a bit of code to achieve this. You can create a custom menu item in your Visual Studio project that, when clicked, will execute a batch file. Here's how you can do that:
### Step-by-Step Guide:
1. **Create a Batch F... | 42,125 | [
{
"from": "human",
"value": "Is it possible to run a batch file as a menu item in studio 2008?\n"
},
{
"from": "gpt",
"value": "Yes, you can run a batch file from a menu item in a Visual Studio 2008 project, but you'll need to use a bit of code to achieve this. You can create a custom menu item ... |
Consider the following file
var1 var2 variable3
1 2 3
11 22 33
I would like to load the numbers into a matrix, and the column titles into a variable that would be equivalent to:
variable_names = char('var1', 'var2', 'variable3');
I don't mind to split the names and the numbers in two files, however prepar... | You can achieve your goal in MATLAB by reading the data from a text file into a matrix and storing the column titles in a character array. Here’s how you can do this step-by-step:
1. **Prepare the text file:** Create a text file (e.g., `data.txt`) that contains your data in the format you provided. Make sure the first... | 41,603 | [
{
"from": "human",
"value": "Consider the following file\nvar1 var2 variable3\n1 2 3\n11 22 33\n\nI would like to load the numbers into a matrix, and the column titles into a variable that would be equivalent to:\nvariable_names = char('var1', 'var2', 'variable3');\n\nI don't mind to split the n... |
How do you detect which form input has focus using JavaScript or jQuery?
From within a function I want to be able to determine which form input has focus. I'd like to be able to do this in straight JavaScript and/or jQuery.
| You can detect which form input has focus in both JavaScript and jQuery by using the `document.activeElement` property in JavaScript and the `:focus` selector in jQuery. Below are examples of how to achieve this in both ways.
### Using JavaScript
You can use `document.activeElement` to get the currently focused eleme... | 43,499 | [
{
"from": "human",
"value": "How do you detect which form input has focus using JavaScript or jQuery?\nFrom within a function I want to be able to determine which form input has focus. I'd like to be able to do this in straight JavaScript and/or jQuery.\n"
},
{
"from": "gpt",
"value": "You can ... |
I've been doing some simple rails Apps lately. I know ruby quite well, but when I started doing things "the rails way" I noticed that some things were done "just because" and It's hard for a (rails) newbie to know what does the code do.
Has rails missed the point and turned into some kind of 4th generation language? I ... | Your observations about Ruby on Rails (Rails) touch on some nuanced points that many developers encounter as they transition into using a framework. Rails indeed emphasizes "convention over configuration," which can make it easy to get started quickly without needing to understand every detail of how things work under ... | 39,476 | [
{
"from": "human",
"value": "I've been doing some simple rails Apps lately. I know ruby quite well, but when I started doing things \"the rails way\" I noticed that some things were done \"just because\" and It's hard for a (rails) newbie to know what does the code do.\nHas rails missed the point and turned... |
I have created a user login page and am using Forms Authentication. Users are required to log into the system to use it, there are no anon pages. When the go into the system and get automatically redirected to the login page though, they loose all styles on the page. It is as if the paths to all the css files is incorr... | This issue where CSS styles are lost when redirecting to the login page in a Forms Authentication scenario is commonly due to relative paths for the CSS files. Here are some troubleshooting steps and solutions to fix this problem:
### 1. **Check Path for CSS Files**
Make sure your CSS files are referenced with absolut... | 39,229 | [
{
"from": "human",
"value": "I have created a user login page and am using Forms Authentication. Users are required to log into the system to use it, there are no anon pages. When the go into the system and get automatically redirected to the login page though, they loose all styles on the page. It is as if... |
I want to be able to push out application updates to windows mobile 5 devices over the air, is this possible? Note, this is just an application, not a rom update.
It doesn't have to be a strict push. It is just as well to have the user go to a web page and download a .cab file. Has anyone had success doing this?
| Yes, it is possible to push application updates to Windows Mobile 5 devices over the air (OTA), and many developers and organizations have used this approach for deploying applications. Although it might not be as straightforward as modern app distribution methods, you can still achieve it using the following methods:
... | 43,367 | [
{
"from": "human",
"value": "I want to be able to push out application updates to windows mobile 5 devices over the air, is this possible? Note, this is just an application, not a rom update.\nIt doesn't have to be a strict push. It is just as well to have the user go to a web page and download a .cab fil... |
It seems that the following piece of HTML is ignored in IE7 but works ok in IE6/FF. It supposes to override all the html links to be opened in the desired frame
<HEAD>
<title>LeftPane</title>
<base target="rightFrame">
</HEAD>
The above code is the header of a left frame that holds an Infragistics UltraWebTr... | To ensure that all links in your ASP.NET web page open in a specific frame, especially when facing issues with the `<base>` tag in Internet Explorer 7, you can use JavaScript to programmatically add the target attribute to all anchor (`<a>`) elements on the page. This way, you can overcome the limitations you've encoun... | 37,863 | [
{
"from": "human",
"value": "It seems that the following piece of HTML is ignored in IE7 but works ok in IE6/FF. It supposes to override all the html links to be opened in the desired frame\n<HEAD> \n <title>LeftPane</title> \n <base target=\"rightFrame\"> \n</HEAD>\n\nThe above code is the header of a... |
I need the current user and the domain. I am using a VB 6 application.
Thanks
| In a Visual Basic 6 (VB6) application, you can retrieve the current user and the domain name by using Windows API calls. Below is a sample code snippet that demonstrates how to do this using the `GetUserName` and `GetComputerName` functions from the Windows API.
First, declare the necessary API functions and variables... | 41,850 | [
{
"from": "human",
"value": "I need the current user and the domain. I am using a VB 6 application. \nThanks\n"
},
{
"from": "gpt",
"value": "In a Visual Basic 6 (VB6) application, you can retrieve the current user and the domain name by using Windows API calls. Below is a sample code snippet th... |
I have a directory full (~103, 104) of XML files from which I need to extract the contents of several fields.
I've tested different xml parsers, and since I don't need to validate the contents (expensive) I was thinking of simply using xml.parsers.expat (the fastest one) to go through the files, one by one to extract ... | Using `xml.parsers.expat` (which is a low-level XML parser) can be efficient for processing a large number of XML files, especially if you are primarily concerned about speed and do not require validation. Here are some considerations and suggestions regarding your approach:
### 1. Efficient XML Parsing
- **Reusing th... | 41,432 | [
{
"from": "human",
"value": "I have a directory full (~103, 104) of XML files from which I need to extract the contents of several fields. \nI've tested different xml parsers, and since I don't need to validate the contents (expensive) I was thinking of simply using xml.parsers.expat (the fastest one) to go... |
I have a template class like below.
template<int S> class A
{
private:
char string[S];
public:
A()
{
for(int i =0; i<S; i++)
{
.
.
}
}
int MaxLength()
{
return S;
}
};
If i instantiate the above class with different values of S, will the compiler create different instances o... | In C++, when you use a template class like your example with `A`, the compiler generates separate instances of the template for each unique template parameter value that you use to instantiate it. This means that if you instantiate the class with different values of `S`, the compiler will create separate instances of t... | 43,817 | [
{
"from": "human",
"value": "I have a template class like below.\ntemplate<int S> class A\n{\nprivate:\n char string[S];\n\npublic:\n A()\n {\n for(int i =0; i<S; i++)\n {\n .\n .\n }\n }\n\n int MaxLength()\n {\n return S;\n }\n};\n\nIf i instantiate the above class with differ... |
I'm trying out PHPTAL and I want to render a table with zebra stripes. I'm looping through a simple php assoc array ($_SERVER).
Note that I don't want to use jQuery or anything like that, I'm trying to learn PHPTAL usage!
Currently I have it working like this (too verbose for my liking):
<tr tal:repeat="item server">
... | To simplify your PHPTAL template for rendering a zebra-striped table based on the `$_SERVER` associative array, you can make use of the `tal:attributes` and a single `tal:repeat` for the rows while leveraging the `odd` and `even` classes.
Here’s a more concise way to achieve your goal:
```html
<table>
<tr tal:repea... | 43,686 | [
{
"from": "human",
"value": "I'm trying out PHPTAL and I want to render a table with zebra stripes. I'm looping through a simple php assoc array ($_SERVER).\nNote that I don't want to use jQuery or anything like that, I'm trying to learn PHPTAL usage!\nCurrently I have it working like this (too verbose for ... |
I have 2 tables (A and B) with the same primary keys. I want to select all row that are in A and not in B. The following works:
select * from A where not exists (select * from B where A.pk=B.pk);
however it seems quite bad (~2 sec on only 100k rows in A and 3-10k less in B)
Is there a better way to run this? Perhaps a... | The performance of SQL queries can depend on various factors, including the database management system (DBMS) being used, the size and distribution of the data, the indexing of the tables, and how the query optimizer interprets the query.
### Options to Select Rows in A that are Not in B
1. **Using NOT EXISTS**:
`... | 42,768 | [
{
"from": "human",
"value": "I have 2 tables (A and B) with the same primary keys. I want to select all row that are in A and not in B. The following works:\nselect * from A where not exists (select * from B where A.pk=B.pk);\n\nhowever it seems quite bad (~2 sec on only 100k rows in A and 3-10k less in B)\... |
I found this solution which works, but I find it hard to believe there isn't a one-click solution to this problem.
Do you know a better way?
| I’d be happy to help! However, I need a bit more context about the specific problem you're trying to solve. If you could share more details about the issue, I can suggest alternatives or potential one-click solutions that may exist. | 45,813 | [
{
"from": "human",
"value": "I found this solution which works, but I find it hard to believe there isn't a one-click solution to this problem. \nDo you know a better way?\n"
},
{
"from": "gpt",
"value": "I’d be happy to help! However, I need a bit more context about the specific problem you're ... |
I've been struggling with this check constraint for a few hours and was hoping someone would be kind enough to explain why this check constraint isn't doing what I think it should be doing.
ALTER TABLE CLIENTS
add CONSTRAINT CHK_DISABILITY_INCOME_TYPE_ID CHECK ((IS_DISABLED IS NULL AND DISABILITY_INCOME_TYPE_ID IS NULL... | Hello Michael,
Let's break down the check constraint you've implemented in your `CLIENTS` table to understand why the behavior you're seeing occurs.
### Your Check Constraint
```sql
CHECK (
(IS_DISABLED IS NULL AND DISABILITY_INCOME_TYPE_ID IS NULL)
OR (IS_DISABLED = 0 AND DISABILITY_INCOME_TYPE_ID IS NULL)... | 39,743 | [
{
"from": "human",
"value": "I've been struggling with this check constraint for a few hours and was hoping someone would be kind enough to explain why this check constraint isn't doing what I think it should be doing.\nALTER TABLE CLIENTS\nadd CONSTRAINT CHK_DISABILITY_INCOME_TYPE_ID CHECK ((IS_DISABLED IS... |
After update, old Eclipse plugins remain in "plugins" folder (there are also leftovers in "features" folder).
Is there a way to remove those automatically?
| Yes, there are ways to clean up old Eclipse plugins and their leftovers in the "plugins" and "features" folders automatically. Here are some methods you can consider:
### 1. Using Eclipse's built-in feature:
Eclipse has a built-in mechanism to manage installations:
- Go to `Help` -> `About Eclipse IDE`.
- Click on `I... | 43,482 | [
{
"from": "human",
"value": "After update, old Eclipse plugins remain in \"plugins\" folder (there are also leftovers in \"features\" folder).\nIs there a way to remove those automatically?\n"
},
{
"from": "gpt",
"value": "Yes, there are ways to clean up old Eclipse plugins and their leftovers i... |
Does anybody know how to make WindowsPrincipal.IsInRole("domain\role") work with active directory universal groups?
Let's say the current user is a member of a group called Role in a domain called domain, and that the Role group is a Global group in active directory. The following code would then yield result = true:
... | The behavior you're experiencing with `WindowsPrincipal.IsInRole` and universal groups in Active Directory can be due to the way Windows manages group memberships and how it checks for roles.
When using the `IsInRole` method, it typically checks the token of the currently logged-in user against the groups that the use... | 38,654 | [
{
"from": "human",
"value": "Does anybody know how to make WindowsPrincipal.IsInRole(\"domain\\role\") work with active directory universal groups?\nLet's say the current user is a member of a group called Role in a domain called domain, and that the Role group is a Global group in active directory. The fo... |
When I have an unconnected mapped drive, the VSTS 2008 SP1 IDE debugger takes about 10 seconds to regain control.
Needless to say single stepping is painful. Is there some setting to make this go away?
I am debugging a mixed( C# / C++ / Web services ) program.
More details:
The program does not use the mapped drive at... | The issue you're experiencing with the Visual Studio Team System (VSTS) 2008 SP1 IDE debugger waiting for an unconnected mapped drive can be frustrating. Here are some suggestions to alleviate the problem without the need to constantly map and unmap the drive:
1. **Disconnect the Mapped Drive:**
If you are not usin... | 40,686 | [
{
"from": "human",
"value": "When I have an unconnected mapped drive, the VSTS 2008 SP1 IDE debugger takes about 10 seconds to regain control.\nNeedless to say single stepping is painful. Is there some setting to make this go away? \nI am debugging a mixed( C# / C++ / Web services ) program.\nMore details:\... |
In my application I have an embedded MSHTML control. The problem is that I cannot set focus to this control. I can click, select, push buttons etc, but it won't accept keyboard input and mouse wheel notifications as a result. Even left-clicks on the control do not set the focus. (The question is related to this issue.)... | It sounds like you are dealing with a tricky situation where the embedded MSHTML control is not accepting focus for keyboard and mouse input. Let's analyze your approaches and suggest some additional strategies:
### 1. Ensure the Embedded Control is Enabled
Before you focus the control, make sure it is enabled and vis... | 42,753 | [
{
"from": "human",
"value": "In my application I have an embedded MSHTML control. The problem is that I cannot set focus to this control. I can click, select, push buttons etc, but it won't accept keyboard input and mouse wheel notifications as a result. Even left-clicks on the control do not set the focus.... |
I recognize that there's an obvious pattern in the output to this, I just want to know why lispbox's REPL aborts when I try to run anything > 52. Also, any suggestions on improving the code are more than welcome. ^-^
(defun count-reduced-fractions (n d sum)
(setf g (gcd n d))
(if (equal 1 d)
(return-from cou... | The issue you're encountering with LispBox's REPL aborting when calling `(count-reduced-fractions 53 53 0)` is likely related to exceeding the maximum recursion depth. Your function uses a recursive approach to count reduced fractions, and as the values of `n` and `d` increase, the depth of recursive calls increases as... | 43,463 | [
{
"from": "human",
"value": "I recognize that there's an obvious pattern in the output to this, I just want to know why lispbox's REPL aborts when I try to run anything > 52. Also, any suggestions on improving the code are more than welcome. ^-^\n(defun count-reduced-fractions (n d sum)\n (setf g (gcd n d... |
I'm writing a C++ program that doesn't work (I get a segmentation fault) when I compile it with optimizations (options -O1, -O2, -O3, etc.), but it works just fine when I compile it without optimizations.
Is there any chance that the error is in my code? or should I assume that this is a bug in GCC?
My GCC version is 3... | The behavior you're encountering—a segmentation fault when optimizations are enabled but not when they are disabled—strongly suggests that there is a bug in your code, rather than a bug in GCC. Such issues are often caused by undefined behavior in your program, which compilers may handle differently depending on optimi... | 40,358 | [
{
"from": "human",
"value": "I'm writing a C++ program that doesn't work (I get a segmentation fault) when I compile it with optimizations (options -O1, -O2, -O3, etc.), but it works just fine when I compile it without optimizations.\nIs there any chance that the error is in my code? or should I assume that... |
Is there a way to change the connection string of a DataBase object in Enterprise Library at runtime? I've found this link but its a little bit outdated (2005)
I've also found this but it seems to apply to .Net in general, I was wondering if there was something that could be done specifically for EntLib.
I was just pas... | In Microsoft Enterprise Library, you can indeed change the connection string used by a `Database` object at runtime. However, the default `DatabaseFactory` does not directly support modifying connection strings dynamically. You can work around this limitation by creating your own `Database` instances using a custom con... | 40,557 | [
{
"from": "human",
"value": "Is there a way to change the connection string of a DataBase object in Enterprise Library at runtime? I've found this link but its a little bit outdated (2005)\nI've also found this but it seems to apply to .Net in general, I was wondering if there was something that could be do... |
I have my enumHelper class that contains these:
public static IList<T> GetValues()
{
IList<T> list = new List<T>();
foreach (object value in Enum.GetValues(typeof(T)))
{
list.Add((T)value);
}
return list;
}
and
public static string Description(Enum value)
{
Attribute DescAttribute = LMIGHelper.GetAttri... | The issue you're encountering is due to the fact that the `Description` method in your `EnumHelper` class expects a parameter of type `Enum`, but you're passing it a generic type `T` which does not necessarily derive from `Enum`. In C#, generics don't constrain `T` to be an enumeration type unless explicitly specified.... | 41,570 | [
{
"from": "human",
"value": "I have my enumHelper class that contains these:\npublic static IList<T> GetValues()\n{\n IList<T> list = new List<T>();\n foreach (object value in Enum.GetValues(typeof(T)))\n {\n list.Add((T)value);\n }\n return list;\n}\n\nand\npublic static string Description(Enum val... |
I have a set of tables that are used to track bills. These tables are loaded from an SSIS process that runs weekly.
I am in the process of creating a second set of tables to track adjustments to the bills that are made via the web. Some of our clients hand key their bills and all of those entries need to be backed up o... | Creating a robust backup strategy for your data that involves both automated processes (like SSIS) and manual entry can be challenging, but there are established best practices that can help ensure data integrity and facilitate efficient recovery of adjustments. Here are some strategies to consider:
### 1. **Use Audit... | 40,637 | [
{
"from": "human",
"value": "I have a set of tables that are used to track bills. These tables are loaded from an SSIS process that runs weekly.\nI am in the process of creating a second set of tables to track adjustments to the bills that are made via the web. Some of our clients hand key their bills and a... |
I have a few ASP.Net database front-end websites where MS Access is the back-end. I am trying to use ASP.Net dynamic data website. Should I change this database to SQL Server Express or something else to make it easier or should this work from with MS Access.
| Using MS Access as a back-end for ASP.NET Dynamic Data websites can work, but there are several considerations that might make switching to SQL Server Express a more beneficial choice:
### Advantages of Switching to SQL Server Express
1. **Scalability**: SQL Server Express can handle larger databases and more concurr... | 39,174 | [
{
"from": "human",
"value": "I have a few ASP.Net database front-end websites where MS Access is the back-end. I am trying to use ASP.Net dynamic data website. Should I change this database to SQL Server Express or something else to make it easier or should this work from with MS Access.\n"
},
{
"... |
!!! This is not a duplicate question since the solutions offered in the other topics didn't work for me.
When I try to commit:
Error: Working copy 'D:\Webs\Drupal 6' locked
Error: Please execute the "Cleanup" command.
When I try to do a cleanup:
Cleanup failed to process the following paths:
D:\Webs\Drupal 6
Does anyon... | It seems like you’re dealing with a locked working copy in a Subversion (SVN) repository. Here are some steps you can try to resolve the issue:
### 1. Check for Locks Manually
Sometimes a lock file might be left over from an interrupted process. Check the `.svn` directory inside your working copy:
- Navigate to `D:\W... | 41,537 | [
{
"from": "human",
"value": "!!! This is not a duplicate question since the solutions offered in the other topics didn't work for me.\nWhen I try to commit:\nError: Working copy 'D:\\Webs\\Drupal 6' locked\nError: Please execute the \"Cleanup\" command.\nWhen I try to do a cleanup:\nCleanup failed to proces... |
In trying to learn how to create objects in ActionScript, I have had no success.
One thing that I have noticed is that there seems to be a billion different ways of doing it. Even if none of them have worked for me. This is really confusing me, and I don't know which approach to try to debug.
The approach that seems ... | Understanding object creation in ActionScript (AS) can indeed be a bit confusing, especially with the differences between ActionScript 2 (AS2) and ActionScript 3 (AS3). Let’s clarify the different approaches and the contexts in which they are used. I'll also provide some guidance on best practices and where to find goo... | 39,729 | [
{
"from": "human",
"value": "In trying to learn how to create objects in ActionScript, I have had no success.\nOne thing that I have noticed is that there seems to be a billion different ways of doing it. Even if none of them have worked for me. This is really confusing me, and I don't know which approach... |
Right now I'm trying to add a button to a webpage that when pressed will start playing a .wav file by dynamically adding an embed tag to the DOM. The text switches to "Stop" while the sound plays, and I'd like to be able to switch it back automatically to "Play" once the file has finished playing.
How would I be able t... | You can achieve this functionality by utilizing the HTML `<audio>` element instead of the `<embed>` tag, which is more modern and offers better control over audio playback. The `<audio>` element allows you to easily manage the playback state and listen for events, including when the audio has finished playing.
Here is... | 41,635 | [
{
"from": "human",
"value": "Right now I'm trying to add a button to a webpage that when pressed will start playing a .wav file by dynamically adding an embed tag to the DOM. The text switches to \"Stop\" while the sound plays, and I'd like to be able to switch it back automatically to \"Play\" once the fil... |
What is the best method of hiding php errors from being displayed on the browser?
Would it be to use the following:
ini_set("display_errors", 1);
Any best practice tips would be appreciated as well!
I am logging the errors, I just want to make sure that setting the display_errors value to off (or 0) will not prevent e... | Hiding PHP errors from being displayed in the browser is important for security and user experience. You can achieve this by modifying the `display_errors` directive in your PHP configuration. Here are some best practices for managing error reporting in PHP:
### 1. Disable Displaying Errors
In your production environ... | 39,291 | [
{
"from": "human",
"value": "What is the best method of hiding php errors from being displayed on the browser?\nWould it be to use the following:\nini_set(\"display_errors\", 1);\n\nAny best practice tips would be appreciated as well!\nI am logging the errors, I just want to make sure that setting the displ... |
Somebody please tell me it is possible to recover Visual Studio source after VS crashes!
I have just spent 5 hours writing a new utility app, and running it with the "Save before Build" option turned on, as well as AutoRecover every 5-mins. But after VS crashed I am unabled to find anything other than an empty project ... | I'm sorry to hear about your experience with Visual Studio crashing. Losing hours of work can be incredibly frustrating. Here are some steps you can take to potentially recover your source code, as well as some tips for future work to minimize the risk of data loss:
### 1. Check AutoRecover Files
Visual Studio does ha... | 41,982 | [
{
"from": "human",
"value": "Somebody please tell me it is possible to recover Visual Studio source after VS crashes!\nI have just spent 5 hours writing a new utility app, and running it with the \"Save before Build\" option turned on, as well as AutoRecover every 5-mins. But after VS crashed I am unabled t... |
I am having issues converting a png to tiff. The conversion goes fine, but the image is huge. I think the issue is that I am not doing the compression correctly? Anyone have any suggestions??
Here is the code sample
public static void test() throws IOException {
// String fileName = "4958813_1";
String file... | Your code seems to be set up to convert a PNG image to a TIFF image with LZW compression. However, there are a couple of considerations that might help you reduce the file size of the output TIFF image:
### 1. Check Compression Settings
LZW compression is typically lossless but may not compress as efficiently as othe... | 38,738 | [
{
"from": "human",
"value": "I am having issues converting a png to tiff. The conversion goes fine, but the image is huge. I think the issue is that I am not doing the compression correctly? Anyone have any suggestions??\nHere is the code sample\npublic static void test() throws IOException {\n\n // S... |
I'm working on a Spring MVC project, and I have unit tests for all of the various components in the source tree.
For example, if I have a controller HomeController, which needs to have a LoginService injected into it, then in my unit test HomeControllerTest I simply instantiate the object as normal (outside of Spring) ... | It's great to see that you're taking a structured approach to testing in your Spring MVC project! Let's break down your questions:
### 1. Separate Unit Tests and Integration Tests
Yes, it is indeed common practice to create both unit tests and integration tests in a Spring project, and many developers follow a simila... | 40,352 | [
{
"from": "human",
"value": "I'm working on a Spring MVC project, and I have unit tests for all of the various components in the source tree.\nFor example, if I have a controller HomeController, which needs to have a LoginService injected into it, then in my unit test HomeControllerTest I simply instantiate... |
What are the proper uses of:
static_cast
dynamic_cast
const_cast
reinterpret_cast
(type)value (C-style cast)
type(value) (function-style cast)
How does one decide which to use in which specific cases?
| In C++, various casting operators serve different purposes and are used in different scenarios. Here’s a breakdown of each casting method you mentioned, their proper uses, and guidelines on when to use each:
### 1. `static_cast`
**Purpose:**
- Used for safe conversions between compatible types, such as:
- Convertin... | 39,130 | [
{
"from": "human",
"value": "What are the proper uses of:\n\nstatic_cast\ndynamic_cast\nconst_cast\nreinterpret_cast\n(type)value (C-style cast)\ntype(value) (function-style cast)\n\nHow does one decide which to use in which specific cases?\n"
},
{
"from": "gpt",
"value": "In C++, various castin... |
Our system generates emails with user-chosen lists of To / CC / BCC contacts. I wanted to store them as follows in our SQL Server database, here's the simplified database table structure:
CREATE TABLE [Contact] (
[ContactID] [int] IDENTITY (1, 1) NOT NULL,
[Name] [varchar] (100) NOT NULL,
[EmailAddress] [v... | Yes, you can represent the email contacts as separate collections (ToContacts, CCContacts, and BCCContacts) in your Email domain object without introducing a new domain object, though it would still be a many-to-many relationship under the hood. However, you would need a way to differentiate between the types of contac... | 36,272 | [
{
"from": "human",
"value": "Our system generates emails with user-chosen lists of To / CC / BCC contacts. I wanted to store them as follows in our SQL Server database, here's the simplified database table structure:\nCREATE TABLE [Contact] (\n [ContactID] [int] IDENTITY (1, 1) NOT NULL,\n [Name] [va... |
Does anyone have a list of email addresses that I can use to test my JS address validation script? I'm looking for as complete of a list as is reasonable to test the most common edge cases, if not all cases.
| While I can't provide actual email addresses, I can suggest some examples of email formats that you can use to test your JavaScript address validation script. Here are some common edge cases and formats you might want to consider:
### Valid Email Formats
1. Basic formats:
- `user@example.com`
- `user.name@examp... | 41,967 | [
{
"from": "human",
"value": "Does anyone have a list of email addresses that I can use to test my JS address validation script? I'm looking for as complete of a list as is reasonable to test the most common edge cases, if not all cases.\n"
},
{
"from": "gpt",
"value": "While I can't provide act... |
I have two forms on a page (one is being grabbed by AJAX). I need them both to be posted, so I serialize the second one and send it in a post using jQuery before submitting the first one. However, only the first form appears to be getting posted. The odd thing is though, if I put an alert after the serialized post i... | The issue you are experiencing is likely due to the fact that the forms are being posted asynchronously with jQuery's `.post()` method, but you immediately call `$("#first_form").submit()` afterward. Since the AJAX call is asynchronous, it may not have completed before the first form is submitted, causing a timing issu... | 41,630 | [
{
"from": "human",
"value": "I have two forms on a page (one is being grabbed by AJAX). I need them both to be posted, so I serialize the second one and send it in a post using jQuery before submitting the first one. However, only the first form appears to be getting posted. The odd thing is though, if I... |
I have often wondered why it is that non-English speaking programmers are forced to use a different language when programming when it would seem to be so easy to offer an IDE that could replace keywords with localized versions. Why can't the Germans use a "während..macht" loop?
Do programmers in Japan, Germany, France,... | You've raised an interesting point about localization in programming languages and the challenges faced by non-English speaking programmers. Here are some key factors that contribute to the current state of programming language design and usage:
1. **Historical Context**: Many programming languages were developed in E... | 43,663 | [
{
"from": "human",
"value": "I have often wondered why it is that non-English speaking programmers are forced to use a different language when programming when it would seem to be so easy to offer an IDE that could replace keywords with localized versions. Why can't the Germans use a \"während..macht\" loop... |
I have a python script that is a http-server: http://paste2.org/p/89701, when benchmarking it against ApacheBench (ab) with a concurrency level (-c switch) that is lower then or equal to the value i specified in the socket.listen()-call in the sourcecode everything works fine, but as soon as put the concurrency level i... | It seems like you are running into a classic issue with socket programming in Python related to the handling of connections and the limits imposed by `socket.listen()`. The behavior you're observing suggests that when the concurrency level in ApacheBench (`ab`) exceeds the number of allowed connections specified in `so... | 31,382 | [
{
"from": "human",
"value": "I have a python script that is a http-server: http://paste2.org/p/89701, when benchmarking it against ApacheBench (ab) with a concurrency level (-c switch) that is lower then or equal to the value i specified in the socket.listen()-call in the sourcecode everything works fine, b... |
I have the following code
<html>
<head>
<title>Test</title>
<style type="text/css">
<!--
body,td,th {
color: #FFFFFF;
}
body {
background-color: #000000;
}
#Pictures {
position:absolute;
width:591px;
height:214px;
z-index:1;
left: 17%;
top: 30%;
text-align:center;
}... | The reason your images and their corresponding text are stacking vertically is because they are enclosed in `<div>` elements. By default, `<div>` elements are block-level elements, which means they will stack vertically.
To align the images and their corresponding text horizontally, you can change the display property... | 39,714 | [
{
"from": "human",
"value": "I have the following code\n<html>\n<head>\n<title>Test</title>\n<style type=\"text/css\">\n\n<!--\n\nbody,td,th {\n\n color: #FFFFFF;\n\n}\n\nbody {\n\n background-color: #000000;\n\n}\n\n\n\n#Pictures {\n\n position:absolute;\n\n width:591px;\n\n height:214px;\n\... |
I want to warn users of Internet Explorer 6 using my site, that IE6 has had serious compatibility issues with my site in the past. What is the best way to do this?
Ideally, I want to have a message appear (not a new window, but a message box, if possible) that warns IE6 users of the issues and reccommends they update t... | To warn users of Internet Explorer 6 and encourage them to upgrade their browsers, you can use JavaScript to check the user agent and display a message on your webpage. Here’s a simple approach using HTML and JavaScript that provides a warning message for IE6 users:
```html
<!DOCTYPE html>
<html lang="en">
<head>
... | 41,921 | [
{
"from": "human",
"value": "I want to warn users of Internet Explorer 6 using my site, that IE6 has had serious compatibility issues with my site in the past. What is the best way to do this?\nIdeally, I want to have a message appear (not a new window, but a message box, if possible) that warns IE6 users o... |
than just to call the parameter as it is?
| It seems like your question might be missing some context. When you mention "to call the parameter as it is," are you asking about passing parameters in a programming context, or are you referring to another situation? Could you provide a bit more detail or clarify your question? This will help me give you a more accur... | 46,291 | [
{
"from": "human",
"value": "than just to call the parameter as it is?\n"
},
{
"from": "gpt",
"value": "It seems like your question might be missing some context. When you mention \"to call the parameter as it is,\" are you asking about passing parameters in a programming context, or are you ref... |
Why are the code-behind pages for an ASP.NET web application locked at run time? I have older projects (probably defined as "web sites" instead of "web apps") where I can edit the code behind, refresh the browser, and see my changes. With the web app, I have to continually close and reopen the browser if I want to see ... | In ASP.NET, the difference between "web site" projects and "web application" projects significantly affects how code is compiled and how changes are reflected during development.
### Key Differences:
1. **Web Site Projects:**
- In web site projects, the code files (code-behind) are compiled at runtime. When you ma... | 41,383 | [
{
"from": "human",
"value": "Why are the code-behind pages for an ASP.NET web application locked at run time? I have older projects (probably defined as \"web sites\" instead of \"web apps\") where I can edit the code behind, refresh the browser, and see my changes. With the web app, I have to continually c... |
We are working on designing an application that is typically OLTP (think: purchasing system). However, this one in particular has the need that some users will be offline, so they need to be able to download the DB to their machine, work on it, and then sync back once they're on the LAN.
I would like to note that I kno... | Hi Daniel,
Your approach to using GUIDs (Globally Unique Identifiers) as keys for your OLTP application, particularly in a scenario where users might be offline and need to sync their data later, is quite reasonable and has some advantages. However, there are also trade-offs and considerations you should keep in mind.... | 1,138 | [
{
"from": "human",
"value": "We are working on designing an application that is typically OLTP (think: purchasing system). However, this one in particular has the need that some users will be offline, so they need to be able to download the DB to their machine, work on it, and then sync back once they're on... |
I often get a problem with Windows Installer trying to uninstall a package, but it complains that:
The feature you are trying to use is on a network resource that is unavailable.
Is there a known means of uninstalling such packages when the original MSI is simply not available?
| Yes, encountering the message about Windows Installer and an unavailable network resource is a common issue when trying to uninstall software. This typically happens when the original MSI file needed for the uninstallation is not accessible. Here are several methods you can try to resolve this issue and uninstall the p... | 43,238 | [
{
"from": "human",
"value": "I often get a problem with Windows Installer trying to uninstall a package, but it complains that:\n\nThe feature you are trying to use is on a network resource that is unavailable.\n\nIs there a known means of uninstalling such packages when the original MSI is simply not avail... |
From what I understand, due to the "same origin policy" enforcement in current browsers, it's impossible to obtain data from an XmlHttpRequest sent to a different domain than the Javascript's original domain.
I have close to zero experience regarding this matter, so I'm confused about web services being unusable from J... | You're on the right track in understanding the Same Origin Policy (SOP) and how it affects web applications and AJAX calls. Let's break this down to clarify how web services can be consumed across different domains.
### Same Origin Policy
The Same Origin Policy is a security measure implemented in web browsers that r... | 40,210 | [
{
"from": "human",
"value": "From what I understand, due to the \"same origin policy\" enforcement in current browsers, it's impossible to obtain data from an XmlHttpRequest sent to a different domain than the Javascript's original domain.\nI have close to zero experience regarding this matter, so I'm confu... |
I have a Canvas in a Flex application which has items inside it that cover only about 50% of the area of the main canvas.
i want the canvas to respond to rollOver events for the full area, and not just the area that is covered by the items inside.
I have been setting the following attributes to achieve this :
<mx:Canva... | In Flex, setting the `backgroundAlpha` to a low value (like `.01`) is a common approach to capture mouse events over a UIComponent, such as a Canvas. However, if you're looking for a more structured or "cleaner" way to achieve mouse event handling over the entire area, you can consider the following options:
1. **Use ... | 42,896 | [
{
"from": "human",
"value": "I have a Canvas in a Flex application which has items inside it that cover only about 50% of the area of the main canvas.\ni want the canvas to respond to rollOver events for the full area, and not just the area that is covered by the items inside.\nI have been setting the follo... |
In jQuery, is there a function/plugin which I can use to match a given regular expression in a string?
For example, in an email input box, I get an email address, and want to see if it is in the correct format. What jQuery function should I use to see if my validating regular expression matches the input?
I've googled ... | jQuery itself does not have a built-in function specifically for regular expression matching. However, you can use JavaScript's native `RegExp` object alongside jQuery to perform this task effectively.
Here’s a simple way to validate an email format using a regular expression in conjunction with jQuery:
1. Capture th... | 42,015 | [
{
"from": "human",
"value": "In jQuery, is there a function/plugin which I can use to match a given regular expression in a string?\nFor example, in an email input box, I get an email address, and want to see if it is in the correct format. What jQuery function should I use to see if my validating regular e... |
I have a function that checks if a cookie (by name) exists or not:
Private Function cookieExists(ByVal cName As String) As Boolean
For Each c As HttpCookie In Response.Cookies
If c.Name = cName Then Return True
Next
Return False
End Function
I have a class that handles cookies in an application-spe... | Yes, while passing the `HttpResponse` object as a parameter is a valid approach, there are cleaner and more maintainable ways to handle cookies within your class. Here are a couple of alternatives:
### 1. **Use the HttpContext Class**
Instead of passing the `HttpResponse` directly, you can use the `HttpContext` class,... | 40,647 | [
{
"from": "human",
"value": "I have a function that checks if a cookie (by name) exists or not:\nPrivate Function cookieExists(ByVal cName As String) As Boolean\n For Each c As HttpCookie In Response.Cookies\n If c.Name = cName Then Return True\n Next\n Return False\nEnd Function\n\nI have a... |
A few days ago, I asked why its not possible to store binary data, such as a jpg file into a string variable.
Most of the answers I got said that string is used for textual information such as what I'm writing now.
What is considered textual data though? Bytes of a certain nature represent a jpg file and those bytes co... | Your question is far from silly! It's a fundamental concept in programming and data representation, and it's great that you're diving deeper into it.
### Textual Data vs. Binary Data
1. **Textual Data**: This is typically information that represents readable characters, such as letters, numbers, punctuation marks, et... | 38,002 | [
{
"from": "human",
"value": "A few days ago, I asked why its not possible to store binary data, such as a jpg file into a string variable.\nMost of the answers I got said that string is used for textual information such as what I'm writing now.\nWhat is considered textual data though? Bytes of a certain nat... |
What is the most direct and/or efficient way to convert a char[] into a CharSequence?
| In Java, the most direct and efficient way to convert a `char[]` into a `CharSequence` is to use the `String` class. The `String` class implements the `CharSequence` interface, allowing you to create a `String` from a `char[]`, which will give you the desired `CharSequence`.
Here's how you can do it:
```java
char[] c... | 43,385 | [
{
"from": "human",
"value": "What is the most direct and/or efficient way to convert a char[] into a CharSequence? \n"
},
{
"from": "gpt",
"value": "In Java, the most direct and efficient way to convert a `char[]` into a `CharSequence` is to use the `String` class. The `String` class implements ... |
If you have to use String.Replace() to replace test 50 times, you essentially have to create a new string 50 times. Does StringBuilder.Replace() do this more efficiently? E.g., should I use a StringBuilder if I'm going to be replacing a lot of text, even while I won't be appending any data to it?
I'm using .NET, but ... | Yes, when dealing with numerous string manipulations like replacements, `StringBuilder` can be more efficient than using `String.Replace()` repeatedly.
### Explanation
1. **Immutability of Strings**:
- In .NET (as well as Java), strings are immutable, meaning that every time you perform an operation like `String... | 42,837 | [
{
"from": "human",
"value": "If you have to use String.Replace() to replace test 50 times, you essentially have to create a new string 50 times. Does StringBuilder.Replace() do this more efficiently? E.g., should I use a StringBuilder if I'm going to be replacing a lot of text, even while I won't be appen... |
For those who are not aware, Lotus Notes is a cool system, which has very powerful database replication abilities, and very strong certificate management and signing.
However that strong certificate usage is itself one of Notes's downfalls.
When you log in to Lotus Notes via a Notes client, the password you use is no... | Lotus Notes and Domino have indeed undergone significant changes over the years, particularly in how authentication and identity management are handled. As of your last query regarding versions, here’s a summary of some key changes and features related to ID file authentication and Active Directory integration:
### Ch... | 39,917 | [
{
"from": "human",
"value": "For those who are not aware, Lotus Notes is a cool system, which has very powerful database replication abilities, and very strong certificate management and signing.\nHowever that strong certificate usage is itself one of Notes's downfalls. \nWhen you log in to Lotus Notes via... |
I am creating a mobile web application using asp.net. The application must support iPhone, Blackberry and Windows Mobile Platform. What are the low things which should be taken care of while developing this application. Is there any best practices list available for this?
Summary:
| When developing a mobile web application using ASP.NET that targets multiple platforms such as iPhone, Blackberry, and Windows Mobile, there are several key considerations and best practices to ensure compatibility, performance, and usability. Here’s a summary of essential guidelines:
### Key Considerations for Mobile... | 41,637 | [
{
"from": "human",
"value": "I am creating a mobile web application using asp.net. The application must support iPhone, Blackberry and Windows Mobile Platform. What are the low things which should be taken care of while developing this application. Is there any best practices list available for this?\nSumma... |
i've got a stock standard ASP.NET web site, deployed to our development machine (internal machine in our server room).
Now, this dev site can be accessed by both INTERNAL and EXTERNAL users. Now, in IIS6 we used to have it so that Anonymous Authentication was turned off and something else was turned on .. giving the us... | To set up an ASP.NET web application that allows internal and external users to access the site using a separate set of credentials (which are different from the users' website accounts) while using IIS 7, you can follow these steps:
### Step 1: Disable Anonymous Authentication
1. Open **IIS Manager**.
2. Select your... | 39,283 | [
{
"from": "human",
"value": "i've got a stock standard ASP.NET web site, deployed to our development machine (internal machine in our server room).\nNow, this dev site can be accessed by both INTERNAL and EXTERNAL users. Now, in IIS6 we used to have it so that Anonymous Authentication was turned off and som... |
I have several init.d scripts that I'm using to start some daemons. Most of these scripts I've found on the internet and they all use start-stop-daemon. My understanding is that "start-stop-daemon" is a command that is specific to Linux or BSD distros and is not available on Solaris.
What is the best way to translate m... | Your understanding is correct that `start-stop-daemon` is a utility used in Debian-based Linux distributions to manage service processes, and it is not available on Solaris. On Solaris, there is no direct equivalent of `start-stop-daemon`, but there are different ways to manage services and daemons.
Here are some step... | 39,827 | [
{
"from": "human",
"value": "I have several init.d scripts that I'm using to start some daemons. Most of these scripts I've found on the internet and they all use start-stop-daemon. My understanding is that \"start-stop-daemon\" is a command that is specific to Linux or BSD distros and is not available on S... |
Having read some on this subject:
Caching MySQL queries
http://www.danga.com/memcached/
My SQL Caching problem:
http://www.petefreitag.com/item/390.cfm
http://framework.zend.com/manual/en/zend.cache.html#zend.cache.introduction
I have a very unique (narrow) set of Queries and I think I could implement some caching quit... | You're on the right track by considering a caching solution that efficiently handles the unique queries your application runs. Caching can significantly improve performance by reducing database load and speeding up response times. Let's break down your approach and explore a few ideas and strategies for implementing ca... | 36,021 | [
{
"from": "human",
"value": "Having read some on this subject:\nCaching MySQL queries\nhttp://www.danga.com/memcached/\nMy SQL Caching problem:\nhttp://www.petefreitag.com/item/390.cfm\nhttp://framework.zend.com/manual/en/zend.cache.html#zend.cache.introduction\nI have a very unique (narrow) set of Queries ... |
I'm starting a web project that likely should be fine with SQLite. I have SQLObject on top of it, but thinking long term here -- if this project should require a more robust (e.g. able to handle high traffic), I will need to have a transition plan ready. My questions:
How easy is it to transition from one DB (SQLite... | Hi Sean,
Transitioning from SQLite to a more robust database like MySQL, PostgreSQL, or Firebird using SQLObject can be quite manageable, especially since SQLObject is designed to abstract away some of the differences between databases. Here are some key points to consider regarding your questions:
### Transitioning ... | 39,203 | [
{
"from": "human",
"value": "I'm starting a web project that likely should be fine with SQLite. I have SQLObject on top of it, but thinking long term here -- if this project should require a more robust (e.g. able to handle high traffic), I will need to have a transition plan ready. My questions:\n\nHow e... |
I have a MFC application in which I want to add internationalization support. The project is configured to use the "multi-byte character set" (the "unicode character set" is not an option in my situation).
Now, I would expect the CWnd::OnChar() function to send me multi-byte characters if I set my keyboard to some for... | When working with multi-byte character sets (MBCS) in an MFC application, it's important to understand that the `OnChar()` function operates on character values after they have been processed by the keyboard input system. Since MFC's message system deals with characters based on the application's character set setting,... | 39,940 | [
{
"from": "human",
"value": "I have a MFC application in which I want to add internationalization support. The project is configured to use the \"multi-byte character set\" (the \"unicode character set\" is not an option in my situation).\nNow, I would expect the CWnd::OnChar() function to send me multi-by... |
Using VBA in MS Office, how do I add text to the Windows clipboard so that it will paste into Word as a table?
| To add text to the Windows clipboard using VBA and have it paste into Word as a table, you can construct a tab-delimited string where rows are separated by line breaks and columns are separated by tabs. This string can be copied to the clipboard, and when pasted into Word, Word will recognize it as a table.
Here's a s... | 40,775 | [
{
"from": "human",
"value": "Using VBA in MS Office, how do I add text to the Windows clipboard so that it will paste into Word as a table?\n"
},
{
"from": "gpt",
"value": "To add text to the Windows clipboard using VBA and have it paste into Word as a table, you can construct a tab-delimited st... |
I need a setup created with InstallShield 2009 to install a windows service. The service needs an own account to be run under. This accounts needs to be created/selected from within the setup.
For this, I add the corresponding Logon Information Panel dialogs:
Dialogs -> All Dialogs -> Right Click -> New Dialog...
On th... | It seems like you're facing an issue with the Logon Information dialog in InstallShield 2009, specifically with browsing for user accounts and domains. Here are some steps to troubleshoot and resolve the issue:
### 1. **Check User Permissions**
- Ensure that the user account running the installation has the necessa... | 42,033 | [
{
"from": "human",
"value": "I need a setup created with InstallShield 2009 to install a windows service. The service needs an own account to be run under. This accounts needs to be created/selected from within the setup.\nFor this, I add the corresponding Logon Information Panel dialogs:\nDialogs -> All Di... |
Here is a little test program:
#include <iostream>
class Test
{
public:
static void DoCrash(){ std::cout<< "TEST IT!"<< std::endl; }
};
int main()
{
Test k;
k.DoCrash(); // calling a static method like a member method...
std::system("pause");
return 0;
}
On VS2008 + SP1 (vc9) it compiles fine:... | Your understanding of static member functions in C++ is generally correct, but there are some important nuances to clarify.
### Static Member Functions
1. **Definition**: Static member functions belong to the class rather than any particular object. This means that they can be called without creating an instance of t... | 43,567 | [
{
"from": "human",
"value": "Here is a little test program: \n#include <iostream>\n\nclass Test\n{\npublic:\n static void DoCrash(){ std::cout<< \"TEST IT!\"<< std::endl; }\n};\n\nint main()\n{\n Test k;\n k.DoCrash(); // calling a static method like a member method...\n\n std::system(\"pause\")... |
I had the following piece of code (simplified for this question):
struct StyleInfo
{
int width;
int height;
};
typedef int (StyleInfo::*StyleInfoMember);
void AddStyleInfoMembers(std::vector<StyleInfoMember>& members)
{
members.push_back(&StyleInfo::width);
members.push_back(&StyleInfo::height);
}
No... | The error you are encountering is due to the fact that you cannot use the member access operator `::` to directly access a member of a member variable in the way you're trying to do. Specifically, `&StyleInfo::size::width` is not valid because `size` is a member of `StyleInfo`, not a type that can be used with `::`.
T... | 41,171 | [
{
"from": "human",
"value": "I had the following piece of code (simplified for this question):\nstruct StyleInfo\n{\n int width;\n int height;\n};\n\ntypedef int (StyleInfo::*StyleInfoMember);\n\nvoid AddStyleInfoMembers(std::vector<StyleInfoMember>& members)\n{\n members.push_back(&StyleInfo::widt... |
I have a C++ API prototype
void Func(int& size);
How can I translate it to P/Invoke in C#?
From what I know, if I use
public static extern Func(ref int size);
, the function will receive a pointer to the int instead of the value.
| To correctly translate a C++ API function that takes an `int&` (a reference to an integer) to P/Invoke in C#, you'll need to define the function signature appropriately in C#. The C++ reference type is essentially equivalent to passing an integer by reference in C#, which can be done using the `ref` keyword.
Here’s ho... | 38,849 | [
{
"from": "human",
"value": "I have a C++ API prototype\nvoid Func(int& size);\n\nHow can I translate it to P/Invoke in C#?\nFrom what I know, if I use \npublic static extern Func(ref int size); \n\n, the function will receive a pointer to the int instead of the value.\n"
},
{
"from": "gpt",
"va... |
I have an after_save filter which I dont want to trigger in a specific instance. Is there a way to do this similar to save_without_validation?
Thanks,
| In Ruby on Rails, you can use various methods to conditionally skip callbacks like `after_save` for specific instances. While there isn't a direct equivalent of `save_without_validation` for skipping callbacks, you can achieve this through a couple of common strategies.
Here are two approaches you might consider:
###... | 40,861 | [
{
"from": "human",
"value": "I have an after_save filter which I dont want to trigger in a specific instance. Is there a way to do this similar to save_without_validation?\nThanks,\n"
},
{
"from": "gpt",
"value": "In Ruby on Rails, you can use various methods to conditionally skip callbacks lik... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.