instruction
stringlengths
14
27.6k
completion
stringlengths
3
38.3k
__original_row_idx
int64
0
50k
conversations
listlengths
2
2
In the spirit of Best Practices: Always return a ____, never a ____, I face a similar question in my upcoming migration from JDK1.4.2 to JDK5 and more. (Yes, I know, JDK1.4.2 is EOL! ;-) ). For functions returning a collection (which are not simple property collections), I always prefer (in JDK1.4.2) returning an Array...
When migrating from JDK 1.4.2 to JDK 5 and beyond, there are indeed some considerations to take into account when deciding whether to return an array (`MyObject[]`), a generic `List<MyObject>`, or a more general `Collection<MyObject>`. Here's a breakdown of the pros and cons of each approach, followed by answers to you...
30,401
[ { "from": "human", "value": "In the spirit of Best Practices: Always return a ____, never a ____, I face a similar question in my upcoming migration from JDK1.4.2 to JDK5 and more. (Yes, I know, JDK1.4.2 is EOL! ;-) ).\nFor functions returning a collection (which are not simple property collections), I alwa...
When the WIN32 docs says something like: wParam The low-order word specifies the edit control identifier. The high-order word specifies the notification message. What's a nice way of building that wParam?
In Win32 API programming, `wParam` is often used in message parameters to convey specific information, and when it refers to using both the low-order word and high-order word, you generally want to combine two values into a single `wParam` value. To do this, you can use bitwise operations, specifically the bitwise OR o...
31,866
[ { "from": "human", "value": "When the WIN32 docs says something like:\nwParam\n The low-order word specifies the edit control identifier.\n The high-order word specifies the notification message. \n\nWhat's a nice way of building that wParam?\n" }, { "from": "gpt", "value": "In Win32 API p...
There is an application with an extensive object graph. This graph mainly consists of a set of subgraphs which are connected to the rest of the graph through the only reference. But internally each such subgraph has some number of cross-references among objects. Once in a while such a sub graph needs to be thrown away....
In most modern garbage-collected programming languages (like Java, C#, etc.), the garbage collector (GC) is designed to automatically determine when an object is no longer reachable, thereby making it eligible for garbage collection. In your scenario, where you have a subgraph of objects connected through internal cros...
33,094
[ { "from": "human", "value": "There is an application with an extensive object graph. This graph mainly consists of a set of subgraphs which are connected to the rest of the graph through the only reference. But internally each such subgraph has some number of cross-references among objects. Once in a while ...
Can source code examples be kept in a SQL database while retaining all formatting (tabs, newlines, etc.)? If so what data type would be used?
Yes, source code examples can be stored in a SQL database while retaining all formatting, including tabs, newlines, and other whitespace characters. The appropriate data type to use for this purpose is typically either `TEXT` or `VARCHAR`, depending on the database system and the expected length of the source code. ##...
34,372
[ { "from": "human", "value": "Can source code examples be kept in a SQL database while retaining all formatting (tabs, newlines, etc.)? If so what data type would be used?\n" }, { "from": "gpt", "value": "Yes, source code examples can be stored in a SQL database while retaining all formatting, in...
I need to move data from a datareader into a Farpoint Spreadsheet component in a Windows form. The DataSource of an fps sheet can't be set to a datareader. I don't want to change my app to use ADO just for this purpose. Right now I'm looping through the query data and pushing it into the sheet cell-by-cell. That's u...
When working with the FarPoint Spread (FPS) component in Windows Forms, you can indeed face challenges when trying to populate a sheet with data from a DataReader because it doesn't support direct assignment. However, if you're concerned about performance while populating the spreadsheet cell-by-cell, there are a few t...
25,091
[ { "from": "human", "value": "I need to move data from a datareader into a Farpoint Spreadsheet component in a Windows form. The DataSource of an fps sheet can't be set to a datareader. I don't want to change my app to use ADO just for this purpose.\nRight now I'm looping through the query data and pushing...
What is the best way to manage a database connection in a Java servlet? Currently, I simply open a connection in the init() function, and then close it in destroy(). However, I am concerned that "permanently" holding onto a database connection could be a bad thing. Is this the correct way to handle this? If not, wha...
Managing database connections in a Java servlet requires careful consideration to achieve a balance between resource utilization and performance. Your current approach of opening a connection in the `init()` method and closing it in `destroy()` is not recommended, as holding onto a database connection for the lifetime ...
29,370
[ { "from": "human", "value": "What is the best way to manage a database connection in a Java servlet?\nCurrently, I simply open a connection in the init() function, and then close it in destroy(). \nHowever, I am concerned that \"permanently\" holding onto a database connection could be a bad thing. \nIs thi...
For the purposes of this question, the code base is an ASP.NET website that has multiple pages written in both C# and Visual Basic .NET. The primary language is C# and the Visual Basic .NET webpages where forked into the project as the same functionality is needed. Should the time be taken to actually rewrite these pa...
Deciding whether to rewrite Visual Basic .NET pages in C# on your ASP.NET website involves several considerations: ### Considerations for Rewriting 1. **Consistency in Codebase**: - **Maintenance**: A consistent codebase in a single language (C#) can simplify maintenance and onboarding new developers who may only ...
30,597
[ { "from": "human", "value": "For the purposes of this question, the code base is an ASP.NET website that has multiple pages written in both C# and Visual Basic .NET. The primary language is C# and the Visual Basic .NET webpages where forked into the project as the same functionality is needed. \nShould the ...
I am hacking up a tagging application for emacs. I have got a tag cloud/weighted list successfully displaying on a buffer, but i am running into a snag. I need to be able to properly word-wrap the buffer, but I haven't a clue where to start. The font I am using is a variable width font. On top of that, each tag is g...
Creating a responsive tag cloud in Emacs with variable-width fonts and dynamic sizes can indeed be challenging. Since each tag's size will vary, you'll need to calculate their widths in pixels and manage the wrapping manually. Here's a general approach to achieve this: ### Step 1: Measure Tag Widths You'll want to me...
26,472
[ { "from": "human", "value": "I am hacking up a tagging application for emacs. I have got a tag cloud/weighted list successfully displaying on a buffer, but i am running into a snag. I need to be able to properly word-wrap the buffer, but I haven't a clue where to start.\nThe font I am using is a variable ...
Assuming one has an abstract base class foo with __get() defined, and a child class bar which inherits from foo with a private variable $var, will the parent __get() be called when trying to access the private $var from outside the class?
In PHP, if you have an abstract base class `foo` with a `__get()` method defined, and a child class `bar` that inherits from `foo` with a private variable `$var`, the behavior when trying to access the private variable from outside the class depends on a few key aspects of visibility and the magic method `__get()`. 1....
33,539
[ { "from": "human", "value": "Assuming one has an abstract base class foo with __get() defined, and a child class bar which inherits from foo with a private variable $var, will the parent __get() be called when trying to access the private $var from outside the class? \n" }, { "from": "gpt", "va...
What is the best way to run an external program from excel. It might run for several minutes. What's the best-practice about how to to this. Ideally, A model dialog box that let's the user know that the process is executing. If the executable fails, the user should receive a notification. A timeout should be enforc...
Running an external program from Excel requires careful planning, especially when considering user experience and error handling. Given your requirements, here's a comprehensive approach using VBA (Visual Basic for Applications). While Excel 2003 and earlier versions have limitations compared to later versions, the fol...
22,065
[ { "from": "human", "value": "What is the best way to run an external program from excel. It might run for several minutes. What's the best-practice about how to to this. Ideally,\n\nA model dialog box that let's the user know that the process is executing.\nIf the executable fails, the user should receiv...
I've been using Flex Builder 3 to create Flex applications that are part of larger Flex / Java project using LiveCycle Data Services. Flex Builder creates and deploys the .war file, which is convenient for the development cycle, but I don't understand what the .war file has to contain in order to deploy and run. I've ...
Creating a .war file for a Flex/Java application and understanding its contents can be a bit complex, but let's break it down and point you towards useful resources. ### Key Components of a .war File for Flex/Java 1. **Flex Application Files:** - Your Flex application files (e.g., `.swf`, `.mxml`, etc.) will be co...
29,240
[ { "from": "human", "value": "I've been using Flex Builder 3 to create Flex applications that are part of larger Flex / Java project using LiveCycle Data Services. Flex Builder creates and deploys the .war file, which is convenient for the development cycle, but I don't understand what the .war file has to ...
I am using a Windows XP Home Edition. I need to install a few extensions to PHP -- memcache, APC, .etc. And I would very much like to use PECL to make this happen. The problem is PECL takes it for granted that I will have certain programs on my computer. On another post, I read, for instance, that you need to have Micr...
Installing PHP extensions on Windows, especially on an older version like Windows XP, can be tricky due to the dependencies and tools required for building extensions from source. Below are several approaches that could help you install PHP extensions like memcache and APC on your system: ### 1. **Using Precompiled DL...
27,821
[ { "from": "human", "value": "I am using a Windows XP Home Edition. I need to install a few extensions to PHP -- memcache, APC, .etc. And I would very much like to use PECL to make this happen. The problem is PECL takes it for granted that I will have certain programs on my computer. On another post, I read,...
We're working now on the design of a new API for our product, which will be exposed via web services. We have a dispute whether we should use strict parameters with well defined types (my opinion) or strings that will contain XML in whatever structure needed. It is quite obvious that ideally using a strict signature is...
When designing an API, especially for web services, the choice between strict parameters with well-defined types and flexible XML structures is a critical one, and both approaches have their pros and cons. Here are some considerations to guide your decision: ### Pros of Using Strict Parameters with Well-Defined Types ...
28,404
[ { "from": "human", "value": "We're working now on the design of a new API for our product, which will be exposed via web services. We have a dispute whether we should use strict parameters with well defined types (my opinion) or strings that will contain XML in whatever structure needed. It is quite obvious...
I went to school for programming years ago and when I got out I found a job in system administration and that is the direction my career took. I'd like to get back into development of some sort and have been 'playing' with C# and ASP.NET, but I've been hearing lots of buzz for other 'new' languages (by new I mean that ...
It's great to hear that you're looking to get back into development! The decision on which languages and technologies to focus on can indeed be a bit daunting, especially given the fast-paced nature of the tech industry. Here are some thoughts to help you navigate this: 1. **Current Skills and Market Demand**: - If...
27,394
[ { "from": "human", "value": "I went to school for programming years ago and when I got out I found a job in system administration and that is the direction my career took. I'd like to get back into development of some sort and have been 'playing' with C# and ASP.NET, but I've been hearing lots of buzz for o...
I am having an VBScript files which runs by many instance of jobs. I need to log the error information if any error occurs in the script processing. If i maintain a log file then how can i differentiate the log file for each instances (around 10 simultaneous instances) of vb script calling. I dont go for any db logging...
When running multiple instances of a VBScript, you can create unique log files for each instance to differentiate their outputs. Below are a few methods you could consider to achieve this: ### 1. Use a Timestamp You can append a timestamp to the log file name. This will help ensure that each instance has a unique file...
26,711
[ { "from": "human", "value": "I am having an VBScript files which runs by many instance of jobs. I need to log the error information if any error occurs in the script processing. If i maintain a log file then how can i differentiate the log file for each instances (around 10 simultaneous instances) of vb scr...
I'd love to use WPF for a consumer app. However, some real world tests are not very encouraging. On several high-end computers I've tested, the .NET 3.5 installation has taken 15-20 mins to complete. I've seen reports online mentioning 50 mins. When Vista marketshare is at 70%, this subject will be moot. Until then, re...
The slow installation times you're experiencing with the .NET Framework 3.5, especially on Windows XP, can be quite frustrating, particularly for consumer applications. Here are some insights and potential solutions to your questions: ### 1. What is Causing the Slow Installation? The prolonged installation times for ...
33,362
[ { "from": "human", "value": "I'd love to use WPF for a consumer app. However, some real world tests are not very encouraging. On several high-end computers I've tested, the .NET 3.5 installation has taken 15-20 mins to complete. I've seen reports online mentioning 50 mins.\nWhen Vista marketshare is at 70%,...
I have worked on several distributed client/server projects recently, and one pain point that we always run into is translating the DTO objects into our entities and vice-versa. I was wondering if anyone has a "simple" solution to this time sink? One thing I thought about was coming up with some sort of translation us...
Transforming Data Transfer Objects (DTOs) into entities and vice-versa is a common challenge in distributed systems, and it can indeed become a time sink if not approached effectively. Here are some strategies that can help streamline the process: ### 1. **Automated Mapping Libraries** Using established mapping librar...
32,922
[ { "from": "human", "value": "I have worked on several distributed client/server projects recently, and one pain point that we always run into is translating the DTO objects into our entities and vice-versa. I was wondering if anyone has a \"simple\" solution to this time sink?\nOne thing I thought about wa...
I'm sure this has been asked before, but I can't find it. What are the benefits/limitations of using a browser-based interface for a stand-alone application vs. using a normal GUI framework? I'm working on a Python program currently implement with wxPython for the GUI. The application is simply user-entry forms and di...
When deciding between a browser-based interface and a traditional GUI framework like wxPython or PyQt for a stand-alone application, there are several benefits and limitations to consider: ### Benefits of Using a Browser-Based Interface 1. **Cross-Platform Compatibility**: A web-based GUI can run on any platform that...
26,875
[ { "from": "human", "value": "I'm sure this has been asked before, but I can't find it. \nWhat are the benefits/limitations of using a browser-based interface for a stand-alone application vs. using a normal GUI framework?\nI'm working on a Python program currently implement with wxPython for the GUI. The ap...
I'm building a class library that will have some public & private methods. I want to be able to unit test the private methods (mostly while developing, but also it could be useful for future refactoring). What is the correct way to do this?
Unit testing private methods directly can be a controversial topic because it often suggests that the design may need to be reconsidered. However, if you want to unit test private methods during development and refactoring, there are several strategies you can employ. Here are some of the most common approaches: ### 1...
26,609
[ { "from": "human", "value": "I'm building a class library that will have some public & private methods. I want to be able to unit test the private methods (mostly while developing, but also it could be useful for future refactoring).\nWhat is the correct way to do this?\n" }, { "from": "gpt", "v...
I have an object that returns an IList which I'm getting from my ObjectDataSource and binding to a Gridview. All works fine if I just use standard binding, but I'm trying to customize my binding to set properties on a linkbutton as follows: protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) ...
The issue you are encountering arises from the fact that `e.Row.DataItem` is not of type `DataRowView` because you are using an `ObjectDataSource` that returns a collection (typically an `IList`) of custom objects, not a `DataTable` or `DataView`. To resolve this, you need to cast `e.Row.DataItem` to the appropriate t...
34,076
[ { "from": "human", "value": "I have an object that returns an IList which I'm getting from my ObjectDataSource and binding to a Gridview. All works fine if I just use standard binding, but I'm trying to customize my binding to set properties on a linkbutton as follows:\nprotected void GridView1_RowDataBoun...
I want to print the full length of a C-string in GDB. By default it's being abbreviated, how do I force GDB to print the whole string?
In GDB (the GNU Debugger), when printing strings, the output might be truncated if the string is too long. However, you can control the behavior of GDB to print the entire C-string without truncation. You can use the `set print elements` command to change the maximum number of elements that GDB will print for arrays, ...
29,843
[ { "from": "human", "value": "I want to print the full length of a C-string in GDB. By default it's being abbreviated, how do I force GDB to print the whole string?\n" }, { "from": "gpt", "value": "In GDB (the GNU Debugger), when printing strings, the output might be truncated if the string is t...
I'm having trouble with SQL Server 2008 (Express with Advanced Services) Reporting Services permissions. I'm running this on Vista Ultimate at home - standalone machine with no servers, no domain or active directory. When I go to the ReportServices site, I get this: The permissions granted to user 'localmachine\Sco...
The `rsAccessDenied` error in SQL Server Reporting Services (SSRS) typically indicates that the user does not have sufficient permissions to perform the requested action. Given that you are running SSRS on a standalone machine and not in a domain environment, the issue usually stems from the configuration of the SSRS s...
27,786
[ { "from": "human", "value": "I'm having trouble with SQL Server 2008 (Express with Advanced Services) Reporting Services permissions. I'm running this on Vista Ultimate at home - standalone machine with no servers, no domain or active directory.\nWhen I go to the ReportServices site, I get this:\n\nThe per...
Before anybody asks, I am not doing any kind of screenscraping. I'm trying to parse an html string to find a div with a certain id. I cannot for the life of me get this to work. The following expression worked in one instance, but not in another. I'm not sure if it has to do with extra elements in the html or not. <...
It looks like you want to extract a specific `<div>` element with a certain `id`, but your regular expression is overly complex and may not be properly handling nested structures. Regular expressions can be tricky for parsing HTML due to the nested and potentially varying structures. In .NET, a more robust solution wo...
33,753
[ { "from": "human", "value": "Before anybody asks, I am not doing any kind of screenscraping.\nI'm trying to parse an html string to find a div with a certain id. I cannot for the life of me get this to work. The following expression worked in one instance, but not in another. I'm not sure if it has to do...
In our project we have a large number (hundreds) of FLA files created by the artists in CS3, from which we compile SWFs to use in our Flex/AS3 application. As part of a streamlined build/deploy system, it would be really handy to be able to automate publishing all these FLAs, and ideally deploying the SWFs too. I found...
Automating the publishing of FLA files from Adobe Flash CS3 can indeed be a bit tricky, especially since you mentioned the preference for a Linux environment. Here’s a solution that incorporates both Windows (for Adobe Flash) and Linux. ### Step 1: Use JSFL for Batch Publishing JSFL (JavaScript Flash) is Adobe's scri...
29,742
[ { "from": "human", "value": "In our project we have a large number (hundreds) of FLA files created by the artists in CS3, from which we compile SWFs to use in our Flex/AS3 application.\nAs part of a streamlined build/deploy system, it would be really handy to be able to automate publishing all these FLAs, a...
My web service method returns a Page object which includes the following methods: public Map<String,String[]> getParameters() { ... } public setParameters(Map<String,String[]> parameters) { ... } On the client side, the JAX-WS generated getParameters() method returns a Parameters object which provides a getEntry() met...
The issue you are encountering, where the `getParameters()` method on the client side is returning an empty list of entries, could be due to several reasons. Here are some common causes and potential solutions to investigate: 1. **Serialization Issue**: The way the `Page` object is being serialized and deserialized be...
32,659
[ { "from": "human", "value": "My web service method returns a Page object which includes the following methods:\npublic Map<String,String[]> getParameters() { ... }\npublic setParameters(Map<String,String[]> parameters) { ... }\n\nOn the client side, the JAX-WS generated getParameters() method returns a Para...
I'm building an extra layer on top of Movable Type for integration with another system. Part of this involves pre-processing and filtering requests before they get to the MT scripts (comment control, translating external users into MT users etc). For example, new comments to posts are submitted to a script in the new l...
Certainly! Here’s a breakdown of the various `mt-*.cgi` scripts in Movable Type, including their purpose and recommendations regarding access control. | Script | Private Access? | Purpose & Description ...
29,844
[ { "from": "human", "value": "I'm building an extra layer on top of Movable Type for integration with another system. Part of this involves pre-processing and filtering requests before they get to the MT scripts (comment control, translating external users into MT users etc).\nFor example, new comments to po...
I have a contacts table which contains fields such as postcode, first name, last name, town, country, phone number etc, all of which are defined as VARCHAR(255) even though none of these fields will ever come close to having 255 characters. (If you're wondering, it's this way because Ruby on Rails migrations map Strin...
In MySQL, using `VARCHAR(n)` where `n` is significantly larger than the expected data size can have implications, even if `VARCHAR` only uses the actual character length plus one or two bytes for storing the length itself. Here are some considerations regarding performance, storage, and indexing when it comes to using ...
30,289
[ { "from": "human", "value": "I have a contacts table which contains fields such as postcode, first name, last name, town, country, phone number etc, all of which are defined as VARCHAR(255) even though none of these fields will ever come close to having 255 characters. (If you're wondering, it's this way b...
I have been thinking about starting a side project at home to exercise my brain a bit. Reversi looks like a simply game, where mobility has a profound effect on game play. It is at least a step up from tic tac toe. This would be a single player against an AI of some sort. I am thinking to try this in C++ on a PC. W...
Starting a side project to create a Reversi game in C++ is a great way to challenge yourself and improve your programming skills! Here are some key points to consider as you embark on this project. ### Potential Issues You Might Encounter 1. **Game Logic Implementation**: - Implementing the rules of Reversi can be...
29,549
[ { "from": "human", "value": "I have been thinking about starting a side project at home to exercise my brain a bit. Reversi looks like a simply game, where mobility has a profound effect on game play.\nIt is at least a step up from tic tac toe. This would be a single player against an AI of some sort.\n...
Simple yes or no question, and I'm 90% sure that it is no... but I'm not sure. Can a Base64 string contain tabs?
No.
36,467
[ { "from": "human", "value": "Simple yes or no question, and I'm 90% sure that it is no... but I'm not sure.\nCan a Base64 string contain tabs?\n" }, { "from": "gpt", "value": "No." } ]
I have a clock feature in a VB.NET program that displays the time including the seconds. I currently have a timer constantly polling using NOW. I have to poll the system clock quite often because I need to have the second update in sync with the system clock. Is there a more direct to access the time only when the seco...
In VB.NET, you can avoid constant polling for the current time by using a `Timer` that updates your clock display only when the seconds change. This can be accomplished by determining the number of seconds when the timer starts and setting the timer to fire just before the second changes. Here’s an efficient way to ach...
29,394
[ { "from": "human", "value": "I have a clock feature in a VB.NET program that displays the time including the seconds. I currently have a timer constantly polling using NOW. I have to poll the system clock quite often because I need to have the second update in sync with the system clock.\nIs there a more di...
When I right-click a solution in VS2008 and select Check In... I am presented with a list of changed files with check boxes and a comment area. (This is done against TFS.) Our check-in process requires that we enter this list of changed files into the bug tracking ticket. This requires typing in the name of each each f...
In Visual Studio 2008, there's no direct built-in functionality to copy the list of changed files from the Check In dialog to the clipboard. However, you can work around this limitation by using a couple of methods: ### Method 1: Use the Output Window 1. **Open the Output Window**: Before you check in your changes, g...
29,212
[ { "from": "human", "value": "When I right-click a solution in VS2008 and select Check In... I am presented with a list of changed files with check boxes and a comment area. (This is done against TFS.)\nOur check-in process requires that we enter this list of changed files into the bug tracking ticket. This ...
I'm creating a gem which has several scripts in the bin directory the utility classes in the lib directory and several tests in the test directory supertool bin toolA toolB lib supertool supertool.rb helper.rb test tc_main.rb tc_etc.rb Now, to run the tests before I even install the gem,...
To simplify your development and testing workflow for your Ruby gem, there are a couple of strategies you can employ. One common approach is to use a testing framework that automatically sets up the load path for you. Here are some options: ### 1. Use Bundler for Development You can set up a `Gemfile` in your project...
32,204
[ { "from": "human", "value": "I'm creating a gem which has\n\nseveral scripts in the bin directory\nthe utility classes in the lib directory\nand several tests in the test directory\n\n\nsupertool\n bin\n toolA\n toolB\n lib\n supertool\n supertool.rb\n helper.rb\n test\n tc_main.rb\n tc_et...
I hava a url such as search.do?offset=20 offset sometimes is in the url sometimes not. When it is not in the URL i want it to be 0. i try, without success, to retrieve the value with a scriptlet as follows: <% Integer offset = (pageContext.findAttribute("offset")==null) ? new Integer("0") : new Integer((String) pageC...
It looks like you're trying to retrieve the value of the `offset` parameter from the URL and provide a default value of `0` if it isn't present. The issue is that you are using `pageContext.findAttribute("offset")`, which searches for an attribute named `offset` in the page context, rather than retrieving the `offset` ...
34,196
[ { "from": "human", "value": "I hava a url such as search.do?offset=20\noffset sometimes is in the url sometimes not. When it is not in the URL i want it to be 0.\ni try, without success, to retrieve the value with a scriptlet as follows: \n<% Integer offset = (pageContext.findAttribute(\"offset\")==null) ?...
File formats I would like to play include .wav, .mp3, .midi. I have tried using the Wireless Toolkit classes with no success. I have also tried using the AudioClip class that is part of the Samsung SDK; again with
It sounds like you are trying to play audio files in various formats (such as .wav, .mp3, and .midi) on a device, potentially using Java, given your mention of Wireless Toolkit classes and Samsung SDK. Here are some steps and tips you can follow to play these audio formats effectively: ### 1. Use the Right Libraries: ...
21,806
[ { "from": "human", "value": "File formats I would like to play include .wav, .mp3, .midi.\nI have tried using the Wireless Toolkit classes with no success. I have also tried using the AudioClip class that is part of the Samsung SDK; again with\n" }, { "from": "gpt", "value": "It sounds like you ...
How can I replace multiple spaces in a string with only one space in C#? Example: 1 2 3 4 5 would be: 1 2 3 4 5
In C#, you can replace multiple spaces in a string with a single space using the `Regex` class from the `System.Text.RegularExpressions` namespace. The `Regex.Replace` method allows you to match multiple spaces and replace them with a single space. Here's an example of how to do this: ```csharp using System; using Sys...
27,947
[ { "from": "human", "value": "How can I replace multiple spaces in a string with only one space in C#?\nExample:\n1 2 3 4 5\n\nwould be:\n1 2 3 4 5\n\n" }, { "from": "gpt", "value": "In C#, you can replace multiple spaces in a string with a single space using the `Regex` class from the `Syste...
How do I get the path to the machine.config from a .Net application? It should automatically get the correct path based on the .Net version of the app.
In a .NET application, you can programmatically retrieve the path to the `machine.config` file based on the runtime version being used by the application. The `machine.config` file is located in a specific directory depending on the .NET version installed on the machine. Here's how you can get the path to `machine.con...
30,563
[ { "from": "human", "value": "How do I get the path to the machine.config from a .Net application? It should automatically get the correct path based on the .Net version of the app.\n" }, { "from": "gpt", "value": "In a .NET application, you can programmatically retrieve the path to the `machine....
I am creating an application in java which will be the part of an external application. My application contains a viewport which shows some polygons and stuff like that. The external application needs to get the image of the viewport in gif format. For that it calls a method in an interface (implemented by my applicati...
In your scenario, since the external application requires the image in GIF format and your GIF encoder class currently returns a byte array, using a `byte[]` as the return type for the method is actually a reasonable choice. A `byte[]` can easily represent the binary data of the GIF image, and it's a standard way of tr...
31,484
[ { "from": "human", "value": "I am creating an application in java which will be the part of an external application. My application contains a viewport which shows some polygons and stuff like that. The external application needs to get the image of the viewport in gif format. For that it calls a method in ...
Similar question as this one but for a Microsoft Environment. Email --> Exchange Server -->[something] For the [something] I was using Outlook 2003 & C# but it feels messy (A program is trying to access outlook, this could be a virus etc) Microsoft.Office.Interop.Outlook.Application objOutlook = new Microsoft.Office.In...
Using Microsoft.Office.Interop.Outlook to interact with Outlook can lead to various issues, especially when it comes to security prompts and performance. Additionally, it ties your application to the Outlook client installed on the machine, which can be problematic for deployment and scalability. Instead, there are se...
29,685
[ { "from": "human", "value": "Similar question as this one but for a Microsoft Environment.\nEmail --> Exchange Server -->[something]\nFor the [something] I was using Outlook 2003 & C# but it feels messy (A program is trying to access outlook, this could be a virus etc)\nMicrosoft.Office.Interop.Outlook.Appl...
Dear stack overflow community, I've been given the task of overhauling a couple of websites for a large corporation I'm working for, as well as developing an internal intranet site for content management and document storage within the organization. My "problem" is this: They want me to use a framework/set of languages...
Hi Seth, You're facing a common dilemma when tasked with choosing the right technology stack for enterprise applications. Here are some considerations and recommendations that might help guide your decision. ### 1. **Python/Django** - **Proven Track Record**: Django is widely used in the industry with notable example...
30,440
[ { "from": "human", "value": "Dear stack overflow community,\nI've been given the task of overhauling a couple of websites for a large corporation I'm working for, as well as developing an internal intranet site for content management and document storage within the organization.\nMy \"problem\" is this: The...
I am trying to quantify "site slowness". In the olden days you just made sure that your HTML was lightweight, images optimized and servers not overloaded. In high end sites built on top of modern content management systems there are a lot more variables: third party advertising, trackers and various other callouts, the...
Measuring "site slowness" can indeed be complex due to the multiple variables involved. Here are several methods and tools you can use to quantify performance issues in modern websites, especially those built on content management systems: ### 1. **Performance Monitoring Tools** - **Google Lighthouse**: This tool p...
27,606
[ { "from": "human", "value": "I am trying to quantify \"site slowness\". In the olden days you just made sure that your HTML was lightweight, images optimized and servers not overloaded. In high end sites built on top of modern content management systems there are a lot more variables: third party advertisin...
I'm looking to create a virtual printer that passes data to my .NET application. I want to then create an installer that installs both the printer and the .NET application. It would we really nice to be able to write it all in C#, but I have a feeling that this will require a printer driver to be written is unmanaged ...
Creating a virtual printer that communicates with a .NET application involves a few components: the printer driver itself (which typically requires unmanaged code), the .NET application to process the printed data, and an installer to bundle both. ### Steps Overview 1. **Create a Virtual Printer Driver**: This is typ...
28,624
[ { "from": "human", "value": "I'm looking to create a virtual printer that passes data to my .NET application. I want to then create an installer that installs both the printer and the .NET application. It would we really nice to be able to write it all in C#, but I have a feeling that this will require a p...
I've created a stored procedure similar to the one below (I'm using this cut down version to try and figure our the problem). CREATE PROCEDURE bsp_testStoredProc AS BEGIN CREATE TABLE #tmpFiles ( AuthorName NVARCHAR(50), PercentageHigh INT ) -- Insert data into temp table SELECT AuthorName, PercentageHi...
The issue you're encountering arises because Visual Studio's design-time tools for database access don't know the structure of temporary tables created within stored procedures. When you execute the stored procedure, the system does not have information about the columns in `#tmpFiles`, making it unable to infer the ou...
29,895
[ { "from": "human", "value": "I've created a stored procedure similar to the one below (I'm using this cut down version to try and figure our the problem). \nCREATE PROCEDURE bsp_testStoredProc\nAS\nBEGIN\n\nCREATE TABLE #tmpFiles \n(\n AuthorName NVARCHAR(50), \n PercentageHigh INT\n) \n\n-- Insert d...
I would like to have some kind of catch-all exceptions mechanism in the root of my code, so when an app terminates unexpectedly I can still provide some useful logging. Something along the lines of static void Main () { if (Debugger.IsAttached) RunApp(); else { try { RunApp(); ...
You can achieve your goal by utilizing `AppDomain.UnhandledException` and `TaskScheduler.UnobservedTaskException` to catch unhandled exceptions globally while still providing a mechanism to log the error information. Here’s a strategy you can implement: 1. **Global Exception Handling**: Set up a global exception handl...
31,850
[ { "from": "human", "value": "I would like to have some kind of catch-all exceptions mechanism in the root of my code, so when an app terminates unexpectedly I can still provide some useful logging.\nSomething along the lines of\nstatic void Main () {\n if (Debugger.IsAttached)\n RunApp();\n els...
I am using C# and ASP.NET with version 2.0 of the .NET Framework library on this particular project. We are also using the AjaxControlToolkit. The AjaxControlToolkit should have the controls available to make a descent User Interface solution to the problem I'm facing. I have run into this in a few projects in the l...
Your instinct to avoid loading 25,000 items in a dropdown list is spot-on. Displaying such a large dataset directly in a dropdown is not user-friendly and can lead to performance issues, as you've already experienced. Your idea of using a Modal Popup with an Autocomplete Extender is a great approach for enhancing the u...
30,423
[ { "from": "human", "value": "I am using C# and ASP.NET with version 2.0 of the .NET Framework library on this particular project. We are also using the AjaxControlToolkit. The AjaxControlToolkit should have the controls available to make a descent User Interface solution to the problem I'm facing. \nI hav...
Anyone using MozyPro to backup SQL Server databases? I'm concerned about the way it does the backup. It just copies data files the way they are. Not using the backup database command. Is it safe?
Using MozyPro (or similar file backup solutions) to back up SQL Server databases can be problematic if you're simply copying the data files directly without using SQL Server's native backup commands. Here are some key points to consider regarding the safety and integrity of such backups: ### 1. **Consistent State**: ...
30,605
[ { "from": "human", "value": "Anyone using MozyPro to backup SQL Server databases?\nI'm concerned about the way it does the backup. It just copies data files the way they are. Not using the backup database command.\nIs it safe?\n" }, { "from": "gpt", "value": "Using MozyPro (or similar file backu...
I'm developing a piece in VB.NET. Inside my primary form, I'm creating a new form to use as a dialog. I was wondering if there was a way to, upon the close of the new dialog, save it's size settings for each user (probably in a file on their machine, through XML or something?)
Yes, you can save the size and position of a form (dialog) in VB.NET and store that information in an XML file. Here’s a step-by-step guide on how you can do that: ### Step 1: Create a Class to Represent Form Settings First, create a class that represents the settings of the form (like size and position): ```vb.net ...
31,239
[ { "from": "human", "value": "I'm developing a piece in VB.NET. Inside my primary form, I'm creating a new form to use as a dialog. I was wondering if there was a way to, upon the close of the new dialog, save it's size settings for each user (probably in a file on their machine, through XML or something?)...
I am using 0.97-pre-SVN-unknown release of Django. I have a model for which I have not given any primary_key. Django, consequently, automatically provides an AutoField that is called "id". Everything's fine with that. But now, I have to change the "verbose_name" of that AutoField to something other than "id". I cannot ...
In Django, when you create a model and don't specify a primary key, it automatically creates an `AutoField` named `id`. However, changing the `verbose_name` of this auto-generated field while keeping the data intact can be a bit tricky since Django doesn't allow directly overriding the `id` field. One way to achieve w...
33,920
[ { "from": "human", "value": "I am using 0.97-pre-SVN-unknown release of Django.\nI have a model for which I have not given any primary_key. Django, consequently, automatically provides an AutoField that is called \"id\". Everything's fine with that. But now, I have to change the \"verbose_name\" of that Aut...
I'm writing out XML files using the MSXML parser, with a wrapper I downloaded from here: http://www.codeproject.com/KB/XML/JW_CXml.aspx. Works great except that when I create a new document from code (so not load from file and modify), the result is all in one big line. I'd like elements to be indented nicely so that I...
As of my last knowledge update in October 2023, MSXML itself does not natively support pretty-printing XML when saving. However, there are a few workarounds you can use to achieve nicely formatted XML output. ### Option 1: Use `IXMLDOMDocument::save` with an external tool After you generate the XML with MSXML, you ca...
31,131
[ { "from": "human", "value": "I'm writing out XML files using the MSXML parser, with a wrapper I downloaded from here: http://www.codeproject.com/KB/XML/JW_CXml.aspx. Works great except that when I create a new document from code (so not load from file and modify), the result is all in one big line. I'd like...
Although I grasp the concept of Bitwise Operators, I can't say that I have come across many use cases during the webdevelopment process at which I had to resort to using Bitwise Operators. Do you use Bitwise Operators? Why do you use them? What are some example use cases? Please remember that this question is specifi...
Bitwise operators are often underutilized in web development compared to their potential, but they can be beneficial in specific scenarios. Here's a breakdown of when and why you might use them in web languages, along with some examples: ### Use Cases for Bitwise Operators in Web Development 1. **Flags and Permission...
27,930
[ { "from": "human", "value": "Although I grasp the concept of Bitwise Operators, I can't say that I have come across many use cases during the webdevelopment process at which I had to resort to using Bitwise Operators.\n\nDo you use Bitwise Operators?\nWhy do you use them?\nWhat are some example use cases?\n...
I am loading some data from an XML document, modifying it, and writing back out to XML. The reading is done using a SAX parser library and the writing is done with a piece of custom code. Sometimes, the file is modified externally, and extra elements are added (such as references to stylesheets). Rather than losing ...
When dealing with the requirement to preserve unknown elements and attributes in an XML document during parsing and writing, you can employ a few strategies that can help you achieve this without losing the extra elements introduced externally. Below are some suggestions that are language-agnostic and applicable regard...
28,497
[ { "from": "human", "value": "I am loading some data from an XML document, modifying it, and writing back out to XML. The reading is done using a SAX parser library and the writing is done with a piece of custom code. Sometimes, the file is modified externally, and extra elements are added (such as referen...
I have a class called Ship and a class called Lifeboat Lifeboat inherits from Ship. Ship contains a method called Validate() which is called before save and it has an abstract method called FurtherValidate() which it calls from Validate. The reason this is in place is so when you call validate on the base it also valid...
To ensure that `FurtherValidate()` cannot be called directly from outside the `Ship` class while still forcing derived classes to implement it, you can make `FurtherValidate()` an `internal` method in the `Ship` class and change its access level to `protected`. This way, `FurtherValidate()` can only be called from wi...
31,114
[ { "from": "human", "value": "I have a class called Ship and a class called Lifeboat\nLifeboat inherits from Ship.\nShip contains a method called Validate() which is called before save and it has an abstract method called FurtherValidate() which it calls from Validate. The reason this is in place is so when ...
UPDATE: Thanks to everyone for the responses. I didn't realize document.write() was deprecated. Add a another notch to the learning column. I'll be taking the advice posted here, but leave the original question so that the answers given make sense in context of the original question. I'm in the process of coding some ...
It's great to see that you're considering different approaches for managing long strings and improving readability in your JavaScript code! Since you mentioned that `document.write()` is deprecated, it's good to note that you might want to use modern DOM manipulation methods (like `innerHTML` or `appendChild`) for bett...
26,826
[ { "from": "human", "value": "UPDATE: Thanks to everyone for the responses. I didn't realize document.write() was deprecated. Add a another notch to the learning column. I'll be taking the advice posted here, but leave the original question so that the answers given make sense in context of the original ques...
I'm writing a PHP script and the script outputs a simple text file log of the operations it performs. How would I use PHP to delete the first several lines from this file when it reaches a certain file size? Ideally, I would like it to keep the first two lines (date/time created and blank) and start deleting from line...
To achieve the functionality of deleting lines from a log file in PHP while retaining the first two lines, you can follow these steps: 1. Read the log file into an array. 2. Check the file size. 3. If the size exceeds a specified limit, retain the first two lines and delete a specified number of lines starting from li...
32,554
[ { "from": "human", "value": "I'm writing a PHP script and the script outputs a simple text file log of the operations it performs. How would I use PHP to delete the first several lines from this file when it reaches a certain file size?\nIdeally, I would like it to keep the first two lines (date/time creat...
Its a little tricky to search for 'var:*' because most search engines wont find it. I'm not clear exactly what var:* means, compared to say var:Object I thought it would let me set arbitrary properties on an object like : var x:* = myObject; x.nonExistantProperty = "123"; but this gives me an error : Property nonExis...
In ActionScript (the programming language used for Adobe Flash), the `var x:*` declaration specifies that the variable `x` can hold a value of any type. The `*` (wildcard type) essentially allows for greater flexibility, as it can represent any object or primitive type. However, it does not allow you to dynamically add...
32,512
[ { "from": "human", "value": "Its a little tricky to search for 'var:*' because most search engines wont find it.\nI'm not clear exactly what var:* means, compared to say var:Object\nI thought it would let me set arbitrary properties on an object like :\nvar x:* = myObject;\nx.nonExistantProperty = \"123\";...
I'm updating a long list of records. In my code, everything run as predicted until it execute the query. I get an Incorrect syntax near 'TempUpdatePhysicalCityStateZip' (my stored procedure name). I've tested it with SQL Server Management Studio and it runs fine. So, I'm not quite sure where I got it wrong. Below i...
The error message "Incorrect syntax near 'TempUpdatePhysicalCityStateZip'" indicates that SQL Server is not recognizing your stored procedure name correctly when you attempt to execute it. This could stem from a couple of common issues when working with stored procedures in C#. ### Here are a few potential fixes: 1....
30,275
[ { "from": "human", "value": "I'm updating a long list of records. In my code, everything run as predicted until it execute the query. I get an \n\nIncorrect syntax near 'TempUpdatePhysicalCityStateZip' \n\n(my stored procedure name). I've tested it with SQL Server Management Studio and it runs fine. So, I'm...
Here's the situation: I have one VS2005 solution with two projects: MyDll (DLL), MyDllUnitTest (console EXE). In MyDll I have a class called MyClass which is internal to the DLL and should not be exported. I want to test it in MyDllUnitTest, so I added a test suite class called MyClassTest, where I create instances of ...
To test an internal class in a separate project while avoiding duplication of code, you can utilize the "InternalsVisibleTo" attribute in C#. This attribute allows you to specify another assembly (project) that can access the internal types of your assembly. Here's how you can set it up: ### Step 1: Modify Your DLL Pr...
28,205
[ { "from": "human", "value": "Here's the situation:\nI have one VS2005 solution with two projects: MyDll (DLL), MyDllUnitTest (console EXE).\nIn MyDll I have a class called MyClass which is internal to the DLL and should not be exported. I want to test it in MyDllUnitTest, so I added a test suite class calle...
I would like to print the records in a new page every time the contract number changes. What is the syntax for new page in the SAP SCRIPT. Kindly let me know if you know how to achieve this.
In SAPscript, you can control page breaks using specific commands. To print records on a new page every time the contract number changes, you would typically use the `/` command to indicate a new page. Here’s a general approach on how to achieve this: 1. **Identify the Contract Number Field**: Ensure you have access ...
33,829
[ { "from": "human", "value": "I would like to print the records in a new page every time the contract number changes. What is the syntax for new page in the SAP SCRIPT.\nKindly let me know if you know how to achieve this.\n" }, { "from": "gpt", "value": "In SAPscript, you can control page breaks ...
do I have to register the HttpVerb constraint in my route definition (when i'm registering routes) if i have decorated my action method with the [AcceptVerbs(..)] attribute already? eg. i have this. [AcceptVerbs(HttpVerbs.Post)] public ActionResult Create(FormCollection formCollection) { .. } do i need to add this to ...
No, you do not need to explicitly add the `HttpVerb` constraint to your route definition if you have already decorated your action method with the `[AcceptVerbs(HttpVerbs.Post)]` attribute. The `[AcceptVerbs]` attribute itself serves to restrict the action to the specified HTTP verbs, meaning that the action will only ...
34,629
[ { "from": "human", "value": "do I have to register the HttpVerb constraint in my route definition (when i'm registering routes) if i have decorated my action method with the [AcceptVerbs(..)] attribute already?\neg. i have this.\n[AcceptVerbs(HttpVerbs.Post)]\npublic ActionResult Create(FormCollection formC...
Next Semester I will be taking a "Software Practive II" class. In that class, my professor wants us to learn XNA. I have been playing around with XNA for quite sometime, and enjoy its functionality and simplicity. However, XNA does not take advantage of System.Windows.Forms. Using CEGUI# I was able to get XNA to work ...
Hi BenShums, If you're looking for a framework that provides functionality similar to XNA while also being compatible with `System.Windows.Forms`, you might want to consider the following options: 1. **MonoGame**: This is an open-source implementation of XNA 4.0 and is often considered the spiritual successor to XNA....
30,750
[ { "from": "human", "value": "Next Semester I will be taking a \"Software Practive II\" class. In that class, my professor wants us to learn XNA. I have been playing around with XNA for quite sometime, and enjoy its functionality and simplicity. However, XNA does not take advantage of System.Windows.Forms. ...
Hallo i am currently playing around with castle projects ActiveRecord and the remoting facility. my current problem is that i need the find a way the implement the save sub from IBaseRepository in my address class and i dont know how. here is my current code, VS tells me on the line "implements IAddress" that i have to...
It looks like there are some misunderstandings in your implementation of the `IBaseRepository` and `IAddress` interfaces, particularly related to the generic nature of the `IBaseRepository` interface. In your code, `IBaseRepository(Of T)` is a generic interface that specifies a `Save` method for any type `T`. However,...
26,461
[ { "from": "human", "value": "Hallo i am currently playing around with castle projects ActiveRecord and the remoting facility.\nmy current problem is that i need the find a way the implement the save sub from IBaseRepository in my address class and i dont know how.\nhere is my current code, VS tells me on th...
We do this using the Advanced button on the checkin dialog now (with Merant, nee PVCS) but the Advanced button is disabled when I set TFS as my SCC provider. Is there a switch we can flip on either side to enable this? Or do we need to write some custom extension? Or can I get the TFS changeset number to associat...
Using TFS (Team Foundation Server) as your source control provider in a context like PowerBuilder (PB) may lead to some limitations, especially when it comes to certain features that were available in previous version control systems like Merant PVCS. Here are a few options and considerations to address the issues you'...
31,329
[ { "from": "human", "value": "We do this using the Advanced button on the checkin dialog now (with Merant, nee PVCS) but the Advanced button is disabled when I set TFS as my SCC provider. Is there a switch we can flip on either side to enable this? \n\nOr do we need to write some custom extension? \nOr ca...
This is the page that I'm having. But the resize part in the section does not seem to be working. I copied most of the code from the Ajax site. I placed a alert() in the tag (line 108) to find the value of 'b._originalHeight' and it shows up as '44'. I have also tried the code in the above-said tutorial (line 132) an...
It seems you're facing issues with the resize functionality of the `UpdatePanelAnimationExtender` in your ASP.NET Web Forms application. The main issue appears to be related to how the original height of the `PanelContainer` is being calculated and then utilized during the resizing animations. Below are several steps a...
29,308
[ { "from": "human", "value": "This is the page that I'm having. But the resize part in the section does not seem to be working. I copied most of the code from the Ajax site. I placed a alert() in the tag (line 108) to find the value of 'b._originalHeight' and it shows up as '44'. I have also tried the code...
Does anyone know of any good tools to view the store name, store location, or values of an X.509 Certificate?
Yes, there are several tools and methods to view details such as the store name, store location, and values of an X.509 certificate. Here are a few options: 1. **OpenSSL**: - OpenSSL is a powerful command-line tool for working with certificates. You can view the details of an X.509 certificate by using the followin...
33,404
[ { "from": "human", "value": "Does anyone know of any good tools to view the store name, store location, or values of an X.509 Certificate?\n" }, { "from": "gpt", "value": "Yes, there are several tools and methods to view details such as the store name, store location, and values of an X.509 cert...
I currently use Visual Studio 2008 SP1 and have been migrating older projects into VS2008 but existing SSIS and SSRS (2005) projects have not been compatible with VS2008. It has been a pain to maintain those BIDS projects as a separate solution. I have been considering upgrading to SQL2008 but because our dev, test an...
You're correct in exploring your options for using BIDS (Business Intelligence Development Studio) with Visual Studio 2008, especially when it comes to SSIS (SQL Server Integration Services) and SSRS (SQL Server Reporting Services) projects. 1. **Installing BIDS with SQL Server 2008**: Yes, you can install BIDS by...
34,077
[ { "from": "human", "value": "I currently use Visual Studio 2008 SP1 and have been migrating older projects into VS2008 but existing SSIS and SSRS (2005) projects have not been compatible with VS2008. It has been a pain to maintain those BIDS projects as a separate solution.\nI have been considering upgradi...
I'm using jQuery to hide and show elements when a radio button group is altered/clicked. It works fine in browsers like Firefox, but in IE 6 and 7, the action only occurs when the user then clicks somewhere else on the page. To elaborate, when you load the page, everything looks fine. In Firefox, if you click a radio b...
The issue you are experiencing with IE 6 and 7 is related to how those older browsers handle events and rendering. The delay in showing/hiding elements until after clicking elsewhere on the page can be addressed by using the `click` event instead of `change`. This ensures the action occurs immediately when the user cli...
32,637
[ { "from": "human", "value": "I'm using jQuery to hide and show elements when a radio button group is altered/clicked. It works fine in browsers like Firefox, but in IE 6 and 7, the action only occurs when the user then clicks somewhere else on the page.\nTo elaborate, when you load the page, everything look...
I have the following unmanaged C++ code: MessageBox( NULL, strMessage, "Cool Product", MB_RETRYCANCEL | MB_ICONEXCLAMATION); I want to disable the RETRY button for 10 seconds (for example), then enable it. How can I do this?
To disable the RETRY button of a message box for a certain duration (e.g., 10 seconds) is not directly supported by the standard Windows API, as the `MessageBox` function creates a modal dialog that does not allow you to manipulate the buttons after it is shown. However, you can achieve similar functionality using a cu...
25,199
[ { "from": "human", "value": "I have the following unmanaged C++ code:\nMessageBox( NULL, strMessage, \"Cool Product\", MB_RETRYCANCEL | MB_ICONEXCLAMATION);\n\nI want to disable the RETRY button for 10 seconds (for example), then enable it.\nHow can I do this?\n" }, { "from": "gpt", "value": "To...
I am using the following code: <?php $stock = $_GET[s]; //returns stock ticker symbol eg GOOG or YHOO $first = $stock[0]; $url = "http://biz.yahoo.com/research/earncal/".$first."/".$stock.".html"; $data = file_get_contents($url); $r_header = '/Prev. Week(.+?)Next Week/'; $r_date = '/\<b\>(.+?)\<\/b\>/'; preg_match($...
It seems like you're having trouble extracting the date from the Yahoo Finance earnings calendar page using regular expressions. Let's go through a few troubleshooting steps to identify the issue. 1. **Ensure Valid URL**: Make sure the URL you're constructing is correct. You mentioned that you're checking the URLs and...
22,475
[ { "from": "human", "value": "I am using the following code:\n<?php\n$stock = $_GET[s]; //returns stock ticker symbol eg GOOG or YHOO\n$first = $stock[0];\n\n$url = \"http://biz.yahoo.com/research/earncal/\".$first.\"/\".$stock.\".html\";\n$data = file_get_contents($url);\n\n$r_header = '/Prev. Week(.+?)Next...
Ok, I know someone here has tried this ninja-elite level of coding before. Essentially what I want to do is this: I want a GridView where each row returned becomes the header portion of an asp.net-ajax AccordionPane. Each row also has some unique key, and when you click on each of those AcccordionPane headers, that wil...
Yes, it is absolutely possible to create a dynamic `Accordion` where each pane header corresponds to a row returned from a `GridView`, and where each pane contains a `GridView` that populates its data based on a unique key from the clicked header. Here's a basic outline of how you can implement this using ASP.NET and A...
20,010
[ { "from": "human", "value": "Ok, I know someone here has tried this ninja-elite level of coding before. Essentially what I want to do is this:\nI want a GridView where each row returned becomes the header portion of an asp.net-ajax AccordionPane. Each row also has some unique key, and when you click on each...
I am just getting started with Silverlight and have recently added a Silverlight project to an established solution. In this particular scenario my solution included an existing ASP.NET web site (not application) which Visual Studio kindly offered to integrated my Silverlight application into, which I accepted. So ever...
To set up your ASP.NET MVC application so that it automatically copies the Silverlight application's `.xap` file to the `ClientBin` directory upon build, you need to follow a few manual steps. Here’s how to do it: ### Steps to Manually Configure Copying of Silverlight XAP File 1. **Add a Reference to the Silverlight ...
31,839
[ { "from": "human", "value": "I am just getting started with Silverlight and have recently added a Silverlight project to an established solution. In this particular scenario my solution included an existing ASP.NET web site (not application) which Visual Studio kindly offered to integrated my Silverlight ap...
If I create a recursive list of of lists: class myList { List<myList> childLists; List<string> things; //... } List<myList> tempList = new List<myList>(); And then later call tempList.Clear(), will it destroy all the childLists in memory, or should I create a recursive method to clear all the childLists first?...
When you call `tempList.Clear()` on your `List<myList>`, it will remove all references to the elements in `tempList`, but it will not automatically clear the child lists or the objects themselves from memory. In C#, memory management is handled by the garbage collector. This means that when there are no more reference...
32,416
[ { "from": "human", "value": "If I create a recursive list of of lists:\nclass myList\n{\n List<myList> childLists;\n List<string> things;\n\n //...\n}\n\nList<myList> tempList = new List<myList>();\n\nAnd then later call tempList.Clear(), will it destroy all the childLists in memory, or should I create a...
What is an external and internal iterator in Java ?
In Java, the concepts of external and internal iterators relate to how you traverse or access the elements of a collection, such as lists, sets, or maps. Here’s a breakdown of both types of iterators: ### External Iterator An external iterator is a design pattern where the iteration logic is handled outside the data ...
31,370
[ { "from": "human", "value": "What is an external and internal iterator in Java ?\n" }, { "from": "gpt", "value": "In Java, the concepts of external and internal iterators relate to how you traverse or access the elements of a collection, such as lists, sets, or maps. Here’s a breakdown of both t...
Is there a way to use THE LOOP in Wordpress to load pages instead of posts? I would like to be able to query a set of child pages, and then use THE LOOP function calls on it - things like the_permalink() and the_title(). Is there a way to do this? I didn't see anything in query_posts() documentation.
Yes, you can use The Loop in WordPress to query and display child pages instead of posts. While `query_posts()` is one way to manipulate the main query, it’s generally not recommended due to its potential to disrupt the main loop. Instead, it's better to use `WP_Query`, which allows for more control and flexibility. H...
25,623
[ { "from": "human", "value": "Is there a way to use THE LOOP in Wordpress to load pages instead of posts?\nI would like to be able to query a set of child pages, and then use THE LOOP function calls on it - things like the_permalink() and the_title().\nIs there a way to do this? I didn't see anything in quer...
Erlang support to partition its nodes into groups using the global_group module. Further, Erlang supports adding nodes on the fly to the node-network. Are these two features usable with each other? As far as I understand, you have to name every node on startup to use the global groups.
In Erlang, the `global_group` module allows you to create groups of nodes for the purpose of organizing distributed applications. You can define groups and manage the nodes that belong to these groups. This can be useful for partitioning your distributed system into logical segments. Regarding the ability to add nodes...
31,305
[ { "from": "human", "value": "Erlang support to partition its nodes into groups using the global_group module.\nFurther, Erlang supports adding nodes on the fly to the node-network. Are these two features usable with each other?\nAs far as I understand, you have to name every node on startup to use the globa...
Newish to Oracle programming (from Sybase and MS SQL Server). What is the "Oracle way" to avoid filling the trans log with large updates? In my specific case, I'm doing an update of potentially a very large number of rows. Here's my approach: UPDATE my_table SET a_col = null WHERE my_table_id IN (SELECT my_table_id ...
Welcome to Oracle programming! Your approach is a common method for updating large numbers of rows in smaller batches to avoid filling the transaction log (or redo logs, in Oracle terminology). However, there are some considerations and potential optimizations you might want to take into account: ### 1. Understanding ...
29,300
[ { "from": "human", "value": "Newish to Oracle programming (from Sybase and MS SQL Server). What is the \"Oracle way\" to avoid filling the trans log with large updates?\nIn my specific case, I'm doing an update of potentially a very large number of rows. Here's my approach:\nUPDATE my_table\nSET a_col = n...
Apparently there's a lot of variety in opinions out there, ranging from, "Never! Always encapsulate (even if it's with a mere macro!)" to "It's no big deal – use them when it's more convenient than not." So. Specific, concrete reasons (preferably with an example) Why global variables are dangerous When global variabl...
Global variables are a contentious topic in programming, and opinions vary widely on their use. Below, I’ll outline specific reasons why global variables can be dangerous, when they may be justified, and alternatives that should be considered instead. ### Why Global Variables Are Dangerous 1. **Unintended Side Effect...
25,220
[ { "from": "human", "value": "Apparently there's a lot of variety in opinions out there, ranging from, \"Never! Always encapsulate (even if it's with a mere macro!)\" to \"It's no big deal – use them when it's more convenient than not.\"\nSo.\nSpecific, concrete reasons (preferably with an example)\n\nWhy g...
Is it different from any other certificate I can generate via makecert or buy from some authority?
Yes, certificates generated using tools like `makecert` or purchased from a Certificate Authority (CA) can differ in several ways: ### 1. **Trustworthiness:** - **Certificates from Trusted CAs:** Certificates bought from recognized CAs are generally trusted by browsers and operating systems. This means users will s...
32,070
[ { "from": "human", "value": "Is it different from any other certificate I can generate via makecert or buy from some authority?\n" }, { "from": "gpt", "value": "Yes, certificates generated using tools like `makecert` or purchased from a Certificate Authority (CA) can differ in several ways:\n\n#...
I'm a developer who works on both individual and group projects using Microsoft Visual Studio. I could setup one of several different source control packages, such as VSS, SourceGear Vault or SVN on a server of my own and access them remotely; however, I don't want to deal with the hassle of setting it up, configuring...
Yes, there are several hosted source control services that you can use without the need to set up and maintain your own server. Here are some popular options: 1. **GitHub**: One of the most popular platforms for hosting Git repositories. GitHub offers features like issue tracking, pull requests, and collaboration tool...
32,075
[ { "from": "human", "value": "I'm a developer who works on both individual and group projects using Microsoft Visual Studio. I could setup one of several different source control packages, such as VSS, SourceGear Vault or SVN on a server of my own and access them remotely; however, I don't want to deal with...
I have C# wrapper of a C Library. It has a method that returns an sbyte that is supposed to represent a char. I can use Convert.ToChar but this is not CLS-compliant. What is the best practice for converting this sbyte to a char compliantly?
When dealing with a `sbyte` in C# that you want to convert to a `char`, you should keep in mind that `sbyte` ranges from -128 to 127, while `char` is a 16-bit unsigned type that ranges from 0 to 65535. Thus, direct conversion might lead to issues if the `sbyte` value is negative or out of the `char` range. To convert ...
34,802
[ { "from": "human", "value": "I have C# wrapper of a C Library. It has a method that returns an sbyte that is supposed to represent a char. I can use Convert.ToChar but this is not CLS-compliant. What is the best practice for converting this sbyte to a char compliantly?\n" }, { "from": "gpt", "v...
Our VSS setup is like this: We have a set of unique folders with 100s of files in them. I need to, from within VBScript, get the latest version of all files in a set of folders and put them into a local directory so that other operations can be performed on them. The reason for VBScript is, well, vague even to me. Perh...
Yes, it is possible to use VBScript to get the latest version of files from a Visual SourceSafe (VSS) repository and copy them to a local directory. However, using VBScript for this task can be challenging due to its limited capabilities compared to more robust languages like VB.NET or C#. If you're set on using VBSc...
29,287
[ { "from": "human", "value": "Our VSS setup is like this: We have a set of unique folders with 100s of files in them. I need to, from within VBScript, get the latest version of all files in a set of folders and put them into a local directory so that other operations can be performed on them.\nThe reason for...
In .NET, if a class contains a member that is a class object, should that member be exposed as a property or with a method?
In .NET, whether to expose a class member (which is an object of another class) as a property or a method depends on a few factors, including the intended use of that member, its lifecycle, and the principles of encapsulation and usability. ### When to Use a Property: 1. **Simple Access**: If the member is meant to b...
31,084
[ { "from": "human", "value": "In .NET, if a class contains a member that is a class object, should that member be exposed as a property or with a method?\n" }, { "from": "gpt", "value": "In .NET, whether to expose a class member (which is an object of another class) as a property or a method depe...
Can you recommend an open source library (C or C++) to convert MS Office files into a set of images? I am evaluating ImageMagick and while it does support PDF files, it does not work with MS Office files.
If you're looking to convert MS Office files (like Word, Excel, and PowerPoint) to images using C or C++, you can consider the following open-source libraries: 1. **LibreOffice**: While it is not a library per se, you can run LibreOffice in headless mode to convert MS Office files to images. You can use system calls f...
32,966
[ { "from": "human", "value": "Can you recommend an open source library (C or C++) to convert MS Office files into a set of images?\nI am evaluating ImageMagick and while it does support PDF files, it does not work with MS Office files.\n" }, { "from": "gpt", "value": "If you're looking to convert...
I think I know the answer, but I would like to bounce around some ideas. I would like to pass several (in this instance 2) somewhat different pieces of data to a View. My initial thought is simply to wrap-up the various objects into a containing object and pass them along that way. Then from the View, I'd have somethi...
Wrapping your multiple objects into a single container class is indeed a common and effective approach in ASP.NET MVC (or other MVC frameworks) for passing multiple pieces of data to a View. This approach offers several advantages: 1. **Organized Structure**: It keeps related data together, which can make your code cl...
24,264
[ { "from": "human", "value": "I think I know the answer, but I would like to bounce around some ideas.\nI would like to pass several (in this instance 2) somewhat different pieces of data to a View. My initial thought is simply to wrap-up the various objects into a containing object and pass them along that...
I'm going to make my monthly trip to the bookstore soon and I'm kind of interested in learning some user interface and/or design stuff - mostly web related, what are some good books I should look at? One that I've seen come up frequently in the past is Don't Make Me Think, which looks promising. I'm aware of the fact t...
It's great that you're interested in learning about user interface (UI) and user experience (UX) design! Here are some recommended books and online resources that you might find helpful: ### Books 1. **"Don't Make Me Think" by Steve Krug** This classic book is a must-read for anyone interested in web usability. ...
31,334
[ { "from": "human", "value": "I'm going to make my monthly trip to the bookstore soon and I'm kind of interested in learning some user interface and/or design stuff - mostly web related, what are some good books I should look at? One that I've seen come up frequently in the past is Don't Make Me Think, which...
Is it possible to break at runtime when a particular file has been modified? ie. monitor the file and break into a debugger once a change has been made to it. This is for a windows app...is this possible in visual studio or windbg? edit: i should have mentioned that this is for a Win32 app..
Yes, it's possible to monitor a file for changes and break into a debugger when a modification is detected. Here are some approaches you can take using Visual Studio or WinDbg for a Win32 application. ### Using Visual Studio 1. **FileSystemWatcher in Managed Code**: If your application is a .NET application, you coul...
28,180
[ { "from": "human", "value": "Is it possible to break at runtime when a particular file has been modified? \nie. monitor the file and break into a debugger once a change has been made to it.\nThis is for a windows app...is this possible in visual studio or windbg?\nedit: i should have mentioned that this i...
I created a module for dotnetnuke that uses Atalasoft's dotImage viewer. dotImage uses and iframe for "ajax" rendering. My module works great on the home page but in any other page the module loads the whole home page in the dotImage iframe. Has anybody worked with both dotnetnuke and dotImage? Any tips?
It sounds like you're encountering an issue with how the iframe is handling URLs when navigating between pages in your DotNetNuke (DNN) site. When you notice that the dotImage viewer is loading the entire home page in the iframe on other pages, it typically indicates a problem with the URL being passed to the iframe. ...
28,348
[ { "from": "human", "value": "I created a module for dotnetnuke that uses Atalasoft's dotImage viewer. dotImage uses and iframe for \"ajax\" rendering. My module works great on the home page but in any other page the module loads the whole home page in the dotImage iframe.\nHas anybody worked with both d...
I'm using JMX to save some diagnostic information from a remote process. Looking at the interface in jconsole shows that the return type is CompositeData (the data actually comes back as CompositeDataSupport). I want to output all the key/value pairs that are associated with this object. The problem is that the interfa...
In JMX, `CompositeData` and its implementation `CompositeDataSupport` are used to represent structured data with key-value pairs, but you are right that `CompositeData` does not provide a direct method for retrieving the keys. Instead, you can use the `getCompositeType()` method to obtain the `CompositeType`, which pro...
33,714
[ { "from": "human", "value": "I'm using JMX to save some diagnostic information from a remote process. Looking at the interface in jconsole shows that the return type is CompositeData (the data actually comes back as CompositeDataSupport). I want to output all the key/value pairs that are associated with thi...
I've inherited a ASP/VB6 code base (not my forte... yet) and I'm trying tease it apart to figure out the cause on an error message I'm receiving when running the app. I've traced it back through an event that is being raised in on of my classes. Is there away in windows I can search the bulk of the code base for where ...
When working with ASP/VB6 code, finding where a specific event is being consumed can be a bit challenging if the IDE's built-in search functions (like Ctrl-F) are insufficient. Here are some strategies you can use within the VB6 IDE, as well as a suggestion for using external tools: ### 1. Using the VB6 IDE: - **Searc...
32,742
[ { "from": "human", "value": "I've inherited a ASP/VB6 code base (not my forte... yet) and I'm trying tease it apart to figure out the cause on an error message I'm receiving when running the app.\nI've traced it back through an event that is being raised in on of my classes. Is there away in windows I can s...
So if i am setting up a yahoo pipes badge on my site, yahoo gives me this code <script src="http://pipes.yahoo.com/js/listbadge.js">{"pipe_id":"USER_ID","_btype":"list"}</script> Notice its passing an object literal to the remote script. i would like to do something similar with my own scripts, how do you interact w...
To achieve similar functionality with your own scripts as Yahoo Pipes does with its `listbadge.js`, you can use a few different methods to handle the input that's passed to your script. Below, I'll outline a straightforward approach. ### Step 1: Create Your JavaScript File Let's assume your script is named `myscript....
33,508
[ { "from": "human", "value": "So if i am setting up a yahoo pipes badge on my site, yahoo gives me this code\n<script src=\"http://pipes.yahoo.com/js/listbadge.js\">{\"pipe_id\":\"USER_ID\",\"_btype\":\"list\"}</script>\n\nNotice its passing an object literal to the remote script. \ni would like to do somet...
I have build plenty of SOAP webservices, but am building a REST webservice for a specific project, and I was wondering what people used for a 'WSDL' for REST services or if it is even needed.
In the SOAP world, WSDL (Web Services Description Language) is a standard format for describing the services, operations, and message formats that a web service provides. However, RESTful web services do not use WSDL. Instead, REST is typically described using other formats and documentation practices. Here are some co...
33,133
[ { "from": "human", "value": "I have build plenty of SOAP webservices, but am building a REST webservice for a specific project, and I was wondering what people used for a 'WSDL' for REST services or if it is even needed.\n" }, { "from": "gpt", "value": "In the SOAP world, WSDL (Web Services Desc...
I like to keep my websites extremely light and fast, but of course I need some kind of user tracking and analytics. It seems like Google Analytics always takes significant enough processing time that I'd like to replace it with something faster (and/or hosted locally), perhaps having less features. I really only care...
If you're looking for lightweight and fast alternatives to Google Analytics while still capturing essential metrics, there are several options you can consider. Many of these options focus on privacy, simplicity, and performance. Here are some suggestions: 1. **Matomo (formerly Piwik)**: - Self-hosted or cloud-host...
33,525
[ { "from": "human", "value": "I like to keep my websites extremely light and fast, but of course I need some kind of user tracking and analytics. \nIt seems like Google Analytics always takes significant enough processing time that I'd like to replace it with something faster (and/or hosted locally), perhaps...
What's the most elegant templating (preferably in pure PHP!) solution you've seen? Specifically i'm interested in handling: Detecting in a repeating block whether it's the first or last element Easy handling of odd/even cases, like a zebra striped table, or similar Other modulos logic, where you'd do something every n...
Absolutely, you can achieve a cleaner templating style in pure PHP while still handling the complexities of detecting first/last elements, odd/even classes, and other modulo logic. A more elegant solution can be designed using PHP's syntax in a way that reduces the need for excessive opening and closing PHP tags. Below...
24,801
[ { "from": "human", "value": "What's the most elegant templating (preferably in pure PHP!) solution you've seen?\nSpecifically i'm interested in handling:\n\nDetecting in a repeating block whether it's the first or last element\nEasy handling of odd/even cases, like a zebra striped table, or similar\nOther m...
With CSS bugs, do you fix them as and when they arise during each stage of your development, or do you save them up till the end? as I'm at quite an early stage in a large project and seem to be getting bogged down with annoying IE6 bugs.
When dealing with CSS bugs, especially in a large project, it can be beneficial to adopt a strategy that works for your workflow and the scale of the project. Here are some approaches to consider: ### 1. **Fix as You Go** - **Pros**: - Keeps your code clean and reduces the number of issues piling up. - Makes it e...
31,572
[ { "from": "human", "value": "With CSS bugs, do you fix them as and when they arise during each stage of your development, or do you save them up till the end? as I'm at quite an early stage in a large project and seem to be getting bogged down with annoying IE6 bugs.\n" }, { "from": "gpt", "valu...
In C#, I want to initialize a string value with an empty string. How should I do this? What is the right way, and why? string willi = string.Empty; or string willi = String.Empty; or string willi = ""; or what?
In C#, you can initialize a string with an empty value using any of the following methods: 1. **Using `string.Empty`**: ```csharp string willi = string.Empty; ``` or ```csharp string willi = String.Empty; // 'String' is the class name, this is also valid. ``` 2. **Using an empty string literal**:...
29,069
[ { "from": "human", "value": "In C#, I want to initialize a string value with an empty string.\nHow should I do this? \nWhat is the right way, and why?\nstring willi = string.Empty;\n\nor\nstring willi = String.Empty;\n\nor\nstring willi = \"\";\n\nor what?\n" }, { "from": "gpt", "value": "In C#,...
I'm building some custom tools to work against a JIRA install, and the exposed SOAP API is great, except that none of the arguments are named. For example, the prototype for getIssue is: RemoteIssue getIssue (string in0, string in1); All of the SOAP RPC methods follow this convention, so without documentation I'm pret...
JIRA's SOAP API documentation has historically been sparse, and it's common for users to struggle with understanding the method signatures due to the lack of named parameters. However, here are some steps and resources that might help you figure out how to use the API effectively: 1. **Official Documentation**: Atlass...
33,673
[ { "from": "human", "value": "I'm building some custom tools to work against a JIRA install, and the exposed SOAP API is great, except that none of the arguments are named.\nFor example, the prototype for getIssue is:\nRemoteIssue getIssue (string in0, string in1);\n\nAll of the SOAP RPC methods follow this ...
Omitting details of methods to calculate primes, and methods of factorisation. Why bother to factorise ? What are its applications ?
Factorization is the process of breaking down an integer into its prime factors. While it may seem like a purely mathematical exercise, it has several important applications across various fields: 1. **Cryptography**: Many encryption algorithms, including RSA, rely on the difficulty of factoring large composite number...
33,989
[ { "from": "human", "value": "Omitting details of methods to calculate primes, and methods of factorisation.\nWhy bother to factorise ?\nWhat are its applications ?\n" }, { "from": "gpt", "value": "Factorization is the process of breaking down an integer into its prime factors. While it may seem ...
I would like to use the API to return all tweets that match my search query, but only tweets posted within the last five seconds. With Twitter's Search API, I can use the since_id to grab all tweets from a specific ID. However, I can't really see a good way to find the tweet ID to begin from. I'm also aware that you ca...
To achieve your goal of fetching tweets posted within the last five seconds using Twitter's API, you may have to employ a combination of the Twitter API v2 endpoints and manage timing yourself, since the Search API does not support real-time streaming or fetching tweets based on a precise time interval. Here's a gener...
29,956
[ { "from": "human", "value": "I would like to use the API to return all tweets that match my search query, but only tweets posted within the last five seconds.\nWith Twitter's Search API, I can use the since_id to grab all tweets from a specific ID. However, I can't really see a good way to find the tweet ID...
I have the following hierachy: public class A { protected class B { } } And I've tried to define a default style in the following ways (inside generic.xaml): <Style TargetType="local:A+B"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="local:A+B"> ...
In WPF, when you're dealing with nested classes and want to define a style for a nested type, you need to make sure you're referencing the type correctly in your XAML. Since `B` is a nested class within `A`, the correct way to reference `B` in XAML would be `local:A+B` where `local` is the XML namespace prefix you have...
34,131
[ { "from": "human", "value": "I have the following hierachy:\npublic class A\n{\n protected class B\n {\n }\n}\n\nAnd I've tried to define a default style in the following ways (inside generic.xaml):\n<Style TargetType=\"local:A+B\">\n <Setter Property=\"Template\">\n <Setter.Value>\n ...
What is the best way to unit test a method that doesn't return anything? Specifically in c#. What I am really trying to test is a method that takes a log file and parses it for specific strings. The strings are then inserted into a database. Nothing that hasn't been done before but being VERY new to TDD I am wondering ...
Unit testing a method that doesn't return any value (void method) is certainly possible and can be effectively done in C#. When testing such methods, you'll usually focus on verifying the side effects of the method. In your case, since the method parses a log file and inserts specific strings into a database, you want ...
28,355
[ { "from": "human", "value": "What is the best way to unit test a method that doesn't return anything? Specifically in c#.\nWhat I am really trying to test is a method that takes a log file and parses it for specific strings. The strings are then inserted into a database. Nothing that hasn't been done before...
I want to read and write from serial using events/interrupts. Currently, I have it in a while loop and it continuously reads and writes through the serial. I want it to only read when something comes from the serial port. How do I implement this in C++? This is my current code: while(true) { //read ...
To implement serial communication using events/interrupts in C++, you can use the Windows API functions to set up an event-driven approach instead of a continuous polling loop. The basic idea is to create an event that triggers when data is available to read from the serial port, and then handle the reading and writing...
26,728
[ { "from": "human", "value": "I want to read and write from serial using events/interrupts.\nCurrently, I have it in a while loop and it continuously reads and writes through the serial. I want it to only read when something comes from the serial port. How do I implement this in C++?\nThis is my current co...
You can structure a C++ program so that (almost) all the code resides in Header files. It essentially looks like a C# or Java program. However, you do need at least one .cpp file to pull in all the header files when compiling. Now I know some people would absolutely detest this idea. But I haven't found any convincing ...
Your suggestion to structure a C++ program with most of the code residing in header files and minimizing the use of .cpp files is an interesting approach. While there are certain advantages to this methodology, there are also some notable downsides to consider. Let’s go over both sides: ### Advantages: 1. **Faster Co...
30,177
[ { "from": "human", "value": "You can structure a C++ program so that (almost) all the code resides in Header files. It essentially looks like a C# or Java program. However, you do need at least one .cpp file to pull in all the header files when compiling. Now I know some people would absolutely detest this ...