instruction stringlengths 14 27.6k | completion stringlengths 3 38.3k | __original_row_idx int64 0 50k | conversations listlengths 2 2 |
|---|---|---|---|
How do you allow a C-extension to use rb_f_require to require a file from outside the ext directory (e.g. requiring lib/foo/foo.rb from ext/foo.so).
| To allow a C-extension in Ruby to use `rb_f_require` to require a Ruby file located outside of the ext directory (e.g., requiring `lib/foo/foo.rb` from `ext/foo.so`), you can follow these steps:
1. **Determine the Path**: First, you need to obtain the path of the Ruby file you want to require. You can do this by defin... | 36,916 | [
{
"from": "human",
"value": "How do you allow a C-extension to use rb_f_require to require a file from outside the ext directory (e.g. requiring lib/foo/foo.rb from ext/foo.so).\n"
},
{
"from": "gpt",
"value": "To allow a C-extension in Ruby to use `rb_f_require` to require a Ruby file located o... |
In SQL Server Mgt Studio 2005, when I open the Object Explorer to script an object to a new Query Editor window, the tab for that new script window is titled something like 'MyServerName.MyDatabaseName - sqlquery37.sql'
Not very descriptive. So when I get a bunch of windows open at the same time, I have no idea which ... | In SQL Server Management Studio (SSMS) 2005, the title of the Query Editor window is indeed not very descriptive when scripting objects. Unfortunately, there is no built-in setting to customize the tab names of the query windows directly in SSMS 2005 to include the name of the object being scripted.
However, there ar... | 36,976 | [
{
"from": "human",
"value": "In SQL Server Mgt Studio 2005, when I open the Object Explorer to script an object to a new Query Editor window, the tab for that new script window is titled something like 'MyServerName.MyDatabaseName - sqlquery37.sql' \nNot very descriptive. So when I get a bunch of windows op... |
This question follows on from this vim search question
I have a setting in my .vimrc which excludes $ as a valid part of a word:
set iskeyword-=$
This works fine for most files but isn't working in PHP. I assume it is being overwritten by a php plugin, but since plugins are loaded after .vimrc I can't work out how to ... | You're on the right track with using `autocmd` to set local options for specific file types in Vim. Since you want to ensure that `$` is excluded as a valid part of a word in PHP files, the solution you implemented is perfect.
Here’s a brief overview of your solution and an alternative approach for clarity:
### Solut... | 37,517 | [
{
"from": "human",
"value": "This question follows on from this vim search question\nI have a setting in my .vimrc which excludes $ as a valid part of a word:\nset iskeyword-=$\n\nThis works fine for most files but isn't working in PHP. I assume it is being overwritten by a php plugin, but since plugins are... |
I'm building the HTML code within an XML DOM object to be used as the contents of the innerHTML of a div element using an XSL template. Traditionally we create a new XML DOM document and add the input parameters as XML Elements for the transform via javascript. This is all very time-consuming as we are basically hand p... | Using `.cloneNode(true)` in JavaScript is a common and efficient way to create a copy of a node along with all of its child nodes. In the context of your requirement to copy a relevant node (e.g., customer info) from an XML DOM document and use it for an XSL transformation, this approach is both valid and practical.
#... | 35,996 | [
{
"from": "human",
"value": "I'm building the HTML code within an XML DOM object to be used as the contents of the innerHTML of a div element using an XSL template. Traditionally we create a new XML DOM document and add the input parameters as XML Elements for the transform via javascript. This is all very ... |
this is probably a newbie ruby question. I have several libraries and apps that I need to deploy to several different hosts. All of the apps and libs will share some common settings for those hosts-- e.g. host name, database server/user/pass, etc.
My goal is to do something like:
cap host1 stage deploy
cap host2 stage ... | To achieve your goal of sharing common settings across multiple deploy files in Ruby using Capistrano, you can create a separate Ruby file that contains your common configuration and host-specific settings. This file can then be included in your main `deploy.rb` files. Here’s how you can structure this:
1. **Create a ... | 34,447 | [
{
"from": "human",
"value": "this is probably a newbie ruby question. I have several libraries and apps that I need to deploy to several different hosts. All of the apps and libs will share some common settings for those hosts-- e.g. host name, database server/user/pass, etc.\nMy goal is to do something lik... |
I'm developing a web app with java servlet, I hope to get the user ip info by calling request.getRemoteAddr() from inside processRequest(HttpServletRequest request,HttpServletResponse response).
But it returns a wrong IP. Since I'm not very knowledgeable about this area, I don't know what it is displaying, maybe a pro... | The behavior you're observing is related to the way the IP address is handled in a local development environment. Here’s a breakdown of what's happening:
1. **Local Environment**: When you run a Java servlet on your local machine (using a server like Tomcat or Jetty), requests to your servlet come from your local mach... | 35,602 | [
{
"from": "human",
"value": "I'm developing a web app with java servlet, I hope to get the user ip info by calling request.getRemoteAddr() from inside processRequest(HttpServletRequest request,HttpServletResponse response).\nBut it returns a wrong IP. Since I'm not very knowledgeable about this area, I don... |
I maintain the build system at my company, which is currently using CVS. This build system is used across multiple projects and multiple CVS repositories.
Whenever we have a release milestone, we create a tag. In CVS, this is easy:
$ cvs tag TAG_NAME
That command works regardless of the CVS module or repository, as ... | When transitioning from CVS to Subversion (SVN), the workflow for tagging does indeed change, and you are correct that SVN requires a bit more setup compared to CVS, particularly regarding the directory structure for tags, branches, and trunk.
However, there are ways to simplify the process of tagging in SVN. Below ar... | 35,125 | [
{
"from": "human",
"value": "I maintain the build system at my company, which is currently using CVS. This build system is used across multiple projects and multiple CVS repositories.\nWhenever we have a release milestone, we create a tag. In CVS, this is easy:\n$ cvs tag TAG_NAME\n\nThat command works re... |
How can I create an Oracle stored procedure which accepts a variable number of parameter values used to feed a IN clause?
This is what I am trying to achieve. I do not know how to declare in PLSQL for passing a variable list of primary keys of the rows I want to update.
FUNCTION EXECUTE_UPDATE
( <parameter_list>
... | To create an Oracle stored procedure that accepts a variable number of parameter values for an `IN` clause in PL/SQL, you can use a collection (like a nested table) to hold the values. Here's a step-by-step guide on how to achieve this.
### Step 1: Create a Type for the Collection
First, you need to define a PL/SQL t... | 35,604 | [
{
"from": "human",
"value": "How can I create an Oracle stored procedure which accepts a variable number of parameter values used to feed a IN clause?\nThis is what I am trying to achieve. I do not know how to declare in PLSQL for passing a variable list of primary keys of the rows I want to update.\nFUNCT... |
In working on a shortest path algorithm across a network I would like to generate a picture of the network. I'd like to represent nodes (circles), links (lines), cost to traverse the link (number in the middle of the link line), and capacity of the link (number on the link line next to the node it represents) in the pi... | Yes, there are several libraries and software options that can help you automate the generation of network diagrams from code. Here are some popular ones:
### 1. **Graphviz**
- **Description**: Graphviz is a powerful open-source graph visualization software that allows you to represent networks as directed or undir... | 33,145 | [
{
"from": "human",
"value": "In working on a shortest path algorithm across a network I would like to generate a picture of the network. I'd like to represent nodes (circles), links (lines), cost to traverse the link (number in the middle of the link line), and capacity of the link (number on the link line ... |
The following code says that passing the map as const into the operator[] method discards qualifiers:
#include <iostream>
#include <map>
#include <string>
using namespace std;
class MapWrapper {
public:
const int &get_value(const int &key) const {
return _map[key];
}
private:
map<int, int> _map;
... | The error you are encountering arises from the use of the `operator[]` on the `std::map` within the `MapWrapper` class. Specifically, `operator[]` is not a `const` operation, and therefore it cannot be used in a method declared as `const`.
### Understanding the Issue
When you call `map[key]`, it not only retrieves th... | 35,113 | [
{
"from": "human",
"value": "The following code says that passing the map as const into the operator[] method discards qualifiers:\n#include <iostream>\n#include <map>\n#include <string>\n\nusing namespace std;\n\nclass MapWrapper {\npublic:\n const int &get_value(const int &key) const {\n return ... |
I've compiled a java project into a Jar file, and am having issues running it.
When I run:
java -jar myJar.jar
I get the following error
Could not find the main class: myClass
The class file is not in the root directory of the jar so I've tried changing the path of the main class to match the path to the class file a... | From the details you've provided, it looks like your JAR file's structure and the `MANIFEST.MF` file are properly configured for running the JAR file. However, the error message indicates that the Java runtime cannot find the specified main class.
Here's a step-by-step guide to help troubleshoot and ensure that every... | 35,845 | [
{
"from": "human",
"value": "I've compiled a java project into a Jar file, and am having issues running it.\nWhen I run:\njava -jar myJar.jar\n\nI get the following error\nCould not find the main class: myClass\n\nThe class file is not in the root directory of the jar so I've tried changing the path of the ... |
I just watched the last Channel 9 vid on the upcoming parallel extensions to .NET.
How would you use this in a web app? I'm specifically thinking of using the parallel Linq extensions against a SQL db. Would this makes sense to use as a way to speed up your data access layer in a multi-user server app? What are the iss... | Using the upcoming parallel extensions in .NET, particularly PLINQ (Parallel LINQ), in a web application can provide benefits when you have a scenario that allows for parallel processing of data. However, when it comes to using PLINQ against a SQL database, there are several considerations and potential issues to keep ... | 34,893 | [
{
"from": "human",
"value": "I just watched the last Channel 9 vid on the upcoming parallel extensions to .NET.\nHow would you use this in a web app? I'm specifically thinking of using the parallel Linq extensions against a SQL db. Would this makes sense to use as a way to speed up your data access layer in... |
I am working on a small project to take a CSV file and then insert its data into a HTML table (I would use datagrid and dataset or datatable, but the system I will be talking to does not support ASP.NET uploads for sending newsletters).
Anyway, I will use the file.readalllines method to return the contents of the csv f... | To parse a CSV file that includes multi-word fields (like car names), you need to be careful about how you split the strings. Instead of splitting directly on spaces, which would split words like "Almera 1.4 TDi" into separate elements, you should look for a more robust way to handle this.
Here are some options to con... | 35,894 | [
{
"from": "human",
"value": "I am working on a small project to take a CSV file and then insert its data into a HTML table (I would use datagrid and dataset or datatable, but the system I will be talking to does not support ASP.NET uploads for sending newsletters).\nAnyway, I will use the file.readalllines ... |
Currently I have an application that receives an uploaded file from my web application. I now need to transfer that file to a file server which happens to be located on the same network (however this might not always be the case).
I was attempting to use the webclient class in C# .NET.
string filePath = "C:\\test\\... | It looks like you're trying to upload a file to a network share using the `WebClient` class, but there are a couple of issues that you may encounter, particularly with how network shares are handled in .NET.
### Issues:
1. **Network Path Format**: When dealing with network paths in a URI, it needs to be formatted pro... | 31,633 | [
{
"from": "human",
"value": "Currently I have an application that receives an uploaded file from my web application. I now need to transfer that file to a file server which happens to be located on the same network (however this might not always be the case).\nI was attempting to use the webclient class in ... |
I have a linker command file that assigns the top address of the stack into a variable
_stack = . + 0x80000;
I want to use this address in a 'c' program - I want to copy the stack to another location and then update the stack pointer to point to the new location before doing a destructive memory test on the orginal... | The behavior you're experiencing seems to stem from how you're defining and using the `_stack` variable in your C program. In your case, `_stack` is being treated as a pointer to the address of the stack, but it seems that you're inadvertently dereferencing it when passing it to the function.
Here's a step-by-step gui... | 26,148 | [
{
"from": "human",
"value": "I have a linker command file that assigns the top address of the stack into a variable \n_stack = . + 0x80000; \n\nI want to use this address in a 'c' program - I want to copy the stack to another location and then update the stack pointer to point to the new location before do... |
I want to limit the number of words a person can enter in a text field. How can I track the number of words (by using a second field) in that field as each word is entered?
| To track the number of words entered in a text field and display this count in a second field, you can use JavaScript to count the words dynamically as the user types. Here’s a simple implementation using HTML and JavaScript:
### HTML Structure
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">... | 32,884 | [
{
"from": "human",
"value": "I want to limit the number of words a person can enter in a text field. How can I track the number of words (by using a second field) in that field as each word is entered?\n"
},
{
"from": "gpt",
"value": "To track the number of words entered in a text field and dis... |
my question is similar to other friend posted here...we are trying to develop an application that supports possibly terabytes of information based on a land registry in Paraguay with images and normal data.
The problem is that we want to reduce the cost of operation to minimum as possible because it´s like a competiti... | When developing an application for a land registry system that needs to handle potentially terabytes of data, while also being cost-effective and easy to manage, several factors come into play. Here are some recommendations for choosing a database and other considerations for your project:
### Database Options
1. **P... | 35,306 | [
{
"from": "human",
"value": "my question is similar to other friend posted here...we are trying to develop an application that supports possibly terabytes of information based on a land registry in Paraguay with images and normal data.\nThe problem is that we want to reduce the cost of operation to minimum... |
I was very impressed with the OpenCalais system. It's (is/has) a web service where you send your text, they analyze it, then you are provided with a series of categorized (RDF enabled) tags that your document belongs to.
But - at the moment - English is the only supported language.
Do you know of similar systems that h... | Yes, there are several systems and services that provide text analysis and categorization for multiple languages, including Italian. Here are a few you might find interesting:
1. **IBM Watson Natural Language Understanding**: IBM's NLU service supports multiple languages, including Italian. It offers features like ent... | 38,220 | [
{
"from": "human",
"value": "I was very impressed with the OpenCalais system. It's (is/has) a web service where you send your text, they analyze it, then you are provided with a series of categorized (RDF enabled) tags that your document belongs to.\nBut - at the moment - English is the only supported langu... |
I'm new with Objective-C, so there probably is a simple solution to this.
I want a number to increment, but each iteration to be show on a label. (for example, it shows 1, 2, 3, 4, 5... displayed apart by an amount of time).
I tried:
#import "testNums.h"
@implementation testNums
- (IBAction)start:(id)sender {
int ... | The issue you're encountering is due to the use of the `sleep` function inside the main thread. When you call `sleep`, it blocks the entire main thread, including the UI thread, which is why your label only updates after the loop completes.
To update the UI in a non-blocking manner, you can use a timer to handle the i... | 36,315 | [
{
"from": "human",
"value": "I'm new with Objective-C, so there probably is a simple solution to this.\nI want a number to increment, but each iteration to be show on a label. (for example, it shows 1, 2, 3, 4, 5... displayed apart by an amount of time).\nI tried:\n#import \"testNums.h\"\n\n@implementation ... |
Given two interface references obtained from different sources. Is there a programmatic way to tell whether they're implemented by the same instance?
A simple equality check of the interface references always fails.
EDIT: Large parts of the original question, which turned out to be an independent problem have now been... | In C#, when you have two references to interfaces that are derived from the same underlying object, a simple equality check (`==`) on the interface references will indeed fail because each reference is treated as a distinct object, even though they might refer to the same instance of an object that implements the inter... | 37,927 | [
{
"from": "human",
"value": "Given two interface references obtained from different sources. Is there a programmatic way to tell whether they're implemented by the same instance?\nA simple equality check of the interface references always fails.\n\nEDIT: Large parts of the original question, which turned ou... |
This is a question already asked by someone:
How can an Eclipse plugin access the project directory?
The answer was good: using ResourcesPlugin.
But for some reason, under no circumstances will my Ganymede eclipse recognise the existence of org.eclipse.core.resources package which contains ResourcesPlugin.
Why is that?... | The issue you are experiencing with accessing the `org.eclipse.core.resources` package in Eclipse Ganymede could be due to several factors. Here are some potential reasons and solutions:
1. **Missing Plugin in the Target Platform**: Ganymede is an older version of Eclipse (released in 2008), and it may not include cer... | 37,210 | [
{
"from": "human",
"value": "This is a question already asked by someone:\nHow can an Eclipse plugin access the project directory?\nThe answer was good: using ResourcesPlugin.\nBut for some reason, under no circumstances will my Ganymede eclipse recognise the existence of org.eclipse.core.resources package ... |
I have a php script that is executing an executable that writes to a serial port.
However, everytime it runs system("c:\Untitled1.exe")
it just opens up a cmd window and freezes.
Anybody know how to fix this? Or if there is an easier way to get PHP to write to the serial port directly? (I've already tried these two: ht... | When you're trying to run a system command in PHP that interacts with hardware (like a serial port), it can be tricky, especially on Windows. Here are a few suggestions to help you troubleshoot and potentially solve the problem:
### 1. Modify the Command Execution:
When calling an executable from PHP, you might want t... | 36,598 | [
{
"from": "human",
"value": "I have a php script that is executing an executable that writes to a serial port.\nHowever, everytime it runs system(\"c:\\Untitled1.exe\")\nit just opens up a cmd window and freezes.\nAnybody know how to fix this? Or if there is an easier way to get PHP to write to the serial p... |
I have a radajaxpanel that is populated with the selected item from a combobox on another update panel. Currently the radajaxpanel is the same background color as the rest of the page. What I'd like to do, is based on it being populated with data, change it's background color to a muted red.
I want it to stand out as... | To achieve a fading effect for the background color of your RadAjaxPanel after a selection is made in the ComboBox, you can use jQuery along with CSS. This will allow you to change the background color to a muted red gradually. Below are the steps to implement this:
1. **Include jQuery**: Ensure that you have jQuery i... | 35,884 | [
{
"from": "human",
"value": "I have a radajaxpanel that is populated with the selected item from a combobox on another update panel. Currently the radajaxpanel is the same background color as the rest of the page. What I'd like to do, is based on it being populated with data, change it's background color ... |
How do I make the XDocument object save an attribute value of a element with single quotes?
| In an `XDocument` object, you can set attribute values using either double quotes or single quotes. However, the XML specification states that attribute values must be quoted with either single or double quotes, but not both. When you save an `XDocument`, it doesn't natively allow you to control the quoting style of th... | 37,976 | [
{
"from": "human",
"value": "How do I make the XDocument object save an attribute value of a element with single quotes?\n"
},
{
"from": "gpt",
"value": "In an `XDocument` object, you can set attribute values using either double quotes or single quotes. However, the XML specification states that... |
To support multiple platforms in C/C++, one would use the preprocessor to enable conditional compiles. E.g.,
#ifdef _WIN32
#include <windows.h>
#endif
How can you do this in Ada? Does Ada have a preprocessor?
| Ada does not have a traditional preprocessor like C/C++. However, you can achieve similar conditional compilation behavior using Ada's built-in mechanisms, primarily through the use of **pragma** and **conditional compilation** directives.
The main tool for conditional compilation in Ada is the `pragma` directive comb... | 35,102 | [
{
"from": "human",
"value": "To support multiple platforms in C/C++, one would use the preprocessor to enable conditional compiles. E.g.,\n#ifdef _WIN32\n #include <windows.h>\n#endif\n\nHow can you do this in Ada? Does Ada have a preprocessor?\n"
},
{
"from": "gpt",
"value": "Ada does not have... |
I have the default that vs.net creates in a MVC app:
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = "" } // Parameter defaults
);
I also ... | To catch routes in ASP.NET MVC that match the pattern you described (where you want to capture any text after the domain name that does not contain a forward slash `/`), you can add an additional route before the default route.
Here's how you can modify your routing configuration to achieve this:
```csharp
public cla... | 36,042 | [
{
"from": "human",
"value": "I have the default that vs.net creates in a MVC app:\nroutes.MapRoute(\n \"Default\", // Route name\n \"{controller}/{action}/{id}\", // URL with parameters\n new { controller = \"Home\", action = \"... |
I need to convert several Java classes to C#, but I have faced few problems.
In Java I have following class hierarchy:
public abstract class AbstractObject {
public String getId() {
return id;
}
}
public class ConcreteObject extends AbstractObject {
public void setId(String id) {
this.id= ... | Yes, it's definitely possible to convert the given Java class hierarchy to C# using properties. In C#, properties provide a way to encapsulate the field access in a manner similar to getters and setters in Java, but with a more concise syntax. You can declare a read-only property in the abstract base class and a read-w... | 38,365 | [
{
"from": "human",
"value": "I need to convert several Java classes to C#, but I have faced few problems.\nIn Java I have following class hierarchy:\npublic abstract class AbstractObject {\n public String getId() {\n return id;\n } \n}\n\npublic class ConcreteObject extends AbstractObject {\n ... |
Anyone know whether it is possible to put mod_python under JBoss like you can Apache HTTPD? Given that JBoss has Tomcat inside it would seem to be a reasonable thing to do.
If not mod_python is there any python support under JBoss which will keep the interpreter in memory?
| As of my last knowledge update in October 2023, mod_python is specifically designed to work with the Apache HTTP Server and is not directly compatible with JBoss, which uses an embedded version of Tomcat for its servlet container. Since JBoss is primarily a Java-based application server, there are limited native suppor... | 36,289 | [
{
"from": "human",
"value": "Anyone know whether it is possible to put mod_python under JBoss like you can Apache HTTPD? Given that JBoss has Tomcat inside it would seem to be a reasonable thing to do.\nIf not mod_python is there any python support under JBoss which will keep the interpreter in memory?\n"
... |
In Linqtosql how do I show items from multiple rows in a single field.
eg I have a 3 table setup for tagging(entity, tag, entitytag) all linked via foreign keys.
For each entity I would like to return the name in one field and then all relevant tags in 2nd field.
eg Item1, tag1; tag2; tag3
Item2, tag4, tag5....
VB s... | To achieve the desired output using LINQ to SQL in VB.NET, you can utilize the `GroupBy` and `Select` methods to aggregate tags related to each entity. Below is a basic example based on your table structure (`Entity`, `Tag`, and `EntityTag`).
Assuming you have the following class definitions:
```vb.net
Public Class ... | 37,062 | [
{
"from": "human",
"value": "In Linqtosql how do I show items from multiple rows in a single field.\neg I have a 3 table setup for tagging(entity, tag, entitytag) all linked via foreign keys.\nFor each entity I would like to return the name in one field and then all relevant tags in 2nd field.\neg Item1, ta... |
I am making a post from a .NET console app to a .NET web service. I know that the timeout on the server side is 20 min, but if my client takes more than 100 seconds to post my data to that service then I get a timeout exception. How would I tell my client to wait the available 20 min to timeout?
| To extend the timeout for your .NET console application's HTTP requests, you can set the `Timeout` property on the `HttpClient` or `HttpClientHandler` that you're using to send the POST request.
Here's an example of how to configure the `HttpClient` to wait up to 20 minutes (1200 seconds):
### Using `HttpClient`
```... | 37,219 | [
{
"from": "human",
"value": "I am making a post from a .NET console app to a .NET web service. I know that the timeout on the server side is 20 min, but if my client takes more than 100 seconds to post my data to that service then I get a timeout exception. How would I tell my client to wait the available... |
How can I get the name of a file in in PHP? What I want to do is have a function take a string of a filename and then do some stuff if it's actually on the page.
function onThisPageFunction(fileNameFromFunction)
{
if(onThisPage == fileNameFromFunction)
{
do stuff
}
}
| To get the name of the currently executing PHP file in order to compare it with a filename passed to a function, you can use the `basename()` function along with the `$_SERVER['PHP_SELF']` superglobal. This will give you the name of the file that is currently being executed.
Here's how you can implement the `onThisPag... | 37,013 | [
{
"from": "human",
"value": "How can I get the name of a file in in PHP? What I want to do is have a function take a string of a filename and then do some stuff if it's actually on the page.\nfunction onThisPageFunction(fileNameFromFunction) \n{ \n if(onThisPage == fileNameFromFunction) \n { \n d... |
How do you get the current time (not date AND time)?
Example: 5:42:12 PM
| To get the current time in the format you specified (e.g., "5:42:12 PM"), you can use different methods depending on the programming language you're working with. Here are a few examples in popular languages:
### Python
```python
from datetime import datetime
current_time = datetime.now().strftime("%I:%M:%S %p")
prin... | 37,478 | [
{
"from": "human",
"value": "How do you get the current time (not date AND time)?\nExample: 5:42:12 PM\n"
},
{
"from": "gpt",
"value": "To get the current time in the format you specified (e.g., \"5:42:12 PM\"), you can use different methods depending on the programming language you're working w... |
At work, we have one of those nasty communal urinals. There is no flush handle. Rather, it has a motion sensor that sometimes triggers when you stand in front of it and sometimes doesn't. When it triggers, a tank fills, which when full is used to flush the urinal.
In my many trips before this nastraption, I have ponder... | That's an interesting problem, and there are certainly a few factors to consider for designing an optimal flushing algorithm for a motion-sensor urinal.
### Factors to Consider:
1. **Usage Frequency**: Monitoring how often the urinal is used can help determine how often to flush. If the urinal is used frequently, mor... | 35,513 | [
{
"from": "human",
"value": "At work, we have one of those nasty communal urinals. There is no flush handle. Rather, it has a motion sensor that sometimes triggers when you stand in front of it and sometimes doesn't. When it triggers, a tank fills, which when full is used to flush the urinal.\nIn my many tr... |
If you know the Index, Value or Text. also if you don't have an ID for a direct reference.
This, this and this are all helpful answers.
Example markup
<div class="selDiv">
<select class="opts">
<option selected value="DEFAULT">Default</option>
<option value="SEL1">Selection 1</option>
<option value="SEL2"... | It seems like you're looking for a way to interact with HTML markup, specifically a `<select>` dropdown, based on different properties such as index, value, or text. Below are examples of how to select an option from the dropdown using JavaScript, depending on what information you have:
### Using Index
If you want to ... | 37,148 | [
{
"from": "human",
"value": "If you know the Index, Value or Text. also if you don't have an ID for a direct reference.\nThis, this and this are all helpful answers.\nExample markup\n<div class=\"selDiv\">\n <select class=\"opts\">\n <option selected value=\"DEFAULT\">Default</option>\n <option value... |
I'm trying to figure out how to pass arguments to an anonymous function in JavaScript.
Check out this sample code and I think you will see what I mean:
<input type="button" value="Click me" id="myButton" />
<script type="text/javascript">
var myButton = document.getElementById("myButton");
var myMessage = "it'... | In your current code, the parameter `myMessage` in the anonymous function shadows the outer variable `myMessage`. This means that when you click the button, the anonymous function's `myMessage` parameter is `undefined` because it's not receiving any arguments from the click event.
To pass the value of the outer `myMes... | 32,603 | [
{
"from": "human",
"value": "I'm trying to figure out how to pass arguments to an anonymous function in JavaScript.\nCheck out this sample code and I think you will see what I mean:\n<input type=\"button\" value=\"Click me\" id=\"myButton\" />\n\n<script type=\"text/javascript\">\n var myButton = documen... |
If I wanted to get a pilot project off the ground using Microsoft PixelSense, where or who do I ask for testing hardware?
| To get a pilot project off the ground using Microsoft PixelSense (now known as Samsung’s Flip or similar interactive display technologies), you can consider the following steps to find hardware for testing:
1. **Contact Microsoft or Samsung**: Depending on the current branding of the technology, reach out directly to ... | 37,649 | [
{
"from": "human",
"value": "If I wanted to get a pilot project off the ground using Microsoft PixelSense, where or who do I ask for testing hardware?\n"
},
{
"from": "gpt",
"value": "To get a pilot project off the ground using Microsoft PixelSense (now known as Samsung’s Flip or similar interac... |
Why does Resharper want you to change most variables to var type instead of the actual type in the code?
| ReSharper, a popular productivity extension for Visual Studio, often encourages developers to use the `var` keyword instead of explicitly specifying the type for variables. Here are several reasons why it promotes this practice:
1. **Type Inference**: The C# compiler uses type inference to determine the type of the va... | 36,975 | [
{
"from": "human",
"value": "Why does Resharper want you to change most variables to var type instead of the actual type in the code?\n"
},
{
"from": "gpt",
"value": "ReSharper, a popular productivity extension for Visual Studio, often encourages developers to use the `var` keyword instead of ex... |
Does anyone have any good font and colour themes for Visual Studio that will give me nice support for Resharper? The majority of themes out there don't support Resharper, and as such all the extra R# highlighting looks rubbish...
Cheers!
Matt
| Finding a good font and color theme for Visual Studio that also supports ReSharper can indeed be challenging. Here are a few recommendations that you might find helpful:
### 1. **One Dark Pro**
- **Description**: This is a popular theme based on the One Dark syntax theme from Atom. It offers a dark background with vib... | 35,739 | [
{
"from": "human",
"value": "Does anyone have any good font and colour themes for Visual Studio that will give me nice support for Resharper? The majority of themes out there don't support Resharper, and as such all the extra R# highlighting looks rubbish...\nCheers!\nMatt\n"
},
{
"from": "gpt",
... |
This isn't about a specific language, rather about the iTunes COM interface.
I managed to add a file to the library with .AddFile(), but now that the file is there I'd like to read some details about it such as the artist, song, and album. Since the song doesn't automatically play, I can't really use CurrentTrack() for... | Yes, you can retrieve details about the last file added to your iTunes library using the iTunes COM interface, even if it hasn't been played. While iTunes doesn't directly provide a method to get the last added track, you can achieve this by sorting the library by the date added attribute.
Here's how you can do it:
1... | 37,638 | [
{
"from": "human",
"value": "This isn't about a specific language, rather about the iTunes COM interface.\nI managed to add a file to the library with .AddFile(), but now that the file is there I'd like to read some details about it such as the artist, song, and album. Since the song doesn't automatically p... |
I have a requirement to extract a distinct subset of rows from a DataTable, and thought LINQ2DataSets may be a useful and clean way to do this, however it appears that it is not possible to simply identify return rows from a LINQ2DS query as follows
var result = from r in fips.AsEnumerable() select
r.Field<string>("FAC... | You're correct that the syntax you provided will generate an error because the LINQ query syntax does not allow for multiple selected fields to be separated by commas in that manner. Instead, you should create an anonymous type to encapsulate the multiple fields you want to return. Here’s how you can achieve that:
```... | 37,511 | [
{
"from": "human",
"value": "I have a requirement to extract a distinct subset of rows from a DataTable, and thought LINQ2DataSets may be a useful and clean way to do this, however it appears that it is not possible to simply identify return rows from a LINQ2DS query as follows\nvar result = from r in fips.... |
How can I add a plaintext into encrypted ciphertext?
For example, I would like to add number 4 into encrypted(5)
| Adding plaintext to encrypted ciphertext directly is generally not feasible without the proper cryptographic scheme that allows for such operations. However, there are specific types of encryption methods that facilitate this kind of operation, most notably homomorphic encryption.
### Homomorphic Encryption
Homomorph... | 37,892 | [
{
"from": "human",
"value": "How can I add a plaintext into encrypted ciphertext?\nFor example, I would like to add number 4 into encrypted(5)\n"
},
{
"from": "gpt",
"value": "Adding plaintext to encrypted ciphertext directly is generally not feasible without the proper cryptographic scheme that... |
I have to have my website stored in a subfolder of my domain root. Is there a way to rewrite the URLs so that it doesn't appear to be stored in a subfolder? It doesn't matter to me if this is done at the IIS level or in the web.config.
| Yes, you can use URL rewriting in IIS to make it appear as though your website is hosted at the root of your domain, even if it’s actually stored in a subfolder. This can be done using the `web.config` file of your application. Below are the steps and a basic example of how to achieve this.
### Step 1: Enable URL Rewr... | 34,444 | [
{
"from": "human",
"value": "I have to have my website stored in a subfolder of my domain root. Is there a way to rewrite the URLs so that it doesn't appear to be stored in a subfolder? It doesn't matter to me if this is done at the IIS level or in the web.config.\n"
},
{
"from": "gpt",
"value... |
I need to cast single figures (1 to 9) to (01 to 09). I can think of a way but its big and ugly and cumbersome. I'm sure there must be some concise way. Any Suggestions
| You can easily format single-digit numbers to have a leading zero by using Python's string formatting methods. Here are a few concise ways to achieve this:
1. **Using f-strings (Python 3.6 and later)**:
```python
number = 5
formatted_number = f"{number:02}"
print(formatted_number) # Output: 05
```
2. ... | 39,429 | [
{
"from": "human",
"value": "I need to cast single figures (1 to 9) to (01 to 09). I can think of a way but its big and ugly and cumbersome. I'm sure there must be some concise way. Any Suggestions\n"
},
{
"from": "gpt",
"value": "You can easily format single-digit numbers to have a leading zero... |
This is one of those meta-programming questions that may or may not belong on SO, but here goes...
Have any other programmers out there noticed that their ability to communicate with people (technical or otherwise) almost disappears during and after a period of intense programming?
I normally think of myself as a relat... | Yes, many programmers and people in technical fields have experienced a similar phenomenon, often referred to as "cognitive fatigue" or "mental fatigue." When you engage in intense programming or problem-solving for an extended period, your brain can become overloaded, leading to a temporary decline in other cognitive ... | 38,844 | [
{
"from": "human",
"value": "This is one of those meta-programming questions that may or may not belong on SO, but here goes...\nHave any other programmers out there noticed that their ability to communicate with people (technical or otherwise) almost disappears during and after a period of intense programm... |
Is there any way to 'hide' the name of a class, whose sole purpose is to provide extension methods, from Intellisense?
I would like to remove the class name from the Intellisense list but need the extension methods of the class to be available to external assemblies via Intellisense in the usual way.
| In C#, it's not possible to completely hide a class from IntelliSense while still allowing its extension methods to be available. However, you can manage the visibility of the class and its members to some extent using access modifiers and specific attributes. Here are a few approaches you might consider:
### 1. **Use... | 36,521 | [
{
"from": "human",
"value": "Is there any way to 'hide' the name of a class, whose sole purpose is to provide extension methods, from Intellisense? \nI would like to remove the class name from the Intellisense list but need the extension methods of the class to be available to external assemblies via Intell... |
I came across this snippet of code on MSDN:
entityBuilder.Metadata = @"res://*/AdventureWorksModel.csdl|
res://*/AdventureWorksModel.ssdl|
res://*/AdventureWorksModel.msl";
What does the res://*/ mean and how does it work? I think it has to do with resource files... | The `res://*/` syntax in the code snippet you provided is indeed related to resource files in the context of .NET applications, specifically with Entity Framework and its metadata handling for models.
### Explanation of `res://*/`
- **`res://`**: This indicates that the following resource is being accessed from an em... | 37,635 | [
{
"from": "human",
"value": "I came across this snippet of code on MSDN:\nentityBuilder.Metadata = @\"res://*/AdventureWorksModel.csdl|\n res://*/AdventureWorksModel.ssdl|\n res://*/AdventureWorksModel.msl\";\n\nWhat does the res://*/ mean and how does i... |
Which GUI framework/library would you choose if you were to start your new project now or in the near future?
It has to be free for commercial use and cross platform.
I have been a happy swing user, but Sun seems like pushing swing to deprecation, while pushing Javafx, which is not yet ready for prime time.
There's als... | If I were starting a new project in the near future and needed a free, cross-platform GUI framework/library, I would consider the following options:
1. **JavaFX**: Despite your concerns about JavaFX not being ready for prime time, it has become the recommended GUI toolkit for Java development. JavaFX is designed to re... | 37,777 | [
{
"from": "human",
"value": "Which GUI framework/library would you choose if you were to start your new project now or in the near future?\nIt has to be free for commercial use and cross platform.\nI have been a happy swing user, but Sun seems like pushing swing to deprecation, while pushing Javafx, which i... |
Applications like CCTray allow one to specify a sound clip to indicate that a build is successful or that a build failed. I'm interested to hear what set of sounds different teams are using.
Here are two sets that we use:
Homer Simpson: "d'oh" for a build failure, "woohoo!" for success
Mario bros: power down sound for... | It's great that you have fun sound cues for build notifications! Here are a few additional ideas that different teams might enjoy:
1. **Classic Video Game Sounds**:
- **Pac-Man**: "Waka Waka" for success, "Game Over" for failure.
- **Zelda**: "Item Get" sound for a successful build, "Failure" sound for a build f... | 38,485 | [
{
"from": "human",
"value": "Applications like CCTray allow one to specify a sound clip to indicate that a build is successful or that a build failed. I'm interested to hear what set of sounds different teams are using.\nHere are two sets that we use:\n\nHomer Simpson: \"d'oh\" for a build failure, \"woohoo... |
In C#
I have a processing time number data column in the database which is in in this format "###" or "##" ( eg: "813" or "67")
When I bind it to the grid view I wanted to display it in this format "0.###" (eg: "0.813" or "0.067")
I tried using {0:0.000} and other formatings. But none seem to work. Can anyone tell me h... | To display your processing time values in the desired format (`"0.###"`) in a GridView in C#, you can use a combination of data formatting and possibly a custom display format in your GridView column.
If you're using a data-bound GridView in ASP.NET or WinForms, here's how you can achieve that:
### Example for ASP.NE... | 37,057 | [
{
"from": "human",
"value": "In C#\nI have a processing time number data column in the database which is in in this format \"###\" or \"##\" ( eg: \"813\" or \"67\")\nWhen I bind it to the grid view I wanted to display it in this format \"0.###\" (eg: \"0.813\" or \"0.067\")\nI tried using {0:0.000} and oth... |
I want to have an executable file that will call some other programs. The way I would do this in Linux is with a simple bash script that looks like this:
#!/bin/bash
echo "running some-program"
/home/murat/some-program arg1 arg2
What's the best way to do this kind of thing under Windows?
| In Windows, you can achieve similar functionality using a batch file (with a `.bat` or `.cmd` extension). A batch file can execute a series of commands, similar to a bash script. Here's how you can create a batch file that runs your specified programs:
1. **Create a new text file** with a `.bat` extension. For example... | 37,470 | [
{
"from": "human",
"value": "I want to have an executable file that will call some other programs. The way I would do this in Linux is with a simple bash script that looks like this:\n#!/bin/bash\necho \"running some-program\"\n/home/murat/some-program arg1 arg2\n\nWhat's the best way to do this kind of thi... |
If I have a string "12 23 34 56"
What's the easiest way to change it to "\x12 \x23 \x34 \x56"?
| You can achieve this by using string manipulation in Python. Here’s a straightforward way to replace spaces with the appropriate hexadecimal escape sequences:
```python
input_string = "12 23 34 56"
# Split the string by spaces, convert each part to the desired format and then join them back
output_string = ' '.join([f... | 39,274 | [
{
"from": "human",
"value": "If I have a string \"12 23 34 56\"\nWhat's the easiest way to change it to \"\\x12 \\x23 \\x34 \\x56\"?\n"
},
{
"from": "gpt",
"value": "You can achieve this by using string manipulation in Python. Here’s a straightforward way to replace spaces with the appropriate h... |
I just installed a linux system (Kubuntu) and was wondering if there is a program to make python programs executable for linux.
| Yes, you can easily make Python scripts executable in a Linux environment, including Kubuntu. Here’s how you can do it:
### Step 1: Write Your Python Script
First, ensure you have your Python script ready. For example, let's say your script is named `my_script.py`.
### Step 2: Add the Shebang Line
At the top of your ... | 36,267 | [
{
"from": "human",
"value": "I just installed a linux system (Kubuntu) and was wondering if there is a program to make python programs executable for linux.\n"
},
{
"from": "gpt",
"value": "Yes, you can easily make Python scripts executable in a Linux environment, including Kubuntu. Here’s how y... |
I have a .net client application which is connected to a remote database.
Is it safe to keep a single connection open for the lifetime of the client (hours)?
Does the answer hold if I have multiple (10 or 100) clients running?
| Keeping a single database connection open for the lifetime of a .NET client application can be acceptable in certain scenarios, but there are several factors to consider to determine whether it's safe and appropriate for your specific use case:
### Considerations for a Single Connection
1. **Connection Pooling**: Mos... | 35,668 | [
{
"from": "human",
"value": "I have a .net client application which is connected to a remote database.\nIs it safe to keep a single connection open for the lifetime of the client (hours)?\nDoes the answer hold if I have multiple (10 or 100) clients running?\n"
},
{
"from": "gpt",
"value": "Keepi... |
The first batch file launches a command prompt, i need the second command to be in the ccontext of the first. how can I do this in python?
As is, it launches the batch, and blocks until the batch (with its command prompt context) terminates, and then executes devenv without the necessary context.
os.system(r'%comspec%... | To achieve what you're looking for, you can use the `subprocess` module in Python to create a single command that executes both the batch file and then runs the `devenv` command in the same context. This is a common requirement when you need to maintain environment changes made by a script (like `vcvarsall.bat`) for su... | 34,717 | [
{
"from": "human",
"value": "The first batch file launches a command prompt, i need the second command to be in the ccontext of the first. how can I do this in python?\nAs is, it launches the batch, and blocks until the batch (with its command prompt context) terminates, and then executes devenv without th... |
Is it possible for a Symbian S60 application to automatically add itself to one of the softkeys. The best would be if it could be done at installation time but if there is some API that can be used to add a shortcut the first time the application runs that would also be ok in our case.
Does Symbian has some best practi... | In the Symbian S60 platform, applications do not have the capability to automatically add themselves to the softkeys or modify softkey assignments at installation time or during execution. This restriction is in place primarily to enhance user control over their device environment and to prevent applications from overr... | 38,079 | [
{
"from": "human",
"value": "Is it possible for a Symbian S60 application to automatically add itself to one of the softkeys. The best would be if it could be done at installation time but if there is some API that can be used to add a shortcut the first time the application runs that would also be ok in ou... |
Is there a way that I can configure Visual Studio 2008 to understand CamelCase? Specifically, I'd like to be able to get Ctrl + right or left cursor to take me to a subsection of a variable or type name.
i.e., if my cursor was at the start of this line:
LongNamedExampleClass longNamed = new LongNamedExampleClass();
a... | Visual Studio 2008 does not natively support jumping between segments of CamelCase identifiers using `Ctrl + left/right arrow` like you can in Eclipse. However, there are a few approaches you can consider to achieve a similar functionality:
### 1. **Use an Extension**
Extensions can enhance Visual Studio's capabilitie... | 36,662 | [
{
"from": "human",
"value": "Is there a way that I can configure Visual Studio 2008 to understand CamelCase? Specifically, I'd like to be able to get Ctrl + right or left cursor to take me to a subsection of a variable or type name.\ni.e., if my cursor was at the start of this line:\nLongNamedExampleClass ... |
Is there a way to have the compile deduce the template parameter automatically?
template<class T>
struct TestA
{
TestA(T v) {}
};
template<class T>
void TestB(T v)
{
}
int main()
{
TestB (5);
}
Test B works fine, however when i change it to TestA it will not compile with the error " use of class template re... | In C++, you can't call a class template without specifying its template parameters. This is unlike function templates, which allow template argument deduction from the function parameters.
When you attempt to create an instance of `TestA` in your `main` function, you need to explicitly specify the template argument. ... | 35,854 | [
{
"from": "human",
"value": "Is there a way to have the compile deduce the template parameter automatically?\ntemplate<class T> \nstruct TestA \n{\n TestA(T v) {} \n};\ntemplate<class T>\nvoid TestB(T v)\n{\n}\nint main()\n{\n TestB (5);\n}\n\nTest B works fine, however when i change it to TestA it wi... |
RDBMS packages today offer a tremendous amount of functionality beyond standard data storage and retrieval. SQL Server for example can send emails, expose web service methods, and execute CLR code amongst other capabilities. However, I have always tried to limit the amount of processing my database server does to jus... | Deciding how much functionality or code to implement directly on your database server versus other servers in your architecture is an important architectural consideration that can affect performance, scalability, maintainability, and security. Here are some factors to consider along with recommendations for those star... | 31,942 | [
{
"from": "human",
"value": "RDBMS packages today offer a tremendous amount of functionality beyond standard data storage and retrieval. SQL Server for example can send emails, expose web service methods, and execute CLR code amongst other capabilities. However, I have always tried to limit the amount of ... |
I have been working with hibernate/JPA on JBoss for some months now and have one question that I can't find an answer or solution for.
It seems like when creating new entity beans I'm not able to do a query before I at least have called EntityManager.persist(entityBean), or else I get the following error:
TransientObje... | The error you're encountering (`TransientObjectException: object references an unsaved transient instance`) occurs because you are attempting to reference an entity (in your case, `Job`) that has not yet been persisted in the database. The JPA provider requires that all references to entities in relationships are manag... | 34,857 | [
{
"from": "human",
"value": "I have been working with hibernate/JPA on JBoss for some months now and have one question that I can't find an answer or solution for.\nIt seems like when creating new entity beans I'm not able to do a query before I at least have called EntityManager.persist(entityBean), or els... |
I'm having some trouble with ASP.NET MVC Beta, and the idea of making routes, controller actions, parameters on those controller actions and Html.ActionLinks all work together. I have an application that I'm working on where I have a model object called a Plot, and a corresponding PlotController. When a user creates a ... | It sounds like you are on the right track with your ASP.NET MVC application, but there are a few adjustments you might need to make to ensure everything works together seamlessly.
### Route Definition
Your route definition looks fine for routing requests to a `Plot` based on a URL-friendly name. However, make sure tha... | 37,152 | [
{
"from": "human",
"value": "I'm having some trouble with ASP.NET MVC Beta, and the idea of making routes, controller actions, parameters on those controller actions and Html.ActionLinks all work together. I have an application that I'm working on where I have a model object called a Plot, and a correspondi... |
We are using SQL Server 2000 and have to move data across servers to store it in a central database. We would rather not use DTS packages because we will move to SQL Server 2005 soon, and we don't want to have to upgrade to SSIS or have to support legacy DTS packages.
Is there any way to use OSQL scripts, vbscript, or... | Absolutely, you can accomplish this using `osql`, VBScript, or even a combination of both. Since you're concerned about the complexities of DTS packages and their future support, using command-line tools and scripting is a good approach.
### Option 1: Using OSQL
`osql` is a command-line utility that allows you to run... | 34,588 | [
{
"from": "human",
"value": "We are using SQL Server 2000 and have to move data across servers to store it in a central database. We would rather not use DTS packages because we will move to SQL Server 2005 soon, and we don't want to have to upgrade to SSIS or have to support legacy DTS packages.\nIs there... |
How do i make the plus minus icons bigger in the tree view in C# .net with out making visual styles disable.
| In a TreeView control in C# .NET, if you want to change the size of the plus (+) and minus (-) icons without disabling visual styles, you can achieve this by customizing the drawing of the TreeView using the `DrawNode` event. However, the TreeView does not directly expose properties to scale the plus/minus icons.
Ins... | 32,299 | [
{
"from": "human",
"value": "How do i make the plus minus icons bigger in the tree view in C# .net with out making visual styles disable.\n"
},
{
"from": "gpt",
"value": "In a TreeView control in C# .NET, if you want to change the size of the plus (+) and minus (-) icons without disabling visual... |
I have built a windows service application in VB.net 2008, and used the Setup Wizard to add an installation process.
The installer works, in that it adds the app to add/remove programs and copies all of the files etc, but it's missing the final (required) step of actually installing the service.
I have added the primar... | Installing a Windows service using a setup project in VB.NET can sometimes be tricky, especially if the service isn't being registered properly during the installation process. Here are some steps and tips to ensure your Windows service is installed correctly using the Setup Wizard:
### Step-by-Step Guide
1. **Ensure... | 33,432 | [
{
"from": "human",
"value": "I have built a windows service application in VB.net 2008, and used the Setup Wizard to add an installation process.\nThe installer works, in that it adds the app to add/remove programs and copies all of the files etc, but it's missing the final (required) step of actually insta... |
I am running into a very strange issue with PHP 5.2.6 w/ IIS on Windows XP (have tried both CGI and ISAPI). I am running a fresh installation with the default php.ini settings.
First, assume the following (ugly, but effective) HTML code:
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="hi... | It sounds like you're encountering a common issue when using PHP with IIS on Windows, particularly with the version you mentioned (PHP 5.2.6). Since you're able to see the `$_GET` variables but not the `$_POST` ones, there are a few things you can check and try:
1. **Check for URL Rewrite Rules**: If you have any URL ... | 36,015 | [
{
"from": "human",
"value": "I am running into a very strange issue with PHP 5.2.6 w/ IIS on Windows XP (have tried both CGI and ISAPI). I am running a fresh installation with the default php.ini settings. \nFirst, assume the following (ugly, but effective) HTML code:\n<form action=\"<?php echo $_SERVER['PH... |
Windows Forms:
For System.Drawing there is a way to get the font height.
Font font = new Font("Arial", 10 , FontStyle.Regular);
float fontHeight = font.GetHeight();
But how do you get the other text metrics like average character width?
| In Windows Forms, while you can easily get the font height using `Font.GetHeight()`, to obtain other text metrics such as the average character width, you can use the `Graphics` class along with the `TextRenderer` or `Graphics.MeasureString` method.
Here’s how you can calculate the average character width:
### Using... | 35,687 | [
{
"from": "human",
"value": "Windows Forms:\nFor System.Drawing there is a way to get the font height. \nFont font = new Font(\"Arial\", 10 , FontStyle.Regular);\nfloat fontHeight = font.GetHeight(); \n\nBut how do you get the other text metrics like average character width?\n"
},
{
"from": "gpt",
... |
Note
The question below was asked in 2008 about some code from 2003. As the OP's update shows, this entire post has been obsoleted by vintage 2008 algorithms and persists here only as a historical curiosity.
I need to do a fast case-insensitive substring search in C/C++. My requirements are as follows:
Should behave ... | For a fast case-insensitive substring search in C/C++, there are several alternative approaches and optimizations that you could consider. Given the context of your request and the historical nature of the original implementation you provided, I'll outline some potential improvements and alternatives.
### Alternative ... | 31,725 | [
{
"from": "human",
"value": "Note\nThe question below was asked in 2008 about some code from 2003. As the OP's update shows, this entire post has been obsoleted by vintage 2008 algorithms and persists here only as a historical curiosity.\n\nI need to do a fast case-insensitive substring search in C/C++. My ... |
I am using struts 1.1 with tiles.
I have tiles with definitions like
<definition name="cnmp.body.index" extends="cnmp.mainLayout" >
<put name="title" value="CNM Portal" />
<put name="bodytitle" value="Home" />
<put name="body" value="/00-CNM_Landing.jsp" />
</definition>
I want to be able to set the value of... | Your approach to dynamically setting the body parameter in your Tiles definition is clever and effective. By using a request attribute, you can modify the content that gets included in the JSP based on your logic in the Action class. Here's a recap of what you've implemented and a few additional tips or best practices ... | 35,959 | [
{
"from": "human",
"value": "I am using struts 1.1 with tiles.\nI have tiles with definitions like\n<definition name=\"cnmp.body.index\" extends=\"cnmp.mainLayout\" >\n <put name=\"title\" value=\"CNM Portal\" />\n <put name=\"bodytitle\" value=\"Home\" />\n <put name=\"body\" value=\"/00-CNM_Landing... |
whats the best way to export a Datagrid to excel? I have no experience whatsoever in exporting datagrid to excel, so i want to know how you guys export datagrid to excel.
i read that there are a lot of ways, but i am thinking to just make a simple export excel to datagrid function.i am using asp.net C#
cheers..
| Exporting a DataGrid (or GridView) to Excel in an ASP.NET application can be accomplished in several ways. Below, I'll outline a simple method that involves converting the data from a DataGrid/GridView to an Excel file format. We will leverage the response object to send the file to the client.
### Method: Export Grid... | 32,811 | [
{
"from": "human",
"value": "whats the best way to export a Datagrid to excel? I have no experience whatsoever in exporting datagrid to excel, so i want to know how you guys export datagrid to excel.\ni read that there are a lot of ways, but i am thinking to just make a simple export excel to datagrid funct... |
I have some update or something that tries to run every night, and ends up leaving the SQL Server service stopped. When the machine restarts, the service restarts properly. How do I go about diagnosing and fixing what is breaking my SQL Server service? I'm running SQL 2005 on Vista Business.
| Diagnosing issues with SQL Server 2005 that cause it to stop unexpectedly can be challenging. Here’s a systematic approach to help you identify and fix the problem:
### Step 1: Check the SQL Server Error Logs
SQL Server maintains error logs that can provide insight into what is happening when the service stops.
1. **... | 34,056 | [
{
"from": "human",
"value": "I have some update or something that tries to run every night, and ends up leaving the SQL Server service stopped. When the machine restarts, the service restarts properly. How do I go about diagnosing and fixing what is breaking my SQL Server service? I'm running SQL 2005 on... |
What are the things to consider when choosing between ByRef and ByVal.
I understand the difference between the two but I don't fully understand if ByRef saves resources or if we even need to worry about that in the .Net environment.
How do you decide between the two if the functionality doesn't matter in a situation?
| When deciding between `ByRef` (by reference) and `ByVal` (by value) in the context of .NET programming, there are several considerations to keep in mind, even if the functional outcomes of each approach are similar:
### 1. **Understanding the Basics**:
- **ByVal**: When you pass a parameter by value, a copy of the ... | 34,488 | [
{
"from": "human",
"value": "What are the things to consider when choosing between ByRef and ByVal.\nI understand the difference between the two but I don't fully understand if ByRef saves resources or if we even need to worry about that in the .Net environment.\nHow do you decide between the two if the fun... |
I have a project where I need to add users to a SharePoint portal, but when I add them, I also need to set addition parameters inside a separate database.
I want to add a custom administration screen where the administration can set these values when they add the user rather than forcing them to first add the user then... | Creating a custom administration screen for adding users to a SharePoint portal and simultaneously setting values in a separate database involves several steps. Here’s a general guide to help you get started, along with some useful resources.
### Steps to Create a Custom Administration Screen
1. **Determine Your Requ... | 34,494 | [
{
"from": "human",
"value": "I have a project where I need to add users to a SharePoint portal, but when I add them, I also need to set addition parameters inside a separate database.\nI want to add a custom administration screen where the administration can set these values when they add the user rather th... |
I am not familiar with this website but I am desperately seeking help with the website I am building. I'm sorry if I'm not in the right place or asking my question incorrectly, so please tell me if I do something wrong!
I have built a simple website, consisting of four pages (index.html plus three others). In FF everyt... | It sounds like you're experiencing a common issue with cross-browser compatibility, particularly between Firefox and Internet Explorer (IE). These types of problems often arise from differences in how browsers interpret CSS and HTML.
### Here are a few steps to help you troubleshoot the issue:
1. **Validate Your HTML... | 36,714 | [
{
"from": "human",
"value": "I am not familiar with this website but I am desperately seeking help with the website I am building. I'm sorry if I'm not in the right place or asking my question incorrectly, so please tell me if I do something wrong!\nI have built a simple website, consisting of four pages (i... |
The TextWrapping property of the TextBox has three possible values:
Wrap
NoWrap
WrapWithOverflow
I would like to bind to the IsChecked property of a MenuItem. If the MenuItem is checked, I want to set the TextWrapping property of a TextBox to Wrap. If the MenuItem is not checked, I want to set the TextWrapping prop... | Your approach using an `IValueConverter` to bind the `IsChecked` property of a `MenuItem` to the `TextWrapping` property of a `TextBox` is perfectly valid and a common method for handling such scenarios in WPF. However, if you're looking for alternatives to using a value converter, here are a few other methods that you... | 28,471 | [
{
"from": "human",
"value": "The TextWrapping property of the TextBox has three possible values:\n\nWrap\nNoWrap\nWrapWithOverflow\n\nI would like to bind to the IsChecked property of a MenuItem. If the MenuItem is checked, I want to set the TextWrapping property of a TextBox to Wrap. If the MenuItem is n... |
I wanna see if there is an approach to pack a few plugins together as a meta plugin that install everything together automatically, works like a project template.
Why not a script? Because I want to put it in github so I don't have to worry about it when I am not with my own PC :) but of coz a script based solution is ... | Creating a meta plugin to bundle several other plugins together is a great approach to streamline the installation process, especially if you want to share it on GitHub. Here are a few methods you can consider for packaging and managing your meta plugin effectively:
### 1. Use a Plugin Management System
If you’re wor... | 33,988 | [
{
"from": "human",
"value": "I wanna see if there is an approach to pack a few plugins together as a meta plugin that install everything together automatically, works like a project template.\nWhy not a script? Because I want to put it in github so I don't have to worry about it when I am not with my own PC... |
I am building a multithreaded system that works like this:
While there are entities:
Gets an entity from nHibernate (using the current session)
Starts a new thread that will work with this entity*
When I start this new thread, it is required to have a new Session, because nHibernate is not thread-safe. I create it, b... | In NHibernate, entities are associated with a specific session, and attempting to use them across different sessions directly can lead to issues since NHibernate sessions are not thread-safe, as you've already noted. When you retrieve an entity using one session, that entity becomes "managed" by that session. If you at... | 32,312 | [
{
"from": "human",
"value": "I am building a multithreaded system that works like this:\nWhile there are entities:\n\nGets an entity from nHibernate (using the current session)\nStarts a new thread that will work with this entity*\n\nWhen I start this new thread, it is required to have a new Session, becaus... |
Whenever I have a library that use across different websites/ applications I've always just added the library's project into the same solution and reference it from there. This is great when needing to debug within the solution but in all other situations it seems pointless and more space taken up in the solution explo... | Your question about whether to reference a library project directly in your solution or to use a DLL is a common dilemma for software developers. Here are some considerations and practices that might help you decide which approach is best for your scenarios:
### Pros and Cons of Referencing the Project
#### Pros:
1. ... | 35,830 | [
{
"from": "human",
"value": "Whenever I have a library that use across different websites/ applications I've always just added the library's project into the same solution and reference it from there. This is great when needing to debug within the solution but in all other situations it seems pointless and ... |
We've been trying to hunt down some heap corruption issues in our multi-threaded C++ apps. As one technique, we tried add -lmcheck to the libraries line of the application. This is causing the app to crash out with apparent heap corruption in relatively short order.
Our app does use both malloc/free and new/delete (as ... | The `-lmcheck` option is part of the GNU C Library's memory checking feature that helps detect memory leaks, uninitialized memory reads, and memory corruption issues. However, the behavior of `-lmcheck` in multi-threaded applications can be problematic.
### Points to Consider:
1. **Thread Safety**: `-lmcheck` is not ... | 37,493 | [
{
"from": "human",
"value": "We've been trying to hunt down some heap corruption issues in our multi-threaded C++ apps. As one technique, we tried add -lmcheck to the libraries line of the application. This is causing the app to crash out with apparent heap corruption in relatively short order.\nOur app doe... |
I've been trying to use Firebug's profiler to better understand the source of some JavaScript performance issues we are seeing, but I'm a little confused by the output.
When I profile some code the profiler reports Profile (464.323 ms, 26,412 calls). I suspect that the 464.323 ms is the sum of the execution time for th... | When analyzing profiling output, it's important to understand the context and definitions of each metric reported. Let's clarify the various terms you're seeing in Firebug's profiler output:
1. **Profile Time (464.323 ms)**: This is the total time taken for all the function calls captured in the profiling session. In ... | 31,228 | [
{
"from": "human",
"value": "I've been trying to use Firebug's profiler to better understand the source of some JavaScript performance issues we are seeing, but I'm a little confused by the output.\nWhen I profile some code the profiler reports Profile (464.323 ms, 26,412 calls). I suspect that the 464.323 ... |
ASP.NET tracing seems very erratic. Sometimes it traces and sometimes it doesn't.
I trace from my ASCX using...
Trace.Write("etc. etc.");
My web.config looks as follows... (in WSS3)
I first ensure that SharePoint allows the page level tracing...
<SafeMode MaxControls="200" CallStack="true" DirectFileDependencies="10" T... | Based on the details you've provided, there are several areas to check and troubleshoot when you're experiencing erratic behavior with ASP.NET tracing in your ASCX files. Here are some suggestions:
1. **Trace Output Location**: Make sure that the log file path you specified (`c:\asptrace\log.txt`) is accessible by the... | 35,533 | [
{
"from": "human",
"value": "ASP.NET tracing seems very erratic. Sometimes it traces and sometimes it doesn't.\nI trace from my ASCX using...\nTrace.Write(\"etc. etc.\");\nMy web.config looks as follows... (in WSS3)\nI first ensure that SharePoint allows the page level tracing...\n<SafeMode MaxControls=\"20... |
How can I generate valid XML in C#?
| Generating valid XML in C# can be done in several ways, but the most common methods involve using either the `XmlDocument` class, the `XDocument` class from LINQ to XML, or the `XmlWriter` class for more control over the formatting. Below are examples using each of these approaches.
### 1. Using `XmlDocument`
```csha... | 35,350 | [
{
"from": "human",
"value": "How can I generate valid XML in C#?\n"
},
{
"from": "gpt",
"value": "Generating valid XML in C# can be done in several ways, but the most common methods involve using either the `XmlDocument` class, the `XDocument` class from LINQ to XML, or the `XmlWriter` class for... |
I want to create a toggle button in html using css. I want it so that when you click on it , it stays pushed in and than when you click it on it again it pops out.
If theres no way of doing it just using css. Is there a way to do it using jQuery?
| Creating a toggle button that stays in its toggled state after being clicked cannot be achieved purely with CSS, as CSS cannot maintain state. However, you can easily accomplish this with a combination of HTML, CSS, and jQuery. Below is an example of how you can create such a toggle button.
### HTML
```html
<!DOCTYPE ... | 35,868 | [
{
"from": "human",
"value": "I want to create a toggle button in html using css. I want it so that when you click on it , it stays pushed in and than when you click it on it again it pops out. \nIf theres no way of doing it just using css. Is there a way to do it using jQuery?\n"
},
{
"from": "gpt"... |
In my application I have a number of panes from m_wndspliter classes. What I want to do is at run time show and hide one of these panes. Whilst with the following code I can show and hide the view associated with the pane, I can't temporarily remove the pane itself.
CWnd * pCurView = m_wndSplitter2.GetPane(2, 0);
if( ... | To temporarily remove a pane from a splitter window in an MFC application, you can make use of the `CSplitterWnd` class. While you can show and hide the views associated with the panes, removing the pane itself requires more than just hiding the view. Here are some steps and sample code to help you achieve this:
1. **... | 36,336 | [
{
"from": "human",
"value": "In my application I have a number of panes from m_wndspliter classes. What I want to do is at run time show and hide one of these panes. Whilst with the following code I can show and hide the view associated with the pane, I can't temporarily remove the pane itself. \nCWnd * pCu... |
I'm trying to get a regex that will match:
somefile_1.txt
somefile_2.txt
somefile_{anything}.txt
but not match:
somefile_16.txt
I tried
somefile_[^(16)].txt
with no luck (it includes even the "16" record)
| To create a regular expression that matches `somefile_1.txt`, `somefile_2.txt`, and `somefile_{anything}.txt` but does not match `somefile_16.txt`, you can use a regex pattern that explicitly specifies the acceptable formats while excluding "16".
Here's an appropriate regex pattern:
```regex
somefile_([1-9]|1[0-5]|[1... | 37,149 | [
{
"from": "human",
"value": "I'm trying to get a regex that will match:\nsomefile_1.txt\nsomefile_2.txt\nsomefile_{anything}.txt\n\nbut not match:\nsomefile_16.txt\n\nI tried\nsomefile_[^(16)].txt\n\nwith no luck (it includes even the \"16\" record)\n"
},
{
"from": "gpt",
"value": "To create a r... |
Using a standard ASP.NET ListView with a LinqDataSource and pagination enabled (with a DataPager), what would be the best way to default to displaying the last page of results?
| To display the last page of results in a standard ASP.NET `ListView` with a `LinqDataSource` and pagination enabled, you can follow these steps:
1. **Determine the total number of items**: You'll need to find out how many items are available in the data source to calculate the total number of pages.
2. **Set the curr... | 31,599 | [
{
"from": "human",
"value": "Using a standard ASP.NET ListView with a LinqDataSource and pagination enabled (with a DataPager), what would be the best way to default to displaying the last page of results?\n"
},
{
"from": "gpt",
"value": "To display the last page of results in a standard ASP.NET... |
I'm using a repeater control and I'm trying to pass a parameter as such:
<%# SomeFunction( DataBinder.Eval(Container.DataItem, "Id") ) %>
It's basically calling:
public string SomeFunction(long id) {
return "Hello";
}
I'm not able to achieve this as I get an error:
error CS1502: The best overloaded meth... | The error you’re encountering indicates that the argument being passed to `SomeFunction` is not of the expected type `long`. In the context of your code, `DataBinder.Eval(Container.DataItem, "Id")` returns an `object`, which might not be directly convertible to `long`.
To resolve this issue, you need to explicitly cas... | 38,503 | [
{
"from": "human",
"value": "I'm using a repeater control and I'm trying to pass a parameter as such:\n<%# SomeFunction( DataBinder.Eval(Container.DataItem, \"Id\") ) %>\n\nIt's basically calling:\npublic string SomeFunction(long id) {\n\n return \"Hello\"; \n\n}\n\nI'm not able to achieve this as... |
I already know Java, Objective C, C#, and some Python. I want to be able to integrate with XML or a MySQL database for dynamic content.
What are some tutorials or online references that would get me up and running with Actionscript 3.0?
| If you're looking to learn ActionScript 3.0, especially with a focus on integrating with XML or a MySQL database, there are several online resources and tutorials that can help you get started. Here are some recommended materials:
### Official Documentation
1. **Adobe ActionScript 3.0 Language and Component Reference*... | 33,347 | [
{
"from": "human",
"value": "I already know Java, Objective C, C#, and some Python. I want to be able to integrate with XML or a MySQL database for dynamic content.\nWhat are some tutorials or online references that would get me up and running with Actionscript 3.0?\n"
},
{
"from": "gpt",
"value... |
Currently I have a table that I search upon 4 fields, FirstName, LastName, MiddleName, And AKA's. I currently have a CONTAINSTABLE search for the rows and it works. Not well but it works. Now I want to make the First Name weighted higher and middle name lower.
I found the command ISABOUT but that seems pretty worthless... | If you want to perform a full-text search while applying different weights to different columns, you can achieve this by using a combination of `CONTAINSTABLE` and a weighting mechanism. Unfortunately, SQL Server does not provide a direct way to apply weights based on columns in `CONTAINSTABLE`. However, you can use th... | 36,819 | [
{
"from": "human",
"value": "Currently I have a table that I search upon 4 fields, FirstName, LastName, MiddleName, And AKA's. I currently have a CONTAINSTABLE search for the rows and it works. Not well but it works. Now I want to make the First Name weighted higher and middle name lower.\nI found the comma... |
How to host the WCF service in windows service?
Thanks
Sekar
| Hosting a WCF (Windows Communication Foundation) service in a Windows Service application allows you to create a long-running service that can respond to client requests. Here's a step-by-step guide on how to do that.
### Step 1: Create a WCF Service
1. **Create a WCF Service Library**:
- Open Visual Studio.
- ... | 33,981 | [
{
"from": "human",
"value": "How to host the WCF service in windows service?\nThanks\nSekar\n"
},
{
"from": "gpt",
"value": "Hosting a WCF (Windows Communication Foundation) service in a Windows Service application allows you to create a long-running service that can respond to client requests. ... |
I'm trying to get a specific asp:button onclick event to fire when I press the enter key in a specific asp:textbox control.
The other factor to be taken into account is that the button is within a asp:Login control template.
I've no idea how to do this, suggestions on a postcard please.
| To trigger an ASP.NET button's `OnClick` event when pressing the Enter key in a specific `TextBox` control, you can handle the `keypress` event of the `TextBox` using JavaScript or jQuery. Since your button is within a `Login` control template, you may need to reference it correctly in the JavaScript function.
Below i... | 34,738 | [
{
"from": "human",
"value": "I'm trying to get a specific asp:button onclick event to fire when I press the enter key in a specific asp:textbox control.\nThe other factor to be taken into account is that the button is within a asp:Login control template.\nI've no idea how to do this, suggestions on a postca... |
I want to start using dependency injection in my WPF application, largely for better unit testability. My app is mostly constructed along the M-V-VM pattern.
I'm looking at Autofac for my IoC container, but I don't think that matters too much for this discussion.
Injecting a service into the start window seems straight... | You're on the right track with wanting to use Dependency Injection (DI) to improve the unit testability of your WPF application that follows the MVVM pattern. You’re also correct in identifying that directly resolving dependencies from within XAML is challenging.
In WPF, User Controls are typically instantiated throug... | 33,348 | [
{
"from": "human",
"value": "I want to start using dependency injection in my WPF application, largely for better unit testability. My app is mostly constructed along the M-V-VM pattern.\nI'm looking at Autofac for my IoC container, but I don't think that matters too much for this discussion.\nInjecting a s... |
While accessing a webservice which is availbale at http://recpushdata.cyndigo.com/jobs.asmx, I am getting this Exception. "Remote name could not be resolved"
Any Suggesytion..what to do..
| The "Remote name could not be resolved" exception indicates that the client application cannot find the specified URL. This could be caused by several issues. Here are some suggestions to troubleshoot and resolve this problem:
1. **Check URL**:
- Ensure that the URL `http://recpushdata.cyndigo.com/jobs.asmx` is cor... | 37,504 | [
{
"from": "human",
"value": "While accessing a webservice which is availbale at http://recpushdata.cyndigo.com/jobs.asmx, I am getting this Exception. \"Remote name could not be resolved\"\nAny Suggesytion..what to do..\n"
},
{
"from": "gpt",
"value": "The \"Remote name could not be resolved\" e... |
I am creating a left navigation system utilizing xml and xsl. Everything was been going great until I tried to use a special character in my xml document. I am using » and I get th error.
reason: Reference to undefined entity 'raquo'.
error code: -1072898046
How do I make this work?
| The error you are encountering is because the XML parser does not recognize the HTML entities like `»`. In XML, you need to use character references or predefined entities instead. For your specific case with `»`, you have two options:
1. **Use the Numeric Character Reference**: For `»`, you can use ... | 36,838 | [
{
"from": "human",
"value": "I am creating a left navigation system utilizing xml and xsl. Everything was been going great until I tried to use a special character in my xml document. I am using » and I get th error.\n\nreason: Reference to undefined entity 'raquo'.\n error code: -1072898046\n\nHow d... |
Does anyone know of a drop-in replacement for an access database, ideally open source. A group I work with occasionally is looking for a replacement database where they'll need to change as little actual SQL as possible. Their app is VB6/COM.
| If you're looking for a drop-in replacement for Microsoft Access that is open source and requires minimal changes to your existing SQL, here are a few options you might consider:
1. **SQLite**:
- **Overview**: SQLite is a lightweight, serverless database engine that can be easily integrated into applications. It's ... | 35,042 | [
{
"from": "human",
"value": "Does anyone know of a drop-in replacement for an access database, ideally open source. A group I work with occasionally is looking for a replacement database where they'll need to change as little actual SQL as possible. Their app is VB6/COM.\n"
},
{
"from": "gpt",
"... |
My cron job is running an hour later after end of DST. This didn't happen to other user's jobs on the same machine (AIX). What am I doing wrong?
| The issue you are experiencing with your cron job running an hour later after the end of Daylight Saving Time (DST) could be related to a few different factors specific to your configuration. Here are some troubleshooting steps you can take:
1. **Check Timezone Settings**: Verify that your user account’s timezone is s... | 30,793 | [
{
"from": "human",
"value": "My cron job is running an hour later after end of DST. This didn't happen to other user's jobs on the same machine (AIX). What am I doing wrong?\n"
},
{
"from": "gpt",
"value": "The issue you are experiencing with your cron job running an hour later after the end o... |
Is it possible to retrieve the CPUID and MAC address of a client machine from a Ruby on Rails application?. Are there any plugins available for this?
| In a Ruby on Rails application, you typically cannot directly retrieve the CPUID (CPU identification) or MAC address of a client machine due to security and privacy restrictions imposed by web browsers and the underlying network protocols. Here are a few points to consider:
### CPUID
- **CPUID**: This is a low-level i... | 34,614 | [
{
"from": "human",
"value": "Is it possible to retrieve the CPUID and MAC address of a client machine from a Ruby on Rails application?. Are there any plugins available for this?\n"
},
{
"from": "gpt",
"value": "In a Ruby on Rails application, you typically cannot directly retrieve the CPUID (CP... |
Are htaccess redirects any slower/put any more strain on Apache than redirects in configuration files? Also, how big can a number of redirects in htaccess get before they start decreasing performance?
| Using `.htaccess` files for redirects can introduce some performance overhead compared to using Apache's main configuration files (like `httpd.conf` or a virtual host configuration). Here's why:
1. **Processing Overhead**: `.htaccess` files are processed on every request. This means that for every HTTP request that Ap... | 36,911 | [
{
"from": "human",
"value": "Are htaccess redirects any slower/put any more strain on Apache than redirects in configuration files? Also, how big can a number of redirects in htaccess get before they start decreasing performance?\n"
},
{
"from": "gpt",
"value": "Using `.htaccess` files for redir... |
I have a tabpanel with a calendar control on the 4th tab but when I select a date, the postback causes the tabpanel to return to the first tab instead of the 4th that it came from.
Is there a way to get it to return to the tab that the calendar control is on and not revert back to the first tab ?
I know setting autoPos... | To ensure that your tab panel remains on the same tab after a postback when interacting with a control like a calendar, you'll need to retain the selected tab index in a way that it can persist across postbacks. Here's a general approach to achieve this in ASP.NET:
### Approach:
1. **Use ViewState or Session**: You c... | 34,126 | [
{
"from": "human",
"value": "I have a tabpanel with a calendar control on the 4th tab but when I select a date, the postback causes the tabpanel to return to the first tab instead of the 4th that it came from.\nIs there a way to get it to return to the tab that the calendar control is on and not revert back... |
Would you (or your customers) rather download a 1mb installer and perhaps be prompted to download and install .NET, or a 23mb installer and never need to even know what .NET is?
Chris
| The preference between a smaller installer that requires additional downloads (like .NET) and a larger all-in-one installer can vary depending on the target audience and their needs. Here are some considerations for both options:
### 1 MB Installer (with .NET dependency):
- **Pros:**
- Faster initial download for us... | 36,972 | [
{
"from": "human",
"value": "Would you (or your customers) rather download a 1mb installer and perhaps be prompted to download and install .NET, or a 23mb installer and never need to even know what .NET is?\nChris\n"
},
{
"from": "gpt",
"value": "The preference between a smaller installer that r... |
I have two strings
<EM>is <i>love</i></EM>,<PARTITION />
and
<EM>is <i>love</i>,<PARTITION />
I want a regex to match the second string completely but should not match the first one. Please help.
Note: Everything can change except the EM and PARTITION tags.
| To create a regex that matches the second string but does not match the first string, we can utilize the structure of the strings and the specific tags you want to match.
Since you want to match:
- `<EM>is <i>love</i>,<PARTITION />`
And **not** match:
- `<EM>is <i>love</i></EM>,<PARTITION />`
The key difference is ... | 38,083 | [
{
"from": "human",
"value": "I have two strings\n<EM>is <i>love</i></EM>,<PARTITION />\n\nand\n<EM>is <i>love</i>,<PARTITION />\n\nI want a regex to match the second string completely but should not match the first one. Please help.\nNote: Everything can change except the EM and PARTITION tags.\n"
},
{... |
I'm still learning Grails and seem to have hit a stumbling block.
Here are the 2 domain classes:
class Photo {
byte[] file
static belongsTo = Profile
}
class Profile {
String fullName
Set photos
static hasMany = [photos:Photo]
}
The relevant controller snippet:
class PhotoController {
... | You are correct that the way you're trying to access the ID of a photo in the GSP is not correct. The Groovy Server Pages (GSP) syntax needs to be used properly to achieve your goal. Here's how you can correct the code to display the photo:
### Updated GSP snippet:
You should first ensure that `profileInstance` is ava... | 35,117 | [
{
"from": "human",
"value": "I'm still learning Grails and seem to have hit a stumbling block.\nHere are the 2 domain classes:\nclass Photo {\n byte[] file \n\n static belongsTo = Profile\n}\n\n\nclass Profile {\n String fullName\n Set photos\n\n static hasMany = [photos:Photo] \n}\n\nThe... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.