instruction
stringlengths
14
27.6k
completion
stringlengths
3
38.3k
__original_row_idx
int64
0
50k
conversations
listlengths
2
2
Can anyone provide some pseudo code for a roulette selection function? How would I implement this: I don't really understand how to read this math notation. I never took any probability or statistics.
Sure! Roulette selection, often used in genetic algorithms, is a method for selecting individuals (solutions) based on their fitness. The idea is to give individuals with higher fitness a higher probability of being selected, similar to how a roulette wheel works where larger segments have a higher chance of being land...
25,063
[ { "from": "human", "value": "Can anyone provide some pseudo code for a roulette selection function? How would I implement this:\n\nI don't really understand how to read this math notation. I never took any probability or statistics.\n" }, { "from": "gpt", "value": "Sure! Roulette selection, ofte...
I just read that the 2.6.27 kernel has a new module called ftrace which sounds a lot like suns dtrace utility. I'm having some trouble googling for documentation, I was wondering if anyone else had something. Is this something that is going to be implemented on the full programming stack like dtrace and we'll get a nic...
Yes, `ftrace` is a powerful tracing framework that was introduced in the Linux kernel (specifically starting from version 2.6.27) and can be compared to DTrace in some aspects, though there are differences in implementation and usage. ### Overview of ftrace - **Function Tracer:** `ftrace` allows you to trace function...
23,806
[ { "from": "human", "value": "I just read that the 2.6.27 kernel has a new module called ftrace which sounds a lot like suns dtrace utility. I'm having some trouble googling for documentation, I was wondering if anyone else had something. Is this something that is going to be implemented on the full programm...
Python's access to environment variables does not accurately reflect the operating system's view of the processes environment. os.getenv and os.environ do not function as expected in particular cases. Is there a way to properly get the running process' environment? To demonstrate what I mean, take the two roughly equi...
The issue you're encountering stems from the way Python handles environment variables compared to C. In Python, the `os.environ` dictionary and `os.getenv()` function retrieve values from the environment variables as they were when the Python interpreter was started. They do not automatically update when the environmen...
24,623
[ { "from": "human", "value": "Python's access to environment variables does not accurately reflect the operating system's view of the processes environment.\nos.getenv and os.environ do not function as expected in particular cases.\nIs there a way to properly get the running process' environment?\n\nTo demon...
I have an asp.net website that allows the user to download largish files - 30mb to about 60mb. Sometimes the download works fine but often it fails at some varying point before the download finishes with the message saying that the connection with the server was reset. Originally I was simply using Server.TransmitFile...
Your current implementation for file downloading in ASP.NET seems to have a couple of potential areas that could contribute to the connection reset issue when downloading large files. Here are a few suggestions and improvements to help troubleshoot and potentially fix the problem: ### 1. **Increase Request and Respons...
20,625
[ { "from": "human", "value": "I have an asp.net website that allows the user to download largish files - 30mb to about 60mb. Sometimes the download works fine but often it fails at some varying point before the download finishes with the message saying that the connection with the server was reset.\nOrigina...
Excuse my title if it's confusing, but I don't know how else to describe this, except in the long explanation below: I would like to create a multidimensional, templated, data bound, repeating ASP.NET control, with paging and sorting. I.e. You specify how many columns and rows per page, so items are displayed across a...
Creating a multidimensional, templated, data-bound control in ASP.NET 2.0 that supports paging and sorting can be a bit of a challenge since the built-in controls like `Repeater`, `DataList`, and `DataGrid` do not provide the functionality you need directly out of the box. However, you can achieve this with some custom...
17,110
[ { "from": "human", "value": "Excuse my title if it's confusing, but I don't know how else to describe this, except in the long explanation below:\nI would like to create a multidimensional, templated, data bound, repeating ASP.NET control, with paging and sorting. I.e. You specify how many columns and rows...
When paging through data that comes from a DB, you need to know how many pages there will be to render the page jump controls. Currently I do that by running the query twice, once wrapped in a count() to determine the total results, and a second time with a limit applied to get back just the results I need for the curr...
Yes, your current approach of running two separate queries can indeed be inefficient, especially if the dataset is large. There are a few strategies you can consider to improve the performance of pagination in PostgreSQL. ### 1. Use `COUNT(*) OVER()` for Total Count You can utilize a window function to get the total ...
23,500
[ { "from": "human", "value": "When paging through data that comes from a DB, you need to know how many pages there will be to render the page jump controls.\nCurrently I do that by running the query twice, once wrapped in a count() to determine the total results, and a second time with a limit applied to get...
How do you pass options to an executable? Is there an easier way than making the options boolean arguments? EDIT: The last two answers have suggested using arguments. I know I can code a workable solution like that, but I'd rather have them be options. EDIT2: Per requests for clarification, I'll use this simple exam...
When dealing with command-line options for executables, a common and more user-friendly approach than using boolean flags (like `true` or `false`) is to use option parsing libraries or frameworks that allow for named arguments, typically prefixed with one or two dashes (e.g., `--nolinebreaks`). This way, options can be...
23,589
[ { "from": "human", "value": "How do you pass options to an executable? Is there an easier way than making the options boolean arguments?\nEDIT: The last two answers have suggested using arguments. I know I can code a workable solution like that, but I'd rather have them be options.\nEDIT2: Per requests f...
I know how to find a method in java using a fixed string, someClass.getMethod("foobar", argTypes); but is there a way to use a regular expression rather than a fixed string to find a method on a given class? An example of the usage might be if I wanted to find a method that was called either "foobar" or "fooBar". Usi...
In Java, the Reflection API does not directly support searching for methods using regular expressions. However, you can achieve this by retrieving all the methods of a class and then filtering them based on the desired regular expression. Here’s how you can do this: 1. Get all the declared methods of the class using `...
23,511
[ { "from": "human", "value": "I know how to find a method in java using a fixed string,\nsomeClass.getMethod(\"foobar\", argTypes);\n\nbut is there a way to use a regular expression rather than a fixed string to find a method on a given class? \nAn example of the usage might be if I wanted to find a method t...
I have this 'simplified' fortran code real B(100, 200) real A(100,200) ... initialize B array code. do I = 1, 100 do J = 1, 200 A(J,I) = B(J,I) end do end do One of the programming gurus warned me, that fortran accesses data efficiently in column order, while c accesses data efficiently in row order. He s...
In Fortran, arrays are stored in column-major order, meaning that elements in the same column are stored in contiguous memory locations. In contrast, C uses row-major order, where elements in the same row are stored contiguously. This difference can lead to inefficiencies when accessing array elements if the loops are ...
24,120
[ { "from": "human", "value": "I have this 'simplified' fortran code\nreal B(100, 200) \nreal A(100,200)\n\n... initialize B array code.\n\ndo I = 1, 100\n do J = 1, 200\n A(J,I) = B(J,I)\n end do\nend do\n\nOne of the programming gurus warned me, that fortran accesses data efficiently in column order, w...
This posting here (How do you manage database revisions on a medium sized project with branches?) got me wondering how best to work on a web project using branching and deploying to dev, staging, and production (along with local copies). We don't have "releases" per se: if a feature is big enough to be noticeable, we p...
Your current workflow does have some advantages, but it also has potential pitfalls, especially with managing complexity and maintaining synchronization between branches. Here’s a refined approach using Git, which can help streamline your workflow and make it more robust: ### Suggested Workflow Using Git 1. **Branch ...
23,607
[ { "from": "human", "value": "This posting here (How do you manage database revisions on a medium sized project with branches?) got me wondering how best to work on a web project using branching and deploying to dev, staging, and production (along with local copies).\nWe don't have \"releases\" per se: if a ...
This is what I currently have: CREATE OR REPLACE TRIGGER MYTRIGGER AFTER INSERT ON SOMETABLE FOR EACH ROW DECLARE v_emplid varchar2(10); BEGIN SELECT personnum into v_emplid FROM PERSON WHERE PERSONID = :new.EMPLOYEEID; dbms_output.put(v_emplid); /* INSERT INTO SOMEOTHERTABLE USING v_emplid and some o...
The error you're encountering, "ORA-00923: FROM keyword not found where expected," typically indicates an issue with the SQL syntax. In your case, it seems to be related to the way you're using the `dbms_output.put` procedure and possibly also with the overall structure of the trigger. Here are a few points to address...
19,204
[ { "from": "human", "value": "This is what I currently have:\nCREATE OR REPLACE TRIGGER MYTRIGGER\nAFTER INSERT ON SOMETABLE\nFOR EACH ROW \n\nDECLARE\n v_emplid varchar2(10); \n\nBEGIN\n SELECT\n personnum into v_emplid\n FROM PERSON\n WHERE PERSONID = :new.EMPLOYEEID;\n\ndbms_output.put(v_emplid);\n...
My application has several threads: 1) Main Thread 2) 2 Sub-Main Threads (each with Message Loop, as shown below), used by TFQM 3) n Worker Threads (simple loop, containing Sleep()) My problem is, when I close my application, the Worker Threads manage to exit properly, but 1 of the 2 Sub-Main Threads hangs (never exits...
The issue you're encountering with one of your Sub-Main Threads hanging upon receiving the `WM_QUIT` message could be caused by several factors. Here's a step-by-step analysis of potential problems and their solutions: ### Potential Issues and Solutions 1. **Message Loop Processing**: - Ensure that the message l...
23,238
[ { "from": "human", "value": "My application has several threads:\n1) Main Thread\n2) 2 Sub-Main Threads (each with Message Loop, as shown below), used by TFQM\n3) n Worker Threads (simple loop, containing Sleep())\nMy problem is, when I close my application, the Worker Threads manage to exit properly, but 1...
I'm parsing XML results from an API call using PHP and xpath. $dom = new DOMDocument(); $dom->loadXML($response->getBody()); $xpath = new DOMXPath($dom); $xpath->registerNamespace("a", "http://www.example.com"); $hrefs = $xpath->query('//a:Books/text()', $dom); for ($i = 0; $i < $hrefs->length; $i++) { ...
Yes, you can access both the text content and the attributes from one XPath query in PHP by using a more complex XPath expression. You can retrieve the text and attributes together, typically by iterating over the selected nodes and accessing both the text nodes and their attributes. Here is how you can adjust your co...
22,443
[ { "from": "human", "value": "I'm parsing XML results from an API call using PHP and xpath. \n $dom = new DOMDocument();\n $dom->loadXML($response->getBody());\n\n $xpath = new DOMXPath($dom);\n $xpath->registerNamespace(\"a\", \"http://www.example.com\");\n\n $hrefs = $xpath->query('//a:Books/text()', $dom...
There are lots of web application frameworks available these days, for pretty much every language out there. In your experience, what are their strengths, weaknesses, and unique features? Assuming the luxury of choice, what factors would lead you to consider one over another other? I'm most interested in people's dir...
I've had experience with several web application frameworks, and each has its own strengths, weaknesses, and unique features that influence the decision to use one over another. Below, I'll share insights into a few popular frameworks and consider the factors you've mentioned. ### Ruby on Rails **Strengths:** - **Rapi...
19,078
[ { "from": "human", "value": "There are lots of web application frameworks available these days, for pretty much every language out there. In your experience, what are their strengths, weaknesses, and unique features? Assuming the luxury of choice, what factors would lead you to consider one over another o...
Is it right to use a private constant in the following situation: Say I have a game with a lives variable and a startingLives variable. At the start of the game I set the lives variable to equal the startingLives variable. This is how I would normally do it: private var lives:int = 0; private var startingLives:int = 3;...
In your situation, using a `const` for `STARTING_LIVES` is indeed a good practice, especially since you indicated that the value is unlikely to change during runtime. By declaring it as a constant, you are making it clear to anyone reading the code (including yourself in the future) that this value is intended to remai...
26,142
[ { "from": "human", "value": "Is it right to use a private constant in the following situation:\nSay I have a game with a lives variable and a startingLives variable. At the start of the game I set the lives variable to equal the startingLives variable. This is how I would normally do it:\nprivate var lives:...
When creating a WPF user control, is it possible to make a property required via an attribute or other mechanism?
In WPF, there isn't a built-in way to enforce property requirements (like "required" properties) directly through attributes in the way you might see in some other frameworks or programming languages. However, you can implement your own checks to enforce required properties for your WPF UserControl. Here are some com...
23,771
[ { "from": "human", "value": "When creating a WPF user control, is it possible to make a property required via an attribute or other mechanism?\n" }, { "from": "gpt", "value": "In WPF, there isn't a built-in way to enforce property requirements (like \"required\" properties) directly through attr...
I have some nested tables that I want to hide/show upon a click on one of the top-level rows. The markup is, in a nutshell, this: <table> <tr> <td>stuff</td> .... more tds here </tr> <tr> <td colspan=some_number> <table> </table> </td> </tr> </table> Now, I'...
It sounds like you're encountering an issue that can sometimes arise due to the way Internet Explorer handles table elements compared to other browsers like Firefox. Let's break down a few strategies to troubleshoot and potentially resolve the issue. ### Troubleshooting Steps: 1. **Check CSS for Display Property**: E...
25,001
[ { "from": "human", "value": "I have some nested tables that I want to hide/show upon a click on one of the top-level rows.\nThe markup is, in a nutshell, this:\n\n <table>\n <tr>\n <td>stuff</td>\n .... more tds here\n </tr>\n <tr>\n <td colspan=some_number>\n <table>\n ...
I have a form showing progress messages as a fairly long process runs. It's a call to a web service so I can't really show a percentage complete figure on a progress bar meaningfully. (I don't particularly like the Marquee property of the progress bar) I would like to show an animated GIF to give the process the feel o...
To display an animated GIF in your form during a long-running process, you can follow these general steps depending on the technology stack you're using. I'll provide a simple example using Windows Forms in C#. If you're using a different framework (like WPF, WinForms, or web applications), the specific implementation ...
21,820
[ { "from": "human", "value": "I have a form showing progress messages as a fairly long process runs. It's a call to a web service so I can't really show a percentage complete figure on a progress bar meaningfully. (I don't particularly like the Marquee property of the progress bar)\nI would like to show an a...
How can i map a date from a java object to a database with Hibernate? I try different approaches, but i am not happy with them. Why? Let me explain my issue. I have the following class [1] including the main method i invoke and with the following mapping [2]. The issue about this approach you can see, when you look at ...
The problem you're encountering is related to how Java and Hibernate handle date and time, particularly with regard to precision and the use of `java.util.Date`. Here's an explanation of the issues you're facing and some suggestions for improving your approach. ### Issues with the Current Approach 1. **Precision of D...
22,876
[ { "from": "human", "value": "How can i map a date from a java object to a database with Hibernate? I try different approaches, but i am not happy with them. Why? Let me explain my issue. I have the following class [1] including the main method i invoke and with the following mapping [2]. The issue about thi...
I'm trying to convert some strings that are in French Canadian and basically, I'd like to be able to take out the French accent marks in the letters while keeping the letter. (E.g. convert é to e, so crème brûlée would become creme brulee) What is the best method for achieving this?
To remove accent marks from French characters while retaining the letters in Python, you can use the `unidecode` library or the `unicodedata` library. Here's how you can use both methods: ### Method 1: Using `unidecode` First, you need to install the `unidecode` library if you haven't done so already: ```bash pip in...
26,265
[ { "from": "human", "value": "I'm trying to convert some strings that are in French Canadian and basically, I'd like to be able to take out the French accent marks in the letters while keeping the letter. (E.g. convert é to e, so crème brûlée would become creme brulee)\nWhat is the best method for achieving ...
I've noticed for quite a long time that strange domains such like jsev.com, cssxx.com appered in my firefox status bar from time to time, I always wonder why so many web pages contains resources from these strange domains. I googled it, but found nothing. I guess it's some kind of virus which infect the servers and ins...
The behavior you're observing, where strange domains are appearing in your Firefox status bar, is indeed concerning and can potentially indicate a few issues. Here are some possible explanations and steps you can take to investigate and resolve the problem: 1. **Malware or Adware Infection**: It's possible that your s...
22,677
[ { "from": "human", "value": "I've noticed for quite a long time that strange domains such like jsev.com, cssxx.com appered in my firefox status bar from time to time, I always wonder why so many web pages contains resources from these strange domains. I googled it, but found nothing. I guess it's some kind ...
I need a date formula in Oracle SQL or T-SQL that will return a date of the previous week (eg Last Monday's date). I have reports with parameters that are run each week usually with parameter dates mon-friday or sunday-saturday of the previous week. I'd like to not have to type in the dates when i run the reports each...
Certainly! Below are the SQL queries that will return the date for last Monday, which is considered the start of the previous week, in both Oracle SQL and T-SQL (used by SQL Server). ### Oracle SQL To get the date of last Monday in Oracle SQL, you can use the following query: ```sql SELECT TRUNC(SYSDATE, 'IW') - 7 A...
27,620
[ { "from": "human", "value": "I need a date formula in Oracle SQL or T-SQL that will return a date of the previous week (eg Last Monday's date).\nI have reports with parameters that are run each week usually with parameter dates mon-friday or sunday-saturday of the previous week. I'd like to not have to typ...
I got an HTML with the <body onload="window.print()">. The question I'm trying to ask is: Is there any way to remove the strings that the web browsers add to the printed page? Such as: Web site from where the page was printed Page count Title of the web page Date of printing
When printing a webpage, browsers often add header and footer information such as the page title, URL, date, and page numbers to the printed output. This behavior can vary depending on the browser and the user's print settings, and there is no standardized way to control these settings through HTML or CSS. However, her...
26,904
[ { "from": "human", "value": "I got an HTML with the <body onload=\"window.print()\">. \nThe question I'm trying to ask is:\n\nIs there any way to remove the strings that the web browsers add to the printed page?\nSuch as:\n\n\nWeb site from where the page was printed\nPage count\nTitle of the web page\nDate...
I have a class which I'm serialising to send over a unix socket and it has to have a string which I've stored as a char array. Can I initialise it in the constructor differently to how I've done it here? typedef struct SerialFunctionStatus_t { SerialFunctionStatus_t() : serial_rx_count(0), serial_tx_count...
Yes, you can initialize the `port` member differently in the constructor. Instead of initializing it with `port[0] = '\0';`, you can use a member initializer list, and if you want to initialize it with a specific string or value, you could also use `strncpy` or `memset`. Here’s how you can do this: ### Option 1: Using...
27,336
[ { "from": "human", "value": "I have a class which I'm serialising to send over a unix socket and it has to have a string which I've stored as a char array. Can I initialise it in the constructor differently to how I've done it here?\ntypedef struct SerialFunctionStatus_t {\n SerialFunctionStatus_t() \n ...
What's the best way to unit test large data sets? Some legacy code that I'm maintaining has structures of a hundred members or more; other parts of the code that we're working on create or analyze data sets of hundreds of samples. The best approach I've found so far is to serialize the structures or data sets from dis...
Unit testing large data sets, especially in legacy codebases, can indeed be challenging. Here are several strategies to improve your approach while adhering to best practices and maintaining efficiency: ### 1. **In-Memory Serialization** Instead of writing to disk, consider using in-memory serialization libraries (lik...
24,587
[ { "from": "human", "value": "What's the best way to unit test large data sets? Some legacy code that I'm maintaining has structures of a hundred members or more; other parts of the code that we're working on create or analyze data sets of hundreds of samples.\nThe best approach I've found so far is to seri...
How do I access user preferences in Firefox? I have the following code: var control = document.getElementById(control_id); if (control) { control.setAttribute('color', nsPreferences.copyUnicharPref(prefstr, default_val)); } But when I run this, I get the following: Error: nsPreferences is not defined Source file: ...
In Firefox, if you're working with user preferences in an XUL-based extension (which seems to be the case from the context of your code), you need to ensure you're properly accessing the `nsIPrefService` to handle preferences. The error you're encountering indicates that the `nsPreferences` object is not defined in you...
26,881
[ { "from": "human", "value": "How do I access user preferences in Firefox? I have the following code:\nvar control = document.getElementById(control_id);\nif (control) {\n control.setAttribute('color', nsPreferences.copyUnicharPref(prefstr, default_val));\n}\n\nBut when I run this, I get the following:\nE...
I have a JSP page that will display the exact content of another web page on a different server. My understanding was that c:import from the JSTL should be able to include content from files that are not part of the current web application. I added c:import url="page on my server in a different application" and it wor...
The `c:import` tag from the JSTL is designed to include content from URLs. However, there are a few reasons why including a page from another server might not work while including from a different application on the same server does. Here are some common issues and suggestions you can consider: 1. **Cross-Origin Resou...
25,808
[ { "from": "human", "value": "I have a JSP page that will display the exact content of another web page on a different server. My understanding was that c:import from the JSTL should be able to include content from files that are not part of the current web application.\nI added c:import url=\"page on my se...
I have seen various rules for naming stored procedures. Some people prefix the sproc name with usp_, others with an abbreviation for the app name, and still others with an owner name. You shouldn't use sp_ in SQL Server unless you really mean it. Some start the proc name with a verb (Get, Add, Save, Remove). Others em...
It sounds like you've carefully considered the various naming conventions for stored procedures and have found a strategy that aligns with your experience and needs. Here’s a summary of the key aspects of your chosen naming convention, along with the rationale behind it: ### Preferred Naming Convention: App Prefix + V...
24,225
[ { "from": "human", "value": "I have seen various rules for naming stored procedures. \nSome people prefix the sproc name with usp_, others with an abbreviation for the app name, and still others with an owner name. You shouldn't use sp_ in SQL Server unless you really mean it.\nSome start the proc name with...
I'm creating a series of builders to clean up the syntax which creates domain classes for my mocks as part of improving our overall unit tests. My builders essentially populate a domain class (such as a Schedule) with some values determined by invoking the appropriate WithXXX and chaining them together. I've encounter...
It sounds like you're trying to build a fluent interface using builders for your domain classes, which is a common design pattern in unit testing. The challenge you're facing is how to maintain the type safety and fluency of your builders, specifically with returning the correct type from the `WithId` method in your `B...
25,569
[ { "from": "human", "value": "I'm creating a series of builders to clean up the syntax which creates domain classes for my mocks as part of improving our overall unit tests. My builders essentially populate a domain class (such as a Schedule) with some values determined by invoking the appropriate WithXXX a...
I'm developing an application that manages network interfaces on behalf of the user and it calls out to several external programs (such as ifconfig) that requires root to make changes. (Specifically, changing the IP address of a local interface, etc.) During development, I have been running the IDE as root (ugh) and th...
It’s great that you are thinking about security early in your application development. Running your application with root privileges can introduce significant security risks, so creating a design that minimizes this risk while still providing the necessary functionality is a good approach. Here are some methods you co...
25,833
[ { "from": "human", "value": "I'm developing an application that manages network interfaces on behalf of the user and it calls out to several external programs (such as ifconfig) that requires root to make changes. (Specifically, changing the IP address of a local interface, etc.) During development, I have ...
I'm using the FormView control in ASP.NET for a simple form to insert into a MS SQL DB. I have an event for onItemInserting to set some values behind (such as time stamp, etc) and was curious how to check some user entered values in the onItemInserting event and cancel the item from being inserted. The reason I want to...
To cancel the insertion of an item in a `FormView` control in ASP.NET during the `ItemInserting` event, you can set the `Cancel` property of the `FormViewInsertEventArgs` parameter to `true`. This will prevent the insert operation from occurring. Below is an example of how to implement this in your `ItemInserting` even...
26,380
[ { "from": "human", "value": "I'm using the FormView control in ASP.NET for a simple form to insert into a MS SQL DB. I have an event for onItemInserting to set some values behind (such as time stamp, etc) and was curious how to check some user entered values in the onItemInserting event and cancel the item ...
I'm trying to select a column from a single table (no joins) and I need the count of the number of rows, ideally before I begin retrieving the rows. I have come to two approaches that provide the information I need. Approach 1: SELECT COUNT( my_table.my_col ) AS row_count FROM my_table WHERE my_table.foo = 'bar' T...
In your scenario, both approaches will yield the same row count and data, but they handle things differently, especially with respect to the timing of the count and potential concurrency issues. Let's break down your concerns and questions: ### Concern about Row Count Consistency - **Approach 1:** First, you execute ...
24,735
[ { "from": "human", "value": "I'm trying to select a column from a single table (no joins) and I need the count of the number of rows, ideally before I begin retrieving the rows. I have come to two approaches that provide the information I need.\nApproach 1:\nSELECT COUNT( my_table.my_col ) AS row_count\n ...
I'd like to add a menu item to the default ContextMenu of a RichTextBox. I could create a new context menu but then I lose the spell check suggestions that show up in the default menu. Is there a way to add an item without re-implementing everything?
Yes, you can add a custom menu item to the default context menu of a `RichTextBox` in a Windows Forms application without losing the built-in functionality such as spell check suggestions. To achieve this, you'll need to intercept the context menu creation event and add your custom item. Here’s a general approach usin...
23,054
[ { "from": "human", "value": "I'd like to add a menu item to the default ContextMenu of a RichTextBox.\nI could create a new context menu but then I lose the spell check suggestions that show up in the default menu.\nIs there a way to add an item without re-implementing everything?\n" }, { "from": "g...
Have done fft (see earlier posting if you are interested!) and got a result, which helps me. Would like to analyse the noisiness / spikiness of an array (actually a vb.nre collection of single). Um, how to explain ... When signal is good, fft power results is 512 data points (frequency buckets) with low values in all b...
Analyzing the noisiness or spikiness of your FFT output can indeed be approached with various statistical methods. Here are a few strategies that you could consider, which are relatively non-intensive computationally: ### 1. **Calculate the Mean and Standard Deviation** You can compute the mean and standard deviation ...
25,267
[ { "from": "human", "value": "Have done fft (see earlier posting if you are interested!) and got a result, which helps me. Would like to analyse the noisiness / spikiness of an array (actually a vb.nre collection of single). Um, how to explain ...\nWhen signal is good, fft power results is 512 data points (f...
I've been testing an application using my machine as a server, and everything's going fine with it, but when I try to set it up to run on the test server, I get this error: Retrieving the COM class factory for component with CLSID {XXXX} failed due to the following error: 80040154. Any ideas? Thanks
The error message you're encountering, specifically "Retrieving the COM class factory for component with CLSID {XXXX} failed due to the following error: 80040154", typically indicates that the COM component you're trying to use is either not registered correctly or the application is running in a different architecture...
24,715
[ { "from": "human", "value": "I've been testing an application using my machine as a server, and everything's going fine with it, but when I try to set it up to run on the test server, I get this error:\n\nRetrieving the COM class factory for\n component with CLSID {XXXX} failed due\n to the following erro...
I've been asked to maintain a large C++ codebase full of memory leaks. While poking around, I found out that we have a lot of buffer overflows that lead to the leaks (how it got this bad, I don't ever want to know). I've decided to removing the buffer overflows first. To make my bug-hunting easier, what tools can be us...
Buffer overflows can be particularly tricky to identify and fix, but there are several tools and techniques you can use to help detect them in a C++ codebase. Here are some of the most effective tools: 1. **AddressSanitizer (ASan)**: - ASan is a fast memory error detector built into the Clang and GCC compilers. It ...
25,585
[ { "from": "human", "value": "I've been asked to maintain a large C++ codebase full of memory leaks. While poking around, I found out that we have a lot of buffer overflows that lead to the leaks (how it got this bad, I don't ever want to know).\nI've decided to removing the buffer overflows first. To make m...
Do any queries exist that require RIGHT JOIN, or can they always be re-written with LEFT JOIN? And more specifically, how do you re-write this one without the right join (and I guess implicitly without any subqueries or other fanciness): SELECT * FROM t1 LEFT JOIN t2 ON t1.k2 = t2.k2 RIGHT JOIN t3 ON t3.k3 = t2.k3
In SQL, while you can always rewrite a `RIGHT JOIN` using a `LEFT JOIN`, the syntax may look a bit different. The main difference between `LEFT JOIN` and `RIGHT JOIN` is the order in which the tables are joined and how null values are handled. A `LEFT JOIN` returns all records from the left table (the first table), and...
25,502
[ { "from": "human", "value": "Do any queries exist that require RIGHT JOIN, or can they always be re-written with LEFT JOIN?\nAnd more specifically, how do you re-write this one without the right join (and I guess implicitly without any subqueries or other fanciness):\n\nSELECT *\nFROM t1\nLEFT JOIN t2 ON t1...
I want to use Google spreadsheets to store data online so multiple people can enter and maintain data, then publish or export (csv, xls, ods) the sheet for their application. What is the easiest way to process the sheet? If the data can be accessed as a link the updates could be immediately reflected in the client's ap...
Using Google Sheets to store and manage data collaboratively is an excellent approach. Here's how you can set up and process your Google Sheets for multiple users while allowing for easy publishing or exporting: ### Setting Up Google Sheets for Collaboration 1. **Create a Google Sheet**: - Go to [Google Sheets](ht...
25,367
[ { "from": "human", "value": "I want to use Google spreadsheets to store data online so multiple people can enter and maintain data, then publish or export (csv, xls, ods) the sheet for their application. What is the easiest way to process the sheet? If the data can be accessed as a link the updates could be...
For the last couple of months I have been writing an intranet site for my college with lots of reports for staff about students. It is all going well but once a week (ish) I am having to go to IT get them to log into IIS stop the application pool, clear out the website folder, clear out the temporary asp.NET cache and ...
Updating an ASP.NET website deployed on IIS can be streamlined to allow for self-service deployments without requiring IT to assist each time. Here’s a breakdown of what you can do to update your website yourself, some options available for deployment, and how to keep the site live during updates. ### Deployment Optio...
18,643
[ { "from": "human", "value": "For the last couple of months I have been writing an intranet site for my college with lots of reports for staff about students. It is all going well but once a week (ish) I am having to go to IT get them to log into IIS stop the application pool, clear out the website folder, c...
How many bytes would an int contain and how many would a long contain in C++? Please provide some information about the 32-bit and the 64-bit computers, and the differences.
In C++, the size of `int` and `long` types can vary depending on the architecture of the system (32-bit vs. 64-bit) as well as the compiler being used. However, there are some general conventions that can be observed: ### 1. **Standard Sizes:** - **int**: Typically, on most platforms, an `int` is 4 bytes (32 bits). - ...
26,808
[ { "from": "human", "value": "How many bytes would an int contain and how many would a long contain in C++?\nPlease provide some information about the 32-bit and the 64-bit computers, and the differences.\n" }, { "from": "gpt", "value": "In C++, the size of `int` and `long` types can vary dependi...
The scenario: 2 user controls (foo.ascx and fum.ascx) foo has a method that would really like to access a property from fum. They live on the same page, but I can't find a very simple way to accomplish this sort of communication. Any ideas?
In ASP.NET Web Forms, user controls can interact with each other if they are placed on the same page. Here are a few methods you can use to access a property of one user control from another: ### Method 1: Expose Public Properties 1. **Expose the Property in fum.ascx.cs**: Make sure that the property you want to acce...
22,992
[ { "from": "human", "value": "The scenario: 2 user controls (foo.ascx and fum.ascx)\nfoo has a method that would really like to access a property from fum. They live on the same page, but I can't find a very simple way to accomplish this sort of communication. \nAny ideas?\n" }, { "from": "gpt", ...
Has anyone been able to create Container-Specific Master Pages for Safari or Chrome? I can't find any ".browser" files for either of these. How often is the %SystemRoot%\Microsoft.NET\Framework\version\CONFIG\Browsers directory updated? Thanks
Creating container-specific master pages or browser-specific styles in ASP.NET Web Forms is typically done using `.browser` files, which are XML files that allow you to define capabilities and settings for various browsers. However, there are a few points to consider regarding browser support and configuration: 1. **B...
24,718
[ { "from": "human", "value": "Has anyone been able to create Container-Specific Master Pages for Safari or Chrome?\nI can't find any \".browser\" files for either of these.\nHow often is the %SystemRoot%\\Microsoft.NET\\Framework\\version\\CONFIG\\Browsers directory updated?\nThanks\n" }, { "from": ...
How do I make sure the correct encoding (UTF-8) is used by Grails?
To ensure that your Grails application uses UTF-8 encoding, you should follow these steps: 1. **Set the JVM encoding**: You can specify the encoding for the JVM in the `GRAILS_OPTS` environment variable or directly in the `JAVA_OPTS`. Add the following line to your `grailsw` startup script or set it in your system env...
25,255
[ { "from": "human", "value": "How do I make sure the correct encoding (UTF-8) is used by Grails?\n" }, { "from": "gpt", "value": "To ensure that your Grails application uses UTF-8 encoding, you should follow these steps:\n\n1. **Set the JVM encoding**: You can specify the encoding for the JVM in ...
Is there an easy way to cancel a curl_easy_perform from another thread?
Yes, there is a way to cancel a `curl_easy_perform()` operation from another thread. To do this, you can use the `curl_easy_pause()` function, which allows you to pause or unpause a running transfer. Here is a general approach to achieving this: 1. **Initialize a CURL object**: First, create and set up your CURL handl...
24,041
[ { "from": "human", "value": "Is there an easy way to cancel a curl_easy_perform from another thread?\n" }, { "from": "gpt", "value": "Yes, there is a way to cancel a `curl_easy_perform()` operation from another thread. To do this, you can use the `curl_easy_pause()` function, which allows you to...
When are custom Exception classes most-valuable? Are there cases when they should or should not be used? What are the benefits? Related questions: Performace Considerations for throwing Exceptions Do you write exceptions for specific issues or general exceptions?
Custom exception classes can be extremely valuable in various scenarios, particularly when developing complex software systems. Here are some insights into when to use them, when not to use them, their benefits, and some performance considerations. ### When to Use Custom Exception Classes 1. **Specificity**: When an ...
21,329
[ { "from": "human", "value": "When are custom Exception classes most-valuable?\nAre there cases when they should or should not be used? What are the benefits?\nRelated questions:\n\nPerformace Considerations for throwing Exceptions\nDo you write exceptions for specific issues or general exceptions?\n\n" }...
On the site we are building. We need to be able to redirect the user to a default page when his session has ended. At first sight we used the Session_End with a Response.Redirect to do this job. Sub Session_End(ByVal sender As Object, ByVal e As EventArgs) Response.Redirect("~/global/exit.aspx") End Sub But it gen...
In ASP.NET, the `Session_End` event is executed on the server side when a session is abandoned or times out. However, it's important to note that the `Response` object is not available in this context because `Session_End` does not handle HTTP requests directly. To redirect users to a specific page when their session ...
24,767
[ { "from": "human", "value": "On the site we are building. We need to be able to redirect the user to a default page when his session has ended.\nAt first sight we used the Session_End with a Response.Redirect to do this job.\nSub Session_End(ByVal sender As Object, ByVal e As EventArgs)\n Response.Redire...
Is anyone familiar with this? Write a procedure that takes as inputs a procedure that computes f and a positive integer n and returns the procedure that computes the nth repeated application of f. The procedure should be able to be used as follows: ((repeated square 2) 5) 625 I know that the following co...
Certainly! You're trying to create a procedure that allows for repeated application of a function (in this case, `f`) a specified number of times (given by the positive integer `n`). This is often referred to as "function composition". The code snippet you provided for the `compose` function is a good start because it...
26,482
[ { "from": "human", "value": "Is anyone familiar with this?\n\nWrite a procedure that takes as inputs\n a procedure that computes f and a\n positive integer n and returns the\n procedure that computes the nth\n repeated application of f. The\n procedure should be able to be used as\n follows:\n((repeat...
Let's say I have a multithreaded C++ program that handles requests in the form of a function call to handleRequest(string key). Each call to handleRequest occurs in a separate thread, and there are an arbitrarily large number of possible values for key. I want the following behavior: Simultaneous calls to handleReques...
To implement the required behavior for the `KeyLock` class in a way that minimizes global serialization while still ensuring that simultaneous calls to `handleRequest(key)` are serialized for the same `key`, we can utilize a combination of thread-local storage and finer-grained locking mechanisms. This approach will re...
19,514
[ { "from": "human", "value": "Let's say I have a multithreaded C++ program that handles requests in the form of a function call to handleRequest(string key). Each call to handleRequest occurs in a separate thread, and there are an arbitrarily large number of possible values for key.\nI want the following beh...
What is the most efficient way to do this?
To provide the best answer, I need a bit more context about what task or process you're trying to accomplish. Are you looking for efficiency in a specific area, such as productivity, time management, project planning, programming, or something else? Please provide more details so I can assist you effectively!
30,685
[ { "from": "human", "value": "What is the most efficient way to do this?\n" }, { "from": "gpt", "value": "To provide the best answer, I need a bit more context about what task or process you're trying to accomplish. Are you looking for efficiency in a specific area, such as productivity, time man...
How do I find a stored procedure in a Sybase database given a text string that appears somewhere in the proc? I want to see if any other proc in the db has similar logic to the one I'm looking at, and I think I have a pretty unique search string (literal) Edit: I'm using Sybase version 11.2
In Sybase version 11.2, you can search for stored procedures (or other database objects) by querying the system tables to look for the presence of your specific text string within the definitions of those procedures. Here’s how you can do that: 1. **Identify the System Tables**: In Sybase, stored procedure definitions...
28,377
[ { "from": "human", "value": "How do I find a stored procedure in a Sybase database given a text string that appears somewhere in the proc? I want to see if any other proc in the db has similar logic to the one I'm looking at, and I think I have a pretty unique search string (literal)\nEdit:\nI'm using Sybas...
I've got a PHPUnit mock object that returns 'return value' no matter what its arguments: // From inside a test... $mock = $this->getMock('myObject', 'methodToMock'); $mock->expects($this->any)) ->method('methodToMock') ->will($this->returnValue('return value')); What I want to be able to do is return a diffe...
In PHPUnit, you can achieve different return values based on the arguments passed to a mocked method by using a combination of the `with()` method and `will()` method with a custom callback. Here's how you can do it: 1. Use the `with()` method to define the expected arguments. 2. Use a closure with the `will()` meth...
29,748
[ { "from": "human", "value": "I've got a PHPUnit mock object that returns 'return value' no matter what its arguments:\n// From inside a test...\n$mock = $this->getMock('myObject', 'methodToMock');\n$mock->expects($this->any))\n ->method('methodToMock')\n ->will($this->returnValue('return value'));\n...
I'm hoping this question isn't too obscure cross fingers I'm looking for a decent reference for netsuite scripting and api (both of which are based on ASP) does anybody know where to find this stuff? The netsuite help pages are mediocre at best, and the forums aren't very active. (I suppose these two things are already...
You're in luck—while NetSuite's documentation can sometimes be a bit challenging to navigate, there are still several resources you can utilize to learn more about NetSuite scripting (SuiteScript) and its API. 1. **NetSuite Help Center**: Although you mentioned that you find the help pages mediocre, they are still the...
26,003
[ { "from": "human", "value": "I'm hoping this question isn't too obscure cross fingers\nI'm looking for a decent reference for netsuite scripting and api (both of which are based on ASP)\ndoes anybody know where to find this stuff? The netsuite help pages are mediocre at best, and the forums aren't very acti...
I need to grant select permission for all tables owned by a specific user to another user. Can I do this with a single command along the lines of: Grant Select on OwningUser.* to ReceivingUser Or do I have to generate the sql for each table with something along the lines of: Select 'GRANT SELECT ON OwningUser.'||Tab...
In standard SQL, there is no single command that allows you to grant privileges on all tables owned by a specific user directly using a wildcard or similar syntax like `GRANT SELECT ON OwningUser.* TO ReceivingUser`. Instead, you will need to generate individual GRANT statements for each table that the owner has. You ...
28,118
[ { "from": "human", "value": "I need to grant select permission for all tables owned by a specific user to another user. Can I do this with a single command along the lines of:\nGrant Select on OwningUser.* to ReceivingUser\n\nOr do I have to generate the sql for each table with something along the lines of...
Edit: I am using SqlDataAdapters to fill the data sets. Sorry--I should have been more clear. I'm working on a project where I need to fill a number of strongly-typed data sets with information from stored procedures. Right now, I have a generic method in my data access layer: public static DataSet FillDataSet(DataSet ...
Both of the approaches you've proposed for handling the mapping of stored procedure results to strongly-typed DataSets have their pros and cons. Here are some thoughts on each approach, as well as an alternative approach you might consider: ### 1. Adding Mappings as a Parameter **Pros:** - Straightforward to implement...
24,461
[ { "from": "human", "value": "Edit: I am using SqlDataAdapters to fill the data sets. Sorry--I should have been more clear.\nI'm working on a project where I need to fill a number of strongly-typed data sets with information from stored procedures. Right now, I have a generic method in my data access layer:\...
I am working on a .NET application that displays multiple charts. My users would like an easy way to say "take chart #3 and maximize it on my fourth monitor". How can I determine the number of monitors so I can give them a selection of "monitor #1, monitor #2, etc"? (Not every user has the same number of monitors.) A...
To work with multiple monitors in a .NET application, you can utilize the `System.Windows.Forms.Screen` class, which provides the necessary information about the monitors connected to the system. Below, I will explain how to determine the number of monitors, present the user with a selection, and position a form (to di...
24,974
[ { "from": "human", "value": "I am working on a .NET application that displays multiple charts. My users would like an easy way to say \"take chart #3 and maximize it on my fourth monitor\".\nHow can I determine the number of monitors so I can give them a selection of \"monitor #1, monitor #2, etc\"? (Not ...
I need to do some work with a backup WSS .dat file and I'm having real trouble making it do anything. I've got it installed through stsadm and that appears to have gone smoothly, but the site now redirects me to an error page - just the classic "File Not Found" one, but in the URL it suggests the errortext would be "Cl...
It sounds like you're encountering a common issue when restoring a SharePoint site, especially when working with backup files (.dat) and trying to configure the site after restoration. The "Class not registered" error often indicates that there is a problem with the underlying components or features of SharePoint that ...
23,655
[ { "from": "human", "value": "I need to do some work with a backup WSS .dat file and I'm having real trouble making it do anything.\nI've got it installed through stsadm and that appears to have gone smoothly, but the site now redirects me to an error page - just the classic \"File Not Found\" one, but in th...
Is there a name meaning "not a singleton"?
There isn't a specific name that means "not a singleton" in a widely recognized or traditional sense. However, the term "singleton" refers to something that is single or unique. To convey the opposite idea, you might consider names that imply plurality or community, such as: - **Althea**: Meaning "healer" or "wholesom...
28,879
[ { "from": "human", "value": "Is there a name meaning \"not a singleton\"?\n" }, { "from": "gpt", "value": "There isn't a specific name that means \"not a singleton\" in a widely recognized or traditional sense. However, the term \"singleton\" refers to something that is single or unique. To conv...
We're developing a service that will accept a POST request. Some of the POST data will need to be encrypted before the POST as it will be stored in hidden fields on a form. The application is written in C#, but we want third party clients to be able to easily integrate with it. We find that most clients use PHP, Classi...
When developing a service that requires encryption for POST data, it's important to choose an encryption algorithm and parameters that are widely supported and easy to implement in various programming languages. Here's a suggested approach for compatibility with PHP, Classic ASP, and VB.Net clients: ### Recommended En...
10,614
[ { "from": "human", "value": "We're developing a service that will accept a POST request. Some of the POST data will need to be encrypted before the POST as it will be stored in hidden fields on a form.\nThe application is written in C#, but we want third party clients to be able to easily integrate with it....
What is the simplest (shortest, fewest rules, and no warnings) way to parse both valid dates and numbers in the same grammar? My problem is that a lexer rule to match a valid month (1-12) will match any occurrence of 1-12. So if I just want to match a number, I need a parse rule like: number: (MONTH|INT); It only gets...
To achieve a grammar that can parse both valid dates and general numbers without conflicts, you can utilize a more specific approach with your lexer rules. The key is to define your lexer rules in such a way that they only match what you expect, thus avoiding ambiguous matches. You can achieve this with a combination o...
21,761
[ { "from": "human", "value": "What is the simplest (shortest, fewest rules, and no warnings) way to parse both valid dates and numbers in the same grammar? My problem is that a lexer rule to match a valid month (1-12) will match any occurrence of 1-12. So if I just want to match a number, I need a parse rule...
In ASP.NET what's the best way to do the following: Show certain controls based on your rights? For a gridview control, how do you show certain columns based on your role? I'm thinking for number 2, have the data come from a role specific view on the database.
In ASP.NET, managing user rights and displaying controls or data based on user roles is a common requirement. Here's a general approach to accomplish both tasks you mentioned: ### 1. Showing Certain Controls Based on User Rights You can manage the visibility of controls based on user roles or rights by using the `Use...
22,512
[ { "from": "human", "value": "In ASP.NET what's the best way to do the following:\n\nShow certain controls based on your rights?\nFor a gridview control, how do you show certain columns based on your role?\n\nI'm thinking for number 2, have the data come from a role specific view on the database.\n" }, {...
I have a package that I just made and I have an "old-mode" that basically makes it work like it worked before: importing everything into the current namespace. One of the nice things about having this as a package is that we no longer have to do that. Anyway, what I would like to do is have it so that whenever anyone...
You can achieve this by customizing the import behavior of your package in Perl. To issue a warning when someone uses the `:oldmode` import tag, you can define the `import` method in your package. Here's a simple example that demonstrates how to implement this functionality: ```perl package Foo; use strict; use warni...
24,594
[ { "from": "human", "value": "I have a package that I just made and I have an \"old-mode\" that basically makes it work like it worked before: importing everything into the current namespace. One of the nice things about having this as a package is that we no longer have to do that. Anyway, what I would li...
What is the fastest list implementation (in java) in a scenario where the list will be created one element at a time then at a later point be read one element at a time? The reads will be done with an iterator and then the list will then be destroyed. I know that the Big O notation for get is O(1) and add is O(1) for a...
In Java, when you're choosing a list implementation for the scenario you've described—where you create the list one element at a time and later iterate through it for reading—the choice between `ArrayList` and `LinkedList` can be informed by the Big O notation and the characteristics of each data structure. ### Big O ...
25,716
[ { "from": "human", "value": "What is the fastest list implementation (in java) in a scenario where the list will be created one element at a time then at a later point be read one element at a time? The reads will be done with an iterator and then the list will then be destroyed.\nI know that the Big O nota...
I want to use remote debugging. The program that I want to debug runs on machine b. Visual Studio runs on machine a. On machine b I have a folder with the following files: msvcr72.dll msvsmon.exe NatDbgDE.dll NatDbgDEUI.dll NatDbgEE.dll NatDbgEEUI.dll If you think some files are missing, could you also describe wher...
It looks like you're trying to set up remote debugging for a program running on a different machine (Machine B) using Visual Studio 2008 on your local machine (Machine A). The steps you're taking and the issues you're encountering suggest a couple of potential problems. ### Files Needed for Remote Debugging The files ...
20,038
[ { "from": "human", "value": "I want to use remote debugging.\nThe program that I want to debug runs on machine b.\nVisual Studio runs on machine a. \nOn machine b I have a folder with the following files:\n\nmsvcr72.dll\nmsvsmon.exe\nNatDbgDE.dll\nNatDbgDEUI.dll\nNatDbgEE.dll\nNatDbgEEUI.dll\n\nIf you think...
I am trying to insert a time only value, but get the following error ex {"SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM."} System.Exception From the front end, the time is selected using the "TimeEdit" control, with the up and down arrows. The table in SQL Server has the fi...
It sounds like you've encountered a common issue when working with SQL Server's `smalldatetime` data type. The `smalldatetime` type expects a complete date and time value, which is why you're getting the overflow error when trying to insert only a time. To resolve this issue and pass a time-only value into a `smalldat...
24,911
[ { "from": "human", "value": "I am trying to insert a time only value, but get the following error\n\n\nex {\"SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.\"} System.Exception\n\n\nFrom the front end, the time is selected using the \"TimeEdit\" control, with the up ...
I'm using a RichTextBox (.NET WinForms 3.5) and would like to override some of the standard ShortCut keys.... For example, I don't want Ctrl+I to make the text italic via the RichText method, but to instead run my own method for processing the text. Any ideas?
To override the default shortcut keys in a `RichTextBox` in a WinForms application, you can handle the `KeyDown` event of the `RichTextBox`. By checking for specific key combinations like `Ctrl + I`, you can prevent the default behavior and execute your custom logic instead. Here’s how you can implement this: 1. Firs...
27,682
[ { "from": "human", "value": "I'm using a RichTextBox (.NET WinForms 3.5) and would like to override some of the standard ShortCut keys....\nFor example, I don't want Ctrl+I to make the text italic via the RichText method, but to instead run my own method for processing the text.\nAny ideas?\n" }, { ...
I'm trying to find an efficient C++ interval tree implementation (mostly likely based on red black trees) without a viral or restrictive license. Any pointers to a clean lightweight standalone implementation? For the use case I have in mind, the set of intervals is known at the outset (there would be say a million) and...
For your use case, since you have a fixed set of intervals that won't change after the initial build, an efficient approach would be to build an interval tree from the intervals and then perform fast queries on it. Below are a few clean and lightweight implementations that you might find helpful: ### 1. **Boost Interv...
20,770
[ { "from": "human", "value": "I'm trying to find an efficient C++ interval tree implementation (mostly likely based on red black trees) without a viral or restrictive license. Any pointers to a clean lightweight standalone implementation? For the use case I have in mind, the set of intervals is known at the ...
I am rendering a rails partial and I want to alternate the background color when it renders the partial. I know that is not super clear so here is an example of what I want to do: Row One grey Background Row Two yellow background Row Three grey Background Row Four yellow background sorry stackoverflow sea...
Yes, you can alternate the background colors of the rows by using a conditional statement in your partial or by passing an additional variable to the partial that indicates whether the row is even or odd. Here are two approaches you can take to achieve this: ### Approach 1: Conditional Logic in the Partial You can a...
27,999
[ { "from": "human", "value": "I am rendering a rails partial and I want to alternate the background color when it renders the partial. I know that is not super clear so here is an example of what I want to do:\n\n\n\nRow One grey Background\n\n\nRow Two yellow background\n\n\nRow Three grey Background\n\n\n...
How do I properly convert two columns from SQL (2008) using Linq into a Dictionary (for caching)? I currently loop through the IQueryable b/c I can't get the ToDictionary method to work. Any ideas? This works: var query = from p in db.Table select p; Dictionary<string, string> dic = new Dictionary<string, ...
To convert two columns from an SQL query into a `Dictionary<TKey, TValue>` using LINQ, you need to ensure that you're selecting the appropriate types and structure for the dictionary. It looks like you are on the right track, but there are a couple of adjustments needed to correctly create the dictionary. Here's a rev...
26,044
[ { "from": "human", "value": "How do I properly convert two columns from SQL (2008) using Linq into a Dictionary (for caching)?\nI currently loop through the IQueryable b/c I can't get the ToDictionary method to work. Any ideas?\nThis works:\nvar query = from p in db.Table\n select p;\n\nDictionar...
Possible Duplicate: What is the correct way to create a single instance application? How to force C# .net app to run only one instance in Windows?
To ensure that your C# .NET application runs as a single instance on Windows, you can use a few different approaches. One of the most common methods involves using a `Mutex`. Below is an example of how to implement this: ### Step-by-Step Implementation 1. **Create a Mutex**: In your `Main` method, create a named mute...
21,625
[ { "from": "human", "value": "\nPossible Duplicate:\nWhat is the correct way to create a single instance application? \n\nHow to force C# .net app to run only one instance in Windows?\n" }, { "from": "gpt", "value": "To ensure that your C# .NET application runs as a single instance on Windows, yo...
I have a request to display VRML models within a .NET application. Does someone know an easy way, maybe with standard .NET components, to achieve this? What are the issues I maybe have to face when representing VRML within an application?
Displaying VRML (Virtual Reality Modeling Language) models within a .NET application can be a challenge, as there are no standard .NET components specifically designed for rendering VRML directly. However, there are some options you can consider to integrate VRML rendering into your .NET application. ### Options for D...
20,447
[ { "from": "human", "value": "I have a request to display VRML models within a .NET application. Does someone know an easy way, maybe with standard .NET components, to achieve this? What are the issues I maybe have to face when representing VRML within an application?\n" }, { "from": "gpt", "valu...
I can't find much information around the web about it. Has anyone used both eConnect and the Dynamics web services to interact (read/write) with Great Plains. I am looking for the pros and cons of both approaches. This product will be installed and configured on various sites, so ease of configuration is really importa...
When deciding between eConnect and Dynamics Web Services for interacting with Microsoft Dynamics GP (formerly Great Plains), it's important to evaluate the pros and cons of each approach based on your specific needs and constraints. Below, I outline the benefits and drawbacks of both methods, considering your requireme...
22,219
[ { "from": "human", "value": "I can't find much information around the web about it. Has anyone used both eConnect and the Dynamics web services to interact (read/write) with Great Plains. I am looking for the pros and cons of both approaches.\nThis product will be installed and configured on various sites, ...
Consider the class below that represents a Broker: public class Broker { public string Name = string.Empty; public int Weight = 0; public Broker(string n, int w) { this.Name = n; this.Weight = w; } } I'd like to randomly select a Broker from an array, taking into account their weig...
The code you provided is almost correct for selecting a broker based on weights, but there is an issue in the logic within the `GetBroker` method that leads to incorrect behavior when the weights are being evaluated. ### Key Issue: The issue arises in how the random number is compared with the broker's weight. In your...
19,450
[ { "from": "human", "value": "Consider the class below that represents a Broker:\npublic class Broker\n{\n public string Name = string.Empty;\n public int Weight = 0;\n\n public Broker(string n, int w)\n {\n this.Name = n;\n this.Weight = w;\n }\n}\n\nI'd like to randomly select ...
I don't see any obvious way to import ICS files into Google Calendar from the API docs here: http://code.google.com/apis/calendar/developers_guide_protocol.html And I'd greatly prefer not to have to parse them myself just to send the appointments into GCal. I'm looking for a programmatic solution, not something like i...
To import ICS files into Google Calendar programmatically, you'll typically need to parse the ICS files yourself or use a library that can handle the parsing for you, since Google Calendar API does not support direct ICS file uploads. Here's a general approach you can take: 1. **Parse the ICS File**: Use an existing ...
25,686
[ { "from": "human", "value": "I don't see any obvious way to import ICS files into Google Calendar from the API docs here:\nhttp://code.google.com/apis/calendar/developers_guide_protocol.html\nAnd I'd greatly prefer not to have to parse them myself just to send the appointments into GCal. I'm looking for a ...
What does this option do? It is accessible from the Build menu.
Could you please specify which option you are referring to in the Build menu? Different software applications may have various options under their Build menu, each serving a distinct purpose. If you can provide more context or the name of the specific option, I'd be happy to help explain what it does!
30,678
[ { "from": "human", "value": "What does this option do? It is accessible from the Build menu.\n" }, { "from": "gpt", "value": "Could you please specify which option you are referring to in the Build menu? Different software applications may have various options under their Build menu, each servin...
I'm using the latest version of the jQuery UI tabs. I have tabs positioned toward the bottom of the page. Every time I click a tab, the screen jumps toward the top. How can I prevent this from happening? Please see this example: http://5bosses.com/examples/tabs/sample_tabs.html
When using jQuery UI tabs and experiencing a screen jump when clicking a tab, it is usually related to the default behavior of anchor tags (`<a>` elements). By default, when you click on an anchor link (which tabs use), the browser attempts to scroll the page to the anchor's target. To prevent this jumping behavior, ...
24,758
[ { "from": "human", "value": "I'm using the latest version of the jQuery UI tabs. I have tabs positioned toward the bottom of the page. \nEvery time I click a tab, the screen jumps toward the top.\nHow can I prevent this from happening?\nPlease see this example:\nhttp://5bosses.com/examples/tabs/sample_tabs....
I'm in the process of trying to hack together the first bits of a kernel. I currently have the entire kernel compiled down as C code, and I've managed to get it displaying text in the console window and all of that fine goodness. Now, I want to start accepting keyboard input so I can actually make some use of the thing...
You're correct that if you're booting with GRUB, you're likely running in protected mode rather than real mode. In this context, you can't directly call BIOS interrupts like `int $0x16` because those interrupts are only available in real mode. To read keyboard input in protected mode, you'll generally want to utilize...
22,808
[ { "from": "human", "value": "I'm in the process of trying to hack together the first bits of a kernel. I currently have the entire kernel compiled down as C code, and I've managed to get it displaying text in the console window and all of that fine goodness. Now, I want to start accepting keyboard input so ...
<div> <span>left</span> <span>right</span> <!-- new line break, so no more content on that line --> <table> ... </table> </div> How can I position those spans (they can be changed to any element) so that depending on how big the table is (not defined anywhere, and shouldn't be) the spans are positioned just on top of...
To position the spans (or any other elements) on the left and right sides of the table dynamically, you can use CSS with a combination of `position: relative` for the parent container and `position: absolute` for the spans. Here's how to do it: ```html <div class="table-container"> <span class="left">a</span> <spa...
25,865
[ { "from": "human", "value": "<div>\n<span>left</span>\n<span>right</span>\n<!-- new line break, so no more content on that line -->\n<table> \n...\n</table>\n</div>\n\nHow can I position those spans (they can be changed to any element) so that depending on how big the table is (not defined anywhere, and sho...
Is it possible to search for an object by one of its properties in a Generic List? Public Class Customer Private _id As Integer Private _name As String Public Property ID() As Integer Get Return _id End Get Set _id = value End Set End Property ...
Yes, you can search for an object by one of its properties in a Generic List in VB.NET. The `List(Of T)` class provides a method called `Find`, which allows you to search for an item based on a predicate. The predicate is a function that defines the conditions of the object you want to find. In your case, you want to ...
24,730
[ { "from": "human", "value": "Is it possible to search for an object by one of its properties in a Generic List?\nPublic Class Customer\n\n Private _id As Integer\n\n Private _name As String\n\n Public Property ID() As Integer\n Get\n Return _id\n End Get\n Set\n ...
Imagine a WinForms client app that displays fairly complex calculated data fetched from a server app with .Net Remoting over a HTTPChannel. Since the client app might be running for a whole workday, I need a method to notify the client that new data is available so the user is able to start a reload of the data when he...
To implement a notification mechanism for your WinForms client application in a .NET 2.0 environment, while keeping your requirements in mind, here are several approaches you can consider: ### 1. Using Windows Communication Foundation (WCF) with .NET Remoting Although WCF is not directly available in .NET 2.0, you can...
24,233
[ { "from": "human", "value": "Imagine a WinForms client app that displays fairly complex calculated data fetched from a server app with .Net Remoting over a HTTPChannel.\nSince the client app might be running for a whole workday, I need a method to notify the client that new data is available so the user is ...
I'm developing in an environment that is severely constrained, but the developers also have tight control over. VCRedist_x86.exe - A 4Mb redistributable - is no fun (four hours to transfer). I'd really prefer to just redistribute MFC90.dll, msvcm90.dll, msvcp90.dll and msvcr90.dll - that's more like 2Mb. However, R...
Distributing Visual C++ runtime libraries in a constrained environment can be challenging due to the dependency on manifests and the use of the Side-by-Side (WinSxS) assembly. Here are a few approaches to consider that could potentially minimize the overhead while adhering to Microsoft’s guidelines: ### 1. Use Manifes...
23,139
[ { "from": "human", "value": "I'm developing in an environment that is severely constrained, but the developers also have tight control over. \nVCRedist_x86.exe - A 4Mb redistributable - is no fun (four hours to transfer). I'd really prefer to just redistribute MFC90.dll, msvcm90.dll, msvcp90.dll and msvcr...
How do I determine the dependencies of a .NET application? Does Dependency Walker work with managed apps? I've downloaded the latest and tried profiling the app, but it just exits without much of an explanation. If it doesn't work with .NET, then is there some other tool that would help me debug a run-time DLL loading ...
To determine the dependencies of a .NET application, you have a few different approaches and tools at your disposal. Dependency Walker is primarily designed for native applications and may not accurately analyze managed (.NET) applications, which is likely why you faced issues when trying to profile your app. ### Reco...
25,684
[ { "from": "human", "value": "How do I determine the dependencies of a .NET application? Does Dependency Walker work with managed apps? I've downloaded the latest and tried profiling the app, but it just exits without much of an explanation. If it doesn't work with .NET, then is there some other tool that wo...
i have a function in CPP with the following prototype: char* complexFunction(char* arg1, ...); i import it from a C# using DLLImport attribute. the questions are: how do i define the prototype in the C# (under the DLLImport attribute)? how do i pass the arguments to this function? thanks
To use a C++ function with a variable argument list (like `complexFunction(char* arg1, ...)`) in C#, you need to take a few things into consideration. ### 1. Defining the Prototype in C# When you define the function in C# using the `DllImport` attribute, you'll need to specify the correct parameters. Since C# doesn't...
24,685
[ { "from": "human", "value": "i have a function in CPP with the following prototype:\nchar* complexFunction(char* arg1, ...);\n\ni import it from a C# using DLLImport attribute.\nthe questions are: \nhow do i define the prototype in the C# (under the DLLImport attribute)?\nhow do i pass the arguments to this...
I found in MYSQL and apparently other database engines that there is a "greatest" function that can be used like: greatest(1, 2, 3, 4), and it would return 4. I need this, but I am using IBM's DB2. Does anybody know of such an equivalent function, even if it only accepts 2 parameters? I found somewhere that MAX shoul...
In IBM DB2, there is no built-in `GREATEST` function like in some other database systems. However, you can achieve similar functionality using a combination of SQL expressions. While there isn't a direct `GREATEST` equivalent that accepts multiple parameters, you can create your own stored procedure or use a simple SQL...
24,082
[ { "from": "human", "value": "I found in MYSQL and apparently other database engines that there is a \"greatest\" function that can be used like: greatest(1, 2, 3, 4), and it would return 4. I need this, but I am using IBM's DB2. Does anybody know of such an equivalent function, even if it only accepts 2 p...
Say you have a bunch of files. Say you can store meta data to these files. Say, one of these meta attributes were called "encryption" Say everyone was allowed to look at these files, but since they are encrypted, only people who know how to decrypt them can actually read the contents. Say, for every given value of "enc...
Your proposed Document Management System (DMS) presents interesting challenges when it comes to encryption and access control, especially in a distributed P2P network context. Here are some recommendations and considerations based on your questions and concerns: ### Encryption Values 1. **Encryption Types**: You migh...
22,978
[ { "from": "human", "value": "Say you have a bunch of files.\nSay you can store meta data to these files.\nSay, one of these meta attributes were called \"encryption\"\nSay everyone was allowed to look at these files, but since they are encrypted, only people who know how to decrypt them can actually read th...
Is it possible to use a variable from one page in a piece of code on another? e.g. submit a form on one page and on the second page use a PHP script to add the data from the form to a MySQL table Thanks for all the help
Yes, it is definitely possible to use a variable from one page in a piece of code on another page when working with PHP. This is commonly done when submitting forms. Here's a general approach to achieving this: ### Step 1: Create the Form (Page 1) On your first page, create an HTML form that collects the data you wan...
24,885
[ { "from": "human", "value": "Is it possible to use a variable from one page in a piece of code on another? e.g. submit a form on one page and on the second page use a PHP script to add the data from the form to a MySQL table\nThanks for all the help \n" }, { "from": "gpt", "value": "Yes, it is d...
Can anybody explain the idea behind JSP custom tag libraries and the JSP 2 tag files? Are they just different ways to do the same thing? How do they compare? What are their pros and cons, and which is better?
JavaServer Pages (JSP) allow developers to create dynamic web content using Java. Custom tag libraries and tag files are two distinct concepts in JSP that provide ways to encapsulate and reuse code, but they differ in implementation and usage. Let's explore both: ### JSP Custom Tag Libraries **Definition:** Custom ta...
22,470
[ { "from": "human", "value": "Can anybody explain the idea behind JSP custom tag libraries and the JSP 2 tag files?\nAre they just different ways to do the same thing?\nHow do they compare? What are their pros and cons, and which is better?\n" }, { "from": "gpt", "value": "JavaServer Pages (JSP) ...
The Situation I have an area of the screen that can be shown and hidden via JavaScript (something like "show/hide advanced search options"). Inside this area there are form elements (select, checkbox, etc). For users using assistive technology like a screen-reader (in this case JAWS), we need to link these form element...
Your situation is quite common in web development, particularly when considering accessibility and the need for a good user experience for both assistive technology users and non-assistive technology users. The behavior you're experiencing with JAWS is related to how screen readers interpret hidden elements and their a...
24,760
[ { "from": "human", "value": "The Situation\nI have an area of the screen that can be shown and hidden via JavaScript (something like \"show/hide advanced search options\"). Inside this area there are form elements (select, checkbox, etc). For users using assistive technology like a screen-reader (in this ca...
If I change the url in the web.config file will the change be reflected in the .disco, .discomap, and .wsdl files that are in the WebReferences folder? [Edit] I'm using asp.net 2005
In ASP.NET 2005, the `.disco`, `.discomap`, and `.wsdl` files in the Web References folder are primarily generated during the process of adding a web reference to your project. These files contain metadata about the web services and their endpoints. If you change the URL in the `web.config` file for a web service refe...
29,125
[ { "from": "human", "value": "If I change the url in the web.config file will the change be reflected in the .disco, .discomap, and .wsdl files that are in the WebReferences folder?\n[Edit]\nI'm using asp.net 2005\n" }, { "from": "gpt", "value": "In ASP.NET 2005, the `.disco`, `.discomap`, and `....
In a SQL-database I make some selects, that get an duration (as result of a subtraction between two dates) in seconds as an int. But I want to format this result in a human-readable form like 'hh:mm' or 'dd:hh'. Is that possible in SQL and how can I realize this?
Yes, you can format durations in a human-readable form in SQL. The method to achieve this depends on the SQL database system you are using. Below are examples for some popular databases: ### 1. PostgreSQL If you are working with PostgreSQL, you can use the following query to convert seconds to `hh:mm` format: ```sql...
19,308
[ { "from": "human", "value": "In a SQL-database I make some selects, that get an duration (as result of a subtraction between two dates) in seconds as an int. But I want to format this result in a human-readable form like 'hh:mm' or 'dd:hh'. Is that possible in SQL and how can I realize this?\n" }, { ...
pdb files contain symbol information for .NET assemblies. I'd like to read a pdb file in order to correlate methods with their file location. The data is contained within it but I can't seem to find a good description of how to get it out. I know about mdbg, but that is very heavy (I think/hope) for what I want.
Reading PDB (Program Database) files to extract information about .NET methods and their associated file locations can be done using various tools and libraries. If you're looking for a lighter solution than `mdbg`, you can consider using the following options: ### 1. **Using `System.Diagnostics.SymbolStore` Namespace...
23,795
[ { "from": "human", "value": "pdb files contain symbol information for .NET assemblies. I'd like to read a pdb file in order to correlate methods with their file location. The data is contained within it but I can't seem to find a good description of how to get it out.\nI know about mdbg, but that is very he...
Is there a SQL or PHP script that I can run that will change the default collation in all tables and fields in a database? I can write one myself, but I think that this should be something that readily available at a site like this. If I can come up with one myself before somebody posts one, I will post it myself.
Changing the default collation for all tables and fields in a MySQL database can be done using SQL queries. Below is a SQL script that will change the default collation for all tables and their respective columns in a specified database. You will need to run it in a MySQL environment. ### Step 1: Change Database Defau...
12,917
[ { "from": "human", "value": "Is there a SQL or PHP script that I can run that will change the default collation in all tables and fields in a database?\nI can write one myself, but I think that this should be something that readily available at a site like this. If I can come up with one myself before someb...
We all know that deadlines and/or critical bugfixes and make us forget a bit about source formatting guidelines. Or sometimes you need to work with 3rd party source code which seems to have been coded by someone who doesn't know the meaning of whitespace and readability. What is your favorite tool to tabulate your code...
When it comes to formatting code and ensuring consistency with source formatting guidelines, there are several tools that developers commonly use. Here are a few of my favorites: 1. **Prettier**: This is a popular code formatter that supports many languages, including JavaScript, TypeScript, HTML, CSS, and more. Prett...
26,614
[ { "from": "human", "value": "We all know that deadlines and/or critical bugfixes and make us forget a bit about source formatting guidelines. Or sometimes you need to work with 3rd party source code which seems to have been coded by someone who doesn't know the meaning of whitespace and readability. What is...
There's something I want to customize in the System.Web.Script.Services.ScriptHandlerFactory and other .NET stuff inside an internal class. Unfortunately, it's an internal class. What options do I have when trying to customize a method in this class?
Customizing or modifying behavior in an internal class of the .NET Framework, such as `System.Web.Script.Services.ScriptHandlerFactory`, can be challenging since these classes are not designed for extension or public access. However, there are several options you might consider: ### 1. **Wrapper or Adapter Pattern**: ...
25,882
[ { "from": "human", "value": "There's something I want to customize in the System.Web.Script.Services.ScriptHandlerFactory and other .NET stuff inside an internal class. Unfortunately, it's an internal class. What options do I have when trying to customize a method in this class?\n" }, { "from": "g...
I am working on C++ and COM/ATL in Windows from last few years. Now I want to shift to Linux Programming. I know basic architecture of Linux. I did some of the projects which are using ncurses, sockets and audio libraries(Terminal Applications). On which tool I should be familiar to start with projects. In windows I ha...
Transitioning to Linux programming from a Windows background is a great move, as you'll encounter different paradigms, tools, and libraries. Given your experience with C++ and some Linux projects, you're already on the right path. Here are the steps you can follow to get deeper into Linux programming: ### 1. **Underst...
21,208
[ { "from": "human", "value": "I am working on C++ and COM/ATL in Windows from last few years. Now I want to shift to Linux Programming. I know basic architecture of Linux. I did some of the projects which are using ncurses, sockets and audio libraries(Terminal Applications). On which tool I should be familia...
On an embedded target I use far pointers to access some parts of the memory map. near pointer (without explicitely specifying __near): unsigned int *VariableOnePtr; Pointer to near pointer: unsigned int **VariableOnePtrPtr; far pointer: unsigned int *__far VariableTwoPtr; What is the correct way to declare a pointer ...
In embedded systems, particularly when working with segmented memory models, far pointers allow you to access memory outside the default segment. When you declare a far pointer and need a pointer to that far pointer, it's important to remember how far pointers are defined in your specific environment. Here’s how you c...
26,041
[ { "from": "human", "value": "On an embedded target I use far pointers to access some parts of the memory map. \nnear pointer (without explicitely specifying __near):\nunsigned int *VariableOnePtr;\nPointer to near pointer: unsigned int **VariableOnePtrPtr;\nfar pointer: unsigned int *__far VariableTwoPtr; \...
I need to create a photo gallery service that is managed by users. I've done this a million times using just Asp.net but I was wondering if there are any special considerations that I need to make when using Asp.net MVC. Basically, I will be storing the actual images on the filesystem and storing the locations in a dat...
You're on the right track with your approach to creating a photo gallery service using ASP.NET MVC. Below are some considerations and recommendations for implementing your photo gallery while addressing security and access control: ### 1. **Image Storage** Storing images on the filesystem and saving their paths in the...
21,873
[ { "from": "human", "value": "I need to create a photo gallery service that is managed by users. I've done this a million times using just Asp.net but I was wondering if there are any special considerations that I need to make when using Asp.net MVC.\nBasically, I will be storing the actual images on the fil...
I set up all my certificates and keys today and am trying to run my project on my iPhone. I'm encountering this strange error: Your mobile device has encountered an unexpected error (0xE800003A) during the install phase: Verifying application Poking around the Apple Developer forums, I've attempted to set new certifi...
The error code `0xE800003A` typically indicates an issue with signing or provisioning when trying to install an app on an iOS device. Here are several steps and considerations that may help you resolve this issue: 1. **Check Bundle Identifier**: Ensure that the bundle identifier in your Xcode project matches exactly w...
25,397
[ { "from": "human", "value": "I set up all my certificates and keys today and am trying to run my project on my iPhone.\nI'm encountering this strange error:\n\nYour mobile device has encountered an unexpected error (0xE800003A) during the install phase: Verifying application\n\nPoking around the Apple Devel...
I like using WCF callbacks when I can because to me it is better than the client having to poll the server and its more real time than polling. The question I have is when I subscribe to a WCF service event is there any kind of heart beat that keeps the connection alive between the client and the server. I starting to ...
You're correct in observing that WCF (Windows Communication Foundation) callbacks can provide a more real-time approach compared to polling; however, maintaining a stable connection and handling issues like disconnects is indeed a critical aspect of using WCF with callbacks. 1. **Heartbeat Mechanism**: By default, WCF...
25,444
[ { "from": "human", "value": "I like using WCF callbacks when I can because to me it is better than the client having to poll the server and its more real time than polling. The question I have is when I subscribe to a WCF service event is there any kind of heart beat that keeps the connection alive between ...
It is typical to have something like this in your cshrc file for setting the path: set path = ( . $otherpath $path ) but, the path gets duplicated when you source your cshrc file multiple times, how do you prevent the duplication? EDIT: This is one unclean way of doing it: set localpaths = ( . $otherpaths ) echo ${pat...
To prevent the duplication of paths in your `cshrc` file when setting the `path` variable, you can use a slightly cleaner approach. Instead of using `egrep` to check for existing paths, you can utilize an associative array to keep track of which paths have already been added. Here's how you can do it: ```csh setlocal ...
26,707
[ { "from": "human", "value": "It is typical to have something like this in your cshrc file for setting the path:\nset path = ( . $otherpath $path )\n\nbut, the path gets duplicated when you source your cshrc file multiple times, how do you prevent the duplication?\nEDIT: This is one unclean way of doing it:\...
Is there any class in the .NET framework that can read/write standard .ini files: [Section] <keyname>=<value> ... Delphi has the TIniFile component and I want to know if there is anything similar for C#?
In the .NET framework, there isn't a built-in class specifically designed for reading and writing INI files like Delphi's `TIniFile`. However, you can easily implement your own INI file reader/writer using classes available in the framework. Alternatively, you can use some third-party libraries that provide similar fun...
23,620
[ { "from": "human", "value": "Is there any class in the .NET framework that can read/write standard .ini files:\n[Section]\n<keyname>=<value>\n...\n\nDelphi has the TIniFile component and I want to know if there is anything similar for C#? \n" }, { "from": "gpt", "value": "In the .NET framework, ...