instruction
stringlengths
14
27.6k
completion
stringlengths
3
38.3k
__original_row_idx
int64
0
50k
conversations
listlengths
2
2
At work I work closely with MS-Office. I have managed to generate some scripts that perform various tasks. While I can port functions to VBA with some difficulty, I do not fully understand the foundations of the VBA language. Items for which I seek basic syntax and examples include: 'hello world' program, loops, flow c...
Certainly! Below is an overview of the basic syntax and examples for the items you mentioned in VBA, along with explanations of key concepts. While I can't provide a direct link, I can summarize these items in a way that's easy to follow. ### 1. Hello World Program A simple "Hello World" program in VBA can be created ...
44,765
[ { "from": "human", "value": "At work I work closely with MS-Office. I have managed to generate some scripts that perform various tasks. While I can port functions to VBA with some difficulty, I do not fully understand the foundations of the VBA language.\nItems for which I seek basic syntax and examples inc...
I would like to log the name of all the files I access from a particular network share (and the process accessing the the file). What are the solutions in C++ / Win32 preferably ?
To log the names of all files accessed from a particular network share in a C++ application using the Win32 API, you can utilize the following approaches: ### 1. **File System Filter Driver:** This is the most comprehensive way to monitor file accesses, including logging the process that accesses the file. A file s...
46,115
[ { "from": "human", "value": "I would like to log the name of all the files I access from a particular network share (and the process accessing the the file).\nWhat are the solutions in C++ / Win32 preferably ?\n" }, { "from": "gpt", "value": "To log the names of all files accessed from a particu...
Is there a way to identify at run-time of an executable is being run from within valgrind? I have a set of C++ unit tests, and one of them expects std::vector::reserve to throw std::bad_alloc. When I run this under valgrind, it bails out completely, preventing me from testing for both memory leaks (using valgrind) an...
Yes, it is possible to detect at runtime if your executable is being run under Valgrind. Valgrind sets certain environment variables and modifies the execution environment, which can be checked programmatically in your code. You can use one of the following methods to check if your program is running under Valgrind: ...
45,509
[ { "from": "human", "value": "Is there a way to identify at run-time of an executable is being run from within valgrind? I have a set of C++ unit tests, and one of them expects std::vector::reserve to throw std::bad_alloc. When I run this under valgrind, it bails out completely, preventing me from testing ...
I wondered whether anybody knows how to obtain membership of local groups on a remote server programmatically via C#. Would this require administrator permissions? And if so is there any way to confirm the currently logged in user's membership (or not) of these groups?
To programmatically obtain membership of local groups on a remote server using C#, you typically need to use the `System.DirectoryServices` namespace or Windows Management Instrumentation (WMI). Depending on how you're accessing this information, you may require administrative privileges, especially if you're trying to...
2,003
[ { "from": "human", "value": "I wondered whether anybody knows how to obtain membership of local groups on a remote server programmatically via C#. Would this require administrator permissions? And if so is there any way to confirm the currently logged in user's membership (or not) of these groups?\n" }, ...
is there a way to get the position over sealevel from a given position using the Google Maps API? Any Help would really be appreciated!
Yes, you can get the elevation above sea level for a given position using the Google Maps Elevation API. This API allows you to query the elevation of locations on the Earth's surface. Here’s how you can use the Google Maps Elevation API: ### Step 1: Obtain an API Key First, you'll need to sign up for Google Cloud an...
48,704
[ { "from": "human", "value": "is there a way to get the position over sealevel from a given position using the Google Maps API?\nAny Help would really be appreciated!\n" }, { "from": "gpt", "value": "Yes, you can get the elevation above sea level for a given position using the Google Maps Elevati...
I have to implement a homemade Trie and I'm stuck on the Iterator part. I can't seem to figure out the increment method for the trie. I hope someone can help me clear things out. Here's the code for the Iterator: template <typename T> class Trie<T>::IteratorPrefixe{ friend class Trie<T>; public: IteratorPrefixe() :...
To implement the increment operator (`operator++`) for the `IteratorPrefixe` class of your `Trie`, you need to traverse the Trie in a way that allows you to visit each node, respecting the lexicographic order defined by the keys. This generally involves some sort of stack or queue to manage your current position in the...
44,553
[ { "from": "human", "value": "I have to implement a homemade Trie and I'm stuck on the Iterator part. I can't seem to figure out the increment method for the trie.\nI hope someone can help me clear things out.\nHere's the code for the Iterator:\ntemplate <typename T> class Trie<T>::IteratorPrefixe{\nfriend c...
Is there a simple way to tell what triggered Click event of a Button apart from setting multiple flags in Mouse/Key Up/Down event handlers? I'm currently only interested in distinguishing mouse from everything else, but it would be nice to handle Stylus and other input types if possible. Do I have to create my own butt...
To distinguish between input sources (like mouse clicks versus keyboard presses) when handling button clicks in a UI, you don’t necessarily need to create your own button control. Many frameworks and languages provide mechanisms to determine the source of an event. Here’s a general approach you can use in most framewo...
42,979
[ { "from": "human", "value": "Is there a simple way to tell what triggered Click event of a Button apart from setting multiple flags in Mouse/Key Up/Down event handlers? I'm currently only interested in distinguishing mouse from everything else, but it would be nice to handle Stylus and other input types if ...
In Windows XP, when a program wants the user's attention, it'll flash its taskbar button orange. Anyone with an IM program is probably familiar with this behavior. But when I'm playing a fullscreen-mode game, I don't see that, and messages go unanswered. Now I'm writing a game engine of my own, and I'd like to be kin...
Windows does not provide a direct API call specifically for receiving notifications when other applications flash their taskbar buttons. However, there are alternative methods that you can employ to achieve similar functionality. One way to approach this is to use Windows Hooks to monitor messages sent to other window...
48,866
[ { "from": "human", "value": "In Windows XP, when a program wants the user's attention, it'll flash its taskbar button orange. Anyone with an IM program is probably familiar with this behavior. But when I'm playing a fullscreen-mode game, I don't see that, and messages go unanswered.\nNow I'm writing a gam...
Update: This turned into a blog post, with updated links and code, over at my blog: https://egilhansen.com/2008/12/01/how-to-take-control-of-style-sheets-in-asp-net-themes-with-the-styleplaceholder-and-style-control/ The problem is pretty simple. When using ASP.NET Themes you do not have much say in how your style she...
This is a well-thought-out solution to address the shortcomings of ASP.NET Themes regarding the rendering and control of style sheets. Your implementation of the `StylePlaceHolder` and `Style` controls provides a flexible and extensible way to handle styles in ASP.NET applications. Here are some observations and sugges...
40,856
[ { "from": "human", "value": "Update: This turned into a blog post, with updated links and code, over at my blog: https://egilhansen.com/2008/12/01/how-to-take-control-of-style-sheets-in-asp-net-themes-with-the-styleplaceholder-and-style-control/\n\nThe problem is pretty simple. When using ASP.NET Themes you...
I've been coding in Ruby for sometime now, but I don't understand when to use: def self.METHOD_NAME end or just: def METHOD_NAME end In any Rails model. Is "self" a modifier like private in Java? When should I use it and when not?. Thanks a ton.
In Ruby, using `self` in the method definition serves a specific purpose related to the context in which the method is called. Let's break it down: 1. **Instance Methods**: ```ruby def method_name # This is an instance method end ``` - An instance method can be called on an instance (object) of the...
48,490
[ { "from": "human", "value": "I've been coding in Ruby for sometime now, but I don't understand when to use:\ndef self.METHOD_NAME\nend\n\nor just:\ndef METHOD_NAME\nend\n\nIn any Rails model. Is \"self\" a modifier like private in Java? When should I use it and when not?. Thanks a ton.\n" }, { "from...
I have an Excel table with several items 1, 2, 3..., each of which has subitems 1.1, 1.2, etc. I'm using the list of subitems as my key column and populating the main items using vlookups, but only showing each main item once. /| A | B | C | -+---------+----------+----------+ 1| Item1 | 1.Note |...
You can achieve your goal using VBA to automatically wrap the notes in column B and adjust their heights according to the content. Merging cells may not be the best approach due to the update limitations, but wrapping text and adjusting row heights can be done with a simple macro. Here's a sample VBA code that you can...
49,280
[ { "from": "human", "value": "I have an Excel table with several items 1, 2, 3..., each of which has subitems 1.1, 1.2, etc. I'm using the list of subitems as my key column and populating the main items using vlookups, but only showing each main item once.\n/| A | B | C |\n-+---------+---...
I am displaying Japanese characters in a VB6 application with the system locale set to Japan and the language for non Unicode programs as Japanese. A call to GetACP() correctly returns 932 for Japanese. When I insert the Japanese strings into my controls they display as “ƒAƒtƒŠƒJ‚Ì—‰¤” rather than “アフリカの女王”. If I ma...
In VB6, to determine the correct character set (Charset) for a given locale (LCID), you can utilize the Windows API functions. The `GetACP()` function you've used returns the current ANSI code page, but for more accurate results with respect to specific LCIDs and their corresponding character sets, you can use the `Get...
49,087
[ { "from": "human", "value": "I am displaying Japanese characters in a VB6 application with the system locale set to Japan and the language for non Unicode programs as Japanese. A call to GetACP() correctly returns 932 for Japanese. When I insert the Japanese strings into my controls they display as “ƒAƒtƒ...
I'd like to split a string using one or more separator characters. E.g. "a b.c", split on " " and "." would give the list ["a", "b", "c"]. At the moment, I can't see anything in the standard library to do this, and my own attempts are a bit clumsy. E.g. def my_split(string, split_chars): if isinstance(string_L, bas...
You can achieve this more elegantly using Python's `re` module, which provides support for regular expressions. With regular expressions, you can define a pattern that matches any of the specified separator characters and use that to split your string. Here's a cleaner implementation of your `my_split` function using `...
46,789
[ { "from": "human", "value": "I'd like to split a string using one or more separator characters.\nE.g. \"a b.c\", split on \" \" and \".\" would give the list [\"a\", \"b\", \"c\"].\nAt the moment, I can't see anything in the standard library to do this, and my own attempts are a bit clumsy. E.g.\ndef my_spl...
Back in college, only the use of pseudo code was evangelized more than OOP in my curriculum. Just like commenting (and other preached 'best practices'), I found that in crunch time psuedocode was often neglected. So my question is...who actually uses it a lot of the time? Or do you only use it when an algorithm is real...
Pseudocode is a tool that can be quite beneficial in various scenarios, and its usage often depends on the developer's experience, the complexity of the problem, and the context of the work being done. Here’s a breakdown of how different levels of developers might utilize pseudocode, along with some insights from diffe...
45,266
[ { "from": "human", "value": "Back in college, only the use of pseudo code was evangelized more than OOP in my curriculum. Just like commenting (and other preached 'best practices'), I found that in crunch time psuedocode was often neglected. So my question is...who actually uses it a lot of the time? Or do ...
I am not able to get the selection object's start and end offsets in Opera (v9.50) when the selection is collapsed (i.e. just point and click instead of highlighting text). This is my simple test code, which works in FF and Safari but does not work in Opera. <html> <head> <script type="text/javascript"> function ...
The issue you're encountering with Opera 9.50 is related to how it handles selection and offsets in its implementation of the Selection API. In particular, this version of Opera does not properly report the `anchorOffset` and `focusOffset` when the selection is collapsed (i.e., when you click without highlighting any t...
48,105
[ { "from": "human", "value": "I am not able to get the selection object's start and end offsets in Opera (v9.50) when the selection is collapsed (i.e. just point and click instead of highlighting text). This is my simple test code, which works in FF and Safari but does not work in Opera. \n<html>\n<head>\n\n...
Say I have an interface like this: public interface ISomeInterface { ... } I also have a couple of classes implementing this interface; public class SomeClass : ISomeInterface { ... } Now I have a WPF ListBox listing items of ISomeInterface, using a custom DataTemplate. The databinding engine will apparently not (tha...
In WPF, when you are binding to an interface, you need to ensure that the properties you want to bind to are explicitly defined in the interface itself. The issue you're encountering is likely due to the fact that WPF does not automatically "know" how to navigate properties of the interface through the implementation c...
49,498
[ { "from": "human", "value": "Say I have an interface like this:\npublic interface ISomeInterface\n{\n...\n}\n\nI also have a couple of classes implementing this interface;\npublic class SomeClass : ISomeInterface\n{\n...\n}\n\nNow I have a WPF ListBox listing items of ISomeInterface, using a custom DataTemp...
After an upgrade to XP and Java 1.6 one of our intranet apps is experiencing a problem when running a java applet in the browser. The java applet is a document editor and accepts a parameter to where the document is located. I assume it copies this file to the users machine for editing. I wish I knew more but I don't h...
The issue you are encountering appears to be related to the applet's attempt to write a file to the local machine, resulting in a `java.io.IOException: Write error`. Since the problem occurs when upgrading from Java 1.3 to Java 1.6, there could be a few different factors at play, including differences in how file permi...
46,145
[ { "from": "human", "value": "After an upgrade to XP and Java 1.6 one of our intranet apps is experiencing a problem when running a java applet in the browser. The java applet is a document editor and accepts a parameter to where the document is located. I assume it copies this file to the users machine for ...
A requirement for my application is if it looses database connectivity then it must pop up a big modal "No Connection. Try again later" dialog blocking all user interaction until such time that connectivity is regained. I achieve this by at the start of the application starting an instance of a DeviceMonitor class. T...
In your situation, it sounds like you need to ensure that the modal dialog is shown on the UI thread instead of the thread that the timer callback is executing on. You can achieve this in a WPF or WinForms application by using `Invoke` or `BeginInvoke` to marshal the call to the UI thread. Since you're already using ...
46,017
[ { "from": "human", "value": "A requirement for my application is if it looses database connectivity then it must pop up a big modal \"No Connection. Try again later\" dialog blocking all user interaction until such time that connectivity is regained.\nI achieve this by at the start of the application start...
Using jQuery, how do you match elements that are prior to the current element in the DOM tree? Using prevAll() only matches previous siblings. eg: <table> <tr> <td class="findme">find this one</td> </tr> <tr> <td><a href="#" class="myLinks">find the previous .findme</a></td> </tr> <t...
To find the first `.findme` element that appears before the clicked link in the DOM, you can use jQuery's `.closest()` method combined with `.prevAll()` and `.find()`. Here's how to do it: 1. When the link is clicked, use `.closest()` to navigate to its ancestor. 2. Use `.prevAll()` to get all previous sibling element...
49,283
[ { "from": "human", "value": "Using jQuery, how do you match elements that are prior to the current element in the DOM tree? Using prevAll() only matches previous siblings.\neg:\n<table>\n <tr>\n <td class=\"findme\">find this one</td>\n </tr>\n <tr>\n <td><a href=\"#\" class=\"myLinks...
The topic generically says it all. Basically in a situation like this: boost::scoped_array<int> p(new int[10]); Is there any appreciable difference in performance between doing: &p[0] and p.get()? I ask because I prefer the first one, it has a more natural pointer like syntax. In fact, it makes it so you could replace...
When using `boost::scoped_array<int>` in C++, both `&p[0]` and `p.get()` can be used to retrieve the underlying pointer to the allocated array. However, there are some differences in semantics and potential performance implications that you should consider: 1. **Semantics**: - `p.get()` is a member function that ex...
45,251
[ { "from": "human", "value": "The topic generically says it all. Basically in a situation like this:\nboost::scoped_array<int> p(new int[10]);\n\nIs there any appreciable difference in performance between doing: &p[0] and p.get()?\nI ask because I prefer the first one, it has a more natural pointer like synt...
When a user clicks in certain places in my control, I want to change the color of some rows and columns in my grid, then fade it back to the normal color, within say 500ms or so. I haven't decided whether to use Winforms or WPF yet, so advice in either of those technologies would work. Thank you. Edit: I understand I...
You can achieve the desired effect of changing the color of some rows and columns in a grid and fading them back in a non-blocking manner using both WinForms and WPF. Below are examples for both technologies. ### Using WPF In WPF, you can use animations to change the color of the cells in your grid. Here is an exampl...
41,561
[ { "from": "human", "value": "When a user clicks in certain places in my control, I want to change the color of some rows and columns in my grid, then fade it back to the normal color, within say 500ms or so. I haven't decided whether to use Winforms or WPF yet, so advice in either of those technologies wou...
For the sake of an example, is this statement window.Number.constructor.prototype.constructor(); read like a path? C:\Users\Vista\Documents\Work\text.txt From left to right window:\Number\constructor\prototype\constructor() where window is the root object, Number is an object inside window, constructor is an object ...
It's great that you're trying to understand the dot notation in JavaScript! Let's clarify how it works and how to read expressions like the ones you've presented. ### Dot Notation Basics In JavaScript, dot notation (`.`) is used to access properties and methods of objects. It can indeed be seen as a "path" through th...
49,578
[ { "from": "human", "value": "For the sake of an example, is this statement\nwindow.Number.constructor.prototype.constructor();\n\nread like a path?\nC:\\Users\\Vista\\Documents\\Work\\text.txt\n\nFrom left to right\nwindow:\\Number\\constructor\\prototype\\constructor()\n\nwhere window is the root object, N...
Why the FontFamily param of the Font object is a string and not an enum?
The `FontFamily` parameter of the `Font` object is typically a string rather than an enum for several reasons: 1. **Flexibility and Variety**: Fonts can have many different names and variations (like "Arial", "Times New Roman", "Comic Sans MS", etc.). Using a string allows developers to specify any font family name th...
49,941
[ { "from": "human", "value": "Why the FontFamily param of the Font object is a string and not an enum?\n" }, { "from": "gpt", "value": "The `FontFamily` parameter of the `Font` object is typically a string rather than an enum for several reasons:\n\n1. **Flexibility and Variety**: Fonts can have ...
I've had been hearing about test driven development for a couple years now, and I never really paid too much attention to it from a practical level until recently when I started getting more interested in the .NET MVC. I've been playing around a lot with the MVC Storefront Sample, and I am realizing just how cool and h...
Shifting from a test-last approach to test-driven development (TDD) requires a mindset change, focusing on tests as part of the development process rather than as a post-development step. Here are some practical steps to help you make this transition effectively and efficiently: ### 1. **Understand the TDD Cycle:** ...
46,985
[ { "from": "human", "value": "I've had been hearing about test driven development for a couple years now, and I never really paid too much attention to it from a practical level until recently when I started getting more interested in the .NET MVC. I've been playing around a lot with the MVC Storefront Sampl...
We have a wsdl specifying a datetime element. It is nullable, in the sense that minOccurs=0. However, using svcutil to generate a proxy class does not give us a .net nullable DateTime property, so how best can we make the proxy class serialise the message to a SOAP message that does not contain the datetime element?
When using `svcutil` to generate a proxy class from a WSDL that specifies a `datetime` element with `minOccurs=0`, the generated code typically reflects a non-nullable `DateTime` type in C#. This can present an issue when trying to serialize a SOAP message that omits the datetime element when it is not present. Here a...
45,799
[ { "from": "human", "value": "We have a wsdl specifying a datetime element. It is nullable, in the sense that minOccurs=0. However, using svcutil to generate a proxy class does not give us a .net nullable DateTime property, so how best can we make the proxy class serialise the message to a SOAP message tha...
DataGridView.CellContentClick is not firing if I mouse click a DataGridViewCheckBoxCell very fast. How can I solve this? I need to know when CheckBox's check state changes
The issue you are encountering with the `DataGridView.CellContentClick` event not firing when you rapidly click a `DataGridViewCheckBoxCell` is not uncommon. The event may be getting skipped due to how the control processes the clicks, especially if the state is being toggled quickly. To reliably capture the check sta...
47,594
[ { "from": "human", "value": "DataGridView.CellContentClick is not firing if I mouse click a DataGridViewCheckBoxCell very fast. How can I solve this? I need to know when CheckBox's check state changes\n" }, { "from": "gpt", "value": "The issue you are encountering with the `DataGridView.CellCont...
I am writing a website with PHP. Since it will need to be accessed by anyone on the network to access the internet I have to create a mobile version. How do I best check if it's a mobile device? I don't want to have a switch statement with 50 devices at the end since I don't only want to support the iPhone. Is there a ...
To detect mobile devices in PHP without having to manually manage a list of user agents, you can use libraries that handle this for you. One popular option is the **Mobile Detect** library, which is lightweight and straightforward to use. ### Steps to Implement Mobile Detect 1. **Download the Library**: You can down...
48,451
[ { "from": "human", "value": "I am writing a website with PHP. Since it will need to be accessed by anyone on the network to access the internet I have to create a mobile version. How do I best check if it's a mobile device? I don't want to have a switch statement with 50 devices at the end since I don't onl...
I have, as best as I can manage, set up IIS (6.0), PHP (5.2.8) and MySQL (5.1.30) on Windows Server 2003, with all the involved mucking about (I think) in IIS and PHP to get things talking to each other. PHP does work - however, I cannot use the mysql or mysqli libraries from a PHP page. Fatal error: Class 'mysqli' no...
It sounds like you're encountering an issue with the PHP configuration on your IIS 6.0 server where the MySQL and MySQLi extensions are not being loaded when running PHP scripts through the web server, even though they work fine in the command line interface (CLI). Here are some steps you can take to troubleshoot and r...
46,175
[ { "from": "human", "value": "I have, as best as I can manage, set up IIS (6.0), PHP (5.2.8) and MySQL (5.1.30) on Windows Server 2003, with all the involved mucking about (I think) in IIS and PHP to get things talking to each other.\nPHP does work - however, I cannot use the mysql or mysqli libraries from a...
What do you think is the best way for obtaining the results of the work of a thread? Imagine a Thread which does some calculations, how do you warn the main program the calculations are done? You could poll every X milliseconds for some public variable called "job finished" or something by the way, but then you'll rece...
To efficiently obtain the results from multiple threads without polling, a common approach is to use synchronization mechanisms provided by the threading library in your programming language of choice. Below are several strategies you can employ, especially for Python, Java, or similar languages: ### 1. **Using Thread...
45,495
[ { "from": "human", "value": "What do you think is the best way for obtaining the results of the work of a thread? Imagine a Thread which does some calculations, how do you warn the main program the calculations are done?\nYou could poll every X milliseconds for some public variable called \"job finished\" o...
I developed a greasemonkey script that refreshes a page and checks for certain updates. I would like to run this script in a tab and browse the internet in another tab, but then have the script automatically activate it's tab when an update is found. Im not sure how clear that was, maybe this is better: Tab 1 is runnin...
Unfortunately, directly shifting focus from one tab to another programmatically, such as with a Greasemonkey or Tampermonkey script, is not supported due to browser security restrictions. Browsers implement these restrictions to prevent web pages from hijacking user interactions or interfering with the user's browsing ...
47,049
[ { "from": "human", "value": "I developed a greasemonkey script that refreshes a page and checks for certain updates. I would like to run this script in a tab and browse the internet in another tab, but then have the script automatically activate it's tab when an update is found.\nIm not sure how clear that ...
Without using any third party program to do this (i.e. without VMware ThinApp, U3 or MojoPac etc.) How to move MSVC++ 6.0 from from its install on C: over to a USB drive? So that it can be used on different PCs with no admin rights and without installing anything on the host PC? Even if it's only usable as a console ap...
Moving Microsoft Visual C++ 6.0 (MSVC++ 6.0) from its installation on a C: drive to a USB drive while maintaining its functionality on different PCs without installation is quite challenging due to the nature of how software like MSVC++ is integrated with the Windows operating system. However, you can attempt the follo...
45,317
[ { "from": "human", "value": "Without using any third party program to do this (i.e. without VMware ThinApp, U3 or MojoPac etc.) How to move MSVC++ 6.0 from from its install on C: over to a USB drive? So that it can be used on different PCs with no admin rights and without installing anything on the host PC?...
In a .NET 3.0 project, I need to make some calls via P/Invoke (specifically to the PrintTicket Provider functions like PTConvertPrintTicketToDevMode() ). The framework has a managed definition of the COM IStream interface: System.Runtime.InteropServices.ComTypes.IStream I need this as System.IO.Stream so that I can eas...
To convert between the COM `IStream` interface and .NET's `System.IO.Stream`, you can create a custom implementation of `Stream` that wraps the `IStream` methods. This will allow you to easily read from and write to `IStream` in a more straightforward way. Here’s a simple implementation of a `Stream` that works with `...
48,206
[ { "from": "human", "value": "In a .NET 3.0 project, I need to make some calls via P/Invoke\n(specifically to the PrintTicket Provider functions like PTConvertPrintTicketToDevMode() ).\nThe framework has a managed definition of the COM IStream interface:\nSystem.Runtime.InteropServices.ComTypes.IStream\nI ne...
Greetings! I have a DropDownList within a FormView which are bound to XmlDataSources: <asp:FormView ID="MyFormView" runat="server" DataSourceID="MyXmlDataSource"> <ItemTemplate> <h1><%# XPath("SomeNode")%></h1> <asp:Label ID="MyLabel" runat="server" AssociatedControlID="MyDdl" Text='<%# XPath("SomeO...
The issue you're experiencing is likely due to the way the ASP.NET lifecycle processes events and binding data to controls like the `FormView` after a postback. After a postback occurs, the control state is restored before your `OnLoad` method runs, which means that any bindings that occurred during the previous load a...
48,943
[ { "from": "human", "value": "Greetings!\nI have a DropDownList within a FormView which are bound to XmlDataSources:\n<asp:FormView ID=\"MyFormView\" runat=\"server\" DataSourceID=\"MyXmlDataSource\">\n <ItemTemplate>\n <h1><%# XPath(\"SomeNode\")%></h1>\n <asp:Label ID=\"MyLabel\" runat=\"s...
I have a requirement for my R&D which seems to be tricky. I want to create a client jar for an EJB application. Consider that I have an EJB application and its jars with me. I just need to create a client jar for that EJB application. To create it, I need the server to be running. But my requirement is that, I have to...
Creating a client JAR for an EJB application without having the server running can be challenging, especially since EJB clients typically require certain resources from the server environment. However, you can work around the need for a running server by using the following steps to create a client JAR. Below is a gene...
45,313
[ { "from": "human", "value": "I have a requirement for my R&D which seems to be tricky.\nI want to create a client jar for an EJB application. \nConsider that I have an EJB application and its jars with me. I just need to create a client jar for that EJB application.\nTo create it, I need the server to be ru...
I am working on implementing tail for an assignment. I have it working correctly however I seem to be getting an error from free at random times. I can't see, to track it down to a pattern or anything besides it is consistent. For example if I call my program as "tail -24 test.in" I would get the the the incorrect chec...
Based on the code you provided and the description of the issue, it seems like there are a few areas that could potentially lead to undefined behavior, memory leaks, or double-free errors. Here are a few suggestions to help you track down and fix the issue: 1. **Uninitialized Variables**: Make sure that all your varia...
45,383
[ { "from": "human", "value": "I am working on implementing tail for an assignment. I have it working correctly however I seem to be getting an error from free at random times.\nI can't see, to track it down to a pattern or anything besides it is consistent.\nFor example if I call my program as \"tail -24 tes...
I saw the following interesting usage of tar in a co-worker's Bash scripts: `tar cf - * | (cd <dest> ; tar xf - )` Apparently it works much like rsync -av does, but faster. The question arises, how? -m EDIT: Can anyone explain why should this solution be preferable over the following? cp -rfp * dest Is the former ...
The command your co-worker is using combines `tar` and a pipe, which can indeed result in a faster copy operation than `cp`, especially under certain conditions. Let's break down both commands and their performance characteristics: ### The `tar` Command ```bash tar cf - * | (cd <dest> ; tar xf - ) ``` - `tar cf - *`...
42,319
[ { "from": "human", "value": "I saw the following interesting usage of tar in a co-worker's Bash scripts:\n`tar cf - * | (cd <dest> ; tar xf - )`\n\nApparently it works much like rsync -av does, but faster. The question arises, how?\n-m\n\nEDIT: Can anyone explain why should this solution be preferable over...
We upgraded our machines with a microsoft patch listed above and are now having issues with some winsock controls. While moving on to the new component library there were two issues that we faced: We are creating a Winsock control dynamically using Form.Controls.Add(...). With the new dlls it gave us a run time erro...
The error you're encountering when trying to set the dynamically created Winsock control to an object of type `mWinsock` likely stems from how the control is being instantiated and how it interacts with type safety in Visual Basic (or whichever environment you're using). Here are some steps and considerations to troub...
47,612
[ { "from": "human", "value": "We upgraded our machines with a microsoft patch listed above and are now having issues with some winsock controls. While moving on to the new component library there were two issues that we faced: \n\nWe are creating a Winsock control dynamically using Form.Controls.Add(...). W...
I'm starting a project that will be public facing using asp.net mvc. I know there are about a billion php, python, and ruby html sanitizers out there, but does anyone have some pointers to anything good in .net? What are your experiences with what is out there? I know stackoverflow is a site done in asp.net that allows...
When building a public-facing application using ASP.NET MVC, it's essential to sanitize user input to prevent XSS (Cross-Site Scripting) and other vulnerabilities. Here are some approaches and libraries available in the .NET ecosystem for sanitizing HTML: ### 1. **HtmlSanitizer** One of the most popular libraries for ...
44,252
[ { "from": "human", "value": "I'm starting a project that will be public facing using asp.net mvc. I know there are about a billion php, python, and ruby html sanitizers out there, but does anyone have some pointers to anything good in .net? What are your experiences with what is out there? I know stackoverf...
I need an OpenSource API in Java, which can encode *.wav and *.au formats to MP3 and vice-versa. I have evaluated Java Sound API and LameOnJ, but they do not meet my requirements and are not stable, respectively. Please suggest one that is free and platform independent.
For encoding and decoding audio formats, especially for converting WAV and AU to MP3 and vice versa in Java, you can consider using the **JAVE** (Java Audio Video Encoder) library. It is an open-source library that provides a straightforward way to handle audio and video encoding. ### Key Features: - **Platform Indepe...
44,667
[ { "from": "human", "value": "I need an OpenSource API in Java, which can encode *.wav and *.au formats to MP3 and vice-versa. \nI have evaluated Java Sound API and LameOnJ, but they do not meet my requirements and are not stable, respectively. Please suggest one that is free and platform independent.\n" }...
Good morning, Apologies for the newbie question. I'm just getting started with ASP.NET internationalization settings. Background info: I have a website which displays a <table> HTML object. In that <table> HTML object, I have a column which displays dates. My server being in the US, those dates show up as MM/DD/YYYY...
Good morning, Alan! Your question is quite common when dealing with internationalization in web applications. It’s great that you’re looking for a proper solution rather than a quick hack! Here are some best practices for handling culture-specific formatting in ASP.NET: ### 1. Detecting Culture from the Request ASP....
48,346
[ { "from": "human", "value": "Good morning,\nApologies for the newbie question. I'm just getting started with ASP.NET internationalization settings.\nBackground info:\nI have a website which displays a <table> HTML object. In that <table> HTML object, I have a column which displays dates. My server being ...
I'm trying to create a color-picker which must dynamically generate its images and figured it would be a whole lot easier to generate SVG than a raster image. Unfortunately, I can't figure out how to represent the big, two-dimensional gradient which will form the centerpiece of the picker. For example, if the currentl...
To create a two-dimensional gradient in SVG where the colors blend based on selected axes, you can use a combination of `linearGradient` elements. Fortunately, SVG has the capability to define gradients directly, which makes it a great choice for creating a color picker. For your specific case, where you want a gradie...
47,949
[ { "from": "human", "value": "I'm trying to create a color-picker which must dynamically generate its images and figured it would be a whole lot easier to generate SVG than a raster image. Unfortunately, I can't figure out how to represent the big, two-dimensional gradient which will form the centerpiece of...
When you run a JUnit 4 ParameterizedTest with the Eclipse TestRunner, the graphical representation is rather dumb: for each test you have a node called [0], [1], etc. Is it possible give the tests [0], [1], etc. explicit names? Implementing a toString method for the tests does not seem to help. (This is a follow-up que...
In JUnit 4, when using `@RunWith(Parameterized.class)`, the test methods generated by the parameterized runner do not inherently allow for custom names. By default, they are represented as `[0]`, `[1]`, etc., which can make it difficult to identify the purpose of each test case in a graphical test runner like the Eclip...
48,386
[ { "from": "human", "value": "When you run a JUnit 4 ParameterizedTest with the Eclipse TestRunner, the graphical representation is rather dumb: for each test you have a node called [0], [1], etc.\nIs it possible give the tests [0], [1], etc. explicit names? Implementing a toString method for the tests does ...
I've created a .NET WCF service that is intended to always be over HTTPS. When I first created the service skeleton and ran it over HTTP, it worked fine. I used PHP5 to test the interoperability with the built in SOAP functions. However, once I switched to HTTPS, when I try to call the function from PHP, I get a fault ...
It looks like you are facing an issue with calling a WCF service over HTTPS from PHP due to the "Method Not Allowed" error. Below are a few steps to troubleshoot and possibly resolve the issue: ### 1. **Check the Endpoint Configuration** From your WCF configuration, you have the following endpoint definition for your...
47,707
[ { "from": "human", "value": "I've created a .NET WCF service that is intended to always be over HTTPS. When I first created the service skeleton and ran it over HTTP, it worked fine. I used PHP5 to test the interoperability with the built in SOAP functions. However, once I switched to HTTPS, when I try to c...
We have a set of web services which is also our internal API. They perfectly share one common web.config file. Is there a way to somehow make log4net create one log for the whole site, for all of them? And have common error handler? The problem I think they are all separate virtual directories, separate applications......
Yes, you can configure multiple web applications (or virtual directories) to share logging functionality using log4net and to centralize error handling. Here’s how you can achieve that: ### Centralized Logging with log4net 1. **Shared `log4net.config`:** Instead of embedding the log4net configuration within each a...
46,082
[ { "from": "human", "value": "We have a set of web services which is also our internal API.\nThey perfectly share one common web.config file.\nIs there a way to somehow make log4net create one log for the whole site, for all of them? And have common error handler? The problem I think they are all separate vi...
The function below is logging the "0", "z" and the "1" ok... but its not capturing the "Z" (shift-z)... any help would be appreciated... __declspec(dllexport) LRESULT CALLBACK HookProc (UINT nCode, WPARAM wParam, LPARAM lParam) { if ((nCode == HC_ACTION) && (wParam == WM_KEYUP)) { // This Struct gets in...
The issue you are experiencing with logging the uppercase "Z" is likely due to how keyboard events are processed and how the virtual key codes are defined. The virtual key code for "Z" is `0x5A` (or `90` in decimal), and the virtual key code for "Shift" is `0x10` (or `16` in decimal). In the code provided, you're using...
45,796
[ { "from": "human", "value": "The function below is logging the \"0\", \"z\" and the \"1\" ok... but its not capturing the \"Z\" (shift-z)... any help would be appreciated...\n__declspec(dllexport)\nLRESULT CALLBACK HookProc (UINT nCode, WPARAM wParam, LPARAM lParam)\n{\n if ((nCode == HC_ACTION) && (wPar...
My homepage (or welcome page) will consist of data from two models (lets call them authors and posts). I am new to rails and not sure what is the best way to accomplish this. Should I create a new controller called welcome which gathers data from the authors and posts and then display them in the welcome index view? Or...
In Rails, it's common to structure your application in a way that promotes clarity, separation of concerns, and scalability. Given that you're creating a homepage (or welcome page) that displays data from both authors and posts, here are some best practices you can follow: ### Option 1: Create a Welcome Controller 1....
48,339
[ { "from": "human", "value": "My homepage (or welcome page) will consist of data from two models (lets call them authors and posts). I am new to rails and not sure what is the best way to accomplish this.\nShould I create a new controller called welcome which gathers data from the authors and posts and then ...
I recently read a discussion regarding whether managed languages are slower (or faster) than native languages (specifically C# vs C++). One person that contributed to the discussion said that the JIT compilers of managed languages would be able to make optimizations regarding references that simply isn't possible in la...
The distinction between managed languages (like C#) and native languages (like C++) comes down to how memory is accessed and managed, particularly with references versus pointers. While both concepts are similar in some ways (they both refer to locations in memory), there are specific optimizations that a Just-In-Time ...
48,804
[ { "from": "human", "value": "I recently read a discussion regarding whether managed languages are slower (or faster) than native languages (specifically C# vs C++). One person that contributed to the discussion said that the JIT compilers of managed languages would be able to make optimizations regarding re...
I'm creating a user-based website. For each user, I'll need a few MySQL tables to store different types of information (that is, userInfo, quotesSubmitted, and ratesSubmitted). Is it a better idea to: a) Create one database for the site (that is, "mySite") and then hundreds or thousands of tables inside this (that is,...
The best approach for your use case is to go with a single database and multiple tables, rather than creating multiple databases or multiple tables for each user. This design is commonly referred to as a "normalized" database schema and has several advantages. ### Recommended Database Schema 1. **Single Database:** ...
47,856
[ { "from": "human", "value": "I'm creating a user-based website. For each user, I'll need a few MySQL tables to store different types of information (that is, userInfo, quotesSubmitted, and ratesSubmitted). Is it a better idea to:\na) Create one database for the site (that is, \"mySite\") and then hundreds ...
I have a small project I want to try porting to Python 3 - how do I go about this? I have made made the code run without warnings using python2.6 -3 (mostly removing .has_key() calls), but I am not sure of the best way to use the 2to3 tool. Use the 2to3 tool to convert this source code to 3.0 syntax. Do not manually e...
It looks like you're on the right track, but there are ways to streamline your process of using the `2to3` tool for porting your code from Python 2 to Python 3. Below is a suggested workflow that will help you convert your code more efficiently: 1. **Rename the original file**: To avoid overwriting and to keep a backu...
48,057
[ { "from": "human", "value": "I have a small project I want to try porting to Python 3 - how do I go about this?\nI have made made the code run without warnings using python2.6 -3 (mostly removing .has_key() calls), but I am not sure of the best way to use the 2to3 tool.\n\nUse the 2to3 tool to convert this ...
I would like to include some code coverage into our nightly build process. We're using CruiseControl, Ant, and Buckminster. Buckminster drives checkout from multiple repositories, and the PDE building and packaging of the product. Has any one any experience integrating code coverage into an RCP headless build? I have b...
Integrating code coverage into a nightly build process, particularly for an RCP (Rich Client Platform) application built with CruiseControl, Ant, and Buckminster, can be accomplished with various tools. Here’s a general approach and considerations for integrating tools like Cobertura, EMMA/EclEmma, or others into your ...
44,261
[ { "from": "human", "value": "I would like to include some code coverage into our nightly build process. We're using CruiseControl, Ant, and Buckminster. Buckminster drives checkout from multiple repositories, and the PDE building and packaging of the product.\nHas any one any experience integrating code cov...
What are some of the techniques available to debug multi threading issues in .net environment.
Debugging multithreading issues in a .NET environment can be quite challenging due to the complexity and non-deterministic behavior of concurrent execution. However, there are several techniques and tools available that can help diagnose and resolve these issues. Here are some common approaches: ### 1. **Visual Studio...
47,432
[ { "from": "human", "value": "What are some of the techniques available to debug multi threading issues in .net environment.\n" }, { "from": "gpt", "value": "Debugging multithreading issues in a .NET environment can be quite challenging due to the complexity and non-deterministic behavior of conc...
So the following rewrite rules always seem to fire. This has the effect of hiding another domain that I am hosting on the server? I can't seem to figure out what's wrong and it is time to call in the experts: RewriteEngine on RewriteCond %{HTTP_HOST} ^danielhonig.com RewriteRule ^(.*)$ http://www.danielhonig.com/$1 [R...
It looks like you're using a combination of `RewriteRule` and `RedirectMatch` to redirect traffic for your domain. The issue you're facing, where the rules seem to always fire and potentially hide another domain hosted on the same server, may stem from how the rules are set up and their order of execution. Here’s a br...
46,515
[ { "from": "human", "value": "So the following rewrite rules always seem to fire. This has the effect of hiding another domain that I am hosting on the server?\nI can't seem to figure out what's wrong and it is time to call in the experts:\nRewriteEngine on\nRewriteCond %{HTTP_HOST} ^danielhonig.com\nRewrit...
I need to send packets from one host to another over a potentially lossy network. In order to minimize packet latency, I'm not considering TCP/IP. But, I wish to maximize the throughput uisng UDP. What should be the optimal size of UDP packet to use? Here are some of my considerations: The MTU size of the switches in ...
When considering the optimal size of UDP packets for a lossy network, you need to balance multiple factors: MTU limitations, potential fragmentation, the overhead from headers, and the characteristics of the specific network and devices you are working with. ### Key Considerations for Optimal UDP Packet Size: 1. **MT...
44,618
[ { "from": "human", "value": "I need to send packets from one host to another over a potentially lossy network. In order to minimize packet latency, I'm not considering TCP/IP. But, I wish to maximize the throughput uisng UDP. What should be the optimal size of UDP packet to use?\nHere are some of my conside...
The code below continues many lines until it ends with a expected /veotherwise /vechoose. I started working on a development firm a little ago where they use this html version called vhtml. I have search the web but it brings different definitions for vhtml. I have seen some posts in Joomla about vhtml but they don'...
The code you've provided is written in a variant of HTML referred to as "vhtml". This format seems to be a templating language that combines HTML with custom tags and logic, which is likely designed for use in a specific framework or system (potentially associated with the development firm you are working at). The synt...
48,044
[ { "from": "human", "value": "The code below continues many lines until it ends with a expected /veotherwise /vechoose. I started working on a development firm a little ago where they use this html version called vhtml. I have search the web but it brings different definitions for vhtml. I have seen some ...
I am using the following methods: public void M1(Int32 a) { // acquire MyMutex DoSomething(a); // release MyMutex } and public void M2(String s, String t) { // acquire MyMutex DoSomethingElse(s, t); // release MyMutex } From what I have found so far it seems that it is not possible to use a single delegat...
In C#, you can use generics and delegates to create a method that can operate on different types of methods with varying signatures. Since your two methods (`M1` and `M2`) have different signatures, a direct delegate cannot be used for both. However, you can create a generic method that accepts a delegate, which will a...
48,555
[ { "from": "human", "value": "I am using the following methods:\npublic void M1(Int32 a)\n{\n // acquire MyMutex\n DoSomething(a);\n // release MyMutex\n}\n\nand\npublic void M2(String s, String t)\n{\n // acquire MyMutex\n DoSomethingElse(s, t);\n // release MyMutex\n}\n\nFrom what I have found so far...
I'm thinking about starting work on a fairly large scale .NET or ASP.NET project (I haven't decided yet, but it is likely that, eventually, it will be accessible from both a desktop application written in .NET as well as an ASP.NET web application). However, I'm not sure if there's a conventional way to structure the p...
Starting a large-scale .NET or ASP.NET project, particularly one that you plan to open-source, is an exciting endeavor! Below are some conventions and best practices to help you structure your project effectively, which will facilitate development, testing, and collaboration. ### Project Structure 1. **Solution Struc...
43,054
[ { "from": "human", "value": "I'm thinking about starting work on a fairly large scale .NET or ASP.NET project (I haven't decided yet, but it is likely that, eventually, it will be accessible from both a desktop application written in .NET as well as an ASP.NET web application). However, I'm not sure if ther...
I'm having issues getting Firefox to update a webpage when its class is changed dynamically. I'm using an HTML table element. When the user clicks a cell in the table header, my script toggles the class back and forth between sorted_asc and sorted_des. I have pseudo element which adds an arrow glyph (pointing up or dow...
It sounds like you're encountering a common issue with how Firefox handles pseudo-elements when dynamically changing classes. In this case, the issue may stem from the fact that Firefox does not always re-render the pseudo-element correctly when the class is changed, especially when it involves visual state changes lik...
49,024
[ { "from": "human", "value": "I'm having issues getting Firefox to update a webpage when its class is changed dynamically.\nI'm using an HTML table element. When the user clicks a cell in the table header, my script toggles the class back and forth between sorted_asc and sorted_des. I have pseudo element whi...
I'm designing an algorithm to do the following: Given array A[1... n], for every i < j, find all inversion pairs such that A[i] > A[j]. I'm using merge sort and copying array A to array B and then comparing the two arrays, but I'm having a difficult time seeing how I can use this to find the number of inversions. Any h...
Using a modified merge sort algorithm is indeed a great approach to count inversions in an array, and it can be done efficiently in O(n log n) time. Here's how you can adapt the merge sort technique to not only count the number of inversions but also to collect the inversion pairs (i, j) where i < j and A[i] > A[j]. #...
46,756
[ { "from": "human", "value": "I'm designing an algorithm to do the following: Given array A[1... n], for every i < j, find all inversion pairs such that A[i] > A[j]. I'm using merge sort and copying array A to array B and then comparing the two arrays, but I'm having a difficult time seeing how I can use thi...
How to find a specific element, or a list of elements by using their TagName using Watin?
WatiN (Web Application Testing in .NET) is a library that allows you to automate web browsers for testing purposes. To find specific elements or a list of elements by their tag name using WatiN, you can use the `Elements` property of the browser instance. Here's a step-by-step guide on how to do this: 1. **Install Wa...
49,582
[ { "from": "human", "value": "How to find a specific element, or a list of elements by using their TagName using Watin?\n" }, { "from": "gpt", "value": "WatiN (Web Application Testing in .NET) is a library that allows you to automate web browsers for testing purposes. To find specific elements or...
I'm working on a C#.Net application which has a somewhat annoying bug in it. The main window has a number of tabs, each of which has a grid on it. When switching from one tab to another, or selecting a different row in a grid, it does some background processing, and during this the menu flickers as it's redrawn (File, ...
It sounds like you're encountering a frustrating issue related to redrawing your application's main window. Disabling and re-enabling redraw using the `WM_SETREDRAW` message can lead to issues like you described, especially when it makes the window temporarily "transparent" to mouse clicks. Instead of using `WM_SETREDR...
43,925
[ { "from": "human", "value": "I'm working on a C#.Net application which has a somewhat annoying bug in it. The main window has a number of tabs, each of which has a grid on it. When switching from one tab to another, or selecting a different row in a grid, it does some background processing, and during this ...
I'm trying to scrape a price from a web page using PHP and Regexes. The price will be in the format £123.12 or $123.12 (i.e., pounds or dollars). I'm loading up the contents using libcurl. The output of which is then going into preg_match_all. So it looks a bit like this: $contents = curl_exec($curl); preg_match_all('...
The issue you're experiencing with matching the '£' character could indeed be related to character encoding. When you fetch the contents of a web page using `cURL`, the character encoding of the response could vary depending on the page, and it might not be in the expected encoding when you're trying to match it with y...
45,966
[ { "from": "human", "value": "I'm trying to scrape a price from a web page using PHP and Regexes. The price will be in the format £123.12 or $123.12 (i.e., pounds or dollars).\nI'm loading up the contents using libcurl. The output of which is then going into preg_match_all. So it looks a bit like this:\n$con...
Is there some way to detect file handle leaks at program termination? In particular I would like to make sure that all of my handles that get created are being freed in code. For example, I may have a CreateFile() somewhere, and at program termination I want to detect and ensure that all of them are closed.
Detecting file handle leaks at program termination can be approached in several ways, depending on the environment you are working in (Windows, Linux, etc.) and the tools you have at your disposal. Here are some common methods to help ensure that all file handles are properly closed before your program terminates: ###...
39,240
[ { "from": "human", "value": "Is there some way to detect file handle leaks at program termination? \nIn particular I would like to make sure that all of my handles that get created are being freed in code. \nFor example, I may have a CreateFile() somewhere, and at program termination I want to detect and e...
What are the differences in considerations in respect to designing or developing an Intranet and an Internet application ?
When designing or developing an Intranet application versus an Internet application, there are several important considerations to keep in mind. Here are some key differences: ### 1. **Audience and Access Control** - **Intranet Applications:** - **Restricted Audience**: Intranet applications are usually used b...
43,652
[ { "from": "human", "value": "What are the differences in considerations in respect to designing or developing an Intranet and an Internet application ?\n" }, { "from": "gpt", "value": "When designing or developing an Intranet application versus an Internet application, there are several importan...
I am running C# framework 2.0 and I would like to get some of the data from a list? The list is a List<>. How can I do that without looping and doing comparaison manually on each element of the List<>?
In C# Framework 2.0, you do not have access to LINQ (which was introduced in .NET Framework 3.5) for querying collections in a more concise way. However, you can achieve some functionality using the `ArrayList` class or other alternative approaches, but that would still typically require looping or manual comparison un...
46,195
[ { "from": "human", "value": "I am running C# framework 2.0 and I would like to get some of the data from a list? The list is a List<>. How can I do that without looping and doing comparaison manually on each element of the List<>?\n" }, { "from": "gpt", "value": "In C# Framework 2.0, you do not ...
I'm trying to make a javascript dropdown list using scriptaculous and prototype. I know this can be done using CSS :hover pseudo-selectors, but I would like to add some additional flair to it. The problem is that while I can kind of get the dropdown/up effect working, it seems very flaky. Is there a simple way to do th...
It looks like you are trying to create a dropdown menu using Scriptaculous and Prototype, but you're encountering issues with the hover behavior. The main problem with your current implementation is that you are using the `onmouseover` event twice for the same element, which can lead to unexpected behavior. Here's a r...
49,508
[ { "from": "human", "value": "I'm trying to make a javascript dropdown list using scriptaculous and prototype. I know this can be done using CSS :hover pseudo-selectors, but I would like to add some additional flair to it. The problem is that while I can kind of get the dropdown/up effect working, it seems v...
There's an executable file generated from my program in MFC and I want to use it as the default program to open the .jpg files. That is to say, each time I double click a .jpg file, my program will run. I tried to add some registry entries linking .jpg files with my program, such as HKEY_CLASSES_ROOT\.jpg\shell\open\c...
To set your MFC application as the default program for opening `.jpg` files, you need to modify the Windows registry correctly to ensure that your application takes precedence over any existing associations. Here’s how you can do that programmatically: ### Steps to Set Your Program as the Default for .jpg Files 1. **...
42,864
[ { "from": "human", "value": "There's an executable file generated from my program in MFC and I want to use it as the default program to open the .jpg files. That is to say, each time I double click a .jpg file, my program will run. \nI tried to add some registry entries linking .jpg files with my program, s...
This seems like something simple, but I can't seem to figure it out! I'm trying to get 2-way data-binding to work on an ASP.net page with a check box as one of the columns. How do I get the updated values (from check boxes) back from the gridview ????? Here is my data type: [Serializable] public class UserRequirements ...
To implement two-way data binding in your GridView, you'll need to collect the updated values from the checkboxes when the user clicks the "Save Changes" button. Here's a step-by-step approach to achieve this: 1. **Persist Data on Postback**: Ensure that the data is correctly bound to the GridView on each postback. Yo...
37,540
[ { "from": "human", "value": "This seems like something simple, but I can't seem to figure it out! I'm trying to get 2-way data-binding to work on an ASP.net page with a check box as one of the columns. How do I get the updated values (from check boxes) back from the gridview ?????\nHere is my data type:\n[S...
I'm looking to establish some kind of socket/COMET type functionality from my server(s) to my iPhone application. Essentially, anytime a user manages to set an arbitrary object 'dirty' on the server, by say, updating their Address.. the feedback should be pushed from the server to any clients keeping a live poll to the...
Using COMET (or long-polling techniques) for real-time communication between your server and iPhone application is a valid approach, but there are more modern and efficient methods available that might suit your needs better than embedding a hidden `UIWebView`. Here are some alternative approaches you can consider: ##...
47,845
[ { "from": "human", "value": "I'm looking to establish some kind of socket/COMET type functionality from my server(s) to my iPhone application. Essentially, anytime a user manages to set an arbitrary object 'dirty' on the server, by say, updating their Address.. the feedback should be pushed from the server ...
I wanna stop the reading of my text input file when the word "synonyms" appears. I'm using ifstream and I don't know how to break the loop. I tried using a stringstream "synonyms" but it ended up junking my bst. I included the complete project files below in case you wanna avoid typing. Important part: for(;;) /*he...
To modify your code such that the loop breaks when the word "synonyms" is encountered, you simply need to check if the `word` being read is equal to "synonyms". If it is, you can use the `break` statement to exit the loop. Here’s how you can do it: 1. After reading the word from the input file, add a check to see if ...
49,022
[ { "from": "human", "value": "I wanna stop the reading of my text input file when the word \"synonyms\" appears. I'm using ifstream and I don't know how to break the loop. I tried using a stringstream \"synonyms\" but it ended up junking my bst. I included the complete project files below in case you wanna ...
I see that I can declare a function with (say) public double Function(double parameter) but what if I do want to take the derivative of that function?
To compute the derivative of a function programmatically, you typically have a few different options depending on the programming environment and libraries you're using. Below are some general approaches that you can take to calculate the derivative of a function defined as `public double Function(double parameter)` in...
46,505
[ { "from": "human", "value": "I see that I can declare a function with (say)\npublic double Function(double parameter)\n\nbut what if I do want to take the derivative of that function?\n" }, { "from": "gpt", "value": "To compute the derivative of a function programmatically, you typically have a ...
Can someone give an example of a good time to actually use "unsafe" and "fixed" in C# code? I've played with it before, but never actually found a good use for it. Consider this code... fixed (byte* pSrc = src, pDst = dst) { //Code that copies the bytes in a loop } compared to simply using... Array.Copy(source, t...
Using `unsafe` and `fixed` in C# can be beneficial in specific scenarios, particularly when performance is critical or when you need to interoperate with unmanaged code. However, for the majority of typical applications, the built-in methods provided by .NET (like `Array.Copy()`) are usually sufficient and more maintai...
4,903
[ { "from": "human", "value": "Can someone give an example of a good time to actually use \"unsafe\" and \"fixed\" in C# code? I've played with it before, but never actually found a good use for it. \nConsider this code...\nfixed (byte* pSrc = src, pDst = dst) {\n //Code that copies the bytes in a loop\n}\...
We are using CMake to manage our builds and have a rather large project consisting of pretty much everything that is needed to build the software base for our embedded platforms save for the toolchain. When building a CDT project with CMake it puts everything into one large project rather than splitting it into individ...
In Eclipse CDT, there is a way to set different code styles for C and C++ files, but it involves using the "Code Formatter" settings in the Eclipse IDE rather than just the project settings. Unfortunately, Eclipse CDT does not directly support different formatter profiles based on the file type within a single project....
49,328
[ { "from": "human", "value": "We are using CMake to manage our builds and have a rather large project consisting of pretty much everything that is needed to build the software base for our embedded platforms save for the toolchain. When building a CDT project with CMake it puts everything into one large proj...
I am a hobbyist programmer (started with VBA to make excel quicker) and have been working with VB.NET / C#.NET and am trying to learn ADO.NET. A facet of programming that has always frustrated me is what does 'good' look like? I am not a professional so have little to compare against. What makes a better programmer? I...
As a hobbyist programmer, it's great that you're seeking to understand what constitutes "good" programming and how you can improve your skills. Here are several key aspects that often differentiate professional programmers from hobbyists, along with some insights into what makes code "good." ### 1. **Understanding of ...
49,008
[ { "from": "human", "value": "I am a hobbyist programmer (started with VBA to make excel quicker) and have been working with VB.NET / C#.NET and am trying to learn ADO.NET.\nA facet of programming that has always frustrated me is what does 'good' look like? I am not a professional so have little to compare a...
Is it possible, or does anyone know the best way to capture MSN chats? I was thinking about attaching to the MSN process, and messing about searching for static addresses for conversations, to capture them. (This is all on the windows platform using c++)
Capturing MSN chats programmatically can be quite complex, especially considering the age of MSN Messenger (which was discontinued in 2013) and the implications of doing so. Here are some methods that were traditionally used, although they may no longer be effective due to the discontinuation of the service and various...
42,217
[ { "from": "human", "value": "Is it possible, or does anyone know the best way to capture MSN chats? I was thinking about attaching to the MSN process, and messing about searching for static addresses for conversations, to capture them. \n(This is all on the windows platform using c++)\n" }, { "fro...
I am working on an ASP.NET (3/5) web application. In the application, we assemble lists of classes from a variety of data sources. I would like to create a report in SQL Server SSRS that renders a report from the contents of one of those lists, without pushing the list to the database (in fact, it would be a violatio...
Creating an SSRS report that uses data from a .NET application directly, without pushing it to SQL Server, can be achieved through several approaches. Below are some strategies you can consider for rendering reports using data already available in your ASP.NET application. ### 1. Use a Web Service as a Data Source You...
47,233
[ { "from": "human", "value": "I am working on an ASP.NET (3/5) web application. In the application, we assemble lists of classes from a variety of data sources. I would like to create a report in SQL Server SSRS that renders a report from the contents of one of those lists, without pushing the list to the ...
Say I have a C program which is broken to a set of *.c and *.h files. If code from one file uses functions from another file, where should I include the header file? Inside the *.c file that used the function, or inside the header of that file? E.g. file foo.c includes foo.h, which contains all declarations for foo.c; ...
When organizing your C code across multiple `.c` and `.h` files, it's important to manage your `#include` directives effectively to ensure clarity and maintainability. Here's a guideline regarding where to include header files when functions from different source files are interdependent. ### Where to Include Header F...
47,694
[ { "from": "human", "value": "Say I have a C program which is broken to a set of *.c and *.h files. If code from one file uses functions from another file, where should I include the header file? Inside the *.c file that used the function, or inside the header of that file?\nE.g. file foo.c includes foo.h, w...
I have code in an Update Panel and even though on a button click i am inserting data into a db and simply calling Updatepanel.Update() the whole page is reloaded: Gifts.ASPX <table style="width:100%;"> <tr> <td> <asp:Label ID="Label2" runat="server" Text="Gift"></asp:Labe...
When using an UpdatePanel in ASP.NET, there are certain considerations to ensure that the partial postbacks work correctly and prevent a full page reload. From the provided code, a few things may be causing the issue you're experiencing. Here are some common factors to check and resolve the problem: ### 1. Trigger for...
48,344
[ { "from": "human", "value": "I have code in an Update Panel and even though on a button click i am inserting data into a db and simply calling Updatepanel.Update() the whole page is reloaded:\nGifts.ASPX\n<table style=\"width:100%;\">\n <tr>\n <td>\n <asp:Label I...
When an application is launched, I need to know for certain methods when they are fired. How to do this using attributes and AOP techniques? The simplest way is to record the time in the event method such as this: private void Page_load() { DateTime dt = DateTime.Now; } And save the Datetime into a database. But thi...
To track method execution times in a clean and maintainable way using attributes and Aspect-Oriented Programming (AOP), you can indeed use PostSharp, as you've mentioned, but handling events can be a bit tricky since they typically require more boilerplate code. Fortunately, there are other frameworks and approaches t...
48,223
[ { "from": "human", "value": "When an application is launched, I need to know for certain methods when they are fired. How to do this using attributes and AOP techniques?\nThe simplest way is to record the time in the event method such as this:\nprivate void Page_load()\n{\n DateTime dt = DateTime.Now;\n}\n...
I need to attach some javascript to the onchange event of the Zend_Form_Element. How do I do that?
In Zend Framework, you can attach JavaScript to the `onchange` event of a form element, such as a select box or input field, by using the `setAttrib()` method. Here's how you can do it: ### Example: Attaching JavaScript to `onchange` Event Suppose you have a form with a select element and you want to trigger some Jav...
48,516
[ { "from": "human", "value": "I need to attach some javascript to the onchange event of the Zend_Form_Element. How do I do that?\n" }, { "from": "gpt", "value": "In Zend Framework, you can attach JavaScript to the `onchange` event of a form element, such as a select box or input field, by using t...
I have recently learned the Ruby programming language, and all in all it is a good language. But I was quite surprised to see that it was not as simple as I had expected. More precisely, the "rule of least-surprise" did not seem very respected to me (of course this is quite subjective). For example: x = true and fal...
Ruby is often praised for its elegant syntax and expressiveness, but it does have its share of quirks and "gotchas" that can surprise newcomers. Here are some other common pitfalls and subtleties to be aware of as you continue learning Ruby: 1. **Logical Operators**: - The expression `x = true and false` assigns `t...
46,051
[ { "from": "human", "value": "I have recently learned the Ruby programming language, and all in all it is a good language. But I was quite surprised to see that it was not as simple as I had expected. More precisely, the \"rule of least-surprise\" did not seem very respected to me (of course this is quite ...
I have a ASP.NET project and when building the project it is showing build suceessfull. But when I am building the deployment project, it is showing build failed with an error message Error 5 "aspnet_compiler.exe" exited with code 1 I rechecked my project and found that when i am removing the line <!--#include ...
The error you're encountering seems to be related to the `aspnet_compiler.exe` tool, which is part of the ASP.NET compilation process. When it exits with code 1, it usually indicates a general error occurred during the compilation. Since you identified that the issue arises when including `topstyle.asp`, there are a fe...
48,801
[ { "from": "human", "value": "I have a ASP.NET project and when building the project it is showing build suceessfull. But when I am building the deployment project, it is showing build failed with an error message \nError 5 \"aspnet_compiler.exe\" exited with code 1\n\nI rechecked my project and found ...
Given a file tree - a directory with directories in it etc, how would you write a script to create a diagram of the file-tree as a graphic file that I can embed in a word processor document. I prefer vector (SVG, EPS, EMF...) files. The tool must run on Windows, but preferably cross-platform. The tool may be commercia...
To create a diagram of a file tree in a vector format like SVG from a script, you can use Python along with the `os` module to traverse the file system and a library like `svgwrite` to generate the SVG file. Here's a step-by-step guide to achieve this: ### Prerequisites 1. **Python Installation:** Ensure you have Pyt...
44,396
[ { "from": "human", "value": "Given a file tree - a directory with directories in it etc, how would you write a script to create a diagram of the file-tree as a graphic file that I can embed in a word processor document.\nI prefer vector (SVG, EPS, EMF...) files.\nThe tool must run on Windows, but preferabl...
I have been searching for several hours but i couldn't find anything about this... Basically I would like to create a template or plug-in for word 2007 that would allow someone to create new pages for a CMS. What I have in mind is something similar to blog post template. I know how to create a basic template but I can'...
Creating a template or plug-in for Word 2007 to publish documents directly to a CMS is an interesting project! While Word 2007 doesn't have built-in support for publishing to CMS platforms, you can create a custom solution using VBA (Visual Basic for Applications) or a Word Add-in. Here’s a basic guide on how to get st...
48,988
[ { "from": "human", "value": "I have been searching for several hours but i couldn't find anything about this... Basically I would like to create a template or plug-in for word 2007 that would allow someone to create new pages for a CMS. What I have in mind is something similar to blog post template. I know ...
I have just realized I've been coercing binding/dependency properties and not really fundamentally understanding the concept. Heres the dependency property: public string Problem { get { return (string)GetValue(ProblemProperty); } set { SetValue(ProblemProperty, value); } } public static readonly DependencyPro...
It looks like you're on the right track in using dependency properties, but there are a couple of important concepts you might be missing that relate to how property change notifications work in WPF (Windows Presentation Foundation). ### Understanding Dependency Properties When you create a dependency property in WPF...
44,793
[ { "from": "human", "value": "I have just realized I've been coercing binding/dependency properties and not really fundamentally understanding the concept.\nHeres the dependency property:\npublic string Problem\n{\n get { return (string)GetValue(ProblemProperty); }\n set { SetValue(ProblemProperty, val...
I am trying to create 1 Parent Drop Down, that has 2 dependent child drop down lists using JAVASCRIPT. My html page is at - http://www.larkgrove.com/entryform/entryform.html I am using the Dynamic Options Lists / Dependent Selects: http://www.javascripttoolbox.com/lib/dynamicoptionlist/examples.php If you check out my ...
To create a parent drop-down with two dependent child drop-down lists using JavaScript, you'll need to follow a structured approach. Below is a simplified example to illustrate how to set this up. You can adapt this code to fit your existing HTML structure. ### HTML Structure Here's an example of how your HTML might ...
48,662
[ { "from": "human", "value": "I am trying to create 1 Parent Drop Down, that has 2 dependent child drop down lists using JAVASCRIPT.\nMy html page is at - http://www.larkgrove.com/entryform/entryform.html\nI am using the Dynamic Options Lists / Dependent Selects:\nhttp://www.javascripttoolbox.com/lib/dynamic...
I've implemented IDynamicObject in C# 4, return a custom MetaObject subclass that does simple property getter/setter dispatch to a Dictionary. Not rocket science. If I do this: dynamic foo = new DynamicFoo(); foo.Name = "Joe"; foo.Name = "Fred"; Console.WriteLine(foo.Name); Then 'Joe' is printed to the console... t...
What you are encountering is indeed related to how the Dynamic Language Runtime (DLR) handles dynamic operations and callsite caching. The DLR optimizes access to dynamic members by caching the results of the first call, which can lead to the behavior you're seeing. In your scenario, when you first set `foo.Name` to "...
46,502
[ { "from": "human", "value": "I've implemented IDynamicObject in C# 4, return a custom MetaObject subclass that does simple property getter/setter dispatch to a Dictionary. Not rocket science.\nIf I do this:\ndynamic foo = new DynamicFoo();\n\nfoo.Name = \"Joe\";\n\nfoo.Name = \"Fred\";\n\nConsole.WriteLine(...
How do type casting happen without loss of data inside the compiler? For example: int i = 10; UINT k = (UINT) k; float fl = 10.123; UINT ufl = (UINT) fl; // data loss here? char *p = "Stackoverflow Rocks"; unsigned char *up = (unsigned char *) p; How does the compiler handle this type of typecasting? A low-le...
Type casting in programming, particularly in languages like C or C++, is a mechanism by which a variable of one type is converted to another type. The process can sometimes involve data loss, depending on the types involved and their representations. Let's break down the examples you've provided and discuss how type ca...
46,638
[ { "from": "human", "value": "How do type casting happen without loss of data inside the compiler?\nFor example:\n int i = 10;\n UINT k = (UINT) k;\n\n float fl = 10.123;\n UINT ufl = (UINT) fl; // data loss here?\n\n char *p = \"Stackoverflow Rocks\";\n unsigned char *up = (unsigned char *) p;\n\nHow does ...
How can I list the contents of a zipped folder in C#? For example how to know how many items are contained within a zipped folder, and what is their name?
In C#, you can list the contents of a zipped folder using the `System.IO.Compression` namespace, which provides classes for working with zip files. The `ZipArchive` class allows you to open a zip file and enumerate its entries. Here's an example of how to list the contents of a zipped folder, including the number of i...
49,957
[ { "from": "human", "value": "How can I list the contents of a zipped folder in C#? For example how to know how many items are contained within a zipped folder, and what is their name?\n" }, { "from": "gpt", "value": "In C#, you can list the contents of a zipped folder using the `System.IO.Compre...
I have the following table custid ordid qty datesold 1 A2 12 2008-01-05 2 A5 5 2008-01-02 1 A1 5 2008-01-01 2 A7 3 2007-02-05 What't the best way of getting the previous order for every customer? Thanks
To retrieve the previous order for each customer from the given table, you can utilize SQL to perform a self-join or use window functions. Both methods can achieve the same goal. Below are two approaches: ### Method 1: Using Window Functions If your SQL database supports window functions (like PostgreSQL, SQL Server,...
49,942
[ { "from": "human", "value": "I have the following table\n\ncustid ordid qty datesold\n1 A2 12 2008-01-05\n2 A5 5 2008-01-02\n1 A1 5 2008-01-01\n2 A7 3 2007-02-05\n\nWhat't the best way of getting the previous order for ...
I am getting the "This attribute does not support request time values." while compiling my custom jsp tag implementation. My TLD file <?xml version="1.0" encoding="ISO-8859-1" ?> <!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN" "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd"> ...
The error message you're receiving indicates that the attributes `viewID` and `viewType` are being treated as runtime values, but your TLD file is configured in a way that does not support them being passed as such. In the TLD file you provided, the `rtexpvalue` attribute is set to `true`, which is correct for allowi...
44,341
[ { "from": "human", "value": "I am getting the \"This attribute does not support request time values.\" while compiling my custom jsp tag implementation.\nMy TLD file\n<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n<!DOCTYPE taglib PUBLIC \"-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN\" \"http:...
I am not sure if I am missing something grotesquely obvious or what, but I can't seem to figure out how to efficiently access tables in a relational database. I am using PostgreSQL for the database server (and Npgsql for its access) and C# with Mono 2.0. Say I have the table created by the following CREATE TABLE and I...
Your intuition is correct that accessing fields in the `NpgsqlDataReader` using their column names (like you would in your pseudocode) is a desirable feature for code readability and maintainability. However, in your case, the `NpgsqlDataReader` does not support direct indexing by column name. Instead, you can use the ...
47,993
[ { "from": "human", "value": "I am not sure if I am missing something grotesquely obvious or what, but I can't seem to figure out how to efficiently access tables in a relational database. I am using PostgreSQL for the database server (and Npgsql for its access) and C# with Mono 2.0.\nSay I have the table c...
I'm trying to save the contents of a particular registry key to a file using the RegSaveKey() API: HKEY key; LRESULT result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"Software\\MyProduct", 0, KEY_ACCESS_ALL, &key); result = RegSaveKey(key, L"c:\\temp\\saved.reg", NULL); However, RegSaveKey() is returning ERROR_PRIVILEGE_NOT...
The `ERROR_PRIVILEGE_NOT_HELD` error indicates that your process does not have the necessary privileges to save the registry key. Even if your process is running as a local administrator or as a service, the `SE_BACKUP_NAME` privilege may not be enabled by default. To resolve this issue, you need to explicitly enable t...
47,574
[ { "from": "human", "value": "I'm trying to save the contents of a particular registry key to a file using the RegSaveKey() API:\nHKEY key;\nLRESULT result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, L\"Software\\\\MyProduct\", 0, KEY_ACCESS_ALL, &key);\nresult = RegSaveKey(key, L\"c:\\\\temp\\\\saved.reg\", NULL);\n...
My company is moving from svn (and open source products) to TFS (and MS products). We've used maven in the past for packaging-up pre-built components into release-ready packages. Is there a tool in TFS or MS-Land as powerful as maven to do this? I've looked at msbuild, but it seems a little less robust than Maven.
When migrating from SVN and open-source products to TFS (now known as Azure DevOps), it's important to consider the tools available in the Microsoft ecosystem for build automation, packaging, and deployment. ### Key Tools in the Microsoft Ecosystem 1. **MSBuild**: - MSBuild is the primary build tool for .NET proje...
44,948
[ { "from": "human", "value": "My company is moving from svn (and open source products) to TFS (and MS products). We've used maven in the past for packaging-up pre-built components into release-ready packages. Is there a tool in TFS or MS-Land as powerful as maven to do this?\nI've looked at msbuild, but it...
I have an application which is a relatively old. Through some minor changes, it builds nearly perfectly with Visual C++ 2008. One thing that I've noticed is that my "debug console" isn't quite working right. Basically in the past, I've use AllocConsole() to create a console for my debug output to go to. Then I would us...
The issue you're encountering with `std::cout` not outputting to the console created by `AllocConsole` is indeed a known quirk in older versions of Visual C++. The reason your custom `streambuf` approach works is that `std::cout` and the C-style `stdout` are not inherently linked after the redirect. Here's a cleaner a...
46,808
[ { "from": "human", "value": "I have an application which is a relatively old. Through some minor changes, it builds nearly perfectly with Visual C++ 2008. One thing that I've noticed is that my \"debug console\" isn't quite working right. Basically in the past, I've use AllocConsole() to create a console fo...
I'm having difficulty searching for this. How would I define an element in an XML schema file for XML that looks like this: <option value="test">sometext</option> I can't figure out how to define an element that is of type xs:string and also has an attribute. Here's what I've got so far: <xs:element name="option"> ...
You're on the right track, but there is a small mistake in your XML schema definition. The text content ("sometext" in your example) must be included in the complex type definition. In XML Schema (XSD), you can use a `xs:simpleContent` to define an element that has both attributes and text content. Here's how you can ...
47,774
[ { "from": "human", "value": "I'm having difficulty searching for this. How would I define an element in an XML schema file for XML that looks like this:\n<option value=\"test\">sometext</option>\n\nI can't figure out how to define an element that is of type xs:string and also has an attribute. \nHere's what...
Javascript I have code that will hide various sections in a MS CRM form based on the value of a Picklist. The code executes in the onChange event of the Picklist. It hides the section by referencing a field in the section and then navigating up the DOM using the ParentElement syntax, as such: crmForm.all.fieldName.pa...
The issue you're experiencing with hiding the section that contains a read-only field in MS CRM is likely due to the structure of the DOM elements in that particular section. When using the `.parentElement` approach, it can sometimes lead to unexpected results if the hierarchy of elements doesn't match your assumptions...
45,647
[ { "from": "human", "value": "Javascript\nI have code that will hide various sections in a MS CRM form based on the value of a Picklist. The code executes in the onChange event of the Picklist. It hides the section by referencing a field in the section and then navigating up the DOM using the ParentElement...
A lot of developers say only throw exceptions in truly exceptional circumstances. One of these would be if an external hard drive I want to write to is not switched on (therefore not a connected/registered drive). However, there are some situations which are difficult to work out whether they are truly exceptional or n...
The debate around when to throw exceptions vs. using return values or other means of error handling is a common one among developers. Below are some insights into best practices regarding exception handling, particularly in your examples: ### When to Use Exceptions 1. **Truly Exceptional Situations**: Exceptions shou...
46,700
[ { "from": "human", "value": "A lot of developers say only throw exceptions in truly exceptional circumstances. One of these would be if an external hard drive I want to write to is not switched on (therefore not a connected/registered drive). However, there are some situations which are difficult to work ou...
In the application I'm writing, one of the methods allows for the numbers the user entered to be turned into letters. For example, the user will be entering grades (as doubles) and the program will decide (when the criteria is met) to return the letter associated with the number. Initially, I had it written like this: ...
To refactor your code to return a letter grade instead of printing it directly, you need to make a few adjustments. Here's how you can do it step by step: 1. Change the method signature to return a `string`. 2. Replace `Console.WriteLine` statements with `return` statements to return the appropriate letter grade. 3. U...
48,673
[ { "from": "human", "value": "In the application I'm writing, one of the methods allows for the numbers the user entered to be turned into letters.\nFor example, the user will be entering grades (as doubles) and the program will decide (when the criteria is met) to return the letter associated with the numbe...
I'm experimenting with IoC on my way to TDD by fiddling with an existing project. In a nutshell, my question is this: what are the best practices around IoC when public and non-public methods are of interest? There are two classes: public abstract class ThisThingBase { public virtual void Method1() {} public vi...
When experimenting with Inversion of Control (IoC) and Test-Driven Development (TDD), it's essential to consider the principles of separation of concerns and interface segregation. Here are some best practices and approaches you can take in your scenario involving public and internal methods. ### Define Interfaces 1....
47,242
[ { "from": "human", "value": "I'm experimenting with IoC on my way to TDD by fiddling with an existing project. In a nutshell, my question is this: what are the best practices around IoC when public and non-public methods are of interest?\nThere are two classes:\npublic abstract class ThisThingBase\n{\n p...
How can I remove duplicate values from a multi-dimensional array in PHP? Example array: Array ( [0] => Array ( [0] => abc [1] => def ) [1] => Array ( [0] => ghi [1] => jkl ) [2] => Array ( [0] => mno [1] => pql ) [3] => Array ...
To remove duplicate values from a multi-dimensional array in PHP, you can use a combination of the `array_map`, `array_unique`, and `array_values` functions. However, since we're dealing with a multi-dimensional array where each sub-array needs to be treated as a single entity, we'll need to serialize the sub-arrays to...
49,881
[ { "from": "human", "value": "How can I remove duplicate values from a multi-dimensional array in PHP?\nExample array:\nArray\n(\n [0] => Array\n (\n [0] => abc\n [1] => def\n )\n\n [1] => Array\n (\n [0] => ghi\n [1] => jkl\n )\n\n [2] => Array\n (\n ...