instruction
stringlengths
14
27.6k
completion
stringlengths
3
38.3k
__original_row_idx
int64
0
50k
conversations
listlengths
2
2
What's everyone take on tieing code enum's to row ID's in a database table? I'm really looking for a cleaner alternative. What if for example your static rows in a given table are ID's 1,2,3, and then that table gets filled with user transactional data using ID's 4-100, and then you later want to add a new row ID which...
When dealing with a database that contains both static rows (like enums or configuration values) and dynamic transactional data, it’s crucial to manage these two types of data separately to avoid the complications you've outlined. Here are a few approaches to consider: ### 1. Use a Separate Table for Enums/Static Data...
32,897
[ { "from": "human", "value": "What's everyone take on tieing code enum's to row ID's in a database table? I'm really looking for a cleaner alternative. What if for example your static rows in a given table are ID's 1,2,3, and then that table gets filled with user transactional data using ID's 4-100, and then...
I'm working on an assigned group project at University where we have to re-implement the TCP/IP stack to support some extra stuff (http://discolab.rutgers.edu/mtcp/), and then demonstrate it. The thesis/design we're working from says the original researchers changed the sourcecode for FreeBSD to support the extra bits ...
Hi Jon, It's great that you're diving into such a challenging and interesting project! Here are some pointers to help you with compiling and modifying FreeBSD to support your custom changes: ### Compiling FreeBSD from Source 1. **Download FreeBSD Source Code:** Make sure you have the FreeBSD source code on your m...
30,861
[ { "from": "human", "value": "I'm working on an assigned group project at University where we have to re-implement the TCP/IP stack to support some extra stuff (http://discolab.rutgers.edu/mtcp/), and then demonstrate it.\nThe thesis/design we're working from says the original researchers changed the sourcec...
I love the Ruby RSpec BDD development style. Are there any good tools for doing this with C/C++?
Yes, there are several tools and frameworks available for Behavior-Driven Development (BDD) in C and C++. Here are some popular options: 1. **Catch2**: This is a multi-header C++ test framework that supports BDD-style tests. You can write tests in a way that resembles natural language, making it easier to read. Catch2...
30,898
[ { "from": "human", "value": "I love the Ruby RSpec BDD development style. Are there any good tools for doing this with C/C++?\n" }, { "from": "gpt", "value": "Yes, there are several tools and frameworks available for Behavior-Driven Development (BDD) in C and C++. Here are some popular options:...
I've got a unfinished project that a developer just didn't finish and didn't leave any documentation about the installation process. I've downloaded the production directory to my windows machine (running InstantRails 2), I created the databases as required in the database.yml and I tried to run the rake:db:migrate --t...
The error message you’re seeing indicates that there’s an issue with a missing or uninitialized constant called `Admin`. This typically arises in a few scenarios in Rails applications, particularly when dealing with migrations. Below are some steps and checks to help you debug and resolve the issue: ### 1. Check Migra...
29,777
[ { "from": "human", "value": "I've got a unfinished project that a developer just didn't finish and didn't leave any documentation about the installation process. I've downloaded the production directory to my windows machine (running InstantRails 2), I created the databases as required in the database.yml a...
How can I check if a file uploaded by a user is a real jpg file in Python (Google App Engine)? This is how far I got by now: Script receives image via HTML Form Post and is processed by the following code ... incomming_image = self.request.get("img") image = db.Blob(incomming_image) ... I found mimetypes.guess_type, b...
To verify if an uploaded file is a genuine JPEG image in Python (especially in the context of Google App Engine), you can follow these steps: 1. **Check the MIME type:** While `mimetypes.guess_type` is useful, it's not always reliable since it only checks the file extension. Instead, you can also use the `file` comman...
32,144
[ { "from": "human", "value": "How can I check if a file uploaded by a user is a real jpg file in Python (Google App Engine)?\nThis is how far I got by now:\nScript receives image via HTML Form Post and is processed by the following code\n...\nincomming_image = self.request.get(\"img\")\nimage = db.Blob(incom...
In python how do you read multiple files from a mysql database using the cursor or loop one by one and store the output in a separate table?
To read multiple files (which I assume are stored as BLOBs or in another format in a MySQL database) and store the output in a separate table using Python, you would typically follow these steps: 1. **Connect to the MySQL database**. 2. **Query the original table to retrieve the files**. 3. **Process each file** (if n...
32,536
[ { "from": "human", "value": "In python how do you read multiple files from a mysql database using the cursor or loop one by one and store the output in a separate table?\n" }, { "from": "gpt", "value": "To read multiple files (which I assume are stored as BLOBs or in another format in a MySQL da...
The code is rather long yet simple: 100 leaky JavaScript objects are created. 10 leaky elements are created from the JS objects. 1 element is removed and 1 is added 10000 times. I assume that the detachEvent call is not functioning properly. Also, if you change this.eventParams from an array to a simple variable, the...
The JavaScript code you provided exhibits behavior that can lead to memory leaks due to improper event handling, particularly when dealing with closures and DOM elements. Let's analyze the issues and the proposed solution you hinted at. ### Why the Leak Occurs: 1. **Closure Creation**: In the `CreateLeakyEle` fun...
29,338
[ { "from": "human", "value": "The code is rather long yet simple:\n\n100 leaky JavaScript objects are created.\n10 leaky elements are created from the JS objects.\n1 element is removed and 1 is added 10000 times.\n\nI assume that the detachEvent call is not functioning properly.\nAlso, if you change this.eve...
The problem is quite basic. I have a JTable showing cached data from a database. If a user clicks in a cell for editing, I want to attempt a lock on that row in the database. If the lock does not succeed, I want to prevent editing. But I can't seem to find any clean way to accomplish this. Am I missing something?
When implementing a locking mechanism for a database row when a user attempts to edit it in a `JTable`, you need to consider both user interaction and database operations. Here's a general approach to achieve what you want: 1. **Listen for Cell Editing Events**: You can use a `TableModelListener` or `CellEditorListene...
29,003
[ { "from": "human", "value": "The problem is quite basic. I have a JTable showing cached data from a database. If a user clicks in a cell for editing, I want to attempt a lock on that row in the database. If the lock does not succeed, I want to prevent editing.\nBut I can't seem to find any clean way to acco...
We're using Perforce and Visual Studio. Whenever we create a branch, some projects will not be bound to source control unless we use "Open from Source Control", but other projects work regardless. From my investigations, I know some of the things involved: In our .csproj files, there are these settings: <SccProjectNam...
When working with Perforce and Visual Studio, particularly concerning source control bindings, it's essential to understand how Visual Studio handles these bindings and the configuration in your `.csproj` and `.sln` files. Let's break down your questions: ### 1. What happens when you do "Change Source Control"? When ...
28,207
[ { "from": "human", "value": "We're using Perforce and Visual Studio. Whenever we create a branch, some projects will not be bound to source control unless we use \"Open from Source Control\", but other projects work regardless. From my investigations, I know some of the things involved:\nIn our .csproj file...
I'm using Windows Vista and C#.net 3.5, but I had my friend run the program on XP and has the same problem. So I have a C# program that I have running in the background with an icon in the SystemTray. I have a low level keyboard hook so when I press two keys (Ctr+windows in this case) it'll pull of the application's m...
It sounds like you are encountering a common issue when trying to create a fullscreen experience with Windows Forms in C#. While setting the `FormBorderStyle` to `None` and the `WindowState` to `Maximized` is the correct approach to create a fullscreen effect, sometimes the behavior of the Windows Taskbar can cause it ...
24,179
[ { "from": "human", "value": "I'm using Windows Vista and C#.net 3.5, but I had my friend run the program on XP and has the same problem.\nSo I have a C# program that I have running in the background with an icon in the SystemTray. I have a low level keyboard hook so when I press two keys (Ctr+windows in th...
How can I define it in the struts framework, when I would like to load templates (JSP, ZUL etc.) from different JAR-Files?
In the Struts framework, if you want to load JSP or ZUL templates from different JAR files, you can achieve this by modifying the classpath or using specific configurations in your project setup. Here are the steps to define it: ### 1. Ensure JAR Files Are in Classpath Make sure that all the JAR files containing your ...
32,633
[ { "from": "human", "value": "How can I define it in the struts framework, when I would like to load templates (JSP, ZUL etc.) from different JAR-Files?\n" }, { "from": "gpt", "value": "In the Struts framework, if you want to load JSP or ZUL templates from different JAR files, you can achieve thi...
I have SAML 1.1 and SAML 1.0 responses in utf-8 char * buffers, and I would like to transform them into Rampart/C saml_response_t * objects. My question is this: What is the correct method for creating a saml_response_t from a string? Ideally I'd like a code sample in C that does this and then disposes of the various ...
To properly transform SAML responses into `saml_response_t *` objects using Axis2/C, you'll need to ensure that you're correctly managing the lifecycle of objects and cleaning up memory afterward. Below is a complete code sample that shows how to create a `saml_response_t` from an XML buffer containing a SAML response,...
25,849
[ { "from": "human", "value": "I have SAML 1.1 and SAML 1.0 responses in utf-8 char * buffers, and I would like to transform them into Rampart/C saml_response_t * objects. My question is this:\nWhat is the correct method for creating a saml_response_t from a string?\nIdeally I'd like a code sample in C that ...
I need to output the contents of a text field using MS Query Analyzer. I have tried this: select top 1 text from myTable (where text is a text field) and DECLARE @data VarChar(8000) select top 1 @data = text from myTable PRINT @data The first one prints only the first 2000 or so characters and the second only prints...
In SQL Server 7, the `text` data type is designed to hold large amounts of data, but it has some limitations when it comes to outputting the entire content. As you've noticed, `SELECT` statements and variable assignments have character limits that prevent you from retrieving the full contents directly. To retrieve an...
33,805
[ { "from": "human", "value": "I need to output the contents of a text field using MS Query Analyzer. I have tried this:\nselect top 1 text from myTable\n\n(where text is a text field)\nand\nDECLARE @data VarChar(8000) \nselect top 1 @data = text from myTable\nPRINT @data\n\nThe first one prints only the firs...
While surfing, I came to know that somebody has done Tower of Hanoi using vim. WOW!!! Can you people share what all cool things you have been doing in vim. Edit: Not sure about the Tower of Hanoi solution using vim being all that useful. But I think this question should be re-opened to allow people to comment on any us...
Vim is an incredibly powerful text editor, and many users have created interesting and useful things using it. Here are some cool things people have done with Vim: 1. **Vim as an IDE**: With plugins like YouCompleteMe, ALE, or coc.nvim, users can turn Vim into a fully functional Integrated Development Environment. You...
33,099
[ { "from": "human", "value": "While surfing, I came to know that somebody has done Tower of Hanoi using vim. WOW!!!\nCan you people share what all cool things you have been doing in vim.\nEdit: Not sure about the Tower of Hanoi solution using vim being all that useful. But I think this question should be re-...
I'm doing some maintenance on a private svn server. Authentication is handled through Apache basic HTTP+mod_authz_svn. I need to have it so every user has read/write access, except for a single read-only user. The read-only user still needs to be authenticated, though. I setup my authz config file like this: [/] * = rw...
The issue you are experiencing with your `authz` configuration stems from how the access control rules are being interpreted. In your configuration, the entry for `*` (which allows all users read/write access) takes precedence over the entry for `read-only`, because `*` essentially grants all users, including `read-onl...
32,799
[ { "from": "human", "value": "I'm doing some maintenance on a private svn server. Authentication is handled through Apache basic HTTP+mod_authz_svn. I need to have it so every user has read/write access, except for a single read-only user. The read-only user still needs to be authenticated, though. I setup m...
I know it is possible, and a lot faster than using GDI+. However I haven't found any good example of using DirectX to resize an image and save it to disk. I have implemented this over and over in GDI+, thats not difficult. However GDI+ does not use any hardware acceleration, and I was hoping to get better performanc...
Using DirectX to resize an image can indeed provide better performance through hardware acceleration, especially for larger images or when dealing with multiple images in a game or other high-performance application. Below, I'll provide a basic example of how you can use Direct2D (a part of DirectX) to resize an image ...
16,686
[ { "from": "human", "value": "I know it is possible, and a lot faster than using GDI+. However I haven't found any good example of using DirectX to resize an image and save it to disk. I have implemented this over and over in GDI+, thats not difficult. However GDI+ does not use any hardware acceleration, ...
I regularly want to check if an object has a member or not. An example is the creation of a singleton in a function. For that purpose, you can use hasattr like this: class Foo(object): @classmethod def singleton(self): if not hasattr(self, 'instance'): self.instance = Foo() return se...
Both methods you provided for checking the presence of an attribute (`hasattr` versus a `try`/`except` block) are valid, but there are differences in their performance and clarity that can make one preferable over the other, especially in the context of your specific use case of implementing a singleton. ### Method 1:...
31,054
[ { "from": "human", "value": "I regularly want to check if an object has a member or not. An example is the creation of a singleton in a function. For that purpose, you can use hasattr like this:\nclass Foo(object):\n @classmethod\n def singleton(self):\n if not hasattr(self, 'instance'):\n ...
The Setup: I'm working on a website that uses Formsauthentication using cookies to store the login ticket. The site also has an HTTPHandler that manages images stored in the database. The handler caches the images to be public and expire in 20 minutes. We have noticed that since the images have the same lifecycle as...
The issue you're experiencing with FormsAuthentication cookies being shared between users likely stems from the way browsers cache responses, especially in conjunction with public caching headers. When images are served with the same cookie associated with user authentication, you risk exposing user data to other users...
32,459
[ { "from": "human", "value": "The Setup:\nI'm working on a website that uses Formsauthentication using cookies to store the login ticket. The site also has an HTTPHandler that manages images stored in the database. The handler caches the images to be public and expire in 20 minutes. We have noticed that s...
The following is code I've used to create a memory mapped file: fid = open(filename, O_CREAT | O_RDWR, 0660); if ( 0 > fid ) { throw error; } /* mapped offset pointer to data file */ offset_table_p = (ubyte_2 *) shmat(fid, 0, SHM_MAP); /* Initialize table */ memset(offset_table_p, 0x00, (table_size + 1) * 2); s...
From your code snippet and description, there are a few potential issues that could cause the failure when attempting to initialize the memory mapped file. Here are some points to consider: 1. **Incorrect Use of File Descriptor with `shmat`:** - The `shmat` function is used for attaching shared memory segments cre...
25,815
[ { "from": "human", "value": "The following is code I've used to create a memory mapped file:\nfid = open(filename, O_CREAT | O_RDWR, 0660);\n\nif ( 0 > fid )\n{\n throw error;\n}\n\n/* mapped offset pointer to data file */\noffset_table_p = (ubyte_2 *) shmat(fid, 0, SHM_MAP);\n\n/* Initialize table */\nm...
Could you recommend a lightweight SQL database which doesn't require installation on a client computer to work and could be accessed easily from .NET application? Only basic SQL capabilities are needed. Now I am using Access database in simple projects and distribute .MDB and .EXE files together. Looking for any altern...
If you are looking for a lightweight SQL database that doesn’t require installation on the client computer and can be easily accessed from a .NET application, here are some alternatives you might consider: 1. **SQLite**: - **Overview**: SQLite is a self-contained, serverless, and zero-configuration SQL database eng...
34,075
[ { "from": "human", "value": "Could you recommend a lightweight SQL database which doesn't require installation on a client computer to work and could be accessed easily from .NET application? Only basic SQL capabilities are needed.\nNow I am using Access database in simple projects and distribute .MDB and ....
What is the difference between the following 2 ways to allocate and init an object? AController *tempAController = [[AController alloc] init]; self.aController = tempAController; [tempAController release]; and self.aController= [[AController alloc] init]; Most of the apple example use the first method. Why would you ...
The two code snippets you've provided both initialize an instance of `AController` and assign it to a property called `aController`. However, they differ in their approach and implications regarding memory management in Objective-C, particularly in the context of manual reference counting (MRC). ### 1. First Method ``...
24,724
[ { "from": "human", "value": "What is the difference between the following 2 ways to allocate and init an object?\nAController *tempAController = [[AController alloc] init];\nself.aController = tempAController;\n[tempAController release];\n\nand\nself.aController= [[AController alloc] init];\n\nMost of the a...
Using qsort in C we pass in a comparison function e.g. int cmp(const void*, const void*); the protoype of qsort expects a int (* )(const void* , const void*) so we call: qsort(..., cmp); but it is equally valid to call: qsort(..., &cmp); and this is what we would have to do if we passed in a static member-function i...
Your discomfort regarding the use of function pointers in C is quite valid, and it stems from a few important concepts in C programming language design, especially around type safety and function pointers. ### Key Points: 1. **Function Pointers and the `&` Operator**: - In C, when you refer to a function by its na...
32,119
[ { "from": "human", "value": "Using qsort in C we pass in a comparison function e.g.\nint cmp(const void*, const void*);\n\nthe protoype of qsort expects a int (* )(const void* , const void*) so we call:\nqsort(..., cmp);\n\nbut it is equally valid to call:\nqsort(..., &cmp);\n\nand this is what we would hav...
Imagine the radio of a car, does the electro magnetic fields through which the car goes through, have interference in the processing? It's easy to understand that a strong field can corrupt data. But what about the data under processment? Can it also be changed? If so how could you protect your code against this? (with...
Electromagnetic interference (EMI) can potentially affect electronic devices, including a car's radio and onboard computing systems. While strong electromagnetic fields are more likely to corrupt data, weaker fields may cause issues during data processing, especially if the electronics are not well-shielded or properly...
31,261
[ { "from": "human", "value": "Imagine the radio of a car, does the electro magnetic fields through which the car goes through, have interference in the processing? It's easy to understand that a strong field can corrupt data. But what about the data under processment? Can it also be changed?\nIf so how could...
What are good reasons to prohibit inheritance in Java, for example by using final classes or classes using a single, private parameterless constructor? What are good reasons of making a method final?
Prohibiting inheritance in Java can be a design choice for several reasons, particularly when using `final` classes or private constructors. Here are some of the good reasons for doing so: ### Reasons to Prohibit Inheritance 1. **Maintainability**: - **Control of Behavior**: When a class is marked as `final`, it e...
25,971
[ { "from": "human", "value": "What are good reasons to prohibit inheritance in Java, for example by using final classes or classes using a single, private parameterless constructor? What are good reasons of making a method final?\n" }, { "from": "gpt", "value": "Prohibiting inheritance in Java ca...
I'm trying to get rid of some spurious warnings in my SSIS Progress log. I'm getting a bunch of warnings about unused columns in tasks that use raw SQL to do their work. I have a Data Flow responsible for archiving data in a staging table prior to loading new data. The Data Flow looks like this: +--------------------+ ...
In SQL Server Integration Services (SSIS), when you're dealing with the situation of spurious warnings about unused output columns, there are a few approaches you can take to suppress these warnings in your logs: ### 1. Use a **Data Viewer** or a **Derived Column Transformation**: If you're getting warnings due to the...
33,666
[ { "from": "human", "value": "I'm trying to get rid of some spurious warnings in my SSIS Progress log. I'm getting a bunch of warnings about unused columns in tasks that use raw SQL to do their work. I have a Data Flow responsible for archiving data in a staging table prior to loading new data. The Data Flow...
Is it possible to add a wildcard application map in IIS6 from the wix installer package? I know how to add application extensions however can't see any way to add wildcards. This is needed for ASP.Net MVC to function properly.
In IIS 6, you cannot directly add a wildcard application map using a WiX installer package. However, you can achieve this by using a combination of WiX and a custom action or by using a tool like the command-line utility `adsutil.vbs` that comes with IIS. ### Using `adsutil.vbs` to Add Wildcard Application Mappings H...
33,452
[ { "from": "human", "value": "Is it possible to add a wildcard application map in IIS6 from the wix installer package? I know how to add application extensions however can't see any way to add wildcards.\nThis is needed for ASP.Net MVC to function properly.\n" }, { "from": "gpt", "value": "In IIS...
I'd like to write an extension method for string, which appears as a static method on System.String - I've not managed to get that done. Is that possible? If so how? Thanks!
In C#, extension methods cannot be directly added to existing types like `System.String` as static methods. Extension methods are syntactic sugar for calling a static method, but they must reside in a static class. This means that you cannot add methods to `System.String` itself, but you can add methods that can be cal...
29,391
[ { "from": "human", "value": "I'd like to write an extension method for string, which appears as a static method on System.String - I've not managed to get that done.\nIs that possible? If so how? Thanks!\n" }, { "from": "gpt", "value": "In C#, extension methods cannot be directly added to existi...
I am trying to sort a list of products by their name in a .Net application written in C#, to obtain the same list that I would get from an SQL Server database through an order by: select * from Products order by ProductName Unfortunately, the application sorting behaves differently than the database sorting. It is prob...
To sort strings in your C# application the same way they would be sorted in your SQL Server database using the `SQL_Latin1_General_CP1_CI_AS` collation, you need to replicate the behavior of that collation in your .NET code. The `SQL_Latin1_General_CP1_CI_AS` collation is case-insensitive and accent-sensitive. Here ar...
31,204
[ { "from": "human", "value": "I am trying to sort a list of products by their name in a .Net application written in C#, to obtain the same list that I would get from an SQL Server database through an order by:\nselect * from Products order by ProductName\nUnfortunately, the application sorting behaves differ...
What should every WPF developer know? Entry Level Strong .NET 2.0 Background & willing to learn! Explain dependency properties? What's a style? What's a template? Binding Differences between base classes: Visual, UIElement, FrameworkElement, Control Visual vs Logical tree? Property Change Notification (INotifyProperty...
Here’s a guide to what every WPF developer should know, organized by entry, mid, and senior-level topics: ### Entry Level 1. **Strong .NET Background**: Understanding .NET framework and C# fundamentals is essential for any WPF developer. 2. **Dependency Properties**: - Special type of properties in WPF that prov...
6,486
[ { "from": "human", "value": "What should every WPF developer know?\nEntry Level\n\nStrong .NET 2.0 Background & willing to learn!\nExplain dependency properties?\nWhat's a style?\nWhat's a template?\nBinding\nDifferences between base classes: Visual, UIElement, FrameworkElement, Control\nVisual vs Logical t...
I have both Fruityloops and Propellerheads Reason software synths on my Windows PC. Any way I can get at and script these from either Visual Basic or Python? Or at least send Midi messages to the synths from code? Update : attempts to use something like a "midi-mapper" (thanks for link MusiGenesis) don't seem to work. ...
Both FL Studio (Fruityloops) and Reason are powerful digital audio workstations (DAWs), and they provide different ways to interact programmatically. Below are some suggestions on how you can send MIDI messages and script interactions with these software synths using either Visual Basic or Python: ### Sending MIDI Mes...
31,229
[ { "from": "human", "value": "I have both Fruityloops and Propellerheads Reason software synths on my Windows PC.\nAny way I can get at and script these from either Visual Basic or Python? Or at least send Midi messages to the synths from code?\nUpdate : attempts to use something like a \"midi-mapper\" (than...
We are in a Windows environment and looking to automate this process for non-company machines. If a vendor comes on site, we'd like to be able to have him/her hit a website that can perform a quick scan of the workstation to determine if they have the proper MS KB patches and if their virus scanner dats are up to date...
Creating a solution to check for Microsoft KB patches and antivirus definitions on non-company machines involves a few steps, especially given the variability in antivirus software. Here’s a general approach to achieve your goals, primarily using web technologies and leveraging the Microsoft Security Center where possi...
31,362
[ { "from": "human", "value": "We are in a Windows environment and looking to automate this process for non-company machines. If a vendor comes on site, we'd like to be able to have him/her hit a website that can perform a quick scan of the workstation to determine if they have the proper MS KB patches and i...
Sometimes I have made some local changes and for whatever reason don't want to commit them to the source repository. In this case I like to zip up and save off my changes on my local file system until I am ready to commit them at a later date. I recall that in an earlier version of eclipse, there was a context sensiti...
In recent versions of Eclipse, the direct functionality to export a selection of files from the Synchronize view might not be explicitly available as it was in earlier versions. However, you can use a workaround to achieve your goal of saving off local changes without committing them. Here's how you can handle it: 1....
33,191
[ { "from": "human", "value": "Sometimes I have made some local changes and for whatever reason don't want to commit them to the source repository. In this case I like to zip up and save off my changes on my local file system until I am ready to commit them at a later date.\nI recall that in an earlier versi...
I've been reading about thread-safe singleton patterns here: http://en.wikipedia.org/wiki/Singleton_pattern#C.2B.2B_.28using_pthreads.29 And it says at the bottom that the only safe way is to use pthread_once - which isn't available on Windows. Is that the only way of guaranteeing thread safe initialisation? I've read ...
In C++, ensuring thread-safe lazy initialization of a singleton can indeed be a challenge, particularly if you're working across different platforms such as Windows and Unix-like systems. You are correct that `pthread_once` is a method for achieving this in POSIX environments, but Windows has different mechanisms. ###...
31,065
[ { "from": "human", "value": "I've been reading about thread-safe singleton patterns here:\nhttp://en.wikipedia.org/wiki/Singleton_pattern#C.2B.2B_.28using_pthreads.29\nAnd it says at the bottom that the only safe way is to use pthread_once - which isn't available on Windows.\nIs that the only way of guarant...
This very simple code gives me tons of errors: #include <iostream> #include <string> int main() { std::string test = " "; std::cout << test; } I tried to compile it on linux by typing gcc -o simpletest simpletest.cpp on the console. I can't see why it isn't working. What is happening?
The issue you are encountering is due to the fact that you are trying to compile C++ code using `gcc`, which is primarily a C compiler. To compile C++ code, you should use `g++`, which is specifically designed for compiling C++ code. Here's how you can compile your code correctly: 1. Save your code in a file named `...
35,230
[ { "from": "human", "value": "This very simple code gives me tons of errors:\n#include <iostream>\n#include <string>\n\nint main() {\n std::string test = \" \";\n std::cout << test;\n}\n\nI tried to compile it on linux by typing gcc -o simpletest simpletest.cpp on the console. I can't see why it isn't ...
Is it possible in a Compact Framework application to prevent the garbage collector from unconditionally stopping at least one of the threads, or to block GC collects at least in some portions of the code? I think it has to deal with setting real time priorities, but I found a lot of advice against doing it.
In the .NET Compact Framework, the garbage collector (GC) is designed to manage memory automatically, and it typically does not provide explicit controls for preventing the GC from stopping threads. In fact, managing GC behavior is generally discouraged because it can lead to complex and hard-to-maintain code, as well ...
34,234
[ { "from": "human", "value": "Is it possible in a Compact Framework application to prevent the garbage collector from unconditionally stopping at least one of the threads, or to block GC collects at least in some portions of the code?\nI think it has to deal with setting real time priorities, but I found a ...
I have a RichTextBox in .NET WinForms. I have been hooking up hot keys with KeyUp. Everything is working fine, except for CtrlI. By the time my handler gets its turn, the selection has been replaced with a '\t'. I turned off ShortcutsEnabled, but it didn't make any difference. Any ideas?
In a WinForms application, the `RichTextBox` control has some built-in shortcut keys that can interfere with custom hotkey handling. The `Ctrl + I` combination is one of the default shortcuts, which toggles the italic formatting for the selected text. Because of this, if you're handling the `KeyUp` event, the text sele...
32,452
[ { "from": "human", "value": "I have a RichTextBox in .NET WinForms. I have been hooking up hot keys with KeyUp. Everything is working fine, except for CtrlI. By the time my handler gets its turn, the selection has been replaced with a '\\t'. I turned off ShortcutsEnabled, but it didn't make any differen...
I have a line (actually a cube) going from (x1,y1,z1) to (x2,y2,z2). I would like to rotate it so that it is aligned along another line going from (x3,y3,z3) to (x4,y4,z4). Presently I am using Math::Atan2 along with Matrix::RotateYawPitchRoll. Any better ways to do this? Edit: I think I've worded this post very badly....
To align one vector (from (x1, y1, z1) to (x2, y2, z2)) to another vector (from (x3, y3, z3) to (x4, y4, z4)), you can compute a rotation matrix that performs this transformation. Here's how you can do this step-by-step: 1. **Calculate Direction Vectors**: First, you need to compute the direction vectors of the tw...
27,524
[ { "from": "human", "value": "I have a line (actually a cube) going from (x1,y1,z1) to (x2,y2,z2). I would like to rotate it so that it is aligned along another line going from (x3,y3,z3) to (x4,y4,z4). Presently I am using Math::Atan2 along with Matrix::RotateYawPitchRoll. Any better ways to do this?\nEdit:...
I have a simple database: ARTICLE ---------- ArticleId (PK), ArticleTitle ..other stuff... USER-ARTICLE ------------ ArchiveId (PK), UserId, ArticleId ..other stuff... The articleId's are foreign keys. I want to be able to delete a user article row by UserArticleId using the following code, UserArticle myobjtodelete...
The error message you're encountering, "Specified cast is not valid," generally indicates that there is a type mismatch occurring somewhere in your data model or when you're interacting with the database. Given the context, it's likely that the problem lies with how the `UserArticle` entity is defined or how the LINQ-t...
32,770
[ { "from": "human", "value": "I have a simple database:\nARTICLE\n----------\nArticleId (PK),\nArticleTitle\n..other stuff...\n\nUSER-ARTICLE\n------------\nArchiveId (PK),\nUserId,\nArticleId\n..other stuff...\n\nThe articleId's are foreign keys. \nI want to be able to delete a user article row by UserArtic...
How do you calculate the Content-Length is a soap message? Is it the number of chars in the whole soap message?
Yes, the `Content-Length` header in an HTTP request or response indicates the size of the message body in bytes. For a SOAP message, the `Content-Length` should be calculated as the number of bytes in the entire SOAP message body, which includes: 1. **The XML declaration (if present)**: The header typically starts wit...
34,474
[ { "from": "human", "value": "How do you calculate the Content-Length is a soap message? Is it the number of chars in the whole soap message?\n" }, { "from": "gpt", "value": "Yes, the `Content-Length` header in an HTTP request or response indicates the size of the message body in bytes. For a SO...
I'm especially interested in memory profiling, reducing the size of a compiled .swf, measuring network latency, etc. Also, I'm focussed entirely on AS3.
Memory profiling, optimizing the size of compiled SWF files, and measuring network latency are essential skills for optimizing ActionScript 3 (AS3) applications, especially in the context of Flash development. Here are some strategies and tools you can use for each of these aspects: ### Memory Profiling in AS3 1. **A...
30,896
[ { "from": "human", "value": "I'm especially interested in memory profiling, reducing the size of a compiled .swf, measuring network latency, etc. Also, I'm focussed entirely on AS3.\n" }, { "from": "gpt", "value": "Memory profiling, optimizing the size of compiled SWF files, and measuring netwo...
When I try to use curl or file_get_contents to read something like http://example.com/python/json/ from http://example.com/ I should be getting a JSON response, but instead I get a 404 error. Using curl or any other method outside my own domain works perfectly well. echo file_get_contents('http://example.com/python/jso...
The issue you are encountering, where you can access a URL externally but receive a 404 error when trying to access it from within your own domain, could stem from several potential causes. Here are some common reasons and troubleshooting steps to consider: ### 1. **Server Configuration / Restrictions** - **Virtual...
31,922
[ { "from": "human", "value": "When I try to use curl or file_get_contents to read something like http://example.com/python/json/ from http://example.com/ I should be getting a JSON response, but instead I get a 404 error. Using curl or any other method outside my own domain works perfectly well.\necho file_g...
I want to write a program for this: In a folder I have n number of files; first read one file and perform some operation then store result in a separate file. Then read 2nd file, perform operation again and save result in new 2nd file. Do the same procedure for n number of files. The program reads all files one by one ...
Certainly! Below is a simple example in Python that demonstrates how to read multiple files from a specified folder, perform some operation on each file, and store the results in separate output files. ### Example Python Program #### Prerequisites Make sure you have Python installed on your system. You can use any te...
31,474
[ { "from": "human", "value": "I want to write a program for this: In a folder I have n number of files; first read one file and perform some operation then store result in a separate file. Then read 2nd file, perform operation again and save result in new 2nd file. Do the same procedure for n number of files...
I've been trying to design a database schema for a side project but I havent been able to produce anything that I'm comfortable with. I'm using ASP.Net with LINQ for my data access: I'm going to allow users to specify up to 10 "items" each with 2 numeric properties, and 1 referential property, the item name. If I were ...
Your concerns about database design are valid, especially when you want to keep your schema scalable and maintainable. Let’s explore a solution that captures your requirements while avoiding excessive NULLs and maintaining clarity. ### Suggested Database Schema 1. **Entries Table** - This table will hold general i...
31,163
[ { "from": "human", "value": "I've been trying to design a database schema for a side project but I havent been able to produce anything that I'm comfortable with. I'm using ASP.Net with LINQ for my data access:\nI'm going to allow users to specify up to 10 \"items\" each with 2 numeric properties, and 1 ref...
I need a database where one (or more) fields behave like a wiki. I want the free-form content creation aspects of a wiki bolstered by the strict semantic structure of a database. Specifically, I need this database field to hold wiki-style markup, track multi-user changes, allow reverts, etc... I've come at this from a...
Creating a hybrid system that combines the flexibility of a wiki with the structured data capabilities of a database can be a complex task, but there are several approaches and technologies that can help you achieve your goal. Here are some suggestions based on your described needs: ### 1. **Use a Wiki Engine with Ext...
31,336
[ { "from": "human", "value": "I need a database where one (or more) fields behave like a wiki. I want the free-form content creation aspects of a wiki bolstered by the strict semantic structure of a database.\nSpecifically, I need this database field to hold wiki-style markup, track multi-user changes, allo...
I'm terribly new to SQL, and cannot seem to get the desired information out, after trying a few different google searches, and reading through some SQL tutorials. I think it involves some sort of joins, but cannot get them straight. Given the following sample tables: Table 1(Activity This is updated every time a change...
To get the desired results based on your description of the tables, we need to perform a few operations. Specifically, we'll need to join the tables together to filter out the relevant activities and comments associated with closed tasks. Here's how you can do it step by step: 1. **Identify Closed Tasks**: First, we'l...
32,381
[ { "from": "human", "value": "I'm terribly new to SQL, and cannot seem to get the desired information out, after trying a few different google searches, and reading through some SQL tutorials.\nI think it involves some sort of joins, but cannot get them straight.\nGiven the following sample tables:\nTable 1(...
Photoshop has that great: BiCube Shaper option for resizing. However I cannot find an equivalent. I've seen various code using GD that used imagecopyresampled and custom unsharp mask, but no where near the quality I am expecting. Any help?
If you're looking for a high-quality image resizing option in PHP similar to Photoshop's BiCubic Shaper, you can use the GD library with a combination of image resizing techniques and post-processing to improve the quality of your images. While GD's native functions may not match the exact quality of Photoshop's resizi...
26,955
[ { "from": "human", "value": "Photoshop has that great:\nBiCube Shaper option for resizing.\nHowever I cannot find an equivalent.\nI've seen various code using GD that used imagecopyresampled and custom unsharp mask, but no where near the quality I am expecting.\nAny help?\n" }, { "from": "gpt", ...
during beta testing we discovered connection pooling error messages . Therefore I have been going through the code and closing down the SqlDataReader objects wherever they have been left unclosed. What I need to know is how to close a datareader (or if there is a need at all to close) that is specified in the SelectSta...
When working with data access in .NET, particularly with `SqlDataReader`, it's essential to manage resources carefully to avoid issues like connection leaks. Let's clarify a few points regarding `SqlDataReader`, `SqlDataSource`, and `ObjectDataSource`. ### Closing SqlDataReader 1. **Explicitly Closing SqlDataReader**...
30,367
[ { "from": "human", "value": "during beta testing we discovered connection pooling error messages . Therefore I have been going through the code and closing down the SqlDataReader objects wherever they have been left unclosed. What I need to know is how to close a datareader (or if there is a need at all to ...
Can my webmethod only return strings like I see in all the asp.net site examples?
In ASP.NET, a WebMethod (often used in ASP.NET Web Services or ASMX services) can indeed return a variety of data types, not just strings. While many examples demonstrate returning strings for simplicity, you can return other types such as: 1. **Primitive Data Types**: Such as `int`, `bool`, `double`, etc. 2. **Custom...
32,335
[ { "from": "human", "value": "Can my webmethod only return strings like I see in all the asp.net site examples?\n" }, { "from": "gpt", "value": "In ASP.NET, a WebMethod (often used in ASP.NET Web Services or ASMX services) can indeed return a variety of data types, not just strings. While many ex...
I downloaded the Aptana_Studio_Setup_Linux.zip package, unpacked it and run ./AptanaStudio. It starts fine, but reports one problem: The embedded browser widget for this editor cannot be created. It is either not available for your operating system or the system needs to be configured in order to support embedded brows...
The issue you are experiencing with Aptana Studio and the embedded browser is relatively common, especially on Linux systems. Aptana Studio, which is built on the Eclipse platform, sometimes struggles with the embedded browser functionality because it relies on Mozilla's XULRunner or the native browser capabilities of ...
30,644
[ { "from": "human", "value": "I downloaded the Aptana_Studio_Setup_Linux.zip package, unpacked it and run ./AptanaStudio. It starts fine, but reports one problem:\nThe embedded browser widget for this editor cannot be created. It is either not available for your operating system or the system needs to be con...
Below is what I'm trying to achieve. The problem is "errors" is not defined. If I remove my match logic, the errors are displayed on the web page. Is there anyway of evaluating the text the error contains? <logic:messagesPresent> <tr> <td class="errorcicon"><img src="images/icon_caution.gif" width="18" heig...
The issue you're encountering stems from the fact that the `errors` object is not properly defined or accessible in the context of your JSP page. To evaluate the error messages effectively, you need to extract them correctly from the `html:errors` tag or the equivalent error collection. Here's a suggested approach to ...
31,074
[ { "from": "human", "value": "Below is what I'm trying to achieve. The problem is \"errors\" is not defined. If I remove my match logic, the errors are displayed on the web page. Is there anyway of evaluating the text the error contains?\n<logic:messagesPresent>\n <tr>\n <td class=\"errorcicon\"><i...
I am going to be making an application that lets users input several parameters for a bowling ball layout, and then show what that layout would look like on the ball. I have found some good resources for sphere math, so if I have a sphere whose center is (0,0,0), I will be able to get the values of the points I need o...
Creating a bowling ball layout application using .NET 2.0 and WinForms sounds like a fun project! Here’s a high-level approach to get you started on each part of your application: ### Step 1: Calculating Points on the Sphere To calculate the points on the surface of a sphere, you can use spherical coordinates. Given a...
29,830
[ { "from": "human", "value": "I am going to be making an application that lets users input several parameters for a bowling ball layout, and then show what that layout would look like on the ball. I have found some good resources for sphere math, so if I have a sphere whose center is (0,0,0), I will be able...
I'm attempting to resize pngs with transparent backgrounds in PHP and the code samples I've found online don't work for me. Here's the code I'm using, advice will be much appreciated! $this->image = imagecreatefrompng($filename); imagesavealpha($this->image, true); $newImage = imagecreatetruecolor($width, $height); /...
It looks like you're close to the correct implementation, but you're encountering issues with transparency in your resized PNGs. The black background you're seeing could result from incorrect handling of alpha transparency during the resizing process. Here's an improved version of your code with some explanations: ``...
32,962
[ { "from": "human", "value": "I'm attempting to resize pngs with transparent backgrounds in PHP and the code samples I've found online don't work for me. Here's the code I'm using, advice will be much appreciated!\n$this->image = imagecreatefrompng($filename);\n\nimagesavealpha($this->image, true);\n$newImag...
I want to get the overall total CPU usage for an application in C#. I've found many ways to dig into the properties of processes, but I only want the CPU usage of the processes, and the total CPU like you get in the TaskManager. How do I do that?
To get the overall total CPU usage for a specific application in C#, you can use the `System.Diagnostics` namespace which provides classes for working with processes. However, retrieving the overall CPU usage in a manner similar to Task Manager can be a bit complex since CPU usage is typically calculated over a period ...
29,858
[ { "from": "human", "value": "I want to get the overall total CPU usage for an application in C#. I've found many ways to dig into the properties of processes, but I only want the CPU usage of the processes, and the total CPU like you get in the TaskManager.\nHow do I do that?\n" }, { "from": "gpt", ...
In an application that is hosting several WCF services, what would be the best way to add custom configuration information for each service? For example you may want to pass or set a company name or specify the connectionString a service or some other parameter. I'm guessing this might be possible by implementing ISe...
To add custom configuration information for each WCF service through behaviors, you can indeed implement `IServiceBehavior`. Below are the detailed steps you can follow to achieve this, including a code example that demonstrates how to handle custom configuration data in the service behaviors. ### Step 1: Create a Cus...
30,471
[ { "from": "human", "value": "In an application that is hosting several WCF services, what would be the best way to add custom configuration information for each service? For example you may want to pass or set a company name or specify the connectionString a service or some other parameter. \nI'm guessing ...
I have a class that downloads, examines and saves some large XML files. Sometimes I want the UI to tell me what's going on, but sometimes I will use the class and ignore the events. So I have placed lines of code like this in a dozen places: RaiseEvent Report("Sending request: " & queryString) RaiseEvent Report("Savin...
In the context of .NET and event handling, if there are no subscribers (listeners) for an event when you raise it, the event will still fire, but there won't be any code executed in response to that event. Here's what you should know: 1. **Event Invocation Overhead**: Raising an event has a minor overhead, even if t...
34,425
[ { "from": "human", "value": "I have a class that downloads, examines and saves some large XML files. Sometimes I want the UI to tell me what's going on, but sometimes I will use the class and ignore the events. So I have placed lines of code like this in a dozen places:\nRaiseEvent Report(\"Sending request:...
From what I understand, the parent attribute of a db.Model (typically defined/passed in the constructor call) allows you to define hierarchies in your data models. As a result, this increases the size of the entity group. However, it's not very clear to me why we would want to do that. Is this strictly for ACID complia...
The `parent` attribute in a Google Cloud Datastore model is indeed used to establish hierarchical relationships among entities, which allows you to create a structure known as an entity group. Using entity groups has implications for transactions, consistency, and data retrieval. ### Advantages of Using Entity Groups ...
30,934
[ { "from": "human", "value": "From what I understand, the parent attribute of a db.Model (typically defined/passed in the constructor call) allows you to define hierarchies in your data models. As a result, this increases the size of the entity group. However, it's not very clear to me why we would want to d...
I have a TObjectList with OwnsObjects = true. It contains quite a few objects. Now I want to remove the object at index Idx from that list, without freeing it. Is the Extract method the only option? ExtractedObject := TheList.Extract(TheList[Idx]); All other methods seem to free the object. I am looking for something a...
In Delphi, when working with a `TObjectList` with `OwnsObjects = True`, the list will automatically free the objects when they are removed using the `Delete` or `Remove` methods. However, as you correctly noted, if you want to remove an object from the list without freeing it, the `Extract` method is the appropriate ch...
35,137
[ { "from": "human", "value": "I have a TObjectList with OwnsObjects = true. It contains quite a few objects. Now I want to remove the object at index Idx from that list, without freeing it.\nIs the Extract method the only option?\nExtractedObject := TheList.Extract(TheList[Idx]);\nAll other methods seem to f...
Ok guys and gals, here is my problem: I've built a custom control that uses a textbox to present data to the user. When the user interacts with the control the value of that textbox is altered with client side javascript. I also have a button on my page. When the user clicks the button I want to take the value from th...
You're encountering a common scenario when dealing with custom controls and client-side JavaScript in ASP.NET. When you manipulate the value of a textbox using client-side JavaScript, that change is reflected in the `Request.Form` collection during the postback, but not in the server-side control properties until the A...
33,578
[ { "from": "human", "value": "Ok guys and gals, here is my problem:\nI've built a custom control that uses a textbox to present data to the user. \nWhen the user interacts with the control the value of that textbox is altered with client side javascript.\nI also have a button on my page. When the user clicks...
My webapp (ASP.NET 2.0) consumes a webservice (asmx on 1.1 framework) on the same machine. After getting XML in return, I pass it to XslCompiledTransform for transform XML to HTML and it works fine. Yesterday I got a System.IO.FileNotFoundException frequently and don't know what causes this kind of problem. First loo...
The `System.IO.FileNotFoundException` you are encountering indicates that the .NET runtime is trying to access a temporary DLL file (in this case, `C:\WINDOWS\TEMP\sivvt5f6.dll`) that it cannot find. This issue may occur during the compilation of XSLT scripts when using the `XslCompiledTransform` class, which can gener...
33,823
[ { "from": "human", "value": "My webapp (ASP.NET 2.0) consumes a webservice (asmx on 1.1 framework) \non the same machine. After getting XML in return, I pass it to\n XslCompiledTransform for transform XML to HTML and it works fine.\nYesterday I got a System.IO.FileNotFoundException frequently and don't know...
I am getting a warning when trying to include the .net 3.5 sp1 prerequisite for my setup project. The warning states Prerequisite could not found for bootstrapping. Any suggestions? Thanks
The warning you are seeing indicates that the setup project is unable to locate the .NET Framework 3.5 SP1 prerequisite package required for bootstrapping. Here are several steps you can take to resolve this issue: ### 1. Install .NET Framework 3.5 SP1: Ensure that you have the .NET Framework 3.5 SP1 redistributable p...
30,878
[ { "from": "human", "value": "I am getting a warning when trying to include the .net 3.5 sp1 prerequisite for my setup project. The warning states Prerequisite could not found for bootstrapping.\nAny suggestions?\nThanks\n" }, { "from": "gpt", "value": "The warning you are seeing indicates that ...
I need to run a RLIKE query on a database mmoved from MySQL to SQL Server 2005 however having problems replicating the "RLIKE" functionality that MySQL provides. Does anyone have any ideas? Cheers, Chris
In MySQL, `RLIKE` is used for regular expression matching, but SQL Server 2005 does not support regular expressions natively. Instead, SQL Server uses different methods for pattern matching, such as the `LIKE` operator and the `PATINDEX` function, but these do not support full regular expression syntax. However, you c...
30,996
[ { "from": "human", "value": "I need to run a RLIKE query on a database mmoved from MySQL to SQL Server 2005 however having problems replicating the \"RLIKE\" functionality that MySQL provides.\nDoes anyone have any ideas?\nCheers,\nChris\n" }, { "from": "gpt", "value": "In MySQL, `RLIKE` is used...
I would like to be able to export my WF diagram from visual studio 2008 into Visio so I can better show it to non-programmers. Dose anyone know if its possible? I haven't come across any mention of it before, and I don't see anything that jumps out at me from VS. [EDIT: WF = Windows Workflow Foundation]
Exporting a Windows Workflow Foundation (WF) diagram directly from Visual Studio 2008 to Microsoft Visio is not a straightforward process, as Visual Studio does not provide a built-in feature to export WF diagrams in a Visio-compatible format. However, you can consider a few approaches to achieve this: ### Manual Expo...
35,158
[ { "from": "human", "value": "I would like to be able to export my WF diagram from visual studio 2008 into Visio so I can better show it to non-programmers. Dose anyone know if its possible? I haven't come across any mention of it before, and I don't see anything that jumps out at me from VS.\n[EDIT: WF = Wi...
I acquired a database from another developer. He didn't use auto_incrementers on any tables. They all have primary key ID's, but he did all the incrementing manually, in code. Can I turn those into Auto_incrementers now? Wow, very nice, thanks a ton. It worked without a hitch on one of my tables. But a second table,...
It sounds like you're trying to convert an existing primary key column in your database to use `AUTO_INCREMENT`, but you're encountering an error related to renaming the temporary table that MySQL creates during this process. Here's a general approach you can take to troubleshoot and resolve this issue. ### Steps to C...
32,744
[ { "from": "human", "value": "I acquired a database from another developer. He didn't use auto_incrementers on any tables. They all have primary key ID's, but he did all the incrementing manually, in code.\nCan I turn those into Auto_incrementers now?\n\nWow, very nice, thanks a ton. It worked without a hi...
Is there an algorithm for accurately multiplying two arbitrarily long integers together? The language I am working with is limited to 64-bit unsigned integer length (maximum integer size of 18446744073709551615). Realistically, I would like to be able to do this by breaking up each number, processing them somehow using...
Yes, there are several algorithms for multiplying large integers by breaking them up into smaller parts that can fit into the 64-bit unsigned integers. One of the most common methods for this is known as the **Karatsuba algorithm**, which reduces the multiplication of two n-digit numbers to at most three multiplication...
28,200
[ { "from": "human", "value": "Is there an algorithm for accurately multiplying two arbitrarily long integers together? The language I am working with is limited to 64-bit unsigned integer length (maximum integer size of 18446744073709551615). Realistically, I would like to be able to do this by breaking up e...
I'd like to write a MessageConverter class that can wrap another MessageConverter. This MessageConverter would call the child converter, which is assumed to generate a TextMessage. It would take the payload and GZIP compress it, creating a BytesMessage which is ultimately returned to the sender. The problem is in writi...
Creating a wrapper `MessageConverter` that GZIP compresses a `TextMessage` payload can be a bit tricky, especially when it comes to handling the conversion back from a `BytesMessage` to the original `TextMessage`. Given your requirements and constraints, here’s an approach you can consider that avoids creating a "dummy...
28,195
[ { "from": "human", "value": "I'd like to write a MessageConverter class that can wrap another MessageConverter. This MessageConverter would call the child converter, which is assumed to generate a TextMessage. It would take the payload and GZIP compress it, creating a BytesMessage which is ultimately return...
I downloaded a VM image of a web application that uses MySQL. How can I monitor its space consumption and know when additional space must be added?
Monitoring the disk space consumption of a VM image that hosts a web application using MySQL is crucial to ensure that you can respond to storage needs in a timely manner. Here are several ways to monitor space consumption, particularly focusing on the MySQL database and the overall VM. ### 1. Monitor Disk Space Usage...
25,350
[ { "from": "human", "value": "I downloaded a VM image of a web application that uses MySQL.\nHow can I monitor its space consumption and know when additional space must be added?\n" }, { "from": "gpt", "value": "Monitoring the disk space consumption of a VM image that hosts a web application usin...
I've been struggling coming up with a good solution to separate my testing data from unit tests (hard coded values). Until it dawned on me that I could create beans with spring and use those beans to hold my data. Are there any draw backs to coding my unit tests this way? Albeit they run a bit slower seeing as h...
Using Spring beans to manage your test data can indeed provide a more organized and reusable structure for your unit tests. However, there are several pros and cons to consider regarding this approach: ### Pros: 1. **Centralized Configuration**: By using Spring beans, you can centralize the configuration of your test...
30,732
[ { "from": "human", "value": "I've been struggling coming up with a good solution to separate my testing data from unit\n tests (hard coded values). Until it dawned on me that I could create beans with spring \nand use those beans to hold my data. \nAre there any draw backs to coding my unit tests this way...
If something is making a single-thread program take, say, 10 times as long as it should, you could run a profiler on it. You could also just halt it with a "pause" button, and you'll see exactly what it's doing. Even if it's only 10% slower than it should be, if you halt it more times, before long you'll see it repeat...
Your analysis presents an interesting approach to identifying performance bottlenecks in single-threaded applications using sampling techniques. While traditional profiling tools can provide detailed insights into function call timings, your method of taking "samples" by halting the program at various points offers an ...
31,140
[ { "from": "human", "value": "If something is making a single-thread program take, say, 10 times as long as it should, you could run a profiler on it. You could also just halt it with a \"pause\" button, and you'll see exactly what it's doing. \nEven if it's only 10% slower than it should be, if you halt it ...
I have heard that closures could be introduced in the next Java standard that is scheduled to be released somewhere around next summer. What would this syntax look like? I read somewhere that introducing closures in java is a bigger change than generic was in java 5. Is this true? pros and cons? (By now we definitely ...
As of now, closures (often referred to as lambda expressions) were indeed introduced in Java 8, which was released in March 2014. This was a significant enhancement to the Java programming language, allowing for a more functional programming style. ### Syntax for Closures (Lambda Expressions) The syntax for lambda e...
31,031
[ { "from": "human", "value": "I have heard that closures could be introduced in the next Java standard that is scheduled to be released somewhere around next summer. \nWhat would this syntax look like?\nI read somewhere that introducing closures in java is a bigger change than generic was in java 5. Is this ...
I have a Python list, say l = [1,5,8] I want to write a SQL query to get the data for all the elements of the list, say select name from students where id = |IN THE LIST l| How do I accomplish this?
To use a list in a SQL query, you can utilize the `IN` clause, which allows you to specify multiple values in a `WHERE` condition. In your case, since you have a Python list, you'll need to convert that list to a format that can be used in SQL. Here’s how to do it in Python: 1. Convert the list to a string that forma...
34,993
[ { "from": "human", "value": "I have a Python list, say\nl = [1,5,8]\n\nI want to write a SQL query to get the data for all the elements of the list, say\nselect name from students where id = |IN THE LIST l|\n\nHow do I accomplish this?\n" }, { "from": "gpt", "value": "To use a list in a SQL quer...
Is there a way to compile a .vbproj or .csproj project file directly, just like Visual Studio does? When you compile in Visual Studio, the "output" window shows the actual call to the compiler, which normally looks like: vbc.exe [bunch of options] [looooong list of .vb files] I would like to programatically call "somet...
Yes, you can compile .vbproj and .csproj files programmatically without needing Visual Studio installed, by using MSBuild. MSBuild is a build platform for managing and building projects, and it can work directly with project files, including .vbproj and .csproj files. Here’s how you can use MSBuild to compile a Visual...
31,045
[ { "from": "human", "value": "Is there a way to compile a .vbproj or .csproj project file directly, just like Visual Studio does?\nWhen you compile in Visual Studio, the \"output\" window shows the actual call to the compiler, which normally looks like:\nvbc.exe [bunch of options] [looooong list of .vb files...
I want to be able to selectively copy a list of files and preserve their directory structure. The problem is that there are quite a few files that their path exceeds 256 character. How is this problem usually handled? Edit: I should make it clear that I only want to selectively copy files, not folders. I don't think...
When you need to selectively copy files while preserving their directory structure, and you're facing the limitation of path lengths exceeding 256 characters, you have a few options to consider. Here are some methods you can use to achieve this: ### 1. Use a Script with PowerShell PowerShell can help you selectively ...
30,743
[ { "from": "human", "value": "I want to be able to selectively copy a list of files and preserve their directory structure. The problem is that there are quite a few files that their path exceeds 256 character. How is this problem usually handled?\nEdit:\nI should make it clear that I only want to selectiv...
I could do this in C#.. int number = 2; string str = "Hello " + number + " world"; ..and str ends up as "Hello 2 world". In VB.NET i could do this.. Dim number As Integer = 2 Dim str As String = "Hello " + number + " world" ..but I get an InvalidCastException "Conversion from string "Hello " to type 'Double' is not v...
In VB.NET, the behavior of the `+` operator can lead to confusion due to operator overloading. When you use the `+` operator to concatenate strings and numbers, VB.NET can sometimes interpret the operation in a different way compared to C#. ### Explanation: 1. **Operator Overloading**: In VB.NET, the `+` operator ca...
33,089
[ { "from": "human", "value": "I could do this in C#..\nint number = 2;\nstring str = \"Hello \" + number + \" world\";\n\n..and str ends up as \"Hello 2 world\".\nIn VB.NET i could do this..\nDim number As Integer = 2\nDim str As String = \"Hello \" + number + \" world\"\n\n..but I get an InvalidCastExceptio...
On my Mac OS X 10.5 (Leopard) machine, I have installed Git 1.6.0.2 using the git-OSX-Installer from Google Code. The installer installs Git to /usr/local/Git. I would now like to keep up with the latest stable Git release (Master branch), currently 1.6.0.3. Can I run "git clone git://git.kernel.org/pub/scm/git/git.git...
Yes, you can clone the Git repository and compile it from source to keep your Git installation updated. Here’s how you can do it on your Mac OS X 10.5 (Leopard) machine: 1. **Install Required Dependencies**: Before you compile Git, make sure you have the necessary build tools and libraries. You will need Xcode and pot...
33,040
[ { "from": "human", "value": "On my Mac OS X 10.5 (Leopard) machine, I have installed Git 1.6.0.2 using the git-OSX-Installer from Google Code. The installer installs Git to /usr/local/Git.\nI would now like to keep up with the latest stable Git release (Master branch), currently 1.6.0.3.\nCan I run \"git cl...
I have a Nant build script which CruiseControl uses to build a solution on-demand. However, we only recently got CruiseControl so our official build number is different from what is listed in CruiseControl. I know CruiseControl injects some properties into build scripts so that I can access the CC build number in the s...
To pass a value back to CruiseControl for the build number in your NAnt build script, you can use the `ccnet` command line arguments and configure your `ccnet` project accordingly. Here's a step-by-step approach on how to achieve this: 1. **Edit your NAnt Build Script**: Modify your NAnt build script to read the off...
33,911
[ { "from": "human", "value": "I have a Nant build script which CruiseControl uses to build a solution on-demand.\nHowever, we only recently got CruiseControl so our official build number is different from what is listed in CruiseControl.\nI know CruiseControl injects some properties into build scripts so tha...
I am trying to write a replacement regular expression to surround all words in quotes except the words AND, OR and NOT. I have tried the following for the match part of the expression: (?i)(?<word>[a-z0-9]+)(?<!and|not|or) and (?i)(?<word>[a-z0-9]+)(?!and|not|or) but neither work. The replacement expression is simp...
To create a regular expression that matches words surrounded by quotes while excluding certain words (AND, OR, NOT), you can use negative lookahead assertions. Here's how to structure the regular expression: ### Regular Expression ``` (?i)\b(?!and\b|or\b|not\b)([a-z0-9]+)\b ``` ### Explanation - `(?i)`: This makes th...
34,288
[ { "from": "human", "value": "I am trying to write a replacement regular expression to surround all words in quotes except the words AND, OR and NOT. \nI have tried the following for the match part of the expression:\n(?i)(?<word>[a-z0-9]+)(?<!and|not|or)\n\nand \n(?i)(?<word>[a-z0-9]+)(?!and|not|or)\n\nbut ...
I have the following method in my unit test project: [TestMethod] [HostType("ASP.NET")] [UrlToTest("http://localhost:3418/Web/SysCoord/ChooseEPA.aspx")] [AspNetDevelopmentServerHost("%PathToWebRoot%")] public void TestMethod1() { Page page = TestContext.RequestedPage; Assert.IsTr...
It looks like you are dealing with a couple of issues while trying to run unit tests against an ASP.NET application using the TestMethod attributes in Visual Studio. Let's break down the main points and see if we can troubleshoot them: ### 1. 404 Not Found Error Initially, you were receiving a 404 error related to `VS...
27,398
[ { "from": "human", "value": "I have the following method in my unit test project:\n [TestMethod]\n [HostType(\"ASP.NET\")]\n [UrlToTest(\"http://localhost:3418/Web/SysCoord/ChooseEPA.aspx\")]\n [AspNetDevelopmentServerHost(\"%PathToWebRoot%\")]\n public void TestMethod1()\n {\n Page...
UPDATE So it turns out internet exploder's stranglehold on "security" to "make up" for being so bad at security was causing my problems. I should have checked that out first haha. Thanks everyone for the input, it has given me ideas on how to optimize my application :D I am writing a web app (in ASP.NET 3.5) that in...
It looks like you're dealing with an issue where the form data sent via POST is not being received correctly by your ASP.NET web application. Here are some things to consider that might help you troubleshoot and resolve the issue: 1. **Form Submission Issues**: Make sure that the form is properly submitting the data. ...
33,429
[ { "from": "human", "value": "UPDATE\nSo it turns out internet exploder's stranglehold on \"security\" to \"make up\" for being so bad at security was causing my problems. I should have checked that out first haha. Thanks everyone for the input, it has given me ideas on how to optimize my application :D\n\...
Is there a way to change the colors used by plain Win32 menus (background, text, and highlight) for a single process, without using SetSysColors? (SetSysColors does a global change, which is bad, and if you crash or forget to set the colors back with SetSysColors again before exiting, they will not be restored until yo...
Changing the colors of plain Win32 menus for a single process without affecting the global system colors is challenging. Unfortunately, the Win32 API does not provide a direct way to customize the menu colors on a per-process basis. The `SetSysColors` function changes the system's color scheme and does not allow for ta...
28,129
[ { "from": "human", "value": "Is there a way to change the colors used by plain Win32 menus (background, text, and highlight) for a single process, without using SetSysColors?\n(SetSysColors does a global change, which is bad, and if you crash or forget to set the colors back with SetSysColors again before e...
As they are in .Net 3.5. I know they are in 4.0, as that's what the DLR works with, but I'm interested in the version we have now.
In .NET Framework 3.5, there are several features and libraries available, but the Dynamic Language Runtime (DLR) was not fully integrated until .NET Framework 4.0. However, some dynamic features can be approximated in 3.5 through the use of reflection and other techniques, although it won't be as seamless or powerful ...
34,371
[ { "from": "human", "value": "As they are in .Net 3.5. I know they are in 4.0, as that's what the DLR works with, but I'm interested in the version we have now.\n" }, { "from": "gpt", "value": "In .NET Framework 3.5, there are several features and libraries available, but the Dynamic Language Run...
I have a method with an out parameter that tries to do a type conversion. Basically: public void GetParameterValue(out object destination) { object paramVal = "I want to return this. could be any type, not just string."; destination = null; // default out param to null destination = Convert.ChangeType(para...
It seems like you're encountering a common issue when dealing with `out` parameters and type inference in C#. Your design intention is to create a method that retrieves a parameter value from an Oracle stored procedure, allowing for type-safe conversions. However, you run into a limitation where the type of the `out` p...
30,501
[ { "from": "human", "value": "I have a method with an out parameter that tries to do a type conversion. Basically:\npublic void GetParameterValue(out object destination)\n{\n object paramVal = \"I want to return this. could be any type, not just string.\";\n\n destination = null; // default out param t...
I would like to look at some examples of some good form layouts (web-based) that have a lot of input fields. I do a lot of web application development and a lot of my forms are input element heavy so I am always looking for good ideas on how to display my forms. For example I have a few list boxes and a lot of text box...
Designing effective forms, especially those with numerous input fields, can be a challenging but critical aspect of web application development. Here are some best practices and examples to help inspire your form layouts: ### Best Practices for Form Layouts 1. **Grouping Related Fields**: Group related fields togethe...
27,916
[ { "from": "human", "value": "I would like to look at some examples of some good form layouts (web-based) that have a lot of input fields. I do a lot of web application development and a lot of my forms are input element heavy so I am always looking for good ideas on how to display my forms. For example I ha...
I have a C# app which uses a System.Diagnostics.Process to run another exe. I ran into some example code where the process is started in a try block and closed in a finally block. I also saw example code where the process is not closed. What happens when the process is not closed? Are the resources used by the proc...
When you start a new process in a C# application using `System.Diagnostics.Process`, it runs independently of the parent process (your application). Here are the answers to your questions: ### What Happens When the Process Is Not Closed? When a process is started but not properly closed, a few things can happen: 1. ...
31,732
[ { "from": "human", "value": "I have a C# app which uses a System.Diagnostics.Process to run another exe. I ran into some example code where the process is started in a try block and closed in a finally block. I also saw example code where the process is not closed.\nWhat happens when the process is not cl...
What's the easiest programmatic way to restart a service on a remote Windows system? Language or method doesn't matter as long as it doesn't require human interaction.
There are several programmatic methods to restart a service on a remote Windows system without human interaction. Below are a few of the most common approaches: ### 1. Using PowerShell Remoting PowerShell Remoting is a built-in feature in Windows that allows you to run commands on remote computers. **Step 1**: Enabl...
31,217
[ { "from": "human", "value": "What's the easiest programmatic way to restart a service on a remote Windows system? Language or method doesn't matter as long as it doesn't require human interaction.\n" }, { "from": "gpt", "value": "There are several programmatic methods to restart a service on a r...
I've been working on a visualization project for 2-dimensional continuous data. It's the kind of thing you could use to study elevation data or temperature patterns on a 2D map. At its core, it's really a way of flattening 3-dimensions into two-dimensions-plus-color. In my particular field of study, I'm not actually wo...
It sounds like you're making great progress on your visualization project! Contour line generation for 2D continuous data can be quite complex, especially when aiming for high-quality, visually appealing output. Here are some detailed suggestions and considerations that could assist with your implementation: ### 1. **...
29,649
[ { "from": "human", "value": "I've been working on a visualization project for 2-dimensional continuous data. It's the kind of thing you could use to study elevation data or temperature patterns on a 2D map. At its core, it's really a way of flattening 3-dimensions into two-dimensions-plus-color. In my parti...
I am synchronizing tables using a stored PL/SQL procedure as part of a web application - when they hit a button it does the sync. The PL/SQL is executing as user A, but needs to disable indexes and sync a couple of tables in schema B. I can't get user A to 'alter index B.indexName unusable' despite granting it 'alter...
The issue you're experiencing, where user A cannot alter an index in schema B, could be due to several potential reasons. Here are some steps and considerations that may help you troubleshoot and resolve the issue: 1. **Check the Index Existence**: Ensure that the index you're trying to alter actually exists in schema...
31,604
[ { "from": "human", "value": "I am synchronizing tables using a stored PL/SQL procedure as part of a web application - when they hit a button it does the sync. The PL/SQL is executing as user A, but needs to disable indexes and sync a couple of tables in schema B. I can't get user A to 'alter index B.index...
I am trying to convert a date with individual parts such as 12, 1, 2007 into a datetime in SQL Server 2005. I have tried the following: CAST(DATEPART(year, DATE)+'-'+ DATEPART(month, DATE) +'-'+ DATEPART(day, DATE) AS DATETIME) but this results in the wrong date. What is the correct way to turn the three date values i...
In SQL Server, you can construct a datetime from individual parts (day, month, year) using the `CONVERT` or `CAST` functions with a string representation of the date. However, your current attempt is using `DATEPART`, which is not necessary since you already have the individual parts. Here's how you can create a datet...
34,246
[ { "from": "human", "value": "I am trying to convert a date with individual parts such as 12, 1, 2007 into a datetime in SQL Server 2005. I have tried the following:\nCAST(DATEPART(year, DATE)+'-'+ DATEPART(month, DATE) +'-'+ DATEPART(day, DATE) AS DATETIME)\n\nbut this results in the wrong date. What is the...
I have a simple Google App Engine app, that I wrote using ordinary strings. I realize I want to make it handle unicode. Are there any gotchas with this? I'm thinking of all the strings that I currently already have in the live database. (From real users who I don't want to upset.)
When updating a Google App Engine app to handle Unicode, there are several considerations and potential gotchas to be aware of, especially since you have existing data in your database. Here are some key points to keep in mind: ### 1. Database Schema - **Data Type Support**: Ensure that your database supports Unicode....
25,639
[ { "from": "human", "value": "I have a simple Google App Engine app, that I wrote using ordinary strings. I realize I want to make it handle unicode. Are there any gotchas with this? I'm thinking of all the strings that I currently already have in the live database. (From real users who I don't want to upset...
We've been using Trac for task/defect tracking and things were going well enough, but this morning it started serving up a 500 error. Looking in the Apache error_log, I get a stack trace that culminates in: PythonHandler trac.web.modpython_frontend: ExtractionError: Can't extract file(s) to egg cache The following ...
It sounds like you're encountering a permissions issue with the Python egg cache directory while using Trac with Apache. Before considering a reinstall of Trac, let's try to troubleshoot the issue step-by-step: ### Step 1: Verify Environment Variable Setup 1. **Check Apache Configuration:** Ensure that you've correct...
28,590
[ { "from": "human", "value": "We've been using Trac for task/defect tracking and things were going well enough, but this morning it started serving up a 500 error. Looking in the Apache error_log, I get a stack trace that culminates in:\n\nPythonHandler trac.web.modpython_frontend:\n ExtractionError: Can't ...
I have implemented VirtualPathProvider class so I can keep all my views in the database instead of FileSystem of web server. It seems MVC requests aspx page correctly from Database, but unable to request related codebehind .cs files and throws error as unable to load the code-behind class file. This virtualPathProvider...
In ASP.NET MVC, the architecture and lifecycle are quite different from Web Forms. While the `VirtualPathProvider` approach you're using may work well for serving views from a database in a Web Forms application, there are some additional considerations you'll need to take into account when it comes to MVC. ### Key Co...
30,777
[ { "from": "human", "value": "I have implemented VirtualPathProvider class so I can keep all my views in the database instead of FileSystem of web server.\nIt seems MVC requests aspx page correctly from Database, but unable to request related codebehind .cs files and throws error as unable to load the code-b...
I'm building a .net application with windows forms. I'm pondering on the following problem: If I specify fonts in my application that are available only in Vista and Office 07, what will happen when the application tries to run in a machine without these ? I suppose the system won't be able to fall back to a font of it...
When building a Windows Forms application, using fonts that are not universally available on all target operating systems can lead to issues if those fonts are not present on the user's machine. Here's what you can do to handle this situation effectively: ### 1. **Use Common Fonts** First, consider sticking to common ...
30,467
[ { "from": "human", "value": "I'm building a .net application with windows forms. I'm pondering on the following problem: If I specify fonts in my application that are available only in Vista and Office 07, what will happen when the application tries to run in a machine without these ?\nI suppose the system ...
This is something that I have always wondered about, but never bothered to profile. Is it more efficient to assign a value to a temp variable, than to keep using that value. An Example may be clearer: string s = reader.GetItem[0].ToString(); someClass.SomeField = s; someOtherClass.someField = s; OR someClass.SomeFiel...
You're correct in your initial assumption that assigning the value to a temporary variable can be more efficient than accessing the same value multiple times, particularly in cases where the method has overhead, such as `reader.GetItem[0].ToString()`. ### Performance Considerations 1. **Method Calls**: Calling method...
31,995
[ { "from": "human", "value": "This is something that I have always wondered about, but never bothered to profile.\nIs it more efficient to assign a value to a temp variable, than to keep using that value. An Example may be clearer:\nstring s = reader.GetItem[0].ToString();\nsomeClass.SomeField = s;\nsomeOth...
I've created a one-line batch file to run SqlMetal to regenerate a LINQ to SQL DataContext for my database; this works great. Refresh_DataContext.bat: "C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\sqlmetal.exe" /server:.\sqlexpress /database:MyDatabaseName /code:"%~dp0\DataContext.vb" /context:DataCon...
To run your batch file automatically during the build process in Visual Studio, you can utilize the pre-build events feature. Here's how you can set it up: 1. **Open Your Project Properties**: - Right-click on your project in Solution Explorer and select "Properties." 2. **Navigate to Build Events**: - In the P...
33,460
[ { "from": "human", "value": "I've created a one-line batch file to run SqlMetal to regenerate a LINQ to SQL DataContext for my database; this works great. \nRefresh_DataContext.bat:\n\"C:\\Program Files\\Microsoft SDKs\\Windows\\v6.0A\\Bin\\sqlmetal.exe\" \n /server:.\\sqlexpress /database:MyDatabaseNam...
I would like to sign a device, and I have 64 bits to store my signature in the device. This device has a MAC address and some other details (about 30 bytes worth) I can mangle to create my signature. If possible, I would like the method to be one-way, so that I can verify that the signature is valid without knowing ho...
Using a cryptographic hash function combined with some secret bit manipulation is indeed a valid approach given your constraints. You can create a signature from the device's details (e.g., MAC address and other attributes) and a secret key. Here's how you can do this in Python: 1. Use a cryptographic hash function li...
33,966
[ { "from": "human", "value": "I would like to sign a device, and I have 64 bits to store my signature in the device. This device has a MAC address and some other details (about 30 bytes worth) I can mangle to create my signature. \nIf possible, I would like the method to be one-way, so that I can verify that...
I created a StateMachine workflow for sharepoint and at one state, I create multiple tasks using a replicator. The number of tasks created is variable. I need to handle the OnTaskChanged event for all the tasks I created which seems impossible as one event handler can only be associated with one task. I can use a ...
Handling the `OnTaskChanged` event for a dynamic number of tasks in a SharePoint State Machine workflow can be challenging because, as you noted, each task can only have one event handler associated with it. Here are some potential workarounds that could help you achieve the desired functionality: ### 1. Use a Single ...
33,743
[ { "from": "human", "value": "I created a StateMachine workflow for sharepoint and at one state, I create multiple tasks using a replicator. The number of tasks created is variable. \nI need to handle the OnTaskChanged event for all the tasks I created which seems impossible as one event handler can only ...
I'm a C/C++ developer, and here are a couple of questions that always baffled me. Is there a big difference between "regular" code and inline code? Which is the main difference? Is inline code simply a "form" of macros? What kind of tradeoff must be done when choosing to inline your code? Thanks
These are great questions that delve into the intricacies of C/C++ programming, particularly regarding inline functions and their relationship to other constructs like macros. Let's break them down: ### 1. Is there a big difference between "regular" code and inline code? Yes, there is a significant difference between ...
24,739
[ { "from": "human", "value": "I'm a C/C++ developer, and here are a couple of questions that always baffled me.\n\nIs there a big difference between \"regular\" code and inline code?\nWhich is the main difference?\nIs inline code simply a \"form\" of macros?\nWhat kind of tradeoff must be done when choosing ...
We are developing a Winforms application and in the process of optimizing the start-up time. The app runs on 64 bit Vista machines. In our testing we found what seems like a counter intuitive result. All else equal, targeting 32-bit vs 64-bit loads in half the time. Can anyone shed some light as to why? Thanks. [Edi...
The difference in startup times between the 32-bit and 64-bit versions of your WinForms application can be attributed to a few factors, especially given your mention of the presence of 32-bit DLLs in your project. Here are some key points to consider: 1. **DLL Loading**: When your application targets x86, it runs in a...
30,509
[ { "from": "human", "value": "We are developing a Winforms application and in the process of optimizing the start-up time.\nThe app runs on 64 bit Vista machines. In our testing we found what seems like a counter intuitive result. All else equal, targeting 32-bit vs 64-bit loads in half the time. Can anyon...
I'm not sure how to describe this problem, so I think an example is the best way to ask my question: I have two tables with a manyToMany relationship: DriversLicence <-> LicenceClass LicenceClass is things like "Car", "Motorbike", and "Medium Rigid". Using Hibernate Criteria, how can I find all licences that have both ...
To find all `DriversLicence` entities that have both the `LicenceClass` "Car" and "Motorbike" using Hibernate Criteria, you can achieve this by constructing the query to group the results based on the driver’s licence and then filter out those that have both classes. Here’s how you can approach this in both SQL and Hib...
30,541
[ { "from": "human", "value": "I'm not sure how to describe this problem, so I think an example is the best way to ask my question:\nI have two tables with a manyToMany relationship:\nDriversLicence <-> LicenceClass\nLicenceClass is things like \"Car\", \"Motorbike\", and \"Medium Rigid\".\nUsing Hibernate Cr...
I am trying to do the following in ASP.NET 3.5. Basically, I am binding a LINQDataSource to a DataList. There is a property called "Deleted" and if it is true, I want to display different markup. The following code throws errors: <asp:DataList runat="server"> <ItemTemplate> <% If CBool(Eval("Deleted")) T...
In ASP.NET Web Forms, you can use the `<%# %>` syntax for data binding expressions, but you cannot directly use VB.NET conditional statements (`If ... Then ... Else ...`) within the `ItemTemplate` of a DataList. Instead, you can use the `Visible` property of child controls or utilize a nested control structure for this...
30,928
[ { "from": "human", "value": "I am trying to do the following in ASP.NET 3.5. Basically, I am binding a LINQDataSource to a DataList. There is a property called \"Deleted\" and if it is true, I want to display different markup. The following code throws errors:\n<asp:DataList runat=\"server\">\n <ItemT...
I have a specialized list that holds items of type IThing: public class ThingList : IList<IThing> {...} public interface IThing { Decimal Weight { get; set; } Decimal Velocity { get; set; } Decimal Distance { get; set; } Decimal Age { get; set; } Decimal AnotherValue { get; set; } [...even mor...
To achieve the ability to get the maximum or minimum of different properties without resorting to reflection, you can use delegates or lambda expressions (if your version of .NET allows it) to pass a function that retrieves the desired property value. This approach adheres to the "Tell, Don't Ask" principle while avoid...
23,043
[ { "from": "human", "value": "I have a specialized list that holds items of type IThing:\npublic class ThingList : IList<IThing>\n{...}\n\npublic interface IThing\n{\n Decimal Weight { get; set; }\n Decimal Velocity { get; set; }\n Decimal Distance { get; set; }\n Decimal Age { get; set; }\n D...