instruction stringlengths 14 27.6k | completion stringlengths 3 38.3k | __original_row_idx int64 0 50k | conversations listlengths 2 2 |
|---|---|---|---|
Imagine you had a group of product categories organized in a nice tree hierarchy and you wanted to provide hackable urls to browse these. You could do something like this
/catalog/categorya/categoryb/categoryc
You could then quite easily figure out which category you should list the products for (note that the full UR... | You're right to consider how to effectively differentiate between categories and products in your URL structure, especially when you want to maintain a user-friendly and hackable format. Let's evaluate your proposed solutions and explore a few more options.
### 1. Suffix Approach
Using a suffix like `.html` or another... | 40,498 | [
{
"from": "human",
"value": "Imagine you had a group of product categories organized in a nice tree hierarchy and you wanted to provide hackable urls to browse these. You could do something like this\n/catalog/categorya/categoryb/categoryc\n\nYou could then quite easily figure out which category you should ... |
I have an abstract class defining a pure virtual method in c++:
class Base
{
Base();
~Base();
virtual bool Test() = 0;
};
I have subclassed this with a number of other classes (which provide an implementation for Test()), which I'll refer to as A, B, C, etc. I now want to create an array of any of these types using t... | To solve the issue you're encountering with storing pointers to instances of derived classes in an array of base class pointers, you need to do a few modifications to your code. The primary issue is that you cannot instantiate an array of an abstract class (`Base` in this case) because it contains pure virtual function... | 45,919 | [
{
"from": "human",
"value": "I have an abstract class defining a pure virtual method in c++:\nclass Base\n{\nBase();\n~Base();\n\nvirtual bool Test() = 0;\n};\n\nI have subclassed this with a number of other classes (which provide an implementation for Test()), which I'll refer to as A, B, C, etc. I now wan... |
I want to read a string value from the registry and concatenate it with another certain string. I'm calling RegQueryValueEx() , like this:
Dim lResult As Long
Dim sLength As Long
Dim sString As String
sString = Space$(256)
sLength = 256
lResult = RegQueryValueEx(hKey, "MyKey", 0, REG_SZ, ByVal sString, sLength)
MsgB... | The issue you're encountering is likely due to the way the string is being handled in memory. The `RegQueryValueEx` function fills the `sString` variable with the registry value, but the `Space$(256)` you initially allocated does not resize the string based on the actual length of the returned value. When concatenating... | 47,886 | [
{
"from": "human",
"value": "I want to read a string value from the registry and concatenate it with another certain string. I'm calling RegQueryValueEx() , like this: \nDim lResult As Long\nDim sLength As Long\nDim sString As String\n\nsString = Space$(256)\nsLength = 256\n\nlResult = RegQueryValueEx(hKey,... |
I love to work on AI optimization software (Genetic Algorithms, Particle Swarm, Ant Colony, ...). Unfortunately I have run out of interesting problems to solve. What problem would you like to have solved?
| It's great to hear about your interest in AI optimization techniques! Here are several interesting problems across various domains that could benefit from your skills in optimization algorithms:
1. **Resource Allocation in Renewable Energy Systems**: Develop an optimization model for the allocation of resources in a h... | 48,597 | [
{
"from": "human",
"value": "I love to work on AI optimization software (Genetic Algorithms, Particle Swarm, Ant Colony, ...). Unfortunately I have run out of interesting problems to solve. What problem would you like to have solved?\n"
},
{
"from": "gpt",
"value": "It's great to hear about your... |
What's the easiest way to figure out if a window is opened modally or not?
CLARIFICATION:
I open a window calling
myWindow.ShowDialog();
I have a footer with an "OK" & "Cancel" button that I only want to show if the window is opened modally. Now I realize I can set a property by doing this:
myWindow.IsModal = true;
m... | In WPF, determining whether a window is opened modally (using `ShowDialog()`) or non-modally (using `Show()`) can be tricky, particularly since the `Window` class does not provide a built-in property to indicate if it was opened modally.
The simplest and most reliable approach to check whether the window is opened mod... | 45,829 | [
{
"from": "human",
"value": "What's the easiest way to figure out if a window is opened modally or not?\nCLARIFICATION:\nI open a window calling \nmyWindow.ShowDialog();\n\nI have a footer with an \"OK\" & \"Cancel\" button that I only want to show if the window is opened modally. Now I realize I can set a ... |
Here's the code I have in the html file to "include" the file "vmenu.php"
<div id="apDivVistaMenus">
<?php
include 'vmenu.php';
?>
<!-- Begin Vista-Buttons.com -->
<!-- End Vista-Buttons.com -->
</div>
The menus used to be between the comments below the php include request. But I save that code into the vm... | The issue you're facing is likely related to the way you're including the `vmenu.php` file and the way your HTML file is structured. While your `vmenu.php` file seems to contain the necessary HTML and JavaScript for your menu, there are a few factors to consider:
1. **File Path**: Double-check that the path to `vmenu.... | 42,097 | [
{
"from": "human",
"value": "Here's the code I have in the html file to \"include\" the file \"vmenu.php\"\n <div id=\"apDivVistaMenus\">\n\n<?php\ninclude 'vmenu.php';\n?>\n\n <!-- Begin Vista-Buttons.com -->\n\n <!-- End Vista-Buttons.com -->\n\n </div>\n\nThe menus used to be between the comments bel... |
I'm trying to get rid of everything before the filename ex:
/home/mike/whatever/test_1.txt
leaving only test_1.txt
what would the simplest way?
thanks
| You can achieve this easily using various command-line tools or programming languages. Here are a few simple methods:
### Using `basename` command in the terminal
If you're using a Unix-like operating system (Linux, macOS), you can use the `basename` command in the terminal:
```bash
basename /home/mike/whatever/test_... | 47,194 | [
{
"from": "human",
"value": "I'm trying to get rid of everything before the filename ex:\n/home/mike/whatever/test_1.txt\n\nleaving only test_1.txt\nwhat would the simplest way?\nthanks\n"
},
{
"from": "gpt",
"value": "You can achieve this easily using various command-line tools or programming l... |
I need to be able to logoff any user from his windows session from a program.
I know I could log in as an admin and force a remote logoff. Is there any other way to force a logoff without logging in?
The tool will run as admin so that's not a problem, being able to remote logoff without logging in is.
Tool is in .NET... | Forcing a logoff of a user from a Windows session without logging in as that user can be a tricky task, and it typically involves administrative privileges. However, you can achieve this through various methods, including using command-line tools or making calls to the Windows API.
Here are a few methods you can cons... | 43,234 | [
{
"from": "human",
"value": "I need to be able to logoff any user from his windows session from a program. \nI know I could log in as an admin and force a remote logoff. Is there any other way to force a logoff without logging in? \nThe tool will run as admin so that's not a problem, being able to remote lo... |
I have a sample file for BASIC page authentication that works perfectly in tomcat but it wont work at all in websphere. Any ideas what needs to be done differently in Websphere?
Thanks
Damien
| When transitioning from Apache Tomcat to IBM WebSphere, there are a few considerations to take into account that could affect the behavior of BASIC authentication. Here are some steps and configurations to check:
### 1. **Check WebSphere Security Configuration**:
- WebSphere has its own security model, and you need... | 44,451 | [
{
"from": "human",
"value": "I have a sample file for BASIC page authentication that works perfectly in tomcat but it wont work at all in websphere. Any ideas what needs to be done differently in Websphere?\nThanks\nDamien\n"
},
{
"from": "gpt",
"value": "When transitioning from Apache Tomcat to... |
Connection Code:
set conx = Server.CreateObject("ADODB.connection")
conx.Open Application("connectionString")
set cmdx = server.CreateObject("ADODB.command")
cmdx.ActiveConnection = conx
cmdx.CommandText = "dbo.sproc"
cmdx.CommandType = &H0004
set rsx = Server.CreateObject("ADODB.Recordset")
rsx.open cmdx
resarray =... | The error message you're encountering, "Operation is not allowed when the object is closed," indicates that the `Recordset` object (`rsx`) is closed when you're trying to access its data. This typically happens when there is a failure in executing the command to open the recordset, often due to issues with the connecti... | 44,873 | [
{
"from": "human",
"value": "Connection Code:\nset conx = Server.CreateObject(\"ADODB.connection\")\nconx.Open Application(\"connectionString\")\n\nset cmdx = server.CreateObject(\"ADODB.command\")\ncmdx.ActiveConnection = conx\ncmdx.CommandText = \"dbo.sproc\"\ncmdx.CommandType = &H0004\n\nset rsx = Server... |
I have a .Net app that will allow the users to attach files to a SQL Server 2005 database. I want to limit the filesize to 10MB, so from what I can tell, I have to declare the datatype varbinary(max), since the max size I can actually specify is 8000 bytes. But the ~2GB filesize varbinary(max) allows seems like overk... | In SQL Server 2005, you are correct that the `varbinary(max)` data type can store large binary data, and it indeed has a maximum size of approximately 2GB. However, SQL Server does not natively support enforcing a maximum size on the `varbinary(max)` columns directly at the database level. Therefore, you will need to i... | 42,278 | [
{
"from": "human",
"value": "I have a .Net app that will allow the users to attach files to a SQL Server 2005 database. I want to limit the filesize to 10MB, so from what I can tell, I have to declare the datatype varbinary(max), since the max size I can actually specify is 8000 bytes. But the ~2GB filesi... |
I'm building a blog using C# and nHibernate for my database persistence. I want to make the entries taggable so I have an IList for the tags property. But how do I map this to a comma separated list in a single column in my database?
I want to avoid using a separate table for the tags and just keep them in one column ... | Yes, it's possible to map a comma-separated list in a single column to an `IList` property in NHibernate, although it's generally not recommended due to potential issues with normalization and query performance. However, if you prefer to keep it simple and avoid using a separate table for the tags, you can achieve this... | 41,829 | [
{
"from": "human",
"value": "I'm building a blog using C# and nHibernate for my database persistence. I want to make the entries taggable so I have an IList for the tags property. But how do I map this to a comma separated list in a single column in my database? \nI want to avoid using a separate table for ... |
How can I create an instance of the Java console inside of a GUI panel?
| Creating a console-like output within a GUI panel in Java can be accomplished using a `JTextArea`, which allows you to display text output similarly to a console. You can then redirect standard output (e.g., `System.out` and `System.err`) to this text area. Here's a step-by-step guide on how to achieve this.
### Step ... | 45,488 | [
{
"from": "human",
"value": "How can I create an instance of the Java console inside of a GUI panel?\n"
},
{
"from": "gpt",
"value": "Creating a console-like output within a GUI panel in Java can be accomplished using a `JTextArea`, which allows you to display text output similarly to a console.... |
I have a .NET 3.5 Web application on VS 2008 SP1 running on Vista Ultimate 32 SP1. I created an Application under the Default Web Site. So the url to the app is "http://localhost/mysite". The application folder is pointing to the solution folder and it is outside the iisroot folder. Anonymous and Integrated Auth (Windo... | It sounds like you're experiencing an issue with debugging your ASP.NET web application in Visual Studio 2008. Given that you can access your application via the browser but encounter problems when trying to debug, here are several troubleshooting steps you can take to resolve the issue:
### 1. Verify the Project Sett... | 42,996 | [
{
"from": "human",
"value": "I have a .NET 3.5 Web application on VS 2008 SP1 running on Vista Ultimate 32 SP1. I created an Application under the Default Web Site. So the url to the app is \"http://localhost/mysite\". The application folder is pointing to the solution folder and it is outside the iisroot f... |
I can't figure out how to achieve the following layout with CSS (probably because I don't actually know CSS).
I have a bunch of divs like this:
<div class="right"> <p>1</p> </div>
<div class="left"> <p>2</p> </div>
<div class="left"> <p>3</p> </div>
<div class="left"> <p>4</p> </div>
<div class="right"> <p>5</p> </d... | To achieve the layout you want with the "right" divs on the right and "left" divs on the left, you can use CSS Flexbox, which provides an easy way to create layouts without worrying too much about floats and clears. Here's a step-by-step guide to achieve the desired layout:
### HTML Structure
Your HTML remains the sam... | 45,434 | [
{
"from": "human",
"value": "I can't figure out how to achieve the following layout with CSS (probably because I don't actually know CSS).\nI have a bunch of divs like this:\n<div class=\"right\"> <p>1</p> </div>\n<div class=\"left\"> <p>2</p> </div>\n<div class=\"left\"> <p>3</p> </div>\n<div class=\"lef... |
Can anyone tell me where the config of cache folder is for phpbb3? I need to use a different folder due to my isp and can't find where i can point the folder to another location.
| In phpBB3, the configuration for the cache folder is specified in the `config.php` file located in the root of your phpBB installation. However, the cache folder is usually set up within the `cache` directory by default.
If you want to change the cache directory to a different location, you can do this by following th... | 46,106 | [
{
"from": "human",
"value": "Can anyone tell me where the config of cache folder is for phpbb3? I need to use a different folder due to my isp and can't find where i can point the folder to another location.\n"
},
{
"from": "gpt",
"value": "In phpBB3, the configuration for the cache folder is sp... |
I know this specific question has been asked before, but I am not getting any results using the bind() event on the jQuery UI Tabs plugin.
I just need the index of the newly selected tab to perform an action when the tab is clicked. bind() allows me to hook into the select event, but my usual method of getting the cur... | It looks like you're trying to use the jQuery UI Tabs plugin to get the index of the newly selected tab, but you're encountering issues with the `bind()` method and the `ui` object being undefined. The confusion may arise from the fact that the jQuery UI Tabs plugin changed its event system over time, and depending on ... | 47,582 | [
{
"from": "human",
"value": "I know this specific question has been asked before, but I am not getting any results using the bind() event on the jQuery UI Tabs plugin. \nI just need the index of the newly selected tab to perform an action when the tab is clicked. bind() allows me to hook into the select eve... |
Is there a way to browse and edit/delete saved form entries in Firefox?
I know I can:
Delete all form data, using the Clear Private Data dialog;
Delete specific entries in a form using shift-delete when the cursor is over them (*).
I want is way to see all saved entries for a specific keyword, edit them, and easily d... | As of my last update in October 2023, Firefox does not have a built-in feature to view, edit, or selectively delete saved form entries in a user-friendly way that allows you to filter by keywords. However, there are a few approaches you can take to manage your saved form entries:
### 1. **Using Firefox's Built-in Opti... | 46,510 | [
{
"from": "human",
"value": "Is there a way to browse and edit/delete saved form entries in Firefox?\nI know I can:\n\nDelete all form data, using the Clear Private Data dialog;\nDelete specific entries in a form using shift-delete when the cursor is over them (*).\n\nI want is way to see all saved entries ... |
I have a SimpleFormController, the doSubmit() is doing nothing but populating a command object(call it bar, a simple POJO, and it have a field, say id). So, the successView is being called.
the successView is "redirect:/foo.html", and the bean def for foo.html is:
I have this bean mapped to a simple jsp, called fo... | In a Spring MVC application, when you perform a redirect to a view (e.g., "redirect:/foo.html"), the redirect is essentially a new request. This means that any model attributes you set in the original request (such as your `bar` object) will not be available in the new request that is triggered by the redirect.
To pas... | 47,413 | [
{
"from": "human",
"value": "I have a SimpleFormController, the doSubmit() is doing nothing but populating a command object(call it bar, a simple POJO, and it have a field, say id). So, the successView is being called.\nthe successView is \"redirect:/foo.html\", and the bean def for foo.html is:\n \nI ha... |
I am a bit rusty on my Haskell and am looking to ramp back up. One thing I enjoy from F# is the F# Interactive shell integrated with Visual Studio: I can evaluate virtually anything (including function and class definitions) and use F# as a shell. Is there an equivalent in Haskell? When I use ghci, I cannot evaluate fu... | In Haskell, `ghci` (the GHC Interactive) is indeed the most commonly used interactive shell, and it allows you to load modules and evaluate expressions. However, you're correct that there are certain nuances with defining and evaluating functions in `ghci` compared to F#.
### Evaluating Function Definitions in GHCi
... | 44,536 | [
{
"from": "human",
"value": "I am a bit rusty on my Haskell and am looking to ramp back up. One thing I enjoy from F# is the F# Interactive shell integrated with Visual Studio: I can evaluate virtually anything (including function and class definitions) and use F# as a shell. Is there an equivalent in Haske... |
In the application I'm writing using a combination of development environments and languages, I have need of accessing a cookie from two different subdomains, each on a separate host.
The cookie is being set on www.mydomain.com using the PHP code that follows, and I'm attempting to access it from distant.mydomain.com o... | The issue you're facing likely stems from the fact that cookies are generally restricted to a single domain and cannot be shared between separate hosts, even if they are under the same parent domain. Cookies are scoped by both domain and path, which means that while you can set a cookie for `.mydomain.com` (allowing su... | 47,385 | [
{
"from": "human",
"value": "In the application I'm writing using a combination of development environments and languages, I have need of accessing a cookie from two different subdomains, each on a separate host.\nThe cookie is being set on www.mydomain.com using the PHP code that follows, and I'm attemptin... |
When adding a bookmark or favorite the browser uses the TITLE tag of the page to automatically populate the title of the bookmark. However, my web pages use SEO-friendly titles which are not really user-friendly. Is there a method to override the title when the browser makes a bookmark?
I am aware that I can create a l... | Unfortunately, when a user adds a bookmark using their browser's built-in functionality (like the bookmarks menu or a hotkey), you do not have the ability to override the title that is automatically pulled from the `<title>` tag of the page. Browsers use the page title for bookmarks and there is no standard method or H... | 46,757 | [
{
"from": "human",
"value": "When adding a bookmark or favorite the browser uses the TITLE tag of the page to automatically populate the title of the bookmark. However, my web pages use SEO-friendly titles which are not really user-friendly. Is there a method to override the title when the browser makes a b... |
How would you write a prepared MySQL statement in PHP that takes a differing number of arguments each time? An example such query is:
SELECT `age`, `name` FROM `people` WHERE id IN (12, 45, 65, 33)
The IN clause will have a different number of ids each time it is run.
I have two possible solutions in my mind but want ... | Using prepared statements in PHP with MySQL to handle a dynamic number of arguments is definitely possible and can be done safely and efficiently. You are correct to avoid solutions that involve using dummy values or concatenating strings, as these could lead to security vulnerabilities and inefficiencies.
### Recomme... | 42,849 | [
{
"from": "human",
"value": "How would you write a prepared MySQL statement in PHP that takes a differing number of arguments each time? An example such query is:\nSELECT `age`, `name` FROM `people` WHERE id IN (12, 45, 65, 33)\n\nThe IN clause will have a different number of ids each time it is run.\nI hav... |
Printing button is not shown in the report toolbar when they are opened in FireFox.
Is there any solution for print button not showing in FireFox ?
Can it be enabled or there is no workaround for this?
| If the print button is not showing in the report toolbar when using Firefox, there are several potential solutions and workarounds you can explore:
### 1. Check Browser Settings
- **Disable Add-ons**: Some browser extensions can interfere with the display of certain elements. Try disabling any add-ons or extensions to... | 45,148 | [
{
"from": "human",
"value": "Printing button is not shown in the report toolbar when they are opened in FireFox.\nIs there any solution for print button not showing in FireFox ?\nCan it be enabled or there is no workaround for this?\n"
},
{
"from": "gpt",
"value": "If the print button is not sho... |
I am trying to decide whether to learn ASP.NET MVC (or to spend the time learning another technology that interests me). I know that it is an elegant framework, but I am trying to assess my future job opportunities if I invest in this skill. In your estimation, how long is it going to be before demand for ASP.NET MVC d... | Your inquiry into the future of ASP.NET MVC and its job market relevance is quite insightful, as it reflects a broader concern among developers about how best to allocate their learning resources.
### Job Market Demand for ASP.NET MVC
1. **Current Trends**: As of 2023, ASP.NET Core has gained significant traction ove... | 45,485 | [
{
"from": "human",
"value": "I am trying to decide whether to learn ASP.NET MVC (or to spend the time learning another technology that interests me). I know that it is an elegant framework, but I am trying to assess my future job opportunities if I invest in this skill. In your estimation, how long is it go... |
consider this code block
public void ManageInstalledComponentsUpdate()
{
IUpdateView view = new UpdaterForm();
BackgroundWorker worker = new BackgroundWorker();
Update update = new Update();
worker.WorkerReportsProgress = true;
worker.WorkerSupportsCan... | The reason the objects `worker`, `view`, and `update` in your code block do not get garbage collected while the `ManageInstalledComponentsUpdate` method is running is primarily due to how references are held in your application, especially in relation to event handlers and the lifetime of the objects involved.
### Key... | 42,605 | [
{
"from": "human",
"value": "consider this code block\npublic void ManageInstalledComponentsUpdate()\n {\n IUpdateView view = new UpdaterForm();\n BackgroundWorker worker = new BackgroundWorker();\n Update update = new Update();\n worker.WorkerReportsProgre... |
I am trying to develop a way to change a flash file displayed on the screen to another file by clicking a button. I have been able to do this with jpg images, but I can't get it to work with flash files. Can anyone help? I would greatly appreciate it.
Below are two htmls:
The first one changes jpg images and it works... | To change a Flash file displayed in an `<object>` tag, you need to update the `param` element within the `<object>`. Unlike images, where you can just change the `src` attribute, Flash files require a bit more handling to update the SWF file being loaded.
Here's how you can modify your second HTML to change the Flash ... | 45,929 | [
{
"from": "human",
"value": "I am trying to develop a way to change a flash file displayed on the screen to another file by clicking a button. I have been able to do this with jpg images, but I can't get it to work with flash files. Can anyone help? I would greatly appreciate it.\nBelow are two htmls: \n\nT... |
In a WPF UserControl, I have to make to call to a WebService. I am making this call on a separate thread but I want to inform the user that the call may take some time.
The WebMethod returns me a collection of objects and I bind it to a ListBox in my UC. So far, so good... This part works really well. However, I want ... | To display a progress indicator in a WPF UserControl while making a call to a WebService, you can use a `ProgressBar` or an animation overlay over your ListBox. Instead of using an Adorner, which can be complex for your needs, you can utilize a `Grid` to overlay the progress indicator. Here's a step-by-step guide on ho... | 44,506 | [
{
"from": "human",
"value": "In a WPF UserControl, I have to make to call to a WebService. I am making this call on a separate thread but I want to inform the user that the call may take some time. \nThe WebMethod returns me a collection of objects and I bind it to a ListBox in my UC. So far, so good... Thi... |
Is there a simple way to set the focus (input cursor) of a web page on the first input element (textbox, dropdownlist, ...) on loading the page without having to know the id of the element?
I would like to implement it as a common script for all my pages/forms of my web application.
| Yes, you can set the focus to the first input element on a web page without knowing its specific ID. This can be achieved using a simple JavaScript function that runs when the page loads. You can use the `querySelector` method to select the first input element (including textboxes, dropdowns, etc.) and then call the `f... | 47,710 | [
{
"from": "human",
"value": "Is there a simple way to set the focus (input cursor) of a web page on the first input element (textbox, dropdownlist, ...) on loading the page without having to know the id of the element?\nI would like to implement it as a common script for all my pages/forms of my web applica... |
Maybe this cannot be done, but please help or suggest how this can be achieved without writing something to disk.
Lets suppose there are two string values that I want to share between two independent applications.
You are welcome to provide code sample in any programming language.
| To share string values between two independent applications without writing anything to disk, you can use inter-process communication (IPC) methods. A common approach is to use named pipes or sockets. Below, I'll provide a Python example that demonstrates how to use a named pipe to share two string values between two i... | 41,965 | [
{
"from": "human",
"value": "Maybe this cannot be done, but please help or suggest how this can be achieved without writing something to disk.\nLets suppose there are two string values that I want to share between two independent applications.\nYou are welcome to provide code sample in any programming langu... |
I have an ASP.Net web user control that contains a TextBox and a calendar from the Ajax Control Toolkit.
When I include this user control on my page I would like it to participate in input validation (there is a required filed validator set on the TextBox inside the UC), ie. when the page is validated the content of th... | You can indeed achieve the desired validation behavior in your ASP.NET Web User Control by inheriting from `BaseValidator` and implementing the necessary properties to allow for validation groups. Since a User Control can’t directly inherit from both `UserControl` and `BaseValidator`, you can create a custom validator ... | 44,123 | [
{
"from": "human",
"value": "I have an ASP.Net web user control that contains a TextBox and a calendar from the Ajax Control Toolkit.\nWhen I include this user control on my page I would like it to participate in input validation (there is a required filed validator set on the TextBox inside the UC), ie. wh... |
I need to test for general URLs using any protocol (http, https, shttp, ftp, svn, mysql and things I don't know about).
My first pass is this:
\w+://(\w+\.)+[\w+](/[\w]+)(\?[-A-Z0-9+&@#/%=~_|!:,.;]*)?
(PCRE and .NET so nothing to fancy)
| Your initial regex for matching URLs is a good starting point, but it has some areas that can be improved for better accuracy and coverage. Here's a refined regex that matches general URLs with various protocols:
```regex
\b(?:[a-zA-Z][a-zA-Z\d+\-.]*):\/\/(?:[a-zA-Z0-9\-]+(\.[a-zA-Z0-9\-]+)*)(:\d+)?(\/[^\s]*)?\b
```
... | 44,688 | [
{
"from": "human",
"value": "I need to test for general URLs using any protocol (http, https, shttp, ftp, svn, mysql and things I don't know about).\nMy first pass is this:\n\\w+://(\\w+\\.)+[\\w+](/[\\w]+)(\\?[-A-Z0-9+&@#/%=~_|!:,.;]*)?\n\n(PCRE and .NET so nothing to fancy)\n"
},
{
"from": "gpt",
... |
So I've got some scripts I've written which set up a Google map on my page. These scripts are in included in the <head> of my page, and use jQuery to build the map with markers generated from a list of addresses on the page.
However, I have some exact co-ordinate data for each address which the javascript requires to p... | If you want to include coordinate data in your HTML document while keeping it hidden from users, there are several best practices you can follow. Here are a few options:
1. **Data Attributes**: You can use HTML data attributes on relevant elements. This allows you to embed the coordinates directly within the HTML with... | 44,599 | [
{
"from": "human",
"value": "So I've got some scripts I've written which set up a Google map on my page. These scripts are in included in the <head> of my page, and use jQuery to build the map with markers generated from a list of addresses on the page.\nHowever, I have some exact co-ordinate data for each ... |
I have a short program that is used exclusively with a remote desktop connection that's been set to only run that program and not allow any other access into the remote machine. Previously, the program just exited and let the connection terminate, but it was very slow, so I wrote the following code to terminate the rem... | You can detect whether your application is running in debug mode by checking the `Debugger.IsAttached` property from the `System.Diagnostics` namespace. This allows you to prevent the `HardTerminalExit` function from executing when you're debugging your application. Here's how you can modify your `HardTerminalExit` met... | 48,959 | [
{
"from": "human",
"value": "I have a short program that is used exclusively with a remote desktop connection that's been set to only run that program and not allow any other access into the remote machine. Previously, the program just exited and let the connection terminate, but it was very slow, so I wrot... |
I'm looking for a way to monitor certain Windows services (on Windows Server 2003) and restart if necessary. The services are on different servers and include mainly SQL Server services (e.g. SQL Server Agent), but also some proprietary services.
Email alerts sent out if a service has stopped would be very useful as we... | To monitor Windows services on Windows Server 2003 and restart them if necessary, you can use a combination of PowerShell (though PowerShell was not natively available on Windows Server 2003, you can install it), Windows Batch scripting, or third-party monitoring tools. Below, I'll outline a method using a simple batch... | 37,314 | [
{
"from": "human",
"value": "I'm looking for a way to monitor certain Windows services (on Windows Server 2003) and restart if necessary. The services are on different servers and include mainly SQL Server services (e.g. SQL Server Agent), but also some proprietary services.\nEmail alerts sent out if a serv... |
I have included a resource in my Visual Studio 2005 solution that was a file on the hard drive. It is a text file, that contains text, and has a .htm extension.
For months it worked fine, until I wanted to edit the contents of the text file. Suddenly Visual Studio insists on syntax checking the file as though it were a... | It sounds like you've encountered a common issue in Visual Studio where the IDE begins to enforce syntax checking based on file extensions and content. To resolve this and make Visual Studio treat your `.htm` file as a plain text file rather than an HTML file, you can try the following approaches:
### Approach 1: Chan... | 47,258 | [
{
"from": "human",
"value": "I have included a resource in my Visual Studio 2005 solution that was a file on the hard drive. It is a text file, that contains text, and has a .htm extension.\nFor months it worked fine, until I wanted to edit the contents of the text file. Suddenly Visual Studio insists on sy... |
I would like to get the current URL and append an additional parameter to the url (for example ?id=1)
I have defined a route:
routes.MapRoute(
"GigDayListings", // Route name
"gig/list/{year}/{month}/{day}", // URL with parameters
... | The issue you are encountering is related to how you are constructing the URL with the route parameters and additional query string parameters. When you call `urlHelper.RouteUrl()` with the route data values, it creates a URL with the parameters you specify, but it does not consider the parameters defined in your route... | 48,291 | [
{
"from": "human",
"value": "I would like to get the current URL and append an additional parameter to the url (for example ?id=1)\nI have defined a route:\n routes.MapRoute(\n \"GigDayListings\", // Route name\n \"gig/list/{year}/{month}/{day}\... |
For the moment the best way that I have found to be able to manipulate DOM from a string that contain HTML is:
WebBrowser webControl = new WebBrowser();
webControl.DocumentText = html;
HtmlDocument doc = webControl.Document;
There are two problems:
Requires the WebBrowser object!
This can't be used with multiple thr... | If you're looking for a way to manipulate HTML DOM from a string without using a `WebBrowser` control and ensuring it can be done on a different thread, you can consider using an HTML parsing library. Here are a few options that you might find useful:
### 1. **Html Agility Pack**
The [Html Agility Pack](https://html-a... | 40,695 | [
{
"from": "human",
"value": "For the moment the best way that I have found to be able to manipulate DOM from a string that contain HTML is:\nWebBrowser webControl = new WebBrowser();\nwebControl.DocumentText = html;\nHtmlDocument doc = webControl.Document;\n\nThere are two problems:\n\nRequires the WebBrows... |
I'm trying to read data from a photocell resistor and my Arduino Diecimila and then graph it in real-time with Processing.
It should be painfully simple; but it’s growing into a little bit of a nightmare for me.
The code I'm running on my Arduino:
int photoPin;
void setup(){
photoPin = 0;
Serial.begin(9600);
}
v... | It looks like you're experiencing issues with reading the serial data in Processing. There are a few potential problems in your Processing code that could lead to the behavior you're observing:
1. **Reading Serial Data**: You are calling `photocell.read()` twice in your `draw()` loop — once to assign a value to `yvals... | 34,129 | [
{
"from": "human",
"value": "I'm trying to read data from a photocell resistor and my Arduino Diecimila and then graph it in real-time with Processing.\nIt should be painfully simple; but it’s growing into a little bit of a nightmare for me.\nThe code I'm running on my Arduino:\nint photoPin;\n\nvoid setup(... |
I'm in need of a macro that will enter data into a webpage search field and than copy the results to excel.
| To create a macro that enters data into a webpage search field and copies the results to Excel, you can use VBA (Visual Basic for Applications) in Excel. Below is a step-by-step guide and a sample code to help you achieve this.
### Step 1: Prepare Your Environment
1. **Enable Developer Tab in Excel**:
- Open Excel... | 43,425 | [
{
"from": "human",
"value": "I'm in need of a macro that will enter data into a webpage search field and than copy the results to excel.\n"
},
{
"from": "gpt",
"value": "To create a macro that enters data into a webpage search field and copies the results to Excel, you can use VBA (Visual Basic ... |
We are currently reviewing how we store our database scripts (tables, procs, functions, views, data fixes) in subversion and I was wondering if there is any consensus as to what is the best approach?
Some of the factors we'd need to consider include:
Should we checkin 'Create' scripts or checkin incremental changes wi... | When it comes to storing database scripts in a version control system like Subversion, it's important to adopt a strategy that balances best practices, team collaboration, and operational needs. Here are some commonly accepted approaches and considerations based on industry practices:
### 1. **Script Management Strate... | 47,301 | [
{
"from": "human",
"value": "We are currently reviewing how we store our database scripts (tables, procs, functions, views, data fixes) in subversion and I was wondering if there is any consensus as to what is the best approach?\nSome of the factors we'd need to consider include:\n\nShould we checkin 'Creat... |
I needed a generic collection or list that can fire an event when an item is added or removed.
I discovered that BindingList(of T) has events for this and wired up a quick proof of concept that worked fine.
Of course, this doesn't feel like the most educated choice; BindingList is overkill for what I'm doing. Are ther... | If you're looking for a simpler collection that can notify changes when items are added or removed, you might consider using `ObservableCollection<T>`. This class is part of the System.Collections.ObjectModel namespace and is designed specifically for data binding scenarios in WPF and other XAML-based applications. It ... | 45,814 | [
{
"from": "human",
"value": "I needed a generic collection or list that can fire an event when an item is added or removed. \nI discovered that BindingList(of T) has events for this and wired up a quick proof of concept that worked fine.\nOf course, this doesn't feel like the most educated choice; BindingLi... |
I'm looking for a way to generate a set of random sided, but regular, polygons, inside a given rectangle or sector of a circle. To better explain, my given 2d space should have a random arrangement of regular polygons with various numbers of sides, so, e.g, if two hexagons are separated by a rectangle equal in length ... | Creating a random arrangement of regular polygons inside a given 2D space like a rectangle or a sector of a circle can be an interesting and complex problem. Below is a general approach to generate random sided regular polygons that could fit into your specified area while considering your requirement for separation an... | 44,283 | [
{
"from": "human",
"value": "I'm looking for a way to generate a set of random sided, but regular, polygons, inside a given rectangle or sector of a circle. To better explain, my given 2d space should have a random arrangement of regular polygons with various numbers of sides, so, e.g, if two hexagons are ... |
This question is about using getter methods of a singleton object in worker threads. Here is some pseudo code first:
// Singleton class which contains data
class MyData
{
static MyData* sMyData ;
int mData1[1024];
int mData2[1024];
int mData3[1024];
MyData* getInstance()
{
// sMyDat... | In the context of your pseudocode, let's address your questions one at a time:
### 1. Thread Safety of Getter Methods
The thread safety of the methods in your singleton class, `MyData`, depends on how the data is accessed and modified.
- **`getInstance()` Method**: Assuming `sMyData` is initialized in a thread-safe... | 37,968 | [
{
"from": "human",
"value": "This question is about using getter methods of a singleton object in worker threads. Here is some pseudo code first:\n// Singleton class which contains data\nclass MyData\n{\n static MyData* sMyData ;\n\n int mData1[1024];\n int mData2[1024];\n int mData3[1024];\n... |
What is the best way of handling trying to get data from a DataReader that has more than one column with the same name?
Because of the amount of work involved and because we don't want to lose support from a vendor by changing the stored procedures we are using to retrieve the data, I am trying to find another way to g... | Handling a `DataReader` that returns multiple columns with the same name can be tricky, but there are several strategies you can use to access the data without altering the stored procedures. Below are a few approaches that you might consider:
### 1. Access by Index
Since you mentioned that you're already using the in... | 46,279 | [
{
"from": "human",
"value": "What is the best way of handling trying to get data from a DataReader that has more than one column with the same name?\nBecause of the amount of work involved and because we don't want to lose support from a vendor by changing the stored procedures we are using to retrieve the ... |
I'm using eclipse for a few months, I realy like gvim better but eclipse makes my life easier with pydev and phpeclipse. Everything is pretty nice, I have a black fluxbox and black GTK themes, I've changed the syntax colors for py and php and now everything is dark background, light foreground (including the eclipse me... | To change the syntax colors for HTML files in Eclipse, you need to adjust the settings in the Eclipse preferences. Here’s how you can do that:
1. **Open Eclipse Preferences**:
- Go to the menu bar and click on `Window` (on Windows) or `Eclipse` (on macOS).
- Select `Preferences`.
2. **Find the Editors Preferenc... | 47,313 | [
{
"from": "human",
"value": "I'm using eclipse for a few months, I realy like gvim better but eclipse makes my life easier with pydev and phpeclipse. Everything is pretty nice, I have a black fluxbox and black GTK themes, I've changed the syntax colors for py and php and now everything is dark background, l... |
I would like to size the width of my button according to its icon image.
I tried to force padding to 0 with no success.
In a tile
<mx:Button id="m1" icon="@Embed('m1.png')"/>
See the result
http://img513.imageshack.us/my.php?image=iconkg3.png
How could i change this gap ?
icon http://img513.imageshack.us/my.php?image... | To adjust the width of your button in Flex (using MXML) to match the icon image closely, you can modify the `buttonMode`, `paddingLeft`, `paddingRight`, and set the `label` property to an empty string if you don't want any text.
Here’s an example of how you can set the properties:
```xml
<mx:Button id="m1" icon="@Emb... | 49,836 | [
{
"from": "human",
"value": "I would like to size the width of my button according to its icon image.\nI tried to force padding to 0 with no success.\nIn a tile\n<mx:Button id=\"m1\" icon=\"@Embed('m1.png')\"/>\n\nSee the result\nhttp://img513.imageshack.us/my.php?image=iconkg3.png\nHow could i change this... |
Wnen I use external resources such as files or DB connection I need to close them before I let them go.
Do I need to do the same thing with Swing components ? If yes then how ?
| In Java Swing, you typically do not need to explicitly "close" Swing components in the same way you would close external resources like files or database connections. Swing components, like `JFrame`, `JButton`, and others, are managed by the Java garbage collector. When you no longer need a Swing component, you can sim... | 45,521 | [
{
"from": "human",
"value": "Wnen I use external resources such as files or DB connection I need to close them before I let them go.\nDo I need to do the same thing with Swing components ? If yes then how ?\n"
},
{
"from": "gpt",
"value": "In Java Swing, you typically do not need to explicitly \... |
I am writing a COM object in C++ using ATL and am not sure whether I should be using VARIANT_BOOL for my methods/properties or not. The object will be called by other C++ apps but I cannot rule out usage from .NET.
I can stick to good old BOOL (which IIRC is simply an unsigned int) but as VARIANT_BOOL is there, should... | When deciding between using `VARIANT_BOOL` and `BOOL` for your COM object methods and properties, there are several factors to consider, especially considering your target audience (both C++ and .NET users).
1. **VARIANT_BOOL and COM**: `VARIANT_BOOL` (which is defined as `short` in the Windows API) is a standard type... | 47,395 | [
{
"from": "human",
"value": "I am writing a COM object in C++ using ATL and am not sure whether I should be using VARIANT_BOOL for my methods/properties or not. The object will be called by other C++ apps but I cannot rule out usage from .NET.\nI can stick to good old BOOL (which IIRC is simply an unsigned... |
A have the document with 23 figures and 46 tables (appendix to journal article). There are 23 sections created in the exactly same manner. When viewing compiled dvi everything is in order, but after creating ps file from the dvi one of the section title is missing. Producing pdf from dvi doesn't help. What may be the p... | It sounds like you're experiencing an issue with one of the section titles not appearing in the PostScript (PS) output of your document. This could be due to several reasons, including issues with your LaTeX code, the way you're compiling your document, or potential problems with the fonts or packages you're using.
He... | 40,844 | [
{
"from": "human",
"value": "A have the document with 23 figures and 46 tables (appendix to journal article). There are 23 sections created in the exactly same manner. When viewing compiled dvi everything is in order, but after creating ps file from the dvi one of the section title is missing. Producing pdf... |
Hi I'm very new to sql but have been passed a job in which I need to query the db(MS SQL 2005) I need to return all workers where a HeadID is given.(tables below)
So I need to get all the managers that match the HeadID and then all the workers that match those managers by ManagerID. How would I do this? Any help or any... | Certainly! To achieve your goal of retrieving all workers based on a given `HeadID`, you can use a SQL query that joins the three tables you've described: `tb_Head`, `tb_Manager`, and `tb_Worker`.
Here's a step-by-step explanation of how to construct the SQL query:
1. **Select the relevant columns**: You want to retu... | 48,408 | [
{
"from": "human",
"value": "Hi I'm very new to sql but have been passed a job in which I need to query the db(MS SQL 2005) I need to return all workers where a HeadID is given.(tables below)\nSo I need to get all the managers that match the HeadID and then all the workers that match those managers by Manag... |
I have a table structure that looks like:
<table>
<tr id="row1">
<td>
<div>row 1 content1</div>
</td>
<td>
<div>row 1 content2</div>
</td>
<td>
<div>row 1 content3</div>
</td>
</tr>
<tr id="row2">
<td>
<div>row 2 content1</div>
</td>
<td>
<div>row 2 content2</div>
... | In jQuery, when you use a selector, it always returns a jQuery object, which behaves like an array but contains methods specific to jQuery. This means that even if your selection matches a single element, it is still wrapped in a jQuery object, and that's why you see it as an array-like structure.
To select the `div` ... | 48,109 | [
{
"from": "human",
"value": "I have a table structure that looks like:\n<table>\n <tr id=\"row1\">\n <td>\n <div>row 1 content1</div>\n </td>\n <td>\n <div>row 1 content2</div>\n </td>\n <td>\n <div>row 1 content3</div>\n </td>\n </tr>\n <tr id=\"row2\">\n <td>\n <div>row 2 con... |
I remember looking at D about 2 years ago, and it looked nice, was actually faster than C for some of the typical language benchmarks, and in general seemed ok, but I didn't find any real projects written in D back then, so I just left as a I came.
Now that a few years have passed I was wondering if there have been an... | As of October 2023, the D programming language is still active, and while it may not have the same level of popularity as languages like C, C++, or Python, it has a dedicated community and several interesting projects. D is known for its performance, expressive syntax, and powerful metaprogramming capabilities, and it ... | 49,370 | [
{
"from": "human",
"value": "I remember looking at D about 2 years ago, and it looked nice, was actually faster than C for some of the typical language benchmarks, and in general seemed ok, but I didn't find any real projects written in D back then, so I just left as a I came. \nNow that a few years have pa... |
In this question superwiren asks about the pitfalls for converting a .net 2.0 solution to .net 3.5.
What about .net 1.1 to .net 2.0?
Is 2.0 fully backwards compatible with 1.1?
| .NET 2.0 is designed to be largely backward compatible with .NET 1.1, but there are some important considerations and potential pitfalls to keep in mind when migrating a solution from .NET 1.1 to .NET 2.0.
### Key Points on Compatibility:
1. **Compatibility**: Most applications and libraries built on .NET 1.1 should ... | 44,890 | [
{
"from": "human",
"value": "In this question superwiren asks about the pitfalls for converting a .net 2.0 solution to .net 3.5. \nWhat about .net 1.1 to .net 2.0? \nIs 2.0 fully backwards compatible with 1.1?\n"
},
{
"from": "gpt",
"value": ".NET 2.0 is designed to be largely backward compatibl... |
I have a WCF service up and running and am able to communicate between the service and a .Net 2.0 Client using basicHttpBinding.
I now need to lock down the WCF service so that it can only be called by authenticated clients.
I have control over the clients that will be calling my service. The clients are part of a pr... | When it comes to securing a WCF service with .NET 2.0 clients, especially when you want to enforce authentication and ensure data is sent over HTTPS, you have a few options. Since you can't use Windows Authentication or upgrade the client, you'll need to consider alternative approaches for authentication and encryption... | 44,038 | [
{
"from": "human",
"value": "I have a WCF service up and running and am able to communicate between the service and a .Net 2.0 Client using basicHttpBinding. \nI now need to lock down the WCF service so that it can only be called by authenticated clients.\nI have control over the clients that will be calli... |
Is there a way to tidy-up the following code, rather than a series of nested try/except statements?
try:
import simplejson as json
except ImportError:
try:
import json
except ImportError:
try:
from django.utils import simplejson as json
except:
raise "Requires... | Yes, you can tidy up the code using a function that attempts to import each module in a cleaner way, avoiding the deeply nested `try/except` statements. You can encapsulate the logic in a helper function that tries each import in sequence. Here's how you can do it:
```python
def import_json():
try:
import ... | 48,982 | [
{
"from": "human",
"value": "Is there a way to tidy-up the following code, rather than a series of nested try/except statements?\ntry:\n import simplejson as json\nexcept ImportError:\n try:\n import json\n except ImportError:\n try:\n from django.utils import simplejson as... |
Update: So, this turns out to have nothing to do with Tortoise SVN. I use Mozy.com for off-site backups and their new version includes these icon overlays. They can be disabled via the config options...or see here http://forum.pcmech.com/showthread.php?p=1385433. Thanks @OS for the answer.
Been using Tortoise SVN for s... | It looks like the issue you're experiencing with the icon overlays in Tortoise SVN has been resolved, as you've identified that the problem was actually caused by the new version of Mozy.com rather than Tortoise SVN itself. It's great that you found a way to disable the Mozy overlays through their configuration options... | 45,082 | [
{
"from": "human",
"value": "Update: So, this turns out to have nothing to do with Tortoise SVN. I use Mozy.com for off-site backups and their new version includes these icon overlays. They can be disabled via the config options...or see here http://forum.pcmech.com/showthread.php?p=1385433. Thanks @OS for ... |
What is the best way to download all of the WSDL files exposed by a WCF service?
For example, the root WSDL file references the following other WSDL files:
<xsd:import schemaLocation="http://localhost:80/?xsd=xsd0" namespace="http://tempuri.com"/>
<xsd:import schemaLocation="http://localhost:80/?xsd=xsd1" namespace="ht... | To automate the process of downloading all WSDL files (including any referenced XSD files) exposed by a WCF service, you can use a combination of scripting and possibly a web client library. Below is a general approach using Python, which is a popular language for automating such tasks. This will allow you to fetch the... | 40,709 | [
{
"from": "human",
"value": "What is the best way to download all of the WSDL files exposed by a WCF service?\nFor example, the root WSDL file references the following other WSDL files:\n<xsd:import schemaLocation=\"http://localhost:80/?xsd=xsd0\" namespace=\"http://tempuri.com\"/>\n<xsd:import schemaLocati... |
I need to detect whether my Makefile is running under valgrind (indirectly, using valgrind --trace-children=yes), I know how to do it from C but I have not found a way to do it from a script,
The earlier answers works on Linux only. For Mac OS X I am an going to grep for VALGRIND_STARTUP_PWD in the environment, unless... | To detect if your Makefile is running under Valgrind, you can indeed check for the environment variable `VALGRIND_STARTUP_PWD`, as it's set by Valgrind. This approach is generally portable across different Unix-like operating systems, including Linux and macOS.
Here’s how you can incorporate this check into your Make... | 48,078 | [
{
"from": "human",
"value": "I need to detect whether my Makefile is running under valgrind (indirectly, using valgrind --trace-children=yes), I know how to do it from C but I have not found a way to do it from a script,\nThe earlier answers works on Linux only. For Mac OS X I am an going to grep for VALGR... |
How do I set the executable icon for my C++ application in visual studio 2008?
| Setting the executable icon for your C++ application in Visual Studio 2008 involves a few steps. Here’s how you can do it:
1. **Prepare Your Icon File**:
- Make sure you have an icon file (`.ico`) that you want to use for your application. You can create your own icon using an icon editor or download one from the ... | 45,520 | [
{
"from": "human",
"value": "How do I set the executable icon for my C++ application in visual studio 2008?\n"
},
{
"from": "gpt",
"value": "Setting the executable icon for your C++ application in Visual Studio 2008 involves a few steps. Here’s how you can do it:\n\n1. **Prepare Your Icon File**... |
I need to update a pair of old classic asp pages— a search.asp page that provides a simple form which is then posted to a results.asp page. One of the form options on the search page is a drop down list (<select) for the "format". If the user chooses the excel format the results page just sets the Response.ContentTyp... | To improve the user experience when users request a large dataset in Excel format, we can implement a few changes. Since the existing implementation does not provide feedback while the Excel file is being generated and downloaded, we can leverage JavaScript and some basic HTML/CSS to enhance the experience. Here’s a st... | 40,914 | [
{
"from": "human",
"value": "I need to update a pair of old classic asp pages— a search.asp page that provides a simple form which is then posted to a results.asp page. One of the form options on the search page is a drop down list (<select) for the \"format\". If the user chooses the excel format the res... |
I have a following SQL QUERY:
SELECT articles.name, articles.price, users.zipcode FROM articles INNER JOIN users ON users.id = articles.user_id WHERE vectors @@ to_tsquery('crime') ORDER BY articles.price ASC
And I Would like to write it inside of a find method from an ActiveRecord Class named Articles (Articles belong... | To translate your SQL query into an ActiveRecord find method correctly, you need to ensure that you're selecting the right attributes, including the user's zipcode, and that you're constructing your query properly. However, your current approach using `find` is a bit outdated. In modern Rails applications, it's better ... | 49,135 | [
{
"from": "human",
"value": "I have a following SQL QUERY:\nSELECT articles.name, articles.price, users.zipcode FROM articles INNER JOIN users ON users.id = articles.user_id WHERE vectors @@ to_tsquery('crime') ORDER BY articles.price ASC\nAnd I Would like to write it inside of a find method from an ActiveR... |
We have a legacy app that uses MFC's CArchive. I am researching saving the data in XML vs. binary. I have looked several libraries such as:
Boost
http://www.codeproject.com/KB/XML/xmlize.aspx
http://www.ucancode.net/faq/Visual-C-MFC-XML-Example.htm
http://www.codeguru.com/cpp/data/data-misc/xml/article.php/c4567
They... | For your requirements of minimal code changes to replace MFC's `CArchive` with an XML serialization solution, you might want to consider using a wrapper or adapter pattern around an existing XML library that provides a similar interface to `CArchive`. Unfortunately, there may not be a library that directly implements a... | 48,474 | [
{
"from": "human",
"value": "We have a legacy app that uses MFC's CArchive. I am researching saving the data in XML vs. binary. I have looked several libraries such as:\n\nBoost\nhttp://www.codeproject.com/KB/XML/xmlize.aspx\nhttp://www.ucancode.net/faq/Visual-C-MFC-XML-Example.htm\nhttp://www.codeguru.com/... |
Now this is all way simplified, but here goes:
I have a User Control that consists only of a single *.ascx file. The control has no code-behind: it's just a script with a few functions, like this:
<%@ Control Language="VB" EnableViewState="False" ClassName="MyControlType" %>
<script runat="server">
Public Function... | Your observation is indeed correct: using a user control defined solely in an ASCX file without a code-behind file has limitations in ASP.NET regarding type resolution and casting.
In the context you provided, when you define a user control without a code-behind file, it doesn't generate a specific class type that you... | 47,453 | [
{
"from": "human",
"value": "Now this is all way simplified, but here goes:\nI have a User Control that consists only of a single *.ascx file. The control has no code-behind: it's just a script with a few functions, like this:\n<%@ Control Language=\"VB\" EnableViewState=\"False\" ClassName=\"MyControlType... |
I generally try and keep all related entities in the same repository. The following are entities that have a relationship between the two (marked with indentation):
User
UserPreference
So they make sense to go into a user repository. However users are often linked to many different entities, what would you do in t... | In a domain-driven design (DDD) approach, managing entities and their relationships across different repositories can be challenging. It’s important to maintain separation of concerns while still enabling access to related data when needed. Here are several strategies to handle this scenario effectively:
### 1. **Use ... | 45,869 | [
{
"from": "human",
"value": "I generally try and keep all related entities in the same repository. The following are entities that have a relationship between the two (marked with indentation):\n\nUser\n\n\nUserPreference\n\n\nSo they make sense to go into a user repository. However users are often linked t... |
If I'm rendering a regular view in asp.net mvc the only domain object properties that show up in my page the ones I specifically write out. For example:
<div><%= Customer.FirstName %></div>
However, if I serialize a domain object for json it will include every property. Example:
public JsonResult Customer (int? id)
{
... | In ASP.NET MVC, when you're returning a JSON representation of a domain object, exposing all properties can lead to security issues or unwanted data leaks. To control which properties are serialized into the JSON response, you have a few good options:
### 1. Use a Data Transfer Object (DTO)
Creating a separate class ... | 46,338 | [
{
"from": "human",
"value": "If I'm rendering a regular view in asp.net mvc the only domain object properties that show up in my page the ones I specifically write out. For example:\n<div><%= Customer.FirstName %></div>\n\nHowever, if I serialize a domain object for json it will include every property. Exam... |
I have the whole MVC-Model set up and use HTML views as templates. But I have german strings in there that I would like to translate to other languages at some point.
What is the best way to do this? I know I have to use Zend_Translate, but do I have to implement a single call to a translate function for every word tha... | Using Zend_Translate for internationalization in an MVC framework is a great approach. To translate your strings efficiently and avoid calling the translation function for every single word in your view templates, consider the following strategies:
### 1. Use Translation Files
You should create separate translation fi... | 45,825 | [
{
"from": "human",
"value": "I have the whole MVC-Model set up and use HTML views as templates. But I have german strings in there that I would like to translate to other languages at some point.\nWhat is the best way to do this? I know I have to use Zend_Translate, but do I have to implement a single call ... |
I would like to completely reset the scroll position of a UITableView, so that every time I open it, it is displaying the top-most items. In other words, I would like to scroll the table view to the top every time it is opened.
I tried using the following piece of code, but it looks like I misunderstood the documentati... | Yes, using `scrollToNearestSelectedRowAtScrollPosition:animated:` is not the right approach if your goal is to reset the scroll position of a `UITableView` to the top when the view appears. This method is intended to scroll to the nearest selected row, which may not achieve the desired effect of scrolling to the top of... | 49,993 | [
{
"from": "human",
"value": "I would like to completely reset the scroll position of a UITableView, so that every time I open it, it is displaying the top-most items. In other words, I would like to scroll the table view to the top every time it is opened.\nI tried using the following piece of code, but it ... |
It's not uncommon for me to record a patch, pull it into my staging branch and then realize I've done something small and silly like a typo in a logging message, or something similarly trivial which doesn't require (to my mind) a whole new patch.
In these instances, I've been using:
darcs amend-record
To update the pa... | In Darcs, when you amend a patch using `darcs amend-record`, the original patch is modified, and as you have noticed, this can lead to conflicts when pulling from a repository that has already incorporated the original version of the patch.
To pull an amended patch more smoothly, you can use the following approach:
1... | 46,314 | [
{
"from": "human",
"value": "It's not uncommon for me to record a patch, pull it into my staging branch and then realize I've done something small and silly like a typo in a logging message, or something similarly trivial which doesn't require (to my mind) a whole new patch.\nIn these instances, I've been u... |
I'm currently working with a specialized, interpreted, programming language implemented in Java. As a very small part of the language, I'd like to add the ability to make calls into Java. Before I dive into all of the nitty-gritty of reflection, I was wondering if anyone knew of a general library for doing the "back-e... | For your use case of invoking Java methods reflectively from a specialized interpreted language, there are a few libraries and approaches that might help simplify the process without diving too deeply into Java reflection's intricacies. Here are some libraries and frameworks that can help you achieve your goal:
1. **J... | 45,005 | [
{
"from": "human",
"value": "I'm currently working with a specialized, interpreted, programming language implemented in Java. As a very small part of the language, I'd like to add the ability to make calls into Java. Before I dive into all of the nitty-gritty of reflection, I was wondering if anyone knew o... |
My VPS provider (Slicehost) doesn't provide an SMTP server. I use Google Apps to send and receive mail for my domains, but I want to be able to programmatically send e-mail.
I've been Googling this issue on and off for many months, and I just can't seem to get a clear picture of what I need to do. Do I just need an M... | To set up email sending on your VPS without an SMTP server provided by your VPS host, you can indeed configure Postfix as a Mail Transfer Agent (MTA). Since you're using Google Apps (now known as Google Workspace), you can configure Postfix to relay your emails through Google's SMTP servers. Here are the steps you can ... | 28,629 | [
{
"from": "human",
"value": "My VPS provider (Slicehost) doesn't provide an SMTP server. I use Google Apps to send and receive mail for my domains, but I want to be able to programmatically send e-mail.\nI've been Googling this issue on and off for many months, and I just can't seem to get a clear picture ... |
I want to keep viewstate of a specific page in session but following code block does not help me, what might I be missing?
So here is the code-behind file content of my page;
public partial class ConfigurationEditorWebForm : PageBase
{
protected void Page_Load(object sender, EventArgs e)
{
... | To store the ViewState of a specific ASP.NET page in the session, your implementation of a custom `PageStatePersister` (in this case, `SessionPageStatePersister`) is key. However, there are several considerations to ensure it works correctly. Here are some points to check and suggestions for your code:
1. **Implementa... | 48,499 | [
{
"from": "human",
"value": "I want to keep viewstate of a specific page in session but following code block does not help me, what might I be missing?\nSo here is the code-behind file content of my page;\n public partial class ConfigurationEditorWebForm : PageBase\n {\n protected void Page_Loa... |
Instead of just filling out the form in HTML it should also be possible to just send a post request containing the params.. Is it possible to turn off the authenticity token if, for example, the Accept flag is set to 'application/JSON' in the HTTP header?
| In a typical web application using frameworks like Ruby on Rails or Django, the authenticity token is used to prevent Cross-Site Request Forgery (CSRF) attacks. This token is usually required for forms submitted via POST requests. However, there may be scenarios where you want to allow requests without the token, such ... | 44,518 | [
{
"from": "human",
"value": "Instead of just filling out the form in HTML it should also be possible to just send a post request containing the params.. Is it possible to turn off the authenticity token if, for example, the Accept flag is set to 'application/JSON' in the HTTP header?\n"
},
{
"from":... |
I need to perform a complicated calculation. In my case it seemed most natural to create a Calculator class (abstracted using a strategy pattern).
To perform the calculation the class needs to accept about 20 inputs, some of which are optional, some of which could change in the future etc. Once the Calculate() method i... | It sounds like you've made significant progress in designing your Calculator class with a focus on maintainability and extensibility. Using interfaces for inputs and outputs is a solid approach, as it allows for flexibility and future changes without significant refactoring.
Given the context you've provided, here’s a... | 44,228 | [
{
"from": "human",
"value": "I need to perform a complicated calculation. In my case it seemed most natural to create a Calculator class (abstracted using a strategy pattern).\nTo perform the calculation the class needs to accept about 20 inputs, some of which are optional, some of which could change in the... |
In my WCF service class which is in the same project as my WebSite I inherit from System.Web.UI.Page so that I have access to the Page.Response object but when I use it I get the error:
"Response is not available in this context."
I want to save to a file the results passes in to my WCF service like so:
pub... | In a WCF service, you do not have access to the `HttpResponse` object as you would in a standard ASP.NET page because WCF services are designed to be loosely coupled and can be hosted in a variety of environments (IIS, self-hosting, etc.).
If you want to return a file from a WCF service, you will need to change your ... | 46,959 | [
{
"from": "human",
"value": "In my WCF service class which is in the same project as my WebSite I inherit from System.Web.UI.Page so that I have access to the Page.Response object but when I use it I get the error:\n\"Response is not available in this context.\"\nI want to save to a file the results passes ... |
What is the meaning, and where is the Ruby documentation for the syntax of:
Array(phrases)
which I found browsing the Rails source here:
# File actionpack/lib/action_view/helpers/text_helper.rb, line 109
...
119: match = Array(phrases).map { |p| Regexp.escape(p) }.join('|')
I thought that Array.new would n... | In Ruby, the syntax `Array(phrases)` is a way to ensure that the variable `phrases` is converted to an Array. This method is particularly useful when you want to handle different types of input seamlessly. The `Array()` method will convert its argument into an array if it isn't one already, which is why this syntax is ... | 47,468 | [
{
"from": "human",
"value": "What is the meaning, and where is the Ruby documentation for the syntax of: \nArray(phrases)\n\nwhich I found browsing the Rails source here:\n# File actionpack/lib/action_view/helpers/text_helper.rb, line 109\n...\n119: match = Array(phrases).map { |p| Regexp.escape(p... |
I need to get a file into memory in my app from a secured web location. I have the URL of the file to capture, but can't seem to get the security issue resolved. Here's the code from the Cookbook samples page:
def download(address)
{
def file = new FileOutputStream(address.tokenize("/")[-1])
def out = new Buf... | It sounds like you're dealing with a common scenario when accessing secured resources over HTTP, where authentication and possibly redirection are involved. Your approach to using `Authenticator` and handling the 302 redirect is a good starting point. Below is an enhanced version of your `downloadIntoMem` method that t... | 43,911 | [
{
"from": "human",
"value": "I need to get a file into memory in my app from a secured web location. I have the URL of the file to capture, but can't seem to get the security issue resolved. Here's the code from the Cookbook samples page:\ndef download(address)\n{\n def file = new FileOutputStream(addr... |
I have multiple xaml based pages stored as children of a canvas on another page. I add and remove the children pages as the application runs. However, pages that are removed from the children collection are still running and respond to keyboard shortcuts. How can I force the older pages to be removed completely?
| When you remove a child from a `Canvas` in a WPF application, you're merely removing the visual representation of that child from the UI. The underlying controls may still be active and can still respond to events, including keyboard shortcuts, unless they are properly disposed of or their event handlers are unsubscrib... | 45,628 | [
{
"from": "human",
"value": "I have multiple xaml based pages stored as children of a canvas on another page. I add and remove the children pages as the application runs. However, pages that are removed from the children collection are still running and respond to keyboard shortcuts. How can I force the ... |
Say we have:
class Base
{
virtual void f() {g();};
virtual void g(){//Do some Base related code;}
};
class Derived : public Base
{
virtual void f(){Base::f();} override;
virtual void g(){/*Do some Derived related code*/} override;
};
int main()
{
Base *pBase = new Derived;
pBase->f();
... | In your provided code snippet, when `Base::f()` is called (through the `Derived` class's overridden `f()`), it will call the method `g()` as defined in the `Base` class. However, because `g()` is a virtual function, the version of `g()` that gets called is determined at runtime based on the actual object type that `pBa... | 49,987 | [
{
"from": "human",
"value": "Say we have:\n\nclass Base\n{ \n virtual void f() {g();};\n virtual void g(){//Do some Base related code;}\n};\n\nclass Derived : public Base\n{ \n virtual void f(){Base::f();} override;\n virtual void g(){/*Do some Derived related code*/} override;\n};\n\nint ma... |
I think there must be something subtle going on here that I don't know about. Consider the following:
public class Foo<T> {
private T[] a = (T[]) new Object[5];
public Foo() {
// Add some elements to a
}
public T[] getA() {
return a;
}
}
Suppose that your main method contains the following:
Foo<Dou... | The issue you are encountering is due to the way Java handles generics and arrays, particularly with respect to type erasure and the creation of generic arrays.
When you declare `private T[] a = (T[]) new Object[5];`, you are creating an `Object` array and then casting it to a `T[]`. This cast is unchecked, which mean... | 45,839 | [
{
"from": "human",
"value": "I think there must be something subtle going on here that I don't know about. Consider the following:\npublic class Foo<T> {\n private T[] a = (T[]) new Object[5];\n\n public Foo() {\n // Add some elements to a\n }\n\n public T[] getA() {\n return a;\n }\n}\n\nSuppose... |
There's a part in my apps that displays the file path loaded by the user through OpenFileDialog. It's taking up too much space to display the whole path, but I don't want to display only the filename as it might be ambiguous. So I would prefer to show the file path relative to the assembly/exe directory.
For example, t... | To achieve the desired display format for the file path relative to your application's directory, you can use the `Path` class provided by .NET instead of regex. The `Path` class contains useful methods to manipulate file paths effectively.
Here’s a step-by-step solution that will help you display the file path in the... | 40,566 | [
{
"from": "human",
"value": "There's a part in my apps that displays the file path loaded by the user through OpenFileDialog. It's taking up too much space to display the whole path, but I don't want to display only the filename as it might be ambiguous. So I would prefer to show the file path relative to t... |
is it possible to hide/block files/folders in a VS2008 solution from various users (by their NTDomainName) if the solution is under TFS?
I have some files and a folder that contains secret info (eg. release.web.config, etc) which i need as part of our RELEASE builds, but i do not want some new contractors to be able to... | In Visual Studio 2008 and Team Foundation Server (TFS), managing visibility of files or folders based on user roles or identities is not directly supported through TFS itself. TFS is primarily a version control system and does not provide granular file/folder access control within a single solution. However, there are ... | 46,203 | [
{
"from": "human",
"value": "is it possible to hide/block files/folders in a VS2008 solution from various users (by their NTDomainName) if the solution is under TFS?\nI have some files and a folder that contains secret info (eg. release.web.config, etc) which i need as part of our RELEASE builds, but i do n... |
Ok I am a total beginner with the Solaris Operating system and I need to install and configure samba on 3 boxes each has a different version of Solaris (8,9,10).
What I want to know location of samba configuration file i.e., smb.conf files in each version? So far all I have found is
Solaris 8
/usr/local/samba/lib/s... | You're correct about the locations of the Samba configuration files for the different versions of Solaris, but let's clarify and summarize it:
1. **Solaris 8**:
- Default location for the Samba configuration file:
```
/usr/local/samba/lib/smb.conf
```
2. **Solaris 9**:
- Default location for the... | 48,944 | [
{
"from": "human",
"value": "Ok I am a total beginner with the Solaris Operating system and I need to install and configure samba on 3 boxes each has a different version of Solaris (8,9,10).\nWhat I want to know location of samba configuration file i.e., smb.conf files in each version? So far all I have fou... |
Using ASP.net 2.0, how do I present the information to the user similar to the Questions list on SO where each question has some child items (like the tags).
I would probably be making two separate queries, one to first find the list of questions, then another query to find all tags which belonged to the list of questi... | In ASP.NET 2.0, both approaches you mentioned can work, but they have different implications in terms of maintainability, efficiency, and ease of use. Let's break down the two approaches and discuss their pros and cons, as well as suggest an alternative.
### Approach 1: Nested Repeaters with `OnItemDataBind`
1. **Des... | 45,165 | [
{
"from": "human",
"value": "Using ASP.net 2.0, how do I present the information to the user similar to the Questions list on SO where each question has some child items (like the tags).\nI would probably be making two separate queries, one to first find the list of questions, then another query to find all... |
I have a table in a DB (Postgres based), which acts like a superclass in object-oriented programming. It has a column 'type' which determines, which additional columns should be present in the table (sub-class properties). But I don't want the table to include all possible columns (all properties of all possible types)... | The design pattern you're using resembles the Entity-Attribute-Value (EAV) model, where you store attributes as rows instead of columns. While the EAV model is flexible, it does have its drawbacks, particularly with data integrity and the need for type conversions.
Here are some approaches to address the limitation of... | 44,369 | [
{
"from": "human",
"value": "I have a table in a DB (Postgres based), which acts like a superclass in object-oriented programming. It has a column 'type' which determines, which additional columns should be present in the table (sub-class properties). But I don't want the table to include all possible colum... |
When do you start to consider a code base to be getting too large and unwieldy?
| Determining when a codebase becomes too large and unwieldy is somewhat subjective, but there are several indicators that can help assess its manageability. Here are some key factors to consider:
1. **Size and Complexity**:
- A codebase that has grown significantly in size (in lines of code) can become difficult to... | 46,501 | [
{
"from": "human",
"value": "When do you start to consider a code base to be getting too large and unwieldy? \n"
},
{
"from": "gpt",
"value": "Determining when a codebase becomes too large and unwieldy is somewhat subjective, but there are several indicators that can help assess its manageabilit... |
I'm learning how to use Greasemonkey, and was wondering what the @namespace metadata id is for.
Does it have to be a web address? Or can it be a folder/directory on my computer?
Does it even need to be filled in?
| The `@namespace` metadata key in Greasemonkey scripts is used to define a unique namespace for your script. This can help to avoid conflicts with other scripts, particularly if you are developing multiple scripts or using scripts from different authors.
### Here are some key points about `@namespace`:
1. **Purpose**:... | 48,777 | [
{
"from": "human",
"value": "I'm learning how to use Greasemonkey, and was wondering what the @namespace metadata id is for. \nDoes it have to be a web address? Or can it be a folder/directory on my computer? \nDoes it even need to be filled in?\n"
},
{
"from": "gpt",
"value": "The `@namespac... |
I've been given a prototype/mockup of a grid written in html and javascript (via ExtJS) that I now need to implement within an ASP.net web application. Does anyone have any pointers as to how to pass data to the grid (to a GroupingStore, specifically).
I'd rather not have a proliferation of web services or helper page... | To implement an ExtJS grid in your ASP.NET web application and populate it with data without resorting to creating multiple web services or helper pages, you can utilize ASP.NET Page Methods or Web Methods (which are static methods in your ASP.NET page) to pass data directly to your ExtJS GroupingStore.
Here's a step... | 42,914 | [
{
"from": "human",
"value": "I've been given a prototype/mockup of a grid written in html and javascript (via ExtJS) that I now need to implement within an ASP.net web application. Does anyone have any pointers as to how to pass data to the grid (to a GroupingStore, specifically). \nI'd rather not have a pr... |
I know that the JVM can do some pretty serious optimizations at runtime, especially in -server mode. Of course, it takes a little while for the JVM to settle down and reach peak performance. Is there any way to take a snapshot of those optimizations so they can be applied immediately the next time you run your app?
"He... | Yes, there are ways to capture and leverage the optimizations made by the JVM during runtime to improve the performance of subsequent executions of your application. One of the primary ways to achieve this is through the use of **JVM Profiling** and **JVM Options** that influence Just-In-Time (JIT) compilation behavior... | 46,777 | [
{
"from": "human",
"value": "I know that the JVM can do some pretty serious optimizations at runtime, especially in -server mode. Of course, it takes a little while for the JVM to settle down and reach peak performance. Is there any way to take a snapshot of those optimizations so they can be applied immedi... |
I want to create a linked server in one sql server to another using the sp_addlinkedserver procedure. When i access the remote server I would like it to logon as me (i.e. using my windows account). How do I do this?
| To create a linked server in SQL Server that uses your Windows account for authentication when accessing a remote server, you can use the `sp_addlinkedserver` procedure in conjunction with `sp_addlinkedsrvlogin`. Here’s how you can do it:
1. **Create the Linked Server**: Use `sp_addlinkedserver` to define the linked s... | 46,664 | [
{
"from": "human",
"value": "I want to create a linked server in one sql server to another using the sp_addlinkedserver procedure. When i access the remote server I would like it to logon as me (i.e. using my windows account). How do I do this?\n"
},
{
"from": "gpt",
"value": "To create a linked... |
Are there any pre-written component-like Silverlight web widgets like there are for Flash?
Flash examples:
XSPF Web Music Player
WordPress Audio Player
FLAMPlayer
Aflax
Clarification: I don't mean controls to use in your IDE to write something custom.
See ALTNET Podcast
I think they use the WordPress Audio Player.
| Yes, there are several pre-written Silverlight web widgets that you can use similarly to how Flash widgets were utilized. While Silverlight didn't gain the same level of popularity as Flash, there are still some useful components and widgets available for various purposes. Here are a few examples:
1. **Silverlight Med... | 48,806 | [
{
"from": "human",
"value": "Are there any pre-written component-like Silverlight web widgets like there are for Flash? \nFlash examples:\nXSPF Web Music Player\nWordPress Audio Player\nFLAMPlayer\nAflax \nClarification: I don't mean controls to use in your IDE to write something custom.\nSee ALTNET Podcas... |
I have a situation in which I parse a body of text and replace certain phrases with links. I then need to re-parse the string to replace a second set of phrases with links. The problem arises at this point, where certain words or phrases in the second set can be substrings of phrases already replaced in the first pass.... | Hi Dave,
You're encountering a common issue when trying to replace text within a string that may already contain HTML markup, particularly when using nested tags. To avoid nested `<a>` tags, a good approach is to ensure that you're only replacing the target phrases that are not already wrapped in an anchor tag.
You c... | 47,279 | [
{
"from": "human",
"value": "I have a situation in which I parse a body of text and replace certain phrases with links. I then need to re-parse the string to replace a second set of phrases with links. The problem arises at this point, where certain words or phrases in the second set can be substrings of ph... |
It is advised to use override instead of new key word in C#. Why that rule?
| In C#, the `override` keyword is used in the context of inheritance and polymorphism, allowing derived classes to provide a specific implementation of a method that is already defined in a base class. In contrast, the `new` keyword is used to hide a member inherited from a base class. Here are the reasons why it's gene... | 46,741 | [
{
"from": "human",
"value": "It is advised to use override instead of new key word in C#. Why that rule?\n"
},
{
"from": "gpt",
"value": "In C#, the `override` keyword is used in the context of inheritance and polymorphism, allowing derived classes to provide a specific implementation of a metho... |
I'm trying to consume Sharepoint webservices with ruby. I've basically given up trying to authenticate with NTLM and temporarily changed the Sharepoint server to use basic authentication. I've been successful getting a WSDL using soap4r but still cannot authenticate when attempting to use an actual web service call.
... | Yes, integrating Ruby with SharePoint web services can sometimes be tricky, especially with authentication. Since you've switched to basic authentication, you may find it easier to work with. Here’s a general approach using the `savon` gem for SOAP requests in Ruby.
### Steps to Use Savon with SharePoint
1. **Install... | 45,866 | [
{
"from": "human",
"value": "I'm trying to consume Sharepoint webservices with ruby. I've basically given up trying to authenticate with NTLM and temporarily changed the Sharepoint server to use basic authentication. I've been successful getting a WSDL using soap4r but still cannot authenticate when attem... |
I know this is possible via a simple registry change to accomplish this as long as IE/firefox is being used. However, I am wondering if there is a reliable way to do so for other browsers,
I am specifically looking for a way to do this via an installer, so editing a preference inside a specific browser will not cut i... | It sounds like you want to modify settings in web browsers through an installer. This can be a challenging task since most modern browsers have security measures in place to prevent unauthorized changes to user settings, and they store user preferences in ways that may not be straightforward to edit.
Here's an overvie... | 45,140 | [
{
"from": "human",
"value": "I know this is possible via a simple registry change to accomplish this as long as IE/firefox is being used. However, I am wondering if there is a reliable way to do so for other browsers,\nI am specifically looking for a way to do this via an installer, so editing a preferenc... |
I want to build a web based front-end to manage/administer my Linux box. E.g. I want to be able to add users, manage the file system and all those sorts of things. Think of it as a cPanel clone but more for system admin rather that web admin.
I was thinking about creating a service that runs on my box and that performs... | Creating a web-based front-end to manage your Linux box is a great project for learning about web development, system administration, and security practices. Here’s a high-level approach you can consider for building your service, along with some security considerations.
### High-Level Architecture
1. **Front-End Int... | 42,120 | [
{
"from": "human",
"value": "I want to build a web based front-end to manage/administer my Linux box. E.g. I want to be able to add users, manage the file system and all those sorts of things. Think of it as a cPanel clone but more for system admin rather that web admin.\nI was thinking about creating a ser... |
Using the code below, I am returning an nvarchar field from MS SQL 2005 and keep getting a System.InvalidCastException.
vo.PlacementID = dr.IsDBNull(0) ? null : dr.GetString(0);
The vo.PlacementID variable is of type String so there shouldn't be a problem.
The values I am trying to return are like this (number, number... | The error you're encountering (`System.InvalidCastException`) is occurring because the data type being returned from the SQL query is not actually a string (`nvarchar`), but rather an integer (`System.Int32`). This suggests that the column `PlacementID` in the SQL Server database may be of an integer type rather than a... | 48,585 | [
{
"from": "human",
"value": "Using the code below, I am returning an nvarchar field from MS SQL 2005 and keep getting a System.InvalidCastException.\nvo.PlacementID = dr.IsDBNull(0) ? null : dr.GetString(0);\n\nThe vo.PlacementID variable is of type String so there shouldn't be a problem.\nThe values I am t... |
When creating a new list do you specify an initial size or leave it blank? I know by specifying an initial size you avoid having the list reallocate the underlying array every-time you add x number of items but you also add verbosity to your code. Is the minimal performance gain worth adding verbosity and complexity to... | When creating a new list in programming, the decision to specify an initial size or leave it blank often depends on the context and requirements of the application, as well as considerations around performance and code readability.
### Pros of Specifying an Initial Size
1. **Performance Optimization**: Specifying an ... | 45,946 | [
{
"from": "human",
"value": "When creating a new list do you specify an initial size or leave it blank? I know by specifying an initial size you avoid having the list reallocate the underlying array every-time you add x number of items but you also add verbosity to your code. Is the minimal performance gain... |
By default C# compares DateTime objects to the 100ns tick. However, my database returns DateTime values to the nearest millisecond. What's the best way to compare two DateTime objects in C# using a specified tolerance?
Edit: I'm dealing with a truncation issue, not a rounding issue. As Joe points out below, a rounding ... | You're on the right track with your solution using the `Duration()` method from `TimeSpan`. To clarify and expand on your approach for comparing two `DateTime` objects with a tolerance for truncation (where the database rounds to the nearest millisecond), you can use the following code snippet:
```csharp
DateTime date... | 47,772 | [
{
"from": "human",
"value": "By default C# compares DateTime objects to the 100ns tick. However, my database returns DateTime values to the nearest millisecond. What's the best way to compare two DateTime objects in C# using a specified tolerance?\nEdit: I'm dealing with a truncation issue, not a rounding i... |
How can I select the good method (I have in the example below show 2 differents way that doesn't work). I was using instead of a variable of type Object with a IF and IS to do the job but I am trying to avoid using Object and boxing/unboxing. So I thought that Generic could do the job but I am stuck here.
Here is a sm... | To address your question effectively while adhering to your constraints—specifically, avoiding boxing/unboxing and the use of interfaces or abstract classes—let’s clarify a few things and identify a suitable solution.
### Problem Explanation
In your code, you want to handle different types (`ObjectType1`, `ObjectType... | 47,155 | [
{
"from": "human",
"value": "How can I select the good method (I have in the example below show 2 differents way that doesn't work). I was using instead of a variable of type Object with a IF and IS to do the job but I am trying to avoid using Object and boxing/unboxing. So I thought that Generic could do ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.