instruction stringlengths 14 27.6k | completion stringlengths 3 38.3k | __original_row_idx int64 0 50k | conversations listlengths 2 2 |
|---|---|---|---|
The more we use RAII in C++, the more we find ourselves with destructors that do non-trivial deallocation. Now, deallocation (finalization, however you want to call it) can fail, in which case exceptions are really the only way to let anybody upstairs know of our deallocation problem. But then again, throwing-destructo... | You've raised some important and nuanced points about using RAII (Resource Acquisition Is Initialization) in C++ and the complexities surrounding destructors, particularly in the context of exception handling.
### Key Issues with Destructors and Exceptions
1. **Exception Safety**: If a destructor throws an exception ... | 16,992 | [
{
"from": "human",
"value": "The more we use RAII in C++, the more we find ourselves with destructors that do non-trivial deallocation. Now, deallocation (finalization, however you want to call it) can fail, in which case exceptions are really the only way to let anybody upstairs know of our deallocation pr... |
Further to my previous question about the Optimal RAID setup for SQL server, could anyone suggest a quick and dirty way of benchmarking the database performance on the new and old servers to compare them? Obviously, the proper way would be to monitor our actual usage and set up all sorts of performance counters and cap... | To quickly benchmark the database performance on your new and old SQL Server setups using your actual database, you can follow these steps. While it won't be as thorough as a detailed performance analysis, it will give you a reasonable understanding of the relative performance of the two environments. Here's a straight... | 19,062 | [
{
"from": "human",
"value": "Further to my previous question about the Optimal RAID setup for SQL server, could anyone suggest a quick and dirty way of benchmarking the database performance on the new and old servers to compare them? Obviously, the proper way would be to monitor our actual usage and set up ... |
Is there any easy way to retrieve table creation DDL from Microsoft Access (2007) or do I have to code it myself using VBA to read the table structure?
I have about 30 tables that we are porting to Oracle and it would make life easier if we could create the tables from the Access definitions.
| Yes, there is a way to retrieve the table creation DDL (Data Definition Language) from Microsoft Access without manually coding it yourself in VBA. Here are a few methods you can consider:
### Method 1: Use Access Export Features
1. **Export to Oracle**: If you have the Oracle ODBC driver installed, you can use the "E... | 16,198 | [
{
"from": "human",
"value": "Is there any easy way to retrieve table creation DDL from Microsoft Access (2007) or do I have to code it myself using VBA to read the table structure? \nI have about 30 tables that we are porting to Oracle and it would make life easier if we could create the tables from the Acc... |
The error happens trying to do an insert from a stored proc. I tried running DBCC CHECKDB as suggested by the kb article that Jonathan Holland suggested and it returned with the all clear.
| When dealing with an insert error in a stored procedure and having already run `DBCC CHECKDB` with no issues reported, here are several steps you can take to further troubleshoot the problem:
1. **Check the Error Message**: Ensure you are capturing the complete error message when the insert fails. The specific error c... | 22,073 | [
{
"from": "human",
"value": "The error happens trying to do an insert from a stored proc. I tried running DBCC CHECKDB as suggested by the kb article that Jonathan Holland suggested and it returned with the all clear.\n"
},
{
"from": "gpt",
"value": "When dealing with an insert error in a store... |
Is there a way to take a class name and convert it to a string in C#?
As part of the Entity Framework, the .Include method takes in a dot-delimited list of strings to join on when performing a query. I have the class model of what I want to join, and for reasons of refactoring and future code maintenance, I want to be... | In C#, if you want to convert a class name to a string for use in the Entity Framework's `.Include` method, you can use the `typeof()` operator instead of creating an instance of the class. The `typeof()` operator provides you with the `Type` object for the class without needing to instantiate it, allowing you to get t... | 21,456 | [
{
"from": "human",
"value": "Is there a way to take a class name and convert it to a string in C#? \nAs part of the Entity Framework, the .Include method takes in a dot-delimited list of strings to join on when performing a query. I have the class model of what I want to join, and for reasons of refactoring... |
I'm using jmockit with my tests and with one class I wish to test, uses InitialContext directly. So I have the following:
public class MyClass {
public void myMethod() {
InitialContext ic = new InitialContext();
javax.mail.Session mailSession = ic.lookup("my.mail.session");
// rest of method follows........ | Mocking JNDI and classes like `InitialContext` can be tricky, especially when using frameworks like JMockit. To resolve the `NoClassDefFoundError` and successfully mock `InitialContext`, you need to ensure a couple of things.
1. **Ensure Class Availability**: First, ensure that your `MockInitialContext` class is prope... | 19,949 | [
{
"from": "human",
"value": "I'm using jmockit with my tests and with one class I wish to test, uses InitialContext directly. So I have the following:\npublic class MyClass {\n public void myMethod() {\n InitialContext ic = new InitialContext();\n javax.mail.Session mailSession = ic.lookup(\"my.mail.... |
We have a number of projects that use the same and/or similar package names. Many or these projects will build jar files that are used by other projects. We have found a number of foo.util foo.db and foo.exceptions where the same class names are being used leading to name space conflicts.
Does anyone know of a tool th... | Yes, there are several tools and techniques you can use to identify namespace conflicts and ambiguous imports in Java codebases. Here are a few options:
1. **Static Analysis Tools**:
- **Checkstyle**: While primarily a coding standard checker, Checkstyle can be configured to identify certain naming conventions and ... | 23,432 | [
{
"from": "human",
"value": "We have a number of projects that use the same and/or similar package names. Many or these projects will build jar files that are used by other projects. We have found a number of foo.util foo.db and foo.exceptions where the same class names are being used leading to name space ... |
I mostly develop on Linux and meld is indispensable for me. However, when I'm on the road I use a MacBook (leopard) and I want to use the same set of tools as on my main development box, meld being one of them.
Although you shoud be able to install meld, I could not succeed with it. So... are there any alternatives tha... | If you’re looking for alternatives to Meld on macOS Leopard, there are a few options that can provide similar functionality for visual file comparison and merging. Here are some alternatives you might consider:
1. **Beyond Compare**: This is a powerful commercial tool that offers a feature set comparable to Meld. Beyo... | 22,875 | [
{
"from": "human",
"value": "I mostly develop on Linux and meld is indispensable for me. However, when I'm on the road I use a MacBook (leopard) and I want to use the same set of tools as on my main development box, meld being one of them.\nAlthough you shoud be able to install meld, I could not succeed wit... |
This is really only easy to explain with an example, so to remove the intersection of a list from within a dict I usually do something like this:
a = {1:'', 2:'', 3:'', 4:''}
exclusion = [3, 4, 5]
# have to build up a new list or the iteration breaks
toRemove = []
for var in a.iterkeys():
if var in exclusion:
... | Yes, there is a more concise and efficient way to remove keys from a dictionary based on a list of exclusions without needing to create an intermediate list or using multiple loops. You can use a dictionary comprehension to create a new dictionary that only includes the keys you want to retain. Here’s how you can do th... | 24,650 | [
{
"from": "human",
"value": "This is really only easy to explain with an example, so to remove the intersection of a list from within a dict I usually do something like this:\na = {1:'', 2:'', 3:'', 4:''}\nexclusion = [3, 4, 5]\n\n# have to build up a new list or the iteration breaks\ntoRemove = []\nfor var... |
Every once in a while, typically when I stop debugging in our UI assembly, I get the following error which requires a restart of Visual Studio 2008 and it's killing my productivity:
Error 13 Unable to copy file
[UI assembly]
to
[output directory].
The process cannot access the file
[output directory][UI ass... | It sounds like you're experiencing a frustrating issue with Visual Studio 2008 related to file locks and build configurations. Here are several potential solutions and workarounds that could help you mitigate this issue:
### 1. Disable/Uninstall Add-ins
Since you are using several add-ins, one of them might be causing... | 19,785 | [
{
"from": "human",
"value": "Every once in a while, typically when I stop debugging in our UI assembly, I get the following error which requires a restart of Visual Studio 2008 and it's killing my productivity:\n\nError 13 Unable to copy file\n [UI assembly]\n to\n [output directory].\n The process can... |
My place of employment is looking into buying a third party tool, for batch based US and Canadian Address correction, with Geo-coding.
What Products have you used?
What do you like about them?
What do you not like about them?
Note that, We are a C/C++ Unix Shop.
| When considering third-party tools for batch address correction and geocoding for the US and Canada, there are several options in the market. Here are a few prominent tools, along with their advantages and disadvantages:
### 1. **SmartyStreets**
- **What I Like:**
- High accuracy for address validation and geo... | 21,821 | [
{
"from": "human",
"value": "My place of employment is looking into buying a third party tool, for batch based US and Canadian Address correction, with Geo-coding.\n\nWhat Products have you used?\nWhat do you like about them?\nWhat do you not like about them?\n\nNote that, We are a C/C++ Unix Shop.\n"
},
... |
We've got a web system running SQL Server 2005 for the back end, and ASP.Net for the front end (using .net 2.0).
Every now and then, the system barfs out the error in the title: 'SQLOLEDB' failed with no error message available, result code: E_FAIL(0x80004005).
The web system runs just fine 24/7, and then every now an... | The error message you're encountering, `'SQLOLEDB' failed with no error message available, result code: E_FAIL(0x80004005)`, is a generic OLE DB error that can be triggered by several underlying issues. Here are some potential causes and troubleshooting steps you can take:
1. **Intermittent Network Issues**: Since you... | 19,543 | [
{
"from": "human",
"value": "We've got a web system running SQL Server 2005 for the back end, and ASP.Net for the front end (using .net 2.0).\nEvery now and then, the system barfs out the error in the title: 'SQLOLEDB' failed with no error message available, result code: E_FAIL(0x80004005). \nThe web system... |
Any failed ASSERT statements on Windows cause the below debug message to appear and freeze the applications execution. I realise this is expected behaviour but it is running periodically on a headless machine so prevent the unit tests from failing, instead waiting on user input indefinitely.
Is there s a registry key o... | To prevent assertion dialogs in a headless environment without modifying the code, you can use the following approaches. These changes can be made at the system or compiler level:
### Option 1: Use Environment Variables
You can set the `_CrtSetReportMode` environment variable in your test execution environment to ign... | 22,536 | [
{
"from": "human",
"value": "Any failed ASSERT statements on Windows cause the below debug message to appear and freeze the applications execution. I realise this is expected behaviour but it is running periodically on a headless machine so prevent the unit tests from failing, instead waiting on user input ... |
In C# I could easily write the following:
string stringValue = string.IsNullOrEmpty( otherString ) ? defaultString : otherString;
Is there a quick way of doing the same thing in Python or am I stuck with an 'if' statement?
| In Python, you can achieve similar functionality using a conditional expression (also known as a ternary conditional operator). The syntax is quite similar to C#. Here is how you can rewrite your C# example in Python:
```python
other_string = None # or some other string value
default_string = "default value"
string_... | 25,687 | [
{
"from": "human",
"value": "In C# I could easily write the following:\nstring stringValue = string.IsNullOrEmpty( otherString ) ? defaultString : otherString;\n\nIs there a quick way of doing the same thing in Python or am I stuck with an 'if' statement?\n"
},
{
"from": "gpt",
"value": "In Pyth... |
I have a little demonstration below of a peculiar problem.
using System;
using System.Windows.Forms;
namespace WindowsApplication1
{
public class TestForm : Form
{
private System.Windows.Forms.TabControl tabControl1;
private System.Windows.Forms.TabPage tabPage1;
private System.Windows.... | The issue you're experiencing with the reported width of `textBox1` in the `tabControl1_Selected` event is due to how the `TabControl` and its contained controls manage their layouts when the tabs are switched. When you resize the form and switch to `tabPage1`, the `TextBox` might not have been completely laid out yet,... | 23,968 | [
{
"from": "human",
"value": "I have a little demonstration below of a peculiar problem.\nusing System;\nusing System.Windows.Forms;\n\nnamespace WindowsApplication1\n{\n public class TestForm : Form\n {\n private System.Windows.Forms.TabControl tabControl1;\n private System.Windows.Forms... |
What is the best way to secure an intranet website developed using PHP from outside attacks?
| Securing an intranet website developed using PHP involves a multi-layered approach to protect against various types of attacks. Here are some best practices to enhance the security of your PHP-based intranet:
### 1. **Network Security**
- **Firewalls**: Use firewalls to restrict access to the web server, allowing onl... | 20,193 | [
{
"from": "human",
"value": "What is the best way to secure an intranet website developed using PHP from outside attacks?\n"
},
{
"from": "gpt",
"value": "Securing an intranet website developed using PHP involves a multi-layered approach to protect against various types of attacks. Here are some... |
Is there any advantage to using __construct() instead of the class's name for a constructor in PHP?
Example (__construct):
class Foo {
function __construct(){
//do stuff
}
}
Example (named):
class Foo {
function Foo(){
//do stuff
}
}
Having the __construct method (first example) is pos... | Yes, there are several advantages to using `__construct()` instead of the class name for the constructor in PHP, particularly given the evolution of PHP language features and best practices.
### Advantages of Using `__construct()`
1. **Compatibility with Inheritance**:
- When you define a constructor using `__cons... | 22,350 | [
{
"from": "human",
"value": "Is there any advantage to using __construct() instead of the class's name for a constructor in PHP?\nExample (__construct):\nclass Foo {\n function __construct(){\n //do stuff\n }\n}\n\nExample (named):\nclass Foo {\n function Foo(){\n //do stuff\n }\n}... |
Assume I have a class foo, and wish to use a std::map to store some boost::shared_ptrs, e.g.:
class foo;
typedef boost::shared_ptr<foo> foo_sp;
typeded std::map<int, foo_sp> foo_sp_map;
foo_sp_map m;
If I add a new foo_sp to the map but the key used already exists, will the existing entry be deleted? For example:
f... | Yes, you are correct in your understanding of how `boost::shared_ptr` works in conjunction with `std::map`.
When you use `m[0] = p2;` to assign a new `boost::shared_ptr<foo>` (`p2`) to an existing key (`0`) in the `std::map`, the existing `boost::shared_ptr<foo>` that was previously associated with that key (`p`, in ... | 17,202 | [
{
"from": "human",
"value": "Assume I have a class foo, and wish to use a std::map to store some boost::shared_ptrs, e.g.:\nclass foo;\n\ntypedef boost::shared_ptr<foo> foo_sp;\ntypeded std::map<int, foo_sp> foo_sp_map;\n\nfoo_sp_map m;\n\nIf I add a new foo_sp to the map but the key used already exists, wi... |
How do I display a leading zero for all numbers with less than two digits?
1 → 01
10 → 10
100 → 100
| To display a leading zero for all numbers with less than two digits, you can use various programming languages or formatting techniques. Below are examples for several common languages:
### Python
You can use the `zfill()` method or string formatting:
```python
def format_number(num):
return str(num).zfill(2)
# ... | 20,917 | [
{
"from": "human",
"value": "How do I display a leading zero for all numbers with less than two digits?\n1 → 01\n10 → 10\n100 → 100\n\n"
},
{
"from": "gpt",
"value": "To display a leading zero for all numbers with less than two digits, you can use various programming languages or format... |
What would be the best way to write Objective-C on the Windows platform?
Cygwin and gcc? Is there a way I can somehow integrate this into Visual Studio?
Along those lines - are there any suggestions as to how to link in and use the Windows SDK for something like this. Its a different beast but I know I can write assemb... | Writing Objective-C on the Windows platform presents some unique challenges, primarily because Objective-C is traditionally associated with macOS and iOS development. However, there are ways to get started with Objective-C on Windows:
### Options for Writing Objective-C on Windows
1. **Cygwin + GCC**:
- Cygwin pro... | 19,861 | [
{
"from": "human",
"value": "What would be the best way to write Objective-C on the Windows platform?\nCygwin and gcc? Is there a way I can somehow integrate this into Visual Studio?\nAlong those lines - are there any suggestions as to how to link in and use the Windows SDK for something like this. Its a di... |
I've made a class which inherits from UserControl, but which I only want to use as a base for subclasses. Is there a way I can stop VS2008 from trying to edit it in the designer, that won't stop the subclasses from being edited in the designer?
| In Visual Studio 2008, you can prevent a class derived from `UserControl` from being editable in the designer while still allowing its subclasses to be editable. To achieve this, you can do the following:
1. **Use the `ToolboxItem` Attribute**: You can prevent the base user control from being added to the toolbox by a... | 23,912 | [
{
"from": "human",
"value": "I've made a class which inherits from UserControl, but which I only want to use as a base for subclasses. Is there a way I can stop VS2008 from trying to edit it in the designer, that won't stop the subclasses from being edited in the designer?\n"
},
{
"from": "gpt",
... |
Given two datetimes. What is the best way to calculate the number of working hours between them. Considering the working hours are Mon 8 - 5.30, and Tue-Fri 8.30 - 5.30, and that potentially any day could be a public holiday.
This is my effort, seem hideously inefficient but in terms of the number of iterations and tha... | Your current approach iterates minute by minute, which can indeed be inefficient, especially if the `IsWorkingDay` function involves a database query. Instead, you can optimize your calculation by breaking down the datetime range into distinct working hours and days.
Here is a more efficient way to calculate the numb... | 17,990 | [
{
"from": "human",
"value": "Given two datetimes. What is the best way to calculate the number of working hours between them. Considering the working hours are Mon 8 - 5.30, and Tue-Fri 8.30 - 5.30, and that potentially any day could be a public holiday.\nThis is my effort, seem hideously inefficient but in... |
I have a web application (asp.net) where work items are submitted and allocated to users according to their workload.
A user's workload is calculated using an algorithm based on the number of items currently allocated to the user (and some other factors). Each new item is allocated to the user with the lowest current w... | In a scenario where multiple threads or processes are concurrently allocating work items and updating user workload, you need a solution that allows for real-time updates and minimizes contention and bottlenecks. Both caching and database locking strategies can be used, but each has its trade-offs. Below are some appro... | 19,345 | [
{
"from": "human",
"value": "I have a web application (asp.net) where work items are submitted and allocated to users according to their workload.\nA user's workload is calculated using an algorithm based on the number of items currently allocated to the user (and some other factors). Each new item is alloc... |
Is it even possible to perform address (physical, not e-mail) validation? It seems like the sheer number of address formats, even in the US alone, would make this a fairly difficult task. On the other hand it seems like a task that would be necessary for several business requirements.
| Yes, it is indeed possible to perform address validation, although it can be challenging due to the variety of formats and standards used across different regions and countries. In the United States, for example, addresses can vary significantly in terms of format, terminology, and abbreviations. Here are some points t... | 21,043 | [
{
"from": "human",
"value": "Is it even possible to perform address (physical, not e-mail) validation? It seems like the sheer number of address formats, even in the US alone, would make this a fairly difficult task. On the other hand it seems like a task that would be necessary for several business requi... |
I have a web page in which people go to register for my site. I use server side validation to authenticate them. I need to call some Javascript to tell GA that user was or was not registered. Later I need stats on success in registration.
How can I call the GA function on my server side C# code?
| To send data to Google Analytics (GA) from your server-side C# code, you can use the Measurement Protocol, which allows you to send HTTP requests to GA to track events and user interactions. Here's how you can implement it in your registration process:
### Step 1: Set Up Google Analytics
Ensure that your Google Analy... | 18,855 | [
{
"from": "human",
"value": "I have a web page in which people go to register for my site. I use server side validation to authenticate them. I need to call some Javascript to tell GA that user was or was not registered. Later I need stats on success in registration.\nHow can I call the GA function on my se... |
I have data coming from the database in the form of a DataSet. I then set it as the DataSource of a grid control before doing a DataBind(). I want to sort the DataSet/DataTable on one column. The column is to complex to sort in the database but I was hoping I could sort it like I would sort a generic list i.e. using a ... | In .NET 2.0, you can sort a `DataTable` directly without needing to transfer it to a different data structure, although the API does not support delegates like you might find in a generic list. Instead, you can use the `DefaultView` of the `DataTable` to apply sorting.
Here’s how you can do it:
1. **Use the `DefaultV... | 22,702 | [
{
"from": "human",
"value": "I have data coming from the database in the form of a DataSet. I then set it as the DataSource of a grid control before doing a DataBind(). I want to sort the DataSet/DataTable on one column. The column is to complex to sort in the database but I was hoping I could sort it like ... |
Is there a way to run some custom Javascript whenever a client-side ASP.NET validator (RequiredFieldValidator, RangeValidator, etc) is triggered?
Basically, I have a complicated layout that requires I run a custom script whenever a DOM element is shown or hidden. I'm looking for a way to automatically run this script ... | Yes, you can execute custom JavaScript whenever a client-side ASP.NET validator is triggered by utilizing the `ClientValidationFunction` and the `OnClientClick` properties, or by attaching your custom JavaScript functions to the events related to the validators. Here's a general approach you can take:
### Method 1: Us... | 19,990 | [
{
"from": "human",
"value": "Is there a way to run some custom Javascript whenever a client-side ASP.NET validator (RequiredFieldValidator, RangeValidator, etc) is triggered? \nBasically, I have a complicated layout that requires I run a custom script whenever a DOM element is shown or hidden. I'm looking f... |
I have an ANSI encoded text file that should not have been encoded as ANSI as there were accented
characters that ANSI does not support. I would rather work with UTF-8.
Can the data be decoded correctly or is it lost in transcoding?
What tools could I use?
Here is a sample of what I have:
ç é
I can tell from context... | When a UTF-8 encoded file is incorrectly interpreted or saved as ANSI (often referring to Windows-1252 or ISO-8859-1), the data may become garbled. In your case, the characters are misrepresented. The garbled output you've shown (e.g., `ç`, `é`) indicates that the UTF-8 byte sequences are being read as single-byte AN... | 21,817 | [
{
"from": "human",
"value": "I have an ANSI encoded text file that should not have been encoded as ANSI as there were accented\ncharacters that ANSI does not support. I would rather work with UTF-8.\nCan the data be decoded correctly or is it lost in transcoding?\nWhat tools could I use?\nHere is a sample o... |
This is only happening on the live server. On multiply development servers the image is being created as expected.
LIVE:
Red Hat
$ php --version
PHP 5.2.6 (cli) (built: May 16 2008 21:56:34)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
GD Support => enabled
GD Ve... | The issue you are experiencing with the image being cut off on the live server while it works correctly on the development servers could be attributed to several factors. Since both servers are using different environments (Red Hat vs. Ubuntu) and slightly different versions of PHP and the GD library, let's explore som... | 20,821 | [
{
"from": "human",
"value": "This is only happening on the live server. On multiply development servers the image is being created as expected.\nLIVE:\nRed Hat\n$ php --version\nPHP 5.2.6 (cli) (built: May 16 2008 21:56:34) \nCopyright (c) 1997-2008 The PHP Group\nZend Engine v2.2.0, Copyright (c) 1998-2008... |
I have been thinking about design by contract lately and I was wondering what people think is the best way to assert pre-condition and post-condition of values in .NET?
i.e. validating argument values to a method.
Some people recommend Debug.Assert while others talk about using an if statement plus throwing an exceptio... | Design by Contract (DbC) is a programming methodology that specifies a formal, precise, and verifiable interface for software components. In .NET, asserting preconditions and postconditions can be implemented in several ways, each with its pros and cons.
### 1. `Debug.Assert`
#### Pros:
- **Performance:** `Debug.Asse... | 21,135 | [
{
"from": "human",
"value": "I have been thinking about design by contract lately and I was wondering what people think is the best way to assert pre-condition and post-condition of values in .NET?\ni.e. validating argument values to a method.\nSome people recommend Debug.Assert while others talk about usin... |
I have no experience with web services. Historically I've built client-server systems using proprietary communication protocols (even they happen to be XML). I just spent a few hours looking over Axis2 and it sent a shudder down my spine. The learning curve of WS scares me, and seeing all that XML surround so little fu... | Choosing between web services and a custom communication protocol can significantly impact your project's architecture, maintainability, and scalability. Here's a guideline to help you navigate this decision:
### Factors to Consider
1. **Interoperability Needs**
- **Web Services**: Great for interoperability acros... | 20,703 | [
{
"from": "human",
"value": "I have no experience with web services. Historically I've built client-server systems using proprietary communication protocols (even they happen to be XML). I just spent a few hours looking over Axis2 and it sent a shudder down my spine. The learning curve of WS scares me, and ... |
I have a string in a node and I'd like to split the string on '?' and return the last item in the array.
For example, in the block below:
<a>
<xsl:attribute name="href">
/newpage.aspx?<xsl:value-of select="someNode"/>
</xsl:attribute>
Link text
</a>
I'd like to split the someNode value.
Edit:
Here... | To split a string on the '?' character in XSLT and return the last item from the resulting array, you can use the `substring-after` function in combination with the `fn:tokenize` function (available in XSLT 2.0 and later). Here's how you can accomplish this:
### Step-by-step approach
1. Use `tokenize` to split the st... | 16,268 | [
{
"from": "human",
"value": "I have a string in a node and I'd like to split the string on '?' and return the last item in the array.\nFor example, in the block below:\n<a>\n <xsl:attribute name=\"href\">\n /newpage.aspx?<xsl:value-of select=\"someNode\"/>\n </xsl:attribute>\n Link text\n</a... |
How do you set a default value for a MySQL Datetime column?
In SQL Server it's getdate(). What is the equivalant for MySQL? I'm using MySQL 5.x if that is a factor.
| In MySQL, you can set a default value for a `DATETIME` column to the current timestamp using the `CURRENT_TIMESTAMP` function. This is similar to `GETDATE()` in SQL Server.
If you're creating a table and want to set a `DATETIME` column to default to the current date and time, you can use the following syntax:
```sql
... | 23,899 | [
{
"from": "human",
"value": "How do you set a default value for a MySQL Datetime column?\nIn SQL Server it's getdate(). What is the equivalant for MySQL? I'm using MySQL 5.x if that is a factor.\n"
},
{
"from": "gpt",
"value": "In MySQL, you can set a default value for a `DATETIME` column to the... |
I'm currently doing some GUI testing on a ASP.net 2.0 application.
The RDBMS is SQL Server 2005. The host is Win Server 2003 / IIS 6.0.
I do not have the source code of the application because it was programmed by an external company who's not releasing the code.
I've noticed that the application performs well when I ... | The symptoms you are describing—performance degradation over time, particularly following a restart of IIS—could indeed be indicative of connection leaks or other resource management issues in the ASP.NET application. Here are the answers to your questions, along with additional guidance on tracking down these issues.
... | 20,616 | [
{
"from": "human",
"value": "I'm currently doing some GUI testing on a ASP.net 2.0 application. \nThe RDBMS is SQL Server 2005. The host is Win Server 2003 / IIS 6.0.\nI do not have the source code of the application because it was programmed by an external company who's not releasing the code.\nI've notice... |
I think most of the SharePoint developers and administrators know that with the change form Firefox 2 to Firefox 3 some functionality of SharePoint have became unavailable.
Especially adding Webparts to a site and using the PeoplePicker don't work anymore with Firefox 3. So I want to know how you deal with this proble... | The compatibility issues between SharePoint and Firefox, particularly after the transition from Firefox 2 to Firefox 3, have been a common frustration for many users. Here are some strategies and workarounds you can consider to help address the complaints and improve usability for users of Firefox 3:
1. **Use Compatib... | 21,570 | [
{
"from": "human",
"value": "I think most of the SharePoint developers and administrators know that with the change form Firefox 2 to Firefox 3 some functionality of SharePoint have became unavailable. \nEspecially adding Webparts to a site and using the PeoplePicker don't work anymore with Firefox 3. So I ... |
There seems to have been some interest over the past year around COP within the .NET community (ala Qi4j). A few folks have rolled there own COP frameworks (see links below) and it would appear .NET 4.0's Dynamic Dispatch and MEF might have a potential role in any .NET COP framework.
On one hand a lot of this would ap... | Composite Oriented Programming (COP) is indeed an interesting concept that has been gaining traction in the .NET community. The ideas behind COP emphasize the combination of behavior and structure in a more modular way, allowing for greater flexibility and extensibility. As you noted, frameworks such as Qi4j in the Jav... | 21,174 | [
{
"from": "human",
"value": "There seems to have been some interest over the past year around COP within the .NET community (ala Qi4j). A few folks have rolled there own COP frameworks (see links below) and it would appear .NET 4.0's Dynamic Dispatch and MEF might have a potential role in any .NET COP frame... |
In Java, suppose I have a String variable S, and I want to search for it inside of another String T, like so:
if (T.matches(S)) ...
(note: the above line was T.contains() until a few posts pointed out that that method does not use regexes. My bad.)
But now suppose S may have unsavory characters in it. For instanc... | Yes, you can escape special characters in a string that will be used as a regular expression in Java. One common approach is to use the `Pattern.quote(String s)` method from the `java.util.regex` package. This method returns a string that is the same as the input string but with any special characters escaped, which ma... | 23,347 | [
{
"from": "human",
"value": "In Java, suppose I have a String variable S, and I want to search for it inside of another String T, like so:\n if (T.matches(S)) ...\n\n(note: the above line was T.contains() until a few posts pointed out that that method does not use regexes. My bad.)\nBut now suppose S may... |
I'm looking for the equivalent in Qt to GetTickCount()
Something that will allow me to measure the time it takes for a segment of code to run as in:
uint start = GetTickCount();
// do something..
uint timeItTook = GetTickCount() - start;
any suggestions?
| In Qt, you can use the `QElapsedTimer` class to measure the elapsed time for a segment of code, similar to how you would use `GetTickCount()` in Windows. Here's how you can do it:
```cpp
#include <QElapsedTimer>
#include <QDebug>
void someFunction() {
QElapsedTimer timer; // Create an instance of QElapsedTimer
... | 25,452 | [
{
"from": "human",
"value": "I'm looking for the equivalent in Qt to GetTickCount()\nSomething that will allow me to measure the time it takes for a segment of code to run as in:\nuint start = GetTickCount();\n// do something..\nuint timeItTook = GetTickCount() - start;\n\nany suggestions?\n"
},
{
"... |
I can enumerate many features of functional programming, but when my friend asked me Could you define functional programming for me? I couldn't.
| Functional programming is a programming paradigm that treats computation as the evaluation of mathematical functions and avoids changing state and mutable data. Here are some key characteristics and concepts that help define functional programming:
1. **First-Class Functions**: Functions are treated as first-class cit... | 24,438 | [
{
"from": "human",
"value": "I can enumerate many features of functional programming, but when my friend asked me Could you define functional programming for me? I couldn't.\n"
},
{
"from": "gpt",
"value": "Functional programming is a programming paradigm that treats computation as the evaluatio... |
What is the best way to get a file (in this case, a .PDF, but any file will do) from a WebResponse and put it into a MemoryStream? Using .GetResponseStream() from WebResponse gets a Stream object, but if you want to convert that Stream to a specific type of stream, what do you do?
| To get a file from a `WebResponse`, specifically a PDF file (or any type of file), and load it into a `MemoryStream`, you can use the `GetResponseStream()` method from the `WebResponse` to get the data as a stream. Then, you can read the contents of that stream into a `MemoryStream`. Here's how you can do this in C#:
... | 21,301 | [
{
"from": "human",
"value": "What is the best way to get a file (in this case, a .PDF, but any file will do) from a WebResponse and put it into a MemoryStream? Using .GetResponseStream() from WebResponse gets a Stream object, but if you want to convert that Stream to a specific type of stream, what do you ... |
What are the main differences between XHTML and HTML? Which one is better in your opinion, and why? Do most browsers support both?
| XHTML (Extensible Hypertext Markup Language) and HTML (Hypertext Markup Language) are both markup languages used for creating web pages, but they have some key differences:
### Main Differences:
1. **Syntax Rules:**
- **XHTML**: Follows strict XML syntax rules. For example, all tags must be properly closed (e.g., ... | 21,341 | [
{
"from": "human",
"value": "What are the main differences between XHTML and HTML? Which one is better in your opinion, and why? Do most browsers support both?\n"
},
{
"from": "gpt",
"value": "XHTML (Extensible Hypertext Markup Language) and HTML (Hypertext Markup Language) are both markup langu... |
In SQL SERVER DB, I need to alter a column baseColumn and a computed column upperBaseColumn. The upperBaseColumn has index on it.
This is how the table looks
create table testTable (baseColumn varchar(10), upperBaseColumn AS (upper(baseColumn))
create index idxUpperBaseColumn ON testTable (upperBaseColumn)
Now I need... | To alter the column length of `baseColumn` and the computed column `upperBaseColumn` in SQL Server, you'll need to take the following steps:
1. **Drop the index on the computed column**: Since `upperBaseColumn` is a computed column with an index, you cannot alter the underlying column until the index is dropped.
2.... | 22,098 | [
{
"from": "human",
"value": "In SQL SERVER DB, I need to alter a column baseColumn and a computed column upperBaseColumn. The upperBaseColumn has index on it.\nThis is how the table looks\ncreate table testTable (baseColumn varchar(10), upperBaseColumn AS (upper(baseColumn))\n\ncreate index idxUpperBaseColu... |
I have an Open Source app and I have it working on Windows, Linux and Macintosh ( it's in C++ and built with gcc ). I've only tested it on a few different flavors of Linux so I don't know if it compiles and runs on all different Linux versions. Is there a place where I can upload my code and have it tested across a bun... | To achieve what you're looking for, you can use several Continuous Integration (CI) services that can compile your code across different operating systems and environments. Here are a few options that could meet your requirements:
1. **Travis CI**:
- Travis CI supports various Linux distributions and allows you to ... | 20,690 | [
{
"from": "human",
"value": "I have an Open Source app and I have it working on Windows, Linux and Macintosh ( it's in C++ and built with gcc ). I've only tested it on a few different flavors of Linux so I don't know if it compiles and runs on all different Linux versions. Is there a place where I can uploa... |
I'm trying to do my linq 2 sql objects manually, so I have the following code:
var mapping = XmlMappingSource.FromXml(xml);
using (DataContext ctx = new DataContext(conn_string, mapping))
{
list = ctx.GetTable<Achievement>().ToList();
}
and the XML looks like this:
<?xml version="1.0" encoding="utf-8" ?>
<Databas... | It seems you're running into an issue with how LINQ to SQL is interpreting the mapping of your `Achievement` class to the SQL table schema you've provided. The error message indicates that LINQ to SQL is expecting the `Id` property to be of type `Int32` but is actually defined as a `Guid` in your `Achievement` class.
... | 19,591 | [
{
"from": "human",
"value": "I'm trying to do my linq 2 sql objects manually, so I have the following code:\nvar mapping = XmlMappingSource.FromXml(xml);\n\nusing (DataContext ctx = new DataContext(conn_string, mapping))\n{\n list = ctx.GetTable<Achievement>().ToList();\n}\n\nand the XML looks like this:... |
Every time I see Ruby or Python discussed in the context of web development, it's always with a framework (Rails for Ruby, Django for Python). Are these frameworks necessary? If not, is there a reason why these languages are often used within a framework, while Perl and PHP are not?
| Frameworks like Ruby on Rails and Django for Ruby and Python respectively provide a structured and efficient way to build web applications. While it is technically possible to develop web applications in these languages without frameworks, there are several reasons why developers often choose to use them:
### Benefits... | 20,316 | [
{
"from": "human",
"value": "Every time I see Ruby or Python discussed in the context of web development, it's always with a framework (Rails for Ruby, Django for Python). Are these frameworks necessary? If not, is there a reason why these languages are often used within a framework, while Perl and PHP are ... |
OK, first let me state that I have never used this control and this is also my first attempt at using a web service.
My dilemma is as follows. I need to query a database to get back a certain column and use that for my autocomplete. Obviously I don't want the query to run every time a user types another word in the tex... | Absolutely! It sounds like you're looking to implement an autocomplete feature in a web application by querying a database and then filtering results based on user input. Here's a step-by-step guide on how to achieve this without overloading your database with queries.
### Step 1: Query the Database
First, you'll wan... | 15,251 | [
{
"from": "human",
"value": "OK, first let me state that I have never used this control and this is also my first attempt at using a web service.\nMy dilemma is as follows. I need to query a database to get back a certain column and use that for my autocomplete. Obviously I don't want the query to run every... |
When I worked on the Zend Framework's database component, we tried to abstract the functionality of the LIMIT clause supported by MySQL, PostgreSQL, and SQLite. That is, creating a query could be done this way:
$select = $db->select();
$select->from('mytable');
$select->order('somecolumn');
$select->limit(10, 20);
Wh... | In Microsoft SQL Server 2000, emulating the LIMIT functionality without using temporary tables, cursors, or T-SQL stored procedures is indeed challenging. Given the restrictions and requirements (specifically needing both offset and count), the solutions are limited.
The main issue, as you pointed out, is that without... | 21,730 | [
{
"from": "human",
"value": "When I worked on the Zend Framework's database component, we tried to abstract the functionality of the LIMIT clause supported by MySQL, PostgreSQL, and SQLite. That is, creating a query could be done this way:\n$select = $db->select();\n$select->from('mytable');\n$select->orde... |
I have a stored procedure that looks like:
CREATE PROCEDURE dbo.usp_TestFilter
@AdditionalFilter BIT = 1
AS
SELECT *
FROM dbo.SomeTable T
WHERE
T.Column1 IS NOT NULL
AND CASE WHEN @AdditionalFilter = 1 THEN
T.Column2 IS NOT NULL
Needless to say, this doesn't work. How can I activate the additiona... | To incorporate the `@AdditionalFilter` parameter into your `WHERE` clause in a way that it conditionally applies an additional filter, you can use a combination of logical conditions. The idea is to always include the essential filters, and then add the condition for `@AdditionalFilter` in a way that doesn't interfere ... | 22,400 | [
{
"from": "human",
"value": "I have a stored procedure that looks like:\nCREATE PROCEDURE dbo.usp_TestFilter\n @AdditionalFilter BIT = 1\nAS\n SELECT *\n FROM dbo.SomeTable T\n WHERE\n T.Column1 IS NOT NULL\n AND CASE WHEN @AdditionalFilter = 1 THEN\n T.Column2 IS NOT NULL\n\nNeedless to say,... |
I'm very early in the iPhone development learning process. I'm trying to get my head around various pieces. Right now I've just taken the basic NavigationController template and I'm trying to create a simple grouped table view with a couple of text fields. What I can't seem to do is to get Interface Builder to allow... | Yes, you can definitely add `UITableViewCell` with `UITextField` to a `UITableView` in Interface Builder, but the process is a bit specific. Here’s a step-by-step guide to help you set it up properly:
### Creating a Grouped Table View with Text Fields
1. **Create a New Project**:
Start a new Xcode project using th... | 18,115 | [
{
"from": "human",
"value": "I'm very early in the iPhone development learning process. I'm trying to get my head around various pieces. Right now I've just taken the basic NavigationController template and I'm trying to create a simple grouped table view with a couple of text fields. What I can't seem t... |
I am creating a Visual Studio Setup project. I want to un-install another component from the system from the install of my component. The other component is installed from my own setup created using Visual Studio.
Currently when I am calling the un-install of the other component from the install action of the component... | When you encounter error code 1618 while trying to uninstall another component during the installation process of your Visual Studio Setup project, it indicates that there is already another Windows Installer (MSI) package running. Windows Installer does not allow nested installations or uninstalls to occur simultaneou... | 19,875 | [
{
"from": "human",
"value": "I am creating a Visual Studio Setup project. I want to un-install another component from the system from the install of my component. The other component is installed from my own setup created using Visual Studio.\nCurrently when I am calling the un-install of the other componen... |
I am using sql server 2005. I just want to know is there something we can get the week number for the particular month. Example Date = '2008-10-16' Is there something we can have SELECT WEEK(Date). Or any better suggestion.
| In SQL Server 2005, there is no built-in function that directly retrieves the week number for a particular month like `WEEK(Date)` in MySQL. However, you can calculate the week number for a specific month using a combination of SQL functions.
Here’s how you can achieve this:
1. Determine the first day of the month fo... | 19,593 | [
{
"from": "human",
"value": "I am using sql server 2005. I just want to know is there something we can get the week number for the particular month. Example Date = '2008-10-16' Is there something we can have SELECT WEEK(Date). Or any better suggestion.\n"
},
{
"from": "gpt",
"value": "In SQL Ser... |
I am using a Q3Table object and wanted to change the width of the vertical header column. Does anyone know how to do this? It seems I can only adjust the height of the header cell but not the width.
| In a Q3Table, the vertical header is controlled using the `setColumnWidth()` method, which can also indirectly affect the header widths. However, if you specifically want to change the width of the vertical header column (the leftmost column displaying the row numbers or labels), you might need to customize the width t... | 21,269 | [
{
"from": "human",
"value": "I am using a Q3Table object and wanted to change the width of the vertical header column. Does anyone know how to do this? It seems I can only adjust the height of the header cell but not the width.\n"
},
{
"from": "gpt",
"value": "In a Q3Table, the vertical header i... |
The majority of resources that I have for UI design all deal with the web world. There are a number of advantages there because of the dynamic nature of the presentation layer.
However, I would like to design better windows form programs. I want a professional flow to my applications. Right now they look pretty by usi... | Improving the usability and flow of Windows Forms applications requires a different approach compared to web design, but there are still plenty of resources and principles you can apply to create professional and user-friendly interfaces. Here are some recommended strategies and resources:
### General Usability Princi... | 17,709 | [
{
"from": "human",
"value": "The majority of resources that I have for UI design all deal with the web world. There are a number of advantages there because of the dynamic nature of the presentation layer. \nHowever, I would like to design better windows form programs. I want a professional flow to my appli... |
I have a combo box on a WinForms app in which an item may be selected, but it is not mandatory. I therefore need an 'Empty' first item to indicate that no value has been set.
The combo box is bound to a DataTable being returned from a stored procedure (I offer no apologies for Hungarian notation on my UI controls :p ):... | To add an empty item to your combo box in a WinForms application, you can indeed make use of the `DataTable.NewRow()` method to create a new, empty row. Here’s a step-by-step approach to implement this, without modifying the stored procedure.
### Steps to Add an Empty Item
1. **Create an Empty Row**: Use the `NewRow`... | 20,535 | [
{
"from": "human",
"value": "I have a combo box on a WinForms app in which an item may be selected, but it is not mandatory. I therefore need an 'Empty' first item to indicate that no value has been set.\nThe combo box is bound to a DataTable being returned from a stored procedure (I offer no apologies for ... |
I'm building a webapp that contains an IFrame in design mode so my user's can "tart" their content up and paste in content to be displayed on their page. Like the WYSIWYG editor on most blog engines or forums.
I'm trying to think of all potential security holes I need to plug, one of which is a user pasting in Javascr... | You're right to be concerned about security when allowing users to input content that can be rendered in an iframe or a WYSIWYG editor. Allowing raw HTML and JavaScript input can lead to Cross-Site Scripting (XSS) attacks, which can compromise the security of your application and its users. Here are some key considerat... | 20,276 | [
{
"from": "human",
"value": "I'm building a webapp that contains an IFrame in design mode so my user's can \"tart\" their content up and paste in content to be displayed on their page. Like the WYSIWYG editor on most blog engines or forums.\nI'm trying to think of all potential security holes I need to plu... |
I want to sort members by name in the source code. Is there any easy way to do it?
I'm using NetBeans, but if there is another editor that can do that, just tell me the name of it.
| If you're looking to sort members (like class fields, methods, etc.) by name in your source code, there are a few approaches you can take depending on your needs and the editor you're using.
### In NetBeans:
1. **Manual Sorting**: Unfortunately, NetBeans doesn't have a built-in feature to automatically sort class memb... | 22,215 | [
{
"from": "human",
"value": "I want to sort members by name in the source code. Is there any easy way to do it? \nI'm using NetBeans, but if there is another editor that can do that, just tell me the name of it.\n"
},
{
"from": "gpt",
"value": "If you're looking to sort members (like class field... |
I know the name of the table I want to find. I'm using Microsoft SQL Server Management Studio 2005, and I want to search all databases in the database server that I'm attached to in the studio. Is this possible? Do I need to query the system tables?
| Yes, you can search for a table across all databases in SQL Server, but you will need to query the system tables or system views to do so. While SQL Server Management Studio (SSMS) doesn't provide a built-in feature to search all databases directly, you can write a query to check each database for the existence of a sp... | 21,384 | [
{
"from": "human",
"value": "I know the name of the table I want to find. I'm using Microsoft SQL Server Management Studio 2005, and I want to search all databases in the database server that I'm attached to in the studio. Is this possible? Do I need to query the system tables?\n"
},
{
"from": "g... |
What are the steps needed to successfully be able to remotely debug a stored procedure (SQL Server 2005) from within VS 2005?
Both client and server machines are on the same domain. I have never done this so step by step instructions would greatly be appreciated.
| Debugging a stored procedure in SQL Server 2005 using Visual Studio 2005 can be a straightforward process if you follow the steps carefully. Below is a step-by-step guide to set up and perform remote debugging.
### Prerequisites
1. **SQL Server 2005**: Ensure SQL Server 2005 is installed and running on the server mach... | 18,254 | [
{
"from": "human",
"value": "What are the steps needed to successfully be able to remotely debug a stored procedure (SQL Server 2005) from within VS 2005? \nBoth client and server machines are on the same domain. I have never done this so step by step instructions would greatly be appreciated.\n"
},
{
... |
I was just wondering, if by moving complex if else statements and the resulting html markup to the code behind violates some 'MVC' law?
It seems like a great option when faced with inline if else statements that can become extremely unreadable.
| Moving complex `if-else` statements and the resulting HTML markup to the code-behind file can indeed be a way to improve the readability of your view, but whether it violates MVC principles depends on how you implement it.
### Understanding MVC Principles
MVC (Model-View-Controller) is a design pattern that separates... | 21,550 | [
{
"from": "human",
"value": "I was just wondering, if by moving complex if else statements and the resulting html markup to the code behind violates some 'MVC' law?\nIt seems like a great option when faced with inline if else statements that can become extremely unreadable.\n"
},
{
"from": "gpt",
... |
I'm using Webbrowser control to login to HTTPS site with "untrusted certificate".
but I get popup such standart window "Security Alert" about untrusted certificate:
I have to find this window by title and send it Alt+Y to press Yes:
int iHandle = NativeWin32.FindWindow(null, "Security Alert");
NativeWin32.SetForegroun... | When using the `WebBrowser` control in .NET, handling untrusted certificates directly is not supported as the control is designed to provide a simplified way of hosting web pages without compromising security. However, there are some approaches you can take to handle or work around the untrusted certificate prompt. Her... | 17,921 | [
{
"from": "human",
"value": "I'm using Webbrowser control to login to HTTPS site with \"untrusted certificate\".\nbut I get popup such standart window \"Security Alert\" about untrusted certificate:\n\nI have to find this window by title and send it Alt+Y to press Yes:\nint iHandle = NativeWin32.FindWindow(... |
I'm writing a WinForms application and one of the tabs in my TabControl has a SplitContainer. I'm saving the SplitterDistance in the user's application settings, but the restore is inconsistent. If the tab page with the splitter is visible, then the restore works and the splitter distance is as I left it. If some other... | It sounds like the issue you are experiencing with the `SplitterDistance` in your `SplitContainer` is related to the timing of when you're restoring the distance. When a tab that contains the `SplitContainer` is not visible, the control may not have been fully laid out yet, and as a result, the `SplitterDistance` may n... | 22,423 | [
{
"from": "human",
"value": "I'm writing a WinForms application and one of the tabs in my TabControl has a SplitContainer. I'm saving the SplitterDistance in the user's application settings, but the restore is inconsistent. If the tab page with the splitter is visible, then the restore works and the splitte... |
Is it possible to copy a single file to multiple directories using the cp command ?
I tried the following , which did not work:
cp file1 /foo/ /bar/
cp file1 {/foo/,/bar}
I know it's possible using a for loop, or find. But is it possible using the gnu cp command?
| The `cp` command does not have built-in functionality to copy a single file to multiple directories in one command directly using the syntax you've tried. However, you can achieve the desired effect by utilizing the shell's brace expansion or by using a simple loop in the command line.
Here's how you can use brace exp... | 20,340 | [
{
"from": "human",
"value": "Is it possible to copy a single file to multiple directories using the cp command ?\nI tried the following , which did not work: \ncp file1 /foo/ /bar/\ncp file1 {/foo/,/bar}\n\nI know it's possible using a for loop, or find. But is it possible using the gnu cp command?\n"
},... |
Let's say I have this model named Product with a field named brand. Suppose the values of brand are stored in the format this_is_a_brand. Can I define a method in the model (or anywhere else) that allows me to modify the value of brand before it is called. For example, if I call @product.brand, I want to get This is a ... | Yes, you can definitely define a method in your `Product` model that formats the `brand` value before it's accessed. This can be done by creating a custom method that transforms the `brand` string from the format `this_is_a_brand` to `This is a Brand`.
Here is a simple implementation of how you could do this in a Ruby... | 20,026 | [
{
"from": "human",
"value": "Let's say I have this model named Product with a field named brand. Suppose the values of brand are stored in the format this_is_a_brand. Can I define a method in the model (or anywhere else) that allows me to modify the value of brand before it is called. For example, if I call... |
I want to create a script that parses or makes sense of apache's error log to see what the most recent error was. I was wondering if anyone out there has something that does this or has any ideas where to start?
| Certainly! You can create a simple script in Python to parse Apache's error log and find the most recent error. Below is a basic example of how you might implement this. The script reads the error log file, parses the log entries, and finds the most recent error message.
### Step 1: Set up the Apache Error Log
Ensure... | 17,907 | [
{
"from": "human",
"value": "I want to create a script that parses or makes sense of apache's error log to see what the most recent error was. I was wondering if anyone out there has something that does this or has any ideas where to start?\n"
},
{
"from": "gpt",
"value": "Certainly! You can cre... |
I've seen a couple questions around here like How to debug RESTful services, which mentions:
Unfortunately that same browser won't allow me to test HTTP PUT, DELETE, and to a certain degree even HTTP POST.
I've also heard that browsers support only GET and POST, from some other sources like:
http://www.packetizer.co... | You're correct that modern browsers, including Firefox, allow sending HTTP methods like PUT and DELETE via AJAX requests (e.g., `XMLHttpRequest` or the Fetch API). However, there are some caveats and nuances to consider when discussing the use of HTTP methods beyond GET and POST in the context of web browsers.
1. **XM... | 21,983 | [
{
"from": "human",
"value": "I've seen a couple questions around here like How to debug RESTful services, which mentions:\n\nUnfortunately that same browser won't allow me to test HTTP PUT, DELETE, and to a certain degree even HTTP POST.\n\nI've also heard that browsers support only GET and POST, from some ... |
The "instruments" that are used with Guitar Hero and Rock Band have USB connections. Is there any documentation or reverse-engineering info out there about how to read the messages they generate?
| Yes, there is a community of enthusiasts who have reverse-engineered the USB protocols used by the instruments in Guitar Hero and Rock Band. Many have shared their findings online, which includes documentation and tools for reading the messages these instruments generate.
### Resources to Consider:
1. **GitHub Reposi... | 22,181 | [
{
"from": "human",
"value": "The \"instruments\" that are used with Guitar Hero and Rock Band have USB connections. Is there any documentation or reverse-engineering info out there about how to read the messages they generate?\n"
},
{
"from": "gpt",
"value": "Yes, there is a community of enthus... |
I'm currently working on a simple CRUD application. One requirement is preventing users from editing things concurrently. In order to do this I "lock" records to see if they're being edited, to prevent other users from editing at the same time. I was thinking a good way of implementing this might be to use an AJAX keep... | Using an AJAX keep-alive mechanism to manage record locking in a CRUD application is a viable approach, but it has some important considerations and potential pitfalls you should be aware of.
### Key Points to Consider:
1. **Session Management**:
- If a user's session expires while they are editing a record, unloc... | 20,495 | [
{
"from": "human",
"value": "I'm currently working on a simple CRUD application. One requirement is preventing users from editing things concurrently. In order to do this I \"lock\" records to see if they're being edited, to prevent other users from editing at the same time. I was thinking a good way of imp... |
I have been asking myself this question for a long time now. Thought of posting it. C# doesn't support Multiple Inheritance(this is the fact). All classes created in C# derive out of 'Object' class(again a fact).
So if C# does not support Multiple inheritance, then how are we able to extend a class even though it alrea... | To clarify your confusion about inheritance in C#, let's break down the concepts you're asking about.
1. **Single Inheritance**: C# supports single inheritance for classes, which means a class can only directly inherit from one base class. This is in contrast to multiple inheritance, where a class can inherit from mul... | 21,759 | [
{
"from": "human",
"value": "I have been asking myself this question for a long time now. Thought of posting it. C# doesn't support Multiple Inheritance(this is the fact). All classes created in C# derive out of 'Object' class(again a fact).\nSo if C# does not support Multiple inheritance, then how are we a... |
We have an Apache ANT script to build our application, then check in the resulting JAR file into version control (VSS in this case). However, now we have a change that requires us to build 2 JAR files for this project, then check both into VSS.
The current target that checks the original JAR file into VSS discovers th... | In Apache ANT, while there aren't direct function parameters like in typical programming languages, you can achieve similar functionality using properties and targets. You can define a target to handle the JAR file check-in that takes the file name as a property. Here's a step-by-step guide to help you generalize your ... | 16,595 | [
{
"from": "human",
"value": "We have an Apache ANT script to build our application, then check in the resulting JAR file into version control (VSS in this case). However, now we have a change that requires us to build 2 JAR files for this project, then check both into VSS.\nThe current target that checks t... |
For some reason beyond me I can't access the mysql server on a machine. I'm looking at an untouched MT (dv) server with CentOS 5. Any ideas on how to get the root going?
| If you're unable to access the MySQL server on a CentOS 5 machine, there are several troubleshooting steps you can follow to gain access as the root user. Here’s a general approach you can take:
### 1. Check MySQL Service Status
First, ensure that the MySQL service is running. You can check the service status with the... | 18,185 | [
{
"from": "human",
"value": "For some reason beyond me I can't access the mysql server on a machine. I'm looking at an untouched MT (dv) server with CentOS 5. Any ideas on how to get the root going?\n"
},
{
"from": "gpt",
"value": "If you're unable to access the MySQL server on a CentOS 5 machin... |
In trying to solve the "ajax back button" problem I have found the Really Simply History library.
Has anyone tried to integrate it with Rails?
It's plain old javascript so it seems like it should integrate just fine, but I know next to nothing about JS itself, so I'm not too confident in trying to do the integration w... | Integrating the Really Simple History library with a Ruby on Rails application is definitely feasible, even if you're not very experienced with JavaScript. The library is designed to help manage browser history in single-page applications (SPAs), which is particularly useful when you're dealing with AJAX requests.
Her... | 19,633 | [
{
"from": "human",
"value": "In trying to solve the \"ajax back button\" problem I have found the Really Simply History library.\nHas anyone tried to integrate it with Rails? \nIt's plain old javascript so it seems like it should integrate just fine, but I know next to nothing about JS itself, so I'm not to... |
I am seeking a backup tool to back-up virtual OS instances run through Microsoft Virtual Server 2005 R2. According to the MS docs, it should be possible to do it live through volume shadow copy service, but I am having trouble finding any tool for any.
What are the best solution to back-up MS Virtual Server instances?
| Backing up virtual machines in Microsoft Virtual Server 2005 R2 can indeed be accomplished using the Volume Shadow Copy Service (VSS) for live backups. However, given that this is an older technology, finding modern tools that still support it can be challenging. Here are some potential solutions and approaches you can... | 20,069 | [
{
"from": "human",
"value": "I am seeking a backup tool to back-up virtual OS instances run through Microsoft Virtual Server 2005 R2. According to the MS docs, it should be possible to do it live through volume shadow copy service, but I am having trouble finding any tool for any.\nWhat are the best solutio... |
How do you automatically start a service after running an install from a Visual Studio Setup Project?
I just figured this one out and thought I would share the answer for the general good. Answer to follow. I am open to other and better ways of doing this.
| That's great that you've found a solution! Automatically starting a service after installation can indeed be useful. Here’s a method that is commonly used to achieve this in a Visual Studio Setup Project.
### Steps to Automatically Start a Service After Installation:
1. **Create a Custom Action**:
You can create ... | 20,734 | [
{
"from": "human",
"value": "How do you automatically start a service after running an install from a Visual Studio Setup Project?\nI just figured this one out and thought I would share the answer for the general good. Answer to follow. I am open to other and better ways of doing this.\n"
},
{
"fr... |
Is it even possible?
Basically, there's a remote repository from which I pull using just:
git pull
Now, I'd like to preview what this pull would change (a diff) without touching anything on my side. The reason is that thing I'm pulling might not be "good" and I want someone else to fix it before making my repository "... | Yes, it is indeed possible to preview what changes would be applied by a `git pull` without actually performing the pull. You can achieve this using the `git fetch` command followed by a `git diff`. Here's how to do it step-by-step:
1. **Fetch the latest changes from the remote repository** without merging them into y... | 24,909 | [
{
"from": "human",
"value": "Is it even possible?\nBasically, there's a remote repository from which I pull using just:\ngit pull\n\nNow, I'd like to preview what this pull would change (a diff) without touching anything on my side. The reason is that thing I'm pulling might not be \"good\" and I want someo... |
I've got a bunch of servers running this Linux app. I'd like for them to be able to generate a GUID with a low probability of collision. I'm sure I could just pull 128 bytes out of /dev/urandom and that would probably be fine, but is there a simple & easy way to generate a GUID that is more equivalent to the Win32 on... | To generate a GUID (or UUID) in Linux that resembles the Win32 CreateGuid() functionality—specifically one that takes into account time, MAC address, and randomness—you can use the `uuid` library, which is available on most Linux distributions.
### Using the `uuid` Command-Line Tool
You can use the `uuidgen` command ... | 17,918 | [
{
"from": "human",
"value": "I've got a bunch of servers running this Linux app. I'd like for them to be able to generate a GUID with a low probability of collision. I'm sure I could just pull 128 bytes out of /dev/urandom and that would probably be fine, but is there a simple & easy way to generate a GUI... |
I'm using C# and I get an out System.OutOfMemoryException error after I read in 50,000 records, what is best practice for handling such large datasets? Will paging help?
| Handling large datasets in C# can be challenging, particularly when you encounter `System.OutOfMemoryException`. Here are some best practices and strategies you can use to manage large datasets effectively:
### 1. **Use Paging**:
Paging can help limit the number of records you load into memory at one time. Instead of ... | 17,653 | [
{
"from": "human",
"value": "I'm using C# and I get an out System.OutOfMemoryException error after I read in 50,000 records, what is best practice for handling such large datasets? Will paging help?\n"
},
{
"from": "gpt",
"value": "Handling large datasets in C# can be challenging, particularly w... |
what is the best way to put a container class or a some other class inside a class as private or a public member?
Requirements:
1.Vector< someclass> inside my class
2.Add and count of vector is needed interface
| To create a class that contains a `std::vector<SomeClass>` as a member, while also providing public interfaces to add elements to the vector and count the number of elements, you can follow the example below. This example includes both a public interface for adding and counting elements, as well as keeping the `std::ve... | 19,515 | [
{
"from": "human",
"value": "what is the best way to put a container class or a some other class inside a class as private or a public member?\nRequirements:\n1.Vector< someclass> inside my class\n2.Add and count of vector is needed interface\n"
},
{
"from": "gpt",
"value": "To create a class th... |
I'm not looking for java-web-start, I'm looking for a thick-client application installation toolkit. I've got a stand-alone application that consists of several files (jar files, data files, etc) and would need to do some pretty standard installation tasks, like asking the user for target directories, have them locate... | There are several installation tools you can use for creating installers for thick-client Java applications that are cross-platform. Here are some popular options:
1. **Install4j**: A powerful installer builder for Java applications. It supports cross-platform installations and provides a graphical interface for creat... | 21,483 | [
{
"from": "human",
"value": "I'm not looking for java-web-start, I'm looking for a thick-client application installation toolkit. I've got a stand-alone application that consists of several files (jar files, data files, etc) and would need to do some pretty standard installation tasks, like asking the user... |
I have a SEAM app with some JPA/Hibernate entities. And I now wonder where to put my query, persistence methods.
The default choice seems to put them in a session bean layer with injected
@PersistenceContext(...) @Inject EntityManager entityManager;
But I think I would rather have the methods on the entities themselv... | When designing your application with JPA/Hibernate, the choice of where to place your query and persistence methods can greatly impact your application's architecture and maintainability. Here's a comparison of the two approaches: using a session bean layer vs. putting methods directly on the entities.
### Approach 1:... | 16,447 | [
{
"from": "human",
"value": "I have a SEAM app with some JPA/Hibernate entities. And I now wonder where to put my query, persistence methods.\nThe default choice seems to put them in a session bean layer with injected \n@PersistenceContext(...) @Inject EntityManager entityManager;\n\nBut I think I would rat... |
I have minified my javascript and my css.
Now, Which is better?
<script type="text/javascript">
<?
$r = file_get_contents('min.js');
if($r) echo $r;
?>
</script>
OR
<script type="text/javascript" src="min.js"></script>
Same question for CSS.
If the answer is 'sometimes because browsers fetch files simultaneously?... | Both methods have their pros and cons, and the choice between them depends on various factors including performance, maintainability, and specific use cases. Let's break down the two approaches for both JavaScript and CSS.
### JavaScript
1. **Inline with PHP:**
```php
<script type="text/javascript">
<?php
... | 17,453 | [
{
"from": "human",
"value": "I have minified my javascript and my css.\nNow, Which is better?\n<script type=\"text/javascript\">\n<?\n $r = file_get_contents('min.js');\n if($r) echo $r;\n?>\n</script>\n\nOR\n<script type=\"text/javascript\" src=\"min.js\"></script>\n\nSame question for CSS.\nIf the answe... |
I am trying to recreate a Perl script in C# but have a problem creating a checksum value that a target system needs.
In Perl this checksum is calculated using the unpack function:
while (<PACKAGE>) {
$checksum += unpack("%32C*", $_);
}
$checksum %= 32767;
close(PACKAGE);
where PACKAGE is the .tar file input stream... | To replicate the behavior of the Perl `unpack` function in your C# code, you need to read the data from the `.tar` file and compute the checksum as shown in your Perl snippet.
The Perl code you've provided is essentially reading the contents of a file line by line and using the unpack function with the `%32C*` templat... | 21,407 | [
{
"from": "human",
"value": "I am trying to recreate a Perl script in C# but have a problem creating a checksum value that a target system needs.\nIn Perl this checksum is calculated using the unpack function:\nwhile (<PACKAGE>) {\n $checksum += unpack(\"%32C*\", $_);\n}\n$checksum %= 32767;\nclose(PACKA... |
I understand that an id must be unique within an HTML/XHTML page.
For a given element, can I assign multiple ids to it?
<div id="nested_element_123 task_123"></div>
I realize I have an easy solution with simply using a class. I'm just curious about using ids in this manner.
| In HTML/XHTML, the `id` attribute must be unique within a page, meaning that no two elements can have the same `id` value. An `id` is designed to serve as a unique identifier for an element, allowing for precise targeting via CSS or JavaScript.
When you write something like this:
```html
<div id="nested_element_123 t... | 23,700 | [
{
"from": "human",
"value": "I understand that an id must be unique within an HTML/XHTML page.\nFor a given element, can I assign multiple ids to it?\n<div id=\"nested_element_123 task_123\"></div>\n\nI realize I have an easy solution with simply using a class. I'm just curious about using ids in this manne... |
For some reason after I installed Boot Camp, my os x terminal started to point to the Boot Camp drive instead of my os x home directory by default! Once in the terminal I know how to switch back an forth and am able to do that, but I was wondering how to make my terminal default back to my os x home folder?
I've checke... | It sounds like your Terminal application is set to start in the Boot Camp drive by default instead of your macOS home directory. You can change this behavior by following these steps:
1. **Open Terminal Preferences**:
- Launch the Terminal app.
- In the menu bar, click on `Terminal`, and then select `Preferences... | 25,061 | [
{
"from": "human",
"value": "For some reason after I installed Boot Camp, my os x terminal started to point to the Boot Camp drive instead of my os x home directory by default! Once in the terminal I know how to switch back an forth and am able to do that, but I was wondering how to make my terminal default... |
I was wondering as to the practicalities of storing an in memory tree structure as directory tree for persistence purposes. In my case he target filesystem will be ZFS, and once the structure has been created it will be accessed by multiple processes infrequently.
How performant is using a Directory Tree as a mechanism... | Storing an in-memory tree structure as a directory tree in a filesystem like ZFS for persistence has both advantages and challenges. Here are some factors to consider regarding performance, usability, and best practices:
### Advantages:
1. **Simplicity**: Using a directory tree can simplify the serialization and deser... | 18,944 | [
{
"from": "human",
"value": "I was wondering as to the practicalities of storing an in memory tree structure as directory tree for persistence purposes. In my case he target filesystem will be ZFS, and once the structure has been created it will be accessed by multiple processes infrequently.\nHow performan... |
I have 2 tables. Table1 has fields A, B, C, D and Table2 has fields A, B. Field A and B of both tables have same record type. I would like to grab the records from both tables of fields A and B as single result.
Is there any Query or Function in PHP+MySql?
Thanks...
| Yes, you can achieve this by using a SQL query that combines the records from both tables. Since you're interested in fields A and B from both tables, you can use a `UNION` to combine the results from both tables. Here's how you can do it:
### SQL Query
You can use the following SQL query to retrieve fields A and B f... | 21,149 | [
{
"from": "human",
"value": "I have 2 tables. Table1 has fields A, B, C, D and Table2 has fields A, B. Field A and B of both tables have same record type. I would like to grab the records from both tables of fields A and B as single result.\nIs there any Query or Function in PHP+MySql?\nThanks...\n"
},
... |
I'd like to create a subset of Users that don't have a login... basically as a way to add a photographer field to photos without having a full blown account associated with that person (since in many cases, they'll never actually log in to the site). A caveat is that I'd also like to be able to enable an account for th... | To achieve your goal of creating a "People" table that can associate with the existing User table while allowing for users without login credentials, you can design your database schema in the following way:
### Database Schema Design
1. **User Table**: This table will store all registered users who have a login. It ... | 15,365 | [
{
"from": "human",
"value": "I'd like to create a subset of Users that don't have a login... basically as a way to add a photographer field to photos without having a full blown account associated with that person (since in many cases, they'll never actually log in to the site). A caveat is that I'd also li... |
Using something like this:
try:
# Something...
except Exception as excep:
logger = logging.getLogger("component")
logger.warning("something raised an exception: " + excep)
logger.info("something raised an exception: " + excep)
I would rather not have it on the error-level cause in my special case it is not... | In your code, you’re catching an exception and logging it at the warning level. If you want to log it differently since it’s not necessarily an error, you can use a different logging level or adjust your messages to clarify the context.
Here’s a suggestion where you might use the `info` level for logging the exceptio... | 23,782 | [
{
"from": "human",
"value": "Using something like this:\ntry:\n # Something...\nexcept Exception as excep:\n logger = logging.getLogger(\"component\")\n logger.warning(\"something raised an exception: \" + excep)\n logger.info(\"something raised an exception: \" + excep)\n\nI would rather not have i... |
In my database, Concessions have a many-to-one relationship with Firms (each Concession has a FirmID). SqlMetal has captured this relationship and generated the appropriate classes, so that each Concession has a Firm element. I'm binding against a query (simplified here) that returns a list of Concessions along with in... | Yes, there is a more elegant way to handle this situation in LINQ while maintaining the object-oriented principles and leveraging the relationships that LINQ to SQL has captured. You can use the `Let` clause to project the results while also checking for null values. Here's how you can do it:
```vb
From c As Concessio... | 25,390 | [
{
"from": "human",
"value": "In my database, Concessions have a many-to-one relationship with Firms (each Concession has a FirmID). SqlMetal has captured this relationship and generated the appropriate classes, so that each Concession has a Firm element. I'm binding against a query (simplified here) that re... |
I frequently run into problems of this form and haven't found a good solution yet:
Assume we have two database tables representing an e-commerce system.
userData (userId, name, ...)
orderData (orderId, userId, orderType, createDate, ...)
For all users in the system, select their user information, their most recent ord... | To achieve the desired result of selecting user information along with their most recent orders of types '1' and '2' in a single query, you can use Common Table Expressions (CTEs) or subqueries along with `LEFT JOIN`. Below is an example SQL query that implements this approach:
```sql
WITH RecentOrders AS (
SELECT... | 20,453 | [
{
"from": "human",
"value": "I frequently run into problems of this form and haven't found a good solution yet:\nAssume we have two database tables representing an e-commerce system.\nuserData (userId, name, ...)\norderData (orderId, userId, orderType, createDate, ...)\n\nFor all users in the system, select... |
I thought the web page designer screen in 2005 was mediocre until I used the one in 2008 which I think is bad. There is an interesting white paper here:
http://www.west-wind.com/weblog/posts/484172.aspx
I've gotten very used to these WYSIWYG designers over the years, but I am looking now for a new way.
I make busin... | Many developers prefer to avoid WYSIWYG designers for various reasons, including lack of control, code bloat, and difficulty in managing complex layouts. Here are several alternatives to using the Visual Studio designer that can help you create clean and efficient data entry forms for your business web applications:
#... | 18,703 | [
{
"from": "human",
"value": "I thought the web page designer screen in 2005 was mediocre until I used the one in 2008 which I think is bad. There is an interesting white paper here:\nhttp://www.west-wind.com/weblog/posts/484172.aspx\nI've gotten very used to these WYSIWYG designers over the years, but I a... |
I have a chart in a Worksheet in Excel and I have a macro set up so that when I change the value in a certain cell the range of data in the chart is set to A2 down as far as the row number corresponding in this certain cell.
What I can't seem to be able to do is to modify the axis as the specified axis no longer covers... | You can modify the axis limits of a chart in Excel using VBA. Below is an example of how you can accomplish this by updating the X-axis based on the specified range.
Assuming that you have a chart on `Sheet1`, and you want to update the X-axis based on the data range starting from `C2` down to the specified last row ... | 21,209 | [
{
"from": "human",
"value": "I have a chart in a Worksheet in Excel and I have a macro set up so that when I change the value in a certain cell the range of data in the chart is set to A2 down as far as the row number corresponding in this certain cell.\nWhat I can't seem to be able to do is to modify the a... |
I'm looking for some good references for learning how to model 2d physics in games. I am not looking for a library to do it for me - I want to think and learn, not blindly use someone else's work.
I've done a good bit of Googling, and while I've found a few tutorials on GameDev, etc., I find their tutorials hard to und... | It's great to hear that you're interested in learning how to model 2D physics for games! Below are some references across different mediums that can help you grasp the concepts involved and apply them in your game development process.
### Books
1. **"Physics for Game Developers" by David M. Bourg** - This book cover... | 20,144 | [
{
"from": "human",
"value": "I'm looking for some good references for learning how to model 2d physics in games. I am not looking for a library to do it for me - I want to think and learn, not blindly use someone else's work.\nI've done a good bit of Googling, and while I've found a few tutorials on GameDev... |
I want to generate some formatted output of data retrieved from an MS-Access database and stored in a DataTable object/variable, myDataTable. However, some of the fields in myDataTable cotain dbNull data. So, the following VB.net code snippet will give errors if the value of any of the fields lastname, intials, or sID ... | To handle potential `DBNull` values in your DataTable without checking each field for `DBNull` explicitly, you can create a helper function that safely retrieves the values and returns a default value (like an empty string) if the data is `DBNull`. Here's how you can implement this in VB.NET:
```vb.net
Dim myDataTable... | 21,692 | [
{
"from": "human",
"value": "I want to generate some formatted output of data retrieved from an MS-Access database and stored in a DataTable object/variable, myDataTable. However, some of the fields in myDataTable cotain dbNull data. So, the following VB.net code snippet will give errors if the value of any... |
I see lots of job ads for C#/.NET programmers, so I thought it could be a good idea to have had a look at it.
After looking at a few tutorials I found nothing really new to me. Just a language with a syntax somewhere between Java and C++ (arguably nicer than both though).
So, what features in particular should I look a... | C# and the .NET ecosystem have indeed gained immense popularity, and there are several unique features, libraries, and tools that set them apart from other programming languages. Here's a breakdown of some special features, reasons for their widespread adoption, and potential gotchas in C#/.NET development.
### Specia... | 16,694 | [
{
"from": "human",
"value": "I see lots of job ads for C#/.NET programmers, so I thought it could be a good idea to have had a look at it.\nAfter looking at a few tutorials I found nothing really new to me. Just a language with a syntax somewhere between Java and C++ (arguably nicer than both though).\nSo, ... |
Every time I make a project I develop several generic routines/modules/libraries that I expect I'll be using with other projects.
Due to the speed of development I don't spend a lot of time making these modules perfect - just good enough for this project, and well enough documented and isolatable that I can easily add ... | Managing the development and maintenance of shared modules or libraries in a way that balances flexibility, stability, and team collaboration can be challenging. Here are some strategies and best practices that you can consider to handle these issues:
### 1. Version Control
**Use Semantic Versioning:** Adopt semantic... | 18,429 | [
{
"from": "human",
"value": "Every time I make a project I develop several generic routines/modules/libraries that I expect I'll be using with other projects.\nDue to the speed of development I don't spend a lot of time making these modules perfect - just good enough for this project, and well enough docume... |
How can I make a major upgrade to an installation set (MSI) built with WiX install into the same folder as the original installation?
The installation is correctly detected as an upgrade, but the directory selection screen is still shown and with the default value (not necessarily the current installation folder).
Do I... | To ensure that your major upgrade installation using WiX installs into the same folder as the original installation, you can utilize the built-in functionality of the Windows Installer to retrieve the installation directory from the previous version during the upgrade process. You do not need to manually store the inst... | 13,515 | [
{
"from": "human",
"value": "How can I make a major upgrade to an installation set (MSI) built with WiX install into the same folder as the original installation?\nThe installation is correctly detected as an upgrade, but the directory selection screen is still shown and with the default value (not necessar... |
I need to select from a table and filter on dates greater than a
specified date.
The problem I'm having is that the dates are stored as nchar(20) and I
can't seem to get it converted to date in the where clause.
SELECT CONVERT(DATETIME,log_time,20) from dbo.logs
where CONVERT(DATETIME,log_time,20) > '10/20/2008'
... | The error you're encountering suggests that some of the entries in the `log_time` column cannot be converted to a `DATETIME` format. This often happens when the data in the column is not in a consistent or valid date format.
To resolve this issue, you can take a few different approaches:
1. **Filtering out invalid da... | 24,597 | [
{
"from": "human",
"value": "I need to select from a table and filter on dates greater than a \nspecified date. \nThe problem I'm having is that the dates are stored as nchar(20) and I \ncan't seem to get it converted to date in the where clause. \nSELECT CONVERT(DATETIME,log_time,20) from dbo.logs \nwhere ... |
I just did a delete from table
How do I roll back or undelete the rows??
| If you executed a `DELETE` statement in a SQL database, whether or not you can roll back or "undelete" the rows depends on several factors, including:
1. **Transaction Control**: If you performed the `DELETE` statement within a transaction and have not yet committed the transaction, you can roll it back.
- Example ... | 21,499 | [
{
"from": "human",
"value": "I just did a delete from table\nHow do I roll back or undelete the rows??\n"
},
{
"from": "gpt",
"value": "If you executed a `DELETE` statement in a SQL database, whether or not you can roll back or \"undelete\" the rows depends on several factors, including:\n\n1.... |
Is it possible to somehow mark a System.Array as immutable. When put behind a public-get/private-set they can't be added to, since it requires re-allocation and re-assignment, but a consumer can still set any subscript they wish:
public class Immy
{
public string[] { get; private set; }
}
I thought the readonly k... | In C#, the `readonly` keyword prevents a field from being assigned to after the constructor has completed, but it does not make the contents of the object it points to immutable. In the case of an array, the `readonly` keyword ensures that the reference to the array cannot be changed, but the elements within the array ... | 22,882 | [
{
"from": "human",
"value": "Is it possible to somehow mark a System.Array as immutable. When put behind a public-get/private-set they can't be added to, since it requires re-allocation and re-assignment, but a consumer can still set any subscript they wish:\npublic class Immy\n{\n public string[] { get... |
I'm a little confused by some PHP syntax I've come across. Here is an example:
$k = $this->_tbl_key;
if( $this->$k)
{
$ret = $this->_db->updateObject( $this->_tbl, $this, $this->_tbl_key, $updateNulls );
}
else
{
$ret = $this->_db->insertObject( $this->_tbl, $this, $this->_tbl_key );
}
My question is basicall... | In PHP, the syntax `$this->$k` is used to access a class member variable dynamically. Here's how it works in your example:
1. **Understanding `$this`**: The `$this` variable refers to the current object instance. Within a class context, it allows you to access properties and methods of that object.
2. **Dynamic Varia... | 22,259 | [
{
"from": "human",
"value": "I'm a little confused by some PHP syntax I've come across. Here is an example:\n$k = $this->_tbl_key;\n\nif( $this->$k)\n{\n $ret = $this->_db->updateObject( $this->_tbl, $this, $this->_tbl_key, $updateNulls );\n}\nelse\n{\n $ret = $this->_db->insertObject( $this->_tbl, $t... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.